@abloatai/transaction 0.59.1 → 0.60.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 (166) hide show
  1. package/dist/auth/apiKey.d.ts +10 -11
  2. package/dist/auth/apiKey.d.ts.map +1 -1
  3. package/dist/auth/apiKey.js +15 -29
  4. package/dist/auth/apiKey.js.map +1 -1
  5. package/dist/auth/browserCredentialSafety.js +1 -1
  6. package/dist/auth/browserCredentialSafety.js.map +1 -1
  7. package/dist/auth/capabilityLifecycle.d.ts +1 -1
  8. package/dist/auth/capabilityLifecycle.d.ts.map +1 -1
  9. package/dist/auth/capabilityLifecycle.js +2 -1
  10. package/dist/auth/capabilityLifecycle.js.map +1 -1
  11. package/dist/auth/credentialEndpoint.js +1 -1
  12. package/dist/auth/credentialEndpoint.js.map +1 -1
  13. package/dist/auth/credentialResult.d.ts +2 -1
  14. package/dist/auth/credentialResult.d.ts.map +1 -1
  15. package/dist/auth/credentialResult.js.map +1 -1
  16. package/dist/claims/events.d.ts +1 -1
  17. package/dist/claims/events.d.ts.map +1 -1
  18. package/dist/client/ablo.d.ts +15 -11
  19. package/dist/client/ablo.d.ts.map +1 -1
  20. package/dist/client/ablo.js +5 -14
  21. package/dist/client/ablo.js.map +1 -1
  22. package/dist/client/resources/httpResources.d.ts +1 -169
  23. package/dist/client/resources/httpResources.d.ts.map +1 -1
  24. package/dist/client/resources/httpResources.js +1 -1
  25. package/dist/client/resources/httpResources.js.map +1 -1
  26. package/dist/client/resources/modelOperations.d.ts +0 -9
  27. package/dist/client/resources/modelOperations.d.ts.map +1 -1
  28. package/dist/client/surface.d.ts +2 -2
  29. package/dist/client/surface.d.ts.map +1 -1
  30. package/dist/client/surface.js +8 -3
  31. package/dist/client/surface.js.map +1 -1
  32. package/dist/commit/contract.d.ts +10 -10
  33. package/dist/commit/recordRuntime.d.ts +3 -2
  34. package/dist/commit/recordRuntime.d.ts.map +1 -1
  35. package/dist/commit/recordRuntime.js +1 -0
  36. package/dist/commit/recordRuntime.js.map +1 -1
  37. package/dist/coordination/index.d.ts +2 -2
  38. package/dist/coordination/index.d.ts.map +1 -1
  39. package/dist/coordination/index.js +3 -4
  40. package/dist/coordination/index.js.map +1 -1
  41. package/dist/coordination/schema.d.ts +3 -47
  42. package/dist/coordination/schema.d.ts.map +1 -1
  43. package/dist/coordination/schema.js +7 -69
  44. package/dist/coordination/schema.js.map +1 -1
  45. package/dist/errorCodes.d.ts +2 -2
  46. package/dist/errorCodes.d.ts.map +1 -1
  47. package/dist/errorCodes.js +5 -9
  48. package/dist/errorCodes.js.map +1 -1
  49. package/dist/errors.d.ts.map +1 -1
  50. package/dist/errors.js +16 -1
  51. package/dist/errors.js.map +1 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/sessions/client.d.ts +29 -0
  56. package/dist/sessions/client.d.ts.map +1 -0
  57. package/dist/sessions/client.js +69 -0
  58. package/dist/sessions/client.js.map +1 -0
  59. package/dist/sessions/contract.d.ts +97 -0
  60. package/dist/sessions/contract.d.ts.map +1 -0
  61. package/dist/sessions/contract.js +5 -0
  62. package/dist/sessions/contract.js.map +1 -0
  63. package/dist/{auth/sessionMint.d.ts → sessions/create.d.ts} +4 -4
  64. package/dist/sessions/create.d.ts.map +1 -0
  65. package/dist/{auth/sessionMint.js → sessions/create.js} +11 -10
  66. package/dist/sessions/create.js.map +1 -0
  67. package/dist/sessions/handler.d.ts +23 -0
  68. package/dist/sessions/handler.d.ts.map +1 -0
  69. package/dist/sessions/handler.js +55 -0
  70. package/dist/sessions/handler.js.map +1 -0
  71. package/dist/sessions/index.d.ts +14 -0
  72. package/dist/sessions/index.d.ts.map +1 -0
  73. package/dist/sessions/index.js +14 -0
  74. package/dist/sessions/index.js.map +1 -0
  75. package/dist/{transport/connection/credentialLifecycle.d.ts → sessions/lifecycle.d.ts} +6 -6
  76. package/dist/sessions/lifecycle.d.ts.map +1 -0
  77. package/dist/{transport/connection/credentialLifecycle.js → sessions/lifecycle.js} +5 -5
  78. package/dist/sessions/lifecycle.js.map +1 -0
  79. package/dist/sessions/source.d.ts +24 -0
  80. package/dist/sessions/source.d.ts.map +1 -0
  81. package/dist/sessions/source.js +56 -0
  82. package/dist/sessions/source.js.map +1 -0
  83. package/dist/transport/connection/index.d.ts +0 -1
  84. package/dist/transport/connection/index.d.ts.map +1 -1
  85. package/dist/transport/connection/index.js +0 -1
  86. package/dist/transport/connection/index.js.map +1 -1
  87. package/dist/transport/connection/manager.d.ts +1 -1
  88. package/dist/transport/connection/manager.d.ts.map +1 -1
  89. package/dist/transport/http/client.d.ts +44 -16
  90. package/dist/transport/http/client.d.ts.map +1 -1
  91. package/dist/transport/http/client.js +125 -12
  92. package/dist/transport/http/client.js.map +1 -1
  93. package/dist/transport/http/options.d.ts +4 -1
  94. package/dist/transport/http/options.d.ts.map +1 -1
  95. package/dist/transport/http/transport.d.ts +25 -10
  96. package/dist/transport/http/transport.d.ts.map +1 -1
  97. package/dist/transport/http/transport.js +102 -56
  98. package/dist/transport/http/transport.js.map +1 -1
  99. package/dist/transport/websocket/commitFrames.d.ts +5 -5
  100. package/dist/transport/websocket/commitFrames.d.ts.map +1 -1
  101. package/dist/transport/websocket/commitFrames.js +1 -0
  102. package/dist/transport/websocket/commitFrames.js.map +1 -1
  103. package/dist/transport/websocket/contextSubscription.d.ts +6 -0
  104. package/dist/transport/websocket/contextSubscription.d.ts.map +1 -0
  105. package/dist/transport/websocket/contextSubscription.js +45 -0
  106. package/dist/transport/websocket/contextSubscription.js.map +1 -0
  107. package/dist/transport/websocket/frameHandlers.d.ts +0 -14
  108. package/dist/transport/websocket/frameHandlers.d.ts.map +1 -1
  109. package/dist/transport/websocket/frameHandlers.js +1 -71
  110. package/dist/transport/websocket/frameHandlers.js.map +1 -1
  111. package/dist/transport/websocket/session.d.ts +4 -0
  112. package/dist/transport/websocket/session.d.ts.map +1 -0
  113. package/dist/transport/websocket/session.js +425 -0
  114. package/dist/transport/websocket/session.js.map +1 -0
  115. package/dist/transport/websocket/sessionContract.d.ts +78 -0
  116. package/dist/transport/websocket/sessionContract.d.ts.map +1 -0
  117. package/dist/transport/websocket/sessionContract.js +2 -0
  118. package/dist/transport/websocket/sessionContract.js.map +1 -0
  119. package/dist/transport/websocket/transport.d.ts +27 -42
  120. package/dist/transport/websocket/transport.d.ts.map +1 -1
  121. package/dist/transport/websocket/transport.js +77 -102
  122. package/dist/transport/websocket/transport.js.map +1 -1
  123. package/dist/wire/inboundFrames.d.ts +0 -10
  124. package/dist/wire/inboundFrames.d.ts.map +1 -1
  125. package/dist/wire/inboundFrames.js +1 -6
  126. package/dist/wire/inboundFrames.js.map +1 -1
  127. package/package.json +7 -1
  128. package/src/auth/apiKey.ts +25 -44
  129. package/src/auth/browserCredentialSafety.ts +1 -1
  130. package/src/auth/capabilityLifecycle.ts +3 -2
  131. package/src/auth/credentialEndpoint.ts +1 -1
  132. package/src/auth/credentialResult.ts +2 -0
  133. package/src/claims/events.ts +1 -2
  134. package/src/client/ablo.ts +23 -13
  135. package/src/client/resources/httpResources.ts +2 -174
  136. package/src/client/resources/modelOperations.ts +0 -10
  137. package/src/client/surface.ts +9 -4
  138. package/src/commit/recordRuntime.ts +4 -2
  139. package/src/coordination/index.ts +2 -9
  140. package/src/coordination/schema.ts +7 -81
  141. package/src/errorCodes.ts +8 -13
  142. package/src/errors.ts +18 -1
  143. package/src/index.ts +1 -0
  144. package/src/sessions/client.ts +121 -0
  145. package/src/sessions/contract.ts +116 -0
  146. package/src/{auth/sessionMint.ts → sessions/create.ts} +13 -12
  147. package/src/sessions/handler.ts +96 -0
  148. package/src/sessions/index.ts +13 -0
  149. package/src/{transport/connection/credentialLifecycle.ts → sessions/lifecycle.ts} +5 -5
  150. package/src/sessions/source.ts +94 -0
  151. package/src/transport/connection/index.ts +0 -1
  152. package/src/transport/connection/manager.ts +1 -1
  153. package/src/transport/http/client.ts +183 -26
  154. package/src/transport/http/options.ts +4 -1
  155. package/src/transport/http/transport.ts +140 -78
  156. package/src/transport/websocket/commitFrames.ts +5 -5
  157. package/src/transport/websocket/contextSubscription.ts +55 -0
  158. package/src/transport/websocket/frameHandlers.ts +0 -102
  159. package/src/transport/websocket/session.ts +522 -0
  160. package/src/transport/websocket/sessionContract.ts +106 -0
  161. package/src/transport/websocket/transport.ts +85 -137
  162. package/src/wire/inboundFrames.ts +0 -6
  163. package/dist/auth/sessionMint.d.ts.map +0 -1
  164. package/dist/auth/sessionMint.js.map +0 -1
  165. package/dist/transport/connection/credentialLifecycle.d.ts.map +0 -1
  166. package/dist/transport/connection/credentialLifecycle.js.map +0 -1
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Session subsystem.
3
+ *
4
+ * Start here and descend into the public contract, issuance, server handler,
5
+ * source normalization, or credential lifecycle. Transports consume the
6
+ * normalized access contract and do not reconstruct session policy.
7
+ */
8
+ export * from './contract.js';
9
+ export * from './client.js';
10
+ export * from './create.js';
11
+ export * from './handler.js';
12
+ export * from './source.js';
13
+ export * from './lifecycle.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sessions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Session subsystem.
3
+ *
4
+ * Start here and descend into the public contract, issuance, server handler,
5
+ * source normalization, or credential lifecycle. Transports consume the
6
+ * normalized access contract and do not reconstruct session policy.
7
+ */
8
+ export * from './contract.js';
9
+ export * from './client.js';
10
+ export * from './create.js';
11
+ export * from './handler.js';
12
+ export * from './source.js';
13
+ export * from './lifecycle.js';
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sessions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Keeps the short-lived access credential fresh. It owns the re-mint hook, a
3
3
  * single-flight guard that stops concurrent triggers from minting more than
