@sanity/cli 7.12.0 → 7.12.1
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/actions/build/buildApp.js +1 -1
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +1 -1
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/commands/backups/disable.js +4 -4
- package/dist/commands/backups/disable.js.map +1 -1
- package/dist/commands/backups/download.js +7 -7
- package/dist/commands/backups/download.js.map +1 -1
- package/dist/commands/backups/enable.js +4 -4
- package/dist/commands/backups/enable.js.map +1 -1
- package/dist/commands/backups/list.js +7 -7
- package/dist/commands/backups/list.js.map +1 -1
- package/dist/commands/codemod.js +5 -5
- package/dist/commands/codemod.js.map +1 -1
- package/dist/commands/cors/add.js +1 -1
- package/dist/commands/cors/add.js.map +1 -1
- package/dist/commands/cors/delete.js +4 -4
- package/dist/commands/cors/delete.js.map +1 -1
- package/dist/commands/cors/list.js +2 -2
- package/dist/commands/cors/list.js.map +1 -1
- package/dist/commands/datasets/alias/create.js +5 -5
- package/dist/commands/datasets/alias/create.js.map +1 -1
- package/dist/commands/datasets/alias/delete.js +2 -2
- package/dist/commands/datasets/alias/delete.js.map +1 -1
- package/dist/commands/datasets/alias/link.js +5 -5
- package/dist/commands/datasets/alias/link.js.map +1 -1
- package/dist/commands/datasets/alias/unlink.js +3 -3
- package/dist/commands/datasets/alias/unlink.js.map +1 -1
- package/dist/commands/datasets/copy.js +7 -7
- package/dist/commands/datasets/copy.js.map +1 -1
- package/dist/commands/datasets/create.js +3 -3
- package/dist/commands/datasets/create.js.map +1 -1
- package/dist/commands/datasets/delete.js +2 -2
- package/dist/commands/datasets/delete.js.map +1 -1
- package/dist/commands/datasets/embeddings/disable.js +3 -3
- package/dist/commands/datasets/embeddings/disable.js.map +1 -1
- package/dist/commands/datasets/embeddings/enable.js +5 -5
- package/dist/commands/datasets/embeddings/enable.js.map +1 -1
- package/dist/commands/datasets/embeddings/status.js +3 -3
- package/dist/commands/datasets/embeddings/status.js.map +1 -1
- package/dist/commands/datasets/export.js +6 -6
- package/dist/commands/datasets/export.js.map +1 -1
- package/dist/commands/datasets/import.js +3 -3
- package/dist/commands/datasets/import.js.map +1 -1
- package/dist/commands/datasets/list.js +2 -2
- package/dist/commands/datasets/list.js.map +1 -1
- package/dist/commands/datasets/visibility/get.js +2 -2
- package/dist/commands/datasets/visibility/get.js.map +1 -1
- package/dist/commands/datasets/visibility/set.js +3 -3
- package/dist/commands/datasets/visibility/set.js.map +1 -1
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.js +2 -2
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/docs/read.js +1 -1
- package/dist/commands/docs/read.js.map +1 -1
- package/dist/commands/docs/search.js +3 -3
- package/dist/commands/docs/search.js.map +1 -1
- package/dist/commands/doctor.js +3 -3
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/documents/create.js +3 -3
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/documents/delete.js +3 -3
- package/dist/commands/documents/delete.js.map +1 -1
- package/dist/commands/documents/get.js +2 -2
- package/dist/commands/documents/get.js.map +1 -1
- package/dist/commands/documents/query.js +2 -2
- package/dist/commands/documents/query.js.map +1 -1
- package/dist/commands/documents/validate.js +3 -3
- package/dist/commands/documents/validate.js.map +1 -1
- package/dist/commands/graphql/deploy.js +13 -13
- package/dist/commands/graphql/deploy.js.map +1 -1
- package/dist/commands/graphql/list.js +2 -2
- package/dist/commands/graphql/list.js.map +1 -1
- package/dist/commands/graphql/undeploy.js +2 -2
- package/dist/commands/graphql/undeploy.js.map +1 -1
- package/dist/commands/hooks/attempt.js +2 -2
- package/dist/commands/hooks/attempt.js.map +1 -1
- package/dist/commands/hooks/create.js +3 -3
- package/dist/commands/hooks/create.js.map +1 -1
- package/dist/commands/hooks/delete.js +4 -4
- package/dist/commands/hooks/delete.js.map +1 -1
- package/dist/commands/hooks/list.js +2 -2
- package/dist/commands/hooks/list.js.map +1 -1
- package/dist/commands/hooks/logs.js +5 -5
- package/dist/commands/hooks/logs.js.map +1 -1
- package/dist/commands/login.js +2 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +2 -2
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/manifest/extract.js +3 -3
- package/dist/commands/manifest/extract.js.map +1 -1
- package/dist/commands/mcp/configure.js +4 -4
- package/dist/commands/mcp/configure.js.map +1 -1
- package/dist/commands/media/create-aspect.js +3 -3
- package/dist/commands/media/create-aspect.js.map +1 -1
- package/dist/commands/media/delete-aspect.js +1 -1
- package/dist/commands/media/delete-aspect.js.map +1 -1
- package/dist/commands/media/deploy-aspect.js +4 -4
- package/dist/commands/media/deploy-aspect.js.map +1 -1
- package/dist/commands/media/export.js +7 -7
- package/dist/commands/media/export.js.map +1 -1
- package/dist/commands/media/import.js +6 -6
- package/dist/commands/media/import.js.map +1 -1
- package/dist/commands/migrations/create.js +4 -4
- package/dist/commands/migrations/create.js.map +1 -1
- package/dist/commands/migrations/list.js +2 -2
- package/dist/commands/migrations/list.js.map +1 -1
- package/dist/commands/migrations/run.js +14 -14
- package/dist/commands/migrations/run.js.map +1 -1
- package/dist/commands/openapi/get.js +3 -3
- package/dist/commands/openapi/get.js.map +1 -1
- package/dist/commands/openapi/list.js +2 -2
- package/dist/commands/openapi/list.js.map +1 -1
- package/dist/commands/organizations/create.js +5 -5
- package/dist/commands/organizations/create.js.map +1 -1
- package/dist/commands/organizations/delete.js +6 -6
- package/dist/commands/organizations/delete.js.map +1 -1
- package/dist/commands/organizations/get.js +3 -3
- package/dist/commands/organizations/get.js.map +1 -1
- package/dist/commands/organizations/list.js +2 -2
- package/dist/commands/organizations/list.js.map +1 -1
- package/dist/commands/organizations/update.js +6 -6
- package/dist/commands/organizations/update.js.map +1 -1
- package/dist/commands/preview.js +2 -2
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/projects/create.js +2 -2
- package/dist/commands/projects/create.js.map +1 -1
- package/dist/commands/projects/list.js +2 -2
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/schemas/delete.js +2 -2
- package/dist/commands/schemas/delete.js.map +1 -1
- package/dist/commands/schemas/deploy.js +2 -2
- package/dist/commands/schemas/deploy.js.map +1 -1
- package/dist/commands/schemas/list.js +1 -1
- package/dist/commands/schemas/list.js.map +1 -1
- package/dist/commands/schemas/validate.js +2 -1
- package/dist/commands/schemas/validate.js.map +1 -1
- package/dist/commands/skills/install.js +2 -2
- package/dist/commands/skills/install.js.map +1 -1
- package/dist/commands/telemetry/disable.js +2 -2
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js +2 -2
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/tokens/create.js +2 -2
- package/dist/commands/tokens/create.js.map +1 -1
- package/dist/commands/tokens/delete.js +2 -2
- package/dist/commands/tokens/delete.js.map +1 -1
- package/dist/commands/tokens/list.js +2 -2
- package/dist/commands/tokens/list.js.map +1 -1
- package/dist/commands/users/invite.js +3 -3
- package/dist/commands/users/invite.js.map +1 -1
- package/oclif.manifest.json +512 -512
- package/package.json +6 -6
|
@@ -97,13 +97,13 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
97
97
|
debug('Schema validation errors: %O', error.problemGroups);
|
|
98
98
|
error.print(this.output);
|
|
99
99
|
this.error('Fix the schema errors above and try again', {
|
|
100
|
-
exit:
|
|
100
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
debug('Failed to resolve GraphQL APIs: %O', error);
|
|
104
104
|
const message = error instanceof Error ? error.message : String(error);
|
|
105
105
|
this.error(`Failed to resolve GraphQL APIs: ${message}`, {
|
|
106
|
-
exit:
|
|
106
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
const hasMultipleApis = flags.api ? flags.api.length > 1 : apiDefs.length > 1;
|
|
@@ -139,7 +139,7 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
139
139
|
for (const apiId of onlyApis || []){
|
|
140
140
|
if (!apiDefs.some((apiDef)=>apiDef.id === apiId)) {
|
|
141
141
|
this.error(`GraphQL API with id "${apiId}" not found`, {
|
|
142
|
-
exit:
|
|
142
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -152,18 +152,18 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
152
152
|
const { apiName } = this.getApiIdentifiers(apiDef, datasetFlag, tagFlag);
|
|
153
153
|
if (apiNames.has(apiName)) {
|
|
154
154
|
this.error(`Multiple GraphQL APIs with the same dataset and tag found (${apiName})`, {
|
|
155
|
-
exit:
|
|
155
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
if (apiDef.id) {
|
|
159
159
|
if (!apiIdRegex.test(apiDef.id)) {
|
|
160
160
|
this.error(`Invalid GraphQL API id "${apiDef.id}" - only a-z, 0-9, underscore and dashes are allowed`, {
|
|
161
|
-
exit:
|
|
161
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
if (apiIds.has(apiDef.id)) {
|
|
165
165
|
this.error(`Multiple GraphQL APIs with the same ID found (${apiDef.id})`, {
|
|
166
|
-
exit:
|
|
166
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
apiIds.add(apiDef.id);
|
|
@@ -219,7 +219,7 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
219
219
|
debug('Failed to get current GraphQL schema properties', err);
|
|
220
220
|
spin.fail();
|
|
221
221
|
this.error('Failed to get current GraphQL schema properties', {
|
|
222
|
-
exit:
|
|
222
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
225
|
// CLI flag takes precedence over configuration
|
|
@@ -240,7 +240,7 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
240
240
|
if (!this.isRecognizedApiGeneration(generation)) {
|
|
241
241
|
spin.fail();
|
|
242
242
|
this.error(`Unknown API generation "${generation}" for API at index ${index}`, {
|
|
243
|
-
exit:
|
|
243
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
const enablePlayground = await this.shouldEnablePlayground({
|
|
@@ -261,7 +261,7 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
261
261
|
spin.fail();
|
|
262
262
|
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
263
263
|
this.error(`Failed to generate schema: ${message}`, {
|
|
264
|
-
exit:
|
|
264
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
let valid;
|
|
@@ -278,7 +278,7 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
278
278
|
const validationError = get(err, 'response.body.validationError');
|
|
279
279
|
spin.fail();
|
|
280
280
|
this.error(validationError ?? 'Failed to validate GraphQL API', {
|
|
281
|
-
exit:
|
|
281
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
// when the result is not valid and there are breaking changes afoot!
|
|
@@ -356,12 +356,12 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
356
356
|
spin.fail();
|
|
357
357
|
debug('Failed to deploy GraphQL API', error);
|
|
358
358
|
this.error('Failed to deploy GraphQL API', {
|
|
359
|
-
exit:
|
|
359
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
if (hasErrors) {
|
|
364
|
-
this.exit(
|
|
364
|
+
this.exit(exitCodes.RUNTIME_ERROR);
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
filterChanges(valid) {
|
|
@@ -396,7 +396,7 @@ export class GraphQLDeployCommand extends SanityCommand {
|
|
|
396
396
|
if (validationError) {
|
|
397
397
|
spin.fail();
|
|
398
398
|
this.error(`GraphQL schema is not valid:\n\n${validationError}`, {
|
|
399
|
-
exit:
|
|
399
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
402
|
const { breakingChanges, dangerousChanges } = this.filterChanges(valid);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/graphql/deploy.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport get from 'lodash-es/get.js'\n\nimport {extractGraphQLAPIs} from '../../actions/graphql/extractGraphQLAPIs.js'\nimport gen1 from '../../actions/graphql/gen1/index.js'\nimport gen2 from '../../actions/graphql/gen2/index.js'\nimport gen3 from '../../actions/graphql/gen3/index.js'\nimport {graphqlDebug} from '../../actions/graphql/graphqlDebug.js'\nimport {resolveApiGeneration} from '../../actions/graphql/resolveApiGeneration.js'\nimport {SchemaError} from '../../actions/graphql/SchemaError.js'\nimport {\n type ExtractedGraphQLAPI,\n type GeneratedApiSpecification,\n type ValidationResponse,\n} from '../../actions/graphql/types.js'\nimport {\n deployGraphQLAPI,\n getClientUrl,\n getCurrentSchemaProps,\n validateGraphQLAPI,\n} from '../../services/graphql.js'\nimport {getDatasetFlag} from '../../util/sharedFlags.js'\n\ninterface DeployTask {\n dataset: string\n enablePlayground: boolean\n projectId: string\n schema: GeneratedApiSpecification\n tag: string\n}\n\nconst apiIdRegex = /^[a-z0-9_-]+$/\nconst generations = {\n gen1,\n gen2,\n gen3,\n}\n\nconst ignoredBreaking = new Set<string>(['OPTIONAL_INPUT_FIELD_ADDED'])\n// Reserved for future use to filter out specific dangerous change types\nconst ignoredWarnings = new Set<string>()\n\nconst debug = graphqlDebug.extend('deploy')\n\nexport class GraphQLDeployCommand extends SanityCommand<typeof GraphQLDeployCommand> {\n static override description = 'Deploy a GraphQL API from the current Sanity schema'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Deploy all defined GraphQL APIs',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dry-run',\n description: 'Validate defined GraphQL APIs, check for breaking changes, skip deploy',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --api staging --api ios',\n description: 'Deploy only the GraphQL APIs with the IDs \"staging\" and \"ios\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --playground',\n description: 'Deploy all defined GraphQL APIs, overriding any playground setting',\n },\n ]\n\n static override flags = {\n api: Flags.string({\n description: 'Only deploy API with this ID (can be specified multiple times)',\n multiple: true,\n }),\n ...getDatasetFlag({description: 'Deploy API for the given dataset', semantics: 'specify'}),\n 'dry-run': Flags.boolean({\n default: false,\n description: 'Validate defined GraphQL APIs, check for breaking changes, skip deploy',\n }),\n force: Flags.boolean({\n description: 'Deploy API without confirming breaking changes',\n }),\n generation: Flags.string({\n description: 'API generation to deploy (defaults to \"gen3\")',\n options: ['gen1', 'gen2', 'gen3'],\n }),\n 'non-null-document-fields': Flags.boolean({\n description: 'Use non-null document fields (_id, _type etc)',\n }),\n playground: Flags.boolean({\n allowNo: true,\n description: 'Enable GraphQL playground for easier debugging',\n }),\n tag: Flags.string({\n description: 'Deploy API(s) to given tag (defaults to \"default\")',\n }),\n 'with-union-cache': Flags.boolean({\n description: 'Cache union types (faster for schemas with many self-references)',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(GraphQLDeployCommand)\n const {\n api: onlyApis,\n dataset: datasetFlag,\n 'dry-run': dryRun,\n generation: generationFlag,\n 'non-null-document-fields': nonNullDocumentFieldsFlag,\n playground: playgroundFlag,\n tag: tagFlag,\n 'with-union-cache': withUnionCache,\n } = flags\n\n const workDir = (await this.getProjectRoot()).directory\n\n let apiDefs: ExtractedGraphQLAPI[] = []\n let spin: ReturnType<typeof spinner>\n\n try {\n apiDefs = await extractGraphQLAPIs(workDir, {\n nonNullDocumentFieldsFlag,\n withUnionCache,\n })\n } catch (error) {\n if (error instanceof SchemaError) {\n debug('Schema validation errors: %O', error.problemGroups)\n error.print(this.output)\n this.error('Fix the schema errors above and try again', {exit: 1})\n }\n debug('Failed to resolve GraphQL APIs: %O', error)\n const message = error instanceof Error ? error.message : String(error)\n this.error(`Failed to resolve GraphQL APIs: ${message}`, {exit: 1})\n }\n\n const hasMultipleApis = flags.api ? flags.api.length > 1 : apiDefs.length > 1\n\n const usedFlags = [\n datasetFlag && '--dataset',\n tagFlag && '--tag',\n playgroundFlag !== undefined && '--playground',\n generationFlag !== undefined && '--generation',\n nonNullDocumentFieldsFlag !== undefined && '--non-null-document-fields',\n ].filter(Boolean)\n\n if (hasMultipleApis && usedFlags.length > 0) {\n this.warn(`More than one API defined, and ${usedFlags.join('/')} is specified`)\n this.warn(`This will use the specified flag(s) for ALL APIs, overriding config!`)\n\n if (flags.force) {\n this.warn(`--force specified, continuing...`)\n } else if (this.isUnattended()) {\n this.error(\n 'Flag overrides for multiple APIs require confirmation. Pass `--force` to continue.',\n {\n exit: exitCodes.USAGE_ERROR,\n },\n )\n } else {\n const confirmed = await confirm({\n default: false,\n message: 'Continue with flag overrides for all APIs?',\n })\n if (!confirmed) {\n this.log('GraphQL deployment cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n }\n }\n\n const deployTasks: DeployTask[] = []\n let hasErrors = false\n\n for (const apiId of onlyApis || []) {\n if (!apiDefs.some((apiDef) => apiDef.id === apiId)) {\n this.error(`GraphQL API with id \"${apiId}\" not found`, {exit: 1})\n }\n }\n\n const apiNames = new Set<string>()\n const apiIds = new Set<string>()\n\n for (const apiDef of apiDefs) {\n if (onlyApis && (!apiDef.id || !onlyApis.includes(apiDef.id))) {\n continue\n }\n\n const {apiName} = this.getApiIdentifiers(apiDef, datasetFlag, tagFlag)\n if (apiNames.has(apiName)) {\n this.error(`Multiple GraphQL APIs with the same dataset and tag found (${apiName})`, {\n exit: 1,\n })\n }\n\n if (apiDef.id) {\n if (!apiIdRegex.test(apiDef.id)) {\n this.error(\n `Invalid GraphQL API id \"${apiDef.id}\" - only a-z, 0-9, underscore and dashes are allowed`,\n {exit: 1},\n )\n }\n\n if (apiIds.has(apiDef.id)) {\n this.error(`Multiple GraphQL APIs with the same ID found (${apiDef.id})`, {exit: 1})\n }\n\n apiIds.add(apiDef.id)\n }\n\n apiNames.add(apiName)\n }\n\n if (onlyApis) {\n this.warn(`Deploying only specified APIs: ${onlyApis.join(', ')}`)\n }\n\n let index = -1\n for (const apiDef of apiDefs) {\n if (onlyApis && (!apiDef.id || !onlyApis.includes(apiDef.id))) {\n continue\n }\n\n index++\n\n const {apiName, dataset, tag} = this.getApiIdentifiers(apiDef, datasetFlag, tagFlag)\n const {playground, projectId} = apiDef\n spin = spinner(`Generating GraphQL API: ${apiName}`).start()\n\n if (!dataset) {\n spin.fail()\n this.error(\n `Dataset is required for API at index ${index}. Pass it with \\`--dataset <name>\\` or configure a dataset for the API.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n // Handle extraction errors early (computed in worker), before network calls and prompts.\n // Continue the loop so all API errors are reported — don't exit on the first failure.\n if (apiDef.schemaErrors?.length) {\n spin.fail()\n new SchemaError(apiDef.schemaErrors).print(this.output, `Schema errors in ${apiName}`)\n hasErrors = true\n continue\n }\n\n if (apiDef.extractionError) {\n debug('Failed to extract schema', apiDef.extractionError)\n spin.fail()\n this.log(`Failed to extract schema for ${apiName}: ${apiDef.extractionError}`)\n hasErrors = true\n continue\n }\n\n if (!apiDef.extracted) {\n spin.fail()\n this.log(`Failed to extract schema for ${apiName}: No extraction result`)\n hasErrors = true\n continue\n }\n\n let currentGeneration: string | undefined\n let playgroundEnabled: boolean | undefined\n try {\n const schemaProps = await getCurrentSchemaProps(projectId, dataset, tag)\n currentGeneration = schemaProps.currentGeneration\n playgroundEnabled = schemaProps.playgroundEnabled\n } catch (err) {\n debug('Failed to get current GraphQL schema properties', err)\n spin.fail()\n this.error('Failed to get current GraphQL schema properties', {exit: 1})\n }\n\n // CLI flag takes precedence over configuration\n const specifiedGeneration = generationFlag === undefined ? apiDef.generation : generationFlag\n\n const generation = await resolveApiGeneration({\n currentGeneration,\n force: flags.force,\n index,\n output: this.output,\n specifiedGeneration,\n unattended: this.isUnattended(),\n })\n\n if (!generation) {\n spin.stop()\n this.log('GraphQL deployment cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n\n if (!this.isRecognizedApiGeneration(generation)) {\n spin.fail()\n this.error(`Unknown API generation \"${generation}\" for API at index ${index}`, {exit: 1})\n }\n\n const enablePlayground = await this.shouldEnablePlayground({\n dryRun,\n playgroundCliFlag: playgroundFlag,\n playgroundConfiguration: playground,\n playgroundCurrentlyEnabled: playgroundEnabled,\n spin,\n })\n\n let apiSpec: GeneratedApiSpecification\n try {\n const generateSchema = generations[generation]\n apiSpec = generateSchema(apiDef.extracted, {filterSuffix: apiDef.filterSuffix})\n } catch (err) {\n debug('Failed to generate schema', err)\n spin.fail()\n const message = err instanceof Error ? err.message : 'Unknown error'\n this.error(`Failed to generate schema: ${message}`, {exit: 1})\n }\n\n let valid: ValidationResponse | undefined\n try {\n valid = await validateGraphQLAPI({\n dataset,\n enablePlayground,\n projectId,\n schema: apiSpec,\n tag,\n })\n } catch (err) {\n debug('validateGraphQLAPI error', err)\n const validationError = get(err, 'response.body.validationError')\n spin.fail()\n this.error(validationError ?? 'Failed to validate GraphQL API', {exit: 1})\n }\n\n // when the result is not valid and there are breaking changes afoot!\n if (!this.isResultValid(valid, {force: flags.force, spin})) {\n // not valid and a dry run? then it can exit with a error\n if (dryRun) {\n spin.fail()\n this.renderBreakingChanges(valid)\n hasErrors = true\n continue\n }\n\n if (this.isUnattended()) {\n spin.fail()\n this.renderBreakingChanges(valid)\n this.error(\n 'GraphQL deployment requires confirmation because the schema contains dangerous changes. Pass `--force` to continue.',\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n spin.stop()\n this.renderBreakingChanges(valid)\n const shouldDeploy = await confirm({\n default: false,\n message: 'Do you want to deploy a new API despite the dangerous changes?',\n })\n\n if (!shouldDeploy) {\n this.log('GraphQL deployment cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n\n spin.succeed()\n } else if (dryRun) {\n // isResultValid() already set the spinner state (succeed or warn).\n // Check whether changes were forced so we print the correct message.\n const {breakingChanges, dangerousChanges} = this.filterChanges(valid)\n if (breakingChanges.length > 0 || dangerousChanges.length > 0) {\n this.renderBreakingChanges(valid)\n this.log('Forced with `--force`, skipping deploy (dry run)')\n } else {\n this.log('GraphQL API is valid and has no breaking changes')\n }\n continue\n }\n\n deployTasks.push({\n dataset,\n enablePlayground,\n projectId,\n schema: apiSpec,\n tag,\n })\n }\n\n // Give some space for deployment tasks\n this.log('')\n\n for (const task of deployTasks) {\n const {dataset, enablePlayground, projectId, schema, tag} = task\n\n this.log(`Project: ${projectId}`)\n this.log(`Dataset: ${dataset}`)\n this.log(`Tag: ${tag}`)\n\n spin = spinner('Deploying GraphQL API').start()\n\n try {\n const response = await deployGraphQLAPI({\n dataset,\n enablePlayground,\n projectId,\n schema,\n tag,\n })\n\n spin.stop()\n const apiUrl = await getClientUrl(\n projectId,\n response.location.replace(/^\\/(v1|v\\d{4}-\\d{2}-\\d{2})\\//, '/'),\n )\n this.log(`URL: ${apiUrl}`)\n spin.start('Deployed!').succeed()\n this.log('')\n } catch (error) {\n spin.fail()\n debug('Failed to deploy GraphQL API', error)\n this.error('Failed to deploy GraphQL API', {exit: 1})\n }\n }\n\n if (hasErrors) {\n this.exit(1)\n }\n }\n\n private filterChanges(valid: ValidationResponse) {\n const {breakingChanges: breaking, dangerousChanges: dangerous} = valid\n return {\n breakingChanges: breaking.filter((change) => !ignoredBreaking.has(change.type)),\n dangerousChanges: dangerous.filter((change) => !ignoredWarnings.has(change.type)),\n }\n }\n\n private getApiIdentifiers(apiDef: ExtractedGraphQLAPI, datasetFlag?: string, tagFlag?: string) {\n const dataset = datasetFlag || apiDef.dataset\n const tag = tagFlag || apiDef.tag || 'default'\n const apiName = [dataset, tag].join('/')\n return {apiName, dataset, tag}\n }\n\n private isRecognizedApiGeneration(generation: string): generation is 'gen1' | 'gen2' | 'gen3' {\n return ['gen1', 'gen2', 'gen3'].includes(generation)\n }\n\n private isResultValid(\n valid: ValidationResponse,\n {force, spin}: {force?: boolean; spin: ReturnType<typeof spinner>},\n ) {\n const {validationError} = valid\n if (validationError) {\n spin.fail()\n this.error(`GraphQL schema is not valid:\\n\\n${validationError}`, {exit: 1})\n }\n\n const {breakingChanges, dangerousChanges} = this.filterChanges(valid)\n\n const hasProblematicChanges = breakingChanges.length > 0 || dangerousChanges.length > 0\n\n if (!hasProblematicChanges) {\n spin.succeed()\n return true\n }\n\n if (force) {\n spin.text = 'Validating GraphQL API: Dangerous changes. Forced with `--force`.'\n spin.warn()\n return true\n }\n\n spin.warn()\n return false\n }\n\n private renderBreakingChanges(valid: ValidationResponse) {\n const {breakingChanges, dangerousChanges} = this.filterChanges(valid)\n\n if (dangerousChanges.length > 0) {\n this.log('\\nFound potentially dangerous changes from previous schema:')\n for (const change of dangerousChanges) this.log(` - ${change.description}`)\n }\n\n if (breakingChanges.length > 0) {\n this.log('\\nFound BREAKING changes from previous schema:')\n for (const change of breakingChanges) this.log(` - ${change.description}`)\n }\n\n this.output.log('')\n }\n\n private async shouldEnablePlayground({\n dryRun,\n playgroundCliFlag,\n playgroundConfiguration,\n playgroundCurrentlyEnabled,\n spin,\n }: {\n dryRun: boolean\n playgroundCliFlag?: boolean\n playgroundConfiguration?: boolean\n playgroundCurrentlyEnabled?: boolean\n spin: ReturnType<typeof spinner>\n }): Promise<boolean> {\n // On a dry run, it doesn't matter, return true 🤷♂️\n if (dryRun) {\n return true\n }\n\n // Prioritize CLI flag if set\n if (playgroundCliFlag !== undefined) {\n return playgroundCliFlag\n }\n\n // If explicitly set true/false in configuration, use that\n if (playgroundConfiguration !== undefined) {\n return playgroundConfiguration\n }\n\n // If API is already deployed, use the current state\n if (playgroundCurrentlyEnabled !== undefined) {\n return playgroundCurrentlyEnabled\n }\n\n // If no API is deployed, default to true if non-interactive\n if (this.isUnattended()) {\n return true\n }\n\n // Interactive environment, so prompt the user\n const prevText = spin.text\n spin.warn()\n const shouldDeploy = await confirm({\n default: true,\n message: 'Do you want to enable a GraphQL playground?',\n })\n spin.clear().start(prevText)\n\n return shouldDeploy\n }\n}\n"],"names":["Flags","exitCodes","SanityCommand","confirm","spinner","get","extractGraphQLAPIs","gen1","gen2","gen3","graphqlDebug","resolveApiGeneration","SchemaError","deployGraphQLAPI","getClientUrl","getCurrentSchemaProps","validateGraphQLAPI","getDatasetFlag","apiIdRegex","generations","ignoredBreaking","Set","ignoredWarnings","debug","extend","GraphQLDeployCommand","description","examples","command","flags","api","string","multiple","semantics","boolean","default","force","generation","options","playground","allowNo","tag","run","parse","onlyApis","dataset","datasetFlag","dryRun","generationFlag","nonNullDocumentFieldsFlag","playgroundFlag","tagFlag","withUnionCache","workDir","getProjectRoot","directory","apiDefs","spin","error","problemGroups","print","output","exit","message","Error","String","hasMultipleApis","length","usedFlags","undefined","filter","Boolean","warn","join","isUnattended","USAGE_ERROR","confirmed","log","USER_ABORT","deployTasks","hasErrors","apiId","some","apiDef","id","apiNames","apiIds","includes","apiName","getApiIdentifiers","has","test","add","index","projectId","start","fail","schemaErrors","extractionError","extracted","currentGeneration","playgroundEnabled","schemaProps","err","specifiedGeneration","unattended","stop","isRecognizedApiGeneration","enablePlayground","shouldEnablePlayground","playgroundCliFlag","playgroundConfiguration","playgroundCurrentlyEnabled","apiSpec","generateSchema","filterSuffix","valid","schema","validationError","isResultValid","renderBreakingChanges","shouldDeploy","succeed","breakingChanges","dangerousChanges","filterChanges","push","task","response","apiUrl","location","replace","breaking","dangerous","change","type","hasProblematicChanges","text","prevText","clear"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,SAAS,EAAEC,aAAa,QA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AAC;YACT,KAAK,MAAMyD,UAAUX,gBAAiB,IAAI,CAAC9C,GAAG,CAAC,CAAC,GAAG,EAAEyD,OAAO5G,WAAW,EAAE;QAC3E;QAEA,IAAI,CAACmC,MAAM,CAACgB,GAAG,CAAC;IAClB;IAEA,MAAcgC,uBAAuB,EACnC9D,MAAM,EACN+D,iBAAiB,EACjBC,uBAAuB,EACvBC,0BAA0B,EAC1BvD,IAAI,EAOL,EAAoB;QACnB,qDAAqD;QACrD,IAAIV,QAAQ;YACV,OAAO;QACT;QAEA,6BAA6B;QAC7B,IAAI+D,sBAAsBzC,WAAW;YACnC,OAAOyC;QACT;QAEA,0DAA0D;QAC1D,IAAIC,4BAA4B1C,WAAW;YACzC,OAAO0C;QACT;QAEA,oDAAoD;QACpD,IAAIC,+BAA+B3C,WAAW;YAC5C,OAAO2C;QACT;QAEA,4DAA4D;QAC5D,IAAI,IAAI,CAACtC,YAAY,IAAI;YACvB,OAAO;QACT;QAEA,8CAA8C;QAC9C,MAAMgE,WAAWjF,KAAKgF,IAAI;QAC1BhF,KAAKe,IAAI;QACT,MAAMiD,eAAe,MAAMtH,QAAQ;YACjCgC,SAAS;YACT4B,SAAS;QACX;QACAN,KAAKkF,KAAK,GAAG5C,KAAK,CAAC2C;QAEnB,OAAOjB;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/graphql/deploy.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {exitCodes, SanityCommand} from '@sanity/cli-core'\nimport {confirm, spinner} from '@sanity/cli-core/ux'\nimport get from 'lodash-es/get.js'\n\nimport {extractGraphQLAPIs} from '../../actions/graphql/extractGraphQLAPIs.js'\nimport gen1 from '../../actions/graphql/gen1/index.js'\nimport gen2 from '../../actions/graphql/gen2/index.js'\nimport gen3 from '../../actions/graphql/gen3/index.js'\nimport {graphqlDebug} from '../../actions/graphql/graphqlDebug.js'\nimport {resolveApiGeneration} from '../../actions/graphql/resolveApiGeneration.js'\nimport {SchemaError} from '../../actions/graphql/SchemaError.js'\nimport {\n type ExtractedGraphQLAPI,\n type GeneratedApiSpecification,\n type ValidationResponse,\n} from '../../actions/graphql/types.js'\nimport {\n deployGraphQLAPI,\n getClientUrl,\n getCurrentSchemaProps,\n validateGraphQLAPI,\n} from '../../services/graphql.js'\nimport {getDatasetFlag} from '../../util/sharedFlags.js'\n\ninterface DeployTask {\n dataset: string\n enablePlayground: boolean\n projectId: string\n schema: GeneratedApiSpecification\n tag: string\n}\n\nconst apiIdRegex = /^[a-z0-9_-]+$/\nconst generations = {\n gen1,\n gen2,\n gen3,\n}\n\nconst ignoredBreaking = new Set<string>(['OPTIONAL_INPUT_FIELD_ADDED'])\n// Reserved for future use to filter out specific dangerous change types\nconst ignoredWarnings = new Set<string>()\n\nconst debug = graphqlDebug.extend('deploy')\n\nexport class GraphQLDeployCommand extends SanityCommand<typeof GraphQLDeployCommand> {\n static override description = 'Deploy a GraphQL API from the current Sanity schema'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Deploy all defined GraphQL APIs',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dry-run',\n description: 'Validate defined GraphQL APIs, check for breaking changes, skip deploy',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --api staging --api ios',\n description: 'Deploy only the GraphQL APIs with the IDs \"staging\" and \"ios\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --playground',\n description: 'Deploy all defined GraphQL APIs, overriding any playground setting',\n },\n ]\n\n static override flags = {\n api: Flags.string({\n description: 'Only deploy API with this ID (can be specified multiple times)',\n multiple: true,\n }),\n ...getDatasetFlag({description: 'Deploy API for the given dataset', semantics: 'specify'}),\n 'dry-run': Flags.boolean({\n default: false,\n description: 'Validate defined GraphQL APIs, check for breaking changes, skip deploy',\n }),\n force: Flags.boolean({\n description: 'Deploy API without confirming breaking changes',\n }),\n generation: Flags.string({\n description: 'API generation to deploy (defaults to \"gen3\")',\n options: ['gen1', 'gen2', 'gen3'],\n }),\n 'non-null-document-fields': Flags.boolean({\n description: 'Use non-null document fields (_id, _type etc)',\n }),\n playground: Flags.boolean({\n allowNo: true,\n description: 'Enable GraphQL playground for easier debugging',\n }),\n tag: Flags.string({\n description: 'Deploy API(s) to given tag (defaults to \"default\")',\n }),\n 'with-union-cache': Flags.boolean({\n description: 'Cache union types (faster for schemas with many self-references)',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(GraphQLDeployCommand)\n const {\n api: onlyApis,\n dataset: datasetFlag,\n 'dry-run': dryRun,\n generation: generationFlag,\n 'non-null-document-fields': nonNullDocumentFieldsFlag,\n playground: playgroundFlag,\n tag: tagFlag,\n 'with-union-cache': withUnionCache,\n } = flags\n\n const workDir = (await this.getProjectRoot()).directory\n\n let apiDefs: ExtractedGraphQLAPI[] = []\n let spin: ReturnType<typeof spinner>\n\n try {\n apiDefs = await extractGraphQLAPIs(workDir, {\n nonNullDocumentFieldsFlag,\n withUnionCache,\n })\n } catch (error) {\n if (error instanceof SchemaError) {\n debug('Schema validation errors: %O', error.problemGroups)\n error.print(this.output)\n this.error('Fix the schema errors above and try again', {exit: exitCodes.RUNTIME_ERROR})\n }\n debug('Failed to resolve GraphQL APIs: %O', error)\n const message = error instanceof Error ? error.message : String(error)\n this.error(`Failed to resolve GraphQL APIs: ${message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n const hasMultipleApis = flags.api ? flags.api.length > 1 : apiDefs.length > 1\n\n const usedFlags = [\n datasetFlag && '--dataset',\n tagFlag && '--tag',\n playgroundFlag !== undefined && '--playground',\n generationFlag !== undefined && '--generation',\n nonNullDocumentFieldsFlag !== undefined && '--non-null-document-fields',\n ].filter(Boolean)\n\n if (hasMultipleApis && usedFlags.length > 0) {\n this.warn(`More than one API defined, and ${usedFlags.join('/')} is specified`)\n this.warn(`This will use the specified flag(s) for ALL APIs, overriding config!`)\n\n if (flags.force) {\n this.warn(`--force specified, continuing...`)\n } else if (this.isUnattended()) {\n this.error(\n 'Flag overrides for multiple APIs require confirmation. Pass `--force` to continue.',\n {\n exit: exitCodes.USAGE_ERROR,\n },\n )\n } else {\n const confirmed = await confirm({\n default: false,\n message: 'Continue with flag overrides for all APIs?',\n })\n if (!confirmed) {\n this.log('GraphQL deployment cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n }\n }\n\n const deployTasks: DeployTask[] = []\n let hasErrors = false\n\n for (const apiId of onlyApis || []) {\n if (!apiDefs.some((apiDef) => apiDef.id === apiId)) {\n this.error(`GraphQL API with id \"${apiId}\" not found`, {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n const apiNames = new Set<string>()\n const apiIds = new Set<string>()\n\n for (const apiDef of apiDefs) {\n if (onlyApis && (!apiDef.id || !onlyApis.includes(apiDef.id))) {\n continue\n }\n\n const {apiName} = this.getApiIdentifiers(apiDef, datasetFlag, tagFlag)\n if (apiNames.has(apiName)) {\n this.error(`Multiple GraphQL APIs with the same dataset and tag found (${apiName})`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (apiDef.id) {\n if (!apiIdRegex.test(apiDef.id)) {\n this.error(\n `Invalid GraphQL API id \"${apiDef.id}\" - only a-z, 0-9, underscore and dashes are allowed`,\n {exit: exitCodes.RUNTIME_ERROR},\n )\n }\n\n if (apiIds.has(apiDef.id)) {\n this.error(`Multiple GraphQL APIs with the same ID found (${apiDef.id})`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n apiIds.add(apiDef.id)\n }\n\n apiNames.add(apiName)\n }\n\n if (onlyApis) {\n this.warn(`Deploying only specified APIs: ${onlyApis.join(', ')}`)\n }\n\n let index = -1\n for (const apiDef of apiDefs) {\n if (onlyApis && (!apiDef.id || !onlyApis.includes(apiDef.id))) {\n continue\n }\n\n index++\n\n const {apiName, dataset, tag} = this.getApiIdentifiers(apiDef, datasetFlag, tagFlag)\n const {playground, projectId} = apiDef\n spin = spinner(`Generating GraphQL API: ${apiName}`).start()\n\n if (!dataset) {\n spin.fail()\n this.error(\n `Dataset is required for API at index ${index}. Pass it with \\`--dataset <name>\\` or configure a dataset for the API.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n // Handle extraction errors early (computed in worker), before network calls and prompts.\n // Continue the loop so all API errors are reported — don't exit on the first failure.\n if (apiDef.schemaErrors?.length) {\n spin.fail()\n new SchemaError(apiDef.schemaErrors).print(this.output, `Schema errors in ${apiName}`)\n hasErrors = true\n continue\n }\n\n if (apiDef.extractionError) {\n debug('Failed to extract schema', apiDef.extractionError)\n spin.fail()\n this.log(`Failed to extract schema for ${apiName}: ${apiDef.extractionError}`)\n hasErrors = true\n continue\n }\n\n if (!apiDef.extracted) {\n spin.fail()\n this.log(`Failed to extract schema for ${apiName}: No extraction result`)\n hasErrors = true\n continue\n }\n\n let currentGeneration: string | undefined\n let playgroundEnabled: boolean | undefined\n try {\n const schemaProps = await getCurrentSchemaProps(projectId, dataset, tag)\n currentGeneration = schemaProps.currentGeneration\n playgroundEnabled = schemaProps.playgroundEnabled\n } catch (err) {\n debug('Failed to get current GraphQL schema properties', err)\n spin.fail()\n this.error('Failed to get current GraphQL schema properties', {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n // CLI flag takes precedence over configuration\n const specifiedGeneration = generationFlag === undefined ? apiDef.generation : generationFlag\n\n const generation = await resolveApiGeneration({\n currentGeneration,\n force: flags.force,\n index,\n output: this.output,\n specifiedGeneration,\n unattended: this.isUnattended(),\n })\n\n if (!generation) {\n spin.stop()\n this.log('GraphQL deployment cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n\n if (!this.isRecognizedApiGeneration(generation)) {\n spin.fail()\n this.error(`Unknown API generation \"${generation}\" for API at index ${index}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n const enablePlayground = await this.shouldEnablePlayground({\n dryRun,\n playgroundCliFlag: playgroundFlag,\n playgroundConfiguration: playground,\n playgroundCurrentlyEnabled: playgroundEnabled,\n spin,\n })\n\n let apiSpec: GeneratedApiSpecification\n try {\n const generateSchema = generations[generation]\n apiSpec = generateSchema(apiDef.extracted, {filterSuffix: apiDef.filterSuffix})\n } catch (err) {\n debug('Failed to generate schema', err)\n spin.fail()\n const message = err instanceof Error ? err.message : 'Unknown error'\n this.error(`Failed to generate schema: ${message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n let valid: ValidationResponse | undefined\n try {\n valid = await validateGraphQLAPI({\n dataset,\n enablePlayground,\n projectId,\n schema: apiSpec,\n tag,\n })\n } catch (err) {\n debug('validateGraphQLAPI error', err)\n const validationError = get(err, 'response.body.validationError')\n spin.fail()\n this.error(validationError ?? 'Failed to validate GraphQL API', {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n // when the result is not valid and there are breaking changes afoot!\n if (!this.isResultValid(valid, {force: flags.force, spin})) {\n // not valid and a dry run? then it can exit with a error\n if (dryRun) {\n spin.fail()\n this.renderBreakingChanges(valid)\n hasErrors = true\n continue\n }\n\n if (this.isUnattended()) {\n spin.fail()\n this.renderBreakingChanges(valid)\n this.error(\n 'GraphQL deployment requires confirmation because the schema contains dangerous changes. Pass `--force` to continue.',\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n spin.stop()\n this.renderBreakingChanges(valid)\n const shouldDeploy = await confirm({\n default: false,\n message: 'Do you want to deploy a new API despite the dangerous changes?',\n })\n\n if (!shouldDeploy) {\n this.log('GraphQL deployment cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n\n spin.succeed()\n } else if (dryRun) {\n // isResultValid() already set the spinner state (succeed or warn).\n // Check whether changes were forced so we print the correct message.\n const {breakingChanges, dangerousChanges} = this.filterChanges(valid)\n if (breakingChanges.length > 0 || dangerousChanges.length > 0) {\n this.renderBreakingChanges(valid)\n this.log('Forced with `--force`, skipping deploy (dry run)')\n } else {\n this.log('GraphQL API is valid and has no breaking changes')\n }\n continue\n }\n\n deployTasks.push({\n dataset,\n enablePlayground,\n projectId,\n schema: apiSpec,\n tag,\n })\n }\n\n // Give some space for deployment tasks\n this.log('')\n\n for (const task of deployTasks) {\n const {dataset, enablePlayground, projectId, schema, tag} = task\n\n this.log(`Project: ${projectId}`)\n this.log(`Dataset: ${dataset}`)\n this.log(`Tag: ${tag}`)\n\n spin = spinner('Deploying GraphQL API').start()\n\n try {\n const response = await deployGraphQLAPI({\n dataset,\n enablePlayground,\n projectId,\n schema,\n tag,\n })\n\n spin.stop()\n const apiUrl = await getClientUrl(\n projectId,\n response.location.replace(/^\\/(v1|v\\d{4}-\\d{2}-\\d{2})\\//, '/'),\n )\n this.log(`URL: ${apiUrl}`)\n spin.start('Deployed!').succeed()\n this.log('')\n } catch (error) {\n spin.fail()\n debug('Failed to deploy GraphQL API', error)\n this.error('Failed to deploy GraphQL API', {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n if (hasErrors) {\n this.exit(exitCodes.RUNTIME_ERROR)\n }\n }\n\n private filterChanges(valid: ValidationResponse) {\n const {breakingChanges: breaking, dangerousChanges: dangerous} = valid\n return {\n breakingChanges: breaking.filter((change) => !ignoredBreaking.has(change.type)),\n dangerousChanges: dangerous.filter((change) => !ignoredWarnings.has(change.type)),\n }\n }\n\n private getApiIdentifiers(apiDef: ExtractedGraphQLAPI, datasetFlag?: string, tagFlag?: string) {\n const dataset = datasetFlag || apiDef.dataset\n const tag = tagFlag || apiDef.tag || 'default'\n const apiName = [dataset, tag].join('/')\n return {apiName, dataset, tag}\n }\n\n private isRecognizedApiGeneration(generation: string): generation is 'gen1' | 'gen2' | 'gen3' {\n return ['gen1', 'gen2', 'gen3'].includes(generation)\n }\n\n private isResultValid(\n valid: ValidationResponse,\n {force, spin}: {force?: boolean; spin: ReturnType<typeof spinner>},\n ) {\n const {validationError} = valid\n if (validationError) {\n spin.fail()\n this.error(`GraphQL schema is not valid:\\n\\n${validationError}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n const {breakingChanges, dangerousChanges} = this.filterChanges(valid)\n\n const hasProblematicChanges = breakingChanges.length > 0 || dangerousChanges.length > 0\n\n if (!hasProblematicChanges) {\n spin.succeed()\n return true\n }\n\n if (force) {\n spin.text = 'Validating GraphQL API: Dangerous changes. Forced with `--force`.'\n spin.warn()\n return true\n }\n\n spin.warn()\n return false\n }\n\n private renderBreakingChanges(valid: ValidationResponse) {\n const {breakingChanges, dangerousChanges} = this.filterChanges(valid)\n\n if (dangerousChanges.length > 0) {\n this.log('\\nFound potentially dangerous changes from previous schema:')\n for (const change of dangerousChanges) this.log(` - ${change.description}`)\n }\n\n if (breakingChanges.length > 0) {\n this.log('\\nFound BREAKING changes from previous schema:')\n for (const change of breakingChanges) this.log(` - ${change.description}`)\n }\n\n this.output.log('')\n }\n\n private async shouldEnablePlayground({\n dryRun,\n playgroundCliFlag,\n playgroundConfiguration,\n playgroundCurrentlyEnabled,\n spin,\n }: {\n dryRun: boolean\n playgroundCliFlag?: boolean\n playgroundConfiguration?: boolean\n playgroundCurrentlyEnabled?: boolean\n spin: ReturnType<typeof spinner>\n }): Promise<boolean> {\n // On a dry run, it doesn't matter, return true 🤷♂️\n if (dryRun) {\n return true\n }\n\n // Prioritize CLI flag if set\n if (playgroundCliFlag !== undefined) {\n return playgroundCliFlag\n }\n\n // If explicitly set true/false in configuration, use that\n if (playgroundConfiguration !== undefined) {\n return playgroundConfiguration\n }\n\n // If API is already deployed, use the current state\n if (playgroundCurrentlyEnabled !== undefined) {\n return playgroundCurrentlyEnabled\n }\n\n // If no API is deployed, default to true if non-interactive\n if (this.isUnattended()) {\n return true\n }\n\n // Interactive environment, so prompt the user\n const prevText = spin.text\n spin.warn()\n const shouldDeploy = await confirm({\n default: true,\n message: 'Do you want to enable a GraphQL playground?',\n })\n spin.clear().start(prevText)\n\n return shouldDeploy\n }\n}\n"],"names":["Flags","exitCodes","SanityCommand","confirm","spinner","get","extractGraphQLAPIs","gen1","gen2","gen3","graphqlDebug","resolveApiGeneration","SchemaError","deployGraphQLAPI","getClientUrl","getCurrentSchemaProps","validateGraphQLAPI","getDatasetFlag","apiIdRegex","generations","ignoredBreaking","Set","ignoredWarnings","debug","extend","GraphQLDeployCommand","description","examples","command","flags","api","string","multiple","semantics","boolean","default","force","generation","options","playground","allowNo","tag","run","parse","onlyApis","dataset","datasetFlag","dryRun","generationFlag","nonNullDocumentFieldsFlag","playgroundFlag","tagFlag","withUnionCache","workDir","getProjectRoot","directory","apiDefs","spin","error","problemGroups","print","output","exit","RUNTIME_ERROR","message","Error","String","hasMultipleApis","length","usedFlags","undefined","filter","Boolean","warn","join","isUnattended","USAGE_ERROR","confirmed","log","USER_ABORT","deployTasks","hasErrors","apiId","some","apiDef","id","apiNames","apiIds","includes","apiName","getApiIdentifiers","has","test","add","index","projectId","start","fail","schemaErrors","extractionError","extracted","currentGeneration","playgroundEnabled","schemaProps","err","specifiedGeneration","unattended","stop","isRecognizedApiGeneration","enablePlayground","shouldEnablePlayground","playgroundCliFlag","playgroundConfiguration","playgroundCurrentlyEnabled","apiSpec","generateSchema","filterSuffix","valid","schema","validationError","isResultValid","renderBreakingChanges","shouldDeploy","succeed","breakingChanges","dangerousChanges","filterChanges","push","task","response","apiUrl","location","replace","breaking","dangerous","change","type","hasProblematicChanges","text","prevText","clear"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,SAAS,EAAEC,aAAa,QAAO,mBAAkB;AACzD,SAAQC,OAAO,EAAEC,OAAO,QAAO,sBAAqB;AACpD,OAAOC,SAAS,mBAAkB;AAElC,SAAQC,kBAAkB,QAAO,8CAA6C;AAC9E,OAAOC,UAAU,sCAAqC;AACtD,OAAOC,UAAU,sCAAqC;AACtD,OAAOC,UAAU,sCAAqC;AACtD,SAAQC,YAAY,QAAO,wCAAuC;AAClE,SAAQC,oBAAoB,QAAO,gDAA+C;AAClF,SAAQC,WAAW,QAAO,uCAAsC;AAMhE,SACEC,gBAAgB,EAChBC,YAAY,EACZC,qBAAqB,EACrBC,kBAAkB,QACb,4BAA2B;AAClC,SAAQC,cAAc,QAAO,4BAA2B;AAUxD,MAAMC,aAAa;AACn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BAAiB,EACjBC,uBAAuB,EACvBC,0BAA0B,EAC1BxD,IAAI,EAOL,EAAoB;QACnB,qDAAqD;QACrD,IAAIV,QAAQ;YACV,OAAO;QACT;QAEA,6BAA6B;QAC7B,IAAIgE,sBAAsBzC,WAAW;YACnC,OAAOyC;QACT;QAEA,0DAA0D;QAC1D,IAAIC,4BAA4B1C,WAAW;YACzC,OAAO0C;QACT;QAEA,oDAAoD;QACpD,IAAIC,+BAA+B3C,WAAW;YAC5C,OAAO2C;QACT;QAEA,4DAA4D;QAC5D,IAAI,IAAI,CAACtC,YAAY,IAAI;YACvB,OAAO;QACT;QAEA,8CAA8C;QAC9C,MAAMgE,WAAWlF,KAAKiF,IAAI;QAC1BjF,KAAKgB,IAAI;QACT,MAAMiD,eAAe,MAAMvH,QAAQ;YACjCgC,SAAS;YACT6B,SAAS;QACX;QACAP,KAAKmF,KAAK,GAAG5C,KAAK,CAAC2C;QAEnB,OAAOjB;IACT;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
|
-
import { getProjectCliClient, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
|
+
import { exitCodes, getProjectCliClient, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
3
|
import { promptForProject } from '../../prompts/promptForProject.js';
|
|
4
4
|
import { GRAPHQL_API_VERSION, listGraphQLEndpoints } from '../../services/graphql.js';
|
|
5
5
|
import { getProjectIdFlag } from '../../util/sharedFlags.js';
|
|
@@ -34,7 +34,7 @@ export class List extends SanityCommand {
|
|
|
34
34
|
const message = error instanceof Error ? error.message : String(error);
|
|
35
35
|
listGraphQLDebug(`Error fetching GraphQL endpoints for project ${projectId}`, error);
|
|
36
36
|
this.error(`GraphQL endpoints list retrieval failed:\n${message}`, {
|
|
37
|
-
exit:
|
|
37
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
if (!endpoints || endpoints.length === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/graphql/list.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {getProjectCliClient, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {\n GRAPHQL_API_VERSION,\n type GraphQLEndpoint,\n listGraphQLEndpoints,\n} from '../../services/graphql.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst listGraphQLDebug = subdebug('graphql:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List deployed GraphQL endpoints for the project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List GraphQL endpoints for the project',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'List GraphQL endpoints for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to list GraphQL endpoints for',\n semantics: 'override',\n }),\n }\n\n public async run(): Promise<void> {\n await this.parse(List)\n\n const projectId = await this.getProjectId({\n fallback: () => promptForProject({}),\n })\n\n let endpoints: GraphQLEndpoint[] | undefined\n try {\n endpoints = await listGraphQLEndpoints(projectId)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n\n listGraphQLDebug(`Error fetching GraphQL endpoints for project ${projectId}`, error)\n this.error(`GraphQL endpoints list retrieval failed:\\n${message}`, {exit:
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/graphql/list.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {exitCodes, getProjectCliClient, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {\n GRAPHQL_API_VERSION,\n type GraphQLEndpoint,\n listGraphQLEndpoints,\n} from '../../services/graphql.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst listGraphQLDebug = subdebug('graphql:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List deployed GraphQL endpoints for the project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List GraphQL endpoints for the project',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'List GraphQL endpoints for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to list GraphQL endpoints for',\n semantics: 'override',\n }),\n }\n\n public async run(): Promise<void> {\n await this.parse(List)\n\n const projectId = await this.getProjectId({\n fallback: () => promptForProject({}),\n })\n\n let endpoints: GraphQLEndpoint[] | undefined\n try {\n endpoints = await listGraphQLEndpoints(projectId)\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n\n listGraphQLDebug(`Error fetching GraphQL endpoints for project ${projectId}`, error)\n this.error(`GraphQL endpoints list retrieval failed:\\n${message}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (!endpoints || endpoints.length === 0) {\n this.log(\"This project doesn't have any GraphQL endpoints deployed.\")\n return\n }\n\n const client = await getProjectCliClient({\n apiVersion: GRAPHQL_API_VERSION,\n projectId,\n })\n\n this.log('Here are the GraphQL endpoints deployed for this project:')\n for (const [index, endpoint] of endpoints.entries()) {\n const {dataset, tag} = endpoint\n const url = client.getUrl(`/graphql/${dataset}/${tag}`)\n\n this.log(`${index + 1}. ${styleText('bold', 'Dataset:')} ${dataset}`)\n this.log(` ${styleText('bold', 'Tag:')} ${tag}`)\n this.log(` ${styleText('bold', 'Generation:')} ${endpoint.generation}`)\n this.log(` ${styleText('bold', 'Playground:')} ${endpoint.playgroundEnabled}`)\n this.log(` ${styleText('bold', 'URL:')} ${url}\\n`)\n }\n }\n}\n"],"names":["styleText","exitCodes","getProjectCliClient","SanityCommand","subdebug","promptForProject","GRAPHQL_API_VERSION","listGraphQLEndpoints","getProjectIdFlag","listGraphQLDebug","List","description","examples","command","flags","semantics","run","parse","projectId","getProjectId","fallback","endpoints","error","message","Error","String","exit","RUNTIME_ERROR","length","log","client","apiVersion","index","endpoint","entries","dataset","tag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AO,GAAI;YACnD,MAAM,EAACC,OAAO,EAAEC,GAAG,EAAC,GAAGH;YACvB,MAAMI,MAAMP,OAAOQ,MAAM,CAAC,CAAC,SAAS,EAAEH,QAAQ,CAAC,EAAEC,KAAK;YAEtD,IAAI,CAACP,GAAG,CAAC,GAAGG,QAAQ,EAAE,GAAG,EAAEhC,UAAU,QAAQ,YAAY,KAAK,EAAEmC,SAAS;YACzE,IAAI,CAACN,GAAG,CAAC,CAAC,IAAI,EAAE7B,UAAU,QAAQ,QAAQ,SAAS,EAAEoC,KAAK;YAC1D,IAAI,CAACP,GAAG,CAAC,CAAC,IAAI,EAAE7B,UAAU,QAAQ,eAAe,EAAE,EAAEiC,SAASM,UAAU,EAAE;YAC1E,IAAI,CAACV,GAAG,CAAC,CAAC,IAAI,EAAE7B,UAAU,QAAQ,eAAe,EAAE,EAAEiC,SAASO,iBAAiB,EAAE;YACjF,IAAI,CAACX,GAAG,CAAC,CAAC,IAAI,EAAE7B,UAAU,QAAQ,QAAQ,EAAE,EAAEqC,IAAI,EAAE,CAAC;QACvD;IACF;AACF"}
|
|
@@ -82,7 +82,7 @@ export class Undeploy extends SanityCommand {
|
|
|
82
82
|
const apiDef = apiDefs.find((def)=>def.id === apiFlag);
|
|
83
83
|
if (!apiDef) {
|
|
84
84
|
this.error(`GraphQL API "${apiFlag}" not found`, {
|
|
85
|
-
exit:
|
|
85
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
projectId = apiDef.projectId;
|
|
@@ -149,7 +149,7 @@ export class Undeploy extends SanityCommand {
|
|
|
149
149
|
const err = error instanceof Error ? error : new Error(`${error}`);
|
|
150
150
|
undeployGraphqlDebug(`Error deleting GraphQL API for ${dataset}/${tag}`, err);
|
|
151
151
|
this.error(`GraphQL API deletion failed:\n${err.message}`, {
|
|
152
|
-
exit:
|
|
152
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/graphql/undeploy.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\n\nimport {getGraphQLAPIs} from '../../actions/graphql/getGraphQLAPIs.js'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {deleteGraphQLAPI} from '../../services/graphql.js'\nimport {getDatasetFlag, getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst undeployGraphqlDebug = subdebug('graphql:undeploy')\n\nexport class Undeploy extends SanityCommand<typeof Undeploy> {\n static override description = 'Remove a deployed GraphQL API'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Undeploy GraphQL API for current project and dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --api ios',\n description: 'Undeploy API with ID \"ios\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dataset staging',\n description: 'Undeploy GraphQL API for staging dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dataset staging --tag next',\n description: 'Undeploy GraphQL API for staging dataset with \"next\" tag',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --force',\n description: 'Undeploy GraphQL API without confirmation prompt',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123 --dataset production',\n description: 'Undeploy GraphQL API for a specific project and dataset',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to undeploy GraphQL API from',\n semantics: 'override',\n }),\n api: Flags.string({\n description: 'Undeploy API with this ID',\n exclusive: ['project-id', 'project'],\n required: false,\n }),\n ...getDatasetFlag({description: 'Dataset to undeploy GraphQL API from', semantics: 'override'}),\n force: Flags.boolean({\n description: 'Skip confirmation prompt',\n required: false,\n }),\n project: Flags.string({\n deprecated: {to: 'project-id'},\n description: 'Project ID to delete GraphQL API for',\n hidden: true,\n required: false,\n }),\n tag: Flags.string({\n default: 'default',\n description: 'Tag to undeploy GraphQL API from',\n required: false,\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Undeploy)\n const {api: apiFlag, dataset: datasetFlag, force, tag: tagFlag} = flags\n\n let projectId: string | undefined\n let dataset = datasetFlag\n let tag = tagFlag\n\n // If specifying --api, use it for the flags not provided\n if (apiFlag) {\n const workDir = (await this.getProjectRoot()).directory\n const apiDefs = await getGraphQLAPIs(workDir)\n const apiDef = apiDefs.find((def) => def.id === apiFlag)\n\n if (!apiDef) {\n this.error(`GraphQL API \"${apiFlag}\" not found`, {exit:
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/graphql/undeploy.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\n\nimport {getGraphQLAPIs} from '../../actions/graphql/getGraphQLAPIs.js'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {deleteGraphQLAPI} from '../../services/graphql.js'\nimport {getDatasetFlag, getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst undeployGraphqlDebug = subdebug('graphql:undeploy')\n\nexport class Undeploy extends SanityCommand<typeof Undeploy> {\n static override description = 'Remove a deployed GraphQL API'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Undeploy GraphQL API for current project and dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --api ios',\n description: 'Undeploy API with ID \"ios\"',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dataset staging',\n description: 'Undeploy GraphQL API for staging dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --dataset staging --tag next',\n description: 'Undeploy GraphQL API for staging dataset with \"next\" tag',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --force',\n description: 'Undeploy GraphQL API without confirmation prompt',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123 --dataset production',\n description: 'Undeploy GraphQL API for a specific project and dataset',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to undeploy GraphQL API from',\n semantics: 'override',\n }),\n api: Flags.string({\n description: 'Undeploy API with this ID',\n exclusive: ['project-id', 'project'],\n required: false,\n }),\n ...getDatasetFlag({description: 'Dataset to undeploy GraphQL API from', semantics: 'override'}),\n force: Flags.boolean({\n description: 'Skip confirmation prompt',\n required: false,\n }),\n project: Flags.string({\n deprecated: {to: 'project-id'},\n description: 'Project ID to delete GraphQL API for',\n hidden: true,\n required: false,\n }),\n tag: Flags.string({\n default: 'default',\n description: 'Tag to undeploy GraphQL API from',\n required: false,\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Undeploy)\n const {api: apiFlag, dataset: datasetFlag, force, tag: tagFlag} = flags\n\n let projectId: string | undefined\n let dataset = datasetFlag\n let tag = tagFlag\n\n // If specifying --api, use it for the flags not provided\n if (apiFlag) {\n const workDir = (await this.getProjectRoot()).directory\n const apiDefs = await getGraphQLAPIs(workDir)\n const apiDef = apiDefs.find((def) => def.id === apiFlag)\n\n if (!apiDef) {\n this.error(`GraphQL API \"${apiFlag}\" not found`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n projectId = apiDef.projectId\n\n if (dataset && dataset !== apiDef.dataset) {\n this.warn(`Both --api and --dataset specified, using --dataset ${dataset}`)\n } else {\n dataset = apiDef.dataset\n }\n\n if (tag && tag !== 'default' && apiDef.tag && tag !== apiDef.tag) {\n this.warn(`Both --api and --tag specified, using --tag ${tag}`)\n } else {\n tag = apiDef.tag || 'default'\n }\n }\n\n // Get projectId from config if not specified\n if (!projectId) {\n projectId = await this.getProjectId({\n deprecatedFlagName: 'project',\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'manage', permission: 'sanity.project.graphql'}],\n }),\n })\n }\n\n // Get dataset from CLI config if not specified\n if (!dataset) {\n const cliConfig = await this.tryGetCliConfig()\n dataset = cliConfig.api?.dataset\n }\n\n if (!dataset) {\n this.error(\n 'Dataset is required. Pass it with `--dataset <name>` or configure it in your project.',\n {\n exit: exitCodes.USAGE_ERROR,\n },\n )\n }\n\n // Confirm deletion unless --force is used\n if (!force) {\n if (this.isUnattended()) {\n this.error('GraphQL API undeploy requires confirmation. Pass `--force` to continue.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n const confirmMessage =\n tag === 'default'\n ? `Delete the GraphQL API for dataset \"${dataset}\" in project ${projectId}?`\n : `Delete the GraphQL API for dataset \"${dataset}\" in project ${projectId} with tag \"${tag}\"?`\n\n const confirmed = await confirm({\n default: false,\n message: confirmMessage,\n })\n\n if (!confirmed) {\n this.log('GraphQL API undeploy cancelled')\n this.exit(exitCodes.USER_ABORT)\n }\n }\n\n try {\n await deleteGraphQLAPI({\n dataset,\n projectId,\n tag,\n })\n\n this.log('GraphQL API deleted')\n } catch (error) {\n const err = error instanceof Error ? error : new Error(`${error}`)\n undeployGraphqlDebug(`Error deleting GraphQL API for ${dataset}/${tag}`, err)\n this.error(`GraphQL API deletion failed:\\n${err.message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["Flags","exitCodes","SanityCommand","subdebug","confirm","getGraphQLAPIs","promptForProject","deleteGraphQLAPI","getDatasetFlag","getProjectIdFlag","undeployGraphqlDebug","Undeploy","description","examples","command","flags","semantics","api","string","exclusive","required","force","boolean","project","deprecated","to","hidden","tag","default","run","parse","apiFlag","dataset","datasetFlag","tagFlag","projectId","workDir","getProjectRoot","directory","apiDefs","apiDef","find","def","id","error","exit","RUNTIME_ERROR","warn","getProjectId","deprecatedFlagName","fallback","requiredPermissions","grant","permission","cliConfig","tryGetCliConfig","USAGE_ERROR","isUnattended","confirmMessage","confirmed","message","log","USER_ABORT","err","Error"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,cAAc,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AAI,CAACoC,YAAY,IAAI;gBACvB,IAAI,CAACb,KAAK,CAAC,2EAA2E;oBACpFC,MAAM5C,UAAUuD,WAAW;gBAC7B;YACF;YAEA,MAAME,iBACJ/B,QAAQ,YACJ,CAAC,oCAAoC,EAAEK,QAAQ,aAAa,EAAEG,UAAU,CAAC,CAAC,GAC1E,CAAC,oCAAoC,EAAEH,QAAQ,aAAa,EAAEG,UAAU,WAAW,EAAER,IAAI,EAAE,CAAC;YAElG,MAAMgC,YAAY,MAAMvD,QAAQ;gBAC9BwB,SAAS;gBACTgC,SAASF;YACX;YAEA,IAAI,CAACC,WAAW;gBACd,IAAI,CAACE,GAAG,CAAC;gBACT,IAAI,CAAChB,IAAI,CAAC5C,UAAU6D,UAAU;YAChC;QACF;QAEA,IAAI;YACF,MAAMvD,iBAAiB;gBACrByB;gBACAG;gBACAR;YACF;YAEA,IAAI,CAACkC,GAAG,CAAC;QACX,EAAE,OAAOjB,OAAO;YACd,MAAMmB,MAAMnB,iBAAiBoB,QAAQpB,QAAQ,IAAIoB,MAAM,GAAGpB,OAAO;YACjElC,qBAAqB,CAAC,+BAA+B,EAAEsB,QAAQ,CAAC,EAAEL,KAAK,EAAEoC;YACzE,IAAI,CAACnB,KAAK,CAAC,CAAC,8BAA8B,EAAEmB,IAAIH,OAAO,EAAE,EAAE;gBAACf,MAAM5C,UAAU6C,aAAa;YAAA;QAC3F;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import { SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
|
+
import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
3
|
import { formatFailure } from '../../actions/hook/formatFailure.js';
|
|
4
4
|
import { promptForProject } from '../../prompts/promptForProject.js';
|
|
5
5
|
import { getHookAttempt } from '../../services/hooks.js';
|
|
@@ -55,7 +55,7 @@ export class AttemptHookCommand extends SanityCommand {
|
|
|
55
55
|
const err = error;
|
|
56
56
|
attemptDebug(`Error fetching hook attempt ${attemptId}`, err);
|
|
57
57
|
this.error(`Hook attempt retrieval failed:\n${err.message}`, {
|
|
58
|
-
exit:
|
|
58
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
const { createdAt, failureReason, inProgress, resultBody, resultCode } = attempt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hooks/attempt.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {formatFailure} from '../../actions/hook/formatFailure.js'\nimport {type DeliveryAttempt} from '../../actions/hook/types.js'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {getHookAttempt} from '../../services/hooks.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst attemptDebug = subdebug('hook:attempt')\n\nexport class AttemptHookCommand extends SanityCommand<typeof AttemptHookCommand> {\n static override args = {\n attemptId: Args.string({\n description: 'The delivery attempt ID to get details for',\n required: true,\n }),\n }\n static override description = 'Print details of a given webhook delivery attempt'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> abc123',\n description: 'Print details of webhook delivery attempt with ID abc123',\n },\n {\n command: '<%= config.bin %> <%= command.id %> abc123 --project-id projectId',\n description: 'Get attempt details for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to view webhook attempt for',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:attempt']\n\n public async run() {\n const {args} = await this.parse(AttemptHookCommand)\n const {attemptId} = args\n\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'read', permission: 'sanity.project.webhooks'}],\n }),\n })\n\n let attempt: DeliveryAttempt\n try {\n attempt = await getHookAttempt({attemptId, projectId})\n } catch (error) {\n const err = error as Error\n attemptDebug(`Error fetching hook attempt ${attemptId}`, err)\n this.error(`Hook attempt retrieval failed:\\n${err.message}`, {exit:
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hooks/attempt.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {formatFailure} from '../../actions/hook/formatFailure.js'\nimport {type DeliveryAttempt} from '../../actions/hook/types.js'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {getHookAttempt} from '../../services/hooks.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst attemptDebug = subdebug('hook:attempt')\n\nexport class AttemptHookCommand extends SanityCommand<typeof AttemptHookCommand> {\n static override args = {\n attemptId: Args.string({\n description: 'The delivery attempt ID to get details for',\n required: true,\n }),\n }\n static override description = 'Print details of a given webhook delivery attempt'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> abc123',\n description: 'Print details of webhook delivery attempt with ID abc123',\n },\n {\n command: '<%= config.bin %> <%= command.id %> abc123 --project-id projectId',\n description: 'Get attempt details for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to view webhook attempt for',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:attempt']\n\n public async run() {\n const {args} = await this.parse(AttemptHookCommand)\n const {attemptId} = args\n\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'read', permission: 'sanity.project.webhooks'}],\n }),\n })\n\n let attempt: DeliveryAttempt\n try {\n attempt = await getHookAttempt({attemptId, projectId})\n } catch (error) {\n const err = error as Error\n attemptDebug(`Error fetching hook attempt ${attemptId}`, err)\n this.error(`Hook attempt retrieval failed:\\n${err.message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n const {createdAt, failureReason, inProgress, resultBody, resultCode} = attempt\n\n this.log(`Date: ${createdAt}`)\n this.log(`Status: ${this.getStatus(attempt)}`)\n this.log(`Status code: ${resultCode}`)\n\n if (attempt.isFailure) {\n this.log(`Failure: ${formatFailure(attempt)}`)\n }\n\n if (!inProgress && (!failureReason || failureReason === 'http')) {\n const body = resultBody ? `\\n---\\n${resultBody}\\n---\\n` : '<empty>'\n this.log(`Response body: ${body}`)\n }\n }\n\n private getStatus(attempt: DeliveryAttempt): string {\n if (attempt.isFailure) {\n return 'Failed'\n }\n\n if (attempt.inProgress) {\n return 'In progress'\n }\n\n return 'Delivered'\n }\n}\n"],"names":["Args","exitCodes","SanityCommand","subdebug","formatFailure","promptForProject","getHookAttempt","getProjectIdFlag","attemptDebug","AttemptHookCommand","args","attemptId","string","description","required","examples","command","flags","semantics","hiddenAliases","run","parse","projectId","getProjectId","fallback","requiredPermissions","grant","permission","attempt","error","err","message","exit","RUNTIME_ERROR","createdAt","failureReason","inProgress","resultBody","resultCode","log","getStatus","isFailure","body"],"mappings":"AAAA,SAAQA,IAAI,QAAO,cAAa;AAChC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAEnE,SAAQC,aAAa,QAAO,sCAAqC;AAEjE,SAAQC,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,cAAc,QAAO,0BAAyB;AACtD,SAAQC,gBAAgB,QAAO,4BAA2B;AAE1D,MAAMC,eAAeL,SAAS;AAE9B,OAAO,MAAMM,2BAA2BP;IACtC,OAAgBQ,OAAO;QACrBC,WAAWX,KAAKY,MAAM,CAAC;YACrBC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IACD,OAAgBD,cAAc,oDAAmD;IAEjF,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;KACD,CAAA;IAED,OAAgBI,QAAQ;QACtB,GAAGV,iBAAiB;YAClBM,aAAa;YACbK,WAAW;QACb,EAAE;IACJ,EAAC;IAED,OAAgBC,gBAA0B;QAAC;KAAe,CAAA;IAE1D,MAAaC,MAAM;QACjB,MAAM,EAACV,IAAI,EAAC,GAAG,MAAM,IAAI,CA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OAAO;IACT;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getSanityUrl, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
1
|
+
import { exitCodes, getSanityUrl, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
2
|
import open from 'open';
|
|
3
3
|
import { promptForProject } from '../../prompts/promptForProject.js';
|
|
4
4
|
import { getProjectById } from '../../services/projects.js';
|
|
@@ -43,7 +43,7 @@ export class CreateHookCommand extends SanityCommand {
|
|
|
43
43
|
const err = error;
|
|
44
44
|
createHookDebug(`Error fetching project info for project ${projectId}`, err);
|
|
45
45
|
this.error(`Failed to fetch project information:\n${err.message}`, {
|
|
46
|
-
exit:
|
|
46
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
const organizationId = projectInfo.organizationId || 'personal';
|
|
@@ -59,7 +59,7 @@ export class CreateHookCommand extends SanityCommand {
|
|
|
59
59
|
const err = error;
|
|
60
60
|
createHookDebug('Error opening browser', err);
|
|
61
61
|
this.error(`Failed to open browser:\n${err.message}`, {
|
|
62
|
-
exit:
|
|
62
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hooks/create.ts"],"sourcesContent":["import {getSanityUrl, SanityCommand, subdebug} from '@sanity/cli-core'\nimport open from 'open'\n\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {getProjectById} from '../../services/projects.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst createHookDebug = subdebug('hook:create')\n\nexport class CreateHookCommand extends SanityCommand<typeof CreateHookCommand> {\n static override description = 'Create a new webhook for the project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Create a new webhook for the project',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'Create a webhook for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to create webhook for',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:create']\n\n public async run() {\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({requiredPermissions: [{grant: 'read', permission: 'sanity.project'}]}),\n })\n\n let projectInfo: {organizationId?: string | null}\n try {\n projectInfo = await getProjectById(projectId)\n } catch (error) {\n const err = error as Error\n createHookDebug(`Error fetching project info for project ${projectId}`, err)\n this.error(`Failed to fetch project information:\\n${err.message}`, {exit:
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hooks/create.ts"],"sourcesContent":["import {exitCodes, getSanityUrl, SanityCommand, subdebug} from '@sanity/cli-core'\nimport open from 'open'\n\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {getProjectById} from '../../services/projects.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst createHookDebug = subdebug('hook:create')\n\nexport class CreateHookCommand extends SanityCommand<typeof CreateHookCommand> {\n static override description = 'Create a new webhook for the project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Create a new webhook for the project',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'Create a webhook for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to create webhook for',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:create']\n\n public async run() {\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({requiredPermissions: [{grant: 'read', permission: 'sanity.project'}]}),\n })\n\n let projectInfo: {organizationId?: string | null}\n try {\n projectInfo = await getProjectById(projectId)\n } catch (error) {\n const err = error as Error\n createHookDebug(`Error fetching project info for project ${projectId}`, err)\n this.error(`Failed to fetch project information:\\n${err.message}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n const organizationId = projectInfo.organizationId || 'personal'\n const manageUrl = getSanityUrl(\n `/organizations/${organizationId}/project/${projectId}/api/webhooks/new`,\n )\n\n if (this.isUnattended()) {\n this.log(`Create a webhook at ${manageUrl}`)\n return\n }\n\n this.log(`Opening ${manageUrl}`)\n\n try {\n await open(manageUrl)\n } catch (error) {\n const err = error as Error\n createHookDebug('Error opening browser', err)\n this.error(`Failed to open browser:\\n${err.message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["exitCodes","getSanityUrl","SanityCommand","subdebug","open","promptForProject","getProjectById","getProjectIdFlag","createHookDebug","CreateHookCommand","description","examples","command","flags","semantics","hiddenAliases","run","projectId","getProjectId","fallback","requiredPermissions","grant","permission","projectInfo","error","err","message","exit","RUNTIME_ERROR","organizationId","manageUrl","isUnattended","log"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,YAAY,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACjF,OAAOC,UAAU,OAAM;AAEvB,SAAQC,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,cAAc,QAAO,6BAA4B;AACzD,SAAQC,gBAAgB,QAAO,4BAA2B;AAE1D,MAAMC,kBAAkBL,SAAS;AAEjC,OAAO,MAAMM,0BAA0BP;IACrC,OAAgBQ,cAAc,uCAAsC;IACpE,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,OAAgBG,QAAQ;QACtB,GAAGN,iBAAiB;YAClBG,aAAa;YACbI,WAAW;QACb,EAAE;IACJ,EAAC;IAED,OAAgBC,gBAA0B;QAAC;KAAc,CAAA;IAEzD,MAAaC,MAAM;QACjB,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY,CAAC;YACxCC,UAAU,IACRd,iBAAiB;oBAACe,qBAAqB;wBAAC;4BAACC,OAAO;4BAAQC,YAAY;wBAAgB;qBAAE;gBAAA;QAC1F;QAEA,IAAIC;QACJ,IAAI;YACFA,cAAc,MAAMjB,eAAeW;QACrC,EAAE,OAAOO,OAAO;YACd,MAAMC,MAAMD;YACZhB,gBAAgB,CAAC,wCAAwC,EAAES,WAAW,EAAEQ;YACxE,IAAI,CAACD,KAAK,CAAC,CAAC,sCAAsC,EAAEC,IAAIC,OAAO,EAAE,EAAE;gBACjEC,MAAM3B,UAAU4B,aAAa;YAC/B;QACF;QAEA,MAAMC,iBAAiBN,YAAYM,cAAc,IAAI;QACrD,MAAMC,YAAY7B,aAChB,CAAC,eAAe,EAAE4B,eAAe,SAAS,EAAEZ,UAAU,iBAAiB,CAAC;QAG1E,IAAI,IAAI,CAACc,YAAY,IAAI;YACvB,IAAI,CAACC,GAAG,CAAC,CAAC,oBAAoB,EAAEF,WAAW;YAC3C;QACF;QAEA,IAAI,CAACE,GAAG,CAAC,CAAC,QAAQ,EAAEF,WAAW;QAE/B,IAAI;YACF,MAAM1B,KAAK0B;QACb,EAAE,OAAON,OAAO;YACd,MAAMC,MAAMD;YACZhB,gBAAgB,yBAAyBiB;YACzC,IAAI,CAACD,KAAK,CAAC,CAAC,yBAAyB,EAAEC,IAAIC,OAAO,EAAE,EAAE;gBAACC,MAAM3B,UAAU4B,aAAa;YAAA;QACtF;IACF;AACF"}
|
|
@@ -62,7 +62,7 @@ export class Delete extends SanityCommand {
|
|
|
62
62
|
const err = error;
|
|
63
63
|
deleteHookDebug(`Error deleting hook ${hookId} for project ${projectId}`, err);
|
|
64
64
|
this.error(`Hook deletion failed:\n${err.message}`, {
|
|
65
|
-
exit:
|
|
65
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -74,12 +74,12 @@ export class Delete extends SanityCommand {
|
|
|
74
74
|
const err = error;
|
|
75
75
|
deleteHookDebug(`Error fetching hooks for project ${projectId}`, err);
|
|
76
76
|
this.error(`Failed to fetch hooks:\n${err.message}`, {
|
|
77
|
-
exit:
|
|
77
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
if (hooks.length === 0) {
|
|
81
81
|
this.error('No hooks configured for this project.', {
|
|
82
|
-
exit:
|
|
82
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
// If hook name is specified, find it in the list
|
|
@@ -88,7 +88,7 @@ export class Delete extends SanityCommand {
|
|
|
88
88
|
const selectedHook = hooks.find((hook)=>hook.name.toLowerCase() === specifiedNameLower);
|
|
89
89
|
if (!selectedHook) {
|
|
90
90
|
this.error(`Hook with name "${specifiedName}" not found`, {
|
|
91
|
-
exit:
|
|
91
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
return selectedHook.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hooks/delete.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n\nimport {type Hook} from '../../actions/hook/types'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {deleteHookForProject, listHooksForProject} from '../../services/hooks.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst deleteHookDebug = subdebug('hook:delete')\n\nexport class Delete extends SanityCommand<typeof Delete> {\n static override args = {\n name: Args.string({\n description: 'Name of webhook to delete (will prompt if not provided)',\n required: false,\n }),\n }\n\n static override description = 'Delete a webhook from the project'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Interactively select and delete a webhook',\n },\n {\n command: '<%= config.bin %> <%= command.id %> my-hook',\n description: 'Delete a specific webhook by name',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'Delete a webhook from a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to delete webhook from',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:delete']\n\n public async run(): Promise<void> {\n const {args} = await this.parse(Delete)\n\n if (!args.name && this.isUnattended()) {\n this.error('Webhook name is required. Pass the name as an argument.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'delete', permission: 'sanity.project.webhooks'}],\n }),\n })\n\n // Get the hook ID to delete\n const hookId = await this.promptForHook(args.name, projectId)\n\n try {\n await deleteHookForProject(projectId, hookId)\n\n this.log('Hook deleted')\n } catch (error) {\n const err = error as Error\n deleteHookDebug(`Error deleting hook ${hookId} for project ${projectId}`, err)\n this.error(`Hook deletion failed:\\n${err.message}`, {exit:
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hooks/delete.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {select} from '@sanity/cli-core/ux'\n\nimport {type Hook} from '../../actions/hook/types'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {deleteHookForProject, listHooksForProject} from '../../services/hooks.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst deleteHookDebug = subdebug('hook:delete')\n\nexport class Delete extends SanityCommand<typeof Delete> {\n static override args = {\n name: Args.string({\n description: 'Name of webhook to delete (will prompt if not provided)',\n required: false,\n }),\n }\n\n static override description = 'Delete a webhook from the project'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Interactively select and delete a webhook',\n },\n {\n command: '<%= config.bin %> <%= command.id %> my-hook',\n description: 'Delete a specific webhook by name',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'Delete a webhook from a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to delete webhook from',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:delete']\n\n public async run(): Promise<void> {\n const {args} = await this.parse(Delete)\n\n if (!args.name && this.isUnattended()) {\n this.error('Webhook name is required. Pass the name as an argument.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'delete', permission: 'sanity.project.webhooks'}],\n }),\n })\n\n // Get the hook ID to delete\n const hookId = await this.promptForHook(args.name, projectId)\n\n try {\n await deleteHookForProject(projectId, hookId)\n\n this.log('Hook deleted')\n } catch (error) {\n const err = error as Error\n deleteHookDebug(`Error deleting hook ${hookId} for project ${projectId}`, err)\n this.error(`Hook deletion failed:\\n${err.message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n\n private async promptForHook(\n specifiedName: string | undefined,\n projectId: string,\n ): Promise<string> {\n let hooks: Hook[]\n try {\n hooks = await listHooksForProject(projectId)\n } catch (error) {\n const err = error as Error\n deleteHookDebug(`Error fetching hooks for project ${projectId}`, err)\n this.error(`Failed to fetch hooks:\\n${err.message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n if (hooks.length === 0) {\n this.error('No hooks configured for this project.', {exit: exitCodes.RUNTIME_ERROR})\n }\n\n // If hook name is specified, find it in the list\n if (specifiedName) {\n const specifiedNameLower = specifiedName.toLowerCase()\n const selectedHook = hooks.find((hook) => hook.name.toLowerCase() === specifiedNameLower)\n\n if (!selectedHook) {\n this.error(`Hook with name \"${specifiedName}\" not found`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n return selectedHook.id\n }\n\n // If no hook name specified, prompt user to select one\n const choices = hooks.map((hook) => ({\n name: hook.name,\n value: hook.id,\n }))\n\n const selectedId = await select({\n choices,\n message: 'Select hook to delete',\n })\n\n return selectedId\n }\n}\n"],"names":["Args","exitCodes","SanityCommand","subdebug","select","promptForProject","deleteHookForProject","listHooksForProject","getProjectIdFlag","deleteHookDebug","Delete","args","name","string","description","required","examples","command","flags","semantics","hiddenAliases","run","parse","isUnattended","error","exit","USAGE_ERROR","projectId","getProjectId","fallback","requiredPermissions","grant","permission","hookId","promptForHook","log","err","message","RUNTIME_ERROR","specifiedName","hooks","length","specifiedNameLower","toLowerCase","selectedHook","find","hook","id","choices","map","value","selectedId"],"mappings":"AAAA,SAAQA,IAAI,QAAO,cAAa;AAChC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,MAAM,QAAO,sBAAqB;AAG1C,SAAQC,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,oBAAoB,EAAEC,mBAAmB,QAAO,0BAAyB;AACjF,SAAQC,gBAAgB,QAAO,4BAA2B;AAE1D,MAAMC,kBAAkBN,SAAS;AAEjC,OAAO,MAAMO,eAAeR;IAC1B,OAAgBS,OAAO;QACrBC,MAAMZ,KAAKa,MAAM,CAAC;YAChBC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,oCAAmC;IAEjE,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;QACA;YACEG,SAAS;YACTH,aAAa;QACf;KACD,CAAA;IAED,OAAgBI,QAAQ;QACtB,GAAGV,iBAAiB;YAClBM,aAAa;YACbK,WAAW;QACb,EAAE;IACJ,EAAC;IAED,OAAgBC,gBAA0B;QAAC;KAAc,CAAA;IAEzD,MAAaC,MAAqB;QAChC,MAAM,EAACV,IAAI,EAAC,GAAG,MAAM,IAAI,CAACW,KAAK,CAACZ;QAEhC,IAAI,CAACC,KAAKC,IAAI,IAAI,IAAI,CAACW,YAAY,IAAI;YACrC,IAAI,CAACC,KAAK,CAAC,2DAA2D;gBACpEC,MAAMxB,UAAUyB,WAAW;YAC7B;QACF;QAEA,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY,CAAC;YACxCC,UAAU,IACRxB,iBAAiB;oBACfyB,qBAAqB;wBAAC;4BAACC,OAAO;4BAAUC,YAAY;wBAAyB;qBAAE;gBACjF;QACJ;QAEA,4BAA4B;QAC5B,MAAMC,SAAS,MAAM,IAAI,CAACC,aAAa,CAACvB,K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AOJ,KAAKC,EAAE;YAChB,CAAA;QAEA,MAAMI,aAAa,MAAM/C,OAAO;YAC9B4C;YACAX,SAAS;QACX;QAEA,OAAOc;IACT;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SanityCommand, subdebug } from '@sanity/cli-core';
|
|
1
|
+
import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
2
2
|
import { promptForProject } from '../../prompts/promptForProject.js';
|
|
3
3
|
import { listHooksForProject } from '../../services/hooks.js';
|
|
4
4
|
import { getProjectIdFlag } from '../../util/sharedFlags.js';
|
|
@@ -43,7 +43,7 @@ export class List extends SanityCommand {
|
|
|
43
43
|
const err = error;
|
|
44
44
|
listHookDebug(`Error fetching hooks for project ${projectId}`, err);
|
|
45
45
|
this.error(`Hook list retrieval failed:\n${err.message}`, {
|
|
46
|
-
exit:
|
|
46
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
for (const hook of hooks){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/hooks/list.ts"],"sourcesContent":["import {SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {type Hook} from '../../actions/hook/types'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {listHooksForProject} from '../../services/hooks.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst listHookDebug = subdebug('hook:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List webhooks for the project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List webhooks for the project',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'List webhooks for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to list webhooks for',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:list']\n\n public async run() {\n // Ensure we have project context\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'read', permission: 'sanity.project.webhooks'}],\n }),\n })\n\n let hooks: Hook[]\n try {\n hooks = await listHooksForProject(projectId)\n } catch (error) {\n const err = error as Error\n\n listHookDebug(`Error fetching hooks for project ${projectId}`, err)\n this.error(`Hook list retrieval failed:\\n${err.message}`, {exit:
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/hooks/list.ts"],"sourcesContent":["import {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {type Hook} from '../../actions/hook/types'\nimport {promptForProject} from '../../prompts/promptForProject.js'\nimport {listHooksForProject} from '../../services/hooks.js'\nimport {getProjectIdFlag} from '../../util/sharedFlags.js'\n\nconst listHookDebug = subdebug('hook:list')\n\nexport class List extends SanityCommand<typeof List> {\n static override description = 'List webhooks for the project'\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List webhooks for the project',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --project-id abc123',\n description: 'List webhooks for a specific project',\n },\n ]\n\n static override flags = {\n ...getProjectIdFlag({\n description: 'Project ID to list webhooks for',\n semantics: 'override',\n }),\n }\n\n static override hiddenAliases: string[] = ['hook:list']\n\n public async run() {\n // Ensure we have project context\n const projectId = await this.getProjectId({\n fallback: () =>\n promptForProject({\n requiredPermissions: [{grant: 'read', permission: 'sanity.project.webhooks'}],\n }),\n })\n\n let hooks: Hook[]\n try {\n hooks = await listHooksForProject(projectId)\n } catch (error) {\n const err = error as Error\n\n listHookDebug(`Error fetching hooks for project ${projectId}`, err)\n this.error(`Hook list retrieval failed:\\n${err.message}`, {exit: exitCodes.RUNTIME_ERROR})\n }\n\n for (const hook of hooks) {\n this.log(`Name: ${hook.name}`)\n this.log(`Dataset: ${hook.dataset}`)\n this.log(`URL: ${hook.url}`)\n\n if (hook.type === 'document') {\n this.log(`HTTP method: ${hook.httpMethod}`)\n\n if (hook.description) {\n this.log(`Description: ${hook.description}`)\n }\n }\n\n this.log('')\n }\n }\n}\n"],"names":["exitCodes","SanityCommand","subdebug","promptForProject","listHooksForProject","getProjectIdFlag","listHookDebug","List","description","examples","command","flags","semantics","hiddenAliases","run","projectId","getProjectId","fallback","requiredPermissions","grant","permission","hooks","error","err","message","exit","RUNTIME_ERROR","hook","log","name","dataset","url","type","httpMethod"],"mappings":"AAAA,SAAQA,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AAGnE,SAAQC,gBAAgB,QAAO,oCAAmC;AAClE,SAAQC,mBAAmB,QAAO,0BAAyB;AAC3D,SAAQC,gBAAgB,QAAO,4BAA2B;AAE1D,MAAMC,gBAAgBJ,SAAS;AAE/B,OAAO,MAAMK,aAAaN;IACxB,OAAgBO,cAAc,gCAA+B;IAC7D,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTF,aAAa;QACf;QACA;YACEE,SAAS;YACTF,aAAa;QACf;KACD,CAAA;IAED,OAAgBG,QAAQ;QACtB,GAAGN,iBAAiB;YAClBG,aAAa;YACbI,WAAW;QACb,EAAE;IACJ,EAAC;IAED,OAAgBC,gBAA0B;QAAC;KAAY,CAAA;IAEvD,MAAaC,MAAM;QACjB,iCAAiC;QACjC,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY,CAAC;YACxCC,UAAU,IACRd,iBAAiB;oBACfe,qBAAqB;wBAAC;4BAACC,OAAO;4BAAQC,YAAY;wBAAyB;qBAAE;gBAC/E;QACJ;QAEA,IAAIC;QACJ,IAAI;YACFA,QAAQ,MAAMjB,oBAAoBW;QACpC,EAAE,OAAOO,OAAO;YACd,MAAMC,MAAMD;YAEZhB,cAAc,CAAC,iCAAiC,EAAES,WAAW,EAAEQ;YAC/D,IAAI,CAACD,KAAK,CAAC,CAAC,6BAA6B,EAAEC,IAAIC,OAAO,EAAE,EAAE;gBAACC,MAAMzB,UAAU0B,aAAa;YAAA;QAC1F;QAEA,KAAK,MAAMC,QAAQN,MAAO;YACxB,IAAI,CAACO,GAAG,CAAC,CAAC,MAAM,EAAED,KA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