@tulipes/mongoose 0.1.0 → 0.2.0-rc.1
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 +23 -0
- package/dist/database.d.ts +10 -12
- package/dist/database.js +1 -33
- package/dist/database.js.map +1 -1
- package/dist/index.d.ts +31 -4
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model-store.d.ts +9 -1
- package/dist/model-store.js +2 -1
- package/dist/model-store.js.map +1 -1
- package/dist/provider.js +2 -3
- package/dist/provider.js.map +1 -1
- package/dist/settings-provider.d.ts +12 -0
- package/dist/settings-provider.js +59 -0
- package/dist/settings-provider.js.map +1 -0
- package/dist/settings-store.d.ts +50 -0
- package/dist/settings-store.js +126 -0
- package/dist/settings-store.js.map +1 -0
- package/package.json +11 -14
package/README.md
CHANGED
|
@@ -69,3 +69,26 @@ ctx.models.connection; // the boot's own mongo
|
|
|
69
69
|
requires core `^0.10.0-rc.1`, the candidate that introduced the provider seam;
|
|
70
70
|
install both with `@next`. See core's
|
|
71
71
|
[MIGRATING.md](https://github.com/kemora13conf/bp-backend-express/blob/v0.10.0-rc.1/packages/core/MIGRATING.md#0100-rc1--declare-the-models-provider).
|
|
72
|
+
|
|
73
|
+
## The settings store
|
|
74
|
+
|
|
75
|
+
The same package keeps an app's settings in MongoDB. Select it in the app's
|
|
76
|
+
root `package.json`:
|
|
77
|
+
|
|
78
|
+
```jsonc
|
|
79
|
+
{ "tulipes": { "providers": { "models": "@tulipes/mongoose", "settings": "@tulipes/mongoose/settings" } } }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Every namespace a `module.config.ts` declares is one document in the
|
|
83
|
+
`settings` collection — `{ _id: "<module>", values, version, updated_at,
|
|
84
|
+
updated_by }` — seeded with the schema's defaults on first boot. A write
|
|
85
|
+
through `ctx.settings.set()` is a `findOneAndUpdate` on `{ _id, version }`:
|
|
86
|
+
a stale version is refused with the current document, so two operators
|
|
87
|
+
cannot overwrite each other, and the document it replaced goes to
|
|
88
|
+
`settings_history`. Other processes see the change through a change stream
|
|
89
|
+
when the connection is to a replica set and by polling (every 2s) otherwise;
|
|
90
|
+
core validates every incoming document against the module's schema before
|
|
91
|
+
applying it. The store shares the models provider's connection when both
|
|
92
|
+
are this package, and opens its own from `MONGO_URI` when the app keeps no
|
|
93
|
+
mongoose models. Without the declaration core keeps settings in
|
|
94
|
+
`config/settings.<APP_ENV>.json`.
|
package/dist/database.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema, type Connection } from "mongoose";
|
|
2
|
-
import { type Ctx
|
|
2
|
+
import { type Ctx } from "@tulipes/core/boot";
|
|
3
3
|
import type { BootReport } from "@tulipes/core/errors";
|
|
4
4
|
import type { ModuleFiles } from "@tulipes/core/modules";
|
|
5
5
|
/**
|
|
@@ -12,24 +12,22 @@ export interface ModelDef {
|
|
|
12
12
|
/** Override mongoose's automatic collection naming when needed. */
|
|
13
13
|
collection?: string;
|
|
14
14
|
}
|
|
15
|
-
/** Default export of `bootstrap/*.bootstrap.ts` — post-DB, pre-server init. */
|
|
16
|
-
export type BootstrapFn = (ctx: DatabaseCtx) => void | Promise<void>;
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* Kept for apps written against 0.10, where bootstrap was this provider's.
|
|
17
|
+
* Since 0.11 core runs bootstrap files in every mode and the function may
|
|
18
|
+
* return its cleanup; prefer `BootstrapFn` from `@tulipes/core/boot`.
|
|
19
|
+
*/
|
|
20
|
+
export type { BootstrapFn } from "@tulipes/core/boot";
|
|
21
|
+
/**
|
|
22
|
+
* Boot phase 5, run by the provider below: connect and register every model
|
|
23
|
+
* in load order. Bootstrap tasks (indexes, seed rows) are core's phase 9,
|
|
24
|
+
* run against the loaded settings and ACL.
|
|
21
25
|
*
|
|
22
26
|
* Reached only when the app declared this provider, so a missing connection
|
|
23
27
|
* string is a contradiction the boot must refuse — an app without a database
|
|
24
28
|
* simply declares no provider.
|
|
25
29
|
*/
|
|
26
30
|
export interface InitDatabaseOptions {
|
|
27
|
-
/**
|
|
28
|
-
* Bootstrap tasks seed and ensure indexes for a process about to serve.
|
|
29
|
-
* A one-shot script skips them: they are somebody else's startup work,
|
|
30
|
-
* and running them on every `ls`-style script is wasted writes.
|
|
31
|
-
*/
|
|
32
|
-
runBootstrap?: boolean;
|
|
33
31
|
/** Register ownership before connecting or compiling models can fail. */
|
|
34
32
|
onConnection?: (connection: Connection) => void;
|
|
35
33
|
}
|
package/dist/database.js
CHANGED
|
@@ -10,7 +10,7 @@ export async function initDatabase(explored, ctx, report, options = {}) {
|
|
|
10
10
|
if (!uri) {
|
|
11
11
|
report.add({
|
|
12
12
|
scope: "providers",
|
|
13
|
-
message: `provider "mongoose" is selected but "${MONGO_URI}" is not declared/set — declare it in a sys module's
|
|
13
|
+
message: `provider "mongoose" is selected but "${MONGO_URI}" is not declared/set — declare it in a sys module's package.json tulipes.env and set it`,
|
|
14
14
|
});
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
@@ -34,11 +34,6 @@ export async function initDatabase(explored, ctx, report, options = {}) {
|
|
|
34
34
|
const store = new ModelStore(connection);
|
|
35
35
|
ctx.models = store;
|
|
36
36
|
await registerModels(explored, connection, store, report);
|
|
37
|
-
// Bootstrap tasks only make sense against a fully-populated model store,
|
|
38
|
-
// and only when nothing above them failed.
|
|
39
|
-
if ((options.runBootstrap ?? true) && report.issues.length === 0) {
|
|
40
|
-
await runBootstrapTasks(explored, ctx, report);
|
|
41
|
-
}
|
|
42
37
|
return connection;
|
|
43
38
|
}
|
|
44
39
|
async function registerModels(explored, connection, store, report) {
|
|
@@ -71,31 +66,4 @@ async function registerModels(explored, connection, store, report) {
|
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
|
-
async function runBootstrapTasks(explored, ctx, report) {
|
|
75
|
-
for (const { module, bootstrapFiles } of explored) {
|
|
76
|
-
for (const file of bootstrapFiles) {
|
|
77
|
-
const exported = await importFile(file, "boot", module.name, report);
|
|
78
|
-
if (!exported)
|
|
79
|
-
continue;
|
|
80
|
-
if (typeof exported.default !== "function") {
|
|
81
|
-
report.add({
|
|
82
|
-
scope: "boot",
|
|
83
|
-
module: module.name,
|
|
84
|
-
message: `${file} must default-export a bootstrap function (ctx) => void`,
|
|
85
|
-
});
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
await exported.default(ctx);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
report.add({
|
|
93
|
-
scope: "boot",
|
|
94
|
-
module: module.name,
|
|
95
|
-
message: `bootstrap task ${file} threw: ${error.message}`,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
69
|
//# sourceMappingURL=database.js.map
|
package/dist/database.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAmB,MAAM,UAAU,CAAC;AAErE,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAmB,MAAM,UAAU,CAAC;AAErE,OAAO,EAAE,UAAU,EAAY,MAAM,oBAAoB,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAoB9C,wEAAwE;AACxE,MAAM,SAAS,GAAG,WAAW,CAAC;AAgB9B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgC,EAChC,GAAQ,EACR,MAAkB,EAClB,OAAO,GAAwB,EAAE;IAEjC,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC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AI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAClC,CAAC;YACF,IAAI,CAAC,QAAQ;gBAAE,SAAS;YAExB,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAwC,CAAC;YAC9D,IACE,OAAO,GAAG,EAAE,IAAI,KAAK,QAAQ;gBAC7B,CAAC,CAAC,GAAG,CAAC,MAAM,YAAY,MAAM,CAAC,EAC/B,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC;oBACT,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,MAAM,CAAC,IAAI;oBACnB,OAAO,EAAE,GAAG,IAAI,oDAAoD;iBACrE,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YAED,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,KAAK,EAAE,CAAC;gBACV,MAAM,CAAC,GAAG,CAAC;oBACT,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,MAAM,CAAC,IAAI;oBACnB,OAAO,EAAE,UAAU,GAAG,CAAC,IAAI,sCAAsC,KAAK,GAAG;iBAC1E,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;YACrE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAc,EAAE,KAAc,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
import type { HydratedDocument, InferSchemaType, Model, ObtainSchemaGeneric, Schema } from "mongoose";
|
|
2
|
+
export { initDatabase, type BootstrapFn, type ModelDef } from "./database.ts";
|
|
3
|
+
export { ModelStore } from "./model-store.ts";
|
|
4
|
+
export { MongoSettingsStore, type MongoSettingsStoreOptions, type SettingsDocument, type SettingsHistoryDocument } from "./settings-store.ts";
|
|
5
|
+
export { provider as settingsProvider } from "./settings-provider.ts";
|
|
6
|
+
export { provider } from "./provider.ts";
|
|
7
|
+
export { provider as default } from "./provider.ts";
|
|
8
|
+
/**
|
|
9
|
+
* Augmentation target for the generated `types/tulipes.d.ts` (`tulipes sync`):
|
|
10
|
+
* codegen adds one property per `models/*.model.ts`, keyed by the model's
|
|
11
|
+
* name and typed as the file's default export, so `ctx.models.get("User")`
|
|
12
|
+
* is typed from the schema the model file declares and a wrong name does
|
|
13
|
+
* not compile. Declared in THIS module (not re-exported) because TypeScript
|
|
14
|
+
* module augmentation only merges with the module that declares the interface.
|
|
15
|
+
*/
|
|
16
|
+
export interface KnownModels {
|
|
17
|
+
}
|
|
18
|
+
/** Every model name `tulipes sync` found; `never` until it has run. */
|
|
19
|
+
export type KnownModelName = keyof KnownModels & string;
|
|
20
|
+
/**
|
|
21
|
+
* The model mongoose compiles from a schema — the same type `model(name,
|
|
22
|
+
* schema)` returns, with the schema's methods, statics, virtuals and query
|
|
23
|
+
* helpers carried over.
|
|
24
|
+
*/
|
|
25
|
+
export type ModelOf<TSchema extends Schema> = Model<InferSchemaType<TSchema>, ObtainSchemaGeneric<TSchema, "TQueryHelpers">, ObtainSchemaGeneric<TSchema, "TInstanceMethods">, ObtainSchemaGeneric<TSchema, "TVirtuals">, HydratedDocument<InferSchemaType<TSchema>, ObtainSchemaGeneric<TSchema, "TVirtuals"> & ObtainSchemaGeneric<TSchema, "TInstanceMethods">, ObtainSchemaGeneric<TSchema, "TQueryHelpers">, ObtainSchemaGeneric<TSchema, "TVirtuals">, ObtainSchemaGeneric<TSchema, "TSchemaOptions">>, TSchema> & ObtainSchemaGeneric<TSchema, "TStaticMethods">;
|
|
26
|
+
/** The model a `models/*.model.ts` default export compiles to. */
|
|
27
|
+
export type DefinedModel<Def> = Def extends {
|
|
28
|
+
schema: infer S extends Schema;
|
|
29
|
+
} ? ModelOf<S> : Model<unknown>;
|
|
30
|
+
/** What `ctx.models.get(name)` returns for a known name. */
|
|
31
|
+
export type KnownModel<N extends KnownModelName> = DefinedModel<KnownModels[N]>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { initDatabase } from "./database.js";
|
|
2
2
|
export { ModelStore } from "./model-store.js";
|
|
3
|
+
export { MongoSettingsStore } from "./settings-store.js";
|
|
4
|
+
export { provider as settingsProvider } from "./settings-provider.js";
|
|
3
5
|
export { provider } from "./provider.js";
|
|
4
6
|
export { provider as default } from "./provider.js";
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAmC,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAuF,MAAM,qBAAqB,CAAC;AAC9I,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/model-store.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Connection, Model } from "mongoose";
|
|
2
2
|
import type { ModelsCapability } from "@tulipes/core/boot";
|
|
3
|
+
import type { KnownModel, KnownModelName } from "./index.ts";
|
|
3
4
|
/**
|
|
4
5
|
* What `ctx.models` is once this provider is in the compilation. Core's
|
|
5
6
|
* ModelsCapability is empty; an app that imports anything from this package
|
|
@@ -10,6 +11,12 @@ declare module "@tulipes/core/boot" {
|
|
|
10
11
|
has(name: string): boolean;
|
|
11
12
|
ownerOf(name: string): string | undefined;
|
|
12
13
|
names(): string[];
|
|
14
|
+
/**
|
|
15
|
+
* A name `tulipes sync` found in a model file is typed from that file's
|
|
16
|
+
* schema; any other string — a dynamic name, or an app that has not run
|
|
17
|
+
* sync — gets the caller-side generic, which the store cannot verify.
|
|
18
|
+
*/
|
|
19
|
+
get<N extends KnownModelName>(name: N): KnownModel<N>;
|
|
13
20
|
get<T = unknown>(name: string): Model<T>;
|
|
14
21
|
/** The boot's own connection, for scripts and tests that need the driver. */
|
|
15
22
|
readonly connection: Connection;
|
|
@@ -25,6 +32,7 @@ declare module "@tulipes/core/boot" {
|
|
|
25
32
|
*/
|
|
26
33
|
export declare class ModelStore implements ModelsCapability {
|
|
27
34
|
#private;
|
|
35
|
+
/** The boot's own connection, for scripts and tests that need the driver. */
|
|
28
36
|
readonly connection: Connection;
|
|
29
37
|
constructor(connection: Connection);
|
|
30
38
|
/** @internal Database loader only. */
|
|
@@ -32,6 +40,6 @@ export declare class ModelStore implements ModelsCapability {
|
|
|
32
40
|
has(name: string): boolean;
|
|
33
41
|
ownerOf(name: string): string | undefined;
|
|
34
42
|
names(): string[];
|
|
35
|
-
|
|
43
|
+
get<N extends KnownModelName>(name: N): KnownModel<N>;
|
|
36
44
|
get<T = unknown>(name: string): Model<T>;
|
|
37
45
|
}
|
package/dist/model-store.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* travel as an undefined into query code.
|
|
8
8
|
*/
|
|
9
9
|
export class ModelStore {
|
|
10
|
-
connection;
|
|
11
10
|
/** name → { model, owning module } */
|
|
12
11
|
#models = new Map();
|
|
12
|
+
/** The boot's own connection, for scripts and tests that need the driver. */
|
|
13
|
+
connection;
|
|
13
14
|
constructor(connection) {
|
|
14
15
|
this.connection = connection;
|
|
15
16
|
}
|
package/dist/model-store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-store.js","sourceRoot":"","sources":["../src/model-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model-store.js","sourceRoot":"","sources":["../src/model-store.ts"],"names":[],"mappings":"AA4BA;;;;;;;GAOG;AACH,MAAM,OAAO,UAAU;IACrB,sCAAsC;IAC7B,OAAO,GAAG,IAAI,GAAG,EAAkD,CAAC;IAC7E,6EAA6E;IACpE,UAAU,CAAa;IAEhC,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,sCAAsC;IACtC,SAAS,CAAC,IAAY,EAAE,KAAmB,EAAE,KAAa;QACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IACvC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAID,0EAA0E;IAC1E,GAAG,CAAC,IAAY;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,gDAAgD,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,GAAG,CACnG,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,KAAkC,CAAC;IACnD,CAAC;CACF"}
|
package/dist/provider.js
CHANGED
|
@@ -10,12 +10,11 @@ import { initDatabase } from "./database.js";
|
|
|
10
10
|
* instance, or `instanceof Schema` and the app's global plugins stop applying.
|
|
11
11
|
*/
|
|
12
12
|
export const provider = {
|
|
13
|
-
contract:
|
|
13
|
+
contract: 2,
|
|
14
14
|
capability: "models",
|
|
15
15
|
name: "mongoose",
|
|
16
|
-
async acquire({ ctx, files
|
|
16
|
+
async acquire({ ctx, files }, report, own) {
|
|
17
17
|
const connection = await initDatabase(files, ctx, report, {
|
|
18
|
-
runBootstrap,
|
|
19
18
|
// Registered before the connection is awaited: a database that never
|
|
20
19
|
// answers is still closed by core's failed-boot cleanup.
|
|
21
20
|
onConnection: (connection) => own({
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,QAAQ;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,QAAQ;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG;QACvC,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE;YACxD,qEAAqE;YACrE,yDAAyD;YACzD,YAAY,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC;gBAChC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE;gBACjC,YAAY,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;gBAC5C,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;oBACb,KAAK,EAAE,aAAa,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE;oBAC3E,KAAK,EAAE,UAAU,CAAC,UAAU,KAAK,CAAC;iBACnC,CAAC;aACH,CAAC;SACH,CAAC,CAAC;QACH,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Provider } from "@tulipes/core/boot";
|
|
2
|
+
/**
|
|
3
|
+
* The "settings" provider an app selects with
|
|
4
|
+
* `"tulipes": { "providers": { "settings": "@tulipes/mongoose/settings" } }`.
|
|
5
|
+
*
|
|
6
|
+
* Acquired right after the models provider, so an app that selected this
|
|
7
|
+
* package for its models shares that connection; one that keeps settings
|
|
8
|
+
* in MongoDB without mongoose models opens its own. Either way the store is
|
|
9
|
+
* what core wraps in the settings manager — it never lands on ctx itself.
|
|
10
|
+
*/
|
|
11
|
+
export declare const provider: Provider<"settings">;
|
|
12
|
+
export default provider;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createConnection } from "mongoose";
|
|
2
|
+
import { MongoSettingsStore } from "./settings-store.js";
|
|
3
|
+
/** Well-known infra variable, declared by the app's sys core module. */
|
|
4
|
+
const MONGO_URI = "MONGO_URI";
|
|
5
|
+
/**
|
|
6
|
+
* The "settings" provider an app selects with
|
|
7
|
+
* `"tulipes": { "providers": { "settings": "@tulipes/mongoose/settings" } }`.
|
|
8
|
+
*
|
|
9
|
+
* Acquired right after the models provider, so an app that selected this
|
|
10
|
+
* package for its models shares that connection; one that keeps settings
|
|
11
|
+
* in MongoDB without mongoose models opens its own. Either way the store is
|
|
12
|
+
* what core wraps in the settings manager — it never lands on ctx itself.
|
|
13
|
+
*/
|
|
14
|
+
export const provider = {
|
|
15
|
+
contract: 2,
|
|
16
|
+
capability: "settings",
|
|
17
|
+
name: "mongoose-settings",
|
|
18
|
+
async acquire({ ctx }, report, own) {
|
|
19
|
+
const shared = ctx.models?.connection;
|
|
20
|
+
let connection = shared;
|
|
21
|
+
let store;
|
|
22
|
+
if (!connection) {
|
|
23
|
+
const uri = ctx.Environment.store.has(MONGO_URI) ? String(ctx.Environment.get(MONGO_URI)) : undefined;
|
|
24
|
+
if (!uri) {
|
|
25
|
+
report.add({
|
|
26
|
+
scope: "providers",
|
|
27
|
+
message: `provider "mongoose-settings" is selected but "${MONGO_URI}" is not declared/set — declare it in a sys module's package.json tulipes.env and set it`,
|
|
28
|
+
});
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
connection = createConnection(uri, { serverSelectionTimeoutMS: 5_000 });
|
|
33
|
+
const owned = connection;
|
|
34
|
+
own({
|
|
35
|
+
dispose: async () => { await store?.dispose(); await owned.close(); },
|
|
36
|
+
forceDispose: () => owned.destroy(true),
|
|
37
|
+
status: () => store?.status() ?? { label: `mongodb://${owned.host}:${owned.port}/${owned.name}.settings`, ready: owned.readyState === 1 },
|
|
38
|
+
});
|
|
39
|
+
await connection.asPromise();
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
report.add({ scope: "providers", message: `settings database connection failed (${MONGO_URI}): ${error.message}` });
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// The connection belongs to the models provider; this resource only
|
|
48
|
+
// owns the watch, which must stop before that connection closes.
|
|
49
|
+
own({
|
|
50
|
+
dispose: () => store?.dispose(),
|
|
51
|
+
status: () => store?.status() ?? { label: "mongodb settings", ready: false },
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
store = new MongoSettingsStore(connection);
|
|
55
|
+
return store;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
export default provider;
|
|
59
|
+
//# sourceMappingURL=settings-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-provider.js","sourceRoot":"","sources":["../src/settings-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAI7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wEAAwE;AACxE,MAAM,SAAS,GAAG,WAAW,CAAC;AAE9B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyB;IAC5C,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,UAAU;IACtB,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG;QAChC,MAAM,MAAM,GAAI,GAAG,CAAC,MAAkD,EAAE,UAAU,CAAC;QACnF,IAAI,UAAU,GAAG,MAAM,CAAC;QACxB,IAAI,KAAqC,CAAC;QAE1C,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACtG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,CAAC,GAAG,CAAC;oBACT,KAAK,EAAE,WAAW;oBAClB,OAAO,EAAE,iDAAiD,SAAS,0FAA0F;iBAC9J,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IAAI,C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,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Connection } from "mongoose";
|
|
2
|
+
import { type Actor, type SettingsStore, type StoredSettings } from "@tulipes/core/config";
|
|
3
|
+
/** One namespace, as the `settings` collection holds it. */
|
|
4
|
+
export interface SettingsDocument {
|
|
5
|
+
_id: string;
|
|
6
|
+
values: Record<string, unknown>;
|
|
7
|
+
version: number;
|
|
8
|
+
updated_at: Date;
|
|
9
|
+
updated_by: Actor;
|
|
10
|
+
}
|
|
11
|
+
/** The document a write replaced, kept for the console to show and revert. */
|
|
12
|
+
export interface SettingsHistoryDocument extends Omit<SettingsDocument, "_id"> {
|
|
13
|
+
namespace: string;
|
|
14
|
+
replaced_at: Date;
|
|
15
|
+
replaced_by: Actor;
|
|
16
|
+
}
|
|
17
|
+
export interface MongoSettingsStoreOptions {
|
|
18
|
+
collection?: string;
|
|
19
|
+
historyCollection?: string;
|
|
20
|
+
/** How often to look for other processes' writes when no change stream is available. */
|
|
21
|
+
pollIntervalMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The settings store an app selects with
|
|
25
|
+
* `"tulipes": { "providers": { "settings": "@tulipes/mongoose/settings" } }`:
|
|
26
|
+
* one document per namespace in `settings`, keyed by module name, with
|
|
27
|
+
* the version the manager hands back on every save. A write is a
|
|
28
|
+
* `findOneAndUpdate` on `{ _id, version: expected }`, so two operators
|
|
29
|
+
* cannot overwrite each other, and the document it replaced goes to
|
|
30
|
+
* `settings_history`. Other processes' writes arrive through a change
|
|
31
|
+
* stream on a replica set and through polling otherwise; the manager
|
|
32
|
+
* validates them before applying, so the store validates nothing.
|
|
33
|
+
*/
|
|
34
|
+
export declare class MongoSettingsStore implements SettingsStore {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(connection: Connection, options?: MongoSettingsStoreOptions);
|
|
37
|
+
load(namespace: string): Promise<StoredSettings | undefined>;
|
|
38
|
+
save(namespace: string, values: Record<string, unknown>, expectedVersion: number, actor: Actor): Promise<StoredSettings>;
|
|
39
|
+
/**
|
|
40
|
+
* A change stream needs a replica set; on a standalone server its first
|
|
41
|
+
* use fails with code 40573, and the store falls back to polling without
|
|
42
|
+
* anyone configuring which deployment this is.
|
|
43
|
+
*/
|
|
44
|
+
watch(listener: (namespace: string, stored: StoredSettings) => void): () => void;
|
|
45
|
+
status(): {
|
|
46
|
+
label: string;
|
|
47
|
+
ready: boolean;
|
|
48
|
+
};
|
|
49
|
+
dispose(): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { SettingsConflictError } from "@tulipes/core/config";
|
|
2
|
+
/**
|
|
3
|
+
* The settings store an app selects with
|
|
4
|
+
* `"tulipes": { "providers": { "settings": "@tulipes/mongoose/settings" } }`:
|
|
5
|
+
* one document per namespace in `settings`, keyed by module name, with
|
|
6
|
+
* the version the manager hands back on every save. A write is a
|
|
7
|
+
* `findOneAndUpdate` on `{ _id, version: expected }`, so two operators
|
|
8
|
+
* cannot overwrite each other, and the document it replaced goes to
|
|
9
|
+
* `settings_history`. Other processes' writes arrive through a change
|
|
10
|
+
* stream on a replica set and through polling otherwise; the manager
|
|
11
|
+
* validates them before applying, so the store validates nothing.
|
|
12
|
+
*/
|
|
13
|
+
export class MongoSettingsStore {
|
|
14
|
+
#connection;
|
|
15
|
+
#settings;
|
|
16
|
+
#history;
|
|
17
|
+
#pollIntervalMs;
|
|
18
|
+
/** Versions this process has seen per namespace, so a watch only reports real changes. */
|
|
19
|
+
#seen = new Map();
|
|
20
|
+
#stream;
|
|
21
|
+
#timer;
|
|
22
|
+
#transport = "idle";
|
|
23
|
+
constructor(connection, options = {}) {
|
|
24
|
+
this.#connection = connection;
|
|
25
|
+
this.#settings = connection.collection(options.collection ?? "settings");
|
|
26
|
+
this.#history = connection.collection(options.historyCollection ?? "settings_history");
|
|
27
|
+
this.#pollIntervalMs = options.pollIntervalMs ?? 2_000;
|
|
28
|
+
}
|
|
29
|
+
async load(namespace) {
|
|
30
|
+
const document = await this.#settings.findOne({ _id: namespace });
|
|
31
|
+
if (!document)
|
|
32
|
+
return undefined;
|
|
33
|
+
this.#seen.set(namespace, document.version);
|
|
34
|
+
return toStored(document);
|
|
35
|
+
}
|
|
36
|
+
async save(namespace, values, expectedVersion, actor) {
|
|
37
|
+
const next = { _id: namespace, values, version: expectedVersion + 1, updated_at: new Date(), updated_by: actor };
|
|
38
|
+
if (expectedVersion === 0) {
|
|
39
|
+
try {
|
|
40
|
+
await this.#settings.insertOne(next);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
// Another process seeded first: the conflict carries its document.
|
|
44
|
+
if (error.code !== 11000)
|
|
45
|
+
throw error;
|
|
46
|
+
throw new SettingsConflictError(namespace, await this.load(namespace), expectedVersion);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const previous = await this.#settings.findOneAndUpdate({ _id: namespace, version: expectedVersion }, { $set: { values, version: next.version, updated_at: next.updated_at, updated_by: actor } }, { returnDocument: "before" });
|
|
51
|
+
if (!previous)
|
|
52
|
+
throw new SettingsConflictError(namespace, await this.load(namespace), expectedVersion);
|
|
53
|
+
const { _id, ...replaced } = previous;
|
|
54
|
+
await this.#history.insertOne({ ...replaced, namespace: _id, replaced_at: next.updated_at, replaced_by: actor });
|
|
55
|
+
}
|
|
56
|
+
this.#seen.set(namespace, next.version);
|
|
57
|
+
return toStored(next);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A change stream needs a replica set; on a standalone server its first
|
|
61
|
+
* use fails with code 40573, and the store falls back to polling without
|
|
62
|
+
* anyone configuring which deployment this is.
|
|
63
|
+
*/
|
|
64
|
+
watch(listener) {
|
|
65
|
+
const emit = (document) => {
|
|
66
|
+
if ((this.#seen.get(document._id) ?? 0) >= document.version)
|
|
67
|
+
return;
|
|
68
|
+
this.#seen.set(document._id, document.version);
|
|
69
|
+
listener(document._id, toStored(document));
|
|
70
|
+
};
|
|
71
|
+
const poll = () => {
|
|
72
|
+
this.#transport = "poll";
|
|
73
|
+
this.#timer = setInterval(() => {
|
|
74
|
+
this.#settings.find({}).toArray().then((documents) => documents.forEach(emit), () => undefined);
|
|
75
|
+
}, this.#pollIntervalMs);
|
|
76
|
+
// A poller must never hold a worker or script open on its own.
|
|
77
|
+
this.#timer.unref();
|
|
78
|
+
};
|
|
79
|
+
try {
|
|
80
|
+
const stream = this.#settings.watch([{ $match: { operationType: { $in: ["insert", "update", "replace"] } } }], { fullDocument: "updateLookup" });
|
|
81
|
+
this.#stream = stream;
|
|
82
|
+
this.#transport = "change stream";
|
|
83
|
+
stream.on("change", (change) => {
|
|
84
|
+
const document = change.fullDocument;
|
|
85
|
+
if (document)
|
|
86
|
+
emit(document);
|
|
87
|
+
});
|
|
88
|
+
stream.on("error", () => {
|
|
89
|
+
void stream.close().catch(() => undefined);
|
|
90
|
+
if (this.#stream === stream) {
|
|
91
|
+
this.#stream = undefined;
|
|
92
|
+
if (!this.#timer)
|
|
93
|
+
poll();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
poll();
|
|
99
|
+
}
|
|
100
|
+
return () => void this.dispose();
|
|
101
|
+
}
|
|
102
|
+
status() {
|
|
103
|
+
const { host, port, name } = this.#connection;
|
|
104
|
+
const transport = this.#transport === "idle" ? "" : ` (${this.#transport})`;
|
|
105
|
+
return { label: `mongodb://${host}:${port}/${name}.${this.#settings.collectionName}${transport}`, ready: this.#connection.readyState === 1 };
|
|
106
|
+
}
|
|
107
|
+
async dispose() {
|
|
108
|
+
if (this.#timer)
|
|
109
|
+
clearInterval(this.#timer);
|
|
110
|
+
this.#timer = undefined;
|
|
111
|
+
const stream = this.#stream;
|
|
112
|
+
this.#stream = undefined;
|
|
113
|
+
this.#transport = "idle";
|
|
114
|
+
if (stream)
|
|
115
|
+
await stream.close().catch(() => undefined);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function toStored(document) {
|
|
119
|
+
return {
|
|
120
|
+
values: document.values,
|
|
121
|
+
version: document.version,
|
|
122
|
+
updated_at: document.updated_at instanceof Date ? document.updated_at.toISOString() : String(document.updated_at),
|
|
123
|
+
updated_by: document.updated_by,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=settings-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-store.js","sourceRoot":"","sources":["../src/settings-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAuD,MAAM,sBAAsB,CAAC;AAyBlH;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAkB;IACpB,WAAW,CAAa;IACxB,SAAS,CAA+B;IACxC,QAAQ,CAAsC;IAC9C,eAAe,CAAS;IACjC,0FAA0F;IACjF,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,OAAO,CAA2B;IAClC,MAAM,CAA6C;IACnD,UAAU,GAAsC,MAAM,CAAC;IAEvD,YAAY,UAAsB,EAAE,OAAO,GAA8B,EAAE;QACzE,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,IAAI,UAAU,CAA4C,CAAC;QACpH,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,IAAI,kBAAkB,CAAmD,CAAC;QACzI,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,cAAc,IAAI,KAAK,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAiB;QAC1B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAChC,IAAI,CAAC,K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AC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,UAAU,GAAG,CAAC;QAC5E,OAAO,EAAE,KAAK,EAAE,aAAa,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,cAAc,GAAG,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,KAAK,CAAC,EAAE,CAAC;IAC/I,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,MAAM;YAAE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,QAA0B;IAC1C,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,UAAU,EAAE,QAAQ,CAAC,UAAU,YAAY,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QACjH,UAAU,EAAE,QAAQ,CAAC,UAAU;KAChC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tulipes/mongoose",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-rc.1",
|
|
4
4
|
"description": "Mongoose models provider for Tulipes apps: connection, model registration and bootstrap behind core's models capability",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
-
".": "./dist/index.js"
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./settings": "./dist/settings-provider.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"dist",
|
|
11
12
|
"README.md",
|
|
12
13
|
"LICENSE"
|
|
13
14
|
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"typecheck": "tsc --noEmit",
|
|
16
|
-
"build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
17
|
-
"prepack": "yarn build"
|
|
18
|
-
},
|
|
19
15
|
"publishConfig": {
|
|
20
|
-
"access": "public"
|
|
21
|
-
"exports": {
|
|
22
|
-
".": "./dist/index.js"
|
|
23
|
-
}
|
|
16
|
+
"access": "public"
|
|
24
17
|
},
|
|
25
18
|
"peerDependencies": {
|
|
26
|
-
"@tulipes/core": "^0.10.0",
|
|
19
|
+
"@tulipes/core": "^0.10.0 || ^0.11.0-rc.1",
|
|
27
20
|
"mongoose": "^8"
|
|
28
21
|
},
|
|
29
22
|
"devDependencies": {
|
|
30
|
-
"@tulipes/core": "0.10.0",
|
|
31
23
|
"@types/node": "^24.2.0",
|
|
32
24
|
"mongoose": "^8",
|
|
33
|
-
"typescript": "^7.0.2"
|
|
25
|
+
"typescript": "^7.0.2",
|
|
26
|
+
"@tulipes/core": "0.11.0-rc.1"
|
|
34
27
|
},
|
|
35
28
|
"repository": {
|
|
36
29
|
"type": "git",
|
|
@@ -50,5 +43,9 @@
|
|
|
50
43
|
"homepage": "https://github.com/kemora13conf/bp-backend-express/tree/master/packages/mongoose#readme",
|
|
51
44
|
"bugs": {
|
|
52
45
|
"url": "https://github.com/kemora13conf/bp-backend-express/issues"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json"
|
|
53
50
|
}
|
|
54
51
|
}
|