@neon/sdk 0.0.0 → 0.2.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.
Files changed (222) hide show
  1. package/LICENSE.md +178 -0
  2. package/README.md +349 -0
  3. package/dist/_virtual/_rolldown/runtime.js +14 -0
  4. package/dist/client/client/client.gen.d.ts +7 -0
  5. package/dist/client/client/client.gen.d.ts.map +1 -0
  6. package/dist/client/client/client.gen.js +176 -0
  7. package/dist/client/client/client.gen.js.map +1 -0
  8. package/dist/client/client/index.d.ts +10 -0
  9. package/dist/client/client/index.js +6 -0
  10. package/dist/client/client/types.gen.d.ts +124 -0
  11. package/dist/client/client/types.gen.d.ts.map +1 -0
  12. package/dist/client/client/types.gen.js +1 -0
  13. package/dist/client/client/utils.gen.d.ts +42 -0
  14. package/dist/client/client/utils.gen.d.ts.map +1 -0
  15. package/dist/client/client/utils.gen.js +179 -0
  16. package/dist/client/client/utils.gen.js.map +1 -0
  17. package/dist/client/client.gen.d.ts +18 -0
  18. package/dist/client/client.gen.d.ts.map +1 -0
  19. package/dist/client/client.gen.js +8 -0
  20. package/dist/client/client.gen.js.map +1 -0
  21. package/dist/client/core/auth.gen.d.ts +29 -0
  22. package/dist/client/core/auth.gen.d.ts.map +1 -0
  23. package/dist/client/core/auth.gen.js +12 -0
  24. package/dist/client/core/auth.gen.js.map +1 -0
  25. package/dist/client/core/bodySerializer.gen.d.ts +29 -0
  26. package/dist/client/core/bodySerializer.gen.d.ts.map +1 -0
  27. package/dist/client/core/bodySerializer.gen.js +33 -0
  28. package/dist/client/core/bodySerializer.gen.js.map +1 -0
  29. package/dist/client/core/params.gen.d.ts +46 -0
  30. package/dist/client/core/params.gen.d.ts.map +1 -0
  31. package/dist/client/core/params.gen.js +65 -0
  32. package/dist/client/core/params.gen.js.map +1 -0
  33. package/dist/client/core/pathSerializer.gen.d.ts +52 -0
  34. package/dist/client/core/pathSerializer.gen.d.ts.map +1 -0
  35. package/dist/client/core/pathSerializer.gen.js +82 -0
  36. package/dist/client/core/pathSerializer.gen.js.map +1 -0
  37. package/dist/client/core/queryKeySerializer.gen.d.ts +22 -0
  38. package/dist/client/core/queryKeySerializer.gen.d.ts.map +1 -0
  39. package/dist/client/core/queryKeySerializer.gen.js +64 -0
  40. package/dist/client/core/queryKeySerializer.gen.js.map +1 -0
  41. package/dist/client/core/serverSentEvents.gen.d.ts +88 -0
  42. package/dist/client/core/serverSentEvents.gen.d.ts.map +1 -0
  43. package/dist/client/core/serverSentEvents.gen.js +95 -0
  44. package/dist/client/core/serverSentEvents.gen.js.map +1 -0
  45. package/dist/client/core/types.gen.d.ts +80 -0
  46. package/dist/client/core/types.gen.d.ts.map +1 -0
  47. package/dist/client/core/types.gen.js +1 -0
  48. package/dist/client/core/utils.gen.d.ts +33 -0
  49. package/dist/client/core/utils.gen.d.ts.map +1 -0
  50. package/dist/client/core/utils.gen.js +78 -0
  51. package/dist/client/core/utils.gen.js.map +1 -0
  52. package/dist/client/index.d.ts +3 -0
  53. package/dist/client/index.js +2 -0
  54. package/dist/client/sdk.gen.d.ts +1362 -0
  55. package/dist/client/sdk.gen.d.ts.map +1 -0
  56. package/dist/client/sdk.gen.js +4315 -0
  57. package/dist/client/sdk.gen.js.map +1 -0
  58. package/dist/client/types.gen.d.ts +9938 -0
  59. package/dist/client/types.gen.d.ts.map +1 -0
  60. package/dist/client/types.gen.js +1 -0
  61. package/dist/index.d.ts +19 -0
  62. package/dist/index.js +4 -0
  63. package/dist/neon/client.d.ts +52 -0
  64. package/dist/neon/client.d.ts.map +1 -0
  65. package/dist/neon/client.js +40 -0
  66. package/dist/neon/client.js.map +1 -0
  67. package/dist/neon/client.test-d.d.ts +1 -0
  68. package/dist/neon/client.test-d.js +76 -0
  69. package/dist/neon/client.test-d.js.map +1 -0
  70. package/dist/neon/config.d.ts +40 -0
  71. package/dist/neon/config.d.ts.map +1 -0
  72. package/dist/neon/config.js +23 -0
  73. package/dist/neon/config.js.map +1 -0
  74. package/dist/neon/connection.d.ts +22 -0
  75. package/dist/neon/connection.d.ts.map +1 -0
  76. package/dist/neon/connection.js +33 -0
  77. package/dist/neon/connection.js.map +1 -0
  78. package/dist/neon/context.d.ts +50 -0
  79. package/dist/neon/context.d.ts.map +1 -0
  80. package/dist/neon/context.js +59 -0
  81. package/dist/neon/context.js.map +1 -0
  82. package/dist/neon/coverage.d.ts +26 -0
  83. package/dist/neon/coverage.d.ts.map +1 -0
  84. package/dist/neon/coverage.js +229 -0
  85. package/dist/neon/coverage.js.map +1 -0
  86. package/dist/neon/errors.d.ts +78 -0
  87. package/dist/neon/errors.d.ts.map +1 -0
  88. package/dist/neon/errors.js +116 -0
  89. package/dist/neon/errors.js.map +1 -0
  90. package/dist/neon/paginate.d.ts +34 -0
  91. package/dist/neon/paginate.d.ts.map +1 -0
  92. package/dist/neon/paginate.js +51 -0
  93. package/dist/neon/paginate.js.map +1 -0
  94. package/dist/neon/resources/account.d.ts +45 -0
  95. package/dist/neon/resources/account.d.ts.map +1 -0
  96. package/dist/neon/resources/account.js +65 -0
  97. package/dist/neon/resources/account.js.map +1 -0
  98. package/dist/neon/resources/branches.d.ts +84 -0
  99. package/dist/neon/resources/branches.d.ts.map +1 -0
  100. package/dist/neon/resources/branches.js +132 -0
  101. package/dist/neon/resources/branches.js.map +1 -0
  102. package/dist/neon/resources/consumption.d.ts +22 -0
  103. package/dist/neon/resources/consumption.d.ts.map +1 -0
  104. package/dist/neon/resources/consumption.js +59 -0
  105. package/dist/neon/resources/consumption.js.map +1 -0
  106. package/dist/neon/resources/dataapi.d.ts +25 -0
  107. package/dist/neon/resources/dataapi.d.ts.map +1 -0
  108. package/dist/neon/resources/dataapi.js +59 -0
  109. package/dist/neon/resources/dataapi.js.map +1 -0
  110. package/dist/neon/resources/databases.d.ts +30 -0
  111. package/dist/neon/resources/databases.d.ts.map +1 -0
  112. package/dist/neon/resources/databases.js +68 -0
  113. package/dist/neon/resources/databases.js.map +1 -0
  114. package/dist/neon/resources/endpoints.d.ts +39 -0
  115. package/dist/neon/resources/endpoints.d.ts.map +1 -0
  116. package/dist/neon/resources/endpoints.js +89 -0
  117. package/dist/neon/resources/endpoints.js.map +1 -0
  118. package/dist/neon/resources/operations.d.ts +27 -0
  119. package/dist/neon/resources/operations.d.ts.map +1 -0
  120. package/dist/neon/resources/operations.js +50 -0
  121. package/dist/neon/resources/operations.js.map +1 -0
  122. package/dist/neon/resources/postgres.d.ts +45 -0
  123. package/dist/neon/resources/postgres.d.ts.map +1 -0
  124. package/dist/neon/resources/postgres.js +104 -0
  125. package/dist/neon/resources/postgres.js.map +1 -0
  126. package/dist/neon/resources/projects.d.ts +84 -0
  127. package/dist/neon/resources/projects.d.ts.map +1 -0
  128. package/dist/neon/resources/projects.js +111 -0
  129. package/dist/neon/resources/projects.js.map +1 -0
  130. package/dist/neon/resources/roles.d.ts +40 -0
  131. package/dist/neon/resources/roles.d.ts.map +1 -0
  132. package/dist/neon/resources/roles.js +78 -0
  133. package/dist/neon/resources/roles.js.map +1 -0
  134. package/dist/neon/resources/snapshots.d.ts +86 -0
  135. package/dist/neon/resources/snapshots.d.ts.map +1 -0
  136. package/dist/neon/resources/snapshots.js +125 -0
  137. package/dist/neon/resources/snapshots.js.map +1 -0
  138. package/dist/neon/result.d.ts +32 -0
  139. package/dist/neon/result.d.ts.map +1 -0
  140. package/dist/neon/result.js +26 -0
  141. package/dist/neon/result.js.map +1 -0
  142. package/dist/neon/retry.d.ts +17 -0
  143. package/dist/neon/retry.d.ts.map +1 -0
  144. package/dist/neon/retry.js +42 -0
  145. package/dist/neon/retry.js.map +1 -0
  146. package/dist/neon/wait.d.ts +27 -0
  147. package/dist/neon/wait.d.ts.map +1 -0
  148. package/dist/neon/wait.js +70 -0
  149. package/dist/neon/wait.js.map +1 -0
  150. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js +879 -0
  151. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.0.9/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
  152. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js +30 -0
  153. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
  154. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js +578 -0
  155. package/dist/node_modules/.pnpm/@vitest_runner@3.0.9/node_modules/@vitest/runner/dist/index.js.map +1 -0
  156. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +92 -0
  157. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js.map +1 -0
  158. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js +43 -0
  159. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
  160. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js +450 -0
  161. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/index.js.map +1 -0
  162. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js +168 -0
  163. package/dist/node_modules/.pnpm/@vitest_utils@3.0.9/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
  164. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js +10 -0
  165. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/branding.js.map +1 -0
  166. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js +109 -0
  167. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/index.js.map +1 -0
  168. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js +10 -0
  169. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/messages.js.map +1 -0
  170. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js +10 -0
  171. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/overloads.js.map +1 -0
  172. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js +10 -0
  173. package/dist/node_modules/.pnpm/expect-type@1.2.1/node_modules/expect-type/dist/utils.js.map +1 -0
  174. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
  175. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js.map +1 -0
  176. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +16 -0
  177. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js.map +1 -0
  178. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
  179. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js.map +1 -0
  180. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +15 -0
  181. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js.map +1 -0
  182. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +13 -0
  183. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js.map +1 -0
  184. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +34 -0
  185. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js.map +1 -0
  186. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +12 -0
  187. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js.map +1 -0
  188. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +122 -0
  189. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js.map +1 -0
  190. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +39 -0
  191. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js.map +1 -0
  192. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +99 -0
  193. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js.map +1 -0
  194. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
  195. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js.map +1 -0
  196. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +14 -0
  197. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js.map +1 -0
  198. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +21 -0
  199. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js.map +1 -0
  200. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
  201. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js.map +1 -0
  202. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
  203. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js.map +1 -0
  204. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
  205. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js.map +1 -0
  206. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +24 -0
  207. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js.map +1 -0
  208. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +9 -0
  209. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js.map +1 -0
  210. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +30 -0
  211. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js.map +1 -0
  212. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +82 -0
  213. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js.map +1 -0
  214. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js +7 -0
  215. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js.map +1 -0
  216. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js +8 -0
  217. package/dist/node_modules/.pnpm/vitest@3.0.9_@types_debug@4.1.13_@types_node@20.19.17_jiti@2.7.0_jsdom@26.1.0_lightning_fb7ae83398b95c49208c9194029bba02/node_modules/vitest/dist/index.js.map +1 -0
  218. package/dist/raw.d.ts +13 -0
  219. package/dist/raw.d.ts.map +1 -0
  220. package/dist/raw.js +159 -0
  221. package/dist/raw.js.map +1 -0
  222. package/package.json +58 -16
