@tailor-platform/sdk 2.0.0-next.3 → 2.0.0-next.5
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 +142 -0
- package/dist/aigateway-DR4Kwuik.mjs +9 -0
- package/dist/{aigateway-B3oZZE6v.mjs.map → aigateway-DR4Kwuik.mjs.map} +1 -1
- package/dist/{application-eHp9jXld.mjs → application-Bf8wxOi6.mjs} +701 -597
- package/dist/application-Bf8wxOi6.mjs.map +1 -0
- package/dist/application-CUkjzfij.mjs +3 -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 +2 -1
- package/dist/cli/cache/store.d.mts +1 -1
- package/dist/cli/commands/api/index.d.mts +1 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +5 -1
- package/dist/cli/commands/deploy/application.d.mts +7 -1
- package/dist/cli/commands/deploy/apply-phases.d.mts +14 -1
- package/dist/cli/commands/deploy/auth.d.mts +5 -1
- package/dist/cli/commands/deploy/deploy.d.mts +5 -0
- package/dist/cli/commands/deploy/executor.d.mts +7 -1
- package/dist/cli/commands/deploy/function-registry.d.mts +5 -0
- package/dist/cli/commands/deploy/idp.d.mts +5 -1
- package/dist/cli/commands/deploy/resolver.d.mts +5 -1
- package/dist/cli/commands/deploy/secret-manager.d.mts +5 -1
- package/dist/cli/commands/deploy/staticwebsite.d.mts +5 -1
- package/dist/cli/commands/deploy/tailordb/index.d.mts +8 -1
- package/dist/cli/commands/deploy/types.d.mts +3 -1
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +3 -0
- package/dist/cli/commands/deploy/workflow.d.mts +4 -1
- package/dist/cli/commands/executor/get.d.mts +0 -1
- package/dist/cli/commands/executor/jobs.d.mts +0 -1
- package/dist/cli/commands/executor/list.d.mts +0 -1
- package/dist/cli/commands/executor/transform.d.mts +1 -0
- package/dist/cli/commands/executor/trigger.d.mts +0 -1
- package/dist/cli/commands/executor/webhook.d.mts +0 -1
- package/dist/cli/commands/function/get.d.mts +0 -1
- package/dist/cli/commands/function/list.d.mts +0 -1
- package/dist/cli/commands/function/transform.d.mts +1 -0
- package/dist/cli/commands/generate/service.d.mts +5 -1
- package/dist/cli/commands/machineuser/list.d.mts +0 -1
- package/dist/cli/commands/machineuser/token.d.mts +0 -1
- package/dist/cli/commands/oauth2client/get.d.mts +0 -1
- package/dist/cli/commands/oauth2client/list.d.mts +0 -1
- package/dist/cli/commands/oauth2client/transform.d.mts +1 -0
- package/dist/cli/commands/organization/folder/create.d.mts +0 -1
- package/dist/cli/commands/organization/folder/delete.d.mts +0 -1
- package/dist/cli/commands/organization/folder/get.d.mts +0 -1
- package/dist/cli/commands/organization/folder/list.d.mts +0 -1
- package/dist/cli/commands/organization/folder/update.d.mts +0 -1
- package/dist/cli/commands/organization/get.d.mts +0 -1
- package/dist/cli/commands/organization/list.d.mts +0 -1
- package/dist/cli/commands/organization/transform.d.mts +2 -0
- package/dist/cli/commands/organization/tree.d.mts +0 -1
- package/dist/cli/commands/organization/update.d.mts +0 -1
- package/dist/cli/commands/remove.d.mts +0 -1
- package/dist/cli/commands/show.d.mts +9 -4
- package/dist/cli/commands/tailordb/migrate/config.d.mts +0 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +16 -3
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +0 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +6 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
- package/dist/cli/commands/tailordb/truncate.d.mts +0 -1
- package/dist/cli/commands/workflow/executions.d.mts +0 -1
- package/dist/cli/commands/workflow/get.d.mts +2 -1
- package/dist/cli/commands/workflow/list.d.mts +0 -1
- package/dist/cli/commands/workflow/resume.d.mts +0 -1
- package/dist/cli/commands/workflow/start.d.mts +0 -1
- package/dist/cli/commands/workflow/status.d.mts +1 -0
- package/dist/cli/commands/workflow/transform.d.mts +1 -0
- package/dist/cli/commands/workflow/wait.d.mts +0 -1
- package/dist/cli/commands/workflow/waiter.d.mts +1 -1
- package/dist/cli/commands/workspace/app/health.d.mts +0 -1
- package/dist/cli/commands/workspace/app/list.d.mts +0 -1
- package/dist/cli/commands/workspace/app/transform.d.mts +2 -0
- package/dist/cli/commands/workspace/create.d.mts +0 -1
- package/dist/cli/commands/workspace/delete.d.mts +0 -1
- package/dist/cli/commands/workspace/get.d.mts +0 -1
- package/dist/cli/commands/workspace/list.d.mts +0 -1
- package/dist/cli/commands/workspace/restore.d.mts +0 -1
- package/dist/cli/commands/workspace/transform.d.mts +2 -0
- package/dist/cli/commands/workspace/user/invite.d.mts +0 -1
- package/dist/cli/commands/workspace/user/list.d.mts +0 -1
- package/dist/cli/commands/workspace/user/remove.d.mts +0 -1
- package/dist/cli/commands/workspace/user/transform.d.mts +1 -0
- package/dist/cli/commands/workspace/user/update.d.mts +0 -1
- package/dist/cli/index.d.mts +6 -3
- package/dist/cli/index.mjs +273 -104
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +4 -2
- package/dist/cli/lib.mjs +4 -4
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/query/index.d.mts +4 -1
- package/dist/cli/services/application.d.mts +12 -1
- package/dist/cli/services/auth/service.d.mts +2 -0
- package/dist/cli/services/executor/service.d.mts +1 -1
- package/dist/cli/services/http-adapter/bundler.d.mts +3 -1
- package/dist/cli/services/http-adapter/service.d.mts +2 -1
- package/dist/cli/services/resolver/service.d.mts +1 -1
- package/dist/cli/services/tailordb/service.d.mts +3 -1
- package/dist/cli/services/workflow/bundler.d.mts +2 -1
- package/dist/cli/services/workflow/service.d.mts +1 -1
- package/dist/cli/shared/args.d.mts +1 -1
- package/dist/cli/shared/client.d.mts +1 -1
- package/dist/cli/shared/config-loader.d.mts +0 -1
- package/dist/cli/shared/context.d.mts +2 -1
- package/dist/cli/shared/script-executor.d.mts +0 -1
- package/dist/cli/shared/seed-chunker.d.mts +7 -3
- package/dist/cli/shared/type-generator.d.mts +0 -1
- package/dist/cli/ts-hook.mjs +43 -13
- package/dist/completion/zsh-worker.zsh +10 -10
- package/dist/configure/config/index.d.mts +0 -1
- package/dist/configure/config/types.d.mts +3 -1
- package/dist/configure/index.d.mts +17 -5
- package/dist/configure/index.mjs +309 -5
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +0 -1
- package/dist/configure/services/aigateway/types.d.mts +0 -1
- package/dist/configure/services/auth/index.d.mts +0 -1
- package/dist/configure/services/auth/types.d.mts +15 -14
- package/dist/configure/services/executor/executor.d.mts +1 -1
- package/dist/configure/services/executor/index.d.mts +1 -0
- package/dist/configure/services/executor/operation.d.mts +2 -2
- package/dist/configure/services/executor/trigger/event.d.mts +0 -1
- package/dist/configure/services/executor/trigger/index.d.mts +0 -1
- package/dist/configure/services/executor/trigger/schedule.d.mts +0 -1
- package/dist/configure/services/executor/trigger/webhook.d.mts +0 -1
- package/dist/configure/services/http-adapter/http-adapter.d.mts +1 -2
- package/dist/configure/services/idp/index.d.mts +1 -5
- package/dist/configure/services/idp/permission.d.mts +4 -5
- package/dist/configure/services/idp/types.d.mts +0 -1
- package/dist/configure/services/index.d.mts +8 -1
- package/dist/configure/services/resolver/resolver.d.mts +1 -0
- package/dist/configure/services/resolver/types.d.mts +0 -1
- package/dist/configure/services/secrets/index.d.mts +0 -1
- package/dist/configure/services/secrets/types.d.mts +0 -1
- package/dist/configure/services/staticwebsite/index.d.mts +0 -1
- package/dist/configure/services/staticwebsite/types.d.mts +0 -1
- package/dist/configure/services/tailordb/permission.d.mts +4 -5
- package/dist/configure/services/tailordb/schema.d.mts +104 -68
- package/dist/configure/services/tailordb/types.d.mts +66 -17
- package/dist/configure/services/workflow/execution-policy.d.mts +70 -0
- package/dist/configure/services/workflow/execution-policy.types.d.mts +103 -0
- package/dist/configure/services/workflow/index.d.mts +4 -1
- package/dist/configure/services/workflow/job.d.mts +7 -3
- package/dist/configure/services/workflow/wait-point.d.mts +0 -1
- package/dist/configure/services/workflow/workflow.d.mts +1 -1
- package/dist/configure/types/field-runtime.d.mts +0 -1
- package/dist/configure/types/field.d.mts +1 -2
- package/dist/configure/types/field.types.d.mts +6 -45
- package/dist/configure/types/index.d.mts +1 -0
- package/dist/configure/types/type.d.mts +1 -2
- package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
- package/dist/{context-Bd266-ru.mjs.map → context-DYQVYWqZ.mjs.map} +1 -1
- 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-DhwZj0RB.mjs → globals-BjhJJ2dN.mjs} +2 -2
- 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-Bx25ZBdN.mjs → idp-RA_swu-h.mjs} +4 -5
- package/dist/idp-RA_swu-h.mjs.map +1 -0
- package/dist/kysely/index.d.mts +3 -4
- package/dist/{kysely-type-5eAChaHO.mjs → kysely-type-DqIRgDYR.mjs} +4 -5
- package/dist/kysely-type-DqIRgDYR.mjs.map +1 -0
- package/dist/parser/service/auth/index.d.mts +1 -1
- package/dist/parser/service/auth/schema.d.mts +2 -0
- package/dist/parser/service/http-adapter/index.d.mts +1 -1
- package/dist/parser/service/idp/types.d.mts +1 -0
- package/dist/parser/service/tailordb/types.d.mts +6 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +0 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +0 -1
- package/dist/plugin/builtin/file-utils/index.mjs +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +0 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +0 -1
- package/dist/plugin/get-generated-type.d.mts +0 -1
- package/dist/plugin/manager.d.mts +2 -1
- package/dist/plugin/types.d.mts +0 -1
- package/dist/plugin/with-context.d.mts +0 -1
- package/dist/{register-ts-hook-ZpBacA07.mjs → register-ts-hook-BhzVkej0.mjs} +799 -446
- package/dist/register-ts-hook-BhzVkej0.mjs.map +1 -0
- package/dist/{registry-DH4m7eYo.mjs → registry-BSbq6SPo.mjs} +4 -3
- package/dist/registry-BSbq6SPo.mjs.map +1 -0
- package/dist/resource_pb-BRv7AMXK.mjs +49 -0
- package/dist/resource_pb-BRv7AMXK.mjs.map +1 -0
- package/dist/runtime/aigateway.d.mts +5 -15
- package/dist/runtime/aigateway.mjs +2 -2
- package/dist/runtime/authconnection.d.mts +5 -15
- package/dist/runtime/authconnection.mjs +2 -2
- package/dist/runtime/context.d.mts +14 -6
- package/dist/runtime/context.mjs +2 -2
- package/dist/runtime/file.d.mts +14 -54
- package/dist/runtime/file.mjs +2 -2
- package/dist/runtime/globals.d.mts +1 -2
- package/dist/runtime/iconv.d.mts +5 -53
- package/dist/runtime/iconv.mjs +2 -2
- package/dist/runtime/idp.d.mts +13 -70
- package/dist/runtime/idp.mjs +2 -2
- package/dist/runtime/index.d.mts +11 -12
- package/dist/runtime/index.mjs +9 -9
- package/dist/runtime/secretmanager.d.mts +7 -20
- package/dist/runtime/secretmanager.mjs +2 -2
- package/dist/runtime/types.d.mts +9 -4
- package/dist/runtime/workflow.d.mts +42 -41
- package/dist/runtime/workflow.mjs +2 -2
- package/dist/{schema-89dYxNC2.mjs → schema-iCd1ugGp.mjs} +257 -54
- package/dist/schema-iCd1ugGp.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 +3 -2
- package/dist/service-BT0GPd01.mjs +3 -0
- package/dist/{service-ufH7sS8o.mjs → service-CzZEVrp9.mjs} +14 -9
- package/dist/service-CzZEVrp9.mjs.map +1 -0
- package/dist/{service_pb-CIrhGwHk.mjs → service_pb-Bk7dL-yT.mjs} +27 -50
- package/dist/service_pb-Bk7dL-yT.mjs.map +1 -0
- package/dist/{service_pb-DjwIn4jO.mjs → service_pb-DZkfjB_6.mjs} +1 -1
- package/dist/tailor-proto/src/tailor/v1/aigateway_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/aigateway_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/application_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/auth_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/events_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/events_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/executor_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/function_registry_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/http_adapter_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/idp_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/idp_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/metadata_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/metadata_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/meter_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/pipeline_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/pipeline_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/secret_manager_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/secret_manager_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -2
- package/dist/tailor-proto/src/tailor/v1/stateflow_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/stateflow_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/staticwebsite_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/tailordb_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/tailordb_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +29 -10
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +35 -2
- package/dist/tailor-proto/src/tailor/v1/workspace_pb.d.mts +0 -1
- package/dist/tailor-proto/src/tailor/v1/workspace_resource_pb.d.mts +0 -1
- package/dist/types/aigateway.generated.d.mts +5 -2
- package/dist/types/auth-connection.generated.d.mts +24 -11
- package/dist/types/auth.generated.d.mts +115 -84
- package/dist/types/executor.generated.d.mts +76 -84
- package/dist/types/helpers.d.mts +7 -6
- package/dist/types/http-adapter.generated.d.mts +11 -5
- package/dist/types/idp.generated.d.mts +536 -524
- package/dist/types/resolver.generated.d.mts +26 -11
- package/dist/types/staticwebsite.generated.d.mts +7 -3
- package/dist/types/tailordb.generated.d.mts +57 -29
- package/dist/types/workflow.generated.d.mts +9 -4
- package/dist/utils/test/index.d.mts +1 -2
- package/dist/utils/test/index.mjs +36 -10
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/utils/test/mock.d.mts +0 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +1 -1
- package/dist/vitest/index.mjs +11 -11
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock-kysely.d.mts +0 -1
- package/dist/vitest/mocks/aigateway.d.mts +2 -2
- package/dist/vitest/mocks/authconnection.d.mts +2 -2
- package/dist/vitest/mocks/idp.d.mts +2 -2
- package/dist/vitest/mocks/secretmanager.d.mts +3 -1
- package/dist/vitest/mocks/tailordb.d.mts +6 -3
- package/dist/vitest/mocks/workflow.d.mts +15 -8
- package/dist/vitest/setup.mjs +1 -1
- package/dist/vitest/workflow-local.d.mts +1 -0
- package/dist/workflow-GNuSnsTx.mjs +22 -0
- package/dist/workflow-GNuSnsTx.mjs.map +1 -0
- package/docs/cli/auth.md +3 -3
- package/docs/cli/setup.md +9 -9
- package/docs/cli-reference.md +7 -6
- package/docs/configuration.md +24 -0
- package/docs/migration/v2.md +317 -0
- package/docs/plugin/custom.md +4 -4
- package/docs/plugin/index.md +2 -2
- package/docs/runtime.md +4 -2
- package/docs/services/aigateway.md +2 -0
- package/docs/services/auth.md +2 -2
- package/docs/services/resolver.md +1 -1
- package/docs/services/tailordb-migration.md +1 -1
- package/docs/services/tailordb.md +125 -93
- package/docs/services/workflow.md +78 -0
- package/package.json +22 -22
- package/dist/aigateway-B3oZZE6v.mjs +0 -15
- package/dist/application-D2hSK1ZL.mjs +0 -3
- package/dist/application-eHp9jXld.mjs.map +0 -1
- package/dist/authconnection-BGQM8FZI.mjs +0 -15
- package/dist/authconnection-BGQM8FZI.mjs.map +0 -1
- package/dist/cli/shared/trigger-context.d.mts +0 -1
- package/dist/field-runtime-CAnh_oow.mjs +0 -183
- package/dist/field-runtime-CAnh_oow.mjs.map +0 -1
- package/dist/file-BbdFGdMV.mjs.map +0 -1
- package/dist/file-utils-CYZnO1pX.mjs.map +0 -1
- package/dist/globals-DhwZj0RB.mjs.map +0 -1
- package/dist/iconv-D2vi8G36.mjs +0 -63
- package/dist/iconv-D2vi8G36.mjs.map +0 -1
- package/dist/idp-Bx25ZBdN.mjs.map +0 -1
- package/dist/kysely-type-5eAChaHO.mjs.map +0 -1
- package/dist/register-ts-hook-ZpBacA07.mjs.map +0 -1
- package/dist/registry-DH4m7eYo.mjs.map +0 -1
- package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
- package/dist/schema-89dYxNC2.mjs.map +0 -1
- package/dist/secretmanager-BVxw3ih_.mjs +0 -24
- package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
- package/dist/service-CkIwEctX.mjs +0 -3
- package/dist/service-ufH7sS8o.mjs.map +0 -1
- package/dist/service_pb-CIrhGwHk.mjs.map +0 -1
- package/dist/types-C-lQ4se3.mjs +0 -4
- package/dist/types-CXF2OYdR.mjs +0 -199
- package/dist/types-CXF2OYdR.mjs.map +0 -1
- package/dist/workflow-Bo59B75H.mjs +0 -50
- package/dist/workflow-Bo59B75H.mjs.map +0 -1
|
@@ -29,7 +29,7 @@ Define TailorDB Types in files matching glob patterns specified in `tailor.confi
|
|
|
29
29
|
import { db } from "@tailor-platform/sdk";
|
|
30
30
|
|
|
31
31
|
// Export both value and type
|
|
32
|
-
export const user = db.
|
|
32
|
+
export const user = db.table("User", {
|
|
33
33
|
name: db.string(),
|
|
34
34
|
email: db.string().unique(),
|
|
35
35
|
age: db.int(),
|
|
@@ -38,7 +38,7 @@ export const user = db.type("User", {
|
|
|
38
38
|
export type user = typeof user;
|
|
39
39
|
|
|
40
40
|
// You can define multiple types in the same file
|
|
41
|
-
export const role = db.
|
|
41
|
+
export const role = db.table("Role", {
|
|
42
42
|
name: db.string().unique(),
|
|
43
43
|
});
|
|
44
44
|
export type role = typeof role;
|
|
@@ -47,7 +47,7 @@ export type role = typeof role;
|
|
|
47
47
|
Specify plural form by passing an array as first argument:
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
|
-
db.
|
|
50
|
+
db.table(["User", "UserList"], {
|
|
51
51
|
name: db.string(),
|
|
52
52
|
});
|
|
53
53
|
```
|
|
@@ -55,7 +55,7 @@ db.type(["User", "UserList"], {
|
|
|
55
55
|
Pass a description as second argument:
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
58
|
-
db.
|
|
58
|
+
db.table("User", "User in the system", {
|
|
59
59
|
name: db.string(),
|
|
60
60
|
});
|
|
61
61
|
```
|
|
@@ -174,11 +174,11 @@ db.string().unique();
|
|
|
174
174
|
Add a relation to field with automatic index and foreign key constraint:
|
|
175
175
|
|
|
176
176
|
```typescript
|
|
177
|
-
const role = db.
|
|
177
|
+
const role = db.table("Role", {
|
|
178
178
|
name: db.string(),
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
-
const user = db.
|
|
181
|
+
const user = db.table("User", {
|
|
182
182
|
name: db.string(),
|
|
183
183
|
roleId: db.uuid().relation({
|
|
184
184
|
type: "n-1",
|
|
@@ -190,7 +190,7 @@ const user = db.type("User", {
|
|
|
190
190
|
For one-to-one relations, use `type: "1-1"`:
|
|
191
191
|
|
|
192
192
|
```typescript
|
|
193
|
-
const userProfile = db.
|
|
193
|
+
const userProfile = db.table("UserProfile", {
|
|
194
194
|
userId: db.uuid().relation({
|
|
195
195
|
type: "1-1",
|
|
196
196
|
toward: { type: user },
|
|
@@ -202,7 +202,7 @@ const userProfile = db.type("UserProfile", {
|
|
|
202
202
|
For foreign key constraint without creating a relation, use `type: "keyOnly"`:
|
|
203
203
|
|
|
204
204
|
```typescript
|
|
205
|
-
const user = db.
|
|
205
|
+
const user = db.table("User", {
|
|
206
206
|
roleId: db.uuid().relation({
|
|
207
207
|
type: "keyOnly",
|
|
208
208
|
toward: { type: role },
|
|
@@ -213,22 +213,25 @@ const user = db.type("User", {
|
|
|
213
213
|
Create relations against different fields using `toward.key`:
|
|
214
214
|
|
|
215
215
|
```typescript
|
|
216
|
-
const user = db.
|
|
216
|
+
const user = db.table("User", {
|
|
217
217
|
email: db.string().unique(),
|
|
218
218
|
});
|
|
219
219
|
|
|
220
|
-
const userProfile = db.
|
|
220
|
+
const userProfile = db.table("UserProfile", {
|
|
221
221
|
userEmail: db.string().relation({
|
|
222
222
|
type: "1-1",
|
|
223
|
-
toward: { type: user, key: "email" },
|
|
223
|
+
toward: { type: user, key: "email", as: "user" },
|
|
224
224
|
}),
|
|
225
225
|
});
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
+
`userEmail` does not end in `ID`, `Id`, or `id`, so this example specifies the forward relation
|
|
229
|
+
name with `toward.as`.
|
|
230
|
+
|
|
228
231
|
Customize relation names using `toward.as` / `backward` options:
|
|
229
232
|
|
|
230
233
|
```typescript
|
|
231
|
-
const userProfile = db.
|
|
234
|
+
const userProfile = db.table("UserProfile", {
|
|
232
235
|
userId: db.uuid().relation({
|
|
233
236
|
type: "1-1",
|
|
234
237
|
toward: { type: user, as: "base" },
|
|
@@ -255,154 +258,165 @@ type User {
|
|
|
255
258
|
- `backward` - Customizes the field name for accessing this type from the related type
|
|
256
259
|
|
|
257
260
|
Relation names share the same GraphQL field namespace as fields, files, and other relations on
|
|
258
|
-
the
|
|
259
|
-
|
|
260
|
-
|
|
261
|
+
the table. The SDK rejects duplicate or empty relation names. When `toward.as` is omitted, the
|
|
262
|
+
default forward name comes from the relation field name with a trailing `ID`, `Id`, or `id`
|
|
263
|
+
removed. This lets multiple fields point to the same target table with distinct forward names:
|
|
261
264
|
|
|
262
265
|
```typescript
|
|
263
|
-
const post = db.
|
|
266
|
+
const post = db.table("Post", {
|
|
264
267
|
authorID: db.uuid().relation({
|
|
265
268
|
type: "n-1",
|
|
266
|
-
toward: { type: user
|
|
269
|
+
toward: { type: user },
|
|
267
270
|
backward: "authoredPosts",
|
|
268
271
|
}),
|
|
269
272
|
reviewerID: db.uuid().relation({
|
|
270
273
|
type: "n-1",
|
|
271
|
-
toward: { type: user
|
|
274
|
+
toward: { type: user },
|
|
272
275
|
backward: "reviewedPosts",
|
|
273
276
|
}),
|
|
274
277
|
});
|
|
275
278
|
```
|
|
276
279
|
|
|
280
|
+
These fields generate the forward names `author` and `reviewer`. A relation field without one of
|
|
281
|
+
the recognized ID suffixes needs an explicit `toward.as`, because its generated forward name
|
|
282
|
+
would conflict with the field itself.
|
|
283
|
+
|
|
277
284
|
Use `toward.as` or `backward` when a generated relation name would conflict with an existing
|
|
278
|
-
field, files entry, or relation on the same
|
|
285
|
+
field, files entry, or relation on the same table.
|
|
279
286
|
|
|
280
287
|
### Hooks
|
|
281
288
|
|
|
282
|
-
Add hooks to execute functions during data creation or update.
|
|
289
|
+
Add hooks to execute functions during data creation or update.
|
|
290
|
+
|
|
291
|
+
#### Field-level Hooks
|
|
292
|
+
|
|
293
|
+
Set hooks directly on individual fields.
|
|
283
294
|
|
|
284
|
-
|
|
285
|
-
|
|
295
|
+
Create hooks receive:
|
|
296
|
+
|
|
297
|
+
- `input`: The field value from the input (null when not provided)
|
|
286
298
|
- `invoker`: Principal performing the operation
|
|
299
|
+
- `now`: Operation timestamp (`Date`), shared across all hooks in the same operation
|
|
287
300
|
|
|
288
|
-
|
|
301
|
+
Update hooks receive the same arguments plus:
|
|
289
302
|
|
|
290
|
-
|
|
303
|
+
- `oldValue`: The previous field value (null only for optional fields)
|
|
291
304
|
|
|
292
305
|
```typescript
|
|
293
306
|
db.string().hooks({
|
|
294
307
|
create: ({ invoker }) => invoker?.id ?? "",
|
|
295
|
-
update: ({
|
|
308
|
+
update: ({ input, oldValue }) => input ?? oldValue,
|
|
296
309
|
});
|
|
297
310
|
```
|
|
298
311
|
|
|
299
|
-
|
|
312
|
+
Field-level hooks operate on a single field and cannot access other fields. Use type-level hooks for cross-field logic.
|
|
300
313
|
|
|
301
314
|
#### Type-level Hooks
|
|
302
315
|
|
|
303
|
-
Set hooks
|
|
316
|
+
Set hooks across multiple fields using `db.table().hooks()`. The hook returns an object with the fields to override. When both field-level and type-level hooks exist for the same field, type-level hooks take priority.
|
|
317
|
+
|
|
318
|
+
Create hooks receive:
|
|
319
|
+
|
|
320
|
+
- `input`: The submitted record data. When field-level hooks or defaults exist, `input` reflects their applied results
|
|
321
|
+
- `invoker`: Principal performing the operation
|
|
322
|
+
- `now`: Operation timestamp (`Date`), shared across all hooks in the same operation
|
|
323
|
+
|
|
324
|
+
Update hooks receive the same arguments plus:
|
|
325
|
+
|
|
326
|
+
- `oldRecord`: The existing record (non-null)
|
|
304
327
|
|
|
305
328
|
```typescript
|
|
306
329
|
export const customer = db
|
|
307
|
-
.
|
|
330
|
+
.table("Customer", {
|
|
308
331
|
firstName: db.string(),
|
|
309
332
|
lastName: db.string(),
|
|
310
333
|
fullName: db.string(),
|
|
311
334
|
})
|
|
312
335
|
.hooks({
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
336
|
+
create: ({ input }) => ({
|
|
337
|
+
fullName: `${input.firstName} ${input.lastName}`,
|
|
338
|
+
}),
|
|
339
|
+
update: ({ input, oldRecord }) => ({
|
|
340
|
+
fullName: `${input.firstName ?? oldRecord.firstName} ${input.lastName ?? oldRecord.lastName}`,
|
|
341
|
+
}),
|
|
317
342
|
});
|
|
318
343
|
```
|
|
319
344
|
|
|
320
|
-
|
|
345
|
+
Use `now` to stamp several fields with the exact same instant:
|
|
321
346
|
|
|
322
347
|
```typescript
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
})
|
|
328
|
-
.hooks({
|
|
329
|
-
name: { create: ({ data }) => data.lastName }, // Type-level - ERROR
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
// OK - set hooks on different fields
|
|
333
|
-
export const user = db
|
|
334
|
-
.type("User", {
|
|
335
|
-
firstName: db.string().hooks({ create: () => "John" }), // Field-level on firstName
|
|
336
|
-
lastName: db.string(),
|
|
348
|
+
export const order = db
|
|
349
|
+
.table("Order", {
|
|
350
|
+
createdAt: db.datetime(),
|
|
351
|
+
updatedAt: db.datetime(),
|
|
337
352
|
})
|
|
338
353
|
.hooks({
|
|
339
|
-
|
|
354
|
+
create: ({ now }) => ({ createdAt: now, updatedAt: now }),
|
|
355
|
+
update: ({ now }) => ({ updatedAt: now }),
|
|
340
356
|
});
|
|
341
357
|
```
|
|
342
358
|
|
|
359
|
+
**Note:** `.hooks()` can only be called once on a type. Duplicate type-level calls fail at compile time and throw at runtime.
|
|
360
|
+
|
|
343
361
|
### Validation
|
|
344
362
|
|
|
345
|
-
Add validation rules to fields. Validators
|
|
363
|
+
Add validation rules to fields. Validators run after hooks.
|
|
346
364
|
|
|
347
|
-
- `value
|
|
348
|
-
- `data`: Entire record data after hook transformations (for accessing other field values)
|
|
349
|
-
- `invoker`: Principal performing the operation
|
|
365
|
+
**Note:** Custom validators run only when built-in type validation succeeds, so `value` always has the field's declared type. For array fields, the validator is called once with the complete array, not per element:
|
|
350
366
|
|
|
351
|
-
|
|
367
|
+
```typescript
|
|
368
|
+
// value is string[], not string
|
|
369
|
+
db.string({ array: true }).validate(({ value }) => value.length >= 2);
|
|
370
|
+
```
|
|
352
371
|
|
|
353
372
|
#### Field-level Validation
|
|
354
373
|
|
|
355
|
-
Set validators directly on individual fields:
|
|
374
|
+
Set validators directly on individual fields. Each validator receives `{ value }` (the field value after hooks) and returns an error message string to fail, or void to pass:
|
|
356
375
|
|
|
357
376
|
```typescript
|
|
358
377
|
db.string().validate(
|
|
359
|
-
({ value }) => value.includes("@"),
|
|
360
|
-
|
|
378
|
+
({ value }) => (value.includes("@") ? undefined : "Must contain @"),
|
|
379
|
+
({ value }) => (value.length >= 5 ? undefined : "Must be at least 5 characters"),
|
|
361
380
|
);
|
|
362
381
|
```
|
|
363
382
|
|
|
364
383
|
#### Type-level Validation
|
|
365
384
|
|
|
366
|
-
Set
|
|
385
|
+
Set a validator across all fields using `db.table().validate()`. The validator receives `{ newRecord, oldRecord, invoker }` and an `issues()` callback to report errors per field:
|
|
367
386
|
|
|
368
387
|
```typescript
|
|
369
388
|
export const user = db
|
|
370
|
-
.
|
|
389
|
+
.table("User", {
|
|
371
390
|
name: db.string(),
|
|
372
391
|
email: db.string(),
|
|
373
392
|
})
|
|
374
|
-
.validate({
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
393
|
+
.validate(({ newRecord }, issues) => {
|
|
394
|
+
if (newRecord.name.length <= 5) {
|
|
395
|
+
issues("name", "Name must be longer than 5 characters");
|
|
396
|
+
}
|
|
397
|
+
if (!newRecord.email.includes("@")) {
|
|
398
|
+
issues("email", "Must contain @");
|
|
399
|
+
}
|
|
380
400
|
});
|
|
381
401
|
```
|
|
382
402
|
|
|
383
|
-
|
|
403
|
+
### Defaults
|
|
404
|
+
|
|
405
|
+
Set a default value for a required field on create. The field becomes optional in the create input — the default fills in when no value is provided:
|
|
384
406
|
|
|
385
407
|
```typescript
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
name: db.string().validate(({ value }) => value.length > 0), // Field-level
|
|
390
|
-
})
|
|
391
|
-
.validate({
|
|
392
|
-
name: [({ value }) => value.length < 100, "Too long"], // Type-level - ERROR
|
|
393
|
-
});
|
|
408
|
+
db.int().default(0);
|
|
409
|
+
db.string().default("pending");
|
|
410
|
+
```
|
|
394
411
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
email: db.string(),
|
|
400
|
-
})
|
|
401
|
-
.validate({
|
|
402
|
-
email: [({ value }) => value.includes("@"), "Invalid email"], // Type-level on email
|
|
403
|
-
});
|
|
412
|
+
For datetime/date/time fields, pass `"now"` to use the operation timestamp:
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
db.datetime().default("now");
|
|
404
416
|
```
|
|
405
417
|
|
|
418
|
+
**Note:** `.validate()` can only be called once on a type. Duplicate type-level calls fail at compile time and throw at runtime.
|
|
419
|
+
|
|
406
420
|
### Vector Search
|
|
407
421
|
|
|
408
422
|
```typescript
|
|
@@ -426,7 +440,7 @@ db.string().serial({
|
|
|
426
440
|
### Common Fields
|
|
427
441
|
|
|
428
442
|
```typescript
|
|
429
|
-
export const user = db.
|
|
443
|
+
export const user = db.table("User", {
|
|
430
444
|
name: db.string(),
|
|
431
445
|
...db.fields.timestamps(),
|
|
432
446
|
});
|
|
@@ -436,10 +450,26 @@ export const user = db.type("User", {
|
|
|
436
450
|
|
|
437
451
|
## Type Modifiers
|
|
438
452
|
|
|
453
|
+
Type builder methods that set one type-level configuration can be called only once on the same type. Duplicate calls fail at compile time and throw at runtime. This applies to `.description()`, `.hooks()`, `.validate()`, `.features()`, `.indexes()`, `.files()`, `.permission()`, and `.gqlPermission()`.
|
|
454
|
+
|
|
455
|
+
Conditional assignment is still supported when only one branch calls the method:
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
let user = db.type("User", {
|
|
459
|
+
name: db.string(),
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
if (enableFiles) {
|
|
463
|
+
user = user.files({
|
|
464
|
+
avatar: "profile image",
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
439
469
|
### Composite Indexes
|
|
440
470
|
|
|
441
471
|
```typescript
|
|
442
|
-
db.
|
|
472
|
+
db.table("User", {
|
|
443
473
|
firstName: db.string(),
|
|
444
474
|
lastName: db.string(),
|
|
445
475
|
}).indexes({
|
|
@@ -452,7 +482,7 @@ db.type("User", {
|
|
|
452
482
|
### File Fields
|
|
453
483
|
|
|
454
484
|
```typescript
|
|
455
|
-
db.
|
|
485
|
+
db.table("User", {
|
|
456
486
|
name: db.string(),
|
|
457
487
|
}).files({
|
|
458
488
|
avatar: "profile image",
|
|
@@ -462,7 +492,7 @@ db.type("User", {
|
|
|
462
492
|
### Features
|
|
463
493
|
|
|
464
494
|
```typescript
|
|
465
|
-
db.
|
|
495
|
+
db.table("User", {
|
|
466
496
|
name: db.string(),
|
|
467
497
|
}).features({
|
|
468
498
|
aggregation: true,
|
|
@@ -475,7 +505,7 @@ db.type("User", {
|
|
|
475
505
|
Enable event publishing for a type to trigger executors on record changes:
|
|
476
506
|
|
|
477
507
|
```typescript
|
|
478
|
-
db.
|
|
508
|
+
db.table("User", {
|
|
479
509
|
name: db.string(),
|
|
480
510
|
}).features({
|
|
481
511
|
publishEvents: true,
|
|
@@ -494,7 +524,7 @@ db.type("User", {
|
|
|
494
524
|
|
|
495
525
|
```typescript
|
|
496
526
|
// publishEvents is automatically enabled because an executor uses this type
|
|
497
|
-
export const order = db.
|
|
527
|
+
export const order = db.table("Order", {
|
|
498
528
|
status: db.string(),
|
|
499
529
|
});
|
|
500
530
|
|
|
@@ -508,7 +538,7 @@ db.type("User", {
|
|
|
508
538
|
2. **Manual enable**: Enable event publishing for external consumers or debugging
|
|
509
539
|
|
|
510
540
|
```typescript
|
|
511
|
-
db.
|
|
541
|
+
db.table("AuditLog", {
|
|
512
542
|
action: db.string(),
|
|
513
543
|
}).features({
|
|
514
544
|
publishEvents: true, // Enable even without executor triggers
|
|
@@ -518,7 +548,7 @@ db.type("User", {
|
|
|
518
548
|
3. **Explicit disable**: Disable event publishing for a type that doesn't need it (error if executor uses it)
|
|
519
549
|
|
|
520
550
|
```typescript
|
|
521
|
-
db.
|
|
551
|
+
db.table("TempData", {
|
|
522
552
|
data: db.string(),
|
|
523
553
|
}).features({
|
|
524
554
|
publishEvents: false, // Explicitly disable
|
|
@@ -534,7 +564,7 @@ Extract subsets of fields from a `TailorDBType` for reuse in resolvers, executor
|
|
|
534
564
|
Select specific fields and optionally modify their properties:
|
|
535
565
|
|
|
536
566
|
```typescript
|
|
537
|
-
const user = db.
|
|
567
|
+
const user = db.table("User", {
|
|
538
568
|
id: db.uuid(),
|
|
539
569
|
name: db.string(),
|
|
540
570
|
email: db.string().unique(),
|
|
@@ -552,6 +582,8 @@ Available options:
|
|
|
552
582
|
| `optional` | Makes the selected fields optional |
|
|
553
583
|
| `array` | Makes the selected fields array types |
|
|
554
584
|
|
|
585
|
+
**Note:** The `array` option cannot change fields with custom validation — their validators expect the original value shape. Define a new field with a matching validator instead.
|
|
586
|
+
|
|
555
587
|
#### `omitFields(keys)`
|
|
556
588
|
|
|
557
589
|
Return all fields except the specified ones:
|
|
@@ -604,7 +636,7 @@ Configure Permission and GQLPermission. For details, see the [TailorDB Permissio
|
|
|
604
636
|
**Important**: Following the secure-by-default principle, all operations are denied if permissions are not configured. You must explicitly grant permissions for each operation (create, read, update, delete).
|
|
605
637
|
|
|
606
638
|
```typescript
|
|
607
|
-
db.
|
|
639
|
+
db.table("User", {
|
|
608
640
|
name: db.string(),
|
|
609
641
|
role: db.enum(["admin", "user"]).index(),
|
|
610
642
|
})
|
|
@@ -634,7 +666,7 @@ import {
|
|
|
634
666
|
unsafeAllowAllGqlPermission,
|
|
635
667
|
} from "@tailor-platform/sdk";
|
|
636
668
|
|
|
637
|
-
db.
|
|
669
|
+
db.table("User", {
|
|
638
670
|
name: db.string(),
|
|
639
671
|
})
|
|
640
672
|
.permission(unsafeAllowAllTypePermission)
|
|
@@ -351,6 +351,84 @@ export default createWorkflow({
|
|
|
351
351
|
});
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
+
## Execution Policies
|
|
355
|
+
|
|
356
|
+
Execution policies apply a per-key concurrency cap to workflow job function dispatches. Declare them at the workspace level and pass a matching key when triggering a job; the platform serializes dispatches that resolve to the same key and suspends any that would exceed the cap until slots free up.
|
|
357
|
+
|
|
358
|
+
### Declaring Policies
|
|
359
|
+
|
|
360
|
+
Use `defineWorkflowExecutionPolicies` with a builder callback. Property names supply the workspace-unique name and default key prefix verbatim, matching the mental model of `defineWaitPoints`. Override `name` or `key` in the body when the property identifier is not valid execution policy grammar or the key prefix needs to differ. Set `matchType: "prefix"` to register the prefix as a wildcard that matches every dispatch key starting with it (the default, `"exact"`, matches only a dispatch key equal to it).
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
import { defineWorkflowExecutionPolicies } from "@tailor-platform/sdk";
|
|
364
|
+
|
|
365
|
+
export const executionPolicies = defineWorkflowExecutionPolicies((define) => ({
|
|
366
|
+
/** Shared cap across every "premium" worker dispatch. */
|
|
367
|
+
premium: define({ concurrencyPolicy: { maxConcurrentExecutions: 5 } }),
|
|
368
|
+
/** Per-tenant cap: one pool per resolved tenant key. */
|
|
369
|
+
tenantApi: define({
|
|
370
|
+
name: "tenant-api",
|
|
371
|
+
matchType: "prefix",
|
|
372
|
+
concurrencyPolicy: { maxConcurrentExecutions: 3 },
|
|
373
|
+
}),
|
|
374
|
+
}));
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
For a single policy, use `defineWorkflowExecutionPolicy(name, def?)`; the key prefix defaults to `name` when `key` is omitted.
|
|
378
|
+
|
|
379
|
+
`concurrencyPolicy` is optional; when omitted, the policy registers the key as valid without a user-defined limit (platform safety nets still apply).
|
|
380
|
+
|
|
381
|
+
Register the policies on your config so the SDK creates them on the workspace during deploy:
|
|
382
|
+
|
|
383
|
+
```typescript
|
|
384
|
+
// tailor.config.ts
|
|
385
|
+
import { defineConfig } from "@tailor-platform/sdk";
|
|
386
|
+
import { executionPolicies } from "./workflows/policies";
|
|
387
|
+
|
|
388
|
+
export default defineConfig({
|
|
389
|
+
workflow: {
|
|
390
|
+
files: ["workflows/**/*.ts"],
|
|
391
|
+
executionPolicies,
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Key Grammar
|
|
397
|
+
|
|
398
|
+
`key` accepts `[a-z0-9_:.-]` and must start with `[a-z0-9]`. An exact key must also end with `[a-z0-9]`; a wildcard prefix (`matchType: "prefix"`) may end with any of those characters, since the platform appends a trailing `*` after it. The platform-registered key — including that trailing `*` when wildcarded — is 2 to 64 characters long, so a wildcard prefix must be at most 63 characters. `foo:bar` is a valid exact key; `tenant-api` with `matchType: "prefix"` registers `tenant-api*` as a wildcard prefix.
|
|
399
|
+
|
|
400
|
+
An exact-key policy applies to dispatches whose runtime key equals the policy key. A wildcard policy applies to every dispatch whose runtime key begins with the prefix; each concrete resolved key gets its own independent pool of the declared size (a `cap = 3` wildcard yields three concurrent dispatches per resolved key, not three across every match). When a dispatch matches more than one policy (for example, an exact key that also falls under a wildcard prefix, or two wildcard prefixes where one starts with the other), every matching policy's cap is enforced independently, and the tightest one blocks.
|
|
401
|
+
|
|
402
|
+
### Referencing a Policy from a Workflow
|
|
403
|
+
|
|
404
|
+
Pass the runtime key through the `executionPolicyKey` option on `job.trigger()` or `tailor.workflow.triggerJobFunction()`. For exact-key policies, use `<policy>.key` directly — it's typed so only a value that came from a declared policy can be passed. For wildcard policies (`matchType: "prefix"`), there is no `<policy>.key` — call `<policy>.keyFor(suffix)` to build the concrete key. `keyFor` joins the prefix and suffix with `.` by default; override it with `separator` — the second argument to `defineWorkflowExecutionPolicies` (applies to every policy in the group), or a `def` field on a single `defineWorkflowExecutionPolicy`.
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
import { createWorkflowJob } from "@tailor-platform/sdk";
|
|
408
|
+
import { executionPolicies } from "./policies";
|
|
409
|
+
import { sendNotification } from "./jobs/send-notification";
|
|
410
|
+
import { fetchTenant } from "./jobs/fetch-tenant";
|
|
411
|
+
|
|
412
|
+
export const mainJob = createWorkflowJob({
|
|
413
|
+
name: "main-job",
|
|
414
|
+
body: async (input: { tenantId: string }) => {
|
|
415
|
+
// Exact key policy: pass .key directly.
|
|
416
|
+
await sendNotification.trigger(
|
|
417
|
+
{ message: "Order processed" },
|
|
418
|
+
{ executionPolicyKey: executionPolicies.premium.key },
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
// Wildcard policy: build the concrete key with keyFor().
|
|
422
|
+
await fetchTenant.trigger(
|
|
423
|
+
{ tenantId: input.tenantId },
|
|
424
|
+
{ executionPolicyKey: executionPolicies.tenantApi.keyFor(input.tenantId) },
|
|
425
|
+
);
|
|
426
|
+
},
|
|
427
|
+
});
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
The same `executionPolicyKey` option is available on `tailor.workflow.triggerJobFunction(name, args, options)` for jobs invoked by name.
|
|
431
|
+
|
|
354
432
|
## Triggering a Workflow from a Resolver
|
|
355
433
|
|
|
356
434
|
You can start a workflow execution from a resolver using `workflow.trigger()`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.5",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -157,11 +157,11 @@
|
|
|
157
157
|
"@opentelemetry/exporter-trace-otlp-proto": "0.220.0",
|
|
158
158
|
"@opentelemetry/resources": "2.9.0",
|
|
159
159
|
"@opentelemetry/sdk-trace-node": "2.9.0",
|
|
160
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
161
|
-
"@oxc-project/types": "0.
|
|
160
|
+
"@opentelemetry/semantic-conventions": "1.43.0",
|
|
161
|
+
"@oxc-project/types": "0.139.0",
|
|
162
162
|
"@standard-schema/spec": "1.1.0",
|
|
163
163
|
"@tailor-platform/function-kysely-tailordb": "0.1.3",
|
|
164
|
-
"@toiroakr/lines-db": "0.10.
|
|
164
|
+
"@toiroakr/lines-db": "0.10.1",
|
|
165
165
|
"@toiroakr/read-multiline": "0.4.1",
|
|
166
166
|
"@urql/core": "6.0.3",
|
|
167
167
|
"amaro": "1.1.10",
|
|
@@ -172,26 +172,26 @@
|
|
|
172
172
|
"es-toolkit": "1.49.0",
|
|
173
173
|
"find-up-simple": "1.0.1",
|
|
174
174
|
"globals": "17.7.0",
|
|
175
|
-
"graphql": "17.0.
|
|
175
|
+
"graphql": "17.0.2",
|
|
176
176
|
"inflection": "3.0.2",
|
|
177
|
-
"kysely": "0.29.
|
|
177
|
+
"kysely": "0.29.3",
|
|
178
178
|
"madge": "8.0.0",
|
|
179
179
|
"mime-types": "3.0.2",
|
|
180
180
|
"open": "11.0.0",
|
|
181
|
-
"oxc-parser": "0.
|
|
181
|
+
"oxc-parser": "0.139.0",
|
|
182
182
|
"p-limit": "7.3.0",
|
|
183
183
|
"pathe": "2.0.3",
|
|
184
184
|
"pgsql-ast-parser": "12.0.2",
|
|
185
185
|
"pkg-types": "2.3.1",
|
|
186
|
-
"politty": "0.11.
|
|
187
|
-
"rolldown": "1.1.
|
|
186
|
+
"politty": "0.11.2",
|
|
187
|
+
"rolldown": "1.1.5",
|
|
188
188
|
"semver": "7.8.5",
|
|
189
189
|
"sql-highlight": "6.1.0",
|
|
190
|
-
"std-env": "4.
|
|
190
|
+
"std-env": "4.2.0",
|
|
191
191
|
"table": "6.9.0",
|
|
192
192
|
"ts-cron-validator": "1.1.5",
|
|
193
|
-
"type-fest": "5.
|
|
194
|
-
"undici": "8.
|
|
193
|
+
"type-fest": "5.8.0",
|
|
194
|
+
"undici": "8.7.0",
|
|
195
195
|
"xdg-basedir": "5.1.0",
|
|
196
196
|
"zod": "4.4.3"
|
|
197
197
|
},
|
|
@@ -199,19 +199,19 @@
|
|
|
199
199
|
"@opentelemetry/sdk-trace-base": "2.9.0",
|
|
200
200
|
"@types/madge": "5.0.3",
|
|
201
201
|
"@types/mime-types": "3.0.1",
|
|
202
|
-
"@types/node": "24.13.
|
|
202
|
+
"@types/node": "24.13.3",
|
|
203
203
|
"@types/semver": "7.7.1",
|
|
204
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
205
|
-
"@vitest/coverage-v8": "4.1.
|
|
204
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
205
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
206
206
|
"eslint-plugin-zod": "4.7.0",
|
|
207
|
-
"oxfmt": "0.
|
|
208
|
-
"oxlint": "1.
|
|
207
|
+
"oxfmt": "0.58.0",
|
|
208
|
+
"oxlint": "1.73.0",
|
|
209
209
|
"oxlint-tsgolint": "0.24.0",
|
|
210
|
-
"sonda": "0.
|
|
211
|
-
"tsdown": "0.22.
|
|
210
|
+
"sonda": "0.14.0",
|
|
211
|
+
"tsdown": "0.22.4",
|
|
212
212
|
"typescript": "6.0.3",
|
|
213
|
-
"vitest": "4.1.
|
|
214
|
-
"zinfer": "0.2.
|
|
213
|
+
"vitest": "4.1.10",
|
|
214
|
+
"zinfer": "0.2.5",
|
|
215
215
|
"@tailor-platform/tailor-proto": "^0.0.0"
|
|
216
216
|
},
|
|
217
217
|
"peerDependencies": {
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
"check:import-cycles": "node --experimental-strip-types scripts/check-import-cycles.ts",
|
|
245
245
|
"lint:fix": "oxlint --type-aware . --fix",
|
|
246
246
|
"typecheck": "tsc --noEmit",
|
|
247
|
-
"typecheck:go": "tsgo",
|
|
247
|
+
"typecheck:go": "tsgo --tsBuildInfoFile ./.tsgo.tsbuildinfo",
|
|
248
248
|
"perf:typecheck": "bash scripts/perf/exec.sh",
|
|
249
249
|
"perf:runtime": "bash scripts/perf/runtime-perf.sh",
|
|
250
250
|
"prepublish": "pnpm run build",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-DXywRVcq.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/runtime/aigateway.ts
|
|
4
|
-
var aigateway_exports = /* @__PURE__ */ __exportAll({ get: () => get });
|
|
5
|
-
const api = () => globalThis.tailor.aigateway;
|
|
6
|
-
/**
|
|
7
|
-
* See {@link TailorAigatewayAPI.get}.
|
|
8
|
-
* @param args - Forwarded to {@link TailorAigatewayAPI.get}
|
|
9
|
-
* @returns The resolved AI Gateway's platform-assigned URL
|
|
10
|
-
*/
|
|
11
|
-
const get = (...args) => api().get(...args);
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { get as n, aigateway_exports as t };
|
|
15
|
-
//# sourceMappingURL=aigateway-B3oZZE6v.mjs.map
|