@jinshuju/cli 0.25.0 → 0.26.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/http.d.ts CHANGED
@@ -44,6 +44,15 @@ export type HttpClientOptions = {
44
44
  */
45
45
  export declare const DEFAULT_TIMEOUT_MS = 60000;
46
46
  export declare const DEFAULT_RETRIES = 3;
47
+ /**
48
+ * The API version every request asks for, in `Jinshuju-Version`. In it a form
49
+ * or table reads its fields in the shape a field write takes, so a field read
50
+ * goes back as it came; without the header the API answers in 2013-07-03,
51
+ * whose fields a write does not take. The commands are written against this
52
+ * version's shapes, so it moves with them, by hand: a spec sync that carried
53
+ * a newer version in would change what the CLI reads before its code did.
54
+ */
55
+ export declare const API_VERSION = "2026-11-12";
47
56
  export declare class JinshujuHttpClient implements HttpClient {
48
57
  private config;
49
58
  private readonly timeoutMs;
package/dist/http.js CHANGED
@@ -41,6 +41,15 @@ const BACKOFF_CAP_MS = 8_000;
41
41
  */
42
42
  const RETRY_ANY = new Set([429, 503]);
43
43
  const RETRY_READS = new Set([500, 502, 504]);
44
+ /**
45
+ * The API version every request asks for, in `Jinshuju-Version`. In it a form
46
+ * or table reads its fields in the shape a field write takes, so a field read
47
+ * goes back as it came; without the header the API answers in 2013-07-03,
48
+ * whose fields a write does not take. The commands are written against this
49
+ * version's shapes, so it moves with them, by hand: a spec sync that carried
50
+ * a newer version in would change what the CLI reads before its code did.
51
+ */
52
+ export const API_VERSION = '2026-11-12';
44
53
  /** How much of an unexpected body is worth putting in front of a reader. */
45
54
  const MAX_SNIPPET = 200;
46
55
  function parseBody(text) {
@@ -242,7 +251,8 @@ export class JinshujuHttpClient {
242
251
  const headers = {
243
252
  Authorization: await this.authorizationHeader(),
244
253
  Accept: 'application/json',
245
- 'User-Agent': `jinshuju-cli/${VERSION} node/${process.versions.node}`
254
+ 'User-Agent': `jinshuju-cli/${VERSION} node/${process.versions.node}`,
255
+ 'Jinshuju-Version': API_VERSION
246
256
  };
247
257
  if (!request.form)
248
258
  headers['Content-Type'] = 'application/json';
@@ -10,12 +10,10 @@ import type { HttpClient, HttpRequest } from './http.js';
10
10
  * value the API learns: an old client would be stricter than the API it
11
11
  * talks to. So the look is a narrow one. It refuses what no newer spec could
12
12
  * have made right — a key that is required, a value of the wrong type, null
13
- * where nothing may be null, a field read back and written back as it came —
14
- * and sends everything else for the API to judge: a key or a value this copy
15
- * does not list may be one the API has learned since. What the CLI's callers
16
- * were most often refused for was the first kind: a field's `validation`
17
- * written back as `form get` returned it, `null` for every key left unset, a
18
- * choice to update named by its value rather than its api_code.
13
+ * where nothing may be null — and sends everything else for the API to judge:
14
+ * a key or a value this copy does not list may be one the API has learned
15
+ * since. A field read with the API version the client asks for is in the
16
+ * shape a write takes, null for a setting included, so it passes as it came.
19
17
  *
20
18
  * What the look finds is said at once, every reason at its pointer, and the
21
19
  * request is not sent. `--as-is` sends the body anyway, for when the API has
package/dist/preflight.js CHANGED
@@ -13,12 +13,10 @@ import { isRecord } from './values.js';
13
13
  * value the API learns: an old client would be stricter than the API it
14
14
  * talks to. So the look is a narrow one. It refuses what no newer spec could
15
15
  * have made right — a key that is required, a value of the wrong type, null
16
- * where nothing may be null, a field read back and written back as it came —
17
- * and sends everything else for the API to judge: a key or a value this copy
18
- * does not list may be one the API has learned since. What the CLI's callers
19
- * were most often refused for was the first kind: a field's `validation`
20
- * written back as `form get` returned it, `null` for every key left unset, a
21
- * choice to update named by its value rather than its api_code.
16
+ * where nothing may be null — and sends everything else for the API to judge:
17
+ * a key or a value this copy does not list may be one the API has learned
18
+ * since. A field read with the API version the client asks for is in the
19
+ * shape a write takes, null for a setting included, so it passes as it came.
22
20
  *
23
21
  * What the look finds is said at once, every reason at its pointer, and the
24
22
  * request is not sent. `--as-is` sends the body anyway, for when the API has
@@ -90,28 +88,8 @@ function refusalOf(issue, method) {
90
88
  }
91
89
  return { pointer, message: `${issue.message}, got ${JSON.stringify(value)}` };
92
90
  }
93
- if (kind === 'unknown_key' && lastSegment(pointer) === 'validation' && isRecord(value)) {
94
- return { pointer, message: flattened(value, issue.takes ?? []) };
95
- }
96
91
  return undefined;
97
92
  }
98
- /**
99
- * `validation` is how a field reads: `form get` and `field list` answer
100
- * `{validation: {required, unique, minimum_length, …}}`, and a field written
101
- * back as it came carries it. The write takes the same keys flat on the
102
- * field, so the message says the payload that would do, worked out from the
103
- * keys the write does take rather than from a list kept here.
104
- */
105
- function flattened(validation, takes) {
106
- const flat = Object.fromEntries(Object.entries(validation).filter(([key]) => takes.includes(key)));
107
- const dropped = Object.keys(validation).filter((key) => !takes.includes(key));
108
- const parts = ['validation is how a field reads, not how it is written'];
109
- if (Object.keys(flat).length > 0)
110
- parts.push(`write its keys flat on the field: ${JSON.stringify(flat)}`);
111
- if (dropped.length > 0)
112
- parts.push(`leave out ${dropped.join(', ')}, which a write does not take`);
113
- return parts.join('; ');
114
- }
115
93
  /** What to add to a refusal at this pointer, when the spec's own words would leave the caller guessing. */
116
94
  function hint(pointer) {
117
95
  if (/\/update_choices\/\d+\/update\/\d+\/api_code$/.test(pointer)) {
@@ -148,9 +126,3 @@ function describe(refusals) {
148
126
  'The request was not sent. --as-is sends it anyway, for the API to judge by the spec it runs.'
149
127
  ].join('\n');
150
128
  }
151
- function lastSegment(pointer) {
152
- return pointer
153
- .slice(pointer.lastIndexOf('/') + 1)
154
- .replace(/~1/g, '/')
155
- .replace(/~0/g, '~');
156
- }
package/dist/schema.d.ts CHANGED
@@ -32,8 +32,6 @@ export interface Issue {
32
32
  readonly value: unknown;
33
33
  /** Whether the rule broken was certainly the one that applied, and not the closest of several shapes. */
34
34
  readonly certain: boolean;
35
- /** For an unknown key, the keys the object does take. */
36
- readonly takes?: readonly string[];
37
35
  }
38
36
  /** The ways a value breaks a schema, first found first. */
39
37
  export declare function validate(schema: Schema | boolean, value: unknown, pointer?: string, certain?: boolean): Issue[];
package/dist/schema.js CHANGED
@@ -26,6 +26,12 @@ export function validate(schema, value, pointer = '', certain = true) {
26
26
  issue('range', `must be at least ${s.minimum}`);
27
27
  if (s.maximum !== undefined && value > s.maximum)
28
28
  issue('range', `must be at most ${s.maximum}`);
29
+ if (s.exclusiveMinimum !== undefined && value <= s.exclusiveMinimum) {
30
+ issue('range', `must be more than ${s.exclusiveMinimum}`);
31
+ }
32
+ if (s.exclusiveMaximum !== undefined && value >= s.exclusiveMaximum) {
33
+ issue('range', `must be less than ${s.exclusiveMaximum}`);
34
+ }
29
35
  }
30
36
  if (typeof value === 'string') {
31
37
  const length = [...value].length;
@@ -98,14 +104,7 @@ function objectIssues(s, value, pointer, certain) {
98
104
  if (declared !== undefined)
99
105
  issues.push(...validate(declared, item, where, certain));
100
106
  else if (s.additionalProperties === false) {
101
- issues.push({
102
- pointer: where,
103
- kind: 'unknown_key',
104
- message: 'is not a key it takes',
105
- value: item,
106
- certain,
107
- takes: Object.keys(s.properties ?? {})
108
- });
107
+ issues.push({ pointer: where, kind: 'unknown_key', message: 'is not a key it takes', value: item, certain });
109
108
  }
110
109
  else if (s.additionalProperties !== undefined) {
111
110
  issues.push(...validate(s.additionalProperties, item, where, certain));
package/dist/spec.d.ts CHANGED
@@ -38,6 +38,8 @@ export interface Schema {
38
38
  readonly else?: Schema | boolean;
39
39
  readonly minimum?: number;
40
40
  readonly maximum?: number;
41
+ readonly exclusiveMinimum?: number;
42
+ readonly exclusiveMaximum?: number;
41
43
  readonly minLength?: number;
42
44
  readonly maxLength?: number;
43
45
  readonly minItems?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinshuju/cli",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Command line interface for Jinshuju Open API v1",
5
5
  "homepage": "https://github.com/jinshuju/cli#readme",
6
6
  "bugs": {