@tailor-platform/sdk 2.0.0-next.3 → 2.0.0-next.5

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 (327) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/dist/aigateway-DR4Kwuik.mjs +9 -0
  3. package/dist/{aigateway-B3oZZE6v.mjs.map → aigateway-DR4Kwuik.mjs.map} +1 -1
  4. package/dist/{application-eHp9jXld.mjs → application-Bf8wxOi6.mjs} +701 -597
  5. package/dist/application-Bf8wxOi6.mjs.map +1 -0
  6. package/dist/application-CUkjzfij.mjs +3 -0
  7. package/dist/authconnection-CZvi9ANm.mjs +9 -0
  8. package/dist/authconnection-CZvi9ANm.mjs.map +1 -0
  9. package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
  10. package/dist/cli/cache/bundle-cache.d.mts +2 -1
  11. package/dist/cli/cache/store.d.mts +1 -1
  12. package/dist/cli/commands/api/index.d.mts +1 -0
  13. package/dist/cli/commands/deploy/aigateway.d.mts +5 -1
  14. package/dist/cli/commands/deploy/application.d.mts +7 -1
  15. package/dist/cli/commands/deploy/apply-phases.d.mts +14 -1
  16. package/dist/cli/commands/deploy/auth.d.mts +5 -1
  17. package/dist/cli/commands/deploy/deploy.d.mts +5 -0
  18. package/dist/cli/commands/deploy/executor.d.mts +7 -1
  19. package/dist/cli/commands/deploy/function-registry.d.mts +5 -0
  20. package/dist/cli/commands/deploy/idp.d.mts +5 -1
  21. package/dist/cli/commands/deploy/resolver.d.mts +5 -1
  22. package/dist/cli/commands/deploy/secret-manager.d.mts +5 -1
  23. package/dist/cli/commands/deploy/staticwebsite.d.mts +5 -1
  24. package/dist/cli/commands/deploy/tailordb/index.d.mts +8 -1
  25. package/dist/cli/commands/deploy/types.d.mts +3 -1
  26. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +3 -0
  27. package/dist/cli/commands/deploy/workflow.d.mts +4 -1
  28. package/dist/cli/commands/executor/get.d.mts +0 -1
  29. package/dist/cli/commands/executor/jobs.d.mts +0 -1
  30. package/dist/cli/commands/executor/list.d.mts +0 -1
  31. package/dist/cli/commands/executor/transform.d.mts +1 -0
  32. package/dist/cli/commands/executor/trigger.d.mts +0 -1
  33. package/dist/cli/commands/executor/webhook.d.mts +0 -1
  34. package/dist/cli/commands/function/get.d.mts +0 -1
  35. package/dist/cli/commands/function/list.d.mts +0 -1
  36. package/dist/cli/commands/function/transform.d.mts +1 -0
  37. package/dist/cli/commands/generate/service.d.mts +5 -1
  38. package/dist/cli/commands/machineuser/list.d.mts +0 -1
  39. package/dist/cli/commands/machineuser/token.d.mts +0 -1
  40. package/dist/cli/commands/oauth2client/get.d.mts +0 -1
  41. package/dist/cli/commands/oauth2client/list.d.mts +0 -1
  42. package/dist/cli/commands/oauth2client/transform.d.mts +1 -0
  43. package/dist/cli/commands/organization/folder/create.d.mts +0 -1
  44. package/dist/cli/commands/organization/folder/delete.d.mts +0 -1
  45. package/dist/cli/commands/organization/folder/get.d.mts +0 -1
  46. package/dist/cli/commands/organization/folder/list.d.mts +0 -1
  47. package/dist/cli/commands/organization/folder/update.d.mts +0 -1
  48. package/dist/cli/commands/organization/get.d.mts +0 -1
  49. package/dist/cli/commands/organization/list.d.mts +0 -1
  50. package/dist/cli/commands/organization/transform.d.mts +2 -0
  51. package/dist/cli/commands/organization/tree.d.mts +0 -1
  52. package/dist/cli/commands/organization/update.d.mts +0 -1
  53. package/dist/cli/commands/remove.d.mts +0 -1
  54. package/dist/cli/commands/show.d.mts +9 -4
  55. package/dist/cli/commands/tailordb/migrate/config.d.mts +0 -1
  56. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +16 -3
  57. package/dist/cli/commands/tailordb/migrate/generate.d.mts +0 -1
  58. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +6 -0
  59. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
  60. package/dist/cli/commands/tailordb/truncate.d.mts +0 -1
  61. package/dist/cli/commands/workflow/executions.d.mts +0 -1
  62. package/dist/cli/commands/workflow/get.d.mts +2 -1
  63. package/dist/cli/commands/workflow/list.d.mts +0 -1
  64. package/dist/cli/commands/workflow/resume.d.mts +0 -1
  65. package/dist/cli/commands/workflow/start.d.mts +0 -1
  66. package/dist/cli/commands/workflow/status.d.mts +1 -0
  67. package/dist/cli/commands/workflow/transform.d.mts +1 -0
  68. package/dist/cli/commands/workflow/wait.d.mts +0 -1
  69. package/dist/cli/commands/workflow/waiter.d.mts +1 -1
  70. package/dist/cli/commands/workspace/app/health.d.mts +0 -1
  71. package/dist/cli/commands/workspace/app/list.d.mts +0 -1
  72. package/dist/cli/commands/workspace/app/transform.d.mts +2 -0
  73. package/dist/cli/commands/workspace/create.d.mts +0 -1
  74. package/dist/cli/commands/workspace/delete.d.mts +0 -1
  75. package/dist/cli/commands/workspace/get.d.mts +0 -1
  76. package/dist/cli/commands/workspace/list.d.mts +0 -1
  77. package/dist/cli/commands/workspace/restore.d.mts +0 -1
  78. package/dist/cli/commands/workspace/transform.d.mts +2 -0
  79. package/dist/cli/commands/workspace/user/invite.d.mts +0 -1
  80. package/dist/cli/commands/workspace/user/list.d.mts +0 -1
  81. package/dist/cli/commands/workspace/user/remove.d.mts +0 -1
  82. package/dist/cli/commands/workspace/user/transform.d.mts +1 -0
  83. package/dist/cli/commands/workspace/user/update.d.mts +0 -1
  84. package/dist/cli/index.d.mts +6 -3
  85. package/dist/cli/index.mjs +273 -104
  86. package/dist/cli/index.mjs.map +1 -1
  87. package/dist/cli/lib.d.mts +4 -2
  88. package/dist/cli/lib.mjs +4 -4
  89. package/dist/cli/lib.mjs.map +1 -1
  90. package/dist/cli/query/index.d.mts +4 -1
  91. package/dist/cli/services/application.d.mts +12 -1
  92. package/dist/cli/services/auth/service.d.mts +2 -0
  93. package/dist/cli/services/executor/service.d.mts +1 -1
  94. package/dist/cli/services/http-adapter/bundler.d.mts +3 -1
  95. package/dist/cli/services/http-adapter/service.d.mts +2 -1
  96. package/dist/cli/services/resolver/service.d.mts +1 -1
  97. package/dist/cli/services/tailordb/service.d.mts +3 -1
  98. package/dist/cli/services/workflow/bundler.d.mts +2 -1
  99. package/dist/cli/services/workflow/service.d.mts +1 -1
  100. package/dist/cli/shared/args.d.mts +1 -1
  101. package/dist/cli/shared/client.d.mts +1 -1
  102. package/dist/cli/shared/config-loader.d.mts +0 -1
  103. package/dist/cli/shared/context.d.mts +2 -1
  104. package/dist/cli/shared/script-executor.d.mts +0 -1
  105. package/dist/cli/shared/seed-chunker.d.mts +7 -3
  106. package/dist/cli/shared/type-generator.d.mts +0 -1
  107. package/dist/cli/ts-hook.mjs +43 -13
  108. package/dist/completion/zsh-worker.zsh +10 -10
  109. package/dist/configure/config/index.d.mts +0 -1
  110. package/dist/configure/config/types.d.mts +3 -1
  111. package/dist/configure/index.d.mts +17 -5
  112. package/dist/configure/index.mjs +309 -5
  113. package/dist/configure/index.mjs.map +1 -1
  114. package/dist/configure/services/aigateway/index.d.mts +0 -1
  115. package/dist/configure/services/aigateway/types.d.mts +0 -1
  116. package/dist/configure/services/auth/index.d.mts +0 -1
  117. package/dist/configure/services/auth/types.d.mts +15 -14
  118. package/dist/configure/services/executor/executor.d.mts +1 -1
  119. package/dist/configure/services/executor/index.d.mts +1 -0
  120. package/dist/configure/services/executor/operation.d.mts +2 -2
  121. package/dist/configure/services/executor/trigger/event.d.mts +0 -1
  122. package/dist/configure/services/executor/trigger/index.d.mts +0 -1
  123. package/dist/configure/services/executor/trigger/schedule.d.mts +0 -1
  124. package/dist/configure/services/executor/trigger/webhook.d.mts +0 -1
  125. package/dist/configure/services/http-adapter/http-adapter.d.mts +1 -2
  126. package/dist/configure/services/idp/index.d.mts +1 -5
  127. package/dist/configure/services/idp/permission.d.mts +4 -5
  128. package/dist/configure/services/idp/types.d.mts +0 -1
  129. package/dist/configure/services/index.d.mts +8 -1
  130. package/dist/configure/services/resolver/resolver.d.mts +1 -0
  131. package/dist/configure/services/resolver/types.d.mts +0 -1
  132. package/dist/configure/services/secrets/index.d.mts +0 -1
  133. package/dist/configure/services/secrets/types.d.mts +0 -1
  134. package/dist/configure/services/staticwebsite/index.d.mts +0 -1
  135. package/dist/configure/services/staticwebsite/types.d.mts +0 -1
  136. package/dist/configure/services/tailordb/permission.d.mts +4 -5
  137. package/dist/configure/services/tailordb/schema.d.mts +104 -68
  138. package/dist/configure/services/tailordb/types.d.mts +66 -17
  139. package/dist/configure/services/workflow/execution-policy.d.mts +70 -0
  140. package/dist/configure/services/workflow/execution-policy.types.d.mts +103 -0
  141. package/dist/configure/services/workflow/index.d.mts +4 -1
  142. package/dist/configure/services/workflow/job.d.mts +7 -3
  143. package/dist/configure/services/workflow/wait-point.d.mts +0 -1
  144. package/dist/configure/services/workflow/workflow.d.mts +1 -1
  145. package/dist/configure/types/field-runtime.d.mts +0 -1
  146. package/dist/configure/types/field.d.mts +1 -2
  147. package/dist/configure/types/field.types.d.mts +6 -45
  148. package/dist/configure/types/index.d.mts +1 -0
  149. package/dist/configure/types/type.d.mts +1 -2
  150. package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
  151. package/dist/{context-Bd266-ru.mjs.map → context-DYQVYWqZ.mjs.map} +1 -1
  152. package/dist/{file-BbdFGdMV.mjs → file-BUcmVIH2.mjs} +12 -14
  153. package/dist/file-BUcmVIH2.mjs.map +1 -0
  154. package/dist/{file-utils-CYZnO1pX.mjs → file-utils-yEiIS4nJ.mjs} +2 -2
  155. package/dist/file-utils-yEiIS4nJ.mjs.map +1 -0
  156. package/dist/{globals-DhwZj0RB.mjs → globals-BjhJJ2dN.mjs} +2 -2
  157. package/dist/globals-BjhJJ2dN.mjs.map +1 -0
  158. package/dist/iconv-QWaZh0TT.mjs +38 -0
  159. package/dist/iconv-QWaZh0TT.mjs.map +1 -0
  160. package/dist/{idp-Bx25ZBdN.mjs → idp-RA_swu-h.mjs} +4 -5
  161. package/dist/idp-RA_swu-h.mjs.map +1 -0
  162. package/dist/kysely/index.d.mts +3 -4
  163. package/dist/{kysely-type-5eAChaHO.mjs → kysely-type-DqIRgDYR.mjs} +4 -5
  164. package/dist/kysely-type-DqIRgDYR.mjs.map +1 -0
  165. package/dist/parser/service/auth/index.d.mts +1 -1
  166. package/dist/parser/service/auth/schema.d.mts +2 -0
  167. package/dist/parser/service/http-adapter/index.d.mts +1 -1
  168. package/dist/parser/service/idp/types.d.mts +1 -0
  169. package/dist/parser/service/tailordb/types.d.mts +6 -1
  170. package/dist/plugin/builtin/enum-constants/index.d.mts +0 -1
  171. package/dist/plugin/builtin/file-utils/index.d.mts +0 -1
  172. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  173. package/dist/plugin/builtin/kysely-type/index.d.mts +0 -1
  174. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  175. package/dist/plugin/builtin/seed/index.d.mts +0 -1
  176. package/dist/plugin/get-generated-type.d.mts +0 -1
  177. package/dist/plugin/manager.d.mts +2 -1
  178. package/dist/plugin/types.d.mts +0 -1
  179. package/dist/plugin/with-context.d.mts +0 -1
  180. package/dist/{register-ts-hook-ZpBacA07.mjs → register-ts-hook-BhzVkej0.mjs} +799 -446
  181. package/dist/register-ts-hook-BhzVkej0.mjs.map +1 -0
  182. package/dist/{registry-DH4m7eYo.mjs → registry-BSbq6SPo.mjs} +4 -3
  183. package/dist/registry-BSbq6SPo.mjs.map +1 -0
  184. package/dist/resource_pb-BRv7AMXK.mjs +49 -0
  185. package/dist/resource_pb-BRv7AMXK.mjs.map +1 -0
  186. package/dist/runtime/aigateway.d.mts +5 -15
  187. package/dist/runtime/aigateway.mjs +2 -2
  188. package/dist/runtime/authconnection.d.mts +5 -15
  189. package/dist/runtime/authconnection.mjs +2 -2
  190. package/dist/runtime/context.d.mts +14 -6
  191. package/dist/runtime/context.mjs +2 -2
  192. package/dist/runtime/file.d.mts +14 -54
  193. package/dist/runtime/file.mjs +2 -2
  194. package/dist/runtime/globals.d.mts +1 -2
  195. package/dist/runtime/iconv.d.mts +5 -53
  196. package/dist/runtime/iconv.mjs +2 -2
  197. package/dist/runtime/idp.d.mts +13 -70
  198. package/dist/runtime/idp.mjs +2 -2
  199. package/dist/runtime/index.d.mts +11 -12
  200. package/dist/runtime/index.mjs +9 -9
  201. package/dist/runtime/secretmanager.d.mts +7 -20
  202. package/dist/runtime/secretmanager.mjs +2 -2
  203. package/dist/runtime/types.d.mts +9 -4
  204. package/dist/runtime/workflow.d.mts +42 -41
  205. package/dist/runtime/workflow.mjs +2 -2
  206. package/dist/{schema-89dYxNC2.mjs → schema-iCd1ugGp.mjs} +257 -54
  207. package/dist/schema-iCd1ugGp.mjs.map +1 -0
  208. package/dist/secretmanager-CYlpffsz.mjs +13 -0
  209. package/dist/secretmanager-CYlpffsz.mjs.map +1 -0
  210. package/dist/seed/index.d.mts +3 -2
  211. package/dist/service-BT0GPd01.mjs +3 -0
  212. package/dist/{service-ufH7sS8o.mjs → service-CzZEVrp9.mjs} +14 -9
  213. package/dist/service-CzZEVrp9.mjs.map +1 -0
  214. package/dist/{service_pb-CIrhGwHk.mjs → service_pb-Bk7dL-yT.mjs} +27 -50
  215. package/dist/service_pb-Bk7dL-yT.mjs.map +1 -0
  216. package/dist/{service_pb-DjwIn4jO.mjs → service_pb-DZkfjB_6.mjs} +1 -1
  217. package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +0 -1
  218. package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +0 -1
  219. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +0 -1
  220. package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +0 -1
  221. package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +0 -1
  222. package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +0 -1
  223. package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +0 -1
  224. package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +0 -1
  225. package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +0 -1
  226. package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +0 -1
  227. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +0 -1
  228. package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +0 -1
  229. package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +0 -1
  230. package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +0 -1
  231. package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +0 -1
  232. package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +0 -1
  233. package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +0 -1
  234. package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +0 -1
  235. package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +0 -1
  236. package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +0 -1
  237. package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +0 -1
  238. package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +0 -1
  239. package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +0 -1
  240. package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +0 -1
  241. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -2
  242. package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +0 -1
  243. package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +0 -1
  244. package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +0 -1
  245. package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +0 -1
  246. package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +0 -1
  247. package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +0 -1
  248. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +0 -1
  249. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +0 -1
  250. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +29 -10
  251. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +35 -2
  252. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +0 -1
  253. package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +0 -1
  254. package/dist/types/aigateway.generated.d.mts +5 -2
  255. package/dist/types/auth-connection.generated.d.mts +24 -11
  256. package/dist/types/auth.generated.d.mts +115 -84
  257. package/dist/types/executor.generated.d.mts +76 -84
  258. package/dist/types/helpers.d.mts +7 -6
  259. package/dist/types/http-adapter.generated.d.mts +11 -5
  260. package/dist/types/idp.generated.d.mts +536 -524
  261. package/dist/types/resolver.generated.d.mts +26 -11
  262. package/dist/types/staticwebsite.generated.d.mts +7 -3
  263. package/dist/types/tailordb.generated.d.mts +57 -29
  264. package/dist/types/workflow.generated.d.mts +9 -4
  265. package/dist/utils/test/index.d.mts +1 -2
  266. package/dist/utils/test/index.mjs +36 -10
  267. package/dist/utils/test/index.mjs.map +1 -1
  268. package/dist/utils/test/mock.d.mts +0 -1
  269. package/dist/vitest/environment.mjs +1 -1
  270. package/dist/vitest/index.d.mts +1 -1
  271. package/dist/vitest/index.mjs +11 -11
  272. package/dist/vitest/index.mjs.map +1 -1
  273. package/dist/vitest/mock-kysely.d.mts +0 -1
  274. package/dist/vitest/mocks/aigateway.d.mts +2 -2
  275. package/dist/vitest/mocks/authconnection.d.mts +2 -2
  276. package/dist/vitest/mocks/idp.d.mts +2 -2
  277. package/dist/vitest/mocks/secretmanager.d.mts +3 -1
  278. package/dist/vitest/mocks/tailordb.d.mts +6 -3
  279. package/dist/vitest/mocks/workflow.d.mts +15 -8
  280. package/dist/vitest/setup.mjs +1 -1
  281. package/dist/vitest/workflow-local.d.mts +1 -0
  282. package/dist/workflow-GNuSnsTx.mjs +22 -0
  283. package/dist/workflow-GNuSnsTx.mjs.map +1 -0
  284. package/docs/cli/auth.md +3 -3
  285. package/docs/cli/setup.md +9 -9
  286. package/docs/cli-reference.md +7 -6
  287. package/docs/configuration.md +24 -0
  288. package/docs/migration/v2.md +317 -0
  289. package/docs/plugin/custom.md +4 -4
  290. package/docs/plugin/index.md +2 -2
  291. package/docs/runtime.md +4 -2
  292. package/docs/services/aigateway.md +2 -0
  293. package/docs/services/auth.md +2 -2
  294. package/docs/services/resolver.md +1 -1
  295. package/docs/services/tailordb-migration.md +1 -1
  296. package/docs/services/tailordb.md +125 -93
  297. package/docs/services/workflow.md +78 -0
  298. package/package.json +22 -22
  299. package/dist/aigateway-B3oZZE6v.mjs +0 -15
  300. package/dist/application-D2hSK1ZL.mjs +0 -3
  301. package/dist/application-eHp9jXld.mjs.map +0 -1
  302. package/dist/authconnection-BGQM8FZI.mjs +0 -15
  303. package/dist/authconnection-BGQM8FZI.mjs.map +0 -1
  304. package/dist/cli/shared/trigger-context.d.mts +0 -1
  305. package/dist/field-runtime-CAnh_oow.mjs +0 -183
  306. package/dist/field-runtime-CAnh_oow.mjs.map +0 -1
  307. package/dist/file-BbdFGdMV.mjs.map +0 -1
  308. package/dist/file-utils-CYZnO1pX.mjs.map +0 -1
  309. package/dist/globals-DhwZj0RB.mjs.map +0 -1
  310. package/dist/iconv-D2vi8G36.mjs +0 -63
  311. package/dist/iconv-D2vi8G36.mjs.map +0 -1
  312. package/dist/idp-Bx25ZBdN.mjs.map +0 -1
  313. package/dist/kysely-type-5eAChaHO.mjs.map +0 -1
  314. package/dist/register-ts-hook-ZpBacA07.mjs.map +0 -1
  315. package/dist/registry-DH4m7eYo.mjs.map +0 -1
  316. package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
  317. package/dist/schema-89dYxNC2.mjs.map +0 -1
  318. package/dist/secretmanager-BVxw3ih_.mjs +0 -24
  319. package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
  320. package/dist/service-CkIwEctX.mjs +0 -3
  321. package/dist/service-ufH7sS8o.mjs.map +0 -1
  322. package/dist/service_pb-CIrhGwHk.mjs.map +0 -1
  323. package/dist/types-C-lQ4se3.mjs +0 -4
  324. package/dist/types-CXF2OYdR.mjs +0 -199
  325. package/dist/types-CXF2OYdR.mjs.map +0 -1
  326. package/dist/workflow-Bo59B75H.mjs +0 -50
  327. package/dist/workflow-Bo59B75H.mjs.map +0 -1
