@tailor-platform/sdk 2.0.0-next.2 → 2.0.0-next.4
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 +511 -10
- package/README.md +9 -9
- package/agent-skills/{tailor-sdk → tailor}/SKILL.md +3 -1
- package/dist/aigateway-DR4Kwuik.mjs +9 -0
- package/dist/aigateway-DR4Kwuik.mjs.map +1 -0
- package/dist/application-BO4ZF8wP.mjs +3 -0
- package/dist/application-BX13RArL.mjs +6669 -0
- package/dist/application-BX13RArL.mjs.map +1 -0
- package/dist/authconnection-CZvi9ANm.mjs +9 -0
- package/dist/authconnection-CZvi9ANm.mjs.map +1 -0
- package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
- package/dist/cli/cache/bundle-cache.d.mts +1 -0
- package/dist/cli/cache/store.d.mts +1 -0
- package/dist/cli/cache/types.d.mts +1 -0
- package/dist/cli/commands/api/api-call.d.mts +19 -0
- package/dist/cli/commands/api/index.d.mts +3 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +1 -0
- package/dist/cli/commands/deploy/application.d.mts +1 -0
- package/dist/cli/commands/deploy/apply-phases.d.mts +1 -0
- package/dist/cli/commands/deploy/auth.d.mts +1 -0
- package/dist/cli/commands/deploy/deploy.d.mts +24 -0
- package/dist/cli/commands/deploy/executor.d.mts +1 -0
- package/dist/cli/commands/deploy/function-registry-types.d.mts +12 -0
- package/dist/cli/commands/deploy/function-registry.d.mts +2 -0
- package/dist/cli/commands/deploy/idp.d.mts +1 -0
- package/dist/cli/commands/deploy/resolver.d.mts +1 -0
- package/dist/cli/commands/deploy/secret-manager.d.mts +1 -0
- package/dist/cli/commands/deploy/staticwebsite.d.mts +1 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +1 -0
- package/dist/cli/commands/deploy/types.d.mts +1 -0
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -0
- package/dist/cli/commands/deploy/workflow.d.mts +1 -0
- package/dist/cli/commands/executor/get.d.mts +29 -0
- package/dist/cli/commands/executor/jobs.d.mts +123 -0
- package/dist/cli/commands/executor/list.d.mts +19 -0
- package/dist/cli/commands/executor/transform.d.mts +41 -0
- package/dist/cli/commands/executor/trigger.d.mts +41 -0
- package/dist/cli/commands/executor/webhook.d.mts +22 -0
- package/dist/cli/commands/function/get.d.mts +18 -0
- package/dist/cli/commands/function/list.d.mts +22 -0
- package/dist/cli/commands/function/transform.d.mts +11 -0
- package/dist/cli/commands/generate/options.d.mts +7 -0
- package/dist/cli/commands/generate/seed/bundler.d.mts +26 -0
- package/dist/cli/commands/generate/service.d.mts +11 -0
- package/dist/cli/commands/machineuser/list.d.mts +27 -0
- package/dist/cli/commands/machineuser/token.d.mts +22 -0
- package/dist/cli/commands/oauth2client/get.d.mts +18 -0
- package/dist/cli/commands/oauth2client/list.d.mts +20 -0
- package/dist/cli/commands/oauth2client/transform.d.mts +20 -0
- package/dist/cli/commands/organization/folder/create.d.mts +18 -0
- package/dist/cli/commands/organization/folder/delete.d.mts +16 -0
- package/dist/cli/commands/organization/folder/get.d.mts +17 -0
- package/dist/cli/commands/organization/folder/list.d.mts +22 -0
- package/dist/cli/commands/organization/folder/update.d.mts +18 -0
- package/dist/cli/commands/organization/get.d.mts +16 -0
- package/dist/cli/commands/organization/list.d.mts +15 -0
- package/dist/cli/commands/organization/transform.d.mts +27 -0
- package/dist/cli/commands/organization/tree.d.mts +25 -0
- package/dist/cli/commands/organization/update.d.mts +17 -0
- package/dist/cli/commands/remove.d.mts +16 -0
- package/dist/cli/commands/show.d.mts +34 -0
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +28 -0
- package/dist/cli/commands/tailordb/migrate/config.d.mts +19 -0
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +223 -0
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +17 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +202 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +98 -0
- package/dist/cli/commands/tailordb/migrate/types.d.mts +7 -0
- package/dist/cli/commands/tailordb/truncate.d.mts +19 -0
- package/dist/cli/commands/workflow/executions.d.mts +75 -0
- package/dist/cli/commands/workflow/get.d.mts +29 -0
- package/dist/cli/commands/workflow/list.d.mts +19 -0
- package/dist/cli/commands/workflow/resume.d.mts +23 -0
- package/dist/cli/commands/workflow/start.d.mts +61 -0
- package/dist/cli/commands/workflow/status.d.mts +5 -0
- package/dist/cli/commands/workflow/transform.d.mts +33 -0
- package/dist/cli/commands/workflow/wait.d.mts +16 -0
- package/dist/cli/commands/workflow/waiter.d.mts +23 -0
- package/dist/cli/commands/workspace/app/health.d.mts +18 -0
- package/dist/cli/commands/workspace/app/list.d.mts +22 -0
- package/dist/cli/commands/workspace/app/transform.d.mts +18 -0
- package/dist/cli/commands/workspace/create.d.mts +25 -0
- package/dist/cli/commands/workspace/delete.d.mts +15 -0
- package/dist/cli/commands/workspace/get.d.mts +17 -0
- package/dist/cli/commands/workspace/list.d.mts +17 -0
- package/dist/cli/commands/workspace/restore.d.mts +15 -0
- package/dist/cli/commands/workspace/transform.d.mts +16 -0
- package/dist/cli/commands/workspace/user/invite.d.mts +22 -0
- package/dist/cli/commands/workspace/user/list.d.mts +22 -0
- package/dist/cli/commands/workspace/user/remove.d.mts +17 -0
- package/dist/cli/commands/workspace/user/transform.d.mts +8 -0
- package/dist/cli/commands/workspace/user/update.d.mts +22 -0
- package/dist/cli/erd-viewer-assets/app.js +279 -36
- package/dist/cli/erd-viewer-assets/index.html +4 -0
- package/dist/cli/erd-viewer-assets/styles.css +252 -5
- package/dist/cli/index.d.mts +18 -3
- package/dist/cli/index.mjs +2237 -520
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +81 -21107
- package/dist/cli/lib.mjs +7 -10
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/query/index.d.mts +39 -0
- package/dist/cli/services/application.d.mts +1 -0
- package/dist/cli/services/auth/service.d.mts +1 -0
- package/dist/cli/services/executor/service.d.mts +1 -0
- package/dist/cli/services/http-adapter/bundler.d.mts +1 -0
- package/dist/cli/services/http-adapter/service.d.mts +1 -0
- package/dist/cli/services/resolver/service.d.mts +1 -0
- package/dist/cli/services/tailordb/service.d.mts +1 -0
- package/dist/cli/services/workflow/bundler.d.mts +1 -0
- package/dist/cli/services/workflow/service.d.mts +1 -0
- package/dist/cli/shared/args.d.mts +13 -0
- package/dist/cli/shared/client.d.mts +1273 -0
- package/dist/cli/shared/config-loader.d.mts +26 -0
- package/dist/cli/shared/context.d.mts +28 -0
- package/dist/cli/shared/script-executor.d.mts +75 -0
- package/dist/cli/shared/seed-chunker.d.mts +46 -0
- package/dist/cli/shared/trigger-context.d.mts +1 -0
- package/dist/cli/shared/type-generator.d.mts +20 -0
- package/dist/cli/ts-hook.d.mts +4 -0
- package/dist/cli/ts-hook.mjs +333 -0
- package/dist/completion/zsh-worker.zsh +1531 -1131
- package/dist/configure/config/index.d.mts +21 -0
- package/dist/configure/config/types.d.mts +105 -0
- package/dist/configure/index.d.mts +124 -9
- package/dist/configure/index.mjs +136 -23
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +17 -0
- package/dist/configure/services/aigateway/types.d.mts +11 -0
- package/dist/configure/services/auth/index.d.mts +34 -0
- package/dist/configure/services/auth/types.d.mts +172 -0
- package/dist/configure/services/executor/executor.d.mts +81 -0
- package/dist/configure/services/executor/index.d.mts +8 -0
- package/dist/configure/services/executor/operation.d.mts +45 -0
- package/dist/configure/services/executor/trigger/event.d.mts +272 -0
- package/dist/configure/services/executor/trigger/index.d.mts +8 -0
- package/dist/configure/services/executor/trigger/schedule.d.mts +25 -0
- package/dist/configure/services/executor/trigger/webhook.d.mts +44 -0
- package/dist/configure/services/executor/types.d.mts +2 -0
- package/dist/configure/services/http-adapter/http-adapter.d.mts +125 -0
- package/dist/configure/services/http-adapter/index.d.mts +2 -0
- package/dist/configure/services/idp/index.d.mts +64 -0
- package/dist/configure/services/idp/permission.d.mts +80 -0
- package/dist/configure/services/idp/types.d.mts +20 -0
- package/dist/configure/services/index.d.mts +34 -0
- package/dist/configure/services/resolver/index.d.mts +5 -0
- package/dist/configure/services/resolver/resolver.d.mts +75 -0
- package/dist/configure/services/resolver/types.d.mts +6 -0
- package/dist/configure/services/secrets/index.d.mts +38 -0
- package/dist/configure/services/secrets/types.d.mts +11 -0
- package/dist/configure/services/staticwebsite/index.d.mts +19 -0
- package/dist/configure/services/staticwebsite/types.d.mts +11 -0
- package/dist/configure/services/tailordb/index.d.mts +4 -0
- package/dist/configure/services/tailordb/permission.d.mts +119 -0
- package/dist/configure/services/tailordb/schema.d.mts +456 -0
- package/dist/configure/services/tailordb/types.d.mts +149 -0
- package/dist/configure/services/workflow/execution-policy.d.mts +71 -0
- package/dist/configure/services/workflow/execution-policy.types.d.mts +104 -0
- package/dist/configure/services/workflow/index.d.mts +8 -0
- package/dist/configure/services/workflow/job.d.mts +84 -0
- package/dist/configure/services/workflow/types.d.mts +2 -0
- package/dist/configure/services/workflow/wait-point.d.mts +73 -0
- package/dist/configure/services/workflow/workflow.d.mts +54 -0
- package/dist/configure/types/aigateway-name.d.mts +12 -0
- package/dist/configure/types/connection-name.d.mts +12 -0
- package/dist/configure/types/field-runtime.d.mts +17 -0
- package/dist/configure/types/field.d.mts +9 -0
- package/dist/configure/types/field.types.d.mts +109 -0
- package/dist/configure/types/idp-name.d.mts +12 -0
- package/dist/configure/types/index.d.mts +4 -0
- package/dist/configure/types/machine-user.d.mts +2 -0
- package/dist/configure/types/type.d.mts +82 -0
- package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
- package/dist/context-DYQVYWqZ.mjs.map +1 -0
- package/dist/{crashreport-DFq-vsU0.mjs → crashreport-Cg-pqRJV.mjs} +6 -6
- package/dist/{crashreport-DFq-vsU0.mjs.map → crashreport-Cg-pqRJV.mjs.map} +1 -1
- package/dist/{crashreport-BMWcxeSE.mjs → crashreport-D3RjuSYb.mjs} +1 -1
- package/dist/enum-constants-j9QBF0cB.mjs.map +1 -1
- package/dist/{errors-Dtf2WPaW.mjs → errors-118wUDRr.mjs} +2 -2
- package/dist/errors-118wUDRr.mjs.map +1 -0
- package/dist/field-runtime-CAnh_oow.mjs +183 -0
- package/dist/field-runtime-CAnh_oow.mjs.map +1 -0
- package/dist/{file-BbdFGdMV.mjs → file-BUcmVIH2.mjs} +12 -14
- package/dist/file-BUcmVIH2.mjs.map +1 -0
- package/dist/{file-utils-CYZnO1pX.mjs → file-utils-yEiIS4nJ.mjs} +2 -2
- package/dist/file-utils-yEiIS4nJ.mjs.map +1 -0
- package/dist/{globals-Cf0sxIt8.mjs → globals-BjhJJ2dN.mjs} +5 -47
- package/dist/globals-BjhJJ2dN.mjs.map +1 -0
- package/dist/iconv-QWaZh0TT.mjs +38 -0
- package/dist/iconv-QWaZh0TT.mjs.map +1 -0
- package/dist/{idp-BDbK5gjm.mjs → idp-RA_swu-h.mjs} +12 -5
- package/dist/idp-RA_swu-h.mjs.map +1 -0
- package/dist/{interceptor-D-q1rvRl.mjs → interceptor-e33JtsC-.mjs} +2 -2
- package/dist/interceptor-e33JtsC-.mjs.map +1 -0
- package/dist/kysely/index.d.mts +2 -3
- package/dist/{kysely-type-DR8uzZTA.mjs → kysely-type-D-zflMGf.mjs} +2 -2
- package/dist/{kysely-type-DR8uzZTA.mjs.map → kysely-type-D-zflMGf.mjs.map} +1 -1
- package/dist/{logger-CxF-Ex5d.mjs → logger-BEiZZ3qT.mjs} +3 -3
- package/dist/{logger-CxF-Ex5d.mjs.map → logger-BEiZZ3qT.mjs.map} +1 -1
- package/dist/parser/service/auth/index.d.mts +1 -0
- package/dist/parser/service/auth/schema.d.mts +1 -0
- package/dist/parser/service/http-adapter/index.d.mts +1 -0
- package/dist/parser/service/http-adapter/schema.d.mts +1 -0
- package/dist/parser/service/idp/types.d.mts +4 -0
- package/dist/parser/service/tailordb/types.d.mts +126 -0
- package/dist/platform-serialize-RoRtBS0v.mjs +46 -0
- package/dist/platform-serialize-RoRtBS0v.mjs.map +1 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +16 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +16 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +16 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +45 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/get-generated-type.d.mts +17 -0
- package/dist/plugin/index.d.mts +3 -118
- package/dist/plugin/index.mjs +1 -1
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/manager.d.mts +1 -0
- package/dist/plugin/types.d.mts +243 -0
- package/dist/plugin/with-context.d.mts +102 -0
- package/dist/{runtime-CY4JvrDj.mjs → register-ts-hook-BM1caLT0.mjs} +4128 -2744
- package/dist/register-ts-hook-BM1caLT0.mjs.map +1 -0
- package/dist/{registry-DH4m7eYo.mjs → registry-BSbq6SPo.mjs} +4 -3
- package/dist/registry-BSbq6SPo.mjs.map +1 -0
- package/dist/{repl-editor-DmGr9zMw.mjs → repl-editor-BCozyiNq.mjs} +6 -5
- package/dist/{repl-editor-DmGr9zMw.mjs.map → repl-editor-BCozyiNq.mjs.map} +1 -1
- package/dist/resource_pb-BRv7AMXK.mjs +49 -0
- package/dist/resource_pb-BRv7AMXK.mjs.map +1 -0
- package/dist/runtime/aigateway.d.mts +26 -0
- package/dist/runtime/aigateway.mjs +3 -0
- package/dist/runtime/authconnection.d.mts +22 -2
- package/dist/runtime/authconnection.mjs +2 -2
- package/dist/runtime/context.d.mts +55 -2
- package/dist/runtime/context.mjs +2 -2
- package/dist/runtime/file.d.mts +170 -2
- package/dist/runtime/file.mjs +2 -2
- package/dist/runtime/globals.d.mts +31 -19
- package/dist/runtime/iconv.d.mts +73 -2
- package/dist/runtime/iconv.mjs +2 -2
- package/dist/runtime/idp.d.mts +129 -2
- package/dist/runtime/idp.mjs +2 -2
- package/dist/runtime/index.d.mts +47 -9
- package/dist/runtime/index.mjs +9 -8
- package/dist/runtime/secretmanager.d.mts +41 -2
- package/dist/runtime/secretmanager.mjs +2 -2
- package/dist/{types-BZ7QKVE8.d.mts → runtime/types.d.mts} +4 -5
- package/dist/runtime/workflow.d.mts +113 -2
- package/dist/runtime/workflow.mjs +2 -2
- package/dist/{schema-Dtw9Orye.mjs → schema-C4LYbXVG.mjs} +21 -186
- package/dist/schema-C4LYbXVG.mjs.map +1 -0
- package/dist/{secret-file-VSVGy1V0.mjs → secret-file-aoNXJmKa.mjs} +3 -3
- package/dist/secret-file-aoNXJmKa.mjs.map +1 -0
- package/dist/secretmanager-Bd45j7an.mjs +98 -0
- package/dist/secretmanager-Bd45j7an.mjs.map +1 -0
- package/dist/secretmanager-CYlpffsz.mjs +13 -0
- package/dist/secretmanager-CYlpffsz.mjs.map +1 -0
- package/dist/seed/index.d.mts +1 -2
- package/dist/{seed-izIEyP3z.mjs → seed-CRSQJI_z.mjs} +14 -3
- package/dist/seed-CRSQJI_z.mjs.map +1 -0
- package/dist/service-CkIwEctX.mjs +3 -0
- package/dist/{service-DU1mVzri2.mjs → service-DeZeYa06.mjs} +3 -3
- package/dist/service-DeZeYa06.mjs.map +1 -0
- package/dist/{service-DjyqbCaJ.mjs → service-ufH7sS8o.mjs} +396 -58
- package/dist/service-ufH7sS8o.mjs.map +1 -0
- package/dist/service_pb-B2FF59sP.mjs +3 -0
- package/dist/service_pb-B5w9rjPY.mjs +955 -0
- package/dist/service_pb-B5w9rjPY.mjs.map +1 -0
- package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +204 -0
- package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +58 -0
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +316 -0
- package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +161 -0
- package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +2070 -0
- package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +861 -0
- package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +112 -0
- package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +69 -0
- package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +439 -0
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +564 -0
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +145 -0
- package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +451 -0
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +192 -0
- package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +50 -0
- package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +407 -0
- package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +430 -0
- package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +73 -0
- package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +17 -0
- package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +309 -0
- package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +591 -0
- package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +330 -0
- package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +113 -0
- package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +346 -0
- package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +54 -0
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +3576 -0
- package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +187 -0
- package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +29 -0
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +429 -0
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +90 -0
- package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +684 -0
- package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +797 -0
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +330 -0
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +183 -0
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +862 -0
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +310 -0
- package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +2015 -0
- package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +483 -0
- package/dist/{telemetry-CdqJEzkj.mjs → telemetry-BRVdwh14.mjs} +3 -3
- package/dist/telemetry-BRVdwh14.mjs.map +1 -0
- package/dist/telemetry-CkbkeJxl.mjs +3 -0
- package/dist/types/aigateway.generated.d.mts +9 -0
- package/dist/types/app-config.generated.d.mts +4 -0
- package/dist/types/auth-connection.generated.d.mts +20 -0
- package/dist/types/auth.generated.d.mts +145 -0
- package/dist/types/executor.generated.d.mts +177 -0
- package/dist/types/helpers.d.mts +39 -0
- package/dist/types/http-adapter.generated.d.mts +17 -0
- package/dist/{workflow.generated-ClEjBYhm.d.mts → types/idp.generated.d.mts} +98 -185
- package/dist/types/resolver.generated.d.mts +39 -0
- package/dist/types/secrets.generated.d.mts +14 -0
- package/dist/types/staticwebsite.generated.d.mts +10 -0
- package/dist/{types-CdcQh4Z2.d.mts → types/tailordb.generated.d.mts} +2 -287
- package/dist/types/workflow.generated.d.mts +12 -0
- package/dist/types-C-lQ4se3.mjs +4 -0
- package/dist/types-CXF2OYdR.mjs +199 -0
- package/dist/types-CXF2OYdR.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +5 -89
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/utils/test/mock.d.mts +87 -0
- package/dist/vitest/environment.d.mts +1 -2
- package/dist/vitest/environment.mjs +2 -2
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.d.mts +12 -428
- package/dist/vitest/index.mjs +740 -9
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock-kysely.d.mts +62 -0
- package/dist/vitest/mock.d.mts +9 -0
- package/dist/vitest/mocks/aigateway.d.mts +30 -0
- package/dist/vitest/mocks/authconnection.d.mts +28 -0
- package/dist/vitest/mocks/file.d.mts +41 -0
- package/dist/vitest/mocks/iconv.d.mts +27 -0
- package/dist/vitest/mocks/idp.d.mts +44 -0
- package/dist/vitest/mocks/secretmanager.d.mts +33 -0
- package/dist/vitest/mocks/tailordb.d.mts +71 -0
- package/dist/vitest/mocks/workflow.d.mts +117 -0
- package/dist/vitest/setup.d.mts +1 -2
- package/dist/vitest/setup.mjs +2 -2
- package/dist/vitest/workflow-local.d.mts +40 -0
- package/dist/workflow-GNuSnsTx.mjs +22 -0
- package/dist/workflow-GNuSnsTx.mjs.map +1 -0
- package/docs/cli/application.md +98 -250
- package/docs/cli/auth.md +51 -295
- package/docs/cli/completion.md +1 -25
- package/docs/cli/crashreport.md +3 -61
- package/docs/cli/executor.md +23 -187
- package/docs/cli/function.md +14 -130
- package/docs/cli/organization.md +11 -221
- package/docs/cli/plugin.md +29 -0
- package/docs/cli/query.md +2 -22
- package/docs/cli/secret.md +71 -251
- package/docs/cli/setup.md +137 -41
- package/docs/cli/skills.md +50 -39
- package/docs/cli/staticwebsite.md +32 -180
- package/docs/cli/tailordb.md +97 -323
- package/docs/cli/upgrade.md +2 -22
- package/docs/cli/user.md +78 -247
- package/docs/cli/workflow.md +44 -203
- package/docs/cli/workspace.md +165 -538
- package/docs/cli-reference.md +167 -67
- package/docs/configuration.md +34 -4
- package/docs/github-actions.md +46 -19
- package/docs/migration/v2.md +397 -26
- package/docs/multi-environment.md +29 -7
- package/docs/plugin/custom.md +4 -4
- package/docs/plugin/index.md +8 -8
- package/docs/quickstart.md +8 -7
- package/docs/runtime.md +9 -3
- package/docs/services/aigateway.md +18 -2
- package/docs/services/auth.md +34 -42
- package/docs/services/http-adapter.md +16 -1
- package/docs/services/idp.md +55 -2
- package/docs/services/resolver.md +2 -2
- package/docs/services/secret.md +11 -11
- package/docs/services/staticwebsite.md +8 -2
- package/docs/services/tailordb-migration.md +25 -23
- package/docs/services/tailordb.md +55 -32
- package/docs/services/workflow.md +92 -14
- package/docs/testing.md +49 -3
- package/package.json +42 -31
- package/postinstall.mjs +4 -6
- package/dist/application-Dtqap5jM.mjs +0 -3
- package/dist/application-XuMWK4eq.mjs +0 -7257
- package/dist/application-XuMWK4eq.mjs.map +0 -1
- package/dist/authconnection-D2MhtTN5.mjs +0 -15
- package/dist/authconnection-D2MhtTN5.mjs.map +0 -1
- package/dist/authconnection-DvUQAjQS.d.mts +0 -39
- package/dist/context-Bd266-ru.mjs.map +0 -1
- package/dist/context-C2lEi9uw.d.mts +0 -47
- package/dist/errors-Dtf2WPaW.mjs.map +0 -1
- package/dist/field-DOsJCPFa.mjs +0 -22
- package/dist/field-DOsJCPFa.mjs.map +0 -1
- package/dist/file-BbdFGdMV.mjs.map +0 -1
- package/dist/file-Dq3NIt_F.d.mts +0 -211
- package/dist/file-utils-CYZnO1pX.mjs.map +0 -1
- package/dist/globals-Cf0sxIt8.mjs.map +0 -1
- package/dist/http-adapter.generated-DFsXDdm5.d.mts +0 -581
- package/dist/iconv-Co-TOPuH.d.mts +0 -122
- package/dist/iconv-D2vi8G36.mjs +0 -63
- package/dist/iconv-D2vi8G36.mjs.map +0 -1
- package/dist/idp-BDbK5gjm.mjs.map +0 -1
- package/dist/idp-DrhVrLmV.d.mts +0 -160
- package/dist/index-BI-_j9Z3.d.mts +0 -1013
- package/dist/index-C4JirJH8.d.mts +0 -18
- package/dist/index-CZfWhr0a.d.mts +0 -18
- package/dist/index-Cg8VKAdN.d.mts +0 -46
- package/dist/index-DYRjoLXD.d.mts +0 -47
- package/dist/index-lFpcjHPU.d.mts +0 -201
- package/dist/index-nW7hE6oE.d.mts +0 -18
- package/dist/interceptor-D-q1rvRl.mjs.map +0 -1
- package/dist/mock-FPxmnt-y.mjs +0 -759
- package/dist/mock-FPxmnt-y.mjs.map +0 -1
- package/dist/registry-DH4m7eYo.mjs.map +0 -1
- package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
- package/dist/runtime-CY4JvrDj.mjs.map +0 -1
- package/dist/schema-Dtw9Orye.mjs.map +0 -1
- package/dist/secret-file-VSVGy1V0.mjs.map +0 -1
- package/dist/secretmanager-B3n4KHfm.d.mts +0 -55
- package/dist/secretmanager-BVxw3ih_.mjs +0 -24
- package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
- package/dist/seed-izIEyP3z.mjs.map +0 -1
- package/dist/service-DCqIWibD.mjs +0 -3
- package/dist/service-DU1mVzri2.mjs.map +0 -1
- package/dist/service-DjyqbCaJ.mjs.map +0 -1
- package/dist/telemetry-CdqJEzkj.mjs.map +0 -1
- package/dist/telemetry-ClwW5ohF.mjs +0 -3
- package/dist/types-74etvaxy.mjs +0 -4
- package/dist/types-BDRml5C3.d.mts +0 -574
- package/dist/types-BQijbo4m.mjs +0 -371
- package/dist/types-BQijbo4m.mjs.map +0 -1
- package/dist/types-BX4q6Mo6.d.mts +0 -339
- package/dist/workflow-BOmaZwwG.mjs +0 -43
- package/dist/workflow-BOmaZwwG.mjs.map +0 -1
- package/dist/workflow-BVy4XWjS.d.mts +0 -101
|
@@ -1,2 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/runtime/secretmanager.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Secret manager utilities.
|
|
4
|
+
*
|
|
5
|
+
* Thin typed wrapper around the platform-provided `tailor.secretmanager` runtime API.
|
|
6
|
+
* At runtime this delegates to `globalThis.tailor.secretmanager`. Use
|
|
7
|
+
* `mockSecretmanager` from `@tailor-platform/sdk/vitest` to mock these calls
|
|
8
|
+
* in unit tests.
|
|
9
|
+
* @example
|
|
10
|
+
* import { secretmanager } from "@tailor-platform/sdk/runtime";
|
|
11
|
+
*
|
|
12
|
+
* const apiKey = await secretmanager.getSecret("my-vault", "API_KEY");
|
|
13
|
+
* const all = await secretmanager.getSecrets("my-vault", ["A", "B"] as const);
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Platform API surface for `tailor.secretmanager`. Describes the shape the
|
|
17
|
+
* platform runtime injects on `globalThis.tailor.secretmanager`.
|
|
18
|
+
*/
|
|
19
|
+
interface TailorSecretmanagerAPI {
|
|
20
|
+
/**
|
|
21
|
+
* Returns multiple secrets from a vault. Missing names are omitted from the result.
|
|
22
|
+
* @param vault - Vault name
|
|
23
|
+
* @param names - Secret names to fetch (use `as const` to narrow the result key)
|
|
24
|
+
* @returns Partial record keyed by the requested names
|
|
25
|
+
*/
|
|
26
|
+
getSecrets<const T extends readonly string[]>(vault: string, names: T): Promise<Partial<Record<T[number], string>>>;
|
|
27
|
+
/**
|
|
28
|
+
* Returns a single secret from a vault, or `undefined` when missing.
|
|
29
|
+
* @param vault - Vault name
|
|
30
|
+
* @param name - Secret name
|
|
31
|
+
* @returns The secret value, or `undefined` if not present
|
|
32
|
+
*/
|
|
33
|
+
getSecret(vault: string, name: string): Promise<string | undefined>;
|
|
34
|
+
}
|
|
35
|
+
/** Runtime wrapper namespace for `tailor.secretmanager`. */
|
|
36
|
+
declare const secretmanager: {
|
|
37
|
+
readonly getSecrets: <const T extends readonly string[]>(vault: string, names: T) => Promise<Partial<Record<T[number], string>>>;
|
|
38
|
+
readonly getSecret: (vault: string, name: string) => Promise<string | undefined>;
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { TailorSecretmanagerAPI, secretmanager };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as secretmanager } from "../secretmanager-CYlpffsz.mjs";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { secretmanager };
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
//#region src/runtime/types.d.ts
|
|
2
|
-
interface
|
|
2
|
+
interface Attributes {}
|
|
3
3
|
interface AttributeList {
|
|
4
4
|
__tuple?: [];
|
|
5
5
|
}
|
|
6
|
-
type
|
|
6
|
+
type InferredAttributes = keyof Attributes extends never ? Record<string, string | string[] | boolean | boolean[] | undefined> : Attributes;
|
|
7
7
|
type InferredAttributeList = AttributeList["__tuple"] extends [] ? string[] : AttributeList["__tuple"];
|
|
8
8
|
/** Represents a user or machine user principal in the Tailor Platform. */
|
|
9
9
|
type TailorPrincipal = {
|
|
10
10
|
/** The ID of the principal. */id: string; /** The type of the principal. */
|
|
11
11
|
type: "user" | "machine_user"; /** The ID of the workspace the principal belongs to. */
|
|
12
12
|
workspaceId: string; /** A map of the principal's attributes. */
|
|
13
|
-
attributes:
|
|
13
|
+
attributes: InferredAttributes; /** A list of the principal's attribute IDs. */
|
|
14
14
|
attributeList: InferredAttributeList;
|
|
15
15
|
};
|
|
16
16
|
interface Env {}
|
|
17
17
|
/** Represents environment variables in the Tailor platform. */
|
|
18
18
|
type TailorEnv = keyof Env extends never ? Record<string, string | number | boolean> : Env;
|
|
19
19
|
//#endregion
|
|
20
|
-
export {
|
|
21
|
-
//# sourceMappingURL=types-BZ7QKVE8.d.mts.map
|
|
20
|
+
export { AttributeList, Attributes, Env, InferredAttributeList, InferredAttributes, TailorEnv, TailorPrincipal };
|
|
@@ -1,2 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/runtime/workflow.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Workflow utilities.
|
|
4
|
+
*
|
|
5
|
+
* Thin typed wrapper around the platform-provided `tailor.workflow` runtime API.
|
|
6
|
+
* At runtime this delegates to `globalThis.tailor.workflow`. Use `mockWorkflow`
|
|
7
|
+
* from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.
|
|
8
|
+
* @example
|
|
9
|
+
* import { workflow } from "@tailor-platform/sdk/runtime";
|
|
10
|
+
*
|
|
11
|
+
* const executionId = await workflow.triggerWorkflow("myWorkflow", { data: "value" });
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Specifies the machine user that should be used to execute the workflow.
|
|
15
|
+
* This allows workflows to run with specific authentication context.
|
|
16
|
+
*/
|
|
17
|
+
interface Invoker {
|
|
18
|
+
/** The namespace where the machine user is defined */
|
|
19
|
+
namespace: string;
|
|
20
|
+
/** The name of the machine user to use for workflow execution */
|
|
21
|
+
machineUserName: string;
|
|
22
|
+
}
|
|
23
|
+
/** Options for {@link triggerWorkflow}. */
|
|
24
|
+
interface TriggerWorkflowOptions {
|
|
25
|
+
/** Optional invoker to specify which machine user should execute the workflow */
|
|
26
|
+
invoker?: Invoker;
|
|
27
|
+
}
|
|
28
|
+
interface PlatformTriggerWorkflowOptions {
|
|
29
|
+
authInvoker?: Invoker;
|
|
30
|
+
}
|
|
31
|
+
declare const executionPolicyKeyBrand: unique symbol;
|
|
32
|
+
/**
|
|
33
|
+
* A concrete runtime key produced by an execution policy instance — either an
|
|
34
|
+
* exact-match policy's `.key`, or a wildcard policy's `.keyFor(suffix)` (see
|
|
35
|
+
* `defineWorkflowExecutionPolicies`). Branded so an arbitrary string that
|
|
36
|
+
* wasn't derived from a declared policy can't be passed as `executionPolicyKey`.
|
|
37
|
+
*/
|
|
38
|
+
type ExecutionPolicyKey = string & {
|
|
39
|
+
readonly [executionPolicyKeyBrand]: never;
|
|
40
|
+
};
|
|
41
|
+
/** Options for {@link triggerJobFunction}. */
|
|
42
|
+
interface TriggerJobFunctionOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Execution policy key matched by the platform against the policies
|
|
45
|
+
* declared with `defineWorkflowExecutionPolicies` in `tailor.config.ts`.
|
|
46
|
+
*/
|
|
47
|
+
executionPolicyKey?: ExecutionPolicyKey;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Platform API surface for `tailor.workflow`. Describes the shape the platform
|
|
51
|
+
* runtime injects on `globalThis.tailor.workflow`.
|
|
52
|
+
*/
|
|
53
|
+
interface PlatformWorkflowAPI {
|
|
54
|
+
/**
|
|
55
|
+
* Triggers a workflow and returns its execution ID.
|
|
56
|
+
* @param workflowName - Workflow name as defined in tailor.config
|
|
57
|
+
* @param args - Arguments forwarded to the workflow's main job
|
|
58
|
+
* @param options - Optional platform trigger options
|
|
59
|
+
* @returns The execution ID of the triggered workflow
|
|
60
|
+
*/
|
|
61
|
+
triggerWorkflow(workflowName: string, args?: any, options?: PlatformTriggerWorkflowOptions): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Resumes a failed or pending-retry workflow execution and returns its execution ID.
|
|
64
|
+
* @param executionId - The execution to resume
|
|
65
|
+
* @returns The execution ID of the resumed workflow
|
|
66
|
+
*/
|
|
67
|
+
resumeWorkflow(executionId: string): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Triggers a job function and returns its result.
|
|
70
|
+
* @param jobName - Job name as defined in the workflow
|
|
71
|
+
* @param args - Arguments forwarded to the job
|
|
72
|
+
* @param options - Optional trigger options (e.g. `executionPolicyKey`)
|
|
73
|
+
* @returns The job's return value
|
|
74
|
+
*/
|
|
75
|
+
triggerJobFunction(jobName: string, args?: any, options?: TriggerJobFunctionOptions): any;
|
|
76
|
+
/**
|
|
77
|
+
* Suspends the current workflow execution and waits for an external signal to resume.
|
|
78
|
+
* @param key - Wait point key
|
|
79
|
+
* @param payload - Optional payload to record with the wait point
|
|
80
|
+
* @returns The payload supplied by the corresponding `resolve` call
|
|
81
|
+
*/
|
|
82
|
+
wait(key: string, payload?: any): any;
|
|
83
|
+
/**
|
|
84
|
+
* Resolves a waiting workflow execution, causing it to resume.
|
|
85
|
+
* @param executionId - The execution to resume
|
|
86
|
+
* @param key - Wait point key to resolve
|
|
87
|
+
* @param callback - Callback receiving the wait payload; its return value is forwarded to `wait`
|
|
88
|
+
* @returns A promise that resolves once the resolve has been recorded
|
|
89
|
+
*/
|
|
90
|
+
resolve(executionId: string, key: string, callback: (waitPayload: any) => any): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/** Runtime wrapper API for workflow and job control. */
|
|
93
|
+
interface TailorWorkflowAPI extends Omit<PlatformWorkflowAPI, "triggerWorkflow"> {
|
|
94
|
+
/**
|
|
95
|
+
* Triggers a workflow and returns its execution ID.
|
|
96
|
+
* @param workflowName - Workflow name as defined in tailor.config
|
|
97
|
+
* @param args - Arguments forwarded to the workflow's main job
|
|
98
|
+
* @param options - Optional SDK trigger options
|
|
99
|
+
* @returns The execution ID of the triggered workflow
|
|
100
|
+
*/
|
|
101
|
+
triggerWorkflow(workflowName: string, args?: any, options?: TriggerWorkflowOptions): Promise<string>;
|
|
102
|
+
}
|
|
103
|
+
declare function triggerWorkflow(workflowName: string, args?: any, options?: TriggerWorkflowOptions): Promise<string>;
|
|
104
|
+
/** Runtime wrapper namespace for `tailor.workflow`. */
|
|
105
|
+
declare const workflow: {
|
|
106
|
+
readonly triggerWorkflow: typeof triggerWorkflow;
|
|
107
|
+
readonly resumeWorkflow: (executionId: string) => Promise<string>;
|
|
108
|
+
readonly triggerJobFunction: (jobName: string, args?: any, options?: TriggerJobFunctionOptions) => any;
|
|
109
|
+
readonly wait: (key: string, payload?: any) => any;
|
|
110
|
+
readonly resolve: (executionId: string, key: string, callback: (waitPayload: any) => any) => Promise<void>;
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { ExecutionPolicyKey, Invoker, PlatformTriggerWorkflowOptions, PlatformWorkflowAPI, TailorWorkflowAPI, TriggerJobFunctionOptions, TriggerWorkflowOptions, workflow };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as workflow } from "../workflow-GNuSnsTx.mjs";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { workflow };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as mapAllowedValues, t as parseInternal } from "./field-runtime-CAnh_oow.mjs";
|
|
2
2
|
import { t as brandValue } from "./brand-Eo4pLXPJ.mjs";
|
|
3
3
|
import { cloneDeep } from "es-toolkit";
|
|
4
4
|
|
|
@@ -6,22 +6,10 @@ import { cloneDeep } from "es-toolkit";
|
|
|
6
6
|
function isRelationSelfConfig(config) {
|
|
7
7
|
return config.toward.type === "self";
|
|
8
8
|
}
|
|
9
|
-
const regex = {
|
|
10
|
-
uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
11
|
-
date: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/,
|
|
12
|
-
time: /^(?<hour>\d{2}):(?<minute>\d{2})$/,
|
|
13
|
-
datetime: /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})T(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2})(.(?<millisec>\d{3}))?Z$/,
|
|
14
|
-
decimal: /^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new TailorDBField instance.
|
|
18
|
-
* @param type - Field type
|
|
19
|
-
* @param options - Field options
|
|
20
|
-
* @param fields - Nested fields for object-like types
|
|
21
|
-
* @param values - Allowed values for enum-like fields
|
|
22
|
-
* @returns A new TailorDBField
|
|
23
|
-
*/
|
|
24
9
|
function createTailorDBField(type, options, fields, values) {
|
|
10
|
+
return createTailorDBFieldRuntime(type, options, fields, values);
|
|
11
|
+
}
|
|
12
|
+
function createTailorDBFieldRuntime(type, options, fields, values) {
|
|
25
13
|
const _metadata = { required: true };
|
|
26
14
|
let _rawRelation;
|
|
27
15
|
if (options) {
|
|
@@ -29,163 +17,11 @@ function createTailorDBField(type, options, fields, values) {
|
|
|
29
17
|
if (options.array === true) _metadata.array = true;
|
|
30
18
|
}
|
|
31
19
|
if (values) _metadata.allowedValues = mapAllowedValues(values);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @returns Array of validation issues
|
|
37
|
-
*/
|
|
38
|
-
function validateValue(args) {
|
|
39
|
-
const { value, data, invoker, pathArray } = args;
|
|
40
|
-
const issues = [];
|
|
41
|
-
switch (type) {
|
|
42
|
-
case "string":
|
|
43
|
-
if (typeof value !== "string") issues.push({
|
|
44
|
-
message: `Expected a string: received ${String(value)}`,
|
|
45
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
46
|
-
});
|
|
47
|
-
break;
|
|
48
|
-
case "integer":
|
|
49
|
-
if (typeof value !== "number" || !Number.isInteger(value)) issues.push({
|
|
50
|
-
message: `Expected an integer: received ${String(value)}`,
|
|
51
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
52
|
-
});
|
|
53
|
-
break;
|
|
54
|
-
case "float":
|
|
55
|
-
if (typeof value !== "number" || !Number.isFinite(value)) issues.push({
|
|
56
|
-
message: `Expected a number: received ${String(value)}`,
|
|
57
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
58
|
-
});
|
|
59
|
-
break;
|
|
60
|
-
case "boolean":
|
|
61
|
-
if (typeof value !== "boolean") issues.push({
|
|
62
|
-
message: `Expected a boolean: received ${String(value)}`,
|
|
63
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
64
|
-
});
|
|
65
|
-
break;
|
|
66
|
-
case "uuid":
|
|
67
|
-
if (typeof value !== "string" || !regex.uuid.test(value)) issues.push({
|
|
68
|
-
message: `Expected a valid UUID: received ${String(value)}`,
|
|
69
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
70
|
-
});
|
|
71
|
-
break;
|
|
72
|
-
case "date":
|
|
73
|
-
if (typeof value !== "string" || !regex.date.test(value)) issues.push({
|
|
74
|
-
message: `Expected to match "yyyy-MM-dd" format: received ${String(value)}`,
|
|
75
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
76
|
-
});
|
|
77
|
-
break;
|
|
78
|
-
case "datetime":
|
|
79
|
-
if (typeof value !== "string" || !regex.datetime.test(value)) issues.push({
|
|
80
|
-
message: `Expected to match ISO format: received ${String(value)}`,
|
|
81
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
82
|
-
});
|
|
83
|
-
break;
|
|
84
|
-
case "time":
|
|
85
|
-
if (typeof value !== "string" || !regex.time.test(value)) issues.push({
|
|
86
|
-
message: `Expected to match "HH:mm" format: received ${String(value)}`,
|
|
87
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
88
|
-
});
|
|
89
|
-
break;
|
|
90
|
-
case "decimal":
|
|
91
|
-
if (typeof value !== "string" || !regex.decimal.test(value)) issues.push({
|
|
92
|
-
message: `Expected a decimal string: received ${String(value)}`,
|
|
93
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
94
|
-
});
|
|
95
|
-
break;
|
|
96
|
-
case "enum":
|
|
97
|
-
if (field._metadata.allowedValues) {
|
|
98
|
-
const allowedValues = field._metadata.allowedValues.map((v) => v.value);
|
|
99
|
-
if (typeof value !== "string" || !allowedValues.includes(value)) issues.push({
|
|
100
|
-
message: `Must be one of [${allowedValues.join(", ")}]: received ${String(value)}`,
|
|
101
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
case "nested":
|
|
106
|
-
if (typeof value !== "object" || value === null || Array.isArray(value) || value instanceof Date) issues.push({
|
|
107
|
-
message: `Expected an object: received ${String(value)}`,
|
|
108
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
109
|
-
});
|
|
110
|
-
else if (Object.keys(field.fields).length > 0) for (const [fieldName, nestedField] of Object.entries(field.fields)) {
|
|
111
|
-
const fieldValue = value[fieldName];
|
|
112
|
-
const result = nestedField._parseInternal({
|
|
113
|
-
value: fieldValue,
|
|
114
|
-
data,
|
|
115
|
-
invoker,
|
|
116
|
-
pathArray: pathArray.concat(fieldName)
|
|
117
|
-
});
|
|
118
|
-
if (result.issues) issues.push(...result.issues);
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
const validateFns = field._metadata.validate;
|
|
123
|
-
if (validateFns && validateFns.length > 0) for (const validateInput of validateFns) {
|
|
124
|
-
const { fn, message } = typeof validateInput === "function" ? {
|
|
125
|
-
fn: validateInput,
|
|
126
|
-
message: "Validation failed"
|
|
127
|
-
} : {
|
|
128
|
-
fn: validateInput[0],
|
|
129
|
-
message: validateInput[1]
|
|
130
|
-
};
|
|
131
|
-
if (!fn({
|
|
132
|
-
value,
|
|
133
|
-
data,
|
|
134
|
-
invoker
|
|
135
|
-
})) issues.push({
|
|
136
|
-
message,
|
|
137
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
return issues;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Internal parse method that tracks field path for nested validation
|
|
144
|
-
* @param args - Parse arguments
|
|
145
|
-
* @returns Parse result with value or issues
|
|
146
|
-
*/
|
|
147
|
-
function parseInternal(args) {
|
|
148
|
-
const { value, data, invoker, pathArray } = args;
|
|
149
|
-
const issues = [];
|
|
150
|
-
const isNullOrUndefined = value === null || value === void 0;
|
|
151
|
-
if (field._metadata.required && isNullOrUndefined) {
|
|
152
|
-
issues.push({
|
|
153
|
-
message: "Required field is missing",
|
|
154
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
155
|
-
});
|
|
156
|
-
return { issues };
|
|
157
|
-
}
|
|
158
|
-
if (!field._metadata.required && isNullOrUndefined) return { value: value ?? null };
|
|
159
|
-
if (field._metadata.array) {
|
|
160
|
-
if (!Array.isArray(value)) {
|
|
161
|
-
issues.push({
|
|
162
|
-
message: "Expected an array",
|
|
163
|
-
path: pathArray.length > 0 ? pathArray : void 0
|
|
164
|
-
});
|
|
165
|
-
return { issues };
|
|
166
|
-
}
|
|
167
|
-
for (let i = 0; i < value.length; i++) {
|
|
168
|
-
const elementValue = value[i];
|
|
169
|
-
const elementIssues = validateValue({
|
|
170
|
-
value: elementValue,
|
|
171
|
-
data,
|
|
172
|
-
invoker,
|
|
173
|
-
pathArray: pathArray.concat(`[${i}]`)
|
|
174
|
-
});
|
|
175
|
-
if (elementIssues.length > 0) issues.push(...elementIssues);
|
|
176
|
-
}
|
|
177
|
-
if (issues.length > 0) return { issues };
|
|
178
|
-
return { value };
|
|
179
|
-
}
|
|
180
|
-
const valueIssues = validateValue({
|
|
181
|
-
value,
|
|
182
|
-
data,
|
|
183
|
-
invoker,
|
|
184
|
-
pathArray
|
|
20
|
+
function parseInternal$1(args) {
|
|
21
|
+
return parseInternal({
|
|
22
|
+
...args,
|
|
23
|
+
field
|
|
185
24
|
});
|
|
186
|
-
issues.push(...valueIssues);
|
|
187
|
-
if (issues.length > 0) return { issues };
|
|
188
|
-
return { value };
|
|
189
25
|
}
|
|
190
26
|
function cloneWith(metadataUpdates) {
|
|
191
27
|
const cloned = field.clone();
|
|
@@ -210,19 +46,21 @@ function createTailorDBField(type, options, fields, values) {
|
|
|
210
46
|
description(description) {
|
|
211
47
|
return cloneWith({ description });
|
|
212
48
|
},
|
|
213
|
-
typeName
|
|
49
|
+
typeName(typeName) {
|
|
50
|
+
return cloneWith({ typeName });
|
|
51
|
+
},
|
|
214
52
|
validate(...validateInputs) {
|
|
215
53
|
return cloneWith({ validate: validateInputs });
|
|
216
54
|
},
|
|
217
55
|
parse(args) {
|
|
218
|
-
return parseInternal({
|
|
56
|
+
return parseInternal$1({
|
|
219
57
|
value: args.value,
|
|
220
58
|
data: args.data,
|
|
221
59
|
invoker: args.invoker,
|
|
222
60
|
pathArray: []
|
|
223
61
|
});
|
|
224
62
|
},
|
|
225
|
-
_parseInternal: parseInternal,
|
|
63
|
+
_parseInternal: parseInternal$1,
|
|
226
64
|
relation(config) {
|
|
227
65
|
const cloned = field.clone();
|
|
228
66
|
const targetType = isRelationSelfConfig(config) ? "self" : config.toward.type.name;
|
|
@@ -262,16 +100,13 @@ function createTailorDBField(type, options, fields, values) {
|
|
|
262
100
|
for (const [key, field] of Object.entries(fields)) cloned[key] = field.clone();
|
|
263
101
|
clonedFields = cloned;
|
|
264
102
|
}
|
|
265
|
-
const clonedField =
|
|
103
|
+
const clonedField = createTailorDBFieldRuntime(type, options, clonedFields, values);
|
|
266
104
|
Object.assign(clonedField._metadata, cloneDeep(this._metadata));
|
|
267
105
|
if (cloneOptions) {
|
|
268
106
|
if (cloneOptions.optional !== void 0) clonedField._metadata.required = !cloneOptions.optional;
|
|
269
107
|
if (cloneOptions.array !== void 0) clonedField._metadata.array = cloneOptions.array;
|
|
270
108
|
}
|
|
271
|
-
if (_rawRelation)
|
|
272
|
-
const clonedRawRelation = cloneDeep(_rawRelation);
|
|
273
|
-
clonedField._setRawRelation(clonedRawRelation);
|
|
274
|
-
}
|
|
109
|
+
if (_rawRelation) clonedField._setRawRelation(cloneDeep(_rawRelation));
|
|
275
110
|
return clonedField;
|
|
276
111
|
},
|
|
277
112
|
_setRawRelation(relation) {
|
|
@@ -360,7 +195,7 @@ function date(options) {
|
|
|
360
195
|
}
|
|
361
196
|
/**
|
|
362
197
|
* Create a datetime field (date and time).
|
|
363
|
-
* Format: ISO 8601 "yyyy-MM-ddTHH:mm:ssZ"
|
|
198
|
+
* Format: ISO 8601, such as "yyyy-MM-ddTHH:mm:ssZ" or "yyyy-MM-ddTHH:mm:ss+09:00"
|
|
364
199
|
* @param options - Field configuration options
|
|
365
200
|
* @returns A datetime field
|
|
366
201
|
* @example db.datetime()
|
|
@@ -525,7 +360,7 @@ function createTailorDBType(name, fields, options) {
|
|
|
525
360
|
}, "tailordb-type");
|
|
526
361
|
}
|
|
527
362
|
const idField = uuid();
|
|
528
|
-
function
|
|
363
|
+
function dbTable(name, fieldsOrDescription, fields) {
|
|
529
364
|
const typeName = Array.isArray(name) ? name[0] : name;
|
|
530
365
|
const pluralForm = Array.isArray(name) ? name[1] : void 0;
|
|
531
366
|
let description;
|
|
@@ -542,9 +377,9 @@ function dbType(name, fieldsOrDescription, fields) {
|
|
|
542
377
|
description
|
|
543
378
|
});
|
|
544
379
|
}
|
|
545
|
-
/** TailorDB schema builder utilities for defining
|
|
380
|
+
/** TailorDB schema builder utilities for defining tables and fields. */
|
|
546
381
|
const db = {
|
|
547
|
-
|
|
382
|
+
table: dbTable,
|
|
548
383
|
uuid,
|
|
549
384
|
string,
|
|
550
385
|
bool,
|
|
@@ -564,7 +399,7 @@ const db = {
|
|
|
564
399
|
* historical records); the current time is used only when the value is omitted.
|
|
565
400
|
* @returns An object with createdAt and updatedAt fields
|
|
566
401
|
* @example
|
|
567
|
-
* const model = db.
|
|
402
|
+
* const model = db.table("Model", {
|
|
568
403
|
* name: db.string(),
|
|
569
404
|
* ...db.fields.timestamps(),
|
|
570
405
|
* });
|
|
@@ -580,4 +415,4 @@ timestamps: () => ({
|
|
|
580
415
|
|
|
581
416
|
//#endregion
|
|
582
417
|
export { db as t };
|
|
583
|
-
//# sourceMappingURL=schema-
|
|
418
|
+
//# sourceMappingURL=schema-C4LYbXVG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-C4LYbXVG.mjs","names":["parseInternal","parseFieldInternal"],"sources":["../src/configure/services/tailordb/schema.ts"],"sourcesContent":["import { cloneDeep } from \"es-toolkit\";\nimport {\n type AllowedValues,\n type AllowedValuesOutput,\n mapAllowedValues,\n} from \"#/configure/types/field\";\nimport {\n parseInternal as parseFieldInternal,\n type FieldParseArgs,\n type FieldParseInternalArgs,\n} from \"#/configure/types/field-runtime\";\nimport { brandValue } from \"#/utils/brand\";\nimport type {\n TailorDBField as TailorDBFieldBase,\n TailorDBType as TailorDBTypeBase,\n DBFieldMetadata,\n DefinedDBFieldMetadata,\n SerialConfig,\n IndexDef,\n TailorDBTypeMetadata,\n RawRelationConfig,\n RelationType,\n} from \"#/configure/services/tailordb/types\";\nimport type {\n FieldOptions,\n FieldOutput,\n TailorFieldType,\n TailorToTs,\n FieldValidateInput,\n ValidateConfig,\n Validators,\n} from \"#/configure/types/field.types\";\nimport type { PluginAttachment, PluginConfigs } from \"#/plugin/types\";\nimport type { InferredAttributes } from \"#/runtime/types\";\nimport type { output, InferFieldsOutput, TypeLevelError } from \"#/types/helpers\";\nimport type { RawPermissions } from \"#/types/tailordb.generated\";\nimport type { TailorTypeGqlPermission, TailorTypePermission } from \"./permission\";\nimport type { Hook, Hooks, ExcludeNestedDBFields, TypeFeatures } from \"./types\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n// Erased DB fields stay assignable across builder method-state changes.\n// oxlint-disable-next-line no-explicit-any\ntype AnyBuilderMethod = any;\n\nexport type TailorAnyDBField = Omit<\n TailorDBFieldBase<AnyBuilderMethod, AnyBuilderMethod>,\n \"fields\"\n> & {\n readonly fields: Record<string, AnyBuilderMethod>;\n _metadata: DBFieldMetadata;\n parse: AnyBuilderMethod;\n _parseInternal: AnyBuilderMethod;\n readonly typeName: TypeLevelError<string>;\n description: AnyBuilderMethod;\n relation: AnyBuilderMethod;\n index: AnyBuilderMethod;\n unique: AnyBuilderMethod;\n vector: AnyBuilderMethod;\n hooks: AnyBuilderMethod;\n validate: AnyBuilderMethod;\n serial: AnyBuilderMethod;\n clone: AnyBuilderMethod;\n};\n\n// Helper alias\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyDBType = TailorDBType<any, any>;\n\ntype IsAny<T> = 0 extends 1 & T ? true : false;\ntype DBFieldTypeNameMethod<Defined extends DefinedDBFieldMetadata> =\n IsAny<Defined> extends true\n ? TypeLevelError<string>\n : TypeLevelError<\"typeName cannot be used on TailorDB fields\">;\n\ntype WithDBFieldDescription<Defined> = Defined & { description: true };\ntype WithDBFieldRelation<Defined, S extends RelationType | RelationSelfConfig> = S extends\n | \"oneToOne\"\n | \"1-1\"\n ? Defined & { unique: true; index: true; relation: true }\n : S extends { type: \"oneToOne\" | \"1-1\" }\n ? Defined & { unique: true; index: true; relation: true }\n : Defined & { index: true; relation: true };\ntype WithDBFieldIndex<Defined> = Defined & { index: true };\ntype WithDBFieldUnique<Defined> = Defined & { unique: true; index: true };\ntype WithDBFieldVector<Defined> = Defined & { vector: true };\ntype WithDBFieldHooks<Defined, H> = Defined & {\n hooks: {\n create: H extends { create: unknown } ? true : false;\n update: H extends { update: unknown } ? true : false;\n };\n serial: false;\n};\ntype WithDBFieldValidate<Defined> = Defined & { validate: true };\ntype WithDBFieldSerial<Defined> = Defined & {\n serial: true;\n hooks: { create: false; update: false };\n};\ntype WithDBFieldCloneOptions<Defined extends DefinedDBFieldMetadata, NewOpt extends FieldOptions> =\n IsAny<Defined> extends true\n ? Defined\n : Omit<Defined, \"array\"> & {\n array: NewOpt extends { array: true }\n ? true\n : NewOpt extends { array: false }\n ? false\n : Defined[\"array\"];\n };\ntype NonNullableDBFieldOutput<Output> = Exclude<Output, null>;\ntype DBFieldScalarOutput<Output> =\n NonNullableDBFieldOutput<Output> extends (infer Item)[] ? Item : NonNullableDBFieldOutput<Output>;\ntype DBFieldCloneArrayOutput<Output, NewOpt extends FieldOptions> = NewOpt extends {\n array: true;\n}\n ? DBFieldScalarOutput<Output>[]\n : NewOpt extends { array: false }\n ? DBFieldScalarOutput<Output>\n : NonNullableDBFieldOutput<Output>;\ntype DBFieldCloneOutput<Output, NewOpt extends FieldOptions> = NewOpt extends { optional: true }\n ? DBFieldCloneArrayOutput<Output, NewOpt> | null\n : NewOpt extends { optional: false }\n ? DBFieldCloneArrayOutput<Output, NewOpt>\n : null extends Output\n ? DBFieldCloneArrayOutput<Output, NewOpt> | null\n : DBFieldCloneArrayOutput<Output, NewOpt>;\ntype FileKeyConflictError<\n Fields extends Record<string, TailorAnyDBField>,\n User extends object,\n> = Partial<\n Record<\n keyof output<TailorDBType<Fields, User>> & string,\n TypeLevelError<\"file keys cannot use existing field names\">\n >\n>;\ntype DBFieldDescriptionFn<Defined extends DefinedDBFieldMetadata, Output> = (\n description: string,\n) => TailorDBField<WithDBFieldDescription<Defined>, Output>;\ntype DBFieldRelationFn<Defined extends DefinedDBFieldMetadata, Output> = {\n <S extends RelationType, T extends TailorAnyDBType>(\n config: RelationConfig<S, T>,\n ): TailorDBField<WithDBFieldRelation<Defined, S>, Output>;\n <S extends RelationSelfConfig>(config: S): TailorDBField<WithDBFieldRelation<Defined, S>, Output>;\n};\ntype DBFieldIndexFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<\n WithDBFieldIndex<Defined>,\n Output\n>;\ntype DBFieldUniqueFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<\n WithDBFieldUnique<Defined>,\n Output\n>;\ntype DBFieldVectorFn<Defined extends DefinedDBFieldMetadata, Output> = () => TailorDBField<\n WithDBFieldVector<Defined>,\n Output\n>;\ntype DBFieldHooksFn<Defined extends DefinedDBFieldMetadata, Output> = <\n const H extends Hook<unknown, Output>,\n>(\n hooks: H,\n) => TailorDBField<WithDBFieldHooks<Defined, H>, Output>;\ntype DBFieldValidateFn<Defined extends DefinedDBFieldMetadata, Output> = (\n ...validate: FieldValidateInput<Output>[]\n) => TailorDBField<WithDBFieldValidate<Defined>, Output>;\ntype DBFieldSerialFn<Defined extends DefinedDBFieldMetadata, Output> = (\n config: SerialConfig<Defined[\"type\"] & (\"integer\" | \"string\")>,\n) => TailorDBField<WithDBFieldSerial<Defined>, Output>;\ntype DBFieldDescriptionMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldDescriptionFn<Defined, Output>\n : Defined extends { description: unknown }\n ? TypeLevelError<\".description() has already been set\">\n : DBFieldDescriptionFn<Defined, Output>;\ntype DBFieldRelationMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldRelationFn<Defined, Output>\n : Defined extends { relation: unknown }\n ? TypeLevelError<\".relation() has already been set\">\n : DBFieldRelationFn<Defined, Output>;\ntype DBFieldIndexMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldIndexFn<Defined, Output>\n : Defined extends { index: unknown }\n ? TypeLevelError<\".index() has already been set\">\n : boolean extends Defined[\"array\"]\n ? DBFieldIndexFn<Defined, Output> | TypeLevelError<\"index cannot be set on array fields\">\n : Defined extends { array: true }\n ? TypeLevelError<\"index cannot be set on array fields\">\n : DBFieldIndexFn<Defined, Output>;\ntype DBFieldUniqueMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldUniqueFn<Defined, Output>\n : Defined extends { unique: unknown }\n ? TypeLevelError<\".unique() has already been set\">\n : boolean extends Defined[\"array\"]\n ? DBFieldUniqueFn<Defined, Output> | TypeLevelError<\"unique cannot be set on array fields\">\n : Defined extends { array: true }\n ? TypeLevelError<\"unique cannot be set on array fields\">\n : DBFieldUniqueFn<Defined, Output>;\ntype DBFieldVectorMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldVectorFn<Defined, Output>\n : Defined extends { vector: unknown }\n ? TypeLevelError<\".vector() has already been set\">\n : Defined extends { type: \"string\"; array: false }\n ? DBFieldVectorFn<Defined, Output>\n : TypeLevelError<\"vector can only be set on non-array string fields\">;\ntype DBFieldHooksMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldHooksFn<Defined, Output>\n : Defined extends {\n serial: true;\n hooks: { create: false; update: false };\n }\n ? TypeLevelError<\"hooks cannot be set after serial\">\n : Defined extends {\n hooks: unknown;\n }\n ? TypeLevelError<\".hooks() has already been set\">\n : Defined extends { type: \"nested\" }\n ? TypeLevelError<\"hooks cannot be set on nested type fields\">\n : DBFieldHooksFn<Defined, Output>;\ntype DBFieldValidateMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldValidateFn<Defined, Output>\n : Defined extends { validate: unknown }\n ? TypeLevelError<\".validate() has already been set\">\n : DBFieldValidateFn<Defined, Output>;\ntype DBFieldSerialMethod<Defined extends DefinedDBFieldMetadata, Output> =\n IsAny<Defined> extends true\n ? DBFieldSerialFn<Defined, Output>\n : Defined extends { serial: true }\n ? TypeLevelError<\".serial() has already been set\">\n : Defined extends { serial: false }\n ? TypeLevelError<\"serial cannot be set after hooks\">\n : IsAny<Output> extends true\n ? Defined extends { type: \"integer\" | \"string\"; array: false }\n ? DBFieldSerialFn<Defined, Output>\n : TypeLevelError<\"serial can only be set on non-array integer or string fields\">\n : null extends Output\n ? TypeLevelError<\"serial can only be set on non-array integer or string fields\">\n : Defined extends { type: \"integer\" | \"string\"; array: false }\n ? DBFieldSerialFn<Defined, Output>\n : TypeLevelError<\"serial can only be set on non-array integer or string fields\">;\n\n/**\n * Full TailorDBField interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorDBField<\n Defined extends DefinedDBFieldMetadata = DefinedDBFieldMetadata,\n // oxlint-disable-next-line no-explicit-any\n Output = any,\n> extends Omit<TailorDBFieldBase<Defined, Output>, \"fields\"> {\n readonly fields: Record<string, TailorAnyDBField>;\n _metadata: DBFieldMetadata;\n\n /**\n * Parse and validate a value against this field's validation rules\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n */\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * typeName is not available on TailorDB fields.\n * Use typeName on pipeline fields (t.enum / t.object) instead.\n */\n typeName: DBFieldTypeNameMethod<Defined>;\n\n /**\n * Set a description for the field\n */\n description: DBFieldDescriptionMethod<Defined, Output>;\n\n /**\n * Define a relation to another type.\n */\n relation: DBFieldRelationMethod<Defined, Output>;\n\n /**\n * Add an index to the field\n */\n index: DBFieldIndexMethod<Defined, Output>;\n\n /**\n * Make the field unique (also adds an index)\n */\n unique: DBFieldUniqueMethod<Defined, Output>;\n\n /**\n * Enable vector search on the field (string type only)\n */\n vector: DBFieldVectorMethod<Defined, Output>;\n\n /**\n * Add hooks for create/update operations on this field.\n */\n hooks: DBFieldHooksMethod<Defined, Output>;\n\n /**\n * Add validation functions to the field.\n */\n validate: DBFieldValidateMethod<Defined, Output>;\n\n /**\n * Configure serial/auto-increment behavior\n */\n serial: DBFieldSerialMethod<Defined, Output>;\n\n /**\n * Clone the field with optional overrides for field options\n */\n clone<const NewOpt extends FieldOptions>(\n options?: NewOpt,\n ): TailorDBField<WithDBFieldCloneOptions<Defined, NewOpt>, DBFieldCloneOutput<Output, NewOpt>>;\n}\n\n/**\n * Full TailorDBType interface with builder methods.\n * Extends the minimal structural interface from types/ with fluent API methods.\n */\nexport interface TailorDBType<\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributes,\n> extends TailorDBTypeBase<Fields, User> {\n _description?: string;\n\n hooks(hooks: Hooks<Fields>): TailorDBType<Fields, User>;\n validate(validators: Validators<Fields>): TailorDBType<Fields, User>;\n features(features: Omit<TypeFeatures, \"pluralForm\">): TailorDBType<Fields, User>;\n indexes(...indexes: IndexDef<TailorDBType<Fields, User>>[]): TailorDBType<Fields, User>;\n files<const F extends string>(\n files: Record<F, string> & FileKeyConflictError<Fields, User>,\n ): TailorDBType<Fields, User>;\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<TailorDBType<Fields, User>>> = TailorTypePermission<\n U,\n output<TailorDBType<Fields, User>>\n >,\n >(\n permission: P,\n ): TailorDBType<Fields, U>;\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(\n permission: P,\n ): TailorDBType<Fields, U>;\n description(description: string): TailorDBType<Fields, User>;\n pickFields<K extends keyof Fields>(keys: K[]): Pick<Fields, K>;\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(\n keys: K[],\n options: Opt,\n ): {\n [P in K]: Fields[P] extends TailorDBField<infer D, infer O>\n ? TailorDBField<WithDBFieldCloneOptions<D, Opt>, DBFieldCloneOutput<O, Opt>>\n : never;\n };\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K>;\n plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: {\n [K in P]: PluginConfigs<keyof Fields & string>[K];\n }): TailorDBType<Fields, User>;\n}\n\nexport type TailorDBInstance<\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributes,\n> = TailorDBType<Fields, User>;\n\ninterface RelationConfig<S extends RelationType, T extends TailorDBType> {\n type: S;\n toward: {\n type: T;\n as?: string;\n key?: keyof T[\"fields\"] & string;\n };\n backward?: string;\n}\n\n// Special config variant for self-referencing relations\ntype RelationSelfConfig = {\n type: RelationType;\n toward: {\n type: \"self\";\n as?: string;\n key?: string;\n };\n backward?: string;\n};\n\nfunction isRelationSelfConfig(\n config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig,\n): config is RelationSelfConfig {\n return config.toward.type === \"self\";\n}\n\ntype DBFieldDefined<T extends TailorFieldType, Opt extends FieldOptions> = {\n type: T;\n array: Opt extends { array: true } ? true : false;\n};\ntype DBFieldOutput<\n T extends TailorFieldType,\n Opt extends FieldOptions,\n OutputBase = TailorToTs[T],\n> = FieldOutput<OutputBase, Opt>;\ntype TailorDBFieldInstance<\n T extends TailorFieldType,\n Opt extends FieldOptions,\n OutputBase = TailorToTs[T],\n> = TailorDBField<DBFieldDefined<T, Opt>, DBFieldOutput<T, Opt, OutputBase>>;\ntype TailorDBFieldRuntimeInstance<\n T extends TailorFieldType,\n Opt extends FieldOptions,\n OutputBase = TailorToTs[T],\n> = TailorDBFieldRuntime<DBFieldDefined<T, Opt>, DBFieldOutput<T, Opt, OutputBase>>;\ntype TailorDBFieldRuntime<Defined extends DefinedDBFieldMetadata, Output> = Omit<\n TailorDBFieldBase<Defined, Output>,\n \"fields\"\n> & {\n readonly fields: Record<string, TailorAnyDBField>;\n _metadata: DBFieldMetadata;\n description(description: string): object;\n typeName(typeName: string): object;\n validate(...validate: FieldValidateInput<Output>[]): object;\n relation(config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig): object;\n index(): object;\n unique(): object;\n vector(): object;\n hooks(hooks: Hook<unknown, Output>): object;\n serial(config: SerialConfig): object;\n clone(options?: FieldOptions): TailorDBFieldRuntime<DefinedDBFieldMetadata, AnyBuilderMethod>;\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n _setRawRelation(relation: RawRelationConfig): void;\n};\n\n/**\n * Creates a new TailorDBField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @returns A new TailorDBField\n */\nfunction createTailorDBField<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): TailorDBFieldInstance<T, TOptions, OutputBase>;\nfunction createTailorDBField<const T extends TailorFieldType, const TOptions extends FieldOptions>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): object {\n return createTailorDBFieldRuntime(type, options, fields, values);\n}\n\nfunction createTailorDBFieldRuntime<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): TailorDBFieldRuntimeInstance<T, TOptions, OutputBase> {\n type FieldValue = DBFieldOutput<T, TOptions, OutputBase>;\n type FieldType = TailorDBFieldRuntimeInstance<T, TOptions, OutputBase>;\n\n const _metadata: DBFieldMetadata = { required: true };\n let _rawRelation: RawRelationConfig | undefined;\n\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n\n function parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<FieldValue> {\n return parseFieldInternal<T, FieldValue>({\n ...args,\n field,\n });\n }\n\n function cloneWith(metadataUpdates: Partial<DBFieldMetadata>) {\n const cloned = field.clone();\n Object.assign(cloned._metadata, metadataUpdates);\n return cloned;\n }\n\n const field: FieldType = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as DBFieldDefined<T, TOptions>,\n _output: undefined as FieldValue,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n get rawRelation(): Readonly<RawRelationConfig> | undefined {\n return _rawRelation ? { ..._rawRelation, toward: { ..._rawRelation.toward } } : undefined;\n },\n\n description(description: string) {\n return cloneWith({ description });\n },\n\n typeName(typeName: string) {\n return cloneWith({ typeName });\n },\n\n validate(...validateInputs: FieldValidateInput<FieldValue>[]) {\n return cloneWith({ validate: validateInputs });\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldValue> {\n return parseInternal({\n value: args.value,\n data: args.data,\n invoker: args.invoker,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n\n // TailorDBField specific methods\n relation(config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig) {\n const cloned = field.clone();\n const targetType = isRelationSelfConfig(config) ? \"self\" : config.toward.type.name;\n cloned._setRawRelation({\n type: config.type,\n toward: {\n type: targetType,\n as: config.toward.as,\n key: config.toward.key,\n },\n backward: config.backward,\n });\n return cloned;\n },\n\n index() {\n return cloneWith({ index: true });\n },\n\n unique() {\n return cloneWith({ unique: true, index: true });\n },\n\n vector() {\n return cloneWith({ vector: true });\n },\n\n hooks(hooks: Hook<unknown, FieldValue>) {\n return cloneWith({ hooks });\n },\n\n serial(config: SerialConfig) {\n return cloneWith({ serial: config });\n },\n\n clone(cloneOptions?: FieldOptions) {\n // Deep clone nested object fields if present\n let clonedFields = fields;\n if (fields) {\n const cloned: Record<string, TailorAnyDBField> = {};\n for (const [key, field] of Object.entries(fields)) {\n cloned[key] = field.clone();\n }\n clonedFields = cloned;\n }\n\n // Create a new field with cloned configuration\n const clonedField = createTailorDBFieldRuntime(type, options, clonedFields, values);\n\n // Deep copy metadata using cloneDeep (preserves function references)\n Object.assign(clonedField._metadata, cloneDeep(this._metadata));\n\n // Apply new options if provided\n if (cloneOptions) {\n if (cloneOptions.optional !== undefined) {\n clonedField._metadata.required = !cloneOptions.optional;\n }\n if (cloneOptions.array !== undefined) {\n clonedField._metadata.array = cloneOptions.array;\n }\n }\n\n // Copy raw relation if exists\n if (_rawRelation) {\n clonedField._setRawRelation(cloneDeep(_rawRelation));\n }\n\n return clonedField;\n },\n\n _setRawRelation(relation: RawRelationConfig) {\n _rawRelation = relation;\n },\n };\n\n return field;\n}\n\nconst createField = createTailorDBField;\n\n/**\n * Create a UUID field.\n * @param options - Field configuration options\n * @returns A UUID field\n * @example db.uuid()\n * @example db.uuid({ optional: true })\n */\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"uuid\", options);\n}\n\n/**\n * Create a string field.\n * @param options - Field configuration options\n * @returns A string field\n * @example db.string()\n * @example db.string({ optional: true })\n */\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"string\", options);\n}\n\n/**\n * Create a boolean field.\n * Note: The method name is `bool` but creates a `boolean` type field.\n * @param options - Field configuration options\n * @returns A boolean field\n * @example db.bool()\n * @example db.bool({ optional: true })\n */\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"boolean\", options);\n}\n\n/**\n * Create an integer field.\n * @param options - Field configuration options\n * @returns An integer field\n * @example db.int()\n * @example db.int({ optional: true })\n */\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"integer\", options);\n}\n\n/**\n * Create a float (decimal number) field.\n * @param options - Field configuration options\n * @returns A float field\n * @example db.float()\n * @example db.float({ optional: true })\n */\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"float\", options);\n}\n\ninterface DecimalFieldOptions extends FieldOptions {\n scale?: number;\n}\n\n/**\n * Create a decimal field (stored as string for precision).\n * @param options - Field configuration options including optional scale (0-12)\n * @returns A decimal field\n * @example db.decimal()\n * @example db.decimal({ scale: 2 })\n * @example db.decimal({ scale: 2, optional: true })\n */\nfunction decimal<const Opt extends DecimalFieldOptions>(options?: Opt) {\n if (options?.scale !== undefined) {\n if (!Number.isInteger(options.scale) || options.scale < 0 || options.scale > 12) {\n throw new Error(\"scale must be an integer between 0 and 12\");\n }\n }\n const field = createField(\"decimal\", options);\n if (options?.scale !== undefined) {\n field._metadata.scale = options.scale;\n }\n return field;\n}\n\n/**\n * Create a date field (date only, no time component).\n * Format: \"yyyy-MM-dd\"\n * @param options - Field configuration options\n * @returns A date field\n * @example db.date()\n */\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"date\", options);\n}\n\n/**\n * Create a datetime field (date and time).\n * Format: ISO 8601, such as \"yyyy-MM-ddTHH:mm:ssZ\" or \"yyyy-MM-ddTHH:mm:ss+09:00\"\n * @param options - Field configuration options\n * @returns A datetime field\n * @example db.datetime()\n */\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"datetime\", options);\n}\n\n/**\n * Create a time field (time only, no date component).\n * Format: \"HH:mm\"\n * @param options - Field configuration options\n * @returns A time field\n * @example db.time()\n */\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"time\", options);\n}\n\n/**\n * Create an enum field with a fixed set of allowed string values.\n * @param values - Array of allowed string values, or array of `{ value, description }` objects\n * @param options - Field configuration options\n * @returns An enum field\n * @example db.enum([\"active\", \"inactive\", \"suspended\"])\n * @example db.enum([\"small\", \"medium\", \"large\"], { optional: true })\n */\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorDBField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\n/**\n * Create a nested object field with sub-fields.\n * @param fields - Record of nested field definitions\n * @param options - Field configuration options\n * @returns A nested object field\n * @example db.object({ street: db.string(), city: db.string(), zip: db.string() })\n * @example db.object({ name: db.string() }, { optional: true })\n */\nfunction object<\n const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>,\n const Opt extends FieldOptions,\n>(fields: F, options?: Opt) {\n return createField(\"nested\", options, fields) as unknown as TailorDBField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n}\n\n/**\n * Creates a new TailorDBType instance.\n * @param name - Type name\n * @param fields - Field definitions\n * @param options - Type options\n * @param options.pluralForm - Optional plural form\n * @param options.description - Optional description\n * @returns A new TailorDBType\n */\nfunction createTailorDBType<\n // oxlint-disable-next-line no-explicit-any\n const Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributes,\n>(\n name: string,\n fields: Fields,\n options: { pluralForm?: string; description?: string },\n): TailorDBType<Fields, User> {\n let _description = options.description;\n let _settings: TypeFeatures = {};\n let _indexes: IndexDef<TailorDBType<Fields, User>>[] = [];\n const _permissions: RawPermissions = {};\n let _files: Record<string, string> = {};\n const _plugins: PluginAttachment[] = [];\n\n if (options.pluralForm) {\n if (name === options.pluralForm) {\n throw new Error(`The name and the plural form must be different. name=${name}`);\n }\n _settings.pluralForm = options.pluralForm;\n }\n\n const dbType: TailorDBType<Fields, User> = {\n name,\n fields: { ...fields },\n _output: null as unknown as InferFieldsOutput<Fields>,\n _description,\n\n get metadata(): TailorDBTypeMetadata {\n // Convert indexes to the format expected by the manifest\n const indexes: Record<string, { fields: string[]; unique?: boolean }> = {};\n if (_indexes.length > 0) {\n _indexes.forEach((index) => {\n const fieldNames = index.fields.map((field) => String(field));\n const key = index.name || `idx_${fieldNames.join(\"_\")}`;\n indexes[key] = {\n fields: fieldNames,\n unique: index.unique,\n };\n });\n }\n\n return {\n name: this.name,\n description: _description,\n settings: _settings,\n permissions: _permissions,\n files: _files,\n ...(Object.keys(indexes).length > 0 && { indexes }),\n };\n },\n\n hooks(hooks: Hooks<Fields>) {\n // `Hooks<Fields>` is strongly typed, but `Object.entries()` loses that information.\n // oxlint-disable-next-line no-explicit-any\n Object.entries(hooks).forEach(([fieldName, fieldHooks]: [string, any]) => {\n const field = this.fields[fieldName];\n if (field === undefined) throw new Error(`field not found: ${fieldName}`);\n (this.fields as Record<string, TailorAnyDBField>)[fieldName] = (\n field as TailorAnyDBField\n ).hooks(fieldHooks);\n });\n return this;\n },\n\n validate(validators: Validators<Fields>) {\n Object.entries(validators).forEach(([fieldName, fieldValidators]) => {\n const field = this.fields[fieldName] as TailorAnyDBField;\n\n const validators = fieldValidators as\n | FieldValidateInput<unknown>\n | FieldValidateInput<unknown>[];\n\n const isValidateConfig = (v: unknown): v is ValidateConfig<unknown> => {\n return Array.isArray(v) && v.length === 2 && typeof v[1] === \"string\";\n };\n\n let updatedField: TailorAnyDBField;\n if (Array.isArray(validators)) {\n if (isValidateConfig(validators)) {\n updatedField = field.validate(validators);\n } else {\n updatedField = field.validate(...validators);\n }\n } else {\n updatedField = field.validate(validators);\n }\n (this.fields as Record<string, TailorAnyDBField>)[fieldName] = updatedField;\n });\n return this;\n },\n\n features(features: Omit<TypeFeatures, \"pluralForm\">) {\n _settings = {\n ..._settings,\n ...features,\n };\n return this;\n },\n\n indexes(...indexes: IndexDef<TailorDBType<Fields, User>>[]) {\n _indexes = indexes;\n return this;\n },\n\n files<const F extends string>(files: Record<F, string> & FileKeyConflictError<Fields, User>) {\n _files = files;\n return this;\n },\n\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<TailorDBType<Fields, User>>> = TailorTypePermission<\n U,\n output<TailorDBType<Fields, User>>\n >,\n >(permission: P) {\n const ret = this as TailorDBType<Fields, U>;\n _permissions.record = permission as RawPermissions[\"record\"];\n return ret;\n },\n\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(permission: P) {\n const ret = this as TailorDBType<Fields, U>;\n _permissions.gql = permission as RawPermissions[\"gql\"];\n return ret;\n },\n\n description(description: string) {\n _description = description;\n this._description = description;\n return this;\n },\n\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options?: Opt) {\n const result = {} as Record<K, TailorAnyDBField>;\n for (const key of keys) {\n const field = this.fields[key] as TailorAnyDBField;\n if (options) {\n result[key] = field.clone(options);\n } else {\n result[key] = field;\n }\n }\n // oxlint-disable-next-line no-explicit-any\n return result as any;\n },\n\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K> {\n const keysSet = new Set(keys);\n const result = {} as Record<string, TailorAnyDBField>;\n for (const key in this.fields) {\n if (Object.hasOwn(this.fields, key) && !keysSet.has(key as unknown as K)) {\n result[key] = this.fields[key] as TailorAnyDBField;\n }\n }\n return result as Omit<Fields, K>;\n },\n\n get plugins(): PluginAttachment[] {\n return _plugins;\n },\n\n plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: {\n [K in P]: PluginConfigs<keyof Fields & string>[K];\n }): TailorDBType<Fields, User> {\n for (const [pluginId, pluginConfig] of Object.entries(config)) {\n _plugins.push({ pluginId, config: pluginConfig });\n }\n return this;\n },\n };\n\n return brandValue(dbType, \"tailordb-type\");\n}\n\nconst idField = uuid();\ntype idField = typeof idField;\ntype DBTable<F extends { id?: never } & Record<string, TailorAnyDBField>> = TailorDBInstance<\n { id: idField } & F\n>;\n\n/**\n * Creates a new database table with the specified fields.\n * An `id` field (UUID) is automatically added to every table.\n * @param name - The name of the table, or a tuple of [name, pluralForm]\n * @param fields - The field definitions for the table\n * @returns A new TailorDB table instance\n * @example\n * export const user = db.table(\"User\", {\n * name: db.string(),\n * email: db.string(),\n * age: db.int({ optional: true }),\n * role: db.enum([\"admin\", \"member\"]),\n * ...db.fields.timestamps(),\n * });\n * // Always export both the value and type:\n * export type user = typeof user;\n */\nfunction dbTable<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fields: F,\n): DBTable<F>;\n/**\n * Creates a new database table with the specified fields and description.\n * An `id` field (UUID) is automatically added to every table.\n * @param name - The name of the table, or a tuple of [name, pluralForm]\n * @param description - A description of the table\n * @param fields - The field definitions for the table\n * @returns A new TailorDB table instance\n */\nfunction dbTable<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n description: string,\n fields: F,\n): DBTable<F>;\nfunction dbTable<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fieldsOrDescription: string | F,\n fields?: F,\n): DBTable<F> {\n const typeName = Array.isArray(name) ? name[0] : name;\n const pluralForm = Array.isArray(name) ? name[1] : undefined;\n\n let description: string | undefined;\n let fieldDef: F;\n if (typeof fieldsOrDescription === \"string\") {\n description = fieldsOrDescription;\n fieldDef = fields as F;\n } else {\n fieldDef = fieldsOrDescription;\n }\n return createTailorDBType<{ id: idField } & F>(\n typeName,\n {\n id: idField,\n ...fieldDef,\n },\n { pluralForm, description },\n ) as DBTable<F>;\n}\n\n/** TailorDB schema builder utilities for defining tables and fields. */\nexport const db = {\n table: dbTable,\n uuid,\n string,\n bool,\n int,\n float,\n decimal,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n fields: {\n /**\n * Creates standard timestamp fields (createdAt, updatedAt) with auto-hooks.\n * createdAt and updatedAt are set on create.\n * User-specified timestamp values are respected when provided (e.g. seeding\n * historical records); the current time is used only when the value is omitted.\n * @returns An object with createdAt and updatedAt fields\n * @example\n * const model = db.table(\"Model\", {\n * name: db.string(),\n * ...db.fields.timestamps(),\n * });\n */\n timestamps: () => ({\n createdAt: datetime()\n .hooks({ create: ({ value }) => value ?? new Date() })\n .description(\"Record creation timestamp\"),\n updatedAt: datetime()\n .hooks({\n create: ({ value }) => value ?? new Date(),\n update: () => new Date(),\n })\n .description(\"Record update timestamp\"),\n }),\n },\n};\n"],"mappings":";;;;;AA4YA,SAAS,qBACP,QAC8B;CAC9B,OAAO,OAAO,OAAO,SAAS;AAChC;AA4DA,SAAS,oBACP,MACA,SACA,QACA,QACQ;CACR,OAAO,2BAA2B,MAAM,SAAS,QAAQ,MAAM;AACjE;AAEA,SAAS,2BAKP,MACA,SACA,QACA,QACuD;CAIvD,MAAM,YAA6B,EAAE,UAAU,KAAK;CACpD,IAAI;CAEJ,IAAI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;CACN;CACA,QAAQ;;;;;;;;;;;;;AAaN,mBAAmB;EACjB,WAAW,SAAS,CAAC,CAClB,MAAM,EAAE,SAAS,EAAE,YAAY,yBAAS,IAAI,KAAK,EAAE,CAAC,CAAC,CACrD,YAAY,2BAA2B;EAC1C,WAAW,SAAS,CAAC,CAClB,MAAM;GACL,SAAS,EAAE,YAAY,yBAAS,IAAI,KAAK;GACzC,8BAAc,IAAI,KAAK;EACzB,CAAC,CAAC,CACD,YAAY,yBAAyB;CAC1C,GACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
|
|
2
|
-
import * as fs from "node:fs";
|
|
3
2
|
import * as path from "pathe";
|
|
3
|
+
import * as fs from "node:fs";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/shared/user-agent.ts
|
|
6
6
|
/**
|
|
@@ -11,7 +11,7 @@ import * as path from "pathe";
|
|
|
11
11
|
* @returns User-Agent header value
|
|
12
12
|
*/
|
|
13
13
|
function userAgentFromVersion(version) {
|
|
14
|
-
return `tailor
|
|
14
|
+
return `tailor/${version}`;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Build the User-Agent string for CLI requests.
|
|
@@ -86,4 +86,4 @@ function tightenSecretFilePermissions(filePath) {
|
|
|
86
86
|
|
|
87
87
|
//#endregion
|
|
88
88
|
export { userAgentFromVersion as a, userAgent as i, tightenSecretFilePermissions as n, writeSecretFile as r, ensureSecretDir as t };
|
|
89
|
-
//# sourceMappingURL=secret-file-
|
|
89
|
+
//# sourceMappingURL=secret-file-aoNXJmKa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-file-aoNXJmKa.mjs","names":[],"sources":["../src/cli/shared/user-agent.ts","../src/cli/shared/secret-file.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","import * as fs from \"node:fs\";\nimport * as path from \"pathe\";\n\nconst DIR_MODE = 0o700;\nconst FILE_MODE = 0o600;\n\n/**\n * Best-effort chmod that only fires when the current mode differs from the\n * target. No-op on Windows (where POSIX mode bits are advisory and ACLs\n * govern access) and on missing paths / permission errors.\n * @param target - Path to chmod\n * @param mode - Desired POSIX mode bits\n */\nfunction chmodIfDifferent(target: string, mode: number): void {\n if (process.platform === \"win32\") return;\n try {\n if ((fs.statSync(target).mode & 0o777) !== mode) {\n fs.chmodSync(target, mode);\n }\n } catch {\n // Missing path or permission error — best-effort.\n }\n}\n\n/**\n * Write a file that may contain secrets with restrictive permissions.\n * Creates the parent directory with 0o700 and the file with 0o600 on POSIX\n * systems so other users on the host cannot read access tokens, refresh\n * tokens, or crash report payloads. On Windows the POSIX mode bits are\n * effectively ignored and ACLs govern access, so the chmod calls are\n * best-effort and silently skipped.\n * @param filePath - Absolute path to write\n * @param content - File content\n */\nexport function writeSecretFile(filePath: string, content: string | Buffer): void {\n ensureSecretDir(path.dirname(filePath));\n fs.writeFileSync(filePath, content, { mode: FILE_MODE });\n chmodIfDifferent(filePath, FILE_MODE);\n}\n\n/**\n * Ensure a directory exists with 0o700 permissions on POSIX systems.\n * `mkdirSync({ recursive: true })` does not chmod existing directories,\n * so this also tightens permissions on directories that were previously\n * created with looser modes.\n * @param dir - Directory path\n */\nexport function ensureSecretDir(dir: string): void {\n fs.mkdirSync(dir, { recursive: true, mode: DIR_MODE });\n chmodIfDifferent(dir, DIR_MODE);\n}\n\n/**\n * Tighten an existing file and its parent directory to secret-file modes\n * (0o600 / 0o700) if they are looser. Used by read paths that may not\n * trigger a subsequent write, so that legacy world-readable files are\n * still secured the next time the CLI runs. Silent no-op on Windows and\n * on missing files / permission errors.\n * @param filePath - Absolute path that should be 0o600 and live under a 0o700 directory\n */\nexport function tightenSecretFilePermissions(filePath: string): void {\n chmodIfDifferent(filePath, FILE_MODE);\n chmodIfDifferent(path.dirname(filePath), DIR_MODE);\n}\n"],"mappings":";;;;;;;;;;;;AASA,SAAgB,qBAAqB,SAAyB;CAC5D,OAAO,UAAU;AACnB;;;;;;;;;AAUA,eAAsB,YAAY;CAEhC,OAAO,sBAAqB,MADF,gBAAgB,EACH,CAAC,WAAW,SAAS;AAC9D;;;;ACrBA,MAAM,WAAW;AACjB,MAAM,YAAY;;;;;;;;AASlB,SAAS,iBAAiB,QAAgB,MAAoB;CAC5D,IAAI,QAAQ,aAAa,SAAS;CAClC,IAAI;EACF,KAAK,GAAG,SAAS,MAAM,CAAC,CAAC,OAAO,SAAW,MACzC,GAAG,UAAU,QAAQ,IAAI;CAE7B,QAAQ,CAER;AACF;;;;;;;;;;;AAYA,SAAgB,gBAAgB,UAAkB,SAAgC;CAChF,gBAAgB,KAAK,QAAQ,QAAQ,CAAC;CACtC,GAAG,cAAc,UAAU,SAAS,EAAE,MAAM,UAAU,CAAC;CACvD,iBAAiB,UAAU,SAAS;AACtC;;;;;;;;AASA,SAAgB,gBAAgB,KAAmB;CACjD,GAAG,UAAU,KAAK;EAAE,WAAW;EAAM,MAAM;CAAS,CAAC;CACrD,iBAAiB,KAAK,QAAQ;AAChC;;;;;;;;;AAUA,SAAgB,6BAA6B,UAAwB;CACnE,iBAAiB,UAAU,SAAS;CACpC,iBAAiB,KAAK,QAAQ,QAAQ,GAAG,QAAQ;AACnD"}
|