create-auto-app 0.2.2 → 0.3.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.
Files changed (324) hide show
  1. package/dist/index.js +5 -0
  2. package/dist/index.js.map +1 -1
  3. package/package.json +4 -3
  4. package/templates/.gitkeep +0 -0
  5. package/templates/shopping-app/.context/schema.json +11 -51
  6. package/templates/shopping-app/.context/server/server/package.json +26 -0
  7. package/templates/shopping-app/.context/server/server/scripts/generate-schema.ts +34 -0
  8. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/commands.ts +8 -0
  9. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/decide.specs.ts +46 -0
  10. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/decide.ts +33 -0
  11. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/events.ts +10 -0
  12. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/evolve.ts +28 -0
  13. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/handle.ts +24 -0
  14. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/mutation.resolver.ts +25 -0
  15. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/register.ts +7 -0
  16. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/accepts-items-and-adds-to-their-cart/state.ts +47 -0
  17. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/react.specs.ts +51 -0
  18. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/react.ts +43 -0
  19. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/creates-a-chat-session-/register.ts +24 -0
  20. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/commands.ts +8 -0
  21. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/decide.specs.ts +38 -0
  22. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/decide.ts +33 -0
  23. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/events.ts +10 -0
  24. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/evolve.ts +28 -0
  25. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/handle.ts +24 -0
  26. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/mutation.resolver.ts +25 -0
  27. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/register.ts +7 -0
  28. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/enters-shopping-criteria-into-assistant/state.ts +47 -0
  29. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/commands.ts +8 -0
  30. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/decide.specs.ts +61 -0
  31. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/decide.ts +35 -0
  32. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/events.ts +9 -0
  33. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/evolve.ts +28 -0
  34. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/handle.ts +49 -0
  35. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/mutation.resolver.ts +25 -0
  36. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/register.ts +7 -0
  37. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/selects-items-relevant-to-the-shopping-criteria-/state.ts +47 -0
  38. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/views-suggested-items/projection.specs.ts +94 -0
  39. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/views-suggested-items/projection.ts +37 -0
  40. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/views-suggested-items/query.resolver.ts +56 -0
  41. package/templates/shopping-app/.context/server/server/src/domain/flows/seasonal-assistant/views-suggested-items/state.ts +4 -0
  42. package/templates/shopping-app/.context/server/server/src/domain/shared/ReadModel.ts +26 -0
  43. package/templates/shopping-app/{server/src/domain/shared/index.d.ts → .context/server/server/src/domain/shared/index.ts} +0 -1
  44. package/templates/shopping-app/{server/src/domain/shared/reactorSpecification.js → .context/server/server/src/domain/shared/reactorSpecification.ts} +116 -22
  45. package/templates/shopping-app/.context/server/server/src/domain/shared/sendCommand.ts +21 -0
  46. package/templates/shopping-app/{server/src/domain/shared/types.d.ts → .context/server/server/src/domain/shared/types.ts} +17 -5
  47. package/templates/shopping-app/.context/server/server/src/server.ts +43 -0
  48. package/templates/shopping-app/{server/src/utils/index.d.ts → .context/server/server/src/utils/index.ts} +0 -1
  49. package/templates/shopping-app/{server/src/utils/loadProjections.js → .context/server/server/src/utils/loadProjections.ts} +11 -6
  50. package/templates/shopping-app/.context/server/server/src/utils/loadRegisterFiles.ts +41 -0
  51. package/templates/shopping-app/{server/src/utils/loadResolvers.js → .context/server/server/src/utils/loadResolvers.ts} +16 -7
  52. package/templates/shopping-app/.context/server/server/tsconfig.json +13 -0
  53. package/templates/shopping-app/.context/server/server/vitest.config.ts +7 -0
  54. package/templates/shopping-app/auto.config.ts +162 -4
  55. package/templates/shopping-app/client/package.json +1 -1
  56. package/templates/shopping-app/client/src/App.tsx +13 -13
  57. package/templates/shopping-app/client/src/components/molecules/QuantitySelector.tsx +4 -4
  58. package/templates/shopping-app/client/src/components/molecules/ShoppingCriteriaForm.tsx +4 -4
  59. package/templates/shopping-app/client/src/components/molecules/SuggestedItemCard.tsx +6 -6
  60. package/templates/shopping-app/client/src/components/organisms/AssistantChatInterface.tsx +3 -3
  61. package/templates/shopping-app/client/src/components/organisms/PageHeader.tsx +2 -3
  62. package/templates/shopping-app/client/src/components/organisms/SuggestedItemsList.tsx +3 -3
  63. package/templates/shopping-app/client/src/index.css +10 -14
  64. package/templates/shopping-app/client/src/pages/AssistantChatPage.tsx +4 -4
  65. package/templates/shopping-app/client/src/pages/SuggestedItemsPage.tsx +4 -4
  66. package/templates/shopping-app/example-integrations/ai-chat-completion/package.json +1 -1
  67. package/templates/shopping-app/example-integrations/cart/package.json +1 -1
  68. package/templates/shopping-app/example-integrations/product-catalogue/package.json +1 -1
  69. package/templates/shopping-app/example-integrations/product-catalogue/src/product-catalogue-integration.ts +122 -115
  70. package/templates/shopping-app/flows/shopping-assistant.flow.ts +0 -1
  71. package/templates/shopping-app/package.json +13 -10
  72. package/templates/shopping-app/server/package.json +2 -2
  73. package/templates/shopping-app/.env +0 -8
  74. package/templates/shopping-app/example-integrations/ai-chat-completion/.turbo/turbo-build.log +0 -4
  75. package/templates/shopping-app/example-integrations/ai-chat-completion/.turbo/turbo-format.log +0 -12
  76. package/templates/shopping-app/example-integrations/ai-chat-completion/.turbo/turbo-lint.log +0 -4
  77. package/templates/shopping-app/example-integrations/ai-chat-completion/.turbo/turbo-test.log +0 -12
  78. package/templates/shopping-app/example-integrations/ai-chat-completion/.turbo/turbo-type-check.log +0 -5
  79. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/ai-integration.d.ts +0 -23
  80. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/ai-integration.d.ts.map +0 -1
  81. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/ai-integration.js +0 -41
  82. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/ai-integration.js.map +0 -1
  83. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/index.d.ts +0 -2
  84. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/index.d.ts.map +0 -1
  85. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/index.js +0 -2
  86. package/templates/shopping-app/example-integrations/ai-chat-completion/dist/index.js.map +0 -1
  87. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/eslint +0 -21
  88. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/jiti +0 -21
  89. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/msw +0 -21
  90. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/tsc +0 -21
  91. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/tsserver +0 -21
  92. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/vite +0 -21
  93. package/templates/shopping-app/example-integrations/ai-chat-completion/node_modules/.bin/vitest +0 -21
  94. package/templates/shopping-app/example-integrations/cart/.turbo/turbo-build.log +0 -4
  95. package/templates/shopping-app/example-integrations/cart/.turbo/turbo-format.log +0 -12
  96. package/templates/shopping-app/example-integrations/cart/.turbo/turbo-lint.log +0 -5
  97. package/templates/shopping-app/example-integrations/cart/.turbo/turbo-test.log +0 -12
  98. package/templates/shopping-app/example-integrations/cart/.turbo/turbo-type-check.log +0 -5
  99. package/templates/shopping-app/example-integrations/cart/dist/cart-integration.d.ts +0 -30
  100. package/templates/shopping-app/example-integrations/cart/dist/cart-integration.d.ts.map +0 -1
  101. package/templates/shopping-app/example-integrations/cart/dist/cart-integration.js +0 -134
  102. package/templates/shopping-app/example-integrations/cart/dist/cart-integration.js.map +0 -1
  103. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/client.gen.d.ts +0 -3
  104. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/client.gen.d.ts.map +0 -1
  105. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/client.gen.js +0 -149
  106. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/client.gen.js.map +0 -1
  107. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/index.d.ts +0 -8
  108. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/index.d.ts.map +0 -1
  109. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/index.js +0 -6
  110. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/index.js.map +0 -1
  111. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/types.gen.d.ts +0 -123
  112. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/types.gen.d.ts.map +0 -1
  113. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/types.gen.js +0 -3
  114. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/types.gen.js.map +0 -1
  115. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/utils.gen.d.ts +0 -46
  116. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/utils.gen.d.ts.map +0 -1
  117. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/utils.gen.js +0 -285
  118. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client/utils.gen.js.map +0 -1
  119. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client.gen.d.ts +0 -13
  120. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client.gen.d.ts.map +0 -1
  121. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client.gen.js +0 -6
  122. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/client.gen.js.map +0 -1
  123. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/auth.gen.d.ts +0 -19
  124. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/auth.gen.d.ts.map +0 -1
  125. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/auth.gen.js +0 -15
  126. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/auth.gen.js.map +0 -1
  127. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/bodySerializer.gen.d.ts +0 -18
  128. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/bodySerializer.gen.d.ts.map +0 -1
  129. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/bodySerializer.gen.js +0 -58
  130. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/bodySerializer.gen.js.map +0 -1
  131. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/params.gen.d.ts +0 -34
  132. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/params.gen.d.ts.map +0 -1
  133. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/params.gen.js +0 -89
  134. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/params.gen.js.map +0 -1
  135. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/pathSerializer.gen.d.ts +0 -34
  136. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/pathSerializer.gen.d.ts.map +0 -1
  137. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/pathSerializer.gen.js +0 -115
  138. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/pathSerializer.gen.js.map +0 -1
  139. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/types.gen.d.ts +0 -79
  140. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/types.gen.d.ts.map +0 -1
  141. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/types.gen.js +0 -3
  142. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/core/types.gen.js.map +0 -1
  143. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/index.d.ts +0 -2
  144. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/index.d.ts.map +0 -1
  145. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/index.js +0 -3
  146. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/index.js.map +0 -1
  147. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/types.gen.d.ts +0 -158
  148. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/types.gen.d.ts.map +0 -1
  149. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/types.gen.js +0 -3
  150. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/types.gen.js.map +0 -1
  151. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/zod.gen.d.ts +0 -382
  152. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/zod.gen.d.ts.map +0 -1
  153. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/zod.gen.js +0 -68
  154. package/templates/shopping-app/example-integrations/cart/dist/generated/cart/zod.gen.js.map +0 -1
  155. package/templates/shopping-app/example-integrations/cart/dist/index.d.ts +0 -2
  156. package/templates/shopping-app/example-integrations/cart/dist/index.d.ts.map +0 -1
  157. package/templates/shopping-app/example-integrations/cart/dist/index.js +0 -2
  158. package/templates/shopping-app/example-integrations/cart/dist/index.js.map +0 -1
  159. package/templates/shopping-app/example-integrations/cart/node_modules/.bin/eslint +0 -21
  160. package/templates/shopping-app/example-integrations/cart/node_modules/.bin/jiti +0 -21
  161. package/templates/shopping-app/example-integrations/cart/node_modules/.bin/msw +0 -21
  162. package/templates/shopping-app/example-integrations/cart/node_modules/.bin/tsc +0 -21
  163. package/templates/shopping-app/example-integrations/cart/node_modules/.bin/tsserver +0 -21
  164. package/templates/shopping-app/example-integrations/cart/node_modules/.bin/vitest +0 -21
  165. package/templates/shopping-app/example-integrations/cart-api/.turbo/turbo-build.log +0 -4
  166. package/templates/shopping-app/example-integrations/cart-api/.turbo/turbo-format.log +0 -10
  167. package/templates/shopping-app/example-integrations/cart-api/.turbo/turbo-lint.log +0 -4
  168. package/templates/shopping-app/example-integrations/cart-api/.turbo/turbo-test.log +0 -12
  169. package/templates/shopping-app/example-integrations/cart-api/.turbo/turbo-type-check.log +0 -4
  170. package/templates/shopping-app/example-integrations/cart-api/dist/data/cart.d.ts +0 -18
  171. package/templates/shopping-app/example-integrations/cart-api/dist/data/cart.d.ts.map +0 -1
  172. package/templates/shopping-app/example-integrations/cart-api/dist/data/cart.js +0 -28
  173. package/templates/shopping-app/example-integrations/cart-api/dist/data/cart.js.map +0 -1
  174. package/templates/shopping-app/example-integrations/cart-api/dist/index.d.ts +0 -4
  175. package/templates/shopping-app/example-integrations/cart-api/dist/index.d.ts.map +0 -1
  176. package/templates/shopping-app/example-integrations/cart-api/dist/index.js +0 -49
  177. package/templates/shopping-app/example-integrations/cart-api/dist/index.js.map +0 -1
  178. package/templates/shopping-app/example-integrations/cart-api/dist/routes/cart.d.ts +0 -4
  179. package/templates/shopping-app/example-integrations/cart-api/dist/routes/cart.d.ts.map +0 -1
  180. package/templates/shopping-app/example-integrations/cart-api/dist/routes/cart.js +0 -261
  181. package/templates/shopping-app/example-integrations/cart-api/dist/routes/cart.js.map +0 -1
  182. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/nodemon +0 -21
  183. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/swagger-jsdoc +0 -21
  184. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/ts-node +0 -21
  185. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/ts-node-cwd +0 -21
  186. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/ts-node-esm +0 -21
  187. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/ts-node-script +0 -21
  188. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/ts-node-transpile-only +0 -21
  189. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/ts-script +0 -21
  190. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/tsc +0 -21
  191. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/tsserver +0 -21
  192. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/tsx +0 -21
  193. package/templates/shopping-app/example-integrations/cart-api/node_modules/.bin/vitest +0 -21
  194. package/templates/shopping-app/example-integrations/product-catalogue/.turbo/turbo-build.log +0 -4
  195. package/templates/shopping-app/example-integrations/product-catalogue/.turbo/turbo-format.log +0 -12
  196. package/templates/shopping-app/example-integrations/product-catalogue/.turbo/turbo-lint.log +0 -5
  197. package/templates/shopping-app/example-integrations/product-catalogue/.turbo/turbo-test.log +0 -12
  198. package/templates/shopping-app/example-integrations/product-catalogue/.turbo/turbo-type-check.log +0 -5
  199. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/client.gen.d.ts +0 -3
  200. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/client.gen.d.ts.map +0 -1
  201. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/client.gen.js +0 -149
  202. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/client.gen.js.map +0 -1
  203. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/index.d.ts +0 -8
  204. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/index.d.ts.map +0 -1
  205. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/index.js +0 -6
  206. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/index.js.map +0 -1
  207. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/types.gen.d.ts +0 -123
  208. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/types.gen.d.ts.map +0 -1
  209. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/types.gen.js +0 -3
  210. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/types.gen.js.map +0 -1
  211. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/utils.gen.d.ts +0 -46
  212. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/utils.gen.d.ts.map +0 -1
  213. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/utils.gen.js +0 -285
  214. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client/utils.gen.js.map +0 -1
  215. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client.gen.d.ts +0 -13
  216. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client.gen.d.ts.map +0 -1
  217. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client.gen.js +0 -6
  218. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/client.gen.js.map +0 -1
  219. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/auth.gen.d.ts +0 -19
  220. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/auth.gen.d.ts.map +0 -1
  221. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/auth.gen.js +0 -15
  222. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/auth.gen.js.map +0 -1
  223. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/bodySerializer.gen.d.ts +0 -18
  224. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/bodySerializer.gen.d.ts.map +0 -1
  225. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/bodySerializer.gen.js +0 -58
  226. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/bodySerializer.gen.js.map +0 -1
  227. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/params.gen.d.ts +0 -34
  228. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/params.gen.d.ts.map +0 -1
  229. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/params.gen.js +0 -89
  230. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/params.gen.js.map +0 -1
  231. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/pathSerializer.gen.d.ts +0 -34
  232. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/pathSerializer.gen.d.ts.map +0 -1
  233. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/pathSerializer.gen.js +0 -115
  234. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/pathSerializer.gen.js.map +0 -1
  235. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/types.gen.d.ts +0 -79
  236. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/types.gen.d.ts.map +0 -1
  237. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/types.gen.js +0 -3
  238. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/core/types.gen.js.map +0 -1
  239. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/index.d.ts +0 -2
  240. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/index.d.ts.map +0 -1
  241. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/index.js +0 -3
  242. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/index.js.map +0 -1
  243. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/types.gen.d.ts +0 -115
  244. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/types.gen.d.ts.map +0 -1
  245. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/types.gen.js +0 -3
  246. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/types.gen.js.map +0 -1
  247. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/zod.gen.d.ts +0 -206
  248. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/zod.gen.d.ts.map +0 -1
  249. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/zod.gen.js +0 -53
  250. package/templates/shopping-app/example-integrations/product-catalogue/dist/generated/product-catalog/zod.gen.js.map +0 -1
  251. package/templates/shopping-app/example-integrations/product-catalogue/dist/index.d.ts +0 -2
  252. package/templates/shopping-app/example-integrations/product-catalogue/dist/index.d.ts.map +0 -1
  253. package/templates/shopping-app/example-integrations/product-catalogue/dist/index.js +0 -2
  254. package/templates/shopping-app/example-integrations/product-catalogue/dist/index.js.map +0 -1
  255. package/templates/shopping-app/example-integrations/product-catalogue/dist/product-catalogue-integration.d.ts +0 -32
  256. package/templates/shopping-app/example-integrations/product-catalogue/dist/product-catalogue-integration.d.ts.map +0 -1
  257. package/templates/shopping-app/example-integrations/product-catalogue/dist/product-catalogue-integration.js +0 -163
  258. package/templates/shopping-app/example-integrations/product-catalogue/dist/product-catalogue-integration.js.map +0 -1
  259. package/templates/shopping-app/example-integrations/product-catalogue/node_modules/.bin/eslint +0 -21
  260. package/templates/shopping-app/example-integrations/product-catalogue/node_modules/.bin/jiti +0 -21
  261. package/templates/shopping-app/example-integrations/product-catalogue/node_modules/.bin/msw +0 -21
  262. package/templates/shopping-app/example-integrations/product-catalogue/node_modules/.bin/tsc +0 -21
  263. package/templates/shopping-app/example-integrations/product-catalogue/node_modules/.bin/tsserver +0 -21
  264. package/templates/shopping-app/example-integrations/product-catalogue/node_modules/.bin/vitest +0 -21
  265. package/templates/shopping-app/example-integrations/product-catalogue-api/.turbo/turbo-build.log +0 -4
  266. package/templates/shopping-app/example-integrations/product-catalogue-api/.turbo/turbo-format.log +0 -10
  267. package/templates/shopping-app/example-integrations/product-catalogue-api/.turbo/turbo-lint.log +0 -5
  268. package/templates/shopping-app/example-integrations/product-catalogue-api/.turbo/turbo-test.log +0 -13
  269. package/templates/shopping-app/example-integrations/product-catalogue-api/.turbo/turbo-type-check.log +0 -5
  270. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/data/products.d.ts +0 -10
  271. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/data/products.d.ts.map +0 -1
  272. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/data/products.js +0 -75
  273. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/data/products.js.map +0 -1
  274. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/index.d.ts +0 -4
  275. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/index.d.ts.map +0 -1
  276. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/index.js +0 -49
  277. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/index.js.map +0 -1
  278. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/routes/products.d.ts +0 -4
  279. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/routes/products.d.ts.map +0 -1
  280. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/routes/products.js +0 -170
  281. package/templates/shopping-app/example-integrations/product-catalogue-api/dist/routes/products.js.map +0 -1
  282. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/nodemon +0 -21
  283. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/swagger-jsdoc +0 -21
  284. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/ts-node +0 -21
  285. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/ts-node-cwd +0 -21
  286. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/ts-node-esm +0 -21
  287. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/ts-node-script +0 -21
  288. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/ts-node-transpile-only +0 -21
  289. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/ts-script +0 -21
  290. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/tsc +0 -21
  291. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/tsserver +0 -21
  292. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/tsx +0 -21
  293. package/templates/shopping-app/example-integrations/product-catalogue-api/node_modules/.bin/vitest +0 -21
  294. package/templates/shopping-app/pnpm-workspace.yaml +0 -2
  295. package/templates/shopping-app/server/src/domain/shared/ReadModel.d.ts +0 -10
  296. package/templates/shopping-app/server/src/domain/shared/ReadModel.d.ts.map +0 -1
  297. package/templates/shopping-app/server/src/domain/shared/ReadModel.js +0 -19
  298. package/templates/shopping-app/server/src/domain/shared/ReadModel.js.map +0 -1
  299. package/templates/shopping-app/server/src/domain/shared/index.d.ts.map +0 -1
  300. package/templates/shopping-app/server/src/domain/shared/index.js +0 -5
  301. package/templates/shopping-app/server/src/domain/shared/index.js.map +0 -1
  302. package/templates/shopping-app/server/src/domain/shared/reactorSpecification.d.ts +0 -56
  303. package/templates/shopping-app/server/src/domain/shared/reactorSpecification.d.ts.map +0 -1
  304. package/templates/shopping-app/server/src/domain/shared/reactorSpecification.js.map +0 -1
  305. package/templates/shopping-app/server/src/domain/shared/sendCommand.d.ts +0 -7
  306. package/templates/shopping-app/server/src/domain/shared/sendCommand.d.ts.map +0 -1
  307. package/templates/shopping-app/server/src/domain/shared/sendCommand.js +0 -16
  308. package/templates/shopping-app/server/src/domain/shared/sendCommand.js.map +0 -1
  309. package/templates/shopping-app/server/src/domain/shared/types.d.ts.map +0 -1
  310. package/templates/shopping-app/server/src/domain/shared/types.js +0 -40
  311. package/templates/shopping-app/server/src/domain/shared/types.js.map +0 -1
  312. package/templates/shopping-app/server/src/utils/index.d.ts.map +0 -1
  313. package/templates/shopping-app/server/src/utils/index.js +0 -4
  314. package/templates/shopping-app/server/src/utils/index.js.map +0 -1
  315. package/templates/shopping-app/server/src/utils/loadProjections.d.ts +0 -3
  316. package/templates/shopping-app/server/src/utils/loadProjections.d.ts.map +0 -1
  317. package/templates/shopping-app/server/src/utils/loadProjections.js.map +0 -1
  318. package/templates/shopping-app/server/src/utils/loadRegisterFiles.d.ts +0 -6
  319. package/templates/shopping-app/server/src/utils/loadRegisterFiles.d.ts.map +0 -1
  320. package/templates/shopping-app/server/src/utils/loadRegisterFiles.js +0 -26
  321. package/templates/shopping-app/server/src/utils/loadRegisterFiles.js.map +0 -1
  322. package/templates/shopping-app/server/src/utils/loadResolvers.d.ts +0 -5
  323. package/templates/shopping-app/server/src/utils/loadResolvers.d.ts.map +0 -1
  324. package/templates/shopping-app/server/src/utils/loadResolvers.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import { describe, it } from 'vitest';
