@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.
- package/README.md +1534 -411
- package/dist/actions/context/commandTable.js +215 -0
- package/dist/actions/context/commandTable.js.map +1 -0
- package/dist/actions/context/contextCommand.js +246 -0
- package/dist/actions/context/contextCommand.js.map +1 -0
- package/dist/actions/context/contextSpec.js +18 -0
- package/dist/actions/context/contextSpec.js.map +1 -0
- package/dist/actions/context/distillContextOperations.js +335 -0
- package/dist/actions/context/distillContextOperations.js.map +1 -0
- package/dist/actions/context/mcpEndpoint.js +165 -0
- package/dist/actions/context/mcpEndpoint.js.map +1 -0
- package/dist/actions/context/operationInput.js +226 -0
- package/dist/actions/context/operationInput.js.map +1 -0
- package/dist/actions/context/operationTypes.js +3 -0
- package/dist/actions/context/operationTypes.js.map +1 -0
- package/dist/actions/context/removedCommands.js +26 -0
- package/dist/actions/context/removedCommands.js.map +1 -0
- package/dist/actions/context/renderOperationResult.js +72 -0
- package/dist/actions/context/renderOperationResult.js.map +1 -0
- package/dist/actions/context/resolveOrganizationId.js +8 -1
- package/dist/actions/context/resolveOrganizationId.js.map +1 -1
- package/dist/actions/context/sourceFile.js +31 -0
- package/dist/actions/context/sourceFile.js.map +1 -0
- package/dist/actions/context/syncOutput.js +17 -0
- package/dist/actions/context/syncOutput.js.map +1 -0
- package/dist/actions/context/table.js +13 -0
- package/dist/actions/context/table.js.map +1 -0
- package/dist/actions/context/waitForJob.js.map +1 -1
- package/dist/actions/context/waitForSourceSync.js +48 -0
- package/dist/actions/context/waitForSourceSync.js.map +1 -0
- package/dist/actions/context/watchJob.js.map +1 -1
- package/dist/actions/context/watchSourceSync.js +40 -0
- package/dist/actions/context/watchSourceSync.js.map +1 -0
- package/dist/commands/context/build.js +19 -81
- package/dist/commands/context/build.js.map +1 -1
- package/dist/commands/context/create.js +3 -104
- package/dist/commands/context/create.js.map +1 -1
- package/dist/commands/context/delete.js +3 -73
- package/dist/commands/context/delete.js.map +1 -1
- package/dist/commands/context/documents/content.js +117 -0
- package/dist/commands/context/documents/content.js.map +1 -0
- package/dist/commands/context/documents/delete.js +5 -0
- package/dist/commands/context/documents/delete.js.map +1 -0
- package/dist/commands/context/documents/edit.js +5 -0
- package/dist/commands/context/documents/edit.js.map +1 -0
- package/dist/commands/context/documents/get.js +5 -0
- package/dist/commands/context/documents/get.js.map +1 -0
- package/dist/commands/context/documents/list.js +5 -0
- package/dist/commands/context/documents/list.js.map +1 -0
- package/dist/commands/context/entries/list.js +2 -2
- package/dist/commands/context/entries/list.js.map +1 -1
- package/dist/commands/context/entries/rebuild.js +3 -93
- package/dist/commands/context/entries/rebuild.js.map +1 -1
- package/dist/commands/context/get.js +3 -88
- package/dist/commands/context/get.js.map +1 -1
- package/dist/commands/context/instructions/create.js +5 -0
- package/dist/commands/context/instructions/create.js.map +1 -0
- package/dist/commands/context/instructions/delete.js +5 -0
- package/dist/commands/context/instructions/delete.js.map +1 -0
- package/dist/commands/context/instructions/edit.js +5 -0
- package/dist/commands/context/instructions/edit.js.map +1 -0
- package/dist/commands/context/issues/apply.js +3 -84
- package/dist/commands/context/issues/apply.js.map +1 -1
- package/dist/commands/context/issues/dismiss.js +3 -50
- package/dist/commands/context/issues/dismiss.js.map +1 -1
- package/dist/commands/context/issues/list.js +0 -5
- package/dist/commands/context/issues/list.js.map +1 -1
- package/dist/commands/context/issues/reopen.js +3 -51
- package/dist/commands/context/issues/reopen.js.map +1 -1
- package/dist/commands/context/issues/resolve.js +23 -92
- package/dist/commands/context/issues/resolve.js.map +1 -1
- package/dist/commands/context/jobs/get.js +3 -88
- package/dist/commands/context/jobs/get.js.map +1 -1
- package/dist/commands/context/list.js +3 -103
- package/dist/commands/context/list.js.map +1 -1
- package/dist/commands/context/mcp/create.js +152 -0
- package/dist/commands/context/mcp/create.js.map +1 -0
- package/dist/commands/context/mcp/delete.js +82 -0
- package/dist/commands/context/mcp/delete.js.map +1 -0
- package/dist/commands/context/mcp/get.js +42 -0
- package/dist/commands/context/mcp/get.js.map +1 -0
- package/dist/commands/context/mcp/initial-context.js +5 -0
- package/dist/commands/context/mcp/initial-context.js.map +1 -0
- package/dist/commands/context/mcp/list.js +87 -0
- package/dist/commands/context/mcp/list.js.map +1 -0
- package/dist/commands/context/mcp/status.js +98 -0
- package/dist/commands/context/mcp/status.js.map +1 -0
- package/dist/commands/context/mcp/update.js +225 -0
- package/dist/commands/context/mcp/update.js.map +1 -0
- package/dist/commands/context/query.js +6 -14
- package/dist/commands/context/query.js.map +1 -1
- package/dist/commands/context/sources/create.js +175 -0
- package/dist/commands/context/sources/create.js.map +1 -0
- package/dist/commands/context/sources/delete.js +5 -0
- package/dist/commands/context/sources/delete.js.map +1 -0
- package/dist/commands/context/sources/edit.js +29 -0
- package/dist/commands/context/sources/edit.js.map +1 -0
- package/dist/commands/context/sources/get.js +5 -0
- package/dist/commands/context/sources/get.js.map +1 -0
- package/dist/commands/context/sources/list.js +5 -0
- package/dist/commands/context/sources/list.js.map +1 -0
- package/dist/commands/context/sources/sync.js +5 -0
- package/dist/commands/context/sources/sync.js.map +1 -0
- package/dist/commands/context/sources/syncs/confirm.js +5 -0
- package/dist/commands/context/sources/syncs/confirm.js.map +1 -0
- package/dist/commands/context/sources/syncs/discard.js +5 -0
- package/dist/commands/context/sources/syncs/discard.js.map +1 -0
- package/dist/commands/context/sources/syncs/get.js +5 -0
- package/dist/commands/context/sources/syncs/get.js.map +1 -0
- package/dist/commands/context/sources/syncs/list.js +5 -0
- package/dist/commands/context/sources/syncs/list.js.map +1 -0
- package/dist/commands/context/sources/upload.js +63 -0
- package/dist/commands/context/sources/upload.js.map +1 -0
- package/dist/commands/context/sync.js +5 -0
- package/dist/commands/context/sync.js.map +1 -0
- package/dist/commands/context/update.js +3 -136
- package/dist/commands/context/update.js.map +1 -1
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js +47 -26
- package/dist/exports/invokeSanityCli/commandPolicies/mcpPolicy.js.map +1 -1
- package/dist/generated/apiRoutes.js +28 -0
- package/dist/generated/apiRoutes.js.map +1 -1
- package/dist/generated/contextOperations.js +1116 -0
- package/dist/generated/contextOperations.js.map +1 -0
- package/dist/hooks/commandNotFound/topicAliases.js +8 -2
- package/dist/hooks/commandNotFound/topicAliases.js.map +1 -1
- package/dist/prompts/promptForText.js +12 -0
- package/dist/prompts/promptForText.js.map +1 -0
- package/dist/services/context.js +276 -202
- package/dist/services/context.js.map +1 -1
- package/dist/util/sharedFlags.js.map +1 -1
- package/dist/util/telemetry/cliCommandIdentity.js +16 -18
- package/dist/util/telemetry/cliCommandIdentity.js.map +1 -1
- package/oclif.config.js +1 -1
- package/oclif.manifest.json +4854 -2834
- package/package.json +20 -19
- package/templates/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/app-quickstart/AGENTS.md +49 -0
- package/templates/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/app-sanity-ui/AGENTS.md +49 -0
- package/templates/shared/dashboard/app-quickstart/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/shared/dashboard/app-quickstart/AGENTS.md +49 -0
- package/templates/shared/dashboard/app-sanity-ui/.claude/skills/sanity-app-sdk/SKILL.md +49 -0
- package/templates/shared/dashboard/app-sanity-ui/AGENTS.md +49 -0
- package/dist/commands/context/imports/create.js +0 -270
- package/dist/commands/context/imports/create.js.map +0 -1
- package/dist/commands/context/imports/delete.js +0 -73
- package/dist/commands/context/imports/delete.js.map +0 -1
- package/dist/commands/context/imports/download.js +0 -60
- package/dist/commands/context/imports/download.js.map +0 -1
- package/dist/commands/context/imports/get.js +0 -88
- package/dist/commands/context/imports/get.js.map +0 -1
- package/dist/commands/context/imports/list.js +0 -100
- package/dist/commands/context/imports/list.js.map +0 -1
- package/dist/commands/context/refresh.js +0 -46
- package/dist/commands/context/refresh.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spinner } from '@sanity/cli-core/ux';
|
|
2
|
+
import { waitForSourceSync } from './waitForSourceSync.js';
|
|
3
|
+
/**
|
|
4
|
+
* Error message for a sync that failed or was cancelled, e.g. "Sync failed: <reason>"
|
|
5
|
+
*/ export function formatSyncFailure(sync) {
|
|
6
|
+
return `Sync ${sync.status}${sync.error ? `: ${sync.error}` : ''}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Watch a source with a spinner until a sync newer than `previousSyncId`
|
|
10
|
+
* settles, updating the spinner text with the sync status on each poll.
|
|
11
|
+
*
|
|
12
|
+
* Fails the spinner and rethrows on polling errors. A completed sync succeeds
|
|
13
|
+
* the spinner, a held one warns, and a failed or cancelled one fails it;
|
|
14
|
+
* turning the outcome into a command error (and exit code) is the caller's
|
|
15
|
+
* responsibility.
|
|
16
|
+
*/ export async function watchSourceSync(knowledgeBaseId, sourceId, target) {
|
|
17
|
+
const label = 'Syncing source';
|
|
18
|
+
const spin = spinner(label).start();
|
|
19
|
+
let sync;
|
|
20
|
+
try {
|
|
21
|
+
sync = await waitForSourceSync(knowledgeBaseId, sourceId, target, {
|
|
22
|
+
onPoll: (pending)=>{
|
|
23
|
+
spin.text = `${label} (${pending?.status ?? 'waiting to start'})`;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
} catch (error) {
|
|
27
|
+
spin.fail(label);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
if (sync.status === 'completed') {
|
|
31
|
+
spin.succeed('Sync completed');
|
|
32
|
+
} else if (sync.status === 'held') {
|
|
33
|
+
spin.warn('Sync held for confirmation');
|
|
34
|
+
} else {
|
|
35
|
+
spin.fail(label);
|
|
36
|
+
}
|
|
37
|
+
return sync;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=watchSourceSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/context/watchSourceSync.ts"],"sourcesContent":["import {spinner} from '@sanity/cli-core/ux'\n\nimport {type Sync} from '../../services/context.js'\nimport {type SyncTarget, waitForSourceSync} from './waitForSourceSync.js'\n\n/**\n * Error message for a sync that failed or was cancelled, e.g. \"Sync failed: <reason>\"\n */\nexport function formatSyncFailure(sync: Sync): string {\n return `Sync ${sync.status}${sync.error ? `: ${sync.error}` : ''}`\n}\n\n/**\n * Watch a source with a spinner until a sync newer than `previousSyncId`\n * settles, updating the spinner text with the sync status on each poll.\n *\n * Fails the spinner and rethrows on polling errors. A completed sync succeeds\n * the spinner, a held one warns, and a failed or cancelled one fails it;\n * turning the outcome into a command error (and exit code) is the caller's\n * responsibility.\n */\nexport async function watchSourceSync(\n knowledgeBaseId: string,\n sourceId: string,\n target: SyncTarget,\n): Promise<Sync> {\n const label = 'Syncing source'\n const spin = spinner(label).start()\n\n let sync: Sync\n try {\n sync = await waitForSourceSync(knowledgeBaseId, sourceId, target, {\n onPoll: (pending) => {\n spin.text = `${label} (${pending?.status ?? 'waiting to start'})`\n },\n })\n } catch (error) {\n spin.fail(label)\n throw error\n }\n\n if (sync.status === 'completed') {\n spin.succeed('Sync completed')\n } else if (sync.status === 'held') {\n spin.warn('Sync held for confirmation')\n } else {\n spin.fail(label)\n }\n\n return sync\n}\n"],"names":["spinner","waitForSourceSync","formatSyncFailure","sync","status","error","watchSourceSync","knowledgeBaseId","sourceId","target","label","spin","start","onPoll","pending","text","fail","succeed","warn"],"mappings":"AAAA,SAAQA,OAAO,QAAO,sBAAqB;AAG3C,SAAyBC,iBAAiB,QAAO,yBAAwB;AAEzE;;CAEC,GACD,OAAO,SAASC,kBAAkBC,IAAU;IAC1C,OAAO,CAAC,KAAK,EAAEA,KAAKC,MAAM,GAAGD,KAAKE,KAAK,GAAG,CAAC,EAAE,EAAEF,KAAKE,KAAK,EAAE,GAAG,IAAI;AACpE;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeC,gBACpBC,eAAuB,EACvBC,QAAgB,EAChBC,MAAkB;IAElB,MAAMC,QAAQ;IACd,MAAMC,OAAOX,QAAQU,OAAOE,KAAK;IAEjC,IAAIT;IACJ,IAAI;QACFA,OAAO,MAAMF,kBAAkBM,iBAAiBC,UAAUC,QAAQ;YAChEI,QAAQ,CAACC;gBACPH,KAAKI,IAAI,GAAG,GAAGL,MAAM,EAAE,EAAEI,SAASV,UAAU,mBAAmB,CAAC,CAAC;YACnE;QACF;IACF,EAAE,OAAOC,OAAO;QACdM,KAAKK,IAAI,CAACN;QACV,MAAML;IACR;IAEA,IAAIF,KAAKC,MAAM,KAAK,aAAa;QAC/BO,KAAKM,OAAO,CAAC;IACf,OAAO,IAAId,KAAKC,MAAM,KAAK,QAAQ;QACjCO,KAAKO,IAAI,CAAC;IACZ,OAAO;QACLP,KAAKK,IAAI,CAACN;IACZ;IAEA,OAAOP;AACT"}
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const buildContextDebug = subdebug('context:build');
|
|
10
|
-
export class BuildKnowledgeBaseCommand extends SanityCommand {
|
|
11
|
-
static args = {
|
|
12
|
-
knowledgeBaseId: Args.string({
|
|
13
|
-
description: 'Knowledge base ID',
|
|
14
|
-
required: true
|
|
15
|
-
})
|
|
16
|
-
};
|
|
17
|
-
static description = 'Build a knowledge base from its imported content';
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { contextCommand } from '../../actions/context/contextCommand.js';
|
|
3
|
+
import { requestContext } from '../../services/context.js';
|
|
4
|
+
const BaseCommand = contextCommand('context build');
|
|
5
|
+
/**
|
|
6
|
+
* `context build` keeps `--cancel`, which calls the cancel operation instead
|
|
7
|
+
* of starting a build
|
|
8
|
+
*/ export class BuildKnowledgeBaseCommand extends BaseCommand {
|
|
18
9
|
static examples = [
|
|
19
10
|
{
|
|
20
11
|
command: '<%= config.bin %> <%= command.id %> kb-abc123',
|
|
@@ -30,81 +21,28 @@ export class BuildKnowledgeBaseCommand extends SanityCommand {
|
|
|
30
21
|
}
|
|
31
22
|
];
|
|
32
23
|
static flags = {
|
|
24
|
+
...BaseCommand.flags,
|
|
33
25
|
cancel: Flags.boolean({
|
|
34
26
|
default: false,
|
|
35
27
|
description: 'Cancel the running build instead of starting one',
|
|
36
28
|
exclusive: [
|
|
37
29
|
'watch'
|
|
38
30
|
]
|
|
39
|
-
}),
|
|
40
|
-
watch: Flags.boolean({
|
|
41
|
-
default: false,
|
|
42
|
-
description: 'Wait for the build to finish, exiting non-zero if it fails'
|
|
43
31
|
})
|
|
44
32
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (cancel) {
|
|
49
|
-
await this.cancelBuild(knowledgeBaseId);
|
|
33
|
+
render(result) {
|
|
34
|
+
if (!this.flags.cancel || this.flags.json) {
|
|
35
|
+
super.render(result);
|
|
50
36
|
return;
|
|
51
37
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const accepted = await buildKnowledgeBase(knowledgeBaseId);
|
|
56
|
-
jobId = accepted.jobId;
|
|
57
|
-
spin.succeed('Build started');
|
|
58
|
-
} catch (error) {
|
|
59
|
-
spin.fail();
|
|
60
|
-
buildContextDebug('Error starting build', error);
|
|
61
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
62
|
-
this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
|
|
63
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
this.error(`Failed to start build: ${getErrorMessage(error)}`, {
|
|
67
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
this.log(formatKeyValue('Job ID', jobId));
|
|
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: 'Building knowledge base',
|
|
79
|
-
successText: 'Build succeeded'
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
buildContextDebug('Error watching build job', error);
|
|
83
|
-
this.error(`Failed to watch build job: ${getErrorMessage(error)}`, {
|
|
84
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (job.status !== 'succeeded') {
|
|
88
|
-
this.error(formatJobFailure('Build', job), {
|
|
89
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
90
|
-
});
|
|
91
|
-
}
|
|
38
|
+
const cancelled = typeof result === 'object' && result !== null && 'cancelled' in result;
|
|
39
|
+
this.log(cancelled && result.cancelled ? 'Build cancelled' : 'No running build to cancel');
|
|
92
40
|
}
|
|
93
|
-
async
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
buildContextDebug('Error cancelling build', error);
|
|
99
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
100
|
-
this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
|
|
101
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
this.error(`Failed to cancel build: ${getErrorMessage(error)}`, {
|
|
105
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
106
|
-
});
|
|
107
|
-
}
|
|
41
|
+
async send(request, flags) {
|
|
42
|
+
if (!flags.cancel) return super.send(request, flags);
|
|
43
|
+
return requestContext('POST /knowledge-bases/{knowledgeBaseId}/build/cancel', {
|
|
44
|
+
params: request.params
|
|
45
|
+
});
|
|
108
46
|
}
|
|
109
47
|
}
|
|
110
48
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/context/build.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/context/build.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {type FlagInput} from '@oclif/core/interfaces'\n\nimport {contextCommand} from '../../actions/context/contextCommand.js'\nimport {type OperationRequest} from '../../actions/context/operationInput.js'\nimport {requestContext} from '../../services/context.js'\n\nconst BaseCommand = contextCommand('context build')\n\n/**\n * `context build` keeps `--cancel`, which calls the cancel operation instead\n * of starting a build\n */\nexport class BuildKnowledgeBaseCommand extends BaseCommand {\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123',\n description: 'Start a build and return the job ID',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --watch',\n description: 'Start a build and wait for it to finish (non-zero exit on failure)',\n },\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 --cancel',\n description: 'Cancel the running build, if any',\n },\n ]\n\n static override flags = {\n ...BaseCommand.flags,\n cancel: Flags.boolean({\n default: false,\n description: 'Cancel the running build instead of starting one',\n exclusive: ['watch'],\n }),\n } satisfies FlagInput\n\n public override render(result: unknown): void {\n if (!this.flags.cancel || this.flags.json) {\n super.render(result)\n return\n }\n const cancelled = typeof result === 'object' && result !== null && 'cancelled' in result\n this.log(cancelled && result.cancelled ? 'Build cancelled' : 'No running build to cancel')\n }\n\n public override async send(\n request: OperationRequest,\n flags: Record<string, unknown>,\n ): Promise<unknown> {\n if (!flags.cancel) return super.send(request, flags)\n return requestContext('POST /knowledge-bases/{knowledgeBaseId}/build/cancel', {\n params: request.params,\n })\n }\n}\n"],"names":["Flags","contextCommand","requestContext","BaseCommand","BuildKnowledgeBaseCommand","examples","command","description","flags","cancel","boolean","default","exclusive","render","result","json","cancelled","log","send","request","params"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AAGjC,SAAQC,cAAc,QAAO,0CAAyC;AAEtE,SAAQC,cAAc,QAAO,4BAA2B;AAExD,MAAMC,cAAcF,eAAe;AAEnC;;;CAGC,GACD,OAAO,MAAMG,kCAAkCD;IAC7C,OAAgBE,WAAW;QACzB;YACEC,SAAS;YACTC,aAAa;QACf;QACA;YACED,SAAS;YACTC,aAAa;QACf;QACA;YACED,SAAS;YACTC,aAAa;QACf;KACD,CAAA;IAED,OAAgBC,QAAQ;QACtB,GAAGL,YAAYK,KAAK;QACpBC,QAAQT,MAAMU,OAAO,CAAC;YACpBC,SAAS;YACTJ,aAAa;YACbK,WAAW;gBAAC;aAAQ;QACtB;IACF,EAAqB;IAELC,OAAOC,MAAe,EAAQ;QAC5C,IAAI,CAAC,IAAI,CAACN,KAAK,CAACC,MAAM,IAAI,IAAI,CAACD,KAAK,CAACO,IAAI,EAAE;YACzC,KAAK,CAACF,OAAOC;YACb;QACF;QACA,MAAME,YAAY,OAAOF,WAAW,YAAYA,WAAW,QAAQ,eAAeA;QAClF,IAAI,CAACG,GAAG,CAACD,aAAaF,OAAOE,SAAS,GAAG,oBAAoB;IAC/D;IAEA,MAAsBE,KACpBC,OAAyB,EACzBX,KAA8B,EACZ;QAClB,IAAI,CAACA,MAAMC,MAAM,EAAE,OAAO,KAAK,CAACS,KAAKC,SAASX;QAC9C,OAAON,eAAe,wDAAwD;YAC5EkB,QAAQD,QAAQC,MAAM;QACxB;IACF;AACF"}
|
|
@@ -1,106 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { requiredWhenUnattended } from '@sanity/cli-core/flags';
|
|
5
|
-
import { input, spinner } from '@sanity/cli-core/ux';
|
|
6
|
-
import { MissingOrganizationError, resolveOrganizationId } from '../../actions/context/resolveOrganizationId.js';
|
|
7
|
-
import { formatKeyValue } from '../../actions/debug/output.js';
|
|
8
|
-
import { createKnowledgeBase } from '../../services/context.js';
|
|
9
|
-
import { getOrganizationFlag } from '../../util/sharedFlags.js';
|
|
10
|
-
import { defineCommandTelemetry } from '../../util/telemetry/commandTelemetry.js';
|
|
11
|
-
const createContextDebug = subdebug('context:create');
|
|
12
|
-
const flags = {
|
|
13
|
-
...getOrganizationFlag({
|
|
14
|
-
description: 'Organization to create the knowledge base in',
|
|
15
|
-
semantics: 'override'
|
|
16
|
-
}),
|
|
17
|
-
description: requiredWhenUnattended(Flags.string({
|
|
18
|
-
description: 'Knowledge base description'
|
|
19
|
-
})),
|
|
20
|
-
title: requiredWhenUnattended(Flags.string({
|
|
21
|
-
description: 'Knowledge base title'
|
|
22
|
-
}))
|
|
23
|
-
};
|
|
24
|
-
export class CreateKnowledgeBaseCommand extends SanityCommand {
|
|
25
|
-
static description = 'Create a knowledge base';
|
|
26
|
-
static examples = [
|
|
27
|
-
{
|
|
28
|
-
command: '<%= config.bin %> <%= command.id %>',
|
|
29
|
-
description: 'Interactively create a knowledge base'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
command: '<%= config.bin %> <%= command.id %> --organization org-abc123 --title "Support docs" --description "Product docs and troubleshooting guides"',
|
|
33
|
-
description: 'Create a knowledge base in a specific organization'
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
static flags = flags;
|
|
37
|
-
static telemetry = defineCommandTelemetry(flags, {
|
|
38
|
-
redact: [
|
|
39
|
-
'title',
|
|
40
|
-
'description'
|
|
41
|
-
]
|
|
42
|
-
});
|
|
43
|
-
async run() {
|
|
44
|
-
const { description: descriptionFlag, organization, title: titleFlag } = this.flags;
|
|
45
|
-
if (titleFlag !== undefined && titleFlag.trim() === '') {
|
|
46
|
-
this.error('Title cannot be empty', {
|
|
47
|
-
exit: exitCodes.USAGE_ERROR
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (descriptionFlag !== undefined && descriptionFlag.trim() === '') {
|
|
51
|
-
this.error('Description cannot be empty', {
|
|
52
|
-
exit: exitCodes.USAGE_ERROR
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
let organizationId;
|
|
56
|
-
try {
|
|
57
|
-
organizationId = await resolveOrganizationId({
|
|
58
|
-
configuredOrganizationId: (await this.tryGetCliConfig()).app?.organizationId,
|
|
59
|
-
flagOrganizationId: organization,
|
|
60
|
-
unattended: this.isUnattended()
|
|
61
|
-
});
|
|
62
|
-
} catch (error) {
|
|
63
|
-
createContextDebug('Error resolving organization', error);
|
|
64
|
-
this.error(getErrorMessage(error), {
|
|
65
|
-
exit: error instanceof MissingOrganizationError ? exitCodes.USAGE_ERROR : exitCodes.RUNTIME_ERROR
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
const title = titleFlag?.trim() || await promptForText('Knowledge base title:');
|
|
69
|
-
const description = descriptionFlag?.trim() || await promptForText('Knowledge base description:');
|
|
70
|
-
const spin = spinner('Creating knowledge base').start();
|
|
71
|
-
try {
|
|
72
|
-
const knowledgeBase = await createKnowledgeBase({
|
|
73
|
-
description,
|
|
74
|
-
organizationId,
|
|
75
|
-
title
|
|
76
|
-
});
|
|
77
|
-
spin.succeed('Knowledge base created');
|
|
78
|
-
const padTo = 12 // "Organization" is the longest key
|
|
79
|
-
;
|
|
80
|
-
this.log(formatKeyValue('ID', knowledgeBase.publicId, {
|
|
81
|
-
padTo
|
|
82
|
-
}));
|
|
83
|
-
this.log(formatKeyValue('Title', knowledgeBase.title, {
|
|
84
|
-
padTo
|
|
85
|
-
}));
|
|
86
|
-
this.log(formatKeyValue('Organization', knowledgeBase.organizationId, {
|
|
87
|
-
padTo
|
|
88
|
-
}));
|
|
89
|
-
} catch (error) {
|
|
90
|
-
spin.fail();
|
|
91
|
-
createContextDebug('Error creating knowledge base', error);
|
|
92
|
-
this.error(`Failed to create knowledge base: ${getErrorMessage(error)}`, {
|
|
93
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async function promptForText(message) {
|
|
99
|
-
const value = await input({
|
|
100
|
-
message,
|
|
101
|
-
validate: (input_)=>input_.trim().length > 0 || 'Value cannot be empty'
|
|
102
|
-
});
|
|
103
|
-
return value.trim();
|
|
104
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../actions/context/contextCommand.js';
|
|
3
|
+
export const CreateKnowledgeBaseCommand = contextCommand('context create');
|
|
105
4
|
|
|
106
5
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/context/create.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/context/create.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../actions/context/contextCommand.js'\n\nexport const CreateKnowledgeBaseCommand = contextCommand('context create')\n"],"names":["contextCommand","CreateKnowledgeBaseCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,0CAAyC;AAEtE,OAAO,MAAMC,6BAA6BD,eAAe,kBAAiB"}
|
|
@@ -1,75 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { confirm } from '@sanity/cli-core/ux';
|
|
5
|
-
import { isHttpError } from '@sanity/client';
|
|
6
|
-
import { deleteKnowledgeBase, getKnowledgeBaseBlueprintOwnership } from '../../services/context.js';
|
|
7
|
-
const deleteContextDebug = subdebug('context:delete');
|
|
8
|
-
export class DeleteKnowledgeBaseCommand extends SanityCommand {
|
|
9
|
-
static args = {
|
|
10
|
-
knowledgeBaseId: Args.string({
|
|
11
|
-
description: 'Knowledge base ID',
|
|
12
|
-
required: true
|
|
13
|
-
})
|
|
14
|
-
};
|
|
15
|
-
static description = 'Delete a knowledge base and its generated content';
|
|
16
|
-
static examples = [
|
|
17
|
-
{
|
|
18
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123',
|
|
19
|
-
description: 'Delete a knowledge base after confirmation'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
command: '<%= config.bin %> <%= command.id %> kb-abc123 --yes',
|
|
23
|
-
description: 'Delete a knowledge base without confirmation prompt'
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
static flags = {
|
|
27
|
-
yes: Flags.boolean({
|
|
28
|
-
char: 'y',
|
|
29
|
-
default: false,
|
|
30
|
-
description: 'Skip confirmation prompt (unattended mode)'
|
|
31
|
-
})
|
|
32
|
-
};
|
|
33
|
-
async run() {
|
|
34
|
-
const { knowledgeBaseId } = this.args;
|
|
35
|
-
const { yes: skipConfirmation } = this.flags;
|
|
36
|
-
const ownership = await getKnowledgeBaseBlueprintOwnership(knowledgeBaseId);
|
|
37
|
-
if (ownership.managed) {
|
|
38
|
-
const manager = ownership.stackName ? `The blueprint stack "${ownership.stackName}"` : 'A blueprint';
|
|
39
|
-
this.error(`${manager} manages knowledge base "${knowledgeBaseId}". To delete it, deploy it with \`lifecycle: {deletionPolicy: 'allow'}\` in the blueprint, then remove it from the blueprint and deploy again.`, {
|
|
40
|
-
exit: exitCodes.USAGE_ERROR
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (this.isUnattended() && !skipConfirmation) {
|
|
44
|
-
this.error('Deletion requires confirmation. Pass `--yes` to delete the knowledge base.', {
|
|
45
|
-
exit: exitCodes.USAGE_ERROR
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (!skipConfirmation) {
|
|
49
|
-
const confirmed = await confirm({
|
|
50
|
-
default: false,
|
|
51
|
-
message: `Delete knowledge base "${knowledgeBaseId}"? This permanently deletes its generated content.`
|
|
52
|
-
});
|
|
53
|
-
if (!confirmed) {
|
|
54
|
-
this.log('Knowledge base not deleted');
|
|
55
|
-
this.exit(exitCodes.USER_ABORT);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
await deleteKnowledgeBase(knowledgeBaseId);
|
|
60
|
-
this.log('Knowledge base deleted');
|
|
61
|
-
} catch (error) {
|
|
62
|
-
deleteContextDebug('Error deleting knowledge base', error);
|
|
63
|
-
if (isHttpError(error) && error.statusCode === 404) {
|
|
64
|
-
this.error(`Knowledge base "${knowledgeBaseId}" not found`, {
|
|
65
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
this.error(`Failed to delete knowledge base: ${getErrorMessage(error)}`, {
|
|
69
|
-
exit: exitCodes.RUNTIME_ERROR
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../actions/context/contextCommand.js';
|
|
3
|
+
export const DeleteKnowledgeBaseCommand = contextCommand('context delete');
|
|
74
4
|
|
|
75
5
|
//# sourceMappingURL=delete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/context/delete.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/context/delete.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../actions/context/contextCommand.js'\n\nexport const DeleteKnowledgeBaseCommand = contextCommand('context delete')\n"],"names":["contextCommand","DeleteKnowledgeBaseCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,0CAAyC;AAEtE,OAAO,MAAMC,6BAA6BD,eAAe,kBAAiB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { writeFile } from 'node:fs/promises';
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
import { exitCodes } from '@sanity/cli-core';
|
|
4
|
+
import { getErrorMessage } from '@sanity/cli-core/errors';
|
|
5
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
6
|
+
import { getDocumentBytes } from '../../../services/context.js';
|
|
7
|
+
import { defineCommandTelemetry } from '../../../util/telemetry/commandTelemetry.js';
|
|
8
|
+
const BaseCommand = contextCommand('context documents content');
|
|
9
|
+
/** The lines of a JSON content view, each prefixed with its line number in the whole document */ function numberLines(view) {
|
|
10
|
+
if (typeof view !== 'object' || view === null || !('content' in view) || !('slice' in view)) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
const { content, slice } = view;
|
|
14
|
+
if (typeof content !== 'string' || typeof slice !== 'object' || slice === null) return '';
|
|
15
|
+
const start = 'start' in slice && typeof slice.start === 'number' ? slice.start : 0;
|
|
16
|
+
const end = 'end' in slice && typeof slice.end === 'number' ? slice.end : 0;
|
|
17
|
+
if (start === 0) return '';
|
|
18
|
+
const width = String(end).length;
|
|
19
|
+
return content.split('\n').slice(0, end - start + 1).map((line, index)=>`${String(start + index).padStart(width)} ${line}\n`).join('');
|
|
20
|
+
}
|
|
21
|
+
const flags = {
|
|
22
|
+
...BaseCommand.flags,
|
|
23
|
+
'line-numbers': Flags.boolean({
|
|
24
|
+
default: false,
|
|
25
|
+
description: 'Number each line as citations number them'
|
|
26
|
+
}),
|
|
27
|
+
output: Flags.string({
|
|
28
|
+
char: 'o',
|
|
29
|
+
description: 'Write the content to this file instead of stdout',
|
|
30
|
+
helpValue: '<file>'
|
|
31
|
+
})
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* `context documents content` prints text and writes bytes: `--format raw`
|
|
35
|
+
* downloads the bytes the source gave, which the spec types only as the JSON
|
|
36
|
+
* view, and `--output` writes to a local file.
|
|
37
|
+
*/ export class GetDocumentContentCommand extends BaseCommand {
|
|
38
|
+
static examples = [
|
|
39
|
+
{
|
|
40
|
+
command: '<%= config.bin %> <%= command.id %> kb-abc123 document-def456',
|
|
41
|
+
description: "Print a document's markdown"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
command: '<%= config.bin %> <%= command.id %> kb-abc123 document-def456 --lines 10-20 --line-numbers',
|
|
45
|
+
description: 'Print lines 10 to 20, each with its line number'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
command: '<%= config.bin %> <%= command.id %> kb-abc123 document-def456 --format raw --output handbook.pdf',
|
|
49
|
+
description: 'Download the original file'
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
static flags = flags;
|
|
53
|
+
static telemetry = {
|
|
54
|
+
redactedFlags: [
|
|
55
|
+
...BaseCommand.telemetry.redactedFlags,
|
|
56
|
+
...defineCommandTelemetry(flags, {
|
|
57
|
+
redact: [
|
|
58
|
+
'output'
|
|
59
|
+
]
|
|
60
|
+
}).redactedFlags
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
render(result) {
|
|
64
|
+
if (result instanceof Uint8Array && !this.flags.json && this.flags.output === undefined) {
|
|
65
|
+
process.stdout.write(result);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (typeof result === 'string' && !this.flags.json && this.flags.output === undefined) {
|
|
69
|
+
this.log(result.replace(/\n$/, ''));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
super.render(result);
|
|
73
|
+
}
|
|
74
|
+
async send(request, values) {
|
|
75
|
+
const output = typeof values.output === 'string' ? values.output : undefined;
|
|
76
|
+
const lineNumbers = Boolean(values['line-numbers']);
|
|
77
|
+
const format = request.query.format ?? (values.json || lineNumbers ? 'json' : 'markdown');
|
|
78
|
+
if (values.json && (values.format !== undefined || output !== undefined)) {
|
|
79
|
+
this.error('--json prints the JSON view and cannot be combined with --format or --output.', {
|
|
80
|
+
exit: exitCodes.USAGE_ERROR
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (lineNumbers && (values.json || request.query.format !== undefined)) {
|
|
84
|
+
this.error('--line-numbers only applies to markdown, without --json or --format.', {
|
|
85
|
+
exit: exitCodes.USAGE_ERROR
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (format === 'raw' && output === undefined && process.stdout.isTTY) {
|
|
89
|
+
this.error('Raw content is binary. Write it to a file with --output, or pipe it.', {
|
|
90
|
+
exit: exitCodes.USAGE_ERROR
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const query = {
|
|
94
|
+
...request.query,
|
|
95
|
+
format
|
|
96
|
+
};
|
|
97
|
+
const content = format === 'raw' ? await getDocumentBytes({
|
|
98
|
+
...request,
|
|
99
|
+
query
|
|
100
|
+
}) : await super.send({
|
|
101
|
+
...request,
|
|
102
|
+
query
|
|
103
|
+
}, values);
|
|
104
|
+
const printable = lineNumbers ? numberLines(content) : content;
|
|
105
|
+
if (output === undefined) return printable;
|
|
106
|
+
try {
|
|
107
|
+
await writeFile(output, printable instanceof Uint8Array || typeof printable === 'string' ? printable : JSON.stringify(printable, null, 2));
|
|
108
|
+
} catch (error) {
|
|
109
|
+
this.error(`Failed to write "${output}": ${getErrorMessage(error)}`, {
|
|
110
|
+
exit: exitCodes.RUNTIME_ERROR
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return `Wrote ${output}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/content.ts"],"sourcesContent":["import {writeFile} from 'node:fs/promises'\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 {type OperationRequest} from '../../../actions/context/operationInput.js'\nimport {getDocumentBytes} from '../../../services/context.js'\nimport {defineCommandTelemetry} from '../../../util/telemetry/commandTelemetry.js'\n\nconst BaseCommand = contextCommand('context documents content')\n\n/** The lines of a JSON content view, each prefixed with its line number in the whole document */\nfunction numberLines(view: unknown): string {\n if (typeof view !== 'object' || view === null || !('content' in view) || !('slice' in view)) {\n return ''\n }\n const {content, slice} = view\n if (typeof content !== 'string' || typeof slice !== 'object' || slice === null) return ''\n const start = 'start' in slice && typeof slice.start === 'number' ? slice.start : 0\n const end = 'end' in slice && typeof slice.end === 'number' ? slice.end : 0\n if (start === 0) return ''\n const width = String(end).length\n return content\n .split('\\n')\n .slice(0, end - start + 1)\n .map((line, index) => `${String(start + index).padStart(width)} ${line}\\n`)\n .join('')\n}\n\nconst flags = {\n ...BaseCommand.flags,\n 'line-numbers': Flags.boolean({\n default: false,\n description: 'Number each line as citations number them',\n }),\n output: Flags.string({\n char: 'o',\n description: 'Write the content to this file instead of stdout',\n helpValue: '<file>',\n }),\n} satisfies FlagInput\n\n/**\n * `context documents content` prints text and writes bytes: `--format raw`\n * downloads the bytes the source gave, which the spec types only as the JSON\n * view, and `--output` writes to a local file.\n */\nexport class GetDocumentContentCommand extends BaseCommand {\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> kb-abc123 document-def456',\n description: \"Print a document's markdown\",\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> kb-abc123 document-def456 --lines 10-20 --line-numbers',\n description: 'Print lines 10 to 20, each with its line number',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> kb-abc123 document-def456 --format raw --output handbook.pdf',\n description: 'Download the original file',\n },\n ]\n\n static override flags = flags\n\n static override telemetry = {\n redactedFlags: [\n ...BaseCommand.telemetry.redactedFlags,\n ...defineCommandTelemetry(flags, {redact: ['output']}).redactedFlags,\n ],\n }\n\n public override render(result: unknown): void {\n if (result instanceof Uint8Array && !this.flags.json && this.flags.output === undefined) {\n process.stdout.write(result)\n return\n }\n if (typeof result === 'string' && !this.flags.json && this.flags.output === undefined) {\n this.log(result.replace(/\\n$/, ''))\n return\n }\n super.render(result)\n }\n\n public override async send(\n request: OperationRequest,\n values: Record<string, unknown>,\n ): Promise<unknown> {\n const output = typeof values.output === 'string' ? values.output : undefined\n const lineNumbers = Boolean(values['line-numbers'])\n const format = request.query.format ?? (values.json || lineNumbers ? 'json' : 'markdown')\n\n if (values.json && (values.format !== undefined || output !== undefined)) {\n this.error('--json prints the JSON view and cannot be combined with --format or --output.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n if (lineNumbers && (values.json || request.query.format !== undefined)) {\n this.error('--line-numbers only applies to markdown, without --json or --format.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n if (format === 'raw' && output === undefined && process.stdout.isTTY) {\n this.error('Raw content is binary. Write it to a file with --output, or pipe it.', {\n exit: exitCodes.USAGE_ERROR,\n })\n }\n\n const query = {...request.query, format}\n const content =\n format === 'raw'\n ? await getDocumentBytes({...request, query})\n : await super.send({...request, query}, values)\n const printable = lineNumbers ? numberLines(content) : content\n if (output === undefined) return printable\n\n try {\n await writeFile(\n output,\n printable instanceof Uint8Array || typeof printable === 'string'\n ? printable\n : JSON.stringify(printable, null, 2),\n )\n } catch (error) {\n this.error(`Failed to write \"${output}\": ${getErrorMessage(error)}`, {\n exit: exitCodes.RUNTIME_ERROR,\n })\n }\n return `Wrote ${output}`\n }\n}\n"],"names":["writeFile","Flags","exitCodes","getErrorMessage","contextCommand","getDocumentBytes","defineCommandTelemetry","BaseCommand","numberLines","view","content","slice","start","end","width","String","length","split","map","line","index","padStart","join","flags","boolean","default","description","output","string","char","helpValue","GetDocumentContentCommand","examples","command","telemetry","redactedFlags","redact","render","result","Uint8Array","json","undefined","process","stdout","write","log","replace","send","request","values","lineNumbers","Boolean","format","query","error","exit","USAGE_ERROR","isTTY","printable","JSON","stringify","RUNTIME_ERROR"],"mappings":"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"}
|
|
@@ -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 DeleteDocumentCommand = contextCommand('context documents delete');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/delete.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const DeleteDocumentCommand = contextCommand('context documents delete')\n"],"names":["contextCommand","DeleteDocumentCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,wBAAwBD,eAAe,4BAA2B"}
|
|
@@ -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 UpdateDocumentCommand = contextCommand('context documents edit');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/edit.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const UpdateDocumentCommand = contextCommand('context documents edit')\n"],"names":["contextCommand","UpdateDocumentCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,wBAAwBD,eAAe,0BAAyB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const GetDocumentCommand = contextCommand('context documents get');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/get.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const GetDocumentCommand = contextCommand('context documents get')\n"],"names":["contextCommand","GetDocumentCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,qBAAqBD,eAAe,yBAAwB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands
|
|
2
|
+
import { contextCommand } from '../../../actions/context/contextCommand.js';
|
|
3
|
+
export const ListDocumentsCommand = contextCommand('context documents list');
|
|
4
|
+
|
|
5
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/commands/context/documents/list.ts"],"sourcesContent":["// GENERATED FILE - DO NOT EDIT. Regenerate with: pnpm generate:context-commands\nimport {contextCommand} from '../../../actions/context/contextCommand.js'\n\nexport const ListDocumentsCommand = contextCommand('context documents list')\n"],"names":["contextCommand","ListDocumentsCommand"],"mappings":"AAAA,gFAAgF;AAChF,SAAQA,cAAc,QAAO,6CAA4C;AAEzE,OAAO,MAAMC,uBAAuBD,eAAe,0BAAyB"}
|