@nu-art/firebase-backend 0.400.5

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 (65) hide show
  1. package/ModuleBE_Firebase.d.ts +20 -0
  2. package/ModuleBE_Firebase.js +69 -0
  3. package/auth/FirebaseBaseWrapper.d.ts +19 -0
  4. package/auth/FirebaseBaseWrapper.js +39 -0
  5. package/auth/FirebaseSession_Admin.d.ts +19 -0
  6. package/auth/FirebaseSession_Admin.js +45 -0
  7. package/auth/firebase-session.d.ts +61 -0
  8. package/auth/firebase-session.js +93 -0
  9. package/database/DatabaseWrapperBE.d.ts +71 -0
  10. package/database/DatabaseWrapperBE.js +182 -0
  11. package/database/types.d.ts +4 -0
  12. package/database/types.js +18 -0
  13. package/firestore/FirestoreCollection.d.ts +71 -0
  14. package/firestore/FirestoreCollection.js +184 -0
  15. package/firestore/FirestoreInterface.d.ts +11 -0
  16. package/firestore/FirestoreInterface.js +111 -0
  17. package/firestore/FirestoreTransaction.d.ts +30 -0
  18. package/firestore/FirestoreTransaction.js +153 -0
  19. package/firestore/FirestoreWrapperBE.d.ts +16 -0
  20. package/firestore/FirestoreWrapperBE.js +53 -0
  21. package/firestore/types.d.ts +6 -0
  22. package/firestore/types.js +25 -0
  23. package/firestore-v3/DocWrapperV3.d.ts +32 -0
  24. package/firestore-v3/DocWrapperV3.js +148 -0
  25. package/firestore-v3/FirestoreCollectionV3.d.ts +154 -0
  26. package/firestore-v3/FirestoreCollectionV3.js +470 -0
  27. package/firestore-v3/FirestoreInterfaceV3.d.ts +10 -0
  28. package/firestore-v3/FirestoreInterfaceV3.js +107 -0
  29. package/firestore-v3/FirestoreWrapperBEV3.d.ts +16 -0
  30. package/firestore-v3/FirestoreWrapperBEV3.js +154 -0
  31. package/firestore-v3/consts.d.ts +13 -0
  32. package/firestore-v3/consts.js +18 -0
  33. package/firestore-v3/types.d.ts +6 -0
  34. package/firestore-v3/types.js +1 -0
  35. package/functions/firebase-function.d.ts +38 -0
  36. package/functions/firebase-function.js +53 -0
  37. package/functions-v2/ModuleBE_BaseFunction.d.ts +11 -0
  38. package/functions-v2/ModuleBE_BaseFunction.js +32 -0
  39. package/functions-v2/ModuleBE_ExpressFunction_V2.d.ts +11 -0
  40. package/functions-v2/ModuleBE_ExpressFunction_V2.js +29 -0
  41. package/functions-v2/ModuleBE_FirebaseDBListener.d.ts +10 -0
  42. package/functions-v2/ModuleBE_FirebaseDBListener.js +24 -0
  43. package/functions-v2/ModuleBE_FirebaseScheduler.d.ts +32 -0
  44. package/functions-v2/ModuleBE_FirebaseScheduler.js +57 -0
  45. package/functions-v2/ModuleBE_FirestoreListener.d.ts +13 -0
  46. package/functions-v2/ModuleBE_FirestoreListener.js +21 -0
  47. package/functions-v2/ModuleBE_PubSubFunction.d.ts +13 -0
  48. package/functions-v2/ModuleBE_PubSubFunction.js +47 -0
  49. package/functions-v2/ModuleBE_StorageListener.d.ts +13 -0
  50. package/functions-v2/ModuleBE_StorageListener.js +34 -0
  51. package/index.d.ts +21 -0
  52. package/index.js +38 -0
  53. package/package.json +75 -0
  54. package/push/PushMessagesWrapperBE.d.ts +14 -0
  55. package/push/PushMessagesWrapperBE.js +44 -0
  56. package/push/types.d.ts +3 -0
  57. package/push/types.js +18 -0
  58. package/storage/StorageWrapperBE.d.ts +63 -0
  59. package/storage/StorageWrapperBE.js +246 -0
  60. package/storage/emulator.d.ts +4 -0
  61. package/storage/emulator.js +46 -0
  62. package/storage/types.d.ts +4 -0
  63. package/storage/types.js +18 -0
  64. package/tools/lock-operation.d.ts +10 -0
  65. package/tools/lock-operation.js +35 -0
