@jinshuju/cli 0.13.0 → 0.14.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/dist/commands/checkin.js +3 -2
- package/dist/commands/entry.js +5 -4
- package/dist/generated/operations.js +347 -61
- package/dist/options.js +9 -2
- package/dist/render.js +2 -2
- package/dist/spec.d.ts +13 -5
- package/dist/spec.js +29 -9
- package/package.json +1 -1
package/dist/commands/checkin.js
CHANGED
|
@@ -20,7 +20,7 @@ export const CHECKIN = [
|
|
|
20
20
|
summary: 'List your check-in campaigns',
|
|
21
21
|
options: [
|
|
22
22
|
{ name: '--form', type: 'string', placeholder: '<token>', description: 'Only the campaigns of this form' },
|
|
23
|
-
LIMIT_OPTION
|
|
23
|
+
{ ...LIMIT_OPTION, description: 'Campaigns to return (default 50, up to 100)' }
|
|
24
24
|
],
|
|
25
25
|
request: (input) => call('listCheckinCampaigns', {
|
|
26
26
|
query: { limit: paging(input).limit, form_token: input.options.form }
|
|
@@ -112,6 +112,7 @@ export const CHECKIN = [
|
|
|
112
112
|
request: (input) => {
|
|
113
113
|
confirmed(input, `Deleting check-in campaign ${input.args.campaign}`);
|
|
114
114
|
return call('deleteCheckinCampaign', { path: { id: input.args.campaign } });
|
|
115
|
-
}
|
|
115
|
+
},
|
|
116
|
+
select: (body, input) => body ?? { id: Number(input.args.campaign) }
|
|
116
117
|
}
|
|
117
118
|
];
|
package/dist/commands/entry.js
CHANGED
|
@@ -7,9 +7,10 @@ import { call, choices } from '../spec.js';
|
|
|
7
7
|
import { isRecord } from '../values.js';
|
|
8
8
|
import { basename } from 'node:path';
|
|
9
9
|
import { upload } from './upload.js';
|
|
10
|
+
/** The api_codes a --fields named, for `call` to spell as the parameter says: comma-joined, as the spec has it. */
|
|
10
11
|
function list(value) {
|
|
11
12
|
const values = value;
|
|
12
|
-
return values && values.length > 0 ? values
|
|
13
|
+
return values && values.length > 0 ? values : undefined;
|
|
13
14
|
}
|
|
14
15
|
function labels(input) {
|
|
15
16
|
return input.options.labels ? true : undefined;
|
|
@@ -378,7 +379,7 @@ export const ENTRY = [
|
|
|
378
379
|
if (keyword !== undefined) {
|
|
379
380
|
throw new UsageError('--keyword searches the fields of one form or table, so it counts one container, not several');
|
|
380
381
|
}
|
|
381
|
-
return call('countEntriesAcrossForms', { query: { filters: filters(input), form_tokens: tokens
|
|
382
|
+
return call('countEntriesAcrossForms', { query: { filters: filters(input), form_tokens: tokens } });
|
|
382
383
|
},
|
|
383
384
|
examples: [
|
|
384
385
|
"jinshuju entry count --form Kp7mQ2 --filter 'field_3 gte 80'",
|
|
@@ -415,7 +416,7 @@ export const ENTRY = [
|
|
|
415
416
|
return call('searchMySubmittedEntries', {
|
|
416
417
|
query: {
|
|
417
418
|
keyword: input.args.keyword,
|
|
418
|
-
form_tokens: tokens.length > 0 ? tokens
|
|
419
|
+
form_tokens: tokens.length > 0 ? tokens : undefined
|
|
419
420
|
}
|
|
420
421
|
});
|
|
421
422
|
}
|
|
@@ -423,7 +424,7 @@ export const ENTRY = [
|
|
|
423
424
|
return call('searchEntriesAcrossForms', {
|
|
424
425
|
query: {
|
|
425
426
|
keyword: input.args.keyword,
|
|
426
|
-
form_tokens: tokens.length > 0 ? tokens
|
|
427
|
+
form_tokens: tokens.length > 0 ? tokens : undefined,
|
|
427
428
|
filters: scope.length > 0 ? JSON.stringify(scope.map(parseFilter)) : undefined
|
|
428
429
|
}
|
|
429
430
|
});
|
|
@@ -8,10 +8,25 @@ export const OPERATIONS = {
|
|
|
8
8
|
path: '/forms/{form_token}/entries/aggregate',
|
|
9
9
|
parameters: [
|
|
10
10
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
11
|
-
{
|
|
12
|
-
|
|
11
|
+
{
|
|
12
|
+
name: 'metrics',
|
|
13
|
+
in: 'query',
|
|
14
|
+
content: 'application/json',
|
|
15
|
+
schema: { type: 'array', items: { $ref: 'AggregateMetric' } }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'dimensions',
|
|
19
|
+
in: 'query',
|
|
20
|
+
content: 'application/json',
|
|
21
|
+
schema: { type: 'array', items: { $ref: 'AggregateDimension' } }
|
|
22
|
+
},
|
|
13
23
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } },
|
|
14
|
-
{
|
|
24
|
+
{
|
|
25
|
+
name: 'filters',
|
|
26
|
+
in: 'query',
|
|
27
|
+
content: 'application/json',
|
|
28
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
29
|
+
},
|
|
15
30
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
16
31
|
]
|
|
17
32
|
},
|
|
@@ -21,10 +36,25 @@ export const OPERATIONS = {
|
|
|
21
36
|
parameters: [
|
|
22
37
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
23
38
|
{ name: 'view_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
24
|
-
{
|
|
25
|
-
|
|
39
|
+
{
|
|
40
|
+
name: 'metrics',
|
|
41
|
+
in: 'query',
|
|
42
|
+
content: 'application/json',
|
|
43
|
+
schema: { type: 'array', items: { $ref: 'AggregateMetric' } }
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'dimensions',
|
|
47
|
+
in: 'query',
|
|
48
|
+
content: 'application/json',
|
|
49
|
+
schema: { type: 'array', items: { $ref: 'AggregateDimension' } }
|
|
50
|
+
},
|
|
26
51
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } },
|
|
27
|
-
{
|
|
52
|
+
{
|
|
53
|
+
name: 'filters',
|
|
54
|
+
in: 'query',
|
|
55
|
+
content: 'application/json',
|
|
56
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
57
|
+
},
|
|
28
58
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
29
59
|
]
|
|
30
60
|
},
|
|
@@ -33,10 +63,25 @@ export const OPERATIONS = {
|
|
|
33
63
|
path: '/tables/{table_token}/entries/aggregate',
|
|
34
64
|
parameters: [
|
|
35
65
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
36
|
-
{
|
|
37
|
-
|
|
66
|
+
{
|
|
67
|
+
name: 'metrics',
|
|
68
|
+
in: 'query',
|
|
69
|
+
content: 'application/json',
|
|
70
|
+
schema: { type: 'array', items: { $ref: 'AggregateMetric' } }
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'dimensions',
|
|
74
|
+
in: 'query',
|
|
75
|
+
content: 'application/json',
|
|
76
|
+
schema: { type: 'array', items: { $ref: 'AggregateDimension' } }
|
|
77
|
+
},
|
|
38
78
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } },
|
|
39
|
-
{
|
|
79
|
+
{
|
|
80
|
+
name: 'filters',
|
|
81
|
+
in: 'query',
|
|
82
|
+
content: 'application/json',
|
|
83
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
84
|
+
},
|
|
40
85
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
41
86
|
]
|
|
42
87
|
},
|
|
@@ -46,10 +91,25 @@ export const OPERATIONS = {
|
|
|
46
91
|
parameters: [
|
|
47
92
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
48
93
|
{ name: 'view_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
49
|
-
{
|
|
50
|
-
|
|
94
|
+
{
|
|
95
|
+
name: 'metrics',
|
|
96
|
+
in: 'query',
|
|
97
|
+
content: 'application/json',
|
|
98
|
+
schema: { type: 'array', items: { $ref: 'AggregateMetric' } }
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'dimensions',
|
|
102
|
+
in: 'query',
|
|
103
|
+
content: 'application/json',
|
|
104
|
+
schema: { type: 'array', items: { $ref: 'AggregateDimension' } }
|
|
105
|
+
},
|
|
51
106
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } },
|
|
52
|
-
{
|
|
107
|
+
{
|
|
108
|
+
name: 'filters',
|
|
109
|
+
in: 'query',
|
|
110
|
+
content: 'application/json',
|
|
111
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
112
|
+
},
|
|
53
113
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
54
114
|
]
|
|
55
115
|
},
|
|
@@ -78,7 +138,13 @@ export const OPERATIONS = {
|
|
|
78
138
|
path: '/forms/{form_token}/fields/check',
|
|
79
139
|
parameters: [
|
|
80
140
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
81
|
-
{
|
|
141
|
+
{
|
|
142
|
+
name: 'checks',
|
|
143
|
+
in: 'query',
|
|
144
|
+
required: true,
|
|
145
|
+
content: 'application/json',
|
|
146
|
+
schema: { type: 'array', items: { $ref: 'FieldDataCheck' } }
|
|
147
|
+
}
|
|
82
148
|
]
|
|
83
149
|
},
|
|
84
150
|
checkTableFieldData: {
|
|
@@ -86,7 +152,13 @@ export const OPERATIONS = {
|
|
|
86
152
|
path: '/tables/{table_token}/fields/check',
|
|
87
153
|
parameters: [
|
|
88
154
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
89
|
-
{
|
|
155
|
+
{
|
|
156
|
+
name: 'checks',
|
|
157
|
+
in: 'query',
|
|
158
|
+
required: true,
|
|
159
|
+
content: 'application/json',
|
|
160
|
+
schema: { type: 'array', items: { $ref: 'FieldDataCheck' } }
|
|
161
|
+
}
|
|
90
162
|
]
|
|
91
163
|
},
|
|
92
164
|
copyForm: {
|
|
@@ -100,7 +172,12 @@ export const OPERATIONS = {
|
|
|
100
172
|
path: '/forms/{form_token}/entries/count',
|
|
101
173
|
parameters: [
|
|
102
174
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
103
|
-
{
|
|
175
|
+
{
|
|
176
|
+
name: 'filters',
|
|
177
|
+
in: 'query',
|
|
178
|
+
content: 'application/json',
|
|
179
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
180
|
+
},
|
|
104
181
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
105
182
|
]
|
|
106
183
|
},
|
|
@@ -108,8 +185,13 @@ export const OPERATIONS = {
|
|
|
108
185
|
method: 'GET',
|
|
109
186
|
path: '/entries/count',
|
|
110
187
|
parameters: [
|
|
111
|
-
{ name: 'form_tokens', in: 'query', schema: { type: 'string' } },
|
|
112
|
-
{
|
|
188
|
+
{ name: 'form_tokens', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
189
|
+
{
|
|
190
|
+
name: 'filters',
|
|
191
|
+
in: 'query',
|
|
192
|
+
content: 'application/json',
|
|
193
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
194
|
+
}
|
|
113
195
|
]
|
|
114
196
|
},
|
|
115
197
|
countFormViewEntries: {
|
|
@@ -118,7 +200,12 @@ export const OPERATIONS = {
|
|
|
118
200
|
parameters: [
|
|
119
201
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
120
202
|
{ name: 'view_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
121
|
-
{
|
|
203
|
+
{
|
|
204
|
+
name: 'filters',
|
|
205
|
+
in: 'query',
|
|
206
|
+
content: 'application/json',
|
|
207
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
208
|
+
},
|
|
122
209
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
123
210
|
]
|
|
124
211
|
},
|
|
@@ -127,7 +214,12 @@ export const OPERATIONS = {
|
|
|
127
214
|
path: '/tables/{table_token}/entries/count',
|
|
128
215
|
parameters: [
|
|
129
216
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
130
|
-
{
|
|
217
|
+
{
|
|
218
|
+
name: 'filters',
|
|
219
|
+
in: 'query',
|
|
220
|
+
content: 'application/json',
|
|
221
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
222
|
+
},
|
|
131
223
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
132
224
|
]
|
|
133
225
|
},
|
|
@@ -137,7 +229,12 @@ export const OPERATIONS = {
|
|
|
137
229
|
parameters: [
|
|
138
230
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
139
231
|
{ name: 'view_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
140
|
-
{
|
|
232
|
+
{
|
|
233
|
+
name: 'filters',
|
|
234
|
+
in: 'query',
|
|
235
|
+
content: 'application/json',
|
|
236
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
237
|
+
},
|
|
141
238
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
142
239
|
]
|
|
143
240
|
},
|
|
@@ -400,7 +497,7 @@ export const OPERATIONS = {
|
|
|
400
497
|
parameters: [
|
|
401
498
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
402
499
|
{ name: 'serial_number', in: 'path', required: true, schema: { type: 'integer' } },
|
|
403
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
500
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
404
501
|
{ name: 'include_labels', in: 'query', schema: { type: 'boolean' } }
|
|
405
502
|
]
|
|
406
503
|
},
|
|
@@ -500,7 +597,7 @@ export const OPERATIONS = {
|
|
|
500
597
|
parameters: [
|
|
501
598
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
502
599
|
{ name: 'serial_number', in: 'path', required: true, schema: { type: 'integer' } },
|
|
503
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
600
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
504
601
|
{ name: 'include_labels', in: 'query', schema: { type: 'boolean' } }
|
|
505
602
|
]
|
|
506
603
|
},
|
|
@@ -548,10 +645,20 @@ export const OPERATIONS = {
|
|
|
548
645
|
path: '/forms/{form_token}/entries',
|
|
549
646
|
parameters: [
|
|
550
647
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
551
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
552
|
-
{
|
|
648
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
649
|
+
{
|
|
650
|
+
name: 'filters',
|
|
651
|
+
in: 'query',
|
|
652
|
+
content: 'application/json',
|
|
653
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
654
|
+
},
|
|
553
655
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } },
|
|
554
|
-
{
|
|
656
|
+
{
|
|
657
|
+
name: 'sort',
|
|
658
|
+
in: 'query',
|
|
659
|
+
content: 'application/json',
|
|
660
|
+
schema: { type: 'array', items: { $ref: 'SortRule' } }
|
|
661
|
+
},
|
|
555
662
|
{ name: 'created_at', in: 'query', schema: { type: 'string' } },
|
|
556
663
|
{ name: 'next', in: 'query', schema: { type: ['integer', 'string'] } },
|
|
557
664
|
{ name: 'skip', in: 'query', schema: { type: 'integer', minimum: 0, maximum: 10000 } },
|
|
@@ -612,8 +719,18 @@ export const OPERATIONS = {
|
|
|
612
719
|
path: '/forms',
|
|
613
720
|
parameters: [
|
|
614
721
|
{ name: 'q', in: 'query', schema: { type: 'string' } },
|
|
615
|
-
{
|
|
616
|
-
|
|
722
|
+
{
|
|
723
|
+
name: 'filters',
|
|
724
|
+
in: 'query',
|
|
725
|
+
content: 'application/json',
|
|
726
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
name: 'sort',
|
|
730
|
+
in: 'query',
|
|
731
|
+
content: 'application/json',
|
|
732
|
+
schema: { type: 'array', items: { $ref: 'FormSortRule' } }
|
|
733
|
+
},
|
|
617
734
|
{ name: 'next', in: 'query', schema: { type: 'string' } },
|
|
618
735
|
{ name: 'skip', in: 'query', schema: { type: 'integer', minimum: 0, maximum: 10000 } },
|
|
619
736
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } },
|
|
@@ -634,8 +751,13 @@ export const OPERATIONS = {
|
|
|
634
751
|
path: '/my/forms/{form_token}/entries',
|
|
635
752
|
parameters: [
|
|
636
753
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
637
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
638
|
-
{
|
|
754
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
755
|
+
{
|
|
756
|
+
name: 'filters',
|
|
757
|
+
in: 'query',
|
|
758
|
+
content: 'application/json',
|
|
759
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
760
|
+
},
|
|
639
761
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } },
|
|
640
762
|
{ name: 'include_labels', in: 'query', schema: { type: 'boolean' } },
|
|
641
763
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } },
|
|
@@ -660,10 +782,20 @@ export const OPERATIONS = {
|
|
|
660
782
|
path: '/tables/{table_token}/entries',
|
|
661
783
|
parameters: [
|
|
662
784
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
663
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
664
|
-
{
|
|
785
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
786
|
+
{
|
|
787
|
+
name: 'filters',
|
|
788
|
+
in: 'query',
|
|
789
|
+
content: 'application/json',
|
|
790
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
791
|
+
},
|
|
665
792
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } },
|
|
666
|
-
{
|
|
793
|
+
{
|
|
794
|
+
name: 'sort',
|
|
795
|
+
in: 'query',
|
|
796
|
+
content: 'application/json',
|
|
797
|
+
schema: { type: 'array', items: { $ref: 'SortRule' } }
|
|
798
|
+
},
|
|
667
799
|
{ name: 'created_at', in: 'query', schema: { type: 'string' } },
|
|
668
800
|
{ name: 'next', in: 'query', schema: { type: ['integer', 'string'] } },
|
|
669
801
|
{ name: 'skip', in: 'query', schema: { type: 'integer', minimum: 0, maximum: 10000 } },
|
|
@@ -699,8 +831,18 @@ export const OPERATIONS = {
|
|
|
699
831
|
path: '/tables',
|
|
700
832
|
parameters: [
|
|
701
833
|
{ name: 'q', in: 'query', schema: { type: 'string' } },
|
|
702
|
-
{
|
|
703
|
-
|
|
834
|
+
{
|
|
835
|
+
name: 'filters',
|
|
836
|
+
in: 'query',
|
|
837
|
+
content: 'application/json',
|
|
838
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
name: 'sort',
|
|
842
|
+
in: 'query',
|
|
843
|
+
content: 'application/json',
|
|
844
|
+
schema: { type: 'array', items: { $ref: 'FormSortRule' } }
|
|
845
|
+
},
|
|
704
846
|
{ name: 'next', in: 'query', schema: { type: 'string' } },
|
|
705
847
|
{ name: 'skip', in: 'query', schema: { type: 'integer', minimum: 0, maximum: 10000 } },
|
|
706
848
|
{ name: 'limit', in: 'query', schema: { type: 'integer' } }
|
|
@@ -798,7 +940,13 @@ export const OPERATIONS = {
|
|
|
798
940
|
path: '/forms/{form_token}/fields/preview_convert',
|
|
799
941
|
parameters: [
|
|
800
942
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
801
|
-
{
|
|
943
|
+
{
|
|
944
|
+
name: 'checks',
|
|
945
|
+
in: 'query',
|
|
946
|
+
required: true,
|
|
947
|
+
content: 'application/json',
|
|
948
|
+
schema: { type: 'array', items: { $ref: 'FieldTypeChangeCheck' } }
|
|
949
|
+
}
|
|
802
950
|
]
|
|
803
951
|
},
|
|
804
952
|
previewTableFieldTypeChange: {
|
|
@@ -806,7 +954,13 @@ export const OPERATIONS = {
|
|
|
806
954
|
path: '/tables/{table_token}/fields/preview_convert',
|
|
807
955
|
parameters: [
|
|
808
956
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
809
|
-
{
|
|
957
|
+
{
|
|
958
|
+
name: 'checks',
|
|
959
|
+
in: 'query',
|
|
960
|
+
required: true,
|
|
961
|
+
content: 'application/json',
|
|
962
|
+
schema: { type: 'array', items: { $ref: 'FieldTypeChangeCheck' } }
|
|
963
|
+
}
|
|
810
964
|
]
|
|
811
965
|
},
|
|
812
966
|
replaceEntry: {
|
|
@@ -832,8 +986,13 @@ export const OPERATIONS = {
|
|
|
832
986
|
path: '/entries/search',
|
|
833
987
|
parameters: [
|
|
834
988
|
{ name: 'keyword', in: 'query', required: true, schema: { type: 'string', maxLength: 200 } },
|
|
835
|
-
{ name: 'form_tokens', in: 'query', schema: { type: 'string' } },
|
|
836
|
-
{
|
|
989
|
+
{ name: 'form_tokens', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
990
|
+
{
|
|
991
|
+
name: 'filters',
|
|
992
|
+
in: 'query',
|
|
993
|
+
content: 'application/json',
|
|
994
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
995
|
+
}
|
|
837
996
|
]
|
|
838
997
|
},
|
|
839
998
|
searchMySubmittedEntries: {
|
|
@@ -841,7 +1000,7 @@ export const OPERATIONS = {
|
|
|
841
1000
|
path: '/my/search',
|
|
842
1001
|
parameters: [
|
|
843
1002
|
{ name: 'keyword', in: 'query', required: true, schema: { type: 'string', minLength: 1 } },
|
|
844
|
-
{ name: 'form_tokens', in: 'query', schema: { type: 'string' } }
|
|
1003
|
+
{ name: 'form_tokens', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } }
|
|
845
1004
|
]
|
|
846
1005
|
},
|
|
847
1006
|
summarizeEntries: {
|
|
@@ -849,9 +1008,14 @@ export const OPERATIONS = {
|
|
|
849
1008
|
path: '/forms/{form_token}/entries/summary',
|
|
850
1009
|
parameters: [
|
|
851
1010
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
852
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
1011
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
853
1012
|
{ name: 'include_overview', in: 'query', schema: { type: 'boolean' } },
|
|
854
|
-
{
|
|
1013
|
+
{
|
|
1014
|
+
name: 'filters',
|
|
1015
|
+
in: 'query',
|
|
1016
|
+
content: 'application/json',
|
|
1017
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
1018
|
+
},
|
|
855
1019
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
856
1020
|
]
|
|
857
1021
|
},
|
|
@@ -861,9 +1025,14 @@ export const OPERATIONS = {
|
|
|
861
1025
|
parameters: [
|
|
862
1026
|
{ name: 'form_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
863
1027
|
{ name: 'view_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
864
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
1028
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
865
1029
|
{ name: 'include_overview', in: 'query', schema: { type: 'boolean' } },
|
|
866
|
-
{
|
|
1030
|
+
{
|
|
1031
|
+
name: 'filters',
|
|
1032
|
+
in: 'query',
|
|
1033
|
+
content: 'application/json',
|
|
1034
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
1035
|
+
},
|
|
867
1036
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
868
1037
|
]
|
|
869
1038
|
},
|
|
@@ -872,9 +1041,14 @@ export const OPERATIONS = {
|
|
|
872
1041
|
path: '/tables/{table_token}/entries/summary',
|
|
873
1042
|
parameters: [
|
|
874
1043
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
875
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
1044
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
876
1045
|
{ name: 'include_overview', in: 'query', schema: { type: 'boolean' } },
|
|
877
|
-
{
|
|
1046
|
+
{
|
|
1047
|
+
name: 'filters',
|
|
1048
|
+
in: 'query',
|
|
1049
|
+
content: 'application/json',
|
|
1050
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
1051
|
+
},
|
|
878
1052
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
879
1053
|
]
|
|
880
1054
|
},
|
|
@@ -884,9 +1058,14 @@ export const OPERATIONS = {
|
|
|
884
1058
|
parameters: [
|
|
885
1059
|
{ name: 'table_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
886
1060
|
{ name: 'view_token', in: 'path', required: true, schema: { type: 'string' } },
|
|
887
|
-
{ name: 'fields', in: 'query', schema: { type: 'string' } },
|
|
1061
|
+
{ name: 'fields', in: 'query', explode: false, schema: { type: 'array', items: { type: 'string' } } },
|
|
888
1062
|
{ name: 'include_overview', in: 'query', schema: { type: 'boolean' } },
|
|
889
|
-
{
|
|
1063
|
+
{
|
|
1064
|
+
name: 'filters',
|
|
1065
|
+
in: 'query',
|
|
1066
|
+
content: 'application/json',
|
|
1067
|
+
schema: { type: 'array', items: { $ref: 'ScopeCondition' } }
|
|
1068
|
+
},
|
|
890
1069
|
{ name: 'keyword', in: 'query', schema: { type: 'string', maxLength: 200 } }
|
|
891
1070
|
]
|
|
892
1071
|
},
|
|
@@ -1159,6 +1338,36 @@ export const SCHEMAS = {
|
|
|
1159
1338
|
enable_auto_position: { type: 'boolean' }
|
|
1160
1339
|
}
|
|
1161
1340
|
},
|
|
1341
|
+
AggregateDimension: {
|
|
1342
|
+
type: 'object',
|
|
1343
|
+
required: ['field'],
|
|
1344
|
+
properties: { field: { type: 'string' }, bucket: { type: 'string', enum: ['day', 'week', 'month'] } }
|
|
1345
|
+
},
|
|
1346
|
+
AggregateMetric: {
|
|
1347
|
+
type: 'object',
|
|
1348
|
+
required: ['func', 'field'],
|
|
1349
|
+
properties: {
|
|
1350
|
+
func: {
|
|
1351
|
+
type: 'string',
|
|
1352
|
+
enum: [
|
|
1353
|
+
'count',
|
|
1354
|
+
'count_non_empty',
|
|
1355
|
+
'count_empty',
|
|
1356
|
+
'count_unique',
|
|
1357
|
+
'sum',
|
|
1358
|
+
'avg',
|
|
1359
|
+
'min',
|
|
1360
|
+
'max',
|
|
1361
|
+
'stddev',
|
|
1362
|
+
'median',
|
|
1363
|
+
'p25',
|
|
1364
|
+
'p75',
|
|
1365
|
+
'p90'
|
|
1366
|
+
]
|
|
1367
|
+
},
|
|
1368
|
+
field: { type: 'string' }
|
|
1369
|
+
}
|
|
1370
|
+
},
|
|
1162
1371
|
AnswerInput: {
|
|
1163
1372
|
type: 'object',
|
|
1164
1373
|
additionalProperties: false,
|
|
@@ -1392,7 +1601,11 @@ export const SCHEMAS = {
|
|
|
1392
1601
|
},
|
|
1393
1602
|
CopyFormInput: {
|
|
1394
1603
|
type: 'object',
|
|
1395
|
-
properties: {
|
|
1604
|
+
properties: {
|
|
1605
|
+
name: { type: 'string' },
|
|
1606
|
+
folder_token: { type: 'string' },
|
|
1607
|
+
with_notification_rules: { type: 'boolean' }
|
|
1608
|
+
},
|
|
1396
1609
|
additionalProperties: false
|
|
1397
1610
|
},
|
|
1398
1611
|
DailyRepeatCloseRuleInput: {
|
|
@@ -1675,6 +1888,21 @@ export const SCHEMAS = {
|
|
|
1675
1888
|
},
|
|
1676
1889
|
additionalProperties: false
|
|
1677
1890
|
},
|
|
1891
|
+
FieldDataCheck: {
|
|
1892
|
+
type: 'object',
|
|
1893
|
+
required: ['field_api_code'],
|
|
1894
|
+
properties: {
|
|
1895
|
+
field_api_code: { type: 'string' },
|
|
1896
|
+
choice_value: { type: 'string' },
|
|
1897
|
+
choice_type: {
|
|
1898
|
+
type: 'string',
|
|
1899
|
+
enum: ['choice', 'statement', 'dimension', 'level_1', 'level_2', 'level_3', 'level_4']
|
|
1900
|
+
},
|
|
1901
|
+
parent_field: { type: 'string' },
|
|
1902
|
+
check_extended_text: { type: 'boolean' },
|
|
1903
|
+
goods_item_dimension_options: { type: 'object' }
|
|
1904
|
+
}
|
|
1905
|
+
},
|
|
1678
1906
|
FieldInput: {
|
|
1679
1907
|
type: 'object',
|
|
1680
1908
|
required: ['type', 'label'],
|
|
@@ -1821,6 +2049,15 @@ export const SCHEMAS = {
|
|
|
1821
2049
|
},
|
|
1822
2050
|
additionalProperties: false
|
|
1823
2051
|
},
|
|
2052
|
+
FieldTypeChangeCheck: {
|
|
2053
|
+
type: 'object',
|
|
2054
|
+
required: ['field_api_code', 'target_type'],
|
|
2055
|
+
properties: {
|
|
2056
|
+
field_api_code: { type: 'string' },
|
|
2057
|
+
target_type: { type: 'string' },
|
|
2058
|
+
target_precision: { type: 'string', enum: ['month', 'day', 'minute', 'second'] }
|
|
2059
|
+
}
|
|
2060
|
+
},
|
|
1824
2061
|
FieldUpdateInput: {
|
|
1825
2062
|
type: 'object',
|
|
1826
2063
|
additionalProperties: false,
|
|
@@ -2119,16 +2356,7 @@ export const SCHEMAS = {
|
|
|
2119
2356
|
items: {
|
|
2120
2357
|
properties: {
|
|
2121
2358
|
type: {
|
|
2122
|
-
not: {
|
|
2123
|
-
enum: [
|
|
2124
|
-
'PageBreak',
|
|
2125
|
-
'GoodsField',
|
|
2126
|
-
'MultipleBlanksField',
|
|
2127
|
-
'WidgetContact',
|
|
2128
|
-
'WidgetVideo',
|
|
2129
|
-
'WidgetButton'
|
|
2130
|
-
]
|
|
2131
|
-
}
|
|
2359
|
+
not: { enum: ['PageBreak', 'MultipleBlanksField', 'WidgetContact', 'WidgetVideo', 'WidgetButton'] }
|
|
2132
2360
|
}
|
|
2133
2361
|
}
|
|
2134
2362
|
}
|
|
@@ -2328,10 +2556,10 @@ export const SCHEMAS = {
|
|
|
2328
2556
|
success_message: { type: 'string' },
|
|
2329
2557
|
success_message_rich_text: { type: 'string' },
|
|
2330
2558
|
success_message_style: { type: 'string', enum: ['text', 'rich_text'] },
|
|
2331
|
-
entry_submit_mode: { type: 'string' },
|
|
2559
|
+
entry_submit_mode: { type: 'string', enum: ['show_message', 'redirect', 'reports', 'exam_score'] },
|
|
2332
2560
|
success_redirect_url: { type: 'string' },
|
|
2333
2561
|
success_redirect_fields: { type: 'array', items: { type: 'string' } },
|
|
2334
|
-
open_entry_action: { type: 'string' },
|
|
2562
|
+
open_entry_action: { type: 'string', enum: ['hide', 'view', 'edit'] },
|
|
2335
2563
|
open_entry_message: { type: 'string' },
|
|
2336
2564
|
open_entry_cancel_reservation: { type: 'boolean' },
|
|
2337
2565
|
show_serial_number_on_success: { type: 'boolean' },
|
|
@@ -2372,7 +2600,18 @@ export const SCHEMAS = {
|
|
|
2372
2600
|
show_field_number: { type: 'boolean' },
|
|
2373
2601
|
password_required: { type: 'boolean' },
|
|
2374
2602
|
access_password: { type: 'string' },
|
|
2375
|
-
allowed_audience: {
|
|
2603
|
+
allowed_audience: {
|
|
2604
|
+
type: 'string',
|
|
2605
|
+
enum: [
|
|
2606
|
+
'public',
|
|
2607
|
+
'internal',
|
|
2608
|
+
'private',
|
|
2609
|
+
'weixin_qiye_followers_only',
|
|
2610
|
+
'weixin_followers_only',
|
|
2611
|
+
'submitter_only',
|
|
2612
|
+
'gd_user_only'
|
|
2613
|
+
]
|
|
2614
|
+
},
|
|
2376
2615
|
weixin_limited: { type: 'boolean' },
|
|
2377
2616
|
submission_region_limited: { type: 'boolean' },
|
|
2378
2617
|
submission_regions: { type: 'array', items: { type: 'string' } },
|
|
@@ -2384,6 +2623,14 @@ export const SCHEMAS = {
|
|
|
2384
2623
|
},
|
|
2385
2624
|
additionalProperties: false
|
|
2386
2625
|
},
|
|
2626
|
+
FormSortRule: {
|
|
2627
|
+
type: 'object',
|
|
2628
|
+
required: ['field'],
|
|
2629
|
+
properties: {
|
|
2630
|
+
field: { type: 'string', enum: ['created_at', 'last_entry_created_at', 'entries_count'] },
|
|
2631
|
+
order: { type: 'string', enum: ['asc', 'desc'] }
|
|
2632
|
+
}
|
|
2633
|
+
},
|
|
2387
2634
|
FormUpdateInput: {
|
|
2388
2635
|
type: 'object',
|
|
2389
2636
|
properties: {
|
|
@@ -3506,6 +3753,40 @@ export const SCHEMAS = {
|
|
|
3506
3753
|
}
|
|
3507
3754
|
}
|
|
3508
3755
|
},
|
|
3756
|
+
ScopeCondition: {
|
|
3757
|
+
type: 'object',
|
|
3758
|
+
required: ['operator'],
|
|
3759
|
+
properties: {
|
|
3760
|
+
field: { type: 'string' },
|
|
3761
|
+
api_code: { type: 'string' },
|
|
3762
|
+
trigger: { type: 'string' },
|
|
3763
|
+
operator: {
|
|
3764
|
+
type: 'string',
|
|
3765
|
+
enum: [
|
|
3766
|
+
'eq',
|
|
3767
|
+
'ne',
|
|
3768
|
+
'any_in',
|
|
3769
|
+
'none_in',
|
|
3770
|
+
'between',
|
|
3771
|
+
'not_between',
|
|
3772
|
+
'null',
|
|
3773
|
+
'not_null',
|
|
3774
|
+
'gte',
|
|
3775
|
+
'gt',
|
|
3776
|
+
'lte',
|
|
3777
|
+
'lt',
|
|
3778
|
+
'like',
|
|
3779
|
+
'not_like',
|
|
3780
|
+
'within_last',
|
|
3781
|
+
'equal',
|
|
3782
|
+
'not_equal',
|
|
3783
|
+
'start',
|
|
3784
|
+
'end'
|
|
3785
|
+
]
|
|
3786
|
+
},
|
|
3787
|
+
value: {}
|
|
3788
|
+
}
|
|
3789
|
+
},
|
|
3509
3790
|
SectionBreakInput: {
|
|
3510
3791
|
type: 'object',
|
|
3511
3792
|
additionalProperties: false,
|
|
@@ -3606,6 +3887,11 @@ export const SCHEMAS = {
|
|
|
3606
3887
|
random_choices: { type: 'boolean' }
|
|
3607
3888
|
}
|
|
3608
3889
|
},
|
|
3890
|
+
SortRule: {
|
|
3891
|
+
type: 'object',
|
|
3892
|
+
required: ['api_code'],
|
|
3893
|
+
properties: { api_code: { type: 'string' }, order: { type: 'string', enum: ['asc', 'desc'] } }
|
|
3894
|
+
},
|
|
3609
3895
|
StatementInput: {
|
|
3610
3896
|
type: 'object',
|
|
3611
3897
|
additionalProperties: false,
|
package/dist/options.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { UsageError } from './errors.js';
|
|
3
|
+
import { choices } from './spec.js';
|
|
3
4
|
export const OUTPUT_FORMATS = ['text', 'json', 'jsonl'];
|
|
4
5
|
/** Accepted by every command. */
|
|
5
6
|
export const GLOBAL_OPTIONS = [
|
|
@@ -84,13 +85,19 @@ export const CONTAINER_LIST_OPTIONS = [
|
|
|
84
85
|
description: 'Table token, repeatable, e.g. Vn4xR8'
|
|
85
86
|
}
|
|
86
87
|
];
|
|
88
|
+
/**
|
|
89
|
+
* The operators a condition takes, off the spec's own ScopeCondition. The
|
|
90
|
+
* list this replaced was written here, and had drifted: it offered `match`,
|
|
91
|
+
* which the spec does not list.
|
|
92
|
+
*/
|
|
93
|
+
const FILTER_OPERATORS = choices('listEntries', 'filters[].operator');
|
|
87
94
|
export const FILTER_OPTION = {
|
|
88
95
|
name: '--filter',
|
|
89
96
|
type: 'string',
|
|
90
97
|
repeatable: true,
|
|
91
98
|
placeholder: "'<field> <op> [value]'",
|
|
92
|
-
description: 'Filter condition, repeatable, AND-combined.
|
|
93
|
-
|
|
99
|
+
description: 'Filter condition, repeatable, AND-combined. ' +
|
|
100
|
+
(FILTER_OPERATORS ? `Operators: ${FILTER_OPERATORS.join(' ')}. ` : '') +
|
|
94
101
|
"e.g. 'field_3 gte 80', 'created_at within_last 30d', 'field_4 between 1,10'"
|
|
95
102
|
};
|
|
96
103
|
export const FILTERS_OPTION = {
|
package/dist/render.js
CHANGED
|
@@ -39,7 +39,7 @@ export function terminalWidth(stream = process.stdout) {
|
|
|
39
39
|
return stream.isTTY && stream.columns > 0 ? stream.columns : PIPED_WIDTH;
|
|
40
40
|
}
|
|
41
41
|
export function json(value) {
|
|
42
|
-
return JSON.stringify(value, null, 2);
|
|
42
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* One JSON object per line, which is what `jq -c`, a shell loop and a log
|
|
@@ -48,7 +48,7 @@ export function json(value) {
|
|
|
48
48
|
*/
|
|
49
49
|
export function jsonl(value, listKey) {
|
|
50
50
|
const rows = listOf(value, listKey);
|
|
51
|
-
return (rows ?? [value]).map((row) => JSON.stringify(row)).join('\n');
|
|
51
|
+
return (rows ?? [value]).map((row) => JSON.stringify(row ?? null)).join('\n');
|
|
52
52
|
}
|
|
53
53
|
/** The rows a payload carries, when it is a listing. */
|
|
54
54
|
function listOf(value, listKey) {
|
package/dist/spec.d.ts
CHANGED
|
@@ -50,6 +50,12 @@ export interface Parameter {
|
|
|
50
50
|
readonly required?: boolean;
|
|
51
51
|
readonly style?: string;
|
|
52
52
|
readonly explode?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The media type of a document the value carries as text in one query
|
|
55
|
+
* value — `filters=[{"field":…}]` — when it does: `application/json`.
|
|
56
|
+
* `schema` is then the document's.
|
|
57
|
+
*/
|
|
58
|
+
readonly content?: string;
|
|
53
59
|
readonly schema: Schema;
|
|
54
60
|
}
|
|
55
61
|
export interface Operation {
|
|
@@ -92,12 +98,14 @@ export interface CallParts {
|
|
|
92
98
|
export declare function call(id: OperationId, parts?: CallParts): HttpRequest;
|
|
93
99
|
export declare function unansweredLookups(): readonly string[];
|
|
94
100
|
/**
|
|
95
|
-
* The values a query parameter takes, for the flag that feeds it.
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
101
|
+
* The values a query parameter takes, for the flag that feeds it. `path` is
|
|
102
|
+
* the parameter's name, and walks on into a document the parameter carries
|
|
103
|
+
* the way `bodyChoices` walks a body: `filters[].operator`. A flag listing
|
|
104
|
+
* the values itself is a second copy, and the second copy was already behind
|
|
105
|
+
* once: a view type and two scenes the API had learned were refused by the
|
|
106
|
+
* CLI before they reached it.
|
|
99
107
|
*/
|
|
100
|
-
export declare function choices(id: OperationId,
|
|
108
|
+
export declare function choices(id: OperationId, path: string): readonly string[] | undefined;
|
|
101
109
|
/**
|
|
102
110
|
* The values a property of a JSON body takes. `path` walks properties with
|
|
103
111
|
* dots and steps into a list's items with `[]`: `fields[].type`.
|
package/dist/spec.js
CHANGED
|
@@ -67,6 +67,16 @@ function queryOf(id, op, values) {
|
|
|
67
67
|
if (!param) {
|
|
68
68
|
throw new UsageError(`${op.method} ${BASE_PATH}${op.path} takes no ${name} parameter (${id} in openapi.yaml)`);
|
|
69
69
|
}
|
|
70
|
+
if (param.content !== undefined) {
|
|
71
|
+
// A document goes as its text in one value, never repeated the way a
|
|
72
|
+
// list is, and as given: it is the caller's payload as often as not,
|
|
73
|
+
// and the API judges it as it does a body. The tests hold the CLI's own
|
|
74
|
+
// to the document's schema.
|
|
75
|
+
if (typeof value !== 'string')
|
|
76
|
+
throw new Error(`${id} ${name} is ${param.content} text, spelled by the command`);
|
|
77
|
+
query[name] = value;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
70
80
|
const texts = typeof value === 'object' ? [...value] : [String(value)];
|
|
71
81
|
check(param, texts);
|
|
72
82
|
if (isArray(param.schema)) {
|
|
@@ -153,29 +163,39 @@ export function unansweredLookups() {
|
|
|
153
163
|
return unanswered;
|
|
154
164
|
}
|
|
155
165
|
/**
|
|
156
|
-
* The values a query parameter takes, for the flag that feeds it.
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
166
|
+
* The values a query parameter takes, for the flag that feeds it. `path` is
|
|
167
|
+
* the parameter's name, and walks on into a document the parameter carries
|
|
168
|
+
* the way `bodyChoices` walks a body: `filters[].operator`. A flag listing
|
|
169
|
+
* the values itself is a second copy, and the second copy was already behind
|
|
170
|
+
* once: a view type and two scenes the API had learned were refused by the
|
|
171
|
+
* CLI before they reached it.
|
|
160
172
|
*/
|
|
161
|
-
export function choices(id,
|
|
173
|
+
export function choices(id, path) {
|
|
174
|
+
const [first, ...rest] = path.split('.');
|
|
175
|
+
const name = first.endsWith('[]') ? first.slice(0, -2) : first;
|
|
162
176
|
const param = OPERATIONS[id].parameters.find((candidate) => candidate.name === name);
|
|
163
|
-
|
|
177
|
+
// A parameter that is a list offers its items' values.
|
|
178
|
+
const start = param && (isArray(param.schema) ? itemsOf(param.schema) : param.schema);
|
|
179
|
+
return enumOf(walk(start, rest), `${id} ${path}`);
|
|
164
180
|
}
|
|
165
181
|
/**
|
|
166
182
|
* The values a property of a JSON body takes. `path` walks properties with
|
|
167
183
|
* dots and steps into a list's items with `[]`: `fields[].type`.
|
|
168
184
|
*/
|
|
169
185
|
export function bodyChoices(id, path) {
|
|
170
|
-
|
|
171
|
-
|
|
186
|
+
return enumOf(walk(OPERATIONS[id].body?.content['application/json'], path.split('.')), `${id} ${path}`);
|
|
187
|
+
}
|
|
188
|
+
/** The schema the steps lead to: each names a property, and `[]` steps into a list's items. */
|
|
189
|
+
function walk(from, steps) {
|
|
190
|
+
let schema = from;
|
|
191
|
+
for (const step of steps) {
|
|
172
192
|
if (!schema)
|
|
173
193
|
break;
|
|
174
194
|
const many = step.endsWith('[]');
|
|
175
195
|
const property = propertyOf(schema, many ? step.slice(0, -2) : step);
|
|
176
196
|
schema = property && (many ? itemsOf(property) : property);
|
|
177
197
|
}
|
|
178
|
-
return
|
|
198
|
+
return schema;
|
|
179
199
|
}
|
|
180
200
|
/** A property as an object schema or any of its allOf parts declares it. */
|
|
181
201
|
function propertyOf(schema, name) {
|