@arcote.tech/arc 0.0.19 → 0.0.20
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.
|
@@ -14,7 +14,7 @@ export type Deserialize<Id extends ArcIdAny, Schema extends ArcObjectAny> = obje
|
|
|
14
14
|
} & ReturnType<Schema["deserialize"]>>;
|
|
15
15
|
type CollectionQueryBuilder<T extends ArcCollection<any, any, any>> = {
|
|
16
16
|
all: () => ArcAllItemsQueryBuilder<T>;
|
|
17
|
-
one: (id: util.GetType<T["id"]> | undefined) => ArcOneItemQueryBuilder<T>;
|
|
17
|
+
one: (id: util.GetType<T["id"]> | undefined | null) => ArcOneItemQueryBuilder<T>;
|
|
18
18
|
};
|
|
19
19
|
type CollectionCommandContext<Id extends ArcIdAny, Schema extends ArcObjectAny> = {
|
|
20
20
|
one: (id: util.GetType<Id>) => Deserialize<Id, Schema>;
|
|
@@ -4,9 +4,9 @@ import type { ArcElement } from "./element";
|
|
|
4
4
|
export declare class ArcOptional<E extends ArcElement> implements ArcElement {
|
|
5
5
|
private parent;
|
|
6
6
|
constructor(parent: E);
|
|
7
|
-
parse(value: util.FirstArgument<E["parse"]> | undefined): ReturnType<E["parse"]> |
|
|
8
|
-
serialize(value: util.FirstArgument<E["serialize"]> | undefined): ReturnType<E["serialize"]> |
|
|
9
|
-
deserialize(value: util.FirstArgument<E["deserialize"]> | undefined): ReturnType<E["deserialize"]> |
|
|
7
|
+
parse(value: util.FirstArgument<E["parse"]> | null | undefined): ReturnType<E["parse"]> | null;
|
|
8
|
+
serialize(value: util.FirstArgument<E["serialize"]> | null | undefined): ReturnType<E["serialize"]> | null;
|
|
9
|
+
deserialize(value: util.FirstArgument<E["deserialize"]> | null | undefined): ReturnType<E["deserialize"]> | null;
|
|
10
10
|
}
|
|
11
11
|
export type ArcOptionalAny = ArcOptional<ArcAbstract>;
|
|
12
12
|
//# sourceMappingURL=optional.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -461,8 +461,10 @@ import { apply } from "mutative";
|
|
|
461
461
|
function deepMerge(target, source) {
|
|
462
462
|
const output = { ...target };
|
|
463
463
|
for (const key in source) {
|
|
464
|
-
if (source[key] === undefined)
|
|
464
|
+
if (source[key] === undefined) {
|
|
465
|
+
output[key] = undefined;
|
|
465
466
|
continue;
|
|
467
|
+
}
|
|
466
468
|
if (isObject(source[key]) && isObject(target[key])) {
|
|
467
469
|
output[key] = deepMerge(target[key], source[key]);
|
|
468
470
|
} else {
|
|
@@ -691,6 +693,7 @@ class ForkedDataStorage extends DataStorage {
|
|
|
691
693
|
store: store.storeName,
|
|
692
694
|
changes: store.changes
|
|
693
695
|
}));
|
|
696
|
+
console.log(changes);
|
|
694
697
|
await this.master.commitChanges(changes);
|
|
695
698
|
}
|
|
696
699
|
}
|
|
@@ -733,6 +736,7 @@ class MasterStoreState extends StoreState {
|
|
|
733
736
|
if (change.type === "modify") {
|
|
734
737
|
const existing = await transaction.findById(this.storeName, change.id);
|
|
735
738
|
const updated = existing ? deepMerge(existing, change.data) : { _id: change.id, ...change.data };
|
|
739
|
+
console.log("updated", updated);
|
|
736
740
|
await transaction.set(this.storeName, updated);
|
|
737
741
|
const item = this.deserialize ? this.deserialize(updated) : updated;
|
|
738
742
|
this.items.set(change.id, item);
|
|
@@ -890,17 +894,17 @@ class ArcOptional {
|
|
|
890
894
|
}
|
|
891
895
|
parse(value) {
|
|
892
896
|
if (!value)
|
|
893
|
-
return;
|
|
897
|
+
return null;
|
|
894
898
|
return this.parent.parse(value);
|
|
895
899
|
}
|
|
896
900
|
serialize(value) {
|
|
897
901
|
if (value)
|
|
898
902
|
return this.parent.serialize(value);
|
|
899
|
-
return;
|
|
903
|
+
return null;
|
|
900
904
|
}
|
|
901
905
|
deserialize(value) {
|
|
902
906
|
if (!value)
|
|
903
|
-
return;
|
|
907
|
+
return null;
|
|
904
908
|
return this.parent.deserialize(value);
|
|
905
909
|
}
|
|
906
910
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.20",
|
|
8
8
|
"private": false,
|
|
9
9
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
10
10
|
"description": "Arc is a framework designed to align code closely with business logic, streamlining development and enhancing productivity.",
|