@collective-intelligence/external-apps-client-sdk 0.2.16 → 0.2.18

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/AGENTS.md CHANGED
@@ -32,3 +32,7 @@ package `README.md` holds the full API.
32
32
  - [skills/client-sdk-move-to-effect/SKILL.md](skills/client-sdk-move-to-effect/SKILL.md):
33
33
  run when Effect code wraps the Promise API (`Effect.tryPromise`,
34
34
  `Effect.promise`) of this SDK.
35
+
36
+ ## Platform guide
37
+
38
+ - [docs/guide/index.md](docs/guide/index.md): read before choosing CI primitives for a solution or demo, or when a task needs the platform model (architecture, access, data, AI, template).
package/README.md CHANGED
@@ -339,7 +339,8 @@ const unsubscribe = realtime.subscribe(
339
339
  its lifetime; the client reconnects with a new ticket.
340
340
  - A 401 or 403 on the ticket, the stream or a grant renewal stops the
341
341
  connection: its status is `idle`, and it asks no ticket until the topics
342
- change, the page is shown or its visibility changes.
342
+ change, the page is shown or its visibility changes. `onRefused` runs once
343
+ when this happens, for example to re-check the session.
343
344
  - The default stream reader uses `fetch`, because `EventSource` does not expose
344
345
  the server's ping comments or a refused stream's status. Inject
345
346
  `eventSourceFactory`, `document`, `window`, `timers` and `random` to test.
package/dist/effect.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Xt as ClientFetch, _ as layerLegacy, a as LegacyResourceClient, an as layerFederatedConfig, c as LegacyResourcesValue, d as ResourcesFromEntityTransportOptions, dn as CiErrorCode, f as ResourcesLayerOptions, fn as CiTransportError, g as layerFromEntityTransport, h as layerConfig$3, i as makeEntityHttpExecute, in as layerFederated, l as ResourceEntityClient, m as layer$3, mn as FederatedAuthErrorCode, nn as FederatedAuth, o as LegacyResources, on as layerServerSession, p as ResourcesValue, pn as FederatedAuthError, rn as FederatedAuthValue, s as LegacyResourcesLayerOptions, sn as layerServerSessionConfig, u as Resources, un as CiError, v as layerLegacyConfig } from "./resources-DVq8jSnc.js";
2
- import { $ as RealtimeTopicFilter, B as layerProxyConfig, D as RunsValue, E as Runs, F as ExecuteResult, I as layerDirect, L as layerDirectConfig, N as CiClient, O as layer$4, P as CiClientValue, Q as RealtimeTopic, R as layerFromExecutor, T as RunFollowOptions, Z as RealtimeChange, f as DelegatedApplicationRuntimeOptions, j as CiStreamPage$1, p as DelegatedRuntimeState, w as DEFAULT_FOLLOW_RUN_DEADLINE_MS, z as layerProxy } from "./index-BTkfYlty.js";
2
+ import { $ as RealtimeTopicFilter, B as layerProxyConfig, D as RunsValue, E as Runs, F as ExecuteResult, I as layerDirect, L as layerDirectConfig, N as CiClient, O as layer$4, P as CiClientValue, Q as RealtimeTopic, R as layerFromExecutor, T as RunFollowOptions, Z as RealtimeChange, f as DelegatedApplicationRuntimeOptions, j as CiStreamPage$1, p as DelegatedRuntimeState, w as DEFAULT_FOLLOW_RUN_DEADLINE_MS, z as layerProxy } from "./index-DhKJ4NCr.js";
3
3
  import * as Schema from "effect/Schema";
4
4
  import * as Config from "effect/Config";
5
5
  import * as Context from "effect/Context";
@@ -946,6 +946,12 @@ type RealtimeClientOptions = Readonly<{
946
946
  onReset?: () => void;
947
947
  /** The user's access changed: re-check the session and its capabilities. */
948
948
  onAccessChanged?: () => void;
949
+ /**
950
+ * The server refused the ticket, the stream or a grant renewal with 401 or
951
+ * 403. The connection stops and shows `"idle"`; it asks no ticket until the
952
+ * topics change, the page is shown or its visibility changes.
953
+ */
954
+ onRefused?: () => void;
949
955
  }>;
950
956
  type RealtimeClientStatus = "idle" | "connecting" | "open" | "backoff";