4
- * once, and a browser-only proactive refresh — a timer plus an OS-wake listener
5
- * — that renews the credential ahead of expiry. It reaches the rest of the
4
+ * once, and proactive refresh — an expiry-aware timer plus a browser OS-wake
5
+ * listener — that renews the credential ahead of expiry. It reaches the rest of the
6
6
  * client only through the small {@link CredentialLifecycleContext} interface,
7
7
  * so the two can reference each other without an import cycle.
8
8
  */
9
- import type { RecoveryClass } from '../../errorCodes.js';
10
- import { type Logger } from '../../logger.js';
11
- import { type CredentialProvider, type CredentialProviderResult } from '../../auth/credentialResult.js';
9
+ import type { RecoveryClass } from '../errorCodes.js';
10
+ import { type Logger } from '../logger.js';
11
+ import { type CredentialProvider, type CredentialProviderResult } from '../auth/credentialResult.js';
12
12
  /**
13
13
  * Tri-state outcome of a credential re-mint, mirroring the `getToken`
14
14
  * contract (see {@link CredentialLifecycle.refresh}).
@@ -175,4 +175,4 @@ export declare class CredentialLifecycle {
175
175
  /** Tear down the proactive credential lifecycle (idempotent). */
176
176
  stop(): void;
177
177
  }
