@g9tm/lynxcontrols-sqlite 1.4.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/README.md +12 -0
- package/contract/cases.json +463 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/codecs/codecs.d.ts +68 -0
- package/dist/codecs/codecs.d.ts.map +1 -0
- package/dist/codecs/codecs.js +201 -0
- package/dist/codecs/codecs.js.map +1 -0
- package/dist/contract/run-contract.d.ts +94 -0
- package/dist/contract/run-contract.d.ts.map +1 -0
- package/dist/contract/run-contract.js +159 -0
- package/dist/contract/run-contract.js.map +1 -0
- package/dist/driver/types.d.ts +87 -0
- package/dist/driver/types.d.ts.map +1 -0
- package/dist/driver/types.js +14 -0
- package/dist/driver/types.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +57 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/query/builders.d.ts +216 -0
- package/dist/query/builders.d.ts.map +1 -0
- package/dist/query/builders.js +490 -0
- package/dist/query/builders.js.map +1 -0
- package/dist/query/compile.d.ts +42 -0
- package/dist/query/compile.d.ts.map +1 -0
- package/dist/query/compile.js +307 -0
- package/dist/query/compile.js.map +1 -0
- package/dist/query/expr.d.ts +201 -0
- package/dist/query/expr.d.ts.map +1 -0
- package/dist/query/expr.js +247 -0
- package/dist/query/expr.js.map +1 -0
- package/dist/repo/audit.d.ts +19 -0
- package/dist/repo/audit.d.ts.map +1 -0
- package/dist/repo/audit.js +36 -0
- package/dist/repo/audit.js.map +1 -0
- package/dist/repo/repository.d.ts +233 -0
- package/dist/repo/repository.d.ts.map +1 -0
- package/dist/repo/repository.js +715 -0
- package/dist/repo/repository.js.map +1 -0
- package/dist/schema/columns.d.ts +115 -0
- package/dist/schema/columns.d.ts.map +1 -0
- package/dist/schema/columns.js +112 -0
- package/dist/schema/columns.js.map +1 -0
- package/dist/schema/entity.d.ts +135 -0
- package/dist/schema/entity.d.ts.map +1 -0
- package/dist/schema/entity.js +227 -0
- package/dist/schema/entity.js.map +1 -0
- package/dist/schema/policies.d.ts +89 -0
- package/dist/schema/policies.d.ts.map +1 -0
- package/dist/schema/policies.js +54 -0
- package/dist/schema/policies.js.map +1 -0
- package/dist/session/ambient.d.ts +32 -0
- package/dist/session/ambient.d.ts.map +1 -0
- package/dist/session/ambient.js +28 -0
- package/dist/session/ambient.js.map +1 -0
- package/dist/session/cache.d.ts +62 -0
- package/dist/session/cache.d.ts.map +1 -0
- package/dist/session/cache.js +239 -0
- package/dist/session/cache.js.map +1 -0
- package/dist/session/database.d.ts +221 -0
- package/dist/session/database.d.ts.map +1 -0
- package/dist/session/database.js +430 -0
- package/dist/session/database.js.map +1 -0
- package/dist/session/locator.d.ts +33 -0
- package/dist/session/locator.d.ts.map +1 -0
- package/dist/session/locator.js +39 -0
- package/dist/session/locator.js.map +1 -0
- package/dist/session/migrations.d.ts +75 -0
- package/dist/session/migrations.d.ts.map +1 -0
- package/dist/session/migrations.js +88 -0
- package/dist/session/migrations.js.map +1 -0
- package/dist/session/mutex.d.ts +7 -0
- package/dist/session/mutex.d.ts.map +1 -0
- package/dist/session/mutex.js +27 -0
- package/dist/session/mutex.js.map +1 -0
- package/dist/session/rows.d.ts +17 -0
- package/dist/session/rows.d.ts.map +1 -0
- package/dist/session/rows.js +52 -0
- package/dist/session/rows.js.map +1 -0
- package/dist/session/schema-setup.d.ts +21 -0
- package/dist/session/schema-setup.d.ts.map +1 -0
- package/dist/session/schema-setup.js +227 -0
- package/dist/session/schema-setup.js.map +1 -0
- package/dist/session/scope.d.ts +117 -0
- package/dist/session/scope.d.ts.map +1 -0
- package/dist/session/scope.js +233 -0
- package/dist/session/scope.js.map +1 -0
- package/dist/session/write-hooks.d.ts +84 -0
- package/dist/session/write-hooks.d.ts.map +1 -0
- package/dist/session/write-hooks.js +55 -0
- package/dist/session/write-hooks.js.map +1 -0
- package/dist/values/ids.d.ts +46 -0
- package/dist/values/ids.d.ts.map +1 -0
- package/dist/values/ids.js +84 -0
- package/dist/values/ids.js.map +1 -0
- package/dist/values/int64.d.ts +33 -0
- package/dist/values/int64.d.ts.map +1 -0
- package/dist/values/int64.js +105 -0
- package/dist/values/int64.js.map +1 -0
- package/dist/values/local-date-time.d.ts +61 -0
- package/dist/values/local-date-time.d.ts.map +1 -0
- package/dist/values/local-date-time.js +122 -0
- package/dist/values/local-date-time.js.map +1 -0
- package/dist/values/sql-value.d.ts +36 -0
- package/dist/values/sql-value.d.ts.map +1 -0
- package/dist/values/sql-value.js +70 -0
- package/dist/values/sql-value.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { G9SqliteError, isG9SqliteError } from "../errors.js";
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
else obj[key] = value;
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
class G9Cache {
|
|
13
|
+
get size() {
|
|
14
|
+
var _ref;
|
|
15
|
+
var _this_rows;
|
|
16
|
+
return null != (_ref = null == (_this_rows = this.rows) ? void 0 : _this_rows.length) ? _ref : 0;
|
|
17
|
+
}
|
|
18
|
+
expired() {
|
|
19
|
+
return void 0 !== this.policy.ttlMs && this.db.options.timeSource.monotonicNow() - this.loadedAt >= this.policy.ttlMs;
|
|
20
|
+
}
|
|
21
|
+
async get() {
|
|
22
|
+
if (null === this.rows || this.expired()) await this.refresh();
|
|
23
|
+
else if (this.refreshing) await this.refreshing;
|
|
24
|
+
if (null !== this.rows && 0 === this.rows.length && !this.emptyRetryAttempted) {
|
|
25
|
+
this.emptyRetryAttempted = true;
|
|
26
|
+
await this.refresh();
|
|
27
|
+
}
|
|
28
|
+
return null === this.rows ? [] : [
|
|
29
|
+
...this.rows
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
peek() {
|
|
33
|
+
return null === this.rows ? void 0 : [
|
|
34
|
+
...this.rows
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
refresh() {
|
|
38
|
+
this.cancelTimer();
|
|
39
|
+
if (this.refreshing) {
|
|
40
|
+
const previous = this.refreshing;
|
|
41
|
+
const next = previous.catch(()=>void 0).then(()=>this.refreshCore());
|
|
42
|
+
this.refreshing = next;
|
|
43
|
+
return next;
|
|
44
|
+
}
|
|
45
|
+
const run = this.refreshCore();
|
|
46
|
+
this.refreshing = run;
|
|
47
|
+
return run;
|
|
48
|
+
}
|
|
49
|
+
async refreshCore() {
|
|
50
|
+
const generation = this.generation;
|
|
51
|
+
try {
|
|
52
|
+
const rows = await this.load(this.policy.maxRows);
|
|
53
|
+
if (generation !== this.generation || this.disposed) return;
|
|
54
|
+
this.rows = rows;
|
|
55
|
+
this.loadedAt = this.db.options.timeSource.monotonicNow();
|
|
56
|
+
if (rows.length > 0) this.emptyRetryAttempted = false;
|
|
57
|
+
this.notify(rows);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (generation === this.generation) this.rows = null;
|
|
60
|
+
if (isG9SqliteError(error, 'too-many-rows')) throw new G9SqliteError('too-many-rows', `Cache '${this.name}' would hold more than ${this.policy.maxRows} rows; caches are for small tables.`, {
|
|
61
|
+
cause: error
|
|
62
|
+
});
|
|
63
|
+
throw error;
|
|
64
|
+
} finally{
|
|
65
|
+
if (generation === this.generation) this.refreshing = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
notify(rows) {
|
|
69
|
+
for (const listener of [
|
|
70
|
+
...this.listeners
|
|
71
|
+
])try {
|
|
72
|
+
listener([
|
|
73
|
+
...rows
|
|
74
|
+
]);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
this.db.report(`cache '${this.name}' listener failed`, error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
listen(listener) {
|
|
80
|
+
this.listeners.push(listener);
|
|
81
|
+
if (null !== this.rows) try {
|
|
82
|
+
listener([
|
|
83
|
+
...this.rows
|
|
84
|
+
]);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
this.db.report(`cache '${this.name}' listener failed`, error);
|
|
87
|
+
}
|
|
88
|
+
return ()=>{
|
|
89
|
+
this.stopListening(listener);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
stopListening(listener) {
|
|
93
|
+
const index = this.listeners.lastIndexOf(listener);
|
|
94
|
+
if (index < 0) return false;
|
|
95
|
+
this.listeners.splice(index, 1);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
scheduleRefresh() {
|
|
99
|
+
if (this.disposed || null === this.rows && !this.refreshing) return;
|
|
100
|
+
this.cancelTimer();
|
|
101
|
+
const fire = ()=>{
|
|
102
|
+
this.timer = null;
|
|
103
|
+
this.refresh().catch((error)=>{
|
|
104
|
+
if (!isG9SqliteError(error, 'cancelled')) this.db.report(`cache '${this.name}' refresh failed`, error);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
if (0 === this.policy.debounceMs) fire();
|
|
108
|
+
else this.timer = this.db.options.timers.setTimeout(fire, this.policy.debounceMs);
|
|
109
|
+
}
|
|
110
|
+
cancelTimer() {
|
|
111
|
+
if (null !== this.timer) {
|
|
112
|
+
this.db.options.timers.clearTimeout(this.timer);
|
|
113
|
+
this.timer = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
reset() {
|
|
117
|
+
this.generation++;
|
|
118
|
+
this.cancelTimer();
|
|
119
|
+
this.rows = null;
|
|
120
|
+
this.refreshing = null;
|
|
121
|
+
this.emptyRetryAttempted = false;
|
|
122
|
+
this.notify([]);
|
|
123
|
+
}
|
|
124
|
+
dispose() {
|
|
125
|
+
this.disposed = true;
|
|
126
|
+
this.cancelTimer();
|
|
127
|
+
this.rows = null;
|
|
128
|
+
this.listeners = [];
|
|
129
|
+
}
|
|
130
|
+
constructor(db, name, tables, policy, load){
|
|
131
|
+
_define_property(this, "db", void 0);
|
|
132
|
+
_define_property(this, "load", void 0);
|
|
133
|
+
_define_property(this, "name", void 0);
|
|
134
|
+
_define_property(this, "policy", void 0);
|
|
135
|
+
_define_property(this, "tables", void 0);
|
|
136
|
+
_define_property(this, "rows", void 0);
|
|
137
|
+
_define_property(this, "loadedAt", void 0);
|
|
138
|
+
_define_property(this, "generation", void 0);
|
|
139
|
+
_define_property(this, "listeners", void 0);
|
|
140
|
+
_define_property(this, "timer", void 0);
|
|
141
|
+
_define_property(this, "refreshing", void 0);
|
|
142
|
+
_define_property(this, "emptyRetryAttempted", void 0);
|
|
143
|
+
_define_property(this, "disposed", void 0);
|
|
144
|
+
this.db = db;
|
|
145
|
+
this.load = load;
|
|
146
|
+
this.rows = null;
|
|
147
|
+
this.loadedAt = 0;
|
|
148
|
+
this.generation = 0;
|
|
149
|
+
this.listeners = [];
|
|
150
|
+
this.timer = null;
|
|
151
|
+
this.refreshing = null;
|
|
152
|
+
this.emptyRetryAttempted = false;
|
|
153
|
+
this.disposed = false;
|
|
154
|
+
this.name = name;
|
|
155
|
+
this.policy = policy;
|
|
156
|
+
this.tables = new Set(tables.map((t)=>t.toLowerCase()));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
class G9CacheRegistry {
|
|
160
|
+
all() {
|
|
161
|
+
return [
|
|
162
|
+
...this.entityCaches.values(),
|
|
163
|
+
...this.dtoCaches.values()
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
defineEntityCache(entity, policy, load) {
|
|
167
|
+
const existing = this.entityCaches.get(entity);
|
|
168
|
+
if (existing) return existing;
|
|
169
|
+
const loader = null != load ? load : (maxRows)=>this.db.loadEntityRowsForCache(entity, maxRows);
|
|
170
|
+
const cache = new G9Cache(this.db, entity.name, [
|
|
171
|
+
entity.table
|
|
172
|
+
], policy, loader);
|
|
173
|
+
this.entityCaches.set(entity, cache);
|
|
174
|
+
return cache;
|
|
175
|
+
}
|
|
176
|
+
entityCache(entity) {
|
|
177
|
+
return this.entityCaches.get(entity);
|
|
178
|
+
}
|
|
179
|
+
defineDtoCache(name, sources, policy, load) {
|
|
180
|
+
if (this.dtoCaches.has(name)) throw new G9SqliteError('misuse', `A DTO cache named '${name}' already exists.`);
|
|
181
|
+
if (0 === sources.length) throw new G9SqliteError('misuse', `DTO cache '${name}' needs at least one source entity.`);
|
|
182
|
+
const cache = new G9Cache(this.db, name, sources.map((s)=>s.table), policy, load);
|
|
183
|
+
this.dtoCaches.set(name, cache);
|
|
184
|
+
for (const source of sources){
|
|
185
|
+
var _this_dtoByEntity_get;
|
|
186
|
+
const list = null != (_this_dtoByEntity_get = this.dtoByEntity.get(source)) ? _this_dtoByEntity_get : [];
|
|
187
|
+
list.push(cache);
|
|
188
|
+
this.dtoByEntity.set(source, list);
|
|
189
|
+
}
|
|
190
|
+
return cache;
|
|
191
|
+
}
|
|
192
|
+
dtoCache(name) {
|
|
193
|
+
return this.dtoCaches.get(name);
|
|
194
|
+
}
|
|
195
|
+
invalidateTable(table) {
|
|
196
|
+
const key = table.toLowerCase();
|
|
197
|
+
for (const cache of this.all())if (cache.tables.has(key)) cache.scheduleRefresh();
|
|
198
|
+
}
|
|
199
|
+
invalidateAll() {
|
|
200
|
+
for (const cache of this.all())cache.scheduleRefresh();
|
|
201
|
+
}
|
|
202
|
+
resetAll() {
|
|
203
|
+
for (const cache of this.all())cache.reset();
|
|
204
|
+
}
|
|
205
|
+
async refreshAll() {
|
|
206
|
+
for (const cache of this.all())await cache.refresh();
|
|
207
|
+
}
|
|
208
|
+
async refreshEntity(entity) {
|
|
209
|
+
const cache = this.entityCaches.get(entity);
|
|
210
|
+
if (!cache) return false;
|
|
211
|
+
await cache.refresh();
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
async refreshEntityAndDtoCaches(entity) {
|
|
215
|
+
var _this_dtoByEntity_get;
|
|
216
|
+
var _this_entityCaches_get;
|
|
217
|
+
await (null == (_this_entityCaches_get = this.entityCaches.get(entity)) ? void 0 : _this_entityCaches_get.refresh());
|
|
218
|
+
for (const dto of null != (_this_dtoByEntity_get = this.dtoByEntity.get(entity)) ? _this_dtoByEntity_get : [])await dto.refresh();
|
|
219
|
+
}
|
|
220
|
+
get totalRows() {
|
|
221
|
+
return this.all().reduce((n, c)=>n + c.size, 0);
|
|
222
|
+
}
|
|
223
|
+
dispose() {
|
|
224
|
+
for (const cache of this.all())cache.dispose();
|
|
225
|
+
}
|
|
226
|
+
constructor(db){
|
|
227
|
+
_define_property(this, "db", void 0);
|
|
228
|
+
_define_property(this, "entityCaches", void 0);
|
|
229
|
+
_define_property(this, "dtoCaches", void 0);
|
|
230
|
+
_define_property(this, "dtoByEntity", void 0);
|
|
231
|
+
this.db = db;
|
|
232
|
+
this.entityCaches = new Map();
|
|
233
|
+
this.dtoCaches = new Map();
|
|
234
|
+
this.dtoByEntity = new Map();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
export { G9CacheRegistry };
|
|
238
|
+
|
|
239
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session/cache.js","sources":["../../src/session/cache.ts"],"sourcesContent":["import { G9SqliteError, isG9SqliteError } from '../errors';\nimport type { G9EntityDescriptor } from '../schema/entity';\nimport type { G9CachePolicy } from '../schema/policies';\nimport type { G9SqliteDatabase } from './database';\n\n/**\n * An in-memory copy of a small, hot table or a DTO projection over tables (MAUI repository cache and\n * `SqliteDtoCache`). Invalidated only by committed writes (never by a rollback), coalesced by the policy's debounce,\n * bounded by `maxRows`, optionally expiring, and reset on a user switch so no row of one user reaches the next.\n */\nexport interface G9CacheHandle<T> {\n readonly name: string;\n readonly policy: G9CachePolicy;\n /** MAUI `GetCacheDataAsync`: loads on first use (and after expiry or reset), then serves copies. */\n get(): Promise<T[]>;\n /** MAUI `GetCacheData` (synchronous): a copy when loaded, otherwise `undefined` (JS cannot block on a load). */\n peek(): T[] | undefined;\n /** MAUI `RefreshCache`: reload now, cancelling a pending debounced refresh. */\n refresh(): Promise<void>;\n /** MAUI `ListenToCacheData`: called with a copy after each refresh and with `[]` on reset; immediately if loaded. */\n listen(listener: (rows: T[]) => void): () => void;\n /** MAUI `StopListeningToCacheData`. */\n stopListening(listener: (rows: T[]) => void): boolean;\n /** MAUI `ScheduleDebouncedRefresh`. */\n scheduleRefresh(): void;\n /** Rows currently held (for bounds checks). */\n readonly size: number;\n}\n\nclass G9Cache<T> implements G9CacheHandle<T> {\n readonly name: string;\n readonly policy: G9CachePolicy;\n readonly tables: ReadonlySet<string>;\n private rows: T[] | null = null;\n private loadedAt = 0;\n private generation = 0;\n private listeners: ((rows: T[]) => void)[] = [];\n private timer: unknown = null;\n private refreshing: Promise<void> | null = null;\n private emptyRetryAttempted = false;\n private disposed = false;\n\n constructor(\n private readonly db: G9SqliteDatabase,\n name: string,\n tables: readonly string[],\n policy: G9CachePolicy,\n private readonly load: (maxRows: number) => Promise<T[]>,\n ) {\n this.name = name;\n this.policy = policy;\n this.tables = new Set(tables.map((t) => t.toLowerCase()));\n }\n\n get size(): number {\n return this.rows?.length ?? 0;\n }\n\n private expired(): boolean {\n return (\n this.policy.ttlMs !== undefined && this.db.options.timeSource.monotonicNow() - this.loadedAt >= this.policy.ttlMs\n );\n }\n\n async get(): Promise<T[]> {\n if (this.rows === null || this.expired()) await this.refresh();\n else if (this.refreshing) await this.refreshing;\n if (this.rows !== null && this.rows.length === 0 && !this.emptyRetryAttempted) {\n // MAUI: an empty cache gets one extra reload (a table filled right after the first read).\n this.emptyRetryAttempted = true;\n await this.refresh();\n }\n // `null` here means a user switch reset the cache while it loaded: nothing of the old user is served.\n return this.rows === null ? [] : [...this.rows];\n }\n\n peek(): T[] | undefined {\n return this.rows === null ? undefined : [...this.rows];\n }\n\n refresh(): Promise<void> {\n this.cancelTimer();\n if (this.refreshing) {\n // A refresh already running may have loaded before the latest commit: chain one more.\n const previous = this.refreshing;\n const next = previous.catch(() => undefined).then(() => this.refreshCore());\n this.refreshing = next;\n return next;\n }\n const run = this.refreshCore();\n this.refreshing = run;\n return run;\n }\n\n private async refreshCore(): Promise<void> {\n const generation = this.generation;\n try {\n const rows = await this.load(this.policy.maxRows);\n if (generation !== this.generation || this.disposed) return;\n this.rows = rows;\n this.loadedAt = this.db.options.timeSource.monotonicNow();\n if (rows.length > 0) this.emptyRetryAttempted = false;\n this.notify(rows);\n } catch (error) {\n if (generation === this.generation) this.rows = null;\n if (isG9SqliteError(error, 'too-many-rows')) {\n throw new G9SqliteError(\n 'too-many-rows',\n `Cache '${this.name}' would hold more than ${this.policy.maxRows} rows; caches are for small tables.`,\n { cause: error },\n );\n }\n throw error;\n } finally {\n if (generation === this.generation) this.refreshing = null;\n }\n }\n\n private notify(rows: readonly T[]): void {\n for (const listener of [...this.listeners]) {\n try {\n listener([...rows]);\n } catch (error) {\n this.db.report(`cache '${this.name}' listener failed`, error);\n }\n }\n }\n\n listen(listener: (rows: T[]) => void): () => void {\n this.listeners.push(listener);\n if (this.rows !== null) {\n try {\n listener([...this.rows]);\n } catch (error) {\n this.db.report(`cache '${this.name}' listener failed`, error);\n }\n }\n return () => {\n this.stopListening(listener);\n };\n }\n\n stopListening(listener: (rows: T[]) => void): boolean {\n const index = this.listeners.lastIndexOf(listener);\n if (index < 0) return false;\n this.listeners.splice(index, 1);\n return true;\n }\n\n scheduleRefresh(): void {\n if (this.disposed || (this.rows === null && !this.refreshing)) return; // never loaded: the next get() loads\n this.cancelTimer();\n const fire = () => {\n this.timer = null;\n this.refresh().catch((error) => {\n if (!isG9SqliteError(error, 'cancelled')) this.db.report(`cache '${this.name}' refresh failed`, error);\n });\n };\n if (this.policy.debounceMs === 0) fire();\n else this.timer = this.db.options.timers.setTimeout(fire, this.policy.debounceMs);\n }\n\n private cancelTimer(): void {\n if (this.timer !== null) {\n this.db.options.timers.clearTimeout(this.timer);\n this.timer = null;\n }\n }\n\n /** MAUI `ResetCacheForSession`: drops rows, invalidates in-flight refreshes, tells listeners `[]`. */\n reset(): void {\n this.generation++;\n this.cancelTimer();\n this.rows = null;\n this.refreshing = null;\n this.emptyRetryAttempted = false;\n this.notify([]);\n }\n\n dispose(): void {\n this.disposed = true;\n this.cancelTimer();\n this.rows = null;\n this.listeners = [];\n }\n}\n\n/**\n * Every cache of one database (MAUI `SqliteRepositoryCacheRegistry`): entity caches keyed by descriptor, DTO caches\n * by name, all invalidated by table on commit.\n */\nexport class G9CacheRegistry {\n private readonly entityCaches = new Map<G9EntityDescriptor, G9Cache<unknown>>();\n private readonly dtoCaches = new Map<string, G9Cache<unknown>>();\n private readonly dtoByEntity = new Map<G9EntityDescriptor, G9Cache<unknown>[]>();\n\n constructor(private readonly db: G9SqliteDatabase) {}\n\n private all(): G9Cache<unknown>[] {\n return [...this.entityCaches.values(), ...this.dtoCaches.values()];\n }\n\n /** MAUI `DefineCache` (+ descriptor `Cache(policy)`): idempotent per entity. */\n defineEntityCache<T>(\n entity: G9EntityDescriptor,\n policy: G9CachePolicy,\n load?: (maxRows: number) => Promise<T[]>,\n ): G9CacheHandle<T> {\n const existing = this.entityCaches.get(entity);\n if (existing) return existing as G9CacheHandle<T>;\n const loader = load ?? ((maxRows: number) => this.db.loadEntityRowsForCache<T>(entity, maxRows));\n const cache = new G9Cache<T>(this.db, entity.name, [entity.table], policy, loader);\n this.entityCaches.set(entity, cache as G9Cache<unknown>);\n return cache;\n }\n\n /** The entity's cache, or `undefined` when none is defined (MAUI `HasDefinedCache`). */\n entityCache<T>(entity: G9EntityDescriptor): G9CacheHandle<T> | undefined {\n return this.entityCaches.get(entity) as G9CacheHandle<T> | undefined;\n }\n\n /** MAUI `SqliteDtoCache<TEntity,TDto>.DefineCache` / `RegisterDtoCacheForEntity`. */\n defineDtoCache<T>(\n name: string,\n sources: readonly G9EntityDescriptor[],\n policy: G9CachePolicy,\n load: (maxRows: number) => Promise<T[]>,\n ): G9CacheHandle<T> {\n if (this.dtoCaches.has(name)) throw new G9SqliteError('misuse', `A DTO cache named '${name}' already exists.`);\n if (sources.length === 0)\n throw new G9SqliteError('misuse', `DTO cache '${name}' needs at least one source entity.`);\n const cache = new G9Cache<T>(\n this.db,\n name,\n sources.map((s) => s.table),\n policy,\n load,\n );\n this.dtoCaches.set(name, cache as G9Cache<unknown>);\n for (const source of sources) {\n const list = this.dtoByEntity.get(source) ?? [];\n list.push(cache as G9Cache<unknown>);\n this.dtoByEntity.set(source, list);\n }\n return cache;\n }\n\n /** The DTO cache of that name, if defined. */\n dtoCache<T>(name: string): G9CacheHandle<T> | undefined {\n return this.dtoCaches.get(name) as G9CacheHandle<T> | undefined;\n }\n\n /** Commit-driven invalidation: every cache reading this table schedules its refresh. */\n invalidateTable(table: string): void {\n const key = table.toLowerCase();\n for (const cache of this.all()) if (cache.tables.has(key)) cache.scheduleRefresh();\n }\n\n /** A raw mutation of unknown tables: every cache schedules its refresh. */\n invalidateAll(): void {\n for (const cache of this.all()) cache.scheduleRefresh();\n }\n\n /** MAUI `ResetAllCachesForSession`: each cache resets even if another fails. */\n resetAll(): void {\n // reset() cannot throw: listener failures are isolated inside it, so every cache resets.\n for (const cache of this.all()) cache.reset();\n }\n\n /** MAUI `HardRefreshAllCacheAsync`. */\n async refreshAll(): Promise<void> {\n for (const cache of this.all()) await cache.refresh();\n }\n\n /** MAUI `RefreshCacheAsync(Type)`: `false` when the entity has no cache. */\n async refreshEntity(entity: G9EntityDescriptor): Promise<boolean> {\n const cache = this.entityCaches.get(entity);\n if (!cache) return false;\n await cache.refresh();\n return true;\n }\n\n /** MAUI `RefreshEntityAndDtoCachesAsync`. */\n async refreshEntityAndDtoCaches(entity: G9EntityDescriptor): Promise<void> {\n await this.entityCaches.get(entity)?.refresh();\n for (const dto of this.dtoByEntity.get(entity) ?? []) await dto.refresh();\n }\n\n /** Total cached rows (memory-bound checks). */\n get totalRows(): number {\n return this.all().reduce((n, c) => n + c.size, 0);\n }\n\n dispose(): void {\n for (const cache of this.all()) cache.dispose();\n }\n}\n"],"names":["G9Cache","_this_rows","undefined","previous","next","run","generation","rows","error","isG9SqliteError","G9SqliteError","listener","index","fire","db","name","tables","policy","load","Set","t","G9CacheRegistry","entity","existing","loader","maxRows","cache","sources","s","source","_this_dtoByEntity_get","list","table","key","_this_entityCaches_get","dto","n","c","Map"],"mappings":";;;;;;;;;;;AA6BA,MAAMA;IAyBJ,IAAI,OAAe;;YACVC;QAAP,OAAO,QAAP,gBAAOA,CAAAA,aAAAA,IAAI,CAAC,IAAI,AAAD,IAARA,KAAAA,IAAAA,WAAW,MAAM,AAAD,IAAC,OAAI;IAC9B;IAEQ,UAAmB;QACzB,OACE,AAAsBC,WAAtB,IAAI,CAAC,MAAM,CAAC,KAAK,IAAkB,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,KAAK,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK;IAErH;IAEA,MAAM,MAAoB;QACxB,IAAI,AAAc,SAAd,IAAI,CAAC,IAAI,IAAa,IAAI,CAAC,OAAO,IAAI,MAAM,IAAI,CAAC,OAAO;aACvD,IAAI,IAAI,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,UAAU;QAC/C,IAAI,AAAc,SAAd,IAAI,CAAC,IAAI,IAAa,AAAqB,MAArB,IAAI,CAAC,IAAI,CAAC,MAAM,IAAU,CAAC,IAAI,CAAC,mBAAmB,EAAE;YAE7E,IAAI,CAAC,mBAAmB,GAAG;YAC3B,MAAM,IAAI,CAAC,OAAO;QACpB;QAEA,OAAO,AAAc,SAAd,IAAI,CAAC,IAAI,GAAY,EAAE,GAAG;eAAI,IAAI,CAAC,IAAI;SAAC;IACjD;IAEA,OAAwB;QACtB,OAAO,AAAc,SAAd,IAAI,CAAC,IAAI,GAAYA,SAAY;eAAI,IAAI,CAAC,IAAI;SAAC;IACxD;IAEA,UAAyB;QACvB,IAAI,CAAC,WAAW;QAChB,I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KAAK,MAAMX,SAAS,IAAI,CAAC,GAAG,GAAIA,MAAM,OAAO;IAC/C;IAnGA,YAA6BZ,EAAoB,CAAE;;QAJnD,uBAAiB,gBAAjB;QACA,uBAAiB,aAAjB;QACA,uBAAiB,eAAjB;aAE6BA,EAAE,GAAFA;aAJZ,YAAY,GAAG,IAAIwB;aACnB,SAAS,GAAG,IAAIA;aAChB,WAAW,GAAG,IAAIA;IAEiB;AAoGtD"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { type G9AbortSignal, type G9Clock, type G9Diagnostics, type G9Timers } from '@g9tm/lynxcontrols-foundation';
|
|
2
|
+
import type { G9CodecContext } from '../codecs/codecs.js';
|
|
3
|
+
import type { G9ConnectionPragmas, G9DriverCapabilities, G9DriverStatement, G9Durability, G9SessionToken, G9SqliteDriver, G9SqlResult, G9TxToken } from '../driver/types.js';
|
|
4
|
+
import { type G9BuildOptions } from '../query/builders.js';
|
|
5
|
+
import type { G9EntityDescriptor } from '../schema/entity.js';
|
|
6
|
+
import type { G9IdCase } from '../values/ids.js';
|
|
7
|
+
import type { G9DateTimeWriteProfile } from '../values/local-date-time.js';
|
|
8
|
+
import { type G9AuditClock, type G9CurrentUserProvider } from './ambient.js';
|
|
9
|
+
import { G9CacheRegistry } from './cache.js';
|
|
10
|
+
import type { G9DatabaseLocator } from './locator.js';
|
|
11
|
+
import { type G9Initializer, type G9Migration } from './migrations.js';
|
|
12
|
+
import { G9AsyncLock } from './mutex.js';
|
|
13
|
+
import type { G9ChangeEvent, G9SqliteInterceptor } from './write-hooks.js';
|
|
14
|
+
/** Bounded retry around whole transactions when SQLite reports `busy` (MAUI `UseBusyRetry`, N10). */
|
|
15
|
+
export interface G9BusyOptions {
|
|
16
|
+
/** `PRAGMA busy_timeout` applied on every open (SQLite's own wait). Default 5000. */
|
|
17
|
+
readonly timeoutMs?: number;
|
|
18
|
+
/** Extra attempts of a whole transaction after `busy` (MAUI default 4). 0 disables. */
|
|
19
|
+
readonly retries?: number;
|
|
20
|
+
/** First back-off delay; doubles per attempt (MAUI default 180). */
|
|
21
|
+
readonly initialDelayMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/** Options of {@link createG9Sqlite} (MAUI `G9SqliteOptions` / `AddG9Sqlite` builder). */
|
|
24
|
+
export interface G9SqliteOptions {
|
|
25
|
+
readonly driver: G9SqliteDriver;
|
|
26
|
+
/** MAUI `DatabaseLocator`. */
|
|
27
|
+
readonly locator: G9DatabaseLocator;
|
|
28
|
+
/** Create a missing database file. Default `false`: opening a missing file fails (`not-found`), never blank. */
|
|
29
|
+
readonly create?: boolean;
|
|
30
|
+
readonly readOnly?: boolean;
|
|
31
|
+
/** MAUI `Clock`: "now" for audit columns. Default UTC. */
|
|
32
|
+
readonly clock?: G9AuditClock;
|
|
33
|
+
/** MAUI `CurrentUser`. Default nobody. */
|
|
34
|
+
readonly currentUser?: G9CurrentUserProvider;
|
|
35
|
+
/** MAUI `CanonicalIdCase`. Default `'lower'`. Fixed for the life of this database object. */
|
|
36
|
+
readonly idCase?: G9IdCase;
|
|
37
|
+
/** How date/times are written. Default the MAUI provider format. */
|
|
38
|
+
readonly dateTimeProfile?: G9DateTimeWriteProfile;
|
|
39
|
+
/** D13: `full` (default) or `normal`. */
|
|
40
|
+
readonly durability?: G9Durability;
|
|
41
|
+
/** Connection tuning applied on every open. Default WAL, temp_store MEMORY, 8 MiB cache, no mmap. */
|
|
42
|
+
readonly connection?: Omit<G9ConnectionPragmas, 'busyTimeoutMs'>;
|
|
43
|
+
/** MAUI `BusyRetryAttempts` / `BusyRetryInitialDelayMs` plus the busy timeout. */
|
|
44
|
+
readonly busy?: G9BusyOptions;
|
|
45
|
+
/** MAUI `Migrations` (N01). */
|
|
46
|
+
readonly migrations?: readonly G9Migration[];
|
|
47
|
+
/** MAUI `Initializers` (N02). */
|
|
48
|
+
readonly initializers?: readonly G9Initializer[];
|
|
49
|
+
/** MAUI `Interceptors` (N03), in registration order. */
|
|
50
|
+
readonly interceptors?: readonly G9SqliteInterceptor[];
|
|
51
|
+
/** MAUI `Entities` (N04): validated now; their indexes are created on open and their caches defined. */
|
|
52
|
+
readonly entities?: Readonly<Record<string, G9EntityDescriptor>>;
|
|
53
|
+
/** Culture key for localized columns when a query calls `withCulture()` without one (`'En'`, `'Fa'`). */
|
|
54
|
+
readonly cultureKey?: () => string;
|
|
55
|
+
/** IN-list placeholder budget (default 16 000). */
|
|
56
|
+
readonly maxInListParameters?: number;
|
|
57
|
+
/** Timers for cache debounce and retry back-off (tests pass fake ones). */
|
|
58
|
+
readonly timers?: G9Timers;
|
|
59
|
+
/** Monotonic time for cache TTL. */
|
|
60
|
+
readonly timeSource?: G9Clock;
|
|
61
|
+
/** Where post-commit hook failures and cache refresh failures are reported. */
|
|
62
|
+
readonly diagnostics?: G9Diagnostics;
|
|
63
|
+
}
|
|
64
|
+
/** Resolved, frozen options. */
|
|
65
|
+
export interface G9ResolvedSqliteOptions {
|
|
66
|
+
readonly driver: G9SqliteDriver;
|
|
67
|
+
readonly locator: G9DatabaseLocator;
|
|
68
|
+
readonly create: boolean;
|
|
69
|
+
readonly readOnly: boolean;
|
|
70
|
+
readonly clock: G9AuditClock;
|
|
71
|
+
readonly currentUser: G9CurrentUserProvider;
|
|
72
|
+
readonly codec: G9CodecContext;
|
|
73
|
+
readonly durability: G9Durability;
|
|
74
|
+
readonly pragmas: G9ConnectionPragmas;
|
|
75
|
+
readonly busyRetries: number;
|
|
76
|
+
readonly busyInitialDelayMs: number;
|
|
77
|
+
readonly migrations: readonly G9Migration[];
|
|
78
|
+
readonly initializers: readonly G9Initializer[];
|
|
79
|
+
readonly interceptors: readonly G9SqliteInterceptor[];
|
|
80
|
+
readonly entities: readonly G9EntityDescriptor[];
|
|
81
|
+
readonly cultureKey: (() => string) | undefined;
|
|
82
|
+
readonly maxInListParameters: number | undefined;
|
|
83
|
+
readonly timers: G9Timers;
|
|
84
|
+
readonly timeSource: G9Clock;
|
|
85
|
+
readonly diagnostics: G9Diagnostics | undefined;
|
|
86
|
+
}
|
|
87
|
+
interface Connection {
|
|
88
|
+
readonly token: G9SessionToken;
|
|
89
|
+
readonly path: string;
|
|
90
|
+
readonly generation: number;
|
|
91
|
+
}
|
|
92
|
+
/** @internal A unit of work: statements run inside one transaction (or one atomic batch) and commit together. */
|
|
93
|
+
export interface G9UnitOfWork {
|
|
94
|
+
readonly db: G9SqliteDatabase;
|
|
95
|
+
/** The transaction token, or `null` for a single atomic batch. */
|
|
96
|
+
readonly tx: G9TxToken | null;
|
|
97
|
+
/** The transaction state (for scopes opened inside the unit), or `null`. */
|
|
98
|
+
readonly txState: TxState | null;
|
|
99
|
+
run(statements: readonly G9DriverStatement[]): Promise<G9SqlResult[]>;
|
|
100
|
+
/** Runs after the commit (never after a rollback). */
|
|
101
|
+
onCommit(callback: () => void | Promise<void>): void;
|
|
102
|
+
readonly signal: G9AbortSignal | undefined;
|
|
103
|
+
}
|
|
104
|
+
interface TxState {
|
|
105
|
+
readonly token: G9TxToken;
|
|
106
|
+
readonly session: G9SessionToken;
|
|
107
|
+
readonly generation: number;
|
|
108
|
+
readonly commitCallbacks: (() => void | Promise<void>)[];
|
|
109
|
+
savepoints: number;
|
|
110
|
+
finished: boolean;
|
|
111
|
+
}
|
|
112
|
+
/** Options of a transaction. */
|
|
113
|
+
export interface G9TransactionOptions {
|
|
114
|
+
/** `immediate` (default) takes the write lock at begin, so a busy conflict surfaces before any work. */
|
|
115
|
+
readonly mode?: 'deferred' | 'immediate';
|
|
116
|
+
readonly signal?: G9AbortSignal;
|
|
117
|
+
/** Override the database's busy retry count for this transaction. */
|
|
118
|
+
readonly retries?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The session layer (MAUI `G9SqliteConnectionProvider` + repository plumbing): owns the connection, the user/path
|
|
122
|
+
* generation, the write lock, transactions, caches and change notifications. One writer connection serialises all
|
|
123
|
+
* work in FIFO order; a transaction holds it for its whole duration.
|
|
124
|
+
*/
|
|
125
|
+
export declare class G9SqliteDatabase {
|
|
126
|
+
/** @internal */ readonly options: G9ResolvedSqliteOptions;
|
|
127
|
+
/** @internal */ readonly lock: G9AsyncLock;
|
|
128
|
+
/** @internal */ readonly caches: G9CacheRegistry;
|
|
129
|
+
private connection;
|
|
130
|
+
private generationValue;
|
|
131
|
+
private capabilitiesValue;
|
|
132
|
+
private readonly unsubscribeLocator;
|
|
133
|
+
private readonly changeListeners;
|
|
134
|
+
private closed;
|
|
135
|
+
constructor(options: G9SqliteOptions);
|
|
136
|
+
/** Bumped by every user/path switch; work noted under an older generation is cancelled or discarded. */
|
|
137
|
+
get generation(): number;
|
|
138
|
+
/** MAUI `DatabasePath`: what the locator answers now. */
|
|
139
|
+
get databasePath(): string;
|
|
140
|
+
/** MAUI `ActiveDatabasePath`: the path of the open connection, or `null`. */
|
|
141
|
+
get activeDatabasePath(): string | null;
|
|
142
|
+
/** MAUI `HasActiveDatabase`: whether the locator can currently answer. */
|
|
143
|
+
get hasActiveDatabase(): boolean;
|
|
144
|
+
/** @internal Build options for compiling queries against this database. */
|
|
145
|
+
buildOptions(): G9BuildOptions;
|
|
146
|
+
/** @internal Reports a non-fatal failure (post-commit hook, cache refresh) to diagnostics. */
|
|
147
|
+
report(message: string, error: unknown): void;
|
|
148
|
+
/** Driver capabilities (negotiated once). */
|
|
149
|
+
capabilities(): Promise<G9DriverCapabilities>;
|
|
150
|
+
private ensureOpen;
|
|
151
|
+
/** @internal Resolves the connection for the current path; caller holds the lock. */
|
|
152
|
+
connect(): Promise<Connection>;
|
|
153
|
+
/**
|
|
154
|
+
* MAUI `SqliteMigrationRunner.RunAsync`: opens the connection now, which applies pending migrations, declared
|
|
155
|
+
* indexes and initializers (otherwise that happens on the first call). Rejects with the migration's error.
|
|
156
|
+
*/
|
|
157
|
+
migrate(): Promise<void>;
|
|
158
|
+
/** @internal Runs work while holding the connection lock. */
|
|
159
|
+
withLock<T>(work: (connection: Connection) => Promise<T>, signal?: G9AbortSignal): Promise<T>;
|
|
160
|
+
/** @internal A read (or any single batch) outside a transaction; discarded if the user switched meanwhile. */
|
|
161
|
+
runRead(statements: readonly G9DriverStatement[], options?: {
|
|
162
|
+
maxRows?: number;
|
|
163
|
+
signal?: G9AbortSignal;
|
|
164
|
+
}): Promise<G9SqlResult[]>;
|
|
165
|
+
/**
|
|
166
|
+
* @internal Runs a unit of work. Inside an open transaction (`parent`), it joins it. Otherwise it takes the lock
|
|
167
|
+
* and either runs one atomic batch (`needsTransaction` false: one bridge call) or a full immediate transaction,
|
|
168
|
+
* retrying the whole unit on `busy`. Commit callbacks run after the lock is released.
|
|
169
|
+
*/
|
|
170
|
+
unit<T>(parent: TxState | null, needsTransaction: boolean, work: (uow: G9UnitOfWork) => Promise<T>, options?: G9TransactionOptions): Promise<T>;
|
|
171
|
+
/** @internal */
|
|
172
|
+
sleep(ms: number, signal?: G9AbortSignal): Promise<void>;
|
|
173
|
+
private joinUnit;
|
|
174
|
+
/** @internal */
|
|
175
|
+
runInTx(tx: TxState, statements: readonly G9DriverStatement[], maxRows: number | undefined, signal: G9AbortSignal | undefined): Promise<G9SqlResult[]>;
|
|
176
|
+
private unitOnce;
|
|
177
|
+
/** @internal */
|
|
178
|
+
beginTx(connection: Connection, mode: 'deferred' | 'immediate'): Promise<TxState>;
|
|
179
|
+
/** @internal */
|
|
180
|
+
commitTx(tx: TxState): Promise<void>;
|
|
181
|
+
/** @internal */
|
|
182
|
+
rollbackTx(tx: TxState): Promise<void>;
|
|
183
|
+
/** @internal Commit callbacks: cache invalidation, post-commit hooks, change events. Failures are reported. */
|
|
184
|
+
runCommitCallbacks(callbacks: readonly (() => void | Promise<void>)[]): Promise<void>;
|
|
185
|
+
/** @internal Explicit transaction: holds the lock until commit/rollback. */
|
|
186
|
+
openTransaction(options?: G9TransactionOptions): Promise<{
|
|
187
|
+
tx: TxState;
|
|
188
|
+
release: () => void;
|
|
189
|
+
}>;
|
|
190
|
+
/**
|
|
191
|
+
* MAUI `SwitchDatabaseAsync` / `DatabasePathChanged`: bumps the generation (queued work of the old user is
|
|
192
|
+
* cancelled, rows a running read returns are discarded), resets every cache synchronously, then closes the
|
|
193
|
+
* connection once the current holder finishes. The next call opens whatever the locator answers.
|
|
194
|
+
*/
|
|
195
|
+
switchDatabase(): Promise<void>;
|
|
196
|
+
/** MAUI `CloseCurrentConnectionAsync`: closes the connection without switching users. */
|
|
197
|
+
closeConnection(): Promise<void>;
|
|
198
|
+
/** MAUI `CheckpointWalAsync`: `PRAGMA wal_checkpoint(TRUNCATE)` on the open connection (no-op when none). */
|
|
199
|
+
checkpointWal(): Promise<void>;
|
|
200
|
+
/** Disposes: unsubscribes the locator, stops caches, closes the connection. Later calls fail with `misuse`. */
|
|
201
|
+
close(): Promise<void>;
|
|
202
|
+
/** Subscribes to committed changes (one event per committed write); returns the unsubscribe function. */
|
|
203
|
+
onChange(listener: (event: G9ChangeEvent) => void): () => void;
|
|
204
|
+
/** @internal Publishes a committed change: caches first, then listeners. */
|
|
205
|
+
publishChange(event: G9ChangeEvent): void;
|
|
206
|
+
/** @internal Tells change listeners (after caches and post-commit hooks). */
|
|
207
|
+
emitChange(event: G9ChangeEvent): void;
|
|
208
|
+
/**
|
|
209
|
+
* Tells caches and listeners that something else wrote to these tables (a sync engine on the same file, another
|
|
210
|
+
* connection). Caches of those tables (and DTO caches over them) refresh.
|
|
211
|
+
*/
|
|
212
|
+
notifyExternalChange(change: {
|
|
213
|
+
readonly tables: readonly string[];
|
|
214
|
+
}): void;
|
|
215
|
+
/** @internal Encodes raw parameters (no codecs, MAUI `NormalizeParam`). */
|
|
216
|
+
encodeRaw(params: readonly unknown[]): G9DriverStatement['params'];
|
|
217
|
+
/** @internal Loads an entity cache: managed SELECT (filters, soft delete), localized when a culture is set. */
|
|
218
|
+
loadEntityRowsForCache<T>(entity: G9EntityDescriptor, maxRows: number): Promise<T[]>;
|
|
219
|
+
}
|
|
220
|
+
export type { TxState as G9TxState };
|
|
221
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 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