@casual-simulation/aux-records 3.2.6 → 3.2.7-alpha.6227012901
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/AIController.d.ts +1 -1
- package/AIGenerateSkyboxInterface.d.ts +1 -1
- package/AuthController.d.ts +53 -1
- package/AuthController.js +117 -1
- package/AuthController.js.map +1 -1
- package/AuthMessenger.d.ts +1 -1
- package/AuthStore.d.ts +5 -1
- package/AuthUtils.d.ts +55 -1
- package/AuthUtils.js +130 -2
- package/AuthUtils.js.map +1 -1
- package/DataRecordsController.d.ts +1 -1
- package/DataRecordsStore.d.ts +1 -1
- package/EventRecordsController.d.ts +1 -1
- package/EventRecordsController.js.map +1 -1
- package/EventRecordsStore.d.ts +1 -1
- package/FileRecordsController.d.ts +1 -1
- package/FileRecordsStore.d.ts +2 -2
- package/LivekitEvents.d.ts +1 -1
- package/MemoryRateLimiter.js +1 -1
- package/MemoryRateLimiter.js.map +1 -1
- package/MemoryStore.d.ts +2 -2
- package/MemoryStore.js +2 -0
- package/MemoryStore.js.map +1 -1
- package/PolicyController.d.ts +1 -1
- package/PolicyController.js.map +1 -1
- package/PolicyPermissions.d.ts +212 -1
- package/PolicyPermissions.js +67 -0
- package/PolicyPermissions.js.map +1 -1
- package/PolicyStore.d.ts +1 -1
- package/RateLimitController.d.ts +3 -1
- package/RateLimitController.js +2 -0
- package/RateLimitController.js.map +1 -1
- package/RecordsController.d.ts +30 -2
- package/RecordsController.js +12 -8
- package/RecordsController.js.map +1 -1
- package/{RecordsHttpServer.d.ts → RecordsServer.d.ts} +35 -5
- package/{RecordsHttpServer.js → RecordsServer.js} +153 -6
- package/RecordsServer.js.map +1 -0
- package/RecordsStore.d.ts +12 -6
- package/SubscriptionConfiguration.d.ts +479 -74
- package/SubscriptionConfiguration.js +34 -1
- package/SubscriptionConfiguration.js.map +1 -1
- package/SubscriptionController.d.ts +1 -1
- package/TestUtils.d.ts +2 -0
- package/TestUtils.js +5 -0
- package/TestUtils.js.map +1 -1
- package/Utils.d.ts +0 -10
- package/Utils.js +0 -19
- package/Utils.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/package.json +6 -3
- package/websockets/InstRecordsStore.d.ts +186 -0
- package/websockets/InstRecordsStore.js +2 -0
- package/websockets/InstRecordsStore.js.map +1 -0
- package/websockets/MemoryInstRecordsStore.d.ts +31 -0
- package/websockets/MemoryInstRecordsStore.js +310 -0
- package/websockets/MemoryInstRecordsStore.js.map +1 -0
- package/websockets/MemoryTempInstRecordsStore.d.ts +31 -0
- package/websockets/MemoryTempInstRecordsStore.js +169 -0
- package/websockets/MemoryTempInstRecordsStore.js.map +1 -0
- package/websockets/MemoryWebsocketConnectionStore.d.ts +33 -0
- package/websockets/MemoryWebsocketConnectionStore.js +169 -0
- package/websockets/MemoryWebsocketConnectionStore.js.map +1 -0
- package/websockets/MemoryWebsocketMessenger.d.ts +21 -0
- package/websockets/MemoryWebsocketMessenger.js +94 -0
- package/websockets/MemoryWebsocketMessenger.js.map +1 -0
- package/websockets/SplitInstRecordsStore.d.ts +21 -0
- package/websockets/SplitInstRecordsStore.js +186 -0
- package/websockets/SplitInstRecordsStore.js.map +1 -0
- package/websockets/TemporaryInstRecordsStore.d.ts +130 -0
- package/websockets/TemporaryInstRecordsStore.js +2 -0
- package/websockets/TemporaryInstRecordsStore.js.map +1 -0
- package/websockets/Utils.d.ts +16 -0
- package/websockets/Utils.js +26 -0
- package/websockets/Utils.js.map +1 -0
- package/websockets/WebsocketConnectionStore.d.ts +141 -0
- package/websockets/WebsocketConnectionStore.js +2 -0
- package/websockets/WebsocketConnectionStore.js.map +1 -0
- package/websockets/WebsocketController.d.ts +97 -0
- package/websockets/WebsocketController.js +707 -0
- package/websockets/WebsocketController.js.map +1 -0
- package/websockets/WebsocketMessenger.d.ts +42 -0
- package/websockets/WebsocketMessenger.js +2 -0
- package/websockets/WebsocketMessenger.js.map +1 -0
- package/websockets/index.d.ts +12 -0
- package/websockets/index.js +12 -0
- package/websockets/index.js.map +1 -0
- package/Errors.d.ts +0 -29
- package/Errors.js +0 -2
- package/Errors.js.map +0 -1
- package/RecordsHttpServer.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the namespace that the given branch should use.
|
|
3
|
+
* @param branch The branch.
|
|
4
|
+
*/
|
|
5
|
+
export declare function branchNamespace(mode: string, recordName: string | null, inst: string, branch: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the namespace that should be used for watching devices connected to branches.
|
|
8
|
+
* @param branch The branch to watch.
|
|
9
|
+
*/
|
|
10
|
+
export declare function watchBranchNamespace(recordName: string | null, inst: string, branch: string): string;
|
|
11
|
+
export declare function branchFromNamespace(mode: string, namespace: string): {
|
|
12
|
+
recordName: string;
|
|
13
|
+
inst: string;
|
|
14
|
+
branch: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the namespace that the given branch should use.
|
|
3
|
+
* @param branch The branch.
|
|
4
|
+
*/
|
|
5
|
+
export function branchNamespace(mode, recordName, inst, branch) {
|
|
6
|
+
return `/${mode}/${recordName !== null && recordName !== void 0 ? recordName : ''}/${inst}/${branch}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Gets the namespace that should be used for watching devices connected to branches.
|
|
10
|
+
* @param branch The branch to watch.
|
|
11
|
+
*/
|
|
12
|
+
export function watchBranchNamespace(recordName, inst, branch) {
|
|
13
|
+
return `/watched_branch/${recordName !== null && recordName !== void 0 ? recordName : ''}/${inst}/${branch}`;
|
|
14
|
+
}
|
|
15
|
+
export function branchFromNamespace(mode, namespace) {
|
|
16
|
+
// e.g. /branch/recordName/inst/branch
|
|
17
|
+
const [recordName, inst, branch] = namespace
|
|
18
|
+
.slice(mode.length + 2)
|
|
19
|
+
.split('/');
|
|
20
|
+
return {
|
|
21
|
+
recordName: recordName === '' ? null : recordName,
|
|
22
|
+
inst,
|
|
23
|
+
branch,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=Utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["Utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC3B,IAAY,EACZ,UAAyB,EACzB,IAAY,EACZ,MAAc;IAEd,OAAO,IAAI,IAAI,IAAI,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAChC,UAAyB,EACzB,IAAY,EACZ,MAAc;IAEd,OAAO,mBAAmB,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,SAAiB;IAC/D,sCAAsC;IACtC,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,SAAS;SACvC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACtB,KAAK,CAAC,GAAG,CAAC,CAAC;IAChB,OAAO;QACH,UAAU,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU;QACjD,IAAI;QACJ,MAAM;KACT,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an interface that defines a connection store for information about available connections.
|
|
3
|
+
*/
|
|
4
|
+
export interface WebsocketConnectionStore {
|
|
5
|
+
/**
|
|
6
|
+
* Saves the given connection to the store.
|
|
7
|
+
* @param connection The connection to save.
|
|
8
|
+
*/
|
|
9
|
+
saveConnection(connection: DeviceConnection): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Saves the given namespace connection to the store.
|
|
12
|
+
* @param connection The connection to save.
|
|
13
|
+
*/
|
|
14
|
+
saveBranchConnection(connection: DeviceBranchConnection): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Deletes the given connection from the store.
|
|
17
|
+
* @param connectionId The ID of the connection.
|
|
18
|
+
* @param mode The mode of the connection.
|
|
19
|
+
* @param recordName The name of the record that the branch exists in.
|
|
20
|
+
* @param inst The name of the inst that the branch exists in.
|
|
21
|
+
* @param branch The name of the branch.
|
|
22
|
+
*/
|
|
23
|
+
deleteBranchConnection(connectionId: string, mode: BranchConnectionMode, recordName: string | null, inst: string, branch: string): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Deletes all the connections with the given connection ID.
|
|
26
|
+
* @param connectionId The ID of the connection.
|
|
27
|
+
*/
|
|
28
|
+
clearConnection(connectionId: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Marks all the connections associated with the given connection ID as expired so that they can be deleted in the future.
|
|
31
|
+
* Works similarly to clearConnection(), but instead of deleting the connection, it marks them as expired.
|
|
32
|
+
*
|
|
33
|
+
* After calling this, the given connection ID will not be present in getConnectionsByNamespace() or countConnections(),
|
|
34
|
+
* but the connection will still be present in getConnection() (until the connection expires).
|
|
35
|
+
*
|
|
36
|
+
* @param connectionId The ID of the connection.
|
|
37
|
+
*/
|
|
38
|
+
expireConnection(connectionId: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets all the connections for the given branch.
|
|
41
|
+
* @param mode The mode of the connections.
|
|
42
|
+
* @param recordName The name of the record that the branch exists in.
|
|
43
|
+
* @param inst The name of the inst that the branch exists in.
|
|
44
|
+
* @param branch The name of the branch.
|
|
45
|
+
*/
|
|
46
|
+
getConnectionsByBranch(mode: BranchConnectionMode, recordName: string | null, inst: string, branch: string): Promise<DeviceBranchConnection[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Counts the number of active connections for the given branch.
|
|
49
|
+
*/
|
|
50
|
+
countConnectionsByBranch(mode: BranchConnectionMode, recordName: string | null, inst: string, branch: string): Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the given connection with the connection ID.
|
|
53
|
+
* @param connectionId The ID of the connection to get.
|
|
54
|
+
*/
|
|
55
|
+
getConnection(connectionId: string): Promise<DeviceConnection>;
|
|
56
|
+
/**
|
|
57
|
+
* Gets the connection for the given connection ID and branch.
|
|
58
|
+
* @param connectionId The ID of the connection to get.
|
|
59
|
+
* @param recordName The name of the record that the branch exists in.
|
|
60
|
+
* @param inst The name of the inst that the branch exists in.
|
|
61
|
+
* @param branch The name of the branch.
|
|
62
|
+
*/
|
|
63
|
+
getBranchConnection(connectionId: string, mode: BranchConnectionMode, recordName: string | null, inst: string, branch: string): Promise<DeviceBranchConnection>;
|
|
64
|
+
/**
|
|
65
|
+
* Gets the list of connections that are present for the given connection ID.
|
|
66
|
+
* @param connectionId The ID of the connection.
|
|
67
|
+
*/
|
|
68
|
+
getConnections(connectionId: string): Promise<DeviceBranchConnection[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Counts the number of active connections.
|
|
71
|
+
*/
|
|
72
|
+
countConnections(): Promise<number>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the last time that the connection rate limit was exceeded for the given connection ID.
|
|
75
|
+
* @param connectionId The ID of the connection.
|
|
76
|
+
*/
|
|
77
|
+
getConnectionRateLimitExceededTime(connectionId: string): Promise<number | null>;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the last time that the connection rate limit was exceeded for the given connection ID.
|
|
80
|
+
* @param connectionId The ID of the connection.
|
|
81
|
+
* @param timeMs The unix time in miliseconds.
|
|
82
|
+
*/
|
|
83
|
+
setConnectionRateLimitExceededTime(connectionId: string, timeMs: number | null): Promise<void>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Defines an interface that represents the connection of a device to the apiary.
|
|
87
|
+
*/
|
|
88
|
+
export interface DeviceConnection {
|
|
89
|
+
/**
|
|
90
|
+
* The server-created ID of the connection.
|
|
91
|
+
*/
|
|
92
|
+
serverConnectionId: string;
|
|
93
|
+
/**
|
|
94
|
+
* The client-created ID of the connection.
|
|
95
|
+
*/
|
|
96
|
+
clientConnectionId: string;
|
|
97
|
+
/**
|
|
98
|
+
* The ID of the user that the connection is associated with.
|
|
99
|
+
*/
|
|
100
|
+
userId: string;
|
|
101
|
+
/**
|
|
102
|
+
* The ID of the session that the user used to connect.
|
|
103
|
+
*/
|
|
104
|
+
sessionId: string;
|
|
105
|
+
/**
|
|
106
|
+
* The token that the device is using.
|
|
107
|
+
*/
|
|
108
|
+
token: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Defines a list of modes that a connection can be in.
|
|
112
|
+
* - "branch": The connection is connected to a branch.
|
|
113
|
+
* - "watch": The connection is watching a branch for connection changes.
|
|
114
|
+
*/
|
|
115
|
+
export type BranchConnectionMode = 'branch' | 'watch_branch';
|
|
116
|
+
/**
|
|
117
|
+
* Defines an interface that represents the connection of a device to a branch.
|
|
118
|
+
*/
|
|
119
|
+
export interface DeviceBranchConnection extends DeviceConnection {
|
|
120
|
+
/**
|
|
121
|
+
* The mode of the connection.
|
|
122
|
+
*/
|
|
123
|
+
mode: BranchConnectionMode;
|
|
124
|
+
/**
|
|
125
|
+
* The name of the record that the device is connected to.
|
|
126
|
+
*/
|
|
127
|
+
recordName: string | null;
|
|
128
|
+
/**
|
|
129
|
+
* The name of the inst that the device is connected to.
|
|
130
|
+
*/
|
|
131
|
+
inst: string;
|
|
132
|
+
/**
|
|
133
|
+
* The name of the branch that the device is connected to.
|
|
134
|
+
*/
|
|
135
|
+
branch: string;
|
|
136
|
+
/**
|
|
137
|
+
* Whether the data stored by the connection is supposed to be temporary.
|
|
138
|
+
*/
|
|
139
|
+
temporary: boolean;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=WebsocketConnectionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebsocketConnectionStore.js","sourceRoot":"","sources":["WebsocketConnectionStore.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { StoredAux } from '@casual-simulation/aux-common/bots';
|
|
2
|
+
import { WebsocketMessenger } from './WebsocketMessenger';
|
|
3
|
+
import { DeviceSelector } from '@casual-simulation/aux-common/common/RemoteActions';
|
|
4
|
+
import { DeviceConnection, WebsocketConnectionStore } from './WebsocketConnectionStore';
|
|
5
|
+
import { AddUpdatesMessage, LoginMessage, SendActionMessage, TimeSyncRequestMessage, UploadHttpHeaders, WatchBranchMessage, WebsocketErrorEvent, WebsocketEvent } from '@casual-simulation/aux-common/websockets/WebsocketEvents';
|
|
6
|
+
import { ConnectionInfo } from '@casual-simulation/aux-common/common/ConnectionInfo';
|
|
7
|
+
import { AuthController } from '../AuthController';
|
|
8
|
+
import { InstRecordsStore } from './InstRecordsStore';
|
|
9
|
+
import { TemporaryInstRecordsStore } from './TemporaryInstRecordsStore';
|
|
10
|
+
import { ZodIssue } from 'zod';
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class that is able to serve causal repos in realtime.
|
|
13
|
+
*/
|
|
14
|
+
export declare class WebsocketController {
|
|
15
|
+
private _connectionStore;
|
|
16
|
+
private _messenger;
|
|
17
|
+
private _instStore;
|
|
18
|
+
private _temporaryStore;
|
|
19
|
+
private _auth;
|
|
20
|
+
/**
|
|
21
|
+
* Gets or sets the default device selector that should be used
|
|
22
|
+
* for events that are sent without a selector.
|
|
23
|
+
*/
|
|
24
|
+
defaultDeviceSelector: DeviceSelector;
|
|
25
|
+
mergeUpdatesOnMaxSizeExceeded: boolean;
|
|
26
|
+
get messenger(): WebsocketMessenger;
|
|
27
|
+
constructor(connectionStore: WebsocketConnectionStore, messenger: WebsocketMessenger, instStore: InstRecordsStore, temporaryInstStore: TemporaryInstRecordsStore, auth: AuthController);
|
|
28
|
+
/**
|
|
29
|
+
* Attempts to log the given connection in.
|
|
30
|
+
* @param connectionId The ID of the connection.
|
|
31
|
+
* @param requestId The ID of the request.
|
|
32
|
+
* @param message The login message.
|
|
33
|
+
*/
|
|
34
|
+
login(connectionId: string, requestId: number, message: LoginMessage): Promise<void>;
|
|
35
|
+
disconnect(connectionId: string): Promise<void>;
|
|
36
|
+
watchBranch(connectionId: string, event: WatchBranchMessage): Promise<void>;
|
|
37
|
+
private _getOrCreateInst;
|
|
38
|
+
private _getOrCreateBranch;
|
|
39
|
+
unwatchBranch(connectionId: string, recordName: string | null, inst: string, branch: string): Promise<void>;
|
|
40
|
+
addUpdates(connectionId: string, event: AddUpdatesMessage): Promise<void>;
|
|
41
|
+
sendAction(connectionId: string, event: SendActionMessage): Promise<void>;
|
|
42
|
+
watchBranchDevices(connectionId: string, recordName: string | null, inst: string, branch: string): Promise<void>;
|
|
43
|
+
unwatchBranchDevices(connectionId: string, recordName: string | null, inst: string, branch: string): Promise<void>;
|
|
44
|
+
deviceCount(connectionId: string, recordName: string | null, inst: string | null, branch: string | null): Promise<void>;
|
|
45
|
+
getBranchData(recordName: string | null, inst: string, branch: string): Promise<StoredAux>;
|
|
46
|
+
getUpdates(connectionId: string, recordName: string | null, inst: string, branch: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Processes a webhook and returns the status code that should be returned.
|
|
49
|
+
* @param branch The branch that the webhook is for.
|
|
50
|
+
* @param method The HTTP method that was used for the webhook.
|
|
51
|
+
* @param url The URL that was requested.
|
|
52
|
+
* @param headers The headers that were included in the request.
|
|
53
|
+
* @param data The data included in the request.
|
|
54
|
+
*/
|
|
55
|
+
webhook(recordName: string | null, inst: string, branch: string, method: string, url: string, headers: object, data: object): Promise<number>;
|
|
56
|
+
syncTime(connectionId: string, event: TimeSyncRequestMessage, requestTime: number): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Handles when the rate limit has been exceeded by the given connection.
|
|
59
|
+
* @param connectionId The ID of the connection.
|
|
60
|
+
* @param retryAfter The Retry-After header value.
|
|
61
|
+
* @param totalHits The total number of hits by the connection.
|
|
62
|
+
* @param timeMs The current time in unix time in miliseconds.
|
|
63
|
+
*/
|
|
64
|
+
rateLimitExceeded(connectionId: string, retryAfter: number, totalHits: number, timeMs: number): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Processes the given upload request.
|
|
67
|
+
* @param connectionId The ID of the connection that is requesting the upload.
|
|
68
|
+
* @param requestId The ID of the request.
|
|
69
|
+
*/
|
|
70
|
+
uploadRequest(connectionId: string, requestId: number): Promise<void>;
|
|
71
|
+
downloadRequest(connectionId: string, requestId: number, url: string, method: string, headers: UploadHttpHeaders): Promise<DownloadRequestResult>;
|
|
72
|
+
sendError(connectionId: string, error: WebsocketControllerError): Promise<void>;
|
|
73
|
+
sendEvent(connectionId: string, event: WebsocketEvent): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
export declare function connectionInfo(device: DeviceConnection): ConnectionInfo;
|
|
76
|
+
/**
|
|
77
|
+
* Determines if the given event targets the given device connection.
|
|
78
|
+
* @param event The event to check.
|
|
79
|
+
* @param device The device to check.
|
|
80
|
+
*/
|
|
81
|
+
export declare function isEventForDevice(event: DeviceSelector, device: DeviceConnection): boolean;
|
|
82
|
+
export type DownloadRequestResult = DownloadRequestSuccess | DownloadRequestFailure;
|
|
83
|
+
export interface DownloadRequestSuccess {
|
|
84
|
+
success: true;
|
|
85
|
+
requestId: number;
|
|
86
|
+
message: string;
|
|
87
|
+
}
|
|
88
|
+
export interface DownloadRequestFailure extends WebsocketControllerError {
|
|
89
|
+
success: false;
|
|
90
|
+
}
|
|
91
|
+
export interface WebsocketControllerError {
|
|
92
|
+
requestId: number;
|
|
93
|
+
errorCode: WebsocketErrorEvent[2];
|
|
94
|
+
errorMessage: string;
|
|
95
|
+
issues?: ZodIssue[];
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=WebsocketController.d.ts.map
|