@@ -0,0 +1,84 @@
1
+ import { ListProjectsData, Project, ProjectCreateRequest, ProjectListItem, ProjectUpdateRequest } 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/projects.d.ts
7
+ /** Input for {@link Projects.transfer} (org → org). */
8
+ interface TransferProjectsInput {
9
+ /** Source org. Defaults to the client's `orgId`. */
10
+ fromOrgId?: string;
11
+ /** Destination org. */
12
+ toOrgId: string;
13
+ projectIds: string[];
14
+ }
15
+ type ListQuery = Omit<NonNullable<ListProjectsData["query"]>, "cursor">;
16
+ type CreateInput = ProjectCreateRequest["project"];
17
+ type UpdateInput = ProjectUpdateRequest["project"];
18
+ /** Per-call options for the connect workflow. */
19
+ interface WorkflowOptions<Throw extends boolean> extends CallOptions<Throw> {
20
+ /** Return a pooled connection string (default `true`). */
21
+ pooled?: boolean;
22
+ }
23
+ /** A project with a ready-to-use connection string to its default branch. */
24
+ interface ProjectConnection {
25
+ project: Project;
26
+ connectionString: string;
27
+ }
28
+ /** Project resource — one API call per method (`list` is cursor-paginated). */
29
+ declare class Projects<DThrow extends boolean> {
30
+ #private;
31
+ constructor(ctx: RequestContext);
32
+ /**
33
+ * List projects (cursor-paginated). Returns a lazy list — `await .all()`, `.page()`,
34
+ * or `for await (… of …)`.
35
+ *
36
+ * @apiCall GET /projects
37
+ */
38
+ list(query?: ListQuery): Paginated<ProjectListItem>;
39
+ /** @apiCall GET /projects/{project_id} */
40
+ get(id: string): Promise<Outcome<Project, DThrow>>;
41
+ get<Throw extends boolean = DThrow>(id: string, opts: CallOptions<Throw>): Promise<Outcome<Project, Throw>>;
42
+ /** @apiCall POST /projects */
43
+ create(input?: CreateInput): Promise<Outcome<Project, DThrow>>;
44
+ create<Throw extends boolean = DThrow>(input: CreateInput | undefined, opts: CallOptions<Throw>): Promise<Outcome<Project, Throw>>;
45
+ /**
46
+ * Create a project and return a ready-to-use connection string to its default branch.
47
+ * One API call plus readiness polling (the create response already carries the
48
+ * connection URI).
49
+ *
50
+ * @workflow createProject + waitForReadiness
51
+ */
52
+ createAndConnect(input?: CreateInput): Promise<Outcome<ProjectConnection, DThrow>>;
53
+ createAndConnect<Throw extends boolean = DThrow>(input: CreateInput | undefined, opts: WorkflowOptions<Throw>): Promise<Outcome<ProjectConnection, Throw>>;
54
+ /** @apiCall PATCH /projects/{project_id} */
55
+ update(id: string, input: UpdateInput): Promise<Outcome<Project, DThrow>>;
56
+ update<Throw extends boolean = DThrow>(id: string, input: UpdateInput, opts: CallOptions<Throw>): Promise<Outcome<Project, Throw>>;
57
+ /** @apiCall DELETE /projects/{project_id} */
58
+ delete(id: string): Promise<Outcome<Project, DThrow>>;
59
+ delete<Throw extends boolean = DThrow>(id: string, opts: CallOptions<Throw>): Promise<Outcome<Project, Throw>>;
60
+ /**
61
+ * Transfer projects from one organization to another (e.g. sponsored → paid). The
62
+ * source org defaults to the client's `orgId`. Requires a key with access to both orgs.
63
+ *
64
+ * @apiCall POST /organizations/{source_org_id}/projects/transfer
65
+ */
66
+ transfer(input: TransferProjectsInput): Promise<Outcome<void, DThrow>>;
67
+ transfer<Throw extends boolean = DThrow>(input: TransferProjectsInput, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
68
+ /**
69
+ * Transfer projects from the personal account to an organization.
70
+ *
71
+ * @apiCall POST /users/me/projects/transfer
72
+ */
73
+ transferFromUser(input: {
74
+ toOrgId: string;
75
+ projectIds: string[];
76
+ }): Promise<Outcome<void, DThrow>>;
77
+ transferFromUser<Throw extends boolean = DThrow>(input: {
78
+ toOrgId: string;
79
+ projectIds: string[];
80
+ }, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
81
+ }
82
+ //#endregion
83
+ export { ProjectConnection, Projects, TransferProjectsInput };
84
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","names":[],"sources":["../../../src/neon/resources/projects.ts"],"mappings":";;;;;;;UAuBiB,qBAAA;EAAA;EAQZ,SAAA,CAAA,EAAS,MAAA;EAAA;SAAoB,EAAA,MAAA;YAAZ,EAAA,MAAA,EAAA;;AAAD,KAAhB,SAAA,GAAY,IAAI,CAAC,WAAD,CAAa,gBAAb,CAAA,OAAA,CAAA,CAAA,EAAA,QAAA,CAAA;AAAA,KAChB,WAAA,GAAc,oBAAA,CAAA,S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AZ,UAAA,EAAA,MAAA,EAAA;MA+FH,OA9Fe,CA8FP,OA9FO,CAAA,IAAA,EA8FO,MA9FP,CAAA,CAAA;kBAAS,CAAA,cAAA,OAAA,GA+Fa,MA/Fb,CAAA,CAAA,KAAA,EAAA;IAAjB,OAAA,EAAA,MAAA;IAAR,UAAA,EAAA,MAAA,EAAA;KAoBiC,IAAA,EA6E7B,WA7E6B,CA6EjB,KA7EiB,CAAA,CAAA,EA8EjC,OA9EiC,CA8EzB,OA9EyB,CAAA,IAAA,EA8EX,KA9EW,CAAA,CAAA"}
@@ -0,0 +1,111 @@
1
+ import { NeonError } from "../errors.js";
2
+ import { err, finalize } from "../result.js";
3
+ import { createProject, deleteProject, getProject, listProjects, transferProjectsFromOrgToOrg, transferProjectsFromUserToOrg, updateProject } from "../../client/sdk.gen.js";
4
+ import { withConnectionString } from "../connection.js";
5
+ import { paginate } from "../paginate.js";
6
+ //#region src/neon/resources/projects.ts
7
+ /** Project resource — one API call per method (`list` is cursor-paginated). */
8
+ var Projects = class {
9
+ #ctx;
10
+ constructor(ctx) {
11
+ this.#ctx = ctx;
12
+ }
13
+ /**
14
+ * List projects (cursor-paginated). Returns a lazy list — `await .all()`, `.page()`,
15
+ * or `for await (… of …)`.
16
+ *
17
+ * @apiCall GET /projects
18
+ */
19
+ list(query) {
20
+ return paginate((cursor, signal) => listProjects({
21
+ client: this.#ctx.client,
22
+ query: {
23
+ org_id: this.#ctx.defaults.orgId,
24
+ ...query,
25
+ cursor
26
+ },
27
+ throwOnError: false,
28
+ signal
29
+ }), (data) => ({
30
+ items: data?.projects ?? [],
31
+ cursor: data?.pagination?.cursor
32
+ }));
33
+ }
34
+ get(id, opts) {
35
+ return this.#ctx.run(opts, (client) => getProject({
36
+ client,
37
+ path: { project_id: id },
38
+ throwOnError: false
39
+ }), (data) => data.project);
40
+ }
41
+ create(input, opts) {
42
+ return this.#ctx.run(opts, (client) => createProject({
43
+ client,
44
+ body: { project: {
45
+ ...this.#ctx.defaults.orgId ? { org_id: this.#ctx.defaults.orgId } : {},
46
+ ...input
47
+ } },
48
+ throwOnError: false
49
+ }), (data) => data.project);
50
+ }
51
+ async createAndConnect(input, opts) {
52
+ const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
53
+ return finalize(withConnectionString(await this.#ctx.execute({
54
+ ...opts,
55
+ waitForReadiness: opts?.waitForReadiness ?? true
56
+ }, (client) => createProject({
57
+ client,
58
+ body: { project: {
59
+ ...this.#ctx.defaults.orgId ? { org_id: this.#ctx.defaults.orgId } : {},
60
+ ...input
61
+ } },
62
+ throwOnError: false
63
+ }), (data) => data), (data) => data.connection_uris, (data, connectionString) => ({
64
+ project: data.project,
65
+ connectionString
66
+ }), opts?.pooled ?? true), shouldThrow);
67
+ }
68
+ update(id, input, opts) {
69
+ return this.#ctx.run(opts, (client) => updateProject({
70
+ client,
71
+ path: { project_id: id },
72
+ body: { project: input },
73
+ throwOnError: false
74
+ }), (data) => data.project);
75
+ }
76
+ delete(id, opts) {
77
+ return this.#ctx.run(opts, (client) => deleteProject({
78
+ client,
79
+ path: { project_id: id },
80
+ throwOnError: false
81
+ }), (data) => data.project);
82
+ }
83
+ async transfer(input, opts) {
84
+ const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
85
+ const fromOrgId = input.fromOrgId ?? this.#ctx.defaults.orgId;
86
+ if (!fromOrgId) return finalize(err(new NeonError("Pass fromOrgId or set orgId on the client.", "client")), shouldThrow);
87
+ return this.#ctx.run(opts, (client) => transferProjectsFromOrgToOrg({
88
+ client,
89
+ path: { source_org_id: fromOrgId },
90
+ body: {
91
+ destination_org_id: input.toOrgId,
92
+ project_ids: input.projectIds
93
+ },
94
+ throwOnError: false
95
+ }), () => void 0);
96
+ }
97
+ transferFromUser(input, opts) {
98
+ return this.#ctx.run(opts, (client) => transferProjectsFromUserToOrg({
99
+ client,
100
+ body: {
101
+ destination_org_id: input.toOrgId,
102
+ project_ids: input.projectIds
103
+ },
104
+ throwOnError: false
105
+ }), () => void 0);
106
+ }
107
+ };
108
+ //#endregion
109
+ export { Projects };
110
+
111
+ //# sourceMappingURL=projects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.js","names":["#ctx"],"sources":["../../../src/neon/resources/projects.ts"],"sourcesContent":["import {\n\tcreateProject,\n\tdeleteProject,\n\tgetProject,\n\tlistProjects,\n\ttransferProjectsFromOrgToOrg,\n\ttransferProjectsFromUserToOrg,\n\tupdateProject,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tListProjectsData,\n\tProject,\n\tProjectCreateRequest,\n\tProjectListItem,\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 resource — one API call per method (`list` is cursor-paginated). */\nexport class Projects<DThrow extends boolean> {\n\treadonly #ctx: RequestContext;\n\n\tconstructor(ctx: RequestContext) {\n\t\tthis.#ctx = 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 * 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":";;;;;;;AAgDA,IAAa,WAAb,MAA8C;CAC7C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;;;;;;;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,IACA,MACyC;EACzC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,WAAW;GACV;GACA,MAAM,EAAE,YAAY,GAAG;GACvB,cAAc;EACf,CAAC,IACD,SAAS,KAAK,OAChB;CACD;CAQA,OACC,OACA,MACyC;EACzC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,cAAc;GACb;GACA,MAAM,EACL,SAAS;IACR,GAAI,KAAKA,KAAK,SAAS,QACpB,EAAE,QAAQ,KAAKA,KAAK,SAAS,MAAM,IACnC,CAAC;IACJ,GAAG;GACJ,EACD;GACA,cAAc;EACf,CAAC,IACD,SAAS,KAAK,OAChB;CACD;CAgBA,MAAM,iBACL,OACA,MAC6D;EAC7D,MAAM,cACL,MAAM,gBAAgB,KAAKA,KAAK,SAAS;EA2B1C,OAAO,SATK,qBACX,MAlBoB,KAAKA,KAAK,QAC9B;GAAE,GAAG;GAAM,kBAAkB,MAAM,oBAAoB;EAAK,IAC3D,WACA,cAAc;GACb;GACA,MAAM,EACL,SAAS;IACR,GAAI,KAAKA,KAAK,SAAS,QACpB,EAAE,QAAQ,KAAKA,KAAK,SAAS,MAAM,IACnC,CAAC;IACJ,GAAG;GACJ,EACD;GACA,cAAc;EACf,CAAC,IACD,SAAS,IACX,IAGE,SAAS,KAAK,kBACd,MAAM,sBAAsB;GAC5B,SAAS,KAAK;GACd;EACD,IACA,MAAM,UAAU,IAEC,GAAG,WAAW;CACjC;CASA,OACC,IACA,OACA,MACyC;EACzC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,cAAc;GACb;GACA,MAAM,EAAE,YAAY,GAAG;GACvB,MAAM,EAAE,SAAS,MAAM;GACvB,cAAc;EACf,CAAC,IACD,SAAS,KAAK,OAChB;CACD;CAQA,OACC,IACA,MACyC;EACzC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,cAAc;GACb;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"}
@@ -0,0 +1,40 @@
1
+ import { Role, RoleCreateRequest } from "../../client/types.gen.js";
2
+ import { Outcome } from "../result.js";
3
+ import { CallOptions, RequestContext } from "../context.js";
4
+
5
+ //#region src/neon/resources/roles.d.ts
6
+ type CreateInput = RoleCreateRequest["role"];
7
+ /** Role resource (branch-scoped). */
8
+ declare class Roles<DThrow extends boolean> {
9
+ #private;
10
+ constructor(ctx: RequestContext);
11
+ /** @apiCall GET /projects/{project_id}/branches/{branch_id}/roles */
12
+ list(projectId: string, branchId: string): Promise<Outcome<Role[], DThrow>>;
13
+ list<Throw extends boolean = DThrow>(projectId: string, branchId: string, opts: CallOptions<Throw>): Promise<Outcome<Role[], Throw>>;
14
+ /** @apiCall GET /projects/{project_id}/branches/{branch_id}/roles/{role_name} */
15
+ get(projectId: string, branchId: string, name: string): Promise<Outcome<Role, DThrow>>;
16
+ get<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, opts: CallOptions<Throw>): Promise<Outcome<Role, Throw>>;
17
+ /** @apiCall POST /projects/{project_id}/branches/{branch_id}/roles */
18
+ create(projectId: string, branchId: string, input: CreateInput): Promise<Outcome<Role, DThrow>>;
19
+ create<Throw extends boolean = DThrow>(projectId: string, branchId: string, input: CreateInput, opts: CallOptions<Throw>): Promise<Outcome<Role, Throw>>;
20
+ /** @apiCall DELETE /projects/{project_id}/branches/{branch_id}/roles/{role_name} */
21
+ delete(projectId: string, branchId: string, name: string): Promise<Outcome<void, DThrow>>;
22
+ delete<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
23
+ /**
24
+ * Reveal the role's password.
25
+ *
26
+ * @apiCall GET /projects/{project_id}/branches/{branch_id}/roles/{role_name}/reveal_password
27
+ */
28
+ password(projectId: string, branchId: string, name: string): Promise<Outcome<string, DThrow>>;
29
+ password<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, opts: CallOptions<Throw>): Promise<Outcome<string, Throw>>;
30
+ /**
31
+ * Reset the role's password; the returned `Role` carries the new `password`.
32
+ *
33
+ * @apiCall POST /projects/{project_id}/branches/{branch_id}/roles/{role_name}/reset_password
34
+ */
35
+ resetPassword(projectId: string, branchId: string, name: string): Promise<Outcome<Role, DThrow>>;
36
+ resetPassword<Throw extends boolean = DThrow>(projectId: string, branchId: string, name: string, opts: CallOptions<Throw>): Promise<Outcome<Role, Throw>>;
37
+ }
38
+ //#endregion
39
+ export { Roles };
40
+ //# sourceMappingURL=roles.d.ts.map
@@ -0,0 +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;;MAQ0C,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,CAAA,EAAhB,OAAgB,CAAR,OAAQ,CAAA,IAAA,EAAA,EAAQ,MAAR,CAAA,CAAA;MAAQ,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;;KAAxB,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,CAAA,EA4BxC,OA5BwC,CA4BhC,OA5BgC,CA4BxB,IA5BwB,EA4BlB,MA5BkB,CAAA,CAAA;KACd,CAAA,cAAA,OAAA,GA4BD,MA5BC,CAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EAgCtB,WAhCsB,CAgCV,KAhCU,CAAA,CAAA,EAiC1B,OAjC0B,CAiClB,OAjCkB,CAiCV,IAjCU,EAiCJ,KAjCI,CAAA,CAAA;;QAGtB,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,KAAA,EAyDC,WAzDD,CAAA,EA0DJ,OA1DI,CA0DI,OA1DJ,CA0DY,IA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,MAxGN,CAAA,CAAA;eAAM,CAAA,cAAA,OAAA,GAyGa,MAzGb,CAAA,CAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,EAAA,IAAA,EAAA,MAAA,EAAA,IAAA,EA6GlB,WA7GkB,CA6GN,KA7GM,CAAA,CAAA,EA8GtB,OA9GsB,CA8Gd,OA9Gc,CA8GN,IA9GM,EA8GA,KA9GA,CAAA,CAAA"}
@@ -0,0 +1,78 @@
1
+ import { createProjectBranchRole, deleteProjectBranchRole, getProjectBranchRole, getProjectBranchRolePassword, listProjectBranchRoles, resetProjectBranchRolePassword } from "../../client/sdk.gen.js";
2
+ //#region src/neon/resources/roles.ts
3
+ /** Role resource (branch-scoped). */
4
+ var Roles = class {
5
+ #ctx;
6
+ constructor(ctx) {
7
+ this.#ctx = ctx;
8
+ }
9
+ list(projectId, branchId, opts) {
10
+ return this.#ctx.run(opts, (client) => listProjectBranchRoles({
11
+ client,
12
+ path: {
13
+ project_id: projectId,
14
+ branch_id: branchId
15
+ },
16
+ throwOnError: false
17
+ }), (data) => data.roles);
18
+ }
19
+ get(projectId, branchId, name, opts) {
20
+ return this.#ctx.run(opts, (client) => getProjectBranchRole({
21
+ client,
22
+ path: {
23
+ project_id: projectId,
24
+ branch_id: branchId,
25
+ role_name: name
26
+ },
27
+ throwOnError: false
28
+ }), (data) => data.role);
29
+ }
30
+ create(projectId, branchId, input, opts) {
31
+ return this.#ctx.run(opts, (client) => createProjectBranchRole({
32
+ client,
33
+ path: {
34
+ project_id: projectId,
35
+ branch_id: branchId
36
+ },
37
+ body: { role: input },
38
+ throwOnError: false
39
+ }), (data) => data.role);
40
+ }
41
+ delete(projectId, branchId, name, opts) {
42
+ return this.#ctx.runVoid(opts, (client) => deleteProjectBranchRole({
43
+ client,
44
+ path: {
45
+ project_id: projectId,
46
+ branch_id: branchId,
47
+ role_name: name
48
+ },
49
+ throwOnError: false
50
+ }));
51
+ }
52
+ password(projectId, branchId, name, opts) {
53
+ return this.#ctx.run(opts, (client) => getProjectBranchRolePassword({
54
+ client,
55
+ path: {
56
+ project_id: projectId,
57
+ branch_id: branchId,
58
+ role_name: name
59
+ },
60
+ throwOnError: false
61
+ }), (data) => data.password);
62
+ }
63
+ resetPassword(projectId, branchId, name, opts) {
64
+ return this.#ctx.run(opts, (client) => resetProjectBranchRolePassword({
65
+ client,
66
+ path: {
67
+ project_id: projectId,
68
+ branch_id: branchId,
69
+ role_name: name
70
+ },
71
+ throwOnError: false
72
+ }), (data) => data.role);
73
+ }
74
+ };
75
+ //#endregion
76
+ export { Roles };
77
+
78
+ //# sourceMappingURL=roles.js.map
@@ -0,0 +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,WACA,uBAAuB;GACtB;GACA,MAAM;IAAE,YAAY;IAAW,WAAW;GAAS;GACnD,cAAc;EACf,CAAC,IACD,SAAS,KAAK,KAChB;CACD;CAcA,IACC,WACA,UACA,MACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,qBAAqB;GACpB;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;EACf,CAAC,IACD,SAAS,KAAK,IAChB;CACD;CAcA,OACC,WACA,UACA,OACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,wBAAwB;GACvB;GACA,MAAM;IAAE,YAAY;IAAW,WAAW;GAAS;GACnD,MAAM,EAAE,MAAM,MAAM;GACpB,cAAc;EACf,CAAC,IACD,SAAS,KAAK,IAChB;CACD;CAcA,OACC,WACA,UACA,MACA,MACmC;EACnC,OAAO,KAAKA,KAAK,QAAQ,OAAO,WAC/B,wBAAwB;GACvB;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;EACf,CAAC,CACF;CACD;CAkBA,SACC,WACA,UACA,MACA,MACuC;EACvC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,6BAA6B;GAC5B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;EACf,CAAC,IACD,SAAS,KAAK,QAChB;CACD;CAkBA,cACC,WACA,UACA,MACA,MACmC;EACnC,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,+BAA+B;GAC9B;GACA,MAAM;IACL,YAAY;IACZ,WAAW;IACX,WAAW;GACZ;GACA,cAAc;EACf,CAAC,IACD,SAAS,KAAK,IAChB;CACD;AACD"}
@@ -0,0 +1,86 @@
1
+ import { BackupSchedule, Branch, Snapshot, SnapshotUpdateRequest } from "../../client/types.gen.js";
2
+ import { Outcome } from "../result.js";
3
+ import { CallOptions, RequestContext } from "../context.js";
4
+
5
+ //#region src/neon/resources/snapshots.d.ts
6
+ type UpdateInput = SnapshotUpdateRequest["snapshot"];
7
+ /**
8
+ * Inspect a freshly restored (not-yet-finalized) branch and decide whether to commit.
9
+ * Return `true` to finalize the restore, `false` to abort it.
10
+ */
11
+ type RestorePreview = (branch: Branch) => boolean | Promise<boolean>;
12
+ /** Options for {@link Snapshots.create} (point-in-time + naming). */
13
+ interface CreateSnapshotInput {
14
+ /** A name for the snapshot. */
15
+ name?: string;
16
+ /** Take the snapshot at this timestamp (ISO 8601). Mutually exclusive with `lsn`. */
17
+ timestamp?: string;
18
+ /** Take the snapshot at this LSN. Mutually exclusive with `timestamp`. */
19
+ lsn?: string;
20
+ /** When the snapshot is automatically deleted (ISO 8601). */
21
+ expiresAt?: string;
22
+ }
23
+ /** Input for {@link Snapshots.restore}. */
24
+ interface RestoreSnapshotInput {
25
+ /** Name for the restored branch. Auto-generated when omitted. */
26
+ name?: string;
27
+ /** Branch to restore onto. Defaults to the snapshot's source branch. */
28
+ targetBranchId?: string;
29
+ /**
30
+ * Finalize immediately (move computes onto the restored branch). Defaults to `true`
31
+ * when restoring as a new branch (nothing to clobber) and `false` when restoring
32
+ * **onto** an existing branch (`targetBranchId`), so you can preview before the swap.
33
+ * Ignored when `preview` is set (the preview flow always restores un-finalized first).
34
+ */
35
+ finalize?: boolean;
36
+ /**
37
+ * Transaction-style restore: receives the restored (un-finalized) branch; return `true`
38
+ * to finalize (commit) or `false` to abort. On abort the preview branch is deleted
39
+ * unless `keepOnAbort` is set. Either way `restore` resolves to the restored `Branch`.
40
+ */
41
+ preview?: RestorePreview;
42
+ /** Keep the preview branch when `preview` returns `false` (default: delete it). */
43
+ keepOnAbort?: boolean;
44
+ }
45
+ /** Snapshot resource. */
46
+ declare class Snapshots<DThrow extends boolean> {
47
+ #private;
48
+ constructor(ctx: RequestContext);
49
+ /** @apiCall GET /projects/{project_id}/snapshots */
50
+ list(projectId: string): Promise<Outcome<Snapshot[], DThrow>>;
51
+ list<Throw extends boolean = DThrow>(projectId: string, opts: CallOptions<Throw>): Promise<Outcome<Snapshot[], Throw>>;
52
+ /** @apiCall POST /projects/{project_id}/branches/{branch_id}/snapshot */
53
+ create(projectId: string, branchId: string, input?: CreateSnapshotInput): Promise<Outcome<Snapshot, DThrow>>;
54
+ create<Throw extends boolean = DThrow>(projectId: string, branchId: string, input: CreateSnapshotInput | undefined, opts: CallOptions<Throw>): Promise<Outcome<Snapshot, Throw>>;
55
+ /** @apiCall PATCH /projects/{project_id}/snapshots/{snapshot_id} */
56
+ update(projectId: string, snapshotId: string, input: UpdateInput): Promise<Outcome<Snapshot, DThrow>>;
57
+ update<Throw extends boolean = DThrow>(projectId: string, snapshotId: string, input: UpdateInput, opts: CallOptions<Throw>): Promise<Outcome<Snapshot, Throw>>;
58
+ /** @apiCall DELETE /projects/{project_id}/snapshots/{snapshot_id} */
59
+ delete(projectId: string, snapshotId: string): Promise<Outcome<void, DThrow>>;
60
+ delete<Throw extends boolean = DThrow>(projectId: string, snapshotId: string, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
61
+ /**
62
+ * Restore a snapshot into a branch. Returns the restored branch.
63
+ *
64
+ * - **As a new branch** (no `targetBranchId`): finalizes by default — ready to use.
65
+ * - **Onto an existing branch** (`targetBranchId`): does **not** finalize by default,
66
+ * so you can preview before the compute swap. Finish later with
67
+ * `branches.finalizeRestore`, or pass a `preview` callback to do it transactionally.
68
+ *
69
+ * With `preview`, this restores un-finalized, runs your callback against the restored
70
+ * branch, then finalizes (commit) or deletes the preview branch (abort, unless
71
+ * `keepOnAbort`). Either way it resolves to the restored `Branch`.
72
+ *
73
+ * @apiCall POST /projects/{project_id}/snapshots/{snapshot_id}/restore
74
+ */
75
+ restore(projectId: string, snapshotId: string, input?: RestoreSnapshotInput): Promise<Outcome<Branch, DThrow>>;
76
+ restore<Throw extends boolean = DThrow>(projectId: string, snapshotId: string, input: RestoreSnapshotInput | undefined, opts: CallOptions<Throw>): Promise<Outcome<Branch, Throw>>;
77
+ /** @apiCall GET /projects/{project_id}/branches/{branch_id}/backup_schedule */
78
+ getSchedule(projectId: string, branchId: string): Promise<Outcome<BackupSchedule, DThrow>>;
79
+ getSchedule<Throw extends boolean = DThrow>(projectId: string, branchId: string, opts: CallOptions<Throw>): Promise<Outcome<BackupSchedule, Throw>>;
80
+ /** @apiCall PUT /projects/{project_id}/branches/{branch_id}/backup_schedule */
81
+ setSchedule(projectId: string, branchId: string, schedule: BackupSchedule): Promise<Outcome<void, DThrow>>;
82
+ setSchedule<Throw extends boolean = DThrow>(projectId: string, branchId: string, schedule: BackupSchedule, opts: CallOptions<Throw>): Promise<Outcome<void, Throw>>;
83
+ }
84
+ //#endregion
85
+ export { CreateSnapshotInput, RestorePreview, RestoreSnapshotInput, Snapshots };
86
+ //# sourceMappingURL=snapshots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshots.d.ts","names":[],"sources":["../../../src/neon/resources/snapshots.ts"],"mappings":";;;;;KAoBK,WAAA,GAAc;;AAF6D;AAQhF;;AAAsC,KAA1B,cAAA,GAA0B,CAAA,MAAA,EAAA,MAAA,EAAA,GAAA,OAAA,GAAqB,OAArB,CAAA,OAAA,CAAA;;AAA4B,UAGjD,mBAAA,CAHiD;EAGjD;EAYA,IAAA,CAAA,EAAA,MAAA;EAuBJ;EAAS,SAAA,CAAA,EAAA,MAAA;;KAQoB,CAAA,EAAA,MAAA;;WAAR,CAAA,EAAA,MAAA;;;AAGd,UAlCH,oBAAA,CAkCG;;MACA,CAAA,EAAA,MAAA;;gBAAR,CAAA,EAAA,MAAA;;;;;;;UAuBoB,CAAA,EAAA,OAAA;;;;;;SAKpB,CAAA,EA9CD,cA8CC;;aA6BH,CAAA,EAAA,OAAA;;;AACG,cAtEC,SAsED,CAAA,eAAA,OAAA,CAAA,CAAA;UAAR;aAC4B,CAAA,GAAA,EApEd,cAoEc;;MAIZ,CAAA,SAAA,EAAA,MAAA,CAAA,EAnEM,OAmEN,CAnEc,OAmEd,CAnEsB,QAmEtB,EAAA,EAnEkC,MAmElC,CAAA,CAAA;MAAZ,CAAA,cAAA,OAAA,GAlEsB,MAkEtB,CAAA,CAAA,SAAA,EAAA,MAAA,EAAA,IAAA,EAhEA,WAgEA,CAhEY,KAgEZ,CAAA,CAAA,EA/DJ,OA+DI,CA/DI,OA+DJ,CA/DY,QA+DZ,EAAA,EA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apshotSchedule, listSnapshots, restoreSnapshot, setSnapshotSchedule, updateSnapshot } from "../../client/sdk.gen.js";
3
+ //#region src/neon/resources/snapshots.ts
4
+ /** Snapshot resource. */
5
+ var Snapshots = class {
6
+ #ctx;
7
+ constructor(ctx) {
8
+ this.#ctx = ctx;
9
+ }
10
+ list(projectId, opts) {
11
+ return this.#ctx.run(opts, (client) => listSnapshots({
12
+ client,
13
+ path: { project_id: projectId },
14
+ throwOnError: false
15
+ }), (data) => data.snapshots);
16
+ }
17
+ create(projectId, branchId, input, opts) {
18
+ return this.#ctx.run(opts, (client) => createSnapshot({
19
+ client,
20
+ path: {
21
+ project_id: projectId,
22
+ branch_id: branchId
23
+ },
24
+ query: {
25
+ name: input?.name,
26
+ timestamp: input?.timestamp,
27
+ lsn: input?.lsn,
28
+ expires_at: input?.expiresAt
29
+ },
30
+ throwOnError: false
31
+ }), (data) => data.snapshot);
32
+ }
33
+ update(projectId, snapshotId, input, opts) {
34
+ return this.#ctx.run(opts, (client) => updateSnapshot({
35
+ client,
36
+ path: {
37
+ project_id: projectId,
38
+ snapshot_id: snapshotId
39
+ },
40
+ body: { snapshot: input },
41
+ throwOnError: false
42
+ }), (data) => data.snapshot);
43
+ }
44
+ delete(projectId, snapshotId, opts) {
45
+ return this.#ctx.run(opts, (client) => deleteSnapshot({
46
+ client,
47
+ path: {
48
+ project_id: projectId,
49
+ snapshot_id: snapshotId
50
+ },
51
+ throwOnError: false
52
+ }), () => void 0);
53
+ }
54
+ async restore(projectId, snapshotId, input, opts) {
55
+ const shouldThrow = opts?.throwOnError ?? this.#ctx.defaults.throwOnError;
56
+ const preview = input?.preview;
57
+ const finalizeNow = preview ? false : input?.finalize ?? input?.targetBranchId === void 0;
58
+ const restored = await this.#ctx.execute({
59
+ ...opts,
60
+ waitForReadiness: preview ? true : opts?.waitForReadiness
61
+ }, (client) => restoreSnapshot({
62
+ client,
63
+ path: {
64
+ project_id: projectId,
65
+ snapshot_id: snapshotId
66
+ },
67
+ body: {
68
+ name: input?.name,
69
+ target_branch_id: input?.targetBranchId,
70
+ finalize_restore: finalizeNow
71
+ },
72
+ throwOnError: false
73
+ }), (data) => data.branch);
74
+ if (restored.error || !preview) return finalize(restored, shouldThrow);
75
+ const branch = restored.data;
76
+ const step = await preview(branch) ? await this.#ctx.execute({
77
+ ...opts,
78
+ waitForReadiness: true
79
+ }, (client) => finalizeRestoreBranch({
80
+ client,
81
+ path: {
82
+ project_id: projectId,
83
+ branch_id: branch.id
84
+ },
85
+ throwOnError: false
86
+ }), () => void 0) : input?.keepOnAbort ? ok(void 0) : await this.#ctx.execute({
87
+ ...opts,
88
+ waitForReadiness: true
89
+ }, (client) => deleteProjectBranch({
90
+ client,
91
+ path: {
92
+ project_id: projectId,
93
+ branch_id: branch.id
94
+ },
95
+ throwOnError: false
96
+ }), () => void 0);
97
+ if (step.error) return finalize(err(step.error), shouldThrow);
98
+ return finalize(ok(branch), shouldThrow);
99
+ }
100
+ getSchedule(projectId, branchId, opts) {
101
+ return this.#ctx.run(opts, (client) => getSnapshotSchedule({
102
+ client,
103
+ path: {
104
+ project_id: projectId,
105
+ branch_id: branchId
106
+ },
107
+ throwOnError: false
108
+ }), (data) => data);
109
+ }
110
+ setSchedule(projectId, branchId, schedule, opts) {
111
+ return this.#ctx.run(opts, (client) => setSnapshotSchedule({
112
+ client,
113
+ path: {
114
+ project_id: projectId,
115
+ branch_id: branchId
116
+ },
117
+ body: schedule,
118
+ throwOnError: false
119
+ }), () => void 0);
120
+ }
121
+ };
122
+ //#endregion
123
+ export { Snapshots };
124
+
125
+ //# sourceMappingURL=snapshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshots.js","names":["#ctx"],"sources":["../../../src/neon/resources/snapshots.ts"],"sourcesContent":["import {\n\tcreateSnapshot,\n\tdeleteProjectBranch,\n\tdeleteSnapshot,\n\tfinalizeRestoreBranch,\n\tgetSnapshotSchedule,\n\tlistSnapshots,\n\trestoreSnapshot,\n\tsetSnapshotSchedule,\n\tupdateSnapshot,\n} from \"../../client/sdk.gen.js\";\nimport type {\n\tBackupSchedule,\n\tBranch,\n\tSnapshot,\n\tSnapshotUpdateRequest,\n} from \"../../client/types.gen.js\";\nimport type { CallOptions, RequestContext } from \"../context.js\";\nimport { err, finalize, type NeonResult, type Outcome, ok } from \"../result.js\";\n\ntype UpdateInput = SnapshotUpdateRequest[\"snapshot\"];\n\n/**\n * Inspect a freshly restored (not-yet-finalized) branch and decide whether to commit.\n * Return `true` to finalize the restore, `false` to abort it.\n */\nexport type RestorePreview = (branch: Branch) => boolean | Promise<boolean>;\n\n/** Options for {@link Snapshots.create} (point-in-time + naming). */\nexport interface CreateSnapshotInput {\n\t/** A name for the snapshot. */\n\tname?: string;\n\t/** Take the snapshot at this timestamp (ISO 8601). Mutually exclusive with `lsn`. */\n\ttimestamp?: string;\n\t/** Take the snapshot at this LSN. Mutually exclusive with `timestamp`. */\n\tlsn?: string;\n\t/** When the snapshot is automatically deleted (ISO 8601). */\n\texpiresAt?: string;\n}\n\n/** Input for {@link Snapshots.restore}. */\nexport interface RestoreSnapshotInput {\n\t/** Name for the restored branch. Auto-generated when omitted. */\n\tname?: string;\n\t/** Branch to restore onto. Defaults to the snapshot's source branch. */\n\ttargetBranchId?: string;\n\t/**\n\t * Finalize immediately (move computes onto the restored branch). Defaults to `true`\n\t * when restoring as a new branch (nothing to clobber) and `false` when restoring\n\t * **onto** an existing branch (`targetBranchId`), so you can preview before the swap.\n\t * Ignored when `preview` is set (the preview flow always restores un-finalized first).\n\t */\n\tfinalize?: boolean;\n\t/**\n\t * Transaction-style restore: receives the restored (un-finalized) branch; return `true`\n\t * to finalize (commit) or `false` to abort. On abort the preview branch is deleted\n\t * unless `keepOnAbort` is set. Either way `restore` resolves to the restored `Branch`.\n\t */\n\tpreview?: RestorePreview;\n\t/** Keep the preview branch when `preview` returns `false` (default: delete it). */\n\tkeepOnAbort?: boolean;\n}\n\n/** Snapshot resource. */\nexport class Snapshots<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}/snapshots */\n\tlist(projectId: string): Promise<Outcome<Snapshot[], DThrow>>;\n\tlist<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Snapshot[], Throw>>;\n\tlist(\n\t\tprojectId: string,\n\t\topts?: CallOptions,\n\t): Promise<Snapshot[] | NeonResult<Snapshot[]>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tlistSnapshots({\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.snapshots,\n\t\t);\n\t}\n\n\t/** @apiCall POST /projects/{project_id}/branches/{branch_id}/snapshot */\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput?: CreateSnapshotInput,\n\t): Promise<Outcome<Snapshot, DThrow>>;\n\tcreate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput: CreateSnapshotInput | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Snapshot, Throw>>;\n\tcreate(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tinput?: CreateSnapshotInput,\n\t\topts?: CallOptions,\n\t): Promise<Snapshot | NeonResult<Snapshot>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tcreateSnapshot({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tquery: {\n\t\t\t\t\t\tname: input?.name,\n\t\t\t\t\t\ttimestamp: input?.timestamp,\n\t\t\t\t\t\tlsn: input?.lsn,\n\t\t\t\t\t\texpires_at: input?.expiresAt,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.snapshot,\n\t\t);\n\t}\n\n\t/** @apiCall PATCH /projects/{project_id}/snapshots/{snapshot_id} */\n\tupdate(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\tinput: UpdateInput,\n\t): Promise<Outcome<Snapshot, DThrow>>;\n\tupdate<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\tinput: UpdateInput,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Snapshot, Throw>>;\n\tupdate(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\tinput: UpdateInput,\n\t\topts?: CallOptions,\n\t): Promise<Snapshot | NeonResult<Snapshot>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tupdateSnapshot({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, snapshot_id: snapshotId },\n\t\t\t\t\tbody: { snapshot: input },\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.snapshot,\n\t\t);\n\t}\n\n\t/** @apiCall DELETE /projects/{project_id}/snapshots/{snapshot_id} */\n\tdelete(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t): Promise<Outcome<void, DThrow>>;\n\tdelete<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tdelete(\n\t\tprojectId: string,\n\t\tsnapshotId: 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\tdeleteSnapshot({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, snapshot_id: snapshotId },\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 * Restore a snapshot into a branch. Returns the restored branch.\n\t *\n\t * - **As a new branch** (no `targetBranchId`): finalizes by default — ready to use.\n\t * - **Onto an existing branch** (`targetBranchId`): does **not** finalize by default,\n\t * so you can preview before the compute swap. Finish later with\n\t * `branches.finalizeRestore`, or pass a `preview` callback to do it transactionally.\n\t *\n\t * With `preview`, this restores un-finalized, runs your callback against the restored\n\t * branch, then finalizes (commit) or deletes the preview branch (abort, unless\n\t * `keepOnAbort`). Either way it resolves to the restored `Branch`.\n\t *\n\t * @apiCall POST /projects/{project_id}/snapshots/{snapshot_id}/restore\n\t */\n\trestore(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\tinput?: RestoreSnapshotInput,\n\t): Promise<Outcome<Branch, DThrow>>;\n\trestore<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\tinput: RestoreSnapshotInput | undefined,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<Branch, Throw>>;\n\tasync restore(\n\t\tprojectId: string,\n\t\tsnapshotId: string,\n\t\tinput?: RestoreSnapshotInput,\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 preview = input?.preview;\n\t\t// New branch → finalize by default; onto existing → preview-first by default.\n\t\t// The preview flow always restores un-finalized so it can inspect first.\n\t\tconst finalizeNow = preview\n\t\t\t? false\n\t\t\t: (input?.finalize ?? input?.targetBranchId === undefined);\n\n\t\tconst restored = await this.#ctx.execute(\n\t\t\t{\n\t\t\t\t...opts,\n\t\t\t\twaitForReadiness: preview ? true : opts?.waitForReadiness,\n\t\t\t},\n\t\t\t(client) =>\n\t\t\t\trestoreSnapshot({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, snapshot_id: snapshotId },\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tname: input?.name,\n\t\t\t\t\t\ttarget_branch_id: input?.targetBranchId,\n\t\t\t\t\t\tfinalize_restore: finalizeNow,\n\t\t\t\t\t},\n\t\t\t\t\tthrowOnError: false,\n\t\t\t\t}),\n\t\t\t(data) => data.branch,\n\t\t);\n\t\tif (restored.error || !preview) {\n\t\t\treturn finalize(restored, shouldThrow);\n\t\t}\n\n\t\tconst branch = restored.data;\n\t\tconst commit = await preview(branch);\n\t\tconst step = commit\n\t\t\t? await this.#ctx.execute(\n\t\t\t\t\t{ ...opts, waitForReadiness: true },\n\t\t\t\t\t(client) =>\n\t\t\t\t\t\tfinalizeRestoreBranch({\n\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\tpath: {\n\t\t\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\t\t\tbranch_id: branch.id,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\t\t}),\n\t\t\t\t\t() => undefined,\n\t\t\t\t)\n\t\t\t: input?.keepOnAbort\n\t\t\t\t? ok(undefined)\n\t\t\t\t: await this.#ctx.execute(\n\t\t\t\t\t\t{ ...opts, waitForReadiness: true },\n\t\t\t\t\t\t(client) =>\n\t\t\t\t\t\t\tdeleteProjectBranch({\n\t\t\t\t\t\t\t\tclient,\n\t\t\t\t\t\t\t\tpath: {\n\t\t\t\t\t\t\t\t\tproject_id: projectId,\n\t\t\t\t\t\t\t\t\tbranch_id: branch.id,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tthrowOnError: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t() => undefined,\n\t\t\t\t\t);\n\n\t\tif (step.error) return finalize(err<Branch>(step.error), shouldThrow);\n\t\treturn finalize(ok(branch), shouldThrow);\n\t}\n\n\t/** @apiCall GET /projects/{project_id}/branches/{branch_id}/backup_schedule */\n\tgetSchedule(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t): Promise<Outcome<BackupSchedule, DThrow>>;\n\tgetSchedule<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<BackupSchedule, Throw>>;\n\tgetSchedule(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\topts?: CallOptions,\n\t): Promise<BackupSchedule | NeonResult<BackupSchedule>> {\n\t\treturn this.#ctx.run(\n\t\t\topts,\n\t\t\t(client) =>\n\t\t\t\tgetSnapshotSchedule({\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,\n\t\t);\n\t}\n\n\t/** @apiCall PUT /projects/{project_id}/branches/{branch_id}/backup_schedule */\n\tsetSchedule(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tschedule: BackupSchedule,\n\t): Promise<Outcome<void, DThrow>>;\n\tsetSchedule<Throw extends boolean = DThrow>(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tschedule: BackupSchedule,\n\t\topts: CallOptions<Throw>,\n\t): Promise<Outcome<void, Throw>>;\n\tsetSchedule(\n\t\tprojectId: string,\n\t\tbranchId: string,\n\t\tschedule: BackupSchedule,\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\tsetSnapshotSchedule({\n\t\t\t\t\tclient,\n\t\t\t\t\tpath: { project_id: projectId, branch_id: branchId },\n\t\t\t\t\tbody: schedule,\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":";;;;AAgEA,IAAa,YAAb,MAA+C;CAC9C;CAEA,YAAY,KAAqB;EAChC,KAAKA,OAAO;CACb;CAQA,KACC,WACA,MAC+C;EAC/C,OAAO,KAAKA,KAAK,IAChB,OACC,WACA,cAAc;GACb;GACA,MAAM,EAAE,YAAY,UAAU;GAC9B,cAAc;EACf,CAAC,IAC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