178
- //# sourceMappingURL=credentialLifecycle.d.ts.map
178
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/sessions/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OA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E,0BAA0B,EAC/B,MAAM,GAAE,MAAmB;IAG9C;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,mBAAmB,GAAG,IAAI,GAAG,IAAI;IAIzD,kFAAkF;IAClF,MAAM,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO;IAShD;;;;;;;;;;;;;;;OAeG;IACG,OAAO,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAkDlD;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAmB3B;;;;;;;;;;;;;;;OAeG;IACG,wBAAwB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAY3F;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,QAAQ,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;IAqFhF,iEAAiE;IACjE,IAAI,IAAI,IAAI;CAIb"}
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Keeps the short-lived access credential fresh. It owns the re-mint hook, a
3
3
  * single-flight guard that stops concurrent triggers from minting more than
4
- * once, and a browser-only proactive refresh — a timer plus an OS-wake listener
5
- * — that renews the credential ahead of expiry. It reaches the rest of the
4
+ * once, and proactive refresh — an expiry-aware timer plus a browser OS-wake
5
+ * listener — that renews the credential ahead of expiry. It reaches the rest of the
6
6
  * client only through the small {@link CredentialLifecycleContext} interface,
7
7
  * so the two can reference each other without an import cycle.
8
8
  */
9
- import { noopLogger } from '../../logger.js';
10
- import { credentialExpiry, credentialToken, } from '../../auth/credentialResult.js';
9
+ import { noopLogger } from '../logger.js';
10
+ import { credentialExpiry, credentialToken, } from '../auth/credentialResult.js';
11
11
  /** The fallback pre-roll interval, and also its ceiling: 10 minutes, which sits
12
12
  * comfortably inside the server's 15-minute default credential lifetime. Used
13
13
  * as-is when the refresher reports no expiry. */
@@ -321,4 +321,4 @@ export class CredentialLifecycle {
321
321
  this.credentialLifecycleTeardown = null;
322
322
  }
323
323
  }
