@514labs/moose-lib 0.6.284-ci-4-g1a9baa0b → 0.6.284-ci-9-g6ab40892

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.
@@ -1,4 +1,4 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, ag as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ak as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, al as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, aj as TaskConfig, ai as TaskContext, ah as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, ap as getCustomView, ao as getCustomViews, v as getIngestApi, u as getIngestApis, an as getMaterializedView, am as getMaterializedViews, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-KhGbXtkS.mjs';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ag as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ak as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, al as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, aj as TaskConfig, ai as TaskContext, ah as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-BtkwFbT9.mjs';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -1,4 +1,4 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, ag as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ak as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, al as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, aj as TaskConfig, ai as TaskContext, ah as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, ap as getCustomView, ao as getCustomViews, v as getIngestApi, u as getIngestApis, an as getMaterializedView, am as getMaterializedViews, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-KhGbXtkS.js';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ag as ConsumerConfig, C as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, j as IngestPipeline, ak as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, al as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, k as SqlResource, c as Stream, d as StreamConfig, T as Task, aj as TaskConfig, ai as TaskContext, ah as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from '../index-BtkwFbT9.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -401,12 +401,8 @@ __export(dmv2_exports, {
401
401
  Workflow: () => Workflow,
402
402
  getApi: () => getApi,
403
403
  getApis: () => getApis,
404
- getCustomView: () => getCustomView,
405
- getCustomViews: () => getCustomViews,
406
404
  getIngestApi: () => getIngestApi,
407
405
  getIngestApis: () => getIngestApis,
408
- getMaterializedView: () => getMaterializedView,
409
- getMaterializedViews: () => getMaterializedViews,
410
406
  getSqlResource: () => getSqlResource,
411
407
  getSqlResources: () => getSqlResources,
412
408
  getStream: () => getStream,
@@ -605,6 +601,16 @@ function emptyIfUndefined(value) {
605
601
  return value === void 0 ? "" : value;
606
602
  }
607
603
 
604
+ // src/blocks/helpers.ts
605
+ function dropView(name) {
606
+ return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
607
+ }
608
+ function createMaterializedView(options) {
609
+ return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
610
+ TO ${quoteIdentifier(options.destinationTable)}
611
+ AS ${options.select}`.trim();
612
+ }
613
+
608
614
  // src/dmv2/internal.ts
609
615
  var import_process = __toESM(require("process"));
610
616
 
@@ -655,9 +661,7 @@ var moose_internal = {
655
661
  apis: /* @__PURE__ */ new Map(),
656
662
  sqlResources: /* @__PURE__ */ new Map(),
657
663
  workflows: /* @__PURE__ */ new Map(),
658
- webApps: /* @__PURE__ */ new Map(),
659
- materializedViews: /* @__PURE__ */ new Map(),
660
- customViews: /* @__PURE__ */ new Map()
664
+ webApps: /* @__PURE__ */ new Map()
661
665
  };
662
666
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
663
667
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2286,67 +2290,6 @@ var ETLPipeline = class {
2286
2290
  }
2287
2291
  };
2288
2292
 
2289
- // src/dmv2/sdk/materializedView.ts
2290
- var requireTargetTableName = (tableName) => {
2291
- if (typeof tableName === "string") {
2292
- return tableName;
2293
- } else {
2294
- throw new Error("Name of targetTable is not specified.");
2295
- }
2296
- };
2297
- var MaterializedView = class {
2298
- /** @internal */
2299
- kind = "MaterializedView";
2300
- /** The name of the materialized view */
2301
- name;
2302
- /** The target OlapTable instance where the materialized data is stored. */
2303
- targetTable;
2304
- /** The SELECT SQL statement */
2305
- selectSql;
2306
- /** Names of source tables that the SELECT reads from */
2307
- sourceTables;
2308
- /** @internal Source file path where this MV was defined */
2309
- sourceFile;
2310
- constructor(options, targetSchema, targetColumns) {
2311
- let selectStatement = options.selectStatement;
2312
- if (typeof selectStatement !== "string") {
2313
- selectStatement = toStaticQuery(selectStatement);
2314
- }
2315
- if (targetSchema === void 0 || targetColumns === void 0) {
2316
- throw new Error(
2317
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2318
- );
2319
- }
2320
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2321
- requireTargetTableName(
2322
- options.targetTable?.name ?? options.tableName
2323
- ),
2324
- {
2325
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2326
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2327
- },
2328
- targetSchema,
2329
- targetColumns
2330
- );
2331
- if (targetTable.name === options.materializedViewName) {
2332
- throw new Error(
2333
- "Materialized view name cannot be the same as the target table name."
2334
- );
2335
- }
2336
- this.name = options.materializedViewName;
2337
- this.targetTable = targetTable;
2338
- this.selectSql = selectStatement;
2339
- this.sourceTables = options.selectTables.map((t) => t.name);
2340
- const stack = new Error().stack;
2341
- this.sourceFile = getSourceFileFromStack(stack);
2342
- const materializedViews = getMooseInternal().materializedViews;
2343
- if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2344
- throw new Error(`MaterializedView with name ${this.name} already exists`);
2345
- }
2346
- materializedViews.set(this.name, this);
2347
- }
2348
- };
2349
-
2350
2293
  // src/dmv2/sdk/sqlResource.ts
2351
2294
  var SqlResource = class {
2352
2295
  /** @internal */
@@ -2401,18 +2344,66 @@ var SqlResource = class {
2401
2344
  }
2402
2345
  };
2403
2346
 
2347
+ // src/dmv2/sdk/materializedView.ts
2348
+ var requireTargetTableName = (tableName) => {
2349
+ if (typeof tableName === "string") {
2350
+ return tableName;
2351
+ } else {
2352
+ throw new Error("Name of targetTable is not specified.");
2353
+ }
2354
+ };
2355
+ var MaterializedView = class extends SqlResource {
2356
+ /** The target OlapTable instance where the materialized data is stored. */
2357
+ targetTable;
2358
+ constructor(options, targetSchema, targetColumns) {
2359
+ let selectStatement = options.selectStatement;
2360
+ if (typeof selectStatement !== "string") {
2361
+ selectStatement = toStaticQuery(selectStatement);
2362
+ }
2363
+ if (targetSchema === void 0 || targetColumns === void 0) {
2364
+ throw new Error(
2365
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2366
+ );
2367
+ }
2368
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2369
+ requireTargetTableName(
2370
+ options.targetTable?.name ?? options.tableName
2371
+ ),
2372
+ {
2373
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2374
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2375
+ },
2376
+ targetSchema,
2377
+ targetColumns
2378
+ );
2379
+ if (targetTable.name === options.materializedViewName) {
2380
+ throw new Error(
2381
+ "Materialized view name cannot be the same as the target table name."
2382
+ );
2383
+ }
2384
+ super(
2385
+ options.materializedViewName,
2386
+ [
2387
+ createMaterializedView({
2388
+ name: options.materializedViewName,
2389
+ destinationTable: targetTable.name,
2390
+ select: selectStatement
2391
+ })
2392
+ // Population is now handled automatically by Rust infrastructure
2393
+ // based on table engine type and whether this is a new or updated view
2394
+ ],
2395
+ [dropView(options.materializedViewName)],
2396
+ {
2397
+ pullsDataFrom: options.selectTables,
2398
+ pushesDataTo: [targetTable]
2399
+ }
2400
+ );
2401
+ this.targetTable = targetTable;
2402
+ }
2403
+ };
2404
+
2404
2405
  // src/dmv2/sdk/view.ts
2405
- var View = class {
2406
- /** @internal */
2407
- kind = "CustomView";
2408
- /** The name of the view */
2409
- name;
2410
- /** The SELECT SQL statement that defines the view */
2411
- selectSql;
2412
- /** Names of source tables/views that the SELECT reads from */
2413
- sourceTables;
2414
- /** @internal Source file path where this view was defined */
2415
- sourceFile;
2406
+ var View = class extends SqlResource {
2416
2407
  /**
2417
2408
  * Creates a new View instance.
2418
2409
  * @param name The name of the view to be created.
@@ -2423,16 +2414,17 @@ var View = class {
2423
2414
  if (typeof selectStatement !== "string") {
2424
2415
  selectStatement = toStaticQuery(selectStatement);
2425
2416
  }
2426
- this.name = name;
2427
- this.selectSql = selectStatement;
2428
- this.sourceTables = baseTables.map((t) => t.name);
2429
- const stack = new Error().stack;
2430
- this.sourceFile = getSourceFileFromStack(stack);
2431
- const customViews = getMooseInternal().customViews;
2432
- if (!isClientOnlyMode() && customViews.has(this.name)) {
2433
- throw new Error(`View with name ${this.name} already exists`);
2434
- }
2435
- customViews.set(this.name, this);
2417
+ super(
2418
+ name,
2419
+ [
2420
+ `CREATE VIEW IF NOT EXISTS ${name}
2421
+ AS ${selectStatement}`.trim()
2422
+ ],
2423
+ [dropView(name)],
2424
+ {
2425
+ pullsDataFrom: baseTables
2426
+ }
2427
+ );
2436
2428
  }
2437
2429
  };
2438
2430
 
@@ -2621,18 +2613,6 @@ function getWebApps() {
2621
2613
  function getWebApp(name) {
2622
2614
  return getMooseInternal().webApps.get(name);
2623
2615
  }
2624
- function getMaterializedViews() {
2625
- return getMooseInternal().materializedViews;
2626
- }
2627
- function getMaterializedView(name) {
2628
- return getMooseInternal().materializedViews.get(name);
2629
- }
2630
- function getCustomViews() {
2631
- return getMooseInternal().customViews;
2632
- }
2633
- function getCustomView(name) {
2634
- return getMooseInternal().customViews.get(name);
2635
- }
2636
2616
  // Annotate the CommonJS export names for ESM import in node:
2637
2617
  0 && (module.exports = {
2638
2618
  Api,
@@ -2652,12 +2632,8 @@ function getCustomView(name) {
2652
2632
  Workflow,
2653
2633
  getApi,
2654
2634
  getApis,
2655
- getCustomView,
2656
- getCustomViews,
2657
2635
  getIngestApi,
2658
2636
  getIngestApis,
2659
- getMaterializedView,
2660
- getMaterializedViews,
2661
2637
  getSqlResource,
2662
2638
  getSqlResources,
2663
2639
  getStream,