@degenerate/generic 0.7.1 → 0.9.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.
- package/LICENSE.md +12 -60
- package/README.md +15 -0
- package/dist/_settings/application-settings.d.ts +1 -0
- package/dist/_settings/application-settings.d.ts.map +1 -1
- package/dist/_settings/application-settings.js +5 -0
- package/dist/_settings/authorization-settings.d.ts +2 -2
- package/dist/application/database/firestore/generics/add-items-to-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/add-items-to-database.js +2 -36
- package/dist/application/database/firestore/generics/add-or-update-items-to-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/add-or-update-items-to-database.js +2 -36
- package/dist/application/database/firestore/generics/delete-items-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/delete-items-on-database.js +2 -36
- package/dist/application/database/firestore/generics/get-item-from-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-item-from-database.js +2 -36
- package/dist/application/database/firestore/generics/get-items-different-path-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-items-different-path-on-database.js +2 -36
- package/dist/application/database/firestore/generics/get-items-from-database.d.ts +9 -4
- package/dist/application/database/firestore/generics/get-items-from-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/get-items-from-database.js +180 -61
- package/dist/application/database/firestore/generics/update-items-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/update-items-on-database.js +2 -36
- package/dist/application/database/firestore/generics/update-items-properties-on-database.d.ts.map +1 -1
- package/dist/application/database/firestore/generics/update-items-properties-on-database.js +2 -36
- package/dist/application/database/firestore/page-cursor/page-cursor.d.ts +33 -0
- package/dist/application/database/firestore/page-cursor/page-cursor.d.ts.map +1 -0
- package/dist/application/database/firestore/page-cursor/page-cursor.js +206 -0
- package/dist/application/database/firestore/path-references/audit-log/create-audit-log-col-ref.d.ts.map +1 -1
- package/dist/application/database/firestore/path-references/audit-log/create-audit-log-col-ref.js +2 -36
- package/dist/application/database/index.d.ts +1 -0
- package/dist/application/database/index.d.ts.map +1 -1
- package/dist/application/database/index.js +3 -0
- package/dist/application/index.d.ts +1 -0
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +3 -0
- package/dist/authorization/jwt/sign/create-jwt-options.d.ts +2 -2
- package/dist/authorization/jwt/sign/create-jwt-options.d.ts.map +1 -1
- package/dist/errors/base-error.d.ts +3 -1
- package/dist/errors/base-error.d.ts.map +1 -1
- package/dist/errors/base-error.js +5 -1
- package/dist/errors/database/database-errors.d.ts +28 -0
- package/dist/errors/database/database-errors.d.ts.map +1 -1
- package/dist/errors/database/database-errors.js +35 -1
- package/dist/helpers/firestore/firestore-id-helpers.d.ts +25 -0
- package/dist/helpers/firestore/firestore-id-helpers.d.ts.map +1 -0
- package/dist/helpers/firestore/firestore-id-helpers.js +39 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -0
- package/dist/models/application/database/firestore-models.d.ts +35 -14
- package/dist/models/application/database/firestore-models.d.ts.map +1 -1
- package/dist/models/application/database/firestore-models.js +64 -46
- package/package.json +13 -4
package/LICENSE.md
CHANGED
|
@@ -1,63 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
ISC License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2024-2026 Degenerate Inc.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
See the License for the specific language governing permissions and
|
|
17
|
-
limitations under the License.
|
|
18
|
-
|
|
19
|
-
## Additional Terms for Proprietary Extensions and Features
|
|
20
|
-
|
|
21
|
-
The SAFE Platform includes features and functionalities that may extend beyond the open-source scope of this license, including but not limited to:
|
|
22
|
-
|
|
23
|
-
1. **Advanced Enterprise Features**:
|
|
24
|
-
- Modules and tools tailored for enterprise-level scalability, security, and analytics.
|
|
25
|
-
- Customizable AI-driven extensions designed for high-volume data processing and decision-making.
|
|
26
|
-
- Separate licensing agreements are required for accessing these features.
|
|
27
|
-
|
|
28
|
-
2. **Marketplace Components**:
|
|
29
|
-
- Extensions, plugins, and templates available through the SAFE Marketplace may include specific licensing terms.
|
|
30
|
-
- Revenue-sharing agreements apply for developers contributing paid components to the Marketplace.
|
|
31
|
-
- Use of these components may require additional payments or subscription plans.
|
|
32
|
-
|
|
33
|
-
3. **Partnered Integrations**:
|
|
34
|
-
- SAFE Platform offers pre-integrated solutions with third-party platforms such as CRM systems, payment gateways, or cloud services.
|
|
35
|
-
- These integrations may require accepting additional terms from the third-party providers.
|
|
36
|
-
- Usage is governed by both this License and the third-party terms where applicable.
|
|
37
|
-
|
|
38
|
-
4. **Subscription-Based Analytics**:
|
|
39
|
-
- Advanced analytics features, including real-time data insights, AI model performance metrics, and user behavior analysis.
|
|
40
|
-
- These are provided through subscription services managed under proprietary agreements.
|
|
41
|
-
- Subscriptions may include tiered pricing based on data volume, number of users, or access levels.
|
|
42
|
-
|
|
43
|
-
5. **Industry-Specific Solutions**:
|
|
44
|
-
- SAFE Platform provides pre-configured templates and rules tailored for industries such as finance, healthcare, and logistics.
|
|
45
|
-
- These solutions include proprietary intellectual property that is not covered by the open-source license.
|
|
46
|
-
- Licensing agreements specify terms for usage and redistribution of these industry-specific components.
|
|
47
|
-
|
|
48
|
-
By using the SAFE Platform, you agree to abide by these additional terms where applicable. For more details, contact [Your Organization's Contact Information].
|
|
49
|
-
|
|
50
|
-
## Contribution and Use
|
|
51
|
-
|
|
52
|
-
1. **Community Contributions**:
|
|
53
|
-
- Contributions to the SAFE Platform's open-source repository are governed by the Apache License 2.0.
|
|
54
|
-
- By submitting a contribution, you agree that your work will be licensed under this license.
|
|
55
|
-
- Contributions must adhere to the project's coding standards and submission guidelines.
|
|
56
|
-
|
|
57
|
-
2. **Proprietary Extensions**:
|
|
58
|
-
- Contributions extending into proprietary areas require pre-approval by the administrators in the .
|
|
59
|
-
- These contributions may be subject to separate agreements defining revenue sharing, ownership rights, and maintenance responsibilities.
|
|
60
|
-
|
|
61
|
-
## Notices
|
|
62
|
-
|
|
63
|
-
This license file is intended to reflect a hybrid open-source and proprietary model for the SAFE Platform. It provides clarity for both community contributors and commercial users. For specific questions or legal inquiries, contact [Your Organization's Contact Information].
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -18,3 +18,18 @@ To install the `@degenerate/generic` package, use the following command:
|
|
|
18
18
|
npm install @degenerate/generic
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
`firebase-admin` (13.9+ or 14; 14.4+ recommended, because earlier releases pull in a `uuid`
|
|
22
|
+
with a moderate advisory, GHSA-w5hq-g745-h8pq) is an **optional peer dependency**: the package uses your app's copy
|
|
23
|
+
rather than bundling its own, so it works with the Firebase app you initialize. Install it yourself if
|
|
24
|
+
you use the Firestore models (`IDatabase*`); package managers don't add an optional peer for you. The
|
|
25
|
+
package loads without it: the Firestore classes are only loaded when one of those schemas checks a
|
|
26
|
+
value, and without firebase-admin that check fails. Only the modular entry points are used
|
|
27
|
+
(`firebase-admin/firestore`), which both majors ship, and nothing opens Firestore while the package
|
|
28
|
+
loads.
|
|
29
|
+
|
|
30
|
+
That's at runtime. The type declarations still import Firestore's types from
|
|
31
|
+
`firebase-admin/firestore`, so a TypeScript project that compiles against this package needs
|
|
32
|
+
firebase-admin installed, at least as a dev dependency. Without it, `tsc` reports TS2307 (Cannot
|
|
33
|
+
find module 'firebase-admin/firestore') under `skipLibCheck: false`. Under `skipLibCheck: true` it
|
|
34
|
+
compiles, but the Firestore-typed fields of the `IDatabase*` models become `any`.
|
|
35
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/application-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"application-settings.d.ts","sourceRoot":"","sources":["../../src/_settings/application-settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;CAc/B,CAAC"}
|
|
@@ -11,6 +11,11 @@ exports.ApplicationSettings = {
|
|
|
11
11
|
MaxSnapshotSizeLargeDocSet: 5, // the maximum number of snapshots to execute aka, store or retrieve in one request for a large document set.
|
|
12
12
|
MaxStorageRecordsPerDoc: 20, // the maximum number of records to store on a document.
|
|
13
13
|
MaxDocumentsToDeleteInBatch: 100, // the maximum number of documents to delete in a batch.
|
|
14
|
+
// the longest page cursor token accepted. Enough for most ordered values (a 1 MiB string,
|
|
15
|
+
// even JSON-escaped, fits), but not all: values Firestore stores small and that encode large
|
|
16
|
+
// (millions of empty Bytes), or overlapping orderings (a and a.b), can exceed it, and the
|
|
17
|
+
// list then refuses that page with DatabaseQueryNotSupportedError.
|
|
18
|
+
MaxPageCursorLength: 16 * 1024 * 1024,
|
|
14
19
|
},
|
|
15
20
|
SystemUser: 'System', // the system user
|
|
16
21
|
};
|
|
@@ -1 +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,EAAmC,uBAAuB,EAAiC,MAAM,uEAAuE,CAAC;
|
|
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,EAAmC,uBAAuB,EAAiC,MAAM,uEAAuE,CAAC;AAChL;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,GACpB,2BAA2B,0BAA0B,EAAE,EACvD,QAAQ,MAAM,EACd,0BAAyB,uBAAmE,KAC7F,OAAO,CAAC,IAAI,CAed,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,44 +1,10 @@
|
|
|
1
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.addItemsToDatabase = void 0;
|
|
37
|
-
const
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
38
5
|
const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
|
|
39
6
|
const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
|
|
40
7
|
const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
|
|
41
|
-
const db = admin.firestore();
|
|
42
8
|
/**
|
|
43
9
|
* this function adds an item to the database.
|
|
44
10
|
*
|
|
@@ -50,7 +16,7 @@ const db = admin.firestore();
|
|
|
50
16
|
const addItemsToDatabase = async (databaseChangeInformation, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogTypeSchema.enum.global) => {
|
|
51
17
|
const auditLogColRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log collection reference
|
|
52
18
|
// create the new records in the database
|
|
53
|
-
await
|
|
19
|
+
await (0, firestore_1.getFirestore)().runTransaction(async (t) => {
|
|
54
20
|
for (const changeRecords of databaseChangeInformation) {
|
|
55
21
|
// create the audit log
|
|
56
22
|
const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogActionSchema.enum.create, changeRecords.auditLogSubType, userId, applicationAuditLogType, changeRecords.alai, changeRecords.item, undefined);
|
package/dist/application/database/firestore/generics/add-or-update-items-to-database.d.ts.map
CHANGED
|
@@ -1 +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,EAEH,uBAAuB,EAG1B,MAAM,uEAAuE,CAAC;AAG/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;
|
|
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,EAEH,uBAAuB,EAG1B,MAAM,uEAAuE,CAAC;AAG/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,0DAA0D,CAAC;AACtG;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,GAAU,CAAC,EACvC,uBAAuB,0BAA0B,EAAE,EACnD,QAAQ,MAAM,EACd,0BAAyB,uBAAmE,KAC7F,OAAO,CAAC,IAAI,CAoCd,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -1,44 +1,10 @@
|
|
|
1
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.addOrUpdateItemsToDatabase = void 0;
|
|
37
|
-
const
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
38
5
|
const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
|
|
39
6
|
const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
|
|
40
7
|
const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
|
|
41
|
-
const db = admin.firestore();
|
|
42
8
|
/**
|
|
43
9
|
* This adds the items to the database if they do not exist, if they do exist then it updates the items.
|
|
44
10
|
*
|
|
@@ -49,7 +15,7 @@ const db = admin.firestore();
|
|
|
49
15
|
*/
|
|
50
16
|
const addOrUpdateItemsToDatabase = async (databaseChangeRecords, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogTypeSchema.enum.global) => {
|
|
51
17
|
// loop the transaction and update the database
|
|
52
|
-
await
|
|
18
|
+
await (0, firestore_1.getFirestore)().runTransaction(async (t) => {
|
|
53
19
|
const auditLogUpdates = []; // create an array of audit log updates
|
|
54
20
|
const updatedRecord = []; // create an array of updated records
|
|
55
21
|
// get the existing records from the database
|
|
@@ -1 +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,EAEH,uBAAuB,EAE1B,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0DAA0D,CAAC;
|
|
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,EAEH,uBAAuB,EAE1B,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0DAA0D,CAAC;AAI/F;;;;;;;GAOG;AACH,QAAA,MAAM,qBAAqB,GACvB,qBAAqB,mBAAmB,EAAE,EAC1C,QAAQ,MAAM,EACd,0BAAyB,uBAAmE,KAC7F,OAAO,CAAC,IAAI,CA2Bd,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,45 +1,11 @@
|
|
|
1
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.deleteItemsOnDatabase = void 0;
|
|
37
|
-
const
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
38
5
|
const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
|
|
39
6
|
const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
|
|
40
7
|
const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
|
|
41
8
|
const database_errors_1 = require("../../../../errors/database/database-errors");
|
|
42
|
-
const db = admin.firestore();
|
|
43
9
|
/**
|
|
44
10
|
* This deletes the items on the database.
|
|
45
11
|
*
|
|
@@ -51,7 +17,7 @@ const db = admin.firestore();
|
|
|
51
17
|
const deleteItemsOnDatabase = async (databaseDeleteItems, userId, applicationAuditLogType = application_audit_log_models_1.ApplicationAuditLogTypeSchema.enum.global) => {
|
|
52
18
|
const auditLogColRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log collection reference
|
|
53
19
|
// create the new records in the database
|
|
54
|
-
await
|
|
20
|
+
await (0, firestore_1.getFirestore)().runTransaction(async (t) => {
|
|
55
21
|
const existingRecords = []; // the existing records in the database, get these for the audit logs and throw error on not foudn checks
|
|
56
22
|
for (const changeRecords of databaseDeleteItems) {
|
|
57
23
|
const existingRecordSnap = await t.get(changeRecords.itemDocRef);
|
|
@@ -1 +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,EAEH,uBAAuB,EAE1B,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;
|
|
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,EAEH,uBAAuB,EAE1B,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0DAA0D,CAAC;AAE5F;;;;;;;GAOG;AACH,QAAA,MAAM,mBAAmB,GAAU,CAAC,EAChC,SAAS,gBAAgB,EACzB,QAAQ,MAAM,EACd,0BAAyB,uBAAmE,KAC7F,OAAO,CAAC,CAAC,GAAG,SAAS,CAgBvB,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,45 +1,11 @@
|
|
|
1
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getItemFromDatabase = void 0;
|
|
37
|
-
const
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
38
5
|
const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
|
|
39
6
|
const database_errors_1 = require("../../../../errors/database/database-errors");
|
|
40
7
|
const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
|
|
41
8
|
const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
|
|
42
|
-
const db = admin.firestore();
|
|
43
9
|
/**
|
|
44
10
|
* This gets a single item from the database
|
|
45
11
|
*
|
|
@@ -52,7 +18,7 @@ const getItemFromDatabase = async (getItem, userId, applicationAuditLogType = ap
|
|
|
52
18
|
const auditLogRef = (0, create_audit_log_col_ref_1.createAuditLogColRef)(); // create the audit log reference
|
|
53
19
|
// create the audit log information
|
|
54
20
|
const auditLog = (0, create_application_audit_log_1.createApplicationAuditLog)(application_audit_log_models_1.ApplicationAuditLogActionSchema.enum.read, getItem.auditLogSubType, userId, applicationAuditLogType, getItem.alai, undefined, undefined);
|
|
55
|
-
const itemData = await
|
|
21
|
+
const itemData = await (0, firestore_1.getFirestore)().runTransaction(async (t) => {
|
|
56
22
|
const connectedSnap = await t.get(getItem.itemDocRef); // get the connected snap
|
|
57
23
|
t.create(auditLogRef.doc(), auditLog); // add the audit log to the database.
|
|
58
24
|
return connectedSnap.data();
|
package/dist/application/database/firestore/generics/get-items-different-path-on-database.d.ts.map
CHANGED
|
@@ -1 +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,EAEH,uBAAuB,EAG1B,MAAM,uEAAuE,CAAC;
|
|
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,EAEH,uBAAuB,EAG1B,MAAM,uEAAuE,CAAC;AAG/E;;;;;;;GAOG;AACH,QAAA,MAAM,gCAAgC,GAAU,CAAC,EAC7C,eAAe,MAAM,EAAE,EACvB,QAAQ,MAAM,EACd,0BAAyB,uBAAmE,KAC7F,OAAO,CAAC,CAAC,EAAE,CA2Bb,CAAC;AAEF,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|
package/dist/application/database/firestore/generics/get-items-different-path-on-database.js
CHANGED
|
@@ -1,45 +1,11 @@
|
|
|
1
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getItemsDifferentPathsOnDatabase = void 0;
|
|
37
|
-
const
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
38
5
|
const create_audit_log_col_ref_1 = require("../path-references/audit-log/create-audit-log-col-ref");
|
|
39
6
|
const application_audit_log_models_1 = require("../../../../models/application/audit-log/application-audit-log-models");
|
|
40
7
|
const create_multiple_path_alai_1 = require("../../../audit-log/additional-ids/create-multiple-path-alai");
|
|
41
8
|
const create_application_audit_log_1 = require("../../../audit-log/create-application-audit-log");
|
|
42
|
-
const db = admin.firestore();
|
|
43
9
|
/**
|
|
44
10
|
* This function gets the items from different paths on the database.
|
|
45
11
|
*
|
|
@@ -53,7 +19,7 @@ const getItemsDifferentPathsOnDatabase = async (documentPaths, userId, applicati
|
|
|
53
19
|
// create the promisees for the documents.
|
|
54
20
|
const documentPromises = [];
|
|
55
21
|
for (const documentPath of documentPaths) {
|
|
56
|
-
documentPromises.push(
|
|
22
|
+
documentPromises.push((0, firestore_1.getFirestore)().doc(documentPath).get());
|
|
57
23
|
}
|
|
58
24
|
// create the audit log additional ids information
|
|
59
25
|
const alai = (0, create_multiple_path_alai_1.createMultiplePathALAI)(documentPaths);
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { ApplicationAuditLogType } from '../../../../models/application/audit-log/application-audit-log-models';
|
|
2
|
-
import { IDatabaseGetInformation } from '../../../../models/application/database/firestore-models';
|
|
2
|
+
import { IDatabaseGetInformation, IDatabasePage } from '../../../../models/application/database/firestore-models';
|
|
3
3
|
/**
|
|
4
|
-
* This function queries the database and returns
|
|
4
|
+
* This function queries the database and returns a page of items, and the cursor for the next page.
|
|
5
5
|
*
|
|
6
6
|
* @param getInformation the get information (instructions for this function)
|
|
7
7
|
* @param userId the user ID performing the action
|
|
8
8
|
* @param applicationAuditLogType the type of audit log to create
|
|
9
9
|
* @param <T> the type of the items to return
|
|
10
|
-
* @returns
|
|
10
|
+
* @returns the page's items, and nextCursor when more items follow
|
|
11
|
+
* @throws {DatabaseQueryNotSupportedError} when the list's filters and order can't be run (a bad
|
|
12
|
+
* field path, or a filter value the SDK refuses while building the query, such as undefined),
|
|
13
|
+
* or the last item's ordered values can't be held in a page cursor. A value the SDK only
|
|
14
|
+
* refuses when it serializes the request (a function, say) surfaces as the SDK's own error.
|
|
15
|
+
* @throws {DatabaseCursorInvalidError} when the cursor is malformed or came from another list.
|
|
11
16
|
*/
|
|
12
|
-
declare const getItemsFromDatabase: <T>(userId: string, getInformation: IDatabaseGetInformation, applicationAuditLogType?: ApplicationAuditLogType) => Promise<T
|
|
17
|
+
declare const getItemsFromDatabase: <T>(userId: string, getInformation: IDatabaseGetInformation, applicationAuditLogType?: ApplicationAuditLogType) => Promise<IDatabasePage<T>>;
|
|
13
18
|
export { getItemsFromDatabase };
|
|
14
19
|
//# sourceMappingURL=get-items-from-database.d.ts.map
|
|
@@ -1 +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":"
|
|
1
|
+
{"version":3,"file":"get-items-from-database.d.ts","sourceRoot":"","sources":["../../../../../src/application/database/firestore/generics/get-items-from-database.ts"],"names":[],"mappings":"AAGA,OAAO,EAEH,uBAAuB,EAE1B,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EACH,uBAAuB,EACvB,aAAa,EAGhB,MAAM,0DAA0D,CAAC;AA6HlE;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,oBAAoB,GAAU,CAAC,EACjC,QAAQ,MAAM,EACd,gBAAgB,uBAAuB,EACvC,0BAAyB,uBAAmE,KAC7F,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAgF1B,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|