@spytecgps/nova-orm 1.0.76 → 1.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/entities/blacklist.d.ts +1 -1
  2. package/dist/entities/blacklist.js.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/repositories/blacklist/deleteBlackList.d.ts +4 -0
  5. package/dist/repositories/blacklist/deleteBlackList.js +20 -0
  6. package/dist/repositories/blacklist/deleteBlackList.js.map +1 -0
  7. package/dist/repositories/blacklist/index.d.ts +31 -1
  8. package/dist/repositories/blacklist/index.js +51 -0
  9. package/dist/repositories/blacklist/index.js.map +1 -1
  10. package/dist/repositories/blacklist/updateBlackList.d.ts +4 -0
  11. package/dist/repositories/blacklist/updateBlackList.js +31 -0
  12. package/dist/repositories/blacklist/updateBlackList.js.map +1 -0
  13. package/dist/repositories/blacklist/upsertBlackList.d.ts +5 -0
  14. package/dist/repositories/blacklist/upsertBlackList.js +41 -0
  15. package/dist/repositories/blacklist/upsertBlackList.js.map +1 -0
  16. package/dist/repositories/deviceTypeFeature/bulkCreateDeviceTypeFeature.d.ts +5 -0
  17. package/dist/repositories/deviceTypeFeature/bulkCreateDeviceTypeFeature.js +20 -0
  18. package/dist/repositories/deviceTypeFeature/bulkCreateDeviceTypeFeature.js.map +1 -0
  19. package/dist/repositories/deviceTypeFeature/deleteDeviceTypeFeature.d.ts +4 -0
  20. package/dist/repositories/deviceTypeFeature/deleteDeviceTypeFeature.js +22 -0
  21. package/dist/repositories/deviceTypeFeature/deleteDeviceTypeFeature.js.map +1 -0
  22. package/dist/repositories/deviceTypeFeature/getDeviceTypeFeatures.d.ts +4 -0
  23. package/dist/repositories/deviceTypeFeature/getDeviceTypeFeatures.js +25 -0
  24. package/dist/repositories/deviceTypeFeature/getDeviceTypeFeatures.js.map +1 -0
  25. package/dist/repositories/deviceTypeFeature/index.d.ts +27 -0
  26. package/dist/repositories/deviceTypeFeature/index.js +48 -0
  27. package/dist/repositories/deviceTypeFeature/index.js.map +1 -0
  28. package/dist/repositories/features/createFeature.d.ts +5 -0
  29. package/dist/repositories/features/createFeature.js +21 -0
  30. package/dist/repositories/features/createFeature.js.map +1 -0
  31. package/dist/repositories/features/deleteFeature.d.ts +4 -0
  32. package/dist/repositories/features/deleteFeature.js +17 -0
  33. package/dist/repositories/features/deleteFeature.js.map +1 -0
  34. package/dist/repositories/features/getFeatures.d.ts +4 -0
  35. package/dist/repositories/features/getFeatures.js +25 -0
  36. package/dist/repositories/features/getFeatures.js.map +1 -0
  37. package/dist/repositories/features/index.d.ts +33 -0
  38. package/dist/repositories/features/index.js +61 -0
  39. package/dist/repositories/features/index.js.map +1 -0
  40. package/dist/repositories/features/upsertFeature.d.ts +4 -0
  41. package/dist/repositories/features/upsertFeature.js +23 -0
  42. package/dist/repositories/features/upsertFeature.js.map +1 -0
  43. package/dist/repositories/index.d.ts +3 -1
  44. package/dist/repositories/index.js +3 -1
  45. package/dist/repositories/index.js.map +1 -1
  46. package/dist/types/blacklist.d.ts +24 -0
  47. package/dist/types/deviceTypeFeature.d.ts +23 -0
  48. package/dist/types/deviceTypeFeature.js +4 -0
  49. package/dist/types/deviceTypeFeature.js.map +1 -0
  50. package/dist/types/feature.d.ts +20 -0
  51. package/dist/types/feature.js +3 -0
  52. package/dist/types/feature.js.map +1 -0
  53. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { DeleteBlacklistParams } from '../../types/blacklist';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const deleteBlackList: (novaDataSource: NovaDataSource, params: DeleteBlacklistParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,20 @@
1
+ import { Blacklist } from '../../entities';
2
+ export const deleteBlackList = async (novaDataSource, params, logger) => {
3
+ if (!params?.filters?.blacklistTypeId || !params?.filters?.value) {
4
+ logger.warn({ params }, 'BlacklistRepository::deleteBlackList - missing required parameters');
5
+ return null;
6
+ }
7
+ return novaDataSource.safeQuery(async (dataSource) => {
8
+ const blacklistRepository = dataSource.getRepository(Blacklist);
9
+ const result = await blacklistRepository
10
+ .createQueryBuilder()
11
+ .delete()
12
+ .where('blacklistTypeId = :blacklistTypeId', {
13
+ blacklistTypeId: params.filters.blacklistTypeId,
14
+ })
15
+ .andWhere('value = :value', { value: params.filters.value })
16
+ .execute();
17
+ return result.affected > 0;
18
+ }, 'BlacklistRepository::deleteBlackList');
19
+ };
20
+ //# sourceMappingURL=deleteBlackList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteBlackList.js","sourceRoot":"","sources":["../../../src/repositories/blacklist/deleteBlackList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,cAA8B,EAC9B,MAA6B,EAC7B,MAAc,EACI,EAAE;IACpB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;QAChE,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,oEAAoE,CAAC,CAAA;QAC7F,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,UAA0B,EAAoB,EAAE;QACrF,MAAM,mBAAmB,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAE/D,MAAM,MAAM,GAAG,MAAM,mBAAmB;aACrC,kBAAkB,EAAE;aACpB,MAAM,EAAE;aACR,KAAK,CAAC,oCAAoC,EAAE;YAC3C,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe;SAChD,CAAC;aACD,QAAQ,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;aAC3D,OAAO,EAAE,CAAA;QAEZ,OAAO,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAA;IAC5B,CAAC,EAAE,sCAAsC,CAAC,CAAA;AAC5C,CAAC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { Blacklist } from '../../entities';
2
- import { GetBlacklistsParams } from '../../types/blacklist';
2
+ import { DeleteBlacklistParams, GetBlacklistsParams, UpdateBlacklistParams, UpsertBlacklistParams } from '../../types/blacklist';
3
3
  import { BaseRepository } from '../baseRepository';
4
4
  export declare class BlacklistRepository extends BaseRepository {
5
5
  /**
@@ -10,4 +10,34 @@ export declare class BlacklistRepository extends BaseRepository {
10
10
  * @returns The blacklists information
11
11
  */
12
12
  getBlacklists(params: GetBlacklistsParams): Promise<Blacklist[]>;
13
+ /**
14
+ * Upsert blacklist
15
+ * @param {UpsertBlacklistParams} params containing information to upsert blacklist
16
+ * - blacklistTypeId The blacklist type id
17
+ * - value The value
18
+ * - notes The notes
19
+ * - createdBy The created by
20
+ * @returns The upserted blacklist information
21
+ */
22
+ upsertBlacklist(params: UpsertBlacklistParams): Promise<Blacklist>;
23
+ /**
24
+ * Update blacklist
25
+ * @param {UpdateBlacklistParams} params containing information to update blacklist
26
+ * - filters.blacklistTypeId The blacklist type id
27
+ * - filters.value The value
28
+ * - values.blacklistTypeId The blacklist type id
29
+ * - values.value The value
30
+ * - values.notes The notes
31
+ * - values.modifiedBy The modified by
32
+ * @returns Whether the blacklist was updated
33
+ */
34
+ updateBlacklist(params: UpdateBlacklistParams): Promise<boolean>;
35
+ /**
36
+ * Delete blacklist
37
+ * @param {DeleteBlacklistParams} params containing information to delete blacklist
38
+ * - filters.blacklistTypeId The blacklist type id
39
+ * - filters.value The value
40
+ * @returns Whether the blacklist was deleted
41
+ */
42
+ deleteBlacklist(params: DeleteBlacklistParams): Promise<boolean>;
13
43
  }
@@ -1,6 +1,9 @@
1
1
  import { NovaDataSource } from '../../novaDataSource';
2
2
  import { BaseRepository } from '../baseRepository';
3
+ import { deleteBlackList } from './deleteBlackList';
3
4
  import { getBlacklists } from './getBlacklists';
5
+ import { updateBlackList } from './updateBlackList';
6
+ import { upsertBlackList } from './upsertBlackList';
4
7
  export class BlacklistRepository extends BaseRepository {
5
8
  /**
6
9
  * Get blacklists
@@ -16,5 +19,53 @@ export class BlacklistRepository extends BaseRepository {
16
19
  this.logger.trace(result, 'BlacklistRepository::getBlacklists result');
17
20
  return result;
18
21
  }
22
+ /**
23
+ * Upsert blacklist
24
+ * @param {UpsertBlacklistParams} params containing information to upsert blacklist
25
+ * - blacklistTypeId The blacklist type id
26
+ * - value The value
27
+ * - notes The notes
28
+ * - createdBy The created by
29
+ * @returns The upserted blacklist information
30
+ */
31
+ async upsertBlacklist(params) {
32
+ this.logger.trace(params, 'BlacklistRepository::upsertBlacklist started with params');
33
+ const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
34
+ const result = await upsertBlackList(novaDataSource, params, this.logger);
35
+ this.logger.trace(result, 'BlacklistRepository::upsertBlacklist result');
36
+ return result;
37
+ }
38
+ /**
39
+ * Update blacklist
40
+ * @param {UpdateBlacklistParams} params containing information to update blacklist
41
+ * - filters.blacklistTypeId The blacklist type id
42
+ * - filters.value The value
43
+ * - values.blacklistTypeId The blacklist type id
44
+ * - values.value The value
45
+ * - values.notes The notes
46
+ * - values.modifiedBy The modified by
47
+ * @returns Whether the blacklist was updated
48
+ */
49
+ async updateBlacklist(params) {
50
+ this.logger.trace(params, 'BlacklistRepository::updateBlacklist started with params');
51
+ const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
52
+ const result = await updateBlackList(novaDataSource, params, this.logger);
53
+ this.logger.trace({ result }, 'BlacklistRepository::updateBlacklist result');
54
+ return result;
55
+ }
56
+ /**
57
+ * Delete blacklist
58
+ * @param {DeleteBlacklistParams} params containing information to delete blacklist
59
+ * - filters.blacklistTypeId The blacklist type id
60
+ * - filters.value The value
61
+ * @returns Whether the blacklist was deleted
62
+ */
63
+ async deleteBlacklist(params) {
64
+ this.logger.trace(params, 'BlacklistRepository::deleteBlacklist started with params');
65
+ const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
66
+ const result = await deleteBlackList(novaDataSource, params, this.logger);
67
+ this.logger.trace({ result }, 'BlacklistRepository::deleteBlacklist result');
68
+ return result;
69
+ }
19
70
  }
20
71
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/blacklist/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,MAA2B;QAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,wDAAwD,CAAC,CAAA;QAEnF,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,2BAA2B,CACjC,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEvE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,2CAA2C,CAAC,CAAA;QAEtE,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/blacklist/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAOrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA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A0D,CAAC,CAAA;QAErF,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,2BAA2B,CACjC,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEzE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,6CAA6C,CAAC,CAAA;QAE5E,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,MAA6B;QACjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,0DAA0D,CAAC,CAAA;QAErF,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,2BAA2B,CACjC,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEzE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,6CAA6C,CAAC,CAAA;QAE5E,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { UpdateBlacklistParams } from '../../types/blacklist';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const updateBlackList: (novaDataSource: NovaDataSource, params: UpdateBlacklistParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,31 @@
1
+ import { Blacklist } from '../../entities';
2
+ export const updateBlackList = async (novaDataSource, params, logger) => {
3
+ if (!params?.filters?.blacklistTypeId ||
4
+ !params?.filters?.value ||
5
+ !params?.values?.blacklistTypeId ||
6
+ !params?.values?.value) {
7
+ logger.warn({ params }, 'BlacklistRepository::updateBlackList - missing required parameters');
8
+ return null;
9
+ }
10
+ return novaDataSource.safeQuery(async (dataSource) => {
11
+ const blacklistRepository = dataSource.getRepository(Blacklist);
12
+ const now = new Date();
13
+ const result = await blacklistRepository
14
+ .createQueryBuilder()
15
+ .update(Blacklist)
16
+ .set({
17
+ blacklistTypeId: params.values.blacklistTypeId,
18
+ value: params.values.value,
19
+ notes: params.values.notes,
20
+ modifiedBy: params.values.modifiedBy,
21
+ modifiedAt: now,
22
+ })
23
+ .where('blacklistTypeId = :blacklistTypeId', {
24
+ blacklistTypeId: params.filters.blacklistTypeId,
25
+ })
26
+ .andWhere('value = :value', { value: params.filters.value })
27
+ .execute();
28
+ return result.affected > 0;
29
+ }, 'BlacklistRepository::updateBlackList');
30
+ };
31
+ //# sourceMappingURL=updateBlackList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateBlackList.js","sourceRoot":"","sources":["../../../src/repositories/blacklist/updateBlackList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,cAA8B,EAC9B,MAA6B,EAC7B,MAAc,EACI,EAAE;IACpB,IACE,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe;QACjC,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;QACvB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe;QAChC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EACtB;QACA,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,oEAAoE,CAAC,CAAA;QAC7F,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,UAA0B,EAAoB,EAAE;QACrF,MAAM,mBAAmB,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAE/D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;QAEtB,MAAM,MAAM,GAAG,MAAM,mBAAmB;aACrC,kBAAkB,EAAE;aACpB,MAAM,CAAC,SAAS,CAAC;aACjB,GAAG,CAAC;YACH,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe;YAC9C,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;YAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;YAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;YACpC,UAAU,EAAE,GAAG;SAChB,CAAC;aACD,KAAK,CAAC,oCAAoC,EAAE;YAC3C,eAAe,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe;SAChD,CAAC;aACD,QAAQ,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;aAC3D,OAAO,EAAE,CAAA;QAEZ,OAAO,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAA;IAC5B,CAAC,EAAE,sCAAsC,CAAC,CAAA;AAC5C,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { Blacklist } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { UpsertBlacklistParams } from '../../types/blacklist';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const upsertBlackList: (novaDataSource: NovaDataSource, params: UpsertBlacklistParams, logger: Logger) => Promise<Blacklist>;
@@ -0,0 +1,41 @@
1
+ import { Blacklist } from '../../entities';
2
+ export const upsertBlackList = async (novaDataSource, params, logger) => {
3
+ // id is required
4
+ if (!params?.blacklistTypeId || !params?.value || !params?.createdBy) {
5
+ logger.warn({ params }, 'BlacklistRepository::upsertBlackList - missing required parameters');
6
+ return null;
7
+ }
8
+ return novaDataSource.safeQuery(async (dataSource) => {
9
+ const blacklistRepository = dataSource.getRepository(Blacklist);
10
+ const existingBlackList = await blacklistRepository.findOne({
11
+ where: {
12
+ blacklistTypeId: params.blacklistTypeId,
13
+ value: params.value,
14
+ },
15
+ });
16
+ const now = new Date();
17
+ const blackList = {
18
+ ...existingBlackList,
19
+ blacklistTypeId: params.blacklistTypeId,
20
+ value: params.value,
21
+ notes: params.notes,
22
+ createdBy: existingBlackList ? existingBlackList.createdBy : params.createdBy,
23
+ createdAt: existingBlackList ? existingBlackList.createdAt : now,
24
+ modifiedBy: existingBlackList ? params.createdBy : null,
25
+ modifiedAt: existingBlackList ? now : null,
26
+ };
27
+ const upsertResult = await blacklistRepository.upsert(blackList, {
28
+ conflictPaths: ['blacklistTypeId', 'value'],
29
+ });
30
+ const result = upsertResult?.raw?.affectedRows > 0
31
+ ? await blacklistRepository.findOne({
32
+ where: {
33
+ blacklistTypeId: params.blacklistTypeId,
34
+ value: params.value,
35
+ },
36
+ })
37
+ : null;
38
+ return result;
39
+ }, 'BlacklistRepository::upsertBlackList');
40
+ };
41
+ //# sourceMappingURL=upsertBlackList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upsertBlackList.js","sourceRoot":"","sources":["../../../src/repositories/blacklist/upsertBlackList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAK1C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,cAA8B,EAC9B,MAA6B,EAC7B,MAAc,EACM,EAAE;IACtB,iBAAiB;IACjB,IAAI,CAAC,MAAM,EAAE,eAAe,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE;QACpE,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,oEAAoE,CAAC,CAAA;QAC7F,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,UAA0B,EAAsB,EAAE;QACvF,MAAM,mBAAmB,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAE/D,MAAM,iBAAiB,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC;YAC1D,KAAK,EA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{ BulkCreateDeviceTypeFeatureParams } from '../../types/deviceTypeFeature';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const bulkCreateDeviceTypeFeature: (novaDataSource: NovaDataSource, params: BulkCreateDeviceTypeFeatureParams, logger: Logger) => Promise<DeviceTypeFeature[]>;
@@ -0,0 +1,20 @@
1
+ import { DeviceTypeFeature } from '../../entities';
2
+ import { requiredBulkCreateDeviceTypeFeatureParamsAttributes, } from '../../types/deviceTypeFeature';
3
+ import { anyAttributeInArrayIsNull } from '../../utils/paramsValidators';
4
+ export const bulkCreateDeviceTypeFeature = async (novaDataSource, params, logger) => {
5
+ if (anyAttributeInArrayIsNull(params.items, requiredBulkCreateDeviceTypeFeatureParamsAttributes)) {
6
+ logger.warn({ params }, 'DeviceTypeFeatureRepository::bulkCreateDeviceTypeFeature missing required parameters');
7
+ return [];
8
+ }
9
+ return novaDataSource.safeQuery(async (safeDataSource) => {
10
+ const deviceTypeFeatureRepository = safeDataSource.getRepository(DeviceTypeFeature);
11
+ const newFeatures = params.items.map(item => ({
12
+ deviceTypeId: item.deviceTypeId,
13
+ featureKey: item.featureKey,
14
+ value: item.value,
15
+ }));
16
+ const createdFeature = await deviceTypeFeatureRepository.save(newFeatures);
17
+ return createdFeature ?? [];
18
+ }, 'DeviceTypeFeatureRepository::bulkCreateDeviceTypeFeature error');
19
+ };
20
+ //# sourceMappingURL=bulkCreateDeviceTypeFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkCreateDeviceTypeFeature.js","sourceRoot":"","sources":["../../../src/repositories/deviceTypeFeature/bulkCreateDeviceTypeFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAEL,mDAAmD,GACpD,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAExE,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAC9C,cAA8B,EAC9B,MAAyC,EACzC,MAAc,EACd,EAAE;IACF,IACE,yBAAyB,CAAC,MAAM,CAAC,KAAK,EAAE,mDAAmD,CAAC,EAC5F;QACA,MAAM,CAAC,IAAI,CACT,EAAE,MAAM,EAAE,EACV,sFAAsF,CACvF,CAAA;QACD,OAAO,EAAE,CAAA;KACV;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,cAA8B,EAEnE,EAAE;QACF,MAAM,2BAA2B,GAAG,cAAc,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAEnF,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAClC,IAAI,CAAC,EAAE,CACL,CAAC;YACC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;SACI,CAAA,CAC1B,CAAA;QAED,MAAM,cAAc,GAAG,MAAM,2BAA2B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAE1E,OAAO,cAAc,IAAI,EAAE,CAAA;IAC7B,CAAC,EAAE,gEAAgE,CAAC,CAAA;AACtE,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { DeleteDeviceTypeFeatureParams } from '../../types/deviceTypeFeature';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const deleteDeviceTypeFeature: (novaDataSource: NovaDataSource, params: DeleteDeviceTypeFeatureParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,22 @@
1
+ import { DeviceTypeFeature } from '../../entities';
2
+ import { oneRequiredDeleteDeviceTypeFeatureParamsAttributes, } from '../../types/deviceTypeFeature';
3
+ import { allAttributesAreNull } from '../../utils/paramsValidators';
4
+ export const deleteDeviceTypeFeature = async (novaDataSource, params, logger) => {
5
+ if (allAttributesAreNull(params.filters, oneRequiredDeleteDeviceTypeFeatureParamsAttributes)) {
6
+ logger.warn({ params }, 'DeviceTypeFeatureRepository::deleteDeviceTypeFeature missing required parameters');
7
+ return false;
8
+ }
9
+ return novaDataSource.safeQuery(async (dataSource) => {
10
+ const featureRepository = dataSource.getRepository(DeviceTypeFeature);
11
+ const result = await featureRepository
12
+ .createQueryBuilder()
13
+ .delete()
14
+ .where('COALESCE(:deviceTypeId, deviceTypeId) = deviceTypeId AND COALESCE(:featureKey, featureKey) = featureKey', {
15
+ deviceTypeId: params.filters.deviceTypeId,
16
+ featureKey: params.filters.featureKey,
17
+ })
18
+ .execute();
19
+ return result.affected > 0;
20
+ }, 'FeatureRepository::deleteFeature');
21
+ };
22
+ //# sourceMappingURL=deleteDeviceTypeFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteDeviceTypeFeature.js","sourceRoot":"","sources":["../../../src/repositories/deviceTypeFeature/deleteDeviceTypeFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAEL,kDAAkD,GACnD,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAEnE,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,cAA8B,EAC9B,MAAqC,EACrC,MAAc,EACI,EAAE;IACpB,IAAI,oBAAoB,CAAC,MAAM,CAAC,OAAO,EAAE,kDAAkD,CAAC,EAAE;QAC5F,MAAM,CAAC,IAAI,CACT,EAAE,MAAM,EAAE,EACV,kFAAkF,CACnF,CAAA;QACD,OAAO,KAAK,CAAA;KACb;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,UAA0B,EAAoB,EAAE;QACrF,MAAM,iBAAiB,GAAG,UAAU,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAErE,MAAM,MAAM,GAAG,MAAM,iBAAiB;aACnC,kBAAkB,EAAE;aACpB,MAAM,EAAE;aACR,KAAK,CACJ,yGAAyG,EACzG;YACE,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY;YACzC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU;SACtC,CACF;aACA,OAAO,EAAE,CAAA;QAEZ,OAAO,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAA;IAC5B,CAAC,EAAE,kCAAkC,CAAC,CAAA;AACxC,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { DeviceTypeFeature } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetDeviceTypeFeaturesParams } from '../../types/deviceTypeFeature';
4
+ export declare const getDeviceTypeFeatures: (novaDataSource: NovaDataSource, params: GetDeviceTypeFeaturesParams) => Promise<DeviceTypeFeature[]>;
@@ -0,0 +1,25 @@
1
+ import { DeviceTypeFeature } from '../../entities';
2
+ export const getDeviceTypeFeatures = async (novaDataSource, params) => {
3
+ // Force the query to run on master or slave
4
+ const dbQueryRunner = novaDataSource.createQueryRunnerFromParams(params);
5
+ return novaDataSource.safeQuery(async (safeDataSource, queryRunner) => {
6
+ const deviceTypeFeatureRepository = safeDataSource.getRepository(DeviceTypeFeature);
7
+ const queryBuilder = deviceTypeFeatureRepository.createQueryBuilder('deviceTypeFeature');
8
+ if (queryRunner) {
9
+ queryBuilder.setQueryRunner(queryRunner);
10
+ }
11
+ if (params?.filters?.deviceTypeIds?.length) {
12
+ queryBuilder.where('deviceTypeFeature.deviceTypeId IN (:deviceTypeIdList)', {
13
+ deviceTypeIdList: params.filters.deviceTypeIds,
14
+ });
15
+ }
16
+ if (params?.filters?.featureKeys?.length) {
17
+ queryBuilder.andWhere('deviceTypeFeature.featureKey IN (:featureKeyList)', {
18
+ featureKeyList: params.filters.featureKeys,
19
+ });
20
+ }
21
+ const deviceTypeFeatures = await queryBuilder.getMany();
22
+ return deviceTypeFeatures?.length ? deviceTypeFeatures : [];
23
+ }, 'FeatureRepository::getFeatures error', dbQueryRunner);
24
+ };
25
+ //# sourceMappingURL=getDeviceTypeFeatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDeviceTypeFeatures.js","sourceRoot":"","sources":["../../../src/repositories/deviceTypeFeature/getDeviceTypeFeatures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIlD,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,cAA8B,EAC9B,MAAmC,EACL,EAAE;IAChC,4CAA4C;IAC5C,MAAM,aAAa,GAAG,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAA;IAExE,OAAO,cAAc,CAAC,SAAS,CAC7B,KAAK,EACH,cAA8B,EAC9B,WAAyB,EACK,EAAE;QAChC,MAAM,2BAA2B,GAAG,cAAc,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAEnF,MAAM,YAAY,GAAG,2BAA2B,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;QAExF,IAAI,WAAW,EAAE;YACf,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;SACzC;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE;YAC1C,YAAY,CAAC,KAAK,CAAC,uDAAuD,EAAE;gBAC1E,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa;aAC/C,CAAC,CAAA;SACH;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE;YACxC,YAAY,CAAC,QAAQ,CAAC,mDAAmD,EAAE;gBACzE,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW;aAC3C,CAAC,CAAA;SACH;QAED,MAAM,kBAAkB,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;QAEvD,OAAO,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAA;IAC7D,CAAC,EACD,sCAAsC,EACtC,aAAa,CACd,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { DeviceTypeFeature } from '../../entities';
2
+ import { BulkCreateDeviceTypeFeatureParams, DeleteDeviceTypeFeatureParams, GetDeviceTypeFeaturesParams } from '../../types/deviceTypeFeature';
3
+ import { BaseRepository } from '../baseRepository';
4
+ /**
5
+ * DeviceTypeFeatureRepository, used to interact with the deviceTypeFeature entity
6
+ * @extends BaseRepository
7
+ */
8
+ export declare class DeviceTypeFeatureRepository extends BaseRepository {
9
+ /**
10
+ * Create a device type feature
11
+ * @param {BulkCreateDeviceTypeFeatureParams} params containing information to create a device type feature
12
+ * @returns {DeviceTypeFeature} the created device type feature
13
+ * */
14
+ bulkCreateDeviceTypeFeature(params: BulkCreateDeviceTypeFeatureParams): Promise<DeviceTypeFeature[]>;
15
+ /**
16
+ * Get device type features
17
+ * @param {GetDeviceTypeFeaturesParams} params containing information to get device type features
18
+ * @returns {DeviceTypeFeature[]} the device type features
19
+ */
20
+ getDeviceTypeFeatures(params?: GetDeviceTypeFeaturesParams): Promise<DeviceTypeFeature[]>;
21
+ /**
22
+ * Delete device type feature
23
+ * @param {DeleteDeviceTypeFeatureParams} params containing information to delete the device type feature
24
+ * @returns {boolean} if the device type feature were deleted
25
+ * */
26
+ deleteDeviceTypeFeature(params: DeleteDeviceTypeFeatureParams): Promise<boolean>;
27
+ }
@@ -0,0 +1,48 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { BaseRepository } from '../baseRepository';
3
+ import { bulkCreateDeviceTypeFeature } from './bulkCreateDeviceTypeFeature';
4
+ import { deleteDeviceTypeFeature } from './deleteDeviceTypeFeature';
5
+ import { getDeviceTypeFeatures } from './getDeviceTypeFeatures';
6
+ /**
7
+ * DeviceTypeFeatureRepository, used to interact with the deviceTypeFeature entity
8
+ * @extends BaseRepository
9
+ */
10
+ export class DeviceTypeFeatureRepository extends BaseRepository {
11
+ /**
12
+ * Create a device type feature
13
+ * @param {BulkCreateDeviceTypeFeatureParams} params containing information to create a device type feature
14
+ * @returns {DeviceTypeFeature} the created device type feature
15
+ * */
16
+ async bulkCreateDeviceTypeFeature(params) {
17
+ this.logger.trace(params, `DeviceTypeFeatureRepository::bulkCreateDeviceTypeFeature started with params`);
18
+ const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
19
+ const result = await bulkCreateDeviceTypeFeature(novaDataSource, params, this.logger);
20
+ this.logger.trace(result, 'DeviceTypeFeatureRepository::bulkCreateDeviceTypeFeature result');
21
+ return result;
22
+ }
23
+ /**
24
+ * Get device type features
25
+ * @param {GetDeviceTypeFeaturesParams} params containing information to get device type features
26
+ * @returns {DeviceTypeFeature[]} the device type features
27
+ */
28
+ async getDeviceTypeFeatures(params) {
29
+ this.logger.trace(params, `DeviceTypeFeatureRepository::getDeviceTypeFeatures started with params`);
30
+ const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
31
+ const result = await getDeviceTypeFeatures(novaDataSource, params);
32
+ this.logger.trace(result, 'DeviceTypeFeatureRepository::getDeviceTypeFeatures result');
33
+ return result;
34
+ }
35
+ /**
36
+ * Delete device type feature
37
+ * @param {DeleteDeviceTypeFeatureParams} params containing information to delete the device type feature
38
+ * @returns {boolean} if the device type feature were deleted
39
+ * */
40
+ async deleteDeviceTypeFeature(params) {
41
+ this.logger.trace(params, `DeviceTypeFeatureRepository::deleteDeviceTypeFeature started with params`);
42
+ const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger, this.replicaNovaDataSourceConfig);
43
+ const result = await deleteDeviceTypeFeature(novaDataSource, params, this.logger);
44
+ this.logger.trace({ result }, 'DeviceTypeFeatureRepository::deleteDeviceTypeFeature result');
45
+ return result;
46
+ }
47
+ }
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repositories/deviceTypeFeature/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAA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ACjE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,MAAM,EACN,0EAA0E,CAC3E,CAAA;QAED,MAAM,cAAc,GAAG,IAAI,cAAc,CACvC,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,2BAA2B,CACjC,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEjF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,6DAA6D,CAAC,CAAA;QAE5F,OAAO,MAAM,CAAA;IACf,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import { Feature } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { CreateFeatureParams } from '../../types/feature';
4
+ import { Logger } from '../../types/logger';
5
+ export declare const createFeature: (novaDataSource: NovaDataSource, params: CreateFeatureParams, logger: Logger) => Promise<Feature>;
@@ -0,0 +1,21 @@
1
+ import { Feature } from '../../entities';
2
+ import { requiredCreateFeatureParamsAttributes } from '../../types/feature';
3
+ import { anyAttributeIsNull } from '../../utils/paramsValidators';
4
+ export const createFeature = async (novaDataSource, params, logger) => {
5
+ if (anyAttributeIsNull(params, requiredCreateFeatureParamsAttributes)) {
6
+ logger.warn({ params }, 'FeatureRepository::createFeature missing required parameters');
7
+ return null;
8
+ }
9
+ return novaDataSource.safeQuery(async (safeDataSource) => {
10
+ const featuresRepository = safeDataSource.getRepository(Feature);
11
+ const newFeature = {
12
+ key: params.key,
13
+ name: params.name,
14
+ description: params.description,
15
+ tags: params.tags,
16
+ };
17
+ const createdFeature = await featuresRepository.save(newFeature);
18
+ return createdFeature ?? null;
19
+ }, 'FeatureRepository::createFeature error');
20
+ };
21
+ //# sourceMappingURL=createFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFeature.js","sourceRoot":"","sources":["../../../src/repositories/features/createFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAuB,qCAAqC,EAAE,MAAM,qBAAqB,CAAA;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,cAA8B,EAC9B,MAA2B,EAC3B,MAAc,EACd,EAAE;IACF,IAAI,kBAAkB,CAAsB,MAAM,EAAE,qCAAqC,CAAC,EAAE;QAC1F,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,8DAA8D,CAAC,CAAA;QACvF,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,cAA8B,EAAoB,EAAE;QACzF,MAAM,kBAAkB,GAAG,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAEhE,MAAM,UAAU,GAAG;YACjB,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;SACP,CAAA;QAEZ,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QAEhE,OAAO,cAAc,IAAI,IAAI,CAAA;IAC/B,CAAC,EAAE,wCAAwC,CAAC,CAAA;AAC9C,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { NovaDataSource } from '../../novaDataSource';
2
+ import { DeleteFeatureParams } from '../../types/feature';
3
+ import { Logger } from '../../types/logger';
4
+ export declare const deleteFeature: (novaDataSource: NovaDataSource, params: DeleteFeatureParams, logger: Logger) => Promise<boolean>;
@@ -0,0 +1,17 @@
1
+ import { Feature } from '../../entities';
2
+ export const deleteFeature = async (novaDataSource, params, logger) => {
3
+ if (!params?.filters?.key) {
4
+ logger.warn({ params }, 'FeatureRepository::deleteFeature missing required parameters');
5
+ return false;
6
+ }
7
+ return novaDataSource.safeQuery(async (dataSource) => {
8
+ const featureRepository = dataSource.getRepository(Feature);
9
+ const result = await featureRepository
10
+ .createQueryBuilder()
11
+ .delete()
12
+ .where('key = :key', { key: params.filters.key })
13
+ .execute();
14
+ return result.affected > 0;
15
+ }, 'FeatureRepository::deleteFeature');
16
+ };
17
+ //# sourceMappingURL=deleteFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteFeature.js","sourceRoot":"","sources":["../../../src/repositories/features/deleteFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAKxC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,cAA8B,EAC9B,MAA2B,EAC3B,MAAc,EACI,EAAE;IACpB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,8DAA8D,CAAC,CAAA;QACvF,OAAO,KAAK,CAAA;KACb;IAED,OAAO,cAAc,CAAC,SAAS,CAAC,KAAK,EAAE,UAA0B,EAAoB,EAAE;QACrF,MAAM,iBAAiB,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAE3D,MAAM,MAAM,GAAG,MAAM,iBAAiB;aACnC,kBAAkB,EAAE;aACpB,MAAM,EAAE;aACR,KAAK,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;aAChD,OAAO,EAAE,CAAA;QAEZ,OAAO,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAA;IAC5B,CAAC,EAAE,kCAAkC,CAAC,CAAA;AACxC,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { Feature } from '../../entities';
2
+ import { NovaDataSource } from '../../novaDataSource';
3
+ import { GetFeatureParams } from '../../types/feature';
4
+ export declare const getFeatures: (novaDataSource: NovaDataSource, params: GetFeatureParams) => Promise<Feature[]>;
@@ -0,0 +1,25 @@
1
+ import { Feature } from '../../entities';
2
+ export const getFeatures = async (novaDataSource, params) => {
3
+ // Force the query to run on master or slave
4
+ const dbQueryRunner = novaDataSource.createQueryRunnerFromParams(params);
5
+ return novaDataSource.safeQuery(async (safeDataSource, queryRunner) => {
6
+ const featureRepository = safeDataSource.getRepository(Feature);
7
+ const queryBuilder = featureRepository.createQueryBuilder('feature');
8
+ if (queryRunner) {
9
+ queryBuilder.setQueryRunner(queryRunner);
10
+ }
11
+ if (params?.filters?.keys?.length) {
12
+ queryBuilder.where('feature.key IN (:keyList)', {
13
+ keyList: params.filters.keys,
14
+ });
15
+ }
16
+ if (params?.filters?.names?.length) {
17
+ queryBuilder.andWhere('feature.name IN (:nameList)', {
18
+ nameList: params.filters.names,
19
+ });
20
+ }
21
+ const features = await queryBuilder.getMany();
22
+ return features?.length ? features : [];
23
+ }, 'FeatureRepository::getFeatures error', dbQueryRunner);
24
+ };
25
+ //# sourceMappingURL=getFeatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFeatures.js","sourceRoot":"","sources":["../../../src/repositories/features/getFeatures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAIxC,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,cAA8B,EAC9B,MAAwB,EACJ,EAAE;IACtB,4CAA4C;IAC5C,MAAM,aAAa,GAAG,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAA;IAExE,OAAO,cAAc,CAAC,SAAS,CAC7B,KAAK,EAAE,cAA8B,EAAE,WAAyB,EAAsB,EAAE;QACtF,MAAM,iBAAiB,GAAG,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAE/D,MAAM,YAAY,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;QAEpE,IAAI,WAAW,EAAE;YACf,YAAY,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;SACzC;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE;YACjC,YAAY,CAAC,KAAK,CAAC,2BAA2B,EAAE;gBAC9C,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI;aAC7B,CAAC,CAAA;SACH;QAED,IAAI,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE;YAClC,YAAY,CAAC,QAAQ,CAAC,6BAA6B,EAAE;gBACnD,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK;aAC/B,CAAC,CAAA;SACH;QAED,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;QAE7C,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAA;IACzC,CAAC,EACD,sCAAsC,EACtC,aAAa,CACd,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { Feature } from '../../entities';
2
+ import { CreateFeatureParams, DeleteFeatureParams, GetFeatureParams } from '../../types/feature';
3
+ import { BaseRepository } from '../baseRepository';
4
+ /**
5
+ * FeatureRepository, used to interact with the feature entity
6
+ * @extends BaseRepository
7
+ */
8
+ export declare class FeatureRepository extends BaseRepository {
9
+ /**
10
+ * Create a feature
11
+ * @param {CreateFeatureParams} params containing information to create a feature
12
+ * @returns {Feature} the created feature
13
+ * */
14
+ createFeature(params: CreateFeatureParams): Promise<Feature>;
15
+ /**
16
+ * Get features
17
+ * @param {GetFeatureParams} params containing information to get features
18
+ * @returns {Feature[]} the features
19
+ */
20
+ getFeatures(params?: GetFeatureParams): Promise<Feature[]>;
21
+ /**
22
+ * Upsert a feature
23
+ * @param {CreateFeatureParams} params containing information to update a feature
24
+ * @returns {Feature} the updated feature
25
+ * */
26
+ upsertFeature(params: CreateFeatureParams): Promise<boolean>;
27
+ /**
28
+ * Delete a feature
29
+ * @param {DeleteFeatureParams} params containing information to delete a feature
30
+ * @returns {boolean} if the feature was deleted
31
+ * */
32
+ deleteFeature(params: DeleteFeatureParams): Promise<boolean>;
33
+ }