@sanity/blueprints 0.34.0 → 0.35.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/definers/agents.d.ts +3 -1
- package/dist/definers/agents.js +3 -1
- package/dist/definers/agents.js.map +1 -1
- package/dist/definers/applications.d.ts +30 -18
- package/dist/definers/applications.js +30 -18
- package/dist/definers/applications.js.map +1 -1
- package/dist/definers/blueprints.d.ts +1 -0
- package/dist/definers/blueprints.js +1 -25
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/context.d.ts +6 -2
- package/dist/definers/context.js +6 -2
- package/dist/definers/context.js.map +1 -1
- package/dist/definers/cors.d.ts +11 -1
- package/dist/definers/cors.js +10 -12
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +12 -2
- package/dist/definers/datasets.js +11 -14
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions/document.d.ts +30 -0
- package/dist/definers/functions/document.js.map +1 -1
- package/dist/definers/functions/durable.d.ts +4 -3
- package/dist/definers/functions/durable.js +4 -3
- package/dist/definers/functions/durable.js.map +1 -1
- package/dist/definers/functions/media-library.d.ts +31 -0
- package/dist/definers/functions/media-library.js +18 -19
- package/dist/definers/functions/media-library.js.map +1 -1
- package/dist/definers/functions/pubsub.d.ts +2 -3
- package/dist/definers/functions/pubsub.js +2 -3
- package/dist/definers/functions/pubsub.js.map +1 -1
- package/dist/definers/functions/queue.d.ts +15 -4
- package/dist/definers/functions/queue.js +19 -6
- package/dist/definers/functions/queue.js.map +1 -1
- package/dist/definers/functions/scheduled.d.ts +7 -6
- package/dist/definers/functions/scheduled.js +7 -6
- package/dist/definers/functions/scheduled.js.map +1 -1
- package/dist/definers/functions/sync-tag-invalidate.d.ts +5 -2
- package/dist/definers/functions/sync-tag-invalidate.js +5 -2
- package/dist/definers/functions/sync-tag-invalidate.js.map +1 -1
- package/dist/definers/installation-config.d.ts +4 -2
- package/dist/definers/installation-config.js +4 -2
- package/dist/definers/installation-config.js.map +1 -1
- package/dist/definers/permissions.d.ts +8 -2
- package/dist/definers/permissions.js +8 -2
- package/dist/definers/permissions.js.map +1 -1
- package/dist/definers/projects.d.ts +3 -4
- package/dist/definers/projects.js +3 -4
- package/dist/definers/projects.js.map +1 -1
- package/dist/definers/resources.d.ts +1 -0
- package/dist/definers/resources.js +1 -11
- package/dist/definers/resources.js.map +1 -1
- package/dist/definers/robotTokens.d.ts +22 -3
- package/dist/definers/robotTokens.js +17 -18
- package/dist/definers/robotTokens.js.map +1 -1
- package/dist/definers/roles.d.ts +53 -5
- package/dist/definers/roles.js +38 -40
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/studios.d.ts +5 -3
- package/dist/definers/studios.js +5 -3
- package/dist/definers/studios.js.map +1 -1
- package/dist/definers/webhooks.d.ts +19 -1
- package/dist/definers/webhooks.js +15 -17
- package/dist/definers/webhooks.js.map +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.js +19 -20
- package/dist/index.js.map +1 -1
- package/dist/resolve/index.d.ts +2 -3
- package/dist/resolve/index.js +2 -3
- package/dist/resolve/index.js.map +1 -1
- package/dist/types/agents.d.ts +7 -3
- package/dist/types/applications.d.ts +67 -49
- package/dist/types/applications.js +9 -6
- package/dist/types/applications.js.map +1 -1
- package/dist/types/context.d.ts +17 -7
- package/dist/types/cors.d.ts +0 -2
- package/dist/types/datasets.d.ts +0 -6
- package/dist/types/functions/index.d.ts +64 -14
- package/dist/types/functions/index.js +2 -1
- package/dist/types/functions/index.js.map +1 -1
- package/dist/types/installation-config.d.ts +13 -10
- package/dist/types/permissions.d.ts +8 -4
- package/dist/types/projects.d.ts +5 -4
- package/dist/types/robotTokens.d.ts +0 -3
- package/dist/types/roles.d.ts +0 -4
- package/dist/types/studios.d.ts +28 -15
- package/dist/types/studios.js +3 -2
- package/dist/types/studios.js.map +1 -1
- package/dist/types/webhooks.d.ts +0 -3
- package/dist/utils/debounce.d.ts +0 -11
- package/dist/utils/debounce.js +0 -22
- package/dist/utils/debounce.js.map +1 -1
- package/dist/utils/parse-duration.d.ts +13 -0
- package/dist/utils/parse-duration.js +24 -0
- package/dist/utils/parse-duration.js.map +1 -1
- package/dist/utils/throttle.d.ts +9 -0
- package/dist/utils/throttle.js +22 -0
- package/dist/utils/throttle.js.map +1 -0
- package/dist/validation/applications.js +7 -2
- package/dist/validation/applications.js.map +1 -1
- package/dist/validation/functions.d.ts +10 -0
- package/dist/validation/functions.js +112 -12
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/projects.js +3 -0
- package/dist/validation/projects.js.map +1 -1
- package/dist/validation/studios.js +4 -5
- package/dist/validation/studios.js.map +1 -1
- package/package.json +1 -1
- package/src/definers/agents.ts +3 -1
- package/src/definers/applications.ts +30 -18
- package/src/definers/blueprints.ts +1 -25
- package/src/definers/context.ts +6 -2
- package/src/definers/cors.ts +10 -12
- package/src/definers/datasets.ts +11 -14
- package/src/definers/functions/document.ts +17 -24
- package/src/definers/functions/durable.ts +4 -3
- package/src/definers/functions/media-library.ts +18 -19
- package/src/definers/functions/pubsub.ts +2 -3
- package/src/definers/functions/queue.ts +19 -6
- package/src/definers/functions/scheduled.ts +7 -6
- package/src/definers/functions/sync-tag-invalidate.ts +5 -2
- package/src/definers/installation-config.ts +4 -2
- package/src/definers/permissions.ts +8 -2
- package/src/definers/projects.ts +3 -4
- package/src/definers/resources.ts +1 -11
- package/src/definers/robotTokens.ts +17 -18
- package/src/definers/roles.ts +38 -40
- package/src/definers/studios.ts +5 -3
- package/src/definers/webhooks.ts +15 -17
- package/src/index.ts +20 -21
- package/src/resolve/index.ts +2 -4
- package/src/types/agents.ts +7 -3
- package/src/types/applications.ts +67 -49
- package/src/types/context.ts +17 -7
- package/src/types/cors.ts +0 -2
- package/src/types/datasets.ts +0 -6
- package/src/types/functions/index.ts +67 -14
- package/src/types/installation-config.ts +13 -10
- package/src/types/permissions.ts +8 -4
- package/src/types/projects.ts +6 -4
- package/src/types/robotTokens.ts +0 -3
- package/src/types/roles.ts +0 -4
- package/src/types/studios.ts +28 -16
- package/src/types/webhooks.ts +0 -3
- package/src/utils/debounce.ts +0 -25
- package/src/utils/parse-duration.ts +27 -0
- package/src/utils/throttle.ts +25 -0
- package/src/validation/applications.ts +6 -2
- package/src/validation/functions.ts +123 -12
- package/src/validation/projects.ts +4 -0
- package/src/validation/studios.ts +3 -6
|
@@ -1,34 +1,10 @@
|
|
|
1
1
|
import {type Blueprint, type BlueprintModule, type BlueprintsApiConfig, validateBlueprint} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
-
/*
|
|
5
|
-
* FUTURE example (move below @example when ready)
|
|
6
|
-
* @example With deployment API config
|
|
7
|
-
* ```ts
|
|
8
|
-
* defineBlueprint({
|
|
9
|
-
* resources: [
|
|
10
|
-
* defineCorsOrigin({
|
|
11
|
-
* name: 'cors-localhost',
|
|
12
|
-
* origin: 'http://localhost:3333'
|
|
13
|
-
* }),
|
|
14
|
-
* defineRole({
|
|
15
|
-
* name: 'role-ci',
|
|
16
|
-
* title: 'CI Role',
|
|
17
|
-
* appliesToRobots: true,
|
|
18
|
-
* permissions: []
|
|
19
|
-
* }),
|
|
20
|
-
* defineRobotToken({
|
|
21
|
-
* name: 'ci-robot',
|
|
22
|
-
* memberships: [{
|
|
23
|
-
* roleNames: ['$.resources.ci-role']}],
|
|
24
|
-
* }),
|
|
25
|
-
* ],
|
|
26
|
-
* })
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
4
|
/**
|
|
30
5
|
* Define a Blueprint to manage Sanity resources
|
|
31
6
|
*
|
|
7
|
+
* @example
|
|
32
8
|
* ```ts
|
|
33
9
|
* defineBlueprint({
|
|
34
10
|
* resources: [
|
package/src/definers/context.ts
CHANGED
|
@@ -11,6 +11,8 @@ import {runValidation} from '../utils/validation.js'
|
|
|
11
11
|
/**
|
|
12
12
|
* Defines a Context knowledge base.
|
|
13
13
|
*
|
|
14
|
+
* Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
15
|
+
*
|
|
14
16
|
* @remarks
|
|
15
17
|
* The blueprint must be scoped to an organization. A new knowledge base has no sources. Add sources in the Context API
|
|
16
18
|
* or the dashboard.
|
|
@@ -41,7 +43,7 @@ import {runValidation} from '../utils/validation.js'
|
|
|
41
43
|
* ```
|
|
42
44
|
* @param parameters The knowledge base configuration
|
|
43
45
|
* @public
|
|
44
|
-
* @beta
|
|
46
|
+
* @beta
|
|
45
47
|
* @category Definers
|
|
46
48
|
* @expandType BlueprintContextKnowledgeBaseConfig
|
|
47
49
|
* @returns The knowledge base resource
|
|
@@ -60,6 +62,8 @@ export function defineContextKnowledgeBase(parameters: BlueprintContextKnowledge
|
|
|
60
62
|
/**
|
|
61
63
|
* Defines a Context MCP endpoint that agents connect to.
|
|
62
64
|
*
|
|
65
|
+
* Deploying Context via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
66
|
+
*
|
|
63
67
|
* @remarks
|
|
64
68
|
* The blueprint must be scoped to an organization.
|
|
65
69
|
*
|
|
@@ -99,7 +103,7 @@ export function defineContextKnowledgeBase(parameters: BlueprintContextKnowledge
|
|
|
99
103
|
* ```
|
|
100
104
|
* @param parameters The MCP endpoint configuration
|
|
101
105
|
* @public
|
|
102
|
-
* @beta
|
|
106
|
+
* @beta
|
|
103
107
|
* @category Definers
|
|
104
108
|
* @expandType BlueprintContextMcpEndpointConfig
|
|
105
109
|
* @returns The MCP endpoint resource
|
package/src/definers/cors.ts
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import {type BlueprintCorsOriginConfig, type BlueprintCorsOriginResource, validateCorsOrigin} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
/**
|
|
5
|
+
* Defines a CORS Origin to be managed in a Blueprint.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
7
8
|
* ```ts
|
|
8
9
|
* defineCorsOrigin({
|
|
9
|
-
* name: '
|
|
10
|
-
* origin: 'https://
|
|
10
|
+
* name: 'my-cors-origin',
|
|
11
|
+
* origin: 'https://mydomain.com',
|
|
11
12
|
* allowCredentials: true,
|
|
12
|
-
* project: 'my-project-id',
|
|
13
13
|
* })
|
|
14
14
|
* ```
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Defines a CORS Origin to be managed in a Blueprint.
|
|
18
15
|
*
|
|
16
|
+
* @example All options
|
|
19
17
|
* ```ts
|
|
20
18
|
* defineCorsOrigin({
|
|
21
|
-
* name: '
|
|
22
|
-
* origin: 'https://
|
|
19
|
+
* name: 'studio-cors',
|
|
20
|
+
* origin: 'https://my-studio.sanity.studio',
|
|
23
21
|
* allowCredentials: true,
|
|
22
|
+
* project: 'my-project-id',
|
|
24
23
|
* })
|
|
25
24
|
* ```
|
|
26
25
|
* @param parameters The CORS Origin configuration
|
|
27
26
|
* @public
|
|
28
|
-
* @beta Deploying CORS Origins via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
29
27
|
* @category Definers
|
|
30
28
|
* @expandType BlueprintCorsOriginConfig
|
|
31
29
|
* @returns The CORS Origin resource
|
package/src/definers/datasets.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import {type BlueprintDatasetConfig, type BlueprintDatasetResource, validateDataset} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
*
|
|
4
|
+
/**
|
|
5
|
+
* Defines a Dataset to be managed in a Blueprint.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* defineDataset({
|
|
10
|
+
* name: 'staging-dataset',
|
|
11
|
+
* datasetName: 'staging',
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
6
15
|
* @example All options
|
|
7
16
|
* ```ts
|
|
8
17
|
* defineDataset({
|
|
@@ -13,20 +22,8 @@ import {runValidation} from '../utils/validation.js'
|
|
|
13
22
|
* lifecycle: {deletionPolicy: 'protect'},
|
|
14
23
|
* })
|
|
15
24
|
* ```
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Defines a Dataset to be managed in a Blueprint.
|
|
19
|
-
*
|
|
20
|
-
* ```ts
|
|
21
|
-
* defineDataset({
|
|
22
|
-
* name: 'staging-dataset',
|
|
23
|
-
* datasetName: 'staging',
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
25
|
* @param parameters The dataset configuration
|
|
27
26
|
* @public
|
|
28
|
-
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
29
|
-
* @hidden
|
|
30
27
|
* @category Definers
|
|
31
28
|
* @expandType BlueprintDatasetConfig
|
|
32
29
|
* @returns The dataset resource
|
|
@@ -11,21 +11,29 @@ import {defineFunction} from './index.js'
|
|
|
11
11
|
type DocumentFunctionEventKey = keyof BlueprintDocumentFunctionResourceEvent
|
|
12
12
|
const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersions', 'resource', ...BASE_EVENT_KEYS.values()])
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
/**
|
|
15
|
+
* Defines a function that is triggered by document events in Sanity datasets.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
17
18
|
* ```ts
|
|
18
|
-
*
|
|
19
|
-
* name: '
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* defineDocumentFunction({
|
|
20
|
+
* name: 'my-document-function',
|
|
21
|
+
* event: {
|
|
22
|
+
* on: ['create', 'update'],
|
|
23
|
+
* filter: "_type == 'post'",
|
|
24
|
+
* projection: "{_id, title, slug}",
|
|
25
|
+
* },
|
|
23
26
|
* })
|
|
27
|
+
* ```
|
|
24
28
|
*
|
|
29
|
+
* @example With robot token reference
|
|
30
|
+
* ```ts
|
|
25
31
|
* defineRobotToken({
|
|
26
32
|
* name: 'fn-robot',
|
|
27
33
|
* memberships: [{
|
|
28
|
-
*
|
|
34
|
+
* resourceType: 'project',
|
|
35
|
+
* resourceId: 'my-project-id',
|
|
36
|
+
* roleNames: ['editor'],
|
|
29
37
|
* }],
|
|
30
38
|
* })
|
|
31
39
|
*
|
|
@@ -43,21 +51,6 @@ const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersio
|
|
|
43
51
|
* },
|
|
44
52
|
* env: {
|
|
45
53
|
* EXTERNAL_API_URL: 'https://api.example.com',
|
|
46
|
-
* SUPER_SECRET: process.env.SUPER_SECRET,
|
|
47
|
-
* },
|
|
48
|
-
* })
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* Defines a function that is triggered by document events in Sanity datasets.
|
|
53
|
-
*
|
|
54
|
-
* ```ts
|
|
55
|
-
* defineDocumentFunction({
|
|
56
|
-
* name: 'my-document-function',
|
|
57
|
-
* event: {
|
|
58
|
-
* on: ['create', 'update'],
|
|
59
|
-
* filter: "_type == 'post'",
|
|
60
|
-
* projection: "{_id, title, slug}",
|
|
61
54
|
* },
|
|
62
55
|
* })
|
|
63
56
|
* ```
|
|
@@ -6,8 +6,9 @@ import {defineFunction} from './index.js'
|
|
|
6
6
|
/**
|
|
7
7
|
* Defines a durable function resource.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Deploying Durable Functions via Blueprints is experimental.
|
|
10
10
|
*
|
|
11
|
+
* @example
|
|
11
12
|
* ```ts
|
|
12
13
|
* defineDurableFunction({
|
|
13
14
|
* name: 'daily-cleanup',
|
|
@@ -16,9 +17,9 @@ import {defineFunction} from './index.js'
|
|
|
16
17
|
* ```
|
|
17
18
|
*
|
|
18
19
|
* @param functionConfig The configuration for the function
|
|
19
|
-
* @category Definers
|
|
20
|
-
* @beta Deploying Durable Functions via Blueprints is experimental.
|
|
21
20
|
* @public
|
|
21
|
+
* @beta
|
|
22
|
+
* @category Definers
|
|
22
23
|
* @expandType BlueprintDurableConfig
|
|
23
24
|
* @returns The validated durable function resource
|
|
24
25
|
*/
|
|
@@ -10,15 +10,30 @@ import {defineFunction} from './index.js'
|
|
|
10
10
|
|
|
11
11
|
type MediaLibraryFunctionEventKey = keyof BlueprintMediaLibraryFunctionResourceEvent
|
|
12
12
|
const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resource', ...BASE_EVENT_KEYS.values()])
|
|
13
|
-
|
|
14
|
-
*
|
|
13
|
+
/**
|
|
14
|
+
* Defines a function that is triggered by media library events.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* defineMediaLibraryAssetFunction({
|
|
19
|
+
* name: 'my-media-library-function',
|
|
20
|
+
* event: {
|
|
21
|
+
* on: ['create'],
|
|
22
|
+
* resource: {
|
|
23
|
+
* type: 'media-library',
|
|
24
|
+
* id: 'my-media-library-id',
|
|
25
|
+
* },
|
|
26
|
+
* },
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
15
30
|
* @example With robot token reference
|
|
16
31
|
* ```ts
|
|
17
32
|
* defineRobotToken({
|
|
18
33
|
* name: 'media-robot',
|
|
19
34
|
* memberships: [{
|
|
20
35
|
* resourceType: 'project',
|
|
21
|
-
* resourceId:
|
|
36
|
+
* resourceId: 'my-project-id',
|
|
22
37
|
* roleNames: ['editor'],
|
|
23
38
|
* }],
|
|
24
39
|
* })
|
|
@@ -41,22 +56,6 @@ const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resourc
|
|
|
41
56
|
* },
|
|
42
57
|
* })
|
|
43
58
|
* ```
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* Defines a function that is triggered by media library events.
|
|
47
|
-
*
|
|
48
|
-
* ```ts
|
|
49
|
-
* defineMediaLibraryAssetFunction({
|
|
50
|
-
* name: 'my-media-library-function',
|
|
51
|
-
* event: {
|
|
52
|
-
* on: ['create'],
|
|
53
|
-
* resource: {
|
|
54
|
-
* type: 'media-library',
|
|
55
|
-
* id: 'my-media-library-id',
|
|
56
|
-
* },
|
|
57
|
-
* },
|
|
58
|
-
* })
|
|
59
|
-
* ```
|
|
60
59
|
* @param functionConfig The configuration for the media library asset function
|
|
61
60
|
* @public
|
|
62
61
|
* @category Definers
|
|
@@ -3,10 +3,9 @@ import {runValidation} from '../../utils/validation.js'
|
|
|
3
3
|
import {defineFunction} from './index.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Defines a function that
|
|
6
|
+
* Defines a function that provides pubsub behaviour.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
9
|
-
* A barebones pubsub function
|
|
8
|
+
* @example
|
|
10
9
|
* ```ts
|
|
11
10
|
* definePubSubFunction({
|
|
12
11
|
* name: 'send-email',
|
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
import {type BlueprintQueueFunctionConfig, type BlueprintQueueFunctionResource, validateQueueFunction} from '../../index.js'
|
|
2
2
|
import {createDebounceObject} from '../../utils/debounce.js'
|
|
3
|
+
import {createThrottleObject} from '../../utils/throttle.js'
|
|
3
4
|
import {runValidation} from '../../utils/validation.js'
|
|
4
5
|
import {defineFunction} from './index.js'
|
|
5
6
|
/**
|
|
6
7
|
* Defines a function that provide queueing behaviour.
|
|
7
8
|
*
|
|
9
|
+
* Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
10
|
+
*
|
|
8
11
|
* @remarks
|
|
9
|
-
* Using the reasonable defaults of concurrency: 1
|
|
12
|
+
* Using the reasonable defaults of concurrency: 1 and fifo: true.
|
|
13
|
+
* Without `maxAttempts`, a failing message is redelivered until the queue's retention period expires.
|
|
10
14
|
* ```ts
|
|
11
15
|
* defineQueueFunction({
|
|
12
16
|
* name: 'send-email',
|
|
13
17
|
* })
|
|
14
18
|
* ```
|
|
15
19
|
*
|
|
16
|
-
* Specifying a concurrency of 5
|
|
20
|
+
* Specifying a concurrency of 5, and giving up on a message after 3 attempts
|
|
17
21
|
* ```ts
|
|
18
22
|
* defineQueueFunction({
|
|
19
23
|
* name: 'bustin-caches',
|
|
20
24
|
* concurrency: 5,
|
|
21
25
|
* fifo: true,
|
|
22
|
-
*
|
|
26
|
+
* maxAttempts: 3,
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Starting at most 100 messages per minute, paced per tenant, with bursts of up to 10
|
|
31
|
+
* ```ts
|
|
32
|
+
* defineQueueFunction({
|
|
33
|
+
* name: 'call-rate-limited-api',
|
|
34
|
+
* throttle: {limit: 100, period: '1 minute', burst: 10, key: 'event.data.tenantId'},
|
|
23
35
|
* })
|
|
24
36
|
* ```
|
|
25
37
|
* @public
|
|
26
|
-
* @alpha
|
|
38
|
+
* @alpha
|
|
27
39
|
* @hidden
|
|
28
40
|
* @category Definers
|
|
29
41
|
* @expandType BlueprintQueueFunctionConfig
|
|
@@ -31,16 +43,17 @@ import {defineFunction} from './index.js'
|
|
|
31
43
|
* @returns The validated queue function resource
|
|
32
44
|
*/
|
|
33
45
|
export function defineQueueFunction(functionConfig: BlueprintQueueFunctionConfig): BlueprintQueueFunctionResource {
|
|
34
|
-
const {concurrency = 1, fifo = true,
|
|
46
|
+
const {concurrency = 1, fifo = true, debounce, event, maxAttempts, throttle} = functionConfig
|
|
35
47
|
|
|
36
48
|
const functionResource: BlueprintQueueFunctionResource = {
|
|
37
49
|
...defineFunction(functionConfig, {skipValidation: true}),
|
|
38
50
|
type: 'sanity.function.queue',
|
|
39
51
|
...(concurrency !== undefined && {concurrency}),
|
|
40
52
|
...(debounce !== undefined && {debounce: createDebounceObject(debounce)}),
|
|
41
|
-
...(dlq !== undefined && {dlq}),
|
|
42
53
|
...(event !== undefined && {event}),
|
|
43
54
|
...(fifo !== undefined && {fifo}),
|
|
55
|
+
...(maxAttempts !== undefined && {maxAttempts}),
|
|
56
|
+
...(throttle !== undefined && {throttle: createThrottleObject(throttle)}),
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
runValidation(() => validateQueueFunction(functionResource))
|
|
@@ -21,7 +21,11 @@ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour
|
|
|
21
21
|
* Supports cron expressions or natural language schedules.
|
|
22
22
|
*
|
|
23
23
|
* @remarks
|
|
24
|
-
*
|
|
24
|
+
* The `event.expression` field accepts standard cron expressions or natural language:
|
|
25
|
+
* `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
|
|
26
|
+
* `'mon, wed, fri at 9am'`, `'first of the month at noon'`
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
25
29
|
* ```ts
|
|
26
30
|
* defineScheduledFunction({
|
|
27
31
|
* name: 'daily-cleanup',
|
|
@@ -29,7 +33,7 @@ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour
|
|
|
29
33
|
* })
|
|
30
34
|
* ```
|
|
31
35
|
*
|
|
32
|
-
*
|
|
36
|
+
* @example Explicit cron fields
|
|
33
37
|
* ```ts
|
|
34
38
|
* defineScheduledFunction({
|
|
35
39
|
* name: 'daily-cleanup',
|
|
@@ -37,10 +41,7 @@ const SCHEDULED_EVENT_KEYS = new Set<ScheduledFunctionEventKey>(['minute', 'hour
|
|
|
37
41
|
* })
|
|
38
42
|
* ```
|
|
39
43
|
*
|
|
40
|
-
*
|
|
41
|
-
* `'every 15 minutes'`, `'weekdays at 8am'`, `'fridays in the evening'`,
|
|
42
|
-
* `'mon, wed, fri at 9am'`, `'first of the month at noon'`
|
|
43
|
-
*
|
|
44
|
+
* @example Natural language schedule
|
|
44
45
|
* ```ts
|
|
45
46
|
* defineScheduledFunction({
|
|
46
47
|
* name: 'daily-cleanup',
|
|
@@ -9,14 +9,17 @@ import {defineFunction} from './index.js'
|
|
|
9
9
|
* Defines a function that is triggered on a sync tag invalidate event.
|
|
10
10
|
*
|
|
11
11
|
* @remarks
|
|
12
|
-
*
|
|
12
|
+
* By default, the event covers all datasets in the function project.
|
|
13
|
+
* Set `event.resource` to scope the event to one dataset.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
13
16
|
* ```ts
|
|
14
17
|
* defineSyncTagInvalidateFunction({
|
|
15
18
|
* name: 'bustin-caches',
|
|
16
19
|
* })
|
|
17
20
|
* ```
|
|
18
21
|
*
|
|
19
|
-
*
|
|
22
|
+
* @example Scoped to one dataset
|
|
20
23
|
* ```ts
|
|
21
24
|
* defineSyncTagInvalidateFunction({
|
|
22
25
|
* name: 'bustin-caches',
|
|
@@ -4,12 +4,15 @@ import {runValidation} from '../utils/validation.js'
|
|
|
4
4
|
/**
|
|
5
5
|
* Defines a singleton Media Library configuration.
|
|
6
6
|
*
|
|
7
|
+
* Configuring the Media Library via Blueprints is experimental. This may be subject to breaking changes.
|
|
8
|
+
*
|
|
7
9
|
* @remarks
|
|
8
10
|
* The Media Library is a Sanity-owned singleton, so this resource carries no
|
|
9
11
|
* application identity of its own — only the config `root` and its `fields`.
|
|
10
12
|
* The provider resolves the organization's media library installation id at
|
|
11
13
|
* deploy time.
|
|
12
14
|
*
|
|
15
|
+
* @example
|
|
13
16
|
* ```ts
|
|
14
17
|
* defineMediaLibraryConfig({
|
|
15
18
|
* name: 'media-library',
|
|
@@ -19,11 +22,10 @@ import {runValidation} from '../utils/validation.js'
|
|
|
19
22
|
* ```
|
|
20
23
|
* @param config The Media Library configuration
|
|
21
24
|
* @public
|
|
22
|
-
* @beta
|
|
25
|
+
* @beta
|
|
23
26
|
* @category Definers
|
|
24
27
|
* @expandType BlueprintMediaLibraryConfigConfig
|
|
25
28
|
* @returns The Media Library configuration resource
|
|
26
|
-
* @hidden
|
|
27
29
|
*/
|
|
28
30
|
export function defineMediaLibraryConfig(config: BlueprintMediaLibraryConfigConfig): BlueprintMediaLibraryConfigResource {
|
|
29
31
|
const resource = {
|
|
@@ -10,6 +10,9 @@ import {runValidation} from '../utils/validation.js'
|
|
|
10
10
|
/**
|
|
11
11
|
* Defines a custom permission that roles can grant, in the shape of the Access API.
|
|
12
12
|
*
|
|
13
|
+
* Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
13
16
|
* ```ts
|
|
14
17
|
* definePermission({
|
|
15
18
|
* name: 'articles-only',
|
|
@@ -42,7 +45,7 @@ import {runValidation} from '../utils/validation.js'
|
|
|
42
45
|
* ```
|
|
43
46
|
* @param parameters The configuration of the permission
|
|
44
47
|
* @public
|
|
45
|
-
* @beta
|
|
48
|
+
* @beta
|
|
46
49
|
* @category Definers
|
|
47
50
|
* @expandType BlueprintPermissionConfig
|
|
48
51
|
* @returns The permission resource
|
|
@@ -61,6 +64,9 @@ export function definePermission(parameters: BlueprintPermissionConfig): Bluepri
|
|
|
61
64
|
/**
|
|
62
65
|
* Defines a content resource as the Manage UI makes it: a custom permission of type `sanity.document.filter.mode`.
|
|
63
66
|
*
|
|
67
|
+
* Deploying Permissions via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
64
70
|
* ```ts
|
|
65
71
|
* defineContentResource({
|
|
66
72
|
* name: 'movies',
|
|
@@ -81,7 +87,7 @@ export function definePermission(parameters: BlueprintPermissionConfig): Bluepri
|
|
|
81
87
|
* ```
|
|
82
88
|
* @param parameters The configuration of the content resource
|
|
83
89
|
* @public
|
|
84
|
-
* @beta
|
|
90
|
+
* @beta
|
|
85
91
|
* @category Definers
|
|
86
92
|
* @expandType BlueprintContentResourceConfig
|
|
87
93
|
* @returns The permission resource
|
package/src/definers/projects.ts
CHANGED
|
@@ -11,19 +11,19 @@ import {runValidation} from '../utils/validation.js'
|
|
|
11
11
|
/**
|
|
12
12
|
* Defines a project.
|
|
13
13
|
*
|
|
14
|
+
* @example
|
|
14
15
|
* ```ts
|
|
15
16
|
* defineProject({
|
|
16
17
|
* name: 'my-project',
|
|
17
18
|
* displayName: 'My Project',
|
|
19
|
+
* logo: './logo.png',
|
|
18
20
|
* })
|
|
19
21
|
* ```
|
|
20
22
|
* @param parameters The project configuration
|
|
21
23
|
* @public
|
|
22
|
-
* @beta Deploying Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
23
24
|
* @category Definers
|
|
24
25
|
* @expandType BlueprintProjectConfig
|
|
25
26
|
* @returns The project resource
|
|
26
|
-
* @hidden
|
|
27
27
|
*/
|
|
28
28
|
export function defineProject(parameters: BlueprintProjectConfig): BlueprintProjectResource {
|
|
29
29
|
// default project name
|
|
@@ -43,6 +43,7 @@ export function defineProject(parameters: BlueprintProjectConfig): BlueprintProj
|
|
|
43
43
|
/**
|
|
44
44
|
* Creates a reference to a project in another stack.
|
|
45
45
|
*
|
|
46
|
+
* @example
|
|
46
47
|
* ```ts
|
|
47
48
|
* referenceProject({
|
|
48
49
|
* name: 'editorial-project',
|
|
@@ -52,10 +53,8 @@ export function defineProject(parameters: BlueprintProjectConfig): BlueprintProj
|
|
|
52
53
|
*
|
|
53
54
|
* @param params The parameters for referencing the project
|
|
54
55
|
* @public
|
|
55
|
-
* @beta Referencing Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
56
56
|
* @category Referencers
|
|
57
57
|
* @returns The project reference
|
|
58
|
-
* @hidden
|
|
59
58
|
*/
|
|
60
59
|
export function referenceProject({name, stack, localName}: BlueprintCrossStackReferenceConfig): BlueprintResource {
|
|
61
60
|
return referenceResource({name, stack, localName, type: 'sanity.project'})
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import {assertResource, type BlueprintCrossStackReferenceResourceConfig, type BlueprintResource} from '../index.js'
|
|
2
2
|
|
|
3
|
-
/*
|
|
4
|
-
* FUTURE example (move below @example when ready)
|
|
5
|
-
* @example With lifecycle
|
|
6
|
-
* ```ts
|
|
7
|
-
* defineResource({
|
|
8
|
-
* name: 'my-resource',
|
|
9
|
-
* type: 'sanity.new.resource',
|
|
10
|
-
* lifecycle: {deletionPolicy: 'retain'},
|
|
11
|
-
* })
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
3
|
/**
|
|
15
4
|
* Defines a generic resource to be managed in Blueprints.
|
|
16
5
|
*
|
|
17
6
|
* @remarks
|
|
18
7
|
* This is useful if the resource type does not yet have a `define*` function.
|
|
19
8
|
*
|
|
9
|
+
* @example
|
|
20
10
|
* ```ts
|
|
21
11
|
* defineResource({
|
|
22
12
|
* name: 'my-resource',
|
|
@@ -8,14 +8,28 @@ import {
|
|
|
8
8
|
} from '../index.js'
|
|
9
9
|
import {runValidation} from '../utils/validation.js'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
*
|
|
11
|
+
/**
|
|
12
|
+
* Defines a Robot Token for automated access. Has a token property provided during deployment that can be referenced by other resources.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* defineRobotToken({
|
|
17
|
+
* name: 'my-robot',
|
|
18
|
+
* memberships: [{
|
|
19
|
+
* resourceType: 'project',
|
|
20
|
+
* resourceId: 'my-project-id',
|
|
21
|
+
* roleNames: ['editor'],
|
|
22
|
+
* }],
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
13
26
|
* @example Cross-resource references
|
|
14
27
|
* ```ts
|
|
15
28
|
* defineRole({
|
|
16
29
|
* name: 'ci-deploy-role',
|
|
17
30
|
* title: 'CI Deploy Role',
|
|
18
31
|
* appliesToRobots: true,
|
|
32
|
+
* appliesToUsers: false,
|
|
19
33
|
* permissions: [{name: 'sanity-project-cors', action: 'create'}],
|
|
20
34
|
* })
|
|
21
35
|
*
|
|
@@ -27,23 +41,8 @@ import {runValidation} from '../utils/validation.js'
|
|
|
27
41
|
* }],
|
|
28
42
|
* })
|
|
29
43
|
* ```
|
|
30
|
-
*/
|
|
31
|
-
/**
|
|
32
|
-
* Defines a Robot Token for automated access. Has a token property provided during deployment that can be referenced by other resources.
|
|
33
|
-
*
|
|
34
|
-
* ```ts
|
|
35
|
-
* defineRobotToken({
|
|
36
|
-
* name: 'my-robot',
|
|
37
|
-
* memberships: [{
|
|
38
|
-
* resourceType: 'project',
|
|
39
|
-
* resourceId: projectId,
|
|
40
|
-
* roleNames: ['editor'],
|
|
41
|
-
* }],
|
|
42
|
-
* })
|
|
43
|
-
* ```
|
|
44
44
|
* @param parameters The robot token configuration
|
|
45
45
|
* @public
|
|
46
|
-
* @beta Deploying Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
47
46
|
* @category Definers
|
|
48
47
|
* @expandType BlueprintRobotTokenConfig
|
|
49
48
|
* @returns The robot token resource
|
|
@@ -65,6 +64,7 @@ export function defineRobotToken(parameters: BlueprintRobotTokenConfig): Bluepri
|
|
|
65
64
|
/**
|
|
66
65
|
* Creates a reference to a robot token in another stack.
|
|
67
66
|
*
|
|
67
|
+
* @example
|
|
68
68
|
* ```ts
|
|
69
69
|
* referenceRobotToken({
|
|
70
70
|
* name: 'editor-token',
|
|
@@ -73,7 +73,6 @@ export function defineRobotToken(parameters: BlueprintRobotTokenConfig): Bluepri
|
|
|
73
73
|
* ```
|
|
74
74
|
*
|
|
75
75
|
* @public
|
|
76
|
-
* @beta Referencing Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
77
76
|
* @category Referencers
|
|
78
77
|
* @expandType BlueprintCrossStackReferenceConfig
|
|
79
78
|
* @param params The parameters for referencing the robot token
|