@tailor-platform/sdk 2.35.0 → 2.37.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 +108 -0
- package/dist/{application-Bj2MtL-d.mjs → application-83WVdH85.mjs} +1 -1
- package/dist/{application-DIsQSnj3.mjs → application-Cida-j1g.mjs} +36 -36
- package/dist/application-Cida-j1g.mjs.map +1 -0
- package/dist/cli/commands/deploy/deploy.d.mts +6 -1
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +1 -0
- package/dist/cli/commands/executor/jobs.d.mts +3 -0
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +3 -0
- package/dist/cli/commands/tailordb/migrate/config.d.mts +4 -0
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +10 -0
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +28 -2
- package/dist/cli/commands/tailordb/migrate/hints.d.mts +1 -0
- package/dist/cli/commands/tailordb/migrate/remote-state.d.mts +3 -0
- package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +3 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +4 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +44 -6
- package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +2 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +2 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +8 -0
- package/dist/cli/commands/tailordb/migrate/types.d.mts +2 -0
- package/dist/cli/commands/workspace/create.d.mts +5 -3
- package/dist/cli/lib.d.mts +2 -2
- package/dist/cli/lib.mjs +1 -1
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +52 -51
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/client.d.mts +26 -0
- package/dist/cli/shared/function-execution.d.mts +2 -0
- package/dist/cli/shared/prompt.d.mts +9 -4
- package/dist/completion/zsh-worker.zsh +21 -13
- package/dist/configure/config/index.d.mts +2 -0
- package/dist/configure/config/types.d.mts +2 -0
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/executor/trigger/webhook.d.mts +1 -0
- package/dist/configure/services/tailordb/schema.d.mts +7 -2
- package/dist/configure/services/tailordb/types.d.mts +3 -0
- package/dist/crashreport-C2AcQNTe.mjs +1 -0
- package/dist/{crashreport-DGU6lwiX.mjs → crashreport-D_wf4GZh.mjs} +4 -4
- package/dist/{crashreport-DGU6lwiX.mjs.map → crashreport-D_wf4GZh.mjs.map} +1 -1
- package/dist/date-representation-Cr7W7Pn2.mjs.map +1 -1
- package/dist/{errors-BXmGBX-7.mjs → errors-Dmdnq0zi.mjs} +2 -2
- package/dist/errors-Dmdnq0zi.mjs.map +1 -0
- package/dist/{kysely-type-B0ri1-Xs.mjs → kysely-type-DVL90_oX.mjs} +6 -6
- package/dist/kysely-type-DVL90_oX.mjs.map +1 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -3
- package/dist/plugin/get-generated-table.d.mts +4 -0
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +55 -3
- package/dist/plugin/with-context.d.mts +16 -0
- package/dist/register-ts-hook-Ht4zCseV.mjs +1115 -0
- package/dist/register-ts-hook-Ht4zCseV.mjs.map +1 -0
- package/dist/schema-BU1aIQ63.mjs.map +1 -1
- package/dist/{secret-file-BxZ-J_Nz.mjs → secret-file-DiuEcLFP.mjs} +2 -2
- package/dist/{secret-file-BxZ-J_Nz.mjs.map → secret-file-DiuEcLFP.mjs.map} +1 -1
- package/dist/service-CZ0EdD2-.mjs +10 -0
- package/dist/service-CZ0EdD2-.mjs.map +1 -0
- package/dist/service-DDrbdyd-.mjs +2 -0
- package/dist/{service-CaGmqg0r.mjs.map → service-DDrbdyd-.mjs.map} +1 -1
- package/dist/service-WhSyhaho.mjs +1 -0
- package/dist/service_pb-BMHhVot2.mjs +1 -0
- package/dist/service_pb-BxMSK0gg.mjs +2 -0
- package/dist/service_pb-BxMSK0gg.mjs.map +1 -0
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +3 -3
- package/dist/tailor-proto/src/tailor/v1/function_resource_pb.d.mts +92 -0
- package/dist/tailor-proto/src/tailor/v1/notification_pb.d.mts +176 -0
- package/dist/tailor-proto/src/tailor/v1/notification_resource_pb.d.mts +172 -0
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +78 -0
- package/dist/types/app-config.generated.d.mts +1 -1
- package/dist/types/auth-connection.generated.d.mts +2 -2
- package/dist/types/auth.generated.d.mts +13 -13
- package/dist/types/executor.generated.d.mts +25 -25
- package/dist/types/field.generated.d.mts +2 -2
- package/dist/types/http-adapter.generated.d.mts +4 -4
- package/dist/types/idp.generated.d.mts +272 -272
- package/dist/types/resolver.generated.d.mts +10 -10
- package/dist/types/tailordb.generated.d.mts +84 -80
- package/dist/types/workflow.generated.d.mts +2 -2
- package/dist/vitest/date-representation.d.mts +2 -0
- package/dist/vitest/environment.d.mts +1 -0
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs +1 -1
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/migration-steps.d.mts +13 -2
- package/dist/vitest/mock-kysely.d.mts +12 -2
- package/dist/vitest/mocks/aigateway.d.mts +7 -1
- package/dist/vitest/mocks/authconnection.d.mts +7 -1
- package/dist/vitest/mocks/file.d.mts +7 -1
- package/dist/vitest/mocks/iconv.d.mts +7 -1
- package/dist/vitest/mocks/idp.d.mts +7 -1
- package/dist/vitest/mocks/logger.d.mts +7 -1
- package/dist/vitest/mocks/secretmanager.d.mts +7 -1
- package/dist/vitest/mocks/tailordb-pglite.d.mts +12 -2
- package/dist/vitest/mocks/tailordb.d.mts +22 -4
- package/dist/vitest/mocks/workflow.d.mts +2 -1
- package/dist/vitest/pglite-kysely.d.mts +23 -2
- package/dist/vitest/pglite-temporal.d.mts +5 -1
- package/dist/vitest/workflow-local.d.mts +7 -0
- package/dist/{workspace_resource_pb-C4CkoYww.mjs → workspace_resource_pb-7smKERdZ.mjs} +2 -2
- package/dist/workspace_resource_pb-7smKERdZ.mjs.map +1 -0
- package/docs/cli/application.md +52 -22
- package/docs/cli/executor.md +2 -0
- package/docs/cli/function.md +3 -1
- package/docs/cli/tailordb.md +31 -23
- package/docs/cli/user.md +1 -1
- package/docs/cli/workflow.md +2 -0
- package/docs/cli/workspace.md +20 -18
- package/docs/cli-reference.md +10 -7
- package/docs/configuration.md +2 -2
- package/docs/data-clone.md +1 -1
- package/docs/github-actions.md +104 -15
- package/docs/plugin/custom.md +4 -4
- package/docs/runtime.md +1 -1
- package/docs/services/auth.md +2 -0
- package/docs/services/executor.md +12 -5
- package/docs/services/idp.md +2 -0
- package/docs/services/tailordb/index.md +12 -3
- package/docs/services/tailordb/migration.md +90 -38
- package/docs/services/workflow.md +1 -1
- package/docs/testing.md +9 -9
- package/package.json +22 -22
- package/dist/application-DIsQSnj3.mjs.map +0 -1
- package/dist/crashreport-WsYAWARW.mjs +0 -1
- package/dist/errors-BXmGBX-7.mjs.map +0 -1
- package/dist/kysely-type-B0ri1-Xs.mjs.map +0 -1
- package/dist/register-ts-hook-CQ7shKO5.mjs +0 -1055
- package/dist/register-ts-hook-CQ7shKO5.mjs.map +0 -1
- package/dist/service-CaGmqg0r.mjs +0 -2
- package/dist/service-DEq_hdht.mjs +0 -1
- package/dist/service-eeXdVrDK.mjs +0 -8
- package/dist/service-eeXdVrDK.mjs.map +0 -1
- package/dist/service_pb-6EkMfdOb.mjs +0 -2
- package/dist/service_pb-6EkMfdOb.mjs.map +0 -1
- package/dist/service_pb-CsJKokDl.mjs +0 -1
- package/dist/workspace_resource_pb-C4CkoYww.mjs.map +0 -1
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
* Run a multi-step migration script's `steps` in tests the way `tailor deploy`
|
|
3
3
|
* does: in dependency order, each step in its own transaction.
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* A step as declared in a migration script's `steps`.
|
|
7
|
+
*
|
|
8
|
+
* **Beta:** This API may change in future releases.
|
|
9
|
+
*/
|
|
6
10
|
export interface RunnableMigrationStep<Trx, Context> {
|
|
7
11
|
/** Steps that must complete before this one starts. */
|
|
8
12
|
readonly dependsOn?: readonly string[];
|
|
9
13
|
/** The step body; it receives its own transaction. */
|
|
10
14
|
run: (trx: Trx, context: Context) => Promise<unknown>;
|
|
11
15
|
}
|
|
16
|
+
/** **Beta:** This API may change in future releases. */
|
|
12
17
|
export interface RunMigrationStepsOptions<Trx, Context extends {
|
|
13
18
|
env: unknown;
|
|
14
19
|
}> {
|
|
@@ -21,7 +26,11 @@ export interface RunMigrationStepsOptions<Trx, Context extends {
|
|
|
21
26
|
/** Values passed as `env` to every step; defaults to `{}`. */
|
|
22
27
|
env?: Context["env"];
|
|
23
28
|
}
|
|
24
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Thrown by {@link runMigrationSteps} when a step fails.
|
|
31
|
+
*
|
|
32
|
+
* **Beta:** This API may change in future releases.
|
|
33
|
+
*/
|
|
25
34
|
export declare class MigrationStepError extends Error {
|
|
26
35
|
/** The step that failed. */
|
|
27
36
|
readonly step: string;
|
|
@@ -33,6 +42,8 @@ export declare class MigrationStepError extends Error {
|
|
|
33
42
|
* Run a migration script's `steps` in the order `tailor deploy` runs them,
|
|
34
43
|
* committing each step separately, so a test can observe what a failure in a
|
|
35
44
|
* later step leaves behind.
|
|
45
|
+
*
|
|
46
|
+
* **Beta:** This API may change in future releases.
|
|
36
47
|
* @param steps - The script's exported `steps`
|
|
37
48
|
* @param options - Transaction runner and env
|
|
38
49
|
* @returns Names of the steps that ran, in execution order
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Kysely, OperationNode, OperationNodeKind, Transaction } from "kysely";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A single statement executed against the mock, captured in order.
|
|
4
|
+
*
|
|
5
|
+
* **Beta:** This API may change in future releases.
|
|
6
|
+
*/
|
|
3
7
|
export interface ExecutedQuery {
|
|
4
8
|
/** The Kysely operation node kind, e.g. `"SelectQueryNode"`. */
|
|
5
9
|
kind: OperationNodeKind;
|
|
@@ -22,7 +26,11 @@ type MockResult = MockRow[] | {
|
|
|
22
26
|
numAffectedRows?: number | bigint;
|
|
23
27
|
};
|
|
24
28
|
type QueryResolver = (query: ExecutedQuery) => MockResult | undefined;
|
|
25
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Controls and assertions for a {@link createKyselyMock} instance.
|
|
31
|
+
*
|
|
32
|
+
* **Beta:** This API may change in future releases.
|
|
33
|
+
*/
|
|
26
34
|
export interface KyselyMock<DB> {
|
|
27
35
|
/** The mock Kysely instance to run queries against. */
|
|
28
36
|
db: Kysely<DB>;
|
|
@@ -53,6 +61,8 @@ export interface KyselyMock<DB> {
|
|
|
53
61
|
* Create a mock Kysely instance for unit-testing code that runs Kysely queries.
|
|
54
62
|
* Pass the namespace schema as the type argument, e.g.
|
|
55
63
|
* `createKyselyMock<Namespace["main-db"]>()`.
|
|
64
|
+
*
|
|
65
|
+
* **Beta:** This API may change in future releases.
|
|
56
66
|
* @returns A {@link KyselyMock} with the mock `db`, recorded queries, and result staging.
|
|
57
67
|
*/
|
|
58
68
|
export declare function createKyselyMock<DB = Record<string, never>>(): KyselyMock<DB>;
|
|
@@ -2,13 +2,19 @@ import { AIGatewayName } from "@tailor-platform/sdk";
|
|
|
2
2
|
interface AigatewayCall {
|
|
3
3
|
name: AIGatewayName;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Initial fixtures for an AI Gateway mock.
|
|
7
|
+
*
|
|
8
|
+
* **Beta:** This API may change in future releases.
|
|
9
|
+
*/
|
|
6
10
|
export interface MockAigatewayOptions {
|
|
7
11
|
/** AI Gateway URLs available when the mock is acquired. */
|
|
8
12
|
urls?: Partial<Record<AIGatewayName, string>>;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Acquire a disposable mock for `tailor.aigateway`. Restored on dispose.
|
|
16
|
+
*
|
|
17
|
+
* **Beta:** This API may change in future releases.
|
|
12
18
|
* @param options - Initial AI Gateway URL fixtures
|
|
13
19
|
* @returns Disposable AI Gateway mock control object
|
|
14
20
|
* @example
|
|
@@ -2,7 +2,11 @@ import { AuthConnectionTokenResult, ConnectionName } from "@tailor-platform/sdk"
|
|
|
2
2
|
interface AuthConnectionCall {
|
|
3
3
|
connectionName: ConnectionName;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Initial fixtures and fallback behavior for an AuthConnection mock.
|
|
7
|
+
*
|
|
8
|
+
* **Beta:** This API may change in future releases.
|
|
9
|
+
*/
|
|
6
10
|
export interface MockAuthconnectionOptions {
|
|
7
11
|
/** Tokens available when the mock is acquired. */
|
|
8
12
|
tokens?: Partial<Record<ConnectionName, AuthConnectionTokenResult>>;
|
|
@@ -11,6 +15,8 @@ export interface MockAuthconnectionOptions {
|
|
|
11
15
|
}
|
|
12
16
|
/**
|
|
13
17
|
* Acquire a disposable mock for `tailor.authconnection`. Restored on dispose.
|
|
18
|
+
*
|
|
19
|
+
* **Beta:** This API may change in future releases.
|
|
14
20
|
* @param options - Initial token fixtures and fallback behavior
|
|
15
21
|
* @returns Disposable AuthConnection mock control object
|
|
16
22
|
* @example
|
|
@@ -8,13 +8,19 @@ interface FileCall {
|
|
|
8
8
|
fieldName: string;
|
|
9
9
|
recordId: string;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Controls fallback behavior for File calls without a configured result.
|
|
13
|
+
*
|
|
14
|
+
* **Beta:** This API may change in future releases.
|
|
15
|
+
*/
|
|
12
16
|
export interface MockFileOptions {
|
|
13
17
|
/** Return a type-compatible fixture or throw when no behavior is configured. */
|
|
14
18
|
onUnhandled?: "fallback" | "error";
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
21
|
* Acquire a disposable mock for `tailordb.file`. Restored on dispose.
|
|
22
|
+
*
|
|
23
|
+
* **Beta:** This API may change in future releases.
|
|
18
24
|
* @param options - Controls behavior for calls without a configured result
|
|
19
25
|
* @returns Disposable File mock control object
|
|
20
26
|
* @example
|
|
@@ -10,13 +10,19 @@ type ConvertMockProcedure = (input: string | Uint8Array | ArrayBuffer, fromEncod
|
|
|
10
10
|
type ConvertBufferMockProcedure = (input: Uint8Array | ArrayBuffer, fromEncoding: string, toEncoding: string) => ConversionResult;
|
|
11
11
|
type EncodeMockProcedure = (input: string, encoding: string) => ConversionResult;
|
|
12
12
|
type TypedOperationMock<RuntimeProcedure, MockProcedure extends (...args: never[]) => unknown> = RuntimeProcedure & MockInstance<MockProcedure>;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Controls how unconfigured Iconv operations are handled.
|
|
15
|
+
*
|
|
16
|
+
* **Beta:** This API may change in future releases.
|
|
17
|
+
*/
|
|
14
18
|
export interface MockIconvOptions {
|
|
15
19
|
/** Return an empty type-compatible value or throw when no behavior is configured. */
|
|
16
20
|
onUnhandled?: "fallback" | "error";
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Acquire a disposable mock for `tailor.iconv`. Restored on dispose.
|
|
24
|
+
*
|
|
25
|
+
* **Beta:** This API may change in future releases.
|
|
20
26
|
* @param options - Fallback behavior for unconfigured operations
|
|
21
27
|
* @returns Disposable Iconv mock control object
|
|
22
28
|
* @example
|
|
@@ -7,7 +7,11 @@ interface IdpCall {
|
|
|
7
7
|
args: unknown[];
|
|
8
8
|
namespace: string;
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Controls fallback behavior for IdP calls without a configured result.
|
|
12
|
+
*
|
|
13
|
+
* **Beta:** This API may change in future releases.
|
|
14
|
+
*/
|
|
11
15
|
export interface MockIdpOptions {
|
|
12
16
|
/** Return a type-compatible fixture or throw when no behavior is configured. */
|
|
13
17
|
onUnhandled?: "fallback" | "error";
|
|
@@ -15,6 +19,8 @@ export interface MockIdpOptions {
|
|
|
15
19
|
type IdpNamespaceMocks = { [Method in IdpMethod]: Mock<IdpClientInstance[Method]>; };
|
|
16
20
|
/**
|
|
17
21
|
* Acquire a disposable mock for `tailor.idp`. Restored on dispose.
|
|
22
|
+
*
|
|
23
|
+
* **Beta:** This API may change in future releases.
|
|
18
24
|
* @param options - Controls behavior for calls without a configured result
|
|
19
25
|
* @returns Disposable IDP mock control object
|
|
20
26
|
* @example
|
|
@@ -6,12 +6,18 @@ interface LogCall {
|
|
|
6
6
|
message: string;
|
|
7
7
|
attributes?: LogAttributes;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Initial fixtures for a logger mock.
|
|
11
|
+
*
|
|
12
|
+
* **Beta:** This API may change in future releases.
|
|
13
|
+
*/
|
|
10
14
|
export interface MockLoggerOptions {}
|
|
11
15
|
/**
|
|
12
16
|
* Acquire a disposable mock for `tailor.logger`. Each method is a `vi.fn`, so
|
|
13
17
|
* calls can be asserted directly; `calls` returns the `debug`/`info`/`warn`/
|
|
14
18
|
* `error` entries in the order they were emitted. Restored on dispose.
|
|
19
|
+
*
|
|
20
|
+
* **Beta:** This API may change in future releases.
|
|
15
21
|
* @param _options - Reserved for future initial fixtures
|
|
16
22
|
* @returns Disposable logger mock control object
|
|
17
23
|
* @example
|
|
@@ -4,7 +4,11 @@ interface SecretCall {
|
|
|
4
4
|
name?: string;
|
|
5
5
|
names?: readonly string[];
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Initial fixtures for a Secret Manager mock.
|
|
9
|
+
*
|
|
10
|
+
* **Beta:** This API may change in future releases.
|
|
11
|
+
*/
|
|
8
12
|
export interface MockSecretmanagerOptions {
|
|
9
13
|
/** Secrets to merge over fixtures inherited from the currently installed mock. */
|
|
10
14
|
secrets?: Record<string, Record<string, string>>;
|
|
@@ -14,6 +18,8 @@ export interface MockSecretmanagerOptions {
|
|
|
14
18
|
* inherited (cloned) from the currently-installed mock on acquisition and
|
|
15
19
|
* restored on dispose, so secrets seeded outside the test survive across
|
|
16
20
|
* `using` scopes while per-test `setSecrets()` overrides stay isolated.
|
|
21
|
+
*
|
|
22
|
+
* **Beta:** This API may change in future releases.
|
|
17
23
|
* @param options - Initial Secret Manager fixtures
|
|
18
24
|
* @returns Disposable SecretManager mock control object
|
|
19
25
|
* @example
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { PGliteClient } from "../pglite-kysely.mjs";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* A query executed through the PGlite-backed TailorDB client.
|
|
4
|
+
*
|
|
5
|
+
* **Beta:** This API may change in future releases.
|
|
6
|
+
*/
|
|
3
7
|
export interface ExecutedPGliteQuery {
|
|
4
8
|
/** Namespace of the `getDB` call that issued the query. */
|
|
5
9
|
namespace: string;
|
|
@@ -8,7 +12,11 @@ export interface ExecutedPGliteQuery {
|
|
|
8
12
|
/** Parameter values bound to the placeholders. */
|
|
9
13
|
params: unknown[];
|
|
10
14
|
}
|
|
11
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Options for {@link mockTailordbWithPGlite}.
|
|
17
|
+
*
|
|
18
|
+
* **Beta:** This API may change in future releases.
|
|
19
|
+
*/
|
|
12
20
|
export interface MockTailordbPGliteOptions {
|
|
13
21
|
/**
|
|
14
22
|
* PGlite instance per `getDB` namespace. A `getDB` call for a namespace
|
|
@@ -28,6 +36,8 @@ interface CreatedClient {
|
|
|
28
36
|
* PGlite instances are borrowed, never closed — close them yourself (e.g. in
|
|
29
37
|
* `afterAll`).
|
|
30
38
|
*
|
|
39
|
+
* **Beta:** This API may change in future releases.
|
|
40
|
+
*
|
|
31
41
|
* Create the tables a test needs up front: run the script `kyselyTypePlugin`
|
|
32
42
|
* writes when `pgliteSchemaPath` is set, or your own `CREATE TABLE`
|
|
33
43
|
* statements matching the generated Kysely types. PGlite runs full PostgreSQL
|
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
type QueryResolver = (query: string, params: unknown[]) => unknown[] | undefined;
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Controls how unmatched TailorDB queries are handled.
|
|
4
|
+
*
|
|
5
|
+
* **Beta:** This API may change in future releases.
|
|
6
|
+
*/
|
|
3
7
|
export interface MockTailordbOptions {
|
|
4
8
|
/** Return an empty result or throw when no configured query behavior matches. */
|
|
5
9
|
onUnhandled?: "fallback" | "error";
|
|
6
10
|
}
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Matches a TailorDB query by SQL text and optionally by parameters.
|
|
13
|
+
*
|
|
14
|
+
* **Beta:** This API may change in future releases.
|
|
15
|
+
*/
|
|
8
16
|
export interface QueryMatch {
|
|
9
17
|
/** Exact SQL text or regular expression to match. */
|
|
10
18
|
sql: string | RegExp;
|
|
11
19
|
/** Exact parameters or a predicate for parameter matching. */
|
|
12
20
|
params?: readonly unknown[] | ((params: unknown[]) => boolean);
|
|
13
21
|
}
|
|
14
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Selects TailorDB queries that receive a configured response.
|
|
24
|
+
*
|
|
25
|
+
* **Beta:** This API may change in future releases.
|
|
26
|
+
*/
|
|
15
27
|
export type QueryMatcher = string | RegExp | QueryMatch | ((query: string, params: unknown[]) => boolean);
|
|
16
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Configures persistent and one-time responses for matched queries.
|
|
30
|
+
*
|
|
31
|
+
* **Beta:** This API may change in future releases.
|
|
32
|
+
*/
|
|
17
33
|
export interface QueryBehavior<Row> {
|
|
18
34
|
/** Return these rows for every matching query after one-time responses are consumed. */
|
|
19
35
|
returnsRows(rows: Row[]): QueryBehavior<Row>;
|
|
@@ -43,6 +59,8 @@ declare class MockQueryResult {
|
|
|
43
59
|
* `tailordb.Client` whose `queryObject` is a shared `vi.fn()` (so query
|
|
44
60
|
* responses can be staged before the client is constructed). Restored on
|
|
45
61
|
* dispose.
|
|
62
|
+
*
|
|
63
|
+
* **Beta:** This API may change in future releases.
|
|
46
64
|
* @param options - Query fallback behavior
|
|
47
65
|
* @returns Disposable TailorDB mock control object
|
|
48
66
|
* @example
|
|
@@ -22,7 +22,8 @@ type WaitPayload<Payload> = [Payload] extends [undefined] ? undefined : Payload;
|
|
|
22
22
|
/**
|
|
23
23
|
* Acquire a disposable mock for workflow operations (`tailor.workflow`).
|
|
24
24
|
* Restored on dispose.
|
|
25
|
-
|
|
25
|
+
*
|
|
26
|
+
* **Beta:** This API may change in future releases.
|
|
26
27
|
* @returns Disposable workflow mock control object
|
|
27
28
|
* @example
|
|
28
29
|
* ```typescript
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { PGliteField } from "./pglite-temporal.mjs";
|
|
2
2
|
import { ColumnType, Kysely } from "kysely";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Result of a {@link PGliteClient.query} call.
|
|
5
|
+
*
|
|
6
|
+
* **Beta:** This API may change in future releases.
|
|
7
|
+
*/
|
|
4
8
|
export interface PGliteQueryResult {
|
|
5
9
|
/** Rows returned by the statement. */
|
|
6
10
|
rows: unknown[];
|
|
@@ -17,6 +21,8 @@ export interface PGliteQueryResult {
|
|
|
17
21
|
* The subset of a `@electric-sql/pglite` `PGlite` instance used by
|
|
18
22
|
* {@link createKyselyPGlite}. Any client with a compatible `query`/`close`
|
|
19
23
|
* pair works.
|
|
24
|
+
*
|
|
25
|
+
* **Beta:** This API may change in future releases.
|
|
20
26
|
*/
|
|
21
27
|
export interface PGliteClient {
|
|
22
28
|
/** Run a single SQL statement with positional (`$1`, `$2`, ...) parameters. */
|
|
@@ -30,6 +36,8 @@ type UnmigratedColumn<C> = C extends ColumnType<infer S, infer I, infer U> ? Col
|
|
|
30
36
|
* `DB` as its rows stand before the migration script has run: every column
|
|
31
37
|
* accepts on insert and update whatever it can still hold on read.
|
|
32
38
|
*
|
|
39
|
+
* **Beta:** This API may change in future releases.
|
|
40
|
+
*
|
|
33
41
|
* The generated `db.ts` types a column the migration makes required as
|
|
34
42
|
* `ColumnType<T | null, T, T>`, and an enum whose values it narrows as
|
|
35
43
|
* `ColumnType<Before, After, After>`, so `migrate.ts` cannot write a null
|
|
@@ -45,7 +53,11 @@ type UnmigratedColumn<C> = C extends ColumnType<infer S, infer I, infer U> ? Col
|
|
|
45
53
|
* ```
|
|
46
54
|
*/
|
|
47
55
|
export type Unmigrated<DB> = { [T in keyof DB]: { [C in keyof DB[T]]: UnmigratedColumn<DB[T][C]>; }; };
|
|
48
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Options for {@link createKyselyPGlite}.
|
|
58
|
+
*
|
|
59
|
+
* **Beta:** This API may change in future releases.
|
|
60
|
+
*/
|
|
49
61
|
export interface CreateKyselyPGliteOptions {
|
|
50
62
|
/**
|
|
51
63
|
* Read date/datetime/time columns back as `Temporal.PlainDate`/`Temporal.Instant`/
|
|
@@ -61,9 +73,16 @@ export interface CreateKyselyPGliteOptions {
|
|
|
61
73
|
* {@link Unmigrated} so the test can stage the rows the script has not yet
|
|
62
74
|
* backfilled: `createKyselyPGlite<Unmigrated<Database>>(new PGlite())`.
|
|
63
75
|
*
|
|
76
|
+
* **Beta:** This API may change in future releases.
|
|
77
|
+
*
|
|
64
78
|
* PGlite runs full PostgreSQL while TailorDB supports a subset of it, so a
|
|
65
79
|
* statement passing here can still be rejected by the platform; keep a
|
|
66
80
|
* statement-level test (see `createKyselyMock`) alongside.
|
|
81
|
+
*
|
|
82
|
+
* While a transaction is open, other queries on the returned Kysely instance
|
|
83
|
+
* wait for it to finish. Inside the transaction, run every query on the
|
|
84
|
+
* transaction (`trx`): a query on the returned instance there waits on itself
|
|
85
|
+
* and never finishes.
|
|
67
86
|
* @param client - A `PGlite` instance from `@electric-sql/pglite`
|
|
68
87
|
* @param options - Adapter options
|
|
69
88
|
* @returns A Kysely instance that executes queries on the client and closes it on `destroy()`
|
|
@@ -88,6 +107,8 @@ export declare function createKyselyPGlite<DB = Record<string, never>>(client: P
|
|
|
88
107
|
* throws, so the script under test still runs against checked relations, and calls that are nested
|
|
89
108
|
* or overlap keep relations unchecked until all of them are done. NOT NULL, UNIQUE, and CHECK
|
|
90
109
|
* constraints stay enforced.
|
|
110
|
+
*
|
|
111
|
+
* **Beta:** This API may change in future releases.
|
|
91
112
|
* @param client - The PGlite instance the rows are written to
|
|
92
113
|
* @param prepare - Writes the rows, for example with the Kysely instance of the same client
|
|
93
114
|
* @returns Whatever `prepare` returns
|
|
@@ -6,6 +6,7 @@ type AnyWorkflowJob = WorkflowJob<string, any, any>;
|
|
|
6
6
|
type AnyWorkflow = Workflow<AnyWorkflowJob>;
|
|
7
7
|
type WorkflowInput<W extends AnyWorkflow> = W["mainJob"] extends WorkflowJob<string, infer I, any> ? I : never;
|
|
8
8
|
type WorkflowOutput<W extends AnyWorkflow> = W["mainJob"] extends WorkflowJob<string, any, infer O> ? Awaited<O> : never;
|
|
9
|
+
/** **Beta:** This API may change in future releases. */
|
|
9
10
|
export interface RunWorkflowLocallyOptions {
|
|
10
11
|
/** Env passed to workflow job bodies during this local run. */
|
|
11
12
|
env?: TailorEnv;
|
|
@@ -13,6 +14,8 @@ export interface RunWorkflowLocallyOptions {
|
|
|
13
14
|
/**
|
|
14
15
|
* Run a workflow's main job and dependent job starts locally with real job bodies.
|
|
15
16
|
*
|
|
17
|
+
* **Beta:** This API may change in future releases.
|
|
18
|
+
*
|
|
16
19
|
* Use this for local full-chain workflow tests. Regular `.start()` calls
|
|
17
20
|
* delegate to the platform workflow runtime and should be mocked with
|
|
18
21
|
* `mockWorkflow()` when you are not intentionally running the local chain.
|
|
@@ -22,6 +25,8 @@ export interface RunWorkflowLocallyOptions {
|
|
|
22
25
|
export declare function runWorkflowLocally<W extends Workflow<WorkflowJob<string, undefined, any>>>(workflow: W): Promise<WorkflowOutput<W>>;
|
|
23
26
|
/**
|
|
24
27
|
* Run a no-input workflow locally with optional runner settings.
|
|
28
|
+
*
|
|
29
|
+
* **Beta:** This API may change in future releases.
|
|
25
30
|
* @param workflow - Workflow definition to run
|
|
26
31
|
* @param args - Must be `undefined` for no-input workflows
|
|
27
32
|
* @param options - Local runner options
|
|
@@ -30,6 +35,8 @@ export declare function runWorkflowLocally<W extends Workflow<WorkflowJob<string
|
|
|
30
35
|
export declare function runWorkflowLocally<W extends Workflow<WorkflowJob<string, undefined, any>>>(workflow: W, args: undefined, options?: RunWorkflowLocallyOptions): Promise<WorkflowOutput<W>>;
|
|
31
36
|
/**
|
|
32
37
|
* Run a workflow locally with real job bodies.
|
|
38
|
+
*
|
|
39
|
+
* **Beta:** This API may change in future releases.
|
|
33
40
|
* @param workflow - Workflow definition to run
|
|
34
41
|
* @param args - Arguments passed to the workflow's main job
|
|
35
42
|
* @param options - Local runner options
|