@mailwoman/core 2.1.0 → 2.2.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/out/api/APIClient.d.ts +57 -0
- package/out/api/APIClient.d.ts.map +1 -0
- package/out/api/APIClient.js +108 -0
- package/out/api/APIClient.js.map +1 -0
- package/out/api/headless.d.ts +17 -0
- package/out/api/headless.d.ts.map +1 -0
- package/out/api/headless.js +18 -0
- package/out/api/headless.js.map +1 -0
- package/out/api/index.d.ts +11 -0
- package/out/api/index.d.ts.map +1 -0
- package/out/api/index.js +11 -0
- package/out/api/index.js.map +1 -0
- package/out/api/responses.d.ts +48 -0
- package/out/api/responses.d.ts.map +1 -0
- package/out/api/responses.js +68 -0
- package/out/api/responses.js.map +1 -0
- package/out/collections.d.ts +66 -0
- package/out/collections.d.ts.map +1 -0
- package/out/collections.js +97 -0
- package/out/collections.js.map +1 -0
- package/out/db/schema.d.ts +21 -0
- package/out/db/schema.d.ts.map +1 -0
- package/out/db/schema.js +16 -0
- package/out/db/schema.js.map +1 -0
- package/out/decoder/build-tree.d.ts +14 -1
- package/out/decoder/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +37 -9
- package/out/decoder/build-tree.js.map +1 -1
- package/out/decoder/proposals-to-tree.d.ts.map +1 -1
- package/out/decoder/proposals-to-tree.js +2 -0
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/serialize-xml.d.ts +22 -1
- package/out/decoder/serialize-xml.d.ts.map +1 -1
- package/out/decoder/serialize-xml.js +64 -4
- package/out/decoder/serialize-xml.js.map +1 -1
- package/out/decoder/types.d.ts +45 -0
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/types.js +6 -0
- package/out/decoder/types.js.map +1 -1
- package/out/errors/index.d.ts +9 -0
- package/out/errors/index.d.ts.map +1 -0
- package/out/errors/index.js +9 -0
- package/out/errors/index.js.map +1 -0
- package/out/errors/schema.d.ts +69 -0
- package/out/errors/schema.d.ts.map +1 -0
- package/out/errors/schema.js +102 -0
- package/out/errors/schema.js.map +1 -0
- package/out/identifiers.d.ts +18 -0
- package/out/identifiers.d.ts.map +1 -0
- package/out/identifiers.js +49 -0
- package/out/identifiers.js.map +1 -0
- package/out/index.d.ts +3 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +3 -4
- package/out/index.js.map +1 -1
- package/out/kysley/adapter.d.ts +13 -0
- package/out/kysley/adapter.d.ts.map +1 -0
- package/out/kysley/adapter.js +25 -0
- package/out/kysley/adapter.js.map +1 -0
- package/out/kysley/client.d.ts +16 -0
- package/out/kysley/client.d.ts.map +1 -0
- package/out/kysley/client.js +22 -0
- package/out/kysley/client.js.map +1 -0
- package/out/kysley/dialect-config.d.ts +27 -0
- package/out/kysley/dialect-config.d.ts.map +1 -0
- package/out/kysley/dialect-config.js +7 -0
- package/out/kysley/dialect-config.js.map +1 -0
- package/out/kysley/dialect.d.ts +39 -0
- package/out/kysley/dialect.d.ts.map +1 -0
- package/out/kysley/dialect.js +49 -0
- package/out/kysley/dialect.js.map +1 -0
- package/out/kysley/driver.d.ts +22 -0
- package/out/kysley/driver.d.ts.map +1 -0
- package/out/kysley/driver.js +114 -0
- package/out/kysley/driver.js.map +1 -0
- package/out/lifecycle/ServiceSymbol.d.ts +59 -0
- package/out/lifecycle/ServiceSymbol.d.ts.map +1 -0
- package/out/lifecycle/ServiceSymbol.js +62 -0
- package/out/lifecycle/ServiceSymbol.js.map +1 -0
- package/out/lifecycle/index.d.ts +11 -0
- package/out/lifecycle/index.d.ts.map +1 -0
- package/out/lifecycle/index.js +11 -0
- package/out/lifecycle/index.js.map +1 -0
- package/out/lifecycle/lru-cache.d.ts +22 -0
- package/out/lifecycle/lru-cache.d.ts.map +1 -0
- package/out/lifecycle/lru-cache.js +31 -0
- package/out/lifecycle/lru-cache.js.map +1 -0
- package/out/lifecycle/services.d.ts +145 -0
- package/out/lifecycle/services.d.ts.map +1 -0
- package/out/lifecycle/services.js +190 -0
- package/out/lifecycle/services.js.map +1 -0
- package/out/logging/index.d.ts +7 -0
- package/out/logging/index.d.ts.map +1 -0
- package/out/logging/index.js +7 -0
- package/out/logging/index.js.map +1 -0
- package/out/logging/shared.d.ts +60 -0
- package/out/logging/shared.d.ts.map +1 -0
- package/out/logging/shared.js +100 -0
- package/out/logging/shared.js.map +1 -0
- package/out/logging/tables.d.ts +7 -0
- package/out/logging/tables.d.ts.map +1 -0
- package/out/logging/tables.js +75 -0
- package/out/logging/tables.js.map +1 -0
- package/out/objects.d.ts +96 -0
- package/out/objects.d.ts.map +1 -0
- package/out/objects.js +96 -0
- package/out/objects.js.map +1 -0
- package/out/parser/proposal-pipeline.d.ts.map +1 -1
- package/out/parser/proposal-pipeline.js +0 -1
- package/out/parser/proposal-pipeline.js.map +1 -1
- package/out/pipeline/index.d.ts +14 -0
- package/out/pipeline/index.d.ts.map +1 -0
- package/out/pipeline/index.js +11 -0
- package/out/pipeline/index.js.map +1 -0
- package/out/pipeline/reconcile.d.ts +135 -0
- package/out/pipeline/reconcile.d.ts.map +1 -0
- package/out/pipeline/reconcile.js +355 -0
- package/out/pipeline/reconcile.js.map +1 -0
- package/out/pipeline/runtime-pipeline.d.ts +29 -0
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -0
- package/out/pipeline/runtime-pipeline.js +288 -0
- package/out/pipeline/runtime-pipeline.js.map +1 -0
- package/out/pipeline/span-logit-aggregation.d.ts +57 -0
- package/out/pipeline/span-logit-aggregation.d.ts.map +1 -0
- package/out/pipeline/span-logit-aggregation.js +105 -0
- package/out/pipeline/span-logit-aggregation.js.map +1 -0
- package/out/pipeline/types.d.ts +189 -0
- package/out/pipeline/types.d.ts.map +1 -0
- package/out/pipeline/types.js +16 -0
- package/out/pipeline/types.js.map +1 -0
- package/out/resolver/index.d.ts +9 -0
- package/out/resolver/index.d.ts.map +1 -0
- package/out/resolver/index.js +8 -0
- package/out/resolver/index.js.map +1 -0
- package/out/resolver/resolve.d.ts +21 -0
- package/out/resolver/resolve.d.ts.map +1 -0
- package/out/resolver/resolve.js +118 -0
- package/out/resolver/resolve.js.map +1 -0
- package/out/resolver/types.d.ts +118 -0
- package/out/resolver/types.d.ts.map +1 -0
- package/out/resolver/types.js +24 -0
- package/out/resolver/types.js.map +1 -0
- package/out/resources/git.d.ts +1 -1
- package/out/resources/index.d.ts +0 -1
- package/out/resources/index.d.ts.map +1 -1
- package/out/resources/index.js +0 -1
- package/out/resources/index.js.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts +0 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.js +0 -1
- package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.js +9 -6
- package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
- package/out/routing/index.d.ts +67 -0
- package/out/routing/index.d.ts.map +1 -0
- package/out/routing/index.js +114 -0
- package/out/routing/index.js.map +1 -0
- package/out/sets.d.ts +2 -0
- package/out/sets.d.ts.map +1 -0
- package/out/sets.js +2 -0
- package/out/sets.js.map +1 -0
- package/package.json +28 -2
- package/out/resources/db/index.d.ts +0 -57
- package/out/resources/db/index.d.ts.map +0 -1
- package/out/resources/db/index.js +0 -57
- package/out/resources/db/index.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { camelCase, capitalCase, snakeCase } from "change-case";
|
|
7
|
+
/**
|
|
8
|
+
* Converts a name to snake_case, unless the name is already in all caps.
|
|
9
|
+
*/
|
|
10
|
+
export function smartSnakeCase(name) {
|
|
11
|
+
const normalizedName = name
|
|
12
|
+
// Remove periods after capital letters, e.g. "U.S.A." -> "USA"
|
|
13
|
+
.replace(/([A-Z])(\.+)/g, "$1")
|
|
14
|
+
.trim();
|
|
15
|
+
if (normalizedName.toUpperCase() === normalizedName) {
|
|
16
|
+
return name
|
|
17
|
+
// Replace all non-word characters with underscores...
|
|
18
|
+
.replace(/\W{1,}/g, "_")
|
|
19
|
+
// ...and then replace all sequences of underscores with a single underscore.
|
|
20
|
+
.replace(/_{2,}/g, "_");
|
|
21
|
+
}
|
|
22
|
+
return snakeCase(normalizedName);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts a name to camelCase, unless the name is already in all caps.
|
|
26
|
+
*/
|
|
27
|
+
export function smartCamelCase(name) {
|
|
28
|
+
if (name.toUpperCase() === name) {
|
|
29
|
+
return name;
|
|
30
|
+
}
|
|
31
|
+
return camelCase(name);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Predicate to determine if a given string is uniformly cased, i.e. all uppercase or all lowercase.
|
|
35
|
+
*/
|
|
36
|
+
export function isUniformlyCased(input) {
|
|
37
|
+
return Boolean(input && (input === input.toUpperCase() || input === input.toLowerCase()));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Capitalizes a string, unless the string is uniformly cased, or an email address.
|
|
41
|
+
*/
|
|
42
|
+
export function smartCapitalCase(input) {
|
|
43
|
+
if (input.includes("@"))
|
|
44
|
+
return input;
|
|
45
|
+
if (isUniformlyCased(input))
|
|
46
|
+
return input;
|
|
47
|
+
return capitalCase(input);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=identifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../identifiers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG/D;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,IAAO;IACvD,MAAM,cAAc,GAAG,IAAI;QAC1B,+DAA+D;SAC9D,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC;SAC9B,IAAI,EAAE,CAAA;IAER,IAAI,cAAc,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;QACrD,OACC,IAAI;YACH,sDAAsD;aACrD,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;YACxB,6EAA6E;aAC5E,OAAO,CAAC,QAAQ,EAAE,GAAG,CACvB,CAAA;IACF,CAAC;IAED,OAAO,SAAS,CAAC,cAAc,CAA8C,CAAA;AAC9E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,IAAO;IACvD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,IAAiD,CAAA;IACzD,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAA8C,CAAA;AACpE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAoB;IACpD,OAAO,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAA;IACrC,IAAI,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAEzC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC"}
|
package/out/index.d.ts
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
6
|
export * from "./classification/index.js";
|
|
7
|
+
export * from "./collections.js";
|
|
7
8
|
export * from "./decoder/index.js";
|
|
8
9
|
export * from "./formatter/index.js";
|
|
10
|
+
export * from "./identifiers.js";
|
|
9
11
|
export * from "./parser/index.js";
|
|
12
|
+
export * from "./pipeline/index.js";
|
|
10
13
|
export * from "./resources/index.js";
|
|
11
14
|
export * from "./solver/index.js";
|
|
12
15
|
export * from "./tokenization/index.js";
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,2BAA2B,CAAA;AACzC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA"}
|
package/out/index.js
CHANGED
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
* @license AGPL-3.0
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
|
-
// `resources` triggers top-level await (libpostal data scan). Keep it LAST so consumers using
|
|
7
|
-
// bare `@mailwoman/core` for non-resource exports (classifiers, tokenization, decoder, …) can
|
|
8
|
-
// resolve those exports before TLA pauses the module. Re-ordering broke
|
|
9
|
-
// `class extends WordClassifier` evaluation under Vite's TLA-aware loader.
|
|
10
6
|
export * from "./classification/index.js";
|
|
7
|
+
export * from "./collections.js";
|
|
11
8
|
export * from "./decoder/index.js";
|
|
12
9
|
export * from "./formatter/index.js";
|
|
10
|
+
export * from "./identifiers.js";
|
|
13
11
|
export * from "./parser/index.js";
|
|
12
|
+
export * from "./pipeline/index.js";
|
|
14
13
|
export * from "./resources/index.js";
|
|
15
14
|
export * from "./solver/index.js";
|
|
16
15
|
export * from "./tokenization/index.js";
|
package/out/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,2BAA2B,CAAA;AACzC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { DialectAdapterBase, Kysely, type MigrationLockOptions } from "kysely";
|
|
7
|
+
export declare class SqliteAdapter extends DialectAdapterBase {
|
|
8
|
+
get supportsTransactionalDdl(): boolean;
|
|
9
|
+
get supportsReturning(): boolean;
|
|
10
|
+
acquireMigrationLock(_db: Kysely<unknown>, _opt: MigrationLockOptions): Promise<void>;
|
|
11
|
+
releaseMigrationLock(_db: Kysely<unknown>, _opt: MigrationLockOptions): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../kysley/adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAE9E,qBAAa,aAAc,SAAQ,kBAAkB;IACpD,IAAa,wBAAwB,IAAI,OAAO,CAE/C;IAED,IAAa,iBAAiB,IAAI,OAAO,CAExC;IAEc,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrF,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAKpG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { DialectAdapterBase, Kysely } from "kysely";
|
|
7
|
+
export class SqliteAdapter extends DialectAdapterBase {
|
|
8
|
+
get supportsTransactionalDdl() {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
get supportsReturning() {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
async acquireMigrationLock(_db, _opt) {
|
|
15
|
+
// SQLite only has one connection that's reserved by the migration system
|
|
16
|
+
// for the whole time between acquireMigrationLock and releaseMigrationLock.
|
|
17
|
+
// We don't need to do anything here.
|
|
18
|
+
}
|
|
19
|
+
async releaseMigrationLock(_db, _opt) {
|
|
20
|
+
// SQLite only has one connection that's reserved by the migration system
|
|
21
|
+
// for the whole time between acquireMigrationLock and releaseMigrationLock.
|
|
22
|
+
// We don't need to do anything here.
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../kysley/adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAA6B,MAAM,QAAQ,CAAA;AAE9E,MAAM,OAAO,aAAc,SAAQ,kBAAkB;IACpD,IAAa,wBAAwB;QACpC,OAAO,KAAK,CAAA;IACb,CAAC;IAED,IAAa,iBAAiB;QAC7B,OAAO,IAAI,CAAA;IACZ,CAAC;IAEQ,KAAK,CAAC,oBAAoB,CAAC,GAAoB,EAAE,IAA0B;QACnF,yEAAyE;QACzE,4EAA4E;QAC5E,qCAAqC;IACtC,CAAC;IAEQ,KAAK,CAAC,oBAAoB,CAAC,GAAoB,EAAE,IAA0B;QACnF,yEAAyE;QACzE,4EAA4E;QAC5E,qCAAqC;IACtC,CAAC;CACD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import type { Database } from "#db/schema";
|
|
7
|
+
import type { SqliteDialectConfig } from "#kysley/dialect-config";
|
|
8
|
+
import { Kysely, type KyselyConfig } from "kysely";
|
|
9
|
+
/**
|
|
10
|
+
* A Kysely client for SQLite that uses the `node:sqlite` library.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DatabaseClient extends Kysely<Database> implements Disposable {
|
|
13
|
+
constructor(dialectConfig: SqliteDialectConfig, config?: Partial<KyselyConfig>);
|
|
14
|
+
[Symbol.dispose](): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../kysley/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAA;AAElD;;GAEG;AACH,qBAAa,cAAe,SAAQ,MAAM,CAAC,QAAQ,CAAE,YAAW,UAAU;gBAC7D,aAAa,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC;IAO9E,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGxB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { SqliteDialect } from "#kysley/dialect";
|
|
7
|
+
import { Kysely } from "kysely";
|
|
8
|
+
/**
|
|
9
|
+
* A Kysely client for SQLite that uses the `node:sqlite` library.
|
|
10
|
+
*/
|
|
11
|
+
export class DatabaseClient extends Kysely {
|
|
12
|
+
constructor(dialectConfig, config) {
|
|
13
|
+
super({
|
|
14
|
+
...config,
|
|
15
|
+
dialect: new SqliteDialect(dialectConfig),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
[Symbol.dispose]() {
|
|
19
|
+
this.destroy();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../kysley/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,MAAM,EAAqB,MAAM,QAAQ,CAAA;AAElD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAgB;IACnD,YAAY,aAAkC,EAAE,MAA8B;QAC7E,KAAK,CAAC;YACL,GAAG,MAAM;YACT,OAAO,EAAE,IAAI,aAAa,CAAC,aAAa,CAAC;SACzC,CAAC,CAAA;IACH,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;CACD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import type { DatabaseConnection } from "kysely";
|
|
7
|
+
import type { DatabaseSync } from "node:sqlite";
|
|
8
|
+
/**
|
|
9
|
+
* Config for the SQLite dialect.
|
|
10
|
+
*/
|
|
11
|
+
export interface SqliteDialectConfig {
|
|
12
|
+
/**
|
|
13
|
+
* A node:sqlite DatabaseSync instance or a function that returns one.
|
|
14
|
+
*
|
|
15
|
+
* If a function is provided, it's called once when the first query is executed.
|
|
16
|
+
*
|
|
17
|
+
* https://nodejs.org/api/sqlite.html#class-databasesync
|
|
18
|
+
*/
|
|
19
|
+
database: InstanceType<typeof DatabaseSync> | (() => Promise<InstanceType<typeof DatabaseSync>>);
|
|
20
|
+
/**
|
|
21
|
+
* Called once when the first query is executed.
|
|
22
|
+
*
|
|
23
|
+
* This is a Kysely specific feature and does not come from the `node:sqlite` module.
|
|
24
|
+
*/
|
|
25
|
+
onCreateConnection?: (connection: DatabaseConnection) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=dialect-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect-config.d.ts","sourceRoot":"","sources":["../../kysley/dialect-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;OAMG;IACH,QAAQ,EAAE,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAA;IAEhG;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect-config.js","sourceRoot":"","sources":["../../kysley/dialect-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { type DatabaseIntrospector, type Dialect, type DialectAdapter, type Driver, type Kysely, type QueryCompiler } from "kysely";
|
|
7
|
+
import type { SqliteDialectConfig } from "#kysley/dialect-config";
|
|
8
|
+
/**
|
|
9
|
+
* SQLite dialect that uses the [`node:sqlite`](https://nodejs.org/api/sqlite.html) library.
|
|
10
|
+
*
|
|
11
|
+
* The constructor takes an instance of {@link SqliteDialectConfig}.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { DatabaseSync } from 'node:sqlite'
|
|
15
|
+
*
|
|
16
|
+
* new SqliteDialect({
|
|
17
|
+
* database: new DatabaseSync("db.sqlite")
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* If you want the pool to only be created once it's first used, `database` can be a function:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { DatabaseSync } from 'node:sqlite'
|
|
25
|
+
*
|
|
26
|
+
* new SqliteDialect({
|
|
27
|
+
* database: async () => new DatabaseSync("db.sqlite")
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class SqliteDialect implements Dialect {
|
|
32
|
+
protected config: SqliteDialectConfig;
|
|
33
|
+
constructor(config: SqliteDialectConfig);
|
|
34
|
+
createDriver(): Driver;
|
|
35
|
+
createQueryCompiler(): QueryCompiler;
|
|
36
|
+
createAdapter(): DialectAdapter;
|
|
37
|
+
createIntrospector(db: Kysely<unknown>): DatabaseIntrospector;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=dialect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../../kysley/dialect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAIN,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAGjE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAc,YAAW,OAAO;IAC5C,SAAS,CAAC,MAAM,EAAE,mBAAmB,CAAA;gBAEzB,MAAM,EAAE,mBAAmB;IAIvC,YAAY,IAAI,MAAM;IAItB,mBAAmB,IAAI,aAAa;IAIpC,aAAa,IAAI,cAAc;IAI/B,kBAAkB,CAAC,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,oBAAoB;CAG7D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { SqliteAdapter, SqliteIntrospector, SqliteQueryCompiler, } from "kysely";
|
|
7
|
+
import { SqliteDriver } from "#kysley/driver";
|
|
8
|
+
/**
|
|
9
|
+
* SQLite dialect that uses the [`node:sqlite`](https://nodejs.org/api/sqlite.html) library.
|
|
10
|
+
*
|
|
11
|
+
* The constructor takes an instance of {@link SqliteDialectConfig}.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { DatabaseSync } from 'node:sqlite'
|
|
15
|
+
*
|
|
16
|
+
* new SqliteDialect({
|
|
17
|
+
* database: new DatabaseSync("db.sqlite")
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* If you want the pool to only be created once it's first used, `database` can be a function:
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { DatabaseSync } from 'node:sqlite'
|
|
25
|
+
*
|
|
26
|
+
* new SqliteDialect({
|
|
27
|
+
* database: async () => new DatabaseSync("db.sqlite")
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class SqliteDialect {
|
|
32
|
+
config;
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this.config = Object.freeze({ ...config });
|
|
35
|
+
}
|
|
36
|
+
createDriver() {
|
|
37
|
+
return new SqliteDriver(this.config);
|
|
38
|
+
}
|
|
39
|
+
createQueryCompiler() {
|
|
40
|
+
return new SqliteQueryCompiler();
|
|
41
|
+
}
|
|
42
|
+
createAdapter() {
|
|
43
|
+
return new SqliteAdapter();
|
|
44
|
+
}
|
|
45
|
+
createIntrospector(db) {
|
|
46
|
+
return new SqliteIntrospector(db);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dialect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialect.js","sourceRoot":"","sources":["../../kysley/dialect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GAOnB,MAAM,QAAQ,CAAA;AAGf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAO,aAAa;IACf,MAAM,CAAqB;IAErC,YAAY,MAA2B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,YAAY;QACX,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACrC,CAAC;IAED,mBAAmB;QAClB,OAAO,IAAI,mBAAmB,EAAE,CAAA;IACjC,CAAC;IAED,aAAa;QACZ,OAAO,IAAI,aAAa,EAAE,CAAA;IAC3B,CAAC;IAED,kBAAkB,CAAC,EAAmB;QACrC,OAAO,IAAI,kBAAkB,CAAC,EAAE,CAAC,CAAA;IAClC,CAAC;CACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { type DatabaseConnection, type Driver, type QueryCompiler } from "kysely";
|
|
7
|
+
import type { SqliteDialectConfig } from "#kysley/dialect-config";
|
|
8
|
+
export declare class SqliteDriver implements Driver {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(config: SqliteDialectConfig);
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
acquireConnection(): Promise<DatabaseConnection>;
|
|
13
|
+
beginTransaction(connection: DatabaseConnection): Promise<void>;
|
|
14
|
+
commitTransaction(connection: DatabaseConnection): Promise<void>;
|
|
15
|
+
rollbackTransaction(connection: DatabaseConnection): Promise<void>;
|
|
16
|
+
savepoint(connection: DatabaseConnection, savepointName: string, compileQuery: QueryCompiler["compileQuery"]): Promise<void>;
|
|
17
|
+
rollbackToSavepoint(connection: DatabaseConnection, savepointName: string, compileQuery: QueryCompiler["compileQuery"]): Promise<void>;
|
|
18
|
+
releaseSavepoint(connection: DatabaseConnection, savepointName: string, compileQuery: QueryCompiler["compileQuery"]): Promise<void>;
|
|
19
|
+
releaseConnection(): Promise<void>;
|
|
20
|
+
destroy(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot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|
6
|
+
import { CompiledQuery, createQueryId, IdentifierNode, RawNode, SelectQueryNode, } from "kysely";
|
|
7
|
+
class ConnectionMutex {
|
|
8
|
+
#promise;
|
|
9
|
+
#resolve;
|
|
10
|
+
async lock() {
|
|
11
|
+
while (this.#promise) {
|
|
12
|
+
await this.#promise;
|
|
13
|
+
}
|
|
14
|
+
this.#promise = new Promise((resolve) => {
|
|
15
|
+
this.#resolve = resolve;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
unlock() {
|
|
19
|
+
const resolve = this.#resolve;
|
|
20
|
+
this.#promise = undefined;
|
|
21
|
+
this.#resolve = undefined;
|
|
22
|
+
resolve?.();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class SqliteDriver {
|
|
26
|
+
#config;
|
|
27
|
+
#connectionMutex = new ConnectionMutex();
|
|
28
|
+
#db;
|
|
29
|
+
#connection;
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this.#config = Object.freeze({ ...config });
|
|
32
|
+
}
|
|
33
|
+
async init() {
|
|
34
|
+
const db = typeof this.#config.database === "function" ? await this.#config.database() : this.#config.database;
|
|
35
|
+
this.#db = db;
|
|
36
|
+
this.#connection = new SqliteConnection(db);
|
|
37
|
+
if (this.#config.onCreateConnection) {
|
|
38
|
+
await this.#config.onCreateConnection(this.#connection);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async acquireConnection() {
|
|
42
|
+
// SQLite only has one single connection. We use a mutex here to wait
|
|
43
|
+
// until the single connection has been released.
|
|
44
|
+
await this.#connectionMutex.lock();
|
|
45
|
+
// biome-ignore lint/style/noNonNullAssertion: :shrug:
|
|
46
|
+
return this.#connection;
|
|
47
|
+
}
|
|
48
|
+
async beginTransaction(connection) {
|
|
49
|
+
await connection.executeQuery(CompiledQuery.raw("begin"));
|
|
50
|
+
}
|
|
51
|
+
async commitTransaction(connection) {
|
|
52
|
+
await connection.executeQuery(CompiledQuery.raw("commit"));
|
|
53
|
+
}
|
|
54
|
+
async rollbackTransaction(connection) {
|
|
55
|
+
await connection.executeQuery(CompiledQuery.raw("rollback"));
|
|
56
|
+
}
|
|
57
|
+
async savepoint(connection, savepointName, compileQuery) {
|
|
58
|
+
await connection.executeQuery(compileQuery(parseSavepointCommand("savepoint", savepointName), createQueryId()));
|
|
59
|
+
}
|
|
60
|
+
async rollbackToSavepoint(connection, savepointName, compileQuery) {
|
|
61
|
+
await connection.executeQuery(compileQuery(parseSavepointCommand("rollback to", savepointName), createQueryId()));
|
|
62
|
+
}
|
|
63
|
+
async releaseSavepoint(connection, savepointName, compileQuery) {
|
|
64
|
+
await connection.executeQuery(compileQuery(parseSavepointCommand("release", savepointName), createQueryId()));
|
|
65
|
+
}
|
|
66
|
+
async releaseConnection() {
|
|
67
|
+
this.#connectionMutex.unlock();
|
|
68
|
+
}
|
|
69
|
+
async destroy() {
|
|
70
|
+
this.#db?.close();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
class SqliteConnection {
|
|
74
|
+
#db;
|
|
75
|
+
constructor(db) {
|
|
76
|
+
this.#db = db;
|
|
77
|
+
}
|
|
78
|
+
executeQuery(compiledQuery) {
|
|
79
|
+
const { sql, parameters } = compiledQuery;
|
|
80
|
+
const stmt = this.#db.prepare(sql);
|
|
81
|
+
const args = Array.isArray(parameters) ? parameters : [];
|
|
82
|
+
if (stmt.columns().length) {
|
|
83
|
+
const rows = stmt.all(...args);
|
|
84
|
+
return Promise.resolve({ rows });
|
|
85
|
+
}
|
|
86
|
+
const result = stmt.run(...args);
|
|
87
|
+
return Promise.resolve({
|
|
88
|
+
numAffectedRows: BigInt(result.changes),
|
|
89
|
+
insertId: BigInt(result.lastInsertRowid),
|
|
90
|
+
rows: [],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async *streamQuery(compiledQuery, _chunkSize) {
|
|
94
|
+
const { sql, parameters, query } = compiledQuery;
|
|
95
|
+
const stmt = this.#db.prepare(sql);
|
|
96
|
+
const args = Array.isArray(parameters) ? parameters : [];
|
|
97
|
+
if (!SelectQueryNode.is(query)) {
|
|
98
|
+
throw new Error("Sqlite driver only supports streaming of select queries");
|
|
99
|
+
}
|
|
100
|
+
const iter = stmt.iterate(...args);
|
|
101
|
+
for (const row of iter) {
|
|
102
|
+
yield {
|
|
103
|
+
rows: [row],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function parseSavepointCommand(command, savepointName) {
|
|
109
|
+
return RawNode.createWithChildren([
|
|
110
|
+
RawNode.createWithSql(`${command} `),
|
|
111
|
+
IdentifierNode.create(savepointName), // ensures savepointName gets sanitized
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../kysley/driver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,aAAa,EACb,aAAa,EAGb,cAAc,EAGd,OAAO,EACP,eAAe,GACf,MAAM,QAAQ,CAAA;AAKf,MAAM,eAAe;IACpB,QAAQ,CAAgB;IACxB,QAAQ,CAAa;IAErB,KAAK,CAAC,IAAI;QACT,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,QAAQ,CAAA;QACpB,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACvC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACxB,CAAC,CAAC,CAAA;IACH,CAAC;IAED,MAAM;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAA;QAE7B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;QACzB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;QAEzB,OAAO,EAAE,EAAE,CAAA;IACZ,CAAC;CACD;AAED,MAAM,OAAO,YAAY;IACf,OAAO,CAAqB;IAC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AG,OAAO,GAAG,CAAC;QACpC,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,uCAAuC;KAC7E,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Supplemental interface for objects which can be further initialized asynchronously.
|
|
8
|
+
*/
|
|
9
|
+
export interface AsyncInitializable extends AsyncDisposable {
|
|
10
|
+
/**
|
|
11
|
+
* A method which can be called to asynchronously construct the object.
|
|
12
|
+
*/
|
|
13
|
+
[ServiceSymbol.asyncInit](...args: any[]): Promise<this>;
|
|
14
|
+
/**
|
|
15
|
+
* Alias for the `AsyncInitSymbol` method.
|
|
16
|
+
*/
|
|
17
|
+
ready?(...args: any[]): Promise<this>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type definition for a class which implements the AsyncInitializable interface.
|
|
21
|
+
*/
|
|
22
|
+
export type AsyncInitializableConstructor<T> = T extends new (...args: any[]) => AsyncInitializable ? new (...args: ConstructorParameters<T>) => T : never;
|
|
23
|
+
/**
|
|
24
|
+
* Symbol extensions associated with a service lifecycle.
|
|
25
|
+
*
|
|
26
|
+
* @singleton
|
|
27
|
+
* @static
|
|
28
|
+
*/
|
|
29
|
+
export declare class ServiceSymbol {
|
|
30
|
+
private constructor();
|
|
31
|
+
/**
|
|
32
|
+
* Global symbol for the AsyncConstructable interface.
|
|
33
|
+
*/
|
|
34
|
+
static readonly asyncInit: unique symbol;
|
|
35
|
+
/**
|
|
36
|
+
* Global symbol to mark an object as disposed.
|
|
37
|
+
*/
|
|
38
|
+
static readonly asyncDisposed: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* Mark an object as disposed.
|
|
41
|
+
*/
|
|
42
|
+
static markAsDisposed(disposable: AsyncDisposable): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Type-predicate to determine if an object has been disposed.
|
|
45
|
+
*/
|
|
46
|
+
static isDisposed(disposable: AsyncDisposable): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Type-predicate to determine if a given input is an object which implements the
|
|
49
|
+
* `AsyncInitializable` interface.
|
|
50
|
+
*/
|
|
51
|
+
static isAsyncInitializable(input: AsyncDisposable): input is AsyncInitializable;
|
|
52
|
+
/**
|
|
53
|
+
* Type-predicate to determine if a given input is an object which implements the
|
|
54
|
+
* `AsyncDisposable` interface.
|
|
55
|
+
*/
|
|
56
|
+
static isAsyncDisposable<T>(input: T): input is T & AsyncDisposable;
|
|
57
|
+
static toString(): string;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ServiceSymbol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceSymbol.d.ts","sourceRoot":"","sources":["../../lifecycle/ServiceSymbol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAC1D;;OAEG;IACH,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD;;OAEG;IACH,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED;;GAEG;AACH,MAAM,MAAM,6BAA6B,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,kBAAkB,GAChG,KAAK,GAAG,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAC,GAC5C,KAAK,CAAA;AAER;;;;;GAKG;AACH,qBAAa,aAAa;IACzB,OAAO;IAIP;;OAEG;IACH,gBAAuB,SAAS,EAAE,OAAO,MAAM,CAA0B;IAEzE;;OAEG;IACH,gBAAuB,aAAa,EAAE,OAAO,MAAM,CAA8B;IAEjF;;OAEG;WACW,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO;IAWlE;;OAEG;WACW,UAAU,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO;IAI9D;;;OAGG;WACW,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,KAAK,IAAI,kBAAkB;IAIvF;;;OAGG;WACW,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,eAAe;WAM5D,QAAQ;CAGtB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { ConsoleLogger } from "../logging/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Symbol extensions associated with a service lifecycle.
|
|
9
|
+
*
|
|
10
|
+
* @singleton
|
|
11
|
+
* @static
|
|
12
|
+
*/
|
|
13
|
+
export class ServiceSymbol {
|
|
14
|
+
constructor() {
|
|
15
|
+
throw new TypeError("Cannot instantiate static class `ServiceSymbol`.");
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Global symbol for the AsyncConstructable interface.
|
|
19
|
+
*/
|
|
20
|
+
static asyncInit = Symbol.for("asyncInit");
|
|
21
|
+
/**
|
|
22
|
+
* Global symbol to mark an object as disposed.
|
|
23
|
+
*/
|
|
24
|
+
static asyncDisposed = Symbol.for("asyncDisposed");
|
|
25
|
+
/**
|
|
26
|
+
* Mark an object as disposed.
|
|
27
|
+
*/
|
|
28
|
+
static markAsDisposed(disposable) {
|
|
29
|
+
if (ServiceSymbol.asyncDisposed in disposable) {
|
|
30
|
+
ConsoleLogger.warn(`[${disposable}] Already disposed!`);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
Object.assign(disposable, { AsyncDisposedSymbol: true });
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type-predicate to determine if an object has been disposed.
|
|
38
|
+
*/
|
|
39
|
+
static isDisposed(disposable) {
|
|
40
|
+
return ServiceSymbol.asyncDisposed in disposable;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Type-predicate to determine if a given input is an object which implements the
|
|
44
|
+
* `AsyncInitializable` interface.
|
|
45
|
+
*/
|
|
46
|
+
static isAsyncInitializable(input) {
|
|
47
|
+
return ServiceSymbol.asyncInit in input && typeof input[ServiceSymbol.asyncInit] === "function";
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Type-predicate to determine if a given input is an object which implements the
|
|
51
|
+
* `AsyncDisposable` interface.
|
|
52
|
+
*/
|
|
53
|
+
static isAsyncDisposable(input) {
|
|
54
|
+
if (!input || typeof input !== "object")
|
|
55
|
+
return false;
|
|
56
|
+
return Object.hasOwn(input, Symbol.asyncDispose);
|
|
57
|
+
}
|
|
58
|
+
static toString() {
|
|
59
|
+
return "ServiceSymbol";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=ServiceSymbol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceSymbol.js","sourceRoot":"","sources":["../../lifecycle/ServiceSymbol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AA0BnD;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACzB;QACC,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAA;IACxE,CAAC;IAED;;OAEG;IACI,MAAM,CAAU,SAAS,GAAkB,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAEzE;;OAEG;IACI,MAAM,CAAU,aAAa,GAAkB,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAEjF;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,UAA2B;QACvD,IAAI,aAAa,CAAC,aAAa,IAAI,UAAU,EAAE,CAAC;YAC/C,aAAa,CAAC,IAAI,CAAC,IAAI,UAAU,qBAAqB,CAAC,CAAA;YACvD,OAAO,KAAK,CAAA;QACb,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAA;QAExD,OAAO,IAAI,CAAA;IACZ,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,UAAU,CAAC,UAA2B;QACnD,OAAO,aAAa,CAAC,aAAa,IAAI,UAAU,CAAA;IACjD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,KAAsB;QACxD,OAAO,aAAa,CAAC,SAAS,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,UAAU,CAAA;IAChG,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,iBAAiB,CAAI,KAAQ;QAC1C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QAErD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;IACjD,CAAC;IAEM,MAAM,CAAC,QAAQ;QACrB,OAAO,eAAe,CAAA;IACvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Lifecycle utilities.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./lru-cache.js";
|
|
9
|
+
export * from "./services.js";
|
|
10
|
+
export * from "./ServiceSymbol.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lifecycle/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Lifecycle utilities.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./lru-cache.js";
|
|
9
|
+
export * from "./services.js";
|
|
10
|
+
export * from "./ServiceSymbol.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|