@kinotic-ai/core 5.0.0-beta.2 → 5.0.0-beta.20

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/dist/index.d.ts CHANGED
@@ -11,7 +11,9 @@ interface ResolvedCredentials {
11
11
  /**
12
12
  * Finds the credentials a Kinotic connection authenticates with. Consulted on every
13
13
  * (re)connect, so an implementation backing short-lived credentials can refresh them each
14
- * time. Returning null means this resolver found nothing — in a
14
+ * time; one whose resolution is expensive — a network round-trip, a disk read — must cache
15
+ * the result internally and refresh only as expiry nears, since reconnects pay the cost of
16
+ * every resolve. Returning null means this resolver found nothing — in a
15
17
  * {@link ChainedCredentialsResolver} the next resolver tries; at the top level the connect
16
18
  * fails naming every resolver consulted.
17
19
  */
@@ -54,27 +56,37 @@ declare class ServerInfo {
54
56
  port?: number | null;
55
57
  useSSL?: boolean | null;
56
58
  }
59
+ /**
60
+ * Builds the base URL of a server for the given scheme stem ({@code 'ws'} or {@code 'http'}):
61
+ * TLS appends {@code s}, and the port is omitted when absent so the scheme default applies.
62
+ */
63
+ declare function buildServerUrl(server: ServerInfo, scheme: "ws" | "http"): string;
64
+ /**
65
+ * Builds the WebSocket broker URL the STOMP client connects to for a given server — the
66
+ * single source of truth for the broker path, so a caller supplying its own
67
+ * {@link WebSocketFactory} never re-types it and drifts from core.
68
+ */
69
+ declare function buildBrokerUrl(server: ServerInfo): string;
57
70
  declare enum SessionKeepAliveMode {
58
71
  NONE = "NONE",
59
72
  ACTIVITY = "ACTIVITY",
60
73
  CONNECTION = "CONNECTION"
61
74
  }
62
75
  /**
63
- * Options for {@link IKinotic#connect}. Every field is optional: absent server fields resolve
64
- * from the environment (the {@code KINOTIC_SERVER_HOST} / {@code KINOTIC_SERVER_PORT} /
65
- * {@code KINOTIC_SERVER_USE_SSL} variables, the browser's own location, then
66
- * {@code https://api.kinotic.com}), and absent {@link credentials} resolve through the
67
- * default {@link ChainedCredentialsResolver} (environment variables, then the browser
68
- * session).
76
+ * Options for {@link IKinotic#connect}. Every field is optional: absent {@link server}
77
+ * fields resolve from the environment (the {@code KINOTIC_SERVER_HOST} /
78
+ * {@code KINOTIC_SERVER_PORT} / {@code KINOTIC_SERVER_USE_SSL} variables, the browser's own
79
+ * location, then {@code https://api.kinotic.ai}), and absent {@link credentials} resolve
80
+ * through the default {@link ChainedCredentialsResolver} (environment variables, then the
81
+ * browser session).
69
82
  *
70
83
  * Authentication is performed during the WebSocket upgrade (handshake), not in the STOMP
71
84
  * CONNECT frame: the resolved credentials supply the upgrade headers, or none for
72
85
  * session-cookie auth.
73
86
  */
74
87
  interface ConnectOptions {
75
- host?: string;
76
- port?: number | null;
77
- useSSL?: boolean | null;
88
+ /** The server to connect to; absent fields resolve from the environment. */
89
+ server?: Partial<ServerInfo>;
78
90
  /**
79
91
  * Finds the credentials this connection authenticates with, consulted on every
80
92
  * (re)connect. Absent, the default resolution chain applies.
@@ -112,7 +124,7 @@ interface Identifiable<T> {
112
124
  *
113
125
  * This is the base shape every participant shares, regardless of scope, and is what RPC-only
114
126
  * consumers work with directly. The Kinotic OS contract layers scope-typed participants on top
115
- * of it — see the participant types in {@code @kinotic-ai/os-api}.
127
+ * of it — see the participant types in {@code @kinotic-ai/management-api}.
116
128
  *
117
129
  * Mirrors the server {@code org.kinotic.core.api.security.Participant}.
118
130
  *
@@ -134,7 +146,7 @@ interface IParticipant extends Identifiable<string> {
134
146
  }
135
147
  /**
136
148
  * A logged-in participant on the RPC layer. Alias of {@link IParticipant}; the Kinotic OS contract
137
- * ({@code @kinotic-ai/os-api}) narrows this to scope-typed participants.
149
+ * ({@code @kinotic-ai/management-api}) narrows this to scope-typed participants.
138
150
  *
139
151
  * Created by Navid Mitchell on 6/2/20
140
152
  */
@@ -147,7 +159,7 @@ declare class ConnectedInfo {
147
159
  participant: Participant;
148
160
  }
149
161
  /**
150
- * Part of the low level portion of kinoitc representing data to be processed
162
+ * Part of the low level portion of kinotic representing data to be processed
151
163
  *
152
164
  * This is similar to a Stomp Frame but with more required information and no control plane semantics.
153
165
  *
@@ -203,17 +215,27 @@ interface IEvent {
203
215
  setHeader(key: string, value: string): void;
204
216
  }
205
217
  /**
206
- * Part of the low level portion of kinoitc representing a connection to a kinoitc server
218
+ * Part of the low level portion of kinotic representing a connection to a kinotic server
207
219
  * This is similar to a Stomp Client but with more required information and no control plane semantics.
208
220
  *
209
221
  * Created by Navid Mitchell on 2019-01-04.
210
222
  */
211
223
  interface IEventBus {
212
224
  /**
213
- * Any errors emitted by this observable will be fatal and the connection will be closed.
214
- * You will need to resolve the problem and reconnect.
225
+ * Emits when the connection ends: an established connection drops before any reconnect, a failure
226
+ * closes it, or {@link disconnect} is called. It carries the failure that ended the connection, or
227
+ * null when nothing failed. The server releases everything it held for the connection at that moment:
228
+ * every request made on it is failed to its caller, and every invocation it was serving is failed to
229
+ * its requester. An end the client reconnects from leaves {@link IEventBus#isConnectionActive} true;
230
+ * one that needs a fresh {@link IEventBus#connect} leaves it false.
231
+ */
232
+ connectionEnded: Observable<Error | null>;
233
+ /**
234
+ * Emits each time a connection is established: the first {@link connect}, and every reconnect the
235
+ * client makes after one ends. It carries the {@link ConnectedInfo} the server issued for that
236
+ * connection, which names the session the requests made on it belong to.
215
237
  */
216
- fatalErrors: Observable<Error>;
238
+ connectionEstablished: Observable<ConnectedInfo>;
217
239
  /**
218
240
  * The {@link ServerInfo} used when connecting, if connected or null
219
241
  */
@@ -237,14 +259,15 @@ interface IEventBus {
237
259
  disconnect(force?: boolean): Promise<void>;
238
260
  /**
239
261
  * Determines if the connection is connected.
240
- * This means that there is an open connection to the Kinoitc server
262
+ * This means that there is an open connection to the Kinotic server
241
263
  * @return true if the connection is active false if not
242
264
  */
243
265
  isConnected(): boolean;
244
266
  /**
245
267
  * Determines if the connection is active.
246
268
  * This means {@link IEventBus#connect()} was called and was successful. The underlying connection may not be established yet.
247
- * If this is true and {@link IEventBus#isConnected} is false messages sent will be queued
269
+ * Subscriptions made while active are established once the connection comes up; sends require
270
+ * {@link IEventBus#isConnected}
248
271
  * @return true if the connection is active false if not
249
272
  */
250
273
  isConnectionActive(): boolean;
@@ -276,8 +299,11 @@ interface IEventBus {
276
299
  */
277
300
  requestStream(event: IEvent, sendControlEvents: boolean): Observable<IEvent>;
278
301
  /**
279
- * Send a single {@link IEvent} to the connected server
302
+ * Send a single {@link IEvent} to the connected server. Events are never held for a later
303
+ * connection, so the caller decides what an event it could not send means — see
304
+ * {@link isConnected}.
280
305
  * @param event to send
306
+ * @throws if the connection is not established
281
307
  */
282
308
  send(event: IEvent): void;
283
309
  }
@@ -290,6 +316,12 @@ declare enum EventConstants {
290
316
  CONTENT_LENGTH_HEADER = "content-length",
291
317
  REPLY_TO_HEADER = "reply-to",
292
318
  /**
319
+ * The participant that sent the event, as JSON. The gateway writes it on every event it delivers to a
320
+ * client, from the participant authenticated on the connection the event came from, and drops any a
321
+ * client supplies; an event that originated inside the platform with no participant bound carries none.
322
+ */
323
+ SENDER_HEADER = "sender",
324
+ /**
293
325
  * Header provided by the server on connection to provide the {@link ConnectedInfo} as a JSON string
294
326
  */
295
327
  CONNECTED_INFO_HEADER = "connected-info",
@@ -351,16 +383,25 @@ declare enum EventConstants {
351
383
  TRACESTATE_HEADER = "tracestate"
352
384
  }
353
385
  /**
354
- * Interface for the service context, extendable by users for type-safe context data.
386
+ * The request context a {@link Context} method receives as its final parameter: the calling participant,
387
+ * plus whatever the registered {@link ContextInterceptor} adds. Extend it for type-safe context data.
355
388
  *
356
389
  * @author Navid Mitchell 🤝Grok
357
390
  * @since 3/25/2025
358
391
  */
359
392
  interface ServiceContext {
393
+ /**
394
+ * The participant that invoked the service method, as authenticated by the gateway on the calling
395
+ * connection. Absent when the invocation originated inside the platform with no participant bound,
396
+ * such as a scheduled job.
397
+ */
398
+ participant?: Participant;
360
399
  [key: string]: any;
361
400
  }
362
401
  /**
363
402
  * Interface for interceptors that create or modify the ServiceContext before service method invocation.
403
+ * The context handed in already carries the calling participant; the context returned is the one the
404
+ * method receives.
364
405
  *
365
406
  * @author Navid Mitchell 🤝Grok
366
407
  * @since 3/25/2025
@@ -369,9 +410,9 @@ interface ContextInterceptor<T extends ServiceContext> {
369
410
  intercept(event: IEvent, context: T): Promise<T> | T;
370
411
  }
371
412
  /**
372
- * `CRI` is a Kinoitc Resource Identifier used by Kinoitc to route requests appropriately.
413
+ * `CRI` is a Kinotic Resource Identifier used by Kinotic to route requests appropriately.
373
414
  *
374
- * The `CRI` is a URI where the parts are named differently for clarity as to their purpose within Kinoitc.
415
+ * The `CRI` is a URI where the parts are named differently for clarity as to their purpose within Kinotic.
375
416
  *
376
417
  * Will be in a format as follows where anything surrounded with `[]` is optional:
377
418
  *
@@ -409,7 +450,7 @@ interface CRI {
409
450
  * The zone this `CRI` is addressed in, or `null` if un-zoned.
410
451
  *
411
452
  * The zone is the isolation boundary routing is validated against, such as
412
- * `app.acme-org.orders-app` or `os-api`.
453
+ * `app.acme-org.orders-app` or `management-api`.
413
454
  *
414
455
  * For the following CRI, `zone` would be the portion specified by `zone`:
415
456
  *
@@ -528,6 +569,12 @@ declare class ServiceIdentifier {
528
569
  * @return the cri for this {@link ServiceIdentifier}
529
570
  */
530
571
  cri(): CRI;
572
+ /**
573
+ * The {@link CRI} of this service's shared, unscoped address. Every instance of a scoped
574
+ * service may listen here for the methods any instance can answer.
575
+ * @return the cri without the scope part
576
+ */
577
+ unscopedCri(): CRI;
531
578
  }
532
579
  import { Observable as Observable2 } from "rxjs";
533
580
  /**
@@ -600,6 +647,7 @@ interface IServiceRegistry {
600
647
  */
601
648
  registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
602
649
  }
650
+ import { ServiceDefinition } from "@kinotic-ai/idl";
603
651
  /**
604
652
  * An implementation of a {@link IEventFactory} which uses JSON content
605
653
  */
@@ -613,11 +661,20 @@ declare class TextEventFactory implements IEventFactory {
613
661
  create(cri: string, args: any[] | null | undefined): IEvent;
614
662
  }
615
663
  /**
664
+ * Declares the definitions of the project's published services, as `kinotic sync` generates them into the
665
+ * project's ServiceDefinitions module, so every registry registers each service in the platform's service
666
+ * directory with its definition when the service comes online. A definition declared again for a qualified
667
+ * name replaces the one held.
668
+ * @param definitions the generated definitions
669
+ */
670
+ declare function declareServiceDefinitions(definitions: ServiceDefinition[]): void;
671
+ /**
616
672
  * The default implementation of {@link IServiceRegistry}
617
673
  */
618
674
  declare class ServiceRegistry implements IServiceRegistry {
619
675
  private _eventBus;
620
676
  private supervisors;
677
+ private entries;
621
678
  private contextInterceptor;
622
679
  private debugLogger;
623
680
  constructor(eventBus: IEventBus);
@@ -626,6 +683,14 @@ declare class ServiceRegistry implements IServiceRegistry {
626
683
  serviceProxy(serviceIdentifier: string): IServiceProxy;
627
684
  register(serviceIdentifier: ServiceIdentifier, service: any): void;
628
685
  unRegister(serviceIdentifier: ServiceIdentifier): void;
686
+ /**
687
+ * Registers every application service registered so far in the platform's service directory, with the
688
+ * definition the project declared for it, so the directory lists the service and the platform checks
689
+ * requests to it; a service the platform refuses fails the registration. A service registered later is
690
+ * registered in the directory as it registers here.
691
+ */
692
+ registerEntries(): Promise<void>;
693
+ private registerEntry;
629
694
  registerContextInterceptor<T extends ServiceContext>(interceptor: ContextInterceptor<T> | null): void;
630
695
  }
631
696
  /**
@@ -693,8 +758,9 @@ declare class KinoticSingleton implements IKinotic {
693
758
  get eventBus(): IEventBus;
694
759
  set eventBus(eventBus: IEventBus);
695
760
  /**
696
- * Connects to a Kinotic server. Every option is optional: absent server fields and
697
- * credentials resolve from the environment — see {@link ConnectOptions}.
761
+ * Connects to a Kinotic server and registers the application services registered so far in the platform's
762
+ * service directory. Every option is optional: absent server fields and credentials resolve from the
763
+ * environment — see {@link ConnectOptions}.
698
764
  * @param options overrides for the resolved connection, or nothing to resolve everything
699
765
  * @return Promise containing the result of the initial connection attempt
700
766
  */
@@ -722,12 +788,67 @@ declare class KinoticSingleton implements IKinotic {
722
788
  */
723
789
  declare const Kinotic: KinoticSingleton;
724
790
  /**
791
+ * A role a service declares for its resource type, named `<type>.<level>`, bundling permissions of the type.
792
+ */
793
+ interface AuthzRoleDeclaration {
794
+ /** The role's id, `<type>.<level>` with a lowercase identifier as the level. */
795
+ id: string;
796
+ /** The short names of the type's permissions the role bundles, such as `can_generate`. */
797
+ permissions: string[];
798
+ }
799
+ /**
800
+ * What a service declares about the resource its functions act on, as {@link AuthzResource} declares it.
801
+ */
802
+ interface AuthzResourceDeclaration {
803
+ /** The resource type, a lowercase identifier such as `report`. */
804
+ value: string;
805
+ /** The type the resource sits under, such as `tenant` or `application`; absent for a root type. */
806
+ parent?: string | null;
807
+ /** The id template every function is checked on, such as `{@applicationId}`, when the service acts on one object. */
808
+ objectId?: string | null;
809
+ /** The permission every function of the service needs, when they all need the same one. */
810
+ permission?: string | null;
811
+ /** The roles the service declares for its type. */
812
+ roles?: AuthzRoleDeclaration[] | null;
813
+ }
814
+ /**
815
+ * What a function declares about its check, as {@link AuthzCheck} declares it; whatever is left out is derived
816
+ * from the function's name and parameters.
817
+ */
818
+ interface AuthzCheckDeclaration {
819
+ /** The short permission name, such as `can_generate`. */
820
+ permission?: string | null;
821
+ /** The type of the object the check is made on, when it is not the service's own. */
822
+ resource?: string | null;
823
+ /** The id template of the object, over the function's parameters and the caller's scope, such as `{reportId}`. */
824
+ objectId?: string | null;
825
+ /** Short names of permissions this one implies. */
826
+ implies?: string[] | null;
827
+ /** True for a function any caller the zone admits may call, which carries no check. */
828
+ zoneOnly?: boolean;
829
+ /** True for a check that must answer from the stored relationships rather than the engine's caches. */
830
+ consistent?: boolean;
831
+ }
832
+ /**
725
833
  * Marks the getter or method that provides the service's scope, which targets requests at one
726
834
  * specific instance of the service, such as the copy running on a particular node. It is
727
835
  * invoked on each instance when the instance registers with the ServiceRegistry.
728
836
  */
729
837
  declare function Scope(value: Function, _context: ClassGetterDecoratorContext | ClassMethodDecoratorContext): void;
730
838
  /**
839
+ * Marks a method of a scoped published service that any instance may answer, because its
840
+ * result does not depend on which instance executes it - typically a read of shared state
841
+ * rather than of the instance's own.
842
+ *
843
+ * A scoped service normally listens only at its scoped address, so every invocation must name
844
+ * an instance. When at least one method carries ScopeOptional, each instance also listens on
845
+ * the service's shared unscoped address, where only the annotated methods may be invoked: an
846
+ * unscoped invocation of any other method is rejected, since it would execute on whichever
847
+ * instance happened to receive it.
848
+ */
849
+ declare function ScopeOptional(value: Function, _context: ClassMethodDecoratorContext): void;
850
+ declare function scopeOptionalMethodNames(instance: object): Set<string>;
851
+ /**
731
852
  * Sets the semantic version a service registers under.
732
853
  * @param version the version in X.Y.Z[-optional] format
733
854
  */
@@ -760,6 +881,31 @@ declare function Context(value: Function, _context: ClassMethodDecoratorContext)
760
881
  */
761
882
  declare function receivesContext(serviceInstance: object, methodName: string): boolean;
762
883
  /**
884
+ * Declares the resource a service's functions act on. `kinotic sync` reads the declaration from the class's
885
+ * source into the service's definition, which the runtime registers in the platform's service directory when
886
+ * the service comes online, so every request to the service is checked. The check of each function is derived
887
+ * by the platform from the function's name and parameters, as it is for the platform's own services: a `find`,
888
+ * `get`, `count`, `search` or `list` function needs `can_view`, a `save`, `update` or `set` function `can_edit`,
889
+ * a `delete` or `remove` function `can_delete`, and a `create` function `can_edit` on the parent, each on the
890
+ * object a parameter named `id` or `<type>Id` names, or on the parent when none does. A function the derivation
891
+ * cannot read declares its check with {@link AuthzCheck}. A runtime holding no definition for a service
892
+ * declaring a resource refuses to serve it.
893
+ * @param declaration the resource type, or the type with its parent, object, permission and roles
894
+ */
895
+ declare function AuthzResource(declaration: AuthzResourceDeclaration | string): (value: Function, _context: ClassDecoratorContext<any>) => void;
896
+ /**
897
+ * Declares the check of a function of an {@link AuthzResource} service, which `kinotic sync` reads into the
898
+ * service's definition: a permission of its own, such as `can_generate`, another object than the derived one,
899
+ * the permissions it implies, a consistent answer, or that any caller the zone admits may call it (`zoneOnly`).
900
+ * @param declaration what the derivation cannot read from the function's name and parameters
901
+ */
902
+ declare function AuthzCheck(declaration: AuthzCheckDeclaration): (_value: Function, _context: ClassMethodDecoratorContext) => void;
903
+ /**
904
+ * Returns whether the given service instance's class, or a class it extends, declares an {@link AuthzResource}.
905
+ * @param serviceInstance the service instance to inspect
906
+ */
907
+ declare function declaresAuthzResource(serviceInstance: object): boolean;
908
+ /**
763
909
  * Registers each instance of the decorated class with the Kinotic ServiceRegistry.
764
910
  * The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link Zone}
765
911
  * on the same class refine the registration.
@@ -769,6 +915,35 @@ declare function receivesContext(serviceInstance: object, methodName: string): b
769
915
  * so it appears in directory listings
770
916
  */
771
917
  declare function Publish(namespace?: string | null, name?: string, advertise?: boolean): <T extends new (...args: any[]) => object>(value: T, _context: ClassDecoratorContext<any>) => T;
918
+ import { ServiceDefinition as ServiceDefinition2 } from "@kinotic-ai/idl";
919
+ /**
920
+ * A service of an application as its runtime registers it in the platform's service directory: the application
921
+ * it belongs to, where it is addressed, whether it is advertised, and its definition with the decorators it
922
+ * declares. The platform owns everything else about the directory's entry: the checks it derives, the tools the
923
+ * functions declare, and the service's liveness.
924
+ */
925
+ interface ServiceDirectoryEntry {
926
+ /**
927
+ * The application the service belongs to, which its zone names.
928
+ */
929
+ applicationId: string;
930
+ /**
931
+ * The zone the service is addressed in, the application's or a label under it.
932
+ */
933
+ zone: string;
934
+ /**
935
+ * The version the service registers under, or null for none.
936
+ */
937
+ version: string | null;
938
+ /**
939
+ * True when the service advertised itself with `@Publish(advertise = true)` and appears in directory listings.
940
+ */
941
+ advertised: boolean;
942
+ /**
943
+ * The service's definition: its functions, and the decorators it declares.
944
+ */
945
+ serviceDefinition: ServiceDefinition2;
946
+ }
772
947
  /**
773
948
  * Validates that the given zone satisfies the zone grammar
774
949
  * @param zone the zone to validate
@@ -1081,6 +1256,16 @@ interface ICrudServiceProxy<T extends Identifiable<string>> extends IEditableDat
1081
1256
  */
1082
1257
  deleteById(id: string): Promise<void>;
1083
1258
  /**
1259
+ * Deletes the entity with the given id and waits for the deletion to be visible in search
1260
+ * results before returning.
1261
+ * Use this when you need read-your-write consistency immediately after deletion.
1262
+ *
1263
+ * @param id must not be {@literal null}.
1264
+ * @return a {@link Promise} signaling when the deletion is visible to search.
1265
+ * @throws IllegalArgumentException in case the given {@literal identity} is {@literal null}.
1266
+ */
1267
+ deleteByIdSync(id: string): Promise<void>;
1268
+ /**
1084
1269
  * Returns a {@link Page} of entities meeting the paging restriction provided in the {@code Pageable} object.
1085
1270
  *
1086
1271
  * @param pageable the page settings to be used
@@ -1111,6 +1296,7 @@ declare class CrudServiceProxy<T extends Identifiable<string>> implements ICrudS
1111
1296
  create(entity: T): Promise<T>;
1112
1297
  createSync(entity: T): Promise<T>;
1113
1298
  deleteById(id: string): Promise<void>;
1299
+ deleteByIdSync(id: string): Promise<void>;
1114
1300
  findAll(pageable: Pageable): Promise<IterablePage<T>>;
1115
1301
  findAllSinglePage(pageable: Pageable): Promise<Page<T>>;
1116
1302
  findById(id: string): Promise<T>;
@@ -1200,17 +1386,20 @@ declare class Event implements IEvent {
1200
1386
  */
1201
1387
  declare class EventBus implements IEventBus {
1202
1388
  serverInfo: ServerInfo | null;
1389
+ private readonly log;
1203
1390
  private stompConnectionManager;
1204
1391
  private connectionLifecycle;
1205
- private replyToCri;
1392
+ private disconnectRequests;
1206
1393
  private requestRepliesObservable;
1207
1394
  private requestRepliesSubject;
1208
1395
  private requestRepliesSubscription;
1209
1396
  private readonly activeCorrelationIds;
1210
1397
  private readonly recentlyReaped;
1398
+ private readonly connectionEndedSubject;
1211
1399
  private static readonly REAP_DEBOUNCE_MS;
1212
1400
  constructor();
1213
- get fatalErrors(): Observable3<Error>;
1401
+ get connectionEnded(): Observable3<Error | null>;
1402
+ get connectionEstablished(): Observable3<ConnectedInfo>;
1214
1403
  isConnectionActive(): boolean;
1215
1404
  isConnected(): boolean;
1216
1405
  connect(options: ConnectOptions): Promise<ConnectedInfo>;
@@ -1222,7 +1411,6 @@ declare class EventBus implements IEventBus {
1222
1411
  requestStream(event: IEvent, sendControlEvents?: boolean): Observable3<IEvent>;
1223
1412
  listen(_serverInfo: ServerInfo): Promise<void>;
1224
1413
  observe(cri: string): Observable3<IEvent>;
1225
- private cleanup;
1226
1414
  /**
1227
1415
  * Cancels a server stream whose reply arrived for a correlationId we no longer track. The server can't
1228
1416
  * detect this itself since all requests share one reply destination, so the cancel is sent to the
@@ -1230,8 +1418,14 @@ declare class EventBus implements IEventBus {
1230
1418
  */
1231
1419
  private cancelIfUnexpected;
1232
1420
  /**
1421
+ * Sends the control event that stops the server stream identified by the correlationId.
1422
+ * @param cri the service the stream originates from
1423
+ * @param correlationId the correlationId of the stream to cancel
1424
+ */
1425
+ private sendCancel;
1426
+ /**
1233
1427
  * Tears down the shared request-replies stream so the next request rebuilds it against the
1234
- * current {@link replyToCri}. Any in-flight requests are failed with the given reason since
1428
+ * connection's reply destination. Any in-flight requests are failed with the given reason since
1235
1429
  * their replies can no longer be delivered.
1236
1430
  */
1237
1431
  private resetRequestReplies;
@@ -1248,6 +1442,38 @@ declare class EventBus implements IEventBus {
1248
1442
  private _observe;
1249
1443
  }
1250
1444
  /**
1445
+ * The error a service call fails with when the server answered it with an error reply. The reply body
1446
+ * describes the exception the server caught, so a caller can branch on which exception it was rather than
1447
+ * on a message written for people: a call that failed because the node serving it left the cluster carries
1448
+ * `RpcServiceUnavailableException`, one rejected because nothing served its address
1449
+ * `RpcMissingServiceException`.
1450
+ */
1451
+ declare class RpcError extends Error {
1452
+ /**
1453
+ * The simple name of the exception the server caught, such as `RpcServiceUnavailableException`.
1454
+ */
1455
+ readonly exceptionName: string;
1456
+ /**
1457
+ * The fully qualified class name of the exception the server caught.
1458
+ */
1459
+ readonly exceptionClass: string;
1460
+ constructor(message: string, exceptionName: string, exceptionClass: string);
1461
+ /**
1462
+ * Builds the error an error reply carries. The body is the server's description of the exception when
1463
+ * it is JSON; otherwise the error header alone names the failure.
1464
+ * @param reply the error reply, which carries the error header
1465
+ */
1466
+ static fromEvent(reply: IEvent): RpcError;
1467
+ }
1468
+ /**
1469
+ * Thrown when the calling participant is not permitted to do what it asked. A service that throws it
1470
+ * fails the invocation with an error reply named {@code AuthorizationException}, the name a Java
1471
+ * service's refusal carries, so a caller reads both the same way.
1472
+ */
1473
+ declare class AuthorizationException extends Error {
1474
+ constructor(message?: string);
1475
+ }
1476
+ /**
1251
1477
  * Kinotic client credentials: a clientId/clientSecret pair presented as upgrade headers —
1252
1478
  * a user's email and password, or a machine identity's id and provisioned secret. Scope is
1253
1479
  * structural, determined by which ids are given: neither → SYSTEM, organizationId only →
@@ -1290,7 +1516,7 @@ declare class ChainedCredentialsResolver implements CredentialsResolver {
1290
1516
  */
1291
1517
  declare class EnvCredentialsResolver implements CredentialsResolver {
1292
1518
  readonly name: string;
1293
- resolve(_server: ServerInfo): Promise<ResolvedCredentials | null>;
1519
+ resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
1294
1520
  }
1295
1521
  /**
1296
1522
  * The browser's session cookie, established by a prior REST login. Resolves to credentials
@@ -1312,7 +1538,7 @@ declare class ParticipantConstants {
1312
1538
  static readonly PARTICIPANT_TYPE_DELEGATE: string;
1313
1539
  /** A non-human caller with its own credential — a platform daemon or an external API client. */
1314
1540
  static readonly PARTICIPANT_TYPE_MACHINE: string;
1315
- /** The clientId TestSecurityService (clienttest profile) maps to the ANONYMOUS role in core package tests. */
1541
+ /** The clientId the test server's TestSecurityService maps to the ANONYMOUS role in core package tests. */
1316
1542
  static readonly CLI_PARTICIPANT_ID: string;
1317
1543
  }
1318
- export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceContext, ServerInfo, Scope, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AbstractIterablePage };
1544
+ export { validateZone, validateLabel, scopeOptionalMethodNames, receivesContext, isAdvertised, declaresAuthzResource, declareServiceDefinitions, createCRI, buildServerUrl, buildBrokerUrl, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceIdentifier, ServiceDirectoryEntry, ServiceContext, ServerInfo, ScopeOptional, Scope, RpcError, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AuthzRoleDeclaration, AuthzResourceDeclaration, AuthzResource, AuthzCheckDeclaration, AuthzCheck, AuthorizationException, AbstractIterablePage };