@lossless.org/client 0.1.0
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/.smartconfig.json +37 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/classes.losslessorgclient.d.ts +32 -0
- package/dist_ts/classes.losslessorgclient.js +103 -0
- package/dist_ts/core/classes.error.d.ts +16 -0
- package/dist_ts/core/classes.error.js +29 -0
- package/dist_ts/core/classes.operation.d.ts +17 -0
- package/dist_ts/core/classes.operation.js +70 -0
- package/dist_ts/core/interfaces.d.ts +18 -0
- package/dist_ts/core/interfaces.js +2 -0
- package/dist_ts/index.d.ts +4 -0
- package/dist_ts/index.js +3 -0
- package/dist_ts/nosqldb/classes.atomicdelete.d.ts +26 -0
- package/dist_ts/nosqldb/classes.atomicdelete.js +44 -0
- package/dist_ts/nosqldb/classes.atomicfindoneandupdate.d.ts +27 -0
- package/dist_ts/nosqldb/classes.atomicfindoneandupdate.js +86 -0
- package/dist_ts/nosqldb/classes.atomicupdate.d.ts +26 -0
- package/dist_ts/nosqldb/classes.atomicupdate.js +55 -0
- package/dist_ts/nosqldb/classes.bootstraprecord.d.ts +14 -0
- package/dist_ts/nosqldb/classes.bootstraprecord.js +80 -0
- package/dist_ts/nosqldb/classes.bsonassertion.d.ts +2 -0
- package/dist_ts/nosqldb/classes.bsonassertion.js +29 -0
- package/dist_ts/nosqldb/classes.bsonobjectid.d.ts +2 -0
- package/dist_ts/nosqldb/classes.bsonobjectid.js +50 -0
- package/dist_ts/nosqldb/classes.bsonsnapshot.d.ts +3 -0
- package/dist_ts/nosqldb/classes.bsonsnapshot.js +126 -0
- package/dist_ts/nosqldb/classes.cached-document.d.ts +27 -0
- package/dist_ts/nosqldb/classes.cached-document.js +112 -0
- package/dist_ts/nosqldb/classes.collection.d.ts +302 -0
- package/dist_ts/nosqldb/classes.collection.js +1568 -0
- package/dist_ts/nosqldb/classes.collectionfactory.d.ts +30 -0
- package/dist_ts/nosqldb/classes.collectionfactory.js +65 -0
- package/dist_ts/nosqldb/classes.collectionlifecycle.d.ts +4 -0
- package/dist_ts/nosqldb/classes.collectionlifecycle.js +15 -0
- package/dist_ts/nosqldb/classes.collectionpreparation.d.ts +34 -0
- package/dist_ts/nosqldb/classes.collectionpreparation.js +134 -0
- package/dist_ts/nosqldb/classes.collectiontopology.d.ts +47 -0
- package/dist_ts/nosqldb/classes.collectiontopology.js +388 -0
- package/dist_ts/nosqldb/classes.connection.d.ts +18 -0
- package/dist_ts/nosqldb/classes.connection.js +23 -0
- package/dist_ts/nosqldb/classes.convenience.d.ts +1 -0
- package/dist_ts/nosqldb/classes.convenience.js +5 -0
- package/dist_ts/nosqldb/classes.cursor.d.ts +15 -0
- package/dist_ts/nosqldb/classes.cursor.js +82 -0
- package/dist_ts/nosqldb/classes.cursoroperation.d.ts +7 -0
- package/dist_ts/nosqldb/classes.cursoroperation.js +36 -0
- package/dist_ts/nosqldb/classes.db.d.ts +98 -0
- package/dist_ts/nosqldb/classes.db.js +434 -0
- package/dist_ts/nosqldb/classes.distributedcoordinator.d.ts +52 -0
- package/dist_ts/nosqldb/classes.distributedcoordinator.js +314 -0
- package/dist_ts/nosqldb/classes.doc.d.ts +722 -0
- package/dist_ts/nosqldb/classes.doc.js +2976 -0
- package/dist_ts/nosqldb/classes.easystore.d.ts +42 -0
- package/dist_ts/nosqldb/classes.easystore.js +199 -0
- package/dist_ts/nosqldb/classes.exactpersistence.d.ts +141 -0
- package/dist_ts/nosqldb/classes.exactpersistence.js +1110 -0
- package/dist_ts/nosqldb/classes.lucene.adapter.d.ts +173 -0
- package/dist_ts/nosqldb/classes.lucene.adapter.js +623 -0
- package/dist_ts/nosqldb/classes.mongoadministration.d.ts +73 -0
- package/dist_ts/nosqldb/classes.mongoadministration.js +497 -0
- package/dist_ts/nosqldb/classes.namespaceinspection.d.ts +42 -0
- package/dist_ts/nosqldb/classes.namespaceinspection.js +138 -0
- package/dist_ts/nosqldb/classes.operationbudget.d.ts +22 -0
- package/dist_ts/nosqldb/classes.operationbudget.js +65 -0
- package/dist_ts/nosqldb/classes.ordinarypersistence.d.ts +18 -0
- package/dist_ts/nosqldb/classes.ordinarypersistence.js +71 -0
- package/dist_ts/nosqldb/classes.persistence.d.ts +14 -0
- package/dist_ts/nosqldb/classes.persistence.js +34 -0
- package/dist_ts/nosqldb/classes.session.d.ts +28 -0
- package/dist_ts/nosqldb/classes.session.js +246 -0
- package/dist_ts/nosqldb/classes.storedinspection.d.ts +44 -0
- package/dist_ts/nosqldb/classes.storedinspection.js +100 -0
- package/dist_ts/nosqldb/classes.testdatabase.d.ts +56 -0
- package/dist_ts/nosqldb/classes.testdatabase.js +250 -0
- package/dist_ts/nosqldb/classes.watcher.d.ts +37 -0
- package/dist_ts/nosqldb/classes.watcher.js +98 -0
- package/dist_ts/nosqldb/index.d.ts +27 -0
- package/dist_ts/nosqldb/index.js +18 -0
- package/dist_ts/nosqldb/logging.d.ts +2 -0
- package/dist_ts/nosqldb/logging.js +3 -0
- package/dist_ts/nosqldb/plugins.d.ts +17 -0
- package/dist_ts/nosqldb/plugins.js +20 -0
- package/dist_ts/nosqldb/shim.d.ts +1 -0
- package/dist_ts/nosqldb/shim.js +8 -0
- package/dist_ts/nosqldb/testsupport.d.ts +3 -0
- package/dist_ts/nosqldb/testsupport.js +3 -0
- package/dist_ts/objectstorage/classes.bucket.d.ts +227 -0
- package/dist_ts/objectstorage/classes.bucket.js +939 -0
- package/dist_ts/objectstorage/classes.connection.d.ts +21 -0
- package/dist_ts/objectstorage/classes.connection.js +27 -0
- package/dist_ts/objectstorage/classes.directory.d.ts +124 -0
- package/dist_ts/objectstorage/classes.directory.js +335 -0
- package/dist_ts/objectstorage/classes.exactpathpurgeerror.d.ts +5 -0
- package/dist_ts/objectstorage/classes.exactpathpurgeerror.js +18 -0
- package/dist_ts/objectstorage/classes.exactuploaderror.d.ts +5 -0
- package/dist_ts/objectstorage/classes.exactuploaderror.js +19 -0
- package/dist_ts/objectstorage/classes.file.d.ts +91 -0
- package/dist_ts/objectstorage/classes.file.js +255 -0
- package/dist_ts/objectstorage/classes.listcursor.d.ts +41 -0
- package/dist_ts/objectstorage/classes.listcursor.js +67 -0
- package/dist_ts/objectstorage/classes.metadata.d.ts +57 -0
- package/dist_ts/objectstorage/classes.metadata.js +113 -0
- package/dist_ts/objectstorage/classes.smartbucket.d.ts +57 -0
- package/dist_ts/objectstorage/classes.smartbucket.js +357 -0
- package/dist_ts/objectstorage/classes.trash.d.ts +11 -0
- package/dist_ts/objectstorage/classes.trash.js +22 -0
- package/dist_ts/objectstorage/classes.watcher.d.ts +79 -0
- package/dist_ts/objectstorage/classes.watcher.js +249 -0
- package/dist_ts/objectstorage/helpers.d.ts +25 -0
- package/dist_ts/objectstorage/helpers.js +215 -0
- package/dist_ts/objectstorage/index.d.ts +13 -0
- package/dist_ts/objectstorage/index.js +13 -0
- package/dist_ts/objectstorage/interfaces.d.ts +276 -0
- package/dist_ts/objectstorage/interfaces.js +2 -0
- package/dist_ts/objectstorage/internal.exactpathpurge.operations.d.ts +11 -0
- package/dist_ts/objectstorage/internal.exactpathpurge.operations.js +1069 -0
- package/dist_ts/objectstorage/internal.exactupload.capability.d.ts +40 -0
- package/dist_ts/objectstorage/internal.exactupload.capability.js +382 -0
- package/dist_ts/objectstorage/internal.exactupload.operations.d.ts +11 -0
- package/dist_ts/objectstorage/internal.exactupload.operations.js +1104 -0
- package/dist_ts/objectstorage/internal.multipart.planner.d.ts +8 -0
- package/dist_ts/objectstorage/internal.multipart.planner.js +63 -0
- package/dist_ts/objectstorage/internal.multipart.stream.d.ts +17 -0
- package/dist_ts/objectstorage/internal.multipart.stream.js +440 -0
- package/dist_ts/objectstorage/internal.multipart.types.d.ts +82 -0
- package/dist_ts/objectstorage/internal.multipart.types.js +2 -0
- package/dist_ts/objectstorage/plugins.d.ts +17 -0
- package/dist_ts/objectstorage/plugins.js +23 -0
- package/dist_ts/plugins.d.ts +4 -0
- package/dist_ts/plugins.js +5 -0
- package/dist_ts/sqldb/classes.clickhouseconnection.d.ts +39 -0
- package/dist_ts/sqldb/classes.clickhouseconnection.js +225 -0
- package/dist_ts/sqldb/classes.sqlconnection.d.ts +50 -0
- package/dist_ts/sqldb/classes.sqlconnection.js +376 -0
- package/dist_ts/sqldb/classes.sqltable.d.ts +29 -0
- package/dist_ts/sqldb/classes.sqltable.js +70 -0
- package/dist_ts/sqldb/clickhouse/classes.metricwriter.d.ts +27 -0
- package/dist_ts/sqldb/clickhouse/classes.metricwriter.js +89 -0
- package/dist_ts/sqldb/clickhouse/index.d.ts +9 -0
- package/dist_ts/sqldb/clickhouse/index.js +13 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.clickhousetable.d.ts +88 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.clickhousetable.js +304 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.httpclient.d.ts +28 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.httpclient.js +46 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.querybuilder.d.ts +43 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.querybuilder.js +155 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.resultset.d.ts +13 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.resultset.js +36 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.smartclickhouse.d.ts +49 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.smartclickhouse.js +106 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.timedatatable.d.ts +51 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.timedatatable.js +96 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.plugins.d.ts +5 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.plugins.js +6 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.types.d.ts +53 -0
- package/dist_ts/sqldb/clickhouse/smartclickhouse.types.js +41 -0
- package/dist_ts/sqldb/index.d.ts +6 -0
- package/dist_ts/sqldb/index.js +6 -0
- package/dist_ts/sqldb/interfaces.d.ts +53 -0
- package/dist_ts/sqldb/interfaces.js +19 -0
- package/dist_ts/sqldb/internal.sqlpool.d.ts +51 -0
- package/dist_ts/sqldb/internal.sqlpool.js +214 -0
- package/dist_ts/sqldb/plugins.clickhouse.d.ts +4 -0
- package/dist_ts/sqldb/plugins.clickhouse.js +5 -0
- package/dist_ts/sqldb/plugins.mariadb.d.ts +4 -0
- package/dist_ts/sqldb/plugins.mariadb.js +5 -0
- package/docs/source/smartbucket/license.md +19 -0
- package/docs/source/smartclickhouse/license.md +19 -0
- package/license.md +21 -0
- package/package.json +101 -0
- package/readme.md +157 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/classes.losslessorgclient.ts +104 -0
- package/ts/core/classes.error.ts +31 -0
- package/ts/core/classes.operation.ts +60 -0
- package/ts/core/interfaces.ts +24 -0
- package/ts/index.ts +4 -0
- package/ts/nosqldb/classes.atomicdelete.ts +81 -0
- package/ts/nosqldb/classes.atomicfindoneandupdate.ts +152 -0
- package/ts/nosqldb/classes.atomicupdate.ts +99 -0
- package/ts/nosqldb/classes.bootstraprecord.ts +107 -0
- package/ts/nosqldb/classes.bsonassertion.ts +25 -0
- package/ts/nosqldb/classes.bsonobjectid.ts +45 -0
- package/ts/nosqldb/classes.bsonsnapshot.ts +105 -0
- package/ts/nosqldb/classes.cached-document.ts +67 -0
- package/ts/nosqldb/classes.collection.ts +2399 -0
- package/ts/nosqldb/classes.collectionfactory.ts +87 -0
- package/ts/nosqldb/classes.collectionlifecycle.ts +24 -0
- package/ts/nosqldb/classes.collectionpreparation.ts +164 -0
- package/ts/nosqldb/classes.collectiontopology.ts +645 -0
- package/ts/nosqldb/classes.connection.ts +31 -0
- package/ts/nosqldb/classes.convenience.ts +5 -0
- package/ts/nosqldb/classes.cursor.ts +88 -0
- package/ts/nosqldb/classes.cursoroperation.ts +38 -0
- package/ts/nosqldb/classes.db.ts +637 -0
- package/ts/nosqldb/classes.distributedcoordinator.ts +305 -0
- package/ts/nosqldb/classes.doc.ts +4928 -0
- package/ts/nosqldb/classes.easystore.ts +154 -0
- package/ts/nosqldb/classes.exactpersistence.ts +1974 -0
- package/ts/nosqldb/classes.lucene.adapter.ts +780 -0
- package/ts/nosqldb/classes.mongoadministration.ts +867 -0
- package/ts/nosqldb/classes.namespaceinspection.ts +199 -0
- package/ts/nosqldb/classes.operationbudget.ts +75 -0
- package/ts/nosqldb/classes.ordinarypersistence.ts +84 -0
- package/ts/nosqldb/classes.persistence.ts +62 -0
- package/ts/nosqldb/classes.session.ts +389 -0
- package/ts/nosqldb/classes.storedinspection.ts +151 -0
- package/ts/nosqldb/classes.testdatabase.ts +272 -0
- package/ts/nosqldb/classes.watcher.ts +96 -0
- package/ts/nosqldb/index.ts +51 -0
- package/ts/nosqldb/logging.ts +3 -0
- package/ts/nosqldb/plugins.ts +37 -0
- package/ts/nosqldb/shim.ts +6 -0
- package/ts/nosqldb/testsupport.ts +13 -0
- package/ts/objectstorage/classes.bucket.ts +1114 -0
- package/ts/objectstorage/classes.connection.ts +36 -0
- package/ts/objectstorage/classes.directory.ts +425 -0
- package/ts/objectstorage/classes.exactpathpurgeerror.ts +24 -0
- package/ts/objectstorage/classes.exactuploaderror.ts +25 -0
- package/ts/objectstorage/classes.file.ts +303 -0
- package/ts/objectstorage/classes.listcursor.ts +89 -0
- package/ts/objectstorage/classes.metadata.ts +134 -0
- package/ts/objectstorage/classes.smartbucket.ts +445 -0
- package/ts/objectstorage/classes.trash.ts +30 -0
- package/ts/objectstorage/classes.watcher.ts +289 -0
- package/ts/objectstorage/helpers.ts +254 -0
- package/ts/objectstorage/index.ts +13 -0
- package/ts/objectstorage/interfaces.ts +389 -0
- package/ts/objectstorage/internal.exactpathpurge.operations.ts +1936 -0
- package/ts/objectstorage/internal.exactupload.capability.ts +580 -0
- package/ts/objectstorage/internal.exactupload.operations.ts +1715 -0
- package/ts/objectstorage/internal.multipart.planner.ts +90 -0
- package/ts/objectstorage/internal.multipart.stream.ts +606 -0
- package/ts/objectstorage/internal.multipart.types.ts +106 -0
- package/ts/objectstorage/plugins.ts +35 -0
- package/ts/plugins.ts +4 -0
- package/ts/sqldb/classes.clickhouseconnection.ts +189 -0
- package/ts/sqldb/classes.sqlconnection.ts +350 -0
- package/ts/sqldb/classes.sqltable.ts +70 -0
- package/ts/sqldb/clickhouse/classes.metricwriter.ts +72 -0
- package/ts/sqldb/clickhouse/index.ts +16 -0
- package/ts/sqldb/clickhouse/smartclickhouse.classes.clickhousetable.ts +372 -0
- package/ts/sqldb/clickhouse/smartclickhouse.classes.httpclient.ts +52 -0
- package/ts/sqldb/clickhouse/smartclickhouse.classes.querybuilder.ts +120 -0
- package/ts/sqldb/clickhouse/smartclickhouse.classes.resultset.ts +44 -0
- package/ts/sqldb/clickhouse/smartclickhouse.classes.smartclickhouse.ts +123 -0
- package/ts/sqldb/clickhouse/smartclickhouse.classes.timedatatable.ts +114 -0
- package/ts/sqldb/clickhouse/smartclickhouse.plugins.ts +5 -0
- package/ts/sqldb/clickhouse/smartclickhouse.types.ts +134 -0
- package/ts/sqldb/index.ts +6 -0
- package/ts/sqldb/interfaces.ts +61 -0
- package/ts/sqldb/internal.sqlpool.ts +179 -0
- package/ts/sqldb/plugins.clickhouse.ts +4 -0
- package/ts/sqldb/plugins.mariadb.ts +4 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { type ISmartdataCollectionPreparationOptions } from './classes.collectionpreparation.js';
|
|
3
|
+
import { type IOrdinaryPersistencePolicy } from './classes.ordinarypersistence.js';
|
|
4
|
+
import { SmartdataDb } from './classes.db.js';
|
|
5
|
+
import { SmartdataDbCursor } from './classes.cursor.js';
|
|
6
|
+
import { SmartDataDbDoc, type IIndexOptions, type TSmartdataNumericDocumentPath, type TSmartdataIdentityValueType } from './classes.doc.js';
|
|
7
|
+
import { SmartdataDbWatcher } from './classes.watcher.js';
|
|
8
|
+
import { type TSmartdataOrdinarySession } from './classes.session.js';
|
|
9
|
+
export interface IFindOptions {
|
|
10
|
+
limit?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export interface IDocValidationFunc<T> {
|
|
16
|
+
(doc: T): boolean;
|
|
17
|
+
}
|
|
18
|
+
export type TDelayed<TDelayedArg> = () => TDelayedArg;
|
|
19
|
+
export interface ICollectionBindingOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Explicit persisted collection name. Use this to bind a renamed model to
|
|
22
|
+
* its legacy collection without changing stored data.
|
|
23
|
+
*/
|
|
24
|
+
collectionName?: string;
|
|
25
|
+
}
|
|
26
|
+
export type TCollectionModelIndexDirection = 1 | -1 | 'text';
|
|
27
|
+
export interface ICollectionModelIndexOptions {
|
|
28
|
+
background?: boolean;
|
|
29
|
+
unique?: boolean;
|
|
30
|
+
sparse?: boolean;
|
|
31
|
+
expireAfterSeconds?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface ICollectionModelIndex {
|
|
34
|
+
name: string;
|
|
35
|
+
key: Record<string, TCollectionModelIndexDirection>;
|
|
36
|
+
options?: ICollectionModelIndexOptions;
|
|
37
|
+
}
|
|
38
|
+
/** Named index on one or more paths rooted in the model's persisted fields. */
|
|
39
|
+
export interface INamedIndexDefinition extends ICollectionModelIndex {
|
|
40
|
+
}
|
|
41
|
+
export type TStringFieldKey<TModel extends object> = {
|
|
42
|
+
[TKey in keyof TModel]-?: NonNullable<TModel[TKey]> extends string ? TKey : never;
|
|
43
|
+
}[keyof TModel] & string;
|
|
44
|
+
export interface ICollectionModelConfig<TModel extends object = any> {
|
|
45
|
+
/**
|
|
46
|
+
* The persisted collection name. Programmatic model binding never derives
|
|
47
|
+
* this value from a constructor name.
|
|
48
|
+
*/
|
|
49
|
+
collectionName: string;
|
|
50
|
+
/**
|
|
51
|
+
* Top-level model fields that SmartData may persist.
|
|
52
|
+
*/
|
|
53
|
+
persistedFields: ReadonlyArray<keyof TModel & string>;
|
|
54
|
+
/**
|
|
55
|
+
* Persisted top-level numeric fields that strict atomic expressions may
|
|
56
|
+
* reference. This explicit runtime declaration complements the TypeScript
|
|
57
|
+
* numeric-field constraint.
|
|
58
|
+
*/
|
|
59
|
+
numericFields?: ReadonlyArray<TSmartdataNumericDocumentPath<TModel>>;
|
|
60
|
+
/**
|
|
61
|
+
* Persisted string identity fields with @unI()-equivalent selector and
|
|
62
|
+
* immutability semantics. Each field requires an explicit single-field,
|
|
63
|
+
* ascending unique index in `indexes`.
|
|
64
|
+
*/
|
|
65
|
+
identityFields?: ReadonlyArray<TStringFieldKey<TModel>>;
|
|
66
|
+
/**
|
|
67
|
+
* Persisted fields used by SmartData's search helpers.
|
|
68
|
+
*/
|
|
69
|
+
searchableFields?: ReadonlyArray<keyof TModel & string>;
|
|
70
|
+
/**
|
|
71
|
+
* Stable named MongoDB indexes. Object property order defines key order.
|
|
72
|
+
*/
|
|
73
|
+
indexes?: ReadonlyArray<ICollectionModelIndex>;
|
|
74
|
+
}
|
|
75
|
+
export interface INormalizedCollectionModelSchema {
|
|
76
|
+
readonly ordinaryPersistence?: IOrdinaryPersistencePolicy;
|
|
77
|
+
readonly collectionName: string;
|
|
78
|
+
readonly persistedFields: readonly string[];
|
|
79
|
+
readonly numericFields: readonly string[];
|
|
80
|
+
readonly identityFields: readonly string[];
|
|
81
|
+
readonly identityValueTypes: Readonly<Record<string, TSmartdataIdentityValueType>>;
|
|
82
|
+
readonly searchableFields: readonly string[];
|
|
83
|
+
readonly indexes: ReadonlyArray<{
|
|
84
|
+
readonly name: string;
|
|
85
|
+
readonly key: ReadonlyArray<readonly [string, TCollectionModelIndexDirection]>;
|
|
86
|
+
readonly options: Readonly<IIndexOptions>;
|
|
87
|
+
}>;
|
|
88
|
+
readonly fingerprint: string;
|
|
89
|
+
}
|
|
90
|
+
export type TCompoundIndexDirection = 1 | -1;
|
|
91
|
+
export interface ICompoundIndexDefinition {
|
|
92
|
+
/** Stable MongoDB index name. */
|
|
93
|
+
name: string;
|
|
94
|
+
/** Ordered fields and their ascending/descending directions. */
|
|
95
|
+
key: Record<string, TCompoundIndexDirection>;
|
|
96
|
+
/** MongoDB create-index options other than `name`. */
|
|
97
|
+
options?: Omit<plugins.mongodb.CreateIndexesOptions, 'name'>;
|
|
98
|
+
}
|
|
99
|
+
export interface ISmartdataIndexInfo {
|
|
100
|
+
name: string;
|
|
101
|
+
fields: Array<{
|
|
102
|
+
path: string;
|
|
103
|
+
direction: 1 | -1 | 'text';
|
|
104
|
+
}>;
|
|
105
|
+
unique: boolean;
|
|
106
|
+
sparse: boolean;
|
|
107
|
+
expireAfterSeconds?: number;
|
|
108
|
+
}
|
|
109
|
+
type TCollectionModelConstructor<TModel extends SmartDataDbDoc<any, any>> = {
|
|
110
|
+
new (...args: any[]): TModel;
|
|
111
|
+
name: string;
|
|
112
|
+
prototype: TModel;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Programmatically declares and binds an ordinary SmartData model.
|
|
116
|
+
*
|
|
117
|
+
* Repeating an equivalent declaration is safe. Divergent declarations for
|
|
118
|
+
* the same constructor, database and collection fail before database work.
|
|
119
|
+
*/
|
|
120
|
+
export declare function defineCollectionModel<TModel extends SmartDataDbDoc<any, any>>(modelArg: TCollectionModelConstructor<TModel>, dbArg: SmartdataDb | TDelayed<SmartdataDb>, configArg: ICollectionModelConfig<TModel>): TCollectionModelConstructor<TModel>;
|
|
121
|
+
/**
|
|
122
|
+
* Declares a stable named compound index owned by a SmartData model.
|
|
123
|
+
*/
|
|
124
|
+
export declare function compoundIndex(definitionArg: ICompoundIndexDefinition): (value: Function, context: ClassDecoratorContext) => any;
|
|
125
|
+
/** Declares an inherited named index without implicitly declaring persisted fields. */
|
|
126
|
+
export declare function namedIndex(definitionArg: INamedIndexDefinition): (value: Function, context: ClassDecoratorContext) => any;
|
|
127
|
+
/**
|
|
128
|
+
* This is a decorator that will tell the decorated class what dbTable to use
|
|
129
|
+
* @param dbArg
|
|
130
|
+
*/
|
|
131
|
+
export declare function Collection(dbArg: SmartdataDb | TDelayed<SmartdataDb>, optionsArg?: ICollectionBindingOptions): (value: Function, context: ClassDecoratorContext) => any;
|
|
132
|
+
export interface IManager {
|
|
133
|
+
db: SmartdataDb;
|
|
134
|
+
}
|
|
135
|
+
export declare const setDefaultManagerForDoc: <T>(managerArg: IManager, dbDocArg: T) => T;
|
|
136
|
+
/**
|
|
137
|
+
* This is a decorator that will tell the decorated class what dbTable to use
|
|
138
|
+
* @param dbArg
|
|
139
|
+
*/
|
|
140
|
+
export declare function managed<TManager extends IManager>(managerOrOptionsArg?: TManager | TDelayed<TManager> | ICollectionBindingOptions, optionsArg?: ICollectionBindingOptions): (value: Function, context: ClassDecoratorContext) => any;
|
|
141
|
+
/**
|
|
142
|
+
* @dpecrecated use @managed instead
|
|
143
|
+
*/
|
|
144
|
+
export declare const Manager: typeof managed;
|
|
145
|
+
export declare class SmartdataCollection<T> {
|
|
146
|
+
/**
|
|
147
|
+
* the collection that is used
|
|
148
|
+
*/
|
|
149
|
+
mongoDbCollection: plugins.mongodb.Collection;
|
|
150
|
+
objectValidation: IDocValidationFunc<T> | null;
|
|
151
|
+
collectionName: string;
|
|
152
|
+
smartdataDb: SmartdataDb;
|
|
153
|
+
uniqueIndexes: string[];
|
|
154
|
+
regularIndexes: Array<{
|
|
155
|
+
field: string;
|
|
156
|
+
options: IIndexOptions;
|
|
157
|
+
}>;
|
|
158
|
+
compoundIndexes: ICompoundIndexDefinition[];
|
|
159
|
+
private modelSchema?;
|
|
160
|
+
private initializationPromise?;
|
|
161
|
+
private initializationGeneration;
|
|
162
|
+
private initialized;
|
|
163
|
+
constructor(classNameArg: string, smartDataDbArg: SmartdataDb);
|
|
164
|
+
private runWithOrdinarySession;
|
|
165
|
+
/**
|
|
166
|
+
* Returns the deep-frozen normalized model schema bound to this collection,
|
|
167
|
+
* or undefined when no model schema has been bound yet. The schema exposes
|
|
168
|
+
* declared fields and named index definitions only, never raw driver access.
|
|
169
|
+
*/
|
|
170
|
+
getBoundModelSchema(): INormalizedCollectionModelSchema | undefined;
|
|
171
|
+
bindModelSchema(schemaArg: INormalizedCollectionModelSchema): void;
|
|
172
|
+
resetForDatabaseReconnect(): void;
|
|
173
|
+
/**
|
|
174
|
+
* makes sure a collection exists within MongoDb that maps to the SmartdataCollection
|
|
175
|
+
*/
|
|
176
|
+
init(): Promise<void>;
|
|
177
|
+
ensureInitialized(): Promise<void>;
|
|
178
|
+
/** Explicit bounded preparation of the bound model's exact declared topology. */
|
|
179
|
+
prepareCollection(opts: ISmartdataCollectionPreparationOptions): Promise<void>;
|
|
180
|
+
isInitializedForCurrentDatabase(): boolean;
|
|
181
|
+
private initializeOnce;
|
|
182
|
+
private publishModelIndexes;
|
|
183
|
+
/**
|
|
184
|
+
* mark unique index
|
|
185
|
+
*/
|
|
186
|
+
markUniqueIndexes(keyArrayArg?: string[]): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* creates regular indexes for the collection
|
|
189
|
+
*/
|
|
190
|
+
createRegularIndexes(indexesArg?: Array<{
|
|
191
|
+
field: string;
|
|
192
|
+
options: IIndexOptions;
|
|
193
|
+
}>): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Logs duplicate values for a field to help diagnose unique index creation failures.
|
|
196
|
+
*/
|
|
197
|
+
private logDuplicatesForField;
|
|
198
|
+
/**
|
|
199
|
+
* adds a validation function that all newly inserted and updated objects have to pass
|
|
200
|
+
*/
|
|
201
|
+
addDocValidation(funcArg: IDocValidationFunc<T>): void;
|
|
202
|
+
/**
|
|
203
|
+
* finds an object in the DbCollection
|
|
204
|
+
*/
|
|
205
|
+
findOne(filterObject: any, opts?: {
|
|
206
|
+
projection?: plugins.mongodb.Document;
|
|
207
|
+
maxTimeMS?: number;
|
|
208
|
+
session?: TSmartdataOrdinarySession;
|
|
209
|
+
}): Promise<any>;
|
|
210
|
+
getCursor(filterObjectArg: any, dbDocArg: typeof SmartDataDbDoc, opts?: {
|
|
211
|
+
session?: plugins.mongodb.ClientSession;
|
|
212
|
+
}): Promise<SmartdataDbCursor<any>>;
|
|
213
|
+
/**
|
|
214
|
+
* finds an object in the DbCollection
|
|
215
|
+
*/
|
|
216
|
+
findAll(filterObject: any, opts?: {
|
|
217
|
+
session?: TSmartdataOrdinarySession;
|
|
218
|
+
}): Promise<any[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Watches the collection, returning a SmartdataDbWatcher with RxJS and EventEmitter support.
|
|
221
|
+
* @param filterObject match filter for change stream
|
|
222
|
+
* @param opts optional MongoDB ChangeStreamOptions & { bufferTimeMs } to buffer events
|
|
223
|
+
* @param smartdataDbDocArg document class for instance creation
|
|
224
|
+
*/
|
|
225
|
+
watch(filterObject: any, opts?: (plugins.mongodb.ChangeStreamOptions & {
|
|
226
|
+
bufferTimeMs?: number;
|
|
227
|
+
}), smartdataDbDocArg?: typeof SmartDataDbDoc): Promise<SmartdataDbWatcher>;
|
|
228
|
+
/**
|
|
229
|
+
* create an object in the database
|
|
230
|
+
*/
|
|
231
|
+
private prepareOrdinaryInsert;
|
|
232
|
+
insert(dbDocArg: T & SmartDataDbDoc<T, unknown>, opts?: {
|
|
233
|
+
session?: TSmartdataOrdinarySession;
|
|
234
|
+
}): Promise<any>;
|
|
235
|
+
/**
|
|
236
|
+
* Executes a bounded grouped-totals aggregation over already-validated
|
|
237
|
+
* stages and never exposes the aggregation cursor. Prefer the validated
|
|
238
|
+
* static `SmartDataDbDoc.getGroupedTotals()`, which owns input validation
|
|
239
|
+
* before this raw persistence boundary.
|
|
240
|
+
*/
|
|
241
|
+
aggregateGroupedTotals(matchArg: plugins.mongodb.Filter<plugins.mongodb.Document> | undefined, groupArg: plugins.mongodb.Document, limitArg: number, opts?: {
|
|
242
|
+
session?: TSmartdataOrdinarySession;
|
|
243
|
+
maxTimeMS?: number;
|
|
244
|
+
timeoutMS?: number;
|
|
245
|
+
signal?: AbortSignal;
|
|
246
|
+
}): Promise<plugins.mongodb.Document[]>;
|
|
247
|
+
insertMany(dbDocsArg: Array<T & SmartDataDbDoc<T, unknown>>, opts?: {
|
|
248
|
+
session?: TSmartdataOrdinarySession;
|
|
249
|
+
ordered?: boolean;
|
|
250
|
+
}): Promise<plugins.mongodb.InsertManyResult>;
|
|
251
|
+
/** Model.insertManyIfAbsent owns identity and new-instance validation. */
|
|
252
|
+
insertManyIfAbsent(documentsArg: Array<T & SmartDataDbDoc<T, unknown>>, identityFieldArg: string, optsArg: {
|
|
253
|
+
session?: TSmartdataOrdinarySession;
|
|
254
|
+
timeoutMS?: number;
|
|
255
|
+
}): Promise<{
|
|
256
|
+
insertedCount: number;
|
|
257
|
+
matchedCount: number;
|
|
258
|
+
}>;
|
|
259
|
+
/**
|
|
260
|
+
* inserts object into the DbCollection
|
|
261
|
+
*/
|
|
262
|
+
update(dbDocArg: T & SmartDataDbDoc<T, unknown>, opts?: {
|
|
263
|
+
session?: TSmartdataOrdinarySession;
|
|
264
|
+
}): Promise<any>;
|
|
265
|
+
delete(dbDocArg: T & SmartDataDbDoc<T, unknown>, opts?: {
|
|
266
|
+
session?: TSmartdataOrdinarySession;
|
|
267
|
+
}): Promise<any>;
|
|
268
|
+
/**
|
|
269
|
+
* Rejects instance-level document targeting when the model declares no
|
|
270
|
+
* identity fields. An empty identity filter would otherwise address an
|
|
271
|
+
* arbitrary document in the collection.
|
|
272
|
+
*/
|
|
273
|
+
private assertConstrainingIdentifiableObject;
|
|
274
|
+
getCount(filterObject: any, opts?: {
|
|
275
|
+
limit?: number;
|
|
276
|
+
hint?: string;
|
|
277
|
+
maxTimeMS?: number;
|
|
278
|
+
timeoutMS?: number;
|
|
279
|
+
signal?: AbortSignal;
|
|
280
|
+
session?: TSmartdataOrdinarySession;
|
|
281
|
+
}): Promise<number>;
|
|
282
|
+
getIndexInfo(): Promise<ISmartdataIndexInfo[]>;
|
|
283
|
+
/**
|
|
284
|
+
* Runs an integrity check on the collection.
|
|
285
|
+
* Compares estimated vs actual document count and checks for duplicates on unique index fields.
|
|
286
|
+
*/
|
|
287
|
+
checkCollectionIntegrity(): Promise<{
|
|
288
|
+
ok: boolean;
|
|
289
|
+
estimatedCount: number;
|
|
290
|
+
actualCount: number;
|
|
291
|
+
duplicateFields: Array<{
|
|
292
|
+
field: string;
|
|
293
|
+
duplicateValues: number;
|
|
294
|
+
}>;
|
|
295
|
+
}>;
|
|
296
|
+
/**
|
|
297
|
+
* checks a Doc for constraints
|
|
298
|
+
* if this.objectValidation is not set it passes.
|
|
299
|
+
*/
|
|
300
|
+
private checkDoc;
|
|
301
|
+
}
|
|
302
|
+
export {};
|