@neon/sdk 1.4.1 → 2.0.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 +257 -30
- package/dist/client/client/client.gen.js +1 -3
- package/dist/client/client/client.gen.js.map +1 -1
- package/dist/client/client/utils.gen.js +1 -3
- package/dist/client/client/utils.gen.js.map +1 -1
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +2 -2
- package/dist/client/raw.gen.d.ts +146 -16
- package/dist/client/raw.gen.d.ts.map +1 -1
- package/dist/client/raw.gen.js +8 -3
- package/dist/client/raw.gen.js.map +1 -1
- package/dist/client/sdk.gen.d.ts +137 -78
- package/dist/client/sdk.gen.d.ts.map +1 -1
- package/dist/client/sdk.gen.js +258 -96
- package/dist/client/sdk.gen.js.map +1 -1
- package/dist/client/types.gen.d.ts +1397 -315
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +2 -2
- package/dist/neon/client.d.ts +2 -0
- package/dist/neon/client.d.ts.map +1 -1
- package/dist/neon/client.js +2 -0
- package/dist/neon/client.js.map +1 -1
- package/dist/neon/config.d.ts +13 -0
- package/dist/neon/config.d.ts.map +1 -1
- package/dist/neon/config.js +2 -0
- package/dist/neon/config.js.map +1 -1
- package/dist/neon/context.d.ts +26 -6
- package/dist/neon/context.d.ts.map +1 -1
- package/dist/neon/context.js +60 -10
- package/dist/neon/context.js.map +1 -1
- package/dist/neon/coverage.d.ts.map +1 -1
- package/dist/neon/coverage.js +12 -2
- package/dist/neon/coverage.js.map +1 -1
- package/dist/neon/deadline.d.ts +81 -0
- package/dist/neon/deadline.d.ts.map +1 -0
- package/dist/neon/deadline.js +143 -0
- package/dist/neon/deadline.js.map +1 -0
- package/dist/neon/errors.d.ts +22 -3
- package/dist/neon/errors.d.ts.map +1 -1
- package/dist/neon/errors.js +22 -2
- package/dist/neon/errors.js.map +1 -1
- package/dist/neon/paginate.d.ts +6 -1
- package/dist/neon/paginate.d.ts.map +1 -1
- package/dist/neon/paginate.js +63 -25
- package/dist/neon/paginate.js.map +1 -1
- package/dist/neon/raw-wrap.d.ts.map +1 -1
- package/dist/neon/raw-wrap.js +17 -2
- package/dist/neon/raw-wrap.js.map +1 -1
- package/dist/neon/resources/account.d.ts.map +1 -1
- package/dist/neon/resources/account.js +18 -12
- package/dist/neon/resources/account.js.map +1 -1
- package/dist/neon/resources/ai-gateway.js +3 -2
- package/dist/neon/resources/ai-gateway.js.map +1 -1
- package/dist/neon/resources/auth.d.ts.map +1 -1
- package/dist/neon/resources/auth.js +42 -28
- package/dist/neon/resources/auth.js.map +1 -1
- package/dist/neon/resources/branches.d.ts +1 -8
- package/dist/neon/resources/branches.d.ts.map +1 -1
- package/dist/neon/resources/branches.js +32 -32
- package/dist/neon/resources/branches.js.map +1 -1
- package/dist/neon/resources/bucket-objects.d.ts.map +1 -1
- package/dist/neon/resources/bucket-objects.js +15 -10
- package/dist/neon/resources/bucket-objects.js.map +1 -1
- package/dist/neon/resources/buckets.d.ts.map +1 -1
- package/dist/neon/resources/buckets.js +9 -6
- package/dist/neon/resources/buckets.js.map +1 -1
- package/dist/neon/resources/consumption.d.ts +4 -4
- package/dist/neon/resources/consumption.d.ts.map +1 -1
- package/dist/neon/resources/consumption.js +6 -6
- package/dist/neon/resources/consumption.js.map +1 -1
- package/dist/neon/resources/credentials.d.ts.map +1 -1
- package/dist/neon/resources/credentials.js +9 -6
- package/dist/neon/resources/credentials.js.map +1 -1
- package/dist/neon/resources/dataapi.d.ts.map +1 -1
- package/dist/neon/resources/dataapi.js +12 -8
- package/dist/neon/resources/dataapi.js.map +1 -1
- package/dist/neon/resources/databases.d.ts.map +1 -1
- package/dist/neon/resources/databases.js +15 -10
- package/dist/neon/resources/databases.js.map +1 -1
- package/dist/neon/resources/endpoints.d.ts.map +1 -1
- package/dist/neon/resources/endpoints.js +27 -18
- package/dist/neon/resources/endpoints.js.map +1 -1
- package/dist/neon/resources/functions.d.ts +1 -1
- package/dist/neon/resources/functions.d.ts.map +1 -1
- package/dist/neon/resources/functions.js +14 -10
- package/dist/neon/resources/functions.js.map +1 -1
- package/dist/neon/resources/logs.d.ts +76 -0
- package/dist/neon/resources/logs.d.ts.map +1 -0
- package/dist/neon/resources/logs.js +90 -0
- package/dist/neon/resources/logs.js.map +1 -0
- package/dist/neon/resources/operations.d.ts +12 -3
- package/dist/neon/resources/operations.d.ts.map +1 -1
- package/dist/neon/resources/operations.js +5 -4
- package/dist/neon/resources/operations.js.map +1 -1
- package/dist/neon/resources/postgres.d.ts.map +1 -1
- package/dist/neon/resources/postgres.js +10 -1
- package/dist/neon/resources/postgres.js.map +1 -1
- package/dist/neon/resources/projects.d.ts +62 -5
- package/dist/neon/resources/projects.d.ts.map +1 -1
- package/dist/neon/resources/projects.js +106 -29
- package/dist/neon/resources/projects.js.map +1 -1
- package/dist/neon/resources/roles.d.ts.map +1 -1
- package/dist/neon/resources/roles.js +18 -12
- package/dist/neon/resources/roles.js.map +1 -1
- package/dist/neon/resources/snapshots.d.ts +10 -1
- package/dist/neon/resources/snapshots.d.ts.map +1 -1
- package/dist/neon/resources/snapshots.js +37 -19
- package/dist/neon/resources/snapshots.js.map +1 -1
- package/dist/neon/resources/storage.js +3 -2
- package/dist/neon/resources/storage.js.map +1 -1
- package/dist/neon/retry.d.ts +30 -8
- package/dist/neon/retry.d.ts.map +1 -1
- package/dist/neon/retry.js +59 -20
- package/dist/neon/retry.js.map +1 -1
- package/dist/neon/wait.d.ts +7 -1
- package/dist/neon/wait.d.ts.map +1 -1
- package/dist/neon/wait.js +53 -34
- package/dist/neon/wait.js.map +1 -1
- package/dist/raw.d.ts +3 -3
- package/dist/raw.js +8 -3
- package/package.json +2 -1
package/dist/neon/context.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { toNeonError } from "./errors.js";
|
|
2
|
+
import { cancelled, createDeadline, resolveTimeoutMs, runBounded } from "./deadline.js";
|
|
2
3
|
import { err, finalize, ok } from "./result.js";
|
|
3
4
|
import { withRetries } from "./retry.js";
|
|
4
5
|
import { hasOperations, waitForOperations } from "./wait.js";
|
|
5
6
|
//#region src/neon/context.ts
|
|
6
7
|
/**
|
|
7
|
-
* Shared execution core: runs a raw client call with retries, maps
|
|
8
|
-
* ergonomic resource shape, optionally waits for provisioning
|
|
9
|
-
* resolved `throwOnError` policy. Returns the bare value
|
|
8
|
+
* Shared execution core: runs a raw client call under a deadline and with retries, maps
|
|
9
|
+
* its envelope to the ergonomic resource shape, optionally waits for provisioning
|
|
10
|
+
* operations, and applies the resolved `throwOnError` policy. Returns the bare value
|
|
11
|
+
* (throwing) or a {@link NeonResult}.
|
|
10
12
|
*/
|
|
11
13
|
var RequestContext = class {
|
|
12
14
|
#config;
|
|
@@ -19,6 +21,17 @@ var RequestContext = class {
|
|
|
19
21
|
get defaults() {
|
|
20
22
|
return this.#config;
|
|
21
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* The deadline for one call: the per-call timeout if given, else the client's.
|
|
26
|
+
*
|
|
27
|
+
* A per-call value is validated the same way the client's was. Skipping that left
|
|
28
|
+
* `requestTimeoutMs: NaN` meaning *unbounded* and a value past `setTimeout`'s range
|
|
29
|
+
* meaning *1ms*, both silently.
|
|
30
|
+
*/
|
|
31
|
+
deadlineFor(opts) {
|
|
32
|
+
const timeoutMs = opts?.requestTimeoutMs === void 0 ? this.#config.requestTimeoutMs : resolveTimeoutMs(opts.requestTimeoutMs);
|
|
33
|
+
return createDeadline(timeoutMs, opts?.signal);
|
|
34
|
+
}
|
|
22
35
|
/** Run a raw call and map its body; applies the resolved `throwOnError` policy. */
|
|
23
36
|
async run(opts, exec, map) {
|
|
24
37
|
const shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;
|
|
@@ -27,9 +40,9 @@ var RequestContext = class {
|
|
|
27
40
|
/** Like {@link run} but for endpoints that may return an empty (204) body. */
|
|
28
41
|
async runVoid(opts, exec) {
|
|
29
42
|
const shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
const readiness = await this.#maybeWait(opts,
|
|
43
|
+
const requested = await this.#request(opts, exec);
|
|
44
|
+
if (!requested.ok) return finalize(err(requested.error), shouldThrow);
|
|
45
|
+
const readiness = await this.#maybeWait(opts, requested.data);
|
|
33
46
|
if (readiness?.error) return finalize(err(readiness.error), shouldThrow);
|
|
34
47
|
return finalize(ok(void 0), shouldThrow);
|
|
35
48
|
}
|
|
@@ -38,11 +51,48 @@ var RequestContext = class {
|
|
|
38
51
|
* throw). Used by `run` and by workflows that post-process the result.
|
|
39
52
|
*/
|
|
40
53
|
async execute(opts, exec, map) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
|
|
54
|
+
const requested = await this.#request(opts, exec);
|
|
55
|
+
if (!requested.ok) return err(requested.error);
|
|
56
|
+
if (requested.data === void 0) return err(toNeonError(void 0, requested.response));
|
|
57
|
+
const readiness = await this.#maybeWait(opts, requested.data);
|
|
44
58
|
if (readiness?.error) return err(readiness.error);
|
|
45
|
-
return ok(map(
|
|
59
|
+
return ok(map(requested.data));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The request phase: bounded by the call's deadline, retried, and never allowed to
|
|
63
|
+
* reject. The deadline is disposed before readiness polling begins, so a request
|
|
64
|
+
* budget cannot cut short the separate `wait` budget.
|
|
65
|
+
*/
|
|
66
|
+
async #request(opts, exec) {
|
|
67
|
+
const deadline = this.deadlineFor(opts);
|
|
68
|
+
try {
|
|
69
|
+
const raw = await runBounded(deadline, () => withRetries(() => exec(this.#config.client, deadline.signal), this.#config.retries, deadline));
|
|
70
|
+
const cancellation = cancelled(deadline);
|
|
71
|
+
if (cancellation) return {
|
|
72
|
+
ok: false,
|
|
73
|
+
error: cancellation
|
|
74
|
+
};
|
|
75
|
+
if (raw === void 0) return {
|
|
76
|
+
ok: false,
|
|
77
|
+
error: toNeonError(void 0, void 0)
|
|
78
|
+
};
|
|
79
|
+
if (raw.error !== void 0) return {
|
|
80
|
+
ok: false,
|
|
81
|
+
error: toNeonError(raw.error, raw.response)
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
ok: true,
|
|
85
|
+
data: raw.data,
|
|
86
|
+
response: raw.response
|
|
87
|
+
};
|
|
88
|
+
} catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
error: cancelled(deadline) ?? toNeonError(error, void 0)
|
|
92
|
+
};
|
|
93
|
+
} finally {
|
|
94
|
+
deadline.dispose();
|
|
95
|
+
}
|
|
46
96
|
}
|
|
47
97
|
/** Poll provisioning operations when `waitForReadiness` is on and the body has any. */
|
|
48
98
|
async #maybeWait(opts, data) {
|
package/dist/neon/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["#config","#maybeWait"],"sources":["../../src/neon/context.ts"],"sourcesContent":["import type { Client } from \"../client/client/index.js\";\nimport { toNeonError } from \"./errors.js\";\nimport { err, finalize, type NeonResult, ok } from \"./result.js\";\nimport { withRetries } from \"./retry.js\";\nimport {\n\thasOperations,\n\ttype WaitForOptions,\n\twaitForOperations,\n} from \"./wait.js\";\n\n/** Fully-resolved runtime configuration shared by every resource namespace. */\nexport interface ResolvedConfig {\n\tclient: Client;\n\tthrowOnError: boolean;\n\tretries: number;\n\twaitForReadiness: boolean;\n\twaitOptions: WaitForOptions;\n\torgId?: string;\n}\n\n/** Per-call overrides accepted by every ergonomic method. */\nexport interface CallOptions<Throw extends boolean = boolean> {\n\t/** Override the client's `throwOnError` for this call. */\n\tthrowOnError?: Throw;\n\t/** Override the client's `waitForReadiness` for this call (mutations only). */\n\twaitForReadiness?: boolean;\n\tsignal?: AbortSignal;\n}\n\ninterface RawResult<D> {\n\tdata?: D | undefined;\n\terror?: unknown;\n\tresponse?: Response | undefined;\n}\n\n/**\n * Shared execution core: runs a raw client call with retries, maps its envelope to the
|
|
1
|
+
{"version":3,"file":"context.js","names":["#config","#request","#maybeWait"],"sources":["../../src/neon/context.ts"],"sourcesContent":["import type { Client } from \"../client/client/index.js\";\nimport {\n\tcancelled,\n\tcreateDeadline,\n\ttype Deadline,\n\tresolveTimeoutMs,\n\trunBounded,\n} from \"./deadline.js\";\nimport { type NeonError, toNeonError } from \"./errors.js\";\nimport { err, finalize, type NeonResult, ok } from \"./result.js\";\nimport { withRetries } from \"./retry.js\";\nimport {\n\thasOperations,\n\ttype WaitForOptions,\n\twaitForOperations,\n} from \"./wait.js\";\n\n/** Fully-resolved runtime configuration shared by every resource namespace. */\nexport interface ResolvedConfig {\n\tclient: Client;\n\tthrowOnError: boolean;\n\tretries: number;\n\t/** `Infinity` when calls are unbounded, which is the default. */\n\trequestTimeoutMs: number;\n\twaitForReadiness: boolean;\n\twaitOptions: WaitForOptions;\n\torgId?: string;\n}\n\n/** Per-call overrides accepted by every ergonomic method. */\nexport interface CallOptions<Throw extends boolean = boolean> {\n\t/** Override the client's `throwOnError` for this call. */\n\tthrowOnError?: Throw;\n\t/** Override the client's `waitForReadiness` for this call (mutations only). */\n\twaitForReadiness?: boolean;\n\t/**\n\t * Deadline for this request and its retries. `Infinity` opts out of a client-wide\n\t * value; readiness polling keeps its own `wait` budget either way.\n\t */\n\trequestTimeoutMs?: number;\n\t/** Cancel the call. Surfaces as a `NeonAbortError` (`kind: \"aborted\"`). */\n\tsignal?: AbortSignal;\n}\n\ninterface RawResult<D> {\n\tdata?: D | undefined;\n\terror?: unknown;\n\tresponse?: Response | undefined;\n}\n\n/** Every generated call the ergonomic layer makes, given the client and the call's signal. */\ntype Exec<D> = (\n\tclient: Client,\n\tsignal: AbortSignal | undefined,\n) => Promise<RawResult<D>>;\n\n/** The request phase's outcome, before readiness polling is considered. */\ntype Requested<D> =\n\t| { ok: true; data: D | undefined; response: Response | undefined }\n\t| { ok: false; error: NeonError };\n\n/**\n * Shared execution core: runs a raw client call under a deadline and with retries, maps\n * its envelope to the ergonomic resource shape, optionally waits for provisioning\n * operations, and applies the resolved `throwOnError` policy. Returns the bare value\n * (throwing) or a {@link NeonResult}.\n */\nexport class RequestContext {\n\treadonly #config: ResolvedConfig;\n\n\tconstructor(config: ResolvedConfig) {\n\t\tthis.#config = config;\n\t}\n\n\tget client(): Client {\n\t\treturn this.#config.client;\n\t}\n\n\tget defaults(): ResolvedConfig {\n\t\treturn this.#config;\n\t}\n\n\t/**\n\t * The deadline for one call: the per-call timeout if given, else the client's.\n\t *\n\t * A per-call value is validated the same way the client's was. Skipping that left\n\t * `requestTimeoutMs: NaN` meaning *unbounded* and a value past `setTimeout`'s range\n\t * meaning *1ms*, both silently.\n\t */\n\tdeadlineFor(opts: CallOptions | undefined): Deadline {\n\t\tconst timeoutMs =\n\t\t\topts?.requestTimeoutMs === undefined\n\t\t\t\t? this.#config.requestTimeoutMs\n\t\t\t\t: resolveTimeoutMs(opts.requestTimeoutMs);\n\t\treturn createDeadline(timeoutMs, opts?.signal);\n\t}\n\n\t/** Run a raw call and map its body; applies the resolved `throwOnError` policy. */\n\tasync run<D, T>(\n\t\topts: CallOptions | undefined,\n\t\texec: Exec<D>,\n\t\tmap: (data: D) => T,\n\t): Promise<T | NeonResult<T>> {\n\t\tconst shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;\n\t\treturn finalize(await this.execute(opts, exec, map), shouldThrow);\n\t}\n\n\t/** Like {@link run} but for endpoints that may return an empty (204) body. */\n\tasync runVoid<D>(\n\t\topts: CallOptions | undefined,\n\t\texec: Exec<D>,\n\t): Promise<void | NeonResult<void>> {\n\t\tconst shouldThrow = opts?.throwOnError ?? this.#config.throwOnError;\n\t\tconst requested = await this.#request(opts, exec);\n\t\tif (!requested.ok)\n\t\t\treturn finalize(err<void>(requested.error), shouldThrow);\n\t\tconst readiness = await this.#maybeWait(opts, requested.data);\n\t\tif (readiness?.error) {\n\t\t\treturn finalize(err<void>(readiness.error), shouldThrow);\n\t\t}\n\t\treturn finalize(ok(undefined), shouldThrow);\n\t}\n\n\t/**\n\t * Run a raw call and map its body, returning the {@link NeonResult} envelope (no\n\t * throw). Used by `run` and by workflows that post-process the result.\n\t */\n\tasync execute<D, T>(\n\t\topts: CallOptions | undefined,\n\t\texec: Exec<D>,\n\t\tmap: (data: D) => T,\n\t): Promise<NeonResult<T>> {\n\t\tconst requested = await this.#request(opts, exec);\n\t\tif (!requested.ok) return err(requested.error);\n\t\tif (requested.data === undefined) {\n\t\t\treturn err(toNeonError(undefined, requested.response));\n\t\t}\n\t\tconst readiness = await this.#maybeWait(opts, requested.data);\n\t\tif (readiness?.error) return err(readiness.error);\n\t\treturn ok(map(requested.data));\n\t}\n\n\t/**\n\t * The request phase: bounded by the call's deadline, retried, and never allowed to\n\t * reject. The deadline is disposed before readiness polling begins, so a request\n\t * budget cannot cut short the separate `wait` budget.\n\t */\n\tasync #request<D>(\n\t\topts: CallOptions | undefined,\n\t\texec: Exec<D>,\n\t): Promise<Requested<D>> {\n\t\tconst deadline = this.deadlineFor(opts);\n\t\ttry {\n\t\t\tconst raw = await runBounded(deadline, () =>\n\t\t\t\twithRetries(\n\t\t\t\t\t() => exec(this.#config.client, deadline.signal),\n\t\t\t\t\tthis.#config.retries,\n\t\t\t\t\tdeadline,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst cancellation = cancelled(deadline);\n\t\t\tif (cancellation) return { ok: false, error: cancellation };\n\t\t\tif (raw === undefined) {\n\t\t\t\treturn { ok: false, error: toNeonError(undefined, undefined) };\n\t\t\t}\n\t\t\tif (raw.error !== undefined) {\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\terror: toNeonError(raw.error, raw.response),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { ok: true, data: raw.data, response: raw.response };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: cancelled(deadline) ?? toNeonError(error, undefined),\n\t\t\t};\n\t\t} finally {\n\t\t\tdeadline.dispose();\n\t\t}\n\t}\n\n\t/** Poll provisioning operations when `waitForReadiness` is on and the body has any. */\n\tasync #maybeWait(\n\t\topts: CallOptions | undefined,\n\t\tdata: unknown,\n\t): Promise<NeonResult<void> | undefined> {\n\t\tconst wait = opts?.waitForReadiness ?? this.#config.waitForReadiness;\n\t\tif (!wait || !hasOperations(data)) return undefined;\n\t\treturn waitForOperations(this.#config.client, data.operations, {\n\t\t\t...this.#config.waitOptions,\n\t\t\tsignal: opts?.signal ?? this.#config.waitOptions.signal,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAmEA,IAAa,iBAAb,MAA4B;CAC3B;CAEA,YAAY,QAAwB;EACnC,KAAKA,UAAU;CAChB;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAKA,QAAQ;CACrB;CAEA,IAAI,WAA2B;EAC9B,OAAO,KAAKA;CACb;;;;;;;;CASA,YAAY,MAAyC;EACpD,MAAM,YACL,MAAM,qBAAqB,KAAA,IACxB,KAAKA,QAAQ,mBACb,iBAAiB,KAAK,gBAAgB;EAC1C,OAAO,eAAe,WAAW,MAAM,MAAM;CAC9C;;CAGA,MAAM,IACL,MACA,MACA,KAC6B;EAC7B,MAAM,cAAc,MAAM,gBAAgB,KAAKA,QAAQ;EACvD,OAAO,SAAS,MAAM,KAAK,QAAQ,MAAM,MAAM,GAAG,GAAG,WAAW;CACjE;;CAGA,MAAM,QACL,MACA,MACmC;EACnC,MAAM,cAAc,MAAM,gBAAgB,KAAKA,QAAQ;EACvD,MAAM,YAAY,MAAM,KAAKC,SAAS,MAAM,IAAI;EAChD,IAAI,CAAC,UAAU,IACd,OAAO,SAAS,IAAU,UAAU,KAAK,GAAG,WAAW;EACxD,MAAM,YAAY,MAAM,KAAKC,WAAW,MAAM,UAAU,IAAI;EAC5D,IAAI,WAAW,OACd,OAAO,SAAS,IAAU,UAAU,KAAK,GAAG,WAAW;EAExD,OAAO,SAAS,GAAG,KAAA,CAAS,GAAG,WAAW;CAC3C;;;;;CAMA,MAAM,QACL,MACA,MACA,KACyB;EACzB,MAAM,YAAY,MAAM,KAAKD,SAAS,MAAM,IAAI;EAChD,IAAI,CAAC,UAAU,IAAI,OAAO,IAAI,UAAU,KAAK;EAC7C,IAAI,UAAU,SAAS,KAAA,GACtB,OAAO,IAAI,YAAY,KAAA,GAAW,UAAU,QAAQ,CAAC;EAEtD,MAAM,YAAY,MAAM,KAAKC,WAAW,MAAM,UAAU,IAAI;EAC5D,IAAI,WAAW,OAAO,OAAO,IAAI,UAAU,KAAK;EAChD,OAAO,GAAG,IAAI,UAAU,IAAI,CAAC;CAC9B;;;;;;CAOA,MAAMD,SACL,MACA,MACwB;EACxB,MAAM,WAAW,KAAK,YAAY,IAAI;EACtC,IAAI;GACH,MAAM,MAAM,MAAM,WAAW,gBAC5B,kBACO,KAAK,KAAKD,QAAQ,QAAQ,SAAS,MAAM,GAC/C,KAAKA,QAAQ,SACb,QACD,CACD;GACA,MAAM,eAAe,UAAU,QAAQ;GACvC,IAAI,cAAc,OAAO;IAAE,IAAI;IAAO,OAAO;GAAa;GAC1D,IAAI,QAAQ,KAAA,GACX,OAAO;IAAE,IAAI;IAAO,OAAO,YAAY,KAAA,GAAW,KAAA,CAAS;GAAE;GAE9D,IAAI,IAAI,UAAU,KAAA,GACjB,OAAO;IACN,IAAI;IACJ,OAAO,YAAY,IAAI,OAAO,IAAI,QAAQ;GAC3C;GAED,OAAO;IAAE,IAAI;IAAM,MAAM,IAAI;IAAM,UAAU,IAAI;GAAS;EAC3D,SAAS,OAAO;GACf,OAAO;IACN,IAAI;IACJ,OAAO,UAAU,QAAQ,KAAK,YAAY,OAAO,KAAA,CAAS;GAC3D;EACD,UAAU;GACT,SAAS,QAAQ;EAClB;CACD;;CAGA,MAAME,WACL,MACA,MACwC;EAExC,IAAI,EADS,MAAM,oBAAoB,KAAKF,QAAQ,qBACvC,CAAC,cAAc,IAAI,GAAG,OAAO,KAAA;EAC1C,OAAO,kBAAkB,KAAKA,QAAQ,QAAQ,KAAK,YAAY;GAC9D,GAAG,KAAKA,QAAQ;GAChB,QAAQ,MAAM,UAAU,KAAKA,QAAQ,YAAY;EAClD,CAAC;CACF;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.d.ts","names":[],"sources":["../../src/neon/coverage.ts"],"mappings":";;AAiBA;
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","names":[],"sources":["../../src/neon/coverage.ts"],"mappings":";;AAiBA;AA6HA;;;;;;;;;;;;;;cA7Ha,SAAS;;;;;cA6HT,qBAAqB"}
|
package/dist/neon/coverage.js
CHANGED
|
@@ -27,6 +27,9 @@ const WRAPPED = /* @__PURE__ */ new Set([
|
|
|
27
27
|
"listProjectPermissions",
|
|
28
28
|
"grantPermissionToProject",
|
|
29
29
|
"revokePermissionFromProject",
|
|
30
|
+
"listProjectMembers",
|
|
31
|
+
"setProjectMemberRole",
|
|
32
|
+
"removeProjectMemberRole",
|
|
30
33
|
"listProjectBranches",
|
|
31
34
|
"getProjectBranch",
|
|
32
35
|
"createProjectBranch",
|
|
@@ -34,7 +37,9 @@ const WRAPPED = /* @__PURE__ */ new Set([
|
|
|
34
37
|
"deleteProjectBranch",
|
|
35
38
|
"setDefaultProjectBranch",
|
|
36
39
|
"finalizeRestoreBranch",
|
|
37
|
-
"
|
|
40
|
+
"queryProjectBranchLogs",
|
|
41
|
+
"listProjectBranchLogFields",
|
|
42
|
+
"listProjectBranchLogFieldValues",
|
|
38
43
|
"getNeonAuth",
|
|
39
44
|
"createNeonAuth",
|
|
40
45
|
"disableNeonAuth",
|
|
@@ -228,8 +233,11 @@ const EXPECTED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
228
233
|
"listProjectBranchEndpoints",
|
|
229
234
|
"listProjectBranchRoles",
|
|
230
235
|
"listProjectBranchFunctions",
|
|
236
|
+
"listProjectBranchLogFields",
|
|
237
|
+
"listProjectBranchLogFieldValues",
|
|
231
238
|
"listProjectBranches",
|
|
232
239
|
"listProjectEndpoints",
|
|
240
|
+
"listProjectMembers",
|
|
233
241
|
"listProjectOperations",
|
|
234
242
|
"listProjectPermissions",
|
|
235
243
|
"listProjectVpcEndpoints",
|
|
@@ -237,9 +245,10 @@ const EXPECTED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
237
245
|
"listSharedProjects",
|
|
238
246
|
"listSnapshots",
|
|
239
247
|
"presignProjectBranchBucketObject",
|
|
248
|
+
"queryProjectBranchLogs",
|
|
240
249
|
"recoverProject",
|
|
241
|
-
"recoverProjectBranch",
|
|
242
250
|
"removeOrganizationMember",
|
|
251
|
+
"removeProjectMemberRole",
|
|
243
252
|
"resetProjectBranchRolePassword",
|
|
244
253
|
"restartProjectEndpoint",
|
|
245
254
|
"restoreProjectBranch",
|
|
@@ -251,6 +260,7 @@ const EXPECTED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
251
260
|
"sendNeonAuthTestEmail",
|
|
252
261
|
"setDefaultProjectBranch",
|
|
253
262
|
"setOrganizationSpendingLimit",
|
|
263
|
+
"setProjectMemberRole",
|
|
254
264
|
"setSnapshotSchedule",
|
|
255
265
|
"startAnonymization",
|
|
256
266
|
"startProjectEndpoint",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.js","names":[],"sources":["../../src/neon/coverage.ts"],"sourcesContent":["/**\n * Drift guard for the ergonomic layer.\n *\n * The raw layer is regenerated from the OpenAPI spec, so it auto-tracks new endpoints.\n * The ergonomic resource namespaces are hand-authored, so they can silently fall behind.\n * `coverage.test.ts` compares the generated operation set against {@link EXPECTED_OPERATIONS}\n * and fails CI when they differ — forcing a conscious decision on every spec change:\n * either wrap the new operation in a resource (and add it to {@link WRAPPED}) or accept\n * that it stays raw-only (and add it to the snapshot below).\n *\n * Workflow when the test fails after a `pnpm generate`:\n * 1. Review the `added` / `removed` operations the test reports.\n * 2. Wrap the ones worth ergonomic treatment (and list them in {@link WRAPPED}).\n * 3. Update {@link EXPECTED_OPERATIONS} to match the new generated set.\n */\n\n/** Operations surfaced by the ergonomic `createNeonClient` namespaces. */\nexport const WRAPPED: ReadonlySet<string> = new Set([\n\t// projects\n\t\"listProjects\",\n\t\"getProject\",\n\t\"createProject\",\n\t\"updateProject\",\n\t\"deleteProject\",\n\t// projects: transfer\n\t\"transferProjectsFromOrgToOrg\",\n\t\"transferProjectsFromUserToOrg\",\n\t// projects: recover + permissions\n\t\"recoverProject\",\n\t\"listProjectPermissions\",\n\t\"grantPermissionToProject\",\n\t\"revokePermissionFromProject\",\n\t// branches\n\t\"listProjectBranches\",\n\t\"getProjectBranch\",\n\t\"createProjectBranch\",\n\t\"updateProjectBranch\",\n\t\"deleteProjectBranch\",\n\t\"setDefaultProjectBranch\",\n\t\"finalizeRestoreBranch\",\n\t\"recoverProjectBranch\",\n\t// neon auth (branch-scoped)\n\t\"getNeonAuth\",\n\t\"createNeonAuth\",\n\t\"disableNeonAuth\",\n\t\"updateNeonAuthConfig\",\n\t\"listBranchNeonAuthOauthProviders\",\n\t\"addBranchNeonAuthOauthProvider\",\n\t\"updateBranchNeonAuthOauthProvider\",\n\t\"deleteBranchNeonAuthOauthProvider\",\n\t\"listBranchNeonAuthTrustedDomains\",\n\t\"addBranchNeonAuthTrustedDomain\",\n\t\"deleteBranchNeonAuthTrustedDomain\",\n\t\"createBranchNeonAuthNewUser\",\n\t\"deleteBranchNeonAuthUser\",\n\t\"updateNeonAuthUserRole\",\n\t// storage\n\t\"getProjectBranchStorage\",\n\t\"listProjectBranchBuckets\",\n\t\"createProjectBranchBucket\",\n\t\"deleteProjectBranchBucket\",\n\t\"listProjectBranchBucketObjects\",\n\t\"getProjectBranchBucketObject\",\n\t\"deleteProjectBranchBucketObject\",\n\t\"deleteProjectBranchBucketObjectsByPrefix\",\n\t\"presignProjectBranchBucketObject\",\n\t// ai gateway\n\t\"getProjectBranchAiGateway\",\n\t// credentials\n\t\"listCredentials\",\n\t\"createCredential\",\n\t\"revokeCredential\",\n\t// functions\n\t\"listProjectBranchFunctions\",\n\t\"getProjectBranchFunction\",\n\t\"updateProjectBranchFunction\",\n\t\"deleteProjectBranchFunction\",\n\t\"createProjectBranchFunctionDeployment\",\n\t// operations\n\t\"getProjectOperation\",\n\t\"listProjectOperations\",\n\t// postgres: endpoints\n\t\"listProjectEndpoints\",\n\t\"listProjectBranchEndpoints\",\n\t\"getProjectEndpoint\",\n\t\"createProjectEndpoint\",\n\t\"updateProjectEndpoint\",\n\t\"deleteProjectEndpoint\",\n\t\"startProjectEndpoint\",\n\t\"suspendProjectEndpoint\",\n\t\"restartProjectEndpoint\",\n\t// postgres: databases\n\t\"listProjectBranchDatabases\",\n\t\"getProjectBranchDatabase\",\n\t\"createProjectBranchDatabase\",\n\t\"updateProjectBranchDatabase\",\n\t\"deleteProjectBranchDatabase\",\n\t// postgres: roles\n\t\"listProjectBranchRoles\",\n\t\"getProjectBranchRole\",\n\t\"createProjectBranchRole\",\n\t\"deleteProjectBranchRole\",\n\t\"getProjectBranchRolePassword\",\n\t\"resetProjectBranchRolePassword\",\n\t// postgres: connection string + data api\n\t\"getConnectionUri\",\n\t\"getProjectBranchDataApi\",\n\t\"createProjectBranchDataApi\",\n\t\"updateProjectBranchDataApi\",\n\t\"deleteProjectBranchDataApi\",\n\t// snapshots\n\t\"listSnapshots\",\n\t\"createSnapshot\",\n\t\"updateSnapshot\",\n\t\"deleteSnapshot\",\n\t\"restoreSnapshot\",\n\t\"getSnapshotSchedule\",\n\t\"setSnapshotSchedule\",\n\t// consumption\n\t\"getConsumptionHistoryPerProject\",\n\t\"getConsumptionHistoryPerProjectV2\",\n\t\"getConsumptionHistoryPerBranchV2\",\n\t// account\n\t\"getCurrentUserInfo\",\n\t\"getCurrentUserOrganizations\",\n\t\"getActiveRegions\",\n\t\"listApiKeys\",\n\t\"createApiKey\",\n\t\"revokeApiKey\",\n]);\n\n/**\n * Committed snapshot of every operation the generated client exposes. Update this\n * deliberately whenever the spec (and thus the generated client) changes.\n */\nexport const EXPECTED_OPERATIONS: ReadonlySet<string> = new Set([\n\t\"acceptProjectTransferRequest\",\n\t\"addBranchNeonAuthOauthProvider\",\n\t\"addBranchNeonAuthTrustedDomain\",\n\t\"addNeonAuthDomainToRedirectUriWhitelist\",\n\t\"addNeonAuthOauthProvider\",\n\t\"addProjectJwks\",\n\t\"assignOrganizationVpcEndpoint\",\n\t\"assignProjectVpcEndpoint\",\n\t\"countProjectBranches\",\n\t\"createApiKey\",\n\t\"createBranchNeonAuthNewUser\",\n\t\"createCredential\",\n\t\"createNeonAuth\",\n\t\"createNeonAuthIntegration\",\n\t\"createNeonAuthNewUser\",\n\t\"createNeonAuthProviderSdkKeys\",\n\t\"createOrgApiKey\",\n\t\"createOrganizationInvitations\",\n\t\"createProject\",\n\t\"createProjectBranch\",\n\t\"createProjectBranchBucket\",\n\t\"createProjectBranchAnonymized\",\n\t\"createProjectBranchDataApi\",\n\t\"createProjectBranchDatabase\",\n\t\"createProjectBranchFunctionDeployment\",\n\t\"createProjectBranchRole\",\n\t\"createProjectEndpoint\",\n\t\"createProjectTransferRequest\",\n\t\"createSnapshot\",\n\t\"deleteBranchNeonAuthOauthProvider\",\n\t\"deleteBranchNeonAuthTrustedDomain\",\n\t\"deleteBranchNeonAuthUser\",\n\t\"deleteNeonAuthDomainFromRedirectUriWhitelist\",\n\t\"deleteNeonAuthIntegration\",\n\t\"deleteNeonAuthOauthProvider\",\n\t\"deleteNeonAuthUser\",\n\t\"deleteOrganizationSpendingLimit\",\n\t\"deleteOrganizationVpcEndpoint\",\n\t\"deleteProject\",\n\t\"deleteProjectBranch\",\n\t\"deleteProjectBranchBucket\",\n\t\"deleteProjectBranchBucketObject\",\n\t\"deleteProjectBranchBucketObjectsByPrefix\",\n\t\"deleteProjectBranchDataApi\",\n\t\"deleteProjectBranchDatabase\",\n\t\"deleteProjectBranchFunction\",\n\t\"deleteProjectBranchRole\",\n\t\"deleteProjectEndpoint\",\n\t\"deleteProjectJwks\",\n\t\"deleteProjectVpcEndpoint\",\n\t\"deleteSnapshot\",\n\t\"disableNeonAuth\",\n\t\"finalizeRestoreBranch\",\n\t\"getActiveRegions\",\n\t\"getAnonymizedBranchStatus\",\n\t\"getAuthDetails\",\n\t\"getAvailablePreloadLibraries\",\n\t\"getConnectionUri\",\n\t\"getConsumptionHistoryPerBranchV2\",\n\t\"getConsumptionHistoryPerProject\",\n\t\"getConsumptionHistoryPerProjectV2\",\n\t\"getCurrentUserInfo\",\n\t\"getCurrentUserOrganizations\",\n\t\"getMaskingRules\",\n\t\"getNeonAuth\",\n\t\"getNeonAuthAllowLocalhost\",\n\t\"getNeonAuthEmailAndPasswordConfig\",\n\t\"getNeonAuthEmailProvider\",\n\t\"getNeonAuthEmailServer\",\n\t\"getNeonAuthPhoneNumberPlugin\",\n\t\"getNeonAuthPluginConfigs\",\n\t\"getNeonAuthWebhookConfig\",\n\t\"getOrganization\",\n\t\"getOrganizationInvitations\",\n\t\"getOrganizationMember\",\n\t\"getOrganizationMembers\",\n\t\"getOrganizationSpendingLimit\",\n\t\"getOrganizationVpcEndpointDetails\",\n\t\"getProject\",\n\t\"getProjectAdvisorSecurityIssues\",\n\t\"getProjectBranch\",\n\t\"getProjectBranchAiGateway\",\n\t\"getProjectBranchBucketObject\",\n\t\"getProjectBranchDataApi\",\n\t\"getProjectBranchDatabase\",\n\t\"getProjectBranchFunction\",\n\t\"getProjectBranchRole\",\n\t\"getProjectBranchRolePassword\",\n\t\"getProjectBranchSchema\",\n\t\"getProjectBranchSchemaComparison\",\n\t\"getProjectBranchStorage\",\n\t\"getProjectEndpoint\",\n\t\"getProjectJwks\",\n\t\"getProjectOperation\",\n\t\"getSnapshotSchedule\",\n\t\"grantPermissionToProject\",\n\t\"listApiKeys\",\n\t\"listBranchNeonAuthOauthProviders\",\n\t\"listBranchNeonAuthTrustedDomains\",\n\t\"listCredentials\",\n\t\"listNeonAuthIntegrations\",\n\t\"listNeonAuthOauthProviders\",\n\t\"listNeonAuthRedirectUriWhitelistDomains\",\n\t\"listOrgApiKeys\",\n\t\"listOrganizationVpcEndpoints\",\n\t\"listOrganizationVpcEndpointsAllRegions\",\n\t\"listProjectBranchDatabases\",\n\t\"listProjectBranchBucketObjects\",\n\t\"listProjectBranchBuckets\",\n\t\"listProjectBranchEndpoints\",\n\t\"listProjectBranchRoles\",\n\t\"listProjectBranchFunctions\",\n\t\"listProjectBranches\",\n\t\"listProjectEndpoints\",\n\t\"listProjectOperations\",\n\t\"listProjectPermissions\",\n\t\"listProjectVpcEndpoints\",\n\t\"listProjects\",\n\t\"listSharedProjects\",\n\t\"listSnapshots\",\n\t\"presignProjectBranchBucketObject\",\n\t\"recoverProject\",\n\t\"recoverProjectBranch\",\n\t\"removeOrganizationMember\",\n\t\"resetProjectBranchRolePassword\",\n\t\"restartProjectEndpoint\",\n\t\"restoreProjectBranch\",\n\t\"restoreSnapshot\",\n\t\"revokeApiKey\",\n\t\"revokeCredential\",\n\t\"revokeOrgApiKey\",\n\t\"revokePermissionFromProject\",\n\t\"sendNeonAuthTestEmail\",\n\t\"setDefaultProjectBranch\",\n\t\"setOrganizationSpendingLimit\",\n\t\"setSnapshotSchedule\",\n\t\"startAnonymization\",\n\t\"startProjectEndpoint\",\n\t\"suspendProjectEndpoint\",\n\t\"transferNeonAuthProviderProject\",\n\t\"transferProjectsFromOrgToOrg\",\n\t\"transferProjectsFromUserToOrg\",\n\t\"updateBranchNeonAuthOauthProvider\",\n\t\"updateMaskingRules\",\n\t\"updateNeonAuthAllowLocalhost\",\n\t\"updateNeonAuthConfig\",\n\t\"updateNeonAuthEmailAndPasswordConfig\",\n\t\"updateNeonAuthEmailProvider\",\n\t\"updateNeonAuthEmailServer\",\n\t\"updateNeonAuthMagicLinkPlugin\",\n\t\"updateNeonAuthOauthProvider\",\n\t\"updateNeonAuthOrganizationPlugin\",\n\t\"updateNeonAuthPhoneNumberPlugin\",\n\t\"updateNeonAuthUserRole\",\n\t\"updateNeonAuthWebhookConfig\",\n\t\"updateOrganizationMember\",\n\t\"updateProject\",\n\t\"updateProjectBranch\",\n\t\"updateProjectBranchDataApi\",\n\t\"updateProjectBranchDatabase\",\n\t\"updateProjectBranchFunction\",\n\t\"updateProjectEndpoint\",\n\t\"updateSnapshot\",\n]);\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA+B,IAAI,IAAI;CAEnD;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;AAMD,MAAa,sCAA2C,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"coverage.js","names":[],"sources":["../../src/neon/coverage.ts"],"sourcesContent":["/**\n * Drift guard for the ergonomic layer.\n *\n * The raw layer is regenerated from the OpenAPI spec, so it auto-tracks new endpoints.\n * The ergonomic resource namespaces are hand-authored, so they can silently fall behind.\n * `coverage.test.ts` compares the generated operation set against {@link EXPECTED_OPERATIONS}\n * and fails CI when they differ — forcing a conscious decision on every spec change:\n * either wrap the new operation in a resource (and add it to {@link WRAPPED}) or accept\n * that it stays raw-only (and add it to the snapshot below).\n *\n * Workflow when the test fails after a `pnpm generate`:\n * 1. Review the `added` / `removed` operations the test reports.\n * 2. Wrap the ones worth ergonomic treatment (and list them in {@link WRAPPED}).\n * 3. Update {@link EXPECTED_OPERATIONS} to match the new generated set.\n */\n\n/** Operations surfaced by the ergonomic `createNeonClient` namespaces. */\nexport const WRAPPED: ReadonlySet<string> = new Set([\n\t// projects\n\t\"listProjects\",\n\t\"getProject\",\n\t\"createProject\",\n\t\"updateProject\",\n\t\"deleteProject\",\n\t// projects: transfer\n\t\"transferProjectsFromOrgToOrg\",\n\t\"transferProjectsFromUserToOrg\",\n\t// projects: recover + permissions\n\t\"recoverProject\",\n\t\"listProjectPermissions\",\n\t\"grantPermissionToProject\",\n\t\"revokePermissionFromProject\",\n\t// projects: org member roles\n\t\"listProjectMembers\",\n\t\"setProjectMemberRole\",\n\t\"removeProjectMemberRole\",\n\t// branches\n\t\"listProjectBranches\",\n\t\"getProjectBranch\",\n\t\"createProjectBranch\",\n\t\"updateProjectBranch\",\n\t\"deleteProjectBranch\",\n\t\"setDefaultProjectBranch\",\n\t\"finalizeRestoreBranch\",\n\t// logs (branch-scoped)\n\t\"queryProjectBranchLogs\",\n\t\"listProjectBranchLogFields\",\n\t\"listProjectBranchLogFieldValues\",\n\t// neon auth (branch-scoped)\n\t\"getNeonAuth\",\n\t\"createNeonAuth\",\n\t\"disableNeonAuth\",\n\t\"updateNeonAuthConfig\",\n\t\"listBranchNeonAuthOauthProviders\",\n\t\"addBranchNeonAuthOauthProvider\",\n\t\"updateBranchNeonAuthOauthProvider\",\n\t\"deleteBranchNeonAuthOauthProvider\",\n\t\"listBranchNeonAuthTrustedDomains\",\n\t\"addBranchNeonAuthTrustedDomain\",\n\t\"deleteBranchNeonAuthTrustedDomain\",\n\t\"createBranchNeonAuthNewUser\",\n\t\"deleteBranchNeonAuthUser\",\n\t\"updateNeonAuthUserRole\",\n\t// storage\n\t\"getProjectBranchStorage\",\n\t\"listProjectBranchBuckets\",\n\t\"createProjectBranchBucket\",\n\t\"deleteProjectBranchBucket\",\n\t\"listProjectBranchBucketObjects\",\n\t\"getProjectBranchBucketObject\",\n\t\"deleteProjectBranchBucketObject\",\n\t\"deleteProjectBranchBucketObjectsByPrefix\",\n\t\"presignProjectBranchBucketObject\",\n\t// ai gateway\n\t\"getProjectBranchAiGateway\",\n\t// credentials\n\t\"listCredentials\",\n\t\"createCredential\",\n\t\"revokeCredential\",\n\t// functions\n\t\"listProjectBranchFunctions\",\n\t\"getProjectBranchFunction\",\n\t\"updateProjectBranchFunction\",\n\t\"deleteProjectBranchFunction\",\n\t\"createProjectBranchFunctionDeployment\",\n\t// operations\n\t\"getProjectOperation\",\n\t\"listProjectOperations\",\n\t// postgres: endpoints\n\t\"listProjectEndpoints\",\n\t\"listProjectBranchEndpoints\",\n\t\"getProjectEndpoint\",\n\t\"createProjectEndpoint\",\n\t\"updateProjectEndpoint\",\n\t\"deleteProjectEndpoint\",\n\t\"startProjectEndpoint\",\n\t\"suspendProjectEndpoint\",\n\t\"restartProjectEndpoint\",\n\t// postgres: databases\n\t\"listProjectBranchDatabases\",\n\t\"getProjectBranchDatabase\",\n\t\"createProjectBranchDatabase\",\n\t\"updateProjectBranchDatabase\",\n\t\"deleteProjectBranchDatabase\",\n\t// postgres: roles\n\t\"listProjectBranchRoles\",\n\t\"getProjectBranchRole\",\n\t\"createProjectBranchRole\",\n\t\"deleteProjectBranchRole\",\n\t\"getProjectBranchRolePassword\",\n\t\"resetProjectBranchRolePassword\",\n\t// postgres: connection string + data api\n\t\"getConnectionUri\",\n\t\"getProjectBranchDataApi\",\n\t\"createProjectBranchDataApi\",\n\t\"updateProjectBranchDataApi\",\n\t\"deleteProjectBranchDataApi\",\n\t// snapshots\n\t\"listSnapshots\",\n\t\"createSnapshot\",\n\t\"updateSnapshot\",\n\t\"deleteSnapshot\",\n\t\"restoreSnapshot\",\n\t\"getSnapshotSchedule\",\n\t\"setSnapshotSchedule\",\n\t// consumption\n\t\"getConsumptionHistoryPerProject\",\n\t\"getConsumptionHistoryPerProjectV2\",\n\t\"getConsumptionHistoryPerBranchV2\",\n\t// account\n\t\"getCurrentUserInfo\",\n\t\"getCurrentUserOrganizations\",\n\t\"getActiveRegions\",\n\t\"listApiKeys\",\n\t\"createApiKey\",\n\t\"revokeApiKey\",\n]);\n\n/**\n * Committed snapshot of every operation the generated client exposes. Update this\n * deliberately whenever the spec (and thus the generated client) changes.\n */\nexport const EXPECTED_OPERATIONS: ReadonlySet<string> = new Set([\n\t\"acceptProjectTransferRequest\",\n\t\"addBranchNeonAuthOauthProvider\",\n\t\"addBranchNeonAuthTrustedDomain\",\n\t\"addNeonAuthDomainToRedirectUriWhitelist\",\n\t\"addNeonAuthOauthProvider\",\n\t\"addProjectJwks\",\n\t\"assignOrganizationVpcEndpoint\",\n\t\"assignProjectVpcEndpoint\",\n\t\"countProjectBranches\",\n\t\"createApiKey\",\n\t\"createBranchNeonAuthNewUser\",\n\t\"createCredential\",\n\t\"createNeonAuth\",\n\t\"createNeonAuthIntegration\",\n\t\"createNeonAuthNewUser\",\n\t\"createNeonAuthProviderSdkKeys\",\n\t\"createOrgApiKey\",\n\t\"createOrganizationInvitations\",\n\t\"createProject\",\n\t\"createProjectBranch\",\n\t\"createProjectBranchBucket\",\n\t\"createProjectBranchAnonymized\",\n\t\"createProjectBranchDataApi\",\n\t\"createProjectBranchDatabase\",\n\t\"createProjectBranchFunctionDeployment\",\n\t\"createProjectBranchRole\",\n\t\"createProjectEndpoint\",\n\t\"createProjectTransferRequest\",\n\t\"createSnapshot\",\n\t\"deleteBranchNeonAuthOauthProvider\",\n\t\"deleteBranchNeonAuthTrustedDomain\",\n\t\"deleteBranchNeonAuthUser\",\n\t\"deleteNeonAuthDomainFromRedirectUriWhitelist\",\n\t\"deleteNeonAuthIntegration\",\n\t\"deleteNeonAuthOauthProvider\",\n\t\"deleteNeonAuthUser\",\n\t\"deleteOrganizationSpendingLimit\",\n\t\"deleteOrganizationVpcEndpoint\",\n\t\"deleteProject\",\n\t\"deleteProjectBranch\",\n\t\"deleteProjectBranchBucket\",\n\t\"deleteProjectBranchBucketObject\",\n\t\"deleteProjectBranchBucketObjectsByPrefix\",\n\t\"deleteProjectBranchDataApi\",\n\t\"deleteProjectBranchDatabase\",\n\t\"deleteProjectBranchFunction\",\n\t\"deleteProjectBranchRole\",\n\t\"deleteProjectEndpoint\",\n\t\"deleteProjectJwks\",\n\t\"deleteProjectVpcEndpoint\",\n\t\"deleteSnapshot\",\n\t\"disableNeonAuth\",\n\t\"finalizeRestoreBranch\",\n\t\"getActiveRegions\",\n\t\"getAnonymizedBranchStatus\",\n\t\"getAuthDetails\",\n\t\"getAvailablePreloadLibraries\",\n\t\"getConnectionUri\",\n\t\"getConsumptionHistoryPerBranchV2\",\n\t\"getConsumptionHistoryPerProject\",\n\t\"getConsumptionHistoryPerProjectV2\",\n\t\"getCurrentUserInfo\",\n\t\"getCurrentUserOrganizations\",\n\t\"getMaskingRules\",\n\t\"getNeonAuth\",\n\t\"getNeonAuthAllowLocalhost\",\n\t\"getNeonAuthEmailAndPasswordConfig\",\n\t\"getNeonAuthEmailProvider\",\n\t\"getNeonAuthEmailServer\",\n\t\"getNeonAuthPhoneNumberPlugin\",\n\t\"getNeonAuthPluginConfigs\",\n\t\"getNeonAuthWebhookConfig\",\n\t\"getOrganization\",\n\t\"getOrganizationInvitations\",\n\t\"getOrganizationMember\",\n\t\"getOrganizationMembers\",\n\t\"getOrganizationSpendingLimit\",\n\t\"getOrganizationVpcEndpointDetails\",\n\t\"getProject\",\n\t\"getProjectAdvisorSecurityIssues\",\n\t\"getProjectBranch\",\n\t\"getProjectBranchAiGateway\",\n\t\"getProjectBranchBucketObject\",\n\t\"getProjectBranchDataApi\",\n\t\"getProjectBranchDatabase\",\n\t\"getProjectBranchFunction\",\n\t\"getProjectBranchRole\",\n\t\"getProjectBranchRolePassword\",\n\t\"getProjectBranchSchema\",\n\t\"getProjectBranchSchemaComparison\",\n\t\"getProjectBranchStorage\",\n\t\"getProjectEndpoint\",\n\t\"getProjectJwks\",\n\t\"getProjectOperation\",\n\t\"getSnapshotSchedule\",\n\t\"grantPermissionToProject\",\n\t\"listApiKeys\",\n\t\"listBranchNeonAuthOauthProviders\",\n\t\"listBranchNeonAuthTrustedDomains\",\n\t\"listCredentials\",\n\t\"listNeonAuthIntegrations\",\n\t\"listNeonAuthOauthProviders\",\n\t\"listNeonAuthRedirectUriWhitelistDomains\",\n\t\"listOrgApiKeys\",\n\t\"listOrganizationVpcEndpoints\",\n\t\"listOrganizationVpcEndpointsAllRegions\",\n\t\"listProjectBranchDatabases\",\n\t\"listProjectBranchBucketObjects\",\n\t\"listProjectBranchBuckets\",\n\t\"listProjectBranchEndpoints\",\n\t\"listProjectBranchRoles\",\n\t\"listProjectBranchFunctions\",\n\t\"listProjectBranchLogFields\",\n\t\"listProjectBranchLogFieldValues\",\n\t\"listProjectBranches\",\n\t\"listProjectEndpoints\",\n\t\"listProjectMembers\",\n\t\"listProjectOperations\",\n\t\"listProjectPermissions\",\n\t\"listProjectVpcEndpoints\",\n\t\"listProjects\",\n\t\"listSharedProjects\",\n\t\"listSnapshots\",\n\t\"presignProjectBranchBucketObject\",\n\t\"queryProjectBranchLogs\",\n\t\"recoverProject\",\n\t\"removeOrganizationMember\",\n\t\"removeProjectMemberRole\",\n\t\"resetProjectBranchRolePassword\",\n\t\"restartProjectEndpoint\",\n\t\"restoreProjectBranch\",\n\t\"restoreSnapshot\",\n\t\"revokeApiKey\",\n\t\"revokeCredential\",\n\t\"revokeOrgApiKey\",\n\t\"revokePermissionFromProject\",\n\t\"sendNeonAuthTestEmail\",\n\t\"setDefaultProjectBranch\",\n\t\"setOrganizationSpendingLimit\",\n\t\"setProjectMemberRole\",\n\t\"setSnapshotSchedule\",\n\t\"startAnonymization\",\n\t\"startProjectEndpoint\",\n\t\"suspendProjectEndpoint\",\n\t\"transferNeonAuthProviderProject\",\n\t\"transferProjectsFromOrgToOrg\",\n\t\"transferProjectsFromUserToOrg\",\n\t\"updateBranchNeonAuthOauthProvider\",\n\t\"updateMaskingRules\",\n\t\"updateNeonAuthAllowLocalhost\",\n\t\"updateNeonAuthConfig\",\n\t\"updateNeonAuthEmailAndPasswordConfig\",\n\t\"updateNeonAuthEmailProvider\",\n\t\"updateNeonAuthEmailServer\",\n\t\"updateNeonAuthMagicLinkPlugin\",\n\t\"updateNeonAuthOauthProvider\",\n\t\"updateNeonAuthOrganizationPlugin\",\n\t\"updateNeonAuthPhoneNumberPlugin\",\n\t\"updateNeonAuthUserRole\",\n\t\"updateNeonAuthWebhookConfig\",\n\t\"updateOrganizationMember\",\n\t\"updateProject\",\n\t\"updateProjectBranch\",\n\t\"updateProjectBranchDataApi\",\n\t\"updateProjectBranchDatabase\",\n\t\"updateProjectBranchFunction\",\n\t\"updateProjectEndpoint\",\n\t\"updateSnapshot\",\n]);\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA+B,IAAI,IAAI;CAEnD;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;;;;AAMD,MAAa,sCAA2C,IAAI,IAAI;CAC/D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { NeonError } from "./errors.js";
|
|
2
|
+
|
|
3
|
+
//#region src/neon/deadline.d.ts
|
|
4
|
+
|
|
5
|
+
/** Why a bounded wait ended. */
|
|
6
|
+
type DelayOutcome = "elapsed" | "cancelled";
|
|
7
|
+
/** What ended a call: the caller's own signal, or the request-timeout budget. */
|
|
8
|
+
type DeadlineSource = "caller" | "timeout";
|
|
9
|
+
interface Deadline {
|
|
10
|
+
/**
|
|
11
|
+
* Attach to every request the call makes. `undefined` when the call is unbounded and
|
|
12
|
+
* the caller passed no signal, so nothing extra is allocated for the common case.
|
|
13
|
+
*/
|
|
14
|
+
readonly signal: AbortSignal | undefined;
|
|
15
|
+
/** Budget left in milliseconds; `Infinity` when no request timeout applies. */
|
|
16
|
+
remainingMs(): number;
|
|
17
|
+
/**
|
|
18
|
+
* What ended the call, or `undefined` while it may still proceed.
|
|
19
|
+
*
|
|
20
|
+
* Reads the clock rather than trusting the timer to have run, and trips the deadline
|
|
21
|
+
* itself if the budget is already spent. A loop that only ever awaits
|
|
22
|
+
* already-resolved promises — paginating a cursor the API keeps repeating, say —
|
|
23
|
+
* yields to the microtask queue but never to the timer phase, so a timer-only
|
|
24
|
+
* deadline would never fire and the call would spin forever.
|
|
25
|
+
*/
|
|
26
|
+
source(): DeadlineSource | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves when the deadline fires, and otherwise never settles. Used to bound the
|
|
29
|
+
* phases a request signal cannot reach. Never rejects.
|
|
30
|
+
*/
|
|
31
|
+
fired(): Promise<void>;
|
|
32
|
+
/** Release the timer and the caller-signal listener. Safe to call more than once. */
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Normalize a `requestTimeoutMs`, rejecting values `setTimeout` would mistreat.
|
|
37
|
+
*
|
|
38
|
+
* Shared by the client config and by per-call overrides — validating only at construction
|
|
39
|
+
* left `requestTimeoutMs: NaN` on a call silently meaning *unbounded*, and a value past
|
|
40
|
+
* {@link MAX_TIMER_MS} silently meaning *1ms*. Both are worse than an error, because the
|
|
41
|
+
* call still returns a plausible-looking result.
|
|
42
|
+
*
|
|
43
|
+
* `undefined` and `Infinity` both mean unbounded; `Infinity` is the documented way to opt
|
|
44
|
+
* a single call out of a client-wide deadline.
|
|
45
|
+
*/
|
|
46
|
+
declare function resolveTimeoutMs(value: number | undefined): number;
|
|
47
|
+
/**
|
|
48
|
+
* The typed error for a deadline that has fired, or `undefined` if it has not.
|
|
49
|
+
*
|
|
50
|
+
* Cancellation is classified from the deadline's own state rather than from the shape of
|
|
51
|
+
* the error that came back. The generated client funnels authentication, serialization,
|
|
52
|
+
* interceptor, transport and parsing faults through one channel, so an error merely named
|
|
53
|
+
* `AbortError` is not evidence that the caller cancelled.
|
|
54
|
+
*/
|
|
55
|
+
declare function cancelled(deadline: Deadline): NeonError | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Race `run()` against the deadline, resolving `undefined` when the deadline wins.
|
|
58
|
+
*
|
|
59
|
+
* The signal alone does not bound a call. The generated client awaits authentication and
|
|
60
|
+
* request interceptors before it constructs the `Request`, and a caller-supplied `fetch`
|
|
61
|
+
* need not honour a signal at all, so an `apiKey` function that never resolves would
|
|
62
|
+
* otherwise hang forever even with a deadline set.
|
|
63
|
+
*/
|
|
64
|
+
declare function runBounded<T>(deadline: Deadline, run: () => Promise<T>): Promise<T | undefined>;
|
|
65
|
+
/**
|
|
66
|
+
* Wait `ms`, or stop early when `signal` aborts. Resolves either way — an abort is
|
|
67
|
+
* reported as `"cancelled"` rather than thrown, and the listener is always removed so a
|
|
68
|
+
* long-lived caller signal doesn't accumulate one per wait.
|
|
69
|
+
*/
|
|
70
|
+
declare function delay(ms: number, signal?: AbortSignal): Promise<DelayOutcome>;
|
|
71
|
+
/**
|
|
72
|
+
* Build the deadline for one call.
|
|
73
|
+
*
|
|
74
|
+
* `timeoutMs` is `Infinity` when no request timeout applies. With no timeout and no caller
|
|
75
|
+
* signal there is nothing to cancel, so a shared no-op deadline is returned and no timer
|
|
76
|
+
* or controller is allocated.
|
|
77
|
+
*/
|
|
78
|
+
declare function createDeadline(timeoutMs: number, callerSignal?: AbortSignal): Deadline;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { Deadline, DeadlineSource, DelayOutcome, cancelled, createDeadline, delay, resolveTimeoutMs, runBounded };
|
|
81
|
+
//# sourceMappingURL=deadline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.d.ts","names":[],"sources":["../../src/neon/deadline.ts"],"mappings":";;;;AAsGoC;AAAW,KA9EnC,YAAA,GA8EmC,SAAA,GAAA,WAAA;AAAS;AAqBlC,KAhGV,cAAA,GAgGoB,QAAA,GAAA,SAAA;AAAA,UA9Ff,QAAA,CA8Fe;EACrB;AACS;AAAR;AACD;EAAR,SAAA,MAAA,EA5Fe,WA4Ff,GAAA,SAAA;EAAO;EAcM,WAAK,EAAA,EAAA,MAAA;EAAA;AAAsB;AAAsB;AAAR;AAAO;AAsBhE;AAA8B;AAEd;AACb;EAAQ,MAAA,EAAA,EAvHA,cAuHA,GAAA,SAAA;;;;;WAlHD;;;;;;;;;;;;;;;iBAwBM,gBAAA;;;;;;;;;iBA2BA,SAAA,WAAoB,WAAW;;;;;;;;;iBAqBzB,wBACX,qBACC,QAAQ,KACjB,QAAQ;;;;;;iBAcK,KAAA,sBAA2B,cAAc,QAAQ;;;;;;;;iBAsBjD,cAAA,mCAEA,cACb"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { NeonAbortError, NeonError, NeonTimeoutError } from "./errors.js";
|
|
2
|
+
//#region src/neon/deadline.ts
|
|
3
|
+
/**
|
|
4
|
+
* Cancellation and deadline plumbing shared by the ergonomic layer.
|
|
5
|
+
*
|
|
6
|
+
* Two facts shape this module. Handing a signal to `fetch` does **not** bound a call: the
|
|
7
|
+
* generated client awaits authentication and request interceptors before it constructs the
|
|
8
|
+
* `Request` (see `client/client/client.gen.ts`), and a caller-supplied `fetch` may ignore
|
|
9
|
+
* the signal entirely. So a deadline both carries a signal *and* offers {@link Deadline.fired}
|
|
10
|
+
* to race the whole execution against.
|
|
11
|
+
*
|
|
12
|
+
* And a cancelled call must still speak the result contract. Anything that waits here
|
|
13
|
+
* reports cancellation as a value rather than rejecting, so a `DOMException` never escapes
|
|
14
|
+
* to a caller who was promised `{ data, error }`.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The largest delay `setTimeout` can represent. Beyond it Node warns
|
|
18
|
+
* (`TimeoutOverflowWarning`) and fires after 1ms instead, which would turn a deliberately
|
|
19
|
+
* generous deadline into an instant timeout.
|
|
20
|
+
*/
|
|
21
|
+
const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
22
|
+
const UNBOUNDED = {
|
|
23
|
+
signal: void 0,
|
|
24
|
+
remainingMs: () => Number.POSITIVE_INFINITY,
|
|
25
|
+
source: () => void 0,
|
|
26
|
+
fired: () => new Promise(() => {}),
|
|
27
|
+
dispose: () => {}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Normalize a `requestTimeoutMs`, rejecting values `setTimeout` would mistreat.
|
|
31
|
+
*
|
|
32
|
+
* Shared by the client config and by per-call overrides — validating only at construction
|
|
33
|
+
* left `requestTimeoutMs: NaN` on a call silently meaning *unbounded*, and a value past
|
|
34
|
+
* {@link MAX_TIMER_MS} silently meaning *1ms*. Both are worse than an error, because the
|
|
35
|
+
* call still returns a plausible-looking result.
|
|
36
|
+
*
|
|
37
|
+
* `undefined` and `Infinity` both mean unbounded; `Infinity` is the documented way to opt
|
|
38
|
+
* a single call out of a client-wide deadline.
|
|
39
|
+
*/
|
|
40
|
+
function resolveTimeoutMs(value) {
|
|
41
|
+
if (value === void 0 || value === Number.POSITIVE_INFINITY) return Number.POSITIVE_INFINITY;
|
|
42
|
+
if (typeof value !== "number" || Number.isNaN(value) || value <= 0) throw new NeonError(`requestTimeoutMs must be a positive number of milliseconds, or Infinity to disable; received ${String(value)}.`, "client");
|
|
43
|
+
if (value > MAX_TIMER_MS) throw new NeonError(`requestTimeoutMs must be at most ${MAX_TIMER_MS}ms (about 24.8 days); received ${value}. Pass Infinity for no deadline.`, "client");
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The typed error for a deadline that has fired, or `undefined` if it has not.
|
|
48
|
+
*
|
|
49
|
+
* Cancellation is classified from the deadline's own state rather than from the shape of
|
|
50
|
+
* the error that came back. The generated client funnels authentication, serialization,
|
|
51
|
+
* interceptor, transport and parsing faults through one channel, so an error merely named
|
|
52
|
+
* `AbortError` is not evidence that the caller cancelled.
|
|
53
|
+
*/
|
|
54
|
+
function cancelled(deadline) {
|
|
55
|
+
const source = deadline.source();
|
|
56
|
+
if (source === "caller") return new NeonAbortError("The request was aborted by its signal.");
|
|
57
|
+
if (source === "timeout") return new NeonTimeoutError("Timed out waiting for the Neon API to respond (requestTimeoutMs).");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Race `run()` against the deadline, resolving `undefined` when the deadline wins.
|
|
61
|
+
*
|
|
62
|
+
* The signal alone does not bound a call. The generated client awaits authentication and
|
|
63
|
+
* request interceptors before it constructs the `Request`, and a caller-supplied `fetch`
|
|
64
|
+
* need not honour a signal at all, so an `apiKey` function that never resolves would
|
|
65
|
+
* otherwise hang forever even with a deadline set.
|
|
66
|
+
*/
|
|
67
|
+
async function runBounded(deadline, run) {
|
|
68
|
+
if (!deadline.signal) return run();
|
|
69
|
+
const execution = run();
|
|
70
|
+
execution.catch(() => {});
|
|
71
|
+
return Promise.race([execution, deadline.fired().then(() => void 0)]);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Wait `ms`, or stop early when `signal` aborts. Resolves either way — an abort is
|
|
75
|
+
* reported as `"cancelled"` rather than thrown, and the listener is always removed so a
|
|
76
|
+
* long-lived caller signal doesn't accumulate one per wait.
|
|
77
|
+
*/
|
|
78
|
+
function delay(ms, signal) {
|
|
79
|
+
if (signal?.aborted) return Promise.resolve("cancelled");
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
const onAbort = () => {
|
|
82
|
+
clearTimeout(timer);
|
|
83
|
+
resolve("cancelled");
|
|
84
|
+
};
|
|
85
|
+
const timer = setTimeout(() => {
|
|
86
|
+
signal?.removeEventListener("abort", onAbort);
|
|
87
|
+
resolve("elapsed");
|
|
88
|
+
}, ms);
|
|
89
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Build the deadline for one call.
|
|
94
|
+
*
|
|
95
|
+
* `timeoutMs` is `Infinity` when no request timeout applies. With no timeout and no caller
|
|
96
|
+
* signal there is nothing to cancel, so a shared no-op deadline is returned and no timer
|
|
97
|
+
* or controller is allocated.
|
|
98
|
+
*/
|
|
99
|
+
function createDeadline(timeoutMs, callerSignal) {
|
|
100
|
+
const bounded = Number.isFinite(timeoutMs);
|
|
101
|
+
if (!bounded && !callerSignal) return UNBOUNDED;
|
|
102
|
+
const startedAt = performance.now();
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
let source;
|
|
105
|
+
let notify;
|
|
106
|
+
const fired = new Promise((resolve) => {
|
|
107
|
+
notify = resolve;
|
|
108
|
+
});
|
|
109
|
+
const trip = (reason) => {
|
|
110
|
+
if (source) return;
|
|
111
|
+
source = reason;
|
|
112
|
+
controller.abort();
|
|
113
|
+
notify?.();
|
|
114
|
+
};
|
|
115
|
+
if (callerSignal?.aborted) trip("caller");
|
|
116
|
+
const onCallerAbort = () => trip("caller");
|
|
117
|
+
const remainingMs = () => bounded ? Math.max(0, timeoutMs - (performance.now() - startedAt)) : Number.POSITIVE_INFINITY;
|
|
118
|
+
let timer;
|
|
119
|
+
const arm = () => {
|
|
120
|
+
const left = remainingMs();
|
|
121
|
+
if (left === 0) return trip("timeout");
|
|
122
|
+
timer = setTimeout(left > MAX_TIMER_MS ? arm : () => trip("timeout"), Math.min(left, MAX_TIMER_MS));
|
|
123
|
+
};
|
|
124
|
+
if (bounded) arm();
|
|
125
|
+
callerSignal?.addEventListener("abort", onCallerAbort, { once: true });
|
|
126
|
+
return {
|
|
127
|
+
signal: controller.signal,
|
|
128
|
+
remainingMs,
|
|
129
|
+
source: () => {
|
|
130
|
+
if (!source && remainingMs() === 0) trip("timeout");
|
|
131
|
+
return source;
|
|
132
|
+
},
|
|
133
|
+
fired: () => fired,
|
|
134
|
+
dispose: () => {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
callerSignal?.removeEventListener("abort", onCallerAbort);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { cancelled, createDeadline, delay, resolveTimeoutMs, runBounded };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.js","names":[],"sources":["../../src/neon/deadline.ts"],"sourcesContent":["/**\n * Cancellation and deadline plumbing shared by the ergonomic layer.\n *\n * Two facts shape this module. Handing a signal to `fetch` does **not** bound a call: the\n * generated client awaits authentication and request interceptors before it constructs the\n * `Request` (see `client/client/client.gen.ts`), and a caller-supplied `fetch` may ignore\n * the signal entirely. So a deadline both carries a signal *and* offers {@link Deadline.fired}\n * to race the whole execution against.\n *\n * And a cancelled call must still speak the result contract. Anything that waits here\n * reports cancellation as a value rather than rejecting, so a `DOMException` never escapes\n * to a caller who was promised `{ data, error }`.\n */\n\nimport { NeonAbortError, NeonError, NeonTimeoutError } from \"./errors.js\";\n\n/**\n * The largest delay `setTimeout` can represent. Beyond it Node warns\n * (`TimeoutOverflowWarning`) and fires after 1ms instead, which would turn a deliberately\n * generous deadline into an instant timeout.\n */\nconst MAX_TIMER_MS = 2 ** 31 - 1;\n\n/** Why a bounded wait ended. */\nexport type DelayOutcome = \"elapsed\" | \"cancelled\";\n\n/** What ended a call: the caller's own signal, or the request-timeout budget. */\nexport type DeadlineSource = \"caller\" | \"timeout\";\n\nexport interface Deadline {\n\t/**\n\t * Attach to every request the call makes. `undefined` when the call is unbounded and\n\t * the caller passed no signal, so nothing extra is allocated for the common case.\n\t */\n\treadonly signal: AbortSignal | undefined;\n\t/** Budget left in milliseconds; `Infinity` when no request timeout applies. */\n\tremainingMs(): number;\n\t/**\n\t * What ended the call, or `undefined` while it may still proceed.\n\t *\n\t * Reads the clock rather than trusting the timer to have run, and trips the deadline\n\t * itself if the budget is already spent. A loop that only ever awaits\n\t * already-resolved promises — paginating a cursor the API keeps repeating, say —\n\t * yields to the microtask queue but never to the timer phase, so a timer-only\n\t * deadline would never fire and the call would spin forever.\n\t */\n\tsource(): DeadlineSource | undefined;\n\t/**\n\t * Resolves when the deadline fires, and otherwise never settles. Used to bound the\n\t * phases a request signal cannot reach. Never rejects.\n\t */\n\tfired(): Promise<void>;\n\t/** Release the timer and the caller-signal listener. Safe to call more than once. */\n\tdispose(): void;\n}\n\nconst UNBOUNDED: Deadline = {\n\tsignal: undefined,\n\tremainingMs: () => Number.POSITIVE_INFINITY,\n\tsource: () => undefined,\n\tfired: () => new Promise<void>(() => {}),\n\tdispose: () => {},\n};\n\n/**\n * Normalize a `requestTimeoutMs`, rejecting values `setTimeout` would mistreat.\n *\n * Shared by the client config and by per-call overrides — validating only at construction\n * left `requestTimeoutMs: NaN` on a call silently meaning *unbounded*, and a value past\n * {@link MAX_TIMER_MS} silently meaning *1ms*. Both are worse than an error, because the\n * call still returns a plausible-looking result.\n *\n * `undefined` and `Infinity` both mean unbounded; `Infinity` is the documented way to opt\n * a single call out of a client-wide deadline.\n */\nexport function resolveTimeoutMs(value: number | undefined): number {\n\tif (value === undefined || value === Number.POSITIVE_INFINITY) {\n\t\treturn Number.POSITIVE_INFINITY;\n\t}\n\tif (typeof value !== \"number\" || Number.isNaN(value) || value <= 0) {\n\t\tthrow new NeonError(\n\t\t\t`requestTimeoutMs must be a positive number of milliseconds, or Infinity to disable; received ${String(value)}.`,\n\t\t\t\"client\",\n\t\t);\n\t}\n\tif (value > MAX_TIMER_MS) {\n\t\tthrow new NeonError(\n\t\t\t`requestTimeoutMs must be at most ${MAX_TIMER_MS}ms (about 24.8 days); received ${value}. Pass Infinity for no deadline.`,\n\t\t\t\"client\",\n\t\t);\n\t}\n\treturn value;\n}\n\n/**\n * The typed error for a deadline that has fired, or `undefined` if it has not.\n *\n * Cancellation is classified from the deadline's own state rather than from the shape of\n * the error that came back. The generated client funnels authentication, serialization,\n * interceptor, transport and parsing faults through one channel, so an error merely named\n * `AbortError` is not evidence that the caller cancelled.\n */\nexport function cancelled(deadline: Deadline): NeonError | undefined {\n\tconst source = deadline.source();\n\tif (source === \"caller\") {\n\t\treturn new NeonAbortError(\"The request was aborted by its signal.\");\n\t}\n\tif (source === \"timeout\") {\n\t\treturn new NeonTimeoutError(\n\t\t\t\"Timed out waiting for the Neon API to respond (requestTimeoutMs).\",\n\t\t);\n\t}\n\treturn undefined;\n}\n\n/**\n * Race `run()` against the deadline, resolving `undefined` when the deadline wins.\n *\n * The signal alone does not bound a call. The generated client awaits authentication and\n * request interceptors before it constructs the `Request`, and a caller-supplied `fetch`\n * need not honour a signal at all, so an `apiKey` function that never resolves would\n * otherwise hang forever even with a deadline set.\n */\nexport async function runBounded<T>(\n\tdeadline: Deadline,\n\trun: () => Promise<T>,\n): Promise<T | undefined> {\n\tif (!deadline.signal) return run();\n\tconst execution = run();\n\t// The losing arm still settles later. Without a handler, its rejection is reported as\n\t// unhandled once the deadline has already answered the caller.\n\texecution.catch(() => {});\n\treturn Promise.race([execution, deadline.fired().then(() => undefined)]);\n}\n\n/**\n * Wait `ms`, or stop early when `signal` aborts. Resolves either way — an abort is\n * reported as `\"cancelled\"` rather than thrown, and the listener is always removed so a\n * long-lived caller signal doesn't accumulate one per wait.\n */\nexport function delay(ms: number, signal?: AbortSignal): Promise<DelayOutcome> {\n\tif (signal?.aborted) return Promise.resolve(\"cancelled\");\n\treturn new Promise<DelayOutcome>((resolve) => {\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timer);\n\t\t\tresolve(\"cancelled\");\n\t\t};\n\t\tconst timer = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(\"elapsed\");\n\t\t}, ms);\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\n/**\n * Build the deadline for one call.\n *\n * `timeoutMs` is `Infinity` when no request timeout applies. With no timeout and no caller\n * signal there is nothing to cancel, so a shared no-op deadline is returned and no timer\n * or controller is allocated.\n */\nexport function createDeadline(\n\ttimeoutMs: number,\n\tcallerSignal?: AbortSignal,\n): Deadline {\n\tconst bounded = Number.isFinite(timeoutMs);\n\tif (!bounded && !callerSignal) return UNBOUNDED;\n\n\t// Monotonic: a wall-clock jump (NTP correction, manual change) would otherwise expire\n\t// a deadline early or extend one whose timer is being starved.\n\tconst startedAt = performance.now();\n\tconst controller = new AbortController();\n\tlet source: DeadlineSource | undefined;\n\tlet notify: (() => void) | undefined;\n\tconst fired = new Promise<void>((resolve) => {\n\t\tnotify = resolve;\n\t});\n\n\tconst trip = (reason: DeadlineSource) => {\n\t\tif (source) return;\n\t\tsource = reason;\n\t\tcontroller.abort();\n\t\tnotify?.();\n\t};\n\n\tif (callerSignal?.aborted) trip(\"caller\");\n\n\tconst onCallerAbort = () => trip(\"caller\");\n\tconst remainingMs = () =>\n\t\tbounded\n\t\t\t? Math.max(0, timeoutMs - (performance.now() - startedAt))\n\t\t\t: Number.POSITIVE_INFINITY;\n\n\t// Deliberately not `unref`ed: every deadline is disposed in a `finally`, so it cannot\n\t// outlive its call, and an unref'd timer is invisible to the event loop's liveness\n\t// accounting — a call whose only pending work is the deadline would starve instead of\n\t// timing out.\n\t//\n\t// Re-armed in chunks rather than scheduled once, because `setTimeout` silently\n\t// collapses any delay above MAX_TIMER_MS to 1ms. `wait.timeoutMs` has always accepted\n\t// arbitrarily large budgets, and a single timer would have turned one into an instant\n\t// timeout.\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst arm = () => {\n\t\tconst left = remainingMs();\n\t\tif (left === 0) return trip(\"timeout\");\n\t\ttimer = setTimeout(\n\t\t\tleft > MAX_TIMER_MS ? arm : () => trip(\"timeout\"),\n\t\t\tMath.min(left, MAX_TIMER_MS),\n\t\t);\n\t};\n\tif (bounded) arm();\n\tcallerSignal?.addEventListener(\"abort\", onCallerAbort, { once: true });\n\n\treturn {\n\t\tsignal: controller.signal,\n\t\tremainingMs,\n\t\tsource: () => {\n\t\t\tif (!source && remainingMs() === 0) trip(\"timeout\");\n\t\t\treturn source;\n\t\t},\n\t\tfired: () => fired,\n\t\tdispose: () => {\n\t\t\tclearTimeout(timer);\n\t\t\tcallerSignal?.removeEventListener(\"abort\", onCallerAbort);\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,eAAe,KAAK,KAAK;AAmC/B,MAAM,YAAsB;CAC3B,QAAQ,KAAA;CACR,mBAAmB,OAAO;CAC1B,cAAc,KAAA;CACd,aAAa,IAAI,cAAoB,CAAC,CAAC;CACvC,eAAe,CAAC;AACjB;;;;;;;;;;;;AAaA,SAAgB,iBAAiB,OAAmC;CACnE,IAAI,UAAU,KAAA,KAAa,UAAU,OAAO,mBAC3C,OAAO,OAAO;CAEf,IAAI,OAAO,UAAU,YAAY,OAAO,MAAM,KAAK,KAAK,SAAS,GAChE,MAAM,IAAI,UACT,gGAAgG,OAAO,KAAK,EAAE,IAC9G,QACD;CAED,IAAI,QAAQ,cACX,MAAM,IAAI,UACT,oCAAoC,aAAa,iCAAiC,MAAM,mCACxF,QACD;CAED,OAAO;AACR;;;;;;;;;AAUA,SAAgB,UAAU,UAA2C;CACpE,MAAM,SAAS,SAAS,OAAO;CAC/B,IAAI,WAAW,UACd,OAAO,IAAI,eAAe,wCAAwC;CAEnE,IAAI,WAAW,WACd,OAAO,IAAI,iBACV,mEACD;AAGF;;;;;;;;;AAUA,eAAsB,WACrB,UACA,KACyB;CACzB,IAAI,CAAC,SAAS,QAAQ,OAAO,IAAI;CACjC,MAAM,YAAY,IAAI;CAGtB,UAAU,YAAY,CAAC,CAAC;CACxB,OAAO,QAAQ,KAAK,CAAC,WAAW,SAAS,MAAM,CAAC,CAAC,WAAW,KAAA,CAAS,CAAC,CAAC;AACxE;;;;;;AAOA,SAAgB,MAAM,IAAY,QAA6C;CAC9E,IAAI,QAAQ,SAAS,OAAO,QAAQ,QAAQ,WAAW;CACvD,OAAO,IAAI,SAAuB,YAAY;EAC7C,MAAM,gBAAgB;GACrB,aAAa,KAAK;GAClB,QAAQ,WAAW;EACpB;EACA,MAAM,QAAQ,iBAAiB;GAC9B,QAAQ,oBAAoB,SAAS,OAAO;GAC5C,QAAQ,SAAS;EAClB,GAAG,EAAE;EACL,QAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;CAC1D,CAAC;AACF;;;;;;;;AASA,SAAgB,eACf,WACA,cACW;CACX,MAAM,UAAU,OAAO,SAAS,SAAS;CACzC,IAAI,CAAC,WAAW,CAAC,cAAc,OAAO;CAItC,MAAM,YAAY,YAAY,IAAI;CAClC,MAAM,aAAa,IAAI,gBAAgB;CACvC,IAAI;CACJ,IAAI;CACJ,MAAM,QAAQ,IAAI,SAAe,YAAY;EAC5C,SAAS;CACV,CAAC;CAED,MAAM,QAAQ,WAA2B;EACxC,IAAI,QAAQ;EACZ,SAAS;EACT,WAAW,MAAM;EACjB,SAAS;CACV;CAEA,IAAI,cAAc,SAAS,KAAK,QAAQ;CAExC,MAAM,sBAAsB,KAAK,QAAQ;CACzC,MAAM,oBACL,UACG,KAAK,IAAI,GAAG,aAAa,YAAY,IAAI,IAAI,UAAU,IACvD,OAAO;CAWX,IAAI;CACJ,MAAM,YAAY;EACjB,MAAM,OAAO,YAAY;EACzB,IAAI,SAAS,GAAG,OAAO,KAAK,SAAS;EACrC,QAAQ,WACP,OAAO,eAAe,YAAY,KAAK,SAAS,GAChD,KAAK,IAAI,MAAM,YAAY,CAC5B;CACD;CACA,IAAI,SAAS,IAAI;CACjB,cAAc,iBAAiB,SAAS,eAAe,EAAE,MAAM,KAAK,CAAC;CAErE,OAAO;EACN,QAAQ,WAAW;EACnB;EACA,cAAc;GACb,IAAI,CAAC,UAAU,YAAY,MAAM,GAAG,KAAK,SAAS;GAClD,OAAO;EACR;EACA,aAAa;EACb,eAAe;GACd,aAAa,KAAK;GAClB,cAAc,oBAAoB,SAAS,aAAa;EACzD;CACD;AACD"}
|
package/dist/neon/errors.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* discriminant, so the same value works whether you read it from `{ error }` or `catch`
|
|
6
6
|
* it.
|
|
7
7
|
*/
|
|
8
|
-
type NeonErrorKind = "api" | "not_found" | "auth" | "rate_limit" | "operation" | "timeout" | "network" | "client";
|
|
8
|
+
type NeonErrorKind = "api" | "not_found" | "auth" | "rate_limit" | "operation" | "timeout" | "aborted" | "network" | "client";
|
|
9
9
|
/**
|
|
10
10
|
* Base class for every error the ergonomic layer produces.
|
|
11
11
|
*
|
|
@@ -64,10 +64,29 @@ declare class NeonOperationError extends NeonError {
|
|
|
64
64
|
status: string;
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* A deadline was exceeded — either `requestTimeoutMs` for a request and its retries, or
|
|
69
|
+
* the `wait` budget while polling operations for readiness.
|
|
70
|
+
*/
|
|
68
71
|
declare class NeonTimeoutError extends NeonError {
|
|
69
72
|
constructor(message: string);
|
|
70
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The caller's `AbortSignal` fired. Distinct from {@link NeonTimeoutError} because nothing
|
|
76
|
+
* went wrong: the caller asked for the work to stop, and the two call for different
|
|
77
|
+
* handling (retry a timeout, don't retry a cancellation).
|
|
78
|
+
*
|
|
79
|
+
* Raised only where the SDK knows the caller cancelled — the call's own deadline, or an
|
|
80
|
+
* already-aborted `signal` on a raw call. A transport failure that merely looks like an
|
|
81
|
+
* abort stays a {@link NeonNetworkError}, since the generated client reports auth,
|
|
82
|
+
* serialization, interceptor and parsing faults through the same channel and an error's
|
|
83
|
+
* name is not evidence about which one occurred.
|
|
84
|
+
*/
|
|
85
|
+
declare class NeonAbortError extends NeonError {
|
|
86
|
+
constructor(message: string, options?: {
|
|
87
|
+
cause?: unknown;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
71
90
|
/** A transport-level failure (DNS, connection, abort) — no HTTP response received. */
|
|
72
91
|
declare class NeonNetworkError extends NeonError {
|
|
73
92
|
/**
|
|
@@ -97,5 +116,5 @@ declare function describeTransportFailure(error: unknown): string;
|
|
|
97
116
|
*/
|
|
98
117
|
declare function toNeonError(error: unknown, response: Response | undefined): NeonError;
|
|
99
118
|
//#endregion
|
|
100
|
-
export { NeonApiError, NeonAuthError, NeonError, NeonErrorKind, NeonNetworkError, NeonNotFoundError, NeonOperationError, NeonRateLimitError, NeonTimeoutError, describeTransportFailure, toNeonError };
|
|
119
|
+
export { NeonAbortError, NeonApiError, NeonAuthError, NeonError, NeonErrorKind, NeonNetworkError, NeonNotFoundError, NeonOperationError, NeonRateLimitError, NeonTimeoutError, describeTransportFailure, toNeonError };
|
|
101
120
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/neon/errors.ts"],"mappings":";;AAUA;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/neon/errors.ts"],"mappings":";;AAUA;AAmBA;AAAuB;AACP;AAIR;AALuB,KAnBnB,aAAA,GAmBmB,KAAA,GAAA,WAAA,GAAA,MAAA,GAAA,YAAA,GAAA,WAAA,GAAA,SAAA,GAAA,SAAA,GAAA,SAAA,GAAA,QAAA;AAAK;AAepC;AAA0B;AAQL;AAOX;AAII;AAnBoB;AAAS;AAkC9B,cAjDA,SAAA,SAAkB,KAAA,CAiDA;EAAA,SAAA,IAAA,EAhDf,aAgDe;EAGM,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EA/C7B,aA+C6B,EAAA,OAHE,CAGF,EAAA;IAA7B,KAAA,CAAA,EAAA,OAAA;EAH+B,CAAA;AAAY;AAWnD;AAA2B,cA7Cd,YAAA,SAAqB,SAAA,CA6CP;EAGU;EAA7B,SAAA,MAAA,EAAA,MAAA;EAH2B;EAAY,SAAA,IAAA,CAAA,EAAA,MAAA;EAWlC;EAAmB,SAAA,SAAA,CAAA,EAAA,MAAA;EAGK;EAA7B,SAAA,QAAA,CAAA,EAnDa,QAmDb;EAHgC;EAAY,SAAA,IAAA,EAAA,OAAA;EAWvC,WAAA,CAAA,OAAA,EAAmB,MAAA,EAAA,IAAA,EAAQ;IAqB3B,IAAA,CAAA,EAzEH,aAyEoB;IAkBjB,MAAA,EAAA,MAAe;IAQf,IAAA,CAAA,EAAA,MAAA;IA4CG,SAAA,CAAA,EAAA,MAAA;IAsBA,QAAA,CAAA,EAjKF,QAiKa;IAAA,IAAA,CAAA,EAAA,OAAA;EAEhB,CAAA;AACR;AAAS;cArJC,iBAAA,SAA0B,YAAA;qCAG/B,6BAA6B;;;cAQxB,aAAA,SAAsB,YAAA;qCAG3B,6BAA6B;;;cAQxB,kBAAA,SAA2B,YAAA;qCAGhC,6BAA6B;;;cAQxB,kBAAA,SAA2B,SAAS;;;;;;;;;;;;;;cAqBpC,gBAAA,SAAyB,SAAS;;;;;;;;;;;;;;cAkBlC,cAAA,SAAuB,SAAS;;;;;;cAQhC,gBAAA,SAAyB,SAAS;;;;;;;;;;;;;;;;;;;;iBA4C/B,wBAAA;;;;;;iBAsBA,WAAA,2BAEL,uBACR"}
|
package/dist/neon/errors.js
CHANGED
|
@@ -88,13 +88,33 @@ var NeonOperationError = class extends NeonError {
|
|
|
88
88
|
this.status = init.status;
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* A deadline was exceeded — either `requestTimeoutMs` for a request and its retries, or
|
|
93
|
+
* the `wait` budget while polling operations for readiness.
|
|
94
|
+
*/
|
|
92
95
|
var NeonTimeoutError = class extends NeonError {
|
|
93
96
|
constructor(message) {
|
|
94
97
|
super(message, "timeout");
|
|
95
98
|
this.name = "NeonTimeoutError";
|
|
96
99
|
}
|
|
97
100
|
};
|
|
101
|
+
/**
|
|
102
|
+
* The caller's `AbortSignal` fired. Distinct from {@link NeonTimeoutError} because nothing
|
|
103
|
+
* went wrong: the caller asked for the work to stop, and the two call for different
|
|
104
|
+
* handling (retry a timeout, don't retry a cancellation).
|
|
105
|
+
*
|
|
106
|
+
* Raised only where the SDK knows the caller cancelled — the call's own deadline, or an
|
|
107
|
+
* already-aborted `signal` on a raw call. A transport failure that merely looks like an
|
|
108
|
+
* abort stays a {@link NeonNetworkError}, since the generated client reports auth,
|
|
109
|
+
* serialization, interceptor and parsing faults through the same channel and an error's
|
|
110
|
+
* name is not evidence about which one occurred.
|
|
111
|
+
*/
|
|
112
|
+
var NeonAbortError = class extends NeonError {
|
|
113
|
+
constructor(message, options) {
|
|
114
|
+
super(message, "aborted", options);
|
|
115
|
+
this.name = "NeonAbortError";
|
|
116
|
+
}
|
|
117
|
+
};
|
|
98
118
|
/** A transport-level failure (DNS, connection, abort) — no HTTP response received. */
|
|
99
119
|
var NeonNetworkError = class extends NeonError {
|
|
100
120
|
/**
|
|
@@ -166,6 +186,6 @@ function toNeonError(error, response) {
|
|
|
166
186
|
return new NeonApiError(message, init);
|
|
167
187
|
}
|
|
168
188
|
//#endregion
|
|
169
|
-
export { NeonApiError, NeonAuthError, NeonError, NeonNetworkError, NeonNotFoundError, NeonOperationError, NeonRateLimitError, NeonTimeoutError, describeTransportFailure, toNeonError };
|
|
189
|
+
export { NeonAbortError, NeonApiError, NeonAuthError, NeonError, NeonNetworkError, NeonNotFoundError, NeonOperationError, NeonRateLimitError, NeonTimeoutError, describeTransportFailure, toNeonError };
|
|
170
190
|
|
|
171
191
|
//# sourceMappingURL=errors.js.map
|