@nu-art/firebase-backend 0.401.9 → 0.500.6

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 (56) hide show
  1. package/ModuleBE_Firebase.d.ts +15 -1
  2. package/ModuleBE_Firebase.js +39 -3
  3. package/auth/firebase-session.d.ts +12 -8
  4. package/auth/firebase-session.js +53 -15
  5. package/firestore/DocWrapper.d.ts +30 -0
  6. package/{firestore-v3/DocWrapperV3.js → firestore/DocWrapper.js} +30 -32
  7. package/firestore/FirestoreCollection.d.ts +141 -59
  8. package/firestore/FirestoreCollection.js +419 -147
  9. package/firestore/FirestoreInterface.d.ts +2 -3
  10. package/firestore/FirestoreInterface.js +1 -5
  11. package/firestore/FirestoreWrapperBE.d.ts +5 -6
  12. package/firestore/FirestoreWrapperBE.js +119 -9
  13. package/firestore/MongoCollection.d.ts +81 -0
  14. package/firestore/MongoCollection.js +426 -0
  15. package/firestore/MongoInterface.d.ts +18 -0
  16. package/firestore/MongoInterface.js +132 -0
  17. package/firestore/MongoWrapperBE.d.ts +18 -0
  18. package/firestore/MongoWrapperBE.js +95 -0
  19. package/firestore/consts.d.ts +23 -0
  20. package/firestore/consts.js +34 -0
  21. package/firestore/types.d.ts +6 -1
  22. package/firestore/types.js +0 -24
  23. package/{functions-v2 → functions}/ModuleBE_BaseFunction.d.ts +6 -3
  24. package/{functions-v2 → functions}/ModuleBE_BaseFunction.js +1 -0
  25. package/{functions-v2/ModuleBE_ExpressFunction_V2.d.ts → functions/ModuleBE_ExpressFunction_Class.d.ts} +5 -3
  26. package/{functions-v2/ModuleBE_ExpressFunction_V2.js → functions/ModuleBE_ExpressFunction_Class.js} +7 -3
  27. package/{functions-v2 → functions}/ModuleBE_FirebaseDBListener.d.ts +2 -1
  28. package/{functions-v2 → functions}/ModuleBE_FirebaseDBListener.js +1 -0
  29. package/{functions-v2 → functions}/ModuleBE_FirebaseScheduler.js +1 -0
  30. package/{functions-v2 → functions}/ModuleBE_FirestoreListener.d.ts +5 -1
  31. package/{functions-v2 → functions}/ModuleBE_FirestoreListener.js +1 -0
  32. package/{functions-v2 → functions}/ModuleBE_PubSubFunction.d.ts +5 -2
  33. package/{functions-v2 → functions}/ModuleBE_PubSubFunction.js +1 -0
  34. package/{functions-v2 → functions}/ModuleBE_StorageListener.js +1 -0
  35. package/index.d.ts +16 -13
  36. package/index.js +16 -13
  37. package/package.json +10 -7
  38. package/firestore/FirestoreTransaction.d.ts +0 -30
  39. package/firestore/FirestoreTransaction.js +0 -153
  40. package/firestore-v3/DocWrapperV3.d.ts +0 -32
  41. package/firestore-v3/FirestoreCollectionV3.d.ts +0 -154
  42. package/firestore-v3/FirestoreCollectionV3.js +0 -470
  43. package/firestore-v3/FirestoreInterfaceV3.d.ts +0 -10
  44. package/firestore-v3/FirestoreInterfaceV3.js +0 -107
  45. package/firestore-v3/FirestoreWrapperBEV3.d.ts +0 -16
  46. package/firestore-v3/FirestoreWrapperBEV3.js +0 -154
  47. package/firestore-v3/consts.d.ts +0 -13
  48. package/firestore-v3/consts.js +0 -18
  49. package/firestore-v3/types.d.ts +0 -6
  50. package/firestore-v3/types.js +0 -1
  51. package/functions/firebase-function.d.ts +0 -38
  52. package/functions/firebase-function.js +0 -53
  53. package/v1.d.ts +0 -21
  54. package/v1.js +0 -38
  55. /package/{functions-v2 → functions}/ModuleBE_FirebaseScheduler.d.ts +0 -0
  56. /package/{functions-v2 → functions}/ModuleBE_StorageListener.d.ts +0 -0
