@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.
- package/dist/collection/collection-change.d.ts +17 -0
- package/dist/collection/collection.d.ts +59 -0
- package/dist/collection/db.d.ts +18 -0
- package/dist/collection/index.d.ts +5 -0
- package/dist/collection/queries/abstract-collection-query.d.ts +20 -0
- package/dist/collection/queries/abstract-many-items.d.ts +20 -0
- package/dist/collection/queries/all-items.d.ts +6 -0
- package/dist/collection/queries/indexed.d.ts +13 -0
- package/dist/collection/queries/one-item.d.ts +11 -0
- package/dist/collection/queries/util.d.ts +6 -0
- package/dist/collection/query-builders/abstract-many-items.d.ts +9 -0
- package/dist/collection/query-builders/all-items.d.ts +8 -0
- package/dist/collection/query-builders/indexed.d.ts +10 -0
- package/dist/collection/query-builders/one-item.d.ts +10 -0
- package/dist/context/commands.d.ts +10 -0
- package/dist/context/context.d.ts +31 -0
- package/dist/context/element.d.ts +8 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/query-builders.d.ts +4 -0
- package/dist/context/query.d.ts +3 -0
- package/dist/elements/abstract-primitive.d.ts +7 -0
- package/dist/elements/abstract.d.ts +12 -0
- package/dist/elements/array.d.ts +12 -0
- package/dist/elements/boolean.d.ts +4 -0
- package/dist/elements/branded.d.ts +20 -0
- package/dist/elements/date.d.ts +8 -0
- package/dist/elements/default.d.ts +10 -0
- package/dist/elements/element.d.ts +5 -0
- package/dist/elements/id.d.ts +9 -0
- package/dist/elements/index.d.ts +9 -0
- package/dist/elements/number.d.ts +4 -0
- package/dist/elements/object.d.ts +28 -0
- package/dist/elements/optional.d.ts +11 -0
- package/dist/elements/string-enum.d.ts +11 -0
- package/dist/elements/string.d.ts +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +918 -911
- package/dist/model/index.d.ts +3 -0
- package/dist/model/model.d.ts +33 -0
- package/dist/model/query-builder.d.ts +3 -0
- package/dist/model/rtc.d.ts +6 -0
- package/dist/rtc/client.d.ts +2 -0
- package/dist/rtc/deserializeChanges.d.ts +2 -0
- package/dist/rtc/index.d.ts +3 -0
- package/dist/rtc/messages.d.ts +20 -0
- package/package.json +3 -3
|
@@ -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,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,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.
|
|
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
|
|
32
|
-
"dist
|
|
31
|
+
"dist/**/*.js",
|
|
32
|
+
"dist/**/*.d.ts"
|
|
33
33
|
]
|
|
34
34
|
}
|