@sanity/blueprints 0.27.0 → 0.29.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 (63) hide show
  1. package/README.md +38 -14
  2. package/dist/definers/functions/durable.d.ts +0 -1
  3. package/dist/definers/functions/durable.js +3 -4
  4. package/dist/definers/functions/durable.js.map +1 -1
  5. package/dist/definers/functions/queue.js +3 -3
  6. package/dist/definers/functions/queue.js.map +1 -1
  7. package/dist/definers/functions/scheduled.d.ts +1 -3
  8. package/dist/definers/functions/scheduled.js +1 -3
  9. package/dist/definers/functions/scheduled.js.map +1 -1
  10. package/dist/resolve/by-name.d.ts +7 -0
  11. package/dist/resolve/by-name.js +13 -0
  12. package/dist/resolve/by-name.js.map +1 -0
  13. package/dist/resolve/import.d.ts +16 -0
  14. package/dist/resolve/import.js +48 -0
  15. package/dist/resolve/import.js.map +1 -0
  16. package/dist/resolve/index.d.ts +18 -0
  17. package/dist/resolve/index.js +19 -0
  18. package/dist/resolve/index.js.map +1 -0
  19. package/dist/resolve/load.d.ts +53 -0
  20. package/dist/resolve/load.js +155 -0
  21. package/dist/resolve/load.js.map +1 -0
  22. package/dist/resolve/stack-config.d.ts +49 -0
  23. package/dist/resolve/stack-config.js +108 -0
  24. package/dist/resolve/stack-config.js.map +1 -0
  25. package/dist/resolve/stack.d.ts +23 -0
  26. package/dist/resolve/stack.js +91 -0
  27. package/dist/resolve/stack.js.map +1 -0
  28. package/dist/resolve/types.d.ts +165 -0
  29. package/dist/resolve/types.js +2 -0
  30. package/dist/resolve/types.js.map +1 -0
  31. package/dist/types/applications.d.ts +3 -1
  32. package/dist/types/applications.js +1 -1
  33. package/dist/types/applications.js.map +1 -1
  34. package/dist/types/functions/index.d.ts +58 -10
  35. package/dist/types/installation-config.d.ts +2 -0
  36. package/dist/types/studios.d.ts +9 -1
  37. package/dist/types/studios.js.map +1 -1
  38. package/dist/utils/debounce.d.ts +20 -0
  39. package/dist/utils/debounce.js +46 -0
  40. package/dist/utils/debounce.js.map +1 -0
  41. package/dist/validation/functions.d.ts +9 -0
  42. package/dist/validation/functions.js +66 -9
  43. package/dist/validation/functions.js.map +1 -1
  44. package/dist/validation/resources.js +14 -4
  45. package/dist/validation/resources.js.map +1 -1
  46. package/package.json +22 -7
  47. package/src/definers/functions/durable.ts +3 -4
  48. package/src/definers/functions/queue.ts +3 -3
  49. package/src/definers/functions/scheduled.ts +1 -3
  50. package/src/resolve/by-name.ts +11 -0
  51. package/src/resolve/import.ts +52 -0
  52. package/src/resolve/index.ts +33 -0
  53. package/src/resolve/load.ts +166 -0
  54. package/src/resolve/stack-config.ts +116 -0
  55. package/src/resolve/stack.ts +100 -0
  56. package/src/resolve/types.ts +179 -0
  57. package/src/types/applications.ts +4 -1
  58. package/src/types/functions/index.ts +70 -19
  59. package/src/types/installation-config.ts +3 -0
  60. package/src/types/studios.ts +11 -1
  61. package/src/utils/debounce.ts +53 -0
  62. package/src/validation/functions.ts +78 -12
  63. package/src/validation/resources.ts +13 -4
