@514labs/moose-lib 0.6.288 → 0.6.289-ci-9-g221fb3d9

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.
Files changed (35) hide show
  1. package/dist/{browserCompatible-15NCyT1P.d.mts → browserCompatible-DCCiBirg.d.mts} +1 -1
  2. package/dist/{browserCompatible-BUKAJYbj.d.ts → browserCompatible-DhVPp9qX.d.ts} +1 -1
  3. package/dist/browserCompatible.d.mts +2 -2
  4. package/dist/browserCompatible.d.ts +2 -2
  5. package/dist/browserCompatible.js +115 -86
  6. package/dist/browserCompatible.js.map +1 -1
  7. package/dist/browserCompatible.mjs +111 -86
  8. package/dist/browserCompatible.mjs.map +1 -1
  9. package/dist/compilerPlugin.js +4 -1
  10. package/dist/compilerPlugin.js.map +1 -1
  11. package/dist/compilerPlugin.mjs +5 -1
  12. package/dist/compilerPlugin.mjs.map +1 -1
  13. package/dist/dataModels/toDataModels.js +4 -1
  14. package/dist/dataModels/toDataModels.js.map +1 -1
  15. package/dist/dataModels/toDataModels.mjs +5 -1
  16. package/dist/dataModels/toDataModels.mjs.map +1 -1
  17. package/dist/dmv2/index.d.mts +1 -1
  18. package/dist/dmv2/index.d.ts +1 -1
  19. package/dist/dmv2/index.js +115 -86
  20. package/dist/dmv2/index.js.map +1 -1
  21. package/dist/dmv2/index.mjs +111 -86
  22. package/dist/dmv2/index.mjs.map +1 -1
  23. package/dist/{index-BtkwFbT9.d.mts → index-CcZRaA0b.d.mts} +84 -41
  24. package/dist/{index-BtkwFbT9.d.ts → index-CcZRaA0b.d.ts} +84 -41
  25. package/dist/index.d.mts +3 -3
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +117 -76
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +113 -76
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/moose-runner.js +28 -2
  32. package/dist/moose-runner.js.map +1 -1
  33. package/dist/moose-runner.mjs +28 -2
  34. package/dist/moose-runner.mjs.map +1 -1
  35. package/package.json +1 -1
@@ -639,16 +639,6 @@ function emptyIfUndefined(value) {
639
639
  return value === void 0 ? "" : value;
640
640
  }
641
641
 
