declastruct 1.1.9 → 1.1.11
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/dist/domain.objects/DeclastructDao.d.ts +11 -7
- package/dist/domain.objects/DeclastructDao.js.map +1 -1
- package/dist/domain.objects/DeclastructDao.test.js +36 -0
- package/dist/domain.objects/DeclastructDao.test.js.map +1 -1
- package/dist/domain.objects/DeclastructProvider.test.js +45 -0
- package/dist/domain.objects/DeclastructProvider.test.js.map +1 -1
- package/dist/domain.operations/plan/computeChange.js +14 -4
- package/dist/domain.operations/plan/computeChange.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,37 +2,41 @@ import { DomainEntity, DomainLiteral, Ref, Refable, RefByPrimary, RefByUnique }
|
|
|
2
2
|
import { HasMetadata } from 'type-fns';
|
|
3
3
|
/**
|
|
4
4
|
* .what = standardized data access interface for any resource type
|
|
5
|
+
*
|
|
5
6
|
* .why = enforces idempotent semantics and consistent access patterns across all providers
|
|
6
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* .note =
|
|
9
|
+
* - TResourceClass is the class constructor (e.g., typeof MyResource) with static unique/primary properties
|
|
10
|
+
* - uses method syntax in the get & set for bivariance, to enable assignment to DeclastructDao<any, any, any>
|
|
7
11
|
*/
|
|
8
12
|
export interface DeclastructDao<TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext = never> {
|
|
9
13
|
get: {
|
|
10
14
|
/**
|
|
11
15
|
* required - fetch by unique keys (enables idempotency)
|
|
12
16
|
*/
|
|
13
|
-
byUnique
|
|
17
|
+
byUnique(input: RefByUnique<TResourceClass>, context: TContext): Promise<TResource | null>;
|
|
14
18
|
/**
|
|
15
19
|
* optional - fetch by primary keys (if resource supports them)
|
|
16
20
|
*/
|
|
17
|
-
byPrimary
|
|
21
|
+
byPrimary?(input: RefByPrimary<TResourceClass>, context: TContext): Promise<TResource | null>;
|
|
18
22
|
/**
|
|
19
23
|
* required - fetch by any supported reference type
|
|
20
24
|
*/
|
|
21
|
-
byRef
|
|
25
|
+
byRef(input: Ref<TResourceClass>, context: TContext): Promise<TResource | null>;
|
|
22
26
|
};
|
|
23
27
|
set: {
|
|
24
28
|
/**
|
|
25
29
|
* required - find or insert resource (idempotent create)
|
|
26
30
|
*/
|
|
27
|
-
finsert
|
|
31
|
+
finsert(input: TResource, context: TContext): Promise<HasMetadata<TResource>>;
|
|
28
32
|
/**
|
|
29
33
|
* optional - create or update resource (idempotent upsert)
|
|
30
34
|
*/
|
|
31
|
-
upsert
|
|
35
|
+
upsert?(input: TResource, context: TContext): Promise<HasMetadata<TResource>>;
|
|
32
36
|
/**
|
|
33
37
|
* optional - delete resource
|
|
34
38
|
*/
|
|
35
|
-
delete
|
|
39
|
+
delete?(input: Ref<TResourceClass>, context: TContext): Promise<void>;
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
export declare class DeclastructDao<TResource extends DomainEntity<any>, TResourceClass extends Refable<any, any, any>, TContext> extends DomainLiteral<DeclastructDao<TResource, TResourceClass, TContext>> implements DeclastructDao<TResource, TResourceClass, TContext> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclastructDao.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.ts"],"names":[],"mappings":";;;AAAA,mDAOwB;
|
|
1
|
+
{"version":3,"file":"DeclastructDao.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.ts"],"names":[],"mappings":";;;AAAA,mDAOwB;AAmExB,MAAa,cAKX,SAAQ,8BAAkE;CACT;AANnE,wCAMmE"}
|
|
@@ -38,5 +38,41 @@ describe('DeclastructDao', () => {
|
|
|
38
38
|
expect(dao.set.upsert).toBeDefined();
|
|
39
39
|
expect(dao.set.delete).toBeDefined();
|
|
40
40
|
});
|
|
41
|
+
describe('resource with optional primary key', () => {
|
|
42
|
+
class DemoResourceWithOptionalPrimary extends domain_objects_1.DomainEntity {
|
|
43
|
+
}
|
|
44
|
+
DemoResourceWithOptionalPrimary.primary = ['uuid'];
|
|
45
|
+
DemoResourceWithOptionalPrimary.unique = ['name'];
|
|
46
|
+
it('RefByPrimary should require uuid (not optional)', () => {
|
|
47
|
+
// type test: this should compile
|
|
48
|
+
const ref = {
|
|
49
|
+
uuid: 'test-uuid',
|
|
50
|
+
};
|
|
51
|
+
// verify ref has uuid
|
|
52
|
+
expect(ref.uuid).toBe('test-uuid');
|
|
53
|
+
// note: the following would fail type check (but we can't test that at runtime)
|
|
54
|
+
// @ts-expect-error - uuid should be required, empty object should fail
|
|
55
|
+
const badRef = {};
|
|
56
|
+
expect(badRef).toBeDefined(); // suppress unused var warning
|
|
57
|
+
});
|
|
58
|
+
it('dao.get.byPrimary should accept RefByPrimary with required uuid', () => {
|
|
59
|
+
// type verification: byPrimary input should have uuid as required (not optional)
|
|
60
|
+
const dao = {
|
|
61
|
+
get: {
|
|
62
|
+
byUnique: async () => null,
|
|
63
|
+
byPrimary: async (input) => {
|
|
64
|
+
// input.uuid should be string (not string | undefined)
|
|
65
|
+
// this assignment would fail if uuid were optional
|
|
66
|
+
const uuid = input.uuid;
|
|
67
|
+
expect(uuid).toBeDefined();
|
|
68
|
+
return null;
|
|
69
|
+
},
|
|
70
|
+
byRef: async () => null,
|
|
71
|
+
},
|
|
72
|
+
set: { finsert: async (r) => r },
|
|
73
|
+
};
|
|
74
|
+
expect(dao.get.byPrimary).toBeDefined();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
41
77
|
});
|
|
42
78
|
//# sourceMappingURL=DeclastructDao.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclastructDao.test.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"DeclastructDao.test.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructDao.test.ts"],"names":[],"mappings":";;AAAA,mDAA4D;AAI5D,QAAQ,CAAC,gBAAgB,EAAE,GAA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CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const domain_objects_1 = require("domain-objects");
|
|
3
4
|
const DeclastructProvider_1 = require("./DeclastructProvider");
|
|
4
5
|
describe('DeclastructProvider', () => {
|
|
5
6
|
it('should build a provider with all required properties', () => {
|
|
@@ -31,5 +32,49 @@ describe('DeclastructProvider', () => {
|
|
|
31
32
|
});
|
|
32
33
|
expect(provider).toBeDefined();
|
|
33
34
|
});
|
|
35
|
+
describe('resource with optional primary key', () => {
|
|
36
|
+
class DemoResourceWithOptionalPrimary extends domain_objects_1.DomainEntity {
|
|
37
|
+
}
|
|
38
|
+
DemoResourceWithOptionalPrimary.primary = ['uuid'];
|
|
39
|
+
DemoResourceWithOptionalPrimary.unique = ['name'];
|
|
40
|
+
it('should work with daos that have optional primary keys and byPrimary defined', () => {
|
|
41
|
+
// define a dao for the resource with optional primary key
|
|
42
|
+
const demoDao = {
|
|
43
|
+
get: {
|
|
44
|
+
byUnique: async () => null,
|
|
45
|
+
byPrimary: async (input) => {
|
|
46
|
+
// input.uuid should be string (not string | undefined)
|
|
47
|
+
const uuid = input.uuid;
|
|
48
|
+
expect(uuid).toBeDefined();
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
byRef: async () => null,
|
|
52
|
+
},
|
|
53
|
+
set: {
|
|
54
|
+
finsert: async (r) => r,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
// build provider with the dao
|
|
58
|
+
const provider = new DeclastructProvider_1.DeclastructProvider({
|
|
59
|
+
name: 'optional-primary-key-provider',
|
|
60
|
+
daos: {
|
|
61
|
+
DemoResourceWithOptionalPrimary: demoDao,
|
|
62
|
+
},
|
|
63
|
+
context: {},
|
|
64
|
+
hooks: {
|
|
65
|
+
beforeAll: async () => { },
|
|
66
|
+
afterAll: async () => { },
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
// verify provider structure
|
|
70
|
+
expect(provider.name).toBe('optional-primary-key-provider');
|
|
71
|
+
expect(provider.daos.DemoResourceWithOptionalPrimary).toBeDefined();
|
|
72
|
+
// access dao to verify structure
|
|
73
|
+
const dao = provider.daos.DemoResourceWithOptionalPrimary;
|
|
74
|
+
expect(dao?.get.byPrimary).toBeDefined();
|
|
75
|
+
expect(dao?.get.byUnique).toBeDefined();
|
|
76
|
+
expect(dao?.set.finsert).toBeDefined();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
34
79
|
});
|
|
35
80
|
//# sourceMappingURL=DeclastructProvider.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeclastructProvider.test.js","sourceRoot":"","sources":["../../src/domain.objects/DeclastructProvider.test.ts"],"names":[],"mappings":";;AAAA,+DAA4D;AAE5D,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,QAAQ,GAAG,IAAI,yCAAmB,CAAC;YACvC,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,EAAE;YACX,KAAK,EAAE;gBACL,SAAS,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;gBACzB,QAAQ,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;aACzB;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAClC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACrC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,EAAE,CAAC,IAAI;iBACxB;gBACD,GAAG,EAAE;oBACH,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAQ;iBAC/B;aACF,CAAC;YAEF,8BAA8B;YAC9B,MAAM,QAAQ,GAAG,IAAI,yCAAmB,CAAC;gBACvC,IAAI,EAAE,+BAA+B;gBACrC,IAAI,EAAE;oBACJ,+BAA+B,EAAE,OAAO;iBACzC;gBACD,OAAO,EAAE,EAAE;gBACX,KAAK,EAAE;oBACL,SAAS,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;oBACzB,QAAQ,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;iBACzB;aACF,CAAC,CAAC;YAEH,4BAA4B;YAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;YAC5D,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,WAAW,EAAE,CAAC;YAEpE,iCAAiC;YACjC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,+BAA+B,CAAC;YAC1D,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;YACzC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -10,10 +10,10 @@ const DeclastructChange_1 = require("../../domain.objects/DeclastructChange");
|
|
|
10
10
|
* .why = determines whether a resource needs to be updated
|
|
11
11
|
* .note = uses deterministic serialization for deep equality check, ignoring metadata
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
13
|
+
const checkAreResourcesEquivalent = (input) => {
|
|
14
14
|
// serialize both deterministically for deep comparison, omitting metadata
|
|
15
|
-
const remoteSerialized = (0, domain_objects_1.serialize)((0, domain_objects_1.omitMetadataValues)(remote));
|
|
16
|
-
const desiredSerialized = (0, domain_objects_1.serialize)((0, domain_objects_1.omitMetadataValues)(desired));
|
|
15
|
+
const remoteSerialized = (0, domain_objects_1.serialize)((0, domain_objects_1.omitMetadataValues)(input.remote));
|
|
16
|
+
const desiredSerialized = (0, domain_objects_1.serialize)((0, domain_objects_1.omitMetadataValues)(input.desired));
|
|
17
17
|
return remoteSerialized === desiredSerialized;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
@@ -57,7 +57,17 @@ const computeChange = ({ desired, remote, }) => {
|
|
|
57
57
|
if (!desired)
|
|
58
58
|
return DeclastructChange_1.DeclastructChangeAction.DESTROY;
|
|
59
59
|
// no changes needed
|
|
60
|
-
|
|
60
|
+
const areResourcesEquivalent = helpful_errors_1.UnexpectedCodePathError.wrap(() => checkAreResourcesEquivalent({ remote, desired }), {
|
|
61
|
+
message: 'failed to checkAreResourcesEquivalent',
|
|
62
|
+
metadata: {
|
|
63
|
+
input: { desired, remote },
|
|
64
|
+
ctors: {
|
|
65
|
+
desired: desired?.constructor.name,
|
|
66
|
+
remote: remote?.constructor.name,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
})();
|
|
70
|
+
if (areResourcesEquivalent)
|
|
61
71
|
return DeclastructChange_1.DeclastructChangeAction.KEEP;
|
|
62
72
|
// resource exists and needs updating
|
|
63
73
|
return DeclastructChange_1.DeclastructChangeAction.UPDATE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeChange.js","sourceRoot":"","sources":["../../../src/domain.operations/plan/computeChange.ts"],"names":[],"mappings":";;;AAAA,mDAKwB;AACxB,mDAAyD;AACzD,yCAAiC;AAEjC,8EAGgD;AAEhD;;;;GAIG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"computeChange.js","sourceRoot":"","sources":["../../../src/domain.operations/plan/computeChange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AAO,IAAI,MAAO,CAAC;IAE7C,gBAAgB;IAChB,OAAO,IAAI,qCAAiB,CAAC;QAC3B,WAAW,EAAE;YACX,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,IAAI;YACzC,IAAI,EAAE,wCAAuB,CAAC,IAAI,CAChC,GAAG,EAAE,CAAC,IAAA,wCAAuB,EAAC,iBAAiB,CAAC,EAChD;gBACE,OAAO,EAAE,mCAAmC;gBAC5C,QAAQ,EAAE;oBACR,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;oBAC1B,KAAK,EAAE;wBACL,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI;wBAClC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI;qBACjC;iBACF;aACF,CACF,EAAE;SACJ;QACD,MAAM;QACN,KAAK,EAAE;YACL,OAAO;YACP,MAAM;YACN,UAAU;SACX;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AArEW,QAAA,aAAa,iBAqExB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declastruct",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "Add declarative control to any resource constructs. Declare, plan, and apply within an observable pit-of-success.",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.11",
|
|
6
6
|
"repository": "ehmpathy/declastruct",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/declastruct",
|
|
8
8
|
"keywords": [
|
|
@@ -59,11 +59,12 @@
|
|
|
59
59
|
"helpful-errors": "1.5.3",
|
|
60
60
|
"jest-diff": "30.0.2",
|
|
61
61
|
"simple-log-methods": "0.6.2",
|
|
62
|
+
"tsx": "4.20.6",
|
|
62
63
|
"type-fns": "1.19.0",
|
|
63
64
|
"uuid-fns": "1.0.2"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|
|
66
|
-
"domain-objects": ">=0.29.
|
|
67
|
+
"domain-objects": ">=0.29.4"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@commitlint/cli": "19.3.0",
|
|
@@ -89,7 +90,6 @@
|
|
|
89
90
|
"rhachet": "1.12.1",
|
|
90
91
|
"rhachet-roles-ehmpathy": "1.9.1",
|
|
91
92
|
"ts-jest": "29.1.3",
|
|
92
|
-
"ts-node": "10.9.2",
|
|
93
93
|
"typescript": "5.4.5"
|
|
94
94
|
},
|
|
95
95
|
"config": {
|