@@ -0,0 +1,166 @@
1
+ import {existsSync, readFileSync, statSync} from 'node:fs'
2
+ import {dirname, extname, join, resolve} from 'node:path'
3
+ import {cwd} from 'node:process'
4
+ import type {Blueprint, BlueprintModule} from '../index.js'
5
+ import {byName} from './by-name.js'
6
+ import {canRetryWithJiti, findJiti, importNative} from './import.js'
7
+ import {readStackConfigFile, resolveStackConfig, stackIdsFromEnv} from './stack-config.js'
8
+ import type {BlueprintInfo, BlueprintLoader, LoadBlueprintFileOptions, LoadedBlueprintFile, ReadBlueprintOptions} from './types.js'
9
+
10
+ const EXTENSIONS = ['.json', '.js', '.mjs', '.ts']
11
+ const BASE_NAMES = EXTENSIONS.map((ext) => `blueprint${ext}`)
12
+
13
+ /**
14
+ * The file names {@link findBlueprintFile} looks for, in order
15
+ * @internal
16
+ * @private
17
+ * @category Resolve
18
+ */
19
+ export const BLUEPRINT_FILE_NAMES = [...BASE_NAMES, ...BASE_NAMES.map((name) => `sanity.${name}`)]
20
+
21
+ /**
22
+ * Find a blueprint file
23
+ *
24
+ * Returns a file path as is. Searches a directory, then its parents, for {@link BLUEPRINT_FILE_NAMES}.
25
+ *
26
+ * @param path A blueprint file or directory. Defaults to the current working directory.
27
+ * @returns The absolute path of the file, or `undefined` when none is found
28
+ * @internal
29
+ * @private
30
+ * @category Resolve
31
+ */
32
+ export function findBlueprintFile(path: string = cwd()): string | undefined {
33
+ let dir = resolve(path)
34
+ if (!existsSync(dir)) return undefined
35
+ if (statSync(dir).isFile()) return dir
36
+
37
+ while (true) {
38
+ for (const name of BLUEPRINT_FILE_NAMES) {
39
+ const candidate = join(dir, name)
40
+ if (existsSync(candidate)) return candidate
41
+ }
42
+ const parent = dirname(dir)
43
+ if (parent === dir) return undefined
44
+ dir = parent
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Load a blueprint file
50
+ *
51
+ * Parses a JSON file. Imports a JS or TS file and calls its default export.
52
+ * TypeScript that Node cannot run, such as an enum, is loaded with jiti when it is installed.
53
+ * Imported modules are cached, so a later call in the same process does not see changes to the file. Pass a `loader` that skips the cache to re-read it.
54
+ *
55
+ * @param path The blueprint file
56
+ * @throws When the file cannot be loaded or does not produce a blueprint object
57
+ * @internal
58
+ * @private
59
+ * @category Resolve
60
+ */
61
+ export async function loadBlueprintFile(path: string, options: LoadBlueprintFileOptions = {}): Promise<LoadedBlueprintFile> {
62
+ const extension = extname(path)
63
+
64
+ if (extension === '.json') {
65
+ let blueprint: unknown
66
+ try {
67
+ blueprint = JSON.parse(readFileSync(path, 'utf8'))
68
+ } catch (error) {
69
+ throw new Error(`Unable to parse ${path}: ${errorText(error)}`, {cause: error})
70
+ }
71
+ return {blueprint: asBlueprint(blueprint, path)}
72
+ }
73
+
74
+ if (!EXTENSIONS.includes(extension)) {
75
+ throw new Error(`Unsupported blueprint file extension "${extension}" for ${path}. Expected one of: ${EXTENSIONS.join(', ')}`)
76
+ }
77
+
78
+ const defaultExport = await importDefault(path, options.loader)
79
+ if (typeof defaultExport !== 'function') {
80
+ throw new Error(`${path} must export a default function. Wrap the blueprint in defineBlueprint().`)
81
+ }
82
+
83
+ const module = defaultExport as BlueprintModule
84
+ let blueprint: unknown
85
+ try {
86
+ blueprint = module()
87
+ } catch (error) {
88
+ throw new Error(`Error executing the default export of ${path}: ${errorText(error)}`, {cause: error})
89
+ }
90
+
91
+ return {blueprint: asBlueprint(blueprint, path), module}
92
+ }
93
+
94
+ /**
95
+ * Read a local blueprint and the ids of the Stack it deploys to
96
+ *
97
+ * Ids come from `overrides`, the environment, `defineBlueprint`, then `.sanity/blueprint.config.json`.
98
+ * Resources are not validated. No network access.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import {readBlueprint} from '@sanity/blueprints/resolve'
103
+ *
104
+ * const {resources, resourcesByName, stackId, sources} = await readBlueprint()
105
+ * resources.map((resource) => resource.name)
106
+ * resourcesByName['production-dataset']?.type // 'sanity.project.dataset'
107
+ * sources.stackId // 'config'
108
+ * ```
109
+ * @throws When no blueprint file is found, it cannot be loaded, or `resources` is not an array
110
+ * @category Resolve
111
+ */
112
+ export async function readBlueprint(options: ReadBlueprintOptions = {}): Promise<BlueprintInfo> {
113
+ const path = findBlueprintFile(options.path)
114
+ if (!path) {
115
+ const searched = resolve(options.path ?? cwd())
116
+ throw new Error(`No blueprint file found in ${searched} or its parent directories. Expected one of: ${BLUEPRINT_FILE_NAMES.join(', ')}`)
117
+ }
118
+
119
+ const {blueprint, module} = await loadBlueprintFile(path, {loader: options.loader})
120
+
121
+ const resources = blueprint.resources ?? []
122
+ if (!Array.isArray(resources)) throw new Error(`Invalid blueprint in ${path}: \`resources\` must be an array`)
123
+
124
+ const file = readStackConfigFile(dirname(path))
125
+ const config = resolveStackConfig({
126
+ overrides: options.overrides,
127
+ env: options.env === undefined ? undefined : options.env && stackIdsFromEnv(options.env),
128
+ module,
129
+ config: file,
130
+ })
131
+
132
+ return {path, blueprint, module, resources, resourcesByName: byName(resources), ...config, configPath: file?.configPath}
133
+ }
134
+
135
+ async function importDefault(path: string, loader?: BlueprintLoader): Promise<unknown> {
136
+ let error: unknown
137
+ try {
138
+ return await (loader ?? importNative)(path)
139
+ } catch (caught) {
140
+ error = caught
141
+ }
142
+
143
+ if (!loader && canRetryWithJiti(error)) {
144
+ const jiti = await findJiti(path)
145
+ if (!jiti) throw new Error(`Unable to import ${path}: ${errorText(error)} Install jiti to load it, or pass a loader.`, {cause: error})
146
+ try {
147
+ return await jiti(path)
148
+ } catch (caught) {
149
+ error = caught
150
+ }
151
+ }
152
+
153
+ throw new Error(`Unable to import ${path}: ${errorText(error)}`, {cause: error})
154
+ }
155
+
156
+ function errorText(error: unknown): string {
157
+ const message = error instanceof Error ? error.message : String(error)
158
+ return message.endsWith('.') ? message : `${message}.`
159
+ }
160
+
161
+ function asBlueprint(value: unknown, path: string): Blueprint {
162
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
163
+ throw new Error(`${path} did not produce a blueprint object`)
164
+ }
165
+ return value as Blueprint
166
+ }
@@ -0,0 +1,116 @@
1
+ import {existsSync, readFileSync} from 'node:fs'
2
+ import {resolve} from 'node:path'
3
+ import {cwd, env as processEnv} from 'node:process'
4
+ import type {BlueprintsApiConfig} from '../index.js'
5
+ import type {ConfigSource, StackConfig, StackConfigFile, StackIdSources, StackIds} from './types.js'
6
+
7
+ /**
8
+ * The directory next to the blueprint file that holds the Stack config
9
+ * @internal
10
+ * @private
11
+ * @category Resolve
12
+ */
13
+ export const STACK_CONFIG_DIR = '.sanity'
14
+
15
+ /**
16
+ * The file in {@link STACK_CONFIG_DIR} that holds the Stack ids
17
+ * @internal
18
+ * @private
19
+ * @category Resolve
20
+ */
21
+ export const STACK_CONFIG_FILE = 'blueprint.config.json'
22
+
23
+ const ID_KEYS: (keyof BlueprintsApiConfig)[] = ['organizationId', 'projectId', 'stackId']
24
+
25
+ /**
26
+ * Read `.sanity/blueprint.config.json` from a blueprint directory
27
+ * @param dir The blueprint directory. Defaults to the current working directory.
28
+ * @returns The ids in the file and its path, or `undefined` when the file does not exist
29
+ * @throws When the file exists and is not valid JSON
30
+ * @internal
31
+ * @private
32
+ * @category Resolve
33
+ */
34
+ export function readStackConfigFile(dir: string = cwd()): StackConfigFile | undefined {
35
+ const configPath = resolve(dir, STACK_CONFIG_DIR, STACK_CONFIG_FILE)
36
+ if (!existsSync(configPath)) return undefined
37
+
38
+ let parsed: Record<string, unknown>
39
+ try {
40
+ parsed = JSON.parse(readFileSync(configPath, 'utf8'))
41
+ } catch (error) {
42
+ throw new Error(`Unable to parse ${configPath}`, {cause: error})
43
+ }
44
+
45
+ return {configPath, ...pickIds(parsed)}
46
+ }
47
+
48
+ /**
49
+ * Read the Stack ids from `SANITY_ORGANIZATION_ID`, `SANITY_PROJECT_ID`, and `SANITY_BLUEPRINT_STACK_ID`
50
+ * @param env The environment to read. Defaults to `process.env`.
51
+ * @internal
52
+ * @private
53
+ * @category Resolve
54
+ */
55
+ export function stackIdsFromEnv(env: NodeJS.ProcessEnv = processEnv): StackIds {
56
+ return pickIds({
57
+ organizationId: env.SANITY_ORGANIZATION_ID,
58
+ projectId: env.SANITY_PROJECT_ID,
59
+ stackId: env.SANITY_BLUEPRINT_STACK_ID,
60
+ })
61
+ }
62
+
63
+ /**
64
+ * Resolve the Stack ids and scope, and which source supplied each id
65
+ *
66
+ * Precedence: `overrides`, `env`, `module`, `config`. The scope is the project if known, else the organization.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * const config = resolveStackConfig({config: readStackConfigFile()})
71
+ * config.stackId // 'ST-abc123'
72
+ * config.sources.stackId // 'config'
73
+ * ```
74
+ * @internal
75
+ * @private
76
+ * @category Resolve
77
+ */
78
+ export function resolveStackConfig(sources: StackIdSources = {}): StackConfig {
79
+ const ordered: [ConfigSource, StackIds | null | undefined][] = [
80
+ ['overrides', sources.overrides],
81
+ ['env', sources.env === undefined ? stackIdsFromEnv() : sources.env],
82
+ ['module', sources.module],
83
+ ['config', sources.config],
84
+ ]
85
+
86
+ const config: StackConfig = {sources: {}}
87
+ for (const [source, values] of ordered) {
88
+ if (!values) continue
89
+ for (const key of ID_KEYS) {
90
+ const value = values[key]
91
+ if (!config[key] && value) {
92
+ config[key] = value
93
+ config.sources[key] = source
94
+ }
95
+ }
96
+ }
97
+
98
+ if (config.projectId) {
99
+ config.scopeType = 'project'
100
+ config.scopeId = config.projectId
101
+ } else if (config.organizationId) {
102
+ config.scopeType = 'organization'
103
+ config.scopeId = config.organizationId
104
+ }
105
+
106
+ return config
107
+ }
108
+
109
+ function pickIds(values: Record<string, unknown>): StackIds {
110
+ const ids: StackIds = {}
111
+ for (const key of ID_KEYS) {
112
+ const value = values[key]
113
+ if (typeof value === 'string' && value.length > 0) ids[key] = value
114
+ }
115
+ return ids
116
+ }
@@ -0,0 +1,100 @@
1
+ import {env as processEnv} from 'node:process'
2
+ import {byName} from './by-name.js'
3
+ import {readBlueprint} from './load.js'
4
+ import type {DeployedStack, LiveResource, ReadStackOptions, StackInfo} from './types.js'
5
+
6
+ /**
7
+ * The Blueprints API version {@link readStack} uses when none is configured
8
+ * @category Resolve
9
+ */
10
+ export const DEFAULT_BLUEPRINTS_API_VERSION = 'v2026-06-15'
11
+
12
+ const API_URLS: Record<string, string> = {
13
+ production: 'https://api.sanity.io',
14
+ staging: 'https://api.sanity.work',
15
+ }
16
+
17
+ /**
18
+ * Read a local blueprint and its deployed Stack
19
+ *
20
+ * Adds each deployed resource's `externalId` and `live` values to the declared resource with the same type and name.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import {readStack} from '@sanity/blueprints/resolve'
25
+ *
26
+ * const {values, resourcesByName} = await readStack({token: process.env.SANITY_AUTH_TOKEN})
27
+ * values['production-dataset']?.['name'] // the deployed dataset's name
28
+ * resourcesByName['my-function']?.externalId
29
+ * ```
30
+ * @throws When {@link readBlueprint} throws, the Stack id or scope is unknown, or the API responds with an error
31
+ * @category Resolve
32
+ */
33
+ export async function readStack(options: ReadStackOptions): Promise<StackInfo> {
34
+ const blueprint = await readBlueprint(options)
35
+ const {stackId, scopeType, scopeId} = blueprint
36
+
37
+ if (!stackId || !scopeType || !scopeId) {
38
+ throw new Error(
39
+ `No Stack to read for ${blueprint.path}. Set a Stack id and a project or organization id in ` +
40
+ '.sanity/blueprint.config.json, in defineBlueprint, or in the SANITY_BLUEPRINT_STACK_ID and ' +
41
+ 'SANITY_PROJECT_ID or SANITY_ORGANIZATION_ID environment variables.',
42
+ )
43
+ }
44
+
45
+ const env = options.env === undefined ? processEnv : options.env
46
+ const apiUrl = (options.apiUrl ?? apiUrlFromEnv(env)).replace(/\/$/, '')
47
+ const apiVersion = options.apiVersion ?? env?.SANITY_BLUEPRINTS_API_VERSION ?? DEFAULT_BLUEPRINTS_API_VERSION
48
+ const fetchFn = options.fetch ?? globalThis.fetch
49
+
50
+ const response = await fetchFn(`${apiUrl}/${apiVersion}/blueprints/stacks/${stackId}`, {
51
+ method: 'GET',
52
+ headers: {
53
+ Accept: 'application/json',
54
+ Authorization: `Bearer ${options.token}`,
55
+ 'X-Sanity-Scope-Type': scopeType,
56
+ 'X-Sanity-Scope-Id': scopeId,
57
+ 'User-Agent': '@sanity/blueprints',
58
+ },
59
+ })
60
+ if (!response.ok) {
61
+ throw new Error(`Failed to read Stack ${stackId}: ${response.status} ${await errorMessage(response)}`)
62
+ }
63
+
64
+ const stack: DeployedStack = await response.json()
65
+ const deployed = new Map(stack.resources.map((resource) => [`${resource.type}:${resource.name}`, resource]))
66
+
67
+ const resources: LiveResource[] = blueprint.resources.map((resource) => {
68
+ const match = deployed.get(`${resource.type}:${resource.name}`)
69
+ if (!match) return resource
70
+ return {
71
+ ...resource,
72
+ externalId: match.externalId ?? undefined,
73
+ live: match.resolvedParameters ?? match.parameters,
74
+ }
75
+ })
76
+
77
+ const values: StackInfo['values'] = {}
78
+ for (const resource of resources) {
79
+ if (resource.live) values[resource.name] = resource.live
80
+ }
81
+
82
+ return {...blueprint, stack, resources, resourcesByName: byName(resources), values}
83
+ }
84
+
85
+ function apiUrlFromEnv(env: NodeJS.ProcessEnv | null): string {
86
+ const sanityEnv = env?.SANITY_INTERNAL_ENV?.toLowerCase()
87
+ if (!sanityEnv) return API_URLS.production
88
+ // a value that is not a known environment is the origin itself
89
+ return API_URLS[sanityEnv] ?? sanityEnv
90
+ }
91
+
92
+ async function errorMessage(response: Response): Promise<string> {
93
+ try {
94
+ const body: {message?: unknown} = await response.json()
95
+ if (typeof body.message === 'string') return body.message
96
+ } catch {
97
+ // the body was not JSON
98
+ }
99
+ return response.statusText
100
+ }
@@ -0,0 +1,179 @@
1
+ import type {Blueprint, BlueprintModule, BlueprintResource, BlueprintsApiConfig} from '../index.js'
2
+
3
+ /**
4
+ * The scope a Stack lives in
5
+ * @category Resolve
6
+ */
7
+ export type ScopeType = 'organization' | 'project'
8
+
9
+ /**
10
+ * Where a resolved id came from, highest precedence first
11
+ *
12
+ * - `overrides`: passed by the caller, for example from command line flags
13
+ * - `env`: the `SANITY_ORGANIZATION_ID`, `SANITY_PROJECT_ID`, and `SANITY_BLUEPRINT_STACK_ID` environment variables
14
+ * - `module`: attached to the blueprint module by `defineBlueprint`
15
+ * - `config`: `.sanity/blueprint.config.json` next to the blueprint file
16
+ * @category Resolve
17
+ */
18
+ export type ConfigSource = 'overrides' | 'env' | 'module' | 'config'
19
+
20
+ /**
21
+ * The ids that identify a Stack
22
+ * @category Resolve
23
+ */
24
+ export type StackIds = Partial<BlueprintsApiConfig>
25
+
26
+ /**
27
+ * The ids from each source, in the order {@link resolveStackConfig} checks them
28
+ * @internal
29
+ * @private
30
+ * @category Resolve
31
+ */
32
+ export interface StackIdSources {
33
+ overrides?: StackIds | null
34
+ /** Defaults to the `SANITY_*` environment variables. Pass `null` to skip them. */
35
+ env?: StackIds | null
36
+ module?: StackIds | null
37
+ config?: StackIds | null
38
+ }
39
+
40
+ /**
41
+ * The Stack ids and scope, with the source of each id
42
+ * @category Resolve
43
+ */
44
+ export interface StackConfig extends StackIds {
45
+ /** `project` when a project id is known, else `organization` when an organization id is known */
46
+ scopeType?: ScopeType
47
+ scopeId?: string
48
+ /** Which source supplied each id */
49
+ sources: {[K in keyof BlueprintsApiConfig]?: ConfigSource}
50
+ }
51
+
52
+ /**
53
+ * The ids in `.sanity/blueprint.config.json`, and the path of that file
54
+ * @internal
55
+ * @private
56
+ * @category Resolve
57
+ */
58
+ export interface StackConfigFile extends StackIds {
59
+ configPath: string
60
+ }
61
+
62
+ /**
63
+ * Imports a blueprint file and returns its default export
64
+ * @category Resolve
65
+ */
66
+ export type BlueprintLoader = (path: string) => Promise<unknown>
67
+
68
+ /**
69
+ * Options for loading a blueprint file
70
+ * @category Resolve
71
+ */
72
+ export interface LoadBlueprintFileOptions {
73
+ /** Imports a JS or TS blueprint file in place of the built-in loading, for example to skip the module cache */
74
+ loader?: BlueprintLoader
75
+ }
76
+
77
+ /**
78
+ * A blueprint file as loaded from disk
79
+ * @category Resolve
80
+ */
81
+ export interface LoadedBlueprintFile {
82
+ /** The blueprint document the module returned or the JSON file held */
83
+ blueprint: Blueprint
84
+ /** The default export of a JS or TS file. Absent when the file was JSON. */
85
+ module?: BlueprintModule
86
+ }
87
+
88
+ /**
89
+ * Options for {@link readBlueprint}
90
+ * @category Resolve
91
+ */
92
+ export interface ReadBlueprintOptions extends LoadBlueprintFileOptions {
93
+ /** A blueprint file or directory. Defaults to the current working directory. */
94
+ path?: string
95
+ /** Ids that win over every other source */
96
+ overrides?: StackIds | null
97
+ /** The environment to read. Defaults to `process.env`. Pass `null` to skip environment variables. */
98
+ env?: NodeJS.ProcessEnv | null
99
+ }
100
+
101
+ /**
102
+ * What a blueprint declares, and the ids that say which Stack it deploys to
103
+ * @category Resolve
104
+ */
105
+ export interface BlueprintInfo extends StackConfig, LoadedBlueprintFile {
106
+ /** The absolute path of the blueprint file */
107
+ path: string
108
+ /** `blueprint.resources`, or an empty list */
109
+ resources: BlueprintResource[]
110
+ /** `resources` keyed by name. A later duplicate name wins. */
111
+ resourcesByName: Record<string, BlueprintResource>
112
+ /** The `.sanity/blueprint.config.json` that was read, when one exists */
113
+ configPath?: string
114
+ }
115
+
116
+ /**
117
+ * A resource as the Blueprints API returns it
118
+ * @category Resolve
119
+ */
120
+ export interface DeployedResource {
121
+ id: string
122
+ name: string
123
+ type: string
124
+ externalId?: string | null
125
+ parameters?: Record<string, unknown>
126
+ /** Parameters with references to other resources resolved */
127
+ resolvedParameters?: Record<string, unknown>
128
+ }
129
+
130
+ /**
131
+ * A Stack as the Blueprints API returns it
132
+ * @category Resolve
133
+ */
134
+ export interface DeployedStack {
135
+ id: string
136
+ name: string
137
+ scopeType: ScopeType
138
+ scopeId: string
139
+ defaultProjectId?: string | null
140
+ resources: DeployedResource[]
141
+ }
142
+
143
+ /**
144
+ * A declared resource with its deployed values, when the Stack has a resource of the same type and name
145
+ * @category Resolve
146
+ */
147
+ export type LiveResource = BlueprintResource & {
148
+ /** The id of the resource in the service that owns it */
149
+ externalId?: string
150
+ /** The deployed parameters, with references resolved when the API has them */
151
+ live?: Record<string, unknown>
152
+ }
153
+
154
+ /**
155
+ * A blueprint with the values its deployed Stack holds
156
+ * @category Resolve
157
+ */
158
+ export interface StackInfo extends BlueprintInfo {
159
+ stack: DeployedStack
160
+ resources: LiveResource[]
161
+ resourcesByName: Record<string, LiveResource>
162
+ /** `live` parameters by resource name, for the resources the Stack has deployed */
163
+ values: Record<string, Record<string, unknown>>
164
+ }
165
+
166
+ /**
167
+ * Options for {@link readStack}
168
+ * @category Resolve
169
+ */
170
+ export interface ReadStackOptions extends ReadBlueprintOptions {
171
+ /** A Sanity auth token */
172
+ token: string
173
+ /** Defaults to the global `fetch` */
174
+ fetch?: typeof fetch
175
+ /** The Sanity API origin. Defaults from `SANITY_INTERNAL_ENV`. */
176
+ apiUrl?: string
177
+ /** The Blueprints API version. Defaults to `SANITY_BLUEPRINTS_API_VERSION` or {@link DEFAULT_BLUEPRINTS_API_VERSION}. */
178
+ apiVersion?: string
179
+ }
@@ -42,7 +42,7 @@ export type ApplicationViewSurface = (typeof APPLICATION_VIEW_SURFACES)[number]
42
42
  * @category Resource Types
43
43
  * @hidden
44
44
  */
45
- export const APPLICATION_DOCK_GROUPS = ['system', 'applications', 'user'] as const
45
+ export const APPLICATION_DOCK_GROUPS = ['system', 'applications'] as const
46
46
 
47
47
  /**
48
48
  * The dock group a window or panel view is placed into.
@@ -216,6 +216,9 @@ export interface BlueprintApplicationResource extends BlueprintResource {
216
216
 
217
217
  /** The background web workers the application runs. */
218
218
  webWorkers?: BlueprintWebWorker[]
219
+
220
+ /** Module federation manifest */
221
+ mfManifest?: Record<string, unknown>
219
222
  }
220
223
 
221
224
  export interface BlueprintViewConfigBase {