unikvs 0.0.9 → 0.0.12
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 +3 -0
- package/dist/src/_logger.d.ts.map +1 -1
- package/dist/src/_merge-variables.d.ts +13 -0
- package/dist/src/_merge-variables.d.ts.map +1 -0
- package/dist/src/_merge-variables.js +12 -0
- package/dist/src/_storage.d.ts +11 -11
- package/dist/src/_storage.d.ts.map +1 -1
- package/dist/src/_storage.js +31 -22
- package/dist/src/_streams.d.ts +20 -0
- package/dist/src/_streams.d.ts.map +1 -0
- package/dist/src/_streams.js +36 -0
- package/dist/src/_to-value-stream.d.ts.map +1 -1
- package/dist/src/_to-value-stream.js +44 -6
- package/dist/src/_transformer.d.ts +7 -7
- package/dist/src/_transformer.d.ts.map +1 -1
- package/dist/src/_transformer.js +12 -12
- package/dist/src/_valibot.d.ts +6 -7
- package/dist/src/_valibot.d.ts.map +1 -1
- package/dist/src/_valibot.js +1 -1
- package/dist/src/_value-schemas.d.ts +179 -0
- package/dist/src/_value-schemas.d.ts.map +1 -0
- package/dist/src/_value-schemas.js +150 -0
- package/dist/src/errors.d.ts +218 -27
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +102 -47
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/unikvs-config.d.ts +58 -139
- package/dist/src/unikvs-config.d.ts.map +1 -1
- package/dist/src/unikvs-config.js +41 -46
- package/dist/src/unikvs.d.ts +86 -161
- package/dist/src/unikvs.d.ts.map +1 -1
- package/dist/src/unikvs.js +374 -171
- package/dist/src/utils.types.d.ts +1 -3
- package/dist/src/utils.types.d.ts.map +1 -1
- package/dist/src/value-stream.types.d.ts +5 -6
- package/dist/src/value-stream.types.d.ts.map +1 -1
- package/dist/src/variables.types.d.ts +11 -0
- package/dist/src/variables.types.d.ts.map +1 -0
- package/package.json +26 -25
- package/src/_merge-variables.ts +19 -0
- package/src/_storage.ts +47 -24
- package/src/_streams.ts +47 -0
- package/src/_to-value-stream.ts +47 -8
- package/src/_transformer.ts +13 -13
- package/src/_valibot.ts +8 -6
- package/src/_value-schemas.ts +362 -0
- package/src/errors.ts +280 -68
- package/src/index.ts +2 -3
- package/src/unikvs-config.ts +142 -167
- package/src/unikvs.ts +523 -285
- package/src/utils.types.ts +1 -3
- package/src/value-stream.types.ts +5 -6
- package/src/variables.types.ts +13 -0
- package/dist/src/_merge-context.d.ts +0 -13
- package/dist/src/_merge-context.d.ts.map +0 -1
- package/dist/src/_merge-context.js +0 -12
- package/dist/src/context.types.d.ts +0 -17
- package/dist/src/context.types.d.ts.map +0 -1
- package/src/_merge-context.ts +0 -19
- package/src/context.types.ts +0 -19
- /package/dist/src/{context.types.js → variables.types.js} +0 -0
package/src/errors.ts
CHANGED
|
@@ -13,55 +13,109 @@ import type { BaseIssue } from "valibot";
|
|
|
13
13
|
//
|
|
14
14
|
// -------------------------------------------------------------------------------------------------
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
18
|
+
*/
|
|
16
19
|
export class InvalidUsageErrorBase<
|
|
17
20
|
TMeta extends ErrorMeta | undefined = ErrorMeta | undefined,
|
|
18
21
|
> extends ErrorBase<TMeta> {}
|
|
19
22
|
|
|
20
23
|
// -------------------------------------------------------------------------------------------------
|
|
21
24
|
|
|
25
|
+
/**
|
|
26
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
27
|
+
*/
|
|
22
28
|
export type Issue = BaseIssue<unknown>;
|
|
23
29
|
|
|
30
|
+
/**
|
|
31
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
32
|
+
*/
|
|
24
33
|
export type InvalidInputErrorMeta = {
|
|
34
|
+
/**
|
|
35
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
36
|
+
*/
|
|
25
37
|
readonly input: unknown;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
41
|
+
*/
|
|
26
42
|
readonly issues: readonly [Issue, ...Issue[]];
|
|
27
43
|
};
|
|
28
44
|
|
|
29
|
-
|
|
45
|
+
/**
|
|
46
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
47
|
+
*/
|
|
48
|
+
export type InvalidInputErrorArgs = ErrorOptions & {
|
|
49
|
+
/**
|
|
50
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
51
|
+
*/
|
|
30
52
|
readonly value: unknown;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
56
|
+
*/
|
|
31
57
|
readonly issues: readonly [Issue, ...Issue[]];
|
|
32
58
|
};
|
|
33
59
|
|
|
60
|
+
/**
|
|
61
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
62
|
+
*/
|
|
34
63
|
export class InvalidInputError extends InvalidUsageErrorBase<InvalidInputErrorMeta> {
|
|
35
64
|
static {
|
|
36
65
|
this.prototype.name = "UniKvsInvalidInputError";
|
|
37
66
|
}
|
|
38
67
|
|
|
39
|
-
public constructor(args: InvalidInputErrorArgs
|
|
40
|
-
const { value: input, issues } = args;
|
|
41
|
-
|
|
68
|
+
public constructor(args: InvalidInputErrorArgs) {
|
|
69
|
+
const { value: input, issues, ...options } = args;
|
|
70
|
+
const meta: InvalidInputErrorMeta = { input, issues };
|
|
71
|
+
super(meta, ({ issues }) => issues.map((i) => i.message).join(": "), options);
|
|
42
72
|
}
|
|
43
73
|
}
|
|
44
74
|
|
|
45
75
|
// -------------------------------------------------------------------------------------------------
|
|
46
76
|
|
|
77
|
+
/**
|
|
78
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
79
|
+
*/
|
|
47
80
|
export type InvalidOutputErrorMeta = {
|
|
81
|
+
/**
|
|
82
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
83
|
+
*/
|
|
48
84
|
readonly output: unknown;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
88
|
+
*/
|
|
49
89
|
readonly issues: readonly [Issue, ...Issue[]];
|
|
50
90
|
};
|
|
51
91
|
|
|
52
|
-
|
|
92
|
+
/**
|
|
93
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
94
|
+
*/
|
|
95
|
+
export type InvalidOutputErrorArgs = ErrorOptions & {
|
|
96
|
+
/**
|
|
97
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
98
|
+
*/
|
|
53
99
|
readonly value: unknown;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
103
|
+
*/
|
|
54
104
|
readonly issues: readonly [Issue, ...Issue[]];
|
|
55
105
|
};
|
|
56
106
|
|
|
107
|
+
/**
|
|
108
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
109
|
+
*/
|
|
57
110
|
export class InvalidOutputError extends InvalidUsageErrorBase<InvalidOutputErrorMeta> {
|
|
58
111
|
static {
|
|
59
112
|
this.prototype.name = "UniKvsInvalidOutputError";
|
|
60
113
|
}
|
|
61
114
|
|
|
62
|
-
public constructor(args: InvalidOutputErrorArgs
|
|
63
|
-
const { value: output, issues } = args;
|
|
64
|
-
|
|
115
|
+
public constructor(args: InvalidOutputErrorArgs) {
|
|
116
|
+
const { value: output, issues, ...options } = args;
|
|
117
|
+
const meta: InvalidOutputErrorMeta = { output, issues };
|
|
118
|
+
super(meta, ({ issues }) => issues.map((i) => i.message).join(": "), options);
|
|
65
119
|
}
|
|
66
120
|
}
|
|
67
121
|
|
|
@@ -71,6 +125,9 @@ export class InvalidOutputError extends InvalidUsageErrorBase<InvalidOutputError
|
|
|
71
125
|
//
|
|
72
126
|
// -------------------------------------------------------------------------------------------------
|
|
73
127
|
|
|
128
|
+
/**
|
|
129
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
130
|
+
*/
|
|
74
131
|
export class UniKvsIsOpenError extends ErrorBase<undefined> {
|
|
75
132
|
static {
|
|
76
133
|
this.prototype.name = "UniKvsIsOpenError";
|
|
@@ -83,6 +140,9 @@ export class UniKvsIsOpenError extends ErrorBase<undefined> {
|
|
|
83
140
|
|
|
84
141
|
setErrorMessage(UniKvsIsOpenError, "UniKvs は開いています", "ja");
|
|
85
142
|
|
|
143
|
+
/**
|
|
144
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
145
|
+
*/
|
|
86
146
|
export class UniKvsIsNotOpenError extends ErrorBase<undefined> {
|
|
87
147
|
static {
|
|
88
148
|
this.prototype.name = "UniKvsIsNotOpenError";
|
|
@@ -95,19 +155,33 @@ export class UniKvsIsNotOpenError extends ErrorBase<undefined> {
|
|
|
95
155
|
|
|
96
156
|
setErrorMessage(UniKvsIsNotOpenError, "UniKvs は開いていません", "ja");
|
|
97
157
|
|
|
158
|
+
/**
|
|
159
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
160
|
+
*/
|
|
98
161
|
export type KeyNotFoundErrorMeta = {
|
|
162
|
+
/**
|
|
163
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
164
|
+
*/
|
|
99
165
|
readonly key: IStorage.Key;
|
|
100
166
|
};
|
|
101
167
|
|
|
102
|
-
|
|
168
|
+
/**
|
|
169
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
170
|
+
*/
|
|
171
|
+
export type KeyNotFoundErrorArgs = ErrorOptions & KeyNotFoundErrorMeta;
|
|
103
172
|
|
|
173
|
+
/**
|
|
174
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
175
|
+
*/
|
|
104
176
|
export class KeyNotFoundError extends ErrorBase<KeyNotFoundErrorMeta> {
|
|
105
177
|
static {
|
|
106
178
|
this.prototype.name = "UniKvsKeyNotFoundError";
|
|
107
179
|
}
|
|
108
180
|
|
|
109
|
-
public constructor(args: KeyNotFoundErrorArgs
|
|
110
|
-
|
|
181
|
+
public constructor(args: KeyNotFoundErrorArgs) {
|
|
182
|
+
const { key, ...options } = args;
|
|
183
|
+
const meta: KeyNotFoundErrorMeta = { key };
|
|
184
|
+
super(meta, ({ key }) => `IStorage.Key ${JSON.stringify(key)} not found`, options);
|
|
111
185
|
}
|
|
112
186
|
}
|
|
113
187
|
|
|
@@ -141,86 +215,147 @@ setErrorMessage(
|
|
|
141
215
|
|
|
142
216
|
// setErrorMessage(StorageIsOpenError, ({ name }) => `ストレージ "${name}" は開いています`, "ja");
|
|
143
217
|
|
|
218
|
+
/**
|
|
219
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
220
|
+
*/
|
|
144
221
|
export type StorageIsNotOpenErrorMeta = {
|
|
222
|
+
/**
|
|
223
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
224
|
+
*/
|
|
145
225
|
readonly name: string;
|
|
146
226
|
};
|
|
147
227
|
|
|
148
|
-
|
|
228
|
+
/**
|
|
229
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
230
|
+
*/
|
|
231
|
+
export type StorageIsNotOpenErrorArgs = ErrorOptions & StorageIsNotOpenErrorMeta;
|
|
149
232
|
|
|
233
|
+
/**
|
|
234
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
235
|
+
*/
|
|
150
236
|
export class StorageIsNotOpenError extends ErrorBase<StorageIsNotOpenErrorMeta> {
|
|
151
237
|
static {
|
|
152
238
|
this.prototype.name = "UniKvsStorageIsNotOpenError";
|
|
153
239
|
}
|
|
154
240
|
|
|
155
|
-
public constructor(args: StorageIsNotOpenErrorArgs
|
|
156
|
-
|
|
241
|
+
public constructor(args: StorageIsNotOpenErrorArgs) {
|
|
242
|
+
const { name, ...options } = args;
|
|
243
|
+
const meta: StorageIsNotOpenErrorMeta = { name };
|
|
244
|
+
super(meta, ({ name }) => `Storage "${name}" is not open`, options);
|
|
157
245
|
}
|
|
158
246
|
}
|
|
159
247
|
|
|
160
248
|
setErrorMessage(StorageIsNotOpenError, ({ name }) => `ストレージ "${name}" は開いていません`, "ja");
|
|
161
249
|
|
|
250
|
+
/**
|
|
251
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
252
|
+
*/
|
|
162
253
|
export type WritableStreamNotSupportedErrorMeta = {
|
|
254
|
+
/**
|
|
255
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
256
|
+
*/
|
|
163
257
|
readonly name: string;
|
|
164
258
|
};
|
|
165
259
|
|
|
166
|
-
|
|
260
|
+
/**
|
|
261
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
262
|
+
*/
|
|
263
|
+
export type WritableStreamNotSupportedErrorArgs = ErrorOptions &
|
|
264
|
+
WritableStreamNotSupportedErrorMeta;
|
|
167
265
|
|
|
266
|
+
/**
|
|
267
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
268
|
+
*/
|
|
168
269
|
export class WritableStreamNotSupportedError extends ErrorBase<WritableStreamNotSupportedErrorMeta> {
|
|
169
270
|
static {
|
|
170
271
|
this.prototype.name = "UniKvsWritableStreamNotSupportedError";
|
|
171
272
|
}
|
|
172
273
|
|
|
173
|
-
public constructor(args: WritableStreamNotSupportedErrorArgs
|
|
174
|
-
|
|
274
|
+
public constructor(args: WritableStreamNotSupportedErrorArgs) {
|
|
275
|
+
const { name, ...options } = args;
|
|
276
|
+
const meta: WritableStreamNotSupportedErrorMeta = { name };
|
|
277
|
+
super(meta, ({ name }) => `Storage "${name}" does not support writable stream`, options);
|
|
175
278
|
}
|
|
176
279
|
}
|
|
177
280
|
|
|
178
281
|
setErrorMessage(
|
|
179
|
-
|
|
282
|
+
WritableStreamNotSupportedError,
|
|
180
283
|
({ name }) => `ストレージ "${name}" は書き込み可能なストリームをサポートしていません`,
|
|
181
284
|
"ja",
|
|
182
285
|
);
|
|
183
286
|
|
|
287
|
+
/**
|
|
288
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
289
|
+
*/
|
|
184
290
|
export type ReadableStreamNotSupportedErrorMeta = {
|
|
291
|
+
/**
|
|
292
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
293
|
+
*/
|
|
185
294
|
readonly name: string;
|
|
186
295
|
};
|
|
187
296
|
|
|
188
|
-
|
|
297
|
+
/**
|
|
298
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
299
|
+
*/
|
|
300
|
+
export type ReadableStreamNotSupportedErrorArgs = ErrorOptions &
|
|
301
|
+
ReadableStreamNotSupportedErrorMeta;
|
|
189
302
|
|
|
303
|
+
/**
|
|
304
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
305
|
+
*/
|
|
190
306
|
export class ReadableStreamNotSupportedError extends ErrorBase<ReadableStreamNotSupportedErrorMeta> {
|
|
191
307
|
static {
|
|
192
308
|
this.prototype.name = "UniKvsReadableStreamNotSupportedError";
|
|
193
309
|
}
|
|
194
310
|
|
|
195
|
-
public constructor(args: ReadableStreamNotSupportedErrorArgs
|
|
196
|
-
|
|
311
|
+
public constructor(args: ReadableStreamNotSupportedErrorArgs) {
|
|
312
|
+
const { name, ...options } = args;
|
|
313
|
+
const meta: ReadableStreamNotSupportedErrorMeta = { name };
|
|
314
|
+
super(meta, ({ name }) => `Storage "${name}" does not support readable stream`, options);
|
|
197
315
|
}
|
|
198
316
|
}
|
|
199
317
|
|
|
200
318
|
setErrorMessage(
|
|
201
|
-
|
|
319
|
+
ReadableStreamNotSupportedError,
|
|
202
320
|
({ name }) => `ストレージ "${name}" は読み取り可能なストリームをサポートしていません`,
|
|
203
321
|
"ja",
|
|
204
322
|
);
|
|
205
323
|
|
|
324
|
+
/**
|
|
325
|
+
* MultipartWriteNotSupportedError に付与されるメタデータです。
|
|
326
|
+
*/
|
|
206
327
|
export type MultipartWriteNotSupportedErrorMeta = {
|
|
328
|
+
/**
|
|
329
|
+
* 対象のストレージの名前です。
|
|
330
|
+
*/
|
|
207
331
|
readonly name: string;
|
|
208
332
|
};
|
|
209
333
|
|
|
210
|
-
|
|
211
|
-
|
|
334
|
+
/**
|
|
335
|
+
* MultipartWriteNotSupportedError のコンストラクター引数です。
|
|
336
|
+
*
|
|
337
|
+
* エラーの追加情報 (`cause`) も含みます。
|
|
338
|
+
*/
|
|
339
|
+
export type MultipartWriteNotSupportedErrorArgs = ErrorOptions &
|
|
340
|
+
MultipartWriteNotSupportedErrorMeta;
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* ストレージがマルチパート書き込みをサポートしていない場合に投げられるエラーです。
|
|
344
|
+
*/
|
|
212
345
|
export class MultipartWriteNotSupportedError extends ErrorBase<MultipartWriteNotSupportedErrorMeta> {
|
|
213
346
|
static {
|
|
214
347
|
this.prototype.name = "UniKvsMultipartWriteNotSupportedError";
|
|
215
348
|
}
|
|
216
349
|
|
|
217
|
-
public constructor(args: MultipartWriteNotSupportedErrorArgs
|
|
218
|
-
|
|
350
|
+
public constructor(args: MultipartWriteNotSupportedErrorArgs) {
|
|
351
|
+
const { name, ...options } = args;
|
|
352
|
+
const meta: MultipartWriteNotSupportedErrorMeta = { name };
|
|
353
|
+
super(meta, ({ name }) => `Storage "${name}" does not support multipart-write`, options);
|
|
219
354
|
}
|
|
220
355
|
}
|
|
221
356
|
|
|
222
357
|
setErrorMessage(
|
|
223
|
-
|
|
358
|
+
MultipartWriteNotSupportedError,
|
|
224
359
|
({ name }) => `ストレージ "${name}" はマルチパート書き込みをサポートしていません`,
|
|
225
360
|
"ja",
|
|
226
361
|
);
|
|
@@ -249,19 +384,33 @@ setErrorMessage(
|
|
|
249
384
|
|
|
250
385
|
// setErrorMessage(TransformerIsOpenError, ({ name }) => `トランスフォーマー "${name}" は開いています`, "ja");
|
|
251
386
|
|
|
387
|
+
/**
|
|
388
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
389
|
+
*/
|
|
252
390
|
export type TransformerIsNotOpenErrorMeta = {
|
|
391
|
+
/**
|
|
392
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
393
|
+
*/
|
|
253
394
|
readonly name: string;
|
|
254
395
|
};
|
|
255
396
|
|
|
256
|
-
|
|
397
|
+
/**
|
|
398
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
399
|
+
*/
|
|
400
|
+
export type TransformerIsNotOpenErrorArgs = ErrorOptions & TransformerIsNotOpenErrorMeta;
|
|
257
401
|
|
|
402
|
+
/**
|
|
403
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
404
|
+
*/
|
|
258
405
|
export class TransformerIsNotOpenError extends ErrorBase<TransformerIsNotOpenErrorMeta> {
|
|
259
406
|
static {
|
|
260
407
|
this.prototype.name = "UniKvsTransformerIsNotOpenError";
|
|
261
408
|
}
|
|
262
409
|
|
|
263
|
-
public constructor(args: TransformerIsNotOpenErrorArgs
|
|
264
|
-
|
|
410
|
+
public constructor(args: TransformerIsNotOpenErrorArgs) {
|
|
411
|
+
const { name, ...options } = args;
|
|
412
|
+
const meta: TransformerIsNotOpenErrorMeta = { name };
|
|
413
|
+
super(meta, ({ name }) => `Transformer "${name}" is not open`, options);
|
|
265
414
|
}
|
|
266
415
|
}
|
|
267
416
|
|
|
@@ -271,46 +420,76 @@ setErrorMessage(
|
|
|
271
420
|
"ja",
|
|
272
421
|
);
|
|
273
422
|
|
|
423
|
+
/**
|
|
424
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
425
|
+
*/
|
|
274
426
|
export type EncodableStreamNotSupportedErrorMeta = {
|
|
427
|
+
/**
|
|
428
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
429
|
+
*/
|
|
275
430
|
readonly name: string;
|
|
276
431
|
};
|
|
277
432
|
|
|
278
|
-
|
|
433
|
+
/**
|
|
434
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
435
|
+
*/
|
|
436
|
+
export type EncodableStreamNotSupportedErrorArgs = ErrorOptions &
|
|
437
|
+
EncodableStreamNotSupportedErrorMeta;
|
|
279
438
|
|
|
439
|
+
/**
|
|
440
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
441
|
+
*/
|
|
280
442
|
export class EncodableStreamNotSupportedError extends ErrorBase<EncodableStreamNotSupportedErrorMeta> {
|
|
281
443
|
static {
|
|
282
444
|
this.prototype.name = "UniKvsEncodableStreamNotSupportedError";
|
|
283
445
|
}
|
|
284
446
|
|
|
285
|
-
public constructor(args: EncodableStreamNotSupportedErrorArgs
|
|
286
|
-
|
|
447
|
+
public constructor(args: EncodableStreamNotSupportedErrorArgs) {
|
|
448
|
+
const { name, ...options } = args;
|
|
449
|
+
const meta: EncodableStreamNotSupportedErrorMeta = { name };
|
|
450
|
+
super(meta, ({ name }) => `Transformer "${name}" does not support encodable stream`, options);
|
|
287
451
|
}
|
|
288
452
|
}
|
|
289
453
|
|
|
290
454
|
setErrorMessage(
|
|
291
|
-
|
|
455
|
+
EncodableStreamNotSupportedError,
|
|
292
456
|
({ name }) => `トランスフォーマー "${name}" はエンコード可能なストリームをサポートしていません`,
|
|
293
457
|
"ja",
|
|
294
458
|
);
|
|
295
459
|
|
|
460
|
+
/**
|
|
461
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
462
|
+
*/
|
|
296
463
|
export type DecodableStreamNotSupportedErrorMeta = {
|
|
464
|
+
/**
|
|
465
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
466
|
+
*/
|
|
297
467
|
readonly name: string;
|
|
298
468
|
};
|
|
299
469
|
|
|
300
|
-
|
|
470
|
+
/**
|
|
471
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
472
|
+
*/
|
|
473
|
+
export type DecodableStreamNotSupportedErrorArgs = ErrorOptions &
|
|
474
|
+
DecodableStreamNotSupportedErrorMeta;
|
|
301
475
|
|
|
476
|
+
/**
|
|
477
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
478
|
+
*/
|
|
302
479
|
export class DecodableStreamNotSupportedError extends ErrorBase<DecodableStreamNotSupportedErrorMeta> {
|
|
303
480
|
static {
|
|
304
481
|
this.prototype.name = "UniKvsDecodableStreamNotSupportedError";
|
|
305
482
|
}
|
|
306
483
|
|
|
307
|
-
public constructor(args: DecodableStreamNotSupportedErrorArgs
|
|
308
|
-
|
|
484
|
+
public constructor(args: DecodableStreamNotSupportedErrorArgs) {
|
|
485
|
+
const { name, ...options } = args;
|
|
486
|
+
const meta: DecodableStreamNotSupportedErrorMeta = { name };
|
|
487
|
+
super(meta, ({ name }) => `Transformer "${name}" does not support decodable stream`, options);
|
|
309
488
|
}
|
|
310
489
|
}
|
|
311
490
|
|
|
312
491
|
setErrorMessage(
|
|
313
|
-
|
|
492
|
+
DecodableStreamNotSupportedError,
|
|
314
493
|
({ name }) => `トランスフォーマー "${name}" はデコード可能なストリームをサポートしていません`,
|
|
315
494
|
"ja",
|
|
316
495
|
);
|
|
@@ -321,41 +500,89 @@ setErrorMessage(
|
|
|
321
500
|
//
|
|
322
501
|
// -------------------------------------------------------------------------------------------------
|
|
323
502
|
|
|
503
|
+
/**
|
|
504
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
505
|
+
*/
|
|
324
506
|
export type PluginOperationAggregateErrorMeta = {
|
|
507
|
+
/**
|
|
508
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
509
|
+
*/
|
|
325
510
|
readonly plugin: "plugin" | "storage" | "transformer";
|
|
326
|
-
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
514
|
+
*/
|
|
515
|
+
readonly action: "open" | "close" | "write" | "read" | "delete" | "clear";
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
519
|
+
*/
|
|
327
520
|
readonly errors: readonly {
|
|
521
|
+
/**
|
|
522
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
523
|
+
*/
|
|
328
524
|
readonly plugin: "storage" | "transformer";
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
528
|
+
*/
|
|
329
529
|
readonly reason: unknown;
|
|
330
530
|
}[];
|
|
331
531
|
};
|
|
332
532
|
|
|
333
|
-
|
|
533
|
+
/**
|
|
534
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
535
|
+
*/
|
|
536
|
+
export type PluginOperationAggregateErrorArgs = ErrorOptions & {
|
|
537
|
+
/**
|
|
538
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
539
|
+
*/
|
|
334
540
|
readonly plugin?: "storage" | "transformer";
|
|
335
|
-
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
544
|
+
*/
|
|
545
|
+
readonly action: "open" | "close" | "write" | "read" | "delete" | "clear";
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
549
|
+
*/
|
|
336
550
|
readonly errors: readonly {
|
|
551
|
+
/**
|
|
552
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
553
|
+
*/
|
|
337
554
|
readonly plugin?: "storage" | "transformer";
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
558
|
+
*/
|
|
338
559
|
readonly reason: unknown;
|
|
339
560
|
}[];
|
|
340
561
|
};
|
|
341
562
|
|
|
563
|
+
/**
|
|
564
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
565
|
+
*/
|
|
342
566
|
export class PluginOperationAggregateError extends ErrorBase<PluginOperationAggregateErrorMeta> {
|
|
343
567
|
static {
|
|
344
568
|
this.prototype.name = "UniKvsPluginOperationAggregateError";
|
|
345
569
|
}
|
|
346
570
|
|
|
347
|
-
public constructor(args: PluginOperationAggregateErrorArgs
|
|
348
|
-
const errors = args
|
|
349
|
-
|
|
571
|
+
public constructor(args: PluginOperationAggregateErrorArgs) {
|
|
572
|
+
const { plugin, action, errors, ...options } = args;
|
|
573
|
+
// 個々のエラーで種別が指定されていない場合は、既定の種別で補完します。
|
|
574
|
+
const normalizedErrors = errors.map((error) => ({
|
|
575
|
+
plugin: error.plugin ?? plugin ?? ("" as never),
|
|
350
576
|
reason: error.reason,
|
|
351
577
|
}));
|
|
352
|
-
const plugins = [...new Set(
|
|
578
|
+
const plugins = [...new Set(normalizedErrors.map((error) => error.plugin))];
|
|
579
|
+
const meta: PluginOperationAggregateErrorMeta = {
|
|
580
|
+
plugin: plugins.length === 1 ? plugins[0]! : "plugin",
|
|
581
|
+
action,
|
|
582
|
+
errors: normalizedErrors,
|
|
583
|
+
};
|
|
353
584
|
super(
|
|
354
|
-
|
|
355
|
-
plugin: plugins.length === 1 ? plugins[0]! : "plugin",
|
|
356
|
-
action: args.action,
|
|
357
|
-
errors,
|
|
358
|
-
},
|
|
585
|
+
meta,
|
|
359
586
|
({ action, errors, plugin }) => `${errors.length} ${plugin}(s) fail ${action} operation`,
|
|
360
587
|
options,
|
|
361
588
|
);
|
|
@@ -375,6 +602,9 @@ setErrorMessage(
|
|
|
375
602
|
//
|
|
376
603
|
// -------------------------------------------------------------------------------------------------
|
|
377
604
|
|
|
605
|
+
/**
|
|
606
|
+
* [API Reference](https://tai-kun.github.io/unikvs/packages/unikvs#errors)
|
|
607
|
+
*/
|
|
378
608
|
export class MissingStorageError extends ErrorBase<undefined> {
|
|
379
609
|
static {
|
|
380
610
|
this.prototype.name = "UniKvsMissingStorageError";
|
|
@@ -390,21 +620,3 @@ setErrorMessage(
|
|
|
390
620
|
"UniKvs を使用するためには最低 1 つのストレージが必要です",
|
|
391
621
|
"ja",
|
|
392
622
|
);
|
|
393
|
-
|
|
394
|
-
// -------------------------------------------------------------------------------------------------
|
|
395
|
-
|
|
396
|
-
export class TransformerRegistrationError extends ErrorBase<undefined> {
|
|
397
|
-
static {
|
|
398
|
-
this.prototype.name = "UniKvsTransformerRegistrationError";
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
public constructor(options?: ErrorOptions) {
|
|
402
|
-
super("Cannot add transformers after storage has already been registered", options);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
setErrorMessage(
|
|
407
|
-
MissingStorageError,
|
|
408
|
-
"ストレージが登録された後にトランスフォーマーを追加することはできません",
|
|
409
|
-
"ja",
|
|
410
|
-
);
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type * from "./
|
|
1
|
+
export type * from "./variables.types.js";
|
|
2
2
|
|
|
3
3
|
export type {
|
|
4
4
|
DecodableStreamNotSupportedErrorArgs,
|
|
@@ -35,14 +35,13 @@ export {
|
|
|
35
35
|
ReadableStreamNotSupportedError,
|
|
36
36
|
StorageIsNotOpenError,
|
|
37
37
|
TransformerIsNotOpenError,
|
|
38
|
-
TransformerRegistrationError,
|
|
39
38
|
UniKvsIsNotOpenError,
|
|
40
39
|
UniKvsIsOpenError,
|
|
41
40
|
WritableStreamNotSupportedError,
|
|
42
41
|
} from "./errors.js";
|
|
43
42
|
|
|
44
43
|
export type * from "./unikvs-config.js";
|
|
45
|
-
export { default as UniKvsConfig } from "./unikvs-config.js";
|
|
44
|
+
export { PlainValue, StreamValue, Value, default as UniKvsConfig } from "./unikvs-config.js";
|
|
46
45
|
|
|
47
46
|
export type * from "./unikvs.js";
|
|
48
47
|
export { default as UniKvs } from "./unikvs.js";
|