2
+ import { DeciderSpecification } from '@event-driven-io/emmett';
3
+ import { decide } from './decide';
4
+ import { evolve } from './evolve';
5
+ import { initialState } from './state';
6
+
7
+ describe('Seasonal Assistant | enters shopping criteria into assistant', () => {
8
+ const given = DeciderSpecification.for({
9
+ decide,
10
+ evolve,
11
+ initialState,
12
+ });
13
+
14
+ it('should emit ShoppingCriteriaEntered for valid EnterShoppingCriteria', () => {
15
+ given([])
16
+ .when({
17
+ type: 'EnterShoppingCriteria',
18
+ data: {
19
+ sessionId: 'shopper-123',
20
+ criteria:
21
+ 'I need back-to-school items for my 7-year-old daughter who loves soccer and crafts, and my 12-year-old son who is into computers and Magic the Gathering.',
22
+ },
23
+ metadata: { now: new Date() },
24
+ })
25
+
26
+ .then([
27
+ {
28
+ type: 'ShoppingCriteriaEntered',
29
+ data: {
30
+ sessionId: 'shopper-123',
31
+ criteria:
32
+ 'I need back-to-school items for my 7-year-old daughter who loves soccer and crafts, and my 12-year-old son who is into computers and Magic the Gathering.',
33
+ timestamp: new Date('2025-09-02T00:39:41.677Z'),
34
+ },
35
+ },
36
+ ]);
37
+ });
38
+ });
@@ -0,0 +1,33 @@
1
+ import { IllegalStateError } from '@event-driven-io/emmett';
2
+ import type { State } from './state';
3
+ import type { EnterShoppingCriteria } from './commands';
4
+ import type { ShoppingCriteriaEntered } from './events';
5
+
6
+ export const decide = (command: EnterShoppingCriteria, state: State): ShoppingCriteriaEntered => {
7
+ switch (command.type) {
8
+ case 'EnterShoppingCriteria': {
9
+ /**
10
+ * ## IMPLEMENTATION INSTRUCTIONS ##
11
+ *
12
+ * This command can directly emit one or more events based on the input.
13
+ *
14
+ * You should:
15
+ * - Validate the command input fields
16
+ * - Inspect the current domain `state` to determine if the command is allowed
17
+ * - If invalid, throw one of the following domain errors: `NotFoundError`, `ValidationError`, or `IllegalStateError`
18
+ * - If valid, return one or more events with the correct structure
19
+ *
20
+ * ⚠️ Only read from inputs — never mutate them. `evolve.ts` handles state updates.
21
+ */
22
+
23
+ // return {
24
+ // type: 'ShoppingCriteriaEntered',
25
+ // data: { ...command.data },
26
+ // } as ShoppingCriteriaEntered;
27
+
28
+ throw new IllegalStateError('Not yet implemented: ' + command.type);
29
+ }
30
+ default:
31
+ throw new IllegalStateError('Unexpected command type: ' + command.type);
32
+ }
33
+ };
@@ -0,0 +1,10 @@
1
+ import type { Event } from '@event-driven-io/emmett';
2
+
3
+ export type ShoppingCriteriaEntered = Event<
4
+ 'ShoppingCriteriaEntered',
5
+ {
6
+ sessionId: string;
7
+ criteria: string;
8
+ timestamp: Date;
9
+ }
10
+ >;
@@ -0,0 +1,28 @@
1
+ import type { State } from './state';
2
+ import type { ShoppingCriteriaEntered } from './events';
3
+
4
+ /**
5
+ * ## IMPLEMENTATION INSTRUCTIONS ##
6
+ *
7
+ * This function defines how the domain state evolves in response to events.
8
+ *
9
+ * Guidelines:
10
+ * - Apply only the **minimal** necessary changes for future decisions in `decide.ts`.
11
+ * - Ignore any event fields not required for decision-making logic.
12
+ * - If the event doesn’t change decision-relevant state, return the existing `state`.
13
+ * - Prefer immutability: always return a **new state object**.
14
+ * - Avoid spreading all of `event.data` unless all fields are relevant.
15
+ */
16
+
17
+ export const evolve = (state: State, event: ShoppingCriteriaEntered): State => {
18
+ switch (event.type) {
19
+ case 'ShoppingCriteriaEntered': {
20
+ // TODO: Update state based on ShoppingCriteriaEntered
21
+ return {
22
+ ...state,
23
+ };
24
+ }
25
+ default:
26
+ return state;
27
+ }
28
+ };
@@ -0,0 +1,24 @@
1
+ import { CommandHandler, type EventStore, type MessageHandlerResult } from '@event-driven-io/emmett';
2
+ import { evolve } from './evolve';
3
+ import { initialState } from './state';
4
+ import { decide } from './decide';
5
+ import type { EnterShoppingCriteria } from './commands';
6
+
7
+ const handler = CommandHandler({
8
+ evolve,
9
+ initialState,
10
+ });
11
+
12
+ export const handle = async (eventStore: EventStore, command: EnterShoppingCriteria): Promise<MessageHandlerResult> => {
13
+ const streamId = `shopping-session-${command.data.sessionId}`;
14
+
15
+ try {
16
+ await handler(eventStore, streamId, (state) => decide(command, state));
17
+ return; // success (returns void)
18
+ } catch (error: any) {
19
+ return {
20
+ type: 'SKIP',
21
+ reason: `Command failed: ${error?.message ?? 'Unknown'}`,
22
+ };
23
+ }
24
+ };
@@ -0,0 +1,25 @@
1
+ import { Mutation, Resolver, Arg, Ctx, Field, InputType } from 'type-graphql';
2
+ import { type GraphQLContext, sendCommand, MutationResponse } from '../../../shared';
3
+
4
+ @InputType()
5
+ export class EnterShoppingCriteriaInput {
6
+ @Field(() => String)
7
+ sessionId!: string;
8
+ @Field(() => String)
9
+ criteria!: string;
10
+ }
11
+
12
+ @Resolver()
13
+ export class EnterShoppingCriteriaResolver {
14
+ @Mutation(() => MutationResponse)
15
+ async enterShoppingCriteria(
16
+ @Arg('input', () => EnterShoppingCriteriaInput) input: EnterShoppingCriteriaInput,
17
+ @Ctx() ctx: GraphQLContext,
18
+ ): Promise<MutationResponse> {
19
+ return await sendCommand(ctx.messageBus, {
20
+ type: 'EnterShoppingCriteria',
21
+ kind: 'Command',
22
+ data: { ...input },
23
+ });
24
+ }
25
+ }
@@ -0,0 +1,7 @@
1
+ import type { CommandProcessor, EventStore } from '@event-driven-io/emmett';
2
+ import { handle } from './handle';
3
+ import type { EnterShoppingCriteria } from './commands';
4
+
5
+ export function register(messageBus: CommandProcessor, eventStore: EventStore) {
6
+ messageBus.handle((command: EnterShoppingCriteria) => handle(eventStore, command), 'EnterShoppingCriteria');
7
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ## IMPLEMENTATION INSTRUCTIONS ##
3
+ *
4
+ * Define the shape of the domain state for the current slice below. This state is used by `decide.ts`
5
+ * to determine whether a command is valid.
6
+ *
7
+ * The state is evolved over time by applying domain events (in `evolve.ts`).
8
+ * Each event updates the state incrementally based on business rules.
9
+ *
10
+ * Guidelines:
11
+ * - Include only fields that are **read** during command validation.
12
+ * - Use discriminated unions (e.g., `status: 'Pending' | 'Done'`) to model state transitions.
13
+ * - Prefer primitive types: `string`, `boolean`, `number`.
14
+ * - Use objects or maps only when structure is essential for decision logic.
15
+ *
16
+ * Do NOT include:
17
+ * - Redundant data already emitted in events unless required to enforce business rules.
18
+ * - Fields used only for projections, UI, or query purposes.
19
+ *
20
+ * ### Example (for a Task domain):
21
+ *
22
+ * ```ts
23
+ * export type PendingTask = {
24
+ * status: 'Pending';
25
+ * };
26
+ *
27
+ * export type InProgressTask = {
28
+ * status: 'InProgress';
29
+ * startedAt: string;
30
+ * };
31
+ *
32
+ * export type CompletedTask = {
33
+ * status: 'Completed';
34
+ * completedAt: string;
35
+ * };
36
+ *
37
+ * export type State = PendingTask | InProgressTask | CompletedTask;
38
+ * ```
39
+ */
40
+
41
+ // TODO: Replace with a discriminated union of domain states for the current slice
42
+ export type State = {};
43
+
44
+ // TODO: Replace the Return with the initial domain state of the current slice
45
+ export const initialState = (): State => {
46
+ return {};
47
+ };
@@ -0,0 +1,8 @@
1
+ import { Command } from '@event-driven-io/emmett';
2
+ export type SuggestShoppingItems = Command<
3
+ 'SuggestShoppingItems',
4
+ {
5
+ sessionId: string;
6
+ prompt: string;
7
+ }
8
+ >;
@@ -0,0 +1,61 @@
1
+ import { describe, it } from 'vitest';
2
+ import { DeciderSpecification } from '@event-driven-io/emmett';
3
+ import { decide } from './decide';
4
+ import { evolve } from './evolve';
5
+ import { initialState } from './state';
6
+
7
+ describe('Seasonal Assistant | selects items relevant to the shopping criteria ', () => {
8
+ const given = DeciderSpecification.for({
9
+ decide,
10
+ evolve,
11
+ initialState,
12
+ });
13
+
14
+ it('should emit ShoppingItemsSuggested for valid SuggestShoppingItems', () => {
15
+ given([])
16
+ .when({
17
+ type: 'SuggestShoppingItems',
18
+ data: {
19
+ sessionId: 'session-abc',
20
+ prompt:
21
+ 'I need back-to-school items for my 7-year-old daughter who loves soccer and crafts, and my 12-year-old son who is into computers and Magic the Gathering.',
22
+ },
23
+ metadata: { now: new Date() },
24
+ })
25
+
26
+ .then([
27
+ {
28
+ type: 'ShoppingItemsSuggested',
29
+ data: {
30
+ sessionId: 'session-abc',
31
+ suggestedItems: [
32
+ {
33
+ productId: 'prod-soccer-ball',
34
+ name: 'Super Soccer Ball',
35
+ quantity: 1,
36
+ reason: 'Perfect for your daughter who loves soccer',
37
+ },
38
+ {
39
+ productId: 'prod-craft-kit',
40
+ name: 'Deluxe Craft Kit',
41
+ quantity: 1,
42
+ reason: 'Great for creative activities and crafts',
43
+ },
44
+ {
45
+ productId: 'prod-laptop-bag',
46
+ name: 'Tech Laptop Backpack',
47
+ quantity: 1,
48
+ reason: "Essential for your son's school computer needs",
49
+ },
50
+ {
51
+ productId: 'prod-mtg-starter',
52
+ name: 'Magic the Gathering Starter Set',
53
+ quantity: 1,
54
+ reason: 'Ideal starter set for Magic the Gathering enthusiasts',
55
+ },
56
+ ],
57
+ },
58
+ },
59
+ ]);
60
+ });
61
+ });
@@ -0,0 +1,35 @@
1
+ import { IllegalStateError } from '@event-driven-io/emmett';
2
+ import type { State } from './state';
3
+ import type { SuggestShoppingItems } from './commands';
4
+ import type { ShoppingItemsSuggested } from './events';
5
+ import type { Products } from '@auto-engineer/product-catalog-integration';
6
+
7
+ export const decide = (command: SuggestShoppingItems, state: State, products?: Products): ShoppingItemsSuggested => {
8
+ switch (command.type) {
9
+ case 'SuggestShoppingItems': {
10
+ /**
11
+ * ## IMPLEMENTATION INSTRUCTIONS ##
12
+ *
13
+ * This command can directly emit one or more events based on the input.
14
+ *
15
+ * You should:
16
+ * - Validate the command input fields
17
+ * - Inspect the current domain `state` to determine if the command is allowed
18
+ * - Use `products` (integration result) to enrich or filter the output
19
+ * - If invalid, throw one of the following domain errors: `NotFoundError`, `ValidationError`, or `IllegalStateError`
20
+ * - If valid, return one or more events with the correct structure
21
+ *
22
+ * ⚠️ Only read from inputs — never mutate them. `evolve.ts` handles state updates.
23
+ */
24
+
25
+ // return {
26
+ // type: 'ShoppingItemsSuggested',
27
+ // data: { ...command.data },
28
+ // } as ShoppingItemsSuggested;
29
+
30
+ throw new IllegalStateError('Not yet implemented: ' + command.type);
31
+ }
32
+ default:
33
+ throw new IllegalStateError('Unexpected command type: ' + command.type);
34
+ }
35
+ };
@@ -0,0 +1,9 @@
1
+ import type { Event } from '@event-driven-io/emmett';
2
+
3
+ export type ShoppingItemsSuggested = Event<
4
+ 'ShoppingItemsSuggested',
5
+ {
6
+ sessionId: string;
7
+ suggestedItems: Array<{ productId: string; name: string; quantity: number; reason: string }>;
8
+ }
9
+ >;
@@ -0,0 +1,28 @@
1
+ import type { State } from './state';
2
+ import type { ShoppingItemsSuggested } from './events';
3
+
4
+ /**
5
+ * ## IMPLEMENTATION INSTRUCTIONS ##
6
+ *
7
+ * This function defines how the domain state evolves in response to events.
8
+ *
9
+ * Guidelines:
10
+ * - Apply only the **minimal** necessary changes for future decisions in `decide.ts`.
11
+ * - Ignore any event fields not required for decision-making logic.
12
+ * - If the event doesn’t change decision-relevant state, return the existing `state`.
13
+ * - Prefer immutability: always return a **new state object**.
14
+ * - Avoid spreading all of `event.data` unless all fields are relevant.
15
+ */
16
+
17
+ export const evolve = (state: State, event: ShoppingItemsSuggested): State => {
18
+ switch (event.type) {
19
+ case 'ShoppingItemsSuggested': {
20
+ // TODO: Update state based on ShoppingItemsSuggested
21
+ return {
22
+ ...state,
23
+ };
24
+ }
25
+ default:
26
+ return state;
27
+ }
28
+ };
@@ -0,0 +1,49 @@
1
+ import '@auto-engineer/product-catalog-integration';
2
+
3
+ import { AI } from '@auto-engineer/ai-integration';
4
+
5
+ import { Products } from '@auto-engineer/product-catalog-integration';
6
+
7
+ import { CommandHandler, type EventStore, type MessageHandlerResult } from '@event-driven-io/emmett';
8
+ import { evolve } from './evolve';
9
+ import { initialState } from './state';
10
+ import { decide } from './decide';
11
+ import type { SuggestShoppingItems } from './commands';
12
+
13
+ /**
14
+ * ## IMPLEMENTATION INSTRUCTIONS ##
15
+ * add the following to the DoChat: schemaName: Products, systemPrompt: use the PRODUCT_CATALOGUE_PRODUCTS MCP tool to get product data
16
+ */
17
+
18
+ const handler = CommandHandler({
19
+ evolve,
20
+ initialState,
21
+ });
22
+
23
+ export const handle = async (eventStore: EventStore, command: SuggestShoppingItems): Promise<MessageHandlerResult> => {
24
+ const streamId = `shopping-session-${command.data.sessionId}`;
25
+
26
+ try {
27
+ // TODO: Map fields from the incoming command to this integration input.
28
+ // - Use relevant fields from `command.data` to populate the required inputs below.
29
+ // - Some fields may require transformation or enrichment.
30
+ // - If additional context is needed, construct it here.
31
+ // const products: Products | undefined = await AI.Commands?.DoChat<Products>({
32
+ // type: 'DoChat',
33
+ // data: {
34
+ //
35
+ // },
36
+ // });
37
+
38
+ await handler(eventStore, streamId, (state) =>
39
+ // TODO: add products as a parameter to decide once implemented above
40
+ decide(command, state /* products */),
41
+ );
42
+ return; // success (returns void)
43
+ } catch (error: any) {
44
+ return {
45
+ type: 'SKIP',
46
+ reason: `Command failed: ${error?.message ?? 'Unknown'}`,
47
+ };
48
+ }
49
+ };
@@ -0,0 +1,25 @@
1
+ import { Mutation, Resolver, Arg, Ctx, Field, InputType } from 'type-graphql';
2
+ import { type GraphQLContext, sendCommand, MutationResponse } from '../../../shared';
3
+
4
+ @InputType()
5
+ export class SuggestShoppingItemsInput {
6
+ @Field(() => String)
7
+ sessionId!: string;
8
+ @Field(() => String)
9
+ prompt!: string;
10
+ }
11
+
12
+ @Resolver()
13
+ export class SuggestShoppingItemsResolver {
14
+ @Mutation(() => MutationResponse)
15
+ async suggestShoppingItems(
16
+ @Arg('input', () => SuggestShoppingItemsInput) input: SuggestShoppingItemsInput,
17
+ @Ctx() ctx: GraphQLContext,
18
+ ): Promise<MutationResponse> {
19
+ return await sendCommand(ctx.messageBus, {
20
+ type: 'SuggestShoppingItems',
21
+ kind: 'Command',
22
+ data: { ...input },
23
+ });
24
+ }
25
+ }
@@ -0,0 +1,7 @@
1
+ import type { CommandProcessor, EventStore } from '@event-driven-io/emmett';
2
+ import { handle } from './handle';
3
+ import type { SuggestShoppingItems } from './commands';
4
+
5
+ export function register(messageBus: CommandProcessor, eventStore: EventStore) {
6
+ messageBus.handle((command: SuggestShoppingItems) => handle(eventStore, command), 'SuggestShoppingItems');
7
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ## IMPLEMENTATION INSTRUCTIONS ##
3
+ *
4
+ * Define the shape of the domain state for the current slice below. This state is used by `decide.ts`
5
+ * to determine whether a command is valid.
6
+ *
7
+ * The state is evolved over time by applying domain events (in `evolve.ts`).
8
+ * Each event updates the state incrementally based on business rules.
9
+ *
10
+ * Guidelines:
11
+ * - Include only fields that are **read** during command validation.
12
+ * - Use discriminated unions (e.g., `status: 'Pending' | 'Done'`) to model state transitions.
13
+ * - Prefer primitive types: `string`, `boolean`, `number`.
14
+ * - Use objects or maps only when structure is essential for decision logic.
15
+ *
16
+ * Do NOT include:
17
+ * - Redundant data already emitted in events unless required to enforce business rules.
18
+ * - Fields used only for projections, UI, or query purposes.
19
+ *
20
+ * ### Example (for a Task domain):
21
+ *
22
+ * ```ts
23
+ * export type PendingTask = {
24
+ * status: 'Pending';
25
+ * };
26
+ *
27
+ * export type InProgressTask = {
28
+ * status: 'InProgress';
29
+ * startedAt: string;
30
+ * };
31
+ *
32
+ * export type CompletedTask = {
33
+ * status: 'Completed';
34
+ * completedAt: string;
35
+ * };
36
+ *
37
+ * export type State = PendingTask | InProgressTask | CompletedTask;
38
+ * ```
39
+ */
40
+
41
+ // TODO: Replace with a discriminated union of domain states for the current slice
42
+ export type State = {};
43
+
44
+ // TODO: Replace the Return with the initial domain state of the current slice
45
+ export const initialState = (): State => {
46
+ return {};
47
+ };
@@ -0,0 +1,94 @@
1
+ import { describe, it, beforeEach, expect } from 'vitest';
2
+ import { InMemoryProjectionSpec } from '@event-driven-io/emmett';
3
+ import { projection } from './projection';
4
+ import type { ShoppingItemsSuggested } from '../selects-items-relevant-to-the-shopping-criteria-/events';
5
+ import { SuggestedItems } from './state';
6
+
7
+ type ProjectionEvent = ShoppingItemsSuggested;
8
+
9
+ describe('SuggestedItemsProjection Projection', () => {
10
+ let given: InMemoryProjectionSpec<ProjectionEvent>;
11
+
12
+ beforeEach(() => {
13
+ given = InMemoryProjectionSpec.for({ projection });
14
+ });
15
+
16
+ it('creates or updates SuggestedItems document - case 1', () =>
17
+ given([
18
+ {
19
+ type: 'ShoppingItemsSuggested',
20
+ data: {
21
+ sessionId: 'session-abc',
22
+ suggestedItems: [
23
+ {
24
+ productId: 'prod-soccer-ball',
25
+ name: 'Super Soccer Ball',
26
+ quantity: 1,
27
+ reason: 'Perfect for your daughter who loves soccer',
28
+ },
29
+ {
30
+ productId: 'prod-craft-kit',
31
+ name: 'Deluxe Craft Kit',
32
+ quantity: 1,
33
+ reason: 'Great for creative activities and crafts',
34
+ },
35
+ {
36
+ productId: 'prod-laptop-bag',
37
+ name: 'Tech Laptop Backpack',
38
+ quantity: 1,
39
+ reason: "Essential for your son's school computer needs",
40
+ },
41
+ {
42
+ productId: 'prod-mtg-starter',
43
+ name: 'Magic the Gathering Starter Set',
44
+ quantity: 1,
45
+ reason: 'Ideal starter set for Magic the Gathering enthusiasts',
46
+ },
47
+ ],
48
+ },
49
+ metadata: {
50
+ streamName: 'ignored-stream',
51
+ streamPosition: 1n,
52
+ globalPosition: 1n,
53
+ },
54
+ },
55
+ ])
56
+ .when([])
57
+ .then(async (state) => {
58
+ const document = await state.database
59
+ .collection<SuggestedItems>('SuggestedItemsProjection')
60
+ .findOne((doc) => doc.sessionId === 'session-abc');
61
+
62
+ const expected: SuggestedItems = {
63
+ sessionId: 'session-abc',
64
+ items: [
65
+ {
66
+ productId: 'prod-soccer-ball',
67
+ name: 'Super Soccer Ball',
68
+ quantity: 1,
69
+ reason: 'Perfect for your daughter who loves soccer',
70
+ },
71
+ {
72
+ productId: 'prod-craft-kit',
73
+ name: 'Deluxe Craft Kit',
74
+ quantity: 1,
75
+ reason: 'Great for creative activities and crafts',
76
+ },
77
+ {
78
+ productId: 'prod-laptop-bag',
79
+ name: 'Tech Laptop Backpack',
80
+ quantity: 1,
81
+ reason: "Essential for your son's school computer needs",
82
+ },
83
+ {
84
+ productId: 'prod-mtg-starter',
85
+ name: 'Magic the Gathering Starter Set',
86
+ quantity: 1,
87
+ reason: 'Ideal starter set for Magic the Gathering enthusiasts',
88
+ },
89
+ ],
90
+ };
91
+
92
+ expect(document).toMatchObject(expected);
93
+ }));
94
+ });
@@ -0,0 +1,37 @@
1
+ import {
2
+ inMemorySingleStreamProjection,
3
+ type ReadEvent,
4
+ type InMemoryReadEventMetadata,
5
+ } from '@event-driven-io/emmett';
6
+ import type { SuggestedItems } from './state';
7
+ import type { ShoppingItemsSuggested } from '../selects-items-relevant-to-the-shopping-criteria-/events';
8
+
9
+ type AllEvents = ShoppingItemsSuggested;
10
+
11
+ export const projection = inMemorySingleStreamProjection<SuggestedItems, AllEvents>({
12
+ collectionName: 'SuggestedItemsProjection',
13
+ canHandle: ['ShoppingItemsSuggested'],
14
+ getDocumentId: (event) => event.data.sessionId,
15
+ evolve: (
16
+ document: SuggestedItems | null,
17
+ event: ReadEvent<AllEvents, InMemoryReadEventMetadata>,
18
+ ): SuggestedItems | null => {
19
+ switch (event.type) {
20
+ case 'ShoppingItemsSuggested': {
21
+ /**
22
+ * ## IMPLEMENTATION INSTRUCTIONS ##
23
+ * This event adds or updates the document.
24
+ * Implement the correct fields as needed for your read model.
25
+ */
26
+ return {
27
+ sessionId: /* TODO: map from event.data */ '',
28
+ items: /* TODO: map from event.data */ [],
29
+ };
30
+ }
31
+ default:
32
+ return document;
33
+ }
34
+ },
35
+ });
36
+
37
+ export default projection;