@sanity/cli 8.27.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 (136) 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.map +1 -1
  11. package/dist/actions/context/operationInput.js +226 -0
  12. package/dist/actions/context/operationInput.js.map +1 -0
  13. package/dist/actions/context/operationTypes.js +3 -0
  14. package/dist/actions/context/operationTypes.js.map +1 -0
  15. package/dist/actions/context/removedCommands.js +26 -0
  16. package/dist/actions/context/removedCommands.js.map +1 -0
  17. package/dist/actions/context/renderOperationResult.js +72 -0
  18. package/dist/actions/context/renderOperationResult.js.map +1 -0
  19. package/dist/actions/context/sourceFile.js +31 -0
  20. package/dist/actions/context/sourceFile.js.map +1 -0
  21. package/dist/actions/context/syncOutput.js +17 -0
  22. package/dist/actions/context/syncOutput.js.map +1 -0
  23. package/dist/actions/context/table.js +13 -0
  24. package/dist/actions/context/table.js.map +1 -0
  25. package/dist/actions/context/waitForJob.js.map +1 -1
  26. package/dist/actions/context/waitForSourceSync.js +48 -0
  27. package/dist/actions/context/waitForSourceSync.js.map +1 -0
  28. package/dist/actions/context/watchJob.js.map +1 -1
  29. package/dist/actions/context/watchSourceSync.js +40 -0
  30. package/dist/actions/context/watchSourceSync.js.map +1 -0
  31. package/dist/commands/context/build.js +19 -81
  32. package/dist/commands/context/build.js.map +1 -1
  33. package/dist/commands/context/create.js +3 -90
  34. package/dist/commands/context/create.js.map +1 -1
  35. package/dist/commands/context/delete.js +3 -73
  36. package/dist/commands/context/delete.js.map +1 -1
  37. package/dist/commands/context/documents/content.js +117 -0
  38. package/dist/commands/context/documents/content.js.map +1 -0
  39. package/dist/commands/context/documents/delete.js +5 -0
  40. package/dist/commands/context/documents/delete.js.map +1 -0
  41. package/dist/commands/context/documents/edit.js +5 -0
  42. package/dist/commands/context/documents/edit.js.map +1 -0
  43. package/dist/commands/context/documents/get.js +5 -0
  44. package/dist/commands/context/documents/get.js.map +1 -0
  45. package/dist/commands/context/documents/list.js +5 -0
  46. package/dist/commands/context/documents/list.js.map +1 -0
  47. package/dist/commands/context/entries/list.js +2 -2
  48. package/dist/commands/context/entries/list.js.map +1 -1
  49. package/dist/commands/context/entries/rebuild.js +3 -93
  50. package/dist/commands/context/entries/rebuild.js.map +1 -1
  51. package/dist/commands/context/get.js +3 -88
  52. package/dist/commands/context/get.js.map +1 -1
  53. package/dist/commands/context/instructions/create.js +5 -0
  54. package/dist/commands/context/instructions/create.js.map +1 -0
  55. package/dist/commands/context/instructions/delete.js +5 -0
  56. package/dist/commands/context/instructions/delete.js.map +1 -0
  57. package/dist/commands/context/instructions/edit.js +5 -0
  58. package/dist/commands/context/instructions/edit.js.map +1 -0
  59. package/dist/commands/context/issues/apply.js +3 -84
  60. package/dist/commands/context/issues/apply.js.map +1 -1
  61. package/dist/commands/context/issues/dismiss.js +3 -50
  62. package/dist/commands/context/issues/dismiss.js.map +1 -1
  63. package/dist/commands/context/issues/reopen.js +3 -51
  64. package/dist/commands/context/issues/reopen.js.map +1 -1
  65. package/dist/commands/context/issues/resolve.js +23 -92
  66. package/dist/commands/context/issues/resolve.js.map +1 -1
  67. package/dist/commands/context/jobs/get.js +3 -88
  68. package/dist/commands/context/jobs/get.js.map +1 -1
  69. package/dist/commands/context/list.js +3 -95
  70. package/dist/commands/context/list.js.map +1 -1
  71. package/dist/commands/context/mcp/initial-context.js +5 -0
  72. package/dist/commands/context/mcp/initial-context.js.map +1 -0
  73. package/dist/commands/context/mcp/list.js +2 -2
  74. package/dist/commands/context/mcp/list.js.map +1 -1
  75. package/dist/commands/context/mcp/status.js.map +1 -1
  76. package/dist/commands/context/mcp/update.js.map +1 -1
  77. package/dist/commands/context/sources/create.js +175 -0
  78. package/dist/commands/context/sources/create.js.map +1 -0
  79. package/dist/commands/context/sources/delete.js +5 -0
  80. package/dist/commands/context/sources/delete.js.map +1 -0
  81. package/dist/commands/context/sources/edit.js +29 -0
  82. package/dist/commands/context/sources/edit.js.map +1 -0
  83. package/dist/commands/context/sources/get.js +5 -0
  84. package/dist/commands/context/sources/get.js.map +1 -0
  85. package/dist/commands/context/sources/list.js +5 -0
  86. package/dist/commands/context/sources/list.js.map +1 -0
  87. package/dist/commands/context/sources/sync.js +5 -0
  88. package/dist/commands/context/sources/sync.js.map +1 -0
  89. package/dist/commands/context/sources/syncs/confirm.js +5 -0
  90. package/dist/commands/context/sources/syncs/confirm.js.map +1 -0
  91. package/dist/commands/context/sources/syncs/discard.js +5 -0
  92. package/dist/commands/context/sources/syncs/discard.js.map +1 -0
  93. package/dist/commands/context/sources/syncs/get.js +5 -0
  94. package/dist/commands/context/sources/syncs/get.js.map +1 -0
  95. package/dist/commands/context/sources/syncs/list.js +5 -0
  96. package/dist/commands/context/sources/syncs/list.js.map +1 -0
  97. package/dist/commands/context/sources/upload.js +63 -0
  98. package/dist/commands/context/sources/upload.js.map +1 -0
  99. package/dist/commands/context/sync.js +5 -0
  100. package/dist/commands/context/sync.js.map +1 -0
  101. package/dist/commands/context/update.js +3 -136
  102. package/dist/commands/context/update.js.map +1 -1
  103. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +41 -26
  104. package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
  105. package/dist/generated/apiRoutes.js +28 -0
  106. package/dist/generated/apiRoutes.js.map +1 -1
  107. package/dist/generated/contextOperations.js +1116 -0
  108. package/dist/generated/contextOperations.js.map +1 -0
  109. package/dist/hooks/commandNotFound/topicAliases.js +8 -2
  110. package/dist/hooks/commandNotFound/topicAliases.js.map +1 -1
  111. package/dist/services/context.js +241 -268
  112. package/dist/services/context.js.map +1 -1
  113. package/dist/util/telemetry/cliCommandIdentity.js +10 -18
  114. package/dist/util/telemetry/cliCommandIdentity.js.map +1 -1
  115. package/oclif.manifest.json +4393 -2923
  116. package/package.json +20 -19
  117. package/templates/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  118. package/templates/app-quickstart/AGENTS.md +49 -0
  119. package/templates/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  120. package/templates/app-sanity-ui/AGENTS.md +49 -0
  121. package/templates/shared/dashboard/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  122. package/templates/shared/dashboard/app-quickstart/AGENTS.md +49 -0
  123. package/templates/shared/dashboard/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
  124. package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +49 -0
  125. package/dist/commands/context/imports/create.js +0 -270
  126. package/dist/commands/context/imports/create.js.map +0 -1
  127. package/dist/commands/context/imports/delete.js +0 -73
  128. package/dist/commands/context/imports/delete.js.map +0 -1
  129. package/dist/commands/context/imports/download.js +0 -60
  130. package/dist/commands/context/imports/download.js.map +0 -1
  131. package/dist/commands/context/imports/get.js +0 -88
  132. package/dist/commands/context/imports/get.js.map +0 -1
  133. package/dist/commands/context/imports/list.js +0 -100
  134. package/dist/commands/context/imports/list.js.map +0 -1
  135. package/dist/commands/context/refresh.js +0 -46
  136. package/dist/commands/context/refresh.js.map +0 -1
