deepline 0.3.293 → 0.3.295
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/compat.ts +35 -7
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +269 -267
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +3 -4
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +14 -1
- package/dist/cli/auth-EDTRERZP.mjs +31 -0
- package/dist/cli/auth-TDHKB277.js +31 -0
- package/dist/cli/billing-ELIDPILY.js +1749 -0
- package/dist/cli/billing-EXGXJVAU.mjs +1749 -0
- package/dist/cli/chunk-2S5Y3TZP.js +5688 -0
- package/dist/cli/chunk-3KC45UVF.js +150 -0
- package/dist/cli/chunk-3XX5TEA4.js +15 -0
- package/dist/cli/chunk-4MBOJQPL.mjs +0 -0
- package/dist/cli/chunk-4NEFYBF7.js +2240 -0
- package/dist/cli/chunk-5JLQPVNX.js +3056 -0
- package/dist/cli/chunk-5KDKFHZI.js +1269 -0
- package/dist/cli/chunk-6A3TJUWC.js +76 -0
- package/dist/cli/chunk-6O5YZOVN.mjs +890 -0
- package/dist/cli/chunk-7P5AA3SN.js +344 -0
- package/dist/cli/chunk-AYHLUHE5.js +52 -0
- package/dist/cli/chunk-CBVIJSHF.mjs +560 -0
- package/dist/cli/chunk-CFVVCN4A.js +735 -0
- package/dist/cli/chunk-COGTRVWW.js +30 -0
- package/dist/cli/chunk-D4AZUZO4.js +190 -0
- package/dist/cli/chunk-DLIRSHV6.mjs +28 -0
- package/dist/cli/chunk-EACVZI6N.mjs +1995 -0
- package/dist/cli/chunk-EDWJY6T4.mjs +3056 -0
- package/dist/cli/chunk-EXMLR72R.mjs +0 -0
- package/dist/cli/chunk-F35VOIQL.js +890 -0
- package/dist/cli/chunk-GAMFK2ZP.mjs +148 -0
- package/dist/cli/chunk-GHRQQPW2.mjs +2240 -0
- package/dist/cli/chunk-GONRLVV3.js +3440 -0
- package/dist/cli/chunk-GVUJJJ5G.mjs +76 -0
- package/dist/cli/chunk-H7HIDGZ7.mjs +150 -0
- package/dist/cli/chunk-HUZXWOSK.mjs +503 -0
- package/dist/cli/chunk-I5YZLGMG.js +1 -0
- package/dist/cli/chunk-ITOFSXIU.mjs +15 -0
- package/dist/cli/chunk-J5NA2TTX.js +503 -0
- package/dist/cli/chunk-JCS5TPNY.mjs +3440 -0
- package/dist/cli/chunk-JNNOCMQY.js +47 -0
- package/dist/cli/chunk-KRD6H754.mjs +30 -0
- package/dist/cli/chunk-LA46MMTL.js +560 -0
- package/dist/cli/chunk-LDWT7RJK.mjs +190 -0
- package/dist/cli/chunk-M2V26OR5.js +499 -0
- package/dist/cli/chunk-MIMASXO4.mjs +389 -0
- package/dist/cli/chunk-MROPCKW2.mjs +190 -0
- package/dist/cli/chunk-NXDRDJ4K.js +389 -0
- package/dist/cli/chunk-NXGCO4JB.mjs +344 -0
- package/dist/cli/chunk-OG64RBAC.js +6 -0
- package/dist/cli/chunk-OQYEC4GL.mjs +34 -0
- package/dist/cli/chunk-OWJZUE3Y.mjs +103 -0
- package/dist/cli/chunk-SDK3ZA2C.js +103 -0
- package/dist/cli/chunk-SFLARO4Y.mjs +47 -0
- package/dist/cli/chunk-SVIIIYIQ.js +923 -0
- package/dist/cli/chunk-TAC3JIFE.mjs +354 -0
- package/dist/cli/chunk-U3PI7HBM.js +34 -0
- package/dist/cli/chunk-UFS752TU.mjs +52 -0
- package/dist/cli/chunk-UI37DQE7.mjs +499 -0
- package/dist/cli/chunk-UNEMDKXN.js +1 -0
- package/dist/cli/chunk-WB6Z2Q44.mjs +1622 -0
- package/dist/cli/chunk-WJYPBHTE.js +148 -0
- package/dist/cli/chunk-WOHBA5PV.js +354 -0
- package/dist/cli/chunk-WQICC2B3.js +190 -0
- package/dist/cli/chunk-WZYKRD7T.mjs +6 -0
- package/dist/cli/chunk-XL2FO6CW.mjs +5688 -0
- package/dist/cli/chunk-XNYIZMNQ.js +28 -0
- package/dist/cli/chunk-XRK2TZT5.js +1995 -0
- package/dist/cli/chunk-YJYPL5OK.mjs +1269 -0
- package/dist/cli/chunk-YWNDYCXR.mjs +735 -0
- package/dist/cli/chunk-YWWAF7KZ.mjs +923 -0
- package/dist/cli/chunk-ZDO3TO3M.js +1622 -0
- package/dist/cli/client-4JVOYVC5.js +20 -0
- package/dist/cli/client-EEN2IJN2.mjs +20 -0
- package/dist/cli/csv-BOHBEP2I.mjs +585 -0
- package/dist/cli/csv-S5NYRUEX.js +585 -0
- package/dist/cli/db-CLODWCOB.mjs +486 -0
- package/dist/cli/db-F6PKFOOV.js +486 -0
- package/dist/cli/executions-5TQAKLJU.js +28 -0
- package/dist/cli/executions-MAKW6QOY.mjs +28 -0
- package/dist/cli/feedback-GV4QJFEN.js +107 -0
- package/dist/cli/feedback-XY24TW7H.mjs +107 -0
- package/dist/cli/getting-started.js +18 -76
- package/dist/cli/getting-started.mjs +10 -37
- package/dist/cli/git-6S2C22T5.js +23 -0
- package/dist/cli/git-OZLBD5HH.mjs +23 -0
- package/dist/cli/index.js +291 -54294
- package/dist/cli/index.mjs +209 -54352
- package/dist/cli/legacy-noops-LLCGDPQE.js +157 -0
- package/dist/cli/legacy-noops-TYH3TW2D.mjs +157 -0
- package/dist/cli/monitors-CABMB4DW.js +3251 -0
- package/dist/cli/monitors-TTD55HMK.mjs +3251 -0
- package/dist/cli/org-MSF3RG76.js +849 -0
- package/dist/cli/org-SFJ77MWY.mjs +849 -0
- package/dist/cli/play-NXHJSCKL.mjs +18439 -0
- package/dist/cli/play-OKSFNNO4.js +18439 -0
- package/dist/cli/providers-QC2ERERL.js +95 -0
- package/dist/cli/providers-TIIAZEUA.mjs +95 -0
- package/dist/cli/proxy-env-EBANZHPV.js +161 -0
- package/dist/cli/proxy-env-M4ZHXHRL.mjs +161 -0
- package/dist/cli/quickstart-ICANHLMI.js +69 -0
- package/dist/cli/quickstart-KWUOP3FI.mjs +69 -0
- package/dist/cli/search-U5H2FDOO.mjs +18 -0
- package/dist/cli/search-XQRQOLWS.js +18 -0
- package/dist/cli/secrets-3J6YTWFA.mjs +400 -0
- package/dist/cli/secrets-YNMNZNOM.js +400 -0
- package/dist/cli/sessions-CLEES4L6.mjs +15 -0
- package/dist/cli/sessions-J6VR47FG.js +15 -0
- package/dist/cli/settings-EEKZMTY4.js +846 -0
- package/dist/cli/settings-UVLOQZRH.mjs +846 -0
- package/dist/cli/setup-DLMDXPGJ.mjs +1257 -0
- package/dist/cli/setup-HC4Q7QM4.js +1257 -0
- package/dist/cli/skills-33PHFBSB.mjs +28 -0
- package/dist/cli/skills-LFRY3KPX.js +28 -0
- package/dist/cli/tools-3COEPKML.mjs +2955 -0
- package/dist/cli/tools-QXEVCN45.js +2955 -0
- package/dist/cli/update-LSAC4FF5.mjs +28 -0
- package/dist/cli/update-NXHSPYXA.js +28 -0
- package/dist/cli/workflow-7S44OECF.mjs +1936 -0
- package/dist/cli/workflow-QPZWYSZE.js +1936 -0
- package/dist/helpers.js +6 -32
- package/dist/helpers.mjs +2 -0
- package/dist/index.js +1972 -12825
- package/dist/index.mjs +1910 -12672
- package/dist/install-integrity.json +110 -0
- package/dist/monitor-fleet-contract.js +31 -730
- package/dist/monitor-fleet-contract.mjs +18 -667
- package/dist/monitor-input-contract.js +10 -390
- package/dist/monitor-input-contract.mjs +7 -348
- package/dist/plays/bundle-play-file.mjs +13 -5178
- package/dist/plays/csv-data-input.js +5 -3132
- package/dist/plays/csv-data-input.mjs +5 -3105
- package/dist/plays/run-request.js +56 -664
- package/dist/plays/run-request.mjs +30 -588
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +5 -212
- package/dist/release.mjs +5 -185
- package/package.json +1 -1
|
@@ -0,0 +1,389 @@
|
|
|
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; }// src/tool-output.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _fs = require('fs');
|
|
9
|
+
var _os = require('os');
|
|
10
|
+
var _path = require('path');
|
|
11
|
+
function isPlainObject(value) {
|
|
12
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function getByDottedPath(root, dottedPath) {
|
|
15
|
+
let current = root;
|
|
16
|
+
for (const segment of String(dottedPath || "").split(".").filter(Boolean)) {
|
|
17
|
+
if (!isPlainObject(current) || !(segment in current)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
current = current[segment];
|
|
21
|
+
}
|
|
22
|
+
return current;
|
|
23
|
+
}
|
|
24
|
+
function normalizeRows(value) {
|
|
25
|
+
if (!Array.isArray(value)) return null;
|
|
26
|
+
return value.map((entry) => {
|
|
27
|
+
if (isPlainObject(entry)) return entry;
|
|
28
|
+
return { value: entry };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function columnsForRows(rows) {
|
|
32
|
+
const seen = /* @__PURE__ */ new Set();
|
|
33
|
+
const columns = [];
|
|
34
|
+
for (const row of rows) {
|
|
35
|
+
for (const key of Object.keys(row)) {
|
|
36
|
+
if (!seen.has(key)) {
|
|
37
|
+
seen.add(key);
|
|
38
|
+
columns.push(key);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return columns;
|
|
43
|
+
}
|
|
44
|
+
function candidateRoots(payload) {
|
|
45
|
+
const roots = [
|
|
46
|
+
{ path: null, value: payload }
|
|
47
|
+
];
|
|
48
|
+
if (isPlainObject(payload) && isPlainObject(payload.toolResponse)) {
|
|
49
|
+
roots.push({ path: "toolResponse", value: payload.toolResponse });
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(payload.toolResponse, "raw")) {
|
|
51
|
+
roots.push({
|
|
52
|
+
path: "toolResponse.raw",
|
|
53
|
+
value: payload.toolResponse.raw
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (isPlainObject(payload) && isPlainObject(payload.output)) {
|
|
58
|
+
roots.push({ path: "output", value: payload.output });
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(payload.output, "body")) {
|
|
60
|
+
roots.push({ path: "output.body", value: payload.output.body });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (isPlainObject(payload) && isPlainObject(payload.result)) {
|
|
64
|
+
roots.push({ path: "result", value: payload.result });
|
|
65
|
+
if (isPlainObject(payload.result.data)) {
|
|
66
|
+
roots.push({ path: "result.data", value: payload.result.data });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return roots;
|
|
70
|
+
}
|
|
71
|
+
function findBestArrayCandidate(value, pathPrefix = "", depth = 0) {
|
|
72
|
+
if (depth > 5) return null;
|
|
73
|
+
const directRows = normalizeRows(value);
|
|
74
|
+
const hasObjectRow = _nullishCoalesce(_optionalChain([directRows, 'optionalAccess', _ => _.some, 'call', _2 => _2(
|
|
75
|
+
(row) => Object.keys(row).some((key) => key !== "value")
|
|
76
|
+
)]), () => ( false));
|
|
77
|
+
let best = directRows && directRows.length > 0 && hasObjectRow ? { path: pathPrefix, rows: directRows } : null;
|
|
78
|
+
if (!isPlainObject(value)) {
|
|
79
|
+
return best;
|
|
80
|
+
}
|
|
81
|
+
for (const [key, child] of Object.entries(value)) {
|
|
82
|
+
const childPath = pathPrefix ? `${pathPrefix}.${key}` : key;
|
|
83
|
+
const candidate = findBestArrayCandidate(child, childPath, depth + 1);
|
|
84
|
+
if (!candidate) continue;
|
|
85
|
+
if (!best || candidate.rows.length > best.rows.length) {
|
|
86
|
+
best = candidate;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return best;
|
|
90
|
+
}
|
|
91
|
+
function tryConvertToList(payload, options) {
|
|
92
|
+
const listExtractorPaths = Array.isArray(_optionalChain([options, 'optionalAccess', _3 => _3.listExtractorPaths])) ? _optionalChain([options, 'optionalAccess', _4 => _4.listExtractorPaths, 'access', _5 => _5.filter, 'call', _6 => _6(
|
|
93
|
+
(entry) => typeof entry === "string" && entry.trim().length > 0
|
|
94
|
+
)]) : [];
|
|
95
|
+
if (listExtractorPaths.length > 0) {
|
|
96
|
+
let emptyMatch = null;
|
|
97
|
+
for (const root of candidateRoots(payload)) {
|
|
98
|
+
for (const extractorPath of listExtractorPaths) {
|
|
99
|
+
const resolved = getByDottedPath(root.value, extractorPath);
|
|
100
|
+
const rows = normalizeRows(resolved);
|
|
101
|
+
if (!rows) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const sourcePath = root.path ? `${root.path}.${extractorPath}` : extractorPath;
|
|
105
|
+
if (rows.length > 0) {
|
|
106
|
+
return { rows, strategy: "configured_paths", sourcePath };
|
|
107
|
+
}
|
|
108
|
+
emptyMatch ??= { rows, strategy: "configured_paths", sourcePath };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (emptyMatch) {
|
|
112
|
+
return emptyMatch;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const root of candidateRoots(payload)) {
|
|
116
|
+
const candidate = findBestArrayCandidate(root.value, _nullishCoalesce(root.path, () => ( "")));
|
|
117
|
+
if (!candidate || candidate.rows.length === 0) continue;
|
|
118
|
+
return {
|
|
119
|
+
rows: candidate.rows,
|
|
120
|
+
strategy: "auto_detected",
|
|
121
|
+
sourcePath: candidate.path || root.path
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function projectRowOutput(conversion) {
|
|
127
|
+
return {
|
|
128
|
+
rows: conversion.rows,
|
|
129
|
+
rowCount: conversion.rows.length,
|
|
130
|
+
columns: columnsForRows(conversion.rows),
|
|
131
|
+
previewRows: conversion.rows.slice(0, 5),
|
|
132
|
+
strategy: conversion.strategy,
|
|
133
|
+
sourcePath: conversion.sourcePath
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function ensureOutputDir() {
|
|
137
|
+
const outputDir = _path.join.call(void 0, _os.homedir.call(void 0, ), ".local", "share", "deepline", "data");
|
|
138
|
+
_fs.mkdirSync.call(void 0, outputDir, { recursive: true });
|
|
139
|
+
return outputDir;
|
|
140
|
+
}
|
|
141
|
+
function writeJsonOutputFile(payload, stem) {
|
|
142
|
+
const outputDir = ensureOutputDir();
|
|
143
|
+
const outputPath = _path.join.call(void 0, outputDir, `${stem}_${Date.now()}.json`);
|
|
144
|
+
_fs.writeFileSync.call(void 0, outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
145
|
+
return outputPath;
|
|
146
|
+
}
|
|
147
|
+
function writeCsvOutputFile(rows, stem, options) {
|
|
148
|
+
const outputPath = _optionalChain([options, 'optionalAccess', _7 => _7.outPath]) ? options.outPath : _path.join.call(void 0, ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
149
|
+
_fs.mkdirSync.call(void 0, _path.dirname.call(void 0, outputPath), { recursive: true });
|
|
150
|
+
const columns = columnsForRows(rows);
|
|
151
|
+
const escapeCell = (value) => {
|
|
152
|
+
const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
153
|
+
if (/[",\n]/.test(normalized)) {
|
|
154
|
+
return `"${normalized.replace(/"/g, '""')}"`;
|
|
155
|
+
}
|
|
156
|
+
return normalized;
|
|
157
|
+
};
|
|
158
|
+
const fd = _fs.openSync.call(void 0, outputPath, "w");
|
|
159
|
+
try {
|
|
160
|
+
_fs.writeSync.call(void 0, fd, `${columns.map(escapeCell).join(",")}
|
|
161
|
+
`);
|
|
162
|
+
for (const row of rows) {
|
|
163
|
+
_fs.writeSync.call(void 0,
|
|
164
|
+
fd,
|
|
165
|
+
`${columns.map((column) => escapeCell(row[column])).join(",")}
|
|
166
|
+
`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
} finally {
|
|
170
|
+
_fs.closeSync.call(void 0, fd);
|
|
171
|
+
}
|
|
172
|
+
const previewRows = rows.slice(0, 5);
|
|
173
|
+
const previewColumns = columns.slice(0, 5);
|
|
174
|
+
const preview = [
|
|
175
|
+
previewColumns.join(","),
|
|
176
|
+
...previewRows.map(
|
|
177
|
+
(row) => previewColumns.map((column) => escapeCell(row[column])).join(",")
|
|
178
|
+
)
|
|
179
|
+
].join("\n");
|
|
180
|
+
return {
|
|
181
|
+
path: outputPath,
|
|
182
|
+
rowCount: rows.length,
|
|
183
|
+
columns,
|
|
184
|
+
preview
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function extractSummaryFields(payload) {
|
|
188
|
+
const candidates = candidateRoots(payload);
|
|
189
|
+
for (const candidate of candidates) {
|
|
190
|
+
if (!isPlainObject(candidate.value)) continue;
|
|
191
|
+
const summaryEntries = Object.entries(candidate.value).filter(
|
|
192
|
+
([, value]) => {
|
|
193
|
+
return value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
if (summaryEntries.length === 0) continue;
|
|
197
|
+
return Object.fromEntries(summaryEntries);
|
|
198
|
+
}
|
|
199
|
+
return {};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ../plays/row-identity.ts
|
|
203
|
+
var POSTGRES_IDENTIFIER_MAX_LENGTH = 63;
|
|
204
|
+
var MAP_KEY_NAMESPACE_MAX_LENGTH = POSTGRES_IDENTIFIER_MAX_LENGTH;
|
|
205
|
+
var SHA256_INITIAL_HASH = [
|
|
206
|
+
1779033703,
|
|
207
|
+
3144134277,
|
|
208
|
+
1013904242,
|
|
209
|
+
2773480762,
|
|
210
|
+
1359893119,
|
|
211
|
+
2600822924,
|
|
212
|
+
528734635,
|
|
213
|
+
1541459225
|
|
214
|
+
];
|
|
215
|
+
var SHA256_ROUND_CONSTANTS = [
|
|
216
|
+
1116352408,
|
|
217
|
+
1899447441,
|
|
218
|
+
3049323471,
|
|
219
|
+
3921009573,
|
|
220
|
+
961987163,
|
|
221
|
+
1508970993,
|
|
222
|
+
2453635748,
|
|
223
|
+
2870763221,
|
|
224
|
+
3624381080,
|
|
225
|
+
310598401,
|
|
226
|
+
607225278,
|
|
227
|
+
1426881987,
|
|
228
|
+
1925078388,
|
|
229
|
+
2162078206,
|
|
230
|
+
2614888103,
|
|
231
|
+
3248222580,
|
|
232
|
+
3835390401,
|
|
233
|
+
4022224774,
|
|
234
|
+
264347078,
|
|
235
|
+
604807628,
|
|
236
|
+
770255983,
|
|
237
|
+
1249150122,
|
|
238
|
+
1555081692,
|
|
239
|
+
1996064986,
|
|
240
|
+
2554220882,
|
|
241
|
+
2821834349,
|
|
242
|
+
2952996808,
|
|
243
|
+
3210313671,
|
|
244
|
+
3336571891,
|
|
245
|
+
3584528711,
|
|
246
|
+
113926993,
|
|
247
|
+
338241895,
|
|
248
|
+
666307205,
|
|
249
|
+
773529912,
|
|
250
|
+
1294757372,
|
|
251
|
+
1396182291,
|
|
252
|
+
1695183700,
|
|
253
|
+
1986661051,
|
|
254
|
+
2177026350,
|
|
255
|
+
2456956037,
|
|
256
|
+
2730485921,
|
|
257
|
+
2820302411,
|
|
258
|
+
3259730800,
|
|
259
|
+
3345764771,
|
|
260
|
+
3516065817,
|
|
261
|
+
3600352804,
|
|
262
|
+
4094571909,
|
|
263
|
+
275423344,
|
|
264
|
+
430227734,
|
|
265
|
+
506948616,
|
|
266
|
+
659060556,
|
|
267
|
+
883997877,
|
|
268
|
+
958139571,
|
|
269
|
+
1322822218,
|
|
270
|
+
1537002063,
|
|
271
|
+
1747873779,
|
|
272
|
+
1955562222,
|
|
273
|
+
2024104815,
|
|
274
|
+
2227730452,
|
|
275
|
+
2361852424,
|
|
276
|
+
2428436474,
|
|
277
|
+
2756734187,
|
|
278
|
+
3204031479,
|
|
279
|
+
3329325298
|
|
280
|
+
];
|
|
281
|
+
function stableValue(value) {
|
|
282
|
+
if (Array.isArray(value)) {
|
|
283
|
+
return value.map((entry) => stableValue(entry));
|
|
284
|
+
}
|
|
285
|
+
if (value && typeof value === "object") {
|
|
286
|
+
return Object.fromEntries(
|
|
287
|
+
Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, stableValue(entry)])
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
function stableStringify(value) {
|
|
293
|
+
return JSON.stringify(stableValue(value));
|
|
294
|
+
}
|
|
295
|
+
function rightRotate32(value, bits) {
|
|
296
|
+
return value >>> bits | value << 32 - bits;
|
|
297
|
+
}
|
|
298
|
+
function sha256Hex(input) {
|
|
299
|
+
const bytes = Array.from(new TextEncoder().encode(input));
|
|
300
|
+
const bitLength = bytes.length * 8;
|
|
301
|
+
bytes.push(128);
|
|
302
|
+
while (bytes.length % 64 !== 56) {
|
|
303
|
+
bytes.push(0);
|
|
304
|
+
}
|
|
305
|
+
const highBits = Math.floor(bitLength / 4294967296);
|
|
306
|
+
const lowBits = bitLength >>> 0;
|
|
307
|
+
bytes.push(
|
|
308
|
+
highBits >>> 24 & 255,
|
|
309
|
+
highBits >>> 16 & 255,
|
|
310
|
+
highBits >>> 8 & 255,
|
|
311
|
+
highBits & 255,
|
|
312
|
+
lowBits >>> 24 & 255,
|
|
313
|
+
lowBits >>> 16 & 255,
|
|
314
|
+
lowBits >>> 8 & 255,
|
|
315
|
+
lowBits & 255
|
|
316
|
+
);
|
|
317
|
+
const hash = [...SHA256_INITIAL_HASH];
|
|
318
|
+
const words = new Array(64).fill(0);
|
|
319
|
+
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
320
|
+
for (let index = 0; index < 16; index += 1) {
|
|
321
|
+
const wordOffset = offset + index * 4;
|
|
322
|
+
words[index] = (_nullishCoalesce(bytes[wordOffset], () => ( 0))) << 24 | (_nullishCoalesce(bytes[wordOffset + 1], () => ( 0))) << 16 | (_nullishCoalesce(bytes[wordOffset + 2], () => ( 0))) << 8 | (_nullishCoalesce(bytes[wordOffset + 3], () => ( 0)));
|
|
323
|
+
}
|
|
324
|
+
for (let index = 16; index < 64; index += 1) {
|
|
325
|
+
const s0 = rightRotate32(words[index - 15], 7) ^ rightRotate32(words[index - 15], 18) ^ words[index - 15] >>> 3;
|
|
326
|
+
const s1 = rightRotate32(words[index - 2], 17) ^ rightRotate32(words[index - 2], 19) ^ words[index - 2] >>> 10;
|
|
327
|
+
words[index] = words[index - 16] + s0 + words[index - 7] + s1 >>> 0;
|
|
328
|
+
}
|
|
329
|
+
let [a, b, c, d, e, f, g, h] = hash;
|
|
330
|
+
for (let index = 0; index < 64; index += 1) {
|
|
331
|
+
const s1 = rightRotate32(e, 6) ^ rightRotate32(e, 11) ^ rightRotate32(e, 25);
|
|
332
|
+
const ch = e & f ^ ~e & g;
|
|
333
|
+
const temp1 = h + s1 + ch + SHA256_ROUND_CONSTANTS[index] + words[index] >>> 0;
|
|
334
|
+
const s0 = rightRotate32(a, 2) ^ rightRotate32(a, 13) ^ rightRotate32(a, 22);
|
|
335
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
336
|
+
const temp2 = s0 + maj >>> 0;
|
|
337
|
+
h = g;
|
|
338
|
+
g = f;
|
|
339
|
+
f = e;
|
|
340
|
+
e = d + temp1 >>> 0;
|
|
341
|
+
d = c;
|
|
342
|
+
c = b;
|
|
343
|
+
b = a;
|
|
344
|
+
a = temp1 + temp2 >>> 0;
|
|
345
|
+
}
|
|
346
|
+
hash[0] = hash[0] + a >>> 0;
|
|
347
|
+
hash[1] = hash[1] + b >>> 0;
|
|
348
|
+
hash[2] = hash[2] + c >>> 0;
|
|
349
|
+
hash[3] = hash[3] + d >>> 0;
|
|
350
|
+
hash[4] = hash[4] + e >>> 0;
|
|
351
|
+
hash[5] = hash[5] + f >>> 0;
|
|
352
|
+
hash[6] = hash[6] + g >>> 0;
|
|
353
|
+
hash[7] = hash[7] + h >>> 0;
|
|
354
|
+
}
|
|
355
|
+
return hash.map((word) => word.toString(16).padStart(8, "0")).join("");
|
|
356
|
+
}
|
|
357
|
+
function sanitizeIdentifierPart(value) {
|
|
358
|
+
return value.trim().replace(/[^a-z0-9]+/gi, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toLowerCase();
|
|
359
|
+
}
|
|
360
|
+
function validateIdentifierPart(rawValue, label, maxLength) {
|
|
361
|
+
const sanitized = sanitizeIdentifierPart(rawValue);
|
|
362
|
+
if (!sanitized) {
|
|
363
|
+
throw new Error(`${label} must contain a letter or number.`);
|
|
364
|
+
}
|
|
365
|
+
if (sanitized.length > maxLength) {
|
|
366
|
+
throw new Error(
|
|
367
|
+
`${label} is too long after normalization (${sanitized.length}/${maxLength}): "${sanitized}".`
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
return sanitized;
|
|
371
|
+
}
|
|
372
|
+
function normalizeTableNamespace(value) {
|
|
373
|
+
return validateIdentifierPart(
|
|
374
|
+
value,
|
|
375
|
+
"ctx.dataset() key",
|
|
376
|
+
MAP_KEY_NAMESPACE_MAX_LENGTH
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
exports.stableStringify = stableStringify; exports.sha256Hex = sha256Hex; exports.normalizeTableNamespace = normalizeTableNamespace; exports.tryConvertToList = tryConvertToList; exports.projectRowOutput = projectRowOutput; exports.writeJsonOutputFile = writeJsonOutputFile; exports.writeCsvOutputFile = writeCsvOutputFile; exports.extractSummaryFields = extractSummaryFields;
|