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

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 (471) hide show
  1. package/CHANGELOG.md +869 -2
  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-DArFTTJ9.mjs +3 -0
  7. package/dist/{application-DqS1yBg3.mjs → application-miwiXtB4.mjs} +1892 -1968
  8. package/dist/application-miwiXtB4.mjs.map +1 -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 +34 -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 +7 -0
  25. package/dist/cli/commands/deploy/idp.d.mts +5 -0
  26. package/dist/cli/commands/deploy/resolver.d.mts +5 -0
  27. package/dist/cli/commands/deploy/secret-manager.d.mts +5 -0
  28. package/dist/cli/commands/deploy/staticwebsite.d.mts +5 -0
  29. package/dist/cli/commands/deploy/tailordb/index.d.mts +9 -0
  30. package/dist/cli/commands/deploy/types.d.mts +3 -0
  31. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +3 -0
  32. package/dist/cli/commands/deploy/workflow.d.mts +4 -0
  33. package/dist/cli/commands/executor/get.d.mts +28 -0
  34. package/dist/cli/commands/executor/jobs.d.mts +122 -0
  35. package/dist/cli/commands/executor/list.d.mts +18 -0
  36. package/dist/cli/commands/executor/transform.d.mts +42 -0
  37. package/dist/cli/commands/executor/trigger.d.mts +40 -0
  38. package/dist/cli/commands/executor/webhook.d.mts +21 -0
  39. package/dist/cli/commands/function/get.d.mts +17 -0
  40. package/dist/cli/commands/function/list.d.mts +21 -0
  41. package/dist/cli/commands/function/transform.d.mts +12 -0
  42. package/dist/cli/commands/generate/options.d.mts +6 -0
  43. package/dist/cli/commands/generate/seed/bundler.d.mts +26 -0
  44. package/dist/cli/commands/generate/service.d.mts +15 -0
  45. package/dist/cli/commands/machineuser/list.d.mts +26 -0
  46. package/dist/cli/commands/machineuser/token.d.mts +21 -0
  47. package/dist/cli/commands/oauth2client/get.d.mts +17 -0
  48. package/dist/cli/commands/oauth2client/list.d.mts +19 -0
  49. package/dist/cli/commands/oauth2client/transform.d.mts +21 -0
  50. package/dist/cli/commands/organization/folder/create.d.mts +17 -0
  51. package/dist/cli/commands/organization/folder/delete.d.mts +15 -0
  52. package/dist/cli/commands/organization/folder/get.d.mts +16 -0
  53. package/dist/cli/commands/organization/folder/list.d.mts +21 -0
  54. package/dist/cli/commands/organization/folder/update.d.mts +17 -0
  55. package/dist/cli/commands/organization/get.d.mts +15 -0
  56. package/dist/cli/commands/organization/list.d.mts +14 -0
  57. package/dist/cli/commands/organization/transform.d.mts +29 -0
  58. package/dist/cli/commands/organization/tree.d.mts +24 -0
  59. package/dist/cli/commands/organization/update.d.mts +16 -0
  60. package/dist/cli/commands/remove.d.mts +15 -0
  61. package/dist/cli/commands/show.d.mts +39 -0
  62. package/dist/cli/commands/staticwebsite/deploy.d.mts +19 -0
  63. package/dist/cli/commands/tailordb/migrate/bundler.d.mts +29 -0
  64. package/dist/cli/commands/tailordb/migrate/config.d.mts +18 -0
  65. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +246 -0
  66. package/dist/cli/commands/tailordb/migrate/generate.d.mts +16 -0
  67. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +208 -0
  68. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +98 -0
  69. package/dist/cli/commands/tailordb/migrate/types.d.mts +7 -0
  70. package/dist/cli/commands/tailordb/truncate.d.mts +18 -0
  71. package/dist/cli/commands/workflow/executions.d.mts +74 -0
  72. package/dist/cli/commands/workflow/get.d.mts +30 -0
  73. package/dist/cli/commands/workflow/list.d.mts +18 -0
  74. package/dist/cli/commands/workflow/resume.d.mts +22 -0
  75. package/dist/cli/commands/workflow/start.d.mts +60 -0
  76. package/dist/cli/commands/workflow/status.d.mts +6 -0
  77. package/dist/cli/commands/workflow/transform.d.mts +34 -0
  78. package/dist/cli/commands/workflow/wait.d.mts +15 -0
  79. package/dist/cli/commands/workflow/waiter.d.mts +23 -0
  80. package/dist/cli/commands/workspace/app/health.d.mts +17 -0
  81. package/dist/cli/commands/workspace/app/list.d.mts +21 -0
  82. package/dist/cli/commands/workspace/app/transform.d.mts +20 -0
  83. package/dist/cli/commands/workspace/create.d.mts +27 -0
  84. package/dist/cli/commands/workspace/delete.d.mts +14 -0
  85. package/dist/cli/commands/workspace/get.d.mts +16 -0
  86. package/dist/cli/commands/workspace/list.d.mts +17 -0
  87. package/dist/cli/commands/workspace/restore.d.mts +14 -0
  88. package/dist/cli/commands/workspace/transform.d.mts +20 -0
  89. package/dist/cli/commands/workspace/user/invite.d.mts +21 -0
  90. package/dist/cli/commands/workspace/user/list.d.mts +21 -0
  91. package/dist/cli/commands/workspace/user/remove.d.mts +16 -0
  92. package/dist/cli/commands/workspace/user/transform.d.mts +9 -0
  93. package/dist/cli/commands/workspace/user/update.d.mts +21 -0
  94. package/dist/cli/index.mjs +12 -5481
  95. package/dist/cli/lib.d.mts +90 -21048
  96. package/dist/cli/lib.mjs +154 -12
  97. package/dist/cli/lib.mjs.map +1 -1
  98. package/dist/cli/main.d.mts +23 -0
  99. package/dist/cli/main.mjs +6583 -0
  100. package/dist/cli/main.mjs.map +1 -0
  101. package/dist/cli/query/index.d.mts +38 -0
  102. package/dist/cli/services/application.d.mts +12 -0
  103. package/dist/cli/services/auth/service.d.mts +3 -0
  104. package/dist/cli/services/executor/service.d.mts +1 -0
  105. package/dist/cli/services/http-adapter/bundler.d.mts +3 -0
  106. package/dist/cli/services/http-adapter/service.d.mts +2 -0
  107. package/dist/cli/services/resolver/service.d.mts +1 -0
  108. package/dist/cli/services/tailordb/service.d.mts +3 -0
  109. package/dist/cli/services/workflow/bundler.d.mts +2 -0
  110. package/dist/cli/services/workflow/service.d.mts +1 -0
  111. package/dist/cli/shared/args.d.mts +13 -0
  112. package/dist/cli/shared/client.d.mts +1273 -0
  113. package/dist/cli/shared/config-loader.d.mts +25 -0
  114. package/dist/cli/shared/context.d.mts +29 -0
  115. package/dist/cli/shared/error-json.d.mts +23 -0
  116. package/dist/cli/shared/readonly-guard.d.mts +25 -0
  117. package/dist/cli/shared/script-executor.d.mts +77 -0
  118. package/dist/cli/shared/seed-chunker.d.mts +45 -0
  119. package/dist/cli/shared/seed-context.d.mts +49 -0
  120. package/dist/cli/shared/tailordb-namespaces.d.mts +40 -0
  121. package/dist/cli/shared/type-generator.d.mts +19 -0
  122. package/dist/cli/shared/workspace-name.d.mts +1 -0
  123. package/dist/cli/ts-hook.d.mts +4 -0
  124. package/dist/cli/ts-hook.mjs +333 -0
  125. package/dist/completion/zsh-worker.zsh +1433 -1239
  126. package/dist/configure/config/index.d.mts +20 -0
  127. package/dist/configure/config/types.d.mts +111 -0
  128. package/dist/configure/index.d.mts +135 -8
  129. package/dist/configure/index.mjs +390 -36
  130. package/dist/configure/index.mjs.map +1 -1
  131. package/dist/configure/services/aigateway/index.d.mts +16 -0
  132. package/dist/configure/services/aigateway/types.d.mts +10 -0
  133. package/dist/configure/services/auth/index.d.mts +33 -0
  134. package/dist/configure/services/auth/types.d.mts +168 -0
  135. package/dist/configure/services/executor/executor.d.mts +70 -0
  136. package/dist/configure/services/executor/index.d.mts +9 -0
  137. package/dist/configure/services/executor/operation.d.mts +50 -0
  138. package/dist/configure/services/executor/trigger/event.d.mts +271 -0
  139. package/dist/configure/services/executor/trigger/index.d.mts +7 -0
  140. package/dist/configure/services/executor/trigger/schedule.d.mts +24 -0
  141. package/dist/configure/services/executor/trigger/webhook.d.mts +43 -0
  142. package/dist/configure/services/executor/types.d.mts +2 -0
  143. package/dist/configure/services/http-adapter/http-adapter.d.mts +124 -0
  144. package/dist/configure/services/http-adapter/index.d.mts +2 -0
  145. package/dist/configure/services/idp/index.d.mts +60 -0
  146. package/dist/configure/services/idp/permission.d.mts +64 -0
  147. package/dist/configure/services/idp/types.d.mts +23 -0
  148. package/dist/configure/services/index.d.mts +40 -0
  149. package/dist/configure/services/resolver/index.d.mts +6 -0
  150. package/dist/configure/services/resolver/permission.d.mts +64 -0
  151. package/dist/configure/services/resolver/resolver.d.mts +88 -0
  152. package/dist/configure/services/resolver/types.d.mts +5 -0
  153. package/dist/configure/services/secrets/index.d.mts +37 -0
  154. package/dist/configure/services/secrets/types.d.mts +10 -0
  155. package/dist/configure/services/staticwebsite/index.d.mts +18 -0
  156. package/dist/configure/services/staticwebsite/types.d.mts +10 -0
  157. package/dist/configure/services/tailordb/index.d.mts +4 -0
  158. package/dist/configure/services/tailordb/permission.d.mts +103 -0
  159. package/dist/configure/services/tailordb/schema.d.mts +486 -0
  160. package/dist/configure/services/tailordb/types.d.mts +198 -0
  161. package/dist/configure/services/workflow/execution-policy.d.mts +70 -0
  162. package/dist/configure/services/workflow/execution-policy.types.d.mts +103 -0
  163. package/dist/configure/services/workflow/index.d.mts +9 -0
  164. package/dist/configure/services/workflow/job.d.mts +83 -0
  165. package/dist/configure/services/workflow/types.d.mts +2 -0
  166. package/dist/configure/services/workflow/wait-point.d.mts +72 -0
  167. package/dist/configure/services/workflow/workflow.d.mts +56 -0
  168. package/dist/configure/types/aigateway-name.d.mts +12 -0
  169. package/dist/configure/types/connection-name.d.mts +12 -0
  170. package/dist/configure/types/field.d.mts +8 -0
  171. package/dist/configure/types/field.types.d.mts +70 -0
  172. package/dist/configure/types/idp-name.d.mts +12 -0
  173. package/dist/configure/types/index.d.mts +5 -0
  174. package/dist/configure/types/machine-user.d.mts +2 -0
  175. package/dist/configure/types/permission-operand.types.d.mts +20 -0
  176. package/dist/configure/types/type.d.mts +73 -0
  177. package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
  178. package/dist/context-DYQVYWqZ.mjs.map +1 -0
  179. package/dist/{crashreport-BsjAkFWw.mjs → crashreport-B5LqCTfF.mjs} +10 -11
  180. package/dist/{crashreport-BsjAkFWw.mjs.map → crashreport-B5LqCTfF.mjs.map} +1 -1
  181. package/dist/{crashreport-pr6Rhvza.mjs → crashreport-eI7ty7ok.mjs} +1 -1
  182. package/dist/enum-constants-j9QBF0cB.mjs.map +1 -1
  183. package/dist/{errors-Dtf2WPaW.mjs → errors-D7583Zz7.mjs} +18 -2
  184. package/dist/errors-D7583Zz7.mjs.map +1 -0
  185. package/dist/{file-_oUZo76X.mjs → file-BUcmVIH2.mjs} +12 -22
  186. package/dist/file-BUcmVIH2.mjs.map +1 -0
  187. package/dist/{file-utils-DcyIPFQh.mjs → file-utils-yEiIS4nJ.mjs} +6 -6
  188. package/dist/file-utils-yEiIS4nJ.mjs.map +1 -0
  189. package/dist/{globals-Crz8o65k.mjs → globals-DQotNuwK.mjs} +33 -55
  190. package/dist/globals-DQotNuwK.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/{kysely-type-DR8uzZTA.mjs → kysely-type-DqIRgDYR.mjs} +5 -4
  199. package/dist/kysely-type-DqIRgDYR.mjs.map +1 -0
  200. package/dist/logger-BtX0suGY.mjs +48 -0
  201. package/dist/logger-BtX0suGY.mjs.map +1 -0
  202. package/dist/logger-CXQq9YIp.mjs +317 -0
  203. package/dist/logger-CXQq9YIp.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/file-utils/index.d.mts +15 -1
  215. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  216. package/dist/plugin/builtin/kysely-type/index.d.mts +15 -1
  217. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  218. package/dist/plugin/builtin/seed/index.d.mts +46 -2
  219. package/dist/plugin/builtin/seed/index.mjs +1 -1
  220. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +19 -0
  221. package/dist/plugin/builtin/seed/types.d.mts +2 -0
  222. package/dist/plugin/get-generated-type.d.mts +16 -0
  223. package/dist/plugin/index.d.mts +3 -117
  224. package/dist/plugin/index.mjs +1 -1
  225. package/dist/plugin/index.mjs.map +1 -1
  226. package/dist/plugin/manager.d.mts +2 -0
  227. package/dist/plugin/types.d.mts +242 -0
  228. package/dist/plugin/with-context.d.mts +101 -0
  229. package/dist/{runtime-n9NCkjee.mjs → register-ts-hook-BAHMwxfG.mjs} +7812 -4094
  230. package/dist/register-ts-hook-BAHMwxfG.mjs.map +1 -0
  231. package/dist/{registry-DdsYlL_P.mjs → registry-BIGVUrMB.mjs} +12 -9
  232. package/dist/registry-BIGVUrMB.mjs.map +1 -0
  233. package/dist/{repl-editor-DmGr9zMw.mjs → repl-editor-BCozyiNq.mjs} +6 -5
  234. package/dist/{repl-editor-DmGr9zMw.mjs.map → repl-editor-BCozyiNq.mjs.map} +1 -1
  235. package/dist/runtime/aigateway.d.mts +25 -0
  236. package/dist/runtime/aigateway.mjs +3 -0
  237. package/dist/runtime/authconnection.d.mts +21 -2
  238. package/dist/runtime/authconnection.mjs +2 -2
  239. package/dist/runtime/context.d.mts +54 -2
  240. package/dist/runtime/context.mjs +2 -2
  241. package/dist/runtime/field-parse.d.mts +10 -0
  242. package/dist/runtime/file.d.mts +170 -2
  243. package/dist/runtime/file.mjs +2 -2
  244. package/dist/runtime/globals.d.mts +38 -20
  245. package/dist/runtime/iconv.d.mts +73 -2
  246. package/dist/runtime/iconv.mjs +2 -2
  247. package/dist/runtime/idp.d.mts +129 -2
  248. package/dist/runtime/idp.mjs +2 -2
  249. package/dist/runtime/index.d.mts +48 -9
  250. package/dist/runtime/index.mjs +10 -8
  251. package/dist/runtime/logger.d.mts +98 -0
  252. package/dist/runtime/logger.mjs +3 -0
  253. package/dist/runtime/secretmanager.d.mts +41 -2
  254. package/dist/runtime/secretmanager.mjs +2 -2
  255. package/dist/runtime/types.d.mts +25 -0
  256. package/dist/runtime/workflow.d.mts +124 -2
  257. package/dist/runtime/workflow.mjs +2 -2
  258. package/dist/{schema-BhkpP5Hw.mjs → schema--xYWRGfe.mjs} +288 -229
  259. package/dist/schema--xYWRGfe.mjs.map +1 -0
  260. package/dist/{secret-file-DBqZhjFQ.mjs → secret-file-C3J4Gy8r.mjs} +2 -2
  261. package/dist/{secret-file-DBqZhjFQ.mjs.map → secret-file-C3J4Gy8r.mjs.map} +1 -1
  262. package/dist/secretmanager-CYlpffsz.mjs +13 -0
  263. package/dist/secretmanager-CYlpffsz.mjs.map +1 -0
  264. package/dist/secretmanager-IY4UvinW.mjs +131 -0
  265. package/dist/secretmanager-IY4UvinW.mjs.map +1 -0
  266. package/dist/seed/index.d.mts +4 -4
  267. package/dist/seed-LUVr7jHL.mjs +444 -0
  268. package/dist/seed-LUVr7jHL.mjs.map +1 -0
  269. package/dist/{service-DU1mVzri.mjs → service-B5WynBHQ.mjs} +3 -3
  270. package/dist/{service-DU1mVzri.mjs.map → service-B5WynBHQ.mjs.map} +1 -1
  271. package/dist/service-BNtPsK9Q.mjs +837 -0
  272. package/dist/service-BNtPsK9Q.mjs.map +1 -0
  273. package/dist/service-D5jn05ZI.mjs +3 -0
  274. package/dist/service_pb-BwZRiNug.mjs +167 -0
  275. package/dist/service_pb-BwZRiNug.mjs.map +1 -0
  276. package/dist/service_pb-wRkxUta6.mjs +3 -0
  277. package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +203 -0
  278. package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +57 -0
  279. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +315 -0
  280. package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +160 -0
  281. package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +2069 -0
  282. package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +865 -0
  283. package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +111 -0
  284. package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +68 -0
  285. package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +438 -0
  286. package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +563 -0
  287. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +144 -0
  288. package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +450 -0
  289. package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +191 -0
  290. package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +49 -0
  291. package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +406 -0
  292. package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +429 -0
  293. package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +72 -0
  294. package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +16 -0
  295. package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +308 -0
  296. package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +590 -0
  297. package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +329 -0
  298. package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +112 -0
  299. package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +345 -0
  300. package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +53 -0
  301. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +3575 -0
  302. package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +186 -0
  303. package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +28 -0
  304. package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +428 -0
  305. package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +89 -0
  306. package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +683 -0
  307. package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +796 -0
  308. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +329 -0
  309. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +182 -0
  310. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +861 -0
  311. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +309 -0
  312. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +2014 -0
  313. package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +482 -0
  314. package/dist/{telemetry-CdqJEzkj.mjs → telemetry-BRVdwh14.mjs} +3 -3
  315. package/dist/telemetry-BRVdwh14.mjs.map +1 -0
  316. package/dist/telemetry-CkbkeJxl.mjs +3 -0
  317. package/dist/test-env-key-D7UkZp99.mjs +75 -0
  318. package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
  319. package/dist/types/aigateway.generated.d.mts +12 -0
  320. package/dist/types/app-config.generated.d.mts +4 -0
  321. package/dist/types/auth-connection.generated.d.mts +33 -0
  322. package/dist/types/auth.generated.d.mts +188 -0
  323. package/dist/types/executor.generated.d.mts +209 -0
  324. package/dist/types/helpers.d.mts +40 -0
  325. package/dist/types/http-adapter.generated.d.mts +28 -0
  326. package/dist/types/idp.generated.d.mts +626 -0
  327. package/dist/types/resolver.generated.d.mts +82 -0
  328. package/dist/types/secrets.generated.d.mts +14 -0
  329. package/dist/types/staticwebsite.generated.d.mts +14 -0
  330. package/dist/types/tailordb.generated.d.mts +468 -0
  331. package/dist/types/workflow.generated.d.mts +17 -0
  332. package/dist/user-agent-Bgsszb5I.mjs +28 -0
  333. package/dist/user-agent-Bgsszb5I.mjs.map +1 -0
  334. package/dist/utils/test/index.d.mts +6 -100
  335. package/dist/utils/test/index.mjs +60 -39
  336. package/dist/utils/test/index.mjs.map +1 -1
  337. package/dist/utils/test/mock.d.mts +86 -0
  338. package/dist/vitest/environment.d.mts +1 -2
  339. package/dist/vitest/environment.mjs +2 -2
  340. package/dist/vitest/environment.mjs.map +1 -1
  341. package/dist/vitest/index.d.mts +15 -429
  342. package/dist/vitest/index.mjs +1240 -31
  343. package/dist/vitest/index.mjs.map +1 -1
  344. package/dist/vitest/mock-kysely.d.mts +61 -0
  345. package/dist/vitest/mock.d.mts +10 -0
  346. package/dist/vitest/mocks/aigateway.d.mts +40 -0
  347. package/dist/vitest/mocks/authconnection.d.mts +38 -0
  348. package/dist/vitest/mocks/file.d.mts +58 -0
  349. package/dist/vitest/mocks/iconv.d.mts +51 -0
  350. package/dist/vitest/mocks/idp.d.mts +60 -0
  351. package/dist/vitest/mocks/logger.d.mts +45 -0
  352. package/dist/vitest/mocks/secretmanager.d.mts +44 -0
  353. package/dist/vitest/mocks/tailordb.d.mts +115 -0
  354. package/dist/vitest/mocks/workflow.d.mts +157 -0
  355. package/dist/vitest/setup.d.mts +1 -2
  356. package/dist/vitest/setup.mjs +2 -2
  357. package/dist/vitest/workflow-local.d.mts +41 -0
  358. package/dist/workflow-CsaQ9qK-.mjs +42 -0
  359. package/dist/workflow-CsaQ9qK-.mjs.map +1 -0
  360. package/dist/{client-z_oHGVNy.mjs → workspace_resource_pb-UGK1SSn_.mjs} +55 -619
  361. package/dist/workspace_resource_pb-UGK1SSn_.mjs.map +1 -0
  362. package/docs/cli/application.md +150 -250
  363. package/docs/cli/auth.md +51 -295
  364. package/docs/cli/completion.md +1 -25
  365. package/docs/cli/crashreport.md +3 -61
  366. package/docs/cli/executor.md +72 -183
  367. package/docs/cli/function.md +16 -132
  368. package/docs/cli/organization.md +11 -221
  369. package/docs/cli/plugin.md +29 -0
  370. package/docs/cli/query.md +2 -22
  371. package/docs/cli/secret.md +71 -251
  372. package/docs/cli/setup.md +138 -40
  373. package/docs/cli/skills.md +50 -39
  374. package/docs/cli/staticwebsite.md +32 -180
  375. package/docs/cli/tailordb.md +71 -427
  376. package/docs/cli/upgrade.md +2 -22
  377. package/docs/cli/user.md +78 -247
  378. package/docs/cli/workflow.md +150 -172
  379. package/docs/cli/workspace.md +167 -538
  380. package/docs/cli-reference.md +213 -96
  381. package/docs/configuration.md +40 -6
  382. package/docs/github-actions.md +72 -24
  383. package/docs/migration/v2.md +1316 -0
  384. package/docs/multi-environment.md +29 -7
  385. package/docs/plugin/custom.md +4 -4
  386. package/docs/plugin/index.md +8 -8
  387. package/docs/quickstart.md +8 -7
  388. package/docs/runtime.md +18 -9
  389. package/docs/services/aigateway.md +20 -2
  390. package/docs/services/auth.md +51 -59
  391. package/docs/services/executor.md +8 -3
  392. package/docs/services/http-adapter.md +16 -1
  393. package/docs/services/idp.md +55 -2
  394. package/docs/services/resolver.md +62 -8
  395. package/docs/services/secret.md +11 -11
  396. package/docs/services/staticwebsite.md +8 -2
  397. package/docs/services/tailordb-migration.md +43 -28
  398. package/docs/services/tailordb.md +200 -99
  399. package/docs/services/workflow.md +133 -55
  400. package/docs/testing.md +244 -143
  401. package/package.json +59 -46
  402. package/postinstall.mjs +4 -6
  403. package/dist/application-DB2r36Et.mjs +0 -3
  404. package/dist/application-DqS1yBg3.mjs.map +0 -1
  405. package/dist/authconnection-D2MhtTN5.mjs +0 -15
  406. package/dist/authconnection-D2MhtTN5.mjs.map +0 -1
  407. package/dist/authconnection-DvUQAjQS.d.mts +0 -39
  408. package/dist/cli/erd-viewer-assets/app.js +0 -1181
  409. package/dist/cli/erd-viewer-assets/index.html +0 -73
  410. package/dist/cli/erd-viewer-assets/serve.json +0 -13
  411. package/dist/cli/erd-viewer-assets/styles.css +0 -789
  412. package/dist/cli/index.d.mts +0 -5
  413. package/dist/cli/index.mjs.map +0 -1
  414. package/dist/client-Dbohmtkv.mjs +0 -3
  415. package/dist/client-z_oHGVNy.mjs.map +0 -1
  416. package/dist/context-Bd266-ru.mjs.map +0 -1
  417. package/dist/context-BuuIb8CC.d.mts +0 -68
  418. package/dist/errors-Dtf2WPaW.mjs.map +0 -1
  419. package/dist/field-DOsJCPFa.mjs +0 -22
  420. package/dist/field-DOsJCPFa.mjs.map +0 -1
  421. package/dist/file-BB8Vs9O_.d.mts +0 -250
  422. package/dist/file-_oUZo76X.mjs.map +0 -1
  423. package/dist/file-utils-DcyIPFQh.mjs.map +0 -1
  424. package/dist/globals-Crz8o65k.mjs.map +0 -1
  425. package/dist/http-adapter.generated-WgMnb7Sb.d.mts +0 -580
  426. package/dist/iconv-Co-TOPuH.d.mts +0 -122
  427. package/dist/iconv-D2vi8G36.mjs +0 -63
  428. package/dist/iconv-D2vi8G36.mjs.map +0 -1
  429. package/dist/idp-BDbK5gjm.mjs.map +0 -1
  430. package/dist/idp-DrhVrLmV.d.mts +0 -160
  431. package/dist/index-5vPyRu1y.d.mts +0 -18
  432. package/dist/index-B7AKc18V.d.mts +0 -47
  433. package/dist/index-BlpzXncY.d.mts +0 -1016
  434. package/dist/index-CK7u9isy.d.mts +0 -46
  435. package/dist/index-CNYe5lnW.d.mts +0 -18
  436. package/dist/index-DjUdWlzf.d.mts +0 -18
  437. package/dist/index-ZePLwxw7.d.mts +0 -208
  438. package/dist/interceptor-D-q1rvRl.mjs.map +0 -1
  439. package/dist/job-fuc3j1Ma.mjs +0 -53
  440. package/dist/job-fuc3j1Ma.mjs.map +0 -1
  441. package/dist/kysely-type-DR8uzZTA.mjs.map +0 -1
  442. package/dist/logger-CxF-Ex5d.mjs +0 -220
  443. package/dist/logger-CxF-Ex5d.mjs.map +0 -1
  444. package/dist/mock-BjFj5o1I.mjs +0 -804
  445. package/dist/mock-BjFj5o1I.mjs.map +0 -1
  446. package/dist/registry-DdsYlL_P.mjs.map +0 -1
  447. package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
  448. package/dist/runtime-n9NCkjee.mjs.map +0 -1
  449. package/dist/schema-BhkpP5Hw.mjs.map +0 -1
  450. package/dist/secretmanager-B3n4KHfm.d.mts +0 -55
  451. package/dist/secretmanager-BVxw3ih_.mjs +0 -24
  452. package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
  453. package/dist/seed-jf3008-h.mjs +0 -1160
  454. package/dist/seed-jf3008-h.mjs.map +0 -1
  455. package/dist/service-CCL8ruDf.mjs +0 -459
  456. package/dist/service-CCL8ruDf.mjs.map +0 -1
  457. package/dist/service-D6yonf2I.mjs +0 -3
  458. package/dist/telemetry-CdqJEzkj.mjs.map +0 -1
  459. package/dist/telemetry-ClwW5ohF.mjs +0 -3
  460. package/dist/test-env-key-D9kM6ETE.mjs +0 -49
  461. package/dist/test-env-key-D9kM6ETE.mjs.map +0 -1
  462. package/dist/types-B2RpYyA_.mjs +0 -371
  463. package/dist/types-B2RpYyA_.mjs.map +0 -1
  464. package/dist/types-ClhIrW_C.mjs +0 -4
  465. package/dist/types-DCUhgpyI.d.mts +0 -784
  466. package/dist/types-DhO_VEZd.d.mts +0 -574
  467. package/dist/types-DwDgacni.d.mts +0 -338
  468. package/dist/workflow-BbKvGLQg.d.mts +0 -96
  469. package/dist/workflow-DgemCAz3.mjs +0 -38
  470. package/dist/workflow-DgemCAz3.mjs.map +0 -1
  471. package/dist/workflow.generated-DtQwEo-x.d.mts +0 -671
