@nice-code/action 0.6.0 → 0.6.2

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.
Files changed (22) hide show
  1. package/build/devtools/browser/index.js +267 -164
  2. package/build/devtools/server/index.js +132 -114
  3. package/build/index.js +1116 -46
  4. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +7 -1
  5. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types.d.ts +31 -3
  6. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.d.ts +18 -1
  7. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.d.ts +12 -1
  8. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionFrameCrypto.d.ts +31 -0
  9. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWireCodec.d.ts +41 -0
  10. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake.d.ts +187 -0
  11. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter.d.ts +20 -0
  12. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory.d.ts +31 -0
  13. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/ws_util.d.ts +9 -0
  14. package/build/types/ActionRuntime/Handler/Server/ActionServerHandler.d.ts +191 -0
  15. package/build/types/devtools/browser/components/OriginChip.d.ts +15 -0
  16. package/build/types/devtools/browser/components/SectionLabel.d.ts +1 -1
  17. package/build/types/devtools/browser/components/utils.d.ts +11 -0
  18. package/build/types/devtools/core/devtools_colors.d.ts +1 -0
  19. package/build/types/devtools/server/index.d.ts +2 -2
  20. package/build/types/index.d.ts +7 -0
  21. package/build/types/utils/decodeActionFrame.d.ts +17 -0
  22. package/package.json +6 -5
