@neon/sdk 0.0.0 → 0.1.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/LICENSE.md +178 -0
- package/README.md +349 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/client/client/client.gen.d.ts +7 -0
- package/dist/client/client/client.gen.d.ts.map +1 -0
- package/dist/client/client/client.gen.js +176 -0
- package/dist/client/client/client.gen.js.map +1 -0
- package/dist/client/client/index.d.ts +10 -0
- package/dist/client/client/index.js +6 -0
- package/dist/client/client/types.gen.d.ts +124 -0
- package/dist/client/client/types.gen.d.ts.map +1 -0
- package/dist/client/client/types.gen.js +1 -0
- package/dist/client/client/utils.gen.d.ts +42 -0
- package/dist/client/client/utils.gen.d.ts.map +1 -0
- package/dist/client/client/utils.gen.js +179 -0
- package/dist/client/client/utils.gen.js.map +1 -0
- package/dist/client/client.gen.d.ts +18 -0
- package/dist/client/client.gen.d.ts.map +1 -0
- package/dist/client/client.gen.js +8 -0
- package/dist/client/client.gen.js.map +1 -0
- package/dist/client/core/auth.gen.d.ts +29 -0
- package/dist/client/core/auth.gen.d.ts.map +1 -0
- package/dist/client/core/auth.gen.js +12 -0
- package/dist/client/core/auth.gen.js.map +1 -0
- package/dist/client/core/bodySerializer.gen.d.ts +29 -0
- package/dist/client/core/bodySerializer.gen.d.ts.map +1 -0
- package/dist/client/core/bodySerializer.gen.js +33 -0
- package/dist/client/core/bodySerializer.gen.js.map +1 -0
- package/dist/client/core/params.gen.d.ts +46 -0
- package/dist/client/core/params.gen.d.ts.map +1 -0
- package/dist/client/core/params.gen.js +65 -0
- package/dist/client/core/params.gen.js.map +1 -0
- package/dist/client/core/pathSerializer.gen.d.ts +52 -0
- package/dist/client/core/pathSerializer.gen.d.ts.map +1 -0
- package/dist/client/core/pathSerializer.gen.js +82 -0
- package/dist/client/core/pathSerializer.gen.js.map +1 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts +22 -0
- package/dist/client/core/queryKeySerializer.gen.d.ts.map +1 -0
- package/dist/client/core/queryKeySerializer.gen.js +64 -0
- package/dist/client/core/queryKeySerializer.gen.js.map +1 -0
- package/dist/client/core/serverSentEvents.gen.d.ts +88 -0
- package/dist/client/core/serverSentEvents.gen.d.ts.map +1 -0
- package/dist/client/core/serverSentEvents.gen.js +95 -0
- package/dist/client/core/serverSentEvents.gen.js.map +1 -0
- package/dist/client/core/types.gen.d.ts +80 -0
- package/dist/client/core/types.gen.d.ts.map +1 -0
- package/dist/client/core/types.gen.js +1 -0
- package/dist/client/core/utils.gen.d.ts +33 -0
- package/dist/client/core/utils.gen.d.ts.map +1 -0
- package/dist/client/core/utils.gen.js +78 -0
- package/dist/client/core/utils.gen.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +2 -0
- package/dist/client/sdk.gen.d.ts +1362 -0
- package/dist/client/sdk.gen.d.ts.map +1 -0
- package/dist/client/sdk.gen.js +4315 -0
- package/dist/client/sdk.gen.js.map +1 -0
- package/dist/client/types.gen.d.ts +9938 -0
- package/dist/client/types.gen.d.ts.map +1 -0
- package/dist/client/types.gen.js +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +4 -0
- package/dist/neon/client.d.ts +52 -0
- package/dist/neon/client.d.ts.map +1 -0
- package/dist/neon/client.js +40 -0
- package/dist/neon/client.js.map +1 -0
- package/dist/neon/config.d.ts +40 -0
- package/dist/neon/config.d.ts.map +1 -0
- package/dist/neon/config.js +23 -0
- package/dist/neon/config.js.map +1 -0
- package/dist/neon/connection.d.ts +22 -0
- package/dist/neon/connection.d.ts.map +1 -0
- package/dist/neon/connection.js +33 -0
- package/dist/neon/connection.js.map +1 -0
- package/dist/neon/context.d.ts +50 -0
- package/dist/neon/context.d.ts.map +1 -0
- package/dist/neon/context.js +59 -0
- package/dist/neon/context.js.map +1 -0
- package/dist/neon/coverage.d.ts +26 -0
- package/dist/neon/coverage.d.ts.map +1 -0
- package/dist/neon/coverage.js +229 -0
- package/dist/neon/coverage.js.map +1 -0
- package/dist/neon/errors.d.ts +78 -0
- package/dist/neon/errors.d.ts.map +1 -0
- package/dist/neon/errors.js +116 -0
- package/dist/neon/errors.js.map +1 -0
- package/dist/neon/paginate.d.ts +34 -0
- package/dist/neon/paginate.d.ts.map +1 -0
- package/dist/neon/paginate.js +51 -0
- package/dist/neon/paginate.js.map +1 -0
- package/dist/neon/resources/account.d.ts +45 -0
- package/dist/neon/resources/account.d.ts.map +1 -0
- package/dist/neon/resources/account.js +65 -0
- package/dist/neon/resources/account.js.map +1 -0
- package/dist/neon/resources/branches.d.ts +84 -0
- package/dist/neon/resources/branches.d.ts.map +1 -0
- package/dist/neon/resources/branches.js +132 -0
- package/dist/neon/resources/branches.js.map +1 -0
- package/dist/neon/resources/consumption.d.ts +22 -0
- package/dist/neon/resources/consumption.d.ts.map +1 -0
- package/dist/neon/resources/consumption.js +59 -0
- package/dist/neon/resources/consumption.js.map +1 -0
- package/dist/neon/resources/dataapi.d.ts +25 -0
- package/dist/neon/resources/dataapi.d.ts.map +1 -0
- package/dist/neon/resources/dataapi.js +59 -0
- package/dist/neon/resources/dataapi.js.map +1 -0
- package/dist/neon/resources/databases.d.ts +30 -0
- package/dist/neon/resources/databases.d.ts.map +1 -0
- package/dist/neon/resources/databases.js +68 -0
- package/dist/neon/resources/databases.js.map +1 -0
- package/dist/neon/resources/endpoints.d.ts +39 -0
- package/dist/neon/resources/endpoints.d.ts.map +1 -0
- package/dist/neon/resources/endpoints.js +89 -0
- package/dist/neon/resources/endpoints.js.map +1 -0
- package/dist/neon/resources/operations.d.ts +27 -0
- package/dist/neon/resources/operations.d.ts.map +1 -0
- package/dist/neon/resources/operations.js +50 -0
- package/dist/neon/resources/operations.js.map +1 -0
- package/dist/neon/resources/postgres.d.ts +45 -0
- package/dist/neon/resources/postgres.d.ts.map +1 -0
- package/dist/neon/resources/postgres.js +104 -0
- package/dist/neon/resources/postgres.js.map +1 -0
- package/dist/neon/resources/projects.d.ts +84 -0
- package/dist/neon/resources/projects.d.ts.map +1 -0
- package/dist/neon/resources/projects.js +111 -0
- package/dist/neon/resources/projects.js.map +1 -0
- package/dist/neon/resources/roles.d.ts +40 -0
- package/dist/neon/resources/roles.d.ts.map +1 -0
- package/dist/neon/resources/roles.js +78 -0
- package/dist/neon/resources/roles.js.map +1 -0
- package/dist/neon/resources/snapshots.d.ts +86 -0
- package/dist/neon/resources/snapshots.d.ts.map +1 -0
- package/dist/neon/resources/snapshots.js +125 -0
- package/dist/neon/resources/snapshots.js.map +1 -0
- package/dist/neon/result.d.ts +32 -0
- package/dist/neon/result.d.ts.map +1 -0
- package/dist/neon/result.js +26 -0
- package/dist/neon/result.js.map +1 -0
- package/dist/neon/retry.d.ts +17 -0
- package/dist/neon/retry.d.ts.map +1 -0
- package/dist/neon/retry.js +42 -0
- package/dist/neon/retry.js.map +1 -0
- package/dist/neon/wait.d.ts +27 -0
- package/dist/neon/wait.d.ts.map +1 -0
- package/dist/neon/wait.js +70 -0
- package/dist/neon/wait.js.map +1 -0
- package/dist/raw.d.ts +13 -0
- package/dist/raw.d.ts.map +1 -0
- package/dist/raw.js +159 -0
- package/dist/raw.js.map +1 -0
- package/package.json +57 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginate.js","names":["#fetchPage","#mapPage","#signal"],"sources":["../../src/neon/paginate.ts"],"sourcesContent":["import { toNeonError } from \"./errors.js\";\nimport { err, type NeonResult, ok } from \"./result.js\";\n\nexport interface Page<T> {\n\titems: T[];\n\t/** Cursor for the next page, when more results exist. */\n\tcursor?: string;\n}\n\ninterface RawResult<D> {\n\tdata?: D | undefined;\n\terror?: unknown;\n\tresponse?: Response | undefined;\n}\n\n/**\n * A lazy, cursor-paginated list. `all()` / `page()` return the `{ data, error }` envelope;\n * the async iterator streams items lazily and throws on a page-fetch error.\n *\n * Note: pagination helpers always use the result envelope (the iterator is the throwing\n * form) regardless of the client's `throwOnError` setting.\n */\nexport interface Paginated<T> extends AsyncIterable<T> {\n\t/** Fetch a single page (optionally from a cursor). */\n\tpage(cursor?: string): Promise<NeonResult<Page<T>>>;\n\t/** Fetch and concatenate every page. */\n\tall(): Promise<NeonResult<T[]>>;\n}\n\nclass PaginatedList<T, D> implements Paginated<T> {\n\treadonly #fetchPage: (\n\t\tcursor: string | undefined,\n\t\tsignal?: AbortSignal,\n\t) => Promise<RawResult<D>>;\n\treadonly #mapPage: (data: D) => Page<T>;\n\treadonly #signal?: AbortSignal;\n\n\tconstructor(\n\t\tfetchPage: (\n\t\t\tcursor: string | undefined,\n\t\t\tsignal?: AbortSignal,\n\t\t) => Promise<RawResult<D>>,\n\t\tmapPage: (data: D) => Page<T>,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\tthis.#fetchPage = fetchPage;\n\t\tthis.#mapPage = mapPage;\n\t\tthis.#signal = signal;\n\t}\n\n\tasync page(cursor?: string): Promise<NeonResult<Page<T>>> {\n\t\tconst raw = await this.#fetchPage(cursor, this.#signal);\n\t\tif (raw.error || raw.data === undefined) {\n\t\t\treturn err(toNeonError(raw.error, raw.response));\n\t\t}\n\t\treturn ok(this.#mapPage(raw.data));\n\t}\n\n\tasync all(): Promise<NeonResult<T[]>> {\n\t\tconst items: T[] = [];\n\t\tlet cursor: string | undefined;\n\t\twhile (true) {\n\t\t\tconst result = await this.page(cursor);\n\t\t\tif (result.error) return err(result.error);\n\t\t\titems.push(...result.data.items);\n\t\t\tif (!result.data.cursor || result.data.items.length === 0) break;\n\t\t\tcursor = result.data.cursor;\n\t\t}\n\t\treturn ok(items);\n\t}\n\n\tasync *[Symbol.asyncIterator](): AsyncIterator<T> {\n\t\tlet cursor: string | undefined;\n\t\twhile (true) {\n\t\t\tconst result = await this.page(cursor);\n\t\t\tif (result.error) throw result.error;\n\t\t\tyield* result.data.items;\n\t\t\tif (!result.data.cursor || result.data.items.length === 0) break;\n\t\t\tcursor = result.data.cursor;\n\t\t}\n\t}\n}\n\n/**\n * Build a {@link Paginated} list from a page fetcher and a page mapper. The response-body\n * type `D` is inferred and erased from the public `Paginated<T>` return.\n */\nexport function paginate<T, D>(\n\tfetchPage: (\n\t\tcursor: string | undefined,\n\t\tsignal?: AbortSignal,\n\t) => Promise<RawResult<D>>,\n\tmapPage: (data: D) => Page<T>,\n\tsignal?: AbortSignal,\n): Paginated<T> {\n\treturn new PaginatedList(fetchPage, mapPage, signal);\n}\n"],"mappings":";;;AA6BA,IAAM,gBAAN,MAAkD;CACjD;CAIA;CACA;CAEA,YACC,WAIA,SACA,QACC;EACD,KAAKA,aAAa;EAClB,KAAKC,WAAW;EAChB,KAAKC,UAAU;CAChB;CAEA,MAAM,KAAK,QAA+C;EACzD,MAAM,MAAM,MAAM,KAAKF,WAAW,QAAQ,KAAKE,OAAO;EACtD,IAAI,IAAI,SAAS,IAAI,SAAS,KAAA,GAC7B,OAAO,IAAI,YAAY,IAAI,OAAO,IAAI,QAAQ,CAAC;EAEhD,OAAO,GAAG,KAAKD,SAAS,IAAI,IAAI,CAAC;CAClC;CAEA,MAAM,MAAgC;EACrC,MAAM,QAAa,CAAC;EACpB,IAAI;EACJ,OAAO,MAAM;GACZ,MAAM,SAAS,MAAM,KAAK,KAAK,MAAM;GACrC,IAAI,OAAO,OAAO,OAAO,IAAI,OAAO,KAAK;GACzC,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK;GAC/B,IAAI,CAAC,OAAO,KAAK,UAAU,OAAO,KAAK,MAAM,WAAW,GAAG;GAC3D,SAAS,OAAO,KAAK;EACtB;EACA,OAAO,GAAG,KAAK;CAChB;CAEA,QAAQ,OAAO,iBAAmC;EACjD,IAAI;EACJ,OAAO,MAAM;GACZ,MAAM,SAAS,MAAM,KAAK,KAAK,MAAM;GACrC,IAAI,OAAO,OAAO,MAAM,OAAO;GAC/B,OAAO,OAAO,KAAK;GACnB,IAAI,CAAC,OAAO,KAAK,UAAU,OAAO,KAAK,MAAM,WAAW,GAAG;GAC3D,SAAS,OAAO,KAAK;EACtB;CACD;AACD;;;;;AAMA,SAAgB,SACf,WAIA,SACA,QACe;CACf,OAAO,IAAI,cAAc,WAAW,SAAS,MAAM;AACpD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ApiKeyCreateResponse, ApiKeyRevokeResponse, ApiKeysListResponseItem, CurrentUserInfoResponse, Organization, RegionResponse } from "../../client/types.gen.js";
|
|
2
|
+
import { Outcome } from "../result.js";
|
|
3
|
+
import { CallOptions, RequestContext } from "../context.js";
|
|
4
|
+
|
|
5
|
+
//#region src/neon/resources/account.d.ts
|
|
6
|
+
/** Current user / account resource. */
|
|
7
|
+
declare class User<DThrow extends boolean> {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(ctx: RequestContext);
|
|
10
|
+
/** @apiCall GET /users/me */
|
|
11
|
+
me(): Promise<Outcome<CurrentUserInfoResponse, DThrow>>;
|
|
12
|
+
me<Throw extends boolean = DThrow>(opts: CallOptions<Throw>): Promise<Outcome<CurrentUserInfoResponse, Throw>>;
|
|
13
|
+
/** @apiCall GET /users/me/organizations */
|
|
14
|
+
organizations(): Promise<Outcome<Organization[], DThrow>>;
|
|
15
|
+
organizations<Throw extends boolean = DThrow>(opts: CallOptions<Throw>): Promise<Outcome<Organization[], Throw>>;
|
|
16
|
+
}
|
|
17
|
+
/** Active regions. */
|
|
18
|
+
declare class Regions<DThrow extends boolean> {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(ctx: RequestContext);
|
|
21
|
+
/** @apiCall GET /regions */
|
|
22
|
+
list(): Promise<Outcome<RegionResponse[], DThrow>>;
|
|
23
|
+
list<Throw extends boolean = DThrow>(opts: CallOptions<Throw>): Promise<Outcome<RegionResponse[], Throw>>;
|
|
24
|
+
}
|
|
25
|
+
/** Account API keys. */
|
|
26
|
+
declare class ApiKeys<DThrow extends boolean> {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(ctx: RequestContext);
|
|
29
|
+
/** @apiCall GET /api_keys */
|
|
30
|
+
list(): Promise<Outcome<ApiKeysListResponseItem[], DThrow>>;
|
|
31
|
+
list<Throw extends boolean = DThrow>(opts: CallOptions<Throw>): Promise<Outcome<ApiKeysListResponseItem[], Throw>>;
|
|
32
|
+
/**
|
|
33
|
+
* Create an API key. The returned `key` token is shown **once** — store it now.
|
|
34
|
+
*
|
|
35
|
+
* @apiCall POST /api_keys
|
|
36
|
+
*/
|
|
37
|
+
create(keyName: string): Promise<Outcome<ApiKeyCreateResponse, DThrow>>;
|
|
38
|
+
create<Throw extends boolean = DThrow>(keyName: string, opts: CallOptions<Throw>): Promise<Outcome<ApiKeyCreateResponse, Throw>>;
|
|
39
|
+
/** @apiCall DELETE /api_keys/{key_id} */
|
|
40
|
+
revoke(keyId: number): Promise<Outcome<ApiKeyRevokeResponse, DThrow>>;
|
|
41
|
+
revoke<Throw extends boolean = DThrow>(keyId: number, opts: CallOptions<Throw>): Promise<Outcome<ApiKeyRevokeResponse, Throw>>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { ApiKeys, Regions, User };
|
|
45
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","names":[],"sources":["../../../src/neon/resources/account.ts"],"mappings":";;;;;;cAoBa;EAAA,CAAA,OAAI;EAAA,WAAA,CAAA,GAAA,EAGC,cAHD;;MAQM,EAAhB,OAAgB,CAAR,OAAQ,CAAA,uBAAA,EAAyB,MAAzB,CAAA,CAAA;KAAyB,cAAA,OAAA,GACpB,MADoB,CAAA,CAAA,IAAA,EAExC,WAFwC,CAE5B,KAF4B,CAAA,CAAA,EAG5C,OAH4C,CAGpC,OAHoC,CAG5B,uBAH4B,EAGH,KAHG,CAAA,CAAA;;eAAzC,CAAA,CAAA,EAeW,OAfX,CAemB,OAfnB,CAe2B,YAf3B,EAAA,EAe2C,MAf3C,CAAA,CAAA;eACqB,CAAA,cAAA,OAAA,GAeW,MAfX,CAAA,CAAA,IAAA,EAgBpB,WAhBoB,CAgBR,KAhBQ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AA,EAmEe,OAnEf,CAmEuB,OAnEvB,CAmE+B,oBAnE/B,EAmEqD,MAnErD,CAAA,CAAA;QACqB,CAAA,cAAA,OAAA,GAmEE,MAnEF,CAAA,CAAA,KAAA,EAAA,MAAA,EAAA,IAAA,EAqEtB,WArEsB,CAqEV,KArEU,CAAA,CAAA,EAsE1B,OAtE0B,CAsElB,OAtEkB,CAsEV,oBAtEU,EAsEY,KAtEZ,CAAA,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createApiKey, getActiveRegions, getCurrentUserInfo, getCurrentUserOrganizations, listApiKeys, revokeApiKey } from "../../client/sdk.gen.js";
|
|
2
|
+
//#region src/neon/resources/account.ts
|
|
3
|
+
/** Current user / account resource. */
|
|
4
|
+
var User = class {
|
|
5
|
+
#ctx;
|
|
6
|
+
constructor(ctx) {
|
|
7
|
+
this.#ctx = ctx;
|
|
8
|
+
}
|
|
9
|
+
me(opts) {
|
|
10
|
+
return this.#ctx.run(opts, (client) => getCurrentUserInfo({
|
|
11
|
+
client,
|
|
12
|
+
throwOnError: false
|
|
13
|
+
}), (data) => data);
|
|
14
|
+
}
|
|
15
|
+
organizations(opts) {
|
|
16
|
+
return this.#ctx.run(opts, (client) => getCurrentUserOrganizations({
|
|
17
|
+
client,
|
|
18
|
+
throwOnError: false
|
|
19
|
+
}), (data) => data.organizations);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/** Active regions. */
|
|
23
|
+
var Regions = class {
|
|
24
|
+
#ctx;
|
|
25
|
+
constructor(ctx) {
|
|
26
|
+
this.#ctx = ctx;
|
|
27
|
+
}
|
|
28
|
+
list(opts) {
|
|
29
|
+
return this.#ctx.run(opts, (client) => getActiveRegions({
|
|
30
|
+
client,
|
|
31
|
+
throwOnError: false
|
|
32
|
+
}), (data) => data.regions);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
/** Account API keys. */
|
|
36
|
+
var ApiKeys = class {
|
|
37
|
+
#ctx;
|
|
38
|
+
constructor(ctx) {
|
|
39
|
+
this.#ctx = ctx;
|
|
40
|
+
}
|
|
41
|
+
list(opts) {
|
|
42
|
+
return this.#ctx.run(opts, (client) => listApiKeys({
|
|
43
|
+
client,
|
|
44
|
+
throwOnError: false
|
|
45
|
+
}), (data) => data);
|
|
46
|
+
}
|
|
47
|
+
create(keyName, opts) {
|
|
48
|
+
return this.#ctx.run(opts, (client) => createApiKey({
|
|
49
|
+
client,
|
|
50
|
+
body: { key_name: keyName },
|
|
51
|
+
throwOnError: false
|
|
52
|
+
}), (data) => data);
|
|
53
|
+
}
|
|
54
|
+
revoke(keyId, opts) {
|
|
55
|
+
return this.#ctx.run(opts, (client) => revokeApiKey({
|
|
56
|
+
client,
|
|
57
|
+
path: { key_id: keyId },
|
|
58
|
+
throwOnError: false
|
|
59
|
+
}), (data) => data);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { ApiKeys, Regions, User };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","names":["#ctx"],"sources":["../../../src/neon/resources/account.ts"],"sourcesContent":["import {\n\tcreateApiKey,\n\tgetActiveRegions,\n\tgetCurrentUserInfo,\n\tgetCurrentUserOrganizations,\n\tlistApiKeys,\n\trevokeApiKey,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tApiKeyCreateResponse,\n\tApiKeyRevokeResponse,\n\tApiKeysListResponseItem,\n\tCurrentUserInfoResponse,\n\tOrganization,\n\tRegionResponse,\n} from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport type { NeonResult, Outcome } from \"../result.js\";\n\n/** Current user / account resource. */\nexport class User<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /users/me */\n\tme(): Promise<Outcome<CurrentUserInfoResponse, DThrow>>;\n\tme<Throw extends boolean = DThrow>(\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<CurrentUserInfoResponse, Throw>>;\n\tme(\n\t\topts?: CallOptions,\n\t): Promise<CurrentUserInfoResponse | NeonResult<CurrentUserInfoResponse>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) => getCurrentUserInfo({ client, throwOnError: false }),\n\t\t\t(data) => data,\n\t\t);\n\t}\n\n\t/** @apiCall GET /users/me/organizations */\n\torganizations(): Promise<Outcome<Organization[], DThrow>>;\n\torganizations<Throw extends boolean = DThrow>(\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Organization[], Throw>>;\n\torganizations(\n\t\topts?: CallOptions,\n\t): Promise<Organization[] | NeonResult<Organization[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetCurrentUserOrganizations({ client, throwOnError: false }),\n\t\t\t(data) => data.organizations,\n\t\t);\n\t}\n}\n\n/** Active regions. */\nexport class Regions<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /regions */\n\tlist(): Promise<Outcome<RegionResponse[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<RegionResponse[], Throw>>;\n\tlist(\n\t\topts?: CallOptions,\n\t): Promise<RegionResponse[] | NeonResult<RegionResponse[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) => getActiveRegions({ client, throwOnError: false }),\n\t\t\t(data) => data.regions,\n\t\t);\n\t}\n}\n\n/** Account API keys. */\nexport class ApiKeys<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /api_keys */\n\tlist(): Promise<Outcome<ApiKeysListResponseItem[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ApiKeysListResponseItem[], Throw>>;\n\tlist(\n\t\topts?: CallOptions,\n\t): Promise<\n\t\tApiKeysListResponseItem[] | NeonResult<ApiKeysListResponseItem[]>\n\t> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) => listApiKeys({ client, throwOnError: false }),\n\t\t\t(data) => data,\n\t\t);\n\t}\n\n\t/**\n\t * Create an API key. The returned `key` token is shown **once** — store it now.\n\t *\n\t * @apiCall POST /api_keys\n\t */\n\tcreate(keyName: string): Promise<Outcome<ApiKeyCreateResponse, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tkeyName: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ApiKeyCreateResponse, Throw>>;\n\tcreate(\n\t\tkeyName: string,\n\t\topts?: CallOptions,\n\t): Promise<ApiKeyCreateResponse | NeonResult<ApiKeyCreateResponse>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tcreateApiKey({\n\t\t\t\t\tclient,\n\t\t\t\t\tbody: { key_name: keyName },\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 /api_keys/{key_id} */\n\trevoke(keyId: number): Promise<Outcome<ApiKeyRevokeResponse, DThrow>>;\n\trevoke<Throw extends boolean = DThrow>(\n\t\tkeyId: number,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<ApiKeyRevokeResponse, Throw>>;\n\trevoke(\n\t\tkeyId: number,\n\t\topts?: CallOptions,\n\t): Promise<ApiKeyRevokeResponse | NeonResult<ApiKeyRevokeResponse>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\trevokeApiKey({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { key_id: keyId },\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"],"mappings":";;;AAoBA,IAAa,OAAb,MAA0C;CACzC;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAOA,GACC,MACyE;EACzE,OAAO,KAAKA,KAAK,IAChB,OACC,WAAW,mBAAmB;GAAE;GAAQ,cAAc;EAAM,CAAC,IAC7D,SAAS,IACX;CACD;CAOA,cACC,MACuD;EACvD,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,4BAA4B;GAAE;GAAQ,cAAc;EAAM,CAAC,IAC3D,SAAS,KAAK,aAChB;CACD;AACD;;AAGA,IAAa,UAAb,MAA6C;CAC5C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAOA,KACC,MAC2D;EAC3D,OAAO,KAAKA,KAAK,IAChB,OACC,WAAW,iBAAiB;GAAE;GAAQ,cAAc;EAAM,CAAC,IAC3D,SAAS,KAAK,OAChB;CACD;AACD;;AAGA,IAAa,UAAb,MAA6C;CAC5C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAOA,KACC,MAGC;EACD,OAAO,KAAKA,KAAK,IAChB,OACC,WAAW,YAAY;GAAE;GAAQ,cAAc;EAAM,CAAC,IACtD,SAAS,IACX;CACD;CAYA,OACC,SACA,MACmE;EACnE,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,aAAa;GACZ;GACA,MAAM,EAAE,UAAU,QAAQ;GAC1B,cAAc;EACf,CAAC,IACD,SAAS,IACX;CACD;CAQA,OACC,OACA,MACmE;EACnE,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,aAAa;GACZ;GACA,MAAM,EAAE,QAAQ,MAAM;GACtB,cAAc;EACf,CAAC,IACD,SAAS,IACX;CACD;AACD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Branch, BranchCreateRequest, BranchUpdateRequest, Endpoint, ListProjectBranchesData } from "../../client/types.gen.js";
|
|
2
|
+
import { Outcome } from "../result.js";
|
|
3
|
+
import { CallOptions, RequestContext } from "../context.js";
|
|
4
|
+
import { Paginated } from "../paginate.js";
|
|
5
|
+
|
|
6
|
+
//#region src/neon/resources/branches.d.ts
|
|
7
|
+
type ListQuery = Omit<NonNullable<ListProjectBranchesData["query"]>, "cursor">;
|
|
8
|
+
type CreateInput = NonNullable<BranchCreateRequest["branch"]>;
|
|
9
|
+
type UpdateInput = BranchUpdateRequest["branch"];
|
|
10
|
+
/** Per-call options for the connect/compute workflows. */
|
|
11
|
+
interface WorkflowOptions<Throw extends boolean> extends CallOptions<Throw> {
|
|
12
|
+
/** Return a pooled connection string (default `true`). */
|
|
13
|
+
pooled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Input for {@link Branches.createWithCompute}. */
|
|
16
|
+
interface CreateWithComputeInput {
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Parent branch id. Defaults to the project's default branch. */
|
|
19
|
+
parentId?: string;
|
|
20
|
+
/** Autoscaling settings for the branch's read-write endpoint. */
|
|
21
|
+
compute?: {
|
|
22
|
+
minCu?: number;
|
|
23
|
+
maxCu?: number;
|
|
24
|
+
suspendTimeoutSeconds?: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** A branch with its read-write endpoint and a ready-to-use connection string. */
|
|
28
|
+
interface BranchWithCompute {
|
|
29
|
+
branch: Branch;
|
|
30
|
+
endpoint: Endpoint;
|
|
31
|
+
connectionString: string;
|
|
32
|
+
}
|
|
33
|
+
/** Branch resource — one API call per CRUD method, plus the `createWithCompute` workflow. */
|
|
34
|
+
declare class Branches<DThrow extends boolean> {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(ctx: RequestContext);
|
|
37
|
+
/** @apiCall GET /projects/{project_id}/branches (cursor-paginated) */
|
|
38
|
+
list(projectId: string, query?: ListQuery): Paginated<Branch>;
|
|
39
|
+
/** @apiCall GET /projects/{project_id}/branches/{branch_id} */
|
|
40
|
+
get(projectId: string, branchId: string): Promise<Outcome<Branch, DThrow>>;
|
|
41
|
+
get<Throw extends boolean = DThrow>(projectId: string, branchId: string, opts: CallOptions<Throw>): Promise<Outcome<Branch, Throw>>;
|
|
42
|
+
/** @apiCall POST /projects/{project_id}/branches */
|
|
43
|
+
create(projectId: string, input?: CreateInput): Promise<Outcome<Branch, DThrow>>;
|
|
44
|
+
create<Throw extends boolean = DThrow>(projectId: string, input: CreateInput | undefined, opts: CallOptions<Throw>): Promise<Outcome<Branch, Throw>>;
|
|
45
|
+
/** @apiCall PATCH /projects/{project_id}/branches/{branch_id} */
|
|
46
|
+
update(projectId: string, branchId: string, input: UpdateInput): Promise<Outcome<Branch, DThrow>>;
|
|
47
|
+
update<Throw extends boolean = DThrow>(projectId: string, branchId: string, input: UpdateInput, opts: CallOptions<Throw>): Promise<Outcome<Branch, Throw>>;
|
|
48
|
+
/** @apiCall DELETE /projects/{project_id}/branches/{branch_id} */
|
|
49
|
+
delete(projectId: string, branchId: string): Promise<Outcome<void, DThrow>>;
|
|
50
|
+
delete<Throw extends boolean = DThrow>(projectId: string, branchId: string, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a branch **with a read-write endpoint** and return a ready-to-use connection
|
|
53
|
+
* string. One API call (Neon creates the endpoint inline) plus readiness polling.
|
|
54
|
+
*
|
|
55
|
+
* @workflow createProjectBranch (with endpoint) + waitForReadiness
|
|
56
|
+
*/
|
|
57
|
+
createWithCompute(projectId: string, input: CreateWithComputeInput): Promise<Outcome<BranchWithCompute, DThrow>>;
|
|
58
|
+
createWithCompute<Throw extends boolean = DThrow>(projectId: string, input: CreateWithComputeInput, opts: WorkflowOptions<Throw>): Promise<Outcome<BranchWithCompute, Throw>>;
|
|
59
|
+
/**
|
|
60
|
+
* Resolve the project's default branch (by the `default` flag — not by name).
|
|
61
|
+
* Returns a `client`-kind {@link NeonError} when no default branch is found.
|
|
62
|
+
*/
|
|
63
|
+
getDefault(projectId: string): Promise<Outcome<Branch, DThrow>>;
|
|
64
|
+
getDefault<Throw extends boolean = DThrow>(projectId: string, opts: CallOptions<Throw>): Promise<Outcome<Branch, Throw>>;
|
|
65
|
+
/** @apiCall POST /projects/{project_id}/branches/{branch_id}/set_as_default */
|
|
66
|
+
setDefault(projectId: string, branchId: string): Promise<Outcome<Branch, DThrow>>;
|
|
67
|
+
setDefault<Throw extends boolean = DThrow>(projectId: string, branchId: string, opts: CallOptions<Throw>): Promise<Outcome<Branch, Throw>>;
|
|
68
|
+
/**
|
|
69
|
+
* Complete (commit) a restore previously started with `snapshots.restore({ finalize: false })`:
|
|
70
|
+
* moves computes onto the restored branch and renames the replaced one. This is **only**
|
|
71
|
+
* the second step — it does not restore anything itself.
|
|
72
|
+
*
|
|
73
|
+
* @apiCall POST /projects/{project_id}/branches/{branch_id}/restore/finalize
|
|
74
|
+
*/
|
|
75
|
+
finalizeRestore(projectId: string, branchId: string, input?: {
|
|
76
|
+
name?: string;
|
|
77
|
+
}): Promise<Outcome<void, DThrow>>;
|
|
78
|
+
finalizeRestore<Throw extends boolean = DThrow>(projectId: string, branchId: string, input: {
|
|
79
|
+
name?: string;
|
|
80
|
+
} | undefined, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { BranchWithCompute, Branches, CreateWithComputeInput };
|
|
84
|
+
//# sourceMappingURL=branches.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branches.d.ts","names":[],"sources":["../../../src/neon/resources/branches.ts"],"mappings":";;;;;;KAsBK,SAAA,GAAY,KAAK,YAAY;KAC7B,WAAA,GAAc,YAAY;AAHiD,KAI3E,WAAA,GAAc,mBAFL,CAAA,QAAA,CAAA;;UAKJ,eALwB,CAAA,cAAA,OAAA,CAAA,SAKuB,WALvB,CAKmC,KALnC,CAAA,CAAA;;QAAjB,CAAA,EAAA,OAAA;AAAI;AAAA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ProjectBranch, listProjectBranches, setDefaultProjectBranch, updateProjectBranch } from "../../client/sdk.gen.js";
|
|
4
|
+
import { withConnectionString } from "../connection.js";
|
|
5
|
+
import { paginate } from "../paginate.js";
|
|
6
|
+
//#region src/neon/resources/branches.ts
|
|
7
|
+
/** Branch resource — one API call per CRUD method, plus the `createWithCompute` workflow. */
|
|
8
|
+
var Branches = class {
|
|
9
|
+
#ctx;
|
|
10
|
+
constructor(ctx) {
|
|
11
|
+
this.#ctx = ctx;
|
|
12
|
+
}
|
|
13
|
+
/** @apiCall GET /projects/{project_id}/branches (cursor-paginated) */
|
|
14
|
+
list(projectId, query) {
|
|
15
|
+
return paginate((cursor, signal) => listProjectBranches({
|
|
16
|
+
client: this.#ctx.client,
|
|
17
|
+
path: { project_id: projectId },
|
|
18
|
+
query: {
|
|
19
|
+
...query,
|
|
20
|
+
cursor
|
|
21
|
+
},
|
|
22
|
+
throwOnError: false,
|
|
23
|
+
signal
|
|
24
|
+
}), (data) => ({
|
|
25
|
+
items: data?.branches ?? [],
|
|
26
|
+
cursor: data?.pagination?.next
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
get(projectId, branchId, opts) {
|
|
30
|
+
return this.#ctx.run(opts, (client) => getProjectBranch({
|
|
31
|
+
client,
|
|
32
|
+
path: {
|
|
33
|
+
project_id: projectId,
|
|
34
|
+
branch_id: branchId
|
|
35
|
+
},
|
|
36
|
+
throwOnError: false
|
|
37
|
+
}), (data) => data.branch);
|
|
38
|
+
}
|
|
39
|
+
create(projectId, input, opts) {
|
|
40
|
+
return this.#ctx.run(opts, (client) => createProjectBranch({
|
|
41
|
+
client,
|
|
42
|
+
path: { project_id: projectId },
|
|
43
|
+
body: { branch: input },
|
|
44
|
+
throwOnError: false
|
|
45
|
+
}), (data) => data.branch);
|
|
46
|
+
}
|
|
47
|
+
update(projectId, branchId, input, opts) {
|
|
48
|
+
return this.#ctx.run(opts, (client) => updateProjectBranch({
|
|
49
|
+
client,
|
|
50
|
+
path: {
|
|
51
|
+
project_id: projectId,
|
|
52
|
+
branch_id: branchId
|
|
53
|
+
},
|
|
54
|
+
body: { branch: input },
|
|
55
|
+
throwOnError: false
|
|
56
|
+
}), (data) => data.branch);
|
|
57
|
+
}
|
|
58
|
+
delete(projectId, branchId, opts) {
|
|
59
|
+
return this.#ctx.runVoid(opts, (client) => deleteProjectBranch({
|
|
60
|
+
client,
|
|
61
|
+
path: {
|
|
62
|
+
project_id: projectId,
|
|
63
|
+
branch_id: branchId
|
|
64
|
+
},
|
|
65
|
+
throwOnError: false
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
async createWithCompute(projectId, input, opts) {
|
|
69
|
+
const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
|
|
70
|
+
return finalize(withConnectionString(await this.#ctx.execute({
|
|
71
|
+
...opts,
|
|
72
|
+
waitForReadiness: opts?.waitForReadiness ?? true
|
|
73
|
+
}, (client) => createProjectBranch({
|
|
74
|
+
client,
|
|
75
|
+
path: { project_id: projectId },
|
|
76
|
+
body: {
|
|
77
|
+
branch: {
|
|
78
|
+
name: input.name,
|
|
79
|
+
parent_id: input.parentId
|
|
80
|
+
},
|
|
81
|
+
endpoints: [{
|
|
82
|
+
type: "read_write",
|
|
83
|
+
autoscaling_limit_min_cu: input.compute?.minCu,
|
|
84
|
+
autoscaling_limit_max_cu: input.compute?.maxCu,
|
|
85
|
+
suspend_timeout_seconds: input.compute?.suspendTimeoutSeconds
|
|
86
|
+
}]
|
|
87
|
+
},
|
|
88
|
+
throwOnError: false
|
|
89
|
+
}), (data) => data), (data) => data.connection_uris, (data, connectionString) => ({
|
|
90
|
+
branch: data.branch,
|
|
91
|
+
endpoint: data.endpoints[0],
|
|
92
|
+
connectionString
|
|
93
|
+
}), opts?.pooled ?? true), shouldThrow);
|
|
94
|
+
}
|
|
95
|
+
async getDefault(projectId, opts) {
|
|
96
|
+
const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
|
|
97
|
+
const result = await this.#ctx.execute(opts, (client) => listProjectBranches({
|
|
98
|
+
client,
|
|
99
|
+
path: { project_id: projectId },
|
|
100
|
+
throwOnError: false
|
|
101
|
+
}), (data) => data.branches);
|
|
102
|
+
if (result.error) return finalize(err(result.error), shouldThrow);
|
|
103
|
+
const branch = result.data.find((candidate) => candidate.default);
|
|
104
|
+
if (!branch) return finalize(err(new NeonError("No default branch found for the project.", "client")), shouldThrow);
|
|
105
|
+
return finalize(ok(branch), shouldThrow);
|
|
106
|
+
}
|
|
107
|
+
setDefault(projectId, branchId, opts) {
|
|
108
|
+
return this.#ctx.run(opts, (client) => setDefaultProjectBranch({
|
|
109
|
+
client,
|
|
110
|
+
path: {
|
|
111
|
+
project_id: projectId,
|
|
112
|
+
branch_id: branchId
|
|
113
|
+
},
|
|
114
|
+
throwOnError: false
|
|
115
|
+
}), (data) => data.branch);
|
|
116
|
+
}
|
|
117
|
+
finalizeRestore(projectId, branchId, input, opts) {
|
|
118
|
+
return this.#ctx.run(opts, (client) => finalizeRestoreBranch({
|
|
119
|
+
client,
|
|
120
|
+
path: {
|
|
121
|
+
project_id: projectId,
|
|
122
|
+
branch_id: branchId
|
|
123
|
+
},
|
|
124
|
+
body: { name: input?.name },
|
|
125
|
+
throwOnError: false
|
|
126
|
+
}), () => void 0);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
export { Branches };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=branches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branches.js","names":["#ctx"],"sources":["../../../src/neon/resources/branches.ts"],"sourcesContent":["import {\n\tcreateProjectBranch,\n\tdeleteProjectBranch,\n\tfinalizeRestoreBranch,\n\tgetProjectBranch,\n\tlistProjectBranches,\n\tsetDefaultProjectBranch,\n\tupdateProjectBranch,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tBranch,\n\tBranchCreateRequest,\n\tBranchUpdateRequest,\n\tEndpoint,\n\tListProjectBranchesData,\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, ok } from \"../result.js\";\n\ntype ListQuery = Omit<NonNullable<ListProjectBranchesData[\"query\"]>, \"cursor\">;\ntype CreateInput = NonNullable<BranchCreateRequest[\"branch\"]>;\ntype UpdateInput = BranchUpdateRequest[\"branch\"];\n\n/** Per-call options for the connect/compute workflows. */\ninterface WorkflowOptions<Throw extends boolean> extends CallOptions<Throw> {\n\t/** Return a pooled connection string (default `true`). */\n\tpooled?: boolean;\n}\n\n/** Input for {@link Branches.createWithCompute}. */\nexport interface CreateWithComputeInput {\n\tname?: string;\n\t/** Parent branch id. Defaults to the project's default branch. */\n\tparentId?: string;\n\t/** Autoscaling settings for the branch's read-write endpoint. */\n\tcompute?: {\n\t\tminCu?: number;\n\t\tmaxCu?: number;\n\t\tsuspendTimeoutSeconds?: number;\n\t};\n}\n\n/** A branch with its read-write endpoint and a ready-to-use connection string. */\nexport interface BranchWithCompute {\n\tbranch: Branch;\n\tendpoint: Endpoint;\n\tconnectionString: string;\n}\n\n/** Branch resource — one API call per CRUD method, plus the `createWithCompute` workflow. */\nexport class Branches<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 (cursor-paginated) */\n\tlist(projectId: string, query?: ListQuery): Paginated<Branch> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tlistProjectBranches({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tquery: { ...query, 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?.branches ?? [],\n\t\t\t\tcursor: data?.pagination?.next,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/branches/{branch_id} */\n\tget(projectId: string, branchId: string): Promise<Outcome<Branch, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Branch, Throw>>;\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts?: CallOptions,\n\t): Promise<Branch | NeonResult<Branch>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetProjectBranch({\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.branch,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/branches */\n\tcreate(\n\t\tprojectId: string,\n\t\tinput?: CreateInput,\n\t): Promise<Outcome<Branch, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tinput: CreateInput | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Branch, Throw>>;\n\tcreate(\n\t\tprojectId: string,\n\t\tinput?: CreateInput,\n\t\topts?: CallOptions,\n\t): Promise<Branch | NeonResult<Branch>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tcreateProjectBranch({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tbody: { branch: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.branch,\n\t\t);\n\t}\n\n\t/** @apiCall PATCH /projects/{project_id}/branches/{branch_id} */\n\tupdate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: UpdateInput,\n\t): Promise<Outcome<Branch, DThrow>>;\n\tupdate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: UpdateInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Branch, Throw>>;\n\tupdate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: UpdateInput,\n\t\topts?: CallOptions,\n\t): Promise<Branch | NeonResult<Branch>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tupdateProjectBranch({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tbody: { branch: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.branch,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id}/branches/{branch_id} */\n\tdelete(projectId: string, branchId: string): Promise<Outcome<void, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts?: CallOptions,\n\t): Promise<void | NeonResult<void>> {\n\t\treturn this.#ctx.runVoid(opts, (client) =>\n\t\t\tdeleteProjectBranch({\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}),\n\t\t);\n\t}\n\n\t/**\n\t * Create a branch **with a read-write endpoint** and return a ready-to-use connection\n\t * string. One API call (Neon creates the endpoint inline) plus readiness polling.\n\t *\n\t * @workflow createProjectBranch (with endpoint) + waitForReadiness\n\t */\n\tcreateWithCompute(\n\t\tprojectId: string,\n\t\tinput: CreateWithComputeInput,\n\t): Promise<Outcome<BranchWithCompute, DThrow>>;\n\tcreateWithCompute<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tinput: CreateWithComputeInput,\n\t\topts: WorkflowOptions<Throw>,\n\t): Promise<Outcome<BranchWithCompute, Throw>>;\n\tasync createWithCompute(\n\t\tprojectId: string,\n\t\tinput: CreateWithComputeInput,\n\t\topts?: WorkflowOptions<boolean>,\n\t): Promise<BranchWithCompute | NeonResult<BranchWithCompute>> {\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\tcreateProjectBranch({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId },\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tbranch: { name: input.name, parent_id: input.parentId },\n\t\t\t\t\t\tendpoints: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"read_write\",\n\t\t\t\t\t\t\t\tautoscaling_limit_min_cu: input.compute?.minCu,\n\t\t\t\t\t\t\t\tautoscaling_limit_max_cu: input.compute?.maxCu,\n\t\t\t\t\t\t\t\tsuspend_timeout_seconds:\n\t\t\t\t\t\t\t\t\tinput.compute?.suspendTimeoutSeconds,\n\t\t\t\t\t\t\t},\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\tbranch: data.branch,\n\t\t\t\tendpoint: data.endpoints[0],\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/**\n\t * Resolve the project's default branch (by the `default` flag — not by name).\n\t * Returns a `client`-kind {@link NeonError} when no default branch is found.\n\t */\n\tgetDefault(projectId: string): Promise<Outcome<Branch, DThrow>>;\n\tgetDefault<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Branch, Throw>>;\n\tasync getDefault(\n\t\tprojectId: string,\n\t\topts?: CallOptions,\n\t): Promise<Branch | NeonResult<Branch>> {\n\t\tconst shouldThrow =\n\t\t\topts?.throwOnError ?? this.#ctx.defaults.throwOnError;\n\t\tconst result = await this.#ctx.execute(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tlistProjectBranches({\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.branches,\n\t\t);\n\t\tif (result.error)\n\t\t\treturn finalize(err<Branch>(result.error), shouldThrow);\n\t\tconst branch = result.data.find((candidate) => candidate.default);\n\t\tif (!branch) {\n\t\t\treturn finalize(\n\t\t\t\terr<Branch>(\n\t\t\t\t\tnew NeonError(\n\t\t\t\t\t\t\"No default branch found for the project.\",\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 finalize(ok(branch), shouldThrow);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/branches/{branch_id}/set_as_default */\n\tsetDefault(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t): Promise<Outcome<Branch, DThrow>>;\n\tsetDefault<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Branch, Throw>>;\n\tsetDefault(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts?: CallOptions,\n\t): Promise<Branch | NeonResult<Branch>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tsetDefaultProjectBranch({\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.branch,\n\t\t);\n\t}\n\n\t/**\n\t * Complete (commit) a restore previously started with `snapshots.restore({ finalize: false })`:\n\t * moves computes onto the restored branch and renames the replaced one. This is **only**\n\t * the second step — it does not restore anything itself.\n\t *\n\t * @apiCall POST /projects/{project_id}/branches/{branch_id}/restore/finalize\n\t */\n\tfinalizeRestore(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput?: { name?: string },\n\t): Promise<Outcome<void, DThrow>>;\n\tfinalizeRestore<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: { name?: string } | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tfinalizeRestore(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput?: { name?: 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\tfinalizeRestoreBranch({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tbody: { name: input?.name },\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,WAAb,MAA8C;CAC7C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;;CAGA,KAAK,WAAmB,OAAsC;EAC7D,OAAO,UACL,QAAQ,WACR,oBAAoB;GACnB,QAAQ,KAAKA,KAAK;GAClB,MAAM,EAAE,YAAY,UAAU;GAC9B,OAAO;IAAE,GAAG;IAAO;GAAO;GAC1B,cAAc;GACd;EACD,CAAC,IACD,UAAU;GACV,OAAO,MAAM,YAAY,CAAC;GAC1B,QAAQ,MAAM,YAAY;EAC3B,EACD;CACD;CASA,IACC,WACA,UACA,MACuC;EACvC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,iBAAiB;GAChB;GACA,MAAM;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,WAAW;CACjC;CAWA,MAAM,WACL,WACA,MACuC;EACvC,MAAM,cACL,MAAM,gBAAgB,KAAKA,KAAK,SAAS;EAC1C,MAAM,SAAS,MAAM,KAAKA,KAAK,QAC9B,OACC,WACA,oBAAoB;GACnB;GACA,MAAM,EAAE,YAAY,UAAU;GAC9B,cAAc;EACf,CAAC,IACD,SAAS,KAAK,QAChB;EACA,IAAI,OAAO,OACV,OAAO,SAAS,IAAY,OAAO,KAAK,GAAG,WAAW;EACvD,MAAM,SAAS,OAAO,KAAK,MAAM,cAAc,UAAU,OAAO;EAChE,IAAI,CAAC,QACJ,OAAO,SACN,IACC,IAAI,UACH,4CACA,QACD,CACD,GACA,WACD;EAED,OAAO,SAAS,GAAG,MAAM,GAAG,WAAW;CACxC;CAYA,WACC,WACA,UACA,MACuC;EACvC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,wBAAwB;GACvB;GACA,MAAM;IAAE,YAAY;IAAW,WAAW;GAAS;GACnD,cAAc;EACf,CAAC,IACD,SAAS,KAAK,MAChB;CACD;CAoBA,gBACC,WACA,UACA,OACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,sBAAsB;GACrB;GACA,MAAM;IAAE,YAAY;IAAW,WAAW;GAAS;GACnD,MAAM,EAAE,MAAM,OAAO,KAAK;GAC1B,cAAc;EACf,CAAC,SACI,KAAA,CACP;CACD;AACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ConsumptionHistoryPerBranchV2, ConsumptionHistoryPerProject, ConsumptionHistoryPerProjectV2, GetConsumptionHistoryPerBranchV2Data, GetConsumptionHistoryPerProjectData, GetConsumptionHistoryPerProjectV2Data } from "../../client/types.gen.js";
|
|
2
|
+
import { RequestContext } from "../context.js";
|
|
3
|
+
import { Paginated } from "../paginate.js";
|
|
4
|
+
|
|
5
|
+
//#region src/neon/resources/consumption.d.ts
|
|
6
|
+
type PerProjectQuery = Omit<GetConsumptionHistoryPerProjectData["query"], "cursor">;
|
|
7
|
+
type PerProjectV2Query = Omit<GetConsumptionHistoryPerProjectV2Data["query"], "cursor">;
|
|
8
|
+
type PerBranchV2Query = Omit<GetConsumptionHistoryPerBranchV2Data["query"], "cursor">;
|
|
9
|
+
/** Consumption history (cursor-paginated). */
|
|
10
|
+
declare class Consumption {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(ctx: RequestContext);
|
|
13
|
+
/** @apiCall GET /consumption_history/projects */
|
|
14
|
+
perProject(query: PerProjectQuery): Paginated<ConsumptionHistoryPerProject>;
|
|
15
|
+
/** @apiCall GET /consumption_history/v2/projects */
|
|
16
|
+
perProjectV2(query: PerProjectV2Query): Paginated<ConsumptionHistoryPerProjectV2>;
|
|
17
|
+
/** @apiCall GET /consumption_history/v2/branches */
|
|
18
|
+
perBranchV2(query: PerBranchV2Query): Paginated<ConsumptionHistoryPerBranchV2>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Consumption };
|
|
22
|
+
//# sourceMappingURL=consumption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumption.d.ts","names":[],"sources":["../../../src/neon/resources/consumption.ts"],"mappings":";;;;;KAgBK,eAAA,GAAkB,KACtB;KAGI,iBAAA,GAAoB,KACxB;AAPyD,KAUrD,gBAAA,GAAmB,IARJ,CASnB,oCATmB,CAAA,OAAA,CAAA,EAAA,QAAA,CAAA;;AACnB,cAaY,WAAA,CAbZ;UADsB;EAAI,WAAA,CAAA,GAAA,EAiBT,cAjBS;EAItB;EAAiB,UAAA,CAAA,KAAA,EAmBb,eAnBa,CAAA,EAoBlB,SApBkB,CAoBR,4BApBQ,CAAA;;cAAG,CAAA,KAAA,EAsChB,iBAtCgB,CAAA,EAuCrB,SAvCqB,CAuCX,8BAvCW,CAAA;EAAI;EAIxB,WAAA,CAAA,KAAA,EAqDI,gBArDY,CAAA,EAsDjB,SAtDiB,CAsDP,6BAtDO,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getConsumptionHistoryPerBranchV2, getConsumptionHistoryPerProject, getConsumptionHistoryPerProjectV2 } from "../../client/sdk.gen.js";
|
|
2
|
+
import { paginate } from "../paginate.js";
|
|
3
|
+
//#region src/neon/resources/consumption.ts
|
|
4
|
+
/** Consumption history (cursor-paginated). */
|
|
5
|
+
var Consumption = class {
|
|
6
|
+
#ctx;
|
|
7
|
+
constructor(ctx) {
|
|
8
|
+
this.#ctx = ctx;
|
|
9
|
+
}
|
|
10
|
+
/** @apiCall GET /consumption_history/projects */
|
|
11
|
+
perProject(query) {
|
|
12
|
+
return paginate((cursor, signal) => getConsumptionHistoryPerProject({
|
|
13
|
+
client: this.#ctx.client,
|
|
14
|
+
query: {
|
|
15
|
+
...query,
|
|
16
|
+
cursor
|
|
17
|
+
},
|
|
18
|
+
throwOnError: false,
|
|
19
|
+
signal
|
|
20
|
+
}), (data) => ({
|
|
21
|
+
items: data?.projects ?? [],
|
|
22
|
+
cursor: data?.pagination?.cursor
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
/** @apiCall GET /consumption_history/v2/projects */
|
|
26
|
+
perProjectV2(query) {
|
|
27
|
+
return paginate((cursor, signal) => getConsumptionHistoryPerProjectV2({
|
|
28
|
+
client: this.#ctx.client,
|
|
29
|
+
query: {
|
|
30
|
+
...query,
|
|
31
|
+
cursor
|
|
32
|
+
},
|
|
33
|
+
throwOnError: false,
|
|
34
|
+
signal
|
|
35
|
+
}), (data) => ({
|
|
36
|
+
items: data?.projects ?? [],
|
|
37
|
+
cursor: data?.pagination?.cursor
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
/** @apiCall GET /consumption_history/v2/branches */
|
|
41
|
+
perBranchV2(query) {
|
|
42
|
+
return paginate((cursor, signal) => getConsumptionHistoryPerBranchV2({
|
|
43
|
+
client: this.#ctx.client,
|
|
44
|
+
query: {
|
|
45
|
+
...query,
|
|
46
|
+
cursor
|
|
47
|
+
},
|
|
48
|
+
throwOnError: false,
|
|
49
|
+
signal
|
|
50
|
+
}), (data) => ({
|
|
51
|
+
items: data?.branches ?? [],
|
|
52
|
+
cursor: data?.pagination?.cursor
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { Consumption };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=consumption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumption.js","names":["#ctx"],"sources":["../../../src/neon/resources/consumption.ts"],"sourcesContent":["import {\n\tgetConsumptionHistoryPerBranchV2,\n\tgetConsumptionHistoryPerProject,\n\tgetConsumptionHistoryPerProjectV2,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tConsumptionHistoryPerBranchV2,\n\tConsumptionHistoryPerProject,\n\tConsumptionHistoryPerProjectV2,\n\tGetConsumptionHistoryPerBranchV2Data,\n\tGetConsumptionHistoryPerProjectData,\n\tGetConsumptionHistoryPerProjectV2Data,\n} from \"../../client/types.gen.js\";\nimport type { RequestContext } from \"../context.js\";\nimport { type Paginated, paginate } from \"../paginate.js\";\n\ntype PerProjectQuery = Omit<\n\tGetConsumptionHistoryPerProjectData[\"query\"],\n\t\"cursor\"\n>;\ntype PerProjectV2Query = Omit<\n\tGetConsumptionHistoryPerProjectV2Data[\"query\"],\n\t\"cursor\"\n>;\ntype PerBranchV2Query = Omit<\n\tGetConsumptionHistoryPerBranchV2Data[\"query\"],\n\t\"cursor\"\n>;\n\n/** Consumption history (cursor-paginated). */\nexport class Consumption {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = ctx;\n\t}\n\n\t/** @apiCall GET /consumption_history/projects */\n\tperProject(\n\t\tquery: PerProjectQuery,\n\t): Paginated<ConsumptionHistoryPerProject> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tgetConsumptionHistoryPerProject({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tquery: { ...query, 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?.projects ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** @apiCall GET /consumption_history/v2/projects */\n\tperProjectV2(\n\t\tquery: PerProjectV2Query,\n\t): Paginated<ConsumptionHistoryPerProjectV2> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tgetConsumptionHistoryPerProjectV2({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tquery: { ...query, 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?.projects ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/** @apiCall GET /consumption_history/v2/branches */\n\tperBranchV2(\n\t\tquery: PerBranchV2Query,\n\t): Paginated<ConsumptionHistoryPerBranchV2> {\n\t\treturn paginate(\n\t\t\t(cursor, signal) =>\n\t\t\t\tgetConsumptionHistoryPerBranchV2({\n\t\t\t\t\tclient: this.#ctx.client,\n\t\t\t\t\tquery: { ...query, 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?.branches ?? [],\n\t\t\t\tcursor: data?.pagination?.cursor,\n\t\t\t}),\n\t\t);\n\t}\n}\n"],"mappings":";;;;AA8BA,IAAa,cAAb,MAAyB;CACxB;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;;CAGA,WACC,OAC0C;EAC1C,OAAO,UACL,QAAQ,WACR,gCAAgC;GAC/B,QAAQ,KAAKA,KAAK;GAClB,OAAO;IAAE,GAAG;IAAO;GAAO;GAC1B,cAAc;GACd;EACD,CAAC,IACD,UAAU;GACV,OAAO,MAAM,YAAY,CAAC;GAC1B,QAAQ,MAAM,YAAY;EAC3B,EACD;CACD;;CAGA,aACC,OAC4C;EAC5C,OAAO,UACL,QAAQ,WACR,kCAAkC;GACjC,QAAQ,KAAKA,KAAK;GAClB,OAAO;IAAE,GAAG;IAAO;GAAO;GAC1B,cAAc;GACd;EACD,CAAC,IACD,UAAU;GACV,OAAO,MAAM,YAAY,CAAC;GAC1B,QAAQ,MAAM,YAAY;EAC3B,EACD;CACD;;CAGA,YACC,OAC2C;EAC3C,OAAO,UACL,QAAQ,WACR,iCAAiC;GAChC,QAAQ,KAAKA,KAAK;GAClB,OAAO;IAAE,GAAG;IAAO;GAAO;GAC1B,cAAc;GACd;EACD,CAAC,IACD,UAAU;GACV,OAAO,MAAM,YAAY,CAAC;GAC1B,QAAQ,MAAM,YAAY;EAC3B,EACD;CACD;AACD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DataApiCreateRequest, DataApiCreateResponse, DataApiReponse, DataApiUpdateRequest } from "../../client/types.gen.js";
|
|
2
|
+
import { Outcome } from "../result.js";
|
|
3
|
+
import { CallOptions, RequestContext } from "../context.js";
|
|
4
|
+
|
|
5
|
+
//#region src/neon/resources/dataapi.d.ts
|
|
6
|
+
/** Neon Data API resource (branch + database scoped). */
|
|
7
|
+
declare class DataApi<DThrow extends boolean> {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(ctx: RequestContext);
|
|
10
|
+
/** @apiCall GET /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */
|
|
11
|
+
get(projectId: string, branchId: string, databaseName: string): Promise<Outcome<DataApiReponse, DThrow>>;
|
|
12
|
+
get<Throw extends boolean = DThrow>(projectId: string, branchId: string, databaseName: string, opts: CallOptions<Throw>): Promise<Outcome<DataApiReponse, Throw>>;
|
|
13
|
+
/** @apiCall POST /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */
|
|
14
|
+
create(projectId: string, branchId: string, databaseName: string, input?: DataApiCreateRequest): Promise<Outcome<DataApiCreateResponse, DThrow>>;
|
|
15
|
+
create<Throw extends boolean = DThrow>(projectId: string, branchId: string, databaseName: string, input: DataApiCreateRequest | undefined, opts: CallOptions<Throw>): Promise<Outcome<DataApiCreateResponse, Throw>>;
|
|
16
|
+
/** @apiCall PATCH /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */
|
|
17
|
+
update(projectId: string, branchId: string, databaseName: string, input?: DataApiUpdateRequest): Promise<Outcome<void, DThrow>>;
|
|
18
|
+
update<Throw extends boolean = DThrow>(projectId: string, branchId: string, databaseName: string, input: DataApiUpdateRequest | undefined, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
|
|
19
|
+
/** @apiCall DELETE /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */
|
|
20
|
+
delete(projectId: string, branchId: string, databaseName: string): Promise<Outcome<void, DThrow>>;
|
|
21
|
+
delete<Throw extends boolean = DThrow>(projectId: string, branchId: string, databaseName: string, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { DataApi };
|
|
25
|
+
//# sourceMappingURL=dataapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataapi.d.ts","names":[],"sources":["../../../src/neon/resources/dataapi.ts"],"mappings":";;;;;;cAgBa;EAAA,CAAA,OAAA;EAAO,WAAA,CAAA,GAAA,EAGF,cAHE;;KAYA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,CAAA,EAAhB,OAAgB,CAAR,OAAQ,CAAA,cAAA,EAAgB,MAAhB,CAAA,CAAA;KAAgB,CAAA,cAAA,OAAA,GACP,MADO,CAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,EAK5B,WAL4B,CAKhB,KALgB,CAAA,CAAA,EAMhC,OANgC,CAMxB,O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EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,EA6GI,WA7GJ,CA6GgB,KA7GhB,CAAA,CAAA,EA8GA,OA9GA,CA8GQ,OA9GR,CAAA,IAAA,EA8GsB,KA9GtB,CAAA,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createProjectBranchDataApi, deleteProjectBranchDataApi, getProjectBranchDataApi, updateProjectBranchDataApi } from "../../client/sdk.gen.js";
|
|
2
|
+
//#region src/neon/resources/dataapi.ts
|
|
3
|
+
/** Neon Data API resource (branch + database scoped). */
|
|
4
|
+
var DataApi = class {
|
|
5
|
+
#ctx;
|
|
6
|
+
constructor(ctx) {
|
|
7
|
+
this.#ctx = ctx;
|
|
8
|
+
}
|
|
9
|
+
get(projectId, branchId, databaseName, opts) {
|
|
10
|
+
return this.#ctx.run(opts, (client) => getProjectBranchDataApi({
|
|
11
|
+
client,
|
|
12
|
+
path: {
|
|
13
|
+
project_id: projectId,
|
|
14
|
+
branch_id: branchId,
|
|
15
|
+
database_name: databaseName
|
|
16
|
+
},
|
|
17
|
+
throwOnError: false
|
|
18
|
+
}), (data) => data);
|
|
19
|
+
}
|
|
20
|
+
create(projectId, branchId, databaseName, input, opts) {
|
|
21
|
+
return this.#ctx.run(opts, (client) => createProjectBranchDataApi({
|
|
22
|
+
client,
|
|
23
|
+
path: {
|
|
24
|
+
project_id: projectId,
|
|
25
|
+
branch_id: branchId,
|
|
26
|
+
database_name: databaseName
|
|
27
|
+
},
|
|
28
|
+
body: input,
|
|
29
|
+
throwOnError: false
|
|
30
|
+
}), (data) => data);
|
|
31
|
+
}
|
|
32
|
+
update(projectId, branchId, databaseName, input, opts) {
|
|
33
|
+
return this.#ctx.run(opts, (client) => updateProjectBranchDataApi({
|
|
34
|
+
client,
|
|
35
|
+
path: {
|
|
36
|
+
project_id: projectId,
|
|
37
|
+
branch_id: branchId,
|
|
38
|
+
database_name: databaseName
|
|
39
|
+
},
|
|
40
|
+
body: input,
|
|
41
|
+
throwOnError: false
|
|
42
|
+
}), () => void 0);
|
|
43
|
+
}
|
|
44
|
+
delete(projectId, branchId, databaseName, opts) {
|
|
45
|
+
return this.#ctx.run(opts, (client) => deleteProjectBranchDataApi({
|
|
46
|
+
client,
|
|
47
|
+
path: {
|
|
48
|
+
project_id: projectId,
|
|
49
|
+
branch_id: branchId,
|
|
50
|
+
database_name: databaseName
|
|
51
|
+
},
|
|
52
|
+
throwOnError: false
|
|
53
|
+
}), () => void 0);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { DataApi };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=dataapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataapi.js","names":["#ctx"],"sources":["../../../src/neon/resources/dataapi.ts"],"sourcesContent":["import {\n\tcreateProjectBranchDataApi,\n\tdeleteProjectBranchDataApi,\n\tgetProjectBranchDataApi,\n\tupdateProjectBranchDataApi,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tDataApiCreateRequest,\n\tDataApiCreateResponse,\n\tDataApiReponse,\n\tDataApiUpdateRequest,\n} from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport type { NeonResult, Outcome } from \"../result.js\";\n\n/** Neon Data API resource (branch + database scoped). */\nexport class DataApi<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}/data-api/{database_name} */\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t): Promise<Outcome<DataApiReponse, DThrow>>;\n\tget<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<DataApiReponse, Throw>>;\n\tget(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\topts?: CallOptions,\n\t): Promise<DataApiReponse | NeonResult<DataApiReponse>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetProjectBranchDataApi({\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\tdatabase_name: databaseName,\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\t/** @apiCall POST /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\tinput?: DataApiCreateRequest,\n\t): Promise<Outcome<DataApiCreateResponse, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\tinput: DataApiCreateRequest | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<DataApiCreateResponse, Throw>>;\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\tinput?: DataApiCreateRequest,\n\t\topts?: CallOptions,\n\t): Promise<DataApiCreateResponse | NeonResult<DataApiCreateResponse>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tcreateProjectBranchDataApi({\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\tdatabase_name: databaseName,\n\t\t\t\t\t},\n\t\t\t\t\tbody: input,\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 PATCH /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */\n\tupdate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\tinput?: DataApiUpdateRequest,\n\t): Promise<Outcome<void, DThrow>>;\n\tupdate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\tinput: DataApiUpdateRequest | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tupdate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\tinput?: DataApiUpdateRequest,\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\tupdateProjectBranchDataApi({\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\tdatabase_name: databaseName,\n\t\t\t\t\t},\n\t\t\t\t\tbody: input,\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/** @apiCall DELETE /projects/{project_id}/branches/{branch_id}/data-api/{database_name} */\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t): Promise<Outcome<void, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tdelete(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tdatabaseName: 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\tdeleteProjectBranchDataApi({\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\tdatabase_name: databaseName,\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":";;;AAgBA,IAAa,UAAb,MAA6C;CAC5C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAcA,IACC,WACA,UACA,cACA,MACuD;EACvD,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,wBAAwB;GACvB;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,eAAe;GAChB;GACA,cAAc;EACf,CAAC,IACD,SAAS,IACX;CACD;CAgBA,OACC,WACA,UACA,cACA,OACA,MACqE;EACrE,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,2BAA2B;GAC1B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,eAAe;GAChB;GACA,MAAM;GACN,cAAc;EACf,CAAC,IACD,SAAS,IACX;CACD;CAgBA,OACC,WACA,UACA,cACA,OACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,2BAA2B;GAC1B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,eAAe;GAChB;GACA,MAAM;GACN,cAAc;EACf,CAAC,SACI,KAAA,CACP;CACD;CAcA,OACC,WACA,UACA,cACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,2BAA2B;GAC1B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,eAAe;GAChB;GACA,cAAc;EACf,CAAC,SACI,KAAA,CACP;CACD;AACD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Database, DatabaseCreateRequest, DatabaseUpdateRequest } from "../../client/types.gen.js";
|
|
2
|
+
import { Outcome } from "../result.js";
|
|
3
|
+
import { CallOptions, RequestContext } from "../context.js";
|
|
4
|
+
|
|
5
|
+
//#region src/neon/resources/databases.d.ts
|
|
6
|
+
type CreateInput = DatabaseCreateRequest["database"];
|
|
7
|
+
type UpdateInput = DatabaseUpdateRequest["database"];
|
|
8
|
+
/** Database resource (branch-scoped). */
|
|
9
|
+
declare class Databases<DThrow extends boolean> {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(ctx: RequestContext);
|
|
12
|
+
/** @apiCall GET /projects/{project_id}/branches/{branch_id}/databases */
|
|
13
|
+
list(projectId: string, branchId: string): Promise<Outcome<Database[], DThrow>>;
|
|
14
|
+
list<Throw extends boolean = DThrow>(projectId: string, branchId: string, opts: CallOptions<Throw>): Promise<Outcome<Database[], Throw>>;
|
|
15
|
+
/** @apiCall GET /projects/{project_id}/branches/{branch_id}/databases/{database_name} */
|
|
16
|
+
get(projectId: string, branchId: string, name: string): Promise<Outcome<Database, DThrow>>;
|
|
17
|
+
get<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, opts: CallOptions<Throw>): Promise<Outcome<Database, Throw>>;
|
|
18
|
+
/** @apiCall POST /projects/{project_id}/branches/{branch_id}/databases */
|
|
19
|
+
create(projectId: string, branchId: string, input: CreateInput): Promise<Outcome<Database, DThrow>>;
|
|
20
|
+
create<Throw extends boolean = DThrow>(projectId: string, branchId: string, input: CreateInput, opts: CallOptions<Throw>): Promise<Outcome<Database, Throw>>;
|
|
21
|
+
/** @apiCall PATCH /projects/{project_id}/branches/{branch_id}/databases/{database_name} */
|
|
22
|
+
update(projectId: string, branchId: string, name: string, input: UpdateInput): Promise<Outcome<Database, DThrow>>;
|
|
23
|
+
update<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, input: UpdateInput, opts: CallOptions<Throw>): Promise<Outcome<Database, Throw>>;
|
|
24
|
+
/** @apiCall DELETE /projects/{project_id}/branches/{branch_id}/databases/{database_name} */
|
|
25
|
+
delete(projectId: string, branchId: string, name: string): Promise<Outcome<void, DThrow>>;
|
|
26
|
+
delete<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { Databases };
|
|
30
|
+
//# sourceMappingURL=databases.d.ts.map
|