@bayoudhi/moose-lib-serverless 0.2.0 → 0.2.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.
- package/dist/index.d.mts +128 -141
- package/dist/index.d.ts +128 -141
- package/dist/index.js +673 -536
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +673 -536
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -28,7 +28,116 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var require_kafka_javascript = __commonJS({
|
|
29
29
|
"stub-native:@514labs/kafka-javascript"(exports, module) {
|
|
30
30
|
"use strict";
|
|
31
|
-
|
|
31
|
+
function createDeepProxy() {
|
|
32
|
+
var handler = {
|
|
33
|
+
get: function(_, prop) {
|
|
34
|
+
if (prop === "__esModule") return true;
|
|
35
|
+
if (prop === "default") return proxy;
|
|
36
|
+
if (typeof prop === "symbol") return void 0;
|
|
37
|
+
return proxy;
|
|
38
|
+
},
|
|
39
|
+
apply: function() {
|
|
40
|
+
return proxy;
|
|
41
|
+
},
|
|
42
|
+
construct: function() {
|
|
43
|
+
return proxy;
|
|
44
|
+
},
|
|
45
|
+
ownKeys: function() {
|
|
46
|
+
return ["length", "name", "prototype"];
|
|
47
|
+
},
|
|
48
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
49
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
50
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
51
|
+
}
|
|
52
|
+
return void 0;
|
|
53
|
+
},
|
|
54
|
+
getPrototypeOf: function() {
|
|
55
|
+
return proxy;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var proxy = new Proxy(function() {
|
|
59
|
+
}, handler);
|
|
60
|
+
return proxy;
|
|
61
|
+
}
|
|
62
|
+
module.exports = createDeepProxy();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// stub-native:@temporalio/client
|
|
67
|
+
var require_client = __commonJS({
|
|
68
|
+
"stub-native:@temporalio/client"(exports, module) {
|
|
69
|
+
"use strict";
|
|
70
|
+
function createDeepProxy() {
|
|
71
|
+
var handler = {
|
|
72
|
+
get: function(_, prop) {
|
|
73
|
+
if (prop === "__esModule") return true;
|
|
74
|
+
if (prop === "default") return proxy;
|
|
75
|
+
if (typeof prop === "symbol") return void 0;
|
|
76
|
+
return proxy;
|
|
77
|
+
},
|
|
78
|
+
apply: function() {
|
|
79
|
+
return proxy;
|
|
80
|
+
},
|
|
81
|
+
construct: function() {
|
|
82
|
+
return proxy;
|
|
83
|
+
},
|
|
84
|
+
ownKeys: function() {
|
|
85
|
+
return ["length", "name", "prototype"];
|
|
86
|
+
},
|
|
87
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
88
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
89
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
90
|
+
}
|
|
91
|
+
return void 0;
|
|
92
|
+
},
|
|
93
|
+
getPrototypeOf: function() {
|
|
94
|
+
return proxy;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var proxy = new Proxy(function() {
|
|
98
|
+
}, handler);
|
|
99
|
+
return proxy;
|
|
100
|
+
}
|
|
101
|
+
module.exports = createDeepProxy();
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// stub-native:redis
|
|
106
|
+
var require_redis = __commonJS({
|
|
107
|
+
"stub-native:redis"(exports, module) {
|
|
108
|
+
"use strict";
|
|
109
|
+
function createDeepProxy() {
|
|
110
|
+
var handler = {
|
|
111
|
+
get: function(_, prop) {
|
|
112
|
+
if (prop === "__esModule") return true;
|
|
113
|
+
if (prop === "default") return proxy;
|
|
114
|
+
if (typeof prop === "symbol") return void 0;
|
|
115
|
+
return proxy;
|
|
116
|
+
},
|
|
117
|
+
apply: function() {
|
|
118
|
+
return proxy;
|
|
119
|
+
},
|
|
120
|
+
construct: function() {
|
|
121
|
+
return proxy;
|
|
122
|
+
},
|
|
123
|
+
ownKeys: function() {
|
|
124
|
+
return ["length", "name", "prototype"];
|
|
125
|
+
},
|
|
126
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
127
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
128
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
129
|
+
}
|
|
130
|
+
return void 0;
|
|
131
|
+
},
|
|
132
|
+
getPrototypeOf: function() {
|
|
133
|
+
return proxy;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var proxy = new Proxy(function() {
|
|
137
|
+
}, handler);
|
|
138
|
+
return proxy;
|
|
139
|
+
}
|
|
140
|
+
module.exports = createDeepProxy();
|
|
32
141
|
}
|
|
33
142
|
});
|
|
34
143
|
|
|
@@ -36,15 +145,44 @@ var require_kafka_javascript = __commonJS({
|
|
|
36
145
|
var require_confluent_schema_registry = __commonJS({
|
|
37
146
|
"stub-native:@kafkajs/confluent-schema-registry"(exports, module) {
|
|
38
147
|
"use strict";
|
|
39
|
-
|
|
148
|
+
function createDeepProxy() {
|
|
149
|
+
var handler = {
|
|
150
|
+
get: function(_, prop) {
|
|
151
|
+
if (prop === "__esModule") return true;
|
|
152
|
+
if (prop === "default") return proxy;
|
|
153
|
+
if (typeof prop === "symbol") return void 0;
|
|
154
|
+
return proxy;
|
|
155
|
+
},
|
|
156
|
+
apply: function() {
|
|
157
|
+
return proxy;
|
|
158
|
+
},
|
|
159
|
+
construct: function() {
|
|
160
|
+
return proxy;
|
|
161
|
+
},
|
|
162
|
+
ownKeys: function() {
|
|
163
|
+
return ["length", "name", "prototype"];
|
|
164
|
+
},
|
|
165
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
166
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
167
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
168
|
+
}
|
|
169
|
+
return void 0;
|
|
170
|
+
},
|
|
171
|
+
getPrototypeOf: function() {
|
|
172
|
+
return proxy;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
var proxy = new Proxy(function() {
|
|
176
|
+
}, handler);
|
|
177
|
+
return proxy;
|
|
178
|
+
}
|
|
179
|
+
module.exports = createDeepProxy();
|
|
40
180
|
}
|
|
41
181
|
});
|
|
42
182
|
|
|
43
183
|
// ../ts-moose-lib/dist/serverless.mjs
|
|
44
184
|
var import_kafka_javascript = __toESM(require_kafka_javascript(), 1);
|
|
45
|
-
|
|
46
|
-
import * as toml from "toml";
|
|
47
|
-
import { createClient } from "@clickhouse/client";
|
|
185
|
+
var import_client2 = __toESM(require_client(), 1);
|
|
48
186
|
import {
|
|
49
187
|
existsSync,
|
|
50
188
|
readdirSync,
|
|
@@ -52,11 +190,15 @@ import {
|
|
|
52
190
|
writeFileSync
|
|
53
191
|
} from "fs";
|
|
54
192
|
import nodePath from "path";
|
|
193
|
+
import { createClient } from "@clickhouse/client";
|
|
194
|
+
import path from "path";
|
|
195
|
+
import * as toml from "toml";
|
|
55
196
|
import process2 from "process";
|
|
197
|
+
var import_redis = __toESM(require_redis(), 1);
|
|
198
|
+
import { parse as parse2 } from "csv-parse";
|
|
56
199
|
import { Readable } from "stream";
|
|
57
|
-
import { createHash } from "crypto";
|
|
58
200
|
import { createHash as createHash2 } from "crypto";
|
|
59
|
-
import {
|
|
201
|
+
import { createHash as createHash3 } from "crypto";
|
|
60
202
|
var __defProp2 = Object.defineProperty;
|
|
61
203
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
62
204
|
var __esm = (fn, res) => function __init() {
|
|
@@ -66,6 +208,26 @@ var __export = (target, all) => {
|
|
|
66
208
|
for (var name in all)
|
|
67
209
|
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
68
210
|
};
|
|
211
|
+
var commons_exports = {};
|
|
212
|
+
__export(commons_exports, {
|
|
213
|
+
ACKs: () => ACKs,
|
|
214
|
+
MAX_RETRIES: () => MAX_RETRIES,
|
|
215
|
+
MAX_RETRIES_PRODUCER: () => MAX_RETRIES_PRODUCER,
|
|
216
|
+
MAX_RETRY_TIME_MS: () => MAX_RETRY_TIME_MS,
|
|
217
|
+
RETRY_FACTOR_PRODUCER: () => RETRY_FACTOR_PRODUCER,
|
|
218
|
+
RETRY_INITIAL_TIME_MS: () => RETRY_INITIAL_TIME_MS,
|
|
219
|
+
antiCachePath: () => antiCachePath,
|
|
220
|
+
cliLog: () => cliLog,
|
|
221
|
+
compilerLog: () => compilerLog,
|
|
222
|
+
createProducerConfig: () => createProducerConfig,
|
|
223
|
+
getClickhouseClient: () => getClickhouseClient,
|
|
224
|
+
getFileName: () => getFileName,
|
|
225
|
+
getKafkaClient: () => getKafkaClient,
|
|
226
|
+
getKafkaProducer: () => getKafkaProducer,
|
|
227
|
+
logError: () => logError,
|
|
228
|
+
mapTstoJs: () => mapTstoJs,
|
|
229
|
+
rewriteImportExtensions: () => rewriteImportExtensions
|
|
230
|
+
});
|
|
69
231
|
function isTruthy(value) {
|
|
70
232
|
if (!value) return false;
|
|
71
233
|
switch (value.trim().toLowerCase()) {
|
|
@@ -81,9 +243,121 @@ function isTruthy(value) {
|
|
|
81
243
|
function mapTstoJs(filePath) {
|
|
82
244
|
return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
|
|
83
245
|
}
|
|
246
|
+
function walkDirectory(dir, extensions) {
|
|
247
|
+
const results = [];
|
|
248
|
+
if (!existsSync(dir)) {
|
|
249
|
+
return results;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
253
|
+
for (const entry of entries) {
|
|
254
|
+
const fullPath = nodePath.join(dir, entry.name);
|
|
255
|
+
if (entry.isDirectory()) {
|
|
256
|
+
if (entry.name !== "node_modules") {
|
|
257
|
+
results.push(...walkDirectory(fullPath, extensions));
|
|
258
|
+
}
|
|
259
|
+
} else if (entry.isFile()) {
|
|
260
|
+
const ext = nodePath.extname(entry.name);
|
|
261
|
+
if (extensions.includes(ext)) {
|
|
262
|
+
results.push(fullPath);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
console.debug(`[moose] Failed to read directory ${dir}:`, e);
|
|
268
|
+
}
|
|
269
|
+
return results;
|
|
270
|
+
}
|
|
271
|
+
function addJsExtensionToImports(content, fileDir) {
|
|
272
|
+
const fromPattern = /(from\s+['"])(\.\.?\/[^'"]*?)(['"])/g;
|
|
273
|
+
const bareImportPattern = /(import\s+['"])(\.\.?\/[^'"]*?)(['"])/g;
|
|
274
|
+
const dynamicPattern = /(import\s*\(\s*['"])(\.\.?\/[^'"]*?)(['"])/g;
|
|
275
|
+
let result = content;
|
|
276
|
+
result = result.replace(fromPattern, (match, prefix, importPath, quote) => {
|
|
277
|
+
return rewriteImportPath(match, prefix, importPath, quote, fileDir);
|
|
278
|
+
});
|
|
279
|
+
result = result.replace(
|
|
280
|
+
bareImportPattern,
|
|
281
|
+
(match, prefix, importPath, quote) => {
|
|
282
|
+
return rewriteImportPath(match, prefix, importPath, quote, fileDir);
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
result = result.replace(
|
|
286
|
+
dynamicPattern,
|
|
287
|
+
(match, prefix, importPath, quote) => {
|
|
288
|
+
return rewriteImportPath(match, prefix, importPath, quote, fileDir);
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
function rewriteImportPath(match, prefix, importPath, quote, fileDir) {
|
|
294
|
+
if (/\.[cm]?js$/.test(importPath)) {
|
|
295
|
+
return match;
|
|
296
|
+
}
|
|
297
|
+
if (/\.json$/.test(importPath)) {
|
|
298
|
+
return match;
|
|
299
|
+
}
|
|
300
|
+
if (fileDir) {
|
|
301
|
+
const resolvedPath = nodePath.resolve(fileDir, importPath);
|
|
302
|
+
if (existsSync(`${resolvedPath}.js`)) {
|
|
303
|
+
return `${prefix}${importPath}.js${quote}`;
|
|
304
|
+
}
|
|
305
|
+
if (existsSync(nodePath.join(resolvedPath, "index.js"))) {
|
|
306
|
+
return `${prefix}${importPath}/index.js${quote}`;
|
|
307
|
+
}
|
|
308
|
+
if (existsSync(`${resolvedPath}.mjs`)) {
|
|
309
|
+
return `${prefix}${importPath}.mjs${quote}`;
|
|
310
|
+
}
|
|
311
|
+
if (existsSync(nodePath.join(resolvedPath, "index.mjs"))) {
|
|
312
|
+
return `${prefix}${importPath}/index.mjs${quote}`;
|
|
313
|
+
}
|
|
314
|
+
if (existsSync(`${resolvedPath}.cjs`)) {
|
|
315
|
+
return `${prefix}${importPath}.cjs${quote}`;
|
|
316
|
+
}
|
|
317
|
+
if (existsSync(nodePath.join(resolvedPath, "index.cjs"))) {
|
|
318
|
+
return `${prefix}${importPath}/index.cjs${quote}`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return `${prefix}${importPath}.js${quote}`;
|
|
322
|
+
}
|
|
323
|
+
function rewriteImportExtensions(outDir) {
|
|
324
|
+
const files = walkDirectory(outDir, [".js", ".mjs"]);
|
|
325
|
+
for (const filePath of files) {
|
|
326
|
+
const content = readFileSync(filePath, "utf-8");
|
|
327
|
+
const fileDir = nodePath.dirname(filePath);
|
|
328
|
+
const rewritten = addJsExtensionToImports(content, fileDir);
|
|
329
|
+
if (content !== rewritten) {
|
|
330
|
+
writeFileSync(filePath, rewritten, "utf-8");
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function createProducerConfig(maxMessageBytes) {
|
|
335
|
+
return {
|
|
336
|
+
kafkaJS: {
|
|
337
|
+
idempotent: false,
|
|
338
|
+
// Not needed for at-least-once delivery
|
|
339
|
+
acks: ACKs,
|
|
340
|
+
retry: {
|
|
341
|
+
retries: MAX_RETRIES_PRODUCER,
|
|
342
|
+
maxRetryTime: MAX_RETRY_TIME_MS
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
"linger.ms": 0,
|
|
346
|
+
// This is to make sure at least once delivery with immediate feedback on the send
|
|
347
|
+
...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
async function getKafkaProducer(cfg, logger, maxMessageBytes) {
|
|
351
|
+
const kafka = await getKafkaClient(cfg, logger);
|
|
352
|
+
const producer = kafka.producer(createProducerConfig(maxMessageBytes));
|
|
353
|
+
await producer.connect();
|
|
354
|
+
return producer;
|
|
355
|
+
}
|
|
356
|
+
var Kafka;
|
|
84
357
|
var compilerLog;
|
|
85
358
|
var antiCachePath;
|
|
86
359
|
var getFileName;
|
|
360
|
+
var getClickhouseClient;
|
|
87
361
|
var cliLog;
|
|
88
362
|
var MAX_RETRIES;
|
|
89
363
|
var MAX_RETRY_TIME_MS;
|
|
@@ -91,10 +365,14 @@ var RETRY_INITIAL_TIME_MS;
|
|
|
91
365
|
var MAX_RETRIES_PRODUCER;
|
|
92
366
|
var RETRY_FACTOR_PRODUCER;
|
|
93
367
|
var ACKs;
|
|
368
|
+
var parseBrokerString;
|
|
94
369
|
var logError;
|
|
95
|
-
var
|
|
96
|
-
|
|
370
|
+
var buildSaslConfig;
|
|
371
|
+
var getKafkaClient;
|
|
372
|
+
var init_commons = __esm({
|
|
373
|
+
"src/commons.ts"() {
|
|
97
374
|
"use strict";
|
|
375
|
+
({ Kafka } = import_kafka_javascript.KafkaJS);
|
|
98
376
|
compilerLog = (message) => {
|
|
99
377
|
if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
|
|
100
378
|
console.log(message);
|
|
@@ -102,13 +380,33 @@ var init_commons_types = __esm({
|
|
|
102
380
|
};
|
|
103
381
|
antiCachePath = (path2) => `${path2}?num=${Math.random().toString()}&time=${Date.now()}`;
|
|
104
382
|
getFileName = (filePath) => {
|
|
105
|
-
const regex = /\/([
|
|
383
|
+
const regex = /\/([^\/]+)\.ts/;
|
|
106
384
|
const matches = filePath.match(regex);
|
|
107
385
|
if (matches && matches.length > 1) {
|
|
108
386
|
return matches[1];
|
|
109
387
|
}
|
|
110
388
|
return "";
|
|
111
389
|
};
|
|
390
|
+
getClickhouseClient = ({
|
|
391
|
+
username,
|
|
392
|
+
password,
|
|
393
|
+
database,
|
|
394
|
+
useSSL,
|
|
395
|
+
host,
|
|
396
|
+
port
|
|
397
|
+
}) => {
|
|
398
|
+
const protocol = useSSL === "1" || useSSL.toLowerCase() === "true" ? "https" : "http";
|
|
399
|
+
console.log(`Connecting to Clickhouse at ${protocol}://${host}:${port}`);
|
|
400
|
+
return createClient({
|
|
401
|
+
url: `${protocol}://${host}:${port}`,
|
|
402
|
+
username,
|
|
403
|
+
password,
|
|
404
|
+
database,
|
|
405
|
+
application: "moose"
|
|
406
|
+
// Note: wait_end_of_query is configured per operation type, not globally
|
|
407
|
+
// to preserve SELECT query performance while ensuring INSERT/DDL reliability
|
|
408
|
+
});
|
|
409
|
+
};
|
|
112
410
|
cliLog = (log) => {
|
|
113
411
|
const level = log.message_type === "Error" ? "error" : log.message_type === "Warning" ? "warn" : "info";
|
|
114
412
|
const structuredLog = {
|
|
@@ -128,6 +426,7 @@ var init_commons_types = __esm({
|
|
|
128
426
|
MAX_RETRIES_PRODUCER = 150;
|
|
129
427
|
RETRY_FACTOR_PRODUCER = 0.2;
|
|
130
428
|
ACKs = -1;
|
|
429
|
+
parseBrokerString = (brokerString) => brokerString.split(",").map((b) => b.trim()).filter((b) => b.length > 0);
|
|
131
430
|
logError = (logger, e) => {
|
|
132
431
|
logger.error(e.message);
|
|
133
432
|
const stack = e.stack;
|
|
@@ -135,6 +434,45 @@ var init_commons_types = __esm({
|
|
|
135
434
|
logger.error(stack);
|
|
136
435
|
}
|
|
137
436
|
};
|
|
437
|
+
buildSaslConfig = (logger, args) => {
|
|
438
|
+
const mechanism = args.saslMechanism ? args.saslMechanism.toLowerCase() : "";
|
|
439
|
+
switch (mechanism) {
|
|
440
|
+
case "plain":
|
|
441
|
+
case "scram-sha-256":
|
|
442
|
+
case "scram-sha-512":
|
|
443
|
+
return {
|
|
444
|
+
mechanism,
|
|
445
|
+
username: args.saslUsername || "",
|
|
446
|
+
password: args.saslPassword || ""
|
|
447
|
+
};
|
|
448
|
+
default:
|
|
449
|
+
logger.warn(`Unsupported SASL mechanism: ${args.saslMechanism}`);
|
|
450
|
+
return void 0;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
getKafkaClient = async (cfg, logger) => {
|
|
454
|
+
const brokers = parseBrokerString(cfg.broker || "");
|
|
455
|
+
if (brokers.length === 0) {
|
|
456
|
+
throw new Error(`No valid broker addresses found in: "${cfg.broker}"`);
|
|
457
|
+
}
|
|
458
|
+
logger.log(`Creating Kafka client with brokers: ${brokers.join(", ")}`);
|
|
459
|
+
logger.log(`Security protocol: ${cfg.securityProtocol || "plaintext"}`);
|
|
460
|
+
logger.log(`Client ID: ${cfg.clientId}`);
|
|
461
|
+
const saslConfig = buildSaslConfig(logger, cfg);
|
|
462
|
+
return new Kafka({
|
|
463
|
+
kafkaJS: {
|
|
464
|
+
clientId: cfg.clientId,
|
|
465
|
+
brokers,
|
|
466
|
+
ssl: cfg.securityProtocol === "SASL_SSL",
|
|
467
|
+
...saslConfig && { sasl: saslConfig },
|
|
468
|
+
retry: {
|
|
469
|
+
initialRetryTime: RETRY_INITIAL_TIME_MS,
|
|
470
|
+
maxRetryTime: MAX_RETRY_TIME_MS,
|
|
471
|
+
retries: MAX_RETRIES
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
};
|
|
138
476
|
}
|
|
139
477
|
});
|
|
140
478
|
async function findConfigFile(startDir = process.cwd()) {
|
|
@@ -315,231 +653,6 @@ var init_runtime = __esm({
|
|
|
315
653
|
globalThis._mooseConfigRegistry = ConfigurationRegistry.getInstance();
|
|
316
654
|
}
|
|
317
655
|
});
|
|
318
|
-
var commons_exports = {};
|
|
319
|
-
__export(commons_exports, {
|
|
320
|
-
ACKs: () => ACKs,
|
|
321
|
-
MAX_RETRIES: () => MAX_RETRIES,
|
|
322
|
-
MAX_RETRIES_PRODUCER: () => MAX_RETRIES_PRODUCER,
|
|
323
|
-
MAX_RETRY_TIME_MS: () => MAX_RETRY_TIME_MS,
|
|
324
|
-
RETRY_FACTOR_PRODUCER: () => RETRY_FACTOR_PRODUCER,
|
|
325
|
-
RETRY_INITIAL_TIME_MS: () => RETRY_INITIAL_TIME_MS,
|
|
326
|
-
antiCachePath: () => antiCachePath,
|
|
327
|
-
cliLog: () => cliLog,
|
|
328
|
-
compilerLog: () => compilerLog,
|
|
329
|
-
createProducerConfig: () => createProducerConfig,
|
|
330
|
-
getClickhouseClient: () => getClickhouseClient,
|
|
331
|
-
getFileName: () => getFileName,
|
|
332
|
-
getKafkaClient: () => getKafkaClient,
|
|
333
|
-
getKafkaProducer: () => getKafkaProducer,
|
|
334
|
-
logError: () => logError,
|
|
335
|
-
mapTstoJs: () => mapTstoJs,
|
|
336
|
-
rewriteImportExtensions: () => rewriteImportExtensions
|
|
337
|
-
});
|
|
338
|
-
function walkDirectory(dir, extensions) {
|
|
339
|
-
const results = [];
|
|
340
|
-
if (!existsSync(dir)) {
|
|
341
|
-
return results;
|
|
342
|
-
}
|
|
343
|
-
try {
|
|
344
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
345
|
-
for (const entry of entries) {
|
|
346
|
-
const fullPath = nodePath.join(dir, entry.name);
|
|
347
|
-
if (entry.isDirectory()) {
|
|
348
|
-
if (entry.name !== "node_modules") {
|
|
349
|
-
results.push(...walkDirectory(fullPath, extensions));
|
|
350
|
-
}
|
|
351
|
-
} else if (entry.isFile()) {
|
|
352
|
-
const ext = nodePath.extname(entry.name);
|
|
353
|
-
if (extensions.includes(ext)) {
|
|
354
|
-
results.push(fullPath);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
} catch (e) {
|
|
359
|
-
console.debug(`[moose] Failed to read directory ${dir}:`, e);
|
|
360
|
-
}
|
|
361
|
-
return results;
|
|
362
|
-
}
|
|
363
|
-
function addJsExtensionToImports(content, fileDir) {
|
|
364
|
-
const fromPattern = /(from\s+['"])(\.\.?\/[^'"]*?)(['"])/g;
|
|
365
|
-
const bareImportPattern = /(import\s+['"])(\.\.?\/[^'"]*?)(['"])/g;
|
|
366
|
-
const dynamicPattern = /(import\s*\(\s*['"])(\.\.?\/[^'"]*?)(['"])/g;
|
|
367
|
-
let result = content;
|
|
368
|
-
result = result.replace(fromPattern, (match, prefix, importPath, quote) => {
|
|
369
|
-
return rewriteImportPath(match, prefix, importPath, quote, fileDir);
|
|
370
|
-
});
|
|
371
|
-
result = result.replace(
|
|
372
|
-
bareImportPattern,
|
|
373
|
-
(match, prefix, importPath, quote) => {
|
|
374
|
-
return rewriteImportPath(match, prefix, importPath, quote, fileDir);
|
|
375
|
-
}
|
|
376
|
-
);
|
|
377
|
-
result = result.replace(
|
|
378
|
-
dynamicPattern,
|
|
379
|
-
(match, prefix, importPath, quote) => {
|
|
380
|
-
return rewriteImportPath(match, prefix, importPath, quote, fileDir);
|
|
381
|
-
}
|
|
382
|
-
);
|
|
383
|
-
return result;
|
|
384
|
-
}
|
|
385
|
-
function rewriteImportPath(match, prefix, importPath, quote, fileDir) {
|
|
386
|
-
if (/\.[cm]?js$/.test(importPath)) {
|
|
387
|
-
return match;
|
|
388
|
-
}
|
|
389
|
-
if (/\.json$/.test(importPath)) {
|
|
390
|
-
return match;
|
|
391
|
-
}
|
|
392
|
-
if (fileDir) {
|
|
393
|
-
const resolvedPath = nodePath.resolve(fileDir, importPath);
|
|
394
|
-
if (existsSync(`${resolvedPath}.js`)) {
|
|
395
|
-
return `${prefix}${importPath}.js${quote}`;
|
|
396
|
-
}
|
|
397
|
-
if (existsSync(nodePath.join(resolvedPath, "index.js"))) {
|
|
398
|
-
return `${prefix}${importPath}/index.js${quote}`;
|
|
399
|
-
}
|
|
400
|
-
if (existsSync(`${resolvedPath}.mjs`)) {
|
|
401
|
-
return `${prefix}${importPath}.mjs${quote}`;
|
|
402
|
-
}
|
|
403
|
-
if (existsSync(nodePath.join(resolvedPath, "index.mjs"))) {
|
|
404
|
-
return `${prefix}${importPath}/index.mjs${quote}`;
|
|
405
|
-
}
|
|
406
|
-
if (existsSync(`${resolvedPath}.cjs`)) {
|
|
407
|
-
return `${prefix}${importPath}.cjs${quote}`;
|
|
408
|
-
}
|
|
409
|
-
if (existsSync(nodePath.join(resolvedPath, "index.cjs"))) {
|
|
410
|
-
return `${prefix}${importPath}/index.cjs${quote}`;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return `${prefix}${importPath}.js${quote}`;
|
|
414
|
-
}
|
|
415
|
-
function rewriteImportExtensions(outDir) {
|
|
416
|
-
const files = walkDirectory(outDir, [".js", ".mjs"]);
|
|
417
|
-
for (const filePath of files) {
|
|
418
|
-
const content = readFileSync(filePath, "utf-8");
|
|
419
|
-
const fileDir = nodePath.dirname(filePath);
|
|
420
|
-
const rewritten = addJsExtensionToImports(content, fileDir);
|
|
421
|
-
if (content !== rewritten) {
|
|
422
|
-
writeFileSync(filePath, rewritten, "utf-8");
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
function createProducerConfig(maxMessageBytes) {
|
|
427
|
-
return {
|
|
428
|
-
kafkaJS: {
|
|
429
|
-
idempotent: false,
|
|
430
|
-
// Not needed for at-least-once delivery
|
|
431
|
-
acks: ACKs,
|
|
432
|
-
retry: {
|
|
433
|
-
retries: MAX_RETRIES_PRODUCER,
|
|
434
|
-
maxRetryTime: MAX_RETRY_TIME_MS
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
"linger.ms": 0,
|
|
438
|
-
// This is to make sure at least once delivery with immediate feedback on the send
|
|
439
|
-
...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
async function getKafkaProducer(cfg, logger, maxMessageBytes) {
|
|
443
|
-
const kafka = await getKafkaClient(cfg, logger);
|
|
444
|
-
const producer = kafka.producer(createProducerConfig(maxMessageBytes));
|
|
445
|
-
await producer.connect();
|
|
446
|
-
return producer;
|
|
447
|
-
}
|
|
448
|
-
var Kafka;
|
|
449
|
-
var getClickhouseClient;
|
|
450
|
-
var parseBrokerString;
|
|
451
|
-
var buildSaslConfig;
|
|
452
|
-
var getKafkaClient;
|
|
453
|
-
var init_commons = __esm({
|
|
454
|
-
"src/commons.ts"() {
|
|
455
|
-
"use strict";
|
|
456
|
-
init_commons_types();
|
|
457
|
-
init_commons_types();
|
|
458
|
-
({ Kafka } = import_kafka_javascript.KafkaJS);
|
|
459
|
-
getClickhouseClient = ({
|
|
460
|
-
username,
|
|
461
|
-
password,
|
|
462
|
-
database,
|
|
463
|
-
useSSL,
|
|
464
|
-
host,
|
|
465
|
-
port
|
|
466
|
-
}) => {
|
|
467
|
-
const protocol = useSSL === "1" || useSSL.toLowerCase() === "true" ? "https" : "http";
|
|
468
|
-
console.log(`Connecting to Clickhouse at ${protocol}://${host}:${port}`);
|
|
469
|
-
return createClient({
|
|
470
|
-
url: `${protocol}://${host}:${port}`,
|
|
471
|
-
username,
|
|
472
|
-
password,
|
|
473
|
-
database,
|
|
474
|
-
application: "moose"
|
|
475
|
-
// Note: wait_end_of_query is configured per operation type, not globally
|
|
476
|
-
// to preserve SELECT query performance while ensuring INSERT/DDL reliability
|
|
477
|
-
});
|
|
478
|
-
};
|
|
479
|
-
parseBrokerString = (brokerString) => brokerString.split(",").map((b) => b.trim()).filter((b) => b.length > 0);
|
|
480
|
-
buildSaslConfig = (logger, args) => {
|
|
481
|
-
const mechanism = args.saslMechanism ? args.saslMechanism.toLowerCase() : "";
|
|
482
|
-
switch (mechanism) {
|
|
483
|
-
case "plain":
|
|
484
|
-
case "scram-sha-256":
|
|
485
|
-
case "scram-sha-512":
|
|
486
|
-
return {
|
|
487
|
-
mechanism,
|
|
488
|
-
username: args.saslUsername || "",
|
|
489
|
-
password: args.saslPassword || ""
|
|
490
|
-
};
|
|
491
|
-
default:
|
|
492
|
-
logger.warn(`Unsupported SASL mechanism: ${args.saslMechanism}`);
|
|
493
|
-
return void 0;
|
|
494
|
-
}
|
|
495
|
-
};
|
|
496
|
-
getKafkaClient = async (cfg, logger) => {
|
|
497
|
-
const brokers = parseBrokerString(cfg.broker || "");
|
|
498
|
-
if (brokers.length === 0) {
|
|
499
|
-
throw new Error(`No valid broker addresses found in: "${cfg.broker}"`);
|
|
500
|
-
}
|
|
501
|
-
logger.log(`Creating Kafka client with brokers: ${brokers.join(", ")}`);
|
|
502
|
-
logger.log(`Security protocol: ${cfg.securityProtocol || "plaintext"}`);
|
|
503
|
-
logger.log(`Client ID: ${cfg.clientId}`);
|
|
504
|
-
const saslConfig = buildSaslConfig(logger, cfg);
|
|
505
|
-
return new Kafka({
|
|
506
|
-
kafkaJS: {
|
|
507
|
-
clientId: cfg.clientId,
|
|
508
|
-
brokers,
|
|
509
|
-
ssl: cfg.securityProtocol === "SASL_SSL",
|
|
510
|
-
...saslConfig && { sasl: saslConfig },
|
|
511
|
-
retry: {
|
|
512
|
-
initialRetryTime: RETRY_INITIAL_TIME_MS,
|
|
513
|
-
maxRetryTime: MAX_RETRY_TIME_MS,
|
|
514
|
-
retries: MAX_RETRIES
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
});
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
|
|
522
|
-
ClickHouseEngines2["MergeTree"] = "MergeTree";
|
|
523
|
-
ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
|
|
524
|
-
ClickHouseEngines2["SummingMergeTree"] = "SummingMergeTree";
|
|
525
|
-
ClickHouseEngines2["AggregatingMergeTree"] = "AggregatingMergeTree";
|
|
526
|
-
ClickHouseEngines2["CollapsingMergeTree"] = "CollapsingMergeTree";
|
|
527
|
-
ClickHouseEngines2["VersionedCollapsingMergeTree"] = "VersionedCollapsingMergeTree";
|
|
528
|
-
ClickHouseEngines2["GraphiteMergeTree"] = "GraphiteMergeTree";
|
|
529
|
-
ClickHouseEngines2["S3Queue"] = "S3Queue";
|
|
530
|
-
ClickHouseEngines2["S3"] = "S3";
|
|
531
|
-
ClickHouseEngines2["Buffer"] = "Buffer";
|
|
532
|
-
ClickHouseEngines2["Distributed"] = "Distributed";
|
|
533
|
-
ClickHouseEngines2["IcebergS3"] = "IcebergS3";
|
|
534
|
-
ClickHouseEngines2["Kafka"] = "Kafka";
|
|
535
|
-
ClickHouseEngines2["ReplicatedMergeTree"] = "ReplicatedMergeTree";
|
|
536
|
-
ClickHouseEngines2["ReplicatedReplacingMergeTree"] = "ReplicatedReplacingMergeTree";
|
|
537
|
-
ClickHouseEngines2["ReplicatedAggregatingMergeTree"] = "ReplicatedAggregatingMergeTree";
|
|
538
|
-
ClickHouseEngines2["ReplicatedSummingMergeTree"] = "ReplicatedSummingMergeTree";
|
|
539
|
-
ClickHouseEngines2["ReplicatedCollapsingMergeTree"] = "ReplicatedCollapsingMergeTree";
|
|
540
|
-
ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
|
|
541
|
-
return ClickHouseEngines2;
|
|
542
|
-
})(ClickHouseEngines || {});
|
|
543
656
|
function shouldSkipStackLine(line) {
|
|
544
657
|
return line.includes("node_modules") || // Skip npm installed packages (prod)
|
|
545
658
|
line.includes("node:internal") || // Skip Node.js internals (modern format)
|
|
@@ -664,148 +777,73 @@ function isArrayNestedType(dt) {
|
|
|
664
777
|
function isNestedType(dt) {
|
|
665
778
|
return typeof dt === "object" && dt !== null && Array.isArray(dt.columns);
|
|
666
779
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
},
|
|
719
|
-
required: [
|
|
720
|
-
"originalRecord",
|
|
721
|
-
"errorMessage",
|
|
722
|
-
"errorType",
|
|
723
|
-
"failedAt",
|
|
724
|
-
"source"
|
|
725
|
-
]
|
|
726
|
-
},
|
|
727
|
-
Recordstringany: {
|
|
728
|
-
type: "object",
|
|
729
|
-
properties: {},
|
|
730
|
-
required: [],
|
|
731
|
-
description: "Construct a type with a set of properties K of type T",
|
|
732
|
-
additionalProperties: {}
|
|
733
|
-
}
|
|
780
|
+
var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
|
|
781
|
+
ClickHouseEngines2["MergeTree"] = "MergeTree";
|
|
782
|
+
ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
|
|
783
|
+
ClickHouseEngines2["SummingMergeTree"] = "SummingMergeTree";
|
|
784
|
+
ClickHouseEngines2["AggregatingMergeTree"] = "AggregatingMergeTree";
|
|
785
|
+
ClickHouseEngines2["CollapsingMergeTree"] = "CollapsingMergeTree";
|
|
786
|
+
ClickHouseEngines2["VersionedCollapsingMergeTree"] = "VersionedCollapsingMergeTree";
|
|
787
|
+
ClickHouseEngines2["GraphiteMergeTree"] = "GraphiteMergeTree";
|
|
788
|
+
ClickHouseEngines2["S3Queue"] = "S3Queue";
|
|
789
|
+
ClickHouseEngines2["S3"] = "S3";
|
|
790
|
+
ClickHouseEngines2["Buffer"] = "Buffer";
|
|
791
|
+
ClickHouseEngines2["Distributed"] = "Distributed";
|
|
792
|
+
ClickHouseEngines2["IcebergS3"] = "IcebergS3";
|
|
793
|
+
ClickHouseEngines2["Kafka"] = "Kafka";
|
|
794
|
+
ClickHouseEngines2["ReplicatedMergeTree"] = "ReplicatedMergeTree";
|
|
795
|
+
ClickHouseEngines2["ReplicatedReplacingMergeTree"] = "ReplicatedReplacingMergeTree";
|
|
796
|
+
ClickHouseEngines2["ReplicatedAggregatingMergeTree"] = "ReplicatedAggregatingMergeTree";
|
|
797
|
+
ClickHouseEngines2["ReplicatedSummingMergeTree"] = "ReplicatedSummingMergeTree";
|
|
798
|
+
ClickHouseEngines2["ReplicatedCollapsingMergeTree"] = "ReplicatedCollapsingMergeTree";
|
|
799
|
+
ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
|
|
800
|
+
return ClickHouseEngines2;
|
|
801
|
+
})(ClickHouseEngines || {});
|
|
802
|
+
init_commons();
|
|
803
|
+
var MOOSE_RUNTIME_ENV_PREFIX = "__MOOSE_RUNTIME_ENV__:";
|
|
804
|
+
var mooseRuntimeEnv = {
|
|
805
|
+
/**
|
|
806
|
+
* Gets a value from an environment variable, with behavior depending on context.
|
|
807
|
+
*
|
|
808
|
+
* When IS_LOADING_INFRA_MAP=true (infrastructure loading):
|
|
809
|
+
* Returns a marker string that Moose CLI will resolve later
|
|
810
|
+
*
|
|
811
|
+
* When IS_LOADING_INFRA_MAP is unset (function/workflow runtime):
|
|
812
|
+
* Returns the actual value from the environment variable
|
|
813
|
+
*
|
|
814
|
+
* @param envVarName - Name of the environment variable to resolve
|
|
815
|
+
* @returns Either a marker string or the actual environment variable value
|
|
816
|
+
* @throws {Error} If the environment variable name is empty
|
|
817
|
+
* @throws {Error} If the environment variable is not set (runtime mode only)
|
|
818
|
+
*
|
|
819
|
+
* @example
|
|
820
|
+
* ```typescript
|
|
821
|
+
* // Instead of this (evaluated at build time):
|
|
822
|
+
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID
|
|
823
|
+
*
|
|
824
|
+
* // Use this (evaluated at runtime):
|
|
825
|
+
* awsAccessKeyId: mooseRuntimeEnv.get("AWS_ACCESS_KEY_ID")
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
828
|
+
get(envVarName) {
|
|
829
|
+
if (!envVarName || envVarName.trim() === "") {
|
|
830
|
+
throw new Error("Environment variable name cannot be empty");
|
|
734
831
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
832
|
+
const isLoadingInfraMap = process.env.IS_LOADING_INFRA_MAP === "true";
|
|
833
|
+
if (isLoadingInfraMap) {
|
|
834
|
+
return `${MOOSE_RUNTIME_ENV_PREFIX}${envVarName}`;
|
|
835
|
+
} else {
|
|
836
|
+
const value = process.env[envVarName];
|
|
837
|
+
if (value === void 0) {
|
|
838
|
+
throw new Error(
|
|
839
|
+
`Environment variable '${envVarName}' is not set. This is required for runtime execution of functions/workflows.`
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
return value;
|
|
739
843
|
}
|
|
740
|
-
]
|
|
741
|
-
};
|
|
742
|
-
var dlqColumns = [
|
|
743
|
-
{
|
|
744
|
-
name: "originalRecord",
|
|
745
|
-
data_type: "Json",
|
|
746
|
-
primary_key: false,
|
|
747
|
-
required: true,
|
|
748
|
-
unique: false,
|
|
749
|
-
default: null,
|
|
750
|
-
annotations: [],
|
|
751
|
-
ttl: null,
|
|
752
|
-
codec: null,
|
|
753
|
-
materialized: null,
|
|
754
|
-
comment: null
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
name: "errorMessage",
|
|
758
|
-
data_type: "String",
|
|
759
|
-
primary_key: false,
|
|
760
|
-
required: true,
|
|
761
|
-
unique: false,
|
|
762
|
-
default: null,
|
|
763
|
-
annotations: [],
|
|
764
|
-
ttl: null,
|
|
765
|
-
codec: null,
|
|
766
|
-
materialized: null,
|
|
767
|
-
comment: null
|
|
768
|
-
},
|
|
769
|
-
{
|
|
770
|
-
name: "errorType",
|
|
771
|
-
data_type: "String",
|
|
772
|
-
primary_key: false,
|
|
773
|
-
required: true,
|
|
774
|
-
unique: false,
|
|
775
|
-
default: null,
|
|
776
|
-
annotations: [],
|
|
777
|
-
ttl: null,
|
|
778
|
-
codec: null,
|
|
779
|
-
materialized: null,
|
|
780
|
-
comment: null
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
name: "failedAt",
|
|
784
|
-
data_type: "DateTime",
|
|
785
|
-
primary_key: false,
|
|
786
|
-
required: true,
|
|
787
|
-
unique: false,
|
|
788
|
-
default: null,
|
|
789
|
-
annotations: [],
|
|
790
|
-
ttl: null,
|
|
791
|
-
codec: null,
|
|
792
|
-
materialized: null,
|
|
793
|
-
comment: null
|
|
794
|
-
},
|
|
795
|
-
{
|
|
796
|
-
name: "source",
|
|
797
|
-
data_type: "String",
|
|
798
|
-
primary_key: false,
|
|
799
|
-
required: true,
|
|
800
|
-
unique: false,
|
|
801
|
-
default: null,
|
|
802
|
-
annotations: [],
|
|
803
|
-
ttl: null,
|
|
804
|
-
codec: null,
|
|
805
|
-
materialized: null,
|
|
806
|
-
comment: null
|
|
807
844
|
}
|
|
808
|
-
|
|
845
|
+
};
|
|
846
|
+
var mooseEnvSecrets = mooseRuntimeEnv;
|
|
809
847
|
var quoteIdentifier = (name) => {
|
|
810
848
|
return name.startsWith("`") && name.endsWith("`") ? name : `\`${name}\``;
|
|
811
849
|
};
|
|
@@ -892,8 +930,8 @@ sql.join = function(fragments, separator) {
|
|
|
892
930
|
sql.raw = function(text) {
|
|
893
931
|
return new Sql([text], []);
|
|
894
932
|
};
|
|
895
|
-
var toStaticQuery = (
|
|
896
|
-
const [query, params] = toQuery(
|
|
933
|
+
var toStaticQuery = (sql3) => {
|
|
934
|
+
const [query, params] = toQuery(sql3);
|
|
897
935
|
if (Object.keys(params).length !== 0) {
|
|
898
936
|
throw new Error(
|
|
899
937
|
"Dynamic SQL is not allowed in the select statement in view creation."
|
|
@@ -901,14 +939,14 @@ var toStaticQuery = (sql2) => {
|
|
|
901
939
|
}
|
|
902
940
|
return query;
|
|
903
941
|
};
|
|
904
|
-
var toQuery = (
|
|
905
|
-
const parameterizedStubs =
|
|
942
|
+
var toQuery = (sql3) => {
|
|
943
|
+
const parameterizedStubs = sql3.values.map(
|
|
906
944
|
(v, i) => createClickhouseParameter(i, v)
|
|
907
945
|
);
|
|
908
|
-
const query =
|
|
946
|
+
const query = sql3.strings.map(
|
|
909
947
|
(s, i) => s != "" ? `${s}${emptyIfUndefined(parameterizedStubs[i])}` : ""
|
|
910
948
|
).join("");
|
|
911
|
-
const query_params =
|
|
949
|
+
const query_params = sql3.values.reduce(
|
|
912
950
|
(acc, v, i) => ({
|
|
913
951
|
...acc,
|
|
914
952
|
[`p${i}`]: getValueFromParameter(v)
|
|
@@ -917,7 +955,7 @@ var toQuery = (sql2) => {
|
|
|
917
955
|
);
|
|
918
956
|
return [query, query_params];
|
|
919
957
|
};
|
|
920
|
-
var toQueryPreview = (
|
|
958
|
+
var toQueryPreview = (sql3) => {
|
|
921
959
|
try {
|
|
922
960
|
const formatValue = (v) => {
|
|
923
961
|
if (Array.isArray(v)) {
|
|
@@ -938,44 +976,254 @@ var toQueryPreview = (sql2) => {
|
|
|
938
976
|
} catch {
|
|
939
977
|
return String(v);
|
|
940
978
|
}
|
|
941
|
-
};
|
|
942
|
-
let out =
|
|
943
|
-
for (let i = 0; i <
|
|
944
|
-
const val = getValueFromParameter(
|
|
945
|
-
out += formatValue(val);
|
|
946
|
-
out +=
|
|
979
|
+
};
|
|
980
|
+
let out = sql3.strings[0] ?? "";
|
|
981
|
+
for (let i = 0; i < sql3.values.length; i++) {
|
|
982
|
+
const val = getValueFromParameter(sql3.values[i]);
|
|
983
|
+
out += formatValue(val);
|
|
984
|
+
out += sql3.strings[i + 1] ?? "";
|
|
985
|
+
}
|
|
986
|
+
return out.replace(/\s+/g, " ").trim();
|
|
987
|
+
} catch (error) {
|
|
988
|
+
console.log(`toQueryPreview error: ${error}`);
|
|
989
|
+
return "/* query preview unavailable */";
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
var getValueFromParameter = (value) => {
|
|
993
|
+
if (Array.isArray(value)) {
|
|
994
|
+
const [type, val] = value;
|
|
995
|
+
if (type === "Identifier") return val;
|
|
996
|
+
}
|
|
997
|
+
return value;
|
|
998
|
+
};
|
|
999
|
+
function createClickhouseParameter(parameterIndex, value) {
|
|
1000
|
+
return `{p${parameterIndex}:${mapToClickHouseType(value)}}`;
|
|
1001
|
+
}
|
|
1002
|
+
var mapToClickHouseType = (value) => {
|
|
1003
|
+
if (typeof value === "number") {
|
|
1004
|
+
return Number.isInteger(value) ? "Int" : "Float";
|
|
1005
|
+
}
|
|
1006
|
+
if (typeof value === "boolean") return "Bool";
|
|
1007
|
+
if (value instanceof Date) return "DateTime";
|
|
1008
|
+
if (Array.isArray(value)) {
|
|
1009
|
+
const [type, _] = value;
|
|
1010
|
+
return type;
|
|
1011
|
+
}
|
|
1012
|
+
return "String";
|
|
1013
|
+
};
|
|
1014
|
+
function emptyIfUndefined(value) {
|
|
1015
|
+
return value === void 0 ? "" : value;
|
|
1016
|
+
}
|
|
1017
|
+
init_commons();
|
|
1018
|
+
function jsonDateReviver(key, value) {
|
|
1019
|
+
const iso8601Format = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)$/;
|
|
1020
|
+
if (typeof value === "string" && iso8601Format.test(value)) {
|
|
1021
|
+
return new Date(value);
|
|
1022
|
+
}
|
|
1023
|
+
return value;
|
|
1024
|
+
}
|
|
1025
|
+
function parseCSV(content, config) {
|
|
1026
|
+
return new Promise((resolve, reject) => {
|
|
1027
|
+
const results = [];
|
|
1028
|
+
parse2(content, {
|
|
1029
|
+
delimiter: config.delimiter,
|
|
1030
|
+
columns: config.columns ?? true,
|
|
1031
|
+
skip_empty_lines: config.skipEmptyLines ?? true,
|
|
1032
|
+
trim: config.trim ?? true
|
|
1033
|
+
}).on("data", (row) => {
|
|
1034
|
+
results.push(row);
|
|
1035
|
+
}).on("end", () => {
|
|
1036
|
+
resolve(results);
|
|
1037
|
+
}).on("error", (error) => {
|
|
1038
|
+
reject(error);
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
function parseJSON(content, config = {}) {
|
|
1043
|
+
try {
|
|
1044
|
+
const parsed = JSON.parse(content, config.reviver);
|
|
1045
|
+
if (Array.isArray(parsed)) {
|
|
1046
|
+
return parsed;
|
|
1047
|
+
} else {
|
|
1048
|
+
return [parsed];
|
|
1049
|
+
}
|
|
1050
|
+
} catch (error) {
|
|
1051
|
+
throw new Error(
|
|
1052
|
+
`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function parseJSONWithDates(content) {
|
|
1057
|
+
return parseJSON(content, { reviver: jsonDateReviver });
|
|
1058
|
+
}
|
|
1059
|
+
function isValidCSVDelimiter(delimiter) {
|
|
1060
|
+
return delimiter.length === 1 && !/\s/.test(delimiter);
|
|
1061
|
+
}
|
|
1062
|
+
var CSV_DELIMITERS = {
|
|
1063
|
+
COMMA: ",",
|
|
1064
|
+
TAB: " ",
|
|
1065
|
+
SEMICOLON: ";",
|
|
1066
|
+
PIPE: "|"
|
|
1067
|
+
};
|
|
1068
|
+
var DEFAULT_CSV_CONFIG = {
|
|
1069
|
+
delimiter: CSV_DELIMITERS.COMMA,
|
|
1070
|
+
columns: true,
|
|
1071
|
+
skipEmptyLines: true,
|
|
1072
|
+
trim: true
|
|
1073
|
+
};
|
|
1074
|
+
var DEFAULT_JSON_CONFIG = {
|
|
1075
|
+
reviver: jsonDateReviver
|
|
1076
|
+
};
|
|
1077
|
+
var DataSource = class {
|
|
1078
|
+
name;
|
|
1079
|
+
supportsIncremental;
|
|
1080
|
+
constructor(config) {
|
|
1081
|
+
this.name = config.name;
|
|
1082
|
+
this.supportsIncremental = config.supportsIncremental ?? false;
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
init_commons();
|
|
1086
|
+
var isClientOnlyMode = () => process2.env.MOOSE_CLIENT_ONLY === "true";
|
|
1087
|
+
var moose_internal = {
|
|
1088
|
+
tables: /* @__PURE__ */ new Map(),
|
|
1089
|
+
streams: /* @__PURE__ */ new Map(),
|
|
1090
|
+
ingestApis: /* @__PURE__ */ new Map(),
|
|
1091
|
+
apis: /* @__PURE__ */ new Map(),
|
|
1092
|
+
sqlResources: /* @__PURE__ */ new Map(),
|
|
1093
|
+
workflows: /* @__PURE__ */ new Map(),
|
|
1094
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
1095
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
1096
|
+
views: /* @__PURE__ */ new Map()
|
|
1097
|
+
};
|
|
1098
|
+
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
1099
|
+
var getMooseInternal = () => globalThis.moose_internal;
|
|
1100
|
+
if (getMooseInternal() === void 0) {
|
|
1101
|
+
globalThis.moose_internal = moose_internal;
|
|
1102
|
+
}
|
|
1103
|
+
var dlqSchema = {
|
|
1104
|
+
version: "3.1",
|
|
1105
|
+
components: {
|
|
1106
|
+
schemas: {
|
|
1107
|
+
DeadLetterModel: {
|
|
1108
|
+
type: "object",
|
|
1109
|
+
properties: {
|
|
1110
|
+
originalRecord: {
|
|
1111
|
+
$ref: "#/components/schemas/Recordstringany"
|
|
1112
|
+
},
|
|
1113
|
+
errorMessage: {
|
|
1114
|
+
type: "string"
|
|
1115
|
+
},
|
|
1116
|
+
errorType: {
|
|
1117
|
+
type: "string"
|
|
1118
|
+
},
|
|
1119
|
+
failedAt: {
|
|
1120
|
+
type: "string",
|
|
1121
|
+
format: "date-time"
|
|
1122
|
+
},
|
|
1123
|
+
source: {
|
|
1124
|
+
oneOf: [
|
|
1125
|
+
{
|
|
1126
|
+
const: "api"
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
const: "transform"
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
const: "table"
|
|
1133
|
+
}
|
|
1134
|
+
]
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
required: [
|
|
1138
|
+
"originalRecord",
|
|
1139
|
+
"errorMessage",
|
|
1140
|
+
"errorType",
|
|
1141
|
+
"failedAt",
|
|
1142
|
+
"source"
|
|
1143
|
+
]
|
|
1144
|
+
},
|
|
1145
|
+
Recordstringany: {
|
|
1146
|
+
type: "object",
|
|
1147
|
+
properties: {},
|
|
1148
|
+
required: [],
|
|
1149
|
+
description: "Construct a type with a set of properties K of type T",
|
|
1150
|
+
additionalProperties: {}
|
|
1151
|
+
}
|
|
947
1152
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
var getValueFromParameter = (value) => {
|
|
955
|
-
if (Array.isArray(value)) {
|
|
956
|
-
const [type, val] = value;
|
|
957
|
-
if (type === "Identifier") return val;
|
|
958
|
-
}
|
|
959
|
-
return value;
|
|
1153
|
+
},
|
|
1154
|
+
schemas: [
|
|
1155
|
+
{
|
|
1156
|
+
$ref: "#/components/schemas/DeadLetterModel"
|
|
1157
|
+
}
|
|
1158
|
+
]
|
|
960
1159
|
};
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1160
|
+
var dlqColumns = [
|
|
1161
|
+
{
|
|
1162
|
+
name: "originalRecord",
|
|
1163
|
+
data_type: "Json",
|
|
1164
|
+
primary_key: false,
|
|
1165
|
+
required: true,
|
|
1166
|
+
unique: false,
|
|
1167
|
+
default: null,
|
|
1168
|
+
annotations: [],
|
|
1169
|
+
ttl: null,
|
|
1170
|
+
codec: null,
|
|
1171
|
+
materialized: null,
|
|
1172
|
+
comment: null
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
name: "errorMessage",
|
|
1176
|
+
data_type: "String",
|
|
1177
|
+
primary_key: false,
|
|
1178
|
+
required: true,
|
|
1179
|
+
unique: false,
|
|
1180
|
+
default: null,
|
|
1181
|
+
annotations: [],
|
|
1182
|
+
ttl: null,
|
|
1183
|
+
codec: null,
|
|
1184
|
+
materialized: null,
|
|
1185
|
+
comment: null
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
name: "errorType",
|
|
1189
|
+
data_type: "String",
|
|
1190
|
+
primary_key: false,
|
|
1191
|
+
required: true,
|
|
1192
|
+
unique: false,
|
|
1193
|
+
default: null,
|
|
1194
|
+
annotations: [],
|
|
1195
|
+
ttl: null,
|
|
1196
|
+
codec: null,
|
|
1197
|
+
materialized: null,
|
|
1198
|
+
comment: null
|
|
1199
|
+
},
|
|
1200
|
+
{
|
|
1201
|
+
name: "failedAt",
|
|
1202
|
+
data_type: "DateTime",
|
|
1203
|
+
primary_key: false,
|
|
1204
|
+
required: true,
|
|
1205
|
+
unique: false,
|
|
1206
|
+
default: null,
|
|
1207
|
+
annotations: [],
|
|
1208
|
+
ttl: null,
|
|
1209
|
+
codec: null,
|
|
1210
|
+
materialized: null,
|
|
1211
|
+
comment: null
|
|
1212
|
+
},
|
|
1213
|
+
{
|
|
1214
|
+
name: "source",
|
|
1215
|
+
data_type: "String",
|
|
1216
|
+
primary_key: false,
|
|
1217
|
+
required: true,
|
|
1218
|
+
unique: false,
|
|
1219
|
+
default: null,
|
|
1220
|
+
annotations: [],
|
|
1221
|
+
ttl: null,
|
|
1222
|
+
codec: null,
|
|
1223
|
+
materialized: null,
|
|
1224
|
+
comment: null
|
|
973
1225
|
}
|
|
974
|
-
|
|
975
|
-
};
|
|
976
|
-
function emptyIfUndefined(value) {
|
|
977
|
-
return value === void 0 ? "" : value;
|
|
978
|
-
}
|
|
1226
|
+
];
|
|
979
1227
|
var OlapTable = class extends TypedBase {
|
|
980
1228
|
name;
|
|
981
1229
|
/** @internal */
|
|
@@ -1047,7 +1295,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1047
1295
|
createConfigHash(clickhouseConfig) {
|
|
1048
1296
|
const effectiveDatabase = this.config.database ?? clickhouseConfig.database;
|
|
1049
1297
|
const configString = `${clickhouseConfig.host}:${clickhouseConfig.port}:${clickhouseConfig.username}:${clickhouseConfig.password}:${effectiveDatabase}:${clickhouseConfig.useSSL}`;
|
|
1050
|
-
return
|
|
1298
|
+
return createHash2("sha256").update(configString).digest("hex").substring(0, 16);
|
|
1051
1299
|
}
|
|
1052
1300
|
/**
|
|
1053
1301
|
* Gets or creates a memoized ClickHouse client.
|
|
@@ -1714,7 +1962,7 @@ var Stream = class extends TypedBase {
|
|
|
1714
1962
|
*
|
|
1715
1963
|
* @internal
|
|
1716
1964
|
*/
|
|
1717
|
-
_consumers =
|
|
1965
|
+
_consumers = new Array();
|
|
1718
1966
|
/**
|
|
1719
1967
|
* Builds the full Kafka topic name including optional namespace and version suffix.
|
|
1720
1968
|
* Version suffix is appended as _x_y_z where dots in version are replaced with underscores.
|
|
@@ -1737,7 +1985,7 @@ var Stream = class extends TypedBase {
|
|
|
1737
1985
|
kafkaConfig.securityProtocol,
|
|
1738
1986
|
kafkaConfig.namespace
|
|
1739
1987
|
].join(":");
|
|
1740
|
-
return
|
|
1988
|
+
return createHash3("sha256").update(configString).digest("hex").substring(0, 16);
|
|
1741
1989
|
}
|
|
1742
1990
|
/**
|
|
1743
1991
|
* Gets or creates a memoized KafkaJS producer using runtime configuration.
|
|
@@ -1819,7 +2067,7 @@ var Stream = class extends TypedBase {
|
|
|
1819
2067
|
default: { SchemaRegistry }
|
|
1820
2068
|
} = await Promise.resolve().then(() => __toESM(require_confluent_schema_registry(), 1));
|
|
1821
2069
|
const registry = new SchemaRegistry({ host: schemaRegistryUrl });
|
|
1822
|
-
let schemaId;
|
|
2070
|
+
let schemaId = void 0;
|
|
1823
2071
|
if ("id" in sr.reference) {
|
|
1824
2072
|
schemaId = sr.reference.id;
|
|
1825
2073
|
} else if ("subjectLatest" in sr.reference) {
|
|
@@ -2579,10 +2827,10 @@ var SqlResource = class {
|
|
|
2579
2827
|
sqlResources.set(name, this);
|
|
2580
2828
|
this.name = name;
|
|
2581
2829
|
this.setup = setup.map(
|
|
2582
|
-
(
|
|
2830
|
+
(sql3) => typeof sql3 === "string" ? sql3 : toStaticQuery(sql3)
|
|
2583
2831
|
);
|
|
2584
2832
|
this.teardown = teardown.map(
|
|
2585
|
-
(
|
|
2833
|
+
(sql3) => typeof sql3 === "string" ? sql3 : toStaticQuery(sql3)
|
|
2586
2834
|
);
|
|
2587
2835
|
this.pullsDataFrom = options?.pullsDataFrom ?? [];
|
|
2588
2836
|
this.pushesDataTo = options?.pushesDataTo ?? [];
|
|
@@ -2811,7 +3059,7 @@ function getSqlResources() {
|
|
|
2811
3059
|
function getSqlResource(name) {
|
|
2812
3060
|
return getMooseInternal().sqlResources.get(name);
|
|
2813
3061
|
}
|
|
2814
|
-
function
|
|
3062
|
+
function getWorkflows2() {
|
|
2815
3063
|
return getMooseInternal().workflows;
|
|
2816
3064
|
}
|
|
2817
3065
|
function getWorkflow(name) {
|
|
@@ -2835,118 +3083,7 @@ function getViews() {
|
|
|
2835
3083
|
function getView(name) {
|
|
2836
3084
|
return getMooseInternal().views.get(name);
|
|
2837
3085
|
}
|
|
2838
|
-
|
|
2839
|
-
var DataSource = class {
|
|
2840
|
-
name;
|
|
2841
|
-
supportsIncremental;
|
|
2842
|
-
constructor(config) {
|
|
2843
|
-
this.name = config.name;
|
|
2844
|
-
this.supportsIncremental = config.supportsIncremental ?? false;
|
|
2845
|
-
}
|
|
2846
|
-
};
|
|
2847
|
-
var MOOSE_RUNTIME_ENV_PREFIX = "__MOOSE_RUNTIME_ENV__:";
|
|
2848
|
-
var mooseRuntimeEnv = {
|
|
2849
|
-
/**
|
|
2850
|
-
* Gets a value from an environment variable, with behavior depending on context.
|
|
2851
|
-
*
|
|
2852
|
-
* When IS_LOADING_INFRA_MAP=true (infrastructure loading):
|
|
2853
|
-
* Returns a marker string that Moose CLI will resolve later
|
|
2854
|
-
*
|
|
2855
|
-
* When IS_LOADING_INFRA_MAP is unset (function/workflow runtime):
|
|
2856
|
-
* Returns the actual value from the environment variable
|
|
2857
|
-
*
|
|
2858
|
-
* @param envVarName - Name of the environment variable to resolve
|
|
2859
|
-
* @returns Either a marker string or the actual environment variable value
|
|
2860
|
-
* @throws {Error} If the environment variable name is empty
|
|
2861
|
-
* @throws {Error} If the environment variable is not set (runtime mode only)
|
|
2862
|
-
*
|
|
2863
|
-
* @example
|
|
2864
|
-
* ```typescript
|
|
2865
|
-
* // Instead of this (evaluated at build time):
|
|
2866
|
-
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID
|
|
2867
|
-
*
|
|
2868
|
-
* // Use this (evaluated at runtime):
|
|
2869
|
-
* awsAccessKeyId: mooseRuntimeEnv.get("AWS_ACCESS_KEY_ID")
|
|
2870
|
-
* ```
|
|
2871
|
-
*/
|
|
2872
|
-
get(envVarName) {
|
|
2873
|
-
if (!envVarName || envVarName.trim() === "") {
|
|
2874
|
-
throw new Error("Environment variable name cannot be empty");
|
|
2875
|
-
}
|
|
2876
|
-
const isLoadingInfraMap = process.env.IS_LOADING_INFRA_MAP === "true";
|
|
2877
|
-
if (isLoadingInfraMap) {
|
|
2878
|
-
return `${MOOSE_RUNTIME_ENV_PREFIX}${envVarName}`;
|
|
2879
|
-
} else {
|
|
2880
|
-
const value = process.env[envVarName];
|
|
2881
|
-
if (value === void 0) {
|
|
2882
|
-
throw new Error(
|
|
2883
|
-
`Environment variable '${envVarName}' is not set. This is required for runtime execution of functions/workflows.`
|
|
2884
|
-
);
|
|
2885
|
-
}
|
|
2886
|
-
return value;
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
};
|
|
2890
|
-
var mooseEnvSecrets = mooseRuntimeEnv;
|
|
2891
|
-
function jsonDateReviver(key, value) {
|
|
2892
|
-
const iso8601Format = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)$/;
|
|
2893
|
-
if (typeof value === "string" && iso8601Format.test(value)) {
|
|
2894
|
-
return new Date(value);
|
|
2895
|
-
}
|
|
2896
|
-
return value;
|
|
2897
|
-
}
|
|
2898
|
-
function parseCSV(content, config) {
|
|
2899
|
-
return new Promise((resolve, reject) => {
|
|
2900
|
-
const results = [];
|
|
2901
|
-
parse2(content, {
|
|
2902
|
-
delimiter: config.delimiter,
|
|
2903
|
-
columns: config.columns ?? true,
|
|
2904
|
-
skip_empty_lines: config.skipEmptyLines ?? true,
|
|
2905
|
-
trim: config.trim ?? true
|
|
2906
|
-
}).on("data", (row) => {
|
|
2907
|
-
results.push(row);
|
|
2908
|
-
}).on("end", () => {
|
|
2909
|
-
resolve(results);
|
|
2910
|
-
}).on("error", (error) => {
|
|
2911
|
-
reject(error);
|
|
2912
|
-
});
|
|
2913
|
-
});
|
|
2914
|
-
}
|
|
2915
|
-
function parseJSON(content, config = {}) {
|
|
2916
|
-
try {
|
|
2917
|
-
const parsed = JSON.parse(content, config.reviver);
|
|
2918
|
-
if (Array.isArray(parsed)) {
|
|
2919
|
-
return parsed;
|
|
2920
|
-
} else {
|
|
2921
|
-
return [parsed];
|
|
2922
|
-
}
|
|
2923
|
-
} catch (error) {
|
|
2924
|
-
throw new Error(
|
|
2925
|
-
`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
2926
|
-
);
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
function parseJSONWithDates(content) {
|
|
2930
|
-
return parseJSON(content, { reviver: jsonDateReviver });
|
|
2931
|
-
}
|
|
2932
|
-
function isValidCSVDelimiter(delimiter) {
|
|
2933
|
-
return delimiter.length === 1 && !/\s/.test(delimiter);
|
|
2934
|
-
}
|
|
2935
|
-
var CSV_DELIMITERS = {
|
|
2936
|
-
COMMA: ",",
|
|
2937
|
-
TAB: " ",
|
|
2938
|
-
SEMICOLON: ";",
|
|
2939
|
-
PIPE: "|"
|
|
2940
|
-
};
|
|
2941
|
-
var DEFAULT_CSV_CONFIG = {
|
|
2942
|
-
delimiter: CSV_DELIMITERS.COMMA,
|
|
2943
|
-
columns: true,
|
|
2944
|
-
skipEmptyLines: true,
|
|
2945
|
-
trim: true
|
|
2946
|
-
};
|
|
2947
|
-
var DEFAULT_JSON_CONFIG = {
|
|
2948
|
-
reviver: jsonDateReviver
|
|
2949
|
-
};
|
|
3086
|
+
init_commons();
|
|
2950
3087
|
export {
|
|
2951
3088
|
ACKs,
|
|
2952
3089
|
Api,
|
|
@@ -2999,7 +3136,7 @@ export {
|
|
|
2999
3136
|
getWebApp,
|
|
3000
3137
|
getWebApps,
|
|
3001
3138
|
getWorkflow,
|
|
3002
|
-
getWorkflows,
|
|
3139
|
+
getWorkflows2 as getWorkflows,
|
|
3003
3140
|
isValidCSVDelimiter,
|
|
3004
3141
|
logError,
|
|
3005
3142
|
mapToClickHouseType,
|