@tailor-platform/sdk 2.0.0-next.1 → 2.0.0-next.11

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 (478) hide show
  1. package/CHANGELOG.md +1056 -24
  2. package/README.md +9 -9
  3. package/agent-skills/{tailor-sdk → tailor}/SKILL.md +3 -1
  4. package/dist/aigateway-DR4Kwuik.mjs +9 -0
  5. package/dist/aigateway-DR4Kwuik.mjs.map +1 -0
  6. package/dist/{application-DqS1yBg3.mjs → application-CM6hKnSK.mjs} +2155 -2008
  7. package/dist/application-CM6hKnSK.mjs.map +1 -0
  8. package/dist/application-CXNaUNhv.mjs +3 -0
  9. package/dist/authconnection-CZvi9ANm.mjs +9 -0
  10. package/dist/authconnection-CZvi9ANm.mjs.map +1 -0
  11. package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
  12. package/dist/cli/cache/bundle-cache.d.mts +2 -0
  13. package/dist/cli/cache/store.d.mts +1 -0
  14. package/dist/cli/cache/types.d.mts +1 -0
  15. package/dist/cli/commands/api/api-call.d.mts +19 -0
  16. package/dist/cli/commands/api/index.d.mts +4 -0
  17. package/dist/cli/commands/deploy/aigateway.d.mts +5 -0
  18. package/dist/cli/commands/deploy/application.d.mts +7 -0
  19. package/dist/cli/commands/deploy/apply-phases.d.mts +14 -0
  20. package/dist/cli/commands/deploy/auth.d.mts +5 -0
  21. package/dist/cli/commands/deploy/deploy.d.mts +35 -0
  22. package/dist/cli/commands/deploy/executor.d.mts +7 -0
  23. package/dist/cli/commands/deploy/function-registry-types.d.mts +12 -0
  24. package/dist/cli/commands/deploy/function-registry.d.mts +6 -0
  25. package/dist/cli/commands/deploy/idp.d.mts +5 -0
  26. package/dist/cli/commands/deploy/label.d.mts +2 -0
  27. package/dist/cli/commands/deploy/resolver.d.mts +5 -0
  28. package/dist/cli/commands/deploy/secret-manager.d.mts +5 -0
  29. package/dist/cli/commands/deploy/staticwebsite.d.mts +5 -0
  30. package/dist/cli/commands/deploy/tailordb/index.d.mts +10 -0
  31. package/dist/cli/commands/deploy/types.d.mts +4 -0
  32. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +2 -0
  33. package/dist/cli/commands/deploy/workflow.d.mts +4 -0
  34. package/dist/cli/commands/executor/get.d.mts +19 -0
  35. package/dist/cli/commands/executor/jobs.d.mts +85 -0
  36. package/dist/cli/commands/executor/list.d.mts +18 -0
  37. package/dist/cli/commands/executor/transform.d.mts +42 -0
  38. package/dist/cli/commands/executor/trigger.d.mts +30 -0
  39. package/dist/cli/commands/executor/webhook.d.mts +21 -0
  40. package/dist/cli/commands/function/get.d.mts +17 -0
  41. package/dist/cli/commands/function/list.d.mts +21 -0
  42. package/dist/cli/commands/function/transform.d.mts +12 -0
  43. package/dist/cli/commands/generate/options.d.mts +6 -0
  44. package/dist/cli/commands/generate/seed/bundler.d.mts +27 -0
  45. package/dist/cli/commands/generate/service.d.mts +15 -0
  46. package/dist/cli/commands/machineuser/list.d.mts +26 -0
  47. package/dist/cli/commands/machineuser/token.d.mts +21 -0
  48. package/dist/cli/commands/oauth2client/get.d.mts +17 -0
  49. package/dist/cli/commands/oauth2client/list.d.mts +19 -0
  50. package/dist/cli/commands/oauth2client/transform.d.mts +21 -0
  51. package/dist/cli/commands/organization/folder/create.d.mts +17 -0
  52. package/dist/cli/commands/organization/folder/delete.d.mts +15 -0
  53. package/dist/cli/commands/organization/folder/get.d.mts +16 -0
  54. package/dist/cli/commands/organization/folder/list.d.mts +21 -0
  55. package/dist/cli/commands/organization/folder/update.d.mts +17 -0
  56. package/dist/cli/commands/organization/get.d.mts +15 -0
  57. package/dist/cli/commands/organization/list.d.mts +14 -0
  58. package/dist/cli/commands/organization/transform.d.mts +29 -0
  59. package/dist/cli/commands/organization/tree.d.mts +24 -0
  60. package/dist/cli/commands/organization/update.d.mts +16 -0
  61. package/dist/cli/commands/remove.d.mts +15 -0
  62. package/dist/cli/commands/show.d.mts +39 -0
  63. package/dist/cli/commands/staticwebsite/deploy.d.mts +19 -0
  64. package/dist/cli/commands/tailordb/migrate/bundler.d.mts +29 -0
  65. package/dist/cli/commands/tailordb/migrate/config.d.mts +18 -0
  66. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +246 -0
  67. package/dist/cli/commands/tailordb/migrate/generate.d.mts +16 -0
  68. package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
  69. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +208 -0
  70. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +98 -0
  71. package/dist/cli/commands/tailordb/migrate/types.d.mts +7 -0
  72. package/dist/cli/commands/tailordb/truncate.d.mts +18 -0
  73. package/dist/cli/commands/workflow/executions.d.mts +62 -0
  74. package/dist/cli/commands/workflow/get.d.mts +21 -0
  75. package/dist/cli/commands/workflow/list.d.mts +18 -0
  76. package/dist/cli/commands/workflow/resume.d.mts +22 -0
  77. package/dist/cli/commands/workflow/start.d.mts +48 -0
  78. package/dist/cli/commands/workflow/status.d.mts +6 -0
  79. package/dist/cli/commands/workflow/transform.d.mts +34 -0
  80. package/dist/cli/commands/workflow/wait.d.mts +15 -0
  81. package/dist/cli/commands/workflow/waiter.d.mts +23 -0
  82. package/dist/cli/commands/workspace/app/health.d.mts +17 -0
  83. package/dist/cli/commands/workspace/app/list.d.mts +21 -0
  84. package/dist/cli/commands/workspace/app/transform.d.mts +20 -0
  85. package/dist/cli/commands/workspace/create.d.mts +27 -0
  86. package/dist/cli/commands/workspace/delete.d.mts +14 -0
  87. package/dist/cli/commands/workspace/get.d.mts +16 -0
  88. package/dist/cli/commands/workspace/list.d.mts +17 -0
  89. package/dist/cli/commands/workspace/restore.d.mts +14 -0
  90. package/dist/cli/commands/workspace/transform.d.mts +20 -0
  91. package/dist/cli/commands/workspace/user/invite.d.mts +21 -0
  92. package/dist/cli/commands/workspace/user/list.d.mts +21 -0
  93. package/dist/cli/commands/workspace/user/remove.d.mts +16 -0
  94. package/dist/cli/commands/workspace/user/transform.d.mts +9 -0
  95. package/dist/cli/commands/workspace/user/update.d.mts +21 -0
  96. package/dist/cli/index.mjs +12 -5481
  97. package/dist/cli/lib.d.mts +86 -21048
  98. package/dist/cli/lib.mjs +245 -46
  99. package/dist/cli/lib.mjs.map +1 -1
  100. package/dist/cli/main.d.mts +23 -0
  101. package/dist/cli/main.mjs +6777 -0
  102. package/dist/cli/main.mjs.map +1 -0
  103. package/dist/cli/query/index.d.mts +38 -0
  104. package/dist/cli/services/application.d.mts +12 -0
  105. package/dist/cli/services/auth/service.d.mts +3 -0
  106. package/dist/cli/services/executor/service.d.mts +1 -0
  107. package/dist/cli/services/http-adapter/bundler.d.mts +4 -0
  108. package/dist/cli/services/http-adapter/service.d.mts +2 -0
  109. package/dist/cli/services/resolver/service.d.mts +1 -0
  110. package/dist/cli/services/tailordb/service.d.mts +3 -0
  111. package/dist/cli/services/workflow/bundler.d.mts +3 -0
  112. package/dist/cli/services/workflow/service.d.mts +1 -0
  113. package/dist/cli/shared/args.d.mts +13 -0
  114. package/dist/cli/shared/client.d.mts +1298 -0
  115. package/dist/cli/shared/config-loader.d.mts +32 -0
  116. package/dist/cli/shared/context.d.mts +29 -0
  117. package/dist/cli/shared/error-json.d.mts +23 -0
  118. package/dist/cli/shared/readonly-guard.d.mts +25 -0
  119. package/dist/cli/shared/script-executor.d.mts +77 -0
  120. package/dist/cli/shared/seed-chunker.d.mts +45 -0
  121. package/dist/cli/shared/seed-context.d.mts +49 -0
  122. package/dist/cli/shared/tailordb-namespaces.d.mts +40 -0
  123. package/dist/cli/shared/tsconfig-paths-plugin.d.mts +2 -0
  124. package/dist/cli/shared/type-generator.d.mts +20 -0
  125. package/dist/cli/shared/workspace-name.d.mts +1 -0
  126. package/dist/cli/ts-hook.d.mts +4 -0
  127. package/dist/cli/ts-hook.mjs +333 -0
  128. package/dist/completion/zsh-worker.zsh +1471 -1217
  129. package/dist/configure/config/index.d.mts +20 -0
  130. package/dist/configure/config/types.d.mts +134 -0
  131. package/dist/configure/index.d.mts +135 -8
  132. package/dist/configure/index.mjs +558 -36
  133. package/dist/configure/index.mjs.map +1 -1
  134. package/dist/configure/services/aigateway/index.d.mts +16 -0
  135. package/dist/configure/services/aigateway/types.d.mts +10 -0
  136. package/dist/configure/services/auth/index.d.mts +33 -0
  137. package/dist/configure/services/auth/types.d.mts +168 -0
  138. package/dist/configure/services/executor/executor.d.mts +70 -0
  139. package/dist/configure/services/executor/index.d.mts +9 -0
  140. package/dist/configure/services/executor/operation.d.mts +50 -0
  141. package/dist/configure/services/executor/trigger/event.d.mts +514 -0
  142. package/dist/configure/services/executor/trigger/index.d.mts +7 -0
  143. package/dist/configure/services/executor/trigger/schedule.d.mts +24 -0
  144. package/dist/configure/services/executor/trigger/webhook.d.mts +43 -0
  145. package/dist/configure/services/executor/types.d.mts +2 -0
  146. package/dist/configure/services/http-adapter/http-adapter.d.mts +124 -0
  147. package/dist/configure/services/http-adapter/index.d.mts +2 -0
  148. package/dist/configure/services/idp/index.d.mts +60 -0
  149. package/dist/configure/services/idp/permission.d.mts +64 -0
  150. package/dist/configure/services/idp/types.d.mts +23 -0
  151. package/dist/configure/services/index.d.mts +40 -0
  152. package/dist/configure/services/resolver/index.d.mts +6 -0
  153. package/dist/configure/services/resolver/permission.d.mts +64 -0
  154. package/dist/configure/services/resolver/resolver.d.mts +88 -0
  155. package/dist/configure/services/resolver/types.d.mts +5 -0
  156. package/dist/configure/services/secrets/index.d.mts +37 -0
  157. package/dist/configure/services/secrets/types.d.mts +10 -0
  158. package/dist/configure/services/staticwebsite/index.d.mts +18 -0
  159. package/dist/configure/services/staticwebsite/types.d.mts +10 -0
  160. package/dist/configure/services/tailordb/index.d.mts +3 -0
  161. package/dist/configure/services/tailordb/permission.d.mts +103 -0
  162. package/dist/configure/services/tailordb/schema.d.mts +486 -0
  163. package/dist/configure/services/tailordb/types.d.mts +198 -0
  164. package/dist/configure/services/workflow/execution-policy.d.mts +70 -0
  165. package/dist/configure/services/workflow/execution-policy.types.d.mts +103 -0
  166. package/dist/configure/services/workflow/index.d.mts +9 -0
  167. package/dist/configure/services/workflow/job.d.mts +92 -0
  168. package/dist/configure/services/workflow/types.d.mts +2 -0
  169. package/dist/configure/services/workflow/wait-point.d.mts +72 -0
  170. package/dist/configure/services/workflow/workflow.d.mts +66 -0
  171. package/dist/configure/types/aigateway-name.d.mts +12 -0
  172. package/dist/configure/types/connection-name.d.mts +12 -0
  173. package/dist/configure/types/field.d.mts +8 -0
  174. package/dist/configure/types/field.types.d.mts +70 -0
  175. package/dist/configure/types/idp-name.d.mts +12 -0
  176. package/dist/configure/types/index.d.mts +5 -0
  177. package/dist/configure/types/machine-user.d.mts +2 -0
  178. package/dist/configure/types/permission-operand.types.d.mts +20 -0
  179. package/dist/configure/types/type.d.mts +73 -0
  180. package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
  181. package/dist/context-DYQVYWqZ.mjs.map +1 -0
  182. package/dist/{crashreport-BsjAkFWw.mjs → crashreport-B5LqCTfF.mjs} +10 -11
  183. package/dist/{crashreport-BsjAkFWw.mjs.map → crashreport-B5LqCTfF.mjs.map} +1 -1
  184. package/dist/{crashreport-pr6Rhvza.mjs → crashreport-eI7ty7ok.mjs} +1 -1
  185. package/dist/{errors-Dtf2WPaW.mjs → errors-D7583Zz7.mjs} +18 -2
  186. package/dist/errors-D7583Zz7.mjs.map +1 -0
  187. package/dist/{file-_oUZo76X.mjs → file-BUcmVIH2.mjs} +12 -22
  188. package/dist/file-BUcmVIH2.mjs.map +1 -0
  189. package/dist/{globals-Crz8o65k.mjs → globals-TfAVItuK.mjs} +32 -55
  190. package/dist/globals-TfAVItuK.mjs.map +1 -0
  191. package/dist/iconv-QWaZh0TT.mjs +38 -0
  192. package/dist/iconv-QWaZh0TT.mjs.map +1 -0
  193. package/dist/{idp-BDbK5gjm.mjs → idp-RA_swu-h.mjs} +12 -5
  194. package/dist/idp-RA_swu-h.mjs.map +1 -0
  195. package/dist/{interceptor-D-q1rvRl.mjs → interceptor-e33JtsC-.mjs} +2 -2
  196. package/dist/interceptor-e33JtsC-.mjs.map +1 -0
  197. package/dist/kysely/index.d.mts +5 -7
  198. package/dist/logger-BtX0suGY.mjs +48 -0
  199. package/dist/logger-BtX0suGY.mjs.map +1 -0
  200. package/dist/logger-CXQq9YIp.mjs +317 -0
  201. package/dist/logger-CXQq9YIp.mjs.map +1 -0
  202. package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
  203. package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
  204. package/dist/parser/service/auth/index.d.mts +1 -0
  205. package/dist/parser/service/auth/schema.d.mts +3 -0
  206. package/dist/parser/service/http-adapter/index.d.mts +1 -0
  207. package/dist/parser/service/http-adapter/schema.d.mts +1 -0
  208. package/dist/parser/service/idp/types.d.mts +5 -0
  209. package/dist/parser/service/tailordb/type-source.d.mts +10 -0
  210. package/dist/parser/service/tailordb/types.d.mts +131 -0
  211. package/dist/platform-serialize-RoRtBS0v.mjs +46 -0
  212. package/dist/platform-serialize-RoRtBS0v.mjs.map +1 -0
  213. package/dist/plugin/builtin/enum-constants/index.d.mts +15 -1
  214. package/dist/plugin/builtin/enum-constants/index.mjs +115 -2
  215. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -0
  216. package/dist/plugin/builtin/file-utils/index.d.mts +15 -1
  217. package/dist/plugin/builtin/file-utils/index.mjs +149 -2
  218. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -0
  219. package/dist/plugin/builtin/kysely-type/index.d.mts +15 -1
  220. package/dist/plugin/builtin/kysely-type/index.mjs +274 -2
  221. package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -0
  222. package/dist/plugin/builtin/seed/index.d.mts +46 -2
  223. package/dist/plugin/builtin/seed/index.mjs +1 -1
  224. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +21 -0
  225. package/dist/plugin/builtin/seed/types.d.mts +2 -0
  226. package/dist/plugin/get-generated-type.d.mts +16 -0
  227. package/dist/plugin/index.d.mts +3 -117
  228. package/dist/plugin/index.mjs +1 -1
  229. package/dist/plugin/index.mjs.map +1 -1
  230. package/dist/plugin/manager.d.mts +2 -0
  231. package/dist/plugin/types.d.mts +242 -0
  232. package/dist/plugin/with-context.d.mts +101 -0
  233. package/dist/{runtime-n9NCkjee.mjs → register-ts-hook-LYV7zH-e.mjs} +9652 -4479
  234. package/dist/register-ts-hook-LYV7zH-e.mjs.map +1 -0
  235. package/dist/{registry-DdsYlL_P.mjs → registry-BIGVUrMB.mjs} +12 -9
  236. package/dist/registry-BIGVUrMB.mjs.map +1 -0
  237. package/dist/{repl-editor-DmGr9zMw.mjs → repl-editor-BCozyiNq.mjs} +6 -5
  238. package/dist/{repl-editor-DmGr9zMw.mjs.map → repl-editor-BCozyiNq.mjs.map} +1 -1
  239. package/dist/runtime/aigateway.d.mts +25 -0
  240. package/dist/runtime/aigateway.mjs +3 -0
  241. package/dist/runtime/authconnection.d.mts +21 -2
  242. package/dist/runtime/authconnection.mjs +2 -2
  243. package/dist/runtime/context.d.mts +54 -2
  244. package/dist/runtime/context.mjs +2 -2
  245. package/dist/runtime/field-parse.d.mts +10 -0
  246. package/dist/runtime/file.d.mts +170 -2
  247. package/dist/runtime/file.mjs +2 -2
  248. package/dist/runtime/globals.d.mts +38 -20
  249. package/dist/runtime/iconv.d.mts +73 -2
  250. package/dist/runtime/iconv.mjs +2 -2
  251. package/dist/runtime/idp.d.mts +129 -2
  252. package/dist/runtime/idp.mjs +2 -2
  253. package/dist/runtime/index.d.mts +48 -9
  254. package/dist/runtime/index.mjs +10 -8
  255. package/dist/runtime/logger.d.mts +98 -0
  256. package/dist/runtime/logger.mjs +3 -0
  257. package/dist/runtime/secretmanager.d.mts +41 -2
  258. package/dist/runtime/secretmanager.mjs +2 -2
  259. package/dist/runtime/types.d.mts +25 -0
  260. package/dist/runtime/workflow.d.mts +106 -2
  261. package/dist/runtime/workflow.mjs +2 -2
  262. package/dist/{schema-BhkpP5Hw.mjs → schema--xYWRGfe.mjs} +288 -229
  263. package/dist/schema--xYWRGfe.mjs.map +1 -0
  264. package/dist/{secret-file-DBqZhjFQ.mjs → secret-file-C3J4Gy8r.mjs} +2 -2
  265. package/dist/{secret-file-DBqZhjFQ.mjs.map → secret-file-C3J4Gy8r.mjs.map} +1 -1
  266. package/dist/secretmanager-CYlpffsz.mjs +13 -0
  267. package/dist/secretmanager-CYlpffsz.mjs.map +1 -0
  268. package/dist/secretmanager-IY4UvinW.mjs +131 -0
  269. package/dist/secretmanager-IY4UvinW.mjs.map +1 -0
  270. package/dist/seed/index.d.mts +4 -4
  271. package/dist/seed-B-yckgQY.mjs +483 -0
  272. package/dist/seed-B-yckgQY.mjs.map +1 -0
  273. package/dist/{service-DU1mVzri.mjs → service-B5WynBHQ.mjs} +3 -3
  274. package/dist/{service-DU1mVzri.mjs.map → service-B5WynBHQ.mjs.map} +1 -1
  275. package/dist/service-M7OYziQP.mjs +3 -0
  276. package/dist/service-k1xy_A5G.mjs +864 -0
  277. package/dist/service-k1xy_A5G.mjs.map +1 -0
  278. package/dist/service_pb-D5--My_M.mjs +167 -0
  279. package/dist/service_pb-D5--My_M.mjs.map +1 -0
  280. package/dist/service_pb-i8CmnQP4.mjs +3 -0
  281. package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +203 -0
  282. package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +57 -0
  283. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +420 -0
  284. package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +160 -0
  285. package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +2069 -0
  286. package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +865 -0
  287. package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +111 -0
  288. package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +68 -0
  289. package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +438 -0
  290. package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +586 -0
  291. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +192 -0
  292. package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +450 -0
  293. package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +191 -0
  294. package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +49 -0
  295. package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +406 -0
  296. package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +429 -0
  297. package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +72 -0
  298. package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +16 -0
  299. package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +308 -0
  300. package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +590 -0
  301. package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +329 -0
  302. package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +112 -0
  303. package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +345 -0
  304. package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +53 -0
  305. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +3658 -0
  306. package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +186 -0
  307. package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +28 -0
  308. package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +428 -0
  309. package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +89 -0
  310. package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +683 -0
  311. package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +796 -0
  312. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +329 -0
  313. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +207 -0
  314. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +961 -0
  315. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +330 -0
  316. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +2014 -0
  317. package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +482 -0
  318. package/dist/{telemetry-CdqJEzkj.mjs → telemetry-BRVdwh14.mjs} +3 -3
  319. package/dist/telemetry-BRVdwh14.mjs.map +1 -0
  320. package/dist/telemetry-CkbkeJxl.mjs +3 -0
  321. package/dist/test-env-key-D7UkZp99.mjs +75 -0
  322. package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
  323. package/dist/types/aigateway.generated.d.mts +12 -0
  324. package/dist/types/app-config.generated.d.mts +4 -0
  325. package/dist/types/auth-connection.generated.d.mts +33 -0
  326. package/dist/types/auth.generated.d.mts +188 -0
  327. package/dist/types/executor.generated.d.mts +229 -0
  328. package/dist/types/helpers.d.mts +40 -0
  329. package/dist/types/http-adapter.generated.d.mts +28 -0
  330. package/dist/types/idp.generated.d.mts +626 -0
  331. package/dist/types/resolver.generated.d.mts +82 -0
  332. package/dist/types/secrets.generated.d.mts +14 -0
  333. package/dist/types/staticwebsite.generated.d.mts +14 -0
  334. package/dist/types/tailordb.generated.d.mts +468 -0
  335. package/dist/types/workflow.generated.d.mts +17 -0
  336. package/dist/user-agent-Bgsszb5I.mjs +28 -0
  337. package/dist/user-agent-Bgsszb5I.mjs.map +1 -0
  338. package/dist/utils/test/index.d.mts +5 -100
  339. package/dist/utils/test/index.mjs +38 -189
  340. package/dist/utils/test/index.mjs.map +1 -1
  341. package/dist/vitest/environment.d.mts +1 -2
  342. package/dist/vitest/environment.mjs +2 -2
  343. package/dist/vitest/environment.mjs.map +1 -1
  344. package/dist/vitest/index.d.mts +17 -431
  345. package/dist/vitest/index.mjs +1234 -67
  346. package/dist/vitest/index.mjs.map +1 -1
  347. package/dist/vitest/mock-kysely.d.mts +61 -0
  348. package/dist/vitest/mock.d.mts +10 -0
  349. package/dist/vitest/mocks/aigateway.d.mts +40 -0
  350. package/dist/vitest/mocks/authconnection.d.mts +38 -0
  351. package/dist/vitest/mocks/file.d.mts +58 -0
  352. package/dist/vitest/mocks/iconv.d.mts +51 -0
  353. package/dist/vitest/mocks/idp.d.mts +60 -0
  354. package/dist/vitest/mocks/logger.d.mts +45 -0
  355. package/dist/vitest/mocks/secretmanager.d.mts +44 -0
  356. package/dist/vitest/mocks/tailordb.d.mts +115 -0
  357. package/dist/vitest/mocks/workflow.d.mts +148 -0
  358. package/dist/vitest/setup.d.mts +1 -2
  359. package/dist/vitest/setup.mjs +2 -2
  360. package/dist/vitest/workflow-local.d.mts +41 -0
  361. package/dist/workflow-Bamae_Yc.mjs +34 -0
  362. package/dist/workflow-Bamae_Yc.mjs.map +1 -0
  363. package/dist/{client-z_oHGVNy.mjs → workspace_resource_pb-DXnO2AT-.mjs} +57 -621
  364. package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
  365. package/docs/cli/application.md +150 -250
  366. package/docs/cli/auth.md +51 -295
  367. package/docs/cli/completion.md +1 -25
  368. package/docs/cli/crashreport.md +3 -61
  369. package/docs/cli/executor.md +72 -183
  370. package/docs/cli/function.md +16 -132
  371. package/docs/cli/organization.md +11 -221
  372. package/docs/cli/plugin.md +29 -0
  373. package/docs/cli/query.md +2 -22
  374. package/docs/cli/secret.md +71 -251
  375. package/docs/cli/setup.md +138 -40
  376. package/docs/cli/skills.md +50 -39
  377. package/docs/cli/staticwebsite.md +32 -180
  378. package/docs/cli/tailordb.md +89 -413
  379. package/docs/cli/upgrade.md +2 -22
  380. package/docs/cli/user.md +78 -247
  381. package/docs/cli/workflow.md +150 -172
  382. package/docs/cli/workspace.md +167 -538
  383. package/docs/cli-reference.md +214 -96
  384. package/docs/configuration.md +90 -6
  385. package/docs/github-actions.md +72 -24
  386. package/docs/migration/v2.md +1613 -0
  387. package/docs/multi-environment.md +29 -7
  388. package/docs/plugin/custom.md +4 -4
  389. package/docs/plugin/index.md +8 -8
  390. package/docs/quickstart.md +8 -7
  391. package/docs/runtime.md +18 -9
  392. package/docs/services/aigateway.md +20 -2
  393. package/docs/services/auth.md +51 -59
  394. package/docs/services/executor.md +91 -6
  395. package/docs/services/http-adapter.md +16 -1
  396. package/docs/services/idp.md +62 -7
  397. package/docs/services/resolver.md +67 -11
  398. package/docs/services/secret.md +11 -11
  399. package/docs/services/staticwebsite.md +8 -2
  400. package/docs/services/tailordb-migration.md +55 -29
  401. package/docs/services/tailordb.md +205 -102
  402. package/docs/services/workflow.md +163 -55
  403. package/docs/testing.md +244 -143
  404. package/package.json +61 -46
  405. package/postinstall.mjs +4 -6
  406. package/dist/application-DB2r36Et.mjs +0 -3
  407. package/dist/application-DqS1yBg3.mjs.map +0 -1
  408. package/dist/authconnection-D2MhtTN5.mjs +0 -15
  409. package/dist/authconnection-D2MhtTN5.mjs.map +0 -1
  410. package/dist/authconnection-DvUQAjQS.d.mts +0 -39
  411. package/dist/cli/erd-viewer-assets/app.js +0 -1181
  412. package/dist/cli/erd-viewer-assets/index.html +0 -73
  413. package/dist/cli/erd-viewer-assets/serve.json +0 -13
  414. package/dist/cli/erd-viewer-assets/styles.css +0 -789
  415. package/dist/cli/index.d.mts +0 -5
  416. package/dist/cli/index.mjs.map +0 -1
  417. package/dist/client-Dbohmtkv.mjs +0 -3
  418. package/dist/client-z_oHGVNy.mjs.map +0 -1
  419. package/dist/context-Bd266-ru.mjs.map +0 -1
  420. package/dist/context-BuuIb8CC.d.mts +0 -68
  421. package/dist/enum-constants-j9QBF0cB.mjs +0 -116
  422. package/dist/enum-constants-j9QBF0cB.mjs.map +0 -1
  423. package/dist/errors-Dtf2WPaW.mjs.map +0 -1
  424. package/dist/field-DOsJCPFa.mjs +0 -22
  425. package/dist/field-DOsJCPFa.mjs.map +0 -1
  426. package/dist/file-BB8Vs9O_.d.mts +0 -250
  427. package/dist/file-_oUZo76X.mjs.map +0 -1
  428. package/dist/file-utils-DcyIPFQh.mjs +0 -150
  429. package/dist/file-utils-DcyIPFQh.mjs.map +0 -1
  430. package/dist/globals-Crz8o65k.mjs.map +0 -1
  431. package/dist/http-adapter.generated-WgMnb7Sb.d.mts +0 -580
  432. package/dist/iconv-Co-TOPuH.d.mts +0 -122
  433. package/dist/iconv-D2vi8G36.mjs +0 -63
  434. package/dist/iconv-D2vi8G36.mjs.map +0 -1
  435. package/dist/idp-BDbK5gjm.mjs.map +0 -1
  436. package/dist/idp-DrhVrLmV.d.mts +0 -160
  437. package/dist/index-5vPyRu1y.d.mts +0 -18
  438. package/dist/index-B7AKc18V.d.mts +0 -47
  439. package/dist/index-BlpzXncY.d.mts +0 -1016
  440. package/dist/index-CK7u9isy.d.mts +0 -46
  441. package/dist/index-CNYe5lnW.d.mts +0 -18
  442. package/dist/index-DjUdWlzf.d.mts +0 -18
  443. package/dist/index-ZePLwxw7.d.mts +0 -208
  444. package/dist/interceptor-D-q1rvRl.mjs.map +0 -1
  445. package/dist/job-fuc3j1Ma.mjs +0 -53
  446. package/dist/job-fuc3j1Ma.mjs.map +0 -1
  447. package/dist/kysely-type-DR8uzZTA.mjs +0 -274
  448. package/dist/kysely-type-DR8uzZTA.mjs.map +0 -1
  449. package/dist/logger-CxF-Ex5d.mjs +0 -220
  450. package/dist/logger-CxF-Ex5d.mjs.map +0 -1
  451. package/dist/mock-BjFj5o1I.mjs +0 -804
  452. package/dist/mock-BjFj5o1I.mjs.map +0 -1
  453. package/dist/registry-DdsYlL_P.mjs.map +0 -1
  454. package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
  455. package/dist/runtime-n9NCkjee.mjs.map +0 -1
  456. package/dist/schema-BhkpP5Hw.mjs.map +0 -1
  457. package/dist/secretmanager-B3n4KHfm.d.mts +0 -55
  458. package/dist/secretmanager-BVxw3ih_.mjs +0 -24
  459. package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
  460. package/dist/seed-jf3008-h.mjs +0 -1160
  461. package/dist/seed-jf3008-h.mjs.map +0 -1
  462. package/dist/service-CCL8ruDf.mjs +0 -459
  463. package/dist/service-CCL8ruDf.mjs.map +0 -1
  464. package/dist/service-D6yonf2I.mjs +0 -3
  465. package/dist/telemetry-CdqJEzkj.mjs.map +0 -1
  466. package/dist/telemetry-ClwW5ohF.mjs +0 -3
  467. package/dist/test-env-key-D9kM6ETE.mjs +0 -49
  468. package/dist/test-env-key-D9kM6ETE.mjs.map +0 -1
  469. package/dist/types-B2RpYyA_.mjs +0 -371
  470. package/dist/types-B2RpYyA_.mjs.map +0 -1
  471. package/dist/types-ClhIrW_C.mjs +0 -4
  472. package/dist/types-DCUhgpyI.d.mts +0 -784
  473. package/dist/types-DhO_VEZd.d.mts +0 -574
  474. package/dist/types-DwDgacni.d.mts +0 -338
  475. package/dist/workflow-BbKvGLQg.d.mts +0 -96
  476. package/dist/workflow-DgemCAz3.mjs +0 -38
  477. package/dist/workflow-DgemCAz3.mjs.map +0 -1
  478. package/dist/workflow.generated-DtQwEo-x.d.mts +0 -671
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema--xYWRGfe.mjs","names":["parseInternal","parseFieldInternal"],"sources":["../src/runtime/field-parse.ts","../src/configure/types/field.ts","../src/configure/services/tailordb/schema.ts"],"sourcesContent":["import type { FieldMetadata, TailorFieldType } from \"#/configure/types/field.types\";\nimport type { TailorPrincipal } from \"#/runtime/types\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nconst regex = {\n uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n date: /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/,\n time: /^(?<hour>[01]\\d|2[0-3]):(?<minute>[0-5]\\d)$/,\n datetime:\n /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})[Tt](?<hour>[01]\\d|2[0-3]):(?<minute>[0-5]\\d):(?<second>[0-5]\\d|60)(\\.(?<fraction>\\d+))?(?<offset>[Zz]|[+-](?:[01]\\d|2[0-3]):[0-5]\\d)$/,\n decimal: /^-?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/,\n} as const;\n\nexport type FieldParseArgs = {\n value: unknown;\n data: unknown;\n invoker: TailorPrincipal | null;\n};\n\nexport type FieldParseInternalArgs = {\n value: unknown;\n data: unknown;\n invoker: TailorPrincipal | null;\n pathArray: string[];\n};\n\nexport type FieldRuntime<T extends TailorFieldType = TailorFieldType> = {\n readonly type: T;\n readonly fields: Record<string, FieldRuntime>;\n _metadata: FieldMetadata;\n};\n\ntype FieldParseRuntimeArgs<T extends TailorFieldType> = FieldParseInternalArgs & {\n field: FieldRuntime<T>;\n};\n\ntype FieldValidationArgs<T extends TailorFieldType> = FieldParseRuntimeArgs<T> & {\n issues: StandardSchemaV1.Issue[];\n};\n\nfunction validateBaseValue<T extends TailorFieldType>(args: FieldValidationArgs<T>): boolean {\n const { field, value, pathArray, issues } = args;\n const path = pathArray.length > 0 ? pathArray : undefined;\n const initialIssueCount = issues.length;\n\n switch (field.type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value)) {\n issues.push({\n message: `Expected an integer: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"float\":\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({\n message: `Expected a number: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"boolean\":\n if (typeof value !== \"boolean\") {\n issues.push({\n message: `Expected a boolean: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"uuid\":\n if (typeof value !== \"string\" || !regex.uuid.test(value)) {\n issues.push({\n message: `Expected a valid UUID: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"date\":\n if (typeof value !== \"string\" || !regex.date.test(value)) {\n issues.push({\n message: `Expected to match \"yyyy-MM-dd\" format: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"datetime\":\n if (typeof value !== \"string\" || !regex.datetime.test(value)) {\n issues.push({\n message: `Expected to match ISO format: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"time\":\n if (typeof value !== \"string\" || !regex.time.test(value)) {\n issues.push({\n message: `Expected to match \"HH:mm\" format: received ${String(value)}`,\n path,\n });\n }\n break;\n case \"decimal\":\n if (typeof value !== \"string\" || !regex.decimal.test(value)) {\n issues.push({\n message: `Expected a decimal string: received ${String(value)}`,\n path,\n });\n }\n break;\n\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._metadata.allowedValues.map((v) => v.value);\n if (typeof value !== \"string\" || !allowedValues.includes(value)) {\n issues.push({\n message: `Must be one of [${allowedValues.join(\", \")}]: received ${String(value)}`,\n path,\n });\n }\n }\n break;\n\n case \"nested\": {\n // Runtime input may not match the declared field type.\n // oxlint-disable typescript/no-unnecessary-condition\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n // oxlint-enable typescript/no-unnecessary-condition\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path,\n });\n return false;\n }\n\n let nestedBaseValid = true;\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = (value as Record<string, unknown>)[fieldName];\n if (\n !validateBaseField({\n ...args,\n field: nestedField,\n value: fieldValue,\n pathArray: pathArray.concat(fieldName),\n })\n ) {\n nestedBaseValid = false;\n }\n }\n return nestedBaseValid;\n }\n }\n\n return issues.length === initialIssueCount;\n}\n\nfunction validateCustomValue<T extends TailorFieldType>(\n args: FieldValidationArgs<T>,\n validateFns: NonNullable<FieldMetadata[\"validate\"]>,\n): void {\n const { value, pathArray, issues } = args;\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n for (const fn of validateFns) {\n const result = fn({ value });\n if (typeof result === \"string\") {\n issues.push({\n message: result,\n path,\n });\n }\n }\n}\n\nfunction validateBaseField<T extends TailorFieldType>(args: FieldValidationArgs<T>): boolean {\n const { field, value, pathArray, issues } = args;\n const path = pathArray.length > 0 ? pathArray : undefined;\n\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path,\n });\n return false;\n }\n\n if (!field._metadata.required && isNullOrUndefined) {\n return true;\n }\n\n let baseValid = true;\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path,\n });\n return false;\n }\n\n for (let i = 0; i < value.length; i++) {\n if (\n !validateBaseValue({\n ...args,\n value: value[i],\n pathArray: pathArray.concat(`[${i}]`),\n })\n ) {\n baseValid = false;\n }\n }\n } else {\n baseValid = validateBaseValue(args);\n }\n\n return baseValid;\n}\n\nfunction validateCustomField<T extends TailorFieldType>(args: FieldValidationArgs<T>): void {\n const { field, value, pathArray } = args;\n if (value === null || value === undefined) {\n return;\n }\n\n if (field.type === \"nested\") {\n const records = field._metadata.array\n ? (value as Record<string, unknown>[])\n : [value as Record<string, unknown>];\n\n for (let i = 0; i < records.length; i++) {\n const record = records[i] as Record<string, unknown>;\n const recordPath = field._metadata.array ? pathArray.concat(`[${i}]`) : pathArray;\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n validateCustomField({\n ...args,\n field: nestedField,\n value: record[fieldName],\n pathArray: recordPath.concat(fieldName),\n });\n }\n }\n }\n\n const validateFns = field._metadata.validate;\n if (validateFns?.length) {\n validateCustomValue(args, validateFns);\n }\n}\n\nexport function parseInternal<T extends TailorFieldType, Output>(\n args: FieldParseRuntimeArgs<T>,\n): StandardSchemaV1.Result<Output> {\n const { value } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n const validationArgs = { ...args, issues };\n const baseValid = validateBaseField(validationArgs);\n if (baseValid) {\n validateCustomField(validationArgs);\n }\n if (issues.length > 0) {\n return { issues };\n }\n\n return { value: (value ?? null) as Output };\n}\n\ntype ParseInputFieldsArgs = FieldParseArgs & {\n fields: Record<string, FieldRuntime>;\n};\n\n/**\n * Validate a value against a record of input fields, treating the record as a\n * single required object — the same code path deployed functions run via\n * `t.object(fields).parse(...)`, so local validation matches platform behavior.\n * @param args - Input field definitions plus the value, context data, and user\n * @returns Validation result\n */\nexport function parseInputFields(args: ParseInputFieldsArgs): StandardSchemaV1.Result<unknown> {\n const { fields, ...parseArgs } = args;\n return parseInternal({\n ...parseArgs,\n field: { type: \"nested\", fields, _metadata: { required: true } },\n pathArray: [],\n });\n}\n","import type { EnumValue } from \"#/configure/types/field.types\";\n\nexport type AllowedValues = readonly [string | EnumValue, ...(string | EnumValue)[]];\n\n/**\n * Normalize allowed values into EnumValue objects with descriptions.\n * @param values - Allowed values as strings or EnumValue objects\n * @returns Normalized allowed values\n */\nexport function mapAllowedValues(values: AllowedValues): EnumValue[] {\n return values.map((value) => {\n if (typeof value === \"string\") {\n return { value, description: \"\" };\n }\n return { ...value, description: value.description ?? \"\" };\n });\n}\n\nexport type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T\n ? T extends string\n ? T\n : T extends { value: infer K }\n ? K\n : never\n : never;\n","import { cloneDeep } from \"es-toolkit\";\nimport {\n type AllowedValues,\n type AllowedValuesOutput,\n mapAllowedValues,\n} from \"#/configure/types/field\";\nimport {\n parseInternal as parseFieldInternal,\n type FieldParseArgs,\n type FieldParseInternalArgs,\n} from \"#/runtime/field-parse\";\nimport { brandValue } from \"#/utils/brand\";\nimport type {\n TailorDBField as TailorDBFieldBase,\n TailorDBType as TailorDBTypeBase,\n DBFieldMetadata,\n DefinedDBFieldMetadata,\n SerialConfig,\n IndexDef,\n TailorDBTypeMetadata,\n RawRelationConfig,\n RelationType,\n} from \"#/configure/services/tailordb/types\";\nimport type {\n FieldOptions,\n FieldOutput,\n TailorFieldType,\n TailorToTs,\n FieldValidateInput,\n} from \"#/configure/types/field.types\";\nimport type { PluginAttachment, PluginConfigs } from \"#/plugin/types\";\nimport type { InferredAttributes } from \"#/runtime/types\";\nimport type { output, InferFieldsOutput, TypeLevelError } from \"#/types/helpers\";\nimport type { RawPermissions } from \"#/types/tailordb.generated\";\nimport type { TailorTypeGqlPermission, TailorTypePermission } from \"./permission\";\nimport type {\n Hook,\n TypeHook,\n ExcludeNestedDBFields,\n ExcludeHookedDBFields,\n ExcludeDefaultedDBFields,\n TypeFeatures,\n TypeValidateFn,\n} from \"./types\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n// Erased DB fields stay assignable across builder method-state changes.\n// oxlint-disable-next-line no-explicit-any\ntype AnyBuilderMethod = any;\n\nexport type TailorAnyDBField = Omit<\n TailorDBFieldBase<AnyBuilderMethod, AnyBuilderMethod>,\n \"fields\"\n> & {\n readonly fields: Record<string, AnyBuilderMethod>;\n _metadata: DBFieldMetadata;\n parse: AnyBuilderMethod;\n readonly typeName: TypeLevelError<string>;\n description: AnyBuilderMethod;\n relation: AnyBuilderMethod;\n index: AnyBuilderMethod;\n unique: AnyBuilderMethod;\n vector: AnyBuilderMethod;\n default: AnyBuilderMethod;\n hooks: AnyBuilderMethod;\n validate: AnyBuilderMethod;\n serial: AnyBuilderMethod;\n clone: AnyBuilderMethod;\n};\n\n// Helper alias\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyDBType = TailorDBType<any, any, any>;\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\ntype DBFieldTypeNameMethod<Defined extends DefinedDBFieldMetadata> =\n IsAny<Defined> extends true\n ? TypeLevelError<string>\n : TypeLevelError<\"typeName cannot be used on TailorDB fields\">;\n\ntype WithDBFieldDescription<Defined> = Defined & { description: true };\ntype WithDBFieldRelation<Defined, S extends RelationType | RelationSelfConfig> = S extends\n | \"oneToOne\"\n | \"1-1\"\n ? Defined & { unique: true; index: true; relation: true }\n : S extends { type: \"oneToOne\" | \"1-1\" }\n ? Defined & { unique: true; index: true; relation: true }\n : Defined & { index: true; relation: true };\ntype WithDBFieldIndex<Defined> = Defined & { index: true };\ntype WithDBFieldUnique<Defined> = Defined & { unique: true; index: true };\ntype WithDBFieldVector<Defined> = Defined & { vector: true };\ntype WithDBFieldHooks<Defined, H> = Defined & {\n hooks: {\n create: H extends { create: unknown } ? true : false;\n update: H extends { update: unknown } ? true : false;\n };\n serial: false;\n};\ntype WithDBFieldDefault<Defined> = Defined & { default: true };\ntype WithDBFieldValidate<Defined> = Defined & { validate: true };\ntype WithDBFieldSerial<Defined> = Defined & {\n serial: true;\n hooks: { create: false; update: false };\n};\ntype WithDBFieldCloneOptions<Defined extends DefinedDBFieldMetadata, NewOpt extends FieldOptions> =\n IsAny<Defined> extends true\n ? Defined\n : Omit<Defined, \"array\"> & {\n array: NewOpt extends { array: true }\n ? true\n : NewOpt extends { array: false }\n ? false\n : Defined[\"array\"];\n };\ntype NonNullableDBFieldOutput<Output> = Exclude<Output, null>;\ntype DBFieldScalarOutput<Output> =\n NonNullableDBFieldOutput<Output> extends (infer Item)[] ? Item : NonNullableDBFieldOutput<Output>;\ntype DBFieldCloneArrayOutput<Output, NewOpt extends FieldOptions> = NewOpt extends {\n array: true;\n}\n ? DBFieldScalarOutput<Output>[]\n : NewOpt extends { array: false }\n ? DBFieldScalarOutput<Output>\n : NonNullableDBFieldOutput<Output>;\ntype DBFieldCloneOutput<Output, NewOpt extends FieldOptions> = NewOpt extends { optional: true }\n ? DBFieldCloneArrayOutput<Output, NewOpt> | null\n : NewOpt extends { optional: false }\n ? DBFieldCloneArrayOutput<Output, NewOpt>\n : null extends Output\n ? DBFieldCloneArrayOutput<Output, NewOpt> | null\n : DBFieldCloneArrayOutput<Output, NewOpt>;\ntype DBFieldCloneOptions<Defined extends DefinedDBFieldMetadata> = Omit<FieldOptions, \"array\"> & {\n array?: Defined extends { validate: unknown } ? Defined[\"array\"] : boolean;\n};\ntype InvalidValidatedArrayCloneKeys<\n Fields extends Record<string, TailorAnyDBField>,\n K extends keyof Fields,\n Opt extends FieldOptions,\n> = Opt extends { array: infer ArrayOption }\n ? {\n [P in K]: Fields[P] extends TailorDBField<infer Defined, infer _Output>\n ? Defined extends { validate: unknown }\n ? ArrayOption extends Defined[\"array\"]\n ? never\n : P\n : never\n : never;\n }[K]\n : never;\ntype DBFieldsCloneOptionsGuard<\n Fields extends Record<string, TailorAnyDBField>,\n K extends keyof Fields,\n Opt extends FieldOptions,\n> = [InvalidValidatedArrayCloneKeys<Fields, K, Opt>] extends [never]\n ? unknown\n : TypeLevelError<\"array cannot be changed on fields with custom validation\">;\ntype DefinedDBTypeMetadata = {\n hooks?: true;\n validate?: true;\n features?: true;\n indexes?: true;\n files?: true;\n permission?: true;\n gqlPermission?: true;\n description?: true;\n};\ntype WithDBTypeMetadata<\n Defined extends DefinedDBTypeMetadata,\n Key extends keyof DefinedDBTypeMetadata,\n> = Defined & Record<Key, true>;\ntype DBTypeDuplicateInputGuard<\n Defined extends DefinedDBTypeMetadata,\n Key extends keyof DefinedDBTypeMetadata,\n Input,\n Message extends string,\n> =\n IsAny<Defined> extends true\n ? Input\n : Defined extends Record<Key, unknown>\n ? TypeLevelError<Message>\n : Input;\ntype DBTypeDuplicateRestGuard<\n Defined extends DefinedDBTypeMetadata,\n Key extends keyof DefinedDBTypeMetadata,\n Input extends unknown[],\n Message extends string,\n> =\n IsAny<Defined> extends true\n ? Input\n : Defined extends Record<Key, unknown>\n ? [TypeLevelError<Message>, ...TypeLevelError<Message>[]]\n : Input;\ntype FileKeyConflictError<\n Fields extends Record<string, TailorAnyDBField>,\n User extends object,\n> = Partial<\n Record<\n keyof output<TailorDBType<Fields, User>> & string,\n TypeLevelError<\"file keys cannot use existing field names\">\n >\n>;\ntype DBFieldDescriptionFn<Defined extends DefinedDBFieldMetadata, Output> = (\n description: string,\n) => TailorDBField<WithDBFieldDescription<Defined>, Output>;\ntype DBFieldRelationFn<Defined extends DefinedDBFieldMetadata, Output> = {\n <S extends RelationType, T extends TailorAnyDBType>(\n config: RelationConfig<S, T>,\n ): TailorDBField<WithDBFieldRelation<Defined, S>, Output>;\n <S extends RelationSelfConfig>(config: S): TailorDBField<WithDBFieldRelation<Defined, S>, Output>;\n};\ntype DBFieldIndexFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<\n WithDBFieldIndex<Defined>,\n Output\n>;\ntype DBFieldUniqueFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<\n WithDBFieldUnique<Defined>,\n Output\n>;\ntype DBFieldVectorFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<\n WithDBFieldVector<Defined>,\n Output\n>;\ntype DBFieldHooksFn<Defined extends DefinedDBFieldMetadata, Output> = <\n const H extends Hook<\n Output,\n Defined extends { default: true } ? Output | null | undefined : Output\n >,\n>(\n hooks: H,\n) => TailorDBField<WithDBFieldHooks<Defined, H>, Output>;\ntype DBFieldValidateFn<Defined extends DefinedDBFieldMetadata, Output> = (\n ...validate: FieldValidateInput<Output>[]\n) => TailorDBField<WithDBFieldValidate<Defined>, Output>;\ntype DBFieldSerialFn<Defined extends DefinedDBFieldMetadata, Output> = (\n config: SerialConfig<Defined[\"type\"] & (\"integer\" | \"string\")>,\n) => TailorDBField<WithDBFieldSerial<Defined>, Output>;\ntype DBFieldDescriptionMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldDescriptionFn<Defined, Output>\n : Defined extends { description: unknown }\n ? TypeLevelError<\".description() has already been set\">\n : DBFieldDescriptionFn<Defined, Output>;\ntype DBFieldRelationMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldRelationFn<Defined, Output>\n : Defined extends { relation: unknown }\n ? TypeLevelError<\".relation() has already been set\">\n : DBFieldRelationFn<Defined, Output>;\ntype DBFieldArrayCheck<A extends boolean, Ok, Msg extends string> = A extends true\n ? TypeLevelError<Msg>\n : Ok;\ntype DBFieldIndexMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldIndexFn<Defined, Output>\n : Defined extends { index: unknown }\n ? TypeLevelError<\".index() has already been set\">\n : DBFieldArrayCheck<\n Defined[\"array\"],\n DBFieldIndexFn<Defined, Output>,\n \"index cannot be set on array fields\"\n >;\ntype DBFieldUniqueMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldUniqueFn<Defined, Output>\n : Defined extends { unique: unknown }\n ? TypeLevelError<\".unique() has already been set\">\n : DBFieldArrayCheck<\n Defined[\"array\"],\n DBFieldUniqueFn<Defined, Output>,\n \"unique cannot be set on array fields\"\n >;\ntype DBFieldVectorMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldVectorFn<Defined, Output>\n : Defined extends { vector: unknown }\n ? TypeLevelError<\".vector() has already been set\">\n : Defined extends { type: \"string\"; array: false }\n ? DBFieldVectorFn<Defined, Output>\n : TypeLevelError<\"vector can only be set on non-array string fields\">;\ntype DBFieldHooksMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldHooksFn<Defined, Output>\n : Defined extends {\n serial: true;\n hooks: { create: false; update: false };\n }\n ? TypeLevelError<\"hooks cannot be set after serial\">\n : Defined extends {\n hooks: unknown;\n }\n ? TypeLevelError<\".hooks() has already been set\">\n : Defined extends { type: \"nested\" }\n ? TypeLevelError<\"hooks cannot be set on nested type fields\">\n : DBFieldHooksFn<Defined, Output>;\ntype DBFieldValidateMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldValidateFn<Defined, Output>\n : Defined extends { validate: unknown }\n ? TypeLevelError<\".validate() has already been set\">\n : DBFieldValidateFn<Defined, Output>;\ntype DBFieldSerialMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldSerialFn<Defined, Output>\n : Defined extends { serial: true }\n ? TypeLevelError<\".serial() has already been set\">\n : Defined extends { serial: false }\n ? TypeLevelError<\"serial cannot be set after hooks\">\n : IsAny<Output> extends true\n ? Defined extends { type: \"integer\" | \"string\"; array: false }\n ? DBFieldSerialFn<Defined, Output>\n : TypeLevelError<\"serial can only be set on non-array integer or string fields\">\n : null extends Output\n ? TypeLevelError<\"serial can only be set on non-array integer or string fields\">\n : Defined extends { type: \"integer\" | \"string\"; array: false }\n ? DBFieldSerialFn<Defined, Output>\n : TypeLevelError<\"serial can only be set on non-array integer or string fields\">;\ntype DBFieldDefaultFn<Defined extends DefinedDBFieldMetadata, Output> = (\n value: Output extends null ? NonNullable<Output> : Output,\n) => TailorDBField<WithDBFieldDefault<Defined>, Output>;\ntype DBFieldDefaultMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldDefaultFn<Defined, Output>\n : Defined extends { default: unknown }\n ? TypeLevelError<\".default() has already been set\">\n : Defined extends { type: \"nested\" }\n ? TypeLevelError<\"default cannot be set on nested type fields\">\n : Defined extends { serial: true }\n ? TypeLevelError<\"default cannot be set on serial fields\">\n : null extends Output\n ? TypeLevelError<\"default cannot be set on optional fields\">\n : DBFieldDefaultFn<Defined, Output>;\n\n/**\n * Full TailorDBField interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorDBField<\n Defined extends DefinedDBFieldMetadata = DefinedDBFieldMetadata,\n // oxlint-disable-next-line no-explicit-any\n Output = any,\n> extends Omit<TailorDBFieldBase<Defined, Output>, \"fields\"> {\n readonly fields: Record<string, TailorAnyDBField>;\n _metadata: DBFieldMetadata;\n\n /**\n * Parse and validate a value against this field's validation rules\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * typeName is not available on TailorDB fields.\n * Use typeName on pipeline fields (t.enum / t.object) instead.\n */\n typeName: DBFieldTypeNameMethod<Defined>;\n\n /**\n * Set a description for the field\n */\n description: DBFieldDescriptionMethod<Defined, Output>;\n\n /**\n * Define a relation to another type.\n */\n relation: DBFieldRelationMethod<Defined, Output>;\n\n /**\n * Add an index to the field\n */\n index: DBFieldIndexMethod<Defined, Output>;\n\n /**\n * Make the field unique (also adds an index)\n */\n unique: DBFieldUniqueMethod<Defined, Output>;\n\n /**\n * Enable vector search on the field (string type only)\n */\n vector: DBFieldVectorMethod<Defined, Output>;\n\n /**\n * Set a default value for the field on create. When the field is required,\n * this makes it optional in the Create input — the default fills in when\n * no value (or a nullish hook result) is provided.\n *\n * For datetime/date/time fields, pass `\"now\"` to use the operation timestamp.\n */\n default: DBFieldDefaultMethod<Defined, Output>;\n\n /**\n * Add hooks for create/update operations on this field.\n */\n hooks: DBFieldHooksMethod<Defined, Output>;\n\n /**\n * Add validation functions to the field.\n *\n * Validators receive `{ value, data, user }` and run after hooks and\n * built-in type validation; they are skipped when built-in validation\n * fails. For array fields, `value` is the complete array.\n */\n validate: DBFieldValidateMethod<Defined, Output>;\n\n /**\n * Configure serial/auto-increment behavior\n */\n serial: DBFieldSerialMethod<Defined, Output>;\n\n /**\n * Clone the field with optional overrides for field options.\n * The `array` option cannot change on fields with custom validation.\n */\n clone<const NewOpt extends DBFieldCloneOptions<Defined>>(\n options?: NewOpt,\n ): TailorDBField<WithDBFieldCloneOptions<Defined, NewOpt>, DBFieldCloneOutput<Output, NewOpt>>;\n}\n\n/**\n * Full TailorDBType interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorDBType<\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributes,\n // oxlint-disable-next-line no-explicit-any\n Defined extends DefinedDBTypeMetadata = any,\n> extends TailorDBTypeBase<Fields, User> {\n _description?: string;\n\n hooks(\n hook: DBTypeDuplicateInputGuard<\n Defined,\n \"hooks\",\n TypeHook<Fields>,\n \".hooks() has already been set\"\n >,\n ): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, \"hooks\">>;\n validate(\n fn: DBTypeDuplicateInputGuard<\n Defined,\n \"validate\",\n TypeValidateFn<Fields>,\n \".validate() has already been set\"\n >,\n ): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, \"validate\">>;\n features(\n features: DBTypeDuplicateInputGuard<\n Defined,\n \"features\",\n Omit<TypeFeatures, \"pluralForm\">,\n \".features() has already been set\"\n >,\n ): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, \"features\">>;\n indexes(\n ...indexes: DBTypeDuplicateRestGuard<\n Defined,\n \"indexes\",\n IndexDef<TailorDBType<Fields, User, Defined>>[],\n \".indexes() has already been set\"\n >\n ): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, \"indexes\">>;\n files<const F extends string>(\n files: DBTypeDuplicateInputGuard<\n Defined,\n \"files\",\n Record<F, string> & FileKeyConflictError<Fields, User>,\n \".files() has already been set\"\n >,\n ): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, \"files\">>;\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<TailorDBType<Fields, User, Defined>>> =\n TailorTypePermission<U, output<TailorDBType<Fields, User, Defined>>>,\n >(\n permission: DBTypeDuplicateInputGuard<\n Defined,\n \"permission\",\n P,\n \".permission() has already been set\"\n >,\n ): TailorDBType<Fields, U, WithDBTypeMetadata<Defined, \"permission\">>;\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(\n permission: DBTypeDuplicateInputGuard<\n Defined,\n \"gqlPermission\",\n P,\n \".gqlPermission() has already been set\"\n >,\n ): TailorDBType<Fields, U, WithDBTypeMetadata<Defined, \"gqlPermission\">>;\n description(\n description: DBTypeDuplicateInputGuard<\n Defined,\n \"description\",\n string,\n \".description() has already been set\"\n >,\n ): TailorDBType<Fields, User, WithDBTypeMetadata<Defined, \"description\">>;\n pickFields<K extends keyof Fields>(keys: K[]): Pick<Fields, K>;\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(\n keys: K[],\n options: Opt & DBFieldsCloneOptionsGuard<Fields, K, Opt>,\n ): {\n [P in K]: Fields[P] extends TailorDBField<infer D, infer O>\n ? TailorDBField<WithDBFieldCloneOptions<D, Opt>, DBFieldCloneOutput<O, Opt>>\n : never;\n };\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K>;\n plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: {\n [K in P]: PluginConfigs<keyof Fields & string>[K];\n }): TailorDBType<Fields, User, Defined>;\n}\n\nexport type TailorDBInstance<\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributes,\n // oxlint-disable-next-line no-explicit-any\n Defined extends DefinedDBTypeMetadata = any,\n> = TailorDBType<Fields, User, Defined>;\n\ninterface RelationConfig<S extends RelationType, T extends TailorDBType> {\n type: S;\n toward: {\n type: T;\n as?: string;\n key?: keyof T[\"fields\"] & string;\n };\n backward?: string;\n}\n\n// Special config variant for self-referencing relations\ntype RelationSelfConfig = {\n type: RelationType;\n toward: {\n type: \"self\";\n as?: string;\n key?: string;\n };\n backward?: string;\n};\n\nfunction isRelationSelfConfig(\n config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig,\n): config is RelationSelfConfig {\n return config.toward.type === \"self\";\n}\n\ntype DBFieldDefined<T extends TailorFieldType, Opt extends FieldOptions> = {\n type: T;\n array: Opt extends { array: true } ? true : false;\n};\ntype DBFieldOutput<\n T extends TailorFieldType,\n Opt extends FieldOptions,\n OutputBase = TailorToTs[T],\n> = FieldOutput<OutputBase, Opt>;\ntype TailorDBFieldInstance<\n T extends TailorFieldType,\n Opt extends FieldOptions,\n OutputBase = TailorToTs[T],\n> = TailorDBField<DBFieldDefined<T, Opt>, DBFieldOutput<T, Opt, OutputBase>>;\ntype TailorDBFieldRuntimeInstance<\n T extends TailorFieldType,\n Opt extends FieldOptions,\n OutputBase = TailorToTs[T],\n> = TailorDBFieldRuntime<DBFieldDefined<T, Opt>, DBFieldOutput<T, Opt, OutputBase>>;\ntype TailorDBFieldRuntime<Defined extends DefinedDBFieldMetadata, Output> = Omit<\n TailorDBFieldBase<Defined, Output>,\n \"fields\"\n> & {\n readonly fields: Record<string, TailorAnyDBField>;\n _metadata: DBFieldMetadata;\n description(description: string): object;\n typeName(typeName: string): object;\n validate(...validate: FieldValidateInput<Output>[]): object;\n relation(config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig): object;\n index(): object;\n unique(): object;\n vector(): object;\n default(value: unknown): object;\n hooks(hooks: Hook<Output>): object;\n serial(config: SerialConfig): object;\n clone(options?: FieldOptions): TailorDBFieldRuntime<DefinedDBFieldMetadata, AnyBuilderMethod>;\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n _setRawRelation(relation: RawRelationConfig): void;\n};\n\n/**\n * Creates a new TailorDBField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @returns A new TailorDBField\n */\nfunction createTailorDBField<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): TailorDBFieldInstance<T, TOptions, OutputBase>;\nfunction createTailorDBField<const T extends TailorFieldType, const TOptions extends FieldOptions>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): object {\n return createTailorDBFieldRuntime(type, options, fields, values);\n}\n\nfunction createTailorDBFieldRuntime<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): TailorDBFieldRuntimeInstance<T, TOptions, OutputBase> {\n type FieldValue = DBFieldOutput<T, TOptions, OutputBase>;\n type FieldType = TailorDBFieldRuntimeInstance<T, TOptions, OutputBase>;\n\n const _metadata: DBFieldMetadata = { required: true };\n let _rawRelation: RawRelationConfig | undefined;\n\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n\n function parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<FieldValue> {\n return parseFieldInternal<T, FieldValue>({\n ...args,\n field,\n });\n }\n\n function cloneWith(metadataUpdates: Partial<DBFieldMetadata>) {\n const cloned = field.clone();\n Object.assign(cloned._metadata, metadataUpdates);\n return cloned;\n }\n\n const field: FieldType = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as DBFieldDefined<T, TOptions>,\n _output: undefined as FieldValue,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n get rawRelation(): Readonly<RawRelationConfig> | undefined {\n return _rawRelation ? { ..._rawRelation, toward: { ..._rawRelation.toward } } : undefined;\n },\n\n description(description: string) {\n return cloneWith({ description });\n },\n\n typeName(typeName: string) {\n return cloneWith({ typeName });\n },\n\n validate(...validateInputs: FieldValidateInput<FieldValue>[]) {\n return cloneWith({ validate: validateInputs });\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldValue> {\n return parseInternal({\n value: args.value,\n data: args.data,\n invoker: args.invoker,\n pathArray: [],\n });\n },\n\n // TailorDBField specific methods\n relation(config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig) {\n const cloned = field.clone();\n const targetType = isRelationSelfConfig(config) ? \"self\" : config.toward.type.name;\n cloned._setRawRelation({\n type: config.type,\n toward: {\n type: targetType,\n as: config.toward.as,\n key: config.toward.key,\n },\n backward: config.backward,\n });\n return cloned;\n },\n\n index() {\n return cloneWith({ index: true });\n },\n\n unique() {\n return cloneWith({ unique: true, index: true });\n },\n\n vector() {\n return cloneWith({ vector: true });\n },\n\n // oxlint-disable-next-line no-explicit-any\n default(value: any) {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ default: value }) as any;\n },\n\n hooks(hooks: Hook<FieldValue>) {\n return cloneWith({ hooks });\n },\n\n serial(config: SerialConfig) {\n return cloneWith({ serial: config });\n },\n\n clone(cloneOptions?: FieldOptions) {\n if (\n this._metadata.validate?.length &&\n cloneOptions?.array !== undefined &&\n cloneOptions.array !== (this._metadata.array === true)\n ) {\n throw new Error(\"Cannot change the array option on a field with custom validation\");\n }\n\n // Deep clone nested object fields if present\n let clonedFields = fields;\n if (fields) {\n const cloned: Record<string, TailorAnyDBField> = {};\n for (const [key, field] of Object.entries(fields)) {\n cloned[key] = field.clone();\n }\n clonedFields = cloned;\n }\n\n // Create a new field with cloned configuration\n const clonedField = createTailorDBFieldRuntime(type, options, clonedFields, values);\n\n // Deep copy metadata using cloneDeep (preserves function references)\n Object.assign(clonedField._metadata, cloneDeep(this._metadata));\n\n // Apply new options if provided\n if (cloneOptions) {\n if (cloneOptions.optional !== undefined) {\n clonedField._metadata.required = !cloneOptions.optional;\n }\n if (cloneOptions.array !== undefined) {\n clonedField._metadata.array = cloneOptions.array;\n }\n }\n\n // Copy raw relation if exists\n if (_rawRelation) {\n clonedField._setRawRelation(cloneDeep(_rawRelation));\n }\n\n return clonedField;\n },\n\n _setRawRelation(relation: RawRelationConfig) {\n _rawRelation = relation;\n },\n };\n\n return field;\n}\n\nconst createField = createTailorDBField;\n\n/**\n * Create a UUID field.\n * @param options - Field configuration options\n * @returns A UUID field\n * @example db.uuid()\n * @example db.uuid({ optional: true })\n */\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"uuid\", options);\n}\n\n/**\n * Create a string field.\n * @param options - Field configuration options\n * @returns A string field\n * @example db.string()\n * @example db.string({ optional: true })\n */\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"string\", options);\n}\n\n/**\n * Create a boolean field.\n * Note: The method name is `bool` but creates a `boolean` type field.\n * @param options - Field configuration options\n * @returns A boolean field\n * @example db.bool()\n * @example db.bool({ optional: true })\n */\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"boolean\", options);\n}\n\n/**\n * Create an integer field.\n * @param options - Field configuration options\n * @returns An integer field\n * @example db.int()\n * @example db.int({ optional: true })\n */\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"integer\", options);\n}\n\n/**\n * Create a float (decimal number) field.\n * @param options - Field configuration options\n * @returns A float field\n * @example db.float()\n * @example db.float({ optional: true })\n */\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"float\", options);\n}\n\ninterface DecimalFieldOptions extends FieldOptions {\n scale?: number;\n}\n\n/**\n * Create a decimal field (stored as string for precision).\n * @param options - Field configuration options including optional scale (0-12)\n * @returns A decimal field\n * @example db.decimal()\n * @example db.decimal({ scale: 2 })\n * @example db.decimal({ scale: 2, optional: true })\n */\nfunction decimal<const Opt extends DecimalFieldOptions>(options?: Opt) {\n if (options?.scale !== undefined) {\n if (!Number.isInteger(options.scale) || options.scale < 0 || options.scale > 12) {\n throw new Error(\"scale must be an integer between 0 and 12\");\n }\n }\n const field = createField(\"decimal\", options);\n if (options?.scale !== undefined) {\n field._metadata.scale = options.scale;\n }\n return field;\n}\n\n/**\n * Create a date field (date only, no time component).\n * Format: \"yyyy-MM-dd\"\n * @param options - Field configuration options\n * @returns A date field\n * @example db.date()\n */\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"date\", options);\n}\n\n/**\n * Create a datetime field (date and time).\n * Format: ISO 8601, such as \"yyyy-MM-ddTHH:mm:ssZ\" or \"yyyy-MM-ddTHH:mm:ss+09:00\"\n * @param options - Field configuration options\n * @returns A datetime field\n * @example db.datetime()\n */\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"datetime\", options);\n}\n\n/**\n * Create a time field (time only, no date component).\n * Format: \"HH:mm\"\n * @param options - Field configuration options\n * @returns A time field\n * @example db.time()\n */\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"time\", options);\n}\n\n/**\n * Create an enum field with a fixed set of allowed string values.\n * @param values - Array of allowed string values, or array of `{ value, description }` objects\n * @param options - Field configuration options\n * @returns An enum field\n * @example db.enum([\"active\", \"inactive\", \"suspended\"])\n * @example db.enum([\"small\", \"medium\", \"large\"], { optional: true })\n */\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorDBField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\n/**\n * Create a nested object field with sub-fields.\n * @param fields - Record of nested field definitions\n * @param options - Field configuration options\n * @returns A nested object field\n * @example db.object({ street: db.string(), city: db.string(), zip: db.string() })\n * @example db.object({ name: db.string() }, { optional: true })\n */\nfunction object<\n const F extends Record<string, TailorAnyDBField> &\n ExcludeNestedDBFields<F> &\n ExcludeHookedDBFields<F> &\n ExcludeDefaultedDBFields<F>,\n const Opt extends FieldOptions,\n>(fields: F, options?: Opt) {\n return createField(\"nested\", options, fields) as unknown as TailorDBField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n}\n\n/**\n * Creates a new TailorDBType instance.\n * @param name - Type name\n * @param fields - Field definitions\n * @param options - Type options\n * @param options.pluralForm - Optional plural form\n * @param options.description - Optional description\n * @returns A new TailorDBType\n */\nfunction createTailorDBType<\n // oxlint-disable-next-line no-explicit-any\n const Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributes,\n>(\n name: string,\n fields: Fields,\n options: { pluralForm?: string; description?: string },\n): TailorDBType<Fields, User, DefinedDBTypeMetadata> {\n let _description = options.description;\n let _settings: TypeFeatures = {};\n let _indexes: IndexDef<TailorDBType<Fields, User, DefinedDBTypeMetadata>>[] = [];\n const _permissions: RawPermissions = {};\n let _files: Record<string, string> = {};\n const _plugins: PluginAttachment[] = [];\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n let _typeHook: { create?: Function; update?: Function } | undefined;\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n let _typeValidate: Function | undefined;\n const _definedMethods = new Set<keyof DefinedDBTypeMetadata>();\n if (options.description !== undefined) {\n _definedMethods.add(\"description\");\n }\n\n function runMethodOnce<T>(method: keyof DefinedDBTypeMetadata, action: () => T): T {\n if (_definedMethods.has(method)) {\n throw new Error(`.${method}() has already been set`);\n }\n const result = action();\n _definedMethods.add(method);\n return result;\n }\n type TypeAfter<Key extends keyof DefinedDBTypeMetadata> = TailorDBType<\n Fields,\n User,\n WithDBTypeMetadata<DefinedDBTypeMetadata, Key>\n >;\n type TypeAfterUser<\n NextUser extends object,\n Key extends keyof DefinedDBTypeMetadata,\n > = TailorDBType<Fields, NextUser, WithDBTypeMetadata<DefinedDBTypeMetadata, Key>>;\n\n if (options.pluralForm) {\n if (name === options.pluralForm) {\n throw new Error(`The name and the plural form must be different. name=${name}`);\n }\n _settings.pluralForm = options.pluralForm;\n }\n\n const dbType: TailorDBType<Fields, User, DefinedDBTypeMetadata> = {\n name,\n fields: { ...fields },\n _output: null as unknown as InferFieldsOutput<Fields>,\n _description,\n\n get metadata(): TailorDBTypeMetadata {\n // Convert indexes to the format expected by the manifest\n const indexes: Record<string, { fields: string[]; unique?: boolean }> = {};\n if (_indexes.length > 0) {\n _indexes.forEach((index) => {\n const fieldNames = index.fields.map((field) => String(field));\n const key = index.name || `idx_${fieldNames.join(\"_\")}`;\n indexes[key] = {\n fields: fieldNames,\n unique: index.unique,\n };\n });\n }\n\n return {\n name: this.name,\n description: _description,\n settings: _settings,\n permissions: _permissions,\n files: _files,\n ...(Object.keys(indexes).length > 0 && { indexes }),\n ...(_typeHook && { typeHook: _typeHook }),\n ...(_typeValidate && { typeValidate: _typeValidate }),\n };\n },\n\n hooks(hook: TypeHook<Fields>): TypeAfter<\"hooks\"> {\n return runMethodOnce(\"hooks\", () => {\n _typeHook = hook;\n return this as TypeAfter<\"hooks\">;\n });\n },\n\n validate(fn: TypeValidateFn<Fields>): TypeAfter<\"validate\"> {\n return runMethodOnce(\"validate\", () => {\n _typeValidate = fn;\n return this as TypeAfter<\"validate\">;\n });\n },\n\n features(features: Omit<TypeFeatures, \"pluralForm\">): TypeAfter<\"features\"> {\n return runMethodOnce(\"features\", () => {\n _settings = {\n ..._settings,\n ...features,\n };\n return this as TypeAfter<\"features\">;\n });\n },\n\n indexes(\n ...indexes: IndexDef<TailorDBType<Fields, User, DefinedDBTypeMetadata>>[]\n ): TypeAfter<\"indexes\"> {\n return runMethodOnce(\"indexes\", () => {\n _indexes = indexes;\n return this as TypeAfter<\"indexes\">;\n });\n },\n\n files<const F extends string>(\n files: Record<F, string> & FileKeyConflictError<Fields, User>,\n ): TypeAfter<\"files\"> {\n return runMethodOnce(\"files\", () => {\n _files = files;\n return this as TypeAfter<\"files\">;\n });\n },\n\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<TailorDBType<Fields, User, DefinedDBTypeMetadata>>> =\n TailorTypePermission<U, output<TailorDBType<Fields, User, DefinedDBTypeMetadata>>>,\n >(permission: P): TypeAfterUser<U, \"permission\"> {\n return runMethodOnce(\"permission\", () => {\n const ret = this as unknown as TypeAfterUser<U, \"permission\">;\n _permissions.record = permission as RawPermissions[\"record\"];\n return ret;\n });\n },\n\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(permission: P): TypeAfterUser<U, \"gqlPermission\"> {\n return runMethodOnce(\"gqlPermission\", () => {\n const ret = this as unknown as TypeAfterUser<U, \"gqlPermission\">;\n _permissions.gql = permission as RawPermissions[\"gql\"];\n return ret;\n });\n },\n\n description(description: string): TypeAfter<\"description\"> {\n return runMethodOnce(\"description\", () => {\n _description = description;\n this._description = description;\n return this as TypeAfter<\"description\">;\n });\n },\n\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options?: Opt) {\n const result = {} as Record<K, TailorAnyDBField>;\n for (const key of keys) {\n const field = this.fields[key] as TailorAnyDBField;\n if (options) {\n result[key] = field.clone(options);\n } else {\n result[key] = field;\n }\n }\n // oxlint-disable-next-line no-explicit-any\n return result as any;\n },\n\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K> {\n const keysSet = new Set(keys);\n const result = {} as Record<string, TailorAnyDBField>;\n for (const key in this.fields) {\n if (Object.hasOwn(this.fields, key) && !keysSet.has(key as unknown as K)) {\n result[key] = this.fields[key] as TailorAnyDBField;\n }\n }\n return result as Omit<Fields, K>;\n },\n\n get plugins(): PluginAttachment[] {\n return _plugins;\n },\n\n plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: {\n [K in P]: PluginConfigs<keyof Fields & string>[K];\n }): TailorDBType<Fields, User, AnyBuilderMethod> {\n for (const [pluginId, pluginConfig] of Object.entries(config)) {\n _plugins.push({ pluginId, config: pluginConfig });\n }\n return this;\n },\n };\n\n return brandValue(dbType, \"tailordb-type\");\n}\n\nconst idField = uuid();\ntype idField = typeof idField;\ntype DBTable<\n F extends { id?: never } & Record<string, TailorAnyDBField>,\n Defined extends DefinedDBTypeMetadata = DefinedDBTypeMetadata,\n> = TailorDBInstance<{ id: idField } & F, InferredAttributes, Defined>;\n\n/**\n * Creates a new database table with the specified fields.\n * An `id` field (UUID) is automatically added to every table.\n * @param name - The name of the table, or a tuple of [name, pluralForm]\n * @param fields - The field definitions for the table\n * @returns A new TailorDB table instance\n * @example\n * export const user = db.table(\"User\", {\n * name: db.string(),\n * email: db.string(),\n * age: db.int({ optional: true }),\n * role: db.enum([\"admin\", \"member\"]),\n * ...db.fields.timestamps(),\n * });\n * // Always export both the value and type:\n * export type user = typeof user;\n */\nfunction dbTable<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fields: F,\n): DBTable<F>;\n/**\n * Creates a new database table with the specified fields and description.\n * An `id` field (UUID) is automatically added to every table.\n * @param name - The name of the table, or a tuple of [name, pluralForm]\n * @param description - A description of the table\n * @param fields - The field definitions for the table\n * @returns A new TailorDB table instance\n */\nfunction dbTable<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n description: string,\n fields: F,\n): DBTable<F, WithDBTypeMetadata<DefinedDBTypeMetadata, \"description\">>;\nfunction dbTable<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fieldsOrDescription: string | F,\n fields?: F,\n): DBTable<F> | DBTable<F, WithDBTypeMetadata<DefinedDBTypeMetadata, \"description\">> {\n const typeName = Array.isArray(name) ? name[0] : name;\n const pluralForm = Array.isArray(name) ? name[1] : undefined;\n\n let description: string | undefined;\n let fieldDef: F;\n if (typeof fieldsOrDescription === \"string\") {\n description = fieldsOrDescription;\n fieldDef = fields as F;\n } else {\n fieldDef = fieldsOrDescription;\n }\n return createTailorDBType<{ id: idField } & F>(\n typeName,\n {\n id: idField,\n ...fieldDef,\n },\n { pluralForm, description },\n ) as DBTable<F>;\n}\n\n/** TailorDB schema builder utilities for defining tables and fields. */\nexport const db = {\n table: dbTable,\n uuid,\n string,\n bool,\n int,\n float,\n decimal,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n fields: {\n /**\n * Creates standard timestamp fields (createdAt, updatedAt) with automatic defaults.\n * Both fields default to the current time on create. updatedAt is also refreshed on update.\n * User-specified values are respected when provided (e.g. seeding historical records).\n * @returns An object with createdAt and updatedAt fields\n * @example\n * const model = db.table(\"Model\", {\n * name: db.string(),\n * ...db.fields.timestamps(),\n * });\n */\n timestamps: () => ({\n createdAt: datetime().default(\"now\").description(\"Record creation timestamp\"),\n updatedAt: datetime()\n .default(\"now\")\n .hooks({ update: ({ input, now }) => input ?? now })\n .description(\"Record update timestamp\"),\n }),\n },\n};\n"],"mappings":";;;;AAIA,MAAM,QAAQ;CACZ,MAAM;CACN,MAAM;CACN,MAAM;CACN,UACE;CACF,SAAS;AACX;AA6BA,SAAS,kBAA6C,MAAuC;CAC3F,MAAM,EAAE,OAAO,OAAO,WAAW,WAAW;CAC5C,MAAM,OAAO,UAAU,SAAS,IAAI,YAAY;CAChD,MAAM,oBAAoB,OAAO;CAEjC,QAAQ,MAAM,MAAd;EACE,KAAK;GACH,IAAI,OAAO,UAAU,UACnB,OAAO,KAAK;IACV,SAAS,+BAA+B,OAAO,KAAK;IACpD;GACF,CAAC;GAEH;EAEF,KAAK;GACH,IAAI,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,OAAO,KAAK,QACrB,IAAI,OAAO,OAAO,KAAK,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,GAAmB,GACrE,OAAO,OAAO,KAAK,OAAO;GAG9B,OAAO;EACT;EAEA,IAAI,UAA8B;GAChC,OAAO;EACT;EAEA,OAA6D,QAEZ;GAC/C,KAAK,MAAM,CAAC,UAAU,iBAAiB,OAAO,QAAQ,MAAM,GAC1D,SAAS,KAAK;IAAE;IAAU,QAAQ;GAAa,CAAC;GAElD,OAAO;EACT;CAGqB,GAAG,eAAe;AAC3C;AAEA,MAAM,UAAU,KAAK;AAyCrB,SAAS,QACP,MACA,qBACA,QACmF;CACnF,MAAM,WAAW,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK;CACjD,MAAM,aAAa,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK;CAEnD,IAAI;CACJ,IAAI;CACJ,IAAI,OAAO,wBAAwB,UAAU;EAC3C,cAAc;EACd,WAAW;CACb,OACE,WAAW;CAEb,OAAO,mBACL,UACA;EACE,IAAI;EACJ,GAAG;CACL,GACA;EAAE;EAAY;CAAY,CAC5B;AACF;;AAGA,MAAa,KAAK;CAChB,OAAO;CACP;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;CACA,QAAQ;;;;;;;;;;;;AAYN,mBAAmB;EACjB,WAAW,SAAS,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,YAAY,2BAA2B;EAC5E,WAAW,SAAS,CAAC,CAClB,QAAQ,KAAK,CAAC,CACd,MAAM,EAAE,SAAS,EAAE,OAAO,UAAU,SAAS,IAAI,CAAC,CAAC,CACnD,YAAY,yBAAyB;CAC1C,GACF;AACF"}
@@ -1,5 +1,5 @@
1
- import * as fs from "node:fs";
2
1
  import * as path from "pathe";
