@gravity-rail/sdk 10.0.0 → 11.0.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.md +25 -32
- package/dist/{account-DEA-f-I9.d.cts → account-D4dzqsFS.d.cts} +0 -2
- package/dist/{account-DEA-f-I9.d.ts → account-D4dzqsFS.d.ts} +0 -2
- package/dist/{agent_team-Baa7AvKF.d.ts → bot_team-CHU0j4Lb.d.ts} +163 -149
- package/dist/{agent_team-EdLmOQDL.d.cts → bot_team-DCnHRLBa.d.cts} +163 -149
- package/dist/{chunk-MWTQXZGB.js → chunk-NCMT36JY.js} +1 -1
- package/dist/chunk-NCMT36JY.js.map +1 -0
- package/dist/{chunk-XTB2HFSI.js → chunk-X6A3URGV.js} +158 -223
- package/dist/chunk-X6A3URGV.js.map +1 -0
- package/dist/{client-BaF3v-ux.d.ts → client-7gZX_34u.d.cts} +643 -967
- package/dist/{client-Cb9pM31S.d.cts → client-Bkn4Vb3I.d.ts} +643 -967
- package/dist/helpers.d.cts +3 -3
- package/dist/helpers.d.ts +3 -3
- package/dist/index.cjs +173 -236
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -8
- package/dist/index.d.ts +11 -8
- package/dist/index.js +18 -17
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +166 -223
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +124 -66
- package/dist/internal.d.ts +124 -66
- package/dist/internal.js +10 -4
- package/dist/internal.js.map +1 -1
- package/dist/{member-import-Bq_eC7gx.d.ts → member-import-B-ym1Ks1.d.ts} +4 -4
- package/dist/{member-import-_zu58M9w.d.cts → member-import-CVeZLZGP.d.cts} +4 -4
- package/dist/realtime.cjs +25 -11
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +28 -9
- package/dist/realtime.d.ts +28 -9
- package/dist/realtime.js +23 -10
- package/dist/realtime.js.map +1 -1
- package/dist/schemas.cjs +8 -66
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +18 -93
- package/dist/schemas.d.ts +18 -93
- package/dist/schemas.js +9 -59
- package/dist/schemas.js.map +1 -1
- package/dist/{tasks-DssYoZDt.d.ts → tasks-C_uMyhuO.d.cts} +52 -99
- package/dist/{tasks-yScacy3c.d.cts → tasks-Dv0rAk5j.d.ts} +52 -99
- package/package.json +1 -1
- package/dist/chunk-MWTQXZGB.js.map +0 -1
- package/dist/chunk-XTB2HFSI.js.map +0 -1
package/dist/realtime.d.cts
CHANGED
|
@@ -25,6 +25,7 @@ import { AccountResponseAvatarIcon, AccountResponseAvatarColor } from './interna
|
|
|
25
25
|
/** The `protocol.init` frame, before either subclass narrows it. */
|
|
26
26
|
interface ProtocolInitMessage {
|
|
27
27
|
memberId?: unknown;
|
|
28
|
+
teammateId?: unknown;
|
|
28
29
|
accountUuid?: unknown;
|
|
29
30
|
workspaceUuids?: unknown;
|
|
30
31
|
}
|
|
@@ -152,28 +153,41 @@ declare abstract class RealtimeSocketClient<TSession extends RealtimeSessionBase
|
|
|
152
153
|
*
|
|
153
154
|
* The socket state machine — login, heartbeat, reconnect, subscribe retry —
|
|
154
155
|
* lives in {@link RealtimeSocketClient}, shared with the account client. This
|
|
155
|
-
* file is what is specific to the workspace mount: its URL, and the
|
|
156
|
-
* `protocol.init` hands back.
|
|
156
|
+
* file is what is specific to the workspace mount: its URL, and the acting
|
|
157
|
+
* principal `protocol.init` hands back.
|
|
157
158
|
*/
|
|
158
159
|
|
|
160
|
+
/**
|
|
161
|
+
* The principal the server authenticated a workspace socket as: a teammate
|
|
162
|
+
* (staff, no Member row) or a participant Member. Exactly one kind.
|
|
163
|
+
*/
|
|
164
|
+
type WorkspaceSocketActor = {
|
|
165
|
+
kind: 'teammate';
|
|
166
|
+
teammateId: number;
|
|
167
|
+
} | {
|
|
168
|
+
kind: 'member';
|
|
169
|
+
memberId: number;
|
|
170
|
+
};
|
|
171
|
+
/** `"teammate:<id>"` or `"member:<id>"`, the same key `/w/{uuid}/me` yields. */
|
|
172
|
+
declare function workspaceSocketActorKey(actor: WorkspaceSocketActor): string;
|
|
159
173
|
/** Build the workspace realtime WebSocket URL from session config. */
|
|
160
174
|
declare function buildWorkspaceWsUrl(session: RealtimeAuthSession): string;
|
|
161
175
|
declare class WorkspaceRealtimeClient extends RealtimeSocketClient<RealtimeAuthSession> {
|
|
162
|
-
private
|
|
176
|
+
private actor;
|
|
163
177
|
protected buildUrl(session: RealtimeAuthSession): string;
|
|
164
178
|
protected readProtocolInit(msg: ProtocolInitMessage): void;
|
|
165
179
|
protected clearIdentity(): void;
|
|
166
180
|
protected sessionRequiresReconnect(previous: RealtimeAuthSession | null, next: RealtimeAuthSession): boolean;
|
|
167
181
|
/**
|
|
168
|
-
*
|
|
182
|
+
* The principal the server authenticated this socket as, or null before
|
|
169
183
|
* `protocol.init` arrives.
|
|
170
184
|
*
|
|
171
185
|
* Channels whose Redis key is workspace-wide can carry events addressed to
|
|
172
|
-
* one
|
|
186
|
+
* one teammate (presence acks, for example). Consumers compare the event's
|
|
173
187
|
* addressee against this so a reply meant for another operator cannot be
|
|
174
188
|
* applied locally.
|
|
175
189
|
*/
|
|
176
|
-
|
|
190
|
+
getActor(): WorkspaceSocketActor | null;
|
|
177
191
|
}
|
|
178
192
|
declare function initWorkspaceSocket(session: RealtimeAuthSession): void;
|
|
179
193
|
declare function subscribeWorkspaceChannel(channel: string, listener: ChannelListener): Unsubscribe;
|
|
@@ -258,7 +272,12 @@ type EditorCollaboratorKind = 'member' | 'manager';
|
|
|
258
272
|
interface EditorCollaborator {
|
|
259
273
|
/** `manager` draws the Manager mark; its `memberId` is the person it acts for. */
|
|
260
274
|
kind: EditorCollaboratorKind;
|
|
261
|
-
|
|
275
|
+
/** `"teammate:<id>"` or `"member:<id>"`: one person across their tabs. */
|
|
276
|
+
actorKey: string;
|
|
277
|
+
/** Set for a Member; null for a teammate. */
|
|
278
|
+
memberId: number | null;
|
|
279
|
+
/** Set for a teammate; null for a Member. */
|
|
280
|
+
teammateId: number | null;
|
|
262
281
|
name: string | null;
|
|
263
282
|
/** The image to draw, if any; null means draw the icon or the initials. */
|
|
264
283
|
avatarUrl: string | null;
|
|
@@ -399,5 +418,5 @@ declare class OperatorSessionClient {
|
|
|
399
418
|
private closeSession;
|
|
400
419
|
}
|
|
401
420
|
|
|
402
|
-
export { AccountRealtimeClient, AccountRealtimeSession, ChannelEvent, ChannelListener, LOGIN_TOKEN_TIMEOUT_MS, OperatorCallPhase, OperatorSessionClient, OperatorSessionState, OrgAuthRequirement, OrgSessionsUpdate, RealtimeAuthSession, RealtimeSessionBase, RealtimeSocketClient, Unsubscribe, WorkspaceRealtimeClient, buildAccountWsUrl, buildWorkspaceWsUrl, editorCollaborationChannel, editorCollaborationItemKey, initAccountSocket, initWorkspaceSocket, isAccountSocketConnected, isWorkspaceSocketConnected, onAccountSocketConnection, onWorkspaceSocketConnection, parseEditorCollaborationEvent, subscribeAccountChannel, subscribeWorkspaceChannel, workspaceChannel };
|
|
403
|
-
export type { CollaboratorsChangedEvent, EditorCollaborationEvent, EditorCollaborationItem, EditorCollaborationItemKind, EditorCollaborationResource, EditorCollaborator, EditorCollaboratorKind, EditorUpdatedEvent, OperatorSessionHandlers, ProtocolInitMessage };
|
|
421
|
+
export { AccountRealtimeClient, AccountRealtimeSession, ChannelEvent, ChannelListener, LOGIN_TOKEN_TIMEOUT_MS, OperatorCallPhase, OperatorSessionClient, OperatorSessionState, OrgAuthRequirement, OrgSessionsUpdate, RealtimeAuthSession, RealtimeSessionBase, RealtimeSocketClient, Unsubscribe, WorkspaceRealtimeClient, buildAccountWsUrl, buildWorkspaceWsUrl, editorCollaborationChannel, editorCollaborationItemKey, initAccountSocket, initWorkspaceSocket, isAccountSocketConnected, isWorkspaceSocketConnected, onAccountSocketConnection, onWorkspaceSocketConnection, parseEditorCollaborationEvent, subscribeAccountChannel, subscribeWorkspaceChannel, workspaceChannel, workspaceSocketActorKey };
|
|
422
|
+
export type { CollaboratorsChangedEvent, EditorCollaborationEvent, EditorCollaborationItem, EditorCollaborationItemKind, EditorCollaborationResource, EditorCollaborator, EditorCollaboratorKind, EditorUpdatedEvent, OperatorSessionHandlers, ProtocolInitMessage, WorkspaceSocketActor };
|
package/dist/realtime.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { AccountResponseAvatarIcon, AccountResponseAvatarColor } from './interna
|
|
|
25
25
|
/** The `protocol.init` frame, before either subclass narrows it. */
|
|
26
26
|
interface ProtocolInitMessage {
|
|
27
27
|
memberId?: unknown;
|
|
28
|
+
teammateId?: unknown;
|
|
28
29
|
accountUuid?: unknown;
|
|
29
30
|
workspaceUuids?: unknown;
|
|
30
31
|
}
|
|
@@ -152,28 +153,41 @@ declare abstract class RealtimeSocketClient<TSession extends RealtimeSessionBase
|
|
|
152
153
|
*
|
|
153
154
|
* The socket state machine — login, heartbeat, reconnect, subscribe retry —
|
|
154
155
|
* lives in {@link RealtimeSocketClient}, shared with the account client. This
|
|
155
|
-
* file is what is specific to the workspace mount: its URL, and the
|
|
156
|
-
* `protocol.init` hands back.
|
|
156
|
+
* file is what is specific to the workspace mount: its URL, and the acting
|
|
157
|
+
* principal `protocol.init` hands back.
|
|
157
158
|
*/
|
|
158
159
|
|
|
160
|
+
/**
|
|
161
|
+
* The principal the server authenticated a workspace socket as: a teammate
|
|
162
|
+
* (staff, no Member row) or a participant Member. Exactly one kind.
|
|
163
|
+
*/
|
|
164
|
+
type WorkspaceSocketActor = {
|
|
165
|
+
kind: 'teammate';
|
|
166
|
+
teammateId: number;
|
|
167
|
+
} | {
|
|
168
|
+
kind: 'member';
|
|
169
|
+
memberId: number;
|
|
170
|
+
};
|
|
171
|
+
/** `"teammate:<id>"` or `"member:<id>"`, the same key `/w/{uuid}/me` yields. */
|
|
172
|
+
declare function workspaceSocketActorKey(actor: WorkspaceSocketActor): string;
|
|
159
173
|
/** Build the workspace realtime WebSocket URL from session config. */
|
|
160
174
|
declare function buildWorkspaceWsUrl(session: RealtimeAuthSession): string;
|
|
161
175
|
declare class WorkspaceRealtimeClient extends RealtimeSocketClient<RealtimeAuthSession> {
|
|
162
|
-
private
|
|
176
|
+
private actor;
|
|
163
177
|
protected buildUrl(session: RealtimeAuthSession): string;
|
|
164
178
|
protected readProtocolInit(msg: ProtocolInitMessage): void;
|
|
165
179
|
protected clearIdentity(): void;
|
|
166
180
|
protected sessionRequiresReconnect(previous: RealtimeAuthSession | null, next: RealtimeAuthSession): boolean;
|
|
167
181
|
/**
|
|
168
|
-
*
|
|
182
|
+
* The principal the server authenticated this socket as, or null before
|
|
169
183
|
* `protocol.init` arrives.
|
|
170
184
|
*
|
|
171
185
|
* Channels whose Redis key is workspace-wide can carry events addressed to
|
|
172
|
-
* one
|
|
186
|
+
* one teammate (presence acks, for example). Consumers compare the event's
|
|
173
187
|
* addressee against this so a reply meant for another operator cannot be
|
|
174
188
|
* applied locally.
|
|
175
189
|
*/
|
|
176
|
-
|
|
190
|
+
getActor(): WorkspaceSocketActor | null;
|
|
177
191
|
}
|
|
178
192
|
declare function initWorkspaceSocket(session: RealtimeAuthSession): void;
|
|
179
193
|
declare function subscribeWorkspaceChannel(channel: string, listener: ChannelListener): Unsubscribe;
|
|
@@ -258,7 +272,12 @@ type EditorCollaboratorKind = 'member' | 'manager';
|
|
|
258
272
|
interface EditorCollaborator {
|
|
259
273
|
/** `manager` draws the Manager mark; its `memberId` is the person it acts for. */
|
|
260
274
|
kind: EditorCollaboratorKind;
|
|
261
|
-
|
|
275
|
+
/** `"teammate:<id>"` or `"member:<id>"`: one person across their tabs. */
|
|
276
|
+
actorKey: string;
|
|
277
|
+
/** Set for a Member; null for a teammate. */
|
|
278
|
+
memberId: number | null;
|
|
279
|
+
/** Set for a teammate; null for a Member. */
|
|
280
|
+
teammateId: number | null;
|
|
262
281
|
name: string | null;
|
|
263
282
|
/** The image to draw, if any; null means draw the icon or the initials. */
|
|
264
283
|
avatarUrl: string | null;
|
|
@@ -399,5 +418,5 @@ declare class OperatorSessionClient {
|
|
|
399
418
|
private closeSession;
|
|
400
419
|
}
|
|
401
420
|
|
|
402
|
-
export { AccountRealtimeClient, AccountRealtimeSession, ChannelEvent, ChannelListener, LOGIN_TOKEN_TIMEOUT_MS, OperatorCallPhase, OperatorSessionClient, OperatorSessionState, OrgAuthRequirement, OrgSessionsUpdate, RealtimeAuthSession, RealtimeSessionBase, RealtimeSocketClient, Unsubscribe, WorkspaceRealtimeClient, buildAccountWsUrl, buildWorkspaceWsUrl, editorCollaborationChannel, editorCollaborationItemKey, initAccountSocket, initWorkspaceSocket, isAccountSocketConnected, isWorkspaceSocketConnected, onAccountSocketConnection, onWorkspaceSocketConnection, parseEditorCollaborationEvent, subscribeAccountChannel, subscribeWorkspaceChannel, workspaceChannel };
|
|
403
|
-
export type { CollaboratorsChangedEvent, EditorCollaborationEvent, EditorCollaborationItem, EditorCollaborationItemKind, EditorCollaborationResource, EditorCollaborator, EditorCollaboratorKind, EditorUpdatedEvent, OperatorSessionHandlers, ProtocolInitMessage };
|
|
421
|
+
export { AccountRealtimeClient, AccountRealtimeSession, ChannelEvent, ChannelListener, LOGIN_TOKEN_TIMEOUT_MS, OperatorCallPhase, OperatorSessionClient, OperatorSessionState, OrgAuthRequirement, OrgSessionsUpdate, RealtimeAuthSession, RealtimeSessionBase, RealtimeSocketClient, Unsubscribe, WorkspaceRealtimeClient, buildAccountWsUrl, buildWorkspaceWsUrl, editorCollaborationChannel, editorCollaborationItemKey, initAccountSocket, initWorkspaceSocket, isAccountSocketConnected, isWorkspaceSocketConnected, onAccountSocketConnection, onWorkspaceSocketConnection, parseEditorCollaborationEvent, subscribeAccountChannel, subscribeWorkspaceChannel, workspaceChannel, workspaceSocketActorKey };
|
|
422
|
+
export type { CollaboratorsChangedEvent, EditorCollaborationEvent, EditorCollaborationItem, EditorCollaborationItemKind, EditorCollaborationResource, EditorCollaborator, EditorCollaboratorKind, EditorUpdatedEvent, OperatorSessionHandlers, ProtocolInitMessage, WorkspaceSocketActor };
|
package/dist/realtime.js
CHANGED
|
@@ -574,36 +574,45 @@ var RealtimeSocketClient = class {
|
|
|
574
574
|
};
|
|
575
575
|
|
|
576
576
|
// src/realtime/workspace-client.ts
|
|
577
|
+
function workspaceSocketActorKey(actor) {
|
|
578
|
+
return actor.kind === "teammate" ? `teammate:${actor.teammateId}` : `member:${actor.memberId}`;
|
|
579
|
+
}
|
|
580
|
+
function readActor(msg) {
|
|
581
|
+
const isId = (value) => typeof value === "number" && Number.isInteger(value);
|
|
582
|
+
if (isId(msg.teammateId)) return { kind: "teammate", teammateId: msg.teammateId };
|
|
583
|
+
if (isId(msg.memberId)) return { kind: "member", memberId: msg.memberId };
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
577
586
|
function buildWorkspaceWsUrl(session) {
|
|
578
587
|
const isSsl = session.apiUrl.startsWith("https");
|
|
579
588
|
const host = session.apiUrl.replace(/^https?:\/\//, "");
|
|
580
589
|
return `${isSsl ? "wss" : "ws"}://${host}/api/v2/w/${session.workspaceUuid}/ws/realtime`;
|
|
581
590
|
}
|
|
582
591
|
var WorkspaceRealtimeClient = class extends RealtimeSocketClient {
|
|
583
|
-
|
|
592
|
+
actor = null;
|
|
584
593
|
buildUrl(session) {
|
|
585
594
|
return buildWorkspaceWsUrl(session);
|
|
586
595
|
}
|
|
587
596
|
readProtocolInit(msg) {
|
|
588
|
-
this.
|
|
597
|
+
this.actor = readActor(msg);
|
|
589
598
|
}
|
|
590
599
|
clearIdentity() {
|
|
591
|
-
this.
|
|
600
|
+
this.actor = null;
|
|
592
601
|
}
|
|
593
602
|
sessionRequiresReconnect(previous, next) {
|
|
594
603
|
return super.sessionRequiresReconnect(previous, next) || previous?.workspaceUuid !== next.workspaceUuid;
|
|
595
604
|
}
|
|
596
605
|
/**
|
|
597
|
-
*
|
|
606
|
+
* The principal the server authenticated this socket as, or null before
|
|
598
607
|
* `protocol.init` arrives.
|
|
599
608
|
*
|
|
600
609
|
* Channels whose Redis key is workspace-wide can carry events addressed to
|
|
601
|
-
* one
|
|
610
|
+
* one teammate (presence acks, for example). Consumers compare the event's
|
|
602
611
|
* addressee against this so a reply meant for another operator cannot be
|
|
603
612
|
* applied locally.
|
|
604
613
|
*/
|
|
605
|
-
|
|
606
|
-
return this.
|
|
614
|
+
getActor() {
|
|
615
|
+
return this.actor;
|
|
607
616
|
}
|
|
608
617
|
};
|
|
609
618
|
var defaultClient = new WorkspaceRealtimeClient();
|
|
@@ -702,14 +711,17 @@ function editorCollaborationItemKey(item) {
|
|
|
702
711
|
function parseCollaborator(value) {
|
|
703
712
|
if (typeof value !== "object" || value === null) return null;
|
|
704
713
|
const record = value;
|
|
705
|
-
if (typeof record.
|
|
714
|
+
if (typeof record.actorKey !== "string" || record.actorKey === "") return null;
|
|
715
|
+
const isId = (value2) => typeof value2 === "number" && Number.isInteger(value2);
|
|
706
716
|
const name = record.name;
|
|
707
717
|
const avatarUrl = record.avatarUrl;
|
|
708
718
|
const avatarIcon = record.avatarIcon;
|
|
709
719
|
const avatarColor = record.avatarColor;
|
|
710
720
|
return {
|
|
711
721
|
kind: record.kind === "manager" ? "manager" : "member",
|
|
712
|
-
|
|
722
|
+
actorKey: record.actorKey,
|
|
723
|
+
memberId: isId(record.memberId) ? record.memberId : null,
|
|
724
|
+
teammateId: isId(record.teammateId) ? record.teammateId : null,
|
|
713
725
|
name: typeof name === "string" ? name : null,
|
|
714
726
|
avatarUrl: typeof avatarUrl === "string" ? avatarUrl : null,
|
|
715
727
|
avatarIcon: typeof avatarIcon === "string" && avatarIcon in AccountResponseAvatarIcon ? avatarIcon : null,
|
|
@@ -1268,6 +1280,7 @@ export {
|
|
|
1268
1280
|
parseOrgAuthRequirements,
|
|
1269
1281
|
subscribeAccountChannel,
|
|
1270
1282
|
subscribeWorkspaceChannel,
|
|
1271
|
-
workspaceChannel
|
|
1283
|
+
workspaceChannel,
|
|
1284
|
+
workspaceSocketActorKey
|
|
1272
1285
|
};
|
|
1273
1286
|
//# sourceMappingURL=realtime.js.map
|