@sanity/functions 1.6.4 → 1.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/invoke.js CHANGED
@@ -104,7 +104,7 @@ export async function invoke(name, payload, options) {
104
104
  // Update lineage or throw error if we exceed the max recursion value
105
105
  const outgoingPayload = {
106
106
  ...payload,
107
- context: { ...payload.context, lineage: buildLineageToken(name, payload.context?.lineage) },
107
+ context: { ...payload.context, lineage: buildLineageToken(name, env['X_SANITY_LINEAGE']) },
108
108
  };
109
109
  const stringPayload = JSON.stringify(outgoingPayload);
110
110
  // Check to make sure payload is not over the max we can handle
@@ -1 +1 @@
1
- {"version":3,"file":"invoke.js","sourceRoot":"","sources":["../src/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAA;AAIhC,IAAI,UAAsD,CAAA;AAE1D,MAAM,aAAa,GAAG,aAAa,CAAA;AACnC,gBAAgB;AAChB,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAErC;;;GAGG;AACH,SAAS,UAAU;IACjB,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,UAAU,GAAG,CAAC,KAAK,IAAI,EAAE;YACvB,MAAM,EAAC,OAAO,EAAE,OAAO,EAAC,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAA;YAC3D,OAAO,OAAO,CAAC;gBACb,OAAO,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;aACtH,CAAC,CAAA;QACJ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACjB,UAAU,GAAG,SAAS,CAAA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AAC;QACD,kGAAkG;QAClG,OAAO,OAAY,CAAA;IACrB,CAAC;IAED,2BAA2B;IAC3B,IAAI,QAAQ,CAAC,KAAK,IAAI,YAAY,KAAK,wBAAwB,EAAE,CAAC;QAChE,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;YACpB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,kBAAkB;YAC3C,OAAO,EAAE,aAAa;SACvB,CAAC,CAAA;IACJ,CAAC;SAAM,IAAI,QAAQ,CAAC,KAAK,IAAI,YAAY,KAAK,uBAAuB,EAAE,CAAC;QACtE,MAAM,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;YACxB,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,kBAAkB;SAC5C,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC,CAAA;IACjE,CAAC;IAED,OAAM;AACR,CAAC;AAED,gBAAgB;AAChB,SAAS,gBAAgB,CAAC,OAAe,EAAE,IAAa;IACtD,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;QAC1D,CAAC;IACH,CAAC;AACH,CAAC"}
package/dist/types.d.ts CHANGED
@@ -234,42 +234,41 @@ export type FunctionResourceEnvelope = {
234
234
  [P in Exclude<FunctionResourceKey, K>]?: FunctionResource;
235
235
  };
236
236
  }[FunctionResourceKey];
237
+ /**
238
+ * Durable alias of FunctionsContext
239
+ * @alpha Using durables is considered experimental and may change in the future.
240
+ * @hidden
241
+ */
242
+ export type DurableContext = FunctionContext;
237
243
  /**
238
244
  * Logger interface for durables.
239
245
  * @alpha Using durables is considered experimental and may change in the future.
240
246
  * @hidden
241
247
  */
242
248
  export interface DurableLogger {
243
- debug(message?: string, ...optionalParams: unknown[]): void;
244
- info(message?: string, ...optionalParams: unknown[]): void;
245
- warn(message?: string, ...optionalParams: unknown[]): void;
246
- error(message?: string, ...optionalParams: unknown[]): void;
247
- log(message?: string, ...optionalParams: unknown[]): void;
249
+ debug(...params: unknown[]): void;
250
+ info(...params: unknown[]): void;
251
+ warn(...params: unknown[]): void;
252
+ error(...params: unknown[]): void;
253
+ log(...params: unknown[]): void;
248
254
  }
249
255
  /**
250
- * // @todo: follow-up to better define separated context
251
256
  * @alpha Using durables is considered experimental and may change in the future.
252
257
  * @hidden
253
258
  */
254
- export interface BaseDurableOperationArgs {
259
+ export interface DurableStepCallbackContext {
255
260
  logger: DurableLogger;
256
261
  }
257
262
  /**
258
- * @todo: follow-up to better define separated context
263
+ * Arguments passed to callbacks that execute a durable attempt.
264
+ * step.run & step.waitForCondition
259
265
  * @alpha Using durables is considered experimental and may change in the future.
260
266
  * @hidden
261
267
  */
262
- export type DurableContext = FunctionContext & {
263
- /**
264
- * Current attempt of the active durable operation.
265
- * Only available in methods that expose the attempt like `waitForCondition`
266
- */
267
- attempt?: number;
268
- /**
269
- * Unique ID for a durable execution
270
- */
271
- runId?: string;
272
- };
268
+ export interface DurableStepAttemptContext extends DurableStepCallbackContext {
269
+ /** Current attempt number, starting at 1. */
270
+ attempt: number;
271
+ }
273
272
  /**
274
273
  * The signature of the duration object passed to the `wait` method of a durable function.
275
274
  * It can be specified in days, hours, minutes, or seconds.
@@ -296,36 +295,67 @@ export type DurableDuration = {
296
295
  * @hidden
297
296
  */
298
297
  export type DurableWaitForConditionDecision = {
299
- shouldContinue: true;
298
+ shouldRetry: true;
300
299
  delay: DurableDuration;
301
300
  } | {
302
- shouldContinue: false;
301
+ shouldRetry: false;
303
302
  };
304
303
  /**
305
304
  * @alpha Using durables is considered experimental and may change in the future.
306
305
  * @hidden
307
306
  */
308
- export interface DurableWaitForConditionOptions<T> {
309
- initial: T;
310
- next: (state: T, context: BaseDurableOperationArgs) => DurableWaitForConditionDecision;
311
- }
307
+ export type DurableStepHandler<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn;
308
+ /**
309
+ * @alpha Using durables is considered experimental and may change in the future.
310
+ * @hidden
311
+ */
312
+ export type DurableStepRunHandler<T = unknown> = DurableStepHandler<[context: DurableStepAttemptContext], T | Promise<T>>;
313
+ /**
314
+ * @alpha Using durables is considered experimental and may change in the future.
315
+ * @hidden
316
+ */
317
+ export type DurableStepWaitForCallbackHandler = DurableStepHandler<[callbackId: string, context: DurableStepCallbackContext], Promise<void>>;
318
+ /**
319
+ * @alpha Using durables is considered experimental and may change in the future.
320
+ * @hidden
321
+ */
322
+ export type DurableWaitForConditionPoller<T = unknown> = DurableStepHandler<[state: T, context: DurableStepAttemptContext], Promise<T>>;
323
+ /**
324
+ * @alpha Using durables is considered experimental and may change in the future.
325
+ * @hidden
326
+ */
327
+ export type DurableWaitForConditionNext<T = unknown> = DurableStepHandler<[
328
+ state: T,
329
+ context: Pick<DurableStepAttemptContext, 'attempt'>
330
+ ], DurableWaitForConditionDecision>;
312
331
  /**
313
332
  * The interface defining the operations available to a durable function.
314
333
  * These operations are steps that delegate to other functions, and wait for external callbacks.
315
334
  * @alpha Using durables is considered experimental and may change in the future.
316
335
  * @hidden
317
336
  */
318
- export interface DurableOperations {
337
+ export type DurableOperations = {
319
338
  /**
320
339
  * Runs a named step. Its result is recorded, so if the workflow re-runs the step
321
340
  * is not executed again. Failures are retried on their own.
322
341
  * similar to ctx.step()
323
342
  * @remarks cannot be nested inside another step
343
+ * @example
344
+ * ```ts
345
+ * step.run({
346
+ * name: 'run-step',
347
+ * handler: async ({logger}) => {
348
+ * logger.log('Running step')
349
+ * }})
350
+ * ```
324
351
  * @param name - Step name
325
- * @param fn - function being executed
352
+ * @param handler - function being executed
326
353
  * @returns The value returned by the executed function
327
354
  */
328
- run<T>(name: string, fn: (args: BaseDurableOperationArgs) => T | Promise<T>): Promise<T>;
355
+ run<T>({ name, handler }: {
356
+ name?: string;
357
+ handler: DurableStepRunHandler<T>;
358
+ }): Promise<T>;
329
359
  /**
330
360
  * Calls another function and awaits its result.
331
361
  * similar to ctx.invoke()
@@ -334,16 +364,22 @@ export interface DurableOperations {
334
364
  * @param input - Data passed to the called function
335
365
  * @returns The value returned by the called function
336
366
  */
337
- delegate<T>(name: string, input?: unknown): Promise<T>;
367
+ delegate<T>({ name, input }: {
368
+ name?: string;
369
+ input?: unknown;
370
+ }): Promise<T>;
338
371
  /**
339
372
  * Waits for an external callback
340
373
  * similar to ctx.waitForCallback()
341
374
  * @remarks cannot be nested inside another step
342
375
  * @param name - Step name
343
- * @param fn - Receives the generated callbackId and returns a delivered promise
376
+ * @param handler - Receives the generated callbackId and returns a delivered promise
344
377
  * @returns The value returned by the executed function
345
378
  */
346
- waitForCallback<T>(name: string, fn: (callbackId: string, args: BaseDurableOperationArgs) => Promise<void>): Promise<T>;
379
+ waitForCallback<T>({ name, handler }: {
380
+ name?: string;
381
+ handler: DurableStepWaitForCallbackHandler;
382
+ }): Promise<T>;
347
383
  /**
348
384
  * Waits for a specified duration
349
385
  * similar to ctx.wait()
@@ -351,63 +387,49 @@ export interface DurableOperations {
351
387
  * @example
352
388
  * Wait for 30 seconds
353
389
  * ```ts
354
- * await step.wait('wait30Sec', { seconds: 30 });
390
+ * await step.wait({name: 'wait30Sec', duration: { seconds: 30 }});
355
391
  * ```
356
392
  * Wait for 2 days and 3 hours
357
393
  * ```ts
358
- * await step.wait('waitALongTime', { days: 2, hours: 3 });
394
+ * await step.wait({name: 'waitALongTime', duration: { days: 2, hours: 3 }});
359
395
  * ```
360
396
  * @param name - Step name
361
397
  * @param duration - Amount of time the function will wait before continuing.
362
398
  * Duration is an object with properties of `seconds`, `minutes`, `hours`, or `days`. Must be at least {seconds: 1}
363
399
  * @returns Resolves after the duration
364
400
  */
365
- wait(name: string, duration: DurableDuration): Promise<void>;
366
- /**
367
- * Waits for a specified duration
368
- * similar to ctx.wait()
369
- * @remarks cannot be nested inside another step
370
- * @example
371
- * Wait for 30 seconds
372
- * ```ts
373
- * await step.wait({ seconds: 30 });
374
- * ```
375
- * @param duration - Amount of time the function will wait before continuing.
376
- * Duration is an object with properties of `seconds`, `minutes`, `hours`, or `days`. Must be at least {seconds: 1}
377
- * @returns Resolves after the duration
378
- */
379
- wait(duration: DurableDuration): Promise<void>;
401
+ wait({ name, duration }: {
402
+ name?: string;
403
+ duration: DurableDuration;
404
+ }): Promise<void>;
380
405
  /**
381
406
  * Waits for a specified condition to be met
382
407
  * similar to ctx.waitForCondition()
383
408
  * @remarks cannot be nested inside another step
384
409
  * @example
385
410
  * ```ts
386
- * await step.waitForCondition(
387
- * 'waitForCondition',
388
- * async (state, {logger}) => {
389
- * logger.log('Checking for article')
390
- *
391
- * const client = createClient({
392
- * apiVersion: '2026-08-05',
393
- * ...context.clientOptions,
394
- * })
395
- * const article = await client.fetch<Article | null>(
396
- * '*[_type == "article"][0]',
397
- * )
398
- * return {...state, article}
399
- * },
400
- * {
411
+ * await step.waitForCondition({{
412
+ * name: 'waitForCondition',
401
413
  * initial: {
402
- * article: null as Article | null,
414
+ * article: null,
403
415
  * },
404
- * next: (state, context) => {
405
- * if (state.article) return {shouldContinue: false}
416
+ * poller: async (state, {attempt}) => {
417
+ * const client = createClient({
418
+ * apiVersion: '2026-08-05',
419
+ * ...context.clientOptions,
420
+ * })
421
+ * const article = await client.fetch<Article | null>(
422
+ * '*[_type == "article"][0]',
423
+ * )
424
+ * return {...state, article}
425
+ * }
426
+ * next: (state, {attempt}) => {
427
+ * if (state.article) return {shouldResume: false}
406
428
  *
407
429
  * return {
408
- * shouldContinue: true,
430
+ * shouldResume: true,
409
431
  * delay: {
410
- * seconds: Math.min((context.attempt ?? 1) * 2, 60),
432
+ * seconds: Math.min(attempt * 2, 60),
411
433
  * },
412
434
  * }
413
435
  * },
@@ -415,57 +437,20 @@ export interface DurableOperations {
415
437
  * )
416
438
  * ```
417
439
  * @param name - Step name
418
- * @param fn - Called on each attempt with the current state and durable context.
419
- * Returns a promise resolving to the updated state,
420
- * which is passed to next to determine whether the condition has been met or another check should be scheduled.
421
- * @param options - Configuration options for the condition
422
- * @returns The value returned by the executed function
423
- */
424
- waitForCondition<T>(name: string, fn: (state: T, args: BaseDurableOperationArgs) => Promise<T>, options: DurableWaitForConditionOptions<T>): Promise<T>;
425
- /**
426
- * Waits for a specified condition to be met
427
- * similar to ctx.waitForCondition()
428
- * @remarks cannot be nested inside another step
429
- * @example
430
- * ```ts
431
- * await step.waitForCondition(
432
- * async (state, {logger}) => {
433
- * logger.log('Checking for article')
434
- *
435
- * const client = createClient({
436
- * apiVersion: '2026-08-05',
437
- * ...context.clientOptions,
438
- * })
439
- * const article = await client.fetch<Article | null>(
440
- * '*[_type == "article"][0]',
441
- * )
442
- * return {...state, article}
443
- * },
444
- * {
445
- * initial: {
446
- * article: null as Article | null,
447
- * },
448
- * next: (state, context) => {
449
- * if (state.article) return {shouldContinue: false}
450
- *
451
- * return {
452
- * shouldContinue: true,
453
- * delay: {
454
- * seconds: Math.min((context.attempt ?? 1) * 2, 60),
455
- * },
456
- * }
457
- * },
458
- * },
459
- * )
460
- * ```
461
- * @param fn - Called on each attempt with the current state and durable context.
440
+ * @param initial - Initial state passed to the first poller call.
441
+ * @param poller - Called on each attempt with the current state and condition context.
442
+ * @param next - A function that determines whether the condition has been met or another check should be run.
462
443
  * Returns a promise resolving to the updated state,
463
- * which is passed to next to determine whether the condition has been met or another check should be scheduled.
464
- * @param options - Configuration options for the condition
444
+ * which is passed to next to determine whether the condition has been met or another check should be run.
465
445
  * @returns The value returned by the executed function
466
446
  */
467
- waitForCondition<T>(fn: (state: T, args: BaseDurableOperationArgs) => Promise<T>, options: DurableWaitForConditionOptions<T>): Promise<T>;
468
- }
447
+ waitForCondition<T>({ name, initial, next, poller, }: {
448
+ name?: string;
449
+ initial: T;
450
+ poller: DurableWaitForConditionPoller<T>;
451
+ next: DurableWaitForConditionNext<T>;
452
+ }): Promise<T>;
453
+ };
469
454
  /**
470
455
  * @alpha Using durables is considered experimental and may change in the future.
471
456
  * @hidden
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/functions",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "Helper methods and type definitions for Sanity Functions",
5
5
  "keywords": [
6
6
  "sanity",
package/src/invoke.ts CHANGED
@@ -125,7 +125,7 @@ export async function invoke<T = unknown>(name: string, payload: FunctionPayload
125
125
  // Update lineage or throw error if we exceed the max recursion value
126
126
  const outgoingPayload: FunctionPayload = {
127
127
  ...payload,
128
- context: {...payload.context, lineage: buildLineageToken(name, payload.context?.lineage)},
128
+ context: {...payload.context, lineage: buildLineageToken(name, env['X_SANITY_LINEAGE'])},
129
129
  }
130
130
 
131
131
  const stringPayload = JSON.stringify(outgoingPayload)
package/src/types.ts CHANGED
@@ -245,43 +245,43 @@ export type FunctionResourceEnvelope = {
245
245
  [K in FunctionResourceKey]-?: {[P in K]: FunctionResource} & {[P in Exclude<FunctionResourceKey, K>]?: FunctionResource}
246
246
  }[FunctionResourceKey]
247
247
 
248
+ /**
249
+ * Durable alias of FunctionsContext
250
+ * @alpha Using durables is considered experimental and may change in the future.
251
+ * @hidden
252
+ */
253
+ export type DurableContext = FunctionContext
254
+
248
255
  /**
249
256
  * Logger interface for durables.
250
257
  * @alpha Using durables is considered experimental and may change in the future.
251
258
  * @hidden
252
259
  */
253
260
  export interface DurableLogger {
254
- debug(message?: string, ...optionalParams: unknown[]): void
255
- info(message?: string, ...optionalParams: unknown[]): void
256
- warn(message?: string, ...optionalParams: unknown[]): void
257
- error(message?: string, ...optionalParams: unknown[]): void
258
- log(message?: string, ...optionalParams: unknown[]): void
261
+ debug(...params: unknown[]): void
262
+ info(...params: unknown[]): void
263
+ warn(...params: unknown[]): void
264
+ error(...params: unknown[]): void
265
+ log(...params: unknown[]): void
259
266
  }
260
267
 
261
268
  /**
262
- * // @todo: follow-up to better define separated context
263
269
  * @alpha Using durables is considered experimental and may change in the future.
264
270
  * @hidden
265
271
  */
266
- export interface BaseDurableOperationArgs {
272
+ export interface DurableStepCallbackContext {
267
273
  logger: DurableLogger
268
274
  }
269
275
 
270
276
  /**
271
- * @todo: follow-up to better define separated context
277
+ * Arguments passed to callbacks that execute a durable attempt.
278
+ * step.run & step.waitForCondition
272
279
  * @alpha Using durables is considered experimental and may change in the future.
273
280
  * @hidden
274
281
  */
275
- export type DurableContext = FunctionContext & {
276
- /**
277
- * Current attempt of the active durable operation.
278
- * Only available in methods that expose the attempt like `waitForCondition`
279
- */
280
- attempt?: number
281
- /**
282
- * Unique ID for a durable execution
283
- */
284
- runId?: string
282
+ export interface DurableStepAttemptContext extends DurableStepCallbackContext {
283
+ /** Current attempt number, starting at 1. */
284
+ attempt: number
285
285
  }
286
286
 
287
287
  /**
@@ -300,16 +300,40 @@ export type DurableDuration =
300
300
  * @alpha Using durables is considered experimental and may change in the future.
301
301
  * @hidden
302
302
  */
303
- export type DurableWaitForConditionDecision = {shouldContinue: true; delay: DurableDuration} | {shouldContinue: false}
303
+ export type DurableWaitForConditionDecision = {shouldRetry: true; delay: DurableDuration} | {shouldRetry: false}
304
304
 
305
305
  /**
306
306
  * @alpha Using durables is considered experimental and may change in the future.
307
307
  * @hidden
308
308
  */
309
- export interface DurableWaitForConditionOptions<T> {
310
- initial: T
311
- next: (state: T, context: BaseDurableOperationArgs) => DurableWaitForConditionDecision
312
- }
309
+ export type DurableStepHandler<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn
310
+
311
+ /**
312
+ * @alpha Using durables is considered experimental and may change in the future.
313
+ * @hidden
314
+ */
315
+ export type DurableStepRunHandler<T = unknown> = DurableStepHandler<[context: DurableStepAttemptContext], T | Promise<T>>
316
+
317
+ /**
318
+ * @alpha Using durables is considered experimental and may change in the future.
319
+ * @hidden
320
+ */
321
+ export type DurableStepWaitForCallbackHandler = DurableStepHandler<[callbackId: string, context: DurableStepCallbackContext], Promise<void>>
322
+
323
+ /**
324
+ * @alpha Using durables is considered experimental and may change in the future.
325
+ * @hidden
326
+ */
327
+ export type DurableWaitForConditionPoller<T = unknown> = DurableStepHandler<[state: T, context: DurableStepAttemptContext], Promise<T>>
328
+
329
+ /**
330
+ * @alpha Using durables is considered experimental and may change in the future.
331
+ * @hidden
332
+ */
333
+ export type DurableWaitForConditionNext<T = unknown> = DurableStepHandler<
334
+ [state: T, context: Pick<DurableStepAttemptContext, 'attempt'>],
335
+ DurableWaitForConditionDecision
336
+ >
313
337
 
314
338
  /**
315
339
  * The interface defining the operations available to a durable function.
@@ -317,17 +341,26 @@ export interface DurableWaitForConditionOptions<T> {
317
341
  * @alpha Using durables is considered experimental and may change in the future.
318
342
  * @hidden
319
343
  */
320
- export interface DurableOperations {
344
+ export type DurableOperations = {
321
345
  /**
322
346
  * Runs a named step. Its result is recorded, so if the workflow re-runs the step
323
347
  * is not executed again. Failures are retried on their own.
324
348
  * similar to ctx.step()
325
349
  * @remarks cannot be nested inside another step
350
+ * @example
351
+ * ```ts
352
+ * step.run({
353
+ * name: 'run-step',
354
+ * handler: async ({logger}) => {
355
+ * logger.log('Running step')
356
+ * }})
357
+ * ```
326
358
  * @param name - Step name
327
- * @param fn - function being executed
359
+ * @param handler - function being executed
328
360
  * @returns The value returned by the executed function
329
361
  */
330
- run<T>(name: string, fn: (args: BaseDurableOperationArgs) => T | Promise<T>): Promise<T>
362
+ run<T>({name, handler}: {name?: string; handler: DurableStepRunHandler<T>}): Promise<T>
363
+
331
364
  /**
332
365
  * Calls another function and awaits its result.
333
366
  * similar to ctx.invoke()
@@ -336,17 +369,17 @@ export interface DurableOperations {
336
369
  * @param input - Data passed to the called function
337
370
  * @returns The value returned by the called function
338
371
  */
339
- delegate<T>(name: string, input?: unknown): Promise<T>
372
+ delegate<T>({name, input}: {name?: string; input?: unknown}): Promise<T>
340
373
 
341
374
  /**
342
375
  * Waits for an external callback
343
376
  * similar to ctx.waitForCallback()
344
377
  * @remarks cannot be nested inside another step
345
378
  * @param name - Step name
346
- * @param fn - Receives the generated callbackId and returns a delivered promise
379
+ * @param handler - Receives the generated callbackId and returns a delivered promise
347
380
  * @returns The value returned by the executed function
348
381
  */
349
- waitForCallback<T>(name: string, fn: (callbackId: string, args: BaseDurableOperationArgs) => Promise<void>): Promise<T>
382
+ waitForCallback<T>({name, handler}: {name?: string; handler: DurableStepWaitForCallbackHandler}): Promise<T>
350
383
 
351
384
  /**
352
385
  * Waits for a specified duration
@@ -355,33 +388,18 @@ export interface DurableOperations {
355
388
  * @example
356
389
  * Wait for 30 seconds
357
390
  * ```ts
358
- * await step.wait('wait30Sec', { seconds: 30 });
391
+ * await step.wait({name: 'wait30Sec', duration: { seconds: 30 }});
359
392
  * ```
360
393
  * Wait for 2 days and 3 hours
361
394
  * ```ts
362
- * await step.wait('waitALongTime', { days: 2, hours: 3 });
395
+ * await step.wait({name: 'waitALongTime', duration: { days: 2, hours: 3 }});
363
396
  * ```
364
397
  * @param name - Step name
365
398
  * @param duration - Amount of time the function will wait before continuing.
366
399
  * Duration is an object with properties of `seconds`, `minutes`, `hours`, or `days`. Must be at least {seconds: 1}
367
400
  * @returns Resolves after the duration
368
401
  */
369
- wait(name: string, duration: DurableDuration): Promise<void>
370
-
371
- /**
372
- * Waits for a specified duration
373
- * similar to ctx.wait()
374
- * @remarks cannot be nested inside another step
375
- * @example
376
- * Wait for 30 seconds
377
- * ```ts
378
- * await step.wait({ seconds: 30 });
379
- * ```
380
- * @param duration - Amount of time the function will wait before continuing.
381
- * Duration is an object with properties of `seconds`, `minutes`, `hours`, or `days`. Must be at least {seconds: 1}
382
- * @returns Resolves after the duration
383
- */
384
- wait(duration: DurableDuration): Promise<void>
402
+ wait({name, duration}: {name?: string; duration: DurableDuration}): Promise<void>
385
403
 
386
404
  /**
387
405
  * Waits for a specified condition to be met
@@ -389,31 +407,28 @@ export interface DurableOperations {
389
407
  * @remarks cannot be nested inside another step
390
408
  * @example
391
409
  * ```ts
392
- * await step.waitForCondition(
393
- * 'waitForCondition',
394
- * async (state, {logger}) => {
395
- * logger.log('Checking for article')
396
- *
397
- * const client = createClient({
398
- * apiVersion: '2026-08-05',
399
- * ...context.clientOptions,
400
- * })
401
- * const article = await client.fetch<Article | null>(
402
- * '*[_type == "article"][0]',
403
- * )
404
- * return {...state, article}
405
- * },
406
- * {
410
+ * await step.waitForCondition({{
411
+ * name: 'waitForCondition',
407
412
  * initial: {
408
- * article: null as Article | null,
413
+ * article: null,
409
414
  * },
410
- * next: (state, context) => {
411
- * if (state.article) return {shouldContinue: false}
415
+ * poller: async (state, {attempt}) => {
416
+ * const client = createClient({
417
+ * apiVersion: '2026-08-05',
418
+ * ...context.clientOptions,
419
+ * })
420
+ * const article = await client.fetch<Article | null>(
421
+ * '*[_type == "article"][0]',
422
+ * )
423
+ * return {...state, article}
424
+ * }
425
+ * next: (state, {attempt}) => {
426
+ * if (state.article) return {shouldResume: false}
412
427
  *
413
428
  * return {
414
- * shouldContinue: true,
429
+ * shouldResume: true,
415
430
  * delay: {
416
- * seconds: Math.min((context.attempt ?? 1) * 2, 60),
431
+ * seconds: Math.min(attempt * 2, 60),
417
432
  * },
418
433
  * }
419
434
  * },
@@ -421,61 +436,24 @@ export interface DurableOperations {
421
436
  * )
422
437
  * ```
423
438
  * @param name - Step name
424
- * @param fn - Called on each attempt with the current state and durable context.
425
- * Returns a promise resolving to the updated state,
426
- * which is passed to next to determine whether the condition has been met or another check should be scheduled.
427
- * @param options - Configuration options for the condition
428
- * @returns The value returned by the executed function
429
- */
430
- waitForCondition<T>(
431
- name: string,
432
- fn: (state: T, args: BaseDurableOperationArgs) => Promise<T>,
433
- options: DurableWaitForConditionOptions<T>,
434
- ): Promise<T>
435
-
436
- /**
437
- * Waits for a specified condition to be met
438
- * similar to ctx.waitForCondition()
439
- * @remarks cannot be nested inside another step
440
- * @example
441
- * ```ts
442
- * await step.waitForCondition(
443
- * async (state, {logger}) => {
444
- * logger.log('Checking for article')
445
- *
446
- * const client = createClient({
447
- * apiVersion: '2026-08-05',
448
- * ...context.clientOptions,
449
- * })
450
- * const article = await client.fetch<Article | null>(
451
- * '*[_type == "article"][0]',
452
- * )
453
- * return {...state, article}
454
- * },
455
- * {
456
- * initial: {
457
- * article: null as Article | null,
458
- * },
459
- * next: (state, context) => {
460
- * if (state.article) return {shouldContinue: false}
461
- *
462
- * return {
463
- * shouldContinue: true,
464
- * delay: {
465
- * seconds: Math.min((context.attempt ?? 1) * 2, 60),
466
- * },
467
- * }
468
- * },
469
- * },
470
- * )
471
- * ```
472
- * @param fn - Called on each attempt with the current state and durable context.
439
+ * @param initial - Initial state passed to the first poller call.
440
+ * @param poller - Called on each attempt with the current state and condition context.
441
+ * @param next - A function that determines whether the condition has been met or another check should be run.
473
442
  * Returns a promise resolving to the updated state,
474
- * which is passed to next to determine whether the condition has been met or another check should be scheduled.
475
- * @param options - Configuration options for the condition
443
+ * which is passed to next to determine whether the condition has been met or another check should be run.
476
444
  * @returns The value returned by the executed function
477
445
  */
478
- waitForCondition<T>(fn: (state: T, args: BaseDurableOperationArgs) => Promise<T>, options: DurableWaitForConditionOptions<T>): Promise<T>
446
+ waitForCondition<T>({
447
+ name,
448
+ initial,
449
+ next,
450
+ poller,
451
+ }: {
452
+ name?: string
453
+ initial: T
454
+ poller: DurableWaitForConditionPoller<T>
455
+ next: DurableWaitForConditionNext<T>
456
+ }): Promise<T>
479
457
  }
480
458
 
481
459
  /**