@tailor-platform/sdk 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/bin/tailor.mjs +3 -2
  3. package/dist/aigateway-DsWDjzk4.mjs +2 -0
  4. package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
  5. package/dist/application-CNeOcaLc.mjs +1 -0
  6. package/dist/application-CmXOqTaK.mjs +192 -0
  7. package/dist/application-CmXOqTaK.mjs.map +1 -0
  8. package/dist/assert-WeXvmG4j.mjs +2 -0
  9. package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
  10. package/dist/authconnection-CynFBIv8.mjs +2 -0
  11. package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
  12. package/dist/brand-C8nMKhJC.mjs +2 -0
  13. package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
  14. package/dist/cli/commands/api/index.d.mts +1 -1
  15. package/dist/cli/commands/deploy/deploy.d.mts +2 -2
  16. package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
  17. package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
  18. package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
  19. package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
  20. package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
  21. package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
  22. package/dist/cli/commands/executor/jobs.d.mts +1 -1
  23. package/dist/cli/commands/executor/trigger.d.mts +1 -1
  24. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
  25. package/dist/cli/commands/show.d.mts +1 -1
  26. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -11
  27. package/dist/cli/commands/tailordb/migrate/generate.d.mts +4 -0
  28. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
  29. package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
  30. package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
  31. package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
  32. package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
  33. package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
  34. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
  35. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
  36. package/dist/cli/commands/workflow/start.d.mts +1 -1
  37. package/dist/cli/commands/workspace/list.d.mts +1 -1
  38. package/dist/cli/lib.d.mts +12 -4
  39. package/dist/cli/lib.mjs +1 -9
  40. package/dist/cli/lib.mjs.map +1 -1
  41. package/dist/cli/main.d.mts +2 -0
  42. package/dist/cli/main.mjs +1170 -7754
  43. package/dist/cli/main.mjs.map +1 -1
  44. package/dist/cli/shared/args.d.mts +65 -1
  45. package/dist/cli/shared/command.d.mts +11 -0
  46. package/dist/cli/shared/context.d.mts +1 -1
  47. package/dist/cli/shared/logger.d.mts +64 -0
  48. package/dist/cli/shared/script-executor.d.mts +1 -1
  49. package/dist/cli/shared/seed-chunker.d.mts +5 -5
  50. package/dist/completion/zsh-worker.zsh +82 -9
  51. package/dist/configure/config/index.d.mts +1 -1
  52. package/dist/configure/config/types.d.mts +2 -2
  53. package/dist/configure/index.d.mts +48 -12
  54. package/dist/configure/index.mjs +1 -1267
  55. package/dist/configure/index.mjs.map +1 -1
  56. package/dist/configure/services/auth/types.d.mts +1 -1
  57. package/dist/configure/services/idp/types.d.mts +1 -1
  58. package/dist/configure/services/tailordb/schema.d.mts +22 -8
  59. package/dist/configure/services/tailordb/types.d.mts +2 -2
  60. package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
  61. package/dist/configure/services/workflow/job.d.mts +12 -2
  62. package/dist/configure/types/field.types.d.mts +1 -1
  63. package/dist/configure/types/permission-operand.types.d.mts +1 -1
  64. package/dist/context-D0QjfxzD.mjs +2 -0
  65. package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
  66. package/dist/crashreport-BN28xp5B.mjs +42 -0
  67. package/dist/{crashreport-Q0pDAlrj.mjs.map → crashreport-BN28xp5B.mjs.map} +1 -1
  68. package/dist/crashreport-By23O2k-.mjs +1 -0
  69. package/dist/errors-DLsQ_-ol.mjs +2 -0
  70. package/dist/errors-DLsQ_-ol.mjs.map +1 -0
  71. package/dist/es-builtins-n3wBv4Sv.mjs +2 -0
  72. package/dist/es-builtins-n3wBv4Sv.mjs.map +1 -0
  73. package/dist/file-COPYfju_.mjs +2 -0
  74. package/dist/file-COPYfju_.mjs.map +1 -0
  75. package/dist/globals-CMHSnj4w.mjs +2 -0
  76. package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
  77. package/dist/iconv-DlFMt2gW.mjs +2 -0
  78. package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
  79. package/dist/idp-G_ojPBB5.mjs +2 -0
  80. package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
  81. package/dist/interceptor-DQg3cR_9.mjs +2 -0
  82. package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
  83. package/dist/kysely/index.mjs +1 -32
  84. package/dist/kysely/index.mjs.map +1 -1
  85. package/dist/kysely-type-BTi3BMtL.mjs +43 -0
  86. package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
  87. package/dist/logger-CCjs1DuH.mjs +9 -0
  88. package/dist/logger-CCjs1DuH.mjs.map +1 -0
  89. package/dist/logger-DP2BjQ93.mjs +2 -0
  90. package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
  91. package/dist/multiline-EyzjEwn9.mjs +3 -0
  92. package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
  93. package/dist/node-builtins-oBl7EbyV.mjs +2 -0
  94. package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
  95. package/dist/package-json-C690ceex.mjs +2 -0
  96. package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
  97. package/dist/package-json-CmqhDJ__.mjs +1 -0
  98. package/dist/parser/service/tailordb/type-source.d.mts +5 -5
  99. package/dist/parser/service/tailordb/types.d.mts +4 -4
  100. package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
  101. package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
  102. package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
  103. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  104. package/dist/plugin/builtin/file-utils/index.mjs +22 -104
  105. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  106. package/dist/plugin/builtin/kysely-type/index.d.mts +8 -1
  107. package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
  108. package/dist/plugin/builtin/seed/index.d.mts +5 -0
  109. package/dist/plugin/builtin/seed/index.mjs +1 -3
  110. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +0 -2
  111. package/dist/plugin/{get-generated-type.d.mts → get-generated-table.d.mts} +5 -5
  112. package/dist/plugin/index.d.mts +3 -2
  113. package/dist/plugin/index.mjs +1 -251
  114. package/dist/plugin/index.mjs.map +1 -1
  115. package/dist/plugin/types.d.mts +30 -23
  116. package/dist/plugin/with-context.d.mts +3 -3
  117. package/dist/register-ts-hook-oDA2JLp2.mjs +640 -0
  118. package/dist/register-ts-hook-oDA2JLp2.mjs.map +1 -0
  119. package/dist/registry-HlEaGvl5.mjs +2 -0
  120. package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
  121. package/dist/repl-editor-BG1aDOfH.mjs +2 -0
  122. package/dist/{repl-editor-F9LotMNx.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
  123. package/dist/runtime/aigateway.mjs +1 -3
  124. package/dist/runtime/authconnection.mjs +1 -3
  125. package/dist/runtime/context.mjs +1 -3
  126. package/dist/runtime/file.d.mts +21 -21
  127. package/dist/runtime/file.mjs +1 -3
  128. package/dist/runtime/globals.mjs +1 -1
  129. package/dist/runtime/iconv.mjs +1 -3
  130. package/dist/runtime/idp.mjs +1 -3
  131. package/dist/runtime/index.mjs +1 -11
  132. package/dist/runtime/logger.mjs +1 -3
  133. package/dist/runtime/secretmanager.mjs +1 -3
  134. package/dist/runtime/types.d.mts +1 -1
  135. package/dist/runtime/workflow.mjs +1 -3
  136. package/dist/schema-AYG4OhXY.mjs +2 -0
  137. package/dist/schema-AYG4OhXY.mjs.map +1 -0
  138. package/dist/secret-file-C9wp_FCX.mjs +2 -0
  139. package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
  140. package/dist/secretmanager-5olfnI1b.mjs +2 -0
  141. package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
  142. package/dist/secretmanager-vHQoXdQz.mjs +2 -0
  143. package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
  144. package/dist/seed/index.mjs +8 -244
  145. package/dist/seed/index.mjs.map +1 -1
  146. package/dist/seed-DwqRFdqP.mjs +207 -0
  147. package/dist/seed-DwqRFdqP.mjs.map +1 -0
  148. package/dist/service-CLPMoj9n.mjs +2 -0
  149. package/dist/{service-LTfp03ZZ.mjs.map → service-CLPMoj9n.mjs.map} +1 -1
  150. package/dist/service-D7iXk0BT.mjs +1 -0
  151. package/dist/service-YqDsHmlK.mjs +7 -0
  152. package/dist/service-YqDsHmlK.mjs.map +1 -0
  153. package/dist/service_pb-DGKCLuAs.mjs +2 -0
  154. package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
  155. package/dist/service_pb-_aeFE-Nv.mjs +1 -0
  156. package/dist/shared/src/color.d.mts +5 -0
  157. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +1 -1
  158. package/dist/telemetry-Bklv9kQY.mjs +2 -0
  159. package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
  160. package/dist/telemetry-DXHP3VVi.mjs +1 -0
  161. package/dist/type-source--ZNcV8RJ.mjs +2 -0
  162. package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
  163. package/dist/types/executor.generated.d.mts +1 -1
  164. package/dist/user-agent-vdHYF3QL.mjs +2 -0
  165. package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
  166. package/dist/utils/test/index.mjs +1 -109
  167. package/dist/utils/test/index.mjs.map +1 -1
  168. package/dist/vitest/environment.mjs +1 -41
  169. package/dist/vitest/environment.mjs.map +1 -1
  170. package/dist/vitest/index.mjs +1 -1986
  171. package/dist/vitest/index.mjs.map +1 -1
  172. package/dist/vitest/mocks/file.d.mts +8 -8
  173. package/dist/vitest/setup.mjs +1 -140
  174. package/dist/vitest/setup.mjs.map +1 -1
  175. package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
  176. package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
  177. package/dist/wait-point-registry-B-ESkTZX.mjs +2 -0
  178. package/dist/wait-point-registry-B-ESkTZX.mjs.map +1 -0
  179. package/dist/workflow-Cs9ISw6j.mjs +2 -0
  180. package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
  181. package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
  182. package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
  183. package/docs/cli/function.md +66 -6
  184. package/docs/cli/setup.md +24 -14
  185. package/docs/cli/tailordb.md +2 -0
  186. package/docs/cli-reference.md +9 -8
  187. package/docs/github-actions.md +14 -12
  188. package/docs/migration/v2.md +18 -2
  189. package/docs/migration/v3.md +121 -0
  190. package/docs/plugin/custom.md +130 -85
  191. package/docs/plugin/index.md +3 -3
  192. package/docs/services/tailordb-migration.md +21 -7
  193. package/docs/services/tailordb.md +9 -7
  194. package/docs/services/workflow.md +10 -9
  195. package/package.json +14 -13
  196. package/postinstall.mjs +1 -1
  197. package/dist/aigateway-DR4Kwuik.mjs +0 -9
  198. package/dist/application-C8a0UJ-z.mjs +0 -6071
  199. package/dist/application-C8a0UJ-z.mjs.map +0 -1
  200. package/dist/application-D4zOiLLa.mjs +0 -3
  201. package/dist/assert-DBxo8jPo.mjs +0 -9
  202. package/dist/authconnection-CZvi9ANm.mjs +0 -9
  203. package/dist/brand-Eo4pLXPJ.mjs +0 -36
  204. package/dist/context-DYQVYWqZ.mjs +0 -23
  205. package/dist/crashreport-Cd4TqfZq.mjs +0 -3
  206. package/dist/crashreport-Q0pDAlrj.mjs +0 -427
  207. package/dist/errors-Bxut5_Sy.mjs +0 -89
  208. package/dist/errors-Bxut5_Sy.mjs.map +0 -1
  209. package/dist/file-BUcmVIH2.mjs +0 -58
  210. package/dist/file-BUcmVIH2.mjs.map +0 -1
  211. package/dist/globals-B2nlxBrz.mjs +0 -126
  212. package/dist/iconv-QWaZh0TT.mjs +0 -38
  213. package/dist/idp-RA_swu-h.mjs +0 -82
  214. package/dist/interceptor-e33JtsC-.mjs +0 -33
  215. package/dist/logger-BtX0suGY.mjs +0 -48
  216. package/dist/logger-D0bEznPv.mjs +0 -362
  217. package/dist/logger-D0bEznPv.mjs.map +0 -1
  218. package/dist/multiline-sfHpTZZK.mjs +0 -38
  219. package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
  220. package/dist/package-json-8b0O9TlX.mjs +0 -17
  221. package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
  222. package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
  223. package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
  224. package/dist/plugin/builtin/seed/types.d.mts +0 -2
  225. package/dist/register-ts-hook-Vqjza10T.mjs +0 -25679
  226. package/dist/register-ts-hook-Vqjza10T.mjs.map +0 -1
  227. package/dist/registry-BIGVUrMB.mjs +0 -54
  228. package/dist/repl-editor-F9LotMNx.mjs +0 -252
  229. package/dist/schema-D4TC4BC3.mjs +0 -640
  230. package/dist/schema-D4TC4BC3.mjs.map +0 -1
  231. package/dist/secret-file-C3J4Gy8r.mjs +0 -64
  232. package/dist/secretmanager-CYlpffsz.mjs +0 -13
  233. package/dist/secretmanager-IY4UvinW.mjs +0 -131
  234. package/dist/seed-Cibjmtry.mjs +0 -489
  235. package/dist/seed-Cibjmtry.mjs.map +0 -1
  236. package/dist/service-2grcAOCJ.mjs +0 -898
  237. package/dist/service-2grcAOCJ.mjs.map +0 -1
  238. package/dist/service-CaBPNDIZ.mjs +0 -3
  239. package/dist/service-LTfp03ZZ.mjs +0 -133
  240. package/dist/service_pb-BEWj1pOV.mjs +0 -167
  241. package/dist/service_pb-BjlhvK9E.mjs +0 -3
  242. package/dist/telemetry-BRVdwh14.mjs +0 -84
  243. package/dist/telemetry-CkbkeJxl.mjs +0 -3
  244. package/dist/type-source-DH_LH20p.mjs +0 -13
  245. package/dist/type-source-DH_LH20p.mjs.map +0 -1
  246. package/dist/user-agent-Bgsszb5I.mjs +0 -28
  247. package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
  248. package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
  249. package/dist/wait-point-registry-TL99zotw.mjs +0 -47
  250. package/dist/wait-point-registry-TL99zotw.mjs.map +0 -1
  251. package/dist/workflow-Bamae_Yc.mjs +0 -34
  252. package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
@@ -1,3 +0,0 @@
1
- import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-C8a0UJ-z.mjs";
2
-
3
- export { defineApplication, generatePluginFilesIfNeeded };
@@ -1,9 +0,0 @@
1
- //#region src/utils/assert.ts
2
- function assertDefined(value, message) {
3
- if (value == null) throw new Error(message);
4
- return value;
5
- }
6
-
7
- //#endregion
8
- export { assertDefined as t };
9
- //# sourceMappingURL=assert-DBxo8jPo.mjs.map
@@ -1,9 +0,0 @@
1
- //#region src/runtime/authconnection.ts
2
- const api = () => globalThis.tailor.authconnection;
3
- const getConnectionToken = (...args) => api().getConnectionToken(...args);
4
- /** Runtime wrapper namespace for `tailor.authconnection`. */
5
- const authconnection = { getConnectionToken };
6
-
7
- //#endregion
8
- export { authconnection as t };
9
- //# sourceMappingURL=authconnection-CZvi9ANm.mjs.map
@@ -1,36 +0,0 @@
1
- //#region src/utils/brand.ts
2
- const SDK_BRAND = Symbol.for("tailor-platform/sdk");
3
- /**
4
- * Adds a non-enumerable SDK brand symbol to the given object (in-place).
5
- * The brand stores the kind so service loaders can distinguish between
6
- * different SDK object types (e.g. a type loader skips executors).
7
- * @param value - The object to brand
8
- * @param kind - The kind of SDK object
9
- * @returns The same object with the brand applied
10
- */
11
- function brandValue(value, kind) {
12
- Object.defineProperty(value, SDK_BRAND, {
13
- value: kind,
14
- enumerable: false,
15
- configurable: false,
16
- writable: false
17
- });
18
- return value;
19
- }
20
- /**
21
- * Checks whether the given value has been branded by the SDK.
22
- * When kind is specified, only returns true if the brand matches that kind.
23
- * Accepts a single kind or an array of kinds for multi-kind matching.
24
- * @param value - The value to check
25
- * @param kind - Optional kind or kinds to match against
26
- * @returns True if the value has the SDK brand symbol (and matches kind if specified)
27
- */
28
- function isSdkBranded(value, kind) {
29
- if (value === null || typeof value !== "object" || !(SDK_BRAND in value)) return false;
30
- const stored = value[SDK_BRAND];
31
- return kind === void 0 || stored === true || (Array.isArray(kind) ? kind.includes(stored) : stored === kind);
32
- }
33
-
34
- //#endregion
35
- export { isSdkBranded as n, brandValue as t };
36
- //# sourceMappingURL=brand-Eo4pLXPJ.mjs.map
@@ -1,23 +0,0 @@
1
- //#region src/runtime/context.ts
2
- /**
3
- * Returns information about the invoker of the current function execution,
4
- * or `null` for anonymous invocations.
5
- * @returns Invoker details, or `null` when the call is anonymous
6
- */
7
- function getInvoker() {
8
- const raw = globalThis.tailor.context.getInvoker();
9
- if (!raw) return null;
10
- return {
11
- id: raw.id,
12
- type: raw.type,
13
- workspaceId: raw.workspaceId,
14
- attributes: raw.attributeMap,
15
- attributeList: raw.attributes
16
- };
17
- }
18
- /** Runtime wrapper namespace for `tailor.context`. */
19
- const context = { getInvoker };
20
-
21
- //#endregion
22
- export { context as t };
23
- //# sourceMappingURL=context-DYQVYWqZ.mjs.map
@@ -1,3 +0,0 @@
1
- import { n as reportCrash, t as initCrashReporting } from "./crashreport-Q0pDAlrj.mjs";
2
-
3
- export { reportCrash };
@@ -1,427 +0,0 @@
1
- import { n as logger } from "./logger-D0bEznPv.mjs";
2
- import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
3
- import { n as userAgentFromVersion } from "./user-agent-Bgsszb5I.mjs";
4
- import { r as writeSecretFile, t as ensureSecretDir } from "./secret-file-C3J4Gy8r.mjs";
5
- import * as path from "pathe";
6
- import * as fs from "node:fs";
7
- import { parseYAML } from "confbox";
8
- import { xdgConfig } from "xdg-basedir";
9
- import * as crypto from "node:crypto";
10
- import { isCI } from "std-env";
11
- import * as os from "node:os";
12
-
13
- //#region src/cli/crashreport/config.ts
14
- /**
15
- * Parse crash report configuration from environment variables.
16
- * Local crash log writing is enabled by default (opt-out via TAILOR_CRASH_REPORTS_LOCAL=off).
17
- * Remote sending is disabled by default (opt-in via TAILOR_CRASH_REPORTS_REMOTE=on).
18
- * Both are auto-disabled in CI environments.
19
- * @returns Crash report configuration
20
- */
21
- function parseCrashReportConfig() {
22
- if (isCI) return {
23
- localEnabled: false,
24
- remoteEnabled: false,
25
- localDir: ""
26
- };
27
- const localEnabled = (process.env.TAILOR_CRASH_REPORTS_LOCAL ?? "on").toLowerCase() !== "off";
28
- const remoteEnabled = (process.env.TAILOR_CRASH_REPORTS_REMOTE ?? "off").toLowerCase() === "on";
29
- const localDir = xdgConfig ? path.join(xdgConfig, "tailor-platform", "crash-reports") : "";
30
- return {
31
- localEnabled: localEnabled && localDir !== "",
32
- remoteEnabled,
33
- localDir
34
- };
35
- }
36
-
37
- //#endregion
38
- //#region src/cli/crashreport/writer.ts
39
- const MAX_CRASH_FILES = 10;
40
- /** Marker line that separates human-readable content from the JSON footer. */
41
- const JSON_FOOTER_MARKER = "--- JSON ---";
42
- /** File extension for crash log files. */
43
- const CRASH_LOG_EXTENSION = ".crash.log";
44
- /**
45
- * Format a CrashReport as human-readable text for local crash log files.
46
- * @param report - Crash report to format
47
- * @returns Formatted text content
48
- */
49
- function formatCrashReport(report) {
50
- return [
51
- `Crash Report: ${report.id}`,
52
- `Timestamp: ${report.timestamp}`,
53
- `Error Type: ${report.errorType}`,
54
- "",
55
- "--- Environment ---",
56
- `SDK Version: ${report.sdkVersion}`,
57
- `Node Version: ${report.nodeVersion}`,
58
- `OS: ${report.osPlatform} ${report.osRelease}`,
59
- `Arch: ${report.arch}`,
60
- "",
61
- "--- Command ---",
62
- `Command: ${report.command}`,
63
- `Arguments: ${JSON.stringify(report.argv)}`,
64
- "",
65
- "--- Error ---",
66
- `Name: ${report.errorName}`,
67
- `Message: ${report.errorMessage}`,
68
- "",
69
- "--- Stack Trace ---",
70
- report.stackTrace || "(no stack trace available)",
71
- "",
72
- JSON_FOOTER_MARKER,
73
- JSON.stringify(report),
74
- ""
75
- ].join("\n");
76
- }
77
- /**
78
- * Generate a filename for a crash log file.
79
- * Format: {timestamp}-{shortId}.crash.log
80
- * @param report - Crash report to generate filename for
81
- * @returns Filename string
82
- */
83
- function generateFilename(report) {
84
- return `${report.timestamp.replace(/[:.]/g, "-")}-${report.id.slice(0, 8)}${CRASH_LOG_EXTENSION}`;
85
- }
86
- /**
87
- * Remove old crash log files, keeping only the most recent ones.
88
- * @param dir - Crash log directory
89
- */
90
- function cleanupOldFiles(dir) {
91
- try {
92
- const files = fs.readdirSync(dir).filter((f) => f.endsWith(CRASH_LOG_EXTENSION)).toSorted().toReversed();
93
- for (const file of files.slice(MAX_CRASH_FILES)) fs.unlinkSync(path.join(dir, file));
94
- } catch {}
95
- }
96
- /**
97
- * Write a crash report to a local file.
98
- * Creates the directory if it doesn't exist. Keeps only the last 10 crash files.
99
- * Never throws - returns the file path on success or undefined on failure.
100
- * @param report - Crash report to write
101
- * @param dir - Directory to write the crash log file to
102
- * @returns File path on success, undefined on failure
103
- */
104
- function writeCrashReport(report, dir) {
105
- try {
106
- ensureSecretDir(dir);
107
- const filename = generateFilename(report);
108
- const filePath = path.join(dir, filename);
109
- const content = formatCrashReport(report);
110
- writeSecretFile(filePath, content);
111
- cleanupOldFiles(dir);
112
- return filePath;
113
- } catch {
114
- return;
115
- }
116
- }
117
-
118
- //#endregion
119
- //#region src/cli/crashreport/sender.ts
120
- const SEND_TIMEOUT_MS = 5e3;
121
- const PRODUCTION_ENDPOINT = "https://sdk-error-tracking-926vh9t4cl.erp.dev/query";
122
- const SUBMIT_MUTATION = `
123
- mutation SubmitCrashReport(
124
- $id: String!
125
- $timestamp: String!
126
- $sdkVersion: String!
127
- $nodeVersion: String!
128
- $osPlatform: String!
129
- $osRelease: String!
130
- $arch: String!
131
- $command: String!
132
- $argv: [String]
133
- $errorName: String!
134
- $errorMessage: String!
135
- $stackTrace: String
136
- $errorType: String!
137
- $userId: String
138
- $userEmail: String
139
- ) {
140
- submitCrashReport(
141
- id: $id
142
- timestamp: $timestamp
143
- sdkVersion: $sdkVersion
144
- nodeVersion: $nodeVersion
145
- osPlatform: $osPlatform
146
- osRelease: $osRelease
147
- arch: $arch
148
- command: $command
149
- argv: $argv
150
- errorName: $errorName
151
- errorMessage: $errorMessage
152
- stackTrace: $stackTrace
153
- errorType: $errorType
154
- userId: $userId
155
- userEmail: $userEmail
156
- ) {
157
- success
158
- }
159
- }`;
160
- /**
161
- * Send a crash report to the remote endpoint via GraphQL mutation.
162
- * Best-effort: never throws, returns boolean success.
163
- * @param report - Crash report to send
164
- * @param ua - User-Agent header value
165
- * @returns true if the request succeeded, false otherwise
166
- */
167
- async function sendCrashReport(report, ua) {
168
- try {
169
- const endpoint = process.env.TAILOR_CRASH_REPORT_ENDPOINT || PRODUCTION_ENDPOINT;
170
- const response = await fetch(endpoint, {
171
- method: "POST",
172
- headers: {
173
- "Content-Type": "application/json",
174
- "User-Agent": ua
175
- },
176
- body: JSON.stringify({
177
- query: SUBMIT_MUTATION,
178
- variables: report
179
- }),
180
- signal: AbortSignal.timeout(SEND_TIMEOUT_MS)
181
- });
182
- if (!response.ok) return false;
183
- const data = await response.json();
184
- if (data.errors?.length) return false;
185
- return data.data?.submitCrashReport.success === true;
186
- } catch {
187
- return false;
188
- }
189
- }
190
-
191
- //#endregion
192
- //#region src/cli/crashreport/sanitize.ts
193
- const HOME_DIR = os.homedir();
194
- const UUID_PATTERN = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
195
- const LONG_HEX_PATTERN = /\b[0-9a-fA-F]{32,}\b/g;
196
- const EMAIL_PATTERN = /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/g;
197
- const ABSOLUTE_PATH_PATTERN = /(?:\/(?:[\w.@\- ]+\/)+[\w.@\- ]+)/g;
198
- const WINDOWS_PATH_PATTERN = /(?:[A-Za-z]:\\(?:[\w.@\- ]+\\)+[\w.@\- ]+)/g;
199
- const URL_QUERY_PATTERN = /[?&][^?\s]*/g;
200
- const EMAIL_TEST_PATTERN = /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/;
201
- const WINDOWS_DRIVE_TEST_PATTERN = /^[A-Za-z]:\\/;
202
- const SDK_PACKAGE_MARKER = "packages/sdk/";
203
- function lastSegment(filePath, separator) {
204
- return filePath.split(separator).pop() ?? filePath;
205
- }
206
- /**
207
- * Sanitize a stack trace by replacing absolute paths with relative SDK paths.
208
- * External paths are replaced with `<external>/filename.ext`.
209
- * Home directories are replaced with `~/<redacted>/`.
210
- * @param stack - Raw stack trace string
211
- * @returns Sanitized stack trace
212
- */
213
- function sanitizeStackTrace(stack) {
214
- const firstFrameIndex = stack.search(/\n\s+at /);
215
- let result;
216
- if (firstFrameIndex !== -1) result = sanitizeMessage(stack.slice(0, firstFrameIndex)) + stack.slice(firstFrameIndex);
217
- else result = sanitizeMessage(stack);
218
- result = result.replace(ABSOLUTE_PATH_PATTERN, (match) => {
219
- const sdkIndex = match.indexOf(SDK_PACKAGE_MARKER);
220
- if (sdkIndex !== -1) return match.slice(sdkIndex);
221
- if (match.startsWith(HOME_DIR)) return `~/<redacted>/${lastSegment(match, "/")}`;
222
- return `<external>/${lastSegment(match, "/")}`;
223
- });
224
- result = result.replace(WINDOWS_PATH_PATTERN, (match) => {
225
- const normalized = match.replace(/\\/g, "/");
226
- const sdkIndex = normalized.indexOf(SDK_PACKAGE_MARKER);
227
- if (sdkIndex !== -1) return normalized.slice(sdkIndex);
228
- return `<external>/${lastSegment(match, "\\")}`;
229
- });
230
- return result;
231
- }
232
- /**
233
- * Sanitize an error message by redacting sensitive information.
234
- * Redacts: UUIDs, long hex tokens, email addresses, absolute paths, URL query strings.
235
- * @param message - Raw error message
236
- * @returns Sanitized error message
237
- */
238
- function sanitizeMessage(message) {
239
- let result = message;
240
- result = result.replace(/\nRequest:\s*[\s\S]*$/, "\nRequest: <redacted>");
241
- result = result.replace(UUID_PATTERN, "<uuid>");
242
- result = result.replace(LONG_HEX_PATTERN, "<redacted>");
243
- result = result.replace(EMAIL_PATTERN, "<email>");
244
- result = result.replace(URL_QUERY_PATTERN, "?<redacted>");
245
- result = result.replace(ABSOLUTE_PATH_PATTERN, (match) => `<path>/${lastSegment(match, "/")}`);
246
- result = result.replace(WINDOWS_PATH_PATTERN, (match) => `<path>/${lastSegment(match, "\\")}`);
247
- return result;
248
- }
249
- /**
250
- * Sanitize process.argv by keeping command/subcommand names and redacting
251
- * values of sensitive flags.
252
- * @param argv - Raw process.argv array
253
- * @returns Sanitized argv array
254
- */
255
- function sanitizeArgv(argv) {
256
- const result = [];
257
- let redactNext = false;
258
- for (const arg of argv) {
259
- if (redactNext) {
260
- if (!arg.startsWith("-")) {
261
- result.push("<redacted>");
262
- redactNext = false;
263
- continue;
264
- }
265
- redactNext = false;
266
- }
267
- if (arg.startsWith("-")) {
268
- const eqIndex = arg.indexOf("=");
269
- if (eqIndex !== -1) {
270
- result.push(`${arg.slice(0, eqIndex)}=<redacted>`);
271
- continue;
272
- }
273
- result.push(arg);
274
- redactNext = true;
275
- continue;
276
- }
277
- if (arg.startsWith("/") && arg.includes("/", 1)) {
278
- result.push("<path>");
279
- continue;
280
- }
281
- if (WINDOWS_DRIVE_TEST_PATTERN.test(arg)) {
282
- result.push("<path>");
283
- continue;
284
- }
285
- if (EMAIL_TEST_PATTERN.test(arg)) {
286
- result.push("<email>");
287
- continue;
288
- }
289
- result.push(arg);
290
- }
291
- return result;
292
- }
293
-
294
- //#endregion
295
- //#region src/cli/crashreport/report.ts
296
- const MAX_COMMAND_TOKENS = 3;
297
- /**
298
- * Parse the command name from process.argv.
299
- * Extracts up to MAX_COMMAND_TOKENS non-flag arguments after the script name.
300
- * @returns Parsed command string
301
- */
302
- function parseCommand() {
303
- const args = process.argv.slice(2);
304
- const commandParts = [];
305
- for (const arg of args) {
306
- if (arg.startsWith("-") || commandParts.length >= MAX_COMMAND_TOKENS) break;
307
- commandParts.push(arg);
308
- }
309
- return commandParts.join(" ") || "<unknown>";
310
- }
311
- /**
312
- * Build a CrashReport data structure from an error and context.
313
- * All sensitive data is sanitized before inclusion.
314
- * @param options - Error, SDK version, and crash type
315
- * @returns Sanitized crash report
316
- */
317
- function buildCrashReport(options) {
318
- const { error, sdkVersion, errorType } = options;
319
- const isError = error instanceof Error;
320
- const rawMessage = isError ? error.message : String(error);
321
- const rawStack = isError && error.stack ? error.stack : "";
322
- const errorName = isError ? error.name : "UnknownError";
323
- const currentUser = readCurrentUser();
324
- return {
325
- id: crypto.randomUUID(),
326
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
327
- sdkVersion,
328
- nodeVersion: process.version,
329
- osPlatform: process.platform,
330
- osRelease: os.release(),
331
- arch: process.arch,
332
- command: sanitizeMessage(parseCommand()),
333
- argv: sanitizeArgv(process.argv),
334
- errorName,
335
- errorMessage: sanitizeMessage(rawMessage),
336
- stackTrace: sanitizeStackTrace(rawStack),
337
- errorType,
338
- userId: currentUser?.id ?? null,
339
- userEmail: currentUser?.email ?? null
340
- };
341
- }
342
- /**
343
- * Read current_user from Tailor Platform config without side effects.
344
- * Unlike readPlatformConfig(), this never triggers migration or logs warnings.
345
- * @returns The current user ID and email, or null if unavailable
346
- */
347
- function readCurrentUser() {
348
- try {
349
- if (!xdgConfig) return null;
350
- const configPath = path.join(xdgConfig, "tailor-platform", "config.yaml");
351
- if (!fs.existsSync(configPath)) return null;
352
- const raw = parseYAML(fs.readFileSync(configPath, "utf-8"));
353
- const currentUser = raw?.current_user ?? null;
354
- if (!currentUser) return null;
355
- const email = raw.users?.[currentUser]?.email;
356
- return {
357
- id: currentUser,
358
- email: typeof email === "string" ? email : legacyEmail(currentUser)
359
- };
360
- } catch {
361
- return null;
362
- }
363
- }
364
- function legacyEmail(user) {
365
- return user.includes("@") ? user : null;
366
- }
367
-
368
- //#endregion
369
- //#region src/cli/crashreport/index.ts
370
- /**
371
- * Report an unexpected crash. Writes a local crash log file and optionally
372
- * sends the report to a remote endpoint. Displays a user-facing message
373
- * with the crash log path and a command to submit the report.
374
- *
375
- * Never throws - all errors are silently caught.
376
- * @param error - The error that caused the crash
377
- * @param errorType - How the error was caught
378
- */
379
- async function reportCrash(error, errorType) {
380
- try {
381
- const config = parseCrashReportConfig();
382
- if (!config.localEnabled && !config.remoteEnabled) return;
383
- const sdkVersion = (await readPackageJson()).version ?? "unknown";
384
- const report = buildCrashReport({
385
- error,
386
- sdkVersion,
387
- errorType
388
- });
389
- if (config.localEnabled) {
390
- const filePath = writeCrashReport(report, config.localDir);
391
- if (filePath) logger.log([
392
- "",
393
- "An unexpected error occurred. A crash report has been saved to:",
394
- ` ${filePath}`,
395
- "",
396
- "To submit this report:",
397
- ` tailor crashreport send --file "${filePath}"`
398
- ].join("\n"));
399
- }
400
- if (config.remoteEnabled) {
401
- const ua = userAgentFromVersion(sdkVersion);
402
- await sendCrashReport(report, ua);
403
- }
404
- } catch {}
405
- }
406
- /**
407
- * Register global uncaughtException and unhandledRejection handlers.
408
- * These catch errors outside the normal cleanup flow (e.g., during
409
- * argument parsing). Should be called once at CLI startup before runMain.
410
- */
411
- function initCrashReporting() {
412
- const config = parseCrashReportConfig();
413
- if (!config.localEnabled && !config.remoteEnabled) return;
414
- const handleFatal = (error, errorType) => {
415
- const message = error instanceof Error ? error.message : String(error);
416
- logger.error(message);
417
- reportCrash(error, errorType).finally(() => {
418
- process.exit(1);
419
- });
420
- };
421
- process.on("uncaughtException", (error) => handleFatal(error, "uncaughtException"));
422
- process.on("unhandledRejection", (reason) => handleFatal(reason, "unhandledRejection"));
423
- }
424
-
425
- //#endregion
426
- export { JSON_FOOTER_MARKER as a, CRASH_LOG_EXTENSION as i, reportCrash as n, parseCrashReportConfig as o, sendCrashReport as r, initCrashReporting as t };
427
- //# sourceMappingURL=crashreport-Q0pDAlrj.mjs.map
@@ -1,89 +0,0 @@
1
- import { r as styles } from "./logger-D0bEznPv.mjs";
2
-
3
- //#region src/cli/shared/errors.ts
4
- function shellQuote(value) {
5
- if (process.platform === "win32") {
6
- if (/^[A-Za-z0-9_./:=@+\\-]+$/.test(value)) return value;
7
- return `"${value.replaceAll("\"", "\\\"")}"`;
8
- }
9
- if (/^[A-Za-z0-9_./:=@+-]+$/.test(value)) return value;
10
- return `'${value.replaceAll("'", `'"'"'`)}'`;
11
- }
12
- function needsArgvRendering(argv) {
13
- return process.platform === "win32" && argv.some((value) => /[%$!]/.test(value));
14
- }
15
- /**
16
- * Render an argv array as a copyable command line for the current platform's shell
17
- * @param {readonly string[]} argv - Executable name followed by its arguments
18
- * @returns {string} A shell-quoted command line, or an `argv [...]` JSON rendering when the platform shell cannot keep a value literal
19
- */
20
- function formatCopyableCommand(argv) {
21
- if (needsArgvRendering(argv)) return `argv ${JSON.stringify(argv)}`;
22
- return argv.map(shellQuote).join(" ");
23
- }
24
- /**
25
- * Format an executable and argv as a shell-safe user-facing command.
26
- * @param next - Executable and arguments to format
27
- * @returns Shell command, or an argv representation when shell quoting is unsafe
28
- */
29
- function formatNextAction(next) {
30
- const argv = [next.command, ...next.args];
31
- const rendered = formatCopyableCommand(argv);
32
- return needsArgvRendering(argv) ? `with ${rendered}` : `\`${rendered}\``;
33
- }
34
- /**
35
- * Format CLI error for output
36
- * @param error - CLIError instance to format
37
- * @returns Formatted error message
38
- */
39
- function formatError(error) {
40
- const parts = [styles.error(`Error${error.code ? ` [${error.code}]` : ""}: ${error.message}`)];
41
- if (error.details) parts.push(`\n ${styles.dim("Details:")} ${error.details}`);
42
- if (error.suggestion) parts.push(`\n ${styles.info("Suggestion:")} ${error.suggestion}`);
43
- if (error.command) parts.push(`\n ${styles.dim("Help:")} Run \`tailor ${error.command} --help\` for usage information.`);
44
- if (error.next) parts.push(`\n ${styles.info("Next:")} Run ${formatNextAction(error.next)}.`);
45
- return parts.join("");
46
- }
47
- /**
48
- * Create a CLI error with formatted output
49
- * @param options - Options to construct a CLIError
50
- * @returns Constructed CLIError instance
51
- */
52
- function createCLIError(options) {
53
- const error = new Error(options.message);
54
- error.name = "CLIError";
55
- error.code = options.code;
56
- error.details = options.details;
57
- error.suggestion = options.suggestion;
58
- error.command = options.command;
59
- error.next = options.next;
60
- error.context = options.context;
61
- error.format = () => formatError(error);
62
- return error;
63
- }
64
- /**
65
- * Type guard to check if an error is a CLIError
66
- * @param error - Error to check
67
- * @returns True if the error is a CLIError
68
- */
69
- function isCLIError(error) {
70
- return error instanceof Error && error.name === "CLIError";
71
- }
72
- const MISSING_NAMED_EXPORT_PATTERN = /does not provide an export named '(?!default')([^']+)'/;
73
- /**
74
- * Suggest `import type` when importing user code fails on a missing named
75
- * export. The CLI strips types from each file in isolation, so a type-only
76
- * export does not exist at runtime and a plain import of it fails to link.
77
- * @param error - Error thrown while importing user modules
78
- * @returns Suggestion text, or undefined when the error is not that failure
79
- */
80
- function typeOnlyImportHint(error) {
81
- if (!(error instanceof SyntaxError)) return void 0;
82
- const name = MISSING_NAMED_EXPORT_PATTERN.exec(error.message)?.[1];
83
- if (!name) return void 0;
84
- return `If '${name}' is a type, import it with \`import type\` (or the inline \`type\` modifier). The CLI runs TypeScript by stripping types from each file in isolation, so type-only exports do not exist at runtime. Set "verbatimModuleSyntax": true in tsconfig.json to catch this at typecheck.`;
85
- }
86
-
87
- //#endregion
88
- export { typeOnlyImportHint as a, isCLIError as i, formatCopyableCommand as n, formatNextAction as r, createCLIError as t };
89
- //# sourceMappingURL=errors-Bxut5_Sy.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-Bxut5_Sy.mjs","names":[],"sources":["../src/cli/shared/errors.ts"],"sourcesContent":["import { styles } from \"./logger\";\n\n/**\n * Options for creating a CLI error\n */\nexport interface CLIErrorOptions {\n message: string;\n details?: string;\n suggestion?: string;\n command?: string;\n code?: string;\n next?: CLIErrorNextAction;\n context?: Readonly<Record<string, unknown>>;\n}\n\nexport interface CLIErrorNextAction {\n /** Executable name, such as `tailor`. */\n command: string;\n /** Arguments passed directly to the executable. */\n args: readonly string[];\n}\n\n/**\n * CLI error interface with formatted output\n */\nexport interface CLIError extends Error {\n readonly code?: string;\n readonly details?: string;\n readonly suggestion?: string;\n readonly command?: string;\n readonly next?: CLIErrorNextAction;\n readonly context?: Readonly<Record<string, unknown>>;\n format(): string;\n}\n\ntype CLIErrorInternal = Error & {\n code?: string;\n details?: string;\n suggestion?: string;\n command?: string;\n next?: CLIErrorNextAction;\n context?: Readonly<Record<string, unknown>>;\n format(): string;\n};\n\nfunction shellQuote(value: string): string {\n if (process.platform === \"win32\") {\n if (/^[A-Za-z0-9_./:=@+\\\\-]+$/.test(value)) return value;\n return `\"${value.replaceAll('\"', '\\\\\"')}\"`;\n }\n if (/^[A-Za-z0-9_./:=@+-]+$/.test(value)) return value;\n return `'${value.replaceAll(\"'\", `'\"'\"'`)}'`;\n}\n\nfunction needsArgvRendering(argv: readonly string[]): boolean {\n // cmd.exe/PowerShell expand %, $, and ! even inside double quotes, so no\n // quoting can keep such values literal on Windows.\n return process.platform === \"win32\" && argv.some((value) => /[%$!]/.test(value));\n}\n\n/**\n * Render an argv array as a copyable command line for the current platform's shell\n * @param {readonly string[]} argv - Executable name followed by its arguments\n * @returns {string} A shell-quoted command line, or an `argv [...]` JSON rendering when the platform shell cannot keep a value literal\n */\nexport function formatCopyableCommand(argv: readonly string[]): string {\n if (needsArgvRendering(argv)) {\n return `argv ${JSON.stringify(argv)}`;\n }\n return argv.map(shellQuote).join(\" \");\n}\n\n/**\n * Format an executable and argv as a shell-safe user-facing command.\n * @param next - Executable and arguments to format\n * @returns Shell command, or an argv representation when shell quoting is unsafe\n */\nexport function formatNextAction(next: CLIErrorNextAction): string {\n const argv = [next.command, ...next.args];\n const rendered = formatCopyableCommand(argv);\n return needsArgvRendering(argv) ? `with ${rendered}` : `\\`${rendered}\\``;\n}\n\n/**\n * Format CLI error for output\n * @param error - CLIError instance to format\n * @returns Formatted error message\n */\nfunction formatError(error: CLIError): string {\n const parts: string[] = [\n styles.error(`Error${error.code ? ` [${error.code}]` : \"\"}: ${error.message}`),\n ];\n\n if (error.details) {\n parts.push(`\\n ${styles.dim(\"Details:\")} ${error.details}`);\n }\n\n if (error.suggestion) {\n parts.push(`\\n ${styles.info(\"Suggestion:\")} ${error.suggestion}`);\n }\n\n if (error.command) {\n parts.push(\n `\\n ${styles.dim(\"Help:\")} Run \\`tailor ${error.command} --help\\` for usage information.`,\n );\n }\n\n if (error.next) {\n parts.push(`\\n ${styles.info(\"Next:\")} Run ${formatNextAction(error.next)}.`);\n }\n\n return parts.join(\"\");\n}\n\n/**\n * Create a CLI error with formatted output\n * @param options - Options to construct a CLIError\n * @returns Constructed CLIError instance\n */\nfunction createCLIError(options: CLIErrorOptions): CLIError {\n const error = new Error(options.message) as CLIErrorInternal;\n error.name = \"CLIError\";\n error.code = options.code;\n error.details = options.details;\n error.suggestion = options.suggestion;\n error.command = options.command;\n error.next = options.next;\n error.context = options.context;\n error.format = () => formatError(error);\n return error;\n}\n\n/**\n * Type guard to check if an error is a CLIError\n * @param error - Error to check\n * @returns True if the error is a CLIError\n */\nexport function isCLIError(error: unknown): error is CLIError {\n return error instanceof Error && error.name === \"CLIError\";\n}\n\nconst MISSING_NAMED_EXPORT_PATTERN = /does not provide an export named '(?!default')([^']+)'/;\n\n/**\n * Suggest `import type` when importing user code fails on a missing named\n * export. The CLI strips types from each file in isolation, so a type-only\n * export does not exist at runtime and a plain import of it fails to link.\n * @param error - Error thrown while importing user modules\n * @returns Suggestion text, or undefined when the error is not that failure\n */\nexport function typeOnlyImportHint(error: unknown): string | undefined {\n if (!(error instanceof SyntaxError)) return undefined;\n const name = MISSING_NAMED_EXPORT_PATTERN.exec(error.message)?.[1];\n if (!name) return undefined;\n return (\n `If '${name}' is a type, import it with \\`import type\\` (or the inline \\`type\\` modifier). ` +\n \"The CLI runs TypeScript by stripping types from each file in isolation, so type-only exports do not exist at runtime. \" +\n 'Set \"verbatimModuleSyntax\": true in tsconfig.json to catch this at typecheck.'\n );\n}\n\n// Re-export createCLIError as CLIError for backward compatibility\nexport { createCLIError as CLIError };\n"],"mappings":";;;AA6CA,SAAS,WAAW,OAAuB;CACzC,IAAI,QAAQ,aAAa,SAAS;EAChC,IAAI,2BAA2B,KAAK,KAAK,GAAG,OAAO;EACnD,OAAO,IAAI,MAAM,WAAW,MAAK,MAAK,EAAE;CAC1C;CACA,IAAI,yBAAyB,KAAK,KAAK,GAAG,OAAO;CACjD,OAAO,IAAI,MAAM,WAAW,KAAK,OAAO,EAAE;AAC5C;AAEA,SAAS,mBAAmB,MAAkC;CAG5D,OAAO,QAAQ,aAAa,WAAW,KAAK,MAAM,UAAU,QAAQ,KAAK,KAAK,CAAC;AACjF;;;;;;AAOA,SAAgB,sBAAsB,MAAiC;CACrE,IAAI,mBAAmB,IAAI,GACzB,OAAO,QAAQ,KAAK,UAAU,IAAI;CAEpC,OAAO,KAAK,IAAI,UAAU,CAAC,CAAC,KAAK,GAAG;AACtC;;;;;;AAOA,SAAgB,iBAAiB,MAAkC;CACjE,MAAM,OAAO,CAAC,KAAK,SAAS,GAAG,KAAK,IAAI;CACxC,MAAM,WAAW,sBAAsB,IAAI;CAC3C,OAAO,mBAAmB,IAAI,IAAI,QAAQ,aAAa,KAAK,SAAS;AACvE;;;;;;AAOA,SAAS,YAAY,OAAyB;CAC5C,MAAM,QAAkB,CACtB,OAAO,MAAM,QAAQ,MAAM,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAI,MAAM,SAAS,CAC/E;CAEA,IAAI,MAAM,SACR,MAAM,KAAK,OAAO,OAAO,IAAI,UAAU,EAAE,GAAG,MAAM,SAAS;CAG7D,IAAI,MAAM,YACR,MAAM,KAAK,OAAO,OAAO,KAAK,aAAa,EAAE,GAAG,MAAM,YAAY;CAGpE,IAAI,MAAM,SACR,MAAM,KACJ,OAAO,OAAO,IAAI,OAAO,EAAE,gBAAgB,MAAM,QAAQ,iCAC3D;CAGF,IAAI,MAAM,MACR,MAAM,KAAK,OAAO,OAAO,KAAK,OAAO,EAAE,OAAO,iBAAiB,MAAM,IAAI,EAAE,EAAE;CAG/E,OAAO,MAAM,KAAK,EAAE;AACtB;;;;;;AAOA,SAAS,eAAe,SAAoC;CAC1D,MAAM,QAAQ,IAAI,MAAM,QAAQ,OAAO;CACvC,MAAM,OAAO;CACb,MAAM,OAAO,QAAQ;CACrB,MAAM,UAAU,QAAQ;CACxB,MAAM,aAAa,QAAQ;CAC3B,MAAM,UAAU,QAAQ;CACxB,MAAM,OAAO,QAAQ;CACrB,MAAM,UAAU,QAAQ;CACxB,MAAM,eAAe,YAAY,KAAK;CACtC,OAAO;AACT;;;;;;AAOA,SAAgB,WAAW,OAAmC;CAC5D,OAAO,iBAAiB,SAAS,MAAM,SAAS;AAClD;AAEA,MAAM,+BAA+B;;;;;;;;AASrC,SAAgB,mBAAmB,OAAoC;CACrE,IAAI,EAAE,iBAAiB,cAAc,OAAO;CAC5C,MAAM,OAAO,6BAA6B,KAAK,MAAM,OAAO,CAAC,GAAG;CAChE,IAAI,CAAC,MAAM,OAAO;CAClB,OACE,OAAO,KAAK;AAIhB"}
@@ -1,58 +0,0 @@
1
- //#region src/runtime/file.ts
2
- const api = () => globalThis.tailordb.file;
3
- /**
4
- * See {@link TailorDBFileAPI.upload}.
5
- * @param args - Forwarded to {@link TailorDBFileAPI.upload}
6
- * @returns Upload response containing the file metadata
7
- */
8
- const upload = (...args) => api().upload(...args);
9
- /**
10
- * See {@link TailorDBFileAPI.download}.
11
- * @param args - Forwarded to {@link TailorDBFileAPI.download}
12
- * @returns Bytes and metadata for the file
13
- */
14
- const download = (...args) => api().download(...args);
15
- /**
16
- * See {@link TailorDBFileAPI.downloadAsBase64}.
17
- * @param args - Forwarded to {@link TailorDBFileAPI.downloadAsBase64}
18
- * @returns Base64-encoded contents and metadata for the file
19
- */
20
- const downloadAsBase64 = (...args) => api().downloadAsBase64(...args);
21
- /**
22
- * See {@link TailorDBFileAPI.delete}.
23
- * @param args - Forwarded to {@link TailorDBFileAPI.delete}
24
- * @returns Resolves once the file has been deleted
25
- */
26
- const deleteFile = (...args) => api().delete(...args);
27
- /**
28
- * See {@link TailorDBFileAPI.getMetadata}.
29
- * @param args - Forwarded to {@link TailorDBFileAPI.getMetadata}
30
- * @returns Metadata for the stored file
31
- */
32
- const getMetadata = (...args) => api().getMetadata(...args);
33
- /**
34
- * See {@link TailorDBFileAPI.downloadStream}.
35
- * @param args - Forwarded to {@link TailorDBFileAPI.downloadStream}
36
- * @returns ReadableStream body and metadata for the file
37
- */
38
- const downloadStream = (...args) => api().downloadStream(...args);
39
- /**
40
- * See {@link TailorDBFileAPI.uploadStream}.
41
- * @param args - Forwarded to {@link TailorDBFileAPI.uploadStream}
42
- * @returns Upload response containing the file metadata
43
- */
44
- const uploadStream = (...args) => api().uploadStream(...args);
45
- /** Runtime wrapper namespace for `tailordb.file`. */
46
- const file = {
47
- upload,
48
- download,
49
- downloadAsBase64,
50
- delete: deleteFile,
51
- getMetadata,
52
- downloadStream,
53
- uploadStream
54
- };
55
-
56
- //#endregion
57
- export { file as t };
58
- //# sourceMappingURL=file-BUcmVIH2.mjs.map