neon 8.11.1 → 8.11.2
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 +1 -1
- package/dist/_chunks/api-GbEaBZJ5.js +388 -0
- package/dist/_chunks/api_keys-CNnnugbQ.js +281 -0
- package/dist/_chunks/ask-DVwy0eUL.js +155 -0
- package/dist/_chunks/auth-CIUtXByB.js +495 -0
- package/dist/_chunks/bootstrap-wPZWa1sT.js +499 -0
- package/dist/_chunks/branches-BNa1xX1L.js +460 -0
- package/dist/_chunks/bucket-BCdryTkD.js +409 -0
- package/dist/_chunks/checkout-CXIOydqZ.js +348 -0
- package/dist/_chunks/claim-DqAvAvDm.js +473 -0
- package/dist/_chunks/config-BH_qRHiG.js +1113 -0
- package/dist/_chunks/connection_string-DB4awPzZ.js +154 -0
- package/dist/_chunks/credentials-BSjE9fRR.js +146 -0
- package/dist/_chunks/data_api-Djxj5ZQD.js +263 -0
- package/dist/_chunks/databases-Dok4wru7.js +84 -0
- package/dist/_chunks/deploy-D7B0Xfjg.js +33 -0
- package/dist/_chunks/dev-CSvxAecE.js +945 -0
- package/dist/_chunks/diff-DhxxbdQE.js +178 -0
- package/dist/_chunks/docs-CrVybkTP.js +197 -0
- package/dist/_chunks/env-5HS5qQGd.js +284 -0
- package/dist/_chunks/feedback-CMayyTa8.js +88 -0
- package/dist/_chunks/functions-Q0zuvtnk.js +464 -0
- package/dist/_chunks/git-H32TNt6M.js +356 -0
- package/dist/_chunks/init-BkA6RilG.js +111 -0
- package/dist/_chunks/inspect-g0wekylj.js +90 -0
- package/dist/_chunks/ip_allow-5lLFvIuE.js +106 -0
- package/dist/_chunks/link-BgtkOBws.js +936 -0
- package/dist/_chunks/logs-DWkpjzIH.js +291 -0
- package/dist/_chunks/mcp-Bo-7TKc7.js +253 -0
- package/dist/_chunks/neon_auth-CBs1_3qu.js +822 -0
- package/dist/_chunks/open-CX3BT3Tp.js +33 -0
- package/dist/_chunks/operations-D4I-AxVs.js +37 -0
- package/dist/_chunks/orgs-xGfANwHQ.js +52 -0
- package/dist/_chunks/plugins-DqD7BDO1.js +169 -0
- package/dist/_chunks/profile-yXOiKk9R.js +672 -0
- package/dist/_chunks/projects-BwI2Uo0z.js +439 -0
- package/dist/_chunks/psql-BM-doe8e.js +64 -0
- package/dist/_chunks/realtime-BRqIyGR-.js +79 -0
- package/dist/_chunks/roles-B4w3YT_7.js +79 -0
- package/dist/_chunks/set_context-DbrwoImy.js +38 -0
- package/dist/_chunks/skills-DyiBXKS3.js +255 -0
- package/dist/_chunks/snapshots-RJBzW8GM.js +338 -0
- package/dist/_chunks/status-DV8Z2kw3.js +44 -0
- package/dist/_chunks/triggers-BrRo1z4b.js +302 -0
- package/dist/_chunks/user-dlOGXbX9.js +60 -0
- package/dist/_chunks/vpc_endpoints-CNb0YfMo.js +105 -0
- package/dist/auth_recovery.js +1 -1
- package/dist/commands/api.js +1 -388
- package/dist/commands/api_keys.js +1 -281
- package/dist/commands/ask.js +1 -155
- package/dist/commands/auth.js +1 -495
- package/dist/commands/bootstrap.js +1 -499
- package/dist/commands/branches.js +1 -460
- package/dist/commands/bucket.js +1 -409
- package/dist/commands/checkout.js +1 -348
- package/dist/commands/claim.js +1 -473
- package/dist/commands/config.js +1 -1113
- package/dist/commands/connection_string.js +1 -154
- package/dist/commands/credentials.js +1 -146
- package/dist/commands/data_api.js +1 -263
- package/dist/commands/databases.js +1 -84
- package/dist/commands/deploy.js +1 -33
- package/dist/commands/dev.js +1 -945
- package/dist/commands/diff.js +1 -178
- package/dist/commands/docs.js +1 -197
- package/dist/commands/env.js +1 -284
- package/dist/commands/feedback.js +1 -88
- package/dist/commands/functions.js +1 -464
- package/dist/commands/functions_new.js +1 -1
- package/dist/commands/git.js +1 -356
- package/dist/commands/index.js +45 -45
- package/dist/commands/init.js +1 -111
- package/dist/commands/inspect.js +1 -90
- package/dist/commands/ip_allow.js +1 -106
- package/dist/commands/link.js +1 -936
- package/dist/commands/logs.js +1 -291
- package/dist/commands/mcp.js +1 -253
- package/dist/commands/neon_auth.js +1 -822
- package/dist/commands/open.js +1 -33
- package/dist/commands/operations.js +1 -37
- package/dist/commands/orgs.js +1 -52
- package/dist/commands/plugins.js +1 -169
- package/dist/commands/profile.js +1 -672
- package/dist/commands/projects.js +1 -439
- package/dist/commands/psql.js +1 -64
- package/dist/commands/realtime.js +1 -79
- package/dist/commands/roles.js +1 -79
- package/dist/commands/set_context.js +1 -38
- package/dist/commands/skills.js +1 -255
- package/dist/commands/snapshots.js +1 -338
- package/dist/commands/status.js +1 -44
- package/dist/commands/subscribe.js +1 -1
- package/dist/commands/triggers.js +1 -302
- package/dist/commands/user.js +1 -60
- package/dist/commands/vpc_endpoints.js +1 -105
- package/dist/functions/registry.js +29 -151
- package/dist/functions/source.js +42 -2
- package/dist/index.js +1 -1
- package/dist/init/auth.js +3 -3
- package/dist/init/link.js +2 -2
- package/dist/init/run.js +3 -3
- package/dist/init/tooling.js +3 -3
- package/dist/mcp/mint.js +1 -1
- package/dist/test_utils/registry.js +1 -2
- package/package.json +8 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { writer } from "../writer.js";
|
|
2
|
-
import { o as resolveNeonEnvVars } from "../_chunks/env-BNm69Qh8.js";
|
|
3
2
|
import { branchIdFromProps } from "../utils/enrichers.js";
|
|
3
|
+
import { o as resolveNeonEnvVars } from "../_chunks/env-BNm69Qh8.js";
|
|
4
4
|
import YAML from "yaml";
|
|
5
5
|
//#region src/commands/subscribe.ts
|
|
6
6
|
const builder = (argv) => argv.usage("$0 realtime subscribe \"<query>\" [options]").positional("query", {
|
|
@@ -1,302 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { log } from "../log.js";
|
|
3
|
-
import { isNeonApiError, messageFromBody, retryOnLock } from "../api.js";
|
|
4
|
-
import { writer } from "../writer.js";
|
|
5
|
-
import { branchIdFromProps, fillSingleProject } from "../utils/enrichers.js";
|
|
6
|
-
//#region src/commands/triggers.ts
|
|
7
|
-
var triggers_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
TRIGGER_FIELDS: () => TRIGGER_FIELDS,
|
|
9
|
-
aliases: () => aliases,
|
|
10
|
-
builder: () => builder,
|
|
11
|
-
command: () => command,
|
|
12
|
-
create: () => create,
|
|
13
|
-
deleteTrigger: () => deleteTrigger,
|
|
14
|
-
describe: () => describe,
|
|
15
|
-
get: () => get,
|
|
16
|
-
handler: () => handler,
|
|
17
|
-
list: () => list,
|
|
18
|
-
update: () => update
|
|
19
|
-
});
|
|
20
|
-
const TRIGGER_NOT_FOUND_MESSAGE = "function trigger not visible on branch";
|
|
21
|
-
/** Translate the trigger-not-found 404 into a resource-specific message; re-throw everything else. */
|
|
22
|
-
async function withTriggerNotFound(triggerId, branchId, run) {
|
|
23
|
-
try {
|
|
24
|
-
return await run();
|
|
25
|
-
} catch (err) {
|
|
26
|
-
if (isNeonApiError(err) && err.status === 404 && messageFromBody(err.data) === TRIGGER_NOT_FOUND_MESSAGE) throw new Error(`Trigger ${triggerId} not found on branch ${branchId}.`);
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const TRIGGER_COMMON_FIELDS = [
|
|
31
|
-
"trigger_id",
|
|
32
|
-
"name",
|
|
33
|
-
"function_slug",
|
|
34
|
-
"function_path",
|
|
35
|
-
"enabled",
|
|
36
|
-
"inherited"
|
|
37
|
-
];
|
|
38
|
-
const TRIGGER_FIELDS = [
|
|
39
|
-
"trigger_id",
|
|
40
|
-
"name",
|
|
41
|
-
"type",
|
|
42
|
-
"function_slug",
|
|
43
|
-
"function_path",
|
|
44
|
-
"schedule",
|
|
45
|
-
"storage",
|
|
46
|
-
"enabled",
|
|
47
|
-
"inherited",
|
|
48
|
-
"next_run_at"
|
|
49
|
-
];
|
|
50
|
-
function storageMatch(config) {
|
|
51
|
-
return config.prefix === void 0 ? config.bucket_name : `${config.bucket_name} ${config.prefix}`;
|
|
52
|
-
}
|
|
53
|
-
function triggerTableRow(t) {
|
|
54
|
-
if (t.type === "schedule") return {
|
|
55
|
-
trigger_id: t.trigger_id,
|
|
56
|
-
name: t.name,
|
|
57
|
-
type: t.type,
|
|
58
|
-
function_slug: t.function_slug,
|
|
59
|
-
function_path: t.function_path,
|
|
60
|
-
schedule: t.schedule.cron,
|
|
61
|
-
storage: "",
|
|
62
|
-
enabled: t.enabled,
|
|
63
|
-
inherited: t.inherited,
|
|
64
|
-
next_run_at: t.next_run_at ?? ""
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
trigger_id: t.trigger_id,
|
|
68
|
-
name: t.name,
|
|
69
|
-
type: t.type,
|
|
70
|
-
function_slug: t.function_slug,
|
|
71
|
-
function_path: t.function_path,
|
|
72
|
-
schedule: "",
|
|
73
|
-
storage: storageMatch(t.storage_object_created),
|
|
74
|
-
enabled: t.enabled,
|
|
75
|
-
inherited: t.inherited,
|
|
76
|
-
next_run_at: ""
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function writeTrigger(props, data, extra) {
|
|
80
|
-
if (props.output !== "table") {
|
|
81
|
-
writer(props).end(data, {
|
|
82
|
-
fields: TRIGGER_COMMON_FIELDS,
|
|
83
|
-
...extra
|
|
84
|
-
});
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const rows = Array.isArray(data) ? data.map(triggerTableRow) : triggerTableRow(data);
|
|
88
|
-
writer(props).end(rows, {
|
|
89
|
-
fields: TRIGGER_FIELDS,
|
|
90
|
-
...extra
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function enabledPatch(type, enabled) {
|
|
94
|
-
if (type === "schedule") return {
|
|
95
|
-
type: "schedule",
|
|
96
|
-
enabled
|
|
97
|
-
};
|
|
98
|
-
return {
|
|
99
|
-
type: "storage_object_created",
|
|
100
|
-
enabled
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function updatePatch(existing, props) {
|
|
104
|
-
if (existing.type === "schedule") {
|
|
105
|
-
const body = { type: "schedule" };
|
|
106
|
-
if (props["function-slug"] !== void 0) body.function_slug = props["function-slug"];
|
|
107
|
-
if (props.name !== void 0) body.name = props.name;
|
|
108
|
-
if (props.cron !== void 0) body.schedule = { cron: props.cron };
|
|
109
|
-
if (props["function-path"] !== void 0) body.function_path = props["function-path"];
|
|
110
|
-
if (props.enabled !== void 0) body.enabled = props.enabled;
|
|
111
|
-
return body;
|
|
112
|
-
}
|
|
113
|
-
const body = { type: "storage_object_created" };
|
|
114
|
-
if (props["function-slug"] !== void 0) body.function_slug = props["function-slug"];
|
|
115
|
-
if (props.name !== void 0) body.name = props.name;
|
|
116
|
-
if (props["function-path"] !== void 0) body.function_path = props["function-path"];
|
|
117
|
-
if (props.enabled !== void 0) body.enabled = props.enabled;
|
|
118
|
-
if (props.bucket !== void 0 || props.prefix !== void 0) body.storage_object_created = {
|
|
119
|
-
bucket_name: props.bucket ?? existing.storage_object_created.bucket_name,
|
|
120
|
-
...props.prefix !== void 0 ? { prefix: props.prefix } : existing.storage_object_created.prefix !== void 0 ? { prefix: existing.storage_object_created.prefix } : {}
|
|
121
|
-
};
|
|
122
|
-
return body;
|
|
123
|
-
}
|
|
124
|
-
function noFieldsToUpdateMessage(type) {
|
|
125
|
-
const flags = type === "schedule" ? [
|
|
126
|
-
"--function-slug",
|
|
127
|
-
"--name",
|
|
128
|
-
"--cron",
|
|
129
|
-
"--function-path",
|
|
130
|
-
"--enabled"
|
|
131
|
-
] : [
|
|
132
|
-
"--function-slug",
|
|
133
|
-
"--name",
|
|
134
|
-
"--bucket",
|
|
135
|
-
"--prefix",
|
|
136
|
-
"--function-path",
|
|
137
|
-
"--enabled"
|
|
138
|
-
];
|
|
139
|
-
const last = flags[flags.length - 1];
|
|
140
|
-
return `No fields to update. Pass at least one of ${flags.slice(0, -1).join(", ")}, or ${last}.`;
|
|
141
|
-
}
|
|
142
|
-
const command = "triggers";
|
|
143
|
-
const describe = "Manage function triggers";
|
|
144
|
-
const aliases = ["trigger"];
|
|
145
|
-
const builder = (argv) => argv.usage("$0 triggers <sub-command> [options]").options({
|
|
146
|
-
"project-id": {
|
|
147
|
-
describe: "Project ID",
|
|
148
|
-
type: "string"
|
|
149
|
-
},
|
|
150
|
-
branch: {
|
|
151
|
-
describe: "Branch ID or name",
|
|
152
|
-
type: "string"
|
|
153
|
-
}
|
|
154
|
-
}).middleware(fillSingleProject).command("list", "List triggers on the branch", (yargs) => yargs, (args) => list(args)).command("get <id>", "Show a trigger", (yargs) => yargs.positional("id", {
|
|
155
|
-
describe: "Trigger ID",
|
|
156
|
-
type: "string"
|
|
157
|
-
}), (args) => get(args)).command("create", "Create a trigger that invokes a function on a cron schedule or when an object is created", (yargs) => yargs.options({
|
|
158
|
-
"function-slug": {
|
|
159
|
-
describe: "Slug of the function to invoke",
|
|
160
|
-
type: "string",
|
|
161
|
-
demandOption: true
|
|
162
|
-
},
|
|
163
|
-
name: {
|
|
164
|
-
describe: "Trigger name (unique per branch)",
|
|
165
|
-
type: "string",
|
|
166
|
-
demandOption: true
|
|
167
|
-
},
|
|
168
|
-
cron: {
|
|
169
|
-
describe: "Five-field UTC cron expression, e.g. '*/15 * * * *'",
|
|
170
|
-
type: "string"
|
|
171
|
-
},
|
|
172
|
-
bucket: {
|
|
173
|
-
describe: "Object-storage bucket to watch (storage_object_created)",
|
|
174
|
-
type: "string"
|
|
175
|
-
},
|
|
176
|
-
prefix: {
|
|
177
|
-
describe: "Object-key prefix to match (requires --bucket on create)",
|
|
178
|
-
type: "string"
|
|
179
|
-
},
|
|
180
|
-
"function-path": {
|
|
181
|
-
describe: "Path the invocation is sent to (default '/')",
|
|
182
|
-
type: "string"
|
|
183
|
-
},
|
|
184
|
-
enabled: {
|
|
185
|
-
describe: "Whether the trigger runs (default true)",
|
|
186
|
-
type: "boolean"
|
|
187
|
-
}
|
|
188
|
-
}), (args) => create(args)).command("update <id>", "Update a trigger", (yargs) => yargs.positional("id", {
|
|
189
|
-
describe: "Trigger ID",
|
|
190
|
-
type: "string"
|
|
191
|
-
}).options({
|
|
192
|
-
"function-slug": {
|
|
193
|
-
describe: "Slug of the function to invoke",
|
|
194
|
-
type: "string"
|
|
195
|
-
},
|
|
196
|
-
name: {
|
|
197
|
-
describe: "Trigger name (unique per branch)",
|
|
198
|
-
type: "string"
|
|
199
|
-
},
|
|
200
|
-
cron: {
|
|
201
|
-
describe: "Five-field UTC cron expression",
|
|
202
|
-
type: "string"
|
|
203
|
-
},
|
|
204
|
-
bucket: {
|
|
205
|
-
describe: "Object-storage bucket to watch (storage_object_created)",
|
|
206
|
-
type: "string"
|
|
207
|
-
},
|
|
208
|
-
prefix: {
|
|
209
|
-
describe: "Object-key prefix to match",
|
|
210
|
-
type: "string"
|
|
211
|
-
},
|
|
212
|
-
"function-path": {
|
|
213
|
-
describe: "Path the invocation is sent to",
|
|
214
|
-
type: "string"
|
|
215
|
-
},
|
|
216
|
-
enabled: {
|
|
217
|
-
describe: "Whether the trigger runs",
|
|
218
|
-
type: "boolean"
|
|
219
|
-
}
|
|
220
|
-
}), (args) => update(args)).command("enable <id>", "Enable a trigger", (yargs) => yargs.positional("id", {
|
|
221
|
-
describe: "Trigger ID",
|
|
222
|
-
type: "string"
|
|
223
|
-
}), (args) => setEnabled(args, true)).command("disable <id>", "Disable a trigger without deleting it", (yargs) => yargs.positional("id", {
|
|
224
|
-
describe: "Trigger ID",
|
|
225
|
-
type: "string"
|
|
226
|
-
}), (args) => setEnabled(args, false)).command("delete <id>", "Delete a trigger", (yargs) => yargs.positional("id", {
|
|
227
|
-
describe: "Trigger ID",
|
|
228
|
-
type: "string"
|
|
229
|
-
}), (args) => deleteTrigger(args));
|
|
230
|
-
const handler = (args) => {
|
|
231
|
-
return args;
|
|
232
|
-
};
|
|
233
|
-
const list = async (props) => {
|
|
234
|
-
const branchId = await branchIdFromProps(props);
|
|
235
|
-
const { data } = await props.apiClient.listProjectBranchTriggers(props.projectId, branchId);
|
|
236
|
-
writeTrigger(props, data.triggers, { emptyMessage: "No triggers found on this branch." });
|
|
237
|
-
};
|
|
238
|
-
const get = async (props) => {
|
|
239
|
-
const branchId = await branchIdFromProps(props);
|
|
240
|
-
const { data } = await withTriggerNotFound(props.id, branchId, () => props.apiClient.getProjectBranchTrigger(props.projectId, branchId, props.id));
|
|
241
|
-
writeTrigger(props, data.trigger);
|
|
242
|
-
};
|
|
243
|
-
const create = async (props) => {
|
|
244
|
-
const branchId = await branchIdFromProps(props);
|
|
245
|
-
const body = createBody(props);
|
|
246
|
-
const { data } = await retryOnLock(() => props.apiClient.createProjectBranchTrigger(props.projectId, branchId, body));
|
|
247
|
-
writeTrigger(props, data.trigger);
|
|
248
|
-
};
|
|
249
|
-
function createBody(props) {
|
|
250
|
-
if (props.cron !== void 0 && props.bucket !== void 0) throw new Error("Pass --cron or --bucket, not both.");
|
|
251
|
-
if (props.prefix !== void 0 && props.bucket === void 0) throw new Error("--prefix requires --bucket.");
|
|
252
|
-
if (props.cron !== void 0) {
|
|
253
|
-
const body = {
|
|
254
|
-
type: "schedule",
|
|
255
|
-
function_slug: props["function-slug"],
|
|
256
|
-
name: props.name,
|
|
257
|
-
schedule: { cron: props.cron }
|
|
258
|
-
};
|
|
259
|
-
if (props["function-path"] !== void 0) body.function_path = props["function-path"];
|
|
260
|
-
if (props.enabled !== void 0) body.enabled = props.enabled;
|
|
261
|
-
return body;
|
|
262
|
-
}
|
|
263
|
-
if (props.bucket !== void 0) {
|
|
264
|
-
const body = {
|
|
265
|
-
type: "storage_object_created",
|
|
266
|
-
function_slug: props["function-slug"],
|
|
267
|
-
name: props.name,
|
|
268
|
-
storage_object_created: {
|
|
269
|
-
bucket_name: props.bucket,
|
|
270
|
-
...props.prefix !== void 0 ? { prefix: props.prefix } : {}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
if (props["function-path"] !== void 0) body.function_path = props["function-path"];
|
|
274
|
-
if (props.enabled !== void 0) body.enabled = props.enabled;
|
|
275
|
-
return body;
|
|
276
|
-
}
|
|
277
|
-
throw new Error("Pass --cron for a schedule trigger, or --bucket for a storage_object_created trigger.");
|
|
278
|
-
}
|
|
279
|
-
const update = async (props) => {
|
|
280
|
-
const branchId = await branchIdFromProps(props);
|
|
281
|
-
const { data: existing } = await withTriggerNotFound(props.id, branchId, () => props.apiClient.getProjectBranchTrigger(props.projectId, branchId, props.id));
|
|
282
|
-
const trigger = existing.trigger;
|
|
283
|
-
if (props.cron !== void 0 && trigger.type !== "schedule") throw new Error(`Trigger ${props.id} is type ${trigger.type}; --cron applies to schedule triggers.`);
|
|
284
|
-
if ((props.bucket !== void 0 || props.prefix !== void 0) && trigger.type !== "storage_object_created") throw new Error(`Trigger ${props.id} is type ${trigger.type}; --bucket and --prefix apply to storage_object_created triggers.`);
|
|
285
|
-
const body = updatePatch(trigger, props);
|
|
286
|
-
if (Object.keys(body).filter((k) => k !== "type").length === 0) throw new Error(noFieldsToUpdateMessage(trigger.type));
|
|
287
|
-
const { data } = await withTriggerNotFound(props.id, branchId, () => retryOnLock(() => props.apiClient.updateProjectBranchTrigger(props.projectId, branchId, props.id, body)));
|
|
288
|
-
writeTrigger(props, data.trigger);
|
|
289
|
-
};
|
|
290
|
-
const setEnabled = async (props, enabled) => {
|
|
291
|
-
const branchId = await branchIdFromProps(props);
|
|
292
|
-
const { data: existing } = await withTriggerNotFound(props.id, branchId, () => props.apiClient.getProjectBranchTrigger(props.projectId, branchId, props.id));
|
|
293
|
-
const { data } = await withTriggerNotFound(props.id, branchId, () => retryOnLock(() => props.apiClient.updateProjectBranchTrigger(props.projectId, branchId, props.id, enabledPatch(existing.trigger.type, enabled))));
|
|
294
|
-
writeTrigger(props, data.trigger);
|
|
295
|
-
};
|
|
296
|
-
const deleteTrigger = async (props) => {
|
|
297
|
-
const branchId = await branchIdFromProps(props);
|
|
298
|
-
await withTriggerNotFound(props.id, branchId, () => retryOnLock(() => props.apiClient.deleteProjectBranchTrigger(props.projectId, branchId, props.id)));
|
|
299
|
-
log.info(`Trigger ${props.id} deleted`);
|
|
300
|
-
};
|
|
301
|
-
//#endregion
|
|
302
|
-
export { TRIGGER_FIELDS, aliases, builder, command, create, deleteTrigger, describe, get, handler, list, triggers_exports as t, update };
|
|
1
|
+
export { t as TRIGGER_FIELDS, n as aliases, r as builder, i as command, a as create, o as deleteTrigger, s as describe, c as get, l as handler, u as list, f as update } from "../_chunks/triggers-BrRo1z4b.js";
|
package/dist/commands/user.js
CHANGED
|
@@ -1,60 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { getAuthContext } from "../auth_context.js";
|
|
3
|
-
import { writer } from "../writer.js";
|
|
4
|
-
//#region src/commands/user.ts
|
|
5
|
-
var user_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
-
authenticationLabel: () => authenticationLabel,
|
|
7
|
-
builder: () => builder,
|
|
8
|
-
command: () => "me",
|
|
9
|
-
describe: () => describe,
|
|
10
|
-
handler: () => handler,
|
|
11
|
-
userDetails: () => userDetails
|
|
12
|
-
});
|
|
13
|
-
const command = "me";
|
|
14
|
-
const describe = "Show current user";
|
|
15
|
-
const builder = (yargs) => yargs.option("context-file", { hidden: true });
|
|
16
|
-
const handler = async (args) => {
|
|
17
|
-
await me(args);
|
|
18
|
-
};
|
|
19
|
-
const me = async (props) => {
|
|
20
|
-
if (!props.apiClient) return;
|
|
21
|
-
const { data } = await props.apiClient.getCurrentUserInfo();
|
|
22
|
-
if (props.output === "json" || props.output === "yaml") {
|
|
23
|
-
writer(props).end(data, { fields: [
|
|
24
|
-
"login",
|
|
25
|
-
"email",
|
|
26
|
-
"name",
|
|
27
|
-
"projects_limit"
|
|
28
|
-
] });
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
writer(props).end(userDetails(data, getAuthContext()), { fields: [
|
|
32
|
-
"login",
|
|
33
|
-
"email",
|
|
34
|
-
"name",
|
|
35
|
-
"projects_limit",
|
|
36
|
-
"authentication"
|
|
37
|
-
] });
|
|
38
|
-
};
|
|
39
|
-
/** Table-only view; the field names become the row labels. */
|
|
40
|
-
const userDetails = (user, auth) => ({
|
|
41
|
-
login: user.login,
|
|
42
|
-
email: user.email,
|
|
43
|
-
name: [user.name, user.last_name].filter(Boolean).join(" "),
|
|
44
|
-
projects_limit: user.projects_limit === 0 ? void 0 : user.projects_limit,
|
|
45
|
-
authentication: auth ? authenticationLabel(auth) : void 0
|
|
46
|
-
});
|
|
47
|
-
const authenticationLabel = (auth) => {
|
|
48
|
-
const profile = auth.profile ? ` (profile ${auth.profile})` : "";
|
|
49
|
-
switch (auth.source) {
|
|
50
|
-
case "stored-credentials": return `OAuth${profile}`;
|
|
51
|
-
case "profile-api-key": return `API key${profile}`;
|
|
52
|
-
case "api-key":
|
|
53
|
-
if (auth.apiKeyFrom === "flag") return "API key (--api-key)";
|
|
54
|
-
if (auth.apiKeyFrom === "env") return "API key (NEON_API_KEY)";
|
|
55
|
-
return "API key";
|
|
56
|
-
case "claimable": return "Claimable project";
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
//#endregion
|
|
60
|
-
export { authenticationLabel, builder, command, describe, handler, user_exports as t, userDetails };
|
|
1
|
+
export { t as authenticationLabel, n as builder, r as command, i as describe, a as handler, o as userDetails } from "../_chunks/user-dlOGXbX9.js";
|
|
@@ -1,105 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { log } from "../log.js";
|
|
3
|
-
import { writer } from "../writer.js";
|
|
4
|
-
import { fillSingleOrg, fillSingleProject } from "../utils/enrichers.js";
|
|
5
|
-
import { REGIONS } from "./projects.js";
|
|
6
|
-
//#region src/commands/vpc_endpoints.ts
|
|
7
|
-
var vpc_endpoints_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
builder: () => builder,
|
|
9
|
-
command: () => "vpc",
|
|
10
|
-
describe: () => describe
|
|
11
|
-
});
|
|
12
|
-
const VPC_ENDPOINT_FIELDS = ["vpc_endpoint_id", "label"];
|
|
13
|
-
const VPC_ENDPOINT_DETAILS_FIELDS = [
|
|
14
|
-
"vpc_endpoint_id",
|
|
15
|
-
"label",
|
|
16
|
-
"state",
|
|
17
|
-
"num_restricted_projects",
|
|
18
|
-
"example_restricted_projects"
|
|
19
|
-
];
|
|
20
|
-
const command = "vpc";
|
|
21
|
-
const describe = "Manage VPC endpoints and project VPC restrictions";
|
|
22
|
-
const builder = (argv) => {
|
|
23
|
-
return argv.usage("$0 vpc <sub-command> [options]").command("endpoint", "Manage VPC endpoints.\nSee: https://neon.tech/docs/guides/neon-private-networking\nAfter adding an endpoint to an organization, client connections will be accepted\nfrom the corresponding VPC for all projects in the organization, unless overridden\nby a project-level VPC endpoint restriction.", (yargs) => {
|
|
24
|
-
return yargs.options({
|
|
25
|
-
"org-id": {
|
|
26
|
-
describe: "Organization ID",
|
|
27
|
-
type: "string"
|
|
28
|
-
},
|
|
29
|
-
"region-id": {
|
|
30
|
-
describe: `The region ID. Possible values: ${REGIONS.join(", ")}`,
|
|
31
|
-
type: "string"
|
|
32
|
-
}
|
|
33
|
-
}).middleware(fillSingleOrg).command("list", "List configured VPC endpoints for this organization.", (yargs) => yargs.demandOption("region-id"), async (args) => {
|
|
34
|
-
await listOrg(args);
|
|
35
|
-
}).command({
|
|
36
|
-
command: "assign <id>",
|
|
37
|
-
aliases: ["update <id>", "add <id>"],
|
|
38
|
-
describe: "Add or update a VPC endpoint for this organization.\nNote: Azure regions are not yet supported.",
|
|
39
|
-
builder: (yargs) => yargs.options({ label: {
|
|
40
|
-
describe: "An optional descriptive label for the VPC endpoint",
|
|
41
|
-
type: "string"
|
|
42
|
-
} }).demandOption("region-id"),
|
|
43
|
-
handler: async (args) => {
|
|
44
|
-
await assignOrg(args);
|
|
45
|
-
}
|
|
46
|
-
}).command("remove <id>", "Remove a VPC endpoint from this organization.", (yargs) => yargs.demandOption("region-id"), async (args) => {
|
|
47
|
-
await removeOrg(args);
|
|
48
|
-
}).command("status <id>", "Get the status of a VPC endpoint for this organization.", (yargs) => yargs.demandOption("region-id"), async (args) => {
|
|
49
|
-
await statusOrg(args);
|
|
50
|
-
});
|
|
51
|
-
}).command("project", "Manage project-level VPC endpoint restrictions.\nBy default, connections are accepted from any VPC configured at the organization level.\nA project-level VPC endpoint restriction can be used to restrict connections to a specific VPC.", (yargs) => {
|
|
52
|
-
return yargs.options({ "project-id": {
|
|
53
|
-
describe: "Project ID",
|
|
54
|
-
type: "string"
|
|
55
|
-
} }).middleware(fillSingleProject).command("list", "List VPC endpoint restrictions for this project.", (yargs) => yargs, async (args) => {
|
|
56
|
-
await listProject(args);
|
|
57
|
-
}).command({
|
|
58
|
-
command: "restrict <id>",
|
|
59
|
-
aliases: ["update <id>"],
|
|
60
|
-
describe: "Configure or update a VPC endpoint restriction for this project.",
|
|
61
|
-
builder: (yargs) => yargs.options({ label: {
|
|
62
|
-
describe: "An optional descriptive label for the VPC endpoint restriction",
|
|
63
|
-
type: "string"
|
|
64
|
-
} }),
|
|
65
|
-
handler: async (args) => {
|
|
66
|
-
await assignProject(args);
|
|
67
|
-
}
|
|
68
|
-
}).command("remove <id>", "Remove a VPC endpoint restriction from this project.", (yargs) => yargs, async (args) => {
|
|
69
|
-
await removeProject(args);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
const listOrg = async (props) => {
|
|
74
|
-
const { data } = await props.apiClient.listOrganizationVpcEndpoints(props.orgId, props.regionId);
|
|
75
|
-
writer(props).end(data.endpoints, { fields: VPC_ENDPOINT_FIELDS });
|
|
76
|
-
};
|
|
77
|
-
const assignOrg = async (props) => {
|
|
78
|
-
const vpcEndpointAssignment = { label: props.label || "" };
|
|
79
|
-
const { data } = await props.apiClient.assignOrganizationVpcEndpoint(props.orgId, props.regionId, props.id, vpcEndpointAssignment);
|
|
80
|
-
writer(props).end(data, { fields: [] });
|
|
81
|
-
if (props.regionId.startsWith("azure")) log.info("VPC endpoint configuration is not supported for Azure regions");
|
|
82
|
-
};
|
|
83
|
-
const removeOrg = async (props) => {
|
|
84
|
-
const { data } = await props.apiClient.deleteOrganizationVpcEndpoint(props.orgId, props.regionId, props.id);
|
|
85
|
-
writer(props).end(data, { fields: [] });
|
|
86
|
-
};
|
|
87
|
-
const statusOrg = async (props) => {
|
|
88
|
-
const { data } = await props.apiClient.getOrganizationVpcEndpointDetails(props.orgId, props.regionId, props.id);
|
|
89
|
-
writer(props).end(data, { fields: VPC_ENDPOINT_DETAILS_FIELDS });
|
|
90
|
-
};
|
|
91
|
-
const listProject = async (props) => {
|
|
92
|
-
const { data } = await props.apiClient.listProjectVpcEndpoints(props.projectId);
|
|
93
|
-
writer(props).end(data.endpoints, { fields: VPC_ENDPOINT_FIELDS });
|
|
94
|
-
};
|
|
95
|
-
const assignProject = async (props) => {
|
|
96
|
-
const vpcEndpointAssignment = { label: props.label || "" };
|
|
97
|
-
const { data } = await props.apiClient.assignProjectVpcEndpoint(props.projectId, props.id, vpcEndpointAssignment);
|
|
98
|
-
writer(props).end(data, { fields: [] });
|
|
99
|
-
};
|
|
100
|
-
const removeProject = async (props) => {
|
|
101
|
-
const { data } = await props.apiClient.deleteProjectVpcEndpoint(props.projectId, props.id);
|
|
102
|
-
writer(props).end(data, { fields: [] });
|
|
103
|
-
};
|
|
104
|
-
//#endregion
|
|
105
|
-
export { builder, command, describe, vpc_endpoints_exports as t };
|
|
1
|
+
export { t as builder, n as command, r as describe } from "../_chunks/vpc_endpoints-CNb0YfMo.js";
|