@arcote.tech/arc 0.0.19 → 0.0.21
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 {
|
|
@@ -890,17 +892,17 @@ class ArcOptional {
|
|
|
890
892
|
}
|
|
891
893
|
parse(value) {
|
|
892
894
|
if (!value)
|
|
893
|
-
return;
|
|
895
|
+
return null;
|
|
894
896
|
return this.parent.parse(value);
|
|
895
897
|
}
|
|
896
898
|
serialize(value) {
|
|
897
899
|
if (value)
|
|
898
900
|
return this.parent.serialize(value);
|
|
899
|
-
return;
|
|
901
|
+
return null;
|
|
900
902
|
}
|
|
901
903
|
deserialize(value) {
|
|
902
904
|
if (!value)
|
|
903
|
-
return;
|
|
905
|
+
return null;
|
|
904
906
|
return this.parent.deserialize(value);
|
|
905
907
|
}
|
|
906
908
|
}
|
|
@@ -1205,14 +1207,16 @@ class ArcStringEnum extends ArcAbstract {
|
|
|
1205
1207
|
// rtc/client.ts
|
|
1206
1208
|
class RTCClient {
|
|
1207
1209
|
storage;
|
|
1210
|
+
token;
|
|
1208
1211
|
_socket;
|
|
1209
1212
|
openSocket;
|
|
1210
1213
|
reconnectAttempts = 0;
|
|
1211
1214
|
maxReconnectAttempts = 5;
|
|
1212
1215
|
syncProgressCallback;
|
|
1213
1216
|
syncPromise = null;
|
|
1214
|
-
constructor(storage) {
|
|
1217
|
+
constructor(storage, token) {
|
|
1215
1218
|
this.storage = storage;
|
|
1219
|
+
this.token = token;
|
|
1216
1220
|
}
|
|
1217
1221
|
async sync(progressCallback) {
|
|
1218
1222
|
if (this.syncPromise)
|
|
@@ -1227,7 +1231,8 @@ class RTCClient {
|
|
|
1227
1231
|
const response = await fetch(`/ws/sync?lastSync=${arcState?.lastSyncDate || ""}`, {
|
|
1228
1232
|
method: "GET",
|
|
1229
1233
|
headers: {
|
|
1230
|
-
"Content-Type": "application/json"
|
|
1234
|
+
"Content-Type": "application/json",
|
|
1235
|
+
Authorization: `Bearer ${this.token}`
|
|
1231
1236
|
}
|
|
1232
1237
|
});
|
|
1233
1238
|
if (!response.ok) {
|
|
@@ -1266,7 +1271,7 @@ class RTCClient {
|
|
|
1266
1271
|
]);
|
|
1267
1272
|
}
|
|
1268
1273
|
async connectWebSocket() {
|
|
1269
|
-
this._socket = new WebSocket(`wss://${window.location.host}/ws`);
|
|
1274
|
+
this._socket = new WebSocket(`wss://${window.location.host}/ws?token=${this.token}`);
|
|
1270
1275
|
this.openSocket = new Promise((resolve) => {
|
|
1271
1276
|
this._socket.addEventListener("open", () => {
|
|
1272
1277
|
this.reconnectAttempts = 0;
|
|
@@ -1313,8 +1318,8 @@ class RTCClient {
|
|
|
1313
1318
|
socket.send(JSON.stringify(message));
|
|
1314
1319
|
}
|
|
1315
1320
|
}
|
|
1316
|
-
var rtcClientFactory = (storage) => {
|
|
1317
|
-
return new RTCClient(storage);
|
|
1321
|
+
var rtcClientFactory = (token) => (storage) => {
|
|
1322
|
+
return new RTCClient(storage, token);
|
|
1318
1323
|
};
|
|
1319
1324
|
// state/query.ts
|
|
1320
1325
|
class ArcStateQuery extends ArcQuery {
|
package/dist/rtc/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RealTimeCommunicationAdapterFactory } from "./rtc";
|
|
2
|
-
export declare const rtcClientFactory: RealTimeCommunicationAdapterFactory;
|
|
2
|
+
export declare const rtcClientFactory: (token: string) => RealTimeCommunicationAdapterFactory;
|
|
3
3
|
//# sourceMappingURL=client.d.ts.map
|
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.21",
|
|
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.",
|