neon 3.0.0 → 3.1.1

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 (207) hide show
  1. package/README.md +70 -5
  2. package/dist/_chunks/auth_selection-DGgq6ifc.js +83 -0
  3. package/dist/_chunks/cmd_pipeline-CUbBO9U_.js +2818 -0
  4. package/dist/_chunks/credentials-MYdHdKah.js +188 -0
  5. package/dist/_chunks/env-NbA61JR3.js +585 -0
  6. package/dist/_chunks/env_services-Tz9G4JeT.js +531 -0
  7. package/dist/_chunks/paths-DMq0Lt7a.js +151 -0
  8. package/dist/_chunks/profiles-Ir29rqns.js +217 -0
  9. package/dist/_chunks/psql-DWH-kc69.js +2169 -0
  10. package/dist/_chunks/rolldown-runtime-D7D4PA-g.js +13 -0
  11. package/dist/_chunks/secure_file-BucZj4yQ.js +39 -0
  12. package/dist/analytics.js +163 -207
  13. package/dist/api.js +815 -758
  14. package/dist/auth.js +121 -141
  15. package/dist/auth_context.js +39 -53
  16. package/dist/cli.js +4 -7
  17. package/dist/commands/api.js +220 -250
  18. package/dist/commands/api_keys.js +251 -314
  19. package/dist/commands/auth.js +283 -328
  20. package/dist/commands/bootstrap.js +372 -437
  21. package/dist/commands/branches.js +304 -455
  22. package/dist/commands/bucket.js +374 -514
  23. package/dist/commands/checkout.js +213 -298
  24. package/dist/commands/config.js +573 -690
  25. package/dist/commands/connection_string.js +137 -165
  26. package/dist/commands/data_api.js +238 -260
  27. package/dist/commands/databases.js +67 -76
  28. package/dist/commands/deploy.js +31 -25
  29. package/dist/commands/dev.js +639 -719
  30. package/dist/commands/diff.js +156 -200
  31. package/dist/commands/env.js +255 -305
  32. package/dist/commands/functions.js +275 -355
  33. package/dist/commands/index.js +70 -65
  34. package/dist/commands/init.js +84 -119
  35. package/dist/commands/inspect.js +55 -55
  36. package/dist/commands/ip_allow.js +88 -120
  37. package/dist/commands/link.js +874 -1019
  38. package/dist/commands/logs.js +291 -0
  39. package/dist/commands/neon_auth.js +725 -933
  40. package/dist/commands/operations.js +34 -25
  41. package/dist/commands/orgs.js +28 -18
  42. package/dist/commands/profile.js +615 -846
  43. package/dist/commands/projects.js +313 -373
  44. package/dist/commands/psql.js +60 -58
  45. package/dist/commands/roles.js +55 -58
  46. package/dist/commands/schema_diff.js +87 -131
  47. package/dist/commands/set_context.js +34 -26
  48. package/dist/commands/snapshots.js +288 -413
  49. package/dist/commands/status.js +41 -37
  50. package/dist/commands/user.js +21 -10
  51. package/dist/commands/vpc_endpoints.js +85 -113
  52. package/dist/config.js +7 -6
  53. package/dist/config_format.js +50 -66
  54. package/dist/config_template.js +128 -157
  55. package/dist/context.js +183 -235
  56. package/dist/current_branch_fast_path.js +40 -49
  57. package/dist/dev/env.js +2 -446
  58. package/dist/dev/functions.js +54 -68
  59. package/dist/dev/inputs.js +46 -58
  60. package/dist/dev/runtime.js +135 -164
  61. package/dist/dev/websocket.js +766 -959
  62. package/dist/env.js +27 -33
  63. package/dist/env_file.js +118 -132
  64. package/dist/env_services.js +2 -51
  65. package/dist/errors.js +57 -68
  66. package/dist/functions_api.js +45 -43
  67. package/dist/help.js +189 -140
  68. package/dist/index.js +182 -257
  69. package/dist/init/agents.js +137 -118
  70. package/dist/init/auth.js +58 -68
  71. package/dist/init/bootstrap.js +325 -396
  72. package/dist/init/build_config.js +4 -2
  73. package/dist/init/detect_agent.js +56 -101
  74. package/dist/init/editors.js +35 -52
  75. package/dist/init/enrich_output.js +51 -66
  76. package/dist/init/extension.js +134 -171
  77. package/dist/init/inspect.js +179 -266
  78. package/dist/init/interactive.js +510 -622
  79. package/dist/init/neonctl.js +117 -168
  80. package/dist/init/orchestrate.js +157 -173
  81. package/dist/init/phases/auth.js +188 -202
  82. package/dist/init/phases/cleanup.js +23 -23
  83. package/dist/init/phases/db.js +251 -277
  84. package/dist/init/phases/getting_started.js +213 -223
  85. package/dist/init/phases/mcp.js +174 -224
  86. package/dist/init/phases/migrations.js +247 -248
  87. package/dist/init/phases/neon_auth.js +114 -133
  88. package/dist/init/phases/setup.js +546 -703
  89. package/dist/init/phases/skills.js +75 -86
  90. package/dist/init/phases/status.js +72 -67
  91. package/dist/init/resolve_context.js +102 -99
  92. package/dist/init/route_command.js +91 -98
  93. package/dist/init/skills.js +174 -218
  94. package/dist/init/vsix.js +77 -99
  95. package/dist/log.js +17 -16
  96. package/dist/neon_services.js +104 -129
  97. package/dist/parameters.gen.js +481 -471
  98. package/dist/pkg.js +17 -19
  99. package/dist/profile_keys.js +44 -47
  100. package/dist/psql/cli.js +44 -47
  101. package/dist/psql/command/cmd_cond.js +231 -406
  102. package/dist/psql/command/cmd_connect.js +557 -764
  103. package/dist/psql/command/cmd_copy.js +728 -984
  104. package/dist/psql/command/cmd_describe.js +1499 -1688
  105. package/dist/psql/command/cmd_format.js +733 -905
  106. package/dist/psql/command/cmd_io.js +2 -2193
  107. package/dist/psql/command/cmd_lo.js +297 -359
  108. package/dist/psql/command/cmd_meta.js +727 -878
  109. package/dist/psql/command/cmd_misc.js +138 -172
  110. package/dist/psql/command/cmd_pipeline.js +2 -1148
  111. package/dist/psql/command/cmd_restrict.js +119 -155
  112. package/dist/psql/command/cmd_show.js +529 -688
  113. package/dist/psql/command/dispatch.js +260 -325
  114. package/dist/psql/command/inputQueue.js +35 -33
  115. package/dist/psql/command/shared.js +49 -63
  116. package/dist/psql/complete/filenames.js +90 -133
  117. package/dist/psql/complete/index.js +59 -97
  118. package/dist/psql/complete/matcher.js +236 -300
  119. package/dist/psql/complete/psqlVars.js +218 -223
  120. package/dist/psql/complete/queries.js +159 -177
  121. package/dist/psql/complete/rules.js +1493 -2299
  122. package/dist/psql/core/common.js +2 -1253
  123. package/dist/psql/core/help.js +456 -546
  124. package/dist/psql/core/mainloop.js +692 -1303
  125. package/dist/psql/core/prompt.js +391 -408
  126. package/dist/psql/core/settings.js +429 -644
  127. package/dist/psql/core/sqlHelp.js +480 -554
  128. package/dist/psql/core/startup.js +2 -846
  129. package/dist/psql/core/syncVars.js +67 -110
  130. package/dist/psql/core/variables.js +156 -278
  131. package/dist/psql/describe/formatters.js +884 -1285
  132. package/dist/psql/describe/processNamePattern.js +173 -260
  133. package/dist/psql/describe/queries.js +1368 -2403
  134. package/dist/psql/describe/versionGate.js +32 -41
  135. package/dist/psql/index.js +2 -2030
  136. package/dist/psql/io/history.js +232 -271
  137. package/dist/psql/io/input.js +103 -108
  138. package/dist/psql/io/lineEditor/buffer.js +238 -319
  139. package/dist/psql/io/lineEditor/complete.js +135 -213
  140. package/dist/psql/io/lineEditor/filename.js +139 -148
  141. package/dist/psql/io/lineEditor/index.js +653 -870
  142. package/dist/psql/io/lineEditor/keymap.js +544 -702
  143. package/dist/psql/io/lineEditor/vt100.js +294 -341
  144. package/dist/psql/io/pgpass.js +158 -187
  145. package/dist/psql/io/pgservice.js +146 -183
  146. package/dist/psql/io/psqlrc.js +328 -403
  147. package/dist/psql/print/aligned.js +1020 -1683
  148. package/dist/psql/print/asciidoc.js +180 -214
  149. package/dist/psql/print/crosstab.js +281 -442
  150. package/dist/psql/print/csv.js +48 -70
  151. package/dist/psql/print/html.js +195 -226
  152. package/dist/psql/print/json.js +75 -88
  153. package/dist/psql/print/latex.js +291 -364
  154. package/dist/psql/print/pager.js +171 -242
  155. package/dist/psql/print/troff.js +194 -226
  156. package/dist/psql/print/unaligned.js +69 -95
  157. package/dist/psql/print/units.js +167 -169
  158. package/dist/psql/scanner/slash.js +428 -483
  159. package/dist/psql/scanner/sql.js +445 -889
  160. package/dist/psql/scanner/stringutils.js +309 -379
  161. package/dist/psql/types/index.js +8 -7
  162. package/dist/psql/types/scanner.js +25 -22
  163. package/dist/psql/wire/connection.js +2042 -2803
  164. package/dist/psql/wire/copy.js +84 -100
  165. package/dist/psql/wire/notify.js +39 -59
  166. package/dist/psql/wire/pipeline.js +305 -518
  167. package/dist/psql/wire/protocol.js +349 -417
  168. package/dist/psql/wire/sasl.js +180 -265
  169. package/dist/psql/wire/tls.js +400 -561
  170. package/dist/storage_api.js +115 -129
  171. package/dist/test_utils/fixtures.js +94 -113
  172. package/dist/test_utils/oauth_server.js +10 -7
  173. package/dist/test_utils/project_dir.js +33 -0
  174. package/dist/utils/ai_gateway_notice.js +131 -162
  175. package/dist/utils/api_enums.js +21 -28
  176. package/dist/utils/auth.js +10 -4
  177. package/dist/utils/branch_notice.js +20 -19
  178. package/dist/utils/branch_picker.js +83 -89
  179. package/dist/utils/cli_name.js +15 -12
  180. package/dist/utils/compute_units.js +20 -27
  181. package/dist/utils/config_diff.js +127 -158
  182. package/dist/utils/enrichers.js +95 -148
  183. package/dist/utils/esbuild.js +130 -189
  184. package/dist/utils/flags.js +35 -47
  185. package/dist/utils/formats.js +8 -15
  186. package/dist/utils/git_diff.js +69 -80
  187. package/dist/utils/inspect_db.js +101 -143
  188. package/dist/utils/inspect_queries.js +179 -142
  189. package/dist/utils/middlewares.js +39 -45
  190. package/dist/utils/openapi.js +87 -99
  191. package/dist/utils/package_manager.js +312 -110
  192. package/dist/utils/point_in_time.js +49 -53
  193. package/dist/utils/psql.js +89 -106
  194. package/dist/utils/service_picker.js +55 -58
  195. package/dist/utils/string.js +5 -5
  196. package/dist/utils/ui.js +38 -55
  197. package/dist/utils/write_sync.js +26 -35
  198. package/dist/utils/zip.js +4 -3
  199. package/dist/writer.js +67 -87
  200. package/package.json +11 -6
  201. package/dist/_shared/auth_selection.js +0 -86
  202. package/dist/_shared/credentials.js +0 -209
  203. package/dist/_shared/env-core/env.js +0 -558
  204. package/dist/_shared/env-core/reuse-secrets.js +0 -223
  205. package/dist/_shared/paths.js +0 -148
  206. package/dist/_shared/profiles.js +0 -276
  207. package/dist/_shared/secure_file.js +0 -43