@@ -1,12 +1,14 @@
1
- import { i as getRegisteredJob, t as TRIGGER_DEFAULT } from "../registry-DdsYlL_P.mjs";
2
- import { a as writeWorkflowTestEnv, i as readWorkflowTestEnv, n as buildJobContext, r as clearWorkflowTestEnv } from "../test-env-key-D9kM6ETE.mjs";
1
+ import { i as getRegisteredJob, t as START_DEFAULT } from "../registry-BIGVUrMB.mjs";
2
+ import { a as writeWorkflowTestEnv, n as clearWorkflowTestEnv, r as readWorkflowTestEnv, t as buildJobContext } from "../test-env-key-D7UkZp99.mjs";
3
3
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
- import { i as platformSerialize } from "../globals-Crz8o65k.mjs";
5
- import { a as mockSecretmanager, i as mockIdp, n as mockFile, o as mockTailordb, r as mockIconv, s as mockWorkflow, t as mockAuthconnection } from "../mock-BjFj5o1I.mjs";
4
+ import { t as platformSerialize } from "../platform-serialize-RoRtBS0v.mjs";
5
+ import { i as withDispose, n as tailorRoot, r as tailordbRoot, t as mockSecretmanager } from "../secretmanager-IY4UvinW.mjs";
6
6
  import { builtinModules } from "node:module";
