@jinshuju/cli 0.2.0 → 0.3.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 CHANGED
@@ -93,6 +93,28 @@ The settings block is always sent first. It is the half that can be rejected —
93
93
  "this is not an exam form" — and sending it first is what guarantees a rejection
94
94
  leaves every other change unsent.
95
95
 
96
+ ### When the form takes entries
97
+
98
+ `setting` travels as is, on create and on edit. Its close rules decide when the
99
+ form is open; they coexist, and `form get` reads them back in the shape they
100
+ were written. On edit a rule replaces what was there (`time_periods` is the
101
+ whole list) and `{"enabled": false}` removes it.
102
+
103
+ ```bash
104
+ # between two instants; either end may be left out
105
+ jinshuju form edit Kp7mQ2 --json '{"setting":{"by_time_range_close_rule":{"start_time":"2026-10-01T09:00:00+08:00","end_time":"2026-10-07T18:00:00+08:00"}}}'
106
+ # 11:00-12:40 and 17:00-18:30, every day
107
+ jinshuju form edit Kp7mQ2 --json '{"setting":{"daily_repeat_close_rule":{"time_periods":[
108
+ {"start_time":{"hour":11,"minute":0},"end_time":{"hour":12,"minute":40}},
109
+ {"start_time":{"hour":17,"minute":0},"end_time":{"hour":18,"minute":30}}]}}}'
110
+ jinshuju form edit Kp7mQ2 --json '{"setting":{"daily_repeat_close_rule":{"enabled":false}}}'
111
+ jinshuju form edit Kp7mQ2 --json '{"setting":{"by_entries_close_rule":{"limit":100}}}' # closes after 100 entries
112
+ jinshuju form edit Kp7mQ2 --json '{"setting":{"manually_close_rule":{"closed":true}}}' # stops it now
113
+ ```
114
+
115
+ `show_form_before_open` and `show_close_count_down` only hold with a time-range
116
+ or daily rule; without one the save resets them to false.
117
+
96
118
  ## Reading data
97
119
 
98
120
  `entry`, `view`, `field` and `comment` are all top-level resources; the
@@ -6,6 +6,11 @@ export const ACCOUNT = [
6
6
  summary: 'Show the current account, plan and quota',
7
7
  request: () => ({ method: 'GET', path: `${API}/billing_account` })
8
8
  },
