@sanity/cli 8.27.0 → 8.28.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/README.md +1515 -408
- package/dist/actions/context/commandTable.js +215 -0
- package/dist/actions/context/commandTable.js.map +1 -0
- package/dist/actions/context/contextCommand.js +246 -0
- package/dist/actions/context/contextCommand.js.map +1 -0
- package/dist/actions/context/contextSpec.js +18 -0
- package/dist/actions/context/contextSpec.js.map +1 -0
- package/dist/actions/context/distillContextOperations.js +335 -0
- package/dist/actions/context/distillContextOperations.js.map +1 -0
- package/dist/actions/context/mcpEndpoint.js.map +1 -1
- package/dist/actions/context/operationInput.js +226 -0
- package/dist/actions/context/operationInput.js.map +1 -0
- package/dist/actions/context/operationTypes.js +3 -0
- package/dist/actions/context/operationTypes.js.map +1 -0
- package/dist/actions/context/removedCommands.js +26 -0
- package/dist/actions/context/removedCommands.js.map +1 -0
- package/dist/actions/context/renderOperationResult.js +72 -0
- package/dist/actions/context/renderOperationResult.js.map +1 -0
- package/dist/actions/context/sourceFile.js +31 -0
- package/dist/actions/context/sourceFile.js.map +1 -0
- package/dist/actions/context/syncOutput.js +17 -0
- package/dist/actions/context/syncOutput.js.map +1 -0
- package/dist/actions/context/table.js +13 -0
- package/dist/actions/context/table.js.map +1 -0
- package/dist/actions/context/waitForJob.js.map +1 -1
- package/dist/actions/context/waitForSourceSync.js +48 -0
- package/dist/actions/context/waitForSourceSync.js.map +1 -0
- package/dist/actions/context/watchJob.js.map +1 -1
- package/dist/actions/context/watchSourceSync.js +40 -0
- package/dist/actions/context/watchSourceSync.js.map +1 -0
- package/dist/actions/dev/servers/startStudioDevServer.js +4 -1
- package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
- package/dist/commands/context/build.js +19 -81
- package/dist/commands/context/build.js.map +1 -1
- package/dist/commands/context/create.js +3 -90
- package/dist/commands/context/create.js.map +1 -1
- package/dist/commands/context/delete.js +3 -73
- package/dist/commands/context/delete.js.map +1 -1
- package/dist/commands/context/documents/content.js +117 -0
- package/dist/commands/context/documents/content.js.map +1 -0
- package/dist/commands/context/documents/delete.js +5 -0
- package/dist/commands/context/documents/delete.js.map +1 -0
- package/dist/commands/context/documents/edit.js +5 -0
- package/dist/commands/context/documents/edit.js.map +1 -0
- package/dist/commands/context/documents/get.js +5 -0
- package/dist/commands/context/documents/get.js.map +1 -0
- package/dist/commands/context/documents/list.js +5 -0
- package/dist/commands/context/documents/list.js.map +1 -0
- package/dist/commands/context/entries/list.js +2 -2
- package/dist/commands/context/entries/list.js.map +1 -1
- package/dist/commands/context/entries/rebuild.js +3 -93
- package/dist/commands/context/entries/rebuild.js.map +1 -1
- package/dist/commands/context/get.js +3 -88
- package/dist/commands/context/get.js.map +1 -1
- package/dist/commands/context/instructions/create.js +5 -0
- package/dist/commands/context/instructions/create.js.map +1 -0
- package/dist/commands/context/instructions/delete.js +5 -0
- package/dist/commands/context/instructions/delete.js.map +1 -0
- package/dist/commands/context/instructions/edit.js +5 -0
- package/dist/commands/context/instructions/edit.js.map +1 -0
- package/dist/commands/context/issues/apply.js +3 -84
- package/dist/commands/context/issues/apply.js.map +1 -1
- package/dist/commands/context/issues/dismiss.js +3 -50
- package/dist/commands/context/issues/dismiss.js.map +1 -1
- package/dist/commands/context/issues/reopen.js +3 -51
- package/dist/commands/context/issues/reopen.js.map +1 -1
- package/dist/commands/context/issues/resolve.js +23 -92
- package/dist/commands/context/issues/resolve.js.map +1 -1
- package/dist/commands/context/jobs/get.js +3 -88
- package/dist/commands/context/jobs/get.js.map +1 -1
- package/dist/commands/context/list.js +3 -95
- package/dist/commands/context/list.js.map +1 -1
- package/dist/commands/context/mcp/initial-context.js +5 -0
- package/dist/commands/context/mcp/initial-context.js.map +1 -0
- package/dist/commands/context/mcp/list.js +2 -2
- package/dist/commands/context/mcp/list.js.map +1 -1
- package/dist/commands/context/mcp/status.js.map +1 -1
- package/dist/commands/context/mcp/update.js.map +1 -1
- package/dist/commands/context/sources/create.js +175 -0
- package/dist/commands/context/sources/create.js.map +1 -0
- package/dist/commands/context/sources/delete.js +5 -0
- package/dist/commands/context/sources/delete.js.map +1 -0
- package/dist/commands/context/sources/edit.js +29 -0
- package/dist/commands/context/sources/edit.js.map +1 -0
- package/dist/commands/context/sources/get.js +5 -0
- package/dist/commands/context/sources/get.js.map +1 -0
- package/dist/commands/context/sources/list.js +5 -0
- package/dist/commands/context/sources/list.js.map +1 -0
- package/dist/commands/context/sources/sync.js +5 -0
- package/dist/commands/context/sources/sync.js.map +1 -0
- package/dist/commands/context/sources/syncs/confirm.js +5 -0
- package/dist/commands/context/sources/syncs/confirm.js.map +1 -0
- package/dist/commands/context/sources/syncs/discard.js +5 -0
- package/dist/commands/context/sources/syncs/discard.js.map +1 -0
- package/dist/commands/context/sources/syncs/get.js +5 -0
- package/dist/commands/context/sources/syncs/get.js.map +1 -0
- package/dist/commands/context/sources/syncs/list.js +5 -0
- package/dist/commands/context/sources/syncs/list.js.map +1 -0
- package/dist/commands/context/sources/upload.js +63 -0
- package/dist/commands/context/sources/upload.js.map +1 -0
- package/dist/commands/context/sync.js +5 -0
- package/dist/commands/context/sync.js.map +1 -0
- package/dist/commands/context/update.js +3 -136
- package/dist/commands/context/update.js.map +1 -1
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +41 -26
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
- package/dist/generated/apiRoutes.js +28 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/generated/contextOperations.js +1116 -0
- package/dist/generated/contextOperations.js.map +1 -0
- package/dist/hooks/commandNotFound/topicAliases.js +8 -2
- package/dist/hooks/commandNotFound/topicAliases.js.map +1 -1
- package/dist/services/context.js +241 -268
- package/dist/services/context.js.map +1 -1
- package/dist/util/telemetry/cliCommandIdentity.js +10 -18
- package/dist/util/telemetry/cliCommandIdentity.js.map +1 -1
- package/oclif.manifest.json +3380 -1910
- package/package.json +24 -23
- package/templates/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/app-quickstart/AGENTS.md +49 -0
- package/templates/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/app-sanity-ui/AGENTS.md +49 -0
- package/templates/shared/dashboard/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/shared/dashboard/app-quickstart/AGENTS.md +49 -0
- package/templates/shared/dashboard/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +49 -0
- package/dist/commands/context/imports/create.js +0 -270
- package/dist/commands/context/imports/create.js.map +0 -1
- package/dist/commands/context/imports/delete.js +0 -73
- package/dist/commands/context/imports/delete.js.map +0 -1
- package/dist/commands/context/imports/download.js +0 -60
- package/dist/commands/context/imports/download.js.map +0 -1
- package/dist/commands/context/imports/get.js +0 -88
- package/dist/commands/context/imports/get.js.map +0 -1
- package/dist/commands/context/imports/list.js +0 -100
- package/dist/commands/context/imports/list.js.map +0 -1
- package/dist/commands/context/refresh.js +0 -46
- package/dist/commands/context/refresh.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/edit.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const UpdateDocumentCommand = contextCommand('context documents edit')\n"],"names":["contextCommand","UpdateDocumentCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,wBAAwBD,eAAe,0BAAyB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const GetDocumentCommand = contextCommand('context documents get');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/get.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const GetDocumentCommand = contextCommand('context documents get')\n"],"names":["contextCommand","GetDocumentCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,qBAAqBD,eAAe,yBAAwB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const ListDocumentsCommand = contextCommand('context documents list');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/list.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const ListDocumentsCommand = contextCommand('context documents list')\n"],"names":["contextCommand","ListDocumentsCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,uBAAuBD,eAAe,0BAAyB"}
|
|
@@ -2,8 +2,8 @@ import { Args } from '@oclif/core';
|
|
|
2
2
|
import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
3
|
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
4
4
|
import { isHttpError } from '@sanity/client';
|
|
5
|
+
import { contextTable } from '../../../actions/context/table.js';
|
|
5
6
|
import { listEntries } from '../../../services/context.js';
|
|
6
|
-
import { Table } from '../../../util/responsiveTable.js';
|
|
7
7
|
const listEntriesDebug = subdebug('context:entries:list');
|
|
8
8
|
export class ListEntriesCommand extends SanityCommand {
|
|
9
9
|
static args = {
|
|
@@ -49,7 +49,7 @@ export class ListEntriesCommand extends SanityCommand {
|
|
|
49
49
|
this.log('No entries found');
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const table =
|
|
52
|
+
const table = contextTable({
|
|
53
53
|
columns: [
|
|
54
54
|
{
|
|
55
55
|
alignment: 'left',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/entries/list.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {isHttpError} from '@sanity/client'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/entries/list.ts"],"sourcesContent":["import {Args} from '@oclif/core'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {isHttpError} from '@sanity/client'\n\nimport {contextTable} from '../../../actions/context/table.js'\nimport {listEntries} from '../../../services/context.js'\n\nconst listEntriesDebug = subdebug('context:entries:list')\n\nexport class ListEntriesCommand extends SanityCommand<typeof ListEntriesCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n }\n\n static override description = 'List the entries a knowledge base build produced'\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123',\n description: 'List all entries for a knowledge base',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --json',\n description: 'Output entries as JSON',\n },\n ]\n\n public async run(): Promise<void> {\n const {knowledgeBaseId} = this.args\n const {json} = this.flags\n\n let entries\n try {\n entries = await listEntries(knowledgeBaseId)\n } catch (error) {\n listEntriesDebug('Error listing entries', error)\n if (isHttpError(error) && error.statusCode === 404) {\n this.error(`Knowledge base \"${knowledgeBaseId}\" not found`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n this.error(`Failed to list entries: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (json) {\n this.logJson(entries)\n return\n }\n\n if (entries.length === 0) {\n this.log('No entries found')\n return\n }\n\n const table = contextTable({\n columns: [\n {alignment: 'left', name: 'path', title: 'Path'},\n {alignment: 'left', name: 'title', title: 'Title'},\n {alignment: 'left', name: 'status', title: 'Status'},\n ],\n })\n\n for (const {path, status, title} of entries) {\n table.addRow({path, status, title})\n }\n\n this.log(table.render())\n }\n}\n"],"names":["Args","exitCodes","SanityCommand","subdebug","getErrorMessage","isHttpError","contextTable","listEntries","listEntriesDebug","ListEntriesCommand","args","knowledgeBaseId","string","description","required","enableJsonFlag","examples","command","run","json","flags","entries","error","statusCode","exit","RUNTIME_ERROR","logJson","length","log","table","columns","alignment","name","title","path","status","addRow","render"],"mappings":"AAAA,SAAQA,IAAI,QAAO,cAAa;AAChC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,WAAW,QAAO,iBAAgB;AAE1C,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,WAAW,QAAO,+BAA8B;AAExD,MAAMC,mBAAmBL,SAAS;AAElC,OAAO,MAAMM,2BAA2BP;IACtC,OAAgBQ,OAAO;QACrBC,iBAAiBX,KAAKY,MAAM,CAAC;YAC3BC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,mDAAkD;IAEhF,OAAgBE,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,MAAaK,MAAqB;QAChC,MAAM,EAACP,eAAe,EAAC,GAAG,IAAI,CAACD,IAAI;QACnC,MAAM,EAACS,IAAI,EAAC,GAAG,IAAI,CAACC,KAAK;QAEzB,IAAIC;QACJ,IAAI;YACFA,UAAU,MAAMd,YAAYI;QAC9B,EAAE,OAAOW,OAAO;YACdd,iBAAiB,yBAAyBc;YAC1C,IAAIjB,YAAYiB,UAAUA,MAAMC,UAAU,KAAK,KAAK;gBAClD,IAAI,CAACD,KAAK,CAAC,CAAC,gBAAgB,EAAEX,gBAAgB,WAAW,CAAC,EAAE;oBAC1Da,MAAMvB,UAAUwB,aAAa;gBAC/B;YACF;YACA,IAAI,CAACH,KAAK,CAAC,CAAC,wBAAwB,EAAElB,gBAAgBkB,QAAQ,EAAE;gBAC9DE,MAAMvB,UAAUwB,aAAa;YAC/B;QACF;QAEA,IAAIN,MAAM;YACR,IAAI,CAACO,OAAO,CAACL;YACb;QACF;QAEA,IAAIA,QAAQM,MAAM,KAAK,GAAG;YACxB,IAAI,CAACC,GAAG,CAAC;YACT;QACF;QAEA,MAAMC,QAAQvB,aAAa;YACzBwB,SAAS;gBACP;oBAACC,WAAW;oBAAQC,MAAM;oBAAQC,OAAO;gBAAM;gBAC/C;oBAACF,WAAW;oBAAQC,MAAM;oBAASC,OAAO;gBAAO;gBACjD;oBAACF,WAAW;oBAAQC,MAAM;oBAAUC,OAAO;gBAAQ;aACpD;QACH;QAEA,KAAK,MAAM,EAACC,IAAI,EAAEC,MAAM,EAAEF,KAAK,EAAC,IAAIZ,QAAS;YAC3CQ,MAAMO,MAAM,CAAC;gBAACF;gBAAMC;gBAAQF;YAAK;QACnC;QAEA,IAAI,CAACL,GAAG,CAACC,MAAMQ,MAAM;IACvB;AACF"}
|
|
@@ -1,95 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { spinner } from '@sanity/cli-core/ux';
|
|
5
|
-
import { isHttpError } from '@sanity/client';
|
|
6
|
-
import { formatJobFailure, watchJob } from '../../../actions/context/watchJob.js';
|
|
7
|
-
import { formatKeyValue } from '../../../actions/debug/output.js';
|
|
8
|
-
import { rebuildEntry } from '../../../services/context.js';
|
|
9
|
-
const rebuildEntryDebug = subdebug('context:entries:rebuild');
|
|
10
|
-
export class RebuildEntryCommand extends SanityCommand {
|
|
11
|
-
static args = {
|
|
12
|
-
knowledgeBaseId: Args.string({
|
|
13
|
-
description: 'Knowledge base ID',
|
|
14
|
-
required: true
|
|
15
|
-
}),
|
|
16
|
-
path: Args.string({
|
|
17
|
-
description: 'Entry path, as listed by `sanity context entries list`',
|
|
18
|
-
required: true
|
|
19
|
-
})
|
|
20
|
-
};
|
|
21
|
-
static description = 'Rebuild one entry from its sources';
|
|
22
|
-
static examples = [
|
|
23
|
-
{
|
|
24
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 billing/refunds',
|
|
25
|
-
description: 'Start a rebuild and return the job ID'
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 billing/refunds --watch',
|
|
29
|
-
description: 'Rebuild an entry and wait for it to finish (non-zero exit on failure)'
|
|
30
|
-
}
|
|
31
|
-
];
|
|
32
|
-
static flags = {
|
|
33
|
-
watch: Flags.boolean({
|
|
34
|
-
default: false,
|
|
35
|
-
description: 'Wait for the rebuild to finish, exiting non-zero if it fails'
|
|
36
|
-
})
|
|
37
|
-
};
|
|
38
|
-
async run() {
|
|
39
|
-
const { knowledgeBaseId, path } = this.args;
|
|
40
|
-
const { watch } = this.flags;
|
|
41
|
-
let accepted;
|
|
42
|
-
const spin = spinner('Starting rebuild').start();
|
|
43
|
-
try {
|
|
44
|
-
accepted = await rebuildEntry(knowledgeBaseId, path);
|
|
45
|
-
spin.succeed('Rebuild started');
|
|
46
|
-
} catch (error) {
|
|
47
|
-
spin.fail();
|
|
48
|
-
rebuildEntryDebug('Error starting rebuild', error);
|
|
49
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
50
|
-
this.error(`Entry "${path}" not found on knowledge base "${knowledgeBaseId}"`, {
|
|
51
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
this.error(`Failed to start rebuild: ${getErrorMessage(error)}`, {
|
|
55
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const { affectedEntries, jobId } = accepted;
|
|
59
|
-
const padTo = 19 // "Shares sources with" is the longest key
|
|
60
|
-
;
|
|
61
|
-
this.log(formatKeyValue('Job ID', jobId, {
|
|
62
|
-
padTo
|
|
63
|
-
}));
|
|
64
|
-
// Other entries citing the same sources can change when they are next rebuilt
|
|
65
|
-
if (affectedEntries.length > 0) {
|
|
66
|
-
const paths = affectedEntries.map((entry)=>entry.path).join(', ');
|
|
67
|
-
this.log(formatKeyValue('Shares sources with', paths, {
|
|
68
|
-
padTo
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
71
|
-
this.log(`Track it with: sanity context jobs get ${knowledgeBaseId} ${jobId}`);
|
|
72
|
-
if (!watch) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
let job;
|
|
76
|
-
try {
|
|
77
|
-
job = await watchJob(knowledgeBaseId, jobId, {
|
|
78
|
-
label: 'Rebuilding entry',
|
|
79
|
-
successText: 'Entry rebuilt'
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
rebuildEntryDebug('Error watching rebuild job', error);
|
|
83
|
-
this.error(`Failed to watch rebuild job: ${getErrorMessage(error)}`, {
|
|
84
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (job.status !== 'succeeded') {
|
|
88
|
-
this.error(formatJobFailure('Rebuild', job), {
|
|
89
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const RebuildEntryCommand = contextCommand('context entries rebuild');
|
|
94
4
|
|
|
95
5
|
//# sourceMappingURL=rebuild.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/entries/rebuild.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/entries/rebuild.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const RebuildEntryCommand = contextCommand('context entries rebuild')\n"],"names":["contextCommand","RebuildEntryCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,sBAAsBD,eAAe,2BAA0B"}
|
|
@@ -1,90 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { isHttpError } from '@sanity/client';
|
|
5
|
-
import { formatKeyValue } from '../../actions/debug/output.js';
|
|
6
|
-
import { getKnowledgeBase } from '../../services/context.js';
|
|
7
|
-
const getContextDebug = subdebug('context:get');
|
|
8
|
-
export class GetKnowledgeBaseCommand extends SanityCommand {
|
|
9
|
-
static args = {
|
|
10
|
-
knowledgeBaseId: Args.string({
|
|
11
|
-
description: 'Knowledge base ID',
|
|
12
|
-
required: true
|
|
13
|
-
})
|
|
14
|
-
};
|
|
15
|
-
static description = 'Get details of a knowledge base';
|
|
16
|
-
static enableJsonFlag = true;
|
|
17
|
-
static examples = [
|
|
18
|
-
{
|
|
19
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123',
|
|
20
|
-
description: 'Get details of a specific knowledge base'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 --json',
|
|
24
|
-
description: 'Output the knowledge base as JSON'
|
|
25
|
-
}
|
|
26
|
-
];
|
|
27
|
-
async run() {
|
|
28
|
-
const { knowledgeBaseId } = this.args;
|
|
29
|
-
const { json } = this.flags;
|
|
30
|
-
let knowledgeBase;
|
|
31
|
-
try {
|
|
32
|
-
knowledgeBase = await getKnowledgeBase(knowledgeBaseId);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
getContextDebug('Error getting knowledge base', error);
|
|
35
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
36
|
-
this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
|
|
37
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
this.error(`Failed to get knowledge base: ${getErrorMessage(error)}`, {
|
|
41
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (json) {
|
|
45
|
-
this.logJson(knowledgeBase);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const pending = knowledgeBase.pendingChanges;
|
|
49
|
-
const padTo = 15 // "Pending changes" is the longest key
|
|
50
|
-
;
|
|
51
|
-
this.log(formatKeyValue('ID', knowledgeBase.publicId, {
|
|
52
|
-
padTo
|
|
53
|
-
}));
|
|
54
|
-
this.log(formatKeyValue('Title', knowledgeBase.title, {
|
|
55
|
-
padTo
|
|
56
|
-
}));
|
|
57
|
-
this.log(formatKeyValue('Description', knowledgeBase.description, {
|
|
58
|
-
padTo
|
|
59
|
-
}));
|
|
60
|
-
this.log(formatKeyValue('Organization', knowledgeBase.organizationId, {
|
|
61
|
-
padTo
|
|
62
|
-
}));
|
|
63
|
-
this.log(formatKeyValue('State', knowledgeBase.state, {
|
|
64
|
-
padTo
|
|
65
|
-
}));
|
|
66
|
-
this.log(formatKeyValue('Active job', knowledgeBase.activeJobId ?? '-', {
|
|
67
|
-
padTo
|
|
68
|
-
}));
|
|
69
|
-
this.log(formatKeyValue('Pending changes', pending ? `${pending.added} added, ${pending.changed} changed, ${pending.removed} removed` : '-', {
|
|
70
|
-
padTo
|
|
71
|
-
}));
|
|
72
|
-
this.log(formatKeyValue('Refresh', knowledgeBase.refreshEnabled ? `enabled (${knowledgeBase.refreshFrequency})` : 'disabled', {
|
|
73
|
-
padTo
|
|
74
|
-
}));
|
|
75
|
-
this.log(formatKeyValue('Open issues', knowledgeBase.openIssueCount, {
|
|
76
|
-
padTo
|
|
77
|
-
}));
|
|
78
|
-
this.log(formatKeyValue('Instructions', knowledgeBase.instructionCount, {
|
|
79
|
-
padTo
|
|
80
|
-
}));
|
|
81
|
-
this.log(formatKeyValue('Created', knowledgeBase.createdAt, {
|
|
82
|
-
padTo
|
|
83
|
-
}));
|
|
84
|
-
this.log(formatKeyValue('Updated', knowledgeBase.updatedAt, {
|
|
85
|
-
padTo
|
|
86
|
-
}));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../actions/context/contextCommand.js';
|
|
3
|
+
export const GetKnowledgeBaseCommand = contextCommand('context get');
|
|
89
4
|
|
|
90
5
|
//# sourceMappingURL=get.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/context/get.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/context/get.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../actions/context/contextCommand.js'\n\nexport const GetKnowledgeBaseCommand = contextCommand('context get')\n"],"names":["contextCommand","GetKnowledgeBaseCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,0CAAyC;AAEtE,OAAO,MAAMC,0BAA0BD,eAAe,eAAc"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const CreateInstructionCommand = contextCommand('context instructions create');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/instructions/create.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const CreateInstructionCommand = contextCommand('context instructions create')\n"],"names":["contextCommand","CreateInstructionCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,2BAA2BD,eAAe,+BAA8B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const DeleteInstructionCommand = contextCommand('context instructions delete');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/instructions/delete.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const DeleteInstructionCommand = contextCommand('context instructions delete')\n"],"names":["contextCommand","DeleteInstructionCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,2BAA2BD,eAAe,+BAA8B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const UpdateInstructionCommand = contextCommand('context instructions edit');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/instructions/edit.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const UpdateInstructionCommand = contextCommand('context instructions edit')\n"],"names":["contextCommand","UpdateInstructionCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,2BAA2BD,eAAe,6BAA4B"}
|
|
@@ -1,86 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { spinner } from '@sanity/cli-core/ux';
|
|
5
|
-
import { isHttpError } from '@sanity/client';
|
|
6
|
-
import { formatJobFailure, watchJob } from '../../../actions/context/watchJob.js';
|
|
7
|
-
import { formatKeyValue } from '../../../actions/debug/output.js';
|
|
8
|
-
import { applyIssues } from '../../../services/context.js';
|
|
9
|
-
const applyIssuesDebug = subdebug('context:issues:apply');
|
|
10
|
-
export class ApplyIssuesCommand extends SanityCommand {
|
|
11
|
-
static args = {
|
|
12
|
-
knowledgeBaseId: Args.string({
|
|
13
|
-
description: 'Knowledge base ID',
|
|
14
|
-
required: true
|
|
15
|
-
}),
|
|
16
|
-
// eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first
|
|
17
|
-
issueId: Args.string({
|
|
18
|
-
description: "ID of an issue to accept and apply (pass several to apply them in one batch). Conflicts can't be applied; resolve them with `sanity context issues resolve`",
|
|
19
|
-
multiple: true,
|
|
20
|
-
required: true
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
static description = 'Accept and apply issues to a knowledge base';
|
|
24
|
-
static examples = [
|
|
25
|
-
{
|
|
26
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456 issue.ghi789',
|
|
27
|
-
description: 'Accept and apply two issues in one batch'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456 --watch',
|
|
31
|
-
description: 'Apply an issue and wait for it to finish (non-zero exit on failure)'
|
|
32
|
-
}
|
|
33
|
-
];
|
|
34
|
-
static flags = {
|
|
35
|
-
watch: Flags.boolean({
|
|
36
|
-
default: false,
|
|
37
|
-
description: 'Wait for the apply to finish, exiting non-zero if it fails'
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
async run() {
|
|
41
|
-
const { issueId: issueIds, knowledgeBaseId } = this.args;
|
|
42
|
-
const { watch } = this.flags;
|
|
43
|
-
let jobId;
|
|
44
|
-
const spin = spinner('Starting apply').start();
|
|
45
|
-
try {
|
|
46
|
-
const accepted = await applyIssues(knowledgeBaseId, issueIds);
|
|
47
|
-
jobId = accepted.jobId;
|
|
48
|
-
spin.succeed('Apply started');
|
|
49
|
-
} catch (error) {
|
|
50
|
-
spin.fail();
|
|
51
|
-
applyIssuesDebug('Error applying issues', error);
|
|
52
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
53
|
-
this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
|
|
54
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
this.error(`Failed to apply issues: ${getErrorMessage(error)}`, {
|
|
58
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
this.log(formatKeyValue('Job ID', jobId));
|
|
62
|
-
this.log(`Track it with: sanity context jobs get ${knowledgeBaseId} ${jobId}`);
|
|
63
|
-
if (!watch) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
let job;
|
|
67
|
-
try {
|
|
68
|
-
job = await watchJob(knowledgeBaseId, jobId, {
|
|
69
|
-
label: 'Applying issues',
|
|
70
|
-
successText: 'Issues applied'
|
|
71
|
-
});
|
|
72
|
-
} catch (error) {
|
|
73
|
-
applyIssuesDebug('Error watching apply job', error);
|
|
74
|
-
this.error(`Failed to watch apply job: ${getErrorMessage(error)}`, {
|
|
75
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (job.status !== 'succeeded') {
|
|
79
|
-
this.error(formatJobFailure('Apply', job), {
|
|
80
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const ApplyIssuesCommand = contextCommand('context issues apply');
|
|
85
4
|
|
|
86
5
|
//# sourceMappingURL=apply.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/issues/apply.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/issues/apply.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const ApplyIssuesCommand = contextCommand('context issues apply')\n"],"names":["contextCommand","ApplyIssuesCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,qBAAqBD,eAAe,wBAAuB"}
|
|
@@ -1,52 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { isHttpError } from '@sanity/client';
|
|
5
|
-
import { dismissIssue } from '../../../services/context.js';
|
|
6
|
-
const dismissIssueDebug = subdebug('context:issues:dismiss');
|
|
7
|
-
export class DismissIssueCommand extends SanityCommand {
|
|
8
|
-
static args = {
|
|
9
|
-
knowledgeBaseId: Args.string({
|
|
10
|
-
description: 'Knowledge base ID',
|
|
11
|
-
required: true
|
|
12
|
-
}),
|
|
13
|
-
// eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first
|
|
14
|
-
issueId: Args.string({
|
|
15
|
-
description: 'Issue ID',
|
|
16
|
-
required: true
|
|
17
|
-
})
|
|
18
|
-
};
|
|
19
|
-
static description = "Dismiss an issue\n\nDismissing is permanent: dismissed issues can't be reopened.";
|
|
20
|
-
static examples = [
|
|
21
|
-
{
|
|
22
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456',
|
|
23
|
-
description: 'Dismiss an issue'
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
async run() {
|
|
27
|
-
const { issueId, knowledgeBaseId } = this.args;
|
|
28
|
-
let dismissed;
|
|
29
|
-
try {
|
|
30
|
-
dismissed = await dismissIssue(knowledgeBaseId, issueId);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
dismissIssueDebug('Error dismissing issue', error);
|
|
33
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
34
|
-
this.error(`Issue "${issueId}" not found on knowledge base "${knowledgeBaseId}"`, {
|
|
35
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
this.error(`Failed to dismiss issue: ${getErrorMessage(error)}`, {
|
|
39
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
// The API returns the issue unchanged when it already left triage
|
|
43
|
-
if (dismissed.status !== 'rejected') {
|
|
44
|
-
this.error(`Issue "${issueId}" is accepted (resolved or applied) and cannot be dismissed`, {
|
|
45
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
this.log('Issue dismissed');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const DismissIssueCommand = contextCommand('context issues dismiss');
|
|
51
4
|
|
|
52
5
|
//# sourceMappingURL=dismiss.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/issues/dismiss.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/issues/dismiss.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const DismissIssueCommand = contextCommand('context issues dismiss')\n"],"names":["contextCommand","DismissIssueCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,sBAAsBD,eAAe,0BAAyB"}
|
|
@@ -1,53 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { isHttpError } from '@sanity/client';
|
|
5
|
-
import { reopenIssue } from '../../../services/context.js';
|
|
6
|
-
const reopenIssueDebug = subdebug('context:issues:reopen');
|
|
7
|
-
export class ReopenIssueCommand extends SanityCommand {
|
|
8
|
-
static args = {
|
|
9
|
-
knowledgeBaseId: Args.string({
|
|
10
|
-
description: 'Knowledge base ID',
|
|
11
|
-
required: true
|
|
12
|
-
}),
|
|
13
|
-
// eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first
|
|
14
|
-
issueId: Args.string({
|
|
15
|
-
description: 'Issue ID',
|
|
16
|
-
required: true
|
|
17
|
-
})
|
|
18
|
-
};
|
|
19
|
-
static description = 'Reopen a resolved conflict issue';
|
|
20
|
-
static examples = [
|
|
21
|
-
{
|
|
22
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456',
|
|
23
|
-
description: 'Return a resolved conflict issue to triage'
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
async run() {
|
|
27
|
-
const { issueId, knowledgeBaseId } = this.args;
|
|
28
|
-
let reopened;
|
|
29
|
-
try {
|
|
30
|
-
reopened = await reopenIssue(knowledgeBaseId, issueId);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
reopenIssueDebug('Error reopening issue', error);
|
|
33
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
34
|
-
this.error(`Issue "${issueId}" not found on knowledge base "${knowledgeBaseId}"`, {
|
|
35
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
this.error(`Failed to reopen issue: ${getErrorMessage(error)}`, {
|
|
39
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
// The API returns the issue unchanged when it cannot be reopened
|
|
43
|
-
if (reopened.status !== 'open') {
|
|
44
|
-
const status = reopened.status === 'rejected' ? 'rejected (dismissed)' : 'accepted (resolved or applied)';
|
|
45
|
-
this.error(`Issue "${issueId}" is ${status} and cannot be reopened.\nOnly resolved conflict issues can be reopened.`, {
|
|
46
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
this.log('Issue reopened');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const ReopenIssueCommand = contextCommand('context issues reopen');
|
|
52
4
|
|
|
53
5
|
//# sourceMappingURL=reopen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/commands/context/issues/reopen.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/issues/reopen.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const ReopenIssueCommand = contextCommand('context issues reopen')\n"],"names":["contextCommand","ReopenIssueCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,qBAAqBD,eAAe,yBAAwB"}
|