@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.
Files changed (164) hide show
  1. package/README.md +1 -2
  2. package/dist/definers/agents.d.ts +3 -1
  3. package/dist/definers/agents.js +4 -2
  4. package/dist/definers/agents.js.map +1 -1
  5. package/dist/definers/applications.d.ts +30 -18
  6. package/dist/definers/applications.js +36 -24
  7. package/dist/definers/applications.js.map +1 -1
  8. package/dist/definers/blueprints.d.ts +1 -0
  9. package/dist/definers/blueprints.js +5 -27
  10. package/dist/definers/blueprints.js.map +1 -1
  11. package/dist/definers/context.d.ts +6 -2
  12. package/dist/definers/context.js +8 -4
  13. package/dist/definers/context.js.map +1 -1
  14. package/dist/definers/cors.d.ts +11 -1
  15. package/dist/definers/cors.js +11 -13
  16. package/dist/definers/cors.js.map +1 -1
  17. package/dist/definers/datasets.d.ts +30 -3
  18. package/dist/definers/datasets.js +32 -16
  19. package/dist/definers/datasets.js.map +1 -1
  20. package/dist/definers/functions/document.d.ts +29 -0
  21. package/dist/definers/functions/document.js +1 -1
  22. package/dist/definers/functions/document.js.map +1 -1
  23. package/dist/definers/functions/durable.d.ts +4 -3
  24. package/dist/definers/functions/durable.js +5 -4
  25. package/dist/definers/functions/durable.js.map +1 -1
  26. package/dist/definers/functions/index.js +1 -1
  27. package/dist/definers/functions/index.js.map +1 -1
  28. package/dist/definers/functions/media-library.d.ts +30 -0
  29. package/dist/definers/functions/media-library.js +19 -21
  30. package/dist/definers/functions/media-library.js.map +1 -1
  31. package/dist/definers/functions/pubsub.d.ts +2 -3
  32. package/dist/definers/functions/pubsub.js +3 -4
  33. package/dist/definers/functions/pubsub.js.map +1 -1
  34. package/dist/definers/functions/queue.d.ts +26 -6
  35. package/dist/definers/functions/queue.js +31 -10
  36. package/dist/definers/functions/queue.js.map +1 -1
  37. package/dist/definers/functions/scheduled.d.ts +7 -6
  38. package/dist/definers/functions/scheduled.js +8 -7
  39. package/dist/definers/functions/scheduled.js.map +1 -1
  40. package/dist/definers/functions/sync-tag-invalidate.d.ts +5 -2
  41. package/dist/definers/functions/sync-tag-invalidate.js +6 -3
  42. package/dist/definers/functions/sync-tag-invalidate.js.map +1 -1
  43. package/dist/definers/installation-config.d.ts +4 -2
  44. package/dist/definers/installation-config.js +5 -3
  45. package/dist/definers/installation-config.js.map +1 -1
  46. package/dist/definers/permissions.d.ts +8 -2
  47. package/dist/definers/permissions.js +12 -5
  48. package/dist/definers/permissions.js.map +1 -1
  49. package/dist/definers/projects.d.ts +3 -4
  50. package/dist/definers/projects.js +4 -5
  51. package/dist/definers/projects.js.map +1 -1
  52. package/dist/definers/resources.d.ts +1 -0
  53. package/dist/definers/resources.js +1 -11
  54. package/dist/definers/resources.js.map +1 -1
  55. package/dist/definers/robotTokens.d.ts +22 -4
  56. package/dist/definers/robotTokens.js +53 -20
  57. package/dist/definers/robotTokens.js.map +1 -1
  58. package/dist/definers/roles.d.ts +49 -9
  59. package/dist/definers/roles.js +54 -55
  60. package/dist/definers/roles.js.map +1 -1
  61. package/dist/definers/studios.d.ts +5 -3
  62. package/dist/definers/studios.js +6 -4
  63. package/dist/definers/studios.js.map +1 -1
  64. package/dist/definers/webhooks.d.ts +19 -1
  65. package/dist/definers/webhooks.js +18 -22
  66. package/dist/definers/webhooks.js.map +1 -1
  67. package/dist/index.d.ts +18 -18
  68. package/dist/index.js +19 -20
  69. package/dist/index.js.map +1 -1
  70. package/dist/resolve/index.d.ts +2 -3
  71. package/dist/resolve/index.js +2 -3
  72. package/dist/resolve/index.js.map +1 -1
  73. package/dist/types/agents.d.ts +7 -3
  74. package/dist/types/applications.d.ts +68 -50
  75. package/dist/types/applications.js +9 -6
  76. package/dist/types/applications.js.map +1 -1
  77. package/dist/types/context.d.ts +17 -7
  78. package/dist/types/cors.d.ts +0 -2
  79. package/dist/types/datasets.d.ts +0 -6
  80. package/dist/types/functions/index.d.ts +96 -21
  81. package/dist/types/functions/index.js +2 -1
  82. package/dist/types/functions/index.js.map +1 -1
  83. package/dist/types/installation-config.d.ts +14 -11
  84. package/dist/types/permissions.d.ts +8 -4
  85. package/dist/types/projects.d.ts +5 -4
  86. package/dist/types/robotTokens.d.ts +14 -4
  87. package/dist/types/roles.d.ts +10 -9
  88. package/dist/types/studios.d.ts +29 -14
  89. package/dist/types/studios.js +3 -2
  90. package/dist/types/studios.js.map +1 -1
  91. package/dist/types/webhooks.d.ts +0 -3
  92. package/dist/utils/debounce.d.ts +0 -11
  93. package/dist/utils/debounce.js +0 -22
  94. package/dist/utils/debounce.js.map +1 -1
  95. package/dist/utils/parse-duration.d.ts +13 -0
  96. package/dist/utils/parse-duration.js +24 -0
  97. package/dist/utils/parse-duration.js.map +1 -1
  98. package/dist/utils/throttle.d.ts +9 -0
  99. package/dist/utils/throttle.js +22 -0
  100. package/dist/utils/throttle.js.map +1 -0
  101. package/dist/utils/validation.d.ts +14 -11
  102. package/dist/utils/validation.js +25 -17
  103. package/dist/utils/validation.js.map +1 -1
  104. package/dist/validation/applications.js +7 -2
  105. package/dist/validation/applications.js.map +1 -1
  106. package/dist/validation/blueprints.js +120 -4
  107. package/dist/validation/blueprints.js.map +1 -1
  108. package/dist/validation/functions.d.ts +19 -0
  109. package/dist/validation/functions.js +169 -36
  110. package/dist/validation/functions.js.map +1 -1
  111. package/dist/validation/projects.js +3 -0
  112. package/dist/validation/projects.js.map +1 -1
  113. package/dist/validation/resources.js +1 -1
  114. package/dist/validation/resources.js.map +1 -1
  115. package/dist/validation/studios.js +4 -0
  116. package/dist/validation/studios.js.map +1 -1
  117. package/package.json +1 -1
  118. package/src/definers/agents.ts +4 -2
  119. package/src/definers/applications.ts +36 -24
  120. package/src/definers/blueprints.ts +4 -27
  121. package/src/definers/context.ts +8 -4
  122. package/src/definers/cors.ts +11 -13
  123. package/src/definers/datasets.ts +40 -16
  124. package/src/definers/functions/document.ts +17 -25
  125. package/src/definers/functions/durable.ts +5 -4
  126. package/src/definers/functions/index.ts +1 -1
  127. package/src/definers/functions/media-library.ts +19 -21
  128. package/src/definers/functions/pubsub.ts +3 -4
  129. package/src/definers/functions/queue.ts +31 -10
  130. package/src/definers/functions/scheduled.ts +8 -7
  131. package/src/definers/functions/sync-tag-invalidate.ts +6 -3
  132. package/src/definers/installation-config.ts +5 -3
  133. package/src/definers/permissions.ts +14 -6
  134. package/src/definers/projects.ts +4 -5
  135. package/src/definers/resources.ts +1 -11
  136. package/src/definers/robotTokens.ts +55 -20
  137. package/src/definers/roles.ts +60 -58
  138. package/src/definers/studios.ts +6 -4
  139. package/src/definers/webhooks.ts +18 -23
  140. package/src/index.ts +20 -21
  141. package/src/resolve/index.ts +2 -4
  142. package/src/types/agents.ts +7 -3
  143. package/src/types/applications.ts +68 -50
  144. package/src/types/context.ts +17 -7
  145. package/src/types/cors.ts +0 -2
  146. package/src/types/datasets.ts +0 -6
  147. package/src/types/functions/index.ts +100 -21
  148. package/src/types/installation-config.ts +14 -11
  149. package/src/types/permissions.ts +8 -4
  150. package/src/types/projects.ts +6 -4
  151. package/src/types/robotTokens.ts +15 -4
  152. package/src/types/roles.ts +10 -9
  153. package/src/types/studios.ts +33 -14
  154. package/src/types/webhooks.ts +0 -3
  155. package/src/utils/debounce.ts +0 -25
  156. package/src/utils/parse-duration.ts +27 -0
  157. package/src/utils/throttle.ts +25 -0
  158. package/src/utils/validation.ts +24 -17
  159. package/src/validation/applications.ts +6 -2
  160. package/src/validation/blueprints.ts +132 -5
  161. package/src/validation/functions.ts +183 -37
  162. package/src/validation/projects.ts +4 -0
  163. package/src/validation/resources.ts +1 -1
  164. package/src/validation/studios.ts +3 -0
@@ -10,12 +10,13 @@ import type {
10
10
  import type {IanaTimezone} from './timezone.js'
11
11
 
12
12
  export * from './event.js'
13
+ export * from './timezone.js'
13
14
 
14
15
  /**
15
16
  * Supported Function runtimes
16
17
  * @category Functions Types
17
18
  */
18
- export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x'] as const
19
+ export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x', 'nodejs26.x'] as const
19
20
  /**
20
21
  * Supported function runtimes
21
22
  * @category Functions Types
@@ -44,42 +45,104 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
44
45
 
45
46
  /**
46
47
  * The runtime environment for the function (currently only Node.js is supported)
47
- * @defaultValue 'nodejs24.x'
48
+ * @defaultValue 'nodejs26.x'
48
49
  */
49
50
  runtime?: FunctionRuntimes
50
51
  }
51
52
 
52
53
  /**
53
- * Configuration used for Queue or Workflow function types.
54
- * @todo: not implemented
54
+ * Configuration used for Queue function types.
55
55
  * @category Functions Types
56
56
  * @alpha
57
57
  * @hidden
58
58
  */
59
59
  interface QueueConfig {
60
60
  /**
61
- * Maximum number of concurrent invocations in progress from queue to Function
62
- * @todo: not implemented, what is the default anyways?
61
+ * How many messages run at once, and whether they run in order.
62
+ * @defaultValue `{limit: 2, fifo: false}`
63
63
  */
64
- concurrency?: number
64
+ concurrency?: ConcurrencyConfig
65
65
  /**
66
66
  * Debounce configuration, with any durations already resolved to seconds.
67
67
  * Definers accept the wider {@link DebounceInput} and parse it into this shape.
68
68
  */
69
69
  debounce?: DebounceConfig
70
+ }
71
+
72
+ /**
73
+ * How many messages a Queue function runs at once, and if they are processed in order.
74
+ *
75
+ * - `{limit: 1, fifo: true}` processes messages one at a time, in order.
76
+ * - `{limit: 5, fifo: true, key: 'event.data.documentId'}` keeps messages with the same key in order,
77
+ * while up to 5 keys run at once, so one busy key doesn't delay the others.
78
+ * - `{limit: 5}` processes up to 5 messages at once, with no order guarantees.
79
+ *
80
+ * A `limit` of 1 needs `fifo: true`, and `fifo` with a `limit` above 1 needs a `key`.
81
+ *
82
+ * Changing `fifo` on a deployed function replaces its queue, and messages still waiting in the old queue are lost.
83
+ * @category Functions Types
84
+ * @alpha
85
+ * @hidden
86
+ */
87
+ export interface ConcurrencyConfig {
70
88
  /**
71
- * Whether to place messages that failed processing into a Dead Letter Queue.
72
- * @todo: not implemented
73
- * @default `false`
89
+ * Maximum number of messages processed at once, from 1 to 1000.
90
+ * A limit of 1 needs `fifo: true`.
74
91
  */
75
- dlq?: boolean
92
+ limit: number
76
93
  /**
77
- * By default, queues employ at-least once delivery. When set to `true`, employs first-in-first-out ordering and exactly-once delivery.
78
- * FIFO queues have a lower transaction-per-second limit.
79
- * @todo: not implemented
80
- * @default `false`
94
+ * Process messages in order: one at a time with a `limit` of 1, or in order per `key` with a higher limit.
95
+ * Changing this on a deployed function replaces its queue, and messages still waiting in the old queue are lost.
96
+ * @defaultValue `false`
81
97
  */
82
98
  fifo?: boolean
99
+ /**
100
+ * Dotted path into `{event, context}`, e.g. `event.data.documentId`; messages with the same value are processed in order.
101
+ * Required when `fifo` is `true` and `limit` is above 1.
102
+ */
103
+ key?: string
104
+ }
105
+
106
+ /**
107
+ * Configuration used when throttling Queue function types.
108
+ * Starts at most `limit` messages per `period`; messages over the rate stay queued and are delivered late, not dropped.
109
+ * @category Functions Types
110
+ * @alpha
111
+ * @hidden
112
+ */
113
+ export interface ThrottleConfig {
114
+ /**
115
+ * Maximum number of messages started per `period`
116
+ */
117
+ limit: number
118
+ /**
119
+ * Length of the throttle period in seconds
120
+ */
121
+ period: number
122
+ /**
123
+ * Number of messages an idle queue may release at once before pacing resumes.
124
+ * Must not be greater than `limit`.
125
+ */
126
+ burst?: number
127
+ /**
128
+ * Dotted path into `{event, context}`, e.g. `event.data.tenantId`; each distinct value is throttled in its own bucket.
129
+ * When omitted, the whole function is throttled as one bucket.
130
+ */
131
+ key?: string
132
+ }
133
+
134
+ /**
135
+ * Throttle configuration as accepted by a function definer, before durations are parsed.
136
+ * @category Functions Types
137
+ * @alpha
138
+ * @hidden
139
+ */
140
+ export interface ThrottleConfigInput extends Omit<ThrottleConfig, 'period'> {
141
+ /**
142
+ * Length of the throttle period.
143
+ * A number is read as seconds, a string is parsed as a duration, e.g. `'1 minute'`.
144
+ */
145
+ period: string | number
83
146
  }
84
147
 
85
148
  /**
@@ -98,7 +161,7 @@ export interface DebounceConfig {
98
161
  */
99
162
  maxWindow?: number
100
163
  /**
101
- * Dotted path into {event, context} used to debounce events
164
+ * Dotted path into `{event, context}` used to group debounced events, e.g. `event.data.documentId`
102
165
  */
103
166
  key?: string
104
167
  }
@@ -117,7 +180,7 @@ export interface DebounceConfigInput extends Omit<DebounceConfig, 'window' | 'ma
117
180
  window: string | number
118
181
  /**
119
182
  * Maximum time to extend a debounce window from the first event.
120
- * Must be greater than `window`.
183
+ * Must be greater than or equal to `window`.
121
184
  * A number is read as seconds, a string is parsed as a duration, e.g. `'1 hour'`.
122
185
  */
123
186
  maxWindow?: string | number
@@ -193,6 +256,17 @@ export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionRes
193
256
  type: 'sanity.function.queue'
194
257
  /** Optional Content Lake event source that triggers the function */
195
258
  event?: BlueprintFunctionResourceContentLakeEvent
259
+ /**
260
+ * Total delivery attempts per message, at most 100: `1` delivers once and never retries, `3` delivers once and retries twice.
261
+ * Messages that use up their attempts are moved to a Dead Letter Queue.
262
+ * @defaultValue `3`, applied by the functions service when omitted
263
+ */
264
+ maxAttempts?: number
265
+ /**
266
+ * Throttle configuration, with `period` already resolved to seconds.
267
+ * Definers accept the wider {@link ThrottleConfigInput} and parse it into this shape.
268
+ */
269
+ throttle?: ThrottleConfig
196
270
  }
197
271
 
198
272
  /**
@@ -205,7 +279,9 @@ export interface BlueprintPubSubFunctionResource extends BlueprintBaseFunctionRe
205
279
 
206
280
  /**
207
281
  * A durable, step-based function.
208
- * @beta Deploying Durable Functions via Blueprints is experimental.
282
+ *
283
+ * Deploying Durable Functions via Blueprints is experimental.
284
+ * @beta
209
285
  * @category Functions Types
210
286
  */
211
287
  export interface BlueprintDurableFunctionResource extends BlueprintBaseFunctionResource {
@@ -301,12 +377,12 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
301
377
  /**
302
378
  * Configuration for defining a queue function.
303
379
  * @public
304
- * @alpha Deploying Queue Functions via Blueprints is experimental. This feature is not available publicly yet.
380
+ * @alpha
305
381
  * @hidden
306
382
  * @category Functions Types
307
383
  * @interface
308
384
  */
309
- export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event' | 'debounce'> & {
385
+ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event' | 'debounce' | 'throttle'> & {
310
386
  /**
311
387
  * Path to the function source code
312
388
  * @defaultValue `functions/${name}`
@@ -318,6 +394,9 @@ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource,
318
394
 
319
395
  /** Optional debounce configuration, as a duration or a full config */
320
396
  debounce?: DebounceInput
397
+
398
+ /** Optional throttle configuration */
399
+ throttle?: ThrottleConfigInput
321
400
  }
322
401
 
323
402
  /**
@@ -337,7 +416,7 @@ export type BlueprintPubSubFunctionConfig = Omit<BlueprintPubSubFunctionResource
337
416
  /**
338
417
  * Configuration for defining a durable function.
339
418
  * @public
340
- * @beta Deploying Durable Functions via Blueprints is experimental.
419
+ * @beta
341
420
  * @category Functions Types
342
421
  * @interface
343
422
  */
@@ -3,13 +3,14 @@ import type {BlueprintResource} from '../index.js'
3
3
  /**
4
4
  * Fields shared by every singleton installation config resource.
5
5
  *
6
+ * This feature is subject to breaking changes.
7
+ *
6
8
  * @remarks
7
9
  * The backend selects a provider from the resource `type`
8
10
  * (`sanity.installation.config`), so every installation config shares that one
9
11
  * type and is discriminated by `appType`.
10
- * @beta This feature is subject to breaking changes.
12
+ * @beta
11
13
  * @category Resource Types
12
- * @hidden
13
14
  */
14
15
  export interface BlueprintInstallationConfigResourceBase extends BlueprintResource {
15
16
  type: 'sanity.installation.config'
@@ -26,9 +27,10 @@ export interface BlueprintInstallationConfigResourceBase extends BlueprintResour
26
27
 
27
28
  /**
28
29
  * One custom field a Media Library configuration exposes.
29
- * @beta This feature is subject to breaking changes.
30
+ *
31
+ * This feature is subject to breaking changes.
32
+ * @beta
30
33
  * @category Resource Types
31
- * @hidden
32
34
  */
33
35
  export interface BlueprintMediaLibraryField {
34
36
  /** Unique within the Media Library config. */
@@ -47,14 +49,15 @@ export interface BlueprintMediaLibraryField {
47
49
  /**
48
50
  * Represents a singleton Media Library configuration resource.
49
51
  *
52
+ * This feature is subject to breaking changes.
53
+ *
50
54
  * @remarks
51
55
  * The Media Library is a Sanity-owned singleton, so this resource carries no
52
56
  * application identity of its own — it only names the target `appType`, the
53
57
  * config `root`, and its `fields`. The provider resolves the organization's
54
58
  * media library installation id at deploy time.
55
- * @beta This feature is subject to breaking changes.
59
+ * @beta
56
60
  * @category Resource Types
57
- * @hidden
58
61
  */
59
62
  export interface BlueprintMediaLibraryConfigResource extends BlueprintInstallationConfigResourceBase {
60
63
  /** The target installation this config applies to. Set by the definer. */
@@ -73,20 +76,20 @@ export interface BlueprintMediaLibraryConfigResource extends BlueprintInstallati
73
76
  /**
74
77
  * A union of every singleton installation config resource, discriminated by `appType`.
75
78
  *
79
+ * This feature is subject to breaking changes.
80
+ *
76
81
  * @remarks
77
82
  * Media Library is the only member today; additional installation configs are
78
83
  * added to this union.
79
- * @beta This feature is subject to breaking changes.
84
+ * @beta
80
85
  * @category Resource Types
81
- * @hidden
82
86
  */
83
87
  export type BlueprintInstallationConfigResource = BlueprintMediaLibraryConfigResource
84
88
 
85
89
  /**
86
90
  * Configuration for a singleton Media Library configuration resource.
87
- * @beta This feature is subject to breaking changes.
91
+ * @beta
88
92
  * @category Resource Types
89
93
  * @interface
90
- * @hidden
91
94
  */
92
- export type BlueprintMediaLibraryConfigConfig = Omit<BlueprintMediaLibraryConfigResource, 'type' | 'appType'>
95
+ export type BlueprintMediaLibraryConfigConfig = Omit<BlueprintMediaLibraryConfigResource, 'type' | 'appType' | 'version' | 'mfManifest'>
@@ -3,16 +3,20 @@ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../inde
3
3
  /**
4
4
  * The type of a custom permission.
5
5
  *
6
+ * This feature is subject to breaking changes.
7
+ *
6
8
  * - **sanity.document.filter** A role grants document actions, such as `read` and `update`, on the documents that match the filter.
7
9
  * - **sanity.document.filter.mode** A role grants the `mode` action, with a `mode` param such as `read` or `publish`, on the documents that match the filter.
8
- * @beta This feature is subject to breaking changes.
10
+ * @beta
9
11
  * @category Resource Types
10
12
  */
11
13
  export type BlueprintPermissionType = 'sanity.document.filter' | 'sanity.document.filter.mode'
12
14
 
13
15
  /**
14
16
  * A custom permission resource that roles can grant.
15
- * @beta This feature is subject to breaking changes.
17
+ *
18
+ * This feature is subject to breaking changes.
19
+ * @beta
16
20
  * @category Resource Types
17
21
  */
18
22
  export interface BlueprintPermissionResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
@@ -48,7 +52,7 @@ export interface BlueprintPermissionResource extends BlueprintResource<Blueprint
48
52
 
49
53
  /**
50
54
  * Configuration for a custom permission resource.
51
- * @beta This feature is subject to breaking changes.
55
+ * @beta
52
56
  * @category Resource Types
53
57
  * @interface
54
58
  */
@@ -56,7 +60,7 @@ export type BlueprintPermissionConfig = Omit<BlueprintPermissionResource, 'type'
56
60
 
57
61
  /**
58
62
  * Configuration for a content resource: a custom permission of type `sanity.document.filter.mode`, as the Manage UI makes it.
59
- * @beta This feature is subject to breaking changes.
63
+ * @beta
60
64
  * @category Resource Types
61
65
  */
62
66
  export interface BlueprintContentResourceConfig extends Omit<BlueprintPermissionConfig, 'permissionType' | 'config'> {
@@ -3,23 +3,25 @@ import type {BlueprintResource, BlueprintResourceLifecycle} from './resources.js
3
3
  /**
4
4
  * Reporesents a Sanity Project.
5
5
  * @see https://www.sanity.io/docs/http-reference/projects-api
6
- * @beta This feature is subject to breaking changes.
7
6
  * @category Resource Types
8
- * @hidden
9
7
  */
10
8
  export interface BlueprintProjectResource extends BlueprintResource<BlueprintResourceLifecycle> {
11
9
  type: 'sanity.project'
12
10
 
13
11
  /** The name of the project, defaults to the resource name if not provided */
14
12
  displayName?: string
13
+
14
+ /**
15
+ * Path to the logo image, relative to the blueprint file. Uploaded on every deploy; omitting it removes the logo.
16
+ * PNG, JPEG, BMP, GIF, TIFF, SVG, WebP, HEIF or AVIF, up to 5 MB.
17
+ */
18
+ logo?: string
15
19
  }
16
20
 
17
21
  /**
18
22
  * Configuration for a Sanity Project.
19
23
  * @see https://www.sanity.io/docs/http-reference/projects-api
20
- * @beta This feature is subject to breaking changes.
21
24
  * @category Resource Types
22
25
  * @interface
23
- * @hidden
24
26
  */
25
27
  export type BlueprintProjectConfig = Omit<BlueprintProjectResource, 'type'>
@@ -8,7 +8,6 @@ export type RobotTokenResourceType = 'organization' | 'project'
8
8
 
9
9
  /**
10
10
  * Defines the robot token's roles within a given resource. Membership scope defaults to the robot token's scope.
11
- * @beta This feature is subject to breaking changes.
12
11
  * @category Resource Types
13
12
  * @expand
14
13
  */
@@ -18,10 +17,20 @@ export interface RobotTokenMembership {
18
17
  roleNames: string[]
19
18
  }
20
19
 
20
+ /**
21
+ * A membership of a robot token, as passed to {@link defineRobotToken}.
22
+ * @category Resource Types
23
+ * @expand
24
+ * @interface
25
+ */
26
+ export type RobotTokenMembershipConfig = RobotTokenMembership & {
27
+ /** The ID of the project that the membership belongs to. Sets `resourceType` to `project` and `resourceId` to the project. */
28
+ project?: string
29
+ }
30
+
21
31
  /**
22
32
  * A robot token that provides automated access.
23
33
  * @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
24
- * @beta This feature is subject to breaking changes.
25
34
  * @category Resource Types
26
35
  */
27
36
  export interface BlueprintRobotTokenResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
@@ -37,14 +46,16 @@ export interface BlueprintRobotTokenResource extends BlueprintResource<Blueprint
37
46
  /**
38
47
  * Configuration for a robot token that provides automated access.
39
48
  * @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
40
- * @beta This feature is subject to breaking changes.
41
49
  * @category Resource Types
42
50
  * @interface
43
51
  */
44
- export type BlueprintRobotTokenConfig = Omit<BlueprintRobotTokenResource, 'type' | 'label' | 'token'> & {
52
+ export type BlueprintRobotTokenConfig = Omit<BlueprintRobotTokenResource, 'type' | 'label' | 'memberships'> & {
45
53
  /**
46
54
  * A descriptive label for the robot token and its use case
47
55
  * @defaultValue The `name` of the resource
48
56
  */
49
57
  label?: string
58
+ /** The ID of the project that the robot token belongs to. Sets `resourceType` to `project` and `resourceId` to the project. */
59
+ project?: string
60
+ memberships: RobotTokenMembershipConfig[]
50
61
  }
@@ -2,7 +2,6 @@ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../inde
2
2
 
3
3
  /**
4
4
  * A permission definition for a role.
5
- * @beta This feature is subject to breaking changes.
6
5
  * @category Resource Types
7
6
  * @expand
8
7
  */
@@ -16,11 +15,11 @@ export interface RolePermission {
16
15
  }
17
16
 
18
17
  /**
19
- * Configuration for a custom role.
20
- * @beta This feature is subject to breaking changes.
18
+ * A custom role resource
21
19
  * @category Resource Types
22
20
  */
23
- export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintProjectResourceLifecycle>, 'type'> {
21
+ export interface BlueprintRoleResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
22
+ type: 'sanity.access.role'
24
23
  title: string
25
24
  description?: string
26
25
  appliesToUsers: boolean
@@ -29,17 +28,19 @@ export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintPro
29
28
  }
30
29
 
31
30
  /**
32
- * A custom role resource
33
- * @beta This feature is subject to breaking changes.
31
+ * Configuration for a custom role.
34
32
  * @category Resource Types
35
33
  */
36
- export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintResource<BlueprintProjectResourceLifecycle> {
37
- type: 'sanity.access.role'
34
+ export interface BlueprintRoleConfig extends Omit<BlueprintRoleResource, 'type'> {
35
+ /**
36
+ * The ID of the project that the role belongs to. Without it, the role is scoped to the stack.
37
+ * Sets `resourceType` to `project` and `resourceId` to the project.
38
+ */
39
+ project?: string
38
40
  }
39
41
 
40
42
  /**
41
43
  * A custom role resource that is tied to a specific project
42
- * @beta This feature is subject to breaking changes.
43
44
  * @category Resource Types
44
45
  */
45
46
  export interface BlueprintProjectRoleResource extends BlueprintRoleResource {
@@ -5,51 +5,64 @@ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../inde
5
5
  /**
6
6
  * Custom Vite configuration for the Studio so it can be changed and extended.
7
7
  * This type matches the type in @sanity/cli-core and must continue to remain compatible.
8
- * @beta This feature is subject to breaking changes.
8
+ *
9
+ * This feature is subject to breaking changes.
10
+ * @beta
9
11
  * @category Resource Types
10
- * @hidden
11
12
  */
12
13
  export type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig
13
14
 
14
15
  /**
15
16
  * The set of valid application visibilities.
16
- * @beta This feature is subject to breaking changes.
17
+ *
18
+ * This feature is subject to breaking changes.
19
+ * @beta
17
20
  * @category Resource Types
18
- * @hidden
19
21
  */
20
22
  export const APPLICATION_VISIBILITIES = ['default', 'unlisted', 'disabled'] as const
21
23
 
22
24
  /**
23
25
  * The visibility of the studio in the dashboard.
24
- * @beta This feature is subject to breaking changes.
26
+ *
27
+ * This feature is subject to breaking changes.
28
+ * @beta
25
29
  * @category Resource Types
26
- * @hidden
27
30
  */
28
31
  export type ApplicationVisibility = (typeof APPLICATION_VISIBILITIES)[number]
29
32
 
30
33
  /**
31
34
  * A workspace definition extracted from a studio's configuration during the build.
32
- * @beta This feature is subject to breaking changes.
35
+ *
36
+ * This feature is subject to breaking changes.
37
+ * @beta
33
38
  * @category Resource Types
34
- * @hidden
35
39
  */
36
40
  export type StudioWorkspace = {
41
+ /** The project ID of the workspace */
37
42
  projectId: string
43
+ /** The dataset of the workspace */
38
44
  dataset: string
45
+ /** The ID of the deployed schema descriptor for the workspace */
39
46
  schemaDescriptorId: string
47
+ /** The workspace name */
40
48
  name: string
49
+ /** The workspace title */
41
50
  title: string | undefined
51
+ /** The workspace subtitle */
42
52
  subtitle: string | undefined
53
+ /** The workspace base path */
43
54
  basePath: string | undefined
55
+ /** The workspace icon */
44
56
  icon: string | undefined
45
57
  }
46
58
 
47
59
  /**
48
60
  * Represents a Studio resource.
61
+ *
62
+ * This feature is subject to breaking changes.
49
63
  * @see https://www.sanity.io/docs/studio
50
- * @beta This feature is subject to breaking changes.
64
+ * @beta
51
65
  * @category Resource Types
52
- * @hidden
53
66
  */
54
67
  export interface BlueprintStudioResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
55
68
  type: 'sanity.studio'
@@ -70,7 +83,10 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
70
83
  /** Title for the studio. */
71
84
  title: string
72
85
 
73
- /** Icon for the studio in the browser. */
86
+ /**
87
+ * Path to the icon image, relative to `root`. Uploaded on every deploy; omitting it removes the icon.
88
+ * PNG, JPEG, BMP, GIF, TIFF, SVG, WebP, HEIF or AVIF, up to 5 MB.
89
+ */
74
90
  icon?: string
75
91
 
76
92
  /** Dashboard visibility */
@@ -118,12 +134,15 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
118
134
  /**
119
135
  * Configuration for a Studio resource.
120
136
  * @see https://www.sanity.io/docs/studio
121
- * @beta This feature is subject to breaking changes.
137
+ * @beta
122
138
  * @category Resource Types
123
139
  * @interface
124
- * @hidden
125
140
  */
126
- export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type' | 'slug' | 'title' | 'autoUpdates'> {
141
+ export interface BlueprintStudioConfig
142
+ extends Omit<
143
+ BlueprintStudioResource,
144
+ 'type' | 'slug' | 'title' | 'autoUpdates' | 'schemaInputs' | 'workspaces' | 'mfManifest' | 'version'
145
+ > {
127
146
  /**
128
147
  * The slug to be used in the studio hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`.
129
148
  *
@@ -2,14 +2,12 @@ import type {BlueprintProjectResourceLifecycle, BlueprintResource} from '../inde
2
2
 
3
3
  /**
4
4
  * Types of events that can trigger a webhook
5
- * @beta This feature is subject to breaking changes.
6
5
  * @category Resource Types
7
6
  */
8
7
  export type WebhookTrigger = 'create' | 'update' | 'delete'
9
8
 
10
9
  /**
11
10
  * A webhook resource definition
12
- * @beta This feature is subject to breaking changes.
13
11
  * @category Resource Types
14
12
  */
15
13
  export interface BlueprintDocumentWebhookResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
@@ -38,7 +36,6 @@ export interface BlueprintDocumentWebhookResource extends BlueprintResource<Blue
38
36
 
39
37
  /**
40
38
  * Configuration for a webhook
41
- * @beta This feature is subject to breaking changes.
42
39
  * @category Resource Types
43
40
  * @interface
44
41
  */
@@ -1,4 +1,3 @@
1
- import type {BlueprintError} from '../types/errors.js'
2
1
  import type {DebounceConfig, DebounceInput} from '../types/functions/index.js'
3
2
  import {parseDuration} from './parse-duration.js'
4
3
 
@@ -27,27 +26,3 @@ export function createDebounceObject(debounce: DebounceInput): DebounceConfig {
27
26
  ...(key !== undefined && {key}),
28
27
  }
29
28
  }
30
-
31
- /**
32
- * Resolves a debounce duration, given either as a number of seconds or as a duration string, to seconds.
33
- * @param field The name of the field being resolved, used in error messages
34
- * @param value The value to resolve
35
- * @returns The value in seconds, or the errors that prevented it from being resolved
36
- */
37
- export function resolveDebounceDuration(field: string, value: unknown): {seconds?: number; errors: BlueprintError[]} {
38
- if (typeof value === 'number') {
39
- return Number.isFinite(value)
40
- ? {seconds: value, errors: []}
41
- : {errors: [{type: 'invalid_value', message: `\`${field}\` must be a valid duration`}]}
42
- }
43
-
44
- if (typeof value === 'string') {
45
- try {
46
- return {seconds: parseDuration(value, 's'), errors: []}
47
- } catch {
48
- return {errors: [{type: 'invalid_value', message: `\`${field}\` must be a valid duration`}]}
49
- }
50
- }
51
-
52
- return {errors: [{type: 'invalid_type', message: `\`${field}\` must be a number of seconds or a duration string`}]}
53
- }
@@ -1,4 +1,5 @@
1
1
  import parse from 'parse-duration'
2
+ import type {BlueprintError} from '../types/errors.js'
2
3
 
3
4
  type DurationUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'mo' | 'y'
4
5
 
@@ -36,3 +37,29 @@ export function parseDuration(duration: string | number, unit: DurationUnit = 's
36
37
 
37
38
  return parsed
38
39
  }
40
+
41
+ /**
42
+ * Resolves a duration field, given either as a number of seconds or as a duration string, to seconds.
43
+ * Unlike {@link parseDuration} this never throws, so validators can report the problem instead.
44
+ * @param field The name of the field being resolved, used in error messages
45
+ * @param value The value to resolve
46
+ * @internal
47
+ * @returns The value in seconds, or the errors that prevented it from being resolved
48
+ */
49
+ export function resolveDuration(field: string, value: unknown): {seconds?: number; errors: BlueprintError[]} {
50
+ if (typeof value === 'number') {
51
+ return Number.isFinite(value)
52
+ ? {seconds: value, errors: []}
53
+ : {errors: [{type: 'invalid_value', message: `\`${field}\` must be a valid duration`}]}
54
+ }
55
+
56
+ if (typeof value === 'string') {
57
+ try {
58
+ return {seconds: parseDuration(value, 's'), errors: []}
59
+ } catch {
60
+ return {errors: [{type: 'invalid_value', message: `\`${field}\` must be a valid duration`}]}
61
+ }
62
+ }
63
+
64
+ return {errors: [{type: 'invalid_type', message: `\`${field}\` must be a number of seconds or a duration string`}]}
65
+ }
@@ -0,0 +1,25 @@
1
+ import type {ThrottleConfig, ThrottleConfigInput} from '../types/functions/index.js'
2
+ import {parseDuration} from './parse-duration.js'
3
+
4
+ /**
5
+ * Normalizes the throttle config accepted by a definer into the shape held by a resource,
6
+ * parsing `period` into seconds.
7
+ * @param throttle The throttle config to normalize
8
+ * @internal
9
+ * @returns The throttle config, with `period` in seconds
10
+ */
11
+ export function createThrottleObject(throttle: ThrottleConfigInput): ThrottleConfig {
12
+ const {limit, period, burst, key} = throttle
13
+
14
+ // `period` is required, so there is nothing sensible to parse without it
15
+ if (period === undefined) {
16
+ throw new Error('Invalid throttle config: `period` must be provided')
17
+ }
18
+
19
+ return {
20
+ limit,
21
+ period: parseDuration(period, 's'),
22
+ ...(burst !== undefined && {burst}),
23
+ ...(key !== undefined && {key}),
24
+ }
25
+ }