@sanity/cli 7.7.0 → 7.8.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 +17 -2
- package/dist/actions/auth/ensureAuthenticated.js +1 -1
- package/dist/actions/auth/ensureAuthenticated.js.map +1 -1
- package/dist/actions/auth/login/validateToken.js +1 -1
- package/dist/actions/auth/login/validateToken.js.map +1 -1
- package/dist/actions/build/buildApp.js +2 -3
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +1 -2
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/deploy/createUserApplication.js +8 -8
- package/dist/actions/deploy/createUserApplication.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +121 -24
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployChecks.js +99 -68
- package/dist/actions/deploy/deployChecks.js.map +1 -1
- package/dist/actions/deploy/deployRunner.js +43 -24
- package/dist/actions/deploy/deployRunner.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +126 -23
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/deploy/deploymentPlan.js +29 -30
- package/dist/actions/deploy/deploymentPlan.js.map +1 -1
- package/dist/actions/deploy/findUserApplication.js +39 -14
- package/dist/actions/deploy/findUserApplication.js.map +1 -1
- package/dist/actions/deploy/resolveDeployTarget.js +43 -0
- package/dist/actions/deploy/resolveDeployTarget.js.map +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
- package/dist/actions/dev/servers/startStudioDevServer.js +1 -2
- package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
- package/dist/actions/graphql/SchemaError.js.map +1 -1
- package/dist/actions/graphql/extractGraphQLAPIs.js +3 -1
- package/dist/actions/graphql/extractGraphQLAPIs.js.map +1 -1
- package/dist/actions/manifest/extractCoreAppManifest.js +1 -1
- package/dist/actions/manifest/extractCoreAppManifest.js.map +1 -1
- package/dist/actions/organizations/getOrganization.js +1 -1
- package/dist/actions/organizations/getOrganization.js.map +1 -1
- package/dist/actions/schema/validateAction.js +1 -1
- package/dist/actions/schema/validateAction.js.map +1 -1
- package/dist/actions/skills/setupSkills.js +1 -1
- package/dist/actions/skills/setupSkills.js.map +1 -1
- package/dist/actions/undeploy/adapters.js +101 -0
- package/dist/actions/undeploy/adapters.js.map +1 -0
- package/dist/actions/undeploy/runUndeploy.js +165 -0
- package/dist/actions/undeploy/runUndeploy.js.map +1 -0
- package/dist/actions/undeploy/undeployPlan.js +108 -0
- package/dist/actions/undeploy/undeployPlan.js.map +1 -0
- package/dist/commands/datasets/copy.js +2 -1
- package/dist/commands/datasets/copy.js.map +1 -1
- package/dist/commands/mcp/configure.js +1 -1
- package/dist/commands/mcp/configure.js.map +1 -1
- package/dist/commands/projects/create.js +18 -13
- package/dist/commands/projects/create.js.map +1 -1
- package/dist/commands/projects/list.js +2 -1
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/schemas/validate.js +3 -2
- package/dist/commands/schemas/validate.js.map +1 -1
- package/dist/commands/skills/install.js +1 -1
- package/dist/commands/skills/install.js.map +1 -1
- package/dist/commands/tokens/list.js +1 -1
- package/dist/commands/tokens/list.js.map +1 -1
- package/dist/commands/undeploy.js +36 -74
- package/dist/commands/undeploy.js.map +1 -1
- package/dist/util/checks.js +83 -0
- package/dist/util/checks.js.map +1 -0
- package/dist/util/toStderrOutput.js +13 -0
- package/dist/util/toStderrOutput.js.map +1 -0
- package/oclif.manifest.json +1298 -1271
- package/package.json +6 -7
- package/dist/actions/undeploy/getStudioOrAppUserApplication.js +0 -36
- package/dist/actions/undeploy/getStudioOrAppUserApplication.js.map +0 -1
- package/dist/util/compareDependencyVersions.js +0 -110
- package/dist/util/compareDependencyVersions.js.map +0 -1
- package/dist/util/getErrorMessage.js +0 -28
- package/dist/util/getErrorMessage.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
4
4
|
"description": "Sanity CLI tool for managing Sanity projects and organizations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -118,9 +118,9 @@
|
|
|
118
118
|
"which": "^6.0.1",
|
|
119
119
|
"yaml": "^2.9.0",
|
|
120
120
|
"zod": "^4.4.3",
|
|
121
|
-
"@sanity/cli-
|
|
122
|
-
"@sanity/
|
|
123
|
-
"@sanity/cli
|
|
121
|
+
"@sanity/cli-build": "^4.0.0",
|
|
122
|
+
"@sanity/cli-core": "^2.3.0",
|
|
123
|
+
"@sanity/workbench-cli": "^1.3.0"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@eslint/compat": "^2.1.0",
|
|
@@ -144,7 +144,6 @@
|
|
|
144
144
|
"@types/which": "^3.0.4",
|
|
145
145
|
"@vitest/coverage-istanbul": "^4.1.9",
|
|
146
146
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
147
|
-
"es-module-lexer": "^2.1.0",
|
|
148
147
|
"eslint": "^10.4.1",
|
|
149
148
|
"jsdom": "^29.1.1",
|
|
150
149
|
"nock": "^14.0.15",
|
|
@@ -156,8 +155,8 @@
|
|
|
156
155
|
"vitest": "^4.1.9",
|
|
157
156
|
"@repo/tsconfig": "3.70.0",
|
|
158
157
|
"@repo/package.config": "0.0.1",
|
|
159
|
-
"@sanity/cli
|
|
160
|
-
"@sanity/
|
|
158
|
+
"@sanity/eslint-config-cli": "1.1.2",
|
|
159
|
+
"@sanity/cli-test": "4.0.0"
|
|
161
160
|
},
|
|
162
161
|
"peerDependencies": {
|
|
163
162
|
"babel-plugin-react-compiler": "*"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getUserApplication } from '../../services/userApplications.js';
|
|
2
|
-
import { getAppId } from '../../util/appId.js';
|
|
3
|
-
import { determineIsApp } from '../../util/determineIsApp.js';
|
|
4
|
-
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
5
|
-
export const NO_APP_ID = 'NO_APP_ID';
|
|
6
|
-
export const NO_APP_ID_OR_STUDIO_HOST = 'NO_APP_ID_OR_STUDIO_HOST';
|
|
7
|
-
// Used only in undeploy flow
|
|
8
|
-
export async function getStudioOrAppUserApplication(options) {
|
|
9
|
-
const { cliConfig } = options;
|
|
10
|
-
const projectId = cliConfig.api?.projectId;
|
|
11
|
-
const isApp = determineIsApp(cliConfig);
|
|
12
|
-
if (isApp) {
|
|
13
|
-
const appId = getAppId(cliConfig);
|
|
14
|
-
if (!appId) {
|
|
15
|
-
throw new Error(NO_APP_ID);
|
|
16
|
-
}
|
|
17
|
-
return getUserApplication({
|
|
18
|
-
appId,
|
|
19
|
-
isSdkApp: true
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
if (!cliConfig.studioHost && !cliConfig.deployment?.appId) {
|
|
23
|
-
throw new Error(NO_APP_ID_OR_STUDIO_HOST);
|
|
24
|
-
}
|
|
25
|
-
if (!projectId) {
|
|
26
|
-
throw new Error(NO_PROJECT_ID);
|
|
27
|
-
}
|
|
28
|
-
return getUserApplication({
|
|
29
|
-
appHost: cliConfig.studioHost,
|
|
30
|
-
appId: cliConfig.deployment?.appId,
|
|
31
|
-
isSdkApp: false,
|
|
32
|
-
projectId
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=getStudioOrAppUserApplication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/undeploy/getStudioOrAppUserApplication.ts"],"sourcesContent":["import {type CliConfig, type Output} from '@sanity/cli-core'\n\nimport {getUserApplication} from '../../services/userApplications.js'\nimport {getAppId} from '../../util/appId.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\ninterface GetStudioOrAppUserApplicationOptions {\n cliConfig: CliConfig\n output: Output\n}\n\nexport const NO_APP_ID = 'NO_APP_ID'\nexport const NO_APP_ID_OR_STUDIO_HOST = 'NO_APP_ID_OR_STUDIO_HOST'\n\n// Used only in undeploy flow\nexport async function getStudioOrAppUserApplication(options: GetStudioOrAppUserApplicationOptions) {\n const {cliConfig} = options\n const projectId = cliConfig.api?.projectId\n const isApp = determineIsApp(cliConfig)\n\n if (isApp) {\n const appId = getAppId(cliConfig)\n if (!appId) {\n throw new Error(NO_APP_ID)\n }\n\n return getUserApplication({appId, isSdkApp: true})\n }\n\n if (!cliConfig.studioHost && !cliConfig.deployment?.appId) {\n throw new Error(NO_APP_ID_OR_STUDIO_HOST)\n }\n\n if (!projectId) {\n throw new Error(NO_PROJECT_ID)\n }\n\n return getUserApplication({\n appHost: cliConfig.studioHost,\n appId: cliConfig.deployment?.appId,\n isSdkApp: false,\n projectId,\n })\n}\n"],"names":["getUserApplication","getAppId","determineIsApp","NO_PROJECT_ID","NO_APP_ID","NO_APP_ID_OR_STUDIO_HOST","getStudioOrAppUserApplication","options","cliConfig","projectId","api","isApp","appId","Error","isSdkApp","studioHost","deployment","appHost"],"mappings":"AAEA,SAAQA,kBAAkB,QAAO,qCAAoC;AACrE,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SAAQC,cAAc,QAAO,+BAA8B;AAC3D,SAAQC,aAAa,QAAO,8BAA6B;AAOzD,OAAO,MAAMC,YAAY,YAAW;AACpC,OAAO,MAAMC,2BAA2B,2BAA0B;AAElE,6BAA6B;AAC7B,OAAO,eAAeC,8BAA8BC,OAA6C;IAC/F,MAAM,EAACC,SAAS,EAAC,GAAGD;IACpB,MAAME,YAAYD,UAAUE,GAAG,EAAED;IACjC,MAAME,QAAQT,eAAeM;IAE7B,IAAIG,OAAO;QACT,MAAMC,QAAQX,SAASO;QACvB,IAAI,CAACI,OAAO;YACV,MAAM,IAAIC,MAAMT;QAClB;QAEA,OAAOJ,mBAAmB;YAACY;YAAOE,UAAU;QAAI;IAClD;IAEA,IAAI,CAACN,UAAUO,UAAU,IAAI,CAACP,UAAUQ,UAAU,EAAEJ,OAAO;QACzD,MAAM,IAAIC,MAAMR;IAClB;IAEA,IAAI,CAACI,WAAW;QACd,MAAM,IAAII,MAAMV;IAClB;IAEA,OAAOH,mBAAmB;QACxBiB,SAAST,UAAUO,UAAU;QAC7BH,OAAOJ,UAAUQ,UAAU,EAAEJ;QAC7BE,UAAU;QACVL;IACF;AACF"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { getModuleUrl } from '@sanity/cli-build/_internal/build';
|
|
3
|
-
import { getLocalPackageVersion, readPackageJson } from '@sanity/cli-core';
|
|
4
|
-
import { createRequester } from '@sanity/cli-core/request';
|
|
5
|
-
import { coerce, eq, prerelease, parse as semverParse } from 'semver';
|
|
6
|
-
const defaultRequester = createRequester({
|
|
7
|
-
middleware: {
|
|
8
|
-
httpErrors: false,
|
|
9
|
-
promise: {
|
|
10
|
-
onlyBody: false
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
/**
|
|
15
|
-
* @internal
|
|
16
|
-
*
|
|
17
|
-
* Compares the versions of dependencies in the studio or app with their remote versions.
|
|
18
|
-
*
|
|
19
|
-
* This function reads the package.json file in the provided working directory, and compares the versions of the dependencies
|
|
20
|
-
* specified in the `autoUpdatesImports` parameter with their remote versions. If the versions do not match, the dependency is
|
|
21
|
-
* added to a list of failed dependencies, which is returned by the function.
|
|
22
|
-
*
|
|
23
|
-
* The failed dependencies are anything that does not strictly match the remote version.
|
|
24
|
-
* This means that if a version is lower or greater by even a patch it will be marked as failed.
|
|
25
|
-
*
|
|
26
|
-
* @param packages - An array of packages with their name and version to compare against remote.
|
|
27
|
-
* @param workDir - The path to the working directory containing the package.json file.
|
|
28
|
-
* @param options - Optional configuration for version comparison.
|
|
29
|
-
*
|
|
30
|
-
* @returns A promise that resolves to an object containing `mismatched` (packages whose local and remote versions differ)
|
|
31
|
-
* and `unresolvedPrerelease` (packages with prerelease versions that could not be resolved remotely).
|
|
32
|
-
*
|
|
33
|
-
* @throws Throws an error if the remote version of a non-prerelease package cannot be fetched, or if the local version
|
|
34
|
-
* of a package cannot be parsed.
|
|
35
|
-
*/ export async function compareDependencyVersions(packages, workDir, { appId, requester = defaultRequester } = {}) {
|
|
36
|
-
const manifest = await readPackageJson(path.join(workDir, 'package.json'), {
|
|
37
|
-
skipSchemaValidation: true
|
|
38
|
-
});
|
|
39
|
-
const dependencies = {
|
|
40
|
-
...manifest?.dependencies,
|
|
41
|
-
...manifest?.devDependencies
|
|
42
|
-
};
|
|
43
|
-
const mismatched = [];
|
|
44
|
-
const unresolvedPrerelease = [];
|
|
45
|
-
for (const pkg of packages){
|
|
46
|
-
// Skip packages that are not declared in the local package.json
|
|
47
|
-
if (!dependencies[pkg.name]) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const resolvedVersion = await getRemoteResolvedVersion(getModuleUrl(pkg, {
|
|
51
|
-
appId
|
|
52
|
-
}), requester);
|
|
53
|
-
if (resolvedVersion === null) {
|
|
54
|
-
if (prerelease(pkg.version)) {
|
|
55
|
-
unresolvedPrerelease.push({
|
|
56
|
-
pkg: pkg.name,
|
|
57
|
-
version: pkg.version
|
|
58
|
-
});
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
throw new Error(`Failed to resolve remote version for ${pkg.name}@${pkg.version}: package not found`);
|
|
62
|
-
}
|
|
63
|
-
const packageVersion = await getLocalPackageVersion(pkg.name, workDir);
|
|
64
|
-
const manifestVersion = dependencies[pkg.name];
|
|
65
|
-
const installed = coerce(packageVersion ? semverParse(packageVersion) : coerce(manifestVersion));
|
|
66
|
-
if (!installed) {
|
|
67
|
-
throw new Error(`Failed to parse installed version for ${pkg.name}`);
|
|
68
|
-
}
|
|
69
|
-
if (!eq(resolvedVersion, installed.version)) {
|
|
70
|
-
mismatched.push({
|
|
71
|
-
installed: installed.version,
|
|
72
|
-
pkg: pkg.name,
|
|
73
|
-
remote: resolvedVersion
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
mismatched,
|
|
79
|
-
unresolvedPrerelease
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
async function getRemoteResolvedVersion(url, request) {
|
|
83
|
-
let response;
|
|
84
|
-
try {
|
|
85
|
-
response = await request({
|
|
86
|
-
maxRedirects: 0,
|
|
87
|
-
method: 'HEAD',
|
|
88
|
-
url
|
|
89
|
-
});
|
|
90
|
-
} catch (err) {
|
|
91
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
92
|
-
throw new Error(`Failed to fetch remote version for ${url}: ${message}`, {
|
|
93
|
-
cause: err
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
// 302 is expected, but lets also handle 2xx
|
|
97
|
-
if (response.statusCode < 400) {
|
|
98
|
-
const resolved = response.headers['x-resolved-version'];
|
|
99
|
-
if (!resolved) {
|
|
100
|
-
throw new Error(`Missing 'x-resolved-version' header on response from HEAD ${url}`);
|
|
101
|
-
}
|
|
102
|
-
return resolved;
|
|
103
|
-
}
|
|
104
|
-
if (response.statusCode === 404) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
throw new Error(`Unexpected HTTP response: ${response.statusCode} ${response.statusMessage}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
//# sourceMappingURL=compareDependencyVersions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/compareDependencyVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type CompareDependencyVersions,\n type CompareDependencyVersionsResult,\n getModuleUrl,\n type UnresolvedPrerelease,\n} from '@sanity/cli-build/_internal/build'\nimport {getLocalPackageVersion, readPackageJson} from '@sanity/cli-core'\nimport {createRequester} from '@sanity/cli-core/request'\nimport {coerce, eq, prerelease, parse as semverParse} from 'semver'\n\nconst defaultRequester = createRequester({\n middleware: {httpErrors: false, promise: {onlyBody: false}},\n})\n\ninterface CompareDependencyVersionsOptions {\n /** When provided, uses the app-specific module endpoint instead of the default endpoint. */\n appId?: string\n /** Optional requester for dependency injection (primarily for testing). */\n requester?: typeof defaultRequester\n}\n\n/**\n * @internal\n *\n * Compares the versions of dependencies in the studio or app with their remote versions.\n *\n * This function reads the package.json file in the provided working directory, and compares the versions of the dependencies\n * specified in the `autoUpdatesImports` parameter with their remote versions. If the versions do not match, the dependency is\n * added to a list of failed dependencies, which is returned by the function.\n *\n * The failed dependencies are anything that does not strictly match the remote version.\n * This means that if a version is lower or greater by even a patch it will be marked as failed.\n *\n * @param packages - An array of packages with their name and version to compare against remote.\n * @param workDir - The path to the working directory containing the package.json file.\n * @param options - Optional configuration for version comparison.\n *\n * @returns A promise that resolves to an object containing `mismatched` (packages whose local and remote versions differ)\n * and `unresolvedPrerelease` (packages with prerelease versions that could not be resolved remotely).\n *\n * @throws Throws an error if the remote version of a non-prerelease package cannot be fetched, or if the local version\n * of a package cannot be parsed.\n */\nexport async function compareDependencyVersions(\n packages: {name: string; version: string}[],\n workDir: string,\n {appId, requester = defaultRequester}: CompareDependencyVersionsOptions = {},\n): Promise<CompareDependencyVersionsResult> {\n const manifest = await readPackageJson(path.join(workDir, 'package.json'), {\n skipSchemaValidation: true,\n })\n const dependencies = {...manifest?.dependencies, ...manifest?.devDependencies}\n\n const mismatched: Array<CompareDependencyVersions> = []\n const unresolvedPrerelease: Array<UnresolvedPrerelease> = []\n\n for (const pkg of packages) {\n // Skip packages that are not declared in the local package.json\n if (!dependencies[pkg.name]) {\n continue\n }\n\n const resolvedVersion = await getRemoteResolvedVersion(getModuleUrl(pkg, {appId}), requester)\n\n if (resolvedVersion === null) {\n if (prerelease(pkg.version)) {\n unresolvedPrerelease.push({pkg: pkg.name, version: pkg.version})\n continue\n }\n throw new Error(\n `Failed to resolve remote version for ${pkg.name}@${pkg.version}: package not found`,\n )\n }\n\n const packageVersion = await getLocalPackageVersion(pkg.name, workDir)\n\n const manifestVersion = dependencies[pkg.name]\n\n const installed = coerce(packageVersion ? semverParse(packageVersion) : coerce(manifestVersion))\n\n if (!installed) {\n throw new Error(`Failed to parse installed version for ${pkg.name}`)\n }\n\n if (!eq(resolvedVersion, installed.version)) {\n mismatched.push({\n installed: installed.version,\n pkg: pkg.name,\n remote: resolvedVersion,\n })\n }\n }\n\n return {mismatched, unresolvedPrerelease}\n}\n\nasync function getRemoteResolvedVersion(\n url: string,\n request: typeof defaultRequester,\n): Promise<string | null> {\n let response\n try {\n response = await request({\n maxRedirects: 0,\n method: 'HEAD',\n url,\n })\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(`Failed to fetch remote version for ${url}: ${message}`, {cause: err})\n }\n\n // 302 is expected, but lets also handle 2xx\n if (response.statusCode < 400) {\n const resolved = response.headers['x-resolved-version']\n if (!resolved) {\n throw new Error(`Missing 'x-resolved-version' header on response from HEAD ${url}`)\n }\n return resolved\n }\n\n if (response.statusCode === 404) {\n return null\n }\n\n throw new Error(`Unexpected HTTP response: ${response.statusCode} ${response.statusMessage}`)\n}\n"],"names":["path","getModuleUrl","getLocalPackageVersion","readPackageJson","createRequester","coerce","eq","prerelease","parse","semverParse","defaultRequester","middleware","httpErrors","promise","onlyBody","compareDependencyVersions","packages","workDir","appId","requester","manifest","join","skipSchemaValidation","dependencies","devDependencies","mismatched","unresolvedPrerelease","pkg","name","resolvedVersion","getRemoteResolvedVersion","version","push","Error","packageVersion","manifestVersion","installed","remote","url","request","response","maxRedirects","method","err","message","String","cause","statusCode","resolved","headers","statusMessage"],"mappings":"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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { isHttpError } from '@sanity/client';
|
|
2
|
-
/**
|
|
3
|
-
* Coerce an unknown thrown value into an Error instance.
|
|
4
|
-
*
|
|
5
|
-
* @param value - The thrown value
|
|
6
|
-
* @returns An Error instance (the original if already an Error, otherwise a new one)
|
|
7
|
-
* @internal
|
|
8
|
-
*/ export function toError(value) {
|
|
9
|
-
return value instanceof Error ? value : new Error(String(value));
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Get the error message from an error object
|
|
13
|
-
*
|
|
14
|
-
* @param err - The error object
|
|
15
|
-
* @returns The error message
|
|
16
|
-
* @internal
|
|
17
|
-
*/ export function getErrorMessage(err) {
|
|
18
|
-
if (isHttpError(err)) {
|
|
19
|
-
const body = err.response.body;
|
|
20
|
-
if (typeof body === 'object' && body !== null && 'message' in body && typeof body.message === 'string') {
|
|
21
|
-
return body.message;
|
|
22
|
-
}
|
|
23
|
-
return err.message || 'HTTP error';
|
|
24
|
-
}
|
|
25
|
-
return err instanceof Error ? err.message : 'Unknown error';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=getErrorMessage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/getErrorMessage.ts"],"sourcesContent":["import {isHttpError} from '@sanity/client'\n\n/**\n * Coerce an unknown thrown value into an Error instance.\n *\n * @param value - The thrown value\n * @returns An Error instance (the original if already an Error, otherwise a new one)\n * @internal\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Get the error message from an error object\n *\n * @param err - The error object\n * @returns The error message\n * @internal\n */\nexport function getErrorMessage(err: unknown): string {\n if (isHttpError(err)) {\n const body = err.response.body\n if (\n typeof body === 'object' &&\n body !== null &&\n 'message' in body &&\n typeof body.message === 'string'\n ) {\n return body.message\n }\n return err.message || 'HTTP error'\n }\n return err instanceof Error ? err.message : 'Unknown error'\n}\n"],"names":["isHttpError","toError","value","Error","String","getErrorMessage","err","body","response","message"],"mappings":"AAAA,SAAQA,WAAW,QAAO,iBAAgB;AAE1C;;;;;;CAMC,GACD,OAAO,SAASC,QAAQC,KAAc;IACpC,OAAOA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF;AAC3D;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBC,GAAY;IAC1C,IAAIN,YAAYM,MAAM;QACpB,MAAMC,OAAOD,IAAIE,QAAQ,CAACD,IAAI;QAC9B,IACE,OAAOA,SAAS,YAChBA,SAAS,QACT,aAAaA,QACb,OAAOA,KAAKE,OAAO,KAAK,UACxB;YACA,OAAOF,KAAKE,OAAO;QACrB;QACA,OAAOH,IAAIG,OAAO,IAAI;IACxB;IACA,OAAOH,eAAeH,QAAQG,IAAIG,OAAO,GAAG;AAC9C"}
|