324
- //# sourceMappingURL=credentialLifecycle.js.map
324
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/sessions/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,gBAAgB,EAChB,eAAe,GAGhB,MAAM,6BAA6B,CAAC;AA8BrC;;kDAEkD;AAClD,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE1D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAA0B,EAAE,KAAa;IAC7E,IAAI,WAAW,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC1D,OAAO,2BAA2B,CAAC;IACrC,CAAC;IACD,MAAM,SAAS,GAAG,WAAW,GAAG,KAAK,CAAC;IACtC,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,oBAAoB,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE,2BAA2B,CAAC,CAAC;AAC1F,CAAC;AAED;8DAC8D;AAC9D,SAAS,oBAAoB,CAAC,SAA6B;IACzD,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,MAAM,CAAC,QAAQ,CAA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qE;YACrE,0EAA0E;YAC1E,yEAAyE;YACzE,kEAAkE;YAClE,sEAAsE;YACtE,wEAAwE;YACxE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,GAAS,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;gBAC1C,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBAC7C,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;QAED,IAAI,CAAC,2BAA2B,GAAG,GAAS,EAAE;YAC5C,KAAK,MAAM,CAAC,IAAI,SAAS;gBAAE,CAAC,EAAE,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC;IAED,iEAAiE;IACjE,IAAI;QACF,IAAI,CAAC,2BAA2B,EAAE,EAAE,CAAC;QACrC,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Runtime lifecycle for a renewable session supplied to `Ablo({ session })`.
3
+ *
4
+ * A session provider mints a credential, while this boundary decides when to
5
+ * reuse it. Keeping that policy here prevents HTTP requests and the WebSocket
6
+ * bootstrap from independently minting duplicate sessions for the same actor.
7
+ */
8
+ import type { CredentialProvider, CredentialProviderResult } from '../auth/credentialResult.js';
9
+ import type { SessionProvider, SessionSource } from './contract.js';
10
+ /** Cache one minted session until it approaches expiry; concurrent refreshes share one mint. */
11
+ export declare function cachedSessionProvider(provider: SessionProvider): CredentialProvider;
12
+ /** The one credential input a live transport consumes. */
13
+ export interface SessionAccess {
14
+ readonly renewable: boolean;
15
+ credential(): Promise<CredentialProviderResult>;
16
+ }
17
+ /** Normalize a static or renewable session before it reaches a transport. */
18
+ export declare function createSessionAccess(source: SessionSource | null | undefined, credential: () => Promise<CredentialProviderResult>): SessionAccess;
19
+ /** Resolve the public session forms into the credential shape auth consumes. */
20
+ export declare function resolveSessionCredential(source: SessionSource, options: {
21
+ readonly fetch?: typeof globalThis.fetch;
22
+ readonly dangerouslyAllowBrowser?: boolean;
23
+ }): string | CredentialProvider;
24
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/sessions/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,eAAe,EAEf,aAAa,EACd,MAAM,eAAe,CAAC;AAevB,gGAAgG;AAChG,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,kBAAkB,CAcnF;AAED,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,UAAU,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACjD;AAED,6EAA6E;AAC7E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,EACxC,UAAU,EAAE,MAAM,OAAO,CAAC,wBAAwB,CAAC,GAClD,aAAa,CAOf;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IACP,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC5C,GACA,MAAM,GAAG,kBAAkB,CAmB7B"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Runtime lifecycle for a renewable session supplied to `Ablo({ session })`.
3
+ *
4
+ * A session provider mints a credential, while this boundary decides when to
5
+ * reuse it. Keeping that policy here prevents HTTP requests and the WebSocket
6
+ * bootstrap from independently minting duplicate sessions for the same actor.
7
+ */
8
+ import { AbloValidationError } from '../errors.js';
9
+ import { createEndpointCredentialResolver, isCredentialEndpoint, } from '../auth/credentialEndpoint.js';
10
+ import { protectBrowserCredentialProvider } from '../auth/browserCredentialSafety.js';
11
+ const SESSION_REFRESH_SKEW_MS = 30_000;
12
+ function remainsUsable(session, now) {
13
+ const expiresAt = Date.parse(session.expiresAt);
14
+ return Number.isFinite(expiresAt) && expiresAt - now > SESSION_REFRESH_SKEW_MS;
15
+ }
16
+ /** Cache one minted session until it approaches expiry; concurrent refreshes share one mint. */
17
+ export function cachedSessionProvider(provider) {
18
+ let current = null;
19
+ let refreshing = null;
20
+ return async () => {
21
+ if (current && remainsUsable(current, Date.now()))
22
+ return current;
23
+ refreshing ??= provider().then((next) => {
24
+ current = next;
25
+ return next;
26
+ }).finally(() => {
27
+ refreshing = null;
28
+ });
29
+ return refreshing;
30
+ };
31
+ }
32
+ /** Normalize a static or renewable session before it reaches a transport. */
33
+ export function createSessionAccess(source, credential) {
34
+ return {
35
+ renewable: typeof source === 'function'
36
+ || (typeof source === 'object' && source !== null && 'endpoint' in source),
37
+ credential,
38
+ };
39
+ }
40
+ /** Resolve the public session forms into the credential shape auth consumes. */
41
+ export function resolveSessionCredential(source, options) {
42
+ if (typeof source === 'function') {
43
+ return protectBrowserCredentialProvider(cachedSessionProvider(source), options.dangerouslyAllowBrowser);
44
+ }
45
+ if (!('endpoint' in source))
46
+ return source.token;
47
+ if (!isCredentialEndpoint(source.endpoint)) {
48
+ throw new AbloValidationError('`session.endpoint` expects a URL or path such as \'/api/ablo-session\'.', { code: 'invalid_options', param: 'session.endpoint' });
49
+ }
50
+ return protectBrowserCredentialProvider(createEndpointCredentialResolver(source.endpoint, {
51
+ fetch: options.fetch,
52
+ timeoutMs: source.timeoutMs,
53
+ allowCrossOrigin: source.allowCrossOrigin,
54
+ }), options.dangerouslyAllowBrowser);
55
+ }
56
+ //# sourceMappingURL=source.js.map
@@ -0,0 +1 @@
1
+ {"version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K,IAAI,IAAI,UAAU,IAAI,MAAM,CAAC;QAC5E,UAAU;KACX,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,wBAAwB,CACtC,MAAqB,EACrB,OAGC;IAED,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,gCAAgC,CACrC,qBAAqB,CAAC,MAAM,CAAC,EAC7B,OAAO,CAAC,uBAAuB,CAChC,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC;IACjD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,mBAAmB,CAC3B,yEAAyE,EACzE,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,EAAE,CACvD,CAAC;IACJ,CAAC;IACD,OAAO,gCAAgC,CAAC,gCAAgC,CAAC,MAAM,CAAC,QAAQ,EAAE;QACxF,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;KAC1C,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;AACvC,CAAC"}
@@ -1,5 +1,4 @@
1
1
  /** Shared connection lifecycle boundary. */
