@514labs/moose-lib 0.6.256-ci-4-g0ca62054 → 0.6.256-ci-3-gafce5840
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/{browserCompatible-B_aEflr_.d.ts → browserCompatible-B6i2YRSY.d.ts} +1 -1
- package/dist/{browserCompatible-DnYA4Zgi.d.mts → browserCompatible-CMIa49e4.d.mts} +1 -1
- package/dist/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +91 -95
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +91 -95
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/compilerPlugin.js.map +1 -1
- package/dist/compilerPlugin.mjs.map +1 -1
- package/dist/dmv2/index.d.mts +1 -1
- package/dist/dmv2/index.d.ts +1 -1
- package/dist/dmv2/index.js +91 -95
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +91 -95
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-rECDLgTX.d.mts → index-BpasnHLt.d.mts} +56 -36
- package/dist/{index-rECDLgTX.d.ts → index-BpasnHLt.d.ts} +56 -36
- package/dist/index.d.mts +5 -28
- package/dist/index.d.ts +5 -28
- package/dist/index.js +93 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -86
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +231 -105
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +231 -105
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +2 -2
package/dist/dmv2/index.mjs
CHANGED
|
@@ -20,7 +20,6 @@ __export(commons_exports, {
|
|
|
20
20
|
antiCachePath: () => antiCachePath,
|
|
21
21
|
cliLog: () => cliLog,
|
|
22
22
|
compilerLog: () => compilerLog,
|
|
23
|
-
createProducerConfig: () => createProducerConfig,
|
|
24
23
|
getClickhouseClient: () => getClickhouseClient,
|
|
25
24
|
getFileName: () => getFileName,
|
|
26
25
|
getKafkaClient: () => getKafkaClient,
|
|
@@ -46,25 +45,18 @@ function isTruthy(value) {
|
|
|
46
45
|
function mapTstoJs(filePath) {
|
|
47
46
|
return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
|
|
48
47
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
48
|
+
async function getKafkaProducer(cfg, logger) {
|
|
49
|
+
const kafka = await getKafkaClient(cfg, logger);
|
|
50
|
+
const producer = kafka.producer({
|
|
51
51
|
kafkaJS: {
|
|
52
|
-
idempotent:
|
|
53
|
-
// Not needed for at-least-once delivery
|
|
52
|
+
idempotent: true,
|
|
54
53
|
acks: ACKs,
|
|
55
54
|
retry: {
|
|
56
55
|
retries: MAX_RETRIES_PRODUCER,
|
|
57
56
|
maxRetryTime: MAX_RETRY_TIME_MS
|
|
58
57
|
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// This is to make sure at least once delivery with immediate feedback on the send
|
|
62
|
-
...maxMessageBytes && { "message.max.bytes": maxMessageBytes }
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
async function getKafkaProducer(cfg, logger, maxMessageBytes) {
|
|
66
|
-
const kafka = await getKafkaClient(cfg, logger);
|
|
67
|
-
const producer = kafka.producer(createProducerConfig(maxMessageBytes));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
68
60
|
await producer.connect();
|
|
69
61
|
return producer;
|
|
70
62
|
}
|
|
@@ -506,16 +498,6 @@ function emptyIfUndefined(value) {
|
|
|
506
498
|
return value === void 0 ? "" : value;
|
|
507
499
|
}
|
|
508
500
|
|
|
509
|
-
// src/blocks/helpers.ts
|
|
510
|
-
function dropView(name) {
|
|
511
|
-
return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
|
|
512
|
-
}
|
|
513
|
-
function createMaterializedView(options) {
|
|
514
|
-
return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
|
|
515
|
-
TO ${quoteIdentifier(options.destinationTable)}
|
|
516
|
-
AS ${options.select}`.trim();
|
|
517
|
-
}
|
|
518
|
-
|
|
519
501
|
// src/dmv2/internal.ts
|
|
520
502
|
import process2 from "process";
|
|
521
503
|
|
|
@@ -569,7 +551,9 @@ var moose_internal = {
|
|
|
569
551
|
apis: /* @__PURE__ */ new Map(),
|
|
570
552
|
sqlResources: /* @__PURE__ */ new Map(),
|
|
571
553
|
workflows: /* @__PURE__ */ new Map(),
|
|
572
|
-
webApps: /* @__PURE__ */ new Map()
|
|
554
|
+
webApps: /* @__PURE__ */ new Map(),
|
|
555
|
+
materializedViews: /* @__PURE__ */ new Map(),
|
|
556
|
+
customViews: /* @__PURE__ */ new Map()
|
|
573
557
|
};
|
|
574
558
|
var defaultRetentionPeriod = 60 * 60 * 24 * 7;
|
|
575
559
|
var getMooseInternal = () => globalThis.moose_internal;
|
|
@@ -2185,6 +2169,67 @@ var ETLPipeline = class {
|
|
|
2185
2169
|
}
|
|
2186
2170
|
};
|
|
2187
2171
|
|
|
2172
|
+
// src/dmv2/sdk/materializedView.ts
|
|
2173
|
+
var requireTargetTableName = (tableName) => {
|
|
2174
|
+
if (typeof tableName === "string") {
|
|
2175
|
+
return tableName;
|
|
2176
|
+
} else {
|
|
2177
|
+
throw new Error("Name of targetTable is not specified.");
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
var MaterializedView = class {
|
|
2181
|
+
/** @internal */
|
|
2182
|
+
kind = "MaterializedView";
|
|
2183
|
+
/** The name of the materialized view */
|
|
2184
|
+
name;
|
|
2185
|
+
/** The target OlapTable instance where the materialized data is stored. */
|
|
2186
|
+
targetTable;
|
|
2187
|
+
/** The SELECT SQL statement */
|
|
2188
|
+
selectSql;
|
|
2189
|
+
/** Names of source tables that the SELECT reads from */
|
|
2190
|
+
sourceTables;
|
|
2191
|
+
/** @internal Source file path where this MV was defined */
|
|
2192
|
+
sourceFile;
|
|
2193
|
+
constructor(options, targetSchema, targetColumns) {
|
|
2194
|
+
let selectStatement = options.selectStatement;
|
|
2195
|
+
if (typeof selectStatement !== "string") {
|
|
2196
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
2197
|
+
}
|
|
2198
|
+
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2199
|
+
throw new Error(
|
|
2200
|
+
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2201
|
+
);
|
|
2202
|
+
}
|
|
2203
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2204
|
+
requireTargetTableName(
|
|
2205
|
+
options.targetTable?.name ?? options.tableName
|
|
2206
|
+
),
|
|
2207
|
+
{
|
|
2208
|
+
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2209
|
+
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2210
|
+
},
|
|
2211
|
+
targetSchema,
|
|
2212
|
+
targetColumns
|
|
2213
|
+
);
|
|
2214
|
+
if (targetTable.name === options.materializedViewName) {
|
|
2215
|
+
throw new Error(
|
|
2216
|
+
"Materialized view name cannot be the same as the target table name."
|
|
2217
|
+
);
|
|
2218
|
+
}
|
|
2219
|
+
this.name = options.materializedViewName;
|
|
2220
|
+
this.targetTable = targetTable;
|
|
2221
|
+
this.selectSql = selectStatement;
|
|
2222
|
+
this.sourceTables = options.selectTables.map((t) => t.name);
|
|
2223
|
+
const stack = new Error().stack;
|
|
2224
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2225
|
+
const materializedViews = getMooseInternal().materializedViews;
|
|
2226
|
+
if (!isClientOnlyMode() && materializedViews.has(this.name)) {
|
|
2227
|
+
throw new Error(`MaterializedView with name ${this.name} already exists`);
|
|
2228
|
+
}
|
|
2229
|
+
materializedViews.set(this.name, this);
|
|
2230
|
+
}
|
|
2231
|
+
};
|
|
2232
|
+
|
|
2188
2233
|
// src/dmv2/sdk/sqlResource.ts
|
|
2189
2234
|
var SqlResource = class {
|
|
2190
2235
|
/** @internal */
|
|
@@ -2230,66 +2275,18 @@ var SqlResource = class {
|
|
|
2230
2275
|
}
|
|
2231
2276
|
};
|
|
2232
2277
|
|
|
2233
|
-
// src/dmv2/sdk/materializedView.ts
|
|
2234
|
-
var requireTargetTableName = (tableName) => {
|
|
2235
|
-
if (typeof tableName === "string") {
|
|
2236
|
-
return tableName;
|
|
2237
|
-
} else {
|
|
2238
|
-
throw new Error("Name of targetTable is not specified.");
|
|
2239
|
-
}
|
|
2240
|
-
};
|
|
2241
|
-
var MaterializedView = class extends SqlResource {
|
|
2242
|
-
/** The target OlapTable instance where the materialized data is stored. */
|
|
2243
|
-
targetTable;
|
|
2244
|
-
constructor(options, targetSchema, targetColumns) {
|
|
2245
|
-
let selectStatement = options.selectStatement;
|
|
2246
|
-
if (typeof selectStatement !== "string") {
|
|
2247
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2248
|
-
}
|
|
2249
|
-
if (targetSchema === void 0 || targetColumns === void 0) {
|
|
2250
|
-
throw new Error(
|
|
2251
|
-
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2252
|
-
);
|
|
2253
|
-
}
|
|
2254
|
-
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2255
|
-
requireTargetTableName(
|
|
2256
|
-
options.targetTable?.name ?? options.tableName
|
|
2257
|
-
),
|
|
2258
|
-
{
|
|
2259
|
-
orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
|
|
2260
|
-
engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
|
|
2261
|
-
},
|
|
2262
|
-
targetSchema,
|
|
2263
|
-
targetColumns
|
|
2264
|
-
);
|
|
2265
|
-
if (targetTable.name === options.materializedViewName) {
|
|
2266
|
-
throw new Error(
|
|
2267
|
-
"Materialized view name cannot be the same as the target table name."
|
|
2268
|
-
);
|
|
2269
|
-
}
|
|
2270
|
-
super(
|
|
2271
|
-
options.materializedViewName,
|
|
2272
|
-
[
|
|
2273
|
-
createMaterializedView({
|
|
2274
|
-
name: options.materializedViewName,
|
|
2275
|
-
destinationTable: targetTable.name,
|
|
2276
|
-
select: selectStatement
|
|
2277
|
-
})
|
|
2278
|
-
// Population is now handled automatically by Rust infrastructure
|
|
2279
|
-
// based on table engine type and whether this is a new or updated view
|
|
2280
|
-
],
|
|
2281
|
-
[dropView(options.materializedViewName)],
|
|
2282
|
-
{
|
|
2283
|
-
pullsDataFrom: options.selectTables,
|
|
2284
|
-
pushesDataTo: [targetTable]
|
|
2285
|
-
}
|
|
2286
|
-
);
|
|
2287
|
-
this.targetTable = targetTable;
|
|
2288
|
-
}
|
|
2289
|
-
};
|
|
2290
|
-
|
|
2291
2278
|
// src/dmv2/sdk/view.ts
|
|
2292
|
-
var View = class
|
|
2279
|
+
var View = class {
|
|
2280
|
+
/** @internal */
|
|
2281
|
+
kind = "CustomView";
|
|
2282
|
+
/** The name of the view */
|
|
2283
|
+
name;
|
|
2284
|
+
/** The SELECT SQL statement that defines the view */
|
|
2285
|
+
selectSql;
|
|
2286
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
2287
|
+
sourceTables;
|
|
2288
|
+
/** @internal Source file path where this view was defined */
|
|
2289
|
+
sourceFile;
|
|
2293
2290
|
/**
|
|
2294
2291
|
* Creates a new View instance.
|
|
2295
2292
|
* @param name The name of the view to be created.
|
|
@@ -2300,17 +2297,16 @@ var View = class extends SqlResource {
|
|
|
2300
2297
|
if (typeof selectStatement !== "string") {
|
|
2301
2298
|
selectStatement = toStaticQuery(selectStatement);
|
|
2302
2299
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
{
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
);
|
|
2300
|
+
this.name = name;
|
|
2301
|
+
this.selectSql = selectStatement;
|
|
2302
|
+
this.sourceTables = baseTables.map((t) => t.name);
|
|
2303
|
+
const stack = new Error().stack;
|
|
2304
|
+
this.sourceFile = getSourceFileFromStack(stack);
|
|
2305
|
+
const customViews = getMooseInternal().customViews;
|
|
2306
|
+
if (!isClientOnlyMode() && customViews.has(this.name)) {
|
|
2307
|
+
throw new Error(`View with name ${this.name} already exists`);
|
|
2308
|
+
}
|
|
2309
|
+
customViews.set(this.name, this);
|
|
2314
2310
|
}
|
|
2315
2311
|
};
|
|
2316
2312
|
|