@repost/client 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/README.md +15 -85
- package/dist/cjs/index-e0zw7VDH.cjs +2987 -0
- package/dist/cjs/index-e0zw7VDH.cjs.map +1 -0
- package/dist/cjs/index.cjs +23 -1046
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/node-Dd92VNS7.cjs +841 -0
- package/dist/cjs/node-Dd92VNS7.cjs.map +1 -0
- package/dist/cjs/observer-dykSFHYi.cjs +69 -0
- package/dist/cjs/observer-dykSFHYi.cjs.map +1 -0
- package/dist/cjs/otel/index.cjs +99 -0
- package/dist/cjs/otel/index.cjs.map +1 -0
- package/dist/cjs/testing/index.cjs +257 -0
- package/dist/cjs/testing/index.cjs.map +1 -0
- package/dist/cjs/types/config.d.ts +28 -0
- package/dist/cjs/types/errors.d.ts +83 -0
- package/dist/cjs/types/index.d.ts +8 -3
- package/dist/cjs/types/observer.d.ts +44 -0
- package/dist/cjs/types/operation-events.d.ts +8 -0
- package/dist/cjs/types/operation-input.d.ts +5 -0
- package/dist/cjs/types/operation-policy.d.ts +23 -0
- package/dist/cjs/types/operation.d.ts +14 -0
- package/dist/cjs/types/otel/index.d.ts +2 -0
- package/dist/cjs/types/otel/metrics.d.ts +5 -0
- package/dist/cjs/types/otel/telemetry.d.ts +5 -0
- package/dist/cjs/types/runtime-state.d.ts +45 -0
- package/dist/cjs/types/serialize.d.ts +9 -3
- package/dist/cjs/types/telemetry.d.ts +43 -0
- package/dist/cjs/types/testing/deterministic.d.ts +19 -0
- package/dist/cjs/types/testing/index.d.ts +16 -0
- package/dist/cjs/types/testing/manual-clock.d.ts +12 -0
- package/dist/cjs/types/testing/recording-observer.d.ts +11 -0
- package/dist/cjs/types/testing/stub-transport.d.ts +35 -0
- package/dist/cjs/types/transport/connect-proxy.d.ts +30 -0
- package/dist/cjs/types/transport/failure.d.ts +7 -0
- package/dist/cjs/types/transport/framing.d.ts +8 -0
- package/dist/cjs/types/transport/h2.d.ts +3 -0
- package/dist/cjs/types/transport/node.d.ts +3 -0
- package/dist/cjs/types/transport/response-reader.d.ts +6 -0
- package/dist/cjs/types/transport/strict-json.d.ts +5 -0
- package/dist/cjs/types/transport/tls.d.ts +14 -0
- package/dist/cjs/types/transport/undici-compat.d.ts +47 -0
- package/dist/cjs/types/transport.d.ts +42 -19
- package/dist/cjs/types/types.d.ts +146 -23
- package/dist/cjs/types/version.d.ts +2 -0
- package/dist/cjs/types/webhooks.d.ts +15 -0
- package/dist/cjs/version-CGqSWJir.cjs +7 -0
- package/dist/cjs/version-CGqSWJir.cjs.map +1 -0
- package/dist/esm/index-DRD5FBax.mjs +2967 -0
- package/dist/esm/index-DRD5FBax.mjs.map +1 -0
- package/dist/esm/index.mjs +3 -1041
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/node-BAJt_qhB.mjs +839 -0
- package/dist/esm/node-BAJt_qhB.mjs.map +1 -0
- package/dist/esm/observer-Dns2X4wE.mjs +66 -0
- package/dist/esm/observer-Dns2X4wE.mjs.map +1 -0
- package/dist/esm/otel/index.mjs +96 -0
- package/dist/esm/otel/index.mjs.map +1 -0
- package/dist/esm/testing/index.mjs +248 -0
- package/dist/esm/testing/index.mjs.map +1 -0
- package/dist/esm/version-Dp5vd2nu.mjs +5 -0
- package/dist/esm/version-Dp5vd2nu.mjs.map +1 -0
- package/index.d.ts +1 -1
- package/index.js +3 -4
- package/index.mjs +1 -1
- package/otel/index.d.ts +1 -0
- package/otel/index.js +3 -0
- package/otel/index.mjs +1 -0
- package/package.json +38 -9
- package/runtime/index.d.ts +1 -1
- package/runtime/index.js +2 -2
- package/runtime/index.mjs +1 -1
- package/scripts/postinstall.js +2 -2
- package/testing/index.d.ts +1 -0
- package/testing/index.js +3 -0
- package/testing/index.mjs +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/testing/manual-clock.ts","../../../../src/testing/deterministic.ts","../../../../src/testing/recording-observer.ts","../../../../src/testing/stub-transport.ts","../../../../src/testing/index.ts"],"sourcesContent":["import type { Scheduler } from \"../types\";\n\ninterface ManualTimer {\n readonly due: number;\n readonly sequence: number;\n resolve(): void;\n reject(reason?: unknown): void;\n cancelled: boolean;\n}\n\nexport class ManualClock {\n private current = 0;\n private sequence = 0;\n private readonly timers: ManualTimer[] = [];\n\n readonly monotonic = (): number => this.current;\n readonly wall = (): number => this.current;\n get nowMs(): number { return this.current; }\n\n async advance(ms: number): Promise<void> {\n if (!Number.isFinite(ms) || ms < 0) throw new RangeError(\"advance requires non-negative milliseconds\");\n const target = this.current + ms;\n while (true) {\n this.timers.sort((left, right) => left.due - right.due || left.sequence - right.sequence);\n const next = this.timers.find((timer) => !timer.cancelled && timer.due <= target);\n if (!next) break;\n this.timers.splice(this.timers.indexOf(next), 1);\n this.current = next.due;\n next.resolve();\n await Promise.resolve();\n await Promise.resolve();\n }\n this.current = target;\n await Promise.resolve();\n }\n\n schedule(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n const timer: ManualTimer = {\n due: this.current + ms,\n sequence: ++this.sequence,\n resolve,\n reject,\n cancelled: false,\n };\n if (signal?.aborted) {\n timer.cancelled = true;\n reject(signal.reason);\n return;\n }\n signal?.addEventListener(\"abort\", () => {\n if (timer.cancelled) return;\n timer.cancelled = true;\n reject(signal.reason);\n }, { once: true });\n this.timers.push(timer);\n });\n }\n}\n\nexport function manualScheduler(clock: ManualClock): Scheduler {\n return { sleep: (ms, signal) => clock.schedule(ms, signal) };\n}\n","import type { Generators, RetryEntropy } from \"../types\";\n\nexport const TestDefaultValueGenerators = {\n fixed(nowIso: string, uuid: string, cuid: string): Generators {\n return { now: () => nowIso, uuid: () => uuid, cuid: () => cuid };\n },\n sequence(entries: Array<Partial<{ now: string; uuid: string; cuid: string }>>): Generators {\n const indices = { now: 0, uuid: 0, cuid: 0 };\n const next = (kind: keyof typeof indices): string => {\n const value = entries[indices[kind]++]?.[kind];\n if (value === undefined) throw new Error(`${kind} sequence exhausted`);\n return value;\n };\n return { now: () => next(\"now\"), uuid: () => next(\"uuid\"), cuid: () => next(\"cuid\") };\n },\n failing(error = new Error(\"default generator failed\")): Generators {\n const fail = (): never => { throw error; };\n return { now: fail, uuid: fail, cuid: fail };\n },\n};\n\nexport const TestIdempotencyKeyGenerator = {\n fixed(key: string): () => string { return () => key; },\n sequence(...keys: string[]): () => string {\n let index = 0;\n return () => {\n const key = keys[index++];\n if (key === undefined) throw new Error(\"idempotency key sequence exhausted\");\n return key;\n };\n },\n failing(error = new Error(\"idempotency key generator failed\")): () => string {\n return () => { throw error; };\n },\n};\n\nexport const DeterministicRetryEntropy = {\n zero(): RetryEntropy { return { nextInt: () => 0 }; },\n sequence(...values: number[]): RetryEntropy {\n let index = 0;\n return {\n nextInt(exclusiveBound) {\n const value = values[index++];\n if (value === undefined) throw new Error(\"entropy sequence exhausted\");\n if (!Number.isInteger(value) || value < 0 || value >= exclusiveBound) throw new RangeError(\"entropy value out of range\");\n return value;\n },\n };\n },\n};\n","import { observerFlush, type FlushableObserver, type ObserverEvent } from \"../observer\";\n\nexport class RecordingObserver {\n private readonly recorded: ObserverEvent[] = [];\n private readonly waiters: Array<(event: ObserverEvent) => void> = [];\n\n readonly callback: FlushableObserver = Object.assign(\n (event: ObserverEvent) => {\n this.recorded.push(event);\n this.waiters.shift()?.(event);\n },\n { [observerFlush]: async () => {} },\n );\n\n get events(): readonly ObserverEvent[] { return Object.freeze([...this.recorded]); }\n\n awaitNext(options: { timeoutMs?: number } = {}): Promise<ObserverEvent> {\n const timeoutMs = options.timeoutMs ?? 1_000;\n return new Promise((resolve, reject) => {\n const waiter = (event: ObserverEvent): void => { clearTimeout(timer); resolve(event); };\n const timer = setTimeout(() => {\n const index = this.waiters.indexOf(waiter);\n if (index >= 0) this.waiters.splice(index, 1);\n reject(new Error(\"observer event timeout\"));\n }, timeoutMs);\n this.waiters.push(waiter);\n });\n }\n\n async awaitQuiescence(): Promise<void> {\n await this.callback[observerFlush]?.();\n }\n}\n","import type { AttemptOutcome, AttemptRequest, Transport } from \"../types\";\nimport type { RepostFailureReason } from \"../errors\";\n\ntype FailureCode = \"DNS\" | \"CONNECT\" | \"PROXY\" | \"TLS\" | \"IO\" | \"ATTEMPT_TIMEOUT\";\n\nexport interface RecordedRequest {\n readonly url: string;\n readonly headers: Readonly<Record<string, string>>;\n readonly bodyText: string;\n readonly bodyBytes: Uint8Array;\n readonly attemptNumber: number;\n readonly idempotencyKey: string;\n readonly attemptTimeoutMs: number;\n readonly captureSequence: number;\n}\n\nexport interface ControlledResponse {\n respond(status: number, body: string, headers?: Record<string, string>): void;\n fail(code: FailureCode, options?: { reason?: RepostFailureReason; committed?: boolean }): void;\n readonly isDone: boolean;\n}\n\nexport class ScriptedStubTransport implements Transport {\n private readonly script: Array<(request: AttemptRequest) => Promise<AttemptOutcome>> = [];\n private readonly captured: RecordedRequest[] = [];\n private sequence = 0;\n\n get requests(): readonly RecordedRequest[] { return Object.freeze([...this.captured]); }\n\n enqueueResponse(status: number, body: string, headers: Record<string, string> = {}): this {\n this.script.push(async (request) => responseOutcome(request, status, body, headers));\n return this;\n }\n\n enqueueFailure(\n code: FailureCode,\n options: { reason?: RepostFailureReason; committed?: boolean } = {},\n ): this {\n this.script.push(async (request) => {\n if (options.committed) request.commitTracker.markCommitted();\n return { kind: \"failure\", code, reason: options.reason ?? null, committed: options.committed ?? false };\n });\n return this;\n }\n\n enqueuePending(): ControlledResponse {\n let settle: ((outcome: AttemptOutcome) => void) | undefined;\n let pending: AttemptOutcome | undefined;\n let done = false;\n this.script.push((request) => {\n if (pending) {\n if (pending.kind === \"response\" || pending.committed) request.commitTracker.markCommitted();\n return Promise.resolve(pending);\n }\n return new Promise((resolve) => {\n settle = (outcome) => {\n if (outcome.kind === \"response\" || outcome.committed) request.commitTracker.markCommitted();\n resolve(outcome);\n };\n request.signal.addEventListener(\"abort\", () => {\n if (!done) complete({ kind: \"failure\", code: \"ATTEMPT_TIMEOUT\", reason: null, committed: request.commitTracker.committed });\n }, { once: true });\n });\n });\n const complete = (outcome: AttemptOutcome): void => {\n if (done) return;\n done = true;\n pending = outcome;\n settle?.(outcome);\n };\n return {\n respond(status, body, headers = {}) { complete(responseOutcome(undefined, status, body, headers)); },\n fail(code, options = {}) { complete({ kind: \"failure\", code, reason: options.reason ?? null, committed: options.committed ?? false }); },\n get isDone() { return done; },\n };\n }\n\n async send(request: AttemptRequest): Promise<AttemptOutcome> {\n const next = this.script.shift();\n if (!next) throw new Error(\"script exhausted\");\n this.sequence += 1;\n const headers = Object.fromEntries(request.headers.map(([name, value]) => [name, name.toLowerCase() === \"authorization\" ? \"<redacted>\" : value]));\n this.captured.push(Object.freeze({\n url: request.url,\n headers: Object.freeze(headers),\n bodyText: new TextDecoder().decode(request.bodyBytes),\n bodyBytes: request.bodyBytes.slice(),\n attemptNumber: request.attemptNumber,\n idempotencyKey: headers[\"idempotency-key\"] ?? \"\",\n attemptTimeoutMs: request.attemptTimeoutMs,\n captureSequence: this.sequence,\n }));\n return next(request);\n }\n}\n\nfunction responseOutcome(\n request: AttemptRequest | undefined,\n status: number,\n body: string,\n headers: Record<string, string>,\n): AttemptOutcome {\n request?.commitTracker.markCommitted();\n const bodyBytes = new TextEncoder().encode(body);\n return {\n kind: \"response\",\n status,\n headers: Object.fromEntries(Object.entries(headers).map(([name, value]) => [name.toLowerCase(), [value]])),\n bodyBytes,\n compressedBytes: bodyBytes.length,\n decompressedBytes: bodyBytes.length,\n truncated: false,\n };\n}\n","import type { RepostClientOptions } from \"../types\";\nimport { ManualClock, manualScheduler } from \"./manual-clock\";\nimport { DeterministicRetryEntropy, TestDefaultValueGenerators, TestIdempotencyKeyGenerator } from \"./deterministic\";\nimport { RecordingObserver } from \"./recording-observer\";\nimport { ScriptedStubTransport, type ControlledResponse, type RecordedRequest } from \"./stub-transport\";\n\nexport { ManualClock, manualScheduler };\nexport { DeterministicRetryEntropy, TestDefaultValueGenerators, TestIdempotencyKeyGenerator };\nexport { RecordingObserver };\nexport { ScriptedStubTransport };\nexport type { ControlledResponse, RecordedRequest };\n\nexport function deterministicClientOptions(overrides: Partial<RepostClientOptions> = {}): {\n options: RepostClientOptions;\n transport: ScriptedStubTransport;\n observer: RecordingObserver;\n clock: ManualClock;\n} {\n const transport = new ScriptedStubTransport();\n const observer = new RecordingObserver();\n const clock = new ManualClock();\n return {\n transport,\n observer,\n clock,\n options: {\n apiKey: \"test-key\",\n transport,\n observer: observer.callback,\n generators: TestDefaultValueGenerators.fixed(\n \"2026-01-01T00:00:00.000Z\",\n \"00000000-0000-4000-8000-000000000000\",\n \"ck0nf0rm4nc3f1x3dcu1d000\",\n ),\n idempotencyKeyGenerator: TestIdempotencyKeyGenerator.fixed(\"idem_test\"),\n retryEntropy: DeterministicRetryEntropy.zero(),\n monotonicClock: clock.monotonic,\n wallClock: clock.wall,\n scheduler: manualScheduler(clock),\n ...overrides,\n },\n };\n}\n"],"names":["observerFlush"],"mappings":";;;;MAUa,WAAW,CAAA;AAAxB,IAAA,WAAA,GAAA;QACU,IAAA,CAAA,OAAO,GAAG,CAAC;QACX,IAAA,CAAA,QAAQ,GAAG,CAAC;QACH,IAAA,CAAA,MAAM,GAAkB,EAAE;AAElC,QAAA,IAAA,CAAA,SAAS,GAAG,MAAc,IAAI,CAAC,OAAO;AACtC,QAAA,IAAA,CAAA,IAAI,GAAG,MAAc,IAAI,CAAC,OAAO;IA0C5C;IAzCE,IAAI,KAAK,KAAa,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;IAE3C,MAAM,OAAO,CAAC,EAAU,EAAA;QACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;AAAE,YAAA,MAAM,IAAI,UAAU,CAAC,4CAA4C,CAAC;AACtG,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,GAAG,EAAE;QAChC,OAAO,IAAI,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tC,0BAA0B,CAC3B;AACD,YAAA,uBAAuB,EAAE,2BAA2B,CAAC,KAAK,CAAC,WAAW,CAAC;AACvE,YAAA,YAAY,EAAE,yBAAyB,CAAC,IAAI,EAAE;YAC9C,cAAc,EAAE,KAAK,CAAC,SAAS;YAC/B,SAAS,EAAE,KAAK,CAAC,IAAI;AACrB,YAAA,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC;AACjC,YAAA,GAAG,SAAS;AACb,SAAA;KACF;AACH;;;;;;;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Generators, RepostClientOptions, RetryEntropy, Scheduler, Transport } from "./types";
|
|
2
|
+
export interface ResolvedClientOptions {
|
|
3
|
+
readonly apiKey?: string;
|
|
4
|
+
readonly apiKeyProvider?: () => string | Promise<string>;
|
|
5
|
+
readonly apiUrl: string;
|
|
6
|
+
readonly transport?: Transport;
|
|
7
|
+
readonly httpTransportOptions?: import("./transport").HttpTransportOptions;
|
|
8
|
+
readonly generators?: Generators;
|
|
9
|
+
readonly attemptTimeoutMs: number;
|
|
10
|
+
readonly operationTimeoutMs: number;
|
|
11
|
+
readonly connectTimeoutMs: number;
|
|
12
|
+
readonly maxAttempts: number;
|
|
13
|
+
readonly retryBaseDelayMs: number;
|
|
14
|
+
readonly retryMaxDelayMs: number;
|
|
15
|
+
readonly maxInFlightOperations: number;
|
|
16
|
+
readonly maxBufferedBytes: number;
|
|
17
|
+
readonly idempotencyKeyGenerator: (() => string) | false;
|
|
18
|
+
readonly retryEntropy: RetryEntropy;
|
|
19
|
+
readonly monotonicClock: () => number;
|
|
20
|
+
readonly wallClock: () => number;
|
|
21
|
+
readonly scheduler: Scheduler;
|
|
22
|
+
readonly userAgent: string;
|
|
23
|
+
readonly observer?: import("./observer").RepostObserver;
|
|
24
|
+
readonly telemetry?: import("./telemetry").RepostTelemetry;
|
|
25
|
+
}
|
|
26
|
+
export declare function snapshotOptions(options: RepostClientOptions): ResolvedClientOptions;
|
|
27
|
+
export declare function canonicalizeBaseUrl(raw: string): string;
|
|
28
|
+
export declare function endpointUrl(base: string): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type RepostErrorCode = "CONFIGURATION" | "CLOSED" | "VALIDATION" | "SERIALIZATION" | "REQUEST_TOO_LARGE" | "DNS" | "CONNECT" | "PROXY" | "TLS" | "IO" | "ATTEMPT_TIMEOUT" | "OPERATION_DEADLINE" | "CANCELLED" | "OVERLOADED" | "RATE_LIMITED" | "HTTP_REJECTED" | "SERVER_FAILURE" | "RESPONSE_TOO_LARGE" | "RESPONSE_PROTOCOL" | "DESCRIPTOR_VERSION";
|
|
2
|
+
export type DeliveryState = "NOT_SENT" | "POSSIBLY_SENT" | "ACCEPTED" | "REJECTED" | "CANCELLED_UNKNOWN";
|
|
3
|
+
export type HttpStatusClass = "INFORMATIONAL" | "SUCCESS" | "REDIRECT" | "CLIENT_ERROR" | "SERVER_ERROR";
|
|
4
|
+
export type RepostFailureReason = "DNS_NOT_FOUND" | "DNS_TIMEOUT" | "CONNECT_REFUSED" | "CONNECT_TIMEOUT" | "CONNECTION_RESET" | "CONNECTION_CLOSED" | "TLS_UNTRUSTED" | "TLS_CERTIFICATE_EXPIRED" | "TLS_CERTIFICATE_NOT_YET_VALID" | "TLS_HOSTNAME_MISMATCH" | "TLS_NEGOTIATION" | "PROXY_AUTH_REQUIRED" | "PROXY_CONNECT_FAILED" | "UNKNOWN";
|
|
5
|
+
export type RepostCauseCategory = "API_KEY_PROVIDER" | "DEFAULT_GENERATOR" | "IDEMPOTENCY_GENERATOR" | "RETRY_ENTROPY" | "DNS_RESOLVER" | "PROXY_CREDENTIAL_PROVIDER" | "TLS_PROVIDER" | "CUSTOM_TRANSPORT" | "RESPONSE_BODY" | "OBSERVER" | "HTTP_RUNTIME" | "TRANSPORT_CLOSE" | "SCHEDULER_CLOSE" | "OPERATION_EXECUTOR_CLOSE" | "DNS_EXECUTOR_CLOSE" | "PROXY_CREDENTIAL_EXECUTOR_CLOSE" | "TLS_EXECUTOR_CLOSE" | "TERMINAL_SETTLEMENT_CLOSE" | "OBSERVER_CLOSE" | "UNKNOWN";
|
|
6
|
+
export type ValidationIssueCode = "REQUIRED" | "NULL_NOT_ALLOWED" | "TYPE_MISMATCH" | "OUT_OF_RANGE" | "NON_FINITE" | "INVALID_DATETIME" | "INVALID_ENUM" | "INVALID_JSON" | "INVALID_UNICODE" | "COLLECTION_LIMIT" | "CYCLE";
|
|
7
|
+
export type ConfigurationIssueCode = "MISSING" | "CONFLICT" | "INVALID_VALUE" | "OUT_OF_RANGE" | "UNSUPPORTED" | "RESOURCE_MISMATCH";
|
|
8
|
+
export type ClientOptionKey = "API_KEY" | "API_KEY_PROVIDER" | "BASE_URI" | "CONNECT_TIMEOUT" | "ATTEMPT_TIMEOUT" | "OPERATION_TIMEOUT" | "MAX_ATTEMPTS" | "MAX_IN_FLIGHT_OPERATIONS" | "MAX_BUFFERED_BYTES" | "RETRY_BASE_DELAY" | "RETRY_MAX_DELAY" | "HTTP_TRANSPORT_OPTIONS" | "TRANSPORT" | "EXECUTOR" | "SCHEDULER" | "OBSERVER" | "OBSERVER_EXECUTOR" | "TELEMETRY" | "DEFAULT_VALUE_GENERATORS" | "IDEMPOTENCY_KEY_GENERATOR" | "MONOTONIC_CLOCK" | "WALL_CLOCK" | "RETRY_ENTROPY" | "USER_AGENT_SUFFIX";
|
|
9
|
+
export interface ValidationIssue {
|
|
10
|
+
readonly code: ValidationIssueCode;
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ConfigurationIssue {
|
|
15
|
+
readonly code: ConfigurationIssueCode;
|
|
16
|
+
readonly optionKeys: readonly ClientOptionKey[];
|
|
17
|
+
}
|
|
18
|
+
export declare const errorCatalog: Readonly<Record<RepostErrorCode, string>>;
|
|
19
|
+
export interface RepostErrorDetails {
|
|
20
|
+
readonly errorCode: RepostErrorCode;
|
|
21
|
+
readonly deliveryState: DeliveryState;
|
|
22
|
+
readonly retryable?: boolean;
|
|
23
|
+
readonly operationId?: string | null;
|
|
24
|
+
readonly idempotencyKey?: string | null;
|
|
25
|
+
readonly attemptCount?: number;
|
|
26
|
+
readonly httpStatus?: number | null;
|
|
27
|
+
readonly failureReason?: RepostFailureReason | null;
|
|
28
|
+
readonly causeCategory?: RepostCauseCategory | null;
|
|
29
|
+
readonly compressedBytes?: number;
|
|
30
|
+
readonly decompressedBytes?: number;
|
|
31
|
+
readonly responseHeaderFields?: number;
|
|
32
|
+
readonly responseHeaderBytes?: number;
|
|
33
|
+
readonly truncated?: boolean;
|
|
34
|
+
readonly validationIssues?: readonly ValidationIssue[];
|
|
35
|
+
readonly configurationIssues?: readonly ConfigurationIssue[];
|
|
36
|
+
readonly body?: unknown;
|
|
37
|
+
readonly closeFailureCount?: number;
|
|
38
|
+
readonly closeFailureCategories?: readonly RepostCauseCategory[];
|
|
39
|
+
readonly issueCount?: number;
|
|
40
|
+
readonly issuesTruncated?: boolean;
|
|
41
|
+
readonly remediationKey?: string | null;
|
|
42
|
+
}
|
|
43
|
+
export declare class RepostError extends Error {
|
|
44
|
+
readonly errorCode: RepostErrorCode;
|
|
45
|
+
readonly deliveryState: DeliveryState;
|
|
46
|
+
readonly retryable: boolean;
|
|
47
|
+
readonly operationId: string | null;
|
|
48
|
+
readonly idempotencyKey: string | null;
|
|
49
|
+
readonly attemptCount: number;
|
|
50
|
+
readonly httpStatus: number | null;
|
|
51
|
+
readonly failureReason: RepostFailureReason | null;
|
|
52
|
+
readonly causeCategory: RepostCauseCategory | null;
|
|
53
|
+
readonly compressedBytes: number;
|
|
54
|
+
readonly decompressedBytes: number;
|
|
55
|
+
readonly responseHeaderFields: number;
|
|
56
|
+
readonly responseHeaderBytes: number;
|
|
57
|
+
readonly truncated: boolean;
|
|
58
|
+
readonly validationIssues: readonly ValidationIssue[];
|
|
59
|
+
readonly configurationIssues: readonly ConfigurationIssue[];
|
|
60
|
+
readonly closeFailureCount: number;
|
|
61
|
+
readonly closeFailureCategories: readonly RepostCauseCategory[];
|
|
62
|
+
readonly issueCount: number;
|
|
63
|
+
readonly issuesTruncated: boolean;
|
|
64
|
+
readonly remediationKey: string | null;
|
|
65
|
+
constructor(details: RepostErrorDetails);
|
|
66
|
+
isRetryable(): boolean;
|
|
67
|
+
}
|
|
68
|
+
export declare class RepostConfigurationError extends RepostError {
|
|
69
|
+
}
|
|
70
|
+
export declare class RepostValidationError extends RepostError {
|
|
71
|
+
}
|
|
72
|
+
export declare class RepostSerializationError extends RepostError {
|
|
73
|
+
}
|
|
74
|
+
export declare class RepostTransportError extends RepostError {
|
|
75
|
+
}
|
|
76
|
+
export declare class RepostPublishError extends RepostError {
|
|
77
|
+
readonly status?: number;
|
|
78
|
+
readonly body?: unknown;
|
|
79
|
+
constructor(details: RepostErrorDetails);
|
|
80
|
+
constructor(_legacyMessage: string, status?: number, body?: unknown);
|
|
81
|
+
}
|
|
82
|
+
export declare class RepostDescriptorVersionError extends RepostError {
|
|
83
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export { serializeModel } from "./serialize";
|
|
2
|
-
export type { DefaultSpec, Envelope, EventDescriptor, FieldDescriptor, ModelDescriptor, RepostClientOptions, SchemaDescriptor,
|
|
3
|
-
export { createHttpTransport, httpTransport, RepostPublishError } from "./transport";
|
|
2
|
+
export type { DefaultSpec, Envelope, EnumDescriptors, EventDescriptor, FieldDescriptor, FieldDescriptorV2, Generators, ModelDescriptor, RepostClientOptions, SchemaDescriptor, ScalarKind, AttemptRequest, AttemptOutcome, BoundedHeaders, CommitTracker, SendResult, SendOperation, SendOperationOutcome, Transport, RetryEntropy, Scheduler, WebhookDescriptors, } from "./types";
|
|
3
|
+
export { createFetchTransport, createHttpTransport, createNodeTransport, httpTransport, RepostPublishError } from "./transport";
|
|
4
4
|
export type { HttpTransportOptions } from "./transport";
|
|
5
|
-
export {
|
|
5
|
+
export { RepostConfigurationError, RepostDescriptorVersionError, RepostError, RepostSerializationError, RepostTransportError, RepostValidationError, errorCatalog, } from "./errors";
|
|
6
|
+
export type { ClientOptionKey, ConfigurationIssue, ConfigurationIssueCode, DeliveryState, HttpStatusClass, RepostCauseCategory, RepostErrorCode, RepostErrorDetails, RepostFailureReason, ValidationIssue, ValidationIssueCode, } from "./errors";
|
|
7
|
+
export { DESCRIPTOR_FORMAT_VERSION, buildClient, buildWebhooks, stubTransport } from "./webhooks";
|
|
8
|
+
export type { RuntimeDiagnostics } from "./runtime-state";
|
|
9
|
+
export type { AttemptSummary, ObserverEvent, ObserverEventKind, ObserverOutcome, RepostObserver, } from "./observer";
|
|
10
|
+
export type { CapturedTelemetryContext, RepostTelemetry, TelemetryAttempt, TelemetryAttemptEnd, TelemetryAttemptStart, TelemetryOperation, TelemetryOperationEnd, TelemetryOperationStart, } from "./telemetry";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DeliveryState, HttpStatusClass, RepostErrorCode } from "./errors";
|
|
2
|
+
import type { RuntimeState } from "./runtime-state";
|
|
3
|
+
export type ObserverEventKind = "operation.start" | "attempt.start" | "attempt.end" | "retry.delay" | "operation.cancel" | "operation.end";
|
|
4
|
+
export type ObserverOutcome = "ACCEPTED" | "RETRYABLE_FAILURE" | "REJECTED" | "FAILED" | "CANCELLED" | "CLOSED";
|
|
5
|
+
export interface AttemptSummary {
|
|
6
|
+
readonly attemptNumber: number;
|
|
7
|
+
readonly outcome: ObserverOutcome;
|
|
8
|
+
readonly errorCode: RepostErrorCode | null;
|
|
9
|
+
readonly deliveryState: DeliveryState | null;
|
|
10
|
+
readonly httpStatusClass: HttpStatusClass | null;
|
|
11
|
+
readonly durationMs: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ObserverEvent {
|
|
14
|
+
readonly schemaVersion: 1;
|
|
15
|
+
readonly kind: ObserverEventKind;
|
|
16
|
+
readonly operationId: string;
|
|
17
|
+
readonly timestampMs: number;
|
|
18
|
+
readonly attemptNumber: number | null;
|
|
19
|
+
readonly durationMs: number | null;
|
|
20
|
+
readonly outcome: ObserverOutcome | null;
|
|
21
|
+
readonly errorCode: RepostErrorCode | null;
|
|
22
|
+
readonly deliveryState: DeliveryState | null;
|
|
23
|
+
readonly httpStatusClass: HttpStatusClass | null;
|
|
24
|
+
readonly retryDelayMs: number | null;
|
|
25
|
+
readonly operationStartedAtMs: number | null;
|
|
26
|
+
readonly operationEndedAtMs: number | null;
|
|
27
|
+
readonly attemptSummaries: readonly AttemptSummary[];
|
|
28
|
+
}
|
|
29
|
+
export type RepostObserver = (event: ObserverEvent) => void | Promise<void>;
|
|
30
|
+
export declare const observerFlush: unique symbol;
|
|
31
|
+
export type FlushableObserver = RepostObserver & {
|
|
32
|
+
[observerFlush]?: () => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
export declare class ObserverDispatcher {
|
|
35
|
+
private readonly callback;
|
|
36
|
+
private readonly state;
|
|
37
|
+
private readonly queue;
|
|
38
|
+
private readonly flushWaiters;
|
|
39
|
+
private draining;
|
|
40
|
+
constructor(callback: RepostObserver | undefined, state: RuntimeState);
|
|
41
|
+
emit(event: ObserverEvent): void;
|
|
42
|
+
flush(): Promise<void>;
|
|
43
|
+
private drain;
|
|
44
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RepostError } from "./errors";
|
|
2
|
+
import type { AttemptSummary, ObserverEvent, ObserverOutcome } from "./observer";
|
|
3
|
+
import type { TelemetryAttemptEnd } from "./telemetry";
|
|
4
|
+
import type { AttemptOutcome } from "./types";
|
|
5
|
+
export declare function observerEvent(kind: ObserverEvent["kind"], operationId: string, timestampMs: number, values?: Partial<ObserverEvent>): ObserverEvent;
|
|
6
|
+
export declare function attemptSummary(attemptNumber: number, outcome: ObserverOutcome, error: RepostError | null, attempt: AttemptOutcome, durationMs: number): AttemptSummary;
|
|
7
|
+
export declare function statusClass(status: number): AttemptSummary["httpStatusClass"];
|
|
8
|
+
export declare function telemetryAttemptEnd(summary: AttemptSummary): TelemetryAttemptEnd;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ResolvedClientOptions } from "./config";
|
|
2
|
+
import type { EventDescriptor, SchemaDescriptor } from "./types";
|
|
3
|
+
export declare function resolveCredential(config: ResolvedClientOptions, operationId: string): Promise<string>;
|
|
4
|
+
export declare function resolveIdempotencyKey(config: ResolvedClientOptions, supplied: string | undefined, operationId: string): string;
|
|
5
|
+
export declare function serializeForSend(schema: SchemaDescriptor, event: EventDescriptor, data: unknown, generators: Required<NonNullable<ResolvedClientOptions["generators"]>>, operationId: string, idempotencyKey: string): Record<string, unknown>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RepostError, RepostTransportError, type DeliveryState, type RepostErrorCode, type RepostErrorDetails, type RepostFailureReason } from "./errors";
|
|
2
|
+
import type { AttemptOutcome, BoundedHeaders, SendResult } from "./types";
|
|
3
|
+
interface ClassifiedFailure {
|
|
4
|
+
code: RepostErrorCode;
|
|
5
|
+
retryable: boolean;
|
|
6
|
+
deliveryState: DeliveryState;
|
|
7
|
+
reason: RepostFailureReason | null;
|
|
8
|
+
acceptancePossible: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function classifyOutcome(outcome: AttemptOutcome, priorPossible: boolean): ClassifiedFailure;
|
|
11
|
+
export declare function validateAcceptedResponse(outcome: Extract<AttemptOutcome, {
|
|
12
|
+
kind: "response";
|
|
13
|
+
}>, envelope: {
|
|
14
|
+
type: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
}, customerId: string): SendResult | "LIMIT_EXCEEDED" | null;
|
|
17
|
+
export declare function parseRetryAfter(headers: BoundedHeaders, wallNow: number): number | null;
|
|
18
|
+
export declare function publicError(code: RepostErrorCode, deliveryState: DeliveryState, retryable: boolean, operationId: string, idempotencyKey: string, attemptCount: number, outcome: AttemptOutcome, failureReason: RepostFailureReason | null): RepostError;
|
|
19
|
+
export declare function cancelled(operationId: string, idempotencyKey: string | null, attemptCount: number, committed: boolean, outcome?: AttemptOutcome | null): RepostTransportError;
|
|
20
|
+
export declare function closed(operationId: string | null, idempotencyKey: string | null, attemptCount: number, committed: boolean, outcome?: AttemptOutcome | null): RepostTransportError;
|
|
21
|
+
export declare function deadlineError(operationId: string, idempotencyKey: string | null, attemptCount: number, committed: boolean, outcome?: AttemptOutcome | null): RepostTransportError;
|
|
22
|
+
export declare function responseDetails(outcome: AttemptOutcome | null): Pick<RepostErrorDetails, "httpStatus" | "compressedBytes" | "decompressedBytes" | "truncated" | "responseHeaderFields" | "responseHeaderBytes">;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ResolvedClientOptions } from "./config";
|
|
2
|
+
import type { EventDescriptor, SchemaDescriptor, SendOperation, SendResult } from "./types";
|
|
3
|
+
import { RuntimeState } from "./runtime-state";
|
|
4
|
+
export interface SendInput {
|
|
5
|
+
readonly customerId: string;
|
|
6
|
+
readonly data: unknown;
|
|
7
|
+
readonly idempotencyKey?: string;
|
|
8
|
+
readonly signal?: AbortSignal;
|
|
9
|
+
}
|
|
10
|
+
export interface SendOperationRuntime {
|
|
11
|
+
send(event: EventDescriptor, input: SendInput): SendOperation<SendResult>;
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createSendOperation(config: ResolvedClientOptions, schema: SchemaDescriptor, state: RuntimeState): SendOperationRuntime;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const PORTABLE_OPERATION_WORKSPACE_BYTES = 2359296;
|
|
2
|
+
export interface RuntimeDiagnostics {
|
|
3
|
+
readonly inFlightOperations: number;
|
|
4
|
+
readonly bufferedBytes: number;
|
|
5
|
+
readonly concurrencyOverloadRejections: number;
|
|
6
|
+
readonly requestByteOverloadRejections: number;
|
|
7
|
+
readonly responseByteOverloadRejections: number;
|
|
8
|
+
readonly responseHeaderLimitFailures: number;
|
|
9
|
+
readonly executorOverloadRejections: number;
|
|
10
|
+
readonly schedulerOverloadRejections: number;
|
|
11
|
+
readonly responseCloseFailures: number;
|
|
12
|
+
readonly droppedObserverEvents: number;
|
|
13
|
+
readonly observerFailures: number;
|
|
14
|
+
readonly closed: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class RuntimeState {
|
|
17
|
+
private readonly maxInFlightOperations;
|
|
18
|
+
private readonly maxBufferedBytes;
|
|
19
|
+
private inFlightOperations;
|
|
20
|
+
private bufferedBytes;
|
|
21
|
+
private concurrencyOverloadRejections;
|
|
22
|
+
private requestByteOverloadRejections;
|
|
23
|
+
private responseHeaderLimitFailures;
|
|
24
|
+
private responseCloseFailures;
|
|
25
|
+
private droppedObserverEvents;
|
|
26
|
+
private observerFailures;
|
|
27
|
+
private closing;
|
|
28
|
+
private closed;
|
|
29
|
+
private readonly active;
|
|
30
|
+
constructor(maxInFlightOperations: number, maxBufferedBytes: number);
|
|
31
|
+
admit(): Admission | null;
|
|
32
|
+
isClosing(): boolean;
|
|
33
|
+
close(): void;
|
|
34
|
+
diagnostics(): RuntimeDiagnostics;
|
|
35
|
+
observerDropped(): void;
|
|
36
|
+
observerFailed(): void;
|
|
37
|
+
responseHeaderLimitFailed(): void;
|
|
38
|
+
responseCloseFailed(): void;
|
|
39
|
+
seedDiagnosticCounter(counter: "concurrencyOverloadRejections", value: number): void;
|
|
40
|
+
}
|
|
41
|
+
export interface Admission {
|
|
42
|
+
readonly signal: AbortSignal;
|
|
43
|
+
retainSerializedRequest(bodyBytes: number): void;
|
|
44
|
+
release(): void;
|
|
45
|
+
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import type { ModelDescriptor } from "./types";
|
|
1
|
+
import type { EnumDescriptors, Generators, ModelDescriptor } from "./types";
|
|
2
|
+
/** Fill the runtime's injectable clock and ID generators with real defaults. */
|
|
3
|
+
export declare function resolveGenerators(generators?: Generators): Required<Generators>;
|
|
2
4
|
/**
|
|
3
5
|
* Serialize a send input into its wire payload, driven by the generated model
|
|
4
6
|
* descriptors: fields are emitted in declaration order under their `@map`'d
|
|
5
7
|
* wire names, absent fields with an `@default` are injected (literals
|
|
6
8
|
* verbatim, `now()`/`uuid()`/`cuid()` generated at send time), absent optional
|
|
7
9
|
* fields are omitted, nested models recurse, and enum members serialize to
|
|
8
|
-
* their (possibly `@map`'d) wire values.
|
|
10
|
+
* their (possibly `@map`'d) wire values. `generators` overrides the clock and
|
|
11
|
+
* id sources for deterministic tests (the conformance suite's seam).
|
|
9
12
|
*/
|
|
10
|
-
export declare function serializeModel(models: Record<string, ModelDescriptor>, modelName: string, data: unknown): Record<string, unknown>;
|
|
13
|
+
export declare function serializeModel(models: Record<string, ModelDescriptor>, modelName: string, data: unknown, generators?: Generators, enums?: EnumDescriptors): Record<string, unknown>;
|
|
14
|
+
export declare function compareUnicodeScalarValues(left: string, right: string): number;
|
|
15
|
+
export declare function validateModelDescriptors(models: Record<string, ModelDescriptor>, enums: EnumDescriptors): void;
|
|
16
|
+
export declare function appendPath(path: string, key: string): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { HttpStatusClass, RepostErrorCode } from "./errors";
|
|
2
|
+
import type { ObserverOutcome } from "./observer";
|
|
3
|
+
export type CapturedTelemetryContext = unknown;
|
|
4
|
+
export interface TelemetryOperationStart {
|
|
5
|
+
readonly startedAtMs: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TelemetryOperationEnd {
|
|
8
|
+
readonly outcome: ObserverOutcome;
|
|
9
|
+
readonly errorCode: RepostErrorCode | null;
|
|
10
|
+
readonly durationMs: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TelemetryAttemptStart {
|
|
13
|
+
readonly startedAtMs: number;
|
|
14
|
+
readonly attemptNumber: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TelemetryAttemptEnd {
|
|
17
|
+
readonly httpStatusClass: HttpStatusClass | null;
|
|
18
|
+
readonly outcome: ObserverOutcome;
|
|
19
|
+
readonly errorCode: RepostErrorCode | null;
|
|
20
|
+
readonly durationMs: number;
|
|
21
|
+
}
|
|
22
|
+
export interface TelemetryAttempt {
|
|
23
|
+
propagationHeaders(): Record<string, string> | null;
|
|
24
|
+
end(end: TelemetryAttemptEnd): void;
|
|
25
|
+
}
|
|
26
|
+
export interface TelemetryOperation {
|
|
27
|
+
startAttempt(start: TelemetryAttemptStart): TelemetryAttempt;
|
|
28
|
+
end(end: TelemetryOperationEnd): void;
|
|
29
|
+
}
|
|
30
|
+
export interface RepostTelemetry {
|
|
31
|
+
captureContext(): CapturedTelemetryContext;
|
|
32
|
+
startOperation(parent: CapturedTelemetryContext, start: TelemetryOperationStart): TelemetryOperation;
|
|
33
|
+
}
|
|
34
|
+
export declare class TelemetryInvoker {
|
|
35
|
+
private readonly telemetry;
|
|
36
|
+
constructor(telemetry: RepostTelemetry | undefined);
|
|
37
|
+
capture(): CapturedTelemetryContext | null;
|
|
38
|
+
startOperation(parent: CapturedTelemetryContext | null, start: TelemetryOperationStart): TelemetryOperation | null;
|
|
39
|
+
startAttempt(operation: TelemetryOperation | null, start: TelemetryAttemptStart): TelemetryAttempt | null;
|
|
40
|
+
headers(attempt: TelemetryAttempt | null): readonly (readonly [string, string])[];
|
|
41
|
+
endAttempt(attempt: TelemetryAttempt | null, end: TelemetryAttemptEnd): void;
|
|
42
|
+
endOperation(operation: TelemetryOperation | null, end: TelemetryOperationEnd): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Generators, RetryEntropy } from "../types";
|
|
2
|
+
export declare const TestDefaultValueGenerators: {
|
|
3
|
+
fixed(nowIso: string, uuid: string, cuid: string): Generators;
|
|
4
|
+
sequence(entries: Array<Partial<{
|
|
5
|
+
now: string;
|
|
6
|
+
uuid: string;
|
|
7
|
+
cuid: string;
|
|
8
|
+
}>>): Generators;
|
|
9
|
+
failing(error?: Error): Generators;
|
|
10
|
+
};
|
|
11
|
+
export declare const TestIdempotencyKeyGenerator: {
|
|
12
|
+
fixed(key: string): () => string;
|
|
13
|
+
sequence(...keys: string[]): () => string;
|
|
14
|
+
failing(error?: Error): () => string;
|
|
15
|
+
};
|
|
16
|
+
export declare const DeterministicRetryEntropy: {
|
|
17
|
+
zero(): RetryEntropy;
|
|
18
|
+
sequence(...values: number[]): RetryEntropy;
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RepostClientOptions } from "../types";
|
|
2
|
+
import { ManualClock, manualScheduler } from "./manual-clock";
|
|
3
|
+
import { DeterministicRetryEntropy, TestDefaultValueGenerators, TestIdempotencyKeyGenerator } from "./deterministic";
|
|
4
|
+
import { RecordingObserver } from "./recording-observer";
|
|
5
|
+
import { ScriptedStubTransport, type ControlledResponse, type RecordedRequest } from "./stub-transport";
|
|
6
|
+
export { ManualClock, manualScheduler };
|
|
7
|
+
export { DeterministicRetryEntropy, TestDefaultValueGenerators, TestIdempotencyKeyGenerator };
|
|
8
|
+
export { RecordingObserver };
|
|
9
|
+
export { ScriptedStubTransport };
|
|
10
|
+
export type { ControlledResponse, RecordedRequest };
|
|
11
|
+
export declare function deterministicClientOptions(overrides?: Partial<RepostClientOptions>): {
|
|
12
|
+
options: RepostClientOptions;
|
|
13
|
+
transport: ScriptedStubTransport;
|
|
14
|
+
observer: RecordingObserver;
|
|
15
|
+
clock: ManualClock;
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Scheduler } from "../types";
|
|
2
|
+
export declare class ManualClock {
|
|
3
|
+
private current;
|
|
4
|
+
private sequence;
|
|
5
|
+
private readonly timers;
|
|
6
|
+
readonly monotonic: () => number;
|
|
7
|
+
readonly wall: () => number;
|
|
8
|
+
get nowMs(): number;
|
|
9
|
+
advance(ms: number): Promise<void>;
|
|
10
|
+
schedule(ms: number, signal?: AbortSignal): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function manualScheduler(clock: ManualClock): Scheduler;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FlushableObserver, type ObserverEvent } from "../observer";
|
|
2
|
+
export declare class RecordingObserver {
|
|
3
|
+
private readonly recorded;
|
|
4
|
+
private readonly waiters;
|
|
5
|
+
readonly callback: FlushableObserver;
|
|
6
|
+
get events(): readonly ObserverEvent[];
|
|
7
|
+
awaitNext(options?: {
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
}): Promise<ObserverEvent>;
|
|
10
|
+
awaitQuiescence(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { AttemptOutcome, AttemptRequest, Transport } from "../types";
|
|
2
|
+
import type { RepostFailureReason } from "../errors";
|
|
3
|
+
type FailureCode = "DNS" | "CONNECT" | "PROXY" | "TLS" | "IO" | "ATTEMPT_TIMEOUT";
|
|
4
|
+
export interface RecordedRequest {
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
7
|
+
readonly bodyText: string;
|
|
8
|
+
readonly bodyBytes: Uint8Array;
|
|
9
|
+
readonly attemptNumber: number;
|
|
10
|
+
readonly idempotencyKey: string;
|
|
11
|
+
readonly attemptTimeoutMs: number;
|
|
12
|
+
readonly captureSequence: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ControlledResponse {
|
|
15
|
+
respond(status: number, body: string, headers?: Record<string, string>): void;
|
|
16
|
+
fail(code: FailureCode, options?: {
|
|
17
|
+
reason?: RepostFailureReason;
|
|
18
|
+
committed?: boolean;
|
|
19
|
+
}): void;
|
|
20
|
+
readonly isDone: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class ScriptedStubTransport implements Transport {
|
|
23
|
+
private readonly script;
|
|
24
|
+
private readonly captured;
|
|
25
|
+
private sequence;
|
|
26
|
+
get requests(): readonly RecordedRequest[];
|
|
27
|
+
enqueueResponse(status: number, body: string, headers?: Record<string, string>): this;
|
|
28
|
+
enqueueFailure(code: FailureCode, options?: {
|
|
29
|
+
reason?: RepostFailureReason;
|
|
30
|
+
committed?: boolean;
|
|
31
|
+
}): this;
|
|
32
|
+
enqueuePending(): ControlledResponse;
|
|
33
|
+
send(request: AttemptRequest): Promise<AttemptOutcome>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Socket } from "node:net";
|
|
2
|
+
import { type TLSSocket } from "node:tls";
|
|
3
|
+
export interface ProxyOptions {
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly credentialsProvider?: () => {
|
|
6
|
+
username: string;
|
|
7
|
+
password: string;
|
|
8
|
+
} | Promise<{
|
|
9
|
+
username: string;
|
|
10
|
+
password: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export interface ProxyTarget {
|
|
14
|
+
readonly hostname: string;
|
|
15
|
+
readonly port: string;
|
|
16
|
+
readonly protocol: string;
|
|
17
|
+
readonly servername?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ProxyTlsOptions {
|
|
20
|
+
readonly caCertificates?: readonly string[];
|
|
21
|
+
readonly minVersion?: "TLSv1.2" | "TLSv1.3";
|
|
22
|
+
readonly maxVersion?: "TLSv1.2" | "TLSv1.3";
|
|
23
|
+
readonly ciphers?: readonly string[];
|
|
24
|
+
readonly clientCertificate?: {
|
|
25
|
+
readonly certificate: string;
|
|
26
|
+
readonly key: string;
|
|
27
|
+
readonly passphrase?: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare function connectThroughProxy(proxy: ProxyOptions, target: ProxyTarget, tls: ProxyTlsOptions | undefined, allowH2: boolean, timeoutMs: number): Promise<Socket | TLSSocket>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AttemptOutcome } from "../types";
|
|
2
|
+
type FailureOutcome = Extract<AttemptOutcome, {
|
|
3
|
+
kind: "failure";
|
|
4
|
+
}>;
|
|
5
|
+
export declare function classifyNetworkFailure(error: unknown, committed?: boolean): FailureOutcome | null;
|
|
6
|
+
export declare function errorCode(error: unknown): string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AttemptRequest } from "../types";
|
|
2
|
+
export interface FramedRequest {
|
|
3
|
+
readonly origin: string;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly headers: string[];
|
|
6
|
+
}
|
|
7
|
+
/** Builds the exact ordered fields used by the Node H1/H2 dispatcher. */
|
|
8
|
+
export declare function frameRequest(request: AttemptRequest): FramedRequest;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AttemptOutcome } from "../types";
|
|
2
|
+
type ResponseOutcome = Extract<AttemptOutcome, {
|
|
3
|
+
kind: "response";
|
|
4
|
+
}>;
|
|
5
|
+
export declare function readResponse(status: number, rawHeaders: readonly Uint8Array[], chunks: readonly Uint8Array[], compressedBytes: number, transportTruncated: boolean, compressedLimit?: number): Promise<ResponseOutcome>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Socket } from "node:net";
|
|
2
|
+
import { type TLSSocket } from "node:tls";
|
|
3
|
+
import { type ProxyOptions, type ProxyTlsOptions } from "./connect-proxy";
|
|
4
|
+
export interface OriginSocketOptions {
|
|
5
|
+
readonly allowH2: boolean;
|
|
6
|
+
readonly connectTimeout: number;
|
|
7
|
+
readonly tls?: ProxyTlsOptions;
|
|
8
|
+
readonly proxy?: ProxyOptions;
|
|
9
|
+
readonly dnsResolver?: (host: string) => Promise<{
|
|
10
|
+
address: string;
|
|
11
|
+
family: 4 | 6;
|
|
12
|
+
}[]>;
|
|
13
|
+
}
|
|
14
|
+
export declare function openOriginSocket(origin: string, options: OriginSocketOptions): Promise<Socket | TLSSocket>;
|