@auto-engineer/narrative 1.88.0 → 1.89.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/narrative@1.88.0 build /home/runner/work/auto-engineer/auto-engineer/packages/narrative
2
+ > @auto-engineer/narrative@1.89.0 build /home/runner/work/auto-engineer/auto-engineer/packages/narrative
3
3
  > tsx scripts/build.ts
4
4
 
5
5
  Running: tsc
@@ -1,14 +1,14 @@
1
1
 
2
- > @auto-engineer/narrative@1.87.0 test /home/runner/work/auto-engineer/auto-engineer/packages/narrative
2
+ > @auto-engineer/narrative@1.88.0 test /home/runner/work/auto-engineer/auto-engineer/packages/narrative
3
3
  > vitest run --reporter=dot
4
4
 
5
5
 
6
6
   RUN  v3.2.4 /home/runner/work/auto-engineer/auto-engineer/packages/narrative
7
7
 
8
- ····································································································································································································································
8
+ ··································································································································································································································································
9
9
 
10
-  Test Files  18 passed (18)
11
-  Tests  228 passed (228)
12
-  Start at  11:44:24
13
-  Duration  33.36s (transform 7.38s, setup 0ms, collect 43.94s, tests 26.88s, environment 6ms, prepare 9.71s)
10
+  Test Files  20 passed (20)
11
+  Tests  258 passed (258)
12
+  Start at  20:22:13
13
+  Duration  40.72s (transform 8.45s, setup 0ms, collect 50.50s, tests 30.50s, environment 13ms, prepare 13.28s)
14
14
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @auto-engineer/narrative@1.87.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/narrative
2
+ > @auto-engineer/narrative@1.88.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/narrative
3
3
  > tsc --noEmit
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # @auto-engineer/flow
2
2
 
