@trakit/sync 0.0.5 → 0.0.7
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/API/Constants.d.ts +8 -0
- package/API/Functions.d.ts +42 -0
- package/API/TrakitBaseCommander.d.ts +70 -0
- package/API/TrakitObjectCommander.d.ts +1317 -0
- package/LICENSE +661 -0
- package/README.md +21 -0
- package/RESTful/Constants.d.ts +36 -0
- package/RESTful/TrakitRestfulCommander.d.ts +52 -0
- package/Synchronization/Functions.d.ts +15 -0
- package/Synchronization/TrakitSyncCommander.d.ts +136 -0
- package/WebSocket/Constants.d.ts +17 -0
- package/WebSocket/Functions.d.ts +8 -0
- package/WebSocket/SubscribedRegions.d.ts +50 -0
- package/WebSocket/TrakitSocketCommander.d.ts +161 -0
- package/index.d.ts +21 -0
- package/package.json +7 -1
- package/trakit-sync.min.js +7 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Payload, Reply } from "@trakit/commands";
|
|
2
|
+
import { codified, email, guid, JsonObject, JsonValue, nothing, SyncName, ulong } from "@trakit/objects";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a standardized error response.
|
|
5
|
+
* @param ex The error to include in the response.
|
|
6
|
+
* @returns A standardized error response object.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createClientErrorResponse(ex: Error, response?: JsonValue): JsonObject;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the name of the identifying key for the given Trak-iT Object type.
|
|
11
|
+
* @param type
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function getJsonKeyName(type: SyncName): "login" | "code" | "handle" | "key" | "guid" | "id";
|
|
15
|
+
/**
|
|
16
|
+
* Returns the value of the identifying key for the given Trak-iT Object.
|
|
17
|
+
* @param json
|
|
18
|
+
* @param type
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export declare function getJsonKeyValue(json: JsonObject, type: SyncName): ulong | guid | email | codified | string;
|
|
22
|
+
/**
|
|
23
|
+
* Translated type name to object name to account for some legacy message names.
|
|
24
|
+
* @param typeName
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function makeObjectName(typeName: string): SyncName;
|
|
28
|
+
/**
|
|
29
|
+
* Factory to create Payload classes based on type name.
|
|
30
|
+
* @param type SyncName representing the type of the payload.
|
|
31
|
+
* @param suffix Optional suffix to append to the class name. Defaults to "Get".
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function makePayloadClass(type: SyncName, suffix?: string | nothing): (new (json: JsonObject) => Payload) | nothing;
|
|
35
|
+
/**
|
|
36
|
+
* Factory to create Reply classes based on type name.
|
|
37
|
+
* @param type SyncName representing the type of the reply.
|
|
38
|
+
* @param suffix Optional suffix to append to the class name. Defaults to "Get".
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function makeReplyClass(type: SyncName, suffix?: string | nothing): (new (json: JsonObject) => Reply) | nothing;
|
|
42
|
+
//# sourceMappingURL=Functions.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Payload, Reply, RepSelfGet } from '@trakit/commands';
|
|
2
|
+
import { guid, Machine, nothing, url } from '@trakit/objects';
|
|
3
|
+
/**
|
|
4
|
+
* The base class used to help define interaction with all Trak-iT API services.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class TrakitBaseCommander<TRequest> {
|
|
7
|
+
/**
|
|
8
|
+
* Details of the {@link User} or {@link Machine} who is connected to the underlying Trak-iT API service.
|
|
9
|
+
*/
|
|
10
|
+
account: RepSelfGet;
|
|
11
|
+
/**
|
|
12
|
+
* {@link url} of the underlying Trak-iT API service.
|
|
13
|
+
*/
|
|
14
|
+
baseAddress: URL | null;
|
|
15
|
+
/**
|
|
16
|
+
* Additional (optional) values added to the query-string of the connection request.
|
|
17
|
+
*/
|
|
18
|
+
readonly query: Map<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Additional (optional) HTTP headers added to the connection request.
|
|
21
|
+
*/
|
|
22
|
+
readonly headers: Map<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the {@link baseAddress} with the appropriate path, query values.
|
|
25
|
+
* @param path Optional path to append to the base address.
|
|
26
|
+
* @returns The constructed URL string.
|
|
27
|
+
*/
|
|
28
|
+
protected createBaseUrl(path?: URL | url | nothing): URL;
|
|
29
|
+
constructor(account?: RepSelfGet | {
|
|
30
|
+
machine: {
|
|
31
|
+
key: string;
|
|
32
|
+
};
|
|
33
|
+
} | Machine | {
|
|
34
|
+
key: string;
|
|
35
|
+
} | {
|
|
36
|
+
ghostId: guid;
|
|
37
|
+
} | guid | nothing, baseAddress?: URL | url | nothing);
|
|
38
|
+
/**
|
|
39
|
+
* Sets the authentication mechanism using either a session id or a Machine object.
|
|
40
|
+
* @param account The session id (string), {@link Machine} object, or {@link RepSelfGet} object.
|
|
41
|
+
*/
|
|
42
|
+
setAuth(account?: RepSelfGet | {
|
|
43
|
+
machine: {
|
|
44
|
+
key: string;
|
|
45
|
+
};
|
|
46
|
+
} | Machine | {
|
|
47
|
+
key: string;
|
|
48
|
+
} | {
|
|
49
|
+
ghostId: guid;
|
|
50
|
+
} | guid | nothing): void;
|
|
51
|
+
/**
|
|
52
|
+
* Sends a command to the underlying service, and returns a Promise that completes when a reply is received.
|
|
53
|
+
* @param payload The payload to send to the service.
|
|
54
|
+
* @returns A promise that settles based on the underlying service's response.
|
|
55
|
+
*/
|
|
56
|
+
command<TReply extends Reply>(payload: Payload): Promise<TReply>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a request object to send to the underlying service.
|
|
59
|
+
* @param payload The payload to send to the underlying service.
|
|
60
|
+
* @returns The request object to send to the underlying service.
|
|
61
|
+
*/
|
|
62
|
+
abstract _createRequest(payload: Payload): TRequest;
|
|
63
|
+
/**
|
|
64
|
+
* Sends a request to the underlying service, and returns a Promise that completes when a reply is received.
|
|
65
|
+
* @param request The request object to send to the service.
|
|
66
|
+
* @returns A promise that resolves for any response, and rejects for client-side and transport errors.
|
|
67
|
+
*/
|
|
68
|
+
abstract _relayRequest(request: TRequest): Promise<any>;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=TrakitBaseCommander.d.ts.map
|