@tailor-platform/sdk 1.76.1 → 1.78.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/dist/{application-BUfYmf0O.mjs → application-CUxVA7Fs.mjs} +378 -1679
- package/dist/application-CUxVA7Fs.mjs.map +1 -0
- package/dist/application-Dp_-ioiP.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/service.d.mts +5 -1
- package/dist/cli/commands/generate/types.d.mts +3 -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 +0 -1
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +0 -1
- 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 +3 -1
- package/dist/cli/index.mjs +660 -56
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +4 -2
- package/dist/cli/lib.mjs +3 -3
- 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 +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/shared/workspace-name.d.mts +1 -0
- package/dist/cli/skills.mjs +1 -1
- package/dist/completion/zsh-worker.zsh +18 -1
- package/dist/configure/config/index.d.mts +0 -1
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +2 -1
- package/dist/configure/index.mjs +248 -4
- 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 +14 -13
- package/dist/configure/services/executor/executor.d.mts +0 -1
- package/dist/configure/services/executor/index.d.mts +1 -0
- package/dist/configure/services/executor/operation.d.mts +1 -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 +5 -0
- package/dist/configure/services/resolver/resolver.d.mts +0 -1
- 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 +21 -8
- package/dist/configure/services/tailordb/types.d.mts +4 -5
- package/dist/configure/services/workflow/execution-policy.d.mts +0 -1
- 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 +0 -1
- package/dist/configure/types/field-runtime.d.mts +1 -1
- package/dist/configure/types/field.d.mts +1 -2
- package/dist/configure/types/field.types.d.mts +1 -2
- package/dist/configure/types/type.d.mts +1 -1
- package/dist/configure/user.d.mts +0 -1
- package/dist/{crashreport-ayWANEZ6.mjs → crashreport-BNWUM6Kf.mjs} +4 -3
- package/dist/{crashreport-ayWANEZ6.mjs.map → crashreport-BNWUM6Kf.mjs.map} +1 -1
- package/dist/{crashreport-Dy4ZzSkd.mjs → crashreport-BafWvjjX.mjs} +1 -1
- package/dist/errors-DVFS0AZk.mjs +100 -0
- package/dist/errors-DVFS0AZk.mjs.map +1 -0
- package/dist/{globals-CcU1ONiK.mjs → globals-CvizbGLY.mjs} +2 -2
- package/dist/{globals-CcU1ONiK.mjs.map → globals-CvizbGLY.mjs.map} +1 -1
- package/dist/kysely/index.d.mts +3 -4
- 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 +1 -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 +0 -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/seed/index.d.mts +0 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/get-generated-type.d.mts +0 -1
- package/dist/plugin/manager.d.mts +3 -1
- package/dist/plugin/types.d.mts +0 -1
- package/dist/plugin/with-context.d.mts +0 -1
- package/dist/{registry-NfSW0BRo.mjs → registry-CYBRvfaU.mjs} +4 -49
- package/dist/registry-CYBRvfaU.mjs.map +1 -0
- package/dist/runtime/aigateway.d.mts +0 -2
- package/dist/runtime/authconnection.d.mts +0 -2
- package/dist/runtime/globals.d.mts +0 -1
- package/dist/runtime/index.d.mts +0 -1
- package/dist/runtime/types.d.mts +16 -7
- package/dist/{runtime-_vUgjiqT.mjs → runtime-BD2vYJFT.mjs} +2382 -1167
- package/dist/runtime-BD2vYJFT.mjs.map +1 -0
- package/dist/{schema-DrVyN-LP.mjs → schema-U6DxoZ8D.mjs} +204 -3
- package/dist/schema-U6DxoZ8D.mjs.map +1 -0
- package/dist/{secret-file-VSVGy1V0.mjs → secret-file-DBqZhjFQ.mjs} +2 -27
- package/dist/{secret-file-VSVGy1V0.mjs.map → secret-file-DBqZhjFQ.mjs.map} +1 -1
- 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/{seed-fm0LeYP2.mjs → seed-DFFigL8V.mjs} +3 -13
- package/dist/seed-DFFigL8V.mjs.map +1 -0
- package/dist/service-CghpdV-9.mjs +3 -0
- package/dist/{service-DBFZQloR.mjs → service-Cp0I7ZFe.mjs} +3 -3
- package/dist/{service-DBFZQloR.mjs.map → service-Cp0I7ZFe.mjs.map} +1 -1
- package/dist/{service-BCRJ-3NV.mjs → service-D12iQGcS.mjs} +2 -2
- package/dist/{service-BCRJ-3NV.mjs.map → service-D12iQGcS.mjs.map} +1 -1
- 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/test-env-key-DuZycyWM.mjs +49 -0
- package/dist/test-env-key-DuZycyWM.mjs.map +1 -0
- package/dist/type-source-DH_LH20p.mjs +13 -0
- package/dist/type-source-DH_LH20p.mjs.map +1 -0
- package/dist/types/aigateway.generated.d.mts +5 -2
- package/dist/types/auth-connection.generated.d.mts +11 -5
- package/dist/types/auth.generated.d.mts +118 -85
- package/dist/types/executor.generated.d.mts +76 -84
- package/dist/types/helpers.d.mts +5 -5
- 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 +24 -10
- package/dist/types/staticwebsite.generated.d.mts +7 -3
- package/dist/types/tailordb.generated.d.mts +55 -29
- package/dist/types/workflow.generated.d.mts +9 -4
- package/dist/user-agent-DX2Jnw0-.mjs +28 -0
- package/dist/user-agent-DX2Jnw0-.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +0 -1
- package/dist/utils/test/index.mjs +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 +600 -185
- 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 +24 -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 +48 -11
- package/dist/vitest/setup.mjs +2 -2
- 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 +58 -11
- package/docs/cli/setup.md +1 -1
- package/docs/cli/workspace.md +6 -4
- package/docs/cli-reference.md +12 -8
- package/docs/runtime.md +3 -4
- package/docs/services/aigateway.md +2 -0
- package/docs/services/tailordb.md +52 -1
- package/docs/services/workflow.md +1 -1
- package/docs/testing.md +103 -89
- package/package.json +16 -16
- package/dist/application-BUfYmf0O.mjs.map +0 -1
- package/dist/application-DbvD5UUz.mjs +0 -3
- package/dist/cli/shared/trigger-context.d.mts +0 -1
- package/dist/errors-Dtf2WPaW.mjs +0 -42
- package/dist/errors-Dtf2WPaW.mjs.map +0 -1
- package/dist/field-runtime-9bfXBAOK.mjs +0 -183
- package/dist/field-runtime-9bfXBAOK.mjs.map +0 -1
- package/dist/job-D-PbD1P3.mjs +0 -55
- package/dist/job-D-PbD1P3.mjs.map +0 -1
- package/dist/logger-BEiZZ3qT.mjs.map +0 -1
- package/dist/registry-NfSW0BRo.mjs.map +0 -1
- package/dist/resource_pb-BRv7AMXK.mjs +0 -49
- package/dist/resource_pb-BRv7AMXK.mjs.map +0 -1
- package/dist/runtime-_vUgjiqT.mjs.map +0 -1
- package/dist/schema-DrVyN-LP.mjs.map +0 -1
- package/dist/secretmanager-Bd45j7an.mjs.map +0 -1
- package/dist/seed-fm0LeYP2.mjs.map +0 -1
- package/dist/service-CPMlIg3X.mjs +0 -3
- package/dist/service_pb-B5w9rjPY.mjs.map +0 -1
- package/dist/types-BwzB2okW.mjs +0 -199
- package/dist/types-BwzB2okW.mjs.map +0 -1
- package/dist/types-KlawuVKa.mjs +0 -4
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
import { AuthConnectionTokenResult, ConnectionName } from "@tailor-platform/sdk";
|
|
2
|
-
|
|
3
2
|
//#region src/vitest/mocks/authconnection.d.ts
|
|
4
3
|
interface AuthConnectionCall {
|
|
5
4
|
connectionName: ConnectionName;
|
|
6
5
|
}
|
|
6
|
+
/** Initial fixtures and fallback behavior for an AuthConnection mock. */
|
|
7
|
+
interface MockAuthconnectionOptions {
|
|
8
|
+
/** Tokens available when the mock is acquired. */
|
|
9
|
+
tokens?: Partial<Record<ConnectionName, AuthConnectionTokenResult>>;
|
|
10
|
+
/** Return a placeholder token or throw when a connection has no configured token. */
|
|
11
|
+
onUnhandled?: "fallback" | "error";
|
|
12
|
+
}
|
|
7
13
|
/**
|
|
8
14
|
* Acquire a disposable mock for `tailor.authconnection`. Restored on dispose.
|
|
15
|
+
* @param options - Initial token fixtures and fallback behavior
|
|
9
16
|
* @returns Disposable AuthConnection mock control object
|
|
10
17
|
* @example
|
|
11
18
|
* ```typescript
|
|
12
19
|
* import { mockAuthconnection } from "@tailor-platform/sdk/vitest";
|
|
13
20
|
*
|
|
14
21
|
* test("returns configured token", async () => {
|
|
15
|
-
* using ac = mockAuthconnection();
|
|
16
|
-
* ac.
|
|
22
|
+
* using ac = mockAuthconnection({ tokens: { google: { access_token: "ya29.xxx" } } });
|
|
23
|
+
* ac.setToken("google", { access_token: "replacement" });
|
|
17
24
|
* // …
|
|
18
25
|
* });
|
|
19
26
|
* ```
|
|
20
27
|
*/
|
|
21
|
-
declare function mockAuthconnection(): {
|
|
22
|
-
/** The `getConnectionToken` `vi.fn`. */
|
|
28
|
+
declare function mockAuthconnection(options?: MockAuthconnectionOptions): {
|
|
29
|
+
/** The `getConnectionToken` `vi.fn`. */
|
|
30
|
+
getConnectionToken: import("vitest").Mock<(connectionName: ConnectionName) => Promise<AuthConnectionTokenResult>>;
|
|
23
31
|
setTokens(value: Partial<Record<ConnectionName, AuthConnectionTokenResult>>): void;
|
|
32
|
+
setToken(connectionName: ConnectionName, token: AuthConnectionTokenResult): void;
|
|
24
33
|
readonly calls: AuthConnectionCall[];
|
|
34
|
+
clear(): void;
|
|
25
35
|
reset(): void;
|
|
26
36
|
} & Disposable;
|
|
27
37
|
//#endregion
|
|
28
|
-
export { mockAuthconnection };
|
|
38
|
+
export { MockAuthconnectionOptions, mockAuthconnection };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { FileDownloadAsBase64Response, FileDownloadResponse, FileDownloadStreamResponse, FileMetadata, FileStreamIterator, FileUploadOptions, FileUploadResponse, FileUploadStreamOptions } from "../../runtime/file.mjs";
|
|
2
|
+
import { Mock } from "vitest";
|
|
1
3
|
//#region src/vitest/mocks/file.d.ts
|
|
2
4
|
type FileResolver = (method: string, call: FileCall) => unknown;
|
|
3
5
|
interface FileCall {
|
|
@@ -7,8 +9,14 @@ interface FileCall {
|
|
|
7
9
|
fieldName: string;
|
|
8
10
|
recordId: string;
|
|
9
11
|
}
|
|
12
|
+
/** Controls fallback behavior for File calls without a configured result. */
|
|
13
|
+
interface MockFileOptions {
|
|
14
|
+
/** Return a type-compatible fixture or throw when no behavior is configured. */
|
|
15
|
+
onUnhandled?: "fallback" | "error";
|
|
16
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* Acquire a disposable mock for `tailordb.file`. Restored on dispose.
|
|
19
|
+
* @param options - Controls behavior for calls without a configured result
|
|
12
20
|
* @returns Disposable File mock control object
|
|
13
21
|
* @example
|
|
14
22
|
* ```typescript
|
|
@@ -16,26 +24,36 @@ interface FileCall {
|
|
|
16
24
|
*
|
|
17
25
|
* test("mock file download", async () => {
|
|
18
26
|
* using file = mockFile();
|
|
19
|
-
* file.
|
|
27
|
+
* file.download.mockResolvedValue({ data: new Uint8Array(), metadata: { ... } });
|
|
20
28
|
* // …
|
|
21
29
|
* });
|
|
22
30
|
* ```
|
|
23
31
|
*/
|
|
24
|
-
declare function mockFile(): {
|
|
32
|
+
declare function mockFile(options?: MockFileOptions): {
|
|
25
33
|
setResolver(value: FileResolver): void;
|
|
26
34
|
/**
|
|
27
|
-
* Enqueue a single result for the next `tailordb.file` call
|
|
28
|
-
*
|
|
35
|
+
* Enqueue a single result for the next `tailordb.file` call.
|
|
36
|
+
* The queue is shared across all methods and namespaces.
|
|
29
37
|
* @param result - Result to return from the next file call
|
|
30
38
|
*/
|
|
31
39
|
enqueueResult(result: unknown): void;
|
|
32
40
|
/**
|
|
33
41
|
* Enqueue results for multiple subsequent `tailordb.file` calls.
|
|
42
|
+
* The queue is shared across all methods and namespaces.
|
|
34
43
|
* @param results - Results to enqueue, one per upcoming call
|
|
35
44
|
*/
|
|
36
45
|
enqueueResults(...results: unknown[]): void;
|
|
37
|
-
|
|
46
|
+
calls: FileCall[];
|
|
47
|
+
clear(): void;
|
|
38
48
|
reset(): void;
|
|
49
|
+
delete: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<void>>;
|
|
50
|
+
upload: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string, data: string | ArrayBuffer | Uint8Array | number[], options?: FileUploadOptions) => Promise<FileUploadResponse>>;
|
|
51
|
+
download: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileDownloadResponse>>;
|
|
52
|
+
downloadAsBase64: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileDownloadAsBase64Response>>;
|
|
53
|
+
getMetadata: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileMetadata>>;
|
|
54
|
+
openDownloadStream: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileStreamIterator>>;
|
|
55
|
+
downloadStream: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string) => Promise<FileDownloadStreamResponse>>;
|
|
56
|
+
uploadStream: Mock<(namespace: string, typeName: string, fieldName: string, recordId: string, readableStream: ReadableStream<Uint8Array | ArrayBuffer>, options?: FileUploadStreamOptions) => Promise<FileUploadResponse>>;
|
|
39
57
|
} & Disposable;
|
|
40
58
|
//#endregion
|
|
41
|
-
export { mockFile };
|
|
59
|
+
export { MockFileOptions, mockFile };
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
+
import { MockInstance } from "vitest";
|
|
1
2
|
//#region src/vitest/mocks/iconv.d.ts
|
|
2
3
|
type IconvResolver = (method: string, args: unknown[]) => unknown;
|
|
4
|
+
type IconvMethod = "convert" | "convertBuffer" | "decode" | "encode" | "encodings";
|
|
3
5
|
interface IconvCall {
|
|
4
|
-
method:
|
|
6
|
+
method: IconvMethod;
|
|
5
7
|
args: unknown[];
|
|
6
8
|
}
|
|
9
|
+
type ConversionResult = string | Uint8Array;
|
|
10
|
+
type ConvertMockProcedure = (input: string | Uint8Array | ArrayBuffer, fromEncoding: string, toEncoding: string) => ConversionResult;
|
|
11
|
+
type ConvertBufferMockProcedure = (input: Uint8Array | ArrayBuffer, fromEncoding: string, toEncoding: string) => ConversionResult;
|
|
12
|
+
type EncodeMockProcedure = (input: string, encoding: string) => ConversionResult;
|
|
13
|
+
type TypedOperationMock<RuntimeProcedure, MockProcedure extends (...args: never[]) => unknown> = RuntimeProcedure & MockInstance<MockProcedure>;
|
|
14
|
+
/** Controls how unconfigured Iconv operations are handled. */
|
|
15
|
+
interface MockIconvOptions {
|
|
16
|
+
/** Return an empty type-compatible value or throw when no behavior is configured. */
|
|
17
|
+
onUnhandled?: "fallback" | "error";
|
|
18
|
+
}
|
|
7
19
|
/**
|
|
8
20
|
* Acquire a disposable mock for `tailor.iconv`. Restored on dispose.
|
|
21
|
+
* @param options - Fallback behavior for unconfigured operations
|
|
9
22
|
* @returns Disposable Iconv mock control object
|
|
10
23
|
* @example
|
|
11
24
|
* ```typescript
|
|
@@ -13,15 +26,26 @@ interface IconvCall {
|
|
|
13
26
|
*
|
|
14
27
|
* test("mock encoding conversion", () => {
|
|
15
28
|
* using iconv = mockIconv();
|
|
16
|
-
* iconv.
|
|
29
|
+
* iconv.decode.mockReturnValue("decoded-text");
|
|
17
30
|
* // …
|
|
18
31
|
* });
|
|
19
32
|
* ```
|
|
20
33
|
*/
|
|
21
|
-
declare function mockIconv(): {
|
|
34
|
+
declare function mockIconv(options?: MockIconvOptions): {
|
|
35
|
+
/** The `convert` `vi.fn`. */
|
|
36
|
+
convert: TypedOperationMock<(<T extends string>(str: string | Uint8Array | ArrayBuffer, fromEncoding: string, toEncoding: T) => T extends "UTF8" | "UTF-8" ? string : Uint8Array), ConvertMockProcedure>;
|
|
37
|
+
/** The `convertBuffer` `vi.fn`. */
|
|
38
|
+
convertBuffer: TypedOperationMock<(<T extends string>(buffer: Uint8Array | ArrayBuffer, fromEncoding: string, toEncoding: T) => T extends "UTF8" | "UTF-8" ? string : Uint8Array), ConvertBufferMockProcedure>;
|
|
39
|
+
/** The `decode` `vi.fn`. */
|
|
40
|
+
decode: import("vitest").Mock<(input: Uint8Array | ArrayBuffer, encoding: string) => string>;
|
|
41
|
+
/** The `encode` `vi.fn`. */
|
|
42
|
+
encode: TypedOperationMock<(<T extends string>(str: string, encoding: T) => T extends "UTF8" | "UTF-8" ? string : Uint8Array), EncodeMockProcedure>;
|
|
43
|
+
/** The `encodings` `vi.fn`. */
|
|
44
|
+
encodings: import("vitest").Mock<() => string[]>;
|
|
22
45
|
setResolver(value: IconvResolver): void;
|
|
23
46
|
readonly calls: IconvCall[];
|
|
47
|
+
clear: () => void;
|
|
24
48
|
reset(): void;
|
|
25
49
|
} & Disposable;
|
|
26
50
|
//#endregion
|
|
27
|
-
export { mockIconv };
|
|
51
|
+
export { MockIconvOptions, mockIconv };
|
|
@@ -1,44 +1,60 @@
|
|
|
1
|
+
import { IdpClientConstructor, IdpClientInstance } from "../../runtime/idp.mjs";
|
|
1
2
|
import { Mock } from "vitest";
|
|
2
|
-
|
|
3
3
|
//#region src/vitest/mocks/idp.d.ts
|
|
4
|
+
type IdpMethod = keyof IdpClientInstance;
|
|
4
5
|
type IdpResolver = (method: string, args: unknown[], namespace: string) => unknown;
|
|
5
6
|
interface IdpCall {
|
|
6
7
|
method: string;
|
|
7
8
|
args: unknown[];
|
|
8
9
|
namespace: string;
|
|
9
10
|
}
|
|
11
|
+
/** Controls fallback behavior for IdP calls without a configured result. */
|
|
12
|
+
interface MockIdpOptions {
|
|
13
|
+
/** Return a type-compatible fixture or throw when no behavior is configured. */
|
|
14
|
+
onUnhandled?: "fallback" | "error";
|
|
15
|
+
}
|
|
16
|
+
type IdpNamespaceMocks = { [Method in IdpMethod]: Mock<IdpClientInstance[Method]>; };
|
|
10
17
|
/**
|
|
11
18
|
* Acquire a disposable mock for `tailor.idp`. Restored on dispose.
|
|
19
|
+
* @param options - Controls behavior for calls without a configured result
|
|
12
20
|
* @returns Disposable IDP mock control object
|
|
13
21
|
* @example
|
|
14
22
|
* ```typescript
|
|
15
23
|
* import { mockIdp } from "@tailor-platform/sdk/vitest";
|
|
16
24
|
*
|
|
17
|
-
* test("
|
|
25
|
+
* test("returns a user", async () => {
|
|
18
26
|
* using idp = mockIdp();
|
|
19
|
-
* idp.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
27
|
+
* idp.namespace("my-idp").user.mockResolvedValue({
|
|
28
|
+
* id: "u-1",
|
|
29
|
+
* name: "alice",
|
|
30
|
+
* disabled: false,
|
|
31
|
+
* mfaEnrolled: false,
|
|
32
|
+
* mfaFactorIds: [],
|
|
33
|
+
* });
|
|
22
34
|
* // …
|
|
23
35
|
* });
|
|
24
36
|
* ```
|
|
25
37
|
*/
|
|
26
|
-
declare function mockIdp(): {
|
|
27
|
-
/** The mock IDP `Client` constructor (`vi.fn`). */
|
|
38
|
+
declare function mockIdp(options?: MockIdpOptions): {
|
|
39
|
+
/** The mock IDP `Client` constructor (`vi.fn`). */
|
|
40
|
+
Client: Mock<IdpClientConstructor>;
|
|
41
|
+
namespace: (name: string) => IdpNamespaceMocks;
|
|
28
42
|
setResolver(value: IdpResolver): void;
|
|
29
43
|
/**
|
|
30
|
-
* Enqueue a single result for the next IDP call
|
|
31
|
-
*
|
|
44
|
+
* Enqueue a single result for the next IDP call.
|
|
45
|
+
* The queue is shared across all methods and namespaces.
|
|
32
46
|
* @param result - Result to return from the next IDP call
|
|
33
47
|
*/
|
|
34
48
|
enqueueResult(result: unknown): void;
|
|
35
49
|
/**
|
|
36
50
|
* Enqueue results for multiple subsequent IDP calls.
|
|
51
|
+
* The queue is shared across all methods and namespaces.
|
|
37
52
|
* @param results - Results to enqueue, one per upcoming call
|
|
38
53
|
*/
|
|
39
54
|
enqueueResults(...results: unknown[]): void;
|
|
40
55
|
readonly calls: IdpCall[];
|
|
56
|
+
clear(): void;
|
|
41
57
|
reset(): void;
|
|
42
58
|
} & Disposable;
|
|
43
59
|
//#endregion
|
|
44
|
-
export { mockIdp };
|
|
60
|
+
export { MockIdpOptions, mockIdp };
|
|
@@ -5,29 +5,40 @@ interface SecretCall {
|
|
|
5
5
|
name?: string;
|
|
6
6
|
names?: readonly string[];
|
|
7
7
|
}
|
|
8
|
+
/** Initial fixtures for a Secret Manager mock. */
|
|
9
|
+
interface MockSecretmanagerOptions {
|
|
10
|
+
/** Secrets to merge over fixtures inherited from the currently installed mock. */
|
|
11
|
+
secrets?: Record<string, Record<string, string>>;
|
|
12
|
+
}
|
|
8
13
|
/**
|
|
9
14
|
* Acquire a disposable mock for `tailor.secretmanager`. The secret store is
|
|
10
15
|
* inherited (cloned) from the currently-installed mock on acquisition and
|
|
11
16
|
* restored on dispose, so secrets seeded outside the test survive across
|
|
12
17
|
* `using` scopes while per-test `setSecrets()` overrides stay isolated.
|
|
18
|
+
* @param options - Initial Secret Manager fixtures
|
|
13
19
|
* @returns Disposable SecretManager mock control object
|
|
14
20
|
* @example
|
|
15
21
|
* ```typescript
|
|
16
22
|
* import { mockSecretmanager } from "@tailor-platform/sdk/vitest";
|
|
17
23
|
*
|
|
18
24
|
* test("reads secrets from vault", async () => {
|
|
19
|
-
* using sm = mockSecretmanager();
|
|
20
|
-
* sm.
|
|
25
|
+
* using sm = mockSecretmanager({ secrets: { "my-vault": { API_KEY: "sk-123" } } });
|
|
26
|
+
* sm.setSecret("my-vault", "API_KEY", "replacement");
|
|
21
27
|
* // …
|
|
22
28
|
* });
|
|
23
29
|
* ```
|
|
24
30
|
*/
|
|
25
|
-
declare function mockSecretmanager(): {
|
|
26
|
-
/** The `getSecret` `vi.fn`. */
|
|
31
|
+
declare function mockSecretmanager(options?: MockSecretmanagerOptions): {
|
|
32
|
+
/** The `getSecret` `vi.fn`. */
|
|
33
|
+
getSecret: import("vitest").Mock<(vault: string, name: string) => Promise<string | undefined>>;
|
|
34
|
+
/** The `getSecrets` `vi.fn`. */
|
|
27
35
|
getSecrets: import("vitest").Mock<(<const T extends readonly string[]>(vault: string, names: T) => Promise<Partial<Record<T[number], string>>>)>;
|
|
28
36
|
setSecrets(secrets: Record<string, Record<string, string>>): void;
|
|
37
|
+
setSecret(vault: string, name: string, value: string): void;
|
|
38
|
+
mergeSecrets(vault: string, secrets: Record<string, string>): void;
|
|
29
39
|
readonly calls: SecretCall[];
|
|
40
|
+
clear(): void;
|
|
30
41
|
reset(): void;
|
|
31
42
|
} & Disposable;
|
|
32
43
|
//#endregion
|
|
33
|
-
export { mockSecretmanager };
|
|
44
|
+
export { MockSecretmanagerOptions, mockSecretmanager };
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
//#region src/vitest/mocks/tailordb.d.ts
|
|
2
|
-
type QueryResolver = (query: string, params: unknown[]) => unknown[];
|
|
2
|
+
type QueryResolver = (query: string, params: unknown[]) => unknown[] | undefined;
|
|
3
|
+
/** Controls how unmatched TailorDB queries are handled. */
|
|
4
|
+
interface MockTailordbOptions {
|
|
5
|
+
/** Return an empty result or throw when no configured query behavior matches. */
|
|
6
|
+
onUnhandled?: "fallback" | "error";
|
|
7
|
+
}
|
|
8
|
+
/** Matches a TailorDB query by SQL text and optionally by parameters. */
|
|
9
|
+
interface QueryMatch {
|
|
10
|
+
/** Exact SQL text or regular expression to match. */
|
|
11
|
+
sql: string | RegExp;
|
|
12
|
+
/** Exact parameters or a predicate for parameter matching. */
|
|
13
|
+
params?: readonly unknown[] | ((params: unknown[]) => boolean);
|
|
14
|
+
}
|
|
15
|
+
/** Selects TailorDB queries that receive a configured response. */
|
|
16
|
+
type QueryMatcher = string | RegExp | QueryMatch | ((query: string, params: unknown[]) => boolean);
|
|
17
|
+
/** Configures persistent and one-time responses for matched queries. */
|
|
18
|
+
interface QueryBehavior<Row> {
|
|
19
|
+
/** Return these rows for every matching query after one-time responses are consumed. */
|
|
20
|
+
returnsRows(rows: Row[]): QueryBehavior<Row>;
|
|
21
|
+
/** Return these rows for the next matching query. */
|
|
22
|
+
returnsRowsOnce(rows: Row[]): QueryBehavior<Row>;
|
|
23
|
+
/** Reject every matching query after one-time responses are consumed. */
|
|
24
|
+
rejects(error: unknown): QueryBehavior<Row>;
|
|
25
|
+
/** Reject the next matching query. */
|
|
26
|
+
rejectsOnce(error: unknown): QueryBehavior<Row>;
|
|
27
|
+
}
|
|
3
28
|
interface ExecutedQuery {
|
|
4
29
|
query: string;
|
|
5
30
|
params: unknown[];
|
|
@@ -19,30 +44,41 @@ declare class MockQueryResult {
|
|
|
19
44
|
* `tailordb.Client` whose `queryObject` is a shared `vi.fn()` (so query
|
|
20
45
|
* responses can be staged before the client is constructed). Restored on
|
|
21
46
|
* dispose.
|
|
47
|
+
* @param options - Query fallback behavior
|
|
22
48
|
* @returns Disposable TailorDB mock control object
|
|
23
49
|
* @example
|
|
24
50
|
* ```typescript
|
|
25
51
|
* import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
26
52
|
*
|
|
27
|
-
* test("
|
|
53
|
+
* test("query-based", async () => {
|
|
28
54
|
* using db = mockTailordb();
|
|
29
|
-
* db.
|
|
55
|
+
* db.onQuery({ sql: /FROM users/, params: ["u-1"] }).returnsRows([{ age: 30 }]);
|
|
30
56
|
* // …
|
|
31
|
-
* expect(db.queryObject).
|
|
57
|
+
* expect(db.queryObject).toHaveBeenCalled();
|
|
32
58
|
* expect(db.Client).toHaveBeenCalledWith({ namespace: "tailordb" });
|
|
33
59
|
* });
|
|
34
60
|
* ```
|
|
35
61
|
*/
|
|
36
|
-
declare function mockTailordb(): {
|
|
37
|
-
/** The mock `tailordb.Client` constructor (`vi.fn`). */
|
|
62
|
+
declare function mockTailordb(options?: MockTailordbOptions): {
|
|
63
|
+
/** The mock `tailordb.Client` constructor (`vi.fn`). */
|
|
64
|
+
Client: import("vitest").Mock<(this: any, config?: {
|
|
38
65
|
namespace?: string;
|
|
39
|
-
}) => void>;
|
|
40
|
-
queryObject
|
|
66
|
+
}) => void>;
|
|
67
|
+
/** The shared `queryObject` `vi.fn` used by every client and transaction. */
|
|
68
|
+
queryObject: import("vitest").Mock<(query: string, params?: unknown[]) => Promise<MockQueryResult>>;
|
|
41
69
|
/**
|
|
42
70
|
* Set a fallback query resolver. Called when the enqueue queue is empty.
|
|
43
71
|
* @param resolver - Function that returns rows for a given query and params
|
|
44
72
|
*/
|
|
45
73
|
setQueryResolver(resolver: QueryResolver): void;
|
|
74
|
+
/**
|
|
75
|
+
* Configure responses for queries matching SQL text, parameters, or a predicate.
|
|
76
|
+
* More recently registered matchers take precedence.
|
|
77
|
+
* Do not combine matchers with a direct `queryObject.mockImplementation()` override.
|
|
78
|
+
* @param matcher - Query matcher
|
|
79
|
+
* @returns Chainable query behavior
|
|
80
|
+
*/
|
|
81
|
+
onQuery<Row = unknown>(matcher: QueryMatcher): QueryBehavior<Row>;
|
|
46
82
|
/**
|
|
47
83
|
* Enqueue rows for the next `queryObject` call (FIFO; takes priority over
|
|
48
84
|
* `setQueryResolver`). Call with no arguments for an empty result.
|
|
@@ -54,6 +90,11 @@ declare function mockTailordb(): {
|
|
|
54
90
|
* @param rowsList - Rows arrays, one per upcoming query
|
|
55
91
|
*/
|
|
56
92
|
enqueueResults(...rowsList: unknown[][]): void;
|
|
93
|
+
/**
|
|
94
|
+
* Enqueue row arrays for subsequent queries whose exact order is under test.
|
|
95
|
+
* @param rowsList - Rows arrays, one per upcoming query
|
|
96
|
+
*/
|
|
97
|
+
enqueueRows(...rowsList: unknown[][]): void;
|
|
57
98
|
/**
|
|
58
99
|
* All queries executed via `queryObject`, in order, derived from the vi.fn
|
|
59
100
|
* call records.
|
|
@@ -64,8 +105,11 @@ declare function mockTailordb(): {
|
|
|
64
105
|
* All TailorDB clients created, with their namespace and end state.
|
|
65
106
|
* @returns Created clients array
|
|
66
107
|
*/
|
|
67
|
-
readonly createdClients: CreatedClient[];
|
|
108
|
+
readonly createdClients: CreatedClient[];
|
|
109
|
+
/** Clear recorded calls while preserving configured query behavior. */
|
|
110
|
+
clear(): void;
|
|
111
|
+
/** Reset query responses and recorded calls (keeps the mock installed). */
|
|
68
112
|
reset(): void;
|
|
69
113
|
} & Disposable;
|
|
70
114
|
//#endregion
|
|
71
|
-
export { mockTailordb };
|
|
115
|
+
export { MockTailordbOptions, QueryBehavior, QueryMatch, QueryMatcher, mockTailordb };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { TailorEnv } from "../../runtime/types.mjs";
|
|
2
2
|
import { TriggerJobFunctionOptions } from "../../runtime/workflow.mjs";
|
|
3
|
-
|
|
3
|
+
import { WorkflowJob } from "../../configure/services/workflow/job.mjs";
|
|
4
|
+
import { Workflow } from "../../configure/services/workflow/workflow.mjs";
|
|
5
|
+
import { WaitPointInstance } from "../../configure/services/workflow/wait-point.mjs";
|
|
6
|
+
import { Mock } from "vitest";
|
|
4
7
|
//#region src/vitest/mocks/workflow.d.ts
|
|
5
8
|
type JobHandler = (jobName: string, args: unknown, options?: TriggerJobFunctionOptions) => unknown;
|
|
6
9
|
type TriggerWorkflowOptions = {
|
|
@@ -22,6 +25,7 @@ interface TriggeredJob {
|
|
|
22
25
|
args: unknown;
|
|
23
26
|
options?: TriggerJobFunctionOptions;
|
|
24
27
|
}
|
|
28
|
+
type WaitPayload<Payload> = [Payload] extends [undefined] ? undefined : Payload;
|
|
25
29
|
/**
|
|
26
30
|
* Acquire a disposable mock for workflow operations (`tailor.workflow`).
|
|
27
31
|
* Restored on dispose.
|
|
@@ -30,20 +34,50 @@ interface TriggeredJob {
|
|
|
30
34
|
* ```typescript
|
|
31
35
|
* import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
32
36
|
*
|
|
33
|
-
* test("job
|
|
37
|
+
* test("job trigger", async () => {
|
|
34
38
|
* using wf = mockWorkflow();
|
|
35
|
-
* wf.
|
|
36
|
-
*
|
|
37
|
-
*
|
|
39
|
+
* const job = wf.job(validateOrder);
|
|
40
|
+
* job.mockResolvedValue({ valid: true });
|
|
41
|
+
* await runWorkflowUnderTest();
|
|
42
|
+
* expect(job).toHaveBeenCalled();
|
|
38
43
|
* });
|
|
39
44
|
* ```
|
|
40
45
|
*/
|
|
41
46
|
declare function mockWorkflow(): {
|
|
42
|
-
/** The `triggerJobFunction` `vi.fn`. */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
/** The `triggerJobFunction` `vi.fn`. */
|
|
48
|
+
triggerJobFunction: Mock<(jobName: string, args?: unknown, _options?: TriggerJobFunctionOptions) => unknown>;
|
|
49
|
+
/** The `triggerWorkflow` `vi.fn`. */
|
|
50
|
+
triggerWorkflow: Mock<(workflowName: string, args?: unknown, _options?: TriggerWorkflowOptions) => Promise<string>>;
|
|
51
|
+
/** The `resumeWorkflow` `vi.fn`. */
|
|
52
|
+
resumeWorkflow: Mock<(executionId: string) => Promise<string>>;
|
|
53
|
+
/** The `wait` `vi.fn`. */
|
|
54
|
+
wait: Mock<(_key: string, _payload?: unknown) => unknown>;
|
|
55
|
+
/** The `resolve` `vi.fn`. */
|
|
56
|
+
resolve: Mock<(_executionId: string, _key: string, _callback: (payload: unknown) => unknown) => Promise<void>>;
|
|
57
|
+
/**
|
|
58
|
+
* Get a stable, typed mock for a workflow job's `trigger` method.
|
|
59
|
+
* The real trigger behavior is used until an implementation or result is configured.
|
|
60
|
+
* @param definition - Workflow job definition to mock
|
|
61
|
+
* @returns Typed `trigger` mock for the definition
|
|
62
|
+
*/
|
|
63
|
+
job<Name extends string, Input, Output>(definition: WorkflowJob<Name, Input, Output>): Mock<WorkflowJob<Name, Input, Output>["trigger"]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get a stable, typed mock for a workflow definition's `trigger` method.
|
|
66
|
+
* The real trigger behavior is used until an implementation or result is configured.
|
|
67
|
+
* @param definition - Workflow definition to mock
|
|
68
|
+
* @returns Typed `trigger` mock for the definition
|
|
69
|
+
*/
|
|
70
|
+
workflow<Definition extends Workflow>(definition: Definition): Mock<Definition["trigger"]>;
|
|
71
|
+
/**
|
|
72
|
+
* Get stable, typed mocks for a wait point's `wait` and `resolve` methods.
|
|
73
|
+
* @param definition - Wait point definition to mock
|
|
74
|
+
* @returns Typed wait point mock control object
|
|
75
|
+
*/
|
|
76
|
+
waitPoint<Payload, Result>(definition: WaitPointInstance<Payload, Result>): {
|
|
77
|
+
wait: Mock<WaitPointInstance<Payload, Result>["wait"]>;
|
|
78
|
+
resolve: Mock<WaitPointInstance<Payload, Result>["resolve"]>;
|
|
79
|
+
setResolvePayload(payload: WaitPayload<Payload>): void;
|
|
80
|
+
};
|
|
47
81
|
/**
|
|
48
82
|
* Set a fallback job handler. Called when the enqueue queue is empty.
|
|
49
83
|
* @param handler - Function returning a result for a job name, args, and options
|
|
@@ -110,7 +144,10 @@ declare function mockWorkflow(): {
|
|
|
110
144
|
readonly resolveCalls: {
|
|
111
145
|
executionId: string;
|
|
112
146
|
key: string;
|
|
113
|
-
}[];
|
|
147
|
+
}[];
|
|
148
|
+
/** Clear recorded calls while preserving configured responses. */
|
|
149
|
+
clear(): void;
|
|
150
|
+
/** Reset all workflow responses and recorded calls (keeps the mock installed). */
|
|
114
151
|
reset(): void;
|
|
115
152
|
} & Disposable;
|
|
116
153
|
//#endregion
|
package/dist/vitest/setup.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as RUNTIME_FLAG_KEY } from "../globals-
|
|
2
|
-
import { t as mockSecretmanager } from "../secretmanager-
|
|
1
|
+
import { t as RUNTIME_FLAG_KEY } from "../globals-CvizbGLY.mjs";
|
|
2
|
+
import { t as mockSecretmanager } from "../secretmanager-IY4UvinW.mjs";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { afterEach, beforeAll, beforeEach } from "vitest";
|
|
5
5
|
|