@tailor-platform/sdk 2.22.0 → 2.24.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 (103) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/aigateway-DsWDjzk4.mjs.map +1 -1
  3. package/dist/application-BDqze-wy.mjs +1 -0
  4. package/dist/application-CfqvzV3I.mjs +200 -0
  5. package/dist/application-CfqvzV3I.mjs.map +1 -0
  6. package/dist/assert-WeXvmG4j.mjs.map +1 -1
  7. package/dist/authconnection-CynFBIv8.mjs.map +1 -1
  8. package/dist/brand-C8nMKhJC.mjs.map +1 -1
  9. package/dist/cli/cache/bundle-cache.d.mts +1 -0
  10. package/dist/cli/lib.mjs +1 -1
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/cli/main.mjs +40 -40
  13. package/dist/cli/main.mjs.map +1 -1
  14. package/dist/cli/services/application.d.mts +1 -0
  15. package/dist/cli/services/workflow/bundler.d.mts +2 -1
  16. package/dist/cli/shared/client.d.mts +17 -2
  17. package/dist/cli/shared/forbidden-runtime-globals.d.mts +1 -0
  18. package/dist/cli/shared/start-context.d.mts +1 -0
  19. package/dist/cli/ts-hook.mjs +3 -3
  20. package/dist/completion/zsh-worker.zsh +13 -7
  21. package/dist/configure/config/types.d.mts +42 -2
  22. package/dist/configure/index.mjs +1 -1
  23. package/dist/configure/index.mjs.map +1 -1
  24. package/dist/context-D0QjfxzD.mjs.map +1 -1
  25. package/dist/crashreport-DFpRn-LS.mjs.map +1 -1
  26. package/dist/date-Dri6Yas-.mjs.map +1 -1
  27. package/dist/errors-CpvSChyL.mjs +7 -0
  28. package/dist/errors-CpvSChyL.mjs.map +1 -0
  29. package/dist/es-builtins-SfvXRVoG.mjs.map +1 -1
  30. package/dist/field-parse-DhnFs9WG.mjs.map +1 -1
  31. package/dist/file-DKBOj5q4.mjs.map +1 -1
  32. package/dist/globals-BCmGX05J.mjs.map +1 -1
  33. package/dist/guards-yDXyKC9F.mjs.map +1 -1
  34. package/dist/iconv-DlFMt2gW.mjs.map +1 -1
  35. package/dist/idp-G_ojPBB5.mjs.map +1 -1
  36. package/dist/interceptor-DQg3cR_9.mjs.map +1 -1
  37. package/dist/kysely/index.mjs.map +1 -1
  38. package/dist/kysely-type-C-iyFFH7.mjs.map +1 -1
  39. package/dist/logger-DP2BjQ93.mjs.map +1 -1
  40. package/dist/logger-Db-YRTwK.mjs.map +1 -1
  41. package/dist/manager-8-JOvuLl.mjs.map +1 -1
  42. package/dist/multiline-EyzjEwn9.mjs.map +1 -1
  43. package/dist/node-builtins-DYfhPBnz.mjs.map +1 -1
  44. package/dist/package-json-C690ceex.mjs.map +1 -1
  45. package/dist/platform-serialize-DkiTdHOt.mjs.map +1 -1
  46. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  47. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  48. package/dist/plugin/index.mjs.map +1 -1
  49. package/dist/{register-ts-hook-z7ggXQy4.mjs → register-ts-hook-CVlI9Jzl.mjs} +57 -57
  50. package/dist/register-ts-hook-CVlI9Jzl.mjs.map +1 -0
  51. package/dist/registry-BijIDRVA.mjs.map +1 -1
  52. package/dist/repl-editor-DGJBfIt1.mjs.map +1 -1
  53. package/dist/schema-CRtAmDcl.mjs.map +1 -1
  54. package/dist/secret-file-C9wp_FCX.mjs.map +1 -1
  55. package/dist/secretmanager-5olfnI1b.mjs.map +1 -1
  56. package/dist/secretmanager-vHQoXdQz.mjs.map +1 -1
  57. package/dist/seed/index.mjs.map +1 -1
  58. package/dist/seed-C3P_T_Eh.mjs.map +1 -1
  59. package/dist/service-CL1Bp4It.mjs.map +1 -1
  60. package/dist/{service-DHVuH7-X.mjs → service-DFmt9UJP.mjs} +2 -2
  61. package/dist/service-DFmt9UJP.mjs.map +1 -0
  62. package/dist/service_pb-ZClWtj1X.mjs +2 -0
  63. package/dist/service_pb-ZClWtj1X.mjs.map +1 -0
  64. package/dist/service_pb-dB3RrGeh.mjs +1 -0
  65. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +83 -1
  66. package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +7 -1
  67. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +79 -7
  68. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +40 -1
  69. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +119 -2
  70. package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +7 -0
  71. package/dist/tailordb-ddl-DqInYupv.mjs.map +1 -1
  72. package/dist/telemetry-Bklv9kQY.mjs.map +1 -1
  73. package/dist/type-source--ZNcV8RJ.mjs.map +1 -1
  74. package/dist/user-agent-vdHYF3QL.mjs.map +1 -1
  75. package/dist/utils/test/index.mjs.map +1 -1
  76. package/dist/vitest/environment.mjs.map +1 -1
  77. package/dist/vitest/index.mjs.map +1 -1
  78. package/dist/vitest/mocks/file.d.mts +1 -1
  79. package/dist/vitest/setup.mjs.map +1 -1
  80. package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -1
  81. package/dist/wait-point-registry-B-ESkTZX.mjs.map +1 -1
  82. package/dist/workflow-Cs9ISw6j.mjs.map +1 -1
  83. package/dist/{workspace_resource_pb-D2njwgsE.mjs → workspace_resource_pb-CxR_6fyN.mjs} +2 -2
  84. package/dist/workspace_resource_pb-CxR_6fyN.mjs.map +1 -0
  85. package/docs/cli/application.md +23 -5
  86. package/docs/cli/function.md +2 -2
  87. package/docs/configuration.md +28 -3
  88. package/docs/github-actions.md +167 -52
  89. package/docs/migration/v3.md +46 -0
  90. package/docs/multi-environment.md +3 -1
  91. package/docs/services/workflow.md +3 -0
  92. package/package.json +6 -6
  93. package/dist/application-BE4vehXW.mjs +0 -1
  94. package/dist/application-BzO9ywXQ.mjs +0 -199
  95. package/dist/application-BzO9ywXQ.mjs.map +0 -1
  96. package/dist/errors-C9zGf4nz.mjs +0 -7
  97. package/dist/errors-C9zGf4nz.mjs.map +0 -1
  98. package/dist/register-ts-hook-z7ggXQy4.mjs.map +0 -1
  99. package/dist/service-DHVuH7-X.mjs.map +0 -1
  100. package/dist/service_pb-DNskuJQC.mjs +0 -1
  101. package/dist/service_pb-y2GYIgfs.mjs +0 -2
  102. package/dist/service_pb-y2GYIgfs.mjs.map +0 -1
  103. package/dist/workspace_resource_pb-D2njwgsE.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-Bklv9kQY.mjs","names":[],"sources":["../src/cli/telemetry/config.ts","../src/cli/telemetry/index.ts"],"sourcesContent":["/**\n * Telemetry configuration parsed from standard OpenTelemetry environment variables.\n * Tracing is enabled when OTEL_EXPORTER_OTLP_ENDPOINT is set.\n */\nexport interface TelemetryConfig {\n readonly enabled: boolean;\n readonly endpoint: string;\n}\n\n/**\n * Parse telemetry configuration from standard OpenTelemetry environment variables.\n * Tracing is enabled when OTEL_EXPORTER_OTLP_ENDPOINT is set.\n * @returns Telemetry configuration\n */\nexport function parseTelemetryConfig(): TelemetryConfig {\n const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? \"\";\n const enabled = endpoint.length > 0;\n\n return {\n enabled,\n endpoint,\n };\n}\n","import { trace, SpanStatusCode, type Span } from \"@opentelemetry/api\";\nimport { parseTelemetryConfig, type TelemetryConfig } from \"./config\";\n\nlet _config: TelemetryConfig | undefined;\nlet _initialized = false;\nlet _provider: { register: () => void; shutdown: () => Promise<void> } | undefined;\n\n/**\n * Check whether telemetry is currently enabled.\n * @returns true if telemetry has been initialized and is enabled\n */\nexport function isTelemetryEnabled(): boolean {\n return _config?.enabled ?? false;\n}\n\n/**\n * Initialize telemetry if OTEL_EXPORTER_OTLP_ENDPOINT is set.\n * When disabled, this is a no-op with zero overhead beyond reading env vars.\n * @returns Promise that resolves when initialization completes\n */\nexport async function initTelemetry(): Promise<void> {\n if (_initialized) return;\n _initialized = true;\n\n _config = parseTelemetryConfig();\n if (!_config.enabled) return;\n\n // Dynamic imports - only loaded when tracing is enabled\n const [\n { NodeTracerProvider, BatchSpanProcessor },\n { OTLPTraceExporter },\n { resourceFromAttributes },\n { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION },\n { readPackageJson },\n ] = await Promise.all([\n import(\"@opentelemetry/sdk-trace-node\"),\n import(\"@opentelemetry/exporter-trace-otlp-proto\"),\n import(\"@opentelemetry/resources\"),\n import(\"@opentelemetry/semantic-conventions\"),\n import(\"#/cli/shared/package-json\"),\n ]);\n\n const packageJson = await readPackageJson();\n const version = packageJson.version ?? \"unknown\";\n\n const resource = resourceFromAttributes({\n [ATTR_SERVICE_NAME]: \"tailor\",\n [ATTR_SERVICE_VERSION]: version,\n });\n\n const exporter = new OTLPTraceExporter({\n url: `${_config.endpoint}/v1/traces`,\n });\n\n _provider = new NodeTracerProvider({\n resource,\n spanProcessors: [new BatchSpanProcessor(exporter)],\n });\n\n _provider.register();\n}\n\n/**\n * Shutdown the telemetry provider, flushing all pending spans.\n * Must be called before process exit to ensure traces are exported.\n * @returns Promise that resolves when shutdown completes\n */\nexport async function shutdownTelemetry(): Promise<void> {\n if (!_provider) return;\n await _provider.shutdown();\n}\n\n/**\n * Execute a function within a new span. Records exceptions and sets span status.\n * When no TracerProvider is registered, the OTel API automatically provides\n * noop spans with zero overhead.\n * @param name - Span name\n * @param fn - Function to execute within the span\n * @returns Result of fn\n */\nexport async function withSpan<T>(name: string, fn: (span: Span) => Promise<T>): Promise<T> {\n const tracer = trace.getTracer(\"tailor\");\n\n return tracer.startActiveSpan(name, async (span) => {\n try {\n const result = await fn(span);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR });\n if (error instanceof Error) {\n span.recordException(error);\n }\n throw error;\n } finally {\n span.end();\n }\n });\n}\n"],"mappings":"+DAcA,SAAgB,sBAAwC,CACtD,IAAM,EAAW,QAAQ,IAAI,6BAA+B,GAG5D,MAAO,CACL,QAHc,EAAS,OAAS,EAIhC,UACF,CACF,CCnBA,IAAI,EACA,EAAe,GACf,EAeJ,eAAsB,eAA+B,CAKnD,GAJI,IACJ,EAAe,GAEf,EAAU,qBAAqB,EAC3B,CAAC,EAAQ,SAAS,OAGtB,GAAM,CACJ,CAAE,qBAAoB,sBACtB,CAAE,qBACF,CAAE,0BACF,CAAE,oBAAmB,wBACrB,CAAE,oBACA,MAAM,QAAQ,IAAI,CACpB,OAAO,iCACP,OAAO,4CACP,OAAO,4BACP,OAAO,uCACP,OAAO,8BACT,CAAC,EAGK,GAAU,MADU,EAAgB,EAAA,CACd,SAAW,UAWvC,EAAY,IAAI,EAAmB,CACjC,SAVe,EAAuB,EACrC,GAAoB,UACpB,GAAuB,CAC1B,CAOS,EACP,eAAgB,CAAC,IAAI,EAAmB,IANrB,EAAkB,CACrC,IAAK,GAAG,EAAQ,SAAS,WAC3B,CAIiD,CAAC,CAAC,CACnD,CAAC,EAED,EAAU,SAAS,CACrB,CAOA,eAAsB,mBAAmC,CAClD,GACL,MAAM,EAAU,SAAS,CAC3B,CAUA,eAAsB,SAAY,EAAc,EAA4C,CAG1F,OAFe,EAAM,UAAU,QAEnB,CAAC,CAAC,gBAAgB,EAAM,KAAO,IAAS,CAClD,GAAI,CACF,IAAM,EAAS,MAAM,EAAG,CAAI,EAE5B,OADA,EAAK,UAAU,CAAE,KAAM,EAAe,EAAG,CAAC,EACnC,CACT,OAAS,EAAO,CAKd,MAJA,EAAK,UAAU,CAAE,KAAM,EAAe,KAAM,CAAC,EACzC,aAAiB,OACnB,EAAK,gBAAgB,CAAK,EAEtB,CACR,QAAU,CACR,EAAK,IAAI,CACX,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"telemetry-Bklv9kQY.mjs","names":["endpoint","_config","_initialized","_provider","version","readPackageJson","NodeTracerProvider","resourceFromAttributes","ATTR_SERVICE_NAME","ATTR_SERVICE_VERSION","BatchSpanProcessor","OTLPTraceExporter","trace","name","result","fn","span","SpanStatusCode","error"],"sources":["../src/cli/telemetry/config.ts","../src/cli/telemetry/index.ts"],"sourcesContent":["/**\n * Telemetry configuration parsed from standard OpenTelemetry environment variables.\n * Tracing is enabled when OTEL_EXPORTER_OTLP_ENDPOINT is set.\n */\nexport interface TelemetryConfig {\n readonly enabled: boolean;\n readonly endpoint: string;\n}\n\n/**\n * Parse telemetry configuration from standard OpenTelemetry environment variables.\n * Tracing is enabled when OTEL_EXPORTER_OTLP_ENDPOINT is set.\n * @returns Telemetry configuration\n */\nexport function parseTelemetryConfig(): TelemetryConfig {\n const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT ?? \"\";\n const enabled = endpoint.length > 0;\n\n return {\n enabled,\n endpoint,\n };\n}\n","import { trace, SpanStatusCode, type Span } from \"@opentelemetry/api\";\nimport { parseTelemetryConfig, type TelemetryConfig } from \"./config\";\n\nlet _config: TelemetryConfig | undefined;\nlet _initialized = false;\nlet _provider: { register: () => void; shutdown: () => Promise<void> } | undefined;\n\n/**\n * Check whether telemetry is currently enabled.\n * @returns true if telemetry has been initialized and is enabled\n */\nexport function isTelemetryEnabled(): boolean {\n return _config?.enabled ?? false;\n}\n\n/**\n * Initialize telemetry if OTEL_EXPORTER_OTLP_ENDPOINT is set.\n * When disabled, this is a no-op with zero overhead beyond reading env vars.\n * @returns Promise that resolves when initialization completes\n */\nexport async function initTelemetry(): Promise<void> {\n if (_initialized) return;\n _initialized = true;\n\n _config = parseTelemetryConfig();\n if (!_config.enabled) return;\n\n // Dynamic imports - only loaded when tracing is enabled\n const [\n { NodeTracerProvider, BatchSpanProcessor },\n { OTLPTraceExporter },\n { resourceFromAttributes },\n { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION },\n { readPackageJson },\n ] = await Promise.all([\n import(\"@opentelemetry/sdk-trace-node\"),\n import(\"@opentelemetry/exporter-trace-otlp-proto\"),\n import(\"@opentelemetry/resources\"),\n import(\"@opentelemetry/semantic-conventions\"),\n import(\"#/cli/shared/package-json\"),\n ]);\n\n const packageJson = await readPackageJson();\n const version = packageJson.version ?? \"unknown\";\n\n const resource = resourceFromAttributes({\n [ATTR_SERVICE_NAME]: \"tailor\",\n [ATTR_SERVICE_VERSION]: version,\n });\n\n const exporter = new OTLPTraceExporter({\n url: `${_config.endpoint}/v1/traces`,\n });\n\n _provider = new NodeTracerProvider({\n resource,\n spanProcessors: [new BatchSpanProcessor(exporter)],\n });\n\n _provider.register();\n}\n\n/**\n * Shutdown the telemetry provider, flushing all pending spans.\n * Must be called before process exit to ensure traces are exported.\n * @returns Promise that resolves when shutdown completes\n */\nexport async function shutdownTelemetry(): Promise<void> {\n if (!_provider) return;\n await _provider.shutdown();\n}\n\n/**\n * Execute a function within a new span. Records exceptions and sets span status.\n * When no TracerProvider is registered, the OTel API automatically provides\n * noop spans with zero overhead.\n * @param name - Span name\n * @param fn - Function to execute within the span\n * @returns Result of fn\n */\nexport async function withSpan<T>(name: string, fn: (span: Span) => Promise<T>): Promise<T> {\n const tracer = trace.getTracer(\"tailor\");\n\n return tracer.startActiveSpan(name, async (span) => {\n try {\n const result = await fn(span);\n span.setStatus({ code: SpanStatusCode.OK });\n return result;\n } catch (error) {\n span.setStatus({ code: SpanStatusCode.ERROR });\n if (error instanceof Error) {\n span.recordException(error);\n }\n throw error;\n } finally {\n span.end();\n }\n });\n}\n"],"mappings":"+DAcA,SAAgB,sBAAwC,CACtD,IAAMA,EAAW,QAAQ,IAAI,6BAA+B,GAG5D,MAAO,CACL,QAHcA,EAAS,OAAS,EAIhC,UACF,CACF,CCnBA,IAAIC,EACAC,EAAe,GACfC,EAeJ,eAAsB,eAA+B,CAKnD,GAJID,IACJ,EAAe,GAEf,EAAU,qBAAqB,EAC3B,CAACD,EAAQ,SAAS,OAGtB,GAAM,CACJ,CAAE,qBAAoB,sBACtB,CAAE,qBACF,CAAE,0BACF,CAAE,oBAAmB,wBACrB,CAAE,oBACA,MAAM,QAAQ,IAAI,CACpB,OAAO,iCACP,OAAO,4CACP,OAAO,4BACP,OAAO,uCACP,OAAO,8BACT,CAAC,EAGKG,GAAU,MADUC,EAAgB,EAAA,CACd,SAAW,UAWvC,EAAY,IAAIC,EAAmB,CACjC,SAVeC,EAAuB,EACrCC,GAAoB,UACpBC,GAAuBL,CAC1B,CAOS,EACP,eAAgB,CAAC,IAAIM,EAAmB,IANrBC,EAAkB,CACrC,IAAK,GAAGV,EAAQ,SAAS,WAC3B,CAIiD,CAAC,CAAC,CACnD,CAAC,EAEDE,EAAU,SAAS,CACrB,CAOA,eAAsB,mBAAmC,CAClDA,GACL,MAAMA,EAAU,SAAS,CAC3B,CAUA,eAAsB,SAAY,EAAc,EAA4C,CAG1F,OAFeS,EAAM,UAAU,QAEnB,CAAC,CAAC,gBAAgBC,EAAM,KAAO,IAAS,CAClD,GAAI,CACF,IAAMC,EAAS,MAAMC,EAAGC,CAAI,EAE5B,OADAA,EAAK,UAAU,CAAE,KAAMC,EAAe,EAAG,CAAC,EACnCH,CACT,OAASI,EAAO,CAKd,MAJAF,EAAK,UAAU,CAAE,KAAMC,EAAe,KAAM,CAAC,EACzCC,aAAiB,OACnBF,EAAK,gBAAgBE,CAAK,EAEtBA,CACR,QAAU,CACRF,EAAK,IAAI,CACX,CACF,CAAC,CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"type-source--ZNcV8RJ.mjs","names":[],"sources":["../src/parser/service/tailordb/type-source.ts"],"sourcesContent":["import type { PluginGeneratedTableSource, TypeSourceInfoEntry } from \"./types\";\n\n/**\n * Checks if a table source is generated by a plugin.\n * @param source - The table source entry to check.\n * @returns True if the source was generated by a plugin.\n */\nexport function isPluginGeneratedTable(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTableSource {\n return source.pluginId !== undefined;\n}\n"],"mappings":"AAOA,SAAgB,uBACd,EACsC,CACtC,OAAO,EAAO,WAAa,IAAA,EAC7B"}
