@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.
Files changed (255) hide show
  1. package/.smartconfig.json +37 -0
  2. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  3. package/dist_ts/00_commitinfo_data.js +9 -0
  4. package/dist_ts/classes.losslessorgclient.d.ts +32 -0
  5. package/dist_ts/classes.losslessorgclient.js +103 -0
  6. package/dist_ts/core/classes.error.d.ts +16 -0
  7. package/dist_ts/core/classes.error.js +29 -0
  8. package/dist_ts/core/classes.operation.d.ts +17 -0
  9. package/dist_ts/core/classes.operation.js +70 -0
  10. package/dist_ts/core/interfaces.d.ts +18 -0
  11. package/dist_ts/core/interfaces.js +2 -0
  12. package/dist_ts/index.d.ts +4 -0
  13. package/dist_ts/index.js +3 -0
  14. package/dist_ts/nosqldb/classes.atomicdelete.d.ts +26 -0
  15. package/dist_ts/nosqldb/classes.atomicdelete.js +44 -0
  16. package/dist_ts/nosqldb/classes.atomicfindoneandupdate.d.ts +27 -0
  17. package/dist_ts/nosqldb/classes.atomicfindoneandupdate.js +86 -0
  18. package/dist_ts/nosqldb/classes.atomicupdate.d.ts +26 -0
  19. package/dist_ts/nosqldb/classes.atomicupdate.js +55 -0
  20. package/dist_ts/nosqldb/classes.bootstraprecord.d.ts +14 -0
  21. package/dist_ts/nosqldb/classes.bootstraprecord.js +80 -0
  22. package/dist_ts/nosqldb/classes.bsonassertion.d.ts +2 -0
  23. package/dist_ts/nosqldb/classes.bsonassertion.js +29 -0
  24. package/dist_ts/nosqldb/classes.bsonobjectid.d.ts +2 -0
  25. package/dist_ts/nosqldb/classes.bsonobjectid.js +50 -0
  26. package/dist_ts/nosqldb/classes.bsonsnapshot.d.ts +3 -0
  27. package/dist_ts/nosqldb/classes.bsonsnapshot.js +126 -0
  28. package/dist_ts/nosqldb/classes.cached-document.d.ts +27 -0
  29. package/dist_ts/nosqldb/classes.cached-document.js +112 -0
  30. package/dist_ts/nosqldb/classes.collection.d.ts +302 -0
  31. package/dist_ts/nosqldb/classes.collection.js +1568 -0
  32. package/dist_ts/nosqldb/classes.collectionfactory.d.ts +30 -0
  33. package/dist_ts/nosqldb/classes.collectionfactory.js +65 -0
  34. package/dist_ts/nosqldb/classes.collectionlifecycle.d.ts +4 -0
  35. package/dist_ts/nosqldb/classes.collectionlifecycle.js +15 -0
  36. package/dist_ts/nosqldb/classes.collectionpreparation.d.ts +34 -0
  37. package/dist_ts/nosqldb/classes.collectionpreparation.js +134 -0
  38. package/dist_ts/nosqldb/classes.collectiontopology.d.ts +47 -0
  39. package/dist_ts/nosqldb/classes.collectiontopology.js +388 -0
  40. package/dist_ts/nosqldb/classes.connection.d.ts +18 -0
  41. package/dist_ts/nosqldb/classes.connection.js +23 -0
  42. package/dist_ts/nosqldb/classes.convenience.d.ts +1 -0
  43. package/dist_ts/nosqldb/classes.convenience.js +5 -0
  44. package/dist_ts/nosqldb/classes.cursor.d.ts +15 -0
  45. package/dist_ts/nosqldb/classes.cursor.js +82 -0
  46. package/dist_ts/nosqldb/classes.cursoroperation.d.ts +7 -0
  47. package/dist_ts/nosqldb/classes.cursoroperation.js +36 -0
  48. package/dist_ts/nosqldb/classes.db.d.ts +98 -0
  49. package/dist_ts/nosqldb/classes.db.js +434 -0
  50. package/dist_ts/nosqldb/classes.distributedcoordinator.d.ts +52 -0
  51. package/dist_ts/nosqldb/classes.distributedcoordinator.js +314 -0
  52. package/dist_ts/nosqldb/classes.doc.d.ts +722 -0
  53. package/dist_ts/nosqldb/classes.doc.js +2976 -0
  54. package/dist_ts/nosqldb/classes.easystore.d.ts +42 -0
  55. package/dist_ts/nosqldb/classes.easystore.js +199 -0
  56. package/dist_ts/nosqldb/classes.exactpersistence.d.ts +141 -0
  57. package/dist_ts/nosqldb/classes.exactpersistence.js +1110 -0
  58. package/dist_ts/nosqldb/classes.lucene.adapter.d.ts +173 -0
  59. package/dist_ts/nosqldb/classes.lucene.adapter.js +623 -0
  60. package/dist_ts/nosqldb/classes.mongoadministration.d.ts +73 -0
  61. package/dist_ts/nosqldb/classes.mongoadministration.js +497 -0
  62. package/dist_ts/nosqldb/classes.namespaceinspection.d.ts +42 -0
  63. package/dist_ts/nosqldb/classes.namespaceinspection.js +138 -0
  64. package/dist_ts/nosqldb/classes.operationbudget.d.ts +22 -0
  65. package/dist_ts/nosqldb/classes.operationbudget.js +65 -0
  66. package/dist_ts/nosqldb/classes.ordinarypersistence.d.ts +18 -0
  67. package/dist_ts/nosqldb/classes.ordinarypersistence.js +71 -0
  68. package/dist_ts/nosqldb/classes.persistence.d.ts +14 -0
  69. package/dist_ts/nosqldb/classes.persistence.js +34 -0
  70. package/dist_ts/nosqldb/classes.session.d.ts +28 -0
  71. package/dist_ts/nosqldb/classes.session.js +246 -0
  72. package/dist_ts/nosqldb/classes.storedinspection.d.ts +44 -0
  73. package/dist_ts/nosqldb/classes.storedinspection.js +100 -0
  74. package/dist_ts/nosqldb/classes.testdatabase.d.ts +56 -0
  75. package/dist_ts/nosqldb/classes.testdatabase.js +250 -0
  76. package/dist_ts/nosqldb/classes.watcher.d.ts +37 -0
  77. package/dist_ts/nosqldb/classes.watcher.js +98 -0
  78. package/dist_ts/nosqldb/index.d.ts +27 -0
  79. package/dist_ts/nosqldb/index.js +18 -0
  80. package/dist_ts/nosqldb/logging.d.ts +2 -0
  81. package/dist_ts/nosqldb/logging.js +3 -0
  82. package/dist_ts/nosqldb/plugins.d.ts +17 -0
  83. package/dist_ts/nosqldb/plugins.js +20 -0
  84. package/dist_ts/nosqldb/shim.d.ts +1 -0
  85. package/dist_ts/nosqldb/shim.js +8 -0
  86. package/dist_ts/nosqldb/testsupport.d.ts +3 -0
  87. package/dist_ts/nosqldb/testsupport.js +3 -0
  88. package/dist_ts/objectstorage/classes.bucket.d.ts +227 -0
  89. package/dist_ts/objectstorage/classes.bucket.js +939 -0
  90. package/dist_ts/objectstorage/classes.connection.d.ts +21 -0
  91. package/dist_ts/objectstorage/classes.connection.js +27 -0
  92. package/dist_ts/objectstorage/classes.directory.d.ts +124 -0
  93. package/dist_ts/objectstorage/classes.directory.js +335 -0
  94. package/dist_ts/objectstorage/classes.exactpathpurgeerror.d.ts +5 -0
  95. package/dist_ts/objectstorage/classes.exactpathpurgeerror.js +18 -0
  96. package/dist_ts/objectstorage/classes.exactuploaderror.d.ts +5 -0
  97. package/dist_ts/objectstorage/classes.exactuploaderror.js +19 -0
  98. package/dist_ts/objectstorage/classes.file.d.ts +91 -0
  99. package/dist_ts/objectstorage/classes.file.js +255 -0
  100. package/dist_ts/objectstorage/classes.listcursor.d.ts +41 -0
  101. package/dist_ts/objectstorage/classes.listcursor.js +67 -0
  102. package/dist_ts/objectstorage/classes.metadata.d.ts +57 -0
  103. package/dist_ts/objectstorage/classes.metadata.js +113 -0
  104. package/dist_ts/objectstorage/classes.smartbucket.d.ts +57 -0
  105. package/dist_ts/objectstorage/classes.smartbucket.js +357 -0
  106. package/dist_ts/objectstorage/classes.trash.d.ts +11 -0
  107. package/dist_ts/objectstorage/classes.trash.js +22 -0
  108. package/dist_ts/objectstorage/classes.watcher.d.ts +79 -0
  109. package/dist_ts/objectstorage/classes.watcher.js +249 -0
  110. package/dist_ts/objectstorage/helpers.d.ts +25 -0
  111. package/dist_ts/objectstorage/helpers.js +215 -0
  112. package/dist_ts/objectstorage/index.d.ts +13 -0
  113. package/dist_ts/objectstorage/index.js +13 -0
  114. package/dist_ts/objectstorage/interfaces.d.ts +276 -0
  115. package/dist_ts/objectstorage/interfaces.js +2 -0
  116. package/dist_ts/objectstorage/internal.exactpathpurge.operations.d.ts +11 -0
  117. package/dist_ts/objectstorage/internal.exactpathpurge.operations.js +1069 -0
  118. package/dist_ts/objectstorage/internal.exactupload.capability.d.ts +40 -0
  119. package/dist_ts/objectstorage/internal.exactupload.capability.js +382 -0
  120. package/dist_ts/objectstorage/internal.exactupload.operations.d.ts +11 -0
  121. package/dist_ts/objectstorage/internal.exactupload.operations.js +1104 -0
  122. package/dist_ts/objectstorage/internal.multipart.planner.d.ts +8 -0
  123. package/dist_ts/objectstorage/internal.multipart.planner.js +63 -0
  124. package/dist_ts/objectstorage/internal.multipart.stream.d.ts +17 -0
  125. package/dist_ts/objectstorage/internal.multipart.stream.js +440 -0
  126. package/dist_ts/objectstorage/internal.multipart.types.d.ts +82 -0
  127. package/dist_ts/objectstorage/internal.multipart.types.js +2 -0
  128. package/dist_ts/objectstorage/plugins.d.ts +17 -0
  129. package/dist_ts/objectstorage/plugins.js +23 -0
  130. package/dist_ts/plugins.d.ts +4 -0
  131. package/dist_ts/plugins.js +5 -0
  132. package/dist_ts/sqldb/classes.clickhouseconnection.d.ts +39 -0
  133. package/dist_ts/sqldb/classes.clickhouseconnection.js +225 -0
  134. package/dist_ts/sqldb/classes.sqlconnection.d.ts +50 -0
  135. package/dist_ts/sqldb/classes.sqlconnection.js +376 -0
  136. package/dist_ts/sqldb/classes.sqltable.d.ts +29 -0
  137. package/dist_ts/sqldb/classes.sqltable.js +70 -0
  138. package/dist_ts/sqldb/clickhouse/classes.metricwriter.d.ts +27 -0
  139. package/dist_ts/sqldb/clickhouse/classes.metricwriter.js +89 -0
  140. package/dist_ts/sqldb/clickhouse/index.d.ts +9 -0
  141. package/dist_ts/sqldb/clickhouse/index.js +13 -0
  142. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.clickhousetable.d.ts +88 -0
  143. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.clickhousetable.js +304 -0
  144. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.httpclient.d.ts +28 -0
  145. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.httpclient.js +46 -0
  146. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.querybuilder.d.ts +43 -0
  147. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.querybuilder.js +155 -0
  148. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.resultset.d.ts +13 -0
  149. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.resultset.js +36 -0
  150. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.smartclickhouse.d.ts +49 -0
  151. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.smartclickhouse.js +106 -0
  152. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.timedatatable.d.ts +51 -0
  153. package/dist_ts/sqldb/clickhouse/smartclickhouse.classes.timedatatable.js +96 -0
  154. package/dist_ts/sqldb/clickhouse/smartclickhouse.plugins.d.ts +5 -0
  155. package/dist_ts/sqldb/clickhouse/smartclickhouse.plugins.js +6 -0
  156. package/dist_ts/sqldb/clickhouse/smartclickhouse.types.d.ts +53 -0
  157. package/dist_ts/sqldb/clickhouse/smartclickhouse.types.js +41 -0
  158. package/dist_ts/sqldb/index.d.ts +6 -0
  159. package/dist_ts/sqldb/index.js +6 -0
  160. package/dist_ts/sqldb/interfaces.d.ts +53 -0
  161. package/dist_ts/sqldb/interfaces.js +19 -0
  162. package/dist_ts/sqldb/internal.sqlpool.d.ts +51 -0
  163. package/dist_ts/sqldb/internal.sqlpool.js +214 -0
  164. package/dist_ts/sqldb/plugins.clickhouse.d.ts +4 -0
  165. package/dist_ts/sqldb/plugins.clickhouse.js +5 -0
  166. package/dist_ts/sqldb/plugins.mariadb.d.ts +4 -0
  167. package/dist_ts/sqldb/plugins.mariadb.js +5 -0
  168. package/docs/source/smartbucket/license.md +19 -0
  169. package/docs/source/smartclickhouse/license.md +19 -0
  170. package/license.md +21 -0
  171. package/package.json +101 -0
  172. package/readme.md +157 -0
  173. package/ts/00_commitinfo_data.ts +8 -0
  174. package/ts/classes.losslessorgclient.ts +104 -0
  175. package/ts/core/classes.error.ts +31 -0
  176. package/ts/core/classes.operation.ts +60 -0
  177. package/ts/core/interfaces.ts +24 -0
  178. package/ts/index.ts +4 -0
  179. package/ts/nosqldb/classes.atomicdelete.ts +81 -0
  180. package/ts/nosqldb/classes.atomicfindoneandupdate.ts +152 -0
  181. package/ts/nosqldb/classes.atomicupdate.ts +99 -0
  182. package/ts/nosqldb/classes.bootstraprecord.ts +107 -0
  183. package/ts/nosqldb/classes.bsonassertion.ts +25 -0
  184. package/ts/nosqldb/classes.bsonobjectid.ts +45 -0
  185. package/ts/nosqldb/classes.bsonsnapshot.ts +105 -0
  186. package/ts/nosqldb/classes.cached-document.ts +67 -0
  187. package/ts/nosqldb/classes.collection.ts +2399 -0
  188. package/ts/nosqldb/classes.collectionfactory.ts +87 -0
  189. package/ts/nosqldb/classes.collectionlifecycle.ts +24 -0
  190. package/ts/nosqldb/classes.collectionpreparation.ts +164 -0
  191. package/ts/nosqldb/classes.collectiontopology.ts +645 -0
  192. package/ts/nosqldb/classes.connection.ts +31 -0
  193. package/ts/nosqldb/classes.convenience.ts +5 -0
  194. package/ts/nosqldb/classes.cursor.ts +88 -0
  195. package/ts/nosqldb/classes.cursoroperation.ts +38 -0
  196. package/ts/nosqldb/classes.db.ts +637 -0
  197. package/ts/nosqldb/classes.distributedcoordinator.ts +305 -0
  198. package/ts/nosqldb/classes.doc.ts +4928 -0
  199. package/ts/nosqldb/classes.easystore.ts +154 -0
  200. package/ts/nosqldb/classes.exactpersistence.ts +1974 -0
  201. package/ts/nosqldb/classes.lucene.adapter.ts +780 -0
  202. package/ts/nosqldb/classes.mongoadministration.ts +867 -0
  203. package/ts/nosqldb/classes.namespaceinspection.ts +199 -0
  204. package/ts/nosqldb/classes.operationbudget.ts +75 -0
  205. package/ts/nosqldb/classes.ordinarypersistence.ts +84 -0
  206. package/ts/nosqldb/classes.persistence.ts +62 -0
  207. package/ts/nosqldb/classes.session.ts +389 -0
  208. package/ts/nosqldb/classes.storedinspection.ts +151 -0
  209. package/ts/nosqldb/classes.testdatabase.ts +272 -0
  210. package/ts/nosqldb/classes.watcher.ts +96 -0
  211. package/ts/nosqldb/index.ts +51 -0
  212. package/ts/nosqldb/logging.ts +3 -0
  213. package/ts/nosqldb/plugins.ts +37 -0
  214. package/ts/nosqldb/shim.ts +6 -0
  215. package/ts/nosqldb/testsupport.ts +13 -0
  216. package/ts/objectstorage/classes.bucket.ts +1114 -0
  217. package/ts/objectstorage/classes.connection.ts +36 -0
  218. package/ts/objectstorage/classes.directory.ts +425 -0
  219. package/ts/objectstorage/classes.exactpathpurgeerror.ts +24 -0
  220. package/ts/objectstorage/classes.exactuploaderror.ts +25 -0
  221. package/ts/objectstorage/classes.file.ts +303 -0
  222. package/ts/objectstorage/classes.listcursor.ts +89 -0
  223. package/ts/objectstorage/classes.metadata.ts +134 -0
  224. package/ts/objectstorage/classes.smartbucket.ts +445 -0
  225. package/ts/objectstorage/classes.trash.ts +30 -0
  226. package/ts/objectstorage/classes.watcher.ts +289 -0
  227. package/ts/objectstorage/helpers.ts +254 -0
  228. package/ts/objectstorage/index.ts +13 -0
  229. package/ts/objectstorage/interfaces.ts +389 -0
  230. package/ts/objectstorage/internal.exactpathpurge.operations.ts +1936 -0
  231. package/ts/objectstorage/internal.exactupload.capability.ts +580 -0
  232. package/ts/objectstorage/internal.exactupload.operations.ts +1715 -0
  233. package/ts/objectstorage/internal.multipart.planner.ts +90 -0
  234. package/ts/objectstorage/internal.multipart.stream.ts +606 -0
  235. package/ts/objectstorage/internal.multipart.types.ts +106 -0
  236. package/ts/objectstorage/plugins.ts +35 -0
  237. package/ts/plugins.ts +4 -0
  238. package/ts/sqldb/classes.clickhouseconnection.ts +189 -0
  239. package/ts/sqldb/classes.sqlconnection.ts +350 -0
  240. package/ts/sqldb/classes.sqltable.ts +70 -0
  241. package/ts/sqldb/clickhouse/classes.metricwriter.ts +72 -0
  242. package/ts/sqldb/clickhouse/index.ts +16 -0
  243. package/ts/sqldb/clickhouse/smartclickhouse.classes.clickhousetable.ts +372 -0
  244. package/ts/sqldb/clickhouse/smartclickhouse.classes.httpclient.ts +52 -0
  245. package/ts/sqldb/clickhouse/smartclickhouse.classes.querybuilder.ts +120 -0
  246. package/ts/sqldb/clickhouse/smartclickhouse.classes.resultset.ts +44 -0
  247. package/ts/sqldb/clickhouse/smartclickhouse.classes.smartclickhouse.ts +123 -0
  248. package/ts/sqldb/clickhouse/smartclickhouse.classes.timedatatable.ts +114 -0
  249. package/ts/sqldb/clickhouse/smartclickhouse.plugins.ts +5 -0
  250. package/ts/sqldb/clickhouse/smartclickhouse.types.ts +134 -0
  251. package/ts/sqldb/index.ts +6 -0
  252. package/ts/sqldb/interfaces.ts +61 -0
  253. package/ts/sqldb/internal.sqlpool.ts +179 -0
  254. package/ts/sqldb/plugins.clickhouse.ts +4 -0
  255. package/ts/sqldb/plugins.mariadb.ts +4 -0
