@tailor-platform/sdk 2.0.0-next.0 → 2.0.0-next.2

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 (208) hide show
  1. package/CHANGELOG.md +161 -0
  2. package/dist/application-Dtqap5jM.mjs +3 -0
  3. package/dist/{client-CobIRHl-.mjs → application-XuMWK4eq.mjs} +5869 -25
  4. package/dist/application-XuMWK4eq.mjs.map +1 -0
  5. package/dist/{assert-CKfwrmCV.mjs → assert-DBxo8jPo.mjs} +1 -2
  6. package/dist/{assert-CKfwrmCV.mjs.map → assert-DBxo8jPo.mjs.map} +1 -1
  7. package/dist/{authconnection-D8SJGMpj.mjs → authconnection-D2MhtTN5.mjs} +2 -3
  8. package/dist/{authconnection-D8SJGMpj.mjs.map → authconnection-D2MhtTN5.mjs.map} +1 -1
  9. package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-DvUQAjQS.d.mts} +1 -1
  10. package/dist/{brand-DlnJ375c.mjs → brand-Eo4pLXPJ.mjs} +1 -2
  11. package/dist/{brand-DlnJ375c.mjs.map → brand-Eo4pLXPJ.mjs.map} +1 -1
  12. package/dist/cli/index.mjs +241 -237
  13. package/dist/cli/index.mjs.map +1 -1
  14. package/dist/cli/lib.d.mts +547 -620
  15. package/dist/cli/lib.mjs +9 -11
  16. package/dist/cli/lib.mjs.map +1 -1
  17. package/dist/completion/zsh-worker.zsh +4108 -0
  18. package/dist/configure/index.d.mts +9 -7
  19. package/dist/configure/index.mjs +76 -40
  20. package/dist/configure/index.mjs.map +1 -1
  21. package/dist/{context-s0lxhu8_.mjs → context-Bd266-ru.mjs} +2 -3
  22. package/dist/context-Bd266-ru.mjs.map +1 -0
  23. package/dist/{context-CUBwSBq4.d.mts → context-C2lEi9uw.d.mts} +7 -28
  24. package/dist/{crashreport-D1wKBJ8N.mjs → crashreport-BMWcxeSE.mjs} +1 -2
  25. package/dist/{crashreport-BhD0y14F.mjs → crashreport-DFq-vsU0.mjs} +21 -14
  26. package/dist/{crashreport-BhD0y14F.mjs.map → crashreport-DFq-vsU0.mjs.map} +1 -1
  27. package/dist/{enum-constants-C7DaWeQo.mjs → enum-constants-j9QBF0cB.mjs} +1 -2
  28. package/dist/enum-constants-j9QBF0cB.mjs.map +1 -0
  29. package/dist/{errors-EsY4XO6O.mjs → errors-Dtf2WPaW.mjs} +1 -2
  30. package/dist/{errors-EsY4XO6O.mjs.map → errors-Dtf2WPaW.mjs.map} +1 -1
  31. package/dist/{field-C4zdJLW5.mjs → field-DOsJCPFa.mjs} +1 -2
  32. package/dist/field-DOsJCPFa.mjs.map +1 -0
  33. package/dist/{file-B58Dm-2P.mjs → file-BbdFGdMV.mjs} +3 -12
  34. package/dist/file-BbdFGdMV.mjs.map +1 -0
  35. package/dist/{file-BzK8z3X-.d.mts → file-Dq3NIt_F.d.mts} +3 -42
  36. package/dist/{file-utils-BHPxPXmn.mjs → file-utils-CYZnO1pX.mjs} +6 -7
  37. package/dist/file-utils-CYZnO1pX.mjs.map +1 -0
  38. package/dist/{globals-ByrCoDip.mjs → globals-Cf0sxIt8.mjs} +53 -5
  39. package/dist/globals-Cf0sxIt8.mjs.map +1 -0
  40. package/dist/http-adapter.generated-DFsXDdm5.d.mts +581 -0
  41. package/dist/{iconv-kwrmd1U_.d.mts → iconv-Co-TOPuH.d.mts} +1 -1
  42. package/dist/{iconv-DreIffeM.mjs → iconv-D2vi8G36.mjs} +2 -3
  43. package/dist/{iconv-DreIffeM.mjs.map → iconv-D2vi8G36.mjs.map} +1 -1
  44. package/dist/{idp-Ch95ag8h.mjs → idp-BDbK5gjm.mjs} +2 -3
  45. package/dist/{idp-Ch95ag8h.mjs.map → idp-BDbK5gjm.mjs.map} +1 -1
  46. package/dist/{idp-BlBPtXJ-.d.mts → idp-DrhVrLmV.d.mts} +1 -1
  47. package/dist/{index-CLxubakC.d.mts → index-BI-_j9Z3.d.mts} +49 -261
  48. package/dist/{index-CPRnOjjt.d.mts → index-C4JirJH8.d.mts} +2 -2
  49. package/dist/{index-CQZVJ5SX.d.mts → index-CZfWhr0a.d.mts} +2 -2
  50. package/dist/{index-DRhMpdnA.d.mts → index-Cg8VKAdN.d.mts} +8 -8
  51. package/dist/{index-CfRFkXIO.d.mts → index-DYRjoLXD.d.mts} +2 -2
  52. package/dist/index-lFpcjHPU.d.mts +201 -0
  53. package/dist/{index-DUupuPhZ.d.mts → index-nW7hE6oE.d.mts} +2 -2
  54. package/dist/{interceptor-DOqRkCya.mjs → interceptor-D-q1rvRl.mjs} +1 -2
  55. package/dist/{interceptor-DOqRkCya.mjs.map → interceptor-D-q1rvRl.mjs.map} +1 -1
  56. package/dist/kysely/index.mjs +0 -1
  57. package/dist/kysely/index.mjs.map +1 -1
  58. package/dist/{kysely-type-D1e0Vwkd.mjs → kysely-type-DR8uzZTA.mjs} +2 -3
  59. package/dist/kysely-type-DR8uzZTA.mjs.map +1 -0
  60. package/dist/{logger-DpJyJvNz.mjs → logger-CxF-Ex5d.mjs} +1 -2
  61. package/dist/{logger-DpJyJvNz.mjs.map → logger-CxF-Ex5d.mjs.map} +1 -1
  62. package/dist/{mock-DMgIygjE.mjs → mock-FPxmnt-y.mjs} +9 -56
  63. package/dist/mock-FPxmnt-y.mjs.map +1 -0
  64. package/dist/{multiline-Cf9ODpr1.mjs → multiline-sfHpTZZK.mjs} +1 -2
  65. package/dist/{multiline-Cf9ODpr1.mjs.map → multiline-sfHpTZZK.mjs.map} +1 -1
  66. package/dist/{package-json-DcQApfPQ.mjs → package-json-8b0O9TlX.mjs} +1 -2
  67. package/dist/{package-json-DcQApfPQ.mjs.map → package-json-8b0O9TlX.mjs.map} +1 -1
  68. package/dist/package-json-Cv2Z-TqQ.mjs +3 -0
  69. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  70. package/dist/plugin/builtin/enum-constants/index.mjs +1 -2
  71. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  72. package/dist/plugin/builtin/file-utils/index.mjs +1 -2
  73. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  74. package/dist/plugin/builtin/kysely-type/index.mjs +1 -2
  75. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  76. package/dist/plugin/builtin/seed/index.mjs +1 -2
  77. package/dist/plugin/index.d.mts +4 -5
  78. package/dist/plugin/index.mjs +0 -1
  79. package/dist/plugin/index.mjs.map +1 -1
  80. package/dist/registry-DH4m7eYo.mjs +53 -0
  81. package/dist/registry-DH4m7eYo.mjs.map +1 -0
  82. package/dist/{repl-editor-CJG3sz7A.mjs → repl-editor-DmGr9zMw.mjs} +2 -3
  83. package/dist/{repl-editor-CJG3sz7A.mjs.map → repl-editor-DmGr9zMw.mjs.map} +1 -1
  84. package/dist/{chunk-BkoGK1jX.mjs → rolldown-runtime-DXywRVcq.mjs} +0 -1
  85. package/dist/runtime/authconnection.d.mts +1 -1
  86. package/dist/runtime/authconnection.mjs +1 -2
  87. package/dist/runtime/context.d.mts +1 -1
  88. package/dist/runtime/context.mjs +1 -2
  89. package/dist/runtime/file.d.mts +2 -2
  90. package/dist/runtime/file.mjs +2 -3
  91. package/dist/runtime/globals.d.mts +8 -41
  92. package/dist/runtime/globals.mjs +0 -1
  93. package/dist/runtime/iconv.d.mts +1 -1
  94. package/dist/runtime/iconv.mjs +1 -2
  95. package/dist/runtime/idp.d.mts +1 -1
  96. package/dist/runtime/idp.mjs +1 -2
  97. package/dist/runtime/index.d.mts +8 -8
  98. package/dist/runtime/index.mjs +7 -8
  99. package/dist/runtime/secretmanager.d.mts +1 -1
  100. package/dist/runtime/secretmanager.mjs +1 -2
  101. package/dist/runtime/workflow.d.mts +2 -2
  102. package/dist/runtime/workflow.mjs +1 -2
  103. package/dist/{runtime-C7qTBDD2.mjs → runtime-CY4JvrDj.mjs} +1069 -542
  104. package/dist/runtime-CY4JvrDj.mjs.map +1 -0
  105. package/dist/{schema-1msIhXwA.mjs → schema-Dtw9Orye.mjs} +18 -16
  106. package/dist/schema-Dtw9Orye.mjs.map +1 -0
  107. package/dist/{secret-file-CWzF8rry.mjs → secret-file-VSVGy1V0.mjs} +27 -3
  108. package/dist/{secret-file-CWzF8rry.mjs.map → secret-file-VSVGy1V0.mjs.map} +1 -1
  109. package/dist/{secretmanager-CKLB3wAQ.d.mts → secretmanager-B3n4KHfm.d.mts} +1 -1
  110. package/dist/{secretmanager-B9h-U_8U.mjs → secretmanager-BVxw3ih_.mjs} +2 -3
  111. package/dist/{secretmanager-B9h-U_8U.mjs.map → secretmanager-BVxw3ih_.mjs.map} +1 -1
  112. package/dist/seed/index.mjs +0 -1
  113. package/dist/seed/index.mjs.map +1 -1
  114. package/dist/{seed-BH2FbrPV.mjs → seed-izIEyP3z.mjs} +7 -19
  115. package/dist/seed-izIEyP3z.mjs.map +1 -0
  116. package/dist/service-DCqIWibD.mjs +3 -0
  117. package/dist/{service-DMohAx8a2.mjs → service-DU1mVzri2.mjs} +3 -4
  118. package/dist/{service-DMohAx8a2.mjs.map → service-DU1mVzri2.mjs.map} +1 -1
  119. package/dist/{service-wI3Hvrgx.mjs → service-DjyqbCaJ.mjs} +9 -10
  120. package/dist/service-DjyqbCaJ.mjs.map +1 -0
  121. package/dist/{telemetry-BQbbVo2t.mjs → telemetry-CdqJEzkj.mjs} +2 -3
  122. package/dist/{telemetry-BQbbVo2t.mjs.map → telemetry-CdqJEzkj.mjs.map} +1 -1
  123. package/dist/telemetry-ClwW5ohF.mjs +3 -0
  124. package/dist/test-env-key-D7UkZp99.mjs +75 -0
  125. package/dist/test-env-key-D7UkZp99.mjs.map +1 -0
  126. package/dist/type-source-DH_LH20p.mjs +13 -0
  127. package/dist/type-source-DH_LH20p.mjs.map +1 -0
  128. package/dist/types-74etvaxy.mjs +4 -0
  129. package/dist/{plugin-C_FyVSdl.d.mts → types-BDRml5C3.d.mts} +128 -188
  130. package/dist/{types-CmzfQP_m.mjs → types-BQijbo4m.mjs} +10 -11
  131. package/dist/types-BQijbo4m.mjs.map +1 -0
  132. package/dist/types-BX4q6Mo6.d.mts +339 -0
  133. package/dist/types-BZ7QKVE8.d.mts +21 -0
  134. package/dist/{tailordb-BlBGmQK-.d.mts → types-CdcQh4Z2.d.mts} +92 -242
  135. package/dist/utils/test/index.d.mts +6 -14
  136. package/dist/utils/test/index.mjs +4 -14
  137. package/dist/utils/test/index.mjs.map +1 -1
  138. package/dist/vitest/environment.mjs +1 -2
  139. package/dist/vitest/environment.mjs.map +1 -1
  140. package/dist/vitest/index.d.mts +42 -5
  141. package/dist/vitest/index.mjs +133 -4
  142. package/dist/vitest/index.mjs.map +1 -1
  143. package/dist/vitest/setup.mjs +2 -3
  144. package/dist/vitest/setup.mjs.map +1 -1
  145. package/dist/{workflow--aPbA8Uq.mjs → workflow-BOmaZwwG.mjs} +9 -5
  146. package/dist/workflow-BOmaZwwG.mjs.map +1 -0
  147. package/dist/{workflow-CMamswkK.d.mts → workflow-BVy4XWjS.d.mts} +15 -10
  148. package/dist/workflow.generated-ClEjBYhm.d.mts +671 -0
  149. package/docs/cli/application.md +0 -2
  150. package/docs/cli/completion.md +3 -0
  151. package/docs/cli/crashreport.md +0 -2
  152. package/docs/cli/executor.md +53 -0
  153. package/docs/cli/function.md +1 -1
  154. package/docs/cli/setup.md +35 -33
  155. package/docs/cli/user.md +3 -3
  156. package/docs/cli/workflow.md +157 -20
  157. package/docs/cli/workspace.md +3 -3
  158. package/docs/cli-reference.md +26 -20
  159. package/docs/configuration.md +0 -2
  160. package/docs/github-actions.md +29 -16
  161. package/docs/migration/v2.md +475 -0
  162. package/docs/plugin/custom.md +2 -2
  163. package/docs/plugin/index.md +1 -1
  164. package/docs/runtime.md +4 -4
  165. package/docs/services/aigateway.md +97 -0
  166. package/docs/services/auth.md +31 -14
  167. package/docs/services/executor.md +3 -5
  168. package/docs/services/resolver.md +8 -10
  169. package/docs/services/tailordb.md +15 -13
  170. package/docs/services/workflow.md +17 -19
  171. package/docs/testing.md +75 -56
  172. package/package.json +18 -17
  173. package/dist/actor-J2gJ0eK5.d.mts +0 -24
  174. package/dist/application-76hhIhnJ.mjs +0 -5594
  175. package/dist/application-76hhIhnJ.mjs.map +0 -1
  176. package/dist/application-av2raLs6.mjs +0 -4
  177. package/dist/cli/skills.d.mts +0 -1
  178. package/dist/cli/skills.mjs +0 -22
  179. package/dist/cli/skills.mjs.map +0 -1
  180. package/dist/client-C68VWo4g.mjs +0 -4
  181. package/dist/client-CobIRHl-.mjs.map +0 -1
  182. package/dist/context-s0lxhu8_.mjs.map +0 -1
  183. package/dist/enum-constants-C7DaWeQo.mjs.map +0 -1
  184. package/dist/env-B-g-qgE4.d.mts +0 -7
  185. package/dist/field-C4zdJLW5.mjs.map +0 -1
  186. package/dist/file-B58Dm-2P.mjs.map +0 -1
  187. package/dist/file-utils-BHPxPXmn.mjs.map +0 -1
  188. package/dist/globals-ByrCoDip.mjs.map +0 -1
  189. package/dist/job-BpsFXPbi.mjs +0 -54
  190. package/dist/job-BpsFXPbi.mjs.map +0 -1
  191. package/dist/kysely-type-D1e0Vwkd.mjs.map +0 -1
  192. package/dist/mock-DMgIygjE.mjs.map +0 -1
  193. package/dist/package-json-wzO6nV9O.mjs +0 -4
  194. package/dist/registry-D0uB0OrK.mjs +0 -178
  195. package/dist/registry-D0uB0OrK.mjs.map +0 -1
  196. package/dist/runtime-C7qTBDD2.mjs.map +0 -1
  197. package/dist/schema-1msIhXwA.mjs.map +0 -1
  198. package/dist/seed-BH2FbrPV.mjs.map +0 -1
  199. package/dist/service-BHQIerYh.mjs +0 -4
  200. package/dist/service-wI3Hvrgx.mjs.map +0 -1
  201. package/dist/telemetry-w92bvGdC.mjs +0 -4
  202. package/dist/types-2Be3wSMc.mjs +0 -5
  203. package/dist/types-CmzfQP_m.mjs.map +0 -1
  204. package/dist/workflow--aPbA8Uq.mjs.map +0 -1
  205. package/dist/workflow.generated-Bf1tWylx.d.mts +0 -1416
  206. package/docs/generator/builtin.md +0 -257
  207. package/docs/generator/custom.md +0 -147
  208. package/docs/generator/index.md +0 -66