1
+ {"version":3,"file":"type-source--ZNcV8RJ.mjs","names":["source"],"sources":["../src/parser/service/tailordb/type-source.ts"],"sourcesContent":["import type { PluginGeneratedTableSource, TypeSourceInfoEntry } from \"./types\";\n\n/**\n * Checks if a table source is generated by a plugin.\n * @param source - The table source entry to check.\n * @returns True if the source was generated by a plugin.\n */\nexport function isPluginGeneratedTable(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTableSource {\n return source.pluginId !== undefined;\n}\n"],"mappings":"AAOA,SAAgB,uBACd,EACsC,CACtC,OAAOA,EAAO,WAAa,IAAA,EAC7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"user-agent-vdHYF3QL.mjs","names":[],"sources":["../src/cli/shared/user-agent.ts"],"sourcesContent":["import { readPackageJson } from \"./package-json\";\n\n/**\n * Build the User-Agent string from an already-known SDK version, without\n * touching the filesystem. Use this when the caller has resolved the version\n * (e.g. crash reporting already reads `package.json`) to avoid a redundant read.\n * @param version - SDK version string\n * @returns User-Agent header value\n */\nexport function userAgentFromVersion(version: string): string {\n return `tailor/${version}`;\n}\n\n/**\n * Build the User-Agent string for CLI requests.\n *\n * Lives in its own module (rather than `client.ts`) so callers that only need\n * the UA — e.g. crash reporting — do not pull in the operator client's heavy\n * OAuth2/Connect/Protobuf dependencies, and so importing it never forms a cycle.\n * @returns User-Agent header value\n */\nexport async function userAgent() {\n const packageJson = await readPackageJson();\n return userAgentFromVersion(packageJson.version ?? \"unknown\");\n}\n"],"mappings":"gDASA,SAAgB,qBAAqB,EAAyB,CAC5D,MAAO,UAAU,GACnB,CAUA,eAAsB,WAAY,CAEhC,OAAO,sBAAqB,MADF,EAAgB,EAAA,CACF,SAAW,SAAS,CAC9D"}
1
+ {"version":3,"file":"user-agent-vdHYF3QL.mjs","names":["readPackageJson","version"],"sources":["../src/cli/shared/user-agent.ts"],"sourcesContent":["import { readPackageJson } from \"./package-json\";\n\n/**\n * Build the User-Agent string from an already-known SDK version, without\n * touching the filesystem. Use this when the caller has resolved the version\n * (e.g. crash reporting already reads `package.json`) to avoid a redundant read.\n * @param version - SDK version string\n * @returns User-Agent header value\n */\nexport function userAgentFromVersion(version: string): string {\n return `tailor/${version}`;\n}\n\n/**\n * Build the User-Agent string for CLI requests.\n *\n * Lives in its own module (rather than `client.ts`) so callers that only need\n * the UA — e.g. crash reporting — do not pull in the operator client's heavy\n * OAuth2/Connect/Protobuf dependencies, and so importing it never forms a cycle.\n * @returns User-Agent header value\n */\nexport async function userAgent() {\n const packageJson = await readPackageJson();\n return userAgentFromVersion(packageJson.version ?? \"unknown\");\n}\n"],"mappings":"gDASA,SAAgB,qBAAqB,EAAyB,CAC5D,MAAO,UAAUC,GACnB,CAUA,eAAsB,WAAY,CAEhC,OAAO,sBAAqB,MADFD,EAAgB,EAAA,CACF,SAAW,SAAS,CAC9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import { isNestedObject } from \"#/runtime/field-parse\";\nimport type { output } from \"#/configure/index\";\nimport type { TailorDBType } from \"#/configure/services/tailordb/schema\";\nimport type { TailorField } from \"#/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n// Not `record[key] = value`: assigning to `__proto__` goes through the inherited\n// setter, which mutates the prototype instead of recording the field and leaves\n// no own property behind for the value to be read from.\nfunction setField(record: Record<string, unknown>, key: string, value: unknown): void {\n Object.defineProperty(record, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n}\n\n/**\n * Creates a hook function that processes TailorDB table fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * - Takes each field from the data's own properties, so a field named after a\n * member of `Object` such as `toString` is read from the record rather than\n * from the prototype\n * @template T - The output type of the hook function\n * @param type - TailorDB table definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown, now: Date = new Date()) => {\n const obj = data && typeof data === \"object\" ? (data as Record<string, unknown>) : undefined;\n const hooked = Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n // `Object.hasOwn`, not `obj?.[key]`: a field named after an Object member\n // such as `toString` would otherwise read the inherited value.\n const input = obj && Object.hasOwn(obj, key) ? obj[key] : undefined;\n let hookedValue: unknown;\n if (key === \"id\") {\n hookedValue = input ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n hookedValue = Array.isArray(input)\n ? input.map((item) => (isNestedObject(item) ? nestedHook(item, now) : item))\n : input;\n } else {\n hookedValue = isNestedObject(input) ? nestedHook(input, now) : input;\n }\n } else if (field.metadata.hooks?.create) {\n hookedValue = field.metadata.hooks.create({ input, invoker: null, now });\n if (hookedValue instanceof Date) {\n hookedValue = hookedValue.toISOString();\n }\n } else {\n hookedValue = input;\n }\n if (hookedValue == null && field.metadata.default !== undefined) {\n const isTimeType =\n field.type === \"datetime\" || field.type === \"date\" || field.type === \"time\";\n hookedValue =\n field.metadata.default === \"now\" && isTimeType\n ? now.toISOString()\n : field.metadata.default;\n }\n // Set even when there is no value: the key carrying `undefined` is what\n // tells a schema inferred from the record that the column is nullable,\n // and it shadows a same-named member of `Object.prototype`.\n setField(hooked, key, hookedValue);\n return hooked;\n },\n {} as Record<string, unknown>,\n );\n\n // oxlint-disable-next-line typescript/no-unnecessary-condition -- metadata absent in recursive nested calls\n if (type.metadata?.typeHook?.create) {\n const { id: _id, ...typeHookInput } = hooked;\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n const overrides = type.metadata.typeHook.create({\n input: typeHookInput,\n invoker: null,\n now,\n });\n if (overrides && typeof overrides === \"object\") {\n for (const [key, value] of Object.entries(overrides as Record<string, unknown>)) {\n setField(hooked, key, value instanceof Date ? value.toISOString() : value);\n }\n }\n }\n\n return hooked as Partial<output<T>>;\n };\n}\n\n// Collect the issues the table's own `validate` reports for a record, so they\n// surface the same way a field's do instead of ending the run.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction typeLevelIssues(type: TailorDBType<any, any> | undefined, hooked: unknown) {\n // oxlint-disable-next-line typescript/no-unnecessary-condition -- absent on a nested type\n const typeValidate = type?.metadata?.typeValidate;\n if (!typeValidate) {\n return [];\n }\n const { id: _id, ...newRecord } = hooked as Record<string, unknown>;\n const issues: StandardSchemaV1.Issue[] = [];\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n typeValidate({ newRecord, oldRecord: null, invoker: null }, (field: string, message: string) => {\n issues.push({ message, path: [field] });\n });\n return issues;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype DeclaredFields = Record<string, TailorField<any, any, any>>;\n\nfunction undeclaredFieldMessage(key: string): string {\n return `Field \"${key}\" is not declared by the table. Remove it from the row, or add it to the table definition and run \\`tailor generate\\`.`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n// Reads the raw row, not the hooked one: the hook only copies the declared fields,\n// so an undeclared key is gone by the time the field schema runs.\nfunction collectUndeclaredFieldIssues(\n value: unknown,\n fields: DeclaredFields,\n path: string[],\n issues: StandardSchemaV1.Issue[],\n): void {\n if (!isRecord(value)) {\n return;\n }\n for (const key of Object.keys(value)) {\n // `Object.hasOwn`, not `key in fields`: a key such as `constructor` would\n // otherwise resolve to a member of `Object.prototype`.\n if (!Object.hasOwn(fields, key)) {\n issues.push({ message: undeclaredFieldMessage(key), path: path.concat(key) });\n continue;\n }\n const field = fields[key];\n if (field?.type !== \"nested\") {\n continue;\n }\n const nested = value[key];\n const nestedFields = field.fields as DeclaredFields;\n if (field.metadata.array) {\n if (Array.isArray(nested)) {\n nested.forEach((item, index) => {\n collectUndeclaredFieldIssues(item, nestedFields, path.concat(key, `[${index}]`), issues);\n });\n }\n } else {\n collectUndeclaredFieldIssues(nested, nestedFields, path.concat(key), issues);\n }\n }\n}\n\n/**\n * Creates the standard schema definition used to validate seed rows.\n * Runs the hook, then the table's own `validate`, and the field schema only when\n * that reported nothing, so both levels of validation report as issues rather\n * than by throwing. When the table is given, a key the row carries that the table\n * does not declare is reported as an issue as well, including keys inside nested\n * objects, so a row that no longer matches the table fails here instead of when\n * it is applied.\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @param type - TailorDB table definition; runs its table-level `validate` and\n * rejects fields it does not declare\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type?: TailorDBType<any, any>,\n) {\n const validateHooked = (hooked: Partial<T>): StandardSchemaV1.Result<T> => {\n const issues = typeLevelIssues(type, hooked);\n if (issues.length > 0) {\n return { issues };\n }\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n invoker: null,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n };\n\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const undeclared: StandardSchemaV1.Issue[] = [];\n if (type) {\n collectUndeclaredFieldIssues(value, type.fields as DeclaredFields, [], undeclared);\n }\n const result = validateHooked(hooked);\n const issues = [...undeclared, ...(result.issues ?? [])];\n return issues.length > 0 ? { issues } : result;\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":"mDASA,SAAS,SAAS,EAAiC,EAAa,EAAsB,CACpF,OAAO,eAAe,EAAQ,EAAK,CACjC,QACA,WAAY,GACZ,SAAU,GACV,aAAc,EAChB,CAAC,CACH,CAeA,SAAgB,mBAAqD,EAAS,CAC5E,OAAQ,EAAe,kBAAY,IAAI,OAAW,CAChD,IAAM,EAAM,GAAQ,OAAO,GAAS,SAAY,EAAmC,IAAA,GAC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,EAAW,MAAM,CAC9B,MAAO,EACP,KAAM,EACN,QAAS,IACX,CAAC,EAID,OAHI,EAAO,OACF,EAEF,CAAE,MAAO,CAAY,CAC9B,EAEA,MAAO,CACL,YAAa,CACX,QAAS,EACT,OAAQ,uBACR,SAAW,GAAmB,CAC5B,IAAM,EAAS,EAAK,CAAK,EACnB,EAAuC,CAAC,EAC1C,GACF,6BAA6B,EAAO,EAAK,OAA0B,CAAC,EAAG,CAAU,EAEnF,IAAM,EAAS,eAAe,CAAM,EAC9B,EAAS,CAAC,GAAG,EAAY,GAAI,EAAO,QAAU,CAAC,CAAE,EACvD,OAAO,EAAO,OAAS,EAAI,CAAE,QAAO,EAAI,CAC1C,CACF,CACF,CACF"}
1
+ {"version":3,"file":"index.mjs","names":["isNestedObject","record","key","obj","data","hooked","type","value","field","input","hookedValue","nestedHook","item","now","isTimeType","_id","typeHookInput","overrides","typeValidate","newRecord","issues","fields","path","nested","nestedFields","index","result","schemaType","hook","undeclared"],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import { isNestedObject } from \"#/runtime/field-parse\";\nimport type { output } from \"#/configure/index\";\nimport type { TailorDBType } from \"#/configure/services/tailordb/schema\";\nimport type { TailorField } from \"#/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n// Not `record[key] = value`: assigning to `__proto__` goes through the inherited\n// setter, which mutates the prototype instead of recording the field and leaves\n// no own property behind for the value to be read from.\nfunction setField(record: Record<string, unknown>, key: string, value: unknown): void {\n Object.defineProperty(record, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n}\n\n/**\n * Creates a hook function that processes TailorDB table fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * - Takes each field from the data's own properties, so a field named after a\n * member of `Object` such as `toString` is read from the record rather than\n * from the prototype\n * @template T - The output type of the hook function\n * @param type - TailorDB table definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown, now: Date = new Date()) => {\n const obj = data && typeof data === \"object\" ? (data as Record<string, unknown>) : undefined;\n const hooked = Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n // `Object.hasOwn`, not `obj?.[key]`: a field named after an Object member\n // such as `toString` would otherwise read the inherited value.\n const input = obj && Object.hasOwn(obj, key) ? obj[key] : undefined;\n let hookedValue: unknown;\n if (key === \"id\") {\n hookedValue = input ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n hookedValue = Array.isArray(input)\n ? input.map((item) => (isNestedObject(item) ? nestedHook(item, now) : item))\n : input;\n } else {\n hookedValue = isNestedObject(input) ? nestedHook(input, now) : input;\n }\n } else if (field.metadata.hooks?.create) {\n hookedValue = field.metadata.hooks.create({ input, invoker: null, now });\n if (hookedValue instanceof Date) {\n hookedValue = hookedValue.toISOString();\n }\n } else {\n hookedValue = input;\n }\n if (hookedValue == null && field.metadata.default !== undefined) {\n const isTimeType =\n field.type === \"datetime\" || field.type === \"date\" || field.type === \"time\";\n hookedValue =\n field.metadata.default === \"now\" && isTimeType\n ? now.toISOString()\n : field.metadata.default;\n }\n // Set even when there is no value: the key carrying `undefined` is what\n // tells a schema inferred from the record that the column is nullable,\n // and it shadows a same-named member of `Object.prototype`.\n setField(hooked, key, hookedValue);\n return hooked;\n },\n {} as Record<string, unknown>,\n );\n\n // oxlint-disable-next-line typescript/no-unnecessary-condition -- metadata absent in recursive nested calls\n if (type.metadata?.typeHook?.create) {\n const { id: _id, ...typeHookInput } = hooked;\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n const overrides = type.metadata.typeHook.create({\n input: typeHookInput,\n invoker: null,\n now,\n });\n if (overrides && typeof overrides === \"object\") {\n for (const [key, value] of Object.entries(overrides as Record<string, unknown>)) {\n setField(hooked, key, value instanceof Date ? value.toISOString() : value);\n }\n }\n }\n\n return hooked as Partial<output<T>>;\n };\n}\n\n// Collect the issues the table's own `validate` reports for a record, so they\n// surface the same way a field's do instead of ending the run.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction typeLevelIssues(type: TailorDBType<any, any> | undefined, hooked: unknown) {\n // oxlint-disable-next-line typescript/no-unnecessary-condition -- absent on a nested type\n const typeValidate = type?.metadata?.typeValidate;\n if (!typeValidate) {\n return [];\n }\n const { id: _id, ...newRecord } = hooked as Record<string, unknown>;\n const issues: StandardSchemaV1.Issue[] = [];\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n typeValidate({ newRecord, oldRecord: null, invoker: null }, (field: string, message: string) => {\n issues.push({ message, path: [field] });\n });\n return issues;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype DeclaredFields = Record<string, TailorField<any, any, any>>;\n\nfunction undeclaredFieldMessage(key: string): string {\n return `Field \"${key}\" is not declared by the table. Remove it from the row, or add it to the table definition and run \\`tailor generate\\`.`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n// Reads the raw row, not the hooked one: the hook only copies the declared fields,\n// so an undeclared key is gone by the time the field schema runs.\nfunction collectUndeclaredFieldIssues(\n value: unknown,\n fields: DeclaredFields,\n path: string[],\n issues: StandardSchemaV1.Issue[],\n): void {\n if (!isRecord(value)) {\n return;\n }\n for (const key of Object.keys(value)) {\n // `Object.hasOwn`, not `key in fields`: a key such as `constructor` would\n // otherwise resolve to a member of `Object.prototype`.\n if (!Object.hasOwn(fields, key)) {\n issues.push({ message: undeclaredFieldMessage(key), path: path.concat(key) });\n continue;\n }\n const field = fields[key];\n if (field?.type !== \"nested\") {\n continue;\n }\n const nested = value[key];\n const nestedFields = field.fields as DeclaredFields;\n if (field.metadata.array) {\n if (Array.isArray(nested)) {\n nested.forEach((item, index) => {\n collectUndeclaredFieldIssues(item, nestedFields, path.concat(key, `[${index}]`), issues);\n });\n }\n } else {\n collectUndeclaredFieldIssues(nested, nestedFields, path.concat(key), issues);\n }\n }\n}\n\n/**\n * Creates the standard schema definition used to validate seed rows.\n * Runs the hook, then the table's own `validate`, and the field schema only when\n * that reported nothing, so both levels of validation report as issues rather\n * than by throwing. When the table is given, a key the row carries that the table\n * does not declare is reported as an issue as well, including keys inside nested\n * objects, so a row that no longer matches the table fails here instead of when\n * it is applied.\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @param type - TailorDB table definition; runs its table-level `validate` and\n * rejects fields it does not declare\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n type?: TailorDBType<any, any>,\n) {\n const validateHooked = (hooked: Partial<T>): StandardSchemaV1.Result<T> => {\n const issues = typeLevelIssues(type, hooked);\n if (issues.length > 0) {\n return { issues };\n }\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n invoker: null,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n };\n\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const undeclared: StandardSchemaV1.Issue[] = [];\n if (type) {\n collectUndeclaredFieldIssues(value, type.fields as DeclaredFields, [], undeclared);\n }\n const result = validateHooked(hooked);\n const issues = [...undeclared, ...(result.issues ?? [])];\n return issues.length > 0 ? { issues } : result;\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":"mDASA,SAAS,SAAS,EAAiC,EAAa,EAAsB,CACpF,OAAO,eAAeC,EAAQC,EA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6BX,EAAMY,EAAcF,EAAK,OAAOpB,EAAK,IAAIuB,EAAM,EAAE,EAAGL,CAAM,CACzF,CAAC,EAGH,6BAA6BG,EAAQC,EAAcF,EAAK,OAAOpB,CAAG,EAAGkB,CAAM,CAE/E,CACF,CAiBA,SAAgB,qBAEd,EACA,EAEA,EACA,CACA,IAAM,eAAkB,GAAmD,CACzE,IAAMA,EAAS,gBAAgBd,EAAMD,CAAM,EAC3C,GAAIe,EAAO,OAAS,EAClB,MAAO,CAAE,QAAO,EAElB,IAAMM,EAASC,EAAW,MAAM,CAC9B,MAAOtB,EACP,KAAMA,EACN,QAAS,IACX,CAAC,EAID,OAHIqB,EAAO,OACFA,EAEF,CAAE,MAAOrB,CAAY,CAC9B,EAEA,MAAO,CACL,YAAa,CACX,QAAS,EACT,OAAQ,uBACR,SAAW,GAAmB,CAC5B,IAAMA,EAASuB,EAAKrB,CAAK,EACnBsB,EAAuC,CAAC,EAC1CvB,GACF,6BAA6BC,EAAOD,EAAK,OAA0B,CAAC,EAAGuB,CAAU,EAEnF,IAAMH,EAAS,eAAerB,CAAM,EAC9Be,EAAS,CAAC,GAAGS,EAAY,GAAIH,EAAO,QAAU,CAAC,CAAE,EACvD,OAAON,EAAO,OAAS,EAAI,CAAE,QAAO,EAAIM,CAC1C,CACF,CACF,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"environment.mjs","names":[],"sources":["../../src/vitest/environment.ts"],"sourcesContent":["import { ES_BUILTINS } from \"#/utils/es-builtins\";\n// Import from ./globals (NOT ./mock): this module runs in the Vitest environment\n// realm where `vi` is unavailable, and ./mock imports `vi`. ./globals is\n// dependency-free of vitest.\nimport { RUNTIME_FLAG_KEY, cleanupPlatformGlobals, installPlatformGlobals } from \"./globals\";\n\n// Globals allowed in the Tailor Platform runtime.\n// ES_BUILTINS is the free-variable allowlist the deploy-time check uses, so\n// the emulated runtime exposes exactly the same identifiers as the production\n// platform (ECMAScript builtins + shared Node/browser runtime globals like\n// console, fetch, setTimeout).\n// Platform API mocks (tailor, tailordb, etc.) are not listed here — the base\n// surface is injected by installPlatformGlobals() after the whitelist cleanup,\n// and per-namespace mocks are layered on at `using xMock()` acquisition time.\nconst ALLOWED_GLOBALS = new Set([\n ...ES_BUILTINS,\n\n // The environment-active flag (set in installPlatformGlobals, used by\n // setup.ts to detect the tailor-runtime environment).\n RUNTIME_FLAG_KEY,\n\n // Used by Vitest internally — not in the platform runtime, but removing breaks the test runner\n \"process\",\n \"require\",\n \"module\",\n \"exports\",\n \"__vitest_worker__\",\n \"__vitest_mocker__\",\n \"VITEST_POOL_ID\",\n]);\n\nexport default {\n name: \"tailor-runtime\",\n viteEnvironment: \"ssr\",\n\n async setup(global: typeof globalThis) {\n const g = global as Record<string, unknown>;\n\n const temporalDescriptor = Object.getOwnPropertyDescriptor(g, \"Temporal\");\n const needsTemporal = g.Temporal === undefined;\n const temporal = needsTemporal\n ? (await import(\"temporal-polyfill/full/implementation\")).Temporal\n : undefined;\n\n // Save and remove all non-whitelisted globals\n const saved: Record<string, PropertyDescriptor> = {};\n for (const key of Object.getOwnPropertyNames(g)) {\n if (!ALLOWED_GLOBALS.has(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(g, key);\n if (descriptor?.configurable) {\n saved[key] = descriptor;\n delete g[key];\n }\n }\n }\n\n // Install the base platform surface after whitelist cleanup. Per-namespace\n // mocks (workflow, tailordb, …) are installed on demand by `using xMock()`.\n installPlatformGlobals(global);\n if (needsTemporal) {\n Object.defineProperty(g, \"Temporal\", {\n value: temporal,\n writable: true,\n configurable: true,\n });\n }\n\n return {\n teardown(global: typeof globalThis) {\n cleanupPlatformGlobals(global);\n\n if (needsTemporal) {\n if (temporalDescriptor) {\n Object.defineProperty(global, \"Temporal\", temporalDescriptor);\n } else {\n Reflect.deleteProperty(global, \"Temporal\");\n }\n }\n\n // Restore removed globals\n const g = global as Record<string, unknown>;\n for (const [key, descriptor] of Object.entries(saved)) {\n Object.defineProperty(g, key, descriptor);\n }\n },\n };\n },\n};\n"],"mappings":"0GAcA,MAAM,kBAAkB,IAAI,IAAI,CAC9B,GAAG,EAIH,EAGA,UACA,UACA,SACA,UACA,oBACA,oBACA,gBACF,CAAC,EAED,IAAA,EAAe,CACb,KAAM,iBACN,gBAAiB,MAEjB,MAAM,MAAM,EAA2B,CACrC,IAAM,EAAI,EAEJ,EAAqB,OAAO,yBAAyB,EAAG,UAAU,EAClE,EAAgB,EAAE,WAAa,IAAA,GAC/B,EAAW,GACZ,MAAM,OAAO,yCAAA,CAA0C,SACxD,IAAA,GAGE,EAA4C,CAAC,EACnD,IAAK,IAAM,KAAO,OAAO,oBAAoB,CAAC,EAC5C,GAAI,CAAC,EAAgB,IAAI,CAAG,EAAG,CAC7B,IAAM,EAAa,OAAO,yBAAyB,EAAG,CAAG,EACrD,GAAY,eACd,EAAM,GAAO,EACb,OAAO,EAAE,GAEb,CAcF,OATA,EAAuB,CAAM,EACzB,GACF,OAAO,eAAe,EAAG,WAAY,CACnC,MAAO,EACP,SAAU,GACV,aAAc,EAChB,CAAC,EAGI,CACL,SAAS,EAA2B,CAClC,EAAuB,CAAM,EAEzB,IACE,EACF,OAAO,eAAe,EAAQ,WAAY,CAAkB,EAE5D,QAAQ,eAAe,EAAQ,UAAU,GAK7C,IAAM,EAAI,EACV,IAAK,GAAM,CAAC,EAAK,KAAe,OAAO,QAAQ,CAAK,EAClD,OAAO,eAAe,EAAG,EAAK,CAAU,CAE5C,CACF,CACF,CACF"}
1
+ {"version":3,"file":"environment.mjs","names":["ES_BUILTINS","cleanupPlatformGlobals","installPlatformGlobals","RUNTIME_FLAG_KEY","ALLOWED_GLOBALS","environment_default","g","global","temporalDescriptor","needsTemporal","temporal","saved","key","descriptor"],"sources":["../../src/vitest/environment.ts"],"sourcesContent":["import { ES_BUILTINS } from \"#/utils/es-builtins\";\n// Import from ./globals (NOT ./mock): this module runs in the Vitest environment\n// realm where `vi` is unavailable, and ./mock imports `vi`. ./globals is\n// dependency-free of vitest.\nimport { RUNTIME_FLAG_KEY, cleanupPlatformGlobals, installPlatformGlobals } from \"./globals\";\n\n// Globals allowed in the Tailor Platform runtime.\n// ES_BUILTINS is the free-variable allowlist the deploy-time check uses, so\n// the emulated runtime exposes exactly the same identifiers as the production\n// platform (ECMAScript builtins + shared Node/browser runtime globals like\n// console, fetch, setTimeout).\n// Platform API mocks (tailor, tailordb, etc.) are not listed here — the base\n// surface is injected by installPlatformGlobals() after the whitelist cleanup,\n// and per-namespace mocks are layered on at `using xMock()` acquisition time.\nconst ALLOWED_GLOBALS = new Set([\n ...ES_BUILTINS,\n\n // The environment-active flag (set in installPlatformGlobals, used by\n // setup.ts to detect the tailor-runtime environment).\n RUNTIME_FLAG_KEY,\n\n // Used by Vitest internally — not in the platform runtime, but removing breaks the test runner\n \"process\",\n \"require\",\n \"module\",\n \"exports\",\n \"__vitest_worker__\",\n \"__vitest_mocker__\",\n \"VITEST_POOL_ID\",\n]);\n\nexport default {\n name: \"tailor-runtime\",\n viteEnvironment: \"ssr\",\n\n async setup(global: typeof globalThis) {\n const g = global as Record<string, unknown>;\n\n const temporalDescriptor = Object.getOwnPropertyDescriptor(g, \"Temporal\");\n const needsTemporal = g.Temporal === undefined;\n const temporal = needsTemporal\n ? (await import(\"temporal-polyfill/full/implementation\")).Temporal\n : undefined;\n\n // Save and remove all non-whitelisted globals\n const saved: Record<string, PropertyDescriptor> = {};\n for (const key of Object.getOwnPropertyNames(g)) {\n if (!ALLOWED_GLOBALS.has(key)) {\n const descriptor = Object.getOwnPropertyDescriptor(g, key);\n if (descriptor?.configurable) {\n saved[key] = descriptor;\n delete g[key];\n }\n }\n }\n\n // Install the base platform surface after whitelist cleanup. Per-namespace\n // mocks (workflow, tailordb, …) are installed on demand by `using xMock()`.\n installPlatformGlobals(global);\n if (needsTemporal) {\n Object.defineProperty(g, \"Temporal\", {\n value: temporal,\n writable: true,\n configurable: true,\n });\n }\n\n return {\n teardown(global: typeof globalThis) {\n cleanupPlatformGlobals(global);\n\n if (needsTemporal) {\n if (temporalDescriptor) {\n Object.defineProperty(global, \"Temporal\", temporalDescriptor);\n } else {\n Reflect.deleteProperty(global, \"Temporal\");\n }\n }\n\n // Restore removed globals\n const g = global as Record<string, unknown>;\n for (const [key, descriptor] of Object.entries(saved)) {\n Object.defineProperty(g, key, descriptor);\n }\n },\n };\n },\n};\n"],"mappings":"0GAcA,MAAMI,kBAAkB,IAAI,IAAI,CAC9B,GAAGJ,EAIHG,EAGA,UACA,UACA,SACA,UACA,oBACA,oBACA,gBACF,CAAC,EAED,IAAAE,EAAe,CACb,KAAM,iBACN,gBAAiB,MAEjB,MAAM,MAAM,EAA2B,CACrC,IAAMC,EAAIC,EAEJC,EAAqB,OAAO,yBAAyBF,EAAG,UAAU,EAClEG,EAAgBH,EAAE,WAAa,IAAA,GAC/BI,EAAWD,GACZ,MAAM,OAAO,yCAAA,CAA0C,SACxD,IAAA,GAGEE,EAA4C,CAAC,EACnD,IAAK,IAAMC,KAAO,OAAO,oBAAoBN,CAAC,EAC5C,GAAI,CAACF,EAAgB,IAAIQ,CAAG,EAAG,CAC7B,IAAMC,EAAa,OAAO,yBAAyBP,EAAGM,CAAG,EACrDC,GAAY,eACd,EAAMD,GAAOC,EACb,OAAOP,EAAEM,GAEb,CAcF,OATAV,EAAuBK,CAAM,EACzBE,GACF,OAAO,eAAeH,EAAG,WAAY,CACnC,MAAOI,EACP,SAAU,GACV,aAAc,EAChB,CAAC,EAGI,CACL,SAAS,EAA2B,CAClCT,EAAuBM,CAAM,EAEzBE,IACED,EACF,OAAO,eAAeD,EAAQ,WAAYC,CAAkB,EAE5D,QAAQ,eAAeD,EAAQ,UAAU,GAK7C,IAAMD,EAAIC,EACV,IAAK,GAAM,CAACK,EAAKC,KAAe,OAAO,QAAQF,CAAK,EAClD,OAAO,eAAeL,EAAGM,EAAKC,CAAU,CAE5C,CACF,CACF,CACF"}