@@ -1,13 +1,12 @@
1
+ import { FieldOptions, FieldOutput, FieldValidateInput, TailorFieldType, TailorToTs } from "../../types/field.types.mjs";
1
2
  import { InferredAttributes, TailorPrincipal } from "../../../runtime/types.mjs";
2
3
  import { InferFieldsOutput, TypeLevelError, output } from "../../../types/helpers.mjs";
3
- import { FieldOptions, FieldOutput, FieldValidateInput, TailorFieldType, TailorToTs, Validators } from "../../types/field.types.mjs";
4
- import { DBFieldMetadata, DefinedDBFieldMetadata, ExcludeNestedDBFields, Hook, Hooks, IndexDef, RelationType, SerialConfig, TailorDBField as TailorDBField$1, TailorDBType as TailorDBType$1, TypeFeatures } from "./types.mjs";
4
+ import { DBFieldMetadata, DefinedDBFieldMetadata, ExcludeDefaultedDBFields, ExcludeHookedDBFields, ExcludeNestedDBFields, Hook, IndexDef, RelationType, SerialConfig, TailorDBField as TailorDBField$1, TailorDBType as TailorDBType$1, TypeFeatures, TypeHook, TypeValidateFn } from "./types.mjs";
5
5
  import { AllowedValues, AllowedValuesOutput } from "../../types/field.mjs";
