@degenerate/generic 0.1.0 → 0.1.1

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 (52) hide show
  1. package/dist/_settings/database-settings.d.ts +18 -0
  2. package/dist/_settings/database-settings.d.ts.map +1 -0
  3. package/dist/_settings/database-settings.js +23 -0
  4. package/dist/application/audit-log/additional-ids/{create-mulitple-path-alai.d.ts → create-multiple-path-alai.d.ts} +1 -1
  5. package/dist/application/audit-log/additional-ids/{create-mulitple-path-alai.d.ts.map → create-multiple-path-alai.d.ts.map} +1 -1
  6. package/dist/application/audit-log/create-application-audit-log.d.ts +2 -2
  7. package/dist/application/audit-log/create-application-audit-log.d.ts.map +1 -1
  8. package/dist/application/audit-log/create-application-audit-log.js +3 -3
  9. package/dist/application/database/firestore/generics/add-items-to-database.d.ts +13 -0
  10. package/dist/application/database/firestore/generics/add-items-to-database.d.ts.map +1 -0
  11. package/dist/application/database/firestore/generics/add-items-to-database.js +54 -0
  12. package/dist/application/database/firestore/generics/add-or-update-items-to-database.d.ts +13 -0
  13. package/dist/application/database/firestore/generics/add-or-update-items-to-database.d.ts.map +1 -0
  14. package/dist/application/database/firestore/generics/add-or-update-items-to-database.js +74 -0
  15. package/dist/application/database/firestore/generics/create-database-change-information.d.ts +15 -0
  16. package/dist/application/database/firestore/generics/create-database-change-information.d.ts.map +1 -0
  17. package/dist/application/database/firestore/generics/create-database-change-information.js +21 -0
  18. package/dist/application/database/firestore/generics/delete-items-on-database.d.ts +13 -0
  19. package/dist/application/database/firestore/generics/delete-items-on-database.d.ts.map +1 -0
  20. package/dist/application/database/firestore/generics/delete-items-on-database.js +66 -0
  21. package/dist/application/database/firestore/generics/get-item-from-database.d.ts +13 -0
  22. package/dist/application/database/firestore/generics/get-item-from-database.d.ts.map +1 -0
  23. package/dist/application/database/firestore/generics/get-item-from-database.js +55 -0
  24. package/dist/application/database/firestore/generics/get-items-different-path-on-database.d.ts +12 -0
  25. package/dist/application/database/firestore/generics/get-items-different-path-on-database.d.ts.map +1 -0
  26. package/dist/application/database/firestore/generics/get-items-different-path-on-database.js +63 -0
  27. package/dist/application/database/firestore/generics/get-items-from-database.d.ts +14 -0
  28. package/dist/application/database/firestore/generics/get-items-from-database.d.ts.map +1 -0
  29. package/dist/application/database/firestore/generics/get-items-from-database.js +80 -0
  30. package/dist/application/database/firestore/generics/update-items-on-database.d.ts +13 -0
  31. package/dist/application/database/firestore/generics/update-items-on-database.d.ts.map +1 -0
  32. package/dist/application/database/firestore/generics/update-items-on-database.js +67 -0
  33. package/dist/application/database/firestore/generics/update-items-properties-on-database.d.ts +14 -0
  34. package/dist/application/database/firestore/generics/update-items-properties-on-database.d.ts.map +1 -0
  35. package/dist/application/database/firestore/generics/update-items-properties-on-database.js +70 -0
  36. package/dist/application/database/firestore/path-references/audit-log/create-audit-log-col-ref.d.ts +9 -0
  37. package/dist/application/database/firestore/path-references/audit-log/create-audit-log-col-ref.d.ts.map +1 -0
  38. package/dist/application/database/firestore/path-references/audit-log/create-audit-log-col-ref.js +38 -0
  39. package/dist/application/index.d.ts +11 -1
  40. package/dist/application/index.d.ts.map +1 -1
  41. package/dist/application/index.js +17 -1
  42. package/dist/errors/database/database-errors.d.ts +24 -0
  43. package/dist/errors/database/database-errors.d.ts.map +1 -0
  44. package/dist/errors/database/database-errors.js +33 -0
  45. package/dist/errors/index.d.ts +2 -1
  46. package/dist/errors/index.d.ts.map +1 -1
  47. package/dist/errors/index.js +3 -1
  48. package/dist/models/application/database/firestore-models.d.ts +84 -0
  49. package/dist/models/application/database/firestore-models.d.ts.map +1 -0
  50. package/dist/models/application/database/firestore-models.js +4 -0
  51. package/package.json +5 -3
  52. /package/dist/application/audit-log/additional-ids/{create-mulitple-path-alai.js → create-multiple-path-alai.js} +0 -0
@@ -0,0 +1,18 @@
1
+ export declare const DatabaseSettingsFirestore: {
2
+ AuditLogs: {
3
+ Collection: string;
4
+ };
5
+ Events: {
6
+ Collection: string;
7
+ };
8
+ Functions: {
9
+ Collection: string;
10
+ };
11
+ Rules: {
12
+ Collection: string;
13
+ };
14
+ ShareData: {
15
+ Collection: string;
16
+ };
17
+ };
18
+ //# sourceMappingURL=database-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/database-settings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;CAgBrC,CAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // This file contains the settings for different databases.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DatabaseSettingsFirestore = void 0;
5
+ //#region Firestore
6
+ exports.DatabaseSettingsFirestore = {
7
+ AuditLogs: {
8
+ Collection: 'AuditLogs', // /{default}/AuditLogs
9
+ },
10
+ Events: {
11
+ Collection: 'Events', // /{default}/Events
12
+ },
13
+ Functions: {
14
+ Collection: 'Functions', // /{default}/Functions
15
+ },
16
+ Rules: {
17
+ Collection: 'Rules', // /{default}/Rules
18
+ },
19
+ ShareData: {
20
+ Collection: 'ShareData', // /{default}/ShareData
21
+ },
22
+ };
23
+ //#endregion Firestore
@@ -7,4 +7,4 @@ import { IAdditionalApplicationAuditLogIds } from '../../../models/application/a
7
7
  */
8
8
  declare const createMultiplePathALAI: (referencePaths: string[]) => IAdditionalApplicationAuditLogIds[];
9
9
  export { createMultiplePathALAI };