3
+ ## 1.89.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`93ff5a5`](https://github.com/BeOnAuto/auto-engineer/commit/93ff5a559f087bb875b2b1e165713e1dc6fbea5b) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: embed instructions in scaffold templates
8
+
9
+ - [`514525d`](https://github.com/BeOnAuto/auto-engineer/commit/514525d0ae9542693fc44e6922fd0c31d229c8c9) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: export validateSliceRequests and add integration tests
10
+
11
+ - [`7af6ae4`](https://github.com/BeOnAuto/auto-engineer/commit/7af6ae46d50a7115da047d07824a4d3e4983338f) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: add nested field validation for query slice requests
12
+
13
+ - [`971394a`](https://github.com/BeOnAuto/auto-engineer/commit/971394ad8d47faad27acf6c4fa82d11010568cda) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: type-annotate aggregateStream + dynamic error listing
14
+
15
+ - [`dbfbe69`](https://github.com/BeOnAuto/auto-engineer/commit/dbfbe69e5fc1efb8a65df1d3d480b36c9666b95a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: add validate-slice-requests skeleton with parse safety
16
+
17
+ - [`d7b3af9`](https://github.com/BeOnAuto/auto-engineer/commit/d7b3af912b1e9f7e4f0bfc91b65768341f87229c) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: add query validation for operation type, state, and top-level fields
18
+
19
+ - [`a36fc79`](https://github.com/BeOnAuto/auto-engineer/commit/a36fc79f40d236b49983574a7f8607e9028e3daf) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: filter linking field to primitive types only
20
+
21
+ - [`73ef7b1`](https://github.com/BeOnAuto/auto-engineer/commit/73ef7b1f2818e72cc5b1cc77400f44ed948e0d39) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: filter event And-steps from react Then items
22
+
23
+ - [`ea41643`](https://github.com/BeOnAuto/auto-engineer/commit/ea41643cbd1303f50313e7dd20d92d4f3a775114) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: use parsedRequest for command mutation names
24
+
25
+ - [`3e9cf93`](https://github.com/BeOnAuto/auto-engineer/commit/3e9cf93af40df9636ae33b9e749dd85ca0b0802e) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: add expectEvents typing shim to decide.specs.ts.ejs
26
+
27
+ - [`0231c5f`](https://github.com/BeOnAuto/auto-engineer/commit/0231c5f5a771786d6534c8a0f9d6dd2856d6b893) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: parseGraphQlRequest accepts mutation operations
28
+
29
+ - [`aacffe9`](https://github.com/BeOnAuto/auto-engineer/commit/aacffe9244a1b364f550caf9b0d5d9ce9c905c2c) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-nestjs**: use parsedRequest for mutation and query names
30
+
31
+ - [`a527ccc`](https://github.com/BeOnAuto/auto-engineer/commit/a527ccc39d7f769609252ebefcb4b26e5fe84316) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: add mutation validation to validate-slice-requests
32
+
33
+ ### Patch Changes
34
+
35
+ - [`dc9b7d9`](https://github.com/BeOnAuto/auto-engineer/commit/dc9b7d9cbcebaf5e34025b6f08b9152f87a67073) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: update ketchup plan for bursts 13-14
36
+
37
+ - [`1d1f519`](https://github.com/BeOnAuto/auto-engineer/commit/1d1f519fa17ba95228e58ef12ce64e3919c0697d) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: add ketchup plan for validate-slice-requests
38
+
39
+ - [`8bbbc30`](https://github.com/BeOnAuto/auto-engineer/commit/8bbbc309734ff5dce3b51473f018caa31208fa7a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: mark burst 18 done in ketchup plan
40
+
41
+ - [`aabe8ae`](https://github.com/BeOnAuto/auto-engineer/commit/aabe8ae4feb13e8ee4b6d3e8a7ef50bb845eaebf) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: derive stable metadata.now for ISO date fields
42
+ - **server-generator-apollo-emmett**: resolve findOne idField from events when missing in Then state
43
+ - **server-generator-apollo-emmett**: return array idField natively from extraction
44
+ - **server-implementer**: add prompt guardrails for phantom enums and hardcoded projections
45
+ - **server-generator-apollo-emmett**: align instruction comment with \_state parameter name
46
+
47
+ - [`5af523f`](https://github.com/BeOnAuto/auto-engineer/commit/5af523f9cb5d1a4e6275589e1f12173637c6458e) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: fix [object Object] serialization bugs
48
+
49
+ - [`a4053ef`](https://github.com/BeOnAuto/auto-engineer/commit/a4053ef91284b9718bacef58ebd3ab250d4cda79) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: update decide.specs.ts snapshots for dynamic errors
50
+
51
+ - [`b63c308`](https://github.com/BeOnAuto/auto-engineer/commit/b63c308209f0316ea3b0433a82d46dec8e15169a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-implementer**: add anti-hardcoding rules for decide functions
52
+
53
+ - [`1947b66`](https://github.com/BeOnAuto/auto-engineer/commit/1947b66d0b4687abcde75f29fc32c8665b929582) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: move burst 17 to done in ketchup plan
54
+
55
+ - [`16c9541`](https://github.com/BeOnAuto/auto-engineer/commit/16c954130331be27f54f2e1ef451545b7e22161d) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: extract parseGraphQlRequest to narrative package
56
+
57
+ - [`bad8ef9`](https://github.com/BeOnAuto/auto-engineer/commit/bad8ef9ceb73f9b7efda58f821073ec9894ee7fb) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: rename ParsedGraphQlQuery to ParsedGraphQlOperation
58
+
59
+ - [`a058731`](https://github.com/BeOnAuto/auto-engineer/commit/a0587319d6772df61b4004df1584d884222e7304) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **global**: add ketchup plan for parsedRequest mutation names
60
+
61
+ - [`d6f6ef6`](https://github.com/BeOnAuto/auto-engineer/commit/d6f6ef6f79ceb712ccfcf00a22789c55d6e9a0b4) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: omit non-command fields from Then assertions
62
+ - **server-generator-apollo-emmett**: derive stable metadata.now for ISO date fields
63
+ - **server-generator-apollo-emmett**: resolve findOne idField from events when missing in Then state
64
+ - **server-generator-apollo-emmett**: return array idField natively from extraction
65
+ - **server-implementer**: add prompt guardrails for phantom enums and hardcoded projections
66
+
67
+ - [`667b53f`](https://github.com/BeOnAuto/auto-engineer/commit/667b53f02b3cc933efe520022dd2f85ba1fbec3b) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **server-generator-apollo-emmett**: move burst 14 to done in ketchup plan
68
+
69
+ - [`e69b385`](https://github.com/BeOnAuto/auto-engineer/commit/e69b38526ab9fd522ef91955a3ee98ed3c611473) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - **narrative**: mark all bursts done in ketchup plan
70
+
71
+ - Updated dependencies [[`dc9b7d9`](https://github.com/BeOnAuto/auto-engineer/commit/dc9b7d9cbcebaf5e34025b6f08b9152f87a67073), [`93ff5a5`](https://github.com/BeOnAuto/auto-engineer/commit/93ff5a559f087bb875b2b1e165713e1dc6fbea5b), [`514525d`](https://github.com/BeOnAuto/auto-engineer/commit/514525d0ae9542693fc44e6922fd0c31d229c8c9), [`7af6ae4`](https://github.com/BeOnAuto/auto-engineer/commit/7af6ae46d50a7115da047d07824a4d3e4983338f), [`1d1f519`](https://github.com/BeOnAuto/auto-engineer/commit/1d1f519fa17ba95228e58ef12ce64e3919c0697d), [`8bbbc30`](https://github.com/BeOnAuto/auto-engineer/commit/8bbbc309734ff5dce3b51473f018caa31208fa7a), [`aabe8ae`](https://github.com/BeOnAuto/auto-engineer/commit/aabe8ae4feb13e8ee4b6d3e8a7ef50bb845eaebf), [`971394a`](https://github.com/BeOnAuto/auto-engineer/commit/971394ad8d47faad27acf6c4fa82d11010568cda), [`5af523f`](https://github.com/BeOnAuto/auto-engineer/commit/5af523f9cb5d1a4e6275589e1f12173637c6458e), [`a4053ef`](https://github.com/BeOnAuto/auto-engineer/commit/a4053ef91284b9718bacef58ebd3ab250d4cda79), [`dbfbe69`](https://github.com/BeOnAuto/auto-engineer/commit/dbfbe69e5fc1efb8a65df1d3d480b36c9666b95a), [`d7b3af9`](https://github.com/BeOnAuto/auto-engineer/commit/d7b3af912b1e9f7e4f0bfc91b65768341f87229c), [`a36fc79`](https://github.com/BeOnAuto/auto-engineer/commit/a36fc79f40d236b49983574a7f8607e9028e3daf), [`73ef7b1`](https://github.com/BeOnAuto/auto-engineer/commit/73ef7b1f2818e72cc5b1cc77400f44ed948e0d39), [`ea41643`](https://github.com/BeOnAuto/auto-engineer/commit/ea41643cbd1303f50313e7dd20d92d4f3a775114), [`3e9cf93`](https://github.com/BeOnAuto/auto-engineer/commit/3e9cf93af40df9636ae33b9e749dd85ca0b0802e), [`0231c5f`](https://github.com/BeOnAuto/auto-engineer/commit/0231c5f5a771786d6534c8a0f9d6dd2856d6b893), [`b63c308`](https://github.com/BeOnAuto/auto-engineer/commit/b63c308209f0316ea3b0433a82d46dec8e15169a), [`1947b66`](https://github.com/BeOnAuto/auto-engineer/commit/1947b66d0b4687abcde75f29fc32c8665b929582), [`aacffe9`](https://github.com/BeOnAuto/auto-engineer/commit/aacffe9244a1b364f550caf9b0d5d9ce9c905c2c), [`a527ccc`](https://github.com/BeOnAuto/auto-engineer/commit/a527ccc39d7f769609252ebefcb4b26e5fe84316), [`16c9541`](https://github.com/BeOnAuto/auto-engineer/commit/16c954130331be27f54f2e1ef451545b7e22161d), [`bad8ef9`](https://github.com/BeOnAuto/auto-engineer/commit/bad8ef9ceb73f9b7efda58f821073ec9894ee7fb), [`a058731`](https://github.com/BeOnAuto/auto-engineer/commit/a0587319d6772df61b4004df1584d884222e7304), [`d6f6ef6`](https://github.com/BeOnAuto/auto-engineer/commit/d6f6ef6f79ceb712ccfcf00a22789c55d6e9a0b4), [`667b53f`](https://github.com/BeOnAuto/auto-engineer/commit/667b53f02b3cc933efe520022dd2f85ba1fbec3b), [`e69b385`](https://github.com/BeOnAuto/auto-engineer/commit/e69b38526ab9fd522ef91955a3ee98ed3c611473)]:
72
+ - @auto-engineer/file-store@1.89.0
73
+ - @auto-engineer/id@1.89.0
74
+ - @auto-engineer/message-bus@1.89.0
75
+
3
76
  ## 1.88.0
4
77
 
5
78
  ### Minor Changes
@@ -10,9 +10,13 @@ export { getNarratives } from './getNarratives';
10
10
  export { addAutoIds, hasAllIds } from './id';
11
11
  export type { ExampleBuilder, GivenBuilder, SliceTypeValueInterface, ThenBuilder, WhenBuilder } from './narrative';
12
12
  export { client, data, describe, example, it, narrative, narrative as flow, request, rule, SliceType, server, should, specs, thenError, } from './narrative';
13
+ export type { ParsedArg, ParsedGraphQlOperation } from './parse-graphql-request';
14
+ export { parseGraphQlRequest, parseSliceRequest } from './parse-graphql-request';
13
15
  export * from './schema';
14
16
  export { createNarrativeSpec, given as testGiven, when as testWhen } from './testing';
15
17
  export type { GeneratedNarratives } from './transformers/model-to-narrative';
16
18
  export { modelToNarrative } from './transformers/model-to-narrative';
17
19
  export { detectQueryAction, extractQueryNameFromRequest } from './transformers/narrative-to-model/spec-processors';
20
+ export type { SliceRequestValidationError } from './validate-slice-requests';
21
+ export { validateSliceRequests } from './validate-slice-requests';
18
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,YAAY,EACV,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,Y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S,GACV,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjF,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,KAAK,IAAI,SAAS,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AACtF,YAAY,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AACnH,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/src/index.js CHANGED
@@ -11,8 +11,10 @@ export { command, decide, evolve, experience, query, react } from './fluent-buil
11
11
  export { getNarratives } from './getNarratives.js';
12
12
  export { addAutoIds, hasAllIds } from './id/index.js';
13
13
  export { client, data, describe, example, it, narrative, narrative as flow, request, rule, SliceType, server, should, specs, thenError, } from './narrative.js';
14
+ export { parseGraphQlRequest, parseSliceRequest } from './parse-graphql-request.js';
14
15
  export * from './schema.js';
15
16
  export { createNarrativeSpec, given as testGiven, when as testWhen } from './testing.js';
16
17
  export { modelToNarrative } from './transformers/model-to-narrative/index.js';
17
18
  export { detectQueryAction, extractQueryNameFromRequest } from './transformers/narrative-to-model/spec-processors.js';
19
+ export { validateSliceRequests } from './validate-slice-requests.js';
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAiBlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5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AE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,mDAAmD,CAAC;AAEnH,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface ParsedArg {
2
+ name: string;
3
+ tsType: string;
4
+ graphqlType: string;
5
+ nullable: boolean;
6
+ }
7
+ export interface ParsedGraphQlOperation {
8
+ operationName: string;
9
+ args: ParsedArg[];
10
+ }
11
+ export declare function convertJsonAstToSdl(request: string): string;
12
+ export declare function parseGraphQlRequest(request: string): ParsedGraphQlOperation;
13
+ export declare function parseSliceRequest(slice: {
14
+ request?: string;
15
+ [key: string]: unknown;
16
+ }): ParsedGraphQlOperation | undefined;
17
+ //# sourceMappingURL=parse-graphql-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-graphql-request.d.ts","sourceRoot":"","sources":["../../src/parse-graphql-request.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AA8BD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAY3D;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,sBAAsB,CAkC3E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,GAAG,sBAAsB,GAAG,SAAS,CAGrC"}
@@ -0,0 +1,77 @@
1
+ import { parse, print } from 'graphql';
2
+ function getTypeName(typeNode) {
3
+ if (typeNode.kind === 'NamedType') {
4
+ return { graphqlType: typeNode.name.value, nullable: true };
5
+ }
6
+ else if (typeNode.kind === 'NonNullType') {
7
+ const inner = getTypeName(typeNode.type);
8
+ return { ...inner, nullable: false };
9
+ }
10
+ else {
11
+ return getTypeName(typeNode.type);
12
+ }
13
+ }
14
+ function graphqlToTs(type) {
15
+ switch (type) {
16
+ case 'String':
17
+ return 'string';
18
+ case 'Int':
19
+ case 'Float':
20
+ case 'Number':
21
+ return 'number';
22
+ case 'Boolean':
23
+ return 'boolean';
24
+ case 'Date':
25
+ return 'Date';
26
+ default:
27
+ return type;
28
+ }
29
+ }
30
+ export function convertJsonAstToSdl(request) {
31
+ if (request.startsWith('{') && request.includes('"kind"')) {
32
+ try {
33
+ const ast = JSON.parse(request);
34
+ if (typeof ast === 'object' && ast !== null && 'kind' in ast && ast.kind === 'Document') {
35
+ return print(ast);
36
+ }
37
+ }
38
+ catch {
39
+ // If parsing fails, assume it's already a GraphQL string
40
+ }
41
+ }
42
+ return request;
43
+ }
44
+ export function parseGraphQlRequest(request) {
45
+ const sdlRequest = convertJsonAstToSdl(request);
46
+ const ast = parse(sdlRequest);
47
+ const op = ast.definitions.find((d) => d.kind === 'OperationDefinition' && (d.operation === 'query' || d.operation === 'mutation'));
48
+ if (!op)
49
+ throw new Error('No query or mutation operation found');
50
+ const operationName = op.name?.value;
51
+ if (operationName == null)
52
+ throw new Error('Operation must have a name');
53
+ const args = (op.variableDefinitions ?? []).map((def) => {
54
+ const varName = def.variable.name.value;
55
+ const { graphqlType, nullable } = getTypeName(def.type);
56
+ return {
57
+ name: varName,
58
+ graphqlType,
59
+ tsType: graphqlToTs(graphqlType),
60
+ nullable,
61
+ };
62
+ });
63
+ const field = op.selectionSet.selections[0];
64
+ if (field?.kind !== 'Field' || !field.name.value) {
65
+ throw new Error('Selection must be a field');
66
+ }
67
+ return {
68
+ operationName: field.name.value,
69
+ args,
70
+ };
71
+ }
72
+ export function parseSliceRequest(slice) {
73
+ if (slice.request == null)
74
+ return undefined;
75
+ return parseGraphQlRequest(slice.request);
76
+ }
77
+ //# sourceMappingURL=parse-graphql-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-graphql-request.js","sourceRoot":"","sources":["../../src/parse-graphql-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAC;AAcpF,SAAS,WAAW,CAAC,QAAkB;IACrC,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC9D,CAAC;SAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,KAAK,CAAC;QACX,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1D,IAAI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QACxD,OAAO;YACL,IAAI,EAAE,OAAO;YACb,WAAW;YACX,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC;YAChC,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5C,IAAI,KAAK,EAAE,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACjD,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK;QAC/B,IAAI;KACL,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAGjC;IACC,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5C,OAAO,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Model } from './schema';
2
+ export interface SliceRequestValidationError {
3
+ type: 'request_parse_error' | 'mutation_wrong_operation_type' | 'mutation_missing_input_arg' | 'mutation_input_type_mismatch' | 'mutation_message_not_found' | 'query_wrong_operation_type' | 'query_state_not_found' | 'query_field_not_found' | 'query_nested_field_not_found';
4
+ message: string;
5
+ flowName: string;
6
+ sliceName: string;
7
+ }
8
+ export declare function validateSliceRequests(model: Model): SliceRequestValidationError[];
9
+ //# sourceMappingURL=validate-slice-requests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-slice-requests.d.ts","sourceRoot":"","sources":["../../src/validate-slice-requests.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,KAAK,EAAc,MAAM,UAAU,CAAC;AAEhE,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EACA,qBAAqB,GACrB,+BAA+B,GAC/B,4BAA4B,GAC5B,8BAA8B,GAC9B,4BAA4B,GAC5B,4BAA4B,GAC5B,uBAAuB,GACvB,uBAAuB,GACvB,8BAA8B,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AA+CD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,GAAG,2BAA2B,EAAE,CAWjF"}
@@ -0,0 +1,235 @@
1
+ import { parse } from 'graphql';
2
+ import { convertJsonAstToSdl } from './parse-graphql-request.js';
3
+ function parseRequestSafe(request) {
4
+ const sdl = convertJsonAstToSdl(request);
5
+ let ast;
6
+ try {
7
+ ast = parse(sdl);
8
+ }
9
+ catch (e) {
10
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
11
+ }
12
+ const op = ast.definitions.find((d) => d.kind === 'OperationDefinition');
13
+ if (!op) {
14
+ return { ok: false, error: 'No operation found in request' };
15
+ }
16
+ if (!op.name) {
17
+ return { ok: false, error: 'Operation must have a name' };
18
+ }
19
+ return { ok: true, operation: op };
20
+ }
21
+ function validateSlice(slice, model, flowName) {
22
+ if (!slice.request || slice.request.trim() === '')
23
+ return [];
24
+ const sliceName = slice.name;
25
+ const parsed = parseRequestSafe(slice.request);
26
+ if (!parsed.ok) {
27
+ return [{ type: 'request_parse_error', message: parsed.error, flowName, sliceName }];
28
+ }
29
+ if (slice.type === 'command') {
30
+ return validateMutationRequest(parsed.operation, model, flowName, sliceName);
31
+ }
32
+ return validateQueryRequest(parsed.operation, model, slice, flowName, sliceName);
33
+ }
34
+ export function validateSliceRequests(model) {
35
+ const errors = [];
36
+ for (const narrative of model.narratives) {
37
+ for (const slice of narrative.slices) {
38
+ if (slice.type !== 'command' && slice.type !== 'query')
39
+ continue;
40
+ errors.push(...validateSlice(slice, model, narrative.name));
41
+ }
42
+ }
43
+ return errors;
44
+ }
45
+ function unwrapType(typeNode) {
46
+ if (typeNode.kind === 'NamedType')
47
+ return typeNode.name.value;
48
+ return unwrapType(typeNode.type);
49
+ }
50
+ function validateMutationRequest(operation, model, flowName, sliceName) {
51
+ const errors = [];
52
+ const operationName = operation.name.value;
53
+ if (operation.operation !== 'mutation') {
54
+ errors.push({
55
+ type: 'mutation_wrong_operation_type',
56
+ message: `Command slice '${sliceName}' request should be a mutation, but found ${operation.operation}`,
57
+ flowName,
58
+ sliceName,
59
+ });
60
+ return errors;
61
+ }
62
+ const inputVar = (operation.variableDefinitions ?? []).find((v) => v.variable.name.value === 'input');
63
+ if (!inputVar) {
64
+ errors.push({
65
+ type: 'mutation_missing_input_arg',
66
+ message: `Mutation '${operationName}' is missing required $input variable`,
67
+ flowName,
68
+ sliceName,
69
+ });
70
+ return errors;
71
+ }
72
+ const inputTypeName = unwrapType(inputVar.type);
73
+ const expectedTypeName = `${operationName}Input`;
74
+ if (inputTypeName !== expectedTypeName) {
75
+ errors.push({
76
+ type: 'mutation_input_type_mismatch',
77
+ message: `Mutation '${operationName}' input type should be '${expectedTypeName}', but found '${inputTypeName}'`,
78
+ flowName,
79
+ sliceName,
80
+ });
81
+ return errors;
82
+ }
83
+ const commandExists = model.messages.some((m) => m.type === 'command' && m.name === operationName);
84
+ if (!commandExists) {
85
+ errors.push({
86
+ type: 'mutation_message_not_found',
87
+ message: `No command message '${operationName}' found in model.messages`,
88
+ flowName,
89
+ sliceName,
90
+ });
91
+ }
92
+ return errors;
93
+ }
94
+ function isInlineObject(ts) {
95
+ return /^\{[\s\S]*\}$/.test(ts.trim());
96
+ }
97
+ function isInlineObjectArray(ts) {
98
+ const t = ts.trim();
99
+ return /^Array<\{[\s\S]*\}>$/.test(t) || /^\{[\s\S]*\}\[\]$/.test(t);
100
+ }
101
+ function extractObjectBody(tsType) {
102
+ const t = tsType.trim();
103
+ let inner;
104
+ if (t.startsWith('Array<{') && t.endsWith('}>')) {
105
+ inner = t.slice(6, -1);
106
+ }
107
+ else if (t.endsWith('[]')) {
108
+ inner = t.slice(0, -2).trim();
109
+ }
110
+ else {
111
+ inner = t;
112
+ }
113
+ const match = inner.match(/^\{([\s\S]*)\}$/);
114
+ return match ? match[1] : null;
115
+ }
116
+ function splitFieldsRespectingNesting(body) {
117
+ const fields = [];
118
+ let current = '';
119
+ let depth = 0;
120
+ for (const char of body) {
121
+ if (char === '<' || char === '{')
122
+ depth++;
123
+ if (char === '>' || char === '}')
124
+ depth--;
125
+ if ((char === ';' || char === ',') && depth === 0) {
126
+ const trimmed = current.trim();
127
+ if (trimmed)
128
+ fields.push(trimmed);
129
+ current = '';
130
+ continue;
131
+ }
132
+ current += char;
133
+ }
134
+ const trimmed = current.trim();
135
+ if (trimmed)
136
+ fields.push(trimmed);
137
+ return fields;
138
+ }
139
+ function extractInlineFieldNames(tsType) {
140
+ const body = extractObjectBody(tsType);
141
+ if (body === null)
142
+ return [];
143
+ return splitFieldsRespectingNesting(body)
144
+ .map((part) => part.split(':')[0].trim())
145
+ .filter((name) => name.length > 0);
146
+ }
147
+ function resolveNestedFieldNames(fieldType, model) {
148
+ const trimmed = fieldType.trim();
149
+ if (isInlineObject(trimmed) || isInlineObjectArray(trimmed)) {
150
+ return extractInlineFieldNames(trimmed);
151
+ }
152
+ const referencedMessage = model.messages.find((m) => m.name === trimmed);
153
+ if (referencedMessage) {
154
+ return referencedMessage.fields.map((f) => f.name);
155
+ }
156
+ return null;
157
+ }
158
+ function extractSelections(selectionSet) {
159
+ const fields = [];
160
+ for (const sel of selectionSet.selections) {
161
+ if (sel.kind !== 'Field')
162
+ continue;
163
+ if (sel.name.value === '__typename')
164
+ continue;
165
+ const field = { name: sel.name.value };
166
+ if (sel.selectionSet) {
167
+ field.children = extractSelections(sel.selectionSet);
168
+ }
169
+ fields.push(field);
170
+ }
171
+ return fields;
172
+ }
173
+ function validateQueryRequest(operation, model, slice, flowName, sliceName) {
174
+ const errors = [];
175
+ const operationName = operation.name.value;
176
+ if (operation.operation !== 'query') {
177
+ errors.push({
178
+ type: 'query_wrong_operation_type',
179
+ message: `Query slice '${sliceName}' request should be a query, but found ${operation.operation}`,
180
+ flowName,
181
+ sliceName,
182
+ });
183
+ return errors;
184
+ }
185
+ const targetName = slice.server?.data?.items?.[0]?.target?.name;
186
+ if (!targetName)
187
+ return errors;
188
+ const stateMessage = model.messages.find((m) => m.type === 'state' && m.name === targetName);
189
+ if (!stateMessage) {
190
+ errors.push({
191
+ type: 'query_state_not_found',
192
+ message: `State '${targetName}' referenced by query '${operationName}' not found in model.messages`,
193
+ flowName,
194
+ sliceName,
195
+ });
196
+ return errors;
197
+ }
198
+ const rootSelection = operation.selectionSet.selections[0];
199
+ if (!rootSelection || rootSelection.kind !== 'Field' || !rootSelection.selectionSet)
200
+ return errors;
201
+ const selectedFields = extractSelections(rootSelection.selectionSet);
202
+ const stateFieldNames = new Set(stateMessage.fields.map((f) => f.name));
203
+ for (const sel of selectedFields) {
204
+ if (!stateFieldNames.has(sel.name)) {
205
+ errors.push({
206
+ type: 'query_field_not_found',
207
+ message: `Field '${sel.name}' in query '${operationName}' not found on state '${targetName}'`,
208
+ flowName,
209
+ sliceName,
210
+ });
211
+ continue;
212
+ }
213
+ if (sel.children && sel.children.length > 0) {
214
+ const stateField = stateMessage.fields.find((f) => f.name === sel.name);
215
+ if (!stateField)
216
+ continue;
217
+ const nestedNames = resolveNestedFieldNames(stateField.type, model);
218
+ if (nestedNames === null)
219
+ continue;
220
+ const nestedNameSet = new Set(nestedNames);
221
+ for (const child of sel.children) {
222
+ if (!nestedNameSet.has(child.name)) {
223
+ errors.push({
224
+ type: 'query_nested_field_not_found',
225
+ message: `Nested field '${child.name}' in query '${operationName}' not found on type of '${sel.name}'`,
226
+ flowName,
227
+ sliceName,
228
+ });
229
+ }
230
+ }
231
+ }
232
+ }
233
+ return errors;
234
+ }
235
+ //# sourceMappingURL=validate-slice-requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-slice-requests.js","sourceRoot":"","sources":["../../src/validate-slice-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,EAAwC,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