@decaf-ts/core 0.7.2 → 0.7.4
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 +6 -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 +5 -11
- 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/{ram/model/RamSequenceModel.d.ts → model/SequenceModel.d.ts} +3 -3
- package/lib/esm/{ram/model/RamSequenceModel.js → model/SequenceModel.js} +12 -11
- package/lib/esm/model/SequenceModel.js.map +1 -0
- 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 +5 -4
- package/lib/esm/model/decorators.js +3 -3
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/model/index.d.ts +1 -0
- package/lib/esm/model/index.js +1 -0
- package/lib/esm/model/index.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 +55 -53
- package/lib/esm/persistence/Adapter.js +85 -61
- 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 +34 -25
- package/lib/esm/persistence/Sequence.js +136 -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/generators.d.ts +14 -0
- package/lib/esm/persistence/generators.js +31 -0
- package/lib/esm/persistence/generators.js.map +1 -0
- package/lib/esm/persistence/index.d.ts +1 -0
- package/lib/esm/persistence/index.js +1 -0
- package/lib/esm/persistence/index.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 +22 -31
- package/lib/esm/ram/RamAdapter.js +36 -34
- 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/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 -3
- package/lib/esm/ram/index.js +0 -3
- 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 +107 -203
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/repository/decorators.js +4 -3
- 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 +50 -0
- package/lib/esm/utils/Services.js +154 -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 +5 -11
- 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/{ram/model/RamSequenceModel.cjs → model/SequenceModel.cjs} +14 -13
- package/lib/{ram/model/RamSequenceModel.d.ts → model/SequenceModel.d.ts} +3 -3
- package/lib/model/SequenceModel.js.map +1 -0
- 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 +3 -3
- package/lib/model/decorators.d.ts +5 -4
- package/lib/model/decorators.js.map +1 -1
- package/lib/model/index.cjs +1 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.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 +90 -66
- package/lib/persistence/Adapter.d.ts +55 -53
- 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 +136 -15
- package/lib/persistence/Sequence.d.ts +34 -25
- 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/generators.cjs +36 -0
- package/lib/persistence/generators.d.ts +14 -0
- package/lib/persistence/generators.js.map +1 -0
- package/lib/persistence/index.cjs +1 -0
- package/lib/persistence/index.d.ts +1 -0
- package/lib/persistence/index.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 -33
- package/lib/ram/RamAdapter.d.ts +22 -31
- 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/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 -3
- package/lib/ram/index.d.ts +0 -3
- package/lib/ram/index.js.map +1 -1
- package/lib/ram/types.d.ts +4 -12
- package/lib/repository/Repository.cjs +108 -204
- package/lib/repository/Repository.d.ts +31 -95
- package/lib/repository/Repository.js.map +1 -1
- package/lib/repository/decorators.cjs +2 -1
- 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 +159 -0
- package/lib/utils/Services.d.ts +50 -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/esm/ram/RamSequence.d.ts +0 -75
- package/lib/esm/ram/RamSequence.js +0 -145
- package/lib/esm/ram/RamSequence.js.map +0 -1
- package/lib/esm/ram/model/RamSequenceModel.js.map +0 -1
- package/lib/esm/ram/model/index.d.ts +0 -1
- package/lib/esm/ram/model/index.js +0 -2
- package/lib/esm/ram/model/index.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
- package/lib/ram/RamSequence.cjs +0 -149
- package/lib/ram/RamSequence.d.ts +0 -75
- package/lib/ram/RamSequence.js.map +0 -1
- package/lib/ram/model/RamSequenceModel.js.map +0 -1
- package/lib/ram/model/index.cjs +0 -18
- package/lib/ram/model/index.d.ts +0 -1
- package/lib/ram/model/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/repository/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAe,MAAM,yBAAyB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/repository/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAe,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,wBAAqB;AAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,kCAAuB;AAC1D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,UAAU,CACxB,KAAqB,EACrB,OAAgB;IAEhB,OAAO,CAAC,CAAC,QAAa,EAAE,WAAiB,EAAE,EAAE;QAC3C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC/D,CAAC;QAED,QAAQ,CAAC,GAAG,CACV,MAAM,CAAC,UAAU,EACjB,QAAQ,CAAC,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EACvE,QAAQ,CACT,CAAC;QAEF,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO;YACL,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;QACzE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YACxC,QAAQ,EAAE,CAAC,QAAwB,EAAE,EAAE;gBACrC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE;oBAC5C,UAAU,EAAE,KAAK;oBACjB,YAAY,EAAE,KAAK;oBACnB,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,KAAK;iBACb,CAAC,CAAC;gBACH,OAAO,QAAQ,CAAC;YAClB,CAAC;SACF,CAAC,CAAC,QAAQ,CAAC,CAAC;IACf,CAAC,CAAQ,CAAC;AACZ,CAAC"}
|
|
@@ -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,qBAE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
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Context, Contextual, OperationKeys } from "@decaf-ts/db-decorators";
|
|
2
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
3
|
+
import { ContextualArgs, ContextualizedArgs, MaybeContextualArg } from "./ContextualLoggedClass";
|
|
4
|
+
import { FlagsOf } from "../persistence/index";
|
|
5
|
+
export declare abstract class Service<C extends Context<any> = any> implements Contextual<C> {
|
|
6
|
+
readonly name?: string | undefined;
|
|
7
|
+
protected constructor(name?: string | undefined);
|
|
8
|
+
/**
|
|
9
|
+
* @description Creates repository flags for an operation
|
|
10
|
+
* @summary Generates a set of flags that describe a database operation, combining default flags with overrides
|
|
11
|
+
* @template F - The Repository Flags type
|
|
12
|
+
* @template M - The model type
|
|
13
|
+
* @param {OperationKeys} operation - The type of operation being performed
|
|
14
|
+
* @param {Constructor<M>} model - The model constructor
|
|
15
|
+
* @param {Partial<F>} flags - Custom flag overrides
|
|
16
|
+
* @param {...any[]} args - Additional arguments
|
|
17
|
+
* @return {Promise<F>} The complete set of flags
|
|
18
|
+
*/
|
|
19
|
+
protected flags(operation: OperationKeys | string, flags: Partial<FlagsOf<C>>, ...args: any[]): Promise<FlagsOf<C>>;
|
|
20
|
+
/**
|
|
21
|
+
* @description The context constructor for this adapter
|
|
22
|
+
* @summary Reference to the context class constructor used by this adapter
|
|
23
|
+
*/
|
|
24
|
+
protected readonly Context: Constructor<C>;
|
|
25
|
+
context(operation: OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE | string, overrides: Partial<FlagsOf<C>>, ...args: any[]): Promise<C>;
|
|
26
|
+
protected logCtx<ARGS extends any[]>(args: ARGS, method: ((...args: any[]) => any) | string, allowCreate?: boolean): Promise<ContextualizedArgs<any, ARGS>>;
|
|
27
|
+
protected static logCtx<CONTEXT extends Context<any>, ARGS extends any[]>(this: Contextual, args: ARGS, operation: ((...args: any[]) => any) | string, allowCreate?: boolean): Promise<ContextualizedArgs<CONTEXT, ARGS>>;
|
|
28
|
+
/**
|
|
29
|
+
* @description Retrieves a Service instance by name/class
|
|
30
|
+
* @summary Looks up and returns a cached API instance by its name or constructor
|
|
31
|
+
* @template A Type extending Api
|
|
32
|
+
* @param {string | Constructor<A>} name - Name of the API or its constructor
|
|
33
|
+
* @return {A} The requested API instance
|
|
34
|
+
*/
|
|
35
|
+
static get<A extends Service>(name: string | symbol | Constructor<A>): A;
|
|
36
|
+
static boot<C extends Context<any> = any>(...args: MaybeContextualArg<C>): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare abstract class ClientBasedService<CLIENT, CONF, C extends Context<any> = any> extends Service {
|
|
39
|
+
protected _client?: CLIENT;
|
|
40
|
+
protected _config?: CONF;
|
|
41
|
+
protected constructor();
|
|
42
|
+
boot(...args: MaybeContextualArg<C>): Promise<void>;
|
|
43
|
+
abstract initialize(...args: ContextualArgs<C>): Promise<{
|
|
44
|
+
config: CONF;
|
|
45
|
+
client: CLIENT;
|
|
46
|
+
}>;
|
|
47
|
+
protected get config(): CONF;
|
|
48
|
+
get client(): CLIENT;
|
|
49
|
+
shutdown(...args: MaybeContextualArg<C>): Promise<void>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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 { Context, DefaultRepositoryFlags, InternalError, } from "@decaf-ts/db-decorators";
|
|
11
|
+
import { final, Logging } from "@decaf-ts/logging";
|
|
12
|
+
import { Injectables } from "@decaf-ts/injectable-decorators";
|
|
13
|
+
export class Service {
|
|
14
|
+
constructor(name) {
|
|
15
|
+
this.name = name;
|
|
16
|
+
/**
|
|
17
|
+
* @description The context constructor for this adapter
|
|
18
|
+
* @summary Reference to the context class constructor used by this adapter
|
|
19
|
+
*/
|
|
20
|
+
this.Context = (Context);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @description Creates repository flags for an operation
|
|
24
|
+
* @summary Generates a set of flags that describe a database operation, combining default flags with overrides
|
|
25
|
+
* @template F - The Repository Flags type
|
|
26
|
+
* @template M - The model type
|
|
27
|
+
* @param {OperationKeys} operation - The type of operation being performed
|
|
28
|
+
* @param {Constructor<M>} model - The model constructor
|
|
29
|
+
* @param {Partial<F>} flags - Custom flag overrides
|
|
30
|
+
* @param {...any[]} args - Additional arguments
|
|
31
|
+
* @return {Promise<F>} The complete set of flags
|
|
32
|
+
*/
|
|
33
|
+
async flags(operation, flags,
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
...args) {
|
|
36
|
+
let log = (flags.logger || Logging.for(this.toString()));
|
|
37
|
+
if (flags.correlationId)
|
|
38
|
+
log = log.for({ correlationId: flags.correlationId });
|
|
39
|
+
return Object.assign({}, DefaultRepositoryFlags, flags, {
|
|
40
|
+
timestamp: new Date(),
|
|
41
|
+
operation: operation,
|
|
42
|
+
logger: log,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async context(operation, overrides, ...args) {
|
|
46
|
+
const flags = await this.flags(operation, overrides, ...args);
|
|
47
|
+
return new this.Context().accumulate(flags);
|
|
48
|
+
}
|
|
49
|
+
async logCtx(args, method, allowCreate = false) {
|
|
50
|
+
return (await Service.logCtx.bind(this)(args, method, allowCreate));
|
|
51
|
+
}
|
|
52
|
+
static async logCtx(args, operation, allowCreate = false) {
|
|
53
|
+
const bootCtx = async function bootCtx() {
|
|
54
|
+
if (!allowCreate)
|
|
55
|
+
throw new InternalError("No context provided");
|
|
56
|
+
return this.context(typeof operation === "string" ? operation : operation.name, {});
|
|
57
|
+
}.bind(this);
|
|
58
|
+
if (args.length < 1) {
|
|
59
|
+
args = [await bootCtx()];
|
|
60
|
+
}
|
|
61
|
+
const ctx = args.pop();
|
|
62
|
+
if (!(ctx instanceof Context))
|
|
63
|
+
args = [...args, await bootCtx()];
|
|
64
|
+
const log = (this
|
|
65
|
+
? ctx.logger.for(this).for(operation)
|
|
66
|
+
: ctx.logger.clear().for(this).for(operation));
|
|
67
|
+
return {
|
|
68
|
+
ctx: ctx,
|
|
69
|
+
log: operation ? log.for(operation) : log,
|
|
70
|
+
ctxArgs: [...args, ctx],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @description Retrieves a Service instance by name/class
|
|
75
|
+
* @summary Looks up and returns a cached API instance by its name or constructor
|
|
76
|
+
* @template A Type extending Api
|
|
77
|
+
* @param {string | Constructor<A>} name - Name of the API or its constructor
|
|
78
|
+
* @return {A} The requested API instance
|
|
79
|
+
*/
|
|
80
|
+
static get(name) {
|
|
81
|
+
if (!name)
|
|
82
|
+
throw new InternalError(`No name provided`);
|
|
83
|
+
const injectable = Injectables.get(name);
|
|
84
|
+
if (injectable)
|
|
85
|
+
return injectable;
|
|
86
|
+
throw new InternalError(`No Service found for ${typeof name === "string" ? name : typeof name === "symbol" ? name.toString() : name.name}`);
|
|
87
|
+
}
|
|
88
|
+
static async boot(...args) {
|
|
89
|
+
const factory = {
|
|
90
|
+
async context(operation) {
|
|
91
|
+
return new Context().accumulate(Object.assign({}, DefaultRepositoryFlags, {
|
|
92
|
+
timestamp: new Date(),
|
|
93
|
+
operation: operation,
|
|
94
|
+
logger: Logging.get(),
|
|
95
|
+
}));
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const { log, ctxArgs } = await this.logCtx.bind(factory)(args, this.boot, true);
|
|
99
|
+
const services = Injectables.services();
|
|
100
|
+
for (const [key, service] of Object.entries(services)) {
|
|
101
|
+
try {
|
|
102
|
+
const s = new service();
|
|
103
|
+
if (s instanceof ClientBasedService)
|
|
104
|
+
await s.boot(...ctxArgs);
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
log.error(`Failed to boot ${key} service`, e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export class ClientBasedService extends Service {
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
}
|
|
116
|
+
async boot(...args) {
|
|
117
|
+
const { log, ctxArgs } = await this.logCtx(args, this.boot, true);
|
|
118
|
+
log.verbose(`Initializing ${this.toString()}...`);
|
|
119
|
+
const { config, client } = await this.initialize(...ctxArgs);
|
|
120
|
+
this._config = config;
|
|
121
|
+
this._client = client;
|
|
122
|
+
}
|
|
123
|
+
get config() {
|
|
124
|
+
if (!this._config)
|
|
125
|
+
throw new InternalError(`Config not initialized`);
|
|
126
|
+
return this._config;
|
|
127
|
+
}
|
|
128
|
+
get client() {
|
|
129
|
+
if (!this._client)
|
|
130
|
+
throw new InternalError(`Client not initialized`);
|
|
131
|
+
return this._client;
|
|
132
|
+
}
|
|
133
|
+
async shutdown(...args) {
|
|
134
|
+
const { log } = await this.logCtx(args, this.shutdown, true);
|
|
135
|
+
log.info(`Shutting down ${this.name} service...`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
__decorate([
|
|
139
|
+
final(),
|
|
140
|
+
__metadata("design:type", Function),
|
|
141
|
+
__metadata("design:paramtypes", [Object]),
|
|
142
|
+
__metadata("design:returntype", Promise)
|
|
143
|
+
], ClientBasedService.prototype, "boot", null);
|
|
144
|
+
__decorate([
|
|
145
|
+
final(),
|
|
146
|
+
__metadata("design:type", Object),
|
|
147
|
+
__metadata("design:paramtypes", [])
|
|
148
|
+
], ClientBasedService.prototype, "config", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
final(),
|
|
151
|
+
__metadata("design:type", Object),
|
|
152
|
+
__metadata("design:paramtypes", [])
|
|
153
|
+
], ClientBasedService.prototype, "client", null);
|
|
154
|
+
//# sourceMappingURL=Services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Services.js","sourceRoot":"","sources":["../../../src/utils/Services.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,OAAO,EAEP,sBAAsB,EACtB,aAAa,GAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAU,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAQ9D,MAAM,OAAgB,OAAO;IAG3B,YAA+B,IAAa;QAAb,SAAI,GAAJ,IAAI,CAAS;QA6B5C;;;WAGG;QACgB,YAAO,GAAmB,CAAA,OAEf,CAAA,CAAC;IAnCgB,CAAC;IAEhD;;;;;;;;;;OAUG;IACO,KAAK,CAAC,KAAK,CACnB,SAAiC,EACjC,KAA0B;IAC1B,6DAA6D;IAC7D,GAAG,IAAW;QAEd,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAW,CAAC;QACnE,IAAI,KAAK,CAAC,aAAa;YACrB,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE;YACtD,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,SAAS;YACpB,MAAM,EAAE,GAAG;SACZ,CAAe,CAAC;IACnB,CAAC;IAUD,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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,CAAC,GAAG,IAA2B;QAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC7D,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC;IACpD,CAAC;CACF;AA7BO;IADL,KAAK,EAAE;;;;8CAOP;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,8 +6,7 @@ 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
|
|
10
|
-
const repository_1 = require("./../repository/index.cjs");
|
|
9
|
+
const constants_1 = require("./../repository/constants.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
|
|
13
12
|
/**
|
|
@@ -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
|
/**
|
|
@@ -99,7 +93,7 @@ function pk(opts = SequenceOptions_1.DefaultSequenceOptions) {
|
|
|
99
93
|
const key = db_decorators_1.DBKeys.ID;
|
|
100
94
|
function pkDec(options, groupsort) {
|
|
101
95
|
return function pkDec(obj, attr) {
|
|
102
|
-
return (0, decoration_1.apply)((0, decorators_1.index)([
|
|
96
|
+
return (0, decoration_1.apply)((0, decorators_1.index)([constants_1.OrderDirection.ASC, constants_1.OrderDirection.DSC]), (0, decorator_validation_1.required)(), (0, db_decorators_1.readonly)(),
|
|
103
97
|
// Model.pk neeeds to get the pk property name from the first property of Metatada[DBKeys.ID] ---> { [DBKeys.ID]: { [attr]:options }}
|
|
104
98
|
(0, decoration_1.propMetadata)(decoration_1.Metadata.key(db_decorators_1.DBKeys.ID, attr), options), (0, db_decorators_1.onCreate)(pkOnCreate, options, groupsort))(obj, attr);
|
|
105
99
|
};
|
|
@@ -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,6DAAyD;AACzD,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,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|| 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.3";
|
|
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.3";
|
|
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
|
}
|