@sanity/blueprints 0.23.6 → 0.26.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.
Files changed (46) hide show
  1. package/dist/definers/applications.d.ts +164 -0
  2. package/dist/definers/applications.js +211 -0
  3. package/dist/definers/applications.js.map +1 -0
  4. package/dist/definers/installation-config.d.ts +26 -0
  5. package/dist/definers/installation-config.js +36 -0
  6. package/dist/definers/installation-config.js.map +1 -0
  7. package/dist/definers/studios.d.ts +1 -1
  8. package/dist/definers/studios.js +1 -1
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.js +6 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/types/applications.d.ts +290 -0
  13. package/dist/types/applications.js +25 -0
  14. package/dist/types/applications.js.map +1 -0
  15. package/dist/types/installation-config.d.ts +75 -0
  16. package/dist/types/installation-config.js +2 -0
  17. package/dist/types/installation-config.js.map +1 -0
  18. package/dist/types/projects.d.ts +1 -1
  19. package/dist/types/robotTokens.d.ts +4 -4
  20. package/dist/types/studios.d.ts +2 -2
  21. package/dist/utils/validation.d.ts +1 -1
  22. package/dist/validation/applications.d.ts +58 -0
  23. package/dist/validation/applications.js +308 -0
  24. package/dist/validation/applications.js.map +1 -0
  25. package/dist/validation/installation-config.d.ts +18 -0
  26. package/dist/validation/installation-config.js +110 -0
  27. package/dist/validation/installation-config.js.map +1 -0
  28. package/dist/validation/robotTokens.js +14 -10
  29. package/dist/validation/robotTokens.js.map +1 -1
  30. package/dist/validation/studios.js +4 -4
  31. package/dist/validation/studios.js.map +1 -1
  32. package/package.json +4 -4
  33. package/src/definers/applications.ts +237 -0
  34. package/src/definers/installation-config.ts +38 -0
  35. package/src/definers/studios.ts +1 -1
  36. package/src/index.ts +6 -0
  37. package/src/types/applications.ts +337 -0
  38. package/src/types/installation-config.ts +86 -0
  39. package/src/types/projects.ts +1 -1
  40. package/src/types/robotTokens.ts +4 -4
  41. package/src/types/studios.ts +2 -2
  42. package/src/utils/validation.ts +1 -1
  43. package/src/validation/applications.ts +330 -0
  44. package/src/validation/installation-config.ts +115 -0
  45. package/src/validation/robotTokens.ts +16 -8
  46. package/src/validation/studios.ts +4 -4
