@sanity/blueprints 0.24.0 → 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.
- package/dist/definers/applications.d.ts +164 -0
- package/dist/definers/applications.js +211 -0
- package/dist/definers/applications.js.map +1 -0
- package/dist/definers/installation-config.d.ts +26 -0
- package/dist/definers/installation-config.js +36 -0
- package/dist/definers/installation-config.js.map +1 -0
- package/dist/definers/studios.d.ts +1 -1
- package/dist/definers/studios.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/types/applications.d.ts +290 -0
- package/dist/types/applications.js +25 -0
- package/dist/types/applications.js.map +1 -0
- package/dist/types/installation-config.d.ts +75 -0
- package/dist/types/installation-config.js +2 -0
- package/dist/types/installation-config.js.map +1 -0
- package/dist/types/projects.d.ts +1 -1
- package/dist/types/robotTokens.d.ts +1 -1
- package/dist/types/studios.d.ts +2 -2
- package/dist/utils/validation.d.ts +1 -1
- package/dist/validation/applications.d.ts +58 -0
- package/dist/validation/applications.js +308 -0
- package/dist/validation/applications.js.map +1 -0
- package/dist/validation/installation-config.d.ts +18 -0
- package/dist/validation/installation-config.js +110 -0
- package/dist/validation/installation-config.js.map +1 -0
- package/dist/validation/studios.js +4 -4
- package/dist/validation/studios.js.map +1 -1
- package/package.json +4 -4
- package/src/definers/applications.ts +237 -0
- package/src/definers/installation-config.ts +38 -0
- package/src/definers/studios.ts +1 -1
- package/src/index.ts +6 -0
- package/src/types/applications.ts +337 -0
- package/src/types/installation-config.ts +86 -0
- package/src/types/projects.ts +1 -1
- package/src/types/robotTokens.ts +1 -1
- package/src/types/studios.ts +2 -2
- package/src/utils/validation.ts +1 -1
- package/src/validation/applications.ts +330 -0
- package/src/validation/installation-config.ts +115 -0
- package/src/validation/studios.ts +4 -4
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ApplicationViewSurface,
|
|
3
|
+
type BlueprintApplicationConfig,
|
|
4
|
+
type BlueprintApplicationResource,
|
|
5
|
+
type BlueprintApplicationView,
|
|
6
|
+
type BlueprintApplicationViewConfig,
|
|
7
|
+
type BlueprintAssetSourceViewConfig,
|
|
8
|
+
type BlueprintPanelViewConfig,
|
|
9
|
+
type BlueprintTileViewConfig,
|
|
10
|
+
type BlueprintWebWorker,
|
|
11
|
+
type BlueprintWebWorkerConfig,
|
|
12
|
+
type BlueprintWindowViewConfig,
|
|
13
|
+
validateApplication,
|
|
14
|
+
validateAssetSourceView,
|
|
15
|
+
validatePanelView,
|
|
16
|
+
validateTileView,
|
|
17
|
+
validateWebWorker,
|
|
18
|
+
validateWindowView,
|
|
19
|
+
} from '../index.js'
|
|
20
|
+
import {runValidation} from '../utils/validation.js'
|
|
21
|
+
|
|
22
|
+
/** Maps a view `surface` to the view `type` the backend expects. */
|
|
23
|
+
const SURFACE_TO_TYPE = {
|
|
24
|
+
window: 'app',
|
|
25
|
+
panel: 'panel',
|
|
26
|
+
'asset-source': 'asset_source',
|
|
27
|
+
tile: 'tile',
|
|
28
|
+
} as const satisfies Record<ApplicationViewSurface, BlueprintApplicationView['type']>
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Transforms an authored view config (discriminated by `surface`) into the
|
|
32
|
+
* emitted view resource (discriminated by `type`), stripping `surface`.
|
|
33
|
+
*/
|
|
34
|
+
function viewConfigToResource(view: BlueprintApplicationViewConfig): BlueprintApplicationView {
|
|
35
|
+
const {surface, ...rest} = view
|
|
36
|
+
// The surface→type mapping guarantees a valid member of the emitted union.
|
|
37
|
+
return {...rest, type: SURFACE_TO_TYPE[surface]} as BlueprintApplicationView
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Defines a window view — the navigable, full-page view of an application.
|
|
42
|
+
* An application may declare at most one window view.
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* defineWindowView({
|
|
46
|
+
* name: 'main',
|
|
47
|
+
* title: 'Design Retro',
|
|
48
|
+
* src: './src/windows/main.tsx',
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example With dock placement
|
|
53
|
+
* ```ts
|
|
54
|
+
* defineWindowView({
|
|
55
|
+
* name: 'main',
|
|
56
|
+
* title: 'Design Retro',
|
|
57
|
+
* src: './src/windows/main.tsx',
|
|
58
|
+
* dock: {group: 'applications', order: 10},
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
* @param config The window view configuration
|
|
62
|
+
* @public
|
|
63
|
+
* @beta Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
64
|
+
* @category Definers
|
|
65
|
+
* @expandType BlueprintWindowViewConfig
|
|
66
|
+
* @returns The window view declaration
|
|
67
|
+
* @hidden
|
|
68
|
+
*/
|
|
69
|
+
export function defineWindowView(config: Omit<BlueprintWindowViewConfig, 'surface' | 'type'>): BlueprintWindowViewConfig {
|
|
70
|
+
const view: BlueprintWindowViewConfig = {...config, surface: 'window', type: 'view'}
|
|
71
|
+
runValidation(() => validateWindowView(viewConfigToResource(view)))
|
|
72
|
+
return view
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Defines a panel view — renders in the dock.
|
|
77
|
+
*
|
|
78
|
+
* ```ts
|
|
79
|
+
* definePanelView({
|
|
80
|
+
* name: 'side',
|
|
81
|
+
* title: 'Favorites',
|
|
82
|
+
* src: './src/panels/main.tsx',
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
* @param config The panel view configuration
|
|
86
|
+
* @public
|
|
87
|
+
* @beta Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
88
|
+
* @category Definers
|
|
89
|
+
* @expandType BlueprintPanelViewConfig
|
|
90
|
+
* @returns The panel view declaration
|
|
91
|
+
* @hidden
|
|
92
|
+
*/
|
|
93
|
+
export function definePanelView(config: Omit<BlueprintPanelViewConfig, 'surface' | 'type'>): BlueprintPanelViewConfig {
|
|
94
|
+
const view: BlueprintPanelViewConfig = {...config, surface: 'panel', type: 'view'}
|
|
95
|
+
runValidation(() => validatePanelView(viewConfigToResource(view)))
|
|
96
|
+
return view
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Defines an asset source view — contributes an asset source.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* defineAssetSourceView({
|
|
104
|
+
* name: 'image-picker',
|
|
105
|
+
* title: 'Image Picker',
|
|
106
|
+
* src: './src/asset-sources/image-picker.tsx',
|
|
107
|
+
* })
|
|
108
|
+
* ```
|
|
109
|
+
* @param config The asset source view configuration
|
|
110
|
+
* @public
|
|
111
|
+
* @beta Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
112
|
+
* @category Definers
|
|
113
|
+
* @expandType BlueprintAssetSourceViewConfig
|
|
114
|
+
* @returns The asset source view declaration
|
|
115
|
+
* @hidden
|
|
116
|
+
*/
|
|
117
|
+
export function defineAssetSourceView(config: Omit<BlueprintAssetSourceViewConfig, 'surface' | 'type'>): BlueprintAssetSourceViewConfig {
|
|
118
|
+
const view: BlueprintAssetSourceViewConfig = {...config, surface: 'asset-source', type: 'view'}
|
|
119
|
+
runValidation(() => validateAssetSourceView(viewConfigToResource(view)))
|
|
120
|
+
return view
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Defines a tile view — docks on the dashboard with a footprint `size`.
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* defineTileView({
|
|
128
|
+
* name: 'jump-back-in',
|
|
129
|
+
* title: 'Main Tile',
|
|
130
|
+
* src: './src/tiles/jump-back-in.tsx',
|
|
131
|
+
* size: 'banner',
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
* @param config The tile view configuration
|
|
135
|
+
* @public
|
|
136
|
+
* @beta Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
137
|
+
* @category Definers
|
|
138
|
+
* @expandType BlueprintTileViewConfig
|
|
139
|
+
* @returns The tile view declaration
|
|
140
|
+
* @hidden
|
|
141
|
+
*/
|
|
142
|
+
export function defineTileView(config: Omit<BlueprintTileViewConfig, 'surface' | 'type'>): BlueprintTileViewConfig {
|
|
143
|
+
const view: BlueprintTileViewConfig = {...config, surface: 'tile', type: 'view'}
|
|
144
|
+
runValidation(() => validateTileView(viewConfigToResource(view)))
|
|
145
|
+
return view
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Defines a background web worker an application runs.
|
|
150
|
+
*
|
|
151
|
+
* ```ts
|
|
152
|
+
* defineWebWorker({
|
|
153
|
+
* name: 'background-refresh',
|
|
154
|
+
* title: 'Background Worker',
|
|
155
|
+
* src: './src/workers/background-refresh.ts',
|
|
156
|
+
* })
|
|
157
|
+
* ```
|
|
158
|
+
* @param config The web worker configuration
|
|
159
|
+
* @public
|
|
160
|
+
* @beta Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
161
|
+
* @category Definers
|
|
162
|
+
* @expandType BlueprintWebWorkerConfig
|
|
163
|
+
* @returns The web worker declaration
|
|
164
|
+
* @hidden
|
|
165
|
+
*/
|
|
166
|
+
export function defineWebWorker(config: BlueprintWebWorkerConfig): BlueprintWebWorker {
|
|
167
|
+
const worker: BlueprintWebWorker = {...config, type: 'worker'}
|
|
168
|
+
runValidation(() => validateWebWorker(worker))
|
|
169
|
+
return worker
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Defines an application.
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* Views are authored in `views` and web workers in `webWorkers`, mirroring the
|
|
177
|
+
* emitted resource. Views are discriminated by `surface` (`window`, `panel`,
|
|
178
|
+
* `asset-source`, `tile`) and transformed to the emitted view `type` the
|
|
179
|
+
* backend expects. An application must declare at least one view of any
|
|
180
|
+
* surface, and at most one `window` view. Every view and web worker `src` is
|
|
181
|
+
* resolved relative to `root`. The `slug` defaults to the resource `name`.
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* defineApplication({
|
|
185
|
+
* name: 'design-retro',
|
|
186
|
+
* title: 'Design Retro',
|
|
187
|
+
* root: './apps/design-retro',
|
|
188
|
+
* views: [
|
|
189
|
+
* defineWindowView({name: 'main', title: 'Design Retro', src: './src/windows/main.tsx'}),
|
|
190
|
+
* ],
|
|
191
|
+
* })
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* @example With views and web workers
|
|
195
|
+
* ```ts
|
|
196
|
+
* defineApplication({
|
|
197
|
+
* name: 'design-retro',
|
|
198
|
+
* title: 'Design Retro',
|
|
199
|
+
* root: './apps/design-retro',
|
|
200
|
+
* slug: 'design-retro',
|
|
201
|
+
* icon: './src/icons/app-icon.svg',
|
|
202
|
+
* visibility: 'unlisted',
|
|
203
|
+
* views: [
|
|
204
|
+
* defineWindowView({
|
|
205
|
+
* name: 'main',
|
|
206
|
+
* title: 'Design Retro',
|
|
207
|
+
* src: './src/windows/main.tsx',
|
|
208
|
+
* dock: {group: 'applications', order: 10},
|
|
209
|
+
* }),
|
|
210
|
+
* definePanelView({name: 'side', title: 'Favorites', src: './src/panels/main.tsx'}),
|
|
211
|
+
* defineAssetSourceView({name: 'image-picker', title: 'Image Picker', src: './src/asset-sources/image-picker.tsx'}),
|
|
212
|
+
* defineTileView({name: 'jump-back-in', title: 'Main Tile', src: './src/tiles/jump-back-in.tsx', size: 'banner'}),
|
|
213
|
+
* ],
|
|
214
|
+
* webWorkers: [
|
|
215
|
+
* defineWebWorker({name: 'background-refresh', title: 'Background Worker', src: './src/workers/background-refresh.ts'}),
|
|
216
|
+
* ],
|
|
217
|
+
* })
|
|
218
|
+
* ```
|
|
219
|
+
* @param config The application configuration
|
|
220
|
+
* @public
|
|
221
|
+
* @beta Deploying Applications via Blueprints is experimental. This may be subject to breaking changes.
|
|
222
|
+
* @category Definers
|
|
223
|
+
* @expandType BlueprintApplicationConfig
|
|
224
|
+
* @returns The application resource
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
export function defineApplication(config: BlueprintApplicationConfig): BlueprintApplicationResource {
|
|
228
|
+
const {views, webWorkers, slug, ...rest} = config
|
|
229
|
+
|
|
230
|
+
const applicationResource: BlueprintApplicationResource = {...rest, type: 'sanity.application', slug: slug ?? rest.name}
|
|
231
|
+
if (views && views.length > 0) applicationResource.views = views.map(viewConfigToResource)
|
|
232
|
+
if (webWorkers && webWorkers.length > 0) applicationResource.webWorkers = webWorkers
|
|
233
|
+
|
|
234
|
+
runValidation(() => validateApplication(applicationResource))
|
|
235
|
+
|
|
236
|
+
return applicationResource
|
|
237
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {type BlueprintMediaLibraryConfigConfig, type BlueprintMediaLibraryConfigResource, validateMediaLibraryConfig} from '../index.js'
|
|
2
|
+
import {runValidation} from '../utils/validation.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Defines a singleton Media Library configuration.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The Media Library is a Sanity-owned singleton, so this resource carries no
|
|
9
|
+
* application identity of its own — only the config `root` and its `fields`.
|
|
10
|
+
* The provider resolves the organization's media library installation id at
|
|
11
|
+
* deploy time.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* defineMediaLibraryConfig({
|
|
15
|
+
* name: 'media-library',
|
|
16
|
+
* root: './media-library',
|
|
17
|
+
* fields: [{name: 'brand', title: 'Brand', src: './src/fields/brand.tsx'}],
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
* @param config The Media Library configuration
|
|
21
|
+
* @public
|
|
22
|
+
* @beta Configuring the Media Library via Blueprints is experimental. This may be subject to breaking changes.
|
|
23
|
+
* @category Definers
|
|
24
|
+
* @expandType BlueprintMediaLibraryConfigConfig
|
|
25
|
+
* @returns The Media Library configuration resource
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
export function defineMediaLibraryConfig(config: BlueprintMediaLibraryConfigConfig): BlueprintMediaLibraryConfigResource {
|
|
29
|
+
const resource = {
|
|
30
|
+
...config,
|
|
31
|
+
type: 'sanity.installation.config',
|
|
32
|
+
appType: 'media-library',
|
|
33
|
+
} satisfies BlueprintMediaLibraryConfigResource
|
|
34
|
+
|
|
35
|
+
runValidation(() => validateMediaLibraryConfig(resource))
|
|
36
|
+
|
|
37
|
+
return resource
|
|
38
|
+
}
|
package/src/definers/studios.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @categoryDescription Referencers
|
|
8
8
|
* These functions are used to reference resources in another Blueprint.
|
|
9
9
|
*/
|
|
10
|
+
export * from './definers/applications.js'
|
|
10
11
|
export * from './definers/blueprints.js'
|
|
11
12
|
export * from './definers/cors.js'
|
|
12
13
|
export * from './definers/datasets.js'
|
|
@@ -18,6 +19,7 @@ export * from './definers/functions/pubsub.js'
|
|
|
18
19
|
export * from './definers/functions/queue.js'
|
|
19
20
|
export * from './definers/functions/scheduled.js'
|
|
20
21
|
export * from './definers/functions/sync-tag-invalidate.js'
|
|
22
|
+
export * from './definers/installation-config.js'
|
|
21
23
|
export * from './definers/projects.js'
|
|
22
24
|
export * from './definers/resources.js'
|
|
23
25
|
export * from './definers/robots.js'
|
|
@@ -35,11 +37,13 @@ export * from './definers/webhooks.js'
|
|
|
35
37
|
* @categoryDescription Functions Types
|
|
36
38
|
* Resource types for functions in a Blueprint.
|
|
37
39
|
*/
|
|
40
|
+
export * from './types/applications.js'
|
|
38
41
|
export * from './types/blueprints.js'
|
|
39
42
|
export * from './types/cors.js'
|
|
40
43
|
export * from './types/datasets.js'
|
|
41
44
|
export * from './types/errors.js'
|
|
42
45
|
export * from './types/functions/index.js'
|
|
46
|
+
export * from './types/installation-config.js'
|
|
43
47
|
export * from './types/projects.js'
|
|
44
48
|
export * from './types/resources.js'
|
|
45
49
|
export * from './types/robots.js'
|
|
@@ -53,10 +57,12 @@ export * from './types/webhooks.js'
|
|
|
53
57
|
* @categoryDescription Validation
|
|
54
58
|
* These functions are used to validate resources in a Blueprint.
|
|
55
59
|
*/
|
|
60
|
+
export * from './validation/applications.js'
|
|
56
61
|
export * from './validation/blueprints.js'
|
|
57
62
|
export * from './validation/cors.js'
|
|
58
63
|
export * from './validation/datasets.js'
|
|
59
64
|
export * from './validation/functions.js'
|
|
65
|
+
export * from './validation/installation-config.js'
|
|
60
66
|
export * from './validation/projects.js'
|
|
61
67
|
export * from './validation/resources.js'
|
|
62
68
|
export * from './validation/robots.js'
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import type {ApplicationVisibility, BlueprintResource} from '../index.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The set of valid tile footprint families.
|
|
5
|
+
*
|
|
6
|
+
* Modelled on widget families rather than a linear scale: `banner` is
|
|
7
|
+
* full-width and shallow, which a `small` → `large` magnitude can't express.
|
|
8
|
+
* @beta This feature is subject to breaking changes.
|
|
9
|
+
* @category Resource Types
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
export const APPLICATION_TILE_SIZES = ['small', 'large', 'banner'] as const
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The footprint family a tile view occupies on the dashboard.
|
|
16
|
+
* @beta This feature is subject to breaking changes.
|
|
17
|
+
* @category Resource Types
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
export type ApplicationTileSize = (typeof APPLICATION_TILE_SIZES)[number]
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The set of surfaces a view can target within the Dashboard/Workbench.
|
|
24
|
+
* @beta This feature is subject to breaking changes.
|
|
25
|
+
* @category Resource Types
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
export const APPLICATION_VIEW_SURFACES = ['window', 'panel', 'asset-source', 'tile'] as const
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The surface a view targets. Used as the discriminator on view configs; the
|
|
32
|
+
* definers transform it to the emitted view `type` the backend expects.
|
|
33
|
+
* @beta This feature is subject to breaking changes.
|
|
34
|
+
* @category Resource Types
|
|
35
|
+
* @hidden
|
|
36
|
+
*/
|
|
37
|
+
export type ApplicationViewSurface = (typeof APPLICATION_VIEW_SURFACES)[number]
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The set of dock groups a window or panel view can be placed into.
|
|
41
|
+
* @beta This feature is subject to breaking changes.
|
|
42
|
+
* @category Resource Types
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
export const APPLICATION_DOCK_GROUPS = ['system', 'applications', 'user'] as const
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The dock group a window or panel view is placed into.
|
|
49
|
+
* @beta This feature is subject to breaking changes.
|
|
50
|
+
* @category Resource Types
|
|
51
|
+
* @hidden
|
|
52
|
+
*/
|
|
53
|
+
export type ApplicationDockGroup = (typeof APPLICATION_DOCK_GROUPS)[number]
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Dock placement for a window view.
|
|
57
|
+
* @beta This feature is subject to breaking changes.
|
|
58
|
+
* @category Resource Types
|
|
59
|
+
* @expand
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
62
|
+
export interface BlueprintApplicationDock {
|
|
63
|
+
/**
|
|
64
|
+
* The dock group the window or panel view is placed into.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue `applications` — the API places the view in the applications dock group when omitted.
|
|
67
|
+
*/
|
|
68
|
+
group?: ApplicationDockGroup
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sort position within the group, ascending.
|
|
72
|
+
*
|
|
73
|
+
* @defaultValue Omitted — ordering falls back to the dashboard application's built-in settings.
|
|
74
|
+
*/
|
|
75
|
+
order?: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Fields shared by every view and web worker an application exposes.
|
|
80
|
+
* @beta This feature is subject to breaking changes.
|
|
81
|
+
* @category Resource Types
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
export interface BlueprintApplicationChildBase {
|
|
85
|
+
/** Unique within the application. Must match `^[a-zA-Z0-9_-]+$`. */
|
|
86
|
+
name: string
|
|
87
|
+
|
|
88
|
+
/** Human-readable title for the view. */
|
|
89
|
+
title: string
|
|
90
|
+
|
|
91
|
+
/** The location of the view source code, relative to the application `root`. */
|
|
92
|
+
src: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A window view — the navigable, full-page view of an application.
|
|
97
|
+
* @beta This feature is subject to breaking changes.
|
|
98
|
+
* @category Resource Types
|
|
99
|
+
* @hidden
|
|
100
|
+
*/
|
|
101
|
+
export interface BlueprintWindowView extends BlueprintApplicationChildBase {
|
|
102
|
+
type: 'app'
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Dock placement for the window view.
|
|
106
|
+
*
|
|
107
|
+
* @defaultValue Omitted — the dashboard applies its default placement (the `applications` group with built-in ordering).
|
|
108
|
+
*/
|
|
109
|
+
dock?: BlueprintApplicationDock
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A panel view — renders in the dock.
|
|
114
|
+
* @beta This feature is subject to breaking changes.
|
|
115
|
+
* @category Resource Types
|
|
116
|
+
* @hidden
|
|
117
|
+
*/
|
|
118
|
+
export interface BlueprintPanelView extends BlueprintApplicationChildBase {
|
|
119
|
+
type: 'panel'
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Dock placement for the panel view.
|
|
123
|
+
*
|
|
124
|
+
* @defaultValue Omitted — the dashboard applies its default placement (the `applications` group with built-in ordering).
|
|
125
|
+
*/
|
|
126
|
+
dock?: BlueprintApplicationDock
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* An asset source view — contributes an asset source.
|
|
131
|
+
* @beta This feature is subject to breaking changes.
|
|
132
|
+
* @category Resource Types
|
|
133
|
+
* @hidden
|
|
134
|
+
*/
|
|
135
|
+
export interface BlueprintAssetSourceView extends BlueprintApplicationChildBase {
|
|
136
|
+
type: 'asset_source'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A tile view — docks on the dashboard with a footprint `size`.
|
|
141
|
+
* @beta This feature is subject to breaking changes.
|
|
142
|
+
* @category Resource Types
|
|
143
|
+
* @hidden
|
|
144
|
+
*/
|
|
145
|
+
export interface BlueprintTileView extends BlueprintApplicationChildBase {
|
|
146
|
+
type: 'tile'
|
|
147
|
+
|
|
148
|
+
/** The footprint family the dashboard lays the tile out by. */
|
|
149
|
+
size: ApplicationTileSize
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Sort position within its layout track, ascending.
|
|
153
|
+
*
|
|
154
|
+
* @defaultValue Omitted — ordering falls back to the dashboard application's built-in settings.
|
|
155
|
+
*/
|
|
156
|
+
order?: number
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A background web worker an application runs.
|
|
161
|
+
* @beta This feature is subject to breaking changes.
|
|
162
|
+
* @category Resource Types
|
|
163
|
+
* @hidden
|
|
164
|
+
*/
|
|
165
|
+
export interface BlueprintWebWorker extends BlueprintApplicationChildBase {
|
|
166
|
+
type: 'worker'
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A union of all view declarations an application can expose.
|
|
171
|
+
* @beta This feature is subject to breaking changes.
|
|
172
|
+
* @category Resource Types
|
|
173
|
+
* @expand
|
|
174
|
+
* @hidden
|
|
175
|
+
*/
|
|
176
|
+
export type BlueprintApplicationView = BlueprintWindowView | BlueprintPanelView | BlueprintAssetSourceView | BlueprintTileView
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* A union of everything an application declares — its views and web workers.
|
|
180
|
+
* @beta This feature is subject to breaking changes.
|
|
181
|
+
* @category Resource Types
|
|
182
|
+
* @hidden
|
|
183
|
+
*/
|
|
184
|
+
export type BlueprintApplicationChild = BlueprintApplicationView | BlueprintWebWorker
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Represents an Application resource.
|
|
188
|
+
* @beta This feature is subject to breaking changes.
|
|
189
|
+
* @category Resource Types
|
|
190
|
+
* @hidden
|
|
191
|
+
*/
|
|
192
|
+
export interface BlueprintApplicationResource extends BlueprintResource {
|
|
193
|
+
type: 'sanity.application'
|
|
194
|
+
|
|
195
|
+
/** The slug to be used in the application hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`. */
|
|
196
|
+
slug: string
|
|
197
|
+
|
|
198
|
+
/** User-facing title for the application. */
|
|
199
|
+
title: string
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The application root directory, relative to the blueprint file. Contains the
|
|
203
|
+
* application's `package.json`; every view and web worker `src` is resolved
|
|
204
|
+
* relative to it.
|
|
205
|
+
*/
|
|
206
|
+
root: string
|
|
207
|
+
|
|
208
|
+
/** Icon for the application (path to an SVG). */
|
|
209
|
+
icon?: string
|
|
210
|
+
|
|
211
|
+
/** Dashboard visibility. */
|
|
212
|
+
visibility?: ApplicationVisibility
|
|
213
|
+
|
|
214
|
+
/** The window, panel, asset source, and tile views the application exposes. */
|
|
215
|
+
views?: BlueprintApplicationView[]
|
|
216
|
+
|
|
217
|
+
/** The background web workers the application runs. */
|
|
218
|
+
webWorkers?: BlueprintWebWorker[]
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface BlueprintViewConfigBase {
|
|
222
|
+
type: 'view'
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Configuration for a window view.
|
|
227
|
+
*
|
|
228
|
+
* @remarks
|
|
229
|
+
* Discriminated by `surface`. The definer transforms `surface: 'window'` to the
|
|
230
|
+
* emitted view `type: 'app'`.
|
|
231
|
+
* @beta This feature is subject to breaking changes.
|
|
232
|
+
* @category Resource Types
|
|
233
|
+
* @interface
|
|
234
|
+
* @hidden
|
|
235
|
+
*/
|
|
236
|
+
export type BlueprintWindowViewConfig = Omit<BlueprintWindowView, 'type'> &
|
|
237
|
+
BlueprintViewConfigBase & {
|
|
238
|
+
/** The surface the view targets. */
|
|
239
|
+
surface: 'window'
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Configuration for a panel view.
|
|
244
|
+
*
|
|
245
|
+
* @remarks
|
|
246
|
+
* Discriminated by `surface`. The definer transforms `surface: 'panel'` to the
|
|
247
|
+
* emitted view `type: 'panel'`.
|
|
248
|
+
* @beta This feature is subject to breaking changes.
|
|
249
|
+
* @category Resource Types
|
|
250
|
+
* @interface
|
|
251
|
+
* @hidden
|
|
252
|
+
*/
|
|
253
|
+
export type BlueprintPanelViewConfig = Omit<BlueprintPanelView, 'type'> &
|
|
254
|
+
BlueprintViewConfigBase & {
|
|
255
|
+
/** The surface the view targets. */
|
|
256
|
+
surface: 'panel'
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Configuration for an asset source view.
|
|
261
|
+
*
|
|
262
|
+
* @remarks
|
|
263
|
+
* Discriminated by `surface`. The definer transforms `surface: 'asset-source'`
|
|
264
|
+
* to the emitted view `type: 'asset_source'`.
|
|
265
|
+
* @beta This feature is subject to breaking changes.
|
|
266
|
+
* @category Resource Types
|
|
267
|
+
* @interface
|
|
268
|
+
* @hidden
|
|
269
|
+
*/
|
|
270
|
+
export type BlueprintAssetSourceViewConfig = Omit<BlueprintAssetSourceView, 'type'> &
|
|
271
|
+
BlueprintViewConfigBase & {
|
|
272
|
+
/** The surface the view targets. */
|
|
273
|
+
surface: 'asset-source'
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Configuration for a tile view.
|
|
278
|
+
*
|
|
279
|
+
* @remarks
|
|
280
|
+
* Discriminated by `surface`. The definer transforms `surface: 'tile'` to the
|
|
281
|
+
* emitted view `type: 'tile'`.
|
|
282
|
+
* @beta This feature is subject to breaking changes.
|
|
283
|
+
* @category Resource Types
|
|
284
|
+
* @interface
|
|
285
|
+
* @hidden
|
|
286
|
+
*/
|
|
287
|
+
export type BlueprintTileViewConfig = Omit<BlueprintTileView, 'type'> &
|
|
288
|
+
BlueprintViewConfigBase & {
|
|
289
|
+
/** The surface the view targets. */
|
|
290
|
+
surface: 'tile'
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Configuration for a web worker.
|
|
295
|
+
* @beta This feature is subject to breaking changes.
|
|
296
|
+
* @category Resource Types
|
|
297
|
+
* @interface
|
|
298
|
+
* @hidden
|
|
299
|
+
*/
|
|
300
|
+
export type BlueprintWebWorkerConfig = Omit<BlueprintWebWorker, 'type'>
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* A union of all view configs an application can declare, discriminated by `surface`.
|
|
304
|
+
* @beta This feature is subject to breaking changes.
|
|
305
|
+
* @category Resource Types
|
|
306
|
+
* @expand
|
|
307
|
+
* @hidden
|
|
308
|
+
*/
|
|
309
|
+
export type BlueprintApplicationViewConfig =
|
|
310
|
+
| BlueprintWindowViewConfig
|
|
311
|
+
| BlueprintPanelViewConfig
|
|
312
|
+
| BlueprintAssetSourceViewConfig
|
|
313
|
+
| BlueprintTileViewConfig
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Configuration for an Application resource.
|
|
317
|
+
* @beta This feature is subject to breaking changes.
|
|
318
|
+
* @category Resource Types
|
|
319
|
+
* @interface
|
|
320
|
+
* @hidden
|
|
321
|
+
*/
|
|
322
|
+
export type BlueprintApplicationConfig = Omit<BlueprintApplicationResource, 'type' | 'slug' | 'views'> & {
|
|
323
|
+
/**
|
|
324
|
+
* The slug to be used in the application hostname. Must match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`.
|
|
325
|
+
*
|
|
326
|
+
* Defaults to the resource `name`.
|
|
327
|
+
*/
|
|
328
|
+
slug?: string
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* The window, panel, asset source, and tile views the application exposes.
|
|
332
|
+
*
|
|
333
|
+
* Authored as surface-discriminated view configs and transformed to the
|
|
334
|
+
* emitted view `type` the backend expects.
|
|
335
|
+
*/
|
|
336
|
+
views?: BlueprintApplicationViewConfig[]
|
|
337
|
+
}
|