@jinshuju/cli 0.15.0 → 0.17.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
@@ -223,6 +223,7 @@ issues exactly one request, and payload keys are field `api_code`s.
223
223
  jinshuju folder create Ledgers --kind table # folders are form or table; a table cannot go in a form folder
224
224
  jinshuju form edit Kp7mQ2 --json '{"name":"2026 signups"}'
225
225
  jinshuju form copy Kp7mQ2 --name Copy
226
+ jinshuju form copy Kp7mQ2 --name 第二期 --with-notification-rules
226
227
  jinshuju form move Kp7mQ2 --folder Fd2xK8 # without --folder, moves it out of its folder
227
228
  jinshuju form theme set Kp7mQ2 --primary-color "#1F6FEB"
228
229
  jinshuju table create --json @table.json --folder Nf7mDC
@@ -253,6 +254,9 @@ jinshuju comment create --form Kp7mQ2 --entry 12 "Contacted, awaiting reply"
253
254
  jinshuju opensearch edit Qy7nR3 --disable
254
255
  jinshuju checkin create --form Kp7mQ2 # needs the check-in plugin enabled for the account
255
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
259
+ jinshuju notification log 6650b2 --form Kp7mQ2 --from 2026-10-01 # what the rule sent: how many succeeded, failed, and why
256
260
  ```
257
261
 
258
262
  Deletion always requires `--yes`. This CLI is non-interactive — stdin belongs to
@@ -309,6 +313,47 @@ person at it can do — a captcha, an SMS code, WeChat, a payment — lists it u
309
313
  `blockers`, and is refused until it is filled in a browser. An OAuth session
310
314
  needs the `submit_entries` scope for these.
311
315
 
316
+ ## Routines (自动任务)
317
+
318
+ A routine is an instruction Jiri carries out on a schedule, or when the data of
319
+ a form or table changes. One created here is active at once, the same as one
320
+ created on the 自动任务 page, and is held to that page's rules and words.
321
+
322
+ ```bash
323
+ jinshuju routine create --name 每周报名汇总 --description 每周一汇总上周报名,按渠道统计 \
324
+ --instruction '汇总上周报名表新增的数据' --object form:Kp7mQ2 --schedule 'weekly 1 09:00'
325
+ jinshuju routine create --json @routine.json # an event trigger and its conditions
326
+ jinshuju routine list --state active
327
+ jinshuju routine get 6ac5f0e2b1d4c3a2f1e0d9c8 # trigger_text, next_runs, objects, url
328
+ jinshuju routine update 6ac5f0e2b1d4c3a2f1e0d9c8 --schedule 'workdays 08:30'
329
+ jinshuju routine pause 6ac5f0e2b1d4c3a2f1e0d9c8
330
+ jinshuju routine resume 6ac5f0e2b1d4c3a2f1e0d9c8
331
+ jinshuju routine run 6ac5f0e2b1d4c3a2f1e0d9c8 # once, now
332
+ jinshuju routine runs 6ac5f0e2b1d4c3a2f1e0d9c8
333
+ jinshuju routine delete 6ac5f0e2b1d4c3a2f1e0d9c8 --yes
334
+ ```
335
+
336
+ `--schedule` is Beijing time and covers the six frequencies: `once 2026-10-12
337
+ 09:00`, `hourly 30`, `daily 09:00`, `workdays 09:00`, `weekly 1,5 09:00` (1 is
338
+ Monday) and `monthly 1,-1 09:00` (-1 is the last day). `--object kind:token`
339
+ names a form, table, view or public query, and given, it is the whole list.
340
+ `--description` is the one sentence the routines list shows people, up to 100
341
+ characters; the instruction is written for Jiri.
342
+ Flags lay over `--json`; `routine create --help` shows the full payload, events
343
+ and conditions included. A routine against the page's rules exits 5 with every
344
+ reason the page gives.
345
+
346
+ Letting a routine delete data (`delete_authorized`) is turned on on the
347
+ 自动任务 page only. There is no flag for it, and a payload naming it, true or
348
+ false, is refused before anything is sent — `routine get` answers with it, so
349
+ take it out before sending a routine read back. A routine's own run cannot
350
+ create or change routines; it may read them.
351
+
352
+ Routines belong to a person, so an account access token cannot manage them. A
353
+ browser login asks for the `routines` OAuth scope; a login made with an older
354
+ version has no such scope, and the routine commands answer it with 403 (exit
355
+ 3). Run `jinshuju auth login` again to get a token that has it.
356
+
312
357
  ## Working with files
313
358
 
314
359
  Seven commands take a file. The CLI uploads with its own credential; there is no
@@ -444,6 +489,32 @@ jinshuju sms template update 6512a1c2d3e4f5a6b7c8d9e0 --content "你报名的课
444
489
  jinshuju sms template delete 6512a1c2d3e4f5a6b7c8d9e0 --yes
445
490
  ```