@@ -0,0 +1,290 @@
1
+ import type { ApplicationVisibility, BlueprintResource } from '../index.js';
2
+ /**
3
+ * The set of valid tile footprint families.
4
+ *
5
+ * Modelled on widget families rather than a linear scale: `banner` is
6
+ * full-width and shallow, which a `small` → `large` magnitude can't express.
7
+ * @beta This feature is subject to breaking changes.
8
+ * @category Resource Types
9
+ * @hidden
10
+ */
11
+ export declare const APPLICATION_TILE_SIZES: readonly ['small', 'large', 'banner'];
12
+ /**
13
+ * The footprint family a tile view occupies on the dashboard.
14
+ * @beta This feature is subject to breaking changes.
15
+ * @category Resource Types
16
+ * @hidden
17
+ */
18
+ export type ApplicationTileSize = (typeof APPLICATION_TILE_SIZES)[number];
19
+ /**
20
+ * The set of surfaces a view can target within the Dashboard/Workbench.
21
+ * @beta This feature is subject to breaking changes.
22
+ * @category Resource Types
23
+ * @hidden
24
+ */
25
+ export declare const APPLICATION_VIEW_SURFACES: readonly ['window', 'panel', 'asset-source', 'tile'];
26
+ /**
27
+ * The surface a view targets. Used as the discriminator on view configs; the
28
+ * definers transform it to the emitted view `type` the backend expects.
29
+ * @beta This feature is subject to breaking changes.
30
+ * @category Resource Types
31
+ * @hidden
32
+ */
33
+ export type ApplicationViewSurface = (typeof APPLICATION_VIEW_SURFACES)[number];
34
+ /**
35
+ * The set of dock groups a window or panel view can be placed into.
36
+ * @beta This feature is subject to breaking changes.
37
+ * @category Resource Types
38
+ * @hidden
39
+ */
40
+ export declare const APPLICATION_DOCK_GROUPS: readonly ['system', 'applications', 'user'];
41
+ /**
42
+ * The dock group a window or panel view is placed into.
43
+ * @beta This feature is subject to breaking changes.
44
+ * @category Resource Types
45
+ * @hidden
46
+ */
47
+ export type ApplicationDockGroup = (typeof APPLICATION_DOCK_GROUPS)[number];
48
+ /**
49
+ * Dock placement for a window view.
50
+ * @beta This feature is subject to breaking changes.
51
+ * @category Resource Types
52
+ * @expand
53
+ * @hidden
54
+ */
55
+ export interface BlueprintApplicationDock {
56
+ /**
57
+ * The dock group the window or panel view is placed into.
58
+ *
59
+ * @defaultValue `applications` — the API places the view in the applications dock group when omitted.
60
+ */
61
+ group?: ApplicationDockGroup;
62
+ /**
63
+ * Sort position within the group, ascending.
64
+ *
65
+ * @defaultValue Omitted — ordering falls back to the dashboard application's built-in settings.
66
+ */
67
+ order?: number;
68
+ }
69
+ /**
70
+ * Fields shared by every view and web worker an application exposes.
71
+ * @beta This feature is subject to breaking changes.
72
+ * @category Resource Types
73
+ * @hidden
74
+ */
75
+ export interface BlueprintApplicationChildBase {
76
+ /** Unique within the application. Must match `^[a-zA-Z0-9_-]+$`. */
77
+ name: string;
78
+ /** Human-readable title for the view. */
79
+ title: string;
80
+ /** The location of the view source code, relative to the application `root`. */
81
+ src: string;
82
+ }
83
+ /**
84
+ * A window view — the navigable, full-page view of an application.
85
+ * @beta This feature is subject to breaking changes.
86
+ * @category Resource Types
87
+ * @hidden
88
+ */
89
+ export interface BlueprintWindowView extends BlueprintApplicationChildBase {
90
+ type: 'app';
91
+ /**
92
+ * Dock placement for the window view.
93
+ *
94
+ * @defaultValue Omitted — the dashboard applies its default placement (the `applications` group with built-in ordering).
95
+ */
96
+ dock?: BlueprintApplicationDock;
97
+ }
98
+ /**
99
+ * A panel view — renders in the dock.
100
+ * @beta This feature is subject to breaking changes.
101
+ * @category Resource Types
102
+ * @hidden
103
+ */
104
+ export interface BlueprintPanelView extends BlueprintApplicationChildBase {
105
+ type: 'panel';
106
+ /**
107
+ * Dock placement for the panel view.
108
+ *
109
+ * @defaultValue Omitted — the dashboard applies its default placement (the `applications` group with built-in ordering).
110
+ */
111
+ dock?: BlueprintApplicationDock;
112
+ }
113
+ /**
114
+ * An asset source view — contributes an asset source.
115
+ * @beta This feature is subject to breaking changes.
116
+ * @category Resource Types
117
+ * @hidden
118
+ */
119
+ export interface BlueprintAssetSourceView extends BlueprintApplicationChildBase {
120
+ type: 'asset_source';
121
+ }
122
+ /**
123
+ * A tile view — docks on the dashboard with a footprint `size`.
124
+ * @beta This feature is subject to breaking changes.
125
+ * @category Resource Types
126
+ * @hidden
127
+ */
128
+ export interface BlueprintTileView extends BlueprintApplicationChildBase {
129
+ type: 'tile';
130
+ /** The footprint family the dashboard lays the tile out by. */
131
+ size: ApplicationTileSize;
132
+ /**
133
+ * Sort position within its layout track, ascending.
134
+ *
135
+ * @defaultValue Omitted — ordering falls back to the dashboard application's built-in settings.
136
+ */
137
+ order?: number;
138
+ }
139
+ /**
140
+ * A background web worker an application runs.
141
+ * @beta This feature is subject to breaking changes.
142
+ * @category Resource Types
143
+ * @hidden
144
+ */
145
+ export interface BlueprintWebWorker extends BlueprintApplicationChildBase {
146
+ type: 'worker';
147
+ }
148
+ /**
149
+ * A union of all view declarations an application can expose.
150
+ * @beta This feature is subject to breaking changes.
151
+ * @category Resource Types
152
+ * @expand
153
+ * @hidden
154
+ */
155
+ export type BlueprintApplicationView = BlueprintWindowView | BlueprintPanelView | BlueprintAssetSourceView | BlueprintTileView;
156
+ /**
157
+ * A union of everything an application declares — its views and web workers.
158
+ * @beta This feature is subject to breaking changes.
159
+ * @category Resource Types
160
+ * @hidden
161
+ */
162
+ export type BlueprintApplicationChild = BlueprintApplicationView | BlueprintWebWorker;
163
+ /**
164
+ * Represents an Application resource.
165
+ * @beta This feature is subject to breaking changes.
166
+ * @category Resource Types
167
+ * @hidden
168
+ */
169
+ export interface BlueprintApplicationResource extends BlueprintResource {
170
+ type: 'sanity.application';
171
+ /** The slug to be used in the application hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`. */
172
+ slug: string;
173
+ /** User-facing title for the application. */
174
+ title: string;
175
+ /**
176
+ * The application root directory, relative to the blueprint file. Contains the
177
+ * application's `package.json`; every view and web worker `src` is resolved
178
+ * relative to it.
179
+ */
180
+ root: string;
181
+ /** Icon for the application (path to an SVG). */
182
+ icon?: string;
183
+ /** Dashboard visibility. */
184
+ visibility?: ApplicationVisibility;
185
+ /** The window, panel, asset source, and tile views the application exposes. */
186
+ views?: BlueprintApplicationView[];
187
+ /** The background web workers the application runs. */
188
+ webWorkers?: BlueprintWebWorker[];
189
+ }
190
+ export interface BlueprintViewConfigBase {
191
+ type: 'view';
192
+ }
193
+ /**
194
+ * Configuration for a window view.
195
+ *
196
+ * @remarks
197
+ * Discriminated by `surface`. The definer transforms `surface: 'window'` to the
198
+ * emitted view `type: 'app'`.
199
+ * @beta This feature is subject to breaking changes.
200
+ * @category Resource Types
201
+ * @interface
202
+ * @hidden
203
+ */
204
+ export type BlueprintWindowViewConfig = Omit<BlueprintWindowView, 'type'> & BlueprintViewConfigBase & {
205
+ /** The surface the view targets. */
206
+ surface: 'window';
207
+ };
208
+ /**
209
+ * Configuration for a panel view.
210
+ *
211
+ * @remarks
212
+ * Discriminated by `surface`. The definer transforms `surface: 'panel'` to the
213
+ * emitted view `type: 'panel'`.
214
+ * @beta This feature is subject to breaking changes.
215
+ * @category Resource Types
216
+ * @interface
217
+ * @hidden
218
+ */
219
+ export type BlueprintPanelViewConfig = Omit<BlueprintPanelView, 'type'> & BlueprintViewConfigBase & {
220
+ /** The surface the view targets. */
221
+ surface: 'panel';
222
+ };
223
+ /**
224
+ * Configuration for an asset source view.
225
+ *
226
+ * @remarks
227
+ * Discriminated by `surface`. The definer transforms `surface: 'asset-source'`
228
+ * to the emitted view `type: 'asset_source'`.
229
+ * @beta This feature is subject to breaking changes.
230
+ * @category Resource Types
231
+ * @interface
232
+ * @hidden
233
+ */
234
+ export type BlueprintAssetSourceViewConfig = Omit<BlueprintAssetSourceView, 'type'> & BlueprintViewConfigBase & {
235
+ /** The surface the view targets. */
236
+ surface: 'asset-source';
237
+ };
238
+ /**
239
+ * Configuration for a tile view.
240
+ *
241
+ * @remarks
242
+ * Discriminated by `surface`. The definer transforms `surface: 'tile'` to the
243
+ * emitted view `type: 'tile'`.
244
+ * @beta This feature is subject to breaking changes.
245
+ * @category Resource Types
246
+ * @interface
247
+ * @hidden
248
+ */
249
+ export type BlueprintTileViewConfig = Omit<BlueprintTileView, 'type'> & BlueprintViewConfigBase & {
250
+ /** The surface the view targets. */
251
+ surface: 'tile';
252
+ };
253
+ /**
254
+ * Configuration for a web worker.
255
+ * @beta This feature is subject to breaking changes.
256
+ * @category Resource Types
257
+ * @interface
258
+ * @hidden
259
+ */
260
+ export type BlueprintWebWorkerConfig = Omit<BlueprintWebWorker, 'type'>;
261
+ /**
262
+ * A union of all view configs an application can declare, discriminated by `surface`.
263
+ * @beta This feature is subject to breaking changes.
264
+ * @category Resource Types
265
+ * @expand
266
+ * @hidden
267
+ */
268
+ export type BlueprintApplicationViewConfig = BlueprintWindowViewConfig | BlueprintPanelViewConfig | BlueprintAssetSourceViewConfig | BlueprintTileViewConfig;
269
+ /**
270
+ * Configuration for an Application resource.
271
+ * @beta This feature is subject to breaking changes.
272
+ * @category Resource Types
273
+ * @interface
274
+ * @hidden
275
+ */
276
+ export type BlueprintApplicationConfig = Omit<BlueprintApplicationResource, 'type' | 'slug' | 'views'> & {
277
+ /**
278
+ * The slug to be used in the application hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`.
279
+ *
280
+ * Defaults to the resource `name`.
281
+ */
282
+ slug?: string;
283
+ /**
284
+ * The window, panel, asset source, and tile views the application exposes.
285
+ *
286
+ * Authored as surface-discriminated view configs and transformed to the
287
+ * emitted view `type` the backend expects.
288
+ */
289
+ views?: BlueprintApplicationViewConfig[];
290
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The set of valid tile footprint families.
3
+ *
4
+ * Modelled on widget families rather than a linear scale: `banner` is
5
+ * full-width and shallow, which a `small` → `large` magnitude can't express.
6
+ * @beta This feature is subject to breaking changes.
7
+ * @category Resource Types
8
+ * @hidden
9
+ */
10
+ export const APPLICATION_TILE_SIZES = ['small', 'large', 'banner'];
11
+ /**
12
+ * The set of surfaces a view can target within the Dashboard/Workbench.
13
+ * @beta This feature is subject to breaking changes.
14
+ * @category Resource Types
15
+ * @hidden
16
+ */
17
+ export const APPLICATION_VIEW_SURFACES = ['window', 'panel', 'asset-source', 'tile'];
18
+ /**
19
+ * The set of dock groups a window or panel view can be placed into.
20
+ * @beta This feature is subject to breaking changes.
21
+ * @category Resource Types
22
+ * @hidden
23
+ */
24
+ export const APPLICATION_DOCK_GROUPS = ['system', 'applications', 'user'];
25
+ //# sourceMappingURL=applications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applications.js","sourceRoot":"","sources":["../../src/types/applications.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AAU3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,CAAU,CAAA;AAW7F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,CAAU,CAAA"}
@@ -0,0 +1,75 @@
1
+ import type { BlueprintResource } from '../index.js';
2
+ /**
3
+ * Fields shared by every singleton installation config resource.
4
+ *
5
+ * @remarks
6
+ * The backend selects a provider from the resource `type`
7
+ * (`sanity.installation.config`), so every installation config shares that one
8
+ * type and is discriminated by `appType`.
9
+ * @beta This feature is subject to breaking changes.
10
+ * @category Resource Types
11
+ * @hidden
12
+ */
13
+ export interface BlueprintInstallationConfigResourceBase extends BlueprintResource {
14
+ type: 'sanity.installation.config';
15
+ /** The installation this config targets. Discriminates the config shape. */
16
+ appType: string;
17
+ /**
18
+ * The config build directory, relative to the blueprint file. Contains the
19
+ * config's `package.json`; every field `src` is resolved relative to it.
20
+ */
21
+ root: string;
22
+ }
23
+ /**
24
+ * One custom field a Media Library configuration exposes.
25
+ * @beta This feature is subject to breaking changes.
26
+ * @category Resource Types
27
+ * @hidden
28
+ */
29
+ export interface BlueprintMediaLibraryField {
30
+ /** Unique within the Media Library config. */
31
+ name: string;
32
+ /** Human-readable title for the field. */
33
+ title: string;
34
+ /** The location of the field source code, relative to `root`. */
35
+ src: string;
36
+ /** Readable outside the owning organization. */
37
+ public?: boolean;
38
+ }
39
+ /**
40
+ * Represents a singleton Media Library configuration resource.
41
+ *
42
+ * @remarks
43
+ * The Media Library is a Sanity-owned singleton, so this resource carries no
44
+ * application identity of its own — it only names the target `appType`, the
45
+ * config `root`, and its `fields`. The provider resolves the organization's
46
+ * media library installation id at deploy time.
47
+ * @beta This feature is subject to breaking changes.
48
+ * @category Resource Types
49
+ * @hidden
50
+ */
51
+ export interface BlueprintMediaLibraryConfigResource extends BlueprintInstallationConfigResourceBase {
52
+ /** The target installation this config applies to. Set by the definer. */
53
+ appType: 'media-library';
54
+ /** The custom fields the Media Library config exposes. */
55
+ fields: BlueprintMediaLibraryField[];
56
+ }
57
+ /**
58
+ * A union of every singleton installation config resource, discriminated by `appType`.
59
+ *
60
+ * @remarks
61
+ * Media Library is the only member today; additional installation configs are
62
+ * added to this union.
63
+ * @beta This feature is subject to breaking changes.
64
+ * @category Resource Types
65
+ * @hidden
66
+ */
67
+ export type BlueprintInstallationConfigResource = BlueprintMediaLibraryConfigResource;
68
+ /**
69
+ * Configuration for a singleton Media Library configuration resource.
70
+ * @beta This feature is subject to breaking changes.
71
+ * @category Resource Types
72
+ * @interface
73
+ * @hidden
74
+ */
75
+ export type BlueprintMediaLibraryConfigConfig = Omit<BlueprintMediaLibraryConfigResource, 'type' | 'appType'>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=installation-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installation-config.js","sourceRoot":"","sources":["../../src/types/installation-config.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import type { BlueprintResource, BlueprintResourceLifecycle } from './resources';
1
+ import type { BlueprintResource, BlueprintResourceLifecycle } from './resources.js';
2
2
  /**
3
3
  * Reporesents a Sanity Project.
4
4
  * @see https://www.sanity.io/docs/http-reference/projects-api
@@ -1,18 +1,18 @@
1
- import type { BlueprintProjectResourceLifecycle, BlueprintResource } from './resources';
1
+ import type { BlueprintProjectResourceLifecycle, BlueprintResource } from './resources.js';
2
2
  /**
3
3
  * Resource types that robot tokens can be attached to.
4
4
  * @internal
5
5
  */
6
6
  export type RobotTokenResourceType = 'organization' | 'project';
7
7
  /**
8
- * Defines the robot token's roles within a given resource.
8
+ * Defines the robot token's roles within a given resource. Membership scope defaults to the robot token's scope.
9
9
  * @beta This feature is subject to breaking changes.
10
10
  * @category Resource Types
11
11
  * @expand
12
12
  */
13
13
  export interface RobotTokenMembership {
14
- resourceType: RobotTokenResourceType;
15
- resourceId: string;
14
+ resourceType?: RobotTokenResourceType;
15
+ resourceId?: string;
16
16
  roleNames: string[];
17
17
  }
18
18
  /**
@@ -31,8 +31,8 @@ export type ApplicationVisibility = (typeof APPLICATION_VISIBILITIES)[number];
31
31
  */
32
32
  export interface BlueprintStudioResource extends BlueprintResource<BlueprintProjectResourceLifecycle> {
33
33
  type: 'sanity.studio';
34
- /** The relative location of the studio source code. */
35
- src: string;
34
+ /** The relative location of the studio directory. */
35
+ root: string;
36
36
  /**
37
37
  * The project ID of the project that contains your Studio.
38
38
  *
@@ -1,4 +1,4 @@
1
- import type { BlueprintError } from '../types/errors';
1
+ import type { BlueprintError } from '../types/errors.js';
2
2
  /**
3
3
  * Executes the given validator function and throws a formatted error if any are returned and throwError is enabled.
4
4
  * Otherwise collects errors for use later during blueprint validation.
@@ -0,0 +1,58 @@
1
+ import type { BlueprintError } from '../types/errors.js';
2
+ /**
3
+ * Whether a path stays within the directory it is resolved against, i.e. it is
4
+ * relative and never climbs above its starting point.
5
+ * @param path The path to check
6
+ * @hidden
7
+ * @category Validation
8
+ * @returns true when the path is relative and does not escape its root
9
+ */
10
+ export declare function isContainedRelativePath(path: string): boolean;
11
+ /**
12
+ * Validates that the given resource is a valid window view.
13
+ * @param resource The window view
14
+ * @hidden
15
+ * @category Validation
16
+ * @returns A list of validation errors
17
+ */
18
+ export declare function validateWindowView(resource: unknown): BlueprintError[];
19
+ /**
20
+ * Validates that the given resource is a valid panel view.
21
+ * @param resource The panel view
22
+ * @hidden
23
+ * @category Validation
24
+ * @returns A list of validation errors
25
+ */
26
+ export declare function validatePanelView(resource: unknown): BlueprintError[];
27
+ /**
28
+ * Validates that the given resource is a valid asset source view.
29
+ * @param resource The asset source view
30
+ * @hidden
31
+ * @category Validation
32
+ * @returns A list of validation errors
33
+ */
34
+ export declare function validateAssetSourceView(resource: unknown): BlueprintError[];
35
+ /**
36
+ * Validates that the given resource is a valid tile view.
37
+ * @param resource The tile view
38
+ * @hidden
39
+ * @category Validation
40
+ * @returns A list of validation errors
41
+ */
42
+ export declare function validateTileView(resource: unknown): BlueprintError[];
43
+ /**
44
+ * Validates that the given resource is a valid web worker.
45
+ * @param resource The web worker
46
+ * @hidden
47
+ * @category Validation
48
+ * @returns A list of validation errors
49
+ */
50
+ export declare function validateWebWorker(resource: unknown): BlueprintError[];
51
+ /**
52
+ * Validates that the given resource is a valid Application.
53
+ * @param resource The Application resource
54
+ * @hidden
55
+ * @category Validation
56
+ * @returns A list of validation errors
57
+ */
58
+ export declare function validateApplication(resource: unknown): BlueprintError[];