@arcote.tech/arc 0.0.6 → 0.0.8
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/context/context.d.ts +1 -1
- package/dist/index.js +16 -12
- package/dist/utils.d.ts +5 -5
- package/package.json +1 -1
|
@@ -26,6 +26,6 @@ declare class ArcContextWithCommands<const C extends ArcContextElement[], Cmds e
|
|
|
26
26
|
constructor(context: C, commands: Cmds);
|
|
27
27
|
}
|
|
28
28
|
export type ArcContextAny = ArcContext<ArcContextElement[]>;
|
|
29
|
-
export type ArcContextWithCommandsAny = ArcContextWithCommands<
|
|
29
|
+
export type ArcContextWithCommandsAny = ArcContextWithCommands<any, any>;
|
|
30
30
|
export declare function context<const C extends ArcContextElement[]>(...collections: C): ArcContext<C>;
|
|
31
31
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -682,10 +682,8 @@ class ArcModel {
|
|
|
682
682
|
return query;
|
|
683
683
|
}
|
|
684
684
|
async runQuery(query) {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
query.run(dbAdapter, this.changes$);
|
|
688
|
-
}
|
|
685
|
+
const dbAdapter = await this.dbAdapterPromise;
|
|
686
|
+
query.run(dbAdapter, this.changes$);
|
|
689
687
|
}
|
|
690
688
|
commands() {
|
|
691
689
|
return new Proxy({}, {
|
|
@@ -819,19 +817,25 @@ class RTCClient {
|
|
|
819
817
|
console.error(`Collection ${collection3} not found`);
|
|
820
818
|
return;
|
|
821
819
|
}
|
|
822
|
-
const deserializedItems = items.map((item) =>
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
await ctx[collection3].set(id3, item);
|
|
820
|
+
const deserializedItems = items.map((item) => {
|
|
821
|
+
if (item.deleted) {
|
|
822
|
+
return {
|
|
823
|
+
collection: collection3,
|
|
824
|
+
type: "delete",
|
|
825
|
+
id: item._id
|
|
826
|
+
};
|
|
830
827
|
}
|
|
828
|
+
return {
|
|
829
|
+
collection: collection3,
|
|
830
|
+
type: "set",
|
|
831
|
+
body: item
|
|
832
|
+
};
|
|
831
833
|
});
|
|
834
|
+
this.model.applyChanges(deserializedItems);
|
|
832
835
|
}
|
|
833
836
|
break;
|
|
834
837
|
case "sync-done":
|
|
838
|
+
window.localStorage.setItem("lastSync", message.date);
|
|
835
839
|
break;
|
|
836
840
|
case "collection-changes":
|
|
837
841
|
const deserializedChanges = deserializeChanges(message.changes, (name) => this.model.getCollection(name));
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ export declare namespace objectUtil {
|
|
|
5
5
|
export type MergeShapes<U, V> = {
|
|
6
6
|
[k in Exclude<keyof U, keyof V>]: U[k];
|
|
7
7
|
} & V;
|
|
8
|
-
type optionalKeys<T extends
|
|
8
|
+
type optionalKeys<T extends any> = {
|
|
9
9
|
[k in keyof T]: undefined extends T[k] ? k : never;
|
|
10
10
|
}[keyof T];
|
|
11
|
-
type requiredKeys<T extends
|
|
11
|
+
type requiredKeys<T extends any> = {
|
|
12
12
|
[k in keyof T]: undefined extends T[k] ? never : k;
|
|
13
13
|
}[keyof T];
|
|
14
|
-
export type addQuestionMarks<T extends
|
|
14
|
+
export type addQuestionMarks<T extends any> = simplify<{
|
|
15
15
|
[K in requiredKeys<T>]: T[K];
|
|
16
16
|
} & {
|
|
17
17
|
[K in optionalKeys<T>]?: T[K];
|
|
@@ -49,11 +49,11 @@ export type ContextTypes<Ctx extends {
|
|
|
49
49
|
}> = Ctx["collections"] extends (ArcCollectionAny | ArcIndexedCollectionAny)[] ? {
|
|
50
50
|
[Collection in Ctx["collections"][number] as `${Collection["name"]}.bodyWithoutId`]: util.GetType<Collection["schema"]>;
|
|
51
51
|
} & {
|
|
52
|
-
[Collection in Ctx["collections"][number] as `${Collection["name"]}.setBody`]: util.FirstArgument<Collection["schema"]["parse"]
|
|
52
|
+
[Collection in Ctx["collections"][number] as `${Collection["name"]}.setBody`]: objectUtil.addQuestionMarks<util.FirstArgument<Collection["schema"]["parse"]>>;
|
|
53
53
|
} & {
|
|
54
54
|
[Collection in Ctx["collections"][number] as `${Collection["name"]}.id`]: util.GetType<Collection["id"]>;
|
|
55
55
|
} & {
|
|
56
56
|
[Collection in Ctx["collections"][number] as `${Collection["name"]}.body`]: util.CollectionItemWithId<Collection>;
|
|
57
57
|
} & {
|
|
58
|
-
[Collection in Ctx["collections"][number] as `${Collection["name"]}.queryCollectionResult`]: QueryCollectionResult<Collection>;
|
|
58
|
+
[Collection in Ctx["collections"][number] as `${Collection["name"]}.queryCollectionResult`]: Omit<QueryCollectionResult<Collection>, "result">;
|
|
59
59
|
} : never;
|
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.8",
|
|
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.",
|