@cloudflare/vitest-plugin 1.1.5 → 1.1.7
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/dist/pool/index.mjs +799 -504
- package/dist/pool/index.mjs.map +1 -1
- package/dist/pool/{open-PBXRGS4R-Bd-FUZNf.mjs → open-PBXRGS4R-CzyP5HqI.mjs} +2 -2
- package/dist/pool/{open-PBXRGS4R-Bd-FUZNf.mjs.map → open-PBXRGS4R-CzyP5HqI.mjs.map} +1 -1
- package/dist/worker/index.mjs.map +1 -1
- package/package.json +10 -9
- package/types/cloudflare-test.d.ts +41 -13
|
@@ -20,14 +20,14 @@ declare module "cloudflare:test" {
|
|
|
20
20
|
* persisted data. Note this can only be used with `stub`s pointing to Durable
|
|
21
21
|
* Objects defined in the `main` worker.
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
export function runInDurableObject<
|
|
25
|
-
O extends DurableObject | Rpc.DurableObject,
|
|
26
|
-
R,
|
|
27
|
-
>(
|
|
23
|
+
export function runInDurableObject<O extends Rpc.DurableObjectBranded, R>(
|
|
28
24
|
stub: DurableObjectStub<O>,
|
|
29
25
|
callback: (instance: O, state: DurableObjectState) => R | Promise<R>
|
|
30
26
|
): Promise<R>;
|
|
27
|
+
export function runInDurableObject<O extends DurableObject, R>(
|
|
28
|
+
stub: DurableObjectStub,
|
|
29
|
+
callback: (instance: O, state: DurableObjectState) => R | Promise<R>
|
|
30
|
+
): Promise<R>;
|
|
31
31
|
/**
|
|
32
32
|
* Immediately runs and removes the Durable Object pointed-to by `stub`'s
|
|
33
33
|
* alarm if one is scheduled. Returns `true` if an alarm ran, and `false`
|
|
@@ -73,9 +73,9 @@ declare module "cloudflare:test" {
|
|
|
73
73
|
/**
|
|
74
74
|
* Gets the IDs of all objects that have been created in the `namespace`.
|
|
75
75
|
*/
|
|
76
|
-
export function listDurableObjectIds<
|
|
77
|
-
|
|
78
|
-
): Promise<DurableObjectId[]>;
|
|
76
|
+
export function listDurableObjectIds<
|
|
77
|
+
T extends Rpc.DurableObjectBranded | undefined,
|
|
78
|
+
>(namespace: DurableObjectNamespace<T>): Promise<DurableObjectId[]>;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Deletes all data from all attached bindings. This is
|
|
@@ -150,17 +150,42 @@ declare module "cloudflare:test" {
|
|
|
150
150
|
* Creates an instance of `ScheduledController` for use as the 1st argument to
|
|
151
151
|
* modules-format `scheduled()` exported handlers.
|
|
152
152
|
*/
|
|
153
|
+
export interface ScheduledControllerOptions {
|
|
154
|
+
scheduledTime?: Date | number;
|
|
155
|
+
cron?: string;
|
|
156
|
+
}
|
|
153
157
|
export function createScheduledController(
|
|
154
|
-
options?:
|
|
158
|
+
options?: ScheduledControllerOptions
|
|
155
159
|
): ScheduledController;
|
|
160
|
+
/** A message used to construct a `MessageBatch` for a queue handler. */
|
|
161
|
+
export type MessageBatchMessage<Body = unknown> = {
|
|
162
|
+
id: string;
|
|
163
|
+
timestamp: Date | number;
|
|
164
|
+
attempts: number;
|
|
165
|
+
body: Body;
|
|
166
|
+
};
|
|
156
167
|
/**
|
|
157
168
|
* Creates an instance of `MessageBatch` for use as the 1st argument to
|
|
158
169
|
* modules-format `queue()` exported handlers.
|
|
159
170
|
*/
|
|
160
171
|
export function createMessageBatch<Body = unknown>(
|
|
161
172
|
queueName: string,
|
|
162
|
-
messages:
|
|
173
|
+
messages: MessageBatchMessage<Body>[]
|
|
163
174
|
): MessageBatch<Body>;
|
|
175
|
+
/** The acknowledgement and retry state collected from a queue handler. */
|
|
176
|
+
export interface QueueResult {
|
|
177
|
+
outcome: string;
|
|
178
|
+
ackAll: boolean;
|
|
179
|
+
retryBatch: {
|
|
180
|
+
retry: boolean;
|
|
181
|
+
delaySeconds?: number;
|
|
182
|
+
};
|
|
183
|
+
explicitAcks: string[];
|
|
184
|
+
retryMessages: {
|
|
185
|
+
msgId: string;
|
|
186
|
+
delaySeconds?: number;
|
|
187
|
+
}[];
|
|
188
|
+
}
|
|
164
189
|
/**
|
|
165
190
|
* Gets the ack/retry state of messages in the `MessageBatch`, and waits for
|
|
166
191
|
* all `ExecutionContext#waitUntil()`ed `Promise`s to settle. Only accepts
|
|
@@ -170,7 +195,7 @@ declare module "cloudflare:test" {
|
|
|
170
195
|
export function getQueueResult(
|
|
171
196
|
batch: MessageBatch,
|
|
172
197
|
ctx: ExecutionContext
|
|
173
|
-
): Promise<
|
|
198
|
+
): Promise<QueueResult>;
|
|
174
199
|
|
|
175
200
|
export interface D1Migration {
|
|
176
201
|
name: string;
|
|
@@ -534,7 +559,10 @@ declare module "cloudflare:test" {
|
|
|
534
559
|
* @param times - Optional number of times the step will time out. Useful for
|
|
535
560
|
* testing retry logic. If omitted, it will time out on **every attempt**.
|
|
536
561
|
*/
|
|
537
|
-
forceStepTimeout(
|
|
562
|
+
forceStepTimeout(
|
|
563
|
+
step: { name: string; index?: number },
|
|
564
|
+
times?: number
|
|
565
|
+
): Promise<void>;
|
|
538
566
|
|
|
539
567
|
/**
|
|
540
568
|
* Sends a mock event to the Workflow instance. This causes a `step.waitForEvent()`
|
|
@@ -688,7 +716,7 @@ declare module "cloudflare:test" {
|
|
|
688
716
|
: { params: Record<Params, string | string[]> };
|
|
689
717
|
type EventContextInitData<Data> =
|
|
690
718
|
Data extends Record<string, never> ? { data?: Data } : { data: Data };
|
|
691
|
-
type EventContextInit<E extends EventContext<unknown,
|
|
719
|
+
type EventContextInit<E extends EventContext<unknown, string, unknown>> =
|
|
692
720
|
E extends EventContext<unknown, infer Params, infer Data>
|
|
693
721
|
? EventContextInitBase &
|
|
694
722
|
EventContextInitParams<Params> &
|