@auto-engineer/narrative 0.12.0 → 0.12.1

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.
Files changed (73) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +11 -0
  3. package/dist/src/fluent-builder.d.ts.map +1 -1
  4. package/dist/src/fluent-builder.js +9 -12
  5. package/dist/src/fluent-builder.js.map +1 -1
  6. package/dist/src/getNarratives.specs.js +43 -27
  7. package/dist/src/getNarratives.specs.js.map +1 -1
  8. package/dist/src/id/addAutoIds.specs.js +11 -25
  9. package/dist/src/id/addAutoIds.specs.js.map +1 -1
  10. package/dist/src/id/hasAllIds.specs.js +12 -12
  11. package/dist/src/index.d.ts +2 -1
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/index.js +1 -1
  14. package/dist/src/index.js.map +1 -1
  15. package/dist/src/model-to-narrative.specs.js +110 -108
  16. package/dist/src/model-to-narrative.specs.js.map +1 -1
  17. package/dist/src/narrative-context.d.ts +4 -2
  18. package/dist/src/narrative-context.d.ts.map +1 -1
  19. package/dist/src/narrative-context.js +98 -95
  20. package/dist/src/narrative-context.js.map +1 -1
  21. package/dist/src/narrative.d.ts +7 -1
  22. package/dist/src/narrative.d.ts.map +1 -1
  23. package/dist/src/narrative.js +27 -6
  24. package/dist/src/narrative.js.map +1 -1
  25. package/dist/src/samples/items.narrative.js +7 -7
  26. package/dist/src/samples/items.narrative.js.map +1 -1
  27. package/dist/src/samples/place-order.narrative.js +4 -4
  28. package/dist/src/samples/place-order.narrative.js.map +1 -1
  29. package/dist/src/samples/questionnaires.narrative.js +16 -18
  30. package/dist/src/samples/questionnaires.narrative.js.map +1 -1
  31. package/dist/src/samples/seasonal-assistant.schema.json +37 -31
  32. package/dist/src/schema.d.ts +1156 -1527
  33. package/dist/src/schema.d.ts.map +1 -1
  34. package/dist/src/schema.js +22 -24
  35. package/dist/src/schema.js.map +1 -1
  36. package/dist/src/slice-builder.js +2 -2
  37. package/dist/src/slice-builder.js.map +1 -1
  38. package/dist/src/transformers/model-to-narrative/generators/flow.d.ts.map +1 -1
  39. package/dist/src/transformers/model-to-narrative/generators/flow.js +34 -10
  40. package/dist/src/transformers/model-to-narrative/generators/flow.js.map +1 -1
  41. package/dist/src/transformers/model-to-narrative/generators/imports.d.ts +1 -1
  42. package/dist/src/transformers/model-to-narrative/generators/imports.d.ts.map +1 -1
  43. package/dist/src/transformers/model-to-narrative/generators/imports.js +2 -1
  44. package/dist/src/transformers/model-to-narrative/generators/imports.js.map +1 -1
  45. package/dist/src/transformers/narrative-to-model/index.d.ts.map +1 -1
  46. package/dist/src/transformers/narrative-to-model/index.js +4 -8
  47. package/dist/src/transformers/narrative-to-model/index.js.map +1 -1
  48. package/dist/src/transformers/narrative-to-model/type-inference.specs.js +3 -3
  49. package/dist/src/transformers/narrative-to-model/type-inference.specs.js.map +1 -1
  50. package/dist/tsconfig.tsbuildinfo +1 -1
  51. package/package.json +5 -5
  52. package/src/fluent-builder.ts +9 -12
  53. package/src/getNarratives.specs.ts +43 -28
  54. package/src/id/addAutoIds.specs.ts +11 -25
  55. package/src/id/hasAllIds.specs.ts +12 -12
  56. package/src/index.ts +2 -1
  57. package/src/model-to-narrative.specs.ts +110 -108
  58. package/src/narrative-context.ts +103 -101
  59. package/src/narrative.ts +44 -6
  60. package/src/samples/items.narrative.ts +7 -7
  61. package/src/samples/place-order.narrative.ts +4 -4
  62. package/src/samples/questionnaires.narrative.ts +17 -18
  63. package/src/samples/seasonal-assistant.schema.json +37 -31
  64. package/src/schema.ts +33 -24
  65. package/src/slice-builder.ts +2 -2
  66. package/src/transformers/model-to-narrative/generators/flow.ts +53 -23
  67. package/src/transformers/model-to-narrative/generators/imports.ts +2 -1
  68. package/src/transformers/narrative-to-model/index.ts +4 -7
  69. package/src/transformers/narrative-to-model/type-inference.specs.ts +3 -3
  70. package/.turbo/turbo-format.log +0 -4
  71. package/.turbo/turbo-lint.log +0 -4
  72. package/.turbo/turbo-test.log +0 -14
  73. package/.turbo/turbo-type-check.log +0 -4
