@514labs/moose-lib 0.6.292 → 0.6.293-ci-14-g63acc348

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, 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-rQOQo9sv.mjs';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ak 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, ao as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, ap 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, an as TaskConfig, am as TaskContext, al as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, K as getCustomView, N as getCustomViews, v as getIngestApi, u as getIngestApis, P as getMaterializedView, Q 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-CcZRaA0b.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, 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-rQOQo9sv.js';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, ak 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, ao as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, ap 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, an as TaskConfig, am as TaskContext, al as TransformConfig, V as View, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, K as getCustomView, N as getCustomViews, v as getIngestApi, u as getIngestApis, P as getMaterializedView, Q 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-CcZRaA0b.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -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;
@@ -2295,6 +2291,67 @@ var ETLPipeline = class {
2295
2291
  }
2296
2292
  };
2297
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
+
2298
2355
  // src/dmv2/sdk/sqlResource.ts
2299
2356
  var SqlResource = class {
2300
2357
  /** @internal */
@@ -2349,66 +2406,18 @@ var SqlResource = class {
2349
2406
  }
2350
2407
  };
2351
2408
 
2352
- // src/dmv2/sdk/materializedView.ts
2353
- var requireTargetTableName = (tableName) => {
2354
- if (typeof tableName === "string") {
2355
- return tableName;
2356
- } else {
2357
- throw new Error("Name of targetTable is not specified.");
2358
- }
2359
- };
2360
- var MaterializedView = class extends SqlResource {
2361
- /** The target OlapTable instance where the materialized data is stored. */
2362
- targetTable;
2363
- constructor(options, targetSchema, targetColumns) {
2364
- let selectStatement = options.selectStatement;
2365
- if (typeof selectStatement !== "string") {
2366
- selectStatement = toStaticQuery(selectStatement);
2367
- }
2368
- if (targetSchema === void 0 || targetColumns === void 0) {
2369
- throw new Error(
2370
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2371
- );
2372
- }
2373
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2374
- requireTargetTableName(
2375
- options.targetTable?.name ?? options.tableName
2376
- ),
2377
- {
2378
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2379
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2380
- },
2381
- targetSchema,
2382
- targetColumns
2383
- );
2384
- if (targetTable.name === options.materializedViewName) {
2385
- throw new Error(
2386
- "Materialized view name cannot be the same as the target table name."
2387
- );
2388
- }
2389
- super(
2390
- options.materializedViewName,
2391
- [
2392
- createMaterializedView({
2393
- name: options.materializedViewName,
2394
- destinationTable: targetTable.name,
2395
- select: selectStatement
2396
- })
2397
- // Population is now handled automatically by Rust infrastructure
2398
- // based on table engine type and whether this is a new or updated view
2399
- ],
2400
- [dropView(options.materializedViewName)],
2401
- {
2402
- pullsDataFrom: options.selectTables,
2403
- pushesDataTo: [targetTable]
2404
- }
2405
- );
2406
- this.targetTable = targetTable;
2407
- }
2408
- };
2409
-
2410
2409
  // src/dmv2/sdk/view.ts
2411
- 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;
2412
2421
  /**
2413
2422
  * Creates a new View instance.
2414
2423
  * @param name The name of the view to be created.
@@ -2419,17 +2428,16 @@ var View = class extends SqlResource {
2419
2428
  if (typeof selectStatement !== "string") {
2420
2429
  selectStatement = toStaticQuery(selectStatement);
2421
2430
  }
2422
- super(
2423
- name,
2424
- [
2425
- `CREATE VIEW IF NOT EXISTS ${name}
2426
- AS ${selectStatement}`.trim()
2427
- ],
2428
- [dropView(name)],
2429
- {
2430
- pullsDataFrom: baseTables
2431
- }
2432
- );
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);
2433
2441
  }
2434
2442
  };
2435
2443
 
@@ -2618,6 +2626,18 @@ function getWebApps() {
2618
2626
  function getWebApp(name) {
2619
2627
  return getMooseInternal().webApps.get(name);
2620
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
+ }
2621
2641
  // Annotate the CommonJS export names for ESM import in node:
2622
2642
  0 && (module.exports = {
2623
2643
  Api,
@@ -2637,8 +2657,12 @@ function getWebApp(name) {
2637
2657
  Workflow,
2638
2658
  getApi,
2639
2659
  getApis,
2660
+ getCustomView,
2661
+ getCustomViews,
2640
2662
  getIngestApi,
2641
2663
  getIngestApis,
2664
+ getMaterializedView,
2665
+ getMaterializedViews,
2642
2666
  getSqlResource,
2643
2667
  getSqlResources,
2644
2668
  getStream,