@@ -0,0 +1,175 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { basename } from 'node:path';
3
+ import { text as readStream } from 'node:stream/consumers';
4
+ import { Flags } from '@oclif/core';
5
+ import { exitCodes } from '@sanity/cli-core';
6
+ import { getErrorMessage } from '@sanity/cli-core/errors';
7
+ import { contextCommand } from '../../../actions/context/contextCommand.js';
8
+ import { flagName } from '../../../actions/context/operationInput.js';
9
+ import { readSourceFile } from '../../../actions/context/sourceFile.js';
10
+ import { createFileSource } from '../../../services/context.js';
11
+ import { defineCommandTelemetry } from '../../../util/telemetry/commandTelemetry.js';
12
+ const BaseCommand = contextCommand('context sources create');
13
+ const SOURCE_FLAGS = [
14
+ 'url',
15
+ 'query',
16
+ 'file',
17
+ 'text'
18
+ ];
19
+ /** The body fields a `--file` source takes; the file supplies the rest */ const FILE_BODY_FIELDS = new Set([
20
+ 'contentType',
21
+ 'title'
22
+ ]);
23
+ const flags = {
24
+ ...BaseCommand.flags,
25
+ file: Flags.string({
26
+ description: 'Local file to upload as a files source: a document, or a zip, tar or gzip archive of them',
27
+ exclusive: [
28
+ 'url',
29
+ 'query',
30
+ 'text'
31
+ ],
32
+ helpValue: '<path>'
33
+ }),
34
+ query: {
35
+ ...BaseCommand.flags.query,
36
+ exclusive: [
37
+ 'url',
38
+ 'file',
39
+ 'text'
40
+ ]
41
+ },
42
+ text: Flags.string({
43
+ description: 'Text or markdown to hold as a files source, read from a local file or `-` for stdin',
44
+ exclusive: [
45
+ 'url',
46
+ 'query',
47
+ 'file'
48
+ ],
49
+ helpValue: '<path|->'
50
+ }),
51
+ url: {
52
+ ...BaseCommand.flags.url,
53
+ exclusive: [
54
+ 'query',
55
+ 'file',
56
+ 'text'
57
+ ]
58
+ }
59
+ };
60
+ /**
61
+ * `context sources create` adds `--file`, which uploads a local file to a
62
+ * signed URL, and `--text`, which reads the content of a files source from a
63
+ * file or stdin. The rest is the spec's `createSource`.
64
+ */ export class CreateSourceCommand extends BaseCommand {
65
+ static examples = [
66
+ {
67
+ command: '<%= config.bin %> <%= command.id %> kb-abc123 --url https://example.com/docs',
68
+ description: 'Crawl a website'
69
+ },
70
+ {
71
+ command: '<%= config.bin %> <%= command.id %> kb-abc123 --url https://example.com/docs --dry-run',
72
+ description: 'Estimate how many pages a crawl of /docs would find, without adding it'
73
+ },
74
+ {
75
+ command: '<%= config.bin %> <%= command.id %> kb-abc123 --query \'*[_type == "article"]\' --sanity-project-id abc123 --sanity-dataset-id production',
76
+ description: 'Read the documents a GROQ query selects from a Sanity dataset'
77
+ },
78
+ {
79
+ command: '<%= config.bin %> <%= command.id %> kb-abc123 --file ./handbook.pdf --watch',
80
+ description: 'Upload a local file and wait for its sync'
81
+ },
82
+ {
83
+ command: 'cat refunds.md | <%= config.bin %> <%= command.id %> kb-abc123 --text - --title "Refund policy"',
84
+ description: 'Add markdown from stdin'
85
+ }
86
+ ];
87
+ static flags = flags;
88
+ static telemetry = {
89
+ redactedFlags: [
90
+ ...BaseCommand.telemetry.redactedFlags,
91
+ ...defineCommandTelemetry(flags, {
92
+ redact: [
93
+ 'file',
94
+ 'text'
95
+ ]
96
+ }).redactedFlags
97
+ ]
98
+ };
99
+ async send(request, values) {
100
+ const body = request.body ?? {};
101
+ const title = typeof body.title === 'string' ? body.title : undefined;
102
+ const { file, text } = values;
103
+ const given = SOURCE_FLAGS.filter((name)=>values[name] !== undefined);
104
+ if (given.length > 1 || given.length === 0 && body.type !== 'files') {
105
+ this.error('Provide exactly one of --url, --query, --file or --text, or `--type files --title <title>` for a files source whose file comes later with `sources upload`.', {
106
+ exit: exitCodes.USAGE_ERROR
107
+ });
108
+ }
109
+ if (typeof file === 'string') {
110
+ // Nested fields such as `crawlOptions.maxDepth` come from flags named after the field itself
111
+ const ignored = Object.entries(body).flatMap(([key, value])=>{
112
+ if (key === 'type') return value === 'files' || values.type === undefined ? [] : [
113
+ key
114
+ ];
115
+ if (FILE_BODY_FIELDS.has(key)) return [];
116
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? Object.keys(value) : [
117
+ key
118
+ ];
119
+ });
120
+ if (ignored.length > 0) {
121
+ this.error(`--file adds a files source, which takes only --title and --content-type. Remove ${ignored.map((name)=>`--${flagName({
122
+ name
123
+ })}`).join(', ')}.`, {
124
+ exit: exitCodes.USAGE_ERROR
125
+ });
126
+ }
127
+ const upload = await this.read(`file "${file}"`, ()=>readSourceFile(file, typeof body.contentType === 'string' ? body.contentType : undefined));
128
+ // The created source has no sync yet; `jobId` lets the output and `--watch` follow the upload's
129
+ const { source, sync } = await createFileSource(request.params.knowledgeBaseId, {
130
+ ...upload,
131
+ title: title ?? upload.filename,
132
+ type: 'files'
133
+ });
134
+ return {
135
+ ...source,
136
+ jobId: sync.jobId
137
+ };
138
+ }
139
+ if (typeof text === 'string') {
140
+ const fromStdin = text === '-';
141
+ if (fromStdin && !title) {
142
+ this.error('Text read from stdin needs a title. Provide it with the --title flag.', {
143
+ exit: exitCodes.USAGE_ERROR
144
+ });
145
+ }
146
+ const content = await this.read(fromStdin ? 'stdin' : `file "${text}"`, ()=>fromStdin ? readStream(process.stdin) : readFile(text, 'utf8'));
147
+ if (content.trim() === '') {
148
+ this.error('Text content cannot be empty', {
149
+ exit: exitCodes.USAGE_ERROR
150
+ });
151
+ }
152
+ return super.send({
153
+ ...request,
154
+ body: {
155
+ ...body,
156
+ content,
157
+ title: title ?? basename(text),
158
+ type: 'files'
159
+ }
160
+ }, values);
161
+ }
162
+ return super.send(request, values);
163
+ }
164
+ async read(what, read) {
165
+ try {
166
+ return await read();
167
+ } catch (error) {
168
+ this.error(`Failed to read ${what}: ${getErrorMessage(error)}`, {
169
+ exit: exitCodes.RUNTIME_ERROR
170
+ });
171
+ }
172
+ }
173
+ }
174
+
175
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/create.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport {basename} from 'node:path'\nimport {text as readStream} from 'node:stream/consumers'\n\nimport {Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\n\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\nimport {flagName, type OperationRequest} from '../../../actions/context/operationInput.js'\nimport {readSourceFile} from '../../../actions/context/sourceFile.js'\nimport {createFileSource} from '../../../services/context.js'\nimport {defineCommandTelemetry} from '../../../util/telemetry/commandTelemetry.js'\n\nconst BaseCommand = contextCommand('context sources create')\n\nconst SOURCE_FLAGS = ['url', 'query', 'file', 'text'] as const\n\n/** The body fields a `--file` source takes; the file supplies the rest */\nconst FILE_BODY_FIELDS = new Set(['contentType', 'title'])\n\nconst flags = {\n ...BaseCommand.flags,\n file: Flags.string({\n description:\n 'Local file to upload as a files source: a document, or a zip, tar or gzip archive of them',\n exclusive: ['url', 'query', 'text'],\n helpValue: '<path>',\n }),\n query: {...BaseCommand.flags.query, exclusive: ['url', 'file', 'text']},\n text: Flags.string({\n description:\n 'Text or markdown to hold as a files source, read from a local file or `-` for stdin',\n exclusive: ['url', 'query', 'file'],\n helpValue: '<path|->',\n }),\n url: {...BaseCommand.flags.url, exclusive: ['query', 'file', 'text']},\n} satisfies FlagInput\n\n/**\n * `context sources create` adds `--file`, which uploads a local file to a\n * signed URL, and `--text`, which reads the content of a files source from a\n * file or stdin. The rest is the spec's `createSource`.\n */\nexport class CreateSourceCommand extends BaseCommand {\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --url https://example.com/docs',\n description: 'Crawl a website',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> kb-abc123 --url https://example.com/docs --dry-run',\n description: 'Estimate how many pages a crawl of /docs would find, without adding it',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> kb-abc123 --query \\'*[_type == \"article\"]\\' --sanity-project-id abc123 --sanity-dataset-id production',\n description: 'Read the documents a GROQ query selects from a Sanity dataset',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --file ./handbook.pdf --watch',\n description: 'Upload a local file and wait for its sync',\n },\n {\n command:\n 'cat refunds.md | <%= config.bin %> <%= command.id %> kb-abc123 --text - --title \"Refund policy\"',\n description: 'Add markdown from stdin',\n },\n ]\n\n static override flags = flags\n\n static override telemetry = {\n redactedFlags: [\n ...BaseCommand.telemetry.redactedFlags,\n ...defineCommandTelemetry(flags, {redact: ['file', 'text']}).redactedFlags,\n ],\n }\n\n public override async send(\n request: OperationRequest,\n values: Record<string, unknown>,\n ): Promise<unknown> {\n const body = request.body ?? {}\n const title = typeof body.title === 'string' ? body.title : undefined\n const {file, text} = values\n\n const given = SOURCE_FLAGS.filter((name) => values[name] !== undefined)\n if (given.length > 1 || (given.length === 0 && body.type !== 'files')) {\n this.error(\n 'Provide exactly one of --url, --query, --file or --text, or `--type files --title <title>` for a files source whose file comes later with `sources upload`.',\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n if (typeof file === 'string') {\n // Nested fields such as `crawlOptions.maxDepth` come from flags named after the field itself\n const ignored = Object.entries(body).flatMap(([key, value]) => {\n if (key === 'type') return value === 'files' || values.type === undefined ? [] : [key]\n if (FILE_BODY_FIELDS.has(key)) return []\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? Object.keys(value)\n : [key]\n })\n if (ignored.length > 0) {\n this.error(\n `--file adds a files source, which takes only --title and --content-type. Remove ${ignored.map((name) => `--${flagName({name})}`).join(', ')}.`,\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n const upload = await this.read(`file \"${file}\"`, () =>\n readSourceFile(file, typeof body.contentType === 'string' ? body.contentType : undefined),\n )\n // The created source has no sync yet; `jobId` lets the output and `--watch` follow the upload's\n const {source, sync} = await createFileSource(request.params.knowledgeBaseId, {\n ...upload,\n title: title ?? upload.filename,\n type: 'files',\n })\n return {...source, jobId: sync.jobId}\n }\n\n if (typeof text === 'string') {\n const fromStdin = text === '-'\n if (fromStdin && !title) {\n this.error('Text read from stdin needs a title. Provide it with the --title flag.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n const content = await this.read(fromStdin ? 'stdin' : `file \"${text}\"`, () =>\n fromStdin ? readStream(process.stdin) : readFile(text, 'utf8'),\n )\n if (content.trim() === '') {\n this.error('Text content cannot be empty', {exit: exitCodes.USAGE_ERROR})\n }\n return super.send(\n {...request, body: {...body, content, title: title ?? basename(text), type: 'files'}},\n values,\n )\n }\n\n return super.send(request, values)\n }\n\n private async read<T>(what: string, read: () => Promise<T>): Promise<T> {\n try {\n return await read()\n } catch (error) {\n this.error(`Failed to read ${what}: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n }\n}\n"],"names":["readFile","basename","text","readStream","Flags","exitCodes","getErrorMessage","contextCommand","flagName","readSourceFile","createFileSource","defineCommandTelemetry","BaseCommand","SOURCE_FLAGS","FILE_BODY_FIELDS","Set","flags","file","string","description","exclusive","helpValue","query","url","CreateSourceCommand","examples","command","telemetry","redactedFlags","redact","send","request","values","body","title","undefined","given","filter","name","length","type","error","exit","USAGE_ERROR","ignored","Object","entries","flatMap","key","value","has","Array","isArray","keys","map","join","upload","read","contentType","source","sync","params","knowledgeBaseId","filename","jobId","fromStdin","content","process","stdin","trim","what","RUNTIME_ERROR"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,SAAQC,QAAQ,QAAO,YAAW;AAClC,SAAQC,QAAQC,UAAU,QAAO,wBAAuB;AAExD,SAAQC,KAAK,QAAO,cAAa;AAEjC,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,eAAe,QAAO,0BAAyB;AAEvD,SAAQC,cAAc,QAAO,6CAA4C;AACzE,SAAQC,QAAQ,QAA8B,6CAA4C;AAC1F,SAAQC,cAAc,QAAO,yCAAwC;AACrE,SAAQC,gBAAgB,QAAO,+BAA8B;AAC7D,SAAQC,sBAAsB,QAAO,8CAA6C;AAElF,MAAMC,cAAcL,eAAe;AAEnC,MAAMM,eAAe;IAAC;IAAO;IAAS;IAAQ;CAAO;AAErD,wEAAwE,GACxE,MAAMC,mBAAmB,IAAIC,IAAI;IAAC;IAAe;CAAQ;AAEzD,MAAMC,QAAQ;IACZ,GAAGJ,YAAYI,KAAK;IACpBC,MAAMb,MAAMc,MAAM,CAAC;QACjBC,aACE;QACFC,WAAW;YAAC;YAAO;YAAS;SAAO;QACnCC,WAAW;IACb;IACAC,OAAO;Q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ClFC,MAAMrC,UAAUsC,WAAW;gBAC7B;YACF;YACA,MAAMuB,UAAU,MAAM,IAAI,CAACT,IAAI,CAACQ,YAAY,UAAU,CAAC,MAAM,EAAE/D,KAAK,CAAC,CAAC,EAAE,IACtE+D,YAAY9D,WAAWgE,QAAQC,KAAK,IAAIpE,SAASE,MAAM;YAEzD,IAAIgE,QAAQG,IAAI,OAAO,IAAI;gBACzB,IAAI,CAAC5B,KAAK,CAAC,gCAAgC;oBAACC,MAAMrC,UAAUsC,WAAW;gBAAA;YACzE;YACA,OAAO,KAAK,CAACb,KACX;gBAAC,GAAGC,OAAO;gBAAEE,MAAM;oBAAC,GAAGA,IAAI;oBAAEiC;oBAAShC,OAAOA,SAASjC,SAASC;oBAAOsC,MAAM;gBAAO;YAAC,GACpFR;QAEJ;QAEA,OAAO,KAAK,CAACF,KAAKC,SAASC;IAC7B;IAEA,MAAcyB,KAAQa,IAAY,EAAEb,IAAsB,EAAc;QACtE,IAAI;YACF,OAAO,MAAMA;QACf,EAAE,OAAOhB,OAAO;YACd,IAAI,CAACA,KAAK,CAAC,CAAC,eAAe,EAAE6B,KAAK,EAAE,EAAEhE,gBAAgBmC,QAAQ,EAAE;gBAC9DC,MAAMrC,UAAUkE,aAAa;YAC/B;QACF;IACF;AACF"}
@@ -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 DeleteSourceCommand = contextCommand('context sources delete');
4
+
5
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/delete.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const DeleteSourceCommand = contextCommand('context sources delete')\n"],"names":["contextCommand","DeleteSourceCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,sBAAsBD,eAAe,0BAAyB"}
@@ -0,0 +1,29 @@
1
+ import { contextCommand } from '../../../actions/context/contextCommand.js';
2
+ import { getSource } from '../../../services/context.js';
3
+ const BaseCommand = contextCommand('context sources edit');
4
+ /**
5
+ * `context sources edit` merges crawl option flags onto the source's stored
6
+ * crawl options: the API replaces `crawlOptions` as a whole, so changing one
7
+ * flag must not drop the others.
8
+ */ export class UpdateSourceCommand extends BaseCommand {
9
+ async send(request, values) {
10
+ const crawlOptions = request.body?.crawlOptions;
11
+ if (typeof crawlOptions !== 'object' || crawlOptions === null) {
12
+ return super.send(request, values);
13
+ }
14
+ const source = await getSource(request.params.knowledgeBaseId, request.params.sourceId);
15
+ const stored = 'crawlOptions' in source ? source.crawlOptions : undefined;
16
+ return super.send({
17
+ ...request,
18
+ body: {
19
+ ...request.body,
20
+ crawlOptions: {
21
+ ...stored,
22
+ ...crawlOptions
23
+ }
24
+ }
25
+ }, values);
26
+ }
27
+ }
28
+
29
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/edit.ts"],"sourcesContent":["import {contextCommand} from '../../../actions/context/contextCommand.js'\nimport {type OperationRequest} from '../../../actions/context/operationInput.js'\nimport {getSource} from '../../../services/context.js'\n\nconst BaseCommand = contextCommand('context sources edit')\n\n/**\n * `context sources edit` merges crawl option flags onto the source's stored\n * crawl options: the API replaces `crawlOptions` as a whole, so changing one\n * flag must not drop the others.\n */\nexport class UpdateSourceCommand extends BaseCommand {\n public override async send(\n request: OperationRequest,\n values: Record<string, unknown>,\n ): Promise<unknown> {\n const crawlOptions = request.body?.crawlOptions\n if (typeof crawlOptions !== 'object' || crawlOptions === null) {\n return super.send(request, values)\n }\n const source = await getSource(request.params.knowledgeBaseId, request.params.sourceId)\n const stored = 'crawlOptions' in source ? source.crawlOptions : undefined\n return super.send(\n {...request, body: {...request.body, crawlOptions: {...stored, ...crawlOptions}}},\n values,\n )\n }\n}\n"],"names":["contextCommand","getSource","BaseCommand","UpdateSourceCommand","send","request","values","crawlOptions","body","source","params","knowledgeBaseId","sourceId","stored","undefined"],"mappings":"AAAA,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,SAAQC,SAAS,QAAO,+BAA8B;AAEtD,MAAMC,cAAcF,eAAe;AAEnC;;;;CAIC,GACD,OAAO,MAAMG,4BAA4BD;IACvC,MAAsBE,KACpBC,OAAyB,EACzBC,MAA+B,EACb;QAClB,MAAMC,eAAeF,QAAQG,IAAI,EAAED;QACnC,IAAI,OAAOA,iBAAiB,YAAYA,iBAAiB,MAAM;YAC7D,OAAO,KAAK,CAACH,KAAKC,SAASC;QAC7B;QACA,MAAMG,SAAS,MAAMR,UAAUI,QAAQK,MAAM,CAACC,eAAe,EAAEN,QAAQK,MAAM,CAACE,QAAQ;QACtF,MAAMC,SAAS,kBAAkBJ,SAASA,OAAOF,YAAY,GAAGO;QAChE,OAAO,KAAK,CAACV,KACX;YAAC,GAAGC,OAAO;YAAEG,MAAM;gBAAC,GAAGH,QAAQG,IAAI;gBAAED,cAAc;oBAAC,GAAGM,MAAM;oBAAE,GAAGN,YAAY;gBAAA;YAAC;QAAC,GAChFD;IAEJ;AACF"}
@@ -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 GetSourceCommand = contextCommand('context sources get');
4
+
5
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/get.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const GetSourceCommand = contextCommand('context sources get')\n"],"names":["contextCommand","GetSourceCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,mBAAmBD,eAAe,uBAAsB"}
@@ -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 ListSourcesCommand = contextCommand('context sources list');
4
+
5
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/list.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const ListSourcesCommand = contextCommand('context sources list')\n"],"names":["contextCommand","ListSourcesCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,qBAAqBD,eAAe,wBAAuB"}
@@ -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 StartSyncCommand = contextCommand('context sources sync');
4
+
5
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/sync.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const StartSyncCommand = contextCommand('context sources sync')\n"],"names":["contextCommand","StartSyncCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,mBAAmBD,eAAe,wBAAuB"}
@@ -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 ConfirmSyncCommand = contextCommand('context sources syncs confirm');
4
+
5
+ //# sourceMappingURL=confirm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/context/sources/syncs/confirm.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../../actions/context/contextCommand.js'\n\nexport const ConfirmSyncCommand = contextCommand('context sources syncs confirm')\n"],"names":["contextCommand","ConfirmSyncCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,gDAA+C;AAE5E,OAAO,MAAMC,qBAAqBD,eAAe,iCAAgC"}
@@ -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 DiscardSyncCommand = contextCommand('context sources syncs discard');
4
+
5
+ //# sourceMappingURL=discard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/context/sources/syncs/discard.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../../actions/context/contextCommand.js'\n\nexport const DiscardSyncCommand = contextCommand('context sources syncs discard')\n"],"names":["contextCommand","DiscardSyncCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,gDAA+C;AAE5E,OAAO,MAAMC,qBAAqBD,eAAe,iCAAgC"}
@@ -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 GetSyncCommand = contextCommand('context sources syncs get');
4
+
5
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/context/sources/syncs/get.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../../actions/context/contextCommand.js'\n\nexport const GetSyncCommand = contextCommand('context sources syncs get')\n"],"names":["contextCommand","GetSyncCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,gDAA+C;AAE5E,OAAO,MAAMC,iBAAiBD,eAAe,6BAA4B"}
@@ -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 ListSyncsCommand = contextCommand('context sources syncs list');
4
+
5
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/commands/context/sources/syncs/list.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../../actions/context/contextCommand.js'\n\nexport const ListSyncsCommand = contextCommand('context sources syncs list')\n"],"names":["contextCommand","ListSyncsCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,gDAA+C;AAE5E,OAAO,MAAMC,mBAAmBD,eAAe,8BAA6B"}
@@ -0,0 +1,63 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { exitCodes } from '@sanity/cli-core';
3
+ import { getErrorMessage } from '@sanity/cli-core/errors';
4
+ import { contextCommand } from '../../../actions/context/contextCommand.js';
5
+ import { readSourceFile } from '../../../actions/context/sourceFile.js';
6
+ import { uploadSourceFile } from '../../../services/context.js';
7
+ import { defineCommandTelemetry } from '../../../util/telemetry/commandTelemetry.js';
8
+ const BaseCommand = contextCommand('context sources upload');
9
+ const flags = {
10
+ ...BaseCommand.flags,
11
+ 'content-type': Flags.string({
12
+ description: 'MIME type of the file, inferred from the file extension when omitted',
13
+ helpValue: '<type>'
14
+ }),
15
+ file: Flags.string({
16
+ description: 'Local file to upload: a document, or a zip, tar or gzip archive of them',
17
+ helpValue: '<path>',
18
+ required: true
19
+ })
20
+ };
21
+ /**
22
+ * `context sources upload` reads a local file and hands it to the client's
23
+ * upload helper, which stages the upload, PUTs the bytes to the signed URL and
24
+ * syncs the source. The spec's `startSourceUpload` only stages it.
25
+ */ export class UploadSourceFileCommand extends BaseCommand {
26
+ static description = 'Upload a new file to a files source, replacing the one it holds, and sync it';
27
+ static examples = [
28
+ {
29
+ command: '<%= config.bin %> <%= command.id %> kb-abc123 source-def456 --file ./handbook.pdf',
30
+ description: 'Replace the file a source holds'
31
+ },
32
+ {
33
+ command: '<%= config.bin %> <%= command.id %> kb-abc123 source-def456 --file ./handbook.pdf --watch',
34
+ description: 'Replace the file and wait for its sync to finish'
35
+ }
36
+ ];
37
+ static flags = flags;
38
+ static telemetry = {
39
+ redactedFlags: [
40
+ ...BaseCommand.telemetry.redactedFlags,
41
+ ...defineCommandTelemetry(flags, {
42
+ redact: [
43
+ 'file'
44
+ ]
45
+ }).redactedFlags
46
+ ]
47
+ };
48
+ async send(request, values) {
49
+ const file = String(values.file);
50
+ const contentType = typeof values['content-type'] === 'string' ? values['content-type'] : undefined;
51
+ let upload;
52
+ try {
53
+ upload = await readSourceFile(file, contentType);
54
+ } catch (error) {
55
+ this.error(`Failed to read file "${file}": ${getErrorMessage(error)}`, {
56
+ exit: exitCodes.RUNTIME_ERROR
57
+ });
58
+ }
59
+ return uploadSourceFile(request.params.knowledgeBaseId, request.params.sourceId, upload);
60
+ }
61
+ }
62
+
63
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/commands/context/sources/upload.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\nimport {exitCodes} from '@sanity/cli-core'\nimport {getErrorMessage} from '@sanity/cli-core/errors'\n\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\nimport {type OperationRequest} from '../../../actions/context/operationInput.js'\nimport {readSourceFile} from '../../../actions/context/sourceFile.js'\nimport {uploadSourceFile} from '../../../services/context.js'\nimport {defineCommandTelemetry} from '../../../util/telemetry/commandTelemetry.js'\n\nconst BaseCommand = contextCommand('context sources upload')\n\nconst flags = {\n ...BaseCommand.flags,\n 'content-type': Flags.string({\n description: 'MIME type of the file, inferred from the file extension when omitted',\n helpValue: '<type>',\n }),\n file: Flags.string({\n description: 'Local file to upload: a document, or a zip, tar or gzip archive of them',\n helpValue: '<path>',\n required: true,\n }),\n} satisfies FlagInput\n\n/**\n * `context sources upload` reads a local file and hands it to the client's\n * upload helper, which stages the upload, PUTs the bytes to the signed URL and\n * syncs the source. The spec's `startSourceUpload` only stages it.\n */\nexport class UploadSourceFileCommand extends BaseCommand {\n static override description =\n 'Upload a new file to a files source, replacing the one it holds, and sync it'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 source-def456 --file ./handbook.pdf',\n description: 'Replace the file a source holds',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> kb-abc123 source-def456 --file ./handbook.pdf --watch',\n description: 'Replace the file and wait for its sync to finish',\n },\n ]\n\n static override flags = flags\n\n static override telemetry = {\n redactedFlags: [\n ...BaseCommand.telemetry.redactedFlags,\n ...defineCommandTelemetry(flags, {redact: ['file']}).redactedFlags,\n ],\n }\n\n public override async send(\n request: OperationRequest,\n values: Record<string, unknown>,\n ): Promise<unknown> {\n const file = String(values.file)\n const contentType =\n typeof values['content-type'] === 'string' ? values['content-type'] : undefined\n let upload\n try {\n upload = await readSourceFile(file, contentType)\n } catch (error) {\n this.error(`Failed to read file \"${file}\": ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n return uploadSourceFile(request.params.knowledgeBaseId, request.params.sourceId, upload)\n }\n}\n"],"names":["Flags","exitCodes","getErrorMessage","contextCommand","readSourceFile","uploadSourceFile","defineCommandTelemetry","BaseCommand","flags","string","description","helpValue","file","required","UploadSourceFileCommand","examples","command","telemetry","redactedFlags","redact","send","request","values","String","contentType","undefined","upload","error","exit","RUNTIME_ERROR","params","knowledgeBaseId","sourceId"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAEjC,SAAQC,SAAS,QAAO,mBAAkB;AAC1C,SAAQC,eAAe,QAAO,0BAAyB;AAEvD,SAAQC,cAAc,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ILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
2
+ import { contextCommand } from '../../actions/context/contextCommand.js';
3
+ export const SyncAllSourcesCommand = contextCommand('context sync');
4
+
5
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/commands/context/sync.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../actions/context/contextCommand.js'\n\nexport const SyncAllSourcesCommand = contextCommand('context sync')\n"],"names":["contextCommand","SyncAllSourcesCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,0CAAyC;AAEtE,OAAO,MAAMC,wBAAwBD,eAAe,gBAAe"}
@@ -1,138 +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 { describeBlueprintManager, getKnowledgeBaseBlueprintOwnership, updateKnowledgeBase } from '../../services/context.js';
7
- import { defineCommandTelemetry } from '../../util/telemetry/commandTelemetry.js';
8
- const updateContextDebug = subdebug('context:update');
9
- const UPDATE_FLAGS = [
10
- 'title',
11
- 'description',
12
- 'refresh-enabled',
13
- 'refresh-frequency'
14
- ];
15
- const flags = {
16
- description: Flags.string({
17
- atLeastOne: [
18
- ...UPDATE_FLAGS
19
- ],
20
- description: 'New knowledge base description',
21
- required: false
22
- }),
23
- 'refresh-enabled': Flags.boolean({
24
- allowNo: true,
25
- atLeastOne: [
26
- ...UPDATE_FLAGS
27
- ],
28
- description: 'Enable scheduled refresh (--no-refresh-enabled to disable)',
29
- required: false
30
- }),
31
- 'refresh-frequency': Flags.custom({
32
- atLeastOne: [
33
- ...UPDATE_FLAGS
34
- ],
35
- description: 'How often scheduled refresh runs',
36
- options: [
37
- 'weekly',
38
- 'monthly'
39
- ],
40
- required: false
41
- })(),
42
- title: Flags.string({
43
- atLeastOne: [
44
- ...UPDATE_FLAGS
45
- ],
46
- description: 'New knowledge base title',
47
- required: false
48
- })
49
- };
50
- export class UpdateKnowledgeBaseCommand extends SanityCommand {
51
- static args = {
52
- knowledgeBaseId: Args.string({
53
- description: 'Knowledge base ID',
54
- required: true
55
- })
56
- };
57
- static description = 'Update a knowledge base';
58
- static examples = [
59
- {
60
- command: '<%= config.bin %> <%= command.id %> kb-abc123 --title "New title"',
61
- description: 'Rename a knowledge base'
62
- },
63
- {
64
- command: '<%= config.bin %> <%= command.id %> kb-abc123 --refresh-enabled --refresh-frequency weekly',
65
- description: 'Enable weekly scheduled refresh'
66
- },
67
- {
68
- command: '<%= config.bin %> <%= command.id %> kb-abc123 --no-refresh-enabled',
69
- description: 'Disable scheduled refresh'
70
- }
71
- ];
72
- static flags = flags;
73
- static telemetry = defineCommandTelemetry(flags, {
74
- redact: [
75
- 'title',
76
- 'description'
77
- ]
78
- });
79
- async run() {
80
- const { knowledgeBaseId } = this.args;
81
- const { description, 'refresh-enabled': refreshEnabled, 'refresh-frequency': refreshFrequency, title } = this.flags;
82
- const params = {};
83
- if (title !== undefined) {
84
- const trimmedTitle = title.trim();
85
- if (trimmedTitle === '') {
86
- this.error('Title cannot be empty', {
87
- exit: exitCodes.USAGE_ERROR
88
- });
89
- }
90
- params.title = trimmedTitle;
91
- }
92
- if (description !== undefined) {
93
- const trimmedDescription = description.trim();
94
- if (trimmedDescription === '') {
95
- this.error('Description cannot be empty', {
96
- exit: exitCodes.USAGE_ERROR
97
- });
98
- }
99
- params.description = trimmedDescription;
100
- }
101
- if (refreshEnabled !== undefined) {
102
- params.refreshEnabled = refreshEnabled;
103
- }
104
- if (refreshFrequency !== undefined) {
105
- params.refreshFrequency = refreshFrequency;
106
- }
107
- const changesBlueprintFields = params.title !== undefined || params.description !== undefined;
108
- const ownership = changesBlueprintFields ? await getKnowledgeBaseBlueprintOwnership(knowledgeBaseId) : {
109
- managed: false
110
- };
111
- if (ownership.managed) {
112
- const manager = describeBlueprintManager(ownership.stackName);
113
- const refreshHint = params.refreshEnabled === undefined && params.refreshFrequency === undefined ? '' : ' Refresh settings are not managed by the blueprint, so you can change them without `--title` and `--description`.';
114
- this.error(`${manager} manages the title and description of knowledge base "${knowledgeBaseId}", so the next deploy would undo this change. Change them in the blueprint and run \`sanity blueprints deploy\` instead.${refreshHint}`, {
115
- exit: exitCodes.USAGE_ERROR
116
- });
117
- }
118
- const spin = spinner('Updating knowledge base').start();
119
- try {
120
- await updateKnowledgeBase(knowledgeBaseId, params);
121
- spin.succeed();
122
- this.log('Knowledge base updated');
123
- } catch (error) {
124
- spin.fail();
125
- updateContextDebug('Error updating knowledge base', error);
126
- if (isHttpError(error) && error.statusCode === 404) {
127
- this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
128
- exit: exitCodes.RUNTIME_ERROR
129
- });
130
- }
131
- this.error(`Failed to update knowledge base: ${getErrorMessage(error)}`, {
132
- exit: exitCodes.RUNTIME_ERROR
133
- });
134
- }
135
- }
136
- }
1
+ // GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
2
+ import { contextCommand } from '../../actions/context/contextCommand.js';
3
+ export const UpdateKnowledgeBaseCommand = contextCommand('context update');
137
4
 