642
- // src/blocks/helpers.ts
643
- function dropView(name) {
644
- return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
645
- }
646
- function createMaterializedView(options) {
647
- return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
648
- TO ${quoteIdentifier(options.destinationTable)}
649
- AS ${options.select}`.trim();
650
- }
651
-
652
642
  // src/dmv2/internal.ts
653
643
  import process2 from "process";
654
644
 
@@ -702,7 +692,9 @@ var moose_internal = {
702
692
  apis: /* @__PURE__ */ new Map(),
703
693
  sqlResources: /* @__PURE__ */ new Map(),
704
694
  workflows: /* @__PURE__ */ new Map(),
705
- webApps: /* @__PURE__ */ new Map()
695
+ webApps: /* @__PURE__ */ new Map(),
696
+ materializedViews: /* @__PURE__ */ new Map(),
697
+ customViews: /* @__PURE__ */ new Map()
706
698
  };
707
699
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
708
700
  var getMooseInternal = () => globalThis.moose_internal;
@@ -777,7 +769,8 @@ var dlqColumns = [
777
769
  annotations: [],
778
770
  ttl: null,
779
771
  codec: null,
780
- materialized: null
772
+ materialized: null,
773
+ comment: null
781
774
  },
782
775
  {
783
776
  name: "errorMessage",
@@ -789,7 +782,8 @@ var dlqColumns = [
789
782
  annotations: [],
790
783
  ttl: null,
791
784
  codec: null,
792
- materialized: null
785
+ materialized: null,
786
+ comment: null
793
787
  },
794
788
  {
795
789
  name: "errorType",
@@ -801,7 +795,8 @@ var dlqColumns = [
801
795
  annotations: [],
802
796
  ttl: null,
803
797
  codec: null,
804
- materialized: null
798
+ materialized: null,
799
+ comment: null
805
800
  },
806
801
  {
807
802
  name: "failedAt",
@@ -813,7 +808,8 @@ var dlqColumns = [
813
808
  annotations: [],
814
809
  ttl: null,
815
810
  codec: null,
816
- materialized: null
811
+ materialized: null,
812
+ comment: null
817
813
  },
818
814
  {
819
815
  name: "source",
@@ -825,7 +821,8 @@ var dlqColumns = [
825
821
  annotations: [],
826
822
  ttl: null,
827
823
  codec: null,
828
- materialized: null
824
+ materialized: null,
825
+ comment: null
829
826
  }
830
827
  ];
831
828
 
@@ -2331,6 +2328,67 @@ var ETLPipeline = class {
2331
2328
  }
2332
2329
  };
2333
2330
 
2331
+ // src/dmv2/sdk/materializedView.ts
2332
+ var requireTargetTableName = (tableName) => {
2333
+ if (typeof tableName === "string") {
2334
+ return tableName;
2335
+ } else {
2336
+ throw new Error("Name of targetTable is not specified.");
2337
+ }
2338
+ };
2339
+ var MaterializedView = class {
2340
+ /** @internal */
2341
+ kind = "MaterializedView";
2342
+ /** The name of the materialized view */
2343
+ name;
2344
+ /** The target OlapTable instance where the materialized data is stored. */
2345
+ targetTable;
2346
+ /** The SELECT SQL statement */
2347
+ selectSql;
2348
+ /** Names of source tables that the SELECT reads from */
2349
+ sourceTables;
2350
+ /** @internal Source file path where this MV was defined */
2351
+ sourceFile;
2352
+ constructor(options, targetSchema, targetColumns) {
2353
+ let selectStatement = options.selectStatement;
2354
+ if (typeof selectStatement !== "string") {
2355
+ selectStatement = toStaticQuery(selectStatement);
2356
+ }
2357
+ if (targetSchema === void 0 || targetColumns === void 0) {
2358
+ throw new Error(
2359
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2360
+ );
2361
+ }
2362
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2363
+ requireTargetTableName(
2364
+ options.targetTable?.name ?? options.tableName
2365
+ ),
2366
+ {
2367
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2368
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2369
+ },
2370
+ targetSchema,
2371
+ targetColumns
2372
+ );
2373
+ if (targetTable.name === options.materializedViewName) {
2374
+ throw new Error(
2375
+ "Materialized view name cannot be the same as the target table name."
2376
+ );
2377
+ }
2378
+ this.name = options.materializedViewName;
2379
+ this.targetTable = targetTable;
2380
+ this.selectSql = selectStatement;
2381
+ this.sourceTables = options.selectTables.map((t) => t.name);
2382
+ const stack = new Error().stack;
2383
+ this.sourceFile = getSourceFileFromStack(stack);
2384
+ const materializedViews = getMooseInternal().materializedViews;
2385
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2386
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2387
+ }
2388
+ materializedViews.set(this.name, this);
2389
+ }
2390
+ };
2391
+
2334
2392
  // src/dmv2/sdk/sqlResource.ts
2335
2393
  var SqlResource = class {
2336
2394
  /** @internal */
@@ -2385,66 +2443,18 @@ var SqlResource = class {
2385
2443
  }
2386
2444
  };
2387
2445
 
2388
- // src/dmv2/sdk/materializedView.ts
2389
- var requireTargetTableName = (tableName) => {
2390
- if (typeof tableName === "string") {
2391
- return tableName;
2392
- } else {
2393
- throw new Error("Name of targetTable is not specified.");
2394
- }
2395
- };
2396
- var MaterializedView = class extends SqlResource {
2397
- /** The target OlapTable instance where the materialized data is stored. */
2398
- targetTable;
2399
- constructor(options, targetSchema, targetColumns) {
2400
- let selectStatement = options.selectStatement;
2401
- if (typeof selectStatement !== "string") {
2402
- selectStatement = toStaticQuery(selectStatement);
2403
- }
2404
- if (targetSchema === void 0 || targetColumns === void 0) {
2405
- throw new Error(
2406
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2407
- );
2408
- }
2409
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2410
- requireTargetTableName(
2411
- options.targetTable?.name ?? options.tableName
2412
- ),
2413
- {
2414
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2415
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2416
- },
2417
- targetSchema,
2418
- targetColumns
2419
- );
2420
- if (targetTable.name === options.materializedViewName) {
2421
- throw new Error(
2422
- "Materialized view name cannot be the same as the target table name."
2423
- );
2424
- }
2425
- super(
2426
- options.materializedViewName,
2427
- [
2428
- createMaterializedView({
2429
- name: options.materializedViewName,
2430
- destinationTable: targetTable.name,
2431
- select: selectStatement
2432
- })
2433
- // Population is now handled automatically by Rust infrastructure
2434
- // based on table engine type and whether this is a new or updated view
2435
- ],
2436
- [dropView(options.materializedViewName)],
2437
- {
2438
- pullsDataFrom: options.selectTables,
2439
- pushesDataTo: [targetTable]
2440
- }
2441
- );
2442
- this.targetTable = targetTable;
2443
- }
2444
- };
2445
-
2446
2446
  // src/dmv2/sdk/view.ts
2447
- var View = class extends SqlResource {
2447
+ var View = class {
2448
+ /** @internal */
2449
+ kind = "CustomView";
2450
+ /** The name of the view */
2451
+ name;
2452
+ /** The SELECT SQL statement that defines the view */
2453
+ selectSql;
2454
+ /** Names of source tables/views that the SELECT reads from */
2455
+ sourceTables;
2456
+ /** @internal Source file path where this view was defined */
2457
+ sourceFile;
2448
2458
  /**
2449
2459
  * Creates a new View instance.
2450
2460
  * @param name The name of the view to be created.
@@ -2455,17 +2465,16 @@ var View = class extends SqlResource {
2455
2465
  if (typeof selectStatement !== "string") {
2456
2466
  selectStatement = toStaticQuery(selectStatement);
2457
2467
  }
2458
- super(
2459
- name,
2460
- [
2461
- `CREATE VIEW IF NOT EXISTS ${name}
2462
- AS ${selectStatement}`.trim()
2463
- ],
2464
- [dropView(name)],
2465
- {
2466
- pullsDataFrom: baseTables
2467
- }
2468
- );
2468
+ this.name = name;
2469
+ this.selectSql = selectStatement;
2470
+ this.sourceTables = baseTables.map((t) => t.name);
2471
+ const stack = new Error().stack;
2472
+ this.sourceFile = getSourceFileFromStack(stack);
2473
+ const customViews = getMooseInternal().customViews;
2474
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2475
+ throw new Error(`View with name ${this.name} already exists`);
2476
+ }
2477
+ customViews.set(this.name, this);
2469
2478
  }
2470
2479
  };
2471
2480
 
@@ -2654,6 +2663,18 @@ function getWebApps2() {
2654
2663
  function getWebApp(name) {
2655
2664
  return getMooseInternal().webApps.get(name);
2656
2665
  }
2666
+ function getMaterializedViews() {
2667
+ return getMooseInternal().materializedViews;
2668
+ }
2669
+ function getMaterializedView(name) {
2670
+ return getMooseInternal().materializedViews.get(name);
2671
+ }
2672
+ function getCustomViews() {
2673
+ return getMooseInternal().customViews;
2674
+ }
2675
+ function getCustomView(name) {
2676
+ return getMooseInternal().customViews.get(name);
2677
+ }
2657
2678
  export {
2658
2679
  Api,
2659
2680
  ConsumptionApi,
@@ -2674,8 +2695,12 @@ export {
2674
2695
  createClickhouseParameter,
2675
2696
  getApi,
2676
2697
  getApis2 as getApis,
2698
+ getCustomView,
2699
+ getCustomViews,
2677
2700
  getIngestApi,
2678
2701
  getIngestApis,
2702
+ getMaterializedView,
2703
+ getMaterializedViews,
2679
2704
  getSqlResource,
2680
2705
  getSqlResources,
2681
2706
  getStream,