@sanity/functions 1.6.8 → 1.6.9
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.d.ts +6 -4
- package/package.json +1 -1
- package/src/types.ts +14 -4
package/dist/types.d.ts
CHANGED
|
@@ -195,10 +195,10 @@ export type SyncTagInvalidateEventHandler = (envelope: {
|
|
|
195
195
|
/**
|
|
196
196
|
* An interface to describe resources found in a Blueprint
|
|
197
197
|
*/
|
|
198
|
-
export interface BlueprintResource {
|
|
198
|
+
export interface BlueprintResource<TType extends string = string> {
|
|
199
199
|
id: string;
|
|
200
200
|
name: string;
|
|
201
|
-
type:
|
|
201
|
+
type: TType;
|
|
202
202
|
}
|
|
203
203
|
export interface ResourcesApi {
|
|
204
204
|
/** Cross-type lookup by name: `context.resources('my-proj')`. */
|
|
@@ -210,7 +210,7 @@ export interface ResourcesApi {
|
|
|
210
210
|
/** Type specific lookup by name: `context.cors('my-cors')` */
|
|
211
211
|
cors(name: string): BlueprintResource | undefined;
|
|
212
212
|
dataset(name: string): BlueprintResource | undefined;
|
|
213
|
-
function(name: string): BlueprintResource | undefined;
|
|
213
|
+
function(name: string): BlueprintResource<`sanity.function.${string}`> | undefined;
|
|
214
214
|
project(name: string): BlueprintResource | undefined;
|
|
215
215
|
role(name: string): BlueprintResource | undefined;
|
|
216
216
|
webhook(name: string): BlueprintResource | undefined;
|
|
@@ -364,11 +364,13 @@ export type DurableOperations = {
|
|
|
364
364
|
* similar to ctx.invoke()
|
|
365
365
|
* @remarks cannot be nested inside another step
|
|
366
366
|
* @param name - Step name
|
|
367
|
+
* @param handler - Function to be invoked
|
|
367
368
|
* @param input - Data passed to the called function
|
|
368
369
|
* @returns The value returned by the called function
|
|
369
370
|
*/
|
|
370
|
-
delegate<T>({ name, input }: {
|
|
371
|
+
delegate<T>({ name, handler, input, }: {
|
|
371
372
|
name?: string;
|
|
373
|
+
handler: string | BlueprintResource<`sanity.function.${string}`>;
|
|
372
374
|
input?: unknown;
|
|
373
375
|
}): Promise<T>;
|
|
374
376
|
/**
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -205,11 +205,12 @@ export type SyncTagInvalidateEventHandler = (envelope: {
|
|
|
205
205
|
/**
|
|
206
206
|
* An interface to describe resources found in a Blueprint
|
|
207
207
|
*/
|
|
208
|
-
export interface BlueprintResource {
|
|
208
|
+
export interface BlueprintResource<TType extends string = string> {
|
|
209
209
|
id: string
|
|
210
210
|
name: string
|
|
211
|
-
type:
|
|
211
|
+
type: TType
|
|
212
212
|
}
|
|
213
|
+
|
|
213
214
|
export interface ResourcesApi {
|
|
214
215
|
/** Cross-type lookup by name: `context.resources('my-proj')`. */
|
|
215
216
|
(name: string): BlueprintResource | undefined
|
|
@@ -220,7 +221,7 @@ export interface ResourcesApi {
|
|
|
220
221
|
/** Type specific lookup by name: `context.cors('my-cors')` */
|
|
221
222
|
cors(name: string): BlueprintResource | undefined
|
|
222
223
|
dataset(name: string): BlueprintResource | undefined
|
|
223
|
-
function(name: string): BlueprintResource | undefined
|
|
224
|
+
function(name: string): BlueprintResource<`sanity.function.${string}`> | undefined
|
|
224
225
|
project(name: string): BlueprintResource | undefined
|
|
225
226
|
role(name: string): BlueprintResource | undefined
|
|
226
227
|
webhook(name: string): BlueprintResource | undefined
|
|
@@ -369,10 +370,19 @@ export type DurableOperations = {
|
|
|
369
370
|
* similar to ctx.invoke()
|
|
370
371
|
* @remarks cannot be nested inside another step
|
|
371
372
|
* @param name - Step name
|
|
373
|
+
* @param handler - Function to be invoked
|
|
372
374
|
* @param input - Data passed to the called function
|
|
373
375
|
* @returns The value returned by the called function
|
|
374
376
|
*/
|
|
375
|
-
delegate<T>({
|
|
377
|
+
delegate<T>({
|
|
378
|
+
name,
|
|
379
|
+
handler,
|
|
380
|
+
input,
|
|
381
|
+
}: {
|
|
382
|
+
name?: string
|
|
383
|
+
handler: string | BlueprintResource<`sanity.function.${string}`>
|
|
384
|
+
input?: unknown
|
|
385
|
+
}): Promise<T>
|
|
376
386
|
|
|
377
387
|
/**
|
|
378
388
|
* Waits for an external callback
|