@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
|
@@ -5,8 +5,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
return
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
10
|
};
|
|
11
11
|
var __export = (target, all) => {
|
|
12
12
|
for (var name in all)
|
|
@@ -30,256 +30,259 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
switch (value.trim().toLowerCase()) {
|
|
37
|
-
case "1":
|
|
38
|
-
case "true":
|
|
39
|
-
case "yes":
|
|
40
|
-
case "on":
|
|
41
|
-
return true;
|
|
42
|
-
default:
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function mapTstoJs(filePath) {
|
|
47
|
-
return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
|
|
48
|
-
}
|
|
49
|
-
var compilerLog, antiCachePath, getFileName, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, RETRY_FACTOR_PRODUCER, ACKs, logError;
|
|
50
|
-
var init_commons_types = __esm({
|
|
51
|
-
"src/commons-types.ts"() {
|
|
33
|
+
// stub-native:@514labs/kafka-javascript
|
|
34
|
+
var require_kafka_javascript = __commonJS({
|
|
35
|
+
"stub-native:@514labs/kafka-javascript"(exports2, module2) {
|
|
52
36
|
"use strict";
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
37
|
+
function createDeepProxy() {
|
|
38
|
+
var handler = {
|
|
39
|
+
get: function(_, prop) {
|
|
40
|
+
if (prop === "__esModule") return true;
|
|
41
|
+
if (prop === "default") return proxy;
|
|
42
|
+
if (typeof prop === "symbol") return void 0;
|
|
43
|
+
return proxy;
|
|
44
|
+
},
|
|
45
|
+
apply: function() {
|
|
46
|
+
return proxy;
|
|
47
|
+
},
|
|
48
|
+
construct: function() {
|
|
49
|
+
return proxy;
|
|
50
|
+
},
|
|
51
|
+
ownKeys: function() {
|
|
52
|
+
return ["length", "name", "prototype"];
|
|
53
|
+
},
|
|
54
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
55
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
57
|
+
}
|
|
58
|
+
return void 0;
|
|
59
|
+
},
|
|
60
|
+
getPrototypeOf: function() {
|
|
61
|
+
return proxy;
|
|
62
|
+
}
|
|
77
63
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
MAX_RETRIES_PRODUCER = 150;
|
|
84
|
-
RETRY_FACTOR_PRODUCER = 0.2;
|
|
85
|
-
ACKs = -1;
|
|
86
|
-
logError = (logger, e) => {
|
|
87
|
-
logger.error(e.message);
|
|
88
|
-
const stack = e.stack;
|
|
89
|
-
if (stack) {
|
|
90
|
-
logger.error(stack);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
64
|
+
var proxy = new Proxy(function() {
|
|
65
|
+
}, handler);
|
|
66
|
+
return proxy;
|
|
67
|
+
}
|
|
68
|
+
module2.exports = createDeepProxy();
|
|
93
69
|
}
|
|
94
70
|
});
|
|
95
71
|
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
72
|
+
// stub-native:@temporalio/client
|
|
73
|
+
var require_client = __commonJS({
|
|
74
|
+
"stub-native:@temporalio/client"(exports2, module2) {
|
|
75
|
+
"use strict";
|
|
76
|
+
function createDeepProxy() {
|
|
77
|
+
var handler = {
|
|
78
|
+
get: function(_, prop) {
|
|
79
|
+
if (prop === "__esModule") return true;
|
|
80
|
+
if (prop === "default") return proxy;
|
|
81
|
+
if (typeof prop === "symbol") return void 0;
|
|
82
|
+
return proxy;
|
|
83
|
+
},
|
|
84
|
+
apply: function() {
|
|
85
|
+
return proxy;
|
|
86
|
+
},
|
|
87
|
+
construct: function() {
|
|
88
|
+
return proxy;
|
|
89
|
+
},
|
|
90
|
+
ownKeys: function() {
|
|
91
|
+
return ["length", "name", "prototype"];
|
|
92
|
+
},
|
|
93
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
94
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
95
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
96
|
+
}
|
|
97
|
+
return void 0;
|
|
98
|
+
},
|
|
99
|
+
getPrototypeOf: function() {
|
|
100
|
+
return proxy;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var proxy = new Proxy(function() {
|
|
104
|
+
}, handler);
|
|
105
|
+
return proxy;
|
|
108
106
|
}
|
|
109
|
-
|
|
107
|
+
module2.exports = createDeepProxy();
|
|
110
108
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (!configPath) {
|
|
117
|
-
throw new ConfigError(
|
|
118
|
-
"moose.config.toml not found in current directory or any parent directory"
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
123
|
-
const config = toml.parse(configContent);
|
|
124
|
-
return config;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
throw new ConfigError(`Failed to parse moose.config.toml: ${error}`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
var import_node_path, toml, ConfigError;
|
|
130
|
-
var init_configFile = __esm({
|
|
131
|
-
"src/config/configFile.ts"() {
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// stub-native:redis
|
|
112
|
+
var require_redis = __commonJS({
|
|
113
|
+
"stub-native:redis"(exports2, module2) {
|
|
132
114
|
"use strict";
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
115
|
+
function createDeepProxy() {
|
|
116
|
+
var handler = {
|
|
117
|
+
get: function(_, prop) {
|
|
118
|
+
if (prop === "__esModule") return true;
|
|
119
|
+
if (prop === "default") return proxy;
|
|
120
|
+
if (typeof prop === "symbol") return void 0;
|
|
121
|
+
return proxy;
|
|
122
|
+
},
|
|
123
|
+
apply: function() {
|
|
124
|
+
return proxy;
|
|
125
|
+
},
|
|
126
|
+
construct: function() {
|
|
127
|
+
return proxy;
|
|
128
|
+
},
|
|
129
|
+
ownKeys: function() {
|
|
130
|
+
return ["length", "name", "prototype"];
|
|
131
|
+
},
|
|
132
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
133
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
134
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
135
|
+
}
|
|
136
|
+
return void 0;
|
|
137
|
+
},
|
|
138
|
+
getPrototypeOf: function() {
|
|
139
|
+
return proxy;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var proxy = new Proxy(function() {
|
|
143
|
+
}, handler);
|
|
144
|
+
return proxy;
|
|
145
|
+
}
|
|
146
|
+
module2.exports = createDeepProxy();
|
|
141
147
|
}
|
|
142
148
|
});
|
|
143
149
|
|
|
144
|
-
//
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
var init_runtime = __esm({
|
|
148
|
-
"src/config/runtime.ts"() {
|
|
150
|
+
// stub-native:@kafkajs/confluent-schema-registry
|
|
151
|
+
var require_confluent_schema_registry = __commonJS({
|
|
152
|
+
"stub-native:@kafkajs/confluent-schema-registry"(exports2, module2) {
|
|
149
153
|
"use strict";
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
switch (value.trim().toLowerCase()) {
|
|
176
|
-
case "1":
|
|
177
|
-
case "true":
|
|
178
|
-
case "yes":
|
|
179
|
-
case "on":
|
|
180
|
-
return true;
|
|
181
|
-
case "0":
|
|
182
|
-
case "false":
|
|
183
|
-
case "no":
|
|
184
|
-
case "off":
|
|
185
|
-
return false;
|
|
186
|
-
default:
|
|
187
|
-
return void 0;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
async getClickHouseConfig() {
|
|
191
|
-
if (this.clickhouseConfig) {
|
|
192
|
-
return this.clickhouseConfig;
|
|
193
|
-
}
|
|
194
|
-
const projectConfig = await readProjectConfig();
|
|
195
|
-
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
196
|
-
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
197
|
-
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
198
|
-
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
199
|
-
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
200
|
-
const envUseSSL = this._parseBool(
|
|
201
|
-
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
202
|
-
);
|
|
203
|
-
return {
|
|
204
|
-
host: envHost ?? projectConfig.clickhouse_config.host,
|
|
205
|
-
port: envPort ?? projectConfig.clickhouse_config.host_port.toString(),
|
|
206
|
-
username: envUser ?? projectConfig.clickhouse_config.user,
|
|
207
|
-
password: envPassword ?? projectConfig.clickhouse_config.password,
|
|
208
|
-
database: envDb ?? projectConfig.clickhouse_config.db_name,
|
|
209
|
-
useSSL: envUseSSL !== void 0 ? envUseSSL : projectConfig.clickhouse_config.use_ssl || false
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
async getStandaloneClickhouseConfig(overrides) {
|
|
213
|
-
if (this.clickhouseConfig) {
|
|
214
|
-
return { ...this.clickhouseConfig, ...overrides };
|
|
215
|
-
}
|
|
216
|
-
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
217
|
-
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
218
|
-
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
219
|
-
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
220
|
-
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
221
|
-
const envUseSSL = this._parseBool(
|
|
222
|
-
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
223
|
-
);
|
|
224
|
-
let projectConfig;
|
|
225
|
-
try {
|
|
226
|
-
projectConfig = await readProjectConfig();
|
|
227
|
-
} catch (error) {
|
|
228
|
-
projectConfig = null;
|
|
229
|
-
}
|
|
230
|
-
const defaults = {
|
|
231
|
-
host: "localhost",
|
|
232
|
-
port: "18123",
|
|
233
|
-
username: "default",
|
|
234
|
-
password: "",
|
|
235
|
-
database: "local",
|
|
236
|
-
useSSL: false
|
|
237
|
-
};
|
|
238
|
-
return {
|
|
239
|
-
host: overrides?.host ?? envHost ?? projectConfig?.clickhouse_config.host ?? defaults.host,
|
|
240
|
-
port: overrides?.port ?? envPort ?? projectConfig?.clickhouse_config.host_port.toString() ?? defaults.port,
|
|
241
|
-
username: overrides?.username ?? envUser ?? projectConfig?.clickhouse_config.user ?? defaults.username,
|
|
242
|
-
password: overrides?.password ?? envPassword ?? projectConfig?.clickhouse_config.password ?? defaults.password,
|
|
243
|
-
database: overrides?.database ?? envDb ?? projectConfig?.clickhouse_config.db_name ?? defaults.database,
|
|
244
|
-
useSSL: overrides?.useSSL ?? envUseSSL ?? projectConfig?.clickhouse_config.use_ssl ?? defaults.useSSL
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
async getKafkaConfig() {
|
|
248
|
-
if (this.kafkaConfig) {
|
|
249
|
-
return this.kafkaConfig;
|
|
154
|
+
function createDeepProxy() {
|
|
155
|
+
var handler = {
|
|
156
|
+
get: function(_, prop) {
|
|
157
|
+
if (prop === "__esModule") return true;
|
|
158
|
+
if (prop === "default") return proxy;
|
|
159
|
+
if (typeof prop === "symbol") return void 0;
|
|
160
|
+
return proxy;
|
|
161
|
+
},
|
|
162
|
+
apply: function() {
|
|
163
|
+
return proxy;
|
|
164
|
+
},
|
|
165
|
+
construct: function() {
|
|
166
|
+
return proxy;
|
|
167
|
+
},
|
|
168
|
+
ownKeys: function() {
|
|
169
|
+
return ["length", "name", "prototype"];
|
|
170
|
+
},
|
|
171
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
172
|
+
if (prop === "length" || prop === "name" || prop === "prototype") {
|
|
173
|
+
return Object.getOwnPropertyDescriptor(target, prop);
|
|
174
|
+
}
|
|
175
|
+
return void 0;
|
|
176
|
+
},
|
|
177
|
+
getPrototypeOf: function() {
|
|
178
|
+
return proxy;
|
|
250
179
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const envSecurityProtocol = this._env("MOOSE_REDPANDA_CONFIG__SECURITY_PROTOCOL") ?? this._env("MOOSE_KAFKA_CONFIG__SECURITY_PROTOCOL");
|
|
258
|
-
const envNamespace = this._env("MOOSE_REDPANDA_CONFIG__NAMESPACE") ?? this._env("MOOSE_KAFKA_CONFIG__NAMESPACE");
|
|
259
|
-
const envSchemaRegistryUrl = this._env("MOOSE_REDPANDA_CONFIG__SCHEMA_REGISTRY_URL") ?? this._env("MOOSE_KAFKA_CONFIG__SCHEMA_REGISTRY_URL");
|
|
260
|
-
const fileKafka = projectConfig.kafka_config ?? projectConfig.redpanda_config;
|
|
261
|
-
return {
|
|
262
|
-
broker: envBroker ?? fileKafka?.broker ?? "localhost:19092",
|
|
263
|
-
messageTimeoutMs: envMsgTimeout ? parseInt(envMsgTimeout, 10) : fileKafka?.message_timeout_ms ?? 1e3,
|
|
264
|
-
saslUsername: envSaslUsername ?? fileKafka?.sasl_username,
|
|
265
|
-
saslPassword: envSaslPassword ?? fileKafka?.sasl_password,
|
|
266
|
-
saslMechanism: envSaslMechanism ?? fileKafka?.sasl_mechanism,
|
|
267
|
-
securityProtocol: envSecurityProtocol ?? fileKafka?.security_protocol,
|
|
268
|
-
namespace: envNamespace ?? fileKafka?.namespace,
|
|
269
|
-
schemaRegistryUrl: envSchemaRegistryUrl ?? fileKafka?.schema_registry_url
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
hasRuntimeConfig() {
|
|
273
|
-
return !!this.clickhouseConfig || !!this.kafkaConfig;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
globalThis._mooseConfigRegistry = ConfigurationRegistry.getInstance();
|
|
180
|
+
};
|
|
181
|
+
var proxy = new Proxy(function() {
|
|
182
|
+
}, handler);
|
|
183
|
+
return proxy;
|
|
184
|
+
}
|
|
185
|
+
module2.exports = createDeepProxy();
|
|
277
186
|
}
|
|
278
187
|
});
|
|
279
188
|
|
|
280
|
-
// src/
|
|
189
|
+
// src/index.ts
|
|
190
|
+
var index_exports = {};
|
|
191
|
+
__export(index_exports, {
|
|
192
|
+
ACKs: () => ACKs,
|
|
193
|
+
Api: () => Api,
|
|
194
|
+
CSV_DELIMITERS: () => CSV_DELIMITERS,
|
|
195
|
+
ClickHouseEngines: () => ClickHouseEngines,
|
|
196
|
+
ConsumptionApi: () => ConsumptionApi,
|
|
197
|
+
DEFAULT_CSV_CONFIG: () => DEFAULT_CSV_CONFIG,
|
|
198
|
+
DEFAULT_JSON_CONFIG: () => DEFAULT_JSON_CONFIG,
|
|
199
|
+
DataSource: () => DataSource,
|
|
200
|
+
DeadLetterQueue: () => DeadLetterQueue,
|
|
201
|
+
ETLPipeline: () => ETLPipeline,
|
|
202
|
+
IngestApi: () => IngestApi,
|
|
203
|
+
IngestPipeline: () => IngestPipeline,
|
|
204
|
+
LifeCycle: () => LifeCycle,
|
|
205
|
+
MAX_RETRIES: () => MAX_RETRIES,
|
|
206
|
+
MAX_RETRIES_PRODUCER: () => MAX_RETRIES_PRODUCER,
|
|
207
|
+
MAX_RETRY_TIME_MS: () => MAX_RETRY_TIME_MS,
|
|
208
|
+
MOOSE_RUNTIME_ENV_PREFIX: () => MOOSE_RUNTIME_ENV_PREFIX,
|
|
209
|
+
MaterializedView: () => MaterializedView,
|
|
210
|
+
OlapTable: () => OlapTable,
|
|
211
|
+
RETRY_FACTOR_PRODUCER: () => RETRY_FACTOR_PRODUCER,
|
|
212
|
+
RETRY_INITIAL_TIME_MS: () => RETRY_INITIAL_TIME_MS,
|
|
213
|
+
Sql: () => Sql,
|
|
214
|
+
SqlResource: () => SqlResource,
|
|
215
|
+
Stream: () => Stream,
|
|
216
|
+
Task: () => Task,
|
|
217
|
+
View: () => View,
|
|
218
|
+
WebApp: () => WebApp,
|
|
219
|
+
Workflow: () => Workflow,
|
|
220
|
+
antiCachePath: () => antiCachePath,
|
|
221
|
+
cliLog: () => cliLog,
|
|
222
|
+
compilerLog: () => compilerLog,
|
|
223
|
+
createClickhouseParameter: () => createClickhouseParameter,
|
|
224
|
+
getApi: () => getApi,
|
|
225
|
+
getApis: () => getApis,
|
|
226
|
+
getFileName: () => getFileName,
|
|
227
|
+
getIngestApi: () => getIngestApi,
|
|
228
|
+
getIngestApis: () => getIngestApis,
|
|
229
|
+
getMaterializedView: () => getMaterializedView,
|
|
230
|
+
getMaterializedViews: () => getMaterializedViews,
|
|
231
|
+
getSqlResource: () => getSqlResource,
|
|
232
|
+
getSqlResources: () => getSqlResources,
|
|
233
|
+
getStream: () => getStream,
|
|
234
|
+
getStreams: () => getStreams,
|
|
235
|
+
getTable: () => getTable,
|
|
236
|
+
getTables: () => getTables,
|
|
237
|
+
getValueFromParameter: () => getValueFromParameter,
|
|
238
|
+
getView: () => getView,
|
|
239
|
+
getViews: () => getViews,
|
|
240
|
+
getWebApp: () => getWebApp,
|
|
241
|
+
getWebApps: () => getWebApps,
|
|
242
|
+
getWorkflow: () => getWorkflow,
|
|
243
|
+
getWorkflows: () => getWorkflows2,
|
|
244
|
+
isValidCSVDelimiter: () => isValidCSVDelimiter,
|
|
245
|
+
logError: () => logError,
|
|
246
|
+
mapToClickHouseType: () => mapToClickHouseType,
|
|
247
|
+
mapTstoJs: () => mapTstoJs,
|
|
248
|
+
mooseEnvSecrets: () => mooseEnvSecrets,
|
|
249
|
+
mooseRuntimeEnv: () => mooseRuntimeEnv,
|
|
250
|
+
parseCSV: () => parseCSV,
|
|
251
|
+
parseJSON: () => parseJSON,
|
|
252
|
+
parseJSONWithDates: () => parseJSONWithDates,
|
|
253
|
+
quoteIdentifier: () => quoteIdentifier,
|
|
254
|
+
sql: () => sql,
|
|
255
|
+
toQuery: () => toQuery,
|
|
256
|
+
toQueryPreview: () => toQueryPreview,
|
|
257
|
+
toStaticQuery: () => toStaticQuery
|
|
258
|
+
});
|
|
259
|
+
module.exports = __toCommonJS(index_exports);
|
|
260
|
+
|
|
261
|
+
// ../ts-moose-lib/dist/serverless.mjs
|
|
262
|
+
var import_fs = require("fs");
|
|
263
|
+
var import_path = __toESM(require("path"), 1);
|
|
264
|
+
var import_client = require("@clickhouse/client");
|
|
265
|
+
var import_kafka_javascript = __toESM(require_kafka_javascript(), 1);
|
|
266
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
267
|
+
var toml = __toESM(require("toml"), 1);
|
|
268
|
+
var import_process = __toESM(require("process"), 1);
|
|
269
|
+
var import_client2 = __toESM(require_client(), 1);
|
|
270
|
+
var import_redis = __toESM(require_redis(), 1);
|
|
271
|
+
var import_csv_parse = require("csv-parse");
|
|
272
|
+
var import_stream = require("stream");
|
|
273
|
+
var import_crypto = require("crypto");
|
|
274
|
+
var import_crypto2 = require("crypto");
|
|
275
|
+
var __defProp2 = Object.defineProperty;
|
|
276
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
277
|
+
var __esm = (fn, res) => function __init() {
|
|
278
|
+
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
279
|
+
};
|
|
280
|
+
var __export2 = (target, all) => {
|
|
281
|
+
for (var name in all)
|
|
282
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
283
|
+
};
|
|
281
284
|
var commons_exports = {};
|
|
282
|
-
|
|
285
|
+
__export2(commons_exports, {
|
|
283
286
|
ACKs: () => ACKs,
|
|
284
287
|
MAX_RETRIES: () => MAX_RETRIES,
|
|
285
288
|
MAX_RETRIES_PRODUCER: () => MAX_RETRIES_PRODUCER,
|
|
@@ -298,6 +301,21 @@ __export(commons_exports, {
|
|
|
298
301
|
mapTstoJs: () => mapTstoJs,
|
|
299
302
|
rewriteImportExtensions: () => rewriteImportExtensions
|
|
300
303
|
});
|
|
304
|
+
function isTruthy(value) {
|
|
305
|
+
if (!value) return false;
|
|
306
|
+
switch (value.trim().toLowerCase()) {
|
|
307
|
+
case "1":
|
|
308
|
+
case "true":
|
|
309
|
+
case "yes":
|
|
310
|
+
case "on":
|
|
311
|
+
return true;
|
|
312
|
+
default:
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function mapTstoJs(filePath) {
|
|
317
|
+
return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
|
|
318
|
+
}
|
|
301
319
|
function walkDirectory(dir, extensions) {
|
|
302
320
|
const results = [];
|
|
303
321
|
if (!(0, import_fs.existsSync)(dir)) {
|
|
@@ -408,17 +426,40 @@ async function getKafkaProducer(cfg, logger, maxMessageBytes) {
|
|
|
408
426
|
await producer.connect();
|
|
409
427
|
return producer;
|
|
410
428
|
}
|
|
411
|
-
var
|
|
429
|
+
var Kafka;
|
|
430
|
+
var compilerLog;
|
|
431
|
+
var antiCachePath;
|
|
432
|
+
var getFileName;
|
|
433
|
+
var getClickhouseClient;
|
|
434
|
+
var cliLog;
|
|
435
|
+
var MAX_RETRIES;
|
|
436
|
+
var MAX_RETRY_TIME_MS;
|
|
437
|
+
var RETRY_INITIAL_TIME_MS;
|
|
438
|
+
var MAX_RETRIES_PRODUCER;
|
|
439
|
+
var RETRY_FACTOR_PRODUCER;
|
|
440
|
+
var ACKs;
|
|
441
|
+
var parseBrokerString;
|
|
442
|
+
var logError;
|
|
443
|
+
var buildSaslConfig;
|
|
444
|
+
var getKafkaClient;
|
|
412
445
|
var init_commons = __esm({
|
|
413
446
|
"src/commons.ts"() {
|
|
414
447
|
"use strict";
|
|
415
|
-
init_commons_types();
|
|
416
|
-
import_kafka_javascript = require("@514labs/kafka-javascript");
|
|
417
|
-
import_client = require("@clickhouse/client");
|
|
418
|
-
import_fs = require("fs");
|
|
419
|
-
import_path = __toESM(require("path"));
|
|
420
|
-
init_commons_types();
|
|
421
448
|
({ Kafka } = import_kafka_javascript.KafkaJS);
|
|
449
|
+
compilerLog = (message) => {
|
|
450
|
+
if (!isTruthy(process.env.MOOSE_DISABLE_COMPILER_LOGS)) {
|
|
451
|
+
console.log(message);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
antiCachePath = (path2) => `${path2}?num=${Math.random().toString()}&time=${Date.now()}`;
|
|
455
|
+
getFileName = (filePath) => {
|
|
456
|
+
const regex = /\/([^\/]+)\.ts/;
|
|
457
|
+
const matches = filePath.match(regex);
|
|
458
|
+
if (matches && matches.length > 1) {
|
|
459
|
+
return matches[1];
|
|
460
|
+
}
|
|
461
|
+
return "";
|
|
462
|
+
};
|
|
422
463
|
getClickhouseClient = ({
|
|
423
464
|
username,
|
|
424
465
|
password,
|
|
@@ -439,7 +480,33 @@ var init_commons = __esm({
|
|
|
439
480
|
// to preserve SELECT query performance while ensuring INSERT/DDL reliability
|
|
440
481
|
});
|
|
441
482
|
};
|
|
483
|
+
cliLog = (log) => {
|
|
484
|
+
const level = log.message_type === "Error" ? "error" : log.message_type === "Warning" ? "warn" : "info";
|
|
485
|
+
const structuredLog = {
|
|
486
|
+
__moose_structured_log__: true,
|
|
487
|
+
level,
|
|
488
|
+
message: log.message,
|
|
489
|
+
resource_type: "runtime",
|
|
490
|
+
cli_action: log.action,
|
|
491
|
+
cli_message_type: log.message_type ?? "Info",
|
|
492
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
493
|
+
};
|
|
494
|
+
process.stderr.write(JSON.stringify(structuredLog) + "\n");
|
|
495
|
+
};
|
|
496
|
+
MAX_RETRIES = 150;
|
|
497
|
+
MAX_RETRY_TIME_MS = 1e3;
|
|
498
|
+
RETRY_INITIAL_TIME_MS = 100;
|
|
499
|
+
MAX_RETRIES_PRODUCER = 150;
|
|
500
|
+
RETRY_FACTOR_PRODUCER = 0.2;
|
|
501
|
+
ACKs = -1;
|
|
442
502
|
parseBrokerString = (brokerString) => brokerString.split(",").map((b) => b.trim()).filter((b) => b.length > 0);
|
|
503
|
+
logError = (logger, e) => {
|
|
504
|
+
logger.error(e.message);
|
|
505
|
+
const stack = e.stack;
|
|
506
|
+
if (stack) {
|
|
507
|
+
logger.error(stack);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
443
510
|
buildSaslConfig = (logger, args) => {
|
|
444
511
|
const mechanism = args.saslMechanism ? args.saslMechanism.toLowerCase() : "";
|
|
445
512
|
switch (mechanism) {
|
|
@@ -461,124 +528,204 @@ var init_commons = __esm({
|
|
|
461
528
|
if (brokers.length === 0) {
|
|
462
529
|
throw new Error(`No valid broker addresses found in: "${cfg.broker}"`);
|
|
463
530
|
}
|
|
464
|
-
logger.log(`Creating Kafka client with brokers: ${brokers.join(", ")}`);
|
|
465
|
-
logger.log(`Security protocol: ${cfg.securityProtocol || "plaintext"}`);
|
|
466
|
-
logger.log(`Client ID: ${cfg.clientId}`);
|
|
467
|
-
const saslConfig = buildSaslConfig(logger, cfg);
|
|
468
|
-
return new Kafka({
|
|
469
|
-
kafkaJS: {
|
|
470
|
-
clientId: cfg.clientId,
|
|
471
|
-
brokers,
|
|
472
|
-
ssl: cfg.securityProtocol === "SASL_SSL",
|
|
473
|
-
...saslConfig && { sasl: saslConfig },
|
|
474
|
-
retry: {
|
|
475
|
-
initialRetryTime: RETRY_INITIAL_TIME_MS,
|
|
476
|
-
maxRetryTime: MAX_RETRY_TIME_MS,
|
|
477
|
-
retries: MAX_RETRIES
|
|
478
|
-
}
|
|
531
|
+
logger.log(`Creating Kafka client with brokers: ${brokers.join(", ")}`);
|
|
532
|
+
logger.log(`Security protocol: ${cfg.securityProtocol || "plaintext"}`);
|
|
533
|
+
logger.log(`Client ID: ${cfg.clientId}`);
|
|
534
|
+
const saslConfig = buildSaslConfig(logger, cfg);
|
|
535
|
+
return new Kafka({
|
|
536
|
+
kafkaJS: {
|
|
537
|
+
clientId: cfg.clientId,
|
|
538
|
+
brokers,
|
|
539
|
+
ssl: cfg.securityProtocol === "SASL_SSL",
|
|
540
|
+
...saslConfig && { sasl: saslConfig },
|
|
541
|
+
retry: {
|
|
542
|
+
initialRetryTime: RETRY_INITIAL_TIME_MS,
|
|
543
|
+
maxRetryTime: MAX_RETRY_TIME_MS,
|
|
544
|
+
retries: MAX_RETRIES
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
async function findConfigFile(startDir = process.cwd()) {
|
|
552
|
+
const fs = await import("fs");
|
|
553
|
+
let currentDir = import_path2.default.resolve(startDir);
|
|
554
|
+
while (true) {
|
|
555
|
+
const configPath = import_path2.default.join(currentDir, "moose.config.toml");
|
|
556
|
+
if (fs.existsSync(configPath)) {
|
|
557
|
+
return configPath;
|
|
558
|
+
}
|
|
559
|
+
const parentDir = import_path2.default.dirname(currentDir);
|
|
560
|
+
if (parentDir === currentDir) {
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
currentDir = parentDir;
|
|
564
|
+
}
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
async function readProjectConfig() {
|
|
568
|
+
const fs = await import("fs");
|
|
569
|
+
const configPath = await findConfigFile();
|
|
570
|
+
if (!configPath) {
|
|
571
|
+
throw new ConfigError(
|
|
572
|
+
"moose.config.toml not found in current directory or any parent directory"
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
try {
|
|
576
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
577
|
+
const config = toml.parse(configContent);
|
|
578
|
+
return config;
|
|
579
|
+
} catch (error) {
|
|
580
|
+
throw new ConfigError(`Failed to parse moose.config.toml: ${error}`);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
var ConfigError;
|
|
584
|
+
var init_configFile = __esm({
|
|
585
|
+
"src/config/configFile.ts"() {
|
|
586
|
+
"use strict";
|
|
587
|
+
ConfigError = class extends Error {
|
|
588
|
+
constructor(message) {
|
|
589
|
+
super(message);
|
|
590
|
+
this.name = "ConfigError";
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
var runtime_exports = {};
|
|
596
|
+
var ConfigurationRegistry;
|
|
597
|
+
var init_runtime = __esm({
|
|
598
|
+
"src/config/runtime.ts"() {
|
|
599
|
+
"use strict";
|
|
600
|
+
init_configFile();
|
|
601
|
+
ConfigurationRegistry = class _ConfigurationRegistry {
|
|
602
|
+
static instance;
|
|
603
|
+
clickhouseConfig;
|
|
604
|
+
kafkaConfig;
|
|
605
|
+
static getInstance() {
|
|
606
|
+
if (!_ConfigurationRegistry.instance) {
|
|
607
|
+
_ConfigurationRegistry.instance = new _ConfigurationRegistry();
|
|
608
|
+
}
|
|
609
|
+
return _ConfigurationRegistry.instance;
|
|
610
|
+
}
|
|
611
|
+
setClickHouseConfig(config) {
|
|
612
|
+
this.clickhouseConfig = config;
|
|
613
|
+
}
|
|
614
|
+
setKafkaConfig(config) {
|
|
615
|
+
this.kafkaConfig = config;
|
|
616
|
+
}
|
|
617
|
+
_env(name) {
|
|
618
|
+
const value = process.env[name];
|
|
619
|
+
if (value === void 0) return void 0;
|
|
620
|
+
const trimmed = value.trim();
|
|
621
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
622
|
+
}
|
|
623
|
+
_parseBool(value) {
|
|
624
|
+
if (value === void 0) return void 0;
|
|
625
|
+
switch (value.trim().toLowerCase()) {
|
|
626
|
+
case "1":
|
|
627
|
+
case "true":
|
|
628
|
+
case "yes":
|
|
629
|
+
case "on":
|
|
630
|
+
return true;
|
|
631
|
+
case "0":
|
|
632
|
+
case "false":
|
|
633
|
+
case "no":
|
|
634
|
+
case "off":
|
|
635
|
+
return false;
|
|
636
|
+
default:
|
|
637
|
+
return void 0;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async getClickHouseConfig() {
|
|
641
|
+
if (this.clickhouseConfig) {
|
|
642
|
+
return this.clickhouseConfig;
|
|
643
|
+
}
|
|
644
|
+
const projectConfig = await readProjectConfig();
|
|
645
|
+
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
646
|
+
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
647
|
+
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
648
|
+
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
649
|
+
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
650
|
+
const envUseSSL = this._parseBool(
|
|
651
|
+
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
652
|
+
);
|
|
653
|
+
return {
|
|
654
|
+
host: envHost ?? projectConfig.clickhouse_config.host,
|
|
655
|
+
port: envPort ?? projectConfig.clickhouse_config.host_port.toString(),
|
|
656
|
+
username: envUser ?? projectConfig.clickhouse_config.user,
|
|
657
|
+
password: envPassword ?? projectConfig.clickhouse_config.password,
|
|
658
|
+
database: envDb ?? projectConfig.clickhouse_config.db_name,
|
|
659
|
+
useSSL: envUseSSL !== void 0 ? envUseSSL : projectConfig.clickhouse_config.use_ssl || false
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
async getStandaloneClickhouseConfig(overrides) {
|
|
663
|
+
if (this.clickhouseConfig) {
|
|
664
|
+
return { ...this.clickhouseConfig, ...overrides };
|
|
665
|
+
}
|
|
666
|
+
const envHost = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST");
|
|
667
|
+
const envPort = this._env("MOOSE_CLICKHOUSE_CONFIG__HOST_PORT");
|
|
668
|
+
const envUser = this._env("MOOSE_CLICKHOUSE_CONFIG__USER");
|
|
669
|
+
const envPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__PASSWORD");
|
|
670
|
+
const envDb = this._env("MOOSE_CLICKHOUSE_CONFIG__DB_NAME");
|
|
671
|
+
const envUseSSL = this._parseBool(
|
|
672
|
+
this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
|
|
673
|
+
);
|
|
674
|
+
let projectConfig;
|
|
675
|
+
try {
|
|
676
|
+
projectConfig = await readProjectConfig();
|
|
677
|
+
} catch (error) {
|
|
678
|
+
projectConfig = null;
|
|
679
|
+
}
|
|
680
|
+
const defaults = {
|
|
681
|
+
host: "localhost",
|
|
682
|
+
port: "18123",
|
|
683
|
+
username: "default",
|
|
684
|
+
password: "",
|
|
685
|
+
database: "local",
|
|
686
|
+
useSSL: false
|
|
687
|
+
};
|
|
688
|
+
return {
|
|
689
|
+
host: overrides?.host ?? envHost ?? projectConfig?.clickhouse_config.host ?? defaults.host,
|
|
690
|
+
port: overrides?.port ?? envPort ?? projectConfig?.clickhouse_config.host_port.toString() ?? defaults.port,
|
|
691
|
+
username: overrides?.username ?? envUser ?? projectConfig?.clickhouse_config.user ?? defaults.username,
|
|
692
|
+
password: overrides?.password ?? envPassword ?? projectConfig?.clickhouse_config.password ?? defaults.password,
|
|
693
|
+
database: overrides?.database ?? envDb ?? projectConfig?.clickhouse_config.db_name ?? defaults.database,
|
|
694
|
+
useSSL: overrides?.useSSL ?? envUseSSL ?? projectConfig?.clickhouse_config.use_ssl ?? defaults.useSSL
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
async getKafkaConfig() {
|
|
698
|
+
if (this.kafkaConfig) {
|
|
699
|
+
return this.kafkaConfig;
|
|
479
700
|
}
|
|
480
|
-
|
|
701
|
+
const projectConfig = await readProjectConfig();
|
|
702
|
+
const envBroker = this._env("MOOSE_REDPANDA_CONFIG__BROKER") ?? this._env("MOOSE_KAFKA_CONFIG__BROKER");
|
|
703
|
+
const envMsgTimeout = this._env("MOOSE_REDPANDA_CONFIG__MESSAGE_TIMEOUT_MS") ?? this._env("MOOSE_KAFKA_CONFIG__MESSAGE_TIMEOUT_MS");
|
|
704
|
+
const envSaslUsername = this._env("MOOSE_REDPANDA_CONFIG__SASL_USERNAME") ?? this._env("MOOSE_KAFKA_CONFIG__SASL_USERNAME");
|
|
705
|
+
const envSaslPassword = this._env("MOOSE_REDPANDA_CONFIG__SASL_PASSWORD") ?? this._env("MOOSE_KAFKA_CONFIG__SASL_PASSWORD");
|
|
706
|
+
const envSaslMechanism = this._env("MOOSE_REDPANDA_CONFIG__SASL_MECHANISM") ?? this._env("MOOSE_KAFKA_CONFIG__SASL_MECHANISM");
|
|
707
|
+
const envSecurityProtocol = this._env("MOOSE_REDPANDA_CONFIG__SECURITY_PROTOCOL") ?? this._env("MOOSE_KAFKA_CONFIG__SECURITY_PROTOCOL");
|
|
708
|
+
const envNamespace = this._env("MOOSE_REDPANDA_CONFIG__NAMESPACE") ?? this._env("MOOSE_KAFKA_CONFIG__NAMESPACE");
|
|
709
|
+
const envSchemaRegistryUrl = this._env("MOOSE_REDPANDA_CONFIG__SCHEMA_REGISTRY_URL") ?? this._env("MOOSE_KAFKA_CONFIG__SCHEMA_REGISTRY_URL");
|
|
710
|
+
const fileKafka = projectConfig.kafka_config ?? projectConfig.redpanda_config;
|
|
711
|
+
return {
|
|
712
|
+
broker: envBroker ?? fileKafka?.broker ?? "localhost:19092",
|
|
713
|
+
messageTimeoutMs: envMsgTimeout ? parseInt(envMsgTimeout, 10) : fileKafka?.message_timeout_ms ?? 1e3,
|
|
714
|
+
saslUsername: envSaslUsername ?? fileKafka?.sasl_username,
|
|
715
|
+
saslPassword: envSaslPassword ?? fileKafka?.sasl_password,
|
|
716
|
+
saslMechanism: envSaslMechanism ?? fileKafka?.sasl_mechanism,
|
|
717
|
+
securityProtocol: envSecurityProtocol ?? fileKafka?.security_protocol,
|
|
718
|
+
namespace: envNamespace ?? fileKafka?.namespace,
|
|
719
|
+
schemaRegistryUrl: envSchemaRegistryUrl ?? fileKafka?.schema_registry_url
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
hasRuntimeConfig() {
|
|
723
|
+
return !!this.clickhouseConfig || !!this.kafkaConfig;
|
|
724
|
+
}
|
|
481
725
|
};
|
|
726
|
+
globalThis._mooseConfigRegistry = ConfigurationRegistry.getInstance();
|
|
482
727
|
}
|
|
483
728
|
});
|
|
484
|
-
|
|
485
|
-
// src/serverless.ts
|
|
486
|
-
var serverless_exports = {};
|
|
487
|
-
__export(serverless_exports, {
|
|
488
|
-
ACKs: () => ACKs,
|
|
489
|
-
Api: () => Api,
|
|
490
|
-
CSV_DELIMITERS: () => CSV_DELIMITERS,
|
|
491
|
-
ClickHouseEngines: () => ClickHouseEngines,
|
|
492
|
-
ConsumptionApi: () => ConsumptionApi,
|
|
493
|
-
DEFAULT_CSV_CONFIG: () => DEFAULT_CSV_CONFIG,
|
|
494
|
-
DEFAULT_JSON_CONFIG: () => DEFAULT_JSON_CONFIG,
|
|
495
|
-
DataSource: () => DataSource,
|
|
496
|
-
DeadLetterQueue: () => DeadLetterQueue,
|
|
497
|
-
ETLPipeline: () => ETLPipeline,
|
|
498
|
-
IngestApi: () => IngestApi,
|
|
499
|
-
IngestPipeline: () => IngestPipeline,
|
|
500
|
-
LifeCycle: () => LifeCycle,
|
|
501
|
-
MAX_RETRIES: () => MAX_RETRIES,
|
|
502
|
-
MAX_RETRIES_PRODUCER: () => MAX_RETRIES_PRODUCER,
|
|
503
|
-
MAX_RETRY_TIME_MS: () => MAX_RETRY_TIME_MS,
|
|
504
|
-
MOOSE_RUNTIME_ENV_PREFIX: () => MOOSE_RUNTIME_ENV_PREFIX,
|
|
505
|
-
MaterializedView: () => MaterializedView,
|
|
506
|
-
OlapTable: () => OlapTable,
|
|
507
|
-
RETRY_FACTOR_PRODUCER: () => RETRY_FACTOR_PRODUCER,
|
|
508
|
-
RETRY_INITIAL_TIME_MS: () => RETRY_INITIAL_TIME_MS,
|
|
509
|
-
Sql: () => Sql,
|
|
510
|
-
SqlResource: () => SqlResource,
|
|
511
|
-
Stream: () => Stream,
|
|
512
|
-
Task: () => Task,
|
|
513
|
-
View: () => View,
|
|
514
|
-
WebApp: () => WebApp,
|
|
515
|
-
Workflow: () => Workflow,
|
|
516
|
-
antiCachePath: () => antiCachePath,
|
|
517
|
-
cliLog: () => cliLog,
|
|
518
|
-
compilerLog: () => compilerLog,
|
|
519
|
-
createClickhouseParameter: () => createClickhouseParameter,
|
|
520
|
-
getApi: () => getApi,
|
|
521
|
-
getApis: () => getApis,
|
|
522
|
-
getFileName: () => getFileName,
|
|
523
|
-
getIngestApi: () => getIngestApi,
|
|
524
|
-
getIngestApis: () => getIngestApis,
|
|
525
|
-
getMaterializedView: () => getMaterializedView,
|
|
526
|
-
getMaterializedViews: () => getMaterializedViews,
|
|
527
|
-
getSqlResource: () => getSqlResource,
|
|
528
|
-
getSqlResources: () => getSqlResources,
|
|
529
|
-
getStream: () => getStream,
|
|
530
|
-
getStreams: () => getStreams,
|
|
531
|
-
getTable: () => getTable,
|
|
532
|
-
getTables: () => getTables,
|
|
533
|
-
getValueFromParameter: () => getValueFromParameter,
|
|
534
|
-
getView: () => getView,
|
|
535
|
-
getViews: () => getViews,
|
|
536
|
-
getWebApp: () => getWebApp,
|
|
537
|
-
getWebApps: () => getWebApps,
|
|
538
|
-
getWorkflow: () => getWorkflow,
|
|
539
|
-
getWorkflows: () => getWorkflows,
|
|
540
|
-
isValidCSVDelimiter: () => isValidCSVDelimiter,
|
|
541
|
-
logError: () => logError,
|
|
542
|
-
mapToClickHouseType: () => mapToClickHouseType,
|
|
543
|
-
mapTstoJs: () => mapTstoJs,
|
|
544
|
-
mooseEnvSecrets: () => mooseEnvSecrets,
|
|
545
|
-
mooseRuntimeEnv: () => mooseRuntimeEnv,
|
|
546
|
-
parseCSV: () => parseCSV,
|
|
547
|
-
parseJSON: () => parseJSON,
|
|
548
|
-
parseJSONWithDates: () => parseJSONWithDates,
|
|
549
|
-
quoteIdentifier: () => quoteIdentifier,
|
|
550
|
-
sql: () => sql,
|
|
551
|
-
toQuery: () => toQuery,
|
|
552
|
-
toQueryPreview: () => toQueryPreview,
|
|
553
|
-
toStaticQuery: () => toStaticQuery
|
|
554
|
-
});
|
|
555
|
-
module.exports = __toCommonJS(serverless_exports);
|
|
556
|
-
|
|
557
|
-
// src/dataModels/types.ts
|
|
558
|
-
var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
|
|
559
|
-
ClickHouseEngines2["MergeTree"] = "MergeTree";
|
|
560
|
-
ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
|
|
561
|
-
ClickHouseEngines2["SummingMergeTree"] = "SummingMergeTree";
|
|
562
|
-
ClickHouseEngines2["AggregatingMergeTree"] = "AggregatingMergeTree";
|
|
563
|
-
ClickHouseEngines2["CollapsingMergeTree"] = "CollapsingMergeTree";
|
|
564
|
-
ClickHouseEngines2["VersionedCollapsingMergeTree"] = "VersionedCollapsingMergeTree";
|
|
565
|
-
ClickHouseEngines2["GraphiteMergeTree"] = "GraphiteMergeTree";
|
|
566
|
-
ClickHouseEngines2["S3Queue"] = "S3Queue";
|
|
567
|
-
ClickHouseEngines2["S3"] = "S3";
|
|
568
|
-
ClickHouseEngines2["Buffer"] = "Buffer";
|
|
569
|
-
ClickHouseEngines2["Distributed"] = "Distributed";
|
|
570
|
-
ClickHouseEngines2["IcebergS3"] = "IcebergS3";
|
|
571
|
-
ClickHouseEngines2["Kafka"] = "Kafka";
|
|
572
|
-
ClickHouseEngines2["ReplicatedMergeTree"] = "ReplicatedMergeTree";
|
|
573
|
-
ClickHouseEngines2["ReplicatedReplacingMergeTree"] = "ReplicatedReplacingMergeTree";
|
|
574
|
-
ClickHouseEngines2["ReplicatedAggregatingMergeTree"] = "ReplicatedAggregatingMergeTree";
|
|
575
|
-
ClickHouseEngines2["ReplicatedSummingMergeTree"] = "ReplicatedSummingMergeTree";
|
|
576
|
-
ClickHouseEngines2["ReplicatedCollapsingMergeTree"] = "ReplicatedCollapsingMergeTree";
|
|
577
|
-
ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
|
|
578
|
-
return ClickHouseEngines2;
|
|
579
|
-
})(ClickHouseEngines || {});
|
|
580
|
-
|
|
581
|
-
// src/dmv2/utils/stackTrace.ts
|
|
582
729
|
function shouldSkipStackLine(line) {
|
|
583
730
|
return line.includes("node_modules") || // Skip npm installed packages (prod)
|
|
584
731
|
line.includes("node:internal") || // Skip Node.js internals (modern format)
|
|
@@ -639,8 +786,6 @@ function getSourceFileFromStack(stack) {
|
|
|
639
786
|
const location = getSourceLocationFromStack(stack);
|
|
640
787
|
return location?.file;
|
|
641
788
|
}
|
|
642
|
-
|
|
643
|
-
// src/dmv2/typedBase.ts
|
|
644
789
|
var TypedBase = class {
|
|
645
790
|
/** The JSON schema representation of type T. Injected by the compiler plugin. */
|
|
646
791
|
schema;
|
|
@@ -699,165 +844,79 @@ var TypedBase = class {
|
|
|
699
844
|
}
|
|
700
845
|
}
|
|
701
846
|
};
|
|
702
|
-
|
|
703
|
-
// src/dataModels/dataModelTypes.ts
|
|
704
847
|
function isArrayNestedType(dt) {
|
|
705
848
|
return typeof dt === "object" && dt !== null && dt.elementType !== null && typeof dt.elementType === "object" && dt.elementType.hasOwnProperty("columns") && Array.isArray(dt.elementType.columns);
|
|
706
849
|
}
|
|
707
850
|
function isNestedType(dt) {
|
|
708
851
|
return typeof dt === "object" && dt !== null && Array.isArray(dt.columns);
|
|
709
852
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
]
|
|
763
|
-
}
|
|
764
|
-
},
|
|
765
|
-
required: [
|
|
766
|
-
"originalRecord",
|
|
767
|
-
"errorMessage",
|
|
768
|
-
"errorType",
|
|
769
|
-
"failedAt",
|
|
770
|
-
"source"
|
|
771
|
-
]
|
|
772
|
-
},
|
|
773
|
-
Recordstringany: {
|
|
774
|
-
type: "object",
|
|
775
|
-
properties: {},
|
|
776
|
-
required: [],
|
|
777
|
-
description: "Construct a type with a set of properties K of type T",
|
|
778
|
-
additionalProperties: {}
|
|
779
|
-
}
|
|
853
|
+
var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
|
|
854
|
+
ClickHouseEngines2["MergeTree"] = "MergeTree";
|
|
855
|
+
ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
|
|
856
|
+
ClickHouseEngines2["SummingMergeTree"] = "SummingMergeTree";
|
|
857
|
+
ClickHouseEngines2["AggregatingMergeTree"] = "AggregatingMergeTree";
|
|
858
|
+
ClickHouseEngines2["CollapsingMergeTree"] = "CollapsingMergeTree";
|
|
859
|
+
ClickHouseEngines2["VersionedCollapsingMergeTree"] = "VersionedCollapsingMergeTree";
|
|
860
|
+
ClickHouseEngines2["GraphiteMergeTree"] = "GraphiteMergeTree";
|
|
861
|
+
ClickHouseEngines2["S3Queue"] = "S3Queue";
|
|
862
|
+
ClickHouseEngines2["S3"] = "S3";
|
|
863
|
+
ClickHouseEngines2["Buffer"] = "Buffer";
|
|
864
|
+
ClickHouseEngines2["Distributed"] = "Distributed";
|
|
865
|
+
ClickHouseEngines2["IcebergS3"] = "IcebergS3";
|
|
866
|
+
ClickHouseEngines2["Kafka"] = "Kafka";
|
|
867
|
+
ClickHouseEngines2["ReplicatedMergeTree"] = "ReplicatedMergeTree";
|
|
868
|
+
ClickHouseEngines2["ReplicatedReplacingMergeTree"] = "ReplicatedReplacingMergeTree";
|
|
869
|
+
ClickHouseEngines2["ReplicatedAggregatingMergeTree"] = "ReplicatedAggregatingMergeTree";
|
|
870
|
+
ClickHouseEngines2["ReplicatedSummingMergeTree"] = "ReplicatedSummingMergeTree";
|
|
871
|
+
ClickHouseEngines2["ReplicatedCollapsingMergeTree"] = "ReplicatedCollapsingMergeTree";
|
|
872
|
+
ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
|
|
873
|
+
return ClickHouseEngines2;
|
|
874
|
+
})(ClickHouseEngines || {});
|
|
875
|
+
init_commons();
|
|
876
|
+
var MOOSE_RUNTIME_ENV_PREFIX = "__MOOSE_RUNTIME_ENV__:";
|
|
877
|
+
var mooseRuntimeEnv = {
|
|
878
|
+
/**
|
|
879
|
+
* Gets a value from an environment variable, with behavior depending on context.
|
|
880
|
+
*
|
|
881
|
+
* When IS_LOADING_INFRA_MAP=true (infrastructure loading):
|
|
882
|
+
* Returns a marker string that Moose CLI will resolve later
|
|
883
|
+
*
|
|
884
|
+
* When IS_LOADING_INFRA_MAP is unset (function/workflow runtime):
|
|
885
|
+
* Returns the actual value from the environment variable
|
|
886
|
+
*
|
|
887
|
+
* @param envVarName - Name of the environment variable to resolve
|
|
888
|
+
* @returns Either a marker string or the actual environment variable value
|
|
889
|
+
* @throws {Error} If the environment variable name is empty
|
|
890
|
+
* @throws {Error} If the environment variable is not set (runtime mode only)
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```typescript
|
|
894
|
+
* // Instead of this (evaluated at build time):
|
|
895
|
+
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID
|
|
896
|
+
*
|
|
897
|
+
* // Use this (evaluated at runtime):
|
|
898
|
+
* awsAccessKeyId: mooseRuntimeEnv.get("AWS_ACCESS_KEY_ID")
|
|
899
|
+
* ```
|
|
900
|
+
*/
|
|
901
|
+
get(envVarName) {
|
|
902
|
+
if (!envVarName || envVarName.trim() === "") {
|
|
903
|
+
throw new Error("Environment variable name cannot be empty");
|
|
780
904
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
905
|
+
const isLoadingInfraMap = process.env.IS_LOADING_INFRA_MAP === "true";
|
|
906
|
+
if (isLoadingInfraMap) {
|
|
907
|
+
return `${MOOSE_RUNTIME_ENV_PREFIX}${envVarName}`;
|
|
908
|
+
} else {
|
|
909
|
+
const value = process.env[envVarName];
|
|
910
|
+
if (value === void 0) {
|
|
911
|
+
throw new Error(
|
|
912
|
+
`Environment variable '${envVarName}' is not set. This is required for runtime execution of functions/workflows.`
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
return value;
|
|
785
916
|
}
|
|
786
|
-
]
|
|
787
|
-
};
|
|
788
|
-
var dlqColumns = [
|
|
789
|
-
{
|
|
790
|
-
name: "originalRecord",
|
|
791
|
-
data_type: "Json",
|
|
792
|
-
primary_key: false,
|
|
793
|
-
required: true,
|
|
794
|
-
unique: false,
|
|
795
|
-
default: null,
|
|
796
|
-
annotations: [],
|
|
797
|
-
ttl: null,
|
|
798
|
-
codec: null,
|
|
799
|
-
materialized: null,
|
|
800
|
-
comment: null
|
|
801
|
-
},
|
|
802
|
-
{
|
|
803
|
-
name: "errorMessage",
|
|
804
|
-
data_type: "String",
|
|
805
|
-
primary_key: false,
|
|
806
|
-
required: true,
|
|
807
|
-
unique: false,
|
|
808
|
-
default: null,
|
|
809
|
-
annotations: [],
|
|
810
|
-
ttl: null,
|
|
811
|
-
codec: null,
|
|
812
|
-
materialized: null,
|
|
813
|
-
comment: null
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
name: "errorType",
|
|
817
|
-
data_type: "String",
|
|
818
|
-
primary_key: false,
|
|
819
|
-
required: true,
|
|
820
|
-
unique: false,
|
|
821
|
-
default: null,
|
|
822
|
-
annotations: [],
|
|
823
|
-
ttl: null,
|
|
824
|
-
codec: null,
|
|
825
|
-
materialized: null,
|
|
826
|
-
comment: null
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
name: "failedAt",
|
|
830
|
-
data_type: "DateTime",
|
|
831
|
-
primary_key: false,
|
|
832
|
-
required: true,
|
|
833
|
-
unique: false,
|
|
834
|
-
default: null,
|
|
835
|
-
annotations: [],
|
|
836
|
-
ttl: null,
|
|
837
|
-
codec: null,
|
|
838
|
-
materialized: null,
|
|
839
|
-
comment: null
|
|
840
|
-
},
|
|
841
|
-
{
|
|
842
|
-
name: "source",
|
|
843
|
-
data_type: "String",
|
|
844
|
-
primary_key: false,
|
|
845
|
-
required: true,
|
|
846
|
-
unique: false,
|
|
847
|
-
default: null,
|
|
848
|
-
annotations: [],
|
|
849
|
-
ttl: null,
|
|
850
|
-
codec: null,
|
|
851
|
-
materialized: null,
|
|
852
|
-
comment: null
|
|
853
917
|
}
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
// src/dmv2/sdk/olapTable.ts
|
|
857
|
-
var import_node_stream = require("stream");
|
|
858
|
-
var import_node_crypto = require("crypto");
|
|
859
|
-
|
|
860
|
-
// src/sqlHelpers.ts
|
|
918
|
+
};
|
|
919
|
+
var mooseEnvSecrets = mooseRuntimeEnv;
|
|
861
920
|
var quoteIdentifier = (name) => {
|
|
862
921
|
return name.startsWith("`") && name.endsWith("`") ? name : `\`${name}\``;
|
|
863
922
|
};
|
|
@@ -944,8 +1003,8 @@ sql.join = function(fragments, separator) {
|
|
|
944
1003
|
sql.raw = function(text) {
|
|
945
1004
|
return new Sql([text], []);
|
|
946
1005
|
};
|
|
947
|
-
var toStaticQuery = (
|
|
948
|
-
const [query, params] = toQuery(
|
|
1006
|
+
var toStaticQuery = (sql3) => {
|
|
1007
|
+
const [query, params] = toQuery(sql3);
|
|
949
1008
|
if (Object.keys(params).length !== 0) {
|
|
950
1009
|
throw new Error(
|
|
951
1010
|
"Dynamic SQL is not allowed in the select statement in view creation."
|
|
@@ -953,14 +1012,14 @@ var toStaticQuery = (sql2) => {
|
|
|
953
1012
|
}
|
|
954
1013
|
return query;
|
|
955
1014
|
};
|
|
956
|
-
var toQuery = (
|
|
957
|
-
const parameterizedStubs =
|
|
1015
|
+
var toQuery = (sql3) => {
|
|
1016
|
+
const parameterizedStubs = sql3.values.map(
|
|
958
1017
|
(v, i) => createClickhouseParameter(i, v)
|
|
959
1018
|
);
|
|
960
|
-
const query =
|
|
1019
|
+
const query = sql3.strings.map(
|
|
961
1020
|
(s, i) => s != "" ? `${s}${emptyIfUndefined(parameterizedStubs[i])}` : ""
|
|
962
1021
|
).join("");
|
|
963
|
-
const query_params =
|
|
1022
|
+
const query_params = sql3.values.reduce(
|
|
964
1023
|
(acc, v, i) => ({
|
|
965
1024
|
...acc,
|
|
966
1025
|
[`p${i}`]: getValueFromParameter(v)
|
|
@@ -969,7 +1028,7 @@ var toQuery = (sql2) => {
|
|
|
969
1028
|
);
|
|
970
1029
|
return [query, query_params];
|
|
971
1030
|
};
|
|
972
|
-
var toQueryPreview = (
|
|
1031
|
+
var toQueryPreview = (sql3) => {
|
|
973
1032
|
try {
|
|
974
1033
|
const formatValue = (v) => {
|
|
975
1034
|
if (Array.isArray(v)) {
|
|
@@ -990,46 +1049,254 @@ var toQueryPreview = (sql2) => {
|
|
|
990
1049
|
} catch {
|
|
991
1050
|
return String(v);
|
|
992
1051
|
}
|
|
993
|
-
};
|
|
994
|
-
let out =
|
|
995
|
-
for (let i = 0; i <
|
|
996
|
-
const val = getValueFromParameter(
|
|
997
|
-
out += formatValue(val);
|
|
998
|
-
out +=
|
|
1052
|
+
};
|
|
1053
|
+
let out = sql3.strings[0] ?? "";
|
|
1054
|
+
for (let i = 0; i < sql3.values.length; i++) {
|
|
1055
|
+
const val = getValueFromParameter(sql3.values[i]);
|
|
1056
|
+
out += formatValue(val);
|
|
1057
|
+
out += sql3.strings[i + 1] ?? "";
|
|
1058
|
+
}
|
|
1059
|
+
return out.replace(/\s+/g, " ").trim();
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
console.log(`toQueryPreview error: ${error}`);
|
|
1062
|
+
return "/* query preview unavailable */";
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
var getValueFromParameter = (value) => {
|
|
1066
|
+
if (Array.isArray(value)) {
|
|
1067
|
+
const [type, val] = value;
|
|
1068
|
+
if (type === "Identifier") return val;
|
|
1069
|
+
}
|
|
1070
|
+
return value;
|
|
1071
|
+
};
|
|
1072
|
+
function createClickhouseParameter(parameterIndex, value) {
|
|
1073
|
+
return `{p${parameterIndex}:${mapToClickHouseType(value)}}`;
|
|
1074
|
+
}
|
|
1075
|
+
var mapToClickHouseType = (value) => {
|
|
1076
|
+
if (typeof value === "number") {
|
|
1077
|
+
return Number.isInteger(value) ? "Int" : "Float";
|
|
1078
|
+
}
|
|
1079
|
+
if (typeof value === "boolean") return "Bool";
|
|
1080
|
+
if (value instanceof Date) return "DateTime";
|
|
1081
|
+
if (Array.isArray(value)) {
|
|
1082
|
+
const [type, _] = value;
|
|
1083
|
+
return type;
|
|
1084
|
+
}
|
|
1085
|
+
return "String";
|
|
1086
|
+
};
|
|
1087
|
+
function emptyIfUndefined(value) {
|
|
1088
|
+
return value === void 0 ? "" : value;
|
|
1089
|
+
}
|
|
1090
|
+
init_commons();
|
|
1091
|
+
function jsonDateReviver(key, value) {
|
|
1092
|
+
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)?)?)?)$/;
|
|
1093
|
+
if (typeof value === "string" && iso8601Format.test(value)) {
|
|
1094
|
+
return new Date(value);
|
|
1095
|
+
}
|
|
1096
|
+
return value;
|
|
1097
|
+
}
|
|
1098
|
+
function parseCSV(content, config) {
|
|
1099
|
+
return new Promise((resolve, reject) => {
|
|
1100
|
+
const results = [];
|
|
1101
|
+
(0, import_csv_parse.parse)(content, {
|
|
1102
|
+
delimiter: config.delimiter,
|
|
1103
|
+
columns: config.columns ?? true,
|
|
1104
|
+
skip_empty_lines: config.skipEmptyLines ?? true,
|
|
1105
|
+
trim: config.trim ?? true
|
|
1106
|
+
}).on("data", (row) => {
|
|
1107
|
+
results.push(row);
|
|
1108
|
+
}).on("end", () => {
|
|
1109
|
+
resolve(results);
|
|
1110
|
+
}).on("error", (error) => {
|
|
1111
|
+
reject(error);
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
function parseJSON(content, config = {}) {
|
|
1116
|
+
try {
|
|
1117
|
+
const parsed = JSON.parse(content, config.reviver);
|
|
1118
|
+
if (Array.isArray(parsed)) {
|
|
1119
|
+
return parsed;
|
|
1120
|
+
} else {
|
|
1121
|
+
return [parsed];
|
|
1122
|
+
}
|
|
1123
|
+
} catch (error) {
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
function parseJSONWithDates(content) {
|
|
1130
|
+
return parseJSON(content, { reviver: jsonDateReviver });
|
|
1131
|
+
}
|
|
1132
|
+
function isValidCSVDelimiter(delimiter) {
|
|
1133
|
+
return delimiter.length === 1 && !/\s/.test(delimiter);
|
|
1134
|
+
}
|
|
1135
|
+
var CSV_DELIMITERS = {
|
|
1136
|
+
COMMA: ",",
|
|
1137
|
+
TAB: " ",
|
|
1138
|
+
SEMICOLON: ";",
|
|
1139
|
+
PIPE: "|"
|
|
1140
|
+
};
|
|
1141
|
+
var DEFAULT_CSV_CONFIG = {
|
|
1142
|
+
delimiter: CSV_DELIMITERS.COMMA,
|
|
1143
|
+
columns: true,
|
|
1144
|
+
skipEmptyLines: true,
|
|
1145
|
+
trim: true
|
|
1146
|
+
};
|
|
1147
|
+
var DEFAULT_JSON_CONFIG = {
|
|
1148
|
+
reviver: jsonDateReviver
|
|
1149
|
+
};
|
|
1150
|
+
var DataSource = class {
|
|
1151
|
+
name;
|
|
1152
|
+
supportsIncremental;
|
|
1153
|
+
constructor(config) {
|
|
1154
|
+
this.name = config.name;
|
|
1155
|
+
this.supportsIncremental = config.supportsIncremental ?? false;
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
init_commons();
|
|
1159
|
+
var isClientOnlyMode = () => import_process.default.env.MOOSE_CLIENT_ONLY === "true";
|
|
1160
|
+
var moose_internal = {
|
|
1161
|
+
tables: /* @__PURE__ */ new Map(),
|
|
1162
|
+
streams: /* @__PURE__ */ new Map(),
|
|
1163
|
+
ingestApis: /* @__PURE__ */ new Map(),
|
|
1164
|
+
apis: /* @__PURE__ */ new Map(),
|
|
1165
|
+
sqlResources: /* @__PURE__ */ new Map(),
|
|
1166
|
+
workflows: /* @__PURE__ */ new Map(),
|
|
1167
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
1168
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
1169
|
+
views: /* @__PURE__ */ new Map()
|
|
1170
|
+
};
|
|
1171
|
+
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
1172
|
+
var getMooseInternal = () => globalThis.moose_internal;
|
|
1173
|
+
if (getMooseInternal() === void 0) {
|
|
1174
|
+
globalThis.moose_internal = moose_internal;
|
|
1175
|
+
}
|
|
1176
|
+
var dlqSchema = {
|
|
1177
|
+
version: "3.1",
|
|
1178
|
+
components: {
|
|
1179
|
+
schemas: {
|
|
1180
|
+
DeadLetterModel: {
|
|
1181
|
+
type: "object",
|
|
1182
|
+
properties: {
|
|
1183
|
+
originalRecord: {
|
|
1184
|
+
$ref: "#/components/schemas/Recordstringany"
|
|
1185
|
+
},
|
|
1186
|
+
errorMessage: {
|
|
1187
|
+
type: "string"
|
|
1188
|
+
},
|
|
1189
|
+
errorType: {
|
|
1190
|
+
type: "string"
|
|
1191
|
+
},
|
|
1192
|
+
failedAt: {
|
|
1193
|
+
type: "string",
|
|
1194
|
+
format: "date-time"
|
|
1195
|
+
},
|
|
1196
|
+
source: {
|
|
1197
|
+
oneOf: [
|
|
1198
|
+
{
|
|
1199
|
+
const: "api"
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
const: "transform"
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
const: "table"
|
|
1206
|
+
}
|
|
1207
|
+
]
|
|
1208
|
+
}
|
|
1209
|
+
},
|
|
1210
|
+
required: [
|
|
1211
|
+
"originalRecord",
|
|
1212
|
+
"errorMessage",
|
|
1213
|
+
"errorType",
|
|
1214
|
+
"failedAt",
|
|
1215
|
+
"source"
|
|
1216
|
+
]
|
|
1217
|
+
},
|
|
1218
|
+
Recordstringany: {
|
|
1219
|
+
type: "object",
|
|
1220
|
+
properties: {},
|
|
1221
|
+
required: [],
|
|
1222
|
+
description: "Construct a type with a set of properties K of type T",
|
|
1223
|
+
additionalProperties: {}
|
|
1224
|
+
}
|
|
999
1225
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
var getValueFromParameter = (value) => {
|
|
1007
|
-
if (Array.isArray(value)) {
|
|
1008
|
-
const [type, val] = value;
|
|
1009
|
-
if (type === "Identifier") return val;
|
|
1010
|
-
}
|
|
1011
|
-
return value;
|
|
1226
|
+
},
|
|
1227
|
+
schemas: [
|
|
1228
|
+
{
|
|
1229
|
+
$ref: "#/components/schemas/DeadLetterModel"
|
|
1230
|
+
}
|
|
1231
|
+
]
|
|
1012
1232
|
};
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1233
|
+
var dlqColumns = [
|
|
1234
|
+
{
|
|
1235
|
+
name: "originalRecord",
|
|
1236
|
+
data_type: "Json",
|
|
1237
|
+
primary_key: false,
|
|
1238
|
+
required: true,
|
|
1239
|
+
unique: false,
|
|
1240
|
+
default: null,
|
|
1241
|
+
annotations: [],
|
|
1242
|
+
ttl: null,
|
|
1243
|
+
codec: null,
|
|
1244
|
+
materialized: null,
|
|
1245
|
+
comment: null
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
name: "errorMessage",
|
|
1249
|
+
data_type: "String",
|
|
1250
|
+
primary_key: false,
|
|
1251
|
+
required: true,
|
|
1252
|
+
unique: false,
|
|
1253
|
+
default: null,
|
|
1254
|
+
annotations: [],
|
|
1255
|
+
ttl: null,
|
|
1256
|
+
codec: null,
|
|
1257
|
+
materialized: null,
|
|
1258
|
+
comment: null
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
name: "errorType",
|
|
1262
|
+
data_type: "String",
|
|
1263
|
+
primary_key: false,
|
|
1264
|
+
required: true,
|
|
1265
|
+
unique: false,
|
|
1266
|
+
default: null,
|
|
1267
|
+
annotations: [],
|
|
1268
|
+
ttl: null,
|
|
1269
|
+
codec: null,
|
|
1270
|
+
materialized: null,
|
|
1271
|
+
comment: null
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
name: "failedAt",
|
|
1275
|
+
data_type: "DateTime",
|
|
1276
|
+
primary_key: false,
|
|
1277
|
+
required: true,
|
|
1278
|
+
unique: false,
|
|
1279
|
+
default: null,
|
|
1280
|
+
annotations: [],
|
|
1281
|
+
ttl: null,
|
|
1282
|
+
codec: null,
|
|
1283
|
+
materialized: null,
|
|
1284
|
+
comment: null
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
name: "source",
|
|
1288
|
+
data_type: "String",
|
|
1289
|
+
primary_key: false,
|
|
1290
|
+
required: true,
|
|
1291
|
+
unique: false,
|
|
1292
|
+
default: null,
|
|
1293
|
+
annotations: [],
|
|
1294
|
+
ttl: null,
|
|
1295
|
+
codec: null,
|
|
1296
|
+
materialized: null,
|
|
1297
|
+
comment: null
|
|
1025
1298
|
}
|
|
1026
|
-
|
|
1027
|
-
};
|
|
1028
|
-
function emptyIfUndefined(value) {
|
|
1029
|
-
return value === void 0 ? "" : value;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
// src/dmv2/sdk/olapTable.ts
|
|
1299
|
+
];
|
|
1033
1300
|
var OlapTable = class extends TypedBase {
|
|
1034
1301
|
name;
|
|
1035
1302
|
/** @internal */
|
|
@@ -1041,7 +1308,14 @@ var OlapTable = class extends TypedBase {
|
|
|
1041
1308
|
/** @internal Cached table name to avoid repeated generation */
|
|
1042
1309
|
_cachedTableName;
|
|
1043
1310
|
constructor(name, config, schema, columns, validators) {
|
|
1044
|
-
const resolvedConfig = config ? "engine" in config ? config : {
|
|
1311
|
+
const resolvedConfig = config ? "engine" in config ? config : {
|
|
1312
|
+
...config,
|
|
1313
|
+
engine: "MergeTree"
|
|
1314
|
+
/* MergeTree */
|
|
1315
|
+
} : {
|
|
1316
|
+
engine: "MergeTree"
|
|
1317
|
+
/* MergeTree */
|
|
1318
|
+
};
|
|
1045
1319
|
const hasFields = Array.isArray(resolvedConfig.orderByFields) && resolvedConfig.orderByFields.length > 0;
|
|
1046
1320
|
const hasExpr = typeof resolvedConfig.orderByExpression === "string" && resolvedConfig.orderByExpression.length > 0;
|
|
1047
1321
|
if (hasFields && hasExpr) {
|
|
@@ -1094,7 +1368,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1094
1368
|
createConfigHash(clickhouseConfig) {
|
|
1095
1369
|
const effectiveDatabase = this.config.database ?? clickhouseConfig.database;
|
|
1096
1370
|
const configString = `${clickhouseConfig.host}:${clickhouseConfig.port}:${clickhouseConfig.username}:${clickhouseConfig.password}:${effectiveDatabase}:${clickhouseConfig.useSSL}`;
|
|
1097
|
-
return (0,
|
|
1371
|
+
return (0, import_crypto.createHash)("sha256").update(configString).digest("hex").substring(0, 16);
|
|
1098
1372
|
}
|
|
1099
1373
|
/**
|
|
1100
1374
|
* Gets or creates a memoized ClickHouse client.
|
|
@@ -1304,7 +1578,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1304
1578
|
* @private
|
|
1305
1579
|
*/
|
|
1306
1580
|
validateInsertParameters(data, options) {
|
|
1307
|
-
const isStream = data instanceof
|
|
1581
|
+
const isStream = data instanceof import_stream.Readable;
|
|
1308
1582
|
const strategy = options?.strategy || "fail-fast";
|
|
1309
1583
|
const shouldValidate = options?.validate !== false;
|
|
1310
1584
|
if (isStream && strategy === "isolate") {
|
|
@@ -1711,9 +1985,6 @@ var OlapTable = class extends TypedBase {
|
|
|
1711
1985
|
// were removed in ENG-856. Use direct configuration instead, e.g.:
|
|
1712
1986
|
// new OlapTable(name, { engine: ClickHouseEngines.ReplacingMergeTree, orderByFields: ["id"], ver: "updated_at" })
|
|
1713
1987
|
};
|
|
1714
|
-
|
|
1715
|
-
// src/dmv2/sdk/stream.ts
|
|
1716
|
-
var import_node_crypto2 = require("crypto");
|
|
1717
1988
|
var RoutedMessage = class {
|
|
1718
1989
|
/** The destination stream for the message */
|
|
1719
1990
|
destination;
|
|
@@ -1764,7 +2035,7 @@ var Stream = class extends TypedBase {
|
|
|
1764
2035
|
*
|
|
1765
2036
|
* @internal
|
|
1766
2037
|
*/
|
|
1767
|
-
_consumers =
|
|
2038
|
+
_consumers = new Array();
|
|
1768
2039
|
/**
|
|
1769
2040
|
* Builds the full Kafka topic name including optional namespace and version suffix.
|
|
1770
2041
|
* Version suffix is appended as _x_y_z where dots in version are replaced with underscores.
|
|
@@ -1787,7 +2058,7 @@ var Stream = class extends TypedBase {
|
|
|
1787
2058
|
kafkaConfig.securityProtocol,
|
|
1788
2059
|
kafkaConfig.namespace
|
|
1789
2060
|
].join(":");
|
|
1790
|
-
return (0,
|
|
2061
|
+
return (0, import_crypto2.createHash)("sha256").update(configString).digest("hex").substring(0, 16);
|
|
1791
2062
|
}
|
|
1792
2063
|
/**
|
|
1793
2064
|
* Gets or creates a memoized KafkaJS producer using runtime configuration.
|
|
@@ -1867,9 +2138,9 @@ var Stream = class extends TypedBase {
|
|
|
1867
2138
|
}
|
|
1868
2139
|
const {
|
|
1869
2140
|
default: { SchemaRegistry }
|
|
1870
|
-
} = await
|
|
2141
|
+
} = await Promise.resolve().then(() => __toESM(require_confluent_schema_registry(), 1));
|
|
1871
2142
|
const registry = new SchemaRegistry({ host: schemaRegistryUrl });
|
|
1872
|
-
let schemaId;
|
|
2143
|
+
let schemaId = void 0;
|
|
1873
2144
|
if ("id" in sr.reference) {
|
|
1874
2145
|
schemaId = sr.reference.id;
|
|
1875
2146
|
} else if ("subjectLatest" in sr.reference) {
|
|
@@ -2047,8 +2318,6 @@ var DeadLetterQueue = class extends Stream {
|
|
|
2047
2318
|
super.addMultiTransform(withValidate);
|
|
2048
2319
|
}
|
|
2049
2320
|
};
|
|
2050
|
-
|
|
2051
|
-
// src/dmv2/sdk/workflow.ts
|
|
2052
2321
|
var Task = class {
|
|
2053
2322
|
/**
|
|
2054
2323
|
* Creates a new Task instance.
|
|
@@ -2156,8 +2425,6 @@ var Workflow = class {
|
|
|
2156
2425
|
validateTask(startingTask, []);
|
|
2157
2426
|
}
|
|
2158
2427
|
};
|
|
2159
|
-
|
|
2160
|
-
// src/dmv2/sdk/ingestApi.ts
|
|
2161
2428
|
var IngestApi = class extends TypedBase {
|
|
2162
2429
|
constructor(name, config, schema, columns, validators, allowExtraFields) {
|
|
2163
2430
|
super(name, config, schema, columns, void 0, allowExtraFields);
|
|
@@ -2168,8 +2435,6 @@ var IngestApi = class extends TypedBase {
|
|
|
2168
2435
|
ingestApis.set(name, this);
|
|
2169
2436
|
}
|
|
2170
2437
|
};
|
|
2171
|
-
|
|
2172
|
-
// src/dmv2/sdk/consumptionApi.ts
|
|
2173
2438
|
var Api = class extends TypedBase {
|
|
2174
2439
|
/** @internal The handler function that processes requests and generates responses. */
|
|
2175
2440
|
_handler;
|
|
@@ -2276,8 +2541,6 @@ var Api = class extends TypedBase {
|
|
|
2276
2541
|
}
|
|
2277
2542
|
};
|
|
2278
2543
|
var ConsumptionApi = Api;
|
|
2279
|
-
|
|
2280
|
-
// src/dmv2/sdk/ingestPipeline.ts
|
|
2281
2544
|
var IngestPipeline = class extends TypedBase {
|
|
2282
2545
|
/**
|
|
2283
2546
|
* The OLAP table component of the pipeline, if configured.
|
|
@@ -2316,7 +2579,7 @@ var IngestPipeline = class extends TypedBase {
|
|
|
2316
2579
|
...config.version && { version: config.version }
|
|
2317
2580
|
} : {
|
|
2318
2581
|
lifeCycle: config.lifeCycle,
|
|
2319
|
-
engine: "MergeTree"
|
|
2582
|
+
engine: "MergeTree",
|
|
2320
2583
|
...config.version && { version: config.version }
|
|
2321
2584
|
};
|
|
2322
2585
|
this.table = new OlapTable(
|
|
@@ -2386,8 +2649,6 @@ var IngestPipeline = class extends TypedBase {
|
|
|
2386
2649
|
}
|
|
2387
2650
|
}
|
|
2388
2651
|
};
|
|
2389
|
-
|
|
2390
|
-
// src/dmv2/sdk/etlPipeline.ts
|
|
2391
2652
|
var InternalBatcher = class {
|
|
2392
2653
|
iterator;
|
|
2393
2654
|
batchSize;
|
|
@@ -2528,8 +2789,6 @@ var ETLPipeline = class {
|
|
|
2528
2789
|
console.log(`Completed ETL Pipeline: ${this.name}`);
|
|
2529
2790
|
}
|
|
2530
2791
|
};
|
|
2531
|
-
|
|
2532
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2533
2792
|
function formatTableReference(table) {
|
|
2534
2793
|
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2535
2794
|
if (database) {
|
|
@@ -2573,7 +2832,8 @@ var MaterializedView = class {
|
|
|
2573
2832
|
),
|
|
2574
2833
|
{
|
|
2575
2834
|
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2576
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree"
|
|
2835
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree"
|
|
2836
|
+
/* MergeTree */
|
|
2577
2837
|
},
|
|
2578
2838
|
targetSchema,
|
|
2579
2839
|
targetColumns
|
|
@@ -2604,8 +2864,6 @@ var MaterializedView = class {
|
|
|
2604
2864
|
materializedViews.set(this.name, this);
|
|
2605
2865
|
}
|
|
2606
2866
|
};
|
|
2607
|
-
|
|
2608
|
-
// src/dmv2/sdk/sqlResource.ts
|
|
2609
2867
|
var SqlResource = class {
|
|
2610
2868
|
/** @internal */
|
|
2611
2869
|
kind = "SqlResource";
|
|
@@ -2642,10 +2900,10 @@ var SqlResource = class {
|
|
|
2642
2900
|
sqlResources.set(name, this);
|
|
2643
2901
|
this.name = name;
|
|
2644
2902
|
this.setup = setup.map(
|
|
2645
|
-
(
|
|
2903
|
+
(sql3) => typeof sql3 === "string" ? sql3 : toStaticQuery(sql3)
|
|
2646
2904
|
);
|
|
2647
2905
|
this.teardown = teardown.map(
|
|
2648
|
-
(
|
|
2906
|
+
(sql3) => typeof sql3 === "string" ? sql3 : toStaticQuery(sql3)
|
|
2649
2907
|
);
|
|
2650
2908
|
this.pullsDataFrom = options?.pullsDataFrom ?? [];
|
|
2651
2909
|
this.pushesDataTo = options?.pushesDataTo ?? [];
|
|
@@ -2658,8 +2916,6 @@ var SqlResource = class {
|
|
|
2658
2916
|
}
|
|
2659
2917
|
}
|
|
2660
2918
|
};
|
|
2661
|
-
|
|
2662
|
-
// src/dmv2/sdk/view.ts
|
|
2663
2919
|
function formatTableReference2(table) {
|
|
2664
2920
|
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2665
2921
|
if (database) {
|
|
@@ -2707,16 +2963,12 @@ var View = class {
|
|
|
2707
2963
|
views.set(this.name, this);
|
|
2708
2964
|
}
|
|
2709
2965
|
};
|
|
2710
|
-
|
|
2711
|
-
// src/dmv2/sdk/lifeCycle.ts
|
|
2712
2966
|
var LifeCycle = /* @__PURE__ */ ((LifeCycle2) => {
|
|
2713
2967
|
LifeCycle2["FULLY_MANAGED"] = "FULLY_MANAGED";
|
|
2714
2968
|
LifeCycle2["DELETION_PROTECTED"] = "DELETION_PROTECTED";
|
|
2715
2969
|
LifeCycle2["EXTERNALLY_MANAGED"] = "EXTERNALLY_MANAGED";
|
|
2716
2970
|
return LifeCycle2;
|
|
2717
2971
|
})(LifeCycle || {});
|
|
2718
|
-
|
|
2719
|
-
// src/dmv2/sdk/webApp.ts
|
|
2720
2972
|
var RESERVED_MOUNT_PATHS = [
|
|
2721
2973
|
"/admin",
|
|
2722
2974
|
"/api",
|
|
@@ -2829,8 +3081,6 @@ Examples:
|
|
|
2829
3081
|
return this._rawApp;
|
|
2830
3082
|
}
|
|
2831
3083
|
};
|
|
2832
|
-
|
|
2833
|
-
// src/dmv2/registry.ts
|
|
2834
3084
|
function getTables() {
|
|
2835
3085
|
return getMooseInternal().tables;
|
|
2836
3086
|
}
|
|
@@ -2882,7 +3132,7 @@ function getSqlResources() {
|
|
|
2882
3132
|
function getSqlResource(name) {
|
|
2883
3133
|
return getMooseInternal().sqlResources.get(name);
|
|
2884
3134
|
}
|
|
2885
|
-
function
|
|
3135
|
+
function getWorkflows2() {
|
|
2886
3136
|
return getMooseInternal().workflows;
|
|
2887
3137
|
}
|
|
2888
3138
|
function getWorkflow(name) {
|
|
@@ -2906,131 +3156,7 @@ function getViews() {
|
|
|
2906
3156
|
function getView(name) {
|
|
2907
3157
|
return getMooseInternal().views.get(name);
|
|
2908
3158
|
}
|
|
2909
|
-
|
|
2910
|
-
// src/serverless.ts
|
|
2911
|
-
init_commons_types();
|
|
2912
|
-
|
|
2913
|
-
// src/connectors/dataSource.ts
|
|
2914
|
-
var DataSource = class {
|
|
2915
|
-
name;
|
|
2916
|
-
supportsIncremental;
|
|
2917
|
-
constructor(config) {
|
|
2918
|
-
this.name = config.name;
|
|
2919
|
-
this.supportsIncremental = config.supportsIncremental ?? false;
|
|
2920
|
-
}
|
|
2921
|
-
};
|
|
2922
|
-
|
|
2923
|
-
// src/secrets.ts
|
|
2924
|
-
var MOOSE_RUNTIME_ENV_PREFIX = "__MOOSE_RUNTIME_ENV__:";
|
|
2925
|
-
var mooseRuntimeEnv = {
|
|
2926
|
-
/**
|
|
2927
|
-
* Gets a value from an environment variable, with behavior depending on context.
|
|
2928
|
-
*
|
|
2929
|
-
* When IS_LOADING_INFRA_MAP=true (infrastructure loading):
|
|
2930
|
-
* Returns a marker string that Moose CLI will resolve later
|
|
2931
|
-
*
|
|
2932
|
-
* When IS_LOADING_INFRA_MAP is unset (function/workflow runtime):
|
|
2933
|
-
* Returns the actual value from the environment variable
|
|
2934
|
-
*
|
|
2935
|
-
* @param envVarName - Name of the environment variable to resolve
|
|
2936
|
-
* @returns Either a marker string or the actual environment variable value
|
|
2937
|
-
* @throws {Error} If the environment variable name is empty
|
|
2938
|
-
* @throws {Error} If the environment variable is not set (runtime mode only)
|
|
2939
|
-
*
|
|
2940
|
-
* @example
|
|
2941
|
-
* ```typescript
|
|
2942
|
-
* // Instead of this (evaluated at build time):
|
|
2943
|
-
* awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID
|
|
2944
|
-
*
|
|
2945
|
-
* // Use this (evaluated at runtime):
|
|
2946
|
-
* awsAccessKeyId: mooseRuntimeEnv.get("AWS_ACCESS_KEY_ID")
|
|
2947
|
-
* ```
|
|
2948
|
-
*/
|
|
2949
|
-
get(envVarName) {
|
|
2950
|
-
if (!envVarName || envVarName.trim() === "") {
|
|
2951
|
-
throw new Error("Environment variable name cannot be empty");
|
|
2952
|
-
}
|
|
2953
|
-
const isLoadingInfraMap = process.env.IS_LOADING_INFRA_MAP === "true";
|
|
2954
|
-
if (isLoadingInfraMap) {
|
|
2955
|
-
return `${MOOSE_RUNTIME_ENV_PREFIX}${envVarName}`;
|
|
2956
|
-
} else {
|
|
2957
|
-
const value = process.env[envVarName];
|
|
2958
|
-
if (value === void 0) {
|
|
2959
|
-
throw new Error(
|
|
2960
|
-
`Environment variable '${envVarName}' is not set. This is required for runtime execution of functions/workflows.`
|
|
2961
|
-
);
|
|
2962
|
-
}
|
|
2963
|
-
return value;
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
|
-
};
|
|
2967
|
-
var mooseEnvSecrets = mooseRuntimeEnv;
|
|
2968
|
-
|
|
2969
|
-
// src/utilities/dataParser.ts
|
|
2970
|
-
var import_csv_parse = require("csv-parse");
|
|
2971
|
-
|
|
2972
|
-
// src/utilities/json.ts
|
|
2973
|
-
function jsonDateReviver(key, value) {
|
|
2974
|
-
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)?)?)?)$/;
|
|
2975
|
-
if (typeof value === "string" && iso8601Format.test(value)) {
|
|
2976
|
-
return new Date(value);
|
|
2977
|
-
}
|
|
2978
|
-
return value;
|
|
2979
|
-
}
|
|
2980
|
-
|
|
2981
|
-
// src/utilities/dataParser.ts
|
|
2982
|
-
function parseCSV(content, config) {
|
|
2983
|
-
return new Promise((resolve, reject) => {
|
|
2984
|
-
const results = [];
|
|
2985
|
-
(0, import_csv_parse.parse)(content, {
|
|
2986
|
-
delimiter: config.delimiter,
|
|
2987
|
-
columns: config.columns ?? true,
|
|
2988
|
-
skip_empty_lines: config.skipEmptyLines ?? true,
|
|
2989
|
-
trim: config.trim ?? true
|
|
2990
|
-
}).on("data", (row) => {
|
|
2991
|
-
results.push(row);
|
|
2992
|
-
}).on("end", () => {
|
|
2993
|
-
resolve(results);
|
|
2994
|
-
}).on("error", (error) => {
|
|
2995
|
-
reject(error);
|
|
2996
|
-
});
|
|
2997
|
-
});
|
|
2998
|
-
}
|
|
2999
|
-
function parseJSON(content, config = {}) {
|
|
3000
|
-
try {
|
|
3001
|
-
const parsed = JSON.parse(content, config.reviver);
|
|
3002
|
-
if (Array.isArray(parsed)) {
|
|
3003
|
-
return parsed;
|
|
3004
|
-
} else {
|
|
3005
|
-
return [parsed];
|
|
3006
|
-
}
|
|
3007
|
-
} catch (error) {
|
|
3008
|
-
throw new Error(
|
|
3009
|
-
`Failed to parse JSON: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
3010
|
-
);
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
function parseJSONWithDates(content) {
|
|
3014
|
-
return parseJSON(content, { reviver: jsonDateReviver });
|
|
3015
|
-
}
|
|
3016
|
-
function isValidCSVDelimiter(delimiter) {
|
|
3017
|
-
return delimiter.length === 1 && !/\s/.test(delimiter);
|
|
3018
|
-
}
|
|
3019
|
-
var CSV_DELIMITERS = {
|
|
3020
|
-
COMMA: ",",
|
|
3021
|
-
TAB: " ",
|
|
3022
|
-
SEMICOLON: ";",
|
|
3023
|
-
PIPE: "|"
|
|
3024
|
-
};
|
|
3025
|
-
var DEFAULT_CSV_CONFIG = {
|
|
3026
|
-
delimiter: CSV_DELIMITERS.COMMA,
|
|
3027
|
-
columns: true,
|
|
3028
|
-
skipEmptyLines: true,
|
|
3029
|
-
trim: true
|
|
3030
|
-
};
|
|
3031
|
-
var DEFAULT_JSON_CONFIG = {
|
|
3032
|
-
reviver: jsonDateReviver
|
|
3033
|
-
};
|
|
3159
|
+
init_commons();
|
|
3034
3160
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3035
3161
|
0 && (module.exports = {
|
|
3036
3162
|
ACKs,
|
|
@@ -3100,4 +3226,4 @@ var DEFAULT_JSON_CONFIG = {
|
|
|
3100
3226
|
toQueryPreview,
|
|
3101
3227
|
toStaticQuery
|
|
3102
3228
|
});
|
|
3103
|
-
//# sourceMappingURL=
|
|
3229
|
+
//# sourceMappingURL=index.js.map
|