@@ -0,0 +1,722 @@
1
+ import * as plugins from './plugins.js';
2
+ import { SmartdataDb } from './classes.db.js';
3
+ import { SmartdataDbCursor } from './classes.cursor.js';
4
+ import { type ISmartdataBootstrapRecordOptions, type ISmartdataBootstrapRecordResult } from './classes.bootstraprecord.js';
5
+ import { type ISmartdataCollectionPreparationOptions } from './classes.collectionpreparation.js';
6
+ import { type ISmartdataStoredInspectionOptions, type ISmartdataStoredInspection, type ISmartdataStoredEvidenceInspection } from './classes.storedinspection.js';
7
+ import { type IManager, type ISmartdataIndexInfo, SmartdataCollection } from './classes.collection.js';
8
+ import { SmartdataDbWatcher } from './classes.watcher.js';
9
+ import { type TSmartdataOrdinarySession } from './classes.session.js';
10
+ import { type ISmartdataCollectionTopologyInspection, type ISmartdataExpectedCollectionTopology } from './classes.collectiontopology.js';
11
+ /**
12
+ * Search options for `.search()`:
13
+ * - filter: additional MongoDB query to AND-merge
14
+ * - validate: post-fetch validator, return true to keep a doc
15
+ */
16
+ export interface SearchOptions<T> {
17
+ /**
18
+ * Additional MongoDB filter to AND‐merge into the query
19
+ */
20
+ filter?: Record<string, any>;
21
+ /**
22
+ * Post‐fetch validator; return true to keep each doc
23
+ */
24
+ validate?: (doc: T) => Promise<boolean> | boolean;
25
+ /**
26
+ * Optional MongoDB session for transactional operations
27
+ */
28
+ session?: TSmartdataOrdinarySession;
29
+ }
30
+ export type TDocCreation = 'db' | 'new' | 'mixed';
31
+ export type TSmartdataPrimaryId<T> = T extends {
32
+ _id: infer TId;
33
+ } ? Extract<TId, string | plugins.mongodb.ObjectId> : plugins.mongodb.ObjectId;
34
+ export type TSmartdataIdentityValueType = 'string' | 'positiveSafeInteger';
35
+ export interface IUnIOptions {
36
+ /**
37
+ * Runtime value contract for this identity field. The default remains a
38
+ * non-empty string. Numeric identities require an explicit opt-in.
39
+ */
40
+ valueType?: TSmartdataIdentityValueType;
41
+ }
42
+ export declare function globalSvDb(): (value: undefined, context: ClassFieldDecoratorContext) => void;
43
+ /**
44
+ * Options for custom serialization/deserialization of a field.
45
+ */
46
+ export interface SvDbOptions {
47
+ /** Function to serialize the field value before saving to DB */
48
+ serialize?: (value: any) => any;
49
+ /** Function to deserialize the field value after reading from DB */
50
+ deserialize?: (value: any) => any;
51
+ /**
52
+ * Explicit relative nested paths that atomic filters and updates may target
53
+ * below this persisted field.
54
+ */
55
+ atomicPaths?: readonly string[];
56
+ /**
57
+ * Declares this persisted top-level field as numeric for strict atomic
58
+ * expression references.
59
+ */
60
+ numeric?: boolean;
61
+ }
62
+ /**
63
+ * saveable - saveable decorator to be used on class properties
64
+ */
65
+ export declare function svDb(options?: SvDbOptions): (value: undefined, context: ClassFieldDecoratorContext) => void;
66
+ /**
67
+ * searchable - marks a property as searchable with Lucene query syntax
68
+ */
69
+ export declare function searchable(): (value: undefined, context: ClassFieldDecoratorContext) => void;
70
+ /**
71
+ * unique index - decorator to mark a unique index
72
+ */
73
+ export declare function unI(optionsArg?: IUnIOptions): (value: undefined, context: ClassFieldDecoratorContext) => void;
74
+ /**
75
+ * Options for MongoDB indexes
76
+ */
77
+ export interface IIndexOptions {
78
+ background?: boolean;
79
+ unique?: boolean;
80
+ sparse?: boolean;
81
+ expireAfterSeconds?: number;
82
+ [key: string]: any;
83
+ }
84
+ /**
85
+ * index - decorator to mark a field for regular indexing
86
+ */
87
+ export declare function index(options?: IIndexOptions): (value: undefined, context: ClassFieldDecoratorContext) => void;
88
+ type ElementOf<T> = T extends ReadonlyArray<infer U> ? U : T;
89
+ type InValues<T> = ReadonlyArray<ElementOf<T>>;
90
+ export type MongoFilterCondition<T> = T | {
91
+ $eq?: T;
92
+ $ne?: T;
93
+ $gt?: T;
94
+ $gte?: T;
95
+ $lt?: T;
96
+ $lte?: T;
97
+ $in?: InValues<T>;
98
+ $nin?: InValues<T>;
99
+ $exists?: boolean;
100
+ $type?: string | number;
101
+ $regex?: string | RegExp;
102
+ $options?: string;
103
+ $all?: T extends ReadonlyArray<infer U> ? ReadonlyArray<U> : never;
104
+ $elemMatch?: T extends ReadonlyArray<infer U> ? MongoFilter<U> : never;
105
+ $size?: T extends ReadonlyArray<any> ? number : never;
106
+ $not?: MongoFilterCondition<T>;
107
+ };
108
+ export type MongoFilter<T> = {
109
+ [K in keyof T]?: T[K] extends object ? T[K] extends any[] ? MongoFilterCondition<T[K]> : MongoFilter<T[K]> | MongoFilterCondition<T[K]> : MongoFilterCondition<T[K]>;
110
+ } & {
111
+ $and?: MongoFilter<T>[];
112
+ $or?: MongoFilter<T>[];
113
+ $nor?: MongoFilter<T>[];
114
+ $not?: MongoFilter<T>;
115
+ [key: string]: any;
116
+ };
117
+ export type TSmartdataDocumentPath<T> = keyof T & string;
118
+ export type TSmartdataAtomicNestedDocumentPath<T> = `${TSmartdataDocumentPath<T>}.${string}`;
119
+ export type TSmartdataAtomicDocumentPath<T> = TSmartdataDocumentPath<T> | TSmartdataAtomicNestedDocumentPath<T>;
120
+ export type TSmartdataProjection<T> = Partial<Record<TSmartdataAtomicDocumentPath<T> | '_id', 0 | 1>>;
121
+ export type TSmartdataSort<T> = Partial<Record<TSmartdataAtomicDocumentPath<T> | '_id', 1 | -1>>;
122
+ export interface ISmartdataCursorOptions<T> {
123
+ projection?: TSmartdataProjection<T>;
124
+ /**
125
+ * Callers are responsible for including a unique final tiebreaker when
126
+ * deterministic pagination across equal values matters.
127
+ */
128
+ sort?: TSmartdataSort<T>;
129
+ batchSize?: number;
130
+ limit?: number;
131
+ /** Zero-based offset. Requires an explicit sort and bounded limit. */
132
+ skip?: number;
133
+ /** Model-declared index name, or MongoDB's built-in `_id_` index. */
134
+ hint?: string;
135
+ maxTimeMS?: number;
136
+ session?: plugins.mongodb.ClientSession;
137
+ /**
138
+ * @deprecated Prefer the structured cursor options. The modifier runs last
139
+ * for backward compatibility.
140
+ */
141
+ modifier?: (cursorArg: plugins.mongodb.FindCursor<plugins.mongodb.WithId<plugins.mongodb.BSON.Document>>) => plugins.mongodb.FindCursor<plugins.mongodb.WithId<plugins.mongodb.BSON.Document>>;
142
+ }
143
+ export interface ISmartdataCountOptions {
144
+ limit?: number;
145
+ /** Model-declared index name, or MongoDB's built-in `_id_` index. */
146
+ hint?: string;
147
+ maxTimeMS?: number;
148
+ /** Client-side operation deadline, including server selection and pool waits. */
149
+ timeoutMS?: number;
150
+ signal?: AbortSignal;
151
+ session?: TSmartdataOrdinarySession;
152
+ }
153
+ export interface ISmartdataOffsetPageOptions<T> {
154
+ skip: number;
155
+ limit: number;
156
+ /** Include a unique final tiebreaker to order equal preceding values. */
157
+ sort: TSmartdataSort<T>;
158
+ projection?: TSmartdataProjection<T>;
159
+ hint?: string;
160
+ maxTimeMS?: number;
161
+ /** Defaults to 5000ms; maximum 120000ms. Covers the cursor's entire lifetime. */
162
+ timeoutMS?: number;
163
+ signal?: AbortSignal;
164
+ session?: TSmartdataOrdinarySession;
165
+ }
166
+ export interface ISmartdataFindOneOptions<T> {
167
+ projection?: TSmartdataProjection<T>;
168
+ maxTimeMS?: number;
169
+ session?: TSmartdataOrdinarySession;
170
+ }
171
+ type TSmartdataAtomicSet<T> = Partial<Pick<T, TSmartdataDocumentPath<T>>> & Partial<Record<TSmartdataAtomicNestedDocumentPath<T>, unknown>>;
172
+ type TSmartdataAtomicIncrement<T> = Partial<Record<{
173
+ [TKey in TSmartdataDocumentPath<T>]: NonNullable<T[TKey]> extends number ? TKey : never;
174
+ }[TSmartdataDocumentPath<T>], number>> & Partial<Record<TSmartdataAtomicNestedDocumentPath<T>, number>>;
175
+ export type TSmartdataNumericDocumentPath<T> = {
176
+ [TKey in TSmartdataDocumentPath<T>]: NonNullable<T[TKey]> extends number ? TKey : never;
177
+ }[TSmartdataDocumentPath<T>];
178
+ export type TSmartdataAtomicNumericFieldReference<T> = `$${TSmartdataNumericDocumentPath<T>}`;
179
+ export type TSmartdataAtomicNumericExpressionOperand<T> = number | TSmartdataAtomicNumericFieldReference<T> | {
180
+ $add: readonly [
181
+ TSmartdataAtomicNumericExpressionOperand<T>,
182
+ TSmartdataAtomicNumericExpressionOperand<T>,
183
+ ...TSmartdataAtomicNumericExpressionOperand<T>[]
184
+ ];
185
+ };
186
+ export interface ISmartdataAtomicNumericExpression<T> {
187
+ $lte: readonly [
188
+ TSmartdataAtomicNumericExpressionOperand<T>,
189
+ TSmartdataAtomicNumericExpressionOperand<T>
190
+ ];
191
+ }
192
+ export interface ISmartdataGroupedTotalsOptions<T> {
193
+ /**
194
+ * One or two declared top-level fields whose distinct value combinations
195
+ * form the groups.
196
+ */
197
+ groupBy: ReadonlyArray<TSmartdataDocumentPath<T>>;
198
+ /**
199
+ * Declared numeric top-level fields to sum per group.
200
+ */
201
+ sums?: ReadonlyArray<TSmartdataNumericDocumentPath<T>>;
202
+ filter?: MongoFilter<T>;
203
+ /**
204
+ * Required bound on the number of returned groups (1..10000). The group
205
+ * stage is not sorted, so when more groups exist than the limit the
206
+ * returned subset is arbitrary. Use `getGroupedTotalsPage()` when the
207
+ * caller must detect overflow at the 10000-group boundary.
208
+ */
209
+ limit: number;
210
+ maxTimeMS?: number;
211
+ /** Client-side deadline for the complete aggregation cursor lifetime. */
212
+ timeoutMS?: number;
213
+ signal?: AbortSignal;
214
+ session?: TSmartdataOrdinarySession;
215
+ }
216
+ export interface ISmartdataGroupedTotalsRow<T> {
217
+ /**
218
+ * The group's key values. Documents missing a group field and documents
219
+ * holding an explicit null merge into one group reported as null.
220
+ */
221
+ group: {
222
+ [TKey in TSmartdataDocumentPath<T>]?: T[TKey] | null;
223
+ };
224
+ count: number;
225
+ sums: Partial<Record<TSmartdataNumericDocumentPath<T>, number>>;
226
+ }
227
+ export interface ISmartdataGroupedTotalsPage<T> {
228
+ rows: Array<ISmartdataGroupedTotalsRow<T>>;
229
+ hasMore: boolean;
230
+ }
231
+ export type TSmartdataAtomicArrayPath<T> = {
232
+ [TKey in TSmartdataDocumentPath<T>]: NonNullable<T[TKey]> extends ReadonlyArray<unknown> ? TKey : never;
233
+ }[TSmartdataDocumentPath<T>];
234
+ type TSmartdataAtomicArrayElement<TValue> = NonNullable<TValue> extends ReadonlyArray<infer TElement> ? TElement : never;
235
+ type TSmartdataAtomicArrayOperation<T> = Partial<{
236
+ [TKey in TSmartdataAtomicArrayPath<T>]: TSmartdataAtomicArrayElement<T[TKey]>;
237
+ }>;
238
+ type TSmartdataAtomicPullScalar<TValue> = Extract<TValue, string | number | boolean | null | Date | plugins.mongodb.ObjectId | plugins.mongodb.Binary | plugins.mongodb.Decimal128 | plugins.mongodb.Long | plugins.mongodb.Int32 | plugins.mongodb.Double | plugins.mongodb.Timestamp>;
239
+ type TSmartdataAtomicArrayPullOperation<T> = Partial<{
240
+ [TKey in TSmartdataAtomicArrayPath<T>]: TSmartdataAtomicPullScalar<TSmartdataAtomicArrayElement<T[TKey]>>;
241
+ }>;
242
+ export interface ISmartdataAtomicUpdate<T> {
243
+ $set?: TSmartdataAtomicSet<T>;
244
+ $unset?: Partial<Record<TSmartdataAtomicDocumentPath<T>, '' | true | 1>>;
245
+ $inc?: TSmartdataAtomicIncrement<T>;
246
+ $setOnInsert?: TSmartdataAtomicSet<T>;
247
+ /**
248
+ * Appends one element to a declared top-level array field. Modifier
249
+ * documents ($each, $position, $slice, $sort) are rejected.
250
+ */
251
+ $push?: TSmartdataAtomicArrayOperation<T>;
252
+ /**
253
+ * Adds one element to a declared top-level array field unless an equal
254
+ * element is already present. Modifier documents are rejected.
255
+ */
256
+ $addToSet?: TSmartdataAtomicArrayOperation<T>;
257
+ /**
258
+ * Removes every element equal to a scalar operand from a declared
259
+ * top-level array field. Operator documents, plain objects, arrays, and
260
+ * regular expressions are rejected.
261
+ */
262
+ $pull?: TSmartdataAtomicArrayPullOperation<T>;
263
+ }
264
+ type TSmartdataAtomicDirectEquality<TValue> = TValue extends ReadonlyArray<infer TEntry> ? ReadonlyArray<TSmartdataAtomicDirectEquality<TEntry>> : TValue extends object ? TValue extends Date | ArrayBufferView | plugins.mongodb.ObjectId | plugins.mongodb.Binary | plugins.mongodb.Decimal128 | plugins.mongodb.Long | plugins.mongodb.Int32 | plugins.mongodb.Double | plugins.mongodb.Timestamp | plugins.mongodb.MinKey | plugins.mongodb.MaxKey ? TValue : never : Exclude<TValue, undefined>;
265
+ type TSmartdataAtomicInValue<TValue> = TValue extends ReadonlyArray<infer TEntry> ? TSmartdataAtomicDirectEquality<TEntry> : TSmartdataAtomicDirectEquality<TValue>;
266
+ export type TSmartdataAtomicFilterCondition<TValue> = TSmartdataAtomicDirectEquality<TValue> | {
267
+ $eq?: TValue;
268
+ $ne?: TSmartdataAtomicDirectEquality<TValue>;
269
+ $gt?: TSmartdataAtomicDirectEquality<TValue>;
270
+ $gte?: TSmartdataAtomicDirectEquality<TValue>;
271
+ $lt?: TSmartdataAtomicDirectEquality<TValue>;
272
+ $lte?: TSmartdataAtomicDirectEquality<TValue>;
273
+ $in?: ReadonlyArray<TSmartdataAtomicInValue<TValue>>;
274
+ $nin?: ReadonlyArray<TSmartdataAtomicInValue<TValue>>;
275
+ $exists?: boolean;
276
+ $type?: plugins.mongodb.BSONType | plugins.mongodb.BSONTypeAlias;
277
+ $regex?: string | RegExp;
278
+ $options?: string;
279
+ $not?: TSmartdataAtomicFilterCondition<TValue>;
280
+ };
281
+ type TSmartdataAtomicTopLevelFilter<T> = {
282
+ [TKey in TSmartdataDocumentPath<T>]?: TSmartdataAtomicFilterCondition<T[TKey]>;
283
+ };
284
+ type TSmartdataAtomicNestedFilter<T> = Partial<Record<TSmartdataAtomicNestedDocumentPath<T>, TSmartdataAtomicFilterCondition<unknown>>>;
285
+ type TSmartdataAtomicFilterBranch<T> = TSmartdataAtomicTopLevelFilter<T> & TSmartdataAtomicNestedFilter<T> & {
286
+ $and?: Array<TSmartdataAtomicFilterBranch<T>>;
287
+ $or?: Array<TSmartdataAtomicFilterBranch<T>>;
288
+ $nor?: Array<TSmartdataAtomicFilterBranch<T>>;
289
+ };
290
+ export type TSmartdataAtomicFilter<T> = TSmartdataAtomicFilterBranch<T> & {
291
+ /**
292
+ * A root-only, fail-closed numeric expression. This predicate never
293
+ * counts as the equality anchor required by atomic writes.
294
+ */
295
+ $expr?: ISmartdataAtomicNumericExpression<T>;
296
+ };
297
+ export interface ISmartdataAtomicUpdateOptions {
298
+ upsert?: boolean;
299
+ session?: TSmartdataOrdinarySession;
300
+ }
301
+ export interface ISmartdataAtomicUpdateResult {
302
+ acknowledged: boolean;
303
+ matchedCount: number;
304
+ modifiedCount: number;
305
+ upsertedId: plugins.mongodb.ObjectId | null;
306
+ }
307
+ export type TSmartdataAtomicReturnDocument = 'before' | 'after';
308
+ export interface ISmartdataAtomicFindOneAndUpdateOptions<TReturnDocument extends TSmartdataAtomicReturnDocument, TModel = any> {
309
+ returnDocument: TReturnDocument;
310
+ upsert?: boolean;
311
+ /**
312
+ * Optional sort applied before MongoDB selects the single document to
313
+ * update. Accepts the same paths as cursor sorts: declared top-level fields,
314
+ * nested paths declared through `@svDb({ atomicPaths })` or a model index,
315
+ * and `_id`. Callers wanting deterministic claim ordering should include a
316
+ * unique tiebreaker field.
317
+ */
318
+ sort?: TSmartdataSort<TModel>;
319
+ session?: TSmartdataOrdinarySession;
320
+ }
321
+ export type TSmartdataAtomicFindOneAndUpdateResult<T, TReturnDocument extends TSmartdataAtomicReturnDocument> = {
322
+ status: 'matched';
323
+ document: T;
324
+ } | {
325
+ status: 'upserted';
326
+ document: TReturnDocument extends 'after' ? T : null;
327
+ } | {
328
+ status: 'not_matched';
329
+ document: null;
330
+ };
331
+ export interface ISmartdataAtomicDeleteOptions {
332
+ session?: TSmartdataOrdinarySession;
333
+ /** Client-side operation deadline, including server selection and pool waits. */
334
+ timeoutMS?: number;
335
+ }
336
+ export interface ISmartdataInsertManyIfAbsentOptions<T> {
337
+ /** A declared, non-serialized @unI identity field. */
338
+ identityField: TSmartdataDocumentPath<T>;
339
+ /** Client-side bulk operation deadline, including server selection and pool waits. */
340
+ timeoutMS?: number;
341
+ session?: TSmartdataOrdinarySession;
342
+ }
343
+ export interface ISmartdataInsertManyIfAbsentResult {
344
+ insertedCount: number;
345
+ matchedCount: number;
346
+ }
347
+ export interface ISmartdataAtomicDeleteResult {
348
+ acknowledged: boolean;
349
+ deletedCount: number;
350
+ }
351
+ export interface ISmartdataAtomicUpdateManyOptions {
352
+ session?: TSmartdataOrdinarySession;
353
+ }
354
+ export interface ISmartdataAtomicUpdateManyResult {
355
+ acknowledged: boolean;
356
+ matchedCount: number;
357
+ modifiedCount: number;
358
+ }
359
+ export declare const convertFilterForMongoDb: (filterArg: {
360
+ [key: string]: any;
361
+ }) => {
362
+ [key: string]: any;
363
+ };
364
+ export declare class SmartDataDbDoc<T extends TImplements, TImplements, TManager extends IManager = any> {
365
+ /**
366
+ * the collection object an Doc belongs to
367
+ */
368
+ static collection: SmartdataCollection<any>;
369
+ static get exact(): unknown;
370
+ collection: SmartdataCollection<any>;
371
+ static defaultManager: any;
372
+ static manager: any;
373
+ manager: TManager;
374
+ /**
375
+ * Helper to get collection with fallback to static for Deno compatibility
376
+ */
377
+ private getCollectionSafe;
378
+ /** Insert a strict primary-only bootstrap record without separate collection/index DDL. */
379
+ static insertBootstrapRecord(dbArg: SmartdataDb, recordArg: unknown, optionsArg?: ISmartdataBootstrapRecordOptions): Promise<ISmartdataBootstrapRecordResult>;
380
+ /** Inspect bounded stored BSON without initializing or hydrating the model. */
381
+ static inspectStoredDocuments(dbArg: SmartdataDb, optionsArg?: ISmartdataStoredInspectionOptions): Promise<ISmartdataStoredInspection>;
382
+ /** Diagnose stored BSON with explicit ordinary validation evidence, without hydration. */
383
+ static inspectStoredDocumentEvidence(dbArg: SmartdataDb, optionsArg?: ISmartdataStoredInspectionOptions): Promise<ISmartdataStoredEvidenceInspection>;
384
+ static createInstanceFromMongoDbNativeDoc<T>(this: plugins.tsclass.typeFest.Class<T>, mongoDbNativeDocArg: any): T;
385
+ private static getDeclaredPersistedRoots;
386
+ private static getDeclaredUniqueRoots;
387
+ private static getDeclaredIdentityValueTypes;
388
+ private static getDeclaredNumericRoots;
389
+ /**
390
+ * Returns every equality key set that globally constrains a single document
391
+ * of this model: each declared identity field on its own, plus the full key
392
+ * set of every declared unqualified unique index. Unique indexes that carry
393
+ * any option beyond `unique` (sparse, partial, or otherwise uninterpretable)
394
+ * or a non-numeric key direction do not qualify — such indexes do not
395
+ * guarantee at most one matching document for an equality filter.
396
+ */
397
+ private static getGloballyConstrainingKeySets;
398
+ private static getDeclaredAtomicPaths;
399
+ private static getSerializedPersistedRoots;
400
+ private static getDeclaredQueryPaths;
401
+ private static assertHydratedProjection;
402
+ /**
403
+ * Initializes the model collection and all model-owned indexes. Failed
404
+ * initialization is retryable after the underlying conflict is repaired.
405
+ */
406
+ static init(): Promise<void>;
407
+ static ensureInitialized(): Promise<void>;
408
+ /** Verify or install the model's exact topology within one explicit deadline. */
409
+ static prepareCollection(opts: ISmartdataCollectionPreparationOptions): Promise<void>;
410
+ /**
411
+ * Returns a sanitized view of the indexes installed for this model.
412
+ */
413
+ static getIndexInfo(): Promise<ISmartdataIndexInfo[]>;
414
+ /**
415
+ * Returns the model's immutable collection and index contract without
416
+ * resolving a manager, database, or SmartdataCollection.
417
+ */
418
+ static getExpectedCollectionTopology(): ISmartdataExpectedCollectionTopology;
419
+ /**
420
+ * Inspects an explicitly supplied connected database without initializing or
421
+ * mutating the model collection.
422
+ */
423
+ static inspectCollectionTopology(dbArg: SmartdataDb): Promise<ISmartdataCollectionTopologyInspection>;
424
+ /**
425
+ * Inserts a newly constructed ordinary model through SmartData.
426
+ */
427
+ static insert<T extends SmartDataDbDoc<any, any>>(this: plugins.tsclass.typeFest.Class<T>, documentArg: T, opts?: {
428
+ session?: TSmartdataOrdinarySession;
429
+ }): Promise<plugins.mongodb.InsertOneResult<{
430
+ _id: TSmartdataPrimaryId<T>;
431
+ }>>;
432
+ /**
433
+ * Inserts a batch of newly constructed ordinary models through SmartData.
434
+ * Each document inserts atomically; the batch as a whole is not isolated
435
+ * unless the caller supplies a transaction session. With ordered semantics
436
+ * (the default) MongoDB stops at the first failure; documents MongoDB
437
+ * reports as inserted are marked database-backed even when the batch fails
438
+ * part-way, so callers can compensate precisely.
439
+ */
440
+ static insertMany<T extends SmartDataDbDoc<any, any>>(this: plugins.tsclass.typeFest.Class<T>, documentsArg: T[], opts?: {
441
+ session?: TSmartdataOrdinarySession;
442
+ ordered?: boolean;
443
+ }): Promise<plugins.mongodb.InsertManyResult<{
444
+ _id: TSmartdataPrimaryId<T>;
445
+ }>>;
446
+ /**
447
+ * Inserts absent identities without changing existing documents, including
448
+ * their timestamps. The unordered batch is bounded to 1000 documents and
449
+ * 16 MiB of serialized BSON. New-model timestamps are preserved. Inputs stay
450
+ * new so the same batch can be retried after an ambiguous result; read a
451
+ * stored instance before updating it because an existing body may differ.
452
+ */
453
+ static insertManyIfAbsent<T extends SmartDataDbDoc<any, any>>(this: plugins.tsclass.typeFest.Class<T>, documentsArg: T[], opts: ISmartdataInsertManyIfAbsentOptions<T>): Promise<ISmartdataInsertManyIfAbsentResult>;
454
+ /**
455
+ * Atomically updates one ordinary model document using a strict selector
456
+ * and a bounded set of MongoDB update operators.
457
+ */
458
+ static atomicUpdate<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: TSmartdataAtomicFilter<T>, updateArg: ISmartdataAtomicUpdate<T>, opts?: ISmartdataAtomicUpdateOptions): Promise<ISmartdataAtomicUpdateResult>;
459
+ /**
460
+ * Atomically updates one ordinary model document and returns a hydrated
461
+ * before or after image with a sanitized persistence outcome.
462
+ */
463
+ static atomicFindOneAndUpdate<T, TReturnDocument extends TSmartdataAtomicReturnDocument>(this: plugins.tsclass.typeFest.Class<T>, filterArg: TSmartdataAtomicFilter<T>, updateArg: ISmartdataAtomicUpdate<T>, optionsArg: ISmartdataAtomicFindOneAndUpdateOptions<TReturnDocument, T>): Promise<TSmartdataAtomicFindOneAndUpdateResult<T, TReturnDocument>>;
464
+ /**
465
+ * Atomically deletes one ordinary model document using a strict selector.
466
+ *
467
+ * This static operation intentionally does not hydrate an instance or run
468
+ * instance deletion hooks. Callers that require those hooks must use the
469
+ * instance `delete()` method instead.
470
+ */
471
+ static atomicDelete<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: TSmartdataAtomicFilter<T>, opts?: ISmartdataAtomicDeleteOptions): Promise<ISmartdataAtomicDeleteResult>;
472
+ /**
473
+ * Atomically deletes every ordinary model document matching a strict
474
+ * selector. Each matched document is deleted atomically; the batch as a
475
+ * whole is not isolated. Unlike `atomicDelete()`, the filter does not need
476
+ * to pin a unique index — plural intent is explicit in this API — but it
477
+ * still requires declared fields and at least one top-level equality
478
+ * anchor.
479
+ */
480
+ static atomicDeleteMany<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: TSmartdataAtomicFilter<T>, opts?: ISmartdataAtomicDeleteOptions): Promise<ISmartdataAtomicDeleteResult>;
481
+ /**
482
+ * Atomically updates every ordinary model document matching a strict
483
+ * selector. Each matched document is updated atomically; the batch as a
484
+ * whole is not isolated. No upsert is possible, so `$setOnInsert` is
485
+ * rejected.
486
+ */
487
+ static atomicUpdateMany<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: TSmartdataAtomicFilter<T>, updateArg: Omit<ISmartdataAtomicUpdate<T>, '$setOnInsert'>, opts?: ISmartdataAtomicUpdateManyOptions): Promise<ISmartdataAtomicUpdateManyResult>;
488
+ /**
489
+ * Computes bounded grouped counts and optional numeric sums server-side.
490
+ * Groups by one or two declared top-level fields, always returns a `count`
491
+ * per group, and sums only declared numeric fields. The `$limit` follows
492
+ * the group stage without a sort, so when more groups exist than the limit
493
+ * the returned subset is arbitrary. Use `getGroupedTotalsPage()` when the
494
+ * caller must detect overflow. The aggregation cursor never leaves SmartData.
495
+ */
496
+ static getGroupedTotals<T>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: ISmartdataGroupedTotalsOptions<T>): Promise<Array<ISmartdataGroupedTotalsRow<T>>>;
497
+ /**
498
+ * Computes the same bounded grouped totals as `getGroupedTotals()` and
499
+ * reports whether at least one additional group exists beyond the requested
500
+ * row limit.
501
+ */
502
+ static getGroupedTotalsPage<T>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: ISmartdataGroupedTotalsOptions<T>): Promise<ISmartdataGroupedTotalsPage<T>>;
503
+ /**
504
+ * gets all instances as array
505
+ * @param this
506
+ * @param filterArg - Type-safe MongoDB filter with nested object support and operators
507
+ * @returns
508
+ */
509
+ static getInstances<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, opts?: {
510
+ session?: TSmartdataOrdinarySession;
511
+ }): Promise<T[]>;
512
+ /**
513
+ * Cursor-paged query with stable seek pagination — the org-standard way to
514
+ * list unbounded collections. Orders by a comparable (ideally indexed)
515
+ * sort field with a unique tiebreaker, returns one page plus the cursor
516
+ * for the next, and never materializes the full result set.
517
+ * Owned sessions require a prepared model and remain leased through optional
518
+ * counting, model hydration and cursor cleanup.
519
+ */
520
+ static getPagedInstances<T>(this: plugins.tsclass.typeFest.Class<T>, optionsArg: {
521
+ filter?: MongoFilter<T>;
522
+ /** Comparable, ideally indexed field that orders the pages (e.g. a numeric timestamp). */
523
+ sortField: string;
524
+ sortDirection?: 'asc' | 'desc';
525
+ /** Unique tiebreaker field present on every document. Defaults to 'id'. */
526
+ uniqueField?: string;
527
+ /** Page size, default 100, capped at 1000. */
528
+ limit?: number;
529
+ /** Seek position returned as nextCursor by the previous page. */
530
+ cursor?: {
531
+ sortValue: number | string;
532
+ uniqueValue: string;
533
+ };
534
+ /** Also count all filter matches (extra query). */
535
+ withTotal?: boolean;
536
+ session?: TSmartdataOrdinarySession;
537
+ }): Promise<{
538
+ documents: T[];
539
+ nextCursor?: {
540
+ sortValue: number | string;
541
+ uniqueValue: string;
542
+ };
543
+ total?: number;
544
+ }>;
545
+ /**
546
+ * gets the first matching instance
547
+ * @param this
548
+ * @param filterArg
549
+ * @returns
550
+ */
551
+ static getInstance<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, opts?: ISmartdataFindOneOptions<T>): Promise<T>;
552
+ static exists<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, opts?: {
553
+ maxTimeMS?: number;
554
+ session?: TSmartdataOrdinarySession;
555
+ }): Promise<boolean>;
556
+ /**
557
+ * get a unique id prefixed with the class name
558
+ */
559
+ static getNewId<T = any>(this: plugins.tsclass.typeFest.Class<T>, lengthArg?: number): Promise<string>;
560
+ /**
561
+ * Stream results using model-declared projections, sorts and index hints.
562
+ * Offset pages require an explicit sort and limit. Include a unique final
563
+ * tiebreaker; concurrent writes can still move rows between offset pages.
564
+ */
565
+ static getCursor<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, opts?: ISmartdataCursorOptions<T>): Promise<SmartdataDbCursor<T>>;
566
+ /**
567
+ * Read a bounded offset page while retaining an owned session through cursor
568
+ * cleanup. Initialize the model before calling; this operation never creates
569
+ * collections or indexes. Count separately with the same filter and hint.
570
+ */
571
+ static getOffsetPage<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, opts: ISmartdataOffsetPageOptions<T>): Promise<T[]>;
572
+ /**
573
+ * watch the collection
574
+ * @param this
575
+ * @param filterArg
576
+ * @param forEachFunction
577
+ */
578
+ /**
579
+ * Watch the collection for changes, with optional buffering and change stream options.
580
+ * @param filterArg MongoDB filter to select which changes to observe
581
+ * @param opts optional ChangeStreamOptions plus bufferTimeMs
582
+ */
583
+ static watch<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, opts?: plugins.mongodb.ChangeStreamOptions & {
584
+ bufferTimeMs?: number;
585
+ }): Promise<SmartdataDbWatcher<T>>;
586
+ /**
587
+ * run a function for all instances
588
+ * @returns
589
+ */
590
+ static forEach<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg: MongoFilter<T>, forEachFunction: (itemArg: T) => Promise<any>): Promise<void>;
591
+ /**
592
+ * returns a count of the documents in the collection
593
+ */
594
+ static getCount<T>(this: plugins.tsclass.typeFest.Class<T>, filterArg?: MongoFilter<T>, opts?: ISmartdataCountOptions): Promise<number>;
595
+ /**
596
+ * Runs an integrity check on this collection.
597
+ * Returns a summary with estimated vs actual counts and any duplicate unique fields.
598
+ */
599
+ static checkCollectionIntegrity<T>(this: plugins.tsclass.typeFest.Class<T>): Promise<{
600
+ ok: boolean;
601
+ estimatedCount: number;
602
+ actualCount: number;
603
+ duplicateFields: Array<{
604
+ field: string;
605
+ duplicateValues: number;
606
+ }>;
607
+ }>;
608
+ /**
609
+ * Create a MongoDB filter from a Lucene query string
610
+ * @param luceneQuery Lucene query string
611
+ * @returns MongoDB query object
612
+ */
613
+ static createSearchFilter<T>(this: plugins.tsclass.typeFest.Class<T>, luceneQuery: string): any;
614
+ /**
615
+ * List all searchable fields defined on this class
616
+ */
617
+ static getSearchableFields(): string[];
618
+ /**
619
+ * Execute a query with optional hard filter and post-fetch validation
620
+ */
621
+ private static execQuery;
622
+ /**
623
+ * Search documents by text or field:value syntax, with safe regex fallback
624
+ * Supports additional filtering and post-fetch validation via opts
625
+ * @param query A search term or field:value expression
626
+ * @param opts Optional filter and validate hooks
627
+ * @returns Array of matching documents
628
+ */
629
+ static search<T>(this: plugins.tsclass.typeFest.Class<T>, query: string, opts?: SearchOptions<T>): Promise<T[]>;
630
+ /**
631
+ * how the Doc in memory was created, may prove useful later.
632
+ */
633
+ creationStatus: TDocCreation;
634
+ /**
635
+ * updated from db in any case where doc comes from db
636
+ */
637
+ _createdAt: string;
638
+ /**
639
+ * will be updated everytime the doc is saved
640
+ */
641
+ _updatedAt: string;
642
+ /**
643
+ * an array of saveable properties of ALL doc
644
+ * Note: Set by decorators on prototype - NOT declared as instance property to avoid shadowing in Deno
645
+ * Declared with definite assignment assertion to satisfy TypeScript without creating instance property
646
+ */
647
+ globalSaveableProperties: string[];
648
+ /**
649
+ * unique indexes
650
+ * Note: Set by decorators on prototype - NOT declared as instance property to avoid shadowing in Deno
651
+ */
652
+ uniqueIndexes: string[];
653
+ /** Runtime value contracts for fields declared with @unI(). */
654
+ identityValueTypes: Record<string, TSmartdataIdentityValueType>;
655
+ /**
656
+ * regular indexes with their options
657
+ * Note: Set by decorators on prototype - NOT declared as instance property to avoid shadowing in Deno
658
+ */
659
+ regularIndexes: Array<{
660
+ field: string;
661
+ options: IIndexOptions;
662
+ }>;
663
+ /**
664
+ * named compound indexes declared by @compoundIndex
665
+ */
666
+ compoundIndexes: Array<{
667
+ name: string;
668
+ key: Record<string, 1 | -1>;
669
+ options?: Omit<plugins.mongodb.CreateIndexesOptions, 'name'>;
670
+ }>;
671
+ /**
672
+ * an array of saveable properties of a specific doc
673
+ * Note: Set by decorators on prototype - NOT declared as instance property to avoid shadowing in Deno
674
+ */
675
+ saveableProperties: string[];
676
+ /**
677
+ * name
678
+ */
679
+ name: string;
680
+ /**
681
+ * primary id in the database
682
+ */
683
+ dbDocUniqueId: string;
684
+ /**
685
+ * class constructor
686
+ */
687
+ constructor();
688
+ /**
689
+ * saves this instance (optionally within a transaction)
690
+ */
691
+ save(opts?: {
692
+ session?: plugins.mongodb.ClientSession;
693
+ }): Promise<any>;
694
+ /**
695
+ * deletes a document from the database (optionally within a transaction)
696
+ */
697
+ delete(opts?: {
698
+ session?: plugins.mongodb.ClientSession;
699
+ }): Promise<any>;
700
+ /**
701
+ * also store any referenced objects to DB
702
+ * better for data consistency
703
+ */
704
+ saveDeep(savedMapArg?: plugins.lik.ObjectMap<SmartDataDbDoc<any, any>>): void;
705
+ /**
706
+ * updates an object from db
707
+ */
708
+ updateFromDb(): Promise<boolean>;
709
+ /**
710
+ * creates a saveable object so the instance can be persisted as json in the database
711
+ *
712
+ * Properties whose value is `undefined` are omitted entirely rather than
713
+ * written as BSON null, so "absent" stays representable. Explicit `null` is
714
+ * untouched and remains storable wherever the field type allows it.
715
+ */
716
+ createSavableObject(): Promise<TImplements>;
717
+ /**
718
+ * creates an identifiable object for operations that require filtering
719
+ */
720
+ createIdentifiableObject(): Promise<any>;
721
+ }
722
+ export {};