@sanity/blueprints 0.13.1 → 0.14.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/projects.d.ts +20 -2
- package/dist/definers/projects.js +22 -2
- package/dist/definers/projects.js.map +1 -1
- package/dist/definers/resources.d.ts +9 -1
- package/dist/definers/resources.js +22 -0
- package/dist/definers/resources.js.map +1 -1
- package/dist/definers/robotTokens.d.ts +19 -1
- package/dist/definers/robotTokens.js +21 -1
- package/dist/definers/robotTokens.js.map +1 -1
- package/dist/definers/roles.d.ts +19 -1
- package/dist/definers/roles.js +21 -1
- package/dist/definers/roles.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/types/datasets.d.ts +2 -0
- package/dist/types/resources.d.ts +35 -2
- package/dist/validation/datasets.js +6 -0
- package/dist/validation/datasets.js.map +1 -1
- package/dist/validation/resources.js +15 -1
- package/dist/validation/resources.js.map +1 -1
- package/package.json +1 -1
- package/src/definers/projects.ts +30 -2
- package/src/definers/resources.ts +26 -1
- package/src/definers/robotTokens.ts +29 -1
- package/src/definers/roles.ts +24 -0
- package/src/index.ts +4 -0
- package/src/types/datasets.ts +2 -0
- package/src/types/resources.ts +40 -2
- package/src/validation/datasets.ts +7 -0
- package/src/validation/resources.ts +13 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BlueprintProjectConfig, type BlueprintProjectResource } from '../index.js';
|
|
1
|
+
import { type BlueprintCrossStackReferenceConfig, type BlueprintProjectConfig, type BlueprintProjectResource, type BlueprintResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a project.
|
|
4
4
|
*
|
|
@@ -13,7 +13,25 @@ import { type BlueprintProjectConfig, type BlueprintProjectResource } from '../i
|
|
|
13
13
|
* @beta Deploying Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
14
14
|
* @category Definers
|
|
15
15
|
* @expandType BlueprintProjectConfig
|
|
16
|
-
* @returns The
|
|
16
|
+
* @returns The project resource
|
|
17
17
|
* @hidden
|
|
18
18
|
*/
|
|
19
19
|
export declare function defineProject(parameters: BlueprintProjectConfig): BlueprintProjectResource;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a reference to a project in another stack.
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* referenceProject({
|
|
25
|
+
* name: 'editorial-project',
|
|
26
|
+
* stack: 'editorial',
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param params The parameters for referencing the project
|
|
31
|
+
* @public
|
|
32
|
+
* @beta Referencing Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
33
|
+
* @category Referencers
|
|
34
|
+
* @returns The project reference
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
37
|
+
export declare function referenceProject({ name, stack, localName }: BlueprintCrossStackReferenceConfig): BlueprintResource;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateProject } from '../index.js';
|
|
1
|
+
import { referenceResource, validateProject, } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
3
|
/**
|
|
4
4
|
* Defines a project.
|
|
@@ -14,7 +14,7 @@ import { runValidation } from '../utils/validation.js';
|
|
|
14
14
|
* @beta Deploying Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
15
15
|
* @category Definers
|
|
16
16
|
* @expandType BlueprintProjectConfig
|
|
17
|
-
* @returns The
|
|
17
|
+
* @returns The project resource
|
|
18
18
|
* @hidden
|
|
19
19
|
*/
|
|
20
20
|
export function defineProject(parameters) {
|
|
@@ -28,4 +28,24 @@ export function defineProject(parameters) {
|
|
|
28
28
|
runValidation(() => validateProject(projectResource));
|
|
29
29
|
return projectResource;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a reference to a project in another stack.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* referenceProject({
|
|
36
|
+
* name: 'editorial-project',
|
|
37
|
+
* stack: 'editorial',
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param params The parameters for referencing the project
|
|
42
|
+
* @public
|
|
43
|
+
* @beta Referencing Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
44
|
+
* @category Referencers
|
|
45
|
+
* @returns The project reference
|
|
46
|
+
* @hidden
|
|
47
|
+
*/
|
|
48
|
+
export function referenceProject({ name, stack, localName }) {
|
|
49
|
+
return referenceResource({ name, stack, localName, type: 'sanity.project' });
|
|
50
|
+
}
|
|
31
51
|
//# sourceMappingURL=projects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/definers/projects.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/definers/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EACjB,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkC;IAC9D,uBAAuB;IACvB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,IAAI,CAAA;IAE7D,MAAM,eAAe,GAA6B;QAChD,GAAG,UAAU;QACb,WAAW;QACX,IAAI,EAAE,gBAAgB;KACvB,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAA;IAErD,OAAO,eAAe,CAAA;AACxB,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAqC;IAC3F,OAAO,iBAAiB,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;AAC5E,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BlueprintResource } from '../index.js';
|
|
1
|
+
import { type BlueprintCrossStackReferenceResourceConfig, type BlueprintResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a generic resource to be managed in Blueprints.
|
|
4
4
|
*
|
|
@@ -17,3 +17,11 @@ import { type BlueprintResource } from '../index.js';
|
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
export declare function defineResource(resourceConfig: Partial<BlueprintResource>): BlueprintResource;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a reference to a resource in another stack
|
|
22
|
+
* @param params The parameters for referencing the resource
|
|
23
|
+
* @category Definers
|
|
24
|
+
* @expandType BlueprintCrossStackReferenceResourceConfig
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare function referenceResource({ name, type, stack, localName }: BlueprintCrossStackReferenceResourceConfig): BlueprintResource;
|
|
@@ -34,4 +34,26 @@ export function defineResource(resourceConfig) {
|
|
|
34
34
|
assertResource(resource);
|
|
35
35
|
return resource;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates a reference to a resource in another stack
|
|
39
|
+
* @param params The parameters for referencing the resource
|
|
40
|
+
* @category Definers
|
|
41
|
+
* @expandType BlueprintCrossStackReferenceResourceConfig
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export function referenceResource({ name, type, stack, localName }) {
|
|
45
|
+
const resource = {
|
|
46
|
+
type,
|
|
47
|
+
name: localName || name,
|
|
48
|
+
lifecycle: {
|
|
49
|
+
ownershipAction: {
|
|
50
|
+
type: 'reference',
|
|
51
|
+
stack,
|
|
52
|
+
name,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
assertResource(resource);
|
|
57
|
+
return resource;
|
|
58
|
+
}
|
|
37
59
|
//# sourceMappingURL=resources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/definers/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/definers/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAA0E,MAAM,aAAa,CAAA;AAEnH;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,cAA0C;IACvE,MAAM,QAAQ,GAAG;QACf,GAAG,cAAc;KAClB,CAAA;IAED,cAAc,CAAC,QAAQ,CAAC,CAAA;IAExB,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAA6C;IAC1G,MAAM,QAAQ,GAAG;QACf,IAAI;QACJ,IAAI,EAAE,SAAS,IAAI,IAAI;QACvB,SAAS,EAAE;YACT,eAAe,EAAE;gBACf,IAAI,EAAE,WAAoB;gBAC1B,KAAK;gBACL,IAAI;aACL;SACF;KACF,CAAA;IAED,cAAc,CAAC,QAAQ,CAAC,CAAA;IAExB,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BlueprintRobotTokenConfig, type BlueprintRobotTokenResource } from '../index.js';
|
|
1
|
+
import { type BlueprintCrossStackReferenceConfig, type BlueprintResource, type BlueprintRobotTokenConfig, type BlueprintRobotTokenResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a Robot Token for automated access. Has a token property provided during deployment that can be referenced by other resources.
|
|
4
4
|
*
|
|
@@ -20,3 +20,21 @@ import { type BlueprintRobotTokenConfig, type BlueprintRobotTokenResource } from
|
|
|
20
20
|
* @returns The robot token resource
|
|
21
21
|
*/
|
|
22
22
|
export declare function defineRobotToken(parameters: BlueprintRobotTokenConfig): BlueprintRobotTokenResource;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a reference to a robot token in another stack.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* referenceRobotToken({
|
|
28
|
+
* name: 'editor-token',
|
|
29
|
+
* stack: 'editorial',
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @beta Referencing Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
35
|
+
* @category Referencers
|
|
36
|
+
* @expandType BlueprintCrossStackReferenceConfig
|
|
37
|
+
* @param params The parameters for referencing the robot token
|
|
38
|
+
* @returns The robot token reference
|
|
39
|
+
*/
|
|
40
|
+
export declare function referenceRobotToken({ name, stack, localName }: BlueprintCrossStackReferenceConfig): BlueprintResource;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateRobotToken } from '../index.js';
|
|
1
|
+
import { referenceResource, validateRobotToken, } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
3
|
/*
|
|
4
4
|
* FUTURE example (move below @example when ready)
|
|
@@ -50,4 +50,24 @@ export function defineRobotToken(parameters) {
|
|
|
50
50
|
runValidation(() => validateRobotToken(robotResource));
|
|
51
51
|
return robotResource;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a reference to a robot token in another stack.
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* referenceRobotToken({
|
|
58
|
+
* name: 'editor-token',
|
|
59
|
+
* stack: 'editorial',
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
* @beta Referencing Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
65
|
+
* @category Referencers
|
|
66
|
+
* @expandType BlueprintCrossStackReferenceConfig
|
|
67
|
+
* @param params The parameters for referencing the robot token
|
|
68
|
+
* @returns The robot token reference
|
|
69
|
+
*/
|
|
70
|
+
export function referenceRobotToken({ name, stack, localName }) {
|
|
71
|
+
return referenceResource({ name, stack, localName, type: 'sanity.access.robot' });
|
|
72
|
+
}
|
|
53
73
|
//# sourceMappingURL=robotTokens.js.map
|
|
@@ -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,EAKL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAqC;IACpE,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,IAAI,CAAA;IAEjD,MAAM,aAAa,GAAgC;QACjD,GAAG,UAAU;QACb,KAAK;QACL,IAAI,EAAE,qBAAqB;KAC5B,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAA;IAEtD,OAAO,aAAa,CAAA;AACtB,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,4 +1,4 @@
|
|
|
1
|
-
import { type BlueprintProjectRoleResource, type BlueprintRoleConfig, type BlueprintRoleResource } from '../index.js';
|
|
1
|
+
import { type BlueprintCrossStackReferenceConfig, type BlueprintProjectRoleResource, type BlueprintResource, type BlueprintRoleConfig, type BlueprintRoleResource } from '../index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Defines a role that is scoped to the same resource as the blueprint.
|
|
4
4
|
*
|
|
@@ -47,3 +47,21 @@ export declare function defineRole(parameters: BlueprintRoleConfig, options?: {
|
|
|
47
47
|
* @returns The role resource
|
|
48
48
|
*/
|
|
49
49
|
export declare function defineProjectRole(projectId: string, parameters: BlueprintRoleConfig): BlueprintProjectRoleResource;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a reference to a role in another stack.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* referenceRole({
|
|
55
|
+
* name: 'editor-role',
|
|
56
|
+
* stack: 'editorial',
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
* @beta Referencing Roles via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
62
|
+
* @category Referencers
|
|
63
|
+
* @expandType BlueprintCrossStackReferenceConfig
|
|
64
|
+
* @param params The parameters for referencing the role
|
|
65
|
+
* @returns The role reference
|
|
66
|
+
*/
|
|
67
|
+
export declare function referenceRole({ name, stack, localName }: BlueprintCrossStackReferenceConfig): BlueprintResource;
|
package/dist/definers/roles.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateProjectRole, validateRole, } from '../index.js';
|
|
1
|
+
import { referenceResource, validateProjectRole, validateRole, } from '../index.js';
|
|
2
2
|
import { runValidation } from '../utils/validation.js';
|
|
3
3
|
/*
|
|
4
4
|
* FUTURE example (move below @example when ready)
|
|
@@ -121,4 +121,24 @@ export function defineProjectRole(projectId, parameters) {
|
|
|
121
121
|
runValidation(() => validateProjectRole(projectRoleResource));
|
|
122
122
|
return projectRoleResource;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a reference to a role in another stack.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* referenceRole({
|
|
129
|
+
* name: 'editor-role',
|
|
130
|
+
* stack: 'editorial',
|
|
131
|
+
* })
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @public
|
|
135
|
+
* @beta Referencing Roles via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
136
|
+
* @category Referencers
|
|
137
|
+
* @expandType BlueprintCrossStackReferenceConfig
|
|
138
|
+
* @param params The parameters for referencing the role
|
|
139
|
+
* @returns The role reference
|
|
140
|
+
*/
|
|
141
|
+
export function referenceRole({ name, stack, localName }) {
|
|
142
|
+
return referenceResource({ name, stack, localName, type: 'sanity.access.role' });
|
|
143
|
+
}
|
|
124
144
|
//# sourceMappingURL=roles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/definers/roles.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,UAAU,CAAC,UAA+B,EAAE,OAAoC;IAC9F,MAAM,YAAY,GAA0B;QAC1C,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAA;IAED,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;QACzB,YAAY,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;IAC/C,CAAC;IAED,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI;QAAE,aAAa,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAA;IAErF,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,UAA+B;IAClF,MAAM,YAAY,GAAG,UAAU,CAAC,UAAU,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAA;IAEnE,MAAM,mBAAmB,GAAiC;QACxD,GAAG,YAAY;QACf,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,SAAS;KACtB,CAAA;IAED,aAAa,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,CAAA;IAE7D,OAAO,mBAAmB,CAAA;AAC5B,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/index.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* @categoryDescription Definers
|
|
3
3
|
* These functions are used to define resources in a Blueprint.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* @categoryDescription Referencers
|
|
7
|
+
* These functions are used to reference resources in another Blueprint.
|
|
8
|
+
*/
|
|
5
9
|
export * from './definers/blueprints.js';
|
|
6
10
|
export * from './definers/cors.js';
|
|
7
11
|
export * from './definers/datasets.js';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* @categoryDescription Definers
|
|
4
4
|
* These functions are used to define resources in a Blueprint.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* @categoryDescription Referencers
|
|
8
|
+
* These functions are used to reference resources in another Blueprint.
|
|
9
|
+
*/
|
|
6
10
|
export * from './definers/blueprints.js';
|
|
7
11
|
export * from './definers/cors.js';
|
|
8
12
|
export * from './definers/datasets.js';
|
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,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,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,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AAEnC,4CAA4C;AAC5C;;;GAGG;AACH,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC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types/datasets.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface BlueprintDatasetResource extends BlueprintResource<BlueprintPro
|
|
|
17
17
|
type: 'sanity.project.dataset';
|
|
18
18
|
/** The name of the dataset. Must be unique within a project. */
|
|
19
19
|
datasetName: string;
|
|
20
|
+
/** The dataset description */
|
|
21
|
+
description?: string;
|
|
20
22
|
/** The ACL mode to set for the new dataset. Defaults to public. */
|
|
21
23
|
aclMode?: AclMode;
|
|
22
24
|
/**
|
|
@@ -24,12 +24,25 @@ export interface BlueprintOwnershipAttachAction {
|
|
|
24
24
|
export interface BlueprintOwnershipDetachAction {
|
|
25
25
|
type: 'detach';
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* An ownership action that will cause the resource to be read during deployment so it can be referenced
|
|
29
|
+
* by other resources. Note that referenced resources must be in the same project or organization as the
|
|
30
|
+
* current stack.
|
|
31
|
+
* @category Blueprint Internals
|
|
32
|
+
*/
|
|
33
|
+
export interface BlueprintOwnershipReferenceAction {
|
|
34
|
+
type: 'reference';
|
|
35
|
+
/** The name or id of the stack where the resource is attached */
|
|
36
|
+
stack: string;
|
|
37
|
+
/** The name of the resource to be referenced */
|
|
38
|
+
name: string;
|
|
39
|
+
}
|
|
27
40
|
/**
|
|
28
41
|
* A union of all possible ownership actions.
|
|
29
42
|
* @category Blueprint Internals
|
|
30
43
|
* @expand
|
|
31
44
|
*/
|
|
32
|
-
export type BlueprintOwnershipAction = BlueprintOwnershipAttachAction | BlueprintOwnershipDetachAction;
|
|
45
|
+
export type BlueprintOwnershipAction = BlueprintOwnershipAttachAction | BlueprintOwnershipDetachAction | BlueprintOwnershipReferenceAction;
|
|
33
46
|
/**
|
|
34
47
|
* An ownership action that will cause the referenced project-contained resource to be attached to the current stack.
|
|
35
48
|
* @category Blueprint Internals
|
|
@@ -43,7 +56,7 @@ export interface BlueprintProjectOwnershipAttachAction extends BlueprintOwnershi
|
|
|
43
56
|
* @category Blueprint Internals
|
|
44
57
|
* @expand
|
|
45
58
|
*/
|
|
46
|
-
export type BlueprintProjectOwnershipAction = BlueprintProjectOwnershipAttachAction | BlueprintOwnershipDetachAction;
|
|
59
|
+
export type BlueprintProjectOwnershipAction = BlueprintProjectOwnershipAttachAction | BlueprintOwnershipDetachAction | BlueprintOwnershipReferenceAction;
|
|
47
60
|
/**
|
|
48
61
|
* Defines the lifcycle policy for this resource.
|
|
49
62
|
* @category Blueprint Internals
|
|
@@ -91,3 +104,23 @@ export interface BlueprintResource<Lifecycle extends BlueprintResourceLifecycle
|
|
|
91
104
|
*/
|
|
92
105
|
lifecycle?: Lifecycle;
|
|
93
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* The configuration for referencing a resource in another stack.
|
|
109
|
+
* @category Blueprint Internals
|
|
110
|
+
*/
|
|
111
|
+
export interface BlueprintCrossStackReferenceConfig {
|
|
112
|
+
/** The name of the resource in the other stack */
|
|
113
|
+
name: string;
|
|
114
|
+
/** The name or id of the stack being referenced */
|
|
115
|
+
stack: string;
|
|
116
|
+
/** The local name of the resource, defaults to the name of the other resource */
|
|
117
|
+
localName?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The configuration for referencing a resource in another stack including the type of resource.
|
|
121
|
+
* @category Blueprint Internals
|
|
122
|
+
*/
|
|
123
|
+
export interface BlueprintCrossStackReferenceResourceConfig extends BlueprintCrossStackReferenceConfig {
|
|
124
|
+
/** The type of resource being referenced (e.g. `sanity.project`) */
|
|
125
|
+
type: string;
|
|
126
|
+
}
|
|
@@ -15,6 +15,12 @@ export function validateDataset(resource) {
|
|
|
15
15
|
if ('type' in resource && resource.type !== 'sanity.project.dataset') {
|
|
16
16
|
errors.push({ type: 'invalid_value', message: 'Dataset type must be `sanity.project.dataset`' });
|
|
17
17
|
}
|
|
18
|
+
// validate description if provided
|
|
19
|
+
if ('description' in resource) {
|
|
20
|
+
if (typeof resource.description !== 'string') {
|
|
21
|
+
errors.push({ type: 'invalid_type', message: 'Dataset description must be a string' });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
18
24
|
// validate ACL mode if provided
|
|
19
25
|
if ('aclMode' in resource) {
|
|
20
26
|
if (typeof resource.aclMode !== 'string') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/validation/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,gBAAgB,EAAC,MAAM,aAAa,CAAA;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,QAAiB;IAC/C,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,MAAM,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;QACrE,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,+CAA+C,EAAC,CAAC,CAAA;IAChG,CAAC;IAED,gCAAgC;IAChC,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC1B,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iEAAiE,EAAC,CAAC,CAAA;QACjH,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAW,QAAQ,CAAC,OAAO,CAAA;YACxC,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,SAAS,EAA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W,KAAK,QAAQ,EAAE,CAAC;YAC7C,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,sCAAsC,EAAC,CAAC,CAAA;QACtF,CAAC;IACH,CAAC;IAED,gCAAgC;IAChC,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC1B,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iEAAiE,EAAC,CAAC,CAAA;QACjH,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAW,QAAQ,CAAC,OAAO,CAAA;YACxC,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBAC1E,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iEAAiE,EAAC,CAAC,CAAA;YAClH,CAAC;QACH,CAAC;IACH,CAAC;IAED,+BAA+B;IAC/B,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;QAC1B,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,kCAAkC,EAAC,CAAC,CAAA;QAClF,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -38,7 +38,7 @@ export function validateResource(resource, options) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
if ('ownershipAction' in resource.lifecycle) {
|
|
41
|
-
const ownershipActionTypes = ['attach', 'detach'];
|
|
41
|
+
const ownershipActionTypes = ['attach', 'detach', 'reference'];
|
|
42
42
|
const ownershipAction = resource.lifecycle.ownershipAction;
|
|
43
43
|
if (typeof ownershipAction !== 'object' || ownershipAction === null) {
|
|
44
44
|
errors.push({ type: 'invalid_type', message: '`ownershipAction` must be an object' });
|
|
@@ -69,6 +69,20 @@ export function validateResource(resource, options) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
else if (ownershipAction.type === 'reference') {
|
|
73
|
+
if (!('name' in ownershipAction)) {
|
|
74
|
+
errors.push({ type: 'missing_parameter', message: '`ownershipAction.name` is required for reference' });
|
|
75
|
+
}
|
|
76
|
+
else if (typeof ownershipAction.name !== 'string') {
|
|
77
|
+
errors.push({ type: 'invalid_type', message: '`ownershipAction.name` must be a string' });
|
|
78
|
+
}
|
|
79
|
+
if (!('stack' in ownershipAction)) {
|
|
80
|
+
errors.push({ type: 'missing_parameter', message: '`ownershipAction.stack` is required for reference' });
|
|
81
|
+
}
|
|
82
|
+
else if (typeof ownershipAction.stack !== 'string') {
|
|
83
|
+
errors.push({ type: 'invalid_type', message: '`ownershipAction.stack` must be a string' });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
88
|
if ('dependsOn' in resource.lifecycle) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/validation/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAA;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB,EAAE,OAAsC;IACxF,IAAI,CAAC,QAAQ;QAAE,OAAO,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,kCAAkC,EAAC,CAAC,CAAA;IAC5F,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,mCAAmC,EAAC,CAAC,CAAA;IAE/G,MAAM,MAAM,GAAqB,EAAE,CAAA;IAEnC,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,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,QAAQ,CAAC,SAAS,EAAE,CAAC;gBACtC,IAAI,OAAO,QAAQ,CAAC,SAAS,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;oBACrD,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,wCAAwC,EAAC,CAAC,CAAA;gBACxF,CAAC;qBAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;oBACpE,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,iFAAiF,EAAC,CAAC,CAAA;gBAClI,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAiB;IAC9C,aAAa,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAA;AACjD,CAAC"}
|
package/package.json
CHANGED
package/src/definers/projects.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BlueprintCrossStackReferenceConfig,
|
|
3
|
+
type BlueprintProjectConfig,
|
|
4
|
+
type BlueprintProjectResource,
|
|
5
|
+
type BlueprintResource,
|
|
6
|
+
referenceResource,
|
|
7
|
+
validateProject,
|
|
8
|
+
} from '../index.js'
|
|
2
9
|
import {runValidation} from '../utils/validation.js'
|
|
3
10
|
|
|
4
11
|
/**
|
|
@@ -15,7 +22,7 @@ import {runValidation} from '../utils/validation.js'
|
|
|
15
22
|
* @beta Deploying Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
16
23
|
* @category Definers
|
|
17
24
|
* @expandType BlueprintProjectConfig
|
|
18
|
-
* @returns The
|
|
25
|
+
* @returns The project resource
|
|
19
26
|
* @hidden
|
|
20
27
|
*/
|
|
21
28
|
export function defineProject(parameters: BlueprintProjectConfig): BlueprintProjectResource {
|
|
@@ -32,3 +39,24 @@ export function defineProject(parameters: BlueprintProjectConfig): BlueprintProj
|
|
|
32
39
|
|
|
33
40
|
return projectResource
|
|
34
41
|
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a reference to a project in another stack.
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* referenceProject({
|
|
48
|
+
* name: 'editorial-project',
|
|
49
|
+
* stack: 'editorial',
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param params The parameters for referencing the project
|
|
54
|
+
* @public
|
|
55
|
+
* @beta Referencing Projects via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
56
|
+
* @category Referencers
|
|
57
|
+
* @returns The project reference
|
|
58
|
+
* @hidden
|
|
59
|
+
*/
|
|
60
|
+
export function referenceProject({name, stack, localName}: BlueprintCrossStackReferenceConfig): BlueprintResource {
|
|
61
|
+
return referenceResource({name, stack, localName, type: 'sanity.project'})
|
|
62
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {assertResource, type BlueprintResource} from '../index.js'
|
|
1
|
+
import {assertResource, type BlueprintCrossStackReferenceResourceConfig, type BlueprintResource} from '../index.js'
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* FUTURE example (move below @example when ready)
|
|
@@ -37,3 +37,28 @@ export function defineResource(resourceConfig: Partial<BlueprintResource>): Blue
|
|
|
37
37
|
|
|
38
38
|
return resource
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a reference to a resource in another stack
|
|
43
|
+
* @param params The parameters for referencing the resource
|
|
44
|
+
* @category Definers
|
|
45
|
+
* @expandType BlueprintCrossStackReferenceResourceConfig
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export function referenceResource({name, type, stack, localName}: BlueprintCrossStackReferenceResourceConfig): BlueprintResource {
|
|
49
|
+
const resource = {
|
|
50
|
+
type,
|
|
51
|
+
name: localName || name,
|
|
52
|
+
lifecycle: {
|
|
53
|
+
ownershipAction: {
|
|
54
|
+
type: 'reference' as const,
|
|
55
|
+
stack,
|
|
56
|
+
name,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
assertResource(resource)
|
|
62
|
+
|
|
63
|
+
return resource
|
|
64
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type BlueprintCrossStackReferenceConfig,
|
|
3
|
+
type BlueprintResource,
|
|
4
|
+
type BlueprintRobotTokenConfig,
|
|
5
|
+
type BlueprintRobotTokenResource,
|
|
6
|
+
referenceResource,
|
|
7
|
+
validateRobotToken,
|
|
8
|
+
} from '../index.js'
|
|
2
9
|
import {runValidation} from '../utils/validation.js'
|
|
3
10
|
|
|
4
11
|
/*
|
|
@@ -54,3 +61,24 @@ export function defineRobotToken(parameters: BlueprintRobotTokenConfig): Bluepri
|
|
|
54
61
|
|
|
55
62
|
return robotResource
|
|
56
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates a reference to a robot token in another stack.
|
|
67
|
+
*
|
|
68
|
+
* ```ts
|
|
69
|
+
* referenceRobotToken({
|
|
70
|
+
* name: 'editor-token',
|
|
71
|
+
* stack: 'editorial',
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
* @beta Referencing Robot Tokens via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
77
|
+
* @category Referencers
|
|
78
|
+
* @expandType BlueprintCrossStackReferenceConfig
|
|
79
|
+
* @param params The parameters for referencing the robot token
|
|
80
|
+
* @returns The robot token reference
|
|
81
|
+
*/
|
|
82
|
+
export function referenceRobotToken({name, stack, localName}: BlueprintCrossStackReferenceConfig): BlueprintResource {
|
|
83
|
+
return referenceResource({name, stack, localName, type: 'sanity.access.robot'})
|
|
84
|
+
}
|
package/src/definers/roles.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type BlueprintCrossStackReferenceConfig,
|
|
2
3
|
type BlueprintProjectRoleResource,
|
|
4
|
+
type BlueprintResource,
|
|
3
5
|
type BlueprintRoleConfig,
|
|
4
6
|
type BlueprintRoleResource,
|
|
7
|
+
referenceResource,
|
|
5
8
|
validateProjectRole,
|
|
6
9
|
validateRole,
|
|
7
10
|
} from '../index.js'
|
|
@@ -134,3 +137,24 @@ export function defineProjectRole(projectId: string, parameters: BlueprintRoleCo
|
|
|
134
137
|
|
|
135
138
|
return projectRoleResource
|
|
136
139
|
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Creates a reference to a role in another stack.
|
|
143
|
+
*
|
|
144
|
+
* ```ts
|
|
145
|
+
* referenceRole({
|
|
146
|
+
* name: 'editor-role',
|
|
147
|
+
* stack: 'editorial',
|
|
148
|
+
* })
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
* @beta Referencing Roles via Blueprints is experimental. This feature is stabilizing but may still be subject to breaking changes.
|
|
153
|
+
* @category Referencers
|
|
154
|
+
* @expandType BlueprintCrossStackReferenceConfig
|
|
155
|
+
* @param params The parameters for referencing the role
|
|
156
|
+
* @returns The role reference
|
|
157
|
+
*/
|
|
158
|
+
export function referenceRole({name, stack, localName}: BlueprintCrossStackReferenceConfig): BlueprintResource {
|
|
159
|
+
return referenceResource({name, stack, localName, type: 'sanity.access.role'})
|
|
160
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* @categoryDescription Definers
|
|
4
4
|
* These functions are used to define resources in a Blueprint.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* @categoryDescription Referencers
|
|
8
|
+
* These functions are used to reference resources in another Blueprint.
|
|
9
|
+
*/
|
|
6
10
|
export * from './definers/blueprints.js'
|
|
7
11
|
export * from './definers/cors.js'
|
|
8
12
|
export * from './definers/datasets.js'
|
package/src/types/datasets.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface BlueprintDatasetResource extends BlueprintResource<BlueprintPro
|
|
|
19
19
|
type: 'sanity.project.dataset'
|
|
20
20
|
/** The name of the dataset. Must be unique within a project. */
|
|
21
21
|
datasetName: string
|
|
22
|
+
/** The dataset description */
|
|
23
|
+
description?: string
|
|
22
24
|
/** The ACL mode to set for the new dataset. Defaults to public. */
|
|
23
25
|
aclMode?: AclMode
|
|
24
26
|
|
package/src/types/resources.ts
CHANGED
|
@@ -25,12 +25,25 @@ export interface BlueprintOwnershipAttachAction {
|
|
|
25
25
|
export interface BlueprintOwnershipDetachAction {
|
|
26
26
|
type: 'detach'
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* An ownership action that will cause the resource to be read during deployment so it can be referenced
|
|
30
|
+
* by other resources. Note that referenced resources must be in the same project or organization as the
|
|
31
|
+
* current stack.
|
|
32
|
+
* @category Blueprint Internals
|
|
33
|
+
*/
|
|
34
|
+
export interface BlueprintOwnershipReferenceAction {
|
|
35
|
+
type: 'reference'
|
|
36
|
+
/** The name or id of the stack where the resource is attached */
|
|
37
|
+
stack: string
|
|
38
|
+
/** The name of the resource to be referenced */
|
|
39
|
+
name: string
|
|
40
|
+
}
|
|
28
41
|
/**
|
|
29
42
|
* A union of all possible ownership actions.
|
|
30
43
|
* @category Blueprint Internals
|
|
31
44
|
* @expand
|
|
32
45
|
*/
|
|
33
|
-
export type BlueprintOwnershipAction = BlueprintOwnershipAttachAction | BlueprintOwnershipDetachAction
|
|
46
|
+
export type BlueprintOwnershipAction = BlueprintOwnershipAttachAction | BlueprintOwnershipDetachAction | BlueprintOwnershipReferenceAction
|
|
34
47
|
|
|
35
48
|
/**
|
|
36
49
|
* An ownership action that will cause the referenced project-contained resource to be attached to the current stack.
|
|
@@ -45,7 +58,10 @@ export interface BlueprintProjectOwnershipAttachAction extends BlueprintOwnershi
|
|
|
45
58
|
* @category Blueprint Internals
|
|
46
59
|
* @expand
|
|
47
60
|
*/
|
|
48
|
-
export type BlueprintProjectOwnershipAction =
|
|
61
|
+
export type BlueprintProjectOwnershipAction =
|
|
62
|
+
| BlueprintProjectOwnershipAttachAction
|
|
63
|
+
| BlueprintOwnershipDetachAction
|
|
64
|
+
| BlueprintOwnershipReferenceAction
|
|
49
65
|
|
|
50
66
|
/**
|
|
51
67
|
* Defines the lifcycle policy for this resource.
|
|
@@ -98,3 +114,25 @@ export interface BlueprintResource<Lifecycle extends BlueprintResourceLifecycle
|
|
|
98
114
|
*/
|
|
99
115
|
lifecycle?: Lifecycle
|
|
100
116
|
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The configuration for referencing a resource in another stack.
|
|
120
|
+
* @category Blueprint Internals
|
|
121
|
+
*/
|
|
122
|
+
export interface BlueprintCrossStackReferenceConfig {
|
|
123
|
+
/** The name of the resource in the other stack */
|
|
124
|
+
name: string
|
|
125
|
+
/** The name or id of the stack being referenced */
|
|
126
|
+
stack: string
|
|
127
|
+
/** The local name of the resource, defaults to the name of the other resource */
|
|
128
|
+
localName?: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The configuration for referencing a resource in another stack including the type of resource.
|
|
133
|
+
* @category Blueprint Internals
|
|
134
|
+
*/
|
|
135
|
+
export interface BlueprintCrossStackReferenceResourceConfig extends BlueprintCrossStackReferenceConfig {
|
|
136
|
+
/** The type of resource being referenced (e.g. `sanity.project`) */
|
|
137
|
+
type: string
|
|
138
|
+
}
|
|
@@ -17,6 +17,13 @@ export function validateDataset(resource: unknown): BlueprintError[] {
|
|
|
17
17
|
errors.push({type: 'invalid_value', message: 'Dataset type must be `sanity.project.dataset`'})
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// validate description if provided
|
|
21
|
+
if ('description' in resource) {
|
|
22
|
+
if (typeof resource.description !== 'string') {
|
|
23
|
+
errors.push({type: 'invalid_type', message: 'Dataset description must be a string'})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
// validate ACL mode if provided
|
|
21
28
|
if ('aclMode' in resource) {
|
|
22
29
|
if (typeof resource.aclMode !== 'string') {
|
|
@@ -39,7 +39,7 @@ export function validateResource(resource: unknown, options?: {projectContained?
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if ('ownershipAction' in resource.lifecycle) {
|
|
42
|
-
const ownershipActionTypes = ['attach', 'detach']
|
|
42
|
+
const ownershipActionTypes = ['attach', 'detach', 'reference']
|
|
43
43
|
const ownershipAction = resource.lifecycle.ownershipAction
|
|
44
44
|
|
|
45
45
|
if (typeof ownershipAction !== 'object' || ownershipAction === null) {
|
|
@@ -65,6 +65,18 @@ export function validateResource(resource: unknown, options?: {projectContained?
|
|
|
65
65
|
errors.push({type: 'invalid_type', message: '`ownershipAction.projectId` must be a string'})
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
} else if (ownershipAction.type === 'reference') {
|
|
69
|
+
if (!('name' in ownershipAction)) {
|
|
70
|
+
errors.push({type: 'missing_parameter', message: '`ownershipAction.name` is required for reference'})
|
|
71
|
+
} else if (typeof ownershipAction.name !== 'string') {
|
|
72
|
+
errors.push({type: 'invalid_type', message: '`ownershipAction.name` must be a string'})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!('stack' in ownershipAction)) {
|
|
76
|
+
errors.push({type: 'missing_parameter', message: '`ownershipAction.stack` is required for reference'})
|
|
77
|
+
} else if (typeof ownershipAction.stack !== 'string') {
|
|
78
|
+
errors.push({type: 'invalid_type', message: '`ownershipAction.stack` must be a string'})
|
|
79
|
+
}
|
|
68
80
|
}
|
|
69
81
|
}
|
|
70
82
|
}
|