@sanity/functions 1.7.0 → 1.7.2
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/definers.d.ts +1 -1
- package/dist/durables.d.ts +1 -1
- package/dist/invoke.d.ts +2 -2
- package/dist/types/context.d.ts +2 -2
- package/dist/types/durables.d.ts +8 -8
- package/dist/types/functions.d.ts +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/types.js +5 -5
- package/dist/types.js.map +1 -1
- package/package.json +6 -4
- package/src/definers.ts +1 -1
- package/src/durables.ts +1 -1
- package/src/invoke.ts +2 -2
- package/src/types/context.ts +2 -2
- package/src/types/durables.ts +8 -8
- package/src/types/functions.ts +1 -1
- package/src/types.ts +5 -5
package/dist/definers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DocumentEventHandler, PubSubEventHandler, ScheduledEventHandler, SyncTagInvalidateEventHandler } from './types/functions';
|
|
1
|
+
import type { DocumentEventHandler, PubSubEventHandler, ScheduledEventHandler, SyncTagInvalidateEventHandler } from './types/functions.js';
|
|
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.
|
package/dist/durables.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DurableHandler } from './types/durables';
|
|
1
|
+
import type { DurableHandler } from './types/durables.js';
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import type { FunctionPayload } from './types/functions';
|
|
2
|
-
import type { InvokeOptions } from './types/invocation';
|
|
1
|
+
import type { FunctionPayload } from './types/functions.js';
|
|
2
|
+
import type { InvokeOptions } from './types/invocation.js';
|
|
3
3
|
/** @internal */
|
|
4
4
|
export declare const MAX_RECURSION_COUNT = 16;
|
|
5
5
|
/**
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { InvokeCallback } from './invocation';
|
|
2
|
-
import type { ResourcesApi } from './resources';
|
|
1
|
+
import type { InvokeCallback } from './invocation.js';
|
|
2
|
+
import type { ResourcesApi } from './resources.js';
|
|
3
3
|
/**
|
|
4
4
|
* The context object passed to the function handler.
|
|
5
5
|
*/
|
package/dist/types/durables.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FunctionContext } from './context';
|
|
2
|
-
import type { GenericEvent } from './functions';
|
|
3
|
-
import type { BlueprintResource } from './resources';
|
|
1
|
+
import type { FunctionContext } from './context.js';
|
|
2
|
+
import type { GenericEvent } from './functions.js';
|
|
3
|
+
import type { BlueprintResource } from './resources.js';
|
|
4
4
|
/**
|
|
5
5
|
* Durable alias of FunctionsContext
|
|
6
6
|
* @alpha Using durables is considered experimental and may change in the future.
|
|
@@ -204,20 +204,20 @@ export type DurableOperations = {
|
|
|
204
204
|
* // my-durable-function/index.ts
|
|
205
205
|
* createDurable(({step, context}) => {
|
|
206
206
|
* // With a function name
|
|
207
|
-
* step.delegate({name: 'my-function', handler: 'my-delegated-function',
|
|
207
|
+
* step.delegate({name: 'my-function', handler: 'my-delegated-function', event: {data: {hello: 'world'}}})
|
|
208
208
|
* // With a resource object
|
|
209
|
-
* step.delegate({name: 'another-function', handler: context.resource.function('my-resource'),
|
|
209
|
+
* step.delegate({name: 'another-function', handler: context.resource.function('my-resource'), event: {data: {hello: 'world'}}})
|
|
210
210
|
* })
|
|
211
211
|
* ```
|
|
212
212
|
* @param name - Step name
|
|
213
213
|
* @param handler - Function to be invoked
|
|
214
|
-
* @param
|
|
214
|
+
* @param event - Data passed to the called function
|
|
215
215
|
* @returns The value returned by the called function
|
|
216
216
|
*/
|
|
217
|
-
delegate<T>({ name, handler,
|
|
217
|
+
delegate<T>({ name, handler, event, }: {
|
|
218
218
|
name?: string;
|
|
219
219
|
handler: string | BlueprintResource<`sanity.function.${string}`>;
|
|
220
|
-
|
|
220
|
+
event?: unknown;
|
|
221
221
|
}): Promise<T>;
|
|
222
222
|
/**
|
|
223
223
|
* Waits for an external callback
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionContext, GenericContext, ScheduledFunctionContext, SyncTagInvalidateContext } from './context';
|
|
1
|
+
import type { FunctionContext, GenericContext, ScheduledFunctionContext, SyncTagInvalidateContext } from './context.js';
|
|
2
2
|
/**
|
|
3
3
|
* The event object received by the function handler in the case of a document event,
|
|
4
4
|
* such as a publish, unpublish, delete or mutation event and similar.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './types/context';
|
|
2
|
-
export * from './types/durables';
|
|
3
|
-
export * from './types/functions';
|
|
4
|
-
export * from './types/invocation';
|
|
5
|
-
export * from './types/resources';
|
|
1
|
+
export * from './types/context.js';
|
|
2
|
+
export * from './types/durables.js';
|
|
3
|
+
export * from './types/functions.js';
|
|
4
|
+
export * from './types/invocation.js';
|
|
5
|
+
export * from './types/resources.js';
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './types/context';
|
|
2
|
-
export * from './types/durables';
|
|
3
|
-
export * from './types/functions';
|
|
4
|
-
export * from './types/invocation';
|
|
5
|
-
export * from './types/resources';
|
|
1
|
+
export * from './types/context.js';
|
|
2
|
+
export * from './types/durables.js';
|
|
3
|
+
export * from './types/functions.js';
|
|
4
|
+
export * from './types/invocation.js';
|
|
5
|
+
export * from './types/resources.js';
|
|
6
6
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/functions",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Helper methods and type definitions for Sanity Functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "rimraf dist .tsbuildinfo && tsc",
|
|
39
39
|
"coverage": "vitest --coverage",
|
|
40
|
-
"docs:typedoc": "typedoc --options typedoc.json",
|
|
40
|
+
"docs:typedoc": "npx -y -p typescript@6 -p typedoc@0.28.20 typedoc --options typedoc.json",
|
|
41
41
|
"docs:watch": "npm run docs:typedoc && open ./docs/html/index.html && npm run docs:typedoc -- --watch",
|
|
42
42
|
"lint": "biome check .",
|
|
43
43
|
"lint:write": "biome check --write .",
|
|
@@ -60,8 +60,7 @@
|
|
|
60
60
|
"@types/node": "^22",
|
|
61
61
|
"@vitest/coverage-v8": "4.1.10",
|
|
62
62
|
"rimraf": "^6.1.2",
|
|
63
|
-
"
|
|
64
|
-
"typescript": "^6.0.3",
|
|
63
|
+
"typescript": "^7.0.2",
|
|
65
64
|
"vitest": "4.1.10"
|
|
66
65
|
},
|
|
67
66
|
"engines": {
|
|
@@ -76,5 +75,8 @@
|
|
|
76
75
|
"@aws-lite/lambda": "^0.1.5",
|
|
77
76
|
"@aws-lite/sns": "^0.0.8",
|
|
78
77
|
"@aws-lite/sqs": "^0.2.4"
|
|
78
|
+
},
|
|
79
|
+
"allowScripts": {
|
|
80
|
+
"fsevents@2.3.3": true
|
|
79
81
|
}
|
|
80
82
|
}
|
package/src/definers.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {DocumentEventHandler, PubSubEventHandler, ScheduledEventHandler, SyncTagInvalidateEventHandler} from './types/functions'
|
|
1
|
+
import type {DocumentEventHandler, PubSubEventHandler, ScheduledEventHandler, SyncTagInvalidateEventHandler} from './types/functions.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Defines a "document event" function handler.
|
package/src/durables.ts
CHANGED
package/src/invoke.ts
CHANGED
|
@@ -2,8 +2,8 @@ import {Buffer} from 'node:buffer'
|
|
|
2
2
|
import crypto from 'node:crypto'
|
|
3
3
|
import {env} from 'node:process'
|
|
4
4
|
import type awsLite from '@aws-lite/client'
|
|
5
|
-
import type {FunctionPayload, FunctionResourceEnvelope} from './types/functions'
|
|
6
|
-
import type {InvokeOptions} from './types/invocation'
|
|
5
|
+
import type {FunctionPayload, FunctionResourceEnvelope} from './types/functions.js'
|
|
6
|
+
import type {InvokeOptions} from './types/invocation.js'
|
|
7
7
|
|
|
8
8
|
let awsPromise: Promise<awsLite.AwsLiteClient> | undefined
|
|
9
9
|
|
package/src/types/context.ts
CHANGED
package/src/types/durables.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {FunctionContext} from './context'
|
|
2
|
-
import type {GenericEvent} from './functions'
|
|
3
|
-
import type {BlueprintResource} from './resources'
|
|
1
|
+
import type {FunctionContext} from './context.js'
|
|
2
|
+
import type {GenericEvent} from './functions.js'
|
|
3
|
+
import type {BlueprintResource} from './resources.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Durable alias of FunctionsContext
|
|
@@ -201,24 +201,24 @@ export type DurableOperations = {
|
|
|
201
201
|
* // my-durable-function/index.ts
|
|
202
202
|
* createDurable(({step, context}) => {
|
|
203
203
|
* // With a function name
|
|
204
|
-
* step.delegate({name: 'my-function', handler: 'my-delegated-function',
|
|
204
|
+
* step.delegate({name: 'my-function', handler: 'my-delegated-function', event: {data: {hello: 'world'}}})
|
|
205
205
|
* // With a resource object
|
|
206
|
-
* step.delegate({name: 'another-function', handler: context.resource.function('my-resource'),
|
|
206
|
+
* step.delegate({name: 'another-function', handler: context.resource.function('my-resource'), event: {data: {hello: 'world'}}})
|
|
207
207
|
* })
|
|
208
208
|
* ```
|
|
209
209
|
* @param name - Step name
|
|
210
210
|
* @param handler - Function to be invoked
|
|
211
|
-
* @param
|
|
211
|
+
* @param event - Data passed to the called function
|
|
212
212
|
* @returns The value returned by the called function
|
|
213
213
|
*/
|
|
214
214
|
delegate<T>({
|
|
215
215
|
name,
|
|
216
216
|
handler,
|
|
217
|
-
|
|
217
|
+
event,
|
|
218
218
|
}: {
|
|
219
219
|
name?: string
|
|
220
220
|
handler: string | BlueprintResource<`sanity.function.${string}`>
|
|
221
|
-
|
|
221
|
+
event?: unknown
|
|
222
222
|
}): Promise<T>
|
|
223
223
|
|
|
224
224
|
/**
|
package/src/types/functions.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {FunctionContext, GenericContext, ScheduledFunctionContext, SyncTagInvalidateContext} from './context'
|
|
1
|
+
import type {FunctionContext, GenericContext, ScheduledFunctionContext, SyncTagInvalidateContext} from './context.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The event object received by the function handler in the case of a document event,
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './types/context'
|
|
2
|
-
export * from './types/durables'
|
|
3
|
-
export * from './types/functions'
|
|
4
|
-
export * from './types/invocation'
|
|
5
|
-
export * from './types/resources'
|
|
1
|
+
export * from './types/context.js'
|
|
2
|
+
export * from './types/durables.js'
|
|
3
|
+
export * from './types/functions.js'
|
|
4
|
+
export * from './types/invocation.js'
|
|
5
|
+
export * from './types/resources.js'
|