9
+ {
10
+ path: ['account', 'me'],
11
+ summary: 'Show who is signed in: name, email, mobile and role in the account',
12
+ request: () => ({ method: 'GET', path: `${API}/me` })
13
+ },
9
14
  {
10
15
  path: ['account', 'member', 'list'],
11
16
  summary: 'List account members',
@@ -90,6 +90,12 @@ const ATTACH_OPTION = {
90
90
  description: 'Upload a file into this attachment field, repeatable. A subtable column names the row it fills: field_5.0.field_2=<file>'
91
91
  };
92
92
  const ATTACH_SHAPE = "--attach must be '<api-code>=<file>', or '<api-code>.<row>.<sub>=<file>' for a subtable column";
93
+ // The write answers success for a value its field could not read and keeps
94
+ // nothing of it, so the only warning a caller gets is the one written here.
95
+ const VALUE_SHAPES = 'Each type takes a value of its own shape — some choices only by code, a time as ' +
96
+ '{hour, minute} — and `field types <Type>` shows it under `value`. A value in a shape its ' +
97
+ 'field cannot read is dropped without an error, as is a key naming no field, so read the ' +
98
+ 'entry back when it matters.';
93
99
  /**
94
100
  * `field_5=/path/a.png`, or `field_5.0.field_2=/path/a.png` for one row of a
95
101
  * subtable column.
@@ -531,7 +537,8 @@ export const ENTRY = [
531
537
  path: ['entry', 'create'],
532
538
  summary: 'Create entries',
533
539
  description: 'The payload is keyed by field api_code, not by field label. --batch takes a list of them and ' +
534
- 'writes them in one request.',
540
+ 'writes them in one request. ' +
541
+ VALUE_SHAPES,
535
542
  options: [...CONTAINER_OPTIONS, JSON_OPTION, BATCH_OPTION, ATTACH_OPTION],
536
543
  run: async (input, client) => {
537
544
  const attached = attachments(input);
@@ -558,7 +565,8 @@ export const ENTRY = [
558
565
  summary: 'Update entries',
559
566
  description: 'The payload merges onto the entry, leaving the fields it does not name alone; --replace ' +
560
567
  'writes the entry as given, clearing the rest. --batch takes [{serial_number, entry}] and ' +
561
- 'always merges.',
568
+ 'always merges. ' +
569
+ VALUE_SHAPES,
562
570
  args: [{ name: 'serial', required: false, description: 'Entry serial number; leave out with --batch' }],
563
571
  options: [
564
572
  ...CONTAINER_OPTIONS,
@@ -92,7 +92,9 @@ export const FIELD = [
92
92
  "a cascade's nesting. `settings` are the flat keys beside them, `flags` the booleans, and " +
93
93
  '`read_as` the name the same field answers with when read back — which is not the name you ' +
94
94
  'write. Name one type to see its structure described in full. A table holds far fewer types ' +
95
- 'than a form, and a scorable question type only belongs to a form that scores answers.',
95
+ 'than a form, and a scorable question type only belongs to a form that scores answers. ' +
96
+ '`value` is what an entry writes into the type: `example` is a value it takes, exact under ' +
97
+ '--output json, and `note` what the example cannot show.',
96
98
  args: [{ name: 'type', required: false, description: 'One type name, e.g. RadioButton' }],
97
99
  options: [
98
100
  KIND_OPTION,
@@ -18,12 +18,28 @@ const FORM_PAYLOAD = [
18
18
  ' { "type": "TextField", "label": "Name", "required": true },',
19
19
  ' { "type": "RadioButton", "label": "Ticket", "choices": [',
20
20
  ' { "name": "Standard" }, { "name": "VIP" } ] }',
21
- ' ]',
21
+ ' ],',
22
+ ' "setting": {',
23
+ ' "by_time_range_close_rule": { "start_time": "2026-10-01T09:00:00+08:00",',
24
+ ' "end_time": "2026-10-07T18:00:00+08:00" },',
25
+ ' "daily_repeat_close_rule": { "time_periods": [',
26
+ ' { "start_time": { "hour": 11, "minute": 0 }, "end_time": { "hour": 12, "minute": 40 } } ] },',
27
+ ' "show_close_count_down": true',
28
+ ' }',
22
29
  '}',
23
30
  '',
24
31
  'A choice carries "name". The "value" it reads back with is the code the',
25
32
  'backend assigns, not what you sent.',
26
33
  '',
34
+ '"setting" is optional and travels as is. When the form takes entries is its',
35
+ 'close rules: by_time_range_close_rule opens it between two instants (either',
36
+ 'may be left out), daily_repeat_close_rule opens it inside time-of-day periods',
37
+ 'every day, by_entries_close_rule {"limit": 100} closes it after that many',
38
+ 'entries, and manually_close_rule {"closed": true} stops it now. The rules',
39
+ 'coexist. show_form_before_open and show_close_count_down only hold with a',
40
+ 'time-range or daily rule. The same keys go in a `form edit` payload, where',
41
+ 'time_periods replaces the list and {"enabled": false} removes a rule.',
42
+ '',
27
43
  'Reading a form back does not give you something you can send again: a field',
28
44
  'written as "TextField" reads as "single_line_text". `field types` lists the',
29
45
  'names to write, and `field types <Type>` describes one.',
@@ -264,7 +280,8 @@ export const FORM = [
264
280
  path: ['form', 'edit'],
265
281
  summary: 'Edit a form',
266
282
  description: 'The payload carries the operations to apply: name, description, setting, and fields as ' +
267
- '{add, update, update_choices, remove}. Only what is named changes.',
283
+ '{add, update, update_choices, remove}. Only what is named changes. `form create --help` ' +
284
+ 'shows what setting takes, the close rules among it.',
268
285
  args: [{ name: 'form', required: true, description: 'Form token' }],
269
286
  options: [JSON_OPTION],
270
287
  run: async (input, client) => {
@@ -297,6 +314,7 @@ export const FORM = [
297
314
  },
298
315
  examples: [
299
316
  'jinshuju form edit Kp7mQ2 --json \'{"name":"2026 活动报名"}\'',
317
+ 'jinshuju form edit Kp7mQ2 --json \'{"setting":{"daily_repeat_close_rule":{"time_periods":[{"start_time":{"hour":11,"minute":0},"end_time":{"hour":12,"minute":40}}]}}}\'',
300
318
  'jinshuju form edit Kp7mQ2 --json \'{"exam_setting":{"total_score":100}}\''
301
319
  ]
302
320
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinshuju/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Command line interface for Jinshuju Open API v1",
5
5
  "homepage": "https://github.com/jinshuju/cli#readme",
6
6
  "bugs": {