@sanity/functions 1.6.8 → 1.7.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.
@@ -1,4 +1,4 @@
1
- import type { DocumentEventHandler, PubSubEventHandler, ScheduledEventHandler, SyncTagInvalidateEventHandler } from './types.js';
1
+ import type { DocumentEventHandler, PubSubEventHandler, ScheduledEventHandler, SyncTagInvalidateEventHandler } from './types/functions';
2
2
  /**
3
3
  * Defines a "document event" function handler.
4
4
  * Returns the handler function as-is, only providing the types and doing basic validation.
@@ -1,4 +1,4 @@
1
- import type { DurableHandler } from './types';
1
+ import type { DurableHandler } from './types/durables';
2
2
  /**
3
3
  * Durables creation function that can be called with or without a config object.
4
4
  * @alpha Durables are an experimental feature and may change in the future.
package/dist/invoke.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { FunctionPayload, InvokeOptions } from './types.js';
1
+ import type { FunctionPayload } from './types/functions';
2
+ import type { InvokeOptions } from './types/invocation';
2
3
  /** @internal */
3
4
  export declare const MAX_RECURSION_COUNT = 16;
4
5
  /**
@@ -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,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;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"}
@@ -0,0 +1,107 @@
1
+ import type { InvokeCallback } from './invocation';
2
+ import type { ResourcesApi } from './resources';
3
+ /**
4
+ * The context object passed to the function handler.
5
+ */
6
+ export interface FunctionContext {
7
+ /** The resource type of the event source; resource type that invoked the function. */
8
+ eventResourceType: string;
9
+ /** The resource ID of the event source; resource ID that invoked the function. */
10
+ eventResourceId: string;
11
+ /** The resource type of the function container; resource type that houses the function. */
12
+ functionResourceType: string;
13
+ /** The resource ID of the function container; resource ID that houses the function. */
14
+ functionResourceId: string;
15
+ /** Sanity lineage token */
16
+ lineage?: string | undefined;
17
+ /**
18
+ * `local` is set to `true` when testing your function locally.
19
+ * i.e. `sanity function test func-name`
20
+ * Otherwise, the property is not set.
21
+ */
22
+ local?: boolean;
23
+ invoke?: InvokeCallback;
24
+ /**
25
+ * Options that can be passed to a `@sanity/client` constructor to configure it
26
+ * against the project and dataset which triggered the event. Note that you should
27
+ * always specify an explicit `apiVersion` in YYYY-MM-DD format (e.g. `2025-05-01`).
28
+ *
29
+ * @example
30
+ * Constructing a client with the options from the context:
31
+ * ```ts
32
+ * const client = createClient({
33
+ * apiVersion: '2025-05-01',
34
+ * ...context.clientOptions,
35
+ * })
36
+ * ```
37
+ */
38
+ clientOptions: {
39
+ apiHost?: string;
40
+ dataset: string;
41
+ projectId: string;
42
+ token: string;
43
+ };
44
+ /** Resource interface that allows access to Blueprint Resources */
45
+ resources: ResourcesApi;
46
+ }
47
+ /**
48
+ * The context object passed to the schedule function handler.
49
+ */
50
+ export interface ScheduledFunctionContext {
51
+ /** Sanity lineage token */
52
+ lineage?: string | undefined;
53
+ /**
54
+ * `local` is set to `true` when testing your function locally.
55
+ * i.e. `sanity function test func-name`
56
+ * Otherwise, the property is not set.
57
+ */
58
+ local?: boolean;
59
+ invoke?: InvokeCallback;
60
+ /**
61
+ * Options that can be passed to a `@sanity/client` constructor to configure it
62
+ * against the project and dataset which triggered the event. Note that you should
63
+ * always specify an explicit `apiVersion` in YYYY-MM-DD format (e.g. `2025-05-01`).
64
+ *
65
+ * @example
66
+ * Constructing a client with the options from the context:
67
+ * ```ts
68
+ * const client = createClient({
69
+ * apiVersion: '2025-05-01',
70
+ * ...context.clientOptions,
71
+ * })
72
+ * ```
73
+ */
74
+ clientOptions?: {
75
+ apiHost?: string;
76
+ dataset?: string;
77
+ projectId?: string;
78
+ token?: string;
79
+ };
80
+ /** Resource interface that allows access to Blueprint Resources */
81
+ resources: ResourcesApi;
82
+ }
83
+ /**
84
+ * The context object passed to the sync tag invalidate event handler.
85
+ */
86
+ export interface SyncTagInvalidateContext extends Omit<FunctionContext, 'clientOptions'> {
87
+ /**
88
+ * A short-lived token that should be used to notify Sanity of sync tag invalidation routine completion. Recommended to use the `done` helper argument provided to the sync tag invalidate event handler instead of this token directly.
89
+ */
90
+ callbackToken: string;
91
+ clientOptions: {
92
+ apiHost: string;
93
+ dataset: string;
94
+ projectId: string;
95
+ /**
96
+ * An API token for use with the Sanity HTTP API. Note that it may be undefined if the user does not explicitly assign a Robot Token to their function definition.
97
+ * @see https://www.sanity.io/docs/blueprints/blueprints-robot-tokens#k8a2a6a24a5c0
98
+ */
99
+ token?: string;
100
+ };
101
+ /** Resource interface that allows access to Blueprint Resources */
102
+ resources: ResourcesApi;
103
+ }
104
+ /**
105
+ * A generic function context type which supports all function types
106
+ */
107
+ export type GenericContext = FunctionContext | ScheduledFunctionContext | SyncTagInvalidateContext;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,315 @@
1
+ import type { FunctionContext } from './context';
2
+ import type { GenericEvent } from './functions';
3
+ import type { BlueprintResource } from './resources';
4
+ /**
5
+ * Durable alias of FunctionsContext
6
+ * @alpha Using durables is considered experimental and may change in the future.
7
+ * @hidden
8
+ */
9
+ export type DurableContext = FunctionContext;
10
+ /**
11
+ * Logger interface for durables.
12
+ * @alpha Using durables is considered experimental and may change in the future.
13
+ * @hidden
14
+ */
15
+ export interface DurableLogger {
16
+ debug(...params: unknown[]): void;
17
+ info(...params: unknown[]): void;
18
+ warn(...params: unknown[]): void;
19
+ error(...params: unknown[]): void;
20
+ log(...params: unknown[]): void;
21
+ }
22
+ /**
23
+ * @alpha Using durables is considered experimental and may change in the future.
24
+ * @hidden
25
+ */
26
+ export interface DurableStepCallbackContext {
27
+ logger: DurableLogger;
28
+ }
29
+ /**
30
+ * Arguments passed to callbacks that execute a durable attempt.
31
+ * step.run & step.waitForCondition
32
+ * @alpha Using durables is considered experimental and may change in the future.
33
+ * @hidden
34
+ */
35
+ export interface DurableStepAttemptContext extends DurableStepCallbackContext {
36
+ /** Current attempt number, starting at 1. */
37
+ attempt: number;
38
+ }
39
+ /**
40
+ * The signature of the duration object passed to the `wait` method of a durable function.
41
+ * It can be specified in days, hours, minutes, or seconds.
42
+ * @alpha Using durables is considered experimental and may change in the future.
43
+ * @hidden
44
+ */
45
+ export type DurableDuration = {
46
+ days: number;
47
+ hours?: number;
48
+ minutes?: number;
49
+ seconds?: number;
50
+ } | {
51
+ hours: number;
52
+ minutes?: number;
53
+ seconds?: number;
54
+ } | {
55
+ minutes: number;
56
+ seconds?: number;
57
+ } | {
58
+ seconds: number;
59
+ };
60
+ /**
61
+ * @alpha: Using durables is considered experimental and may change in the future.
62
+ * @hidden
63
+ */
64
+ export type DurableJitterStrategy = 'none' | 'full' | 'half';
65
+ /**
66
+ * @alpha: Using durables is considered experimental and may change in the future.
67
+ * @hidden
68
+ */
69
+ export interface DurableRetryStrategy {
70
+ maxAttempts?: number;
71
+ initialDelay?: DurableDuration;
72
+ maxDelay?: DurableDuration;
73
+ backoffRate?: number;
74
+ jitter?: DurableJitterStrategy;
75
+ retryableErrors?: (string | RegExp)[];
76
+ retryableErrorTypes?: (new () => Error)[];
77
+ }
78
+ /**
79
+ * @alpha: Using durables is considered experimental and may change in the future.
80
+ * @hidden
81
+ */
82
+ export type DurableStepSemantics = 'at-most-once-per-retry' | 'at-least-once-per-retry';
83
+ /**
84
+ * @alpha: Using durables is considered experimental and may change in the future.
85
+ * @hidden
86
+ */
87
+ export interface DurableStepConfig {
88
+ strategy?: DurableRetryStrategy;
89
+ semantics?: DurableStepSemantics;
90
+ }
91
+ /**
92
+ * Allowed operations in a retry code block
93
+ * @alpha: Using durables is considered experimental and may change in the future.
94
+ * @hidden
95
+ */
96
+ export type DurableRetryOperations = Pick<DurableOperations, 'delegate' | 'waitForCallback' | 'waitForCondition'>;
97
+ /**
98
+ * @alpha: Using durables is considered experimental and may change in the future.
99
+ * @hidden
100
+ */
101
+ export type DurableRetryBlock<T> = (envelope: {
102
+ step: DurableRetryOperations;
103
+ attempt: number;
104
+ }) => Promise<T>;
105
+ /**
106
+ * @alpha: Using durables is considered experimental and may change in the future.
107
+ * @hidden
108
+ */
109
+ export type DurableRetry = <T>(name: string | undefined, config: DurableRetryStrategy, block: DurableRetryBlock<T>) => Promise<T>;
110
+ /**
111
+ * @alpha Using durables is considered experimental and may change in the future.
112
+ * @hidden
113
+ */
114
+ export type DurableWaitForConditionDecision = {
115
+ shouldRetry: true;
116
+ delay: DurableDuration;
117
+ } | {
118
+ shouldRetry: false;
119
+ };
120
+ /**
121
+ * @alpha Using durables is considered experimental and may change in the future.
122
+ * @hidden
123
+ */
124
+ export type DurableStepHandler<TArgs extends unknown[], TReturn> = (...args: TArgs) => TReturn;
125
+ /**
126
+ * @alpha Using durables is considered experimental and may change in the future.
127
+ * @hidden
128
+ */
129
+ export type DurableStepRunHandler<T = unknown> = DurableStepHandler<[context: DurableStepAttemptContext], T | Promise<T>>;
130
+ /**
131
+ * @alpha Using durables is considered experimental and may change in the future.
132
+ * @hidden
133
+ */
134
+ export type DurableStepWaitForCallbackHandler = DurableStepHandler<[callbackId: string, context: DurableStepCallbackContext], Promise<void>>;
135
+ /**
136
+ * @alpha Using durables is considered experimental and may change in the future.
137
+ * @hidden
138
+ */
139
+ export type DurableWaitForConditionPoller<T = unknown> = DurableStepHandler<[state: T, context: DurableStepAttemptContext], Promise<T>>;
140
+ /**
141
+ * @alpha Using durables is considered experimental and may change in the future.
142
+ * @hidden
143
+ */
144
+ export type DurableWaitForConditionNext<T = unknown> = DurableStepHandler<[
145
+ state: T,
146
+ context: Pick<DurableStepAttemptContext, 'attempt'>
147
+ ], DurableWaitForConditionDecision>;
148
+ /**
149
+ * The interface defining the operations available to a durable function.
150
+ * These operations are steps that delegate to other functions, and wait for external callbacks.
151
+ * @alpha Using durables is considered experimental and may change in the future.
152
+ * @hidden
153
+ */
154
+ export type DurableOperations = {
155
+ /**
156
+ * Runs a named step. Its result is recorded, so if the workflow re-runs the step
157
+ * is not executed again. Failures are retried on their own.
158
+ * similar to ctx.step()
159
+ * @remarks cannot be nested inside another step
160
+ * @example
161
+ * ```ts
162
+ * step.run({
163
+ * name: 'run-step',
164
+ * handler: async ({logger}) => {
165
+ * logger.log('Running step')
166
+ * }})
167
+ * ```
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * // With a retry config
172
+ * step.run({
173
+ * name: 'run-with-retry'
174
+ * handler: () => { // handler code }
175
+ * retry: { strategy: { maxAttempts: 2 } }
176
+ * })
177
+ * ```
178
+ * @param name - Step name
179
+ * @param handler - function being executed
180
+ * @param retry - retry configuration
181
+ * @returns The value returned by the executed function
182
+ */
183
+ run<T>({ name, handler, retry }: {
184
+ name?: string;
185
+ handler: DurableStepRunHandler<T>;
186
+ retry?: DurableStepConfig;
187
+ }): Promise<T>;
188
+ /**
189
+ * Calls another function and awaits its result.
190
+ * similar to ctx.invoke()
191
+ * @remarks cannot be nested inside another step
192
+ * @example
193
+ * ```ts
194
+ * // my-delegated-function/index.ts
195
+ * export const handler = pubSubEventHandler({event}) => {
196
+ * ...
197
+ * }
198
+ *
199
+ * // my-resource/index.ts
200
+ * export const handler = pubSubEventHandler({event}) => {
201
+ * ...
202
+ * }
203
+ *
204
+ * // my-durable-function/index.ts
205
+ * createDurable(({step, context}) => {
206
+ * // With a function name
207
+ * step.delegate({name: 'my-function', handler: 'my-delegated-function', input: {}})
208
+ * // With a resource object
209
+ * step.delegate({name: 'another-function', handler: context.resource.function('my-resource'), input: {}})
210
+ * })
211
+ * ```
212
+ * @param name - Step name
213
+ * @param handler - Function to be invoked
214
+ * @param input - Data passed to the called function
215
+ * @returns The value returned by the called function
216
+ */
217
+ delegate<T>({ name, handler, input, }: {
218
+ name?: string;
219
+ handler: string | BlueprintResource<`sanity.function.${string}`>;
220
+ input?: unknown;
221
+ }): Promise<T>;
222
+ /**
223
+ * Waits for an external callback
224
+ * similar to ctx.waitForCallback()
225
+ * @remarks cannot be nested inside another step
226
+ * @param name - Step name
227
+ * @param handler - Receives the generated callbackId and returns a delivered promise
228
+ * @returns The value returned by the executed function
229
+ */
230
+ waitForCallback<T>({ name, handler }: {
231
+ name?: string;
232
+ handler: DurableStepWaitForCallbackHandler;
233
+ }): Promise<T>;
234
+ /**
235
+ * Waits for a specified duration
236
+ * similar to ctx.wait()
237
+ * @remarks cannot be nested inside another step
238
+ * @example
239
+ * Wait for 30 seconds
240
+ * ```ts
241
+ * await step.wait({name: 'wait30Sec', duration: { seconds: 30 }});
242
+ * ```
243
+ * Wait for 2 days and 3 hours
244
+ * ```ts
245
+ * await step.wait({name: 'waitALongTime', duration: { days: 2, hours: 3 }});
246
+ * ```
247
+ * @param name - Step name
248
+ * @param duration - Amount of time the function will wait before continuing.
249
+ * Duration is an object with properties of `seconds`, `minutes`, `hours`, or `days`. Must be at least {seconds: 1}
250
+ * @returns Resolves after the duration
251
+ */
252
+ wait({ name, duration }: {
253
+ name?: string;
254
+ duration: DurableDuration;
255
+ }): Promise<void>;
256
+ /**
257
+ * Waits for a specified condition to be met
258
+ * similar to ctx.waitForCondition()
259
+ * @remarks cannot be nested inside another step
260
+ * @example
261
+ * ```ts
262
+ * await step.waitForCondition({{
263
+ * name: 'waitForCondition',
264
+ * initial: {
265
+ * article: null,
266
+ * },
267
+ * poller: async (state, {attempt}) => {
268
+ * const client = createClient({
269
+ * apiVersion: '2026-08-05',
270
+ * ...context.clientOptions,
271
+ * })
272
+ * const article = await client.fetch<Article | null>(
273
+ * '*[_type == "article"][0]',
274
+ * )
275
+ * return {...state, article}
276
+ * }
277
+ * next: (state, {attempt}) => {
278
+ * if (state.article) return {shouldRetry: false}
279
+ *
280
+ * return {
281
+ * shouldRetry: true,
282
+ * delay: {
283
+ * seconds: Math.min(attempt * 2, 60),
284
+ * },
285
+ * }
286
+ * },
287
+ * },
288
+ * )
289
+ * ```
290
+ * @param name - Step name
291
+ * @param initial - Initial state passed to the first poller call.
292
+ * @param poller - Called on each attempt with the current state and condition context.
293
+ * @param next - A function that determines whether the condition has been met or another check should be run.
294
+ * Returns a promise resolving to the updated state,
295
+ * which is passed to next to determine whether the condition has been met or another check should be run.
296
+ * @returns The value returned by the executed function
297
+ */
298
+ waitForCondition<T>({ name, initial, next, poller, }: {
299
+ name?: string;
300
+ initial: T;
301
+ poller: DurableWaitForConditionPoller<T>;
302
+ next: DurableWaitForConditionNext<T>;
303
+ }): Promise<T>;
304
+ };
305
+ /**
306
+ * @alpha Using durables is considered experimental and may change in the future.
307
+ * @hidden
308
+ */
309
+ export type DurableHandler = (envelope: {
310
+ context: DurableContext;
311
+ event?: GenericEvent;
312
+ step: DurableOperations;
313
+ logger: DurableLogger;
314
+ retry: DurableRetry;
315
+ }) => unknown | Promise<unknown>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=durables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durables.js","sourceRoot":"","sources":["../../src/types/durables.ts"],"names":[],"mappings":""}
@@ -0,0 +1,100 @@
1
+ import type { FunctionContext, GenericContext, ScheduledFunctionContext, SyncTagInvalidateContext } from './context';
2
+ /**
3
+ * The event object received by the function handler in the case of a document event,
4
+ * such as a publish, unpublish, delete or mutation event and similar.
5
+ */
6
+ export interface DocumentEvent<IData = any> {
7
+ /**
8
+ * The data delivered to the function. This is the result of applying any configured
9
+ * GROQ-projection to the changed document. If no projection is configured, this is
10
+ * the document itself.
11
+ */
12
+ data: IData;
13
+ }
14
+ /**
15
+ * The event object received by the function handler in the case of a sync-tag-invalidate event.
16
+ */
17
+ export interface SyncTagInvalidateEvent {
18
+ /**
19
+ * The sync tags for use with cache invalidation and notifying the callback endpoint once tags are invalidated.
20
+ */
21
+ data: {
22
+ /** Array of sync tags to be invalidated. */
23
+ syncTags: string[];
24
+ };
25
+ }
26
+ /**
27
+ * A function handler for a document event.
28
+ */
29
+ export type DocumentEventHandler<IData = any> = (envelope: {
30
+ context: FunctionContext;
31
+ event: DocumentEvent<IData>;
32
+ }) => void | Promise<void>;
33
+ /**
34
+ * A function handler for a schedule event.
35
+ */
36
+ export type ScheduledEventHandler = (envelope: {
37
+ context: ScheduledFunctionContext;
38
+ }) => void | Promise<void>;
39
+ /**
40
+ * A generic function event type which supports all function types
41
+ */
42
+ export type GenericEvent = DocumentEvent | SyncTagInvalidateEvent;
43
+ /**
44
+ * A function handler for a pubsub event.
45
+ *
46
+ * A pubsub function can be triggered by any event source, so the envelope is intentionally
47
+ * permissive and needs no narrowing: `context` is any supported context, `event` is any
48
+ * supported event, and `done` is optional (present only for sync-tag-invalidate events).
49
+ *
50
+ * `IResult` is the value the handler resolves to and defaults to `void`. Pubsub is the one
51
+ * function type that may be invoked with {@link invoke | `invoke(name, payload, {sync: true})`},
52
+ * which returns the handler's resolved value to the caller.
53
+ */
54
+ export type PubSubEventHandler<IData = any, IResult = void> = (envelope: {
55
+ context: GenericContext;
56
+ event: DocumentEvent<IData> | SyncTagInvalidateEvent;
57
+ done?: SyncTagInvalidateCallback;
58
+ }) => IResult | Promise<IResult>;
59
+ /**
60
+ * A generic function handler that can receive the payload of any function type.
61
+ *
62
+ * @deprecated Renamed to {@link PubSubEventHandler}. This alias will be removed in the next
63
+ * major version.
64
+ */
65
+ export type EventHandler<IData = any, IResult = void> = PubSubEventHandler<IData, IResult>;
66
+ /**
67
+ * A callback function to invoke once a sync-tag-invalidate event has been processed. Signals to Sanity that sync tag invalidation has completed.
68
+ */
69
+ export type SyncTagInvalidateCallback = (syncTags: string[]) => Promise<Response>;
70
+ /**
71
+ * A function handler for a sync-tag-invalidate event.
72
+ */
73
+ export type SyncTagInvalidateEventHandler = (envelope: {
74
+ context: SyncTagInvalidateContext;
75
+ event: SyncTagInvalidateEvent;
76
+ done: SyncTagInvalidateCallback;
77
+ }) => void | Promise<void>;
78
+ /**
79
+ * The payload for the `invoke` method
80
+ */
81
+ export type FunctionPayload = {
82
+ event: GenericEvent;
83
+ context: GenericContext;
84
+ };
85
+ /**
86
+ * The definition of a function resource in our resource discovery table
87
+ */
88
+ export type FunctionResource = {
89
+ logicalResourceId: string;
90
+ physicalResourceId: string;
91
+ };
92
+ type FunctionResourceKey = 'eventsourcemapping' | 'function' | 'parameter' | 'queue' | 'schedule' | 'subscription' | 'topic';
93
+ export type FunctionResourceEnvelope = {
94
+ [K in FunctionResourceKey]-?: {
95
+ [P in K]: FunctionResource;
96
+ } & {
97
+ [P in Exclude<FunctionResourceKey, K>]?: FunctionResource;
98
+ };
99
+ }[FunctionResourceKey];
100
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../src/types/functions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Callback provided by Sanity CLI when doing local development.
3
+ *
4
+ * The CLI receives the event data alone: it delivers it to the target function as
5
+ * `event.data` and derives the target's context from the calling function's own context.
6
+ */
7
+ export type InvokeCallback = <T = unknown>(name: string, payload?: Record<string, unknown>, options?: InvokeOptions) => Promise<T>;
8
+ /**
9
+ * Options provided to invoke
10
+ */
11
+ export type InvokeOptions = {
12
+ sync?: boolean;
13
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation.js","sourceRoot":"","sources":["../../src/types/invocation.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * An interface to describe resources found in a Blueprint
3
+ */
4
+ export interface BlueprintResource<TType extends string = string> {
5
+ id: string;
6
+ name: string;
7
+ type: TType;
8
+ }
9
+ export interface ResourcesApi {
10
+ /** Cross-type lookup by name: `context.resources('my-proj')`. */
11
+ (name: string): BlueprintResource | undefined;
12
+ /** Flat array of every resource across types. */
13
+ all(): BlueprintResource[];
14
+ /** Iterate every resource: `for (const r of context.resources)`. */
15
+ [Symbol.iterator](): IterableIterator<BlueprintResource>;
16
+ /** Type specific lookup by name: `context.cors('my-cors')` */
17
+ cors(name: string): BlueprintResource | undefined;
18
+ dataset(name: string): BlueprintResource | undefined;
19
+ function(name: string): BlueprintResource<`sanity.function.${string}`> | undefined;
20
+ project(name: string): BlueprintResource | undefined;
21
+ role(name: string): BlueprintResource | undefined;
22
+ webhook(name: string): BlueprintResource | undefined;
23
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/types/resources.ts"],"names":[],"mappings":""}