@atscript/moost-db 0.1.147 → 0.1.148
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/dist/{db-space-registry-C_wft7kl.mjs → db-space-registry-Cdb0FGCn.mjs} +28 -2
- package/dist/{db-space-registry-CKR6G-hi.d.mts → db-space-registry-Cvd8s9ql.d.mts} +17 -1
- package/dist/{db-space-registry-DqKr5Zdk.cjs → db-space-registry-D5gnC_-6.cjs} +32 -0
- package/dist/{db-space-registry-CWpYwZ4R.d.cts → db-space-registry-fXB8LnGe.d.cts} +17 -1
- package/dist/index.cjs +1248 -233
- package/dist/index.d.cts +373 -48
- package/dist/index.d.mts +373 -48
- package/dist/index.mjs +1246 -233
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/package.json +16 -14
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_DB_SPACE, DEFAULT_DB_SPACE as DEFAULT_DB_SPACE$1 } from "@atscript/db";
|
|
1
|
+
import { DEFAULT_DB_SPACE, DEFAULT_DB_SPACE as DEFAULT_DB_SPACE$1, aggregateFailure } from "@atscript/db";
|
|
2
2
|
//#region src/db-space-registry.ts
|
|
3
3
|
/**
|
|
4
4
|
* Ambient registry of {@link DbSpace} instances, keyed by name.
|
|
@@ -44,5 +44,31 @@ function resolveDbSpace(name = DEFAULT_DB_SPACE) {
|
|
|
44
44
|
function clearDbSpaces() {
|
|
45
45
|
spaces.clear();
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Closes every distinct registered space (see `DbSpace.close`), then clears
|
|
49
|
+
* the registry like {@link clearDbSpaces}. Failures are collected into an
|
|
50
|
+
* `AggregateError`; every space is attempted.
|
|
51
|
+
*
|
|
52
|
+
* Not wired into `Moost.dispose()` automatically: the registry outlives app
|
|
53
|
+
* instances (the Vite dev server disposes the app on every HMR reload while the
|
|
54
|
+
* next one reuses the space). Call it from your shutdown path:
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* app.disposeOnSignals()
|
|
58
|
+
* // in any DI singleton: @MoostDispose() close() { return closeDbSpaces() }
|
|
59
|
+
* ```
|
|
60
|
+
* @since 0.1.148
|
|
61
|
+
*/
|
|
62
|
+
async function closeDbSpaces() {
|
|
63
|
+
const distinct = [...new Set(spaces.values())];
|
|
64
|
+
spaces.clear();
|
|
65
|
+
const errors = [];
|
|
66
|
+
for (const space of distinct) try {
|
|
67
|
+
await space.close();
|
|
68
|
+
} catch (error) {
|
|
69
|
+
errors.push(error);
|
|
70
|
+
}
|
|
71
|
+
if (errors.length > 0) throw aggregateFailure("closeDbSpaces failed", errors);
|
|
72
|
+
}
|
|
47
73
|
//#endregion
|
|
48
|
-
export { resolveDbSpace as i, clearDbSpaces as n,
|
|
74
|
+
export { resolveDbSpace as a, provideDbSpace as i, clearDbSpaces as n, closeDbSpaces as r, DEFAULT_DB_SPACE$1 as t };
|
|
@@ -23,5 +23,21 @@ declare function provideDbSpace(space: DbSpace, name?: string): void;
|
|
|
23
23
|
declare function resolveDbSpace(name?: string): DbSpace;
|
|
24
24
|
/** Removes all registered spaces. Intended for test teardown. */
|
|
25
25
|
declare function clearDbSpaces(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Closes every distinct registered space (see `DbSpace.close`), then clears
|
|
28
|
+
* the registry like {@link clearDbSpaces}. Failures are collected into an
|
|
29
|
+
* `AggregateError`; every space is attempted.
|
|
30
|
+
*
|
|
31
|
+
* Not wired into `Moost.dispose()` automatically: the registry outlives app
|
|
32
|
+
* instances (the Vite dev server disposes the app on every HMR reload while the
|
|
33
|
+
* next one reuses the space). Call it from your shutdown path:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* app.disposeOnSignals()
|
|
37
|
+
* // in any DI singleton: @MoostDispose() close() { return closeDbSpaces() }
|
|
38
|
+
* ```
|
|
39
|
+
* @since 0.1.148
|
|
40
|
+
*/
|
|
41
|
+
declare function closeDbSpaces(): Promise<void>;
|
|
26
42
|
//#endregion
|
|
27
|
-
export { resolveDbSpace as i, clearDbSpaces as n,
|
|
43
|
+
export { resolveDbSpace as a, provideDbSpace as i, clearDbSpaces as n, closeDbSpaces as r, DEFAULT_DB_SPACE$1 as t };
|
|
@@ -44,6 +44,32 @@ function resolveDbSpace(name = _atscript_db.DEFAULT_DB_SPACE) {
|
|
|
44
44
|
function clearDbSpaces() {
|
|
45
45
|
spaces.clear();
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Closes every distinct registered space (see `DbSpace.close`), then clears
|
|
49
|
+
* the registry like {@link clearDbSpaces}. Failures are collected into an
|
|
50
|
+
* `AggregateError`; every space is attempted.
|
|
51
|
+
*
|
|
52
|
+
* Not wired into `Moost.dispose()` automatically: the registry outlives app
|
|
53
|
+
* instances (the Vite dev server disposes the app on every HMR reload while the
|
|
54
|
+
* next one reuses the space). Call it from your shutdown path:
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* app.disposeOnSignals()
|
|
58
|
+
* // in any DI singleton: @MoostDispose() close() { return closeDbSpaces() }
|
|
59
|
+
* ```
|
|
60
|
+
* @since 0.1.148
|
|
61
|
+
*/
|
|
62
|
+
async function closeDbSpaces() {
|
|
63
|
+
const distinct = [...new Set(spaces.values())];
|
|
64
|
+
spaces.clear();
|
|
65
|
+
const errors = [];
|
|
66
|
+
for (const space of distinct) try {
|
|
67
|
+
await space.close();
|
|
68
|
+
} catch (error) {
|
|
69
|
+
errors.push(error);
|
|
70
|
+
}
|
|
71
|
+
if (errors.length > 0) throw (0, _atscript_db.aggregateFailure)("closeDbSpaces failed", errors);
|
|
72
|
+
}
|
|
47
73
|
//#endregion
|
|
48
74
|
Object.defineProperty(exports, "clearDbSpaces", {
|
|
49
75
|
enumerable: true,
|
|
@@ -51,6 +77,12 @@ Object.defineProperty(exports, "clearDbSpaces", {
|
|
|
51
77
|
return clearDbSpaces;
|
|
52
78
|
}
|
|
53
79
|
});
|
|
80
|
+
Object.defineProperty(exports, "closeDbSpaces", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function() {
|
|
83
|
+
return closeDbSpaces;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
54
86
|
Object.defineProperty(exports, "provideDbSpace", {
|
|
55
87
|
enumerable: true,
|
|
56
88
|
get: function() {
|
|
@@ -23,5 +23,21 @@ declare function provideDbSpace(space: DbSpace, name?: string): void;
|
|
|
23
23
|
declare function resolveDbSpace(name?: string): DbSpace;
|
|
24
24
|
/** Removes all registered spaces. Intended for test teardown. */
|
|
25
25
|
declare function clearDbSpaces(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Closes every distinct registered space (see `DbSpace.close`), then clears
|
|
28
|
+
* the registry like {@link clearDbSpaces}. Failures are collected into an
|
|
29
|
+
* `AggregateError`; every space is attempted.
|
|
30
|
+
*
|
|
31
|
+
* Not wired into `Moost.dispose()` automatically: the registry outlives app
|
|
32
|
+
* instances (the Vite dev server disposes the app on every HMR reload while the
|
|
33
|
+
* next one reuses the space). Call it from your shutdown path:
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* app.disposeOnSignals()
|
|
37
|
+
* // in any DI singleton: @MoostDispose() close() { return closeDbSpaces() }
|
|
38
|
+
* ```
|
|
39
|
+
* @since 0.1.148
|
|
40
|
+
*/
|
|
41
|
+
declare function closeDbSpaces(): Promise<void>;
|
|
26
42
|
//#endregion
|
|
27
|
-
export { resolveDbSpace as i, clearDbSpaces as n,
|
|
43
|
+
export { resolveDbSpace as a, provideDbSpace as i, clearDbSpaces as n, closeDbSpaces as r, DEFAULT_DB_SPACE as t };
|