2
2
  export * from './manager.js';
3
- export * from './credentialLifecycle.js';
4
3
  export * from './networkProbe.js';
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/connection/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/connection/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  /** Shared connection lifecycle boundary. */
2
2
  export * from './manager.js';
3
- export * from './credentialLifecycle.js';
4
3
  export * from './networkProbe.js';
5
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/connection/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/connection/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -41,7 +41,7 @@
41
41
  */
42
42
  import { probeNetwork, type ProbeResult } from './networkProbe.js';
43
43
  import type { AuthTokenGetter } from '../../auth/credentialSource.js';
44
- import type { CredentialRefreshOutcome } from './credentialLifecycle.js';
44
+ import type { CredentialRefreshOutcome } from '../../sessions/lifecycle.js';
45
45
  import { type Logger } from '../../logger.js';
46
46
  import { type TransportObservability } from '../../observability.js';
47
47
  export type ConnectionState = 'connected' | 'offline' | 'probing_network' | 'validating_session' | 'refreshing_credential' | 'reconnecting' | 'backoff' | 'waiting_for_network' | 'auth_blocked' | 'session_expired';
@@ -1 +1 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/transport/connection/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAA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C,QAAQ,CAAC,YAAY,CAAC,CAAkB;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAEvD,OAAO,CAAC,mBAAmB,CAA6B;IACxD,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,sBAAsB,CAA6B;gBAE/C,OAAO,GAAE,wBAA6B;IAWlD,KAAK,CAAC,SAAS,EAAE,mBAAmB,GAAG,IAAI;IAO3C,OAAO,IAAI,IAAI;IAef,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAwClC,OAAO,CAAC,UAAU;IA2LlB,OAAO,CAAC,YAAY;IA4EpB;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;YASd,QAAQ;IAwCtB;;;;;;;;;;;;;;;;;OAiBG;YACW,oBAAoB;YA8CpB,YAAY;IAuB1B,OAAO,CAAC,eAAe;IAiDvB,OAAO,CAAC,qBAAqB;IA4B7B,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,aAAa;IAyDrB,IAAI,WAAW,IAAI,OAAO,CAAuC;IACjE,IAAI,SAAS,IAAI,OAAO,CAA6E;IACrG,IAAI,cAAc,IAAI,OAAO,CAQ5B;IACD,IAAI,gBAAgB,IAAI,OAAO,CAA6C;IAE5E,IAAI,eAAe,IAAI,MAAM,GAAG,IAAI,CAUnC;IAID,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kBAAkB;CAM3B"}
@@ -1,10 +1,13 @@
1
1
  import type { HttpClientConfig } from './options.js';
2
- import type { CommitResource, HttpClaimApi, HttpClaimsResource, HttpLogsResource, ModelReadOptions, ModelList, SessionResource } from '../../client/resources/httpResources.js';
2
+ import type { CommitResource, HttpClaimApi, HttpClaimsResource, HttpLogsResource, ModelReadOptions, ModelList } from '../../client/resources/httpResources.js';
3
3
  import type { ModelCreateParams, ModelCreateManyParams, ModelDeleteParams, ServerReadOptions, ListAllOptions, ModelReadParams, ModelUpdateParams } from '../../client/resources/modelOperations.js';
