@tailor-platform/sdk 2.0.0-next.4 → 2.0.0-next.6
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 +135 -0
- package/dist/{application-BX13RArL.mjs → application-BJXRpQj5.mjs} +602 -1842
- package/dist/application-BJXRpQj5.mjs.map +1 -0
- package/dist/application-BV-AXawv.mjs +3 -0
- 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 +13 -3
- 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 -1
- 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/options.d.mts +0 -1
- package/dist/cli/commands/generate/service.d.mts +6 -2
- 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/staticwebsite/deploy.d.mts +19 -0
- 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 +3 -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 +1 -1
- package/dist/cli/commands/workspace/restore.d.mts +0 -1
- package/dist/cli/commands/workspace/transform.d.mts +4 -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 +871 -1577
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +10 -4
- package/dist/cli/lib.mjs +50 -4
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/query/index.d.mts +0 -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 +1 -2
- package/dist/cli/shared/context.d.mts +2 -1
- package/dist/cli/shared/readonly-guard.d.mts +25 -0
- package/dist/cli/shared/script-executor.d.mts +0 -1
- package/dist/cli/shared/seed-chunker.d.mts +7 -3
- package/dist/cli/shared/tailordb-namespaces.d.mts +37 -0
- package/dist/cli/shared/type-generator.d.mts +0 -1
- package/dist/cli/shared/workspace-name.d.mts +1 -0
- package/dist/completion/zsh-worker.zsh +15 -303
- package/dist/configure/config/index.d.mts +0 -1
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +14 -4
- package/dist/configure/index.mjs +201 -6
- 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 +2 -13
- package/dist/configure/services/executor/index.d.mts +1 -0
- package/dist/configure/services/executor/operation.d.mts +9 -4
- 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 +5 -0
- 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 +86 -56
- package/dist/configure/services/tailordb/types.d.mts +66 -17
- package/dist/configure/services/workflow/execution-policy.d.mts +2 -3
- package/dist/configure/services/workflow/execution-policy.types.d.mts +0 -1
- package/dist/configure/services/workflow/index.d.mts +1 -0
- package/dist/configure/services/workflow/job.d.mts +0 -1
- 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.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 +2 -11
- package/dist/{crashreport-D3RjuSYb.mjs → crashreport-0ioNRZ4K.mjs} +1 -1
- package/dist/{crashreport-Cg-pqRJV.mjs → crashreport-CxHne11E.mjs} +4 -3
- package/dist/{crashreport-Cg-pqRJV.mjs.map → crashreport-CxHne11E.mjs.map} +1 -1
- package/dist/errors-DfnF4ibq.mjs +100 -0
- package/dist/errors-DfnF4ibq.mjs.map +1 -0
- package/dist/{globals-BjhJJ2dN.mjs → globals-D-YbJKW-.mjs} +16 -10
- package/dist/globals-D-YbJKW-.mjs.map +1 -0
- package/dist/kysely/index.d.mts +3 -4
- package/dist/{kysely-type-D-zflMGf.mjs → kysely-type-DqIRgDYR.mjs} +4 -3
- package/dist/kysely-type-DqIRgDYR.mjs.map +1 -0
- package/dist/{logger-BEiZZ3qT.mjs → logger-BwS4ppwO.mjs} +3 -3
- package/dist/logger-BwS4ppwO.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/type-source.d.mts +10 -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/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-BM1caLT0.mjs → register-ts-hook-DL31O2W9.mjs} +3076 -1744
- package/dist/register-ts-hook-DL31O2W9.mjs.map +1 -0
- package/dist/{registry-BSbq6SPo.mjs → registry-CC3CbQiF.mjs} +3 -3
- package/dist/registry-CC3CbQiF.mjs.map +1 -0
- package/dist/runtime/aigateway.d.mts +0 -1
- package/dist/runtime/authconnection.d.mts +0 -1
- package/dist/runtime/context.d.mts +0 -1
- package/dist/runtime/field-parse.d.mts +10 -0
- package/dist/runtime/globals.d.mts +5 -3
- package/dist/runtime/index.d.mts +0 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/types.d.mts +9 -4
- package/dist/runtime/workflow.d.mts +70 -10
- package/dist/runtime/workflow.mjs +1 -1
- package/dist/{schema-C4LYbXVG.mjs → schema--xYWRGfe.mjs} +272 -51
- package/dist/schema--xYWRGfe.mjs.map +1 -0
- package/dist/{secret-file-aoNXJmKa.mjs → secret-file-C3J4Gy8r.mjs} +2 -27
- package/dist/secret-file-C3J4Gy8r.mjs.map +1 -0
- package/dist/{secretmanager-Bd45j7an.mjs → secretmanager-IY4UvinW.mjs} +42 -9
- package/dist/secretmanager-IY4UvinW.mjs.map +1 -0
- package/dist/seed/index.d.mts +3 -2
- package/dist/{service-ufH7sS8o.mjs → service-CnHz9rwz.mjs} +47 -20
- package/dist/service-CnHz9rwz.mjs.map +1 -0
- package/dist/{service-DeZeYa06.mjs → service-DaeJlBoH.mjs} +3 -3
- package/dist/{service-DeZeYa06.mjs.map → service-DaeJlBoH.mjs.map} +1 -1
- package/dist/service-nU6ITOHL.mjs +3 -0
- package/dist/service_pb-BoLM0X4K.mjs +167 -0
- package/dist/service_pb-BoLM0X4K.mjs.map +1 -0
- package/dist/{service_pb-B2FF59sP.mjs → service_pb-r1T7kpJc.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 +0 -1
- 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 +0 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +0 -1
- 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 +133 -123
- 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/user-agent-Bgsszb5I.mjs +28 -0
- package/dist/user-agent-Bgsszb5I.mjs.map +1 -0
- 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 +9 -9
- package/dist/vitest/index.mjs +591 -173
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock-kysely.d.mts +0 -1
- package/dist/vitest/mock.d.mts +8 -8
- package/dist/vitest/mocks/aigateway.d.mts +16 -6
- package/dist/vitest/mocks/authconnection.d.mts +16 -6
- package/dist/vitest/mocks/file.d.mts +23 -6
- package/dist/vitest/mocks/iconv.d.mts +28 -4
- package/dist/vitest/mocks/idp.d.mts +26 -10
- package/dist/vitest/mocks/secretmanager.d.mts +16 -5
- package/dist/vitest/mocks/tailordb.d.mts +54 -10
- package/dist/vitest/mocks/workflow.d.mts +72 -21
- package/dist/vitest/setup.mjs +2 -2
- package/dist/vitest/workflow-local.d.mts +1 -0
- package/dist/workflow-9kHGKxF2.mjs +64 -0
- package/dist/workflow-9kHGKxF2.mjs.map +1 -0
- package/dist/{service_pb-B5w9rjPY.mjs → workspace_resource_pb-Db3fv68L.mjs} +57 -165
- package/dist/workspace_resource_pb-Db3fv68L.mjs.map +1 -0
- package/docs/cli/application.md +61 -15
- package/docs/cli/setup.md +1 -1
- package/docs/cli/tailordb.md +8 -140
- package/docs/cli/workspace.md +6 -4
- package/docs/cli-reference.md +18 -14
- package/docs/github-actions.md +8 -0
- package/docs/migration/v2.md +247 -0
- package/docs/runtime.md +5 -6
- package/docs/services/aigateway.md +2 -0
- package/docs/services/executor.md +5 -0
- package/docs/services/tailordb.md +144 -68
- package/docs/services/workflow.md +3 -3
- package/docs/testing.md +105 -89
- package/package.json +22 -25
- package/dist/application-BO4ZF8wP.mjs +0 -3
- package/dist/application-BX13RArL.mjs.map +0 -1
- package/dist/cli/erd-viewer-assets/app.js +0 -1424
- package/dist/cli/erd-viewer-assets/index.html +0 -77
- package/dist/cli/erd-viewer-assets/serve.json +0 -13
- package/dist/cli/erd-viewer-assets/styles.css +0 -1036
- package/dist/cli/shared/trigger-context.d.mts +0 -1
- package/dist/configure/types/field-runtime.d.mts +0 -17
- package/dist/errors-118wUDRr.mjs +0 -42
- package/dist/errors-118wUDRr.mjs.map +0 -1
- package/dist/field-runtime-CAnh_oow.mjs +0 -183
- package/dist/field-runtime-CAnh_oow.mjs.map +0 -1
- package/dist/globals-BjhJJ2dN.mjs.map +0 -1
- package/dist/kysely-type-D-zflMGf.mjs.map +0 -1
- package/dist/logger-BEiZZ3qT.mjs.map +0 -1
- package/dist/register-ts-hook-BM1caLT0.mjs.map +0 -1
- package/dist/registry-BSbq6SPo.mjs.map +0 -1
- package/dist/resource_pb-BRv7AMXK.mjs +0 -49
- package/dist/resource_pb-BRv7AMXK.mjs.map +0 -1
- package/dist/schema-C4LYbXVG.mjs.map +0 -1
- package/dist/secret-file-aoNXJmKa.mjs.map +0 -1
- package/dist/secretmanager-Bd45j7an.mjs.map +0 -1
- package/dist/service-CkIwEctX.mjs +0 -3
- package/dist/service-ufH7sS8o.mjs.map +0 -1
- package/dist/service_pb-B5w9rjPY.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-GNuSnsTx.mjs +0 -22
- package/dist/workflow-GNuSnsTx.mjs.map +0 -1
package/docs/testing.md
CHANGED
|
@@ -70,18 +70,23 @@ import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
|
70
70
|
|
|
71
71
|
test("...", () => {
|
|
72
72
|
using db = mockTailordb();
|
|
73
|
-
db.
|
|
73
|
+
db.onQuery(/SELECT age/).returnsRows([{ age: 30 }]);
|
|
74
74
|
// …
|
|
75
75
|
}); // reset automatically here
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
Runtime operations are exposed as typed Vitest mocks wherever the platform API has a stable operation shape. For example, use `file.download.mockResolvedValue(...)`, `iconv.decode.mockReturnValue(...)`, or `wf.job(myJob).mockResolvedValue(...)`, then assert with native Vitest matchers. Service-specific helpers cover stateful fixtures and query matching.
|
|
79
|
+
|
|
80
|
+
Every controller provides two lifecycle methods when manual reuse is useful:
|
|
81
|
+
|
|
82
|
+
- `clear()` removes call history but preserves configured behavior.
|
|
83
|
+
- `reset()` removes call history and configured behavior, restoring the controller's default behavior.
|
|
79
84
|
|
|
80
85
|
> **Requirements:** `using` requires TypeScript ≥ 5.2 and a runtime that provides `Symbol.dispose` (Node ≥ 20.4 — the SDK already targets Node ≥ 22, and Vitest's transformer downlevels the syntax for you).
|
|
81
86
|
>
|
|
82
87
|
> **Acquire what you use:** a namespace is only mocked while you hold it with `using`, so code under test that calls a platform API (e.g. `tailor.workflow`, `tailordb.Client`) must run inside a test that has acquired the matching `mockX()`. The error classes and `tailor.context` are always present.
|
|
83
88
|
>
|
|
84
|
-
> **Seeded secrets survive:** secrets seeded from `tailor.config.ts` stay available across tests;
|
|
89
|
+
> **Seeded secrets survive:** secrets seeded from `tailor.config.ts` stay available across tests; per-test fixtures passed to `mockSecretmanager({ secrets: ... })` apply only within that test.
|
|
85
90
|
|
|
86
91
|
### TailorDB Mock
|
|
87
92
|
|
|
@@ -92,8 +97,8 @@ import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
|
92
97
|
|
|
93
98
|
test("resolver queries the database", async () => {
|
|
94
99
|
using db = mockTailordb();
|
|
95
|
-
//
|
|
96
|
-
db.
|
|
100
|
+
// Use an explicit queue when transaction order is part of the test.
|
|
101
|
+
db.enqueueRows(
|
|
97
102
|
[], // BEGIN (empty result)
|
|
98
103
|
[{ age: 30 }], // SELECT (one row)
|
|
99
104
|
[], // COMMIT
|
|
@@ -112,19 +117,15 @@ test("resolver queries the database", async () => {
|
|
|
112
117
|
});
|
|
113
118
|
```
|
|
114
119
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- **`enqueueResult(...rows)`** — Order-based, single query. Arguments are the row objects returned by the next `queryObject` call (`enqueueResult()` for empty, `enqueueResult({ id: "1" })` for one row, `enqueueResult({ a: 1 }, { a: 2 })` for multiple rows). Consumed in FIFO order.
|
|
118
|
-
- **`enqueueResults(...rowsArrays)`** — Order-based, multiple queries. Each argument is a rows array for one upcoming query. Equivalent to calling `enqueueResult` for each entry but easier to read for transactional sequences.
|
|
119
|
-
- **`setQueryResolver((query, params) => rows)`** — Content-based fallback. Called when the queue is empty.
|
|
120
|
+
Match queries by SQL text, a regular expression, SQL plus parameters, or a predicate. The most recently registered matcher wins:
|
|
120
121
|
|
|
121
122
|
```typescript
|
|
122
123
|
test("content-based mock", async () => {
|
|
123
124
|
using db = mockTailordb();
|
|
124
|
-
db.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
db.onQuery({ sql: /FROM users/i, params: ["1"] }).returnsRows([{ id: "1", name: "test" }]);
|
|
126
|
+
db.onQuery(/FROM audit_logs/i)
|
|
127
|
+
.returnsRowsOnce([{ id: "first" }])
|
|
128
|
+
.returnsRows([{ id: "later" }]);
|
|
128
129
|
|
|
129
130
|
const result = await resolver.body({
|
|
130
131
|
input: { userId: "1" },
|
|
@@ -137,40 +138,46 @@ test("content-based mock", async () => {
|
|
|
137
138
|
});
|
|
138
139
|
```
|
|
139
140
|
|
|
141
|
+
Within one `mockTailordb()` instance, use either `onQuery()` matchers or a direct `queryObject.mockImplementation()` override. A direct override replaces matcher-based behavior, so do not combine the two styles.
|
|
142
|
+
|
|
143
|
+
`returnsRowsOnce` and `rejectsOnce` configure one-time responses before the persistent `returnsRows` or `rejects` response. `enqueueRows(...rowArrays)` remains available for transaction sequences whose exact call order is under test. The existing `enqueueResult`, `enqueueResults`, and `setQueryResolver` helpers remain supported for compatibility.
|
|
144
|
+
|
|
145
|
+
Pass `{ onUnhandled: "error" }` to make an unmatched query fail instead of returning an empty result.
|
|
146
|
+
|
|
140
147
|
### Workflow Mock
|
|
141
148
|
|
|
142
|
-
Workflow job `.trigger()` calls use the platform workflow runtime. Acquire `mockWorkflow()` when you want to provide trigger responses with `setJobHandler` / `enqueueResult` or assert on `triggeredJobs`. If no response is configured, the mock throws so missing job mocks fail loudly:
|
|
149
|
+
Workflow job `.trigger()` calls use the platform workflow runtime. Acquire `mockWorkflow()` when you want to provide trigger responses with `setJobHandler` / `enqueueResult` or assert on `triggeredJobs`. If no response is configured, the mock throws so missing job mocks fail loudly. Use `job(definition)` or `workflow(definition)` to get a stable, fully typed Vitest mock for one definition:
|
|
143
150
|
|
|
144
151
|
```typescript
|
|
145
152
|
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
153
|
+
import { processPayment, validateOrder } from "./jobs";
|
|
146
154
|
|
|
147
155
|
test("workflow triggers jobs", async () => {
|
|
148
156
|
using wf = mockWorkflow();
|
|
149
|
-
wf.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
157
|
+
const validate = wf.job(validateOrder);
|
|
158
|
+
const payment = wf.job(processPayment);
|
|
159
|
+
validate.mockResolvedValue({ valid: true });
|
|
160
|
+
payment.mockResolvedValue({ txnId: "txn-1" });
|
|
154
161
|
|
|
155
162
|
const result = await main({ input: { orderId: "o-1" } });
|
|
156
163
|
|
|
157
|
-
expect(
|
|
158
|
-
|
|
159
|
-
{ jobName: "process-payment", args: { orderId: "o-1" } },
|
|
160
|
-
]);
|
|
164
|
+
expect(validate).toHaveBeenCalledWith({ orderId: "o-1" });
|
|
165
|
+
expect(payment).toHaveBeenCalledWith({ orderId: "o-1" });
|
|
161
166
|
});
|
|
162
167
|
```
|
|
163
168
|
|
|
164
|
-
`
|
|
169
|
+
Unconfigured definition mocks continue to run their real implementations. The lower-level `triggerJobFunction`, `triggerWorkflow`, `resumeWorkflow`, `wait`, and `resolve` mocks and the existing `setJobHandler`, `enqueueResult`, `enqueueResults`, and call-record helpers remain available.
|
|
170
|
+
|
|
171
|
+
Use `waitPoint(definition)` for typed wait-point control:
|
|
165
172
|
|
|
166
173
|
```typescript
|
|
167
174
|
using wf = mockWorkflow();
|
|
175
|
+
const approvalMock = wf.waitPoint(approvalWaitPoint);
|
|
168
176
|
|
|
169
|
-
|
|
170
|
-
|
|
177
|
+
approvalMock.wait.mockResolvedValue({ approved: true });
|
|
178
|
+
await approvalWaitPoint.wait({ message: "Please approve" });
|
|
171
179
|
|
|
172
|
-
|
|
173
|
-
wf.enqueueResults({ valid: true }, { txnId: "txn-1" });
|
|
180
|
+
expect(approvalMock.wait).toHaveBeenCalledWith({ message: "Please approve" });
|
|
174
181
|
```
|
|
175
182
|
|
|
176
183
|
Use `wf.setEnv(...)` when locally-run workflow job bodies need configuration values. Per-run `runWorkflowLocally(..., { env })` options take precedence over the mock's env.
|
|
@@ -181,13 +188,14 @@ Use `wf.setEnv(...)` when locally-run workflow job bodies need configuration val
|
|
|
181
188
|
import { mockSecretmanager } from "@tailor-platform/sdk/vitest";
|
|
182
189
|
|
|
183
190
|
test("reads secrets from vault", async () => {
|
|
184
|
-
using sm = mockSecretmanager(
|
|
185
|
-
|
|
186
|
-
"my-vault": { API_KEY: "sk-123", DB_PASS: "secret" },
|
|
191
|
+
using sm = mockSecretmanager({
|
|
192
|
+
secrets: { "my-vault": { API_KEY: "sk-123" } },
|
|
187
193
|
});
|
|
194
|
+
sm.setSecret("my-vault", "API_KEY", "override");
|
|
195
|
+
sm.mergeSecrets("my-vault", { DB_PASS: "secret" });
|
|
188
196
|
|
|
189
197
|
const key = await tailor.secretmanager.getSecret("my-vault", "API_KEY");
|
|
190
|
-
expect(key).toBe("
|
|
198
|
+
expect(key).toBe("override");
|
|
191
199
|
expect(sm.calls).toEqual([{ method: "getSecret", vault: "my-vault", name: "API_KEY" }]);
|
|
192
200
|
});
|
|
193
201
|
```
|
|
@@ -198,65 +206,65 @@ test("reads secrets from vault", async () => {
|
|
|
198
206
|
import { mockAuthconnection } from "@tailor-platform/sdk/vitest";
|
|
199
207
|
|
|
200
208
|
test("returns configured token", async () => {
|
|
201
|
-
using ac = mockAuthconnection(
|
|
202
|
-
|
|
203
|
-
|
|
209
|
+
using ac = mockAuthconnection({
|
|
210
|
+
tokens: { google: { access_token: "ya29.xxx" } },
|
|
211
|
+
onUnhandled: "error",
|
|
204
212
|
});
|
|
213
|
+
ac.setToken("google", { access_token: "replacement" });
|
|
205
214
|
|
|
206
215
|
const token = await tailor.authconnection.getConnectionToken("google");
|
|
207
|
-
expect(token.access_token).toBe("
|
|
216
|
+
expect(token.access_token).toBe("replacement");
|
|
208
217
|
});
|
|
209
218
|
```
|
|
210
219
|
|
|
211
|
-
|
|
220
|
+
By default, an unconfigured connection returns `{ access_token: "mock-token" }`. Pass `onUnhandled: "error"` to fail instead.
|
|
212
221
|
|
|
213
222
|
### IDP Mock
|
|
214
223
|
|
|
215
224
|
```typescript
|
|
216
225
|
import { mockIdp } from "@tailor-platform/sdk/vitest";
|
|
217
226
|
|
|
218
|
-
test("
|
|
219
|
-
using idp = mockIdp();
|
|
220
|
-
idp.
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
test("namespace-specific mock", async () => {
|
|
228
|
+
using idp = mockIdp({ onUnhandled: "error" });
|
|
229
|
+
const customerIdp = idp.namespace("my-ns");
|
|
230
|
+
customerIdp.user.mockResolvedValue({
|
|
231
|
+
id: "u-1",
|
|
232
|
+
name: "alice",
|
|
233
|
+
disabled: false,
|
|
234
|
+
mfaEnrolled: false,
|
|
235
|
+
mfaFactorIds: [],
|
|
223
236
|
});
|
|
224
237
|
|
|
225
238
|
const client = new tailor.idp.Client({ namespace: "my-ns" });
|
|
226
239
|
const user = await client.user("u-1");
|
|
227
240
|
expect(user.name).toBe("alice");
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
test("queue-based", async () => {
|
|
231
|
-
using idp = mockIdp();
|
|
232
|
-
idp.enqueueResult({ id: "u-1", name: "alice", disabled: false });
|
|
233
|
-
|
|
234
|
-
const client = new tailor.idp.Client({ namespace: "my-ns" });
|
|
235
|
-
const user = await client.user("u-1");
|
|
236
|
-
expect(user.name).toBe("alice");
|
|
237
|
-
expect(idp.calls).toMatchObject([{ method: "user", namespace: "my-ns" }]);
|
|
241
|
+
expect(customerIdp.user).toHaveBeenCalledWith("u-1");
|
|
238
242
|
});
|
|
239
243
|
```
|
|
240
244
|
|
|
245
|
+
Each namespace exposes typed mocks for `users`, `user`, `userByName`, `createUser`, `updateUser`, `deleteUser`, `sendPasswordResetEmail`, and `unenrollMfa`. The existing resolver, queue, and aggregate `calls` APIs remain supported.
|
|
246
|
+
|
|
241
247
|
### File Mock
|
|
242
248
|
|
|
243
249
|
```typescript
|
|
244
250
|
import { mockFile } from "@tailor-platform/sdk/vitest";
|
|
245
251
|
|
|
246
252
|
test("mock file download", async () => {
|
|
247
|
-
using file = mockFile();
|
|
248
|
-
file.
|
|
253
|
+
using file = mockFile({ onUnhandled: "error" });
|
|
254
|
+
file.download.mockResolvedValue({
|
|
249
255
|
data: new Uint8Array([1, 2, 3]),
|
|
250
256
|
metadata: { contentType: "image/png", fileSize: 3, sha256sum: "abc", lastUploadedAt: "" },
|
|
251
257
|
});
|
|
252
258
|
|
|
253
259
|
const result = await tailordb.file.download("ns", "Doc", "attachment", "r-1");
|
|
254
260
|
expect(result.data).toEqual(new Uint8Array([1, 2, 3]));
|
|
255
|
-
expect(file.
|
|
261
|
+
expect(file.download).toHaveBeenCalledWith("ns", "Doc", "attachment", "r-1");
|
|
256
262
|
});
|
|
257
263
|
```
|
|
258
264
|
|
|
259
|
-
|
|
265
|
+
All File operations are typed Vitest mocks: `upload`, `download`, `downloadAsBase64`, `delete`, `getMetadata`, `downloadStream`, and `uploadStream`. Use native methods such as `mockResolvedValueOnce` and `mockRejectedValueOnce` to model success and failure. The existing resolver, queue, and aggregate `calls` APIs remain supported.
|
|
266
|
+
|
|
267
|
+
For `downloadStream`, configure a `FileDownloadStreamResponse` object with a `ReadableStream` body and metadata:
|
|
260
268
|
|
|
261
269
|
```typescript
|
|
262
270
|
test("mock file download stream", async () => {
|
|
@@ -267,7 +275,7 @@ test("mock file download stream", async () => {
|
|
|
267
275
|
controller.close();
|
|
268
276
|
},
|
|
269
277
|
});
|
|
270
|
-
file.
|
|
278
|
+
file.downloadStream.mockResolvedValue({
|
|
271
279
|
body,
|
|
272
280
|
metadata: { contentType: "image/png", fileSize: 3, sha256sum: "abc", lastUploadedAt: "" },
|
|
273
281
|
});
|
|
@@ -284,10 +292,7 @@ import { mockIconv } from "@tailor-platform/sdk/vitest";
|
|
|
284
292
|
|
|
285
293
|
test("mock encoding conversion", () => {
|
|
286
294
|
using iconv = mockIconv();
|
|
287
|
-
iconv.
|
|
288
|
-
if (method === "decode") return "decoded-text";
|
|
289
|
-
return null; // falls back to default empty string
|
|
290
|
-
});
|
|
295
|
+
iconv.decode.mockReturnValue("decoded-text");
|
|
291
296
|
|
|
292
297
|
const result = tailor.iconv.decode(new Uint8Array([0x48, 0x69]), "UTF-8");
|
|
293
298
|
expect(result).toBe("decoded-text");
|
|
@@ -295,22 +300,26 @@ test("mock encoding conversion", () => {
|
|
|
295
300
|
});
|
|
296
301
|
```
|
|
297
302
|
|
|
303
|
+
`convert`, `convertBuffer`, `decode`, `encode`, and `encodings` are all typed Vitest mocks. Pass `{ onUnhandled: "error" }` to fail calls without a configured implementation. The existing resolver and aggregate `calls` APIs remain supported.
|
|
304
|
+
|
|
298
305
|
### AI Gateway Mock
|
|
299
306
|
|
|
300
307
|
```typescript
|
|
301
308
|
import { mockAigateway } from "@tailor-platform/sdk/vitest";
|
|
302
309
|
|
|
303
310
|
test("resolves an AI Gateway URL", async () => {
|
|
304
|
-
using aigateway = mockAigateway(
|
|
305
|
-
|
|
311
|
+
using aigateway = mockAigateway({
|
|
312
|
+
urls: { "my-aigateway": "https://my-aigateway.example.com" },
|
|
313
|
+
});
|
|
314
|
+
aigateway.setUrl("my-aigateway", "https://replacement.example.com");
|
|
306
315
|
|
|
307
316
|
const { url } = await tailor.aigateway.get("my-aigateway");
|
|
308
|
-
expect(url).toBe("https://
|
|
317
|
+
expect(url).toBe("https://replacement.example.com");
|
|
309
318
|
expect(aigateway.calls).toEqual([{ name: "my-aigateway" }]);
|
|
310
319
|
});
|
|
311
320
|
```
|
|
312
321
|
|
|
313
|
-
Calling `get` for a name that
|
|
322
|
+
Calling `get` for a name that has not been registered throws. `setUrls` remains available when replacing the complete URL fixture.
|
|
314
323
|
|
|
315
324
|
### Loading Secrets from Config
|
|
316
325
|
|
|
@@ -323,7 +332,7 @@ export default defineConfig({
|
|
|
323
332
|
});
|
|
324
333
|
```
|
|
325
334
|
|
|
326
|
-
This makes `tailor.secretmanager.getSecret("vault", "key")` return the values defined in your config. You can still override with `
|
|
335
|
+
This makes `tailor.secretmanager.getSecret("vault", "key")` return the values defined in your config. You can still override with `mockSecretmanager({ secrets: ... })` in individual tests: a per-test overlay applies only within that test, and the config-loaded secrets remain available to every other test.
|
|
327
336
|
|
|
328
337
|
### Per-Project Configuration
|
|
329
338
|
|
|
@@ -548,19 +557,21 @@ Reach for [`mockTailordb`](#mocking-the-tailordb-client) instead when you want t
|
|
|
548
557
|
|
|
549
558
|
#### Resolvers that resume a workflow
|
|
550
559
|
|
|
551
|
-
Resolvers that call `waitPoint.resolve(...)` delegate to `tailor.workflow.resolve` at runtime. With the `tailor-runtime` environment active, use `mockWorkflow().
|
|
560
|
+
Resolvers that call `waitPoint.resolve(...)` delegate to `tailor.workflow.resolve` at runtime. With the `tailor-runtime` environment active, use `mockWorkflow().waitPoint(definition)` to invoke the callback with the payload that originally suspended the job:
|
|
552
561
|
|
|
553
562
|
```typescript
|
|
554
563
|
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
555
564
|
import { describe, expect, test } from "vitest";
|
|
565
|
+
import { approval } from "../workflow/approval";
|
|
556
566
|
import resolver from "./resolveApproval";
|
|
557
567
|
|
|
558
568
|
describe("resolveApproval resolver", () => {
|
|
559
569
|
test("resolves approval with approved=true", async () => {
|
|
560
570
|
using wf = mockWorkflow();
|
|
561
|
-
wf.
|
|
562
|
-
|
|
563
|
-
|
|
571
|
+
const approvalMock = wf.waitPoint(approval);
|
|
572
|
+
approvalMock.setResolvePayload({
|
|
573
|
+
message: "Please approve order order-1",
|
|
574
|
+
orderId: "order-1",
|
|
564
575
|
});
|
|
565
576
|
|
|
566
577
|
const result = await resolver.body({
|
|
@@ -571,16 +582,16 @@ describe("resolveApproval resolver", () => {
|
|
|
571
582
|
});
|
|
572
583
|
|
|
573
584
|
expect(result).toEqual({ resolved: true });
|
|
574
|
-
expect(
|
|
585
|
+
expect(approvalMock.resolve).toHaveBeenCalledWith("exec-1", expect.any(Function));
|
|
575
586
|
});
|
|
576
587
|
});
|
|
577
588
|
```
|
|
578
589
|
|
|
579
|
-
`
|
|
590
|
+
`setResolvePayload` is typed from the wait-point definition. The lower-level `setResolveHandler` and `resolveCalls` APIs remain available when a test must control several wait points together.
|
|
580
591
|
|
|
581
592
|
#### Resolvers that resume failed workflows
|
|
582
593
|
|
|
583
|
-
Resolvers or executors that call `workflow.
|
|
594
|
+
Resolvers or executors that call `workflow.resumeWorkflowExecution(executionId)` delegate to `tailor.workflow.resumeWorkflowExecution` at runtime. With the `tailor-runtime` environment active, use `mockWorkflow().setResumeHandler` to control the returned execution ID and inspect `resumeWorkflowExecution.mock.calls`:
|
|
584
595
|
|
|
585
596
|
```typescript
|
|
586
597
|
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
@@ -600,7 +611,7 @@ describe("retryFailedWorkflow resolver", () => {
|
|
|
600
611
|
});
|
|
601
612
|
|
|
602
613
|
expect(result).toEqual({ resumedExecutionId: "exec-resumed-123" });
|
|
603
|
-
expect(wf.
|
|
614
|
+
expect(wf.resumeWorkflowExecution.mock.calls).toEqual([["exec-failed-456"]]);
|
|
604
615
|
});
|
|
605
616
|
});
|
|
606
617
|
```
|
|
@@ -687,24 +698,26 @@ describe("validateOrder", () => {
|
|
|
687
698
|
|
|
688
699
|
#### Jobs that trigger other jobs
|
|
689
700
|
|
|
690
|
-
|
|
701
|
+
Use `mockWorkflow().job(definition)` to replace dependent jobs with deterministic results:
|
|
691
702
|
|
|
692
703
|
```typescript
|
|
693
|
-
import {
|
|
704
|
+
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
705
|
+
import { describe, expect, test } from "vitest";
|
|
694
706
|
import { fulfillOrder, processPayment, sendConfirmation, validateOrder } from "./order-fulfillment";
|
|
695
707
|
|
|
696
708
|
describe("fulfillOrder", () => {
|
|
697
709
|
test("chains validate → pay → confirm", async () => {
|
|
698
|
-
using
|
|
710
|
+
using wf = mockWorkflow();
|
|
711
|
+
const validate = wf.job(validateOrder).mockResolvedValue({
|
|
699
712
|
valid: true,
|
|
700
713
|
orderId: "order-1",
|
|
701
714
|
});
|
|
702
|
-
|
|
715
|
+
wf.job(processPayment).mockResolvedValue({
|
|
703
716
|
transactionId: "txn-order-1",
|
|
704
717
|
amount: 100,
|
|
705
718
|
status: "completed",
|
|
706
719
|
});
|
|
707
|
-
|
|
720
|
+
wf.job(sendConfirmation).mockResolvedValue({
|
|
708
721
|
orderId: "order-1",
|
|
709
722
|
transactionId: "txn-order-1",
|
|
710
723
|
confirmed: true,
|
|
@@ -715,7 +728,7 @@ describe("fulfillOrder", () => {
|
|
|
715
728
|
{ env: {}, invoker: null },
|
|
716
729
|
);
|
|
717
730
|
|
|
718
|
-
expect(
|
|
731
|
+
expect(validate).toHaveBeenCalledWith({ orderId: "order-1", amount: 100 });
|
|
719
732
|
expect(result).toMatchObject({ confirmed: true, paymentStatus: "completed" });
|
|
720
733
|
});
|
|
721
734
|
});
|
|
@@ -725,17 +738,18 @@ describe("fulfillOrder", () => {
|
|
|
725
738
|
|
|
726
739
|
#### Jobs that wait on approval
|
|
727
740
|
|
|
728
|
-
`.wait()` calls delegate to `tailor.workflow.wait`. With the `tailor-runtime` environment active, use `mockWorkflow().
|
|
741
|
+
`.wait()` calls delegate to `tailor.workflow.wait`. With the `tailor-runtime` environment active, use `mockWorkflow().waitPoint(definition)` to drive each branch with a typed mock:
|
|
729
742
|
|
|
730
743
|
```typescript
|
|
731
744
|
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
732
745
|
import { describe, expect, test } from "vitest";
|
|
733
|
-
import { processWithApproval } from "./approval";
|
|
746
|
+
import { approval, processWithApproval } from "./approval";
|
|
734
747
|
|
|
735
748
|
describe("processWithApproval", () => {
|
|
736
749
|
test("returns approved status when .wait() resolves positively", async () => {
|
|
737
750
|
using wf = mockWorkflow();
|
|
738
|
-
wf.
|
|
751
|
+
const approvalMock = wf.waitPoint(approval);
|
|
752
|
+
approvalMock.wait.mockResolvedValue({ approved: true });
|
|
739
753
|
|
|
740
754
|
const result = await processWithApproval.body(
|
|
741
755
|
{ orderId: "order-1" },
|
|
@@ -743,15 +757,15 @@ describe("processWithApproval", () => {
|
|
|
743
757
|
);
|
|
744
758
|
|
|
745
759
|
expect(result).toEqual({ orderId: "order-1", status: "approved" });
|
|
746
|
-
expect(
|
|
747
|
-
|
|
748
|
-
|
|
760
|
+
expect(approvalMock.wait).toHaveBeenCalledWith({
|
|
761
|
+
message: "Please approve order order-1",
|
|
762
|
+
orderId: "order-1",
|
|
749
763
|
});
|
|
750
764
|
});
|
|
751
765
|
|
|
752
766
|
test("returns rejected status when .wait() resolves negatively", async () => {
|
|
753
767
|
using wf = mockWorkflow();
|
|
754
|
-
wf.
|
|
768
|
+
wf.waitPoint(approval).wait.mockResolvedValue({ approved: false });
|
|
755
769
|
|
|
756
770
|
const result = await processWithApproval.body(
|
|
757
771
|
{ orderId: "order-2" },
|
|
@@ -763,7 +777,7 @@ describe("processWithApproval", () => {
|
|
|
763
777
|
});
|
|
764
778
|
```
|
|
765
779
|
|
|
766
|
-
`setWaitHandler`
|
|
780
|
+
The lower-level `setWaitHandler` and `waitCalls` APIs remain available when one handler must cover several wait points.
|
|
767
781
|
|
|
768
782
|
#### Running a full workflow locally
|
|
769
783
|
|
|
@@ -783,6 +797,8 @@ describe("order-fulfillment workflow", () => {
|
|
|
783
797
|
});
|
|
784
798
|
```
|
|
785
799
|
|
|
800
|
+
Acquire `mockWorkflow()` only when you need to override a dependent definition with `wf.job(...)` / `wf.workflow(...)` (the rest still run their real bodies), control the env via `wf.setEnv(...)`, or assert on calls.
|
|
801
|
+
|
|
786
802
|
Pass `{ env }` as the third argument when job bodies need configuration values during the local run.
|
|
787
803
|
|
|
788
804
|
If you already acquired `mockWorkflow()`, you can also call `wf.setEnv(...)` to reuse the same env across local workflow runs.
|
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.6",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -157,61 +157,58 @@
|
|
|
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",
|
|
168
168
|
"chalk": "5.6.2",
|
|
169
|
-
"chokidar": "5.0.0",
|
|
170
169
|
"confbox": "0.2.4",
|
|
171
170
|
"date-fns": "4.4.0",
|
|
172
171
|
"es-toolkit": "1.49.0",
|
|
173
172
|
"find-up-simple": "1.0.1",
|
|
174
173
|
"globals": "17.7.0",
|
|
175
|
-
"graphql": "17.0.
|
|
174
|
+
"graphql": "17.0.2",
|
|
176
175
|
"inflection": "3.0.2",
|
|
177
|
-
"kysely": "0.29.
|
|
178
|
-
"madge": "8.0.0",
|
|
176
|
+
"kysely": "0.29.3",
|
|
179
177
|
"mime-types": "3.0.2",
|
|
180
178
|
"open": "11.0.0",
|
|
181
|
-
"oxc-parser": "0.
|
|
179
|
+
"oxc-parser": "0.139.0",
|
|
182
180
|
"p-limit": "7.3.0",
|
|
183
181
|
"pathe": "2.0.3",
|
|
184
182
|
"pgsql-ast-parser": "12.0.2",
|
|
185
183
|
"pkg-types": "2.3.1",
|
|
186
|
-
"politty": "0.11.
|
|
187
|
-
"rolldown": "1.1.
|
|
184
|
+
"politty": "0.11.2",
|
|
185
|
+
"rolldown": "1.1.5",
|
|
188
186
|
"semver": "7.8.5",
|
|
189
187
|
"sql-highlight": "6.1.0",
|
|
190
|
-
"std-env": "4.
|
|
188
|
+
"std-env": "4.2.0",
|
|
191
189
|
"table": "6.9.0",
|
|
192
190
|
"ts-cron-validator": "1.1.5",
|
|
193
|
-
"type-fest": "5.
|
|
194
|
-
"undici": "8.
|
|
191
|
+
"type-fest": "5.8.0",
|
|
192
|
+
"undici": "8.7.0",
|
|
195
193
|
"xdg-basedir": "5.1.0",
|
|
196
194
|
"zod": "4.4.3"
|
|
197
195
|
},
|
|
198
196
|
"devDependencies": {
|
|
199
197
|
"@opentelemetry/sdk-trace-base": "2.9.0",
|
|
200
|
-
"@types/madge": "5.0.3",
|
|
201
198
|
"@types/mime-types": "3.0.1",
|
|
202
|
-
"@types/node": "24.13.
|
|
199
|
+
"@types/node": "24.13.3",
|
|
203
200
|
"@types/semver": "7.7.1",
|
|
204
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
205
|
-
"@vitest/coverage-v8": "4.1.
|
|
201
|
+
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
202
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
206
203
|
"eslint-plugin-zod": "4.7.0",
|
|
207
|
-
"oxfmt": "0.
|
|
208
|
-
"oxlint": "1.
|
|
204
|
+
"oxfmt": "0.58.0",
|
|
205
|
+
"oxlint": "1.73.0",
|
|
209
206
|
"oxlint-tsgolint": "0.24.0",
|
|
210
|
-
"sonda": "0.
|
|
211
|
-
"tsdown": "0.22.
|
|
207
|
+
"sonda": "0.14.0",
|
|
208
|
+
"tsdown": "0.22.5",
|
|
212
209
|
"typescript": "6.0.3",
|
|
213
|
-
"vitest": "4.1.
|
|
214
|
-
"zinfer": "0.2.
|
|
210
|
+
"vitest": "4.1.10",
|
|
211
|
+
"zinfer": "0.2.5",
|
|
215
212
|
"@tailor-platform/tailor-proto": "^0.0.0"
|
|
216
213
|
},
|
|
217
214
|
"peerDependencies": {
|
|
@@ -244,7 +241,7 @@
|
|
|
244
241
|
"check:import-cycles": "node --experimental-strip-types scripts/check-import-cycles.ts",
|
|
245
242
|
"lint:fix": "oxlint --type-aware . --fix",
|
|
246
243
|
"typecheck": "tsc --noEmit",
|
|
247
|
-
"typecheck:go": "tsgo",
|
|
244
|
+
"typecheck:go": "tsgo --tsBuildInfoFile ./.tsgo.tsbuildinfo",
|
|
248
245
|
"perf:typecheck": "bash scripts/perf/exec.sh",
|
|
249
246
|
"perf:runtime": "bash scripts/perf/runtime-perf.sh",
|
|
250
247
|
"prepublish": "pnpm run build",
|