@514labs/moose-lib 0.6.288 → 0.6.289-ci-7-ge6ab7015

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-BUKAJYbj.d.ts → browserCompatible-B2F3r37v.d.ts} +1 -1
  2. package/dist/{browserCompatible-15NCyT1P.d.mts → browserCompatible-DVf1GCzu.d.mts} +1 -1
  3. package/dist/browserCompatible.d.mts +2 -2
  4. package/dist/browserCompatible.d.ts +2 -2
  5. package/dist/browserCompatible.js +95 -86
  6. package/dist/browserCompatible.js.map +1 -1
  7. package/dist/browserCompatible.mjs +95 -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-C0jZ1bu4.d.mts} +84 -41
  24. package/dist/{index-BtkwFbT9.d.ts → index-C0jZ1bu4.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 +97 -76
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +97 -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
@@ -401,8 +401,12 @@ __export(dmv2_exports, {
401
401
  Workflow: () => Workflow,
402
402
  getApi: () => getApi,
403
403
  getApis: () => getApis,
404
+ getCustomView: () => getCustomView,
405
+ getCustomViews: () => getCustomViews,
404
406
  getIngestApi: () => getIngestApi,
405
407
  getIngestApis: () => getIngestApis,
408
+ getMaterializedView: () => getMaterializedView,
409
+ getMaterializedViews: () => getMaterializedViews,
406
410
  getSqlResource: () => getSqlResource,
407
411
  getSqlResources: () => getSqlResources,
408
412
  getStream: () => getStream,
@@ -601,16 +605,6 @@ function emptyIfUndefined(value) {
601
605
  return value === void 0 ? "" : value;
602
606
  }
603
607
 
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
-
614
608
  // src/dmv2/internal.ts
615
609
  var import_process = __toESM(require("process"));
616
610
 
@@ -661,7 +655,9 @@ var moose_internal = {
661
655
  apis: /* @__PURE__ */ new Map(),
662
656
  sqlResources: /* @__PURE__ */ new Map(),
663
657
  workflows: /* @__PURE__ */ new Map(),
664
- webApps: /* @__PURE__ */ new Map()
658
+ webApps: /* @__PURE__ */ new Map(),
659
+ materializedViews: /* @__PURE__ */ new Map(),
660
+ customViews: /* @__PURE__ */ new Map()
665
661
  };
666
662
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
667
663
  var getMooseInternal = () => globalThis.moose_internal;
@@ -736,7 +732,8 @@ var dlqColumns = [
736
732
  annotations: [],
737
733
  ttl: null,
738
734
  codec: null,
739
- materialized: null
735
+ materialized: null,
736
+ comment: null
740
737
  },
741
738
  {
742
739
  name: "errorMessage",
@@ -748,7 +745,8 @@ var dlqColumns = [
748
745
  annotations: [],
749
746
  ttl: null,
750
747
  codec: null,
751
- materialized: null
748
+ materialized: null,
749
+ comment: null
752
750
  },
753
751
  {
754
752
  name: "errorType",
@@ -760,7 +758,8 @@ var dlqColumns = [
760
758
  annotations: [],
761
759
  ttl: null,
762
760
  codec: null,
763
- materialized: null
761
+ materialized: null,
762
+ comment: null
764
763
  },
765
764
  {
766
765
  name: "failedAt",
@@ -772,7 +771,8 @@ var dlqColumns = [
772
771
  annotations: [],
773
772
  ttl: null,
774
773
  codec: null,
775
- materialized: null
774
+ materialized: null,
775
+ comment: null
776
776
  },
777
777
  {
778
778
  name: "source",
@@ -784,7 +784,8 @@ var dlqColumns = [
784
784
  annotations: [],
785
785
  ttl: null,
786
786
  codec: null,
787
- materialized: null
787
+ materialized: null,
788
+ comment: null
788
789
  }
789
790
  ];
790
791
 
@@ -2290,6 +2291,67 @@ var ETLPipeline = class {
2290
2291
  }
2291
2292
  };
2292
2293
 
2294
+ // src/dmv2/sdk/materializedView.ts
2295
+ var requireTargetTableName = (tableName) => {
2296
+ if (typeof tableName === "string") {
2297
+ return tableName;
2298
+ } else {
2299
+ throw new Error("Name of targetTable is not specified.");
2300
+ }
2301
+ };
2302
+ var MaterializedView = class {
2303
+ /** @internal */
2304
+ kind = "MaterializedView";
2305
+ /** The name of the materialized view */
2306
+ name;
2307
+ /** The target OlapTable instance where the materialized data is stored. */
2308
+ targetTable;
2309
+ /** The SELECT SQL statement */
2310
+ selectSql;
2311
+ /** Names of source tables that the SELECT reads from */
2312
+ sourceTables;
2313
+ /** @internal Source file path where this MV was defined */
2314
+ sourceFile;
2315
+ constructor(options, targetSchema, targetColumns) {
2316
+ let selectStatement = options.selectStatement;
2317
+ if (typeof selectStatement !== "string") {
2318
+ selectStatement = toStaticQuery(selectStatement);
2319
+ }
2320
+ if (targetSchema === void 0 || targetColumns === void 0) {
2321
+ throw new Error(
2322
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2323
+ );
2324
+ }
2325
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2326
+ requireTargetTableName(
2327
+ options.targetTable?.name ?? options.tableName
2328
+ ),
2329
+ {
2330
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2331
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2332
+ },
2333
+ targetSchema,
2334
+ targetColumns
2335
+ );
2336
+ if (targetTable.name === options.materializedViewName) {
2337
+ throw new Error(
2338
+ "Materialized view name cannot be the same as the target table name."
2339
+ );
2340
+ }
2341
+ this.name = options.materializedViewName;
2342
+ this.targetTable = targetTable;
2343
+ this.selectSql = selectStatement;
2344
+ this.sourceTables = options.selectTables.map((t) => t.name);
2345
+ const stack = new Error().stack;
2346
+ this.sourceFile = getSourceFileFromStack(stack);
2347
+ const materializedViews = getMooseInternal().materializedViews;
2348
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2349
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2350
+ }
2351
+ materializedViews.set(this.name, this);
2352
+ }
2353
+ };
2354
+
2293
2355
  // src/dmv2/sdk/sqlResource.ts
2294
2356
  var SqlResource = class {
2295
2357
  /** @internal */
@@ -2344,66 +2406,18 @@ var SqlResource = class {
2344
2406
  }
2345
2407
  };
2346
2408
 
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
-
2405
2409
  // src/dmv2/sdk/view.ts
2406
- var View = class extends SqlResource {
2410
+ var View = class {
2411
+ /** @internal */
2412
+ kind = "CustomView";
2413
+ /** The name of the view */
2414
+ name;
2415
+ /** The SELECT SQL statement that defines the view */
2416
+ selectSql;
2417
+ /** Names of source tables/views that the SELECT reads from */
2418
+ sourceTables;
2419
+ /** @internal Source file path where this view was defined */
2420
+ sourceFile;
2407
2421
  /**
2408
2422
  * Creates a new View instance.
2409
2423
  * @param name The name of the view to be created.
@@ -2414,17 +2428,16 @@ var View = class extends SqlResource {
2414
2428
  if (typeof selectStatement !== "string") {
2415
2429
  selectStatement = toStaticQuery(selectStatement);
2416
2430
  }
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
- );
2431
+ this.name = name;
2432
+ this.selectSql = selectStatement;
2433
+ this.sourceTables = baseTables.map((t) => t.name);
2434
+ const stack = new Error().stack;
2435
+ this.sourceFile = getSourceFileFromStack(stack);
2436
+ const customViews = getMooseInternal().customViews;
2437
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2438
+ throw new Error(`View with name ${this.name} already exists`);
2439
+ }
2440
+ customViews.set(this.name, this);
2428
2441
  }
2429
2442
  };
2430
2443
 
@@ -2613,6 +2626,18 @@ function getWebApps() {
2613
2626
  function getWebApp(name) {
2614
2627
  return getMooseInternal().webApps.get(name);
2615
2628
  }
2629
+ function getMaterializedViews() {
2630
+ return getMooseInternal().materializedViews;
2631
+ }
2632
+ function getMaterializedView(name) {
2633
+ return getMooseInternal().materializedViews.get(name);
2634
+ }
2635
+ function getCustomViews() {
2636
+ return getMooseInternal().customViews;
2637
+ }
2638
+ function getCustomView(name) {
2639
+ return getMooseInternal().customViews.get(name);
2640
+ }
2616
2641
  // Annotate the CommonJS export names for ESM import in node:
2617
2642
  0 && (module.exports = {
2618
2643
  Api,
@@ -2632,8 +2657,12 @@ function getWebApp(name) {
2632
2657
  Workflow,
2633
2658
  getApi,
2634
2659
  getApis,
2660
+ getCustomView,
2661
+ getCustomViews,
2635
2662
  getIngestApi,
2636
2663
  getIngestApis,
2664
+ getMaterializedView,
2665
+ getMaterializedViews,
2637
2666
  getSqlResource,
2638
2667
  getSqlResources,
2639
2668
  getStream,