4
4
  import type { Schema, SchemaRecord, InferModel, InferCreate } from '../../schema/schema.js';
5
5
  import { type ModelUpdater, type FunctionalUpdateOptions } from '../../client/resources/functionalUpdate.js';
6
+ import type { JsonValue } from '../../types/streams.js';
6
7
  import type { ReadDependency } from '../../coordination/schema.js';
7
8
  import type { EffectiveAuthority } from '../../auth/capability.js';
9
+ import type { WebSocketObservedDelta } from '../websocket/sessionContract.js';
10
+ import type { CoreSyncEventMap } from '../websocket/transport.js';
8
11
  export interface AbloHttpClientOptions<S extends SchemaRecord> extends HttpClientConfig<S> {
9
12
  /**
10
13
  * Per-request deadline. A black-holed HTTP request otherwise has no platform
@@ -12,6 +15,16 @@ export interface AbloHttpClientOptions<S extends SchemaRecord> extends HttpClien
12
15
  * @default 30_000
13
16
  */
14
17
  readonly timeoutMs?: number;
18
+ /** Initial groups observed by a session-backed WebSocket client. */
19
+ readonly groups?: readonly string[];
20
+ /** Application frame names accepted by `subscribe` on the WebSocket transport. */
21
+ readonly collaborationEvents?: readonly string[];
22
+ /** Durable resume position for WebSocket observation. */
23
+ readonly cursorStore?: import('../../client/contract.js').ObserveCursorStore;
24
+ readonly cursorKey?: string;
25
+ readonly reconnectDelay?: number;
26
+ readonly maxReconnectDelay?: number;
27
+ readonly connectTimeoutMs?: number;
15
28
  }
16
29
  declare const capturedRowBrand: unique symbol;
17
30
  /** A point-read row whose exact watermark is privately retained by its client. */
@@ -30,7 +43,7 @@ export type HttpModelMutationParams<P> = Omit<P, 'reads'> & {
30
43
  * coordinated writes.
31
44
  * It deliberately omits the stateful client's local-only
32
45
  * reads (the `local` namespace) and live subscriptions (`onChange`), which need
33
- * a resident graph and a persistent socket; those are absent from the type, so
46
+ * a local graph and a persistent socket; those are absent from the type, so
34
47
  * reaching for one is a compile error rather than a runtime gap.
35
48
  *
36
49
  * This is also the base the reactive per-model surface is composed from, rather
@@ -101,7 +114,7 @@ export interface HttpModelClient<T, C = T> {
101
114
  }
102
115
  /**
103
116
  * The type of the stateless HTTP client: a typed {@link HttpModelClient} per
104
- * schema model, plus `commits`, `dispose`, and the session-mint surface. It
117
+ * schema model, plus `commits` and lifecycle operations. It
105
118
  * exposes only what request/response transport can do, so reaching for a
106
119
  * stateful-only capability — the `local` reads, `onChange`, or the synchronous
107
120
  * `claim.state`/`queue`/`reorder` reads — is a compile error rather than a value
@@ -134,21 +147,36 @@ export type AbloHttpClient<S extends SchemaRecord> = {
134
147
  dispose(): Promise<void>;
135
148
  /** Resolves the bearer credential this client authenticates with, or `null` if none is set. */
136
149
  getAuthToken(): Promise<string | null>;
137
- /**
138
- * Mints a short-lived, scoped session token. Minting is itself a stateless
139
- * request, so it is available here even though the local-cache reads are not.
140
- * Pass `{ user }` to mint an end-user key (`ek_`) or `{ agent, can }` to mint a
141
- * scoped agent key (`rk_`). See {@link CreateSessionParams}.
142
- */
143
- readonly sessions: SessionResource<S>;
150
+ };
151
+ /** The same typed resource client, with server-pushed capabilities carried by WebSocket. */
152
+ export type AbloWebSocketClient<S extends SchemaRecord> = AbloHttpClient<S> & {
153
+ observe(options?: {
154
+ signal?: AbortSignal;
155
+ }): AsyncIterable<WebSocketObservedDelta>;
156
+ subscribe<K extends keyof CoreSyncEventMap>(event: K, listener: (...args: CoreSyncEventMap[K]) => void): () => void;
157
+ updateSubscription(groups: readonly string[], options?: {
158
+ timeoutMs?: number;
159
+ }): Promise<{
160
+ groups: string[];
161
+ }>;
162
+ readonly presence: {
163
+ update(input?: {
164
+ readonly status?: 'online' | 'away' | 'offline';
165
+ readonly customStatus?: string;
166
+ readonly timezone?: string;
167
+ readonly activity?: Readonly<Record<string, JsonValue>>;
168
+ }): Promise<void>;
169
+ };
170
+ readonly collaboration: {
171
+ send(event: string, payload: Readonly<Record<string, JsonValue>>): Promise<void>;
172
+ };
144
173
  };