6
6
  import { FieldParseArgs, FieldParseInternalArgs } from "../../types/field-runtime.mjs";
7
7
  import { PluginConfigs } from "../../../plugin/types.mjs";
8
8
  import { TailorTypeGqlPermission, TailorTypePermission } from "./permission.mjs";
9
9
  import { StandardSchemaV1 } from "@standard-schema/spec";
10
-
11
10
  //#region src/configure/services/tailordb/schema.d.ts
12
11
  type AnyBuilderMethod = any;
13
12
  type TailorAnyDBField = Omit<TailorDBField$1<AnyBuilderMethod, AnyBuilderMethod>, "fields"> & {
@@ -21,12 +20,13 @@ type TailorAnyDBField = Omit<TailorDBField$1<AnyBuilderMethod, AnyBuilderMethod>
21
20
  index: AnyBuilderMethod;
22
21
  unique: AnyBuilderMethod;
23
22
  vector: AnyBuilderMethod;
23
+ default: AnyBuilderMethod;
24
24
  hooks: AnyBuilderMethod;
25
25
  validate: AnyBuilderMethod;
26
26
  serial: AnyBuilderMethod;
27
27
  clone: AnyBuilderMethod;
28
28
  };
29
- type TailorAnyDBType = TailorDBType<any, any>;
29
+ type TailorAnyDBType = TailorDBType<any, any, any>;
30
30
  type IsAny<T> = 0 extends 1 & T ? true : false;
31
31
  type DBFieldTypeNameMethod<Defined extends DefinedDBFieldMetadata> = IsAny<Defined> extends true ? TypeLevelError<string> : TypeLevelError<"typeName cannot be used on TailorDB fields">;
32
32
  type WithDBFieldDescription<Defined> = Defined & {
@@ -67,6 +67,9 @@ type WithDBFieldHooks<Defined, H> = Defined & {
67
67
  };
68
68
  serial: false;
69
69
  };
