-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into ft/add-bulk-meter-api
- Loading branch information
Showing
34 changed files
with
17,806 additions
and
1,533 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const parseMetadata = ( | ||
metadata: Record<string, unknown>, | ||
): any | null => { | ||
try { | ||
if (typeof metadata !== 'string') return metadata; | ||
return JSON.parse(metadata); | ||
} catch (e) { | ||
console.error(e, `certificate doesnt contains valid metadata ${metadata}`); | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
InfluxDB, | ||
Point, | ||
QueryApi, | ||
WriteApi, | ||
} from '@influxdata/influxdb-client'; | ||
|
||
const dbConfig = { | ||
url: process.env.INFLUXDB_URL || 'http://localhost:8086', | ||
token: process.env.INFLUXDB_TOKEN || 'admin:admin', | ||
}; | ||
|
||
const dbWriter = (): WriteApi => { | ||
return new InfluxDB(dbConfig).getWriteApi( | ||
process.env.INFLUXDB_ORG || '', | ||
process.env.INFLUXDB_BUCKET, | ||
); | ||
}; | ||
|
||
const dbReader = (): QueryApi => { | ||
return new InfluxDB(dbConfig).getQueryApi(process.env.INFLUXDB_ORG || ''); | ||
}; | ||
|
||
const writePoints = async (points: Point[]): Promise<void> => { | ||
const writer = dbWriter(); | ||
writer.writePoints(points); | ||
await writer.close(); | ||
}; | ||
|
||
const executeQuery = async (query: string): Promise<any[]> => { | ||
const reader = dbReader(); | ||
const results = await reader.collectRows(query); | ||
return results; | ||
}; | ||
|
||
export { dbReader, dbWriter, writePoints, executeQuery }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Role } from '../utils/enums'; | ||
import { ILoggedInUser, IUser } from '../models'; | ||
import { Organization } from '../pods/organization/organization.entity'; | ||
|
||
export const canManageOrganization = ({ | ||
user, | ||
organization, | ||
organizationAdmin, | ||
}: { | ||
user: ILoggedInUser; | ||
organizationAdmin: IUser; | ||
organization: Organization; | ||
}): boolean => { | ||
if (!organization) return false; | ||
|
||
if (user.role !== Role.ApiUser) { | ||
return user.organizationId === organization.id; | ||
} | ||
|
||
if (organizationAdmin.api_user_id !== user.api_user_id) { | ||
return false; | ||
} | ||
|
||
if (organizationAdmin.role !== Role.OrganizationAdmin) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.