@mantajs/core 0.1.6 → 0.2.0-beta.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 (564) hide show
  1. package/dist/adapters/auth-mock.d.ts +44 -0
  2. package/dist/adapters/auth-mock.d.ts.map +1 -0
  3. package/dist/adapters/auth-mock.js +160 -0
  4. package/dist/adapters/auth-mock.js.map +1 -0
  5. package/dist/adapters/cache-memory.d.ts +11 -0
  6. package/dist/adapters/cache-memory.d.ts.map +1 -0
  7. package/dist/adapters/cache-memory.js +32 -0
  8. package/dist/adapters/cache-memory.js.map +1 -0
  9. package/dist/adapters/database-memory.d.ts +24 -0
  10. package/dist/adapters/database-memory.d.ts.map +1 -0
  11. package/dist/adapters/database-memory.js +141 -0
  12. package/dist/adapters/database-memory.js.map +1 -0
  13. package/dist/adapters/eventbus-memory.d.ts +37 -0
  14. package/dist/adapters/eventbus-memory.d.ts.map +1 -0
  15. package/dist/adapters/eventbus-memory.js +166 -0
  16. package/dist/adapters/eventbus-memory.js.map +1 -0
  17. package/dist/adapters/file-memory.d.ts +24 -0
  18. package/dist/adapters/file-memory.d.ts.map +1 -0
  19. package/dist/adapters/file-memory.js +77 -0
  20. package/dist/adapters/file-memory.js.map +1 -0
  21. package/dist/adapters/http-memory.d.ts +23 -0
  22. package/dist/adapters/http-memory.d.ts.map +1 -0
  23. package/dist/adapters/http-memory.js +149 -0
  24. package/dist/adapters/http-memory.js.map +1 -0
  25. package/dist/adapters/index.d.ts +14 -0
  26. package/dist/adapters/index.d.ts.map +1 -0
  27. package/dist/adapters/index.js +15 -0
  28. package/dist/adapters/index.js.map +1 -0
  29. package/dist/adapters/job-scheduler-memory.d.ts +20 -0
  30. package/dist/adapters/job-scheduler-memory.d.ts.map +1 -0
  31. package/dist/adapters/job-scheduler-memory.js +103 -0
  32. package/dist/adapters/job-scheduler-memory.js.map +1 -0
  33. package/dist/adapters/locking-memory.d.ts +20 -0
  34. package/dist/adapters/locking-memory.d.ts.map +1 -0
  35. package/dist/adapters/locking-memory.js +85 -0
  36. package/dist/adapters/locking-memory.js.map +1 -0
  37. package/dist/adapters/logger-test.d.ts +30 -0
  38. package/dist/adapters/logger-test.d.ts.map +1 -0
  39. package/dist/adapters/logger-test.js +77 -0
  40. package/dist/adapters/logger-test.js.map +1 -0
  41. package/dist/adapters/notification-memory.d.ts +27 -0
  42. package/dist/adapters/notification-memory.d.ts.map +1 -0
  43. package/dist/adapters/notification-memory.js +69 -0
  44. package/dist/adapters/notification-memory.js.map +1 -0
  45. package/dist/adapters/relational-query-memory.d.ts +47 -0
  46. package/dist/adapters/relational-query-memory.d.ts.map +1 -0
  47. package/dist/adapters/relational-query-memory.js +263 -0
  48. package/dist/adapters/relational-query-memory.js.map +1 -0
  49. package/dist/adapters/repository-factory-memory.d.ts +17 -0
  50. package/dist/adapters/repository-factory-memory.d.ts.map +1 -0
  51. package/dist/adapters/repository-factory-memory.js +32 -0
  52. package/dist/adapters/repository-factory-memory.js.map +1 -0
  53. package/dist/adapters/repository-memory.d.ts +30 -0
  54. package/dist/adapters/repository-memory.d.ts.map +1 -0
  55. package/dist/adapters/repository-memory.js +183 -0
  56. package/dist/adapters/repository-memory.js.map +1 -0
  57. package/dist/ai/index.d.ts +53 -0
  58. package/dist/ai/index.d.ts.map +1 -0
  59. package/dist/ai/index.js +48 -0
  60. package/dist/ai/index.js.map +1 -0
  61. package/dist/app/index.d.ts +97 -0
  62. package/dist/app/index.d.ts.map +1 -0
  63. package/dist/app/index.js +217 -0
  64. package/dist/app/index.js.map +1 -0
  65. package/dist/app/request-context.d.ts +35 -0
  66. package/dist/app/request-context.d.ts.map +1 -0
  67. package/dist/app/request-context.js +32 -0
  68. package/dist/app/request-context.js.map +1 -0
  69. package/dist/auth/auth-module-service.d.ts +62 -0
  70. package/dist/auth/auth-module-service.d.ts.map +1 -0
  71. package/dist/auth/auth-module-service.js +210 -0
  72. package/dist/auth/auth-module-service.js.map +1 -0
  73. package/dist/auth/index.d.ts +7 -0
  74. package/dist/auth/index.d.ts.map +1 -0
  75. package/dist/auth/index.js +5 -0
  76. package/dist/auth/index.js.map +1 -0
  77. package/dist/auth/middleware.d.ts +19 -0
  78. package/dist/auth/middleware.d.ts.map +1 -0
  79. package/dist/auth/middleware.js +61 -0
  80. package/dist/auth/middleware.js.map +1 -0
  81. package/dist/auth/models/auth-identity.d.ts +11 -0
  82. package/dist/auth/models/auth-identity.d.ts.map +1 -0
  83. package/dist/auth/models/auth-identity.js +12 -0
  84. package/dist/auth/models/auth-identity.js.map +1 -0
  85. package/dist/auth/providers/emailpass.d.ts +7 -0
  86. package/dist/auth/providers/emailpass.d.ts.map +1 -0
  87. package/dist/auth/providers/emailpass.js +94 -0
  88. package/dist/auth/providers/emailpass.js.map +1 -0
  89. package/dist/auth/providers/types.d.ts +66 -0
  90. package/dist/auth/providers/types.d.ts.map +1 -0
  91. package/dist/auth/providers/types.js +3 -0
  92. package/dist/auth/providers/types.js.map +1 -0
  93. package/dist/auth/types.d.ts +36 -0
  94. package/dist/auth/types.d.ts.map +1 -0
  95. package/dist/auth/types.js +3 -0
  96. package/dist/auth/types.js.map +1 -0
  97. package/dist/command/define-command-graph.d.ts +63 -0
  98. package/dist/command/define-command-graph.d.ts.map +1 -0
  99. package/dist/command/define-command-graph.js +80 -0
  100. package/dist/command/define-command-graph.js.map +1 -0
  101. package/dist/command/dml-to-zod.d.ts +34 -0
  102. package/dist/command/dml-to-zod.d.ts.map +1 -0
  103. package/dist/command/dml-to-zod.js +140 -0
  104. package/dist/command/dml-to-zod.js.map +1 -0
  105. package/dist/command/generate-entity-commands.d.ts +68 -0
  106. package/dist/command/generate-entity-commands.d.ts.map +1 -0
  107. package/dist/command/generate-entity-commands.js +350 -0
  108. package/dist/command/generate-entity-commands.js.map +1 -0
  109. package/dist/command/index.d.ts +54 -0
  110. package/dist/command/index.d.ts.map +1 -0
  111. package/dist/command/index.js +338 -0
  112. package/dist/command/index.js.map +1 -0
  113. package/dist/command/types.d.ts +131 -0
  114. package/dist/command/types.d.ts.map +1 -0
  115. package/dist/command/types.js +2 -0
  116. package/dist/command/types.js.map +1 -0
  117. package/dist/config/built-in-presets.d.ts +20 -0
  118. package/dist/config/built-in-presets.d.ts.map +1 -0
  119. package/dist/config/built-in-presets.js +70 -0
  120. package/dist/config/built-in-presets.js.map +1 -0
  121. package/dist/config/config-manager.d.ts +117 -0
  122. package/dist/config/config-manager.d.ts.map +1 -0
  123. package/dist/config/config-manager.js +245 -0
  124. package/dist/config/config-manager.js.map +1 -0
  125. package/dist/config/define-config.d.ts +20 -0
  126. package/dist/config/define-config.d.ts.map +1 -0
  127. package/dist/config/define-config.js +64 -0
  128. package/dist/config/define-config.js.map +1 -0
  129. package/dist/config/feature-flags.d.ts +48 -0
  130. package/dist/config/feature-flags.d.ts.map +1 -0
  131. package/dist/config/feature-flags.js +97 -0
  132. package/dist/config/feature-flags.js.map +1 -0
  133. package/dist/config/index.d.ts +9 -0
  134. package/dist/config/index.d.ts.map +1 -0
  135. package/dist/config/index.js +8 -0
  136. package/dist/config/index.js.map +1 -0
  137. package/dist/config/presets.d.ts +38 -0
  138. package/dist/config/presets.d.ts.map +1 -0
  139. package/dist/config/presets.js +29 -0
  140. package/dist/config/presets.js.map +1 -0
  141. package/dist/config/types.d.ts +707 -0
  142. package/dist/config/types.d.ts.map +1 -0
  143. package/dist/config/types.js +112 -0
  144. package/dist/config/types.js.map +1 -0
  145. package/dist/context/index.d.ts +95 -0
  146. package/dist/context/index.d.ts.map +1 -0
  147. package/dist/context/index.js +26 -0
  148. package/dist/context/index.js.map +1 -0
  149. package/dist/context/registry.d.ts +32 -0
  150. package/dist/context/registry.d.ts.map +1 -0
  151. package/dist/context/registry.js +142 -0
  152. package/dist/context/registry.js.map +1 -0
  153. package/dist/db/index.d.ts +2 -0
  154. package/dist/db/index.d.ts.map +1 -0
  155. package/dist/db/index.js +4 -0
  156. package/dist/db/index.js.map +1 -0
  157. package/dist/db/schema.d.ts +839 -0
  158. package/dist/db/schema.d.ts.map +1 -0
  159. package/dist/db/schema.js +106 -0
  160. package/dist/db/schema.js.map +1 -0
  161. package/dist/dml/entity.d.ts +132 -0
  162. package/dist/dml/entity.d.ts.map +1 -0
  163. package/dist/dml/entity.js +110 -0
  164. package/dist/dml/entity.js.map +1 -0
  165. package/dist/dml/from-zod.d.ts +13 -0
  166. package/dist/dml/from-zod.d.ts.map +1 -0
  167. package/dist/dml/from-zod.js +81 -0
  168. package/dist/dml/from-zod.js.map +1 -0
  169. package/dist/dml/generator/index.d.ts +62 -0
  170. package/dist/dml/generator/index.d.ts.map +1 -0
  171. package/dist/dml/generator/index.js +208 -0
  172. package/dist/dml/generator/index.js.map +1 -0
  173. package/dist/dml/index.d.ts +11 -0
  174. package/dist/dml/index.d.ts.map +1 -0
  175. package/dist/dml/index.js +13 -0
  176. package/dist/dml/index.js.map +1 -0
  177. package/dist/dml/infer.d.ts +36 -0
  178. package/dist/dml/infer.d.ts.map +1 -0
  179. package/dist/dml/infer.js +5 -0
  180. package/dist/dml/infer.js.map +1 -0
  181. package/dist/dml/model.d.ts +58 -0
  182. package/dist/dml/model.d.ts.map +1 -0
  183. package/dist/dml/model.js +95 -0
  184. package/dist/dml/model.js.map +1 -0
  185. package/dist/dml/modifiers.d.ts +9 -0
  186. package/dist/dml/modifiers.d.ts.map +1 -0
  187. package/dist/dml/modifiers.js +25 -0
  188. package/dist/dml/modifiers.js.map +1 -0
  189. package/dist/dml/properties/array.d.ts +7 -0
  190. package/dist/dml/properties/array.d.ts.map +1 -0
  191. package/dist/dml/properties/array.js +5 -0
  192. package/dist/dml/properties/array.js.map +1 -0
  193. package/dist/dml/properties/autoincrement.d.ts +7 -0
  194. package/dist/dml/properties/autoincrement.d.ts.map +1 -0
  195. package/dist/dml/properties/autoincrement.js +5 -0
  196. package/dist/dml/properties/autoincrement.js.map +1 -0
  197. package/dist/dml/properties/base.d.ts +124 -0
  198. package/dist/dml/properties/base.d.ts.map +1 -0
  199. package/dist/dml/properties/base.js +76 -0
  200. package/dist/dml/properties/base.js.map +1 -0
  201. package/dist/dml/properties/big-number.d.ts +7 -0
  202. package/dist/dml/properties/big-number.d.ts.map +1 -0
  203. package/dist/dml/properties/big-number.js +5 -0
  204. package/dist/dml/properties/big-number.js.map +1 -0
  205. package/dist/dml/properties/boolean.d.ts +7 -0
  206. package/dist/dml/properties/boolean.d.ts.map +1 -0
  207. package/dist/dml/properties/boolean.js +5 -0
  208. package/dist/dml/properties/boolean.js.map +1 -0
  209. package/dist/dml/properties/computed.d.ts +9 -0
  210. package/dist/dml/properties/computed.d.ts.map +1 -0
  211. package/dist/dml/properties/computed.js +22 -0
  212. package/dist/dml/properties/computed.js.map +1 -0
  213. package/dist/dml/properties/date-time.d.ts +7 -0
  214. package/dist/dml/properties/date-time.d.ts.map +1 -0
  215. package/dist/dml/properties/date-time.js +5 -0
  216. package/dist/dml/properties/date-time.js.map +1 -0
  217. package/dist/dml/properties/enum.d.ts +12 -0
  218. package/dist/dml/properties/enum.d.ts.map +1 -0
  219. package/dist/dml/properties/enum.js +14 -0
  220. package/dist/dml/properties/enum.js.map +1 -0
  221. package/dist/dml/properties/float.d.ts +7 -0
  222. package/dist/dml/properties/float.d.ts.map +1 -0
  223. package/dist/dml/properties/float.js +5 -0
  224. package/dist/dml/properties/float.js.map +1 -0
  225. package/dist/dml/properties/index.d.ts +15 -0
  226. package/dist/dml/properties/index.d.ts.map +1 -0
  227. package/dist/dml/properties/index.js +15 -0
  228. package/dist/dml/properties/index.js.map +1 -0
  229. package/dist/dml/properties/json.d.ts +7 -0
  230. package/dist/dml/properties/json.d.ts.map +1 -0
  231. package/dist/dml/properties/json.js +6 -0
  232. package/dist/dml/properties/json.js.map +1 -0
  233. package/dist/dml/properties/nullable.d.ts +23 -0
  234. package/dist/dml/properties/nullable.d.ts.map +1 -0
  235. package/dist/dml/properties/nullable.js +46 -0
  236. package/dist/dml/properties/nullable.js.map +1 -0
  237. package/dist/dml/properties/number.d.ts +10 -0
  238. package/dist/dml/properties/number.d.ts.map +1 -0
  239. package/dist/dml/properties/number.js +13 -0
  240. package/dist/dml/properties/number.js.map +1 -0
  241. package/dist/dml/properties/primary-key.d.ts +14 -0
  242. package/dist/dml/properties/primary-key.d.ts.map +1 -0
  243. package/dist/dml/properties/primary-key.js +23 -0
  244. package/dist/dml/properties/primary-key.js.map +1 -0
  245. package/dist/dml/properties/text.d.ts +15 -0
  246. package/dist/dml/properties/text.d.ts.map +1 -0
  247. package/dist/dml/properties/text.js +19 -0
  248. package/dist/dml/properties/text.js.map +1 -0
  249. package/dist/dml/relations/belongs-to.d.ts +20 -0
  250. package/dist/dml/relations/belongs-to.d.ts.map +1 -0
  251. package/dist/dml/relations/belongs-to.js +29 -0
  252. package/dist/dml/relations/belongs-to.js.map +1 -0
  253. package/dist/dml/relations/has-many.d.ts +16 -0
  254. package/dist/dml/relations/has-many.d.ts.map +1 -0
  255. package/dist/dml/relations/has-many.js +25 -0
  256. package/dist/dml/relations/has-many.js.map +1 -0
  257. package/dist/dml/relations/has-one.d.ts +26 -0
  258. package/dist/dml/relations/has-one.d.ts.map +1 -0
  259. package/dist/dml/relations/has-one.js +46 -0
  260. package/dist/dml/relations/has-one.js.map +1 -0
  261. package/dist/dml/relations/many-to-many.d.ts +9 -0
  262. package/dist/dml/relations/many-to-many.d.ts.map +1 -0
  263. package/dist/dml/relations/many-to-many.js +11 -0
  264. package/dist/dml/relations/many-to-many.js.map +1 -0
  265. package/dist/errors/manta-error.d.ts +68 -0
  266. package/dist/errors/manta-error.d.ts.map +1 -0
  267. package/dist/errors/manta-error.js +80 -0
  268. package/dist/errors/manta-error.js.map +1 -0
  269. package/dist/events/index.d.ts +3 -0
  270. package/dist/events/index.d.ts.map +1 -0
  271. package/dist/events/index.js +3 -0
  272. package/dist/events/index.js.map +1 -0
  273. package/dist/events/message-aggregator.d.ts +25 -0
  274. package/dist/events/message-aggregator.d.ts.map +1 -0
  275. package/dist/events/message-aggregator.js +35 -0
  276. package/dist/events/message-aggregator.js.map +1 -0
  277. package/dist/events/types.d.ts +42 -0
  278. package/dist/events/types.d.ts.map +1 -0
  279. package/dist/events/types.js +3 -0
  280. package/dist/events/types.js.map +1 -0
  281. package/dist/index.d.ts +55 -0
  282. package/dist/index.d.ts.map +1 -0
  283. package/dist/index.js +53 -0
  284. package/dist/index.js.map +1 -0
  285. package/dist/job/index.d.ts +52 -0
  286. package/dist/job/index.d.ts.map +1 -0
  287. package/dist/job/index.js +31 -0
  288. package/dist/job/index.js.map +1 -0
  289. package/dist/link/index.d.ts +97 -0
  290. package/dist/link/index.d.ts.map +1 -0
  291. package/dist/link/index.js +185 -0
  292. package/dist/link/index.js.map +1 -0
  293. package/dist/middleware/define-middleware.d.ts +54 -0
  294. package/dist/middleware/define-middleware.d.ts.map +1 -0
  295. package/dist/middleware/define-middleware.js +40 -0
  296. package/dist/middleware/define-middleware.js.map +1 -0
  297. package/dist/middleware/index.d.ts +56 -0
  298. package/dist/middleware/index.d.ts.map +1 -0
  299. package/dist/middleware/index.js +50 -0
  300. package/dist/middleware/index.js.map +1 -0
  301. package/dist/module/index.d.ts +56 -0
  302. package/dist/module/index.d.ts.map +1 -0
  303. package/dist/module/index.js +52 -0
  304. package/dist/module/index.js.map +1 -0
  305. package/dist/module/versioning.d.ts +27 -0
  306. package/dist/module/versioning.d.ts.map +1 -0
  307. package/dist/module/versioning.js +64 -0
  308. package/dist/module/versioning.js.map +1 -0
  309. package/dist/naming.d.ts +39 -0
  310. package/dist/naming.d.ts.map +1 -0
  311. package/dist/naming.js +95 -0
  312. package/dist/naming.js.map +1 -0
  313. package/dist/ports/analytics.d.ts +7 -0
  314. package/dist/ports/analytics.d.ts.map +1 -0
  315. package/dist/ports/analytics.js +3 -0
  316. package/dist/ports/analytics.js.map +1 -0
  317. package/dist/ports/auth.d.ts +27 -0
  318. package/dist/ports/auth.d.ts.map +1 -0
  319. package/dist/ports/auth.js +3 -0
  320. package/dist/ports/auth.js.map +1 -0
  321. package/dist/ports/cache.d.ts +35 -0
  322. package/dist/ports/cache.d.ts.map +1 -0
  323. package/dist/ports/cache.js +3 -0
  324. package/dist/ports/cache.js.map +1 -0
  325. package/dist/ports/database.d.ts +40 -0
  326. package/dist/ports/database.d.ts.map +1 -0
  327. package/dist/ports/database.js +3 -0
  328. package/dist/ports/database.js.map +1 -0
  329. package/dist/ports/event-bus.d.ts +85 -0
  330. package/dist/ports/event-bus.d.ts.map +1 -0
  331. package/dist/ports/event-bus.js +3 -0
  332. package/dist/ports/event-bus.js.map +1 -0
  333. package/dist/ports/file.d.ts +62 -0
  334. package/dist/ports/file.d.ts.map +1 -0
  335. package/dist/ports/file.js +3 -0
  336. package/dist/ports/file.js.map +1 -0
  337. package/dist/ports/http.d.ts +20 -0
  338. package/dist/ports/http.d.ts.map +1 -0
  339. package/dist/ports/http.js +3 -0
  340. package/dist/ports/http.js.map +1 -0
  341. package/dist/ports/in-memory-progress-channel.d.ts +9 -0
  342. package/dist/ports/in-memory-progress-channel.d.ts.map +1 -0
  343. package/dist/ports/in-memory-progress-channel.js +19 -0
  344. package/dist/ports/in-memory-progress-channel.js.map +1 -0
  345. package/dist/ports/in-memory-queue.d.ts +24 -0
  346. package/dist/ports/in-memory-queue.d.ts.map +1 -0
  347. package/dist/ports/in-memory-queue.js +63 -0
  348. package/dist/ports/in-memory-queue.js.map +1 -0
  349. package/dist/ports/index.d.ts +27 -0
  350. package/dist/ports/index.d.ts.map +1 -0
  351. package/dist/ports/index.js +6 -0
  352. package/dist/ports/index.js.map +1 -0
  353. package/dist/ports/job-scheduler.d.ts +42 -0
  354. package/dist/ports/job-scheduler.d.ts.map +1 -0
  355. package/dist/ports/job-scheduler.js +3 -0
  356. package/dist/ports/job-scheduler.js.map +1 -0
  357. package/dist/ports/locking.d.ts +43 -0
  358. package/dist/ports/locking.d.ts.map +1 -0
  359. package/dist/ports/locking.js +3 -0
  360. package/dist/ports/locking.js.map +1 -0
  361. package/dist/ports/logger.d.ts +65 -0
  362. package/dist/ports/logger.d.ts.map +1 -0
  363. package/dist/ports/logger.js +3 -0
  364. package/dist/ports/logger.js.map +1 -0
  365. package/dist/ports/notification.d.ts +71 -0
  366. package/dist/ports/notification.d.ts.map +1 -0
  367. package/dist/ports/notification.js +3 -0
  368. package/dist/ports/notification.js.map +1 -0
  369. package/dist/ports/progress-channel.d.ts +46 -0
  370. package/dist/ports/progress-channel.d.ts.map +1 -0
  371. package/dist/ports/progress-channel.js +6 -0
  372. package/dist/ports/progress-channel.js.map +1 -0
  373. package/dist/ports/queue.d.ts +21 -0
  374. package/dist/ports/queue.d.ts.map +1 -0
  375. package/dist/ports/queue.js +15 -0
  376. package/dist/ports/queue.js.map +1 -0
  377. package/dist/ports/relational-query.d.ts +37 -0
  378. package/dist/ports/relational-query.d.ts.map +1 -0
  379. package/dist/ports/relational-query.js +3 -0
  380. package/dist/ports/relational-query.js.map +1 -0
  381. package/dist/ports/repository-factory.d.ts +21 -0
  382. package/dist/ports/repository-factory.d.ts.map +1 -0
  383. package/dist/ports/repository-factory.js +4 -0
  384. package/dist/ports/repository-factory.js.map +1 -0
  385. package/dist/ports/repository.d.ts +73 -0
  386. package/dist/ports/repository.d.ts.map +1 -0
  387. package/dist/ports/repository.js +3 -0
  388. package/dist/ports/repository.js.map +1 -0
  389. package/dist/ports/schema-generator.d.ts +15 -0
  390. package/dist/ports/schema-generator.d.ts.map +1 -0
  391. package/dist/ports/schema-generator.js +4 -0
  392. package/dist/ports/schema-generator.js.map +1 -0
  393. package/dist/ports/search.d.ts +7 -0
  394. package/dist/ports/search.d.ts.map +1 -0
  395. package/dist/ports/search.js +3 -0
  396. package/dist/ports/search.js.map +1 -0
  397. package/dist/ports/types.d.ts +112 -0
  398. package/dist/ports/types.d.ts.map +1 -0
  399. package/dist/ports/types.js +26 -0
  400. package/dist/ports/types.js.map +1 -0
  401. package/dist/ports/workflow-store.d.ts +111 -0
  402. package/dist/ports/workflow-store.d.ts.map +1 -0
  403. package/dist/ports/workflow-store.js +5 -0
  404. package/dist/ports/workflow-store.js.map +1 -0
  405. package/dist/query/define-query-graph.d.ts +55 -0
  406. package/dist/query/define-query-graph.d.ts.map +1 -0
  407. package/dist/query/define-query-graph.js +59 -0
  408. package/dist/query/define-query-graph.js.map +1 -0
  409. package/dist/query/define-query.d.ts +79 -0
  410. package/dist/query/define-query.d.ts.map +1 -0
  411. package/dist/query/define-query.js +77 -0
  412. package/dist/query/define-query.js.map +1 -0
  413. package/dist/query/extend-query-graph.d.ts +36 -0
  414. package/dist/query/extend-query-graph.d.ts.map +1 -0
  415. package/dist/query/extend-query-graph.js +34 -0
  416. package/dist/query/extend-query-graph.js.map +1 -0
  417. package/dist/query/index.d.ts +181 -0
  418. package/dist/query/index.d.ts.map +1 -0
  419. package/dist/query/index.js +288 -0
  420. package/dist/query/index.js.map +1 -0
  421. package/dist/service/define.d.ts +97 -0
  422. package/dist/service/define.d.ts.map +1 -0
  423. package/dist/service/define.js +45 -0
  424. package/dist/service/define.js.map +1 -0
  425. package/dist/service/index.d.ts +52 -0
  426. package/dist/service/index.d.ts.map +1 -0
  427. package/dist/service/index.js +281 -0
  428. package/dist/service/index.js.map +1 -0
  429. package/dist/service/instantiate.d.ts +15 -0
  430. package/dist/service/instantiate.d.ts.map +1 -0
  431. package/dist/service/instantiate.js +143 -0
  432. package/dist/service/instantiate.js.map +1 -0
  433. package/dist/service/snapshot-repository.d.ts +31 -0
  434. package/dist/service/snapshot-repository.d.ts.map +1 -0
  435. package/dist/service/snapshot-repository.js +114 -0
  436. package/dist/service/snapshot-repository.js.map +1 -0
  437. package/dist/service/types.d.ts +39 -0
  438. package/dist/service/types.d.ts.map +1 -0
  439. package/dist/service/types.js +3 -0
  440. package/dist/service/types.js.map +1 -0
  441. package/dist/strict-mode/index.d.ts +42 -0
  442. package/dist/strict-mode/index.d.ts.map +1 -0
  443. package/dist/strict-mode/index.js +84 -0
  444. package/dist/strict-mode/index.js.map +1 -0
  445. package/dist/subscriber/index.d.ts +117 -0
  446. package/dist/subscriber/index.d.ts.map +1 -0
  447. package/dist/subscriber/index.js +76 -0
  448. package/dist/subscriber/index.js.map +1 -0
  449. package/dist/testing/relational-query-suite.d.ts +22 -0
  450. package/dist/testing/relational-query-suite.d.ts.map +1 -0
  451. package/dist/testing/relational-query-suite.js +233 -0
  452. package/dist/testing/relational-query-suite.js.map +1 -0
  453. package/dist/user/auto-routes.d.ts +32 -0
  454. package/dist/user/auto-routes.d.ts.map +1 -0
  455. package/dist/user/auto-routes.js +424 -0
  456. package/dist/user/auto-routes.js.map +1 -0
  457. package/dist/user/define-user.d.ts +54 -0
  458. package/dist/user/define-user.d.ts.map +1 -0
  459. package/dist/user/define-user.js +103 -0
  460. package/dist/user/define-user.js.map +1 -0
  461. package/dist/user/index.d.ts +7 -0
  462. package/dist/user/index.d.ts.map +1 -0
  463. package/dist/user/index.js +5 -0
  464. package/dist/user/index.js.map +1 -0
  465. package/dist/user/models/user.d.ts +15 -0
  466. package/dist/user/models/user.d.ts.map +1 -0
  467. package/dist/user/models/user.js +16 -0
  468. package/dist/user/models/user.js.map +1 -0
  469. package/dist/user/user-module-service.d.ts +55 -0
  470. package/dist/user/user-module-service.d.ts.map +1 -0
  471. package/dist/user/user-module-service.js +100 -0
  472. package/dist/user/user-module-service.js.map +1 -0
  473. package/dist/workflows/ai-step.d.ts +2 -0
  474. package/dist/workflows/ai-step.d.ts.map +1 -0
  475. package/dist/workflows/ai-step.js +54 -0
  476. package/dist/workflows/ai-step.js.map +1 -0
  477. package/dist/workflows/create-step.d.ts +16 -0
  478. package/dist/workflows/create-step.d.ts.map +1 -0
  479. package/dist/workflows/create-step.js +194 -0
  480. package/dist/workflows/create-step.js.map +1 -0
  481. package/dist/workflows/create-workflow.d.ts +16 -0
  482. package/dist/workflows/create-workflow.d.ts.map +1 -0
  483. package/dist/workflows/create-workflow.js +21 -0
  484. package/dist/workflows/create-workflow.js.map +1 -0
  485. package/dist/workflows/define-workflow.d.ts +55 -0
  486. package/dist/workflows/define-workflow.d.ts.map +1 -0
  487. package/dist/workflows/define-workflow.js +72 -0
  488. package/dist/workflows/define-workflow.js.map +1 -0
  489. package/dist/workflows/emit-event-step.d.ts +17 -0
  490. package/dist/workflows/emit-event-step.d.ts.map +1 -0
  491. package/dist/workflows/emit-event-step.js +46 -0
  492. package/dist/workflows/emit-event-step.js.map +1 -0
  493. package/dist/workflows/for-each.d.ts +6 -0
  494. package/dist/workflows/for-each.d.ts.map +1 -0
  495. package/dist/workflows/for-each.js +79 -0
  496. package/dist/workflows/for-each.js.map +1 -0
  497. package/dist/workflows/index.d.ts +15 -0
  498. package/dist/workflows/index.d.ts.map +1 -0
  499. package/dist/workflows/index.js +12 -0
  500. package/dist/workflows/index.js.map +1 -0
  501. package/dist/workflows/manager.d.ts +99 -0
  502. package/dist/workflows/manager.d.ts.map +1 -0
  503. package/dist/workflows/manager.js +450 -0
  504. package/dist/workflows/manager.js.map +1 -0
  505. package/dist/workflows/orphan-reaper.d.ts +50 -0
  506. package/dist/workflows/orphan-reaper.d.ts.map +1 -0
  507. package/dist/workflows/orphan-reaper.js +69 -0
  508. package/dist/workflows/orphan-reaper.js.map +1 -0
  509. package/dist/workflows/progress-helper.d.ts +20 -0
  510. package/dist/workflows/progress-helper.d.ts.map +1 -0
  511. package/dist/workflows/progress-helper.js +48 -0
  512. package/dist/workflows/progress-helper.js.map +1 -0
  513. package/dist/workflows/step.d.ts +103 -0
  514. package/dist/workflows/step.d.ts.map +1 -0
  515. package/dist/workflows/step.js +949 -0
  516. package/dist/workflows/step.js.map +1 -0
  517. package/dist/workflows/types.d.ts +215 -0
  518. package/dist/workflows/types.d.ts.map +1 -0
  519. package/dist/workflows/types.js +9 -0
  520. package/dist/workflows/types.js.map +1 -0
  521. package/dist/workflows/yield.d.ts +12 -0
  522. package/dist/workflows/yield.d.ts.map +1 -0
  523. package/dist/workflows/yield.js +29 -0
  524. package/dist/workflows/yield.js.map +1 -0
  525. package/docs/00-overview.md +254 -0
  526. package/docs/01-getting-started.md +224 -0
  527. package/docs/02-models.md +163 -0
  528. package/docs/03-services.md +208 -0
  529. package/docs/04-users.md +165 -0
  530. package/docs/05-commands.md +501 -0
  531. package/docs/06-queries.md +342 -0
  532. package/docs/07-events.md +248 -0
  533. package/docs/08-links.md +182 -0
  534. package/docs/09-agents.md +142 -0
  535. package/docs/10-spa.md +327 -0
  536. package/docs/11-config.md +481 -0
  537. package/docs/12-constraints.md +183 -0
  538. package/docs/13-testing.md +345 -0
  539. package/docs/14-adapters.md +204 -0
  540. package/docs/15-hosts.md +163 -0
  541. package/docs/16-reference.md +274 -0
  542. package/docs/17-dashboard.md +619 -0
  543. package/docs/AGENT.md +501 -0
  544. package/package.json +49 -52
  545. package/.medusa/server/src/admin/index.js +0 -5358
  546. package/.medusa/server/src/admin/index.mjs +0 -5356
  547. package/.medusa/server/src/api/admin/companies/[id]/route.js +0 -39
  548. package/.medusa/server/src/api/admin/companies/middlewares.js +0 -41
  549. package/.medusa/server/src/api/admin/companies/route.js +0 -37
  550. package/.medusa/server/src/api/admin/companies/validators.js +0 -29
  551. package/.medusa/server/src/api/middlewares.js +0 -8
  552. package/.medusa/server/src/index.js +0 -5
  553. package/.medusa/server/src/modules/company/index.js +0 -13
  554. package/.medusa/server/src/modules/company/migrations/Migration20260126141741.js +0 -26
  555. package/.medusa/server/src/modules/company/models/company.js +0 -24
  556. package/.medusa/server/src/modules/company/models/employee.js +0 -15
  557. package/.medusa/server/src/modules/company/models/index.js +0 -11
  558. package/.medusa/server/src/modules/company/service.js +0 -11
  559. package/.medusa/server/src/workflows/create-company.js +0 -10
  560. package/.medusa/server/src/workflows/delete-company.js +0 -10
  561. package/.medusa/server/src/workflows/steps/create-company.js +0 -16
  562. package/.medusa/server/src/workflows/steps/delete-company.js +0 -30
  563. package/.medusa/server/src/workflows/steps/update-company.js +0 -30
  564. package/.medusa/server/src/workflows/update-company.js +0 -10
@@ -0,0 +1,481 @@
1
+ # Configuration — defineConfig() & CLI
2
+
3
+ ## Project setup
4
+
5
+ ### `manta init` — New standalone project
6
+
7
+ ```bash
8
+ manta init my-app
9
+ cd my-app
10
+ pnpm install
11
+ manta dev
12
+ ```
13
+
14
+ Creates a complete, functional Manta project. After `pnpm install`, the project is ready to run with admin dashboard, database, and all framework features.
15
+
16
+ **What `manta init` generates:**
17
+
18
+ ```
19
+ my-app/
20
+ ├── manta.config.ts # defineConfig() — database, http, admin: true
21
+ ├── package.json # @mantajs/core, @mantajs/cli, @mantajs/host-nitro, @mantajs/dashboard
22
+ ├── tsconfig.json # ES2022, ESNext, JSX support, strict
23
+ ├── .env / .env.example # DATABASE_URL, PORT, ANTHROPIC_API_KEY
24
+ ├── .gitignore # .manta/, .manta/types/, node_modules/, .env
25
+ ├── AGENT.md # AI instructions (copied from @mantajs/core/docs/)
26
+ └── src/
27
+ ├── modules/ # Your business modules (entities + services)
28
+ ├── commands/ # Application commands (cross-module workflows)
29
+ ├── subscribers/ # Event handlers
30
+ ├── jobs/ # Cron tasks
31
+ ├── links/ # Cross-module relations
32
+ ├── queries/ # CQRS read endpoints (defineQuery, defineQueryGraph)
33
+ ├── agents/ # AI steps
34
+ └── admin/ # Dashboard (index.html + main.tsx)
35
+ ├── index.html
36
+ └── main.tsx
37
+ ```
38
+
39
+ **What it does NOT generate:**
40
+ - No `nitro.config.ts` — the host adapter handles this internally
41
+ - No `drizzle.config.ts` — the CLI handles this internally
42
+ - No `src/api/` — routes are auto-generated from commands + queries
43
+
44
+ The only config file the developer maintains is `manta.config.ts`.
45
+
46
+ ### `manta setup` — Add Manta to existing project
47
+
48
+ ```bash
49
+ cd my-nextjs-app
50
+ npx manta setup
51
+ ```
52
+
53
+ Detects the existing framework and adapts:
54
+
55
+ | Detected | Context | What it generates |
56
+ |----------|---------|------------------|
57
+ | `next.config.*` | Next.js | `AGENT.md` with Next.js + Manta instructions, `src/manta/` subdirectory |
58
+ | `nuxt.config.*` | Nuxt | `AGENT.md` with Nuxt + Manta instructions, `server/manta/` subdirectory |
59
+ | `workspaces` in package.json | Monorepo | `AGENT.md` at root, `packages/backend/` with Manta structure |
60
+ | Nothing detected | Standalone | Full Manta project structure in current directory |
61
+
62
+ In all cases, `manta setup`:
63
+ 1. Creates `manta.config.ts`
64
+ 2. Creates module/command/subscriber directories
65
+ 3. Generates **`AGENT.md` at the project root** — the first file an AI reads
66
+ 4. The `AGENT.md` is context-aware (mentions the detected framework)
67
+ 5. `AGENT.md` is committed to git (not gitignored) — every clone has it
68
+
69
+ ### The AGENT.md
70
+
71
+ The `AGENT.md` lives at the root of every Manta project. It's the first file an AI reads.
72
+
73
+ **Canonical location:** `@mantajs/core/docs/AGENT.md` — alongside all other framework documentation. The CLI copies it to the project root during `manta init`.
74
+
75
+ For `manta setup` (existing projects), context-specific templates exist in the CLI:
76
+
77
+ ```
78
+ packages/cli/src/templates/agent/
79
+ ├── nextjs.md # Next.js + Manta
80
+ └── nuxt.md # Nuxt + Manta
81
+ ```
82
+
83
+ `manta init` copies the canonical AGENT.md from `@mantajs/core/docs/`. `manta setup` detects the context and uses the appropriate template. The developer can then edit it to add project-specific context (business domain, team conventions, etc.).
84
+
85
+ Each AGENT.md contains:
86
+ - Stack description (what framework + Manta)
87
+ - The primitives with file locations
88
+ - Project structure adapted to the context
89
+ - Critical rules
90
+ - Links to full documentation in `node_modules/@mantajs/core/docs/`
91
+
92
+ The templates are maintained by the framework team. They are rich, detailed documents — not auto-generated strings.
93
+
94
+ ## manta.config.ts
95
+
96
+ ```typescript
97
+ export default {
98
+ database: {
99
+ url: process.env.DATABASE_URL ?? 'postgresql://localhost:5432/my_app',
100
+ pool: { min: 2, max: 10 },
101
+ },
102
+ http: { port: 3000 },
103
+ admin: { enabled: true },
104
+ }
105
+ ```
106
+
107
+ Or with validation via `defineConfig()`:
108
+
109
+ ```typescript
110
+ export default defineConfig({
111
+ database: { url: process.env.DATABASE_URL },
112
+ http: { port: 3000 },
113
+ auth: {
114
+ jwtSecret: process.env.JWT_SECRET,
115
+ },
116
+ admin: { enabled: true },
117
+ strict: false,
118
+ })
119
+ ```
120
+
121
+ `defineConfig()` validates `http`, `auth`, and `query` sections immediately via Zod. Invalid values throw at definition time, not at boot.
122
+
123
+ ## Configuration sections
124
+
125
+ | Section | Key fields | Default |
126
+ |---------|-----------|---------|
127
+ | `database` | `url`, `pool.min`, `pool.max` | Required |
128
+ | `http` | `port` | `9000` |
129
+ | `auth` | `jwtSecret`, `session.enabled`, `session.cookieName` | Dev: auto-generated secret |
130
+ | `query` | `maxEntities`, `defaultLimit` | `10000`, `100` |
131
+ | `admin` | `enabled` | `false` |
132
+ | `preset` | `'dev'`, `'vercel'` | Auto-detected from `APP_ENV` |
133
+ | `strict` | `true`/`false` | `false` |
134
+ | `plugins` | Array of plugin configs | `[]` |
135
+
136
+ ## Presets (adapter bundles)
137
+
138
+ The framework auto-detects the environment and loads appropriate adapters:
139
+
140
+ | Adapter | Dev (in-memory) | Prod (Vercel) |
141
+ |---------|----------------|---------------|
142
+ | Database | PostgreSQL (local) | Neon (serverless) |
143
+ | Cache | In-memory | Upstash Redis |
144
+ | Events | In-memory | Upstash Queues |
145
+ | File | Local filesystem | Vercel Blob |
146
+ | Logger | Pino (pretty) | Pino (JSON) |
147
+ | Locking | In-memory | Neon advisory locks |
148
+ | Jobs | node-cron | Vercel Cron |
149
+
150
+ Detection: `APP_ENV` > `NODE_ENV` > default `'development'`.
151
+
152
+ ## Environment variables
153
+
154
+ | Variable | Required | Description |
155
+ |----------|----------|-------------|
156
+ | `DATABASE_URL` | Yes | PostgreSQL connection string |
157
+ | `JWT_SECRET` | Prod only | JWT signing secret (dev: auto-generated) |
158
+ | `APP_ENV` | No | Force environment (`development` or `production`) |
159
+ | `ANTHROPIC_API_KEY` | No | Enable AI chat in admin dashboard |
160
+
161
+ ## CLI commands
162
+
163
+ | Command | Description |
164
+ |---------|-------------|
165
+ | `manta init` | Scaffold new project |
166
+ | `manta dev` | Dev server with hot reload + auto-migration |
167
+ | `manta build` | Production build |
168
+ | `manta start` | Start production server |
169
+ | `manta db:create` | Create PostgreSQL database |
170
+ | `manta db:generate` | Generate SQL migrations from DML models |
171
+ | `manta db:migrate` | Apply pending migrations |
172
+ | `manta db:rollback` | Revert last migration(s) |
173
+ | `manta db:diff` | Compare schema vs database (diagnostic) |
174
+ | `manta exec <script>` | Run TypeScript script with app context |
175
+ | `manta user -e <email>` | Create admin user |
176
+
177
+ ### manta dev
178
+
179
+ Starts development server. Auto-performs:
180
+ 1. Load env + config
181
+ 2. Generate `.manta/types/` (TypeScript types for autocomplete)
182
+ 3. Start Nitro dev server with HMR
183
+ 4. On first request: connect DB, instantiate adapters, discover modules/commands/subscribers/jobs/links/queries
184
+ 5. Auto-create tables in dev mode (no manual migration needed)
185
+ 6. Wire all routes, subscribers, jobs
186
+
187
+ ### manta db:generate
188
+
189
+ Scans `src/modules/*/models/` and `src/links/` to generate SQL migrations:
190
+
191
+ ```bash
192
+ manta db:generate --name add-blog-post
193
+ # Creates: drizzle/migrations/20260323_add-blog-post.sql
194
+ ```
195
+
196
+ ### manta exec
197
+
198
+ Run scripts with full app context:
199
+
200
+ ```typescript
201
+ // scripts/seed.ts
202
+ export async function main(app) {
203
+ await app.modules.blog.createPosts([
204
+ { title: 'First Post', slug: 'first', content: '...', status: 'published' },
205
+ { title: 'Second Post', slug: 'second', content: '...', status: 'draft' },
206
+ ])
207
+ }
208
+ ```
209
+
210
+ ```bash
211
+ manta exec scripts/seed.ts
212
+ manta exec scripts/seed.ts --dry-run # Rollback after execution (test mode)
213
+ ```
214
+
215
+ ## Codegen (.manta/types/)
216
+
217
+ On `manta dev` or `manta build`, the framework generates:
218
+
219
+ | File | Content |
220
+ |------|---------|
221
+ | `types.ts` | `MantaEntities` — typed step proxy for `step.service.catalog.create()` |
222
+ | `app.d.ts` | `MantaAppModules` — typed `app.modules.catalog.listProducts()` |
223
+ | `events.d.ts` | `MantaEventName` — union of all known event names |
224
+
225
+ These are TypeScript module augmentations. After codegen, `app.modules.*` has full autocomplete in your IDE.
226
+
227
+ ## Bootstrap sequence (summary)
228
+
229
+ 1. Load .env + config
230
+ 2. Resolve preset → adapter list
231
+ 3. Initialize logger, database, cache, locking, events, file, jobs
232
+ 4. Create `MantaApp` builder
233
+ 5. Discover resources (modules, commands, subscribers, jobs, links, queries)
234
+ 6. Load modules → instantiate services → generate tables (dev only)
235
+ 7. Load links → generate pivot tables
236
+ 8. Load subscribers → wire event bus
237
+ 9. Load jobs → schedule cron
238
+ 10. Load commands → register in CommandRegistry → wire HTTP callables
239
+ 11. Wire relational query (Drizzle relations for Query.graph)
240
+ 12. Build immutable app
241
+ 13. Wire auth routes + query routes + OpenAPI
242
+ 14. Ready to serve
243
+
244
+ ## Publishing modules and plugins
245
+
246
+ ### Naming convention
247
+
248
+ All published packages must include `manta` in the name:
249
+
250
+ - Module: `manta-module-catalog`, `manta-module-blog`, `@my-org/manta-module-payment`
251
+ - Plugin: `manta-plugin-ecommerce`, `@my-org/manta-plugin-cms`
252
+
253
+ This makes packages discoverable on npm and distinguishable from non-Manta packages.
254
+
255
+ ### Package structure convention
256
+
257
+ **Module package** — contains entities and services (the fundamental data unit):
258
+
259
+ ```
260
+ manta-module-catalog/
261
+ ├── entities/ # Entities (model.ts + service.ts)
262
+ │ └── product/
263
+ │ ├── model.ts
264
+ │ └── service.ts
265
+ ├── commands/ # Module-scoped commands (optional)
266
+ ├── index.ts # Barrel exports
267
+ ├── package.json # name: "manta-module-catalog"
268
+ ├── AGENT.md # AI instructions (written by dev)
269
+ ├── README.md # Auto-generated documentation
270
+ └── docs/ # Detailed docs (optional, for complex modules)
271
+ ```
272
+
273
+ **Plugin package** — orchestration only, NO entities:
274
+
275
+ ```
276
+ manta-plugin-ecommerce/
277
+ ├── commands/ # Application-level commands (cross-module orchestration)
278
+ │ ├── create-order.ts
279
+ │ └── process-payment.ts
280
+ ├── subscribers/ # Event reactions
281
+ │ └── order-placed.ts
282
+ ├── jobs/ # Scheduled tasks
283
+ │ └── cleanup-abandoned-carts.ts
284
+ ├── links/ # Cross-module relationships
285
+ │ └── order-product.ts
286
+ ├── queries/ # CQRS read endpoints
287
+ │ └── store/
288
+ ├── index.ts # Barrel exports
289
+ ├── package.json # name: "manta-plugin-ecommerce"
290
+ │ # peerDependencies: { "manta-module-customer": "^1.0", ... }
291
+ ├── AGENT.md # AI instructions
292
+ └── README.md # Auto-generated
293
+ ```
294
+
295
+ Note: the plugin's `package.json` lists its module dependencies as `peerDependencies`. The consumer installs both the plugin and the modules it needs.
296
+
297
+ **`AGENT.md`** — Written by the module developer. Explains to an AI agent:
298
+ - What the module does and why
299
+ - How to use it (which commands, which entities)
300
+ - What events it emits
301
+ - What dependencies it has
302
+ - Integration examples
303
+
304
+ When an AI encounters this module in `node_modules/`, it reads `AGENT.md` first and knows exactly how to use it.
305
+
306
+ **`README.md`** — Auto-generated by `manta extract`. Parsed from the source code:
307
+ - Entity schemas (from `defineModel`)
308
+ - Service methods with signatures (from `defineService`)
309
+ - Commands with input schemas (from `defineCommand`)
310
+ - Events emitted
311
+ - Install instructions
312
+
313
+ **`docs/`** — Optional. For complex modules that need to explain business concepts beyond the API reference.
314
+
315
+ ### Extract a module
316
+
317
+ ```bash
318
+ manta extract module catalog
319
+ ```
320
+
321
+ Interactive prompts:
322
+ 1. **npm scope** — `@my-org` or none (guides to npm account creation if needed)
323
+ 2. **Package name** — defaults to `manta-module-catalog`
324
+
325
+ What it generates:
326
+ 1. `packages/manta-module-catalog/` with entities, commands, barrel
327
+ 2. `package.json` with name, version, exports
328
+ 3. `AGENT.md` template (dev fills in the "why" and "how to use")
329
+ 4. `README.md` auto-generated from code analysis (entities, methods, commands, events)
330
+ 5. Workspace reference in root `package.json`
331
+
332
+ Works locally via pnpm workspace before publishing:
333
+
334
+ ```bash
335
+ cd packages/manta-module-catalog
336
+ npm publish
337
+ ```
338
+
339
+ ### Extract a plugin
340
+
341
+ ```bash
342
+ manta extract plugin ecommerce
343
+ ```
344
+
345
+ Interactive CLI:
346
+ 1. **npm scope** — same as module
347
+ 2. **Select module dependencies** — which published modules does this plugin depend on? (listed as `peerDependencies`)
348
+ 3. **Select commands** (application-level)
349
+ 4. **Select subscribers, jobs, links, queries**
350
+
351
+ What it generates:
352
+ 1. `packages/manta-plugin-ecommerce/` with commands, subscribers, jobs, links, queries
353
+ 2. `package.json` with `peerDependencies` on the required modules
354
+ 3. `AGENT.md` template
355
+ 4. `README.md` auto-generated
356
+ 5. All selected elements organized following the same file-based convention
357
+
358
+ **Important:** The extract command will refuse to include entities or services in a plugin. If your `src/` contains modules that the plugin uses, extract them as separate module packages first:
359
+
360
+ ```bash
361
+ # First: extract the modules
362
+ manta extract module customer
363
+ manta extract module product
364
+
365
+ # Then: extract the plugin (references modules as peerDependencies)
366
+ manta extract plugin ecommerce
367
+ ```
368
+
369
+ ### Module vs Plugin — the fundamental separation
370
+
371
+ **A plugin CANNOT contain modules.** This is enforced at build time.
372
+
373
+ Modules are the fundamental data unit (entities + service + DB). Plugins are the orchestration layer (workflows, subscribers, jobs, links, queries). Forcing this separation ensures modules are independently publishable, reusable, and ejectible.
374
+
375
+ | | Module | Plugin |
376
+ |---|--------|--------|
377
+ | **Contains** | entities/ + commands/ for one domain | App commands + subscribers + jobs + links + queries. **NO entities.** |
378
+ | **Dependencies** | None (self-contained) | Declares dependencies on published modules (e.g., `manta-module-customer`) |
379
+ | **Naming** | `manta-module-{name}` | `manta-plugin-{name}` |
380
+ | **AI docs** | `AGENT.md` at package root | `AGENT.md` at package root |
381
+ | **Extract** | `manta extract module <name>` | `manta extract plugin <name>` |
382
+ | **Eject** | `manta eject <package>` | `manta eject <package>` |
383
+ | **Build validation** | Must contain at least one entity | Must NOT contain `defineModel()` |
384
+
385
+ **Why?** If a plugin embedded modules, those modules would be locked inside the plugin. By forcing separation:
386
+ - Modules are reusable across plugins (any plugin can depend on `manta-module-customer`)
387
+ - Eject is granular (eject the plugin or a specific module independently)
388
+ - Plugin authors are incentivized to publish their modules separately
389
+
390
+ ### Eject
391
+
392
+ ```bash
393
+ # Eject a module — copies entity + service code to src/modules/
394
+ manta eject manta-module-catalog
395
+
396
+ # Eject a plugin — copies orchestration code (commands, subscribers, jobs, links, queries) to src/
397
+ manta eject manta-plugin-ecommerce
398
+ ```
399
+
400
+ **Module eject:** Copies the module source from `node_modules/` into `src/modules/catalog/`. Removes the npm dependency. The code is now yours — no more updates from the package.
401
+
402
+ **Plugin eject:** Copies the plugin's commands, subscribers, jobs, links, and queries into your `src/` directories. Module dependencies stay as npm packages — you only eject the orchestration layer. To also customize a module, eject it separately:
403
+
404
+ ```bash
405
+ # Eject the plugin (orchestration)
406
+ manta eject manta-plugin-ecommerce
407
+
408
+ # Eject just one module you need to customize
409
+ manta eject manta-module-customer
410
+
411
+ # Other modules (product, order, etc.) stay as npm packages
412
+ ```
413
+
414
+ This granular eject is possible precisely because plugins don't embed modules.
415
+
416
+ ### Auto-generated README
417
+
418
+ The `manta extract` command generates `README.md` by parsing the source:
419
+
420
+ ```markdown
421
+ # manta-module-catalog
422
+
423
+ ## Entities
424
+
425
+ ### Product
426
+ | Property | Type | Modifiers |
427
+ |----------|------|-----------|
428
+ | title | text | — |
429
+ | sku | text | unique |
430
+ | price | number | — |
431
+ | status | enum(draft, active, archived) | — |
432
+
433
+ ## Service methods
434
+ | Method | Arguments | Description |
435
+ |--------|-----------|-------------|
436
+ | activate | (id: string) | Activate a draft product |
437
+ | archive | (id: string) | Archive a product |
438
+
439
+ ## Auto-generated CRUD
440
+ createProducts, listProducts, retrieveProduct, updateProducts,
441
+ deleteProducts, softDeleteProducts, restoreProducts
442
+
443
+ ## Commands
444
+ | Name | Description | Input |
445
+ |------|-------------|-------|
446
+ | catalog:activate-product | Activate a draft product | { id: string } |
447
+
448
+ ## Events emitted
449
+ product.created, product.updated, product.deleted
450
+
451
+ ## Install
452
+ pnpm add manta-module-catalog
453
+
454
+ ## Usage
455
+ Add to your manta.config.ts modules section. The framework discovers it automatically.
456
+ ```
457
+
458
+ This is generated entirely from code — no manual documentation needed for the technical reference.
459
+
460
+ ### Naming convention — full ecosystem
461
+
462
+ Every published Manta package follows a strict naming convention for automatic discovery:
463
+
464
+ | Type | Naming pattern | Example |
465
+ |------|---------------|---------|
466
+ | Module | `manta-module-{name}` | `manta-module-blog`, `@acme/manta-module-payment` |
467
+ | Plugin | `manta-plugin-{name}` | `manta-plugin-ecommerce`, `@acme/manta-plugin-cms` |
468
+ | Adapter | `manta-adapter-{port}-{impl}` | `manta-adapter-cache-redis`, `manta-adapter-file-s3` |
469
+
470
+ **Why the naming convention matters:** The Manta community registry automatically scans npm for packages matching `manta-module-*`, `manta-plugin-*`, `manta-adapter-*`. Published packages are indexed and listed on the community page — no manual submission required.
471
+
472
+ ### Community registry (automatic)
473
+
474
+ The Manta ecosystem page scans npm and GitHub for published packages:
475
+
476
+ 1. **Auto-discovery** — Any package matching `manta-module-*`, `manta-plugin-*`, or `manta-adapter-*` is found automatically
477
+ 2. **Auto-documentation** — The registry reads the package's `AGENT.md` and `README.md` to generate a listing page
478
+ 3. **Security audit** — Packages are checked for known vulnerabilities before being listed (npm audit + custom checks)
479
+ 4. **Categories** — Modules, plugins, and adapters are listed separately with search and filtering
480
+
481
+ This means: publish on npm with the right name, include `AGENT.md` and `README.md`, and your package appears in the community listing automatically.
@@ -0,0 +1,183 @@
1
+ # Constraints — Constraint as Convention
2
+
3
+ ## Philosophy
4
+
5
+ Manta follows a **"you can't make mistakes"** approach. The framework doesn't tell you "don't do X" — it makes X **structurally impossible**. When something is caught at runtime, the error message tells you exactly **what to do** to fix it.
6
+
7
+ This is designed for AI-first development: an AI reading these error messages can fix the issue in one pass.
8
+
9
+ ## Structural constraints (impossible to bypass)
10
+
11
+ ### Module isolation
12
+
13
+ **Service isolation:** `defineService('entity', ({ db, log }) => ({...}))` receives **only `{ db, log }`** (typed repository + logger). You cannot:
14
+ - Import another module's service
15
+ - Access `app` or `app.modules.*`
16
+ - Call external APIs
17
+
18
+ The TypeScript type system enforces this — `db: TypedRepository<T>` has no escape hatch.
19
+
20
+ **Module command isolation:** Commands in `src/modules/catalog/commands/` can ONLY use `step.service.catalog.*`. They cannot reference other modules' services. The step proxy in a module command only resolves the module's own entities. If you try to call `step.service.inventory.*` from a catalog module command, it will fail.
21
+
22
+ **Why?** Modules must be self-contained. Cross-module orchestration happens in **application commands** (`src/commands/`) which have no scope restriction.
23
+
24
+ ### Compensation is automatic
25
+
26
+ Service methods are plain `async` functions. The framework auto-snapshots repository state before every mutation. In a workflow, if a step fails, all previous steps are automatically rolled back using the snapshots. No manual compensation logic needed.
27
+
28
+ ```typescript
29
+ // Just write plain async functions — compensation is handled by the framework
30
+ activate: async (id: string) => {
31
+ await db.update({ id, status: 'active' })
32
+ }
33
+ ```
34
+
35
+ ### step.action requires compensation
36
+
37
+ ```typescript
38
+ // Runtime error: step.action("charge") requires a compensate function
39
+ step.action('charge', { invoke: async () => {...} })
40
+
41
+ // Correct:
42
+ step.action('charge', {
43
+ invoke: async () => { ... },
44
+ compensate: async (result) => { ... },
45
+ })
46
+ ```
47
+
48
+ ### Plugin-module separation
49
+
50
+ **Plugins CANNOT contain modules.** This is enforced at two levels:
51
+
52
+ 1. **Build-time validation (`manta build`):** The build scans every plugin package. If a plugin contains `defineModel()` calls, the build fails:
53
+
54
+ ```
55
+ Plugin "manta-plugin-ecommerce" contains entity definitions (found defineModel("Customer")
56
+ in commands/create-customer.ts). Plugins cannot embed modules.
57
+
58
+ Modules must be published as separate packages (manta-module-customer) and declared
59
+ as peerDependencies of the plugin.
60
+
61
+ Fix: extract the module first with `manta extract module customer`, then reference it
62
+ as a dependency in the plugin's package.json.
63
+ ```
64
+
65
+ 2. **Extract-time validation (`manta extract plugin`):** The CLI refuses to include entities or services in a plugin package. It prompts you to extract modules first.
66
+
67
+ **Why?** Modules are the fundamental data unit — independently publishable, versionable, ejectible. If a plugin embedded modules, they'd be locked inside. This constraint forces a healthy ecosystem where modules are reusable across plugins.
68
+
69
+ ## Validation at definition time
70
+
71
+ Every `define*()` validates its arguments immediately. Errors are thrown when the file is loaded, not when the feature is used.
72
+
73
+ ### defineModel / DmlEntity
74
+
75
+ | Validation | Error message |
76
+ |-----------|--------------|
77
+ | Empty name | `Entity name is required. Usage: defineModel("Product", { title: field.text() })` |
78
+ | Lowercase | `Entity name must be PascalCase (got "product"). Change to "Product"` |
79
+ | Empty schema | `Entity "X" must have at least one property. Add properties with field.text(), field.number(), etc.` |
80
+ | Reserved column | `Property "id" is implicit and cannot be redefined in entity "X"` |
81
+ | Reserved prefix | `Property "raw_price" uses reserved "raw_" prefix (reserved for bigNumber shadow columns)` |
82
+
83
+ ### defineCommand
84
+
85
+ | Validation | Error message |
86
+ |-----------|--------------|
87
+ | Missing name | `Command name is required. Usage: defineCommand({ name: '...', description: '...', input: z.object({...}), workflow: async (input, { step }) => {...} })` |
88
+ | Missing description | `Command "X" requires a description (used for AI tool discovery and documentation)` |
89
+ | Missing input | `Command "X" requires an input Zod schema. Use z.object({}) for commands with no input.` |
90
+ | Missing workflow | `Command "X" workflow must be an async function: workflow: async (input, { step }) => {...}` |
91
+
92
+ ### defineSubscriber
93
+
94
+ | Validation | Error message |
95
+ |-----------|--------------|
96
+ | Empty event | `Subscriber event must be a non-empty string or array` |
97
+ | Non-function handler | `Subscriber handler must be a function` |
98
+
99
+ ### defineJob
100
+
101
+ | Validation | Error message |
102
+ |-----------|--------------|
103
+ | Missing name | `Job name is required` |
104
+ | Missing schedule | `Job schedule (cron expression) is required` |
105
+ | Non-function handler | `Job handler must be a function` |
106
+
107
+ ### defineLink
108
+
109
+ | Validation | Error message |
110
+ |-----------|--------------|
111
+ | Missing entities | `Link requires exactly two entities in the selector tuple` |
112
+
113
+ ### defineConfig
114
+
115
+ Validates `http`, `auth`, and `query` sections via Zod schemas. Errors include field path and issue:
116
+
117
+ ```
118
+ Invalid http config:
119
+ - port: Number must be greater than or equal to 1
120
+ ```
121
+
122
+ ## Duplicate detection
123
+
124
+ | Duplicate | When detected | Error |
125
+ |-----------|--------------|-------|
126
+ | Two modules with same name | `registerModule()` | `Module "X" is already registered. Each module name must be unique.` |
127
+ | Two commands with same name | `CommandRegistry.register()` | `Command "X" is already registered` |
128
+ | Two links between same entities | `defineLink()` | `Link between "X" and "Y" is already defined (table: "Z").` |
129
+ | Two queries with same name in same context | `QueryRegistry.register()` | `Query "X" is already registered in context "Y"` |
130
+
131
+ ## Runtime protection
132
+
133
+ ### Service method validation
134
+
135
+ At boot, when services are instantiated, every custom method is checked:
136
+
137
+ ```
138
+ Service method "activate" on entity "Product" must be an async function.
139
+ ```
140
+
141
+ ### Service resolution in workflows
142
+
143
+ When `step.service.catalog.activate(id)` is called and the service doesn't exist:
144
+
145
+ ```
146
+ Service for "catalog" not found. Available modules: [catalog, inventory, stats].
147
+ Check that the module is in src/modules/ and contains a service.ts with defineService().
148
+ ```
149
+
150
+ ### Link resolution
151
+
152
+ When auto-linking fails because an entity hasn't been created yet:
153
+
154
+ ```
155
+ Cannot link: no Product created yet in this workflow. Call step.service.product.create() first.
156
+ ```
157
+
158
+ ### Command input validation
159
+
160
+ Invalid input returns HTTP 400 with Zod details:
161
+
162
+ ```json
163
+ {
164
+ "type": "INVALID_DATA",
165
+ "message": "Validation failed",
166
+ "details": [
167
+ { "path": ["price"], "message": "Number must be greater than or equal to 0" }
168
+ ]
169
+ }
170
+ ```
171
+
172
+ ## What an AI should know
173
+
174
+ 1. **Every error message tells you what to do.** Read it, follow the instruction.
175
+ 2. **If TypeScript complains, it's a real error.** The type system catches missing compensation, wrong entity names, invalid configs.
176
+ 3. **If a define*() throws, the file has a problem.** Fix the arguments, not the framework.
177
+ 4. **Module isolation is absolute.** Don't try to import from another module's directory. Use commands for cross-module orchestration.
178
+ 5. **Module commands are scoped.** A command in `src/modules/catalog/commands/` can ONLY use `step.service.catalog.*`. For cross-module, use `src/commands/`.
179
+ 6. **Application commands are unrestricted.** A command in `src/commands/` can call any module via `step.service.*` and any module command via `step.command.*`.
180
+ 7. **Soft-delete is automatic.** All reads filter `deleted_at IS NULL`. Use `withDeleted: true` only when you need to see deleted records.
181
+ 8. **Installed modules have AGENT.md.** When you encounter a Manta module in `node_modules/`, read its `AGENT.md` first — it explains what the module does, how to use it, and what events it emits.
182
+ 9. **Package naming convention.** Modules: `manta-module-{name}`. Plugins: `manta-plugin-{name}`. Adapters: `manta-adapter-{port}-{impl}`. Always "manta" in the name — this enables automatic discovery on npm.
183
+ 10. **Plugins NEVER contain modules.** A plugin is orchestration only (commands, subscribers, jobs, links, contexts). Entities and services MUST be in separate module packages. If you're building a plugin and need entities, extract them as a module first.