declastruct 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/__test_assets__/getExampleContext.d.ts +33 -0
- package/dist/__test_assets__/getExampleContext.js +87 -0
- package/dist/__test_assets__/getExampleContext.js.map +1 -0
- package/dist/contract/commands/command.apply.d.ts +6 -0
- package/dist/contract/commands/command.apply.js +20 -0
- package/dist/contract/commands/command.apply.js.map +1 -0
- package/dist/contract/commands/command.plan.d.ts +6 -0
- package/dist/contract/commands/command.plan.js +20 -0
- package/dist/contract/commands/command.plan.js.map +1 -0
- package/dist/contract/commands/utils/resolveCommandInputs.d.ts +17 -0
- package/dist/contract/commands/utils/resolveCommandInputs.js +23 -0
- package/dist/contract/commands/utils/resolveCommandInputs.js.map +1 -0
- package/dist/contract/sdk/index.d.ts +3 -0
- package/dist/contract/sdk/index.js +20 -0
- package/dist/contract/sdk/index.js.map +1 -0
- package/dist/contract/sdk/refs.d.ts +2 -0
- package/dist/contract/sdk/refs.js +19 -0
- package/dist/contract/sdk/refs.js.map +1 -0
- package/dist/contract/sdk/sync/apply.d.ts +22 -0
- package/dist/contract/sdk/sync/apply.js +29 -0
- package/dist/contract/sdk/sync/apply.js.map +1 -0
- package/dist/contract/sdk/sync/plan.d.ts +22 -0
- package/dist/contract/sdk/sync/plan.js +30 -0
- package/dist/contract/sdk/sync/plan.js.map +1 -0
- package/dist/domain/DeclaredResource.d.ts +2 -0
- package/dist/domain/DeclaredResource.js +3 -0
- package/dist/domain/DeclaredResource.js.map +1 -0
- package/dist/domain/DeclaredResourceReference.d.ts +66 -0
- package/dist/domain/DeclaredResourceReference.js +42 -0
- package/dist/domain/DeclaredResourceReference.js.map +1 -0
- package/dist/domain/DeclastructChangeProposal.d.ts +61 -0
- package/dist/domain/DeclastructChangeProposal.js +37 -0
- package/dist/domain/DeclastructChangeProposal.js.map +1 -0
- package/dist/domain/DeclastructContext.d.ts +24 -0
- package/dist/domain/DeclastructContext.js +3 -0
- package/dist/domain/DeclastructContext.js.map +1 -0
- package/dist/domain/DeclastructProvider.d.ts +58 -0
- package/dist/domain/DeclastructProvider.js +3 -0
- package/dist/domain/DeclastructProvider.js.map +1 -0
- package/dist/domain/DeclastructProviderContext.d.ts +30 -0
- package/dist/domain/DeclastructProviderContext.js +3 -0
- package/dist/domain/DeclastructProviderContext.js.map +1 -0
- package/dist/domain/DeclastructProviderResourceRemoteStateInterface.d.ts +156 -0
- package/dist/domain/DeclastructProviderResourceRemoteStateInterface.js +3 -0
- package/dist/domain/DeclastructProviderResourceRemoteStateInterface.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/logic/actions/execute/canUpdateResource.d.ts +5 -0
- package/dist/logic/actions/execute/canUpdateResource.js +12 -0
- package/dist/logic/actions/execute/canUpdateResource.js.map +1 -0
- package/dist/logic/actions/execute/executeProposal.d.ts +5 -0
- package/dist/logic/actions/execute/executeProposal.js +52 -0
- package/dist/logic/actions/execute/executeProposal.js.map +1 -0
- package/dist/logic/actions/propose/getColoredActionToken.d.ts +4 -0
- package/dist/logic/actions/propose/getColoredActionToken.js +22 -0
- package/dist/logic/actions/propose/getColoredActionToken.js.map +1 -0
- package/dist/logic/actions/propose/getColoredProposalTitle.d.ts +4 -0
- package/dist/logic/actions/propose/getColoredProposalTitle.js +34 -0
- package/dist/logic/actions/propose/getColoredProposalTitle.js.map +1 -0
- package/dist/logic/actions/propose/proposeChangeForResource.d.ts +7 -0
- package/dist/logic/actions/propose/proposeChangeForResource.js +65 -0
- package/dist/logic/actions/propose/proposeChangeForResource.js.map +1 -0
- package/dist/logic/actions/propose/proposeChangeForResource.test.d.ts +1 -0
- package/dist/logic/actions/propose/proposeChangeForResource.test.js +48 -0
- package/dist/logic/actions/propose/proposeChangeForResource.test.js.map +1 -0
- package/dist/logic/commands/command.apply.d.ts +8 -0
- package/dist/logic/commands/command.apply.js +77 -0
- package/dist/logic/commands/command.apply.js.map +1 -0
- package/dist/logic/commands/command.plan.d.ts +13 -0
- package/dist/logic/commands/command.plan.js +155 -0
- package/dist/logic/commands/command.plan.js.map +1 -0
- package/dist/logic/commands/execute.d.ts +15 -0
- package/dist/logic/commands/execute.js +63 -0
- package/dist/logic/commands/execute.js.map +1 -0
- package/dist/logic/tools/compare/castReferenceToGrokableString.d.ts +16 -0
- package/dist/logic/tools/compare/castReferenceToGrokableString.js +66 -0
- package/dist/logic/tools/compare/castReferenceToGrokableString.js.map +1 -0
- package/dist/logic/tools/compare/castReferenceToGrokableString.test.d.ts +1 -0
- package/dist/logic/tools/compare/castReferenceToGrokableString.test.js +111 -0
- package/dist/logic/tools/compare/castReferenceToGrokableString.test.js.map +1 -0
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.d.ts +11 -0
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.js +61 -0
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.js.map +1 -0
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.d.ts +1 -0
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js +31 -0
- package/dist/logic/tools/compare/detectDifferenceBetweenDesiredAndRemoteStateOfResource.test.js.map +1 -0
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.d.ts +21 -0
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.js +53 -0
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.js.map +1 -0
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.d.ts +1 -0
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.js +31 -0
- package/dist/logic/tools/compare/resolveReferenceToCommonComparableForm.test.js.map +1 -0
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.d.ts +10 -0
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.js +41 -0
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.js.map +1 -0
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.d.ts +1 -0
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.js +174 -0
- package/dist/logic/tools/compare/resolveReferencesToCommonComparableForm.test.js.map +1 -0
- package/dist/logic/tools/context/createDeclastructContext.d.ts +10 -0
- package/dist/logic/tools/context/createDeclastructContext.js +12 -0
- package/dist/logic/tools/context/createDeclastructContext.js.map +1 -0
- package/dist/logic/tools/context/destroyDeclastructContext.d.ts +4 -0
- package/dist/logic/tools/context/destroyDeclastructContext.js +10 -0
- package/dist/logic/tools/context/destroyDeclastructContext.js.map +1 -0
- package/dist/logic/tools/provider/castProviderContextToGlobalContext.d.ts +4 -0
- package/dist/logic/tools/provider/castProviderContextToGlobalContext.js +10 -0
- package/dist/logic/tools/provider/castProviderContextToGlobalContext.js.map +1 -0
- package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.d.ts +13 -0
- package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.js +29 -0
- package/dist/logic/tools/provider/getProviderContextFromGlobalContextForResourceClass.js.map +1 -0
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.d.ts +13 -0
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js +24 -0
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceExecutionDependenciesForResource.js.map +1 -0
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.d.ts +10 -0
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js +21 -0
- package/dist/logic/tools/provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass.js.map +1 -0
- package/dist/logic/tools/reference/buildPrimaryKeyTo.d.ts +5 -0
- package/dist/logic/tools/reference/buildPrimaryKeyTo.js +40 -0
- package/dist/logic/tools/reference/buildPrimaryKeyTo.js.map +1 -0
- package/dist/logic/tools/reference/buildReferenceTo.d.ts +28 -0
- package/dist/logic/tools/reference/buildReferenceTo.js +92 -0
- package/dist/logic/tools/reference/buildReferenceTo.js.map +1 -0
- package/dist/logic/tools/reference/buildReferenceTo.test.d.ts +1 -0
- package/dist/logic/tools/reference/buildReferenceTo.test.js +119 -0
- package/dist/logic/tools/reference/buildReferenceTo.test.js.map +1 -0
- package/dist/logic/tools/reference/buildUniqueKeyTo.d.ts +5 -0
- package/dist/logic/tools/reference/buildUniqueKeyTo.js +40 -0
- package/dist/logic/tools/reference/buildUniqueKeyTo.js.map +1 -0
- package/dist/logic/tools/reference/defineReferenceClassOf.d.ts +5 -0
- package/dist/logic/tools/reference/defineReferenceClassOf.js +25 -0
- package/dist/logic/tools/reference/defineReferenceClassOf.js.map +1 -0
- package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.d.ts +13 -0
- package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.js +36 -0
- package/dist/logic/tools/reference/defineReferenceKeyConstituentsOf.js.map +1 -0
- package/dist/logic/tools/reference/getByReference.d.ts +15 -0
- package/dist/logic/tools/reference/getByReference.js +55 -0
- package/dist/logic/tools/reference/getByReference.js.map +1 -0
- package/dist/logic/tools/reference/getByReference.test.d.ts +1 -0
- package/dist/logic/tools/reference/getByReference.test.js +92 -0
- package/dist/logic/tools/reference/getByReference.test.js.map +1 -0
- package/dist/logic/tools/reference/getByReferencedPrimaryKey.d.ts +6 -0
- package/dist/logic/tools/reference/getByReferencedPrimaryKey.js +17 -0
- package/dist/logic/tools/reference/getByReferencedPrimaryKey.js.map +1 -0
- package/dist/logic/tools/reference/getByReferencedUniqueKey.d.ts +7 -0
- package/dist/logic/tools/reference/getByReferencedUniqueKey.js +42 -0
- package/dist/logic/tools/reference/getByReferencedUniqueKey.js.map +1 -0
- package/dist/logic/tools/reference/getPrimaryKeyByReference.d.ts +15 -0
- package/dist/logic/tools/reference/getPrimaryKeyByReference.js +36 -0
- package/dist/logic/tools/reference/getPrimaryKeyByReference.js.map +1 -0
- package/dist/logic/tools/reference/getReferenceTo.d.ts +18 -0
- package/dist/logic/tools/reference/getReferenceTo.js +55 -0
- package/dist/logic/tools/reference/getReferenceTo.js.map +1 -0
- package/dist/logic/tools/reference/getReferenceTo.test.d.ts +1 -0
- package/dist/logic/tools/reference/getReferenceTo.test.js +95 -0
- package/dist/logic/tools/reference/getReferenceTo.test.js.map +1 -0
- package/dist/logic/tools/reference/getUniqueKeyByReference.d.ts +15 -0
- package/dist/logic/tools/reference/getUniqueKeyByReference.js +36 -0
- package/dist/logic/tools/reference/getUniqueKeyByReference.js.map +1 -0
- package/dist/logic/tools/reference/isPrimaryKeyReference.d.ts +6 -0
- package/dist/logic/tools/reference/isPrimaryKeyReference.js +7 -0
- package/dist/logic/tools/reference/isPrimaryKeyReference.js.map +1 -0
- package/dist/logic/tools/reference/isUniqueKeyReference.d.ts +6 -0
- package/dist/logic/tools/reference/isUniqueKeyReference.js +7 -0
- package/dist/logic/tools/reference/isUniqueKeyReference.js.map +1 -0
- package/package.json +100 -0
- package/readme.md +56 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const domain_objects_1 = require("domain-objects");
|
|
4
|
+
const buildReferenceTo_1 = require("./buildReferenceTo");
|
|
5
|
+
const getByReference_1 = require("./getByReference");
|
|
6
|
+
const getReferenceTo_1 = require("./getReferenceTo");
|
|
7
|
+
const log = console;
|
|
8
|
+
class CNCMachine extends domain_objects_1.DomainObject {
|
|
9
|
+
}
|
|
10
|
+
CNCMachine.primary = ['uuid'];
|
|
11
|
+
CNCMachine.unique = ['serialNumber'];
|
|
12
|
+
const exampleMachine = new CNCMachine({
|
|
13
|
+
uuid: 'de0e34ca-ce61-4884-ace5-093a1a32ff92',
|
|
14
|
+
serialNumber: '821',
|
|
15
|
+
size: 'big',
|
|
16
|
+
location: 'basement',
|
|
17
|
+
});
|
|
18
|
+
const cncMachineRemoteStateInterface = {
|
|
19
|
+
for: CNCMachine.name,
|
|
20
|
+
findByPrimary: async ({ uuid }) => {
|
|
21
|
+
if (uuid === exampleMachine.uuid)
|
|
22
|
+
return exampleMachine;
|
|
23
|
+
return null;
|
|
24
|
+
},
|
|
25
|
+
findByUnique: async ({ serialNumber }) => {
|
|
26
|
+
if (serialNumber === exampleMachine.serialNumber)
|
|
27
|
+
return exampleMachine;
|
|
28
|
+
return null;
|
|
29
|
+
},
|
|
30
|
+
create: () => Promise.reject(new Error('todo')),
|
|
31
|
+
destroy: () => Promise.reject(new Error('todo')),
|
|
32
|
+
};
|
|
33
|
+
const exampleContext = {
|
|
34
|
+
log,
|
|
35
|
+
providers: [
|
|
36
|
+
{
|
|
37
|
+
agentOptions: {},
|
|
38
|
+
interfaces: {
|
|
39
|
+
[cncMachineRemoteStateInterface.for]: cncMachineRemoteStateInterface,
|
|
40
|
+
}, // TODO: fix types to make this assertion not needed
|
|
41
|
+
hooks: {},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
resources: [], // no resources needed in context for this test
|
|
45
|
+
};
|
|
46
|
+
// todo: remove the declastruct references in favor of domain-object references
|
|
47
|
+
describe.skip('getByReference', () => {
|
|
48
|
+
it('should be able to find by autogenerated reference', async () => {
|
|
49
|
+
const autogeneratedReference = (0, getReferenceTo_1.getRef)(exampleMachine);
|
|
50
|
+
const resource = await (0, getByReference_1.getByReference)({
|
|
51
|
+
reference: autogeneratedReference,
|
|
52
|
+
}, exampleContext);
|
|
53
|
+
expect(resource).toBeInstanceOf(CNCMachine);
|
|
54
|
+
});
|
|
55
|
+
it('should be able to find by manually built primary key reference', async () => {
|
|
56
|
+
const primaryKeyReference = (0, buildReferenceTo_1.buildRef)(CNCMachine, {
|
|
57
|
+
uuid: exampleMachine.uuid,
|
|
58
|
+
});
|
|
59
|
+
const resource = await (0, getByReference_1.getByReference)({
|
|
60
|
+
reference: primaryKeyReference,
|
|
61
|
+
}, exampleContext);
|
|
62
|
+
expect(resource).toBeInstanceOf(CNCMachine);
|
|
63
|
+
});
|
|
64
|
+
it('should be able to find by manually built unique key reference', async () => {
|
|
65
|
+
const uniqueKeyReference = (0, buildReferenceTo_1.buildRef)(CNCMachine, {
|
|
66
|
+
serialNumber: exampleMachine.serialNumber,
|
|
67
|
+
});
|
|
68
|
+
const resource = await (0, getByReference_1.getByReference)({
|
|
69
|
+
reference: uniqueKeyReference,
|
|
70
|
+
}, exampleContext);
|
|
71
|
+
expect(resource).toBeInstanceOf(CNCMachine);
|
|
72
|
+
});
|
|
73
|
+
it('should return null if the resource does not exist in remote state by primary key', async () => {
|
|
74
|
+
const primaryKeyReference = (0, buildReferenceTo_1.buildRef)(CNCMachine, {
|
|
75
|
+
uuid: '__RANDO_UUID__',
|
|
76
|
+
});
|
|
77
|
+
const resource = await (0, getByReference_1.getByReference)({
|
|
78
|
+
reference: primaryKeyReference,
|
|
79
|
+
}, exampleContext);
|
|
80
|
+
expect(resource).toEqual(null);
|
|
81
|
+
});
|
|
82
|
+
it('should return null if the resource does not exist in remote state by unique key', async () => {
|
|
83
|
+
const uniqueKeyReference = (0, buildReferenceTo_1.buildRef)(CNCMachine, {
|
|
84
|
+
serialNumber: '__RANDO_SERIAL_NUMBER__',
|
|
85
|
+
});
|
|
86
|
+
const resource = await (0, getByReference_1.getByReference)({
|
|
87
|
+
reference: uniqueKeyReference,
|
|
88
|
+
}, exampleContext);
|
|
89
|
+
expect(resource).toEqual(null);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=getByReference.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getByReference.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getByReference.test.ts"],"names":[],"mappings":";;AAAA,mDAA8C;AAQ9C,yDAA8C;AAC9C,qDAAkD;AAClD,qDAA0C;AAE1C,MAAM,GAAG,G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E,SAAS,EAAE,mBAAmB;SAC/B,EACD,cAAc,CACf,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,iFAAiF,EAAE,KAAK,IAAI,EAAE;QAC/F,MAAM,kBAAkB,GAAwB,IAAA,2BAAQ,EAAC,UAAU,EAAE;YACnE,YAAY,EAAE,yBAAyB;SACxC,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAc,EACnC;YACE,SAAS,EAAE,kBAAkB;SAC9B,EACD,cAAc,CACf,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
2
|
+
import { DeclastructContext } from '../../../domain/DeclastructContext';
|
|
3
|
+
export declare const getByReferencedPrimaryKey: <R extends DeclaredResource, P extends keyof R>({ referenceOf, primaryKey, }: {
|
|
4
|
+
referenceOf: string;
|
|
5
|
+
primaryKey: Required<Pick<R, P>>;
|
|
6
|
+
}, context: DeclastructContext) => Promise<Required<R> | null>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getByReferencedPrimaryKey = void 0;
|
|
4
|
+
const getProviderContextFromGlobalContextForResourceClass_1 = require("../provider/getProviderContextFromGlobalContextForResourceClass");
|
|
5
|
+
const getProviderResourceRemoteStateInterfaceFromContextForResourceClass_1 = require("../provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass");
|
|
6
|
+
const getByReferencedPrimaryKey = ({ referenceOf, primaryKey, }, context) => {
|
|
7
|
+
// lookup the interface
|
|
8
|
+
const persistanceInterface = (0, getProviderResourceRemoteStateInterfaceFromContextForResourceClass_1.getProviderResourceRemoteStateInterfaceFromContextForResourceClass)({
|
|
9
|
+
resourceClassName: referenceOf,
|
|
10
|
+
}, context);
|
|
11
|
+
// lookup the provider context
|
|
12
|
+
const providerContext = (0, getProviderContextFromGlobalContextForResourceClass_1.getProviderContextFromGlobalContextForResourceClass)({ resourceClassName: referenceOf }, context);
|
|
13
|
+
// find by primary
|
|
14
|
+
return persistanceInterface.findByPrimary(primaryKey, providerContext);
|
|
15
|
+
};
|
|
16
|
+
exports.getByReferencedPrimaryKey = getByReferencedPrimaryKey;
|
|
17
|
+
//# sourceMappingURL=getByReferencedPrimaryKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getByReferencedPrimaryKey.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getByReferencedPrimaryKey.ts"],"names":[],"mappings":";;;AAEA,yIAAsI;AACtI,uKAAoK;AAE7J,MAAM,yBAAyB,GAAG,CAIvC,EACE,WAAW,EACX,UAAU,GAIX,EACD,OAA2B,EAC3B,EAAE;IACF,uBAAuB;IACvB,MAAM,oBAAoB,GACxB,IAAA,uIAAkE,EAMhE;QACE,iBAAiB,EAAE,WAAW;KAC/B,EACD,OAAO,CACR,CAAC;IAEJ,8BAA8B;IAC9B,MAAM,eAAe,GAAG,IAAA,yGAAmD,EACzE,EAAE,iBAAiB,EAAE,WAAW,EAAE,EAClC,OAAO,CACR,CAAC;IAEF,kBAAkB;IAClB,OAAO,oBAAoB,CAAC,aAAa,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AACzE,CAAC,CAAC;AAnCW,QAAA,yBAAyB,6BAmCpC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VisualogicContext } from 'visualogic';
|
|
2
|
+
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
3
|
+
import { DeclastructContext } from '../../../domain/DeclastructContext';
|
|
4
|
+
export declare const getByReferencedUniqueKey: <R extends DeclaredResource, U extends keyof R>({ referenceOf, uniqueKey, }: {
|
|
5
|
+
referenceOf: string;
|
|
6
|
+
uniqueKey: Required<Pick<R, U>>;
|
|
7
|
+
}, context: DeclastructContext & VisualogicContext) => Promise<Required<R> | null>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getByReferencedUniqueKey = void 0;
|
|
4
|
+
const getProviderContextFromGlobalContextForResourceClass_1 = require("../provider/getProviderContextFromGlobalContextForResourceClass");
|
|
5
|
+
const getProviderResourceRemoteStateInterfaceFromContextForResourceClass_1 = require("../provider/getProviderResourceRemoteStateInterfaceFromContextForResourceClass");
|
|
6
|
+
const getByReferencedUniqueKey = async ({ referenceOf, uniqueKey, }, context) => {
|
|
7
|
+
// lookup the interface
|
|
8
|
+
// const stopwatchOne = startDurationStopwatch(
|
|
9
|
+
// {
|
|
10
|
+
// for: `getByReferencedUniqueKey.ofClass::${referenceOf}.getInterface`,
|
|
11
|
+
// log: { level: LogLevel.INFO, threshold: { milliseconds: 1 } },
|
|
12
|
+
// },
|
|
13
|
+
// context,
|
|
14
|
+
// );
|
|
15
|
+
const persistanceInterface = (0, getProviderResourceRemoteStateInterfaceFromContextForResourceClass_1.getProviderResourceRemoteStateInterfaceFromContextForResourceClass)({
|
|
16
|
+
resourceClassName: referenceOf,
|
|
17
|
+
}, context);
|
|
18
|
+
// stopwatchOne.stop();
|
|
19
|
+
// lookup the provider context
|
|
20
|
+
// const stopwatchTwo = startDurationStopwatch(
|
|
21
|
+
// {
|
|
22
|
+
// for: `getByReferencedUniqueKey.ofClass::${referenceOf}.getContext`,
|
|
23
|
+
// log: { level: LogLevel.INFO, threshold: { milliseconds: 1 } },
|
|
24
|
+
// },
|
|
25
|
+
// context,
|
|
26
|
+
// );
|
|
27
|
+
const providerContext = (0, getProviderContextFromGlobalContextForResourceClass_1.getProviderContextFromGlobalContextForResourceClass)({ resourceClassName: referenceOf }, context);
|
|
28
|
+
// stopwatchTwo.stop();
|
|
29
|
+
// find by unique
|
|
30
|
+
// const stopwatchThree = startDurationStopwatch(
|
|
31
|
+
// {
|
|
32
|
+
// for: `getByReferencedUniqueKey.ofClass::${referenceOf}:persistanceInterface.findByUnique`,
|
|
33
|
+
// log: { level: LogLevel.INFO, threshold: { milliseconds: 1 } },
|
|
34
|
+
// },
|
|
35
|
+
// context,
|
|
36
|
+
// );
|
|
37
|
+
const result = await persistanceInterface.findByUnique(uniqueKey, providerContext);
|
|
38
|
+
// stopwatchThree.stop();
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
exports.getByReferencedUniqueKey = getByReferencedUniqueKey;
|
|
42
|
+
//# sourceMappingURL=getByReferencedUniqueKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getByReferencedUniqueKey.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getByReferencedUniqueKey.ts"],"names":[],"mappings":";;;AAIA,yIAAsI;AACtI,uKAAoK;AAE7J,MAAM,wBAAwB,GAAG,KAAK,EAI3C,EACE,WAAW,EACX,SAAS,GAIV,EACD,OAA+C,EAC/C,EAAE;IACF,uBAAuB;IACvB,+CAA+C;IAC/C,MAAM;IACN,4EAA4E;IAC5E,qEAAqE;IACrE,OAAO;IACP,aAAa;IACb,KAAK;IACL,MAAM,oBAAoB,GACxB,IAAA,uIAAkE,EAMhE;QACE,iBAAiB,EAAE,WAAW;KAC/B,EACD,OAAO,CACR,CAAC;IACJ,uBAAuB;IAEvB,8BAA8B;IAC9B,+CAA+C;IAC/C,MAAM;IACN,0EAA0E;IAC1E,qEAAqE;IACrE,OAAO;IACP,aAAa;IACb,KAAK;IACL,MAAM,eAAe,GAAG,IAAA,yGAAmD,EACzE,EAAE,iBAAiB,EAAE,WAAW,EAAE,EAClC,OAAO,CACR,CAAC;IACF,uBAAuB;IAEvB,iBAAiB;IACjB,iDAAiD;IACjD,MAAM;IACN,iGAAiG;IACjG,qEAAqE;IACrE,OAAO;IACP,aAAa;IACb,KAAK;IACL,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,YAAY,CACpD,SAAS,EACT,eAAe,CAChB,CAAC;IACF,yBAAyB;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA/DW,QAAA,wBAAwB,4BA+DnC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VisualogicContext } from 'visualogic';
|
|
2
|
+
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
3
|
+
import { DeclaredResourceReference } from '../../../domain/DeclaredResourceReference';
|
|
4
|
+
import { DeclastructContext } from '../../../domain/DeclastructContext';
|
|
5
|
+
/**
|
|
6
|
+
* tactic: gets the primary key of a resource by reference
|
|
7
|
+
* strategy
|
|
8
|
+
* - if reference is identified by primary key, then return it
|
|
9
|
+
* - if reference is identified by unique key, then get the resource by reference, and build the primary key from it
|
|
10
|
+
* usecase
|
|
11
|
+
* - speed up unique key resolution by returning it from the reference if already present, preventing redundant downstream calls
|
|
12
|
+
*/
|
|
13
|
+
export declare const getPrimaryKeyByReference: <T extends DeclaredResource, P extends keyof T, U extends keyof T>({ reference, }: {
|
|
14
|
+
reference: DeclaredResourceReference<T, P, U>;
|
|
15
|
+
}, context: DeclastructContext & VisualogicContext) => Promise<Required<Pick<T, P>>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrimaryKeyByReference = void 0;
|
|
4
|
+
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
5
|
+
const error_fns_2 = require("@ehmpathy/error-fns");
|
|
6
|
+
const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
|
|
7
|
+
const buildPrimaryKeyTo_1 = require("./buildPrimaryKeyTo");
|
|
8
|
+
const getByReference_1 = require("./getByReference");
|
|
9
|
+
/**
|
|
10
|
+
* tactic: gets the primary key of a resource by reference
|
|
11
|
+
* strategy
|
|
12
|
+
* - if reference is identified by primary key, then return it
|
|
13
|
+
* - if reference is identified by unique key, then get the resource by reference, and build the primary key from it
|
|
14
|
+
* usecase
|
|
15
|
+
* - speed up unique key resolution by returning it from the reference if already present, preventing redundant downstream calls
|
|
16
|
+
*/
|
|
17
|
+
const getPrimaryKeyByReference = async ({ reference, }, context) => {
|
|
18
|
+
// if reference is by primary key, return the value
|
|
19
|
+
if (reference.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.PRIMARY_KEY)
|
|
20
|
+
return reference.identifiedBy.value;
|
|
21
|
+
// if reference is by unique key, get the resource by reference and build the primary key from it
|
|
22
|
+
if (reference.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY) {
|
|
23
|
+
const resource = await (0, getByReference_1.getByReference)({ reference }, context);
|
|
24
|
+
if (!resource)
|
|
25
|
+
throw new error_fns_1.BadRequestError(
|
|
26
|
+
// todo: make this a typed error
|
|
27
|
+
'could not find resource by unique-key reference to getPrimaryKeyByReference', { reference });
|
|
28
|
+
return (0, buildPrimaryKeyTo_1.buildPrimaryKeyTo)(resource.constructor, resource);
|
|
29
|
+
}
|
|
30
|
+
// otherwise, resource reference was declared incorrectly. this should not happen due to types
|
|
31
|
+
throw new error_fns_2.UnexpectedCodePathError('invalid resource reference declaration', {
|
|
32
|
+
reference,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.getPrimaryKeyByReference = getPrimaryKeyByReference;
|
|
36
|
+
//# sourceMappingURL=getPrimaryKeyByReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPrimaryKeyByReference.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getPrimaryKeyByReference.ts"],"names":[],"mappings":";;;AAAA,mDAAsD;AACtD,mDAA8D;AAI9D,yFAGmD;AAEnD,2DAAwD;AACxD,qDAAkD;AAElD;;;;;;;GAOG;AACI,MAAM,wBAAwB,GAAG,KAAK,EAK3C,EACE,SAAS,GAGV,EACD,OAA+C,EAChB,EAAE;IACjC,mDAAmD;IACnD,IACE,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,4DAAgC,CAAC,WAAW;QAE3E,OAAO,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC;IAEtC,iGAAiG;IACjG,IACE,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,4DAAgC,CAAC,UAAU,EAC1E,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAc,EAAC,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,2BAAe;YACvB,gCAAgC;YAChC,6EAA6E,EAC7E,EAAE,SAAS,EAAE,CACd,CAAC;QACJ,OAAO,IAAA,qCAAiB,EAAC,QAAQ,CAAC,WAAkB,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED,8FAA8F;IAC9F,MAAM,IAAI,mCAAuB,CAAC,wCAAwC,EAAE;QAC1E,SAAS;KACV,CAAC,CAAC;AACL,CAAC,CAAC;AApCW,QAAA,wBAAwB,4BAoCnC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DomainObject } from 'domain-objects';
|
|
2
|
+
import { DeclaredResourceReference } from '../../../domain/DeclaredResourceReference';
|
|
3
|
+
export declare class CanNotReferenceDeclaredResourceError extends Error {
|
|
4
|
+
constructor({ resource, reason, }: {
|
|
5
|
+
resource: DomainObject<any>;
|
|
6
|
+
reason: string;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* returns a reference to a resource
|
|
11
|
+
* - uses the primary key if possible
|
|
12
|
+
* - uses the unique key otherwise
|
|
13
|
+
*
|
|
14
|
+
* note
|
|
15
|
+
* - this is a convinience wrapper for the function `buildReferenceTo`
|
|
16
|
+
*/
|
|
17
|
+
export declare const getReferenceTo: <T extends DomainObject<any>, P extends keyof T, U extends keyof T>(resource: T) => DeclaredResourceReference<T, P, U>;
|
|
18
|
+
export { getReferenceTo as getRef };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRef = exports.getReferenceTo = exports.CanNotReferenceDeclaredResourceError = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
const buildReferenceTo_1 = require("./buildReferenceTo");
|
|
6
|
+
class CanNotReferenceDeclaredResourceError extends Error {
|
|
7
|
+
constructor({ resource, reason, }) {
|
|
8
|
+
super(`
|
|
9
|
+
Can not reference declared resource ${resource.constructor?.name
|
|
10
|
+
? `of class '${resource.constructor.name}'`
|
|
11
|
+
: ''} because ${reason}.
|
|
12
|
+
|
|
13
|
+
resource
|
|
14
|
+
${JSON.stringify(resource, null, 2)}
|
|
15
|
+
`.trim());
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.CanNotReferenceDeclaredResourceError = CanNotReferenceDeclaredResourceError;
|
|
19
|
+
/**
|
|
20
|
+
* returns a reference to a resource
|
|
21
|
+
* - uses the primary key if possible
|
|
22
|
+
* - uses the unique key otherwise
|
|
23
|
+
*
|
|
24
|
+
* note
|
|
25
|
+
* - this is a convinience wrapper for the function `buildReferenceTo`
|
|
26
|
+
*/
|
|
27
|
+
const getReferenceTo = (resource) => {
|
|
28
|
+
// confirm that it is an instance of a domain object
|
|
29
|
+
if (!(resource instanceof domain_objects_1.DomainObject))
|
|
30
|
+
throw new CanNotReferenceDeclaredResourceError({
|
|
31
|
+
resource,
|
|
32
|
+
reason: 'the resource is not an instance of a DomainObject class',
|
|
33
|
+
});
|
|
34
|
+
// confirm that it is an instance of a domain entity
|
|
35
|
+
if (!(resource instanceof domain_objects_1.DomainEntity))
|
|
36
|
+
throw new CanNotReferenceDeclaredResourceError({
|
|
37
|
+
resource,
|
|
38
|
+
reason: 'the resource is not an instance of a DomainEntity class. only Entities have distinct state of their own',
|
|
39
|
+
});
|
|
40
|
+
// try to build the reference
|
|
41
|
+
try {
|
|
42
|
+
return (0, buildReferenceTo_1.buildReferenceTo)(resource.constructor, resource);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (error instanceof buildReferenceTo_1.CanNotBuildReferenceError)
|
|
46
|
+
throw new CanNotReferenceDeclaredResourceError({
|
|
47
|
+
resource,
|
|
48
|
+
reason: 'neither the primary key nor unique key is present in the resource',
|
|
49
|
+
});
|
|
50
|
+
throw error; // otherwise, forward the error
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.getReferenceTo = getReferenceTo;
|
|
54
|
+
exports.getRef = exports.getReferenceTo;
|
|
55
|
+
//# sourceMappingURL=getReferenceTo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReferenceTo.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getReferenceTo.ts"],"names":[],"mappings":";;;AAAA,mDAA4D;AAG5D,yDAG4B;AAE5B,MAAa,oCAAqC,SAAQ,KAAK;IAC7D,YAAY,EACV,QAAQ,EACR,MAAM,GAIP;QACC,KAAK,CACH;sCAEE,QAAQ,CAAC,WAAW,EAAE,IAAI;YACxB,CAAC,CAAC,aAAa,QAAQ,CAAC,WAAW,CAAC,IAAI,GAAG;YAC3C,CAAC,CAAC,EACN,YAAY,MAAM;;;EAGtB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;KAC9B,CAAC,IAAI,EAAE,CACP,CAAC;IACJ,CAAC;CACF;AArBD,oFAqBC;AACD;;;;;;;GAOG;AACI,MAAM,cAAc,GAAG,CAW5B,QAAW,EACyB,EAAE;IACtC,oDAAoD;IACpD,IAAI,CAAC,CAAC,QAAQ,YAAY,6BAAY,CAAC;QACrC,MAAM,IAAI,oCAAoC,CAAC;YAC7C,QAAQ;YACR,MAAM,EAAE,yDAAyD;SAClE,CAAC,CAAC;IAEL,oDAAoD;IACpD,IAAI,CAAC,CAAC,QAAQ,YAAY,6BAAY,CAAC;QACrC,MAAM,IAAI,oCAAoC,CAAC;YAC7C,QAAQ;YACR,MAAM,EACJ,yGAAyG;SAC5G,CAAC,CAAC;IAEL,6BAA6B;IAC7B,IAAI,CAAC;QACH,OAAO,IAAA,mCAAgB,EAAC,QAAQ,CAAC,WAAkB,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,YAAY,4CAAyB;YAC5C,MAAM,IAAI,oCAAoC,CAAC;gBAC7C,QAAQ;gBACR,MAAM,EACJ,mEAAmE;aACtE,CAAC,CAAC;QACL,MAAM,KAAK,CAAC,CAAC,+BAA+B;IAC9C,CAAC;AACH,CAAC,CAAC;AAxCW,QAAA,cAAc,kBAwCzB;AAEyB,iBA1Cd,sBAAc,CA0CM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const domain_objects_1 = require("domain-objects");
|
|
4
|
+
const buildReferenceTo_1 = require("./buildReferenceTo");
|
|
5
|
+
const getReferenceTo_1 = require("./getReferenceTo");
|
|
6
|
+
// todo: remove the declastruct references in favor of domain-object references
|
|
7
|
+
describe.skip('getReferenceTo', () => {
|
|
8
|
+
it('should throw a helpful error if the resource is not an instance of a domain object', () => {
|
|
9
|
+
try {
|
|
10
|
+
(0, getReferenceTo_1.getReferenceTo)({ name: 'bob', age: 21 });
|
|
11
|
+
throw new Error('should not reach here');
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
expect(error).toBeInstanceOf(getReferenceTo_1.CanNotReferenceDeclaredResourceError);
|
|
15
|
+
expect(error.message).toContain('resource is not an instance of a');
|
|
16
|
+
expect(error).toMatchSnapshot();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
it('should throw a helpful error the class does not have unique key defined', () => {
|
|
20
|
+
class CNCMachine extends domain_objects_1.DomainObject {
|
|
21
|
+
}
|
|
22
|
+
CNCMachine.primary = ['uuid'];
|
|
23
|
+
try {
|
|
24
|
+
(0, getReferenceTo_1.getReferenceTo)(new CNCMachine({
|
|
25
|
+
serialNumber: '821',
|
|
26
|
+
size: 'big',
|
|
27
|
+
location: 'basement',
|
|
28
|
+
}));
|
|
29
|
+
throw new Error('should not reach here');
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
expect(error).toBeInstanceOf(buildReferenceTo_1.CanNotReferenceDeclaredResourceClassError);
|
|
33
|
+
expect(error.message).toContain(`the static property 'unique' was not defined as an array of strings`);
|
|
34
|
+
expect(error).toMatchSnapshot();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
it('should throw a helpful error the class does not have primary key defined correctly', () => {
|
|
38
|
+
class CNCMachine extends domain_objects_1.DomainObject {
|
|
39
|
+
}
|
|
40
|
+
CNCMachine.primary = 'uuid';
|
|
41
|
+
try {
|
|
42
|
+
(0, getReferenceTo_1.getReferenceTo)(new CNCMachine({
|
|
43
|
+
serialNumber: '821',
|
|
44
|
+
size: 'big',
|
|
45
|
+
location: 'basement',
|
|
46
|
+
}));
|
|
47
|
+
throw new Error('should not reach here');
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
expect(error).toBeInstanceOf(getReferenceTo_1.CanNotReferenceDeclaredResourceError);
|
|
51
|
+
expect(error.message).toContain(`the static property 'primary' was not defined as an array of strings`);
|
|
52
|
+
expect(error).toMatchSnapshot();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
it('should be able to reference by unique key', () => {
|
|
56
|
+
class CNCMachine extends domain_objects_1.DomainObject {
|
|
57
|
+
}
|
|
58
|
+
CNCMachine.primary = ['uuid'];
|
|
59
|
+
CNCMachine.unique = ['serialNumber'];
|
|
60
|
+
const reference = (0, getReferenceTo_1.getReferenceTo)(new CNCMachine({
|
|
61
|
+
serialNumber: '821',
|
|
62
|
+
size: 'big',
|
|
63
|
+
location: 'basement',
|
|
64
|
+
}));
|
|
65
|
+
expect(reference).toEqual({
|
|
66
|
+
referenceOf: 'CNCMachine',
|
|
67
|
+
identifiedBy: {
|
|
68
|
+
key: 'UNIQUE_KEY',
|
|
69
|
+
value: { serialNumber: '821' },
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
expect(reference).toMatchSnapshot(); // log for viewing
|
|
73
|
+
});
|
|
74
|
+
it('should reference by primary key if posible', () => {
|
|
75
|
+
class CNCMachine extends domain_objects_1.DomainObject {
|
|
76
|
+
}
|
|
77
|
+
CNCMachine.primary = ['uuid'];
|
|
78
|
+
CNCMachine.unique = ['serialNumber'];
|
|
79
|
+
const reference = (0, getReferenceTo_1.getReferenceTo)(new CNCMachine({
|
|
80
|
+
uuid: 'de0e34ca-ce61-4884-ace5-093a1a32ff92',
|
|
81
|
+
serialNumber: '821',
|
|
82
|
+
size: 'big',
|
|
83
|
+
location: 'basement',
|
|
84
|
+
}));
|
|
85
|
+
expect(reference).toEqual({
|
|
86
|
+
referenceOf: 'CNCMachine',
|
|
87
|
+
identifiedBy: {
|
|
88
|
+
key: 'PRIMARY_KEY',
|
|
89
|
+
value: { uuid: 'de0e34ca-ce61-4884-ace5-093a1a32ff92' },
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
expect(reference).toMatchSnapshot(); // log for viewing
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=getReferenceTo.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReferenceTo.test.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getReferenceTo.test.ts"],"names":[],"mappings":";;AAAA,mDAA8C;AAE9C,yDAA+E;AAC/E,qDAG0B;AAE1B,+EAA+E;AAC/E,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,o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AS,GAAG,IAAA,+BAAc,EAC9B,IAAI,UAAU,CAAC;YACb,IAAI,EAAE,sCAAsC;YAC5C,YAAY,EAAE,KAAK;YACnB,IAAI,EAAE,KAAK;YACX,QAAQ,EAAE,UAAU;SACrB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;YACxB,WAAW,EAAE,YAAY;YACzB,YAAY,EAAE;gBACZ,GAAG,EAAE,aAAa;gBAClB,KAAK,EAAE,EAAE,IAAI,EAAE,sCAAsC,EAAE;aACxD;SACF,CAAC,CAAC;QACH,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,kBAAkB;IACzD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { VisualogicContext } from 'visualogic';
|
|
2
|
+
import { DeclaredResource } from '../../../domain/DeclaredResource';
|
|
3
|
+
import { DeclaredResourceReference } from '../../../domain/DeclaredResourceReference';
|
|
4
|
+
import { DeclastructContext } from '../../../domain/DeclastructContext';
|
|
5
|
+
/**
|
|
6
|
+
* tactic: gets the unique key of a resource by reference
|
|
7
|
+
* strategy
|
|
8
|
+
* - if reference is identified by unique key, then return it
|
|
9
|
+
* - if reference is identified by primary key, then get the resource by reference, and build the unique key from it
|
|
10
|
+
* usecase
|
|
11
|
+
* - speed up unique key resolution by returning it from the reference if already present, preventing redundant downstream calls
|
|
12
|
+
*/
|
|
13
|
+
export declare const getUniqueKeyByReference: <T extends DeclaredResource, P extends keyof T, U extends keyof T>({ reference, }: {
|
|
14
|
+
reference: DeclaredResourceReference<T, P, U>;
|
|
15
|
+
}, context: DeclastructContext & VisualogicContext) => Promise<Required<Pick<T, U>>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUniqueKeyByReference = void 0;
|
|
4
|
+
const error_fns_1 = require("@ehmpathy/error-fns");
|
|
5
|
+
const error_fns_2 = require("@ehmpathy/error-fns");
|
|
6
|
+
const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
|
|
7
|
+
const buildUniqueKeyTo_1 = require("./buildUniqueKeyTo");
|
|
8
|
+
const getByReference_1 = require("./getByReference");
|
|
9
|
+
/**
|
|
10
|
+
* tactic: gets the unique key of a resource by reference
|
|
11
|
+
* strategy
|
|
12
|
+
* - if reference is identified by unique key, then return it
|
|
13
|
+
* - if reference is identified by primary key, then get the resource by reference, and build the unique key from it
|
|
14
|
+
* usecase
|
|
15
|
+
* - speed up unique key resolution by returning it from the reference if already present, preventing redundant downstream calls
|
|
16
|
+
*/
|
|
17
|
+
const getUniqueKeyByReference = async ({ reference, }, context) => {
|
|
18
|
+
// if reference is by unique key, return the value
|
|
19
|
+
if (reference.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY)
|
|
20
|
+
return reference.identifiedBy.value;
|
|
21
|
+
// if reference is by primary key, get the resource by reference and build the primary key from it
|
|
22
|
+
if (reference.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.PRIMARY_KEY) {
|
|
23
|
+
const resource = await (0, getByReference_1.getByReference)({ reference }, context);
|
|
24
|
+
if (!resource)
|
|
25
|
+
throw new error_fns_1.BadRequestError(
|
|
26
|
+
// todo: make this a typed error
|
|
27
|
+
'could not find resource by primary-key reference to getUniqueKeyByReference', { reference });
|
|
28
|
+
return (0, buildUniqueKeyTo_1.buildUniqueKeyTo)(resource.constructor, resource);
|
|
29
|
+
}
|
|
30
|
+
// otherwise, resource reference was declared incorrectly. this should not happen due to types
|
|
31
|
+
throw new error_fns_2.UnexpectedCodePathError('invalid resource reference declaration', {
|
|
32
|
+
reference,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.getUniqueKeyByReference = getUniqueKeyByReference;
|
|
36
|
+
//# sourceMappingURL=getUniqueKeyByReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUniqueKeyByReference.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/getUniqueKeyByReference.ts"],"names":[],"mappings":";;;AAAA,mDAAsD;AACtD,mDAA8D;AAI9D,yFAGmD;AAEnD,yDAAsD;AACtD,qDAAkD;AAElD;;;;;;;GAOG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAK1C,EACE,SAAS,GAGV,EACD,OAA+C,EAChB,EAAE;IACjC,kDAAkD;IAClD,IACE,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,4DAAgC,CAAC,UAAU;QAE1E,OAAO,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC;IAEtC,kGAAkG;IAClG,IACE,SAAS,CAAC,YAAY,CAAC,GAAG,KAAK,4DAAgC,CAAC,WAAW,EAC3E,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,+BAAc,EAAC,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ;YACX,MAAM,IAAI,2BAAe;YACvB,gCAAgC;YAChC,6EAA6E,EAC7E,EAAE,SAAS,EAAE,CACd,CAAC;QACJ,OAAO,IAAA,mCAAgB,EAAC,QAAQ,CAAC,WAAkB,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,8FAA8F;IAC9F,MAAM,IAAI,mCAAuB,CAAC,wCAAwC,EAAE;QAC1E,SAAS;KACV,CAAC,CAAC;AACL,CAAC,CAAC;AApCW,QAAA,uBAAuB,2BAoClC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeclaredResourceReference, DeclaredResourceReferenceKeyType } from '../../../domain/DeclaredResourceReference';
|
|
2
|
+
export declare const isPrimaryKeyReference: <T, P extends keyof T, U extends keyof T>(ref: DeclaredResourceReference<T, P, U>) => ref is DeclaredResourceReference<T, P, U> & {
|
|
3
|
+
identifiedBy: {
|
|
4
|
+
key: DeclaredResourceReferenceKeyType.PRIMARY_KEY;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPrimaryKeyReference = void 0;
|
|
4
|
+
const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
|
|
5
|
+
const isPrimaryKeyReference = (ref) => ref.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.PRIMARY_KEY;
|
|
6
|
+
exports.isPrimaryKeyReference = isPrimaryKeyReference;
|
|
7
|
+
//# sourceMappingURL=isPrimaryKeyReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPrimaryKeyReference.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/isPrimaryKeyReference.ts"],"names":[],"mappings":";;;AAAA,yFAGmD;AAE5C,MAAM,qBAAqB,GAAG,CAWnC,GAAuC,EAGvC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,KAAK,4DAAgC,CAAC,WAAW,CAAC;AAd9D,QAAA,qBAAqB,yBAcyC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeclaredResourceReference, DeclaredResourceReferenceKeyType } from '../../../domain/DeclaredResourceReference';
|
|
2
|
+
export declare const isUniqueKeyReference: <T, P extends keyof T, U extends keyof T>(ref: DeclaredResourceReference<T, P, U>) => ref is DeclaredResourceReference<T, P, U> & {
|
|
3
|
+
identifiedBy: {
|
|
4
|
+
key: DeclaredResourceReferenceKeyType.UNIQUE_KEY;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isUniqueKeyReference = void 0;
|
|
4
|
+
const DeclaredResourceReference_1 = require("../../../domain/DeclaredResourceReference");
|
|
5
|
+
const isUniqueKeyReference = (ref) => ref.identifiedBy.key === DeclaredResourceReference_1.DeclaredResourceReferenceKeyType.UNIQUE_KEY;
|
|
6
|
+
exports.isUniqueKeyReference = isUniqueKeyReference;
|
|
7
|
+
//# sourceMappingURL=isUniqueKeyReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isUniqueKeyReference.js","sourceRoot":"","sources":["../../../../src/logic/tools/reference/isUniqueKeyReference.ts"],"names":[],"mappings":";;;AAAA,yFAGmD;AAE5C,MAAM,oBAAoB,GAAG,CAWlC,GAAuC,EAGvC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,KAAK,4DAAgC,CAAC,UAAU,CAAC;AAd7D,QAAA,oBAAoB,wBAcyC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "declastruct",
|
|
3
|
+
"author": "ehmpathy",
|
|
4
|
+
"description": "Add declarative control to any resource constructs. Declare, plan, and apply within an observable pit-of-success.",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"repository": "ehmpathy/declastruct",
|
|
7
|
+
"homepage": "https://github.com/ehmpathy/declastruct",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"role",
|
|
10
|
+
"organization",
|
|
11
|
+
"crew",
|
|
12
|
+
"agent"
|
|
13
|
+
],
|
|
14
|
+
"bugs": "https://github.com/ehmpathy/declastruct/issues",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=8.0.0"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"/dist"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build:ts": "tsc -p ./tsconfig.build.json",
|
|
25
|
+
"commit:with-cli": "npx cz",
|
|
26
|
+
"fix:format:prettier": "prettier --write '**/*.ts' --config ./prettier.config.js",
|
|
27
|
+
"fix:format": "npm run fix:format:prettier",
|
|
28
|
+
"fix:lint": "eslint -c ./.eslintrc.js src/**/*.ts --fix",
|
|
29
|
+
"build:clean": "rm dist/ -rf",
|
|
30
|
+
"build:compile": "tsc -p ./tsconfig.build.json",
|
|
31
|
+
"build": "npm run build:clean && npm run build:compile",
|
|
32
|
+
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
33
|
+
"test:types": "tsc -p ./tsconfig.build.json --noEmit",
|
|
34
|
+
"test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
|
|
35
|
+
"test:format": "npm run test:format:prettier",
|
|
36
|
+
"test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
|
|
37
|
+
"test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
|
|
38
|
+
"test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
|
|
39
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
|
|
40
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
|
|
41
|
+
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
42
|
+
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
43
|
+
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
44
|
+
"prepush": "npm run test && npm run build",
|
|
45
|
+
"prepublish": "npm run build",
|
|
46
|
+
"preversion": "npm run prepush",
|
|
47
|
+
"postversion": "git push origin HEAD --tags --no-verify",
|
|
48
|
+
"postinstall": "[ -d .git ] && npm run prepare:husky || exit 0",
|
|
49
|
+
"prepare:husky": "npx husky install && chmod ug+x .husky/*"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@ehmpathy/error-fns": "1.3.7",
|
|
53
|
+
"@ehmpathy/number-fns": "1.0.1",
|
|
54
|
+
"bottleneck": "2.19.5",
|
|
55
|
+
"chalk": "5.4.1",
|
|
56
|
+
"deep-object-diff": "1.1.9",
|
|
57
|
+
"domain-objects": "0.24.3",
|
|
58
|
+
"flattie": "1.1.1",
|
|
59
|
+
"indent-string": "5.0.0",
|
|
60
|
+
"jest-diff": "30.0.2",
|
|
61
|
+
"joi": "17.13.3",
|
|
62
|
+
"ora": "5.4.1",
|
|
63
|
+
"simple-in-memory-cache": "0.4.0",
|
|
64
|
+
"type-fns": "1.19.0",
|
|
65
|
+
"uuid-fns": "1.0.0",
|
|
66
|
+
"visualogic": "1.3.2",
|
|
67
|
+
"with-simple-caching": "0.14.1"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@commitlint/cli": "19.3.0",
|
|
71
|
+
"@commitlint/config-conventional": "13.1.0",
|
|
72
|
+
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
73
|
+
"@tsconfig/node-lts-strictest": "18.12.1",
|
|
74
|
+
"@types/jest": "29.2.4",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
76
|
+
"@typescript-eslint/parser": "7.8.0",
|
|
77
|
+
"core-js": "3.26.1",
|
|
78
|
+
"cz-conventional-changelog": "3.3.0",
|
|
79
|
+
"declapract": "0.12.0",
|
|
80
|
+
"declapract-typescript-ehmpathy": "0.39.5",
|
|
81
|
+
"depcheck": "1.4.3",
|
|
82
|
+
"eslint": "8.56.0",
|
|
83
|
+
"eslint-config-airbnb-typescript": "18.0.0",
|
|
84
|
+
"eslint-config-prettier": "8.5.0",
|
|
85
|
+
"eslint-plugin-import": "2.26.0",
|
|
86
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
87
|
+
"husky": "8.0.3",
|
|
88
|
+
"jest": "29.3.1",
|
|
89
|
+
"prettier": "2.8.1",
|
|
90
|
+
"simple-leveled-log-methods": "0.4.1",
|
|
91
|
+
"ts-jest": "29.1.3",
|
|
92
|
+
"ts-node": "10.9.2",
|
|
93
|
+
"typescript": "5.4.5"
|
|
94
|
+
},
|
|
95
|
+
"config": {
|
|
96
|
+
"commitizen": {
|
|
97
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|