@superblocksteam/library-shared 1.99.99-next.3 → 2.0.0-SNAPSHOT.295fc0b43e332060
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/computed.d.ts +4 -2
- package/dist/computed.d.ts.map +1 -1
- package/dist/computed.js +1 -1
- package/dist/computed.js.map +1 -1
- package/dist/default-structure.d.ts +12 -0
- package/dist/default-structure.d.ts.map +1 -0
- package/dist/default-structure.js +36 -0
- package/dist/default-structure.js.map +1 -0
- package/dist/event-trigger-constants.d.ts +2 -0
- package/dist/event-trigger-constants.d.ts.map +1 -0
- package/dist/event-trigger-constants.js +2 -0
- package/dist/event-trigger-constants.js.map +1 -0
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +12 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +11 -4
- package/dist/layout.js.map +1 -1
- package/dist/mobx-sync/apply-patch.d.ts.map +1 -1
- package/dist/mobx-sync/apply-patch.js +23 -4
- package/dist/mobx-sync/apply-patch.js.map +1 -1
- package/dist/mobx-sync/to-patch.d.ts.map +1 -1
- package/dist/mobx-sync/to-patch.js.map +1 -1
- package/dist/pages.d.ts +76 -6
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +54 -2
- package/dist/pages.js.map +1 -1
- package/dist/pegs/find-string-interpolation.d.ts +12 -0
- package/dist/pegs/find-string-interpolation.d.ts.map +1 -0
- package/dist/pegs/find-string-interpolation.js +1265 -0
- package/dist/pegs/find-string-interpolation.js.map +1 -0
- package/dist/props/helpers.d.ts +1 -9
- package/dist/props/helpers.d.ts.map +1 -1
- package/dist/props/helpers.js +5 -54
- package/dist/props/helpers.js.map +1 -1
- package/dist/props/prop-types.d.ts +24 -13
- package/dist/props/prop-types.d.ts.map +1 -1
- package/dist/props/prop-types.js.map +1 -1
- package/dist/props/properties-panel.d.ts +61 -26
- package/dist/props/properties-panel.d.ts.map +1 -1
- package/dist/props/properties-panel.js +2 -5
- package/dist/props/properties-panel.js.map +1 -1
- package/dist/props/tailwind-property-keys.d.ts +5 -0
- package/dist/props/tailwind-property-keys.d.ts.map +1 -0
- package/dist/props/tailwind-property-keys.js +234 -0
- package/dist/props/tailwind-property-keys.js.map +1 -0
- package/dist/restart-contract.d.ts +35 -0
- package/dist/restart-contract.d.ts.map +1 -0
- package/dist/restart-contract.js +49 -0
- package/dist/restart-contract.js.map +1 -0
- package/dist/scope.d.ts +2 -0
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +3 -0
- package/dist/scope.js.map +1 -1
- package/dist/testing/default-structure-scope/index.d.ts +8 -0
- package/dist/testing/default-structure-scope/index.d.ts.map +1 -0
- package/dist/testing/default-structure-scope/index.js +62 -0
- package/dist/testing/default-structure-scope/index.js.map +1 -0
- package/dist/testing/fake-editor-channel/fake-artifact.d.ts +41 -0
- package/dist/testing/fake-editor-channel/fake-artifact.d.ts.map +1 -0
- package/dist/testing/fake-editor-channel/fake-artifact.js +74 -0
- package/dist/testing/fake-editor-channel/fake-artifact.js.map +1 -0
- package/dist/testing/fake-editor-channel/index.d.ts +115 -0
- package/dist/testing/fake-editor-channel/index.d.ts.map +1 -0
- package/dist/testing/fake-editor-channel/index.js +292 -0
- package/dist/testing/fake-editor-channel/index.js.map +1 -0
- package/dist/testing/fake-editor-channel/type-pins.d.ts +13 -0
- package/dist/testing/fake-editor-channel/type-pins.d.ts.map +1 -0
- package/dist/testing/fake-editor-channel/type-pins.js +13 -0
- package/dist/testing/fake-editor-channel/type-pins.js.map +1 -0
- package/dist/types/ai.d.ts +1745 -0
- package/dist/types/ai.d.ts.map +1 -0
- package/dist/types/ai.js +445 -0
- package/dist/types/ai.js.map +1 -0
- package/dist/types/apis.d.ts +44 -1
- package/dist/types/apis.d.ts.map +1 -1
- package/dist/types/base-entity-manager.d.ts +15 -0
- package/dist/types/base-entity-manager.d.ts.map +1 -0
- package/dist/types/base-entity-manager.js +2 -0
- package/dist/types/base-entity-manager.js.map +1 -0
- package/dist/types/common.d.ts +4 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +4 -1
- package/dist/types/common.js.map +1 -1
- package/dist/types/edit-operations.d.ts +26 -35
- package/dist/types/edit-operations.d.ts.map +1 -1
- package/dist/types/edit-operations.js +2 -0
- package/dist/types/edit-operations.js.map +1 -1
- package/dist/types/entities.d.ts +10 -29
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/entities.js +0 -5
- package/dist/types/entities.js.map +1 -1
- package/dist/types/errors.d.ts +82 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +18 -1
- package/dist/types/errors.js.map +1 -1
- package/dist/types/events.d.ts +218 -26
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/events.js +33 -5
- package/dist/types/events.js.map +1 -1
- package/dist/types/index.d.ts +19 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +19 -7
- package/dist/types/index.js.map +1 -1
- package/dist/types/migration.d.ts +240 -0
- package/dist/types/migration.d.ts.map +1 -0
- package/dist/types/migration.js +50 -0
- package/dist/types/migration.js.map +1 -0
- package/dist/types/mobx-shared-state.d.ts +25 -1
- package/dist/types/mobx-shared-state.d.ts.map +1 -1
- package/dist/types/parent-messages.d.ts +44 -14
- package/dist/types/parent-messages.d.ts.map +1 -1
- package/dist/types/persisted-chat-message.d.ts +55 -0
- package/dist/types/persisted-chat-message.d.ts.map +1 -0
- package/dist/types/persisted-chat-message.js +757 -0
- package/dist/types/persisted-chat-message.js.map +1 -0
- package/dist/types/protected-packages.d.ts +54 -0
- package/dist/types/protected-packages.d.ts.map +1 -0
- package/dist/types/protected-packages.js +91 -0
- package/dist/types/protected-packages.js.map +1 -0
- package/dist/types/register-component.d.ts +128 -0
- package/dist/types/register-component.d.ts.map +1 -0
- package/dist/types/register-component.js +45 -0
- package/dist/types/register-component.js.map +1 -0
- package/dist/types/routing.d.ts +68 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/types/routing.js +2 -0
- package/dist/types/routing.js.map +1 -0
- package/dist/types/scope.d.ts +8 -6
- package/dist/types/scope.d.ts.map +1 -1
- package/dist/types/snapshot.d.ts +53 -0
- package/dist/types/snapshot.d.ts.map +1 -0
- package/dist/types/snapshot.js +2 -0
- package/dist/types/snapshot.js.map +1 -0
- package/dist/types/socket-method-names.d.ts +216 -0
- package/dist/types/socket-method-names.d.ts.map +1 -0
- package/dist/types/socket-method-names.js +165 -0
- package/dist/types/socket-method-names.js.map +1 -0
- package/dist/types/socket.d.ts +722 -48
- package/dist/types/socket.d.ts.map +1 -1
- package/dist/types/theme.d.ts +8 -7
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/types/theme.js +5 -6
- package/dist/types/theme.js.map +1 -1
- package/dist/types/tool-permission-response.d.ts +5 -0
- package/dist/types/tool-permission-response.d.ts.map +1 -0
- package/dist/types/tool-permission-response.js +26 -0
- package/dist/types/tool-permission-response.js.map +1 -0
- package/dist/types/vite.d.ts +29 -0
- package/dist/types/vite.d.ts.map +1 -0
- package/dist/types/vite.js +6 -0
- package/dist/types/vite.js.map +1 -0
- package/dist/urls.d.ts +7 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.js +6 -0
- package/dist/urls.js.map +1 -0
- package/dist/utils/binding-identifier.d.ts +1 -0
- package/dist/utils/binding-identifier.d.ts.map +1 -1
- package/dist/utils/binding-identifier.js +3 -0
- package/dist/utils/binding-identifier.js.map +1 -1
- package/dist/utils/blocks.d.ts +3 -0
- package/dist/utils/blocks.d.ts.map +1 -0
- package/dist/utils/blocks.js +70 -0
- package/dist/utils/blocks.js.map +1 -0
- package/dist/utils/computed-args.d.ts +11 -0
- package/dist/utils/computed-args.d.ts.map +1 -0
- package/dist/utils/computed-args.js +13 -0
- package/dist/utils/computed-args.js.map +1 -0
- package/dist/utils/dev-server-authorization.d.ts +4 -0
- package/dist/utils/dev-server-authorization.d.ts.map +1 -0
- package/dist/utils/dev-server-authorization.js +56 -0
- package/dist/utils/dev-server-authorization.js.map +1 -0
- package/dist/utils/dotted-paths.js +1 -1
- package/dist/utils/dotted-paths.js.map +1 -1
- package/dist/utils/properties.d.ts +12 -9
- package/dist/utils/properties.d.ts.map +1 -1
- package/dist/utils/properties.js +14 -6
- package/dist/utils/properties.js.map +1 -1
- package/dist/utils/routing.d.ts +5 -0
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/routing.js +16 -0
- package/dist/utils/routing.js.map +1 -0
- package/dist/utils/strings.d.ts +12 -0
- package/dist/utils/strings.d.ts.map +1 -1
- package/dist/utils/strings.js +40 -1
- package/dist/utils/strings.js.map +1 -1
- package/package.json +53 -25
- package/dist/apis.d.ts +0 -2
- package/dist/apis.d.ts.map +0 -1
- package/dist/apis.js +0 -4
- package/dist/apis.js.map +0 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { ISocketClient, RequestContextBase } from "@superblocksteam/shared";
|
|
2
|
+
import { EDITOR_CLIENT_METHOD_NAMES, SERVER_EDITOR_METHOD_NAMES } from "../../types/socket-method-names.js";
|
|
3
|
+
import type { EditorClientMethods, ServerMethods } from "../../types/socket.js";
|
|
4
|
+
export { EDITOR_CLIENT_METHOD_NAMES, SERVER_EDITOR_METHOD_NAMES };
|
|
5
|
+
export { FakeArtifact, type FakeArtifactState } from "./fake-artifact.js";
|
|
6
|
+
type FakeHandler<Method> = Method extends (params: infer Params) => Promise<infer Result> ? (params: Params, context: RequestContextBase, peer: ISocketClient<ServerMethods>, next: () => Promise<Result>) => Result | Promise<Result> : never;
|
|
7
|
+
export type FakeEditorClientHandlers = Partial<{
|
|
8
|
+
[Method in keyof EditorClientMethods]: readonly FakeHandler<EditorClientMethods[Method]>[];
|
|
9
|
+
}>;
|
|
10
|
+
export type FakeServerEditorHandlers = Partial<{
|
|
11
|
+
[Method in keyof ServerMethods["editor"]]: ServerMethods["editor"][Method];
|
|
12
|
+
}>;
|
|
13
|
+
export interface FakeEditorChannelRequest {
|
|
14
|
+
direction: "editor-to-server" | "server-to-editor";
|
|
15
|
+
generation: number;
|
|
16
|
+
method: keyof EditorClientMethods | keyof ServerMethods["editor"];
|
|
17
|
+
params: unknown;
|
|
18
|
+
transportSeq: number;
|
|
19
|
+
}
|
|
20
|
+
export interface FakeEditorChannelPeer extends ISocketClient<EditorClientMethods> {
|
|
21
|
+
readonly connectionGeneration: number;
|
|
22
|
+
readonly isConnected: boolean;
|
|
23
|
+
invalidateConnection(generation: number): void;
|
|
24
|
+
whenConnected(timeoutMs: number): Promise<boolean>;
|
|
25
|
+
whenConnectedAfter(generation: number, timeoutMs: number): Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* In-memory editor Channel Adapter for contract and surface tests.
|
|
29
|
+
*
|
|
30
|
+
* Calls from an editor into `ServerMethods.editor` are recorded by `call`.
|
|
31
|
+
* Calls from the server into `EditorClientMethods` are initiated through
|
|
32
|
+
* `push` and delivered to the handlers bound for the current connection.
|
|
33
|
+
* Editor handlers are connection-scoped: `dropConnection` clears them, so a
|
|
34
|
+
* `reconnect` without replacement handlers starts the new generation with
|
|
35
|
+
* none bound. Within a live connection, `bindEditorHandlers` merges across
|
|
36
|
+
* distinct methods but is last-write-wins per method key: re-binding a
|
|
37
|
+
* method replaces its whole handler chain rather than appending to it. The
|
|
38
|
+
* handlers passed to `reconnect` replace the entire bound set.
|
|
39
|
+
*
|
|
40
|
+
* Error behavior mirrors the real transport (`ISocket`) for the codes this
|
|
41
|
+
* fake models: 2, 5, and 10. Unknown method names reject with a plain
|
|
42
|
+
* `{ code: 2, message }` object and `next()` past the last handler rejects
|
|
43
|
+
* with a plain `{ code: 5, message, stack }` object; like the real remote
|
|
44
|
+
* error path, neither is an Error instance. Calls on a dropped connection
|
|
45
|
+
* reject with an actual `SocketErrorException` (code 10), matching the real
|
|
46
|
+
* local closed-socket path. Codes 4, 6, 7, 8, and 9 are not modeled; in
|
|
47
|
+
* particular, an in-flight push during a real mid-connection drop rejects
|
|
48
|
+
* with code 8, which this fake cannot produce because `dropConnection` does
|
|
49
|
+
* not reject in-flight work.
|
|
50
|
+
*
|
|
51
|
+
* A peer's `close`/`closeAndRejectPendingRequests` is terminal: it resolves
|
|
52
|
+
* pending connection waiters `false` immediately (matching StablePeer), while
|
|
53
|
+
* `dropConnection` is transient and leaves them pending for `reconnect`.
|
|
54
|
+
* StablePeer's disconnected-call queueing and replay (dispatch/flush) is not
|
|
55
|
+
* modeled: calls on a dropped connection reject rather than queue.
|
|
56
|
+
*
|
|
57
|
+
* By default (`strict: true`) a valid method with no handler bound also
|
|
58
|
+
* rejects with code 2, matching production; pass `strict: false` to resolve
|
|
59
|
+
* `undefined` instead for recording-only tests. In strict mode a
|
|
60
|
+
* valid-but-unhandled request IS recorded in `requests` before rejecting,
|
|
61
|
+
* while an unknown method name is NOT recorded.
|
|
62
|
+
*/
|
|
63
|
+
export declare class FakeEditorChannel {
|
|
64
|
+
readonly call: ISocketClient<ServerMethods>["call"];
|
|
65
|
+
readonly editorPeer: FakeEditorChannelPeer;
|
|
66
|
+
readonly push: ISocketClient<EditorClientMethods>["call"];
|
|
67
|
+
readonly requests: FakeEditorChannelRequest[];
|
|
68
|
+
private connected;
|
|
69
|
+
private editorHandlers;
|
|
70
|
+
private generation;
|
|
71
|
+
private nextTransportSeq;
|
|
72
|
+
private readonly serverHandlers;
|
|
73
|
+
private readonly strict;
|
|
74
|
+
private readonly waiters;
|
|
75
|
+
constructor(options?: {
|
|
76
|
+
editorHandlers?: FakeEditorClientHandlers;
|
|
77
|
+
serverHandlers?: FakeServerEditorHandlers;
|
|
78
|
+
/**
|
|
79
|
+
* When true (the default), a valid method with no handler bound rejects
|
|
80
|
+
* with a plain `{ code: 2, message }` object like the real transport.
|
|
81
|
+
* Pass false to resolve `undefined` instead for recording-only tests.
|
|
82
|
+
*/
|
|
83
|
+
strict?: boolean;
|
|
84
|
+
});
|
|
85
|
+
get connectionGeneration(): number;
|
|
86
|
+
get isConnected(): boolean;
|
|
87
|
+
bindEditorHandlers(handlers: FakeEditorClientHandlers): void;
|
|
88
|
+
dropConnection(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Terminal close, as invoked through a peer's `close` or
|
|
91
|
+
* `closeAndRejectPendingRequests`. On top of `dropConnection`, settles
|
|
92
|
+
* every pending connection waiter with `false` immediately (matching
|
|
93
|
+
* StablePeer's rejectPendingConnectionState); `dropConnection` alone
|
|
94
|
+
* leaves waiters pending so a later `reconnect` can resolve them `true`.
|
|
95
|
+
*/
|
|
96
|
+
private closeConnection;
|
|
97
|
+
reconnect(handlers?: FakeEditorClientHandlers): void;
|
|
98
|
+
invalidateConnection(generation: number): void;
|
|
99
|
+
/**
|
|
100
|
+
* The editor-path correlation ID (the per-turn `requestId` string inside
|
|
101
|
+
* editor-to-server payloads) of the most recent editor call that carried
|
|
102
|
+
* one. Distinct from `transportSeq`, the fake's per-message counter, and
|
|
103
|
+
* from A2A task ids, which belong to the gateway path.
|
|
104
|
+
*/
|
|
105
|
+
lastEditorPathCorrelationId(): string | undefined;
|
|
106
|
+
whenConnected(timeoutMs: number): Promise<boolean>;
|
|
107
|
+
whenConnectedAfter(generation: number, timeoutMs: number): Promise<boolean>;
|
|
108
|
+
private record;
|
|
109
|
+
private receiveEditorCall;
|
|
110
|
+
private pushToEditor;
|
|
111
|
+
private callingPeer;
|
|
112
|
+
private assertConnected;
|
|
113
|
+
private waitForConnection;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/fake-editor-channel/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAG3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAA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epD,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAM9C;;;;;OAKG;IACH,2BAA2B,IAAI,MAAM,GAAG,SAAS;IAiBjD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOlD,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO3E,OAAO,CAAC,MAAM;YAiBA,iBAAiB;YA2BjB,YAAY;IAwC1B,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,iBAAiB;CAgB1B"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { SocketErrorException } from "@superblocksteam/shared";
|
|
2
|
+
import { EDITOR_CLIENT_METHOD_NAMES, SERVER_EDITOR_METHOD_NAMES, editorClientMethodSet, serverEditorMethodSet, } from "../../types/socket-method-names.js";
|
|
3
|
+
// Re-exported for existing importers of the testing subpath; the canonical,
|
|
4
|
+
// production-consumable home is `../../types/socket-method-names.js`
|
|
5
|
+
// (`@superblocksteam/library-shared/types/socket-method-names`).
|
|
6
|
+
export { EDITOR_CLIENT_METHOD_NAMES, SERVER_EDITOR_METHOD_NAMES };
|
|
7
|
+
export { FakeArtifact } from "./fake-artifact.js";
|
|
8
|
+
/**
|
|
9
|
+
* The remote-error shape the real transport delivers for an unknown method:
|
|
10
|
+
* `ISocket.handleMessage` builds `{ code: 2, message }` directly (no stack)
|
|
11
|
+
* and `respondError` JSON-serializes it, so the caller's promise rejects with
|
|
12
|
+
* a parsed plain object, never an Error instance.
|
|
13
|
+
*/
|
|
14
|
+
const unknownMethodError = (message) => ({
|
|
15
|
+
code: 2,
|
|
16
|
+
message,
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Strict-mode rejection for a valid method with no handler bound. Same plain
|
|
20
|
+
* `{ code: 2, message }` shape and code as the real transport's unknown-method
|
|
21
|
+
* rejection, but the message names the missing binding so a failure points at
|
|
22
|
+
* the absent stub instead of a nonexistent typo in the method name.
|
|
23
|
+
*/
|
|
24
|
+
const strictUnboundError = (method) => ({
|
|
25
|
+
code: 2,
|
|
26
|
+
message: `no handler bound for ${method} (strict mode - bind a handler or construct with strict: false)`,
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* The remote-error shape the real transport delivers when a handler chain
|
|
30
|
+
* throws: `ISocket.handleMessage` catches the `SocketErrorException` and
|
|
31
|
+
* serializes `{ code, message, stack }`, so the caller's promise rejects with
|
|
32
|
+
* a parsed plain object carrying a stack string, never an Error instance.
|
|
33
|
+
*/
|
|
34
|
+
const remoteHandlerError = (code, message) => {
|
|
35
|
+
const exception = new SocketErrorException(code, message);
|
|
36
|
+
return {
|
|
37
|
+
code: exception.code,
|
|
38
|
+
message: exception.message,
|
|
39
|
+
stack: exception.stack,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* In-memory editor Channel Adapter for contract and surface tests.
|
|
44
|
+
*
|
|
45
|
+
* Calls from an editor into `ServerMethods.editor` are recorded by `call`.
|
|
46
|
+
* Calls from the server into `EditorClientMethods` are initiated through
|
|
47
|
+
* `push` and delivered to the handlers bound for the current connection.
|
|
48
|
+
* Editor handlers are connection-scoped: `dropConnection` clears them, so a
|
|
49
|
+
* `reconnect` without replacement handlers starts the new generation with
|
|
50
|
+
* none bound. Within a live connection, `bindEditorHandlers` merges across
|
|
51
|
+
* distinct methods but is last-write-wins per method key: re-binding a
|
|
52
|
+
* method replaces its whole handler chain rather than appending to it. The
|
|
53
|
+
* handlers passed to `reconnect` replace the entire bound set.
|
|
54
|
+
*
|
|
55
|
+
* Error behavior mirrors the real transport (`ISocket`) for the codes this
|
|
56
|
+
* fake models: 2, 5, and 10. Unknown method names reject with a plain
|
|
57
|
+
* `{ code: 2, message }` object and `next()` past the last handler rejects
|
|
58
|
+
* with a plain `{ code: 5, message, stack }` object; like the real remote
|
|
59
|
+
* error path, neither is an Error instance. Calls on a dropped connection
|
|
60
|
+
* reject with an actual `SocketErrorException` (code 10), matching the real
|
|
61
|
+
* local closed-socket path. Codes 4, 6, 7, 8, and 9 are not modeled; in
|
|
62
|
+
* particular, an in-flight push during a real mid-connection drop rejects
|
|
63
|
+
* with code 8, which this fake cannot produce because `dropConnection` does
|
|
64
|
+
* not reject in-flight work.
|
|
65
|
+
*
|
|
66
|
+
* A peer's `close`/`closeAndRejectPendingRequests` is terminal: it resolves
|
|
67
|
+
* pending connection waiters `false` immediately (matching StablePeer), while
|
|
68
|
+
* `dropConnection` is transient and leaves them pending for `reconnect`.
|
|
69
|
+
* StablePeer's disconnected-call queueing and replay (dispatch/flush) is not
|
|
70
|
+
* modeled: calls on a dropped connection reject rather than queue.
|
|
71
|
+
*
|
|
72
|
+
* By default (`strict: true`) a valid method with no handler bound also
|
|
73
|
+
* rejects with code 2, matching production; pass `strict: false` to resolve
|
|
74
|
+
* `undefined` instead for recording-only tests. In strict mode a
|
|
75
|
+
* valid-but-unhandled request IS recorded in `requests` before rejecting,
|
|
76
|
+
* while an unknown method name is NOT recorded.
|
|
77
|
+
*/
|
|
78
|
+
export class FakeEditorChannel {
|
|
79
|
+
call;
|
|
80
|
+
editorPeer;
|
|
81
|
+
push;
|
|
82
|
+
requests = [];
|
|
83
|
+
connected = true;
|
|
84
|
+
editorHandlers = {};
|
|
85
|
+
generation = 1;
|
|
86
|
+
nextTransportSeq = 1;
|
|
87
|
+
serverHandlers;
|
|
88
|
+
strict;
|
|
89
|
+
waiters = new Set();
|
|
90
|
+
constructor(options = {}) {
|
|
91
|
+
this.serverHandlers = options.serverHandlers ?? {};
|
|
92
|
+
this.strict = options.strict ?? true;
|
|
93
|
+
this.bindEditorHandlers(options.editorHandlers ?? {});
|
|
94
|
+
const editorCalls = Object.fromEntries(SERVER_EDITOR_METHOD_NAMES.map((method) => [
|
|
95
|
+
method,
|
|
96
|
+
(params) => this.receiveEditorCall(method, params),
|
|
97
|
+
]));
|
|
98
|
+
this.call = { editor: editorCalls };
|
|
99
|
+
this.push = Object.fromEntries(EDITOR_CLIENT_METHOD_NAMES.map((method) => [
|
|
100
|
+
method,
|
|
101
|
+
(params) => this.pushToEditor(method, params),
|
|
102
|
+
]));
|
|
103
|
+
const getConnectionGeneration = () => this.connectionGeneration;
|
|
104
|
+
const getIsConnected = () => this.isConnected;
|
|
105
|
+
this.editorPeer = {
|
|
106
|
+
get connectionGeneration() {
|
|
107
|
+
return getConnectionGeneration();
|
|
108
|
+
},
|
|
109
|
+
get isConnected() {
|
|
110
|
+
return getIsConnected();
|
|
111
|
+
},
|
|
112
|
+
call: this.push,
|
|
113
|
+
close: () => this.closeConnection(),
|
|
114
|
+
closeAndRejectPendingRequests: () => this.closeConnection(),
|
|
115
|
+
invalidateConnection: (generation) => this.invalidateConnection(generation),
|
|
116
|
+
requestWithTracing: (method, params) => this.pushToEditor(method, params),
|
|
117
|
+
whenConnected: (timeoutMs) => this.whenConnected(timeoutMs),
|
|
118
|
+
whenConnectedAfter: (generation, timeoutMs) => this.whenConnectedAfter(generation, timeoutMs),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
get connectionGeneration() {
|
|
122
|
+
return this.generation;
|
|
123
|
+
}
|
|
124
|
+
get isConnected() {
|
|
125
|
+
return this.connected;
|
|
126
|
+
}
|
|
127
|
+
bindEditorHandlers(handlers) {
|
|
128
|
+
this.editorHandlers = { ...this.editorHandlers, ...handlers };
|
|
129
|
+
}
|
|
130
|
+
dropConnection() {
|
|
131
|
+
this.connected = false;
|
|
132
|
+
this.editorHandlers = {};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Terminal close, as invoked through a peer's `close` or
|
|
136
|
+
* `closeAndRejectPendingRequests`. On top of `dropConnection`, settles
|
|
137
|
+
* every pending connection waiter with `false` immediately (matching
|
|
138
|
+
* StablePeer's rejectPendingConnectionState); `dropConnection` alone
|
|
139
|
+
* leaves waiters pending so a later `reconnect` can resolve them `true`.
|
|
140
|
+
*/
|
|
141
|
+
closeConnection() {
|
|
142
|
+
this.dropConnection();
|
|
143
|
+
for (const waiter of this.waiters) {
|
|
144
|
+
clearTimeout(waiter.timer);
|
|
145
|
+
waiter.resolve(false);
|
|
146
|
+
}
|
|
147
|
+
this.waiters.clear();
|
|
148
|
+
}
|
|
149
|
+
reconnect(handlers) {
|
|
150
|
+
if (handlers) {
|
|
151
|
+
this.editorHandlers = handlers;
|
|
152
|
+
}
|
|
153
|
+
this.connected = true;
|
|
154
|
+
this.generation += 1;
|
|
155
|
+
for (const waiter of this.waiters) {
|
|
156
|
+
if (this.generation > waiter.afterGeneration) {
|
|
157
|
+
clearTimeout(waiter.timer);
|
|
158
|
+
waiter.resolve(true);
|
|
159
|
+
this.waiters.delete(waiter);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
invalidateConnection(generation) {
|
|
164
|
+
if (generation === this.generation) {
|
|
165
|
+
this.dropConnection();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The editor-path correlation ID (the per-turn `requestId` string inside
|
|
170
|
+
* editor-to-server payloads) of the most recent editor call that carried
|
|
171
|
+
* one. Distinct from `transportSeq`, the fake's per-message counter, and
|
|
172
|
+
* from A2A task ids, which belong to the gateway path.
|
|
173
|
+
*/
|
|
174
|
+
lastEditorPathCorrelationId() {
|
|
175
|
+
for (let index = this.requests.length - 1; index >= 0; index -= 1) {
|
|
176
|
+
const request = this.requests[index];
|
|
177
|
+
if (request?.direction !== "editor-to-server") {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const params = request.params;
|
|
181
|
+
if (params && typeof params === "object" && "requestId" in params) {
|
|
182
|
+
const requestId = params.requestId;
|
|
183
|
+
if (typeof requestId === "string") {
|
|
184
|
+
return requestId;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
whenConnected(timeoutMs) {
|
|
191
|
+
if (this.connected) {
|
|
192
|
+
return Promise.resolve(true);
|
|
193
|
+
}
|
|
194
|
+
return this.waitForConnection(this.generation - 1, timeoutMs);
|
|
195
|
+
}
|
|
196
|
+
whenConnectedAfter(generation, timeoutMs) {
|
|
197
|
+
if (this.connected && this.generation > generation) {
|
|
198
|
+
return Promise.resolve(true);
|
|
199
|
+
}
|
|
200
|
+
return this.waitForConnection(generation, timeoutMs);
|
|
201
|
+
}
|
|
202
|
+
record(direction, method, params) {
|
|
203
|
+
const transportSeq = this.nextTransportSeq;
|
|
204
|
+
this.nextTransportSeq += 1;
|
|
205
|
+
this.requests.push({
|
|
206
|
+
direction,
|
|
207
|
+
generation: this.generation,
|
|
208
|
+
method,
|
|
209
|
+
params,
|
|
210
|
+
transportSeq,
|
|
211
|
+
});
|
|
212
|
+
return { method: String(method), requestId: transportSeq };
|
|
213
|
+
}
|
|
214
|
+
async receiveEditorCall(method, params) {
|
|
215
|
+
this.assertConnected();
|
|
216
|
+
// Object.hasOwn, not `in`: the `in` operator walks the prototype chain,
|
|
217
|
+
// so an Object.prototype name like "hasOwnProperty" would pass the guard.
|
|
218
|
+
if (!Object.hasOwn(serverEditorMethodSet, method)) {
|
|
219
|
+
return Promise.reject(unknownMethodError(`unknown method editor.${String(method)}`));
|
|
220
|
+
}
|
|
221
|
+
this.record("editor-to-server", method, params);
|
|
222
|
+
const handler = Object.hasOwn(this.serverHandlers, method)
|
|
223
|
+
? this.serverHandlers[method]
|
|
224
|
+
: undefined;
|
|
225
|
+
if (!handler) {
|
|
226
|
+
if (this.strict) {
|
|
227
|
+
return Promise.reject(strictUnboundError(`editor.${String(method)}`));
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
return handler(params);
|
|
232
|
+
}
|
|
233
|
+
async pushToEditor(method, params) {
|
|
234
|
+
this.assertConnected();
|
|
235
|
+
// Object.hasOwn, not `in`: the `in` operator walks the prototype chain,
|
|
236
|
+
// so an Object.prototype name like "hasOwnProperty" would pass the guard.
|
|
237
|
+
if (!Object.hasOwn(editorClientMethodSet, method)) {
|
|
238
|
+
return Promise.reject(unknownMethodError(`unknown method ${String(method)}`));
|
|
239
|
+
}
|
|
240
|
+
const context = this.record("server-to-editor", method, params);
|
|
241
|
+
const handlers = Object.hasOwn(this.editorHandlers, method)
|
|
242
|
+
? this.editorHandlers[method]
|
|
243
|
+
: undefined;
|
|
244
|
+
if (!handlers?.length) {
|
|
245
|
+
if (this.strict) {
|
|
246
|
+
return Promise.reject(strictUnboundError(String(method)));
|
|
247
|
+
}
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
const invoke = (index) => {
|
|
251
|
+
const handler = handlers[index];
|
|
252
|
+
if (!handler) {
|
|
253
|
+
return Promise.reject(remoteHandlerError(5, "cannot call past the last handler in the chain"));
|
|
254
|
+
}
|
|
255
|
+
return Promise.resolve(handler(params, context, this.callingPeer(), () => invoke(index + 1)));
|
|
256
|
+
};
|
|
257
|
+
return invoke(0);
|
|
258
|
+
}
|
|
259
|
+
callingPeer() {
|
|
260
|
+
return {
|
|
261
|
+
call: this.call,
|
|
262
|
+
close: () => this.closeConnection(),
|
|
263
|
+
closeAndRejectPendingRequests: () => this.closeConnection(),
|
|
264
|
+
requestWithTracing: (method, params) => {
|
|
265
|
+
const editorPrefix = "editor.";
|
|
266
|
+
const editorMethod = method.startsWith(editorPrefix)
|
|
267
|
+
? method.slice(editorPrefix.length)
|
|
268
|
+
: method;
|
|
269
|
+
return this.receiveEditorCall(editorMethod, params);
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
assertConnected() {
|
|
274
|
+
if (!this.connected) {
|
|
275
|
+
throw new SocketErrorException(10, "[internal] Connection closed");
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
waitForConnection(afterGeneration, timeoutMs) {
|
|
279
|
+
return new Promise((resolve) => {
|
|
280
|
+
const waiter = {
|
|
281
|
+
afterGeneration,
|
|
282
|
+
resolve,
|
|
283
|
+
timer: setTimeout(() => {
|
|
284
|
+
this.waiters.delete(waiter);
|
|
285
|
+
resolve(false);
|
|
286
|
+
}, timeoutMs),
|
|
287
|
+
};
|
|
288
|
+
this.waiters.add(waiter);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/fake-editor-channel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAO/D,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAG5C,4EAA4E;AAC5E,qEAAqE;AACrE,iEAAiE;AACjE,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,CAAC;AAElE,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAuD1E;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAe,EAAE,CAAC,CAAC;IAC5D,IAAI,EAAE,CAAC;IACP,OAAO;CACR,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,MAAc,EAAe,EAAE,CAAC,CAAC;IAC3D,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,wBAAwB,MAAM,iEAAiE;CACzG,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,OAAe,EAAe,EAAE;IACxE,MAAM,SAAS,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,KAAK,EAAE,SAAS,CAAC,KAAK;KACvB,C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AC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC;oBACnC,CAAC,CAAC,MAAM,CAAC;gBACX,OAAO,IAAI,CAAC,iBAAiB,CAC3B,YAA6C,EAC7C,MAAM,CACW,CAAC;YACtB,CAAC;SACF,CAAC;IACJ,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,CAAC,EAAE,EAAE,8BAA8B,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAEO,iBAAiB,CACvB,eAAuB,EACvB,SAAiB;QAEjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,MAAM,MAAM,GAAqB;gBAC/B,eAAe;gBACf,OAAO;gBACP,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE;oBACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC5B,OAAO,CAAC,KAAK,CAAC,CAAC;gBACjB,CAAC,EAAE,SAAS,CAAC;aACd,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MethodSchema } from "@superblocksteam/shared";
|
|
2
|
+
import type { IsVoidMethodResult } from "../../types/socket-method-names.js";
|
|
3
|
+
import type { FakeEditorClientHandlers } from "./index.js";
|
|
4
|
+
type BoundHandler<Method extends keyof FakeEditorClientHandlers> = NonNullable<FakeEditorClientHandlers[Method]>[number];
|
|
5
|
+
export declare const aiPushMessageHandlerPin: BoundHandler<"aiPushMessage">;
|
|
6
|
+
export declare const aiCaptureScreenshotHandlerPin: BoundHandler<"aiCaptureScreenshot">;
|
|
7
|
+
type ClassifiedMethodResult<Method extends MethodSchema<never, unknown>> = IsVoidMethodResult<Awaited<ReturnType<Method>>>;
|
|
8
|
+
export declare const anyResultClassifiesNonVoidPin: ClassifiedMethodResult<MethodSchema<void, any>>;
|
|
9
|
+
export declare const neverResultClassifiesNonVoidPin: ClassifiedMethodResult<MethodSchema<void, never>>;
|
|
10
|
+
export declare const voidResultClassifiesVoidPin: ClassifiedMethodResult<MethodSchema<void, void>>;
|
|
11
|
+
export declare const unionWithVoidClassifiesNonVoidPin: ClassifiedMethodResult<MethodSchema<void, string | void>>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=type-pins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-pins.d.ts","sourceRoot":"","sources":["../../../src/testing/fake-editor-channel/type-pins.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,KAAK,YAAY,CAAC,MAAM,SAAS,MAAM,wBAAwB,IAAI,WAAW,CAC5E,wBAAwB,CAAC,MAAM,CAAC,CACjC,CAAC,MAAM,CAAC,CAAC;AAIV,eAAO,MAAM,uBAAuB,EAAE,YAAY,CAChD,eAAe,CACC,CAAC;AAEnB,eAAO,MAAM,6BAA6B,EAAE,YAAY,CACtD,qBAAqB,CACH,CAAC;AAOrB,KAAK,sBAAsB,CAAC,MAAM,SAAS,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,IACrE,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAGlD,eAAO,MAAM,6BAA6B,EAAE,sBAAsB,CAChE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAChB,CAAC;AAGV,eAAO,MAAM,+BAA+B,EAAE,sBAAsB,CAClE,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAClB,CAAC;AAGV,eAAO,MAAM,2BAA2B,EAAE,sBAAsB,CAC9D,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAClB,CAAC;AAGT,eAAO,MAAM,iCAAiC,EAAE,sBAAsB,CACpE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAC1B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Each assignment errors if the FakeHandler conditional resolves to never,
|
|
2
|
+
// because no function is assignable to never.
|
|
3
|
+
export const aiPushMessageHandlerPin = async () => { };
|
|
4
|
+
export const aiCaptureScreenshotHandlerPin = async () => ({});
|
|
5
|
+
// An `any` result must classify non-void.
|
|
6
|
+
export const anyResultClassifiesNonVoidPin = false;
|
|
7
|
+
// A `never` result must classify non-void.
|
|
8
|
+
export const neverResultClassifiesNonVoidPin = false;
|
|
9
|
+
// A genuine void result stays void.
|
|
10
|
+
export const voidResultClassifiesVoidPin = true;
|
|
11
|
+
// A union containing void still promises a real result, so non-void.
|
|
12
|
+
export const unionWithVoidClassifiesNonVoidPin = false;
|
|
13
|
+
//# sourceMappingURL=type-pins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-pins.js","sourceRoot":"","sources":["../../../src/testing/fake-editor-channel/type-pins.ts"],"names":[],"mappings":"AAYA,2EAA2E;AAC3E,8CAA8C;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAEhC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC;AAEnB,MAAM,CAAC,MAAM,6BAA6B,GAEtC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAUrB,0CAA0C;AAC1C,MAAM,CAAC,MAAM,6BAA6B,GAEtC,KAAK,CAAC;AAEV,2CAA2C;AAC3C,MAAM,CAAC,MAAM,+BAA+B,GAExC,KAAK,CAAC;AAEV,oCAAoC;AACpC,MAAM,CAAC,MAAM,2BAA2B,GAEpC,IAAI,CAAC;AAET,qEAAqE;AACrE,MAAM,CAAC,MAAM,iCAAiC,GAE1C,KAAK,CAAC"}
|