@bayoudhi/moose-lib-serverless 0.1.2 → 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/{helpers-C3Yr4RzN.d.mts → index.d.mts} +453 -132
- package/dist/{helpers-C3Yr4RzN.d.ts → index.d.ts} +453 -132
- package/dist/{serverless.js → index.js} +841 -715
- package/dist/index.js.map +1 -0
- package/dist/{serverless.mjs → index.mjs} +798 -656
- package/dist/index.mjs.map +1 -0
- package/package.json +15 -8
- package/dist/browserCompatible.d.mts +0 -14
- package/dist/browserCompatible.d.ts +0 -14
- package/dist/serverless.d.mts +0 -383
- package/dist/serverless.d.ts +0 -383
- package/dist/serverless.js.map +0 -1
- package/dist/serverless.mjs.map +0 -1
|
@@ -1,261 +1,213 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
9
|
};
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
9
17
|
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
10
26
|
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
switch (value.trim().toLowerCase()) {
|
|
15
|
-
case "1":
|
|
16
|
-
case "true":
|
|
17
|
-
case "yes":
|
|
18
|
-
case "on":
|
|
19
|
-
return true;
|
|
20
|
-
default:
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function mapTstoJs(filePath) {
|
|
25
|
-
return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
|
|
26
|
-
}
|
|
27
|
-
var compilerLog, antiCachePath, getFileName, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, RETRY_FACTOR_PRODUCER, ACKs, logError;
|
|
28
|
-
var init_commons_types = __esm({
|
|
29
|
-
"src/commons-types.ts"() {
|
|
27
|
+
// stub-native:@514labs/kafka-javascript
|
|
28
|
+
var require_kafka_javascript = __commonJS({
|
|
29
|
+
"stub-native:@514labs/kafka-javascript"(exports, module) {
|
|
30
30
|
"use strict";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
+
}
|
|
55
57
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
MAX_RETRIES_PRODUCER = 150;
|
|
62
|
-
RETRY_FACTOR_PRODUCER = 0.2;
|
|
63
|
-
ACKs = -1;
|
|
64
|
-
logError = (logger, e) => {
|
|
65
|
-
logger.error(e.message);
|
|
66
|
-
const stack = e.stack;
|
|
67
|
-
if (stack) {
|
|
68
|
-
logger.error(stack);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
58
|
+
var proxy = new Proxy(function() {
|
|
59
|
+
}, handler);
|
|
60
|
+
return proxy;
|
|
61
|
+
}
|
|
62
|
+
module.exports = createDeepProxy();
|
|
71
63
|
}
|
|
72
64
|
});
|
|
73
65
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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;
|
|
88
100
|
}
|
|
89
|
-
|
|
101
|
+
module.exports = createDeepProxy();
|
|
90
102
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (!configPath) {
|
|
97
|
-
throw new ConfigError(
|
|
98
|
-
"moose.config.toml not found in current directory or any parent directory"
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
103
|
-
const config = toml.parse(configContent);
|
|
104
|
-
return config;
|
|
105
|
-
} catch (error) {
|
|
106
|
-
throw new ConfigError(`Failed to parse moose.config.toml: ${error}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
var ConfigError;
|
|
110
|
-
var init_configFile = __esm({
|
|
111
|
-
"src/config/configFile.ts"() {
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// stub-native:redis
|
|
106
|
+
var require_redis = __commonJS({
|
|
107
|
+
"stub-native:redis"(exports, module) {
|
|
112
108
|
"use strict";
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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();
|
|
119
141
|
}
|
|
120
142
|
});
|
|
121
143
|
|
|
122
|
-
//
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
var init_runtime = __esm({
|
|
126
|
-
"src/config/runtime.ts"() {
|
|
144
|
+
// stub-native:@kafkajs/confluent-schema-registry
|
|
145
|
+
var require_confluent_schema_registry = __commonJS({
|
|
146
|
+
"stub-native:@kafkajs/confluent-schema-registry"(exports, module) {
|
|
127
147
|
"use strict";
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
switch (value.trim().toLowerCase()) {
|
|
154
|
-
case "1":
|
|
155
|
-
case "true":
|
|
156
|
-
case "yes":
|
|
157
|
-
case "on":
|
|
158
|
-
return true;
|
|
159
|
-
case "0":
|
|
160
|
-
case "false":
|
|
161
|
-
case "no":
|
|
162
|
-
case "off":
|
|
163
|
-
return false;
|
|
164
|
-
default:
|
|
165
|
-
return void 0;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async getClickHouseConfig() {
|
|
169
|
-
if (this.clickhouseConfig) {
|
|
170
|
-
return this.clickhouseConfig;
|
|
171
|
-
}
|
|
172
|
-
const projectConfig = await readProjectConfig();
|
|
173
|
-
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
174
|
-
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
175
|
-
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
176
|
-
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
177
|
-
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
178
|
-
const envUseSSL = this._parseBool(
|
|
179
|
-
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
180
|
-
);
|
|
181
|
-
return {
|
|
182
|
-
host: envHost ?? projectConfig.clickhouse_config.host,
|
|
183
|
-
port: envPort ?? projectConfig.clickhouse_config.host_port.toString(),
|
|
184
|
-
username: envUser ?? projectConfig.clickhouse_config.user,
|
|
185
|
-
password: envPassword ?? projectConfig.clickhouse_config.password,
|
|
186
|
-
database: envDb ?? projectConfig.clickhouse_config.db_name,
|
|
187
|
-
useSSL: envUseSSL !== void 0 ? envUseSSL : projectConfig.clickhouse_config.use_ssl || false
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
async getStandaloneClickhouseConfig(overrides) {
|
|
191
|
-
if (this.clickhouseConfig) {
|
|
192
|
-
return { ...this.clickhouseConfig, ...overrides };
|
|
193
|
-
}
|
|
194
|
-
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
195
|
-
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
196
|
-
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
197
|
-
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
198
|
-
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
199
|
-
const envUseSSL = this._parseBool(
|
|
200
|
-
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
201
|
-
);
|
|
202
|
-
let projectConfig;
|
|
203
|
-
try {
|
|
204
|
-
projectConfig = await readProjectConfig();
|
|
205
|
-
} catch (error) {
|
|
206
|
-
projectConfig = null;
|
|
207
|
-
}
|
|
208
|
-
const defaults = {
|
|
209
|
-
host: "localhost",
|
|
210
|
-
port: "18123",
|
|
211
|
-
username: "default",
|
|
212
|
-
password: "",
|
|
213
|
-
database: "local",
|
|
214
|
-
useSSL: false
|
|
215
|
-
};
|
|
216
|
-
return {
|
|
217
|
-
host: overrides?.host ?? envHost ?? projectConfig?.clickhouse_config.host ?? defaults.host,
|
|
218
|
-
port: overrides?.port ?? envPort ?? projectConfig?.clickhouse_config.host_port.toString() ?? defaults.port,
|
|
219
|
-
username: overrides?.username ?? envUser ?? projectConfig?.clickhouse_config.user ?? defaults.username,
|
|
220
|
-
password: overrides?.password ?? envPassword ?? projectConfig?.clickhouse_config.password ?? defaults.password,
|
|
221
|
-
database: overrides?.database ?? envDb ?? projectConfig?.clickhouse_config.db_name ?? defaults.database,
|
|
222
|
-
useSSL: overrides?.useSSL ?? envUseSSL ?? projectConfig?.clickhouse_config.use_ssl ?? defaults.useSSL
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
async getKafkaConfig() {
|
|
226
|
-
if (this.kafkaConfig) {
|
|
227
|
-
return this.kafkaConfig;
|
|
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;
|
|
228
173
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const envSecurityProtocol = this._env("MOOSE_REDPANDA_CONFIG__SECURITY_PROTOCOL") ?? this._env("MOOSE_KAFKA_CONFIG__SECURITY_PROTOCOL");
|
|
236
|
-
const envNamespace = this._env("MOOSE_REDPANDA_CONFIG__NAMESPACE") ?? this._env("MOOSE_KAFKA_CONFIG__NAMESPACE");
|
|
237
|
-
const envSchemaRegistryUrl = this._env("MOOSE_REDPANDA_CONFIG__SCHEMA_REGISTRY_URL") ?? this._env("MOOSE_KAFKA_CONFIG__SCHEMA_REGISTRY_URL");
|
|
238
|
-
const fileKafka = projectConfig.kafka_config ?? projectConfig.redpanda_config;
|
|
239
|
-
return {
|
|
240
|
-
broker: envBroker ?? fileKafka?.broker ?? "localhost:19092",
|
|
241
|
-
messageTimeoutMs: envMsgTimeout ? parseInt(envMsgTimeout, 10) : fileKafka?.message_timeout_ms ?? 1e3,
|
|
242
|
-
saslUsername: envSaslUsername ?? fileKafka?.sasl_username,
|
|
243
|
-
saslPassword: envSaslPassword ?? fileKafka?.sasl_password,
|
|
244
|
-
saslMechanism: envSaslMechanism ?? fileKafka?.sasl_mechanism,
|
|
245
|
-
securityProtocol: envSecurityProtocol ?? fileKafka?.security_protocol,
|
|
246
|
-
namespace: envNamespace ?? fileKafka?.namespace,
|
|
247
|
-
schemaRegistryUrl: envSchemaRegistryUrl ?? fileKafka?.schema_registry_url
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
hasRuntimeConfig() {
|
|
251
|
-
return !!this.clickhouseConfig || !!this.kafkaConfig;
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
globalThis._mooseConfigRegistry = ConfigurationRegistry.getInstance();
|
|
174
|
+
};
|
|
175
|
+
var proxy = new Proxy(function() {
|
|
176
|
+
}, handler);
|
|
177
|
+
return proxy;
|
|
178
|
+
}
|
|
179
|
+
module.exports = createDeepProxy();
|
|
255
180
|
}
|
|
256
181
|
});
|
|
257
182
|
|
|
258
|
-
//
|
|
183
|
+
// ../ts-moose-lib/dist/serverless.mjs
|
|
184
|
+
var import_kafka_javascript = __toESM(require_kafka_javascript(), 1);
|
|
185
|
+
var import_client2 = __toESM(require_client(), 1);
|
|
186
|
+
import {
|
|
187
|
+
existsSync,
|
|
188
|
+
readdirSync,
|
|
189
|
+
readFileSync,
|
|
190
|
+
writeFileSync
|
|
191
|
+
} from "fs";
|
|
192
|
+
import nodePath from "path";
|
|
193
|
+
import { createClient } from "@clickhouse/client";
|
|
194
|
+
import path from "path";
|
|
195
|
+
import * as toml from "toml";
|
|
196
|
+
import process2 from "process";
|
|
197
|
+
var import_redis = __toESM(require_redis(), 1);
|
|
198
|
+
import { parse as parse2 } from "csv-parse";
|
|
199
|
+
import { Readable } from "stream";
|
|
200
|
+
import { createHash as createHash2 } from "crypto";
|
|
201
|
+
import { createHash as createHash3 } from "crypto";
|
|
202
|
+
var __defProp2 = Object.defineProperty;
|
|
203
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
204
|
+
var __esm = (fn, res) => function __init() {
|
|
205
|
+
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
206
|
+
};
|
|
207
|
+
var __export = (target, all) => {
|
|
208
|
+
for (var name in all)
|
|
209
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
210
|
+
};
|
|
259
211
|
var commons_exports = {};
|
|
260
212
|
__export(commons_exports, {
|
|
261
213
|
ACKs: () => ACKs,
|
|
@@ -276,15 +228,21 @@ __export(commons_exports, {
|
|
|
276
228
|
mapTstoJs: () => mapTstoJs,
|
|
277
229
|
rewriteImportExtensions: () => rewriteImportExtensions
|
|
278
230
|
});
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
231
|
+
function isTruthy(value) {
|
|
232
|
+
if (!value) return false;
|
|
233
|
+
switch (value.trim().toLowerCase()) {
|
|
234
|
+
case "1":
|
|
235
|
+
case "true":
|
|
236
|
+
case "yes":
|
|
237
|
+
case "on":
|
|
238
|
+
return true;
|
|
239
|
+
default:
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function mapTstoJs(filePath) {
|
|
244
|
+
return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
|
|
245
|
+
}
|
|
288
246
|
function walkDirectory(dir, extensions) {
|
|
289
247
|
const results = [];
|
|
290
248
|
if (!existsSync(dir)) {
|
|
@@ -395,13 +353,40 @@ async function getKafkaProducer(cfg, logger, maxMessageBytes) {
|
|
|
395
353
|
await producer.connect();
|
|
396
354
|
return producer;
|
|
397
355
|
}
|
|
398
|
-
var Kafka
|
|
356
|
+
var Kafka;
|
|
357
|
+
var compilerLog;
|
|
358
|
+
var antiCachePath;
|
|
359
|
+
var getFileName;
|
|
360
|
+
var getClickhouseClient;
|
|
361
|
+
var cliLog;
|
|
362
|
+
var MAX_RETRIES;
|
|
363
|
+
var MAX_RETRY_TIME_MS;
|
|
364
|
+
var RETRY_INITIAL_TIME_MS;
|
|
365
|
+
var MAX_RETRIES_PRODUCER;
|
|
366
|
+
var RETRY_FACTOR_PRODUCER;
|
|
367
|
+
var ACKs;
|
|
368
|
+
var parseBrokerString;
|
|
369
|
+
var logError;
|
|
370
|
+
var buildSaslConfig;
|
|
371
|
+
var getKafkaClient;
|
|
399
372
|
var init_commons = __esm({
|
|
400
373
|
"src/commons.ts"() {
|
|
401
374
|
"use strict";
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
375
|
+
({ Kafka } = import_kafka_javascript.KafkaJS);
|
|
376
|
+
compilerLog = (message) => {
|
|
377
|
+
if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
|
|
378
|
+
console.log(message);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
antiCachePath = (path2) => `${path2}?num=${Math.random().toString()}&time=${Date.now()}`;
|
|
382
|
+
getFileName = (filePath) => {
|
|
383
|
+
const regex = /\/([^\/]+)\.ts/;
|
|
384
|
+
const matches = filePath.match(regex);
|
|
385
|
+
if (matches && matches.length > 1) {
|
|
386
|
+
return matches[1];
|
|
387
|
+
}
|
|
388
|
+
return "";
|
|
389
|
+
};
|
|
405
390
|
getClickhouseClient = ({
|
|
406
391
|
username,
|
|
407
392
|
password,
|
|
@@ -422,7 +407,33 @@ var init_commons = __esm({
|
|
|
422
407
|
// to preserve SELECT query performance while ensuring INSERT/DDL reliability
|
|
423
408
|
});
|
|
424
409
|
};
|
|
410
|
+
cliLog = (log) => {
|
|
411
|
+
const level = log.message_type === "Error" ? "error" : log.message_type === "Warning" ? "warn" : "info";
|
|
412
|
+
const structuredLog = {
|
|
413
|
+
__moose_structured_log__: true,
|
|
414
|
+
level,
|
|
415
|
+
message: log.message,
|
|
416
|
+
resource_type: "runtime",
|
|
417
|
+
cli_action: log.action,
|
|
418
|
+
cli_message_type: log.message_type ?? "Info",
|
|
419
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
420
|
+
};
|
|
421
|
+
process.stderr.write(JSON.stringify(structuredLog) + "\n");
|
|
422
|
+
};
|
|
423
|
+
MAX_RETRIES = 150;
|
|
424
|
+
MAX_RETRY_TIME_MS = 1e3;
|
|
425
|
+
RETRY_INITIAL_TIME_MS = 100;
|
|
426
|
+
MAX_RETRIES_PRODUCER = 150;
|
|
427
|
+
RETRY_FACTOR_PRODUCER = 0.2;
|
|
428
|
+
ACKs = -1;
|
|
425
429
|
parseBrokerString = (brokerString) => brokerString.split(",").map((b) => b.trim()).filter((b) => b.length > 0);
|
|
430
|
+
logError = (logger, e) => {
|
|
431
|
+
logger.error(e.message);
|
|
432
|
+
const stack = e.stack;
|
|
433
|
+
if (stack) {
|
|
434
|
+
logger.error(stack);
|
|
435
|
+
}
|
|
436
|
+
};
|
|
426
437
|
buildSaslConfig = (logger, args) => {
|
|
427
438
|
const mechanism = args.saslMechanism ? args.saslMechanism.toLowerCase() : "";
|
|
428
439
|
switch (mechanism) {
|
|
@@ -438,58 +449,210 @@ var init_commons = __esm({
|
|
|
438
449
|
logger.warn(`Unsupported SASL mechanism: ${args.saslMechanism}`);
|
|
439
450
|
return void 0;
|
|
440
451
|
}
|
|
441
|
-
};
|
|
442
|
-
getKafkaClient = async (cfg, logger) => {
|
|
443
|
-
const brokers = parseBrokerString(cfg.broker || "");
|
|
444
|
-
if (brokers.length === 0) {
|
|
445
|
-
throw new Error(`No valid broker addresses found in: "${cfg.broker}"`);
|
|
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
|
+
};
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
async function findConfigFile(startDir = process.cwd()) {
|
|
479
|
+
const fs = await import("fs");
|
|
480
|
+
let currentDir = path.resolve(startDir);
|
|
481
|
+
while (true) {
|
|
482
|
+
const configPath = path.join(currentDir, "moose.config.toml");
|
|
483
|
+
if (fs.existsSync(configPath)) {
|
|
484
|
+
return configPath;
|
|
485
|
+
}
|
|
486
|
+
const parentDir = path.dirname(currentDir);
|
|
487
|
+
if (parentDir === currentDir) {
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
currentDir = parentDir;
|
|
491
|
+
}
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
async function readProjectConfig() {
|
|
495
|
+
const fs = await import("fs");
|
|
496
|
+
const configPath = await findConfigFile();
|
|
497
|
+
if (!configPath) {
|
|
498
|
+
throw new ConfigError(
|
|
499
|
+
"moose.config.toml not found in current directory or any parent directory"
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
try {
|
|
503
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
504
|
+
const config = toml.parse(configContent);
|
|
505
|
+
return config;
|
|
506
|
+
} catch (error) {
|
|
507
|
+
throw new ConfigError(`Failed to parse moose.config.toml: ${error}`);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
var ConfigError;
|
|
511
|
+
var init_configFile = __esm({
|
|
512
|
+
"src/config/configFile.ts"() {
|
|
513
|
+
"use strict";
|
|
514
|
+
ConfigError = class extends Error {
|
|
515
|
+
constructor(message) {
|
|
516
|
+
super(message);
|
|
517
|
+
this.name = "ConfigError";
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
var runtime_exports = {};
|
|
523
|
+
var ConfigurationRegistry;
|
|
524
|
+
var init_runtime = __esm({
|
|
525
|
+
"src/config/runtime.ts"() {
|
|
526
|
+
"use strict";
|
|
527
|
+
init_configFile();
|
|
528
|
+
ConfigurationRegistry = class _ConfigurationRegistry {
|
|
529
|
+
static instance;
|
|
530
|
+
clickhouseConfig;
|
|
531
|
+
kafkaConfig;
|
|
532
|
+
static getInstance() {
|
|
533
|
+
if (!_ConfigurationRegistry.instance) {
|
|
534
|
+
_ConfigurationRegistry.instance = new _ConfigurationRegistry();
|
|
535
|
+
}
|
|
536
|
+
return _ConfigurationRegistry.instance;
|
|
537
|
+
}
|
|
538
|
+
setClickHouseConfig(config) {
|
|
539
|
+
this.clickhouseConfig = config;
|
|
540
|
+
}
|
|
541
|
+
setKafkaConfig(config) {
|
|
542
|
+
this.kafkaConfig = config;
|
|
446
543
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
544
|
+
_env(name) {
|
|
545
|
+
const value = process.env[name];
|
|
546
|
+
if (value === void 0) return void 0;
|
|
547
|
+
const trimmed = value.trim();
|
|
548
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
549
|
+
}
|
|
550
|
+
_parseBool(value) {
|
|
551
|
+
if (value === void 0) return void 0;
|
|
552
|
+
switch (value.trim().toLowerCase()) {
|
|
553
|
+
case "1":
|
|
554
|
+
case "true":
|
|
555
|
+
case "yes":
|
|
556
|
+
case "on":
|
|
557
|
+
return true;
|
|
558
|
+
case "0":
|
|
559
|
+
case "false":
|
|
560
|
+
case "no":
|
|
561
|
+
case "off":
|
|
562
|
+
return false;
|
|
563
|
+
default:
|
|
564
|
+
return void 0;
|
|
462
565
|
}
|
|
463
|
-
}
|
|
566
|
+
}
|
|
567
|
+
async getClickHouseConfig() {
|
|
568
|
+
if (this.clickhouseConfig) {
|
|
569
|
+
return this.clickhouseConfig;
|
|
570
|
+
}
|
|
571
|
+
const projectConfig = await readProjectConfig();
|
|
572
|
+
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
573
|
+
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
574
|
+
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
575
|
+
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
576
|
+
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
577
|
+
const envUseSSL = this._parseBool(
|
|
578
|
+
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
579
|
+
);
|
|
580
|
+
return {
|
|
581
|
+
host: envHost ?? projectConfig.clickhouse_config.host,
|
|
582
|
+
port: envPort ?? projectConfig.clickhouse_config.host_port.toString(),
|
|
583
|
+
username: envUser ?? projectConfig.clickhouse_config.user,
|
|
584
|
+
password: envPassword ?? projectConfig.clickhouse_config.password,
|
|
585
|
+
database: envDb ?? projectConfig.clickhouse_config.db_name,
|
|
586
|
+
useSSL: envUseSSL !== void 0 ? envUseSSL : projectConfig.clickhouse_config.use_ssl || false
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
async getStandaloneClickhouseConfig(overrides) {
|
|
590
|
+
if (this.clickhouseConfig) {
|
|
591
|
+
return { ...this.clickhouseConfig, ...overrides };
|
|
592
|
+
}
|
|
593
|
+
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
594
|
+
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
595
|
+
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
596
|
+
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
597
|
+
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
598
|
+
const envUseSSL = this._parseBool(
|
|
599
|
+
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
600
|
+
);
|
|
601
|
+
let projectConfig;
|
|
602
|
+
try {
|
|
603
|
+
projectConfig = await readProjectConfig();
|
|
604
|
+
} catch (error) {
|
|
605
|
+
projectConfig = null;
|
|
606
|
+
}
|
|
607
|
+
const defaults = {
|
|
608
|
+
host: "localhost",
|
|
609
|
+
port: "18123",
|
|
610
|
+
username: "default",
|
|
611
|
+
password: "",
|
|
612
|
+
database: "local",
|
|
613
|
+
useSSL: false
|
|
614
|
+
};
|
|
615
|
+
return {
|
|
616
|
+
host: overrides?.host ?? envHost ?? projectConfig?.clickhouse_config.host ?? defaults.host,
|
|
617
|
+
port: overrides?.port ?? envPort ?? projectConfig?.clickhouse_config.host_port.toString() ?? defaults.port,
|
|
618
|
+
username: overrides?.username ?? envUser ?? projectConfig?.clickhouse_config.user ?? defaults.username,
|
|
619
|
+
password: overrides?.password ?? envPassword ?? projectConfig?.clickhouse_config.password ?? defaults.password,
|
|
620
|
+
database: overrides?.database ?? envDb ?? projectConfig?.clickhouse_config.db_name ?? defaults.database,
|
|
621
|
+
useSSL: overrides?.useSSL ?? envUseSSL ?? projectConfig?.clickhouse_config.use_ssl ?? defaults.useSSL
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
async getKafkaConfig() {
|
|
625
|
+
if (this.kafkaConfig) {
|
|
626
|
+
return this.kafkaConfig;
|
|
627
|
+
}
|
|
628
|
+
const projectConfig = await readProjectConfig();
|
|
629
|
+
const envBroker = this._env("MOOSE_REDPANDA_CONFIG__BROKER") ?? this._env("MOOSE_KAFKA_CONFIG__BROKER");
|
|
630
|
+
const envMsgTimeout = this._env("MOOSE_REDPANDA_CONFIG__MESSAGE_TIMEOUT_MS") ?? this._env("MOOSE_KAFKA_CONFIG__MESSAGE_TIMEOUT_MS");
|
|
631
|
+
const envSaslUsername = this._env("MOOSE_REDPANDA_CONFIG__SASL_USERNAME") ?? this._env("MOOSE_KAFKA_CONFIG__SASL_USERNAME");
|
|
632
|
+
const envSaslPassword = this._env("MOOSE_REDPANDA_CONFIG__SASL_PASSWORD") ?? this._env("MOOSE_KAFKA_CONFIG__SASL_PASSWORD");
|
|
633
|
+
const envSaslMechanism = this._env("MOOSE_REDPANDA_CONFIG__SASL_MECHANISM") ?? this._env("MOOSE_KAFKA_CONFIG__SASL_MECHANISM");
|
|
634
|
+
const envSecurityProtocol = this._env("MOOSE_REDPANDA_CONFIG__SECURITY_PROTOCOL") ?? this._env("MOOSE_KAFKA_CONFIG__SECURITY_PROTOCOL");
|
|
635
|
+
const envNamespace = this._env("MOOSE_REDPANDA_CONFIG__NAMESPACE") ?? this._env("MOOSE_KAFKA_CONFIG__NAMESPACE");
|
|
636
|
+
const envSchemaRegistryUrl = this._env("MOOSE_REDPANDA_CONFIG__SCHEMA_REGISTRY_URL") ?? this._env("MOOSE_KAFKA_CONFIG__SCHEMA_REGISTRY_URL");
|
|
637
|
+
const fileKafka = projectConfig.kafka_config ?? projectConfig.redpanda_config;
|
|
638
|
+
return {
|
|
639
|
+
broker: envBroker ?? fileKafka?.broker ?? "localhost:19092",
|
|
640
|
+
messageTimeoutMs: envMsgTimeout ? parseInt(envMsgTimeout, 10) : fileKafka?.message_timeout_ms ?? 1e3,
|
|
641
|
+
saslUsername: envSaslUsername ?? fileKafka?.sasl_username,
|
|
642
|
+
saslPassword: envSaslPassword ?? fileKafka?.sasl_password,
|
|
643
|
+
saslMechanism: envSaslMechanism ?? fileKafka?.sasl_mechanism,
|
|
644
|
+
securityProtocol: envSecurityProtocol ?? fileKafka?.security_protocol,
|
|
645
|
+
namespace: envNamespace ?? fileKafka?.namespace,
|
|
646
|
+
schemaRegistryUrl: envSchemaRegistryUrl ?? fileKafka?.schema_registry_url
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
hasRuntimeConfig() {
|
|
650
|
+
return !!this.clickhouseConfig || !!this.kafkaConfig;
|
|
651
|
+
}
|
|
464
652
|
};
|
|
653
|
+
globalThis._mooseConfigRegistry = ConfigurationRegistry.getInstance();
|
|
465
654
|
}
|
|
466
655
|
});
|
|
467
|
-
|
|
468
|
-
// src/dataModels/types.ts
|
|
469
|
-
var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
|
|
470
|
-
ClickHouseEngines2["MergeTree"] = "MergeTree";
|
|
471
|
-
ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
|
|
472
|
-
ClickHouseEngines2["SummingMergeTree"] = "SummingMergeTree";
|
|
473
|
-
ClickHouseEngines2["AggregatingMergeTree"] = "AggregatingMergeTree";
|
|
474
|
-
ClickHouseEngines2["CollapsingMergeTree"] = "CollapsingMergeTree";
|
|
475
|
-
ClickHouseEngines2["VersionedCollapsingMergeTree"] = "VersionedCollapsingMergeTree";
|
|
476
|
-
ClickHouseEngines2["GraphiteMergeTree"] = "GraphiteMergeTree";
|
|
477
|
-
ClickHouseEngines2["S3Queue"] = "S3Queue";
|
|
478
|
-
ClickHouseEngines2["S3"] = "S3";
|
|
479
|
-
ClickHouseEngines2["Buffer"] = "Buffer";
|
|
480
|
-
ClickHouseEngines2["Distributed"] = "Distributed";
|
|
481
|
-
ClickHouseEngines2["IcebergS3"] = "IcebergS3";
|
|
482
|
-
ClickHouseEngines2["Kafka"] = "Kafka";
|
|
483
|
-
ClickHouseEngines2["ReplicatedMergeTree"] = "ReplicatedMergeTree";
|
|
484
|
-
ClickHouseEngines2["ReplicatedReplacingMergeTree"] = "ReplicatedReplacingMergeTree";
|
|
485
|
-
ClickHouseEngines2["ReplicatedAggregatingMergeTree"] = "ReplicatedAggregatingMergeTree";
|
|
486
|
-
ClickHouseEngines2["ReplicatedSummingMergeTree"] = "ReplicatedSummingMergeTree";
|
|
487
|
-
ClickHouseEngines2["ReplicatedCollapsingMergeTree"] = "ReplicatedCollapsingMergeTree";
|
|
488
|
-
ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
|
|
489
|
-
return ClickHouseEngines2;
|
|
490
|
-
})(ClickHouseEngines || {});
|
|
491
|
-
|
|
492
|
-
// src/dmv2/utils/stackTrace.ts
|
|
493
656
|
function shouldSkipStackLine(line) {
|
|
494
657
|
return line.includes("node_modules") || // Skip npm installed packages (prod)
|
|
495
658
|
line.includes("node:internal") || // Skip Node.js internals (modern format)
|
|
@@ -550,8 +713,6 @@ function getSourceFileFromStack(stack) {
|
|
|
550
713
|
const location = getSourceLocationFromStack(stack);
|
|
551
714
|
return location?.file;
|
|
552
715
|
}
|
|
553
|
-
|
|
554
|
-
// src/dmv2/typedBase.ts
|
|
555
716
|
var TypedBase = class {
|
|
556
717
|
/** The JSON schema representation of type T. Injected by the compiler plugin. */
|
|
557
718
|
schema;
|
|
@@ -610,165 +771,79 @@ var TypedBase = class {
|
|
|
610
771
|
}
|
|
611
772
|
}
|
|
612
773
|
};
|
|
613
|
-
|
|
614
|
-
// src/dataModels/dataModelTypes.ts
|
|
615
774
|
function isArrayNestedType(dt) {
|
|
616
775
|
return typeof dt === "object" && dt !== null && dt.elementType !== null && typeof dt.elementType === "object" && dt.elementType.hasOwnProperty("columns") && Array.isArray(dt.elementType.columns);
|
|
617
776
|
}
|
|
618
777
|
function isNestedType(dt) {
|
|
619
778
|
return typeof dt === "object" && dt !== null && Array.isArray(dt.columns);
|
|
620
779
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
]
|
|
674
|
-
}
|
|
675
|
-
},
|
|
676
|
-
required: [
|
|
677
|
-
"originalRecord",
|
|
678
|
-
"errorMessage",
|
|
679
|
-
"errorType",
|
|
680
|
-
"failedAt",
|
|
681
|
-
"source"
|
|
682
|
-
]
|
|
683
|
-
},
|
|
684
|
-
Recordstringany: {
|
|
685
|
-
type: "object",
|
|
686
|
-
properties: {},
|
|
687
|
-
required: [],
|
|
688
|
-
description: "Construct a type with a set of properties K of type T",
|
|
689
|
-
additionalProperties: {}
|
|
690
|
-
}
|
|
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");
|
|
691
831
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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;
|
|
696
843
|
}
|
|
697
|
-
]
|
|
698
|
-
};
|
|
699
|
-
var dlqColumns = [
|
|
700
|
-
{
|
|
701
|
-
name: "originalRecord",
|
|
702
|
-
data_type: "Json",
|
|
703
|
-
primary_key: false,
|
|
704
|
-
required: true,
|
|
705
|
-
unique: false,
|
|
706
|
-
default: null,
|
|
707
|
-
annotations: [],
|
|
708
|
-
ttl: null,
|
|
709
|
-
codec: null,
|
|
710
|
-
materialized: null,
|
|
711
|
-
comment: null
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
name: "errorMessage",
|
|
715
|
-
data_type: "String",
|
|
716
|
-
primary_key: false,
|
|
717
|
-
required: true,
|
|
718
|
-
unique: false,
|
|
719
|
-
default: null,
|
|
720
|
-
annotations: [],
|
|
721
|
-
ttl: null,
|
|
722
|
-
codec: null,
|
|
723
|
-
materialized: null,
|
|
724
|
-
comment: null
|
|
725
|
-
},
|
|
726
|
-
{
|
|
727
|
-
name: "errorType",
|
|
728
|
-
data_type: "String",
|
|
729
|
-
primary_key: false,
|
|
730
|
-
required: true,
|
|
731
|
-
unique: false,
|
|
732
|
-
default: null,
|
|
733
|
-
annotations: [],
|
|
734
|
-
ttl: null,
|
|
735
|
-
codec: null,
|
|
736
|
-
materialized: null,
|
|
737
|
-
comment: null
|
|
738
|
-
},
|
|
739
|
-
{
|
|
740
|
-
name: "failedAt",
|
|
741
|
-
data_type: "DateTime",
|
|
742
|
-
primary_key: false,
|
|
743
|
-
required: true,
|
|
744
|
-
unique: false,
|
|
745
|
-
default: null,
|
|
746
|
-
annotations: [],
|
|
747
|
-
ttl: null,
|
|
748
|
-
codec: null,
|
|
749
|
-
materialized: null,
|
|
750
|
-
comment: null
|
|
751
|
-
},
|
|
752
|
-
{
|
|
753
|
-
name: "source",
|
|
754
|
-
data_type: "String",
|
|
755
|
-
primary_key: false,
|
|
756
|
-
required: true,
|
|
757
|
-
unique: false,
|
|
758
|
-
default: null,
|
|
759
|
-
annotations: [],
|
|
760
|
-
ttl: null,
|
|
761
|
-
codec: null,
|
|
762
|
-
materialized: null,
|
|
763
|
-
comment: null
|
|
764
844
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
// src/dmv2/sdk/olapTable.ts
|
|
768
|
-
import { Readable } from "stream";
|
|
769
|
-
import { createHash } from "crypto";
|
|
770
|
-
|
|
771
|
-
// src/sqlHelpers.ts
|
|
845
|
+
};
|
|
846
|
+
var mooseEnvSecrets = mooseRuntimeEnv;
|
|
772
847
|
var quoteIdentifier = (name) => {
|
|
773
848
|
return name.startsWith("`") && name.endsWith("`") ? name : `\`${name}\``;
|
|
774
849
|
};
|
|
@@ -855,8 +930,8 @@ sql.join = function(fragments, separator) {
|
|
|
855
930
|
sql.raw = function(text) {
|
|
856
931
|
return new Sql([text], []);
|
|
857
932
|
};
|
|
858
|
-
var toStaticQuery = (
|
|
859
|
-
const [query, params] = toQuery(
|
|
933
|
+
var toStaticQuery = (sql3) => {
|
|
934
|
+
const [query, params] = toQuery(sql3);
|
|
860
935
|
if (Object.keys(params).length !== 0) {
|
|
861
936
|
throw new Error(
|
|
862
937
|
"Dynamic SQL is not allowed in the select statement in view creation."
|
|
@@ -864,14 +939,14 @@ var toStaticQuery = (sql2) => {
|
|
|
864
939
|
}
|
|
865
940
|
return query;
|
|
866
941
|
};
|
|
867
|
-
var toQuery = (
|
|
868
|
-
const parameterizedStubs =
|
|
942
|
+
var toQuery = (sql3) => {
|
|
943
|
+
const parameterizedStubs = sql3.values.map(
|
|
869
944
|
(v, i) => createClickhouseParameter(i, v)
|
|
870
945
|
);
|
|
871
|
-
const query =
|
|
946
|
+
const query = sql3.strings.map(
|
|
872
947
|
(s, i) => s != "" ? `${s}${emptyIfUndefined(parameterizedStubs[i])}` : ""
|
|
873
948
|
).join("");
|
|
874
|
-
const query_params =
|
|
949
|
+
const query_params = sql3.values.reduce(
|
|
875
950
|
(acc, v, i) => ({
|
|
876
951
|
...acc,
|
|
877
952
|
[`p${i}`]: getValueFromParameter(v)
|
|
@@ -880,7 +955,7 @@ var toQuery = (sql2) => {
|
|
|
880
955
|
);
|
|
881
956
|
return [query, query_params];
|
|
882
957
|
};
|
|
883
|
-
var toQueryPreview = (
|
|
958
|
+
var toQueryPreview = (sql3) => {
|
|
884
959
|
try {
|
|
885
960
|
const formatValue = (v) => {
|
|
886
961
|
if (Array.isArray(v)) {
|
|
@@ -901,46 +976,254 @@ var toQueryPreview = (sql2) => {
|
|
|
901
976
|
} catch {
|
|
902
977
|
return String(v);
|
|
903
978
|
}
|
|
904
|
-
};
|
|
905
|
-
let out =
|
|
906
|
-
for (let i = 0; i <
|
|
907
|
-
const val = getValueFromParameter(
|
|
908
|
-
out += formatValue(val);
|
|
909
|
-
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
|
+
}
|
|
910
1152
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
var getValueFromParameter = (value) => {
|
|
918
|
-
if (Array.isArray(value)) {
|
|
919
|
-
const [type, val] = value;
|
|
920
|
-
if (type === "Identifier") return val;
|
|
921
|
-
}
|
|
922
|
-
return value;
|
|
1153
|
+
},
|
|
1154
|
+
schemas: [
|
|
1155
|
+
{
|
|
1156
|
+
$ref: "#/components/schemas/DeadLetterModel"
|
|
1157
|
+
}
|
|
1158
|
+
]
|
|
923
1159
|
};
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
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
|
|
936
1225
|
}
|
|
937
|
-
|
|
938
|
-
};
|
|
939
|
-
function emptyIfUndefined(value) {
|
|
940
|
-
return value === void 0 ? "" : value;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
// src/dmv2/sdk/olapTable.ts
|
|
1226
|
+
];
|
|
944
1227
|
var OlapTable = class extends TypedBase {
|
|
945
1228
|
name;
|
|
946
1229
|
/** @internal */
|
|
@@ -952,7 +1235,14 @@ var OlapTable = class extends TypedBase {
|
|
|
952
1235
|
/** @internal Cached table name to avoid repeated generation */
|
|
953
1236
|
_cachedTableName;
|
|
954
1237
|
constructor(name, config, schema, columns, validators) {
|
|
955
|
-
const resolvedConfig = config ? "engine" in config ? config : {
|
|
1238
|
+
const resolvedConfig = config ? "engine" in config ? config : {
|
|
1239
|
+
...config,
|
|
1240
|
+
engine: "MergeTree"
|
|
1241
|
+
/* MergeTree */
|
|
1242
|
+
} : {
|
|
1243
|
+
engine: "MergeTree"
|
|
1244
|
+
/* MergeTree */
|
|
1245
|
+
};
|
|
956
1246
|
const hasFields = Array.isArray(resolvedConfig.orderByFields) && resolvedConfig.orderByFields.length > 0;
|
|
957
1247
|
const hasExpr = typeof resolvedConfig.orderByExpression === "string" && resolvedConfig.orderByExpression.length > 0;
|
|
958
1248
|
if (hasFields && hasExpr) {
|
|
@@ -1005,7 +1295,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1005
1295
|
createConfigHash(clickhouseConfig) {
|
|
1006
1296
|
const effectiveDatabase = this.config.database ?? clickhouseConfig.database;
|
|
1007
1297
|
const configString = `${clickhouseConfig.host}:${clickhouseConfig.port}:${clickhouseConfig.username}:${clickhouseConfig.password}:${effectiveDatabase}:${clickhouseConfig.useSSL}`;
|
|
1008
|
-
return
|
|
1298
|
+
return createHash2("sha256").update(configString).digest("hex").substring(0, 16);
|
|
1009
1299
|
}
|
|
1010
1300
|
/**
|
|
1011
1301
|
* Gets or creates a memoized ClickHouse client.
|
|
@@ -1622,9 +1912,6 @@ var OlapTable = class extends TypedBase {
|
|
|
1622
1912
|
// were removed in ENG-856. Use direct configuration instead, e.g.:
|
|
1623
1913
|
// new OlapTable(name, { engine: ClickHouseEngines.ReplacingMergeTree, orderByFields: ["id"], ver: "updated_at" })
|
|
1624
1914
|
};
|
|
1625
|
-
|
|
1626
|
-
// src/dmv2/sdk/stream.ts
|
|
1627
|
-
import { createHash as createHash2 } from "crypto";
|
|
1628
1915
|
var RoutedMessage = class {
|
|
1629
1916
|
/** The destination stream for the message */
|
|
1630
1917
|
destination;
|
|
@@ -1675,7 +1962,7 @@ var Stream = class extends TypedBase {
|
|
|
1675
1962
|
*
|
|
1676
1963
|
* @internal
|
|
1677
1964
|
*/
|
|
1678
|
-
_consumers =
|
|
1965
|
+
_consumers = new Array();
|
|
1679
1966
|
/**
|
|
1680
1967
|
* Builds the full Kafka topic name including optional namespace and version suffix.
|
|
1681
1968
|
* Version suffix is appended as _x_y_z where dots in version are replaced with underscores.
|
|
@@ -1698,7 +1985,7 @@ var Stream = class extends TypedBase {
|
|
|
1698
1985
|
kafkaConfig.securityProtocol,
|
|
1699
1986
|
kafkaConfig.namespace
|
|
1700
1987
|
].join(":");
|
|
1701
|
-
return
|
|
1988
|
+
return createHash3("sha256").update(configString).digest("hex").substring(0, 16);
|
|
1702
1989
|
}
|
|
1703
1990
|
/**
|
|
1704
1991
|
* Gets or creates a memoized KafkaJS producer using runtime configuration.
|
|
@@ -1778,9 +2065,9 @@ var Stream = class extends TypedBase {
|
|
|
1778
2065
|
}
|
|
1779
2066
|
const {
|
|
1780
2067
|
default: { SchemaRegistry }
|
|
1781
|
-
} = await
|
|
2068
|
+
} = await Promise.resolve().then(() => __toESM(require_confluent_schema_registry(), 1));
|
|
1782
2069
|
const registry = new SchemaRegistry({ host: schemaRegistryUrl });
|
|
1783
|
-
let schemaId;
|
|
2070
|
+
let schemaId = void 0;
|
|
1784
2071
|
if ("id" in sr.reference) {
|
|
1785
2072
|
schemaId = sr.reference.id;
|
|
1786
2073
|
} else if ("subjectLatest" in sr.reference) {
|
|
@@ -1958,8 +2245,6 @@ var DeadLetterQueue = class extends Stream {
|
|
|
1958
2245
|
super.addMultiTransform(withValidate);
|
|
1959
2246
|
}
|
|
1960
2247
|
};
|
|
1961
|
-
|
|
1962
|
-
// src/dmv2/sdk/workflow.ts
|
|
1963
2248
|
var Task = class {
|
|
1964
2249
|
/**
|
|
1965
2250
|
* Creates a new Task instance.
|
|
@@ -2067,8 +2352,6 @@ var Workflow = class {
|
|
|
2067
2352
|
validateTask(startingTask, []);
|
|
2068
2353
|
}
|
|
2069
2354
|
};
|
|
2070
|
-
|
|
2071
|
-
// src/dmv2/sdk/ingestApi.ts
|
|
2072
2355
|
var IngestApi = class extends TypedBase {
|
|
2073
2356
|
constructor(name, config, schema, columns, validators, allowExtraFields) {
|
|
2074
2357
|
super(name, config, schema, columns, void 0, allowExtraFields);
|
|
@@ -2079,8 +2362,6 @@ var IngestApi = class extends TypedBase {
|
|
|
2079
2362
|
ingestApis.set(name, this);
|
|
2080
2363
|
}
|
|
2081
2364
|
};
|
|
2082
|
-
|
|
2083
|
-
// src/dmv2/sdk/consumptionApi.ts
|
|
2084
2365
|
var Api = class extends TypedBase {
|
|
2085
2366
|
/** @internal The handler function that processes requests and generates responses. */
|
|
2086
2367
|
_handler;
|
|
@@ -2187,8 +2468,6 @@ var Api = class extends TypedBase {
|
|
|
2187
2468
|
}
|
|
2188
2469
|
};
|
|
2189
2470
|
var ConsumptionApi = Api;
|
|
2190
|
-
|
|
2191
|
-
// src/dmv2/sdk/ingestPipeline.ts
|
|
2192
2471
|
var IngestPipeline = class extends TypedBase {
|
|
2193
2472
|
/**
|
|
2194
2473
|
* The OLAP table component of the pipeline, if configured.
|
|
@@ -2227,7 +2506,7 @@ var IngestPipeline = class extends TypedBase {
|
|
|
2227
2506
|
...config.version && { version: config.version }
|
|
2228
2507
|
} : {
|
|
2229
2508
|
lifeCycle: config.lifeCycle,
|
|
2230
|
-
engine: "MergeTree"
|
|
2509
|
+
engine: "MergeTree",
|
|
2231
2510
|
...config.version && { version: config.version }
|
|
2232
2511
|
};
|
|
2233
2512
|
this.table = new OlapTable(
|
|
@@ -2297,8 +2576,6 @@ var IngestPipeline = class extends TypedBase {
|
|
|
2297
2576
|
}
|
|
2298
2577
|
}
|
|
2299
2578
|
};
|
|
2300
|
-
|
|
2301
|
-
// src/dmv2/sdk/etlPipeline.ts
|
|
2302
2579
|
var InternalBatcher = class {
|
|
2303
2580
|
iterator;
|
|
2304
2581
|
batchSize;
|
|
@@ -2439,8 +2716,6 @@ var ETLPipeline = class {
|
|
|
2439
2716
|
console.log(`Completed ETL Pipeline: ${this.name}`);
|
|
2440
2717
|
}
|
|
2441
2718
|
};
|
|
2442
|
-
|
|
2443
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2444
2719
|
function formatTableReference(table) {
|
|
2445
2720
|
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2446
2721
|
if (database) {
|
|
@@ -2484,7 +2759,8 @@ var MaterializedView = class {
|
|
|
2484
2759
|
),
|
|
2485
2760
|
{
|
|
2486
2761
|
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2487
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree"
|
|
2762
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree"
|
|
2763
|
+
/* MergeTree */
|
|
2488
2764
|
},
|
|
2489
2765
|
targetSchema,
|
|
2490
2766
|
targetColumns
|
|
@@ -2515,8 +2791,6 @@ var MaterializedView = class {
|
|
|
2515
2791
|
materializedViews.set(this.name, this);
|
|
2516
2792
|
}
|
|
2517
2793
|
};
|
|
2518
|
-
|
|
2519
|
-
// src/dmv2/sdk/sqlResource.ts
|
|
2520
2794
|
var SqlResource = class {
|
|
2521
2795
|
/** @internal */
|
|
2522
2796
|
kind = "SqlResource";
|
|
@@ -2553,10 +2827,10 @@ var SqlResource = class {
|
|
|
2553
2827
|
sqlResources.set(name, this);
|
|
2554
2828
|
this.name = name;
|
|
2555
2829
|
this.setup = setup.map(
|
|
2556
|
-
(
|
|
2830
|
+
(sql3) => typeof sql3 === "string" ? sql3 : toStaticQuery(sql3)
|
|
2557
2831
|
);
|
|
2558
2832
|
this.teardown = teardown.map(
|
|
2559
|
-
(
|
|
2833
|
+
(sql3) => typeof sql3 === "string" ? sql3 : toStaticQuery(sql3)
|
|
2560
2834
|
);
|
|
2561
2835
|
this.pullsDataFrom = options?.pullsDataFrom ?? [];
|
|
2562
2836
|
this.pushesDataTo = options?.pushesDataTo ?? [];
|
|
@@ -2569,8 +2843,6 @@ var SqlResource = class {
|
|
|
2569
2843
|
}
|
|
2570
2844
|
}
|
|
2571
2845
|
};
|
|
2572
|
-
|
|
2573
|
-
// src/dmv2/sdk/view.ts
|
|
2574
2846
|
function formatTableReference2(table) {
|
|
2575
2847
|
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2576
2848
|
if (database) {
|
|
@@ -2618,16 +2890,12 @@ var View = class {
|
|
|
2618
2890
|
views.set(this.name, this);
|
|
2619
2891
|
}
|
|
2620
2892
|
};
|
|
2621
|
-
|
|
2622
|
-
// src/dmv2/sdk/lifeCycle.ts
|
|
2623
2893
|
var LifeCycle = /* @__PURE__ */ ((LifeCycle2) => {
|
|
2624
2894
|
LifeCycle2["FULLY_MANAGED"] = "FULLY_MANAGED";
|
|
2625
2895
|
LifeCycle2["DELETION_PROTECTED"] = "DELETION_PROTECTED";
|
|
2626
2896
|
LifeCycle2["EXTERNALLY_MANAGED"] = "EXTERNALLY_MANAGED";
|
|
2627
2897
|
return LifeCycle2;
|
|
2628
2898
|
})(LifeCycle || {});
|
|
2629
|
-
|
|
2630
|
-
// src/dmv2/sdk/webApp.ts
|
|
2631
2899
|
var RESERVED_MOUNT_PATHS = [
|
|
2632
2900
|
"/admin",
|
|
2633
2901
|
"/api",
|
|
@@ -2740,8 +3008,6 @@ Examples:
|
|
|
2740
3008
|
return this._rawApp;
|
|
2741
3009
|
}
|
|
2742
3010
|
};
|
|
2743
|
-
|
|
2744
|
-
// src/dmv2/registry.ts
|
|
2745
3011
|
function getTables() {
|
|
2746
3012
|
return getMooseInternal().tables;
|
|
2747
3013
|
}
|
|
@@ -2793,7 +3059,7 @@ function getSqlResources() {
|
|
|
2793
3059
|
function getSqlResource(name) {
|
|
2794
3060
|
return getMooseInternal().sqlResources.get(name);
|
|
2795
3061
|
}
|
|
2796
|
-
function
|
|
3062
|
+
function getWorkflows2() {
|
|
2797
3063
|
return getMooseInternal().workflows;
|
|
2798
3064
|
}
|
|
2799
3065
|
function getWorkflow(name) {
|
|
@@ -2817,131 +3083,7 @@ function getViews() {
|
|
|
2817
3083
|
function getView(name) {
|
|
2818
3084
|
return getMooseInternal().views.get(name);
|
|
2819
3085
|
}
|
|
2820
|
-
|
|
2821
|
-
// src/serverless.ts
|
|
2822
|
-
init_commons_types();
|
|
2823
|
-
|
|
2824
|
-
// src/connectors/dataSource.ts
|
|
2825
|
-
var DataSource = class {
|
|
2826
|
-
name;
|
|
2827
|
-
supportsIncremental;
|
|
2828
|
-
constructor(config) {
|
|
2829
|
-
this.name = config.name;
|
|
2830
|
-
this.supportsIncremental = config.supportsIncremental ?? false;
|
|
2831
|
-
}
|
|
2832
|
-
};
|
|
2833
|
-
|
|
2834
|
-
// src/secrets.ts
|
|
2835
|
-
var MOOSE_RUNTIME_ENV_PREFIX = "__MOOSE_RUNTIME_ENV__:";
|
|
2836
|
-
var mooseRuntimeEnv = {
|
|
2837
|
-
/**
|
|
2838
|
-
* Gets a value from an environment variable, with behavior depending on context.
|
|
2839
|
-
*
|
|
2840
|
-
* When IS_LOADING_INFRA_MAP=true (infrastructure loading):
|
|
2841
|
-
* Returns a marker string that Moose CLI will resolve later
|
|
2842
|
-
*
|
|
2843
|
-
* When IS_LOADING_INFRA_MAP is unset (function/workflow runtime):
|
|
2844
|
-
* Returns the actual value from the environment variable
|
|
2845
|
-
*
|
|
2846
|
-
* @param envVarName - Name of the environment variable to resolve
|
|
2847
|
-
* @returns Either a marker string or the actual environment variable value
|
|
2848
|
-
* @throws {Error} If the environment variable name is empty
|
|
2849
|
-
* @throws {Error} If the environment variable is not set (runtime mode only)
|
|
2850
|
-
*
|
|
2851
|
-
* @example
|
|
2852
|
-
* ```typescript
|
|
2853
|
-
* // Instead of this (evaluated at build time):
|
|
2854
|
-
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID
|
|
2855
|
-
*
|
|
2856
|
-
* // Use this (evaluated at runtime):
|
|
2857
|
-
* awsAccessKeyId: mooseRuntimeEnv.get("AWS_ACCESS_KEY_ID")
|
|
2858
|
-
* ```
|
|
2859
|
-
*/
|
|
2860
|
-
get(envVarName) {
|
|
2861
|
-
if (!envVarName || envVarName.trim() === "") {
|
|
2862
|
-
throw new Error("Environment variable name cannot be empty");
|
|
2863
|
-
}
|
|
2864
|
-
const isLoadingInfraMap = process.env.IS_LOADING_INFRA_MAP === "true";
|
|
2865
|
-
if (isLoadingInfraMap) {
|
|
2866
|
-
return `${MOOSE_RUNTIME_ENV_PREFIX}${envVarName}`;
|
|
2867
|
-
} else {
|
|
2868
|
-
const value = process.env[envVarName];
|
|
2869
|
-
if (value === void 0) {
|
|
2870
|
-
throw new Error(
|
|
2871
|
-
`Environment variable '${envVarName}' is not set. This is required for runtime execution of functions/workflows.`
|
|
2872
|
-
);
|
|
2873
|
-
}
|
|
2874
|
-
return value;
|
|
2875
|
-
}
|
|
2876
|
-
}
|
|
2877
|
-
};
|
|
2878
|
-
var mooseEnvSecrets = mooseRuntimeEnv;
|
|
2879
|
-
|
|
2880
|
-
// src/utilities/dataParser.ts
|
|
2881
|
-
import { parse as parse2 } from "csv-parse";
|
|
2882
|
-
|
|
2883
|
-
// src/utilities/json.ts
|
|
2884
|
-
function jsonDateReviver(key, value) {
|
|
2885
|
-
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)?)?)?)$/;
|
|
2886
|
-
if (typeof value === "string" && iso8601Format.test(value)) {
|
|
2887
|
-
return new Date(value);
|
|
2888
|
-
}
|
|
2889
|
-
return value;
|
|
2890
|
-
}
|
|
2891
|
-
|
|
2892
|
-
// src/utilities/dataParser.ts
|
|
2893
|
-
function parseCSV(content, config) {
|
|
2894
|
-
return new Promise((resolve, reject) => {
|
|
2895
|
-
const results = [];
|
|
2896
|
-
parse2(content, {
|
|
2897
|
-
delimiter: config.delimiter,
|
|
2898
|
-
columns: config.columns ?? true,
|
|
2899
|
-
skip_empty_lines: config.skipEmptyLines ?? true,
|
|
2900
|
-
trim: config.trim ?? true
|
|
2901
|
-
}).on("data", (row) => {
|
|
2902
|
-
results.push(row);
|
|
2903
|
-
}).on("end", () => {
|
|
2904
|
-
resolve(results);
|
|
2905
|
-
}).on("error", (error) => {
|
|
2906
|
-
reject(error);
|
|
2907
|
-
});
|
|
2908
|
-
});
|
|
2909
|
-
}
|
|
2910
|
-
function parseJSON(content, config = {}) {
|
|
2911
|
-
try {
|
|
2912
|
-
const parsed = JSON.parse(content, config.reviver);
|
|
2913
|
-
if (Array.isArray(parsed)) {
|
|
2914
|
-
return parsed;
|
|
2915
|
-
} else {
|
|
2916
|
-
return [parsed];
|
|
2917
|
-
}
|
|
2918
|
-
} catch (error) {
|
|
2919
|
-
throw new Error(
|
|
2920
|
-
`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
2921
|
-
);
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
function parseJSONWithDates(content) {
|
|
2925
|
-
return parseJSON(content, { reviver: jsonDateReviver });
|
|
2926
|
-
}
|
|
2927
|
-
function isValidCSVDelimiter(delimiter) {
|
|
2928
|
-
return delimiter.length === 1 && !/\s/.test(delimiter);
|
|
2929
|
-
}
|
|
2930
|
-
var CSV_DELIMITERS = {
|
|
2931
|
-
COMMA: ",",
|
|
2932
|
-
TAB: " ",
|
|
2933
|
-
SEMICOLON: ";",
|
|
2934
|
-
PIPE: "|"
|
|
2935
|
-
};
|
|
2936
|
-
var DEFAULT_CSV_CONFIG = {
|
|
2937
|
-
delimiter: CSV_DELIMITERS.COMMA,
|
|
2938
|
-
columns: true,
|
|
2939
|
-
skipEmptyLines: true,
|
|
2940
|
-
trim: true
|
|
2941
|
-
};
|
|
2942
|
-
var DEFAULT_JSON_CONFIG = {
|
|
2943
|
-
reviver: jsonDateReviver
|
|
2944
|
-
};
|
|
3086
|
+
init_commons();
|
|
2945
3087
|
export {
|
|
2946
3088
|
ACKs,
|
|
2947
3089
|
Api,
|
|
@@ -2994,7 +3136,7 @@ export {
|
|
|
2994
3136
|
getWebApp,
|
|
2995
3137
|
getWebApps,
|
|
2996
3138
|
getWorkflow,
|
|
2997
|
-
getWorkflows,
|
|
3139
|
+
getWorkflows2 as getWorkflows,
|
|
2998
3140
|
isValidCSVDelimiter,
|
|
2999
3141
|
logError,
|
|
3000
3142
|
mapToClickHouseType,
|
|
@@ -3010,4 +3152,4 @@ export {
|
|
|
3010
3152
|
toQueryPreview,
|
|
3011
3153
|
toStaticQuery
|
|
3012
3154
|
};
|
|
3013
|
-
//# sourceMappingURL=
|
|
3155
|
+
//# sourceMappingURL=index.mjs.map
|