@sanity/blueprints 0.34.1 → 0.36.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/README.md +1 -2
- package/dist/definers/agents.d.ts +3 -1
- package/dist/definers/agents.js +4 -2
- package/dist/definers/agents.js.map +1 -1
- package/dist/definers/applications.d.ts +30 -18
- package/dist/definers/applications.js +36 -24
- package/dist/definers/applications.js.map +1 -1
- package/dist/definers/blueprints.d.ts +1 -0
- package/dist/definers/blueprints.js +5 -27
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/context.d.ts +6 -2
- package/dist/definers/context.js +8 -4
- package/dist/definers/context.js.map +1 -1
- package/dist/definers/cors.d.ts +11 -1
- package/dist/definers/cors.js +11 -13
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +30 -3
- package/dist/definers/datasets.js +32 -16
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions/document.d.ts +29 -0
- package/dist/definers/functions/document.js +1 -1
- package/dist/definers/functions/document.js.map +1 -1
- package/dist/definers/functions/durable.d.ts +4 -3
- package/dist/definers/functions/durable.js +5 -4
- package/dist/definers/functions/durable.js.map +1 -1
- package/dist/definers/functions/index.js +1 -1
- package/dist/definers/functions/index.js.map +1 -1
- package/dist/definers/functions/media-library.d.ts +30 -0
- package/dist/definers/functions/media-library.js +19 -21
- 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 +3 -4
- package/dist/definers/functions/pubsub.js.map +1 -1
- package/dist/definers/functions/queue.d.ts +26 -6
- package/dist/definers/functions/queue.js +31 -10
- package/dist/definers/functions/queue.js.map +1 -1
- package/dist/definers/functions/scheduled.d.ts +7 -6
- package/dist/definers/functions/scheduled.js +8 -7
- 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 +6 -3
- 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 +5 -3
- package/dist/definers/installation-config.js.map +1 -1
- package/dist/definers/permissions.d.ts +8 -2
- package/dist/definers/permissions.js +12 -5
- package/dist/definers/permissions.js.map +1 -1
- package/dist/definers/projects.d.ts +3 -4
- package/dist/definers/projects.js +4 -5
- 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 -4
- package/dist/definers/robotTokens.js +53 -20
- package/dist/definers/robotTokens.js.map +1 -1
- package/dist/definers/roles.d.ts +49 -9
- package/dist/definers/roles.js +54 -55
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/studios.d.ts +5 -3
- package/dist/definers/studios.js +6 -4
- package/dist/definers/studios.js.map +1 -1
- package/dist/definers/webhooks.d.ts +19 -1
- package/dist/definers/webhooks.js +18 -22
- 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 +68 -50
- 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 +96 -21
- package/dist/types/functions/index.js +2 -1
- package/dist/types/functions/index.js.map +1 -1
- package/dist/types/installation-config.d.ts +14 -11
- package/dist/types/permissions.d.ts +8 -4
- package/dist/types/projects.d.ts +5 -4
- package/dist/types/robotTokens.d.ts +14 -4
- package/dist/types/roles.d.ts +10 -9
- package/dist/types/studios.d.ts +29 -14
- 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/utils/validation.d.ts +14 -11
- package/dist/utils/validation.js +25 -17
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/applications.js +7 -2
- package/dist/validation/applications.js.map +1 -1
- package/dist/validation/blueprints.js +120 -4
- package/dist/validation/blueprints.js.map +1 -1
- package/dist/validation/functions.d.ts +19 -0
- package/dist/validation/functions.js +169 -36
- 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/resources.js +1 -1
- package/dist/validation/resources.js.map +1 -1
- package/dist/validation/studios.js +4 -0
- package/dist/validation/studios.js.map +1 -1
- package/package.json +1 -1
- package/src/definers/agents.ts +4 -2
- package/src/definers/applications.ts +36 -24
- package/src/definers/blueprints.ts +4 -27
- package/src/definers/context.ts +8 -4
- package/src/definers/cors.ts +11 -13
- package/src/definers/datasets.ts +40 -16
- package/src/definers/functions/document.ts +17 -25
- package/src/definers/functions/durable.ts +5 -4
- package/src/definers/functions/index.ts +1 -1
- package/src/definers/functions/media-library.ts +19 -21
- package/src/definers/functions/pubsub.ts +3 -4
- package/src/definers/functions/queue.ts +31 -10
- package/src/definers/functions/scheduled.ts +8 -7
- package/src/definers/functions/sync-tag-invalidate.ts +6 -3
- package/src/definers/installation-config.ts +5 -3
- package/src/definers/permissions.ts +14 -6
- package/src/definers/projects.ts +4 -5
- package/src/definers/resources.ts +1 -11
- package/src/definers/robotTokens.ts +55 -20
- package/src/definers/roles.ts +60 -58
- package/src/definers/studios.ts +6 -4
- package/src/definers/webhooks.ts +18 -23
- 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 +68 -50
- 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 +100 -21
- package/src/types/installation-config.ts +14 -11
- package/src/types/permissions.ts +8 -4
- package/src/types/projects.ts +6 -4
- package/src/types/robotTokens.ts +15 -4
- package/src/types/roles.ts +10 -9
- package/src/types/studios.ts +33 -14
- 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/utils/validation.ts +24 -17
- package/src/validation/applications.ts +6 -2
- package/src/validation/blueprints.ts +132 -5
- package/src/validation/functions.ts +183 -37
- package/src/validation/projects.ts +4 -0
- package/src/validation/resources.ts +1 -1
- package/src/validation/studios.ts +3 -0
|
@@ -41,6 +41,9 @@ function viewConfigToResource(view: BlueprintApplicationViewConfig): BlueprintAp
|
|
|
41
41
|
* Defines a window view — the navigable, full-page view of an application.
|
|
42
42
|
* An application may declare at most one window view.
|
|
43
43
|
*
|
|
44
|
+
* Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
44
47
|
* ```ts
|
|
45
48
|
* defineWindowView({
|
|
46
49
|
* name: 'main',
|
|
@@ -60,21 +63,23 @@ function viewConfigToResource(view: BlueprintApplicationViewConfig): BlueprintAp
|
|
|
60
63
|
* ```
|
|
61
64
|
* @param config The window view configuration
|
|
62
65
|
* @public
|
|
63
|
-
* @beta
|
|
64
|
-
* @category
|
|
66
|
+
* @beta
|
|
67
|
+
* @category Application Children
|
|
65
68
|
* @expandType BlueprintWindowViewConfig
|
|
66
69
|
* @returns The window view declaration
|
|
67
|
-
* @hidden
|
|
68
70
|
*/
|
|
69
71
|
export function defineWindowView(config: Omit<BlueprintWindowViewConfig, 'surface' | 'type'>): BlueprintWindowViewConfig {
|
|
70
72
|
const view: BlueprintWindowViewConfig = {...config, surface: 'window', type: 'view'}
|
|
71
|
-
runValidation(() => validateWindowView(viewConfigToResource(view)))
|
|
73
|
+
runValidation(view, () => validateWindowView(viewConfigToResource(view)))
|
|
72
74
|
return view
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Defines a panel view — renders in the dock.
|
|
77
79
|
*
|
|
80
|
+
* Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
78
83
|
* ```ts
|
|
79
84
|
* definePanelView({
|
|
80
85
|
* name: 'side',
|
|
@@ -84,21 +89,23 @@ export function defineWindowView(config: Omit<BlueprintWindowViewConfig, 'surfac
|
|
|
84
89
|
* ```
|
|
85
90
|
* @param config The panel view configuration
|
|
86
91
|
* @public
|
|
87
|
-
* @beta
|
|
88
|
-
* @category
|
|
92
|
+
* @beta
|
|
93
|
+
* @category Application Children
|
|
89
94
|
* @expandType BlueprintPanelViewConfig
|
|
90
95
|
* @returns The panel view declaration
|
|
91
|
-
* @hidden
|
|
92
96
|
*/
|
|
93
97
|
export function definePanelView(config: Omit<BlueprintPanelViewConfig, 'surface' | 'type'>): BlueprintPanelViewConfig {
|
|
94
98
|
const view: BlueprintPanelViewConfig = {...config, surface: 'panel', type: 'view'}
|
|
95
|
-
runValidation(() => validatePanelView(viewConfigToResource(view)))
|
|
99
|
+
runValidation(view, () => validatePanelView(viewConfigToResource(view)))
|
|
96
100
|
return view
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
/**
|
|
100
104
|
* Defines an asset source view — contributes an asset source.
|
|
101
105
|
*
|
|
106
|
+
* Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
102
109
|
* ```ts
|
|
103
110
|
* defineAssetSourceView({
|
|
104
111
|
* name: 'image-picker',
|
|
@@ -108,21 +115,23 @@ export function definePanelView(config: Omit<BlueprintPanelViewConfig, 'surface'
|
|
|
108
115
|
* ```
|
|
109
116
|
* @param config The asset source view configuration
|
|
110
117
|
* @public
|
|
111
|
-
* @beta
|
|
112
|
-
* @category
|
|
118
|
+
* @beta
|
|
119
|
+
* @category Application Children
|
|
113
120
|
* @expandType BlueprintAssetSourceViewConfig
|
|
114
121
|
* @returns The asset source view declaration
|
|
115
|
-
* @hidden
|
|
116
122
|
*/
|
|
117
123
|
export function defineAssetSourceView(config: Omit<BlueprintAssetSourceViewConfig, 'surface' | 'type'>): BlueprintAssetSourceViewConfig {
|
|
118
124
|
const view: BlueprintAssetSourceViewConfig = {...config, surface: 'asset-source', type: 'view'}
|
|
119
|
-
runValidation(() => validateAssetSourceView(viewConfigToResource(view)))
|
|
125
|
+
runValidation(view, () => validateAssetSourceView(viewConfigToResource(view)))
|
|
120
126
|
return view
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
/**
|
|
124
130
|
* Defines a tile view — docks on the dashboard with a footprint `size`.
|
|
125
131
|
*
|
|
132
|
+
* Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
126
135
|
* ```ts
|
|
127
136
|
* defineTileView({
|
|
128
137
|
* name: 'jump-back-in',
|
|
@@ -133,21 +142,23 @@ export function defineAssetSourceView(config: Omit<BlueprintAssetSourceViewConfi
|
|
|
133
142
|
* ```
|
|
134
143
|
* @param config The tile view configuration
|
|
135
144
|
* @public
|
|
136
|
-
* @beta
|
|
137
|
-
* @category
|
|
145
|
+
* @beta
|
|
146
|
+
* @category Application Children
|
|
138
147
|
* @expandType BlueprintTileViewConfig
|
|
139
148
|
* @returns The tile view declaration
|
|
140
|
-
* @hidden
|
|
141
149
|
*/
|
|
142
150
|
export function defineTileView(config: Omit<BlueprintTileViewConfig, 'surface' | 'type'>): BlueprintTileViewConfig {
|
|
143
151
|
const view: BlueprintTileViewConfig = {...config, surface: 'tile', type: 'view'}
|
|
144
|
-
runValidation(() => validateTileView(viewConfigToResource(view)))
|
|
152
|
+
runValidation(view, () => validateTileView(viewConfigToResource(view)))
|
|
145
153
|
return view
|
|
146
154
|
}
|
|
147
155
|
|
|
148
156
|
/**
|
|
149
157
|
* Defines a background web worker an application runs.
|
|
150
158
|
*
|
|
159
|
+
* Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
151
162
|
* ```ts
|
|
152
163
|
* defineWebWorker({
|
|
153
164
|
* name: 'background-refresh',
|
|
@@ -157,21 +168,22 @@ export function defineTileView(config: Omit<BlueprintTileViewConfig, 'surface' |
|
|
|
157
168
|
* ```
|
|
158
169
|
* @param config The web worker configuration
|
|
159
170
|
* @public
|
|
160
|
-
* @beta
|
|
161
|
-
* @category
|
|
171
|
+
* @beta
|
|
172
|
+
* @category Application Children
|
|
162
173
|
* @expandType BlueprintWebWorkerConfig
|
|
163
174
|
* @returns The web worker declaration
|
|
164
|
-
* @hidden
|
|
165
175
|
*/
|
|
166
176
|
export function defineWebWorker(config: BlueprintWebWorkerConfig): BlueprintWebWorker {
|
|
167
177
|
const worker: BlueprintWebWorker = {...config, type: 'worker'}
|
|
168
|
-
runValidation(() => validateWebWorker(worker))
|
|
178
|
+
runValidation(worker, () => validateWebWorker(worker))
|
|
169
179
|
return worker
|
|
170
180
|
}
|
|
171
181
|
|
|
172
182
|
/**
|
|
173
183
|
* Defines an application.
|
|
174
184
|
*
|
|
185
|
+
* Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
186
|
+
*
|
|
175
187
|
* @remarks
|
|
176
188
|
* Views are authored in `views` and web workers in `webWorkers`, mirroring the
|
|
177
189
|
* emitted resource. Views are discriminated by `surface` (`window`, `panel`,
|
|
@@ -180,6 +192,7 @@ export function defineWebWorker(config: BlueprintWebWorkerConfig): BlueprintWebW
|
|
|
180
192
|
* surface, and at most one `window` view. Every view and web worker `src` is
|
|
181
193
|
* resolved relative to `root`. The `slug` defaults to the resource `name`.
|
|
182
194
|
*
|
|
195
|
+
* @example
|
|
183
196
|
* ```ts
|
|
184
197
|
* defineApplication({
|
|
185
198
|
* name: 'design-retro',
|
|
@@ -198,7 +211,7 @@ export function defineWebWorker(config: BlueprintWebWorkerConfig): BlueprintWebW
|
|
|
198
211
|
* title: 'Design Retro',
|
|
199
212
|
* root: './apps/design-retro',
|
|
200
213
|
* slug: 'design-retro',
|
|
201
|
-
* icon: './src/icons/app-icon.
|
|
214
|
+
* icon: './src/icons/app-icon.png',
|
|
202
215
|
* visibility: 'unlisted',
|
|
203
216
|
* views: [
|
|
204
217
|
* defineWindowView({
|
|
@@ -218,11 +231,10 @@ export function defineWebWorker(config: BlueprintWebWorkerConfig): BlueprintWebW
|
|
|
218
231
|
* ```
|
|
219
232
|
* @param config The application configuration
|
|
220
233
|
* @public
|
|
221
|
-
* @beta
|
|
234
|
+
* @beta
|
|
222
235
|
* @category Definers
|
|
223
236
|
* @expandType BlueprintApplicationConfig
|
|
224
237
|
* @returns The application resource
|
|
225
|
-
* @hidden
|
|
226
238
|
*/
|
|
227
239
|
export function defineApplication(config: BlueprintApplicationConfig): BlueprintApplicationResource {
|
|
228
240
|
const {views, webWorkers, slug, ...rest} = config
|
|
@@ -231,7 +243,7 @@ export function defineApplication(config: BlueprintApplicationConfig): Blueprint
|
|
|
231
243
|
if (views && views.length > 0) applicationResource.views = views.map(viewConfigToResource)
|
|
232
244
|
if (webWorkers && webWorkers.length > 0) applicationResource.webWorkers = webWorkers
|
|
233
245
|
|
|
234
|
-
runValidation(() => validateApplication(applicationResource))
|
|
246
|
+
runValidation(applicationResource, () => validateApplication(applicationResource))
|
|
235
247
|
|
|
236
248
|
return applicationResource
|
|
237
249
|
}
|
|
@@ -1,34 +1,10 @@
|
|
|
1
1
|
import {type Blueprint, type BlueprintModule, type BlueprintsApiConfig, validateBlueprint} from '../index.js'
|
|
2
|
-
import {
|
|
2
|
+
import {formatErrors} 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: [
|
|
@@ -55,7 +31,8 @@ import {runValidation} from '../utils/validation.js'
|
|
|
55
31
|
export function defineBlueprint(blueprintConfig: Partial<Blueprint> & Partial<BlueprintsApiConfig>): BlueprintModule {
|
|
56
32
|
const {organizationId, projectId, stackId, blueprintVersion, resources, values, outputs} = blueprintConfig
|
|
57
33
|
|
|
58
|
-
|
|
34
|
+
const errors = validateBlueprint(blueprintConfig)
|
|
35
|
+
if (errors.length > 0) throw new Error(formatErrors(errors))
|
|
59
36
|
|
|
60
37
|
function blueprint(): Blueprint {
|
|
61
38
|
return {
|
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
|
|
@@ -52,7 +54,7 @@ export function defineContextKnowledgeBase(parameters: BlueprintContextKnowledge
|
|
|
52
54
|
type: 'sanity.context.knowledge-base',
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
runValidation(() => validateContextKnowledgeBase(knowledgeBaseResource))
|
|
57
|
+
runValidation(knowledgeBaseResource, () => validateContextKnowledgeBase(knowledgeBaseResource))
|
|
56
58
|
|
|
57
59
|
return knowledgeBaseResource
|
|
58
60
|
}
|
|
@@ -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
|
|
@@ -116,7 +120,7 @@ export function defineContextMcpEndpoint(parameters: BlueprintContextMcpEndpoint
|
|
|
116
120
|
: parameters.sources,
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
runValidation(() => validateContextMcpEndpoint(mcpEndpointResource))
|
|
123
|
+
runValidation(mcpEndpointResource, () => validateContextMcpEndpoint(mcpEndpointResource))
|
|
120
124
|
|
|
121
125
|
return mcpEndpointResource
|
|
122
126
|
}
|
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
|
|
@@ -37,7 +35,7 @@ export function defineCorsOrigin(parameters: BlueprintCorsOriginConfig): Bluepri
|
|
|
37
35
|
type: 'sanity.project.cors',
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
runValidation(() => validateCorsOrigin(corsResource))
|
|
38
|
+
runValidation(corsResource, () => validateCorsOrigin(corsResource))
|
|
41
39
|
|
|
42
40
|
return corsResource
|
|
43
41
|
}
|
package/src/definers/datasets.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BlueprintCrossStackReferenceConfig,
|
|
3
|
+
type BlueprintDatasetConfig,
|
|
4
|
+
type BlueprintDatasetResource,
|
|
5
|
+
type BlueprintResource,
|
|
6
|
+
referenceResource,
|
|
7
|
+
validateDataset,
|
|
8
|
+
} from '../index.js'
|
|
2
9
|
import {runValidation} from '../utils/validation.js'
|
|
3
10
|
|
|
4
|
-
|
|
5
|
-
*
|
|
11
|
+
/**
|
|
12
|
+
* Defines a Dataset to be managed in a Blueprint.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* defineDataset({
|
|
17
|
+
* name: 'staging-dataset',
|
|
18
|
+
* datasetName: 'staging',
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
6
22
|
* @example All options
|
|
7
23
|
* ```ts
|
|
8
24
|
* defineDataset({
|
|
@@ -13,20 +29,8 @@ import {runValidation} from '../utils/validation.js'
|
|
|
13
29
|
* lifecycle: {deletionPolicy: 'protect'},
|
|
14
30
|
* })
|
|
15
31
|
* ```
|
|
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
32
|
* @param parameters The dataset configuration
|
|
27
33
|
* @public
|
|
28
|
-
* @alpha Deploying Datasets via Blueprints is experimental. This feature is subject to breaking changes.
|
|
29
|
-
* @hidden
|
|
30
34
|
* @category Definers
|
|
31
35
|
* @expandType BlueprintDatasetConfig
|
|
32
36
|
* @returns The dataset resource
|
|
@@ -43,7 +47,27 @@ export function defineDataset(parameters: BlueprintDatasetConfig): BlueprintData
|
|
|
43
47
|
type: 'sanity.project.dataset',
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
runValidation(() => validateDataset(datasetResource))
|
|
50
|
+
runValidation(datasetResource, () => validateDataset(datasetResource))
|
|
47
51
|
|
|
48
52
|
return datasetResource
|
|
49
53
|
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Creates a reference to a dataset in another stack.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* referenceDataset({
|
|
61
|
+
* name: 'prod-dataset',
|
|
62
|
+
* stack: 'editorial',
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param params The parameters for referencing the dataset
|
|
67
|
+
* @public
|
|
68
|
+
* @category Referencers
|
|
69
|
+
* @returns The datset reference
|
|
70
|
+
*/
|
|
71
|
+
export function referenceDataset({name, stack, localName}: BlueprintCrossStackReferenceConfig): BlueprintResource {
|
|
72
|
+
return referenceResource({name, stack, localName, type: 'sanity.project.dataset'})
|
|
73
|
+
}
|
|
@@ -11,21 +11,28 @@ 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
|
+
* project: 'my-project-id',
|
|
35
|
+
* roleNames: ['editor'],
|
|
29
36
|
* }],
|
|
30
37
|
* })
|
|
31
38
|
*
|
|
@@ -43,21 +50,6 @@ const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersio
|
|
|
43
50
|
* },
|
|
44
51
|
* env: {
|
|
45
52
|
* 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
53
|
* },
|
|
62
54
|
* })
|
|
63
55
|
* ```
|
|
@@ -106,7 +98,7 @@ export function defineDocumentFunction(
|
|
|
106
98
|
event,
|
|
107
99
|
}
|
|
108
100
|
|
|
109
|
-
runValidation(() => validateDocumentFunction(functionResource))
|
|
101
|
+
runValidation(functionResource, () => validateDocumentFunction(functionResource))
|
|
110
102
|
|
|
111
103
|
return functionResource
|
|
112
104
|
}
|
|
@@ -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
|
*/
|
|
@@ -34,6 +35,6 @@ export function defineDurableFunction(functionConfig: BlueprintDurableConfig): B
|
|
|
34
35
|
// ...(debounce !== undefined && {debounce: createDebounceObject(debounce)}),
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
runValidation(() => validateDurableFunction(functionResource))
|
|
38
|
+
runValidation(functionResource, () => validateDurableFunction(functionResource))
|
|
38
39
|
return functionResource
|
|
39
40
|
}
|
|
@@ -33,7 +33,7 @@ export function defineFunction(
|
|
|
33
33
|
|
|
34
34
|
if (lifecycle) functionResource.lifecycle = lifecycle
|
|
35
35
|
|
|
36
|
-
if (options?.skipValidation !== true) runValidation(() => validateFunction(functionResource))
|
|
36
|
+
if (options?.skipValidation !== true) runValidation(functionResource, () => validateFunction(functionResource))
|
|
37
37
|
|
|
38
38
|
return functionResource
|
|
39
39
|
}
|
|
@@ -10,15 +10,29 @@ 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
|
-
*
|
|
21
|
-
* resourceId: projectId,
|
|
35
|
+
* project: 'my-project-id',
|
|
22
36
|
* roleNames: ['editor'],
|
|
23
37
|
* }],
|
|
24
38
|
* })
|
|
@@ -41,22 +55,6 @@ const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resourc
|
|
|
41
55
|
* },
|
|
42
56
|
* })
|
|
43
57
|
* ```
|
|
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
58
|
* @param functionConfig The configuration for the media library asset function
|
|
61
59
|
* @public
|
|
62
60
|
* @category Definers
|
|
@@ -74,7 +72,7 @@ export function defineMediaLibraryAssetFunction(
|
|
|
74
72
|
event: buildMediaLibraryFunctionEvent(event),
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
runValidation(() => validateMediaLibraryAssetFunction(functionResource))
|
|
75
|
+
runValidation(functionResource, () => validateMediaLibraryAssetFunction(functionResource))
|
|
78
76
|
|
|
79
77
|
return functionResource
|
|
80
78
|
}
|
|
@@ -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',
|
|
@@ -24,7 +23,7 @@ export function definePubSubFunction(functionConfig: BlueprintPubSubFunctionConf
|
|
|
24
23
|
type: 'sanity.function.pubsub',
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
runValidation(() => validatePubSubFunction(functionResource))
|
|
26
|
+
runValidation(functionResource, () => validatePubSubFunction(functionResource))
|
|
28
27
|
|
|
29
28
|
return functionResource
|
|
30
29
|
}
|