@sanity/functions 1.9.0 → 1.10.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/dist/types/durables.d.ts +26 -8
- package/package.json +2 -2
- package/src/types/durables.ts +34 -7
package/dist/types/durables.d.ts
CHANGED
|
@@ -45,6 +45,14 @@ export interface DurableTopLevelContext extends DurableStepContext {
|
|
|
45
45
|
context: DurableContext;
|
|
46
46
|
event?: GenericEvent;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Context parameter passed to the `waitForCallback` submitter method.
|
|
50
|
+
* @alpha Using durables is considered experimental and may change in the future.
|
|
51
|
+
* @hidden
|
|
52
|
+
*/
|
|
53
|
+
export interface DurableCallbackSubmitterContext extends DurableStepCallbackContext {
|
|
54
|
+
callbackId: string;
|
|
55
|
+
}
|
|
48
56
|
/**
|
|
49
57
|
* Arguments passed to callbacks that execute a durable attempt.
|
|
50
58
|
* step.run & step.waitForCondition
|
|
@@ -113,7 +121,7 @@ export type DurableStepFanoutHandler<T = unknown> = DurableStepHandler<[context:
|
|
|
113
121
|
* @alpha Using durables is considered experimental and may change in the future.
|
|
114
122
|
* @hidden
|
|
115
123
|
*/
|
|
116
|
-
export type
|
|
124
|
+
export type DurableStepWaitForCallbackSubmitter = DurableStepHandler<[context: DurableCallbackSubmitterContext], Promise<void>>;
|
|
117
125
|
/**
|
|
118
126
|
* @alpha Using durables is considered experimental and may change in the future.
|
|
119
127
|
* @hidden
|
|
@@ -355,16 +363,26 @@ export type DurableOperations = {
|
|
|
355
363
|
retry?: DurableRetryStrategy;
|
|
356
364
|
}): Promise<T>;
|
|
357
365
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
366
|
+
* Generates a unique callback ID, runs a handler to pass the ID to an external system and waits for some external system to POST JSON data to a Sanity Durable callback API.
|
|
367
|
+
* @example
|
|
368
|
+
* Wait for 30 seconds
|
|
369
|
+
* ```ts
|
|
370
|
+
* await step.waitForCallback({name: 'ask-for-permission', submitter: async ({callbackId}) => {
|
|
371
|
+
* await sendForApproval(callbackId)
|
|
372
|
+
* }});
|
|
373
|
+
* ```
|
|
374
|
+
* ```
|
|
361
375
|
* @param name - Step name
|
|
362
|
-
* @param
|
|
363
|
-
* @
|
|
376
|
+
* @param submitter - Function that submits the provided callbackId parameter to an external system
|
|
377
|
+
* @param timeout - Maximum time to wait for the callback result
|
|
378
|
+
* @param retry - retry configuration for the submitter function
|
|
379
|
+
* @returns The value returned to the Sanity Durable callback HTTP API
|
|
364
380
|
*/
|
|
365
|
-
waitForCallback<T>({ name,
|
|
381
|
+
waitForCallback<T>({ name, submitter, timeout, retry, }: {
|
|
366
382
|
name?: string;
|
|
367
|
-
|
|
383
|
+
submitter: DurableStepWaitForCallbackSubmitter;
|
|
384
|
+
timeout?: DurableDuration;
|
|
385
|
+
retry?: DurableRetryStrategy;
|
|
368
386
|
}): Promise<T>;
|
|
369
387
|
/**
|
|
370
388
|
* Waits for a specified duration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/functions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Helper methods and type definitions for Sanity Functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typecheck": "tsc --noEmit --project tsconfig.test.json"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@aws-lite/client": "^0.
|
|
50
|
+
"@aws-lite/client": "^0.24.1",
|
|
51
51
|
"@aws-lite/dynamodb": "^0.3.9",
|
|
52
52
|
"@aws-lite/dynamodb-types": "^0.3.12",
|
|
53
53
|
"@aws-lite/lambda": "^0.1.5",
|
package/src/types/durables.ts
CHANGED
|
@@ -50,6 +50,15 @@ export interface DurableTopLevelContext extends DurableStepContext {
|
|
|
50
50
|
event?: GenericEvent
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Context parameter passed to the `waitForCallback` submitter method.
|
|
55
|
+
* @alpha Using durables is considered experimental and may change in the future.
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
export interface DurableCallbackSubmitterContext extends DurableStepCallbackContext {
|
|
59
|
+
callbackId: string
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
/**
|
|
54
63
|
* Arguments passed to callbacks that execute a durable attempt.
|
|
55
64
|
* step.run & step.waitForCondition
|
|
@@ -111,7 +120,7 @@ export type DurableStepFanoutHandler<T = unknown> = DurableStepHandler<[context:
|
|
|
111
120
|
* @alpha Using durables is considered experimental and may change in the future.
|
|
112
121
|
* @hidden
|
|
113
122
|
*/
|
|
114
|
-
export type
|
|
123
|
+
export type DurableStepWaitForCallbackSubmitter = DurableStepHandler<[context: DurableCallbackSubmitterContext], Promise<void>>
|
|
115
124
|
|
|
116
125
|
/**
|
|
117
126
|
* @alpha Using durables is considered experimental and may change in the future.
|
|
@@ -371,14 +380,32 @@ export type DurableOperations = {
|
|
|
371
380
|
}): Promise<T>
|
|
372
381
|
|
|
373
382
|
/**
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
383
|
+
* Generates a unique callback ID, runs a handler to pass the ID to an external system and waits for some external system to POST JSON data to a Sanity Durable callback API.
|
|
384
|
+
* @example
|
|
385
|
+
* Wait for 30 seconds
|
|
386
|
+
* ```ts
|
|
387
|
+
* await step.waitForCallback({name: 'ask-for-permission', submitter: async ({callbackId}) => {
|
|
388
|
+
* await sendForApproval(callbackId)
|
|
389
|
+
* }});
|
|
390
|
+
* ```
|
|
391
|
+
* ```
|
|
377
392
|
* @param name - Step name
|
|
378
|
-
* @param
|
|
379
|
-
* @
|
|
393
|
+
* @param submitter - Function that submits the provided callbackId parameter to an external system
|
|
394
|
+
* @param timeout - Maximum time to wait for the callback result
|
|
395
|
+
* @param retry - retry configuration for the submitter function
|
|
396
|
+
* @returns The value returned to the Sanity Durable callback HTTP API
|
|
380
397
|
*/
|
|
381
|
-
waitForCallback<T>({
|
|
398
|
+
waitForCallback<T>({
|
|
399
|
+
name,
|
|
400
|
+
submitter,
|
|
401
|
+
timeout,
|
|
402
|
+
retry,
|
|
403
|
+
}: {
|
|
404
|
+
name?: string
|
|
405
|
+
submitter: DurableStepWaitForCallbackSubmitter
|
|
406
|
+
timeout?: DurableDuration
|
|
407
|
+
retry?: DurableRetryStrategy
|
|
408
|
+
}): Promise<T>
|
|
382
409
|
|
|
383
410
|
/**
|
|
384
411
|
* Waits for a specified duration
|