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.cjs
CHANGED
|
@@ -565,28 +565,36 @@ class DefaultValueProvider {
|
|
|
565
565
|
constructor(navigate = null) {
|
|
566
566
|
this.#navigate = navigate;
|
|
567
567
|
}
|
|
568
|
-
|
|
568
|
+
/**
|
|
569
|
+
*
|
|
570
|
+
*/
|
|
571
|
+
get(key, baseValue) {
|
|
569
572
|
if (this.#navigate == null) {
|
|
570
|
-
return
|
|
573
|
+
return baseValue;
|
|
571
574
|
}
|
|
572
575
|
const result = this.#navigate.walk(key, { allowIntermediate: true });
|
|
573
576
|
if (result == null) {
|
|
574
577
|
return undefined;
|
|
575
578
|
}
|
|
576
579
|
else if (isJSONTypeData(result.value)) {
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
580
|
+
if (baseValue != null) {
|
|
581
|
+
return baseValue;
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
const defaultValue = result.value.default_value;
|
|
585
|
+
return ((defaultValue != null)
|
|
586
|
+
? defaultValue
|
|
587
|
+
: undefined);
|
|
588
|
+
}
|
|
581
589
|
}
|
|
582
590
|
else {
|
|
583
591
|
// for (const [key, value] of Object.entries(result.value)) {
|
|
584
592
|
// console.log(key, value);
|
|
585
593
|
// }
|
|
586
|
-
return this.#getDefaultData(result.value);
|
|
594
|
+
return this.#getDefaultData(result.value, baseValue);
|
|
587
595
|
}
|
|
588
596
|
}
|
|
589
|
-
#getDefaultData(typeData) {
|
|
597
|
+
#getDefaultData(typeData, baseValue) {
|
|
590
598
|
if (t$1 in typeData) {
|
|
591
599
|
if (typeData.value.default_value != null) {
|
|
592
600
|
return typeData.value.default_value;
|
|
@@ -594,18 +602,17 @@ class DefaultValueProvider {
|
|
|
594
602
|
return undefined;
|
|
595
603
|
}
|
|
596
604
|
else {
|
|
597
|
-
let
|
|
598
|
-
const result = {};
|
|
605
|
+
let result = baseValue;
|
|
599
606
|
for (const [key, value] of Object.entries(typeData)) {
|
|
600
607
|
const defaultValue = this.#getDefaultData(value);
|
|
601
608
|
if (defaultValue !== undefined) {
|
|
602
|
-
result
|
|
603
|
-
|
|
609
|
+
result ??= {};
|
|
610
|
+
if (!(key in result)) {
|
|
611
|
+
result[key] = defaultValue;
|
|
612
|
+
}
|
|
604
613
|
}
|
|
605
614
|
}
|
|
606
|
-
return
|
|
607
|
-
? result
|
|
608
|
-
: undefined);
|
|
615
|
+
return result;
|
|
609
616
|
}
|
|
610
617
|
}
|
|
611
618
|
}
|
|
@@ -685,8 +692,8 @@ class JSONAccessor {
|
|
|
685
692
|
getOne(key) {
|
|
686
693
|
this.#ensureNotDropped();
|
|
687
694
|
let value = this.#getData(key);
|
|
688
|
-
if (value == null) {
|
|
689
|
-
value = this.#defaultValueProvider.get(key);
|
|
695
|
+
if (value == null || typeof value === 'object') {
|
|
696
|
+
value = this.#defaultValueProvider.get(key, value);
|
|
690
697
|
}
|
|
691
698
|
return value;
|
|
692
699
|
}
|
|
@@ -695,8 +702,8 @@ class JSONAccessor {
|
|
|
695
702
|
const result = {};
|
|
696
703
|
for (const key of keys) {
|
|
697
704
|
let value = this.#getData(key);
|
|
698
|
-
if (value == null) {
|
|
699
|
-
value = this.#defaultValueProvider.get(key);
|
|
705
|
+
if (value == null || typeof value === 'object') {
|
|
706
|
+
value = this.#defaultValueProvider.get(key, value);
|
|
700
707
|
}
|
|
701
708
|
const resolved = resolveNestedRef(result, key, true);
|
|
702
709
|
resolved.parent[resolved.key] = value;
|
|
@@ -1597,13 +1604,13 @@ class ACSubStorage {
|
|
|
1597
1604
|
await this.#master.move(this.#prefix + ':' + oldIdentifier, this.#prefix + ':' + newIdentifier);
|
|
1598
1605
|
}
|
|
1599
1606
|
async dropDir(identifier) {
|
|
1600
|
-
await this.dropDir(this.#prefix + ':' + identifier);
|
|
1607
|
+
await this.#master.dropDir(this.#prefix + ':' + identifier);
|
|
1601
1608
|
}
|
|
1602
1609
|
async drop(identifier) {
|
|
1603
|
-
await this.drop(this.#prefix + ':' + identifier);
|
|
1610
|
+
await this.#master.drop(this.#prefix + ':' + identifier);
|
|
1604
1611
|
}
|
|
1605
1612
|
async dropAll() {
|
|
1606
|
-
await this.dropDir(this.#prefix);
|
|
1613
|
+
await this.#master.dropDir(this.#prefix);
|
|
1607
1614
|
}
|
|
1608
1615
|
async commit(identifier = '') {
|
|
1609
1616
|
await this.#master.commit(this.#prefix + ':' + identifier);
|