@collective-intelligence/external-apps-client-sdk 0.1.35 → 0.1.37

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 CHANGED
@@ -335,6 +335,196 @@ const unsubscribe = realtime.subscribe(
335
335
  `eventSourceFactory`, `document`, `window`, `timers` and `random` to test.
336
336
  - `getState()` reports `status`, `connections` (0 or 1), `topics` and
337
337
  `lastEventId`; `close()` ends the connection and the page listeners.
338
+ - `createRealtimeClient` runs on the realtime service of `./effect`, in a
339
+ runtime of its own. Its listeners and callbacks run in the same call as the
340
+ page event, stream event or timer that causes them. `access-changed` calls
341
+ `onAccessChanged` only, never `onReset`.
342
+ - A failed ticket request logs a warning, and a failed connection step logs an
343
+ error, through the Effect logger (the console by default). The connection
344
+ goes on: the backoff or the ping timeout reconnects. The warning shows a
345
+ relative `ticketUrl` on the placeholder origin `realtime-ticket.invalid`;
346
+ `fetch` gets `ticketUrl` as you wrote it.
347
+
348
+ ### Realtime on Effect
349
+
350
+ `./effect` gives the same connection as the `RealtimeClient` service. The
351
+ connection rules above apply. `subscribe(topic)` is a `Stream` of
352
+ `RealtimeChange | RealtimeResync`, discriminated on `op`. A delivery that
353
+ cannot name its changes emits one Resync, `{ op: "resync" }`, in their place:
354
+ refetch the topic. Every subscription receives each Resync, so the Resync
355
+ replaces `onReset`, and a delivery never drops changes without a Resync.
356
+ `access-changed` also Resyncs: changed access can change what each query
357
+ returns, so every subscription receives one Resync at the next delivery, in
358
+ place of its pending changes. `accessChanges` emits at once at each
359
+ `access-changed` event: re-check the session. The streams end when the layer
360
+ scope closes, and the scope also closes the connection and the page
361
+ listeners.
362
+
363
+ ```ts
364
+ import {
365
+ layerRealtimeClient,
366
+ subscribe
367
+ } from "@collective-intelligence/external-apps-client-sdk/effect"
368
+ import * as Effect from "effect/Effect"
369
+ import * as Stream from "effect/Stream"
370
+
371
+ const leads = subscribe({ schema: "crm.lead" }).pipe(
372
+ Stream.runForEach((update) =>
373
+ update.op === "resync" ? refetchLeads : invalidateLead(update.id)
374
+ )
375
+ )
376
+
377
+ Effect.runFork(
378
+ leads.pipe(
379
+ Effect.provide(layerRealtimeClient({ ticketUrl: "/api/realtime/ticket" }))
380
+ )
381
+ )
382
+ ```
383
+
384
+ - `layerRealtimeClient` reads with the global `fetch`, and follows the
385
+ `document` and `window` of the browser. Outside a browser the page is always
386
+ visible. Provide `FetchHttpClient.Fetch` to use a different `fetch`.
387
+ - `HttpClient` resolves a relative `ticketUrl` against `location`. Outside a
388
+ browser, give an absolute `ticketUrl`.
389
+ - Timers use `Clock` and the jitter uses `Random`, so a test can use `TestClock`
390
+ and a fixed `Random`.
391
+
392
+ ## Expected Errors and `./effect`
393
+
394
+ `effect` `^4.1.0` is a required peer dependency. Install it in the
395
+ application. The SDK does not include a copy of `effect`, so the application
396
+ and every SDK share one copy.
397
+
398
+ The SDK defines its Expected Errors as `Schema.TaggedError` classes with bare
399
+ tags. Each class extends `Error`:
400
+
401
+ - `CiError { code, message, retryable, details? }`: CI returned an error for an
402
+ operation.
403
+ - `FederatedAuthError { code, message }`: the federated sign-in failed.
404
+ `createFederatedAuth` and `createServerSessionAuth` reject with it.
405
+ - `CiTransportError { cause }`: the request did not reach CI, or the response
406
+ was not readable. Its `message` is empty; do not show it to users.
407
+
408
+ ```ts
409
+ import { FederatedAuthError } from "@collective-intelligence/external-apps-client-sdk"
410
+
411
+ try {
412
+ await auth.getAccessToken()
413
+ } catch (error) {
414
+ if (error instanceof FederatedAuthError) {
415
+ showSignInError(error.code)
416
+ }
417
+ }
418
+ ```
419
+
420
+ `.` and `./effect` export the same classes, so `instanceof` gives the same
421
+ result for both entries. `./effect` also exports the wire Schemas `CiErrorCode`
422
+ and `FederatedAuthErrorCode`, and the envelope Schemas `CiErrorEnvelope`,
423
+ `CiResult(value)` and `CiStreamPage`, whose Types are the `.` types `CiError`,
424
+ `CiResult` and `CiStreamPage`.
425
+
426
+ ### What each operation gives
427
+
428
+ Every capability runs on one Effect Core. The `.` entry is a Vanilla Facade
429
+ over it: each client holds one Effect runtime and keeps its Promise
430
+ signatures. `close()` disposes that runtime: it cancels the calls in flight,
431
+ and a later call rejects. The clients of `createClient`,
432
+ `createDirectTransport`, `createProxyTransport`, `createFederatedAuth`,
433
+ `createServerSessionAuth`, `createFixedWorkflowClient`,
434
+ `createDelegatedApplicationRuntime` (also for its `client` and `auth`),
435
+ `createEntityHttpTransport` and `createResourceClient` have `close()`.
436
+ `followRun` is a function, not a client: it runs on the default Effect
437
+ runtime. A failure gives one of these outcomes:
438
+
439
+ | Failure | `.` operation that returns `CiResult` | `.` operation that rejects | `./effect` |
440
+ | ----------------------------------- | ------------------------------------------------------- | --------------------------------------------------------- | ----------------------------- |
441
+ | CI returns an error | resolves `{ ok: false, error }`; `error` is a `CiError` | rejects with `CiError` (`FederatedAuthError` for sign-in) | fails with the same class |
442
+ | The request does not reach CI | rejects with `CiTransportError` | rejects with `CiTransportError` | fails with `CiTransportError` |
443
+ | The caller aborts its `AbortSignal` | rejects with `signal.reason` | rejects with `signal.reason` | interruption |
444
+ | Bad SDK input | throws `TypeError` | throws `TypeError` | dies with `TypeError` |
445
+
446
+ - The operations that return `CiResult` are the domain methods of
447
+ `createClient`, `client.execute` and the `execute` of
448
+ `createDirectTransport` and `createProxyTransport`.
449
+ - An operation outside the client registry, or a call without an
450
+ `organizationId`, still resolves `CiResult` `invalid_request`;
451
+ `forOrganization("")` throws `TypeError`.
452
+ - `followRun` and `client.runs.follow` reject with the `CiError` of the failed
453
+ read. A run that does not finish before `deadlineMs` rejects with `CiError`
454
+ `unavailable` (`retryable: true`, message "Run did not finish").
455
+ - `createFixedWorkflowClient().invoke` rejects with `CiError`: the code that
456
+ the route names, else the code of its HTTP status.
457
+ - `createFederatedAuth` and `createServerSessionAuth` reject with
458
+ `FederatedAuthError`. A bad option throws `FederatedAuthError`
459
+ `configuration_error` when you create the client.
460
+ - `createDelegatedApplicationRuntime().followRun` without a session rejects
461
+ with `FederatedAuthError` `reauthorization_required`.
462
+ - `createResourceClient` and `createEntityHttpTransport` keep the
463
+ `ResourceResult` envelope: a transport failure or an abort in flight resolves
464
+ `transport_error`, with `outcome` `rejected` for a read and `uncertain` for a
465
+ write.
466
+
467
+ The `error` of a failed `CiResult` is a `CiError` instance, so it has
468
+ `_tag: "CiError"` and its JSON form includes `_tag`. Decode a wire code with
469
+ its code Schema:
470
+
471
+ ```ts
472
+ import { CiError } from "@collective-intelligence/external-apps-client-sdk"
473
+ import { CiErrorCode } from "@collective-intelligence/external-apps-client-sdk/effect"
474
+ import * as Schema from "effect/Schema"
475
+
476
+ if (!result.ok && result.error instanceof CiError) {
477
+ throw result.error
478
+ }
479
+
480
+ const code = Schema.decodeUnknownSync(CiErrorCode)(value)
481
+ ```
482
+
483
+ ### `./effect` services
484
+
485
+ `./effect` exports one `Context.Service` per client, a layer constructor and
486
+ a layer that reads Effect `Config`:
487
+
488
+ | Service | Layers | Same capability at `.` |
489
+ | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
490
+ | `CiClient` (`execute`, `executeResult`) | `layerCiClientDirect`, `layerCiClientProxy`, `layerCiClientFromExecutor`, `layerCiClientDirectConfig`, `layerCiClientProxyConfig` | `createClient`, `createDirectTransport`, `createProxyTransport` |
491
+ | `Runs` (`follow`) | `layerRuns` (needs `CiClient`) | `followRun`, `client.runs.follow` |
492
+ | `FederatedAuth` | `layerFederatedAuth`, `layerServerSessionAuth`, and their `…Config` forms | `createFederatedAuth`, `createServerSessionAuth` |
493
+ | `FixedWorkflows` (`invoke`) | `layerFixedWorkflows`, `layerFixedWorkflowsConfig` | `createFixedWorkflowClient` |
494
+ | `DelegatedRuntime` | `layerDelegatedRuntime`, `layerDelegatedRuntimeConfig` | `createDelegatedApplicationRuntime` |
495
+ | `Resources` (`bind(definition)`) | `layerResources`, `layerResourcesConfig`, `layerResourcesFromEntityTransport` | `createResourceClient` with `protocol: "entity"`, `createEntityHttpTransport` |
496
+ | `LegacyResources` (`bind(definition)`) | `layerLegacyResources`, `layerLegacyResourcesConfig` | `createResourceClient` over a `ResourceTransport` |
497
+ | `RealtimeClient` | `layerRealtimeClient`, `layerRealtimeClientConfig` | `createRealtimeClient` |
498
+
499
+ `CiClient.execute` puts the `CiError` of CI in the typed error channel;
500
+ `executeResult` keeps the `CiResult` envelope with the correlation id of CI. A
501
+ `Resources` or `LegacyResources` client fails with `CiError`, whose `details`
502
+ hold the resource `resourceCode` and `outcome`, or with `CiTransportError`
503
+ when the answer was not readable or the transport rejected.
504
+ `layerResourcesFromEntityTransport({ transport })` binds an `EntityTransport`
505
+ of the app, and `layerLegacyResources({ transport })` a `ResourceTransport`
506
+ with its lifecycle operations (`softDelete`, `restore`, `hardDelete`). A `…Config` layer takes `Config.Wrap` of the layer options: give
507
+ each field as a `Config`, for example `Config.String("CI_TENANT_URL")`, and a
508
+ function field as `Config.succeed(fn)`.
509
+
510
+ ```ts
511
+ import * as Effect from "effect/Effect"
512
+ import {
513
+ CiClient,
514
+ layerCiClientDirect
515
+ } from "@collective-intelligence/external-apps-client-sdk/effect"
516
+
517
+ const program = CiClient.use((ci) =>
518
+ ci.execute("context_get", {}, { organizationId })
519
+ ).pipe(
520
+ Effect.catchTag("CiError", (error) => Effect.succeed(error.code)),
521
+ Effect.provide(layerCiClientDirect({ auth, tenantUrl }))
522
+ )
523
+ ```
524
+
525
+ At `.`, the `CiError` type stays the envelope shape that `CiResult` carries,
526
+ and every `CiError` instance has that shape. `new FederatedAuthError(code,
527
+ message)` still works beside `new FederatedAuthError({ code, message })`.
338
528
 
339
529
  ## Workspace development
340
530
 
@@ -0,0 +1,132 @@
1
+ import { $t as layerFederatedConfig, Qt as layerFederated, Wt as ClientFetch, Xt as FederatedAuth, Zt as FederatedAuthValue, _ as layerLegacyConfig, a as LegacyResources, an as CiErrorCode, c as ResourceEntityClient, cn as FederatedAuthErrorCode, d as ResourcesLayerOptions, en as layerServerSession, f as ResourcesValue, g as layerLegacy, h as layerFromEntityTransport, i as LegacyResourceClient, in as CiError, l as Resources, m as layerConfig$3, o as LegacyResourcesLayerOptions, on as CiTransportError, p as layer$3, s as LegacyResourcesValue, sn as FederatedAuthError, tn as layerServerSessionConfig, u as ResourcesFromEntityTransportOptions } from "./resources-tBGn1Exi.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-BqdhzpcZ.js";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Config from "effect/Config";
5
+ import * as Context from "effect/Context";
6
+ import * as Effect from "effect/Effect";
7
+ import "effect/http/HttpClient";
8
+ import * as Layer from "effect/Layer";
9
+ import * as Stream from "effect/Stream";
10
+ /** An Expected Error as the `CiResult` envelope carries it: the fields of `CiError`, without `_tag`. */
11
+ declare const CiErrorEnvelope: Schema.Struct<{
12
+ readonly code: Schema.Literals<readonly ["unauthenticated", "forbidden", "not_found", "conflict", "invalid_request", "rate_limited", "unavailable", "internal"]>;
13
+ readonly details: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
14
+ readonly message: Schema.String;
15
+ readonly retryable: Schema.Boolean;
16
+ }>;
17
+ /** The `CiResult` envelope of one CI operation; `value` is the Schema of its success value. */
18
+ declare const CiResult: <Value extends Schema.Top>(value: Value) => Schema.Union<readonly [Schema.Struct<{
19
+ readonly correlationId: Schema.String;
20
+ readonly ok: Schema.Literal<true>;
21
+ readonly value: Value;
22
+ }>, Schema.Struct<{
23
+ readonly correlationId: Schema.String;
24
+ readonly error: Schema.Struct<{
25
+ readonly code: Schema.Literals<readonly ["unauthenticated", "forbidden", "not_found", "conflict", "invalid_request", "rate_limited", "unavailable", "internal"]>;
26
+ readonly details: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
27
+ readonly message: Schema.String;
28
+ readonly retryable: Schema.Boolean;
29
+ }>;
30
+ readonly ok: Schema.Literal<false>;
31
+ }>]>;
32
+ /** One page of the events of a run: the output of `runs_stream`. */
33
+ declare const CiStreamPage: Schema.Struct<{
34
+ readonly events: Schema.mutableKey<Schema.mutable<Schema.$Array<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>>>;
35
+ readonly nextCursor: Schema.mutableKey<Schema.NullOr<Schema.String>>;
36
+ }>;
37
+ /** Refetch every subscribed topic: the changes of a delivery could not be named. */
38
+ type RealtimeResync = Readonly<{
39
+ op: "resync";
40
+ }>;
41
+ type RealtimeUpdate = RealtimeChange | RealtimeResync;
42
+ declare const RealtimeClient_base: Context.ServiceClass<RealtimeClient, "@collective-intelligence/external-apps-client-sdk/RealtimeClient", Readonly<{
43
+ /**
44
+ * The changes of `topic`, one per record and delivery, in order of
45
+ * arrival; a delivery that cannot name its changes brings one Resync in
46
+ * their place. Every stream open without a last event id Resyncs, the
47
+ * first one included. The stream ends when the client closes.
48
+ */
49
+ subscribe: (topic: RealtimeTopic) => Stream.Stream<RealtimeUpdate>;
50
+ /** One element at each `access-changed` event, at once: re-check the session. */
51
+ accessChanges: Stream.Stream<void>;
52
+ }>>;
53
+ declare class RealtimeClient extends RealtimeClient_base {}
54
+ type RealtimeClientLayerOptions = Readonly<{
55
+ /** The application's ticket route, e.g. `/api/realtime/ticket`. */
56
+ ticketUrl: string;
57
+ }>;
58
+ /** `RealtimeClient` with the `fetch` of `FetchHttpClient.Fetch` and the page of this runtime. */
59
+ declare const layer$2: (options: RealtimeClientLayerOptions) => Layer.Layer<RealtimeClient, never, never>;
60
+ /** `layer` with options that Effect `Config` reads. */
61
+ declare const layerConfig$2: (config: Config.Wrap<RealtimeClientLayerOptions>) => Layer.Layer<RealtimeClient, Config.ConfigError, never>;
62
+ /** The changes and Resyncs of `topic` from the `RealtimeClient` of the context. */
63
+ declare const subscribe: (topic: RealtimeTopic) => Stream.Stream<RealtimeUpdate, never, RealtimeClient>;
64
+ type FixedWorkflowRequest = Readonly<{
65
+ /** The body of the route; `JSON.stringify` writes it. */
66
+ body: unknown;
67
+ /** The Fixed workflow route, e.g. `/api/leads/lead-1/convert`. */
68
+ url: string;
69
+ }>;
70
+ type FixedWorkflowsValue = Readonly<{
71
+ /** Posts `request` once, with a new idempotency key, and succeeds with the admitted run id. */
72
+ invoke: (request: FixedWorkflowRequest) => Effect.Effect<Readonly<{
73
+ runId: string;
74
+ }>, CiError | CiTransportError>;
75
+ }>;
76
+ declare const FixedWorkflows_base: Context.ServiceClass<FixedWorkflows, "@collective-intelligence/external-apps-client-sdk/FixedWorkflows", Readonly<{
77
+ /** Posts `request` once, with a new idempotency key, and succeeds with the admitted run id. */
78
+ invoke: (request: FixedWorkflowRequest) => Effect.Effect<Readonly<{
79
+ runId: string;
80
+ }>, CiError | CiTransportError>;
81
+ }>>;
82
+ declare class FixedWorkflows extends FixedWorkflows_base {}
83
+ type FixedWorkflowsLayerOptions = Readonly<{
84
+ fetch?: ClientFetch;
85
+ }>;
86
+ /** `FixedWorkflows` over the `fetch` of `options`. */
87
+ declare const layer$1: (options?: FixedWorkflowsLayerOptions) => Layer.Layer<FixedWorkflows, never, never>;
88
+ /** `layer` with options that Effect `Config` reads. */
89
+ declare const layerConfig$1: (config: Config.Wrap<FixedWorkflowsLayerOptions>) => Layer.Layer<FixedWorkflows, Config.ConfigError, never>;
90
+ type FollowError = CiError | CiTransportError | FederatedAuthError;
91
+ type DelegatedRuntimeValue = Readonly<{
92
+ applicationId: string;
93
+ getSnapshot: () => DelegatedRuntimeState;
94
+ /** Calls `notify` at each state change, in the call that changes it. */
95
+ subscribe: (notify: () => void) => () => void;
96
+ /** Each state, from the subscription on. */
97
+ changes: Stream.Stream<DelegatedRuntimeState>;
98
+ /** Reads the session again; a read that fails makes the state `unavailable`. */
99
+ refresh: Effect.Effect<void>;
100
+ /** Refreshes, then starts a login when the session is anonymous or expired. */
101
+ initialize: (url: string) => Effect.Effect<void, FederatedAuthError>;
102
+ login: (returnTo: string) => Effect.Effect<void, FederatedAuthError>;
103
+ logout: Effect.Effect<void>;
104
+ /** Follows a run of the session's organization; without a session, `reauthorization_required`. */
105
+ followRun: (runId: string) => Effect.Effect<CiStreamPage$1, FollowError>;
106
+ }>;
107
+ declare const DelegatedRuntime_base: Context.ServiceClass<DelegatedRuntime, "@collective-intelligence/external-apps-client-sdk/DelegatedRuntime", Readonly<{
108
+ applicationId: string;
109
+ getSnapshot: () => DelegatedRuntimeState;
110
+ /** Calls `notify` at each state change, in the call that changes it. */
111
+ subscribe: (notify: () => void) => () => void;
112
+ /** Each state, from the subscription on. */
113
+ changes: Stream.Stream<DelegatedRuntimeState>;
114
+ /** Reads the session again; a read that fails makes the state `unavailable`. */
115
+ refresh: Effect.Effect<void>;
116
+ /** Refreshes, then starts a login when the session is anonymous or expired. */
117
+ initialize: (url: string) => Effect.Effect<void, FederatedAuthError>;
118
+ login: (returnTo: string) => Effect.Effect<void, FederatedAuthError>;
119
+ logout: Effect.Effect<void>;
120
+ /** Follows a run of the session's organization; without a session, `reauthorization_required`. */
121
+ followRun: (runId: string) => Effect.Effect<CiStreamPage$1, FollowError>;
122
+ }>>;
123
+ declare class DelegatedRuntime extends DelegatedRuntime_base {}
124
+ /**
125
+ * `DelegatedRuntime` for a sealed-cookie BFF, merged with its own
126
+ * `FederatedAuth`, `CiClient` and `Runs`. A bad `authBasePath` fails with
127
+ * `configuration_error`; a bad `origin` or `proxyPath` dies with `TypeError`.
128
+ */
129
+ declare const layer: (options: DelegatedApplicationRuntimeOptions) => Layer.Layer<FederatedAuth | CiClient | Runs | DelegatedRuntime, FederatedAuthError, never>;
130
+ /** `layer` with options that Effect `Config` reads. */
131
+ declare const layerConfig: (config: Config.Wrap<DelegatedApplicationRuntimeOptions>) => Layer.Layer<FederatedAuth | CiClient | Runs | DelegatedRuntime, FederatedAuthError | Config.ConfigError, never>;
132
+ export { CiClient, type CiClientValue, CiError, CiErrorCode, CiErrorEnvelope, CiResult, CiStreamPage, CiTransportError, DEFAULT_FOLLOW_RUN_DEADLINE_MS, DelegatedRuntime, type DelegatedRuntimeValue, type ExecuteResult, FederatedAuth, FederatedAuthError, FederatedAuthErrorCode, type FederatedAuthValue, type FixedWorkflowRequest, FixedWorkflows, type FixedWorkflowsLayerOptions, type FixedWorkflowsValue, type LegacyResourceClient, LegacyResources, type LegacyResourcesLayerOptions, type LegacyResourcesValue, type RealtimeChange, RealtimeClient, type RealtimeClientLayerOptions, type RealtimeResync, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeUpdate, type ResourceEntityClient, Resources, type ResourcesFromEntityTransportOptions, type ResourcesLayerOptions, type ResourcesValue, type RunFollowOptions, Runs, type RunsValue, layerDirect as layerCiClientDirect, layerDirectConfig as layerCiClientDirectConfig, layerFromExecutor as layerCiClientFromExecutor, layerProxy as layerCiClientProxy, layerProxyConfig as layerCiClientProxyConfig, layer as layerDelegatedRuntime, layerConfig as layerDelegatedRuntimeConfig, layerFederated as layerFederatedAuth, layerFederatedConfig as layerFederatedAuthConfig, layer$1 as layerFixedWorkflows, layerConfig$1 as layerFixedWorkflowsConfig, layerLegacy as layerLegacyResources, layerLegacyConfig as layerLegacyResourcesConfig, layer$2 as layerRealtimeClient, layerConfig$2 as layerRealtimeClientConfig, layer$3 as layerResources, layerConfig$3 as layerResourcesConfig, layerFromEntityTransport as layerResourcesFromEntityTransport, layer$4 as layerRuns, layerServerSession as layerServerSessionAuth, layerServerSessionConfig as layerServerSessionAuthConfig, subscribe };
package/dist/effect.js ADDED
@@ -0,0 +1,32 @@
1
+ import { C as CiError, D as FederatedAuthErrorCode, E as FederatedAuthError, T as CiTransportError, a as layerConfig$3, c as layerLegacyConfig, i as layer$3, n as Resources, o as layerFromEntityTransport, s as layerLegacy, t as LegacyResources, w as CiErrorCode } from "./service-C7kswu6e.js";
2
+ import { C as RealtimeClient, D as subscribe, T as layerConfig$2, _ as layerDirect, a as layer$1, b as layerProxy, c as layerFederated, d as layerServerSessionConfig, f as DEFAULT_FOLLOW_RUN_DEADLINE_MS, g as CiClient, h as layer$4, i as FixedWorkflows, l as layerFederatedConfig, n as layer, o as layerConfig$1, p as Runs, r as layerConfig, s as FederatedAuth, t as DelegatedRuntime, u as layerServerSession, v as layerDirectConfig, w as layer$2, x as layerProxyConfig, y as layerFromExecutor } from "./service-CxUyG8yF.js";
3
+ import * as Schema from "effect/Schema";
4
+ /**
5
+ * The wire Schemas of the CI envelopes that `./effect` exports. The Type of
6
+ * each Schema is the type of `.` that the code uses (`./envelopes`,
7
+ * `./streaming`), with the same `readonly` and optional keys; the type test
8
+ * `type-tests/wire-schemas.ts` holds them equal.
9
+ */
10
+ /** An Expected Error as the `CiResult` envelope carries it: the fields of `CiError`, without `_tag`. */
11
+ const CiErrorEnvelope = Schema.Struct({
12
+ code: CiError.fields.code,
13
+ details: CiError.fields.details,
14
+ message: CiError.fields.message,
15
+ retryable: CiError.fields.retryable
16
+ });
17
+ /** The `CiResult` envelope of one CI operation; `value` is the Schema of its success value. */
18
+ const CiResult = (value) => Schema.Union([Schema.Struct({
19
+ correlationId: Schema.String,
20
+ ok: Schema.Literal(true),
21
+ value
22
+ }), Schema.Struct({
23
+ correlationId: Schema.String,
24
+ error: CiErrorEnvelope,
25
+ ok: Schema.Literal(false)
26
+ })]);
27
+ /** One page of the events of a run: the output of `runs_stream`. */
28
+ const CiStreamPage = Schema.Struct({
29
+ events: Schema.mutableKey(Schema.mutable(Schema.Array(Schema.JsonObject))),
30
+ nextCursor: Schema.mutableKey(Schema.NullOr(Schema.String))
31
+ });
32
+ export { CiClient, CiError, CiErrorCode, CiErrorEnvelope, CiResult, CiStreamPage, CiTransportError, DEFAULT_FOLLOW_RUN_DEADLINE_MS, DelegatedRuntime, FederatedAuth, FederatedAuthError, FederatedAuthErrorCode, FixedWorkflows, LegacyResources, RealtimeClient, Resources, Runs, layerDirect as layerCiClientDirect, layerDirectConfig as layerCiClientDirectConfig, layerFromExecutor as layerCiClientFromExecutor, layerProxy as layerCiClientProxy, layerProxyConfig as layerCiClientProxyConfig, layer as layerDelegatedRuntime, layerConfig as layerDelegatedRuntimeConfig, layerFederated as layerFederatedAuth, layerFederatedConfig as layerFederatedAuthConfig, layer$1 as layerFixedWorkflows, layerConfig$1 as layerFixedWorkflowsConfig, layerLegacy as layerLegacyResources, layerLegacyConfig as layerLegacyResourcesConfig, layer$2 as layerRealtimeClient, layerConfig$2 as layerRealtimeClientConfig, layer$3 as layerResources, layerConfig$3 as layerResourcesConfig, layerFromEntityTransport as layerResourcesFromEntityTransport, layer$4 as layerRuns, layerServerSession as layerServerSessionAuth, layerServerSessionConfig as layerServerSessionAuthConfig, subscribe };