@living-architecture/riviere-builder 0.3.5 → 0.4.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/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,gBAAgB,EACjB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEZ,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,WAAW,EACX,gBAAgB,EACjB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAaxF,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,eAAe,EACf,WAAW,EACX,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,OAAO,EACP,YAAY,EACb,MAAM,SAAS,CAAA;AAEhB,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,EACX,eAAe,EACf,WAAW,EACX,aAAa,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I,MAAM;IAInB;;;;;;;;;;;;;;;OAeG;IACH,KAAK,IAAI,YAAY;IASrB;;;;;;;;;;;;OAYG;IACG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcvC,OAAO,CAAC,mBAAmB;CAG5B"}
|
package/dist/builder.js
CHANGED
|
@@ -6,6 +6,7 @@ import { assertCustomTypeExists, assertDomainExists, assertRequiredPropertiesPro
|
|
|
6
6
|
import { ComponentId } from '@living-architecture/riviere-schema';
|
|
7
7
|
import { createSourceNotFoundError, findNearMatches } from './component-suggestion';
|
|
8
8
|
import { mergeBehavior } from './merge-behavior';
|
|
9
|
+
import { deduplicateStrings, deduplicateStateTransitions } from './deduplicate';
|
|
9
10
|
import { CustomTypeAlreadyDefinedError, DuplicateComponentError, DuplicateDomainError, InvalidEnrichmentTargetError, } from './errors';
|
|
10
11
|
/**
|
|
11
12
|
* Programmatically construct Rivière architecture graphs.
|
|
@@ -470,10 +471,14 @@ export class RiviereBuilder {
|
|
|
470
471
|
component.entity = enrichment.entity;
|
|
471
472
|
}
|
|
472
473
|
if (enrichment.stateChanges !== undefined) {
|
|
473
|
-
|
|
474
|
+
const existing = component.stateChanges ?? [];
|
|
475
|
+
const newItems = deduplicateStateTransitions(existing, enrichment.stateChanges);
|
|
476
|
+
component.stateChanges = [...existing, ...newItems];
|
|
474
477
|
}
|
|
475
478
|
if (enrichment.businessRules !== undefined) {
|
|
476
|
-
|
|
479
|
+
const existing = component.businessRules ?? [];
|
|
480
|
+
const newItems = deduplicateStrings(existing, enrichment.businessRules);
|
|
481
|
+
component.businessRules = [...existing, ...newItems];
|
|
477
482
|
}
|
|
478
483
|
if (enrichment.behavior !== undefined) {
|
|
479
484
|
component.behavior = mergeBehavior(component.behavior, enrichment.behavior);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StateTransition } from '@living-architecture/riviere-schema';
|
|
2
|
+
export declare function deduplicateStrings(existing: string[], incoming: string[]): string[];
|
|
3
|
+
export declare function deduplicateStateTransitions(existing: StateTransition[], incoming: StateTransition[]): StateTransition[];
|
|
4
|
+
//# sourceMappingURL=deduplicate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deduplicate.d.ts","sourceRoot":"","sources":["../src/deduplicate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAE1E,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGnF;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,eAAe,EAAE,EAC3B,QAAQ,EAAE,eAAe,EAAE,GAC1B,eAAe,EAAE,CAOnB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function deduplicateStrings(existing, incoming) {
|
|
2
|
+
const existingSet = new Set(existing);
|
|
3
|
+
return incoming.filter((item) => !existingSet.has(item));
|
|
4
|
+
}
|
|
5
|
+
export function deduplicateStateTransitions(existing, incoming) {
|
|
6
|
+
return incoming.filter((item) => !existing.some((e) => e.from === item.from && e.to === item.to && e.trigger === item.trigger));
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-behavior.d.ts","sourceRoot":"","sources":["../src/merge-behavior.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;
|
|
1
|
+
{"version":3,"file":"merge-behavior.d.ts","sourceRoot":"","sources":["../src/merge-behavior.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAQ/F,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,EACvC,QAAQ,EAAE,iBAAiB,GAC1B,iBAAiB,CASnB"}
|
package/dist/merge-behavior.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
+
import { deduplicateStrings } from './deduplicate';
|
|
2
|
+
function mergeStringArray(existing, incoming) {
|
|
3
|
+
const base = existing ?? [];
|
|
4
|
+
return [...base, ...deduplicateStrings(base, incoming)];
|
|
5
|
+
}
|
|
1
6
|
export function mergeBehavior(existing, incoming) {
|
|
2
7
|
const base = existing ?? {};
|
|
3
8
|
return {
|
|
4
9
|
...base,
|
|
5
|
-
...(incoming.reads !== undefined && {
|
|
6
|
-
|
|
7
|
-
}),
|
|
8
|
-
...(incoming.
|
|
9
|
-
validates: [...(base.validates ?? []), ...incoming.validates],
|
|
10
|
-
}),
|
|
11
|
-
...(incoming.modifies !== undefined && {
|
|
12
|
-
modifies: [...(base.modifies ?? []), ...incoming.modifies],
|
|
13
|
-
}),
|
|
14
|
-
...(incoming.emits !== undefined && {
|
|
15
|
-
emits: [...(base.emits ?? []), ...incoming.emits],
|
|
16
|
-
}),
|
|
10
|
+
...(incoming.reads !== undefined && { reads: mergeStringArray(base.reads, incoming.reads) }),
|
|
11
|
+
...(incoming.validates !== undefined && { validates: mergeStringArray(base.validates, incoming.validates) }),
|
|
12
|
+
...(incoming.modifies !== undefined && { modifies: mergeStringArray(base.modifies, incoming.modifies) }),
|
|
13
|
+
...(incoming.emits !== undefined && { emits: mergeStringArray(base.emits, incoming.emits) }),
|
|
17
14
|
};
|
|
18
15
|
}
|