token-goat 2.9.14 → 2.9.15
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 +15 -1
- package/dist/token-goat-chunk-2X2EBBC6.mjs +277 -0
- package/dist/{token-goat-chunk-XQF5J25J.mjs → token-goat-chunk-3NSDDTGL.mjs} +5 -4
- package/dist/token-goat-chunk-4EXFN2AW.mjs +29 -0
- package/dist/{token-goat-chunk-4SDX3QP3.mjs → token-goat-chunk-5V7DAC7V.mjs} +5 -4
- package/dist/token-goat-chunk-6DLVZDB6.mjs +34 -0
- package/dist/{token-goat-chunk-XEH6KBWW.mjs → token-goat-chunk-7ZYK25AO.mjs} +4 -3
- package/dist/{token-goat-chunk-7OGKZ7AP.mjs → token-goat-chunk-A4JYKD5H.mjs} +5 -3
- package/dist/{token-goat-chunk-2ESBO4IN.mjs → token-goat-chunk-ASYEPR3S.mjs} +10 -7
- package/dist/{token-goat-chunk-PGGDW7DZ.mjs → token-goat-chunk-ATIFTMRC.mjs} +9 -6
- package/dist/{token-goat-chunk-IT6O3PNN.mjs → token-goat-chunk-BL5LNGBG.mjs} +813 -4613
- package/dist/{token-goat-chunk-PRJVGIC5.mjs → token-goat-chunk-C5JIO6HK.mjs} +7 -5
- package/dist/{token-goat-chunk-YTQHZJXW.mjs → token-goat-chunk-DQ4J5AFF.mjs} +40 -17
- package/dist/token-goat-chunk-ERTXEKB6.mjs +228 -0
- package/dist/{token-goat-chunk-ASVVF4JV.mjs → token-goat-chunk-GIIHUSZX.mjs} +137 -19
- package/dist/{token-goat-chunk-DAMXYVIW.mjs → token-goat-chunk-GMQQA7E4.mjs} +296 -276
- package/dist/{token-goat-chunk-T2IWWTHB.mjs → token-goat-chunk-IVUQLQWN.mjs} +33 -1142
- package/dist/{token-goat-chunk-POBYR64E.mjs → token-goat-chunk-K7F2BFIK.mjs} +801 -3
- package/dist/{token-goat-chunk-RUDOKYPJ.mjs → token-goat-chunk-LCZBPOIN.mjs} +1733 -1360
- package/dist/token-goat-chunk-LMFO66YD.mjs +331 -0
- package/dist/{token-goat-chunk-EZNVAIR3.mjs → token-goat-chunk-LT7JRU6K.mjs} +4 -3
- package/dist/{token-goat-chunk-YHGTGG6K.mjs → token-goat-chunk-MZDIJJ3R.mjs} +29 -5
- package/dist/{token-goat-chunk-O5WAMISC.mjs → token-goat-chunk-NDPO7GAH.mjs} +26 -16
- package/dist/token-goat-chunk-NDRP4KJQ.mjs +4371 -0
- package/dist/{token-goat-chunk-ZFM4PWXL.mjs → token-goat-chunk-NU7TLMQK.mjs} +3 -3
- package/dist/token-goat-chunk-OSUFN2FV.mjs +326 -0
- package/dist/token-goat-chunk-OUGNPMDA.mjs +959 -0
- package/dist/{token-goat-chunk-AMYCQJX4.mjs → token-goat-chunk-PM76YS22.mjs} +49 -256
- package/dist/{token-goat-chunk-SAQ5PG4L.mjs → token-goat-chunk-S4XRY446.mjs} +5 -2
- package/dist/{token-goat-chunk-DBNY4RLN.mjs → token-goat-chunk-SFAS46RE.mjs} +5 -3
- package/dist/{token-goat-chunk-XVZ4MNQC.mjs → token-goat-chunk-SZWYESBS.mjs} +221 -78
- package/dist/{token-goat-chunk-HF6H7RNK.mjs → token-goat-chunk-XEPXYDPI.mjs} +3 -2
- package/dist/{token-goat-chunk-EG3663UT.mjs → token-goat-chunk-YKG35VHC.mjs} +4 -2
- package/dist/{token-goat-chunk-VZYD4OZB.mjs → token-goat-chunk-YQ7WI2CO.mjs} +78 -266
- package/dist/{token-goat-chunk-3XQPEJMV.mjs → token-goat-chunk-YZX7EFG4.mjs} +1 -1
- package/dist/token-goat-hook.mjs +13 -9
- package/dist/token-goat.core.mjs +21 -16
- package/docs/cli.md +8 -6
- package/package.json +1 -1
- package/dist/token-goat-chunk-ZD4EM4LR.mjs +0 -30
- package/dist/token-goat-chunk-ZYNNQ36L.mjs +0 -479
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
Database
|
|
5
|
+
} from "./token-goat-chunk-OSUFN2FV.mjs";
|
|
6
|
+
import {
|
|
7
|
+
displaySafeText
|
|
8
|
+
} from "./token-goat-chunk-ERTXEKB6.mjs";
|
|
9
|
+
import {
|
|
10
|
+
init_define_import_meta_env
|
|
11
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
12
|
+
|
|
13
|
+
// src/sqlite_query.ts
|
|
14
|
+
init_define_import_meta_env();
|
|
15
|
+
import * as fs from "node:fs";
|
|
16
|
+
var SQLITE_QUERY_ROW_CAP = 5e3;
|
|
17
|
+
var SQLITE_MAGIC = Buffer.from([83, 81, 76, 105, 116, 101, 32, 102, 111, 114, 109, 97, 116, 32, 51, 0]);
|
|
18
|
+
function readMagicBytes(filePath) {
|
|
19
|
+
let fd;
|
|
20
|
+
try {
|
|
21
|
+
fd = fs.openSync(filePath, "r");
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const buf = Buffer.alloc(SQLITE_MAGIC.length);
|
|
27
|
+
const bytesRead = fs.readSync(fd, buf, 0, buf.length, 0);
|
|
28
|
+
return bytesRead === buf.length ? buf : null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
} finally {
|
|
32
|
+
fs.closeSync(fd);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function isSqliteFile(filePath) {
|
|
36
|
+
const magic = readMagicBytes(filePath);
|
|
37
|
+
return magic !== null && magic.equals(SQLITE_MAGIC);
|
|
38
|
+
}
|
|
39
|
+
function openReadonlySqlite(filePath) {
|
|
40
|
+
if (!fs.existsSync(filePath)) {
|
|
41
|
+
throw new Error(`file not found: ${displaySafeText(filePath)}`);
|
|
42
|
+
}
|
|
43
|
+
if (!isSqliteFile(filePath)) {
|
|
44
|
+
throw new Error(`not a valid SQLite database (bad file header): ${displaySafeText(filePath)}`);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
return new Database(filePath, { readonly: true, fileMustExist: true });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
50
|
+
throw new Error(`failed to open SQLite database: ${msg}`, { cause: e });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function quoteIdent(name) {
|
|
54
|
+
return `"${name.replace(/"/g, '""')}"`;
|
|
55
|
+
}
|
|
56
|
+
function getSqliteSchema(filePath) {
|
|
57
|
+
const db = openReadonlySqlite(filePath);
|
|
58
|
+
try {
|
|
59
|
+
const objects = db.prepare("SELECT name, type FROM sqlite_master WHERE type IN ('table','view') AND name NOT LIKE 'sqlite\\_%' ESCAPE '\\' ORDER BY name").all();
|
|
60
|
+
const tables = objects.map((o) => {
|
|
61
|
+
const columns = db.prepare(`PRAGMA table_info(${quoteIdent(o.name)})`).all().map(
|
|
62
|
+
(c) => ({
|
|
63
|
+
name: c.name,
|
|
64
|
+
type: c.type || "",
|
|
65
|
+
notNull: c.notnull === 1,
|
|
66
|
+
primaryKey: c.pk > 0,
|
|
67
|
+
defaultValue: c.dflt_value === null || c.dflt_value === void 0 ? null : String(c.dflt_value)
|
|
68
|
+
})
|
|
69
|
+
);
|
|
70
|
+
const indexes = db.prepare(`PRAGMA index_list(${quoteIdent(o.name)})`).all().map(
|
|
71
|
+
(idx) => {
|
|
72
|
+
const idxColumns = db.prepare(`PRAGMA index_info(${quoteIdent(idx.name)})`).all().map((c) => c.name);
|
|
73
|
+
return { name: idx.name, unique: idx.unique === 1, columns: idxColumns };
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
const foreignKeys = db.prepare(`PRAGMA foreign_key_list(${quoteIdent(o.name)})`).all().map((fk) => ({ table: fk.table, from: fk.from, to: fk.to }));
|
|
77
|
+
let rowCount;
|
|
78
|
+
try {
|
|
79
|
+
const row = db.prepare(`SELECT COUNT(*) AS c FROM ${quoteIdent(o.name)}`).get();
|
|
80
|
+
rowCount = row.c;
|
|
81
|
+
} catch {
|
|
82
|
+
rowCount = null;
|
|
83
|
+
}
|
|
84
|
+
return { name: o.name, kind: o.type === "view" ? "view" : "table", columns, indexes, foreignKeys, rowCount };
|
|
85
|
+
});
|
|
86
|
+
return { tables };
|
|
87
|
+
} finally {
|
|
88
|
+
db.close();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function formatSqliteSchema(result) {
|
|
92
|
+
if (result.tables.length === 0) return "(no tables or views found)";
|
|
93
|
+
return result.tables.map((t) => {
|
|
94
|
+
const lines = [`${t.name} (${t.kind}${t.rowCount !== null ? `, ${t.rowCount} row${t.rowCount === 1 ? "" : "s"}` : ""})`];
|
|
95
|
+
for (const c of t.columns) {
|
|
96
|
+
const flags = [c.primaryKey ? "PK" : null, c.notNull ? "NOT NULL" : null, c.defaultValue !== null ? `DEFAULT ${c.defaultValue}` : null].filter((f) => f !== null).join(" ");
|
|
97
|
+
lines.push(` ${displaySafeText(c.name)} ${displaySafeText(c.type || "(untyped)")}${flags ? ` ${flags}` : ""}`);
|
|
98
|
+
}
|
|
99
|
+
if (t.indexes.length > 0) {
|
|
100
|
+
lines.push(" indexes:");
|
|
101
|
+
for (const idx of t.indexes) {
|
|
102
|
+
lines.push(` ${displaySafeText(idx.name)}${idx.unique ? " (unique)" : ""}: ${displaySafeText(idx.columns.join(", "))}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (t.foreignKeys.length > 0) {
|
|
106
|
+
lines.push(" foreign keys:");
|
|
107
|
+
for (const fk of t.foreignKeys) {
|
|
108
|
+
lines.push(` ${fk.from} -> ${fk.table}.${fk.to}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return lines.join("\n");
|
|
112
|
+
}).join("\n\n");
|
|
113
|
+
}
|
|
114
|
+
function getSqliteTables(filePath) {
|
|
115
|
+
const db = openReadonlySqlite(filePath);
|
|
116
|
+
try {
|
|
117
|
+
const objects = db.prepare(
|
|
118
|
+
// ESCAPE makes every `_` literal; see getSqliteSchema above. Here it costs three tables rather than one, since `%_fts_%` and `%_vec0_%` exist to hide the shadow tables FTS5 and sqlite-vec create beside a virtual table, and unescaped they also hide anything of the shape `my_ftsx_cache`.
|
|
119
|
+
"SELECT name, type FROM sqlite_master WHERE type IN ('table','view') AND name NOT LIKE 'sqlite\\_%' ESCAPE '\\' AND name NOT LIKE '%\\_fts\\_%' ESCAPE '\\' AND name NOT LIKE '%\\_vec0\\_%' ESCAPE '\\' ORDER BY name"
|
|
120
|
+
).all();
|
|
121
|
+
return objects.map((o) => {
|
|
122
|
+
let columnCount;
|
|
123
|
+
try {
|
|
124
|
+
const cols = db.prepare(`PRAGMA table_info(${quoteIdent(o.name)})`).all();
|
|
125
|
+
columnCount = cols.length;
|
|
126
|
+
} catch {
|
|
127
|
+
columnCount = 0;
|
|
128
|
+
}
|
|
129
|
+
let rowCount;
|
|
130
|
+
try {
|
|
131
|
+
const row = db.prepare(`SELECT COUNT(*) AS c FROM ${quoteIdent(o.name)}`).get();
|
|
132
|
+
rowCount = row.c;
|
|
133
|
+
} catch {
|
|
134
|
+
rowCount = null;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
name: o.name,
|
|
138
|
+
kind: o.type === "view" ? "view" : "table",
|
|
139
|
+
rowCount,
|
|
140
|
+
columnCount
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
} finally {
|
|
144
|
+
db.close();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function formatSqliteTables(tables) {
|
|
148
|
+
if (tables.length === 0) return "(no tables or views found)";
|
|
149
|
+
return tables.map((t) => {
|
|
150
|
+
const parts = [t.kind];
|
|
151
|
+
if (t.rowCount !== null) {
|
|
152
|
+
parts.push(`${t.rowCount.toLocaleString()} row${t.rowCount === 1 ? "" : "s"}`);
|
|
153
|
+
}
|
|
154
|
+
parts.push(`${t.columnCount} col${t.columnCount === 1 ? "" : "s"}`);
|
|
155
|
+
return `${displaySafeText(t.name)} (${parts.join(", ")})`;
|
|
156
|
+
}).join("\n");
|
|
157
|
+
}
|
|
158
|
+
var FORBIDDEN_KEYWORDS = [
|
|
159
|
+
"INSERT",
|
|
160
|
+
"UPDATE",
|
|
161
|
+
"DELETE",
|
|
162
|
+
"DROP",
|
|
163
|
+
"ALTER",
|
|
164
|
+
"CREATE",
|
|
165
|
+
"ATTACH",
|
|
166
|
+
"DETACH",
|
|
167
|
+
"TRUNCATE",
|
|
168
|
+
"VACUUM",
|
|
169
|
+
"REINDEX",
|
|
170
|
+
"PRAGMA",
|
|
171
|
+
"BEGIN",
|
|
172
|
+
"COMMIT",
|
|
173
|
+
"ROLLBACK",
|
|
174
|
+
"SAVEPOINT",
|
|
175
|
+
"RELEASE",
|
|
176
|
+
"GRANT",
|
|
177
|
+
"REVOKE"
|
|
178
|
+
];
|
|
179
|
+
function stripSqlLiteralsAndComments(sql) {
|
|
180
|
+
let out = "";
|
|
181
|
+
let i = 0;
|
|
182
|
+
const n = sql.length;
|
|
183
|
+
while (i < n) {
|
|
184
|
+
const c = sql[i];
|
|
185
|
+
if (c === "'" || c === '"' || c === "`") {
|
|
186
|
+
const quote = c;
|
|
187
|
+
out += " ";
|
|
188
|
+
i++;
|
|
189
|
+
while (i < n) {
|
|
190
|
+
if (sql[i] === quote) {
|
|
191
|
+
if (sql[i + 1] === quote) {
|
|
192
|
+
i += 2;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
i++;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
i++;
|
|
199
|
+
}
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (c === "[") {
|
|
203
|
+
out += " ";
|
|
204
|
+
i++;
|
|
205
|
+
while (i < n && sql[i] !== "]") i++;
|
|
206
|
+
if (i < n) i++;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (c === "-" && sql[i + 1] === "-") {
|
|
210
|
+
while (i < n && sql[i] !== "\n") i++;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (c === "/" && sql[i + 1] === "*") {
|
|
214
|
+
i += 2;
|
|
215
|
+
while (i < n && !(sql[i] === "*" && sql[i + 1] === "/")) i++;
|
|
216
|
+
i += 2;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
out += c;
|
|
220
|
+
i++;
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
function validateReadOnlySelect(sql) {
|
|
225
|
+
const stripped = stripSqlLiteralsAndComments(sql);
|
|
226
|
+
const trimmed = stripped.trim();
|
|
227
|
+
if (trimmed === "") {
|
|
228
|
+
throw new Error("empty query");
|
|
229
|
+
}
|
|
230
|
+
const withoutTrailingSemicolons = trimmed.replace(/;+\s*$/, "");
|
|
231
|
+
if (withoutTrailingSemicolons.includes(";")) {
|
|
232
|
+
throw new Error("multiple statements are not allowed (sqlite-query accepts exactly one read-only SELECT statement)");
|
|
233
|
+
}
|
|
234
|
+
const upper = withoutTrailingSemicolons.toUpperCase();
|
|
235
|
+
if (!/^(SELECT|WITH)\b/.test(upper.trimStart())) {
|
|
236
|
+
throw new Error("only SELECT statements are allowed (sqlite-query is read-only)");
|
|
237
|
+
}
|
|
238
|
+
for (const kw of FORBIDDEN_KEYWORDS) {
|
|
239
|
+
if (new RegExp(`\\b${kw}\\b`).test(upper)) {
|
|
240
|
+
throw new Error(`statement contains forbidden keyword '${kw}' (sqlite-query only allows read-only SELECT queries)`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (/\bREPLACE\b(?!\s*\()/.test(upper)) {
|
|
244
|
+
throw new Error("statement contains forbidden keyword 'REPLACE' (sqlite-query only allows read-only SELECT queries)");
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function normalizeSqliteScalar(value) {
|
|
248
|
+
if (typeof value === "bigint") {
|
|
249
|
+
return Number.isSafeInteger(Number(value)) ? Number(value) : value.toString();
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
253
|
+
function normalizeSqliteRow(row) {
|
|
254
|
+
const out = {};
|
|
255
|
+
for (const [k, v] of Object.entries(row)) out[k] = normalizeSqliteScalar(v);
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
258
|
+
function runReadOnlySqliteQuery(filePath, sql, opts = {}) {
|
|
259
|
+
validateReadOnlySelect(sql);
|
|
260
|
+
const rowCap = opts.rowCap ?? SQLITE_QUERY_ROW_CAP;
|
|
261
|
+
const db = openReadonlySqlite(filePath);
|
|
262
|
+
try {
|
|
263
|
+
let stmt;
|
|
264
|
+
try {
|
|
265
|
+
stmt = db.prepare(sql);
|
|
266
|
+
} catch (e) {
|
|
267
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
268
|
+
throw new Error(`invalid SQL: ${msg}`, { cause: e });
|
|
269
|
+
}
|
|
270
|
+
if (!stmt.reader) {
|
|
271
|
+
throw new Error("only read-only SELECT statements are allowed (sqlite-query is read-only)");
|
|
272
|
+
}
|
|
273
|
+
stmt.safeIntegers(true);
|
|
274
|
+
let columns = [];
|
|
275
|
+
try {
|
|
276
|
+
columns = stmt.columns().map((c) => c.name);
|
|
277
|
+
} catch {
|
|
278
|
+
columns = [];
|
|
279
|
+
}
|
|
280
|
+
const rows = [];
|
|
281
|
+
let rowCapped = false;
|
|
282
|
+
for (const row of stmt.iterate()) {
|
|
283
|
+
if (rows.length >= rowCap) {
|
|
284
|
+
rowCapped = true;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
rows.push(normalizeSqliteRow(row));
|
|
288
|
+
}
|
|
289
|
+
return { columns, rows, rowCapped };
|
|
290
|
+
} finally {
|
|
291
|
+
db.close();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function formatSqliteCell(value) {
|
|
295
|
+
if (value === null || value === void 0) return "";
|
|
296
|
+
if (value instanceof Uint8Array) return `<blob ${value.length} bytes>`;
|
|
297
|
+
return String(value);
|
|
298
|
+
}
|
|
299
|
+
function formatSqliteQueryTable(result, opts = {}) {
|
|
300
|
+
if (result.columns.length === 0 && result.rows.length === 0) return "(no rows)";
|
|
301
|
+
const lines = [
|
|
302
|
+
result.columns.map(quoteCsvCellLocal).join(","),
|
|
303
|
+
...result.rows.map((r) => result.columns.map((c) => quoteCsvCellLocal(formatSqliteCell(r[c]))).join(","))
|
|
304
|
+
];
|
|
305
|
+
if (opts.headTruncated === true) {
|
|
306
|
+
lines.push("...(more rows elided; use --head to see more)");
|
|
307
|
+
}
|
|
308
|
+
if (result.rowCapped) {
|
|
309
|
+
lines.push(`...(result truncated at the ${SQLITE_QUERY_ROW_CAP}-row safety cap; narrow the query with WHERE/LIMIT for a complete result)`);
|
|
310
|
+
}
|
|
311
|
+
return lines.join("\n");
|
|
312
|
+
}
|
|
313
|
+
function quoteCsvCellLocal(cell) {
|
|
314
|
+
if (cell.includes(",") || cell.includes('"') || cell.includes("\n") || cell.includes("\r")) {
|
|
315
|
+
return `"${cell.replace(/"/g, '""')}"`;
|
|
316
|
+
}
|
|
317
|
+
return cell;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export {
|
|
321
|
+
SQLITE_QUERY_ROW_CAP,
|
|
322
|
+
isSqliteFile,
|
|
323
|
+
openReadonlySqlite,
|
|
324
|
+
getSqliteSchema,
|
|
325
|
+
formatSqliteSchema,
|
|
326
|
+
getSqliteTables,
|
|
327
|
+
formatSqliteTables,
|
|
328
|
+
validateReadOnlySelect,
|
|
329
|
+
runReadOnlySqliteQuery,
|
|
330
|
+
formatSqliteQueryTable
|
|
331
|
+
};
|
|
@@ -5,12 +5,13 @@ import {
|
|
|
5
5
|
docxTables,
|
|
6
6
|
docxText,
|
|
7
7
|
formatDocxTables
|
|
8
|
-
} from "./token-goat-chunk-
|
|
9
|
-
import "./token-goat-chunk-
|
|
8
|
+
} from "./token-goat-chunk-5V7DAC7V.mjs";
|
|
9
|
+
import "./token-goat-chunk-MZDIJJ3R.mjs";
|
|
10
10
|
import "./token-goat-chunk-XTQAOTSO.mjs";
|
|
11
11
|
import "./token-goat-chunk-AH6QILZM.mjs";
|
|
12
12
|
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
13
|
-
import "./token-goat-chunk-
|
|
13
|
+
import "./token-goat-chunk-PM76YS22.mjs";
|
|
14
|
+
import "./token-goat-chunk-ERTXEKB6.mjs";
|
|
14
15
|
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
15
16
|
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
16
17
|
export {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
17
17
|
import {
|
|
18
18
|
pushAll
|
|
19
|
-
} from "./token-goat-chunk-
|
|
19
|
+
} from "./token-goat-chunk-PM76YS22.mjs";
|
|
20
20
|
import {
|
|
21
21
|
init_define_import_meta_env
|
|
22
22
|
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
@@ -332,7 +332,7 @@ function pushTextValue(runs, val) {
|
|
|
332
332
|
runs.push(String(val["#text"]));
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
|
-
function collectTextRuns(node, tag) {
|
|
335
|
+
function collectTextRuns(node, tag, skipInside = []) {
|
|
336
336
|
const runs = [];
|
|
337
337
|
function walk(n) {
|
|
338
338
|
if (Array.isArray(n)) {
|
|
@@ -342,6 +342,7 @@ function collectTextRuns(node, tag) {
|
|
|
342
342
|
if (n !== null && typeof n === "object") {
|
|
343
343
|
const obj = n;
|
|
344
344
|
for (const [key, val] of Object.entries(obj)) {
|
|
345
|
+
if (skipInside.includes(key)) continue;
|
|
345
346
|
if (key === tag) {
|
|
346
347
|
pushTextValue(runs, val);
|
|
347
348
|
} else if (val !== null && typeof val === "object") {
|
|
@@ -353,7 +354,8 @@ function collectTextRuns(node, tag) {
|
|
|
353
354
|
walk(node);
|
|
354
355
|
return runs;
|
|
355
356
|
}
|
|
356
|
-
function collectElements(node, tag) {
|
|
357
|
+
function collectElements(node, tag, opts = {}) {
|
|
358
|
+
const skip = opts.skipInside;
|
|
357
359
|
const out = [];
|
|
358
360
|
function walk(n) {
|
|
359
361
|
if (Array.isArray(n)) {
|
|
@@ -363,9 +365,17 @@ function collectElements(node, tag) {
|
|
|
363
365
|
if (n !== null && typeof n === "object") {
|
|
364
366
|
const obj = n;
|
|
365
367
|
for (const [key, val] of Object.entries(obj)) {
|
|
368
|
+
if (skip !== void 0 && skip.includes(key)) continue;
|
|
366
369
|
if (key === tag) {
|
|
367
|
-
if (
|
|
368
|
-
|
|
370
|
+
if (opts.includeNested !== true) {
|
|
371
|
+
if (Array.isArray(val)) pushAll(out, val);
|
|
372
|
+
else out.push(val);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
for (const item of Array.isArray(val) ? val : [val]) {
|
|
376
|
+
out.push(item);
|
|
377
|
+
if (item !== null && typeof item === "object") walk(item);
|
|
378
|
+
}
|
|
369
379
|
} else if (val !== null && typeof val === "object") {
|
|
370
380
|
walk(val);
|
|
371
381
|
}
|
|
@@ -375,6 +385,19 @@ function collectElements(node, tag) {
|
|
|
375
385
|
walk(node);
|
|
376
386
|
return out;
|
|
377
387
|
}
|
|
388
|
+
function collectParagraphTexts(node, paragraphTag, runTag, skipInside = [], breakTag) {
|
|
389
|
+
const paragraphs = collectElements(node, paragraphTag, { skipInside });
|
|
390
|
+
if (paragraphs.length === 0) {
|
|
391
|
+
const whole = joinParagraphRuns(node, runTag, skipInside, breakTag);
|
|
392
|
+
return whole.length > 0 ? [whole] : [];
|
|
393
|
+
}
|
|
394
|
+
return paragraphs.map((p) => joinParagraphRuns(p, runTag, skipInside, breakTag));
|
|
395
|
+
}
|
|
396
|
+
function joinParagraphRuns(node, runTag, skipInside, breakTag) {
|
|
397
|
+
const runs = collectTextRuns(node, runTag, skipInside);
|
|
398
|
+
const broken = breakTag !== void 0 && collectElements(node, breakTag, { skipInside }).length > 0;
|
|
399
|
+
return runs.join(broken ? " " : "");
|
|
400
|
+
}
|
|
378
401
|
function sortNumberedParts(paths, pattern) {
|
|
379
402
|
return paths.map((p) => {
|
|
380
403
|
const m = pattern.exec(p);
|
|
@@ -392,5 +415,6 @@ export {
|
|
|
392
415
|
parseOoxmlPart,
|
|
393
416
|
collectTextRuns,
|
|
394
417
|
collectElements,
|
|
418
|
+
collectParagraphTexts,
|
|
395
419
|
sortNumberedParts
|
|
396
420
|
};
|
|
@@ -70,28 +70,36 @@ import {
|
|
|
70
70
|
requirePositiveInt,
|
|
71
71
|
run,
|
|
72
72
|
visualStudioManualSteps
|
|
73
|
-
} from "./token-goat-chunk-
|
|
74
|
-
import "./token-goat-chunk-
|
|
75
|
-
import "./token-goat-chunk-
|
|
76
|
-
import
|
|
77
|
-
|
|
73
|
+
} from "./token-goat-chunk-GMQQA7E4.mjs";
|
|
74
|
+
import "./token-goat-chunk-LCZBPOIN.mjs";
|
|
75
|
+
import "./token-goat-chunk-LMFO66YD.mjs";
|
|
76
|
+
import {
|
|
77
|
+
cmdDescribe,
|
|
78
|
+
cmdSessionSchema
|
|
79
|
+
} from "./token-goat-chunk-OUGNPMDA.mjs";
|
|
80
|
+
import "./token-goat-chunk-BL5LNGBG.mjs";
|
|
81
|
+
import "./token-goat-chunk-YQ7WI2CO.mjs";
|
|
78
82
|
import "./token-goat-chunk-NEI4NC54.mjs";
|
|
79
|
-
import "./token-goat-chunk-
|
|
80
|
-
import "./token-goat-chunk-
|
|
81
|
-
import "./token-goat-chunk-
|
|
82
|
-
import "./token-goat-chunk-
|
|
83
|
+
import "./token-goat-chunk-5V7DAC7V.mjs";
|
|
84
|
+
import "./token-goat-chunk-ASYEPR3S.mjs";
|
|
85
|
+
import "./token-goat-chunk-NU7TLMQK.mjs";
|
|
86
|
+
import "./token-goat-chunk-YKG35VHC.mjs";
|
|
83
87
|
import "./token-goat-chunk-3BTK54F3.mjs";
|
|
84
|
-
import "./token-goat-chunk-
|
|
88
|
+
import "./token-goat-chunk-MZDIJJ3R.mjs";
|
|
85
89
|
import "./token-goat-chunk-XTQAOTSO.mjs";
|
|
86
90
|
import "./token-goat-chunk-AH6QILZM.mjs";
|
|
91
|
+
import "./token-goat-chunk-XEPXYDPI.mjs";
|
|
92
|
+
import "./token-goat-chunk-NDRP4KJQ.mjs";
|
|
93
|
+
import "./token-goat-chunk-2X2EBBC6.mjs";
|
|
87
94
|
import "./token-goat-chunk-Y4AFKTHK.mjs";
|
|
88
|
-
import "./token-goat-chunk-
|
|
89
|
-
import "./token-goat-chunk-
|
|
90
|
-
import "./token-goat-chunk-
|
|
95
|
+
import "./token-goat-chunk-SFAS46RE.mjs";
|
|
96
|
+
import "./token-goat-chunk-IVUQLQWN.mjs";
|
|
97
|
+
import "./token-goat-chunk-K7F2BFIK.mjs";
|
|
98
|
+
import "./token-goat-chunk-S4XRY446.mjs";
|
|
91
99
|
import "./token-goat-chunk-EEIDFMEM.mjs";
|
|
92
|
-
import "./token-goat-chunk-
|
|
93
|
-
import "./token-goat-chunk-
|
|
94
|
-
import "./token-goat-chunk-
|
|
100
|
+
import "./token-goat-chunk-OSUFN2FV.mjs";
|
|
101
|
+
import "./token-goat-chunk-PM76YS22.mjs";
|
|
102
|
+
import "./token-goat-chunk-ERTXEKB6.mjs";
|
|
95
103
|
import "./token-goat-chunk-GMOUBOX4.mjs";
|
|
96
104
|
import "./token-goat-chunk-A37V4PBF.mjs";
|
|
97
105
|
export {
|
|
@@ -101,6 +109,7 @@ export {
|
|
|
101
109
|
buildProgram,
|
|
102
110
|
cmdCsvProfile,
|
|
103
111
|
cmdCsvQuery,
|
|
112
|
+
cmdDescribe,
|
|
104
113
|
cmdDocxOutline,
|
|
105
114
|
cmdDocxTables,
|
|
106
115
|
cmdDocxText,
|
|
@@ -125,6 +134,7 @@ export {
|
|
|
125
134
|
cmdPptxSlide,
|
|
126
135
|
cmdPptxText,
|
|
127
136
|
cmdReplace,
|
|
137
|
+
cmdSessionSchema,
|
|
128
138
|
cmdSharepointResolve,
|
|
129
139
|
cmdSkillBody,
|
|
130
140
|
cmdSkillCompact,
|