@sanity/blueprints 0.22.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/definers/functions/base-event.d.ts +2 -0
- package/dist/definers/functions/base-event.js +2 -0
- package/dist/definers/functions/base-event.js.map +1 -0
- package/dist/definers/functions/document.d.ts +26 -0
- package/dist/definers/functions/document.js +43 -0
- package/dist/definers/functions/document.js.map +1 -0
- package/dist/definers/functions/event.d.ts +20 -0
- package/dist/definers/functions/event.js +30 -0
- package/dist/definers/functions/event.js.map +1 -0
- package/dist/definers/functions/index.d.ts +15 -0
- package/dist/definers/functions/index.js +34 -0
- package/dist/definers/functions/index.js.map +1 -0
- package/dist/definers/functions/media-library.d.ts +23 -0
- package/dist/definers/functions/media-library.js +83 -0
- package/dist/definers/functions/media-library.js.map +1 -0
- package/dist/definers/functions/pipeline.d.ts +26 -0
- package/dist/definers/functions/pipeline.js +41 -0
- package/dist/definers/functions/pipeline.js.map +1 -0
- package/dist/definers/functions/queue.d.ts +30 -0
- package/dist/definers/functions/queue.js +47 -0
- package/dist/definers/functions/queue.js.map +1 -0
- package/dist/definers/functions/scheduled.d.ts +46 -0
- package/dist/definers/functions/scheduled.js +91 -0
- package/dist/definers/functions/scheduled.js.map +1 -0
- package/dist/definers/functions/sync-tag-invalidate.d.ts +31 -0
- package/dist/definers/functions/sync-tag-invalidate.js +43 -0
- package/dist/definers/functions/sync-tag-invalidate.js.map +1 -0
- package/dist/definers/studios.d.ts +22 -0
- package/dist/definers/studios.js +31 -0
- package/dist/definers/studios.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/types/functions/event.d.ts +9 -26
- package/dist/types/functions/index.d.ts +64 -47
- package/dist/types/functions/index.js.map +1 -1
- package/dist/types/studios.d.ts +57 -0
- package/dist/types/studios.js +2 -0
- package/dist/types/studios.js.map +1 -0
- package/dist/validation/functions.d.ts +10 -1
- package/dist/validation/functions.js +91 -19
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/studios.d.ts +9 -0
- package/dist/validation/studios.js +70 -0
- package/dist/validation/studios.js.map +1 -0
- package/package.json +19 -9
- package/src/definers/functions/base-event.ts +4 -0
- package/src/definers/functions/document.ts +129 -0
- package/src/definers/functions/event.ts +32 -0
- package/src/definers/functions/index.ts +39 -0
- package/src/definers/functions/media-library.ts +98 -0
- package/src/definers/functions/pipeline.ts +42 -0
- package/src/definers/functions/queue.ts +49 -0
- package/src/definers/functions/scheduled.ts +112 -0
- package/src/definers/functions/sync-tag-invalidate.ts +51 -0
- package/src/definers/studios.ts +34 -0
- package/src/index.ts +11 -1
- package/src/types/functions/event.ts +4 -31
- package/src/types/functions/index.ts +75 -57
- package/src/types/studios.ts +68 -0
- package/src/validation/functions.ts +98 -21
- package/src/validation/studios.ts +76 -0
- package/dist/definers/functions.d.ts +0 -195
- package/dist/definers/functions.js +0 -368
- package/dist/definers/functions.js.map +0 -1
- package/src/definers/functions.ts +0 -526
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { validateSyncTagInvalidateFunction, } from '../../index.js';
|
|
2
|
+
import { runValidation } from '../../utils/validation.js';
|
|
3
|
+
import { defineFunction } from './index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Defines a function that is triggered on a sync tag invalidate event.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Using implicit event scoping to all datasets in the function project:
|
|
9
|
+
* ```ts
|
|
10
|
+
* defineSyncTagInvalidateFunction({
|
|
11
|
+
* name: 'bustin-caches',
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Using explicit event scoping to a particular dataset in the function project:
|
|
16
|
+
* ```ts
|
|
17
|
+
* defineSyncTagInvalidateFunction({
|
|
18
|
+
* name: 'bustin-caches',
|
|
19
|
+
* event: {
|
|
20
|
+
* resource: {
|
|
21
|
+
* type: 'dataset',
|
|
22
|
+
* id: 'myProj.myDataset',
|
|
23
|
+
* },
|
|
24
|
+
* },
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
* @public
|
|
28
|
+
* @category Definers
|
|
29
|
+
* @expandType BlueprintSyncTagInvalidateFunctionConfig
|
|
30
|
+
* @param functionConfig The configuration for the sync tag invalidate function
|
|
31
|
+
* @returns The validated sync tag invalidate function resource
|
|
32
|
+
*/
|
|
33
|
+
export function defineSyncTagInvalidateFunction(functionConfig) {
|
|
34
|
+
const { event } = functionConfig;
|
|
35
|
+
const functionResource = {
|
|
36
|
+
...defineFunction(functionConfig, { skipValidation: true }),
|
|
37
|
+
type: 'sanity.function.sync-tag-invalidate',
|
|
38
|
+
...(event?.resource ? { event } : {}),
|
|
39
|
+
};
|
|
40
|
+
runValidation(() => validateSyncTagInvalidateFunction(functionResource));
|
|
41
|
+
return functionResource;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=sync-tag-invalidate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-tag-invalidate.js","sourceRoot":"","sources":["../../../src/definers/functions/sync-tag-invalidate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iCAAiC,GAClC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAA;AACzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,+BAA+B,CAC7C,cAAwD;IAExD,MAAM,EAAC,KAAK,EAAC,GAAG,cAAc,CAAA;IAE9B,MAAM,gBAAgB,GAA+C;QACnE,GAAG,cAAc,CAAC,cAAc,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;QACzD,IAAI,EAAE,qCAAqC;QAC3C,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACpC,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,iCAAiC,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAExE,OAAO,gBAAgB,CAAA;AACzB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BlueprintStudioConfig, BlueprintStudioResource } from '../types/studios.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a studio.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* defineStudio({
|
|
7
|
+
* name: 'my-studio',
|
|
8
|
+
* src: 'studios/my-studio',
|
|
9
|
+
* autoUpdates: {
|
|
10
|
+
* enabled: true
|
|
11
|
+
* }
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
* @param parameters The studio configuration
|
|
15
|
+
* @public
|
|
16
|
+
* @beta Deploying Studios via Blueprints is experimental. This may be subject to breaking changes.
|
|
17
|
+
* @category Definers
|
|
18
|
+
* @expandType BlueprintStudioConfig
|
|
19
|
+
* @returns The studio resource
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export declare function defineStudio(config: BlueprintStudioConfig): BlueprintStudioResource;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { validateStudio } from '../index.js';
|
|
2
|
+
import { runValidation } from '../utils/validation.js';
|
|
3
|
+
/**
|
|
4
|
+
* Defines a studio.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* defineStudio({
|
|
8
|
+
* name: 'my-studio',
|
|
9
|
+
* src: 'studios/my-studio',
|
|
10
|
+
* autoUpdates: {
|
|
11
|
+
* enabled: true
|
|
12
|
+
* }
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
* @param parameters The studio configuration
|
|
16
|
+
* @public
|
|
17
|
+
* @beta Deploying Studios via Blueprints is experimental. This may be subject to breaking changes.
|
|
18
|
+
* @category Definers
|
|
19
|
+
* @expandType BlueprintStudioConfig
|
|
20
|
+
* @returns The studio resource
|
|
21
|
+
* @hidden
|
|
22
|
+
*/
|
|
23
|
+
export function defineStudio(config) {
|
|
24
|
+
const studioResource = {
|
|
25
|
+
...config,
|
|
26
|
+
type: 'sanity.studio',
|
|
27
|
+
};
|
|
28
|
+
runValidation(() => validateStudio(studioResource));
|
|
29
|
+
return studioResource;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=studios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studios.js","sourceRoot":"","sources":["../../src/definers/studios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,YAAY,CAAC,MAA6B;IACxD,MAAM,cAAc,GAA4B;QAC9C,GAAG,MAAM;QACT,IAAI,EAAE,eAAe;KACtB,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAA;IAEnD,OAAO,cAAc,CAAA;AACvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,12 +9,20 @@
|
|
|
9
9
|
export * from './definers/blueprints.js';
|
|
10
10
|
export * from './definers/cors.js';
|
|
11
11
|
export * from './definers/datasets.js';
|
|
12
|
-
export * from './definers/functions.js';
|
|
12
|
+
export * from './definers/functions/document.js';
|
|
13
|
+
export * from './definers/functions/event.js';
|
|
14
|
+
export * from './definers/functions/index.js';
|
|
15
|
+
export * from './definers/functions/media-library.js';
|
|
16
|
+
export * from './definers/functions/pipeline.js';
|
|
17
|
+
export * from './definers/functions/queue.js';
|
|
18
|
+
export * from './definers/functions/scheduled.js';
|
|
19
|
+
export * from './definers/functions/sync-tag-invalidate.js';
|
|
13
20
|
export * from './definers/projects.js';
|
|
14
21
|
export * from './definers/resources.js';
|
|
15
22
|
export * from './definers/robots.js';
|
|
16
23
|
export * from './definers/robotTokens.js';
|
|
17
24
|
export * from './definers/roles.js';
|
|
25
|
+
export * from './definers/studios.js';
|
|
18
26
|
export * from './definers/webhooks.js';
|
|
19
27
|
/**
|
|
20
28
|
* @categoryDescription Resource Types
|
|
@@ -34,6 +42,7 @@ export * from './types/resources.js';
|
|
|
34
42
|
export * from './types/robots.js';
|
|
35
43
|
export * from './types/robotTokens.js';
|
|
36
44
|
export * from './types/roles.js';
|
|
45
|
+
export * from './types/studios.js';
|
|
37
46
|
export * from './types/webhooks.js';
|
|
38
47
|
/**
|
|
39
48
|
* @categoryDescription Validation
|
|
@@ -48,6 +57,7 @@ export * from './validation/resources.js';
|
|
|
48
57
|
export * from './validation/robots.js';
|
|
49
58
|
export * from './validation/robotTokens.js';
|
|
50
59
|
export * from './validation/roles.js';
|
|
60
|
+
export * from './validation/studios.js';
|
|
51
61
|
export * from './validation/webhooks.js';
|
|
52
62
|
/**
|
|
53
63
|
* @categoryDescription Blueprint Internals
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,20 @@
|
|
|
10
10
|
export * from './definers/blueprints.js';
|
|
11
11
|
export * from './definers/cors.js';
|
|
12
12
|
export * from './definers/datasets.js';
|
|
13
|
-
export * from './definers/functions.js';
|
|
13
|
+
export * from './definers/functions/document.js';
|
|
14
|
+
export * from './definers/functions/event.js';
|
|
15
|
+
export * from './definers/functions/index.js';
|
|
16
|
+
export * from './definers/functions/media-library.js';
|
|
17
|
+
export * from './definers/functions/pipeline.js';
|
|
18
|
+
export * from './definers/functions/queue.js';
|
|
19
|
+
export * from './definers/functions/scheduled.js';
|
|
20
|
+
export * from './definers/functions/sync-tag-invalidate.js';
|
|
14
21
|
export * from './definers/projects.js';
|
|
15
22
|
export * from './definers/resources.js';
|
|
16
23
|
export * from './definers/robots.js';
|
|
17
24
|
export * from './definers/robotTokens.js';
|
|
18
25
|
export * from './definers/roles.js';
|
|
26
|
+
export * from './definers/studios.js';
|
|
19
27
|
export * from './definers/webhooks.js';
|
|
20
28
|
// TYPES - base types for all resources
|
|
21
29
|
/**
|
|
@@ -36,6 +44,7 @@ export * from './types/resources.js';
|
|
|
36
44
|
export * from './types/robots.js';
|
|
37
45
|
export * from './types/robotTokens.js';
|
|
38
46
|
export * from './types/roles.js';
|
|
47
|
+
export * from './types/studios.js';
|
|
39
48
|
export * from './types/webhooks.js';
|
|
40
49
|
// VALIDATION - validation for all resources
|
|
41
50
|
/**
|
|
@@ -51,6 +60,7 @@ export * from './validation/resources.js';
|
|
|
51
60
|
export * from './validation/robots.js';
|
|
52
61
|
export * from './validation/robotTokens.js';
|
|
53
62
|
export * from './validation/roles.js';
|
|
63
|
+
export * from './validation/studios.js';
|
|
54
64
|
export * from './validation/webhooks.js';
|
|
55
65
|
// Public BLUEPRINTS INTERNALS - published bucket of misc Blueprint types
|
|
56
66
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD;;;GAGG;AACH;;;GAGG;AACH,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD;;;GAGG;AACH;;;GAGG;AACH,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kCAAkC,CAAA;AAChD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uCAAuC,CAAA;AACrD,cAAc,kCAAkC,CAAA;AAChD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mCAAmC,CAAA;AACjD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AAEtC,uCAAuC;AACvC;;;GAGG;AACH;;;GAGG;AACH,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AAEnC,4CAA4C;AAC5C;;;GAGG;AACH,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AAExC,yEAAyE;AACzE;;;GAGG"}
|
|
@@ -71,27 +71,19 @@ export type BlueprintScheduledFunctionResourceEvent = BlueprintScheduledFunction
|
|
|
71
71
|
* @category Functions Types
|
|
72
72
|
*/
|
|
73
73
|
export type BlueprintScheduledFunctionConfigEvent = BlueprintScheduledFunctionExplicitResourceEvent | BlueprintScheduledFunctionExpressionResourceEvent;
|
|
74
|
-
/**
|
|
75
|
-
* Event configuration for queue functions
|
|
76
|
-
* @category Functions Types
|
|
77
|
-
* @alpha
|
|
78
|
-
* @hidden
|
|
79
|
-
*/
|
|
80
|
-
export interface BlueprintQueueFunctionResourceEvent {
|
|
81
|
-
concurrency?: number;
|
|
82
|
-
fifo?: boolean;
|
|
83
|
-
dlq?: boolean;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Union type of all queue function resource event configurations
|
|
87
|
-
* @category Functions Types
|
|
88
|
-
*/
|
|
89
|
-
export type BlueprintQueueFunctionConfigEvent = true | BlueprintQueueFunctionResourceEvent;
|
|
90
74
|
/**
|
|
91
75
|
* Union type of all function resource event configurations
|
|
92
76
|
* @category Functions Types
|
|
93
77
|
*/
|
|
94
|
-
export type BlueprintFunctionResourceEvent =
|
|
78
|
+
export type BlueprintFunctionResourceEvent = ({
|
|
79
|
+
type: 'document';
|
|
80
|
+
} & BlueprintDocumentFunctionResourceEvent) | ({
|
|
81
|
+
type: 'media-library';
|
|
82
|
+
} & BlueprintMediaLibraryFunctionResourceEvent) | ({
|
|
83
|
+
type: 'cron';
|
|
84
|
+
} & BlueprintScheduledFunctionResourceEvent) | ({
|
|
85
|
+
type: 'sync-tag-invalidate';
|
|
86
|
+
} & BlueprintSyncTagInvalidateFunctionResourceEvent);
|
|
95
87
|
/**
|
|
96
88
|
* Dataset resource for scoping document functions to specific datasets
|
|
97
89
|
* @example { type: 'dataset', id: 'my-project.production' }
|
|
@@ -115,12 +107,3 @@ export interface BlueprintFunctionResourceEventResourceMediaLibrary {
|
|
|
115
107
|
* @category Functions Types
|
|
116
108
|
*/
|
|
117
109
|
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,12 +1,12 @@
|
|
|
1
1
|
import type { BlueprintResource } from '../../index.js';
|
|
2
|
-
import type { BlueprintDocumentFunctionResourceEvent,
|
|
2
|
+
import type { BlueprintDocumentFunctionResourceEvent, BlueprintFunctionResourceEvent, BlueprintMediaLibraryFunctionResourceEvent, BlueprintScheduledFunctionConfigEvent, BlueprintScheduledFunctionResourceEvent, BlueprintSyncTagInvalidateFunctionResourceEvent } from './event.js';
|
|
3
3
|
import type { IanaTimezone } from './timezone.js';
|
|
4
4
|
export * from './event.js';
|
|
5
5
|
/**
|
|
6
6
|
* Supported Function runtimes
|
|
7
7
|
* @category Functions Types
|
|
8
8
|
*/
|
|
9
|
-
export declare const VALID_RUNTIMES: readonly [
|
|
9
|
+
export declare const VALID_RUNTIMES: readonly ['node', 'nodejs22.x', 'nodejs24.x'];
|
|
10
10
|
/**
|
|
11
11
|
* Supported function runtimes
|
|
12
12
|
* @category Functions Types
|
|
@@ -35,6 +35,43 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
|
|
|
35
35
|
*/
|
|
36
36
|
runtime?: FunctionRuntimes;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Configuration used for Queue or Workflow function types.
|
|
40
|
+
* @todo: not implemented
|
|
41
|
+
* @category Functions Types
|
|
42
|
+
* @alpha
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
interface QueueConfig {
|
|
46
|
+
/**
|
|
47
|
+
* Maximum number of concurrent invocations in progress from queue to Function
|
|
48
|
+
* @todo: not implemented, what is the default anyways?
|
|
49
|
+
*/
|
|
50
|
+
concurrency?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Debounce window in seconds
|
|
53
|
+
* @todo: not implemented - and should this always be provided with debounceKey?
|
|
54
|
+
*/
|
|
55
|
+
debounce?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Path used to group debounced events, e.g. 'document._id'
|
|
58
|
+
* @todo: not implemented - and should this always be provided with debounce window?
|
|
59
|
+
*/
|
|
60
|
+
debounceKey?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Whether to place messages that failed processing into a Dead Letter Queue.
|
|
63
|
+
* @todo: not implemented
|
|
64
|
+
* @default `false`
|
|
65
|
+
*/
|
|
66
|
+
dlq?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* By default, queues employ at-least once delivery. When set to `true`, employs first-in-first-out ordering and exactly-once delivery.
|
|
69
|
+
* FIFO queues have a lower transaction-per-second limit.
|
|
70
|
+
* @todo: not implemented
|
|
71
|
+
* @default `false`
|
|
72
|
+
*/
|
|
73
|
+
fifo?: boolean;
|
|
74
|
+
}
|
|
38
75
|
/**
|
|
39
76
|
* Base function resource with common properties for all function types that can belong to projects.
|
|
40
77
|
* @category Functions Types
|
|
@@ -87,9 +124,10 @@ export interface BlueprintSyncTagInvalidateFunctionResource extends BlueprintBas
|
|
|
87
124
|
* @alpha
|
|
88
125
|
* @hidden
|
|
89
126
|
*/
|
|
90
|
-
export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionResource {
|
|
127
|
+
export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionResource, QueueConfig {
|
|
91
128
|
type: 'sanity.function.queue';
|
|
92
|
-
event
|
|
129
|
+
/** Optional event configuration that triggers the function */
|
|
130
|
+
event?: BlueprintFunctionResourceEvent;
|
|
93
131
|
}
|
|
94
132
|
/**
|
|
95
133
|
* A function resource triggered by another function
|
|
@@ -100,6 +138,18 @@ export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionRes
|
|
|
100
138
|
export interface BlueprintEventFunctionResource extends BlueprintBaseFunctionResource {
|
|
101
139
|
type: 'sanity.function.event';
|
|
102
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* A durable, step-based pipeline function.
|
|
143
|
+
* @public
|
|
144
|
+
* @alpha Deploying Pipeline Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
145
|
+
* @hidden
|
|
146
|
+
* @category Functions Types
|
|
147
|
+
* @interface
|
|
148
|
+
*/
|
|
149
|
+
export interface BlueprintPipelineResource extends BlueprintBaseFunctionResource, QueueConfig {
|
|
150
|
+
type: 'sanity.function.pipeline';
|
|
151
|
+
event?: BlueprintFunctionResourceEvent;
|
|
152
|
+
}
|
|
103
153
|
/**
|
|
104
154
|
* Configuration for defining a base function.
|
|
105
155
|
* @internal
|
|
@@ -186,28 +236,19 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
|
|
|
186
236
|
* @category Functions Types
|
|
187
237
|
* @interface
|
|
188
238
|
*/
|
|
189
|
-
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> & {
|
|
239
|
+
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'> & QueueConfig & {
|
|
190
240
|
/**
|
|
191
241
|
* Path to the function source code
|
|
192
242
|
* @defaultValue `functions/${name}`
|
|
193
243
|
*/
|
|
194
244
|
src?: string;
|
|
195
|
-
/**
|
|
196
|
-
|
|
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
|
-
*
|
|
203
|
-
* @defaultValue true
|
|
204
|
-
*/
|
|
205
|
-
queue?: BlueprintQueueFunctionConfigEvent;
|
|
245
|
+
/** Optional event configuration that triggers the queue function */
|
|
246
|
+
event?: BlueprintFunctionResourceEvent;
|
|
206
247
|
};
|
|
207
248
|
/**
|
|
208
249
|
* Configuration for defining an event function.
|
|
209
250
|
* @public
|
|
210
|
-
* @alpha Deploying
|
|
251
|
+
* @alpha Deploying Event Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
211
252
|
* @hidden
|
|
212
253
|
* @category Functions Types
|
|
213
254
|
* @interface
|
|
@@ -220,45 +261,21 @@ export type BlueprintEventFunctionConfig = Omit<BlueprintEventFunctionResource,
|
|
|
220
261
|
src?: string;
|
|
221
262
|
};
|
|
222
263
|
/**
|
|
223
|
-
*
|
|
264
|
+
* Configuration for defining a pipeline function.
|
|
224
265
|
* @public
|
|
225
|
-
* @alpha Deploying
|
|
266
|
+
* @alpha Deploying Pipeline Functions via Blueprints is experimental. This feature is not available publicly yet.
|
|
226
267
|
* @hidden
|
|
227
268
|
* @category Functions Types
|
|
228
269
|
* @interface
|
|
229
270
|
*/
|
|
230
|
-
export
|
|
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;
|
|
271
|
+
export type BlueprintPipelineConfig = Omit<BlueprintPipelineResource, 'type' | 'src' | 'event'> & {
|
|
241
272
|
/**
|
|
242
|
-
* Path
|
|
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}`
|
|
273
|
+
* Path to the pipeline source code
|
|
274
|
+
* @defaultValue `functions/${name}`
|
|
258
275
|
*/
|
|
259
276
|
src?: string;
|
|
260
277
|
/**
|
|
261
278
|
* Trigger configuration
|
|
262
279
|
*/
|
|
263
|
-
event
|
|
280
|
+
event?: BlueprintFunctionResourceEvent;
|
|
264
281
|
};
|
|
@@ -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":"AAWA,cAAc,YAAY,CAAA;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAU,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ConfigEnv, InlineConfig } from 'vite';
|
|
2
|
+
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Custom Vite configuration for the Studio so it can be changed and extended.
|
|
5
|
+
* This type matches the type in @sanity/cli-core and must continue to remain compatible.
|
|
6
|
+
* @beta This feature is subject to breaking changes.
|
|
7
|
+
* @category Resource Types
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Represents a Studio resource.
|
|
13
|
+
* @see https://www.sanity.io/docs/studio
|
|
14
|
+
* @beta This feature is subject to breaking changes.
|
|
15
|
+
* @category Resource Types
|
|
16
|
+
* @hidden
|
|
17
|
+
*/
|
|
18
|
+
export interface BlueprintStudioResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
19
|
+
type: 'sanity.studio';
|
|
20
|
+
/** The relative location of the studio source code. */
|
|
21
|
+
src: string;
|
|
22
|
+
/**
|
|
23
|
+
* Auto update settings for the studio.
|
|
24
|
+
*/
|
|
25
|
+
autoUpdates: {
|
|
26
|
+
/** Whether auto updates are enabled for the studio */
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
/** What "version"/"channel" to use for auto updates */
|
|
29
|
+
version?: string;
|
|
30
|
+
};
|
|
31
|
+
/** The base path of the studio URL. Defaults to '/' */
|
|
32
|
+
basePath?: string;
|
|
33
|
+
/** Whether or not to minify the source code. Defaults to true. */
|
|
34
|
+
minify?: boolean;
|
|
35
|
+
/** Whether or not to configure the reactCompiler. Defaults to false. */
|
|
36
|
+
reactCompiler?: boolean;
|
|
37
|
+
/** Whether or not to generate source maps. Defaults to false. */
|
|
38
|
+
sourceMap?: boolean;
|
|
39
|
+
/** Custom Vite configuration for the Studio so it can be changed and extended. */
|
|
40
|
+
vite?: UserViteConfig;
|
|
41
|
+
/**
|
|
42
|
+
* The project ID of the project that contains your Studio.
|
|
43
|
+
*
|
|
44
|
+
* The `project` attribute must be defined if your blueprint is scoped to an organization.
|
|
45
|
+
*/
|
|
46
|
+
project?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration for a Studio resource.
|
|
50
|
+
* @see https://www.sanity.io/docs/studio
|
|
51
|
+
* @beta This feature is subject to breaking changes.
|
|
52
|
+
* @category Resource Types
|
|
53
|
+
* @interface
|
|
54
|
+
* @hidden
|
|
55
|
+
*/
|
|
56
|
+
export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type'> {
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studios.js","sourceRoot":"","sources":["../../src/types/studios.ts"],"names":[],"mappings":""}
|
|
@@ -51,7 +51,7 @@ export declare function validateSyncTagInvalidateFunction(functionResource: unkn
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function validateQueueFunction(functionResource: unknown): BlueprintError[];
|
|
53
53
|
/**
|
|
54
|
-
* Validates
|
|
54
|
+
* Validates an event function resource configuration.
|
|
55
55
|
* @param functionResource The function resource to validate
|
|
56
56
|
* @alpha
|
|
57
57
|
* @hidden
|
|
@@ -59,3 +59,12 @@ export declare function validateQueueFunction(functionResource: unknown): Bluepr
|
|
|
59
59
|
* @returns Array of validation errors, empty if valid
|
|
60
60
|
*/
|
|
61
61
|
export declare function validateEventFunction(functionResource: unknown): BlueprintError[];
|
|
62
|
+
/**
|
|
63
|
+
* Validates a pipeline function resource configuration.
|
|
64
|
+
* @param functionResource The function resource to validate
|
|
65
|
+
* @alpha
|
|
66
|
+
* @hidden
|
|
67
|
+
* @category Functions Types
|
|
68
|
+
* @returns Array of validation errors, empty if valid
|
|
69
|
+
*/
|
|
70
|
+
export declare function validatePipelineFunction(functionResource: unknown): BlueprintError[];
|
|
@@ -155,8 +155,10 @@ function validateFunctionEventResourceDataset(event) {
|
|
|
155
155
|
const errors = [];
|
|
156
156
|
if (!event || typeof event !== 'object')
|
|
157
157
|
return [{ type: 'invalid_value', message: '`event` must be an object' }];
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
// `resource` is optional for the event types that reach here (document and sync-tag-invalidate),
|
|
159
|
+
// so there is nothing to validate when it is absent.
|
|
160
|
+
if (!('resource' in event) || typeof event.resource === 'undefined')
|
|
161
|
+
return [];
|
|
160
162
|
const resource = event.resource;
|
|
161
163
|
if (!resource || typeof resource !== 'object')
|
|
162
164
|
return [{ type: 'invalid_value', message: '`event.resource` must be an object' }];
|
|
@@ -418,32 +420,61 @@ export function validateQueueFunction(functionResource) {
|
|
|
418
420
|
if ('type' in functionResource && functionResource.type !== 'sanity.function.queue') {
|
|
419
421
|
errors.push({ type: 'invalid_value', message: '`type` must be `sanity.function.queue`' });
|
|
420
422
|
}
|
|
421
|
-
if ('
|
|
422
|
-
|
|
423
|
+
if ('concurrency' in functionResource) {
|
|
424
|
+
if (typeof functionResource.concurrency !== 'number') {
|
|
425
|
+
errors.push({ type: 'invalid_type', message: '`concurrency` must be a number' });
|
|
426
|
+
}
|
|
427
|
+
else if (functionResource.concurrency < 1) {
|
|
428
|
+
errors.push({ type: 'invalid_type', message: '`concurrency` must be at least 1' });
|
|
429
|
+
}
|
|
430
|
+
else if (functionResource.concurrency > 500) {
|
|
431
|
+
errors.push({ type: 'invalid_value', message: '`concurrency` must be less than 500' });
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if ('fifo' in functionResource && typeof functionResource.fifo !== 'boolean') {
|
|
435
|
+
errors.push({ type: 'invalid_type', message: '`fifo` must be a boolean' });
|
|
436
|
+
}
|
|
437
|
+
if ('dlq' in functionResource && typeof functionResource.dlq !== 'boolean') {
|
|
438
|
+
errors.push({ type: 'invalid_type', message: '`dlq` must be a boolean' });
|
|
439
|
+
}
|
|
440
|
+
if ('event' in functionResource && typeof functionResource.event !== 'undefined') {
|
|
441
|
+
errors.push(...validateFunctionEvent(functionResource.event));
|
|
423
442
|
}
|
|
424
443
|
errors.push(...validateFunction(functionResource));
|
|
425
444
|
return errors;
|
|
426
445
|
}
|
|
427
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Validates a function event configuration.
|
|
448
|
+
* The event is a discriminated union keyed by `type`; validation is delegated to the
|
|
449
|
+
* matching per-type event validator.
|
|
450
|
+
* @param event The event configuration to validate
|
|
451
|
+
* @returns Array of validation errors, empty if valid
|
|
452
|
+
*/
|
|
453
|
+
function validateFunctionEvent(event) {
|
|
428
454
|
if (!event || typeof event !== 'object')
|
|
429
455
|
return [{ type: 'invalid_type', message: '`event` must be an object' }];
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
456
|
+
if (!('type' in event))
|
|
457
|
+
return [{ type: 'missing_parameter', message: '`event.type` is required' }];
|
|
458
|
+
switch (event.type) {
|
|
459
|
+
case 'document':
|
|
460
|
+
return validateDocumentFunctionEvent(event);
|
|
461
|
+
case 'media-library':
|
|
462
|
+
return validateMediaLibraryFunctionEvent(event);
|
|
463
|
+
case 'cron':
|
|
464
|
+
return validateScheduledFunctionEvent(event);
|
|
465
|
+
case 'sync-tag-invalidate':
|
|
466
|
+
return validateFunctionEventResourceDataset(event);
|
|
467
|
+
default:
|
|
468
|
+
return [
|
|
469
|
+
{
|
|
470
|
+
type: 'invalid_value',
|
|
471
|
+
message: '`event.type` must be either `cron`, `document`, `sync-tag-invalidate`, or `media-library`',
|
|
472
|
+
},
|
|
473
|
+
];
|
|
442
474
|
}
|
|
443
|
-
return errors;
|
|
444
475
|
}
|
|
445
476
|
/**
|
|
446
|
-
* Validates
|
|
477
|
+
* Validates an event function resource configuration.
|
|
447
478
|
* @param functionResource The function resource to validate
|
|
448
479
|
* @alpha
|
|
449
480
|
* @hidden
|
|
@@ -462,4 +493,45 @@ export function validateEventFunction(functionResource) {
|
|
|
462
493
|
errors.push(...validateFunction(functionResource));
|
|
463
494
|
return errors;
|
|
464
495
|
}
|
|
496
|
+
/**
|
|
497
|
+
* Validates a pipeline function resource configuration.
|
|
498
|
+
* @param functionResource The function resource to validate
|
|
499
|
+
* @alpha
|
|
500
|
+
* @hidden
|
|
501
|
+
* @category Functions Types
|
|
502
|
+
* @returns Array of validation errors, empty if valid
|
|
503
|
+
*/
|
|
504
|
+
export function validatePipelineFunction(functionResource) {
|
|
505
|
+
if (!functionResource)
|
|
506
|
+
return [{ type: 'invalid_value', message: 'Function config must be provided' }];
|
|
507
|
+
if (typeof functionResource !== 'object')
|
|
508
|
+
return [{ type: 'invalid_type', message: 'Function config must be an object' }];
|
|
509
|
+
const errors = [];
|
|
510
|
+
if ('type' in functionResource && functionResource.type !== 'sanity.function.pipeline') {
|
|
511
|
+
errors.push({ type: 'invalid_value', message: '`type` must be `sanity.function.pipeline`' });
|
|
512
|
+
}
|
|
513
|
+
if ('debounceKey' in functionResource && typeof functionResource.debounceKey !== 'string') {
|
|
514
|
+
errors.push({ type: 'invalid_type', message: '`debounceKey` must be a string' });
|
|
515
|
+
}
|
|
516
|
+
if ('debounceKey' in functionResource && !('debounce' in functionResource)) {
|
|
517
|
+
errors.push({ type: 'invalid_value', message: '`debounceKey` requires a `debounce` to be set' });
|
|
518
|
+
}
|
|
519
|
+
if ('concurrency' in functionResource && typeof functionResource.concurrency !== 'number') {
|
|
520
|
+
errors.push({ type: 'invalid_type', message: '`concurrency` must be a number' });
|
|
521
|
+
}
|
|
522
|
+
if ('concurrency' in functionResource && typeof functionResource.concurrency === 'number' && functionResource.concurrency < 1) {
|
|
523
|
+
errors.push({ type: 'invalid_value', message: '`concurrency` must be at least 1' });
|
|
524
|
+
}
|
|
525
|
+
if ('concurrency' in functionResource && typeof functionResource.concurrency === 'number' && functionResource.concurrency > 500) {
|
|
526
|
+
errors.push({ type: 'invalid_value', message: '`concurrency` must be less than 500' });
|
|
527
|
+
}
|
|
528
|
+
if ('debounce' in functionResource && typeof functionResource.debounce !== 'number') {
|
|
529
|
+
errors.push({ type: 'invalid_type', message: '`debounce` must be a number' });
|
|
530
|
+
}
|
|
531
|
+
if ('event' in functionResource) {
|
|
532
|
+
errors.push(...validateFunctionEvent(functionResource.event));
|
|
533
|
+
}
|
|
534
|
+
errors.push(...validateFunction(functionResource));
|
|
535
|
+
return errors;
|
|
536
|
+
}
|
|
465
537
|
//# sourceMappingURL=functions.js.map
|