446
491
 
492
+ ## Sending SMS and email to entries
493
+
494
+ `sms send` and `email send` pick the entries of a form the way `entry count`
495
+ narrows them, by `--filter`, `--keyword` or `--view`, or the whole form with
496
+ `--select-all`, and send to the field `--field` names. Sending uses quota and
497
+ cannot be recalled, so each takes `--estimate` or `--yes`: `--estimate` answers
498
+ how many entries and recipients it reaches, how many are missing a number or an
499
+ address, what it bills and whether the quota covers it, and sends nothing;
500
+ `--yes` sends. The entries are picked again when it sends.
501
+
502
+ An SMS goes out from a template, by the id `sms template list` gives; variables
503
+ are filled from the fields `--placeholder` names, one per variable in order.
504
+ `--send-at` schedules it and `--manual` holds it for `sms task send`. A task whose
505
+ template failed review can be changed with `sms task change`, and a sent one
506
+ sent again with `sms task resend` to the entries that got a result.
507
+
508
+ ```bash
509
+ jinshuju sms send --form Kp7mQ2 --field field_2 --template-id 6512a1c2d3e4f5a6b7c8d9e0 --filter 'field_5 eq 已报名' --estimate
510
+ jinshuju sms send --form Kp7mQ2 --field field_2 --template-id 6512a1c2d3e4f5a6b7c8d9e0 --filter 'field_5 eq 已报名' --yes
511
+ jinshuju sms task list --form Kp7mQ2 --from 2026-10-01 # each task with how many numbers succeeded or failed
512
+ jinshuju sms task activities 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED
513
+ jinshuju sms task resend 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED --yes
514
+ jinshuju email smtp-account list
515
+ jinshuju email send --form Kp7mQ2 --field field_3 --select-all --subject 上课提醒 --content '<p>明天上午 9 点开课</p>' --yes
516
+ ```
517
+
447
518
  ## Odds and ends
448
519
 
