@sanity/cli 8.26.0 → 8.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +1534 -411
  2. package/dist/actions/context/commandTable.js +215 -0
  3. package/dist/actions/context/commandTable.js.map +1 -0
  4. package/dist/actions/context/contextCommand.js +246 -0
  5. package/dist/actions/context/contextCommand.js.map +1 -0
  6. package/dist/actions/context/contextSpec.js +18 -0
  7. package/dist/actions/context/contextSpec.js.map +1 -0
  8. package/dist/actions/context/distillContextOperations.js +335 -0
  9. package/dist/actions/context/distillContextOperations.js.map +1 -0
  10. package/dist/actions/context/mcpEndpoint.js +165 -0
  11. package/dist/actions/context/mcpEndpoint.js.map +1 -0
  12. package/dist/actions/context/operationInput.js +226 -0
  13. package/dist/actions/context/operationInput.js.map +1 -0
  14. package/dist/actions/context/operationTypes.js +3 -0
  15. package/dist/actions/context/operationTypes.js.map +1 -0
  16. package/dist/actions/context/removedCommands.js +26 -0
  17. package/dist/actions/context/removedCommands.js.map +1 -0
  18. package/dist/actions/context/renderOperationResult.js +72 -0
  19. package/dist/actions/context/renderOperationResult.js.map +1 -0
  20. package/dist/actions/context/resolveOrganizationId.js +8 -1
  21. package/dist/actions/context/resolveOrganizationId.js.map +1 -1
  22. package/dist/actions/context/sourceFile.js +31 -0
  23. package/dist/actions/context/sourceFile.js.map +1 -0
  24. package/dist/actions/context/syncOutput.js +17 -0
  25. package/dist/actions/context/syncOutput.js.map +1 -0
  26. package/dist/actions/context/table.js +13 -0
  27. package/dist/actions/context/table.js.map +1 -0
  28. package/dist/actions/context/waitForJob.js.map +1 -1
  29. package/dist/actions/context/waitForSourceSync.js +48 -0
  30. package/dist/actions/context/waitForSourceSync.js.map +1 -0
  31. package/dist/actions/context/watchJob.js.map +1 -1
  32. package/dist/actions/context/watchSourceSync.js +40 -0
  33. package/dist/actions/context/watchSourceSync.js.map +1 -0
  34. package/dist/commands/context/build.js +19 -81
  35. package/dist/commands/context/build.js.map +1 -1
  36. package/dist/commands/context/create.js +3 -104
  37. package/dist/commands/context/create.js.map +1 -1
  38. package/dist/commands/context/delete.js +3 -73
  39. package/dist/commands/context/delete.js.map +1 -1
  40. package/dist/commands/context/documents/content.js +117 -0
  41. package/dist/commands/context/documents/content.js.map +1 -0
  42. package/dist/commands/context/documents/delete.js +5 -0
  43. package/dist/commands/context/documents/delete.js.map +1 -0
  44. package/dist/commands/context/documents/edit.js +5 -0
  45. package/dist/commands/context/documents/edit.js.map +1 -0
  46. package/dist/commands/context/documents/get.js +5 -0
  47. package/dist/commands/context/documents/get.js.map +1 -0
  48. package/dist/commands/context/documents/list.js +5 -0
  49. package/dist/commands/context/documents/list.js.map +1 -0
  50. package/dist/commands/context/entries/list.js +2 -2
  51. package/dist/commands/context/entries/list.js.map +1 -1
  52. package/dist/commands/context/entries/rebuild.js +3 -93
  53. package/dist/commands/context/entries/rebuild.js.map +1 -1
  54. package/dist/commands/context/get.js +3 -88
  55. package/dist/commands/context/get.js.map +1 -1
  56. package/dist/commands/context/instructions/create.js +5 -0
  57. package/dist/commands/context/instructions/create.js.map +1 -0
  58. package/dist/commands/context/instructions/delete.js +5 -0
  59. package/dist/commands/context/instructions/delete.js.map +1 -0
  60. package/dist/commands/context/instructions/edit.js +5 -0
  61. package/dist/commands/context/instructions/edit.js.map +1 -0
  62. package/dist/commands/context/issues/apply.js +3 -84
  63. package/dist/commands/context/issues/apply.js.map +1 -1
  64. package/dist/commands/context/issues/dismiss.js +3 -50
  65. package/dist/commands/context/issues/dismiss.js.map +1 -1
  66. package/dist/commands/context/issues/list.js +0 -5
  67. package/dist/commands/context/issues/list.js.map +1 -1
  68. package/dist/commands/context/issues/reopen.js +3 -51
  69. package/dist/commands/context/issues/reopen.js.map +1 -1
  70. package/dist/commands/context/issues/resolve.js +23 -92
  71. package/dist/commands/context/issues/resolve.js.map +1 -1
  72. package/dist/commands/context/jobs/get.js +3 -88
  73. package/dist/commands/context/jobs/get.js.map +1 -1
  74. package/dist/commands/context/list.js +3 -103
  75. package/dist/commands/context/list.js.map +1 -1
  76. package/dist/commands/context/mcp/create.js +152 -0
  77. package/dist/commands/context/mcp/create.js.map +1 -0
  78. package/dist/commands/context/mcp/delete.js +82 -0
  79. package/dist/commands/context/mcp/delete.js.map +1 -0
  80. package/dist/commands/context/mcp/get.js +42 -0
  81. package/dist/commands/context/mcp/get.js.map +1 -0
  82. package/dist/commands/context/mcp/initial-context.js +5 -0
  83. package/dist/commands/context/mcp/initial-context.js.map +1 -0
  84. package/dist/commands/context/mcp/list.js +87 -0
  85. package/dist/commands/context/mcp/list.js.map +1 -0
  86. package/dist/commands/context/mcp/status.js +98 -0
  87. package/dist/commands/context/mcp/status.js.map +1 -0
  88. package/dist/commands/context/mcp/update.js +225 -0
  89. package/dist/commands/context/mcp/update.js.map +1 -0
  90. package/dist/commands/context/query.js +6 -14
  91. package/dist/commands/context/query.js.map +1 -1
  92. package/dist/commands/context/sources/create.js +175 -0
  93. package/dist/commands/context/sources/create.js.map +1 -0
  94. package/dist/commands/context/sources/delete.js +5 -0
  95. package/dist/commands/context/sources/delete.js.map +1 -0
  96. package/dist/commands/context/sources/edit.js +29 -0
  97. package/dist/commands/context/sources/edit.js.map +1 -0
  98. package/dist/commands/context/sources/get.js +5 -0
  99. package/dist/commands/context/sources/get.js.map +1 -0
  100. package/dist/commands/context/sources/list.js +5 -0
  101. package/dist/commands/context/sources/list.js.map +1 -0
  102. package/dist/commands/context/sources/sync.js +5 -0
  103. package/dist/commands/context/sources/sync.js.map +1 -0
  104. package/dist/commands/context/sources/syncs/confirm.js +5 -0
  105. package/dist/commands/context/sources/syncs/confirm.js.map +1 -0
  106. package/dist/commands/context/sources/syncs/discard.js +5 -0
  107. package/dist/commands/context/sources/syncs/discard.js.map +1 -0
  108. package/dist/commands/context/sources/syncs/get.js +5 -0
  109. package/dist/commands/context/sources/syncs/get.js.map +1 -0
  110. package/dist/commands/context/sources/syncs/list.js +5 -0
  111. package/dist/commands/context/sources/syncs/list.js.map +1 -0
  112. package/dist/commands/context/sources/upload.js +63 -0
  113. package/dist/commands/context/sources/upload.js.map +1 -0
  114. package/dist/commands/context/sync.js +5 -0
  115. package/dist/commands/context/sync.js.map +1 -0
  116. package/dist/commands/context/update.js +3 -136
  117. package/dist/commands/context/update.js.map +1 -1
  118. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +47 -26
  119. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
  120. package/dist/generated/apiRoutes.js +28 -0
  121. package/dist/generated/apiRoutes.js.map +1 -1
  122. package/dist/generated/contextOperations.js +1116 -0
  123. package/dist/generated/contextOperations.js.map +1 -0
  124. package/dist/hooks/commandNotFound/topicAliases.js +8 -2
  125. package/dist/hooks/commandNotFound/topicAliases.js.map +1 -1
  126. package/dist/prompts/promptForText.js +12 -0
  127. package/dist/prompts/promptForText.js.map +1 -0
  128. package/dist/services/context.js +276 -202
  129. package/dist/services/context.js.map +1 -1
  130. package/dist/util/sharedFlags.js.map +1 -1
  131. package/dist/util/telemetry/cliCommandIdentity.js +16 -18
  132. package/dist/util/telemetry/cliCommandIdentity.js.map +1 -1
  133. package/oclif.config.js +1 -1
  134. package/oclif.manifest.json +4854 -2834
  135. package/package.json +20 -19
  136. package/templates/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  137. package/templates/app-quickstart/AGENTS.md +49 -0
  138. package/templates/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  139. package/templates/app-sanity-ui/AGENTS.md +49 -0
  140. package/templates/shared/dashboard/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  141. package/templates/shared/dashboard/app-quickstart/AGENTS.md +49 -0
  142. package/templates/shared/dashboard/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  143. package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +49 -0
  144. package/dist/commands/context/imports/create.js +0 -270
  145. package/dist/commands/context/imports/create.js.map +0 -1
  146. package/dist/commands/context/imports/delete.js +0 -73
  147. package/dist/commands/context/imports/delete.js.map +0 -1
  148. package/dist/commands/context/imports/download.js +0 -60
  149. package/dist/commands/context/imports/download.js.map +0 -1
  150. package/dist/commands/context/imports/get.js +0 -88
  151. package/dist/commands/context/imports/get.js.map +0 -1
  152. package/dist/commands/context/imports/list.js +0 -100
  153. package/dist/commands/context/imports/list.js.map +0 -1
  154. package/dist/commands/context/refresh.js +0 -46
  155. package/dist/commands/context/refresh.js.map +0 -1
