@sanity/blueprints 0.20.1 → 0.21.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.
@@ -175,7 +175,7 @@ export declare function defineQueueFunction(functionConfig: BlueprintQueueFuncti
175
175
  * @hidden
176
176
  * @category Definers
177
177
  * @expandType BlueprintEventFunctionConfig
178
- * @param functionConfig The configuration for the queue function
178
+ * @param functionConfig The configuration for the event function
179
179
  * @returns The validated event function resource
180
180
  */
181
181
  export declare function defineEventFunction(functionConfig: BlueprintEventFunctionConfig): BlueprintEventFunctionResource;
@@ -258,7 +258,7 @@ export function defineQueueFunction(functionConfig) {
258
258
  * @hidden
259
259
  * @category Definers
260
260
  * @expandType BlueprintEventFunctionConfig
261
- * @param functionConfig The configuration for the queue function
261
+ * @param functionConfig The configuration for the event function
262
262
  * @returns The validated event function resource
263
263
  */
264
264
  export function defineEventFunction(functionConfig) {
@@ -82,12 +82,11 @@ export interface BlueprintQueueFunctionResourceEvent {
82
82
  fifo?: boolean;
83
83
  dlq?: boolean;
84
84
  }
85
- export type BlueprintQueueFunctionBooleanResourceEvent = boolean;
86
85
  /**
87
86
  * Union type of all queue function resource event configurations
88
87
  * @category Functions Types
89
88
  */
90
- export type BlueprintQueueFunctionConfigEvent = BlueprintQueueFunctionBooleanResourceEvent | BlueprintQueueFunctionResourceEvent;
89
+ export type BlueprintQueueFunctionConfigEvent = true | BlueprintQueueFunctionResourceEvent;
91
90
  /**
92
91
  * Union type of all function resource event configurations
93
92
  * @category Functions Types
@@ -193,8 +193,13 @@ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource,
193
193
  */
194
194
  src?: string;
195
195
  /**
196
- * Queue configuration. Pass `true` or omit to use defaults (concurrency: 1, fifo: true, dlq: true),
197
- * or pass an object to override specific settings.
196
+ * Queue configuration.
197
+ *
198
+ * Omit this property or set it to `true` to use the defaults:
199
+ * concurrency: 1, fifo: true, dlq: true.
200
+ *
201
+ * Provide an object to override specific settings.
202
+ *
198
203
  * @defaultValue true
199
204
  */
200
205
  queue?: BlueprintQueueFunctionConfigEvent;
@@ -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,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,qCAAqC,EAAC,CAAC,CAAA;IAC/F,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,sCAAsC,EAAC,CAAC,CAAA;IAElH,MAAM,MAAM,GAAqB,gBAAgB,CAAC,QAAQ,EAAE,EAAC,gBAAgB,EAAE,IAAI,EAAC,CAAC,CAAA;IAErF,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;Q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AAC,EAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,qDAAqD,EAAC,CAAC,CAAA;QACvG,CAAC;IACH,CAAC;IAED,IAAI,kBAAkB,IAAI,QAAQ,EAAE,CAAC;QACnC,IAAI,OAAO,QAAQ,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnD,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,gDAAgD,EAAC,CAAC,CAAA;QAChG,CAAC;aAAM,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;YACjG,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,kHAAkH;aAC5H,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC1B,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,sCAAsC,EAAC,CAAC,CAAA;QACtF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/blueprints",
3
- "version": "0.20.1",
3
+ "version": "0.21.0",
4
4
  "description": "Helper methods and type definitions for Sanity Blueprints",
5
5
  "keywords": [
6
6
  "sanity",
@@ -396,7 +396,7 @@ export function defineQueueFunction(functionConfig: BlueprintQueueFunctionConfig
396
396
  * @hidden
397
397
  * @category Definers
398
398
  * @expandType BlueprintEventFunctionConfig
399
- * @param functionConfig The configuration for the queue function
399
+ * @param functionConfig The configuration for the event function
400
400
  * @returns The validated event function resource
401
401
  */
402
402
  export function defineEventFunction(functionConfig: BlueprintEventFunctionConfig): BlueprintEventFunctionResource {
@@ -95,13 +95,11 @@ export interface BlueprintQueueFunctionResourceEvent {
95
95
  dlq?: boolean
96
96
  }
97
97
 
98
- export type BlueprintQueueFunctionBooleanResourceEvent = boolean
99
-
100
98
  /**
101
99
  * Union type of all queue function resource event configurations
102
100
  * @category Functions Types
103
101
  */
104
- export type BlueprintQueueFunctionConfigEvent = BlueprintQueueFunctionBooleanResourceEvent | BlueprintQueueFunctionResourceEvent
102
+ export type BlueprintQueueFunctionConfigEvent = true | BlueprintQueueFunctionResourceEvent
105
103
 
106
104
  /**
107
105
  * Union type of all function resource event configurations
@@ -222,8 +222,13 @@ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource,
222
222
  */
223
223
  src?: string
224
224
  /**
225
- * Queue configuration. Pass `true` or omit to use defaults (concurrency: 1, fifo: true, dlq: true),
226
- * or pass an object to override specific settings.
225
+ * Queue configuration.
226
+ *
227
+ * Omit this property or set it to `true` to use the defaults:
228
+ * concurrency: 1, fifo: true, dlq: true.
229
+ *
230
+ * Provide an object to override specific settings.
231
+ *
227
232
  * @defaultValue true
228
233
  */
229
234
  queue?: BlueprintQueueFunctionConfigEvent
@@ -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'})