@@ -1,6 +1,6 @@
1
1
  # GitHub Actions Integration
2
2
 
3
- `tailor-sdk setup github` generates a GitHub Actions workflow that deploys your
3
+ `tailor-sdk setup` generates a GitHub Actions workflow that deploys your
4
4
  Tailor Platform application automatically on push or tag.
5
5
 
6
6
  > **Beta:** This command is under active development. CLI flags, the generated
@@ -14,13 +14,16 @@ lives):
14
14
 
15
15
  ```bash
16
16
  # Branch target: deploy to stg on every push to main
17
- tailor-sdk setup github -n my-app-stg
17
+ tailor-sdk setup -n my-app-stg
18
18
 
19
19
  # Tag target: deploy to production when a tag is pushed, with an approval gate
20
- tailor-sdk setup github -n my-app-prod \
20
+ tailor-sdk setup -n my-app-prod \
21
21
  --tag --branch main --environment production
22
22
  ```
23
23
 
24
+ `setup` defaults to the GitHub provider; `--provider github` (`-p github`) is
25
+ accepted but optional, and other providers are not yet supported.
26
+
24
27
  After running the command, follow the **Next steps** printed to the terminal to
25
28
  set the required secrets, set the `TAILOR_PLATFORM_WORKSPACE_ID` variable, and
