ac-storage 0.13.0 → 0.14.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/dist/bundle.cjs +29 -22
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +29 -22
- package/dist/bundle.mjs.map +1 -1
- package/package.json +2 -2
- package/_TESTPATH/ac-drop/.acstorage +0 -8
package/dist/bundle.mjs
CHANGED
|
@@ -542,28 +542,36 @@ class DefaultValueProvider {
|
|
|
542
542
|
constructor(navigate = null) {
|
|
543
543
|
this.#navigate = navigate;
|
|
544
544
|
}
|
|
545
|
-
|
|
545
|
+
/**
|
|
546
|
+
*
|
|
547
|
+
*/
|
|
548
|
+
get(key, baseValue) {
|
|
546
549
|
if (this.#navigate == null) {
|
|
547
|
-
return
|
|
550
|
+
return baseValue;
|
|
548
551
|
}
|
|
549
552
|
const result = this.#navigate.walk(key, { allowIntermediate: true });
|
|
550
553
|
if (result == null) {
|
|
551
554
|
return undefined;
|
|
552
555
|
}
|
|
553
556
|
else if (isJSONTypeData(result.value)) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
557
|
+
if (baseValue != null) {
|
|
558
|
+
return baseValue;
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
const defaultValue = result.value.default_value;
|
|
562
|
+
return ((defaultValue != null)
|
|
563
|
+
? defaultValue
|
|
564
|
+
: undefined);
|
|
565
|
+
}
|
|
558
566
|
}
|
|
559
567
|
else {
|
|
560
568
|
// for (const [key, value] of Object.entries(result.value)) {
|
|
561
569
|
// console.log(key, value);
|
|
562
570
|
// }
|
|
563
|
-
return this.#getDefaultData(result.value);
|
|
571
|
+
return this.#getDefaultData(result.value, baseValue);
|
|
564
572
|
}
|
|
565
573
|
}
|
|
566
|
-
#getDefaultData(typeData) {
|
|
574
|
+
#getDefaultData(typeData, baseValue) {
|
|
567
575
|
if (t$1 in typeData) {
|
|
568
576
|
if (typeData.value.default_value != null) {
|
|
569
577
|
return typeData.value.default_value;
|
|
@@ -571,18 +579,17 @@ class DefaultValueProvider {
|
|
|
571
579
|
return undefined;
|
|
572
580
|
}
|
|
573
581
|
else {
|
|
574
|
-
let
|
|
575
|
-
const result = {};
|
|
582
|
+
let result = baseValue;
|
|
576
583
|
for (const [key, value] of Object.entries(typeData)) {
|
|
577
584
|
const defaultValue = this.#getDefaultData(value);
|
|
578
585
|
if (defaultValue !== undefined) {
|
|
579
|
-
result
|
|
580
|
-
|
|
586
|
+
result ??= {};
|
|
587
|
+
if (!(key in result)) {
|
|
588
|
+
result[key] = defaultValue;
|
|
589
|
+
}
|
|
581
590
|
}
|
|
582
591
|
}
|
|
583
|
-
return
|
|
584
|
-
? result
|
|
585
|
-
: undefined);
|
|
592
|
+
return result;
|
|
586
593
|
}
|
|
587
594
|
}
|
|
588
595
|
}
|
|
@@ -662,8 +669,8 @@ class JSONAccessor {
|
|
|
662
669
|
getOne(key) {
|
|
663
670
|
this.#ensureNotDropped();
|
|
664
671
|
let value = this.#getData(key);
|
|
665
|
-
if (value == null) {
|
|
666
|
-
value = this.#defaultValueProvider.get(key);
|
|
672
|
+
if (value == null || typeof value === 'object') {
|
|
673
|
+
value = this.#defaultValueProvider.get(key, value);
|
|
667
674
|
}
|
|
668
675
|
return value;
|
|
669
676
|
}
|
|
@@ -672,8 +679,8 @@ class JSONAccessor {
|
|
|
672
679
|
const result = {};
|
|
673
680
|
for (const key of keys) {
|
|
674
681
|
let value = this.#getData(key);
|
|
675
|
-
if (value == null) {
|
|
676
|
-
value = this.#defaultValueProvider.get(key);
|
|
682
|
+
if (value == null || typeof value === 'object') {
|
|
683
|
+
value = this.#defaultValueProvider.get(key, value);
|
|
677
684
|
}
|
|
678
685
|
const resolved = resolveNestedRef(result, key, true);
|
|
679
686
|
resolved.parent[resolved.key] = value;
|
|
@@ -1574,13 +1581,13 @@ class ACSubStorage {
|
|
|
1574
1581
|
await this.#master.move(this.#prefix + ':' + oldIdentifier, this.#prefix + ':' + newIdentifier);
|
|
1575
1582
|
}
|
|
1576
1583
|
async dropDir(identifier) {
|
|
1577
|
-
await this.dropDir(this.#prefix + ':' + identifier);
|
|
1584
|
+
await this.#master.dropDir(this.#prefix + ':' + identifier);
|
|
1578
1585
|
}
|
|
1579
1586
|
async drop(identifier) {
|
|
1580
|
-
await this.drop(this.#prefix + ':' + identifier);
|
|
1587
|
+
await this.#master.drop(this.#prefix + ':' + identifier);
|
|
1581
1588
|
}
|
|
1582
1589
|
async dropAll() {
|
|
1583
|
-
await this.dropDir(this.#prefix);
|
|
1590
|
+
await this.#master.dropDir(this.#prefix);
|
|
1584
1591
|
}
|
|
1585
1592
|
async commit(identifier = '') {
|
|
1586
1593
|
await this.#master.commit(this.#prefix + ':' + identifier);
|