@jinshuju/cli 0.27.0 → 0.28.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
@@ -100,8 +100,8 @@ jinshuju form create --json '{
100
100
  block that belongs to it. That settings block has an endpoint of its own, so a
101
101
  payload carrying it becomes two requests — and the general form update does not
102
102
  recognise the key at all (it reads only `name`, `description`, `setting`,
103
- `fields` and `field_rules`), so without the dispatch `exam_setting` would be
104
- dropped in silence.
103
+ `fields`, `field_rules`, `redirect_rules` and `layout`), so without the dispatch
104
+ `exam_setting` would be dropped in silence.
105
105
 
106
106
  The settings block is always sent first. It is the half that can be rejected —
107
107
  "this is not an exam form" — and sending it first is what guarantees a rejection
@@ -232,6 +232,10 @@ jinshuju form copy Kp7mQ2 --name Copy
232
232
  jinshuju form copy Kp7mQ2 --name 第二期 --with-notification-rules
233
233
  jinshuju form move Kp7mQ2 --folder Fd2xK8 # without --folder, moves it out of its folder
234
234
  jinshuju form theme set Kp7mQ2 --primary-color "#1F6FEB"
235
+ jinshuju form setting edit Kp7mQ2 --json '{"weixin_share":{"title":"2026 年会报名"}}' # the card a link shows in WeChat
236
+ jinshuju form redirect-rule edit Kp7mQ2 --json @redirect-rules.json # where a submission meeting conditions goes instead
237
+ jinshuju form cooperator add Kp7mQ2 --user 6512a1c2d3e4f5a6b7c8d9d3 --role data_viewer # account members; no invitation is sent
238
+ jinshuju form result-share create Kp7mQ2 --fields field_2,field_3 --stats field_3 # a link to the results, answered in url
235
239
  jinshuju table create --json @table.json --folder Nf7mDC
236
240
  jinshuju table edit Vn4xR8 --json '{"name":"2026 ledger"}'
237
241
  ```
@@ -280,6 +284,7 @@ jinshuju comment create --form Kp7mQ2 --entry 12 "Contacted, awaiting reply"
280
284
  jinshuju opensearch edit Qy7nR3 --disable
281
285
  jinshuju checkin create --form Kp7mQ2 # needs the check-in plugin enabled for the account
282
286
  jinshuju checkin edit 42 --disable
287
+ jinshuju checkin edit 42 --success-message '签到成功,$(field_1)' # what registrants see once checked in
283
288
  jinshuju notification create --form Kp7mQ2 --approach SMS --recipients field_2 --template-id 6650a1 --placeholder field_1
284
289
  jinshuju notification list --form Kp7mQ2 # each rule says whether it can send, and why not
285
290
  jinshuju notification log 6650b2 --form Kp7mQ2 --from 2026-10-01 # what the rule sent: how many succeeded, failed, and why
@@ -383,7 +388,7 @@ version has no such scope, and the routine commands answer it with 403 (exit
383
388
 
384
389
  ## Working with files
385
390
 
386
- Nine commands take a file. The CLI uploads with its own credential; there is no
391
+ Ten commands take a file. The CLI uploads with its own credential; there is no
387
392
  ticket to fetch first.
388
393
 
389
394
  ```bash
@@ -395,6 +400,7 @@ jinshuju form theme set Kp7mQ2 --wallpaper ./bg.png
395
400
  jinshuju opensearch edit Qy7nR3 --header ./banner.png
396
401
  jinshuju form wheel-fortune edit Kp7mQ2 --json @wheel.json --prize-image 一等奖=./earbuds.png
397
402
  jinshuju form quickpay edit Kp7mQ2 --json @quickpay.json --deliverable-file 电子书=./book.pdf
403
+ jinshuju form setting edit Kp7mQ2 --share-icon ./logo.png # the icon of the card a link shows in WeChat
398
404
  jinshuju form image upload ./venue-map.png # answers with a url for an <img> in a form or field description
399
405
  jinshuju sms signature create 小金培训 --license ./license.jpg --company-name 小金培训有限公司 --company-id 91110000MA00000000 \
400
406
  --id-card-front ./front.jpg --id-card-back ./back.jpg --id-card-name 张三 --id-card-number 110101199001011234 --mobile 13800000000
@@ -9,6 +9,14 @@ const DISPLAY_FIELD_OPTION = {
9
9
  placeholder: '<api-code>',
10
10
  description: 'Field shown to staff when they verify a check-in, usually the name'
11
11
  };