138
5
  //# sourceMappingURL=update.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/commands/context/update.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 {type Context, isHttpError} from '@sanity/client'\n\nimport {\n type BlueprintOwnership,\n describeBlueprintManager,\n getKnowledgeBaseBlueprintOwnership,\n updateKnowledgeBase,\n} from '../../services/context.js'\nimport {defineCommandTelemetry} from '../../util/telemetry/commandTelemetry.js'\n\nconst updateContextDebug = subdebug('context:update')\n\nconst UPDATE_FLAGS = ['title', 'description', 'refresh-enabled', 'refresh-frequency'] as const\n\nconst flags = {\n description: Flags.string({\n atLeastOne: [...UPDATE_FLAGS],\n description: 'New knowledge base description',\n required: false,\n }),\n 'refresh-enabled': Flags.boolean({\n allowNo: true,\n atLeastOne: [...UPDATE_FLAGS],\n description: 'Enable scheduled refresh (--no-refresh-enabled to disable)',\n required: false,\n }),\n 'refresh-frequency': Flags.custom<'monthly' | 'weekly'>({\n atLeastOne: [...UPDATE_FLAGS],\n description: 'How often scheduled refresh runs',\n options: ['weekly', 'monthly'],\n required: false,\n })(),\n title: Flags.string({\n atLeastOne: [...UPDATE_FLAGS],\n description: 'New knowledge base title',\n required: false,\n }),\n} satisfies FlagInput\n\nexport class UpdateKnowledgeBaseCommand extends SanityCommand<typeof UpdateKnowledgeBaseCommand> {\n static override args = {\n knowledgeBaseId: Args.string({\n description: 'Knowledge base ID',\n required: true,\n }),\n }\n\n static override description = 'Update a knowledge base'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --title \"New title\"',\n description: 'Rename a knowledge base',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> kb-abc123 --refresh-enabled --refresh-frequency weekly',\n description: 'Enable weekly scheduled refresh',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --no-refresh-enabled',\n description: 'Disable scheduled refresh',\n },\n ]\n\n static override flags = flags\n\n static telemetry = defineCommandTelemetry(flags, {\n redact: ['title', 'description'],\n })\n\n public async run(): Promise<void> {\n const {knowledgeBaseId} = this.args\n const {\n description,\n 'refresh-enabled': refreshEnabled,\n 'refresh-frequency': refreshFrequency,\n title,\n } = this.flags\n\n const params: Context.EditKnowledgeBaseParams = {}\n if (title !== undefined) {\n const trimmedTitle = title.trim()\n if (trimmedTitle === '') {\n this.error('Title cannot be empty', {exit: exitCodes.USAGE_ERROR})\n }\n params.title = trimmedTitle\n }\n if (description !== undefined) {\n const trimmedDescription = description.trim()\n if (trimmedDescription === '') {\n this.error('Description cannot be empty', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n params.description = trimmedDescription\n }\n if (refreshEnabled !== undefined) {\n params.refreshEnabled = refreshEnabled\n }\n if (refreshFrequency !== undefined) {\n params.refreshFrequency = refreshFrequency\n }\n\n const changesBlueprintFields = params.title !== undefined || params.description !== undefined\n const ownership: BlueprintOwnership = changesBlueprintFields\n ? await getKnowledgeBaseBlueprintOwnership(knowledgeBaseId)\n : {managed: false}\n if (ownership.managed) {\n const manager = describeBlueprintManager(ownership.stackName)\n const refreshHint =\n params.refreshEnabled === undefined && params.refreshFrequency === undefined\n ? ''\n : ' Refresh settings are not managed by the blueprint, so you can change them without `--title` and `--description`.'\n this.error(\n `${manager} manages the title and description of knowledge base \"${knowledgeBaseId}\", so the next deploy would undo this change. Change them in the blueprint and run \\`sanity blueprints deploy\\` instead.${refreshHint}`,\n {exit: exitCodes.USAGE_ERROR},\n )\n }\n\n const spin = spinner('Updating knowledge base').start()\n try {\n await updateKnowledgeBase(knowledgeBaseId, params)\n spin.succeed()\n this.log('Knowledge base updated')\n } catch (error) {\n spin.fail()\n updateContextDebug('Error updating 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 update knowledge base: ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n }\n}\n"],"names":["Args","Flags","exitCodes","SanityCommand","subdebug","getErrorMessage","spinner","isHttpError","describeBlueprintManager","getKnowledgeBaseBlueprintOwnership","updateKnowledgeBase","defineCommandTelemetry","updateContextDebug","UPDATE_FLAGS","flags","description","string","atLeastOne","required","boolean","allowNo","custom","options","title","UpdateKnowledgeBaseCommand","args","knowledgeBaseId","examples","command","telemetry","redact","run","refreshEnabled","refreshFrequency","params","undefined","trimmedTitle","trim","error","exit","USAGE_ERROR","trimmedDescription","changesBlueprintFields","ownership","managed","manager","stackName","refreshHint","spin","start","succeed","log","fail","statusCode","RUNTIME_ERROR"],"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,SAAsBC,WAAW,QAAO,iBAAgB;AAExD,SAEEC,wBAAwB,EACxBC,kCAAkC,EAClCC,mBAAmB,QACd,4BAA2B;AAClC,SAAQC,sBAAsB,QAAO,2CAA0C;AAE/E,MAAMC,qBAAqBR,SAAS;AAEpC,MAAMS,eAAe;IAAC;IAAS;IAAe;IAAmB;CAAoB;AAErF,MAAMC,QAAQ;IACZC,aAAad,MAAMe,MAAM,CAAC;QACxBC,YAAY;eAAIJ;SAAa;QAC7BE,aAAa;QACbG,UAAU;IACZ;IACA,mBAAmBjB,MAAMkB,OAAO,CAAC;QAC/BC,SAAS;QACTH,YAAY;eAAIJ;SAAa;QAC7BE,aAAa;QACbG,UAAU;IACZ;IACA,qBAAqBjB,MAAMoB,MAAM,CAAuB;QACtDJ,YAAY;eAAIJ;SAAa;QAC7BE,aAAa;QACbO,SAAS;YAAC;YAAU;SAAU;QAC9BJ,UAAU;IACZ;IACAK,OAAOtB,MAAMe,MAAM,CAAC;QAClBC,YAAY;eAAIJ;SAAa;QAC7BE,aAAa;QACbG,UAAU;IACZ;AACF;AAEA,OAAO,MAAMM,mCAAmCrB;IAC9C,OAAgBsB,OAAO;QACrBC,iBAAiB1B,KAAKgB,MAAM,CAAC;YAC3BD,aAAa;YACbG,UAAU;QACZ;IACF,EAAC;IAED,OAAgBH,cAAc,0BAAyB;IAEvD,OAAgBY,WAAW;QACzB;YACEC,SAAS;YACTb,aAAa;QACf;QACA;YACEa,SACE;YACFb,aAAa;QACf;QACA;YACEa,SAAS;YACTb,aAAa;QACf;KACD,CAAA;IAED,OAAgB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gBAAgB,wHAAwH,EAAEqB,aAAa,EAC1N;gBAACR,MAAMrC,UAAUsC,WAAW;YAAA;QAEhC;QAEA,MAAMQ,OAAO1C,QAAQ,2BAA2B2C,KAAK;QACrD,IAAI;YACF,MAAMvC,oBAAoBgB,iBAAiBQ;YAC3Cc,KAAKE,OAAO;YACZ,IAAI,CAACC,GAAG,CAAC;QACX,EAAE,OAAOb,OAAO;YACdU,KAAKI,IAAI;YACTxC,mBAAmB,iCAAiC0B;YACpD,IAAI/B,YAAY+B,UAAUA,MAAMe,UAAU,KAAK,KAAK;gBAClD,IAAI,CAACf,KAAK,CAAC,CAAC,gBAAgB,EAAEZ,gBAAgB,WAAW,CAAC,EAAE;oBAC1Da,MAAMrC,UAAUoD,aAAa;gBAC/B;YACF;YACA,IAAI,CAAChB,KAAK,CAAC,CAAC,iCAAiC,EAAEjC,gBAAgBiC,QAAQ,EAAE;gBACvEC,MAAMrC,UAAUoD,aAAa;YAC/B;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/commands/context/update.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../actions/context/contextCommand.js'\n\nexport const UpdateKnowledgeBaseCommand = contextCommand('context update')\n"],"names":["contextCommand","UpdateKnowledgeBaseCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,0CAAyC;AAEtE,OAAO,MAAMC,6BAA6BD,eAAe,kBAAiB"}