@collective-intelligence/external-apps-client-sdk 0.1.34 → 0.1.36
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 +105 -0
- package/dist/effect.d.ts +33 -0
- package/dist/effect.js +2 -0
- package/dist/event-stream-Djqhj56G.d.ts +63 -0
- package/dist/federated-auth-lotz7RGT.d.ts +94 -0
- package/dist/index.d.ts +15 -63
- package/dist/index.js +159 -621
- package/dist/{resources-DVME85iC.js → resources-BFJrm_N2.js} +1 -21
- package/dist/{resources-GSZWfWkN.d.ts → resources-Czlu8xAB.d.ts} +5 -66
- package/dist/resources.d.ts +1 -1
- package/dist/resources.js +1 -1
- package/dist/rolldown-runtime-DC62tzP2.js +31 -0
- package/dist/service-4l3X16iR.js +750 -0
- package/package.json +15 -2
package/README.md
CHANGED
|
@@ -335,6 +335,111 @@ 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`.
|
|
423
|
+
|
|
424
|
+
The `error` of a failed `CiResult` has no `_tag`, so the `CiError` Schema does
|
|
425
|
+
not decode it. Give it to the constructor, which adds the tag. Decode a wire
|
|
426
|
+
code with its code Schema:
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
import { CiError } from "@collective-intelligence/external-apps-client-sdk"
|
|
430
|
+
import { CiErrorCode } from "@collective-intelligence/external-apps-client-sdk/effect"
|
|
431
|
+
import * as Schema from "effect/Schema"
|
|
432
|
+
|
|
433
|
+
if (!result.ok) {
|
|
434
|
+
throw new CiError(result.error)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const code = Schema.decodeUnknownSync(CiErrorCode)(value)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
At `.`, the `CiError` type stays the envelope shape that `CiResult` carries,
|
|
441
|
+
and every `CiError` instance has that shape. `new FederatedAuthError(code,
|
|
442
|
+
message)` still works beside `new FederatedAuthError({ code, message })`.
|
|
338
443
|
|
|
339
444
|
## Workspace development
|
|
340
445
|
|
package/dist/effect.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { c as CiErrorCode, d as FederatedAuthErrorCode, l as CiTransportError, s as CiError, u as FederatedAuthError } from "./federated-auth-lotz7RGT.js";
|
|
2
|
+
import { d as RealtimeTopicFilter, l as RealtimeChange, u as RealtimeTopic } from "./event-stream-Djqhj56G.js";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import "effect/Effect";
|
|
5
|
+
import "effect/http/HttpClient";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
/** Refetch every subscribed topic: the changes of a delivery could not be named. */
|
|
9
|
+
type RealtimeResync = Readonly<{
|
|
10
|
+
op: "resync";
|
|
11
|
+
}>;
|
|
12
|
+
type RealtimeUpdate = RealtimeChange | RealtimeResync;
|
|
13
|
+
declare const RealtimeClient_base: Context.ServiceClass<RealtimeClient, "@collective-intelligence/external-apps-client-sdk/RealtimeClient", Readonly<{
|
|
14
|
+
/**
|
|
15
|
+
* The changes of `topic`, one per record and delivery, in order of
|
|
16
|
+
* arrival; a delivery that cannot name its changes brings one Resync in
|
|
17
|
+
* their place. Every stream open without a last event id Resyncs, the
|
|
18
|
+
* first one included. The stream ends when the client closes.
|
|
19
|
+
*/
|
|
20
|
+
subscribe: (topic: RealtimeTopic) => Stream.Stream<RealtimeUpdate>;
|
|
21
|
+
/** One element at each `access-changed` event, at once: re-check the session. */
|
|
22
|
+
accessChanges: Stream.Stream<void>;
|
|
23
|
+
}>>;
|
|
24
|
+
declare class RealtimeClient extends RealtimeClient_base {}
|
|
25
|
+
type RealtimeClientLayerOptions = Readonly<{
|
|
26
|
+
/** The application's ticket route, e.g. `/api/realtime/ticket`. */
|
|
27
|
+
ticketUrl: string;
|
|
28
|
+
}>;
|
|
29
|
+
/** `RealtimeClient` with the `fetch` of `FetchHttpClient.Fetch` and the page of this runtime. */
|
|
30
|
+
declare const layer: (options: RealtimeClientLayerOptions) => Layer.Layer<RealtimeClient, never, never>;
|
|
31
|
+
/** The changes and Resyncs of `topic` from the `RealtimeClient` of the context. */
|
|
32
|
+
declare const subscribe: (topic: RealtimeTopic) => Stream.Stream<RealtimeUpdate, never, RealtimeClient>;
|
|
33
|
+
export { CiError, CiErrorCode, CiTransportError, FederatedAuthError, FederatedAuthErrorCode, type RealtimeChange, RealtimeClient, type RealtimeClientLayerOptions, type RealtimeResync, type RealtimeTopic, type RealtimeTopicFilter, type RealtimeUpdate, layer as layerRealtimeClient, subscribe };
|
package/dist/effect.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { d as CiError, f as CiErrorCode, h as FederatedAuthErrorCode, i as subscribe, m as FederatedAuthError, n as layer, p as CiTransportError, t as RealtimeClient } from "./service-4l3X16iR.js";
|
|
2
|
+
export { CiError, CiErrorCode, CiTransportError, FederatedAuthError, FederatedAuthErrorCode, RealtimeClient, layer as layerRealtimeClient, subscribe };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { t as ClientFetch } from "./federated-auth-lotz7RGT.js";
|
|
2
|
+
import "effect/Context";
|
|
3
|
+
import "effect/Effect";
|
|
4
|
+
import "effect/Layer";
|
|
5
|
+
import "effect/Stream";
|
|
6
|
+
/** One equality filter on a dotted data path of a topic's records. */
|
|
7
|
+
type RealtimeTopicFilter = Readonly<{
|
|
8
|
+
field: string;
|
|
9
|
+
eq: string | number | boolean | null;
|
|
10
|
+
}>;
|
|
11
|
+
/** The records of one entity schema, named by FQN or id, optionally filtered. */
|
|
12
|
+
type RealtimeTopic = Readonly<{
|
|
13
|
+
schema: string;
|
|
14
|
+
filter?: RealtimeTopicFilter;
|
|
15
|
+
}>;
|
|
16
|
+
/** A record of a subscribed topic changed; refetch it, the event carries ids only. */
|
|
17
|
+
type RealtimeChange = Readonly<{
|
|
18
|
+
id: string;
|
|
19
|
+
op: "create" | "update" | "delete";
|
|
20
|
+
revision: string;
|
|
21
|
+
topic: RealtimeTopic;
|
|
22
|
+
}>;
|
|
23
|
+
/** One stable key per topic, whatever the key order of the object. */
|
|
24
|
+
declare const realtimeTopicKey: ({ filter, schema }: RealtimeTopic) => string;
|
|
25
|
+
type PageEvents = Readonly<{
|
|
26
|
+
addEventListener: (type: string, listener: () => void) => void;
|
|
27
|
+
removeEventListener: (type: string, listener: () => void) => void;
|
|
28
|
+
}>;
|
|
29
|
+
type RealtimeDocument = PageEvents & Readonly<{
|
|
30
|
+
visibilityState: DocumentVisibilityState;
|
|
31
|
+
}>;
|
|
32
|
+
type RealtimeWindow = PageEvents;
|
|
33
|
+
/** One dispatched Server-Sent Event. */
|
|
34
|
+
type RealtimeStreamEvent = Readonly<{
|
|
35
|
+
type: string;
|
|
36
|
+
data: string;
|
|
37
|
+
/** The `id:` of this event, when it carried one. */
|
|
38
|
+
id: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* How a stream ended: `status` when the server refused it, and the
|
|
42
|
+
* reconnect delay the server asked for with `retry:` or `Retry-After`.
|
|
43
|
+
*/
|
|
44
|
+
type RealtimeStreamEnd = Readonly<{
|
|
45
|
+
status: number | undefined;
|
|
46
|
+
retryMilliseconds: number | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
type RealtimeStreamHandlers = Readonly<{
|
|
49
|
+
onOpen: () => void;
|
|
50
|
+
onEvent: (event: RealtimeStreamEvent) => void;
|
|
51
|
+
/** A comment or an `id:`-only frame: the server is alive. */
|
|
52
|
+
onPing: (id?: string) => void;
|
|
53
|
+
/** Called once, unless the stream was closed by the client. */
|
|
54
|
+
onEnd: (end: RealtimeStreamEnd) => void;
|
|
55
|
+
}>;
|
|
56
|
+
type RealtimeEventSource = Readonly<{
|
|
57
|
+
close: () => void;
|
|
58
|
+
}>;
|
|
59
|
+
/** Opens one event stream; `close` stops it without calling `onEnd`. */
|
|
60
|
+
type RealtimeEventSourceFactory = (url: string, handlers: RealtimeStreamHandlers) => RealtimeEventSource;
|
|
61
|
+
/** Reads `text/event-stream` with `fetch`, so pings and refusals are visible. */
|
|
62
|
+
declare const createFetchEventSourceFactory: (fetch: ClientFetch) => RealtimeEventSourceFactory;
|
|
63
|
+
export { RealtimeStreamHandlers as a, RealtimeWindow as c, RealtimeTopicFilter as d, realtimeTopicKey as f, RealtimeStreamEvent as i, RealtimeChange as l, RealtimeEventSourceFactory as n, createFetchEventSourceFactory as o, RealtimeStreamEnd as r, RealtimeDocument as s, RealtimeEventSource as t, RealtimeTopic as u };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
/** Code of an Expected Error that CI returns for an operation. */
|
|
3
|
+
declare const CiErrorCode: Schema.Literals<readonly ["unauthenticated", "forbidden", "not_found", "conflict", "invalid_request", "rate_limited", "unavailable", "internal"]>;
|
|
4
|
+
type CiErrorCode = typeof CiErrorCode.Type;
|
|
5
|
+
/** Code of an Expected Error of the federated sign-in flow. */
|
|
6
|
+
declare const FederatedAuthErrorCode: Schema.Literals<readonly ["configuration_error", "invalid_return_target", "invalid_callback", "invalid_state", "transaction_expired", "authorization_failed", "token_exchange_failed", "reauthorization_required"]>;
|
|
7
|
+
type FederatedAuthErrorCode = typeof FederatedAuthErrorCode.Type;
|
|
8
|
+
declare const CiError_base: Schema.Class<CiError, Schema.TaggedStruct<"CiError", {
|
|
9
|
+
readonly code: Schema.Literals<readonly ["unauthenticated", "forbidden", "not_found", "conflict", "invalid_request", "rate_limited", "unavailable", "internal"]>;
|
|
10
|
+
readonly details: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
11
|
+
readonly message: Schema.String;
|
|
12
|
+
readonly retryable: Schema.Boolean;
|
|
13
|
+
}>, import("effect/Cause").YieldableError>;
|
|
14
|
+
/** An Expected Error that CI returns for an operation. */
|
|
15
|
+
declare class CiError extends CiError_base {}
|
|
16
|
+
type FederatedAuthErrorFields = Readonly<{
|
|
17
|
+
code: FederatedAuthErrorCode;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
declare const FederatedAuthError_base: Schema.Class<FederatedAuthError, Schema.TaggedStruct<"FederatedAuthError", {
|
|
21
|
+
readonly code: Schema.Literals<readonly ["configuration_error", "invalid_return_target", "invalid_callback", "invalid_state", "transaction_expired", "authorization_failed", "token_exchange_failed", "reauthorization_required"]>;
|
|
22
|
+
readonly message: Schema.String;
|
|
23
|
+
}>, import("effect/Cause").YieldableError>;
|
|
24
|
+
/** An Expected Error of the federated sign-in flow. */
|
|
25
|
+
declare class FederatedAuthError extends FederatedAuthError_base {
|
|
26
|
+
constructor(fields: FederatedAuthErrorFields, options?: Schema.MakeOptions);
|
|
27
|
+
/** The positional form that `.` callers used before the tagged class. */
|
|
28
|
+
constructor(code: FederatedAuthErrorCode, message: string);
|
|
29
|
+
}
|
|
30
|
+
declare const CiTransportError_base: Schema.Class<CiTransportError, Schema.TaggedStruct<"CiTransportError", {
|
|
31
|
+
readonly cause: Schema.Defect;
|
|
32
|
+
}>, import("effect/Cause").YieldableError>;
|
|
33
|
+
/** The request did not reach CI, or CI's response was not readable. */
|
|
34
|
+
declare class CiTransportError extends CiTransportError_base {}
|
|
35
|
+
/**
|
|
36
|
+
* The signed-in CI user as the application's BFF reports it: the fields of
|
|
37
|
+
* CI's `/oauth/identity`, read live by the server, plus email and name.
|
|
38
|
+
*/
|
|
39
|
+
type FederatedSessionIdentity = Readonly<{
|
|
40
|
+
appId: string;
|
|
41
|
+
/** The App Permissions of the user's effective roles. */
|
|
42
|
+
appPermissions: readonly string[];
|
|
43
|
+
email: string | null;
|
|
44
|
+
/** A person is a member or an External App User of one Organization, never both. */
|
|
45
|
+
kind: "member" | "external_app_user";
|
|
46
|
+
name: string | null;
|
|
47
|
+
organizationId: string;
|
|
48
|
+
/** The user's effective roles on the app. */
|
|
49
|
+
roles: readonly string[];
|
|
50
|
+
userId: string;
|
|
51
|
+
}>;
|
|
52
|
+
type FederatedAuthState = Readonly<{
|
|
53
|
+
status: "anonymous";
|
|
54
|
+
}> | Readonly<{
|
|
55
|
+
status: "redirecting";
|
|
56
|
+
}> | Readonly<{
|
|
57
|
+
expiresAt: number;
|
|
58
|
+
identity?: FederatedSessionIdentity;
|
|
59
|
+
status: "authenticated";
|
|
60
|
+
}> | Readonly<{
|
|
61
|
+
status: "expired";
|
|
62
|
+
}> | Readonly<{
|
|
63
|
+
error: FederatedAuthError;
|
|
64
|
+
status: "error";
|
|
65
|
+
}>;
|
|
66
|
+
type FederatedAuth = Readonly<{
|
|
67
|
+
beginLogin: (options: Readonly<{
|
|
68
|
+
returnTo: string;
|
|
69
|
+
}>) => Promise<string>;
|
|
70
|
+
completeLogin: (callbackUrl: string) => Promise<Readonly<{
|
|
71
|
+
returnTo: string;
|
|
72
|
+
}>>;
|
|
73
|
+
getAccessToken: () => Promise<string>;
|
|
74
|
+
getState: () => FederatedAuthState;
|
|
75
|
+
logout: () => Promise<void>;
|
|
76
|
+
reauthorize: (options?: Readonly<{
|
|
77
|
+
returnTo?: string;
|
|
78
|
+
}>) => Promise<string>;
|
|
79
|
+
subscribe: (listener: (state: FederatedAuthState) => void) => () => void;
|
|
80
|
+
}>;
|
|
81
|
+
type ClientFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
82
|
+
type FederatedAuthOptions = Readonly<{
|
|
83
|
+
clientId: string;
|
|
84
|
+
crypto?: Pick<Crypto, "getRandomValues" | "subtle">;
|
|
85
|
+
fetch?: ClientFetch;
|
|
86
|
+
navigate?: (url: string) => void;
|
|
87
|
+
now?: () => number;
|
|
88
|
+
redirectUri: string;
|
|
89
|
+
scopes: readonly string[];
|
|
90
|
+
sessionStorage?: Pick<Storage, "getItem" | "removeItem" | "setItem">;
|
|
91
|
+
tenantUrl: string;
|
|
92
|
+
}>;
|
|
93
|
+
declare const createFederatedAuth: (options: FederatedAuthOptions) => FederatedAuth;
|
|
94
|
+
export { FederatedSessionIdentity as a, CiErrorCode as c, FederatedAuthErrorCode as d, FederatedAuthState as i, CiTransportError as l, FederatedAuth as n, createFederatedAuth as o, FederatedAuthOptions as r, CiError as s, ClientFetch as t, FederatedAuthError as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as FederatedSessionIdentity, d as FederatedAuthErrorCode, i as FederatedAuthState, l as CiTransportError, n as FederatedAuth, o as createFederatedAuth, r as FederatedAuthOptions, s as CiError$1, t as ClientFetch, u as FederatedAuthError } from "./federated-auth-lotz7RGT.js";
|
|
2
|
+
import { a as RealtimeStreamHandlers, c as RealtimeWindow, d as RealtimeTopicFilter, f as realtimeTopicKey, i as RealtimeStreamEvent, l as RealtimeChange, n as RealtimeEventSourceFactory, o as createFetchEventSourceFactory, r as RealtimeStreamEnd, s as RealtimeDocument, t as RealtimeEventSource, u as RealtimeTopic } from "./event-stream-Djqhj56G.js";
|
|
3
|
+
import { $ as ResourceSort, A as ResourceCreateRequest, B as ResourceLifecycleInput, C as EntityUploadInput, Ct as ConversationContinueTarget, D as ResourceCapabilities, Dt as QueryFilter, E as PortableResourceSchema, Et as KnowledgeQuery, F as ResourceFilter, G as ResourceMutationInput, H as ResourceListQuery, I as ResourceGetRequest, J as ResourceRecord, K as ResourcePagination, L as ResourceId, M as ResourceDefinition, N as ResourceError, O as ResourceClient, Ot as SearchQuery, P as ResourceErrorCode, Q as ResourceRevision, R as ResourceIdentityField, S as EntityUpdateInput, St as ApplicationRole, T as IdempotencyKey, Tt as JsonObject, U as ResourceListRequest, V as ResourceLifecycleRequest, W as ResourceListResult, X as ResourceRequestOptions, Y as ResourceRecordId, Z as ResourceResult, _ as EntityPage, _t as OperationExecutionOptions, a as isEntityReadLimitError, at as createProxyTransport, b as EntityRequest, bt as isClientOperationId, c as EntityCreateInput, ct as CiResult, d as EntityFileValue, dt as OperationSuccess, et as ResourceTransport, f as EntityFileWrite, ft as ClientOperationDefinition, g as EntityOperationResult, gt as ClientOperationOutput, h as EntityOperation, ht as ClientOperationMap, i as createEntityProtocol, it as ProxyTransportOptions, j as ResourceCursor, k as ResourceCreateInput, kt as WorkflowInvokeTarget, l as EntityDeleteInput, lt as JsonValue, m as EntityMemberValue, mt as ClientOperationInput, n as EntityHttpTransportOptions, nt as ResourceUpdateRequest, o as createResourceClient, ot as CiError$2, p as EntityListQuery, pt as ClientOperationId, q as ResourcePaginationMode, r as createEntityHttpTransport, rt as ProxyAuthentication, s as EntityClient, st as CiErrorCode, t as EntityHttpDestination, tt as ResourceTransportRequest, u as EntityFileFieldWrite, ut as OperationRequest, v as EntityProtocol, vt as TypedOperationExecutor, w as EntityUploadSlot, wt as ConversationHistory, x as EntityTransport, xt as AgentInvokeTarget, y as EntityReadLimitDetails, yt as clientOperationIds, z as ResourceJsonValue } from "./resources-Czlu8xAB.js";
|
|
2
4
|
type ServerSessionAuthOptions = Readonly<{
|
|
3
5
|
basePath: string;
|
|
4
6
|
fetch?: ClientFetch;
|
|
@@ -202,7 +204,7 @@ declare const createDelegatedApplicationRuntime: (options: DelegatedApplicationR
|
|
|
202
204
|
created: boolean;
|
|
203
205
|
kind: "member" | "external_app_user";
|
|
204
206
|
}>;
|
|
205
|
-
context_get: ClientOperationDefinition<Readonly<Record<string, string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly<{
|
|
207
|
+
context_get: ClientOperationDefinition<unknown[] | Readonly<Record<string, string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly<{
|
|
206
208
|
readonly [key: string]: string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null;
|
|
207
209
|
}> | null)[] | Readonly<{
|
|
208
210
|
readonly [key: string]: string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null;
|
|
@@ -226,7 +228,7 @@ declare const createDelegatedApplicationRuntime: (options: DelegatedApplicationR
|
|
|
226
228
|
readonly [key: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null;
|
|
227
229
|
}> | null)[] | Readonly<{
|
|
228
230
|
readonly [key: string]: string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null;
|
|
229
|
-
}> | null
|
|
231
|
+
}> | null>>, Readonly<Record<string, string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly<{
|
|
230
232
|
readonly [key: string]: string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null;
|
|
231
233
|
}> | null)[] | Readonly<{
|
|
232
234
|
readonly [key: string]: string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null)[] | Readonly< /*elided*/ any> | null;
|
|
@@ -808,67 +810,10 @@ type DirectTransportOptions = Readonly<{
|
|
|
808
810
|
tenantUrl: string;
|
|
809
811
|
}>;
|
|
810
812
|
declare const createDirectTransport: <Operations extends ClientOperationMap>(options: DirectTransportOptions) => TypedOperationExecutor<Operations>;
|
|
811
|
-
/** One dispatched Server-Sent Event. */
|
|
812
|
-
type RealtimeStreamEvent = Readonly<{
|
|
813
|
-
type: string;
|
|
814
|
-
data: string;
|
|
815
|
-
/** The `id:` of this event, when it carried one. */
|
|
816
|
-
id: string | undefined;
|
|
817
|
-
}>;
|
|
818
|
-
/**
|
|
819
|
-
* How a stream ended: `status` when the server refused it, and the
|
|
820
|
-
* reconnect delay the server asked for with `retry:` or `Retry-After`.
|
|
821
|
-
*/
|
|
822
|
-
type RealtimeStreamEnd = Readonly<{
|
|
823
|
-
status: number | undefined;
|
|
824
|
-
retryMilliseconds: number | undefined;
|
|
825
|
-
}>;
|
|
826
|
-
type RealtimeStreamHandlers = Readonly<{
|
|
827
|
-
onOpen: () => void;
|
|
828
|
-
onEvent: (event: RealtimeStreamEvent) => void;
|
|
829
|
-
/** A comment or an `id:`-only frame: the server is alive. */
|
|
830
|
-
onPing: (id?: string) => void;
|
|
831
|
-
/** Called once, unless the stream was closed by the client. */
|
|
832
|
-
onEnd: (end: RealtimeStreamEnd) => void;
|
|
833
|
-
}>;
|
|
834
|
-
type RealtimeEventSource = Readonly<{
|
|
835
|
-
close: () => void;
|
|
836
|
-
}>;
|
|
837
|
-
/** Opens one event stream; `close` stops it without calling `onEnd`. */
|
|
838
|
-
type RealtimeEventSourceFactory = (url: string, handlers: RealtimeStreamHandlers) => RealtimeEventSource;
|
|
839
|
-
/** Reads `text/event-stream` with `fetch`, so pings and refusals are visible. */
|
|
840
|
-
declare const createFetchEventSourceFactory: (fetch: ClientFetch) => RealtimeEventSourceFactory;
|
|
841
|
-
/** One equality filter on a dotted data path of a topic's records. */
|
|
842
|
-
type RealtimeTopicFilter = Readonly<{
|
|
843
|
-
field: string;
|
|
844
|
-
eq: string | number | boolean | null;
|
|
845
|
-
}>;
|
|
846
|
-
/** The records of one entity schema, named by FQN or id, optionally filtered. */
|
|
847
|
-
type RealtimeTopic = Readonly<{
|
|
848
|
-
schema: string;
|
|
849
|
-
filter?: RealtimeTopicFilter;
|
|
850
|
-
}>;
|
|
851
|
-
/** A record of a subscribed topic changed; refetch it, the event carries ids only. */
|
|
852
|
-
type RealtimeChange = Readonly<{
|
|
853
|
-
id: string;
|
|
854
|
-
op: "create" | "update" | "delete";
|
|
855
|
-
revision: string;
|
|
856
|
-
topic: RealtimeTopic;
|
|
857
|
-
}>;
|
|
858
|
-
/** One stable key per topic, whatever the key order of the object. */
|
|
859
|
-
declare const realtimeTopicKey: ({ filter, schema }: RealtimeTopic) => string;
|
|
860
813
|
/** Schedules `callback` after `milliseconds`; the result cancels it. */
|
|
861
814
|
type RealtimeTimers = Readonly<{
|
|
862
815
|
schedule: (callback: () => void, milliseconds: number) => () => void;
|
|
863
816
|
}>;
|
|
864
|
-
type PageEvents = Readonly<{
|
|
865
|
-
addEventListener: (type: string, listener: () => void) => void;
|
|
866
|
-
removeEventListener: (type: string, listener: () => void) => void;
|
|
867
|
-
}>;
|
|
868
|
-
type RealtimeDocument = PageEvents & Readonly<{
|
|
869
|
-
visibilityState: DocumentVisibilityState;
|
|
870
|
-
}>;
|
|
871
|
-
type RealtimeWindow = PageEvents;
|
|
872
817
|
type RealtimeClientOptions = Readonly<{
|
|
873
818
|
/** The application's ticket route, e.g. `/api/realtime/ticket`. */
|
|
874
819
|
ticketUrl: string;
|
|
@@ -918,8 +863,15 @@ type RealtimeClient = Readonly<{
|
|
|
918
863
|
* Changes and resets reach the listeners in one delivery per tab, 250 to
|
|
919
864
|
* 1000 ms after the first of them: a burst of changes refetches once, and
|
|
920
865
|
* tabs that reset together refetch apart.
|
|
921
|
-
*
|
|
922
|
-
*
|
|
866
|
+
* The client runs on the realtime service (`./service`) in a runtime of its
|
|
867
|
+
* own; `close` disposes of it.
|
|
923
868
|
*/
|
|
924
869
|
declare const createRealtimeClient: (options: RealtimeClientOptions) => RealtimeClient;
|
|
925
|
-
|
|
870
|
+
/** The class of an Expected Error that CI returns. */
|
|
871
|
+
declare const CiError: typeof CiError$1;
|
|
872
|
+
/**
|
|
873
|
+
* An Expected Error as the `CiResult` envelope carries it. This type of `.`
|
|
874
|
+
* keeps the envelope shape; each instance of the `CiError` class has it.
|
|
875
|
+
*/
|
|
876
|
+
type CiError = CiError$2;
|
|
877
|
+
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 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 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, isEntityReadLimitError, nextStreamCursor, realtimeTopicKey };
|