26
29
  commit the generated files.
@@ -33,7 +36,7 @@ before the first deploy (see [Targeting a workspace](#targeting-a-workspace)).
33
36
  ## Targets
34
37
 
35
38
  A _target_ is one workflow file that handles one deployment destination.
36
- Run `setup github` once per target.
39
+ Run `setup` once per target.
37
40
 
38
41
  ### Branch target (recommended for staging)
39
42
 
@@ -41,9 +44,9 @@ The branch target fires on pull requests and pushes to the branch you specify
41
44
  (defaulting to the repository's default branch when `--branch` is omitted):
42
45
 
43
46
  ```bash
44
- tailor-sdk setup github -n my-app-stg
47
+ tailor-sdk setup -n my-app-stg
45
48
  # Equivalent to:
46
- tailor-sdk setup github -n my-app-stg --branch main
49
+ tailor-sdk setup -n my-app-stg --branch main
47
50
  ```
48
51
 
49
52
  What it does:
@@ -66,7 +69,7 @@ The tag target fires when a tag matching `--tag-pattern` (default `v*`) is
66
69
  pushed:
67
70
 
68
71
  ```bash
69
- tailor-sdk setup github -n my-app-prod \
72
+ tailor-sdk setup -n my-app-prod \
70
73
  --tag --tag-pattern "v*" --branch main --environment production
71
74
  ```
72
75
 
@@ -136,7 +139,7 @@ environment is planned.)
136
139
 
137
140
  ## Generated files
138
141
 
139
- Running `setup github` creates or updates:
142
+ Running `setup` creates or updates:
140
143
 
141
144
  ### `.github/workflows/tailor-<workspace-name>.yml`
142
145
 
@@ -148,10 +151,10 @@ edit or rename them — the SDK tracks them by id.
148
151
 
149
152
  You can add your own jobs and steps around the managed ones. To add
150
153
  project-specific setup (such as private registry authentication or a system
151
- dependency), add a step _before_ the managed setup steps. For post-install
152
- extras (such as `playwright install`), add a step _after_ them.
154
+ dependency), add a step _before_ the managed `tailor-setup` step. For
155
+ post-install extras (such as `playwright install`), add a step _after_ it.
153
156
 
154
- Note that re-running `setup github` currently regenerates the whole file: if
157
+ Note that re-running `setup` currently regenerates the whole file: if
155
158
  the file differs from what the SDK last wrote — whether you edited a managed
156
159
  step or added your own — the command stops and reports the conflict. Pass
157
160
  `--force` to discard your edits and regenerate from the current template, then
@@ -167,7 +170,7 @@ detect hand edits.
167
170
 
168
171
  ### `tailor.config.ts` (id injection)
169
172
 
170
- If your config does not already have an `id` field, `setup github` injects one.
173
+ If your config does not already have an `id` field, `setup` injects one.
171
174
  This `id` must be committed alongside the workflow file. In CI, `tailor-sdk
172
175
  deploy` refuses to inject a new id — if the id were assigned fresh on each CI
173
176
  run, every deploy would create a brand-new application and lose ownership of
@@ -238,7 +241,7 @@ you can deploy any commit regardless of branch membership.
238
241
  For a monorepo where your SDK app lives in a subdirectory, pass `--dir`:
239
242
 
240
243
  ```bash
241
- tailor-sdk setup github -n my-app --dir apps/backend
244
+ tailor-sdk setup -n my-app --dir apps/backend
242
245
  ```
243
246
 
244
247
  The generated workflow adds a `paths` filter on `apps/backend/**` so the
@@ -303,10 +306,10 @@ A typical setup with staging and production:
303
306
 
304
307
  ```bash
305
308
  # Staging: main → stg (deploy on every push to main)
306
- tailor-sdk setup github -n my-app-stg
309
+ tailor-sdk setup -n my-app-stg
307
310
 
308
311
  # Production: tagged commits → prod, with approval gate and branch guard
309
- tailor-sdk setup github -n my-app-prod \
312
+ tailor-sdk setup -n my-app-prod \
310
313
  --tag --branch main --environment production
311
314
  ```
312
315
 
@@ -326,9 +329,19 @@ gh secret set TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET --env production
326
329
 
327
330
  Commit both workflow files and `.github/tailor-sdk.lock`.
328
331
 
332
+ ## Checking for drift
333
+
334
+ `tailor-sdk setup check` audits the workflows recorded in
335
+ `.github/tailor-sdk.lock` against your current config and repository, without
336
+ writing anything. It reports when a workflow file is missing or hand-edited, a
337
+ newer template is available, `tailor.config.ts` is no longer under the recorded
338
+ `--dir`, or the repository default branch no longer matches a branch target's
339
+ trigger. It exits non-zero when it finds drift, so you can run it in CI. Each
340
+ finding names a stable rule key for future suppression.
341
+
329
342
  ## Updating the generated workflow
330
343
 
331
- When you upgrade the SDK, re-run `setup github` with the same flags to pick up
344
+ When you upgrade the SDK, re-run `setup` with the same flags to pick up
332
345
  template improvements. If the SDK detects that you have hand-edited a managed
333
346
  section, it stops and asks you to use `--force` to overwrite your edits, or to
334
347
  move your customizations into your own steps before regenerating.
@@ -0,0 +1,475 @@
1
+ # Migrating to v2
2
+
3
+ <!-- Generated from the sdk-codemod registry. Run `pnpm codemod:docs:update` and edit `packages/sdk-codemod/src/registry.ts` instead of this file. -->
4
+
5
+ Run the codemods, then finish anything reported as not migrated automatically:
6
+
7
+ ```sh
8
+ npx @tailor-platform/sdk-codemod --from <current-version> --to <target-version>
9
+ ```
10
+
11
+ ## defineGenerators → definePlugins
12
+
13
+ **Migration:** Partially automatic
14
+
15
+ Migrate defineGenerators() tuple syntax to definePlugins() with explicit plugin imports
16
+
17
+ Before:
18
+
19
+ ```ts
20
+ import { defineGenerators } from "@tailor-platform/sdk";
21
+
22
+ export const generators = defineGenerators(
23
+ ["@tailor-platform/kysely-type", { distPath: "db.ts" }],
24
+ );
25
+ ```
26
+
27
+ After:
28
+
29
+ ```ts
30
+ import { definePlugins } from "@tailor-platform/sdk";
31
+ import { kyselyTypePlugin } from "@tailor-platform/sdk/plugin/kysely-type";
32
+
33
+ export const generators = definePlugins(kyselyTypePlugin({ distPath: "db.ts" }));
34
+ ```
35
+
36
+ <details>
37
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
38
+
39
+ ```text
40
+ defineGenerators() is replaced by definePlugins() in v2. The codemod rewrites the
41
+ known plugin tuples (kysely-type, enum-constants, file-utils, seed). For any
42
+ remaining defineGenerators([...]) the codemod left in place — a plugin it does not
43
+ know, or a non-tuple/spread form — convert it to definePlugins(pluginFn(config)),
44
+ importing the matching plugin from its @tailor-platform/sdk/plugin/<name> subpath.
45
+ ```
46
+
47
+ </details>
48
+
49
+ ## @tailor-platform/sdk/cli plugin imports → dedicated subpaths
50
+
51
+ **Migration:** Automatic
52
+
53
+ Rewrite deprecated plugin re-export imports (kyselyTypePlugin, enumConstantsPlugin, fileUtilsPlugin, seedPlugin) from `@tailor-platform/sdk/cli` to their dedicated plugin subpaths
54
+
55
+ Before:
56
+
57
+ ```ts
58
+ import { kyselyTypePlugin } from "@tailor-platform/sdk/cli";
59
+ ```
60
+
61
+ After:
62
+
63
+ ```ts
64
+ import { kyselyTypePlugin } from "@tailor-platform/sdk/plugin/kysely-type";
65
+ ```
66
+
67
+ ## function test-run --arg input unwrap
68
+
69
+ **Migration:** Automatic
70
+
71
+ Strip the deprecated {input: ...} wrapper from `tailor-sdk function test-run --arg` JSON in scripts and docs
72
+
73
+ Before:
74
+
75
+ ```sh
76
+ tailor-sdk function test-run resolvers/add.ts --arg '{"input":{"a":1}}'
77
+ ```
78
+
79
+ After:
80
+
81
+ ```sh
82
+ tailor-sdk function test-run resolvers/add.ts --arg '{"a":1}'
83
+ ```
84
+
85
+ ## tailor-sdk-skills → tailor-sdk skills install
86
+
87
+ **Migration:** Partially automatic
88
+
89
+ Replace deprecated `tailor-sdk-skills` invocations with `tailor-sdk skills install`
90
+
91
+ Before:
92
+
93
+ ```sh
94
+ npx tailor-sdk-skills
95
+ ```
96
+
97
+ After:
98
+
99
+ ```sh
100
+ tailor-sdk skills install
101
+ ```
102
+
103
+ <details>
104
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
105
+
106
+ ```text
107
+ The standalone tailor-sdk-skills binary is removed in v2; call the skills install
108
+ subcommand on the main tailor-sdk CLI instead. Replace any remaining
109
+ tailor-sdk-skills invocations the codemod did not rewrite with
110
+ `tailor-sdk skills install`.
111
+ ```
112
+
113
+ </details>
114
+
115
+ ## Unify TailorUser/TailorActor/TailorActorType/TailorInvoker → TailorPrincipal
116
+
117
+ **Migration:** Partially automatic
118
+
119
+ Rename TailorUser/TailorActor/TailorActorType/TailorInvoker to TailorPrincipal, drop unauthenticatedTailorUser, rename resolver body `user` to `caller`, and rename TailorDB callback `user` to `invoker`
120
+
121
+ Type references unify under `TailorPrincipal`:
122
+
123
+ Before:
124
+
125
+ ```ts
126
+ import type { TailorUser } from "@tailor-platform/sdk";
127
+ ```
128
+
129
+ After:
130
+
131
+ ```ts
132
+ import type { TailorPrincipal } from "@tailor-platform/sdk";
133
+ ```
134
+
135
+ The resolver body `user` becomes `caller`:
136
+
137
+ Before:
138
+
139
+ ```ts
140
+ body: ({ input, user }) => user.id,
141
+ ```
142
+
143
+ After:
144
+
145
+ ```ts
146
+ body: ({ input, caller }) => caller.id,
147
+ ```
148
+
149
+ <details>
150
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
151
+
152
+ ```text
153
+ Finish the cases the codemod left for manual migration:
154
+ - Rename user -> caller in resolver bodies the codemod skipped because a `caller`
155
+ binding already exists or renaming would shadow/collide with another value.
156
+ - Replace member-access on the removed unauthenticatedTailorUser (e.g.
157
+ unauthenticatedTailorUser.id); the codemod only replaced standalone references
158
+ with null and left member access to surface a type error.
159
+ - Review helper adapters that still accept or read `context.user`; v2 resolver
160
+ context uses nullable `caller` and `invoker`, so project-specific helper
161
+ semantics for anonymous callers and command invokers must be chosen explicitly.
162
+ - Review `caller?.` values passed to APIs that require non-null values. If the
163
+ resolver requires authentication, throw or otherwise narrow before the call;
164
+ if anonymous callers are allowed, keep the nullable flow explicit.
165
+ Use TailorPrincipal for the unified user/actor/invoker type.
166
+ ```
167
+
168
+ </details>
169
+
170
+ ## tailor-sdk apply → tailor-sdk deploy
171
+
172
+ **Migration:** Automatic
173
+
174
+ Rewrite `tailor-sdk apply` invocations in package.json scripts, shell scripts, CI configs, and docs to the canonical v2 `tailor-sdk deploy` command
175
+
176
+ Before:
177
+
178
+ ```sh
179
+ tailor-sdk apply --profile prod
180
+ ```
181
+
182
+ After:
183
+
184
+ ```sh
185
+ tailor-sdk deploy --profile prod
186
+ ```
187
+
188
+ ## v2 CLI rename
189
+
190
+ **Migration:** Partially automatic
191
+
192
+ Rewrite `tailor-sdk crash-report` to `tailor-sdk crashreport` and `--machineuser` to `--machine-user` across package.json scripts, shell scripts, CI configs, and docs
193
+
194
+ Before:
195
+
196
+ ```sh
197
+ tailor-sdk crash-report list
198
+ tailor-sdk login --machineuser
199
+ ```
200
+
201
+ After:
202
+
203
+ ```sh
204
+ tailor-sdk crashreport list
205
+ tailor-sdk login --machine-user
206
+ ```
207
+
208
+ <details>
209
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
210
+
211
+ ```text
212
+ Apply the v2 CLI renames the codemod did not reach (only `tailor-sdk`-prefixed
213
+ invocations are rewritten): `tailor-sdk crash-report` -> `tailor-sdk crashreport`
214
+ and the `--machineuser` option -> `--machine-user`. Leave unrelated commands that
215
+ happen to use `--machineuser` alone.
216
+ ```
217
+
218
+ </details>
219
+
220
+ ## auth.invoker("name") → "name"
221
+
222
+ **Migration:** Partially automatic
223
+
224
+ Replace `auth.invoker("name")` calls with the bare `"name"` string and drop the `auth` import when no other reference remains. The `auth.invoker()` helper is deprecated in v2 because importing `auth` from `tailor.config.ts` into runtime files pulls Node-only modules into the bundle.
225
+
226
+ Before:
227
+
228
+ ```ts
229
+ createResolver({ invoker: auth.invoker("manager") });
230
+ ```
231
+
232
+ After:
233
+
234
+ ```ts
235
+ createResolver({ invoker: "manager" });
236
+ ```
237
+
238
+ <details>
239
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
240
+
241
+ ```text
242
+ In Tailor SDK v2 the auth.invoker() helper is removed; an invoker is now the
243
+ machine user name passed directly as a string. The codemod already rewrote the
244
+ string-literal form auth.invoker("name") to "name". These files still contain
245
+ auth.invoker(...) because the argument is not a plain string literal (a variable,
246
+ template literal, function call, or property access).
247
+
248
+ For each remaining auth.invoker(<expr>) call:
249
+ 1. Replace the whole call with <expr> as-is (e.g. auth.invoker(name) becomes name).
250
+ 2. Make sure <expr> evaluates to the machine user name (a string); adjust it if it
251
+ resolves to an object or an auth config value instead.
252
+ 3. After removing every auth.invoker usage in a file, delete the now-unused auth
253
+ import (keeping it pulls Node-only config modules into runtime bundles); leave
254
+ the import if auth is still referenced elsewhere.
255
+
256
+ Do not change behavior beyond removing the auth.invoker() indirection.
257
+ ```
258
+
259
+ </details>
260
+
261
+ ## Tailordb → tailordb (lowercase ambient namespace)
262
+
263
+ **Migration:** Partially automatic
264
+
265
+ Rewrite references to the removed capital-cased `Tailordb` ambient namespace (`Tailordb.QueryResult`, `Tailordb.CommandType`, `Tailordb.Client`, `typeof Tailordb.Client`) to the lowercase `tailordb.*` namespace exposed by `@tailor-platform/sdk/runtime/globals`. Because v2 no longer activates ambient declarations automatically, each file that contains `tailordb.*` references after the rewrite must also add `import "@tailor-platform/sdk/runtime/globals"`.
266
+
267
+ Before:
268
+
269
+ ```ts
270
+ const command: Tailordb.CommandType = "SELECT";
271
+ ```
272
+
273
+ After:
274
+
275
+ ```ts
276
+ import "@tailor-platform/sdk/runtime/globals";
277
+ const command: tailordb.CommandType = "SELECT";
278
+ ```
279
+
280
+ <details>
281
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
282
+
283
+ ```text
284
+ The capital-cased Tailordb ambient namespace is removed in v2; use the lowercase
285
+ tailordb.* namespace from @tailor-platform/sdk/runtime/globals. The codemod rewrites
286
+ the known members (QueryResult, CommandType, Client). Rewrite any other remaining
287
+ Tailordb.* reference to its tailordb.* equivalent (and confirm the member still
288
+ exists on the lowercase namespace).
289
+ Also add `import "@tailor-platform/sdk/runtime/globals"` at the top of each file
290
+ that contains any tailordb.* type reference — v2 no longer activates ambient
291
+ declarations automatically on SDK import.
292
+ ```
293
+
294
+ </details>
295
+
296
+ ## executeScript arg JSON.stringify → value
297
+
298
+ **Migration:** Partially automatic
299
+
300
+ Unwrap `JSON.stringify(...)` passed as the `executeScript` `arg` option. In v2 `arg` takes a JSON-serializable value and is serialized internally, so a pre-stringified argument double-encodes.
301
+
302
+ Before:
303
+
304
+ ```ts
305
+ await executeScript({ ...opts, arg: JSON.stringify({ a: 1 }) });
306
+ ```
307
+
308
+ After:
309
+
310
+ ```ts
311
+ await executeScript({ ...opts, arg: { a: 1 } });
312
+ ```
313
+
314
+ <details>
315
+ <summary>Prompt for an AI agent (to finish the cases the codemod could not migrate)</summary>
316
+
317
+ ```text
318
+ In Tailor SDK v2 the executeScript() arg option takes a JSON-serializable value
319
+ and is serialized internally, so a pre-stringified argument double-encodes. The
320
+ codemod already rewrote the direct form arg: JSON.stringify(X) to arg: X. Review
321
+ the executeScript calls in these files for cases it could not rewrite — where the
322
+ arg value is reached indirectly, for example:
323
+ - a variable holding a JSON.stringify(...) result (const s = JSON.stringify(x); ... arg: s)
324
+ - JSON.stringify(x, null, 2) or another multi-argument form
325
+ - an options object built or spread dynamically
326
+
327
+ For each such call, pass the underlying value directly as arg (drop the
328
+ JSON.stringify wrapper) so executeScript serializes it once. Leave calls that
329
+ already pass a plain value unchanged.
330
+ ```
331
+
332
+ </details>
333
+
334
+ ## openDownloadStream → downloadStream
335
+
336
+ **Migration:** Manual
337
+
338
+ The deprecated `openDownloadStream` file-streaming API is removed in v2. Use `downloadStream` for streamed file downloads. The generated file utilities now emit `downloadFileStream` (which calls `downloadStream` and returns `FileDownloadStreamResponse`) instead of the removed `openFileDownloadStream` helper.
339
+
340
+ Before:
341
+
342
+ ```ts
343
+ const res = await openDownloadStream(namespace, typeName, fieldName, recordId);
344
+ ```
345
+
346
+ After:
347
+
348
+ ```ts
349
+ const res = await downloadStream(namespace, typeName, fieldName, recordId);
350
+ ```
351
+
352
+ <details>
353
+ <summary>Prompt for an AI agent (to perform this migration)</summary>
354
+
355
+ ```text
356
+ The openDownloadStream file-streaming API is removed in v2. Replace every call to
357
+ openDownloadStream with downloadStream (same arguments). If you used the generated
358
+ openFileDownloadStream helper, switch to downloadFileStream, which calls
359
+ downloadStream and returns FileDownloadStreamResponse.
360
+ ```
361
+
362
+ </details>
363
+
364
+ ## Ambient runtime globals are opt-in
365
+
366
+ **Migration:** Manual
367
+
368
+ Importing `@tailor-platform/sdk` no longer activates the ambient `tailor.*` / `tailordb.*` global declarations. Normal SDK development does not need them — use the SDK APIs and the typed wrappers from `@tailor-platform/sdk/runtime`. Only if you relied on the ambient globals directly, add `import "@tailor-platform/sdk/runtime/globals"`. (The capital-cased `Tailordb.*` namespace is removed separately — see the `Tailordb → tailordb` codemod.)
369
+
370
+ Preferred: switch to the typed wrappers from `@tailor-platform/sdk/runtime` and drop the ambient globals:
371
+
372
+ Before:
373
+
374
+ ```ts
375
+ const client = new tailor.idp.Client();
376
+ ```
377
+
378
+ After:
379
+
380
+ ```ts
381
+ import { idp } from "@tailor-platform/sdk/runtime";
382
+ const client = new idp.Client({ namespace: "my-namespace" });
383
+ ```
384
+
385
+ Fallback: only if you must keep referencing the bare `tailor.*` names, opt into the global declarations:
386
+
387
+ Before:
388
+
389
+ ```ts
390
+ const client = new tailor.idp.Client();
391
+ ```
392
+
393
+ After:
394
+
395
+ ```ts
396
+ import "@tailor-platform/sdk/runtime/globals";
397
+ const client = new tailor.idp.Client();
398
+ ```
399
+
400
+ <details>
401
+ <summary>Prompt for an AI agent (to perform this migration)</summary>
402
+
403
+ ```text
404
+ The v2 SDK no longer enables ambient Tailor runtime globals from
405
+ `@tailor-platform/sdk`. For each flagged file that uses `tailor.*`,
406
+ `tailordb.*`, or Tailor runtime error globals, prefer migrating to the
407
+ typed wrappers from `@tailor-platform/sdk/runtime` (e.g. replace
408
+ `new tailor.idp.Client()` with `import { idp } from "@tailor-platform/sdk/runtime"`
409
+ and `new idp.Client({ namespace })`). The wrappers are self-contained, so the
410
+ ambient globals are no longer needed.
411
+
412
+ Only when the file must keep referencing the bare `tailor.*` names directly,
413
+ opt into the global declarations instead by adding one of these:
414
+ - per-file: `import "@tailor-platform/sdk/runtime/globals";`
415
+ - project-wide: `"types": ["@tailor-platform/sdk/runtime/globals"]` in
416
+ the relevant tsconfig compilerOptions
417
+
418
+ Leave files unchanged when the matching name is local, imported from another
419
+ module, or appears only in comments or strings.
420
+ ```
421
+
422
+ </details>
423
+
424
+ ## Workflow .trigger() and trigger tests
425
+
426
+ **Migration:** Manual
427
+
428
+ Workflow job `.trigger()` now aligns with the platform runtime: it returns the job result directly instead of a Promise wrapper, and tests no longer run job bodies locally. Mock trigger responses with `mockWorkflow()` (`setJobHandler` / `enqueueResult`, assert via `triggeredJobs`), or use `runWorkflowLocally()` for a full-chain local run.
429
+
430
+ Tests must mock the workflow runtime instead of running bodies locally:
431
+
432
+ Before:
433
+
434
+ ```ts
435
+ const result = await orderJob.trigger({ id });
436
+ expect(result.status).toBe("done");
437
+ ```
438
+
439
+ After:
440
+
441
+ ```ts
442
+ using wf = mockWorkflow();
443
+ wf.setJobHandler((jobName) => (jobName === "order-job" ? { status: "done" } : null));
444
+ const result = await orderJob.trigger({ id });
445
+ expect(result.status).toBe("done");
446
+ ```
447
+
448
+ <details>
449
+ <summary>Prompt for an AI agent (to perform this migration)</summary>
450
+
451
+ ```text
452
+ Workflow job .trigger() now uses the platform workflow runtime instead of running
453
+ the job body locally. In tests, acquire `using wf = mockWorkflow()` and provide
454
+ trigger responses (setJobHandler / enqueueResult), or use runWorkflowLocally() for a
455
+ full-chain local run; an unmocked trigger now throws. Outside tests, treat the
456
+ trigger result as the job output directly (no Promise wrapper to unwrap).
457
+ ```
458
+
459
+ </details>
460
+
461
+ ## Behavioral changes (no migration required)
462
+
463
+ These v2 changes alter runtime or CLI behavior; no source change is needed.
464
+
465
+ ### CLI tokens stored in the OS keyring
466
+
467
+ CLI login tokens are stored in the OS keyring by default when available, falling back to the platform config file when it is not. No source change is required; re-login if you need tokens moved into the keyring.
468
+
469
+ ### CLI users keyed by subject ID
470
+
471
+ The CLI stores human users by their stable subject ID instead of email (email is kept for display). Legacy email-keyed entries are migrated automatically on the next login or token refresh. No source change is required.
472
+
473
+ ### function logs require a content hash for source mapping
474
+
475
+ `tailor-sdk function logs` maps stack traces against the function bundle only when the execution recorded a `contentHash`. Executions without one now show raw stack traces instead of mapped frames. No source change is required.
@@ -18,7 +18,7 @@ const myPlugin: Plugin = {
18
18
  export default myPlugin; // Required: must be default export
19
19
  ```
20
20
 
21
- This is required so that generators can use plugin-generated TailorDB types via `getGeneratedType()`.
21
+ This is required so that other plugins and generation-time hooks can use plugin-generated TailorDB types via `getGeneratedType()`.
22
22
 
23
23
  ## Plugin Interface
24
24
 
@@ -276,7 +276,7 @@ import type {
276
276
 
277
277
  ## getGeneratedType Helper
278
278
 
279
- The SDK provides an async `getGeneratedType()` helper function to retrieve plugin-generated TailorDB types. This enables generators and other tools to work with types generated by plugins.
279
+ The SDK provides an async `getGeneratedType()` helper function to retrieve plugin-generated TailorDB types. This enables plugins and other tools to work with types generated by plugins.
280
280
 
281
281
  ```typescript
282
282
  import { join } from "node:path";
@@ -149,7 +149,7 @@ These hooks produce TailorDB types, resolvers, and executors that become part of
149
149
  | `onResolverReady` | TailorDB types, Resolvers, Auth | Write output files |
150
150
  | `onExecutorReady` | TailorDB types, Resolvers, Executors, Auth | Write output files |
151
151
 
152
- These hooks receive all finalized data and produce output files (TypeScript code, etc.). They replace the previous standalone `defineGenerators()` approach. No `importPath` required.
152
+ These hooks receive all finalized data and produce output files (TypeScript code, etc.). No `importPath` required.
153
153
 
154
154
  A plugin can implement hooks from either or both phases.
155
155
 
package/docs/runtime.md CHANGED
@@ -50,9 +50,7 @@ import type { ListUsersResponse, ClientConfig } from "@tailor-platform/sdk/runti
50
50
 
51
51
  Most users do not need to touch the globals entry — `@tailor-platform/sdk/runtime` (and its subpath modules) cover the same surface without depending on any ambient declaration.
52
52
 
53
- For backwards compatibility with the previous `@tailor-platform/function-types`-based setup, the SDK still activates the ambient `tailor.*` / `tailordb.*` types automatically when you import from `@tailor-platform/sdk`. **This implicit activation will be removed in v2.0**; new code should prefer the typed wrappers from `@tailor-platform/sdk/runtime`.
54
-
55
- If you want to opt into the globals explicitly (or you are migrating ahead of v2.0), add a single side-effect import anywhere in your project:
53
+ Importing from `@tailor-platform/sdk` does not activate the ambient `tailor.*` / `tailordb.*` declarations. If you want to opt into the globals, add a single side-effect import anywhere in your project:
56
54
 
57
55
  ```ts
58
56
  import "@tailor-platform/sdk/runtime/globals";
@@ -68,6 +66,8 @@ Or register the entry in `tsconfig.json`:
68
66
  }
69
67
  ```
70
68
 
69
+ The globals entry exposes the lowercase `tailordb.*` namespace only. If your project still references the removed capital-cased `Tailordb.*` namespace from `@tailor-platform/function-types`, migrate before upgrading in two steps: run `pnpm dlx @tailor-platform/sdk-codemod v2/tailordb-namespace` to rewrite `Tailordb.*` references to lowercase `tailordb.*`, then add the `import "@tailor-platform/sdk/runtime/globals"` opt-in above so the rewritten references resolve.
70
+
71
71
  ## Namespaces
72
72
 
73
73
  The runtime entry re-exports the following namespaces. Detailed signatures, parameters, and return types live in the JSDoc next to each export — hover the symbol in your IDE or browse the source.
@@ -78,7 +78,7 @@ The runtime entry re-exports the following namespaces. Detailed signatures, para
78
78
  - `idp` — IdP user management (`new Client({ namespace })`)
79
79
  - `workflow` — workflow & job control (`triggerWorkflow`, `triggerJobFunction`, `wait`, `resolve`)
80
80
  - `context` — execution context (`getInvoker`)
81
- - `file` — `tailordb.file` BLOB API (`upload`, `download`, `downloadAsBase64`, `delete`, `getMetadata`, `downloadStream`, `uploadStream`, `openDownloadStream` _(deprecated)_)
81
+ - `file` — `tailordb.file` BLOB API (`upload`, `download`, `downloadAsBase64`, `delete`, `getMetadata`, `downloadStream`, `uploadStream`)
82
82
 
83
83
  ## Testing
84
84