@jinshuju/cli 0.19.0 → 0.21.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 +38 -3
- package/dist/cli.js +5 -2
- package/dist/commands/field.js +90 -3
- package/dist/commands/form.js +21 -4
- package/dist/commands/notification.js +3 -1
- package/dist/commands/routine.js +20 -15
- package/dist/errors.d.ts +17 -0
- package/dist/errors.js +17 -0
- package/dist/generated/operations.d.ts +3 -1
- package/dist/generated/operations.js +918 -188
- package/dist/http.d.ts +6 -0
- package/dist/http.js +58 -11
- package/dist/options.js +116 -4
- package/dist/preflight.d.ts +32 -0
- package/dist/preflight.js +156 -0
- package/dist/schema.d.ts +39 -0
- package/dist/schema.js +239 -0
- package/dist/spec.d.ts +19 -0
- package/dist/spec.js +23 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -85,6 +85,7 @@ field — the server assigns it.
|
|
|
85
85
|
jinshuju form create --json @form.json --scene registry --layout card --folder Fd2xK8
|
|
86
86
|
jinshuju form create --json @exam.json --type exam # the payload may carry exam_setting
|
|
87
87
|
jinshuju form edit Kp7mQ2 --json '{"exam_setting":{"limited_time":45}}'
|
|
88
|
+
jinshuju form get Kp7mQ2 --include exam_setting # reads it back with the form
|
|
88
89
|
|
|
89
90
|
jinshuju form create --json '{
|
|
90
91
|
"name": "Event signup",
|
|
@@ -163,9 +164,13 @@ maximum (50 in most cases), and anything larger is capped.
|
|
|
163
164
|
`--all` reads at most 200 pages. Past that it stops with an error naming the
|
|
164
165
|
cursor; pass it to `--next` (with `--all` again) to read on.
|
|
165
166
|
|
|
166
|
-
`--filter` is repeatable
|
|
167
|
-
|
|
168
|
-
the
|
|
167
|
+
`--filter` is repeatable, one condition per flag, and the conditions are
|
|
168
|
+
AND-combined. An operator written otherwise (`=`, `in`, `not_empty`) is refused
|
|
169
|
+
with the one meant, one the CLI's copy of the spec does not list goes through
|
|
170
|
+
for the API to judge, two conditions in one flag are refused with the way to
|
|
171
|
+
write them, and a value in quotes is taken whole, without them. For conditions
|
|
172
|
+
it cannot express, use `--filters <json|@file>`. Cursors are opaque strings —
|
|
173
|
+
pass the `next` value from the previous response back verbatim.
|
|
169
174
|
|
|
170
175
|
## Analysis
|
|
171
176
|
|
|
@@ -240,6 +245,14 @@ jinshuju field update-choices --form Kp7mQ2 field_7 --json '{"add":[{"label":"Th
|
|
|
240
245
|
jinshuju field remove --form Kp7mQ2 field_9 --yes
|
|
241
246
|
```
|
|
242
247
|
|
|
248
|
+
A payload is looked at once before it is sent, against the openapi.yaml the
|
|
249
|
+
CLI shipped with, and refused only for what a newer API could not have made
|
|
250
|
+
right: a required key missing, a value of the wrong type, `null` for a key
|
|
251
|
+
that cannot be null, a field's `validation` written back as `form get` returned
|
|
252
|
+
it. A key or a value that copy does not list is sent for the API to judge, since
|
|
253
|
+
the API may have learned it since. A refusal names the day the copy was
|
|
254
|
+
fetched, and `--as-is` sends the payload anyway.
|
|
255
|
+
|
|
243
256
|
Data and views:
|
|
244
257
|
|
|
245
258
|
```bash
|
|
@@ -430,6 +443,11 @@ parsing anything:
|
|
|
430
443
|
| 7 | transport: the connection failed or timed out |
|
|
431
444
|
| 8 | rate limited: wait and retry; the message and `retry_after` say how long |
|
|
432
445
|
|
|
446
|
+
A refusal with several reasons lists every one of them, one line each, even
|
|
447
|
+
when the server's own description repeats only the first three: a request body
|
|
448
|
+
that is wrong in five places is corrected in one go rather than in five. A list
|
|
449
|
+
longer than twenty is cut, and says how many it kept back.
|
|
450
|
+
|
|
433
451
|
With `--output json`, stderr carries the same as JSON, plus the status and body
|
|
434
452
|
the server answered with:
|
|
435
453
|
|
|
@@ -463,6 +481,23 @@ jinshuju field preview-convert --form Kp7mQ2 field_1 --to RadioButton
|
|
|
463
481
|
it takes that data along, so it is worth asking first. `preview-convert` reports
|
|
464
482
|
how much a type conversion would keep and how much it would clear.
|
|
465
483
|
|
|
484
|
+
## Writing a condition
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
jinshuju field filterable --form Kp7mQ2
|
|
488
|
+
jinshuju field filterable --form Kp7mQ2 --for routine field_5 --output json
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
A routine's or a notification rule's `scope_conditions` test fields, and a
|
|
492
|
+
condition's value is not the value the field takes in an entry: a goods field
|
|
493
|
+
is tested with `[{"api_code": …}]`, a choice by its code. `field filterable`
|
|
494
|
+
lists the fields a condition can test, the operators each takes, and for each
|
|
495
|
+
operator the value it takes, with examples written in the field's own codes;
|
|
496
|
+
`--for routine` narrows it to the fields a routine's data trigger can test.
|
|
497
|
+
Copy an example's shape. Creating or updating a routine with conditions
|
|
498
|
+
answers with `preview_condition_matches`: which of the latest entries meet each
|
|
499
|
+
group, the quickest way to see that a condition means what it was meant to.
|
|
500
|
+
|
|
466
501
|
## SMS signatures and templates
|
|
467
502
|
|
|
468
503
|
An SMS notification needs a signature and a template, and both wait on a
|
package/dist/cli.js
CHANGED
|
@@ -5,6 +5,7 @@ import { helpFor, rootHelp } from './help.js';
|
|
|
5
5
|
import { HttpError, JinshujuHttpClient } from './http.js';
|
|
6
6
|
import { runLocal } from './local.js';
|
|
7
7
|
import { GLOBAL_OPTIONS, LOCAL_OPTIONS, UsageError } from './options.js';
|
|
8
|
+
import { checked } from './preflight.js';
|
|
8
9
|
import { progress } from './progress.js';
|
|
9
10
|
import { format, terminalWidth } from './render.js';
|
|
10
11
|
import { fail, ok, outputOf, unknown } from './result.js';
|
|
@@ -43,12 +44,14 @@ async function runRemote(command, words, flags, runtime, stdin) {
|
|
|
43
44
|
const input = { ...bindArgs(command, words), options };
|
|
44
45
|
const output = options.output ?? 'text';
|
|
45
46
|
const width = runtime.width ?? terminalWidth();
|
|
46
|
-
|
|
47
|
+
// Every request leaves through the preflight, a test's mock client's too:
|
|
48
|
+
// a body is looked at once, on its way to the wire, whichever command built it.
|
|
49
|
+
const client = checked(runtime.client ??
|
|
47
50
|
new JinshujuHttpClient(loadConfig({
|
|
48
51
|
configPath: options.config ?? defaultConfigPath,
|
|
49
52
|
env: runtime.env,
|
|
50
53
|
cli: { host: options.host }
|
|
51
|
-
}));
|
|
54
|
+
})), options.as_is === true);
|
|
52
55
|
// A command that needs more than one round trip, or has to decide how many,
|
|
53
56
|
// runs itself and answers with what should be printed.
|
|
54
57
|
const hints = { list: command.text?.list ?? command.paginate?.items, essentialLists: command.text?.essentialLists };
|
package/dist/commands/field.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { CONTAINER_OPTIONS, JSON_OPTION, UsageError } from '../options.js';
|
|
2
|
-
import { call } from '../spec.js';
|
|
2
|
+
import { call, choices } from '../spec.js';
|
|
3
3
|
import { YES_OPTION, confirmed, onContainer, one, payload, requiredOption } from './shared.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* One field, or a list of them — the same objects `fields` holds above. And
|
|
6
|
+
* what a field read back is not: what the CLI's callers were most often
|
|
7
|
+
* refused for was a field written back as `form get` returned it.
|
|
8
|
+
*/
|
|
5
9
|
const FIELD_PAYLOAD = [
|
|
6
10
|
'{ "type": "TextField", "label": "Notes", "required": false }',
|
|
7
11
|
'',
|
|
12
|
+
'A field as `form get` or `field list` returns it is not a field to write back:',
|
|
13
|
+
' validation: {required, unique, minimum_length, …} is written flat on the field',
|
|
14
|
+
' choices are changed with `field update-choices`; `field update` takes them only on a',
|
|
15
|
+
' CascadeDropDown, or with a `type` that turns a text field into a choice field',
|
|
16
|
+
' a key read as null is left out, not written as null',
|
|
17
|
+
'',
|
|
8
18
|
'Field types: jinshuju field types'
|
|
9
19
|
];
|
|
10
20
|
/**
|
|
@@ -77,6 +87,38 @@ function labelsOf(payload) {
|
|
|
77
87
|
return typeof label === 'string' ? [label] : [];
|
|
78
88
|
}));
|
|
79
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A listing is for finding the field, so each row names its operators and no
|
|
92
|
+
* more. One field is for writing its condition, and a table of formats loses
|
|
93
|
+
* whatever a narrow terminal has no room for, so each operator becomes its own
|
|
94
|
+
* block: the format, its description, and every example as the JSON to send.
|
|
95
|
+
* A reservation field is listed once for its items and once for its date, so
|
|
96
|
+
* one field may be two rows, told apart by scope_attr (none, and date_time).
|
|
97
|
+
*/
|
|
98
|
+
function conditionFieldsForReading(body) {
|
|
99
|
+
const rows = body.data ?? [];
|
|
100
|
+
const operatorsOf = (row) => Array.isArray(row.operators) ? row.operators : [];
|
|
101
|
+
const oneField = rows.length > 0 && rows.every((row) => row.trigger === rows[0].trigger);
|
|
102
|
+
if (!oneField) {
|
|
103
|
+
return {
|
|
104
|
+
data: rows.map((row) => ({
|
|
105
|
+
...row,
|
|
106
|
+
operators: operatorsOf(row)
|
|
107
|
+
.map((operator) => operator.operator)
|
|
108
|
+
.join(' ')
|
|
109
|
+
}))
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return Object.fromEntries(rows.map((row) => {
|
|
113
|
+
const { operators: _operators, ...rest } = row;
|
|
114
|
+
const heading = row.scope_attr ? `${row.trigger} scope_attr=${row.scope_attr}` : String(row.trigger);
|
|
115
|
+
const operators = Object.fromEntries(operatorsOf(row).map(({ operator, examples, ...format }) => [
|
|
116
|
+
operator,
|
|
117
|
+
{ ...format, examples: Array.isArray(examples) ? examples.map((example) => JSON.stringify(example)) : [] }
|
|
118
|
+
]));
|
|
119
|
+
return [heading, { ...rest, operators }];
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
80
122
|
const KIND_OPTION = {
|
|
81
123
|
name: '--kind',
|
|
82
124
|
type: 'string',
|
|
@@ -136,6 +178,49 @@ export const FIELD = [
|
|
|
136
178
|
request: (input) => onContainer(input, 'getForm', 'getTable'),
|
|
137
179
|
select: (body) => ({ data: selectFields(body) })
|
|
138
180
|
},
|
|
181
|
+
{
|
|
182
|
+
path: ['field', 'filterable'],
|
|
183
|
+
summary: 'List the fields a condition can test, with the operators and values each takes',
|
|
184
|
+
description: 'The fields the scope_conditions of a routine or a notification rule can name, and for each the ' +
|
|
185
|
+
'operators it takes and the value each operator takes: value_format names the shape, ' +
|
|
186
|
+
"value_description says it, and examples are values written with the field's own codes. " +
|
|
187
|
+
'Write a condition {trigger, operator, value} as an example shows; an operator or a field not ' +
|
|
188
|
+
'listed is not one a condition can use. A row with a scope_attr needs it in the condition too: a ' +
|
|
189
|
+
'reservation field is listed once for its items, without one, and once for its date, with date_time. ' +
|
|
190
|
+
"A routine's data trigger tests fewer fields than a notification rule: ask with --for routine. " +
|
|
191
|
+
'Name a trigger to read one field in full; text clips long descriptions, --output json keeps them whole.',
|
|
192
|
+
args: [{ name: 'trigger', required: false, description: 'One field, as a condition names it, e.g. field_3' }],
|
|
193
|
+
options: [
|
|
194
|
+
...CONTAINER_OPTIONS,
|
|
195
|
+
{
|
|
196
|
+
name: '--for',
|
|
197
|
+
type: 'string',
|
|
198
|
+
choices: choices('listFormConditionTriggerableFields', 'fields_context'),
|
|
199
|
+
placeholder: '<context>',
|
|
200
|
+
description: "Only the fields a condition there can test; routine is a routine's data trigger"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
request: (input) => onContainer(input, 'listFormConditionTriggerableFields', 'listTableConditionTriggerableFields', {
|
|
204
|
+
query: { fields_context: input.options.for }
|
|
205
|
+
}),
|
|
206
|
+
select: (body, input) => {
|
|
207
|
+
const rows = body.condition_triggerable_fields ?? [];
|
|
208
|
+
const trigger = input.args.trigger;
|
|
209
|
+
if (trigger === undefined)
|
|
210
|
+
return { data: rows };
|
|
211
|
+
const picked = rows.filter((row) => row.trigger === trigger);
|
|
212
|
+
if (picked.length === 0) {
|
|
213
|
+
throw new UsageError(`${trigger} is not a field a condition can test here; run without it to list them`);
|
|
214
|
+
}
|
|
215
|
+
return { data: picked };
|
|
216
|
+
},
|
|
217
|
+
render: conditionFieldsForReading,
|
|
218
|
+
examples: [
|
|
219
|
+
'jinshuju field filterable --form Kp7mQ2',
|
|
220
|
+
'jinshuju field filterable --form Kp7mQ2 --for routine',
|
|
221
|
+
'jinshuju field filterable --table Vn4xR8'
|
|
222
|
+
]
|
|
223
|
+
},
|
|
139
224
|
{
|
|
140
225
|
path: ['field', 'add'],
|
|
141
226
|
summary: 'Add fields to a form or table',
|
|
@@ -152,9 +237,11 @@ export const FIELD = [
|
|
|
152
237
|
{
|
|
153
238
|
path: ['field', 'update'],
|
|
154
239
|
summary: 'Update one field',
|
|
155
|
-
description: 'The patch is merged onto the field; the api_code comes from the argument, not the payload.'
|
|
240
|
+
description: 'The patch is merged onto the field; the api_code comes from the argument, not the payload. ' +
|
|
241
|
+
'Write only the keys to change, flat on the field, as the payload below says.',
|
|
156
242
|
args: [{ name: 'api-code', required: true, description: 'Field api_code, e.g. field_3' }],
|
|
157
243
|
options: [...CONTAINER_OPTIONS, JSON_OPTION],
|
|
244
|
+
payload: FIELD_PAYLOAD,
|
|
158
245
|
request: (input) => onContainer(input, 'updateForm', 'updateTable', {
|
|
159
246
|
body: {
|
|
160
247
|
fields: { update: [{ ...payload(input), api_code: input.args['api-code'] }] }
|
package/dist/commands/form.js
CHANGED
|
@@ -61,7 +61,13 @@ const FORM_INCLUDES = {
|
|
|
61
61
|
rules: 'include_field_rules',
|
|
62
62
|
extended: 'include_extended_attributes',
|
|
63
63
|
transactions: 'include_transactions',
|
|
64
|
-
analytics: 'include_analytics'
|
|
64
|
+
analytics: 'include_analytics',
|
|
65
|
+
// An exam form's exam settings, under the key `form edit` writes them by;
|
|
66
|
+
// any other form carries nothing for it. The one name here that is the key
|
|
67
|
+
// itself: `exam` alone reads as the scene, and this list already has
|
|
68
|
+
// `setting`, which it sits beside. An OAuth token needs the form_setting
|
|
69
|
+
// scope, which the CLI's own login asks for.
|
|
70
|
+
exam_setting: 'include_exam_setting'
|
|
65
71
|
};
|
|
66
72
|
const INCLUDE_OPTION = {
|
|
67
73
|
name: '--include',
|
|
@@ -188,13 +194,18 @@ export const FORM = [
|
|
|
188
194
|
summary: 'Show a form: fields, types, choices',
|
|
189
195
|
description: 'The form carries its setting already. --include adds the blocks that are separate reads ' +
|
|
190
196
|
'otherwise, so asking for a form and its rules is one round trip. analytics says which ' +
|
|
191
|
-
'statistics each field takes, which is what the analysis reads validate against.
|
|
197
|
+
'statistics each field takes, which is what the analysis reads validate against. ' +
|
|
198
|
+
"exam_setting is an exam form's, read back in the shape `form edit` writes it. `fields` " +
|
|
192
199
|
'comes back as a list of one-key objects keyed by api_code, not a flat list — `field list` ' +
|
|
193
200
|
'answers the same fields flattened, with api_code on each.',
|
|
194
201
|
args: [{ name: 'form', required: true, description: 'Form token, six letters and digits, e.g. Kp7mQ2' }],
|
|
195
202
|
options: [INCLUDE_OPTION],
|
|
196
203
|
request: (input) => call('getForm', { path: { form_token: input.args.form }, query: includes(input) }),
|
|
197
|
-
examples: [
|
|
204
|
+
examples: [
|
|
205
|
+
'jinshuju form get Kp7mQ2',
|
|
206
|
+
'jinshuju form get Kp7mQ2 --include theme,rules,analytics',
|
|
207
|
+
'jinshuju form get Kp7mQ2 --include exam_setting'
|
|
208
|
+
]
|
|
198
209
|
},
|
|
199
210
|
{
|
|
200
211
|
path: ['form', 'create'],
|
|
@@ -233,6 +244,9 @@ export const FORM = [
|
|
|
233
244
|
const { body, settings } = createFormBody(input);
|
|
234
245
|
if (!settings)
|
|
235
246
|
return client.request(call('createForm', { body }));
|
|
247
|
+
// The settings can only be sent to a form that exists, but what they
|
|
248
|
+
// would be refused for here can be said before one is made.
|
|
249
|
+
client.check?.(saveSettings('new', settings));
|
|
236
250
|
const form = await client.request(call('createForm', { body }));
|
|
237
251
|
try {
|
|
238
252
|
await client.request(saveSettings(form.token, settings));
|
|
@@ -268,7 +282,10 @@ export const FORM = [
|
|
|
268
282
|
delete body[settings.key];
|
|
269
283
|
// The settings go first: they are the half that can be refused for what
|
|
270
284
|
// the form is, so leading with them is what keeps a refusal from landing
|
|
271
|
-
// after the rest was already written.
|
|
285
|
+
// after the rest was already written. What the rest would be refused for
|
|
286
|
+
// here is said before either goes.
|
|
287
|
+
if (Object.keys(body).length > 0)
|
|
288
|
+
client.check?.(call('updateForm', { path: { form_token: form }, body }));
|
|
272
289
|
await client.request(saveSettings(form, settings));
|
|
273
290
|
if (Object.keys(body).length === 0)
|
|
274
291
|
return client.request(call('getForm', { path: { form_token: form } }));
|
|
@@ -78,7 +78,9 @@ export const NOTIFICATION = [
|
|
|
78
78
|
'Each approach takes its own keys: SMS --recipients --template-id --placeholder; ' +
|
|
79
79
|
'EMAIL --recipients --subject --content; WEIXIN_ONETIME --subject --content; ' +
|
|
80
80
|
'WXWORK and DING_TALK --url --content; WEBHOOK --url. ' +
|
|
81
|
-
'scope_conditions, schedule_time_rule, smtp_account_id, weixin_onetime_url and mentioned_mobile_list go through --json.'
|
|
81
|
+
'scope_conditions, schedule_time_rule, smtp_account_id, weixin_onetime_url and mentioned_mobile_list go through --json. ' +
|
|
82
|
+
'Each condition in scope_conditions takes the operators and values `jinshuju field filterable --form <token>` ' +
|
|
83
|
+
'lists for its field, written as its examples are.',
|
|
82
84
|
options: [
|
|
83
85
|
FORM_OPTION,
|
|
84
86
|
{
|
package/dist/commands/routine.js
CHANGED
|
@@ -44,8 +44,8 @@ const ROUTINE_PAYLOAD = [
|
|
|
44
44
|
' { "source_kind": "form" | "table", "source_token": "Kp7mQ2",',
|
|
45
45
|
' "on": "created" | "updated" | "matched",',
|
|
46
46
|
' "field_codes": ["field_3"],',
|
|
47
|
-
' "scope_conditions": [{ "trigger": "field_5", "operator": "
|
|
48
|
-
' "value": "code_vip", "group_index": 0 }],',
|
|
47
|
+
' "scope_conditions": [{ "trigger": "field_5", "operator": "any_in",',
|
|
48
|
+
' "value": ["code_vip"], "group_index": 0 }],',
|
|
49
49
|
' "include_bulk": false }',
|
|
50
50
|
' on created runs for each new entry',
|
|
51
51
|
' on updated runs when one of field_codes changes: 1 to 10 api_codes;',
|
|
@@ -55,20 +55,23 @@ const ROUTINE_PAYLOAD = [
|
|
|
55
55
|
' after the change. The source joins objects by itself.',
|
|
56
56
|
' include_bulk: imports and batch edits trigger as well, as one run.',
|
|
57
57
|
'',
|
|
58
|
-
'A condition
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
' yesterday, tomorrow, this_week, last_week, this_month,',
|
|
68
|
-
' last_month, next_month, last_1, last_3, last_7, last_30',
|
|
58
|
+
'A condition names a field and what to test it for. Its value is not shaped',
|
|
59
|
+
'as the field takes it in an entry: `jinshuju field filterable --form <token>',
|
|
60
|
+
'--for routine` lists the fields a routine can test, the operators each takes',
|
|
61
|
+
"and the value each operator takes, with examples in the field's own codes.",
|
|
62
|
+
' trigger the field as that list names it; a subtable column is',
|
|
63
|
+
' field_3.field_1',
|
|
64
|
+
' operator one the field lists there',
|
|
65
|
+
" value shaped as that operator's examples: a choice is its code,",
|
|
66
|
+
' never its label',
|
|
69
67
|
' group_index conditions sharing an index must all hold; a negative index',
|
|
70
68
|
' makes its group any-of; separate groups are alternatives',
|
|
71
|
-
' scope_attr
|
|
69
|
+
' scope_attr when the field lists one: date_time tests a reservation',
|
|
70
|
+
' field by its date; its items are listed without one',
|
|
71
|
+
'',
|
|
72
|
+
"The answer's preview_condition_matches says which of the source's latest 20",
|
|
73
|
+
'entries meet each group as the conditions stand. When those are not the',
|
|
74
|
+
'entries the instruction means, the conditions are wrong: fix them with update.',
|
|
72
75
|
'',
|
|
73
76
|
'Keys the API does not read are ignored, so `routine get --output json` can be',
|
|
74
77
|
'edited and sent back, once delete_authorized is taken out of it.',
|
|
@@ -256,6 +259,7 @@ export const ROUTINE = [
|
|
|
256
259
|
description: "trigger_text says when it runs in the 自动任务 page's words; next_runs holds the next five times of an " +
|
|
257
260
|
'active schedule, and is empty otherwise. A data trigger has its conditions in words under ' +
|
|
258
261
|
'event.conditions, and as stored under event.scope_conditions, which is what update takes back. ' +
|
|
262
|
+
"preview_condition_matches says which of the source's latest 20 entries meet each condition group. " +
|
|
259
263
|
'last_run is the latest run, and url opens the routine on the page.',
|
|
260
264
|
args: [ROUTINE_ARG],
|
|
261
265
|
request: (input) => call('getRoutine', { path: { id: input.args.routine } }),
|
|
@@ -265,7 +269,8 @@ export const ROUTINE = [
|
|
|
265
269
|
path: ['routine', 'create'],
|
|
266
270
|
summary: 'Create a routine; it is active at once',
|
|
267
271
|
description: 'The flags cover a scheduled routine in one command; an event trigger and its conditions go in --json, ' +
|
|
268
|
-
'and the flags still apply on top of it. The answer is the routine as `routine get` shows it, url included
|
|
272
|
+
'and the flags still apply on top of it. The answer is the routine as `routine get` shows it, url included; ' +
|
|
273
|
+
'for a data trigger with conditions, read its preview_condition_matches before saying the routine is right. ' +
|
|
269
274
|
"A routine against the page's rules is refused with every reason the page gives.",
|
|
270
275
|
options: ROUTINE_OPTIONS,
|
|
271
276
|
payload: ROUTINE_PAYLOAD,
|
package/dist/errors.d.ts
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
export declare class UsageError extends Error {
|
|
3
3
|
name: string;
|
|
4
4
|
}
|
|
5
|
+
/** One thing a body was refused for before it was sent, at the value a JSON Pointer names. */
|
|
6
|
+
export interface Refusal {
|
|
7
|
+
readonly pointer: string;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A body refused here, before it was sent, by the openapi.yaml this CLI
|
|
12
|
+
* shipped with (src/preflight.ts). Usage, like any input the CLI could not
|
|
13
|
+
* take, and the reasons are kept apart from the words so `--output json`
|
|
14
|
+
* can carry them the way a server's 400 carries its errors[].
|
|
15
|
+
*/
|
|
16
|
+
export declare class PreflightError extends UsageError {
|
|
17
|
+
readonly errors: readonly Refusal[];
|
|
18
|
+
constructor(message: string, errors: readonly Refusal[]);
|
|
19
|
+
}
|
|
5
20
|
/** No credential, or one the server would not take. */
|
|
6
21
|
export declare class AuthError extends Error {
|
|
7
22
|
name: string;
|
|
@@ -46,6 +61,8 @@ export type ClassifiedError = {
|
|
|
46
61
|
body?: unknown;
|
|
47
62
|
/** Seconds the server asked for before trying again, when it said. */
|
|
48
63
|
retry_after?: number;
|
|
64
|
+
/** What a body was refused for before it was sent, each at its pointer. */
|
|
65
|
+
errors?: readonly Refusal[];
|
|
49
66
|
};
|
|
50
67
|
/**
|
|
51
68
|
* Sorts a failure into its kind. An error that wraps another — "the form was
|
package/dist/errors.js
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
export class UsageError extends Error {
|
|
3
3
|
name = 'UsageError';
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* A body refused here, before it was sent, by the openapi.yaml this CLI
|
|
7
|
+
* shipped with (src/preflight.ts). Usage, like any input the CLI could not
|
|
8
|
+
* take, and the reasons are kept apart from the words so `--output json`
|
|
9
|
+
* can carry them the way a server's 400 carries its errors[].
|
|
10
|
+
*/
|
|
11
|
+
export class PreflightError extends UsageError {
|
|
12
|
+
errors;
|
|
13
|
+
constructor(message, errors) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.errors = errors;
|
|
16
|
+
this.name = 'PreflightError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
5
19
|
/** No credential, or one the server would not take. */
|
|
6
20
|
export class AuthError extends Error {
|
|
7
21
|
name = 'AuthError';
|
|
@@ -79,6 +93,9 @@ function retryAfterIn(body) {
|
|
|
79
93
|
*/
|
|
80
94
|
export function classify(error) {
|
|
81
95
|
const message = error instanceof Error ? error.message : String(error);
|
|
96
|
+
if (error instanceof PreflightError) {
|
|
97
|
+
return { kind: 'usage', exitCode: EXIT_CODES.usage, message, errors: error.errors };
|
|
98
|
+
}
|
|
82
99
|
if (error instanceof UsageError)
|
|
83
100
|
return { kind: 'usage', exitCode: EXIT_CODES.usage, message };
|
|
84
101
|
if (error instanceof AuthError)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Operation, Schema } from '../spec.js';
|
|
2
2
|
/** The path every operation's path is relative to, from `servers`. */
|
|
3
3
|
export declare const BASE_PATH = "/api/v1";
|
|
4
|
-
|
|
4
|
+
/** The day spec/openapi.yaml was fetched from the API, when scripts/fetch-spec.mjs recorded it. */
|
|
5
|
+
export declare const SPEC_DATE: string | undefined;
|
|
6
|
+
export type OperationId = 'aggregateEntries' | 'aggregateFormViewEntries' | 'aggregateTableEntries' | 'aggregateTableViewEntries' | 'aggregateTradeTransactions' | 'checkFormFieldData' | 'checkTableFieldData' | 'copyForm' | 'countEntries' | 'countEntriesAcrossForms' | 'countFormViewEntries' | 'countTableEntries' | 'countTableViewEntries' | 'createCheckinCampaign' | 'createEmailTask' | 'createEntriesBatch' | 'createEntry' | 'createEntryComment' | 'createEntryImport' | 'createEntryLegacy' | 'createFillFormEntry' | 'createFillViewEntry' | 'createFolder' | 'createForm' | 'createFormView' | 'createFormWebhook' | 'createMemoryNote' | 'createMessageChannel' | 'createNotificationRule' | 'createOpensearchQuery' | 'createRoutine' | 'createSmsSignature' | 'createSmsTask' | 'createSmsTemplate' | 'createTable' | 'createTableEntry' | 'createTableEntryComment' | 'createTableView' | 'createTemplateUsage' | 'createWeixinOauthSession' | 'deleteCheckinCampaign' | 'deleteEntry' | 'deleteEntryComment' | 'deleteForm' | 'deleteFormView' | 'deleteFormWebhook' | 'deleteMemoryNotes' | 'deleteMessageChannel' | 'deleteNotificationRule' | 'deleteRoutine' | 'deleteSmsSignature' | 'deleteSmsTemplate' | 'deleteTable' | 'deleteTableEntry' | 'deleteTableEntryComment' | 'deleteTableView' | 'estimateEmailTask' | 'estimateEmailTaskResend' | 'estimateMessage' | 'estimateSmsTask' | 'estimateSmsTaskChange' | 'estimateSmsTaskResend' | 'getBillingAccount' | 'getCheckinCampaign' | 'getCurrentUser' | 'getEmailTask' | 'getEntry' | 'getEntryImport' | 'getEntryStats' | 'getEvaluationSetting' | 'getExamSetting' | 'getFieldType' | 'getFillFormPage' | 'getFillViewPage' | 'getFolder' | 'getForm' | 'getFormSetting' | 'getFormView' | 'getManuallyCloseRule' | 'getMemory' | 'getMessage' | 'getMessageChannel' | 'getNotificationRule' | 'getOpensearchQuery' | 'getPublishedArtifact' | 'getRoutine' | 'getSmsTask' | 'getTable' | 'getTableEntry' | 'getTableView' | 'getTradeMerchant' | 'listArtifacts' | 'listBillingAccountInvoices' | 'listBillingAccountPaidFeatures' | 'listBillingAccountPaymentHistories' | 'listBillingAccountUsers' | 'listCheckinCampaigns' | 'listContacts' | 'listEmailTaskActivities' | 'listEmailTasks' | 'listEntries' | 'listEntryComments' | 'listExtendedAttributes' | 'listFieldRules' | 'listFieldTypes' | 'listFolders' | 'listFormConditionTriggerableFields' | 'listFormCooperators' | 'listFormViewEntries' | 'listFormViews' | 'listForms' | 'listMessageChannels' | 'listMessages' | 'listMyFilledForms' | 'listMySubmittedEntries' | 'listNotificationRuleNotifications' | 'listNotificationRules' | 'listOpensearchQueries' | 'listOpensearchQuerySuggestions' | 'listRoutineRuns' | 'listRoutines' | 'listSmsAuditStatuses' | 'listSmsSignatures' | 'listSmsTaskActivities' | 'listSmsTasks' | 'listSmsTemplates' | 'listSmtpAccounts' | 'listTableConditionTriggerableFields' | 'listTableEntries' | 'listTableEntryComments' | 'listTableViewEntries' | 'listTableViews' | 'listTables' | 'listTradePayouts' | 'listTradeRefunds' | 'listTradeTransactions' | 'moveFormToFolder' | 'moveTableToFolder' | 'patchEntriesBatch' | 'pauseRoutine' | 'prepareEntryAttachmentUpload' | 'prepareFormImageUpload' | 'prepareImportFileUpload' | 'previewFormFieldTypeChange' | 'previewTableFieldTypeChange' | 'replaceEntry' | 'replaceTableEntry' | 'resendEmailTask' | 'resendSmsTask' | 'resumeRoutine' | 'runRoutine' | 'searchEntriesAcrossForms' | 'searchMySubmittedEntries' | 'sendMessage' | 'sendSmsTask' | 'summarizeEntries' | 'summarizeFormViewEntries' | 'summarizeTableEntries' | 'summarizeTableViewEntries' | 'updateAccessPolicy' | 'updateCheckinCampaign' | 'updateEntry' | 'updateEntryComment' | 'updateEntryViaPost' | 'updateEvaluationSetting' | 'updateExamSetting' | 'updateForm' | 'updateFormSetting' | 'updateFormTheme' | 'updateFormView' | 'updateManuallyCloseRule' | 'updateMemoryNote' | 'updateNotificationRule' | 'updateOpensearchQuery' | 'updatePublishedArtifact' | 'updateRoutine' | 'updateSmsSignature' | 'updateSmsTask' | 'updateSmsTemplate' | 'updateTable' | 'updateTableEntry' | 'updateTableEntryComment' | 'updateTableEntryViaPost' | 'updateTableView' | 'uploadEntryAttachment' | 'uploadFormImage' | 'uploadImportFile' | 'uploadUserLicenseAttachment' | 'verifyRedirectParams';
|
|
5
7
|
export declare const OPERATIONS: {
|
|
6
8
|
readonly [id in OperationId]: Operation;
|
|
7
9
|
};
|