@noldova/context.data 0.0.0-stage → 0.0.7

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 (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/api/index.d.ts +569 -0
  4. package/api/index.js +25 -0
  5. package/api/index.js.map +1 -0
  6. package/enums/change-operation.js +14 -0
  7. package/enums/change-operation.js.map +1 -0
  8. package/exceptions/data.exception.js +15 -0
  9. package/exceptions/data.exception.js.map +1 -0
  10. package/models/change.js +31 -0
  11. package/models/change.js.map +1 -0
  12. package/models/connection.js +63 -0
  13. package/models/connection.js.map +1 -0
  14. package/models/data-record.js +44 -0
  15. package/models/data-record.js.map +1 -0
  16. package/models/data-source.js +20 -0
  17. package/models/data-source.js.map +1 -0
  18. package/models/database-facade.js +29 -0
  19. package/models/database-facade.js.map +1 -0
  20. package/models/db-context-options-builder.js +14 -0
  21. package/models/db-context-options-builder.js.map +1 -0
  22. package/models/db-context-options.js +16 -0
  23. package/models/db-context-options.js.map +1 -0
  24. package/models/db-context.js +18 -0
  25. package/models/db-context.js.map +1 -0
  26. package/models/index.js +26 -0
  27. package/models/index.js.map +1 -0
  28. package/models/migration.js +28 -0
  29. package/models/migration.js.map +1 -0
  30. package/models/transaction.js +48 -0
  31. package/models/transaction.js.map +1 -0
  32. package/package.json +24 -4
  33. package/resources.js +38 -0
  34. package/resources.js.map +1 -0
  35. package/services/change-feed.js +24 -0
  36. package/services/change-feed.js.map +1 -0
  37. package/services/data-provider.js +10 -0
  38. package/services/data-provider.js.map +1 -0
  39. package/services/migration-history.js +10 -0
  40. package/services/migration-history.js.map +1 -0
  41. package/services/migrator.js +32 -0
  42. package/services/migrator.js.map +1 -0
  43. package/types/data-value.js +9 -0
  44. package/types/data-value.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Noldova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # noldova.context.data
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The database-independent data model a provider implements: a `DbContext`
4
+ opened from options, its connection and transactions, the migrations it
5
+ applies in id order, and a change feed that records every mutation in
6
+ sequence. Every operation that reaches the database returns a promise;
7
+ connections, transactions and contexts are disposed with `await using`.
8
+ A connection runs one transaction at a time; inside a transaction's action,
9
+ everything goes through the transaction the action receives, never the
10
+ connection, whose calls would wait for the action to end.
11
+
12
+ `noldova.context.data.sql` implements the model over SQL, and its SQLite and
13
+ PostgreSQL providers over each database.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install @noldova/context.data
19
+ ```
20
+
21
+ ## Use
22
+
23
+ ```ts
24
+ import { ChangeOperation } from "@noldova/context.data";
25
+
26
+ await using context = new NotesContext(options);
27
+ await context.database.migrateAsync();
28
+ await context.database.connection.runInTransactionAsync(async transaction => {
29
+ await context.database.changeFeed.appendAsync("note", "1", ChangeOperation.Insert, "{}", transaction);
30
+ });
31
+ const changes = await context.database.changeFeed.readAfterAsync(0);
32
+ ```
33
+
34
+ The declaration file `api/index.d.ts` documents every member with its
35
+ contract.
36
+
37
+ ## License
38
+
39
+ MIT; see `LICENSE`.
package/api/index.d.ts ADDED
@@ -0,0 +1,569 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import type { ExceptionOptions } from "@noldova/context.exceptions";
10
+ import { Exception } from "@noldova/context.exceptions";
11
+
12
+ /**
13
+ * A value a store holds in a field or binds to a query: text, a number, or
14
+ * `null`.
15
+ */
16
+ export declare type DataValue = string | number | null;
17
+
18
+ /**
19
+ * What happened to a record, as a change feed records it.
20
+ */
21
+ export declare enum ChangeOperation {
22
+ /**
23
+ * The record was created; the change carries its complete payload.
24
+ */
25
+ Insert = "Insert",
26
+ /**
27
+ * The record was replaced; the change carries its complete new payload.
28
+ */
29
+ Update = "Update",
30
+ /**
31
+ * The record was removed; the change carries its last payload.
32
+ */
33
+ Delete = "Delete"
34
+ }
35
+
36
+ /**
37
+ * Raised by data packages for misuse of a store or an unexpected answer from
38
+ * it: an operation on a closed connection, a completed transaction used
39
+ * again, a record without the requested field, or a migration list out of
40
+ * order.
41
+ */
42
+ export declare class DataException extends Exception {
43
+ /**
44
+ * The exception's name, `"DataException"`, which the class sets itself so
45
+ * that it stays the same in a minified build.
46
+ */
47
+ public override readonly name: string;
48
+
49
+ /**
50
+ * Initializes the exception with a message and optional options carrying
51
+ * the cause.
52
+ */
53
+ public constructor(message: string, options?: ExceptionOptions);
54
+ }
55
+
56
+ /**
57
+ * The identity of one store: a name and where it lives, such as a file path or
58
+ * a server address. A provider opens a connection on a data source.
59
+ */
60
+ export declare class DataSource {
61
+ /**
62
+ * The store's name.
63
+ */
64
+ public readonly name: string;
65
+
66
+ /**
67
+ * Where the store lives, in the form its provider understands.
68
+ */
69
+ public readonly location: string;
70
+
71
+ /**
72
+ * Initializes the identity. A blank name or location throws
73
+ * `ArgumentException`.
74
+ */
75
+ public constructor(name: string, location: string);
76
+ }
77
+
78
+ /**
79
+ * One result of a query, read by field name: a row in a relational store, a
80
+ * flat document elsewhere. Reading a field the record does not have, or one
81
+ * whose value has another type, throws `DataException`.
82
+ */
83
+ export declare class DataRecord {
84
+ /**
85
+ * Initializes the record with a copy of the given field values.
86
+ */
87
+ public constructor(values: ReadonlyMap<string, DataValue>);
88
+
89
+ /**
90
+ * Returns true when the record has the field, whatever its value.
91
+ */
92
+ public hasField(name: string): boolean;
93
+
94
+ /**
95
+ * Reads a text field that is not `null`.
96
+ */
97
+ public readString(name: string): string;
98
+
99
+ /**
100
+ * Reads a text field, returning `null` for `null`.
101
+ */
102
+ public readNullableString(name: string): string | null;
103
+
104
+ /**
105
+ * Reads an integer field that is not `null`.
106
+ */
107
+ public readInteger(name: string): number;
108
+
109
+ /**
110
+ * Reads an integer field, returning `null` for `null`.
111
+ */
112
+ public readNullableInteger(name: string): number | null;
113
+
114
+ /**
115
+ * Reads a field's value as it is.
116
+ */
117
+ public readValue(name: string): DataValue;
118
+ }
119
+
120
+ /**
121
+ * One entry of a change feed: what happened to which record, with the
122
+ * record's payload at that moment, as text the application interprets.
123
+ */
124
+ export declare class Change {
125
+ /**
126
+ * Position in the feed, a positive integer the store assigns.
127
+ */
128
+ public readonly sequence: number;
129
+
130
+ /**
131
+ * The kind of record, the container's name.
132
+ */
133
+ public readonly entity: string;
134
+
135
+ /**
136
+ * The record's id.
137
+ */
138
+ public readonly entityId: string;
139
+
140
+ /**
141
+ * What happened.
142
+ */
143
+ public readonly operation: ChangeOperation;
144
+
145
+ /**
146
+ * The record's payload after the operation, or before it for a delete.
147
+ */
148
+ public readonly payload: string;
149
+
150
+ /**
151
+ * ISO 8601 timestamp of the change.
152
+ */
153
+ public readonly createdAt: string;
154
+
155
+ /**
156
+ * Initializes the change. A sequence that is not a positive integer throws
157
+ * `ArgumentOutOfRangeException`; a blank entity, id, or timestamp throws
158
+ * `ArgumentException`.
159
+ */
160
+ public constructor(sequence: number, entity: string, entityId: string, operation: ChangeOperation, payload: string, createdAt: string);
161
+ }
162
+
163
+ /**
164
+ * A named index over the fields of a container, a table or a collection,
165
+ * unique or not. Declared by migrations; rendered by the store kind.
166
+ */
167
+ export declare class Index {
168
+ /**
169
+ * The index's name.
170
+ */
171
+ public readonly name: string;
172
+
173
+ /**
174
+ * The table or collection the index belongs to.
175
+ */
176
+ public readonly container: string;
177
+
178
+ /**
179
+ * The indexed fields, in order; a copy.
180
+ */
181
+ public readonly fields: readonly string[];
182
+
183
+ /**
184
+ * True when the indexed fields identify one record.
185
+ */
186
+ public readonly isUnique: boolean;
187
+
188
+ /**
189
+ * Initializes the index. A blank name or container, or no fields, throws
190
+ * `ArgumentException`.
191
+ */
192
+ public constructor(name: string, container: string, fields: readonly string[], isUnique: boolean);
193
+ }
194
+
195
+ /**
196
+ * One step of a store's schema history, identified by fourteen digits of
197
+ * timestamp, an underscore, and a PascalCase name, such as
198
+ * `20260908120000_Initial`. Migrations apply in id order; what a migration
199
+ * does is declared by the store kind that extends this class.
200
+ */
201
+ export declare abstract class Migration {
202
+ /**
203
+ * The id that orders the migration and records it as applied.
204
+ */
205
+ public readonly id: string;
206
+
207
+ /**
208
+ * Initializes the migration. An id that does not match the pattern throws
209
+ * `ArgumentException`.
210
+ */
211
+ protected constructor(id: string);
212
+
213
+ /**
214
+ * Verifies that migrations are listed once each in ascending id order;
215
+ * otherwise throws `DataException`.
216
+ */
217
+ public static validateOrder(migrations: readonly Migration[]): void;
218
+ }
219
+
220
+ /**
221
+ * What a context needs to open its store: the provider and the data source;
222
+ * built by `DbContextOptionsBuilder`.
223
+ */
224
+ export declare class DbContextOptions<TConnection extends Connection, TMigration extends Migration> {
225
+ /**
226
+ * The provider that opens the connection and applies the migrations.
227
+ */
228
+ public readonly provider: DataProvider<TConnection, TMigration>;
229
+
230
+ /**
231
+ * The store to open.
232
+ */
233
+ public readonly dataSource: DataSource;
234
+
235
+ /**
236
+ * Initializes the options.
237
+ */
238
+ public constructor(provider: DataProvider<TConnection, TMigration>, dataSource: DataSource);
239
+ }
240
+
241
+ /**
242
+ * A unit of work on a connection: committed or rolled back exactly once.
243
+ * Disposing an incomplete transaction rolls it back. Store kinds implement
244
+ * the two core operations and add the operations that run inside it.
245
+ */
246
+ export declare abstract class Transaction implements AsyncDisposable {
247
+ /**
248
+ * True once the store successfully committed or rolled back.
249
+ */
250
+ public get isCompleted(): boolean;
251
+
252
+ /**
253
+ * True once a nested action failed: the transaction can then only roll
254
+ * back, even when its outer action swallowed the failure.
255
+ */
256
+ public get isRollbackOnly(): boolean;
257
+
258
+ /**
259
+ * Runs an action as part of this transaction, joining it: nothing is
260
+ * committed until the outermost action, the connection's, ends. A failure
261
+ * marks the transaction rollback-only and is rethrown. A completed
262
+ * transaction throws `DataException`.
263
+ */
264
+ public runInTransactionAsync<T>(action: (transaction: this) => Promise<T>): Promise<T>;
265
+
266
+ /**
267
+ * Makes the work permanent. A completed transaction throws
268
+ * `DataException`. If the store's commit fails, the transaction remains
269
+ * incomplete so disposal can attempt rollback.
270
+ */
271
+ public commitAsync(): Promise<void>;
272
+
273
+ /**
274
+ * Discards the work. A completed transaction throws `DataException`.
275
+ * Completion is recorded only after the store's rollback succeeds.
276
+ */
277
+ public rollbackAsync(): Promise<void>;
278
+
279
+ /**
280
+ * Rolls back unless already completed.
281
+ */
282
+ public [Symbol.asyncDispose](): Promise<void>;
283
+
284
+ /**
285
+ * Commits in the store.
286
+ */
287
+ protected abstract commitCoreAsync(): Promise<void>;
288
+
289
+ /**
290
+ * Rolls back in the store.
291
+ */
292
+ protected abstract rollbackCoreAsync(): Promise<void>;
293
+
294
+ /**
295
+ * Throws `DataException` when the transaction is completed.
296
+ */
297
+ protected throwIfCompleted(): void;
298
+ }
299
+
300
+ /**
301
+ * The append-only log of every mutation of a store, read in sequence order:
302
+ * the source of an application's events and of replication between machines.
303
+ * Store kinds implement the two core operations; arguments are validated
304
+ * here. Inside a transaction's action, pass the transaction, so the feed runs
305
+ * its statements in it; without one, the feed takes its turn on the
306
+ * connection.
307
+ */
308
+ export declare abstract class ChangeFeed<TTransaction extends Transaction = Transaction> {
309
+ /**
310
+ * Records a change and returns it with the sequence the store assigned. A
311
+ * blank entity or id rejects with `ArgumentException`.
312
+ */
313
+ public appendAsync(entity: string, entityId: string, operation: ChangeOperation, payload: string, transaction?: TTransaction): Promise<Change>;
314
+
315
+ /**
316
+ * Reads changes with a sequence greater than the given one, at most
317
+ * `limit` of them, one hundred by default. A negative sequence or a
318
+ * limit that is not positive rejects with `ArgumentOutOfRangeException`.
319
+ */
320
+ public readAfterAsync(sequence: number, limit?: number, transaction?: TTransaction): Promise<readonly Change[]>;
321
+
322
+ /**
323
+ * Appends in the store, in the transaction when one is given.
324
+ */
325
+ protected abstract appendCoreAsync(entity: string, entityId: string, operation: ChangeOperation, payload: string, transaction: TTransaction | undefined): Promise<Change>;
326
+
327
+ /**
328
+ * Reads from the store, in the transaction when one is given.
329
+ */
330
+ protected abstract readAfterCoreAsync(sequence: number, limit: number, transaction: TTransaction | undefined): Promise<readonly Change[]>;
331
+ }
332
+
333
+ /**
334
+ * One session on a data source. Its operations take turns: a transaction
335
+ * holds the connection from its start until it commits or rolls back, and
336
+ * an operation started meanwhile, from any caller, waits for its turn, so
337
+ * two callers never share a transaction. Store kinds add their operations,
338
+ * each taking its turn through `runExclusiveAsync`, and the same operations
339
+ * on their transaction, which run inside the turn. Opening a connection never
340
+ * waits on a network; disposal closes it.
341
+ */
342
+ export declare abstract class Connection<TTransaction extends Transaction = Transaction> implements AsyncDisposable {
343
+ /**
344
+ * The data source the connection was opened on.
345
+ */
346
+ public readonly dataSource: DataSource;
347
+
348
+ /**
349
+ * Initializes the connection for a data source.
350
+ */
351
+ protected constructor(dataSource: DataSource);
352
+
353
+ /**
354
+ * True until the connection is closed.
355
+ */
356
+ public abstract get isOpen(): boolean;
357
+
358
+ /**
359
+ * True while a transaction holds the connection.
360
+ */
361
+ public get isInTransaction(): boolean;
362
+
363
+ /**
364
+ * Runs an action inside a transaction, once the connection's earlier
365
+ * operations have ended: committed when its promise fulfills, rolled back
366
+ * when it rejects, and the action's exception is rethrown. The action
367
+ * receives the transaction; nest through its `runInTransactionAsync`. A nested
368
+ * failure rolls the transaction back, with `DataException` when the outer
369
+ * action swallowed it. A failed commit also triggers rollback. If the
370
+ * action or commit and the rollback both fail, a `SuppressedError` retains
371
+ * the original failure in `suppressed` and the rollback failure in `error`.
372
+ * A closed connection rejects with `DataException`.
373
+ *
374
+ * Never call the connection inside an action: use the transaction the
375
+ * action receives. A call on the connection waits for its turn, which
376
+ * comes only after the action ends, so it never settles.
377
+ */
378
+ public runInTransactionAsync<T>(action: (transaction: TTransaction) => Promise<T>): Promise<T>;
379
+
380
+ /**
381
+ * Closes the connection once its earlier operations have ended; a second
382
+ * call does nothing.
383
+ */
384
+ public closeAsync(): Promise<void>;
385
+
386
+ /**
387
+ * Closes the connection.
388
+ */
389
+ public [Symbol.asyncDispose](): Promise<void>;
390
+
391
+ /**
392
+ * Starts a transaction in the store.
393
+ */
394
+ protected abstract beginTransactionCoreAsync(): Promise<TTransaction>;
395
+
396
+ /**
397
+ * Closes the connection in the store.
398
+ */
399
+ protected abstract closeCoreAsync(): Promise<void>;
400
+
401
+ /**
402
+ * Runs an operation once the connection's earlier operations have ended,
403
+ * and holds the connection until it ends.
404
+ */
405
+ protected runExclusiveAsync<T>(operation: () => Promise<T>): Promise<T>;
406
+
407
+ /**
408
+ * Throws `DataException` when the connection is closed.
409
+ */
410
+ protected throwIfClosed(): void;
411
+ }
412
+
413
+ /**
414
+ * Where a store remembers which migrations have been applied. Store kinds
415
+ * implement it over their own storage.
416
+ */
417
+ export declare abstract class MigrationHistory {
418
+ /**
419
+ * Returns the applied ids in ascending order, creating the storage when
420
+ * absent.
421
+ */
422
+ public abstract getAppliedAsync(): Promise<readonly string[]>;
423
+
424
+ /**
425
+ * Records an id as applied.
426
+ */
427
+ public abstract recordAsync(id: string): Promise<void>;
428
+ }
429
+
430
+ /**
431
+ * Applies the migrations a store has not seen yet, in id order, and records
432
+ * them. Store kinds implement how one migration is
433
+ * applied and recorded, atomically where the store allows.
434
+ */
435
+ export declare abstract class Migrator<TMigration extends Migration> {
436
+ /**
437
+ * The history the migrator reads and, through `applyAsync`, writes.
438
+ */
439
+ protected readonly history: MigrationHistory;
440
+
441
+ /**
442
+ * Initializes the migrator. Migrations that repeat an id or are not in
443
+ * ascending order throw `DataException`.
444
+ */
445
+ protected constructor(migrations: readonly TMigration[], history: MigrationHistory);
446
+
447
+ /**
448
+ * Applies every pending migration and returns the ids applied by this
449
+ * call, in order.
450
+ */
451
+ public migrateAsync(): Promise<readonly string[]>;
452
+
453
+ /**
454
+ * Returns the migrations not yet recorded, in id order.
455
+ */
456
+ public getPendingMigrationsAsync(): Promise<readonly TMigration[]>;
457
+
458
+ /**
459
+ * Returns the applied ids in ascending order.
460
+ */
461
+ public getAppliedMigrationsAsync(): Promise<readonly string[]>;
462
+
463
+ /**
464
+ * Applies one migration and records it in the history, and returns true;
465
+ * returns false, applying nothing, when the history already records it,
466
+ * such as when another process applied it meanwhile.
467
+ */
468
+ protected abstract applyAsync(migration: TMigration): Promise<boolean>;
469
+ }
470
+
471
+ /**
472
+ * One kind of store, such as SQLite: opens connections on its data sources
473
+ * and creates the migrator and the change feed over them. A store kind extends it and a context receives it through its
474
+ * options.
475
+ */
476
+ export declare abstract class DataProvider<TConnection extends Connection, TMigration extends Migration> {
477
+ /**
478
+ * Opens a connection on the data source, doing no I/O a store can defer
479
+ * to the connection's first operation.
480
+ */
481
+ public abstract openConnection(dataSource: DataSource): TConnection;
482
+
483
+ /**
484
+ * Creates the migrator that applies the migrations over the connection.
485
+ */
486
+ public abstract createMigrator(connection: TConnection, migrations: readonly TMigration[]): Migrator<TMigration>;
487
+
488
+ /**
489
+ * Creates the change feed over the connection.
490
+ */
491
+ public abstract createChangeFeed(connection: TConnection): ChangeFeed;
492
+ }
493
+
494
+ /**
495
+ * Builds the options a context is constructed from. Providers add a method per store kind, such as
496
+ * `useSQLite`, beside the general `use`.
497
+ */
498
+ export declare class DbContextOptionsBuilder {
499
+ /**
500
+ * Returns options for the provider and data source.
501
+ */
502
+ public use<TConnection extends Connection, TMigration extends Migration>(
503
+ provider: DataProvider<TConnection, TMigration>,
504
+ dataSource: DataSource): DbContextOptions<TConnection, TMigration>;
505
+ }
506
+
507
+ /**
508
+ * A context's `database`: the connection it owns, the migrations it applies
509
+ * to it, and the store's change feed. Opening
510
+ * the connection and creating the migrator and the feed happen here, when
511
+ * the context is constructed.
512
+ */
513
+ export declare class DatabaseFacade<TConnection extends Connection, TMigration extends Migration> {
514
+ /**
515
+ * The connection opened on the options' data source.
516
+ */
517
+ public readonly connection: TConnection;
518
+
519
+ /**
520
+ * The change feed of the store, over the connection.
521
+ */
522
+ public readonly changeFeed: ChangeFeed;
523
+
524
+ /**
525
+ * Opens the connection through the options' provider and creates the
526
+ * migrator over it for the migrations and the change feed. Migrations out
527
+ * of order throw `DataException` before any connection opens.
528
+ */
529
+ public constructor(options: DbContextOptions<TConnection, TMigration>, migrations: readonly TMigration[]);
530
+
531
+ /**
532
+ * Applies every pending migration and returns the ids applied by this
533
+ * call, in order.
534
+ */
535
+ public migrateAsync(): Promise<readonly string[]>;
536
+
537
+ /**
538
+ * Returns the applied ids in ascending order.
539
+ */
540
+ public getAppliedMigrationsAsync(): Promise<readonly string[]>;
541
+
542
+ /**
543
+ * Returns the migrations not yet applied, in id order.
544
+ */
545
+ public getPendingMigrationsAsync(): Promise<readonly TMigration[]>;
546
+ }
547
+
548
+ /**
549
+ * The one object an application talks to for one store. Constructed from options and its migrations, it opens its
550
+ * connection and exposes it with the migrations as `database`; disposal
551
+ * closes the connection. Applications extend it with their record sets.
552
+ */
553
+ export declare abstract class DbContext<TConnection extends Connection, TMigration extends Migration> implements AsyncDisposable {
554
+ /**
555
+ * The connection and the migrations of the store.
556
+ */
557
+ public readonly database: DatabaseFacade<TConnection, TMigration>;
558
+
559
+ /**
560
+ * Opens the store the options describe with the migrations, in id order;
561
+ * migrations out of order throw `DataException`.
562
+ */
563
+ protected constructor(options: DbContextOptions<TConnection, TMigration>, migrations: readonly TMigration[]);
564
+
565
+ /**
566
+ * Closes the connection.
567
+ */
568
+ public [Symbol.asyncDispose](): Promise<void>;
569
+ }
package/api/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export { ChangeOperation } from "../enums/change-operation.js";
9
+ export { DataException } from "../exceptions/data.exception.js";
10
+ export { Change } from "../models/change.js";
11
+ export { DataRecord } from "../models/data-record.js";
12
+ export { DataSource } from "../models/data-source.js";
13
+ export { DbContextOptions } from "../models/db-context-options.js";
14
+ export { Index } from "../models/index.js";
15
+ export { Migration } from "../models/migration.js";
16
+ export { ChangeFeed } from "../services/change-feed.js";
17
+ export { Connection } from "../models/connection.js";
18
+ export { DataProvider } from "../services/data-provider.js";
19
+ export { DatabaseFacade } from "../models/database-facade.js";
20
+ export { DbContext } from "../models/db-context.js";
21
+ export { DbContextOptionsBuilder } from "../models/db-context-options-builder.js";
22
+ export { MigrationHistory } from "../services/migration-history.js";
23
+ export { Migrator } from "../services/migrator.js";
24
+ export { Transaction } from "../models/transaction.js";
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export var ChangeOperation;
9
+ (function (ChangeOperation) {
10
+ ChangeOperation["Insert"] = "Insert";
11
+ ChangeOperation["Update"] = "Update";
12
+ ChangeOperation["Delete"] = "Delete";
13
+ })(ChangeOperation || (ChangeOperation = {}));
14
+ //# sourceMappingURL=change-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-operation.js","sourceRoot":"","sources":["../../../../src/data/noldova.context.data/src/enums/change-operation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;AACnB,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Exception } from "@noldova/context.exceptions";
9
+ export class DataException extends Exception {
10
+ name = "DataException";
11
+ constructor(message, options) {
12
+ super(message, options);
13
+ }
14
+ }
15
+ //# sourceMappingURL=data.exception.js.map