12
+ const SUCCESS_MESSAGE_OPTION = {
13
+ name: '--success-message',
14
+ type: 'string',
15
+ placeholder: '<html>',
16
+ description: 'What registrants see once checked in, HTML allowed: $(field_1) puts in their answer to that field, ' +
17
+ '$(checkin_time) the time and, while the check-in code is on, $(gen_code) the code; any other $(...) ' +
18
+ 'is refused. Takes the admin role on the form'
19
+ };
12
20
  const TIMES_EXAMPLE = 'jinshuju checkin edit 42 --json \'{"date_settings":[{"start_date":"2026-10-20","end_date":"2026-10-21",' +
13
21
  '"periods":["Tuesday"],"durations":[{"start":"09:00","end":"12:00"}]}]}\'';
14
22
  function rest(input) {
@@ -55,6 +63,7 @@ export const CHECKIN = [
55
63
  type: 'boolean',
56
64
  description: 'Also make the check-in field required and unique, so every registrant can be found'
57
65
  },
66
+ SUCCESS_MESSAGE_OPTION,
58
67
  JSON_OPTION
59
68
  ],
60
69
  request: (input) => call('createCheckinCampaign', {
@@ -64,7 +73,8 @@ export const CHECKIN = [
64
73
  checkin_field_api_code: input.options.check_in_field,
65
74
  display_field_api_code: input.options.display_field,
66
75
  enable_checkin_code: input.options.no_check_in_code ? false : undefined,
67
- checkin_field_required_unique: input.options.unique_check_in_field || undefined
76
+ checkin_field_required_unique: input.options.unique_check_in_field || undefined,
77
+ success_message: input.options.success_message
68
78
  })
69
79
  }),
70
80
  examples: [
@@ -82,6 +92,7 @@ export const CHECKIN = [
82
92
  DISPLAY_FIELD_OPTION,
83
93
  { name: '--enable', type: 'boolean', description: 'Resume check-in' },
84
94
  { name: '--disable', type: 'boolean', description: 'Pause check-in; records are kept' },
95
+ SUCCESS_MESSAGE_OPTION,
85
96
  JSON_OPTION
86
97
  ],
87
98
  request: (input) => {
@@ -93,12 +104,14 @@ export const CHECKIN = [
93
104
  body: overriding(rest(input), {
94
105
  name: input.options.name,
95
106
  display_field_api_code: input.options.display_field,
96
- enabled: input.options.enable ? true : input.options.disable ? false : undefined
107
+ enabled: input.options.enable ? true : input.options.disable ? false : undefined,
108
+ success_message: input.options.success_message
97
109
  })
98
110
  });
99
111
  },
100
112
  examples: [
101
113
  'jinshuju checkin edit 42 --disable',
114
+ "jinshuju checkin edit 42 --success-message '签到成功,$(field_1),请到 $(field_3) 入座'",
102
115
  TIMES_EXAMPLE,
103
116
  'jinshuju checkin edit 42 --json \'{"geo_location":null}\''
104
117
  ]
