@jinshuju/cli 0.25.1 → 0.26.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 +8 -4
- package/dist/commands/field.js +22 -21
- package/dist/commands/form.js +8 -7
- package/dist/generated/operations.js +961 -395
- package/dist/http.d.ts +9 -0
- package/dist/http.js +11 -1
- package/dist/preflight.d.ts +4 -6
- package/dist/preflight.js +4 -32
- package/dist/schema.d.ts +0 -2
- package/dist/schema.js +7 -8
- package/dist/spec.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,13 +252,17 @@ account lacks also answers with `unusable_features`, and these commands and
|
|
|
252
252
|
`field list` keep it beside the fields: the form is saved, but respondents
|
|
253
253
|
cannot submit it until the account upgrades.
|
|
254
254
|
|
|
255
|
+
The CLI asks for API version `2026-11-12` (`Jinshuju-Version`), in which
|
|
256
|
+
`form get`, `table get` and `field list` read each field in the shape
|
|
257
|
+
`field update` takes: a field read goes back as it came, whole or a few of its
|
|
258
|
+
keys, and `null` for a setting clears it or puts it back to its default.
|
|
259
|
+
|
|
255
260
|
A payload is looked at once before it is sent, against the openapi.yaml the
|
|
256
261
|
CLI shipped with, and refused only for what a newer API could not have made
|
|
257
262
|
right: a required key missing, a value of the wrong type, `null` for a key
|
|
258
|
-
that cannot be null
|
|
259
|
-
|
|
260
|
-
the
|
|
261
|
-
fetched, and `--as-is` sends the payload anyway.
|
|
263
|
+
that cannot be null. A key or a value that copy does not list is sent for the
|
|
264
|
+
API to judge, since the API may have learned it since. A refusal names the day
|
|
265
|
+
the copy was fetched, and `--as-is` sends the payload anyway.
|
|
262
266
|
|
|
263
267
|
Data and views:
|
|
264
268
|
|
package/dist/commands/field.js
CHANGED
|
@@ -2,29 +2,28 @@ import { CONTAINER_OPTIONS, JSON_OPTION, UsageError } from '../options.js';
|
|
|
2
2
|
import { call, choices } from '../spec.js';
|
|
3
3
|
import { YES_OPTION, confirmed, onContainer, one, payload, requiredOption } from './shared.js';
|
|
4
4
|
/**
|
|
5
|
-
* One field, or a list of them — the same objects `fields` holds above.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* One field, or a list of them — the same objects `fields` holds above. A
|
|
6
|
+
* field reads in the shape a write takes, so what `field list` answers goes
|
|
7
|
+
* back as it came; what is left to say is which of the keys it carries a
|
|
8
|
+
* write cannot change.
|
|
8
9
|
*/
|
|
9
10
|
const FIELD_PAYLOAD = [
|
|
10
11
|
'{ "type": "TextField", "label": "Notes", "required": false }',
|
|
11
12
|
'',
|
|
12
|
-
'A field as `form get` or `field list` returns it
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
13
|
+
'A field as `form get` or `field list` returns it can be written back as it is, whole or',
|
|
14
|
+
'a few of its keys:',
|
|
15
|
+
' null for a setting clears it, or puts it back to its default',
|
|
16
|
+
' choices are changed with `field update-choices`; `field update` takes them as read,',
|
|
17
|
+
' which changes nothing, and replaces them only on a CascadeDropDown or with a `type`',
|
|
18
|
+
' that turns a text field into a choice field',
|
|
19
|
+
" a key no write can change, like minimum_length or a choice's hidden, goes back only as",
|
|
20
|
+
' it was read; the API answers which key when one differs',
|
|
17
21
|
'',
|
|
18
22
|
'Field types: jinshuju field types'
|
|
19
23
|
];
|
|
20
|
-
/**
|
|
21
|
-
* A form's fields arrive as one object per field, keyed by api_code. A list of
|
|
22
|
-
* fields is what a caller asked for, so it is a list here, with the api_code
|
|
23
|
-
* alongside the rest rather than hidden in the key.
|
|
24
|
-
*/
|
|
24
|
+
/** A form's or table's fields, each with its api_code, as the API answers them. */
|
|
25
25
|
function selectFields(body) {
|
|
26
|
-
|
|
27
|
-
return fields.flatMap((entry) => Object.entries(entry).map(([api_code, attributes]) => ({ api_code, ...attributes })));
|
|
26
|
+
return body?.fields ?? [];
|
|
28
27
|
}
|
|
29
28
|
/** `field_7:choice_1` into the target the check endpoint reads. */
|
|
30
29
|
function parseCheckTarget(target) {
|
|
@@ -148,9 +147,10 @@ export const FIELD = [
|
|
|
148
147
|
summary: 'List the field types a form or table can hold',
|
|
149
148
|
description: 'What to put in `type` when adding a field, and what each type accepts. `structure` is the ' +
|
|
150
149
|
"part no example can carry: the keys that give a type its shape, like a table's columns or " +
|
|
151
|
-
"a cascade's nesting. `settings` are the flat keys beside them, `flags` the booleans
|
|
152
|
-
'
|
|
153
|
-
'
|
|
150
|
+
"a cascade's nesting. `settings` are the flat keys beside them, and `flags` the booleans. " +
|
|
151
|
+
'A field reads back with the `type` it was written with; `read_as` is the name an older API ' +
|
|
152
|
+
'version read it as, which this CLI does not ask for. ' +
|
|
153
|
+
'Name one type to see its structure described in full. A table holds far fewer types ' +
|
|
154
154
|
'than a form, and a scorable question type only belongs to a form that scores answers. ' +
|
|
155
155
|
'`value` is what an entry writes into the type: `example` is a value it takes, exact under ' +
|
|
156
156
|
'--output json, and `note` what the example cannot show.',
|
|
@@ -189,7 +189,8 @@ export const FIELD = [
|
|
|
189
189
|
{
|
|
190
190
|
path: ['field', 'list'],
|
|
191
191
|
summary: 'List the fields of a form or table',
|
|
192
|
-
description:
|
|
192
|
+
description: 'The same fields `form get` and `table get` return, each in the shape `field update` takes, ' +
|
|
193
|
+
`so one can be changed and sent back as it is. ${UNUSABLE_FEATURES}`,
|
|
193
194
|
options: [...CONTAINER_OPTIONS],
|
|
194
195
|
request: (input) => onContainer(input, 'getForm', 'getTable'),
|
|
195
196
|
select: (body) => fieldListing(body, selectFields(body))
|
|
@@ -254,7 +255,7 @@ export const FIELD = [
|
|
|
254
255
|
path: ['field', 'update'],
|
|
255
256
|
summary: 'Update one field',
|
|
256
257
|
description: 'The patch is merged onto the field; the api_code comes from the argument, not the payload. ' +
|
|
257
|
-
'Write
|
|
258
|
+
'Write the keys to change, or the whole field as `field list` read it, as the payload below says. ' +
|
|
258
259
|
WRITE_ANSWER,
|
|
259
260
|
args: [{ name: 'api-code', required: true, description: 'Field api_code, e.g. field_3' }],
|
|
260
261
|
options: [...CONTAINER_OPTIONS, JSON_OPTION],
|
|
@@ -304,7 +305,7 @@ export const FIELD = [
|
|
|
304
305
|
description: 'The conversion happens in place, so the only thing at stake is the data: this reports how ' +
|
|
305
306
|
'many values are kept and how many are cleared. The edit itself is `field update <api-code> ' +
|
|
306
307
|
'--json \'{"type":"TextArea"}\'`, and supported=false means that call would refuse it. ' +
|
|
307
|
-
'source_type and target_type are
|
|
308
|
+
'source_type and target_type are type names as a field reads and writes them (NumberField).',
|
|
308
309
|
args: [
|
|
309
310
|
{ name: 'api-code', required: false, description: 'Field api_code; omit it only when --json names the field' }
|
|
310
311
|
],
|
package/dist/commands/form.js
CHANGED
|
@@ -28,8 +28,8 @@ const FORM_PAYLOAD = [
|
|
|
28
28
|
' }',
|
|
29
29
|
'}',
|
|
30
30
|
'',
|
|
31
|
-
'A choice carries "name".
|
|
32
|
-
'backend assigns,
|
|
31
|
+
'A choice carries "name". It reads back with that text as "value", beside',
|
|
32
|
+
'the "api_code" the backend assigns, which `field update-choices` names it by.',
|
|
33
33
|
'',
|
|
34
34
|
'"setting" is optional and travels as is. When the form takes entries is its',
|
|
35
35
|
'close rules: by_time_range_close_rule opens it between two instants (either',
|
|
@@ -47,9 +47,10 @@ const FORM_PAYLOAD = [
|
|
|
47
47
|
'not-open and fill-limit messages. A key left out keeps its text, and ""',
|
|
48
48
|
'puts the default back.',
|
|
49
49
|
'',
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
'
|
|
50
|
+
'A form reads its fields back in the shape written here, each with the',
|
|
51
|
+
'api_code the backend assigned, and a field read goes back through',
|
|
52
|
+
'`field update` as it came. `field types` lists the types to write, and',
|
|
53
|
+
'`field types <Type>` describes one.',
|
|
53
54
|
'',
|
|
54
55
|
'Field types: jinshuju field types'
|
|
55
56
|
];
|
|
@@ -350,8 +351,8 @@ export const FORM = [
|
|
|
350
351
|
'otherwise, so asking for a form and its rules is one round trip. analytics says which ' +
|
|
351
352
|
'statistics each field takes, which is what the analysis reads validate against. ' +
|
|
352
353
|
"exam_setting is an exam form's, read back in the shape `form edit` writes it. `fields` " +
|
|
353
|
-
'
|
|
354
|
-
'
|
|
354
|
+
'is a list of fields, each with its api_code and in the shape `field update` takes, so a ' +
|
|
355
|
+
'field read here goes back as it came.',
|
|
355
356
|
args: [{ name: 'form', required: true, description: 'Form token, six letters and digits, e.g. Kp7mQ2' }],
|
|
356
357
|
options: [INCLUDE_OPTION],
|
|
357
358
|
request: (input) => call('getForm', { path: { form_token: input.args.form }, query: includes(input) }),
|