145
174
  /**
146
- * Builds the stateless, typed HTTP client. Each `client.<model>` resolves to the
147
- * protocol client's model accessor, while `commits`, `dispose`, and the other
148
- * protocol members pass through unchanged. No socket is ever opened; the bearer
149
- * credential is the identity.
175
+ * Builds the typed headless client. An API-key identity uses HTTP. A session
176
+ * identity uses one lazily opened WebSocket by default for commits and live
177
+ * coordination until `dispose()`; point reads and administration remain HTTP.
150
178
  */
151
- /** @internal Constructed only through the public `Ablo({ transport: 'http' })` factory. */
152
- export declare function createAbloHttpClient<S extends SchemaRecord>(options: AbloHttpClientOptions<S>): AbloHttpClient<S>;
179
+ /** @internal Constructed only through the public `Ablo()` factory. */
180
+ export declare function createAbloHttpClient<S extends SchemaRecord>(options: AbloHttpClientOptions<S>): AbloHttpClient<S> | AbloWebSocketClient<S>;
153
181
  export {};
154
182
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/transport/http/client.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EACV,cAAc,EAEd,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAEhB,gBAAgB,EAEhB,SAAS,EAGT,eAAe,EAChB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,iBAAiB,EAClB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE5F,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC7B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AASnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAA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
20
  import { createHttpTransport, } from './transport.js';
21
- import { modelWireNames } from '../../auth/capability.js';
22
21
  import { collectModelList, modelList } from '../../client/resources/httpResources.js';
23
22
  import { resolveCreateId } from '../../client/resources/modelCreate.js';
24
23
  import { omittedModelError } from '../../schema/select.js';
25
24
  import { reconcileFunctionalUpdate, } from '../../client/resources/functionalUpdate.js';
26
25
  import { AbloConnectionError, AbloValidationError } from '../../errors.js';
27
26
  import { capturePointRead, createReadSetContext, kReadEvidence, prepareReadSet, } from '../../commit/readSetContext.js';
28
- import { recordHttpCommitReceipt } from '../../commit/recordRuntime.js';
27
+ import { recordHttpCommitReceipt, recordWebSocketCommitReceipt, } from '../../commit/recordRuntime.js';
28
+ import { createWebSocketSession, } from '../websocket/session.js';
29
+ import { subscribeWebSocketReadChanges } from '../websocket/contextSubscription.js';
29
30
  /**
30
31
  * Private transport members that pass straight through the facade. Everything
31
32
  * else must be a declared schema model; there is no dynamic fallback namespace.
@@ -39,7 +40,6 @@ const PROTOCOL_MEMBERS = new Set([
39
40
  'logs',
40
41
  'identity',
41
42
  'getAuthToken',
42
- 'sessions',
43
43
  ]);
44
44
  /** Narrows a bare property name to a transport key so the facade can index it typed. */
45
45
  function isProtocolMember(prop) {
@@ -189,29 +189,95 @@ function createHttpModelClient(protocol, modelName, clientIdentity, readSetConte
189
189
  };
190
190
  }
191
191
  /**
192
- * Builds the stateless, typed HTTP client. Each `client.<model>` resolves to the
193
- * protocol client's model accessor, while `commits`, `dispose`, and the other
194
- * protocol members pass through unchanged. No socket is ever opened; the bearer
195
- * credential is the identity.
192
+ * Builds the typed headless client. An API-key identity uses HTTP. A session
193
+ * identity uses one lazily opened WebSocket by default for commits and live
194
+ * coordination until `dispose()`; point reads and administration remain HTTP.
196
195
  */