@@ -0,0 +1,291 @@
1
+ import { t as __exportAll } from "../_chunks/rolldown-runtime-D7D4PA-g.js";
2
+ import { log } from "../log.js";
3
+ import { isNeonApiError } from "../api.js";
4
+ import { writer } from "../writer.js";
5
+ import { noPassthrough, single } from "../utils/flags.js";
6
+ import { branchIdFromProps, fillSingleProject } from "../utils/enrichers.js";
7
+ //#region src/commands/logs.ts
8
+ var logs_exports = /* @__PURE__ */ __exportAll({
9
+ assertReachableLogsPage: () => assertReachableLogsPage,
10
+ buildLogsQueryBody: () => buildLogsQueryBody,
11
+ builder: () => builder,
12
+ command: () => command,
13
+ describe: () => describe,
14
+ escapeLogSingleLine: () => escapeLogSingleLine,
15
+ escapeLogTableCell: () => escapeLogTableCell,
16
+ handler: () => handler
17
+ });
18
+ const LOGS_EPILOG = `
19
+ Logs require Neon Platform Beta and are currently available only for projects in aws-us-east-2.
20
+
21
+ For more information, visit https://neon.com/docs/reference/neon-cli`;
22
+ const LOG_SOURCES = [
23
+ "function",
24
+ "storage",
25
+ "pg_endpoint"
26
+ ];
27
+ const LOG_SORT_ORDERS = ["asc", "desc"];
28
+ const LOG_SEVERITIES = [
29
+ "trace",
30
+ "debug",
31
+ "info",
32
+ "warn",
33
+ "error",
34
+ "fatal"
35
+ ];
36
+ const LOG_FIELDS = [
37
+ "timestamp",
38
+ "source",
39
+ "service_name",
40
+ "severity_text",
41
+ "message"
42
+ ];
43
+ const escapeLogTableCell = (value) => value.replace(/\p{Cc}/gu, (character) => character === "\n" || character === " " ? character : `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
44
+ const escapeLogSingleLine = (value) => value.replace(/\p{Cc}/gu, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
45
+ const PORTABLE_LOG_CURSOR = /^[A-Za-z0-9._~+/=-]+$/u;
46
+ const assertReachableLogsPage = ({ is_truncated, next_cursor }) => {
47
+ if (is_truncated && !next_cursor) throw new Error("Neon returned an incomplete logs page without a pagination cursor. No records were printed because the result cannot be completed; retry the command.");
48
+ if (is_truncated && next_cursor !== void 0 && !PORTABLE_LOG_CURSOR.test(next_cursor)) throw new Error("Neon returned a pagination cursor containing characters that are unsafe in supported shells. No records were printed because the next page cannot be requested safely.");
49
+ };
50
+ const logLimit = (value) => {
51
+ if (value === void 0) return void 0;
52
+ if (Array.isArray(value) || typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > 1e3) throw new Error("--limit must be an integer from 1 to 1000.");
53
+ return value;
54
+ };
55
+ const CONTENT_FILTERS = [
56
+ "source",
57
+ "service-name",
58
+ "scope-name",
59
+ "minimum-severity",
60
+ "severity-text",
61
+ "body-contains",
62
+ "trace-id"
63
+ ];
64
+ const scopeOptions = {
65
+ "project-id": {
66
+ describe: "Project ID",
67
+ type: "string",
68
+ coerce: single("project-id")
69
+ },
70
+ branch: {
71
+ describe: "Branch ID or name",
72
+ type: "string",
73
+ coerce: single("branch")
74
+ }
75
+ };
76
+ const windowOptions = (defaultWindow) => ({
77
+ since: {
78
+ describe: `Length of the window, ending at --end-time or now. Defaults to ${defaultWindow}; the maximum window is 7d. Mutually exclusive with --start-time.`,
79
+ type: "string",
80
+ coerce: single("since")
81
+ },
82
+ "start-time": {
83
+ describe: "Inclusive start of the window (RFC 3339, e.g. 2025-01-01T00:00:00Z). The maximum window is 7d. Mutually exclusive with --since.",
84
+ type: "string",
85
+ coerce: single("start-time")
86
+ },
87
+ "end-time": {
88
+ describe: "Exclusive end of the window (RFC 3339). Defaults to the current time.",
89
+ type: "string",
90
+ coerce: single("end-time")
91
+ }
92
+ });
93
+ const command = "logs";
94
+ const describe = "Query branch logs";
95
+ const builder = (argv) => argv.usage("$0 logs <sub-command> [options]").options(scopeOptions).middleware(fillSingleProject).command("query", "Query log records on a branch", (yargs) => yargs.epilogue(LOGS_EPILOG).options({
96
+ ...windowOptions("1h"),
97
+ limit: {
98
+ describe: "Maximum number of records to return per page (1-1000)",
99
+ type: "number",
100
+ default: 100,
101
+ coerce: logLimit
102
+ },
103
+ cursor: {
104
+ describe: "Pagination cursor returned as next_cursor by a previous call. Repeat the same time range and filters.",
105
+ type: "string",
106
+ coerce: single("cursor")
107
+ },
108
+ "sort-order": {
109
+ describe: "Order records by timestamp. Defaults to desc (newest first).",
110
+ type: "string",
111
+ choices: LOG_SORT_ORDERS,
112
+ coerce: single("sort-order")
113
+ },
114
+ source: {
115
+ describe: "Only records emitted by this service",
116
+ type: "string",
117
+ choices: LOG_SOURCES,
118
+ coerce: single("source")
119
+ },
120
+ "service-name": {
121
+ describe: "Match the OpenTelemetry service.name resource attribute exactly",
122
+ type: "string",
123
+ coerce: single("service-name")
124
+ },
125
+ "scope-name": {
126
+ describe: "Match the OpenTelemetry instrumentation scope name exactly",
127
+ type: "string",
128
+ coerce: single("scope-name")
129
+ },
130
+ "minimum-severity": {
131
+ describe: "Only records at or above this severity. Combines with --severity-text. If Neon reports that this filter is unsupported, use --severity-text instead.",
132
+ type: "string",
133
+ choices: LOG_SEVERITIES,
134
+ coerce: single("minimum-severity")
135
+ },
136
+ "severity-text": {
137
+ describe: "Match the OpenTelemetry severity text exactly. Run `neon logs field-values severity_text` to discover the values present.",
138
+ type: "string",
139
+ coerce: single("severity-text")
140
+ },
141
+ "body-contains": {
142
+ describe: "Match the case-sensitive rendered message. Structured bodies are rendered as compact JSON.",
143
+ type: "string",
144
+ coerce: single("body-contains")
145
+ },
146
+ "trace-id": {
147
+ describe: "Match records carrying this trace ID (32 lowercase hex digits)",
148
+ type: "string",
149
+ coerce: single("trace-id")
150
+ },
151
+ logql: {
152
+ describe: "Raw LogQL expression (stream selectors and line filters only). Replaces the structured filters; the window, --limit, --sort-order and --cursor still apply.",
153
+ type: "string",
154
+ coerce: single("logql")
155
+ }
156
+ }).conflicts("since", "start-time").conflicts("logql", [...CONTENT_FILTERS]).example([
157
+ ["$0 logs query --since 30m", "The last 30 minutes of logs on the default branch"],
158
+ ["$0 logs query --branch main --source pg_endpoint --minimum-severity error", "Postgres compute errors on main"],
159
+ ["$0 logs query --since 1h --logql '{entity_type=\"function\"} |= \"timeout\"'", "A raw LogQL selection instead of the structured filters"]
160
+ ]).strict().check(noPassthrough("logs query")), (args) => query(args)).command("fields", "List the log fields whose values can be discovered on a branch", (yargs) => yargs.epilogue(LOGS_EPILOG).strict().check(noPassthrough("logs fields")), (args) => fields(args)).command("field-values <field>", "List the distinct values observed for a log field", (yargs) => yargs.epilogue(LOGS_EPILOG).positional("field", {
161
+ describe: "The log field to list values for. Must be one of the names `logs fields` reports.",
162
+ type: "string",
163
+ demandOption: true
164
+ }).options({
165
+ ...windowOptions("6h"),
166
+ source: {
167
+ describe: "Only consider records emitted by this service",
168
+ type: "string",
169
+ choices: LOG_SOURCES,
170
+ coerce: single("source")
171
+ },
172
+ limit: {
173
+ describe: "Maximum number of distinct values to return (1-1000)",
174
+ type: "number",
175
+ coerce: logLimit
176
+ }
177
+ }).conflicts("since", "start-time").example([["$0 logs field-values service_name --since 6h", "Service names seen in the last six hours"]]).strict().check(noPassthrough("logs field-values")), (args) => fieldValues(args)).demandCommand(1, "Run `neon logs --help` to see the subcommands.").epilogue(LOGS_EPILOG);
178
+ const handler = (args) => {
179
+ return args;
180
+ };
181
+ /**
182
+ * Map the parsed flags onto the request body, dropping everything the user did
183
+ * not supply so the API applies its own defaults rather than ours.
184
+ */
185
+ const buildLogsQueryBody = (flags) => {
186
+ const body = {};
187
+ if (flags.since !== void 0) body.since = flags.since;
188
+ if (flags.startTime !== void 0) body.start_time = flags.startTime;
189
+ if (flags.endTime !== void 0) body.end_time = flags.endTime;
190
+ if (flags.limit !== void 0) body.limit = flags.limit;
191
+ if (flags.cursor !== void 0) body.cursor = flags.cursor;
192
+ if (flags.sortOrder !== void 0) body.sort_order = flags.sortOrder;
193
+ if (flags.source !== void 0) body.source = flags.source;
194
+ if (flags.serviceName !== void 0) body.service_name = flags.serviceName;
195
+ if (flags.scopeName !== void 0) body.scope_name = flags.scopeName;
196
+ if (flags.minimumSeverity !== void 0) body.minimum_severity = flags.minimumSeverity;
197
+ if (flags.severityText !== void 0) body.severity_text = flags.severityText;
198
+ if (flags.bodyContains !== void 0) body.body_contains = flags.bodyContains;
199
+ if (flags.traceId !== void 0) body.trace_id = flags.traceId;
200
+ if (flags.logql !== void 0) body.logql = flags.logql;
201
+ return body;
202
+ };
203
+ const describeWindow = (window, defaultSince) => window.startTime ? `window from ${window.startTime} to ${window.endTime ?? "now"}` : `${window.since ?? defaultSince} window ending ${window.endTime ?? "now"}`;
204
+ const apiErrorReason = (data) => {
205
+ if (typeof data !== "object" || data === null || !("reason" in data)) return;
206
+ return typeof data.reason === "string" ? data.reason : void 0;
207
+ };
208
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
209
+ const isOptionalString = (value) => value === void 0 || typeof value === "string";
210
+ const isProjectBranchLogRecord = (value) => isRecord(value) && typeof value.timestamp === "string" && !Number.isNaN(Date.parse(value.timestamp)) && typeof value.message === "string" && (value.source === void 0 || LOG_SOURCES.some((source) => source === value.source)) && isOptionalString(value.entity_id) && isOptionalString(value.service_name) && isOptionalString(value.scope_name) && isOptionalString(value.severity_text) && (value.severity_number === void 0 || typeof value.severity_number === "number" && Number.isInteger(value.severity_number) && value.severity_number >= 0 && value.severity_number <= 24) && isOptionalString(value.trace_id) && isOptionalString(value.span_id) && isRecord(value.attributes);
211
+ function assertLogsQueryResponse(value) {
212
+ if (!isRecord(value) || !Array.isArray(value.logs) || !value.logs.every(isProjectBranchLogRecord) || !isOptionalString(value.next_cursor) || typeof value.is_truncated !== "boolean") throw new Error("Neon returned an invalid logs query response; expected logs[] and is_truncated.");
213
+ }
214
+ function assertLogFieldsResponse(value) {
215
+ if (!isRecord(value) || !Array.isArray(value.fields) || !value.fields.every((field) => typeof field === "string")) throw new Error("Neon returned an invalid log fields response; expected fields[].");
216
+ }
217
+ function assertLogFieldValuesResponse(value) {
218
+ if (!isRecord(value) || !Array.isArray(value.values) || !value.values.every((field) => typeof field === "string") || typeof value.is_truncated !== "boolean") throw new Error("Neon returned an invalid log field-values response; expected values[] and is_truncated.");
219
+ }
220
+ const query = async (props) => {
221
+ const branchId = await branchIdFromProps(props);
222
+ const { data } = await props.apiClient.queryProjectBranchLogs(props.projectId, branchId, buildLogsQueryBody(props));
223
+ assertLogsQueryResponse(data);
224
+ assertReachableLogsPage(data);
225
+ if (props.output === "json" || props.output === "yaml") {
226
+ writer(props).end(data, { fields: [
227
+ "logs",
228
+ "next_cursor",
229
+ "is_truncated"
230
+ ] });
231
+ return;
232
+ }
233
+ writer(props).end(data.logs.map((record) => ({
234
+ timestamp: escapeLogTableCell(record.timestamp),
235
+ source: record.source === void 0 ? void 0 : escapeLogTableCell(record.source),
236
+ service_name: record.service_name === void 0 ? void 0 : escapeLogTableCell(record.service_name),
237
+ severity_text: record.severity_text === void 0 ? void 0 : escapeLogTableCell(record.severity_text),
238
+ message: escapeLogTableCell(record.message)
239
+ })), {
240
+ fields: LOG_FIELDS,
241
+ title: "logs",
242
+ emptyMessage: `No logs found in the ${describeWindow(props, "1h")}.`
243
+ });
244
+ if (data.is_truncated && data.next_cursor) log.info(`More logs matched than were returned. Re-run with the same filters plus --cursor=${data.next_cursor} to fetch the next page.`);
245
+ };
246
+ const fields = async (props) => {
247
+ const branchId = await branchIdFromProps(props);
248
+ const { data } = await props.apiClient.listProjectBranchLogFields(props.projectId, branchId);
249
+ assertLogFieldsResponse(data);
250
+ if (props.output === "json" || props.output === "yaml") {
251
+ writer(props).end(data, { fields: ["fields"] });
252
+ return;
253
+ }
254
+ writer(props).end(data.fields.map((field) => ({ field: escapeLogTableCell(field) })), {
255
+ fields: ["field"],
256
+ title: "fields",
257
+ emptyMessage: "No log fields found."
258
+ });
259
+ };
260
+ const fieldValues = async (props) => {
261
+ const branchId = await branchIdFromProps(props);
262
+ let data;
263
+ try {
264
+ ({data} = await props.apiClient.listProjectBranchLogFieldValues({
265
+ projectId: props.projectId,
266
+ branchId,
267
+ fieldName: props.field,
268
+ ...props.since !== void 0 ? { since: props.since } : {},
269
+ ...props.startTime !== void 0 ? { start_time: props.startTime } : {},
270
+ ...props.endTime !== void 0 ? { end_time: props.endTime } : {},
271
+ ...props.source !== void 0 ? { source: props.source } : {},
272
+ ...props.limit !== void 0 ? { limit: props.limit } : {}
273
+ }));
274
+ } catch (error) {
275
+ if (isNeonApiError(error) && error.status === 400 && apiErrorReason(error.data) === "unknown_field") throw new Error(`Unknown log field "${escapeLogSingleLine(props.field)}". Run \`neon logs fields --project-id ${escapeLogSingleLine(props.projectId)} --branch ${escapeLogSingleLine(branchId)}\` to list the fields this branch supports.`);
276
+ throw error;
277
+ }
278
+ assertLogFieldValuesResponse(data);
279
+ if (props.output === "json" || props.output === "yaml") {
280
+ writer(props).end(data, { fields: ["values", "is_truncated"] });
281
+ return;
282
+ }
283
+ writer(props).end(data.values.map((value) => ({ value: escapeLogTableCell(value) })), {
284
+ fields: ["value"],
285
+ title: "values",
286
+ emptyMessage: `No values found in the ${describeWindow(props, "6h")}.`
287
+ });
288
+ if (data.is_truncated) log.info(`More values exist than were returned for "${escapeLogSingleLine(props.field)}". Narrow the window with --since or --start-time, restrict --source, or raise --limit, then run it again.`);
289
+ };
290
+ //#endregion
291
+ export { assertReachableLogsPage, buildLogsQueryBody, builder, command, describe, escapeLogSingleLine, escapeLogTableCell, handler, logs_exports as t };