@@ -0,0 +1,15 @@
1
+ import { ESize } from "../ui_util/size";
2
+ /**
3
+ * Marks an action that was received from another runtime (a backend push, or an action relayed from
4
+ * another client) rather than dispatched locally. The chip shows the origin's `envId`; the tooltip
5
+ * carries the full coordinate. Render it only when {@link getInboundOrigin} returns a value.
6
+ */
7
+ export declare function OriginChip({ origin, size, subtle, }: {
8
+ origin: {
9
+ envId: string;
10
+ perId?: string;
11
+ insId?: string;
12
+ };
13
+ size?: ESize;
14
+ subtle?: boolean;
15
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- export declare function SectionLabel({ label, color }: {
1
+ export declare function SectionLabel({ label, color, }: {
2
2
  label: string;
3
3
  color?: string;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,6 +5,17 @@ export declare const STATUS_COLOR: Record<TDevtoolsActionStatus, string>;
5
5
  export declare const STATUS_THING: Record<TDevtoolsActionStatus, ESemanticThing>;
6
6
  export declare const STATUS_SYMBOL: Record<TDevtoolsActionStatus, string>;
7
7
  export declare const STATUS_ICON: Record<TDevtoolsActionStatus, LucideIcon>;
8
+ /**
9
+ * The runtime an action *originated* on, when that differs from the runtime that handled it — i.e. an
10
+ * inbound action received over a transport (a backend push, or an action relayed from another client),
11
+ * rather than one dispatched locally. Returns `null` for locally-originated actions (where the origin
12
+ * matches the handling runtime) and for actions with no known origin.
13
+ */
14
+ export declare function getInboundOrigin(entry: IDevtoolsActionEntry): {
15
+ envId: string;
16
+ perId?: string;
17
+ insId?: string;
18
+ } | null;
8
19
  export declare function safeStringify(value: unknown, indent?: number): string;
9
20
  export declare function formatRelativeAge(ms: number): string;
10
21
  export declare function formatDuration(entry: IDevtoolsActionEntry): string | null;
@@ -54,6 +54,7 @@ export declare enum ESemanticThing {
54
54
  domain = "domain",
55
55
  handler_local = "handler_local",
56
56
  handler_external = "handler_external",
57
+ origin = "origin",// runtime an action was received from (inbound / pushed actions)
57
58
  age = "age",// non-latest relative-age chip
58
59
  io_input = "io_input",
59
60
  io_output = "io_output",
@@ -1,3 +1,3 @@
1
- export { ActionServerDevtools, type IActionServerDevtoolsOptions, type TServerDevtoolsLogFn, } from "./NiceActionServerDevtools";
2
- export { ActionDevtoolsCore, type IActionDevtoolsCoreOptions } from "../core/ActionDevtoolsCore";
3
1
  export type { IDevtoolsActionEntry, IDevtoolsObservableDomain, TDevtoolsActionStatus, TDevtoolsListener, } from "../core/ActionDevtools.types";
2
+ export { ActionDevtoolsCore, type IActionDevtoolsCoreOptions } from "../core/ActionDevtoolsCore";
3
+ export { ActionServerDevtools, type IActionServerDevtoolsOptions, type TServerDevtoolsLogFn, } from "./NiceActionServerDevtools";
@@ -22,10 +22,17 @@ export * from "./ActionRuntime/Handler/ExternalClient/Transport/err_nice_transpo
22
22
  export { HttpTransport, type IHttpTransportOptions, } from "./ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport";
23
23
  export { type ITransportConnectionContext, Transport, } from "./ActionRuntime/Handler/ExternalClient/Transport/Transport";
24
24
  export * from "./ActionRuntime/Handler/ExternalClient/Transport/Transport.types";
25
+ export { createActionFrameCrypto, type IActionFrameCrypto, type IActionFrameCryptoConfig, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionFrameCrypto";
26
+ export { createClientHandshake, createInMemoryTofuVerifyKeyResolver, createServerHandshake, createStorageTofuVerifyKeyResolver, decodeHandshakeMessage, EHandshakeMessageType, ESecurityLevel, encodeHandshakeMessage, type IClientHandshakeConfig, type IClientVerifyKeyResolveInput, type IClientVerifyKeyResolver, type IHandshakeEncryptionKeyMaterial, type IHandshakeResult, type IServerHandshakeConfig, runtimeLinkId, type THandshakeMessage, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake";
27
+ export { createBinaryWsAdapter } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter";
28
+ export { createBinaryWsSessionFactory, type IBinaryWsSessionOptions, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory";
29
+ export type { IActionTransportDef_Ws, IActionTransportInitialized_Ws, IActionTransportReadyData_Ws, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types";
25
30
  export { type IWebSocketTransportAdvancedOptions, type IWebSocketTransportSocketOptions, type TWebSocketTransportOptions, WebSocketTransport, } from "./ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport";
26
31
  export { ActionLocalHandler, createLocalHandler, } from "./ActionRuntime/Handler/Local/ActionLocalHandler";
32
+ export { ActionServerHandler, createServerHandler, type IActionServerConnectionBinding, type IActionServerHandlerOptions, type TActionChannelFormatMessage, type TActionConnectionEncoding, } from "./ActionRuntime/Handler/Server/ActionServerHandler";
27
33
  export * from "./ActionRuntime/RuntimeCoordinate";
28
34
  export { EErrId_NiceAction, err_nice_action } from "./errors/err_nice_action";
35
+ export { decodeActionFrame, type IActionFrameDecoder } from "./utils/decodeActionFrame";
29
36
  export { isActionPayload_Any_JsonObject } from "./utils/isActionPayload_Any_JsonObject";
30
37
  export * from "./utils/isActionPayload_Request_JsonObject";
31
38
  export * from "./utils/isActionPayload_Result_JsonObject";
@@ -0,0 +1,17 @@
1
+ import type { TActionPayload_Any_JsonObject } from "../ActionDefinition/Action/Payload/ActionPayload.types";
2
+ /**
3
+ * Minimal codec shape needed to turn an incoming channel frame back into action wire JSON. Matches
4
+ * the `formatMessage` object the WebSocket transport (and `createBinaryWsAdapter`) provide.
5
+ */
6
+ export interface IActionFrameDecoder {
7
+ incoming?: (frame: string | ArrayBuffer | Uint8Array | Blob) => TActionPayload_Any_JsonObject<any, any> | undefined;
8
+ }
9
+ /**
10
+ * Decode a single inbound channel frame (text or binary) into validated action wire JSON, or
11
+ * `undefined` if it isn't a recognisable action payload.
12
+ *
13
+ * Shared by the WebSocket transport's message listener and the server-side `ActionServerHandler` so
14
+ * both decode identically: a binary `decoder.incoming` (e.g. msgpackr) takes precedence, and plain
15
+ * text frames fall back to JSON — keeping binary and JSON clients interoperable on one channel.
16
+ */
17
+ export declare function decodeActionFrame(frame: string | ArrayBuffer | Uint8Array, decoder?: IActionFrameDecoder): TActionPayload_Any_JsonObject<any, any> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-code/action",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -44,16 +44,17 @@
44
44
  "build-types": "tsc --project tsconfig.build.json"
45
45
  },
46
46
  "dependencies": {
47
- "@nice-code/common-errors": "0.6.0",
48
- "@nice-code/error": "0.6.0",
49
- "@nice-code/util": "0.6.0",
47
+ "@nice-code/common-errors": "0.6.2",
48
+ "@nice-code/error": "0.6.2",
49
+ "@nice-code/util": "0.6.2",
50
50
  "@standard-schema/spec": "^1.1.0",
51
51
  "@tanstack/react-virtual": "^3.13.26",
52
52
  "http-status-codes": "^2.3.0",
53
53
  "lucide-react": "1.17.0",
54
54
  "nanoid": "^5.1.9",
55
55
  "source-map-js": "^1.2.1",
56
- "std-env": "^4.1.0"
56
+ "std-env": "^4.1.0",
57
+ "msgpackr": "2.0.4"
57
58
  },
58
59
  "devDependencies": {
59
60
  "@tanstack/react-query": "^5.100.3",