@jinshuju/cli 0.14.0 → 0.16.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 +107 -2
- package/dist/cli.js +5 -1
- package/dist/commands/account.js +7 -0
- package/dist/commands/email.d.ts +2 -0
- package/dist/commands/email.js +161 -0
- package/dist/commands/folder.js +8 -0
- package/dist/commands/form.js +14 -3
- package/dist/commands/index.js +24 -2
- package/dist/commands/notification.d.ts +2 -0
- package/dist/commands/notification.js +135 -0
- package/dist/commands/routine.d.ts +13 -0
- package/dist/commands/routine.js +353 -0
- package/dist/commands/shared.d.ts +23 -0
- package/dist/commands/shared.js +73 -1
- package/dist/commands/sms.js +570 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/generated/operations.d.ts +1 -1
- package/dist/generated/operations.js +731 -2
- package/dist/http.js +17 -1
- package/dist/spec.js +16 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -111,7 +111,10 @@ leaves every other change unsent.
|
|
|
111
111
|
`setting` travels as is, on create and on edit. Its close rules decide when the
|
|
112
112
|
form is open; they coexist, and `form get` reads them back in the shape they
|
|
113
113
|
were written. On edit a rule replaces what was there (`time_periods` is the
|
|
114
|
-
whole list)
|
|
114
|
+
whole list). A time-range, daily or entries rule is removed by
|
|
115
|
+
`{"enabled": false}` or by `null`. `manually_close_rule` is a switch rather
|
|
116
|
+
than a rule: `{"closed": false}` reopens the form, and changing `closed` either
|
|
117
|
+
way deletes the other three rules.
|
|
115
118
|
|
|
116
119
|
```bash
|
|
117
120
|
# between two instants; either end may be left out
|
|
@@ -122,7 +125,9 @@ jinshuju form edit Kp7mQ2 --json '{"setting":{"daily_repeat_close_rule":{"time_p
|
|
|
122
125
|
{"start_time":{"hour":17,"minute":0},"end_time":{"hour":18,"minute":30}}]}}}'
|
|
123
126
|
jinshuju form edit Kp7mQ2 --json '{"setting":{"daily_repeat_close_rule":{"enabled":false}}}'
|
|
124
127
|
jinshuju form edit Kp7mQ2 --json '{"setting":{"by_entries_close_rule":{"limit":100}}}' # closes after 100 entries
|
|
128
|
+
jinshuju form edit Kp7mQ2 --json '{"setting":{"by_entries_close_rule":null}}' # takes the limit off
|
|
125
129
|
jinshuju form edit Kp7mQ2 --json '{"setting":{"manually_close_rule":{"closed":true}}}' # stops it now
|
|
130
|
+
jinshuju form edit Kp7mQ2 --json '{"setting":{"manually_close_rule":{"closed":false}}}' # reopens it
|
|
126
131
|
```
|
|
127
132
|
|
|
128
133
|
`show_form_before_open` and `show_close_count_down` only hold with a time-range
|
|
@@ -139,6 +144,7 @@ jinshuju entry list --form Kp7mQ2
|
|
|
139
144
|
jinshuju entry list --table Vn4xR8
|
|
140
145
|
jinshuju entry get 1 --form Kp7mQ2
|
|
141
146
|
jinshuju entry list --form Kp7mQ2 --view aB3dE9
|
|
147
|
+
jinshuju folder get Fd2xK8 # the folder a form or table's folder_token names
|
|
142
148
|
```
|
|
143
149
|
|
|
144
150
|
Filtering, sorting and paging:
|
|
@@ -217,6 +223,7 @@ issues exactly one request, and payload keys are field `api_code`s.
|
|
|
217
223
|
jinshuju folder create Ledgers --kind table # folders are form or table; a table cannot go in a form folder
|
|
218
224
|
jinshuju form edit Kp7mQ2 --json '{"name":"2026 signups"}'
|
|
219
225
|
jinshuju form copy Kp7mQ2 --name Copy
|
|
226
|
+
jinshuju form copy Kp7mQ2 --name 第二期 --with-notification-rules
|
|
220
227
|
jinshuju form move Kp7mQ2 --folder Fd2xK8 # without --folder, moves it out of its folder
|
|
221
228
|
jinshuju form theme set Kp7mQ2 --primary-color "#1F6FEB"
|
|
222
229
|
jinshuju table create --json @table.json --folder Nf7mDC
|
|
@@ -247,6 +254,8 @@ jinshuju comment create --form Kp7mQ2 --entry 12 "Contacted, awaiting reply"
|
|
|
247
254
|
jinshuju opensearch edit Qy7nR3 --disable
|
|
248
255
|
jinshuju checkin create --form Kp7mQ2 # needs the check-in plugin enabled for the account
|
|
249
256
|
jinshuju checkin edit 42 --disable
|
|
257
|
+
jinshuju notification create --form Kp7mQ2 --approach SMS --recipients field_2 --sms-template 6650a1 --placeholders field_1
|
|
258
|
+
jinshuju notification list --form Kp7mQ2 # each rule says whether it can send, and why not
|
|
250
259
|
```
|
|
251
260
|
|
|
252
261
|
Deletion always requires `--yes`. This CLI is non-interactive — stdin belongs to
|
|
@@ -303,9 +312,50 @@ person at it can do — a captcha, an SMS code, WeChat, a payment — lists it u
|
|
|
303
312
|
`blockers`, and is refused until it is filled in a browser. An OAuth session
|
|
304
313
|
needs the `submit_entries` scope for these.
|
|
305
314
|
|
|
315
|
+
## Routines (自动任务)
|
|
316
|
+
|
|
317
|
+
A routine is an instruction Jiri carries out on a schedule, or when the data of
|
|
318
|
+
a form or table changes. One created here is active at once, the same as one
|
|
319
|
+
created on the 自动任务 page, and is held to that page's rules and words.
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
jinshuju routine create --name 每周报名汇总 --description 每周一汇总上周报名,按渠道统计 \
|
|
323
|
+
--instruction '汇总上周报名表新增的数据' --object form:Kp7mQ2 --schedule 'weekly 1 09:00'
|
|
324
|
+
jinshuju routine create --json @routine.json # an event trigger and its conditions
|
|
325
|
+
jinshuju routine list --state active
|
|
326
|
+
jinshuju routine get 6ac5f0e2b1d4c3a2f1e0d9c8 # trigger_text, next_runs, objects, url
|
|
327
|
+
jinshuju routine update 6ac5f0e2b1d4c3a2f1e0d9c8 --schedule 'workdays 08:30'
|
|
328
|
+
jinshuju routine pause 6ac5f0e2b1d4c3a2f1e0d9c8
|
|
329
|
+
jinshuju routine resume 6ac5f0e2b1d4c3a2f1e0d9c8
|
|
330
|
+
jinshuju routine run 6ac5f0e2b1d4c3a2f1e0d9c8 # once, now
|
|
331
|
+
jinshuju routine runs 6ac5f0e2b1d4c3a2f1e0d9c8
|
|
332
|
+
jinshuju routine delete 6ac5f0e2b1d4c3a2f1e0d9c8 --yes
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
`--schedule` is Beijing time and covers the six frequencies: `once 2026-10-12
|
|
336
|
+
09:00`, `hourly 30`, `daily 09:00`, `workdays 09:00`, `weekly 1,5 09:00` (1 is
|
|
337
|
+
Monday) and `monthly 1,-1 09:00` (-1 is the last day). `--object kind:token`
|
|
338
|
+
names a form, table, view or public query, and given, it is the whole list.
|
|
339
|
+
`--description` is the one sentence the routines list shows people, up to 100
|
|
340
|
+
characters; the instruction is written for Jiri.
|
|
341
|
+
Flags lay over `--json`; `routine create --help` shows the full payload, events
|
|
342
|
+
and conditions included. A routine against the page's rules exits 5 with every
|
|
343
|
+
reason the page gives.
|
|
344
|
+
|
|
345
|
+
Letting a routine delete data (`delete_authorized`) is turned on on the
|
|
346
|
+
自动任务 page only. There is no flag for it, and a payload naming it, true or
|
|
347
|
+
false, is refused before anything is sent — `routine get` answers with it, so
|
|
348
|
+
take it out before sending a routine read back. A routine's own run cannot
|
|
349
|
+
create or change routines; it may read them.
|
|
350
|
+
|
|
351
|
+
Routines belong to a person, so an account access token cannot manage them. A
|
|
352
|
+
browser login asks for the `routines` OAuth scope; a login made with an older
|
|
353
|
+
version has no such scope, and the routine commands answer it with 403 (exit
|
|
354
|
+
3). Run `jinshuju auth login` again to get a token that has it.
|
|
355
|
+
|
|
306
356
|
## Working with files
|
|
307
357
|
|
|
308
|
-
|
|
358
|
+
Seven commands take a file. The CLI uploads with its own credential; there is no
|
|
309
359
|
ticket to fetch first.
|
|
310
360
|
|
|
311
361
|
```bash
|
|
@@ -316,6 +366,9 @@ jinshuju entry create --form Kp7mQ2 --json '{"field_1":"Alice"}' --attach field_
|
|
|
316
366
|
jinshuju form theme set Kp7mQ2 --wallpaper ./bg.png
|
|
317
367
|
jinshuju opensearch edit Qy7nR3 --header ./banner.png
|
|
318
368
|
jinshuju form image upload ./venue-map.png # answers with a url for an <img> in a form or field description
|
|
369
|
+
jinshuju sms signature create 小金培训 --license ./license.jpg --company-name 小金培训有限公司 --company-id 91110000MA00000000 \
|
|
370
|
+
--id-card-front ./front.jpg --id-card-back ./back.jpg --id-card-name 张三 --id-card-number 110101199001011234 --mobile 13800000000
|
|
371
|
+
jinshuju sms signature update 6512a1c2d3e4f5a6b7c8d9d3 --license ./license-clear.jpg
|
|
319
372
|
```
|
|
320
373
|
|
|
321
374
|
```bash
|
|
@@ -409,6 +462,58 @@ jinshuju field preview-convert --form Kp7mQ2 field_1 --to RadioButton
|
|
|
409
462
|
it takes that data along, so it is worth asking first. `preview-convert` reports
|
|
410
463
|
how much a type conversion would keep and how much it would clear.
|
|
411
464
|
|
|
465
|
+
## SMS signatures and templates
|
|
466
|
+
|
|
467
|
+
An SMS notification needs a signature and a template, and both wait on a
|
|
468
|
+
review, so submit them as early as you can. A template can go in while its
|
|
469
|
+
signature is still under review; `sms status` follows both, with the reason
|
|
470
|
+
when one is rejected.
|
|
471
|
+
|
|
472
|
+
`sms signature list` shows every signature of the account and `sms template list`
|
|
473
|
+
your templates with the ones the account shares; both carry the ids the updates
|
|
474
|
+
and deletes take. A rejected signature, and a template of yours that is not under
|
|
475
|
+
review, can be changed and sent back to review; only the flags given change. The
|
|
476
|
+
same ones can be deleted with `--yes`; deleting a signature takes its templates
|
|
477
|
+
with it.
|
|
478
|
+
|
|
479
|
+
```bash
|
|
480
|
+
jinshuju sms signature create 小金培训 --license ./license.jpg --company-name 小金培训有限公司 --company-id 91110000MA00000000 \
|
|
481
|
+
--id-card-front ./front.jpg --id-card-back ./back.jpg --id-card-name 张三 --id-card-number 110101199001011234 --mobile 13800000000
|
|
482
|
+
jinshuju sms template create --signature 小金培训 --content "你报名的课程明天上午 9 点开课,请准时参加。"
|
|
483
|
+
jinshuju sms status
|
|
484
|
+
jinshuju sms signature list --status FAIL
|
|
485
|
+
jinshuju sms template list --keyword 开课 --scope owned
|
|
486
|
+
jinshuju sms signature update 6512a1c2d3e4f5a6b7c8d9d3 --license ./license-clear.jpg
|
|
487
|
+
jinshuju sms template update 6512a1c2d3e4f5a6b7c8d9e0 --content "你报名的课程后天上午 9 点开课。"
|
|
488
|
+
jinshuju sms template delete 6512a1c2d3e4f5a6b7c8d9e0 --yes
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
## Sending SMS and email to entries
|
|
492
|
+
|
|
493
|
+
`sms send` and `email send` pick the entries of a form the way `entry count`
|
|
494
|
+
narrows them, by `--filter`, `--keyword` or `--view`, or the whole form with
|
|
495
|
+
`--select-all`, and send to the field `--field` names. Sending uses quota and
|
|
496
|
+
cannot be recalled, so each takes `--estimate` or `--yes`: `--estimate` answers
|
|
497
|
+
how many entries and recipients it reaches, how many are missing a number or an
|
|
498
|
+
address, what it bills and whether the quota covers it, and sends nothing;
|
|
499
|
+
`--yes` sends. The entries are picked again when it sends.
|
|
500
|
+
|
|
501
|
+
An SMS goes out from a template, by the id `sms template list` gives; variables
|
|
502
|
+
are filled from the fields `--placeholder` names, one per variable in order.
|
|
503
|
+
`--send-at` schedules it and `--manual` holds it for `sms task send`. A task whose
|
|
504
|
+
template failed review can be changed with `sms task change`, and a sent one
|
|
505
|
+
sent again with `sms task resend` to the entries that got a result.
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
jinshuju sms send --form Kp7mQ2 --field field_2 --template-id 6512a1c2d3e4f5a6b7c8d9e0 --filter 'field_5 eq 已报名' --estimate
|
|
509
|
+
jinshuju sms send --form Kp7mQ2 --field field_2 --template-id 6512a1c2d3e4f5a6b7c8d9e0 --filter 'field_5 eq 已报名' --yes
|
|
510
|
+
jinshuju sms task list --form Kp7mQ2
|
|
511
|
+
jinshuju sms task activities 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED
|
|
512
|
+
jinshuju sms task resend 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED --yes
|
|
513
|
+
jinshuju email smtp-account list
|
|
514
|
+
jinshuju email send --form Kp7mQ2 --field field_3 --select-all --subject 上课提醒 --content '<p>明天上午 9 点开课</p>' --yes
|
|
515
|
+
```
|
|
516
|
+
|
|
412
517
|
## Odds and ends
|
|
413
518
|
|
|
414
519
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -75,7 +75,11 @@ async function runRemote(command, words, flags, runtime, stdin) {
|
|
|
75
75
|
}
|
|
76
76
|
const rows = [];
|
|
77
77
|
await readAllPages(client, request, command.paginate, progress(), (page) => rows.push(...page));
|
|
78
|
-
|
|
78
|
+
const listing = { count: rows.length, data: rows };
|
|
79
|
+
// Every page read is still one listing, and reads the way a single page does.
|
|
80
|
+
if (output === 'text' && command.render)
|
|
81
|
+
return ok(format(command.render(listing), output, width, hints));
|
|
82
|
+
return ok(format(listing, output, width, hints));
|
|
79
83
|
}
|
|
80
84
|
const result = await client.request(request);
|
|
81
85
|
const selected = command.select ? command.select(result, input) : result;
|
package/dist/commands/account.js
CHANGED
|
@@ -18,6 +18,13 @@ export const ACCOUNT = [
|
|
|
18
18
|
options: [LIMIT_OPTION],
|
|
19
19
|
request: (input) => call('listBillingAccountUsers', { query: paging(input) })
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
path: ['account', 'paid-feature', 'list'],
|
|
23
|
+
summary: "List which paid features the account's plan includes",
|
|
24
|
+
description: 'Each paid feature, its name as the product shows it, and whether the plan includes it now. Quotas ' +
|
|
25
|
+
'left this month, and whether each add-on service can still be used, are in account get.',
|
|
26
|
+
request: () => call('listBillingAccountPaidFeatures')
|
|
27
|
+
},
|
|
21
28
|
{
|
|
22
29
|
path: ['account', 'invoice', 'list'],
|
|
23
30
|
summary: 'List e-invoices, and the amount not invoiced yet',
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { PAGINATION_OPTIONS } from '../options.js';
|
|
2
|
+
import { bodyChoices, call, choices } from '../spec.js';
|
|
3
|
+
import { ESTIMATE_OPTION, estimating, FORM_OPTION, given, LISTING, NARROWING_OPTIONS, narrowingBody, narrowingQuery, paging, requiredOption, SELECT_ALL_OPTION, selectAll, SEND_OPTION } from './shared.js';
|
|
4
|
+
const SMTP_ACCOUNT_OPTION = {
|
|
5
|
+
name: '--smtp-account-id',
|
|
6
|
+
type: 'string',
|
|
7
|
+
placeholder: '<id>',
|
|
8
|
+
description: "Send through this SMTP account of the account's, from `email smtp-account list`; uses no email quota"
|
|
9
|
+
};
|
|
10
|
+
const TASK_ARG = [{ name: 'id', required: true, description: 'Task id, from `email task list`' }];
|
|
11
|
+
export const EMAIL = [
|
|
12
|
+
{
|
|
13
|
+
path: ['email', 'send'],
|
|
14
|
+
summary: 'Send an email to the entries of a form',
|
|
15
|
+
description: 'Picks the entries the way `entry count` narrows them, or the whole form with --select-all, and sends to the ' +
|
|
16
|
+
'email field --field names. --estimate answers how many entries and addresses it reaches, how many are ' +
|
|
17
|
+
'missing an address and whether the quota covers them, and sends nothing; --yes sends, and wants --subject and ' +
|
|
18
|
+
'--content. The entries are picked again when it sends.',
|
|
19
|
+
options: [
|
|
20
|
+
FORM_OPTION,
|
|
21
|
+
{
|
|
22
|
+
name: '--field',
|
|
23
|
+
type: 'string',
|
|
24
|
+
placeholder: '<api_code>',
|
|
25
|
+
description: 'Email field to send to; a table column as <table api_code>.<column api_code>'
|
|
26
|
+
},
|
|
27
|
+
{ name: '--subject', type: 'string', placeholder: '<text>', description: 'Subject' },
|
|
28
|
+
{ name: '--content', type: 'string', placeholder: '<html>', description: 'Body, as HTML' },
|
|
29
|
+
SMTP_ACCOUNT_OPTION,
|
|
30
|
+
...NARROWING_OPTIONS,
|
|
31
|
+
SELECT_ALL_OPTION,
|
|
32
|
+
ESTIMATE_OPTION,
|
|
33
|
+
SEND_OPTION
|
|
34
|
+
],
|
|
35
|
+
request: (input) => {
|
|
36
|
+
const path = { form_token: requiredOption(input, 'form') };
|
|
37
|
+
const entry_field = requiredOption(input, 'field');
|
|
38
|
+
const smtp_account_id = input.options.smtp_account_id;
|
|
39
|
+
if (estimating(input, 'Sending email')) {
|
|
40
|
+
return call('estimateEmailTask', {
|
|
41
|
+
path,
|
|
42
|
+
query: { entry_field, ...narrowingQuery(input), select_all: selectAll(input), smtp_account_id }
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return call('createEmailTask', {
|
|
46
|
+
path,
|
|
47
|
+
body: given({
|
|
48
|
+
entry_field,
|
|
49
|
+
...narrowingBody(input),
|
|
50
|
+
select_all: selectAll(input),
|
|
51
|
+
smtp_account_id,
|
|
52
|
+
subject: requiredOption(input, 'subject'),
|
|
53
|
+
content: requiredOption(input, 'content')
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
examples: [
|
|
58
|
+
"jinshuju email send --form Kp7mQ2 --field field_3 --filter 'field_5 eq 已报名' --estimate",
|
|
59
|
+
"jinshuju email send --form Kp7mQ2 --field field_3 --filter 'field_5 eq 已报名' --subject 上课提醒 " +
|
|
60
|
+
"--content '<p>明天上午 9 点开课</p>' --yes"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
path: ['email', 'task', 'list'],
|
|
65
|
+
summary: "List a form's email tasks, newest first",
|
|
66
|
+
description: 'Without how many addresses succeeded or failed: `email task get` has those.',
|
|
67
|
+
options: [
|
|
68
|
+
FORM_OPTION,
|
|
69
|
+
{
|
|
70
|
+
name: '--status',
|
|
71
|
+
type: 'string',
|
|
72
|
+
choices: choices('listEmailTasks', 'status'),
|
|
73
|
+
placeholder: '<status>',
|
|
74
|
+
description: 'Only the tasks in this status'
|
|
75
|
+
},
|
|
76
|
+
...PAGINATION_OPTIONS
|
|
77
|
+
],
|
|
78
|
+
request: (input) => call('listEmailTasks', {
|
|
79
|
+
path: { form_token: requiredOption(input, 'form') },
|
|
80
|
+
query: { status: input.options.status, ...paging(input) }
|
|
81
|
+
}),
|
|
82
|
+
paginate: LISTING,
|
|
83
|
+
examples: ['jinshuju email task list --form Kp7mQ2']
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
path: ['email', 'task', 'get'],
|
|
87
|
+
summary: 'Show an email task and how many addresses succeeded or failed so far',
|
|
88
|
+
args: TASK_ARG,
|
|
89
|
+
options: [FORM_OPTION],
|
|
90
|
+
request: (input) => call('getEmailTask', { path: { form_token: requiredOption(input, 'form'), id: input.args.id } }),
|
|
91
|
+
examples: ['jinshuju email task get 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2']
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
path: ['email', 'task', 'activities'],
|
|
95
|
+
summary: 'List the sending result of each address an email task sent to',
|
|
96
|
+
args: TASK_ARG,
|
|
97
|
+
options: [
|
|
98
|
+
FORM_OPTION,
|
|
99
|
+
{
|
|
100
|
+
name: '--status',
|
|
101
|
+
type: 'string',
|
|
102
|
+
choices: choices('listEmailTaskActivities', 'status'),
|
|
103
|
+
placeholder: '<status>',
|
|
104
|
+
description: 'Only the addresses with this result; both when omitted'
|
|
105
|
+
},
|
|
106
|
+
{ name: '--email', type: 'string', placeholder: '<address>', description: 'Only this address' },
|
|
107
|
+
...PAGINATION_OPTIONS
|
|
108
|
+
],
|
|
109
|
+
request: (input) => call('listEmailTaskActivities', {
|
|
110
|
+
path: { form_token: requiredOption(input, 'form'), id: input.args.id },
|
|
111
|
+
query: {
|
|
112
|
+
status: input.options.status,
|
|
113
|
+
email: input.options.email,
|
|
114
|
+
...paging(input)
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
paginate: LISTING,
|
|
118
|
+
examples: ['jinshuju email task activities 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED']
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
path: ['email', 'task', 'resend'],
|
|
122
|
+
summary: 'Send an email task again to the entries that got a result',
|
|
123
|
+
description: 'A new task, with the same subject, content and SMTP account, to the entries of this one that got --status: ' +
|
|
124
|
+
'FAILED, SUCCESS or ALL. A filter, keyword or view narrows them further, and a serial_number none_in condition ' +
|
|
125
|
+
'leaves some out. It sends at once. --estimate answers what it would send and sends nothing; --yes sends.',
|
|
126
|
+
args: TASK_ARG,
|
|
127
|
+
options: [
|
|
128
|
+
FORM_OPTION,
|
|
129
|
+
{
|
|
130
|
+
name: '--status',
|
|
131
|
+
type: 'string',
|
|
132
|
+
choices: bodyChoices('resendEmailTask', 'status'),
|
|
133
|
+
placeholder: '<status>',
|
|
134
|
+
description: 'Send again to the entries with this result; ALL for every one the task sent to'
|
|
135
|
+
},
|
|
136
|
+
...NARROWING_OPTIONS,
|
|
137
|
+
ESTIMATE_OPTION,
|
|
138
|
+
SEND_OPTION
|
|
139
|
+
],
|
|
140
|
+
request: (input) => {
|
|
141
|
+
const path = { form_token: requiredOption(input, 'form'), id: input.args.id };
|
|
142
|
+
const status = requiredOption(input, 'status');
|
|
143
|
+
if (estimating(input, `Sending task ${input.args.id} again`)) {
|
|
144
|
+
return call('estimateEmailTaskResend', { path, query: { status, ...narrowingQuery(input) } });
|
|
145
|
+
}
|
|
146
|
+
return call('resendEmailTask', { path, body: given({ status, ...narrowingBody(input) }) });
|
|
147
|
+
},
|
|
148
|
+
examples: [
|
|
149
|
+
'jinshuju email task resend 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED --estimate',
|
|
150
|
+
'jinshuju email task resend 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED --yes'
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
path: ['email', 'smtp-account', 'list'],
|
|
155
|
+
summary: "List the SMTP accounts the account's email can be sent through",
|
|
156
|
+
description: 'Empty when the plan does not include custom SMTP. Every member gets the same list. The id goes to ' +
|
|
157
|
+
'`email send --smtp-account-id`.',
|
|
158
|
+
request: () => call('listSmtpAccounts'),
|
|
159
|
+
examples: ['jinshuju email smtp-account list']
|
|
160
|
+
}
|
|
161
|
+
];
|
package/dist/commands/folder.js
CHANGED
|
@@ -8,6 +8,14 @@ export const FOLDER = [
|
|
|
8
8
|
options: [LIMIT_OPTION],
|
|
9
9
|
request: (input) => call('listFolders', { query: paging(input) })
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
path: ['folder', 'get'],
|
|
13
|
+
summary: 'Show a folder: its name and kind',
|
|
14
|
+
description: 'Takes the folder_token a form or table answers with, to say which folder that is.',
|
|
15
|
+
args: [{ name: 'folder', required: true, description: 'Folder token, e.g. Fd2xK8' }],
|
|
16
|
+
request: (input) => call('getFolder', { path: { folder_token: input.args.folder } }),
|
|
17
|
+
examples: ['jinshuju folder get Fd2xK8']
|
|
18
|
+
},
|
|
11
19
|
{
|
|
12
20
|
path: ['folder', 'create'],
|
|
13
21
|
summary: 'Create a folder',
|
package/dist/commands/form.js
CHANGED
|
@@ -37,7 +37,9 @@ const FORM_PAYLOAD = [
|
|
|
37
37
|
'entries, and manually_close_rule {"closed": true} stops it now. The rules',
|
|
38
38
|
'coexist. show_form_before_open and show_close_count_down only hold with a',
|
|
39
39
|
'time-range or daily rule. The same keys go in a `form edit` payload, where',
|
|
40
|
-
'time_periods replaces the list and {"enabled": false} removes a
|
|
40
|
+
'time_periods replaces the list and {"enabled": false} or null removes a',
|
|
41
|
+
'time-range, daily or entries rule. {"closed": false} reopens the form, and',
|
|
42
|
+
'changing "closed" either way deletes the other three rules.',
|
|
41
43
|
'',
|
|
42
44
|
'Reading a form back does not give you something you can send again: a field',
|
|
43
45
|
'written as "TextField" reads as "single_line_text". `field types` lists the',
|
|
@@ -294,11 +296,20 @@ export const FORM = [
|
|
|
294
296
|
args: [{ name: 'form', required: true, description: 'Form token to copy' }],
|
|
295
297
|
options: [
|
|
296
298
|
{ name: '--name', type: 'string', placeholder: '<name>', description: 'Name for the copy' },
|
|
297
|
-
FOLDER_OPTION
|
|
299
|
+
FOLDER_OPTION,
|
|
300
|
+
{
|
|
301
|
+
name: '--with-notification-rules',
|
|
302
|
+
type: 'boolean',
|
|
303
|
+
description: 'Also copy the notification rules; needs manage permission on the form'
|
|
304
|
+
}
|
|
298
305
|
],
|
|
299
306
|
request: (input) => call('copyForm', {
|
|
300
307
|
path: { form_token: input.args.form },
|
|
301
|
-
body: given({
|
|
308
|
+
body: given({
|
|
309
|
+
name: input.options.name,
|
|
310
|
+
folder_token: input.options.folder,
|
|
311
|
+
with_notification_rules: input.options.with_notification_rules ? true : undefined
|
|
312
|
+
})
|
|
302
313
|
})
|
|
303
314
|
},
|
|
304
315
|
{
|
package/dist/commands/index.js
CHANGED
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
import { ACCOUNT } from './account.js';
|
|
11
11
|
import { CHECKIN } from './checkin.js';
|
|
12
12
|
import { COMMENT } from './comment.js';
|
|
13
|
+
import { EMAIL } from './email.js';
|
|
13
14
|
import { ENTRY } from './entry.js';
|
|
14
15
|
import { FIELD } from './field.js';
|
|
15
16
|
import { FILL } from './fill.js';
|
|
16
17
|
import { FOLDER } from './folder.js';
|
|
17
18
|
import { FORM } from './form.js';
|
|
18
19
|
import { LOCAL } from './local.js';
|
|
20
|
+
import { NOTIFICATION } from './notification.js';
|
|
19
21
|
import { OPENSEARCH } from './opensearch.js';
|
|
22
|
+
import { ROUTINE } from './routine.js';
|
|
20
23
|
import { SMS } from './sms.js';
|
|
21
24
|
import { TABLE } from './table.js';
|
|
22
25
|
import { TRADE } from './trade.js';
|
|
@@ -43,6 +46,21 @@ export const RESOURCES = [
|
|
|
43
46
|
{ name: 'entry', summary: 'Manage entries' },
|
|
44
47
|
{ name: 'comment', summary: 'Manage entry comments' },
|
|
45
48
|
{ name: 'opensearch', summary: 'Manage public queries' },
|
|
49
|
+
{
|
|
50
|
+
name: 'notification',
|
|
51
|
+
summary: 'Notification rules: SMS, email and WeChat to submitters, bots and webhooks to your team',
|
|
52
|
+
note: 'An SMS rule needs an approved template of your own, shared in the account or from the system (`sms status`). ' +
|
|
53
|
+
'A rule under review is saved but does not send; `notification get` says why a rule cannot send. ' +
|
|
54
|
+
'Only a manager of the form can create, edit or delete its rules. `notification edit --disable` turns a rule off for now.'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'routine',
|
|
58
|
+
summary: 'Manage routines (自动任务): Jiri at work on a schedule or when data changes',
|
|
59
|
+
note: 'Routines are your own: an account access token cannot manage them. An OAuth session needs the routines ' +
|
|
60
|
+
'scope, which `jinshuju auth login` asks for; a session from before this version needs a new login. ' +
|
|
61
|
+
'Letting a routine delete data (delete_authorized) is turned on on the 自动任务 page only; no flag or ' +
|
|
62
|
+
'payload here can set it.'
|
|
63
|
+
},
|
|
46
64
|
{
|
|
47
65
|
name: 'checkin',
|
|
48
66
|
summary: 'Check-in campaigns: registrants of a form check in on site',
|
|
@@ -68,7 +86,8 @@ export const RESOURCES = [
|
|
|
68
86
|
{ name: 'transaction', summary: 'Payment orders placed on payment forms' },
|
|
69
87
|
{ name: 'refund', summary: 'Refunds of payment orders' },
|
|
70
88
|
{ name: 'payout', summary: 'Payouts to the settlement account' },
|
|
71
|
-
{ name: 'sms', summary: 'SMS
|
|
89
|
+
{ name: 'sms', summary: 'Manage SMS signatures and templates, and send SMS to entries' },
|
|
90
|
+
{ name: 'email', summary: 'Send email to entries' },
|
|
72
91
|
{ name: 'config', summary: 'Manage CLI configuration' }
|
|
73
92
|
];
|
|
74
93
|
export const COMMANDS = [
|
|
@@ -82,10 +101,13 @@ export const COMMANDS = [
|
|
|
82
101
|
...ENTRY,
|
|
83
102
|
...COMMENT,
|
|
84
103
|
...OPENSEARCH,
|
|
104
|
+
...NOTIFICATION,
|
|
105
|
+
...ROUTINE,
|
|
85
106
|
...CHECKIN,
|
|
86
107
|
...FILL,
|
|
87
108
|
...TRADE,
|
|
88
|
-
...SMS
|
|
109
|
+
...SMS,
|
|
110
|
+
...EMAIL
|
|
89
111
|
];
|
|
90
112
|
/** The command whose path the words begin with, longest match first. */
|
|
91
113
|
export function findCommand(words, commands = COMMANDS) {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { JSON_OPTION, UsageError } from '../options.js';
|
|
2
|
+
import { bodyChoices, call } from '../spec.js';
|
|
3
|
+
import { YES_OPTION, confirmed, overriding, requiredOption } from './shared.js';
|
|
4
|
+
const RULE_ARG = { name: 'rule', required: true, description: 'Notification rule id' };
|
|
5
|
+
const FORM_OPTION = { name: '--form', type: 'string', placeholder: '<token>', description: 'Form token' };
|
|
6
|
+
/** What `notification create` and `notification edit` both take. */
|
|
7
|
+
const RULE_OPTIONS = [
|
|
8
|
+
{
|
|
9
|
+
name: '--trigger',
|
|
10
|
+
type: 'string',
|
|
11
|
+
choices: bodyChoices('createNotificationRule', 'trigger_scope'),
|
|
12
|
+
placeholder: '<scope>',
|
|
13
|
+
description: 'When it sends; matched_* need scope_conditions and schedule_time a schedule_time_rule, through --json'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: '--recipients',
|
|
17
|
+
type: 'list',
|
|
18
|
+
placeholder: '<mobile|email|api-code,...>',
|
|
19
|
+
description: 'SMS and EMAIL: mobiles or emails, or api_codes of the fields holding them'
|
|
20
|
+
},
|
|
21
|
+
{ name: '--sms-template', type: 'string', placeholder: '<id>', description: 'SMS template id (see `sms status`)' },
|
|
22
|
+
{
|
|
23
|
+
name: '--placeholders',
|
|
24
|
+
type: 'list',
|
|
25
|
+
placeholder: '<api-code,...>',
|
|
26
|
+
description: "SMS: the field filling each of the template's $(...) placeholders, in order"
|
|
27
|
+
},
|
|
28
|
+
{ name: '--subject', type: 'string', placeholder: '<text>', description: 'EMAIL and WEIXIN_ONETIME subject' },
|
|
29
|
+
{ name: '--content', type: 'string', placeholder: '<text>', description: 'Message; $(api_code) inserts a field' },
|
|
30
|
+
{
|
|
31
|
+
name: '--url',
|
|
32
|
+
type: 'string',
|
|
33
|
+
placeholder: '<url>',
|
|
34
|
+
description: 'WXWORK, DING_TALK and WEBHOOK: bot or webhook URL'
|
|
35
|
+
},
|
|
36
|
+
JSON_OPTION
|
|
37
|
+
];
|
|
38
|
+
function ruleBody(input) {
|
|
39
|
+
const rest = input.options.json ?? {};
|
|
40
|
+
return overriding(rest, {
|
|
41
|
+
trigger_scope: input.options.trigger,
|
|
42
|
+
recipients: input.options.recipients,
|
|
43
|
+
sms_template_id: input.options.sms_template,
|
|
44
|
+
placeholder_keys: input.options.placeholders,
|
|
45
|
+
subject: input.options.subject,
|
|
46
|
+
content: input.options.content,
|
|
47
|
+
url: input.options.url
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export const NOTIFICATION = [
|
|
51
|
+
{
|
|
52
|
+
path: ['notification', 'list'],
|
|
53
|
+
summary: "List a form's notification rules and whether each can send",
|
|
54
|
+
options: [FORM_OPTION],
|
|
55
|
+
request: (input) => call('listNotificationRules', { path: { form_token: requiredOption(input, 'form') } })
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
path: ['notification', 'get'],
|
|
59
|
+
summary: 'Show a notification rule, and why it cannot send if it cannot',
|
|
60
|
+
args: [RULE_ARG],
|
|
61
|
+
options: [FORM_OPTION],
|
|
62
|
+
request: (input) => call('getNotificationRule', { path: { form_token: requiredOption(input, 'form'), id: input.args.rule } })
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: ['notification', 'create'],
|
|
66
|
+
summary: 'Create a notification rule',
|
|
67
|
+
description: 'The rule is on once created and sends for the entries that match it from then on; --disable saves it off. ' +
|
|
68
|
+
'Each approach takes its own keys: SMS --recipients --sms-template --placeholders; ' +
|
|
69
|
+
'EMAIL --recipients --subject --content; WEIXIN_ONETIME --subject --content; ' +
|
|
70
|
+
'WXWORK and DING_TALK --url --content; WEBHOOK --url. ' +
|
|
71
|
+
'scope_conditions, schedule_time_rule, smtp_account_id, weixin_onetime_url and mentioned_mobile_list go through --json.',
|
|
72
|
+
options: [
|
|
73
|
+
FORM_OPTION,
|
|
74
|
+
{
|
|
75
|
+
name: '--approach',
|
|
76
|
+
type: 'string',
|
|
77
|
+
choices: bodyChoices('createNotificationRule', 'approach'),
|
|
78
|
+
placeholder: '<approach>',
|
|
79
|
+
description: 'How it is sent'
|
|
80
|
+
},
|
|
81
|
+
...RULE_OPTIONS,
|
|
82
|
+
{ name: '--disable', type: 'boolean', description: 'Save it turned off' }
|
|
83
|
+
],
|
|
84
|
+
request: (input) => call('createNotificationRule', {
|
|
85
|
+
path: { form_token: requiredOption(input, 'form') },
|
|
86
|
+
body: overriding(ruleBody(input), {
|
|
87
|
+
approach: requiredOption(input, 'approach'),
|
|
88
|
+
enabled: input.options.disable ? false : undefined
|
|
89
|
+
})
|
|
90
|
+
}),
|
|
91
|
+
examples: [
|
|
92
|
+
'jinshuju notification create --form Kp7mQ2 --approach SMS --recipients field_2 --sms-template 6650a1 --placeholders field_1',
|
|
93
|
+
'jinshuju notification create --form Kp7mQ2 --approach SMS --recipients field_2 --sms-template 6650a1 --placeholders field_1 ' +
|
|
94
|
+
'--trigger schedule_time --json \'{"schedule_time_rule":{"date_key":"field_5","date_offset_action":"before",' +
|
|
95
|
+
'"date_offset_number":1,"date_offset_unit":"day","hour":9,"minute":0}}\''
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
path: ['notification', 'edit'],
|
|
100
|
+
summary: 'Edit a notification rule, or turn it off and on',
|
|
101
|
+
description: 'Only what is named changes. The approach cannot be changed; create another rule instead.',
|
|
102
|
+
args: [RULE_ARG],
|
|
103
|
+
options: [
|
|
104
|
+
FORM_OPTION,
|
|
105
|
+
...RULE_OPTIONS,
|
|
106
|
+
{ name: '--enable', type: 'boolean', description: 'Turn the rule on' },
|
|
107
|
+
{ name: '--disable', type: 'boolean', description: 'Turn the rule off' }
|
|
108
|
+
],
|
|
109
|
+
request: (input) => {
|
|
110
|
+
if (input.options.enable && input.options.disable) {
|
|
111
|
+
throw new UsageError('--enable and --disable are opposites, pass one');
|
|
112
|
+
}
|
|
113
|
+
return call('updateNotificationRule', {
|
|
114
|
+
path: { form_token: requiredOption(input, 'form'), id: input.args.rule },
|
|
115
|
+
body: overriding(ruleBody(input), {
|
|
116
|
+
enabled: input.options.enable ? true : input.options.disable ? false : undefined
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
examples: ['jinshuju notification edit 6650b2 --form Kp7mQ2 --disable']
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
path: ['notification', 'delete'],
|
|
124
|
+
summary: 'Delete a notification rule',
|
|
125
|
+
description: 'What it has scheduled but not sent yet is cancelled. To stop it for now, use `notification edit --disable`.',
|
|
126
|
+
args: [RULE_ARG],
|
|
127
|
+
options: [FORM_OPTION, YES_OPTION],
|
|
128
|
+
request: (input) => {
|
|
129
|
+
confirmed(input, `Deleting notification rule ${input.args.rule}`);
|
|
130
|
+
return call('deleteNotificationRule', {
|
|
131
|
+
path: { form_token: requiredOption(input, 'form'), id: input.args.rule }
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Command } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `weekly 1,5 09:00` into the schedule object the API reads, so one command
|
|
4
|
+
* can create any of the six. Only the words are checked: whether 8 is a
|
|
5
|
+
* weekday or the time has passed is the server's to say, in the page's words.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseSchedule(input: string): Record<string, unknown>;
|
|
8
|
+
/** `form:Kp7mQ2` into `{ kind, token }`. The kinds are the server's to check. */
|
|
9
|
+
export declare function parseObject(input: string): {
|
|
10
|
+
kind: string;
|
|
11
|
+
token: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const ROUTINE: readonly Command[];
|