7
+ import { isEqual } from "es-toolkit";
7
8
  import { fileURLToPath } from "node:url";
8
9
  import { dirname, isAbsolute, matchesGlob, relative, resolve } from "node:path";
9
10
  import { ColumnNode, InsertQueryNode, Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler, PrimitiveValueListNode, ReferenceNode, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode } from "kysely";
11
+ import { vi } from "vitest";
10
12
 
11
13
  //#region src/vitest/blocked-modules.ts
12
14
  /**
@@ -52,7 +54,8 @@ function isBlockedModule(specifier) {
52
54
  * @returns Error message with optional suggestion for the Web Standard API alternative
53
55
  */
54
56
  function getBlockedMessage(specifier) {
55
- const suggestion = SUGGESTIONS[specifier.startsWith("node:") ? specifier.slice(5) : specifier];
57
+ const bare = specifier.startsWith("node:") ? specifier.slice(5) : specifier;
58
+ const suggestion = SUGGESTIONS[bare];
56
59
  const base = `"${specifier}" is not available in the Tailor Platform runtime.`;
57
60
  return suggestion ? `${base} ${suggestion}` : base;
58
61
  }
@@ -60,12 +63,12 @@ function getBlockedMessage(specifier) {
60
63
  //#endregion
61
64
  //#region src/vitest/plugin.ts
62
65
  const DEFAULT_TEST_INCLUDE = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
63
- const IMPORT_LIKE_TYPES = new Set([
66
+ const IMPORT_LIKE_TYPES = /* @__PURE__ */ new Set([
64
67
  "ImportDeclaration",
65
68
  "ExportNamedDeclaration",
66
69
  "ExportAllDeclaration"
67
70
  ]);
68
- const UNSAFE_BINDING_NAMES = new Set([
71
+ const UNSAFE_BINDING_NAMES = /* @__PURE__ */ new Set([
69
72
  "break",
70
73
  "case",
71
74
  "catch",
@@ -185,7 +188,7 @@ function createBlockPlugin() {
185
188
  const testConfig = config.test;
186
189
  const root = testConfig?.root ?? config.root;
187
190
  const toAbsolutePaths = (value, baseRoot) => (Array.isArray(value) ? value : value ? [value] : []).map((f) => resolve(baseRoot, f));
188
- const exemptHostFiles = new Set([...toAbsolutePaths(testConfig?.setupFiles, root), ...toAbsolutePaths(testConfig?.globalSetup, root)]);
191
+ const exemptHostFiles = /* @__PURE__ */ new Set([...toAbsolutePaths(testConfig?.setupFiles, root), ...toAbsolutePaths(testConfig?.globalSetup, root)]);
189
192
  const includePairs = [{
190
193
  root,
191
194
  patterns: testConfig?.include ?? DEFAULT_TEST_INCLUDE
@@ -291,9 +294,1207 @@ function createEnvironmentPlugin(options) {
291
294
  };
292
295
  }
293
296
 
297
+ //#endregion
298
+ //#region src/vitest/mocks/aigateway.ts
299
+ /**
300
+ * Acquire a disposable mock for `tailor.aigateway`. Restored on dispose.
301
+ * @param options - Initial AI Gateway URL fixtures
302
+ * @returns Disposable AI Gateway mock control object
303
+ * @example
304
+ * ```typescript
305
+ * import { mockAigateway } from "@tailor-platform/sdk/vitest";
306
+ *
307
+ * test("resolves an AI Gateway URL", async () => {
308
+ * using aigateway = mockAigateway({
309
+ * urls: { "my-aigateway": "https://my-aigateway.example.com" },
310
+ * });
311
+ * aigateway.setUrl("my-aigateway", "https://replacement.example.com");
312
+ * // …
313
+ * });
314
+ * ```
315
+ */
316
+ function mockAigateway(options = {}) {
317
+ const root = tailorRoot();
318
+ const prev = root.aigateway;
319
+ let urls = { ...options.urls };
320
+ async function defaultGet(name) {
321
+ const url = urls[name];
322
+ if (url === void 0) throw new Error(`No AI Gateway registered for "${name}". Acquire mockAigateway() and call setUrls(...).`);
323
+ return { url };
324
+ }
325
+ const get = vi.fn(defaultGet);
326
+ root.aigateway = { get };
327
+ return withDispose({
328
+ /** The `get` `vi.fn`. */
329
+ get,
330
+ setUrls(value) {
331
+ urls = value;
332
+ },
333
+ setUrl(name, url) {
334
+ urls = {
335
+ ...urls,
336
+ [name]: url
337
+ };
338
+ },
339
+ get calls() {
340
+ return get.mock.calls.map(([name]) => ({ name }));
341
+ },
342
+ clear() {
343
+ get.mockClear();
344
+ },
345
+ reset() {
346
+ urls = {};
347
+ get.mockReset();
348
+ get.mockImplementation(defaultGet);
349
+ }
350
+ }, () => {
351
+ root.aigateway = prev;
352
+ });
353
+ }
354
+
355
+ //#endregion
356
+ //#region src/vitest/mocks/authconnection.ts
357
+ /**
358
+ * Acquire a disposable mock for `tailor.authconnection`. Restored on dispose.
359
+ * @param options - Initial token fixtures and fallback behavior
360
+ * @returns Disposable AuthConnection mock control object
361
+ * @example
362
+ * ```typescript
363
+ * import { mockAuthconnection } from "@tailor-platform/sdk/vitest";
364
+ *
365
+ * test("returns configured token", async () => {
366
+ * using ac = mockAuthconnection({ tokens: { google: { access_token: "ya29.xxx" } } });
367
+ * ac.setToken("google", { access_token: "replacement" });
368
+ * // …
369
+ * });
370
+ * ```
371
+ */
372
+ function mockAuthconnection(options = {}) {
373
+ const root = tailorRoot();
374
+ const prev = root.authconnection;
375
+ let tokens = { ...options.tokens };
376
+ async function defaultGetConnectionToken(connectionName) {
377
+ const token = tokens[connectionName];
378
+ if (token) return token;
379
+ if (options.onUnhandled === "error") throw new Error(`No AuthConnection token configured for "${connectionName}"`);
380
+ return { access_token: "mock-token" };
381
+ }
382
+ const getConnectionToken = vi.fn(defaultGetConnectionToken);
383
+ root.authconnection = { getConnectionToken };
384
+ return withDispose({
385
+ /** The `getConnectionToken` `vi.fn`. */
386
+ getConnectionToken,
387
+ setTokens(value) {
388
+ tokens = value;
389
+ },
390
+ setToken(connectionName, token) {
391
+ tokens = {
392
+ ...tokens,
393
+ [connectionName]: token
394
+ };
395
+ },
396
+ get calls() {
397
+ return getConnectionToken.mock.calls.map(([connectionName]) => ({ connectionName }));
398
+ },
399
+ clear() {
400
+ getConnectionToken.mockClear();
401
+ },
402
+ reset() {
403
+ tokens = {};
404
+ getConnectionToken.mockReset();
405
+ getConnectionToken.mockImplementation(defaultGetConnectionToken);
406
+ }
407
+ }, () => {
408
+ root.authconnection = prev;
409
+ });
410
+ }
411
+
412
+ //#endregion
413
+ //#region src/vitest/mocks/file.ts
414
+ const FILE_METHODS = [
415
+ "upload",
416
+ "download",
417
+ "downloadAsBase64",
418
+ "delete",
419
+ "getMetadata",
420
+ "downloadStream",
421
+ "uploadStream"
422
+ ];
423
+ const FILE_DEFAULTS = {
424
+ upload: { metadata: {
425
+ fileSize: 0,
426
+ sha256sum: ""
427
+ } },
428
+ download: {
429
+ data: /* @__PURE__ */ new Uint8Array(),
430
+ metadata: {
431
+ contentType: "",
432
+ fileSize: 0,
433
+ sha256sum: "",
434
+ lastUploadedAt: ""
435
+ }
436
+ },
437
+ downloadAsBase64: {
438
+ data: "",
439
+ metadata: {
440
+ contentType: "",
441
+ fileSize: 0,
442
+ sha256sum: "",
443
+ lastUploadedAt: ""
444
+ }
445
+ },
446
+ getMetadata: {
447
+ contentType: "",
448
+ fileSize: 0,
449
+ sha256sum: "",
450
+ urlPath: ""
451
+ },
452
+ downloadStream: null,
453
+ uploadStream: { metadata: {
454
+ fileSize: 0,
455
+ sha256sum: ""
456
+ } }
457
+ };
458
+ /**
459
+ * Acquire a disposable mock for `tailordb.file`. Restored on dispose.
460
+ * @param options - Controls behavior for calls without a configured result
461
+ * @returns Disposable File mock control object
462
+ * @example
463
+ * ```typescript
464
+ * import { mockFile } from "@tailor-platform/sdk/vitest";
465
+ *
466
+ * test("mock file download", async () => {
467
+ * using file = mockFile();
468
+ * file.download.mockResolvedValue({ data: new Uint8Array(), metadata: { ... } });
469
+ * // …
470
+ * });
471
+ * ```
472
+ */
473
+ function mockFile(options = {}) {
474
+ const root = tailordbRoot();
475
+ const prev = root.file;
476
+ const { onUnhandled = "fallback" } = options;
477
+ const queue = [];
478
+ const calls = [];
479
+ let resolver = () => null;
480
+ function handle(method, namespace, typeName, fieldName, recordId) {
481
+ if (queue.length > 0) return queue.shift();
482
+ const resolved = resolver(method, {
483
+ method,
484
+ namespace,
485
+ typeName,
486
+ fieldName,
487
+ recordId
488
+ });
489
+ if (resolved != null) return resolved;
490
+ if (onUnhandled === "error") throw new Error(`No File mock configured for "${method}"`);
491
+ const fallback = FILE_DEFAULTS[method];
492
+ return fallback === void 0 ? void 0 : structuredClone(fallback);
493
+ }
494
+ const upload = vi.fn(async (...args) => {
495
+ const [namespace, typeName, fieldName, recordId] = args;
496
+ return handle("upload", namespace, typeName, fieldName, recordId);
497
+ });
498
+ const download = vi.fn(async (...args) => handle("download", ...args));
499
+ const downloadAsBase64 = vi.fn(async (...args) => handle("downloadAsBase64", ...args));
500
+ const deleteFile = vi.fn(async (...args) => {
501
+ handle("delete", ...args);
502
+ });
503
+ const getMetadata = vi.fn(async (...args) => handle("getMetadata", ...args));
504
+ const downloadStream = vi.fn(async (...args) => {
505
+ const resolved = handle("downloadStream", ...args);
506
+ if (resolved != null) return resolved;
507
+ return {
508
+ body: new ReadableStream({ start(controller) {
509
+ controller.close();
510
+ } }),
511
+ metadata: {
512
+ contentType: "",
513
+ fileSize: 0,
514
+ sha256sum: "",
515
+ lastUploadedAt: ""
516
+ }
517
+ };
518
+ });
519
+ const uploadStream = vi.fn(async (...args) => {
520
+ const [namespace, typeName, fieldName, recordId] = args;
521
+ return handle("uploadStream", namespace, typeName, fieldName, recordId);
522
+ });
523
+ const mocks = {
524
+ upload,
525
+ download,
526
+ downloadAsBase64,
527
+ delete: deleteFile,
528
+ getMetadata,
529
+ downloadStream,
530
+ uploadStream
531
+ };
532
+ function track(method, operation) {
533
+ return function(...args) {
534
+ calls.push({
535
+ method,
536
+ namespace: args[0],
537
+ typeName: args[1],
538
+ fieldName: args[2],
539
+ recordId: args[3]
540
+ });
541
+ return operation.apply(this, args);
542
+ };
543
+ }
544
+ root.file = {
545
+ upload: track("upload", upload),
546
+ download: track("download", download),
547
+ downloadAsBase64: track("downloadAsBase64", downloadAsBase64),
548
+ delete: track("delete", deleteFile),
549
+ getMetadata: track("getMetadata", getMetadata),
550
+ downloadStream: track("downloadStream", downloadStream),
551
+ uploadStream: track("uploadStream", uploadStream)
552
+ };
553
+ function allMocks() {
554
+ return FILE_METHODS.map((method) => mocks[method]);
555
+ }
556
+ return withDispose({
557
+ ...mocks,
558
+ setResolver(value) {
559
+ resolver = value;
560
+ },
561
+ /**
562
+ * Enqueue a single result for the next `tailordb.file` call.
563
+ * The queue is shared across all methods and namespaces.
564
+ * @param result - Result to return from the next file call
565
+ */
566
+ enqueueResult(result) {
567
+ queue.push(result);
568
+ },
569
+ /**
570
+ * Enqueue results for multiple subsequent `tailordb.file` calls.
571
+ * The queue is shared across all methods and namespaces.
572
+ * @param results - Results to enqueue, one per upcoming call
573
+ */
574
+ enqueueResults(...results) {
575
+ queue.push(...results);
576
+ },
577
+ get calls() {
578
+ return calls;
579
+ },
580
+ clear() {
581
+ calls.length = 0;
582
+ for (const mock of allMocks()) mock.mockClear();
583
+ },
584
+ reset() {
585
+ queue.length = 0;
586
+ calls.length = 0;
587
+ resolver = () => null;
588
+ for (const mock of allMocks()) mock.mockReset();
589
+ }
590
+ }, () => {
591
+ root.file = prev;
592
+ });
593
+ }
594
+
595
+ //#endregion
596
+ //#region src/vitest/mocks/iconv.ts
597
+ function isUtf8(encoding) {
598
+ return encoding === "UTF8" || encoding === "UTF-8";
599
+ }
600
+ function defaultIconvResult(method, args) {
601
+ switch (method) {
602
+ case "convert":
603
+ case "convertBuffer": return isUtf8(args[2]) ? "" : /* @__PURE__ */ new Uint8Array();
604
+ case "decode": return "";
605
+ case "encode": return isUtf8(args[1]) ? "" : /* @__PURE__ */ new Uint8Array();
606
+ case "encodings": return [];
607
+ }
608
+ }
609
+ /**
610
+ * Acquire a disposable mock for `tailor.iconv`. Restored on dispose.
611
+ * @param options - Fallback behavior for unconfigured operations
612
+ * @returns Disposable Iconv mock control object
613
+ * @example
614
+ * ```typescript
615
+ * import { mockIconv } from "@tailor-platform/sdk/vitest";
616
+ *
617
+ * test("mock encoding conversion", () => {
618
+ * using iconv = mockIconv();
619
+ * iconv.decode.mockReturnValue("decoded-text");
620
+ * // …
621
+ * });
622
+ * ```
623
+ */
624
+ function mockIconv(options = {}) {
625
+ const root = tailorRoot();
626
+ const prev = root.iconv;
627
+ let resolver = null;
628
+ const calls = [];
629
+ function resolve(method, args) {
630
+ if (resolver) {
631
+ const result = resolver(method, args);
632
+ if (result != null) return result;
633
+ }
634
+ if (options.onUnhandled === "error") throw new Error(`No Iconv mock behavior configured for "${method}"`);
635
+ return defaultIconvResult(method, args);
636
+ }
637
+ function defaultConvert(input, fromEncoding, toEncoding) {
638
+ return resolve("convert", [
639
+ input,
640
+ fromEncoding,
641
+ toEncoding
642
+ ]);
643
+ }
644
+ function defaultConvertBuffer(input, fromEncoding, toEncoding) {
645
+ return resolve("convertBuffer", [
646
+ input,
647
+ fromEncoding,
648
+ toEncoding
649
+ ]);
650
+ }
651
+ function defaultDecode(input, encoding) {
652
+ return resolve("decode", [input, encoding]);
653
+ }
654
+ function defaultEncode(input, encoding) {
655
+ return resolve("encode", [input, encoding]);
656
+ }
657
+ function defaultEncodings() {
658
+ return resolve("encodings", []);
659
+ }
660
+ const convert = vi.fn(defaultConvert);
661
+ const convertBuffer = vi.fn(defaultConvertBuffer);
662
+ const decode = vi.fn(defaultDecode);
663
+ const encode = vi.fn(defaultEncode);
664
+ const encodings = vi.fn(defaultEncodings);
665
+ function track(method, operation) {
666
+ return function(...args) {
667
+ calls.push({
668
+ method,
669
+ args: [...args]
670
+ });
671
+ return operation.apply(this, args);
672
+ };
673
+ }
674
+ const trackedConvert = track("convert", convert);
675
+ const trackedConvertBuffer = track("convertBuffer", convertBuffer);
676
+ const trackedDecode = track("decode", decode);
677
+ const trackedEncode = track("encode", encode);
678
+ const trackedEncodings = track("encodings", encodings);
679
+ class MockIconv {
680
+ #fromEncoding;
681
+ #toEncoding;
682
+ constructor(fromEncoding, toEncoding) {
683
+ this.#fromEncoding = fromEncoding;
684
+ this.#toEncoding = toEncoding;
685
+ }
686
+ convert(input) {
687
+ return trackedConvert.call(this, input, this.#fromEncoding, this.#toEncoding);
688
+ }
689
+ }
690
+ root.iconv = {
691
+ convert: trackedConvert,
692
+ convertBuffer: trackedConvertBuffer,
693
+ decode: trackedDecode,
694
+ encode: trackedEncode,
695
+ encodings: trackedEncodings,
696
+ Iconv: MockIconv
697
+ };
698
+ function clear() {
699
+ calls.length = 0;
700
+ convert.mockClear();
701
+ convertBuffer.mockClear();
702
+ decode.mockClear();
703
+ encode.mockClear();
704
+ encodings.mockClear();
705
+ }
706
+ return withDispose({
707
+ /** The `convert` `vi.fn`. */
708
+ convert,
709
+ /** The `convertBuffer` `vi.fn`. */
710
+ convertBuffer,
711
+ /** The `decode` `vi.fn`. */
712
+ decode,
713
+ /** The `encode` `vi.fn`. */
714
+ encode,
715
+ /** The `encodings` `vi.fn`. */
716
+ encodings,
717
+ setResolver(value) {
718
+ resolver = value;
719
+ },
720
+ get calls() {
721
+ return calls;
722
+ },
723
+ clear,
724
+ reset() {
725
+ resolver = null;
726
+ calls.length = 0;
727
+ convert.mockReset();
728
+ convert.mockImplementation(defaultConvert);
729
+ convertBuffer.mockReset();
730
+ convertBuffer.mockImplementation(defaultConvertBuffer);
731
+ decode.mockReset();
732
+ decode.mockImplementation(defaultDecode);
733
+ encode.mockReset();
734
+ encode.mockImplementation(defaultEncode);
735
+ encodings.mockReset();
736
+ encodings.mockImplementation(defaultEncodings);
737
+ }
738
+ }, () => {
739
+ root.iconv = prev;
740
+ });
741
+ }
742
+
743
+ //#endregion
744
+ //#region src/vitest/mocks/idp.ts
745
+ const IDP_METHODS = [
746
+ "users",
747
+ "user",
748
+ "userByName",
749
+ "createUser",
750
+ "updateUser",
751
+ "deleteUser",
752
+ "sendPasswordResetEmail",
753
+ "unenrollMfa"
754
+ ];
755
+ const IDP_USER_DEFAULT = {
756
+ id: "mock-id",
757
+ name: "mock-user",
758
+ disabled: false,
759
+ mfaEnrolled: false,
760
+ mfaFactorIds: []
761
+ };
762
+ const IDP_DEFAULTS = {
763
+ users: {
764
+ users: [],
765
+ nextPageToken: null,
766
+ totalCount: 0
767
+ },
768
+ user: IDP_USER_DEFAULT,
769
+ userByName: IDP_USER_DEFAULT,
770
+ createUser: IDP_USER_DEFAULT,
771
+ updateUser: IDP_USER_DEFAULT,
772
+ deleteUser: true,
773
+ sendPasswordResetEmail: true,
774
+ unenrollMfa: true
775
+ };
776
+ /**
777
+ * Acquire a disposable mock for `tailor.idp`. Restored on dispose.
778
+ * @param options - Controls behavior for calls without a configured result
779
+ * @returns Disposable IDP mock control object
780
+ * @example
781
+ * ```typescript
782
+ * import { mockIdp } from "@tailor-platform/sdk/vitest";
783
+ *
784
+ * test("returns a user", async () => {
785
+ * using idp = mockIdp();
786
+ * idp.namespace("my-idp").user.mockResolvedValue({
787
+ * id: "u-1",
788
+ * name: "alice",
789
+ * disabled: false,
790
+ * mfaEnrolled: false,
791
+ * mfaFactorIds: [],
792
+ * });
793
+ * // …
794
+ * });
795
+ * ```
796
+ */
797
+ function mockIdp(options = {}) {
798
+ const root = tailorRoot();
799
+ const prev = root.idp;
800
+ const { onUnhandled = "fallback" } = options;
801
+ const queue = [];
802
+ const calls = [];
803
+ let resolver = () => null;
804
+ const namespaces = /* @__PURE__ */ new Map();
805
+ function compatibilityArgs(method, args) {
806
+ return method === "users" && args.length === 0 ? [void 0] : args;
807
+ }
808
+ function handle(method, args, namespace) {
809
+ if (queue.length > 0) return queue.shift();
810
+ const resolved = resolver(method, compatibilityArgs(method, args), namespace);
811
+ if (resolved != null) return resolved;
812
+ if (onUnhandled === "error") throw new Error(`No IdP mock configured for "${namespace}.${method}"`);
813
+ return structuredClone(IDP_DEFAULTS[method]);
814
+ }
815
+ function createNamespaceMocks(namespace) {
816
+ return {
817
+ users: vi.fn(async (...args) => handle("users", args, namespace)),
818
+ user: vi.fn(async (...args) => handle("user", args, namespace)),
819
+ userByName: vi.fn(async (...args) => handle("userByName", args, namespace)),
820
+ createUser: vi.fn(async (...args) => handle("createUser", args, namespace)),
821
+ updateUser: vi.fn(async (...args) => handle("updateUser", args, namespace)),
822
+ deleteUser: vi.fn(async (...args) => handle("deleteUser", args, namespace)),
823
+ sendPasswordResetEmail: vi.fn(async (...args) => handle("sendPasswordResetEmail", args, namespace)),
824
+ unenrollMfa: vi.fn(async (...args) => handle("unenrollMfa", args, namespace))
825
+ };
826
+ }
827
+ function namespace(name) {
828
+ const existing = namespaces.get(name);
829
+ if (existing) return existing;
830
+ const mocks = createNamespaceMocks(name);
831
+ namespaces.set(name, mocks);
832
+ return mocks;
833
+ }
834
+ function track(method, mock, namespaceName) {
835
+ return function(...args) {
836
+ calls.push({
837
+ method,
838
+ args: [...compatibilityArgs(method, args)],
839
+ namespace: namespaceName
840
+ });
841
+ return mock.apply(this, args);
842
+ };
843
+ }
844
+ const defaultClient = function(config) {
845
+ const mocks = namespace(config.namespace);
846
+ this.users = track("users", mocks.users, config.namespace);
847
+ this.user = track("user", mocks.user, config.namespace);
848
+ this.userByName = track("userByName", mocks.userByName, config.namespace);
849
+ this.createUser = track("createUser", mocks.createUser, config.namespace);
850
+ this.updateUser = track("updateUser", mocks.updateUser, config.namespace);
851
+ this.deleteUser = track("deleteUser", mocks.deleteUser, config.namespace);
852
+ this.sendPasswordResetEmail = track("sendPasswordResetEmail", mocks.sendPasswordResetEmail, config.namespace);
853
+ this.unenrollMfa = track("unenrollMfa", mocks.unenrollMfa, config.namespace);
854
+ };
855
+ const Client = vi.fn(defaultClient);
856
+ root.idp = { Client };
857
+ function allMocks() {
858
+ return [...namespaces.values()].flatMap((mocks) => IDP_METHODS.map((method) => mocks[method]));
859
+ }
860
+ return withDispose({
861
+ /** The mock IDP `Client` constructor (`vi.fn`). */
862
+ Client,
863
+ namespace,
864
+ setResolver(value) {
865
+ resolver = value;
866
+ },
867
+ /**
868
+ * Enqueue a single result for the next IDP call.
869
+ * The queue is shared across all methods and namespaces.
870
+ * @param result - Result to return from the next IDP call
871
+ */
872
+ enqueueResult(result) {
873
+ queue.push(result);
874
+ },
875
+ /**
876
+ * Enqueue results for multiple subsequent IDP calls.
877
+ * The queue is shared across all methods and namespaces.
878
+ * @param results - Results to enqueue, one per upcoming call
879
+ */
880
+ enqueueResults(...results) {
881
+ queue.push(...results);
882
+ },
883
+ get calls() {
884
+ return calls;
885
+ },
886
+ clear() {
887
+ calls.length = 0;
888
+ Client.mockClear();
889
+ for (const mock of allMocks()) mock.mockClear();
890
+ },
891
+ reset() {
892
+ queue.length = 0;
893
+ calls.length = 0;
894
+ resolver = () => null;
895
+ Client.mockReset();
896
+ Client.mockImplementation(defaultClient);
897
+ for (const mock of allMocks()) mock.mockReset();
898
+ }
899
+ }, () => {
900
+ root.idp = prev;
901
+ });
902
+ }
903
+
904
+ //#endregion
905
+ //#region src/vitest/mocks/logger.ts
906
+ /**
907
+ * Acquire a disposable mock for `tailor.logger`. Each method is a `vi.fn`, so
908
+ * calls can be asserted directly; `calls` returns the `debug`/`info`/`warn`/
909
+ * `error` entries in the order they were emitted. Restored on dispose.
910
+ * @param _options - Reserved for future initial fixtures
911
+ * @returns Disposable logger mock control object
912
+ * @example
913
+ * ```typescript
914
+ * import { mockLogger } from "@tailor-platform/sdk/vitest";
915
+ *
916
+ * test("logs the processed order", () => {
917
+ * using logger = mockLogger();
918
+ * // …run code that calls tailor.logger.info…
919
+ * expect(logger.info).toHaveBeenCalledWith("order processed", { orderId: "o-1" });
920
+ * });
921
+ * ```
922
+ */
923
+ function mockLogger(_options = {}) {
924
+ const root = tailorRoot();
925
+ const prev = root.logger;
926
+ const debug = vi.fn((_message, _attributes) => {});
927
+ const info = vi.fn((_message, _attributes) => {});
928
+ const warn = vi.fn((_message, _attributes) => {});
929
+ const error = vi.fn((_message, _attributes) => {});
930
+ const setAttributes = vi.fn((_attributes) => {});
931
+ root.logger = {
932
+ debug,
933
+ info,
934
+ warn,
935
+ error,
936
+ setAttributes
937
+ };
938
+ const severityFns = {
939
+ debug,
940
+ info,
941
+ warn,
942
+ error
943
+ };
944
+ return withDispose({
945
+ /** The `debug` `vi.fn`. */
946
+ debug,
947
+ /** The `info` `vi.fn`. */
948
+ info,
949
+ /** The `warn` `vi.fn`. */
950
+ warn,
951
+ /** The `error` `vi.fn`. */
952
+ error,
953
+ /** The `setAttributes` `vi.fn`. */
954
+ setAttributes,
955
+ get calls() {
956
+ return Object.entries(severityFns).flatMap(([severity, fn]) => fn.mock.calls.map((args, i) => ({
957
+ order: fn.mock.invocationCallOrder[i] ?? 0,
958
+ call: {
959
+ severity,
960
+ message: args[0],
961
+ attributes: args[1]
962
+ }
963
+ }))).toSorted((a, b) => a.order - b.order).map((e) => e.call);
964
+ },
965
+ clear() {
966
+ debug.mockClear();
967
+ info.mockClear();
968
+ warn.mockClear();
969
+ error.mockClear();
970
+ setAttributes.mockClear();
971
+ },
972
+ reset() {
973
+ debug.mockReset();
974
+ info.mockReset();
975
+ warn.mockReset();
976
+ error.mockReset();
977
+ setAttributes.mockReset();
978
+ }
979
+ }, () => {
980
+ root.logger = prev;
981
+ });
982
+ }
983
+
984
+ //#endregion
985
+ //#region src/vitest/mocks/tailordb.ts
986
+ function testRegex(regex, value) {
987
+ const lastIndex = regex.lastIndex;
988
+ regex.lastIndex = 0;
989
+ try {
990
+ return regex.test(value);
991
+ } finally {
992
+ regex.lastIndex = lastIndex;
993
+ }
994
+ }
995
+ var MockQueryResult = class {
996
+ command;
997
+ rowCount;
998
+ rows;
999
+ constructor(rows) {
1000
+ this.command = "";
1001
+ this.rowCount = rows.length;
1002
+ this.rows = rows;
1003
+ }
1004
+ };
1005
+ /**
1006
+ * Acquire a disposable mock for TailorDB operations. Installs a mock
1007
+ * `tailordb.Client` whose `queryObject` is a shared `vi.fn()` (so query
1008
+ * responses can be staged before the client is constructed). Restored on
1009
+ * dispose.
1010
+ * @param options - Query fallback behavior
1011
+ * @returns Disposable TailorDB mock control object
1012
+ * @example
1013
+ * ```typescript
1014
+ * import { mockTailordb } from "@tailor-platform/sdk/vitest";
1015
+ *
1016
+ * test("query-based", async () => {
1017
+ * using db = mockTailordb();
1018
+ * db.onQuery({ sql: /FROM users/, params: ["u-1"] }).returnsRows([{ age: 30 }]);
1019
+ * // …
1020
+ * expect(db.queryObject).toHaveBeenCalled();
1021
+ * expect(db.Client).toHaveBeenCalledWith({ namespace: "tailordb" });
1022
+ * });
1023
+ * ```
1024
+ */
1025
+ function mockTailordb(options = {}) {
1026
+ const root = tailordbRoot();
1027
+ const prevClient = root.Client;
1028
+ const rules = [];
1029
+ let queryResolver;
1030
+ function matchesQuery(matcher, query, params) {
1031
+ if (typeof matcher === "function") return matcher(query, params);
1032
+ if (typeof matcher === "string") return query === matcher;
1033
+ if (matcher instanceof RegExp) return testRegex(matcher, query);
1034
+ let sqlMatches;
1035
+ if (typeof matcher.sql === "string") sqlMatches = query === matcher.sql;
1036
+ else sqlMatches = testRegex(matcher.sql, query);
1037
+ if (!sqlMatches || matcher.params === void 0) return sqlMatches;
1038
+ if (typeof matcher.params === "function") return matcher.params(params);
1039
+ const expectedParams = matcher.params;
1040
+ return params.length === expectedParams.length && params.every((value, index) => isEqual(value, expectedParams[index]));
1041
+ }
1042
+ function queryResponse(response) {
1043
+ if (response.type === "error") throw response.error;
1044
+ return new MockQueryResult(response.rows);
1045
+ }
1046
+ async function defaultQuery(query, params = []) {
1047
+ for (let i = rules.length - 1; i >= 0; i -= 1) {
1048
+ const rule = rules[i];
1049
+ if (!rule || !matchesQuery(rule.matcher, query, params)) continue;
1050
+ const once = rule.once.shift();
1051
+ if (once) return queryResponse(once);
1052
+ if (rule.fallback) return queryResponse(rule.fallback);
1053
+ }
1054
+ if (queryResolver) return new MockQueryResult(queryResolver(query, params) ?? []);
1055
+ if (options.onUnhandled === "error") throw new Error(`No TailorDB query behavior matched: ${query}`);
1056
+ return new MockQueryResult([]);
1057
+ }
1058
+ const queryObject = vi.fn(defaultQuery);
1059
+ const defaultConnect = async () => {};
1060
+ const connect = vi.fn(defaultConnect);
1061
+ const createdClients = [];
1062
+ function enqueueRowsList(rowsList) {
1063
+ for (const rows of rowsList) queryObject.mockImplementationOnce(async () => new MockQueryResult(rows));
1064
+ }
1065
+ const defaultClient = function(config) {
1066
+ const record = {
1067
+ namespace: config?.namespace,
1068
+ ended: false
1069
+ };
1070
+ createdClients.push(record);
1071
+ this.connect = connect;
1072
+ this.end = vi.fn(async () => {
1073
+ record.ended = true;
1074
+ });
1075
+ this.queryObject = queryObject;
1076
+ this.createTransaction = (name) => {
1077
+ if (!name) throw new Error("Transaction name must be a non-empty string");
1078
+ return {
1079
+ begin: async () => {},
1080
+ commit: async () => {},
1081
+ rollback: async () => {},
1082
+ queryObject
1083
+ };
1084
+ };
1085
+ };
1086
+ const Client = vi.fn(defaultClient);
1087
+ root.Client = Client;
1088
+ return withDispose({
1089
+ /** The mock `tailordb.Client` constructor (`vi.fn`). */
1090
+ Client,
1091
+ /** The shared `queryObject` `vi.fn` used by every client and transaction. */
1092
+ queryObject,
1093
+ /**
1094
+ * Set a fallback query resolver. Called when the enqueue queue is empty.
1095
+ * @param resolver - Function that returns rows for a given query and params
1096
+ */
1097
+ setQueryResolver(resolver) {
1098
+ queryResolver = resolver;
1099
+ queryObject.mockImplementation(defaultQuery);
1100
+ },
1101
+ /**
1102
+ * Configure responses for queries matching SQL text, parameters, or a predicate.
1103
+ * More recently registered matchers take precedence.
1104
+ * Do not combine matchers with a direct `queryObject.mockImplementation()` override.
1105
+ * @param matcher - Query matcher
1106
+ * @returns Chainable query behavior
1107
+ */
1108
+ onQuery(matcher) {
1109
+ const rule = {
1110
+ matcher,
1111
+ once: []
1112
+ };
1113
+ rules.push(rule);
1114
+ const behavior = {
1115
+ returnsRows(rows) {
1116
+ rule.fallback = {
1117
+ type: "rows",
1118
+ rows
1119
+ };
1120
+ return behavior;
1121
+ },
1122
+ returnsRowsOnce(rows) {
1123
+ rule.once.push({
1124
+ type: "rows",
1125
+ rows
1126
+ });
1127
+ return behavior;
1128
+ },
1129
+ rejects(error) {
1130
+ rule.fallback = {
1131
+ type: "error",
1132
+ error
1133
+ };
1134
+ return behavior;
1135
+ },
1136
+ rejectsOnce(error) {
1137
+ rule.once.push({
1138
+ type: "error",
1139
+ error
1140
+ });
1141
+ return behavior;
1142
+ }
1143
+ };
1144
+ return behavior;
1145
+ },
1146
+ /**
1147
+ * Enqueue rows for the next `queryObject` call (FIFO; takes priority over
1148
+ * `setQueryResolver`). Call with no arguments for an empty result.
1149
+ * @param rows - Row objects to return from the next `queryObject` call
1150
+ */
1151
+ enqueueResult(...rows) {
1152
+ enqueueRowsList([rows]);
1153
+ },
1154
+ /**
1155
+ * Enqueue rows for multiple subsequent `queryObject` calls (FIFO).
1156
+ * @param rowsList - Rows arrays, one per upcoming query
1157
+ */
1158
+ enqueueResults(...rowsList) {
1159
+ enqueueRowsList(rowsList);
1160
+ },
1161
+ /**
1162
+ * Enqueue row arrays for subsequent queries whose exact order is under test.
1163
+ * @param rowsList - Rows arrays, one per upcoming query
1164
+ */
1165
+ enqueueRows(...rowsList) {
1166
+ enqueueRowsList(rowsList);
1167
+ },
1168
+ /**
1169
+ * All queries executed via `queryObject`, in order, derived from the vi.fn
1170
+ * call records.
1171
+ * @returns Executed queries array
1172
+ */
1173
+ get executedQueries() {
1174
+ return queryObject.mock.calls.map(([query, params]) => ({
1175
+ query,
1176
+ params: params ?? []
1177
+ }));
1178
+ },
1179
+ /**
1180
+ * All TailorDB clients created, with their namespace and end state.
1181
+ * @returns Created clients array
1182
+ */
1183
+ get createdClients() {
1184
+ return createdClients;
1185
+ },
1186
+ /** Clear recorded calls while preserving configured query behavior. */
1187
+ clear() {
1188
+ queryObject.mockClear();
1189
+ connect.mockClear();
1190
+ Client.mockClear();
1191
+ createdClients.length = 0;
1192
+ },
1193
+ /** Reset query responses and recorded calls (keeps the mock installed). */
1194
+ reset() {
1195
+ queryObject.mockReset();
1196
+ queryObject.mockImplementation(defaultQuery);
1197
+ connect.mockReset();
1198
+ connect.mockImplementation(defaultConnect);
1199
+ Client.mockReset();
1200
+ Client.mockImplementation(defaultClient);
1201
+ createdClients.length = 0;
1202
+ rules.length = 0;
1203
+ queryResolver = void 0;
1204
+ }
1205
+ }, () => {
1206
+ root.Client = prevClient;
1207
+ });
1208
+ }
1209
+
1210
+ //#endregion
1211
+ //#region src/vitest/mocks/workflow.ts
1212
+ const originalProcedures = /* @__PURE__ */ new WeakMap();
1213
+ function replaceProcedure(target, key, current) {
1214
+ const original = originalProcedures.get(current) ?? current;
1215
+ const defaultImplementation = function(...args) {
1216
+ return Reflect.apply(original, this, args);
1217
+ };
1218
+ const mock = vi.fn(defaultImplementation);
1219
+ originalProcedures.set(mock, original);
1220
+ const record = target;
1221
+ record[key] = mock;
1222
+ return {
1223
+ mock,
1224
+ scoped: {
1225
+ mockClear: () => mock.mockClear(),
1226
+ mockReset: () => mock.mockReset(),
1227
+ restore: () => {
1228
+ if (record[key] === mock) record[key] = current;
1229
+ }
1230
+ }
1231
+ };
1232
+ }
1233
+ function replaceStart(definition) {
1234
+ return replaceProcedure(definition, "start", definition.start);
1235
+ }
1236
+ /**
1237
+ * Acquire a disposable mock for workflow operations (`tailor.workflow`).
1238
+ * Restored on dispose.
1239
+ *
1240
+ * The canonical `execJobFunction` and its `startJobFunction` alias share the
1241
+ * same underlying `vi.fn`, so calls through either name are recorded once and
1242
+ * handlers configured on either name apply to both.
1243
+ * @returns Disposable workflow mock control object
1244
+ * @example
1245
+ * ```typescript
1246
+ * import { mockWorkflow } from "@tailor-platform/sdk/vitest";
1247
+ *
1248
+ * test("job start", async () => {
1249
+ * using wf = mockWorkflow();
1250
+ * const job = wf.job(validateOrder);
1251
+ * job.mockResolvedValue({ valid: true });
1252
+ * await runWorkflowUnderTest();
1253
+ * expect(job).toHaveBeenCalled();
1254
+ * });
1255
+ * ```
1256
+ */
1257
+ function mockWorkflow() {
1258
+ const root = tailorRoot();
1259
+ const prev = root.workflow;
1260
+ const prevEnv = readWorkflowTestEnv();
1261
+ const jobSpies = /* @__PURE__ */ new Map();
1262
+ const workflowSpies = /* @__PURE__ */ new Map();
1263
+ const waitPointMocks = /* @__PURE__ */ new Map();
1264
+ const scopedMocks = /* @__PURE__ */ new Set();
1265
+ const defaultExecJob = (jobName, _args, _options) => {
1266
+ throw new Error(`No workflow job mock for "${jobName}". Call mockWorkflow().setJobHandler(...) or enqueueResult(...), or use runWorkflowLocally() for local workflow execution.`);
1267
+ };
1268
+ const defaultStartWorkflow = async (_workflowName, _args, _options) => {
1269
+ return START_DEFAULT;
1270
+ };
1271
+ const defaultResumeWorkflowExecution = async (executionId) => executionId;
1272
+ const execJobFunction = vi.fn(defaultExecJob);
1273
+ const startWorkflow = vi.fn(defaultStartWorkflow);
1274
+ const resumeWorkflowExecution = vi.fn(defaultResumeWorkflowExecution);
1275
+ const wait = vi.fn((_key, _payload) => null);
1276
+ const resolve = vi.fn(async (_executionId, _key, _callback) => {});
1277
+ const jobFunctionShim = (...call) => {
1278
+ const out = call.length >= 3 ? execJobFunction(call[0], platformSerialize(call[1]), call[2]) : execJobFunction(call[0], platformSerialize(call[1]));
1279
+ return out instanceof Promise ? out.then((v) => platformSerialize(v)) : platformSerialize(out);
1280
+ };
1281
+ const workflowShim = (...call) => call.length >= 3 ? startWorkflow(call[0], platformSerialize(call[1]), call[2]) : startWorkflow(call[0], platformSerialize(call[1]));
1282
+ const resumeShim = (executionId) => resumeWorkflowExecution(executionId);
1283
+ root.workflow = {
1284
+ execJobFunction: jobFunctionShim,
1285
+ startJobFunction: jobFunctionShim,
1286
+ startWorkflow: workflowShim,
1287
+ resumeWorkflowExecution: resumeShim,
1288
+ wait: (key, payload) => wait(key, platformSerialize(payload)),
1289
+ resolve: (executionId, key, callback) => resolve(executionId, key, (payload) => {
1290
+ const out = callback(payload);
1291
+ return out instanceof Promise ? out.then((v) => platformSerialize(v)) : platformSerialize(out);
1292
+ })
1293
+ };
1294
+ return withDispose({
1295
+ /** The `execJobFunction` `vi.fn`. */
1296
+ execJobFunction,
1297
+ /**
1298
+ * Alias of `execJobFunction` (same `vi.fn` reference).
1299
+ * @deprecated Use `execJobFunction` instead.
1300
+ */
1301
+ startJobFunction: execJobFunction,
1302
+ /** The `startWorkflow` `vi.fn`. */
1303
+ startWorkflow,
1304
+ /** The `resumeWorkflowExecution` `vi.fn`. */
1305
+ resumeWorkflowExecution,
1306
+ /** The `wait` `vi.fn`. */
1307
+ wait,
1308
+ /** The `resolve` `vi.fn`. */
1309
+ resolve,
1310
+ /**
1311
+ * Get a stable, typed mock for a workflow job's `start` method.
1312
+ * The real start behavior is used until an implementation or result is configured.
1313
+ * @param definition - Workflow job definition to mock
1314
+ * @returns Typed `start` mock for the definition
1315
+ */
1316
+ job(definition) {
1317
+ const existing = jobSpies.get(definition);
1318
+ if (existing) return existing;
1319
+ const { mock, scoped } = replaceStart(definition);
1320
+ scopedMocks.add(scoped);
1321
+ jobSpies.set(definition, mock);
1322
+ return mock;
1323
+ },
1324
+ /**
1325
+ * Get a stable, typed mock for a workflow definition's `start` method.
1326
+ * The real start behavior is used until an implementation or result is configured.
1327
+ * @param definition - Workflow definition to mock
1328
+ * @returns Typed `start` mock for the definition
1329
+ */
1330
+ workflow(definition) {
1331
+ const existing = workflowSpies.get(definition);
1332
+ if (existing) return existing;
1333
+ const { mock, scoped } = replaceStart(definition);
1334
+ workflowSpies.set(definition, mock);
1335
+ scopedMocks.add(scoped);
1336
+ return mock;
1337
+ },
1338
+ /**
1339
+ * Get stable, typed mocks for a wait point's `wait` and `resolve` methods.
1340
+ * @param definition - Wait point definition to mock
1341
+ * @returns Typed wait point mock control object
1342
+ */
1343
+ waitPoint(definition) {
1344
+ const existing = waitPointMocks.get(definition);
1345
+ if (existing) return existing;
1346
+ const waitReplacement = replaceProcedure(definition, "wait", definition.wait);
1347
+ const resolveReplacement = replaceProcedure(definition, "resolve", definition.resolve);
1348
+ const waitSpy = waitReplacement.mock;
1349
+ const resolveSpy = resolveReplacement.mock;
1350
+ scopedMocks.add(waitReplacement.scoped);
1351
+ scopedMocks.add(resolveReplacement.scoped);
1352
+ const waitPointMock = {
1353
+ wait: waitSpy,
1354
+ resolve: resolveSpy,
1355
+ /**
1356
+ * Invoke the next and subsequent resolve callbacks with a wait payload.
1357
+ * @param payload - Payload originally supplied to the wait point
1358
+ */
1359
+ setResolvePayload(payload) {
1360
+ resolveSpy.mockImplementation(async (_executionId, callback) => {
1361
+ platformSerialize(await callback(platformSerialize(payload)));
1362
+ });
1363
+ }
1364
+ };
1365
+ waitPointMocks.set(definition, waitPointMock);
1366
+ return waitPointMock;
1367
+ },
1368
+ /**
1369
+ * Set a fallback job handler. Called when the enqueue queue is empty.
1370
+ * @param handler - Function returning a result for a job name, args, and options
1371
+ */
1372
+ setJobHandler(handler) {
1373
+ execJobFunction.mockImplementation((name, args, options) => handler(name, args, options));
1374
+ },
1375
+ /**
1376
+ * Enqueue a single result for the next `execJobFunction` call (FIFO;
1377
+ * takes priority over `setJobHandler`).
1378
+ * @param result - Result to return from the next call
1379
+ */
1380
+ enqueueResult(result) {
1381
+ execJobFunction.mockImplementationOnce(() => result);
1382
+ },
1383
+ /**
1384
+ * Enqueue results for multiple subsequent `execJobFunction` calls (FIFO).
1385
+ * @param results - Results to enqueue, one per upcoming call
1386
+ */
1387
+ enqueueResults(...results) {
1388
+ for (const result of results) execJobFunction.mockImplementationOnce(() => result);
1389
+ },
1390
+ /**
1391
+ * All jobs executed via `execJobFunction`, in order.
1392
+ * @returns Started jobs array
1393
+ */
1394
+ get startedJobs() {
1395
+ return execJobFunction.mock.calls.map(([jobName, args, options]) => ({
1396
+ jobName,
1397
+ args,
1398
+ ...options !== void 0 && { options }
1399
+ }));
1400
+ },
1401
+ /**
1402
+ * Configure what `startWorkflow` returns. Pass a string (same id every
1403
+ * call) or `(name, args, options) => string`. Default: a placeholder UUID.
1404
+ * @param handler - Static execution ID or a function returning one
1405
+ */
1406
+ setStartHandler(handler) {
1407
+ startWorkflow.mockImplementation(typeof handler === "function" ? async (name, args, options) => handler(name, args, options) : async () => handler);
1408
+ },
1409
+ /**
1410
+ * Configure what `resumeWorkflowExecution` returns. Pass a string (same id
1411
+ * every call) or `(executionId) => string`. Default: echoes the input executionId.
1412
+ * @param handler - Static execution ID or a function returning one
1413
+ */
1414
+ setResumeHandler(handler) {
1415
+ resumeWorkflowExecution.mockImplementation(typeof handler === "function" ? async (executionId) => handler(executionId) : async () => handler);
1416
+ },
1417
+ /**
1418
+ * Configure what `wait` returns. Pass `(key, payload) => unknown` or any
1419
+ * other value to return it for every call. Default: `null`.
1420
+ * @param handler - Static value or a function returning one
1421
+ */
1422
+ setWaitHandler: ((handler) => {
1423
+ wait.mockImplementation(typeof handler === "function" ? (key, payload) => handler(key, payload) : () => handler);
1424
+ }),
1425
+ /**
1426
+ * Set the `env` passed to job bodies invoked via `createWorkflowJob().start()`.
1427
+ * Cleared on dispose / reset.
1428
+ * @param env - Env passed to job bodies.
1429
+ */
1430
+ setEnv(env) {
1431
+ writeWorkflowTestEnv({ ...env });
1432
+ },
1433
+ /**
1434
+ * Configure how `resolve` runs the user-supplied callback. Default: callback
1435
+ * is not invoked (records the call only).
1436
+ * @param handler - Function invoked per `resolve` call
1437
+ */
1438
+ setResolveHandler(handler) {
1439
+ resolve.mockImplementation(async (executionId, key, callback) => {
1440
+ await handler(executionId, key, callback);
1441
+ });
1442
+ },
1443
+ /**
1444
+ * `wait` calls reshaped as `{ key, payload }` for assertions.
1445
+ * @returns Wait call records
1446
+ */
1447
+ get waitCalls() {
1448
+ return wait.mock.calls.map(([key, payload]) => ({
1449
+ key,
1450
+ payload
1451
+ }));
1452
+ },
1453
+ /**
1454
+ * `resolve` calls reshaped as `{ executionId, key }` for assertions.
1455
+ * @returns Resolve call records
1456
+ */
1457
+ get resolveCalls() {
1458
+ return resolve.mock.calls.map(([executionId, key]) => ({
1459
+ executionId,
1460
+ key
1461
+ }));
1462
+ },
1463
+ /** Clear recorded calls while preserving configured responses. */
1464
+ clear() {
1465
+ execJobFunction.mockClear();
1466
+ startWorkflow.mockClear();
1467
+ resumeWorkflowExecution.mockClear();
1468
+ wait.mockClear();
1469
+ resolve.mockClear();
1470
+ for (const mock of scopedMocks) mock.mockClear();
1471
+ },
1472
+ /** Reset all workflow responses and recorded calls (keeps the mock installed). */
1473
+ reset() {
1474
+ execJobFunction.mockReset();
1475
+ execJobFunction.mockImplementation(defaultExecJob);
1476
+ startWorkflow.mockReset();
1477
+ startWorkflow.mockImplementation(defaultStartWorkflow);
1478
+ resumeWorkflowExecution.mockReset();
1479
+ resumeWorkflowExecution.mockImplementation(defaultResumeWorkflowExecution);
1480
+ wait.mockReset();
1481
+ wait.mockImplementation(() => null);
1482
+ resolve.mockReset();
1483
+ resolve.mockImplementation(async () => {});
1484
+ for (const mock of scopedMocks) mock.mockReset();
1485
+ clearWorkflowTestEnv();
1486
+ }
1487
+ }, () => {
1488
+ for (const mock of scopedMocks) mock.restore();
1489
+ root.workflow = prev;
1490
+ if (prevEnv !== void 0) writeWorkflowTestEnv(prevEnv);
1491
+ else clearWorkflowTestEnv();
1492
+ });
1493
+ }
1494
+
294
1495
  //#endregion
295
1496
  //#region src/vitest/workflow-local.ts
296
- var PendingTrigger = class {
1497
+ var PendingStart = class {
297
1498
  jobName;
298
1499
  args;
299
1500
  constructor(jobName, args) {
@@ -310,7 +1511,7 @@ async function runWorkflowLocally(workflow, args, options) {
310
1511
  if (options?.env !== void 0) writeWorkflowTestEnv({ ...options.env });
311
1512
  root.tailor = {
312
1513
  ...previousTailor,
313
- workflow: createLocalWorkflowRuntime(previousTailor?.workflow, runner.triggerJobFunction)
1514
+ workflow: createLocalWorkflowRuntime(previousTailor?.workflow, runner.startJobFunction)
314
1515
  };
315
1516
  try {
316
1517
  return await runner.runJob(workflow.mainJob.name, args);
@@ -323,19 +1524,19 @@ async function runWorkflowLocally(workflow, args, options) {
323
1524
  }
324
1525
  function createLocalJobRunner() {
325
1526
  let activeExecution;
326
- const triggerJobFunction = (jobName, args) => {
327
- if (!activeExecution) throw new Error(`Cannot trigger workflow job "${jobName}" outside runWorkflowLocally() job execution.`);
1527
+ const startJobFunction = (jobName, args) => {
1528
+ if (!activeExecution) throw new Error(`Cannot start workflow job "${jobName}" outside runWorkflowLocally() job execution.`);
328
1529
  if (activeExecution.pending) throw activeExecution.pending;
329
1530
  const serializedArgs = platformSerialize(args);
330
1531
  const index = activeExecution.cursor;
331
1532
  activeExecution.cursor += 1;
332
1533
  const cached = activeExecution.records[index];
333
1534
  if (cached) {
334
- assertSameTrigger(cached, jobName, serializedArgs);
1535
+ assertSameStart(cached, jobName, serializedArgs);
335
1536
  if (cached.status === "rejected") throw cached.error;
336
1537
  return platformSerialize(cached.result);
337
1538
  }
338
- const pending = new PendingTrigger(jobName, serializedArgs);
1539
+ const pending = new PendingStart(jobName, serializedArgs);
339
1540
  activeExecution.pending = pending;
340
1541
  throw pending;
341
1542
  };
@@ -353,15 +1554,15 @@ function createLocalJobRunner() {
353
1554
  try {
354
1555
  const out = await body(platformSerialize(args), buildJobContext());
355
1556
  if (execution.pending) {
356
- await settlePendingTrigger(records, execution.pending, runJob);
1557
+ await settlePendingStart(records, execution.pending, runJob);
357
1558
  continue;
358
1559
  }
359
- if (execution.cursor !== records.length) throw new Error(`Workflow job trigger sequence changed while replaying "${name}". Expected ${records.length} trigger(s), but replay reached ${execution.cursor}.`);
1560
+ if (execution.cursor !== records.length) throw new Error(`Workflow job start sequence changed while replaying "${name}". Expected ${records.length} start(s), but replay reached ${execution.cursor}.`);
360
1561
  return platformSerialize(out);
361
1562
  } catch (cause) {
362
- const pending = cause instanceof PendingTrigger ? cause : execution.pending;
1563
+ const pending = cause instanceof PendingStart ? cause : execution.pending;
363
1564
  if (pending) {
364
- await settlePendingTrigger(records, pending, runJob);
1565
+ await settlePendingStart(records, pending, runJob);
365
1566
  continue;
366
1567
  }
367
1568
  throw cause;
@@ -372,10 +1573,10 @@ function createLocalJobRunner() {
372
1573
  };
373
1574
  return {
374
1575
  runJob,
375
- triggerJobFunction
1576
+ startJobFunction
376
1577
  };
377
1578
  }
378
- async function settlePendingTrigger(records, pending, runJob) {
1579
+ async function settlePendingStart(records, pending, runJob) {
379
1580
  try {
380
1581
  records.push({
381
1582
  jobName: pending.jobName,
@@ -392,18 +1593,25 @@ async function settlePendingTrigger(records, pending, runJob) {
392
1593
  });
393
1594
  }
394
1595
  }
395
- function assertSameTrigger(record, jobName, args) {
1596
+ function assertSameStart(record, jobName, args) {
396
1597
  if (record.jobName === jobName && JSON.stringify(record.args) === JSON.stringify(args)) return;
397
- throw new Error(`Workflow job trigger sequence changed while replaying. Expected ${record.jobName}(${JSON.stringify(record.args)}), but got ${jobName}(${JSON.stringify(args)}).`);
1598
+ throw new Error(`Workflow job start sequence changed while replaying. Expected ${record.jobName}(${JSON.stringify(record.args)}), but got ${jobName}(${JSON.stringify(args)}).`);
398
1599
  }
399
- function createLocalWorkflowRuntime(previous, triggerJobFunction) {
1600
+ function createLocalWorkflowRuntime(previous, execJobFunction) {
1601
+ const startWorkflow = async (name, args, options) => {
1602
+ if (previous) return await previous.startWorkflow(name, args, options);
1603
+ platformSerialize(args);
1604
+ return START_DEFAULT;
1605
+ };
1606
+ const resumeWorkflowExecution = async (executionId) => {
1607
+ if (previous) return await previous.resumeWorkflowExecution(executionId);
1608
+ return executionId;
1609
+ };
400
1610
  return {
401
- triggerJobFunction,
402
- triggerWorkflow: async (name, args, options) => {
403
- if (previous) return await previous.triggerWorkflow(name, args, options);
404
- platformSerialize(args);
405
- return TRIGGER_DEFAULT;
406
- },
1611
+ execJobFunction,
1612
+ startJobFunction: execJobFunction,
1613
+ startWorkflow,
1614
+ resumeWorkflowExecution,
407
1615
  wait: (key, payload) => {
408
1616
  if (previous) return previous.wait(key, payload);
409
1617
  throw new Error(`No wait handler for "${key}". Acquire mockWorkflow() and call setWaitHandler(...).`);
@@ -608,7 +1816,8 @@ function createKyselyMock() {
608
1816
  *
609
1817
  * 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with
610
1818
  * control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`,
611
- * `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`. Each
1819
+ * `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway`,
1820
+ * `mockLogger`. Each
612
1821
  * provides response configuration, call recording, and reset.
613
1822
  *
614
1823
  * 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the
@@ -646,5 +1855,5 @@ function tailorRuntime(options) {
646
1855
  }
647
1856
 
648
1857
  //#endregion
649
- export { createKyselyMock, mockAuthconnection, mockFile, mockIconv, mockIdp, mockSecretmanager, mockTailordb, mockWorkflow, runWorkflowLocally, tailorRuntime };
1858
+ export { createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockLogger, mockSecretmanager, mockTailordb, mockWorkflow, runWorkflowLocally, tailorRuntime };
650
1859
  //# sourceMappingURL=index.mjs.map