unikvs 0.0.5 → 0.0.7

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.
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _UniKvs_con, _UniKvs_context, _UniKvs_destinations, _UniKvs_transformers;
12
+ var _UniKvs_instances, _UniKvs_con, _UniKvs_acSet, _UniKvs_context, _UniKvs_destinations, _UniKvs_transformers, _UniKvs_close;
13
13
  import { asyncmux, Asyncmux } from "asyncmux";
14
14
  import combineSignals from "./_combine-signals.js";
15
15
  import logger from "./_logger.js";
@@ -23,18 +23,30 @@ import UniKvsConfig from "./unikvs-config.js";
23
23
  // スキーマ
24
24
  //
25
25
  // -------------------------------------------------------------------------------------------------
26
- const ContextKeySchema = v.union([v.string(), v.symbol(), v.number()]);
26
+ const ContextKeySchema = v.string();
27
27
  const ContextSourceSchema = v.union([
28
28
  v.record(v.any(), v.unknown()),
29
29
  v.array(v.tuple([ContextKeySchema, v.unknown()])),
30
30
  ]);
31
31
  const OpenOptionsSchema = v.object({
32
+ /**
33
+ * 処理の中断を通知するためのシグナルです。
34
+ */
32
35
  signal: v.optional(v.instance(AbortSignal)),
36
+ /**
37
+ * 実行時のコンテキスト情報です。
38
+ */
33
39
  context: v.optional(ContextSourceSchema),
34
40
  });
35
41
  const OpenArgsSchema = v.tuple([v.optional(OpenOptionsSchema)]);
36
42
  const CloseOptionsSchema = v.object({
43
+ /**
44
+ * 処理の中断を通知するためのシグナルです。
45
+ */
37
46
  signal: v.optional(v.instance(AbortSignal)),
47
+ /**
48
+ * 実行時のコンテキスト情報です。
49
+ */
38
50
  context: v.optional(ContextSourceSchema),
39
51
  });
40
52
  const CloseArgsSchema = v.tuple([v.optional(CloseOptionsSchema)]);
@@ -89,7 +101,13 @@ const DeleteArgsSchema = v.union([
89
101
  v.pipe(v.tuple([DeleteOptionsSchema.entries.key, v.optional(v.omit(DeleteOptionsSchema, ["key"]))]), v.transform(([key, options]) => [{ ...options, key }])),
90
102
  ]);
91
103
  const ClearOptionsSchema = v.object({
104
+ /**
105
+ * 処理の中断を通知するためのシグナルです。
106
+ */
92
107
  signal: v.optional(v.instance(AbortSignal)),
108
+ /**
109
+ * 実行時のコンテキスト情報です。
110
+ */
93
111
  context: v.optional(ContextSourceSchema),
94
112
  });
95
113
  const ClearArgsSchema = v.tuple([v.optional(ClearOptionsSchema)]);
