@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.
- package/README.md +38 -14
- package/dist/definers/functions/durable.d.ts +0 -1
- package/dist/definers/functions/durable.js +3 -4
- package/dist/definers/functions/durable.js.map +1 -1
- package/dist/definers/functions/queue.js +3 -3
- package/dist/definers/functions/queue.js.map +1 -1
- package/dist/definers/functions/scheduled.d.ts +1 -3
- package/dist/definers/functions/scheduled.js +1 -3
- package/dist/definers/functions/scheduled.js.map +1 -1
- package/dist/resolve/by-name.d.ts +7 -0
- package/dist/resolve/by-name.js +13 -0
- package/dist/resolve/by-name.js.map +1 -0
- package/dist/resolve/import.d.ts +16 -0
- package/dist/resolve/import.js +48 -0
- package/dist/resolve/import.js.map +1 -0
- package/dist/resolve/index.d.ts +18 -0
- package/dist/resolve/index.js +19 -0
- package/dist/resolve/index.js.map +1 -0
- package/dist/resolve/load.d.ts +53 -0
- package/dist/resolve/load.js +155 -0
- package/dist/resolve/load.js.map +1 -0
- package/dist/resolve/stack-config.d.ts +49 -0
- package/dist/resolve/stack-config.js +108 -0
- package/dist/resolve/stack-config.js.map +1 -0
- package/dist/resolve/stack.d.ts +23 -0
- package/dist/resolve/stack.js +91 -0
- package/dist/resolve/stack.js.map +1 -0
- package/dist/resolve/types.d.ts +165 -0
- package/dist/resolve/types.js +2 -0
- package/dist/resolve/types.js.map +1 -0
- package/dist/types/applications.d.ts +3 -1
- package/dist/types/applications.js +1 -1
- package/dist/types/applications.js.map +1 -1
- package/dist/types/functions/index.d.ts +58 -10
- package/dist/types/installation-config.d.ts +2 -0
- package/dist/types/studios.d.ts +9 -1
- package/dist/types/studios.js.map +1 -1
- package/dist/utils/debounce.d.ts +20 -0
- package/dist/utils/debounce.js +46 -0
- package/dist/utils/debounce.js.map +1 -0
- package/dist/validation/functions.d.ts +9 -0
- package/dist/validation/functions.js +66 -9
- package/dist/validation/functions.js.map +1 -1
- package/dist/validation/resources.js +14 -4
- package/dist/validation/resources.js.map +1 -1
- package/package.json +22 -7
- package/src/definers/functions/durable.ts +3 -4
- package/src/definers/functions/queue.ts +3 -3
- package/src/definers/functions/scheduled.ts +1 -3
- package/src/resolve/by-name.ts +11 -0
- package/src/resolve/import.ts +52 -0
- package/src/resolve/index.ts +33 -0
- package/src/resolve/load.ts +166 -0
- package/src/resolve/stack-config.ts +116 -0
- package/src/resolve/stack.ts +100 -0
- package/src/resolve/types.ts +179 -0
- package/src/types/applications.ts +4 -1
- package/src/types/functions/index.ts +70 -19
- package/src/types/installation-config.ts +3 -0
- package/src/types/studios.ts +11 -1
- package/src/utils/debounce.ts +53 -0
- package/src/validation/functions.ts +78 -12
- package/src/validation/resources.ts +13 -4
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { cwd, env as processEnv } from 'node:process';
|
|
4
|
+
/**
|
|
5
|
+
* The directory next to the blueprint file that holds the Stack config
|
|
6
|
+
* @internal
|
|
7
|
+
* @private
|
|
8
|
+
* @category Resolve
|
|
9
|
+
*/
|
|
10
|
+
export const STACK_CONFIG_DIR = '.sanity';
|
|
11
|
+
/**
|
|
12
|
+
* The file in {@link STACK_CONFIG_DIR} that holds the Stack ids
|
|
13
|
+
* @internal
|
|
14
|
+
* @private
|
|
15
|
+
* @category Resolve
|
|
16
|
+
*/
|
|
17
|
+
export const STACK_CONFIG_FILE = 'blueprint.config.json';
|
|
18
|
+
const ID_KEYS = ['organizationId', 'projectId', 'stackId'];
|
|
19
|
+
/**
|
|
20
|
+
* Read `.sanity/blueprint.config.json` from a blueprint directory
|
|
21
|
+
* @param dir The blueprint directory. Defaults to the current working directory.
|
|
22
|
+
* @returns The ids in the file and its path, or `undefined` when the file does not exist
|
|
23
|
+
* @throws When the file exists and is not valid JSON
|
|
24
|
+
* @internal
|
|
25
|
+
* @private
|
|
26
|
+
* @category Resolve
|
|
27
|
+
*/
|
|
28
|
+
export function readStackConfigFile(dir = cwd()) {
|
|
29
|
+
const configPath = resolve(dir, STACK_CONFIG_DIR, STACK_CONFIG_FILE);
|
|
30
|
+
if (!existsSync(configPath))
|
|
31
|
+
return undefined;
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new Error(`Unable to parse ${configPath}`, { cause: error });
|
|
38
|
+
}
|
|
39
|
+
return { configPath, ...pickIds(parsed) };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read the Stack ids from `SANITY_ORGANIZATION_ID`, `SANITY_PROJECT_ID`, and `SANITY_BLUEPRINT_STACK_ID`
|
|
43
|
+
* @param env The environment to read. Defaults to `process.env`.
|
|
44
|
+
* @internal
|
|
45
|
+
* @private
|
|
46
|
+
* @category Resolve
|
|
47
|
+
*/
|
|
48
|
+
export function stackIdsFromEnv(env = processEnv) {
|
|
49
|
+
return pickIds({
|
|
50
|
+
organizationId: env.SANITY_ORGANIZATION_ID,
|
|
51
|
+
projectId: env.SANITY_PROJECT_ID,
|
|
52
|
+
stackId: env.SANITY_BLUEPRINT_STACK_ID,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the Stack ids and scope, and which source supplied each id
|
|
57
|
+
*
|
|
58
|
+
* Precedence: `overrides`, `env`, `module`, `config`. The scope is the project if known, else the organization.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const config = resolveStackConfig({config: readStackConfigFile()})
|
|
63
|
+
* config.stackId // 'ST-abc123'
|
|
64
|
+
* config.sources.stackId // 'config'
|
|
65
|
+
* ```
|
|
66
|
+
* @internal
|
|
67
|
+
* @private
|
|
68
|
+
* @category Resolve
|
|
69
|
+
*/
|
|
70
|
+
export function resolveStackConfig(sources = {}) {
|
|
71
|
+
const ordered = [
|
|
72
|
+
['overrides', sources.overrides],
|
|
73
|
+
['env', sources.env === undefined ? stackIdsFromEnv() : sources.env],
|
|
74
|
+
['module', sources.module],
|
|
75
|
+
['config', sources.config],
|
|
76
|
+
];
|
|
77
|
+
const config = { sources: {} };
|
|
78
|
+
for (const [source, values] of ordered) {
|
|
79
|
+
if (!values)
|
|
80
|
+
continue;
|
|
81
|
+
for (const key of ID_KEYS) {
|
|
82
|
+
const value = values[key];
|
|
83
|
+
if (!config[key] && value) {
|
|
84
|
+
config[key] = value;
|
|
85
|
+
config.sources[key] = source;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (config.projectId) {
|
|
90
|
+
config.scopeType = 'project';
|
|
91
|
+
config.scopeId = config.projectId;
|
|
92
|
+
}
|
|
93
|
+
else if (config.organizationId) {
|
|
94
|
+
config.scopeType = 'organization';
|
|
95
|
+
config.scopeId = config.organizationId;
|
|
96
|
+
}
|
|
97
|
+
return config;
|
|
98
|
+
}
|
|
99
|
+
function pickIds(values) {
|
|
100
|
+
const ids = {};
|
|
101
|
+
for (const key of ID_KEYS) {
|
|
102
|
+
const value = values[key];
|
|
103
|
+
if (typeof value === 'string' && value.length > 0)
|
|
104
|
+
ids[key] = value;
|
|
105
|
+
}
|
|
106
|
+
return ids;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=stack-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-config.js","sourceRoot":"","sources":["../../src/resolve/stack-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,GAAG,EAAE,GAAG,IAAI,UAAU,EAAC,MAAM,cAAc,CAAA;AAInD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CA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,GAAG,KAAK,CAAA;IACrE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReadStackOptions, StackInfo } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The Blueprints API version {@link readStack} uses when none is configured
|
|
4
|
+
* @category Resolve
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_BLUEPRINTS_API_VERSION = "v2026-06-15";
|
|
7
|
+
/**
|
|
8
|
+
* Read a local blueprint and its deployed Stack
|
|
9
|
+
*
|
|
10
|
+
* Adds each deployed resource's `externalId` and `live` values to the declared resource with the same type and name.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import {readStack} from '@sanity/blueprints/resolve'
|
|
15
|
+
*
|
|
16
|
+
* const {values, resourcesByName} = await readStack({token: process.env.SANITY_AUTH_TOKEN})
|
|
17
|
+
* values['production-dataset']?.['name'] // the deployed dataset's name
|
|
18
|
+
* resourcesByName['my-function']?.externalId
|
|
19
|
+
* ```
|
|
20
|
+
* @throws When {@link readBlueprint} throws, the Stack id or scope is unknown, or the API responds with an error
|
|
21
|
+
* @category Resolve
|
|
22
|
+
*/
|
|
23
|
+
export declare function readStack(options: ReadStackOptions): Promise<StackInfo>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { env as processEnv } from 'node:process';
|
|
2
|
+
import { byName } from './by-name.js';
|
|
3
|
+
import { readBlueprint } from './load.js';
|
|
4
|
+
/**
|
|
5
|
+
* The Blueprints API version {@link readStack} uses when none is configured
|
|
6
|
+
* @category Resolve
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_BLUEPRINTS_API_VERSION = 'v2026-06-15';
|
|
9
|
+
const API_URLS = {
|
|
10
|
+
production: 'https://api.sanity.io',
|
|
11
|
+
staging: 'https://api.sanity.work',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Read a local blueprint and its deployed Stack
|
|
15
|
+
*
|
|
16
|
+
* Adds each deployed resource's `externalId` and `live` values to the declared resource with the same type and name.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import {readStack} from '@sanity/blueprints/resolve'
|
|
21
|
+
*
|
|
22
|
+
* const {values, resourcesByName} = await readStack({token: process.env.SANITY_AUTH_TOKEN})
|
|
23
|
+
* values['production-dataset']?.['name'] // the deployed dataset's name
|
|
24
|
+
* resourcesByName['my-function']?.externalId
|
|
25
|
+
* ```
|
|
26
|
+
* @throws When {@link readBlueprint} throws, the Stack id or scope is unknown, or the API responds with an error
|
|
27
|
+
* @category Resolve
|
|
28
|
+
*/
|
|
29
|
+
export async function readStack(options) {
|
|
30
|
+
const blueprint = await readBlueprint(options);
|
|
31
|
+
const { stackId, scopeType, scopeId } = blueprint;
|
|
32
|
+
if (!stackId || !scopeType || !scopeId) {
|
|
33
|
+
throw new Error(`No Stack to read for ${blueprint.path}. Set a Stack id and a project or organization id in ` +
|
|
34
|
+
'.sanity/blueprint.config.json, in defineBlueprint, or in the SANITY_BLUEPRINT_STACK_ID and ' +
|
|
35
|
+
'SANITY_PROJECT_ID or SANITY_ORGANIZATION_ID environment variables.');
|
|
36
|
+
}
|
|
37
|
+
const env = options.env === undefined ? processEnv : options.env;
|
|
38
|
+
const apiUrl = (options.apiUrl ?? apiUrlFromEnv(env)).replace(/\/$/, '');
|
|
39
|
+
const apiVersion = options.apiVersion ?? env?.SANITY_BLUEPRINTS_API_VERSION ?? DEFAULT_BLUEPRINTS_API_VERSION;
|
|
40
|
+
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
41
|
+
const response = await fetchFn(`${apiUrl}/${apiVersion}/blueprints/stacks/${stackId}`, {
|
|
42
|
+
method: 'GET',
|
|
43
|
+
headers: {
|
|
44
|
+
Accept: 'application/json',
|
|
45
|
+
Authorization: `Bearer ${options.token}`,
|
|
46
|
+
'X-Sanity-Scope-Type': scopeType,
|
|
47
|
+
'X-Sanity-Scope-Id': scopeId,
|
|
48
|
+
'User-Agent': '@sanity/blueprints',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
throw new Error(`Failed to read Stack ${stackId}: ${response.status} ${await errorMessage(response)}`);
|
|
53
|
+
}
|
|
54
|
+
const stack = await response.json();
|
|
55
|
+
const deployed = new Map(stack.resources.map((resource) => [`${resource.type}:${resource.name}`, resource]));
|
|
56
|
+
const resources = blueprint.resources.map((resource) => {
|
|
57
|
+
const match = deployed.get(`${resource.type}:${resource.name}`);
|
|
58
|
+
if (!match)
|
|
59
|
+
return resource;
|
|
60
|
+
return {
|
|
61
|
+
...resource,
|
|
62
|
+
externalId: match.externalId ?? undefined,
|
|
63
|
+
live: match.resolvedParameters ?? match.parameters,
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const values = {};
|
|
67
|
+
for (const resource of resources) {
|
|
68
|
+
if (resource.live)
|
|
69
|
+
values[resource.name] = resource.live;
|
|
70
|
+
}
|
|
71
|
+
return { ...blueprint, stack, resources, resourcesByName: byName(resources), values };
|
|
72
|
+
}
|
|
73
|
+
function apiUrlFromEnv(env) {
|
|
74
|
+
const sanityEnv = env?.SANITY_INTERNAL_ENV?.toLowerCase();
|
|
75
|
+
if (!sanityEnv)
|
|
76
|
+
return API_URLS.production;
|
|
77
|
+
// a value that is not a known environment is the origin itself
|
|
78
|
+
return API_URLS[sanityEnv] ?? sanityEnv;
|
|
79
|
+
}
|
|
80
|
+
async function errorMessage(response) {
|
|
81
|
+
try {
|
|
82
|
+
const body = await response.json();
|
|
83
|
+
if (typeof body.message === 'string')
|
|
84
|
+
return body.message;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// the body was not JSON
|
|
88
|
+
}
|
|
89
|
+
return response.statusText;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.js","source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ACjC,IAAI,QAAQ,CAAC,IAAI;YAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAA;IAC1D,CAAC;IAED,OAAO,EAAC,GAAG,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAC,CAAA;AACrF,CAAC;AAED,SAAS,aAAa,CAAC,GAA6B;IAClD,MAAM,SAAS,GAAG,GAAG,EAAE,mBAAmB,EAAE,WAAW,EAAE,CAAA;IACzD,IAAI,CAAC,SAAS;QAAE,OAAO,QAAQ,CAAC,UAAU,CAAA;IAC1C,+DAA+D;IAC/D,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,CAAA;AACzC,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,QAAkB;IAC5C,IAAI,CAAC;QACH,MAAM,IAAI,GAAwB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QACvD,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,wBAAwB;IAC1B,CAAC;IACD,OAAO,QAAQ,CAAC,UAAU,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { Blueprint, BlueprintModule, BlueprintResource, BlueprintsApiConfig } from '../index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The scope a Stack lives in
|
|
4
|
+
* @category Resolve
|
|
5
|
+
*/
|
|
6
|
+
export type ScopeType = 'organization' | 'project';
|
|
7
|
+
/**
|
|
8
|
+
* Where a resolved id came from, highest precedence first
|
|
9
|
+
*
|
|
10
|
+
* - `overrides`: passed by the caller, for example from command line flags
|
|
11
|
+
* - `env`: the `SANITY_ORGANIZATION_ID`, `SANITY_PROJECT_ID`, and `SANITY_BLUEPRINT_STACK_ID` environment variables
|
|
12
|
+
* - `module`: attached to the blueprint module by `defineBlueprint`
|
|
13
|
+
* - `config`: `.sanity/blueprint.config.json` next to the blueprint file
|
|
14
|
+
* @category Resolve
|
|
15
|
+
*/
|
|
16
|
+
export type ConfigSource = 'overrides' | 'env' | 'module' | 'config';
|
|
17
|
+
/**
|
|
18
|
+
* The ids that identify a Stack
|
|
19
|
+
* @category Resolve
|
|
20
|
+
*/
|
|
21
|
+
export type StackIds = Partial<BlueprintsApiConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* The ids from each source, in the order {@link resolveStackConfig} checks them
|
|
24
|
+
* @internal
|
|
25
|
+
* @private
|
|
26
|
+
* @category Resolve
|
|
27
|
+
*/
|
|
28
|
+
export interface StackIdSources {
|
|
29
|
+
overrides?: StackIds | null;
|
|
30
|
+
/** Defaults to the `SANITY_*` environment variables. Pass `null` to skip them. */
|
|
31
|
+
env?: StackIds | null;
|
|
32
|
+
module?: StackIds | null;
|
|
33
|
+
config?: StackIds | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The Stack ids and scope, with the source of each id
|
|
37
|
+
* @category Resolve
|
|
38
|
+
*/
|
|
39
|
+
export interface StackConfig extends StackIds {
|
|
40
|
+
/** `project` when a project id is known, else `organization` when an organization id is known */
|
|
41
|
+
scopeType?: ScopeType;
|
|
42
|
+
scopeId?: string;
|
|
43
|
+
/** Which source supplied each id */
|
|
44
|
+
sources: {
|
|
45
|
+
[K in keyof BlueprintsApiConfig]?: ConfigSource;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The ids in `.sanity/blueprint.config.json`, and the path of that file
|
|
50
|
+
* @internal
|
|
51
|
+
* @private
|
|
52
|
+
* @category Resolve
|
|
53
|
+
*/
|
|
54
|
+
export interface StackConfigFile extends StackIds {
|
|
55
|
+
configPath: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Imports a blueprint file and returns its default export
|
|
59
|
+
* @category Resolve
|
|
60
|
+
*/
|
|
61
|
+
export type BlueprintLoader = (path: string) => Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* Options for loading a blueprint file
|
|
64
|
+
* @category Resolve
|
|
65
|
+
*/
|
|
66
|
+
export interface LoadBlueprintFileOptions {
|
|
67
|
+
/** Imports a JS or TS blueprint file in place of the built-in loading, for example to skip the module cache */
|
|
68
|
+
loader?: BlueprintLoader;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A blueprint file as loaded from disk
|
|
72
|
+
* @category Resolve
|
|
73
|
+
*/
|
|
74
|
+
export interface LoadedBlueprintFile {
|
|
75
|
+
/** The blueprint document the module returned or the JSON file held */
|
|
76
|
+
blueprint: Blueprint;
|
|
77
|
+
/** The default export of a JS or TS file. Absent when the file was JSON. */
|
|
78
|
+
module?: BlueprintModule;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Options for {@link readBlueprint}
|
|
82
|
+
* @category Resolve
|
|
83
|
+
*/
|
|
84
|
+
export interface ReadBlueprintOptions extends LoadBlueprintFileOptions {
|
|
85
|
+
/** A blueprint file or directory. Defaults to the current working directory. */
|
|
86
|
+
path?: string;
|
|
87
|
+
/** Ids that win over every other source */
|
|
88
|
+
overrides?: StackIds | null;
|
|
89
|
+
/** The environment to read. Defaults to `process.env`. Pass `null` to skip environment variables. */
|
|
90
|
+
env?: NodeJS.ProcessEnv | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What a blueprint declares, and the ids that say which Stack it deploys to
|
|
94
|
+
* @category Resolve
|
|
95
|
+
*/
|
|
96
|
+
export interface BlueprintInfo extends StackConfig, LoadedBlueprintFile {
|
|
97
|
+
/** The absolute path of the blueprint file */
|
|
98
|
+
path: string;
|
|
99
|
+
/** `blueprint.resources`, or an empty list */
|
|
100
|
+
resources: BlueprintResource[];
|
|
101
|
+
/** `resources` keyed by name. A later duplicate name wins. */
|
|
102
|
+
resourcesByName: Record<string, BlueprintResource>;
|
|
103
|
+
/** The `.sanity/blueprint.config.json` that was read, when one exists */
|
|
104
|
+
configPath?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A resource as the Blueprints API returns it
|
|
108
|
+
* @category Resolve
|
|
109
|
+
*/
|
|
110
|
+
export interface DeployedResource {
|
|
111
|
+
id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
type: string;
|
|
114
|
+
externalId?: string | null;
|
|
115
|
+
parameters?: Record<string, unknown>;
|
|
116
|
+
/** Parameters with references to other resources resolved */
|
|
117
|
+
resolvedParameters?: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* A Stack as the Blueprints API returns it
|
|
121
|
+
* @category Resolve
|
|
122
|
+
*/
|
|
123
|
+
export interface DeployedStack {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
scopeType: ScopeType;
|
|
127
|
+
scopeId: string;
|
|
128
|
+
defaultProjectId?: string | null;
|
|
129
|
+
resources: DeployedResource[];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A declared resource with its deployed values, when the Stack has a resource of the same type and name
|
|
133
|
+
* @category Resolve
|
|
134
|
+
*/
|
|
135
|
+
export type LiveResource = BlueprintResource & {
|
|
136
|
+
/** The id of the resource in the service that owns it */
|
|
137
|
+
externalId?: string;
|
|
138
|
+
/** The deployed parameters, with references resolved when the API has them */
|
|
139
|
+
live?: Record<string, unknown>;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* A blueprint with the values its deployed Stack holds
|
|
143
|
+
* @category Resolve
|
|
144
|
+
*/
|
|
145
|
+
export interface StackInfo extends BlueprintInfo {
|
|
146
|
+
stack: DeployedStack;
|
|
147
|
+
resources: LiveResource[];
|
|
148
|
+
resourcesByName: Record<string, LiveResource>;
|
|
149
|
+
/** `live` parameters by resource name, for the resources the Stack has deployed */
|
|
150
|
+
values: Record<string, Record<string, unknown>>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Options for {@link readStack}
|
|
154
|
+
* @category Resolve
|
|
155
|
+
*/
|
|
156
|
+
export interface ReadStackOptions extends ReadBlueprintOptions {
|
|
157
|
+
/** A Sanity auth token */
|
|
158
|
+
token: string;
|
|
159
|
+
/** Defaults to the global `fetch` */
|
|
160
|
+
fetch?: typeof fetch;
|
|
161
|
+
/** The Sanity API origin. Defaults from `SANITY_INTERNAL_ENV`. */
|
|
162
|
+
apiUrl?: string;
|
|
163
|
+
/** The Blueprints API version. Defaults to `SANITY_BLUEPRINTS_API_VERSION` or {@link DEFAULT_BLUEPRINTS_API_VERSION}. */
|
|
164
|
+
apiVersion?: string;
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/resolve/types.ts"],"names":[],"mappings":""}
|
|
@@ -37,7 +37,7 @@ export type ApplicationViewSurface = (typeof APPLICATION_VIEW_SURFACES)[number];
|
|
|
37
37
|
* @category Resource Types
|
|
38
38
|
* @hidden
|
|
39
39
|
*/
|
|
40
|
-
export declare const APPLICATION_DOCK_GROUPS: readonly ['system', 'applications'
|
|
40
|
+
export declare const APPLICATION_DOCK_GROUPS: readonly ['system', 'applications'];
|
|
41
41
|
/**
|
|
42
42
|
* The dock group a window or panel view is placed into.
|
|
43
43
|
* @beta This feature is subject to breaking changes.
|
|
@@ -186,6 +186,8 @@ export interface BlueprintApplicationResource extends BlueprintResource {
|
|
|
186
186
|
views?: BlueprintApplicationView[];
|
|
187
187
|
/** The background web workers the application runs. */
|
|
188
188
|
webWorkers?: BlueprintWebWorker[];
|
|
189
|
+
/** Module federation manifest */
|
|
190
|
+
mfManifest?: Record<string, unknown>;
|
|
189
191
|
}
|
|
190
192
|
export interface BlueprintViewConfigBase {
|
|
191
193
|
type: 'view';
|
|
@@ -21,5 +21,5 @@ export const APPLICATION_VIEW_SURFACES = ['window', 'panel', 'asset-source', 'ti
|
|
|
21
21
|
* @category Resource Types
|
|
22
22
|
* @hidden
|
|
23
23
|
*/
|
|
24
|
-
export const APPLICATION_DOCK_GROUPS = ['system', 'applications'
|
|
24
|
+
export const APPLICATION_DOCK_GROUPS = ['system', 'applications'];
|
|
25
25
|
//# sourceMappingURL=applications.js.map
|
|
@@ -1 +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,
|
|
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,CAAU,CAAA"}
|
|
@@ -49,15 +49,10 @@ interface QueueConfig {
|
|
|
49
49
|
*/
|
|
50
50
|
concurrency?: number;
|
|
51
51
|
/**
|
|
52
|
-
* Debounce
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
debounce?: number;
|
|
56
|
-
/**
|
|
57
|
-
* Path used to group debounced events, e.g. 'document._id'
|
|
58
|
-
* @todo: not implemented - and should this always be provided with debounce window?
|
|
52
|
+
* Debounce configuration, with any durations already resolved to seconds.
|
|
53
|
+
* Definers accept the wider {@link DebounceInput} and parse it into this shape.
|
|
59
54
|
*/
|
|
60
|
-
|
|
55
|
+
debounce?: DebounceConfig;
|
|
61
56
|
/**
|
|
62
57
|
* Whether to place messages that failed processing into a Dead Letter Queue.
|
|
63
58
|
* @todo: not implemented
|
|
@@ -72,6 +67,53 @@ interface QueueConfig {
|
|
|
72
67
|
*/
|
|
73
68
|
fifo?: boolean;
|
|
74
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Configuration used when debouncing Queue or Workflow function types.
|
|
72
|
+
* @category Functions Types
|
|
73
|
+
* @alpha
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
export interface DebounceConfig {
|
|
77
|
+
/**
|
|
78
|
+
* Debounce window in seconds
|
|
79
|
+
*/
|
|
80
|
+
window: number;
|
|
81
|
+
/**
|
|
82
|
+
* Maximum time in seconds to extend a debounce window from the first event
|
|
83
|
+
*/
|
|
84
|
+
maxWindow?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Dotted path into {event, context} used to debounce events
|
|
87
|
+
*/
|
|
88
|
+
key?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Debounce configuration as accepted by a function definer, before durations are parsed.
|
|
92
|
+
* @category Functions Types
|
|
93
|
+
* @alpha
|
|
94
|
+
* @hidden
|
|
95
|
+
*/
|
|
96
|
+
export interface DebounceConfigInput extends Omit<DebounceConfig, 'window' | 'maxWindow'> {
|
|
97
|
+
/**
|
|
98
|
+
* Debounce window
|
|
99
|
+
* A number is read as seconds, a string is parsed as a duration, e.g. `'5 minutes'`.
|
|
100
|
+
*/
|
|
101
|
+
window: string | number;
|
|
102
|
+
/**
|
|
103
|
+
* Maximum time to extend a debounce window from the first event.
|
|
104
|
+
* Must be greater than `window`.
|
|
105
|
+
* A number is read as seconds, a string is parsed as a duration, e.g. `'1 hour'`.
|
|
106
|
+
*/
|
|
107
|
+
maxWindow?: string | number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Debounce configuration accepted by a function definer, either as a bare duration
|
|
111
|
+
* used as the window, or as a full config.
|
|
112
|
+
* @category Functions Types
|
|
113
|
+
* @alpha
|
|
114
|
+
* @hidden
|
|
115
|
+
*/
|
|
116
|
+
export type DebounceInput = string | number | DebounceConfigInput;
|
|
75
117
|
/**
|
|
76
118
|
* Base function resource with common properties for all function types that can belong to projects.
|
|
77
119
|
* @category Functions Types
|
|
@@ -232,7 +274,7 @@ export type BlueprintSyncTagInvalidateFunctionConfig = Omit<BlueprintSyncTagInva
|
|
|
232
274
|
* @category Functions Types
|
|
233
275
|
* @interface
|
|
234
276
|
*/
|
|
235
|
-
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event'
|
|
277
|
+
export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource, 'type' | 'src' | 'event' | 'debounce'> & {
|
|
236
278
|
/**
|
|
237
279
|
* Path to the function source code
|
|
238
280
|
* @defaultValue `functions/${name}`
|
|
@@ -240,6 +282,8 @@ export type BlueprintQueueFunctionConfig = Omit<BlueprintQueueFunctionResource,
|
|
|
240
282
|
src?: string;
|
|
241
283
|
/** Optional event configuration that triggers the queue function */
|
|
242
284
|
event?: BlueprintFunctionResourceContentLakeEvent;
|
|
285
|
+
/** Optional debounce configuration, as a duration or a full config */
|
|
286
|
+
debounce?: DebounceInput;
|
|
243
287
|
};
|
|
244
288
|
/**
|
|
245
289
|
* Configuration for defining an event function.
|
|
@@ -262,7 +306,7 @@ export type BlueprintPubSubFunctionConfig = Omit<BlueprintPubSubFunctionResource
|
|
|
262
306
|
* @category Functions Types
|
|
263
307
|
* @interface
|
|
264
308
|
*/
|
|
265
|
-
export type BlueprintDurableConfig = Omit<BlueprintDurableFunctionResource, 'type' | 'src' | 'event' | 'durableTimeout'> & {
|
|
309
|
+
export type BlueprintDurableConfig = Omit<BlueprintDurableFunctionResource, 'type' | 'src' | 'event' | 'durableTimeout' | 'debounce'> & {
|
|
266
310
|
/**
|
|
267
311
|
* Path to the function source code
|
|
268
312
|
* @defaultValue `functions/${name}`
|
|
@@ -277,4 +321,8 @@ export type BlueprintDurableConfig = Omit<BlueprintDurableFunctionResource, 'typ
|
|
|
277
321
|
* @defaultValue 86_400 (24 hours)
|
|
278
322
|
*/
|
|
279
323
|
durableTimeout?: string | number;
|
|
324
|
+
/**
|
|
325
|
+
* Optional debounce configuration, as a duration or a full config
|
|
326
|
+
*/
|
|
327
|
+
debounce?: DebounceInput;
|
|
280
328
|
};
|
|
@@ -55,6 +55,8 @@ export interface BlueprintMediaLibraryConfigResource extends BlueprintInstallati
|
|
|
55
55
|
fields: BlueprintMediaLibraryField[];
|
|
56
56
|
/** The local version of `sanity` at deployment. Populated during deployment. */
|
|
57
57
|
version?: string;
|
|
58
|
+
/** Module federation manifest */
|
|
59
|
+
mfManifest?: Record<string, unknown>;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* A union of every singleton installation config resource, discriminated by `appType`.
|
package/dist/types/studios.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkspaceSchemaInput } from '@sanity/cli-build/_internal/manifest';
|
|
1
2
|
import type { ConfigEnv, InlineConfig } from 'vite';
|
|
2
3
|
import type { BlueprintProjectResourceLifecycle, BlueprintResource } from '../index.js';
|
|
3
4
|
/**
|
|
@@ -64,8 +65,15 @@ export interface BlueprintStudioResource extends BlueprintResource<BlueprintProj
|
|
|
64
65
|
reactCompiler?: boolean;
|
|
65
66
|
/** Whether or not to generate source maps. Defaults to false. */
|
|
66
67
|
sourceMap?: boolean;
|
|
67
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Custom Vite configuration for the Studio so it can be changed and extended.
|
|
70
|
+
* Install vite to dev dependencies to get detailed type information.
|
|
71
|
+
*/
|
|
68
72
|
vite?: UserViteConfig;
|
|
73
|
+
/** Schema inputs extracted from the studio's schema definition. */
|
|
74
|
+
schemaInputs?: WorkspaceSchemaInput[];
|
|
75
|
+
/** Module federation manifest */
|
|
76
|
+
mfManifest?: Record<string, unknown>;
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
79
|
* Configuration for a Studio resource.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studios.js","sourceRoot":"","sources":["../../src/types/studios.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studios.js","sourceRoot":"","sources":["../../src/types/studios.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAU,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BlueprintError } from '../types/errors.js';
|
|
2
|
+
import type { DebounceConfig, DebounceInput } from '../types/functions/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Normalizes the debounce config accepted by a definer into the shape held by a resource,
|
|
5
|
+
* parsing any duration into seconds. A bare duration is shorthand for `{window: <duration>}`.
|
|
6
|
+
* @param debounce The debounce config or duration to normalize
|
|
7
|
+
* @internal
|
|
8
|
+
* @returns The debounce config, with `window` and `maxWindow` in seconds
|
|
9
|
+
*/
|
|
10
|
+
export declare function createDebounceObject(debounce: DebounceInput): DebounceConfig;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves a debounce duration, given either as a number of seconds or as a duration string, to seconds.
|
|
13
|
+
* @param field The name of the field being resolved, used in error messages
|
|
14
|
+
* @param value The value to resolve
|
|
15
|
+
* @returns The value in seconds, or the errors that prevented it from being resolved
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveDebounceDuration(field: string, value: unknown): {
|
|
18
|
+
seconds?: number;
|
|
19
|
+
errors: BlueprintError[];
|
|
20
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { parseDuration } from './parse-duration.js';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes the debounce config accepted by a definer into the shape held by a resource,
|
|
4
|
+
* parsing any duration into seconds. A bare duration is shorthand for `{window: <duration>}`.
|
|
5
|
+
* @param debounce The debounce config or duration to normalize
|
|
6
|
+
* @internal
|
|
7
|
+
* @returns The debounce config, with `window` and `maxWindow` in seconds
|
|
8
|
+
*/
|
|
9
|
+
export function createDebounceObject(debounce) {
|
|
10
|
+
if (typeof debounce !== 'object') {
|
|
11
|
+
return { window: parseDuration(debounce, 's') };
|
|
12
|
+
}
|
|
13
|
+
const { window, maxWindow, key } = debounce;
|
|
14
|
+
// `window` is required, so there is nothing sensible to parse without it
|
|
15
|
+
if (window === undefined) {
|
|
16
|
+
throw new Error('Invalid debounce config: `window` must be provided');
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
window: parseDuration(window, 's'),
|
|
20
|
+
...(maxWindow !== undefined && { maxWindow: parseDuration(maxWindow, 's') }),
|
|
21
|
+
...(key !== undefined && { key }),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolves a debounce duration, given either as a number of seconds or as a duration string, to seconds.
|
|
26
|
+
* @param field The name of the field being resolved, used in error messages
|
|
27
|
+
* @param value The value to resolve
|
|
28
|
+
* @returns The value in seconds, or the errors that prevented it from being resolved
|
|
29
|
+
*/
|
|
30
|
+
export function resolveDebounceDuration(field, value) {
|
|
31
|
+
if (typeof value === 'number') {
|
|
32
|
+
return Number.isFinite(value)
|
|
33
|
+
? { seconds: value, errors: [] }
|
|
34
|
+
: { errors: [{ type: 'invalid_value', message: `\`${field}\` must be a valid duration` }] };
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
try {
|
|
38
|
+
return { seconds: parseDuration(value, 's'), errors: [] };
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return { errors: [{ type: 'invalid_value', message: `\`${field}\` must be a valid duration` }] };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { errors: [{ type: 'invalid_type', message: `\`${field}\` must be a number of seconds or a duration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