449
520
  ```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
- return ok(format({ count: rows.length, data: rows }, output, width, hints));
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;
@@ -0,0 +1,2 @@
1
+ import type { Command } from './types.js';
2
+ export declare const EMAIL: readonly Command[];
@@ -0,0 +1,162 @@
1
+ import { PAGINATION_OPTIONS } from '../options.js';
2
+ import { bodyChoices, call, choices } from '../spec.js';
3
+ import { DAY_RANGE_OPTIONS, dayRange, 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, with how many addresses succeeded or failed so far",
66
+ description: '--from and --to pick the tasks by the day they were created. A page holds at most 100 tasks.',
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
+ ...DAY_RANGE_OPTIONS,
77
+ ...PAGINATION_OPTIONS
78
+ ],
79
+ request: (input) => call('listEmailTasks', {
80
+ path: { form_token: requiredOption(input, 'form') },
81
+ query: { status: input.options.status, ...dayRange(input), ...paging(input) }
82
+ }),
83
+ paginate: LISTING,
84
+ examples: ['jinshuju email task list --form Kp7mQ2', 'jinshuju email task list --form Kp7mQ2 --from 2026-10-01']
85
+ },
86
+ {
87
+ path: ['email', 'task', 'get'],
88
+ summary: 'Show an email task and how many addresses succeeded or failed so far',
89
+ args: TASK_ARG,
90
+ options: [FORM_OPTION],
91
+ request: (input) => call('getEmailTask', { path: { form_token: requiredOption(input, 'form'), id: input.args.id } }),
92
+ examples: ['jinshuju email task get 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2']
93
+ },
94
+ {
95
+ path: ['email', 'task', 'activities'],
96
+ summary: 'List the sending result of each address an email task sent to',
97
+ args: TASK_ARG,
98
+ options: [
99
+ FORM_OPTION,
100
+ {
101
+ name: '--status',
102
+ type: 'string',
103
+ choices: choices('listEmailTaskActivities', 'status'),
104
+ placeholder: '<status>',
105
+ description: 'Only the addresses with this result; both when omitted'
106
+ },
107
+ { name: '--email', type: 'string', placeholder: '<address>', description: 'Only this address' },
108
+ ...PAGINATION_OPTIONS
109
+ ],
110
+ request: (input) => call('listEmailTaskActivities', {
111
+ path: { form_token: requiredOption(input, 'form'), id: input.args.id },
112
+ query: {
113
+ status: input.options.status,
114
+ email: input.options.email,
115
+ ...paging(input)
116
+ }
117
+ }),
118
+ paginate: LISTING,
119
+ examples: ['jinshuju email task activities 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED']
120
+ },
121
+ {
122
+ path: ['email', 'task', 'resend'],
123
+ summary: 'Send an email task again to the entries that got a result',
124
+ description: 'A new task, with the same subject, content and SMTP account, to the entries of this one that got --status: ' +
125
+ 'FAILED, SUCCESS or ALL. A filter, keyword or view narrows them further, and a serial_number none_in condition ' +
126
+ 'leaves some out. It sends at once. --estimate answers what it would send and sends nothing; --yes sends.',
127
+ args: TASK_ARG,
128
+ options: [
129
+ FORM_OPTION,
130
+ {
131
+ name: '--status',
132
+ type: 'string',
133
+ choices: bodyChoices('resendEmailTask', 'status'),
134
+ placeholder: '<status>',
135
+ description: 'Send again to the entries with this result; ALL for every one the task sent to'
136
+ },
137
+ ...NARROWING_OPTIONS,
138
+ ESTIMATE_OPTION,
139
+ SEND_OPTION
140
+ ],
141
+ request: (input) => {
142
+ const path = { form_token: requiredOption(input, 'form'), id: input.args.id };
143
+ const status = requiredOption(input, 'status');
144
+ if (estimating(input, `Sending task ${input.args.id} again`)) {
145
+ return call('estimateEmailTaskResend', { path, query: { status, ...narrowingQuery(input) } });
146
+ }
147
+ return call('resendEmailTask', { path, body: given({ status, ...narrowingBody(input) }) });
148
+ },
149
+ examples: [
150
+ 'jinshuju email task resend 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED --estimate',
151
+ 'jinshuju email task resend 6716f2a8c1d2e3f4a5b6c7d9 --form Kp7mQ2 --status FAILED --yes'
152
+ ]
153
+ },
154
+ {
155
+ path: ['email', 'smtp-account', 'list'],
156
+ summary: "List the SMTP accounts the account's email can be sent through",
157
+ description: 'Empty when the plan does not include custom SMTP. Every member gets the same list. The id goes to ' +
158
+ '`email send --smtp-account-id`.',
159
+ request: () => call('listSmtpAccounts'),
160
+ examples: ['jinshuju email smtp-account list']
161
+ }
162
+ ];
@@ -296,11 +296,20 @@ export const FORM = [
296
296
  args: [{ name: 'form', required: true, description: 'Form token to copy' }],
297
297
  options: [
298
298
  { name: '--name', type: 'string', placeholder: '<name>', description: 'Name for the copy' },
299
- 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
+ }
300
305
  ],
301
306
  request: (input) => call('copyForm', {
302
307
  path: { form_token: input.args.form },
303
- body: given({ name: input.options.name, folder_token: input.options.folder })
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
+ })
304
313
  })
305
314
  },
306
315
  {
@@ -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: 'Manage SMS signatures and templates' },
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,2 @@
1
+ import type { Command } from './types.js';
2
+ export declare const NOTIFICATION: readonly Command[];
@@ -0,0 +1,163 @@
1
+ import { JSON_OPTION, PAGINATION_OPTIONS, UsageError } from '../options.js';
2
+ import { bodyChoices, call, choices } from '../spec.js';
3
+ import { DAY_RANGE_OPTIONS, LISTING, YES_OPTION, confirmed, dayRange, overriding, paging, 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
+ {
136
+ path: ['notification', 'log'],
137
+ summary: 'List what a notification rule sent, with how many succeeded or failed and why',
138
+ description: 'Covers the last 180 days, as the notification log page does; notifications scheduled for later are not listed. ' +
139
+ '--from and --to pick them by the day they were sent. The summary counts every match, not just the page.',
140
+ args: [RULE_ARG],
141
+ options: [
142
+ FORM_OPTION,
143
+ {
144
+ name: '--status',
145
+ type: 'string',
146
+ choices: choices('listNotificationRuleNotifications', 'status'),
147
+ placeholder: '<status>',
148
+ description: 'Only the notifications in this status, e.g. FAILED'
149
+ },
150
+ ...DAY_RANGE_OPTIONS,
151
+ ...PAGINATION_OPTIONS
152
+ ],
153
+ request: (input) => call('listNotificationRuleNotifications', {
154
+ path: { form_token: requiredOption(input, 'form'), id: input.args.rule },
155
+ query: { status: input.options.status, ...dayRange(input), ...paging(input) }
156
+ }),
157
+ paginate: LISTING,
158
+ examples: [
159
+ 'jinshuju notification log 6650b2 --form Kp7mQ2',
160
+ 'jinshuju notification log 6650b2 --form Kp7mQ2 --status FAILED --from 2026-10-01 --to 2026-10-31'
161
+ ]
162
+ }
163
+ ];
@@ -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[];