@jinshuju/cli 0.1.3 → 0.2.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 +58 -1
- package/dist/args.d.ts +47 -0
- package/dist/args.js +185 -0
- package/dist/auth.js +43 -11
- package/dist/cli-bin.js +1 -1
- package/dist/cli.d.ts +2 -20
- package/dist/cli.js +71 -659
- package/dist/commands/account.d.ts +2 -0
- package/dist/commands/account.js +15 -0
- package/dist/commands/comment.d.ts +2 -0
- package/dist/commands/comment.js +66 -0
- package/dist/commands/entry.d.ts +31 -0
- package/dist/commands/entry.js +715 -0
- package/dist/commands/field.d.ts +3 -0
- package/dist/commands/field.js +259 -0
- package/dist/commands/folder.d.ts +2 -0
- package/dist/commands/folder.js +31 -0
- package/dist/commands/form.d.ts +2 -0
- package/dist/commands/form.js +394 -0
- package/dist/commands/index.d.ts +16 -0
- package/dist/commands/index.js +68 -0
- package/dist/commands/local.d.ts +10 -0
- package/dist/commands/local.js +76 -0
- package/dist/commands/opensearch.d.ts +2 -0
- package/dist/commands/opensearch.js +73 -0
- package/dist/commands/shared.d.ts +57 -0
- package/dist/commands/shared.js +122 -0
- package/dist/commands/table.d.ts +2 -0
- package/dist/commands/table.js +101 -0
- package/dist/{commands.d.ts → commands/types.d.ts} +24 -30
- package/dist/commands/types.js +1 -0
- package/dist/commands/upload.d.ts +7 -0
- package/dist/commands/upload.js +40 -0
- package/dist/commands/view.d.ts +2 -0
- package/dist/commands/view.js +81 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +45 -5
- package/dist/errors.d.ts +48 -0
- package/dist/errors.js +99 -0
- package/dist/help.d.ts +1 -1
- package/dist/help.js +11 -1
- package/dist/http.d.ts +37 -4
- package/dist/http.js +119 -14
- package/dist/local.d.ts +24 -0
- package/dist/local.js +208 -0
- package/dist/options.d.ts +8 -4
- package/dist/options.js +63 -18
- package/dist/payload.d.ts +14 -8
- package/dist/payload.js +22 -54
- package/dist/render.d.ts +21 -0
- package/dist/render.js +315 -0
- package/dist/result.d.ts +31 -0
- package/dist/result.js +32 -0
- package/dist/values.d.ts +4 -0
- package/dist/values.js +8 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +16 -0
- package/package.json +23 -18
- package/dist/commands.js +0 -1690
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LIMIT_OPTION } from '../options.js';
|
|
2
|
+
import { API, paging } from './shared.js';
|
|
3
|
+
export const ACCOUNT = [
|
|
4
|
+
{
|
|
5
|
+
path: ['account', 'get'],
|
|
6
|
+
summary: 'Show the current account, plan and quota',
|
|
7
|
+
request: () => ({ method: 'GET', path: `${API}/billing_account` })
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
path: ['account', 'member', 'list'],
|
|
11
|
+
summary: 'List account members',
|
|
12
|
+
options: [LIMIT_OPTION],
|
|
13
|
+
request: (input) => ({ method: 'GET', path: `${API}/billing_account/users`, query: paging(input) })
|
|
14
|
+
}
|
|
15
|
+
];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CONTAINER_OPTIONS, UsageError } from '../options.js';
|
|
2
|
+
import { YES_OPTION, confirmed, containerPath, given } from './shared.js';
|
|
3
|
+
/** A comment lives under its entry, so every verb needs the entry as well. */
|
|
4
|
+
const ENTRY_OPTION = {
|
|
5
|
+
name: '--entry',
|
|
6
|
+
type: 'string',
|
|
7
|
+
placeholder: '<serial>',
|
|
8
|
+
description: 'Entry serial number'
|
|
9
|
+
};
|
|
10
|
+
function commentsPath(input) {
|
|
11
|
+
const serial = input.options.entry;
|
|
12
|
+
if (!serial)
|
|
13
|
+
throw new UsageError('--entry <serial> is required');
|
|
14
|
+
return `${containerPath(input)}/entries/${serial}/comments`;
|
|
15
|
+
}
|
|
16
|
+
export const COMMENT = [
|
|
17
|
+
{
|
|
18
|
+
path: ['comment', 'list'],
|
|
19
|
+
summary: "List an entry's comments",
|
|
20
|
+
options: [
|
|
21
|
+
...CONTAINER_OPTIONS,
|
|
22
|
+
{ name: '--entry', type: 'string', placeholder: '<serial>', description: 'Entry serial number' }
|
|
23
|
+
],
|
|
24
|
+
request: (input) => ({ method: 'GET', path: commentsPath(input) })
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
path: ['comment', 'create'],
|
|
28
|
+
summary: 'Comment on an entry',
|
|
29
|
+
args: [{ name: 'content', required: true, description: 'Comment text' }],
|
|
30
|
+
options: [
|
|
31
|
+
...CONTAINER_OPTIONS,
|
|
32
|
+
ENTRY_OPTION,
|
|
33
|
+
{ name: '--reply-to', type: 'string', placeholder: '<comment-id>', description: 'Reply under this comment' }
|
|
34
|
+
],
|
|
35
|
+
request: (input) => ({
|
|
36
|
+
method: 'POST',
|
|
37
|
+
path: `${commentsPath(input)}`,
|
|
38
|
+
body: given({ content: input.args.content, parent_id: input.options.reply_to })
|
|
39
|
+
}),
|
|
40
|
+
examples: ['jinshuju comment create --form Kp7mQ2 --entry 12 "已联系,等回复"']
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: ['comment', 'update'],
|
|
44
|
+
summary: 'Edit a comment',
|
|
45
|
+
args: [
|
|
46
|
+
{ name: 'comment', required: true, description: 'Comment id' },
|
|
47
|
+
{ name: 'content', required: true, description: 'New comment text' }
|
|
48
|
+
],
|
|
49
|
+
options: [...CONTAINER_OPTIONS, ENTRY_OPTION],
|
|
50
|
+
request: (input) => ({
|
|
51
|
+
method: 'PATCH',
|
|
52
|
+
path: `${commentsPath(input)}/${input.args.comment}`,
|
|
53
|
+
body: { content: input.args.content }
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
path: ['comment', 'delete'],
|
|
58
|
+
summary: 'Delete a comment',
|
|
59
|
+
args: [{ name: 'comment', required: true, description: 'Comment id' }],
|
|
60
|
+
options: [...CONTAINER_OPTIONS, ENTRY_OPTION, YES_OPTION],
|
|
61
|
+
request: (input) => {
|
|
62
|
+
confirmed(input, `Deleting comment ${input.args.comment}`);
|
|
63
|
+
return { method: 'DELETE', path: `${commentsPath(input)}/${input.args.comment}` };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Command } from './types.js';
|
|
2
|
+
import { type HttpClient } from '../http.js';
|
|
3
|
+
interface ImportJob {
|
|
4
|
+
readonly job_id: string;
|
|
5
|
+
readonly status: string;
|
|
6
|
+
readonly total_rows?: number | null;
|
|
7
|
+
readonly processed_rows?: number | null;
|
|
8
|
+
readonly error_message?: string | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* How long `--wait` waits before giving up. An import of any size the plan
|
|
12
|
+
* allows finishes well inside this; one that has not is stuck, and a command
|
|
13
|
+
* that never returns is worse than one that says so and names the job.
|
|
14
|
+
*/
|
|
15
|
+
export declare const IMPORT_WAIT_MS: number;
|
|
16
|
+
export type Waiting = {
|
|
17
|
+
step(message: string): void;
|
|
18
|
+
/** How long to wait in all; tests shorten it. */
|
|
19
|
+
deadlineMs?: number;
|
|
20
|
+
/** How to pause between polls, and what time it is; tests replace both. */
|
|
21
|
+
sleep?: (ms: number) => Promise<void>;
|
|
22
|
+
now?: () => number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Waits for the rows to be written. A failed import exits non-zero, because
|
|
26
|
+
* the alternative — answering 0 for an import that wrote nothing — is how a
|
|
27
|
+
* caller comes to believe data is there when it is not.
|
|
28
|
+
*/
|
|
29
|
+
export declare function awaitImport(client: HttpClient, token: string, jobId: string, watching: Waiting): Promise<ImportJob>;
|
|
30
|
+
export declare const ENTRY: readonly Command[];
|
|
31
|
+
export {};
|