@vforsh/argus-core 0.2.0 → 0.4.0
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/.tsbuildinfo +1 -1
- package/dist/auth/state.d.ts +13 -0
- package/dist/auth/state.d.ts.map +1 -1
- package/dist/auth/state.js +31 -0
- package/dist/auth/state.js.map +1 -1
- package/dist/errorMessage.d.ts +9 -0
- package/dist/errorMessage.d.ts.map +1 -0
- package/dist/errorMessage.js +17 -0
- package/dist/errorMessage.js.map +1 -0
- package/dist/http/fetch.d.ts +34 -0
- package/dist/http/fetch.d.ts.map +1 -1
- package/dist/http/fetch.js +46 -4
- package/dist/http/fetch.js.map +1 -1
- package/dist/http/watcher.d.ts +34 -0
- package/dist/http/watcher.d.ts.map +1 -0
- package/dist/http/watcher.js +33 -0
- package/dist/http/watcher.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol/http/auth.d.ts +25 -21
- package/dist/protocol/http/auth.d.ts.map +1 -1
- package/dist/protocol/http/auth.js +125 -0
- package/dist/protocol/http/auth.js.map +1 -1
- package/dist/protocol/http/code.d.ts +17 -12
- package/dist/protocol/http/code.d.ts.map +1 -1
- package/dist/protocol/http/code.js +53 -1
- package/dist/protocol/http/code.js.map +1 -1
- package/dist/protocol/http/dialog.d.ts +9 -6
- package/dist/protocol/http/dialog.d.ts.map +1 -1
- package/dist/protocol/http/dialog.js +21 -1
- package/dist/protocol/http/dialog.js.map +1 -1
- package/dist/protocol/http/dom.d.ts +61 -33
- package/dist/protocol/http/dom.d.ts.map +1 -1
- package/dist/protocol/http/dom.js +252 -1
- package/dist/protocol/http/dom.js.map +1 -1
- package/dist/protocol/http/domInteraction.d.ts +9 -9
- package/dist/protocol/http/domInteraction.d.ts.map +1 -1
- package/dist/protocol/http/domInteraction.js +3 -0
- package/dist/protocol/http/domInteraction.js.map +1 -1
- package/dist/protocol/http/emulation.d.ts +14 -21
- package/dist/protocol/http/emulation.d.ts.map +1 -1
- package/dist/protocol/http/emulation.js +99 -1
- package/dist/protocol/http/emulation.js.map +1 -1
- package/dist/protocol/http/errors.d.ts +51 -4
- package/dist/protocol/http/errors.d.ts.map +1 -1
- package/dist/protocol/http/errors.js +47 -1
- package/dist/protocol/http/errors.js.map +1 -1
- package/dist/protocol/http/eval.d.ts +22 -58
- package/dist/protocol/http/eval.d.ts.map +1 -1
- package/dist/protocol/http/eval.js +24 -1
- package/dist/protocol/http/eval.js.map +1 -1
- package/dist/protocol/http/extension.d.ts +52 -36
- package/dist/protocol/http/extension.d.ts.map +1 -1
- package/dist/protocol/http/extension.js +34 -1
- package/dist/protocol/http/extension.js.map +1 -1
- package/dist/protocol/http/locate.d.ts +9 -3
- package/dist/protocol/http/locate.d.ts.map +1 -1
- package/dist/protocol/http/locate.js +28 -1
- package/dist/protocol/http/locate.js.map +1 -1
- package/dist/protocol/http/logs.d.ts +9 -12
- package/dist/protocol/http/logs.d.ts.map +1 -1
- package/dist/protocol/http/net.d.ts +19 -27
- package/dist/protocol/http/net.d.ts.map +1 -1
- package/dist/protocol/http/netMock.d.ts +17 -27
- package/dist/protocol/http/netMock.d.ts.map +1 -1
- package/dist/protocol/http/netMock.js +126 -0
- package/dist/protocol/http/netMock.js.map +1 -1
- package/dist/protocol/http/query.d.ts +97 -0
- package/dist/protocol/http/query.d.ts.map +1 -0
- package/dist/protocol/http/query.js +79 -0
- package/dist/protocol/http/query.js.map +1 -0
- package/dist/protocol/http/record.d.ts +11 -6
- package/dist/protocol/http/record.d.ts.map +1 -1
- package/dist/protocol/http/record.js +56 -0
- package/dist/protocol/http/record.js.map +1 -1
- package/dist/protocol/http/screenshot.d.ts +18 -3
- package/dist/protocol/http/screenshot.d.ts.map +1 -1
- package/dist/protocol/http/screenshot.js +45 -1
- package/dist/protocol/http/screenshot.js.map +1 -1
- package/dist/protocol/http/snapshot.d.ts +5 -3
- package/dist/protocol/http/snapshot.d.ts.map +1 -1
- package/dist/protocol/http/snapshot.js +16 -1
- package/dist/protocol/http/snapshot.js.map +1 -1
- package/dist/protocol/http/status.d.ts +17 -9
- package/dist/protocol/http/status.d.ts.map +1 -1
- package/dist/protocol/http/status.js +12 -1
- package/dist/protocol/http/status.js.map +1 -1
- package/dist/protocol/http/storage.d.ts +7 -31
- package/dist/protocol/http/storage.d.ts.map +1 -1
- package/dist/protocol/http/storage.js +31 -1
- package/dist/protocol/http/storage.js.map +1 -1
- package/dist/protocol/http/throttle.d.ts +14 -21
- package/dist/protocol/http/throttle.d.ts.map +1 -1
- package/dist/protocol/http/throttle.js +27 -1
- package/dist/protocol/http/throttle.js.map +1 -1
- package/dist/protocol/http/trace.d.ts +9 -6
- package/dist/protocol/http/trace.d.ts.map +1 -1
- package/dist/protocol/http/trace.js +29 -1
- package/dist/protocol/http/trace.js.map +1 -1
- package/dist/protocol/http/visibility.d.ts +7 -3
- package/dist/protocol/http/visibility.d.ts.map +1 -1
- package/dist/protocol/http/visibility.js +19 -1
- package/dist/protocol/http/visibility.js.map +1 -1
- package/dist/protocol/http.d.ts +18 -16
- package/dist/protocol/http.d.ts.map +1 -1
- package/dist/protocol/http.js +17 -1
- package/dist/protocol/http.js.map +1 -1
- package/dist/protocol/native-messaging.d.ts +276 -0
- package/dist/protocol/native-messaging.d.ts.map +1 -0
- package/dist/protocol/native-messaging.js +19 -0
- package/dist/protocol/native-messaging.js.map +1 -0
- package/dist/protocol/scenario.d.ts +63 -0
- package/dist/protocol/scenario.d.ts.map +1 -0
- package/dist/protocol/scenario.js +2 -0
- package/dist/protocol/scenario.js.map +1 -0
- package/dist/protocol/schemaFields.d.ts +76 -0
- package/dist/protocol/schemaFields.d.ts.map +1 -0
- package/dist/protocol/schemaFields.js +152 -0
- package/dist/protocol/schemaFields.js.map +1 -0
- package/dist/protocol/version.d.ts +14 -0
- package/dist/protocol/version.d.ts.map +1 -1
- package/dist/protocol/version.js +21 -0
- package/dist/protocol/version.js.map +1 -1
- package/dist/registry/lock.d.ts.map +1 -1
- package/dist/registry/lock.js +2 -3
- package/dist/registry/lock.js.map +1 -1
- package/dist/registry/registry.d.ts +14 -0
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +20 -0
- package/dist/registry/registry.js.map +1 -1
- package/dist/textPattern.d.ts.map +1 -1
- package/dist/textPattern.js +2 -1
- package/dist/textPattern.js.map +1 -1
- package/dist/time.d.ts +20 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +39 -0
- package/dist/time.js.map +1 -0
- package/package.json +9 -7
package/dist/http/fetch.js
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when the server answered with a non-2xx status.
|
|
3
|
+
*
|
|
4
|
+
* Distinct from a transport failure (connection refused, DNS, timeout): the peer is
|
|
5
|
+
* alive and rejected this specific request. Callers that treat failures as liveness
|
|
6
|
+
* signals — such as registry pruning — must not evict a peer that threw this.
|
|
7
|
+
*/
|
|
8
|
+
export class HttpResponseError extends Error {
|
|
9
|
+
/** HTTP status code returned by the server. */
|
|
10
|
+
status;
|
|
11
|
+
/** Brand, so the check survives two copies of this module in one process. */
|
|
12
|
+
isHttpResponseError = true;
|
|
13
|
+
constructor(message, status) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'HttpResponseError';
|
|
16
|
+
this.status = status;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Type guard for {@link HttpResponseError} that tolerates duplicate module instances. */
|
|
20
|
+
export const isHttpResponseError = (error) => error != null && typeof error === 'object' && error.isHttpResponseError === true;
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when a request exceeded its timeout budget.
|
|
23
|
+
*
|
|
24
|
+
* Distinct from a connection failure: a slow endpoint on a perfectly healthy peer produces this,
|
|
25
|
+
* so callers that treat failures as liveness signals — registry pruning — must not evict on it.
|
|
26
|
+
* Typed rather than message-matched because `fetch`'s connection errors carry runtime-specific
|
|
27
|
+
* shapes (Bun sets `code: 'ConnectionRefused'`, Node nests an errno under `cause`), so the timeout
|
|
28
|
+
* is the one failure we can identify reliably ourselves.
|
|
29
|
+
*/
|
|
30
|
+
export class HttpTimeoutError extends Error {
|
|
31
|
+
/** The budget that elapsed, in milliseconds. */
|
|
32
|
+
timeoutMs;
|
|
33
|
+
/** Brand, so the check survives two copies of this module in one process. */
|
|
34
|
+
isHttpTimeoutError = true;
|
|
35
|
+
constructor(timeoutMs) {
|
|
36
|
+
super(`Request timed out after ${timeoutMs}ms`);
|
|
37
|
+
this.name = 'HttpTimeoutError';
|
|
38
|
+
this.timeoutMs = timeoutMs;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Type guard for {@link HttpTimeoutError} that tolerates duplicate module instances. */
|
|
42
|
+
export const isHttpTimeoutError = (error) => error != null && typeof error === 'object' && error.isHttpTimeoutError === true;
|
|
1
43
|
export const fetchJson = async (url, options = {}) => {
|
|
2
44
|
const controller = new AbortController();
|
|
3
45
|
const timeoutMs = options.timeoutMs ?? 5_000;
|
|
@@ -15,13 +57,13 @@ export const fetchJson = async (url, options = {}) => {
|
|
|
15
57
|
return (await response.json());
|
|
16
58
|
}
|
|
17
59
|
const errorMessage = await extractErrorMessage(response);
|
|
18
|
-
throw new
|
|
60
|
+
throw new HttpResponseError(errorMessage ?? `Request failed (${response.status} ${response.statusText})`, response.status);
|
|
19
61
|
}
|
|
20
62
|
return (await response.json());
|
|
21
63
|
}
|
|
22
64
|
catch (error) {
|
|
23
65
|
if (isAbortError(error)) {
|
|
24
|
-
throw new
|
|
66
|
+
throw new HttpTimeoutError(timeoutMs);
|
|
25
67
|
}
|
|
26
68
|
throw error;
|
|
27
69
|
}
|
|
@@ -42,13 +84,13 @@ export const fetchText = async (url, options = {}) => {
|
|
|
42
84
|
headers: body ? { 'Content-Type': 'application/json' } : undefined,
|
|
43
85
|
});
|
|
44
86
|
if (!response.ok) {
|
|
45
|
-
throw new
|
|
87
|
+
throw new HttpResponseError(`Request failed (${response.status} ${response.statusText})`, response.status);
|
|
46
88
|
}
|
|
47
89
|
return await response.text();
|
|
48
90
|
}
|
|
49
91
|
catch (error) {
|
|
50
92
|
if (isAbortError(error)) {
|
|
51
|
-
throw new
|
|
93
|
+
throw new HttpTimeoutError(timeoutMs);
|
|
52
94
|
}
|
|
53
95
|
throw error;
|
|
54
96
|
}
|
package/dist/http/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC3C,+CAA+C;IACtC,MAAM,CAAQ;IAEvB,6EAA6E;IACpE,mBAAmB,GAAG,IAAI,CAAA;IAEnC,YAAY,OAAe,EAAE,MAAc;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACrB,CAAC;CACD;AAED,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAA8B,EAAE,CACjF,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAA2C,CAAC,mBAAmB,KAAK,IAAI,CAAA;AAExH;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAC1C,gDAAgD;IACvC,SAAS,CAAQ;IAE1B,6EAA6E;IACpE,kBAAkB,GAAG,IAAI,CAAA;IAElC,YAAY,SAAiB;QAC5B,KAAK,CAAC,2BAA2B,SAAS,IAAI,CAAC,CAAA;QAC/C,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,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,CAAC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WatcherRecord } from '../registry/types.js';
|
|
2
|
+
/** Build the URL for a watcher endpoint. */
|
|
3
|
+
export declare const buildWatcherUrl: (watcher: Pick<WatcherRecord, "host" | "port">, path: string, query?: URLSearchParams) => string;
|
|
4
|
+
/** Describe a failure to reach a watcher, in the phrasing both the CLI and the SDK surface. */
|
|
5
|
+
export declare const formatWatcherTransportError: (watcher: Pick<WatcherRecord, "id">, error: unknown) => string;
|
|
6
|
+
/**
|
|
7
|
+
* How a failed watcher request should be interpreted.
|
|
8
|
+
*
|
|
9
|
+
* - `api-rejection`: the watcher answered and refused this request, so it is demonstrably alive.
|
|
10
|
+
* - `unreachable`: nothing is listening on the watcher's port (connection refused, DNS failure,
|
|
11
|
+
* host unreachable). Strong evidence the watcher is gone.
|
|
12
|
+
* - `transport`: the request failed without saying anything about liveness — a timeout or abort,
|
|
13
|
+
* which a slow command produces against a perfectly healthy watcher.
|
|
14
|
+
*/
|
|
15
|
+
export type WatcherFailureKind = 'api-rejection' | 'unreachable' | 'transport';
|
|
16
|
+
/**
|
|
17
|
+
* Classify a thrown watcher-request failure.
|
|
18
|
+
*
|
|
19
|
+
* Identified by what we can recognize reliably rather than by errno: `fetch` reports connection
|
|
20
|
+
* failures with runtime-specific shapes (Bun sets `code: 'ConnectionRefused'` on the error, Node
|
|
21
|
+
* nests an errno under `cause`), so anything that is neither our own response error nor our own
|
|
22
|
+
* timeout is treated as the connection never having been answered.
|
|
23
|
+
*/
|
|
24
|
+
export declare const classifyWatcherFailure: (error: unknown) => WatcherFailureKind;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a failed request should evict the watcher from the shared on-disk registry.
|
|
27
|
+
*
|
|
28
|
+
* The registry is shared between the CLI and the SDK, so this decision cannot live on one side:
|
|
29
|
+
* an eviction by either stack deletes an entry the other reads. Only `unreachable` evicts. An
|
|
30
|
+
* `api-rejection` came from a live watcher, and a `transport` failure is a timeout on a slow
|
|
31
|
+
* command — evicting there would delete healthy watchers mid-session.
|
|
32
|
+
*/
|
|
33
|
+
export declare const shouldEvictWatcherOnFailure: (failure: WatcherFailureKind) => boolean;
|
|
34
|
+
//# sourceMappingURL=watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/http/watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAIzD,4CAA4C;AAC5C,eAAO,MAAM,eAAe,GAAI,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,MAAM,MAAM,EAAE,QAAQ,eAAe,KAAG,MAGtH,CAAA;AAED,+FAA+F;AAC/F,eAAO,MAAM,2BAA2B,GAAI,SAAS,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,OAAO,OAAO,KAAG,MAChC,CAAA;AAEjE;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG,aAAa,GAAG,WAAW,CAAA;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,kBAMvD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GAAI,SAAS,kBAAkB,KAAG,OAAoC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isHttpResponseError, isHttpTimeoutError } from './fetch.js';
|
|
2
|
+
import { formatError } from '../errorMessage.js';
|
|
3
|
+
/** Build the URL for a watcher endpoint. */
|
|
4
|
+
export const buildWatcherUrl = (watcher, path, query) => {
|
|
5
|
+
const qs = query?.toString();
|
|
6
|
+
return `http://${watcher.host}:${watcher.port}${path}${qs ? `?${qs}` : ''}`;
|
|
7
|
+
};
|
|
8
|
+
/** Describe a failure to reach a watcher, in the phrasing both the CLI and the SDK surface. */
|
|
9
|
+
export const formatWatcherTransportError = (watcher, error) => `${watcher.id}: failed to reach watcher (${formatError(error)})`;
|
|
10
|
+
/**
|
|
11
|
+
* Classify a thrown watcher-request failure.
|
|
12
|
+
*
|
|
13
|
+
* Identified by what we can recognize reliably rather than by errno: `fetch` reports connection
|
|
14
|
+
* failures with runtime-specific shapes (Bun sets `code: 'ConnectionRefused'` on the error, Node
|
|
15
|
+
* nests an errno under `cause`), so anything that is neither our own response error nor our own
|
|
16
|
+
* timeout is treated as the connection never having been answered.
|
|
17
|
+
*/
|
|
18
|
+
export const classifyWatcherFailure = (error) => {
|
|
19
|
+
if (isHttpResponseError(error)) {
|
|
20
|
+
return 'api-rejection';
|
|
21
|
+
}
|
|
22
|
+
return isHttpTimeoutError(error) ? 'transport' : 'unreachable';
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Whether a failed request should evict the watcher from the shared on-disk registry.
|
|
26
|
+
*
|
|
27
|
+
* The registry is shared between the CLI and the SDK, so this decision cannot live on one side:
|
|
28
|
+
* an eviction by either stack deletes an entry the other reads. Only `unreachable` evicts. An
|
|
29
|
+
* `api-rejection` came from a live watcher, and a `transport` failure is a timeout on a slow
|
|
30
|
+
* command — evicting there would delete healthy watchers mid-session.
|
|
31
|
+
*/
|
|
32
|
+
export const shouldEvictWatcherOnFailure = (failure) => failure === 'unreachable';
|
|
33
|
+
//# sourceMappingURL=watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watcher.js","sourceRoot":"","sources":["../../src/http/watcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAA6C,EAAE,IAAY,EAAE,KAAuB,EAAU,EAAE;IAC/H,MAAM,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAA;IAC5B,OAAO,UAAU,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AAC5E,CAAC,CAAA;AAED,+FAA+F;AAC/F,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,OAAkC,EAAE,KAAc,EAAU,EAAE,CACzG,GAAG,OAAO,CAAC,EAAE,8BAA8B,WAAW,CAAC,KAAK,CAAC,GAAG,CAAA;AAajE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAsB,EAAE;IAC5E,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,eAAe,CAAA;IACvB,CAAC;IAED,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAA;AAC/D,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,OAA2B,EAAW,EAAE,CAAC,OAAO,KAAK,aAAa,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,16 @@ export * from './protocol/http.js';
|
|
|
3
3
|
export * from './protocol/schema.js';
|
|
4
4
|
export { AUTH_STATE_METADATA_SCHEMA_VERSION } from './protocol/http/auth.js';
|
|
5
5
|
export * from './protocol/version.js';
|
|
6
|
+
export * from './protocol/native-messaging.js';
|
|
6
7
|
export * from './registry/registry.js';
|
|
7
8
|
export * from './registry/types.js';
|
|
8
9
|
export * from './registry/paths.js';
|
|
9
10
|
export * from './logs/previewStringify.js';
|
|
11
|
+
export * from './errorMessage.js';
|
|
10
12
|
export * from './textPattern.js';
|
|
13
|
+
export * from './time.js';
|
|
11
14
|
export * from './auth/cookies.js';
|
|
12
15
|
export * from './auth/state.js';
|
|
13
16
|
export * from './http/fetch.js';
|
|
17
|
+
export * from './http/watcher.js';
|
|
14
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAA;AAC5E,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAA;AAC5E,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,16 @@ export * from './protocol/http.js';
|
|
|
3
3
|
export * from './protocol/schema.js';
|
|
4
4
|
export { AUTH_STATE_METADATA_SCHEMA_VERSION } from './protocol/http/auth.js';
|
|
5
5
|
export * from './protocol/version.js';
|
|
6
|
+
export * from './protocol/native-messaging.js';
|
|
6
7
|
export * from './registry/registry.js';
|
|
7
8
|
export * from './registry/types.js';
|
|
8
9
|
export * from './registry/paths.js';
|
|
9
10
|
export * from './logs/previewStringify.js';
|
|
11
|
+
export * from './errorMessage.js';
|
|
10
12
|
export * from './textPattern.js';
|
|
13
|
+
export * from './time.js';
|
|
11
14
|
export * from './auth/cookies.js';
|
|
12
15
|
export * from './auth/state.js';
|
|
13
16
|
export * from './http/fetch.js';
|
|
17
|
+
export * from './http/watcher.js';
|
|
14
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAA;AAC5E,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAA;AAC5E,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Ok } from './errors.js';
|
|
1
2
|
/** Cookie metadata exposed by the auth cookie endpoints. */
|
|
2
3
|
export type AuthCookie = {
|
|
3
4
|
name: string;
|
|
@@ -18,21 +19,19 @@ export type AuthCookieIdentity = {
|
|
|
18
19
|
path: string;
|
|
19
20
|
};
|
|
20
21
|
/** Response payload for GET /auth/cookies. */
|
|
21
|
-
export type AuthCookiesResponse = {
|
|
22
|
-
ok: true;
|
|
22
|
+
export type AuthCookiesResponse = Ok<{
|
|
23
23
|
origin: string;
|
|
24
24
|
cookies: AuthCookie[];
|
|
25
|
-
}
|
|
25
|
+
}>;
|
|
26
26
|
/** Request payload for exact cookie lookup. */
|
|
27
27
|
export type AuthCookieGetRequest = AuthCookieIdentity & {
|
|
28
28
|
includeValue?: boolean;
|
|
29
29
|
};
|
|
30
30
|
/** Response payload for exact cookie lookup. */
|
|
31
|
-
export type AuthCookieGetResponse = {
|
|
32
|
-
ok: true;
|
|
31
|
+
export type AuthCookieGetResponse = Ok<{
|
|
33
32
|
origin: string;
|
|
34
33
|
cookie: AuthCookie | null;
|
|
35
|
-
}
|
|
34
|
+
}>;
|
|
36
35
|
/** Cookie payload used by auth-state export and import. */
|
|
37
36
|
export type AuthStateCookie = {
|
|
38
37
|
name: string;
|
|
@@ -50,20 +49,18 @@ export type AuthCookieSetRequest = {
|
|
|
50
49
|
cookie: AuthStateCookie;
|
|
51
50
|
};
|
|
52
51
|
/** Response payload for cookie upserts. */
|
|
53
|
-
export type AuthCookieSetResponse = {
|
|
54
|
-
ok: true;
|
|
52
|
+
export type AuthCookieSetResponse = Ok<{
|
|
55
53
|
origin: string;
|
|
56
54
|
cookie: AuthCookie;
|
|
57
|
-
}
|
|
55
|
+
}>;
|
|
58
56
|
/** Request payload for exact cookie deletion. */
|
|
59
57
|
export type AuthCookieDeleteRequest = AuthCookieIdentity;
|
|
60
58
|
/** Response payload for exact cookie deletion. */
|
|
61
|
-
export type AuthCookieDeleteResponse = {
|
|
62
|
-
ok: true;
|
|
59
|
+
export type AuthCookieDeleteResponse = Ok<{
|
|
63
60
|
origin: string;
|
|
64
61
|
deleted: boolean;
|
|
65
62
|
cookie: AuthCookieIdentity;
|
|
66
|
-
}
|
|
63
|
+
}>;
|
|
67
64
|
/** Scope used by bulk cookie clearing. */
|
|
68
65
|
export type AuthCookieClearScope = 'origin' | 'site' | 'domain' | 'browserContext';
|
|
69
66
|
/** Request payload for scoped cookie clearing. */
|
|
@@ -74,8 +71,7 @@ export type AuthCookieClearRequest = {
|
|
|
74
71
|
authOnly?: boolean;
|
|
75
72
|
};
|
|
76
73
|
/** Response payload for scoped cookie clearing. */
|
|
77
|
-
export type AuthCookieClearResponse = {
|
|
78
|
-
ok: true;
|
|
74
|
+
export type AuthCookieClearResponse = Ok<{
|
|
79
75
|
origin: string;
|
|
80
76
|
scope: AuthCookieClearScope;
|
|
81
77
|
scopeValue: string | null;
|
|
@@ -83,7 +79,7 @@ export type AuthCookieClearResponse = {
|
|
|
83
79
|
authOnly: boolean;
|
|
84
80
|
cleared: number;
|
|
85
81
|
cookies: AuthCookieIdentity[];
|
|
86
|
-
}
|
|
82
|
+
}>;
|
|
87
83
|
/** A single storage entry for localStorage/sessionStorage snapshots. */
|
|
88
84
|
export type AuthStateStorageEntry = {
|
|
89
85
|
name: string;
|
|
@@ -139,22 +135,30 @@ export type AuthStateSnapshotMetadata = {
|
|
|
139
135
|
recommendedStartupUrl: string | null;
|
|
140
136
|
};
|
|
141
137
|
/** Portable auth snapshot used to rehydrate a fresh browser session. */
|
|
142
|
-
export type AuthStateSnapshot = {
|
|
143
|
-
ok: true;
|
|
138
|
+
export type AuthStateSnapshot = Ok<{
|
|
144
139
|
url: string;
|
|
145
140
|
origin: string;
|
|
146
141
|
cookies: AuthStateCookie[];
|
|
147
142
|
origins: AuthStateOrigin[];
|
|
148
143
|
metadata: AuthStateSnapshotMetadata;
|
|
149
|
-
}
|
|
144
|
+
}>;
|
|
150
145
|
/** Request payload for loading an auth-state snapshot into an attached watcher target. */
|
|
151
146
|
export type AuthStateLoadRequest = {
|
|
152
147
|
snapshot: AuthStateSnapshot;
|
|
153
148
|
url?: string;
|
|
154
149
|
};
|
|
155
150
|
/** Response payload for auth-state hydration requests. */
|
|
156
|
-
export type AuthStateLoadResponse = {
|
|
157
|
-
ok: true;
|
|
151
|
+
export type AuthStateLoadResponse = Ok<{
|
|
158
152
|
startupUrl: string | null;
|
|
159
|
-
}
|
|
153
|
+
}>;
|
|
154
|
+
/** Scopes accepted by POST /auth/cookies/clear. */
|
|
155
|
+
export declare const AUTH_COOKIE_CLEAR_SCOPES: readonly ["origin", "site", "domain", "browserContext"];
|
|
156
|
+
/** Schema for POST /auth/cookies/get request payloads. */
|
|
157
|
+
export declare const authCookieGetRequestSchema: import("../schema.js").ProtocolSchema<AuthCookieGetRequest>;
|
|
158
|
+
/** Schema for POST /auth/cookies/delete request payloads. */
|
|
159
|
+
export declare const authCookieDeleteRequestSchema: import("../schema.js").ProtocolSchema<AuthCookieIdentity>;
|
|
160
|
+
/** Schema for POST /auth/cookies/set request payloads. */
|
|
161
|
+
export declare const authCookieSetRequestSchema: import("../schema.js").ProtocolSchema<AuthCookieSetRequest>;
|
|
162
|
+
/** Schema for POST /auth/cookies/clear request payloads. */
|
|
163
|
+
export declare const authCookieClearRequestSchema: import("../schema.js").ProtocolSchema<AuthCookieClearRequest>;
|
|
160
164
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/protocol/http/auth.ts"],"names":[],"m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CAAA;IACzC,0CAA0C;IAC1C,SAAS,EAAE,0BAA0B,CAAA;IACrC,6CAA6C;IAC7C,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC,CAAA;AAED,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG,EAAE,CAAC;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,OAAO,EAAE,eAAe,EAAE,CAAA;IAC1B,QAAQ,EAAE,yBAAyB,CAAA;CACnC,CAAC,CAAA;AAEF,0FAA0F;AAC1F,MAAM,MAAM,oBAAoB,GAAG;IAClC,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,0DAA0D;AAC1D,MAAM,MAAM,qBAAqB,GAAG,EAAE,CAAC;IACtC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB,CAAC,CAAA;AAMF,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,yDAA0D,CAAA;AAe/F,0DAA0D;AAC1D,eAAO,MAAM,0BAA0B,6DAYrC,CAAA;AAEF,6DAA6D;AAC7D,eAAO,MAAM,6BAA6B,2DAQxC,CAAA;AAEF,0DAA0D;AAC1D,eAAO,MAAM,0BAA0B,6DAuDrC,CAAA;AAEF,4DAA4D;AAC5D,eAAO,MAAM,4BAA4B,+DAqBvC,CAAA"}
|
|
@@ -1,3 +1,128 @@
|
|
|
1
|
+
import { normalizeCookieDomainFilter, normalizeCookieSameSite } from '../../auth/cookies.js';
|
|
2
|
+
import { defineProtocolSchema, invalidProtocolPayload, validProtocolPayload } from '../schema.js';
|
|
3
|
+
import { compact, fieldError, optionalBoolean, optionalEnum, optionalNumber, optionalRecord, optionalString, readFields, requireObject, requiredString, } from '../schemaFields.js';
|
|
1
4
|
/** Schema version for the auth-state metadata block. */
|
|
2
5
|
export const AUTH_STATE_METADATA_SCHEMA_VERSION = 1;
|
|
6
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
// Request schemas
|
|
8
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
9
|
+
/** Scopes accepted by POST /auth/cookies/clear. */
|
|
10
|
+
export const AUTH_COOKIE_CLEAR_SCOPES = ['origin', 'site', 'domain', 'browserContext'];
|
|
11
|
+
/** Read the name/domain/path triple that identifies one cookie. */
|
|
12
|
+
const readCookieIdentity = (source) => {
|
|
13
|
+
const fields = readFields(source, { name: requiredString, domain: requiredString, path: requiredString });
|
|
14
|
+
if (!fields.ok) {
|
|
15
|
+
// requiredString names the field, which is the message these routes already used.
|
|
16
|
+
return fieldError(fields.issues[0]?.message ?? 'name, domain, and path are required');
|
|
17
|
+
}
|
|
18
|
+
if (!fields.value.path.startsWith('/')) {
|
|
19
|
+
return fieldError('path must start with "/"');
|
|
20
|
+
}
|
|
21
|
+
return fields.value;
|
|
22
|
+
};
|
|
23
|
+
/** Schema for POST /auth/cookies/get request payloads. */
|
|
24
|
+
export const authCookieGetRequestSchema = defineProtocolSchema((value) => {
|
|
25
|
+
const invalid = requireObject(value);
|
|
26
|
+
if (invalid)
|
|
27
|
+
return invalid;
|
|
28
|
+
const source = value;
|
|
29
|
+
const identity = readCookieIdentity(source);
|
|
30
|
+
if ('__fieldError' in identity)
|
|
31
|
+
return invalidProtocolPayload(identity.__fieldError);
|
|
32
|
+
const fields = readFields(source, { includeValue: optionalBoolean });
|
|
33
|
+
if (!fields.ok)
|
|
34
|
+
return fields;
|
|
35
|
+
return validProtocolPayload(compact({ ...identity, ...fields.value }));
|
|
36
|
+
});
|
|
37
|
+
/** Schema for POST /auth/cookies/delete request payloads. */
|
|
38
|
+
export const authCookieDeleteRequestSchema = defineProtocolSchema((value) => {
|
|
39
|
+
const invalid = requireObject(value);
|
|
40
|
+
if (invalid)
|
|
41
|
+
return invalid;
|
|
42
|
+
const identity = readCookieIdentity(value);
|
|
43
|
+
if ('__fieldError' in identity)
|
|
44
|
+
return invalidProtocolPayload(identity.__fieldError);
|
|
45
|
+
return validProtocolPayload(identity);
|
|
46
|
+
});
|
|
47
|
+
/** Schema for POST /auth/cookies/set request payloads. */
|
|
48
|
+
export const authCookieSetRequestSchema = defineProtocolSchema((value) => {
|
|
49
|
+
const invalid = requireObject(value);
|
|
50
|
+
if (invalid)
|
|
51
|
+
return invalid;
|
|
52
|
+
const outer = readFields(value, { cookie: optionalRecord });
|
|
53
|
+
if (!outer.ok)
|
|
54
|
+
return outer;
|
|
55
|
+
if (outer.value.cookie == null) {
|
|
56
|
+
return invalidProtocolPayload('cookie is required');
|
|
57
|
+
}
|
|
58
|
+
const source = outer.value.cookie;
|
|
59
|
+
const identity = readCookieIdentity(source);
|
|
60
|
+
if ('__fieldError' in identity)
|
|
61
|
+
return invalidProtocolPayload(identity.__fieldError);
|
|
62
|
+
const fields = readFields(source, {
|
|
63
|
+
value: optionalString,
|
|
64
|
+
secure: optionalBoolean,
|
|
65
|
+
httpOnly: optionalBoolean,
|
|
66
|
+
session: optionalBoolean,
|
|
67
|
+
sameSite: optionalString,
|
|
68
|
+
expires: (input, key) => optionalNumber(input, key),
|
|
69
|
+
});
|
|
70
|
+
if (!fields.ok)
|
|
71
|
+
return fields;
|
|
72
|
+
const { value: cookieValue, secure, httpOnly, session, sameSite, expires } = fields.value;
|
|
73
|
+
if (typeof cookieValue !== 'string')
|
|
74
|
+
return invalidProtocolPayload('cookie.value must be a string');
|
|
75
|
+
if (secure == null)
|
|
76
|
+
return invalidProtocolPayload('cookie.secure must be a boolean');
|
|
77
|
+
if (httpOnly == null)
|
|
78
|
+
return invalidProtocolPayload('cookie.httpOnly must be a boolean');
|
|
79
|
+
if (session == null)
|
|
80
|
+
return invalidProtocolPayload('cookie.session must be a boolean');
|
|
81
|
+
const normalizedSameSite = sameSite ? normalizeCookieSameSite(sameSite) : null;
|
|
82
|
+
if (sameSite && !normalizedSameSite) {
|
|
83
|
+
return invalidProtocolPayload('cookie.sameSite must be one of: Strict, Lax, None');
|
|
84
|
+
}
|
|
85
|
+
if (session && expires != null) {
|
|
86
|
+
return invalidProtocolPayload('cookie.expires must be null when cookie.session is true');
|
|
87
|
+
}
|
|
88
|
+
if (!session && expires == null) {
|
|
89
|
+
return invalidProtocolPayload('cookie.expires is required when cookie.session is false');
|
|
90
|
+
}
|
|
91
|
+
if (normalizedSameSite === 'None' && !secure) {
|
|
92
|
+
return invalidProtocolPayload('cookie.secure must be true when cookie.sameSite is None');
|
|
93
|
+
}
|
|
94
|
+
return validProtocolPayload({
|
|
95
|
+
cookie: compact({
|
|
96
|
+
...identity,
|
|
97
|
+
value: cookieValue,
|
|
98
|
+
secure,
|
|
99
|
+
httpOnly,
|
|
100
|
+
session,
|
|
101
|
+
sameSite: normalizedSameSite,
|
|
102
|
+
expires: expires ?? null,
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
/** Schema for POST /auth/cookies/clear request payloads. */
|
|
107
|
+
export const authCookieClearRequestSchema = defineProtocolSchema((value) => {
|
|
108
|
+
const invalid = requireObject(value);
|
|
109
|
+
if (invalid)
|
|
110
|
+
return invalid;
|
|
111
|
+
const fields = readFields(value, {
|
|
112
|
+
scope: (source, key) => optionalEnum(source, key, AUTH_COOKIE_CLEAR_SCOPES),
|
|
113
|
+
domain: optionalString,
|
|
114
|
+
sessionOnly: optionalBoolean,
|
|
115
|
+
authOnly: optionalBoolean,
|
|
116
|
+
});
|
|
117
|
+
if (!fields.ok)
|
|
118
|
+
return fields;
|
|
119
|
+
const { scope, domain } = fields.value;
|
|
120
|
+
if (scope == null) {
|
|
121
|
+
return invalidProtocolPayload(`scope must be one of: ${AUTH_COOKIE_CLEAR_SCOPES.join(', ')}`);
|
|
122
|
+
}
|
|
123
|
+
if (scope === 'domain' && !normalizeCookieDomainFilter(domain)) {
|
|
124
|
+
return invalidProtocolPayload('domain is required when scope is "domain"');
|
|
125
|
+
}
|
|
126
|
+
return validProtocolPayload(compact({ ...fields.value, scope }));
|
|
127
|
+
});
|
|
3
128
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/protocol/http/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/protocol/http/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAC5F,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACjG,OAAO,EACN,OAAO,EACP,UAAU,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,GAEd,MAAM,oBAAoB,CAAA;AA8G3B,wDAAwD;AACxD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAA;AAoEnD,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF,mDAAmD;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,CAAU,CAAA;AAE/F,mEAAmE;AACnE,MAAM,kBAAkB,GAAG,CAAC,MAA+B,EAAmC,EAAE;IAC/F,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAA;IACzG,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QAChB,kFAAkF;QAClF,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,qCAAqC,CAAC,CAAA;IACtF,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC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,MAAM,MAAM,GAAG,UAAU,CAAC,KAAgC,EAAE;QAC3D,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,wBAAwB,CAAC;QAC3E,MAAM,EAAE,cAAc;QACtB,WAAW,EAAE,eAAe;QAC5B,QAAQ,EAAE,eAAe;KACzB,CAAC,CAAA;IACF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAA;IAC7B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAA;IAEtC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,sBAAsB,CAAC,yBAAyB,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9F,CAAC;IACD,IAAI,KAAK,KAAK,QAAQ,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,OAAO,sBAAsB,CAAC,2CAA2C,CAAC,CAAA;IAC3E,CAAC;IAED,OAAO,oBAAoB,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AACjE,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Ok } from './errors.js';
|
|
1
2
|
/** Runtime resource type exposed by the live runtime-code API. */
|
|
2
3
|
export type CodeResourceType = 'script' | 'stylesheet';
|
|
3
4
|
/** Runtime script/stylesheet metadata. */
|
|
@@ -13,10 +14,9 @@ export type CodeListRequest = {
|
|
|
13
14
|
pattern?: string;
|
|
14
15
|
};
|
|
15
16
|
/** Response payload for POST /code/list. */
|
|
16
|
-
export type CodeListResponse = {
|
|
17
|
-
ok: true;
|
|
17
|
+
export type CodeListResponse = Ok<{
|
|
18
18
|
resources: CodeResource[];
|
|
19
|
-
}
|
|
19
|
+
}>;
|
|
20
20
|
/** Request payload for POST /code/read. */
|
|
21
21
|
export type CodeReadRequest = {
|
|
22
22
|
/** Resource URL from /code/list. */
|
|
@@ -27,8 +27,7 @@ export type CodeReadRequest = {
|
|
|
27
27
|
limit?: number;
|
|
28
28
|
};
|
|
29
29
|
/** Response payload for POST /code/read. */
|
|
30
|
-
export type CodeReadResponse = {
|
|
31
|
-
ok: true;
|
|
30
|
+
export type CodeReadResponse = Ok<{
|
|
32
31
|
resource: CodeResource;
|
|
33
32
|
/** Raw source text for the requested line slice. */
|
|
34
33
|
source: string;
|
|
@@ -36,7 +35,7 @@ export type CodeReadResponse = {
|
|
|
36
35
|
totalLines: number;
|
|
37
36
|
startLine: number;
|
|
38
37
|
endLine: number;
|
|
39
|
-
}
|
|
38
|
+
}>;
|
|
40
39
|
/** Request payload for POST /code/grep. */
|
|
41
40
|
export type CodeGrepRequest = {
|
|
42
41
|
/** Plain string or /regex/flags pattern to match within source lines. */
|
|
@@ -61,12 +60,11 @@ export type CodeGrepSkippedResource = {
|
|
|
61
60
|
reason: string;
|
|
62
61
|
};
|
|
63
62
|
/** Response payload for POST /code/grep. */
|
|
64
|
-
export type CodeGrepResponse = {
|
|
65
|
-
ok: true;
|
|
63
|
+
export type CodeGrepResponse = Ok<{
|
|
66
64
|
matches: CodeGrepMatch[];
|
|
67
65
|
/** Non-fatal runtime resources skipped while searching. */
|
|
68
66
|
skippedResources: CodeGrepSkippedResource[];
|
|
69
|
-
}
|
|
67
|
+
}>;
|
|
70
68
|
/** Request payload for POST /code/edit. */
|
|
71
69
|
export type CodeEditRequest = {
|
|
72
70
|
/** Resource URL from /code/list. */
|
|
@@ -75,8 +73,15 @@ export type CodeEditRequest = {
|
|
|
75
73
|
source: string;
|
|
76
74
|
};
|
|
77
75
|
/** Response payload for POST /code/edit. */
|
|
78
|
-
export type CodeEditResponse = {
|
|
79
|
-
ok: true;
|
|
76
|
+
export type CodeEditResponse = Ok<{
|
|
80
77
|
resource: CodeResource;
|
|
81
|
-
}
|
|
78
|
+
}>;
|
|
79
|
+
/** Schema for POST /code/list request payloads. */
|
|
80
|
+
export declare const codeListRequestSchema: import("../schema.js").ProtocolSchema<CodeListRequest>;
|
|
81
|
+
/** Schema for POST /code/read request payloads. */
|
|
82
|
+
export declare const codeReadRequestSchema: import("../schema.js").ProtocolSchema<CodeReadRequest>;
|
|
83
|
+
/** Schema for POST /code/grep request payloads. */
|
|
84
|
+
export declare const codeGrepRequestSchema: import("../schema.js").ProtocolSchema<CodeGrepRequest>;
|
|
85
|
+
/** Schema for POST /code/edit request payloads. */
|
|
86
|
+
export declare const codeEditRequestSchema: import("../schema.js").ProtocolSchema<CodeEditRequest>;
|
|
82
87
|
//# sourceMappingURL=code.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/protocol/http/code.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/protocol/http/code.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAErC,kEAAkE;AAClE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,YAAY,CAAA;AAEtD,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAAG;IAC1B,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAA;IACX,qBAAqB;IACrB,IAAI,EAAE,gBAAgB,CAAA;CACtB,CAAA;AAED,2CAA2C;AAC3C,MAAM,MAAM,eAAe,GAAG;IAC7B,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;IACjC,SAAS,EAAE,YAAY,EAAE,CAAA;CACzB,CAAC,CAAA;AAEF,2CAA2C;AAC3C,MAAM,MAAM,eAAe,GAAG;IAC7B,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAA;IACX,6CAA6C;I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,MAAM,gBAAgB,GAAG,EAAE,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAA;CACtB,CAAC,CAAA;AAEF,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,wDAQhC,CAAA;AAEF,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,wDAYhC,CAAA;AAEF,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,wDAWhC,CAAA;AAEF,mDAAmD;AACnD,eAAO,MAAM,qBAAqB,wDAYhC,CAAA"}
|
|
@@ -1,2 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineProtocolSchema, validProtocolPayload } from '../schema.js';
|
|
2
|
+
import { compact, fieldError, optionalInteger, optionalNonEmptyString, readFields, requireObject, requiredString } from '../schemaFields.js';
|
|
3
|
+
/** Schema for POST /code/list request payloads. */
|
|
4
|
+
export const codeListRequestSchema = defineProtocolSchema((value) => {
|
|
5
|
+
const invalid = requireObject(value);
|
|
6
|
+
if (invalid)
|
|
7
|
+
return invalid;
|
|
8
|
+
const fields = readFields(value, { pattern: optionalNonEmptyString });
|
|
9
|
+
if (!fields.ok)
|
|
10
|
+
return fields;
|
|
11
|
+
return validProtocolPayload(compact(fields.value));
|
|
12
|
+
});
|
|
13
|
+
/** Schema for POST /code/read request payloads. */
|
|
14
|
+
export const codeReadRequestSchema = defineProtocolSchema((value) => {
|
|
15
|
+
const invalid = requireObject(value);
|
|
16
|
+
if (invalid)
|
|
17
|
+
return invalid;
|
|
18
|
+
const fields = readFields(value, {
|
|
19
|
+
url: requiredString,
|
|
20
|
+
offset: (source, key) => optionalInteger(source, key, { min: 0 }),
|
|
21
|
+
limit: (source, key) => optionalInteger(source, key, { min: 1 }),
|
|
22
|
+
});
|
|
23
|
+
if (!fields.ok)
|
|
24
|
+
return fields;
|
|
25
|
+
return validProtocolPayload(compact(fields.value));
|
|
26
|
+
});
|
|
27
|
+
/** Schema for POST /code/grep request payloads. */
|
|
28
|
+
export const codeGrepRequestSchema = defineProtocolSchema((value) => {
|
|
29
|
+
const invalid = requireObject(value);
|
|
30
|
+
if (invalid)
|
|
31
|
+
return invalid;
|
|
32
|
+
const fields = readFields(value, {
|
|
33
|
+
pattern: requiredString,
|
|
34
|
+
urlPattern: optionalNonEmptyString,
|
|
35
|
+
});
|
|
36
|
+
if (!fields.ok)
|
|
37
|
+
return fields;
|
|
38
|
+
return validProtocolPayload(compact(fields.value));
|
|
39
|
+
});
|
|
40
|
+
/** Schema for POST /code/edit request payloads. */
|
|
41
|
+
export const codeEditRequestSchema = defineProtocolSchema((value) => {
|
|
42
|
+
const invalid = requireObject(value);
|
|
43
|
+
if (invalid)
|
|
44
|
+
return invalid;
|
|
45
|
+
const fields = readFields(value, {
|
|
46
|
+
url: requiredString,
|
|
47
|
+
// Empty source is legal: it clears the resource.
|
|
48
|
+
source: (source, key) => (typeof source[key] === 'string' ? source[key] : fieldError('source must be a string')),
|
|
49
|
+
});
|
|
50
|
+
if (!fields.ok)
|
|
51
|
+
return fields;
|
|
52
|
+
return validProtocolPayload(fields.value);
|
|
53
|
+
});
|
|
2
54
|
//# sourceMappingURL=code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../../src/protocol/http/code.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../../src/protocol/http/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,sBAAsB,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AA4F5I,mDAAmD;AACnD,MAAM,CAAC,MAAM,qBAAqB,GAAG,oBAAoB,CAAkB,CAAC,KAAK,EAAE,EAAE;IACpF,MAAM,OAAO,GAAG,aAAa,CAAkB,KAAK,CAAC,CAAA;IACrD,IAAI,OAAO;QAAE,OAA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