@neon/tools 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -14
- package/dist/index.d.ts +73 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -16
- package/dist/lib/customize.d.ts +16 -16
- package/dist/lib/customize.d.ts.map +1 -1
- package/dist/lib/customize.js +53 -67
- package/dist/lib/envelope.d.ts +5 -0
- package/dist/lib/envelope.d.ts.map +1 -0
- package/dist/lib/envelope.js +22 -0
- package/dist/lib/workflows.d.ts +315 -0
- package/dist/lib/workflows.d.ts.map +1 -0
- package/dist/lib/workflows.js +113 -0
- package/dist/operations.gen.d.ts +943 -1440
- package/dist/operations.gen.d.ts.map +1 -1
- package/dist/operations.gen.js +1663 -421
- package/package.json +2 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function optionalGroup<Value extends Record<string, unknown>>(value: Value, required: true): Value;
|
|
2
|
+
export declare function optionalGroup<Value extends Record<string, unknown>>(value: Value, required: false): Value | undefined;
|
|
3
|
+
export declare function decodeBinaryFields(body: Record<string, unknown>, fields: readonly string[], decode: (value: string) => Blob): Record<string, unknown>;
|
|
4
|
+
export declare function decodeBinaryFields(body: Record<string, unknown> | undefined, fields: readonly string[], decode: (value: string) => Blob): Record<string, unknown> | undefined;
|
|
5
|
+
//# sourceMappingURL=envelope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/lib/envelope.ts"],"names":[],"mappings":"AAYA,wBAAgB,aAAa,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,IAAI,GACZ,KAAK,CAAC;AACT,wBAAgB,aAAa,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,KAAK,GACb,KAAK,GAAG,SAAS,CAAC;AAYrB,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC3B,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/lib/envelope.ts
|
|
2
|
+
const defined = (value) => {
|
|
3
|
+
const next = {};
|
|
4
|
+
for (const [key, child] of Object.entries(value)) if (child !== void 0) next[key] = child;
|
|
5
|
+
return next;
|
|
6
|
+
};
|
|
7
|
+
function optionalGroup(value, required) {
|
|
8
|
+
const next = defined(value);
|
|
9
|
+
if (!required && Object.keys(next).length === 0) return;
|
|
10
|
+
return next;
|
|
11
|
+
}
|
|
12
|
+
function decodeBinaryFields(body, fields, decode) {
|
|
13
|
+
if (body === void 0) return;
|
|
14
|
+
const next = { ...body };
|
|
15
|
+
for (const field of fields) {
|
|
16
|
+
const value = next[field];
|
|
17
|
+
if (typeof value === "string") next[field] = decode(value);
|
|
18
|
+
}
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { decodeBinaryFields, optionalGroup };
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { type NeonConfig } from "@neon/sdk";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { type NeonBearerCredential } from "./auth.js";
|
|
4
|
+
import type { NeonTool } from "./operation.js";
|
|
5
|
+
export interface WorkflowClientOptions {
|
|
6
|
+
apiKey?: NeonBearerCredential;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
wait?: NeonConfig["wait"];
|
|
10
|
+
}
|
|
11
|
+
export declare const createBranchWithComputeInputSchema: z.ZodObject<{
|
|
12
|
+
project_id: z.ZodString;
|
|
13
|
+
name: z.ZodOptional<z.ZodString>;
|
|
14
|
+
parent_id: z.ZodOptional<z.ZodString>;
|
|
15
|
+
compute: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
min_cu: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
max_cu: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
suspend_timeout_seconds: z.ZodOptional<z.ZodInt>;
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
pooled: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export declare const createProjectAndConnectInputSchema: z.ZodObject<{
|
|
23
|
+
pooled: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
quota: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
active_time_seconds: z.ZodOptional<z.ZodInt>;
|
|
27
|
+
compute_time_seconds: z.ZodOptional<z.ZodInt>;
|
|
28
|
+
written_data_bytes: z.ZodOptional<z.ZodInt>;
|
|
29
|
+
data_transfer_bytes: z.ZodOptional<z.ZodInt>;
|
|
30
|
+
logical_size_bytes: z.ZodOptional<z.ZodInt>;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
allowed_ips: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
ips: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
protected_branches_only: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
}, z.core.$strict>>;
|
|
36
|
+
enable_logical_replication: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
maintenance_window: z.ZodOptional<z.ZodObject<{
|
|
38
|
+
weekdays: z.ZodArray<z.ZodInt>;
|
|
39
|
+
start_time: z.ZodString;
|
|
40
|
+
end_time: z.ZodString;
|
|
41
|
+
}, z.core.$strict>>;
|
|
42
|
+
block_public_connections: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
block_vpc_connections: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
audit_log_level: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
base: "base";
|
|
46
|
+
extended: "extended";
|
|
47
|
+
full: "full";
|
|
48
|
+
}>>;
|
|
49
|
+
hipaa: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
preload_libraries: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
use_defaults: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
enabled_libraries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
|
+
}, z.core.$strict>>;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
name: z.ZodOptional<z.ZodString>;
|
|
56
|
+
branch: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
name: z.ZodOptional<z.ZodString>;
|
|
58
|
+
role_name: z.ZodOptional<z.ZodString>;
|
|
59
|
+
database_name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
61
|
+
}, z.core.$strict>>;
|
|
62
|
+
autoscaling_limit_min_cu: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
autoscaling_limit_max_cu: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
provisioner: z.ZodOptional<z.ZodString>;
|
|
65
|
+
region_id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
default_endpoint_settings: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
pg_settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
68
|
+
pgbouncer_settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
69
|
+
autoscaling_limit_min_cu: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
autoscaling_limit_max_cu: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
suspend_timeout_seconds: z.ZodOptional<z.ZodInt>;
|
|
72
|
+
}, z.core.$strict>>;
|
|
73
|
+
pg_version: z.ZodOptional<z.ZodInt>;
|
|
74
|
+
store_passwords: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
history_retention_seconds: z.ZodOptional<z.ZodInt>;
|
|
76
|
+
org_id: z.ZodOptional<z.ZodString>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
export declare const workflowIds: readonly ["createBranchWithCompute", "createProjectAndConnect"];
|
|
79
|
+
export type NeonWorkflowId = (typeof workflowIds)[number];
|
|
80
|
+
export declare const workflowFactories: {
|
|
81
|
+
createBranchWithCompute: (options: WorkflowClientOptions) => NeonTool<z.ZodObject<{
|
|
82
|
+
project_id: z.ZodString;
|
|
83
|
+
name: z.ZodOptional<z.ZodString>;
|
|
84
|
+
parent_id: z.ZodOptional<z.ZodString>;
|
|
85
|
+
compute: z.ZodOptional<z.ZodObject<{
|
|
86
|
+
min_cu: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
max_cu: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
suspend_timeout_seconds: z.ZodOptional<z.ZodInt>;
|
|
89
|
+
}, z.core.$strict>>;
|
|
90
|
+
pooled: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
}, z.core.$strict>, "create_branch_with_compute", {
|
|
92
|
+
branch: {
|
|
93
|
+
id: string;
|
|
94
|
+
project_id: string;
|
|
95
|
+
parent_id?: string | null | undefined;
|
|
96
|
+
parent_lsn?: string | null | undefined;
|
|
97
|
+
parent_timestamp?: string | null | undefined;
|
|
98
|
+
name: string;
|
|
99
|
+
current_state: import("@neon/sdk").BranchState;
|
|
100
|
+
pending_state?: string | null | undefined;
|
|
101
|
+
state_changed_at: string;
|
|
102
|
+
logical_size?: number | null | undefined;
|
|
103
|
+
creation_source: string;
|
|
104
|
+
primary?: boolean | null | undefined;
|
|
105
|
+
default: boolean;
|
|
106
|
+
protected: boolean;
|
|
107
|
+
cpu_used_sec: number;
|
|
108
|
+
compute_time_seconds: number;
|
|
109
|
+
active_time_seconds: number;
|
|
110
|
+
written_data_bytes: number;
|
|
111
|
+
data_transfer_bytes: number;
|
|
112
|
+
created_at: string;
|
|
113
|
+
updated_at: string;
|
|
114
|
+
ttl_interval_seconds?: number | null | undefined;
|
|
115
|
+
expires_at?: string | null | undefined;
|
|
116
|
+
last_reset_at?: string | null | undefined;
|
|
117
|
+
created_by?: {
|
|
118
|
+
name?: string | null | undefined;
|
|
119
|
+
image?: string | null | undefined;
|
|
120
|
+
} | null | undefined;
|
|
121
|
+
init_source?: string | null | undefined;
|
|
122
|
+
restore_status?: string | null | undefined;
|
|
123
|
+
restored_from?: string | null | undefined;
|
|
124
|
+
restored_as?: string | null | undefined;
|
|
125
|
+
restricted_actions?: {
|
|
126
|
+
name: string;
|
|
127
|
+
reason: string;
|
|
128
|
+
}[] | null | undefined;
|
|
129
|
+
recovery?: {
|
|
130
|
+
deleted_at: string;
|
|
131
|
+
recoverable_until: string;
|
|
132
|
+
deletion_method: "user" | "ttl";
|
|
133
|
+
} | null | undefined;
|
|
134
|
+
};
|
|
135
|
+
endpoint: {
|
|
136
|
+
host: string;
|
|
137
|
+
id: string;
|
|
138
|
+
name?: string | null | undefined;
|
|
139
|
+
project_id: string;
|
|
140
|
+
branch_id: string;
|
|
141
|
+
autoscaling_limit_min_cu: import("@neon/sdk").ComputeUnit;
|
|
142
|
+
autoscaling_limit_max_cu: import("@neon/sdk").ComputeUnit;
|
|
143
|
+
region_id: string;
|
|
144
|
+
type: import("@neon/sdk").EndpointType;
|
|
145
|
+
current_state: import("@neon/sdk").EndpointState;
|
|
146
|
+
pending_state?: import("@neon/sdk").EndpointState | null | undefined;
|
|
147
|
+
settings: {
|
|
148
|
+
pg_settings?: {
|
|
149
|
+
[x: string]: string;
|
|
150
|
+
} | null | undefined;
|
|
151
|
+
pgbouncer_settings?: {
|
|
152
|
+
[x: string]: string;
|
|
153
|
+
} | null | undefined;
|
|
154
|
+
preload_libraries?: {
|
|
155
|
+
use_defaults?: boolean | null | undefined;
|
|
156
|
+
enabled_libraries?: string[] | null | undefined;
|
|
157
|
+
} | null | undefined;
|
|
158
|
+
};
|
|
159
|
+
pooler_enabled: boolean;
|
|
160
|
+
pooler_mode: import("@neon/sdk").EndpointPoolerMode;
|
|
161
|
+
disabled: boolean;
|
|
162
|
+
passwordless_access: boolean;
|
|
163
|
+
last_active?: string | null | undefined;
|
|
164
|
+
creation_source: string;
|
|
165
|
+
created_at: string;
|
|
166
|
+
updated_at: string;
|
|
167
|
+
started_at?: string | null | undefined;
|
|
168
|
+
suspended_at?: string | null | undefined;
|
|
169
|
+
proxy_host: string;
|
|
170
|
+
suspend_timeout_seconds: import("@neon/sdk").SuspendTimeoutSeconds;
|
|
171
|
+
provisioner: import("@neon/sdk").Provisioner;
|
|
172
|
+
compute_release_version?: string | null | undefined;
|
|
173
|
+
};
|
|
174
|
+
connectionString: string;
|
|
175
|
+
}>;
|
|
176
|
+
createProjectAndConnect: (options: WorkflowClientOptions) => NeonTool<z.ZodObject<{
|
|
177
|
+
pooled: z.ZodOptional<z.ZodBoolean>;
|
|
178
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
179
|
+
quota: z.ZodOptional<z.ZodObject<{
|
|
180
|
+
active_time_seconds: z.ZodOptional<z.ZodInt>;
|
|
181
|
+
compute_time_seconds: z.ZodOptional<z.ZodInt>;
|
|
182
|
+
written_data_bytes: z.ZodOptional<z.ZodInt>;
|
|
183
|
+
data_transfer_bytes: z.ZodOptional<z.ZodInt>;
|
|
184
|
+
logical_size_bytes: z.ZodOptional<z.ZodInt>;
|
|
185
|
+
}, z.core.$strict>>;
|
|
186
|
+
allowed_ips: z.ZodOptional<z.ZodObject<{
|
|
187
|
+
ips: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
188
|
+
protected_branches_only: z.ZodOptional<z.ZodBoolean>;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
enable_logical_replication: z.ZodOptional<z.ZodBoolean>;
|
|
191
|
+
maintenance_window: z.ZodOptional<z.ZodObject<{
|
|
192
|
+
weekdays: z.ZodArray<z.ZodInt>;
|
|
193
|
+
start_time: z.ZodString;
|
|
194
|
+
end_time: z.ZodString;
|
|
195
|
+
}, z.core.$strict>>;
|
|
196
|
+
block_public_connections: z.ZodOptional<z.ZodBoolean>;
|
|
197
|
+
block_vpc_connections: z.ZodOptional<z.ZodBoolean>;
|
|
198
|
+
audit_log_level: z.ZodOptional<z.ZodEnum<{
|
|
199
|
+
base: "base";
|
|
200
|
+
extended: "extended";
|
|
201
|
+
full: "full";
|
|
202
|
+
}>>;
|
|
203
|
+
hipaa: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
+
preload_libraries: z.ZodOptional<z.ZodObject<{
|
|
205
|
+
use_defaults: z.ZodOptional<z.ZodBoolean>;
|
|
206
|
+
enabled_libraries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
207
|
+
}, z.core.$strict>>;
|
|
208
|
+
}, z.core.$strict>>;
|
|
209
|
+
name: z.ZodOptional<z.ZodString>;
|
|
210
|
+
branch: z.ZodOptional<z.ZodObject<{
|
|
211
|
+
name: z.ZodOptional<z.ZodString>;
|
|
212
|
+
role_name: z.ZodOptional<z.ZodString>;
|
|
213
|
+
database_name: z.ZodOptional<z.ZodString>;
|
|
214
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
215
|
+
}, z.core.$strict>>;
|
|
216
|
+
autoscaling_limit_min_cu: z.ZodOptional<z.ZodNumber>;
|
|
217
|
+
autoscaling_limit_max_cu: z.ZodOptional<z.ZodNumber>;
|
|
218
|
+
provisioner: z.ZodOptional<z.ZodString>;
|
|
219
|
+
region_id: z.ZodOptional<z.ZodString>;
|
|
220
|
+
default_endpoint_settings: z.ZodOptional<z.ZodObject<{
|
|
221
|
+
pg_settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
222
|
+
pgbouncer_settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
223
|
+
autoscaling_limit_min_cu: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
autoscaling_limit_max_cu: z.ZodOptional<z.ZodNumber>;
|
|
225
|
+
suspend_timeout_seconds: z.ZodOptional<z.ZodInt>;
|
|
226
|
+
}, z.core.$strict>>;
|
|
227
|
+
pg_version: z.ZodOptional<z.ZodInt>;
|
|
228
|
+
store_passwords: z.ZodOptional<z.ZodBoolean>;
|
|
229
|
+
history_retention_seconds: z.ZodOptional<z.ZodInt>;
|
|
230
|
+
org_id: z.ZodOptional<z.ZodString>;
|
|
231
|
+
}, z.core.$strict>, "create_project_and_connect", {
|
|
232
|
+
project: {
|
|
233
|
+
data_storage_bytes_hour: number;
|
|
234
|
+
data_transfer_bytes: number;
|
|
235
|
+
written_data_bytes: number;
|
|
236
|
+
compute_time_seconds: number;
|
|
237
|
+
active_time_seconds: number;
|
|
238
|
+
cpu_used_sec: number;
|
|
239
|
+
id: string;
|
|
240
|
+
platform_id: string;
|
|
241
|
+
region_id: string;
|
|
242
|
+
name: string;
|
|
243
|
+
provisioner: import("@neon/sdk").Provisioner;
|
|
244
|
+
default_endpoint_settings?: {
|
|
245
|
+
pg_settings?: {
|
|
246
|
+
[x: string]: string;
|
|
247
|
+
} | null | undefined;
|
|
248
|
+
pgbouncer_settings?: {
|
|
249
|
+
[x: string]: string;
|
|
250
|
+
} | null | undefined;
|
|
251
|
+
autoscaling_limit_min_cu?: number | null | undefined;
|
|
252
|
+
autoscaling_limit_max_cu?: number | null | undefined;
|
|
253
|
+
suspend_timeout_seconds?: number | null | undefined;
|
|
254
|
+
} | null | undefined;
|
|
255
|
+
settings?: {
|
|
256
|
+
quota?: {
|
|
257
|
+
active_time_seconds?: number | null | undefined;
|
|
258
|
+
compute_time_seconds?: number | null | undefined;
|
|
259
|
+
written_data_bytes?: number | null | undefined;
|
|
260
|
+
data_transfer_bytes?: number | null | undefined;
|
|
261
|
+
logical_size_bytes?: number | null | undefined;
|
|
262
|
+
} | null | undefined;
|
|
263
|
+
allowed_ips?: {
|
|
264
|
+
ips?: string[] | null | undefined;
|
|
265
|
+
protected_branches_only?: boolean | null | undefined;
|
|
266
|
+
} | null | undefined;
|
|
267
|
+
enable_logical_replication?: boolean | null | undefined;
|
|
268
|
+
maintenance_window?: {
|
|
269
|
+
weekdays: number[];
|
|
270
|
+
start_time: string;
|
|
271
|
+
end_time: string;
|
|
272
|
+
} | null | undefined;
|
|
273
|
+
block_public_connections?: boolean | null | undefined;
|
|
274
|
+
block_vpc_connections?: boolean | null | undefined;
|
|
275
|
+
audit_log_level?: import("@neon/sdk").ProjectAuditLogLevel | null | undefined;
|
|
276
|
+
hipaa?: boolean | null | undefined;
|
|
277
|
+
preload_libraries?: {
|
|
278
|
+
use_defaults?: boolean | null | undefined;
|
|
279
|
+
enabled_libraries?: string[] | null | undefined;
|
|
280
|
+
} | null | undefined;
|
|
281
|
+
} | null | undefined;
|
|
282
|
+
pg_version: import("@neon/sdk").PgVersion;
|
|
283
|
+
proxy_host: string;
|
|
284
|
+
branch_logical_size_limit: number;
|
|
285
|
+
branch_logical_size_limit_bytes: number;
|
|
286
|
+
store_passwords: boolean;
|
|
287
|
+
maintenance_starts_at?: string | null | undefined;
|
|
288
|
+
creation_source: string;
|
|
289
|
+
history_retention_seconds: number;
|
|
290
|
+
created_at: string;
|
|
291
|
+
updated_at: string;
|
|
292
|
+
synthetic_storage_size?: number | null | undefined;
|
|
293
|
+
consumption_period_start: string;
|
|
294
|
+
consumption_period_end: string;
|
|
295
|
+
quota_reset_at?: string | null | undefined;
|
|
296
|
+
owner_id: string;
|
|
297
|
+
owner?: {
|
|
298
|
+
email: string;
|
|
299
|
+
name: string;
|
|
300
|
+
branches_limit: number;
|
|
301
|
+
subscription_type: import("@neon/sdk").BillingSubscriptionType;
|
|
302
|
+
} | null | undefined;
|
|
303
|
+
compute_last_active_at?: string | null | undefined;
|
|
304
|
+
org_id?: string | null | undefined;
|
|
305
|
+
maintenance_scheduled_for?: string | null | undefined;
|
|
306
|
+
hipaa_enabled_at?: string | null | undefined;
|
|
307
|
+
effective_project_permission?: (import("@neon/sdk").ProjectPermissionLevel | null) | undefined;
|
|
308
|
+
};
|
|
309
|
+
connectionString: string;
|
|
310
|
+
}>;
|
|
311
|
+
};
|
|
312
|
+
export type WorkflowFactories = typeof workflowFactories;
|
|
313
|
+
export declare const isNeonWorkflowId: (id: string) => id is NeonWorkflowId;
|
|
314
|
+
export declare const workflowFactoryFor: (workflowId: NeonWorkflowId) => WorkflowFactories[NeonWorkflowId];
|
|
315
|
+
//# sourceMappingURL=workflows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/lib/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAEN,KAAK,oBAAoB,EAEzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAEX,QAAQ,EAER,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,qBAAqB;IACrC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;CAC1B;AAkBD,eAAO,MAAM,kCAAkC;;;;;;;;;;kBAY7C,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAG7C,CAAC;AAEH,eAAO,MAAM,WAAW,iEAGd,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAkI1D,eAAO,MAAM,iBAAiB;uCA1EgB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCA6CrB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgClE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,KAAG,EAAE,IAAI,cACJ,CAAC;AAEjD,eAAO,MAAM,kBAAkB,GAC9B,YAAY,cAAc,KACxB,iBAAiB,CAAC,cAAc,CAQlC,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { missingBearerCredential, requireBearerCredential } from "./auth.js";
|
|
2
|
+
import { zBranchCreateRequest, zComputeUnit, zCreateProjectBody, zCreateProjectBranchPath, zSuspendTimeoutSeconds } from "../generated/zod.gen.js";
|
|
3
|
+
import { toToolResult } from "./result.js";
|
|
4
|
+
import { createNeonClient } from "@neon/sdk";
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
//#region src/lib/workflows.ts
|
|
7
|
+
const branchCreateFields = zBranchCreateRequest.shape.branch.unwrap().shape;
|
|
8
|
+
const projectCreateFields = zCreateProjectBody.shape.project.shape;
|
|
9
|
+
const writeAnnotations = {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: true,
|
|
12
|
+
openWorldHint: true
|
|
13
|
+
};
|
|
14
|
+
const pooledField = z.boolean().describe("Return a pooled connection string. Default true. Set false for a direct connection.").optional();
|
|
15
|
+
const createBranchWithComputeInputSchema = z.strictObject({
|
|
16
|
+
project_id: zCreateProjectBranchPath.shape.project_id,
|
|
17
|
+
name: branchCreateFields.name,
|
|
18
|
+
parent_id: branchCreateFields.parent_id,
|
|
19
|
+
compute: z.strictObject({
|
|
20
|
+
min_cu: zComputeUnit.optional(),
|
|
21
|
+
max_cu: zComputeUnit.optional(),
|
|
22
|
+
suspend_timeout_seconds: zSuspendTimeoutSeconds.optional()
|
|
23
|
+
}).optional(),
|
|
24
|
+
pooled: pooledField
|
|
25
|
+
});
|
|
26
|
+
const createProjectAndConnectInputSchema = z.strictObject({
|
|
27
|
+
...projectCreateFields,
|
|
28
|
+
pooled: pooledField
|
|
29
|
+
});
|
|
30
|
+
const workflowIds = ["createBranchWithCompute", "createProjectAndConnect"];
|
|
31
|
+
const resolveApiKey = (options, context) => {
|
|
32
|
+
if (context !== void 0 && "apiKey" in context) {
|
|
33
|
+
if (context.apiKey === void 0) throw new TypeError("A Neon API key or OAuth access token is required");
|
|
34
|
+
return requireBearerCredential(context.apiKey);
|
|
35
|
+
}
|
|
36
|
+
return options.apiKey === void 0 ? missingBearerCredential : requireBearerCredential(options.apiKey);
|
|
37
|
+
};
|
|
38
|
+
const workflowClient = (options, context) => createNeonClient({
|
|
39
|
+
apiKey: resolveApiKey(options, context),
|
|
40
|
+
throwOnError: true,
|
|
41
|
+
...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
|
|
42
|
+
...options.fetch === void 0 ? {} : { fetch: options.fetch },
|
|
43
|
+
...options.wait === void 0 ? {} : { wait: options.wait }
|
|
44
|
+
});
|
|
45
|
+
const bindWorkflow = (options, tool, run) => ({
|
|
46
|
+
...tool,
|
|
47
|
+
async execute(input, context) {
|
|
48
|
+
const parsed = await tool.inputSchema.parseAsync(input);
|
|
49
|
+
const result = await run(workflowClient(options, context), parsed, context?.signal);
|
|
50
|
+
return toToolResult(result);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const createBranchWithComputeTool = (options) => bindWorkflow(options, {
|
|
54
|
+
operationId: "createBranchWithCompute",
|
|
55
|
+
id: "create_branch_with_compute",
|
|
56
|
+
title: "Create branch with compute",
|
|
57
|
+
description: "Create a branch with a read-write endpoint and return its connection string. Use this instead of create_project_branch when the next step needs to connect: create_project_branch omits compute unless you pass endpoints, and it does not wait or return a connection string. The call waits until the compute is ready, up to five minutes by default.",
|
|
58
|
+
inputSchema: createBranchWithComputeInputSchema,
|
|
59
|
+
annotations: writeAnnotations,
|
|
60
|
+
requiresApproval: true,
|
|
61
|
+
metadata: {
|
|
62
|
+
method: "POST",
|
|
63
|
+
path: "/projects/{project_id}/branches",
|
|
64
|
+
stability: "stable",
|
|
65
|
+
deprecated: false,
|
|
66
|
+
tags: ["Branch"]
|
|
67
|
+
}
|
|
68
|
+
}, (neon, input, signal) => neon.branches.createWithCompute(input.project_id, {
|
|
69
|
+
name: input.name,
|
|
70
|
+
parentId: input.parent_id,
|
|
71
|
+
compute: input.compute === void 0 ? void 0 : {
|
|
72
|
+
minCu: input.compute.min_cu,
|
|
73
|
+
maxCu: input.compute.max_cu,
|
|
74
|
+
suspendTimeoutSeconds: input.compute.suspend_timeout_seconds
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
signal,
|
|
78
|
+
...input.pooled === void 0 ? {} : { pooled: input.pooled }
|
|
79
|
+
}));
|
|
80
|
+
const createProjectAndConnectTool = (options) => bindWorkflow(options, {
|
|
81
|
+
operationId: "createProjectAndConnect",
|
|
82
|
+
id: "create_project_and_connect",
|
|
83
|
+
title: "Create project and connect",
|
|
84
|
+
description: "Create a project and return a connection string to its default branch. Use this instead of create_project when the next step needs to connect. The call waits until the default compute is ready, up to five minutes by default.",
|
|
85
|
+
inputSchema: createProjectAndConnectInputSchema,
|
|
86
|
+
annotations: writeAnnotations,
|
|
87
|
+
requiresApproval: true,
|
|
88
|
+
metadata: {
|
|
89
|
+
method: "POST",
|
|
90
|
+
path: "/projects",
|
|
91
|
+
stability: "stable",
|
|
92
|
+
deprecated: false,
|
|
93
|
+
tags: ["Project"]
|
|
94
|
+
}
|
|
95
|
+
}, (neon, input, signal) => {
|
|
96
|
+
const { pooled, ...project } = input;
|
|
97
|
+
return neon.projects.createAndConnect(project, {
|
|
98
|
+
signal,
|
|
99
|
+
...pooled === void 0 ? {} : { pooled }
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const workflowFactories = {
|
|
103
|
+
createBranchWithCompute: createBranchWithComputeTool,
|
|
104
|
+
createProjectAndConnect: createProjectAndConnectTool
|
|
105
|
+
};
|
|
106
|
+
const isNeonWorkflowId = (id) => workflowIds.includes(id);
|
|
107
|
+
const workflowFactoryFor = (workflowId) => {
|
|
108
|
+
const knownWorkflowId = workflowIds.find((candidate) => candidate === workflowId);
|
|
109
|
+
if (knownWorkflowId === void 0) throw new TypeError(`Unknown Neon workflow "${workflowId}".`);
|
|
110
|
+
return workflowFactories[knownWorkflowId];
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
export { createBranchWithComputeInputSchema, createProjectAndConnectInputSchema, isNeonWorkflowId, workflowFactories, workflowFactoryFor, workflowIds };
|