@celljs/ta-host 4.11.0 → 4.13.0
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/README.en.md +3 -2
- package/README.md +3 -2
- package/esm/node/extension-data-notifier.d.ts +3 -0
- package/esm/node/extension-data-notifier.js +8 -2
- package/esm/node/extension-providers.js +1 -1
- package/esm/node/host-protocol.d.ts +20 -1
- package/esm/node/host-protocol.js +1 -0
- package/esm/node/index.d.ts +3 -0
- package/esm/node/index.js +3 -0
- package/esm/node/keep-awake.d.ts +44 -0
- package/esm/node/keep-awake.js +112 -0
- package/esm/node/package-host-extension.js +2 -0
- package/esm/node/package-hosts.d.ts +23 -1
- package/esm/node/package-hosts.js +61 -3
- package/esm/node/relay-bridge.d.ts +37 -3
- package/esm/node/relay-bridge.js +271 -10
- package/esm/node/rooms-bridge.d.ts +13 -2
- package/esm/node/rooms-bridge.js +34 -4
- package/esm/node/session-catalog.d.ts +1 -1
- package/esm/node/session-catalog.js +5 -0
- package/esm/node/session-list-feed.d.ts +11 -1
- package/esm/node/session-list-feed.js +17 -3
- package/esm/node/session-resume.d.ts +52 -0
- package/esm/node/session-resume.js +174 -0
- package/esm/node/settings-store.d.ts +3 -0
- package/esm/node/settings-store.js +22 -0
- package/esm/node/ta-errors.d.ts +1 -0
- package/esm/node/ta-errors.js +4 -0
- package/esm/node/ta-server-impl.d.ts +10 -0
- package/esm/node/ta-server-impl.js +57 -9
- package/esm/node/ta-session-factory.js +5 -2
- package/esm/node/ta-session-registry.d.ts +12 -1
- package/esm/node/ta-session-registry.js +30 -1
- package/esm/node/ta-session.d.ts +3 -0
- package/esm/node/ta-session.js +16 -0
- package/esm/node/team/authority.d.ts +19 -0
- package/esm/node/team/authority.js +79 -0
- package/esm/node/team/call-util.d.ts +23 -0
- package/esm/node/team/call-util.js +88 -0
- package/esm/node/team/connections.d.ts +15 -0
- package/esm/node/team/connections.js +81 -0
- package/esm/node/team/host-team.d.ts +13 -0
- package/esm/node/team/host-team.js +69 -0
- package/esm/node/team/index.d.ts +13 -0
- package/esm/node/team/index.js +14 -0
- package/esm/node/team/member-devices.d.ts +11 -0
- package/esm/node/team/member-devices.js +56 -0
- package/esm/node/team/package-permissions.d.ts +23 -0
- package/esm/node/team/package-permissions.js +75 -0
- package/esm/node/team/principals.d.ts +22 -0
- package/esm/node/team/principals.js +72 -0
- package/esm/node/team/run-actors.d.ts +21 -0
- package/esm/node/team/run-actors.js +100 -0
- package/esm/node/team/shared-data.d.ts +18 -0
- package/esm/node/team/shared-data.js +55 -0
- package/esm/node/team/team-calls.d.ts +33 -0
- package/esm/node/team/team-calls.js +266 -0
- package/esm/node/team/team-gate.d.ts +31 -0
- package/esm/node/team/team-gate.js +177 -0
- package/esm/node/team/team-protocol.d.ts +89 -0
- package/esm/node/team/team-protocol.js +27 -0
- package/esm/node/team/visibility.d.ts +13 -0
- package/esm/node/team/visibility.js +50 -0
- package/esm/node/terminal-service.d.ts +5 -0
- package/esm/node/terminal-service.js +11 -2
- package/lib/node/extension-data-notifier.d.ts +3 -0
- package/lib/node/extension-data-notifier.js +8 -2
- package/lib/node/extension-providers.js +1 -1
- package/lib/node/host-protocol.d.ts +20 -1
- package/lib/node/host-protocol.js +2 -1
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +3 -0
- package/lib/node/keep-awake.d.ts +45 -0
- package/lib/node/keep-awake.js +115 -0
- package/lib/node/package-host-extension.js +2 -0
- package/lib/node/package-hosts.d.ts +23 -1
- package/lib/node/package-hosts.js +60 -2
- package/lib/node/relay-bridge.d.ts +37 -3
- package/lib/node/relay-bridge.js +269 -8
- package/lib/node/rooms-bridge.d.ts +13 -2
- package/lib/node/rooms-bridge.js +34 -4
- package/lib/node/session-catalog.d.ts +1 -1
- package/lib/node/session-catalog.js +5 -0
- package/lib/node/session-list-feed.d.ts +11 -1
- package/lib/node/session-list-feed.js +17 -3
- package/lib/node/session-resume.d.ts +53 -0
- package/lib/node/session-resume.js +177 -0
- package/lib/node/settings-store.d.ts +3 -0
- package/lib/node/settings-store.js +22 -0
- package/lib/node/ta-errors.d.ts +1 -0
- package/lib/node/ta-errors.js +4 -0
- package/lib/node/ta-server-impl.d.ts +10 -0
- package/lib/node/ta-server-impl.js +57 -9
- package/lib/node/ta-session-factory.js +4 -1
- package/lib/node/ta-session-registry.d.ts +12 -1
- package/lib/node/ta-session-registry.js +30 -1
- package/lib/node/ta-session.d.ts +3 -0
- package/lib/node/ta-session.js +16 -0
- package/lib/node/team/authority.d.ts +20 -0
- package/lib/node/team/authority.js +82 -0
- package/lib/node/team/call-util.d.ts +24 -0
- package/lib/node/team/call-util.js +91 -0
- package/lib/node/team/connections.d.ts +16 -0
- package/lib/node/team/connections.js +84 -0
- package/lib/node/team/host-team.d.ts +14 -0
- package/lib/node/team/host-team.js +72 -0
- package/lib/node/team/index.d.ts +14 -0
- package/lib/node/team/index.js +30 -0
- package/lib/node/team/member-devices.d.ts +12 -0
- package/lib/node/team/member-devices.js +59 -0
- package/lib/node/team/package-permissions.d.ts +24 -0
- package/lib/node/team/package-permissions.js +78 -0
- package/lib/node/team/principals.d.ts +23 -0
- package/lib/node/team/principals.js +75 -0
- package/lib/node/team/run-actors.d.ts +22 -0
- package/lib/node/team/run-actors.js +103 -0
- package/lib/node/team/shared-data.d.ts +19 -0
- package/lib/node/team/shared-data.js +58 -0
- package/lib/node/team/team-calls.d.ts +34 -0
- package/lib/node/team/team-calls.js +270 -0
- package/lib/node/team/team-gate.d.ts +32 -0
- package/lib/node/team/team-gate.js +180 -0
- package/lib/node/team/team-protocol.d.ts +90 -0
- package/lib/node/team/team-protocol.js +30 -0
- package/lib/node/team/visibility.d.ts +14 -0
- package/lib/node/team/visibility.js +53 -0
- package/lib/node/terminal-service.d.ts +5 -0
- package/lib/node/terminal-service.js +11 -2
- package/package.json +14 -10
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Server } from 'node:http';
|
|
2
2
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
3
|
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
4
|
-
import { type TaPackageShare, type TaRelayDevice, type TaRelayInfo, TaRelayServer, type TaSharedContent, type TaShareInfo, type TaShareInput, type TaShares } from '@celljs/ta-protocol';
|
|
5
|
-
import { type RelayContentShare, RelayHost, RelayHubs, type RelayPublicIdentity, RelayStore } from '@celljs/ta-relay/lib/node';
|
|
4
|
+
import { type TaExtensionRelays, type TaPackageShare, type TaRelayDevice, type TaRelayFeature, type TaRelayInfo, type TaRelayProbe, TaRelayServer, type TaRelayStore, type TaRelays, type TaRelayType, type TaSharedContent, type TaShareInfo, type TaShareInput, type TaShares } from '@celljs/ta-protocol';
|
|
5
|
+
import { type RelayContentShare, RelayHost, RelayHubs, type RelayPublicIdentity, RelayStore, RelaysFile } from '@celljs/ta-relay/lib/node';
|
|
6
6
|
import { ServerAware } from '@celljs/web/lib/node';
|
|
7
|
-
import { WebExtensionCatalog } from './host-protocol';
|
|
7
|
+
import { KeepAwake, WebExtensionCatalog } from './host-protocol';
|
|
8
8
|
import { type TaAccess } from './ta-access';
|
|
9
9
|
/** The id of {@link RelayBridge}, for TaRelayServerImpl. */
|
|
10
10
|
export declare const RELAY_BRIDGE: unique symbol;
|
|
@@ -16,12 +16,18 @@ export declare const RELAY_BRIDGE: unique symbol;
|
|
|
16
16
|
export declare class RelayBridge implements ServerAware, ApplicationLifecycle<Application> {
|
|
17
17
|
protected readonly access: TaAccess;
|
|
18
18
|
readonly store: RelayStore;
|
|
19
|
+
/** Which relay each feature uses (docs/design/ta-relays.md); without the file, the relay of relay.json or the official one. */
|
|
20
|
+
readonly relays: RelaysFile;
|
|
19
21
|
/** The identity, friends and rooms of this Ta (RoomsBridge runs them): shares with Ta friends need them too. */
|
|
20
22
|
readonly hubs: RelayHubs;
|
|
23
|
+
/** The relay a feature uses now: as relays.json says, else the relay of relay.json (what was used before it), else the official one. */
|
|
24
|
+
relayFor(feature: string): string;
|
|
21
25
|
protected host?: RelayHost;
|
|
22
26
|
/** Content shared by links (TaExtensionHost.shares): kept in the agent directory, handed on by this server, a copy sealed on the relay if asked. */
|
|
23
27
|
readonly shares: TaShares;
|
|
24
28
|
get online(): boolean;
|
|
29
|
+
/** The paired devices connected now (RelayHost.devicesOpen). */
|
|
30
|
+
get devicesOpen(): number;
|
|
25
31
|
/** relay.json changed here: no need to wait for the watch. */
|
|
26
32
|
refresh(): void;
|
|
27
33
|
setServer(server: Server): Promise<void>;
|
|
@@ -35,19 +41,47 @@ export declare class RelayBridge implements ServerAware, ApplicationLifecycle<Ap
|
|
|
35
41
|
protected friendsOf(ids: readonly string[] | undefined): RelayPublicIdentity[];
|
|
36
42
|
protected info(content: RelayContentShare): TaShareInfo;
|
|
37
43
|
protected start(server: Server): void;
|
|
44
|
+
/** The relays, and which one each feature uses. */
|
|
45
|
+
listRelays(): TaRelays;
|
|
46
|
+
/** The types of services packages registered (TaExtensionRelays.registerType), by their names in relays.json. */
|
|
47
|
+
protected readonly types: Map<string, TaRelayType>;
|
|
48
|
+
/** The store of a service of a type a package registered. */
|
|
49
|
+
openStore(id: string): TaRelayStore;
|
|
50
|
+
/**
|
|
51
|
+
* Adds a service of a registered type after trying it: a file written, read back and removed, so that a wrong
|
|
52
|
+
* address or password is said now, not at the first sync.
|
|
53
|
+
*/
|
|
54
|
+
addStore(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
|
|
55
|
+
/** Writes, reads back and removes a small file: whether the store takes what sync will put there. */
|
|
56
|
+
static tryStore(store: TaRelayStore): Promise<number>;
|
|
57
|
+
/** relays.json for the server side of packages (TaExtensionHost.relays). */
|
|
58
|
+
readonly extensionRelays: TaExtensionRelays;
|
|
59
|
+
/** relays.json changed: what connects to relays follows. */
|
|
60
|
+
relaysChanged(): void;
|
|
38
61
|
}
|
|
39
62
|
/** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
|
|
40
63
|
export declare class TaRelayServerImpl implements TaRelayServer {
|
|
41
64
|
protected readonly bridge: RelayBridge;
|
|
42
65
|
protected readonly catalog: WebExtensionCatalog;
|
|
43
66
|
protected readonly environments: ExecEnvironmentFactory;
|
|
67
|
+
protected readonly keepAwake: KeepAwake;
|
|
44
68
|
sharePackage(id: string): Promise<TaPackageShare>;
|
|
45
69
|
unsharePackage(id: string): Promise<void>;
|
|
46
70
|
getRelay(): Promise<TaRelayInfo>;
|
|
71
|
+
setKeepAwake(on: boolean): Promise<void>;
|
|
47
72
|
pair(relay: string, name: string): Promise<{
|
|
48
73
|
link: string;
|
|
49
74
|
device: TaRelayDevice;
|
|
50
75
|
}>;
|
|
51
76
|
unpair(deviceId: string): Promise<void>;
|
|
77
|
+
listRelays(): Promise<TaRelays>;
|
|
78
|
+
addRelay(url: string, name?: string): Promise<string>;
|
|
79
|
+
addFolder(path: string, name?: string): Promise<string>;
|
|
80
|
+
addStore(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
|
|
81
|
+
removeRelay(id: string): Promise<void>;
|
|
82
|
+
chooseRelay(feature: TaRelayFeature, id: string | null): Promise<TaRelays>;
|
|
83
|
+
probeRelay(idOrUrl: string): Promise<TaRelayProbe>;
|
|
84
|
+
/** A change of relays.json; what it refuses is said as the errors of Ta. */
|
|
85
|
+
protected relaysCall<T>(change: () => T): T;
|
|
52
86
|
}
|
|
53
87
|
//# sourceMappingURL=relay-bridge.d.ts.map
|
package/lib/node/relay-bridge.js
CHANGED
|
@@ -36,11 +36,13 @@ const WATCH_INTERVAL_MS = 2000;
|
|
|
36
36
|
let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
37
37
|
constructor() {
|
|
38
38
|
this.store = new node_1.RelayStore(ta_brand_1.TaBrand.agentDir());
|
|
39
|
+
/** Which relay each feature uses (docs/design/ta-relays.md); without the file, the relay of relay.json or the official one. */
|
|
40
|
+
this.relays = new node_1.RelaysFile(ta_brand_1.TaBrand.agentDir());
|
|
39
41
|
/** The identity, friends and rooms of this Ta (RoomsBridge runs them): shares with Ta friends need them too. */
|
|
40
42
|
this.hubs = new node_1.RelayHubs({
|
|
41
43
|
store: new node_1.RelayHubFiles(ta_brand_1.TaBrand.agentDir()),
|
|
42
44
|
name: node_1.RelayHubFiles.userName,
|
|
43
|
-
relay: () =>
|
|
45
|
+
relay: (use) => this.relayFor(use !== null && use !== void 0 ? use : 'rooms'),
|
|
44
46
|
});
|
|
45
47
|
/** Content shared by links (TaExtensionHost.shares): kept in the agent directory, handed on by this server, a copy sealed on the relay if asked. */
|
|
46
48
|
this.shares = {
|
|
@@ -49,12 +51,56 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
49
51
|
remove: async (id) => this.unshare(id),
|
|
50
52
|
open: (link, password) => this.open(link, password),
|
|
51
53
|
};
|
|
54
|
+
/** The types of services packages registered (TaExtensionRelays.registerType), by their names in relays.json. */
|
|
55
|
+
this.types = new Map();
|
|
56
|
+
/** relays.json for the server side of packages (TaExtensionHost.relays). */
|
|
57
|
+
this.extensionRelays = {
|
|
58
|
+
serviceFor: async (feature) => {
|
|
59
|
+
var _a;
|
|
60
|
+
const listed = this.listRelays();
|
|
61
|
+
return ((_a = listed.relays.find(service => service.id === listed.use[feature])) !== null && _a !== void 0 ? _a : { id: '', type: 'ta-relay', url: this.relayFor(feature), builtin: false });
|
|
62
|
+
},
|
|
63
|
+
addFolder: async (path, name) => this.relays.addFolder(path, name),
|
|
64
|
+
list: async () => this.listRelays().relays,
|
|
65
|
+
registerType: (type, definition) => {
|
|
66
|
+
const unregister = node_1.RelayTypes.register(type, { features: ['sync'], key: options => definition.key(options) });
|
|
67
|
+
this.types.set(type, definition);
|
|
68
|
+
return () => {
|
|
69
|
+
unregister();
|
|
70
|
+
if (this.types.get(type) === definition) {
|
|
71
|
+
this.types.delete(type);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
openStore: async (id) => this.openStore(id),
|
|
76
|
+
storeConfig: async (id) => {
|
|
77
|
+
const service = this.relays.services().find(each => each.id === id);
|
|
78
|
+
return service && 'options' in service
|
|
79
|
+
? { type: service.type, options: service.options, ...(service.name ? { name: service.name } : {}) }
|
|
80
|
+
: undefined;
|
|
81
|
+
},
|
|
82
|
+
addStore: (type, options, name) => this.addStore(type, options, name),
|
|
83
|
+
choose: async (feature, id) => {
|
|
84
|
+
this.relays.use(feature, id !== null && id !== void 0 ? id : undefined);
|
|
85
|
+
this.relaysChanged();
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** The relay a feature uses now: as relays.json says, else the relay of relay.json (what was used before it), else the official one. */
|
|
90
|
+
relayFor(feature) {
|
|
91
|
+
return this.relays.urlFor(feature, this.store.read().url);
|
|
52
92
|
}
|
|
53
93
|
get online() {
|
|
54
94
|
var _a;
|
|
55
95
|
var _b;
|
|
56
96
|
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.online) !== null && _b !== void 0 ? _b : false;
|
|
57
97
|
}
|
|
98
|
+
/** The paired devices connected now (RelayHost.devicesOpen). */
|
|
99
|
+
get devicesOpen() {
|
|
100
|
+
var _a;
|
|
101
|
+
var _b;
|
|
102
|
+
return (_b = (_a = this.host) === null || _a === void 0 ? void 0 : _a.devicesOpen) !== null && _b !== void 0 ? _b : 0;
|
|
103
|
+
}
|
|
58
104
|
/** relay.json changed here: no need to wait for the watch. */
|
|
59
105
|
refresh() {
|
|
60
106
|
var _a;
|
|
@@ -87,7 +133,7 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
87
133
|
if (people && people.length === 0) {
|
|
88
134
|
throw new node_1.RelayContentError('people', 'Choose the Ta friends to share it with: none of them is a friend of this Ta.');
|
|
89
135
|
}
|
|
90
|
-
const { content, link } = await this.store.addContent({ ...input, createdAt, people, ...(people ? { identity: await this.hubs.identity() } : {}) }, createdAt);
|
|
136
|
+
const { content, link } = await this.store.addContent({ ...input, createdAt, people, relay: this.relayFor('share'), ...(people ? { identity: await this.hubs.identity() } : {}) }, createdAt);
|
|
91
137
|
if (content.offline) {
|
|
92
138
|
const key = node_1.RelayBytes.fromBase64(content.key);
|
|
93
139
|
try {
|
|
@@ -109,11 +155,11 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
109
155
|
return this.info(content);
|
|
110
156
|
}
|
|
111
157
|
async unshare(id) {
|
|
112
|
-
const
|
|
158
|
+
const config = this.store.read();
|
|
113
159
|
const content = this.store.removeContent(id);
|
|
114
160
|
this.refresh();
|
|
115
161
|
if (content === null || content === void 0 ? void 0 : content.offline) {
|
|
116
|
-
await node_1.RelayBlobClient.remove(
|
|
162
|
+
await node_1.RelayBlobClient.remove(node_1.RelayStore.relayOf(content, config), content.id, content.offline.token).catch(() => undefined);
|
|
117
163
|
}
|
|
118
164
|
return !!content;
|
|
119
165
|
}
|
|
@@ -163,6 +209,105 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
163
209
|
host.start();
|
|
164
210
|
(0, node_fs_1.watchFile)(this.store.file, { interval: WATCH_INTERVAL_MS }, () => host.refresh());
|
|
165
211
|
}
|
|
212
|
+
/** The relays, and which one each feature uses. */
|
|
213
|
+
listRelays() {
|
|
214
|
+
const { config, error } = this.relays.safeRead();
|
|
215
|
+
const services = this.relays.services(config).map(service => {
|
|
216
|
+
const name = service.name ? { name: service.name } : {};
|
|
217
|
+
if (node_1.RelayServiceUtil.isFolder(service)) {
|
|
218
|
+
return { id: service.id, type: 'folder', path: service.path, builtin: false, only: ['sync'], ...name };
|
|
219
|
+
}
|
|
220
|
+
if (node_1.RelayServiceUtil.isRelay(service)) {
|
|
221
|
+
return { id: service.id, type: 'ta-relay', url: service.url, builtin: service.builtin, ...name };
|
|
222
|
+
}
|
|
223
|
+
const options = 'options' in service ? service.options : {};
|
|
224
|
+
const definition = this.types.get(service.type);
|
|
225
|
+
if (!definition) {
|
|
226
|
+
return { id: service.id, type: service.type, builtin: false, only: [], unavailable: true, ...name };
|
|
227
|
+
}
|
|
228
|
+
// What the page sees of it: never a password or a key.
|
|
229
|
+
const secret = new Set(definition.options.filter(option => option.secret).map(option => option.key));
|
|
230
|
+
const shown = Object.fromEntries(Object.entries(options).filter(([key]) => !secret.has(key)));
|
|
231
|
+
return { id: service.id, type: service.type, builtin: false, only: ['sync'], options: shown, where: definition.where(options), ...name };
|
|
232
|
+
});
|
|
233
|
+
const fallback = this.store.read().url;
|
|
234
|
+
// Without relays.json, the relay of relay.json is the one of every feature: listed, as one added.
|
|
235
|
+
if (fallback && !services.some(service => service.url === fallback)) {
|
|
236
|
+
services.push({ id: 'relay-json', type: 'ta-relay', url: fallback, name: new URL(fallback).host, builtin: false });
|
|
237
|
+
}
|
|
238
|
+
const use = Object.fromEntries(node_1.RELAY_FEATURES.map(feature => {
|
|
239
|
+
var _a;
|
|
240
|
+
const service = this.relays.serviceFor(feature, fallback);
|
|
241
|
+
const url = node_1.RelayServiceUtil.isRelay(service) ? service.url : undefined;
|
|
242
|
+
return [feature, service.id || ((_a = services.find(each => each.type === 'ta-relay' && each.url === url)) === null || _a === void 0 ? void 0 : _a.id) || ''];
|
|
243
|
+
}));
|
|
244
|
+
const drives = node_1.RelayServiceUtil.drives().filter(drive => !services.some(service => service.type === 'folder' && service.path === drive.path));
|
|
245
|
+
const types = [...this.types].map(([type, { title, hint, icon, options }]) => ({
|
|
246
|
+
type,
|
|
247
|
+
title,
|
|
248
|
+
...(hint ? { hint } : {}),
|
|
249
|
+
...(icon ? { icon } : {}),
|
|
250
|
+
options,
|
|
251
|
+
}));
|
|
252
|
+
return {
|
|
253
|
+
relays: services,
|
|
254
|
+
use,
|
|
255
|
+
file: this.relays.file,
|
|
256
|
+
...(drives.length ? { drives } : {}),
|
|
257
|
+
...(types.length ? { types } : {}),
|
|
258
|
+
...(error ? { error } : {}),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/** The store of a service of a type a package registered. */
|
|
262
|
+
openStore(id) {
|
|
263
|
+
var _a;
|
|
264
|
+
const service = this.relays.services().find(each => each.id === id);
|
|
265
|
+
if (!service || !('options' in service)) {
|
|
266
|
+
throw new node_1.RelaysConfigError(`There is no store ${id} in relays.json.`);
|
|
267
|
+
}
|
|
268
|
+
const definition = this.types.get(service.type);
|
|
269
|
+
if (!definition) {
|
|
270
|
+
throw new node_1.RelaysConfigError(`${(_a = service.name) !== null && _a !== void 0 ? _a : id} is a service of type ${service.type}: turn on the package that adds it.`);
|
|
271
|
+
}
|
|
272
|
+
return definition.create(service.options);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Adds a service of a registered type after trying it: a file written, read back and removed, so that a wrong
|
|
276
|
+
* address or password is said now, not at the first sync.
|
|
277
|
+
*/
|
|
278
|
+
async addStore(type, options, name) {
|
|
279
|
+
var _a;
|
|
280
|
+
const definition = this.types.get(type);
|
|
281
|
+
if (!definition) {
|
|
282
|
+
throw new node_1.RelaysConfigError(`There is no type ${type}: turn on the package that adds it.`);
|
|
283
|
+
}
|
|
284
|
+
for (const option of definition.options) {
|
|
285
|
+
if (!option.optional && !String((_a = options === null || options === void 0 ? void 0 : options[option.key]) !== null && _a !== void 0 ? _a : '').trim()) {
|
|
286
|
+
throw new node_1.RelaysConfigError(`${option.key} is needed.`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
await RelayBridge_1.tryStore(definition.create(options));
|
|
290
|
+
const id = this.relays.addStore(type, options, name);
|
|
291
|
+
this.relaysChanged();
|
|
292
|
+
return id;
|
|
293
|
+
}
|
|
294
|
+
/** Writes, reads back and removes a small file: whether the store takes what sync will put there. */
|
|
295
|
+
static async tryStore(store) {
|
|
296
|
+
const started = Date.now();
|
|
297
|
+
const path = `ta-sync/.ta-check-${Math.random().toString(36).slice(2, 10)}`;
|
|
298
|
+
const bytes = new TextEncoder().encode('ta');
|
|
299
|
+
await store.write(path, bytes);
|
|
300
|
+
const back = await store.read(path);
|
|
301
|
+
await store.remove(path).catch(() => undefined);
|
|
302
|
+
if (!back || new TextDecoder().decode(back) !== 'ta') {
|
|
303
|
+
throw new node_1.RelaysConfigError('The store took the file but did not give it back.');
|
|
304
|
+
}
|
|
305
|
+
return Date.now() - started;
|
|
306
|
+
}
|
|
307
|
+
/** relays.json changed: what connects to relays follows. */
|
|
308
|
+
relaysChanged() {
|
|
309
|
+
this.refresh();
|
|
310
|
+
}
|
|
166
311
|
};
|
|
167
312
|
exports.RelayBridge = RelayBridge;
|
|
168
313
|
__decorate([
|
|
@@ -172,7 +317,7 @@ __decorate([
|
|
|
172
317
|
exports.RelayBridge = RelayBridge = RelayBridge_1 = __decorate([
|
|
173
318
|
(0, core_1.Component)([exports.RELAY_BRIDGE, node_2.ServerAware, core_1.ApplicationLifecycle])
|
|
174
319
|
], RelayBridge);
|
|
175
|
-
const device = ({ id, name, createdAt }) => ({ id, name, createdAt });
|
|
320
|
+
const device = ({ id, name, createdAt, relay }) => ({ id, name, createdAt, ...(relay ? { relay } : {}) });
|
|
176
321
|
/** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
|
|
177
322
|
let TaRelayServerImpl = class TaRelayServerImpl {
|
|
178
323
|
sharePackage(id) {
|
|
@@ -186,7 +331,7 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
186
331
|
if (size > node_1.RELAY_SHARE_MAX_BYTES) {
|
|
187
332
|
throw ta_errors_1.TaErrors.invalidArgument(`${pkg.name} is ${(size / 1024 / 1024).toFixed(1)} MB packed, more than the ${node_1.RELAY_SHARE_MAX_BYTES / 1024 / 1024} MB a link takes.`, 'Publish it to npm or Git and share that, or export it as a file.');
|
|
188
333
|
}
|
|
189
|
-
const { link, share } = this.bridge.store.shareRoot(pkg.root, pkg.name);
|
|
334
|
+
const { link, share } = this.bridge.store.shareRoot(pkg.root, pkg.name, Date.now(), this.bridge.relayFor('share'));
|
|
190
335
|
this.bridge.refresh();
|
|
191
336
|
return { link: node_1.RelayShareUtil.link(link), expiresAt: share.expiresAt, maxBytes: node_1.RELAY_SHARE_MAX_BYTES };
|
|
192
337
|
});
|
|
@@ -199,8 +344,22 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
199
344
|
});
|
|
200
345
|
}
|
|
201
346
|
async getRelay() {
|
|
202
|
-
const
|
|
203
|
-
|
|
347
|
+
const config = this.bridge.store.read();
|
|
348
|
+
const { devices, keepAwake } = config;
|
|
349
|
+
const relay = this.bridge.relayFor('devices');
|
|
350
|
+
return {
|
|
351
|
+
// The relay a new device goes through; online, whether ta serve is at every relay its devices are on.
|
|
352
|
+
...(devices.length ? { relay } : {}),
|
|
353
|
+
defaultRelay: relay,
|
|
354
|
+
online: this.bridge.online,
|
|
355
|
+
// Those of people let in are theirs, not the user's: ta-team lists them.
|
|
356
|
+
devices: devices.filter(each => !each.member).map(each => device({ ...each, relay: node_1.RelayStore.relayOf(each, config) })),
|
|
357
|
+
...(this.keepAwake.supported ? { keepAwake: keepAwake !== false } : {}),
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
async setKeepAwake(on) {
|
|
361
|
+
this.bridge.store.setKeepAwake(on !== false);
|
|
362
|
+
this.keepAwake.check();
|
|
204
363
|
}
|
|
205
364
|
pair(relay, name) {
|
|
206
365
|
return ta_errors_1.TaErrors.guard(() => {
|
|
@@ -218,6 +377,104 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
218
377
|
this.bridge.store.remove(deviceId);
|
|
219
378
|
this.bridge.refresh();
|
|
220
379
|
}
|
|
380
|
+
async listRelays() {
|
|
381
|
+
return this.bridge.listRelays();
|
|
382
|
+
}
|
|
383
|
+
addRelay(url, name) {
|
|
384
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
385
|
+
var _a;
|
|
386
|
+
let address;
|
|
387
|
+
try {
|
|
388
|
+
address = node_1.RelayInfoUtil.normalize(url);
|
|
389
|
+
}
|
|
390
|
+
catch (_b) {
|
|
391
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${url} is not the address of a relay.`, 'Pass https://<host> of a relay of Ta: one of your own Cloudflare, or ta relay behind HTTPS.');
|
|
392
|
+
}
|
|
393
|
+
const probe = await node_1.RelayInfoUtil.probe(address);
|
|
394
|
+
if (!probe.online) {
|
|
395
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${address} does not answer as a relay of Ta: ${(_a = probe.error) !== null && _a !== void 0 ? _a : 'no answer'}.`, 'Check the address, and that the relay runs.');
|
|
396
|
+
}
|
|
397
|
+
return this.relaysCall(() => this.bridge.relays.add(address, typeof name === 'string' ? name : undefined));
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
addFolder(path, name) {
|
|
401
|
+
return ta_errors_1.TaErrors.guard(async () => this.relaysCall(() => this.bridge.relays.addFolder(String(path !== null && path !== void 0 ? path : ''), typeof name === 'string' ? name : undefined)));
|
|
402
|
+
}
|
|
403
|
+
addStore(type, options, name) {
|
|
404
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
405
|
+
const given = options && typeof options === 'object' ? options : {};
|
|
406
|
+
try {
|
|
407
|
+
return await this.bridge.addStore(String(type !== null && type !== void 0 ? type : ''), given, typeof name === 'string' ? name : undefined);
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
if (error instanceof node_1.RelaysConfigError) {
|
|
411
|
+
throw ta_errors_1.TaErrors.invalidArgument(error.message, 'Check what you filled in, and that the package of the type is on.');
|
|
412
|
+
}
|
|
413
|
+
throw ta_errors_1.TaErrors.invalidArgument(`The store does not take a file: ${error instanceof Error ? error.message : String(error)}`, 'Check the address, the user and the password or keys.');
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
removeRelay(id) {
|
|
418
|
+
return ta_errors_1.TaErrors.guard(async () => this.relaysCall(() => this.bridge.relays.remove(String(id !== null && id !== void 0 ? id : ''))));
|
|
419
|
+
}
|
|
420
|
+
chooseRelay(feature, id) {
|
|
421
|
+
return ta_errors_1.TaErrors.guard(async () => {
|
|
422
|
+
if (!node_1.RELAY_FEATURES.includes(feature)) {
|
|
423
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${feature} is not a feature that goes through a relay.`, `Pass one of ${node_1.RELAY_FEATURES.join(', ')}.`);
|
|
424
|
+
}
|
|
425
|
+
this.relaysCall(() => this.bridge.relays.use(feature, typeof id === 'string' && id ? id : undefined));
|
|
426
|
+
this.bridge.relaysChanged();
|
|
427
|
+
return this.bridge.listRelays();
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
async probeRelay(idOrUrl) {
|
|
431
|
+
var _a, _b, _c;
|
|
432
|
+
const text = String(idOrUrl !== null && idOrUrl !== void 0 ? idOrUrl : '');
|
|
433
|
+
const service = this.bridge.listRelays().relays.find(relay => relay.id === text);
|
|
434
|
+
if ((service === null || service === void 0 ? void 0 : service.type) === 'folder') {
|
|
435
|
+
const started = Date.now();
|
|
436
|
+
const problem = node_1.RelayServiceUtil.checkFolder((_a = service.path) !== null && _a !== void 0 ? _a : '');
|
|
437
|
+
return {
|
|
438
|
+
online: !problem,
|
|
439
|
+
capabilities: ['store'],
|
|
440
|
+
persistent: true,
|
|
441
|
+
path: node_1.RelayServiceUtil.expand((_b = service.path) !== null && _b !== void 0 ? _b : ''),
|
|
442
|
+
ms: Date.now() - started,
|
|
443
|
+
...(problem ? { error: problem } : {}),
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
if (service && service.type !== 'ta-relay') {
|
|
447
|
+
// A store of a package: whether it takes a file now.
|
|
448
|
+
try {
|
|
449
|
+
const ms = await RelayBridge.tryStore(this.bridge.openStore(service.id));
|
|
450
|
+
return { online: true, capabilities: ['store'], persistent: true, ms };
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
return { online: false, capabilities: ['store'], error: error instanceof Error ? error.message : String(error) };
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const url = (_c = service === null || service === void 0 ? void 0 : service.url) !== null && _c !== void 0 ? _c : text;
|
|
457
|
+
const probe = await node_1.RelayInfoUtil.probe(url);
|
|
458
|
+
return {
|
|
459
|
+
online: probe.online,
|
|
460
|
+
...(probe.info ? { capabilities: probe.info.capabilities, limits: probe.info.limits, persistent: probe.info.persistent } : {}),
|
|
461
|
+
...(probe.legacy ? { legacy: true } : {}),
|
|
462
|
+
...(probe.ms !== undefined ? { ms: probe.ms } : {}),
|
|
463
|
+
...(probe.error ? { error: probe.error } : {}),
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
/** A change of relays.json; what it refuses is said as the errors of Ta. */
|
|
467
|
+
relaysCall(change) {
|
|
468
|
+
try {
|
|
469
|
+
return change();
|
|
470
|
+
}
|
|
471
|
+
catch (error) {
|
|
472
|
+
if (error instanceof node_1.RelaysConfigError) {
|
|
473
|
+
throw ta_errors_1.TaErrors.invalidArgument(error.message, `Fix ${this.bridge.relays.file} by hand, or choose otherwise.`);
|
|
474
|
+
}
|
|
475
|
+
throw error;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
221
478
|
};
|
|
222
479
|
exports.TaRelayServerImpl = TaRelayServerImpl;
|
|
223
480
|
__decorate([
|
|
@@ -232,6 +489,10 @@ __decorate([
|
|
|
232
489
|
(0, core_1.Autowired)(ta_exec_1.ExecEnvironmentFactory),
|
|
233
490
|
__metadata("design:type", Object)
|
|
234
491
|
], TaRelayServerImpl.prototype, "environments", void 0);
|
|
492
|
+
__decorate([
|
|
493
|
+
(0, core_1.Autowired)(host_protocol_1.KeepAwake),
|
|
494
|
+
__metadata("design:type", Object)
|
|
495
|
+
], TaRelayServerImpl.prototype, "keepAwake", void 0);
|
|
235
496
|
exports.TaRelayServerImpl = TaRelayServerImpl = __decorate([
|
|
236
497
|
(0, rpc_1.Rpc)(ta_protocol_1.TaRelayServer)
|
|
237
498
|
], TaRelayServerImpl);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
2
2
|
import { type RpcConnection } from '@celljs/rpc/lib/node';
|
|
3
|
-
import { type TaFriend, type TaIdentity, type TaRoomEvent, type TaRoomInfo, type TaRoomRequest, TaRoomServer, type TaRooms, type TaRoomValue, type TaRoomWatch } from '@celljs/ta-protocol';
|
|
3
|
+
import { type TaFriend, type TaFriendRequest, type TaIdentity, type TaRoomEvent, type TaRoomInfo, type TaRoomRequest, TaRoomServer, type TaRooms, type TaRoomValue, type TaRoomWatch } from '@celljs/ta-protocol';
|
|
4
4
|
import type { RelayHubs } from '@celljs/ta-relay/lib/node';
|
|
5
5
|
import { type RelayBridge } from './relay-bridge';
|
|
6
6
|
/** The id of {@link RoomsBridge}. */
|
|
@@ -21,7 +21,7 @@ export declare class RoomsBridge implements ApplicationLifecycle<Application> {
|
|
|
21
21
|
/** `watch` undefined: no more. */
|
|
22
22
|
watch(connection: RpcConnection, watch: TaRoomWatch | undefined): void;
|
|
23
23
|
protected broadcast(event: TaRoomEvent): void;
|
|
24
|
-
protected static identity({ id, name }: TaIdentity): TaIdentity;
|
|
24
|
+
protected static identity({ id, name, shared }: TaIdentity): TaIdentity;
|
|
25
25
|
}
|
|
26
26
|
/** The rooms for clients (TaRoomServer): those of RoomsBridge, what goes wrong said as the errors of Ta. */
|
|
27
27
|
export declare class TaRoomServerImpl implements TaRoomServer {
|
|
@@ -34,6 +34,8 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
34
34
|
kind: string;
|
|
35
35
|
title: string;
|
|
36
36
|
view?: string;
|
|
37
|
+
unlisted?: boolean;
|
|
38
|
+
use?: string;
|
|
37
39
|
}): Promise<TaRoomInfo>;
|
|
38
40
|
invite(room: string, options?: {
|
|
39
41
|
days?: number;
|
|
@@ -54,7 +56,16 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
54
56
|
version: number;
|
|
55
57
|
}>;
|
|
56
58
|
listFriends(): Promise<TaFriend[]>;
|
|
59
|
+
friendLink(renew?: boolean): Promise<{
|
|
60
|
+
link: string;
|
|
61
|
+
expiresAt: number;
|
|
62
|
+
}>;
|
|
63
|
+
addFriend(link: string): Promise<void>;
|
|
64
|
+
offerFriend(room: string, member: string): Promise<void>;
|
|
65
|
+
listFriendRequests(): Promise<TaFriendRequest[]>;
|
|
66
|
+
answerFriend(id: string, accept: boolean): Promise<void>;
|
|
57
67
|
removeFriend(id: string): Promise<boolean>;
|
|
68
|
+
friendRoom(): Promise<TaRoomInfo>;
|
|
58
69
|
watch(messages?: boolean, state?: string[]): Promise<void>;
|
|
59
70
|
unwatch(): Promise<void>;
|
|
60
71
|
}
|
package/lib/node/rooms-bridge.js
CHANGED
|
@@ -42,9 +42,21 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
42
42
|
send: (room, data, to) => this.hubs.send(room, data, to),
|
|
43
43
|
getState: (room, prefix) => this.hubs.getState(room, prefix),
|
|
44
44
|
setState: (room, key, value, version) => this.hubs.setState(room, key, value, version),
|
|
45
|
-
listFriends: async () => this.hubs.
|
|
46
|
-
|
|
45
|
+
listFriends: async () => this.hubs.listFriends(),
|
|
46
|
+
friendLink: renew => this.hubs.friendLink(renew === true),
|
|
47
|
+
addFriend: link => this.hubs.addFriend(link),
|
|
48
|
+
offerFriend: (room, member) => this.hubs.offerFriend(room, member),
|
|
49
|
+
listFriendRequests: async () => this.hubs.friendRequests(),
|
|
50
|
+
answerFriend: (id, accept) => this.hubs.answerFriend(id, accept),
|
|
51
|
+
removeFriend: id => this.hubs.removeFriend(id),
|
|
52
|
+
friendRoom: () => this.hubs.friendRoom(),
|
|
47
53
|
onEvent: listener => this.hubs.onEvent(listener),
|
|
54
|
+
exportIdentity: async () => (await this.hubs.exportIdentity()),
|
|
55
|
+
importIdentity: (bundle, options) => this.hubs.importIdentity(bundle, options !== null && options !== void 0 ? options : {}),
|
|
56
|
+
setIdentityShared: shared => this.hubs.setShared(shared),
|
|
57
|
+
upsertRoom: async (record) => this.hubs.upsert(record),
|
|
58
|
+
forgetRoom: async (room, member) => this.hubs.forget(room, member),
|
|
59
|
+
mergeFriends: async (friends) => this.hubs.mergeFriends(friends),
|
|
48
60
|
};
|
|
49
61
|
}
|
|
50
62
|
get hubs() {
|
|
@@ -78,8 +90,8 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
78
90
|
}
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
|
-
static identity({ id, name }) {
|
|
82
|
-
return { id, name };
|
|
93
|
+
static identity({ id, name, shared }) {
|
|
94
|
+
return { id, name, ...(shared ? { shared } : {}) };
|
|
83
95
|
}
|
|
84
96
|
};
|
|
85
97
|
exports.RoomsBridge = RoomsBridge;
|
|
@@ -137,9 +149,27 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
137
149
|
listFriends() {
|
|
138
150
|
return ta_errors_1.TaErrors.guard(() => this.rooms.listFriends());
|
|
139
151
|
}
|
|
152
|
+
friendLink(renew) {
|
|
153
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.friendLink(renew === true));
|
|
154
|
+
}
|
|
155
|
+
addFriend(link) {
|
|
156
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.addFriend(link));
|
|
157
|
+
}
|
|
158
|
+
offerFriend(room, member) {
|
|
159
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.offerFriend(room, member));
|
|
160
|
+
}
|
|
161
|
+
listFriendRequests() {
|
|
162
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.listFriendRequests());
|
|
163
|
+
}
|
|
164
|
+
answerFriend(id, accept) {
|
|
165
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.answerFriend(id, accept === true));
|
|
166
|
+
}
|
|
140
167
|
removeFriend(id) {
|
|
141
168
|
return ta_errors_1.TaErrors.guard(() => this.rooms.removeFriend(id));
|
|
142
169
|
}
|
|
170
|
+
friendRoom() {
|
|
171
|
+
return ta_errors_1.TaErrors.guard(() => this.rooms.friendRoom());
|
|
172
|
+
}
|
|
143
173
|
async watch(messages, state) {
|
|
144
174
|
this.bridge.watch(node_1.RpcContext.requireConnection(), ta_protocol_1.TaRoomWatchUtil.of(messages !== null && messages !== void 0 ? messages : undefined, state));
|
|
145
175
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CodingAgentOptions } from '@celljs/ai-coding-agent';
|
|
2
|
-
import type
|
|
2
|
+
import { type TaSavedSessionInfo, type TaSavedSessionQuery } from '@celljs/ta-protocol';
|
|
3
3
|
import { TaSessionCatalog } from './host-protocol';
|
|
4
4
|
import { PiDirectories } from './remote/remote-protocol';
|
|
5
5
|
/** What a list shows of a session file, with the directory pi worked in, before it is a location. */
|
|
@@ -14,6 +14,7 @@ const promises_1 = require("node:fs/promises");
|
|
|
14
14
|
const node_path_1 = require("node:path");
|
|
15
15
|
const ai_coding_agent_1 = require("@celljs/ai-coding-agent");
|
|
16
16
|
const core_1 = require("@celljs/core");
|
|
17
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
17
18
|
const host_protocol_1 = require("./host-protocol");
|
|
18
19
|
const remote_protocol_1 = require("./remote/remote-protocol");
|
|
19
20
|
const session_info_util_1 = require("./session-info-util");
|
|
@@ -81,6 +82,7 @@ var SessionCatalogUtil;
|
|
|
81
82
|
let messageCount = 0;
|
|
82
83
|
let updatedAt;
|
|
83
84
|
const marks = [];
|
|
85
|
+
let asking;
|
|
84
86
|
for (const line of text.split('\n')) {
|
|
85
87
|
const entry = parse(line);
|
|
86
88
|
if (!entry) {
|
|
@@ -98,12 +100,14 @@ var SessionCatalogUtil;
|
|
|
98
100
|
}
|
|
99
101
|
else if (entry.type === 'custom') {
|
|
100
102
|
marks.push(entry);
|
|
103
|
+
asking = ta_protocol_1.TaAskUtil.next(asking, entry);
|
|
101
104
|
}
|
|
102
105
|
else if (entry.type === 'message' && entry.message && typeof entry.message === 'object') {
|
|
103
106
|
const message = entry.message;
|
|
104
107
|
messageCount++;
|
|
105
108
|
firstMessage !== null && firstMessage !== void 0 ? firstMessage : (firstMessage = session_info_util_1.SessionInfoUtil.firstMessage([message]));
|
|
106
109
|
messages.push(message);
|
|
110
|
+
asking = ta_protocol_1.TaAskUtil.next(asking, { type: 'message', message });
|
|
107
111
|
if (typeof message.timestamp === 'number') {
|
|
108
112
|
updatedAt = Math.max(updatedAt !== null && updatedAt !== void 0 ? updatedAt : 0, message.timestamp);
|
|
109
113
|
}
|
|
@@ -124,6 +128,7 @@ var SessionCatalogUtil;
|
|
|
124
128
|
createdAt,
|
|
125
129
|
updatedAt: updatedAt !== null && updatedAt !== void 0 ? updatedAt : createdAt,
|
|
126
130
|
group: groupOf(marks),
|
|
131
|
+
asking,
|
|
127
132
|
};
|
|
128
133
|
}
|
|
129
134
|
SessionCatalogUtil.summarize = summarize;
|
|
@@ -17,10 +17,20 @@ interface Watcher {
|
|
|
17
17
|
export declare class SessionListFeed {
|
|
18
18
|
protected readonly list: () => TaSessionInfo[];
|
|
19
19
|
protected readonly intervalMs: number;
|
|
20
|
+
/** What a connection may see of the list: all of it, but for those let in (docs/design/ta-team.md). */
|
|
21
|
+
protected readonly filter: (connection: RpcConnection, list: TaSessionInfo[]) => TaSessionInfo[];
|
|
20
22
|
protected readonly watchers: Map<RpcConnection, Watcher>;
|
|
21
|
-
|
|
23
|
+
/** `Date.now()` time the last connection stopped watching; 0 for none yet. */
|
|
24
|
+
protected leftAt: number;
|
|
25
|
+
constructor(list: () => TaSessionInfo[], intervalMs?: number,
|
|
26
|
+
/** What a connection may see of the list: all of it, but for those let in (docs/design/ta-team.md). */
|
|
27
|
+
filter?: (connection: RpcConnection, list: TaSessionInfo[]) => TaSessionInfo[]);
|
|
22
28
|
/** The list now; the connection is told of each change from now on, until it closes. */
|
|
23
29
|
watch(connection: RpcConnection): TaSessionInfo[];
|
|
30
|
+
/** The connections watching now. */
|
|
31
|
+
get watching(): number;
|
|
32
|
+
/** `Date.now()` time a connection last watched: now while one does; 0 for never. */
|
|
33
|
+
get watchedAt(): number;
|
|
24
34
|
/** What a list shows changed: a session opened or closed, or one of them changed. */
|
|
25
35
|
changed(): void;
|
|
26
36
|
protected schedule(connection: RpcConnection, watcher: Watcher): void;
|