@@ -1,30 +0,0 @@
1
- import { DocWrapper, FirestoreCollection } from './FirestoreCollection.js';
2
- import { Subset, TS_Object } from '@nu-art/ts-common';
3
- import { FirestoreQuery } from '@nu-art/firebase-shared';
4
- import { Transaction } from 'firebase-admin/firestore';
5
- export declare class FirestoreTransaction {
6
- transaction: Transaction;
7
- constructor(transaction: Transaction);
8
- private _query;
9
- private _queryUnique;
10
- private _queryItem;
11
- query<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<Type[]>;
12
- queryItem<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Type): Promise<Type | undefined>;
13
- queryUnique<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<Type | undefined>;
14
- insert<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Type, _id?: string): Promise<Type>;
15
- insertAll<Type extends TS_Object>(collection: FirestoreCollection<Type>, instances: Type[], _ids?: string[]): Promise<Awaited<Type>[]>;
16
- upsert<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Type, _id?: string): Promise<Type>;
17
- upsert_Read<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Type, _id?: string): Promise<() => Promise<Type>>;
18
- getOrCreateDocument<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Type, _id?: string): Promise<FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData, FirebaseFirestore.DocumentData>>;
19
- upsertAll<Type extends TS_Object>(collection: FirestoreCollection<Type>, instances: Type[], _ids?: string[]): Promise<Type[]>;
20
- upsertAll_Read<Type extends TS_Object>(collection: FirestoreCollection<Type>, instances: Type[], _ids?: string[]): Promise<() => Promise<Type[]>>;
21
- patch<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Subset<Type>): Promise<any>;
22
- patch_Read<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Subset<Type>): Promise<() => Promise<any>>;
23
- delete<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<Type[]>;
24
- delete_Read<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<() => Promise<Type[]>>;
25
- deleteItem<Type extends TS_Object>(collection: FirestoreCollection<Type>, instance: Type): Promise<Type | undefined>;
26
- deleteUnique<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<Type | undefined>;
27
- deleteUnique_Read<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<undefined | (() => Promise<Type>)>;
28
- newQueryUnique<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<DocWrapper<Type> | undefined>;
29
- newQuery<Type extends TS_Object>(collection: FirestoreCollection<Type>, ourQuery: FirestoreQuery<Type>): Promise<DocWrapper<Type>[]>;
30
- }
@@ -1,153 +0,0 @@
1
- /*
2
- * Firebase is a simpler Typescript wrapper to all of firebase services.
3
- *
4
- * Copyright (C) 2020 Adam van der Kruk aka TacB0sS
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- import { DocWrapper, } from './FirestoreCollection.js';
19
- import { BadImplementationException, merge } from '@nu-art/ts-common';
20
- import { FirestoreInterface } from './FirestoreInterface.js';
21
- export class FirestoreTransaction {
22
- transaction;
23
- constructor(transaction) {
24
- this.transaction = transaction;
25
- }
26
- async _query(collection, ourQuery) {
27
- const query = FirestoreInterface.buildQuery(collection, ourQuery);
28
- return (await this.transaction.get(query)).docs;
29
- }
30
- async _queryUnique(collection, ourQuery) {
31
- const results = await this._query(collection, ourQuery);
32
- return FirestoreInterface.assertUniqueDocument(results, ourQuery, collection.name);
33
- }
34
- async _queryItem(collection, instance) {
35
- const ourQuery = FirestoreInterface.buildUniqueQuery(collection, instance);
36
- const results = await this._query(collection, ourQuery);
37
- return FirestoreInterface.assertUniqueDocument(results, ourQuery, collection.name);
38
- }
39
- async query(collection, ourQuery) {
40
- return (await this._query(collection, ourQuery)).map(result => result.data());
41
- }
42
- async queryItem(collection, instance) {
43
- const ourQuery = FirestoreInterface.buildUniqueQuery(collection, instance);
44
- return this.queryUnique(collection, ourQuery);
45
- }
46
- async queryUnique(collection, ourQuery) {
47
- const doc = await this._queryUnique(collection, ourQuery);
48
- if (!doc)
49
- return;
50
- return doc.data();
51
- }
52
- async insert(collection, instance, _id) {
53
- const doc = collection.createDocumentReference(_id);
54
- try {
55
- await this.transaction.create(doc, instance);
56
- }
57
- catch (e) {
58
- console.error('Failed creating object: ', instance, e);
59
- throw e;
60
- }
61
- return instance;
62
- }
63
- async insertAll(collection, instances, _ids) {
64
- return await Promise.all(instances.map((instance, i) => this.insert(collection, instance, _ids?.[i])));
65
- }
66
- //------------------------
67
- async upsert(collection, instance, _id) {
68
- return (await this.upsert_Read(collection, instance, _id))();
69
- }
70
- async upsert_Read(collection, instance, _id) {
71
- const ref = await this.getOrCreateDocument(collection, instance, _id);
72
- return async () => {
73
- try {
74
- await this.transaction.set(ref, instance);
75
- }
76
- catch (e) {
77
- console.error('Failed creating object: ', instance, e);
78
- throw e;
79
- }
80
- return instance;
81
- };
82
- }
83
- async getOrCreateDocument(collection, instance, _id) {
84
- let ref = (await this._queryItem(collection, instance))?.ref;
85
- if (!ref)
86
- ref = collection.createDocumentReference(_id);
87
- return ref;
88
- }
89
- async upsertAll(collection, instances, _ids) {
90
- if (instances.length > 500)
91
- throw new BadImplementationException('Firestore transaction supports maximum 500 at a time');
92
- return (await this.upsertAll_Read(collection, instances, _ids))();
93
- }
94
- async upsertAll_Read(collection, instances, _ids) {
95
- const writes = await Promise.all(instances.map(async (instance, i) => this.upsert_Read(collection, instance, _ids?.[i])));
96
- return async () => Promise.all(writes.map(async (_write) => _write()));
97
- }
98
- async patch(collection, instance) {
99
- return (await this.patch_Read(collection, instance))();
100
- }
101
- async patch_Read(collection, instance) {
102
- const doc = await this._queryItem(collection, instance);
103
- if (!doc)
104
- throw new BadImplementationException(`Patching a non existent doc for query ${FirestoreInterface.buildUniqueQuery(collection, instance)}`);
105
- return async () => {
106
- const patchedInstance = merge(await doc.data(), instance);
107
- this.transaction.set(doc.ref, patchedInstance);
108
- return patchedInstance;
109
- };
110
- }
111
- async delete(collection, ourQuery) {
112
- return await (await this.delete_Read(collection, ourQuery))();
113
- }
114
- async delete_Read(collection, ourQuery) {
115
- const docs = await this._query(collection, ourQuery);
116
- if (docs.length > 500)
117
- throw new BadImplementationException(`Trying to delete ${docs.length} documents. Not allowed more then 5oo in a single transaction`);
118
- return async () => {
119
- const toReturn = docs.map(doc => doc.data());
120
- await Promise.all(docs.map(async (doc) => this.transaction.delete(doc.ref)));
121
- return toReturn;
122
- };
123
- }
124
- async deleteItem(collection, instance) {
125
- return this.deleteUnique(collection, FirestoreInterface.buildUniqueQuery(collection, instance));
126
- }
127
- async deleteUnique(collection, ourQuery) {
128
- const write = await this.deleteUnique_Read(collection, ourQuery);
129
- if (!write)
130
- return;
131
- return write();
132
- }
133
- async deleteUnique_Read(collection, ourQuery) {
134
- const doc = (await this._queryUnique(collection, ourQuery));
135
- if (!doc)
136
- return;
137
- return async () => {
138
- const result = doc.data();
139
- await this.transaction.delete(doc.ref);
140
- return result;
141
- };
142
- }
143
- async newQueryUnique(collection, ourQuery) {
144
- const doc = await this._queryUnique(collection, ourQuery);
145
- if (!doc || !doc.exists)
146
- return;
147
- return new DocWrapper(collection.wrapper, doc);
148
- }
149
- async newQuery(collection, ourQuery) {
150
- const docs = await this._query(collection, ourQuery);
151
- return docs.filter(doc => doc.exists).map(doc => new DocWrapper(collection.wrapper, doc));
152
- }
153
- }
@@ -1,32 +0,0 @@
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
- }
@@ -1,154 +0,0 @@
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 {};