@living-architecture/riviere-query 0.2.7 → 0.2.9
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-queries.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RiviereGraph, DomainOpComponent } from '@living-architecture/riviere-schema';
|
|
2
|
-
import
|
|
2
|
+
import { Entity } from './event-types';
|
|
3
|
+
import type { EntityTransition } from './event-types';
|
|
3
4
|
import type { State, Domain } from './domain-types';
|
|
4
5
|
export declare function queryDomains(graph: RiviereGraph): Domain[];
|
|
5
6
|
export declare function operationsForEntity(graph: RiviereGraph, entityName: string): DomainOpComponent[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain-queries.d.ts","sourceRoot":"","sources":["../src/domain-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC1F,OAAO,
|
|
1
|
+
{"version":3,"file":"domain-queries.d.ts","sourceRoot":"","sources":["../src/domain-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAmB,MAAM,gBAAgB,CAAA;AAIpE,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,EAAE,CAU1D;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAEhG;AAQD,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBhF;AAcD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAQxF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAUhG;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,EAAE,CAWhF"}
|
package/dist/domain-queries.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Entity } from './event-types';
|
|
1
2
|
import { parseEntityName, parseDomainName, parseState, parseOperationName } from './domain-types';
|
|
2
3
|
import { componentsInDomain } from './component-queries';
|
|
3
4
|
export function queryDomains(graph) {
|
|
@@ -21,14 +22,20 @@ export function queryEntities(graph, domainName) {
|
|
|
21
22
|
for (const op of filtered) {
|
|
22
23
|
const key = `${op.domain}:${op.entity}`;
|
|
23
24
|
const existing = entityMap.get(key);
|
|
24
|
-
if (existing) {
|
|
25
|
+
if (existing !== undefined) {
|
|
25
26
|
entityMap.set(key, { ...existing, operations: [...existing.operations, op] });
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
|
-
entityMap.set(key, { name:
|
|
29
|
+
entityMap.set(key, { name: op.entity, domain: op.domain, operations: [op] });
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
return Array.from(entityMap.values())
|
|
32
|
+
return Array.from(entityMap.values())
|
|
33
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
34
|
+
.map((partial) => createEntity(graph, partial));
|
|
35
|
+
}
|
|
36
|
+
function createEntity(graph, partial) {
|
|
37
|
+
const sortedOperations = [...partial.operations].sort((a, b) => a.operationName.localeCompare(b.operationName));
|
|
38
|
+
return new Entity(parseEntityName(partial.name), parseDomainName(partial.domain), sortedOperations, statesForEntity(graph, partial.name), transitionsForEntity(graph, partial.name), businessRulesForEntity(graph, partial.name));
|
|
32
39
|
}
|
|
33
40
|
export function businessRulesForEntity(graph, entityName) {
|
|
34
41
|
const operations = operationsForEntity(graph, entityName);
|
package/dist/event-types.d.ts
CHANGED
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
import type { DomainOpComponent } from '@living-architecture/riviere-schema';
|
|
2
2
|
import type { EntityName, DomainName, State, OperationName, EventId, EventName, HandlerId, HandlerName } from './domain-types';
|
|
3
3
|
/**
|
|
4
|
-
* A domain entity with its associated operations.
|
|
4
|
+
* A domain entity with its associated operations, states, and business rules.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export declare class Entity {
|
|
7
7
|
/** The entity name. */
|
|
8
|
-
name: EntityName;
|
|
8
|
+
readonly name: EntityName;
|
|
9
9
|
/** The domain containing the entity. */
|
|
10
|
-
domain: DomainName;
|
|
10
|
+
readonly domain: DomainName;
|
|
11
|
+
/** All domain operations targeting this entity. */
|
|
12
|
+
readonly operations: DomainOpComponent[];
|
|
13
|
+
/** Ordered states derived from state transitions (initial → terminal). */
|
|
14
|
+
readonly states: State[];
|
|
15
|
+
/** State transitions with triggering operations. */
|
|
16
|
+
readonly transitions: EntityTransition[];
|
|
17
|
+
/** Deduplicated business rules from all operations. */
|
|
18
|
+
readonly businessRules: string[];
|
|
19
|
+
constructor(
|
|
20
|
+
/** The entity name. */
|
|
21
|
+
name: EntityName,
|
|
22
|
+
/** The domain containing the entity. */
|
|
23
|
+
domain: DomainName,
|
|
11
24
|
/** All domain operations targeting this entity. */
|
|
12
|
-
operations: DomainOpComponent[]
|
|
25
|
+
operations: DomainOpComponent[],
|
|
26
|
+
/** Ordered states derived from state transitions (initial → terminal). */
|
|
27
|
+
states: State[],
|
|
28
|
+
/** State transitions with triggering operations. */
|
|
29
|
+
transitions: EntityTransition[],
|
|
30
|
+
/** Deduplicated business rules from all operations. */
|
|
31
|
+
businessRules: string[]);
|
|
32
|
+
hasStates(): boolean;
|
|
33
|
+
hasBusinessRules(): boolean;
|
|
34
|
+
firstOperationId(): string | undefined;
|
|
13
35
|
}
|
|
14
36
|
/**
|
|
15
37
|
* A state transition in an entity's state machine.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../src/event-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,KAAK,EACL,aAAa,EACb,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACZ,MAAM,gBAAgB,CAAA;AAEvB;;GAEG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../src/event-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,KAAK,EACL,aAAa,EACb,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACZ,MAAM,gBAAgB,CAAA;AAEvB;;GAEG;AACH,qBAAa,MAAM;IAEf,uBAAuB;aACP,IAAI,EAAE,UAAU;IAChC,wCAAwC;aACxB,MAAM,EAAE,UAAU;IAClC,mDAAmD;aACnC,UAAU,EAAE,iBAAiB,EAAE;IAC/C,0EAA0E;aAC1D,MAAM,EAAE,KAAK,EAAE;IAC/B,oDAAoD;aACpC,WAAW,EAAE,gBAAgB,EAAE;IAC/C,uDAAuD;aACvC,aAAa,EAAE,MAAM,EAAE;;IAXvC,uBAAuB;IACP,IAAI,EAAE,UAAU;IAChC,wCAAwC;IACxB,MAAM,EAAE,UAAU;IAClC,mDAAmD;IACnC,UAAU,EAAE,iBAAiB,EAAE;IAC/C,0EAA0E;IAC1D,MAAM,EAAE,KAAK,EAAE;IAC/B,oDAAoD;IACpC,WAAW,EAAE,gBAAgB,EAAE;IAC/C,uDAAuD;IACvC,aAAa,EAAE,MAAM,EAAE;IAGzC,SAAS,IAAI,OAAO;IAIpB,gBAAgB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AAE,SAAS,EAAE,CAAA;IAC7B,wDAAwD;IACxD,0BAA0B,EAAE,yBAAyB,EAAE,CAAA;CACxD"}
|
package/dist/event-types.js
CHANGED
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A domain entity with its associated operations, states, and business rules.
|
|
3
|
+
*/
|
|
4
|
+
export class Entity {
|
|
5
|
+
name;
|
|
6
|
+
domain;
|
|
7
|
+
operations;
|
|
8
|
+
states;
|
|
9
|
+
transitions;
|
|
10
|
+
businessRules;
|
|
11
|
+
constructor(
|
|
12
|
+
/** The entity name. */
|
|
13
|
+
name,
|
|
14
|
+
/** The domain containing the entity. */
|
|
15
|
+
domain,
|
|
16
|
+
/** All domain operations targeting this entity. */
|
|
17
|
+
operations,
|
|
18
|
+
/** Ordered states derived from state transitions (initial → terminal). */
|
|
19
|
+
states,
|
|
20
|
+
/** State transitions with triggering operations. */
|
|
21
|
+
transitions,
|
|
22
|
+
/** Deduplicated business rules from all operations. */
|
|
23
|
+
businessRules) {
|
|
24
|
+
this.name = name;
|
|
25
|
+
this.domain = domain;
|
|
26
|
+
this.operations = operations;
|
|
27
|
+
this.states = states;
|
|
28
|
+
this.transitions = transitions;
|
|
29
|
+
this.businessRules = businessRules;
|
|
30
|
+
}
|
|
31
|
+
hasStates() {
|
|
32
|
+
return this.states.length > 0;
|
|
33
|
+
}
|
|
34
|
+
hasBusinessRules() {
|
|
35
|
+
return this.businessRules.length > 0;
|
|
36
|
+
}
|
|
37
|
+
firstOperationId() {
|
|
38
|
+
return this.operations[0]?.id;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@living-architecture/riviere-query",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"tslib": "^2.3.0",
|
|
26
26
|
"zod": "^4.2.1",
|
|
27
|
-
"@living-architecture/riviere-schema": "0.2.
|
|
27
|
+
"@living-architecture/riviere-schema": "0.2.6"
|
|
28
28
|
}
|
|
29
29
|
}
|