@@ -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 = new 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 {listEntries} from '../../../services/context.js'\nimport {Table} from '../../../util/responsiveTable.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 = new Table({\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","listEntries","Table","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,WAAW,QAAO,+BAA8B;AACxD,SAAQC,KAAK,QAAO,mCAAkC;AAEtD,MAAMC,mBAAmBL,SAAS;AAElC,OAAO,MAAMM,2BAA2BP;IACtC,OAAgBQ,OAAO;QACrBC,iBAAiB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F;gBAAMC;gBAAQF;YAAK;QACnC;QAEA,IAAI,CAACL,GAAG,CAACC,MAAMQ,MAAM;IACvB;AACF"}
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
- import { Args, Flags } from '@oclif/core';
2
- import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
- import { getErrorMessage } from '@sanity/cli-core/errors';
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":["import {Args, Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {isHttpError} from '@sanity/client'\n\nimport {formatJobFailure, watchJob} from '../../../actions/context/watchJob.js'\nimport {formatKeyValue} from '../../../actions/debug/output.js'\nimport {rebuildEntry} from '../../../services/context.js'\n\nconst rebuildEntryDebug = subdebug('context:entries:rebuild')\n\nexport class RebuildEntryCommand extends SanityCommand<typeof RebuildEntryCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n path: Args.string({\n description: 'Entry path, as listed by `sanity context entries list`',\n required: true,\n }),\n }\n\n static override description = 'Rebuild one entry from its sources'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 billing/refunds',\n description: 'Start a rebuild and return the job ID',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 billing/refunds --watch',\n description: 'Rebuild an entry and wait for it to finish (non-zero exit on failure)',\n },\n ]\n\n static override flags = {\n watch: Flags.boolean({\n default: false,\n description: 'Wait for the rebuild to finish, exiting non-zero if it fails',\n }),\n } satisfies FlagInput\n\n public async run(): Promise<void> {\n const {knowledgeBaseId, path} = this.args\n const {watch} = this.flags\n\n let accepted\n const spin = spinner('Starting rebuild').start()\n try {\n accepted = await rebuildEntry(knowledgeBaseId, path)\n spin.succeed('Rebuild started')\n } catch (error) {\n spin.fail()\n rebuildEntryDebug('Error starting rebuild', error)\n if (isHttpError(error) && error.statusCode === 404) {\n this.error(`Entry \"${path}\" not found on knowledge base \"${knowledgeBaseId}\"`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n this.error(`Failed to start rebuild: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n const {affectedEntries, jobId} = accepted\n const padTo = 19 // \"Shares sources with\" is the longest key\n this.log(formatKeyValue('Job ID', jobId, {padTo}))\n // Other entries citing the same sources can change when they are next rebuilt\n if (affectedEntries.length > 0) {\n const paths = affectedEntries.map((entry) => entry.path).join(', ')\n this.log(formatKeyValue('Shares sources with', paths, {padTo}))\n }\n this.log(`Track it with: sanity context jobs get ${knowledgeBaseId} ${jobId}`)\n\n if (!watch) {\n return\n }\n\n let job\n try {\n job = await watchJob(knowledgeBaseId, jobId, {\n label: 'Rebuilding entry',\n successText: 'Entry rebuilt',\n })\n } catch (error) {\n rebuildEntryDebug('Error watching rebuild job', error)\n this.error(`Failed to watch rebuild job: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (job.status !== 'succeeded') {\n this.error(formatJobFailure('Rebuild', job), {exit: exitCodes.RUNTIME_ERROR})\n }\n }\n}\n"],"names":["Args","Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","spinner","isHttpError","formatJobFailure","watchJob","formatKeyValue","rebuildEntry","rebuildEntryDebug","RebuildEntryCommand","args","knowledgeBaseId","string","description","required","path","examples","command","flags","watch","boolean","default","run","accepted","spin","start","succeed","error","fail","statusCode","exit","RUNTIME_ERROR","affectedEntries","jobId","padTo","log","length","paths","map","entry","join","job","label","successText","status"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AAEvC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;A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Q,EAAE;gBAC/DG,MAAMhC,UAAUiC,aAAa;YAC/B;QACF;QAEA,MAAM,EAACC,eAAe,EAAEC,KAAK,EAAC,GAAGV;QACjC,MAAMW,QAAQ,GAAG,2CAA2C;;QAC5D,IAAI,CAACC,GAAG,CAAC7B,eAAe,UAAU2B,OAAO;YAACC;QAAK;QAC/C,8EAA8E;QAC9E,IAAIF,gBAAgBI,MAAM,GAAG,GAAG;YAC9B,MAAMC,QAAQL,gBAAgBM,GAAG,CAAC,CAACC,QAAUA,MAAMxB,IAAI,EAAEyB,IAAI,CAAC;YAC9D,IAAI,CAACL,GAAG,CAAC7B,eAAe,uBAAuB+B,OAAO;gBAACH;YAAK;QAC9D;QACA,IAAI,CAACC,GAAG,CAAC,CAAC,uCAAuC,EAAExB,gBAAgB,CAAC,EAAEsB,OAAO;QAE7E,IAAI,CAACd,OAAO;YACV;QACF;QAEA,IAAIsB;QACJ,IAAI;YACFA,MAAM,MAAMpC,SAASM,iBAAiBsB,OAAO;gBAC3CS,OAAO;gBACPC,aAAa;YACf;QACF,EAAE,OAAOhB,OAAO;YACdnB,kBAAkB,8BAA8BmB;YAChD,IAAI,CAACA,KAAK,CAAC,CAAC,6BAA6B,EAAE1B,gBAAgB0B,QAAQ,EAAE;gBACnEG,MAAMhC,UAAUiC,aAAa;YAC/B;QACF;QAEA,IAAIU,IAAIG,MAAM,KAAK,aAAa;YAC9B,IAAI,CAACjB,KAAK,CAACvB,iBAAiB,WAAWqC,MAAM;gBAACX,MAAMhC,UAAUiC,aAAa;YAAA;QAC7E;IACF;AACF"}
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
- import { Args } from '@oclif/core';
2
- import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
- import { getErrorMessage } from '@sanity/cli-core/errors';
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":["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 {formatKeyValue} from '../../actions/debug/output.js'\nimport {getKnowledgeBase} from '../../services/context.js'\n\nconst getContextDebug = subdebug('context:get')\n\nexport class GetKnowledgeBaseCommand extends SanityCommand<typeof GetKnowledgeBaseCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n }\n\n static override description = 'Get details of a knowledge base'\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123',\n description: 'Get details of a specific knowledge base',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --json',\n description: 'Output the knowledge base as JSON',\n },\n ]\n\n public async run(): Promise<void> {\n const {knowledgeBaseId} = this.args\n const {json} = this.flags\n\n let knowledgeBase\n try {\n knowledgeBase = await getKnowledgeBase(knowledgeBaseId)\n } catch (error) {\n getContextDebug('Error getting knowledge base', 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 get knowledge base: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (json) {\n this.logJson(knowledgeBase)\n return\n }\n\n const pending = knowledgeBase.pendingChanges\n const padTo = 15 // \"Pending changes\" is the longest key\n this.log(formatKeyValue('ID', knowledgeBase.publicId, {padTo}))\n this.log(formatKeyValue('Title', knowledgeBase.title, {padTo}))\n this.log(formatKeyValue('Description', knowledgeBase.description, {padTo}))\n this.log(formatKeyValue('Organization', knowledgeBase.organizationId, {padTo}))\n this.log(formatKeyValue('State', knowledgeBase.state, {padTo}))\n this.log(formatKeyValue('Active job', knowledgeBase.activeJobId ?? '-', {padTo}))\n this.log(\n formatKeyValue(\n 'Pending changes',\n pending\n ? `${pending.added} added, ${pending.changed} changed, ${pending.removed} removed`\n : '-',\n {padTo},\n ),\n )\n this.log(\n formatKeyValue(\n 'Refresh',\n knowledgeBase.refreshEnabled ? `enabled (${knowledgeBase.refreshFrequency})` : 'disabled',\n {padTo},\n ),\n )\n this.log(formatKeyValue('Open issues', knowledgeBase.openIssueCount, {padTo}))\n this.log(formatKeyValue('Instructions', knowledgeBase.instructionCount, {padTo}))\n this.log(formatKeyValue('Created', knowledgeBase.createdAt, {padTo}))\n this.log(formatKeyValue('Updated', knowledgeBase.updatedAt, {padTo}))\n }\n}\n"],"names":["Args","exitCodes","SanityCommand","subdebug","getErrorMessage","isHttpError","formatKeyValue","getKnowledgeBase","getContextDebug","GetKnowledgeBaseCommand","args","knowledgeBaseId","string","description","required","enableJsonFlag","examples","command","run","json","flags","knowledgeBase","error","statusCode","exit","RUNTIME_ERROR","logJson","pending","pendingChanges","padTo","log","publicId","title","organizationId","state","activeJobId","added","changed","removed","refreshEnabled","refreshFrequency","openIssueCount","instructionCount","createdAt","updatedAt"],"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,cAAc,QAAO,gCAA+B;AAC5D,SAAQC,gBAAgB,QAAO,4BAA2B;AAE1D,MAAMC,kBAAkBL,SAAS;AAEjC,OAAO,MAAMM,gCAAgCP;IAC3C,OAAgBQ,OAAO;QACrBC,iBAAiBX,KAAKY,MAAM,CAAC;YAC3BC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,kCAAiC;IAE/D,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,gBAAgB,MAAMd,iBAAiBI;QACzC,EAAE,OAAOW,OAAO;YACdd,gBAAgB,gCAAgCc;YAChD,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,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sB,SAAS,EAAE;YAACd;QAAK;QAClE,IAAI,CAACC,GAAG,CAACxB,eAAe,WAAWe,cAAcuB,SAAS,EAAE;YAACf;QAAK;IACpE;AACF"}
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
- import { Args, Flags } from '@oclif/core';
2
- import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
- import { getErrorMessage } from '@sanity/cli-core/errors';
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":["import {Args, Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {isHttpError} from '@sanity/client'\n\nimport {formatJobFailure, watchJob} from '../../../actions/context/watchJob.js'\nimport {formatKeyValue} from '../../../actions/debug/output.js'\nimport {applyIssues} from '../../../services/context.js'\n\nconst applyIssuesDebug = subdebug('context:issues:apply')\n\nexport class ApplyIssuesCommand extends SanityCommand<typeof ApplyIssuesCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n // eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first\n issueId: Args.string({\n description:\n \"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`\",\n multiple: true,\n required: true,\n }),\n }\n\n static override description = 'Accept and apply issues to a knowledge base'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456 issue.ghi789',\n description: 'Accept and apply two issues in one batch',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456 --watch',\n description: 'Apply an issue and wait for it to finish (non-zero exit on failure)',\n },\n ]\n\n static override flags = {\n watch: Flags.boolean({\n default: false,\n description: 'Wait for the apply to finish, exiting non-zero if it fails',\n }),\n } satisfies FlagInput\n\n public async run(): Promise<void> {\n const {issueId: issueIds, knowledgeBaseId} = this.args\n const {watch} = this.flags\n\n let jobId: string\n const spin = spinner('Starting apply').start()\n try {\n const accepted = await applyIssues(knowledgeBaseId, issueIds)\n jobId = accepted.jobId\n spin.succeed('Apply started')\n } catch (error) {\n spin.fail()\n applyIssuesDebug('Error applying issues', 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 apply issues: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n this.log(formatKeyValue('Job ID', jobId))\n this.log(`Track it with: sanity context jobs get ${knowledgeBaseId} ${jobId}`)\n\n if (!watch) {\n return\n }\n\n let job\n try {\n job = await watchJob(knowledgeBaseId, jobId, {\n label: 'Applying issues',\n successText: 'Issues applied',\n })\n } catch (error) {\n applyIssuesDebug('Error watching apply job', error)\n this.error(`Failed to watch apply job: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n if (job.status !== 'succeeded') {\n this.error(formatJobFailure('Apply', job), {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n }\n}\n"],"names":["Args","Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","spinner","isHttpError","formatJobFailure","watchJob","formatKeyValue","applyIssues","applyIssuesDebug","ApplyIssuesCommand","args","knowledgeBaseId","string","description","required","issueId","multiple","examples","command","flags","watch","boolean","default","run","issueIds","jobId","spin","start","accepted","succeed","error","fail","statusCode","exit","RUNTIME_ERROR","log","job","label","successText","status"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AAEvC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,SAAQC,WAAW,QAAO,iBAAgB;AAE1C,SAAQC,gBAAgB,EAAEC,QAAQ,QAAO,uCAAsC;AAC/E,SAAQC,cAAc,QAAO,mCAAkC;AAC/D,SAAQC,WAAW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QAClC,IAAI,CAACU,GAAG,CAAC,CAAC,uCAAuC,EAAExB,gBAAgB,CAAC,EAAEc,OAAO;QAE7E,IAAI,CAACL,OAAO;YACV;QACF;QAEA,IAAIgB;QACJ,IAAI;YACFA,MAAM,MAAM/B,SAASM,iBAAiBc,OAAO;gBAC3CY,OAAO;gBACPC,aAAa;YACf;QACF,EAAE,OAAOR,OAAO;YACdtB,iBAAiB,4BAA4BsB;YAC7C,IAAI,CAACA,KAAK,CAAC,CAAC,2BAA2B,EAAE7B,gBAAgB6B,QAAQ,EAAE;gBACjEG,MAAMnC,UAAUoC,aAAa;YAC/B;QACF;QAEA,IAAIE,IAAIG,MAAM,KAAK,aAAa;YAC9B,IAAI,CAACT,KAAK,CAAC1B,iBAAiB,SAASgC,MAAM;gBACzCH,MAAMnC,UAAUoC,aAAa;YAC/B;QACF;IACF;AACF"}
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
- import { Args } from '@oclif/core';
2
- import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
- import { getErrorMessage } from '@sanity/cli-core/errors';
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":["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 {dismissIssue} from '../../../services/context.js'\n\nconst dismissIssueDebug = subdebug('context:issues:dismiss')\n\nexport class DismissIssueCommand extends SanityCommand<typeof DismissIssueCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n // eslint-disable-next-line perfectionist/sort-objects -- positional order: knowledge base first\n issueId: Args.string({\n description: 'Issue ID',\n required: true,\n }),\n }\n\n static override description =\n \"Dismiss an issue\\n\\nDismissing is permanent: dismissed issues can't be reopened.\"\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 issue.def456',\n description: 'Dismiss an issue',\n },\n ]\n\n public async run(): Promise<void> {\n const {issueId, knowledgeBaseId} = this.args\n\n let dismissed\n try {\n dismissed = await dismissIssue(knowledgeBaseId, issueId)\n } catch (error) {\n dismissIssueDebug('Error dismissing issue', error)\n if (isHttpError(error) && error.statusCode === 404) {\n this.error(`Issue \"${issueId}\" not found on knowledge base \"${knowledgeBaseId}\"`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n this.error(`Failed to dismiss issue: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n // The API returns the issue unchanged when it already left triage\n if (dismissed.status !== 'rejected') {\n this.error(`Issue \"${issueId}\" is accepted (resolved or applied) and cannot be dismissed`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n this.log('Issue dismissed')\n }\n}\n"],"names":["Args","exitCodes","SanityCommand","subdebug","getErrorMessage","isHttpError","dismissIssue","dismissIssueDebug","DismissIssueCommand","args","knowledgeBaseId","string","description","required","issueId","examples","command","run","dismissed","error","statusCode","exit","RUNTIME_ERROR","status","log"],"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,+BAA8B;AAEzD,MAAMC,oBAAoBJ,SAAS;AAEnC,OAAO,MAAMK,4BAA4BN;IACvC,OAAgBO,OAAO;QACrBC,iBAAiBV,KAAKW,MAAM,CAAC;YAC3BC,aAAa;YACbC,UAAU;QACZ;QACA,gGAAgG;QAChGC,SAASd,KAAKW,MAAM,CAAC;YACnBC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cACd,mFAAkF;IAEpF,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,MAAaK,MAAqB;QAChC,MAAM,EAACH,OAAO,EAAEJ,eAAe,EAAC,GAAG,IAAI,CAACD,IAAI;QAE5C,IAAIS;QACJ,IAAI;YACFA,YAAY,MAAMZ,aAAaI,iBAAiBI;QAClD,EAAE,OAAOK,OAAO;YACdZ,kBAAkB,0BAA0BY;YAC5C,IAAId,YAAYc,UAAUA,MAAMC,UAAU,KAAK,KAAK;gBAClD,IAAI,CAACD,KAAK,CAAC,CAAC,OAAO,EAAEL,QAAQ,+BAA+B,EAAEJ,gBAAgB,CAAC,CAAC,EAAE;oBAChFW,MAAMpB,UAAUqB,aAAa;gBAC/B;YACF;YACA,IAAI,CAACH,KAAK,CAAC,CAAC,yBAAyB,EAAEf,gBAAgBe,QAAQ,EAAE;gBAC/DE,MAAMpB,UAAUqB,aAAa;YAC/B;QACF;QAEA,kEAAkE;QAClE,IAAIJ,UAAUK,MAAM,KAAK,YAAY;YACnC,IAAI,CAACJ,KAAK,CAAC,CAAC,OAAO,EAAEL,QAAQ,2DAA2D,CAAC,EAAE;gBACzFO,MAAMpB,UAAUqB,aAAa;YAC/B;QACF;QAEA,IAAI,CAACE,GAAG,CAAC;IACX;AACF"}
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"}
@@ -40,12 +40,7 @@ export class ListIssuesCommand extends SanityCommand {
40
40
  description: 'Only list issues of this kind',
41
41
  // A Record forces every kind the client knows to be listed, so the options can't drift
42
42
  options: Object.keys({
43
- add_entry: true,
44
43
  conflict: true,
45
- gap: true,
46
- merge_entry: true,
47
- remove_entry: true,
48
- split_entry: true,
49
44
  update_required: true
50
45
  })
51
46
  })(),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/commands/context/issues/list.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type Context, isHttpError} from '@sanity/client'\n\nimport {listIssues} from '../../../services/context.js'\n\nconst listIssuesDebug = subdebug('context:issues:list')\n\nexport class ListIssuesCommand extends SanityCommand<typeof ListIssuesCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n }\n\n static override description = 'List issues found by knowledge base builds'\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123',\n description: 'List all issues for a knowledge base',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --status open',\n description: 'List issues awaiting triage',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --kind conflict --severity critical',\n description: 'List critical conflicts',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --scope billing',\n description: 'List issues about entries under billing/',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --json',\n description: 'Output issues as JSON',\n },\n ]\n\n static override flags = {\n kind: Flags.custom<IssueKind>({\n description: 'Only list issues of this kind',\n // A Record forces every kind the client knows to be listed, so the options can't drift\n options: Object.keys({\n add_entry: true,\n conflict: true,\n gap: true,\n merge_entry: true,\n remove_entry: true,\n split_entry: true,\n update_required: true,\n } satisfies Record<IssueKind, true>),\n })(),\n scope: Flags.string({\n description:\n 'Only list issues about this entry path or anything under it (`*` for knowledge-base-wide issues)',\n helpValue: '<path>',\n parse: async (input: string) => {\n const trimmed = input.trim().replace(/\\/+$/, '')\n if (trimmed === '') {\n throw new Error('`--scope` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n severity: Flags.custom<Context.IssueDoc['content']['severity']>({\n description: 'Only list issues of this severity',\n options: ['critical', 'suggestion'],\n })(),\n status: Flags.custom<Context.IssueDoc['status']>({\n description:\n 'Only list issues with this status (rejected = dismissed, accepted = resolved or applied)',\n options: ['open', 'accepted', 'rejected'],\n })(),\n } satisfies FlagInput\n\n public async run(): Promise<void> {\n const {knowledgeBaseId} = this.args\n const {json, kind, scope, severity, status} = this.flags\n\n let issues\n try {\n issues = await listIssues(knowledgeBaseId, status)\n } catch (error) {\n listIssuesDebug('Error listing issues', 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 issues: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n // The client only filters on status; the rest are applied here\n const matches = issues.filter(\n ({content}) =>\n (kind === undefined || content.kind === kind) &&\n (severity === undefined || content.severity === severity) &&\n (scope === undefined ||\n content.scopePath === scope ||\n content.scopePath.startsWith(`${scope}/`)),\n )\n\n if (json) {\n this.logJson(matches)\n return\n }\n\n if (matches.length === 0) {\n this.log('No issues found')\n return\n }\n\n // Two lines per issue so long IDs never wrap: ID and metadata, then the summary cut to fit\n const width = Math.max(process.stdout.columns ?? 100, 40)\n const blocks = matches.map(({_id, content, status: issueStatus}) => {\n const meta = [content.kind, content.severity, issueStatus, content.scopePath].join(' · ')\n return `${_id} ${meta}\\n ${truncate(content.issue, width - 2)}`\n })\n this.log(blocks.join('\\n\\n'))\n }\n}\n\ntype IssueKind = Context.IssueDoc['content']['kind']\n\nfunction truncate(text: string, maxLength: number): string {\n // Count characters, not UTF-16 units, so an emoji at the cut point isn't split\n const chars = [...text.replaceAll(/\\s+/g, ' ').trim()]\n return chars.length <= maxLength ? chars.join('') : `${chars.slice(0, maxLength - 1).join('')}…`\n}\n"],"names":["Args","Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","isHttpError","listIssues","listIssuesDebug","ListIssuesCommand","args","knowledgeBaseId","string","description","required","enableJsonFlag","examples","command","flags","kind","custom","options","Object","keys","add_entry","conflict","gap","merge_entry","remove_entry","split_entry","update_required","scope","helpValue","parse","input","trimmed","trim","replace","Error","severity","status","run","json","issues","error","statusCode","exit","RUNTIME_ERROR","matches","filter","content","undefined","scopePath","startsWith","logJson","length","log","width","Math","max","process","stdout","columns","blocks","map","_id","issueStatus","meta","join","truncate","issue","text","maxLength","chars","replaceAll","slice"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AAEvC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAsBC,WAAW,QAAO,iBAAgB;AAExD,SAAQC,UAAU,QAAO,+BAA8B;AAEvD,MAAMC,kBAAkBJ,SAAS;AAEjC,OAAO,MAAMK,0BAA0BN;IACrC,OAAgBO,OAAO;QACrBC,iBAAiBX,KAAKY,MAAM,CAAC;YAC3BC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,6CAA4C;IAE1E,OAAgBE,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtBC,MAAMlB,MAAMmB,MAAM,CAAY;YAC5BP,aAAa;YACb,uFAAuF;YACvFQ,SAASC,OAAOC,IAAI,CA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AAAC/B,CAAAA,SAASgC,aAAaD,QAAQ/B,IAAI,KAAKA,IAAG,KAC1CoB,CAAAA,aAAaY,aAAaD,QAAQX,QAAQ,KAAKA,QAAO,KACtDR,CAAAA,UAAUoB,aACTD,QAAQE,SAAS,KAAKrB,SACtBmB,QAAQE,SAAS,CAACC,UAAU,CAAC,GAAGtB,MAAM,CAAC,CAAC,CAAA;QAG9C,IAAIW,MAAM;YACR,IAAI,CAACY,OAAO,CAACN;YACb;QACF;QAEA,IAAIA,QAAQO,MAAM,KAAK,GAAG;YACxB,IAAI,CAACC,GAAG,CAAC;YACT;QACF;QAEA,2FAA2F;QAC3F,MAAMC,QAAQC,KAAKC,GAAG,CAACC,QAAQC,MAAM,CAACC,OAAO,IAAI,KAAK;QACtD,MAAMC,SAASf,QAAQgB,GAAG,CAAC,CAAC,EAACC,GAAG,EAAEf,OAAO,EAAEV,QAAQ0B,WAAW,EAAC;YAC7D,MAAMC,OAAO;gBAACjB,QAAQ/B,IAAI;gBAAE+B,QAAQX,QAAQ;gBAAE2B;gBAAahB,QAAQE,SAAS;aAAC,CAACgB,IAAI,CAAC;YACnF,OAAO,GAAGH,IAAI,EAAE,EAAEE,KAAK,IAAI,EAAEE,SAASnB,QAAQoB,KAAK,EAAEb,QAAQ,IAAI;QACnE;QACA,IAAI,CAACD,GAAG,CAACO,OAAOK,IAAI,CAAC;IACvB;AACF;AAIA,SAASC,SAASE,IAAY,EAAEC,SAAiB;IAC/C,+EAA+E;IAC/E,MAAMC,QAAQ;WAAIF,KAAKG,UAAU,CAAC,QAAQ,KAAKtC,IAAI;KAAG;IACtD,OAAOqC,MAAMlB,MAAM,IAAIiB,YAAYC,MAAML,IAAI,CAAC,MAAM,GAAGK,MAAME,KAAK,CAAC,GAAGH,YAAY,GAAGJ,IAAI,CAAC,IAAI,CAAC,CAAC;AAClG"}
1
+ {"version":3,"sources":["../../../../src/commands/context/issues/list.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes, SanityCommand, subdebug} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\nimport {type Context, isHttpError} from '@sanity/client'\n\nimport {listIssues} from '../../../services/context.js'\n\nconst listIssuesDebug = subdebug('context:issues:list')\n\nexport class ListIssuesCommand extends SanityCommand<typeof ListIssuesCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n }\n\n static override description = 'List issues found by knowledge base builds'\n\n static override enableJsonFlag = true\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123',\n description: 'List all issues for a knowledge base',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --status open',\n description: 'List issues awaiting triage',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --kind conflict --severity critical',\n description: 'List critical conflicts',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --scope billing',\n description: 'List issues about entries under billing/',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --json',\n description: 'Output issues as JSON',\n },\n ]\n\n static override flags = {\n kind: Flags.custom<IssueKind>({\n description: 'Only list issues of this kind',\n // A Record forces every kind the client knows to be listed, so the options can't drift\n options: Object.keys({\n conflict: true,\n update_required: true,\n } satisfies Record<IssueKind, true>),\n })(),\n scope: Flags.string({\n description:\n 'Only list issues about this entry path or anything under it (`*` for knowledge-base-wide issues)',\n helpValue: '<path>',\n parse: async (input: string) => {\n const trimmed = input.trim().replace(/\\/+$/, '')\n if (trimmed === '') {\n throw new Error('`--scope` cannot be empty if provided')\n }\n return trimmed\n },\n }),\n severity: Flags.custom<Context.IssueDoc['content']['severity']>({\n description: 'Only list issues of this severity',\n options: ['critical', 'suggestion'],\n })(),\n status: Flags.custom<Context.IssueDoc['status']>({\n description:\n 'Only list issues with this status (rejected = dismissed, accepted = resolved or applied)',\n options: ['open', 'accepted', 'rejected'],\n })(),\n } satisfies FlagInput\n\n public async run(): Promise<void> {\n const {knowledgeBaseId} = this.args\n const {json, kind, scope, severity, status} = this.flags\n\n let issues\n try {\n issues = await listIssues(knowledgeBaseId, status)\n } catch (error) {\n listIssuesDebug('Error listing issues', 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 issues: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n\n // The client only filters on status; the rest are applied here\n const matches = issues.filter(\n ({content}) =>\n (kind === undefined || content.kind === kind) &&\n (severity === undefined || content.severity === severity) &&\n (scope === undefined ||\n content.scopePath === scope ||\n content.scopePath.startsWith(`${scope}/`)),\n )\n\n if (json) {\n this.logJson(matches)\n return\n }\n\n if (matches.length === 0) {\n this.log('No issues found')\n return\n }\n\n // Two lines per issue so long IDs never wrap: ID and metadata, then the summary cut to fit\n const width = Math.max(process.stdout.columns ?? 100, 40)\n const blocks = matches.map(({_id, content, status: issueStatus}) => {\n const meta = [content.kind, content.severity, issueStatus, content.scopePath].join(' · ')\n return `${_id} ${meta}\\n ${truncate(content.issue, width - 2)}`\n })\n this.log(blocks.join('\\n\\n'))\n }\n}\n\ntype IssueKind = Context.IssueDoc['content']['kind']\n\nfunction truncate(text: string, maxLength: number): string {\n // Count characters, not UTF-16 units, so an emoji at the cut point isn't split\n const chars = [...text.replaceAll(/\\s+/g, ' ').trim()]\n return chars.length <= maxLength ? chars.join('') : `${chars.slice(0, maxLength - 1).join('')}…`\n}\n"],"names":["Args","Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","isHttpError","listIssues","listIssuesDebug","ListIssuesCommand","args","knowledgeBaseId","string","description","required","enableJsonFlag","examples","command","flags","kind","custom","options","Object","keys","conflict","update_required","scope","helpValue","parse","input","trimmed","trim","replace","Error","severity","status","run","json","issues","error","statusCode","exit","RUNTIME_ERROR","matches","filter","content","undefined","scopePath","startsWith","logJson","length","log","width","Math","max","process","stdout","columns","blocks","map","_id","issueStatus","meta","join","truncate","issue","text","maxLength","chars","replaceAll","slice"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AAEvC,SAAQC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;AACnE,SAAQC,eAAe,QAAO,0BAAyB;AACvD,SAAsBC,WAAW,QAAO,iBAAgB;AAExD,SAAQC,UAAU,QAAO,+BAA8B;AAEvD,MAAMC,kBAAkBJ,SAAS;AAEjC,OAAO,MAAMK,0BAA0BN;IACrC,OAAgBO,OAAO;QACrBC,iBAAiBX,KAAKY,MAAM,CAAC;YAC3BC,aAAa;YACbC,UAAU;QACZ;IACF,EAAC;IAED,OAAgBD,cAAc,6CAA4C;IAE1E,OAAgBE,iBAAiB,KAAI;IAErC,OAAgBC,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtBC,MAAMlB,MAAMmB,MAAM,CAAY;YAC5BP,aAAa;YACb,uFAAuF;YACvFQ,SAASC,OAAOC,IAAI,CAAC;gBACnBC,UAAU;gBACVC,iBAAiB;YACnB;QACF;QACAC,OAAOzB,MAAMW,MAAM,CAAC;YAClBC,aACE;YACFc,WAAW;YACXC,OAAO,OAAOC;gBACZ,MAAMC,UAAUD,MAAME,IAAI,GAAGC,OAAO,CAAC,QAAQ;gBAC7C,IAAIF,YAAY,IAAI;oBAClB,MAAM,IAAIG,MAAM;gBAClB;gBACA,OAAOH;YACT;QACF;QACAI,UAAUjC,MAAMmB,MAAM,CAA0C;YAC9DP,aAAa;YACbQ,SAAS;gBAAC;gBAAY;aAAa;QACrC;QACAc,QAAQlC,MAAMmB,MAAM,CAA6B;YA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AAK;QACtD,MAAMC,SAASf,QAAQgB,GAAG,CAAC,CAAC,EAACC,GAAG,EAAEf,OAAO,EAAEV,QAAQ0B,WAAW,EAAC;YAC7D,MAAMC,OAAO;gBAACjB,QAAQ1B,IAAI;gBAAE0B,QAAQX,QAAQ;gBAAE2B;gBAAahB,QAAQE,SAAS;aAAC,CAACgB,IAAI,CAAC;YACnF,OAAO,GAAGH,IAAI,EAAE,EAAEE,KAAK,IAAI,EAAEE,SAASnB,QAAQoB,KAAK,EAAEb,QAAQ,IAAI;QACnE;QACA,IAAI,CAACD,GAAG,CAACO,OAAOK,IAAI,CAAC;IACvB;AACF;AAIA,SAASC,SAASE,IAAY,EAAEC,SAAiB;IAC/C,+EAA+E;IAC/E,MAAMC,QAAQ;WAAIF,KAAKG,UAAU,CAAC,QAAQ,KAAKtC,IAAI;KAAG;IACtD,OAAOqC,MAAMlB,MAAM,IAAIiB,YAAYC,MAAML,IAAI,CAAC,MAAM,GAAGK,MAAME,KAAK,CAAC,GAAGH,YAAY,GAAGJ,IAAI,CAAC,IAAI,CAAC,CAAC;AAClG"}
@@ -1,53 +1,5 @@
1
- import { Args } from '@oclif/core';
2
- import { exitCodes, SanityCommand, subdebug } from '@sanity/cli-core';
3
- import { getErrorMessage } from '@sanity/cli-core/errors';
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