@zinn-dev/cli 0.41.0 → 0.42.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 +11 -689
- package/index.js +2 -2
- package/package.json +3 -2
- package/skills/zinn/SKILL.md +1 -1
- package/src/capabilities-schema.d.ts +22 -23
- package/src/capabilities-schema.js +17 -82
- package/src/capabilities.d.ts +11 -3
- package/src/capabilities.js +12 -4
- package/src/column-hint.d.ts +3 -0
- package/src/column-hint.js +225 -0
- package/src/database.js +1 -4
- package/src/errors.js +2 -0
- package/src/input.d.ts +154 -43
- package/src/input.js +86 -13
- package/src/lib.d.ts +30 -2
- package/src/lib.js +74 -13
- package/src/presentation/activity-presentation.d.ts +9 -1
- package/src/presentation/activity-presentation.js +108 -25
- package/src/presentation/capabilities-presentation.d.ts +2 -0
- package/src/presentation/capabilities-presentation.js +3 -0
- package/src/presentation/column-presentation.d.ts +6 -0
- package/src/presentation/column-presentation.js +10 -0
- package/src/presentation/comment-presentation.d.ts +15 -0
- package/src/presentation/comment-presentation.js +29 -0
- package/src/presentation/description-presentation.d.ts +17 -0
- package/src/presentation/description-presentation.js +26 -4
- package/src/presentation/label-presentation.d.ts +8 -0
- package/src/presentation/label-presentation.js +28 -0
- package/src/presentation/project-presentation.d.ts +7 -0
- package/src/presentation/project-presentation.js +19 -0
- package/src/presentation/relation-presentation.d.ts +7 -0
- package/src/presentation/relation-presentation.js +73 -0
- package/src/presentation/task-presentation.d.ts +3 -3
- package/src/presentation/task-presentation.js +22 -18
- package/src/project.d.ts +14 -5
- package/src/project.js +18 -6
- package/src/result-schemas.d.ts +230 -23
- package/src/result-schemas.js +62 -3
- package/src/results.d.ts +34 -17
- package/src/results.js +19 -0
- package/src/routes/activity-router.d.ts +34 -1
- package/src/routes/activity-router.js +104 -31
- package/src/routes/aliases.d.ts +2 -0
- package/src/routes/aliases.js +11 -0
- package/src/routes/capabilities-router.js +9 -3
- package/src/routes/comment-router.d.ts +41 -18
- package/src/routes/comment-router.js +65 -48
- package/src/routes/label-router.d.ts +57 -7
- package/src/routes/label-router.js +84 -39
- package/src/routes/project-router.d.ts +34 -12
- package/src/routes/project-router.js +59 -55
- package/src/routes/relation-router.d.ts +6 -6
- package/src/routes/relation-router.js +52 -69
- package/src/routes/restore-router.js +1 -1
- package/src/routes/router.d.ts +1 -1
- package/src/routes/router.js +38 -9
- package/src/routes/routes.d.ts +253 -45
- package/src/routes/routes.js +4 -0
- package/src/routes/task-router.d.ts +107 -26
- package/src/routes/task-router.js +151 -143
- package/src/routes/whoami-router.d.ts +21 -0
- package/src/routes/whoami-router.js +31 -0
- package/src/text-edit.d.ts +13 -9
- package/src/text-edit.js +23 -18
- package/src/text-input.d.ts +47 -0
- package/src/text-input.js +187 -0
- package/src/types.d.ts +32 -9
- package/src/types.js +9 -1
package/src/text-edit.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TextEdit } from "@zinn-dev/core";
|
|
2
|
+
import type { TextFlag, TextValues } from "./text-input.js";
|
|
2
3
|
/** The flags that change how a text flag (--description, --text) is applied to the stored text. */
|
|
3
4
|
export declare const textEditOptions: {
|
|
4
5
|
readonly append: {
|
|
@@ -15,29 +16,32 @@ export declare const textEditOptions: {
|
|
|
15
16
|
readonly type: "boolean";
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
|
-
export declare function textEditConstraints(textFlag:
|
|
19
|
+
export declare function textEditConstraints(textFlag: TextFlag): readonly [{
|
|
19
20
|
readonly kind: "exclusive";
|
|
20
21
|
readonly members: readonly ["option:append", "option:replacing"];
|
|
21
22
|
}, {
|
|
22
|
-
readonly kind: "
|
|
23
|
+
readonly kind: "requiresAny";
|
|
23
24
|
readonly input: "option:append";
|
|
24
|
-
readonly
|
|
25
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
25
26
|
}, {
|
|
26
|
-
readonly kind: "
|
|
27
|
+
readonly kind: "requiresAny";
|
|
27
28
|
readonly input: "option:replacing";
|
|
28
|
-
readonly
|
|
29
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
29
30
|
}, {
|
|
30
31
|
readonly kind: "requires";
|
|
31
32
|
readonly input: "option:all";
|
|
32
33
|
readonly requires: "option:replacing";
|
|
33
34
|
}];
|
|
34
|
-
type TextEditFlags = {
|
|
35
|
+
type TextEditFlags = TextValues & {
|
|
35
36
|
append?: boolean | undefined;
|
|
36
37
|
replacing?: string | undefined;
|
|
37
38
|
all?: boolean | undefined;
|
|
38
39
|
};
|
|
39
40
|
/** Help paragraph for the text-edit flags of a command whose text flag is `textFlag`. */
|
|
40
|
-
export declare function textEditHelp(textFlag:
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
export declare function textEditHelp(textFlag: TextFlag): string;
|
|
42
|
+
/**
|
|
43
|
+
* The value to send to core for a text flag: the full text, or one edit object.
|
|
44
|
+
* The text comes inline or from its file flag, which is read only after the flag checks pass.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveTextEdit(flags: TextEditFlags, textFlag: TextFlag): Promise<string | TextEdit | undefined>;
|
|
43
47
|
export {};
|
package/src/text-edit.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { quit } from "./lib.js";
|
|
2
2
|
import { getOptionInputs, violatesConstraint } from "./input.js";
|
|
3
|
+
import { resolveTextInput, textOptionNames, textSourceConstraint } from "./text-input.js";
|
|
3
4
|
/** The flags that change how a text flag (--description, --text) is applied to the stored text. */
|
|
4
5
|
export const textEditOptions = {
|
|
5
6
|
append: { type: "boolean" },
|
|
@@ -7,28 +8,29 @@ export const textEditOptions = {
|
|
|
7
8
|
all: { type: "boolean" },
|
|
8
9
|
};
|
|
9
10
|
export function textEditConstraints(textFlag) {
|
|
10
|
-
const
|
|
11
|
+
const textSources = textSourceConstraint(textFlag).members;
|
|
11
12
|
return [
|
|
12
13
|
{ kind: "exclusive", members: ["option:append", "option:replacing"] },
|
|
13
|
-
{ kind: "
|
|
14
|
-
{ kind: "
|
|
14
|
+
{ kind: "requiresAny", input: "option:append", members: textSources },
|
|
15
|
+
{ kind: "requiresAny", input: "option:replacing", members: textSources },
|
|
15
16
|
{ kind: "requires", input: "option:all", requires: "option:replacing" },
|
|
16
17
|
];
|
|
17
18
|
}
|
|
18
19
|
/** Help paragraph for the text-edit flags of a command whose text flag is `textFlag`. */
|
|
19
20
|
export function textEditHelp(textFlag) {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
--all
|
|
23
|
-
|
|
24
|
-
No match, or several matches without --all, fails without changing anything.
|
|
25
|
-
An empty ${textFlag} with --replacing deletes the match.`;
|
|
21
|
+
return `--append adds ${textFlag} as a new paragraph.
|
|
22
|
+
--replacing <old> replaces one exact, case-sensitive match; --all replaces every match.
|
|
23
|
+
No match, or several without --all, fails without changes. ${textFlag} '' with --replacing deletes the match.`;
|
|
26
24
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The value to send to core for a text flag: the full text, or one edit object.
|
|
27
|
+
* The text comes inline or from its file flag, which is read only after the flag checks pass.
|
|
28
|
+
*/
|
|
29
|
+
export async function resolveTextEdit(flags, textFlag) {
|
|
29
30
|
const isAppending = flags.append === true;
|
|
30
31
|
const [exclusiveModifiers, appendRequiresText, replacingRequiresText, allRequiresReplacing] = textEditConstraints(textFlag);
|
|
31
|
-
const
|
|
32
|
+
const { text, file } = textOptionNames(textFlag);
|
|
33
|
+
const inputs = getOptionInputs(flags);
|
|
32
34
|
if (violatesConstraint(exclusiveModifiers, inputs)) {
|
|
33
35
|
quit(`Option "--append" cannot be used with "--replacing"`, undefined, {
|
|
34
36
|
argument: "--append",
|
|
@@ -37,21 +39,24 @@ export function resolveTextEdit(text, flags, textFlag) {
|
|
|
37
39
|
if (violatesConstraint(appendRequiresText, inputs) ||
|
|
38
40
|
violatesConstraint(replacingRequiresText, inputs)) {
|
|
39
41
|
const modifier = isAppending ? "--append" : "--replacing";
|
|
40
|
-
quit(`Option "${modifier}" needs "${textFlag}"`, undefined, {
|
|
42
|
+
quit(`Option "${modifier}" needs "${textFlag}" or "--${file}"`, undefined, {
|
|
43
|
+
argument: textFlag,
|
|
44
|
+
});
|
|
41
45
|
}
|
|
42
46
|
if (violatesConstraint(allRequiresReplacing, inputs)) {
|
|
43
47
|
quit(`Option "--all" needs "--replacing"`, undefined, { argument: "--all" });
|
|
44
48
|
}
|
|
45
|
-
|
|
49
|
+
const resolvedText = await resolveTextInput(flags[text], flags[file], textFlag);
|
|
50
|
+
if (resolvedText === undefined) {
|
|
46
51
|
return undefined;
|
|
47
52
|
}
|
|
48
53
|
if (isAppending) {
|
|
49
|
-
return { append:
|
|
54
|
+
return { append: resolvedText };
|
|
50
55
|
}
|
|
51
56
|
if (flags.replacing !== undefined) {
|
|
52
57
|
return flags.all === true
|
|
53
|
-
? { find: flags.replacing, replace:
|
|
54
|
-
: { find: flags.replacing, replace:
|
|
58
|
+
? { find: flags.replacing, replace: resolvedText, all: true }
|
|
59
|
+
: { find: flags.replacing, replace: resolvedText };
|
|
55
60
|
}
|
|
56
|
-
return
|
|
61
|
+
return resolvedText;
|
|
57
62
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The option names of each text flag and of the file flag that can supply its text instead */
|
|
3
|
+
declare const textOptions: {
|
|
4
|
+
readonly "--description": {
|
|
5
|
+
readonly text: "description";
|
|
6
|
+
readonly file: "description-file";
|
|
7
|
+
};
|
|
8
|
+
readonly "--text": {
|
|
9
|
+
readonly text: "text";
|
|
10
|
+
readonly file: "text-file";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type TextFlag = keyof typeof textOptions;
|
|
14
|
+
export type TextValues = {
|
|
15
|
+
[Name in (typeof textOptions)[TextFlag][keyof (typeof textOptions)[TextFlag]]]?: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
export declare function textOptionNames(textFlag: TextFlag): {
|
|
18
|
+
readonly text: "description";
|
|
19
|
+
readonly file: "description-file";
|
|
20
|
+
} | {
|
|
21
|
+
readonly text: "text";
|
|
22
|
+
readonly file: "text-file";
|
|
23
|
+
};
|
|
24
|
+
/** The flag that reads a text flag's value from a file, or from stdin as "-" */
|
|
25
|
+
export declare const textFileOption: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly value: {
|
|
28
|
+
readonly kind: "path";
|
|
29
|
+
readonly name: "path";
|
|
30
|
+
readonly description: "A UTF-8 file, or \"-\" for stdin. Trailing line breaks are dropped; empty or blank input is an error.";
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Inline text and its file flag are alternatives for the same field */
|
|
34
|
+
export declare function textSourceConstraint(textFlag: TextFlag): {
|
|
35
|
+
readonly kind: "exclusive";
|
|
36
|
+
readonly members: readonly ["option:description" | "option:text", "option:description-file" | "option:text-file"];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Validates `fields` against their rules in a core input schema, so a command can reject
|
|
40
|
+
* a bad key, name or title before it reads text from stdin, which cannot be read twice.
|
|
41
|
+
* Rules that span the whole input, such as "at least one field", stay with core.
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkFieldsBeforeText(schema: z.ZodObject, fields: Record<string, unknown>): void;
|
|
44
|
+
export declare function textFileHelp(textFlag: TextFlag): string;
|
|
45
|
+
/** Resolves one inline or file source before the command opens the database. */
|
|
46
|
+
export declare function resolveTextInput(text: string | undefined, path: string | undefined, textFlag: TextFlag): Promise<string | undefined>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { constants, promises as fs } from "node:fs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { isMissingFileError, MAX_TEXT_BYTES } from "@zinn-dev/core";
|
|
5
|
+
import { CliError, classifyFailure } from "./errors.js";
|
|
6
|
+
/** The option names of each text flag and of the file flag that can supply its text instead */
|
|
7
|
+
const textOptions = {
|
|
8
|
+
"--description": { text: "description", file: "description-file" },
|
|
9
|
+
"--text": { text: "text", file: "text-file" },
|
|
10
|
+
};
|
|
11
|
+
export function textOptionNames(textFlag) {
|
|
12
|
+
return textOptions[textFlag];
|
|
13
|
+
}
|
|
14
|
+
/** The flag that reads a text flag's value from a file, or from stdin as "-" */
|
|
15
|
+
export const textFileOption = {
|
|
16
|
+
type: "string",
|
|
17
|
+
value: {
|
|
18
|
+
kind: "path",
|
|
19
|
+
name: "path",
|
|
20
|
+
description: 'A UTF-8 file, or "-" for stdin. Trailing line breaks are dropped; empty or blank input is an error.',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
/** Inline text and its file flag are alternatives for the same field */
|
|
24
|
+
export function textSourceConstraint(textFlag) {
|
|
25
|
+
const { text, file } = textOptionNames(textFlag);
|
|
26
|
+
return {
|
|
27
|
+
kind: "exclusive",
|
|
28
|
+
members: [`option:${text}`, `option:${file}`],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates `fields` against their rules in a core input schema, so a command can reject
|
|
33
|
+
* a bad key, name or title before it reads text from stdin, which cannot be read twice.
|
|
34
|
+
* Rules that span the whole input, such as "at least one field", stay with core.
|
|
35
|
+
*/
|
|
36
|
+
export function checkFieldsBeforeText(schema, fields) {
|
|
37
|
+
const names = Object.keys(schema.shape).filter((name) => name in fields);
|
|
38
|
+
const shape = Object.fromEntries(names.map((name) => [name, schema.shape[name]]));
|
|
39
|
+
z.strictObject(shape).parse(fields);
|
|
40
|
+
}
|
|
41
|
+
export function textFileHelp(textFlag) {
|
|
42
|
+
return `--${textOptionNames(textFlag).file} <path> takes the text from a UTF-8 file, or from stdin when <path> is "-".`;
|
|
43
|
+
}
|
|
44
|
+
// One extra byte detects oversized input without waiting for EOF.
|
|
45
|
+
const READ_LIMIT = MAX_TEXT_BYTES + 1;
|
|
46
|
+
const sizeLimitMessage = `Text is at least ${READ_LIMIT} UTF-8 bytes; the limit is ${MAX_TEXT_BYTES} bytes. Nothing was written.`;
|
|
47
|
+
async function readTextFile(path, refuse) {
|
|
48
|
+
const checkFile = (stats) => {
|
|
49
|
+
if (!stats.isFile()) {
|
|
50
|
+
refuse('Expected a regular file. Use "-" for piped input.');
|
|
51
|
+
}
|
|
52
|
+
if (stats.size > MAX_TEXT_BYTES) {
|
|
53
|
+
refuse(sizeLimitMessage);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
checkFile(await fs.stat(path));
|
|
57
|
+
// A path replaced by a FIFO after stat must not block open.
|
|
58
|
+
const file = await fs.open(path, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
59
|
+
try {
|
|
60
|
+
checkFile(await file.stat());
|
|
61
|
+
const bytes = Buffer.allocUnsafe(READ_LIMIT);
|
|
62
|
+
let size = 0;
|
|
63
|
+
while (size < READ_LIMIT) {
|
|
64
|
+
const { bytesRead } = await file.read(bytes, size, READ_LIMIT - size, null);
|
|
65
|
+
if (bytesRead === 0) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
size += bytesRead;
|
|
69
|
+
}
|
|
70
|
+
if (size > MAX_TEXT_BYTES) {
|
|
71
|
+
refuse(sizeLimitMessage);
|
|
72
|
+
}
|
|
73
|
+
return bytes.subarray(0, size);
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await file.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function readStdin(fileFlag, refuse) {
|
|
80
|
+
const input = process.stdin;
|
|
81
|
+
if (input.isTTY) {
|
|
82
|
+
refuse('Stdin is a terminal. Pipe text or supply a file path instead of "-".');
|
|
83
|
+
}
|
|
84
|
+
return new Promise((resolve, reject) => {
|
|
85
|
+
const collected = Buffer.allocUnsafe(READ_LIMIT);
|
|
86
|
+
let size = 0;
|
|
87
|
+
const cleanup = () => {
|
|
88
|
+
input.off("readable", readAvailable);
|
|
89
|
+
input.off("end", finish);
|
|
90
|
+
input.off("error", fail);
|
|
91
|
+
input.off("close", close);
|
|
92
|
+
};
|
|
93
|
+
const fail = (error) => {
|
|
94
|
+
cleanup();
|
|
95
|
+
reject(error);
|
|
96
|
+
};
|
|
97
|
+
const finish = () => {
|
|
98
|
+
cleanup();
|
|
99
|
+
resolve(collected.subarray(0, size));
|
|
100
|
+
};
|
|
101
|
+
const close = () => {
|
|
102
|
+
fail(new CliError("Stdin closed before all text could be read.", "storage", {
|
|
103
|
+
argument: fileFlag,
|
|
104
|
+
path: "-",
|
|
105
|
+
reason: "io",
|
|
106
|
+
}));
|
|
107
|
+
};
|
|
108
|
+
const readAvailable = () => {
|
|
109
|
+
while (size < READ_LIMIT) {
|
|
110
|
+
const available = Math.max(input.readableLength, 1);
|
|
111
|
+
const bytes = input.read(Math.min(available, READ_LIMIT - size));
|
|
112
|
+
if (bytes === null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
bytes.copy(collected, size);
|
|
116
|
+
size += bytes.length;
|
|
117
|
+
if (size > MAX_TEXT_BYTES) {
|
|
118
|
+
cleanup();
|
|
119
|
+
input.destroy();
|
|
120
|
+
try {
|
|
121
|
+
refuse(sizeLimitMessage);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
reject(error);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
input.on("readable", readAvailable);
|
|
130
|
+
input.once("end", finish);
|
|
131
|
+
input.once("error", fail);
|
|
132
|
+
input.once("close", close);
|
|
133
|
+
readAvailable();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/** Resolves one inline or file source before the command opens the database. */
|
|
137
|
+
export async function resolveTextInput(text, path, textFlag) {
|
|
138
|
+
const fileFlag = `--${textOptionNames(textFlag).file}`;
|
|
139
|
+
const refuse = (message) => {
|
|
140
|
+
throw new CliError(message, "invalid_input", { argument: fileFlag, path });
|
|
141
|
+
};
|
|
142
|
+
if (text !== undefined && path !== undefined) {
|
|
143
|
+
refuse(`Options "${textFlag}" and "${fileFlag}" cannot be used together.`);
|
|
144
|
+
}
|
|
145
|
+
if (path === undefined) {
|
|
146
|
+
return text;
|
|
147
|
+
}
|
|
148
|
+
let bytes;
|
|
149
|
+
try {
|
|
150
|
+
bytes = path === "-" ? await readStdin(fileFlag, refuse) : await readTextFile(path, refuse);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error instanceof CliError) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
const failure = classifyFailure(error);
|
|
157
|
+
const code = isMissingFileError(error) ? "not_found" : failure.code;
|
|
158
|
+
throw new CliError(`Cannot read ${fileFlag} ${JSON.stringify(path)}.`, code, {
|
|
159
|
+
...failure.details,
|
|
160
|
+
argument: fileFlag,
|
|
161
|
+
path,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
let decoded;
|
|
165
|
+
try {
|
|
166
|
+
decoded = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return refuse("Input is not valid UTF-8. Save the file as UTF-8.");
|
|
170
|
+
}
|
|
171
|
+
if (decoded.includes("\0")) {
|
|
172
|
+
refuse("Input contains a NUL character. Save the file as UTF-8 text without NUL characters.");
|
|
173
|
+
}
|
|
174
|
+
let end = decoded.length;
|
|
175
|
+
while (end > 0 && decoded[end - 1] === "\n") {
|
|
176
|
+
end -= 1;
|
|
177
|
+
if (end > 0 && decoded[end - 1] === "\r") {
|
|
178
|
+
end -= 1;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const result = decoded.slice(0, end);
|
|
182
|
+
if (result.trim().length === 0) {
|
|
183
|
+
const clearHint = textFlag === "--description" ? ' To clear a description, use --description "".' : "";
|
|
184
|
+
refuse(`Input is empty or blank.${clearHint}`);
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,23 +1,46 @@
|
|
|
1
1
|
import type { CommandInput } from "./input.js";
|
|
2
2
|
import type { CommandResult } from "./results.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
export declare const commandEffectsSchema: z.ZodObject<{
|
|
5
|
+
domain: z.ZodEnum<{
|
|
6
|
+
read: "read";
|
|
7
|
+
create: "create";
|
|
8
|
+
update: "update";
|
|
9
|
+
delete: "delete";
|
|
10
|
+
replace: "replace";
|
|
11
|
+
none: "none";
|
|
12
|
+
}>;
|
|
13
|
+
storage: z.ZodEnum<{
|
|
14
|
+
backup: "backup";
|
|
15
|
+
none: "none";
|
|
16
|
+
"normal-open": "normal-open";
|
|
17
|
+
restore: "restore";
|
|
18
|
+
migrate: "migrate";
|
|
19
|
+
reindex: "reindex";
|
|
20
|
+
inspect: "inspect";
|
|
21
|
+
}>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
export declare const commandConfirmationSchema: z.ZodObject<{
|
|
24
|
+
kind: z.ZodEnum<{
|
|
25
|
+
prompt: "prompt";
|
|
26
|
+
none: "none";
|
|
27
|
+
"project-delete": "project-delete";
|
|
28
|
+
}>;
|
|
29
|
+
description: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>;
|
|
3
31
|
export type Command = {
|
|
4
32
|
input: CommandInput;
|
|
5
33
|
results: readonly CommandResult[];
|
|
6
34
|
summary: string;
|
|
7
|
-
effects:
|
|
8
|
-
|
|
9
|
-
storage: "normal-open" | "backup" | "restore" | "migrate" | "reindex" | "inspect" | "none";
|
|
10
|
-
};
|
|
11
|
-
confirmation: {
|
|
12
|
-
kind: "none" | "prompt" | "project-delete";
|
|
13
|
-
description?: string;
|
|
14
|
-
};
|
|
35
|
+
effects: z.infer<typeof commandEffectsSchema>;
|
|
36
|
+
confirmation: z.infer<typeof commandConfirmationSchema>;
|
|
15
37
|
run: (args: Array<string>) => void | Promise<void>;
|
|
16
38
|
help: string;
|
|
17
|
-
guessedFlags?: Record<string, (args: Array<string>) => Array<string
|
|
39
|
+
guessedFlags?: Record<string, (args: Array<string>) => Array<string> | undefined>;
|
|
18
40
|
};
|
|
19
41
|
export type ParsedRoute = {
|
|
20
42
|
command: string;
|
|
43
|
+
aliases: Array<Array<string>>;
|
|
21
44
|
} & Command;
|
|
22
45
|
export type RouteDef = {
|
|
23
46
|
[key: string]: Command | RouteDef;
|
package/src/types.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const commandEffectsSchema = z.strictObject({
|
|
3
|
+
domain: z.enum(["read", "create", "update", "delete", "replace", "none"]),
|
|
4
|
+
storage: z.enum(["normal-open", "backup", "restore", "migrate", "reindex", "inspect", "none"]),
|
|
5
|
+
});
|
|
6
|
+
export const commandConfirmationSchema = z.strictObject({
|
|
7
|
+
kind: z.enum(["none", "prompt", "project-delete"]),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
});
|