@jinshuju/cli 0.25.0 → 0.25.1

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
@@ -246,6 +246,12 @@ jinshuju field update-choices --form Kp7mQ2 field_7 --json '{"add":[{"label":"Th
246
246
  jinshuju field remove --form Kp7mQ2 field_9 --yes
247
247
  ```
248
248
 
249
+ `add`, `update` and `update-choices` answer with the fields they touched rather
250
+ than the whole container the PATCH returns. A form whose fields need a plan its
251
+ account lacks also answers with `unusable_features`, and these commands and
252
+ `field list` keep it beside the fields: the form is saved, but respondents
253
+ cannot submit it until the account upgrades.
254
+
249
255
  A payload is looked at once before it is sent, against the openapi.yaml the
250
256
  CLI shipped with, and refused only for what a newer API could not have made
251
257
  right: a required key missing, a value of the wrong type, `null` for a key
@@ -65,6 +65,18 @@ function fieldTypesForReading(body) {
65
65
  }
66
66
  return rows[0];
67
67
  }
68
+ /**
69
+ * Fields as a listing, cut out of the form that answered, with the one thing
70
+ * beside them that the cut must not lose: `unusable_features`. A form answers
71
+ * with it when its fields need a plan its account lacks. The form is saved, but
72
+ * a respondent's submission is refused until the account upgrades, and the
73
+ * fields are where that news arrives: dropping it left the caller thinking all
74
+ * was well. A table never has it.
75
+ */
76
+ function fieldListing(body, rows) {
77
+ const unusable = body?.unusable_features;
78
+ return { data: rows, ...(unusable === undefined ? {} : { unusable_features: unusable }) };
79
+ }
68
80
  /**
69
81
  * What a field write touched, out of the whole form it answers with.
70
82
  *
@@ -77,7 +89,7 @@ function fieldTypesForReading(body) {
77
89
  function touchedFields(body, wanted) {
78
90
  const fields = selectFields(body);
79
91
  const touched = fields.filter(wanted);
80
- return { data: touched.length > 0 ? touched : fields };
92
+ return fieldListing(body, touched.length > 0 ? touched : fields);
81
93
  }
82
94
  /** The labels a field payload carries, one object or a list of them. */
83
95
  function labelsOf(payload) {
@@ -119,6 +131,10 @@ function conditionFieldsForReading(body) {
119
131
  return [heading, { ...rest, operators }];
120
132
  }));
121
133
  }
134
+ /** What `unusable_features` beside the fields means, which help says for each command that keeps it. */
135
+ const UNUSABLE_FEATURES = "unusable_features beside the fields means the form holds fields its account's plan cannot use: " +
136
+ 'it is saved, but respondents cannot submit it until the account upgrades.';
137
+ const WRITE_ANSWER = `Answers with the fields it touched. ${UNUSABLE_FEATURES}`;
122
138
  const KIND_OPTION = {
123
139
  name: '--kind',
124
140
  type: 'string',
@@ -173,10 +189,10 @@ export const FIELD = [
173
189
  {
174
190
  path: ['field', 'list'],
175
191
  summary: 'List the fields of a form or table',
176
- description: 'Read out of the object structure, the same fields `form get` and `table get` return.',
192
+ description: `Read out of the object structure, the same fields \`form get\` and \`table get\` return. ${UNUSABLE_FEATURES}`,
177
193
  options: [...CONTAINER_OPTIONS],
178
194
  request: (input) => onContainer(input, 'getForm', 'getTable'),
179
- select: (body) => ({ data: selectFields(body) })
195
+ select: (body) => fieldListing(body, selectFields(body))
180
196
  },
181
197
  {
182
198
  path: ['field', 'filterable'],
@@ -224,7 +240,7 @@ export const FIELD = [
224
240
  {
225
241
  path: ['field', 'add'],
226
242
  summary: 'Add fields to a form or table',
227
- description: 'One field object, or a list of them. Do not pass api_code: the backend generates it.',
243
+ description: `One field object, or a list of them. Do not pass api_code: the backend generates it. ${WRITE_ANSWER}`,
228
244
  options: [...CONTAINER_OPTIONS, JSON_OPTION],
229
245
  payload: FIELD_PAYLOAD,
230
246
  request: (input) => onContainer(input, 'updateForm', 'updateTable', { body: { fields: { add: one(payload(input)) } } }),
@@ -238,7 +254,8 @@ export const FIELD = [
238
254
  path: ['field', 'update'],
239
255
  summary: 'Update one field',
240
256
  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.',
257
+ 'Write only the keys to change, flat on the field, as the payload below says. ' +
258
+ WRITE_ANSWER,
242
259
  args: [{ name: 'api-code', required: true, description: 'Field api_code, e.g. field_3' }],
243
260
  options: [...CONTAINER_OPTIONS, JSON_OPTION],
244
261
  payload: FIELD_PAYLOAD,
@@ -253,7 +270,7 @@ export const FIELD = [
253
270
  {
254
271
  path: ['field', 'update-choices'],
255
272
  summary: "Change a field's choices",
256
- description: 'The payload is the choice operations the field takes, e.g. {add, update, remove}.',
273
+ description: `The payload is the choice operations the field takes, e.g. {add, update, remove}. ${WRITE_ANSWER}`,
257
274
  args: [{ name: 'api-code', required: true, description: 'Field api_code' }],
258
275
  options: [...CONTAINER_OPTIONS, JSON_OPTION],
259
276
  request: (input) => onContainer(input, 'updateForm', 'updateTable', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinshuju/cli",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Command line interface for Jinshuju Open API v1",
5
5
  "homepage": "https://github.com/jinshuju/cli#readme",
6
6
  "bugs": {