70
+ type WithDBFieldDefault<Defined> = Defined & {
71
+ default: true;
72
+ };
70
73
  type WithDBFieldValidate<Defined> = Defined & {
71
74
  validate: true;
72
75
  };
@@ -96,6 +99,30 @@ type DBFieldCloneOutput<Output, NewOpt extends FieldOptions> = NewOpt extends {
96
99
  } ? DBFieldCloneArrayOutput<Output, NewOpt> | null : NewOpt extends {
97
100
  optional: false;
98
101
  } ? DBFieldCloneArrayOutput<Output, NewOpt> : null extends Output ? DBFieldCloneArrayOutput<Output, NewOpt> | null : DBFieldCloneArrayOutput<Output, NewOpt>;
102
+ type DBFieldCloneOptions<Defined extends DefinedDBFieldMetadata> = Omit<FieldOptions, "array"> & {
103
+ array?: Defined extends {
104
+ validate: unknown;
105
+ } ? Defined["array"] : boolean;
106
+ };
107
+ type InvalidValidatedArrayCloneKeys<Fields extends Record<string, TailorAnyDBField>, K extends keyof Fields, Opt extends FieldOptions> = Opt extends {
108
+ array: infer ArrayOption;
109
+ } ? { [P in K]: Fields[P] extends TailorDBField<infer Defined, infer _Output> ? Defined extends {
110
+ validate: unknown;
111
+ } ? ArrayOption extends Defined["array"] ? never : P : never : never; }[K] : never;
112
+ type DBFieldsCloneOptionsGuard<Fields extends Record<string, TailorAnyDBField>, K extends keyof Fields, Opt extends FieldOptions> = [InvalidValidatedArrayCloneKeys<Fields, K, Opt>] extends [never] ? unknown : TypeLevelError<"array cannot be changed on fields with custom validation">;
113
+ type DefinedDBTypeMetadata = {
114
+ hooks?: true;
115
+ validate?: true;
116
+ features?: true;
117
+ indexes?: true;
118
+ files?: true;
119
+ permission?: true;
120
+ gqlPermission?: true;
121
+ description?: true;
122
+ };
123
+ type WithDBTypeMetadata<Defined extends DefinedDBTypeMetadata, Key extends keyof DefinedDBTypeMetadata> = Defined & Record<Key, true>;
124
+ type DBTypeDuplicateInputGuard<Defined extends DefinedDBTypeMetadata, Key extends keyof DefinedDBTypeMetadata, Input, Message extends string> = IsAny<Defined> extends true ? Input : Defined extends Record<Key, unknown> ? TypeLevelError<Message> : Input;
125
+ type DBTypeDuplicateRestGuard<Defined extends DefinedDBTypeMetadata, Key extends keyof DefinedDBTypeMetadata, Input extends unknown[], Message extends string> = IsAny<Defined> extends true ? Input : Defined extends Record<Key, unknown> ? [TypeLevelError<Message>, ...TypeLevelError<Message>[]] : Input;
99
126
  type FileKeyConflictError<Fields extends Record<string, TailorAnyDBField>, User extends object> = Partial<Record<keyof output<TailorDBType<Fields, User>> & string, TypeLevelError<"file keys cannot use existing field names">>>;
100
127
  type DBFieldDescriptionFn<Defined extends DefinedDBFieldMetadata, Output> = (description: string) => TailorDBField<WithDBFieldDescription<Defined>, Output>;
101
128
  type DBFieldRelationFn<Defined extends DefinedDBFieldMetadata, Output> = {
@@ -105,7 +132,9 @@ type DBFieldRelationFn<Defined extends DefinedDBFieldMetadata, Output> = {
105
132
  type DBFieldIndexFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<WithDBFieldIndex<Defined>, Output>;
106
133
  type DBFieldUniqueFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<WithDBFieldUnique<Defined>, Output>;
107
134
  type DBFieldVectorFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<WithDBFieldVector<Defined>, Output>;
108
- type DBFieldHooksFn<Defined extends DefinedDBFieldMetadata, Output> = <const H extends Hook<unknown, Output>>(hooks: H) => TailorDBField<WithDBFieldHooks<Defined, H>, Output>;
135
+ type DBFieldHooksFn<Defined extends DefinedDBFieldMetadata, Output> = <const H extends Hook<Output, Defined extends {
136
+ default: true;
137
+ } ? Output | null | undefined : Output>>(hooks: H) => TailorDBField<WithDBFieldHooks<Defined, H>, Output>;
109
138
  type DBFieldValidateFn<Defined extends DefinedDBFieldMetadata, Output> = (...validate: FieldValidateInput<Output>[]) => TailorDBField<WithDBFieldValidate<Defined>, Output>;
110
139
  type DBFieldSerialFn<Defined extends DefinedDBFieldMetadata, Output> = (config: SerialConfig<Defined["type"] & ("integer" | "string")>) => TailorDBField<WithDBFieldSerial<Defined>, Output>;
111
140
  type DBFieldDescriptionMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny<Defined> extends true ? DBFieldDescriptionFn<Defined, Output> : Defined extends {
@@ -114,16 +143,13 @@ type DBFieldDescriptionMethod<Defined extends DefinedDBFieldMetadata, Output> =
114
143
  type DBFieldRelationMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny<Defined> extends true ? DBFieldRelationFn<Defined, Output> : Defined extends {
115
144
  relation: unknown;
116
145
  } ? TypeLevelError<".relation() has already been set"> : DBFieldRelationFn<Defined, Output>;
146
+ type DBFieldArrayCheck<A extends boolean, Ok, Msg extends string> = A extends true ? TypeLevelError<Msg> : Ok;
117
147
  type DBFieldIndexMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny<Defined> extends true ? DBFieldIndexFn<Defined, Output> : Defined extends {
118
148
  index: unknown;
119
- } ? TypeLevelError<".index() has already been set"> : boolean extends Defined["array"] ? DBFieldIndexFn<Defined, Output> | TypeLevelError<"index cannot be set on array fields"> : Defined extends {
120
- array: true;
121
- } ? TypeLevelError<"index cannot be set on array fields"> : DBFieldIndexFn<Defined, Output>;
149
+ } ? TypeLevelError<".index() has already been set"> : DBFieldArrayCheck<Defined["array"], DBFieldIndexFn<Defined, Output>, "index cannot be set on array fields">;
122
150
  type DBFieldUniqueMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny<Defined> extends true ? DBFieldUniqueFn<Defined, Output> : Defined extends {
123
151
  unique: unknown;
124
- } ? TypeLevelError<".unique() has already been set"> : boolean extends Defined["array"] ? DBFieldUniqueFn<Defined, Output> | TypeLevelError<"unique cannot be set on array fields"> : Defined extends {
125
- array: true;
126
- } ? TypeLevelError<"unique cannot be set on array fields"> : DBFieldUniqueFn<Defined, Output>;
152
+ } ? TypeLevelError<".unique() has already been set"> : DBFieldArrayCheck<Defined["array"], DBFieldUniqueFn<Defined, Output>, "unique cannot be set on array fields">;
127
153
  type DBFieldVectorMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny<Defined> extends true ? DBFieldVectorFn<Defined, Output> : Defined extends {
128
154
  vector: unknown;
129
155
  } ? TypeLevelError<".vector() has already been set"> : Defined extends {
@@ -155,6 +181,14 @@ type DBFieldSerialMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny
155
181
  type: "integer" | "string";
156
182
  array: false;
157
183
  } ? DBFieldSerialFn<Defined, Output> : TypeLevelError<"serial can only be set on non-array integer or string fields">;
184
+ type DBFieldDefaultFn<Defined extends DefinedDBFieldMetadata, Output> = (value: Output extends null ? NonNullable<Output> : Output) => TailorDBField<WithDBFieldDefault<Defined>, Output>;
185
+ type DBFieldDefaultMethod<Defined extends DefinedDBFieldMetadata, Output> = IsAny<Defined> extends true ? DBFieldDefaultFn<Defined, Output> : Defined extends {
186
+ default: unknown;
187
+ } ? TypeLevelError<".default() has already been set"> : Defined extends {
188
+ type: "nested";
189
+ } ? TypeLevelError<"default cannot be set on nested type fields"> : Defined extends {
190
+ serial: true;
191
+ } ? TypeLevelError<"default cannot be set on serial fields"> : null extends Output ? TypeLevelError<"default cannot be set on optional fields"> : DBFieldDefaultFn<Defined, Output>;
158
192
  /**
159
193
  * Full TailorDBField interface with builder methods.
160
194
  * Extends the minimal structural interface from types/ with fluent API methods.
@@ -196,12 +230,24 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata = DefinedDBFieldM
196
230
  * Enable vector search on the field (string type only)
197
231
  */
198
232
  vector: DBFieldVectorMethod<Defined, Output>;
233
+ /**
234
+ * Set a default value for the field on create. When the field is required,
235
+ * this makes it optional in the Create input — the default fills in when
236
+ * no value (or a nullish hook result) is provided.
237
+ *
238
+ * For datetime/date/time fields, pass `"now"` to use the operation timestamp.
239
+ */
240
+ default: DBFieldDefaultMethod<Defined, Output>;
199
241
  /**
200
242
  * Add hooks for create/update operations on this field.
201
243
  */
202
244
  hooks: DBFieldHooksMethod<Defined, Output>;
203
245
  /**
204
246
  * Add validation functions to the field.
247
+ *
248
+ * Validators receive `{ value, data, user }` and run after hooks and
249
+ * built-in type validation; they are skipped when built-in validation
250
+ * fails. For array fields, `value` is the complete array.
205
251
  */
206
252
  validate: DBFieldValidateMethod<Defined, Output>;
207
253
  /**
@@ -209,30 +255,31 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata = DefinedDBFieldM
209
255
  */
210
256
  serial: DBFieldSerialMethod<Defined, Output>;
211
257
  /**
212
- * Clone the field with optional overrides for field options
258
+ * Clone the field with optional overrides for field options.
259
+ * The `array` option cannot change on fields with custom validation.
213
260
  */
214
- clone<const NewOpt extends FieldOptions>(options?: NewOpt): TailorDBField<WithDBFieldCloneOptions<Defined, NewOpt>, DBFieldCloneOutput<Output, NewOpt>>;
261
+ clone<const NewOpt extends DBFieldCloneOptions<Defined>>(options?: NewOpt): TailorDBField<WithDBFieldCloneOptions<Defined, NewOpt>, DBFieldCloneOutput<Output, NewOpt>>;
215
262
  }