2
+ import * as fs from "node:fs";
3
3
 
4
4
  //#region src/cli/shared/secret-file.ts
5
5
  const DIR_MODE = 448;
@@ -61,4 +61,4 @@ function tightenSecretFilePermissions(filePath) {
61
61
 
62
62
  //#endregion
63
63
  export { tightenSecretFilePermissions as n, writeSecretFile as r, ensureSecretDir as t };
64
- //# sourceMappingURL=secret-file-DBqZhjFQ.mjs.map
64
+ //# sourceMappingURL=secret-file-C3J4Gy8r.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"secret-file-DBqZhjFQ.mjs","names":[],"sources":["../src/cli/shared/secret-file.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\n\nconst DIR_MODE = 0o700;\nconst FILE_MODE = 0o600;\n\n/**\n * Best-effort chmod that only fires when the current mode differs from the\n * target. No-op on Windows (where POSIX mode bits are advisory and ACLs\n * govern access) and on missing paths / permission errors.\n * @param target - Path to chmod\n * @param mode - Desired POSIX mode bits\n */\nfunction chmodIfDifferent(target: string, mode: number): void {\n if (process.platform === \"win32\") return;\n try {\n if ((fs.statSync(target).mode & 0o777) !== mode) {\n fs.chmodSync(target, mode);\n }\n } catch {\n // Missing path or permission error — best-effort.\n }\n}\n\n/**\n * Write a file that may contain secrets with restrictive permissions.\n * Creates the parent directory with 0o700 and the file with 0o600 on POSIX\n * systems so other users on the host cannot read access tokens, refresh\n * tokens, or crash report payloads. On Windows the POSIX mode bits are\n * effectively ignored and ACLs govern access, so the chmod calls are\n * best-effort and silently skipped.\n * @param filePath - Absolute path to write\n * @param content - File content\n */\nexport function writeSecretFile(filePath: string, content: string | Buffer): void {\n ensureSecretDir(path.dirname(filePath));\n fs.writeFileSync(filePath, content, { mode: FILE_MODE });\n chmodIfDifferent(filePath, FILE_MODE);\n}\n\n/**\n * Ensure a directory exists with 0o700 permissions on POSIX systems.\n * `mkdirSync({ recursive: true })` does not chmod existing directories,\n * so this also tightens permissions on directories that were previously\n * created with looser modes.\n * @param dir - Directory path\n */\nexport function ensureSecretDir(dir: string): void {\n fs.mkdirSync(dir, { recursive: true, mode: DIR_MODE });\n chmodIfDifferent(dir, DIR_MODE);\n}\n\n/**\n * Tighten an existing file and its parent directory to secret-file modes\n * (0o600 / 0o700) if they are looser. Used by read paths that may not\n * trigger a subsequent write, so that legacy world-readable files are\n * still secured the next time the CLI runs. Silent no-op on Windows and\n * on missing files / permission errors.\n * @param filePath - Absolute path that should be 0o600 and live under a 0o700 directory\n */\nexport function tightenSecretFilePermissions(filePath: string): void {\n chmodIfDifferent(filePath, FILE_MODE);\n chmodIfDifferent(path.dirname(filePath), DIR_MODE);\n}\n"],"mappings":";;;;AAGA,MAAM,WAAW;AACjB,MAAM,YAAY;;;;;;;;AASlB,SAAS,iBAAiB,QAAgB,MAAoB;CAC5D,IAAI,QAAQ,aAAa,SAAS;CAClC,IAAI;EACF,KAAK,GAAG,SAAS,MAAM,CAAC,CAAC,OAAO,SAAW,MACzC,GAAG,UAAU,QAAQ,IAAI;CAE7B,QAAQ,CAER;AACF;;;;;;;;;;;AAYA,SAAgB,gBAAgB,UAAkB,SAAgC;CAChF,gBAAgB,KAAK,QAAQ,QAAQ,CAAC;CACtC,GAAG,cAAc,UAAU,SAAS,EAAE,MAAM,UAAU,CAAC;CACvD,iBAAiB,UAAU,SAAS;AACtC;;;;;;;;AASA,SAAgB,gBAAgB,KAAmB;CACjD,GAAG,UAAU,KAAK;EAAE,WAAW;EAAM,MAAM;CAAS,CAAC;CACrD,iBAAiB,KAAK,QAAQ;AAChC;;;;;;;;;AAUA,SAAgB,6BAA6B,UAAwB;CACnE,iBAAiB,UAAU,SAAS;CACpC,iBAAiB,KAAK,QAAQ,QAAQ,GAAG,QAAQ;AACnD"}
1
+ {"version":3,"file":"secret-file-C3J4Gy8r.mjs","names":[],"sources":["../src/cli/shared/secret-file.ts"],"sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\n\nconst DIR_MODE = 0o700;\nconst FILE_MODE = 0o600;\n\n/**\n * Best-effort chmod that only fires when the current mode differs from the\n * target. No-op on Windows (where POSIX mode bits are advisory and ACLs\n * govern access) and on missing paths / permission errors.\n * @param target - Path to chmod\n * @param mode - Desired POSIX mode bits\n */\nfunction chmodIfDifferent(target: string, mode: number): void {\n if (process.platform === \"win32\") return;\n try {\n if ((fs.statSync(target).mode & 0o777) !== mode) {\n fs.chmodSync(target, mode);\n }\n } catch {\n // Missing path or permission error — best-effort.\n }\n}\n\n/**\n * Write a file that may contain secrets with restrictive permissions.\n * Creates the parent directory with 0o700 and the file with 0o600 on POSIX\n * systems so other users on the host cannot read access tokens, refresh\n * tokens, or crash report payloads. On Windows the POSIX mode bits are\n * effectively ignored and ACLs govern access, so the chmod calls are\n * best-effort and silently skipped.\n * @param filePath - Absolute path to write\n * @param content - File content\n */\nexport function writeSecretFile(filePath: string, content: string | Buffer): void {\n ensureSecretDir(path.dirname(filePath));\n fs.writeFileSync(filePath, content, { mode: FILE_MODE });\n chmodIfDifferent(filePath, FILE_MODE);\n}\n\n/**\n * Ensure a directory exists with 0o700 permissions on POSIX systems.\n * `mkdirSync({ recursive: true })` does not chmod existing directories,\n * so this also tightens permissions on directories that were previously\n * created with looser modes.\n * @param dir - Directory path\n */\nexport function ensureSecretDir(dir: string): void {\n fs.mkdirSync(dir, { recursive: true, mode: DIR_MODE });\n chmodIfDifferent(dir, DIR_MODE);\n}\n\n/**\n * Tighten an existing file and its parent directory to secret-file modes\n * (0o600 / 0o700) if they are looser. Used by read paths that may not\n * trigger a subsequent write, so that legacy world-readable files are\n * still secured the next time the CLI runs. Silent no-op on Windows and\n * on missing files / permission errors.\n * @param filePath - Absolute path that should be 0o600 and live under a 0o700 directory\n */\nexport function tightenSecretFilePermissions(filePath: string): void {\n chmodIfDifferent(filePath, FILE_MODE);\n chmodIfDifferent(path.dirname(filePath), DIR_MODE);\n}\n"],"mappings":";;;;AAGA,MAAM,WAAW;AACjB,MAAM,YAAY;;;;;;;;AASlB,SAAS,iBAAiB,QAAgB,MAAoB;CAC5D,IAAI,QAAQ,aAAa,SAAS;CAClC,IAAI;EACF,KAAK,GAAG,SAAS,MAAM,CAAC,CAAC,OAAO,SAAW,MACzC,GAAG,UAAU,QAAQ,IAAI;CAE7B,QAAQ,CAER;AACF;;;;;;;;;;;AAYA,SAAgB,gBAAgB,UAAkB,SAAgC;CAChF,gBAAgB,KAAK,QAAQ,QAAQ,CAAC;CACtC,GAAG,cAAc,UAAU,SAAS,EAAE,MAAM,UAAU,CAAC;CACvD,iBAAiB,UAAU,SAAS;AACtC;;;;;;;;AASA,SAAgB,gBAAgB,KAAmB;CACjD,GAAG,UAAU,KAAK;EAAE,WAAW;EAAM,MAAM;CAAS,CAAC;CACrD,iBAAiB,KAAK,QAAQ;AAChC;;;;;;;;;AAUA,SAAgB,6BAA6B,UAAwB;CACnE,iBAAiB,UAAU,SAAS;CACpC,iBAAiB,KAAK,QAAQ,QAAQ,GAAG,QAAQ;AACnD"}
@@ -0,0 +1,13 @@
1
+ //#region src/runtime/secretmanager.ts
2
+ const api = () => globalThis.tailor.secretmanager;
3
+ const getSecrets = (...args) => api().getSecrets(...args);
4
+ const getSecret = (...args) => api().getSecret(...args);
5
+ /** Runtime wrapper namespace for `tailor.secretmanager`. */
6
+ const secretmanager = {
7
+ getSecrets,
8
+ getSecret
9
+ };
10
+
11
+ //#endregion
12
+ export { secretmanager as t };
13
+ //# sourceMappingURL=secretmanager-CYlpffsz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretmanager-CYlpffsz.mjs","names":[],"sources":["../src/runtime/secretmanager.ts"],"sourcesContent":["/**\n * Secret manager utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.secretmanager` runtime API.\n * At runtime this delegates to `globalThis.tailor.secretmanager`. Use\n * `mockSecretmanager` from `@tailor-platform/sdk/vitest` to mock these calls\n * in unit tests.\n * @example\n * import { secretmanager } from \"@tailor-platform/sdk/runtime\";\n *\n * const apiKey = await secretmanager.getSecret(\"my-vault\", \"API_KEY\");\n * const all = await secretmanager.getSecrets(\"my-vault\", [\"A\", \"B\"] as const);\n */\n\n/**\n * Platform API surface for `tailor.secretmanager`. Describes the shape the\n * platform runtime injects on `globalThis.tailor.secretmanager`.\n */\nexport interface TailorSecretmanagerAPI {\n /**\n * Returns multiple secrets from a vault. Missing names are omitted from the result.\n * @param vault - Vault name\n * @param names - Secret names to fetch (use `as const` to narrow the result key)\n * @returns Partial record keyed by the requested names\n */\n getSecrets<const T extends readonly string[]>(\n vault: string,\n names: T,\n ): Promise<Partial<Record<T[number], string>>>;\n\n /**\n * Returns a single secret from a vault, or `undefined` when missing.\n * @param vault - Vault name\n * @param name - Secret name\n * @returns The secret value, or `undefined` if not present\n */\n getSecret(vault: string, name: string): Promise<string | undefined>;\n}\n\nconst api = (): TailorSecretmanagerAPI =>\n (globalThis as unknown as { tailor: { secretmanager: TailorSecretmanagerAPI } }).tailor\n .secretmanager;\n\nconst getSecrets: TailorSecretmanagerAPI[\"getSecrets\"] = (...args) => api().getSecrets(...args);\n\nconst getSecret: TailorSecretmanagerAPI[\"getSecret\"] = (...args) => api().getSecret(...args);\n\n/** Runtime wrapper namespace for `tailor.secretmanager`. */\nexport const secretmanager = {\n getSecrets,\n getSecret,\n} as const satisfies TailorSecretmanagerAPI;\n"],"mappings":";AAuCA,MAAM,YACH,WAAgF,OAC9E;AAEL,MAAM,cAAoD,GAAG,SAAS,IAAI,CAAC,CAAC,WAAW,GAAG,IAAI;AAE9F,MAAM,aAAkD,GAAG,SAAS,IAAI,CAAC,CAAC,UAAU,GAAG,IAAI;;AAG3F,MAAa,gBAAgB;CAC3B;CACA;AACF"}
@@ -0,0 +1,131 @@
1
+ import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
2
+ import { vi } from "vitest";
3
+
4
+ //#region src/vitest/mocks/shared.ts
5
+ function withDispose(facade, dispose) {
6
+ Object.defineProperty(facade, Symbol.dispose, {
7
+ value: dispose,
8
+ enumerable: false,
9
+ writable: true,
10
+ configurable: true
11
+ });
12
+ return facade;
13
+ }
14
+ function tailorRoot() {
15
+ const g = globalThis;
16
+ if (!g.tailor) g.tailor = { context: { getInvoker: () => null } };
17
+ return g.tailor;
18
+ }
19
+ function tailordbRoot() {
20
+ const g = globalThis;
21
+ if (!g.tailordb) g.tailordb = {};
22
+ return g.tailordb;
23
+ }
24
+
25
+ //#endregion
26
+ //#region src/vitest/mocks/secretmanager.ts
27
+ const SECRET_STORE = Symbol("tailorSecretStore");
28
+ /**
29
+ * Acquire a disposable mock for `tailor.secretmanager`. The secret store is
30
+ * inherited (cloned) from the currently-installed mock on acquisition and
31
+ * restored on dispose, so secrets seeded outside the test survive across
32
+ * `using` scopes while per-test `setSecrets()` overrides stay isolated.
33
+ * @param options - Initial Secret Manager fixtures
34
+ * @returns Disposable SecretManager mock control object
35
+ * @example
36
+ * ```typescript
37
+ * import { mockSecretmanager } from "@tailor-platform/sdk/vitest";
38
+ *
39
+ * test("reads secrets from vault", async () => {
40
+ * using sm = mockSecretmanager({ secrets: { "my-vault": { API_KEY: "sk-123" } } });
41
+ * sm.setSecret("my-vault", "API_KEY", "replacement");
42
+ * // …
43
+ * });
44
+ * ```
45
+ */
46
+ function mockSecretmanager(options = {}) {
47
+ const root = tailorRoot();
48
+ const prev = root.secretmanager;
49
+ const holder = { store: structuredClone(prev?.[SECRET_STORE]?.store ?? {}) };
50
+ for (const [vault, secrets] of Object.entries(options.secrets ?? {})) holder.store[vault] = {
51
+ ...holder.store[vault],
52
+ ...secrets
53
+ };
54
+ async function defaultGetSecret(vault, name) {
55
+ return holder.store[vault]?.[name];
56
+ }
57
+ async function defaultGetSecrets(vault, names) {
58
+ const vaultData = holder.store[vault] ?? {};
59
+ const result = {};
60
+ for (const name of names) if (name in vaultData) result[name] = assertDefined(vaultData[name], `vault entry missing for: ${name}`);
61
+ return result;
62
+ }
63
+ const getSecret = vi.fn(defaultGetSecret);
64
+ const getSecrets = vi.fn(defaultGetSecrets);
65
+ root.secretmanager = {
66
+ getSecret,
67
+ getSecrets,
68
+ [SECRET_STORE]: holder
69
+ };
70
+ return withDispose({
71
+ /** The `getSecret` `vi.fn`. */
72
+ getSecret,
73
+ /** The `getSecrets` `vi.fn`. */
74
+ getSecrets,
75
+ setSecrets(secrets) {
76
+ holder.store = secrets;
77
+ },
78
+ setSecret(vault, name, value) {
79
+ holder.store = {
80
+ ...holder.store,
81
+ [vault]: {
82
+ ...holder.store[vault],
83
+ [name]: value
84
+ }
85
+ };
86
+ },
87
+ mergeSecrets(vault, secrets) {
88
+ holder.store = {
89
+ ...holder.store,
90
+ [vault]: {
91
+ ...holder.store[vault],
92
+ ...secrets
93
+ }
94
+ };
95
+ },
96
+ get calls() {
97
+ return [...getSecret.mock.calls.map((args, i) => ({
98
+ order: getSecret.mock.invocationCallOrder[i] ?? 0,
99
+ call: {
100
+ method: "getSecret",
101
+ vault: args[0],
102
+ name: args[1]
103
+ }
104
+ })), ...getSecrets.mock.calls.map((args, i) => ({
105
+ order: getSecrets.mock.invocationCallOrder[i] ?? 0,
106
+ call: {
107
+ method: "getSecrets",
108
+ vault: args[0],
109
+ names: args[1]
110
+ }
111
+ }))].toSorted((a, b) => a.order - b.order).map((e) => e.call);
112
+ },
113
+ clear() {
114
+ getSecret.mockClear();
115
+ getSecrets.mockClear();
116
+ },
117
+ reset() {
118
+ holder.store = {};
119
+ getSecret.mockReset();
120
+ getSecret.mockImplementation(defaultGetSecret);
121
+ getSecrets.mockReset();
122
+ getSecrets.mockImplementation(defaultGetSecrets);
123
+ }
124
+ }, () => {
125
+ root.secretmanager = prev;
126
+ });
127
+ }
128
+
129
+ //#endregion
130
+ export { withDispose as i, tailorRoot as n, tailordbRoot as r, mockSecretmanager as t };
131
+ //# sourceMappingURL=secretmanager-IY4UvinW.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secretmanager-IY4UvinW.mjs","names":[],"sources":["../src/vitest/mocks/shared.ts","../src/vitest/mocks/secretmanager.ts"],"sourcesContent":["// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\n// Attach a non-enumerable `Symbol.dispose` to a facade so it works with `using`.\nexport function withDispose<T extends object>(facade: T, dispose: () => void): T & Disposable {\n Object.defineProperty(facade, Symbol.dispose, {\n value: dispose,\n enumerable: false,\n writable: true,\n configurable: true,\n });\n return facade as T & Disposable;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function tailorRoot(): Record<string, any> {\n const g = globalThis as Record<string, unknown>;\n if (!g.tailor) {\n // Ensure the container (and the always-present context stub) exists even if\n // the base globals were not installed (e.g. a unit test that only acquires\n // a single mock without the tailor-runtime environment).\n g.tailor = { context: { getInvoker: () => null } };\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return g.tailor as Record<string, any>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function tailordbRoot(): Record<string, any> {\n const g = globalThis as Record<string, unknown>;\n if (!g.tailordb) {\n g.tailordb = {};\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return g.tailordb as Record<string, any>;\n}\n","import { vi } from \"vitest\";\nimport { assertDefined } from \"#/utils/assert\";\nimport { tailorRoot, withDispose } from \"./shared\";\n\ninterface SecretCall {\n method: \"getSecret\" | \"getSecrets\";\n vault: string;\n name?: string;\n names?: readonly string[];\n}\n\n/** Initial fixtures for a Secret Manager mock. */\nexport interface MockSecretmanagerOptions {\n /** Secrets to merge over fixtures inherited from the currently installed mock. */\n secrets?: Record<string, Record<string, string>>;\n}\n\n// ---------------------------------------------------------------------------\n// SecretManager Mock\n// ---------------------------------------------------------------------------\n\n// Hidden accessor key used to inherit the previous scope's secret store on\n// acquisition (so secrets seeded once outside tests — e.g. from tailor.config.ts\n// via setup.ts — remain visible) while still isolating per-test overrides.\nconst SECRET_STORE = Symbol(\"tailorSecretStore\");\n\n/**\n * Acquire a disposable mock for `tailor.secretmanager`. The secret store is\n * inherited (cloned) from the currently-installed mock on acquisition and\n * restored on dispose, so secrets seeded outside the test survive across\n * `using` scopes while per-test `setSecrets()` overrides stay isolated.\n * @param options - Initial Secret Manager fixtures\n * @returns Disposable SecretManager mock control object\n * @example\n * ```typescript\n * import { mockSecretmanager } from \"@tailor-platform/sdk/vitest\";\n *\n * test(\"reads secrets from vault\", async () => {\n * using sm = mockSecretmanager({ secrets: { \"my-vault\": { API_KEY: \"sk-123\" } } });\n * sm.setSecret(\"my-vault\", \"API_KEY\", \"replacement\");\n * // …\n * });\n * ```\n */\nexport function mockSecretmanager(options: MockSecretmanagerOptions = {}) {\n const root = tailorRoot();\n const prev = root.secretmanager;\n\n const holder: { store: Record<string, Record<string, string>> } = {\n // prior mock state may be absent\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n store: structuredClone((prev?.[SECRET_STORE]?.store as typeof holder.store) ?? {}),\n };\n for (const [vault, secrets] of Object.entries(options.secrets ?? {})) {\n holder.store[vault] = { ...holder.store[vault], ...secrets };\n }\n\n async function defaultGetSecret(vault: string, name: string): Promise<string | undefined> {\n return holder.store[vault]?.[name];\n }\n\n async function defaultGetSecrets<const T extends readonly string[]>(\n vault: string,\n names: T,\n ): Promise<Partial<Record<T[number], string>>> {\n const vaultData = holder.store[vault] ?? {};\n const result: Record<string, string> = {};\n for (const name of names) {\n if (name in vaultData) {\n result[name] = assertDefined(vaultData[name], `vault entry missing for: ${name}`);\n }\n }\n return result as Partial<Record<T[number], string>>;\n }\n\n const getSecret = vi.fn(defaultGetSecret);\n const getSecrets = vi.fn(defaultGetSecrets);\n\n root.secretmanager = { getSecret, getSecrets, [SECRET_STORE]: holder };\n\n const facade = {\n /** The `getSecret` `vi.fn`. */\n getSecret,\n /** The `getSecrets` `vi.fn`. */\n getSecrets,\n\n setSecrets(secrets: Record<string, Record<string, string>>): void {\n holder.store = secrets;\n },\n\n setSecret(vault: string, name: string, value: string): void {\n holder.store = {\n ...holder.store,\n [vault]: { ...holder.store[vault], [name]: value },\n };\n },\n\n mergeSecrets(vault: string, secrets: Record<string, string>): void {\n holder.store = {\n ...holder.store,\n [vault]: { ...holder.store[vault], ...secrets },\n };\n },\n\n get calls(): SecretCall[] {\n // Merge both methods' calls back into chronological order via vi.fn's\n // global invocationCallOrder, so a test mixing getSecret/getSecrets sees\n // them in the order they actually ran (not all getSecret, then all getSecrets).\n const entries: { order: number; call: SecretCall }[] = [\n ...getSecret.mock.calls.map((args, i) => ({\n order: getSecret.mock.invocationCallOrder[i] ?? 0,\n call: { method: \"getSecret\" as const, vault: args[0] as string, name: args[1] as string },\n })),\n ...getSecrets.mock.calls.map((args, i) => ({\n order: getSecrets.mock.invocationCallOrder[i] ?? 0,\n call: {\n method: \"getSecrets\" as const,\n vault: args[0] as string,\n names: args[1] as readonly string[],\n },\n })),\n ];\n return entries.toSorted((a, b) => a.order - b.order).map((e) => e.call);\n },\n\n clear(): void {\n getSecret.mockClear();\n getSecrets.mockClear();\n },\n\n reset(): void {\n holder.store = {};\n getSecret.mockReset();\n getSecret.mockImplementation(defaultGetSecret);\n getSecrets.mockReset();\n getSecrets.mockImplementation(defaultGetSecrets);\n },\n };\n\n return withDispose(facade, () => {\n root.secretmanager = prev;\n });\n}\n"],"mappings":";;;;AAKA,SAAgB,YAA8B,QAAW,SAAqC;CAC5F,OAAO,eAAe,QAAQ,OAAO,SAAS;EAC5C,OAAO;EACP,YAAY;EACZ,UAAU;EACV,cAAc;CAChB,CAAC;CACD,OAAO;AACT;AAGA,SAAgB,aAAkC;CAChD,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,QAIL,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,KAAK,EAAE;CAGnD,OAAO,EAAE;AACX;AAGA,SAAgB,eAAoC;CAClD,MAAM,IAAI;CACV,IAAI,CAAC,EAAE,UACL,EAAE,WAAW,CAAC;CAGhB,OAAO,EAAE;AACX;;;;ACZA,MAAM,eAAe,OAAO,mBAAmB;;;;;;;;;;;;;;;;;;;AAoB/C,SAAgB,kBAAkB,UAAoC,CAAC,GAAG;CACxE,MAAM,OAAO,WAAW;CACxB,MAAM,OAAO,KAAK;CAElB,MAAM,SAA4D,EAGhE,OAAO,gBAAiB,OAAO,aAAa,EAAE,SAAiC,CAAC,CAAC,EACnF;CACA,KAAK,MAAM,CAAC,OAAO,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F,EAAE,CAES,CAAC,CAAC,UAAU,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,KAAK,MAAM,EAAE,IAAI;EACxE;EAEA,QAAc;GACZ,UAAU,UAAU;GACpB,WAAW,UAAU;EACvB;EAEA,QAAc;GACZ,OAAO,QAAQ,CAAC;GAChB,UAAU,UAAU;GACpB,UAAU,mBAAmB,gBAAgB;GAC7C,WAAW,UAAU;GACrB,WAAW,mBAAmB,iBAAiB;EACjD;CAGsB,SAAS;EAC/B,KAAK,gBAAgB;CACvB,CAAC;AACH"}
@@ -1,8 +1,9 @@
1
1
  import { ForeignKeyDefinition, IndexDefinition, defineSchema } from "@toiroakr/lines-db";
2
-
3
2
  //#region src/seed/index.d.ts
4
3
  type ValidateSeedDataOptions = {
5
- /** Resolved absolute path to a data directory or a .jsonl file */path: string; /** Show verbose error output */
4
+ /** Resolved absolute path to a data directory or a .jsonl file */
5
+ path: string;
6
+ /** Show verbose error output */
6
7
  verbose?: boolean;
7
8
  };
8
9
  type ValidateSeedResult = {
@@ -22,5 +23,4 @@ type ValidateSeedResult = {
22
23
  */
23
24
  declare function validateSeedData(options: ValidateSeedDataOptions): Promise<ValidateSeedResult>;
24
25
  //#endregion
25
- export { type ForeignKeyDefinition, type IndexDefinition, defineSchema, validateSeedData };
26
- //# sourceMappingURL=index.d.mts.map
26
+ export { type ForeignKeyDefinition, type IndexDefinition, defineSchema, validateSeedData };