@phreshos/core 0.1.2 → 0.1.4
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/askable.d.ts +5 -6
- package/dist/channel.d.ts +6 -1
- package/dist/client.d.ts +3 -0
- package/dist/config.d.ts +0 -5
- package/dist/endpoint.d.ts +3 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +1 -0
- package/dist/program.d.ts +0 -5
- package/dist/server.d.ts +3 -0
- package/dist/service.d.ts +73 -0
- package/dist/service.js +27 -0
- package/package.json +1 -1
package/dist/askable.d.ts
CHANGED
|
@@ -12,12 +12,11 @@ export interface Askable<Events extends object = {}, Fallback = unknown> extends
|
|
|
12
12
|
/**
|
|
13
13
|
* Sends one question payload to this target and waits for its answer.
|
|
14
14
|
*
|
|
15
|
-
* The SDK uses a ten-second deadline by default.
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* exists, so a ready unanswered question waits for that deadline.
|
|
15
|
+
* The SDK uses a ten-second deadline by default. Any target-specific
|
|
16
|
+
* readiness wait shares that same deadline with the answer. The operation
|
|
17
|
+
* rejects when the target is known to be unavailable, or stops before
|
|
18
|
+
* answering. A boundary cannot infer whether an answerer exists, so a
|
|
19
|
+
* delivered but unanswered question waits for the deadline.
|
|
21
20
|
*/
|
|
22
21
|
ask<Answer = unknown>(event: string): Promise<Answer>;
|
|
23
22
|
ask<Answer = unknown, Payload = unknown>(event: string, payload: Payload): Promise<Answer>;
|
package/dist/channel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Endpoint } from "./endpoint.js";
|
|
2
2
|
import type { Publishable } from "./publishable.js";
|
|
3
|
+
import type { ServiceDefinition } from "./service.js";
|
|
3
4
|
import type { Captures, Subscribable } from "./subscribable.js";
|
|
4
5
|
/** One application value arriving through the current Endpoint's Channel. */
|
|
5
6
|
export type ChannelMessage<Payload = unknown, From = Endpoint> = Readonly<{
|
|
@@ -16,6 +17,10 @@ type ChannelFallback<Events extends object, From> = keyof Events extends never ?
|
|
|
16
17
|
/** Every application event observable through a Channel. */
|
|
17
18
|
export type ChannelCapture<Events extends object = {}, From = Endpoint> = Captures<ChannelEvents<Events, From>, ChannelFallback<Events, From>>;
|
|
18
19
|
/** Addressed input and destinationless output for the executing Endpoint. */
|
|
19
|
-
export interface Channel<Events extends object = {}, From = Endpoint> extends Subscribable<ChannelEvents<Events, From>, ChannelFallback<Events, From>>, Publishable {
|
|
20
|
+
export interface Channel<Events extends object = {}, From = Endpoint, Definition extends ServiceDefinition = ServiceDefinition> extends Subscribable<ChannelEvents<Events, From>, ChannelFallback<Events, From>>, Publishable {
|
|
21
|
+
/** Exposes this executing Channel under one public service name. */
|
|
22
|
+
enableService(definition: Definition): Promise<void>;
|
|
23
|
+
/** Stops exposing this executing Channel as a service. */
|
|
24
|
+
disableService(): Promise<void>;
|
|
20
25
|
}
|
|
21
26
|
export {};
|
package/dist/client.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Endpoint, type EndpointTraffic } from "./endpoint.js";
|
|
|
2
2
|
import type { LaunchClient } from "./launch.js";
|
|
3
3
|
import type { Server } from "./server.js";
|
|
4
4
|
import type { Window } from "./window.js";
|
|
5
|
+
import type { ClientServiceHandler } from "./service.js";
|
|
5
6
|
/** Directed communication originating from one Client. */
|
|
6
7
|
export interface ClientTraffic<Events extends object = {}, To = Endpoint, AskTo = Server> extends EndpointTraffic<Events, To, AskTo> {
|
|
7
8
|
}
|
|
@@ -16,4 +17,6 @@ export interface Client<Events extends object = {}> {
|
|
|
16
17
|
readonly window: Window;
|
|
17
18
|
/** Starts a fresh Client and Window using optional Process-local overrides. */
|
|
18
19
|
start(overrides?: LaunchClient): Promise<void>;
|
|
20
|
+
/** Returns this Client's current complete service handle, or `null`. */
|
|
21
|
+
service<ServiceEvents extends object = {}>(): Promise<ClientServiceHandler<ServiceEvents> | null>;
|
|
19
22
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -52,11 +52,6 @@ type Description = Readonly<{
|
|
|
52
52
|
version?: string;
|
|
53
53
|
/** Short human-readable explanation of what the Program does. */
|
|
54
54
|
description?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Markdown file describing only the Program-owned API contract.
|
|
57
|
-
* System access, Endpoint, and event mechanics belong to system documentation.
|
|
58
|
-
*/
|
|
59
|
-
apiDocs?: string;
|
|
60
55
|
/** PNG source between 128 and 2,048 pixels per side and no larger than 5 MiB. */
|
|
61
56
|
icon?: string;
|
|
62
57
|
/** Command run before production start, installation, and packaging. */
|
package/dist/endpoint.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Process } from "./process.js";
|
|
2
2
|
import type { Publishable } from "./publishable.js";
|
|
3
3
|
import type { Server } from "./server.js";
|
|
4
|
+
import type { ServiceHandler } from "./service.js";
|
|
4
5
|
import type { Captures, Cleanup, Subscribable } from "./subscribable.js";
|
|
5
6
|
/** One application value observed in traffic originating from an Endpoint. */
|
|
6
7
|
export type TrafficMessage<Payload = unknown, To = Endpoint> = Readonly<{
|
|
@@ -67,5 +68,7 @@ export interface Endpoint<Events extends object = {}> extends Publishable, Subsc
|
|
|
67
68
|
* fails. Stopping never exits the Process implicitly.
|
|
68
69
|
*/
|
|
69
70
|
stop(): Promise<void>;
|
|
71
|
+
/** Returns this Endpoint's current complete service handle, or `null`. */
|
|
72
|
+
service(): Promise<ServiceHandler | null>;
|
|
70
73
|
}
|
|
71
74
|
export {};
|
package/dist/main.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { type Message, type Cleanup, type Capture, type Captures, type EventMess
|
|
|
2
2
|
export { type Publishable } from "./publishable.js";
|
|
3
3
|
export { type Timeoutable } from "./timeout.js";
|
|
4
4
|
export { type Askable, type TimedAskable } from "./askable.js";
|
|
5
|
+
export { ClientServiceHandler, ServerServiceHandler, ServiceHandler, isServiceKey, type ClientServiceChannel, type ServerServiceChannel, type ServerServiceDefinition, type ServiceChannel, type ServiceDefinition, type ServiceKey, type ServiceLifecycleEvents } from "./service.js";
|
|
5
6
|
export { isPermissionName, permissionNames, type PermissionDecision, type PermissionDecisions, type PermissionName, type Permissions, type ProgramPermissions, type TimedPermissions } from "./permissions.js";
|
|
6
7
|
export { type Outcome } from "./outcome.js";
|
|
7
8
|
export { type ServedFile } from "./served-file.js";
|
package/dist/main.js
CHANGED
|
@@ -2,6 +2,7 @@ export {} from "./subscribable.js";
|
|
|
2
2
|
export {} from "./publishable.js";
|
|
3
3
|
export {} from "./timeout.js";
|
|
4
4
|
export {} from "./askable.js";
|
|
5
|
+
export { ClientServiceHandler, ServerServiceHandler, ServiceHandler, isServiceKey } from "./service.js";
|
|
5
6
|
export { isPermissionName, permissionNames } from "./permissions.js";
|
|
6
7
|
export {} from "./outcome.js";
|
|
7
8
|
export {} from "./served-file.js";
|
package/dist/program.d.ts
CHANGED
|
@@ -83,11 +83,6 @@ export interface Program<Events extends object = {}> extends Subscribable<Progra
|
|
|
83
83
|
getProcess(identityOrName: string): Promise<Process | null>;
|
|
84
84
|
/** Creates one Process of this Program. */
|
|
85
85
|
createProcess(launch?: Launch): Promise<Process>;
|
|
86
|
-
/**
|
|
87
|
-
* Returns the Program-authored API entry point, or `null`.
|
|
88
|
-
* The document describes the Program's contract, not system mechanics.
|
|
89
|
-
*/
|
|
90
|
-
apiDocs(): Promise<string | null>;
|
|
91
86
|
/**
|
|
92
87
|
* Returns one standard PNG representation of this Program's icon.
|
|
93
88
|
* Programs without an authored icon receive the system default.
|
package/dist/server.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Askable } from "./askable.js";
|
|
|
2
2
|
import { Endpoint, type EndpointTraffic } from "./endpoint.js";
|
|
3
3
|
import type { Outcome } from "./outcome.js";
|
|
4
4
|
import type { Cleanup } from "./subscribable.js";
|
|
5
|
+
import type { ServerServiceHandler } from "./service.js";
|
|
5
6
|
/** One answer sent by this Server to the Endpoint that asked. */
|
|
6
7
|
export type AnswerMessage<Result = unknown, To = Endpoint> = Readonly<{
|
|
7
8
|
/** Destination Endpoint, or `null` when its identity is outside this boundary. */
|
|
@@ -39,4 +40,6 @@ export interface Server<Events extends object = {}> extends Askable {
|
|
|
39
40
|
* The SDK uses its ten-second deadline unless one is supplied.
|
|
40
41
|
*/
|
|
41
42
|
waitReady(timeout?: number): Promise<void>;
|
|
43
|
+
/** Returns this Server's current complete service handle, or `null`. */
|
|
44
|
+
service<ServiceEvents extends object = {}>(): Promise<ServerServiceHandler<ServiceEvents> | null>;
|
|
42
45
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Askable } from "./askable.js";
|
|
2
|
+
import type { Subscribable } from "./subscribable.js";
|
|
3
|
+
/** Stable public coordinates of one explicitly named Endpoint service. */
|
|
4
|
+
export type ServiceKey = Readonly<{
|
|
5
|
+
/** Stable identity of the Program that owns the providing Endpoint. */
|
|
6
|
+
program: string;
|
|
7
|
+
/** Endpoint kind deliberately exposed by the service author. */
|
|
8
|
+
endpoint: "server" | "client";
|
|
9
|
+
/** Program-authored service identity. */
|
|
10
|
+
name: string;
|
|
11
|
+
}>;
|
|
12
|
+
/** Runtime declaration of one service exposed by an Endpoint Channel. */
|
|
13
|
+
export type ServiceDefinition = Readonly<{
|
|
14
|
+
/** Program-authored service identity. */
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
/** Runtime declaration of one Server service and its optional API document. */
|
|
18
|
+
export type ServerServiceDefinition = ServiceDefinition & Readonly<{
|
|
19
|
+
/** Complete API documentation owned by this service. */
|
|
20
|
+
docs?: string;
|
|
21
|
+
}>;
|
|
22
|
+
/** Lifecycle transitions of one exact service identity. */
|
|
23
|
+
export type ServiceLifecycleEvents = {
|
|
24
|
+
/** A live Endpoint began providing this service. */
|
|
25
|
+
enable: undefined;
|
|
26
|
+
/** The providing Endpoint stopped exposing this service. */
|
|
27
|
+
disable: undefined;
|
|
28
|
+
};
|
|
29
|
+
/** Application events emitted by one service. */
|
|
30
|
+
export interface ServiceChannel<Events extends object = {}> extends Subscribable<Events, keyof Events extends never ? unknown : never> {
|
|
31
|
+
}
|
|
32
|
+
/** Communication surface of a service provided by a Server Endpoint. */
|
|
33
|
+
export interface ServerServiceChannel<Events extends object = {}> extends ServiceChannel<Events>, Askable {
|
|
34
|
+
}
|
|
35
|
+
/** Communication surface of a service provided by a Client Endpoint. */
|
|
36
|
+
export interface ClientServiceChannel<Events extends object = {}> extends ServiceChannel<Events> {
|
|
37
|
+
}
|
|
38
|
+
/** Stable lifecycle handle for one exact public service identity. */
|
|
39
|
+
export declare class ServiceHandler<Channel extends object = ServiceChannel> {
|
|
40
|
+
protected constructor();
|
|
41
|
+
}
|
|
42
|
+
export interface ServiceHandler<Channel extends object = ServiceChannel> extends Subscribable<ServiceLifecycleEvents, never> {
|
|
43
|
+
/** Program namespace of this service. */
|
|
44
|
+
readonly program: string;
|
|
45
|
+
/** Endpoint kind represented by this service. */
|
|
46
|
+
readonly endpoint: "server" | "client";
|
|
47
|
+
/** Program-authored service identity. */
|
|
48
|
+
readonly name: string;
|
|
49
|
+
/** Application communication, separate from service lifecycle. */
|
|
50
|
+
readonly channel: Channel;
|
|
51
|
+
/** Explicitly reads whether no live Endpoint currently provides the service. */
|
|
52
|
+
disabled(): Promise<boolean>;
|
|
53
|
+
}
|
|
54
|
+
/** Stable handle for one Server-provided service. */
|
|
55
|
+
export declare class ServerServiceHandler<Events extends object = {}> extends ServiceHandler<ServerServiceChannel<Events>> {
|
|
56
|
+
protected constructor();
|
|
57
|
+
}
|
|
58
|
+
export interface ServerServiceHandler<Events extends object = {}> {
|
|
59
|
+
readonly endpoint: "server";
|
|
60
|
+
readonly channel: ServerServiceChannel<Events>;
|
|
61
|
+
/** Explicitly reads this live Server service's documentation, or `null`. */
|
|
62
|
+
docs(): Promise<string | null>;
|
|
63
|
+
}
|
|
64
|
+
/** Stable handle for one Client-provided service. */
|
|
65
|
+
export declare class ClientServiceHandler<Events extends object = {}> extends ServiceHandler<ClientServiceChannel<Events>> {
|
|
66
|
+
protected constructor();
|
|
67
|
+
}
|
|
68
|
+
export interface ClientServiceHandler<Events extends object = {}> {
|
|
69
|
+
readonly endpoint: "client";
|
|
70
|
+
readonly channel: ClientServiceChannel<Events>;
|
|
71
|
+
}
|
|
72
|
+
/** Returns whether a boundary value is a complete service key. */
|
|
73
|
+
export declare function isServiceKey(value: unknown): value is ServiceKey;
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Stable lifecycle handle for one exact public service identity. */
|
|
2
|
+
export class ServiceHandler {
|
|
3
|
+
constructor() { }
|
|
4
|
+
}
|
|
5
|
+
/** Stable handle for one Server-provided service. */
|
|
6
|
+
export class ServerServiceHandler extends ServiceHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** Stable handle for one Client-provided service. */
|
|
12
|
+
export class ClientServiceHandler extends ServiceHandler {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Returns whether a boundary value is a complete service key. */
|
|
18
|
+
export function isServiceKey(value) {
|
|
19
|
+
if (typeof value !== "object" || value === null)
|
|
20
|
+
return false;
|
|
21
|
+
const candidate = value;
|
|
22
|
+
return typeof candidate.program === "string"
|
|
23
|
+
&& candidate.program.length > 0
|
|
24
|
+
&& (candidate.endpoint === "server" || candidate.endpoint === "client")
|
|
25
|
+
&& typeof candidate.name === "string"
|
|
26
|
+
&& candidate.name.length > 0;
|
|
27
|
+
}
|