10
- //# sourceMappingURL=create-mulitple-path-alai.d.ts.map
10
+ //# sourceMappingURL=create-multiple-path-alai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-mulitple-path-alai.d.ts","sourceRoot":"","sources":["../../../../src/application/audit-log/additional-ids/create-mulitple-path-alai.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,oEAAoE,CAAC;AAEvH;;;;;GAKG;AACH,QAAA,MAAM,sBAAsB,mBAAoB,MAAM,EAAE,KAAG,iCAAiC,EAQ3F,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
1
+ {"version":3,"file":"create-multiple-path-alai.d.ts","sourceRoot":"","sources":["../../../../src/application/audit-log/additional-ids/create-multiple-path-alai.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,oEAAoE,CAAC;AAEvH;;;;;GAKG;AACH,QAAA,MAAM,sBAAsB,mBAAoB,MAAM,EAAE,KAAG,iCAAiC,EAQ3F,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -11,6 +11,6 @@ import { ApplicationAuditLogAction, ApplicationAuditLogSubType, ApplicationAudit
11
11
  * @param championsNetworkId the champions network Id.
12
12
  * @param organizationId the organization Id.
13
13
  */
14
- declare const createApplicationLog: (applicationAuditLogAction: ApplicationAuditLogAction, applicationAuditLogSubType: ApplicationAuditLogSubType, createdBy: string, applicationAuditLogType?: ApplicationAuditLogType, alai?: IAdditionalApplicationAuditLogIds[], currentData?: any, previousData?: any) => IApplicationAuditLog;
15
- export { createApplicationLog };
14
+ declare const createApplicationAuditLog: (applicationAuditLogAction: ApplicationAuditLogAction, applicationAuditLogSubType: ApplicationAuditLogSubType, createdBy: string, applicationAuditLogType?: ApplicationAuditLogType, alai?: IAdditionalApplicationAuditLogIds[], currentData?: any, previousData?: any) => IApplicationAuditLog;
15
+ export { createApplicationAuditLog };
16
16
  //# sourceMappingURL=create-application-audit-log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-application-audit-log.d.ts","sourceRoot":"","sources":["../../../src/application/audit-log/create-application-audit-log.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,iCAAiC,EACjC,oBAAoB,EACvB,MAAM,iEAAiE,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,oBAAoB,8BACK,yBAAyB,8BACxB,0BAA0B,aAC3C,MAAM,4BACQ,uBAAuB,SAC1C,iCAAiC,EAAE,gBAC3B,GAAG,iBACF,GAAG,KACnB,oBAaF,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
1
+ {"version":3,"file":"create-application-audit-log.d.ts","sourceRoot":"","sources":["../../../src/application/audit-log/create-application-audit-log.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,iCAAiC,EACjC,oBAAoB,EACvB,MAAM,iEAAiE,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,yBAAyB,8BACA,yBAAyB,8BACxB,0BAA0B,aAC3C,MAAM,4BACQ,uBAAuB,SAC1C,iCAAiC,EAAE,gBAC3B,GAAG,iBACF,GAAG,KACnB,oBAaF,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createApplicationLog = void 0;
4
+ exports.createApplicationAuditLog = void 0;
5
5
  const application_audit_log_models_1 = require("../../models/application/audit-log/application-audit-log-models");
6
6
  /**
7
7
  * This creates the application audit log.
@@ -15,7 +15,7 @@ const application_audit_log_models_1 = require("../../models/application/audit-l
15
15
  * @param championsNetworkId the champions network Id.
16
16
  * @param organizationId the organization Id.
17
17
  */
18
- const createApplicationLog = (applicationAuditLogAction, applicationAuditLogSubType, createdBy, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global, alai = [], currentData, previousData) => {
18
+ const createApplicationAuditLog = (applicationAuditLogAction, applicationAuditLogSubType, createdBy, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global, alai = [], currentData, previousData) => {
19
19
  const auditLog = {
20
20
  additionalAuditLogIds: alai,
21
21
  applicationAuditLogAction,
@@ -30,4 +30,4 @@ const createApplicationLog = (applicationAuditLogAction, applicationAuditLogSubT
30
30
  auditLog.previousData = previousData;
31
31
  return auditLog;
32
32
  };
33
- exports.createApplicationLog = createApplicationLog;
33
+ exports.createApplicationAuditLog = createApplicationAuditLog;
@@ -0,0 +1,13 @@
1
+ import { IDatabaseChangeInformation } from '../../../../models/application/database/firestore-models';
2
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
3
+ /**
4
+ * this function adds an item to the database.
5
+ *
6
+ * @param databaseChangeInformation the database change information
7
+ * @param userId the user id that is adding the item to the database
8
+ * @param applicationAuditLogType the type of audit log to create
9
+ * @returns
10
+ */
11
+ declare const addItemsToDatabase: (databaseChangeInformation: IDatabaseChangeInformation[], userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<void>;
12
+ export { addItemsToDatabase };
13
+ //# sourceMappingURL=add-items-to-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-items-to-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/add-items-to-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AAEtG,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAE3I;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,8BACO,0BAA0B,EAAE,UAC/C,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,IAAI,CAed,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.addItemsToDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
29
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
30
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
31
+ const db = admin.firestore();
32
+ /**
33
+ * this function adds an item to the database.
34
+ *
35
+ * @param databaseChangeInformation the database change information
36
+ * @param userId the user id that is adding the item to the database
37
+ * @param applicationAuditLogType the type of audit log to create
38
+ * @returns
39
+ */
40
+ const addItemsToDatabase = async (databaseChangeInformation, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
41
+ const auditLogColRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log collection reference
42
+ // create the new records in the database
43
+ await db.runTransaction(async (t) => {
44
+ for (const changeRecords of databaseChangeInformation) {
45
+ // create the audit log
46
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.create, changeRecords.auditLogSubType, userId, applicationAuditLogType, changeRecords.alai, changeRecords.item, undefined);
47
+ t.create(changeRecords.itemDocRef, JSON.parse(JSON.stringify(changeRecords.item))); // add the item to the database.
48
+ t.create(auditLogColRef.doc(), auditLog); // add the audit log to the database.
49
+ }
50
+ return;
51
+ });
52
+ return;
53
+ };
54
+ exports.addItemsToDatabase = addItemsToDatabase;
@@ -0,0 +1,13 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ import { IDatabaseChangeInformation } from '../../../../models/application/database/firestore-models';
3
+ /**
4
+ * This adds the items to the database if they do not exist, if they do exist then it updates the items.
5
+ *
6
+ * @param databaseChangeRecords the database change records
7
+ * @param userId the user id that this change is recorded under.
8
+ * @param applicationAuditLogType the type of audit log to create
9
+ * @returns
10
+ */
11
+ declare const addOrUpdateItemsToDatabase: <T>(databaseChangeRecords: IDatabaseChangeInformation[], userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<void>;
12
+ export { addOrUpdateItemsToDatabase };
13
+ //# sourceMappingURL=add-or-update-items-to-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-or-update-items-to-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/add-or-update-items-to-database.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,uBAAuB,EAAwB,MAAM,uEAAuE,CAAC;AAGjK,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AAGtG;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,GAAU,CAAC,yBAChB,0BAA0B,EAAE,UAC3C,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,IAAI,CAoCd,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.addOrUpdateItemsToDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
29
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
30
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
31
+ const db = admin.firestore();
32
+ /**
33
+ * This adds the items to the database if they do not exist, if they do exist then it updates the items.
34
+ *
35
+ * @param databaseChangeRecords the database change records
36
+ * @param userId the user id that this change is recorded under.
37
+ * @param applicationAuditLogType the type of audit log to create
38
+ * @returns
39
+ */
40
+ const addOrUpdateItemsToDatabase = async (databaseChangeRecords, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
41
+ // loop the transaction and update the database
42
+ await db.runTransaction(async (t) => {
43
+ const auditLogUpdates = []; // create an array of audit log updates
44
+ const updatedRecord = []; // create an array of updated records
45
+ // get the existing records from the database
46
+ for (const changeRecord of databaseChangeRecords) {
47
+ const newRecord = JSON.parse(JSON.stringify(changeRecord.item));
48
+ const existingRecordSnap = await t.get(changeRecord.itemDocRef);
49
+ // check if the record exists, if it does not exist then don't add it to the audit log.
50
+ if (existingRecordSnap.exists) {
51
+ const existingRecord = existingRecordSnap.data();
52
+ // create the audit log for the update stringify and parse to ensure the deep properties are copied.
53
+ const updatedData = { ...JSON.parse(JSON.stringify(existingRecord)), ...newRecord };
54
+ // create the audit log
55
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.update, changeRecord.auditLogSubType, userId, applicationAuditLogType, changeRecord.alai, updatedData, existingRecord);
56
+ auditLogUpdates.push(auditLog);
57
+ updatedRecord.push(updatedData);
58
+ }
59
+ else {
60
+ // create the audit log
61
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.create, changeRecord.auditLogSubType, userId, applicationAuditLogType, changeRecord.alai, newRecord, undefined);
62
+ auditLogUpdates.push(auditLog);
63
+ updatedRecord.push(newRecord);
64
+ }
65
+ }
66
+ // update the database.
67
+ for (let i = 0; i < databaseChangeRecords.length; i++) {
68
+ const changeRecord = databaseChangeRecords[i];
69
+ t.set(changeRecord.itemDocRef, updatedRecord[i]); // no merge requeired at this was done in the function.
70
+ t.create((0, create_audit_log_col_ref_1.createAuditLogColRef)().doc(), auditLogUpdates[i]);
71
+ }
72
+ });
73
+ };
74
+ exports.addOrUpdateItemsToDatabase = addOrUpdateItemsToDatabase;
@@ -0,0 +1,15 @@
1
+ import { DocumentReference } from 'firebase-admin/firestore';
2
+ import { IAdditionalApplicationAuditLogIds, ApplicationAuditLogSubType } from '../../../../models/application/audit-log/application-audit-log-models';
3
+ import { IDatabaseChangeInformation } from '../../../../models/application/database/firestore-models';
4
+ /**
5
+ * this function creates the database change information.
6
+ *
7
+ * @param alai the additional application audit log ids
8
+ * @param auditLogSubType the audit log sub type
9
+ * @param item the item to add to the database
10
+ * @param itemDocRef the item document reference (where to add the item to the database)
11
+ * @returns
12
+ */
13
+ declare const createDatabaseChangeInformation: (alai: IAdditionalApplicationAuditLogIds[], auditLogSubType: ApplicationAuditLogSubType, item: unknown, itemDocRef: DocumentReference) => IDatabaseChangeInformation;
14
+ export { createDatabaseChangeInformation };
15
+ //# sourceMappingURL=create-database-change-information.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-database-change-information.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/create-database-change-information.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,MAAM,uEAAuE,CAAC;AACtJ,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AAEtG;;;;;;;;GAQG;AACH,QAAA,MAAM,+BAA+B,SAC3B,iCAAiC,EAAE,mBACxB,0BAA0B,QACrC,OAAO,cACD,iBAAiB,KAC9B,0BAOF,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDatabaseChangeInformation = void 0;
4
+ /**
5
+ * this function creates the database change information.
6
+ *
7
+ * @param alai the additional application audit log ids
8
+ * @param auditLogSubType the audit log sub type
9
+ * @param item the item to add to the database
10
+ * @param itemDocRef the item document reference (where to add the item to the database)
11
+ * @returns
12
+ */
13
+ const createDatabaseChangeInformation = (alai, auditLogSubType, item, itemDocRef) => {
14
+ return {
15
+ alai,
16
+ auditLogSubType,
17
+ item,
18
+ itemDocRef,
19
+ };
20
+ };
21
+ exports.createDatabaseChangeInformation = createDatabaseChangeInformation;
@@ -0,0 +1,13 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ import { IDatabaseDeleteItem } from '../../../../models/application/database/firestore-models';
3
+ /**
4
+ * This deletes the items on the database.
5
+ *
6
+ * @param databaseDeleteItems the database delete items
7
+ * @param userId the user id that is updating the database
8
+ * @param applicationAuditLogType the type of audit log to create
9
+ * @returns
10
+ */
11
+ declare const deleteItemsOnDatabase: (databaseDeleteItems: IDatabaseDeleteItem[], userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<void>;
12
+ export { deleteItemsOnDatabase };
13
+ //# sourceMappingURL=delete-items-on-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-items-on-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/delete-items-on-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,mBAAmB,EAAE,MAAM,0DAA0D,CAAC;AAM/F;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,wBACF,mBAAmB,EAAE,UAClC,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,IAAI,CA2Bd,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.deleteItemsOnDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
29
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
30
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
31
+ const database_errors_1 = require("../../../../errors/database/database-errors");
32
+ const db = admin.firestore();
33
+ /**
34
+ * This deletes the items on the database.
35
+ *
36
+ * @param databaseDeleteItems the database delete items
37
+ * @param userId the user id that is updating the database
38
+ * @param applicationAuditLogType the type of audit log to create
39
+ * @returns
40
+ */
41
+ const deleteItemsOnDatabase = async (databaseDeleteItems, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
42
+ const auditLogColRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log collection reference
43
+ // create the new records in the database
44
+ await db.runTransaction(async (t) => {
45
+ const existingRecords = []; // the existing records in the database, get these for the audit logs and throw error on not foudn checks
46
+ for (const changeRecords of databaseDeleteItems) {
47
+ const existingRecordSnap = await t.get(changeRecords.itemDocRef);
48
+ // check if the record exists
49
+ if (!existingRecordSnap.exists && changeRecords.throwErrorOnNotFound) {
50
+ throw new database_errors_1.DatabaseRecordNotFoundError(changeRecords.itemDocRef.path);
51
+ }
52
+ existingRecords.push(existingRecordSnap.data());
53
+ }
54
+ // loop the records and delete them from the database
55
+ for (let i = 0; i < existingRecords.length; i++) {
56
+ const existingRecord = existingRecords[i]; // the existing record
57
+ const deleteRecord = databaseDeleteItems[i]; // the delete record
58
+ // create the audit log
59
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.delete, deleteRecord.auditLogSubType, userId, applicationAuditLogType, deleteRecord.alai, undefined, existingRecord);
60
+ t.delete(deleteRecord.itemDocRef); // delete the item from the database.
61
+ t.create(auditLogColRef.doc(), auditLog); // add the audit log to the database.
62
+ }
63
+ return;
64
+ });
65
+ };
66
+ exports.deleteItemsOnDatabase = deleteItemsOnDatabase;
@@ -0,0 +1,13 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ import { IDatabaseGetItem } from '../../../../models/application/database/firestore-models';
3
+ /**
4
+ * This gets a single item from the database
5
+ *
6
+ * @param getItem the instructions for this function
7
+ * @param userId the user ID performing the action
8
+ * @param applicationAuditLogType the type of audit log to create
9
+ * @returns
10
+ */
11
+ declare const getItemFromDatabase: <T>(getItem: IDatabaseGetItem, userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<T | undefined>;
12
+ export { getItemFromDatabase };
13
+ //# sourceMappingURL=get-item-from-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-item-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-item-from-database.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAG5F;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,GAAU,CAAC,WACvB,gBAAgB,UACjB,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,CAAC,GAAG,SAAS,CAgBvB,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getItemFromDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
29
+ const database_errors_1 = require("../../../../errors/database/database-errors");
30
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
31
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
32
+ const db = admin.firestore();
33
+ /**
34
+ * This gets a single item from the database
35
+ *
36
+ * @param getItem the instructions for this function
37
+ * @param userId the user ID performing the action
38
+ * @param applicationAuditLogType the type of audit log to create
39
+ * @returns
40
+ */
41
+ const getItemFromDatabase = async (getItem, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
42
+ const auditLogRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log reference
43
+ // create the audit log information
44
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.read, getItem.auditLogSubType, userId, applicationAuditLogType, getItem.alai, undefined, undefined);
45
+ const itemData = await db.runTransaction(async (t) => {
46
+ const connectedSnap = await t.get(getItem.itemDocRef); // get the connected snap
47
+ t.create(auditLogRef.doc(), auditLog); // add the audit log to the database.
48
+ return connectedSnap.data();
49
+ });
50
+ if (getItem.throwErrorOnNotFound && !itemData) {
51
+ throw new database_errors_1.DatabaseRecordNotFoundError(getItem.itemDocRef.path);
52
+ }
53
+ return itemData;
54
+ };
55
+ exports.getItemFromDatabase = getItemFromDatabase;
@@ -0,0 +1,12 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ /**
3
+ * This function gets the items from different paths on the database.
4
+ *
5
+ * @param documentPaths the paths of the documents to get
6
+ * @param userId the user ID performing the action
7
+ * @param applicationAuditLogType the type of audit log to create
8
+ * @returns
9
+ */
10
+ declare const getItemsDifferentPathsOnDatabase: <T>(documentPaths: string[], userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<T[]>;
11
+ export { getItemsDifferentPathsOnDatabase };
12
+ //# sourceMappingURL=get-items-different-path-on-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-items-different-path-on-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-different-path-on-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAA+B,MAAM,uEAAuE,CAAC;AAIxK;;;;;;;GAOG;AACH,QAAA,MAAM,gCAAgC,GAAU,CAAC,iBAC9B,MAAM,EAAE,UACf,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,CAAC,EAAE,CAwBb,CAAC;AAEF,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getItemsDifferentPathsOnDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
29
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
30
+ const create_multiple_path_alai_1 = require("../../../audit-log/additional-ids/create-multiple-path-alai");
31
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
32
+ const db = admin.firestore();
33
+ /**
34
+ * This function gets the items from different paths on the database.
35
+ *
36
+ * @param documentPaths the paths of the documents to get
37
+ * @param userId the user ID performing the action
38
+ * @param applicationAuditLogType the type of audit log to create
39
+ * @returns
40
+ */
41
+ const getItemsDifferentPathsOnDatabase = async (documentPaths, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
42
+ const auditLogColRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log collection reference
43
+ // create the promisees for the documents.
44
+ const documentPromises = [];
45
+ for (const documentPath of documentPaths) {
46
+ documentPromises.push(db.doc(documentPath).get());
47
+ }
48
+ // create the audit log additional ids information
49
+ const alai = (0, create_multiple_path_alai_1.createMultiplePathALAI)(documentPaths);
50
+ // create the audit log information
51
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.list, application_audit_log_models_1.MultiplePathAuditLogSubType.multiplePathALAI, userId, applicationAuditLogType, alai, undefined, undefined);
52
+ // add in the audit log
53
+ await auditLogColRef.add(auditLog);
54
+ const allDocuments = await Promise.all(documentPromises);
55
+ const allDocumentsData = [];
56
+ for (const document of allDocuments) {
57
+ if (document.exists) {
58
+ allDocumentsData.push(document.data());
59
+ }
60
+ }
61
+ return allDocumentsData;
62
+ };
63
+ exports.getItemsDifferentPathsOnDatabase = getItemsDifferentPathsOnDatabase;
@@ -0,0 +1,14 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ import { IDatabaseGetInformation } from '../../../../models/application/database/firestore-models';
3
+ /**
4
+ * This function queries the database and returns the items or an empty array.
5
+ *
6
+ * @param getInformation the get information (instructions for this function)
7
+ * @param userId the user ID performing the action
8
+ * @param applicationAuditLogType the type of audit log to create
9
+ * @param <T> the type of the items to return
10
+ * @returns
11
+ */
12
+ declare const getItemsFromDatabase: <T>(userId: string, getInformation: IDatabaseGetInformation, applicationAuditLogType?: ApplicationAuditLogType) => Promise<T[]>;
13
+ export { getItemsFromDatabase };
14
+ //# sourceMappingURL=get-items-from-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-items-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-from-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,uBAAuB,EAAE,MAAM,0DAA0D,CAAC;AAKnG;;;;;;;;GAQG;AACH,QAAA,MAAM,oBAAoB,GAAU,CAAC,UACzB,MAAM,kBACE,uBAAuB,4BACd,uBAAuB,KACjD,OAAO,CAAC,CAAC,EAAE,CA0Cb,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getItemsFromDatabase = void 0;
27
+ const firebase = __importStar(require("firebase-admin"));
28
+ const application_settings_1 = require("../../../../_settings/application-settings");
29
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
30
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
31
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
32
+ const db = firebase.firestore();
33
+ /**
34
+ * This function queries the database and returns the items or an empty array.
35
+ *
36
+ * @param getInformation the get information (instructions for this function)
37
+ * @param userId the user ID performing the action
38
+ * @param applicationAuditLogType the type of audit log to create
39
+ * @param <T> the type of the items to return
40
+ * @returns
41
+ */
42
+ const getItemsFromDatabase = async (userId, getInformation, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
43
+ const maxResults = application_settings_1.ApplicationSettings.SystemValues.MaxSnapshotSize; // the maximum number of results to return.
44
+ const auditLogColRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log collection reference
45
+ // get the items from the database.
46
+ const itemsToReturn = await db.runTransaction(async (t) => {
47
+ const databaseItems = [];
48
+ const itemQuery = getInformation.itemColRef;
49
+ console.log('itemQuery', itemQuery);
50
+ // add in the query fields if they are set.
51
+ for (const queryField of getInformation.queryFields) {
52
+ itemQuery.where(queryField.fieldPath, queryField.opStr, queryField.value);
53
+ }
54
+ // If order by is set, then order the items.
55
+ if (getInformation.orderBy) {
56
+ itemQuery.orderBy(getInformation.orderBy.fieldPath, getInformation.orderBy.direction);
57
+ }
58
+ // add in the query for the pagination.
59
+ if (typeof getInformation.lastId !== 'undefined' && getInformation.lastId.length > 0) {
60
+ const lastElement = await t.get(itemQuery.doc(getInformation.lastId));
61
+ itemQuery.startAfter(lastElement);
62
+ }
63
+ // set the limit and query the database.
64
+ itemQuery.limit(maxResults);
65
+ console.log('itemQueryAfter', itemQuery.limit);
66
+ const itemSnapshot = await t.get(itemQuery);
67
+ console.log('itemSnapshot', itemSnapshot);
68
+ // get the items from the database.
69
+ for (const docSnap of itemSnapshot.docs) {
70
+ const item = docSnap.data();
71
+ databaseItems.push(item);
72
+ }
73
+ // create the audit log information
74
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.list, getInformation.auditLogSubType, userId, applicationAuditLogType, getInformation.alai, undefined, undefined);
75
+ t.create(auditLogColRef.doc(), auditLog); // add the audit log to the database.
76
+ return databaseItems;
77
+ });
78
+ return itemsToReturn;
79
+ };
80
+ exports.getItemsFromDatabase = getItemsFromDatabase;
@@ -0,0 +1,13 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ import { IDatabaseChangeInformation } from '../../../../models/application/database/firestore-models';
3
+ /**
4
+ * This updates the items on the database.
5
+ *
6
+ * @param databaseChangeInformation the database change information
7
+ * @param userId the user id that is updating the database
8
+ * @param applicationAuditLogType the type of audit log to create
9
+ * @returns
10
+ */
11
+ declare const updateItemsOnDatabase: <T>(databaseChangeInformation: IDatabaseChangeInformation[], userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<void>;
12
+ export { updateItemsOnDatabase };
13
+ //# sourceMappingURL=update-items-on-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-items-on-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/update-items-on-database.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,uBAAuB,EAAE,MAAM,uEAAuE,CAAC;AAC3I,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AAMtG;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,GAAU,CAAC,6BACP,0BAA0B,EAAE,UAC/C,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,IAAI,CA0Bd,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.updateItemsOnDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
29
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
30
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
31
+ const database_errors_1 = require("../../../../errors/database/database-errors");
32
+ const db = admin.firestore();
33
+ /**
34
+ * This updates the items on the database.
35
+ *
36
+ * @param databaseChangeInformation the database change information
37
+ * @param userId the user id that is updating the database
38
+ * @param applicationAuditLogType the type of audit log to create
39
+ * @returns
40
+ */
41
+ const updateItemsOnDatabase = async (databaseChangeInformation, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
42
+ // loop the transaction and update the database
43
+ await db.runTransaction(async (t) => {
44
+ // get the existing records from the database
45
+ const existingRecords = [];
46
+ for (const changeRecords of databaseChangeInformation) {
47
+ const existingRecordSnap = await t.get(changeRecords.itemDocRef);
48
+ // check if the record exists
49
+ if (!existingRecordSnap.exists)
50
+ throw new database_errors_1.DatabaseRecordNotFoundError(changeRecords.itemDocRef.path);
51
+ existingRecords.push(existingRecordSnap.data());
52
+ }
53
+ // create the updates and the audit logs.
54
+ for (let i = 0; i < existingRecords.length; i++) {
55
+ // get the change record and the existing record
56
+ const changeRecord = databaseChangeInformation[i];
57
+ const existingRecord = existingRecords[i];
58
+ // create the audit log
59
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.update, changeRecord.auditLogSubType, userId, applicationAuditLogType, changeRecord.alai, changeRecord.item, existingRecord);
60
+ const updatedRecord = { ...existingRecord, ...changeRecord.item };
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ t.update(changeRecord.itemDocRef, updatedRecord);
63
+ t.create((0, create_audit_log_col_ref_1.createAuditLogColRef)().doc(), auditLog);
64
+ }
65
+ });
66
+ };
67
+ exports.updateItemsOnDatabase = updateItemsOnDatabase;
@@ -0,0 +1,14 @@
1
+ import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
2
+ import { IDatabasePropertyChangeInformation } from '../../../../models/application/database/firestore-models';
3
+ /**
4
+ * This takes a partial object to update and updates the properties on the database. This function is used to update
5
+ * the properties of an object on the database.
6
+ *
7
+ * @param databaseChangeRecords the database change records (the reference and properties to update)
8
+ * @param userId the user ID that is updating the database
9
+ * @param applicationAuditLogType the type of audit log to create
10
+ * @returns
11
+ */
12
+ declare const updateItemsPropertiesOnDatabase: <T>(databaseChangeRecords: IDatabasePropertyChangeInformation[], userId: string, applicationAuditLogType?: ApplicationAuditLogType) => Promise<void>;
13
+ export { updateItemsPropertiesOnDatabase };
14
+ //# sourceMappingURL=update-items-properties-on-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-items-properties-on-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/update-items-properties-on-database.ts"],"names":[],"mappings":"AAEA,OAAO,EAGH,uBAAuB,EAC1B,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,kCAAkC,EAAE,MAAM,0DAA0D,CAAC;AAI9G;;;;;;;;GAQG;AACH,QAAA,MAAM,+BAA+B,GAAU,CAAC,yBACrB,kCAAkC,EAAE,UACnD,MAAM,4BACW,uBAAuB,KACjD,OAAO,CAAC,IAAI,CA6Bd,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,CAAC"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.updateItemsPropertiesOnDatabase = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const database_errors_1 = require("../../../../errors/database/database-errors");
29
+ const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
30
+ const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
31
+ const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
32
+ const db = admin.firestore();
33
+ /**
34
+ * This takes a partial object to update and updates the properties on the database. This function is used to update
35
+ * the properties of an object on the database.
36
+ *
37
+ * @param databaseChangeRecords the database change records (the reference and properties to update)
38
+ * @param userId the user ID that is updating the database
39
+ * @param applicationAuditLogType the type of audit log to create
40
+ * @returns
41
+ */
42
+ const updateItemsPropertiesOnDatabase = async (databaseChangeRecords, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogType.global) => {
43
+ // loop the transaction and update the database
44
+ await db.runTransaction(async (t) => {
45
+ const auditLogUpdates = []; // create an array of audit log updates
46
+ const updatedRecord = []; // create an array of updated records
47
+ // get the existing records from the database
48
+ for (const changeRecord of databaseChangeRecords) {
49
+ const existingRecordSnap = await t.get(changeRecord.itemDocRef);
50
+ // check if the record exists
51
+ if (!existingRecordSnap.exists)
52
+ throw new database_errors_1.DatabaseRecordNotFoundError(changeRecord.itemDocRef.path);
53
+ const existingRecord = existingRecordSnap.data();
54
+ // create the audit log for the update stringify and parse to ensure the deep properties are copied.
55
+ const recordExisting = JSON.parse(JSON.stringify(existingRecord));
56
+ const updatedData = { recordExisting, ...changeRecord.partialObjectUpdate };
57
+ // create the audit log
58
+ const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogAction.update, changeRecord.auditLogSubType, userId, applicationAuditLogType, changeRecord.alai, updatedData, existingRecord);
59
+ auditLogUpdates.push(auditLog);
60
+ updatedRecord.push(updatedData);
61
+ }
62
+ // update the database.
63
+ for (let i = 0; i < databaseChangeRecords.length; i++) {
64
+ const changeRecord = databaseChangeRecords[i];
65
+ t.update(changeRecord.itemDocRef, updatedRecord[i]);
66
+ t.create((0, create_audit_log_col_ref_1.createAuditLogColRef)().doc(), auditLogUpdates[i]);
67
+ }
68
+ });
69
+ };
70
+ exports.updateItemsPropertiesOnDatabase = updateItemsPropertiesOnDatabase;
@@ -0,0 +1,9 @@
1
+ import { CollectionReference } from 'firebase-admin/firestore';
2
+ /**
3
+ * This creates the audit log collection reference.
4
+ *
5
+ * @returns the collection reference.
6
+ */
7
+ declare const createAuditLogColRef: () => CollectionReference;
8
+ export { createAuditLogColRef };
9
+ //# sourceMappingURL=create-audit-log-col-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-audit-log-col-ref.d.ts","sourceRoot":"","sources":["../../../../../../src/application/database/firestore/path-references/audit-log/create-audit-log-col-ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAI/D;;;;GAIG;AACH,QAAA,MAAM,oBAAoB,QAAO,mBAEhC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.createAuditLogColRef = void 0;
27
+ const admin = __importStar(require("firebase-admin"));
28
+ const database_settings_1 = require("../../../../../_settings/database-settings");
29
+ const db = admin.firestore();
30
+ /**
31
+ * This creates the audit log collection reference.
32
+ *
33
+ * @returns the collection reference.
34
+ */
35
+ const createAuditLogColRef = () => {
36
+ return db.collection(database_settings_1.DatabaseSettingsFirestore.AuditLogs.Collection);
37
+ };
38
+ exports.createAuditLogColRef = createAuditLogColRef;
@@ -1,5 +1,15 @@
1
1
  export * from './audit-log/additional-ids/create-audit-log-additional-ids-with-query';
2
- export * from './audit-log/additional-ids/create-mulitple-path-alai';
2
+ export * from './audit-log/additional-ids/create-multiple-path-alai';
3
3
  export * from './audit-log/additional-ids/create-query-audit-log-for-alai';
4
4
  export * from './audit-log/create-application-audit-log';
5
+ export * from './database/firestore/generics/add-items-to-database';
6
+ export * from './database/firestore/generics/add-or-update-items-to-database';
7
+ export * from './database/firestore/generics/create-database-change-information';
8
+ export * from './database/firestore/generics/delete-items-on-database';
9
+ export * from './database/firestore/generics/get-item-from-database';
10
+ export * from './database/firestore/generics/get-items-different-path-on-database';
11
+ export * from './database/firestore/generics/get-items-from-database';
12
+ export * from './database/firestore/generics/update-items-on-database';
13
+ export * from './database/firestore/generics/update-items-properties-on-database';
14
+ export * from './database/firestore/path-references/audit-log/create-audit-log-col-ref';
5
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAKA,cAAc,uEAAuE,CAAC;AACtF,cAAc,sDAAsD,CAAC;AACrE,cAAc,4DAA4D,CAAC;AAG3E,cAAc,0CAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAKA,cAAc,uEAAuE,CAAC;AACtF,cAAc,sDAAsD,CAAC;AACrE,cAAc,4DAA4D,CAAC;AAG3E,cAAc,0CAA0C,CAAC;AAUzD,cAAc,qDAAqD,CAAC;AACpE,cAAc,+DAA+D,CAAC;AAC9E,cAAc,kEAAkE,CAAC;AACjF,cAAc,wDAAwD,CAAC;AACvE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oEAAoE,CAAC;AACnF,cAAc,uDAAuD,CAAC;AACtE,cAAc,wDAAwD,CAAC;AACvE,cAAc,mEAAmE,CAAC;AAMlF,cAAc,yEAAyE,CAAC"}
@@ -18,9 +18,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  //#region Audit Log
19
19
  //#region Additional Ids
20
20
  __exportStar(require("./audit-log/additional-ids/create-audit-log-additional-ids-with-query"), exports);
21
- __exportStar(require("./audit-log/additional-ids/create-mulitple-path-alai"), exports);
21
+ __exportStar(require("./audit-log/additional-ids/create-multiple-path-alai"), exports);
22
22
  __exportStar(require("./audit-log/additional-ids/create-query-audit-log-for-alai"), exports);
23
23
  //#endregion Additional Ids
24
24
  __exportStar(require("./audit-log/create-application-audit-log"), exports);
25
25
  //#endregion Audit Log
26
+ //#region Database
27
+ //#region Firestore
28
+ //#region Generics
29
+ __exportStar(require("./database/firestore/generics/add-items-to-database"), exports);
30
+ __exportStar(require("./database/firestore/generics/add-or-update-items-to-database"), exports);
31
+ __exportStar(require("./database/firestore/generics/create-database-change-information"), exports);
32
+ __exportStar(require("./database/firestore/generics/delete-items-on-database"), exports);
33
+ __exportStar(require("./database/firestore/generics/get-item-from-database"), exports);
34
+ __exportStar(require("./database/firestore/generics/get-items-different-path-on-database"), exports);
35
+ __exportStar(require("./database/firestore/generics/get-items-from-database"), exports);
36
+ __exportStar(require("./database/firestore/generics/update-items-on-database"), exports);
37
+ __exportStar(require("./database/firestore/generics/update-items-properties-on-database"), exports);
38
+ //#endregion Generics
39
+ //#region Path References
40
+ __exportStar(require("./database/firestore/path-references/audit-log/create-audit-log-col-ref"), exports);
41
+ //#endregion Path References
26
42
  //#endregion Application
@@ -0,0 +1,24 @@
1
+ import { BaseError } from '../base-error';
2
+ /**
3
+ * This is throw when a database records is not found.
4
+ */
5
+ export declare class DatabaseRecordNotFoundError extends BaseError {
6
+ /**
7
+ * This is thrown when a database record is not found.
8
+ *
9
+ * @param databasePath the path to the database record.
10
+ */
11
+ constructor(databasePath: string);
12
+ }
13
+ /**
14
+ * This is throw when too many database records are found.
15
+ */
16
+ export declare class DatabaseTooManyRecordsError extends BaseError {
17
+ /**
18
+ * This is thrown when too many database records are found.
19
+ *
20
+ * @param databasePath the path to the database record.
21
+ */
22
+ constructor(databasePath: string);
23
+ }
24
+ //# sourceMappingURL=database-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database-errors.d.ts","sourceRoot":"","sources":["../../../src/errors/database/database-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,SAAS;IACtD;;;;OAIG;gBACS,YAAY,EAAE,MAAM;CAGnC;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,SAAS;IACtD;;;;OAIG;gBACS,YAAY,EAAE,MAAM;CAGnC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatabaseTooManyRecordsError = exports.DatabaseRecordNotFoundError = void 0;
4
+ // This file contains all the errors that are related to database records.
5
+ const base_error_1 = require("../base-error");
6
+ /**
7
+ * This is throw when a database records is not found.
8
+ */
9
+ class DatabaseRecordNotFoundError extends base_error_1.BaseError {
10
+ /**
11
+ * This is thrown when a database record is not found.
12
+ *
13
+ * @param databasePath the path to the database record.
14
+ */
15
+ constructor(databasePath) {
16
+ super(`The database record at ${databasePath} was not found`);
17
+ }
18
+ }
19
+ exports.DatabaseRecordNotFoundError = DatabaseRecordNotFoundError;
20
+ /**
21
+ * This is throw when too many database records are found.
22
+ */
23
+ class DatabaseTooManyRecordsError extends base_error_1.BaseError {
24
+ /**
25
+ * This is thrown when too many database records are found.
26
+ *
27
+ * @param databasePath the path to the database record.
28
+ */
29
+ constructor(databasePath) {
30
+ super(`Too many records found at ${databasePath}`);
31
+ }
32
+ }
33
+ exports.DatabaseTooManyRecordsError = DatabaseTooManyRecordsError;
@@ -1,8 +1,9 @@
1
1
  export * from './audit-log/audit-log-errors';
2
- export * from './base-error';
2
+ export * from './database/database-errors';
3
3
  export * from './generic/generic-errors';
4
4
  export * from './request/request-errors';
5
5
  export * from './safe/safe-rules-errors';
6
6
  export * from './scheduler/scheduler-errors';
7
7
  export * from './share-data/share-data-errors';
8
+ export * from './base-error';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAG/C,cAAc,cAAc,CAAC"}
@@ -15,9 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./audit-log/audit-log-errors"), exports);
18
- __exportStar(require("./base-error"), exports);
18
+ __exportStar(require("./database/database-errors"), exports);
19
19
  __exportStar(require("./generic/generic-errors"), exports);
20
20
  __exportStar(require("./request/request-errors"), exports);
21
21
  __exportStar(require("./safe/safe-rules-errors"), exports);
22
22
  __exportStar(require("./scheduler/scheduler-errors"), exports);
23
23
  __exportStar(require("./share-data/share-data-errors"), exports);
24
+ // Base error
25
+ __exportStar(require("./base-error"), exports);
@@ -0,0 +1,84 @@
1
+ import { CollectionReference, DocumentReference } from 'firebase-admin/firestore';
2
+ import * as admin from 'firebase-admin';
3
+ import { IAdditionalApplicationAuditLogIds, ApplicationAuditLogSubType, IApplicationAuditLog } from '../audit-log/application-audit-log-models';
4
+ /**
5
+ * This contains the information that is needed to pass a change to the generic database functions.
6
+ */
7
+ export interface IDatabaseChangeInformation {
8
+ alai: IAdditionalApplicationAuditLogIds[];
9
+ auditLogSubType: ApplicationAuditLogSubType;
10
+ item: unknown;
11
+ itemDocRef: DocumentReference;
12
+ }
13
+ /**
14
+ * This contains the information that is needed to pass a change to the generic database functions.
15
+ * It allows for a property of an object to be retrieved and updated without needing the original
16
+ * object when called.
17
+ */
18
+ export interface IDatabasePropertyChangeInformation {
19
+ alai: IAdditionalApplicationAuditLogIds[];
20
+ auditLogSubType: ApplicationAuditLogSubType;
21
+ partialObjectUpdate: any;
22
+ itemDocRef: DocumentReference;
23
+ }
24
+ /**
25
+ * This contains the information records and audit logs for database changes
26
+ */
27
+ export interface IDatabaseUpdates {
28
+ recordsandRefs: IDatabaseRecordAndRef[];
29
+ auditLogInfo: IApplicationAuditLog;
30
+ }
31
+ /**
32
+ * This contains the database record and document reference to update.
33
+ */
34
+ export interface IDatabaseRecordAndRef {
35
+ record: unknown;
36
+ recordDocRef: DocumentReference;
37
+ }
38
+ /**
39
+ * This contains the information to get a single item from the database.
40
+ */
41
+ export interface IDatabaseGetItem extends IDatabaseAuditLogUpdates {
42
+ itemDocRef: DocumentReference;
43
+ throwErrorOnNotFound: boolean;
44
+ }
45
+ /**
46
+ * This contains the information that is needed to get multiple items from the database.
47
+ */
48
+ export interface IDatabaseGetInformation extends IDatabaseAuditLogUpdates {
49
+ itemColRef: CollectionReference;
50
+ lastId: string;
51
+ orderBy?: IDatabaseOrderBy;
52
+ queryFields: IDatabaseQueryFields[];
53
+ isMaxSizeDocumentSet?: boolean;
54
+ }
55
+ /**
56
+ * This contains the information that is needed to get information from the database.
57
+ */
58
+ export interface IDatabaseOrderBy {
59
+ fieldPath: string | admin.firestore.FieldPath;
60
+ direction: admin.firestore.OrderByDirection;
61
+ }
62
+ /**
63
+ * This contains the query information for the database if it is required
64
+ */
65
+ export interface IDatabaseQueryFields {
66
+ fieldPath: string | admin.firestore.FieldPath;
67
+ opStr: admin.firestore.WhereFilterOp;
68
+ value: any;
69
+ }
70
+ /**
71
+ * This contains the information to delete a single item from the database.
72
+ */
73
+ export interface IDatabaseDeleteItem extends IDatabaseAuditLogUpdates {
74
+ itemDocRef: DocumentReference;
75
+ throwErrorOnNotFound: boolean;
76
+ }
77
+ /**
78
+ * This contains the additional information audit logs.
79
+ */
80
+ export interface IDatabaseAuditLogUpdates {
81
+ alai: IAdditionalApplicationAuditLogIds[];
82
+ auditLogSubType: ApplicationAuditLogSubType;
83
+ }
84
+ //# sourceMappingURL=firestore-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firestore-models.d.ts","sourceRoot":"","sources":["../../../../src/models/application/database/firestore-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACH,iCAAiC,EACjC,0BAA0B,EAC1B,oBAAoB,EACvB,MAAM,2CAA2C,CAAC;AAMnD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACvC,IAAI,EAAE,iCAAiC,EAAE,CAAC;IAC1C,eAAe,EAAE,0BAA0B,CAAC;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,iBAAiB,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,kCAAkC;IAC/C,IAAI,EAAE,iCAAiC,EAAE,CAAC;IAC1C,eAAe,EAAE,0BAA0B,CAAC;IAE5C,mBAAmB,EAAE,GAAG,CAAC;IACzB,UAAU,EAAE,iBAAiB,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,cAAc,EAAE,qBAAqB,EAAE,CAAC;IACxC,YAAY,EAAE,oBAAoB,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,iBAAiB,CAAC;CACnC;AAMD;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,wBAAwB;IAC9D,UAAU,EAAE,iBAAiB,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACrE,UAAU,EAAE,mBAAmB,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;IAC9C,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,SAAS,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;IAC9C,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;IAErC,KAAK,EAAE,GAAG,CAAC;CACd;AAMD;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,wBAAwB;IACjE,UAAU,EAAE,iBAAiB,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;CACjC;AAMD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,iCAAiC,EAAE,CAAC;IAC1C,eAAe,EAAE,0BAA0B,CAAC;CAC/C"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //#endregion Audit Log Information
4
+ //#endregion Backend Data Models
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@degenerate/generic",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "This contains the generic information needed for the ShareData Adaptive Framework Ecosystem (SAFE) network",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -48,7 +48,9 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "bip39": "^3.1.0",
51
- "elliptic": "^6.5.7"
51
+ "elliptic": "^6.5.7",
52
+ "firebase-admin": "^12.7.0",
53
+ "firebase-functions": "^6.1.0"
52
54
  },
53
- "gitHead": "608fbf8b2b80f30464af3898f08f7ad8db9b543c"
55
+ "gitHead": "1c0ecfa12a0ed23296006ca29a22e77b28d183ed"
54
56
  }