@@ -10,13 +10,14 @@ describe('modelToNarrative', () => {
10
10
  expect(code).toEqual(`import {
11
11
  command,
12
12
  data,
13
+ describe,
13
14
  example,
14
15
  gql,
16
+ it,
15
17
  narrative,
16
18
  query,
17
19
  react,
18
20
  rule,
19
- should,
20
21
  sink,
21
22
  source,
22
23
  specs,
@@ -92,13 +93,13 @@ type ItemsAddedToCart = Event<
92
93
  narrative('Seasonal Assistant', () => {
93
94
  command('enters shopping criteria into assistant')
94
95
  .client(() => {
95
- specs('Assistant Chat Interface', () => {
96
- should('allow shopper to describe their shopping needs in natural language');
97
- should('provide a text input for entering criteria');
98
- should('show examples of what to include (age, interests, budget)');
99
- should('show a button to submit the criteria');
100
- should('generate a persisted session id for a visit');
101
- should('show the header on top of the page');
96
+ describe('Assistant Chat Interface', () => {
97
+ it('allow shopper to describe their shopping needs in natural language');
98
+ it('provide a text input for entering criteria');
99
+ it('show examples of what to include (age, interests, budget)');
100
+ it('show a button to submit the criteria');
101
+ it('generate a persisted session id for a visit');
102
+ it('show the header on top of the page');
102
103
  });
103
104
  })
104
105
  .request(
@@ -236,11 +237,11 @@ narrative('Seasonal Assistant', () => {
236
237
  });
237
238
  query('views suggested items')
238
239
  .client(() => {
239
- specs('Suggested Items Screen', () => {
240
- should('display all suggested items with names and reasons');
241
- should('show quantity selectors for each item');
242
- should('have an "Add to Cart" button for selected items');
243
- should('allow removing items from the suggestions');
240
+ describe('Suggested Items Screen', () => {
241
+ it('display all suggested items with names and reasons');
242
+ it('show quantity selectors for each item');
243
+ it('have an "Add to Cart" button for selected items');
244
+ it('allow removing items from the suggestions');
244
245
  });
245
246
  })
246
247
  .request(
@@ -323,10 +324,10 @@ narrative('Seasonal Assistant', () => {
323
324
  });
324
325
  command('accepts items and adds to their cart')
325
326
  .client(() => {
326
- specs('Suggested Items Screen', () => {
327
- should('allow selecting specific items to add');
328
- should('update quantities before adding to cart');
329
- should('provide feedback when items are added');
327
+ describe('Suggested Items Screen', () => {
328
+ it('allow selecting specific items to add');
329
+ it('update quantities before adding to cart');
330
+ it('provide feedback when items are added');
330
331
  });
331
332
  })
332
333
  .server(() => {
@@ -372,10 +373,10 @@ narrative('Seasonal Assistant', () => {
372
373
  id: 'EXP-001',
373
374
  type: 'experience',
374
375
  client: {
375
- specs: {
376
- name: '',
377
- rules: ['show a hero section with a welcome message', 'allow user to start the questionnaire'],
378
- },
376
+ specs: [
377
+ { type: 'it', title: 'show a hero section with a welcome message' },
378
+ { type: 'it', title: 'allow user to start the questionnaire' },
379
+ ],
379
380
  },
380
381
  },
381
382
  ],
@@ -387,13 +388,11 @@ narrative('Seasonal Assistant', () => {
387
388
 
388
389
  const code = await modelToNarrative(experienceModel);
389
390
 
390
- expect(code).toEqual(`import { experience, narrative, should, specs } from '@auto-engineer/narrative';
391
+ expect(code).toEqual(`import { experience, it, narrative } from '@auto-engineer/narrative';
391
392
  narrative('Test Experience Flow', 'TEST-001', () => {
392
393
  experience('Homepage', 'EXP-001').client(() => {
393
- specs(() => {
394
- should('show a hero section with a welcome message');
395
- should('allow user to start the questionnaire');
396
- });
394
+ it('show a hero section with a welcome message');
395
+ it('allow user to start the questionnaire');
397
396
  });
398
397
  });
399
398
  `);
@@ -412,10 +411,16 @@ narrative('Test Experience Flow', 'TEST-001', () => {
412
411
  // id: undefined - no ID
413
412
  type: 'experience',
414
413
  client: {
415
- specs: {
416
- name: 'Homepage specs',
417
- rules: ['show welcome message', 'display navigation'],
418
- },
414
+ specs: [
415
+ {
416
+ type: 'describe',
417
+ title: 'Homepage specs',
418
+ children: [
419
+ { type: 'it', title: 'show welcome message' },
420
+ { type: 'it', title: 'display navigation' },
421
+ ],
422
+ },
423
+ ],
419
424
  },
420
425
  },
421
426
  ],
@@ -427,12 +432,12 @@ narrative('Test Experience Flow', 'TEST-001', () => {
427
432
 
428
433
  const code = await modelToNarrative(modelWithoutIds);
429
434
 
430
- expect(code).toEqual(`import { experience, narrative, should, specs } from '@auto-engineer/narrative';
435
+ expect(code).toEqual(`import { describe, experience, it, narrative } from '@auto-engineer/narrative';
431
436
  narrative('Test Flow without IDs', () => {
432
437
  experience('Homepage').client(() => {
433
- specs('Homepage specs', () => {
434
- should('show welcome message');
435
- should('display navigation');
438
+ describe('Homepage specs', () => {
439
+ it('show welcome message');
440
+ it('display navigation');
436
441
  });
437
442
  });
438
443
  });
@@ -452,10 +457,16 @@ narrative('Test Flow without IDs', () => {
452
457
  id: 'SLICE-ABC',
453
458
  type: 'experience',
454
459
  client: {
455
- specs: {
456
- name: 'Homepage specs',
457
- rules: ['show welcome message', 'display navigation'],
458
- },
460
+ specs: [
461
+ {
462
+ type: 'describe',
463
+ title: 'Homepage specs',
464
+ children: [
465
+ { type: 'it', title: 'show welcome message' },
466
+ { type: 'it', title: 'display navigation' },
467
+ ],
468
+ },
469
+ ],
459
470
  },
460
471
  },
461
472
  {
@@ -463,11 +474,16 @@ narrative('Test Flow without IDs', () => {
463
474
  id: 'SLICE-XYZ',
464
475
  type: 'query',
465
476
  client: {
466
- description: 'Product query client',
467
- specs: {
468
- name: 'Product list specs',
469
- rules: ['display all products', 'allow filtering'],
470
- },
477
+ specs: [
478
+ {
479
+ type: 'describe',
480
+ title: 'Product list specs',
481
+ children: [
482
+ { type: 'it', title: 'display all products' },
483
+ { type: 'it', title: 'allow filtering' },
484
+ ],
485
+ },
486
+ ],
471
487
  },
472
488
  server: {
473
489
  description: 'Product query server',
@@ -486,19 +502,19 @@ narrative('Test Flow without IDs', () => {
486
502
 
487
503
  const code = await modelToNarrative(modelWithIds);
488
504
 
489
- expect(code).toEqual(`import { experience, narrative, query, should, specs } from '@auto-engineer/narrative';
505
+ expect(code).toEqual(`import { describe, experience, it, narrative, query, specs } from '@auto-engineer/narrative';
490
506
  narrative('Test Flow with IDs', 'FLOW-123', () => {
491
507
  experience('Homepage', 'SLICE-ABC').client(() => {
492
- specs('Homepage specs', () => {
493
- should('show welcome message');
494
- should('display navigation');
508
+ describe('Homepage specs', () => {
509
+ it('show welcome message');
510
+ it('display navigation');
495
511
  });
496
512
  });
497
513
  query('view products', 'SLICE-XYZ')
498
514
  .client(() => {
499
- specs('Product list specs', () => {
500
- should('display all products');
501
- should('allow filtering');
515
+ describe('Product list specs', () => {
516
+ it('display all products');
517
+ it('allow filtering');
502
518
  });
503
519
  })
504
520
  .server(() => {
@@ -521,7 +537,7 @@ narrative('Test Flow with IDs', 'FLOW-123', () => {
521
537
  id: 'SLICE-789',
522
538
  type: 'command',
523
539
  client: {
524
- description: 'Command processing client',
540
+ specs: [],
525
541
  },
526
542
  server: {
527
543
  description: 'Command processing server',
@@ -690,10 +706,10 @@ narrative('Questionnaire Flow', 'QUEST-001', () => {});
690
706
  id: 'AUTO-H1a4Bn6Cy',
691
707
  type: 'experience',
692
708
  client: {
693
- specs: {
694
- name: '',
695
- rules: ['show a hero section with a welcome message', 'allow user to start the questionnaire'],
696
- },
709
+ specs: [
710
+ { type: 'it', title: 'show a hero section with a welcome message' },
711
+ { type: 'it', title: 'allow user to start the questionnaire' },
712
+ ],
697
713
  },
698
714
  },
699
715
  {
@@ -701,16 +717,18 @@ narrative('Questionnaire Flow', 'QUEST-001', () => {});
701
717
  id: 'AUTO-V7n8Rq5M',
702
718
  type: 'query',
703
719
  client: {
704
- description: '',
705
- specs: {
706
- name: 'Questionnaire Progress',
707
- rules: [
708
- 'focus on the current question based on the progress state',
709
- 'display the list of answered questions',
710
- 'display the list of remaining questions',
711
- 'show a progress indicator that is always visible as the user scrolls',
712
- ],
713
- },
720
+ specs: [
721
+ {
722
+ type: 'describe',
723
+ title: 'Questionnaire Progress',
724
+ children: [
725
+ { type: 'it', title: 'focus on the current question based on the progress state' },
726
+ { type: 'it', title: 'display the list of answered questions' },
727
+ { type: 'it', title: 'display the list of remaining questions' },
728
+ { type: 'it', title: 'show a progress indicator that is always visible as the user scrolls' },
729
+ ],
730
+ },
731
+ ],
714
732
  },
715
733
  request:
716
734
  'query QuestionnaireProgress($participantId: ID!) {\n questionnaireProgress(participantId: $participantId) {\n questionnaireId\n participantId\n currentQuestionId\n remainingQuestions\n status\n answers {\n questionId\n value\n }\n }\n}',
@@ -900,13 +918,14 @@ narrative('Questionnaire Flow', 'QUEST-001', () => {});
900
918
 
901
919
  expect(code).toEqual(`import {
902
920
  data,
921
+ describe,
903
922
  example,
904
923
  experience,
905
924
  gql,
925
+ it,
906
926
  narrative,
907
927
  query,
908
928
  rule,
909
- should,
910
929
  source,
911
930
  specs,
912
931
  } from '@auto-engineer/narrative';
@@ -946,18 +965,16 @@ type QuestionnaireProgress = State<
946
965
  >;
947
966
  narrative('Questionnaires', 'AUTO-Q9m2Kp4Lx', () => {
948
967
  experience('Homepage', 'AUTO-H1a4Bn6Cy').client(() => {
949
- specs(() => {
950
- should('show a hero section with a welcome message');
951
- should('allow user to start the questionnaire');
952
- });
968
+ it('show a hero section with a welcome message');
969
+ it('allow user to start the questionnaire');
953
970
  });
954
971
  query('views the questionnaire', 'AUTO-V7n8Rq5M')
955
972
  .client(() => {
956
- specs('Questionnaire Progress', () => {
957
- should('focus on the current question based on the progress state');
958
- should('display the list of answered questions');
959
- should('display the list of remaining questions');
960
- should('show a progress indicator that is always visible as the user scrolls');
973
+ describe('Questionnaire Progress', () => {
974
+ it('focus on the current question based on the progress state');
975
+ it('display the list of answered questions');
976
+ it('display the list of remaining questions');
977
+ it('show a progress indicator that is always visible as the user scrolls');
961
978
  });
962
979
  })
963
980
  .request(
@@ -1021,7 +1038,7 @@ narrative('Questionnaires', 'AUTO-Q9m2Kp4Lx', () => {
1021
1038
  id: 'TEST-SLICE',
1022
1039
  type: 'query',
1023
1040
  client: {
1024
- description: 'Test client for duplicate rules',
1041
+ specs: [],
1025
1042
  },
1026
1043
  server: {
1027
1044
  description: 'Test server for duplicate rules',
@@ -1188,7 +1205,7 @@ narrative('Test Flow', 'TEST-FLOW', () => {
1188
1205
  id: 'MULTI-SLICE',
1189
1206
  type: 'query',
1190
1207
  client: {
1191
- description: 'Multi given client',
1208
+ specs: [],
1192
1209
  },
1193
1210
  server: {
1194
1211
  description: 'Multi given server rules',
@@ -1435,7 +1452,7 @@ narrative('Multi Given Flow', 'MULTI-GIVEN', () => {
1435
1452
  id: 'REF-SLICE',
1436
1453
  type: 'query',
1437
1454
  client: {
1438
- description: 'Client for referenced states',
1455
+ specs: [],
1439
1456
  },
1440
1457
  server: {
1441
1458
  description: 'Server for referenced states',
@@ -1596,7 +1613,7 @@ narrative('Referenced States Flow', 'REF-STATES', () => {
1596
1613
  id: 'DATE-SLICE',
1597
1614
  type: 'query',
1598
1615
  client: {
1599
- description: 'Date client',
1616
+ specs: [],
1600
1617
  },
1601
1618
  server: {
1602
1619
  description: 'Date server with Date fields',
@@ -1748,10 +1765,7 @@ narrative('Date Handling Flow', 'DATE-FLOW', () => {
1748
1765
  id: 'AUTO-aifPcU3hw',
1749
1766
  type: 'experience',
1750
1767
  client: {
1751
- specs: {
1752
- name: '',
1753
- rules: ['show active surveys summary'],
1754
- },
1768
+ specs: [{ type: 'it', title: 'show active surveys summary' }],
1755
1769
  },
1756
1770
  },
1757
1771
  ],
@@ -1765,10 +1779,7 @@ narrative('Date Handling Flow', 'DATE-FLOW', () => {
1765
1779
  id: 'AUTO-MPviTMrQC',
1766
1780
  type: 'experience',
1767
1781
  client: {
1768
- specs: {
1769
- name: '',
1770
- rules: ['allow entering survey title'],
1771
- },
1782
+ specs: [{ type: 'it', title: 'allow entering survey title' }],
1772
1783
  },
1773
1784
  },
1774
1785
  ],
@@ -1782,10 +1793,7 @@ narrative('Date Handling Flow', 'DATE-FLOW', () => {
1782
1793
  id: 'AUTO-eME978Euk',
1783
1794
  type: 'experience',
1784
1795
  client: {
1785
- specs: {
1786
- name: '',
1787
- rules: ['show daily response rate charts'],
1788
- },
1796
+ specs: [{ type: 'it', title: 'show daily response rate charts' }],
1789
1797
  },
1790
1798
  },
1791
1799
  ],
@@ -1797,26 +1805,20 @@ narrative('Date Handling Flow', 'DATE-FLOW', () => {
1797
1805
 
1798
1806
  const code = await modelToNarrative(modelWithMultipleFlowsSameSource);
1799
1807
 
1800
- expect(code).toEqual(`import { experience, narrative, should, specs } from '@auto-engineer/narrative';
1808
+ expect(code).toEqual(`import { experience, it, narrative } from '@auto-engineer/narrative';
1801
1809
  narrative('Home Screen', () => {
1802
1810
  experience('Active Surveys Summary', 'AUTO-aifPcU3hw').client(() => {
1803
- specs(() => {
1804
- should('show active surveys summary');
1805
- });
1811
+ it('show active surveys summary');
1806
1812
  });
1807
1813
  });
1808
1814
  narrative('Create Survey', () => {
1809
1815
  experience('Create Survey Form', 'AUTO-MPviTMrQC').client(() => {
1810
- specs(() => {
1811
- should('allow entering survey title');
1812
- });
1816
+ it('allow entering survey title');
1813
1817
  });
1814
1818
  });
1815
1819
  narrative('Response Analytics', () => {
1816
1820
  experience('Response Rate Charts', 'AUTO-eME978Euk').client(() => {
1817
- specs(() => {
1818
- should('show daily response rate charts');
1819
- });
1821
+ it('show daily response rate charts');
1820
1822
  });
1821
1823
  });
1822
1824
  `);
@@ -1835,7 +1837,7 @@ narrative('Response Analytics', () => {
1835
1837
  id: 'SUMMARY-001',
1836
1838
  type: 'query',
1837
1839
  client: {
1838
- description: 'Summary view client',
1840
+ specs: [],
1839
1841
  },
1840
1842
  server: {
1841
1843
  description: 'Summary calculation server',
@@ -2048,7 +2050,7 @@ narrative('Todo List Summary', 'TODO-001', () => {
2048
2050
  id: 'SUMMARY-SLICE',
2049
2051
  type: 'query',
2050
2052
  client: {
2051
- description: 'Summary client',
2053
+ specs: [],
2052
2054
  },
2053
2055
  server: {
2054
2056
  description: 'Summary server',
@@ -2121,7 +2123,7 @@ narrative('Todo Summary Flow', 'TODO-SUMMARY', () => {
2121
2123
  id: 'TODO-SLICE',
2122
2124
  type: 'query',
2123
2125
  client: {
2124
- description: 'Todo client',
2126
+ specs: [],
2125
2127
  },
2126
2128
  server: {
2127
2129
  description: 'Todo server',
@@ -2194,7 +2196,7 @@ narrative('Todo Flow', 'TODO-FLOW', () => {
2194
2196
  id: 'USER-PROJECT-SLICE',
2195
2197
  type: 'query',
2196
2198
  client: {
2197
- description: 'User project client',
2199
+ specs: [],
2198
2200
  },
2199
2201
  server: {
2200
2202
  description: 'User project server',
@@ -2269,7 +2271,7 @@ narrative('User Project Flow', 'USER-PROJECT-FLOW', () => {
2269
2271
  id: 'SUMMARY-SLICE',
2270
2272
  type: 'query',
2271
2273
  client: {
2272
- description: 'Summary client',
2274
+ specs: [],
2273
2275
  },
2274
2276
  server: {
2275
2277
  description: 'Summary server',
@@ -2297,7 +2299,7 @@ narrative('User Project Flow', 'USER-PROJECT-FLOW', () => {
2297
2299
  id: 'TODO-SLICE',
2298
2300
  type: 'query',
2299
2301
  client: {
2300
- description: 'Todo client',
2302
+ specs: [],
2301
2303
  },
2302
2304
  server: {
2303
2305
  description: 'Todo server',
@@ -2325,7 +2327,7 @@ narrative('User Project Flow', 'USER-PROJECT-FLOW', () => {
2325
2327
  id: 'USER-PROJECT-SLICE',
2326
2328
  type: 'query',
2327
2329
  client: {
2328
- description: 'User project client',
2330
+ specs: [],
2329
2331
  },
2330
2332
  server: {
2331
2333
  description: 'User project server',