@neon/sdk 1.4.1 → 1.5.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 +64 -3
- package/dist/client/types.gen.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- 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 +59 -10
- package/dist/neon/context.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 +59 -24
- 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 -1
- package/dist/neon/resources/branches.d.ts.map +1 -1
- package/dist/neon/resources/branches.js +29 -20
- 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/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 +9 -1
- package/dist/neon/resources/postgres.js.map +1 -1
- package/dist/neon/resources/projects.d.ts +1 -1
- package/dist/neon/resources/projects.d.ts.map +1 -1
- package/dist/neon/resources/projects.js +35 -24
- 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/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","names":["#ctx"],"sources":["../../../src/neon/resources/operations.ts"],"sourcesContent":["import {\n\tgetProjectOperation,\n\tlistProjectOperations,\n} from \"../../client/sdk.gen.js\";\nimport type { Operation } from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { type Paginated, paginate } from \"../paginate.js\";\nimport type { NeonResult, Outcome } from \"../result.js\";\nimport { type WaitForOptions, waitForOperations } from \"../wait.js\";\n\n/** Operation resource — read operations and wait for them to finish. */\nexport class Operations<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/operations (cursor-paginated) */\n\tlist(projectId: string): Paginated<Operation> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tlistProjectOperations({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tquery: { cursor },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => ({\n\t\t\t\titems: data?.operations ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/operations/{operation_id} */\n\tget(\n\t\tprojectId: string,\n\t\toperationId: string,\n\t): Promise<Outcome<Operation, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\toperationId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Operation, Throw>>;\n\tget(\n\t\tprojectId: string,\n\t\toperationId: string,\n\t\topts?: CallOptions,\n\t): Promise<Operation | NeonResult<Operation>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetProjectOperation({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, operation_id: operationId },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.operation,\n\t\t);\n\t}\n\n\t/**\n\t * Poll until every given operation reaches a terminal `finished`/`skipped` state.\n\t * The primitive behind `waitForReadiness`; use it directly with operations obtained\n\t * from any source (e.g. a raw call or a create response).\n\t */\n\twaitFor(operations: readonly Operation[]): Promise<Outcome<void, DThrow>>;\n\twaitFor<Throw extends boolean = DThrow>(\n\t\toperations: readonly Operation[],\n\t\topts:
|
|
1
|
+
{"version":3,"file":"operations.js","names":["#ctx"],"sources":["../../../src/neon/resources/operations.ts"],"sourcesContent":["import {\n\tgetProjectOperation,\n\tlistProjectOperations,\n} from \"../../client/sdk.gen.js\";\nimport type { Operation } from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { type Paginated, paginate } from \"../paginate.js\";\nimport type { NeonResult, Outcome } from \"../result.js\";\nimport { type WaitForOptions, waitForOperations } from \"../wait.js\";\n\n/**\n * Options for {@link Operations.waitFor}.\n *\n * `requestTimeoutMs` and `waitForReadiness` are deliberately excluded. Readiness is\n * budgeted by `timeoutMs`, and waiting *is* the readiness step — accepting either would\n * offer a knob that silently did nothing.\n */\nexport type WaitForForOptions<Throw extends boolean> = WaitForOptions &\n\tOmit<CallOptions<Throw>, \"requestTimeoutMs\" | \"waitForReadiness\">;\n\n/** Operation resource — read operations and wait for them to finish. */\nexport class Operations<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/operations (cursor-paginated) */\n\tlist(projectId: string, opts?: CallOptions): Paginated<Operation> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tlistProjectOperations({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tquery: { cursor },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => ({\n\t\t\t\titems: data?.operations ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t\t() => this.#ctx.deadlineFor(opts),\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/operations/{operation_id} */\n\tget(\n\t\tprojectId: string,\n\t\toperationId: string,\n\t): Promise<Outcome<Operation, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\toperationId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Operation, Throw>>;\n\tget(\n\t\tprojectId: string,\n\t\toperationId: string,\n\t\topts?: CallOptions,\n\t): Promise<Operation | NeonResult<Operation>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tgetProjectOperation({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, operation_id: operationId },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.operation,\n\t\t);\n\t}\n\n\t/**\n\t * Poll until every given operation reaches a terminal `finished`/`skipped` state.\n\t * The primitive behind `waitForReadiness`; use it directly with operations obtained\n\t * from any source (e.g. a raw call or a create response).\n\t */\n\twaitFor(operations: readonly Operation[]): Promise<Outcome<void, DThrow>>;\n\twaitFor<Throw extends boolean = DThrow>(\n\t\toperations: readonly Operation[],\n\t\topts: WaitForForOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tasync waitFor(\n\t\toperations: readonly Operation[],\n\t\topts?: WaitForForOptions<boolean>,\n\t): Promise<void | NeonResult<void>> {\n\t\tconst defaults = this.#ctx.defaults;\n\t\tconst shouldThrow = opts?.throwOnError ?? defaults.throwOnError;\n\t\tconst result = await waitForOperations(this.#ctx.client, operations, {\n\t\t\tpollIntervalMs:\n\t\t\t\topts?.pollIntervalMs ?? defaults.waitOptions.pollIntervalMs,\n\t\t\ttimeoutMs: opts?.timeoutMs ?? defaults.waitOptions.timeoutMs,\n\t\t\tsignal: opts?.signal ?? defaults.waitOptions.signal,\n\t\t});\n\t\tif (!shouldThrow) return result;\n\t\tif (result.error) throw result.error;\n\t\treturn result.data;\n\t}\n}\n"],"mappings":";;;;;AAqBA,IAAa,aAAb,MAAgD;CAC/C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;;CAGA,KAAK,WAAmB,MAA0C;EACjE,OAAO,UACL,QAAQ,WACR,sBAAsB;GACrB,QAAQ,KAAKA,KAAK;GAClB,MAAM,EAAE,YAAY,UAAU;GAC9B,OAAO,EAAE,OAAO;GAChB,cAAc;GACd;EACD,CAAC,IACD,UAAU;GACV,OAAO,MAAM,cAAc,CAAC;GAC5B,QAAQ,MAAM,YAAY;EAC3B,UACM,KAAKA,KAAK,YAAY,IAAI,CACjC;CACD;CAYA,IACC,WACA,aACA,MAC6C;EAC7C,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,oBAAoB;GACnB;GACA,MAAM;IAAE,YAAY;IAAW,cAAc;GAAY;GACzD,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,SAChB;CACD;CAYA,MAAM,QACL,YACA,MACmC;EACnC,MAAM,WAAW,KAAKA,KAAK;EAC3B,MAAM,cAAc,MAAM,gBAAgB,SAAS;EACnD,MAAM,SAAS,MAAM,kBAAkB,KAAKA,KAAK,QAAQ,YAAY;GACpE,gBACC,MAAM,kBAAkB,SAAS,YAAY;GAC9C,WAAW,MAAM,aAAa,SAAS,YAAY;GACnD,QAAQ,MAAM,UAAU,SAAS,YAAY;EAC9C,CAAC;EACD,IAAI,CAAC,aAAa,OAAO;EACzB,IAAI,OAAO,OAAO,MAAM,OAAO;EAC/B,OAAO,OAAO;CACf;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","names":[],"sources":["../../../src/neon/resources/postgres.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","names":[],"sources":["../../../src/neon/resources/postgres.ts"],"mappings":";;;;;;;;;UAgBiB,sBAAA;EAAA,SAAA,EAAA,MAAA;EAmBJ;EAAQ,QAAA,CAAA,EAAA,MAAA;EACU;EAAV,UAAA,CAAA,EAAA,MAAA;EACE;EAAN,YAAA,CAAA,EAAA,MAAA;EACc;EAAV,QAAA,CAAA,EAAA,MAAA;EACM;EAAR,MAAA,CAAA,EAAA,OAAA;AAGD;AAcR;AACkB;AAAhB;AAAR;AACsC;AAChC,cAxBG,QAwBH,CAAA,eAAA,OAAA,CAAA,CAAA;EACU,CAAA,OAAA;EAAZ,SAAA,SAAA,EAxBa,SAwBb,CAxBuB,MAwBvB,CAAA;EACoB,SAAA,KAAA,EAxBX,KAwBW,CAxBL,MAwBK,CAAA;EAAhB,SAAA,SAAA,EAvBS,SAuBT,CAvBmB,MAuBnB,CAAA;EAAR,SAAA,OAAA,EAtBe,OAsBf,CAtBuB,MAsBvB,CAAA;EAAO,WAAA,CAAA,GAAA,EAnBO,cAmBP;;;;;;2BALD,yBACN,QAAQ,gBAAgB;2CACc,gBAChC,8BACF,YAAY,SAChB,QAAQ,gBAAgB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NeonError, toNeonError } from "../errors.js";
|
|
2
|
+
import { cancelled, runBounded } from "../deadline.js";
|
|
2
3
|
import { err, finalize, ok } from "../result.js";
|
|
3
4
|
import { getConnectionUri, listProjectBranchDatabases, listProjectBranchRoles, listProjectBranches } from "../../client/sdk.gen.js";
|
|
4
5
|
import { DataApi } from "./dataapi.js";
|
|
@@ -26,7 +27,14 @@ var Postgres = class {
|
|
|
26
27
|
}
|
|
27
28
|
async connectionString(params, opts) {
|
|
28
29
|
const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
|
|
29
|
-
|
|
30
|
+
const deadline = this.#ctx.deadlineFor(opts);
|
|
31
|
+
try {
|
|
32
|
+
const resolved = await runBounded(deadline, () => this.#resolve(params, deadline.signal));
|
|
33
|
+
const cancellation = cancelled(deadline);
|
|
34
|
+
return finalize(cancellation !== void 0 ? err(cancellation) : resolved ?? err(new NeonError("The connection-string resolver ended without a result.", "client")), shouldThrow);
|
|
35
|
+
} finally {
|
|
36
|
+
deadline.dispose();
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
39
|
async #resolve(params, signal) {
|
|
32
40
|
const client = this.#ctx.client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.js","names":["#ctx","#resolve"],"sources":["../../../src/neon/resources/postgres.ts"],"sourcesContent":["import {\n\tgetConnectionUri,\n\tlistProjectBranchDatabases,\n\tlistProjectBranches,\n\tlistProjectBranchRoles,\n} from \"../../client/sdk.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { NeonError, toNeonError } from \"../errors.js\";\nimport { err, finalize, type NeonResult, type Outcome, ok } from \"../result.js\";\nimport { DataApi } from \"./dataapi.js\";\nimport { Databases } from \"./databases.js\";\nimport { Endpoints } from \"./endpoints.js\";\nimport { Roles } from \"./roles.js\";\n\n/** Parameters for {@link Postgres.connectionString}. */\nexport interface ConnectionStringParams {\n\tprojectId: string;\n\t/** Defaults to the project's default branch. */\n\tbranchId?: string;\n\t/** Defaults to the branch's read-write endpoint. */\n\tendpointId?: string;\n\t/** Auto-selected when the branch has exactly one database. */\n\tdatabaseName?: string;\n\t/** Auto-selected when the branch has exactly one role. */\n\troleName?: string;\n\t/** Pooled connection string (default `true`). */\n\tpooled?: boolean;\n}\n\n/**\n * The Postgres data plane of a branch: compute endpoints, roles, databases, the Data API,\n * and a connection-string helper. (Grouped under `neon.postgres.*` so future top-level\n * namespaces like `functions` / `storage` stay unambiguous.)\n */\nexport class Postgres<DThrow extends boolean> {\n\treadonly endpoints: Endpoints<DThrow>;\n\treadonly roles: Roles<DThrow>;\n\treadonly databases: Databases<DThrow>;\n\treadonly dataApi: DataApi<DThrow>;\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t\tthis.endpoints = new Endpoints<DThrow>(ctx);\n\t\tthis.roles = new Roles<DThrow>(ctx);\n\t\tthis.databases = new Databases<DThrow>(ctx);\n\t\tthis.dataApi = new DataApi<DThrow>(ctx);\n\t}\n\n\t/**\n\t * Resolve a Postgres connection string. Auto-selects the default branch and the sole\n\t * role/database when not specified (mirrors `@neon/config`'s `fetchEnv`); returns\n\t * a `client`-kind {@link NeonError} when the selection is ambiguous.\n\t */\n\tconnectionString(\n\t\tparams: ConnectionStringParams,\n\t): Promise<Outcome<string, DThrow>>;\n\tconnectionString<Throw extends boolean = DThrow>(\n\t\tparams: ConnectionStringParams,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<string, Throw>>;\n\tasync connectionString(\n\t\tparams: ConnectionStringParams,\n\t\topts?: CallOptions,\n\t): Promise<string | NeonResult<string>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\
|
|
1
|
+
{"version":3,"file":"postgres.js","names":["#ctx","#resolve"],"sources":["../../../src/neon/resources/postgres.ts"],"sourcesContent":["import {\n\tgetConnectionUri,\n\tlistProjectBranchDatabases,\n\tlistProjectBranches,\n\tlistProjectBranchRoles,\n} from \"../../client/sdk.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { cancelled, runBounded } from \"../deadline.js\";\nimport { NeonError, toNeonError } from \"../errors.js\";\nimport { err, finalize, type NeonResult, type Outcome, ok } from \"../result.js\";\nimport { DataApi } from \"./dataapi.js\";\nimport { Databases } from \"./databases.js\";\nimport { Endpoints } from \"./endpoints.js\";\nimport { Roles } from \"./roles.js\";\n\n/** Parameters for {@link Postgres.connectionString}. */\nexport interface ConnectionStringParams {\n\tprojectId: string;\n\t/** Defaults to the project's default branch. */\n\tbranchId?: string;\n\t/** Defaults to the branch's read-write endpoint. */\n\tendpointId?: string;\n\t/** Auto-selected when the branch has exactly one database. */\n\tdatabaseName?: string;\n\t/** Auto-selected when the branch has exactly one role. */\n\troleName?: string;\n\t/** Pooled connection string (default `true`). */\n\tpooled?: boolean;\n}\n\n/**\n * The Postgres data plane of a branch: compute endpoints, roles, databases, the Data API,\n * and a connection-string helper. (Grouped under `neon.postgres.*` so future top-level\n * namespaces like `functions` / `storage` stay unambiguous.)\n */\nexport class Postgres<DThrow extends boolean> {\n\treadonly endpoints: Endpoints<DThrow>;\n\treadonly roles: Roles<DThrow>;\n\treadonly databases: Databases<DThrow>;\n\treadonly dataApi: DataApi<DThrow>;\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t\tthis.endpoints = new Endpoints<DThrow>(ctx);\n\t\tthis.roles = new Roles<DThrow>(ctx);\n\t\tthis.databases = new Databases<DThrow>(ctx);\n\t\tthis.dataApi = new DataApi<DThrow>(ctx);\n\t}\n\n\t/**\n\t * Resolve a Postgres connection string. Auto-selects the default branch and the sole\n\t * role/database when not specified (mirrors `@neon/config`'s `fetchEnv`); returns\n\t * a `client`-kind {@link NeonError} when the selection is ambiguous.\n\t */\n\tconnectionString(\n\t\tparams: ConnectionStringParams,\n\t): Promise<Outcome<string, DThrow>>;\n\tconnectionString<Throw extends boolean = DThrow>(\n\t\tparams: ConnectionStringParams,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<string, Throw>>;\n\tasync connectionString(\n\t\tparams: ConnectionStringParams,\n\t\topts?: CallOptions,\n\t): Promise<string | NeonResult<string>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\t// This resolver makes up to four sequential requests without going through\n\t\t// RequestContext, so it owns the deadline covering all of them.\n\t\tconst deadline = this.#ctx.deadlineFor(opts);\n\t\ttry {\n\t\t\tconst resolved = await runBounded(deadline, () =>\n\t\t\t\tthis.#resolve(params, deadline.signal),\n\t\t\t);\n\t\t\tconst cancellation = cancelled(deadline);\n\t\t\t// `runBounded` resolves undefined only when the deadline won the race, which\n\t\t\t// `cancelled` then reports, so the fallback is unreachable by construction.\n\t\t\tconst result: NeonResult<string> =\n\t\t\t\tcancellation !== undefined\n\t\t\t\t\t? err(cancellation)\n\t\t\t\t\t: (resolved ??\n\t\t\t\t\t\terr(\n\t\t\t\t\t\t\tnew NeonError(\n\t\t\t\t\t\t\t\t\"The connection-string resolver ended without a result.\",\n\t\t\t\t\t\t\t\t\"client\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t));\n\t\t\treturn finalize(result, shouldThrow);\n\t\t} finally {\n\t\t\tdeadline.dispose();\n\t\t}\n\t}\n\n\tasync #resolve(\n\t\tparams: ConnectionStringParams,\n\t\tsignal?: AbortSignal,\n\t): Promise<NeonResult<string>> {\n\t\tconst client = this.#ctx.client;\n\t\tconst projectId = params.projectId;\n\t\tlet branchId = params.branchId;\n\t\tlet roleName = params.roleName;\n\t\tlet databaseName = params.databaseName;\n\n\t\tif ((!roleName || !databaseName) && !branchId) {\n\t\t\tconst branches = await listProjectBranches({\n\t\t\t\tclient,\n\t\t\t\tpath: { project_id: projectId },\n\t\t\t\tthrowOnError: false,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tif (branches.error || !branches.data) {\n\t\t\t\treturn err(toNeonError(branches.error, branches.response));\n\t\t\t}\n\t\t\tbranchId = branches.data.branches.find(\n\t\t\t\t(branch) => branch.default,\n\t\t\t)?.id;\n\t\t\tif (!branchId) {\n\t\t\t\treturn err(\n\t\t\t\t\tnew NeonError(\n\t\t\t\t\t\t\"Could not determine the default branch; pass branchId.\",\n\t\t\t\t\t\t\"client\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!roleName) {\n\t\t\tif (!branchId) return err(branchRequired(\"roleName\"));\n\t\t\tconst roles = await listProjectBranchRoles({\n\t\t\t\tclient,\n\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\tthrowOnError: false,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tif (roles.error || !roles.data)\n\t\t\t\treturn err(toNeonError(roles.error, roles.response));\n\t\t\tif (roles.data.roles.length !== 1) {\n\t\t\t\treturn err(\n\t\t\t\t\tambiguous(\"role\", roles.data.roles.length, \"roleName\"),\n\t\t\t\t);\n\t\t\t}\n\t\t\troleName = roles.data.roles[0].name;\n\t\t}\n\n\t\tif (!databaseName) {\n\t\t\tif (!branchId) return err(branchRequired(\"databaseName\"));\n\t\t\tconst databases = await listProjectBranchDatabases({\n\t\t\t\tclient,\n\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\tthrowOnError: false,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\tif (databases.error || !databases.data) {\n\t\t\t\treturn err(toNeonError(databases.error, databases.response));\n\t\t\t}\n\t\t\tif (databases.data.databases.length !== 1) {\n\t\t\t\treturn err(\n\t\t\t\t\tambiguous(\n\t\t\t\t\t\t\"database\",\n\t\t\t\t\t\tdatabases.data.databases.length,\n\t\t\t\t\t\t\"databaseName\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tdatabaseName = databases.data.databases[0].name;\n\t\t}\n\n\t\tconst conn = await getConnectionUri({\n\t\t\tclient,\n\t\t\tpath: { project_id: projectId },\n\t\t\tquery: {\n\t\t\t\tbranch_id: branchId,\n\t\t\t\tendpoint_id: params.endpointId,\n\t\t\t\tdatabase_name: databaseName,\n\t\t\t\trole_name: roleName,\n\t\t\t\tpooled: params.pooled ?? true,\n\t\t\t},\n\t\t\tthrowOnError: false,\n\t\t\tsignal,\n\t\t});\n\t\tif (conn.error || !conn.data)\n\t\t\treturn err(toNeonError(conn.error, conn.response));\n\t\treturn ok(conn.data.uri);\n\t}\n}\n\nfunction branchRequired(param: string): NeonError {\n\treturn new NeonError(\n\t\t`Pass branchId or ${param} to resolve a connection string.`,\n\t\t\"client\",\n\t);\n}\n\nfunction ambiguous(kind: string, count: number, param: string): NeonError {\n\treturn new NeonError(\n\t\t`Expected exactly one ${kind} to auto-select for the connection string; found ${count}. Pass ${param}.`,\n\t\t\"client\",\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,IAAa,WAAb,MAA8C;CAC7C;CACA;CACA;CACA;CACA;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;EACZ,KAAK,YAAY,IAAI,UAAkB,GAAG;EAC1C,KAAK,QAAQ,IAAI,MAAc,GAAG;EAClC,KAAK,YAAY,IAAI,UAAkB,GAAG;EAC1C,KAAK,UAAU,IAAI,QAAgB,GAAG;CACvC;CAcA,MAAM,iBACL,QACA,MACuC;EACvC,MAAM,cACL,MAAM,gBAAgB,KAAKA,KAAK,SAAS;EAG1C,MAAM,WAAW,KAAKA,KAAK,YAAY,IAAI;EAC3C,IAAI;GACH,MAAM,WAAW,MAAM,WAAW,gBACjC,KAAKC,SAAS,QAAQ,SAAS,MAAM,CACtC;GACA,MAAM,eAAe,UAAU,QAAQ;GAavC,OAAO,SATN,iBAAiB,KAAA,IACd,IAAI,YAAY,IACf,YACF,IACC,IAAI,UACH,0DACA,QACD,CACD,GACqB,WAAW;EACpC,UAAU;GACT,SAAS,QAAQ;EAClB;CACD;CAEA,MAAMA,SACL,QACA,QAC8B;EAC9B,MAAM,SAAS,KAAKD,KAAK;EACzB,MAAM,YAAY,OAAO;EACzB,IAAI,WAAW,OAAO;EACtB,IAAI,WAAW,OAAO;EACtB,IAAI,eAAe,OAAO;EAE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,OAAO,MAAM,iBAAiB;GACnC;GACA,MAAM,EAAE,YAAY,UAAU;GAC9B,OAAO;IACN,WAAW;IACX,aAAa,OAAO;IACpB,eAAe;IACf,WAAW;IACX,QAAQ,OAAO,UAAU;GAC1B;GACA,cAAc;GACd;EACD,CAAC;EACD,IAAI,KAAK,SAAS,CAAC,KAAK,MACvB,OAAO,IAAI,YAAY,KAAK,OAAO,KAAK,QAAQ,CAAC;EAClD,OAAO,GAAG,KAAK,KAAK,GAAG;CACxB;AACD;AAEA,SAAS,eAAe,OAA0B;CACjD,OAAO,IAAI,UACV,oBAAoB,MAAM,mCAC1B,QACD;AACD;AAEA,SAAS,UAAU,MAAc,OAAe,OAA0B;CACzE,OAAO,IAAI,UACV,wBAAwB,KAAK,mDAAmD,MAAM,SAAS,MAAM,IACrG,QACD;AACD"}
|
|
@@ -51,7 +51,7 @@ declare class Projects<DThrow extends boolean> {
|
|
|
51
51
|
*
|
|
52
52
|
* @apiCall GET /projects
|
|
53
53
|
*/
|
|
54
|
-
list(query?: ListQuery): Paginated<ProjectListItem>;
|
|
54
|
+
list(query?: ListQuery, opts?: CallOptions): Paginated<ProjectListItem>;
|
|
55
55
|
/** @apiCall GET /projects/{project_id} */
|
|
56
56
|
get(id: string): Promise<Outcome<Project, DThrow>>;
|
|
57
57
|
get<Throw extends boolean = DThrow>(id: string, opts: CallOptions<Throw>): Promise<Outcome<Project, Throw>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.d.ts","names":[],"sources":["../../../src/neon/resources/projects.ts"],"mappings":";;;;;;;UA4BiB,qBAAA;EAAA;EAQZ,SAAA,CAAA,EAAS,MAAA;EAAA;EAAoB,OAAA,EAAA,MAAA;EAAZ,UAAA,EAAA,MAAA,EAAA;AAAL;AAAI,KAAhB,SAAA,GAAY,IAAI,CAAC,WAAD,CAAa,gBAAb,CAAA,OAAA,CAAA,CAAA,EAAA,QAAA,CAAA;AAAA,KAChB,WAAA,GAAc,oBAAA,CA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AA,CAAA,cAAA,OAAA,GAuItB,MAvIsB,CAAA,CAAA,EAAA,EAAA,MAAA,EAAA,IAAA,EAyI/C,WAzI+C,CAyInC,KAzImC,CAAA,CAAA,EA0InD,OA1ImD,CA0I3C,OA1I2C,CA0InC,OA1ImC,EA0I1B,KA1I0B,CAAA,CAAA;EAAjB;AAAR;AACE;AACvB;AACW;AAAZ;EACY,QAAA,CAAA,KAAA,EA8JH,qBA9JG,CAAA,EA8JqB,OA9JrB,CA8J6B,OA9J7B,CAAA,IAAA,EA8J2C,MA9J3C,CAAA,CAAA;EAAS,QAAA,CAAA,cAAA,OAAA,GA+JK,MA/JL,CAAA,CAAA,KAAA,EAgKpB,qBAhKoB,EAAA,IAAA,EAiKrB,WAjKqB,CAiKT,KAjKS,CAAA,CAAA,EAkKzB,OAlKyB,CAkKjB,OAlKiB,CAAA,IAAA,EAkKH,KAlKG,CAAA,CAAA;EAAjB;AAAR;AAiCM;AACU;AAAmB;EAA3B,gBAAA,CAAA,KAAA,EAAA;IAAR,OAAA,EAAA,MAAA;IACsC,UAAA,EAAA,MAAA,EAAA;EACjC,CAAA,CAAA,EA0KJ,OA1KI,CA0KI,OA1KJ,CAAA,IAAA,EA0KkB,MA1KlB,CAAA,CAAA;EACe,gBAAA,CAAA,cAAA,OAAA,GA0KkB,MA1KlB,CAAA,CAAA,KAAA,EAAA;IAAhB,OAAA,EAAA,MAAA;IACY,UAAA,EAAA,MAAA,EAAA;EAAmB,CAAA,EAAA,IAAA,EA2K/B,WA3K+B,CA2KnB,KA3KmB,CAAA,CAAA,EA4KnC,OA5KmC,CA4K3B,OA5K2B,CAAA,IAAA,EA4Kb,KA5Ka,CAAA,CAAA;AAA3B"}
|
|
@@ -11,28 +11,31 @@ var Permissions = class {
|
|
|
11
11
|
this.#ctx = ctx;
|
|
12
12
|
}
|
|
13
13
|
list(projectId, opts) {
|
|
14
|
-
return this.#ctx.run(opts, (client) => listProjectPermissions({
|
|
14
|
+
return this.#ctx.run(opts, (client, signal) => listProjectPermissions({
|
|
15
15
|
client,
|
|
16
16
|
path: { project_id: projectId },
|
|
17
|
-
throwOnError: false
|
|
17
|
+
throwOnError: false,
|
|
18
|
+
signal
|
|
18
19
|
}), (data) => data.project_permissions);
|
|
19
20
|
}
|
|
20
21
|
grant(projectId, email, opts) {
|
|
21
|
-
return this.#ctx.run(opts, (client) => grantPermissionToProject({
|
|
22
|
+
return this.#ctx.run(opts, (client, signal) => grantPermissionToProject({
|
|
22
23
|
client,
|
|
23
24
|
path: { project_id: projectId },
|
|
24
25
|
body: { email },
|
|
25
|
-
throwOnError: false
|
|
26
|
+
throwOnError: false,
|
|
27
|
+
signal
|
|
26
28
|
}), (data) => data);
|
|
27
29
|
}
|
|
28
30
|
revoke(projectId, permissionId, opts) {
|
|
29
|
-
return this.#ctx.run(opts, (client) => revokePermissionFromProject({
|
|
31
|
+
return this.#ctx.run(opts, (client, signal) => revokePermissionFromProject({
|
|
30
32
|
client,
|
|
31
33
|
path: {
|
|
32
34
|
project_id: projectId,
|
|
33
35
|
permission_id: permissionId
|
|
34
36
|
},
|
|
35
|
-
throwOnError: false
|
|
37
|
+
throwOnError: false,
|
|
38
|
+
signal
|
|
36
39
|
}), (data) => data);
|
|
37
40
|
}
|
|
38
41
|
};
|
|
@@ -51,7 +54,7 @@ var Projects = class {
|
|
|
51
54
|
*
|
|
52
55
|
* @apiCall GET /projects
|
|
53
56
|
*/
|
|
54
|
-
list(query) {
|
|
57
|
+
list(query, opts) {
|
|
55
58
|
return paginate((cursor, signal) => listProjects({
|
|
56
59
|
client: this.#ctx.client,
|
|
57
60
|
query: {
|
|
@@ -64,23 +67,25 @@ var Projects = class {
|
|
|
64
67
|
}), (data) => ({
|
|
65
68
|
items: data?.projects ?? [],
|
|
66
69
|
cursor: data?.pagination?.cursor
|
|
67
|
-
}));
|
|
70
|
+
}), () => this.#ctx.deadlineFor(opts));
|
|
68
71
|
}
|
|
69
72
|
get(id, opts) {
|
|
70
|
-
return this.#ctx.run(opts, (client) => getProject({
|
|
73
|
+
return this.#ctx.run(opts, (client, signal) => getProject({
|
|
71
74
|
client,
|
|
72
75
|
path: { project_id: id },
|
|
73
|
-
throwOnError: false
|
|
76
|
+
throwOnError: false,
|
|
77
|
+
signal
|
|
74
78
|
}), (data) => data.project);
|
|
75
79
|
}
|
|
76
80
|
create(input, opts) {
|
|
77
|
-
return this.#ctx.run(opts, (client) => createProject({
|
|
81
|
+
return this.#ctx.run(opts, (client, signal) => createProject({
|
|
78
82
|
client,
|
|
79
83
|
body: { project: {
|
|
80
84
|
...this.#ctx.defaults.orgId ? { org_id: this.#ctx.defaults.orgId } : {},
|
|
81
85
|
...input
|
|
82
86
|
} },
|
|
83
|
-
throwOnError: false
|
|
87
|
+
throwOnError: false,
|
|
88
|
+
signal
|
|
84
89
|
}), (data) => data.project);
|
|
85
90
|
}
|
|
86
91
|
async createAndConnect(input, opts) {
|
|
@@ -88,62 +93,68 @@ var Projects = class {
|
|
|
88
93
|
return finalize(withConnectionString(await this.#ctx.execute({
|
|
89
94
|
...opts,
|
|
90
95
|
waitForReadiness: opts?.waitForReadiness ?? true
|
|
91
|
-
}, (client) => createProject({
|
|
96
|
+
}, (client, signal) => createProject({
|
|
92
97
|
client,
|
|
93
98
|
body: { project: {
|
|
94
99
|
...this.#ctx.defaults.orgId ? { org_id: this.#ctx.defaults.orgId } : {},
|
|
95
100
|
...input
|
|
96
101
|
} },
|
|
97
|
-
throwOnError: false
|
|
102
|
+
throwOnError: false,
|
|
103
|
+
signal
|
|
98
104
|
}), (data) => data), (data) => data.connection_uris, (data, connectionString) => ({
|
|
99
105
|
project: data.project,
|
|
100
106
|
connectionString
|
|
101
107
|
}), opts?.pooled ?? true), shouldThrow);
|
|
102
108
|
}
|
|
103
109
|
update(id, input, opts) {
|
|
104
|
-
return this.#ctx.run(opts, (client) => updateProject({
|
|
110
|
+
return this.#ctx.run(opts, (client, signal) => updateProject({
|
|
105
111
|
client,
|
|
106
112
|
path: { project_id: id },
|
|
107
113
|
body: { project: input },
|
|
108
|
-
throwOnError: false
|
|
114
|
+
throwOnError: false,
|
|
115
|
+
signal
|
|
109
116
|
}), (data) => data.project);
|
|
110
117
|
}
|
|
111
118
|
delete(id, opts) {
|
|
112
|
-
return this.#ctx.run(opts, (client) => deleteProject({
|
|
119
|
+
return this.#ctx.run(opts, (client, signal) => deleteProject({
|
|
113
120
|
client,
|
|
114
121
|
path: { project_id: id },
|
|
115
|
-
throwOnError: false
|
|
122
|
+
throwOnError: false,
|
|
123
|
+
signal
|
|
116
124
|
}), (data) => data.project);
|
|
117
125
|
}
|
|
118
126
|
recover(id, opts) {
|
|
119
|
-
return this.#ctx.run(opts, (client) => recoverProject({
|
|
127
|
+
return this.#ctx.run(opts, (client, signal) => recoverProject({
|
|
120
128
|
client,
|
|
121
129
|
path: { project_id: id },
|
|
122
|
-
throwOnError: false
|
|
130
|
+
throwOnError: false,
|
|
131
|
+
signal
|
|
123
132
|
}), (data) => data.project);
|
|
124
133
|
}
|
|
125
134
|
async transfer(input, opts) {
|
|
126
135
|
const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
|
|
127
136
|
const fromOrgId = input.fromOrgId ?? this.#ctx.defaults.orgId;
|
|
128
137
|
if (!fromOrgId) return finalize(err(new NeonError("Pass fromOrgId or set orgId on the client.", "client")), shouldThrow);
|
|
129
|
-
return this.#ctx.run(opts, (client) => transferProjectsFromOrgToOrg({
|
|
138
|
+
return this.#ctx.run(opts, (client, signal) => transferProjectsFromOrgToOrg({
|
|
130
139
|
client,
|
|
131
140
|
path: { source_org_id: fromOrgId },
|
|
132
141
|
body: {
|
|
133
142
|
destination_org_id: input.toOrgId,
|
|
134
143
|
project_ids: input.projectIds
|
|
135
144
|
},
|
|
136
|
-
throwOnError: false
|
|
145
|
+
throwOnError: false,
|
|
146
|
+
signal
|
|
137
147
|
}), () => void 0);
|
|
138
148
|
}
|
|
139
149
|
transferFromUser(input, opts) {
|
|
140
|
-
return this.#ctx.run(opts, (client) => transferProjectsFromUserToOrg({
|
|
150
|
+
return this.#ctx.run(opts, (client, signal) => transferProjectsFromUserToOrg({
|
|
141
151
|
client,
|
|
142
152
|
body: {
|
|
143
153
|
destination_org_id: input.toOrgId,
|
|
144
154
|
project_ids: input.projectIds
|
|
145
155
|
},
|
|
146
|
-
throwOnError: false
|
|
156
|
+
throwOnError: false,
|
|
157
|
+
signal
|
|
147
158
|
}), () => void 0);
|
|
148
159
|
}
|
|
149
160
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","names":["#ctx"],"sources":["../../../src/neon/resources/projects.ts"],"sourcesContent":["import {\n\tcreateProject,\n\tdeleteProject,\n\tgetProject,\n\tgrantPermissionToProject,\n\tlistProjectPermissions,\n\tlistProjects,\n\trecoverProject,\n\trevokePermissionFromProject,\n\ttransferProjectsFromOrgToOrg,\n\ttransferProjectsFromUserToOrg,\n\tupdateProject,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tListProjectsData,\n\tProject,\n\tProjectCreateRequest,\n\tProjectListItem,\n\tProjectPermission,\n\tProjectUpdateRequest,\n} from \"../../client/types.gen.js\";\nimport { withConnectionString } from \"../connection.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { NeonError } from \"../errors.js\";\nimport { type Paginated, paginate } from \"../paginate.js\";\nimport { err, finalize, type NeonResult, type Outcome } from \"../result.js\";\n\n/** Input for {@link Projects.transfer} (org → org). */\nexport interface TransferProjectsInput {\n\t/** Source org. Defaults to the client's `orgId`. */\n\tfromOrgId?: string;\n\t/** Destination org. */\n\ttoOrgId: string;\n\tprojectIds: string[];\n}\n\ntype ListQuery = Omit<NonNullable<ListProjectsData[\"query\"]>, \"cursor\">;\ntype CreateInput = ProjectCreateRequest[\"project\"];\ntype UpdateInput = ProjectUpdateRequest[\"project\"];\n\n/** Per-call options for the connect workflow. */\ninterface WorkflowOptions<Throw extends boolean> extends CallOptions<Throw> {\n\t/** Return a pooled connection string (default `true`). */\n\tpooled?: boolean;\n}\n\n/** A project with a ready-to-use connection string to its default branch. */\nexport interface ProjectConnection {\n\tproject: Project;\n\tconnectionString: string;\n}\n\n/** Project access grants (share a project with additional users by email). */\nexport class Permissions<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/permissions */\n\tlist(projectId: string): Promise<Outcome<ProjectPermission[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ProjectPermission[], Throw>>;\n\tlist(\n\t\tprojectId: string,\n\t\topts?: CallOptions,\n\t): Promise<ProjectPermission[] | NeonResult<ProjectPermission[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tlistProjectPermissions({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.project_permissions,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/permissions */\n\tgrant(\n\t\tprojectId: string,\n\t\temail: string,\n\t): Promise<Outcome<ProjectPermission, DThrow>>;\n\tgrant<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\temail: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ProjectPermission, Throw>>;\n\tgrant(\n\t\tprojectId: string,\n\t\temail: string,\n\t\topts?: CallOptions,\n\t): Promise<ProjectPermission | NeonResult<ProjectPermission>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgrantPermissionToProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tbody: { email },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id}/permissions/{permission_id} */\n\trevoke(\n\t\tprojectId: string,\n\t\tpermissionId: string,\n\t): Promise<Outcome<ProjectPermission, DThrow>>;\n\trevoke<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tpermissionId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ProjectPermission, Throw>>;\n\trevoke(\n\t\tprojectId: string,\n\t\tpermissionId: string,\n\t\topts?: CallOptions,\n\t): Promise<ProjectPermission | NeonResult<ProjectPermission>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\trevokePermissionFromProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tpermission_id: permissionId,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data,\n\t\t);\n\t}\n}\n\n/** Project resource — one API call per method (`list` is cursor-paginated). */\nexport class Projects<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\t/** Project access grants (share by email). */\n\treadonly permissions: Permissions<DThrow>;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t\tthis.permissions = new Permissions<DThrow>(ctx);\n\t}\n\n\t/**\n\t * List projects (cursor-paginated). Returns a lazy list — `await .all()`, `.page()`,\n\t * or `for await (… of …)`.\n\t *\n\t * @apiCall GET /projects\n\t */\n\tlist(query?: ListQuery): Paginated<ProjectListItem> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tlistProjects({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tquery: {\n\t\t\t\t\t\torg_id: this.#ctx.defaults.orgId,\n\t\t\t\t\t\t...query,\n\t\t\t\t\t\tcursor,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => ({\n\t\t\t\titems: data?.projects ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id} */\n\tget(id: string): Promise<Outcome<Project, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tget(\n\t\tid: string,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects */\n\tcreate(input?: CreateInput): Promise<Outcome<Project, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tinput: CreateInput | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tcreate(\n\t\tinput?: CreateInput,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tcreateProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tproject: {\n\t\t\t\t\t\t\t...(this.#ctx.defaults.orgId\n\t\t\t\t\t\t\t\t? { org_id: this.#ctx.defaults.orgId }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/**\n\t * Create a project and return a ready-to-use connection string to its default branch.\n\t * One API call plus readiness polling (the create response already carries the\n\t * connection URI).\n\t *\n\t * @workflow createProject + waitForReadiness\n\t */\n\tcreateAndConnect(\n\t\tinput?: CreateInput,\n\t): Promise<Outcome<ProjectConnection, DThrow>>;\n\tcreateAndConnect<Throw extends boolean = DThrow>(\n\t\tinput: CreateInput | undefined,\n\t\topts: WorkflowOptions<Throw>,\n\t): Promise<Outcome<ProjectConnection, Throw>>;\n\tasync createAndConnect(\n\t\tinput?: CreateInput,\n\t\topts?: WorkflowOptions<boolean>,\n\t): Promise<ProjectConnection | NeonResult<ProjectConnection>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\tconst result = await this.#ctx.execute(\n\t\t\t{ ...opts, waitForReadiness: opts?.waitForReadiness ?? true },\n\t\t\t(client) =>\n\t\t\t\tcreateProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tproject: {\n\t\t\t\t\t\t\t...(this.#ctx.defaults.orgId\n\t\t\t\t\t\t\t\t? { org_id: this.#ctx.defaults.orgId }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data,\n\t\t);\n\t\tconst out = withConnectionString(\n\t\t\tresult,\n\t\t\t(data) => data.connection_uris,\n\t\t\t(data, connectionString) => ({\n\t\t\t\tproject: data.project,\n\t\t\t\tconnectionString,\n\t\t\t}),\n\t\t\topts?.pooled ?? true,\n\t\t);\n\t\treturn finalize(out, shouldThrow);\n\t}\n\n\t/** @apiCall PATCH /projects/{project_id} */\n\tupdate(id: string, input: UpdateInput): Promise<Outcome<Project, DThrow>>;\n\tupdate<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\tinput: UpdateInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tupdate(\n\t\tid: string,\n\t\tinput: UpdateInput,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tupdateProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tbody: { project: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id} */\n\tdelete(id: string): Promise<Outcome<Project, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tdelete(\n\t\tid: string,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tdeleteProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/**\n\t * Recover a soft-deleted project within its retention window (beta). Mirrors\n\t * `branches.recover` at the project level.\n\t *\n\t * @apiCall POST /projects/{project_id}/recover\n\t */\n\trecover(id: string): Promise<Outcome<Project, DThrow>>;\n\trecover<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\trecover(\n\t\tid: string,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\trecoverProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/**\n\t * Transfer projects from one organization to another (e.g. sponsored → paid). The\n\t * source org defaults to the client's `orgId`. Requires a key with access to both orgs.\n\t *\n\t * @apiCall POST /organizations/{source_org_id}/projects/transfer\n\t */\n\ttransfer(input: TransferProjectsInput): Promise<Outcome<void, DThrow>>;\n\ttransfer<Throw extends boolean = DThrow>(\n\t\tinput: TransferProjectsInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tasync transfer(\n\t\tinput: TransferProjectsInput,\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\tconst fromOrgId = input.fromOrgId ?? this.#ctx.defaults.orgId;\n\t\tif (!fromOrgId) {\n\t\t\treturn finalize(\n\t\t\t\terr<void>(\n\t\t\t\t\tnew NeonError(\n\t\t\t\t\t\t\"Pass fromOrgId or set orgId on the client.\",\n\t\t\t\t\t\t\"client\",\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tshouldThrow,\n\t\t\t);\n\t\t}\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\ttransferProjectsFromOrgToOrg({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { source_org_id: fromOrgId },\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tdestination_org_id: input.toOrgId,\n\t\t\t\t\t\tproject_ids: input.projectIds,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t() => undefined,\n\t\t);\n\t}\n\n\t/**\n\t * Transfer projects from the personal account to an organization.\n\t *\n\t * @apiCall POST /users/me/projects/transfer\n\t */\n\ttransferFromUser(input: {\n\t\ttoOrgId: string;\n\t\tprojectIds: string[];\n\t}): Promise<Outcome<void, DThrow>>;\n\ttransferFromUser<Throw extends boolean = DThrow>(\n\t\tinput: { toOrgId: string; projectIds: string[] },\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\ttransferFromUser(\n\t\tinput: { toOrgId: string; projectIds: string[] },\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\ttransferProjectsFromUserToOrg({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tdestination_org_id: input.toOrgId,\n\t\t\t\t\t\tproject_ids: input.projectIds,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t() => undefined,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;AAqDA,IAAa,cAAb,MAAiD;CAChD;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAQA,KACC,WACA,MACiE;EACjE,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,uBAAuB;GACtB;GACA,MAAM,EAAE,YAAY,UAAU;GAC9B,cAAc;EACf,CAAC,IACD,SAAS,KAAK,mBAChB;CACD;CAYA,MACC,WACA,OACA,MAC6D;EAC7D,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,yBAAyB;GACxB;GACA,MAAM,EAAE,YAAY,UAAU;GAC9B,MAAM,EAAE,MAAM;GACd,cAAc;EACf,CAAC,IACD,SAAS,IACX;CACD;CAYA,OACC,WACA,cACA,MAC6D;EAC7D,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,4BAA4B;GAC3B;GACA,MAAM;IACL,YAAY;IACZ,eAAe;GAChB;GACA,cAAc;EACf,CAAC,IACD,SAAS,IACX;CACD;AACD;;AAGA,IAAa,WAAb,MAA8C;CAC7C;;CAEA;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;EACZ,KAAK,cAAc,IAAI,YAAoB,GAAG;CAC/C;;;;;;;CAQA,KAAK,OAA+C;EACnD,OAAO,UACL,QAAQ,WACR,aAAa;GACZ,QAAQ,KAAKA,KAAK;GAClB,OAAO;IACN,QAAQ,KAAKA,KAAK,SAAS;IAC3B,GAAG;IACH;GACD;GACA,cAAc;GACd;EACD,CAAC,IACD,UAAU;GACV,OAAO,MAAM,YAAY,CAAC;GAC1B,QAAQ,MAAM,YAAY;EAC3B,EACD;CACD;CAQA,IACC,IAC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MACyC;EACzC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,eAAe;GACd;GACA,MAAM,EAAE,YAAY,GAAG;GACvB,cAAc;EACf,CAAC,IACD,SAAS,KAAK,OAChB;CACD;CAaA,MAAM,SACL,OACA,MACmC;EACnC,MAAM,cACL,MAAM,gBAAgB,KAAKA,KAAK,SAAS;EAC1C,MAAM,YAAY,MAAM,aAAa,KAAKA,KAAK,SAAS;EACxD,IAAI,CAAC,WACJ,OAAO,SACN,IACC,IAAI,UACH,8CACA,QACD,CACD,GACA,WACD;EAED,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,6BAA6B;GAC5B;GACA,MAAM,EAAE,eAAe,UAAU;GACjC,MAAM;IACL,oBAAoB,MAAM;IAC1B,aAAa,MAAM;GACpB;GACA,cAAc;EACf,CAAC,SACI,KAAA,CACP;CACD;CAeA,iBACC,OACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,8BAA8B;GAC7B;GACA,MAAM;IACL,oBAAoB,MAAM;IAC1B,aAAa,MAAM;GACpB;GACA,cAAc;EACf,CAAC,SACI,KAAA,CACP;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"projects.js","names":["#ctx"],"sources":["../../../src/neon/resources/projects.ts"],"sourcesContent":["import {\n\tcreateProject,\n\tdeleteProject,\n\tgetProject,\n\tgrantPermissionToProject,\n\tlistProjectPermissions,\n\tlistProjects,\n\trecoverProject,\n\trevokePermissionFromProject,\n\ttransferProjectsFromOrgToOrg,\n\ttransferProjectsFromUserToOrg,\n\tupdateProject,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tListProjectsData,\n\tProject,\n\tProjectCreateRequest,\n\tProjectListItem,\n\tProjectPermission,\n\tProjectUpdateRequest,\n} from \"../../client/types.gen.js\";\nimport { withConnectionString } from \"../connection.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { NeonError } from \"../errors.js\";\nimport { type Paginated, paginate } from \"../paginate.js\";\nimport { err, finalize, type NeonResult, type Outcome } from \"../result.js\";\n\n/** Input for {@link Projects.transfer} (org → org). */\nexport interface TransferProjectsInput {\n\t/** Source org. Defaults to the client's `orgId`. */\n\tfromOrgId?: string;\n\t/** Destination org. */\n\ttoOrgId: string;\n\tprojectIds: string[];\n}\n\ntype ListQuery = Omit<NonNullable<ListProjectsData[\"query\"]>, \"cursor\">;\ntype CreateInput = ProjectCreateRequest[\"project\"];\ntype UpdateInput = ProjectUpdateRequest[\"project\"];\n\n/** Per-call options for the connect workflow. */\ninterface WorkflowOptions<Throw extends boolean> extends CallOptions<Throw> {\n\t/** Return a pooled connection string (default `true`). */\n\tpooled?: boolean;\n}\n\n/** A project with a ready-to-use connection string to its default branch. */\nexport interface ProjectConnection {\n\tproject: Project;\n\tconnectionString: string;\n}\n\n/** Project access grants (share a project with additional users by email). */\nexport class Permissions<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/permissions */\n\tlist(projectId: string): Promise<Outcome<ProjectPermission[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ProjectPermission[], Throw>>;\n\tlist(\n\t\tprojectId: string,\n\t\topts?: CallOptions,\n\t): Promise<ProjectPermission[] | NeonResult<ProjectPermission[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tlistProjectPermissions({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.project_permissions,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/permissions */\n\tgrant(\n\t\tprojectId: string,\n\t\temail: string,\n\t): Promise<Outcome<ProjectPermission, DThrow>>;\n\tgrant<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\temail: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ProjectPermission, Throw>>;\n\tgrant(\n\t\tprojectId: string,\n\t\temail: string,\n\t\topts?: CallOptions,\n\t): Promise<ProjectPermission | NeonResult<ProjectPermission>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tgrantPermissionToProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tbody: { email },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id}/permissions/{permission_id} */\n\trevoke(\n\t\tprojectId: string,\n\t\tpermissionId: string,\n\t): Promise<Outcome<ProjectPermission, DThrow>>;\n\trevoke<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tpermissionId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ProjectPermission, Throw>>;\n\trevoke(\n\t\tprojectId: string,\n\t\tpermissionId: string,\n\t\topts?: CallOptions,\n\t): Promise<ProjectPermission | NeonResult<ProjectPermission>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\trevokePermissionFromProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tpermission_id: permissionId,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data,\n\t\t);\n\t}\n}\n\n/** Project resource — one API call per method (`list` is cursor-paginated). */\nexport class Projects<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\t/** Project access grants (share by email). */\n\treadonly permissions: Permissions<DThrow>;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t\tthis.permissions = new Permissions<DThrow>(ctx);\n\t}\n\n\t/**\n\t * List projects (cursor-paginated). Returns a lazy list — `await .all()`, `.page()`,\n\t * or `for await (… of …)`.\n\t *\n\t * @apiCall GET /projects\n\t */\n\tlist(query?: ListQuery, opts?: CallOptions): Paginated<ProjectListItem> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tlistProjects({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tquery: {\n\t\t\t\t\t\torg_id: this.#ctx.defaults.orgId,\n\t\t\t\t\t\t...query,\n\t\t\t\t\t\tcursor,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => ({\n\t\t\t\titems: data?.projects ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t\t() => this.#ctx.deadlineFor(opts),\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id} */\n\tget(id: string): Promise<Outcome<Project, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tget(\n\t\tid: string,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tgetProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects */\n\tcreate(input?: CreateInput): Promise<Outcome<Project, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tinput: CreateInput | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tcreate(\n\t\tinput?: CreateInput,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tcreateProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tproject: {\n\t\t\t\t\t\t\t...(this.#ctx.defaults.orgId\n\t\t\t\t\t\t\t\t? { org_id: this.#ctx.defaults.orgId }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/**\n\t * Create a project and return a ready-to-use connection string to its default branch.\n\t * One API call plus readiness polling (the create response already carries the\n\t * connection URI).\n\t *\n\t * @workflow createProject + waitForReadiness\n\t */\n\tcreateAndConnect(\n\t\tinput?: CreateInput,\n\t): Promise<Outcome<ProjectConnection, DThrow>>;\n\tcreateAndConnect<Throw extends boolean = DThrow>(\n\t\tinput: CreateInput | undefined,\n\t\topts: WorkflowOptions<Throw>,\n\t): Promise<Outcome<ProjectConnection, Throw>>;\n\tasync createAndConnect(\n\t\tinput?: CreateInput,\n\t\topts?: WorkflowOptions<boolean>,\n\t): Promise<ProjectConnection | NeonResult<ProjectConnection>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\tconst result = await this.#ctx.execute(\n\t\t\t{ ...opts, waitForReadiness: opts?.waitForReadiness ?? true },\n\t\t\t(client, signal) =>\n\t\t\t\tcreateProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tproject: {\n\t\t\t\t\t\t\t...(this.#ctx.defaults.orgId\n\t\t\t\t\t\t\t\t? { org_id: this.#ctx.defaults.orgId }\n\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data,\n\t\t);\n\t\tconst out = withConnectionString(\n\t\t\tresult,\n\t\t\t(data) => data.connection_uris,\n\t\t\t(data, connectionString) => ({\n\t\t\t\tproject: data.project,\n\t\t\t\tconnectionString,\n\t\t\t}),\n\t\t\topts?.pooled ?? true,\n\t\t);\n\t\treturn finalize(out, shouldThrow);\n\t}\n\n\t/** @apiCall PATCH /projects/{project_id} */\n\tupdate(id: string, input: UpdateInput): Promise<Outcome<Project, DThrow>>;\n\tupdate<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\tinput: UpdateInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tupdate(\n\t\tid: string,\n\t\tinput: UpdateInput,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tupdateProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tbody: { project: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id} */\n\tdelete(id: string): Promise<Outcome<Project, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\tdelete(\n\t\tid: string,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tdeleteProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/**\n\t * Recover a soft-deleted project within its retention window (beta). Mirrors\n\t * `branches.recover` at the project level.\n\t *\n\t * @apiCall POST /projects/{project_id}/recover\n\t */\n\trecover(id: string): Promise<Outcome<Project, DThrow>>;\n\trecover<Throw extends boolean = DThrow>(\n\t\tid: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Project, Throw>>;\n\trecover(\n\t\tid: string,\n\t\topts?: CallOptions,\n\t): Promise<Project | NeonResult<Project>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\trecoverProject({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: id },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.project,\n\t\t);\n\t}\n\n\t/**\n\t * Transfer projects from one organization to another (e.g. sponsored → paid). The\n\t * source org defaults to the client's `orgId`. Requires a key with access to both orgs.\n\t *\n\t * @apiCall POST /organizations/{source_org_id}/projects/transfer\n\t */\n\ttransfer(input: TransferProjectsInput): Promise<Outcome<void, DThrow>>;\n\ttransfer<Throw extends boolean = DThrow>(\n\t\tinput: TransferProjectsInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tasync transfer(\n\t\tinput: TransferProjectsInput,\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\tconst fromOrgId = input.fromOrgId ?? this.#ctx.defaults.orgId;\n\t\tif (!fromOrgId) {\n\t\t\treturn finalize(\n\t\t\t\terr<void>(\n\t\t\t\t\tnew NeonError(\n\t\t\t\t\t\t\"Pass fromOrgId or set orgId on the client.\",\n\t\t\t\t\t\t\"client\",\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tshouldThrow,\n\t\t\t);\n\t\t}\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\ttransferProjectsFromOrgToOrg({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { source_org_id: fromOrgId },\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tdestination_org_id: input.toOrgId,\n\t\t\t\t\t\tproject_ids: input.projectIds,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t() => undefined,\n\t\t);\n\t}\n\n\t/**\n\t * Transfer projects from the personal account to an organization.\n\t *\n\t * @apiCall POST /users/me/projects/transfer\n\t */\n\ttransferFromUser(input: {\n\t\ttoOrgId: string;\n\t\tprojectIds: string[];\n\t}): Promise<Outcome<void, DThrow>>;\n\ttransferFromUser<Throw extends boolean = DThrow>(\n\t\tinput: { toOrgId: string; projectIds: string[] },\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\ttransferFromUser(\n\t\tinput: { toOrgId: string; projectIds: string[] },\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\ttransferProjectsFromUserToOrg({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tdestination_org_id: input.toOrgId,\n\t\t\t\t\t\tproject_ids: input.projectIds,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t() => undefined,\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;AAqDA,IAAa,cAAb,MAAiD;CAChD;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAQA,KACC,WACA,MACiE;EACjE,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,uBAAuB;GACtB;GACA,MAAM,EAAE,YAAY,UAAU;GAC9B,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,mBAChB;CACD;CAYA,MACC,WACA,OACA,MAC6D;EAC7D,OAAO,KAAKA,KA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B;GAC5B;GACA,MAAM,EAAE,eAAe,UAAU;GACjC,MAAM;IACL,oBAAoB,MAAM;IAC1B,aAAa,MAAM;GACpB;GACA,cAAc;GACd;EACD,CAAC,SACI,KAAA,CACP;CACD;CAeA,iBACC,OACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,8BAA8B;GAC7B;GACA,MAAM;IACL,oBAAoB,MAAM;IAC1B,aAAa,MAAM;GACpB;GACA,cAAc;GACd;EACD,CAAC,SACI,KAAA,CACP;CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","names":[],"sources":["../../../src/neon/resources/roles.ts"],"mappings":";;;;;KAYK,WAAA,GAAc;;AAAd,cAGQ,KAHG,CAAA,eAAG,OAAiB,CAAA,CAAA;EAGvB,CAAA,OAAK;EAAA,WAAA,CAAA,GAAA,EAGA,cAHA;EAGA;EAK0C,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,CAAA,EAAhB,OAAgB,CAAR,OAAQ,CAAA,IAAA,EAAA,EAAQ,MAAR,CAAA,CAAA;EAAQ,IAAA,CAAA,cAAA,OAAA,GACtC,MADsC,CAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,IAAA,EAI5D,WAJ4D,CAIhD,KAJgD,CAAA,CAAA,EAKhE,OALgE,CAKxD,OALwD,CAKhD,IALgD,EAAA,EAKxC,KALwC,CAAA,CAAA;EAAhB;EAAR,GAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"roles.d.ts","names":[],"sources":["../../../src/neon/resources/roles.ts"],"mappings":";;;;;KAYK,WAAA,GAAc;;AAAd,cAGQ,KAHG,CAAA,eAAG,OAAiB,CAAA,CAAA;EAGvB,CAAA,OAAK;EAAA,WAAA,CAAA,GAAA,EAGA,cAHA;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,EAiHtB,OAjHsB,CAiHd,OAjHc,CAiHN,IAjHM,EAiHA,KAjHA,CAAA,CAAA;AAAd"}
|
|
@@ -7,68 +7,74 @@ var Roles = class {
|
|
|
7
7
|
this.#ctx = ctx;
|
|
8
8
|
}
|
|
9
9
|
list(projectId, branchId, opts) {
|
|
10
|
-
return this.#ctx.run(opts, (client) => listProjectBranchRoles({
|
|
10
|
+
return this.#ctx.run(opts, (client, signal) => listProjectBranchRoles({
|
|
11
11
|
client,
|
|
12
12
|
path: {
|
|
13
13
|
project_id: projectId,
|
|
14
14
|
branch_id: branchId
|
|
15
15
|
},
|
|
16
|
-
throwOnError: false
|
|
16
|
+
throwOnError: false,
|
|
17
|
+
signal
|
|
17
18
|
}), (data) => data.roles);
|
|
18
19
|
}
|
|
19
20
|
get(projectId, branchId, name, opts) {
|
|
20
|
-
return this.#ctx.run(opts, (client) => getProjectBranchRole({
|
|
21
|
+
return this.#ctx.run(opts, (client, signal) => getProjectBranchRole({
|
|
21
22
|
client,
|
|
22
23
|
path: {
|
|
23
24
|
project_id: projectId,
|
|
24
25
|
branch_id: branchId,
|
|
25
26
|
role_name: name
|
|
26
27
|
},
|
|
27
|
-
throwOnError: false
|
|
28
|
+
throwOnError: false,
|
|
29
|
+
signal
|
|
28
30
|
}), (data) => data.role);
|
|
29
31
|
}
|
|
30
32
|
create(projectId, branchId, input, opts) {
|
|
31
|
-
return this.#ctx.run(opts, (client) => createProjectBranchRole({
|
|
33
|
+
return this.#ctx.run(opts, (client, signal) => createProjectBranchRole({
|
|
32
34
|
client,
|
|
33
35
|
path: {
|
|
34
36
|
project_id: projectId,
|
|
35
37
|
branch_id: branchId
|
|
36
38
|
},
|
|
37
39
|
body: { role: input },
|
|
38
|
-
throwOnError: false
|
|
40
|
+
throwOnError: false,
|
|
41
|
+
signal
|
|
39
42
|
}), (data) => data.role);
|
|
40
43
|
}
|
|
41
44
|
delete(projectId, branchId, name, opts) {
|
|
42
|
-
return this.#ctx.runVoid(opts, (client) => deleteProjectBranchRole({
|
|
45
|
+
return this.#ctx.runVoid(opts, (client, signal) => deleteProjectBranchRole({
|
|
43
46
|
client,
|
|
44
47
|
path: {
|
|
45
48
|
project_id: projectId,
|
|
46
49
|
branch_id: branchId,
|
|
47
50
|
role_name: name
|
|
48
51
|
},
|
|
49
|
-
throwOnError: false
|
|
52
|
+
throwOnError: false,
|
|
53
|
+
signal
|
|
50
54
|
}));
|
|
51
55
|
}
|
|
52
56
|
password(projectId, branchId, name, opts) {
|
|
53
|
-
return this.#ctx.run(opts, (client) => getProjectBranchRolePassword({
|
|
57
|
+
return this.#ctx.run(opts, (client, signal) => getProjectBranchRolePassword({
|
|
54
58
|
client,
|
|
55
59
|
path: {
|
|
56
60
|
project_id: projectId,
|
|
57
61
|
branch_id: branchId,
|
|
58
62
|
role_name: name
|
|
59
63
|
},
|
|
60
|
-
throwOnError: false
|
|
64
|
+
throwOnError: false,
|
|
65
|
+
signal
|
|
61
66
|
}), (data) => data.password);
|
|
62
67
|
}
|
|
63
68
|
resetPassword(projectId, branchId, name, opts) {
|
|
64
|
-
return this.#ctx.run(opts, (client) => resetProjectBranchRolePassword({
|
|
69
|
+
return this.#ctx.run(opts, (client, signal) => resetProjectBranchRolePassword({
|
|
65
70
|
client,
|
|
66
71
|
path: {
|
|
67
72
|
project_id: projectId,
|
|
68
73
|
branch_id: branchId,
|
|
69
74
|
role_name: name
|
|
70
75
|
},
|
|
71
|
-
throwOnError: false
|
|
76
|
+
throwOnError: false,
|
|
77
|
+
signal
|
|
72
78
|
}), (data) => data.role);
|
|
73
79
|
}
|
|
74
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.js","names":["#ctx"],"sources":["../../../src/neon/resources/roles.ts"],"sourcesContent":["import {\n\tcreateProjectBranchRole,\n\tdeleteProjectBranchRole,\n\tgetProjectBranchRole,\n\tgetProjectBranchRolePassword,\n\tlistProjectBranchRoles,\n\tresetProjectBranchRolePassword,\n} from \"../../client/sdk.gen.js\";\nimport type { Role, RoleCreateRequest } from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport type { NeonResult, Outcome } from \"../result.js\";\n\ntype CreateInput = RoleCreateRequest[\"role\"];\n\n/** Role resource (branch-scoped). */\nexport class Roles<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/branches/{branch_id}/roles */\n\tlist(projectId: string, branchId: string): Promise<Outcome<Role[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role[], Throw>>;\n\tlist(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts?: CallOptions,\n\t): Promise<Role[] | NeonResult<Role[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tlistProjectBranchRoles({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.roles,\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/branches/{branch_id}/roles/{role_name} */\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<Role, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role, Throw>>;\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<Role | NeonResult<Role>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetProjectBranchRole({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\t\trole_name: name,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.role,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/branches/{branch_id}/roles */\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateInput,\n\t): Promise<Outcome<Role, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role, Throw>>;\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateInput,\n\t\topts?: CallOptions,\n\t): Promise<Role | NeonResult<Role>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tcreateProjectBranchRole({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tbody: { role: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.role,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id}/branches/{branch_id}/roles/{role_name} */\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<void, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\treturn this.#ctx.runVoid(opts, (client) =>\n\t\t\tdeleteProjectBranchRole({\n\t\t\t\tclient,\n\t\t\t\tpath: {\n\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\trole_name: name,\n\t\t\t\t},\n\t\t\t\tthrowOnError: false,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Reveal the role's password.\n\t *\n\t * @apiCall GET /projects/{project_id}/branches/{branch_id}/roles/{role_name}/reveal_password\n\t */\n\tpassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<string, DThrow>>;\n\tpassword<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<string, Throw>>;\n\tpassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<string | NeonResult<string>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetProjectBranchRolePassword({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\t\trole_name: name,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.password,\n\t\t);\n\t}\n\n\t/**\n\t * Reset the role's password; the returned `Role` carries the new `password`.\n\t *\n\t * @apiCall POST /projects/{project_id}/branches/{branch_id}/roles/{role_name}/reset_password\n\t */\n\tresetPassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<Role, DThrow>>;\n\tresetPassword<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role, Throw>>;\n\tresetPassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<Role | NeonResult<Role>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tresetProjectBranchRolePassword({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\t\trole_name: name,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.role,\n\t\t);\n\t}\n}\n"],"mappings":";;;AAeA,IAAa,QAAb,MAA2C;CAC1C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CASA,KACC,WACA,UACA,MACuC;EACvC,OAAO,KAAKA,KAAK,IAChB,OACC,
|
|
1
|
+
{"version":3,"file":"roles.js","names":["#ctx"],"sources":["../../../src/neon/resources/roles.ts"],"sourcesContent":["import {\n\tcreateProjectBranchRole,\n\tdeleteProjectBranchRole,\n\tgetProjectBranchRole,\n\tgetProjectBranchRolePassword,\n\tlistProjectBranchRoles,\n\tresetProjectBranchRolePassword,\n} from \"../../client/sdk.gen.js\";\nimport type { Role, RoleCreateRequest } from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport type { NeonResult, Outcome } from \"../result.js\";\n\ntype CreateInput = RoleCreateRequest[\"role\"];\n\n/** Role resource (branch-scoped). */\nexport class Roles<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/branches/{branch_id}/roles */\n\tlist(projectId: string, branchId: string): Promise<Outcome<Role[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role[], Throw>>;\n\tlist(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts?: CallOptions,\n\t): Promise<Role[] | NeonResult<Role[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tlistProjectBranchRoles({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.roles,\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/branches/{branch_id}/roles/{role_name} */\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<Role, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role, Throw>>;\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<Role | NeonResult<Role>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tgetProjectBranchRole({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\t\trole_name: name,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.role,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/branches/{branch_id}/roles */\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateInput,\n\t): Promise<Outcome<Role, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role, Throw>>;\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateInput,\n\t\topts?: CallOptions,\n\t): Promise<Role | NeonResult<Role>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tcreateProjectBranchRole({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tbody: { role: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.role,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id}/branches/{branch_id}/roles/{role_name} */\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<void, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\treturn this.#ctx.runVoid(opts, (client, signal) =>\n\t\t\tdeleteProjectBranchRole({\n\t\t\t\tclient,\n\t\t\t\tpath: {\n\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\trole_name: name,\n\t\t\t\t},\n\t\t\t\tthrowOnError: false,\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Reveal the role's password.\n\t *\n\t * @apiCall GET /projects/{project_id}/branches/{branch_id}/roles/{role_name}/reveal_password\n\t */\n\tpassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<string, DThrow>>;\n\tpassword<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<string, Throw>>;\n\tpassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<string | NeonResult<string>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tgetProjectBranchRolePassword({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\t\trole_name: name,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.password,\n\t\t);\n\t}\n\n\t/**\n\t * Reset the role's password; the returned `Role` carries the new `password`.\n\t *\n\t * @apiCall POST /projects/{project_id}/branches/{branch_id}/roles/{role_name}/reset_password\n\t */\n\tresetPassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t): Promise<Outcome<Role, DThrow>>;\n\tresetPassword<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Role, Throw>>;\n\tresetPassword(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tname: string,\n\t\topts?: CallOptions,\n\t): Promise<Role | NeonResult<Role>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client, signal) =>\n\t\t\t\tresetProjectBranchRolePassword({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: {\n\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\tbranch_id: branchId,\n\t\t\t\t\t\trole_name: name,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\tsignal,\n\t\t\t\t}),\n\t\t\t(data) => data.role,\n\t\t);\n\t}\n}\n"],"mappings":";;;AAeA,IAAa,QAAb,MAA2C;CAC1C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CASA,KACC,WACA,UACA,MACuC;EACvC,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,uBAAuB;GACtB;GACA,MAAM;IAAE,YAAY;IAAW,WAAW;GAAS;GACnD,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,KAChB;CACD;CAcA,IACC,WACA,UACA,MACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,qBAAqB;GACpB;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,IAChB;CACD;CAcA,OACC,WACA,UACA,OACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,wBAAwB;GACvB;GACA,MAAM;IAAE,YAAY;IAAW,WAAW;GAAS;GACnD,MAAM,EAAE,MAAM,MAAM;GACpB,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,IAChB;CACD;CAcA,OACC,WACA,UACA,MACA,MACmC;EACnC,OAAO,KAAKA,KAAK,QAAQ,OAAO,QAAQ,WACvC,wBAAwB;GACvB;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;GACd;EACD,CAAC,CACF;CACD;CAkBA,SACC,WACA,UACA,MACA,MACuC;EACvC,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,6BAA6B;GAC5B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,QAChB;CACD;CAkBA,cACC,WACA,UACA,MACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,QAAQ,WACR,+BAA+B;GAC9B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;GACd;EACD,CAAC,IACD,SAAS,KAAK,IAChB;CACD;AACD"}
|
|
@@ -8,7 +8,16 @@ import { CallOptions, RequestContext } from "../context.js";
|
|
|
8
8
|
* Inspect a freshly restored (not-yet-finalized) branch and decide whether to commit.
|
|
9
9
|
* Return `true` to finalize the restore, `false` to abort it.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Inspect a restored-but-un-finalized branch and decide whether to commit it.
|
|
13
|
+
*
|
|
14
|
+
* The second argument carries the call's `signal`. The SDK cannot interrupt this callback
|
|
15
|
+
* — it is the caller's own code — so long-running checks should honour the signal
|
|
16
|
+
* themselves; the restore is left un-finalized if the call is cancelled around it.
|
|
17
|
+
*/
|
|
18
|
+
type RestorePreview = (branch: Branch, context: {
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}) => boolean | Promise<boolean>;
|
|
12
21
|
/** Options for {@link Snapshots.create} (point-in-time + naming). */
|
|
13
22
|
interface CreateSnapshotInput {
|
|
14
23
|
/** A name for the snapshot. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshots.d.ts","names":[],"sources":["../../../src/neon/resources/snapshots.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"snapshots.d.ts","names":[],"sources":["../../../src/neon/resources/snapshots.ts"],"mappings":";;;;;;;;AAgCA;AAA0B;AACjB;AACY;AACN;AAAO;AAGtB;AAYA;AAYA;AA6BY,KA3DA,cAAA,GA2DiB,CAAA,MAAA,EA1DpB,MA0DoB,EAAA,OAAA,EAAA;EAOjB,MAAA,CAAA,EAhES,WAgET;AAAuB,CAAA,EAAA,GAAA,OAAA,GA/DpB,OA+DoB,CAAA,OAAA,CAAA;AAAQ;AAAL,UA5DrB,mBAAA,CA4DqB;EAC1B;EAAiB,IAAA,CAAA,EAAA,MAAA;EAIZ;EAMJ,SAAA,CAAA,EAAS,MAAA;EAAA;EAGJ,GAAA,CAAA,EAAA,MAAA;EAKwB;EAAY,SAAA,CAAA,EAAA,MAAA;AAApB;AAAR;AACI,UApEb,mBAAA,CAoEa;EAEV;EAAZ,IAAA,CAAA,EAAA,MAAA;EACY;AAAY;AAApB;AAAR;AAsBM;EACU,SAAA,CAAA,EAAA,MAAA,GAAA,IAAA;AAAU;AAAlB;AAAR,UAlFa,oBAAA,CA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