@decaf-ts/core 0.7.1 → 0.7.3
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 +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/lib/esm/identity/decorators.d.ts +3 -4
- package/lib/esm/identity/decorators.js +4 -10
- package/lib/esm/identity/decorators.js.map +1 -1
- package/lib/esm/identity/index.d.ts +0 -1
- package/lib/esm/identity/index.js +0 -1
- package/lib/esm/identity/index.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/interfaces/ContextuallyLogged.d.ts +8 -0
- package/lib/esm/interfaces/ContextuallyLogged.js +2 -0
- package/lib/esm/interfaces/ContextuallyLogged.js.map +1 -0
- package/lib/esm/interfaces/ErrorParser.d.ts +2 -2
- package/lib/esm/interfaces/Executor.d.ts +1 -1
- package/lib/esm/interfaces/Observable.d.ts +8 -8
- package/lib/esm/interfaces/Observer.d.ts +2 -2
- package/lib/esm/interfaces/RawExecutor.d.ts +1 -1
- package/lib/esm/model/BaseModel.d.ts +2 -2
- package/lib/esm/model/BaseModel.js +2 -2
- package/lib/esm/model/construction.d.ts +9 -8
- package/lib/esm/model/construction.js +2 -2
- package/lib/esm/model/construction.js.map +1 -1
- package/lib/esm/model/decorators.d.ts +4 -3
- package/lib/esm/model/decorators.js +2 -2
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/overrides/Metadata.d.ts +1 -8
- package/lib/esm/overrides/Model.d.ts +75 -0
- package/lib/esm/overrides/Model.js +2 -0
- package/lib/esm/overrides/Model.js.map +1 -0
- package/lib/esm/overrides/index.d.ts +2 -0
- package/lib/esm/overrides/index.js +2 -0
- package/lib/esm/overrides/index.js.map +1 -1
- package/lib/esm/overrides/injectables.d.ts +10 -0
- package/lib/esm/overrides/injectables.js +2 -0
- package/lib/esm/overrides/injectables.js.map +1 -0
- package/lib/esm/overrides/overrides.js +45 -3
- package/lib/esm/overrides/overrides.js.map +1 -1
- package/lib/esm/persistence/Adapter.d.ts +54 -51
- package/lib/esm/persistence/Adapter.js +78 -57
- package/lib/esm/persistence/Adapter.js.map +1 -1
- package/lib/esm/persistence/Dispatch.d.ts +7 -6
- package/lib/esm/persistence/Dispatch.js +25 -18
- package/lib/esm/persistence/Dispatch.js.map +1 -1
- package/lib/esm/persistence/ObserverHandler.d.ts +7 -6
- package/lib/esm/persistence/ObserverHandler.js +5 -4
- package/lib/esm/persistence/ObserverHandler.js.map +1 -1
- package/lib/esm/persistence/Sequence.d.ts +10 -17
- package/lib/esm/persistence/Sequence.js +10 -15
- package/lib/esm/persistence/Sequence.js.map +1 -1
- package/lib/esm/persistence/constants.d.ts +1 -0
- package/lib/esm/persistence/constants.js +1 -0
- package/lib/esm/persistence/constants.js.map +1 -1
- package/lib/esm/persistence/migrations.d.ts +8 -8
- package/lib/esm/persistence/migrations.js +8 -9
- package/lib/esm/persistence/migrations.js.map +1 -1
- package/lib/esm/persistence/types.d.ts +38 -20
- package/lib/esm/query/Paginator.d.ts +6 -5
- package/lib/esm/query/Paginator.js +4 -4
- package/lib/esm/query/Paginator.js.map +1 -1
- package/lib/esm/query/Statement.d.ts +9 -8
- package/lib/esm/query/Statement.js +23 -10
- package/lib/esm/query/Statement.js.map +1 -1
- package/lib/esm/ram/RamAdapter.d.ts +21 -21
- package/lib/esm/ram/RamAdapter.js +36 -23
- package/lib/esm/ram/RamAdapter.js.map +1 -1
- package/lib/esm/ram/RamPaginator.d.ts +2 -1
- package/lib/esm/ram/RamPaginator.js +5 -3
- package/lib/esm/ram/RamPaginator.js.map +1 -1
- package/lib/esm/ram/RamSequence.d.ts +4 -11
- package/lib/esm/ram/RamSequence.js +20 -24
- package/lib/esm/ram/RamSequence.js.map +1 -1
- package/lib/esm/ram/RamStatement.d.ts +7 -7
- package/lib/esm/ram/RamStatement.js.map +1 -1
- package/lib/esm/ram/handlers.d.ts +3 -4
- package/lib/esm/ram/handlers.js.map +1 -1
- package/lib/esm/ram/index.d.ts +0 -1
- package/lib/esm/ram/index.js +0 -1
- package/lib/esm/ram/index.js.map +1 -1
- package/lib/esm/ram/types.d.ts +4 -12
- package/lib/esm/repository/Repository.d.ts +31 -95
- package/lib/esm/repository/Repository.js +106 -201
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/repository/decorators.js +3 -2
- package/lib/esm/repository/decorators.js.map +1 -1
- package/lib/esm/repository/utils.d.ts +1 -1
- package/lib/esm/repository/utils.js +2 -3
- package/lib/esm/repository/utils.js.map +1 -1
- package/lib/esm/utils/ContextualLoggedClass.d.ts +16 -0
- package/lib/esm/utils/ContextualLoggedClass.js +29 -0
- package/lib/esm/utils/ContextualLoggedClass.js.map +1 -0
- package/lib/esm/utils/Services.d.ts +28 -0
- package/lib/esm/utils/Services.js +88 -0
- package/lib/esm/utils/Services.js.map +1 -0
- package/lib/esm/utils/decorators.d.ts +1 -9
- package/lib/esm/utils/decorators.js +26 -15
- package/lib/esm/utils/decorators.js.map +1 -1
- package/lib/esm/utils/index.d.ts +2 -1
- package/lib/esm/utils/index.js +2 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/identity/decorators.cjs +3 -9
- package/lib/identity/decorators.d.ts +3 -4
- package/lib/identity/decorators.js.map +1 -1
- package/lib/identity/index.cjs +0 -1
- package/lib/identity/index.d.ts +0 -1
- package/lib/identity/index.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/ContextuallyLogged.cjs +3 -0
- package/lib/interfaces/ContextuallyLogged.d.ts +8 -0
- package/lib/interfaces/ContextuallyLogged.js.map +1 -0
- package/lib/interfaces/ErrorParser.d.ts +2 -2
- package/lib/interfaces/Executor.d.ts +1 -1
- package/lib/interfaces/Observable.d.ts +8 -8
- package/lib/interfaces/Observer.d.ts +2 -2
- package/lib/interfaces/RawExecutor.d.ts +1 -1
- package/lib/model/BaseModel.cjs +2 -2
- package/lib/model/BaseModel.d.ts +2 -2
- package/lib/model/construction.cjs +2 -2
- package/lib/model/construction.d.ts +9 -8
- package/lib/model/construction.js.map +1 -1
- package/lib/model/decorators.cjs +1 -1
- package/lib/model/decorators.d.ts +4 -3
- package/lib/model/decorators.js.map +1 -1
- package/lib/overrides/Metadata.d.ts +1 -8
- package/lib/overrides/Model.cjs +4 -0
- package/lib/overrides/Model.d.ts +75 -0
- package/lib/overrides/Model.js.map +1 -0
- package/lib/overrides/index.cjs +2 -0
- package/lib/overrides/index.d.ts +2 -0
- package/lib/overrides/index.js.map +1 -1
- package/lib/overrides/injectables.cjs +4 -0
- package/lib/overrides/injectables.d.ts +10 -0
- package/lib/overrides/injectables.js.map +1 -0
- package/lib/overrides/overrides.cjs +43 -1
- package/lib/overrides/overrides.js.map +1 -1
- package/lib/persistence/Adapter.cjs +83 -62
- package/lib/persistence/Adapter.d.ts +54 -51
- package/lib/persistence/Adapter.js.map +1 -1
- package/lib/persistence/Dispatch.cjs +25 -18
- package/lib/persistence/Dispatch.d.ts +7 -6
- package/lib/persistence/Dispatch.js.map +1 -1
- package/lib/persistence/ObserverHandler.cjs +5 -4
- package/lib/persistence/ObserverHandler.d.ts +7 -6
- package/lib/persistence/ObserverHandler.js.map +1 -1
- package/lib/persistence/Sequence.cjs +10 -15
- package/lib/persistence/Sequence.d.ts +10 -17
- package/lib/persistence/Sequence.js.map +1 -1
- package/lib/persistence/constants.cjs +1 -0
- package/lib/persistence/constants.d.ts +1 -0
- package/lib/persistence/constants.js.map +1 -1
- package/lib/persistence/migrations.cjs +7 -8
- package/lib/persistence/migrations.d.ts +8 -8
- package/lib/persistence/migrations.js.map +1 -1
- package/lib/persistence/types.d.ts +38 -20
- package/lib/query/Paginator.cjs +4 -4
- package/lib/query/Paginator.d.ts +6 -5
- package/lib/query/Paginator.js.map +1 -1
- package/lib/query/Statement.cjs +34 -21
- package/lib/query/Statement.d.ts +9 -8
- package/lib/query/Statement.js.map +1 -1
- package/lib/ram/RamAdapter.cjs +35 -22
- package/lib/ram/RamAdapter.d.ts +21 -21
- package/lib/ram/RamAdapter.js.map +1 -1
- package/lib/ram/RamPaginator.cjs +5 -3
- package/lib/ram/RamPaginator.d.ts +2 -1
- package/lib/ram/RamPaginator.js.map +1 -1
- package/lib/ram/RamSequence.cjs +19 -23
- package/lib/ram/RamSequence.d.ts +4 -11
- package/lib/ram/RamSequence.js.map +1 -1
- package/lib/ram/RamStatement.d.ts +7 -7
- package/lib/ram/RamStatement.js.map +1 -1
- package/lib/ram/handlers.d.ts +3 -4
- package/lib/ram/handlers.js.map +1 -1
- package/lib/ram/index.cjs +0 -1
- package/lib/ram/index.d.ts +0 -1
- package/lib/ram/index.js.map +1 -1
- package/lib/ram/types.d.ts +4 -12
- package/lib/repository/Repository.cjs +107 -202
- package/lib/repository/Repository.d.ts +31 -95
- package/lib/repository/Repository.js.map +1 -1
- package/lib/repository/decorators.cjs +1 -0
- package/lib/repository/decorators.js.map +1 -1
- package/lib/repository/utils.cjs +2 -3
- package/lib/repository/utils.d.ts +1 -1
- package/lib/repository/utils.js.map +1 -1
- package/lib/utils/ContextualLoggedClass.cjs +33 -0
- package/lib/utils/ContextualLoggedClass.d.ts +16 -0
- package/lib/utils/ContextualLoggedClass.js.map +1 -0
- package/lib/utils/Services.cjs +93 -0
- package/lib/utils/Services.d.ts +28 -0
- package/lib/utils/Services.js.map +1 -0
- package/lib/utils/decorators.cjs +27 -16
- package/lib/utils/decorators.d.ts +1 -9
- package/lib/utils/decorators.js.map +1 -1
- package/lib/utils/index.cjs +2 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/lib/esm/identity/utils.d.ts +0 -24
- package/lib/esm/identity/utils.js +0 -44
- package/lib/esm/identity/utils.js.map +0 -1
- package/lib/esm/ram/RamContext.d.ts +0 -28
- package/lib/esm/ram/RamContext.js +0 -30
- package/lib/esm/ram/RamContext.js.map +0 -1
- package/lib/identity/utils.cjs +0 -49
- package/lib/identity/utils.d.ts +0 -24
- package/lib/identity/utils.js.map +0 -1
- package/lib/ram/RamContext.cjs +0 -34
- package/lib/ram/RamContext.d.ts +0 -28
- package/lib/ram/RamContext.js.map +0 -1
|
@@ -29,7 +29,7 @@ import { Constructor } from "@decaf-ts/decoration";
|
|
|
29
29
|
* U-->>C: throw InternalError
|
|
30
30
|
* end
|
|
31
31
|
* end
|
|
32
|
-
* U->>S: sf(INJECTABLE, flavour,
|
|
32
|
+
* U->>S: sf(INJECTABLE, flavour, Model.tableName(model))
|
|
33
33
|
* S-->>C: token string
|
|
34
34
|
* @memberOf module:core
|
|
35
35
|
*/
|
|
@@ -2,7 +2,6 @@ import { InternalError } from "@decaf-ts/db-decorators";
|
|
|
2
2
|
import { sf } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { PersistenceKeys } from "./../persistence/constants.js";
|
|
4
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { getTableName } from "./../identity/utils.js";
|
|
6
5
|
import { DefaultFlavour, Decoration } from "@decaf-ts/decoration";
|
|
7
6
|
/**
|
|
8
7
|
* @description Generates a unique injectable name for a repository.
|
|
@@ -33,7 +32,7 @@ import { DefaultFlavour, Decoration } from "@decaf-ts/decoration";
|
|
|
33
32
|
* U-->>C: throw InternalError
|
|
34
33
|
* end
|
|
35
34
|
* end
|
|
36
|
-
* U->>S: sf(INJECTABLE, flavour,
|
|
35
|
+
* U->>S: sf(INJECTABLE, flavour, Model.tableName(model))
|
|
37
36
|
* S-->>C: token string
|
|
38
37
|
* @memberOf module:core
|
|
39
38
|
*/
|
|
@@ -43,6 +42,6 @@ export function generateInjectableNameForRepository(model, flavour) {
|
|
|
43
42
|
if (!flavour || flavour === DefaultFlavour)
|
|
44
43
|
throw new InternalError(`Could not retrieve flavour from model ${model instanceof Model ? model.constructor.name : model.name}`);
|
|
45
44
|
}
|
|
46
|
-
return sf(PersistenceKeys.INJECTABLE, flavour,
|
|
45
|
+
return sf(PersistenceKeys.INJECTABLE, flavour, Model.tableName(model));
|
|
47
46
|
}
|
|
48
47
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/repository/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,sCAAiC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/repository/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,sCAAiC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAe,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,mCAAmC,CACjD,KAAyB,EACzB,OAAgB;IAEhB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CACrC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAE,KAAa,CAC5D,CAAC;QACF,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,cAAc;YACxC,MAAM,IAAI,aAAa,CACrB,yCAAyC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CACxG,CAAC;IACN,CAAC;IACD,OAAO,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
2
|
+
import { Context } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { LoggerOf } from "../persistence/index";
|
|
4
|
+
export type ContextualArgs<C extends Context<any>, ARGS extends any[] = any[]> = [...ARGS, C];
|
|
5
|
+
export type MaybeContextualArg<C extends Context<any>, ARGS extends any[] = any[]> = any[] | ContextualArgs<C, ARGS>;
|
|
6
|
+
export type ContextualizedArgs<C extends Context<any>, ARGS extends any[] = any[]> = {
|
|
7
|
+
ctx: C;
|
|
8
|
+
log: LoggerOf<C>;
|
|
9
|
+
ctxArgs: ContextualArgs<C, ARGS>;
|
|
10
|
+
};
|
|
11
|
+
export declare abstract class ContextualLoggedClass<C extends Context<any>> extends LoggedClass {
|
|
12
|
+
protected logFor(ctx: C, ...args: any[]): LoggerOf<C>;
|
|
13
|
+
protected logCtx<ARGS extends any[]>(args: ARGS, method: ((...args: any[]) => any) | string): ContextualizedArgs<any, ARGS>;
|
|
14
|
+
protected static logCtx<CONTEXT extends Context<any>, ARGS extends any[]>(this: any, args: ARGS, method: string): ContextualizedArgs<CONTEXT, ARGS>;
|
|
15
|
+
protected static logCtx<CONTEXT extends Context<any>, ARGS extends any[]>(this: any, args: ARGS, method: (...args: any[]) => any): ContextualizedArgs<CONTEXT, ARGS>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LoggedClass } from "@decaf-ts/logging";
|
|
2
|
+
import { Context, InternalError } from "@decaf-ts/db-decorators";
|
|
3
|
+
export class ContextualLoggedClass extends LoggedClass {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5
|
+
logFor(ctx, ...args) {
|
|
6
|
+
return ctx.logger.for(this);
|
|
7
|
+
}
|
|
8
|
+
logCtx(args, method) {
|
|
9
|
+
return ContextualLoggedClass.logCtx.call(this, args, method);
|
|
10
|
+
}
|
|
11
|
+
static logCtx(args, method) {
|
|
12
|
+
if (args.length < 1)
|
|
13
|
+
throw new InternalError("No context provided");
|
|
14
|
+
const ctx = args.pop();
|
|
15
|
+
if (!(ctx instanceof Context))
|
|
16
|
+
throw new InternalError("No context provided");
|
|
17
|
+
if (args.filter((a) => a instanceof Context).length > 1)
|
|
18
|
+
throw new Error("here");
|
|
19
|
+
const log = (this
|
|
20
|
+
? ctx.logger.for(this).for(method)
|
|
21
|
+
: ctx.logger.clear().for(this).for(method));
|
|
22
|
+
return {
|
|
23
|
+
ctx: ctx,
|
|
24
|
+
log: method ? log.for(method) : log,
|
|
25
|
+
ctxArgs: [...args, ctx],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ContextualLoggedClass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextualLoggedClass.js","sourceRoot":"","sources":["../../../src/utils/ContextualLoggedClass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAsBjE,MAAM,OAAgB,qBAEpB,SAAQ,WAAW;IACnB,6DAA6D;IACnD,MAAM,CAAC,GAAM,EAAE,GAAG,IAAW;QACrC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAgB,CAAC;IAC7C,CAAC;IAES,MAAM,CACd,IAAU,EACV,MAA0C;QAE1C,OAAO,qBAAqB,CAAC,MAAM,CAAC,IAAI,CACtC,IAAI,EACJ,IAAI,EACJ,MAAa,CACiB,CAAC;IACnC,CAAC;IAYS,MAAM,CAAC,MAAM,CAErB,IAAU,EACV,MAA0C;QAE1C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAa,CAAC;QAClC,IAAI,CAAC,CAAC,GAAG,YAAY,OAAO,CAAC;YAC3B,MAAM,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC1B,MAAM,GAAG,GAAG,CACV,IAAI;YACF,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;YAClC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CACxB,CAAC;QACvB,OAAO;YACL,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,MAAM,CAAC,CAAC,CAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAuB,CAAC,CAAC,CAAC,GAAG;YAC1D,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC;SACxB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
2
|
+
import { ContextualLoggedClass } from "./ContextualLoggedClass";
|
|
3
|
+
export declare abstract class Service extends ContextualLoggedClass<any> {
|
|
4
|
+
readonly name?: string | undefined;
|
|
5
|
+
protected constructor(name?: string | undefined);
|
|
6
|
+
/**
|
|
7
|
+
* @description Retrieves a Service instance by name/class
|
|
8
|
+
* @summary Looks up and returns a cached API instance by its name or constructor
|
|
9
|
+
* @template A Type extending Api
|
|
10
|
+
* @param {string | Constructor<A>} name - Name of the API or its constructor
|
|
11
|
+
* @return {A} The requested API instance
|
|
12
|
+
*/
|
|
13
|
+
static get<A extends Service>(name: string | symbol | Constructor<A>): A;
|
|
14
|
+
static boot(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class ClientBasedService<CLIENT, CONF> extends Service {
|
|
17
|
+
protected _client?: CLIENT;
|
|
18
|
+
protected _config?: CONF;
|
|
19
|
+
protected constructor();
|
|
20
|
+
boot(): Promise<void>;
|
|
21
|
+
abstract initialize(): Promise<{
|
|
22
|
+
config: CONF;
|
|
23
|
+
client: CLIENT;
|
|
24
|
+
}>;
|
|
25
|
+
protected get config(): CONF;
|
|
26
|
+
get client(): CLIENT;
|
|
27
|
+
shutdown(): Promise<void>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { InternalError } from "@decaf-ts/db-decorators";
|
|
11
|
+
import { final, Logging } from "@decaf-ts/logging";
|
|
12
|
+
import { Injectables } from "@decaf-ts/injectable-decorators";
|
|
13
|
+
import { ContextualLoggedClass } from "./ContextualLoggedClass.js";
|
|
14
|
+
export class Service extends ContextualLoggedClass {
|
|
15
|
+
constructor(name) {
|
|
16
|
+
super();
|
|
17
|
+
this.name = name;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @description Retrieves a Service instance by name/class
|
|
21
|
+
* @summary Looks up and returns a cached API instance by its name or constructor
|
|
22
|
+
* @template A Type extending Api
|
|
23
|
+
* @param {string | Constructor<A>} name - Name of the API or its constructor
|
|
24
|
+
* @return {A} The requested API instance
|
|
25
|
+
*/
|
|
26
|
+
static get(name) {
|
|
27
|
+
if (!name)
|
|
28
|
+
throw new InternalError(`No name provided`);
|
|
29
|
+
const injectable = Injectables.get(name);
|
|
30
|
+
if (injectable)
|
|
31
|
+
return injectable;
|
|
32
|
+
throw new InternalError(`No Service found for ${typeof name === "string" ? name : typeof name === "symbol" ? name.toString() : name.name}`);
|
|
33
|
+
}
|
|
34
|
+
static async boot() {
|
|
35
|
+
const log = Logging.for(this.boot);
|
|
36
|
+
const services = Injectables.services();
|
|
37
|
+
for (const [key, service] of Object.entries(services)) {
|
|
38
|
+
try {
|
|
39
|
+
const s = new service.data();
|
|
40
|
+
if (s instanceof ClientBasedService)
|
|
41
|
+
await s.boot();
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
log.error(`Failed to boot ${key} service`, e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ClientBasedService extends Service {
|
|
50
|
+
constructor() {
|
|
51
|
+
super();
|
|
52
|
+
}
|
|
53
|
+
async boot() {
|
|
54
|
+
const { config, client } = await this.initialize();
|
|
55
|
+
this._config = config;
|
|
56
|
+
this._client = client;
|
|
57
|
+
}
|
|
58
|
+
get config() {
|
|
59
|
+
if (!this._config)
|
|
60
|
+
throw new InternalError(`Config not initialized`);
|
|
61
|
+
return this._config;
|
|
62
|
+
}
|
|
63
|
+
get client() {
|
|
64
|
+
if (!this._client)
|
|
65
|
+
throw new InternalError(`Client not initialized`);
|
|
66
|
+
return this._client;
|
|
67
|
+
}
|
|
68
|
+
async shutdown() {
|
|
69
|
+
// do nothing. sub classes must implement this if controlled shutdown is necessary
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
__decorate([
|
|
73
|
+
final(),
|
|
74
|
+
__metadata("design:type", Function),
|
|
75
|
+
__metadata("design:paramtypes", []),
|
|
76
|
+
__metadata("design:returntype", Promise)
|
|
77
|
+
], ClientBasedService.prototype, "boot", null);
|
|
78
|
+
__decorate([
|
|
79
|
+
final(),
|
|
80
|
+
__metadata("design:type", Object),
|
|
81
|
+
__metadata("design:paramtypes", [])
|
|
82
|
+
], ClientBasedService.prototype, "config", null);
|
|
83
|
+
__decorate([
|
|
84
|
+
final(),
|
|
85
|
+
__metadata("design:type", Object),
|
|
86
|
+
__metadata("design:paramtypes", [])
|
|
87
|
+
], ClientBasedService.prototype, "client", null);
|
|
88
|
+
//# sourceMappingURL=Services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Services.js","sourceRoot":"","sources":["../../../src/utils/Services.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,mCAAgC;AAEhE,MAAM,OAAgB,OAAQ,SAAQ,qBAA0B;IAC9D,YAA+B,IAAa;QAC1C,KAAK,EAAE,CAAC;QADqB,SAAI,GAAJ,IAAI,CAAS;IAE5C,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,CAAoB,IAAsC;QAClE,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAEvD,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,UAAU;YAAE,OAAO,UAAe,CAAC;QAEvC,MAAM,IAAI,aAAa,CACrB,wBAAwB,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CACnH,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI;QACf,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtD,IAAI,CAAC;gBACH,MAAM,CAAC,GAAG,IACR,OACD,CAAC,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,YAAY,kBAAkB;oBAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YACtD,CAAC;YAAC,OAAO,CAAU,EAAE,CAAC;gBACpB,GAAG,CAAC,KAAK,CAAC,kBAAkB,GAAG,UAAU,EAAE,CAAU,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAgB,kBAAiC,SAAQ,OAAO;IAKpE;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAGK,AAAN,KAAK,CAAC,IAAI;QACR,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAOD,IACc,MAAM;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,aAAa,CAAC,wBAAwB,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IACI,MAAM;QACR,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,aAAa,CAAC,wBAAwB,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,kFAAkF;IACpF,CAAC;CACF;AA1BO;IADL,KAAK,EAAE;;;;8CAKP;AAOD;IAAC,KAAK,EAAE;;;gDAIP;AAED;IAAC,KAAK,EAAE;;;gDAIP"}
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* @description Creates a decorator that makes a method non-configurable
|
|
3
|
-
* @summary This decorator prevents a method from being overridden by making it non-configurable.
|
|
4
|
-
* It throws an error if used on anything other than a method.
|
|
5
|
-
* @return {Function} A decorator function that can be applied to methods
|
|
6
|
-
* @function final
|
|
7
|
-
* @category Method Decorators
|
|
8
|
-
*/
|
|
9
|
-
export declare function final(): (target: object, propertyKey?: any, descriptor?: PropertyDescriptor) => PropertyDescriptor;
|
|
1
|
+
export declare function service(key: string): (target: any, prop?: any, descriptor?: any) => void;
|
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return (target, propertyKey, descriptor) => {
|
|
11
|
-
if (!descriptor)
|
|
12
|
-
throw new Error("final decorator can only be used on methods");
|
|
13
|
-
if (descriptor?.configurable) {
|
|
14
|
-
descriptor.configurable = false;
|
|
1
|
+
import { apply, metadata, Metadata } from "@decaf-ts/decoration";
|
|
2
|
+
import { inject, injectable } from "@decaf-ts/injectable-decorators";
|
|
3
|
+
import { PersistenceKeys } from "./../persistence/index.js";
|
|
4
|
+
export function service(key) {
|
|
5
|
+
return function service(target, prop, descriptor) {
|
|
6
|
+
Metadata.set(PersistenceKeys.SERVICE, key, target);
|
|
7
|
+
const decs = [];
|
|
8
|
+
if (descriptor && typeof descriptor.value === "number") {
|
|
9
|
+
decs.push(inject());
|
|
15
10
|
}
|
|
16
|
-
|
|
11
|
+
else if (!descriptor && !prop) {
|
|
12
|
+
decs.push(injectable({
|
|
13
|
+
callback: (inst) => Object.defineProperty(inst, "name", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: false,
|
|
16
|
+
writable: false,
|
|
17
|
+
value: key,
|
|
18
|
+
}),
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
else if (!descriptor) {
|
|
22
|
+
decs.push(inject());
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
throw new Error("Invalid decorator usage. Should be impossible");
|
|
26
|
+
decs.push(metadata(PersistenceKeys.SERVICE, key));
|
|
27
|
+
return apply(...decs)(target, prop, descriptor);
|
|
17
28
|
};
|
|
18
29
|
}
|
|
19
30
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/utils/decorators.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/utils/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,kCAA6B;AAEvD,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,OAAO,SAAS,OAAO,CAAC,MAAW,EAAE,IAAU,EAAE,UAAgB;QAC/D,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,UAAU,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACtB,CAAC;aAAM,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CACP,UAAU,CAAC;gBACT,QAAQ,EAAE,CAAC,IAAS,EAAE,EAAE,CACtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE;oBAClC,UAAU,EAAE,IAAI;oBAChB,YAAY,EAAE,KAAK;oBACnB,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,GAAG;iBACX,CAAC;aACL,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,IAAI,CAAC,UAAU,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACtB,CAAC;;YAAM,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAExE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAClD,OAAO,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/esm/utils/index.d.ts
CHANGED
package/lib/esm/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,2CAAwC;AACxC,4BAAyB;AACzB,8BAA2B"}
|
|
@@ -6,7 +6,6 @@ const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
|
6
6
|
const SequenceOptions_1 = require("./../interfaces/SequenceOptions.cjs");
|
|
7
7
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
8
8
|
const decorators_1 = require("./../model/decorators.cjs");
|
|
9
|
-
const utils_1 = require("./utils.cjs");
|
|
10
9
|
const repository_1 = require("./../repository/index.cjs");
|
|
11
10
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
12
11
|
const defaultPkPriority = 60; // Default priority for primary key to run latter than other properties
|
|
@@ -51,15 +50,10 @@ async function pkOnCreate(context, data, key, model) {
|
|
|
51
50
|
return;
|
|
52
51
|
}
|
|
53
52
|
const setPrimaryKeyValue = function (target, propertyKey, value) {
|
|
54
|
-
|
|
55
|
-
enumerable: true,
|
|
56
|
-
writable: false,
|
|
57
|
-
configurable: true,
|
|
58
|
-
value: value,
|
|
59
|
-
});
|
|
53
|
+
Reflect.set(target, propertyKey, value);
|
|
60
54
|
};
|
|
61
55
|
if (!data.name)
|
|
62
|
-
data.name =
|
|
56
|
+
data.name = decorator_validation_1.Model.sequenceName(model, "pk");
|
|
63
57
|
let sequence;
|
|
64
58
|
try {
|
|
65
59
|
sequence = await this.adapter.Sequence(data);
|
|
@@ -67,7 +61,7 @@ async function pkOnCreate(context, data, key, model) {
|
|
|
67
61
|
catch (e) {
|
|
68
62
|
throw new db_decorators_1.InternalError(`Failed to instantiate Sequence ${data.name}: ${e}`);
|
|
69
63
|
}
|
|
70
|
-
const next = await sequence.next();
|
|
64
|
+
const next = await sequence.next(context);
|
|
71
65
|
setPrimaryKeyValue(model, key, next);
|
|
72
66
|
}
|
|
73
67
|
/**
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
2
|
import { SequenceOptions } from "../interfaces/SequenceOptions";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Context } from "@decaf-ts/db-decorators";
|
|
3
|
+
import { ContextOf } from "../persistence/types";
|
|
4
|
+
import { Repository } from "../repository/Repository";
|
|
6
5
|
/**
|
|
7
6
|
* @description Callback function for primary key creation
|
|
8
7
|
* @summary Handles the creation of primary key values for models using sequences
|
|
@@ -39,7 +38,7 @@ import { Context } from "@decaf-ts/db-decorators";
|
|
|
39
38
|
* pkOnCreate->>Model: Set primary key value
|
|
40
39
|
* end
|
|
41
40
|
*/
|
|
42
|
-
export declare function pkOnCreate<M extends Model, R extends
|
|
41
|
+
export declare function pkOnCreate<M extends Model, R extends Repository<M, any>, V extends SequenceOptions>(this: R, context: ContextOf<R>, data: V, key: keyof M, model: M): Promise<void>;
|
|
43
42
|
/**
|
|
44
43
|
* @description Primary Key Decorator
|
|
45
44
|
* @summary Marks a property as the model's primary key with automatic sequence generation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/identity/decorators.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/identity/decorators.ts"],"names":[],"mappings":";;AA6DA,gCAmCC;AAsBD,gBAgCC;AAtJD,yEAAiE;AACjE,yEAGuC;AACvC,2DAMiC;AACjC,0DAA4C;AAE5C,0DAA+C;AAC/C,qDAK8B;AAG9B,MAAM,iBAAiB,GAAG,EAAE,CAAC,CAAC,uEAAuE;AAErG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACI,KAAK,UAAU,UAAU,CAM9B,OAAqB,EACrB,IAAO,EACP,GAAY,EACZ,KAAQ;IAER,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IAED,MAAM,kBAAkB,GAAG,UACzB,MAAS,EACT,WAAmB,EACnB,KAA+B;QAE/B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,IAAI,CAAC,IAAI,GAAG,4BAAK,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5D,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,CAAM,EAAE,CAAC;QAChB,MAAM,IAAI,6BAAa,CACrB,kCAAkC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,CACpD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,kBAAkB,CAAC,KAAK,EAAE,GAAa,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,EAAE,CAChB,OAGI,wCAAsB;IAE1B,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,wCAAsB,EAAE,IAAI,EAAE;QACrD,SAAS,EACP,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,KAAK,WAAW;YAChD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,wCAAsB,CAAC,SAAS;KACzD,CAAoB,CAAC;IAEtB,MAAM,GAAG,GAAG,sBAAM,CAAC,EAAE,CAAC;IACtB,SAAS,KAAK,CAAC,OAAwB,EAAE,SAAqB;QAC5D,OAAO,SAAS,KAAK,CAAC,GAAQ,EAAE,IAAS;YACvC,OAAO,IAAA,kBAAK,EACV,IAAA,kBAAK,EAAC,CAAC,2BAAc,CAAC,GAAG,EAAE,2BAAc,CAAC,GAAG,CAAC,CAAC,EAC/C,IAAA,+BAAQ,GAAE,EACV,IAAA,wBAAQ,GAAE;YACV,qIAAqI;YACrI,IAAA,yBAAY,EAAC,qBAAQ,CAAC,GAAG,CAAC,sBAAM,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,EACpD,IAAA,wBAAQ,EAAC,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CACzC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACf,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,uBAAU,CAAC,GAAG,CAAC,GAAG,CAAC;SACvB,MAAM,CAAC;QACN,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC;KAC9C,CAAC;SACD,KAAK,EAAE,CAAC;AACb,CAAC"}
|
package/lib/identity/index.cjs
CHANGED
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./decorators.cjs"), exports);
|
|
18
|
-
__exportStar(require("./utils.cjs"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
package/lib/identity/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAA6B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/identity/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAA6B"}
|
package/lib/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ __exportStar(require("./ram/index.cjs"), exports);
|
|
|
44
44
|
* @const VERSION
|
|
45
45
|
* @memberOf module:core
|
|
46
46
|
*/
|
|
47
|
-
exports.VERSION = "0.7.
|
|
47
|
+
exports.VERSION = "0.7.2";
|
|
48
48
|
/**
|
|
49
49
|
* @description Stores the current package version
|
|
50
50
|
* @summary A constant representing the version of the core package
|
package/lib/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export * from "./ram";
|
|
|
20
20
|
* @const VERSION
|
|
21
21
|
* @memberOf module:core
|
|
22
22
|
*/
|
|
23
|
-
export declare const VERSION = "0.7.
|
|
23
|
+
export declare const VERSION = "0.7.2";
|
|
24
24
|
/**
|
|
25
25
|
* @description Stores the current package version
|
|
26
26
|
* @summary A constant representing the version of the core package
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { LoggerOf } from "../persistence/index";
|
|
3
|
+
export interface ContextuallyLogged<C extends Context<any>> {
|
|
4
|
+
logAndCtx(args: any[], method?: (...args: any[]) => any): {
|
|
5
|
+
ctx: C;
|
|
6
|
+
log: LoggerOf<C>;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextuallyLogged.js","sourceRoot":"","sources":["../../src/interfaces/ContextuallyLogged.ts"],"names":[],"mappings":""}
|
|
@@ -10,7 +10,7 @@ export interface ErrorParser {
|
|
|
10
10
|
* @description Parses a generic Error into a BaseError
|
|
11
11
|
* @summary Converts a standard Error object into a more specific BaseError type
|
|
12
12
|
* @param {Error} error - The error to be parsed
|
|
13
|
-
* @return {
|
|
13
|
+
* @return {E} The parsed error as a BaseError instance
|
|
14
14
|
*/
|
|
15
|
-
parseError(error: Error):
|
|
15
|
+
parseError<E extends BaseError>(error: Error): E;
|
|
16
16
|
}
|
|
@@ -6,28 +6,28 @@ import { Observer } from "./Observer";
|
|
|
6
6
|
* @interface Observable
|
|
7
7
|
* @memberOf module:core
|
|
8
8
|
*/
|
|
9
|
-
export interface Observable {
|
|
9
|
+
export interface Observable<REGISTRATION extends [Observer, ...any[]] = [Observer], ARGS extends any[] = any[]> {
|
|
10
10
|
/**
|
|
11
11
|
* @description Registers an observer to receive notifications
|
|
12
12
|
* @summary Adds an observer to the list of observers that will be notified of state changes
|
|
13
|
-
* @
|
|
14
|
-
* @param {...
|
|
13
|
+
* @template REGISTRATION - The type of the registration arguments for the observer
|
|
14
|
+
* @param {...REGISTRATION} args - @{link Observer} and additional arguments
|
|
15
15
|
* @return {void}
|
|
16
16
|
*/
|
|
17
|
-
observe(
|
|
17
|
+
observe(...args: REGISTRATION): void;
|
|
18
18
|
/**
|
|
19
19
|
* @description Unregisters an observer from receiving notifications
|
|
20
20
|
* @summary Removes an observer from the list of observers that will be notified of state changes
|
|
21
|
-
* @
|
|
22
|
-
* @param {...
|
|
21
|
+
* @template REGISTRATION - The type of the registration arguments for the observer
|
|
22
|
+
* @param {...REGISTRATION} args - @{link Observer} and additional arguments
|
|
23
23
|
* @return {void}
|
|
24
24
|
*/
|
|
25
|
-
unObserve(
|
|
25
|
+
unObserve(...args: REGISTRATION): void;
|
|
26
26
|
/**
|
|
27
27
|
* @description Notifies all registered observers of a state change
|
|
28
28
|
* @summary Calls the update method on all registered observers, passing any provided arguments
|
|
29
29
|
* @param {...any[]} args - Arguments to pass to the observers' update methods
|
|
30
30
|
* @return {Promise<void>} A promise that resolves when all observers have been updated
|
|
31
31
|
*/
|
|
32
|
-
updateObservers(...args:
|
|
32
|
+
updateObservers(...args: ARGS): Promise<void>;
|
|
33
33
|
}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* @interface Observer
|
|
5
5
|
* @memberOf module:core
|
|
6
6
|
*/
|
|
7
|
-
export interface Observer {
|
|
7
|
+
export interface Observer<ARGS extends any[] = any[]> {
|
|
8
8
|
/**
|
|
9
9
|
* @description Updates the observer with new state information
|
|
10
10
|
* @summary Called by an Observable when its state changes, allowing the Observer to react to those changes
|
|
11
11
|
* @param {...any[]} args - Arguments containing state information from the Observable
|
|
12
12
|
* @return {Promise<void>} A promise that resolves when the observer has processed the update
|
|
13
13
|
*/
|
|
14
|
-
refresh(...args:
|
|
14
|
+
refresh(...args: ARGS): Promise<void>;
|
|
15
15
|
}
|
package/lib/model/BaseModel.cjs
CHANGED
|
@@ -44,9 +44,9 @@ exports.BaseModel = BaseModel;
|
|
|
44
44
|
__decorate([
|
|
45
45
|
(0, decorators_1.createdAt)(),
|
|
46
46
|
__metadata("design:type", Date)
|
|
47
|
-
], BaseModel.prototype, "
|
|
47
|
+
], BaseModel.prototype, "createdAt", void 0);
|
|
48
48
|
__decorate([
|
|
49
49
|
(0, decorators_1.updatedAt)(),
|
|
50
50
|
__metadata("design:type", Date)
|
|
51
|
-
], BaseModel.prototype, "
|
|
51
|
+
], BaseModel.prototype, "updatedAt", void 0);
|
|
52
52
|
//# sourceMappingURL=BaseModel.js.map
|
package/lib/model/BaseModel.d.ts
CHANGED
|
@@ -27,11 +27,11 @@ export declare abstract class BaseModel extends Model {
|
|
|
27
27
|
* @description Creation timestamp for the model
|
|
28
28
|
* @summary Automatically set to the current date and time when the model is created
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
createdAt: Date;
|
|
31
31
|
/**
|
|
32
32
|
* @description Last update timestamp for the model
|
|
33
33
|
* @summary Automatically updated to the current date and time whenever the model is modified
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
updatedAt: Date;
|
|
36
36
|
protected constructor(arg?: ModelArg<BaseModel>);
|
|
37
37
|
}
|
|
@@ -66,7 +66,7 @@ async function createOrUpdate(model, context, alias, repository) {
|
|
|
66
66
|
throw new db_decorators_1.InternalError(`Could not find model ${model.constructor.name}`);
|
|
67
67
|
repository = Repository_1.Repository.forModel(constructor, alias);
|
|
68
68
|
}
|
|
69
|
-
if (typeof model[repository.
|
|
69
|
+
if (typeof model[decorator_validation_1.Model.pk(repository.class)] === "undefined")
|
|
70
70
|
return repository.create(model, context);
|
|
71
71
|
else {
|
|
72
72
|
try {
|
|
@@ -456,7 +456,7 @@ async function oneToManyOnDelete(context, data, key, model) {
|
|
|
456
456
|
: repositoryFromTypeMetadata(model, key, this.adapter.alias);
|
|
457
457
|
const uniqueValues = new Set([
|
|
458
458
|
...(isInstantiated
|
|
459
|
-
? values.map((v) => v[repo
|
|
459
|
+
? values.map((v) => v[repo["pk"]])
|
|
460
460
|
: values),
|
|
461
461
|
]);
|
|
462
462
|
for (const id of uniqueValues.values()) {
|