216
263
  /**
217
264
  * Full TailorDBType interface with builder methods.
218
265
  * Extends the minimal structural interface from types/ with fluent API methods.
219
266
  */
220
- interface TailorDBType<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributes> extends TailorDBType$1<Fields, User> {
267
+ interface TailorDBType<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributes, Defined extends DefinedDBTypeMetadata = any> extends TailorDBType$1<Fields, User> {
221
268
  _description?: string;
222
- hooks(hooks: Hooks<Fields>): TailorDBType<Fields, User>;
223
- validate(validators: Validators<Fields>): TailorDBType<Fields, User>;
224
- features(features: Omit<TypeFeatures, "pluralForm">): TailorDBType<Fields, User>;
225
- indexes(...indexes: IndexDef<TailorDBType<Fields, User>>[]): TailorDBType<Fields, User>;
226
- files<const F extends string>(files: Record<F, string> & FileKeyConflictError<Fields, User>): TailorDBType<Fields, User>;
227
- permission<U extends object = User, P extends TailorTypePermission<U, output<TailorDBType<Fields, User>>> = TailorTypePermission<U, output<TailorDBType<Fields, User>>>>(permission: P): TailorDBType<Fields, U>;
228
- gqlPermission<U extends object = User, P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>>(permission: P): TailorDBType<Fields, U>;
229
- description(description: string): TailorDBType<Fields, User>;
269
+ hooks(hook: DBTypeDuplicateInputGuard<Defined, "hooks", TypeHook<Fields>, ".hooks() has already been set">): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, "hooks">>;
270
+ validate(fn: DBTypeDuplicateInputGuard<Defined, "validate", TypeValidateFn<Fields>, ".validate() has already been set">): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, "validate">>;
271
+ features(features: DBTypeDuplicateInputGuard<Defined, "features", Omit<TypeFeatures, "pluralForm">, ".features() has already been set">): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, "features">>;
272
+ indexes(...indexes: DBTypeDuplicateRestGuard<Defined, "indexes", IndexDef<TailorDBType<Fields, User, Defined>>[], ".indexes() has already been set">): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, "indexes">>;
273
+ files<const F extends string>(files: DBTypeDuplicateInputGuard<Defined, "files", Record<F, string> & FileKeyConflictError<Fields, User>, ".files() has already been set">): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, "files">>;
274
+ permission<U extends object = User, P extends TailorTypePermission<U, output<TailorDBType<Fields, User, Defined>>> = TailorTypePermission<U, output<TailorDBType<Fields, User, Defined>>>>(permission: DBTypeDuplicateInputGuard<Defined, "permission", P, ".permission() has already been set">): TailorDBType<Fields, U, WithDBTypeMetadata<Defined, "permission">>;
275
+ gqlPermission<U extends object = User, P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>>(permission: DBTypeDuplicateInputGuard<Defined, "gqlPermission", P, ".gqlPermission() has already been set">): TailorDBType<Fields, U, WithDBTypeMetadata<Defined, "gqlPermission">>;
276
+ description(description: DBTypeDuplicateInputGuard<Defined, "description", string, ".description() has already been set">): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, "description">>;
230
277
  pickFields<K extends keyof Fields>(keys: K[]): Pick<Fields, K>;
231
- pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options: Opt): { [P in K]: Fields[P] extends TailorDBField<infer D, infer O> ? TailorDBField<WithDBFieldCloneOptions<D, Opt>, DBFieldCloneOutput<O, Opt>> : never };
278
+ pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options: Opt & DBFieldsCloneOptionsGuard<Fields, K, Opt>): { [P in K]: Fields[P] extends TailorDBField<infer D, infer O> ? TailorDBField<WithDBFieldCloneOptions<D, Opt>, DBFieldCloneOutput<O, Opt>> : never; };
232
279
  omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K>;
233
- plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: { [K in P]: PluginConfigs<keyof Fields & string>[K] }): TailorDBType<Fields, User>;
280
+ plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: { [K in P]: PluginConfigs<keyof Fields & string>[K]; }): TailorDBType<Fields, User, Defined>;
234
281
  }
