@arcote.tech/arc 0.0.7 → 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.
@@ -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<ArcContextElement[], any>;
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
@@ -817,16 +817,21 @@ class RTCClient {
817
817
  console.error(`Collection ${collection3} not found`);
818
818
  return;
819
819
  }
820
- const deserializedItems = items.map((item) => c.deserialize(item));
821
- this.model.executeCommand(async (ctx) => {
822
- for (const item of deserializedItems) {
823
- const id3 = item._id;
824
- if (!item)
825
- await ctx[collection3].remove(id3);
826
- else
827
- 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
+ };
828
827
  }
828
+ return {
829
+ collection: collection3,
830
+ type: "set",
831
+ body: item
832
+ };
829
833
  });
834
+ this.model.applyChanges(deserializedItems);
830
835
  }
831
836
  break;
832
837
  case "sync-done":
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 object> = {
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 object> = {
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 object> = simplify<{
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",
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.",