@@ -154,10 +172,12 @@ export default class UniKvs {
154
172
  * @param transformers トランスフォーマーのリストです。
155
173
  */
156
174
  constructor(context, destinations, transformers) {
175
+ _UniKvs_instances.add(this);
157
176
  /**
158
177
  * 現在の接続状態です。非接続時は null となります。
159
178
  */
160
179
  _UniKvs_con.set(this, void 0);
180
+ _UniKvs_acSet.set(this, void 0);
161
181
  /**
162
182
  * 基本となる実行コンテキスト情報です。
163
183
  */
@@ -171,10 +191,8 @@ export default class UniKvs {
171
191
  */
172
192
  _UniKvs_transformers.set(this, void 0);
173
193
  __classPrivateFieldSet(this, _UniKvs_con, null, "f");
174
- __classPrivateFieldSet(this, _UniKvs_context, {
175
- ...context,
176
- "unikvs:instance": this,
177
- }, "f");
194
+ __classPrivateFieldSet(this, _UniKvs_acSet, new Set(), "f");
195
+ __classPrivateFieldSet(this, _UniKvs_context, { ...context }, "f");
178
196
  __classPrivateFieldSet(this, _UniKvs_destinations, destinations, "f");
179
197
  __classPrivateFieldSet(this, _UniKvs_transformers, transformers, "f");
180
198
  }
@@ -184,114 +202,131 @@ export default class UniKvs {
184
202
  * @returns 利用可能である場合は true、そうでない場合は false を返します。
185
203
  */
186
204
  get isOpen() {
187
- return !!__classPrivateFieldGet(this, _UniKvs_con, "f");
205
+ return __classPrivateFieldGet(this, _UniKvs_con, "f") !== null;
188
206
  }
189
207
  async open(...args) {
190
- if (__classPrivateFieldGet(this, _UniKvs_con, "f")) {
208
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") !== null) {
191
209
  throw new UniKvsIsOpenError();
192
210
  }
193
- __classPrivateFieldSet(this, _UniKvs_con, {
194
- conAc: new AbortController(),
195
- ioMux: new Asyncmux(),
196
- }, "f");
211
+ const [options = {}] = v.parseInput(OpenArgsSchema, args);
212
+ const { signal: signalOption, context: contextOption } = options;
213
+ const ac = new AbortController();
214
+ const signal = combineSignals([ac.signal, signalOption]);
215
+ const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
216
+ context["unikvs:action"] = "open";
217
+ signal.throwIfAborted();
218
+ __classPrivateFieldGet(this, _UniKvs_acSet, "f").add(ac);
219
+ const dispose = [];
220
+ const lock = await asyncmux(this, signal);
197
221
  try {
198
- const [options = {}] = v.parseInput(OpenArgsSchema, args);
199
- const { signal: signalOption, context: contextOption } = options;
200
- const { conAc } = __classPrivateFieldGet(this, _UniKvs_con, "f");
201
- const signal = combineSignals([conAc.signal, signalOption]);
202
- const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
203
- context["unikvs:action"] = "open";
222
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") !== null) {
223
+ throw new UniKvsIsOpenError();
224
+ }
204
225
  const openFns = [];
205
- const dispose = [];
206
- const lock = await asyncmux(this, signal);
207
- try {
208
- // ロック待機中に接続状態が変更されていないか再確認します。
209
- if (__classPrivateFieldGet(this, _UniKvs_con, "f").conAc !== conAc) {
210
- throw new UniKvsIsOpenError();
211
- }
212
- // 各ストレージのオープン処理をリストに追加します。
213
- for (const storage of __classPrivateFieldGet(this, _UniKvs_destinations, "f")) {
214
- openFns.push([
215
- async () => {
216
- await storage.open(context, signal);
217
- dispose.push(async () => {
218
- try {
219
- await storage.close(context, signal);
220
- }
221
- catch (ex) {
222
- logger.error `Failed to close storage: ${ex}`;
223
- }
224
- });
225
- },
226
- "storage",
227
- ]);
226
+ // 各ストレージのオープン処理をリストに追加します。
227
+ for (const storage of __classPrivateFieldGet(this, _UniKvs_destinations, "f")) {
228
+ openFns.push([
229
+ async () => {
230
+ await storage.open(context, signal);
231
+ dispose.push(async () => {
232
+ try {
233
+ await storage.close(context, signal);
234
+ }
235
+ catch (ex) {
236
+ logger.error `Failed to close storage: ${ex}`;
237
+ }
238
+ });
239
+ },
240
+ "storage",
241
+ ]);
242
+ }
243
+ // 各トランスフォーマーのオープン処理をリストに追加します。
244
+ for (const transformer of __classPrivateFieldGet(this, _UniKvs_transformers, "f")) {
245
+ openFns.push([
246
+ async () => {
247
+ await transformer.open(context, signal);
248
+ dispose.push(async () => {
249
+ try {
250
+ await transformer.close(context, signal);
251
+ }
252
+ catch (ex) {
253
+ logger.error `Failed to close transformer: ${ex}`;
254
+ }
255
+ });
256
+ },
257
+ "transformer",
258
+ ]);
259
+ }
260
+ // すべての処理を並列に実行し、エラーが発生した場合は集約します。
261
+ const errors = [];
262
+ await Promise.all(openFns.map(async ([f, plugin]) => {
263
+ try {
264
+ await f();
228
265
  }
229
- // 各トランスフォーマーのオープン処理をリストに追加します。
230
- for (const transformer of __classPrivateFieldGet(this, _UniKvs_transformers, "f")) {
231
- openFns.push([
232
- async () => {
233
- await transformer.open(context, signal);
234
- dispose.push(async () => {
235
- try {
236
- await transformer.close(context, signal);
237
- }
238
- catch (ex) {
239
- logger.error `Failed to close transformer: ${ex}`;
240
- }
241
- });
242
- },
243
- "transformer",
244
- ]);
266
+ catch (reason) {
267
+ errors.push({ plugin, reason });
245
268
  }
246
- // すべての処理を並列に実行し、エラーが発生した場合は集約します。
247
- const errors = [];
248
- await Promise.all(openFns.map(async ([f, plugin]) => {
249
- try {
250
- await f();
251
- }
252
- catch (reason) {
253
- errors.push({ plugin, reason });
254
- }
269
+ }));
270
+ if (errors.length > 0) {
271
+ throw new PluginOperationAggregateError({ action: "open", errors });
272
+ }
273
+ __classPrivateFieldSet(this, _UniKvs_con, {
274
+ ac,
275
+ io: new Asyncmux(),
276
+ }, "f");
277
+ }
278
+ catch (ex) {
279
+ if (dispose.length > 0) {
280
+ await Promise.all(dispose.map(async (f) => {
281
+ await f();
255
282
  }));
256
- if (errors.length > 0) {
257
- throw new PluginOperationAggregateError({ action: "open", errors });
258
- }
259
283
  }
260
- catch (ex) {
261
- __classPrivateFieldSet(this, _UniKvs_con, null, "f"); // unlock の前に null に戻します。
262
- if (dispose.length > 0) {
263
- await Promise.all(dispose.map(async (f) => {
264
- await f();
265
- }));
284
+ throw ex;
285
+ }
286
+ finally {
287
+ __classPrivateFieldGet(this, _UniKvs_acSet, "f").delete(ac);
288
+ lock.release();
289
+ }
290
+ }
291
+ close(...args) {
292
+ try {
293
+ const [options = {}] = v.parseInput(CloseArgsSchema, args);
294
+ const { signal = AbortSignal.timeout(10e3), context: contextOption } = options;
295
+ const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
296
+ context["unikvs:action"] = "close";
297
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
298
+ const acArr = [...__classPrivateFieldGet(this, _UniKvs_acSet, "f")];
299
+ __classPrivateFieldGet(this, _UniKvs_acSet, "f").clear();
300
+ for (const ac of acArr) {
301
+ if (!ac.signal.aborted) {
302
+ ac.abort(new UniKvsIsNotOpenError());
303
+ }
266
304
  }
267
- throw ex;
305
+ throw new UniKvsIsNotOpenError();
268
306
  }
269
- finally {
270
- lock.release();
307
+ const { ac } = __classPrivateFieldGet(this, _UniKvs_con, "f");
308
+ const acArr = [ac, ...__classPrivateFieldGet(this, _UniKvs_acSet, "f")];
309
+ __classPrivateFieldGet(this, _UniKvs_acSet, "f").clear();
310
+ for (const ac of acArr) {
311
+ if (!ac.signal.aborted) {
312
+ ac.abort(new UniKvsIsNotOpenError());
313
+ }
271
314
  }
315
+ return __classPrivateFieldGet(this, _UniKvs_instances, "m", _UniKvs_close).call(this, context, signal, __classPrivateFieldGet(this, _UniKvs_con, "f"));
272
316
  }
273
317
  catch (ex) {
274
- __classPrivateFieldSet(this, _UniKvs_con, null, "f");
275
- throw ex;
318
+ return Promise.reject(ex);
276
319
  }
277
320
  }
278
- async close(...args) {
279
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
280
- throw new UniKvsIsNotOpenError();
281
- }
282
- const [options = {}] = v.parseInput(CloseArgsSchema, args);
283
- const { signal = AbortSignal.timeout(10e3), context: contextOption } = options;
284
- const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
285
- context["unikvs:action"] = "close";
286
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
287
- conAc.abort(new UniKvsIsNotOpenError()); // 実行中の他の操作をすべて中断させるために signal を発火させます。
321
+ async [(_UniKvs_con = new WeakMap(), _UniKvs_acSet = new WeakMap(), _UniKvs_context = new WeakMap(), _UniKvs_destinations = new WeakMap(), _UniKvs_transformers = new WeakMap(), _UniKvs_instances = new WeakSet(), _UniKvs_close = async function _UniKvs_close(context, signal, con) {
288
322
  const lock = await asyncmux(this, signal);
289
323
  try {
290
324
  // ロック待機中に接続状態が変更されていないか再確認します。
291
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
325
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") !== con) {
292
326
  throw new UniKvsIsNotOpenError();
293
327
  }
294
- const lock = await ioMux.lock({ signal });
328
+ const { io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
329
+ const lock = await io.lock({ signal });
295
330
  try {
296
331
  const closeFns = [];
297
332
  // ストレージのクローズ処理を登録します。
@@ -329,13 +364,12 @@ export default class UniKvs {
329
364
  finally {
330
365
  lock.release();
331
366
  }
367
+ __classPrivateFieldSet(this, _UniKvs_con, null, "f");
332
368
  }
333
369
  finally {
334
- __classPrivateFieldSet(this, _UniKvs_con, null, "f");
335
370
  lock.release();
336
371
  }
337
- }
338
- async [(_UniKvs_con = new WeakMap(), _UniKvs_context = new WeakMap(), _UniKvs_destinations = new WeakMap(), _UniKvs_transformers = new WeakMap(), Symbol.asyncDispose)]() {
372
+ }, Symbol.asyncDispose)]() {
339
373
  if (!this.isOpen) {
340
374
  return;
341
375
  }
@@ -344,20 +378,20 @@ export default class UniKvs {
344
378
  });
345
379
  }
346
380
  async set(...args) {
347
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
381
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
348
382
  throw new UniKvsIsNotOpenError();
349
383
  }
350
384
  const [options] = v.parseInput(SetArgsSchema, args);
351
385
  const { key, value, signal: signalOption, context: contextOption } = options;
352
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
353
- const signal = combineSignals([conAc.signal, signalOption]);
386
+ const { ac, io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
387
+ const signal = combineSignals([ac.signal, signalOption]);
354
388
  const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
355
389
  context["unikvs:action"] = "set";
356
390
  context["unikvs:key"] = key;
357
391
  const lock = await asyncmux(this, signal);
358
392
  try {
359
393
  // ロック待機中に接続状態が変更されていないか再確認します。
360
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
394
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
361
395
  throw new UniKvsIsNotOpenError();
362
396
  }
363
397
  const errors = [];
@@ -369,7 +403,7 @@ export default class UniKvs {
369
403
  const e = await transformer.getEncodable(context, signal);
370
404
  data = data.pipeThrough(e);
371
405
  }
372
- const lock = await ioMux.lock({ key, signal });
406
+ const lock = await io.lock({ key, signal });
373
407
  try {
374
408
  await Promise.all(__classPrivateFieldGet(this, _UniKvs_destinations, "f").map(async (storage, i) => {
375
409
  try {
@@ -397,7 +431,7 @@ export default class UniKvs {
397
431
  for (const transformer of __classPrivateFieldGet(this, _UniKvs_transformers, "f")) {
398
432
  data = await transformer.encode(context, signal, data);
399
433
  }
400
- const lock = await ioMux.lock({ key, signal });
434
+ const lock = await io.lock({ key, signal });
401
435
  try {
402
436
  await Promise.all(__classPrivateFieldGet(this, _UniKvs_destinations, "f").map(async (storage) => {
403
437
  try {
@@ -445,25 +479,25 @@ export default class UniKvs {
445
479
  }
446
480
  }
447
481
  async get(...args) {
448
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
482
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
449
483
  throw new UniKvsIsNotOpenError();
450
484
  }
451
485
  const [options] = v.parseInput(GetArgsSchema, args);
452
486
  const { key, signal: signalOption, context: contextOption } = options;
453
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
454
- const signal = combineSignals([conAc.signal, signalOption]);
487
+ const { ac, io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
488
+ const signal = combineSignals([ac.signal, signalOption]);
455
489
  const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
456
490
  context["unikvs:action"] = "get";
457
491
  context["unikvs:key"] = key;
458
492
  const lock = await asyncmux.readonly(this, signal);
459
493
  try {
460
494
  // ロック待機中に接続状態が変更されていないか再確認します。
461
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
495
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
462
496
  throw new UniKvsIsNotOpenError();
463
497
  }
464
498
  const NONE = {};
465
499
  let data = NONE;
466
- const lock = await ioMux.rLock({ key, signal });
500
+ const lock = await io.rLock({ key, signal });
467
501
  try {
468
502
  // 各ストレージを巡回し、最初に見つかったデータを取得します。
469
503
  for (const storage of __classPrivateFieldGet(this, _UniKvs_destinations, "f")) {
@@ -492,25 +526,25 @@ export default class UniKvs {
492
526
  }
493
527
  }
494
528
  async stream(...args) {
495
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
529
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
496
530
  throw new UniKvsIsNotOpenError();
497
531
  }
498
532
  const [options] = v.parseInput(StreamArgsSchema, args);
499
533
  const { key, signal: signalOption, context: contextOption } = options;
500
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
501
- const signal = combineSignals([conAc.signal, signalOption]);
534
+ const { ac, io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
535
+ const signal = combineSignals([ac.signal, signalOption]);
502
536
  const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
503
537
  context["unikvs:action"] = "stream";
504
538
  context["unikvs:key"] = key;
505
539
  const lock = await asyncmux(this, signal);
506
540
  try {
507
541
  // ロック待機中に接続状態が変更されていないか再確認します。
508
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
542
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
509
543
  throw new UniKvsIsNotOpenError();
510
544
  }
511
545
  const NONE = {};
512
546
  let r = NONE;
513
- const lock = await ioMux.rLock({ key, signal });
547
+ const lock = await io.rLock({ key, signal });
514
548
  try {
515
549
  // 各ストレージを巡回し、最初に見つかったデータを取得します。
516
550
  for (const storage of __classPrivateFieldGet(this, _UniKvs_destinations, "f")) {
@@ -570,23 +604,23 @@ export default class UniKvs {
570
604
  }
571
605
  }
572
606
  async has(...args) {
573
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
607
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
574
608
  throw new UniKvsIsNotOpenError();
575
609
  }
576
610
  const [options] = v.parseInput(HasArgsSchema, args);
577
611
  const { key, signal: signalOption, context: contextOption } = options;
578
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
579
- const signal = combineSignals([conAc.signal, signalOption]);
612
+ const { ac, io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
613
+ const signal = combineSignals([ac.signal, signalOption]);
580
614
  const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
581
615
  context["unikvs:action"] = "has";
582
616
  context["unikvs:key"] = key;
583
617
  const lock = await asyncmux(this, signal);
584
618
  try {
585
619
  // ロック待機中に接続状態が変更されていないか再確認します。
586
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
620
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
587
621
  throw new UniKvsIsNotOpenError();
588
622
  }
589
- const lock = await ioMux.rLock({ key, signal });
623
+ const lock = await io.rLock({ key, signal });
590
624
  try {
591
625
  // いずれかのストレージに存在すれば true を返します。
592
626
  for (const storage of __classPrivateFieldGet(this, _UniKvs_destinations, "f")) {
@@ -605,23 +639,23 @@ export default class UniKvs {
605
639
  }
606
640
  }
607
641
  async delete(...args) {
608
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
642
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
609
643
  throw new UniKvsIsNotOpenError();
610
644
  }
611
645
  const [options] = v.parseInput(DeleteArgsSchema, args);
612
646
  const { key, signal: signalOption, context: contextOption } = options;
613
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
614
- const signal = combineSignals([conAc.signal, signalOption]);
647
+ const { ac, io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
648
+ const signal = combineSignals([ac.signal, signalOption]);
615
649
  const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
616
650
  context["unikvs:action"] = "delete";
617
651
  context["unikvs:key"] = key;
618
652
  const lock = await asyncmux(this, signal);
619
653
  try {
620
654
  // ロック待機中に接続状態が変更されていないか再確認します。
621
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
655
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
622
656
  throw new UniKvsIsNotOpenError();
623
657
  }
624
- const lock = await ioMux.lock({ key, signal });
658
+ const lock = await io.lock({ key, signal });
625
659
  try {
626
660
  // すべてのストレージから対象データを削除します。
627
661
  // すべての処理を並列に実行し、エラーが発生した場合は集約します。
@@ -649,22 +683,22 @@ export default class UniKvs {
649
683
  }
650
684
  }
651
685
  async clear(...args) {
652
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
686
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
653
687
  throw new UniKvsIsNotOpenError();
654
688
  }
655
689
  const [options = {}] = v.parseInput(ClearArgsSchema, args);
656
690
  const { signal: signalOption, context: contextOption } = options;
657
- const { conAc, ioMux } = __classPrivateFieldGet(this, _UniKvs_con, "f");
658
- const signal = combineSignals([conAc.signal, signalOption]);
691
+ const { ac, io } = __classPrivateFieldGet(this, _UniKvs_con, "f");
692
+ const signal = combineSignals([ac.signal, signalOption]);
659
693
  const context = mergeContext(__classPrivateFieldGet(this, _UniKvs_context, "f"), contextOption);
660
694
  context["unikvs:action"] = "clear";
661
695
  const lock = await asyncmux(this, signal);
662
696
  try {
663
697
  // ロック待機中に接続状態が変更されていないか再確認します。
664
- if (!__classPrivateFieldGet(this, _UniKvs_con, "f")) {
698
+ if (__classPrivateFieldGet(this, _UniKvs_con, "f") === null) {
665
699
  throw new UniKvsIsNotOpenError();
666
700
  }
667
- const lock = await ioMux.lock({ signal });
701
+ const lock = await io.lock({ signal });
668
702
  try {
669
703
  // すべてのストレージで一括削除を実行します。
670
704
  // すべての処理を並列に実行し、エラーが発生した場合は集約します。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unikvs",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/tai-kun/unikvs",
6
6
  "license": "MIT",
@@ -25,7 +25,8 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@unikvs/core": "0.0.5",
28
+ "@tai-kun/valibot-extra-lab": "^0.0.4",
29
+ "@unikvs/core": "0.0.7",
29
30
  "asyncmux": "^0.0.8",
30
31
  "call-fn-once": "^0.0.4",
31
32
  "try-capture-stack-trace": "^0.0.3"
@@ -34,12 +35,12 @@
34
35
  "@tsconfig/node24": "^24.0.4",
35
36
  "@tsconfig/strictest": "^2.0.8",
36
37
  "@types/node": "^24.12.2",
37
- "@unikvs/checksum": "0.0.5",
38
- "@unikvs/compression": "0.0.5",
39
- "@unikvs/fs.node": "0.0.5",
40
- "@unikvs/memory": "0.0.5",
41
- "@unikvs/opfs": "0.0.5",
42
- "@unikvs/utils": "0.0.5",
38
+ "@unikvs/checksum": "0.0.7",
39
+ "@unikvs/compression": "0.0.7",
40
+ "@unikvs/fs.node": "0.0.7",
41
+ "@unikvs/memory": "0.0.7",
42
+ "@unikvs/opfs": "0.0.7",
43
+ "@unikvs/utils": "0.0.7",
43
44
  "@vitest/browser": "^4.1.5",
44
45
  "@vitest/browser-playwright": "^4.1.5",
45
46
  "npm-check-updates": "^20.0.2",
package/src/_valibot.ts CHANGED
@@ -9,26 +9,24 @@ import {
9
9
  type InvalidOutputErrorArgs,
10
10
  } from "./errors.js";
11
11
 
12
+ export type { InferInput, InferOutput } from "valibot";
12
13
  export {
13
14
  any,
14
15
  omit,
15
16
  pipe,
16
- array,
17
- tuple,
18
17
  union,
19
18
  number,
20
- object,
21
- record,
22
19
  string,
23
20
  symbol,
24
21
  unknown,
25
22
  instance,
26
23
  minValue,
27
24
  optional,
28
- transform,
29
25
  safeInteger,
30
26
  } from "valibot";
31
27
 
28
+ export { array, tuple, object, record, transform } from "@tai-kun/valibot-extra-lab";
29
+
32
30
  type BaseSchema = typeof safeParse extends (schema: infer S, ...args: any) => any ? S : never;
33
31
 
34
32
  export interface ParseInputErrorConstructor {