235
- type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributes> = TailorDBType<Fields, User>;
282
+ type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributes, Defined extends DefinedDBTypeMetadata = any> = TailorDBType<Fields, User, Defined>;
236
283
  interface RelationConfig<S extends RelationType, T extends TailorDBType> {
237
284
  type: S;
238
285
  toward: {
@@ -358,7 +405,7 @@ declare function _enum<const V extends AllowedValues, const Opt extends FieldOpt
358
405
  * @example db.object({ street: db.string(), city: db.string(), zip: db.string() })
359
406
  * @example db.object({ name: db.string() }, { optional: true })
360
407
  */
361
- declare function object<const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>, const Opt extends FieldOptions>(fields: F, options?: Opt): TailorDBField<{
408
+ declare function object<const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F> & ExcludeHookedDBFields<F> & ExcludeDefaultedDBFields<F>, const Opt extends FieldOptions>(fields: F, options?: Opt): TailorDBField<{
362
409
  type: "nested";
363
410
  array: Opt extends {
364
411
  array: true;
@@ -366,19 +413,19 @@ declare function object<const F extends Record<string, TailorAnyDBField> & Exclu
366
413
  }, FieldOutput<InferFieldsOutput<F>, Opt>>;
367
414
  declare const idField: TailorDBFieldInstance<"uuid", FieldOptions, string>;
368
415
  type idField = typeof idField;
369
- type DBType<F extends {
416
+ type DBTable<F extends {
370
417
  id?: never;
371
- } & Record<string, TailorAnyDBField>> = TailorDBInstance<{
418
+ } & Record<string, TailorAnyDBField>, Defined extends DefinedDBTypeMetadata = DefinedDBTypeMetadata> = TailorDBInstance<{
372
419
  id: idField;
373
- } & F>;
420
+ } & F, InferredAttributes, Defined>;
374
421
  /**
375
- * Creates a new database type with the specified fields.
376
- * An `id` field (UUID) is automatically added to every type.
377
- * @param name - The name of the type, or a tuple of [name, pluralForm]
378
- * @param fields - The field definitions for the type
379
- * @returns A new TailorDBType instance
422
+ * Creates a new database table with the specified fields.
423
+ * An `id` field (UUID) is automatically added to every table.
424
+ * @param name - The name of the table, or a tuple of [name, pluralForm]
425
+ * @param fields - The field definitions for the table
426
+ * @returns A new TailorDB table instance
380
427
  * @example
381
- * export const user = db.type("User", {
428
+ * export const user = db.table("User", {
382
429
  * name: db.string(),
383
430
  * email: db.string(),
384
431
  * age: db.int({ optional: true }),
@@ -388,23 +435,23 @@ type DBType<F extends {
388
435
  * // Always export both the value and type:
389
436
  * export type user = typeof user;
390
437
  */
391
- declare function dbType<const F extends {
438
+ declare function dbTable<const F extends {
392
439
  id?: never;
393
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
440
+ } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBTable<F>;
394
441
  /**
395
- * Creates a new database type with the specified fields and description.
396
- * An `id` field (UUID) is automatically added to every type.
397
- * @param name - The name of the type, or a tuple of [name, pluralForm]
398
- * @param description - A description of the type
399
- * @param fields - The field definitions for the type
400
- * @returns A new TailorDBType instance
442
+ * Creates a new database table with the specified fields and description.
443
+ * An `id` field (UUID) is automatically added to every table.
444
+ * @param name - The name of the table, or a tuple of [name, pluralForm]
445
+ * @param description - A description of the table
446
+ * @param fields - The field definitions for the table
447
+ * @returns A new TailorDB table instance
401
448
  */
402
- declare function dbType<const F extends {
449
+ declare function dbTable<const F extends {
403
450
  id?: never;
404
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBType<F>;
405
- /** TailorDB schema builder utilities for defining types and fields. */
451
+ } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBTable<F, WithDBTypeMetadata<DefinedDBTypeMetadata, "description">>;
452
+ /** TailorDB schema builder utilities for defining tables and fields. */
406
453
  declare const db: {
407
- type: typeof dbType;
454
+ table: typeof dbTable;
408
455
  uuid: typeof uuid;
409
456
  string: typeof string;
410
457
  bool: typeof bool;
@@ -418,36 +465,25 @@ declare const db: {
418
465
  object: typeof object;
419
466
  fields: {
420
467
  /**
421
- * Creates standard timestamp fields (createdAt, updatedAt) with auto-hooks.
422
- * createdAt and updatedAt are set on create.
423
- * User-specified timestamp values are respected when provided (e.g. seeding
424
- * historical records); the current time is used only when the value is omitted.
468
+ * Creates standard timestamp fields (createdAt, updatedAt) with automatic defaults.
469
+ * Both fields default to the current time on create. updatedAt is also refreshed on update.
470
+ * User-specified values are respected when provided (e.g. seeding historical records).
425
471
  * @returns An object with createdAt and updatedAt fields
426
472
  * @example
427
- * const model = db.type("Model", {
473
+ * const model = db.table("Model", {
428
474
  * name: db.string(),
429
475
  * ...db.fields.timestamps(),
430
476
  * });
431
477
  */
432
478
  timestamps: () => {
433
- createdAt: TailorDBField<WithDBFieldDescription<WithDBFieldHooks<DBFieldDefined<"datetime", FieldOptions>, {
434
- readonly create: ({
435
- value
436
- }: {
437
- value: string | Date | null;
438
- data: unknown;
439
- invoker: TailorPrincipal | null;
440
- }) => string | Date;
441
- }>>, string | Date>;
442
- updatedAt: TailorDBField<WithDBFieldDescription<WithDBFieldHooks<DBFieldDefined<"datetime", FieldOptions>, {
443
- readonly create: ({
444
- value
445
- }: {
446
- value: string | Date | null;
447
- data: unknown;
479
+ createdAt: TailorDBField<WithDBFieldDescription<WithDBFieldDefault<DBFieldDefined<"datetime", FieldOptions>>>, string | Date>;
480
+ updatedAt: TailorDBField<WithDBFieldDescription<WithDBFieldHooks<WithDBFieldDefault<DBFieldDefined<"datetime", FieldOptions>>, {
481
+ readonly update: ({ input, now }: {
482
+ input: string | Date | null;
483
+ oldValue: string | Date;
448
484
  invoker: TailorPrincipal | null;
485
+ now: Date;
449
486
  }) => string | Date;
450
- readonly update: () => Date;
451
487
  }>>, string | Date>;
452
488
  };
453
489
  };
@@ -1,9 +1,7 @@
1
+ import { DefinedFieldMetadata, FieldMetadata, TailorField, TailorFieldType } from "../../types/field.types.mjs";
1
2
  import { InferredAttributes, TailorPrincipal } from "../../../runtime/types.mjs";
2
- import { InferFieldsOutput, Prettify, output } from "../../../types/helpers.mjs";
3
- import { DefinedFieldMetadata, FieldMetadata, TailorField } from "../../types/field.types.mjs";
3
+ import { DeepReadonly, InferFieldsOutput, Prettify, output } from "../../../types/helpers.mjs";
4
4
  import { DBFieldMetadata as DBFieldMetadata$1, GqlOperationsInput, RawPermissions, TailorDBServiceConfigInput } from "../../../types/tailordb.generated.mjs";
5
- import { NonEmptyObject } from "type-fest";
6
-
7
5
  //#region src/configure/services/tailordb/types.d.ts
8
6
  type SerialConfig<T extends "string" | "integer" = "string" | "integer"> = Prettify<{
9
7
  start: number;
@@ -23,6 +21,7 @@ interface DBFieldMetadata extends FieldMetadata {
23
21
  serial?: SerialConfig;
24
22
  relation?: boolean;
25
23
  scale?: number;
24
+ default?: unknown;
26
25
  }
27
26
  interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
28
27
  index?: boolean;
@@ -37,6 +36,7 @@ interface DefinedDBFieldMetadata extends DefinedFieldMetadata {
37
36
  };
38
37
  serial?: boolean;
39
38
  relation?: boolean;
39
+ default?: boolean;
40
40
  }
41
41
  type GqlOperationsConfig = GqlOperationsInput;
42
42
  interface RawRelationConfig {
@@ -64,6 +64,11 @@ interface TailorDBTypeMetadata {
64
64
  fields: string[];
65
65
  unique?: boolean;
66
66
  }>;
67
+ typeHook?: {
68
+ create?: Function;
69
+ update?: Function;
70
+ };
71
+ typeValidate?: Function;
67
72
  }
68
73
  /**
69
74
  * Minimal structural interface for TailorDBField.
@@ -91,24 +96,68 @@ interface TailorDBType<Fields extends Record<string, TailorAnyDBField> = any, Us
91
96
  }
92
97
  type TailorAnyDBType = TailorDBType<any, any>;
93
98
  type TailorDBInstance<Fields extends Record<string, TailorAnyDBField> = any, User extends object = InferredAttributes> = TailorDBType<Fields, User>;
94
- type HookFn<TValue, TData, TReturn> = (args: {
95
- value: TValue;
96
- data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
99
+ type HookArgs<TData> = TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: DeepReadonly<TData[K]> | null | undefined; } : unknown;
100
+ type CreateHookFn<TValue, TReturn> = (args: {
101
+ input: TValue;
102
+ invoker: TailorPrincipal | null;
103
+ now: Date;
104
+ }) => TReturn;
105
+ type UpdateHookFn<TValue, TReturn> = (args: {
106
+ input: TValue;
107
+ oldValue: TReturn;
97
108
  invoker: TailorPrincipal | null;
109
+ now: Date;
98
110
  }) => TReturn;
99
- type Hook<TData, TReturn> = {
100
- create?: HookFn<TReturn | null, TData, TReturn>;
101
- update?: HookFn<TReturn | null, TData, TReturn>;
111
+ type Hook<TReturn, TCreateReturn = TReturn> = {
112
+ create?: CreateHookFn<TReturn | null, TCreateReturn>;
113
+ update?: UpdateHookFn<TReturn | null, TReturn>;
114
+ };
115
+ type DotJoin<A extends string, B extends string> = A extends "" ? B : `${A}.${B}`;
116
+ type DottedPaths<T, Prefix extends string = ""> = string extends keyof T ? string : T extends readonly (infer E)[] ? E extends Record<string, unknown> ? { [K in keyof E & string]: `${Prefix}[${number}].${K}` | DottedPaths<NonNullable<E[K]>, `${Prefix}[${number}].${K}`>; }[keyof E & string] : never : T extends Record<string, unknown> ? { [K in keyof T & string]: DotJoin<Prefix, K> | DottedPaths<NonNullable<T[K]>, DotJoin<Prefix, K>>; }[keyof T & string] : never;
117
+ type TypeValidateFn<F extends Record<string, TailorAnyDBField>, TData = { [K in keyof F]: output<F[K]>; }> = (args: {
118
+ newRecord: DeepReadonly<TData>;
119
+ oldRecord: DeepReadonly<TData> | null;
120
+ invoker: TailorPrincipal | null;
121
+ }, issues: <P extends DottedPaths<Omit<TData, "id">>>(field: P, message: string) => void) => void;
122
+ type TypeCreateHookFn<F extends Record<string, TailorAnyDBField>, TData = { [K in keyof F]: output<F[K]>; }> = (args: {
123
+ input: DeepReadonly<TData>;
124
+ invoker: TailorPrincipal | null;
125
+ now: Date;
126
+ }) => { [K in Exclude<keyof TData & string, "id">]?: TData[K] | null; };
127
+ type TypeUpdateHookFn<F extends Record<string, TailorAnyDBField>, TData = { [K in keyof F]: output<F[K]>; }> = (args: {
128
+ input: HookArgs<TData>;
129
+ oldRecord: DeepReadonly<TData>;
130
+ invoker: TailorPrincipal | null;
131
+ now: Date;
132
+ }) => { [K in Exclude<keyof TData & string, "id">]?: TData[K] | null; };
133
+ type TypeHook<F extends Record<string, TailorAnyDBField>> = {
134
+ create?: TypeCreateHookFn<F>;
135
+ update?: TypeUpdateHookFn<F>;
102
136
  };
103
- type Hooks<F extends Record<string, TailorAnyDBField>, TData = { [K in keyof F]: output<F[K]> }> = NonEmptyObject<{ [K in Exclude<keyof F, "id"> as F[K]["_defined"] extends {
104
- hooks: unknown;
105
- } ? never : F[K]["_defined"] extends {
106
- type: "nested";
107
- } ? never : K]?: Hook<TData, output<F[K]>> }>;
108
137
  type ExcludeNestedDBFields<T extends Record<string, TailorAnyDBField>> = { [K in keyof T]: T[K] extends TailorDBField<{
109
138
  type: "nested";
110
139
  array: boolean;
111
- }, any> ? never : T[K] };
140
+ }, any> ? never : T[K]; };
141
+ type ExcludeHookedDBFields<T extends Record<string, TailorAnyDBField>> = { [K in keyof T]: T[K] extends TailorDBField<{
142
+ type: TailorFieldType;
143
+ array: boolean;
144
+ hooks: {
145
+ create: true;
146
+ update: boolean;
147
+ };
148
+ }, any> ? never : T[K] extends TailorDBField<{
149
+ type: TailorFieldType;
150
+ array: boolean;
151
+ hooks: {
152
+ create: boolean;
153
+ update: true;
154
+ };
155
+ }, any> ? never : T[K]; };
156
+ type ExcludeDefaultedDBFields<T extends Record<string, TailorAnyDBField>> = { [K in keyof T]: T[K] extends TailorDBField<{
157
+ type: TailorFieldType;
158
+ array: boolean;
159
+ default: true;
160
+ }, any> ? never : T[K]; };
112
161
  interface TypeFeatures {
113
162
  pluralForm?: string;
114
163
  aggregation?: true;
@@ -146,4 +195,4 @@ type TailorDBServiceInput = {
146
195
  [namespace: string]: TailorDBServiceConfigInput | TailorDBExternalConfig;
147
196
  };
148
197
  //#endregion
149
- export { DBFieldMetadata, DefinedDBFieldMetadata, ExcludeNestedDBFields, GqlOperationsConfig, Hook, Hooks, IndexDef, PluginAttachment, RawRelationConfig, RelationType, SerialConfig, TailorAnyDBField, TailorAnyDBType, TailorDBExternalConfig, TailorDBField, TailorDBInstance, TailorDBServiceInput, TailorDBType, TailorDBTypeMetadata, TypeFeatures };
198
+ export { DBFieldMetadata, DefinedDBFieldMetadata, ExcludeDefaultedDBFields, ExcludeHookedDBFields, ExcludeNestedDBFields, GqlOperationsConfig, Hook, IndexDef, PluginAttachment, RawRelationConfig, RelationType, SerialConfig, TailorAnyDBField, TailorAnyDBType, TailorDBExternalConfig, TailorDBField, TailorDBInstance, TailorDBServiceInput, TailorDBType, TailorDBTypeMetadata, TypeFeatures, TypeHook, TypeValidateFn };
@@ -0,0 +1,70 @@
1
+ import { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExactInstance, ExecutionPolicyGroupOptions, ExecutionPolicyInstance, ExecutionPolicyWildcardInstance, ResolvedExecutionPolicyInstance } from "./execution-policy.types.mjs";
2
+ //#region src/configure/services/workflow/execution-policy.d.ts
3
+ type ResolveKey<Def, Fallback extends string> = Def extends {
4
+ key: infer K extends string;
5
+ } ? K : Fallback;
6
+ type ResolveMatchType<Def> = Def extends {
7
+ matchType: infer M extends "exact" | "prefix";
8
+ } ? M : "exact";
9
+ /**
10
+ * Define a single workflow job function execution policy.
11
+ *
12
+ * Use this when declaring a policy outside the
13
+ * {@link defineWorkflowExecutionPolicies} builder — for example, when the
14
+ * runtime key prefix needs to differ from the corresponding workspace-unique
15
+ * name.
16
+ *
17
+ * When `matchType: "prefix"` is set, the returned instance has `keyFor(suffix)`
18
+ * instead of a directly-usable `key` (see {@link ExecutionPolicyWildcardInstance}).
19
+ * @param name - Workspace-unique name. Must match `^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$`.
20
+ * @param def - Optional overrides for `key` (defaults to `name`), `matchType`, `separator` (the `keyFor` join character, defaults to `.`), and concurrency
21
+ * @returns An execution policy instance
22
+ * @example
23
+ * export const perTenant = defineWorkflowExecutionPolicy("tenant-api", {
24
+ * matchType: "prefix",
25
+ * concurrencyPolicy: { maxConcurrentExecutions: 3 },
26
+ * });
27
+ *
28
+ * perTenant.keyFor(tenantId); // "tenant-api.<tenantId>"
29
+ */
30
+ declare function defineWorkflowExecutionPolicy<const N extends string, const D extends (Omit<ExecutionPolicyDefInput, "name"> & {
31
+ separator?: string;
32
+ }) | undefined = undefined>(name: N, def?: D): ResolvedExecutionPolicyInstance<ResolveKey<D, N>, ResolveMatchType<D>>;
33
+ /**
34
+ * Define a group of workflow job function execution policies. Property names
35
+ * become the workspace-unique `name` and default `key` verbatim, matching the
36
+ * mental model of {@link defineWaitPoints}. Provide `name` / `key` explicitly
37
+ * to override the property-name default (for example, when the property name
38
+ * is not valid for the execution policy grammar or when the runtime key
39
+ * prefix needs to differ).
40
+ *
41
+ * When `matchType: "prefix"` is set, the returned instance has `keyFor(suffix)`
42
+ * instead of a directly-usable `key` (see {@link ExecutionPolicyWildcardInstance}).
43
+ * `matchType` can be combined with an explicit `key`, or left to apply to
44
+ * the property-name-derived prefix.
45
+ *
46
+ * The return type mirrors the builder's return type so JSDoc on each property
47
+ * is preserved in IDE autocompletion.
48
+ * @param builder - Callback that receives a `define` factory and returns a record of policies
49
+ * @param options - Group-wide options; `separator` overrides the `.` `keyFor` uses to join the prefix and suffix for every prefix policy in the group
50
+ * @returns The same object returned by the builder (with `name` / `key` resolved on each instance)
51
+ * @example
52
+ * export const executionPolicies = defineWorkflowExecutionPolicies((define) => ({
53
+ * premium: define({ concurrencyPolicy: { maxConcurrentExecutions: 5 } }),
54
+ * "tenant-api": define({
55
+ * matchType: "prefix",
56
+ * concurrencyPolicy: { maxConcurrentExecutions: 3 },
57
+ * }),
58
+ * }));
59
+ *
60
+ * // In a workflow job function:
61
+ * await tailor.workflow.triggerJobFunction("worker", args, {
62
+ * executionPolicyKey: executionPolicies.premium.key,
63
+ * });
64
+ * await tailor.workflow.triggerJobFunction("worker", args, {
65
+ * executionPolicyKey: executionPolicies["tenant-api"].keyFor(input.tenantId),
66
+ * });
67
+ */
68
+ declare function defineWorkflowExecutionPolicies<T extends Record<string, ExecutionPolicyInstance>>(builder: (define: <const D extends ExecutionPolicyDefInput | undefined = undefined>(def?: D) => ResolvedExecutionPolicyInstance<ResolveKey<D, string>, ResolveMatchType<D>>) => T, options?: ExecutionPolicyGroupOptions): T;
69
+ //#endregion
70
+ export { type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ResolvedExecutionPolicyInstance, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy };
@@ -0,0 +1,103 @@
1
+ import { ExecutionPolicyKey } from "../../../runtime/workflow.mjs";
2
+ //#region src/configure/services/workflow/execution-policy.types.d.ts
3
+ /**
4
+ * Optional per-key concurrency cap applied to job function dispatches that
5
+ * resolve to a policy's `executionPolicyKey`.
6
+ */
7
+ interface ExecutionPolicyConcurrency {
8
+ /** Maximum number of concurrent executions allowed per resolved key. */
9
+ maxConcurrentExecutions: number;
10
+ }
11
+ /** Fields shared by both {@link ExecutionPolicyExactInstance} and {@link ExecutionPolicyWildcardInstance}. */
12
+ interface ExecutionPolicyBase {
13
+ /** Workspace-unique name for this policy. */
14
+ readonly name: string;
15
+ /** Optional per-key concurrency cap. */
16
+ readonly concurrencyPolicy?: ExecutionPolicyConcurrency;
17
+ }
18
+ /**
19
+ * An execution policy declared with `matchType: "exact"` (the default).
20
+ * `key` is branded as {@link ExecutionPolicyKey}, so it can be passed
21
+ * directly as the `executionPolicyKey` option.
22
+ */
23
+ interface ExecutionPolicyExactInstance<Key extends string = string> extends ExecutionPolicyBase {
24
+ /** Declared key; the platform registers it verbatim. */
25
+ readonly key: Key & ExecutionPolicyKey;
26
+ readonly matchType: "exact";
27
+ }
28
+ /**
29
+ * An execution policy declared with `matchType: "prefix"`. The platform
30
+ * registers the declared key prefix with a trailing `*`, and matches every
31
+ * dispatch whose runtime key begins with that prefix. There is no
32
+ * directly-usable `key` — use `keyFor` to build a concrete, branded runtime
33
+ * key at the call site instead of hand-concatenating the prefix and a
34
+ * suffix.
35
+ */
36
+ interface ExecutionPolicyWildcardInstance extends ExecutionPolicyBase {
37
+ readonly matchType: "prefix";
38
+ /**
39
+ * Build a concrete runtime key by appending `suffix` after this policy's
40
+ * declared key prefix, separated by `.` unless a different separator was
41
+ * configured where this policy was declared.
42
+ * @param suffix - Value appended after the wildcard prefix
43
+ * @returns The concrete key to pass as `executionPolicyKey`
44
+ * @throws If the resulting key does not match the execution policy key
45
+ * grammar (for example, an empty `suffix`)
46
+ * @example
47
+ * // key: "tenant-api", matchType: "prefix"
48
+ * tenantApi.keyFor(tenantId); // "tenant-api.<tenantId>"
49
+ */
50
+ keyFor(suffix: string): ExecutionPolicyKey;
51
+ }
52
+ /**
53
+ * A declared workflow job function execution policy — either
54
+ * {@link ExecutionPolicyExactInstance} or {@link ExecutionPolicyWildcardInstance}.
55
+ */
56
+ type ExecutionPolicyInstance<Key extends string = string> = ExecutionPolicyExactInstance<Key> | ExecutionPolicyWildcardInstance;
57
+ /**
58
+ * Resolves to {@link ExecutionPolicyWildcardInstance} when `MatchType` is
59
+ * known at the type level to be `"prefix"`, to {@link ExecutionPolicyExactInstance}
60
+ * when it's known to be `"exact"`, or to their union when `MatchType` is the
61
+ * unnarrowed `"exact" | "prefix"` (e.g. a caller passed a non-literal
62
+ * `matchType`) — narrowing to one branch in that case would claim a `key` or
63
+ * `keyFor` that may not exist on the actual runtime instance.
64
+ */
65
+ type ResolvedExecutionPolicyInstance<Key extends string, MatchType extends "exact" | "prefix"> = "exact" | "prefix" extends MatchType ? ExecutionPolicyExactInstance<Key> | ExecutionPolicyWildcardInstance : MatchType extends "prefix" ? ExecutionPolicyWildcardInstance : ExecutionPolicyExactInstance<Key>;
66
+ /**
67
+ * Body of an execution policy declaration.
68
+ *
69
+ * When both `name` and `key` are omitted in the `defineWorkflowExecutionPolicies`
70
+ * builder, the property name is used verbatim for both (like
71
+ * `defineWaitPoints`). Provide `name` when the property identifier is not
72
+ * valid execution policy grammar, and provide `key` when the runtime key
73
+ * prefix needs to differ from `name` (e.g. it needs `:` or `.`).
74
+ */
75
+ interface ExecutionPolicyDefInput {
76
+ /** Overrides the property-name-derived `name`. 3-63 characters from `[a-z0-9-]`; must start and end with `[a-z0-9]`. */
77
+ name?: string;
78
+ /** Overrides the property-name-derived `key` prefix. Independent of `matchType` — both may be set together. */
79
+ key?: string;
80
+ /**
81
+ * `"exact"` (the default) matches a dispatch whose runtime key equals
82
+ * `key` (or the resolved `name`, if `key` is omitted). `"prefix"`
83
+ * registers `key` as a wildcard prefix — the platform appends a trailing
84
+ * `*`, and the resulting instance exposes `keyFor(suffix)` to build
85
+ * concrete dispatch keys instead of a directly-usable `key`.
86
+ */
87
+ matchType?: "exact" | "prefix";
88
+ /** Optional per-key concurrency cap. */
89
+ concurrencyPolicy?: ExecutionPolicyConcurrency;
90
+ }
91
+ /**
92
+ * Options for {@link defineWorkflowExecutionPolicies}, applying to every
93
+ * policy declared by the builder (not settable per policy).
94
+ */
95
+ interface ExecutionPolicyGroupOptions {
96
+ /**
97
+ * Separator `keyFor(suffix)` inserts between a wildcard policy's declared
98
+ * `key` prefix and `suffix`. Defaults to `.`.
99
+ */
100
+ separator?: string;
101
+ }
102
+ //#endregion
103
+ export { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExactInstance, ExecutionPolicyGroupOptions, ExecutionPolicyInstance, ExecutionPolicyWildcardInstance, ResolvedExecutionPolicyInstance };
@@ -1,6 +1,9 @@
1
+ import { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExactInstance, ExecutionPolicyGroupOptions, ExecutionPolicyInstance, ExecutionPolicyWildcardInstance, ResolvedExecutionPolicyInstance } from "./execution-policy.types.mjs";
1
2
  import { WorkflowServiceConfig, WorkflowServiceInput } from "../../config/types.mjs";
2
3
  import { ConcurrencyPolicy, RetryPolicy } from "../../../types/workflow.generated.mjs";
3
4
  import { WorkflowJob, WorkflowJobContext, createWorkflowJob } from "./job.mjs";
4
5
  import { Workflow, WorkflowConfig, createWorkflow } from "./workflow.mjs";
6
+ import { defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy } from "./execution-policy.mjs";
5
7
  import { WaitPointInstance, createWaitPoint, createWaitPoints } from "./wait-point.mjs";
6
- export { type ConcurrencyPolicy, type RetryPolicy, WaitPointInstance, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, type WorkflowServiceConfig, type WorkflowServiceInput, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob };
8
+ import "./types.mjs";
9
+ export { type ConcurrencyPolicy, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ResolvedExecutionPolicyInstance, type RetryPolicy, WaitPointInstance, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, type WorkflowServiceConfig, type WorkflowServiceInput, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy };