@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
|
@@ -2,11 +2,12 @@ import type { BlueprintResource } from '../../index.js';
|
|
|
2
2
|
import type { BlueprintDocumentFunctionResourceEvent, BlueprintFunctionResourceContentLakeEvent, BlueprintMediaLibraryFunctionResourceEvent, BlueprintScheduledFunctionConfigEvent, BlueprintScheduledFunctionResourceEvent, BlueprintSyncTagInvalidateFunctionResourceEvent } from './event.js';
|
|
3
3
|
import type { IanaTimezone } from './timezone.js';
|
|
4
4
|
export * from './event.js';
|
|
5
|
+
export * from './timezone.js';
|
|
5
6
|
/**
|
|
6
7
|
* Supported Function runtimes
|
|
7
8
|
* @category Functions Types
|
|
8
9
|
*/
|
|
9
|
-
export declare const VALID_RUNTIMES: readonly ['node', 'nodejs22.x', 'nodejs24.x'];
|
|
10
|
+
export declare const VALID_RUNTIMES: readonly ['node', 'nodejs22.x', 'nodejs24.x', 'nodejs26.x'];
|
|
10
11
|
/**
|
|
11
12
|
* Supported function runtimes
|
|
12
13
|
* @category Functions Types
|
|
@@ -31,7 +32,7 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
|
|
|
31
32
|
robotToken?: string;
|
|
32
33
|
/**
|
|
33
34
|
* The runtime environment for the function (currently only Node.js is supported)
|
|
34
|
-
* @defaultValue '
|
|
35
|
+
* @defaultValue 'nodejs26.x'
|
|
35
36
|
*/
|
|
36
37
|
runtime?: FunctionRuntimes;
|
|
37
38
|
}
|
|
@@ -53,12 +54,6 @@ interface QueueConfig {
|
|
|
53
54
|
* Definers accept the wider {@link DebounceInput} and parse it into this shape.
|
|
54
55
|
*/
|
|
55
56
|
debounce?: DebounceConfig;
|
|
56
|
-
/**
|
|
57
|
-
* Whether to place messages that failed processing into a Dead Letter Queue.
|
|
58
|
-
* @todo: not implemented
|
|
59
|
-
* @default `false`
|
|
60
|
-
*/
|
|
61
|
-
dlq?: boolean;
|
|
62
57
|
/**
|
|
63
58
|
* By default, queues employ at-least once delivery. When set to `true`, employs first-in-first-out ordering and exactly-once delivery.
|
|
64
59
|
* FIFO queues have a lower transaction-per-second limit.
|
|
@@ -67,6 +62,46 @@ interface QueueConfig {
|
|
|
67
62
|
*/
|
|
68
63
|
fifo?: boolean;
|
|
69
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Configuration used when throttling Queue function types.
|
|
67
|
+
* Starts at most `limit` messages per `period`; messages over the rate stay queued and are delivered late, not dropped.
|
|
68
|
+
* @category Functions Types
|
|
69
|
+
* @alpha
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
export interface ThrottleConfig {
|
|
73
|
+
/**
|
|
74
|
+
* Maximum number of messages started per `period`
|
|
75
|
+
*/
|
|
76
|
+
limit: number;
|
|
77
|
+
/**
|
|
78
|
+
* Length of the throttle period in seconds
|
|
79
|
+
*/
|
|
80
|
+
period: number;
|
|
81
|
+
/**
|
|
82
|
+
* Number of messages an idle queue may release at once before pacing resumes.
|
|
83
|
+
* Must not be greater than `limit`.
|
|
84
|
+
*/
|
|
85
|
+
burst?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Dotted path into `{event, context}`, e.g. `event.data.tenantId`; each distinct value is throttled in its own bucket.
|
|
88
|
+
* When omitted, the whole function is throttled as one bucket.
|
|
89
|
+
*/
|
|
90
|
+
key?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Throttle configuration as accepted by a function definer, before durations are parsed.
|
|
94
|
+
* @category Functions Types
|
|
95
|
+
* @alpha
|
|
96
|
+
* @hidden
|
|
97
|
+
*/
|
|
98
|
+
export interface ThrottleConfigInput extends Omit<ThrottleConfig, 'period'> {
|
|
99
|
+
/**
|
|
100
|
+
* Length of the throttle period.
|
|
101
|
+
* A number is read as seconds, a string is parsed as a duration, e.g. `'1 minute'`.
|
|
102
|
+
*/
|
|
103
|
+
period: string | number;
|
|
104
|
+
}
|
|
70
105
|
/**
|
|
71
106
|
* Configuration used when debouncing Queue or Workflow function types.
|
|
72
107
|
* @category Functions Types
|
|
@@ -83,7 +118,7 @@ export interface DebounceConfig {
|
|
|
83
118
|
*/
|
|
84
119
|
maxWindow?: number;
|
|
85
120
|
/**
|
|
86
|
-
* Dotted path into {event, context} used to
|
|
121
|
+
* Dotted path into `{event, context}` used to group debounced events, e.g. `event.data.documentId`
|
|
87
122
|
*/
|
|
88
123
|
key?: string;
|
|
89
124
|
}
|
|
@@ -101,7 +136,7 @@ export interface DebounceConfigInput extends Omit<DebounceConfig, 'window' | 'ma
|
|
|
101
136
|
window: string | number;
|
|
102
137
|
/**
|
|
103
138
|
* Maximum time to extend a debounce window from the first event.
|
|
104
|
-
* Must be greater than `window`.
|
|
139
|
+
* Must be greater than or equal to `window`.
|
|
105
140
|
* A number is read as seconds, a string is parsed as a duration, e.g. `'1 hour'`.
|
|
106
141
|
*/
|
|
107
142
|
maxWindow?: string | number;
|
|
@@ -170,6 +205,17 @@ export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionRes
|
|
|
170
205
|
type: 'sanity.function.queue';
|
|
171
206
|
/** Optional Content Lake event source that triggers the function */
|
|
172
207
|
event?: BlueprintFunctionResourceContentLakeEvent;
|
|
208
|
+
/**
|
|
209
|
+
* Total delivery attempts per message, at most 1000: `1` delivers once and never retries, `3` delivers once and retries twice.
|
|
210
|
+
* Messages that use up their attempts are moved to a Dead Letter Queue.
|
|
211
|
+
* When omitted, a message is redelivered until the queue's retention period expires.
|
|
212
|
+
*/
|
|
213
|
+
maxAttempts?: number;
|
|
214
|
+
/**
|
|
215
|
+
* Throttle configuration, with `period` already resolved to seconds.
|
|
216
|
+
* Definers accept the wider {@link ThrottleConfigInput} and parse it into this shape.
|
|
217
|
+
*/
|
|
218
|
+
throttle?: ThrottleConfig;
|
|
173
219
|
}
|
|
174
220
|
/**
|
|
175
221
|
* A function resource triggered by another function
|
|
@@ -180,7 +226,9 @@ export interface BlueprintPubSubFunctionResource extends BlueprintBaseFunctionRe
|
|
|
180
226
|
}
|
|
181
227
|
/**
|
|
182
228
|
* A durable, step-based function.
|
|
183
|
-
*
|
|
229
|
+
*
|
|
230
|
+
* Deploying Durable Functions via Blueprints is experimental.
|
|
231
|
+
* @beta
|
|
184
232
|
* @category Functions Types
|
|
185
233
|
*/
|
|
186
234
|
export interface BlueprintDurableFunctionResource extends BlueprintBaseFunctionResource {
|
|
@@ -268,12 +316,12 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
|
|
|
268
316
|
/**
|
|
269
317
|
* Configuration for defining a queue function.
|
|
270
318
|
* @public
|
|
271
|
-
* @alpha
|
|
319
|
+
* @alpha
|
|
272
320
|
* @hidden
|
|
273
321
|
* @category Functions Types
|
|
274
322
|
* @interface
|
|
275
323
|
*/
|
|
276
|
-
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event' | 'debounce'> & {
|
|
324
|
+
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event' | 'debounce' | 'throttle'> & {
|
|
277
325
|
/**
|
|
278
326
|
* Path to the function source code
|
|
279
327
|
* @defaultValue `functions/${name}`
|
|
@@ -283,6 +331,8 @@ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource,
|
|
|
283
331
|
event?: BlueprintFunctionResourceContentLakeEvent;
|
|
284
332
|
/** Optional debounce configuration, as a duration or a full config */
|
|
285
333
|
debounce?: DebounceInput;
|
|
334
|
+
/** Optional throttle configuration */
|
|
335
|
+
throttle?: ThrottleConfigInput;
|
|
286
336
|
};
|
|
287
337
|
/**
|
|
288
338
|
* Configuration for defining an event function.
|
|
@@ -300,7 +350,7 @@ export type BlueprintPubSubFunctionConfig = Omit<BlueprintPubSubFunctionResource
|
|
|
300
350
|
/**
|
|
301
351
|
* Configuration for defining a durable function.
|
|
302
352
|
* @public
|
|
303
|
-
* @beta
|
|
353
|
+
* @beta
|
|
304
354
|
* @category Functions Types
|
|
305
355
|
* @interface
|
|
306
356
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './event.js';
|
|
2
|
+
export * from './timezone.js';
|
|
2
3
|
/**
|
|
3
4
|
* Supported Function runtimes
|
|
4
5
|
* @category Functions Types
|
|
5
6
|
*/
|
|
6
|
-
export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x'];
|
|
7
|
+
export const VALID_RUNTIMES = ['node', 'nodejs22.x', 'nodejs24.x', 'nodejs26.x'];
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/functions/index.ts"],"names":[],"mappings":"AAWA,cAAc,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/functions/index.ts"],"names":[],"mappings":"AAWA,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAE7B;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,CAAU,CAAA"}
|
|
@@ -2,13 +2,14 @@ import type { BlueprintResource } from '../index.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Fields shared by every singleton installation config resource.
|
|
4
4
|
*
|
|
5
|
+
* This feature is subject to breaking changes.
|
|
6
|
+
*
|
|
5
7
|
* @remarks
|
|
6
8
|
* The backend selects a provider from the resource `type`
|
|
7
9
|
* (`sanity.installation.config`), so every installation config shares that one
|
|
8
10
|
* type and is discriminated by `appType`.
|
|
9
|
-
* @beta
|
|
11
|
+
* @beta
|
|
10
12
|
* @category Resource Types
|
|
11
|
-
* @hidden
|
|
12
13
|
*/
|
|
13
14
|
export interface BlueprintInstallationConfigResourceBase extends BlueprintResource {
|
|
14
15
|
type: 'sanity.installation.config';
|
|
@@ -22,9 +23,10 @@ export interface BlueprintInstallationConfigResourceBase extends BlueprintResour
|
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* One custom field a Media Library configuration exposes.
|
|
25
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* This feature is subject to breaking changes.
|
|
28
|
+
* @beta
|
|
26
29
|
* @category Resource Types
|
|
27
|
-
* @hidden
|
|
28
30
|
*/
|
|
29
31
|
export interface BlueprintMediaLibraryField {
|
|
30
32
|
/** Unique within the Media Library config. */
|
|
@@ -39,14 +41,15 @@ export interface BlueprintMediaLibraryField {
|
|
|
39
41
|
/**
|
|
40
42
|
* Represents a singleton Media Library configuration resource.
|
|
41
43
|
*
|
|
44
|
+
* This feature is subject to breaking changes.
|
|
45
|
+
*
|
|
42
46
|
* @remarks
|
|
43
47
|
* The Media Library is a Sanity-owned singleton, so this resource carries no
|
|
44
48
|
* application identity of its own — it only names the target `appType`, the
|
|
45
49
|
* config `root`, and its `fields`. The provider resolves the organization's
|
|
46
50
|
* media library installation id at deploy time.
|
|
47
|
-
* @beta
|
|
51
|
+
* @beta
|
|
48
52
|
* @category Resource Types
|
|
49
|
-
* @hidden
|
|
50
53
|
*/
|
|
51
54
|
export interface BlueprintMediaLibraryConfigResource extends BlueprintInstallationConfigResourceBase {
|
|
52
55
|
/** The target installation this config applies to. Set by the definer. */
|
|
@@ -61,19 +64,19 @@ export interface BlueprintMediaLibraryConfigResource extends BlueprintInstallati
|
|
|
61
64
|
/**
|
|
62
65
|
* A union of every singleton installation config resource, discriminated by `appType`.
|
|
63
66
|
*
|
|
67
|
+
* This feature is subject to breaking changes.
|
|
68
|
+
*
|
|
64
69
|
* @remarks
|
|
65
70
|
* Media Library is the only member today; additional installation configs are
|
|
66
71
|
* added to this union.
|
|
67
|
-
* @beta
|
|
72
|
+
* @beta
|
|
68
73
|
* @category Resource Types
|
|
69
|
-
* @hidden
|
|
70
74
|
*/
|
|
71
75
|
export type BlueprintInstallationConfigResource = BlueprintMediaLibraryConfigResource;
|
|
72
76
|
/**
|
|
73
77
|
* Configuration for a singleton Media Library configuration resource.
|
|
74
|
-
* @beta
|
|
78
|
+
* @beta
|
|
75
79
|
* @category Resource Types
|
|
76
80
|
* @interface
|
|
77
|
-
* @hidden
|
|
78
81
|
*/
|
|
79
82
|
export type BlueprintMediaLibraryConfigConfig = Omit<BlueprintMediaLibraryConfigResource, 'type' | 'appType'>;
|
|
@@ -2,15 +2,19 @@ import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../in
|
|
|
2
2
|
/**
|
|
3
3
|
* The type of a custom permission.
|
|
4
4
|
*
|
|
5
|
+
* This feature is subject to breaking changes.
|
|
6
|
+
*
|
|
5
7
|
* - **sanity.document.filter** A role grants document actions, such as `read` and `update`, on the documents that match the filter.
|
|
6
8
|
* - **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.
|
|
7
|
-
* @beta
|
|
9
|
+
* @beta
|
|
8
10
|
* @category Resource Types
|
|
9
11
|
*/
|
|
10
12
|
export type BlueprintPermissionType = 'sanity.document.filter' | 'sanity.document.filter.mode';
|
|
11
13
|
/**
|
|
12
14
|
* A custom permission resource that roles can grant.
|
|
13
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* This feature is subject to breaking changes.
|
|
17
|
+
* @beta
|
|
14
18
|
* @category Resource Types
|
|
15
19
|
*/
|
|
16
20
|
export interface BlueprintPermissionResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
@@ -45,14 +49,14 @@ export interface BlueprintPermissionResource extends BlueprintResource<Blueprint
|
|
|
45
49
|
}
|
|
46
50
|
/**
|
|
47
51
|
* Configuration for a custom permission resource.
|
|
48
|
-
* @beta
|
|
52
|
+
* @beta
|
|
49
53
|
* @category Resource Types
|
|
50
54
|
* @interface
|
|
51
55
|
*/
|
|
52
56
|
export type BlueprintPermissionConfig = Omit<BlueprintPermissionResource, 'type'>;
|
|
53
57
|
/**
|
|
54
58
|
* Configuration for a content resource: a custom permission of type `sanity.document.filter.mode`, as the Manage UI makes it.
|
|
55
|
-
* @beta
|
|
59
|
+
* @beta
|
|
56
60
|
* @category Resource Types
|
|
57
61
|
*/
|
|
58
62
|
export interface BlueprintContentResourceConfig extends Omit<BlueprintPermissionConfig, 'permissionType' | 'config'> {
|
package/dist/types/projects.d.ts
CHANGED
|
@@ -2,21 +2,22 @@ import type { BlueprintResource, BlueprintResourceLifecycle } from './resources.
|
|
|
2
2
|
/**
|
|
3
3
|
* Reporesents a Sanity Project.
|
|
4
4
|
* @see https://www.sanity.io/docs/http-reference/projects-api
|
|
5
|
-
* @beta This feature is subject to breaking changes.
|
|
6
5
|
* @category Resource Types
|
|
7
|
-
* @hidden
|
|
8
6
|
*/
|
|
9
7
|
export interface BlueprintProjectResource extends BlueprintResource<BlueprintResourceLifecycle> {
|
|
10
8
|
type: 'sanity.project';
|
|
11
9
|
/** The name of the project, defaults to the resource name if not provided */
|
|
12
10
|
displayName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Path to the logo image, relative to the blueprint file. Uploaded on every deploy; omitting it removes the logo.
|
|
13
|
+
* PNG, JPEG, BMP, GIF, TIFF, SVG, WebP, HEIF or AVIF, up to 5 MB.
|
|
14
|
+
*/
|
|
15
|
+
logo?: string;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* Configuration for a Sanity Project.
|
|
16
19
|
* @see https://www.sanity.io/docs/http-reference/projects-api
|
|
17
|
-
* @beta This feature is subject to breaking changes.
|
|
18
20
|
* @category Resource Types
|
|
19
21
|
* @interface
|
|
20
|
-
* @hidden
|
|
21
22
|
*/
|
|
22
23
|
export type BlueprintProjectConfig = Omit<BlueprintProjectResource, 'type'>;
|
|
@@ -6,7 +6,6 @@ import type { BlueprintProjectResourceLifecycle, BlueprintResource } from './res
|
|
|
6
6
|
export type RobotTokenResourceType = 'organization' | 'project';
|
|
7
7
|
/**
|
|
8
8
|
* Defines the robot token's roles within a given resource. Membership scope defaults to the robot token's scope.
|
|
9
|
-
* @beta This feature is subject to breaking changes.
|
|
10
9
|
* @category Resource Types
|
|
11
10
|
* @expand
|
|
12
11
|
*/
|
|
@@ -18,7 +17,6 @@ export interface RobotTokenMembership {
|
|
|
18
17
|
/**
|
|
19
18
|
* A robot token that provides automated access.
|
|
20
19
|
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
21
|
-
* @beta This feature is subject to breaking changes.
|
|
22
20
|
* @category Resource Types
|
|
23
21
|
*/
|
|
24
22
|
export interface BlueprintRobotTokenResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
@@ -32,7 +30,6 @@ export interface BlueprintRobotTokenResource extends BlueprintResource<Blueprint
|
|
|
32
30
|
/**
|
|
33
31
|
* Configuration for a robot token that provides automated access.
|
|
34
32
|
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
35
|
-
* @beta This feature is subject to breaking changes.
|
|
36
33
|
* @category Resource Types
|
|
37
34
|
* @interface
|
|
38
35
|
*/
|
package/dist/types/roles.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* A permission definition for a role.
|
|
4
|
-
* @beta This feature is subject to breaking changes.
|
|
5
4
|
* @category Resource Types
|
|
6
5
|
* @expand
|
|
7
6
|
*/
|
|
@@ -15,7 +14,6 @@ export interface RolePermission {
|
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* Configuration for a custom role.
|
|
18
|
-
* @beta This feature is subject to breaking changes.
|
|
19
17
|
* @category Resource Types
|
|
20
18
|
*/
|
|
21
19
|
export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintProjectResourceLifecycle>, 'type'> {
|
|
@@ -27,7 +25,6 @@ export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintPro
|
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* A custom role resource
|
|
30
|
-
* @beta This feature is subject to breaking changes.
|
|
31
28
|
* @category Resource Types
|
|
32
29
|
*/
|
|
33
30
|
export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
@@ -35,7 +32,6 @@ export interface BlueprintRoleResource extends BlueprintRoleConfig, BlueprintRes
|
|
|
35
32
|
}
|
|
36
33
|
/**
|
|
37
34
|
* A custom role resource that is tied to a specific project
|
|
38
|
-
* @beta This feature is subject to breaking changes.
|
|
39
35
|
* @category Resource Types
|
|
40
36
|
*/
|
|
41
37
|
export interface BlueprintProjectRoleResource extends BlueprintRoleResource {
|
package/dist/types/studios.d.ts
CHANGED
|
@@ -4,47 +4,60 @@ import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../in
|
|
|
4
4
|
/**
|
|
5
5
|
* Custom Vite configuration for the Studio so it can be changed and extended.
|
|
6
6
|
* This type matches the type in @sanity/cli-core and must continue to remain compatible.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* This feature is subject to breaking changes.
|
|
9
|
+
* @beta
|
|
8
10
|
* @category Resource Types
|
|
9
|
-
* @hidden
|
|
10
11
|
*/
|
|
11
12
|
export type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig;
|
|
12
13
|
/**
|
|
13
14
|
* The set of valid application visibilities.
|
|
14
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* This feature is subject to breaking changes.
|
|
17
|
+
* @beta
|
|
15
18
|
* @category Resource Types
|
|
16
|
-
* @hidden
|
|
17
19
|
*/
|
|
18
20
|
export declare const APPLICATION_VISIBILITIES: readonly ['default', 'unlisted', 'disabled'];
|
|
19
21
|
/**
|
|
20
22
|
* The visibility of the studio in the dashboard.
|
|
21
|
-
*
|
|
23
|
+
*
|
|
24
|
+
* This feature is subject to breaking changes.
|
|
25
|
+
* @beta
|
|
22
26
|
* @category Resource Types
|
|
23
|
-
* @hidden
|
|
24
27
|
*/
|
|
25
28
|
export type ApplicationVisibility = (typeof APPLICATION_VISIBILITIES)[number];
|
|
26
29
|
/**
|
|
27
30
|
* A workspace definition extracted from a studio's configuration during the build.
|
|
28
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* This feature is subject to breaking changes.
|
|
33
|
+
* @beta
|
|
29
34
|
* @category Resource Types
|
|
30
|
-
* @hidden
|
|
31
35
|
*/
|
|
32
36
|
export type StudioWorkspace = {
|
|
37
|
+
/** The project ID of the workspace */
|
|
33
38
|
projectId: string;
|
|
39
|
+
/** The dataset of the workspace */
|
|
34
40
|
dataset: string;
|
|
41
|
+
/** The ID of the deployed schema descriptor for the workspace */
|
|
35
42
|
schemaDescriptorId: string;
|
|
43
|
+
/** The workspace name */
|
|
36
44
|
name: string;
|
|
45
|
+
/** The workspace title */
|
|
37
46
|
title: string | undefined;
|
|
47
|
+
/** The workspace subtitle */
|
|
38
48
|
subtitle: string | undefined;
|
|
49
|
+
/** The workspace base path */
|
|
39
50
|
basePath: string | undefined;
|
|
51
|
+
/** The workspace icon */
|
|
40
52
|
icon: string | undefined;
|
|
41
53
|
};
|
|
42
54
|
/**
|
|
43
55
|
* Represents a Studio resource.
|
|
56
|
+
*
|
|
57
|
+
* This feature is subject to breaking changes.
|
|
44
58
|
* @see https://www.sanity.io/docs/studio
|
|
45
|
-
* @beta
|
|
59
|
+
* @beta
|
|
46
60
|
* @category Resource Types
|
|
47
|
-
* @hidden
|
|
48
61
|
*/
|
|
49
62
|
export interface BlueprintStudioResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
50
63
|
type: 'sanity.studio';
|
|
@@ -60,7 +73,10 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
60
73
|
slug: string;
|
|
61
74
|
/** Title for the studio. */
|
|
62
75
|
title: string;
|
|
63
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Path to the icon image, relative to `root`. Uploaded on every deploy; omitting it removes the icon.
|
|
78
|
+
* PNG, JPEG, BMP, GIF, TIFF, SVG, WebP, HEIF or AVIF, up to 5 MB.
|
|
79
|
+
*/
|
|
64
80
|
icon?: string;
|
|
65
81
|
/** Dashboard visibility */
|
|
66
82
|
visibility?: ApplicationVisibility;
|
|
@@ -73,8 +89,6 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
73
89
|
/** What "version"/"channel" to use for auto updates */
|
|
74
90
|
version?: string;
|
|
75
91
|
};
|
|
76
|
-
/** The base path of the studio URL. Defaults to '/' */
|
|
77
|
-
basePath?: string;
|
|
78
92
|
/** Whether or not to minify the source code. Defaults to true. */
|
|
79
93
|
minify?: boolean;
|
|
80
94
|
/** Whether or not to configure the reactCompiler. Defaults to false. */
|
|
@@ -98,10 +112,9 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
98
112
|
/**
|
|
99
113
|
* Configuration for a Studio resource.
|
|
100
114
|
* @see https://www.sanity.io/docs/studio
|
|
101
|
-
* @beta
|
|
115
|
+
* @beta
|
|
102
116
|
* @category Resource Types
|
|
103
117
|
* @interface
|
|
104
|
-
* @hidden
|
|
105
118
|
*/
|
|
106
119
|
export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type' | 'slug' | 'title' | 'autoUpdates'> {
|
|
107
120
|
/**
|
package/dist/types/studios.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The set of valid application visibilities.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This feature is subject to breaking changes.
|
|
5
|
+
* @beta
|
|
4
6
|
* @category Resource Types
|
|
5
|
-
* @hidden
|
|
6
7
|
*/
|
|
7
8
|
export const APPLICATION_VISIBILITIES = ['default', 'unlisted', 'disabled'];
|
|
8
9
|
//# sourceMappingURL=studios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studios.js","sourceRoot":"","sources":["../../src/types/studios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studios.js","sourceRoot":"","sources":["../../src/types/studios.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAA"}
|
package/dist/types/webhooks.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Types of events that can trigger a webhook
|
|
4
|
-
* @beta This feature is subject to breaking changes.
|
|
5
4
|
* @category Resource Types
|
|
6
5
|
*/
|
|
7
6
|
export type WebhookTrigger = 'create' | 'update' | 'delete';
|
|
8
7
|
/**
|
|
9
8
|
* A webhook resource definition
|
|
10
|
-
* @beta This feature is subject to breaking changes.
|
|
11
9
|
* @category Resource Types
|
|
12
10
|
*/
|
|
13
11
|
export interface BlueprintDocumentWebhookResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
@@ -35,7 +33,6 @@ export interface BlueprintDocumentWebhookResource extends BlueprintResource<Blue
|
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
35
|
* Configuration for a webhook
|
|
38
|
-
* @beta This feature is subject to breaking changes.
|
|
39
36
|
* @category Resource Types
|
|
40
37
|
* @interface
|
|
41
38
|
*/
|
package/dist/utils/debounce.d.ts
CHANGED
|
@@ -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
|
/**
|
|
4
3
|
* Normalizes the debounce config accepted by a definer into the shape held by a resource,
|
|
@@ -8,13 +7,3 @@ import type { DebounceConfig, DebounceInput } from '../types/functions/index.js'
|
|
|
8
7
|
* @returns The debounce config, with `window` and `maxWindow` in seconds
|
|
9
8
|
*/
|
|
10
9
|
export declare function createDebounceObject(debounce: DebounceInput): DebounceConfig;
|
|
11
|
-
/**
|
|
12
|
-
* Resolves a debounce duration, given either as a number of seconds or as a duration string, to seconds.
|
|
13
|
-
* @param field The name of the field being resolved, used in error messages
|
|
14
|
-
* @param value The value to resolve
|
|
15
|
-
* @returns The value in seconds, or the errors that prevented it from being resolved
|
|
16
|
-
*/
|
|
17
|
-
export declare function resolveDebounceDuration(field: string, value: unknown): {
|
|
18
|
-
seconds?: number;
|
|
19
|
-
errors: BlueprintError[];
|
|
20
|
-
};
|
package/dist/utils/debounce.js
CHANGED
|
@@ -21,26 +21,4 @@ export function createDebounceObject(debounce) {
|
|
|
21
21
|
...(key !== undefined && { key }),
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Resolves a debounce duration, given either as a number of seconds or as a duration string, to seconds.
|
|
26
|
-
* @param field The name of the field being resolved, used in error messages
|
|
27
|
-
* @param value The value to resolve
|
|
28
|
-
* @returns The value in seconds, or the errors that prevented it from being resolved
|
|
29
|
-
*/
|
|
30
|
-
export function resolveDebounceDuration(field, value) {
|
|
31
|
-
if (typeof value === 'number') {
|
|
32
|
-
return Number.isFinite(value)
|
|
33
|
-
? { seconds: value, errors: [] }
|
|
34
|
-
: { errors: [{ type: 'invalid_value', message: `\`${field}\` must be a valid duration` }] };
|
|
35
|
-
}
|
|
36
|
-
if (typeof value === 'string') {
|
|
37
|
-
try {
|
|
38
|
-
return { seconds: parseDuration(value, 's'), errors: [] };
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return { errors: [{ type: 'invalid_value', message: `\`${field}\` must be a valid duration` }] };
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return { errors: [{ type: 'invalid_type', message: `\`${field}\` must be a number of seconds or a duration string` }] };
|
|
45
|
-
}
|
|
46
24
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/utils/debounce.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAuB;IAC1D,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAC,CAAA;IAC/C,CAAC;IAED,MAAM,EAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAC,GAAG,QAAQ,CAAA;IAEzC,yEAAyE;IACzE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;IACvE,CAAC;IAED,OAAO;QACL,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC;QAClC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAC,SAAS,EAAE,aAAa,CAAC,SAAS,EAAE,GAAG,CAAC,EAAC,CAAC;QAC1E,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,EAAC,GAAG,EAAC,CAAC;KAChC,CAAA;AACH,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BlueprintError } from '../types/errors.js';
|
|
1
2
|
type DurationUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'mo' | 'y';
|
|
2
3
|
/**
|
|
3
4
|
* Small parse-duration wrapper for string or number
|
|
@@ -6,4 +7,16 @@ type DurationUnit = 'ms' | 's' | 'm' | 'h' | 'd' | 'w' | 'mo' | 'y';
|
|
|
6
7
|
* @return parsed number in the specified unit
|
|
7
8
|
*/
|
|
8
9
|
export declare function parseDuration(duration: string | number, unit?: DurationUnit): number;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a duration field, given either as a number of seconds or as a duration string, to seconds.
|
|
12
|
+
* Unlike {@link parseDuration} this never throws, so validators can report the problem instead.
|
|
13
|
+
* @param field The name of the field being resolved, used in error messages
|
|
14
|
+
* @param value The value to resolve
|
|
15
|
+
* @internal
|
|
16
|
+
* @returns The value in seconds, or the errors that prevented it from being resolved
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveDuration(field: string, value: unknown): {
|
|
19
|
+
seconds?: number;
|
|
20
|
+
errors: BlueprintError[];
|
|
21
|
+
};
|
|
9
22
|
export {};
|
|
@@ -27,4 +27,28 @@ export function parseDuration(duration, unit = 's') {
|
|
|
27
27
|
}
|
|
28
28
|
return parsed;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolves a duration field, given either as a number of seconds or as a duration string, to seconds.
|
|
32
|
+
* Unlike {@link parseDuration} this never throws, so validators can report the problem instead.
|
|
33
|
+
* @param field The name of the field being resolved, used in error messages
|
|
34
|
+
* @param value The value to resolve
|
|
35
|
+
* @internal
|
|
36
|
+
* @returns The value in seconds, or the errors that prevented it from being resolved
|
|
37
|
+
*/
|
|
38
|
+
export function resolveDuration(field, value) {
|
|
39
|
+
if (typeof value === 'number') {
|
|
40
|
+
return Number.isFinite(value)
|
|
41
|
+
? { seconds: value, errors: [] }
|
|
42
|
+
: { errors: [{ type: 'invalid_value', message: `\`${field}\` must be a valid duration` }] };
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === 'string') {
|
|
45
|
+
try {
|
|
46
|
+
return { seconds: parseDuration(value, 's'), errors: [] };
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return { errors: [{ type: 'invalid_value', message: `\`${field}\` must be a valid duration` }] };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return { errors: [{ type: 'invalid_type', message: `\`${field}\` must be a number of seconds or a duration string` }] };
|
|
53
|
+
}
|
|
30
54
|
//# sourceMappingURL=parse-duration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-duration.js","sourceRoot":"","sources":["../../src/utils/parse-duration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"parse-duration.js","sourceRoot":"","sources":["../../src/utils/parse-duration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAKlC,MAAM,WAAW,GAAG,UAAU,CAAA;AAC9B,MAAM,UAAU,GAAG,WAAW,GAAG,IAAI,CAAA;AACrC,MAAM,KAAK,GAAG,KAAK,CAAC,IAA8B,CAAA;AAElD,wGAAwG;AACxG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;IACnB,IAAI,EAAE,UAAU;IAChB,EAAE,EAAE,UAAU;IACd,CAAC,EAAE,UAAU;IAEb,KAAK,EAAE,UAAU,GAAG,EAAE;IACtB,GAAG,EAAE,UAAU,GAAG,EAAE;IACpB,EAAE,EAAE,UAAU,GAAG,EAAE;IAEnB,IAAI,EAAE,UAAU,GAAG,EAAE;IACrB,EAAE,EAAE,UAAU,GAAG,EAAE;IACnB,CAAC,EAAE,UAAU,GAAG,EAAE;CACnB,CAAC,CAAA;AAEF;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB,EAAE,IAAI,GAAiB,GAAG;IAC/E,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAE9E,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,KAAc;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC3B,CAAC,CAAC,EAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAC;YAC9B,CAAC,CAAC,EAAC,MAAM,EAAE,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,KAAK,6BAA6B,EAAC,CAAC,EAAC,CAAA;IAC3F,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,OAAO,EAAC,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAC,CAAA;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAC,MAAM,EAAE,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,KAAK,6BAA6B,EAAC,CAAC,EAAC,CAAA;QAC9F,CAAC;IACH,CAAC;IAED,OAAO,EAAC,MAAM,EAAE,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,KAAK,qDAAqD,EAAC,CAAC,EAAC,CAAA;AACrH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ThrottleConfig, ThrottleConfigInput } from '../types/functions/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes the throttle config accepted by a definer into the shape held by a resource,
|
|
4
|
+
* parsing `period` into seconds.
|
|
5
|
+
* @param throttle The throttle config to normalize
|
|
6
|
+
* @internal
|
|
7
|
+
* @returns The throttle config, with `period` in seconds
|
|
8
|
+
*/
|
|
9
|
+
export declare function createThrottleObject(throttle: ThrottleConfigInput): ThrottleConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { parseDuration } from './parse-duration.js';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes the throttle config accepted by a definer into the shape held by a resource,
|
|
4
|
+
* parsing `period` into seconds.
|
|
5
|
+
* @param throttle The throttle config to normalize
|
|
6
|
+
* @internal
|
|
7
|
+
* @returns The throttle config, with `period` in seconds
|
|
8
|
+
*/
|
|
9
|
+
export function createThrottleObject(throttle) {
|
|
10
|
+
const { limit, period, burst, key } = throttle;
|
|
11
|
+
// `period` is required, so there is nothing sensible to parse without it
|
|
12
|
+
if (period === undefined) {
|
|
13
|
+
throw new Error('Invalid throttle config: `period` must be provided');
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
limit,
|
|
17
|
+
period: parseDuration(period, 's'),
|
|
18
|
+
...(burst !== undefined && { burst }),
|
|
19
|
+
...(key !== undefined && { key }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=throttle.js.map
|