951
957
  type RealtimeClientState = Readonly<{
@@ -973,8 +979,8 @@ type RealtimeClient = Readonly<{
973
979
  * Changes and resets reach the listeners in one delivery per tab, 250 to
974
980
  * 1000 ms after the first of them: a burst of changes refetches once, and
975
981
  * tabs that reset together refetch apart.
976
- * The client runs on the realtime service (`./service`) in a runtime of its
977
- * own; `close` disposes of it.
982
+ * The client runs on the realtime service (`./service`) in a fiber of its
983
+ * own; `close` interrupts it, which closes the connection.
978
984
  */
979
985
  declare const createRealtimeClient: (options: RealtimeClientOptions) => RealtimeClient;
980
986
  /** The class of an Expected Error that CI returns. */
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { $ as ResourceDefinition, $t as FederatedAuthState, A as EntityFileFieldWrite, At as JsonValue, B as EntityRequest, Bt as clientOperationIds, C as EntityBatchInput, Ct as ResourceUpdateRequest, D as EntityClient, E as EntityBatchRefusedDetails, Et as createProxyTransport, F as EntityOperation, Ft as ClientOperationInput, G as EntityUploadSlot, Gt as JsonObject, H as EntityTransport, I as EntityOperationResult, It as ClientOperationMap, J as ResourceCapabilities, Jt as SearchQuery, K as IdempotencyKey, Kt as KnowledgeQuery, L as EntityPage, Lt as ClientOperationOutput, M as EntityFileWrite, Mt as OperationSuccess, N as EntityListQuery, Nt as ClientOperationDefinition, O as EntityCreateInput, Ot as CiErrorCode, P as EntityMemberValue, Pt as ClientOperationId, Q as ResourceCursor, Qt as FederatedAuthOptions, R as EntityProtocol, Rt as OperationExecutionOptions, S as createResourceClient, St as ResourceTransportRequest, T as EntityBatchRefusal, Tt as ProxyTransportOptions, U as EntityUpdateInput, V as EntityRestoreInput, Vt as isClientOperationId, W as EntityUploadInput, X as ResourceCreateInput, Xt as ClientFetch, Y as ResourceClient, Yt as WorkflowInvokeTarget, Z as ResourceCreateRequest, Zt as FederatedAuth, _t as ResourceRequestOptions, at as ResourceIdentityField, b as isEntityBatchRefusedError, bt as ResourceSort, cn as ServerSessionAuthOptions, ct as ResourceLifecycleRequest, dt as ResourceListResult, en as FederatedSessionIdentity, et as ResourceError, fn as CiTransportError, ft as ResourceMutationInput, gt as ResourceRecordId, ht as ResourceRecord, it as ResourceId, j as EntityFileValue, jt as OperationRequest, k as EntityDeleteInput, kt as CiResult, ln as createServerSessionAuth, lt as ResourceListQuery, mn as FederatedAuthErrorCode, mt as ResourcePaginationMode, n as EntityHttpTransportOptions, nt as ResourceFilter, ot as ResourceJsonValue, pn as FederatedAuthError, pt as ResourcePagination, q as PortableResourceSchema, qt as QueryFilter, r as createEntityHttpTransport, rt as ResourceGetRequest, st as ResourceLifecycleInput, t as EntityHttpDestination, tn as createFederatedAuth, tt as ResourceErrorCode, ut as ResourceListRequest, vt as ResourceResult, w as EntityBatchOp, wt as ProxyAuthentication, x as isEntityReadLimitError, xt as ResourceTransport, y as createEntityProtocol, yt as ResourceRevision, z as EntityReadLimitDetails, zt as TypedOperationExecutor } from "./resources-DVq8jSnc.js";
2
- import { $ as RealtimeTopicFilter, A as CiStreamEvent, C as followRun, G as RealtimeStreamEnd, H as createDirectTransport, J as createFetchEventSourceFactory, K as RealtimeStreamEvent, M as nextStreamCursor, Q as RealtimeTopic, S as FollowRunSource, U as RealtimeEventSource, V as DirectTransportOptions, W as RealtimeEventSourceFactory, X as RealtimeWindow, Y as RealtimeDocument, Z as RealtimeChange, _ as ClientSdkEntrypoint, a as RealtimeClientStatus, b as createClient, c as FixedWorkflowClient, d as DelegatedApplicationRuntime, et as realtimeTopicKey, f as DelegatedApplicationRuntimeOptions, g as ClientSdkClient, h as ClientDomains, i as RealtimeClientState, j as CiStreamPage, k as CiRunCancellation, l as FixedWorkflowClientOptions, m as createDelegatedApplicationRuntime, n as RealtimeClient, o as RealtimeTimers, p as DelegatedRuntimeState, q as RealtimeStreamHandlers, r as RealtimeClientOptions, s as createRealtimeClient, t as CiError, u as createFixedWorkflowClient, v as OrganizationClient, w as DEFAULT_FOLLOW_RUN_DEADLINE_MS, x as FollowRunOptions, y as clientSdkProtocolVersion } from "./index-BTkfYlty.js";
2
+ import { $ as RealtimeTopicFilter, A as CiStreamEvent, C as followRun, G as RealtimeStreamEnd, H as createDirectTransport, J as createFetchEventSourceFactory, K as RealtimeStreamEvent, M as nextStreamCursor, Q as RealtimeTopic, S as FollowRunSource, U as RealtimeEventSource, V as DirectTransportOptions, W as RealtimeEventSourceFactory, X as RealtimeWindow, Y as RealtimeDocument, Z as RealtimeChange, _ as ClientSdkEntrypoint, a as RealtimeClientStatus, b as createClient, c as FixedWorkflowClient, d as DelegatedApplicationRuntime, et as realtimeTopicKey, f as DelegatedApplicationRuntimeOptions, g as ClientSdkClient, h as ClientDomains, i as RealtimeClientState, j as CiStreamPage, k as CiRunCancellation, l as FixedWorkflowClientOptions, m as createDelegatedApplicationRuntime, n as RealtimeClient, o as RealtimeTimers, p as DelegatedRuntimeState, q as RealtimeStreamHandlers, r as RealtimeClientOptions, s as createRealtimeClient, t as CiError, u as createFixedWorkflowClient, v as OrganizationClient, w as DEFAULT_FOLLOW_RUN_DEADLINE_MS, x as FollowRunOptions, y as clientSdkProtocolVersion } from "./index-DhKJ4NCr.js";
3
3
  export { CiError, type CiErrorCode, type CiResult, type CiRunCancellation, type CiStreamEvent, type CiStreamPage, CiTransportError, type ClientDomains, type ClientFetch, type ClientOperationDefinition, type ClientOperationId, type ClientOperationInput, type ClientOperationMap, type ClientOperationOutput, type ClientSdkClient, type ClientSdkEntrypoint, DEFAULT_FOLLOW_RUN_DEADLINE_MS, type DelegatedApplicationRuntime, type DelegatedApplicationRuntimeOptions, type DelegatedRuntimeState, type DirectTransportOptions, type EntityBatchInput, type EntityBatchOp, type EntityBatchRefusal, type EntityBatchRefusedDetails, type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityMemberValue, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityReadLimitDetails, type EntityRequest, type EntityRestoreInput, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type FederatedAuth, FederatedAuthError, type FederatedAuthErrorCode, type FederatedAuthOptions, type FederatedAuthState, type FederatedSessionIdentity, type FixedWorkflowClient, type FixedWorkflowClientOptions, type FollowRunOptions, type FollowRunSource, type IdempotencyKey, type JsonObject, type JsonValue, type KnowledgeQuery, type OperationExecutionOptions, type OperationRequest, type OperationSuccess, type OrganizationClient, type PortableResourceSchema, type ProxyAuthentication, type ProxyTransportOptions, type QueryFilter, type RealtimeChange, type RealtimeClient, type RealtimeClientOptions, type RealtimeClientState, type RealtimeClientStatus, type RealtimeDocument, type RealtimeEventSource, type RealtimeEventSourceFactory, type RealtimeStreamEnd, type RealtimeStreamEvent, type RealtimeStreamHandlers, type RealtimeTimers, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeWindow, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, type SearchQuery, type ServerSessionAuthOptions, type TypedOperationExecutor, type WorkflowInvokeTarget, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFetchEventSourceFactory, createFixedWorkflowClient, createProxyTransport, createRealtimeClient, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, isEntityBatchRefusedError, isEntityReadLimitError, nextStreamCursor, realtimeTopicKey };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { A as errors_exports, C as isClientOperationId, D as CiTransportError, O as FederatedAuthError, b as proxyHttpOptions, d as createEntityHttpTransport, g as isEntityReadLimitError, h as isEntityBatchRefusedError, m as createEntityProtocol, v as directHttpOptions, w as toCiResult, x as clientOperationIds, y as makeHttpExecute } from "./service-DaANR0QD.js";
2
2
  import { A as layerFromFactory, E as makeConnection, M as currentLink, N as createFetchEventSourceFactory, O as realtimeTopicKey, S as make, a as layer$2, c as layerFederated, f as DEFAULT_FOLLOW_RUN_DEADLINE_MS, g as CiClient, h as layer, i as FixedWorkflows, j as layerBrowser, k as layer$3, m as followSource, n as layer$1, p as Runs, s as FederatedAuth, t as DelegatedRuntime, u as layerServerSession, y as layerFromExecutor } from "./service-dVoDg4IP.js";
3
- import { t as createResourceClient } from "./resources-BedkrCzl.js";
3
+ import { t as createResourceClient } from "./resources-DhUOIac7.js";
4
4
  import * as Clock from "effect/Clock";
5
5
  import * as Context from "effect/Context";
6
6
  import * as Duration from "effect/Duration";
@@ -27,6 +27,14 @@ const runPromise = async (runtime, effect, signal) => {
27
27
  }
28
28
  };
29
29
  /**
30
+ * Internal; no entrypoint exports it. Builds the services of `runtime` in the
31
+ * call, for a facade constructor: a configuration error of its Layer throws
32
+ * there, and the synchronous `getState`, `getSnapshot` and `subscribe` of the
33
+ * facade read the built services. The other methods yield their service
34
+ * inside their own `runPromise`.
35
+ */
36
+ const buildServices = (runtime) => runtime.runSync(runtime.contextEffect);
37
+ /**
30
38
  * The `.` facade of sign-in: `createFederatedAuth` keeps its options and
31
39
  * methods over the `FederatedAuth` service (`./service`), in a runtime of
32
40
  * its own.
@@ -34,18 +42,19 @@ const runPromise = async (runtime, effect, signal) => {
34
42
  /**
35
43
  * Internal. The facade of the `FederatedAuth` service in `runtime`;
36
44
  * `getState` and `subscribe` stay synchronous. A configuration error throws
37
- * its `FederatedAuthError` here.
45
+ * its `FederatedAuthError` here. Each other method yields the service inside
46
+ * its run.
38
47
  */
39
48
  const authFacade = (runtime) => {
40
- const session = runtime.runSync(FederatedAuth);
49
+ const { getState, subscribe } = Context.get(buildServices(runtime), FederatedAuth);
41
50
  return {
42
- beginLogin: (options) => runPromise(runtime, session.beginLogin(options)),
43
- completeLogin: (callbackUrl) => runPromise(runtime, session.completeLogin(callbackUrl)),
44
- getAccessToken: () => runPromise(runtime, session.getAccessToken),
45
- getState: session.getState,
46
- logout: () => runPromise(runtime, session.logout),
47
- reauthorize: (options) => runPromise(runtime, session.reauthorize(options)),
48
- subscribe: session.subscribe
51
+ beginLogin: (options) => runPromise(runtime, FederatedAuth.use((auth) => auth.beginLogin(options))),
52
+ completeLogin: (callbackUrl) => runPromise(runtime, FederatedAuth.use((auth) => auth.completeLogin(callbackUrl))),
53
+ getAccessToken: () => runPromise(runtime, FederatedAuth.use((auth) => auth.getAccessToken)),
54
+ getState,
55
+ logout: () => runPromise(runtime, FederatedAuth.use((auth) => auth.logout)),
56
+ reauthorize: (options) => runPromise(runtime, FederatedAuth.use((auth) => auth.reauthorize(options))),
57
+ subscribe
49
58
  };
50
59
  };
51
60
  /**
@@ -229,7 +238,7 @@ const createClient = (options) => {
229
238
  */
230
239
  const createDelegatedApplicationRuntime = (options) => {
231
240
  const runtime = ManagedRuntime.make(layer$1(options));
232
- const session = runtime.runSync(DelegatedRuntime);
241
+ const { getSnapshot, subscribe } = Context.get(buildServices(runtime), DelegatedRuntime);
233
242
  const sessionAuth = authFacade(runtime);
234
243
  const client = clientFacade(runtime);
235
244
  const auth = sessionAuth;
@@ -238,14 +247,14 @@ const createDelegatedApplicationRuntime = (options) => {
238
247
  auth,
239
248
  client,
240
249
  close: () => runtime.dispose(),
241
- followRun: (runId) => runPromise(runtime, session.followRun(runId)),
242
- getSnapshot: session.getSnapshot,
243
- initialize: (url) => runPromise(runtime, session.initialize(url)),
244
- login: (returnTo) => runPromise(runtime, session.login(returnTo)),
245
- logout: () => runPromise(runtime, session.logout),
246
- refresh: () => runPromise(runtime, session.refresh),
250
+ followRun: (runId) => runPromise(runtime, DelegatedRuntime.use((session) => session.followRun(runId))),
251
+ getSnapshot,
252
+ initialize: (url) => runPromise(runtime, DelegatedRuntime.use((session) => session.initialize(url))),
253
+ login: (returnTo) => runPromise(runtime, DelegatedRuntime.use((session) => session.login(returnTo))),
254
+ logout: () => runPromise(runtime, DelegatedRuntime.use((session) => session.logout)),
255
+ refresh: () => runPromise(runtime, DelegatedRuntime.use((session) => session.refresh)),
247
256
  sessionAuth,
248
- subscribe: session.subscribe
257
+ subscribe
249
258
  };
250
259
  };
251
260
  /**
@@ -311,8 +320,6 @@ const defaultTimers = { schedule: (callback, milliseconds) => {
311
320
  const handle = globalThis.setTimeout(callback, milliseconds);
312
321
  return () => globalThis.clearTimeout(handle);
313
322
  } };
314
- /** The connection of one facade client, as its runtime holds it. */
315
- var FacadeConnection = class extends Context.Service()("@collective-intelligence/external-apps-client-sdk/FacadeConnection") {};
316
323
  /**
317
324
  * A scheduler that runs fiber tasks in the call stack of the facade. A task
318
325
  * that a callback schedules outside every fiber runs at once; a task that a
@@ -424,42 +431,37 @@ const fetchOf = (fetch, appUrls) => {
424
431
  * Changes and resets reach the listeners in one delivery per tab, 250 to
425
432
  * 1000 ms after the first of them: a burst of changes refetches once, and
426
433
  * tabs that reset together refetch apart.
427
- * The client runs on the realtime service (`./service`) in a runtime of its
428
- * own; `close` disposes of it.
434
+ * The client runs on the realtime service (`./service`) in a fiber of its
435
+ * own; `close` interrupts it, which closes the connection.
429
436
  */
430
437
  const createRealtimeClient = (options) => {
431
438
  const { flush, scheduler } = makeSyncScheduler();
432
- const runtime = ManagedRuntime.make(Layer.effect(FacadeConnection, makeConnection({
439
+ const { onAccessChanged, onRefused, onReset } = options;
440
+ const services = Layer.mergeAll(FetchHttpClient.layer, layerBrowser({
441
+ document: options.document,
442
+ window: options.window
443
+ }), options.eventSourceFactory === void 0 ? layer$3 : layerFromFactory(options.eventSourceFactory)).pipe(Layer.provideMerge(Layer.mergeAll(Layer.succeed(FetchHttpClient.Fetch, fetchOf(options.fetch ?? globalThis.fetch, [options.ticketUrl, options.revalidateUrl].filter((url) => url !== void 0))), Layer.succeed(Clock.Clock, clockOf(options.timers ?? defaultTimers, flush)), Layer.succeed(Random.Random, randomOf(options.random ?? Math.random)))));
444
+ let connection;
445
+ const fiber = Effect.runFork(makeConnection({
433
446
  resyncOnAccessChange: false,
434
447
  ticketUrl: onPlaceholderOrigin(options.ticketUrl),
435
- ...options.revalidateUrl !== void 0 && { revalidateUrl: onPlaceholderOrigin(options.revalidateUrl) }
436
- })).pipe(Layer.provide([
437
- FetchHttpClient.layer,
438
- layerBrowser({
439
- document: options.document,
440
- window: options.window
441
- }),
442
- options.eventSourceFactory === void 0 ? layer$3 : layerFromFactory(options.eventSourceFactory)
443
- ]), Layer.provide([
444
- Layer.succeed(FetchHttpClient.Fetch, fetchOf(options.fetch ?? globalThis.fetch, [options.ticketUrl, options.revalidateUrl].filter((url) => url !== void 0))),
445
- Layer.succeed(Clock.Clock, clockOf(options.timers ?? defaultTimers, flush)),
446
- Layer.succeed(Random.Random, randomOf(options.random ?? Math.random))
447
- ])));
448
- const started = runtime.runFork(FacadeConnection, { scheduler });
448
+ ...options.revalidateUrl !== void 0 && { revalidateUrl: onPlaceholderOrigin(options.revalidateUrl) },
449
+ ...onRefused !== void 0 && { onRefused: () => notify(onRefused) }
450
+ }).pipe(Effect.tap((started) => Effect.sync(() => {
451
+ connection = started;
452
+ })), Effect.andThen(Effect.never), Effect.scoped, Effect.provide(services)), { scheduler });
449
453
  flush();
450
- const exit = started.pollUnsafe();
451
- if (exit?._tag !== "Success") throw new Error("The realtime client did not start.", { cause: exit });
452
- const connection = exit.value;
453
- const { onAccessChanged, onReset } = options;
454
- if (onReset !== void 0) connection.listenResyncs(() => notify(onReset));
455
- if (onAccessChanged !== void 0) connection.listenAccessChanges(() => notify(onAccessChanged));
454
+ if (connection === void 0) throw new Error("The realtime client did not start.", { cause: fiber.pollUnsafe() });
455
+ const open = connection;
456
+ if (onReset !== void 0) open.listenResyncs(() => notify(onReset));
457
+ if (onAccessChanged !== void 0) open.listenAccessChanges(() => notify(onAccessChanged));
456
458
  return {
457
459
  close: () => {
458
- Effect.runFork(runtime.disposeEffect, { scheduler });
460
+ fiber.interruptUnsafe();
459
461
  flush();
460
462
  },
461
463
  getState: () => {
462
- const { machine, topics } = connection.state();
464
+ const { machine, topics } = open.state();
463
465
  return {
464
466
  connections: currentLink(machine) === void 0 ? 0 : 1,
465
467
  lastEventId: machine.lastEventId,
@@ -467,7 +469,7 @@ const createRealtimeClient = (options) => {
467
469
  topics
468
470
  };
469
471
  },
470
- subscribe: (topic, onChanges) => connection.listen(topic, (changes) => notify(() => onChanges(changes)))
472
+ subscribe: (topic, onChanges) => open.listen(topic, (changes) => notify(() => onChanges(changes)))
471
473
  };
472
474
  };
473
475
  /** The class of an Expected Error that CI returns. */
@@ -76,7 +76,8 @@ const defaultRequestId = () => globalThis.crypto.randomUUID();
76
76
  /**
77
77
  * The `.` facade of the resource core (`./service`), in a runtime of its
78
78
  * own that holds no service: the core needs none. `close` disposes it. A
79
- * transport that rejects resolves `transport_error`.
79
+ * transport that rejects, and a request whose signal aborts, resolve
80
+ * `transport_error`.
80
81
  */
81
82
  const createLegacyResourceClient = (options) => {
82
83
  const runtime = ManagedRuntime.make(Layer.empty);
@@ -87,15 +88,21 @@ const createLegacyResourceClient = (options) => {
87
88
  });
88
89
  const run = async (call, requestOptions) => {
89
90
  const correlationId = requestId();
91
+ const signal = requestOptions?.signal;
90
92
  try {
91
- return await runtime.runPromise(call(correlationId, requestOptions));
93
+ return await runtime.runPromise(call(correlationId, requestOptions), signal === void 0 ? void 0 : { signal });
92
94
  } catch (error) {
93
- if (!(error instanceof CiTransportError)) throw error;
94
- return {
95
+ if (error instanceof CiTransportError) return {
95
96
  correlationId,
96
97
  error: unavailable(error.cause),
97
98
  ok: false
98
99
  };
100
+ if (signal?.aborted === true) return {
101
+ correlationId,
102
+ error: unavailable(signal.reason),
103
+ ok: false
104
+ };
105
+ throw error;
99
106
  }
100
107
  };
101
108
  return {
package/dist/resources.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { d as createEntityHttpTransport, g as isEntityReadLimitError, h as isEntityBatchRefusedError, m as createEntityProtocol } from "./service-DaANR0QD.js";
2
- import { t as createResourceClient } from "./resources-BedkrCzl.js";
2
+ import { t as createResourceClient } from "./resources-DhUOIac7.js";
3
3
  export { createEntityHttpTransport, createEntityProtocol, createResourceClient, isEntityBatchRefusedError, isEntityReadLimitError };