@sanity/blueprints 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/dist/definers/agents.js +1 -1
- package/dist/definers/agents.js.map +1 -1
- package/dist/definers/applications.js +6 -6
- package/dist/definers/applications.js.map +1 -1
- package/dist/definers/blueprints.js +4 -2
- package/dist/definers/blueprints.js.map +1 -1
- package/dist/definers/context.js +2 -2
- package/dist/definers/context.js.map +1 -1
- package/dist/definers/cors.js +1 -1
- package/dist/definers/cors.js.map +1 -1
- package/dist/definers/datasets.d.ts +18 -1
- package/dist/definers/datasets.js +21 -2
- package/dist/definers/datasets.js.map +1 -1
- package/dist/definers/functions/document.d.ts +1 -2
- package/dist/definers/functions/document.js +1 -1
- package/dist/definers/functions/document.js.map +1 -1
- package/dist/definers/functions/durable.js +1 -1
- package/dist/definers/functions/durable.js.map +1 -1
- package/dist/definers/functions/index.js +1 -1
- package/dist/definers/functions/index.js.map +1 -1
- package/dist/definers/functions/media-library.d.ts +1 -2
- package/dist/definers/functions/media-library.js +2 -3
- package/dist/definers/functions/media-library.js.map +1 -1
- package/dist/definers/functions/pubsub.js +1 -1
- package/dist/definers/functions/pubsub.js.map +1 -1
- package/dist/definers/functions/queue.d.ts +16 -7
- package/dist/definers/functions/queue.js +18 -10
- package/dist/definers/functions/queue.js.map +1 -1
- package/dist/definers/functions/scheduled.js +1 -1
- package/dist/definers/functions/scheduled.js.map +1 -1
- package/dist/definers/functions/sync-tag-invalidate.js +1 -1
- package/dist/definers/functions/sync-tag-invalidate.js.map +1 -1
- package/dist/definers/installation-config.js +1 -1
- package/dist/definers/installation-config.js.map +1 -1
- package/dist/definers/permissions.js +4 -3
- package/dist/definers/permissions.js.map +1 -1
- package/dist/definers/projects.js +1 -1
- package/dist/definers/projects.js.map +1 -1
- package/dist/definers/robotTokens.d.ts +1 -2
- package/dist/definers/robotTokens.js +38 -4
- package/dist/definers/robotTokens.js.map +1 -1
- package/dist/definers/roles.d.ts +22 -30
- package/dist/definers/roles.js +39 -38
- package/dist/definers/roles.js.map +1 -1
- package/dist/definers/studios.js +1 -1
- package/dist/definers/studios.js.map +1 -1
- package/dist/definers/webhooks.js +3 -5
- package/dist/definers/webhooks.js.map +1 -1
- package/dist/types/applications.d.ts +1 -1
- package/dist/types/functions/index.d.ts +36 -11
- package/dist/types/installation-config.d.ts +1 -1
- package/dist/types/robotTokens.d.ts +14 -1
- package/dist/types/roles.d.ts +10 -5
- package/dist/types/studios.d.ts +1 -1
- package/dist/utils/validation.d.ts +14 -11
- package/dist/utils/validation.js +25 -17
- package/dist/utils/validation.js.map +1 -1
- package/dist/validation/blueprints.js +120 -4
- package/dist/validation/blueprints.js.map +1 -1
- package/dist/validation/functions.d.ts +9 -0
- package/dist/validation/functions.js +65 -32
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/resources.js +1 -1
- package/dist/validation/resources.js.map +1 -1
- package/package.json +1 -1
- package/src/definers/agents.ts +1 -1
- package/src/definers/applications.ts +6 -6
- package/src/definers/blueprints.ts +3 -2
- package/src/definers/context.ts +2 -2
- package/src/definers/cors.ts +1 -1
- package/src/definers/datasets.ts +29 -2
- package/src/definers/functions/document.ts +2 -3
- package/src/definers/functions/durable.ts +1 -1
- package/src/definers/functions/index.ts +1 -1
- package/src/definers/functions/media-library.ts +2 -3
- package/src/definers/functions/pubsub.ts +1 -1
- package/src/definers/functions/queue.ts +18 -10
- package/src/definers/functions/scheduled.ts +1 -1
- package/src/definers/functions/sync-tag-invalidate.ts +1 -1
- package/src/definers/installation-config.ts +1 -1
- package/src/definers/permissions.ts +6 -4
- package/src/definers/projects.ts +1 -1
- package/src/definers/robotTokens.ts +40 -4
- package/src/definers/roles.ts +45 -41
- package/src/definers/studios.ts +1 -1
- package/src/definers/webhooks.ts +3 -6
- package/src/types/applications.ts +1 -1
- package/src/types/functions/index.ts +37 -11
- package/src/types/installation-config.ts +1 -1
- package/src/types/robotTokens.ts +15 -1
- package/src/types/roles.ts +10 -5
- package/src/types/studios.ts +5 -1
- package/src/utils/validation.ts +24 -17
- package/src/validation/blueprints.ts +132 -5
- package/src/validation/functions.ts +68 -33
- package/src/validation/resources.ts +1 -1
|
@@ -8,8 +8,7 @@ import { runValidation } from '../utils/validation.js';
|
|
|
8
8
|
* defineRobotToken({
|
|
9
9
|
* name: 'my-robot',
|
|
10
10
|
* memberships: [{
|
|
11
|
-
*
|
|
12
|
-
* resourceId: 'my-project-id',
|
|
11
|
+
* project: 'my-project-id',
|
|
13
12
|
* roleNames: ['editor'],
|
|
14
13
|
* }],
|
|
15
14
|
* })
|
|
@@ -40,15 +39,50 @@ import { runValidation } from '../utils/validation.js';
|
|
|
40
39
|
* @returns The robot token resource
|
|
41
40
|
*/
|
|
42
41
|
export function defineRobotToken(parameters) {
|
|
42
|
+
const { project, memberships, ...rest } = parameters;
|
|
43
43
|
const label = parameters.label || parameters.name;
|
|
44
44
|
const robotResource = {
|
|
45
|
-
...
|
|
45
|
+
...rest,
|
|
46
46
|
label,
|
|
47
47
|
type: 'sanity.access.robot',
|
|
48
|
+
// malformed memberships pass through untouched, so validation reports them instead of throwing here
|
|
49
|
+
memberships: Array.isArray(memberships) ? memberships.map(toMembership) : memberships,
|
|
48
50
|
};
|
|
49
|
-
|
|
51
|
+
if (project !== undefined) {
|
|
52
|
+
robotResource.resourceType = 'project';
|
|
53
|
+
robotResource.resourceId = project;
|
|
54
|
+
}
|
|
55
|
+
runValidation(robotResource, () => [
|
|
56
|
+
...validateProjectScope(parameters, 'Robot token'),
|
|
57
|
+
...(Array.isArray(memberships) ? memberships.flatMap((membership) => validateProjectScope(membership, 'Membership')) : []),
|
|
58
|
+
...validateRobotToken(robotResource),
|
|
59
|
+
]);
|
|
50
60
|
return robotResource;
|
|
51
61
|
}
|
|
62
|
+
function toMembership(membership) {
|
|
63
|
+
if (typeof membership !== 'object' || membership === null)
|
|
64
|
+
return membership;
|
|
65
|
+
const { project, ...rest } = membership;
|
|
66
|
+
const result = rest;
|
|
67
|
+
if (project !== undefined) {
|
|
68
|
+
result.resourceType = 'project';
|
|
69
|
+
result.resourceId = project;
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `project` sets `resourceType` and `resourceId`, so it can't be combined with them.
|
|
75
|
+
* @param scope The robot token or membership options that were passed to the definer
|
|
76
|
+
* @param label The label used as the prefix of error messages
|
|
77
|
+
* @returns A list of validation errors
|
|
78
|
+
*/
|
|
79
|
+
function validateProjectScope(scope, label) {
|
|
80
|
+
if (typeof scope !== 'object' || scope === null || !('project' in scope) || scope.project === undefined)
|
|
81
|
+
return [];
|
|
82
|
+
if (!('resourceType' in scope) && !('resourceId' in scope))
|
|
83
|
+
return [];
|
|
84
|
+
return [{ type: 'invalid_value', message: `${label} \`project\` can't be combined with \`resourceType\` or \`resourceId\`` }];
|
|
85
|
+
}
|
|
52
86
|
/**
|
|
53
87
|
* Creates a reference to a robot token in another stack.
|
|
54
88
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"robotTokens.js","sourceRoot":"","sources":["../../src/definers/robotTokens.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"robotTokens.js","sourceRoot":"","sources":["../../src/definers/robotTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACpE,MAAM,EAAC,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI,EAAC,GAAG,UAAU,CAAA;IAClD,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,IAAI,CAAA;IAEjD,MAAM,aAAa,GAAgC;QAC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Q,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAClH,IAAI,CAAC,CAAC,cAAc,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACrE,OAAO,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,KAAK,wEAAwE,EAAC,CAAC,CAAA;AAC7H,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAqC;IAC9F,OAAO,iBAAiB,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,qBAAqB,EAAC,CAAC,CAAA;AACjF,CAAC"}
|
package/dist/definers/roles.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type BlueprintCrossStackReferenceConfig, type BlueprintProjectRoleResource, type BlueprintResource, type BlueprintRoleConfig, type BlueprintRoleResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
|
-
* Defines a role
|
|
3
|
+
* Defines a custom role. Set `project` to scope the role to a project. Without it, the role is scoped to the same resource
|
|
4
|
+
* as the blueprint.
|
|
4
5
|
*
|
|
5
6
|
* @example
|
|
6
7
|
* ```ts
|
|
@@ -36,18 +37,35 @@ import { type BlueprintCrossStackReferenceConfig, type BlueprintProjectRoleResou
|
|
|
36
37
|
* }],
|
|
37
38
|
* })
|
|
38
39
|
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example In a project, for a robot token
|
|
42
|
+
* ```ts
|
|
43
|
+
* defineRole({
|
|
44
|
+
* name: 'ci-deploy-role',
|
|
45
|
+
* title: 'CI Deploy Role',
|
|
46
|
+
* project: 'my-project-id',
|
|
47
|
+
* appliesToRobots: true,
|
|
48
|
+
* appliesToUsers: false,
|
|
49
|
+
* permissions: [{name: 'sanity-project-cors', action: 'create'}],
|
|
50
|
+
* })
|
|
51
|
+
*
|
|
52
|
+
* defineRobotToken({
|
|
53
|
+
* name: 'ci-robot',
|
|
54
|
+
* memberships: [{project: 'my-project-id', roleNames: ['$.resources.ci-deploy-role']}],
|
|
55
|
+
* })
|
|
56
|
+
* ```
|
|
39
57
|
* @param parameters The configuration of the role
|
|
40
58
|
* @public
|
|
41
59
|
* @category Definers
|
|
42
60
|
* @expandType BlueprintRoleConfig
|
|
43
61
|
* @returns The role resource
|
|
44
62
|
*/
|
|
45
|
-
export declare function defineRole(parameters: BlueprintRoleConfig
|
|
46
|
-
skipValidation?: boolean;
|
|
47
|
-
}): BlueprintRoleResource;
|
|
63
|
+
export declare function defineRole(parameters: BlueprintRoleConfig): BlueprintRoleResource;
|
|
48
64
|
/**
|
|
49
65
|
* Defines a role that is scoped to the specified project.
|
|
50
66
|
*
|
|
67
|
+
* @deprecated Use {@link defineRole} with `project` instead.
|
|
68
|
+
*
|
|
51
69
|
* @example
|
|
52
70
|
* ```ts
|
|
53
71
|
* defineProjectRole('my-project-id', {
|
|
@@ -61,32 +79,6 @@ export declare function defineRole(parameters: BlueprintRoleConfig, options?: {
|
|
|
61
79
|
* }],
|
|
62
80
|
* })
|
|
63
81
|
* ```
|
|
64
|
-
*
|
|
65
|
-
* @example Cross-resource references
|
|
66
|
-
* ```ts
|
|
67
|
-
* defineProjectRole('my-project-id', {
|
|
68
|
-
* name: 'ci-deploy-role',
|
|
69
|
-
* title: 'CI Deploy Role',
|
|
70
|
-
* appliesToRobots: true,
|
|
71
|
-
* appliesToUsers: false,
|
|
72
|
-
* permissions: [{
|
|
73
|
-
* name: 'sanity-project-cors',
|
|
74
|
-
* action: 'create',
|
|
75
|
-
* }, {
|
|
76
|
-
* name: 'sanity-project-cors',
|
|
77
|
-
* action: 'delete',
|
|
78
|
-
* }],
|
|
79
|
-
* })
|
|
80
|
-
*
|
|
81
|
-
* defineRobotToken({
|
|
82
|
-
* name: 'ci-robot',
|
|
83
|
-
* memberships: [{
|
|
84
|
-
* resourceType: 'project',
|
|
85
|
-
* resourceId: 'my-project-id',
|
|
86
|
-
* roleNames: ['$.resources.ci-deploy-role'],
|
|
87
|
-
* }],
|
|
88
|
-
* })
|
|
89
|
-
* ```
|
|
90
82
|
* @public
|
|
91
83
|
* @category Definers
|
|
92
84
|
* @expandType BlueprintRoleConfig
|
package/dist/definers/roles.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { referenceResource, validateProjectRole, validateRole, } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
3
|
/**
|
|
4
|
-
* Defines a role
|
|
4
|
+
* Defines a custom role. Set `project` to scope the role to a project. Without it, the role is scoped to the same resource
|
|
5
|
+
* as the blueprint.
|
|
5
6
|
*
|
|
6
7
|
* @example
|
|
7
8
|
* ```ts
|
|
@@ -37,13 +38,37 @@ import { runValidation } from '../utils/validation.js';
|
|
|
37
38
|
* }],
|
|
38
39
|
* })
|
|
39
40
|
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example In a project, for a robot token
|
|
43
|
+
* ```ts
|
|
44
|
+
* defineRole({
|
|
45
|
+
* name: 'ci-deploy-role',
|
|
46
|
+
* title: 'CI Deploy Role',
|
|
47
|
+
* project: 'my-project-id',
|
|
48
|
+
* appliesToRobots: true,
|
|
49
|
+
* appliesToUsers: false,
|
|
50
|
+
* permissions: [{name: 'sanity-project-cors', action: 'create'}],
|
|
51
|
+
* })
|
|
52
|
+
*
|
|
53
|
+
* defineRobotToken({
|
|
54
|
+
* name: 'ci-robot',
|
|
55
|
+
* memberships: [{project: 'my-project-id', roleNames: ['$.resources.ci-deploy-role']}],
|
|
56
|
+
* })
|
|
57
|
+
* ```
|
|
40
58
|
* @param parameters The configuration of the role
|
|
41
59
|
* @public
|
|
42
60
|
* @category Definers
|
|
43
61
|
* @expandType BlueprintRoleConfig
|
|
44
62
|
* @returns The role resource
|
|
45
63
|
*/
|
|
46
|
-
export function defineRole(parameters
|
|
64
|
+
export function defineRole(parameters) {
|
|
65
|
+
if (parameters.project !== undefined)
|
|
66
|
+
return defineRoleInProject(parameters.project, parameters);
|
|
67
|
+
const roleResource = buildRoleResource(parameters);
|
|
68
|
+
runValidation(roleResource, () => validateRole(roleResource));
|
|
69
|
+
return roleResource;
|
|
70
|
+
}
|
|
71
|
+
function buildRoleResource(parameters) {
|
|
47
72
|
const roleResource = {
|
|
48
73
|
name: parameters.name,
|
|
49
74
|
type: 'sanity.access.role',
|
|
@@ -56,13 +81,22 @@ export function defineRole(parameters, options) {
|
|
|
56
81
|
if (parameters.lifecycle) {
|
|
57
82
|
roleResource.lifecycle = parameters.lifecycle;
|
|
58
83
|
}
|
|
59
|
-
if (options?.skipValidation !== true)
|
|
60
|
-
runValidation(() => validateRole(roleResource));
|
|
61
84
|
return roleResource;
|
|
62
85
|
}
|
|
86
|
+
function defineRoleInProject(project, parameters) {
|
|
87
|
+
const projectRoleResource = {
|
|
88
|
+
...buildRoleResource(parameters),
|
|
89
|
+
resourceType: 'project',
|
|
90
|
+
resourceId: project,
|
|
91
|
+
};
|
|
92
|
+
runValidation(projectRoleResource, () => validateProjectRole(projectRoleResource));
|
|
93
|
+
return projectRoleResource;
|
|
94
|
+
}
|
|
63
95
|
/**
|
|
64
96
|
* Defines a role that is scoped to the specified project.
|
|
65
97
|
*
|
|
98
|
+
* @deprecated Use {@link defineRole} with `project` instead.
|
|
99
|
+
*
|
|
66
100
|
* @example
|
|
67
101
|
* ```ts
|
|
68
102
|
* defineProjectRole('my-project-id', {
|
|
@@ -76,32 +110,6 @@ export function defineRole(parameters, options) {
|
|
|
76
110
|
* }],
|
|
77
111
|
* })
|
|
78
112
|
* ```
|
|
79
|
-
*
|
|
80
|
-
* @example Cross-resource references
|
|
81
|
-
* ```ts
|
|
82
|
-
* defineProjectRole('my-project-id', {
|
|
83
|
-
* name: 'ci-deploy-role',
|
|
84
|
-
* title: 'CI Deploy Role',
|
|
85
|
-
* appliesToRobots: true,
|
|
86
|
-
* appliesToUsers: false,
|
|
87
|
-
* permissions: [{
|
|
88
|
-
* name: 'sanity-project-cors',
|
|
89
|
-
* action: 'create',
|
|
90
|
-
* }, {
|
|
91
|
-
* name: 'sanity-project-cors',
|
|
92
|
-
* action: 'delete',
|
|
93
|
-
* }],
|
|
94
|
-
* })
|
|
95
|
-
*
|
|
96
|
-
* defineRobotToken({
|
|
97
|
-
* name: 'ci-robot',
|
|
98
|
-
* memberships: [{
|
|
99
|
-
* resourceType: 'project',
|
|
100
|
-
* resourceId: 'my-project-id',
|
|
101
|
-
* roleNames: ['$.resources.ci-deploy-role'],
|
|
102
|
-
* }],
|
|
103
|
-
* })
|
|
104
|
-
* ```
|
|
105
113
|
* @public
|
|
106
114
|
* @category Definers
|
|
107
115
|
* @expandType BlueprintRoleConfig
|
|
@@ -110,14 +118,7 @@ export function defineRole(parameters, options) {
|
|
|
110
118
|
* @returns The role resource
|
|
111
119
|
*/
|
|
112
120
|
export function defineProjectRole(projectId, parameters) {
|
|
113
|
-
|
|
114
|
-
const projectRoleResource = {
|
|
115
|
-
...roleResource,
|
|
116
|
-
resourceType: 'project',
|
|
117
|
-
resourceId: projectId,
|
|
118
|
-
};
|
|
119
|
-
runValidation(() => validateProjectRole(projectRoleResource));
|
|
120
|
-
return projectRoleResource;
|
|
121
|
+
return defineRoleInProject(projectId, parameters);
|
|
121
122
|
}
|
|
122
123
|
/**
|
|
123
124
|
* Creates a reference to a role in another stack.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/definers/roles.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD
|
|
1
|
+
{"version":3,"file":"roles.js","sourceRoot":"","sources":["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AG,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAElF,OAAO,mBAAmB,CAAA;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,UAA+B;IAClF,OAAO,mBAAmB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAqC;IACxF,OAAO,iBAAiB,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAC,CAAC,CAAA;AAChF,CAAC"}
|
package/dist/definers/studios.js
CHANGED
|
@@ -35,7 +35,7 @@ export function defineStudio(config) {
|
|
|
35
35
|
autoUpdates,
|
|
36
36
|
type: 'sanity.studio',
|
|
37
37
|
};
|
|
38
|
-
runValidation(() => validateStudio(studioResource));
|
|
38
|
+
runValidation(studioResource, () => validateStudio(studioResource));
|
|
39
39
|
return studioResource;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=studios.js.map
|
|
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,YAAY,CAAC,MAA6B;IACxD,MAAM,WAAW,GAA2C,EAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,EAAC,CAAA;IAC1G,IAAI,MAAM,CAAC,WAAW,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAA;IAClD,CAAC;IAED,MAAM,cAAc,GAA4B;QAC9C,GAAG,MAAM;QACT,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI;QAChC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI;QAClC,WAAW;QACX,IAAI,EAAE,eAAe;KACtB,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAA;
|
|
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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,YAAY,CAAC,MAA6B;IACxD,MAAM,WAAW,GAA2C,EAAC,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,IAAI,IAAI,EAAC,CAAA;IAC1G,IAAI,MAAM,CAAC,WAAW,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;QAC9C,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAA;IAClD,CAAC;IAED,MAAM,cAAc,GAA4B;QAC9C,GAAG,MAAM;QACT,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI;QAChC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI;QAClC,WAAW;QACX,IAAI,EAAE,eAAe;KACtB,CAAA;IAED,aAAa,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAA;IAEnE,OAAO,cAAc,CAAA;AACvB,CAAC"}
|
|
@@ -39,15 +39,13 @@ import { runValidation } from '../utils/validation.js';
|
|
|
39
39
|
* @returns The webhook resource
|
|
40
40
|
*/
|
|
41
41
|
export function defineDocumentWebhook(parameters) {
|
|
42
|
-
// default the display name
|
|
43
|
-
if (!parameters.displayName) {
|
|
44
|
-
parameters.displayName = parameters.name.substring(0, 100);
|
|
45
|
-
}
|
|
46
42
|
const webhookResource = {
|
|
47
43
|
...parameters,
|
|
44
|
+
// default the display name
|
|
45
|
+
displayName: parameters.displayName || parameters.name.substring(0, 100),
|
|
48
46
|
type: 'sanity.project.webhook',
|
|
49
47
|
};
|
|
50
|
-
runValidation(() => validateDocumentWebhook(webhookResource));
|
|
48
|
+
runValidation(webhookResource, () => validateDocumentWebhook(webhookResource));
|
|
51
49
|
return webhookResource;
|
|
52
50
|
}
|
|
53
51
|
//# sourceMappingURL=webhooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/definers/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,uBAAuB,EAAC,MAAM,aAAa,CAAA;AAC/H,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAA0C;IAC9E,
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/definers/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,uBAAuB,EAAC,MAAM,aAAa,CAAA;AAC/H,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAA0C;IAC9E,MAAM,eAAe,GAAqC;QACxD,GAAG,UAAU;QACb,2BAA2B;QAC3B,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;QACxE,IAAI,EAAE,wBAAwB;KAC/B,CAAA;IAED,aAAa,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC,CAAA;IAE9E,OAAO,eAAe,CAAA;AACxB,CAAC"}
|
|
@@ -298,7 +298,7 @@ export type BlueprintApplicationViewConfig = BlueprintWindowViewConfig | Bluepri
|
|
|
298
298
|
* @category Resource Types
|
|
299
299
|
* @interface
|
|
300
300
|
*/
|
|
301
|
-
export type BlueprintApplicationConfig = Omit<BlueprintApplicationResource, 'type' | 'slug' | 'views'> & {
|
|
301
|
+
export type BlueprintApplicationConfig = Omit<BlueprintApplicationResource, 'type' | 'slug' | 'views' | 'mfManifest'> & {
|
|
302
302
|
/**
|
|
303
303
|
* The slug to be used in the application hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`.
|
|
304
304
|
*
|
|
@@ -37,30 +37,55 @@ interface BlueprintCommonFunctionResource extends BlueprintResource {
|
|
|
37
37
|
runtime?: FunctionRuntimes;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Configuration used for Queue
|
|
41
|
-
* @todo: not implemented
|
|
40
|
+
* Configuration used for Queue function types.
|
|
42
41
|
* @category Functions Types
|
|
43
42
|
* @alpha
|
|
44
43
|
* @hidden
|
|
45
44
|
*/
|
|
46
45
|
interface QueueConfig {
|
|
47
46
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
47
|
+
* How many messages run at once, and whether they run in order.
|
|
48
|
+
* @defaultValue `{limit: 2, fifo: false}`
|
|
50
49
|
*/
|
|
51
|
-
concurrency?:
|
|
50
|
+
concurrency?: ConcurrencyConfig;
|
|
52
51
|
/**
|
|
53
52
|
* Debounce configuration, with any durations already resolved to seconds.
|
|
54
53
|
* Definers accept the wider {@link DebounceInput} and parse it into this shape.
|
|
55
54
|
*/
|
|
56
55
|
debounce?: DebounceConfig;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* How many messages a Queue function runs at once, and if they are processed in order.
|
|
59
|
+
*
|
|
60
|
+
* - `{limit: 1, fifo: true}` processes messages one at a time, in order.
|
|
61
|
+
* - `{limit: 5, fifo: true, key: 'event.data.documentId'}` keeps messages with the same key in order,
|
|
62
|
+
* while up to 5 keys run at once, so one busy key doesn't delay the others.
|
|
63
|
+
* - `{limit: 5}` processes up to 5 messages at once, with no order guarantees.
|
|
64
|
+
*
|
|
65
|
+
* A `limit` of 1 needs `fifo: true`, and `fifo` with a `limit` above 1 needs a `key`.
|
|
66
|
+
*
|
|
67
|
+
* Changing `fifo` on a deployed function replaces its queue, and messages still waiting in the old queue are lost.
|
|
68
|
+
* @category Functions Types
|
|
69
|
+
* @alpha
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
export interface ConcurrencyConfig {
|
|
73
|
+
/**
|
|
74
|
+
* Maximum number of messages processed at once, from 1 to 1000.
|
|
75
|
+
* A limit of 1 needs `fifo: true`.
|
|
76
|
+
*/
|
|
77
|
+
limit: number;
|
|
57
78
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @default `false`
|
|
79
|
+
* Process messages in order: one at a time with a `limit` of 1, or in order per `key` with a higher limit.
|
|
80
|
+
* Changing this on a deployed function replaces its queue, and messages still waiting in the old queue are lost.
|
|
81
|
+
* @defaultValue `false`
|
|
62
82
|
*/
|
|
63
83
|
fifo?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Dotted path into `{event, context}`, e.g. `event.data.documentId`; messages with the same value are processed in order.
|
|
86
|
+
* Required when `fifo` is `true` and `limit` is above 1.
|
|
87
|
+
*/
|
|
88
|
+
key?: string;
|
|
64
89
|
}
|
|
65
90
|
/**
|
|
66
91
|
* Configuration used when throttling Queue function types.
|
|
@@ -206,9 +231,9 @@ export interface BlueprintQueueFunctionResource extends BlueprintBaseFunctionRes
|
|
|
206
231
|
/** Optional Content Lake event source that triggers the function */
|
|
207
232
|
event?: BlueprintFunctionResourceContentLakeEvent;
|
|
208
233
|
/**
|
|
209
|
-
* Total delivery attempts per message, at most
|
|
234
|
+
* Total delivery attempts per message, at most 100: `1` delivers once and never retries, `3` delivers once and retries twice.
|
|
210
235
|
* Messages that use up their attempts are moved to a Dead Letter Queue.
|
|
211
|
-
*
|
|
236
|
+
* @defaultValue `3`, applied by the functions service when omitted
|
|
212
237
|
*/
|
|
213
238
|
maxAttempts?: number;
|
|
214
239
|
/**
|
|
@@ -79,4 +79,4 @@ export type BlueprintInstallationConfigResource = BlueprintMediaLibraryConfigRes
|
|
|
79
79
|
* @category Resource Types
|
|
80
80
|
* @interface
|
|
81
81
|
*/
|
|
82
|
-
export type BlueprintMediaLibraryConfigConfig = Omit<BlueprintMediaLibraryConfigResource, 'type' | 'appType'>;
|
|
82
|
+
export type BlueprintMediaLibraryConfigConfig = Omit<BlueprintMediaLibraryConfigResource, 'type' | 'appType' | 'version' | 'mfManifest'>;
|
|
@@ -14,6 +14,16 @@ export interface RobotTokenMembership {
|
|
|
14
14
|
resourceId?: string;
|
|
15
15
|
roleNames: string[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A membership of a robot token, as passed to {@link defineRobotToken}.
|
|
19
|
+
* @category Resource Types
|
|
20
|
+
* @expand
|
|
21
|
+
* @interface
|
|
22
|
+
*/
|
|
23
|
+
export type RobotTokenMembershipConfig = RobotTokenMembership & {
|
|
24
|
+
/** The ID of the project that the membership belongs to. Sets `resourceType` to `project` and `resourceId` to the project. */
|
|
25
|
+
project?: string;
|
|
26
|
+
};
|
|
17
27
|
/**
|
|
18
28
|
* A robot token that provides automated access.
|
|
19
29
|
* @see https://www.sanity.io/docs/content-lake/http-auth#k4c21d7b829fe
|
|
@@ -33,10 +43,13 @@ export interface BlueprintRobotTokenResource extends BlueprintResource<Blueprint
|
|
|
33
43
|
* @category Resource Types
|
|
34
44
|
* @interface
|
|
35
45
|
*/
|
|
36
|
-
export type BlueprintRobotTokenConfig = Omit<BlueprintRobotTokenResource, 'type' | 'label' | '
|
|
46
|
+
export type BlueprintRobotTokenConfig = Omit<BlueprintRobotTokenResource, 'type' | 'label' | 'memberships'> & {
|
|
37
47
|
/**
|
|
38
48
|
* A descriptive label for the robot token and its use case
|
|
39
49
|
* @defaultValue The `name` of the resource
|
|
40
50
|
*/
|
|
41
51
|
label?: string;
|
|
52
|
+
/** The ID of the project that the robot token belongs to. Sets `resourceType` to `project` and `resourceId` to the project. */
|
|
53
|
+
project?: string;
|
|
54
|
+
memberships: RobotTokenMembershipConfig[];
|
|
42
55
|
};
|
package/dist/types/roles.d.ts
CHANGED
|
@@ -13,10 +13,11 @@ export interface RolePermission {
|
|
|
13
13
|
params?: Record<string, unknown>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* A custom role resource
|
|
17
17
|
* @category Resource Types
|
|
18
18
|
*/
|
|
19
|
-
export interface
|
|
19
|
+
export interface BlueprintRoleResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
|
|
20
|
+
type: 'sanity.access.role';
|
|
20
21
|
title: string;
|
|
21
22
|
description?: string;
|
|
22
23
|
appliesToUsers: boolean;
|
|
@@ -24,11 +25,15 @@ export interface BlueprintRoleConfig extends Omit<BlueprintResource<BlueprintPro
|
|
|
24
25
|
permissions: RolePermission[];
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
|
-
*
|
|
28
|
+
* Configuration for a custom role.
|
|
28
29
|
* @category Resource Types
|
|
29
30
|
*/
|
|
30
|
-
export interface
|
|
31
|
-
|
|
31
|
+
export interface BlueprintRoleConfig extends Omit<BlueprintRoleResource, 'type'> {
|
|
32
|
+
/**
|
|
33
|
+
* The ID of the project that the role belongs to. Without it, the role is scoped to the stack.
|
|
34
|
+
* Sets `resourceType` to `project` and `resourceId` to the project.
|
|
35
|
+
*/
|
|
36
|
+
project?: string;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* A custom role resource that is tied to a specific project
|
package/dist/types/studios.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
116
116
|
* @category Resource Types
|
|
117
117
|
* @interface
|
|
118
118
|
*/
|
|
119
|
-
export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type' | 'slug' | 'title' | 'autoUpdates'> {
|
|
119
|
+
export interface BlueprintStudioConfig extends Omit<BlueprintStudioResource, 'type' | 'slug' | 'title' | 'autoUpdates' | 'schemaInputs' | 'workspaces' | 'mfManifest' | 'version'> {
|
|
120
120
|
/**
|
|
121
121
|
* The slug to be used in the studio hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`.
|
|
122
122
|
*
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import type { BlueprintError } from '../types/errors.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Runs a validator and records its errors against `target`, which is the object a definer returns.
|
|
4
|
+
* `defineBlueprint` reports the errors of the resources in its `resources` list, so errors for a resource that never makes
|
|
5
|
+
* it into a blueprint are not reported, and errors don't carry over from one blueprint to the next.
|
|
6
|
+
* @param target The object the errors belong to, usually the resource a definer returns
|
|
7
|
+
* @param validator A function that returns a list of validation errors
|
|
6
8
|
* @internal
|
|
7
9
|
*/
|
|
8
|
-
export declare function runValidation(validator: () => BlueprintError[]
|
|
9
|
-
throwError?: boolean;
|
|
10
|
-
}): void;
|
|
10
|
+
export declare function runValidation(target: unknown, validator: () => BlueprintError[]): void;
|
|
11
11
|
/**
|
|
12
|
-
* Gets the
|
|
13
|
-
* @
|
|
12
|
+
* Gets the validation errors that were recorded against an object when a definer created it.
|
|
13
|
+
* @param target The object the errors belong to, usually a resource
|
|
14
|
+
* @returns The recorded errors, or an empty list
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
16
|
-
export declare function
|
|
17
|
+
export declare function getValidationErrors(target: unknown): BlueprintError[];
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* Formats a list of validation errors as an error message, one error per line.
|
|
20
|
+
* @param errors The errors to format
|
|
21
|
+
* @returns The error message
|
|
19
22
|
* @internal
|
|
20
23
|
*/
|
|
21
|
-
export declare function
|
|
24
|
+
export declare function formatErrors(errors: BlueprintError[]): string;
|
|
22
25
|
/**
|
|
23
26
|
* Checks whether a value is a blueprint reference expression.
|
|
24
27
|
*
|
package/dist/utils/validation.js
CHANGED
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
const
|
|
1
|
+
const errorsByTarget = new WeakMap();
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Runs a validator and records its errors against `target`, which is the object a definer returns.
|
|
4
|
+
* `defineBlueprint` reports the errors of the resources in its `resources` list, so errors for a resource that never makes
|
|
5
|
+
* it into a blueprint are not reported, and errors don't carry over from one blueprint to the next.
|
|
6
|
+
* @param target The object the errors belong to, usually the resource a definer returns
|
|
7
|
+
* @param validator A function that returns a list of validation errors
|
|
6
8
|
* @internal
|
|
7
9
|
*/
|
|
8
|
-
export function runValidation(
|
|
10
|
+
export function runValidation(target, validator) {
|
|
9
11
|
const errors = validator();
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if (errors.length === 0)
|
|
13
|
+
return;
|
|
14
|
+
// there is nothing to attach the errors to, so report them right away
|
|
15
|
+
if (typeof target !== 'object' || target === null)
|
|
16
|
+
throw new Error(formatErrors(errors));
|
|
17
|
+
errorsByTarget.set(target, [...(errorsByTarget.get(target) ?? []), ...errors]);
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
|
-
* Gets the
|
|
18
|
-
* @
|
|
20
|
+
* Gets the validation errors that were recorded against an object when a definer created it.
|
|
21
|
+
* @param target The object the errors belong to, usually a resource
|
|
22
|
+
* @returns The recorded errors, or an empty list
|
|
19
23
|
* @internal
|
|
20
24
|
*/
|
|
21
|
-
export function
|
|
22
|
-
|
|
25
|
+
export function getValidationErrors(target) {
|
|
26
|
+
if (typeof target !== 'object' || target === null)
|
|
27
|
+
return [];
|
|
28
|
+
return errorsByTarget.get(target) ?? [];
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
|
-
*
|
|
31
|
+
* Formats a list of validation errors as an error message, one error per line.
|
|
32
|
+
* @param errors The errors to format
|
|
33
|
+
* @returns The error message
|
|
26
34
|
* @internal
|
|
27
35
|
*/
|
|
28
|
-
export function
|
|
29
|
-
|
|
36
|
+
export function formatErrors(errors) {
|
|
37
|
+
return errors.map((err) => err.message).join('\n');
|
|
30
38
|
}
|
|
31
39
|
const REFERENCE_PREFIXES = ['$.resources.', '$.values.', '$.parameters.', '$.params.'];
|
|
32
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAAG,IAAI,OAAO,EAA4B,CAAA;AAE9D;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAe,EAAE,SAAiC;IAC9E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IAE/B,sEAAsE;IACtE,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;IAExF,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAA;AAChF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe;IACjD,IAAI,O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