@sanity/blueprints 0.7.1 → 0.9.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/blueprints.d.ts +12 -0
- package/dist/definers/blueprints.js +12 -0
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/cors.d.ts +10 -0
- package/dist/definers/cors.js +10 -0
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +9 -0
- package/dist/definers/datasets.js +9 -0
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions.d.ts +85 -1
- package/dist/definers/functions.js +108 -4
- package/dist/definers/functions.js.map +1 -1
- package/dist/definers/resources.d.ts +5 -0
- package/dist/definers/resources.js +5 -0
- package/dist/definers/resources.js.map +1 -1
- package/dist/definers/robots.d.ts +18 -0
- package/dist/definers/robots.js +30 -0
- package/dist/definers/robots.js.map +1 -0
- package/dist/definers/roles.d.ts +36 -0
- package/dist/definers/roles.js +39 -0
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/webhooks.d.ts +13 -0
- package/dist/definers/webhooks.js +13 -0
- package/dist/definers/webhooks.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/types/blueprints.d.ts +5 -5
- package/dist/types/cors.d.ts +30 -4
- package/dist/types/datasets.d.ts +16 -4
- package/dist/types/functions.d.ts +45 -0
- package/dist/types/resources.d.ts +47 -1
- package/dist/types/robots.d.ts +30 -0
- package/dist/types/robots.js +2 -0
- package/dist/types/robots.js.map +1 -0
- package/dist/types/roles.d.ts +16 -2
- package/dist/types/webhooks.d.ts +3 -0
- package/dist/utils/validation.d.ts +4 -0
- package/dist/utils/validation.js +4 -0
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/blueprints.d.ts +5 -0
- package/dist/validation/blueprints.js +5 -0
- package/dist/validation/blueprints.js.map +1 -1
- package/dist/validation/cors.d.ts +6 -1
- package/dist/validation/cors.js +7 -1
- package/dist/validation/cors.js.map +1 -1
- package/dist/validation/datasets.d.ts +6 -1
- package/dist/validation/datasets.js +7 -1
- package/dist/validation/datasets.js.map +1 -1
- package/dist/validation/functions.d.ts +20 -1
- package/dist/validation/functions.js +144 -5
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/resources.d.ts +9 -1
- package/dist/validation/resources.js +55 -1
- package/dist/validation/resources.js.map +1 -1
- package/dist/validation/robots.d.ts +8 -0
- package/dist/validation/robots.js +97 -0
- package/dist/validation/robots.js.map +1 -0
- package/dist/validation/roles.d.ts +11 -6
- package/dist/validation/roles.js +30 -23
- package/dist/validation/roles.js.map +1 -1
- package/dist/validation/webhooks.d.ts +7 -2
- package/dist/validation/webhooks.js +35 -29
- package/dist/validation/webhooks.js.map +1 -1
- package/package.json +6 -6
- package/src/definers/blueprints.ts +12 -0
- package/src/definers/cors.ts +10 -0
- package/src/definers/datasets.ts +9 -0
- package/src/definers/functions.ts +152 -3
- package/src/definers/resources.ts +6 -1
- package/src/definers/robots.ts +33 -0
- package/src/definers/roles.ts +40 -0
- package/src/definers/webhooks.ts +13 -0
- package/src/index.ts +3 -0
- package/src/types/blueprints.ts +5 -5
- package/src/types/cors.ts +30 -4
- package/src/types/datasets.ts +16 -4
- package/src/types/functions.ts +48 -0
- package/src/types/resources.ts +54 -1
- package/src/types/robots.ts +35 -0
- package/src/types/roles.ts +19 -5
- package/src/types/webhooks.ts +5 -0
- package/src/utils/validation.ts +4 -0
- package/src/validation/blueprints.ts +5 -0
- package/src/validation/cors.ts +7 -2
- package/src/validation/datasets.ts +7 -2
- package/src/validation/functions.ts +152 -12
- package/src/validation/resources.ts +50 -1
- package/src/validation/robots.ts +96 -0
- package/src/validation/roles.ts +30 -24
- package/src/validation/webhooks.ts +35 -30
|
@@ -1,52 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { validateResource } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that the given resource is a valid Document Webhook.
|
|
4
|
+
* @param resource The Document Webhook resource
|
|
5
|
+
* @returns A list of validation errors
|
|
6
|
+
*/
|
|
7
|
+
export function validateDocumentWebhook(resource) {
|
|
8
|
+
if (!resource)
|
|
3
9
|
return [{ type: 'invalid_value', message: 'Webhook config must be provided' }];
|
|
4
|
-
if (typeof
|
|
10
|
+
if (typeof resource !== 'object')
|
|
5
11
|
return [{ type: 'invalid_type', message: 'Webhook config must be an object' }];
|
|
6
|
-
const errors =
|
|
7
|
-
if (!('name' in
|
|
12
|
+
const errors = validateResource(resource, { projectContained: true });
|
|
13
|
+
if (!('name' in resource)) {
|
|
8
14
|
errors.push({ type: 'missing_parameter', message: 'Webhook name is required' });
|
|
9
15
|
}
|
|
10
|
-
else if (typeof
|
|
16
|
+
else if (typeof resource.name !== 'string') {
|
|
11
17
|
errors.push({ type: 'invalid_type', message: 'Webhook name must be a string' });
|
|
12
18
|
}
|
|
13
|
-
if (!('type' in
|
|
19
|
+
if (!('type' in resource)) {
|
|
14
20
|
errors.push({ type: 'missing_parameter', message: 'Webhook type is required' });
|
|
15
21
|
}
|
|
16
|
-
else if (
|
|
22
|
+
else if (resource.type !== 'sanity.project.webhook') {
|
|
17
23
|
errors.push({ type: 'invalid_value', message: 'Webhook type must be `sanity.project.webhook`' });
|
|
18
24
|
}
|
|
19
|
-
if ('displayName' in
|
|
20
|
-
if (typeof
|
|
25
|
+
if ('displayName' in resource) {
|
|
26
|
+
if (typeof resource.displayName !== 'string') {
|
|
21
27
|
errors.push({ type: 'invalid_type', message: 'Display name must be a string' });
|
|
22
28
|
}
|
|
23
|
-
else if (
|
|
29
|
+
else if (resource.displayName.length > 100) {
|
|
24
30
|
errors.push({ type: 'invalid_value', message: 'Display name must be 100 characters or less' });
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
|
-
if (!('url' in
|
|
33
|
+
if (!('url' in resource)) {
|
|
28
34
|
errors.push({ type: 'missing_parameter', message: 'Webhook URL is required' });
|
|
29
35
|
}
|
|
30
|
-
else if (typeof
|
|
36
|
+
else if (typeof resource.url !== 'string') {
|
|
31
37
|
errors.push({ type: 'invalid_type', message: 'Webhook URL must be a string' });
|
|
32
38
|
}
|
|
33
39
|
else {
|
|
34
40
|
// Validate URL format
|
|
35
41
|
try {
|
|
36
|
-
new URL(
|
|
42
|
+
new URL(resource.url);
|
|
37
43
|
}
|
|
38
44
|
catch {
|
|
39
45
|
errors.push({ type: 'invalid_value', message: 'Webhook URL must be a valid URL' });
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
|
-
if (!('on' in
|
|
48
|
+
if (!('on' in resource) || !Array.isArray(resource.on) || resource.on.length === 0) {
|
|
43
49
|
errors.push({ type: 'invalid_value', message: 'At least one event type must be specified in the "on" field' });
|
|
44
50
|
}
|
|
45
51
|
else {
|
|
46
52
|
// Validate event types
|
|
47
53
|
const validEvents = ['create', 'update', 'delete'];
|
|
48
|
-
if (
|
|
49
|
-
const invalidEvents =
|
|
54
|
+
if (resource.on) {
|
|
55
|
+
const invalidEvents = resource.on.filter((event) => !validEvents.includes(event));
|
|
50
56
|
if (invalidEvents.length > 0) {
|
|
51
57
|
errors.push({
|
|
52
58
|
type: 'invalid_value',
|
|
@@ -56,21 +62,21 @@ export function validateDocumentWebhook(parameters) {
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
// Validate dataset pattern
|
|
59
|
-
if (!('dataset' in
|
|
65
|
+
if (!('dataset' in resource)) {
|
|
60
66
|
errors.push({ type: 'missing_parameter', message: 'Webhook dataset is required' });
|
|
61
67
|
}
|
|
62
|
-
else if (typeof
|
|
68
|
+
else if (typeof resource.dataset !== 'string' || !/^[a-z0-9-_]+$/.test(resource.dataset)) {
|
|
63
69
|
errors.push({ type: 'invalid_format', message: 'Dataset must match pattern: ^[a-z0-9-_]+$' });
|
|
64
70
|
}
|
|
65
71
|
// Validate HTTP method
|
|
66
|
-
if ('httpMethod' in
|
|
72
|
+
if ('httpMethod' in resource) {
|
|
67
73
|
const validMethods = ['POST', 'PUT', 'PATCH', 'DELETE', 'GET'];
|
|
68
|
-
const message = `Invalid HTTP method: ${
|
|
69
|
-
if (typeof
|
|
74
|
+
const message = `Invalid HTTP method: ${resource.httpMethod}. Valid methods are: ${validMethods.join(', ')}`;
|
|
75
|
+
if (typeof resource.httpMethod !== 'string') {
|
|
70
76
|
errors.push({ type: 'invalid_type', message });
|
|
71
77
|
}
|
|
72
78
|
else {
|
|
73
|
-
if (!validMethods.includes(
|
|
79
|
+
if (!validMethods.includes(resource.httpMethod)) {
|
|
74
80
|
errors.push({
|
|
75
81
|
type: 'invalid_value',
|
|
76
82
|
message,
|
|
@@ -79,23 +85,23 @@ export function validateDocumentWebhook(parameters) {
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
// Validate status
|
|
82
|
-
if ('status' in
|
|
88
|
+
if ('status' in resource) {
|
|
83
89
|
const message = 'Status must be either "enabled" or "disabled"';
|
|
84
|
-
if (typeof
|
|
90
|
+
if (typeof resource.status !== 'string') {
|
|
85
91
|
errors.push({ type: 'invalid_type', message });
|
|
86
92
|
}
|
|
87
|
-
else if (!['enabled', 'disabled'].includes(
|
|
93
|
+
else if (!['enabled', 'disabled'].includes(resource.status)) {
|
|
88
94
|
errors.push({ type: 'invalid_value', message });
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
// Validate headers pattern
|
|
92
|
-
if ('headers' in
|
|
93
|
-
if (typeof
|
|
98
|
+
if ('headers' in resource) {
|
|
99
|
+
if (typeof resource.headers !== 'object' || !resource.headers || Array.isArray(resource.headers)) {
|
|
94
100
|
errors.push({ type: 'invalid_type', message: 'Webhook headers must be an object' });
|
|
95
101
|
}
|
|
96
102
|
else {
|
|
97
103
|
const headerNamePattern = /^[a-zA-Z][a-zA-Z0-9-_]*$/;
|
|
98
|
-
for (const [key, value] of Object.entries(
|
|
104
|
+
for (const [key, value] of Object.entries(resource.headers)) {
|
|
99
105
|
if (!headerNamePattern.test(key)) {
|
|
100
106
|
errors.push({ type: 'invalid_format', message: `Header key "${key}" must match pattern: ${headerNamePattern.source}` });
|
|
101
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/validation/webhooks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/validation/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAC,MAAM,aAAa,CAAA;AAEjE;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAiB;IACvD,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iCAAiC,EAAC,CAAC,CAAA;IAC3F,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,kCAAkC,EAAC,CAAC,CAAA;IAE9G,MAAM,MAAM,GAAqB,gBAAgB,CAAC,QAAQ,EAAE,EAAC,gBAAgB,EAAE,IAAI,EAAC,CAAC,CAAA;IAErF,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,0BAA0B,EAAC,CAAC,CAAA;IAC/E,CAAC;SAAM,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,+BAA+B,EAAC,CAAC,CAAA;IAC/E,CAAC;IAED,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,0BAA0B,EAAC,CAAC,CAAA;IAC/E,CAAC;SAAM,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,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACjG,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,mCAAmC,EAAC,CAAC,CAAA;QACnF,CAAC;aAAM,CAAC;YACN,MAAM,iBAAiB,GAAG,0BAA0B,CAAA;YACpD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5D,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,GAAG,yBAAyB,iBAAiB,CAAC,MAAM,EAAE,EAAC,CAAC,CAAA;gBACvH,CAAC;gBACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAC9B,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,EAAC,CAAC,CAAA;gBAC5F,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/blueprints",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Helper methods and type definitions for Sanity Blueprints",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"typecheck": "tsc --noEmit --project tsconfig.test.json"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@biomejs/biome": "
|
|
50
|
+
"@biomejs/biome": "2.3.11",
|
|
51
51
|
"@types/node": "^20",
|
|
52
|
-
"@vitest/coverage-v8": "^
|
|
53
|
-
"rimraf": "^6.
|
|
54
|
-
"typescript": "^5.
|
|
55
|
-
"vitest": "
|
|
52
|
+
"@vitest/coverage-v8": "^4.0.17",
|
|
53
|
+
"rimraf": "^6.1.2",
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"vitest": "4.0.17"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=20"
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import {type Blueprint, type BlueprintModule, type BlueprintsApiConfig, validateBlueprint} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Define a Blueprint to manage Sanity resources
|
|
6
|
+
* ```
|
|
7
|
+
* defineBlueprint({
|
|
8
|
+
* resources: [
|
|
9
|
+
* // list of managed resources
|
|
10
|
+
* ]
|
|
11
|
+
* })
|
|
12
|
+
* ```
|
|
13
|
+
* @param blueprintConfig The blueprint configuration
|
|
14
|
+
* @returns A blueprint module
|
|
15
|
+
*/
|
|
4
16
|
export function defineBlueprint(blueprintConfig: Partial<Blueprint> & Partial<BlueprintsApiConfig>): BlueprintModule {
|
|
5
17
|
const {organizationId, projectId, stackId, blueprintVersion, resources, values, outputs} = blueprintConfig
|
|
6
18
|
|
package/src/definers/cors.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import {type BlueprintCorsOriginConfig, type BlueprintCorsOriginResource, validateCorsOrigin} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Defines a CORS Origin to be managed in a Blueprint.
|
|
6
|
+
* ```
|
|
7
|
+
* defineCorsOrigin({
|
|
8
|
+
* origin: 'https://mydomain.com',
|
|
9
|
+
* allowCredentials: true
|
|
10
|
+
* })
|
|
11
|
+
* ```
|
|
12
|
+
* @param parameters The CORS Origin configuration
|
|
13
|
+
*/
|
|
4
14
|
export function defineCorsOrigin(parameters: BlueprintCorsOriginConfig): BlueprintCorsOriginResource {
|
|
5
15
|
const corsResource: BlueprintCorsOriginResource = {
|
|
6
16
|
...parameters,
|
package/src/definers/datasets.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import {type BlueprintDatasetConfig, type BlueprintDatasetResource, validateDataset} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Defines a Dataset to be managed in a Blueprint.
|
|
6
|
+
* ```
|
|
7
|
+
* defineDataset({
|
|
8
|
+
* name: 'production'
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
* @param parameters The dataset configuration
|
|
12
|
+
*/
|
|
4
13
|
export function defineDataset(parameters: BlueprintDatasetConfig): BlueprintDatasetResource {
|
|
5
14
|
// default dataset name
|
|
6
15
|
const datasetName = parameters.datasetName || parameters.name
|
|
@@ -5,9 +5,14 @@ import {
|
|
|
5
5
|
type BlueprintFunctionBaseResourceEvent,
|
|
6
6
|
type BlueprintMediaLibraryAssetFunctionResource,
|
|
7
7
|
type BlueprintMediaLibraryFunctionResourceEvent,
|
|
8
|
+
type BlueprintScheduleFunctionExplicitResourceEvent,
|
|
9
|
+
type BlueprintScheduleFunctionExpressionResourceEvent,
|
|
10
|
+
type BlueprintScheduleFunctionResource,
|
|
11
|
+
type BlueprintScheduleFunctionResourceEvent,
|
|
8
12
|
validateDocumentFunction,
|
|
9
13
|
validateFunction,
|
|
10
14
|
validateMediaLibraryAssetFunction,
|
|
15
|
+
validateScheduleFunction,
|
|
11
16
|
} from '../index.js'
|
|
12
17
|
import {runValidation} from '../utils/validation.js'
|
|
13
18
|
|
|
@@ -17,11 +22,37 @@ type DocumentFunctionEventKey = keyof BlueprintDocumentFunctionResourceEvent
|
|
|
17
22
|
const DOCUMENT_EVENT_KEYS = new Set<DocumentFunctionEventKey>(['includeAllVersions', 'resource', ...BASE_EVENT_KEYS.values()])
|
|
18
23
|
type MediaLibraryFunctionEventKey = keyof BlueprintMediaLibraryFunctionResourceEvent
|
|
19
24
|
const MEDIA_LIBRARY_EVENT_KEYS = new Set<MediaLibraryFunctionEventKey>(['resource', ...BASE_EVENT_KEYS.values()])
|
|
25
|
+
type ScheduleFunctionEventKey =
|
|
26
|
+
| keyof BlueprintScheduleFunctionExplicitResourceEvent
|
|
27
|
+
| keyof BlueprintScheduleFunctionExpressionResourceEvent
|
|
28
|
+
const SCHEDULE_EVENT_KEYS = new Set<ScheduleFunctionEventKey>(['minute', 'hour', 'dayOfWeek', 'month', 'dayOfMonth', 'expression'])
|
|
20
29
|
|
|
21
30
|
interface RequiredFunctionProperties {
|
|
22
31
|
name: string
|
|
23
32
|
}
|
|
24
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Defines a function that is triggered by document events in Sanity datasets.
|
|
36
|
+
* ```
|
|
37
|
+
* defineDocumentFunction({
|
|
38
|
+
* name: 'my-document-function',
|
|
39
|
+
* src: 'functions/my-function',
|
|
40
|
+
* memory: 3,
|
|
41
|
+
* timeout: 300,
|
|
42
|
+
* event: {
|
|
43
|
+
* on: ['create', 'update'],
|
|
44
|
+
* filter: "_type == 'some-type'",
|
|
45
|
+
* projection: "{title, _id, _type}",
|
|
46
|
+
* includeDrafts: false,
|
|
47
|
+
* },
|
|
48
|
+
* env: {
|
|
49
|
+
* MY_ENV_VAR: 'custom-value',
|
|
50
|
+
* },
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
* @param functionConfig The configuration for the document function
|
|
54
|
+
* @returns The validated document function resource
|
|
55
|
+
*/
|
|
25
56
|
export function defineDocumentFunction(
|
|
26
57
|
functionConfig: Partial<BlueprintDocumentFunctionResource> & RequiredFunctionProperties,
|
|
27
58
|
): BlueprintDocumentFunctionResource
|
|
@@ -34,7 +65,7 @@ export function defineDocumentFunction(
|
|
|
34
65
|
export function defineDocumentFunction(
|
|
35
66
|
functionConfig: Partial<BlueprintDocumentFunctionResource> & RequiredFunctionProperties & Partial<BlueprintDocumentFunctionResourceEvent>,
|
|
36
67
|
): BlueprintDocumentFunctionResource {
|
|
37
|
-
let {name, src, event, timeout, memory, env, type, ...maybeEvent} = functionConfig
|
|
68
|
+
let {name, src, event, timeout, memory, env, type, robotToken, ...maybeEvent} = functionConfig
|
|
38
69
|
if (!type) type = 'sanity.function.document'
|
|
39
70
|
|
|
40
71
|
// event validation and normalization
|
|
@@ -64,6 +95,7 @@ export function defineDocumentFunction(
|
|
|
64
95
|
timeout,
|
|
65
96
|
memory,
|
|
66
97
|
env,
|
|
98
|
+
robotToken,
|
|
67
99
|
},
|
|
68
100
|
{
|
|
69
101
|
skipValidation: true, // already done below
|
|
@@ -78,13 +110,36 @@ export function defineDocumentFunction(
|
|
|
78
110
|
return functionResource
|
|
79
111
|
}
|
|
80
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Defines a function that is triggered by media library events.
|
|
115
|
+
* ```
|
|
116
|
+
* defineMediaLibraryAssetFunction({
|
|
117
|
+
* name: 'my-media-library-function',
|
|
118
|
+
* src: 'functions/media-library-function',
|
|
119
|
+
* event: {
|
|
120
|
+
* on: ['create', 'update'],
|
|
121
|
+
* resource: {
|
|
122
|
+
* type: 'media-library',
|
|
123
|
+
* id: 'my-media-library-id',
|
|
124
|
+
* },
|
|
125
|
+
* filter: "type == 'my-type'",
|
|
126
|
+
* projection: "{_id}",
|
|
127
|
+
* },
|
|
128
|
+
* env: {
|
|
129
|
+
* MY_ENV_VAR: 'custom-value',
|
|
130
|
+
* },
|
|
131
|
+
* })
|
|
132
|
+
* ```
|
|
133
|
+
* @param functionConfig The configuration for the media library asset function
|
|
134
|
+
* @returns The validated media library asset function resource
|
|
135
|
+
*/
|
|
81
136
|
export function defineMediaLibraryAssetFunction(
|
|
82
137
|
functionConfig: Partial<BlueprintMediaLibraryAssetFunctionResource> &
|
|
83
138
|
RequiredFunctionProperties &
|
|
84
139
|
Pick<BlueprintMediaLibraryAssetFunctionResource, 'event'> &
|
|
85
140
|
Partial<BlueprintMediaLibraryFunctionResourceEvent>,
|
|
86
141
|
): BlueprintMediaLibraryAssetFunctionResource {
|
|
87
|
-
let {name, src, event, timeout, memory, env, type} = functionConfig
|
|
142
|
+
let {name, src, event, timeout, memory, env, type, robotToken} = functionConfig
|
|
88
143
|
if (!type) type = 'sanity.function.media-library.asset'
|
|
89
144
|
|
|
90
145
|
const functionResource: BlueprintMediaLibraryAssetFunctionResource = {
|
|
@@ -95,6 +150,7 @@ export function defineMediaLibraryAssetFunction(
|
|
|
95
150
|
timeout,
|
|
96
151
|
memory,
|
|
97
152
|
env,
|
|
153
|
+
robotToken,
|
|
98
154
|
},
|
|
99
155
|
{
|
|
100
156
|
skipValidation: true, // already done below
|
|
@@ -109,11 +165,83 @@ export function defineMediaLibraryAssetFunction(
|
|
|
109
165
|
return functionResource
|
|
110
166
|
}
|
|
111
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Defines a function that is triggered on a schedule.
|
|
170
|
+
* ```
|
|
171
|
+
* defineScheduleFunction({
|
|
172
|
+
* name: 'my-schedule-function',
|
|
173
|
+
* src: 'functions/schedule-function',
|
|
174
|
+
* memory: 3,
|
|
175
|
+
* timeout: 300,
|
|
176
|
+
* event: {
|
|
177
|
+
* minute: "0",
|
|
178
|
+
* hour: "0",
|
|
179
|
+
* dayOfMonth: "*",
|
|
180
|
+
* month: "*",
|
|
181
|
+
* dayOfWeek: "*",
|
|
182
|
+
* },
|
|
183
|
+
* })
|
|
184
|
+
* ```
|
|
185
|
+
* @beta
|
|
186
|
+
* @param functionConfig The configuration for the document function
|
|
187
|
+
* @returns The validated schedule function resource
|
|
188
|
+
*/
|
|
189
|
+
export function defineScheduleFunction(
|
|
190
|
+
functionConfig: Partial<BlueprintScheduleFunctionResource> &
|
|
191
|
+
RequiredFunctionProperties &
|
|
192
|
+
Pick<BlueprintScheduleFunctionResource, 'event'> &
|
|
193
|
+
Partial<BlueprintScheduleFunctionResourceEvent>,
|
|
194
|
+
): BlueprintScheduleFunctionResource {
|
|
195
|
+
let {name, src, event, timeout, memory, env, type, timezone} = functionConfig
|
|
196
|
+
if (!type) type = 'sanity.function.cron'
|
|
197
|
+
|
|
198
|
+
const functionResource: BlueprintScheduleFunctionResource = {
|
|
199
|
+
...defineFunction(
|
|
200
|
+
{
|
|
201
|
+
name,
|
|
202
|
+
src,
|
|
203
|
+
timeout,
|
|
204
|
+
memory,
|
|
205
|
+
env,
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
skipValidation: true, // already done below
|
|
209
|
+
},
|
|
210
|
+
),
|
|
211
|
+
type,
|
|
212
|
+
event: buildScheduleFunctionEvent(event),
|
|
213
|
+
}
|
|
214
|
+
if (timezone) {
|
|
215
|
+
functionResource.timezone = timezone
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
runValidation(() => validateScheduleFunction(functionResource))
|
|
219
|
+
|
|
220
|
+
return functionResource
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Defines a base function resource with common properties.
|
|
225
|
+
* ```
|
|
226
|
+
* defineFunction({
|
|
227
|
+
* name: 'my-function',
|
|
228
|
+
* src: 'functions/my-function',
|
|
229
|
+
* timeout: 300,
|
|
230
|
+
* memory: 1,
|
|
231
|
+
* env: {
|
|
232
|
+
* MY_ENV_VAR: 'my-custom-value'
|
|
233
|
+
* },
|
|
234
|
+
* })
|
|
235
|
+
* ```
|
|
236
|
+
* @param functionConfig The configuration for the function
|
|
237
|
+
* @param options Optional configuration including validation options
|
|
238
|
+
* @returns The validated function resource
|
|
239
|
+
*/
|
|
112
240
|
export function defineFunction(
|
|
113
241
|
functionConfig: Partial<BlueprintBaseFunctionResource> & RequiredFunctionProperties,
|
|
114
242
|
options?: {skipValidation?: boolean},
|
|
115
243
|
): BlueprintBaseFunctionResource {
|
|
116
|
-
let {name, src, timeout, memory, env, type} = functionConfig
|
|
244
|
+
let {name, src, timeout, memory, env, type, robotToken} = functionConfig
|
|
117
245
|
|
|
118
246
|
// defaults
|
|
119
247
|
if (!src) src = `functions/${name}`
|
|
@@ -126,6 +254,7 @@ export function defineFunction(
|
|
|
126
254
|
timeout,
|
|
127
255
|
memory,
|
|
128
256
|
env,
|
|
257
|
+
robotToken,
|
|
129
258
|
}
|
|
130
259
|
|
|
131
260
|
if (options?.skipValidation !== true) runValidation(() => validateFunction(functionResource))
|
|
@@ -133,6 +262,12 @@ export function defineFunction(
|
|
|
133
262
|
return functionResource
|
|
134
263
|
}
|
|
135
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Builds a document function event configuration from partial event properties.
|
|
267
|
+
* Filters out non-event properties and applies defaults.
|
|
268
|
+
* @param event Partial document function event configuration
|
|
269
|
+
* @returns Complete document function event configuration
|
|
270
|
+
*/
|
|
136
271
|
function buildDocumentFunctionEvent(event: Partial<BlueprintDocumentFunctionResourceEvent>): BlueprintDocumentFunctionResourceEvent {
|
|
137
272
|
const cleanEvent = Object.fromEntries(
|
|
138
273
|
Object.entries(event).filter(([key]) => DOCUMENT_EVENT_KEYS.has(key as DocumentFunctionEventKey)),
|
|
@@ -144,6 +279,12 @@ function buildDocumentFunctionEvent(event: Partial<BlueprintDocumentFunctionReso
|
|
|
144
279
|
}
|
|
145
280
|
}
|
|
146
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Builds a media library function event configuration.
|
|
284
|
+
* Filters out non-event properties and applies defaults.
|
|
285
|
+
* @param event Media library function event configuration
|
|
286
|
+
* @returns Complete media library function event configuration
|
|
287
|
+
*/
|
|
147
288
|
function buildMediaLibraryFunctionEvent(event: BlueprintMediaLibraryFunctionResourceEvent): BlueprintMediaLibraryFunctionResourceEvent {
|
|
148
289
|
const cleanEvent = Object.fromEntries(
|
|
149
290
|
Object.entries(event).filter(([key]) => MEDIA_LIBRARY_EVENT_KEYS.has(key as MediaLibraryFunctionEventKey)),
|
|
@@ -155,3 +296,11 @@ function buildMediaLibraryFunctionEvent(event: BlueprintMediaLibraryFunctionReso
|
|
|
155
296
|
}
|
|
156
297
|
return fullEvent
|
|
157
298
|
}
|
|
299
|
+
|
|
300
|
+
function buildScheduleFunctionEvent(event: BlueprintScheduleFunctionResourceEvent): BlueprintScheduleFunctionResourceEvent {
|
|
301
|
+
const cleanEvent = Object.fromEntries(
|
|
302
|
+
Object.entries(event).filter(([key]) => SCHEDULE_EVENT_KEYS.has(key as ScheduleFunctionEventKey)),
|
|
303
|
+
) as BlueprintScheduleFunctionResourceEvent
|
|
304
|
+
|
|
305
|
+
return cleanEvent
|
|
306
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {type BlueprintResource
|
|
1
|
+
import {assertResource, type BlueprintResource} from '../index.js'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Defines a generic resource to be managed in Blueprints.
|
|
5
|
+
* This is useful if the resource type does not yet have a `define*` function.
|
|
6
|
+
* @param resourceConfig The resource configuration
|
|
7
|
+
*/
|
|
3
8
|
export function defineResource(resourceConfig: Partial<BlueprintResource>): BlueprintResource {
|
|
4
9
|
const resource = {
|
|
5
10
|
...resourceConfig,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {type BlueprintRobotConfig, type BlueprintRobotResource, validateRobot} from '../index.js'
|
|
2
|
+
import {runValidation} from '../utils/validation.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Defines a Robot token for automated access. Has a token property provided during deployment that can be referenced by other resources.
|
|
6
|
+
* ```
|
|
7
|
+
* defineRobot({
|
|
8
|
+
* name: 'my-robot',
|
|
9
|
+
* label: 'My Robot',
|
|
10
|
+
* memberships: [{
|
|
11
|
+
* resourceType: 'project',
|
|
12
|
+
* resourceId: projectId,
|
|
13
|
+
* roleNames: ['custom-robot-role'],
|
|
14
|
+
* }],
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param parameters The robot configuration
|
|
19
|
+
*/
|
|
20
|
+
export function defineRobot(parameters: BlueprintRobotConfig): BlueprintRobotResource {
|
|
21
|
+
// default robot label
|
|
22
|
+
const label = parameters.label || parameters.name
|
|
23
|
+
|
|
24
|
+
const robotResource: BlueprintRobotResource = {
|
|
25
|
+
...parameters,
|
|
26
|
+
label,
|
|
27
|
+
type: 'sanity.access.robot',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
runValidation(() => validateRobot(robotResource))
|
|
31
|
+
|
|
32
|
+
return robotResource
|
|
33
|
+
}
|
package/src/definers/roles.ts
CHANGED
|
@@ -9,6 +9,24 @@ import {runValidation} from '../utils/validation.js'
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Defines a role that is scoped to the same resource as the blueprint.
|
|
12
|
+
* ```
|
|
13
|
+
* defineRole({
|
|
14
|
+
* name: 'custom-robot-role',
|
|
15
|
+
* title: 'Custom Robot Role',
|
|
16
|
+
* appliesToRobots: true,
|
|
17
|
+
* appliesToUsers: false,
|
|
18
|
+
* permissions: [{
|
|
19
|
+
* name: 'sanity-project-cors',
|
|
20
|
+
* action: 'create'
|
|
21
|
+
* }, {
|
|
22
|
+
* name: 'sanity-project-cors',
|
|
23
|
+
* action: 'read'
|
|
24
|
+
* }, {
|
|
25
|
+
* name: 'sanity-project-cors',
|
|
26
|
+
* action: 'delete'
|
|
27
|
+
* }]
|
|
28
|
+
* }),
|
|
29
|
+
* ```
|
|
12
30
|
* @param parameters The configuration of the role
|
|
13
31
|
* @returns The role resource
|
|
14
32
|
*/
|
|
@@ -23,6 +41,10 @@ export function defineRole(parameters: BlueprintRoleConfig, options?: {skipValid
|
|
|
23
41
|
permissions: parameters.permissions,
|
|
24
42
|
}
|
|
25
43
|
|
|
44
|
+
if (parameters.lifecycle) {
|
|
45
|
+
roleResource.lifecycle = parameters.lifecycle
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
if (options?.skipValidation !== true) runValidation(() => validateRole(roleResource))
|
|
27
49
|
|
|
28
50
|
return roleResource
|
|
@@ -30,6 +52,24 @@ export function defineRole(parameters: BlueprintRoleConfig, options?: {skipValid
|
|
|
30
52
|
|
|
31
53
|
/**
|
|
32
54
|
* Defines a role that is scoped to the specified project.
|
|
55
|
+
* ```
|
|
56
|
+
* defineProjectRole(projectId, {
|
|
57
|
+
* name: 'custom-robot-role',
|
|
58
|
+
* title: 'Custom Robot Role',
|
|
59
|
+
* appliesToRobots: true,
|
|
60
|
+
* appliesToUsers: false,
|
|
61
|
+
* permissions: [{
|
|
62
|
+
* name: 'sanity-project-cors',
|
|
63
|
+
* action: 'create'
|
|
64
|
+
* }, {
|
|
65
|
+
* name: 'sanity-project-cors',
|
|
66
|
+
* action: 'read'
|
|
67
|
+
* }, {
|
|
68
|
+
* name: 'sanity-project-cors',
|
|
69
|
+
* action: 'delete'
|
|
70
|
+
* }]
|
|
71
|
+
* }),
|
|
72
|
+
* ```
|
|
33
73
|
* @param projectId The ID of the project to which the role will be scoped
|
|
34
74
|
* @param parameters The configuration of the role
|
|
35
75
|
* @returns The role resource
|
package/src/definers/webhooks.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import {type BlueprintDocumentWebhookConfig, type BlueprintDocumentWebhookResource, validateDocumentWebhook} from '../index.js'
|
|
2
2
|
import {runValidation} from '../utils/validation.js'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Defines a webhook that is called when document changes occur.
|
|
6
|
+
* ```
|
|
7
|
+
* defineDocumentWebhook({
|
|
8
|
+
* name: 'my-webhook',
|
|
9
|
+
* on: ['create'],
|
|
10
|
+
* url: 'https://example.com/webhook',
|
|
11
|
+
* projection: '{_id}',
|
|
12
|
+
* dataset: 'staging'
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
* @param parameters The webhook configuration
|
|
16
|
+
*/
|
|
4
17
|
export function defineDocumentWebhook(parameters: BlueprintDocumentWebhookConfig): BlueprintDocumentWebhookResource {
|
|
5
18
|
// default the display name
|
|
6
19
|
if (!parameters.displayName) {
|
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './definers/cors.js'
|
|
|
4
4
|
export * from './definers/datasets.js'
|
|
5
5
|
export * from './definers/functions.js'
|
|
6
6
|
export * from './definers/resources.js'
|
|
7
|
+
export * from './definers/robots.js'
|
|
7
8
|
export * from './definers/roles.js'
|
|
8
9
|
export * from './definers/webhooks.js'
|
|
9
10
|
|
|
@@ -14,6 +15,7 @@ export * from './types/datasets.js'
|
|
|
14
15
|
export * from './types/errors.js'
|
|
15
16
|
export * from './types/functions.js'
|
|
16
17
|
export * from './types/resources.js'
|
|
18
|
+
export * from './types/robots.js'
|
|
17
19
|
export * from './types/roles.js'
|
|
18
20
|
export * from './types/webhooks.js'
|
|
19
21
|
|
|
@@ -23,5 +25,6 @@ export * from './validation/cors.js'
|
|
|
23
25
|
export * from './validation/datasets.js'
|
|
24
26
|
export * from './validation/functions.js'
|
|
25
27
|
export * from './validation/resources.js'
|
|
28
|
+
export * from './validation/robots.js'
|
|
26
29
|
export * from './validation/roles.js'
|
|
27
30
|
export * from './validation/webhooks.js'
|
package/src/types/blueprints.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type {BlueprintResource} from '../index.js'
|
|
2
2
|
|
|
3
|
+
/** Additional configuration on a Blueprint that overrides the normal configuration */
|
|
3
4
|
export interface BlueprintsApiConfig {
|
|
4
5
|
organizationId: string
|
|
5
6
|
projectId: string
|
|
6
7
|
stackId: string
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
/** A key-value pair that will be output from a Blueprint */
|
|
9
11
|
export interface BlueprintOutput {
|
|
10
12
|
name: string
|
|
11
13
|
value: string
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** A representation of a Blueprint document */
|
|
14
17
|
export interface Blueprint {
|
|
15
18
|
$schema: string
|
|
16
19
|
blueprintVersion: string
|
|
@@ -19,8 +22,5 @@ export interface Blueprint {
|
|
|
19
22
|
outputs?: BlueprintOutput[]
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
projectId?: string
|
|
25
|
-
stackId?: string
|
|
26
|
-
}
|
|
25
|
+
/** The result of defining a blueprint with `defineBlueprint` */
|
|
26
|
+
export type BlueprintModule = ((args?: unknown) => Blueprint) & Partial<BlueprintsApiConfig>
|