@jinshuju/cli 0.10.0 → 0.12.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 +10 -1
- package/dist/commands/account.js +9 -10
- package/dist/commands/checkin.d.ts +2 -0
- package/dist/commands/checkin.js +117 -0
- package/dist/commands/comment.js +10 -11
- package/dist/commands/entry.js +89 -87
- package/dist/commands/field.js +18 -26
- package/dist/commands/fill.d.ts +1 -3
- package/dist/commands/fill.js +17 -9
- package/dist/commands/folder.js +5 -8
- package/dist/commands/form.js +52 -65
- package/dist/commands/index.js +17 -0
- package/dist/commands/opensearch.js +8 -13
- package/dist/commands/shared.d.ts +13 -4
- package/dist/commands/shared.js +12 -8
- package/dist/commands/sms.js +2 -2
- package/dist/commands/table.js +17 -27
- package/dist/commands/trade.js +48 -43
- package/dist/commands/upload.d.ts +9 -2
- package/dist/commands/upload.js +9 -4
- package/dist/commands/view.js +9 -13
- package/dist/generated/operations.d.ts +11 -0
- package/dist/generated/operations.js +4003 -0
- package/dist/options.d.ts +7 -2
- package/dist/options.js +7 -5
- package/dist/spec.d.ts +105 -0
- package/dist/spec.js +201 -0
- package/package.json +8 -4
package/dist/commands/field.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CONTAINER_OPTIONS, JSON_OPTION, UsageError } from '../options.js';
|
|
2
|
-
import {
|
|
2
|
+
import { call } from '../spec.js';
|
|
3
|
+
import { YES_OPTION, confirmed, onContainer, one, payload, requiredOption } from './shared.js';
|
|
3
4
|
/** One field, or a list of them — the same objects `fields` holds above. */
|
|
4
5
|
const FIELD_PAYLOAD = [
|
|
5
6
|
'{ "type": "TextField", "label": "Notes", "required": false }',
|
|
@@ -106,11 +107,12 @@ export const FIELD = [
|
|
|
106
107
|
description: `Only types of this scope: ${FIELD_SCOPES.join(', ')}`
|
|
107
108
|
}
|
|
108
109
|
],
|
|
109
|
-
request: (input) =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
request: (input) => {
|
|
111
|
+
const query = { kind: input.options.kind };
|
|
112
|
+
return input.args.type
|
|
113
|
+
? call('getFieldType', { path: { type: input.args.type }, query })
|
|
114
|
+
: call('listFieldTypes', { query });
|
|
115
|
+
},
|
|
114
116
|
select: (body, input) => {
|
|
115
117
|
const rows = Array.isArray(body.data)
|
|
116
118
|
? body.data
|
|
@@ -131,7 +133,7 @@ export const FIELD = [
|
|
|
131
133
|
summary: 'List the fields of a form or table',
|
|
132
134
|
description: 'Read out of the object structure, the same fields `form get` and `table get` return.',
|
|
133
135
|
options: [...CONTAINER_OPTIONS],
|
|
134
|
-
request: (input) => (
|
|
136
|
+
request: (input) => onContainer(input, 'getForm', 'getTable'),
|
|
135
137
|
select: (body) => ({ data: selectFields(body) })
|
|
136
138
|
},
|
|
137
139
|
{
|
|
@@ -140,11 +142,7 @@ export const FIELD = [
|
|
|
140
142
|
description: 'One field object, or a list of them. Do not pass api_code: the backend generates it.',
|
|
141
143
|
options: [...CONTAINER_OPTIONS, JSON_OPTION],
|
|
142
144
|
payload: FIELD_PAYLOAD,
|
|
143
|
-
request: (input) => ({
|
|
144
|
-
method: 'PATCH',
|
|
145
|
-
path: containerPath(input),
|
|
146
|
-
body: { fields: { add: one(payload(input)) } }
|
|
147
|
-
}),
|
|
145
|
+
request: (input) => onContainer(input, 'updateForm', 'updateTable', { body: { fields: { add: one(payload(input)) } } }),
|
|
148
146
|
select: (body, input) => {
|
|
149
147
|
const labels = labelsOf(payload(input));
|
|
150
148
|
return touchedFields(body, (field) => labels.has(String(field.label)));
|
|
@@ -157,9 +155,7 @@ export const FIELD = [
|
|
|
157
155
|
description: 'The patch is merged onto the field; the api_code comes from the argument, not the payload.',
|
|
158
156
|
args: [{ name: 'api-code', required: true, description: 'Field api_code, e.g. field_3' }],
|
|
159
157
|
options: [...CONTAINER_OPTIONS, JSON_OPTION],
|
|
160
|
-
request: (input) => ({
|
|
161
|
-
method: 'PATCH',
|
|
162
|
-
path: containerPath(input),
|
|
158
|
+
request: (input) => onContainer(input, 'updateForm', 'updateTable', {
|
|
163
159
|
body: {
|
|
164
160
|
fields: { update: [{ ...payload(input), api_code: input.args['api-code'] }] }
|
|
165
161
|
}
|
|
@@ -173,9 +169,7 @@ export const FIELD = [
|
|
|
173
169
|
description: 'The payload is the choice operations the field takes, e.g. {add, update, remove}.',
|
|
174
170
|
args: [{ name: 'api-code', required: true, description: 'Field api_code' }],
|
|
175
171
|
options: [...CONTAINER_OPTIONS, JSON_OPTION],
|
|
176
|
-
request: (input) => ({
|
|
177
|
-
method: 'PATCH',
|
|
178
|
-
path: containerPath(input),
|
|
172
|
+
request: (input) => onContainer(input, 'updateForm', 'updateTable', {
|
|
179
173
|
body: {
|
|
180
174
|
fields: {
|
|
181
175
|
update_choices: [{ ...payload(input), field_api_code: input.args['api-code'] }]
|
|
@@ -192,9 +186,7 @@ export const FIELD = [
|
|
|
192
186
|
'this cannot express — a matrix statement, a cascade level — goes through --json.',
|
|
193
187
|
args: [{ name: 'target', required: false, variadic: true, description: 'field api_code, or api_code:choice' }],
|
|
194
188
|
options: [...CONTAINER_OPTIONS, JSON_OPTION],
|
|
195
|
-
request: (input) => ({
|
|
196
|
-
method: 'GET',
|
|
197
|
-
path: `${containerPath(input)}/fields/check`,
|
|
189
|
+
request: (input) => onContainer(input, 'checkFormFieldData', 'checkTableFieldData', {
|
|
198
190
|
query: { checks: JSON.stringify(checks(input, parseCheckTarget)) }
|
|
199
191
|
}),
|
|
200
192
|
examples: [
|
|
@@ -238,11 +230,9 @@ export const FIELD = [
|
|
|
238
230
|
}
|
|
239
231
|
]
|
|
240
232
|
: one(input.options.json);
|
|
241
|
-
return {
|
|
242
|
-
method: 'GET',
|
|
243
|
-
path: `${containerPath(input)}/fields/preview_convert`,
|
|
233
|
+
return onContainer(input, 'previewFormFieldTypeChange', 'previewTableFieldTypeChange', {
|
|
244
234
|
query: { checks: JSON.stringify(inline) }
|
|
245
|
-
};
|
|
235
|
+
});
|
|
246
236
|
},
|
|
247
237
|
examples: ['jinshuju field preview-convert --form Kp7mQ2 field_1 --to RadioButton']
|
|
248
238
|
},
|
|
@@ -254,7 +244,9 @@ export const FIELD = [
|
|
|
254
244
|
options: [...CONTAINER_OPTIONS, YES_OPTION],
|
|
255
245
|
request: (input) => {
|
|
256
246
|
confirmed(input, `Removing ${input.args['api-code']} and any answers it holds`);
|
|
257
|
-
return
|
|
247
|
+
return onContainer(input, 'updateForm', 'updateTable', {
|
|
248
|
+
body: { fields: { remove: [input.args['api-code']] } }
|
|
249
|
+
});
|
|
258
250
|
},
|
|
259
251
|
examples: ['jinshuju field remove --form Kp7mQ2 field_9 --yes']
|
|
260
252
|
}
|
package/dist/commands/fill.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import type { Command
|
|
2
|
-
/** `/api/v1/fill/<route>/<token>` for a fill link, or for the `f/…` / `v/…` path of one. */
|
|
3
|
-
export declare function fillPagePath(input: CommandInput): string;
|
|
1
|
+
import type { Command } from './types.js';
|
|
4
2
|
export declare const FILL: readonly Command[];
|
package/dist/commands/fill.js
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { UsageError } from '../errors.js';
|
|
2
2
|
import { JSON_OPTION } from '../options.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { call } from '../spec.js';
|
|
4
|
+
/**
|
|
5
|
+
* The two kinds of fill page: `/f/<token>` for a form, `/v/<token>` for a
|
|
6
|
+
* table's form view. The API mirrors them as two operations each, so a link is
|
|
7
|
+
* all it takes to know which.
|
|
8
|
+
*/
|
|
9
|
+
const ROUTES = {
|
|
10
|
+
f: { token: 'form_token', page: 'getFillFormPage', submit: 'createFillFormEntry' },
|
|
11
|
+
v: { token: 'view_token', page: 'getFillViewPage', submit: 'createFillViewEntry' }
|
|
12
|
+
};
|
|
6
13
|
const PAGE_ARG = {
|
|
7
14
|
name: 'page',
|
|
8
15
|
required: true,
|
|
9
16
|
description: 'The fill link as shared, e.g. https://example.jinshuju.net/v/aB3dE9, or just its path: v/aB3dE9'
|
|
10
17
|
};
|
|
11
|
-
/**
|
|
12
|
-
|
|
18
|
+
/** The page's or the submit's request for a fill link, or for the `f/…` / `v/…` path of one. */
|
|
19
|
+
function fillPage(input, what, parts = {}) {
|
|
13
20
|
const page = input.args.page.trim();
|
|
14
21
|
let path = page;
|
|
15
22
|
if (/^https?:\/\//i.test(page)) {
|
|
@@ -21,10 +28,11 @@ export function fillPagePath(input) {
|
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
const [route, token] = path.split('/').filter(Boolean);
|
|
24
|
-
|
|
31
|
+
const kind = route !== undefined && Object.hasOwn(ROUTES, route) ? ROUTES[route] : undefined;
|
|
32
|
+
if (!kind || !token) {
|
|
25
33
|
throw new UsageError(`Not a fill link: ${page}. A fill link ends in /f/<token> or /v/<token>.`);
|
|
26
34
|
}
|
|
27
|
-
return
|
|
35
|
+
return call(kind[what], { ...parts, path: { [kind.token]: token } });
|
|
28
36
|
}
|
|
29
37
|
export const FILL = [
|
|
30
38
|
{
|
|
@@ -36,7 +44,7 @@ export const FILL = [
|
|
|
36
44
|
'not empty the page has to be filled in a browser. `manageable` appears only when you could already ' +
|
|
37
45
|
'read the form or table behind the page.',
|
|
38
46
|
args: [PAGE_ARG],
|
|
39
|
-
request: (input) => (
|
|
47
|
+
request: (input) => fillPage(input, 'page'),
|
|
40
48
|
examples: ['jinshuju fill get https://example.jinshuju.net/v/aB3dE9', 'jinshuju fill get f/Kp7mQ2']
|
|
41
49
|
},
|
|
42
50
|
{
|
|
@@ -63,7 +71,7 @@ export const FILL = [
|
|
|
63
71
|
const body = { entry };
|
|
64
72
|
if (input.options.password !== undefined)
|
|
65
73
|
body.password = input.options.password;
|
|
66
|
-
return
|
|
74
|
+
return fillPage(input, 'submit', { body });
|
|
67
75
|
},
|
|
68
76
|
examples: ['jinshuju fill submit https://example.jinshuju.net/v/aB3dE9 --json \'{"field_1":"张三"}\'']
|
|
69
77
|
}
|
package/dist/commands/folder.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { LIMIT_OPTION } from '../options.js';
|
|
2
|
-
import {
|
|
2
|
+
import { bodyChoices, call } from '../spec.js';
|
|
3
|
+
import { given, paging } from './shared.js';
|
|
3
4
|
export const FOLDER = [
|
|
4
5
|
{
|
|
5
6
|
path: ['folder', 'list'],
|
|
6
7
|
summary: 'List folders',
|
|
7
8
|
options: [LIMIT_OPTION],
|
|
8
|
-
request: (input) => (
|
|
9
|
+
request: (input) => call('listFolders', { query: paging(input) })
|
|
9
10
|
},
|
|
10
11
|
{
|
|
11
12
|
path: ['folder', 'create'],
|
|
@@ -16,16 +17,12 @@ export const FOLDER = [
|
|
|
16
17
|
{
|
|
17
18
|
name: '--kind',
|
|
18
19
|
type: 'string',
|
|
19
|
-
choices:
|
|
20
|
+
choices: bodyChoices('createFolder', 'kind'),
|
|
20
21
|
placeholder: '<kind>',
|
|
21
22
|
description: 'What the folder holds (default form)'
|
|
22
23
|
}
|
|
23
24
|
],
|
|
24
|
-
request: (input) => ({
|
|
25
|
-
method: 'POST',
|
|
26
|
-
path: `${API}/folders`,
|
|
27
|
-
body: { name: input.args.name, kind: input.options.kind }
|
|
28
|
-
}),
|
|
25
|
+
request: (input) => call('createFolder', { body: given({ name: input.args.name, kind: input.options.kind }) }),
|
|
29
26
|
examples: ['jinshuju folder create 2026年活动', 'jinshuju folder create 台账 --kind table']
|
|
30
27
|
}
|
|
31
28
|
];
|
package/dist/commands/form.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FILTER_OPTION, FILTERS_OPTION, JSON_OPTION, MINE_OPTION, PAGINATION_OPTIONS, SORT_OPTION, UsageError } from '../options.js';
|
|
2
|
-
import {
|
|
2
|
+
import { FOLDER_OPTION, LISTING, filters, given, keywords, overriding, paging, payload, refuseWithMine, sort } from './shared.js';
|
|
3
3
|
import { validateContainerPayload } from '../payload.js';
|
|
4
|
-
import {
|
|
4
|
+
import { bodyChoices, call } from '../spec.js';
|
|
5
|
+
import { upload, uploadFormImage } from './upload.js';
|
|
5
6
|
/**
|
|
6
7
|
* The shape behind `--json` on a form, shown rather than described: `fields` is
|
|
7
8
|
* the part nothing else hints at, and one choice field carries more of the
|
|
@@ -76,7 +77,7 @@ function includes(input) {
|
|
|
76
77
|
if (!parameter) {
|
|
77
78
|
throw new UsageError(`--include takes ${Object.keys(FORM_INCLUDES).join(', ')}, got ${JSON.stringify(name)}`);
|
|
78
79
|
}
|
|
79
|
-
query[parameter] =
|
|
80
|
+
query[parameter] = true;
|
|
80
81
|
}
|
|
81
82
|
return query;
|
|
82
83
|
}
|
|
@@ -88,16 +89,7 @@ function themeBody(input) {
|
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
/** The scenes a form can be created for, as the API names them. */
|
|
91
|
-
const FORM_SCENES =
|
|
92
|
-
'survey',
|
|
93
|
-
'registry',
|
|
94
|
-
'vote',
|
|
95
|
-
'exam',
|
|
96
|
-
'reservation',
|
|
97
|
-
'customer_acquisition',
|
|
98
|
-
'evaluation',
|
|
99
|
-
'online_payment'
|
|
100
|
-
];
|
|
92
|
+
const FORM_SCENES = bodyChoices('createForm', 'scene');
|
|
101
93
|
/**
|
|
102
94
|
* A form's type picks both the scene it is created in and the settings block
|
|
103
95
|
* that belongs to it. Those settings live behind their own endpoint, so a
|
|
@@ -107,18 +99,22 @@ const FORM_SCENES = [
|
|
|
107
99
|
*/
|
|
108
100
|
const FORM_TYPES = {
|
|
109
101
|
normal: {},
|
|
110
|
-
exam: { scene: 'exam', settingKey: 'exam_setting',
|
|
111
|
-
evaluation: { scene: 'evaluation', settingKey: 'evaluation_setting',
|
|
102
|
+
exam: { scene: 'exam', settingKey: 'exam_setting', operation: 'updateExamSetting' },
|
|
103
|
+
evaluation: { scene: 'evaluation', settingKey: 'evaluation_setting', operation: 'updateEvaluationSetting' }
|
|
112
104
|
};
|
|
113
|
-
/** Which settings block a payload carries, and
|
|
105
|
+
/** Which settings block a payload carries, and which operation it has to be sent to. */
|
|
114
106
|
function settingsBlock(body) {
|
|
115
|
-
for (const { settingKey,
|
|
116
|
-
if (settingKey &&
|
|
117
|
-
return { key: settingKey,
|
|
107
|
+
for (const { settingKey, operation } of Object.values(FORM_TYPES)) {
|
|
108
|
+
if (settingKey && operation && body[settingKey] !== undefined) {
|
|
109
|
+
return { key: settingKey, operation, value: body[settingKey] };
|
|
118
110
|
}
|
|
119
111
|
}
|
|
120
112
|
return undefined;
|
|
121
113
|
}
|
|
114
|
+
/** A settings block, sent to the form it belongs to. */
|
|
115
|
+
function saveSettings(form, settings) {
|
|
116
|
+
return call(settings.operation, { path: { form_token: form }, body: settings.value });
|
|
117
|
+
}
|
|
122
118
|
/** The scene a --type implies, refusing a --scene that contradicts it. */
|
|
123
119
|
function sceneFor(input) {
|
|
124
120
|
const type = input.options.type ?? 'normal';
|
|
@@ -166,19 +162,17 @@ export const FORM = [
|
|
|
166
162
|
request: (input) => {
|
|
167
163
|
if (input.options.mine) {
|
|
168
164
|
refuseWithMine(input, ['name', 'with_transactions', 'filter', 'filters', 'sort']);
|
|
169
|
-
return
|
|
165
|
+
return call('listMyFilledForms', { query: paging(input) });
|
|
170
166
|
}
|
|
171
|
-
return {
|
|
172
|
-
method: 'GET',
|
|
173
|
-
path: `${API}/forms`,
|
|
167
|
+
return call('listForms', {
|
|
174
168
|
query: {
|
|
175
169
|
q: keywords(input.options.name),
|
|
176
|
-
include_transactions: input.options.with_transactions ?
|
|
170
|
+
include_transactions: input.options.with_transactions ? true : undefined,
|
|
177
171
|
filters: filters(input),
|
|
178
172
|
sort: sort(input, 'field'),
|
|
179
173
|
...paging(input)
|
|
180
174
|
}
|
|
181
|
-
};
|
|
175
|
+
});
|
|
182
176
|
},
|
|
183
177
|
paginate: LISTING,
|
|
184
178
|
examples: [
|
|
@@ -197,11 +191,7 @@ export const FORM = [
|
|
|
197
191
|
'answers the same fields flattened, with api_code on each.',
|
|
198
192
|
args: [{ name: 'form', required: true, description: 'Form token, six letters and digits, e.g. Kp7mQ2' }],
|
|
199
193
|
options: [INCLUDE_OPTION],
|
|
200
|
-
request: (input) => ({
|
|
201
|
-
method: 'GET',
|
|
202
|
-
path: `${API}/forms/${input.args.form}`,
|
|
203
|
-
query: includes(input)
|
|
204
|
-
}),
|
|
194
|
+
request: (input) => call('getForm', { path: { form_token: input.args.form }, query: includes(input) }),
|
|
205
195
|
examples: ['jinshuju form get Kp7mQ2', 'jinshuju form get Kp7mQ2 --include theme,rules,analytics']
|
|
206
196
|
},
|
|
207
197
|
{
|
|
@@ -226,12 +216,12 @@ export const FORM = [
|
|
|
226
216
|
type: 'string',
|
|
227
217
|
choices: FORM_SCENES,
|
|
228
218
|
placeholder: '<scene>',
|
|
229
|
-
description: `What the form is for: ${FORM_SCENES.join(', ')}`
|
|
219
|
+
description: FORM_SCENES ? `What the form is for: ${FORM_SCENES.join(', ')}` : 'What the form is for'
|
|
230
220
|
},
|
|
231
221
|
{
|
|
232
222
|
name: '--layout',
|
|
233
223
|
type: 'string',
|
|
234
|
-
choices:
|
|
224
|
+
choices: bodyChoices('createForm', 'layout'),
|
|
235
225
|
placeholder: '<layout>',
|
|
236
226
|
description: 'classic shows every field at once, card one page at a time'
|
|
237
227
|
},
|
|
@@ -240,14 +230,10 @@ export const FORM = [
|
|
|
240
230
|
run: async (input, client) => {
|
|
241
231
|
const { body, settings } = createFormBody(input);
|
|
242
232
|
if (!settings)
|
|
243
|
-
return client.request(
|
|
244
|
-
const form = await client.request(
|
|
233
|
+
return client.request(call('createForm', { body }));
|
|
234
|
+
const form = await client.request(call('createForm', { body }));
|
|
245
235
|
try {
|
|
246
|
-
await client.request(
|
|
247
|
-
method: 'PATCH',
|
|
248
|
-
path: `${API}/forms/${form.token}/${settings.path}`,
|
|
249
|
-
body: settings.value
|
|
250
|
-
});
|
|
236
|
+
await client.request(saveSettings(form.token, settings));
|
|
251
237
|
}
|
|
252
238
|
catch (error) {
|
|
253
239
|
// The form exists; saying so beats an error that reads as though
|
|
@@ -255,7 +241,7 @@ export const FORM = [
|
|
|
255
241
|
throw new Error(`form ${form.token} was created, but its ${settings.key} was refused: ` +
|
|
256
242
|
`${error.message}. Fix it and apply with \`form edit\`.`, { cause: error });
|
|
257
243
|
}
|
|
258
|
-
return client.request(
|
|
244
|
+
return client.request(call('getForm', { path: { form_token: form.token } }));
|
|
259
245
|
},
|
|
260
246
|
examples: [
|
|
261
247
|
'jinshuju form create --json @form.json',
|
|
@@ -272,23 +258,20 @@ export const FORM = [
|
|
|
272
258
|
args: [{ name: 'form', required: true, description: 'Form token' }],
|
|
273
259
|
options: [JSON_OPTION],
|
|
274
260
|
run: async (input, client) => {
|
|
261
|
+
const form = input.args.form;
|
|
275
262
|
const body = { ...payload(input) };
|
|
276
263
|
const settings = settingsBlock(body);
|
|
277
264
|
if (!settings)
|
|
278
|
-
return client.request(
|
|
265
|
+
return client.request(call('updateForm', { path: { form_token: form }, body }));
|
|
279
266
|
delete body[settings.key];
|
|
280
267
|
// The settings go first: they are the half that can be refused for what
|
|
281
268
|
// the form is, so leading with them is what keeps a refusal from landing
|
|
282
269
|
// after the rest was already written.
|
|
283
|
-
await client.request(
|
|
284
|
-
method: 'PATCH',
|
|
285
|
-
path: `${API}/forms/${input.args.form}/${settings.path}`,
|
|
286
|
-
body: settings.value
|
|
287
|
-
});
|
|
270
|
+
await client.request(saveSettings(form, settings));
|
|
288
271
|
if (Object.keys(body).length === 0)
|
|
289
|
-
return client.request(
|
|
272
|
+
return client.request(call('getForm', { path: { form_token: form } }));
|
|
290
273
|
try {
|
|
291
|
-
return await client.request(
|
|
274
|
+
return await client.request(call('updateForm', { path: { form_token: form }, body }));
|
|
292
275
|
}
|
|
293
276
|
catch (error) {
|
|
294
277
|
// Ordering cannot make two requests atomic; it only chooses which half
|
|
@@ -302,7 +285,7 @@ export const FORM = [
|
|
|
302
285
|
examples: [
|
|
303
286
|
'jinshuju form edit Kp7mQ2 --json \'{"name":"2026 活动报名"}\'',
|
|
304
287
|
'jinshuju form edit Kp7mQ2 --json \'{"setting":{"daily_repeat_close_rule":{"time_periods":[{"start_time":{"hour":11,"minute":0},"end_time":{"hour":12,"minute":40}}]}}}\'',
|
|
305
|
-
'jinshuju form edit Kp7mQ2 --json \'{"exam_setting":{"
|
|
288
|
+
'jinshuju form edit Kp7mQ2 --json \'{"exam_setting":{"limited_time":30}}\''
|
|
306
289
|
]
|
|
307
290
|
},
|
|
308
291
|
{
|
|
@@ -313,9 +296,8 @@ export const FORM = [
|
|
|
313
296
|
{ name: '--name', type: 'string', placeholder: '<name>', description: 'Name for the copy' },
|
|
314
297
|
FOLDER_OPTION
|
|
315
298
|
],
|
|
316
|
-
request: (input) => ({
|
|
317
|
-
|
|
318
|
-
path: `${API}/forms/${input.args.form}/copy`,
|
|
299
|
+
request: (input) => call('copyForm', {
|
|
300
|
+
path: { form_token: input.args.form },
|
|
319
301
|
body: given({ name: input.options.name, folder_token: input.options.folder })
|
|
320
302
|
})
|
|
321
303
|
},
|
|
@@ -324,9 +306,8 @@ export const FORM = [
|
|
|
324
306
|
summary: 'Move a form into a folder, or out of one',
|
|
325
307
|
args: [{ name: 'form', required: true, description: 'Form token' }],
|
|
326
308
|
options: [FOLDER_OPTION],
|
|
327
|
-
request: (input) => ({
|
|
328
|
-
|
|
329
|
-
path: `${API}/forms/${input.args.form}/folder`,
|
|
309
|
+
request: (input) => call('moveFormToFolder', {
|
|
310
|
+
path: { form_token: input.args.form },
|
|
330
311
|
body: { folder_token: input.options.folder ?? '' }
|
|
331
312
|
}),
|
|
332
313
|
examples: ['jinshuju form move Kp7mQ2 --folder Fd2xK8', 'jinshuju form move Kp7mQ2']
|
|
@@ -353,9 +334,9 @@ export const FORM = [
|
|
|
353
334
|
run: async (input, client) => {
|
|
354
335
|
const wallpaper = input.options.wallpaper;
|
|
355
336
|
const header = input.options.header;
|
|
356
|
-
const path =
|
|
337
|
+
const path = { form_token: input.args.form };
|
|
357
338
|
if (!wallpaper && !header)
|
|
358
|
-
return client.request(
|
|
339
|
+
return client.request(call('updateFormTheme', { path, body: themeBody(input) }));
|
|
359
340
|
const body = themeBody(input);
|
|
360
341
|
if (wallpaper) {
|
|
361
342
|
const image = await uploadFormImage(client, wallpaper, 'wallpaper');
|
|
@@ -365,18 +346,28 @@ export const FORM = [
|
|
|
365
346
|
const image = await uploadFormImage(client, header, 'header');
|
|
366
347
|
body.header = { ...body.header, header_image_attachment_id: image };
|
|
367
348
|
}
|
|
368
|
-
return client.request(
|
|
349
|
+
return client.request(call('updateFormTheme', { path, body }));
|
|
369
350
|
},
|
|
370
351
|
examples: [
|
|
371
352
|
'jinshuju form theme set Kp7mQ2 --primary-color "#1F6FEB"',
|
|
372
353
|
'jinshuju form theme set Kp7mQ2 --wallpaper ./bg.png'
|
|
373
354
|
]
|
|
374
355
|
},
|
|
356
|
+
{
|
|
357
|
+
path: ['form', 'image', 'upload'],
|
|
358
|
+
summary: 'Upload an image for a form or field description',
|
|
359
|
+
description: "Answers with a url to put in an <img src> inside a form's description or a field's notes. " +
|
|
360
|
+
'The image belongs to the first form saved with a description that refers to it; one that no ' +
|
|
361
|
+
'form takes within 7 days is removed.',
|
|
362
|
+
args: [{ name: 'file', required: true, description: 'Image file' }],
|
|
363
|
+
request: (input) => upload('uploadFormImage', {}, input.args.file, { image_type: 'description' }),
|
|
364
|
+
examples: ['jinshuju form image upload ./venue-map.png']
|
|
365
|
+
},
|
|
375
366
|
{
|
|
376
367
|
path: ['form', 'rule', 'get'],
|
|
377
368
|
summary: 'Show the field display rules of a form',
|
|
378
369
|
args: [{ name: 'form', required: true, description: 'Form token' }],
|
|
379
|
-
request: (input) => (
|
|
370
|
+
request: (input) => call('listFieldRules', { path: { form_token: input.args.form } })
|
|
380
371
|
},
|
|
381
372
|
{
|
|
382
373
|
path: ['form', 'rule', 'edit'],
|
|
@@ -384,16 +375,12 @@ export const FORM = [
|
|
|
384
375
|
description: 'The payload is {add, update, remove}; a rule is targeted by the index `form rule get` shows.',
|
|
385
376
|
args: [{ name: 'form', required: true, description: 'Form token' }],
|
|
386
377
|
options: [JSON_OPTION],
|
|
387
|
-
request: (input) => ({
|
|
388
|
-
method: 'PATCH',
|
|
389
|
-
path: `${API}/forms/${input.args.form}`,
|
|
390
|
-
body: { field_rules: payload(input) }
|
|
391
|
-
})
|
|
378
|
+
request: (input) => call('updateForm', { path: { form_token: input.args.form }, body: { field_rules: payload(input) } })
|
|
392
379
|
},
|
|
393
380
|
{
|
|
394
381
|
path: ['form', 'cooperator', 'list'],
|
|
395
382
|
summary: 'List the cooperators of a form',
|
|
396
383
|
args: [{ name: 'form', required: true, description: 'Form token' }],
|
|
397
|
-
request: (input) => (
|
|
384
|
+
request: (input) => call('listFormCooperators', { path: { form_token: input.args.form } })
|
|
398
385
|
}
|
|
399
386
|
];
|
package/dist/commands/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* without its help, nor accept a flag it never described.
|
|
9
9
|
*/
|
|
10
10
|
import { ACCOUNT } from './account.js';
|
|
11
|
+
import { CHECKIN } from './checkin.js';
|
|
11
12
|
import { COMMENT } from './comment.js';
|
|
12
13
|
import { ENTRY } from './entry.js';
|
|
13
14
|
import { FIELD } from './field.js';
|
|
@@ -42,6 +43,21 @@ export const RESOURCES = [
|
|
|
42
43
|
{ name: 'entry', summary: 'Manage entries' },
|
|
43
44
|
{ name: 'comment', summary: 'Manage entry comments' },
|
|
44
45
|
{ name: 'opensearch', summary: 'Manage public queries' },
|
|
46
|
+
{
|
|
47
|
+
name: 'checkin',
|
|
48
|
+
summary: 'Check-in campaigns: registrants of a form check in on site',
|
|
49
|
+
note: [
|
|
50
|
+
'Check-in rides on a form: people register by filling the form in, then check in on site.',
|
|
51
|
+
' 1. The form needs a mobile or name field to check in with (`field list --form <token>`),',
|
|
52
|
+
' and its after-submit action must be the default message.',
|
|
53
|
+
' 2. `checkin create --form <token>` turns it on. Registrants then see a check-in code after submitting.',
|
|
54
|
+
" 3. Share the form's fill link for registration. On site, show `checkin_url` as a QR code",
|
|
55
|
+
' for registrants to check themselves in, and send `verifier_invite_url` to staff who verify them.',
|
|
56
|
+
' 4. `checkin edit --disable` pauses check-in; records are kept.',
|
|
57
|
+
'The check-in plugin has to be enabled for the account in the plugin center first.',
|
|
58
|
+
'You see and change only the campaigns you created.'
|
|
59
|
+
].join('\n')
|
|
60
|
+
},
|
|
45
61
|
{
|
|
46
62
|
name: 'fill',
|
|
47
63
|
summary: 'Fill in a form through its fill link',
|
|
@@ -66,6 +82,7 @@ export const COMMANDS = [
|
|
|
66
82
|
...ENTRY,
|
|
67
83
|
...COMMENT,
|
|
68
84
|
...OPENSEARCH,
|
|
85
|
+
...CHECKIN,
|
|
69
86
|
...FILL,
|
|
70
87
|
...TRADE,
|
|
71
88
|
...SMS
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { JSON_OPTION, UsageError } from '../options.js';
|
|
2
|
-
import {
|
|
2
|
+
import { call } from '../spec.js';
|
|
3
|
+
import { overriding, payload } from './shared.js';
|
|
3
4
|
import { uploadFormImage } from './upload.js';
|
|
4
5
|
export const OPENSEARCH = [
|
|
5
6
|
{
|
|
6
7
|
path: ['opensearch', 'list'],
|
|
7
8
|
summary: 'List public queries',
|
|
8
9
|
options: [{ name: '--form', type: 'string', placeholder: '<token>', description: 'Only the queries of this form' }],
|
|
9
|
-
request: (input) => ({
|
|
10
|
-
method: 'GET',
|
|
11
|
-
path: `${API}/opensearch/queries`,
|
|
12
|
-
query: { form_token: input.options.form }
|
|
13
|
-
})
|
|
10
|
+
request: (input) => call('listOpensearchQueries', { query: { form_token: input.options.form } })
|
|
14
11
|
},
|
|
15
12
|
{
|
|
16
13
|
path: ['opensearch', 'get'],
|
|
17
14
|
summary: 'Show a public query',
|
|
18
15
|
args: [{ name: 'query', required: true, description: 'Public query token' }],
|
|
19
|
-
request: (input) => (
|
|
16
|
+
request: (input) => call('getOpensearchQuery', { path: { query_token: input.args.query } })
|
|
20
17
|
},
|
|
21
18
|
{
|
|
22
19
|
path: ['opensearch', 'fields'],
|
|
@@ -26,7 +23,7 @@ export const OPENSEARCH = [
|
|
|
26
23
|
const form = input.options.form;
|
|
27
24
|
if (!form)
|
|
28
25
|
throw new UsageError('--form <token> is required');
|
|
29
|
-
return
|
|
26
|
+
return call('listOpensearchQuerySuggestions', { query: { form_token: form } });
|
|
30
27
|
}
|
|
31
28
|
},
|
|
32
29
|
{
|
|
@@ -41,11 +38,9 @@ export const OPENSEARCH = [
|
|
|
41
38
|
const form = input.options.form;
|
|
42
39
|
if (!form)
|
|
43
40
|
throw new UsageError('--form <token> is required');
|
|
44
|
-
return {
|
|
45
|
-
method: 'POST',
|
|
46
|
-
path: `${API}/opensearch/queries`,
|
|
41
|
+
return call('createOpensearchQuery', {
|
|
47
42
|
body: overriding(payload(input), { form_token: form })
|
|
48
|
-
};
|
|
43
|
+
});
|
|
49
44
|
}
|
|
50
45
|
},
|
|
51
46
|
{
|
|
@@ -72,7 +67,7 @@ export const OPENSEARCH = [
|
|
|
72
67
|
const image = await uploadFormImage(client, header, 'opensearch_header');
|
|
73
68
|
body.header = { background_image: { attachment_id: image } };
|
|
74
69
|
}
|
|
75
|
-
return client.request(
|
|
70
|
+
return client.request(call('updateOpensearchQuery', { path: { query_token: input.args.query }, body }));
|
|
76
71
|
},
|
|
77
72
|
examples: ['jinshuju opensearch edit Qy7nR3 --disable', 'jinshuju opensearch edit Qy7nR3 --header ./banner.png']
|
|
78
73
|
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
import type { HttpRequest } from '../http.js';
|
|
1
2
|
import { type OptionSpec } from '../options.js';
|
|
3
|
+
import { type CallParts, type OperationId } from '../spec.js';
|
|
2
4
|
import type { CommandInput, Pagination } from './types.js';
|
|
3
5
|
/** What more than one resource's commands build their requests from. */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The request for whichever container was named. openapi.yaml has a form's
|
|
8
|
+
* operation and a table's as two, under two paths; the CLI has one command and
|
|
9
|
+
* `--form` or `--table`, so the flag picks the operation and its token fills
|
|
10
|
+
* the path.
|
|
11
|
+
*/
|
|
12
|
+
export declare function onContainer(input: CommandInput, form: OperationId, table: OperationId, parts?: CallParts): HttpRequest;
|
|
7
13
|
/** The conditions themselves. A read sends them as a query string, a write as a body. */
|
|
8
14
|
export declare function filterConditions(input: CommandInput): unknown;
|
|
9
15
|
export declare function filters(input: CommandInput): string | undefined;
|
|
10
16
|
export declare function sort(input: CommandInput, key: 'api_code' | 'field'): string | undefined;
|
|
11
|
-
export declare function paging(input: CommandInput):
|
|
17
|
+
export declare function paging(input: CommandInput): {
|
|
18
|
+
limit?: number;
|
|
19
|
+
next?: string;
|
|
20
|
+
};
|
|
12
21
|
/** The sort rules as the API's own objects, for a body. */
|
|
13
22
|
export declare function sortRules(input: CommandInput): {
|
|
14
23
|
api_code: string;
|
package/dist/commands/shared.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { UsageError, parseFilter, parseSort, resolveContainer } from '../options.js';
|
|
2
|
+
import { call } from '../spec.js';
|
|
2
3
|
/** What more than one resource's commands build their requests from. */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The request for whichever container was named. openapi.yaml has a form's
|
|
6
|
+
* operation and a table's as two, under two paths; the CLI has one command and
|
|
7
|
+
* `--form` or `--table`, so the flag picks the operation and its token fills
|
|
8
|
+
* the path.
|
|
9
|
+
*/
|
|
10
|
+
export function onContainer(input, form, table, parts = {}) {
|
|
6
11
|
const { token, kind } = resolveContainer(input.options);
|
|
7
|
-
return
|
|
12
|
+
return kind === 'table'
|
|
13
|
+
? call(table, { ...parts, path: { ...parts.path, table_token: token } })
|
|
14
|
+
: call(form, { ...parts, path: { ...parts.path, form_token: token } });
|
|
8
15
|
}
|
|
9
16
|
/** The conditions themselves. A read sends them as a query string, a write as a body. */
|
|
10
17
|
export function filterConditions(input) {
|
|
@@ -33,10 +40,7 @@ export function sort(input, key) {
|
|
|
33
40
|
return JSON.stringify(rules.map(parseSort).map((rule) => ({ [key]: rule.field, order: rule.order })));
|
|
34
41
|
}
|
|
35
42
|
export function paging(input) {
|
|
36
|
-
return {
|
|
37
|
-
limit: input.options.limit === undefined ? undefined : String(input.options.limit),
|
|
38
|
-
next: input.options.next
|
|
39
|
-
};
|
|
43
|
+
return { limit: input.options.limit, next: input.options.next };
|
|
40
44
|
}
|
|
41
45
|
/** The sort rules as the API's own objects, for a body. */
|
|
42
46
|
export function sortRules(input) {
|
package/dist/commands/sms.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { call } from '../spec.js';
|
|
2
2
|
export const SMS = [
|
|
3
3
|
{
|
|
4
4
|
path: ['sms', 'status'],
|
|
5
5
|
summary: 'List SMS signatures and templates with their review status and why a review failed',
|
|
6
6
|
description: 'Your own signatures and templates, not those of the rest of the account.',
|
|
7
|
-
request: () => (
|
|
7
|
+
request: () => call('listSmsAuditStatuses')
|
|
8
8
|
}
|
|
9
9
|
];
|