deepline 0.3.325 → 0.3.327
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/dist/bundling-sources/sdk/src/client.ts +23 -25
- package/dist/bundling-sources/sdk/src/compat.ts +11 -6
- package/dist/bundling-sources/sdk/src/db/query.ts +172 -0
- package/dist/bundling-sources/sdk/src/errors.ts +35 -0
- package/dist/bundling-sources/sdk/src/index.ts +13 -0
- package/dist/bundling-sources/sdk/src/play.ts +34 -31
- package/dist/bundling-sources/sdk/src/plays/authoring-graph-path.ts +13 -0
- package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +2 -1
- package/dist/bundling-sources/sdk/src/plays/local-play-execution.ts +189 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/tool-calls.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/projection.ts +11 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +98 -11
- package/dist/cli/auth-67YOPQ6M.js +31 -0
- package/dist/cli/{auth-PIZESRPC.mjs → auth-EBBDOKNV.mjs} +4 -4
- package/dist/cli/{billing-DQKFCQV5.js → billing-6AAB7WPJ.js} +70 -70
- package/dist/cli/{billing-HSL6VTCM.mjs → billing-IM2QUFX4.mjs} +4 -4
- package/dist/cli/{chunk-WW4XZIVM.mjs → chunk-3ITDKXNC.mjs} +12 -9
- package/dist/cli/{chunk-K7FC5IUU.js → chunk-3MXRNPBN.js} +1 -1
- package/dist/cli/{chunk-DLW7X2UK.js → chunk-4TO56P22.js} +5928 -5730
- package/dist/cli/{chunk-MNKDSR2J.js → chunk-4ZARCCPT.js} +344 -254
- package/dist/cli/{chunk-PBNZXZCW.js → chunk-77RAV5XX.js} +48 -48
- package/dist/cli/{chunk-HUKWYHBG.js → chunk-7RCJDAJX.js} +2 -2
- package/dist/cli/{chunk-5TYU3UIS.mjs → chunk-A5SKM3GL.mjs} +1 -1
- package/dist/cli/{chunk-XNL3SEMC.js → chunk-AFNEQ43J.js} +8 -3
- package/dist/cli/{chunk-XSEMQ4II.js → chunk-AGH6YP2T.js} +2 -1
- package/dist/cli/chunk-AID3OYVJ.js +8 -0
- package/dist/cli/{chunk-YE3O2UHM.mjs → chunk-CCRQ2VGJ.mjs} +24 -1
- package/dist/cli/{chunk-HPTQEWCF.js → chunk-CISKBOXD.js} +70 -67
- package/dist/cli/{chunk-OPERWJR6.mjs → chunk-D6GD5AVN.mjs} +3 -3
- package/dist/cli/{chunk-6RMKHN7S.mjs → chunk-DCAU6PND.mjs} +4 -20
- package/dist/cli/{chunk-PVDQ55PS.js → chunk-DM3SHV6U.js} +29 -6
- package/dist/cli/{chunk-CV5GDCKN.js → chunk-DSDX6EUW.js} +29 -45
- package/dist/cli/{chunk-5FHU7TV4.mjs → chunk-DVV4FPS7.mjs} +2 -2
- package/dist/cli/{chunk-AQUNQJ5Y.mjs → chunk-F45425TB.mjs} +1 -1
- package/dist/cli/{chunk-NWBARG3F.mjs → chunk-G5774EFF.mjs} +1 -1
- package/dist/cli/chunk-GVESPYSY.mjs +234 -0
- package/dist/cli/{chunk-H5TJBRSC.mjs → chunk-HOWQKN6J.mjs} +98 -113
- package/dist/cli/{chunk-UYFWTIKF.js → chunk-HZZJR2GV.js} +26 -26
- package/dist/cli/{chunk-76VKBPOC.mjs → chunk-JOA6IKDE.mjs} +7 -2
- package/dist/cli/chunk-LVEDPCLJ.js +234 -0
- package/dist/cli/{chunk-KZNFYOHX.js → chunk-MOP6D7Z5.js} +6 -6
- package/dist/cli/{chunk-YXRPWMGN.js → chunk-NWIJLTRL.js} +147 -162
- package/dist/cli/chunk-OVDNJAJN.mjs +8 -0
- package/dist/cli/{chunk-XIVUB36F.mjs → chunk-QZAP5VOS.mjs} +104 -14
- package/dist/cli/{chunk-6VZDSBK6.mjs → chunk-REP2MYBI.mjs} +2 -2
- package/dist/cli/{chunk-PWV2M4LW.mjs → chunk-RSEVBSFE.mjs} +1 -1
- package/dist/cli/{chunk-OOPSX57I.js → chunk-TAGHNT5P.js} +6 -6
- package/dist/cli/{chunk-QQ2FG5W3.js → chunk-UROXKPND.js} +6 -6
- package/dist/cli/{chunk-7PZFGB7L.mjs → chunk-YIY74KUF.mjs} +2 -1
- package/dist/cli/{chunk-7MD453WV.mjs → chunk-ZOFARJWH.mjs} +5674 -5476
- package/dist/cli/client-7LZCG4VD.js +20 -0
- package/dist/cli/{client-57SR4KVM.mjs → client-JCMSACT4.mjs} +3 -3
- package/dist/cli/{csv-G2FRMOXL.mjs → csv-NPMWVM5D.mjs} +3 -3
- package/dist/cli/{csv-5DJSC6BD.js → csv-OILKDKUX.js} +12 -12
- package/dist/cli/{db-WWZEXM3N.mjs → db-AZUAOWPQ.mjs} +214 -137
- package/dist/cli/{db-NVO7P4VO.js → db-MNDRYYEX.js} +226 -149
- package/dist/cli/{describe-26OMF3A4.mjs → describe-KJWOHMKC.mjs} +12 -11
- package/dist/cli/{describe-M26LHDBQ.js → describe-QENLDLM2.js} +28 -27
- package/dist/cli/{executions-KI47LPKE.js → executions-P36UHBPG.js} +6 -6
- package/dist/cli/{executions-2LLHY3IL.mjs → executions-QZNQWF6F.mjs} +4 -4
- package/dist/cli/{feedback-2Y26C2BZ.js → feedback-K4UGTLFD.js} +6 -6
- package/dist/cli/{feedback-O26VL2OF.mjs → feedback-RQ6HSZSG.mjs} +3 -3
- package/dist/cli/{git-UVPGZN3K.mjs → git-PBRMCBMI.mjs} +4 -4
- package/dist/cli/git-RPFH3NJ2.js +23 -0
- package/dist/cli/index.js +105 -87
- package/dist/cli/index.mjs +65 -47
- package/dist/cli/{legacy-noops-IK5CH72U.mjs → legacy-noops-G7GWJ5UC.mjs} +4 -4
- package/dist/cli/{legacy-noops-H6Y3SEVB.js → legacy-noops-X74FM35Q.js} +7 -7
- package/dist/cli/{monitors-SFVVMAJT.mjs → monitors-KL2MCR57.mjs} +4 -4
- package/dist/cli/{monitors-JL6TTQCI.js → monitors-VKURX3YM.js} +85 -85
- package/dist/cli/{org-SSDONL57.mjs → org-DT53KTNW.mjs} +4 -4
- package/dist/cli/{org-OVMAZCQS.js → org-ZYXJDC44.js} +60 -60
- package/dist/cli/play-BUQV47E2.js +153 -0
- package/dist/cli/{play-X6NPACUO.mjs → play-WIJGQYTB.mjs} +11 -10
- package/dist/cli/{providers-E24JDWSR.js → providers-GRTW4TXX.js} +7 -7
- package/dist/cli/{providers-ONUBYYY4.mjs → providers-GYGKGS2J.mjs} +4 -4
- package/dist/cli/{quickstart-TB7C3DLG.js → quickstart-WB26543C.js} +5 -5
- package/dist/cli/{quickstart-B7NIXACV.mjs → quickstart-XF3M2M2S.mjs} +3 -3
- package/dist/cli/{search-N3QUIATW.mjs → search-ANJLTOF2.mjs} +5 -5
- package/dist/cli/search-CR2GZLCM.js +26 -0
- package/dist/cli/{secrets-CPCVFDYB.js → secrets-5KBUGMTK.js} +13 -13
- package/dist/cli/{secrets-V7Z4M67T.mjs → secrets-D6UR5CTW.mjs} +4 -4
- package/dist/cli/{sessions-E4FIZLQP.js → sessions-46PXFULL.js} +5 -5
- package/dist/cli/{sessions-PDOBKAKO.mjs → sessions-S7N4JEWK.mjs} +4 -4
- package/dist/cli/{settings-UVM2WDE4.js → settings-KMNBITSU.js} +74 -74
- package/dist/cli/{settings-QYHYHZDI.mjs → settings-V6U3SRTH.mjs} +7 -7
- package/dist/cli/{setup-3JFAXQLJ.js → setup-4K5FY6AU.js} +41 -41
- package/dist/cli/{setup-4RLAETDW.mjs → setup-OGITSLTN.mjs} +6 -6
- package/dist/cli/skills-4FP2MZKL.js +28 -0
- package/dist/cli/{skills-ZX2JSWOZ.mjs → skills-AXWAYPBY.mjs} +4 -4
- package/dist/cli/tools-7YZPH6WC.js +39 -0
- package/dist/cli/{tools-EGXCVIPJ.mjs → tools-LJCY6B23.mjs} +8 -7
- package/dist/cli/update-3VUOW6AP.js +28 -0
- package/dist/cli/{update-7FEKRQFE.mjs → update-DDR5XIUB.mjs} +6 -6
- package/dist/cli/{workflow-54VCKIG2.js → workflow-7CTCDWL3.js} +15 -15
- package/dist/cli/{workflow-7V7TTTKK.mjs → workflow-PRNCVANQ.mjs} +5 -5
- package/dist/{client-Bb4Jjzmj.d.ts → client-DHq8dJ56.d.ts} +39 -11
- package/dist/{client-COa-3GHK.d.mts → client-wiWPZhnI.d.mts} +39 -11
- package/dist/{compiler-manifest-CsnWj-AK.d.mts → compiler-manifest-9TkZ_ykI.d.mts} +711 -711
- package/dist/{compiler-manifest-CsnWj-AK.d.ts → compiler-manifest-9TkZ_ykI.d.ts} +711 -711
- package/dist/index-B-5_Xhud.d.mts +75 -0
- package/dist/index-ykksoEyR.d.ts +75 -0
- package/dist/index.d.mts +52 -13
- package/dist/index.d.ts +52 -13
- package/dist/index.js +142 -68
- package/dist/index.mjs +102 -28
- package/dist/install-integrity.json +91 -84
- package/dist/plays/bundle-play-file.d.mts +7 -75
- package/dist/plays/bundle-play-file.d.ts +7 -75
- package/dist/plays/bundle-play-file.mjs +1 -1
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
- package/dist/cli/auth-RXCD4GOV.js +0 -31
- package/dist/cli/chunk-OWJZUE3Y.mjs +0 -103
- package/dist/cli/chunk-SDK3ZA2C.js +0 -103
- package/dist/cli/client-562MULXK.js +0 -20
- package/dist/cli/git-KGPX5YPD.js +0 -23
- package/dist/cli/play-3DB4MSHN.js +0 -152
- package/dist/cli/search-NJ637YGQ.js +0 -26
- package/dist/cli/skills-BYRYG64R.js +0 -28
- package/dist/cli/tools-TAWOAY5X.js +0 -38
- package/dist/cli/update-H24GEBXM.js +0 -28
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkAID3OYVJjs = require('./chunk-AID3OYVJ.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunk4ZARCCPTjs = require('./chunk-4ZARCCPT.js');
|
|
4
8
|
require('./chunk-LA46MMTL.js');
|
|
5
9
|
|
|
6
10
|
|
|
@@ -10,10 +14,13 @@ require('./chunk-LA46MMTL.js');
|
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
require('./chunk-
|
|
17
|
+
|
|
18
|
+
var _chunkUROXKPNDjs = require('./chunk-UROXKPND.js');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
var _chunkDM3SHV6Ujs = require('./chunk-DM3SHV6U.js');
|
|
15
22
|
require('./chunk-XNYIZMNQ.js');
|
|
16
|
-
require('./chunk-
|
|
23
|
+
require('./chunk-3MXRNPBN.js');
|
|
17
24
|
require('./chunk-S6R3OX7B.js');
|
|
18
25
|
|
|
19
26
|
|
|
@@ -21,26 +28,18 @@ var _chunk7P5AA3SNjs = require('./chunk-7P5AA3SN.js');
|
|
|
21
28
|
require('./chunk-OG64RBAC.js');
|
|
22
29
|
require('./chunk-COGTRVWW.js');
|
|
23
30
|
|
|
24
|
-
// src/cli/
|
|
31
|
+
// src/cli/operations/db-query.ts
|
|
25
32
|
var _fs = require('fs');
|
|
26
33
|
var _path = require('path');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
return parsed;
|
|
34
|
+
|
|
35
|
+
// src/cli/renderers/db-query.ts
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function queryIntentLine(operationKey) {
|
|
39
|
+
return operationKey === void 0 ? "The tool equivalent starts a new SQL execution; it cannot recover this unkeyed operation." : "The tool equivalent recovers this SQL operation through its original key.";
|
|
35
40
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
if (parsed > CUSTOMER_DB_QUERY_MAX_ROWS) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`--max-rows must be ${CUSTOMER_DB_QUERY_MAX_ROWS} or less. Add LIMIT/OFFSET to page larger exports.`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
return parsed;
|
|
41
|
+
function errorMessage(value) {
|
|
42
|
+
return value instanceof Error ? value.message : String(_nullishCoalesce(value, () => ( "")));
|
|
44
43
|
}
|
|
45
44
|
function formatCell(value) {
|
|
46
45
|
if (value === null || value === void 0) return "";
|
|
@@ -48,8 +47,8 @@ function formatCell(value) {
|
|
|
48
47
|
return text.length > 80 ? `${text.slice(0, 77)}...` : text;
|
|
49
48
|
}
|
|
50
49
|
function tableLines(result) {
|
|
51
|
-
const rows =
|
|
52
|
-
const responseColumns =
|
|
50
|
+
const rows = _chunkUROXKPNDjs.dataExportRows.call(void 0, customerDbRows(result));
|
|
51
|
+
const responseColumns = _chunkUROXKPNDjs.dataExportColumns.call(void 0,
|
|
53
52
|
rows,
|
|
54
53
|
customerDbColumnNames(result)
|
|
55
54
|
);
|
|
@@ -95,23 +94,11 @@ function tableLines(result) {
|
|
|
95
94
|
return lines;
|
|
96
95
|
}
|
|
97
96
|
function customerDbRows(result) {
|
|
98
|
-
return
|
|
97
|
+
return _chunkUROXKPNDjs.recordRows.call(void 0, result.rows);
|
|
99
98
|
}
|
|
100
99
|
function customerDbColumnNames(result) {
|
|
101
100
|
return result.columns.map((column) => column.name).filter(Boolean);
|
|
102
101
|
}
|
|
103
|
-
function errorMessage(value) {
|
|
104
|
-
return value instanceof Error ? value.message : String(_nullishCoalesce(value, () => ( "")));
|
|
105
|
-
}
|
|
106
|
-
function resolveDbQuerySql(rawSql, readFile = (path) => _fs.readFileSync.call(void 0, path, "utf8")) {
|
|
107
|
-
const value = rawSql.trim();
|
|
108
|
-
if (!value.startsWith("@")) return value;
|
|
109
|
-
const filePath = value.slice(1).trim();
|
|
110
|
-
if (!filePath) {
|
|
111
|
-
throw new Error("--sql @file requires a file path after `@`.");
|
|
112
|
-
}
|
|
113
|
-
return readFile(_path.resolve.call(void 0, filePath)).trim();
|
|
114
|
-
}
|
|
115
102
|
function collectErrorText(value) {
|
|
116
103
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
117
104
|
return errorMessage(value);
|
|
@@ -129,14 +116,15 @@ function collectErrorText(value) {
|
|
|
129
116
|
].filter(Boolean).join("\n");
|
|
130
117
|
}
|
|
131
118
|
function formatDbQueryError(sql, error) {
|
|
132
|
-
const text = collectErrorText(error);
|
|
119
|
+
const text = error instanceof _chunkDM3SHV6Ujs.CustomerDbQueryOutcomeUnknownError ? collectErrorText(error.cause) : collectErrorText(error);
|
|
133
120
|
const lower = text.toLowerCase();
|
|
134
121
|
const referencesStorage = /"storage"\.|storage\./i.test(sql);
|
|
135
122
|
const runIdColumnMissing = /column\s+"?run_id"?\s+does not exist/i.test(text) || /run_id.*does not exist/i.test(lower);
|
|
136
123
|
const relationMissing = /relation\s+["']?[^"']*storage[^"']*["']?\s+does not exist/i.test(text) || /42p01/i.test(text);
|
|
137
124
|
if (referencesStorage && relationMissing) {
|
|
138
125
|
return [
|
|
139
|
-
|
|
126
|
+
...error instanceof _chunkDM3SHV6Ujs.CustomerDbQueryOutcomeUnknownError ? [error.message] : [],
|
|
127
|
+
error instanceof _chunkDM3SHV6Ujs.CustomerDbQueryOutcomeUnknownError ? "The server reported that the referenced storage table does not exist." : "Customer DB query failed: the referenced storage table does not exist.",
|
|
140
128
|
"Play dataset tables are created only when the corresponding ctx.dataset(...).run(...) call executes. Pilot branches, early returns, and runs that fail before the dataset do not create that table.",
|
|
141
129
|
"Use `deepline runs get <run-id> --full --json` to inspect returned dataset handles, then export them with `deepline runs export <run-id> --dataset result.rows --out rows.csv`.",
|
|
142
130
|
`Original error: ${errorMessage(error)}`
|
|
@@ -144,6 +132,7 @@ function formatDbQueryError(sql, error) {
|
|
|
144
132
|
}
|
|
145
133
|
if (referencesStorage && runIdColumnMissing) {
|
|
146
134
|
return [
|
|
135
|
+
...error instanceof _chunkDM3SHV6Ujs.CustomerDbQueryOutcomeUnknownError ? [error.message] : [],
|
|
147
136
|
"Customer DB query failed: storage dataset tables use `_run_id`, not `run_id`.",
|
|
148
137
|
"Prefer `deepline runs export <run-id> --dataset result.rows --out rows.csv` unless you are doing deep table debugging.",
|
|
149
138
|
`Original error: ${errorMessage(error)}`
|
|
@@ -154,33 +143,11 @@ function formatDbQueryError(sql, error) {
|
|
|
154
143
|
}
|
|
155
144
|
return errorMessage(error);
|
|
156
145
|
}
|
|
157
|
-
function dbRepairHumanLines(result) {
|
|
158
|
-
const repair = result.repair;
|
|
159
|
-
return [
|
|
160
|
-
"Workspace storage repair completed.",
|
|
161
|
-
...repair ? [
|
|
162
|
-
`Location changed: ${repair.location.changed ? "yes" : "no"}`,
|
|
163
|
-
`Storage contract: ${repair.storage_contract.current ? "current" : "not ready"}`,
|
|
164
|
-
`Runtime migration: ${repair.runtime_migration.current ? "current" : "not ready"}`,
|
|
165
|
-
`Runtime capability probe: ${repair.runtime_capabilities.after.runtime_capabilities_ready ? "passed" : "failed"}`,
|
|
166
|
-
`Materialized table grants reconciled: ${repair.materialized_tables.repaired_count}`
|
|
167
|
-
] : [
|
|
168
|
-
"Runtime capability probe: unavailable from this server version",
|
|
169
|
-
`Materialized table grants reconciled: ${result.count}`
|
|
170
|
-
],
|
|
171
|
-
`Runtime role: ${result.connection_grants.runtime_role}`,
|
|
172
|
-
`Customer DB role: ${result.connection_grants.customer_db_role}`
|
|
173
|
-
];
|
|
174
|
-
}
|
|
175
|
-
function dbRepairPlainText(result) {
|
|
176
|
-
return result.repair ? "Workspace storage repair completed. Runtime capability probe passed.\n" : `Workspace storage repair completed. ${result.count} materialized table grant(s) reconciled; runtime capability probe unavailable.
|
|
177
|
-
`;
|
|
178
|
-
}
|
|
179
146
|
function writeCustomerDbCsv(result, outPath) {
|
|
180
147
|
const resolved = _path.resolve.call(void 0, outPath);
|
|
181
148
|
_fs.writeFileSync.call(void 0,
|
|
182
149
|
resolved,
|
|
183
|
-
|
|
150
|
+
_chunkUROXKPNDjs.dataExportCsvString.call(void 0, customerDbRows(result), customerDbColumnNames(result)),
|
|
184
151
|
"utf-8"
|
|
185
152
|
);
|
|
186
153
|
return resolved;
|
|
@@ -194,81 +161,51 @@ function dbQueryExportEnvelope(input) {
|
|
|
194
161
|
row_count_returned: input.result.row_count_returned,
|
|
195
162
|
truncated: input.result.truncated,
|
|
196
163
|
...input.outPath ? { file: input.outPath, local: { file: input.outPath } } : {},
|
|
197
|
-
next: {
|
|
164
|
+
next: {
|
|
165
|
+
toolEquivalent: input.toolCommand,
|
|
166
|
+
executionIntent: input.operationKey === void 0 ? "new_execution" : "recover_original",
|
|
167
|
+
...input.operationKey === void 0 ? {} : { recoverOperation: input.toolCommand }
|
|
168
|
+
},
|
|
198
169
|
render: {
|
|
199
170
|
sections: [
|
|
200
171
|
{
|
|
201
172
|
title: "customer db export",
|
|
202
173
|
lines: [
|
|
203
|
-
`Rendered ${input.result.row_count_returned} row(s) as ${input.format} to ${destination}
|
|
174
|
+
`Rendered ${input.result.row_count_returned} row(s) as ${input.format} to ${destination}`,
|
|
175
|
+
queryIntentLine(input.operationKey)
|
|
204
176
|
]
|
|
205
177
|
}
|
|
206
178
|
],
|
|
207
|
-
actions: [
|
|
179
|
+
actions: [
|
|
180
|
+
{
|
|
181
|
+
label: "Tool equivalent",
|
|
182
|
+
command: input.toolCommand
|
|
183
|
+
}
|
|
184
|
+
]
|
|
208
185
|
}
|
|
209
186
|
};
|
|
210
187
|
}
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
sql = resolveDbQuerySql(rawSql);
|
|
223
|
-
} catch (error) {
|
|
224
|
-
console.error(errorMessage(error));
|
|
225
|
-
return 1;
|
|
226
|
-
}
|
|
227
|
-
if (!sql) {
|
|
228
|
-
console.error("SQL file is empty.");
|
|
229
|
-
return 1;
|
|
230
|
-
}
|
|
231
|
-
const maxRowsIndex = args.indexOf("--max-rows");
|
|
232
|
-
const maxRows = maxRowsIndex >= 0 && args[maxRowsIndex + 1] ? parseMaxRows(args[maxRowsIndex + 1]) : void 0;
|
|
233
|
-
const formatIndex = args.indexOf("--format");
|
|
234
|
-
const format = formatIndex >= 0 ? _optionalChain([args, 'access', _4 => _4[formatIndex + 1], 'optionalAccess', _5 => _5.trim, 'call', _6 => _6(), 'access', _7 => _7.toLowerCase, 'call', _8 => _8()]) : "";
|
|
235
|
-
if (format && !CUSTOMER_DB_QUERY_FORMATS.has(format)) {
|
|
236
|
-
console.error(
|
|
237
|
-
'Usage: deepline db query --sql "select * from table limit 20" [--format table|json|csv|markdown] [--out path]'
|
|
238
|
-
);
|
|
239
|
-
return 1;
|
|
240
|
-
}
|
|
241
|
-
const outIndex = args.indexOf("--out");
|
|
242
|
-
const outPath = outIndex >= 0 ? _optionalChain([args, 'access', _9 => _9[outIndex + 1], 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]) : "";
|
|
243
|
-
if (outIndex >= 0 && !outPath) {
|
|
244
|
-
console.error("--out requires a path.");
|
|
245
|
-
return 1;
|
|
246
|
-
}
|
|
247
|
-
const jsonOutput = _chunkQQ2FG5W3js.argsWantJson.call(void 0, args);
|
|
248
|
-
const explicitJsonOutput = args.includes("--json");
|
|
249
|
-
const client = new (0, _chunkMNKDSR2Jjs.DeeplineClient)();
|
|
250
|
-
let result;
|
|
251
|
-
try {
|
|
252
|
-
result = await client.db.query({ sql, maxRows });
|
|
253
|
-
} catch (error) {
|
|
254
|
-
console.error(formatDbQueryError(sql, error));
|
|
255
|
-
return 1;
|
|
256
|
-
}
|
|
257
|
-
const toolCommand = `deepline tools execute query_customer_db --payload ${JSON.stringify(
|
|
258
|
-
{
|
|
259
|
-
sql,
|
|
260
|
-
...maxRows ? { max_rows: maxRows } : {}
|
|
261
|
-
}
|
|
262
|
-
)} --json`;
|
|
188
|
+
function renderDbQueryResult(result, query, options) {
|
|
189
|
+
const { sql, maxRows, operationKey } = query;
|
|
190
|
+
const { format, out: outPath, json: explicitJsonOutput = false } = options;
|
|
191
|
+
const jsonOutput = explicitJsonOutput || _chunkUROXKPNDjs.shouldEmitJson.call(void 0, );
|
|
192
|
+
const toolPayload = JSON.stringify({
|
|
193
|
+
sql,
|
|
194
|
+
result_mode: "rows",
|
|
195
|
+
...maxRows ? { max_rows: maxRows } : {},
|
|
196
|
+
...operationKey !== void 0 ? { operation_key: operationKey } : {}
|
|
197
|
+
});
|
|
198
|
+
const toolCommand = `deepline tools execute query_customer_db --payload ${_chunkAID3OYVJjs.shellQuote.call(void 0, toolPayload)} --json`;
|
|
263
199
|
if (format === "csv") {
|
|
264
200
|
if (outPath) {
|
|
265
201
|
const exportedPath = writeCustomerDbCsv(result, outPath);
|
|
266
|
-
|
|
202
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
267
203
|
dbQueryExportEnvelope({
|
|
268
204
|
result,
|
|
269
205
|
format,
|
|
270
206
|
outPath: exportedPath,
|
|
271
|
-
toolCommand
|
|
207
|
+
toolCommand,
|
|
208
|
+
operationKey
|
|
272
209
|
}),
|
|
273
210
|
{
|
|
274
211
|
json: jsonOutput,
|
|
@@ -276,39 +213,41 @@ async function handleDbQuery(args) {
|
|
|
276
213
|
`
|
|
277
214
|
}
|
|
278
215
|
);
|
|
279
|
-
return
|
|
216
|
+
return;
|
|
280
217
|
}
|
|
281
|
-
|
|
218
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
282
219
|
dbQueryExportEnvelope({
|
|
283
220
|
result,
|
|
284
221
|
format,
|
|
285
222
|
outPath: null,
|
|
286
|
-
toolCommand
|
|
223
|
+
toolCommand,
|
|
224
|
+
operationKey
|
|
287
225
|
}),
|
|
288
226
|
{
|
|
289
227
|
json: explicitJsonOutput,
|
|
290
|
-
text:
|
|
228
|
+
text: _chunkUROXKPNDjs.dataExportCsvString.call(void 0,
|
|
291
229
|
customerDbRows(result),
|
|
292
230
|
customerDbColumnNames(result)
|
|
293
231
|
)
|
|
294
232
|
}
|
|
295
233
|
);
|
|
296
|
-
return
|
|
234
|
+
return;
|
|
297
235
|
}
|
|
298
236
|
if (format === "markdown") {
|
|
299
|
-
const content =
|
|
237
|
+
const content = _chunkUROXKPNDjs.markdownTableFromRows.call(void 0,
|
|
300
238
|
customerDbRows(result),
|
|
301
239
|
customerDbColumnNames(result)
|
|
302
240
|
);
|
|
303
241
|
if (outPath) {
|
|
304
242
|
const exportedPath = _path.resolve.call(void 0, outPath);
|
|
305
243
|
_fs.writeFileSync.call(void 0, exportedPath, content, "utf-8");
|
|
306
|
-
|
|
244
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
307
245
|
dbQueryExportEnvelope({
|
|
308
246
|
result,
|
|
309
247
|
format,
|
|
310
248
|
outPath: exportedPath,
|
|
311
|
-
toolCommand
|
|
249
|
+
toolCommand,
|
|
250
|
+
operationKey
|
|
312
251
|
}),
|
|
313
252
|
{
|
|
314
253
|
json: jsonOutput,
|
|
@@ -316,42 +255,176 @@ async function handleDbQuery(args) {
|
|
|
316
255
|
`
|
|
317
256
|
}
|
|
318
257
|
);
|
|
319
|
-
return
|
|
258
|
+
return;
|
|
320
259
|
}
|
|
321
|
-
|
|
260
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
322
261
|
dbQueryExportEnvelope({
|
|
323
262
|
result,
|
|
324
263
|
format,
|
|
325
264
|
outPath: null,
|
|
326
|
-
toolCommand
|
|
265
|
+
toolCommand,
|
|
266
|
+
operationKey
|
|
327
267
|
}),
|
|
328
268
|
{
|
|
329
269
|
json: explicitJsonOutput,
|
|
330
270
|
text: content
|
|
331
271
|
}
|
|
332
272
|
);
|
|
333
|
-
return
|
|
273
|
+
return;
|
|
334
274
|
}
|
|
335
|
-
|
|
275
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
336
276
|
{
|
|
337
277
|
...result,
|
|
338
|
-
next: {
|
|
278
|
+
next: {
|
|
279
|
+
toolEquivalent: toolCommand,
|
|
280
|
+
executionIntent: operationKey === void 0 ? "new_execution" : "recover_original",
|
|
281
|
+
...operationKey === void 0 ? {} : { recoverOperation: toolCommand }
|
|
282
|
+
},
|
|
339
283
|
render: {
|
|
340
|
-
sections: [
|
|
341
|
-
|
|
284
|
+
sections: [
|
|
285
|
+
{
|
|
286
|
+
title: "customer db query",
|
|
287
|
+
lines: [...tableLines(result), queryIntentLine(operationKey)]
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
actions: [
|
|
291
|
+
{
|
|
292
|
+
label: "Tool equivalent",
|
|
293
|
+
command: toolCommand
|
|
294
|
+
}
|
|
295
|
+
]
|
|
342
296
|
}
|
|
343
297
|
},
|
|
344
298
|
{
|
|
345
299
|
json: explicitJsonOutput || format === "json" || format !== "table" && jsonOutput
|
|
346
300
|
}
|
|
347
301
|
);
|
|
348
|
-
return
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/cli/operations/db-query.ts
|
|
306
|
+
function resolveDbQuerySql(rawSql, readFile = (path) => _fs.readFileSync.call(void 0, path, "utf8")) {
|
|
307
|
+
const value = rawSql.trim();
|
|
308
|
+
if (!value.startsWith("@")) return value;
|
|
309
|
+
const filePath = value.slice(1).trim();
|
|
310
|
+
if (!filePath) {
|
|
311
|
+
throw new Error("--sql @file requires a file path after `@`.");
|
|
312
|
+
}
|
|
313
|
+
return readFile(_path.resolve.call(void 0, filePath)).trim();
|
|
314
|
+
}
|
|
315
|
+
async function runDbQueryCommand(options) {
|
|
316
|
+
let sql = "";
|
|
317
|
+
try {
|
|
318
|
+
sql = resolveDbQuerySql(options.sql);
|
|
319
|
+
if (!sql) throw new Error("SQL file is empty.");
|
|
320
|
+
const maxRows = options.maxRows === void 0 ? void 0 : Number(options.maxRows);
|
|
321
|
+
if (maxRows !== void 0 && maxRows > 1e3)
|
|
322
|
+
throw new Error(
|
|
323
|
+
"--max-rows must be 1000 or less. Add LIMIT/OFFSET to page larger exports."
|
|
324
|
+
);
|
|
325
|
+
if (maxRows !== void 0 && (!Number.isSafeInteger(maxRows) || maxRows < 1)) {
|
|
326
|
+
throw new Error(
|
|
327
|
+
"--max-rows must be a positive whole number of 1000 or less. Add LIMIT/OFFSET to page larger exports."
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
const operationKey = options.operationKey;
|
|
331
|
+
if (operationKey !== void 0 && (!operationKey.trim() || operationKey.length > 512)) {
|
|
332
|
+
throw new Error(
|
|
333
|
+
"--operation-key requires a non-empty intended-operation key of at most 512 characters."
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
const format = _optionalChain([options, 'access', _ => _.format, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3(), 'access', _4 => _4.toLowerCase, 'call', _5 => _5()]);
|
|
337
|
+
if (format !== void 0 && !["table", "json", "csv", "markdown"].includes(format)) {
|
|
338
|
+
throw new Error("--format must be table, json, csv, or markdown.");
|
|
339
|
+
}
|
|
340
|
+
const out = _optionalChain([options, 'access', _6 => _6.out, 'optionalAccess', _7 => _7.trim, 'call', _8 => _8()]);
|
|
341
|
+
if (out !== void 0 && !out) throw new Error("--out requires a path.");
|
|
342
|
+
if (out !== void 0 && format !== "csv" && format !== "markdown")
|
|
343
|
+
throw new Error("--out requires --format csv or --format markdown.");
|
|
344
|
+
const query = {
|
|
345
|
+
sql,
|
|
346
|
+
...maxRows === void 0 ? {} : { maxRows },
|
|
347
|
+
...operationKey === void 0 ? {} : { operationKey }
|
|
348
|
+
};
|
|
349
|
+
const plan = _chunk4ZARCCPTjs.planCustomerDbQuery.call(void 0, query);
|
|
350
|
+
if (options.dryRun) {
|
|
351
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
352
|
+
{
|
|
353
|
+
dryRun: true,
|
|
354
|
+
...plan,
|
|
355
|
+
effects: {
|
|
356
|
+
...plan.effects,
|
|
357
|
+
localWrites: out === void 0 ? "none" : "export_file"
|
|
358
|
+
},
|
|
359
|
+
output: {
|
|
360
|
+
format: _nullishCoalesce(format, () => ( "automatic")),
|
|
361
|
+
...out === void 0 ? {} : { file: _path.resolve.call(void 0, out) }
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
{ json: options.json || _chunkUROXKPNDjs.shouldEmitJson.call(void 0, ) }
|
|
365
|
+
);
|
|
366
|
+
return 0;
|
|
367
|
+
}
|
|
368
|
+
const client = new (0, _chunk4ZARCCPTjs.DeeplineClient)();
|
|
369
|
+
const result = await client.db.query(query);
|
|
370
|
+
renderDbQueryResult(result, query, {
|
|
371
|
+
format,
|
|
372
|
+
out,
|
|
373
|
+
json: options.json
|
|
374
|
+
});
|
|
375
|
+
return 0;
|
|
376
|
+
} catch (error) {
|
|
377
|
+
if (error instanceof _chunkDM3SHV6Ujs.CustomerDbQueryOutcomeUnknownError && (options.json || _chunkUROXKPNDjs.shouldEmitJson.call(void 0, ))) {
|
|
378
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
379
|
+
{
|
|
380
|
+
ok: false,
|
|
381
|
+
error: {
|
|
382
|
+
code: error.code,
|
|
383
|
+
message: error.message,
|
|
384
|
+
outcome: error.outcome,
|
|
385
|
+
retryable: error.retryable,
|
|
386
|
+
...error.operationKey === void 0 ? {} : { operationKey: error.operationKey }
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{ json: true }
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
console.error(formatDbQueryError(sql, error));
|
|
393
|
+
return 1;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// src/cli/commands/db.ts
|
|
398
|
+
function errorMessage2(value) {
|
|
399
|
+
return value instanceof Error ? value.message : String(_nullishCoalesce(value, () => ( "")));
|
|
400
|
+
}
|
|
401
|
+
function dbRepairHumanLines(result) {
|
|
402
|
+
const repair = result.repair;
|
|
403
|
+
return [
|
|
404
|
+
"Workspace storage repair completed.",
|
|
405
|
+
...repair ? [
|
|
406
|
+
`Location changed: ${repair.location.changed ? "yes" : "no"}`,
|
|
407
|
+
`Storage contract: ${repair.storage_contract.current ? "current" : "not ready"}`,
|
|
408
|
+
`Runtime migration: ${repair.runtime_migration.current ? "current" : "not ready"}`,
|
|
409
|
+
`Runtime capability probe: ${repair.runtime_capabilities.after.runtime_capabilities_ready ? "passed" : "failed"}`,
|
|
410
|
+
`Materialized table grants reconciled: ${repair.materialized_tables.repaired_count}`
|
|
411
|
+
] : [
|
|
412
|
+
"Runtime capability probe: unavailable from this server version",
|
|
413
|
+
`Materialized table grants reconciled: ${result.count}`
|
|
414
|
+
],
|
|
415
|
+
`Runtime role: ${result.connection_grants.runtime_role}`,
|
|
416
|
+
`Customer DB role: ${result.connection_grants.customer_db_role}`
|
|
417
|
+
];
|
|
418
|
+
}
|
|
419
|
+
function dbRepairPlainText(result) {
|
|
420
|
+
return result.repair ? "Workspace storage repair completed. Runtime capability probe passed.\n" : `Workspace storage repair completed. ${result.count} materialized table grant(s) reconciled; runtime capability probe unavailable.
|
|
421
|
+
`;
|
|
349
422
|
}
|
|
350
423
|
async function handleDbRepair(args) {
|
|
351
424
|
const providerIndex = args.indexOf("--provider");
|
|
352
|
-
const provider = providerIndex >= 0 ? _optionalChain([args, 'access',
|
|
353
|
-
const jsonOutput =
|
|
354
|
-
const client = new (0,
|
|
425
|
+
const provider = providerIndex >= 0 ? _optionalChain([args, 'access', _9 => _9[providerIndex + 1], 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]) : void 0;
|
|
426
|
+
const jsonOutput = _chunkUROXKPNDjs.argsWantJson.call(void 0, args);
|
|
427
|
+
const client = new (0, _chunk4ZARCCPTjs.DeeplineClient)();
|
|
355
428
|
let result;
|
|
356
429
|
try {
|
|
357
430
|
result = await client.repairIngestionStorage(
|
|
@@ -364,10 +437,10 @@ async function handleDbRepair(args) {
|
|
|
364
437
|
);
|
|
365
438
|
return 1;
|
|
366
439
|
}
|
|
367
|
-
console.error(
|
|
440
|
+
console.error(errorMessage2(error));
|
|
368
441
|
return 1;
|
|
369
442
|
}
|
|
370
|
-
|
|
443
|
+
_chunkUROXKPNDjs.printCommandEnvelope.call(void 0,
|
|
371
444
|
{
|
|
372
445
|
command: "db repair",
|
|
373
446
|
status: result.status,
|
|
@@ -427,6 +500,11 @@ Examples:
|
|
|
427
500
|
CREATE TABLE storage.blocked (...) instead of CREATE TABLE blocked (...).
|
|
428
501
|
--format csv and --format markdown are explicit data/display formats and can
|
|
429
502
|
be written directly with --out.
|
|
503
|
+
Effects: SQL may mutate customer storage; --out writes one local export. SQL does not spend credits.
|
|
504
|
+
SQL is attempted once, without automatic retries or URL failover. A lost response means unknown outcome.
|
|
505
|
+
For recoverable writes, choose --operation-key before execution. Recover with the original key,
|
|
506
|
+
SQL and options; a new key starts a new operation. A key added afterward cannot recover unkeyed SQL.
|
|
507
|
+
--dry-run shows this plan without executing SQL, exporting data, or maintaining the installation.
|
|
430
508
|
|
|
431
509
|
Examples:
|
|
432
510
|
deepline db query --sql "select * from companies limit 20"
|
|
@@ -437,18 +515,17 @@ Examples:
|
|
|
437
515
|
deepline db query --sql "select * from contacts limit 20" --format csv --out contacts.csv
|
|
438
516
|
deepline db query --sql "select domain, name from companies limit 20" --format markdown
|
|
439
517
|
`
|
|
440
|
-
).requiredOption("--sql <sql>", "SQL statement").option(
|
|
518
|
+
).requiredOption("--sql <sql>", "SQL statement").option(
|
|
519
|
+
"--dry-run",
|
|
520
|
+
"Describe the request, effects and recovery without executing SQL or writing an export"
|
|
521
|
+
).option("--max-rows <n>", "Maximum returned rows").option(
|
|
522
|
+
"--operation-key <key>",
|
|
523
|
+
"Recover this intended transactional SQL operation; separate intentions need separate keys"
|
|
524
|
+
).option("--format <format>", "Output format: table, json, csv, or markdown").option("--out <path>", "Write csv or markdown output to a file").option(
|
|
441
525
|
"--json",
|
|
442
526
|
"Emit raw JSON response. Also automatic when stdout is piped"
|
|
443
527
|
).action(async (options) => {
|
|
444
|
-
process.exitCode = await
|
|
445
|
-
"--sql",
|
|
446
|
-
options.sql,
|
|
447
|
-
...options.maxRows ? ["--max-rows", options.maxRows] : [],
|
|
448
|
-
...options.format ? ["--format", options.format] : [],
|
|
449
|
-
...options.out ? ["--out", options.out] : [],
|
|
450
|
-
...options.json ? ["--json"] : []
|
|
451
|
-
]);
|
|
528
|
+
process.exitCode = await runDbQueryCommand(options);
|
|
452
529
|
});
|
|
453
530
|
db.command("repair").description(
|
|
454
531
|
"Repair this workspace storage contract (role/DB grants). Org admin only."
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
describedTool,
|
|
3
3
|
publicToolSchemas,
|
|
4
4
|
toolMetadataJsonForDescribe
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HOWQKN6J.mjs";
|
|
6
6
|
import {
|
|
7
7
|
describedPlay
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZOFARJWH.mjs";
|
|
9
9
|
import {
|
|
10
10
|
SCHEMA_LINE_LIMIT,
|
|
11
11
|
addDescribeOptions,
|
|
@@ -13,26 +13,27 @@ import {
|
|
|
13
13
|
examples,
|
|
14
14
|
schemaLines,
|
|
15
15
|
topLevelField
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-JOA6IKDE.mjs";
|
|
17
|
+
import "./chunk-OVDNJAJN.mjs";
|
|
17
18
|
import "./chunk-EDWJY6T4.mjs";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-D6GD5AVN.mjs";
|
|
20
|
+
import "./chunk-REP2MYBI.mjs";
|
|
20
21
|
import "./chunk-MIMASXO4.mjs";
|
|
21
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-GVESPYSY.mjs";
|
|
22
23
|
import {
|
|
23
24
|
DeeplineClient
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-QZAP5VOS.mjs";
|
|
25
26
|
import "./chunk-CBVIJSHF.mjs";
|
|
26
27
|
import "./chunk-WXLOW623.mjs";
|
|
27
28
|
import "./chunk-UFS752TU.mjs";
|
|
28
29
|
import "./chunk-GAMFK2ZP.mjs";
|
|
29
30
|
import {
|
|
30
31
|
printCommandEnvelope
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-F45425TB.mjs";
|
|
33
|
+
import "./chunk-CCRQ2VGJ.mjs";
|
|
33
34
|
import "./chunk-DLIRSHV6.mjs";
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-G5774EFF.mjs";
|
|
36
|
+
import "./chunk-YIY74KUF.mjs";
|
|
36
37
|
import "./chunk-H7HIDGZ7.mjs";
|
|
37
38
|
import "./chunk-KP7W5NO6.mjs";
|
|
38
39
|
import "./chunk-6IKARAYD.mjs";
|