@tailor-platform/sdk 1.57.0 → 1.59.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 +75 -0
- package/dist/{application-CdkoGX27.mjs → application-FnWOxBk7.mjs} +48 -28
- package/dist/application-FnWOxBk7.mjs.map +1 -0
- package/dist/application-VOdgMtOD.mjs +4 -0
- package/dist/{authconnection-TsdLYaLs.d.mts → authconnection-BIYzEh2p.d.mts} +2 -2
- package/dist/authconnection-D8SJGMpj.mjs.map +1 -1
- package/dist/cli/erd-viewer-assets/app.js +4 -4
- package/dist/cli/index.mjs +172 -20
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +581 -2
- package/dist/cli/lib.mjs +4 -3
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/client-B-jRdlC_.mjs +4 -0
- package/dist/{client-DLPEPJ_s.mjs → client-W5P4NYYX.mjs} +154 -12
- package/dist/client-W5P4NYYX.mjs.map +1 -0
- package/dist/configure/index.d.mts +2 -2
- package/dist/configure/index.mjs +8 -8
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{crashreport-Bm2mN5tg.mjs → crashreport-D3DvAzdg.mjs} +3 -3
- package/dist/crashreport-D3DvAzdg.mjs.map +1 -0
- package/dist/{crashreport-C5oHvHUC.mjs → crashreport-lnVTnbB5.mjs} +1 -1
- package/dist/file-B58Dm-2P.mjs.map +1 -1
- package/dist/{file-VTJbbOL3.d.mts → file-BzK8z3X-.d.mts} +2 -2
- package/dist/globals-ByrCoDip.mjs +109 -0
- package/dist/globals-ByrCoDip.mjs.map +1 -0
- package/dist/iconv-DreIffeM.mjs.map +1 -1
- package/dist/{iconv-Chu6Hit2.d.mts → iconv-kwrmd1U_.d.mts} +2 -2
- package/dist/{idp-Di9N4FSJ.d.mts → idp-BlBPtXJ-.d.mts} +2 -2
- package/dist/idp-Ch95ag8h.mjs.map +1 -1
- package/dist/{index-B61gFI9a.d.mts → index-Cr6ufjZ5.d.mts} +12 -9
- package/dist/{index-DTSQthwF.d.mts → index-DRhMpdnA.d.mts} +7 -7
- package/dist/{job-CEAJLiGp.mjs → job-BpsFXPbi.mjs} +8 -17
- package/dist/job-BpsFXPbi.mjs.map +1 -0
- package/dist/mock-Dpu__UeJ.mjs +805 -0
- package/dist/mock-Dpu__UeJ.mjs.map +1 -0
- package/dist/registry-D0uB0OrK.mjs +178 -0
- package/dist/registry-D0uB0OrK.mjs.map +1 -0
- package/dist/{repl-editor-ihh8koiR.mjs → repl-editor-Y9QJDL0K.mjs} +3 -9
- package/dist/{repl-editor-ihh8koiR.mjs.map → repl-editor-Y9QJDL0K.mjs.map} +1 -1
- package/dist/runtime/authconnection.d.mts +1 -1
- package/dist/runtime/file.d.mts +1 -1
- package/dist/runtime/globals.d.mts +5 -5
- package/dist/runtime/iconv.d.mts +1 -1
- package/dist/runtime/idp.d.mts +1 -1
- package/dist/runtime/index.d.mts +7 -7
- package/dist/runtime/secretmanager.d.mts +1 -1
- package/dist/runtime/workflow.d.mts +1 -1
- package/dist/{runtime-1YuaoNr8.mjs → runtime-CrUa8Z2k.mjs} +383 -402
- package/dist/runtime-CrUa8Z2k.mjs.map +1 -0
- package/dist/secretmanager-B9h-U_8U.mjs.map +1 -1
- package/dist/{secretmanager-BhpDmxwT.d.mts → secretmanager-CKLB3wAQ.d.mts} +2 -2
- package/dist/utils/test/index.d.mts +6 -6
- package/dist/utils/test/index.mjs +7 -7
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +3 -4
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.d.mts +167 -120
- package/dist/vitest/index.mjs +6 -6
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/setup.d.mts +1 -1
- package/dist/vitest/setup.mjs +4 -3
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/workflow--aPbA8Uq.mjs.map +1 -1
- package/dist/{workflow-dYYH7QFa.d.mts → workflow-CMamswkK.d.mts} +2 -2
- package/dist/{workflow.generated-Kz-nQrTf.d.mts → workflow.generated-CV77NlFp.d.mts} +3 -2
- package/docs/cli/application.md +5 -5
- package/docs/cli/auth.md +55 -6
- package/docs/cli/function.md +2 -2
- package/docs/cli/staticwebsite.md +137 -0
- package/docs/cli-reference.md +17 -14
- package/docs/configuration.md +1 -1
- package/docs/generator/builtin.md +1 -1
- package/docs/runtime.md +9 -12
- package/docs/services/auth.md +0 -11
- package/docs/services/staticwebsite.md +13 -0
- package/docs/testing.md +92 -85
- package/package.json +8 -8
- package/dist/application-CdkoGX27.mjs.map +0 -1
- package/dist/application-x_mURdR0.mjs +0 -4
- package/dist/client-DLPEPJ_s.mjs.map +0 -1
- package/dist/client-DrzwCD1W.mjs +0 -4
- package/dist/crashreport-Bm2mN5tg.mjs.map +0 -1
- package/dist/job-CEAJLiGp.mjs.map +0 -1
- package/dist/mock-B6PI49C_.mjs +0 -844
- package/dist/mock-B6PI49C_.mjs.map +0 -1
- package/dist/runtime-1YuaoNr8.mjs.map +0 -1
- package/dist/test-env-key-CSnK4W1Y.mjs +0 -30
- package/dist/test-env-key-CSnK4W1Y.mjs.map +0 -1
package/dist/vitest/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as TailorEnv } from "../env-B-g-qgE4.mjs";
|
|
2
2
|
import { Kysely, OperationNode, OperationNodeKind, Transaction } from "kysely";
|
|
3
|
+
import { Mock } from "vitest";
|
|
3
4
|
import { Plugin } from "vitest/config";
|
|
4
5
|
|
|
5
6
|
//#region src/vitest/mock.d.ts
|
|
@@ -58,60 +59,55 @@ interface IconvCall {
|
|
|
58
59
|
method: string;
|
|
59
60
|
args: unknown[];
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
declare class MockQueryResult {
|
|
63
|
+
command: string;
|
|
64
|
+
rowCount: number;
|
|
65
|
+
rows: unknown[];
|
|
66
|
+
constructor(rows: unknown[]);
|
|
64
67
|
}
|
|
65
68
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
69
|
+
* Acquire a disposable mock for TailorDB operations. Installs a mock
|
|
70
|
+
* `tailordb.Client` whose `queryObject` is a shared `vi.fn()` (so query
|
|
71
|
+
* responses can be staged before the client is constructed). Restored on
|
|
72
|
+
* dispose.
|
|
73
|
+
* @returns Disposable TailorDB mock control object
|
|
70
74
|
* @example
|
|
71
75
|
* ```typescript
|
|
72
|
-
* import {
|
|
73
|
-
*
|
|
74
|
-
* beforeEach(() => tailordbMock.reset());
|
|
75
|
-
*
|
|
76
|
-
* test("content-based", () => {
|
|
77
|
-
* tailordbMock.setQueryResolver((query) => {
|
|
78
|
-
* if (query.includes("SELECT")) return [{ id: "1" }];
|
|
79
|
-
* return [];
|
|
80
|
-
* });
|
|
81
|
-
* });
|
|
76
|
+
* import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
82
77
|
*
|
|
83
|
-
* test("order-based", () => {
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* );
|
|
78
|
+
* test("order-based", async () => {
|
|
79
|
+
* using db = mockTailordb();
|
|
80
|
+
* db.enqueueResults([], [{ age: 30 }], []); // BEGIN / SELECT / COMMIT
|
|
81
|
+
* // …
|
|
82
|
+
* expect(db.queryObject).toHaveBeenCalledTimes(3);
|
|
83
|
+
* expect(db.Client).toHaveBeenCalledWith({ namespace: "tailordb" });
|
|
89
84
|
* });
|
|
90
85
|
* ```
|
|
91
86
|
*/
|
|
92
|
-
declare
|
|
87
|
+
declare function mockTailordb(): {
|
|
88
|
+
/** The mock `tailordb.Client` constructor (`vi.fn`). */Client: Mock<(this: any, config?: {
|
|
89
|
+
namespace?: string;
|
|
90
|
+
}) => void>; /** The shared `queryObject` `vi.fn` used by every client and transaction. */
|
|
91
|
+
queryObject: Mock<(_query: string, _params?: unknown[]) => Promise<MockQueryResult>>;
|
|
93
92
|
/**
|
|
94
|
-
* Set a fallback query resolver. Called when the
|
|
93
|
+
* Set a fallback query resolver. Called when the enqueue queue is empty.
|
|
95
94
|
* @param resolver - Function that returns rows for a given query and params
|
|
96
95
|
*/
|
|
97
96
|
setQueryResolver(resolver: QueryResolver$1): void;
|
|
98
97
|
/**
|
|
99
|
-
* Enqueue rows for the next `queryObject` call
|
|
100
|
-
*
|
|
101
|
-
* order; when the queue is exhausted, subsequent calls fall back to `setQueryResolver`
|
|
102
|
-
* (default: empty rows). Use `enqueueResults` to stage rows for multiple queries in one
|
|
103
|
-
* call.
|
|
98
|
+
* Enqueue rows for the next `queryObject` call (FIFO; takes priority over
|
|
99
|
+
* `setQueryResolver`). Call with no arguments for an empty result.
|
|
104
100
|
* @param rows - Row objects to return from the next `queryObject` call
|
|
105
101
|
*/
|
|
106
102
|
enqueueResult(...rows: unknown[]): void;
|
|
107
103
|
/**
|
|
108
|
-
* Enqueue rows for multiple subsequent `queryObject` calls.
|
|
109
|
-
* array for one query, consumed in FIFO order.
|
|
104
|
+
* Enqueue rows for multiple subsequent `queryObject` calls (FIFO).
|
|
110
105
|
* @param rowsList - Rows arrays, one per upcoming query
|
|
111
106
|
*/
|
|
112
107
|
enqueueResults(...rowsList: unknown[][]): void;
|
|
113
108
|
/**
|
|
114
|
-
* All queries executed via `queryObject`, in order.
|
|
109
|
+
* All queries executed via `queryObject`, in order, derived from the vi.fn
|
|
110
|
+
* call records.
|
|
115
111
|
* @returns Executed queries array
|
|
116
112
|
*/
|
|
117
113
|
readonly executedQueries: ExecutedQuery$1[];
|
|
@@ -119,58 +115,43 @@ declare const tailordbMock: {
|
|
|
119
115
|
* All TailorDB clients created, with their namespace and end state.
|
|
120
116
|
* @returns Created clients array
|
|
121
117
|
*/
|
|
122
|
-
readonly createdClients: CreatedClient[]; /** Reset
|
|
118
|
+
readonly createdClients: CreatedClient[]; /** Reset query responses and recorded calls (keeps the mock installed). */
|
|
123
119
|
reset(): void;
|
|
124
|
-
};
|
|
120
|
+
} & Disposable;
|
|
125
121
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
122
|
+
* Acquire a disposable mock for workflow operations (`tailor.workflow`).
|
|
123
|
+
* Restored on dispose.
|
|
124
|
+
* @returns Disposable workflow mock control object
|
|
129
125
|
* @example
|
|
130
126
|
* ```typescript
|
|
131
|
-
* import {
|
|
127
|
+
* import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
132
128
|
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* return null;
|
|
139
|
-
* });
|
|
140
|
-
* });
|
|
141
|
-
*
|
|
142
|
-
* test("wait point", () => {
|
|
143
|
-
* workflowMock.setWaitHandler(() => ({ approved: true }));
|
|
144
|
-
* // …
|
|
145
|
-
* expect(workflowMock.waitCalls).toEqual([{ key: "approval", payload: undefined }]);
|
|
146
|
-
* });
|
|
147
|
-
*
|
|
148
|
-
* test("resolve point", () => {
|
|
149
|
-
* workflowMock.setResolveHandler((_executionId, _key, callback) =>
|
|
150
|
-
* callback({ approved: true }),
|
|
151
|
-
* );
|
|
152
|
-
* // …
|
|
153
|
-
* expect(workflowMock.resolveCalls).toEqual([
|
|
154
|
-
* { executionId: "mock-execution-id", key: "approval" },
|
|
155
|
-
* ]);
|
|
129
|
+
* test("job handler", async () => {
|
|
130
|
+
* using wf = mockWorkflow();
|
|
131
|
+
* wf.setJobHandler((name) => (name === "validate" ? { valid: true } : null));
|
|
132
|
+
* await runWorkflowUnderTest(); // calls tailor.workflow.triggerJobFunction("validate", {})
|
|
133
|
+
* expect(wf.triggerJobFunction).toHaveBeenCalledWith("validate", {});
|
|
156
134
|
* });
|
|
157
135
|
* ```
|
|
158
136
|
*/
|
|
159
|
-
declare
|
|
137
|
+
declare function mockWorkflow(): {
|
|
138
|
+
/** The `triggerJobFunction` `vi.fn`. */triggerJobFunction: Mock<(jobName: string, args?: unknown) => unknown>; /** The `triggerWorkflow` `vi.fn`. */
|
|
139
|
+
triggerWorkflow: Mock<(workflowName: string, args?: unknown, _options?: TriggerWorkflowOptions) => Promise<string>>; /** The `wait` `vi.fn`. */
|
|
140
|
+
wait: Mock<(_key: string, _payload?: unknown) => unknown>; /** The `resolve` `vi.fn`. */
|
|
141
|
+
resolve: Mock<(_executionId: string, _key: string, _callback: (payload: unknown) => unknown) => Promise<void>>;
|
|
160
142
|
/**
|
|
161
|
-
* Set a fallback job handler. Called when the
|
|
162
|
-
* @param handler - Function
|
|
143
|
+
* Set a fallback job handler. Called when the enqueue queue is empty.
|
|
144
|
+
* @param handler - Function returning a result for a job name and args
|
|
163
145
|
*/
|
|
164
146
|
setJobHandler(handler: JobHandler): void;
|
|
165
147
|
/**
|
|
166
|
-
* Enqueue a single result for the next `triggerJobFunction` call
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* @param result - Result to return from the next `triggerJobFunction` call
|
|
148
|
+
* Enqueue a single result for the next `triggerJobFunction` call (FIFO;
|
|
149
|
+
* takes priority over `setJobHandler`).
|
|
150
|
+
* @param result - Result to return from the next call
|
|
170
151
|
*/
|
|
171
152
|
enqueueResult(result: unknown): void;
|
|
172
153
|
/**
|
|
173
|
-
* Enqueue results for multiple subsequent `triggerJobFunction` calls.
|
|
154
|
+
* Enqueue results for multiple subsequent `triggerJobFunction` calls (FIFO).
|
|
174
155
|
* @param results - Results to enqueue, one per upcoming call
|
|
175
156
|
*/
|
|
176
157
|
enqueueResults(...results: unknown[]): void;
|
|
@@ -180,38 +161,31 @@ declare const workflowMock: {
|
|
|
180
161
|
*/
|
|
181
162
|
readonly triggeredJobs: TriggeredJob[];
|
|
182
163
|
/**
|
|
183
|
-
* Configure what `
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param handler - Static execution ID or a function that returns one
|
|
164
|
+
* Configure what `triggerWorkflow` returns. Pass a string (same id every
|
|
165
|
+
* call) or `(name, args, options) => string`. Default: a placeholder UUID.
|
|
166
|
+
* @param handler - Static execution ID or a function returning one
|
|
187
167
|
*/
|
|
188
168
|
setTriggerHandler(handler: string | TriggerHandlerFn): void;
|
|
189
169
|
/**
|
|
190
|
-
* Configure what `
|
|
191
|
-
*
|
|
192
|
-
* @param handler - Static value or a function
|
|
170
|
+
* Configure what `wait` returns. Pass `(key, payload) => unknown` or any
|
|
171
|
+
* other value to return it for every call. Default: `null`.
|
|
172
|
+
* @param handler - Static value or a function returning one
|
|
193
173
|
*/
|
|
194
174
|
setWaitHandler: SetWaitHandler;
|
|
195
175
|
/**
|
|
196
176
|
* Set the `env` passed to job bodies invoked via `createWorkflowJob().trigger()`.
|
|
197
|
-
* Cleared
|
|
177
|
+
* Cleared on dispose / reset.
|
|
198
178
|
* @param env - Env passed to job bodies.
|
|
199
179
|
*/
|
|
200
180
|
setEnv(env: TailorEnv): void;
|
|
201
181
|
/**
|
|
202
|
-
* Configure how `
|
|
203
|
-
*
|
|
204
|
-
* resolve→wait wiring in tests. Default: callback is not invoked (records the call only).
|
|
182
|
+
* Configure how `resolve` runs the user-supplied callback. Default: callback
|
|
183
|
+
* is not invoked (records the call only).
|
|
205
184
|
* @param handler - Function invoked per `resolve` call
|
|
206
185
|
*/
|
|
207
186
|
setResolveHandler(handler: ResolveHandler): void;
|
|
208
187
|
/**
|
|
209
|
-
*
|
|
210
|
-
* @returns Workflow calls array
|
|
211
|
-
*/
|
|
212
|
-
readonly calls: WorkflowCall[];
|
|
213
|
-
/**
|
|
214
|
-
* `tailor.workflow.wait` calls reshaped as `{ key, payload }` for assertions.
|
|
188
|
+
* `wait` calls reshaped as `{ key, payload }` for assertions.
|
|
215
189
|
* @returns Wait call records
|
|
216
190
|
*/
|
|
217
191
|
readonly waitCalls: {
|
|
@@ -219,33 +193,81 @@ declare const workflowMock: {
|
|
|
219
193
|
payload: unknown;
|
|
220
194
|
}[];
|
|
221
195
|
/**
|
|
222
|
-
* `
|
|
196
|
+
* `resolve` calls reshaped as `{ executionId, key }` for assertions.
|
|
223
197
|
* @returns Resolve call records
|
|
224
198
|
*/
|
|
225
199
|
readonly resolveCalls: {
|
|
226
200
|
executionId: string;
|
|
227
201
|
key: string;
|
|
228
|
-
}[]; /** Reset all workflow
|
|
202
|
+
}[]; /** Reset all workflow responses and recorded calls (keeps the mock installed). */
|
|
229
203
|
reset(): void;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
|
|
204
|
+
} & Disposable;
|
|
205
|
+
/**
|
|
206
|
+
* Acquire a disposable mock for `tailor.secretmanager`. The secret store is
|
|
207
|
+
* inherited (cloned) from the currently-installed mock on acquisition and
|
|
208
|
+
* restored on dispose, so secrets seeded outside the test survive across
|
|
209
|
+
* `using` scopes while per-test `setSecrets()` overrides stay isolated.
|
|
210
|
+
* @returns Disposable SecretManager mock control object
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* import { mockSecretmanager } from "@tailor-platform/sdk/vitest";
|
|
214
|
+
*
|
|
215
|
+
* test("reads secrets from vault", async () => {
|
|
216
|
+
* using sm = mockSecretmanager();
|
|
217
|
+
* sm.setSecrets({ "my-vault": { API_KEY: "sk-123" } });
|
|
218
|
+
* // …
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
declare function mockSecretmanager(): {
|
|
223
|
+
/** The `getSecret` `vi.fn`. */getSecret: Mock<(vault: string, name: string) => Promise<string | undefined>>; /** The `getSecrets` `vi.fn`. */
|
|
224
|
+
getSecrets: Mock<(<const T extends readonly string[]>(vault: string, names: T) => Promise<Partial<Record<T[number], string>>>)>;
|
|
233
225
|
setSecrets(secrets: Record<string, Record<string, string>>): void;
|
|
234
226
|
readonly calls: SecretCall[];
|
|
235
227
|
reset(): void;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
|
|
239
|
-
|
|
228
|
+
} & Disposable;
|
|
229
|
+
/**
|
|
230
|
+
* Acquire a disposable mock for `tailor.authconnection`. Restored on dispose.
|
|
231
|
+
* @returns Disposable AuthConnection mock control object
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* import { mockAuthconnection } from "@tailor-platform/sdk/vitest";
|
|
235
|
+
*
|
|
236
|
+
* test("returns configured token", async () => {
|
|
237
|
+
* using ac = mockAuthconnection();
|
|
238
|
+
* ac.setTokens({ google: { access_token: "ya29.xxx" } });
|
|
239
|
+
* // …
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare function mockAuthconnection(): {
|
|
244
|
+
/** The `getConnectionToken` `vi.fn`. */getConnectionToken: Mock<(connectionName: string) => Promise<any>>;
|
|
245
|
+
setTokens(value: Record<string, unknown>): void;
|
|
240
246
|
readonly calls: AuthConnectionCall[];
|
|
241
247
|
reset(): void;
|
|
242
|
-
};
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
|
|
248
|
+
} & Disposable;
|
|
249
|
+
/**
|
|
250
|
+
* Acquire a disposable mock for `tailor.idp`. Restored on dispose.
|
|
251
|
+
* @returns Disposable IDP mock control object
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* import { mockIdp } from "@tailor-platform/sdk/vitest";
|
|
255
|
+
*
|
|
256
|
+
* test("resolver-based", async () => {
|
|
257
|
+
* using idp = mockIdp();
|
|
258
|
+
* idp.setResolver((method) =>
|
|
259
|
+
* method === "user" ? { id: "u-1", name: "alice", disabled: false } : null,
|
|
260
|
+
* );
|
|
261
|
+
* // …
|
|
262
|
+
* });
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
declare function mockIdp(): {
|
|
266
|
+
/** The mock IDP `Client` constructor (`vi.fn`). */Client: Mock;
|
|
267
|
+
setResolver(value: IdpResolver): void;
|
|
246
268
|
/**
|
|
247
|
-
* Enqueue a single result for the next IDP call
|
|
248
|
-
*
|
|
269
|
+
* Enqueue a single result for the next IDP call (FIFO; falls back to
|
|
270
|
+
* `setResolver` when exhausted).
|
|
249
271
|
* @param result - Result to return from the next IDP call
|
|
250
272
|
*/
|
|
251
273
|
enqueueResult(result: unknown): void;
|
|
@@ -256,14 +278,45 @@ declare const idpMock: {
|
|
|
256
278
|
enqueueResults(...results: unknown[]): void;
|
|
257
279
|
readonly calls: IdpCall[];
|
|
258
280
|
reset(): void;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
|
|
262
|
-
|
|
281
|
+
} & Disposable;
|
|
282
|
+
/**
|
|
283
|
+
* Acquire a disposable mock for `tailor.iconv`. Restored on dispose.
|
|
284
|
+
* @returns Disposable Iconv mock control object
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* import { mockIconv } from "@tailor-platform/sdk/vitest";
|
|
288
|
+
*
|
|
289
|
+
* test("mock encoding conversion", () => {
|
|
290
|
+
* using iconv = mockIconv();
|
|
291
|
+
* iconv.setResolver((method) => (method === "decode" ? "decoded-text" : null));
|
|
292
|
+
* // …
|
|
293
|
+
* });
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
declare function mockIconv(): {
|
|
297
|
+
setResolver(value: IconvResolver): void;
|
|
298
|
+
readonly calls: IconvCall[];
|
|
299
|
+
reset(): void;
|
|
300
|
+
} & Disposable;
|
|
301
|
+
/**
|
|
302
|
+
* Acquire a disposable mock for `tailordb.file`. Restored on dispose.
|
|
303
|
+
* @returns Disposable File mock control object
|
|
304
|
+
* @example
|
|
305
|
+
* ```typescript
|
|
306
|
+
* import { mockFile } from "@tailor-platform/sdk/vitest";
|
|
307
|
+
*
|
|
308
|
+
* test("mock file download", async () => {
|
|
309
|
+
* using file = mockFile();
|
|
310
|
+
* file.enqueueResult({ data: new Uint8Array([1, 2, 3]), metadata: { ... } });
|
|
311
|
+
* // …
|
|
312
|
+
* });
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
declare function mockFile(): {
|
|
316
|
+
setResolver(value: FileResolver): void;
|
|
263
317
|
/**
|
|
264
|
-
* Enqueue a single result for the next `tailordb.file` call
|
|
265
|
-
*
|
|
266
|
-
* in one call.
|
|
318
|
+
* Enqueue a single result for the next `tailordb.file` call (FIFO; falls
|
|
319
|
+
* back to `setResolver` when exhausted).
|
|
267
320
|
* @param result - Result to return from the next file call
|
|
268
321
|
*/
|
|
269
322
|
enqueueResult(result: unknown): void;
|
|
@@ -274,13 +327,7 @@ declare const fileMock: {
|
|
|
274
327
|
enqueueResults(...results: unknown[]): void;
|
|
275
328
|
readonly calls: FileCall[];
|
|
276
329
|
reset(): void;
|
|
277
|
-
};
|
|
278
|
-
/** Mock control for `tailor.iconv` — encoding call recording. */
|
|
279
|
-
declare const iconvMock: {
|
|
280
|
-
setResolver(resolver: IconvResolver): void;
|
|
281
|
-
readonly calls: IconvCall[];
|
|
282
|
-
reset(): void;
|
|
283
|
-
};
|
|
330
|
+
} & Disposable;
|
|
284
331
|
//#endregion
|
|
285
332
|
//#region src/vitest/mock-kysely.d.ts
|
|
286
333
|
/** A single statement executed against the mock, captured in order. */
|
|
@@ -362,8 +409,8 @@ declare function createKyselyMock<DB = Record<string, never>>(): KyselyMock<DB>;
|
|
|
362
409
|
* via beforeEach/afterEach since Vitest needs it during initialization.
|
|
363
410
|
*
|
|
364
411
|
* 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with
|
|
365
|
-
* control objects: `
|
|
366
|
-
* `
|
|
412
|
+
* control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`,
|
|
413
|
+
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`. Each
|
|
367
414
|
* provides response configuration, call recording, and reset.
|
|
368
415
|
*
|
|
369
416
|
* 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the
|
|
@@ -378,7 +425,7 @@ declare function createKyselyMock<DB = Record<string, never>>(): KyselyMock<DB>;
|
|
|
378
425
|
* ## Options
|
|
379
426
|
*
|
|
380
427
|
* - **`config`** — Path to `tailor.config.ts`. Loads `defineSecretManager()` values
|
|
381
|
-
* into `
|
|
428
|
+
* into `mockSecretmanager` so `getSecret()` returns the configured values.
|
|
382
429
|
* @example
|
|
383
430
|
* ```typescript
|
|
384
431
|
* // vitest.config.ts
|
|
@@ -400,5 +447,5 @@ declare function tailorRuntime(options?: {
|
|
|
400
447
|
config?: string;
|
|
401
448
|
}): Plugin[];
|
|
402
449
|
//#endregion
|
|
403
|
-
export { type ExecutedQuery, type KyselyMock,
|
|
450
|
+
export { type ExecutedQuery, type KyselyMock, createKyselyMock, mockAuthconnection, mockFile, mockIconv, mockIdp, mockSecretmanager, mockTailordb, mockWorkflow, tailorRuntime };
|
|
404
451
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/vitest/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as mockSecretmanager, i as mockIdp, n as mockFile, o as mockTailordb, r as mockIconv, s as mockWorkflow, t as mockAuthconnection } from "../mock-Dpu__UeJ.mjs";
|
|
3
3
|
import { builtinModules } from "node:module";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { dirname, isAbsolute, matchesGlob, relative, resolve } from "node:path";
|
|
@@ -234,7 +234,7 @@ function createBlockPlugin() {
|
|
|
234
234
|
}
|
|
235
235
|
if (replacements.length === 0) return void 0;
|
|
236
236
|
let transformed = code;
|
|
237
|
-
for (const r of replacements.
|
|
237
|
+
for (const r of replacements.toSorted((a, b) => b.start - a.start)) transformed = transformed.slice(0, r.start) + r.replacement + transformed.slice(r.end);
|
|
238
238
|
return {
|
|
239
239
|
code: transformed,
|
|
240
240
|
map: null
|
|
@@ -475,8 +475,8 @@ function createKyselyMock() {
|
|
|
475
475
|
* via beforeEach/afterEach since Vitest needs it during initialization.
|
|
476
476
|
*
|
|
477
477
|
* 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with
|
|
478
|
-
* control objects: `
|
|
479
|
-
* `
|
|
478
|
+
* control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`,
|
|
479
|
+
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`. Each
|
|
480
480
|
* provides response configuration, call recording, and reset.
|
|
481
481
|
*
|
|
482
482
|
* 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the
|
|
@@ -491,7 +491,7 @@ function createKyselyMock() {
|
|
|
491
491
|
* ## Options
|
|
492
492
|
*
|
|
493
493
|
* - **`config`** — Path to `tailor.config.ts`. Loads `defineSecretManager()` values
|
|
494
|
-
* into `
|
|
494
|
+
* into `mockSecretmanager` so `getSecret()` returns the configured values.
|
|
495
495
|
* @example
|
|
496
496
|
* ```typescript
|
|
497
497
|
* // vitest.config.ts
|
|
@@ -514,5 +514,5 @@ function tailorRuntime(options) {
|
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
//#endregion
|
|
517
|
-
export {
|
|
517
|
+
export { createKyselyMock, mockAuthconnection, mockFile, mockIconv, mockIdp, mockSecretmanager, mockTailordb, mockWorkflow, tailorRuntime };
|
|
518
518
|
//# sourceMappingURL=index.mjs.map
|