@@ -0,0 +1,32 @@
1
+ import { DBProto, UniqueId } from '@nu-art/ts-common';
2
+ import { FirestoreType_DocumentReference } from '../firestore/types.js';
3
+ import { Transaction } from 'firebase-admin/firestore';
4
+ import { FirestoreCollectionV3 } from './FirestoreCollectionV3.js';
5
+ import type { firestore as Fa } from 'firebase-admin';
6
+ export type UpdateObject<Proto extends DBProto<any>> = {
7
+ _id: UniqueId;
8
+ } & Fa.UpdateData<Proto['dbType']>;
9
+ export declare class DocWrapperV3<Proto extends DBProto<any>> {
10
+ readonly ref: FirestoreType_DocumentReference<Proto['dbType']>;
11
+ readonly collection: FirestoreCollectionV3<Proto>;
12
+ data?: Proto['dbType'];
13
+ protected constructor(collection: FirestoreCollectionV3<Proto>, ref: FirestoreType_DocumentReference<Proto['dbType']>, data?: Proto['dbType']);
14
+ fromCache: () => Proto["dbType"] | undefined;
15
+ cleanCache: () => DocWrapperV3<Proto>;
16
+ private assertId;
17
+ get: (transaction?: Transaction) => Promise<Proto["dbType"] | undefined>;
18
+ prepareForCreate: (preDBItem: Proto["uiType"], transaction?: Transaction, upgrade?: boolean) => Promise<Proto["dbType"]>;
19
+ create: (preDBItem: Proto["uiType"], transaction?: Transaction) => Promise<Proto["dbType"]>;
20
+ prepareForSet: (updatedDBItem: Proto["dbType"], dbItem?: Proto["dbType"], transaction?: Transaction, upgrade?: boolean) => Promise<Proto["dbType"]>;
21
+ set: (item: Proto["uiType"] | Proto["dbType"], transaction?: Transaction) => Promise<Proto["dbType"]>;
22
+ private postWriteProcessing;
23
+ prepareForUpdate(updateData: UpdateObject<Proto['dbType']>, transaction?: Transaction): Promise<UpdateObject<Proto["dbType"]>>;
24
+ /**
25
+ * Recursively replaces any undefined or null fields in DB item with firestore.FieldValue.delete()
26
+ * @private
27
+ * @param updateData
28
+ */
29
+ private updateDeletedFields;
30
+ update: (updateData: UpdateObject<Proto["dbType"]>) => Promise<Proto["dbType"] | undefined>;
31
+ delete: (transaction?: Transaction) => Promise<Proto["dbType"] | undefined>;
32
+ }
@@ -0,0 +1,148 @@
1
+ import { _keys, currentTimeMillis, exists, MUSTNeverHappenException } from '@nu-art/ts-common';
2
+ import { assertUniqueId } from './FirestoreCollectionV3.js';
3
+ import { HttpCodes } from '@nu-art/ts-common/core/exceptions/http-codes';
4
+ import { addDeletedToTransaction } from './consts.js';
5
+ import admin from 'firebase-admin';
6
+ const { FieldValue } = admin.firestore;
7
+ export class DocWrapperV3 {
8
+ ref;
9
+ collection;
10
+ data;
11
+ constructor(collection, ref, data) {
12
+ this.collection = collection;
13
+ this.ref = ref;
14
+ this.data = data;
15
+ }
16
+ fromCache = () => {
17
+ return this.data;
18
+ };
19
+ cleanCache = () => {
20
+ delete this.data;
21
+ return this;
22
+ };
23
+ assertId(item) {
24
+ item._id = assertUniqueId(item, this.collection.uniqueKeys);
25
+ if (item._id !== this.ref.id)
26
+ throw new MUSTNeverHappenException(`Composed _id does not match doc ref id! \n expected: ${this.ref.id} \n actual: ${item._id} \n`);
27
+ }
28
+ get = async (transaction) => {
29
+ if (transaction)
30
+ return this.data ?? (this.data = (await transaction.get(this.ref)).data());
31
+ return this.data ?? (this.data = (await this.ref.get()).data());
32
+ };
33
+ prepareForCreate = async (preDBItem, transaction, upgrade = true) => {
34
+ const now = currentTimeMillis();
35
+ this.assertId(preDBItem);
36
+ preDBItem.__updated = preDBItem.__created = now;
37
+ if (upgrade) {
38
+ preDBItem._v = this.collection.getVersion();
39
+ await this.collection.hooks?.upgradeInstances([preDBItem]);
40
+ }
41
+ await this.collection.hooks?.preWriteProcessing?.(preDBItem, undefined, transaction);
42
+ this.collection.validateItem(preDBItem);
43
+ return preDBItem;
44
+ };
45
+ create = async (preDBItem, transaction) => {
46
+ const dbItem = await this.prepareForCreate(preDBItem);
47
+ if (transaction) {
48
+ transaction.create(this.ref, dbItem);
49
+ this.data = dbItem;
50
+ }
51
+ else
52
+ await this.ref.create(dbItem);
53
+ this.postWriteProcessing({ updated: dbItem }, 'create', transaction);
54
+ return dbItem;
55
+ };
56
+ prepareForSet = async (updatedDBItem, dbItem, transaction, upgrade = true) => {
57
+ if (!dbItem)
58
+ return this.prepareForCreate(updatedDBItem, transaction);
59
+ this.assertId(updatedDBItem);
60
+ updatedDBItem.__created = dbItem.__created;
61
+ this.collection.dbDef.lockKeys?.forEach(lockedKey => {
62
+ if (exists(dbItem[lockedKey]))
63
+ updatedDBItem[lockedKey] = dbItem[lockedKey];
64
+ });
65
+ updatedDBItem.__updated = currentTimeMillis();
66
+ if (this.collection.needsUpgrade(updatedDBItem._v)) {
67
+ await this.collection.hooks?.upgradeInstances([updatedDBItem]);
68
+ }
69
+ updatedDBItem._v = this.collection.getVersion();
70
+ await this.collection.hooks?.preWriteProcessing?.(updatedDBItem, dbItem, transaction);
71
+ this.collection.validateItem(updatedDBItem);
72
+ return updatedDBItem;
73
+ };
74
+ set = async (item, transaction) => {
75
+ if (!transaction)
76
+ return this.collection.runTransaction((transaction) => this.set(item, transaction));
77
+ const currDBItem = await this.get(transaction);
78
+ if ((currDBItem?.__updated || 0) > (item.__updated || currentTimeMillis()))
79
+ throw HttpCodes._4XX.ENTITY_IS_OUTDATED('Item is outdated', `${this.collection.collection.path}/${currDBItem?._id} is outdated`);
80
+ const newDBItem = await this.prepareForSet(item, currDBItem, transaction, false);
81
+ // Will always get here with a transaction!
82
+ transaction.set(this.ref, newDBItem);
83
+ this.data = currDBItem;
84
+ this.postWriteProcessing({ updated: newDBItem, before: currDBItem }, 'set', transaction);
85
+ return newDBItem;
86
+ };
87
+ postWriteProcessing(data, actionType, transaction) {
88
+ const toExecute = () => this.collection.hooks?.postWriteProcessing?.(data, actionType);
89
+ if (transaction)
90
+ // @ts-ignore
91
+ transaction.postTransaction(toExecute);
92
+ else
93
+ toExecute();
94
+ }
95
+ async prepareForUpdate(updateData, transaction) {
96
+ delete updateData.__created;
97
+ delete updateData._v;
98
+ updateData.__updated = currentTimeMillis();
99
+ // this.collection.dbDef.lockKeys?.forEach(lockedKey => {
100
+ // (updateData as Partial<Proto['dbType']>)[lockedKey] = undefined;
101
+ // });
102
+ this.updateDeletedFields(updateData);
103
+ await this.collection.validateUpdateData(updateData, transaction);
104
+ return updateData;
105
+ }
106
+ /**
107
+ * Recursively replaces any undefined or null fields in DB item with firestore.FieldValue.delete()
108
+ * @private
109
+ * @param updateData
110
+ */
111
+ updateDeletedFields(updateData) {
112
+ if (typeof updateData !== 'object' || updateData === null)
113
+ return;
114
+ _keys(updateData).forEach(_key => {
115
+ const _value = updateData[_key];
116
+ if (!exists(_value)) {
117
+ updateData[_key] = FieldValue.delete();
118
+ }
119
+ else {
120
+ this.updateDeletedFields(_value);
121
+ }
122
+ });
123
+ }
124
+ update = async (updateData) => {
125
+ updateData = await this.prepareForUpdate(updateData);
126
+ await this.ref.update(updateData);
127
+ const dbItem = await this.get();
128
+ this.postWriteProcessing({ updated: dbItem }, 'update');
129
+ return dbItem;
130
+ };
131
+ delete = async (transaction) => {
132
+ if (!transaction)
133
+ return this.collection.runTransaction(transaction => this.delete(transaction));
134
+ const dbItem = await this.get(transaction);
135
+ if (!dbItem)
136
+ return;
137
+ addDeletedToTransaction(transaction, {
138
+ dbKey: this.collection.dbDef.entityName,
139
+ ids: [dbItem._id]
140
+ });
141
+ await this.collection.hooks?.canDeleteItems([dbItem], transaction);
142
+ // Will always get here with a transaction!
143
+ transaction.delete(this.ref);
144
+ this.cleanCache();
145
+ this.postWriteProcessing({ deleted: dbItem }, 'delete', transaction);
146
+ return dbItem;
147
+ };
148
+ }
@@ -0,0 +1,154 @@
1
+ import { CustomException, DBDef_V3, DBProto, InvalidResult, Logger, UniqueId } from '@nu-art/ts-common';
2
+ import { FirestoreType_Collection, FirestoreType_DocumentReference } from '../firestore/types.js';
3
+ import { Clause_Where, FirestoreQuery, MultiWriteOperation } from '@nu-art/firebase-shared';
4
+ import { FirestoreWrapperBEV3 } from './FirestoreWrapperBEV3.js';
5
+ import { Transaction } from 'firebase-admin/firestore';
6
+ import { firestore } from 'firebase-admin';
7
+ import { DocWrapperV3, UpdateObject } from './DocWrapperV3.js';
8
+ import UpdateData = firestore.UpdateData;
9
+ export type PostWriteProcessingData<Proto extends DBProto<any>> = {
10
+ before?: Proto['dbType'] | Proto['dbType'][];
11
+ updated?: Proto['dbType'] | Proto['dbType'][];
12
+ deleted?: Proto['dbType'] | Proto['dbType'][] | null;
13
+ };
14
+ export type CollectionActionType = 'create' | 'set' | 'update' | 'delete';
15
+ export type FirestoreCollectionHooks<Proto extends DBProto<any>> = {
16
+ canDeleteItems: (dbItems: Proto['dbType'][], transaction?: Transaction) => Promise<void>;
17
+ preWriteProcessing?: (dbInstance: Proto['dbType'], originalDbInstance?: Proto['dbType'], transaction?: Transaction) => Promise<void>;
18
+ manipulateQuery?: (query: FirestoreQuery<Proto['dbType']>) => FirestoreQuery<Proto['dbType']>;
19
+ postWriteProcessing?: (data: PostWriteProcessingData<Proto>, actionType: CollectionActionType, transaction?: Transaction) => Promise<void>;
20
+ upgradeInstances: (instances: Proto['dbType'][]) => Promise<any>;
21
+ };
22
+ export type MultiWriteItem<Op extends MultiWriteOperation, Proto extends DBProto<any>> = Op extends 'delete' ? undefined : Op extends 'update' ? UpdateObject<Proto['dbType']> : Proto;
23
+ type MultiWriteType = 'bulk' | 'batch';
24
+ /**
25
+ * # <ins>FirestoreBulkException</ins>
26
+ * @category Exceptions
27
+ */
28
+ export declare class FirestoreBulkException extends CustomException {
29
+ causes?: Error[];
30
+ constructor(causes?: Error[]);
31
+ }
32
+ /**
33
+ * FirestoreCollection is a class for handling Firestore collections.
34
+ */
35
+ export declare class FirestoreCollectionV3<Proto extends DBProto<any>> extends Logger {
36
+ readonly wrapper: FirestoreWrapperBEV3;
37
+ readonly collection: FirestoreType_Collection;
38
+ readonly dbDef: DBDef_V3<Proto>;
39
+ readonly uniqueKeys: Proto['uniqueKeys'][] | string[];
40
+ private readonly validator;
41
+ readonly hooks?: FirestoreCollectionHooks<Proto['dbType']>;
42
+ constructor(wrapper: FirestoreWrapperBEV3, _dbDef: DBDef_V3<Proto>, hooks?: FirestoreCollectionHooks<Proto['dbType']>);
43
+ doc: Readonly<{
44
+ _: (ref: FirestoreType_DocumentReference<Proto["dbType"]>, data?: Proto["dbType"]) => DocWrapperV3<Proto>;
45
+ unique: (id: Proto["uniqueParam"]) => DocWrapperV3<Proto>;
46
+ item: (item: Proto["uiType"]) => DocWrapperV3<Proto>;
47
+ all: (_ids: (Proto["uniqueParam"])[]) => DocWrapperV3<Proto>[];
48
+ allItems: (preDBItems: Proto["uiType"][]) => DocWrapperV3<Proto>[];
49
+ query: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<DocWrapperV3<Proto>[]>;
50
+ unManipulatedQuery: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<DocWrapperV3<Proto>[]>;
51
+ }>;
52
+ private getAll;
53
+ private _customQuery;
54
+ query: Readonly<{
55
+ unique: (_id: Proto["uniqueParam"], transaction?: Transaction) => Promise<Proto["dbType"] | undefined>;
56
+ uniqueAssert: (_id: Proto["uniqueParam"], transaction?: Transaction) => Promise<Proto["dbType"]>;
57
+ uniqueWhere: (where: Clause_Where<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"]>;
58
+ uniqueCustom: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"]>;
59
+ all: (_ids: (Proto["uniqueParam"])[], transaction?: Transaction) => Promise<(Proto["dbType"] | undefined)[]>;
60
+ custom: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"][]>;
61
+ where: (where: Clause_Where<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"][]>;
62
+ unManipulatedQuery: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"][]>;
63
+ }>;
64
+ uniqueGetOrCreate: (where: Clause_Where<Proto["dbType"]>, toCreate: (transaction?: Transaction) => Promise<Proto["uiType"]>, transaction?: Transaction) => Promise<Proto["dbType"] | Proto["uiType"]>;
65
+ protected _createAll: (preDBItems: Proto["uiType"][], transaction?: Transaction, multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
66
+ create: Readonly<{
67
+ item: (preDBItem: Proto["uiType"], transaction?: Transaction) => Promise<Proto["dbType"]>;
68
+ all: (preDBItems: Proto["uiType"][], transaction?: Transaction, multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
69
+ }>;
70
+ private _setAll;
71
+ set: Readonly<{
72
+ item: (preDBItem: Proto["uiType"], transaction?: Transaction) => Promise<Proto["dbType"]>;
73
+ all: (items: (Proto["uiType"] | Proto["dbType"])[], transaction?: Transaction) => Promise<Awaited<Proto["dbType"]>[]>;
74
+ /**
75
+ * Multi is a non atomic operation
76
+ */
77
+ multi: (items: (Proto["uiType"] | Proto["dbType"])[], transaction?: Transaction, multiWriteType?: MultiWriteType) => Promise<Awaited<Proto["dbType"]>[]>;
78
+ }>;
79
+ private upgradeInstances;
80
+ protected _updateAll: (updateData: UpdateObject<Proto["dbType"]>[], multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
81
+ validateUpdateData(updateData: UpdateData<Proto['dbType']>, transaction?: Transaction): Promise<void>;
82
+ protected _deleteQuery: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction, multiWriteType?: MultiWriteType) => Promise<NonNullable<Proto["dbType"]>[]>;
83
+ protected _deleteUnManipulatedQuery: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction, multiWriteType?: MultiWriteType) => Promise<NonNullable<Proto["dbType"]>[]>;
84
+ protected _deleteAll: (docsToBeDeleted: DocWrapperV3<Proto>[], transaction?: Transaction, multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
85
+ private deleteCollection;
86
+ delete: Readonly<{
87
+ unique: (id: Proto["uniqueParam"], transaction?: Transaction) => Promise<Proto["dbType"] | undefined>;
88
+ item: (item: Proto["uiType"], transaction?: Transaction) => Promise<Proto["dbType"] | undefined>;
89
+ all: (ids: (Proto["uniqueParam"])[], transaction?: Transaction) => Promise<Proto["dbType"][]>;
90
+ allDocs: (docs: DocWrapperV3<Proto>[], transaction?: Transaction) => Promise<Proto["dbType"][]>;
91
+ allItems: (items: Proto["uiType"][], transaction?: Transaction) => Promise<Proto["dbType"][]>;
92
+ query: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"][]>;
93
+ unManipulatedQuery: (query: FirestoreQuery<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"][]>;
94
+ where: (where: Clause_Where<Proto["dbType"]>, transaction?: Transaction) => Promise<Proto["dbType"][]>;
95
+ /**
96
+ * Multi is a non atomic operation - doesn't use transactions. Use 'all' variants for transaction.
97
+ */
98
+ multi: {
99
+ all: (ids: UniqueId[], multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
100
+ items: (items: Proto["uiType"][], multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
101
+ allDocs: (docs: DocWrapperV3<Proto>[], multiWriteType?: MultiWriteType) => Promise<Proto["dbType"][]>;
102
+ query: (query: FirestoreQuery<Proto["dbType"]>, multiWriteType?: MultiWriteType) => Promise<NonNullable<Proto["dbType"]>[]>;
103
+ };
104
+ yes: {
105
+ iam: {
106
+ sure: {
107
+ iwant: {
108
+ todelete: {
109
+ the: {
110
+ collection: {
111
+ delete: () => Promise<void>;
112
+ };
113
+ };
114
+ };
115
+ };
116
+ };
117
+ };
118
+ };
119
+ }>;
120
+ /**
121
+ * @param writer Type of BulkWriter - can be Bulk writer or Batch writer
122
+ * @param doc
123
+ * @param operation create/update/set/delete
124
+ * @param item - mandatory for everything but delete
125
+ */
126
+ private addToMultiWrite;
127
+ private multiWrite;
128
+ private bulkWrite;
129
+ /**
130
+ * @param docs docs to write to
131
+ * @param operation create/update/set/delete
132
+ * @param items mandatory for everything but delete
133
+ */
134
+ private batchWrite;
135
+ /**
136
+ * A firestore transaction is run globally on the firestore project and not specifically on any collection, locking specific documents in the project.
137
+ * @param processor
138
+ * @param transaction A transaction that was provided to be used
139
+ */
140
+ runTransaction: <ReturnType>(processor: (transaction: Transaction) => Promise<ReturnType>, transaction?: Transaction) => Promise<ReturnType>;
141
+ runTransactionInChunks: <T = any, R = any>(items: T[], processor: (chunk: typeof items, transaction: Transaction) => Promise<R[]>, chunkSize?: number) => Promise<R[]>;
142
+ getVersion: () => any;
143
+ needsUpgrade: (version?: string) => boolean;
144
+ validateItem(dbItem: Proto['dbType']): void;
145
+ protected onValidationError(instance: Proto['dbType'], results: InvalidResult<Proto['dbType']>): void;
146
+ private assertNoDuplicatedIds;
147
+ composeDbObjectUniqueId: (item: Proto["uiType"]) => string;
148
+ }
149
+ /**
150
+ * If the collection has unique keys, assert they exist, and use them to generate the _id.
151
+ * In the case an _id already exists, verify it is not different from the uniqueKeys-generated _id.
152
+ */
153
+ export declare const assertUniqueId: <Proto extends DBProto<any>>(item: Proto["dbType"], keys: Proto["uniqueKeys"]) => string;
154
+ export {};