@sanity/blueprints 0.20.2 → 0.22.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/types/functions/event.d.ts +9 -0
- package/dist/types/functions/index.d.ts +44 -1
- package/dist/types/functions/index.js.map +1 -1
- package/dist/validation/cors.js +11 -0
- package/dist/validation/cors.js.map +1 -1
- package/package.json +1 -1
- package/src/types/functions/event.ts +8 -0
- package/src/types/functions/index.ts +46 -0
- package/src/validation/cors.ts +11 -0
|
@@ -115,3 +115,12 @@ export interface BlueprintFunctionResourceEventResourceMediaLibrary {
|
|
|
115
115
|
* @category Functions Types
|
|
116
116
|
*/
|
|
117
117
|
export type BlueprintFunctionResourceEventName = 'publish' | 'create' | 'delete' | 'update';
|
|
118
|
+
/**
|
|
119
|
+
* Event configuration for workflows.
|
|
120
|
+
* @category Functions Types
|
|
121
|
+
*/
|
|
122
|
+
export type BlueprintWorkflowFunctionResourceEvent = ({
|
|
123
|
+
type: 'document';
|
|
124
|
+
} & BlueprintDocumentFunctionResourceEvent) | ({
|
|
125
|
+
type: 'sync-tag-invalidate';
|
|
126
|
+
} & BlueprintSyncTagInvalidateFunctionResourceEvent);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BlueprintResource } from '../../index.js';
|
|
2
|
-
import type { BlueprintDocumentFunctionResourceEvent, BlueprintMediaLibraryFunctionResourceEvent, BlueprintQueueFunctionConfigEvent, BlueprintQueueFunctionResourceEvent, BlueprintScheduledFunctionConfigEvent, BlueprintScheduledFunctionResourceEvent, BlueprintSyncTagInvalidateFunctionResourceEvent } from './event.js';
|
|
2
|
+
import type { BlueprintDocumentFunctionResourceEvent, BlueprintMediaLibraryFunctionResourceEvent, BlueprintQueueFunctionConfigEvent, BlueprintQueueFunctionResourceEvent, BlueprintScheduledFunctionConfigEvent, BlueprintScheduledFunctionResourceEvent, BlueprintSyncTagInvalidateFunctionResourceEvent, BlueprintWorkflowFunctionResourceEvent } from './event.js';
|
|
3
3
|
import type { IanaTimezone } from './timezone.js';
|
|
4
4
|
export * from './event.js';
|
|
5
5
|
/**
|
|
@@ -219,3 +219,46 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
|
|
|
219
219
|
*/
|
|
220
220
|
src?: string;
|
|
221
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* A durable, step-based workflow function.
|
|
224
|
+
* @public
|
|
225
|
+
* @alpha Deploying Workflows via Blueprints is experimental. This feature is not available publicly yet.
|
|
226
|
+
* @hidden
|
|
227
|
+
* @category Functions Types
|
|
228
|
+
* @interface
|
|
229
|
+
*/
|
|
230
|
+
export interface BlueprintWorkflowFunctionResource extends BlueprintBaseFunctionResource {
|
|
231
|
+
type: 'sanity.function.workflow';
|
|
232
|
+
event: BlueprintWorkflowFunctionResourceEvent;
|
|
233
|
+
/**
|
|
234
|
+
* Max concurrent executions
|
|
235
|
+
*/
|
|
236
|
+
concurrency?: number;
|
|
237
|
+
/**
|
|
238
|
+
* Debounce window in minutes
|
|
239
|
+
*/
|
|
240
|
+
debounce?: number;
|
|
241
|
+
/**
|
|
242
|
+
* Path used to group debounced events, e.g. 'document._id'
|
|
243
|
+
*/
|
|
244
|
+
debounceKey?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Configuration for defining a workflow function.
|
|
248
|
+
* @public
|
|
249
|
+
* @alpha Deploying Workflows via Blueprints is experimental.
|
|
250
|
+
* @hidden
|
|
251
|
+
* @category Functions Types
|
|
252
|
+
* @interface
|
|
253
|
+
*/
|
|
254
|
+
export type BlueprintWorkflowFunctionConfig = Omit<BlueprintWorkflowFunctionResource, 'type' | 'src' | 'event'> & {
|
|
255
|
+
/**
|
|
256
|
+
* Path to the workflow source code
|
|
257
|
+
* @defaultValue `workflows/${name}`
|
|
258
|
+
*/
|
|
259
|
+
src?: string;
|
|
260
|
+
/**
|
|
261
|
+
* Trigger configuration
|
|
262
|
+
*/
|
|
263
|
+
event: BlueprintWorkflowFunctionResourceEvent;
|
|
264
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/functions/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/functions/index.ts"],"names":[],"mappings":"AAaA,cAAc,YAAY,CAAA;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAU,CAAA"}
|
package/dist/validation/cors.js
CHANGED
|
@@ -36,6 +36,17 @@ export function validateCorsOrigin(resource) {
|
|
|
36
36
|
errors.push({ type: 'invalid_format', message: 'CORS Origin must include a protocol (e.g. https://)' });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
if ('allowCredentials' in resource) {
|
|
40
|
+
if (typeof resource.allowCredentials !== 'boolean') {
|
|
41
|
+
errors.push({ type: 'invalid_type', message: 'CORS Origin allowCredentials must be a boolean' });
|
|
42
|
+
}
|
|
43
|
+
else if ('origin' in resource && resource.origin === '*' && resource.allowCredentials === true) {
|
|
44
|
+
errors.push({
|
|
45
|
+
type: 'invalid_value',
|
|
46
|
+
message: 'A blanket wildcard origin "*" cannot allow credentials. Set allowCredentials to false, or use a specific origin.',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
39
50
|
if ('project' in resource) {
|
|
40
51
|
if (typeof resource.project !== 'string') {
|
|
41
52
|
errors.push({ type: 'invalid_type', message: 'CORS Origin project must be a string' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cors.js","sourceRoot":"","sources":["../../src/validation/cors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAC,MAAM,aAAa,CAAA;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,wBAAwB,CAAA;AAElD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAiB;IAClD,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MAAM,CAAA;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -137,3 +137,11 @@ export interface BlueprintFunctionResourceEventResourceMediaLibrary {
|
|
|
137
137
|
* @category Functions Types
|
|
138
138
|
*/
|
|
139
139
|
export type BlueprintFunctionResourceEventName = 'publish' | 'create' | 'delete' | 'update'
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Event configuration for workflows.
|
|
143
|
+
* @category Functions Types
|
|
144
|
+
*/
|
|
145
|
+
export type BlueprintWorkflowFunctionResourceEvent =
|
|
146
|
+
| ({type: 'document'} & BlueprintDocumentFunctionResourceEvent)
|
|
147
|
+
| ({type: 'sync-tag-invalidate'} & BlueprintSyncTagInvalidateFunctionResourceEvent)
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
BlueprintScheduledFunctionConfigEvent,
|
|
8
8
|
BlueprintScheduledFunctionResourceEvent,
|
|
9
9
|
BlueprintSyncTagInvalidateFunctionResourceEvent,
|
|
10
|
+
BlueprintWorkflowFunctionResourceEvent,
|
|
10
11
|
} from './event.js'
|
|
11
12
|
import type {IanaTimezone} from './timezone.js'
|
|
12
13
|
|
|
@@ -249,3 +250,48 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
|
|
|
249
250
|
*/
|
|
250
251
|
src?: string
|
|
251
252
|
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* A durable, step-based workflow function.
|
|
256
|
+
* @public
|
|
257
|
+
* @alpha Deploying Workflows via Blueprints is experimental. This feature is not available publicly yet.
|
|
258
|
+
* @hidden
|
|
259
|
+
* @category Functions Types
|
|
260
|
+
* @interface
|
|
261
|
+
*/
|
|
262
|
+
export interface BlueprintWorkflowFunctionResource extends BlueprintBaseFunctionResource {
|
|
263
|
+
type: 'sanity.function.workflow'
|
|
264
|
+
event: BlueprintWorkflowFunctionResourceEvent
|
|
265
|
+
/**
|
|
266
|
+
* Max concurrent executions
|
|
267
|
+
*/
|
|
268
|
+
concurrency?: number
|
|
269
|
+
/**
|
|
270
|
+
* Debounce window in minutes
|
|
271
|
+
*/
|
|
272
|
+
debounce?: number
|
|
273
|
+
/**
|
|
274
|
+
* Path used to group debounced events, e.g. 'document._id'
|
|
275
|
+
*/
|
|
276
|
+
debounceKey?: string
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Configuration for defining a workflow function.
|
|
281
|
+
* @public
|
|
282
|
+
* @alpha Deploying Workflows via Blueprints is experimental.
|
|
283
|
+
* @hidden
|
|
284
|
+
* @category Functions Types
|
|
285
|
+
* @interface
|
|
286
|
+
*/
|
|
287
|
+
export type BlueprintWorkflowFunctionConfig = Omit<BlueprintWorkflowFunctionResource, 'type' | 'src' | 'event'> & {
|
|
288
|
+
/**
|
|
289
|
+
* Path to the workflow source code
|
|
290
|
+
* @defaultValue `workflows/${name}`
|
|
291
|
+
*/
|
|
292
|
+
src?: string
|
|
293
|
+
/**
|
|
294
|
+
* Trigger configuration
|
|
295
|
+
*/
|
|
296
|
+
event: BlueprintWorkflowFunctionResourceEvent
|
|
297
|
+
}
|
package/src/validation/cors.ts
CHANGED
|
@@ -36,6 +36,17 @@ export function validateCorsOrigin(resource: unknown): BlueprintError[] {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
if ('allowCredentials' in resource) {
|
|
40
|
+
if (typeof resource.allowCredentials !== 'boolean') {
|
|
41
|
+
errors.push({type: 'invalid_type', message: 'CORS Origin allowCredentials must be a boolean'})
|
|
42
|
+
} else if ('origin' in resource && resource.origin === '*' && resource.allowCredentials === true) {
|
|
43
|
+
errors.push({
|
|
44
|
+
type: 'invalid_value',
|
|
45
|
+
message: 'A blanket wildcard origin "*" cannot allow credentials. Set allowCredentials to false, or use a specific origin.',
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
39
50
|
if ('project' in resource) {
|
|
40
51
|
if (typeof resource.project !== 'string') {
|
|
41
52
|
errors.push({type: 'invalid_type', message: 'CORS Origin project must be a string'})
|