@@ -16,7 +16,7 @@ const FIELD_PAYLOAD = [
16
16
  ' choices are changed with `field update-choices`; `field update` takes them as read,',
17
17
  ' which changes nothing, and replaces them only on a CascadeDropDown or with a `type`',
18
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",
19
+ " a key no write can change, like api_code_alias or a choice's hidden, goes back only as",
20
20
  ' it was read; the API answers which key when one differs',
21
21
  '',
22
22
  'Field types: jinshuju field types'
@@ -1,5 +1,5 @@
1
1
  import { FILTER_OPTION, FILTERS_OPTION, JSON_OPTION, MINE_OPTION, PAGINATION_OPTIONS, SORT_OPTION, UsageError } from '../options.js';
2
- import { FOLDER_OPTION, LISTING, PREVIEW_OPTION, YES_OPTION, filters, given, keywords, overriding, paging, payload, refuseWithMine, requiredOption, sort, trash } from './shared.js';
2
+ import { FOLDER_OPTION, LISTING, PREVIEW_OPTION, YES_OPTION, confirmed, filters, given, keywords, overriding, paging, payload, refuseWithMine, requiredOption, sort, trash } from './shared.js';
3
3
  import { validateContainerPayload } from '../payload.js';
4
4
  import { bodyChoices, call } from '../spec.js';
5
5
  import { readableSize, upload, uploadedId, uploadFormImage } from './upload.js';
@@ -66,6 +66,7 @@ const FORM_INCLUDES = {
66
66
  setting: '',
67
67
  theme: 'include_theme',
68
68
  rules: 'include_field_rules',
69
+ redirect_rules: 'include_redirect_rules',
69
70
  extended: 'include_extended_attributes',
70
71
  transactions: 'include_transactions',
71
72
  analytics: 'include_analytics',
@@ -244,12 +245,121 @@ const DELIVERABLE_FILE_OPTION = {
244
245
  placeholder: '<name>=<file>',
245
246
  description: 'Upload a file for the deliverable of this name in the payload, repeatable'
246
247
  };
248
+ /**
249
+ * What `form redirect-rule edit --json` takes, shown rather than described: the
250
+ * three operations side by side, as `form rule edit` takes them for display rules.
251
+ */
252
+ const REDIRECT_RULE_PAYLOAD = [
253
+ '{',
254
+ ' "add": [',
255
+ ' { "redirect_url": "https://example.com/paper-b", "operator": "or",',
256
+ ' "conditions": [ { "trigger": "field_3", "value": "B 卷" } ] }',
257
+ ' ],',
258
+ ' "update": [ { "index": 0, "redirect_url": "https://example.com/next" } ],',
259
+ ' "remove": [ 1 ]',
260
+ '}',
261
+ '',
262
+ "A submission that meets a rule's conditions goes to its redirect_url instead",
263
+ 'of the success page; "operator" combines the conditions with or (the default)',
264
+ 'or and. A condition names its trigger field by api_code, and the choice it',
265
+ 'compares with by its value or its api_code, which is how it reads back.',
266
+ '"comparator" defaults to the first the field takes, and one it does not take',
267
+ 'is answered with those it does. update and remove name a rule by the index',
268
+ '`form redirect-rule get` shows, and one index cannot be both. Adding or',
269
+ 'changing a rule needs a plan with field_redirect_rules; removing one does',
270
+ 'not. A table has no redirect rules.',
271
+ '',
272
+ 'Trigger fields and their choices: jinshuju field list --form <token>'
273
+ ];
274
+ /**
275
+ * The flags of a result share, beside `--json` for the rest. The three lists are
276
+ * what a share is for, and a list left out on create shows nothing of its kind,
277
+ * so they are the ones worth a flag each.
278
+ */
279
+ const RESULT_SHARE_OPTIONS = [
280
+ { name: '--title', type: 'string', placeholder: '<title>', description: "Page title; the form's name when empty" },
281
+ {
282
+ name: '--fields',
283
+ type: 'list',
284
+ placeholder: '<api-code,...>',
285
+ description: 'Fields whose values visitors see entry by entry'
286
+ },
287
+ {
288
+ name: '--stats',
289
+ type: 'list',
290
+ placeholder: '<api-code,...>',
291
+ description: "Fields whose statistics visitors see; only fields the form's report has statistics for"
292
+ },
293
+ {
294
+ name: '--masked',
295
+ type: 'list',
296
+ placeholder: '<api-code,...>',
297
+ description: "Fields shown partly hidden, such as names and mobile numbers; --masked '' hides none"
298
+ },
299
+ { name: '--password', type: 'string', placeholder: '<password>', description: 'Ask visitors for this password' },
300
+ JSON_OPTION
301
+ ];
302
+ const RESULT_SHARE_ARG = {
303
+ name: 'share',
304
+ required: true,
305
+ description: 'Result share token, from `form result-share list`'
306
+ };
307
+ /** A result share's body: `--json`, with the flags that were given laid over it. */
308
+ function resultShareBody(input) {
309
+ const json = input.options.json;
310
+ if (json !== undefined && !isRecord(json))
311
+ throw new UsageError('--json must be a JSON object');
312
+ if (input.options.enable && input.options.disable) {
313
+ throw new UsageError('--enable and --disable are opposites, pass one');
314
+ }
315
+ const password = input.options.password;
316
+ if (password !== undefined && input.options.no_password) {
317
+ throw new UsageError('--password and --no-password are opposites, pass one');
318
+ }
319
+ return overriding(json ?? {}, {
320
+ title: input.options.title,
321
+ enabled: input.options.enable ? true : input.options.disable ? false : undefined,
322
+ readable_field_api_codes: input.options.fields,
323
+ report_field_api_codes: input.options.stats,
324
+ privacy_protected_field_api_codes: input.options.masked,
325
+ // The API takes a password only beside the switch that asks for it, and
326
+ // turning the switch off is what clears one.
327
+ password_required: password !== undefined ? true : input.options.no_password ? false : undefined,
328
+ access_password: password
329
+ });
330
+ }
331
+ /**
332
+ * What `form setting edit --json` takes, shown rather than described: the
333
+ * WeChat share card, which is the reason the command exists, and one setting
334
+ * `form edit` writes as well, to say the two overlap.
335
+ */
336
+ const SETTING_PAYLOAD = [
337
+ '{',
338
+ ' "weixin_share": {',
339
+ ' "title": "2026 年会报名",',
340
+ ' "description": "点开填写,三分钟搞定",',
341
+ ' "predefined_icon": 3',
342
+ ' },',
343
+ ' "show_progress": true',
344
+ '}',
345
+ '',
346
+ 'Only the keys present are written. weixin_share is the card a link to the form',
347
+ 'shows when shared in WeChat: a null or empty title or description shows the',
348
+ "form's own, and the icon is one of predefined_icon (1 to 35, the settings",
349
+ "page's), icon_image_url or icon_attachment_id, at most one of them; a custom",
350
+ 'icon needs customized_weixin_thumbnail in the plan. --share-icon uploads an',
351
+ 'image and sets icon_attachment_id.',
352
+ '',
353
+ 'Most keys here go in the setting of a `form edit` payload too. weixin_share,',
354
+ 'enable_qrcode, show_progress and the data push (entry_post_url, post_new_entry,',
355
+ 'post_updated_entry) go only here; the payment accounts, payment expiry and',
356
+ 'submission regions only there.',
357
+ '',
358
+ 'The fields success_redirect_fields names by api_code: jinshuju field list --form <token>'
359
+ ];
247
360
  function themeBody(input) {
248
361
  const rest = input.options.json ?? {};
249
- return overriding(rest, {
250
- primary_color: input.options.primary_color,
251
- secondary_color: input.options.secondary_color
252
- });
362
+ return overriding(rest, { primary_color: input.options.primary_color });
253
363
  }
254
364
  /** The scenes a form can be created for, as the API names them. */
255
365
  const FORM_SCENES = bodyChoices('createForm', 'scene');
@@ -258,7 +368,7 @@ const FORM_SCENES = bodyChoices('createForm', 'scene');
258
368
  * that belongs to it. Those settings live behind their own endpoint, so a
259
369
  * payload carrying one is two requests, not one — and a generic edit would
260
370
  * drop the block on the floor, since the form update only reads name,
261
- * description, setting, fields and field_rules.
371
+ * description, setting, fields, field_rules, redirect_rules and layout.
262
372
  */
263
373
  const FORM_TYPES = {
264
374
  normal: {},
@@ -426,7 +536,9 @@ export const FORM = [
426
536
  description: 'The payload carries the operations to apply: name, description, setting, layout, and fields as ' +
427
537
  '{add, update, update_choices, remove}. Only what is named changes. Switching layout keeps every ' +
428
538
  'field; the card layout hides the ones it cannot show and the classic layout shows them again. `form create --help` ' +
429
- 'shows what setting takes, the close rules among it.',
539
+ 'shows what setting takes, the close rules among it; `form setting edit` writes the few settings this ' +
540
+ 'payload cannot, the WeChat share card among them. Display and redirect rules have commands of their ' +
541
+ 'own: `form rule edit` and `form redirect-rule edit`.',
430
542
  args: [{ name: 'form', required: true, description: 'Form token' }],
431
543
  options: [JSON_OPTION],
432
544
  run: async (input, client) => {
@@ -513,13 +625,12 @@ export const FORM = [
513
625
  {
514
626
  path: ['form', 'theme', 'set'],
515
627
  summary: "Set a form's theme",
516
- description: 'The colours have flags of their own, and --wallpaper and --header each upload an image and ' +
628
+ description: 'The primary colour has a flag of its own, and --wallpaper and --header each upload an image and ' +
517
629
  'bind it to the theme in one command. Everything else the theme takes — typography, ' +
518
630
  'form_container, submit_button — goes through --json.',
519
631
  args: [{ name: 'form', required: true, description: 'Form token' }],
520
632
  options: [
521
633
  { name: '--primary-color', type: 'string', placeholder: '<hex>', description: 'Primary colour, e.g. #1F6FEB' },
522
- { name: '--secondary-color', type: 'string', placeholder: '<hex>', description: 'Secondary colour' },
523
634
  {
524
635
  name: '--wallpaper',
525
636
  type: 'string',
@@ -551,6 +662,68 @@ export const FORM = [
551
662
  'jinshuju form theme set Kp7mQ2 --wallpaper ./bg.png'
552
663
  ]
553
664
  },
665
+ {
666
+ path: ['form', 'setting', 'get'],
667
+ summary: "Show a form's settings, the WeChat share card among them",
668
+ description: 'What happens after submitting, when the form takes entries, its access policy and WeChat limits, the ' +
669
+ 'card a link to it shows when shared in WeChat (weixin_share) and its data push. `form get` carries ' +
670
+ 'most of them under setting as well.',
671
+ args: [{ name: 'form', required: true, description: 'Form token' }],
672
+ request: (input) => call('getFormSetting', { path: { form_token: input.args.form } }),
673
+ examples: ['jinshuju form setting get Kp7mQ2']
674
+ },
675
+ {
676
+ path: ['form', 'setting', 'edit'],
677
+ summary: "Edit a form's settings, the WeChat share card among them",
678
+ description: 'Writes the settings through their own endpoint, which takes the few that a `form edit` payload ' +
679
+ 'cannot: the WeChat share card above all. --share-icon uploads an image and makes it the icon of ' +
680
+ 'that card in one command.',
681
+ payload: SETTING_PAYLOAD,
682
+ args: [{ name: 'form', required: true, description: 'Form token' }],
683
+ options: [
684
+ JSON_OPTION,
685
+ {
686
+ name: '--share-icon',
687
+ type: 'string',
688
+ placeholder: '<file>',
689
+ description: 'Image file to use as the icon of the card a link to the form shows in WeChat'
690
+ }
691
+ ],
692
+ run: async (input, client) => {
693
+ const json = input.options.json;
694
+ const icon = input.options.share_icon;
695
+ if (json === undefined && icon === undefined)
696
+ throw new UsageError('pass --json, --share-icon or both');
697
+ if (json !== undefined && !isRecord(json))
698
+ throw new UsageError('--json must be a JSON object');
699
+ const path = { form_token: input.args.form };
700
+ const body = { ...json };
701
+ if (icon === undefined)
702
+ return client.request(call('updateFormSetting', { path, body }));
703
+ const share = isRecord(body.weixin_share) ? body.weixin_share : {};
704
+ // The other two icon keys would be refused beside the uploaded one, so
705
+ // they are said to clash before an image goes up for nothing.
706
+ for (const key of ['predefined_icon', 'icon_image_url', 'icon_attachment_id']) {
707
+ if (share[key] !== undefined)
708
+ throw new UsageError(`--share-icon sets the icon, so weixin_share.${key} cannot`);
709
+ }
710
+ client.check?.(call('updateFormSetting', { path, body: { ...body, weixin_share: { ...share } } }));
711
+ const attachment = await uploadFormImage(client, icon, 'weixin_share_icon');
712
+ const saved = { ...body, weixin_share: { ...share, icon_attachment_id: attachment } };
713
+ try {
714
+ return await client.request(call('updateFormSetting', { path, body: saved }));
715
+ }
716
+ catch (error) {
717
+ throw new Error(`uploaded ${icon} as icon_attachment_id ${attachment}, but saving the settings failed: ` +
718
+ `${error.message}. Put the id in weixin_share to run again without uploading it again.`, { cause: error });
719
+ }
720
+ },
721
+ examples: [
722
+ 'jinshuju form setting edit Kp7mQ2 --json \'{"weixin_share":{"title":"2026 年会报名","description":"点开填写,三分钟搞定"}}\'',
723
+ 'jinshuju form setting edit Kp7mQ2 --json \'{"weixin_share":{"predefined_icon":3}}\'',
724
+ 'jinshuju form setting edit Kp7mQ2 --share-icon ./logo.png'
725
+ ]
726
+ },
554
727
  {
555
728
  path: ['form', 'image', 'upload'],
556
729
  summary: 'Upload an image for a form or field description',
@@ -565,7 +738,8 @@ export const FORM = [
565
738
  path: ['form', 'rule', 'get'],
566
739
  summary: 'Show the field display rules of a form',
567
740
  args: [{ name: 'form', required: true, description: 'Form token' }],
568
- request: (input) => call('listFieldRules', { path: { form_token: input.args.form } })
741
+ request: (input) => call('listFieldRules', { path: { form_token: input.args.form } }),
742
+ text: { essentialLists: ['conditions'] }
569
743
  },
570
744
  {
571
745
  path: ['form', 'rule', 'edit'],
@@ -575,6 +749,98 @@ export const FORM = [
575
749
  options: [JSON_OPTION],
576
750
  request: (input) => call('updateForm', { path: { form_token: input.args.form }, body: { field_rules: payload(input) } })
577
751
  },
752
+ {
753
+ path: ['form', 'redirect-rule', 'get'],
754
+ summary: 'Show where a form sends a submission that meets conditions, instead of its success page',
755
+ description: 'Each rule with the index `form redirect-rule edit` names it by. They take effect on a plan with ' +
756
+ 'field_redirect_rules; `form get --include redirect_rules` reads them along with the form.',
757
+ args: [{ name: 'form', required: true, description: 'Form token' }],
758
+ request: (input) => call('listRedirectRules', { path: { form_token: input.args.form } }),
759
+ // A rule without its conditions says where a submission goes but not when,
760
+ // and a table of rules has no room for them.
761
+ text: { essentialLists: ['conditions'] },
762
+ examples: ['jinshuju form redirect-rule get Kp7mQ2']
763
+ },
764
+ {
765
+ path: ['form', 'redirect-rule', 'edit'],
766
+ summary: 'Edit where a form sends a submission that meets conditions, instead of its success page',
767
+ description: 'The payload is {add, update, remove}; a rule is targeted by the index `form redirect-rule get` shows. ' +
768
+ 'One redirect for every submission is the setting instead: entry_submit_mode and success_redirect_url ' +
769
+ 'in a `form edit` payload.',
770
+ payload: REDIRECT_RULE_PAYLOAD,
771
+ args: [{ name: 'form', required: true, description: 'Form token' }],
772
+ options: [JSON_OPTION],
773
+ request: (input) => call('updateForm', { path: { form_token: input.args.form }, body: { redirect_rules: payload(input) } }),
774
+ examples: [
775
+ 'jinshuju form redirect-rule edit Kp7mQ2 --json \'{"add":[{"redirect_url":"https://example.com/paper-b","conditions":[{"trigger":"field_3","value":"B 卷"}]}]}\'',
776
+ 'jinshuju form redirect-rule edit Kp7mQ2 --json \'{"remove":[0]}\''
777
+ ]
778
+ },
779
+ {
780
+ path: ['form', 'result-share', 'list'],
781
+ summary: "List a form's result shares (结果分享), newest first",
782
+ description: "Links that show the form's entries and statistics to whoever opens them, each with its url.",
783
+ args: [{ name: 'form', required: true, description: 'Form token' }],
784
+ request: (input) => call('listOpenResults', { path: { form_token: input.args.form } }),
785
+ examples: ['jinshuju form result-share list Kp7mQ2']
786
+ },
787
+ {
788
+ path: ['form', 'result-share', 'get'],
789
+ summary: 'Show a result share and its link',
790
+ args: [{ name: 'form', required: true, description: 'Form token' }, RESULT_SHARE_ARG],
791
+ request: (input) => call('getOpenResult', { path: { form_token: input.args.form, token: input.args.share } }),
792
+ examples: ['jinshuju form result-share get Kp7mQ2 Rs8kT2']
793
+ },
794
+ {
795
+ path: ['form', 'result-share', 'create'],
796
+ summary: "Share a form's results through a link, answered in url",
797
+ description: 'Visitors see the values of --fields entry by entry and the statistics of --stats; a list left out ' +
798
+ "shows nothing of its kind. The rest takes the settings page's defaults: anyone with the link gets in, " +
799
+ 'without a password, and every field that can be partly hidden is, which --masked replaces. ' +
800
+ 'Forms only, not quick payment forms; the plan must include 结果分享, and caps how many a form has.',
801
+ args: [{ name: 'form', required: true, description: 'Form token' }],
802
+ options: RESULT_SHARE_OPTIONS,
803
+ request: (input) => call('createOpenResult', { path: { form_token: input.args.form }, body: resultShareBody(input) }),
804
+ examples: [
805
+ 'jinshuju form result-share create Kp7mQ2 --title 积分公示 --fields field_2,field_3 --stats field_3',
806
+ 'jinshuju form result-share create Kp7mQ2 --stats field_4 --password 2026'
807
+ ]
808
+ },
809
+ {
810
+ path: ['form', 'result-share', 'edit'],
811
+ summary: 'Edit a result share, or turn it off and on',
812
+ description: 'Only what is named changes, and a list given replaces the one stored; the link stays the same. ' +
813
+ 'A share open only to submitters or behind SMS verification keeps that audience, and is changed ' +
814
+ 'on the settings page.',
815
+ args: [{ name: 'form', required: true, description: 'Form token' }, RESULT_SHARE_ARG],
816
+ options: [
817
+ ...RESULT_SHARE_OPTIONS,
818
+ { name: '--no-password', type: 'boolean', description: 'Let visitors in without a password again' },
819
+ { name: '--enable', type: 'boolean', description: 'Turn the link back on' },
820
+ { name: '--disable', type: 'boolean', description: 'Keep the link, showing visitors that nothing is shared' }
821
+ ],
822
+ request: (input) => {
823
+ const body = resultShareBody(input);
824
+ if (Object.keys(body).length === 0)
825
+ throw new UsageError('name something to change, with a flag or --json');
826
+ return call('updateOpenResult', { path: { form_token: input.args.form, token: input.args.share }, body });
827
+ },
828
+ examples: [
829
+ 'jinshuju form result-share edit Kp7mQ2 Rs8kT2 --fields field_2,field_3,field_5',
830
+ 'jinshuju form result-share edit Kp7mQ2 Rs8kT2 --disable'
831
+ ]
832
+ },
833
+ {
834
+ path: ['form', 'result-share', 'delete'],
835
+ summary: 'Delete a result share; its link stops working',
836
+ args: [{ name: 'form', required: true, description: 'Form token' }, RESULT_SHARE_ARG],
837
+ options: [YES_OPTION],
838
+ request: (input) => {
839
+ confirmed(input, `Deleting result share ${input.args.share}`, 'stops its link for good');
840
+ return call('deleteOpenResult', { path: { form_token: input.args.form, token: input.args.share } });
841
+ },
842
+ examples: ['jinshuju form result-share delete Kp7mQ2 Rs8kT2 --yes']
843
+ },
578
844
  {
579
845
  path: ['form', 'wheel-fortune', 'get'],
580
846
  summary: "Show a form's lucky wheel: prizes, draws, how winners redeem",
@@ -707,7 +973,49 @@ export const FORM = [
707
973
  {
708
974
  path: ['form', 'cooperator', 'list'],
709
975
  summary: 'List the cooperators of a form',
710
- args: [{ name: 'form', required: true, description: 'Form token' }],
976
+ description: "A table's token reads a table's cooperators the same way.",
977
+ args: [{ name: 'form', required: true, description: 'Form token, or a table token' }],
711
978
  request: (input) => call('listFormCooperators', { path: { form_token: input.args.form } })
979
+ },
980
+ {
981
+ path: ['form', 'cooperator', 'add'],
982
+ summary: 'Add account members to a form as cooperators, all with one role',
983
+ description: "As adding team members on the form's cooperation page does; no invitation is sent. Only active " +
984
+ 'members of the account can be added, by the id `account member list` shows. One deactivated, ' +
985
+ 'outside the account or a cooperator already (through a folder too) adds nobody, and so does ' +
986
+ 'needing more seats than the form has left outside the Enterprise plans. A table token adds ' +
987
+ 'cooperators to the table, which has only the manager and data_viewer roles.',
988
+ args: [{ name: 'form', required: true, description: 'Form token, or a table token' }],
989
+ options: [
990
+ {
991
+ name: '--user',
992
+ type: 'string',
993
+ repeatable: true,
994
+ placeholder: '<id>',
995
+ description: 'Account member id, from `jinshuju account member list`; repeatable, up to 100'
996
+ },
997
+ {
998
+ name: '--role',
999
+ type: 'string',
1000
+ choices: bodyChoices('createFormCooperators', 'role'),
1001
+ placeholder: '<role>',
1002
+ description: 'manager administers the form, data_maintainer adds, edits, deletes and exports entries, ' +
1003
+ 'data_viewer reads and exports them'
1004
+ }
1005
+ ],
1006
+ request: (input) => {
1007
+ const users = input.options.user ?? [];
1008
+ if (users.length === 0) {
1009
+ throw new UsageError('--user is required: an account member id, from `jinshuju account member list`');
1010
+ }
1011
+ return call('createFormCooperators', {
1012
+ path: { form_token: input.args.form },
1013
+ body: { user_ids: users, role: requiredOption(input, 'role') }
1014
+ });
1015
+ },
1016
+ examples: [
1017
+ 'jinshuju form cooperator add Kp7mQ2 --user 6512a1c2d3e4f5a6b7c8d9d3 --role data_viewer',
1018
+ 'jinshuju form cooperator add Kp7mQ2 --user 6512a1c2d3e4f5a6b7c8d9d3 --user 6512a1c2d3e4f5a6b7c8d9d4 --role manager'
1019
+ ]
712
1020
  }
713
1021
  ];
@@ -4,7 +4,7 @@ import { type OperationId } from '../spec.js';
4
4
  * What the CLI uploads a form image as. A test holds the list to the spec's
5
5
  * `image_type`, which is where it would otherwise drift.
6
6
  */
7
- export declare const FORM_IMAGE_TYPES: readonly ["description", "header", "wallpaper", "opensearch_header", "wheel_fortune_prize"];
7
+ export declare const FORM_IMAGE_TYPES: readonly ["description", "header", "wallpaper", "opensearch_header", "wheel_fortune_prize", "weixin_share_icon"];
8
8
  export type FormImageType = (typeof FORM_IMAGE_TYPES)[number];
9
9
  /**
10
10
  * A file on disk, as multipart. The three endpoints that take one authenticate
@@ -29,8 +29,8 @@ interface Upload {
29
29
  /** A file uploaded with a progress line while it goes, answered by its id. */
30
30
  export declare function uploadedId(client: HttpClient, { id, path, file, extra, key }: Upload): Promise<string>;
31
31
  /**
32
- * An image that a form's theme, one of its public queries or a prize of its lucky wheel
33
- * refers to by id, uploaded with `imageType` saying which.
32
+ * An image that a form's theme, one of its public queries, a prize of its lucky wheel
33
+ * or its WeChat share card refers to by id, uploaded with `imageType` saying which.
34
34
  */
35
35
  export declare function uploadFormImage(client: HttpClient, file: string, imageType: FormImageType): Promise<string>;
36
36
  export {};
@@ -30,7 +30,8 @@ export const FORM_IMAGE_TYPES = [
30
30
  'header',
31
31
  'wallpaper',
32
32
  'opensearch_header',
33
- 'wheel_fortune_prize'
33
+ 'wheel_fortune_prize',
34
+ 'weixin_share_icon'
34
35
  ];
35
36
  /**
36
37
  * A file on disk, as multipart. The three endpoints that take one authenticate
@@ -82,8 +83,8 @@ export async function uploadedId(client, { id, path = {}, file, extra, key }) {
82
83
  }
83
84
  }
84
85
  /**
85
- * An image that a form's theme, one of its public queries or a prize of its lucky wheel
86
- * refers to by id, uploaded with `imageType` saying which.
86
+ * An image that a form's theme, one of its public queries, a prize of its lucky wheel
87
+ * or its WeChat share card refers to by id, uploaded with `imageType` saying which.
87
88
  */
88
89
  export function uploadFormImage(client, file, imageType) {
89
90
  return uploadedId(client, { id: 'uploadFormImage', file, extra: { image_type: imageType }, key: 'attachment_id' });
@@ -3830,6 +3830,7 @@ export const SCHEMAS = {
3830
3830
  buttons: { type: 'array', minItems: 1, items: { $ref: 'WidgetButtonItemInput' } },
3831
3831
  segments: { type: 'array', minItems: 1, items: { $ref: 'SequenceSegmentInput' } },
3832
3832
  display_field_api_codes: { type: 'array', maxItems: 20, items: { type: 'string' } },
3833
+ masked_display_field_api_codes: { type: 'array', maxItems: 20, items: { type: 'string' } },
3833
3834
  init_row_length: { type: 'integer', minimum: 1 },
3834
3835
  widget_images: { type: 'array', items: { $ref: 'WidgetImageInput' } },
3835
3836
  answers: { type: 'array', items: { $ref: 'AnswerInput' } },
@@ -4139,6 +4140,7 @@ export const SCHEMAS = {
4139
4140
  position: { type: 'integer', minimum: 0 },
4140
4141
  unique: { type: 'boolean' },
4141
4142
  display_field_api_codes: { type: 'array', maxItems: 20, items: { type: 'string' } },
4143
+ masked_display_field_api_codes: { type: 'array', maxItems: 20, items: { type: 'string' } },
4142
4144
  associated_form_token: { type: 'string' },
4143
4145
  associated_field_api_codes: { type: 'array', minItems: 1, maxItems: 4, items: { type: 'string' } },
4144
4146
  privacy_safe: { type: 'boolean' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinshuju/cli",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Command line interface for Jinshuju Open API v1",
5
5
  "homepage": "https://github.com/jinshuju/cli#readme",
6
6
  "bugs": {