197
- /** @internal Constructed only through the public `Ablo({ transport: 'http' })` factory. */
196
+ /** @internal Constructed only through the public `Ablo()` factory. */
198
197
  export function createAbloHttpClient(options) {
199
198
  const { schema, onCommitReceipt, ...rest } = options;
199
+ const usesWebSocket = options.transport === 'websocket'
200
+ || (options.transport === undefined && options.session != null);
200
201
  const readSetContext = createReadSetContext();
201
202
  const transport = createHttpTransport({
202
203
  ...rest,
203
- // Derived from the schema this client is bound to, never assembled by hand
204
- // — see `auth/capability.ts`.
205
- modelTypenames: modelWireNames(schema.models),
206
204
  onCommitReceipt: (observation) => {
207
205
  recordHttpCommitReceipt(readSetContext, observation);
208
206
  onCommitReceipt?.(observation);
209
207
  },
208
+ ...(usesWebSocket ? {
209
+ dispatchCommit: async (input) => {
210
+ const receipt = await (await webSocketSession()).commit(input);
211
+ recordWebSocketCommitReceipt(readSetContext, {
212
+ receipt,
213
+ operations: input.operations,
214
+ reads: input.reads,
215
+ });
216
+ return receipt;
217
+ },
218
+ dispatchClaim: async (input) => (await webSocketSession()).claim(input),
219
+ releaseDispatchedClaim: (input) => {
220
+ void webSocketSession().then((session) => session.release(input));
221
+ },
222
+ } : {}),
210
223
  });
211
224
  const schemaModels = new Set(Object.keys(schema.models));
212
225
  const clientIdentity = {};
213
226
  const omittedModels = new Set(schema.omittedModels ?? []);
214
227
  const models = new Map();
228
+ let webSocket = null;
229
+ let webSocketPromise = null;
230
+ const webSocketOpen = new AbortController();
231
+ let disposed = false;
232
+ const webSocketSession = () => {
233
+ if (disposed) {
234
+ return Promise.reject(new AbloConnectionError('This Ablo client is disposed.'));
235
+ }
236
+ if (webSocket)
237
+ return Promise.resolve(webSocket);
238
+ if (webSocketPromise)
239
+ return webSocketPromise;
240
+ webSocketPromise = (async () => {
241
+ await transport.ready();
242
+ const session = await createWebSocketSession({
243
+ baseUrl: rest.baseURL ?? undefined,
244
+ access: transport.access,
245
+ syncGroups: options.groups,
246
+ collaborationEvents: options.collaborationEvents,
247
+ cursorStore: options.cursorStore,
248
+ cursorKey: options.cursorKey,
249
+ reconnectDelay: options.reconnectDelay,
250
+ maxReconnectDelay: options.maxReconnectDelay,
251
+ connectTimeoutMs: options.connectTimeoutMs,
252
+ }, webSocketOpen.signal);
253
+ if (disposed) {
254
+ await session.close();
255
+ throw new AbloConnectionError('This Ablo client is disposed.');
256
+ }
257
+ webSocket = session;
258
+ return session;
259
+ })().finally(() => {
260
+ webSocketPromise = null;
261
+ });
262
+ return webSocketPromise;
263
+ };
264
+ const ready = async () => {
265
+ await transport.ready();
266
+ if (usesWebSocket)
267
+ await webSocketSession();
268
+ };
269
+ const dispose = async () => {
270
+ if (disposed)
271
+ return;
272
+ disposed = true;
273
+ webSocketOpen.abort();
274
+ const opening = webSocketPromise;
275
+ if (webSocket)
276
+ await webSocket.close();
277
+ else
278
+ await opening?.then((session) => session.close()).catch(() => undefined);
279
+ await transport.dispose();
280
+ };
215
281
  const model = (name) => {
216
282
  const cached = models.get(name);
217
283
  if (cached)
@@ -243,13 +309,51 @@ export function createAbloHttpClient(options) {
243
309
  return {
244
310
  context: readSetContext,
245
311
  client: clientIdentity,
246
- onChange: transport.onChange,
312
+ onChange: (reads, listener) => usesWebSocket
313
+ ? subscribeWhenConnected(webSocketSession, reads, listener)
314
+ : transport.onChange(reads, listener),
247
315
  };
248
316
  }
249
317
  if (typeof prop !== 'string')
250
318
  return undefined;
251
319
  if (prop === 'commits')
252
320
  return commits;
321
+ if (prop === 'ready')
322
+ return ready;
323
+ if (prop === 'dispose')
324
+ return dispose;
325
+ if (usesWebSocket && prop === 'observe') {
326
+ return async function* (observeOptions) {
327
+ yield* (await webSocketSession()).observe(observeOptions);
328
+ };
329
+ }
330
+ if (usesWebSocket && prop === 'subscribe') {
331
+ return (event, listener) => {
332
+ let stop;
333
+ let cancelled = false;
334
+ void webSocketSession().then((session) => {
335
+ if (!cancelled)
336
+ stop = session.subscribe(event, listener);
337
+ });
338
+ return () => { cancelled = true; stop?.(); };
339
+ };
340
+ }
341
+ if (usesWebSocket && prop === 'updateSubscription') {
342
+ return async (groups, subscriptionOptions) => {
343
+ const result = await (await webSocketSession()).updateSubscription(groups, subscriptionOptions);
344
+ return { groups: result.syncGroups };
345
+ };
346
+ }
347
+ if (usesWebSocket && prop === 'presence') {
348
+ return {
349
+ update: async (input) => (await webSocketSession()).presence.update(input),
350
+ };
351
+ }
352
+ if (usesWebSocket && prop === 'collaboration') {
353
+ return {
354
+ send: async (event, payload) => (await webSocketSession()).collaboration.send(event, payload),
355
+ };
356
+ }
253
357
  // Real protocol members pass through unchanged.
254
358
  if (isProtocolMember(prop)) {
255
359
  return transport[prop];
@@ -271,4 +375,13 @@ export function createAbloHttpClient(options) {
271
375
  // method on this type is missing at runtime.
272
376
  return facade;
273
377
  }
378
+ function subscribeWhenConnected(session, reads, listener) {
379
+ let stop;
380
+ let cancelled = false;
381
+ void session().then((connected) => {
382
+ if (!cancelled)
383
+ stop = subscribeWebSocketReadChanges(connected, reads, listener);
384
+ });
385
+ return () => { cancelled = true; stop?.(); };
386
+ }
274
387
  //# sourceMappingURL=client.js.map