@gravity-rail/sdk 9.2.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.
Files changed (44) hide show
  1. package/README.md +25 -32
  2. package/dist/{account-DLwJWX9b.d.cts → account-D4dzqsFS.d.cts} +1 -3
  3. package/dist/{account-DLwJWX9b.d.ts → account-D4dzqsFS.d.ts} +1 -3
  4. package/dist/{agent_team-C4ZYR_m1.d.ts → bot_team-CHU0j4Lb.d.ts} +163 -149
  5. package/dist/{agent_team-C6FdNgYH.d.cts → bot_team-DCnHRLBa.d.cts} +163 -149
  6. package/dist/{chunk-MWTQXZGB.js → chunk-NCMT36JY.js} +1 -1
  7. package/dist/chunk-NCMT36JY.js.map +1 -0
  8. package/dist/{chunk-7LQYEV5Y.js → chunk-X6A3URGV.js} +177 -231
  9. package/dist/chunk-X6A3URGV.js.map +1 -0
  10. package/dist/{client-DVF3qwNq.d.ts → client-7gZX_34u.d.cts} +713 -988
  11. package/dist/{client-DwslF70Y.d.cts → client-Bkn4Vb3I.d.ts} +713 -988
  12. package/dist/helpers.d.cts +3 -3
  13. package/dist/helpers.d.ts +3 -3
  14. package/dist/index.cjs +192 -244
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +11 -8
  17. package/dist/index.d.ts +11 -8
  18. package/dist/index.js +18 -17
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal.cjs +185 -231
  21. package/dist/internal.cjs.map +1 -1
  22. package/dist/internal.d.cts +160 -66
  23. package/dist/internal.d.ts +160 -66
  24. package/dist/internal.js +10 -4
  25. package/dist/internal.js.map +1 -1
  26. package/dist/{member-import-BpcX-swC.d.ts → member-import-B-ym1Ks1.d.ts} +4 -4
  27. package/dist/{member-import-CA9YWv3Y.d.cts → member-import-CVeZLZGP.d.cts} +4 -4
  28. package/dist/realtime.cjs +25 -11
  29. package/dist/realtime.cjs.map +1 -1
  30. package/dist/realtime.d.cts +28 -9
  31. package/dist/realtime.d.ts +28 -9
  32. package/dist/realtime.js +23 -10
  33. package/dist/realtime.js.map +1 -1
  34. package/dist/schemas.cjs +8 -66
  35. package/dist/schemas.cjs.map +1 -1
  36. package/dist/schemas.d.cts +35 -110
  37. package/dist/schemas.d.ts +35 -110
  38. package/dist/schemas.js +9 -59
  39. package/dist/schemas.js.map +1 -1
  40. package/dist/{tasks-BGLfmf5y.d.ts → tasks-C_uMyhuO.d.cts} +56 -100
  41. package/dist/{tasks-BZb3rt5m.d.cts → tasks-Dv0rAk5j.d.ts} +56 -100
  42. package/package.json +1 -1
  43. package/dist/chunk-7LQYEV5Y.js.map +0 -1
  44. package/dist/chunk-MWTQXZGB.js.map +0 -1
@@ -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 member id
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 memberId;
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
- * Member id the server authenticated this socket as, or null before
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 member (presence acks, for example). Consumers compare the event's
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
- getMemberId(): number | null;
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
- memberId: number;
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 };
@@ -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 member id
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 memberId;
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
- * Member id the server authenticated this socket as, or null before
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 member (presence acks, for example). Consumers compare the event's
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
- getMemberId(): number | null;
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
- memberId: number;
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
- memberId = null;
592
+ actor = null;
584
593
  buildUrl(session) {
585
594
  return buildWorkspaceWsUrl(session);
586
595
  }
587
596
  readProtocolInit(msg) {
588
- this.memberId = typeof msg.memberId === "number" ? msg.memberId : null;
597
+ this.actor = readActor(msg);
589
598
  }
590
599
  clearIdentity() {
591
- this.memberId = null;
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
- * Member id the server authenticated this socket as, or null before
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 member (presence acks, for example). Consumers compare the event's
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
- getMemberId() {
606
- return this.memberId;
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.memberId !== "number" || !Number.isInteger(record.memberId)) return null;
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
- memberId: record.memberId,
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