@noldova/context.json 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/api/index.d.ts +430 -0
- package/api/index.js +10 -0
- package/api/index.js.map +1 -0
- package/exceptions/json.exception.js +17 -0
- package/exceptions/json.exception.js.map +1 -0
- package/package.json +23 -4
- package/resources.js +40 -0
- package/resources.js.map +1 -0
- package/services/json.reader.js +192 -0
- package/services/json.reader.js.map +1 -0
- package/types/json-object.js +9 -0
- package/types/json-object.js.map +1 -0
- package/types/json-value.js +9 -0
- package/types/json-value.js.map +1 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Exception, type ExceptionOptions } from "@noldova/context.exceptions";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A value JSON can carry.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* `undefined` is never a JSON value. In JSON an absent key means missing and `null` means
|
|
16
|
+
* explicitly nothing; `JsonReader` keeps that distinction.
|
|
17
|
+
*/
|
|
18
|
+
export declare type JsonValue = string | number | boolean | null | readonly JsonValue[] | JsonObject;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A JSON object: string keys with JSON values.
|
|
22
|
+
*/
|
|
23
|
+
export declare type JsonObject = { readonly [key: string]: JsonValue };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Raised when text or a value received at a boundary is not the JSON its reader expects.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Every failure of `JsonReader` is a `JsonException`, and so is a failure of a model's own
|
|
30
|
+
* `fromJson` that reads through it. The message is the path, `: `, and the text, so it can be
|
|
31
|
+
* shown to a user as is.
|
|
32
|
+
*/
|
|
33
|
+
export declare class JsonException extends Exception {
|
|
34
|
+
/**
|
|
35
|
+
* Path of the offending field, such as `$.params.name`, or the root path `$` when the whole
|
|
36
|
+
* value is at fault.
|
|
37
|
+
*/
|
|
38
|
+
public readonly path: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Initializes the exception. The message becomes the path, `: `, and the text.
|
|
42
|
+
*
|
|
43
|
+
* @param text What is wrong, as a sentence without the path, normally a `Resources` message.
|
|
44
|
+
* @param path Path of the offending field, or the root path.
|
|
45
|
+
* @param options Optional options carrying the cause, such as the `SyntaxError` of a failed
|
|
46
|
+
* parse.
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { JsonException } from "@noldova/context.json";
|
|
50
|
+
*
|
|
51
|
+
* export function requirePort(port: number): number {
|
|
52
|
+
* if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
53
|
+
* throw new JsonException("Expected a port number.", "$.port");
|
|
54
|
+
* return port;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
public constructor(text: string, path: string, options?: ExceptionOptions);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Reads typed fields from untrusted JSON, so that unknown input is narrowed in one place, such
|
|
63
|
+
* as a model's `fromJson`.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
* A required field must be present and not `null`. An `optional` accessor returns `undefined`
|
|
67
|
+
* for an absent field and still rejects `null`. A `nullable` accessor requires the field and
|
|
68
|
+
* accepts `null`. Unknown fields are ignored, so a reader accepts JSON that a newer writer
|
|
69
|
+
* extended.
|
|
70
|
+
* Every failure is a `JsonException` whose path names the field.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
75
|
+
*
|
|
76
|
+
* export function readMessage(line: string): string {
|
|
77
|
+
* const reader = JsonReader.parse(line);
|
|
78
|
+
* const detail = reader.readOptionalString("detail");
|
|
79
|
+
* return `${reader.readNonBlankString("id")}: ${detail ?? "no detail"}`;
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare class JsonReader {
|
|
84
|
+
/**
|
|
85
|
+
* The deepest nesting of arrays and objects a reader accepts, counting the outermost as 1;
|
|
86
|
+
* deeper JSON is refused with a `JsonException` rather than read recursively.
|
|
87
|
+
*/
|
|
88
|
+
public static readonly maximumDepth: number;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Path of the object this reader reads, such as `$` or `$.params.version`; field paths are
|
|
92
|
+
* built beneath it.
|
|
93
|
+
*/
|
|
94
|
+
public readonly path: string;
|
|
95
|
+
|
|
96
|
+
private constructor();
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Parses text as JSON and returns a reader over the resulting object.
|
|
100
|
+
*
|
|
101
|
+
* @param text The JSON text, such as one line received from another process.
|
|
102
|
+
* @param path Path to report for the parsed value; the root path `$` by default.
|
|
103
|
+
* @returns A reader over the parsed object.
|
|
104
|
+
* @throws JsonException synchronously when the text is not valid JSON (the `SyntaxError` is the cause),
|
|
105
|
+
* the parsed value is not an object, or it nests deeper than `maximumDepth`.
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
109
|
+
*
|
|
110
|
+
* export const reader: JsonReader = JsonReader.parse("{\"name\":\"Fixture\"}");
|
|
111
|
+
* ```
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { JsonException, JsonReader } from "@noldova/context.json";
|
|
115
|
+
*
|
|
116
|
+
* try {
|
|
117
|
+
* JsonReader.parse("[1, 2]");
|
|
118
|
+
* }
|
|
119
|
+
* catch (error) {
|
|
120
|
+
* if (!(error instanceof JsonException))
|
|
121
|
+
* throw error;
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
public static parse(text: string, path?: string): JsonReader;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Returns a reader over an untrusted value that must be a JSON object.
|
|
129
|
+
*
|
|
130
|
+
* @param value The untrusted value, such as a structured-clone payload.
|
|
131
|
+
* @param path Path to report for the value; the root path `$` by default.
|
|
132
|
+
* @returns A reader over the narrowed object.
|
|
133
|
+
* @throws JsonException synchronously when the value is not a JSON object or contains anything JSON
|
|
134
|
+
* cannot carry, as `toJsonValue` says.
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
138
|
+
*
|
|
139
|
+
* export function readName(message: unknown): string {
|
|
140
|
+
* return JsonReader.fromValue(message, "$.params").readString("name");
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
public static fromValue(value: unknown, path?: string): JsonReader;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Narrows an untrusted value to JSON, preserving keys such as `__proto__` as data.
|
|
148
|
+
*
|
|
149
|
+
* @param value The untrusted value; repeated references are allowed unless they form a cycle.
|
|
150
|
+
* @param path Path to report for the value; the root path `$` by default.
|
|
151
|
+
* @returns The value as JSON; object members whose value is `undefined` are dropped.
|
|
152
|
+
* @throws JsonException synchronously for `undefined`, functions, symbols, bigints, non-finite
|
|
153
|
+
* numbers, objects other than arrays and plain objects (whose prototype is `Object.prototype` or
|
|
154
|
+
* `null`), arrays with missing items, circular references, and nesting deeper than
|
|
155
|
+
* `maximumDepth`, at the path of the offending member.
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { JsonReader, type JsonValue } from "@noldova/context.json";
|
|
159
|
+
*
|
|
160
|
+
* export const value: JsonValue = JsonReader.toJsonValue({ name: "Fixture", nickname: undefined });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
public static toJsonValue(value: unknown, path?: string): JsonValue;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Returns the narrowed object this reader reads from.
|
|
167
|
+
*
|
|
168
|
+
* @returns The object, as JSON.
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
172
|
+
*
|
|
173
|
+
* const reader: JsonReader = JsonReader.parse("{\"name\":\"Fixture\"}");
|
|
174
|
+
* export const copy: string = JSON.stringify(reader.toJson());
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
public toJson(): JsonObject;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Reports whether a field is present, with any value including `null`.
|
|
181
|
+
*
|
|
182
|
+
* @param name The field's name.
|
|
183
|
+
* @returns `true` when the field exists.
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
187
|
+
*
|
|
188
|
+
* const reader: JsonReader = JsonReader.parse("{\"name\":\"Fixture\"}");
|
|
189
|
+
* export const hasEmail: boolean = reader.hasField("email");
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
public hasField(name: string): boolean;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Reads a required string field.
|
|
196
|
+
*
|
|
197
|
+
* @param name The field's name.
|
|
198
|
+
* @returns The string, possibly empty.
|
|
199
|
+
* @throws JsonException synchronously when the field is absent, `null`, or not a string.
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
203
|
+
*
|
|
204
|
+
* const reader: JsonReader = JsonReader.parse("{\"name\":\"Fixture\"}");
|
|
205
|
+
* export const name: string = reader.readString("name");
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
public readString(name: string): string;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Reads a required string field that must not be blank.
|
|
212
|
+
*
|
|
213
|
+
* @param name The field's name.
|
|
214
|
+
* @returns The string, which is not blank.
|
|
215
|
+
* @throws JsonException synchronously when the field is absent, `null`, not a string, or empty or whitespace.
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
219
|
+
*
|
|
220
|
+
* const reader: JsonReader = JsonReader.parse("{\"id\":\"a1\"}");
|
|
221
|
+
* export const id: string = reader.readNonBlankString("id");
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
public readNonBlankString(name: string): string;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Reads an optional string field.
|
|
228
|
+
*
|
|
229
|
+
* @param name The field's name.
|
|
230
|
+
* @returns The string, or `undefined` when the field is absent.
|
|
231
|
+
* @throws JsonException synchronously when the field is present but `null` or not a string.
|
|
232
|
+
* @example
|
|
233
|
+
* ```ts
|
|
234
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
235
|
+
*
|
|
236
|
+
* const reader: JsonReader = JsonReader.parse("{\"name\":\"Fixture\"}");
|
|
237
|
+
* export const nickname: string | undefined = reader.readOptionalString("nickname");
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
public readOptionalString(name: string): string | undefined;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Reads a required string field that may be explicitly `null`.
|
|
244
|
+
*
|
|
245
|
+
* @param name The field's name.
|
|
246
|
+
* @returns The string, or `null` when the field is `null`.
|
|
247
|
+
* @throws JsonException synchronously when the field is absent or neither a string nor `null`.
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
251
|
+
*
|
|
252
|
+
* const reader: JsonReader = JsonReader.parse("{\"parentId\":null}");
|
|
253
|
+
* export const parentId: string | null = reader.readNullableString("parentId");
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
public readNullableString(name: string): string | null;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Reads a required number field.
|
|
260
|
+
*
|
|
261
|
+
* @param name The field's name.
|
|
262
|
+
* @returns The number, always finite.
|
|
263
|
+
* @throws JsonException synchronously when the field is absent, `null`, or not a number.
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
267
|
+
*
|
|
268
|
+
* const reader: JsonReader = JsonReader.parse("{\"ratio\":0.5}");
|
|
269
|
+
* export const ratio: number = reader.readNumber("ratio");
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
public readNumber(name: string): number;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Reads a required integer field.
|
|
276
|
+
*
|
|
277
|
+
* @param name The field's name.
|
|
278
|
+
* @returns The integer.
|
|
279
|
+
* @throws JsonException synchronously when the field is absent, `null`, not a number, or not an integer.
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
283
|
+
*
|
|
284
|
+
* const reader: JsonReader = JsonReader.parse("{\"count\":3}");
|
|
285
|
+
* export const count: number = reader.readInteger("count");
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
public readInteger(name: string): number;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Reads a required field that is an integer or `null`.
|
|
292
|
+
*
|
|
293
|
+
* @param name The field's name.
|
|
294
|
+
* @returns The integer, or `null` when the field is `null`.
|
|
295
|
+
* @throws JsonException synchronously when the field is absent or not an integer.
|
|
296
|
+
* @example
|
|
297
|
+
* ```ts
|
|
298
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
299
|
+
*
|
|
300
|
+
* const reader: JsonReader = JsonReader.parse("{\"exitCode\":null}");
|
|
301
|
+
* export const exitCode: number | null = reader.readNullableInteger("exitCode");
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
public readNullableInteger(name: string): number | null;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Reads a required array of strings.
|
|
308
|
+
*
|
|
309
|
+
* @param name The field's name.
|
|
310
|
+
* @returns The strings, in order; empty for an empty array.
|
|
311
|
+
* @throws JsonException synchronously when the field is absent, `null`, or not an array, or when an item is
|
|
312
|
+
* not a string; the path names the item.
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
316
|
+
*
|
|
317
|
+
* const reader: JsonReader = JsonReader.parse("{\"tags\":[\"a\",\"b\"]}");
|
|
318
|
+
* export const tags: readonly string[] = reader.readStringArray("tags");
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
public readStringArray(name: string): readonly string[];
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Reads a required array of objects as nested readers.
|
|
325
|
+
*
|
|
326
|
+
* @param name The field's name.
|
|
327
|
+
* @returns One reader per item, in order, each with the item's path such as `$.options.1`; empty
|
|
328
|
+
* for an empty array.
|
|
329
|
+
* @throws JsonException synchronously when the field is absent, `null`, or not an array, or when an item is
|
|
330
|
+
* not an object; the path names the item.
|
|
331
|
+
* @example
|
|
332
|
+
* ```ts
|
|
333
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
334
|
+
*
|
|
335
|
+
* const reader: JsonReader = JsonReader.parse("{\"items\":[{\"id\":\"a\"},{\"id\":\"b\"}]}");
|
|
336
|
+
* export const ids: readonly string[] = reader.readObjectArray("items").map(t => t.readString("id"));
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
public readObjectArray(name: string): readonly JsonReader[];
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Reads a required field that is an object or `null`.
|
|
343
|
+
*
|
|
344
|
+
* @param name The field's name.
|
|
345
|
+
* @returns A reader over the nested object, or `null` when the field is `null`.
|
|
346
|
+
* @throws JsonException synchronously when the field is absent or neither an object nor `null`.
|
|
347
|
+
* @example
|
|
348
|
+
* ```ts
|
|
349
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
350
|
+
*
|
|
351
|
+
* const reader: JsonReader = JsonReader.parse("{\"error\":null}");
|
|
352
|
+
* export const error: JsonReader | null = reader.readNullableObject("error");
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
public readNullableObject(name: string): JsonReader | null;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Reads a required boolean field.
|
|
359
|
+
*
|
|
360
|
+
* @param name The field's name.
|
|
361
|
+
* @returns The boolean.
|
|
362
|
+
* @throws JsonException synchronously when the field is absent, `null`, or not a boolean.
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
366
|
+
*
|
|
367
|
+
* const reader: JsonReader = JsonReader.parse("{\"enabled\":true}");
|
|
368
|
+
* export const enabled: boolean = reader.readBoolean("enabled");
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
public readBoolean(name: string): boolean;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Reads a required object field as a nested reader.
|
|
375
|
+
*
|
|
376
|
+
* @param name The field's name.
|
|
377
|
+
* @returns A reader over the nested object whose path is this reader's path plus the name.
|
|
378
|
+
* @throws JsonException synchronously when the field is absent, `null`, or not an object.
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts
|
|
381
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
382
|
+
*
|
|
383
|
+
* const reader: JsonReader = JsonReader.parse("{\"params\":{\"taskId\":\"t1\"}}");
|
|
384
|
+
* export const taskId: string = reader.readObject("params").readString("taskId");
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
public readObject(name: string): JsonReader;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Reads a required string field that must be one of a set of values, such as an enum's values.
|
|
391
|
+
*
|
|
392
|
+
* @param name The field's name.
|
|
393
|
+
* @param values The accepted values.
|
|
394
|
+
* @returns The matching value, typed as one of `values`.
|
|
395
|
+
* @throws JsonException synchronously when the field is absent, `null`, not a string, or not among the
|
|
396
|
+
* values.
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
400
|
+
*
|
|
401
|
+
* const reader: JsonReader = JsonReader.parse("{\"mode\":\"dark\"}");
|
|
402
|
+
* export const mode: "light" | "dark" = reader.readOneOf("mode", ["light", "dark"]);
|
|
403
|
+
* ```
|
|
404
|
+
* @example
|
|
405
|
+
* ```ts
|
|
406
|
+
* import { JsonReader } from "@noldova/context.json";
|
|
407
|
+
*
|
|
408
|
+
* const reader: JsonReader = JsonReader.parse("{\"mode\":\"dark\"}");
|
|
409
|
+
* // @ts-expect-error
|
|
410
|
+
* export const mode: "light" = reader.readOneOf("mode", ["light", "dark"]);
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
public readOneOf<T extends string>(name: string, values: readonly T[]): T;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Reads a required field of any JSON type.
|
|
417
|
+
*
|
|
418
|
+
* @param name The field's name.
|
|
419
|
+
* @returns The field's value, including `null` when the field is `null`.
|
|
420
|
+
* @throws JsonException synchronously when the field is absent.
|
|
421
|
+
* @example
|
|
422
|
+
* ```ts
|
|
423
|
+
* import { JsonReader, type JsonValue } from "@noldova/context.json";
|
|
424
|
+
*
|
|
425
|
+
* const reader: JsonReader = JsonReader.parse("{\"data\":[1,null]}");
|
|
426
|
+
* export const data: JsonValue = reader.readValue("data");
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
public readValue(name: string): JsonValue;
|
|
430
|
+
}
|
package/api/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { JsonException } from "../exceptions/json.exception.js";
|
|
9
|
+
export { JsonReader } from "../services/json.reader.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.context.json/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { Exception } from "@noldova/context.exceptions";
|
|
9
|
+
import { Resources } from "../resources.js";
|
|
10
|
+
export class JsonException extends Exception {
|
|
11
|
+
path;
|
|
12
|
+
constructor(text, path, options) {
|
|
13
|
+
super(`${path}${Resources.pathMessageSeparator}${text}`, options);
|
|
14
|
+
this.path = path;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=json.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.exception.js","sourceRoot":"","sources":["../../../../src/noldova.context.json/src/exceptions/json.exception.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1B,IAAI,CAAS;IAE7B,YAAmB,IAAY,EAAE,IAAY,EAAE,OAA0B;QACvE,KAAK,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,oBAAoB,GAAG,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAElE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/context.json",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "api/index.js",
|
|
6
|
+
"types": "api/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/noldova-com/context.git",
|
|
11
|
+
"directory": "src/noldova.context.json"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/noldova-com/context#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/noldova-com/context/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@noldova/context.core": "0.0.1",
|
|
23
|
+
"@noldova/context.exceptions": "0.0.1"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/resources.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class Resources {
|
|
9
|
+
static arrayHole = "An array with a missing item cannot be carried as JSON.";
|
|
10
|
+
static arrayTypeName = "an array";
|
|
11
|
+
static blankString = "Expected a string that is not blank.";
|
|
12
|
+
static booleanTypeName = "a boolean";
|
|
13
|
+
static circularReference = "Circular references cannot be carried as JSON.";
|
|
14
|
+
static invalidJsonText = "The text is not valid JSON.";
|
|
15
|
+
static listSeparator = ", ";
|
|
16
|
+
static missingField = "The field is required.";
|
|
17
|
+
static notInteger = "Expected an integer.";
|
|
18
|
+
static notObject = "Expected a JSON object.";
|
|
19
|
+
static notPlainObject = "Only arrays and plain objects can be carried as JSON.";
|
|
20
|
+
static numberTypeName = "a number";
|
|
21
|
+
static objectTypeName = "an object";
|
|
22
|
+
static pathMessageSeparator = ": ";
|
|
23
|
+
static pathSeparator = ".";
|
|
24
|
+
static rootPath = "$";
|
|
25
|
+
static stringTypeName = "a string";
|
|
26
|
+
static unexpectedNull = "Null is not an accepted value here.";
|
|
27
|
+
static formatNotJsonValue(kind) {
|
|
28
|
+
return `A value of type "${kind}" cannot be carried as JSON.`;
|
|
29
|
+
}
|
|
30
|
+
static formatNotOneOf(values) {
|
|
31
|
+
return `Expected one of ${values.join(Resources.listSeparator)}.`;
|
|
32
|
+
}
|
|
33
|
+
static formatTooDeep(maximumDepth) {
|
|
34
|
+
return `JSON nested more than ${maximumDepth} levels deep is not accepted.`;
|
|
35
|
+
}
|
|
36
|
+
static formatWrongType(expected) {
|
|
37
|
+
return `Expected ${expected}.`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=resources.js.map
|
package/resources.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/noldova.context.json/src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,SAAS;IACb,MAAM,CAAU,SAAS,GAAW,yDAAyD,CAAC;IAC9F,MAAM,CAAU,aAAa,GAAW,UAAU,CAAC;IACnD,MAAM,CAAU,WAAW,GAAW,sCAAsC,CAAC;IAC7E,MAAM,CAAU,eAAe,GAAW,WAAW,CAAC;IACtD,MAAM,CAAU,iBAAiB,GAAW,gDAAgD,CAAC;IAC7F,MAAM,CAAU,eAAe,GAAW,6BAA6B,CAAC;IACxE,MAAM,CAAU,aAAa,GAAW,IAAI,CAAC;IAC7C,MAAM,CAAU,YAAY,GAAW,wBAAwB,CAAC;IAChE,MAAM,CAAU,UAAU,GAAW,sBAAsB,CAAC;IAC5D,MAAM,CAAU,SAAS,GAAW,yBAAyB,CAAC;IAC9D,MAAM,CAAU,cAAc,GAAW,uDAAuD,CAAC;IACjG,MAAM,CAAU,cAAc,GAAW,UAAU,CAAC;IACpD,MAAM,CAAU,cAAc,GAAW,WAAW,CAAC;IACrD,MAAM,CAAU,oBAAoB,GAAW,IAAI,CAAC;IACpD,MAAM,CAAU,aAAa,GAAW,GAAG,CAAC;IAC5C,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IACvC,MAAM,CAAU,cAAc,GAAW,UAAU,CAAC;IACpD,MAAM,CAAU,cAAc,GAAW,qCAAqC,CAAC;IAE/E,MAAM,CAAC,kBAAkB,CAAC,IAAY;QAC3C,OAAO,oBAAoB,IAAI,8BAA8B,CAAC;IAChE,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,MAAyB;QACpD,OAAO,mBAAmB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC;IACpE,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,YAAoB;QAC9C,OAAO,yBAAyB,YAAY,+BAA+B,CAAC;IAC9E,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,QAAgB;QAC5C,OAAO,YAAY,QAAQ,GAAG,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import "@noldova/context.core";
|
|
9
|
+
import { ExceptionOptions } from "@noldova/context.exceptions";
|
|
10
|
+
import { JsonException } from "../exceptions/json.exception.js";
|
|
11
|
+
import { Resources } from "../resources.js";
|
|
12
|
+
export class JsonReader {
|
|
13
|
+
static maximumDepth = 64;
|
|
14
|
+
value;
|
|
15
|
+
path;
|
|
16
|
+
constructor(value, path) {
|
|
17
|
+
this.value = value;
|
|
18
|
+
this.path = path;
|
|
19
|
+
}
|
|
20
|
+
static parse(text, path = Resources.rootPath) {
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(text);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new JsonException(Resources.invalidJsonText, path, new ExceptionOptions(error));
|
|
27
|
+
}
|
|
28
|
+
return JsonReader.fromValue(parsed, path);
|
|
29
|
+
}
|
|
30
|
+
static fromValue(value, path = Resources.rootPath) {
|
|
31
|
+
const json = JsonReader.toJsonValue(value, path);
|
|
32
|
+
if (!JsonReader.isObject(json))
|
|
33
|
+
throw new JsonException(Resources.notObject, path);
|
|
34
|
+
return new JsonReader(json, path);
|
|
35
|
+
}
|
|
36
|
+
static toJsonValue(value, path = Resources.rootPath) {
|
|
37
|
+
return JsonReader.convertToJsonValue(value, path, new Set());
|
|
38
|
+
}
|
|
39
|
+
toJson() {
|
|
40
|
+
return this.value;
|
|
41
|
+
}
|
|
42
|
+
hasField(name) {
|
|
43
|
+
return Object.hasOwn(this.value, name);
|
|
44
|
+
}
|
|
45
|
+
readString(name) {
|
|
46
|
+
const field = this.readRequired(name);
|
|
47
|
+
if (!Object.isString(field))
|
|
48
|
+
this.throwWrongTypeException(name, Resources.stringTypeName);
|
|
49
|
+
return field;
|
|
50
|
+
}
|
|
51
|
+
readNonBlankString(name) {
|
|
52
|
+
const text = this.readString(name);
|
|
53
|
+
if (String.isNullOrWhitespace(text))
|
|
54
|
+
throw new JsonException(Resources.blankString, this.formatFieldPath(name));
|
|
55
|
+
return text;
|
|
56
|
+
}
|
|
57
|
+
readOptionalString(name) {
|
|
58
|
+
return this.hasField(name) ? this.readString(name) : undefined;
|
|
59
|
+
}
|
|
60
|
+
readNullableString(name) {
|
|
61
|
+
return Object.isNull(this.readRequiredOrNull(name)) ? null : this.readString(name);
|
|
62
|
+
}
|
|
63
|
+
readNumber(name) {
|
|
64
|
+
const field = this.readRequired(name);
|
|
65
|
+
if (!Object.isNumber(field))
|
|
66
|
+
this.throwWrongTypeException(name, Resources.numberTypeName);
|
|
67
|
+
return field;
|
|
68
|
+
}
|
|
69
|
+
readInteger(name) {
|
|
70
|
+
const value = this.readNumber(name);
|
|
71
|
+
if (!Number.isInteger(value))
|
|
72
|
+
throw new JsonException(Resources.notInteger, this.formatFieldPath(name));
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
readNullableInteger(name) {
|
|
76
|
+
return Object.isNull(this.readRequiredOrNull(name)) ? null : this.readInteger(name);
|
|
77
|
+
}
|
|
78
|
+
readBoolean(name) {
|
|
79
|
+
const field = this.readRequired(name);
|
|
80
|
+
if (!Object.isBoolean(field))
|
|
81
|
+
this.throwWrongTypeException(name, Resources.booleanTypeName);
|
|
82
|
+
return field;
|
|
83
|
+
}
|
|
84
|
+
readObject(name) {
|
|
85
|
+
const field = this.readRequired(name);
|
|
86
|
+
if (!JsonReader.isObject(field))
|
|
87
|
+
this.throwWrongTypeException(name, Resources.objectTypeName);
|
|
88
|
+
return new JsonReader(field, this.formatFieldPath(name));
|
|
89
|
+
}
|
|
90
|
+
readNullableObject(name) {
|
|
91
|
+
return Object.isNull(this.readRequiredOrNull(name)) ? null : this.readObject(name);
|
|
92
|
+
}
|
|
93
|
+
readStringArray(name) {
|
|
94
|
+
const field = this.readRequired(name);
|
|
95
|
+
if (!Array.isArray(field))
|
|
96
|
+
this.throwWrongTypeException(name, Resources.arrayTypeName);
|
|
97
|
+
return field.map((t, index) => {
|
|
98
|
+
if (!Object.isString(t))
|
|
99
|
+
throw new JsonException(Resources.formatWrongType(Resources.stringTypeName), this.formatItemPath(name, index));
|
|
100
|
+
return t;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
readObjectArray(name) {
|
|
104
|
+
const field = this.readRequired(name);
|
|
105
|
+
if (!Array.isArray(field))
|
|
106
|
+
this.throwWrongTypeException(name, Resources.arrayTypeName);
|
|
107
|
+
return field.map((t, index) => {
|
|
108
|
+
const path = this.formatItemPath(name, index);
|
|
109
|
+
if (!JsonReader.isObject(t))
|
|
110
|
+
throw new JsonException(Resources.formatWrongType(Resources.objectTypeName), path);
|
|
111
|
+
return new JsonReader(t, path);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
readOneOf(name, values) {
|
|
115
|
+
const text = this.readString(name);
|
|
116
|
+
const match = values.find(t => t === text);
|
|
117
|
+
if (Object.isUndefined(match))
|
|
118
|
+
throw new JsonException(Resources.formatNotOneOf(values), this.formatFieldPath(name));
|
|
119
|
+
return match;
|
|
120
|
+
}
|
|
121
|
+
readValue(name) {
|
|
122
|
+
return this.readRequiredOrNull(name);
|
|
123
|
+
}
|
|
124
|
+
readRequired(name) {
|
|
125
|
+
const field = this.readRequiredOrNull(name);
|
|
126
|
+
if (Object.isNull(field))
|
|
127
|
+
throw new JsonException(Resources.unexpectedNull, this.formatFieldPath(name));
|
|
128
|
+
return field;
|
|
129
|
+
}
|
|
130
|
+
readRequiredOrNull(name) {
|
|
131
|
+
if (!this.hasField(name))
|
|
132
|
+
throw new JsonException(Resources.missingField, this.formatFieldPath(name));
|
|
133
|
+
return this.value[name];
|
|
134
|
+
}
|
|
135
|
+
throwWrongTypeException(name, expected) {
|
|
136
|
+
throw new JsonException(Resources.formatWrongType(expected), this.formatFieldPath(name));
|
|
137
|
+
}
|
|
138
|
+
formatFieldPath(name) {
|
|
139
|
+
return JsonReader.formatChildPath(this.path, name);
|
|
140
|
+
}
|
|
141
|
+
formatItemPath(name, index) {
|
|
142
|
+
return JsonReader.formatChildPath(this.formatFieldPath(name), String(index));
|
|
143
|
+
}
|
|
144
|
+
static convertToJsonValue(value, path, ancestors) {
|
|
145
|
+
if (Object.isNull(value) || Object.isString(value) || Object.isBoolean(value))
|
|
146
|
+
return value;
|
|
147
|
+
if (Object.isNumber(value)) {
|
|
148
|
+
if (!Number.isFinite(value))
|
|
149
|
+
throw new JsonException(Resources.formatNotJsonValue(String(value)), path);
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
if (Array.isArray(value) || JsonReader.isPlainObject(value)) {
|
|
153
|
+
if (ancestors.has(value))
|
|
154
|
+
throw new JsonException(Resources.circularReference, path);
|
|
155
|
+
if (ancestors.size === JsonReader.maximumDepth)
|
|
156
|
+
throw new JsonException(Resources.formatTooDeep(JsonReader.maximumDepth), path);
|
|
157
|
+
ancestors.add(value);
|
|
158
|
+
const result = Array.isArray(value) ? JsonReader.convertArray(value, path, ancestors) : JsonReader.convertObject(value, path, ancestors);
|
|
159
|
+
ancestors.delete(value);
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
if (Object.isObject(value) && !Object.isFunction(value))
|
|
163
|
+
throw new JsonException(Resources.notPlainObject, path);
|
|
164
|
+
throw new JsonException(Resources.formatNotJsonValue(typeof value), path);
|
|
165
|
+
}
|
|
166
|
+
static convertArray(value, path, ancestors) {
|
|
167
|
+
return Array.from({ length: value.length }, (_, index) => {
|
|
168
|
+
const itemPath = JsonReader.formatChildPath(path, String(index));
|
|
169
|
+
if (!Object.hasOwn(value, index))
|
|
170
|
+
throw new JsonException(Resources.arrayHole, itemPath);
|
|
171
|
+
return JsonReader.convertToJsonValue(value[index], itemPath, ancestors);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
static convertObject(value, path, ancestors) {
|
|
175
|
+
return Object.fromEntries(Object.entries(value)
|
|
176
|
+
.filter(([, member]) => !Object.isUndefined(member))
|
|
177
|
+
.map(([key, member]) => [key, JsonReader.convertToJsonValue(member, JsonReader.formatChildPath(path, key), ancestors)]));
|
|
178
|
+
}
|
|
179
|
+
static formatChildPath(parent, child) {
|
|
180
|
+
return `${parent}${Resources.pathSeparator}${child}`;
|
|
181
|
+
}
|
|
182
|
+
static isPlainObject(value) {
|
|
183
|
+
if (!Object.isObject(value) || Object.isFunction(value))
|
|
184
|
+
return false;
|
|
185
|
+
const prototype = Object.getPrototypeOf(value);
|
|
186
|
+
return prototype === Object.prototype || Object.isNull(prototype);
|
|
187
|
+
}
|
|
188
|
+
static isObject(value) {
|
|
189
|
+
return Object.isObject(value) && !Array.isArray(value);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=json.reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.reader.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,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-object.js","sourceRoot":"","sources":["../../../../src/noldova.context.json/src/types/json-object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-value.js","sourceRoot":"","sources":["../../../../src/noldova.context.json/src/types/json-value.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/README.md
DELETED