@tailor-platform/sdk 2.3.0 → 2.5.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.
- package/CHANGELOG.md +171 -0
- package/README.md +1 -1
- package/dist/aigateway-DsWDjzk4.mjs +2 -0
- package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
- package/dist/application-DFOUovmN.mjs +1 -0
- package/dist/application-D_4vg1KR.mjs +192 -0
- package/dist/application-D_4vg1KR.mjs.map +1 -0
- package/dist/assert-WeXvmG4j.mjs +2 -0
- package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
- package/dist/authconnection-CynFBIv8.mjs +2 -0
- package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
- package/dist/brand-C8nMKhJC.mjs +2 -0
- package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
- package/dist/cli/commands/deploy/deploy.d.mts +2 -2
- package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
- package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
- package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
- package/dist/cli/commands/executor/jobs.d.mts +1 -1
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
- package/dist/cli/commands/show.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +15 -15
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +7 -3
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
- package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
- package/dist/cli/lib.d.mts +8 -4
- package/dist/cli/lib.mjs +1 -9
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +1170 -7686
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/seed-chunker.d.mts +5 -5
- package/dist/cli/ts-hook.mjs +3 -1
- package/dist/completion/zsh-worker.zsh +99 -18
- package/dist/configure/config/index.d.mts +2 -2
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +49 -12
- package/dist/configure/index.mjs +1 -1267
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +5 -4
- package/dist/configure/services/aigateway/types.d.mts +6 -1
- package/dist/configure/services/auth/types.d.mts +3 -3
- package/dist/configure/services/idp/types.d.mts +1 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +5 -9
- package/dist/configure/services/tailordb/types.d.mts +8 -5
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/job.d.mts +12 -2
- package/dist/configure/types/auth-namespace-name.d.mts +18 -0
- package/dist/configure/types/field.types.d.mts +1 -1
- package/dist/configure/types/permission-operand.types.d.mts +1 -1
- package/dist/context-D0QjfxzD.mjs +2 -0
- package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
- package/dist/crashreport-B-_HTKLr.mjs +42 -0
- package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
- package/dist/crashreport-BmsRIdpy.mjs +1 -0
- package/dist/errors-DSEXKRVD.mjs +2 -0
- package/dist/errors-DSEXKRVD.mjs.map +1 -0
- package/dist/file-COPYfju_.mjs +2 -0
- package/dist/file-COPYfju_.mjs.map +1 -0
- package/dist/globals-CMHSnj4w.mjs +2 -0
- package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
- package/dist/iconv-DlFMt2gW.mjs +2 -0
- package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
- package/dist/idp-G_ojPBB5.mjs +2 -0
- package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
- package/dist/interceptor-DQg3cR_9.mjs +2 -0
- package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
- package/dist/kysely/index.mjs +1 -31
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/kysely-type-BTi3BMtL.mjs +43 -0
- package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
- package/dist/logger-BcGy-u7G.mjs +9 -0
- package/dist/{logger-DSdExfor.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
- package/dist/logger-DP2BjQ93.mjs +2 -0
- package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
- package/dist/multiline-EyzjEwn9.mjs +3 -0
- package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
- package/dist/node-builtins-oBl7EbyV.mjs +2 -0
- package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
- package/dist/package-json-C690ceex.mjs +2 -0
- package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
- package/dist/package-json-CmqhDJ__.mjs +1 -0
- package/dist/parser/service/tailordb/type-source.d.mts +5 -5
- package/dist/parser/service/tailordb/types.d.mts +4 -4
- package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
- package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +22 -101
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +9 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
- package/dist/plugin/builtin/seed/index.d.mts +5 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -3
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -6
- package/dist/plugin/get-generated-table.d.mts +16 -0
- package/dist/plugin/index.d.mts +3 -2
- package/dist/plugin/index.mjs +1 -251
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +32 -25
- package/dist/plugin/with-context.d.mts +4 -4
- package/dist/register-ts-hook-Drnaproy.mjs +640 -0
- package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
- package/dist/registry-HlEaGvl5.mjs +2 -0
- package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
- package/dist/repl-editor-BG1aDOfH.mjs +2 -0
- package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
- package/dist/runtime/aigateway.mjs +1 -3
- package/dist/runtime/authconnection.mjs +1 -3
- package/dist/runtime/context.mjs +1 -3
- package/dist/runtime/file.d.mts +28 -28
- package/dist/runtime/file.mjs +1 -3
- package/dist/runtime/globals.mjs +1 -1
- package/dist/runtime/iconv.mjs +1 -3
- package/dist/runtime/idp.mjs +1 -3
- package/dist/runtime/index.mjs +1 -11
- package/dist/runtime/logger.mjs +1 -3
- package/dist/runtime/secretmanager.mjs +1 -3
- package/dist/runtime/types.d.mts +1 -1
- package/dist/runtime/workflow.mjs +1 -3
- package/dist/schema-Ze_dI5VX.mjs +2 -0
- package/dist/schema-Ze_dI5VX.mjs.map +1 -0
- package/dist/secret-file-C9wp_FCX.mjs +2 -0
- package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
- package/dist/secretmanager-5olfnI1b.mjs +2 -0
- package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
- package/dist/secretmanager-vHQoXdQz.mjs +2 -0
- package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
- package/dist/seed/index.d.mts +4 -4
- package/dist/seed/index.mjs +8 -244
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-DwqRFdqP.mjs +207 -0
- package/dist/seed-DwqRFdqP.mjs.map +1 -0
- package/dist/service-BVe9u2Rt.mjs +7 -0
- package/dist/service-BVe9u2Rt.mjs.map +1 -0
- package/dist/service-CpZELSBa.mjs +1 -0
- package/dist/service-DlgaUO4V.mjs +2 -0
- package/dist/{service-hZskxZmg.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
- package/dist/service_pb-DGKCLuAs.mjs +2 -0
- package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
- package/dist/service_pb-_aeFE-Nv.mjs +1 -0
- package/dist/telemetry-Bklv9kQY.mjs +2 -0
- package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
- package/dist/telemetry-DXHP3VVi.mjs +1 -0
- package/dist/type-source--ZNcV8RJ.mjs +2 -0
- package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
- package/dist/types/aigateway.generated.d.mts +2 -2
- package/dist/types/auth.generated.d.mts +3 -3
- package/dist/types/executor.generated.d.mts +2 -2
- package/dist/types/tailordb.generated.d.mts +12 -12
- package/dist/user-agent-vdHYF3QL.mjs +2 -0
- package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +1 -109
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -41
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs +1 -1980
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/file.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -140
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
- package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
- package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
- package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
- package/dist/workflow-Cs9ISw6j.mjs +2 -0
- package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
- package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
- package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
- package/docs/cli/application.md +3 -1
- package/docs/cli/function.md +77 -13
- package/docs/cli/setup.md +24 -14
- package/docs/cli/tailordb.md +32 -30
- package/docs/cli/workspace.md +2 -2
- package/docs/cli-reference.md +23 -22
- package/docs/configuration.md +2 -2
- package/docs/github-actions.md +10 -9
- package/docs/migration/v2.md +16 -4
- package/docs/migration/v3.md +123 -0
- package/docs/plugin/custom.md +130 -85
- package/docs/plugin/index.md +3 -3
- package/docs/quickstart.md +1 -1
- package/docs/services/aigateway.md +33 -9
- package/docs/services/executor.md +5 -1
- package/docs/services/tailordb-migration.md +68 -54
- package/docs/services/tailordb.md +7 -7
- package/docs/services/workflow.md +10 -9
- package/docs/testing.md +1 -1
- package/package.json +16 -16
- package/postinstall.mjs +1 -1
- package/dist/aigateway-DR4Kwuik.mjs +0 -9
- package/dist/application-BZfk4HKm.mjs +0 -3
- package/dist/application-F-nl107y.mjs +0 -6019
- package/dist/application-F-nl107y.mjs.map +0 -1
- package/dist/assert-DBxo8jPo.mjs +0 -9
- package/dist/authconnection-CZvi9ANm.mjs +0 -9
- package/dist/brand-Eo4pLXPJ.mjs +0 -36
- package/dist/context-DYQVYWqZ.mjs +0 -23
- package/dist/crashreport-CIIfLnoO.mjs +0 -423
- package/dist/crashreport-CINZ5dVN.mjs +0 -3
- package/dist/errors-BVb6vYGy.mjs +0 -89
- package/dist/errors-BVb6vYGy.mjs.map +0 -1
- package/dist/file-BUcmVIH2.mjs +0 -58
- package/dist/file-BUcmVIH2.mjs.map +0 -1
- package/dist/globals-B2nlxBrz.mjs +0 -126
- package/dist/iconv-QWaZh0TT.mjs +0 -38
- package/dist/idp-RA_swu-h.mjs +0 -82
- package/dist/interceptor-e33JtsC-.mjs +0 -33
- package/dist/logger-BtX0suGY.mjs +0 -48
- package/dist/logger-DSdExfor.mjs +0 -358
- package/dist/multiline-sfHpTZZK.mjs +0 -38
- package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
- package/dist/package-json-8b0O9TlX.mjs +0 -17
- package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
- package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
- package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
- package/dist/plugin/builtin/seed/types.d.mts +0 -2
- package/dist/plugin/get-generated-type.d.mts +0 -16
- package/dist/register-ts-hook-ClI226n2.mjs +0 -25543
- package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
- package/dist/registry-BIGVUrMB.mjs +0 -54
- package/dist/repl-editor-BCozyiNq.mjs +0 -251
- package/dist/schema--xYWRGfe.mjs +0 -639
- package/dist/schema--xYWRGfe.mjs.map +0 -1
- package/dist/secret-file-C3J4Gy8r.mjs +0 -64
- package/dist/secretmanager-CYlpffsz.mjs +0 -13
- package/dist/secretmanager-IY4UvinW.mjs +0 -131
- package/dist/seed-xqM9WIHP.mjs +0 -483
- package/dist/seed-xqM9WIHP.mjs.map +0 -1
- package/dist/service-C_WpbKHu.mjs +0 -898
- package/dist/service-C_WpbKHu.mjs.map +0 -1
- package/dist/service-D1RCdzIL.mjs +0 -3
- package/dist/service-hZskxZmg.mjs +0 -131
- package/dist/service_pb-BEWj1pOV.mjs +0 -167
- package/dist/service_pb-BjlhvK9E.mjs +0 -3
- package/dist/telemetry-BRVdwh14.mjs +0 -84
- package/dist/telemetry-CkbkeJxl.mjs +0 -3
- package/dist/type-source-DH_LH20p.mjs +0 -13
- package/dist/type-source-DH_LH20p.mjs.map +0 -1
- package/dist/user-agent-Bgsszb5I.mjs +0 -28
- package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
- package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
- package/dist/wait-point-registry-TL99zotw.mjs +0 -47
- package/dist/workflow-Bamae_Yc.mjs +0 -34
- package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"./service_pb-DGKCLuAs.mjs";export{r as OperatorService,t as PingRequestSchema,n as PingResponseSchema,e as file_tailor_v1_service};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{SpanStatusCode as e,trace as t}from"@opentelemetry/api";function parseTelemetryConfig(){let e=process.env.OTEL_EXPORTER_OTLP_ENDPOINT??``;return{enabled:e.length>0,endpoint:e}}let n,r=!1,i;async function initTelemetry(){if(r||(r=!0,n=parseTelemetryConfig(),!n.enabled))return;let[{NodeTracerProvider:e,BatchSpanProcessor:t},{OTLPTraceExporter:a},{resourceFromAttributes:o},{ATTR_SERVICE_NAME:s,ATTR_SERVICE_VERSION:c},{readPackageJson:l}]=await Promise.all([import(`@opentelemetry/sdk-trace-node`),import(`@opentelemetry/exporter-trace-otlp-proto`),import(`@opentelemetry/resources`),import(`@opentelemetry/semantic-conventions`),import(`./package-json-CmqhDJ__.mjs`)]),u=(await l()).version??`unknown`;i=new e({resource:o({[s]:`tailor`,[c]:u}),spanProcessors:[new t(new a({url:`${n.endpoint}/v1/traces`}))]}),i.register()}async function shutdownTelemetry(){i&&await i.shutdown()}async function withSpan(n,r){return t.getTracer(`tailor`).startActiveSpan(n,async t=>{try{let n=await r(t);return t.setStatus({code:e.OK}),n}catch(n){throw t.setStatus({code:e.ERROR}),n instanceof Error&&t.recordException(n),n}finally{t.end()}})}export{shutdownTelemetry as n,withSpan as r,initTelemetry as t};
|
|
2
|
+
//# sourceMappingURL=telemetry-Bklv9kQY.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./telemetry-Bklv9kQY.mjs";export{t as initTelemetry,e as shutdownTelemetry};
|
|
@@ -0,0 +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"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
type AIGateway = {
|
|
3
3
|
/** AI Gateway name */
|
|
4
4
|
name: string;
|
|
5
|
-
/** Auth namespace used to resolve request tokens against the workspace's auth */
|
|
6
|
-
authNamespace
|
|
5
|
+
/** Auth namespace used to resolve request tokens against the workspace's auth. Defaults to the application's own auth service when omitted; omitting it without an Auth service configured is rejected. */
|
|
6
|
+
authNamespace?: string | undefined;
|
|
7
7
|
/** Allowed CORS origins for browser-based clients. Each entry is `*`, `http(s)://*`, `http(s)://*.example.com`, or `http(s)://app.example.com`, optionally with `:port`. Empty list disables cross-origin access. */
|
|
8
8
|
cors?: string[] | undefined;
|
|
9
9
|
};
|
|
@@ -138,7 +138,7 @@ type SCIMResource = {
|
|
|
138
138
|
name: string;
|
|
139
139
|
/** TailorDB namespace for the resource */
|
|
140
140
|
tailorDBNamespace: string;
|
|
141
|
-
/** TailorDB
|
|
141
|
+
/** TailorDB table name for the resource */
|
|
142
142
|
tailorDBType: string;
|
|
143
143
|
/** Core SCIM schema definition */
|
|
144
144
|
coreSchema: {
|
|
@@ -177,9 +177,9 @@ type SCIMConfig = {
|
|
|
177
177
|
resources: SCIMResource[];
|
|
178
178
|
};
|
|
179
179
|
type TenantProvider = {
|
|
180
|
-
/** TailorDB namespace for the tenant
|
|
180
|
+
/** TailorDB namespace for the tenant table */
|
|
181
181
|
namespace: string;
|
|
182
|
-
/** TailorDB
|
|
182
|
+
/** TailorDB table name for tenants */
|
|
183
183
|
type: string;
|
|
184
184
|
/** Field used as the tenant signature */
|
|
185
185
|
signatureField: string;
|
|
@@ -4,8 +4,8 @@ type TailorDBTrigger = {
|
|
|
4
4
|
kind: "tailordb";
|
|
5
5
|
/** TailorDB event types to trigger on */
|
|
6
6
|
events: ("tailordb.type_record.created" | "tailordb.type_record.updated" | "tailordb.type_record.deleted")[];
|
|
7
|
-
/** TailorDB
|
|
8
|
-
|
|
7
|
+
/** TailorDB table name to watch for events */
|
|
8
|
+
tableName: string;
|
|
9
9
|
/** Condition function to filter events */
|
|
10
10
|
condition?: Function | undefined;
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/types/tailordb.generated.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Configuration for GraphQL operations on a TailorDB
|
|
3
|
+
* Configuration for GraphQL operations on a TailorDB table.
|
|
4
4
|
* All operations are enabled by default (undefined or true = enabled, false = disabled).
|
|
5
5
|
*/
|
|
6
6
|
type GqlOperationsInput = "query" | {
|
|
@@ -41,7 +41,7 @@ type DBFieldMetadata = {
|
|
|
41
41
|
vector?: boolean | undefined;
|
|
42
42
|
/** Whether the field is a foreign key */
|
|
43
43
|
foreignKey?: boolean | undefined;
|
|
44
|
-
/** Target
|
|
44
|
+
/** Target table name for foreign key relations */
|
|
45
45
|
foreignKeyType?: string | undefined;
|
|
46
46
|
/** Target field name for foreign key relations */
|
|
47
47
|
foreignKeyField?: string | undefined;
|
|
@@ -69,20 +69,20 @@ type DBFieldMetadata = {
|
|
|
69
69
|
default?: unknown;
|
|
70
70
|
};
|
|
71
71
|
type TailorDBTypeParsedSettings = {
|
|
72
|
-
/** Custom plural form of the
|
|
72
|
+
/** Custom plural form of the table name for GraphQL */
|
|
73
73
|
pluralForm?: string | undefined;
|
|
74
|
-
/** Enable aggregation queries for this
|
|
74
|
+
/** Enable aggregation queries for this table */
|
|
75
75
|
aggregation?: boolean | undefined;
|
|
76
|
-
/** Enable bulk upsert mutation for this
|
|
76
|
+
/** Enable bulk upsert mutation for this table */
|
|
77
77
|
bulkUpsert?: boolean | undefined;
|
|
78
|
-
/** Configure GraphQL operations for this
|
|
78
|
+
/** Configure GraphQL operations for this table. Use "query" for read-only mode, or an object for granular control. */
|
|
79
79
|
gqlOperations?: GqlOperations;
|
|
80
80
|
/**
|
|
81
|
-
* Enable publishing events for this
|
|
81
|
+
* Enable publishing events for this table.
|
|
82
82
|
* When enabled, record creation/update/deletion events are published.
|
|
83
|
-
* If not specified, this is automatically set to true when an executor uses this
|
|
83
|
+
* If not specified, this is automatically set to true when an executor uses this table
|
|
84
84
|
* with recordCreated/recordUpdated/recordDeleted triggers. If explicitly set to false
|
|
85
|
-
* while an executor uses this
|
|
85
|
+
* while an executor uses this table, an error will be thrown during apply.
|
|
86
86
|
*/
|
|
87
87
|
publishEvents?: boolean | undefined;
|
|
88
88
|
};
|
|
@@ -441,9 +441,9 @@ type RawPermissions = {
|
|
|
441
441
|
}[] | undefined;
|
|
442
442
|
};
|
|
443
443
|
type TailorDBServiceConfigInput = {
|
|
444
|
-
/** Glob patterns for TailorDB
|
|
444
|
+
/** Glob patterns for TailorDB table definition files */
|
|
445
445
|
files: string[];
|
|
446
|
-
/** Glob patterns to exclude from
|
|
446
|
+
/** Glob patterns to exclude from table discovery */
|
|
447
447
|
ignores?: string[] | undefined;
|
|
448
448
|
/** Migration configuration */
|
|
449
449
|
migration?: {
|
|
@@ -452,7 +452,7 @@ type TailorDBServiceConfigInput = {
|
|
|
452
452
|
/** Machine user name for migration execution */
|
|
453
453
|
machineUser?: string | undefined;
|
|
454
454
|
} | undefined;
|
|
455
|
-
/** Default GraphQL operations for all
|
|
455
|
+
/** Default GraphQL operations for all tables in this service */
|
|
456
456
|
gqlOperations?: "query" | {
|
|
457
457
|
/** Enable create mutation (default: true) */
|
|
458
458
|
create?: boolean | undefined;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./package-json-C690ceex.mjs";function userAgentFromVersion(e){return`tailor/${e}`}async function userAgent(){return userAgentFromVersion((await e()).version??`unknown`)}export{userAgentFromVersion as n,userAgent as t};
|
|
2
|
+
//# sourceMappingURL=user-agent-vdHYF3QL.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-agent-
|
|
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"}
|
|
@@ -4,7 +4,7 @@ import { output } from "../../configure/index.mjs";
|
|
|
4
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
//#region src/utils/test/index.d.ts
|
|
6
6
|
/**
|
|
7
|
-
* Creates a hook function that processes TailorDB
|
|
7
|
+
* Creates a hook function that processes TailorDB table fields
|
|
8
8
|
* - Uses existing id from data if provided, otherwise generates UUID for id fields
|
|
9
9
|
* - Recursively processes nested types
|
|
10
10
|
* - Executes hooks.create for fields with create hooks
|
|
@@ -12,19 +12,19 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
12
12
|
* member of `Object` such as `toString` is read from the record rather than
|
|
13
13
|
* from the prototype
|
|
14
14
|
* @template T - The output type of the hook function
|
|
15
|
-
* @param type - TailorDB
|
|
15
|
+
* @param type - TailorDB table definition
|
|
16
16
|
* @returns A function that transforms input data according to field hooks
|
|
17
17
|
*/
|
|
18
18
|
declare function createTailorDBHook<T extends TailorDBType<any, any>>(type: T): (data: unknown, now?: Date) => Partial<output<T>>;
|
|
19
19
|
/**
|
|
20
20
|
* Creates the standard schema definition used to validate seed rows.
|
|
21
|
-
* Runs the hook, then the
|
|
21
|
+
* Runs the hook, then the table's own `validate`, and the field schema only when
|
|
22
22
|
* that reported nothing, so both levels of validation report as issues rather
|
|
23
23
|
* than by throwing.
|
|
24
24
|
* @template T - The output type after validation
|
|
25
25
|
* @param schemaType - TailorDB field schema for validation
|
|
26
26
|
* @param hook - Hook function to transform data before validation
|
|
27
|
-
* @param type - TailorDB
|
|
27
|
+
* @param type - TailorDB table definition, when it carries a table-level `validate`
|
|
28
28
|
* @returns Schema object with ~standard section for defineSchema
|
|
29
29
|
*/
|
|
30
30
|
declare function createStandardSchema<T = Record<string, unknown>>(schemaType: TailorField<any, T>, hook: (data: unknown) => Partial<T>, type?: TailorDBType<any, any>): {
|
|
@@ -1,110 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function setField(record, key, value) {
|
|
3
|
-
Object.defineProperty(record, key, {
|
|
4
|
-
value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
writable: true,
|
|
7
|
-
configurable: true
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Creates a hook function that processes TailorDB type fields
|
|
12
|
-
* - Uses existing id from data if provided, otherwise generates UUID for id fields
|
|
13
|
-
* - Recursively processes nested types
|
|
14
|
-
* - Executes hooks.create for fields with create hooks
|
|
15
|
-
* - Takes each field from the data's own properties, so a field named after a
|
|
16
|
-
* member of `Object` such as `toString` is read from the record rather than
|
|
17
|
-
* from the prototype
|
|
18
|
-
* @template T - The output type of the hook function
|
|
19
|
-
* @param type - TailorDB type definition
|
|
20
|
-
* @returns A function that transforms input data according to field hooks
|
|
21
|
-
*/
|
|
22
|
-
function createTailorDBHook(type) {
|
|
23
|
-
return (data, now = /* @__PURE__ */ new Date()) => {
|
|
24
|
-
const obj = data && typeof data === "object" ? data : void 0;
|
|
25
|
-
const hooked = Object.entries(type.fields).reduce((hooked, [key, value]) => {
|
|
26
|
-
const field = value;
|
|
27
|
-
const input = obj && Object.hasOwn(obj, key) ? obj[key] : void 0;
|
|
28
|
-
let hookedValue;
|
|
29
|
-
if (key === "id") hookedValue = input ?? crypto.randomUUID();
|
|
30
|
-
else if (field.type === "nested") {
|
|
31
|
-
const nestedHook = createTailorDBHook({ fields: field.fields });
|
|
32
|
-
if (field.metadata.array) hookedValue = Array.isArray(input) ? input.map((item) => nestedHook(item, now)) : input;
|
|
33
|
-
else hookedValue = nestedHook(input, now);
|
|
34
|
-
} else if (field.metadata.hooks?.create) {
|
|
35
|
-
hookedValue = field.metadata.hooks.create({
|
|
36
|
-
input,
|
|
37
|
-
invoker: null,
|
|
38
|
-
now
|
|
39
|
-
});
|
|
40
|
-
if (hookedValue instanceof Date) hookedValue = hookedValue.toISOString();
|
|
41
|
-
} else hookedValue = input;
|
|
42
|
-
if (hookedValue == null && field.metadata.default !== void 0) {
|
|
43
|
-
const isTimeType = field.type === "datetime" || field.type === "date" || field.type === "time";
|
|
44
|
-
hookedValue = field.metadata.default === "now" && isTimeType ? now.toISOString() : field.metadata.default;
|
|
45
|
-
}
|
|
46
|
-
setField(hooked, key, hookedValue);
|
|
47
|
-
return hooked;
|
|
48
|
-
}, {});
|
|
49
|
-
if (type.metadata?.typeHook?.create) {
|
|
50
|
-
const { id: _id, ...typeHookInput } = hooked;
|
|
51
|
-
const overrides = type.metadata.typeHook.create({
|
|
52
|
-
input: typeHookInput,
|
|
53
|
-
invoker: null,
|
|
54
|
-
now
|
|
55
|
-
});
|
|
56
|
-
if (overrides && typeof overrides === "object") for (const [key, value] of Object.entries(overrides)) setField(hooked, key, value instanceof Date ? value.toISOString() : value);
|
|
57
|
-
}
|
|
58
|
-
return hooked;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function typeLevelIssues(type, hooked) {
|
|
62
|
-
const typeValidate = type?.metadata?.typeValidate;
|
|
63
|
-
if (!typeValidate) return [];
|
|
64
|
-
const { id: _id, ...newRecord } = hooked;
|
|
65
|
-
const issues = [];
|
|
66
|
-
typeValidate({
|
|
67
|
-
newRecord,
|
|
68
|
-
oldRecord: null,
|
|
69
|
-
invoker: null
|
|
70
|
-
}, (field, message) => {
|
|
71
|
-
issues.push({
|
|
72
|
-
message,
|
|
73
|
-
path: [field]
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
return issues;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Creates the standard schema definition used to validate seed rows.
|
|
80
|
-
* Runs the hook, then the type's own `validate`, and the field schema only when
|
|
81
|
-
* that reported nothing, so both levels of validation report as issues rather
|
|
82
|
-
* than by throwing.
|
|
83
|
-
* @template T - The output type after validation
|
|
84
|
-
* @param schemaType - TailorDB field schema for validation
|
|
85
|
-
* @param hook - Hook function to transform data before validation
|
|
86
|
-
* @param type - TailorDB type definition, when it carries a type-level `validate`
|
|
87
|
-
* @returns Schema object with ~standard section for defineSchema
|
|
88
|
-
*/
|
|
89
|
-
function createStandardSchema(schemaType, hook, type) {
|
|
90
|
-
return { "~standard": {
|
|
91
|
-
version: 1,
|
|
92
|
-
vendor: "@tailor-platform/sdk",
|
|
93
|
-
validate: (value) => {
|
|
94
|
-
const hooked = hook(value);
|
|
95
|
-
const issues = typeLevelIssues(type, hooked);
|
|
96
|
-
if (issues.length > 0) return { issues };
|
|
97
|
-
const result = schemaType.parse({
|
|
98
|
-
value: hooked,
|
|
99
|
-
data: hooked,
|
|
100
|
-
invoker: null
|
|
101
|
-
});
|
|
102
|
-
if (result.issues) return result;
|
|
103
|
-
return { value: hooked };
|
|
104
|
-
}
|
|
105
|
-
} };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
//#endregion
|
|
109
|
-
export { createStandardSchema, createTailorDBHook };
|
|
1
|
+
function setField(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function createTailorDBHook(e){return(t,n=new Date)=>{let r=t&&typeof t==`object`?t:void 0,i=Object.entries(e.fields).reduce((e,[t,i])=>{let a=i,o=r&&Object.hasOwn(r,t)?r[t]:void 0,s;if(t===`id`)s=o??crypto.randomUUID();else if(a.type===`nested`){let e=createTailorDBHook({fields:a.fields});s=a.metadata.array?Array.isArray(o)?o.map(t=>e(t,n)):o:e(o,n)}else a.metadata.hooks?.create?(s=a.metadata.hooks.create({input:o,invoker:null,now:n}),s instanceof Date&&(s=s.toISOString())):s=o;if(s==null&&a.metadata.default!==void 0){let e=a.type===`datetime`||a.type===`date`||a.type===`time`;s=a.metadata.default===`now`&&e?n.toISOString():a.metadata.default}return setField(e,t,s),e},{});if(e.metadata?.typeHook?.create){let{id:t,...r}=i,a=e.metadata.typeHook.create({input:r,invoker:null,now:n});if(a&&typeof a==`object`)for(let[e,t]of Object.entries(a))setField(i,e,t instanceof Date?t.toISOString():t)}return i}}function typeLevelIssues(e,t){let n=e?.metadata?.typeValidate;if(!n)return[];let{id:r,...i}=t,a=[];return n({newRecord:i,oldRecord:null,invoker:null},(e,t)=>{a.push({message:t,path:[e]})}),a}function createStandardSchema(e,t,n){return{"~standard":{version:1,vendor:`@tailor-platform/sdk`,validate:r=>{let i=t(r),a=typeLevelIssues(n,i);if(a.length>0)return{issues:a};let o=e.parse({value:i,data:i,invoker:null});return o.issues?o:{value:i}}}}}export{createStandardSchema,createTailorDBHook};
|
|
110
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import 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
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/index.ts"],"sourcesContent":["import 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) ? input.map((item) => nestedHook(item, now)) : input;\n } else {\n hookedValue = nestedHook(input, now);\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/**\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.\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, when it carries a table-level `validate`\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 return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\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 } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":"AAQA,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,EAAY,IAAI,OAAW,CAChD,IAAM,EAAM,GAAQ,OAAO,GAAS,SAAY,EAAmC,IAAA,GAC7E,EAAS,OAAO,QAAQ,EAAK,MAAM,CAAC,CAAC,QACxC,EAAQ,CAAC,EAAK,KAAW,CAExB,IAAM,EAAQ,EAGR,EAAQ,GAAO,OAAO,OAAO,EAAK,CAAG,EAAI,EAAI,GAAO,IAAA,GACtD,EACJ,GAAI,IAAQ,KACV,EAAc,GAAS,OAAO,WAAW,OACpC,GAAI,EAAM,OAAS,SAAU,CAElC,IAAM,EAAa,mBAAmB,CAAE,OAAQ,EAAM,MAAO,CAAQ,EACrE,AAGE,EAHE,EAAM,SAAS,MACH,MAAM,QAAQ,CAAK,EAAI,EAAM,IAAK,GAAS,EAAW,EAAM,CAAG,CAAC,EAAI,EAEpE,EAAW,EAAO,CAAG,CAEvC,MAAW,EAAM,SAAS,OAAO,QAC/B,EAAc,EAAM,SAAS,MAAM,OAAO,CAAE,QAAO,QAAS,KAAM,KAAI,CAAC,EACnE,aAAuB,OACzB,EAAc,EAAY,YAAY,IAGxC,EAAc,EAEhB,GAAI,GAAe,MAAQ,EAAM,SAAS,UAAY,IAAA,GAAW,CAC/D,IAAM,EACJ,EAAM,OAAS,YAAc,EAAM,OAAS,QAAU,EAAM,OAAS,OACvE,EACE,EAAM,SAAS,UAAY,OAAS,EAChC,EAAI,YAAY,EAChB,EAAM,SAAS,OACvB,CAKA,OADA,SAAS,EAAQ,EAAK,CAAW,EAC1B,CACT,EACA,CAAC,CACH,EAGA,GAAI,EAAK,UAAU,UAAU,OAAQ,CACnC,GAAM,CAAE,GAAI,EAAK,GAAG,GAAkB,EAEhC,EAAY,EAAK,SAAS,SAAS,OAAO,CAC9C,MAAO,EACP,QAAS,KACT,KACF,CAAC,EACD,GAAI,GAAa,OAAO,GAAc,SACpC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAoC,EAC5E,SAAS,EAAQ,EAAK,aAAiB,KAAO,EAAM,YAAY,EAAI,CAAK,CAG/E,CAEA,OAAO,CACT,CACF,CAKA,SAAS,gBAAgB,EAA0C,EAAiB,CAElF,IAAM,EAAe,GAAM,UAAU,aACrC,GAAI,CAAC,EACH,MAAO,CAAC,EAEV,GAAM,CAAE,GAAI,EAAK,GAAG,GAAc,EAC5B,EAAmC,CAAC,EAK1C,OAHA,EAAa,CAAE,YAAW,UAAW,KAAM,QAAS,IAAK,GAAI,EAAe,IAAoB,CAC9F,EAAO,KAAK,CAAE,UAAS,KAAM,CAAC,CAAK,CAAE,CAAC,CACxC,CAAC,EACM,CACT,CAaA,SAAgB,qBAEd,EACA,EAEA,EACA,CACA,MAAO,CACL,YAAa,CACX,QAAS,EACT,OAAQ,uBACR,SAAW,GAAmB,CAC5B,IAAM,EAAS,EAAK,CAAK,EACnB,EAAS,gBAAgB,EAAM,CAAM,EAC3C,GAAI,EAAO,OAAS,EAClB,MAAO,CAAE,QAAO,EAElB,IAAM,EAAS,EAAW,MAAM,CAC9B,MAAO,EACP,KAAM,EACN,QAAS,IACX,CAAC,EAID,OAHI,EAAO,OACF,EAEF,CAAE,MAAO,CAAY,CAC9B,CACF,CACF,CACF"}
|
|
@@ -1,42 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as globals from "globals";
|
|
3
|
-
|
|
4
|
-
//#region src/vitest/environment.ts
|
|
5
|
-
const globalsMap = globals.default ?? globals;
|
|
6
|
-
const ALLOWED_GLOBALS = /* @__PURE__ */ new Set([
|
|
7
|
-
...Object.keys(globalsMap.builtin ?? {}),
|
|
8
|
-
...Object.keys(globalsMap["shared-node-browser"] ?? {}),
|
|
9
|
-
RUNTIME_FLAG_KEY,
|
|
10
|
-
"process",
|
|
11
|
-
"require",
|
|
12
|
-
"module",
|
|
13
|
-
"exports",
|
|
14
|
-
"__vitest_worker__",
|
|
15
|
-
"__vitest_mocker__",
|
|
16
|
-
"VITEST_POOL_ID"
|
|
17
|
-
]);
|
|
18
|
-
var environment_default = {
|
|
19
|
-
name: "tailor-runtime",
|
|
20
|
-
viteEnvironment: "ssr",
|
|
21
|
-
async setup(global) {
|
|
22
|
-
const g = global;
|
|
23
|
-
const saved = {};
|
|
24
|
-
for (const key of Object.getOwnPropertyNames(g)) if (!ALLOWED_GLOBALS.has(key)) {
|
|
25
|
-
const descriptor = Object.getOwnPropertyDescriptor(g, key);
|
|
26
|
-
if (descriptor?.configurable) {
|
|
27
|
-
saved[key] = descriptor;
|
|
28
|
-
delete g[key];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
installPlatformGlobals(global);
|
|
32
|
-
return { teardown(global) {
|
|
33
|
-
cleanupPlatformGlobals(global);
|
|
34
|
-
const g = global;
|
|
35
|
-
for (const [key, descriptor] of Object.entries(saved)) Object.defineProperty(g, key, descriptor);
|
|
36
|
-
} };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { environment_default as default };
|
|
1
|
+
import{n as e,r as t,t as n}from"../globals-CMHSnj4w.mjs";import*as r from"globals";const i=r.default??r,a=new Set([...Object.keys(i.builtin??{}),...Object.keys(i[`shared-node-browser`]??{}),n,`process`,`require`,`module`,`exports`,`__vitest_worker__`,`__vitest_mocker__`,`VITEST_POOL_ID`]);var o={name:`tailor-runtime`,viteEnvironment:`ssr`,async setup(n){let r=n,i={};for(let e of Object.getOwnPropertyNames(r))if(!a.has(e)){let t=Object.getOwnPropertyDescriptor(r,e);t?.configurable&&(i[e]=t,delete r[e])}return t(n),{teardown(t){e(t);let n=t;for(let[e,t]of Object.entries(i))Object.defineProperty(n,e,t)}}}};export{o as default};
|
|
42
2
|
//# sourceMappingURL=environment.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.mjs","names":[],"sources":["../../src/vitest/environment.ts"],"sourcesContent":["import * as globals from \"globals\";\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// Normalize the `globals` module shape across CJS/ESM interop so the\n// whitelist build doesn't crash if the default export is unavailable or\n// the keyed sets are missing. Mirrors src/cli/services/tailordb/es-builtins.ts.\ntype GlobalsShape = {\n builtin?: Record<string, boolean>;\n \"shared-node-browser\"?: Record<string, boolean>;\n};\nconst globalsMap: GlobalsShape =\n (globals as unknown as { default?: GlobalsShape }).default
|
|
1
|
+
{"version":3,"file":"environment.mjs","names":[],"sources":["../../src/vitest/environment.ts"],"sourcesContent":["import * as globals from \"globals\";\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// Normalize the `globals` module shape across CJS/ESM interop so the\n// whitelist build doesn't crash if the default export is unavailable or\n// the keyed sets are missing. Mirrors src/cli/services/tailordb/es-builtins.ts.\ntype GlobalsShape = {\n builtin?: Record<string, boolean>;\n \"shared-node-browser\"?: Record<string, boolean>;\n};\nconst globalsMap: GlobalsShape =\n (globals as unknown as { default?: GlobalsShape }).default ?? globals;\n\n// Globals allowed in the Tailor Platform runtime.\n// Mirrors ES_BUILTINS in src/cli/services/tailordb/es-builtins.ts so the\n// emulated runtime exposes exactly the same identifiers as the production\n// platform's free-variable allowlist (ECMAScript builtins + shared\n// Node/browser runtime globals like 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 ...Object.keys(globalsMap.builtin ?? {}),\n ...Object.keys(globalsMap[\"shared-node-browser\"] ?? {}),\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 // 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\n return {\n teardown(global: typeof globalThis) {\n cleanupPlatformGlobals(global);\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":"oFAaA,MAAM,EACH,EAAkD,SAAW,EAU1D,EAAkB,IAAI,IAAI,CAC9B,GAAG,OAAO,KAAK,EAAW,SAAW,CAAC,CAAC,EACvC,GAAG,OAAO,KAAK,EAAW,wBAA0B,CAAC,CAAC,EAItD,EAGA,UACA,UACA,SACA,UACA,oBACA,oBACA,gBACF,CAAC,EAED,IAAA,EAAe,CACb,KAAM,iBACN,gBAAiB,MAEjB,MAAM,MAAM,EAA2B,CACrC,IAAM,EAAI,EAGJ,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,CAOF,OAFA,EAAuB,CAAM,EAEtB,CACL,SAAS,EAA2B,CAClC,EAAuB,CAAM,EAG7B,IAAM,EAAI,EACV,IAAK,GAAM,CAAC,EAAK,KAAe,OAAO,QAAQ,CAAK,EAClD,OAAO,eAAe,EAAG,EAAK,CAAU,CAE5C,CACF,CACF,CACF"}
|