@arcote.tech/arc 0.0.1 → 0.0.3

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.
Files changed (46) hide show
  1. package/dist/collection/collection-change.d.ts +17 -0
  2. package/dist/collection/collection.d.ts +59 -0
  3. package/dist/collection/db.d.ts +18 -0
  4. package/dist/collection/index.d.ts +5 -0
  5. package/dist/collection/queries/abstract-collection-query.d.ts +20 -0
  6. package/dist/collection/queries/abstract-many-items.d.ts +20 -0
  7. package/dist/collection/queries/all-items.d.ts +6 -0
  8. package/dist/collection/queries/indexed.d.ts +13 -0
  9. package/dist/collection/queries/one-item.d.ts +11 -0
  10. package/dist/collection/queries/util.d.ts +6 -0
  11. package/dist/collection/query-builders/abstract-many-items.d.ts +9 -0
  12. package/dist/collection/query-builders/all-items.d.ts +8 -0
  13. package/dist/collection/query-builders/indexed.d.ts +10 -0
  14. package/dist/collection/query-builders/one-item.d.ts +10 -0
  15. package/dist/context/commands.d.ts +10 -0
  16. package/dist/context/context.d.ts +31 -0
  17. package/dist/context/element.d.ts +8 -0
  18. package/dist/context/index.d.ts +1 -0
  19. package/dist/context/query-builders.d.ts +4 -0
  20. package/dist/context/query.d.ts +3 -0
  21. package/dist/elements/abstract-primitive.d.ts +7 -0
  22. package/dist/elements/abstract.d.ts +12 -0
  23. package/dist/elements/array.d.ts +12 -0
  24. package/dist/elements/boolean.d.ts +4 -0
  25. package/dist/elements/branded.d.ts +20 -0
  26. package/dist/elements/date.d.ts +8 -0
  27. package/dist/elements/default.d.ts +10 -0
  28. package/dist/elements/element.d.ts +5 -0
  29. package/dist/elements/id.d.ts +9 -0
  30. package/dist/elements/index.d.ts +9 -0
  31. package/dist/elements/number.d.ts +4 -0
  32. package/dist/elements/object.d.ts +28 -0
  33. package/dist/elements/optional.d.ts +11 -0
  34. package/dist/elements/string-enum.d.ts +11 -0
  35. package/dist/elements/string.d.ts +4 -0
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.js +918 -911
  38. package/dist/model/index.d.ts +3 -0
  39. package/dist/model/model.d.ts +33 -0
  40. package/dist/model/query-builder.d.ts +3 -0
  41. package/dist/model/rtc.d.ts +6 -0
  42. package/dist/rtc/client.d.ts +2 -0
  43. package/dist/rtc/deserializeChanges.d.ts +2 -0
  44. package/dist/rtc/index.d.ts +3 -0
  45. package/dist/rtc/messages.d.ts +20 -0
  46. package/package.json +3 -3
@@ -0,0 +1,3 @@
1
+ export * from "./model";
2
+ export * from "./query-builder";
3
+ export * from "./rtc";
@@ -0,0 +1,33 @@
1
+ import { Subject } from "rxjs";
2
+ import type { ArcCollectionAny, ArcIndexedCollectionAny } from "../collection";
3
+ import type { CollectionChange } from "../collection/collection-change";
4
+ import type { DBAdapterFactory } from "../collection/db";
5
+ import type { CommandsClient } from "../context/commands";
6
+ import { type ArcContextAny, type ArcContextWithCommandsAny } from "../context/context";
7
+ import type { ArcQuery } from "../context/query";
8
+ import type { QueryFactoryFunction } from "./query-builder";
9
+ import type { RealTimeCommunicationAdapterFactory } from "./rtc";
10
+ export declare class ArcModel<C extends ArcContextWithCommandsAny> {
11
+ private context;
12
+ private rtc;
13
+ private dbAdapterPromise;
14
+ changes$: Subject<CollectionChange>;
15
+ constructor(context: C, dbAdapterFactory: DBAdapterFactory, rtcAdapterFactory: RealTimeCommunicationAdapterFactory);
16
+ query(queryFactory: QueryFactoryFunction<C>): ArcQuery;
17
+ private runQuery;
18
+ commands(): CommandsClient<C["commands"]>;
19
+ executeCommand(command: C["commands"][string], ...args: any[]): Promise<{
20
+ changes: CollectionChange[];
21
+ result: any;
22
+ }>;
23
+ private applyChangesForTransaction;
24
+ private notifyChange;
25
+ applyChanges(changes: CollectionChange[]): Promise<void>;
26
+ getCollection(name: string): ArcCollectionAny | ArcIndexedCollectionAny;
27
+ }
28
+ export type ArcModelAny = ArcModel<ArcContextWithCommandsAny>;
29
+ export type ArcModelDependencies<C extends ArcContextAny> = {
30
+ dbAdapterFactory: DBAdapterFactory;
31
+ rtcAdapterFactory: RealTimeCommunicationAdapterFactory;
32
+ };
33
+ export declare function model<C extends ArcContextWithCommandsAny>(context: C, dependencies: ArcModelDependencies<C>): ArcModel<C>;
@@ -0,0 +1,3 @@
1
+ import type { ArcContextAny } from "../context/context";
2
+ import type { ArcQueryBuilder } from "../context/query-builders";
3
+ export type QueryFactoryFunction<C extends ArcContextAny> = (queryBuilder: ReturnType<C["queryBuilder"]>) => ArcQueryBuilder;
@@ -0,0 +1,6 @@
1
+ import type { CollectionChange } from "../collection/collection-change";
2
+ import type { ArcModelAny } from "./model";
3
+ export interface RealTimeCommunicationAdapter {
4
+ commandExecuted(command: string, changes: CollectionChange[]): void;
5
+ }
6
+ export type RealTimeCommunicationAdapterFactory = (model: ArcModelAny) => RealTimeCommunicationAdapter;
@@ -0,0 +1,2 @@
1
+ import type { RealTimeCommunicationAdapterFactory } from "../model/rtc";
2
+ export declare const rtcClientFactory: RealTimeCommunicationAdapterFactory;
@@ -0,0 +1,2 @@
1
+ import type { CollectionChange } from "../collection";
2
+ export declare function deserializeChanges(changes: CollectionChange[], getCollection: (name: string) => any): CollectionChange[];
@@ -0,0 +1,3 @@
1
+ export * from "./client";
2
+ export * from "./deserializeChanges";
3
+ export * from "./messages";
@@ -0,0 +1,20 @@
1
+ import type { CollectionChange } from "../collection";
2
+ export type MessageClientToHost = {
3
+ type: "sync";
4
+ lastDate: string | null;
5
+ } | {
6
+ type: "command-executed";
7
+ command: string;
8
+ changes: CollectionChange[];
9
+ };
10
+ export type MessageHostToClient = {
11
+ type: "sync-result";
12
+ collection: string;
13
+ items: any[];
14
+ } | {
15
+ type: "collection-changes";
16
+ changes: CollectionChange[];
17
+ } | {
18
+ type: "sync-done";
19
+ date: string;
20
+ };
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.1",
7
+ "version": "0.0.3",
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.",
@@ -28,7 +28,7 @@
28
28
  "typescript": "^5.0.0"
29
29
  },
30
30
  "files": [
31
- "dist/*.js",
32
- "dist/*.d.ts"
31
+ "dist/**/*.js",
32
+ "dist/**/*.d.ts"
33
33
  ]
34
34
  }