@514labs/moose-lib 0.6.279-ci-9-gaf2329aa → 0.6.279-ci-1-g5f380e27

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-BtkwFbT9.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, 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';
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-BtkwFbT9.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, 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';
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,
@@ -598,16 +602,6 @@ function emptyIfUndefined(value) {
598
602
  return value === void 0 ? "" : value;
599
603
  }
600
604
 
601
- // src/blocks/helpers.ts
602
- function dropView(name) {
603
- return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
604
- }
605
- function createMaterializedView(options) {
606
- return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
607
- TO ${quoteIdentifier(options.destinationTable)}
608
- AS ${options.select}`.trim();
609
- }
610
-
611
605
  // src/dmv2/internal.ts
612
606
  var import_process = __toESM(require("process"));
613
607
 
@@ -658,7 +652,9 @@ var moose_internal = {
658
652
  apis: /* @__PURE__ */ new Map(),
659
653
  sqlResources: /* @__PURE__ */ new Map(),
660
654
  workflows: /* @__PURE__ */ new Map(),
661
- webApps: /* @__PURE__ */ new Map()
655
+ webApps: /* @__PURE__ */ new Map(),
656
+ materializedViews: /* @__PURE__ */ new Map(),
657
+ customViews: /* @__PURE__ */ new Map()
662
658
  };
663
659
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
664
660
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2287,6 +2283,67 @@ var ETLPipeline = class {
2287
2283
  }
2288
2284
  };
2289
2285
 
2286
+ // src/dmv2/sdk/materializedView.ts
2287
+ var requireTargetTableName = (tableName) => {
2288
+ if (typeof tableName === "string") {
2289
+ return tableName;
2290
+ } else {
2291
+ throw new Error("Name of targetTable is not specified.");
2292
+ }
2293
+ };
2294
+ var MaterializedView = class {
2295
+ /** @internal */
2296
+ kind = "MaterializedView";
2297
+ /** The name of the materialized view */
2298
+ name;
2299
+ /** The target OlapTable instance where the materialized data is stored. */
2300
+ targetTable;
2301
+ /** The SELECT SQL statement */
2302
+ selectSql;
2303
+ /** Names of source tables that the SELECT reads from */
2304
+ sourceTables;
2305
+ /** @internal Source file path where this MV was defined */
2306
+ sourceFile;
2307
+ constructor(options, targetSchema, targetColumns) {
2308
+ let selectStatement = options.selectStatement;
2309
+ if (typeof selectStatement !== "string") {
2310
+ selectStatement = toStaticQuery(selectStatement);
2311
+ }
2312
+ if (targetSchema === void 0 || targetColumns === void 0) {
2313
+ throw new Error(
2314
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2315
+ );
2316
+ }
2317
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2318
+ requireTargetTableName(
2319
+ options.targetTable?.name ?? options.tableName
2320
+ ),
2321
+ {
2322
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2323
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2324
+ },
2325
+ targetSchema,
2326
+ targetColumns
2327
+ );
2328
+ if (targetTable.name === options.materializedViewName) {
2329
+ throw new Error(
2330
+ "Materialized view name cannot be the same as the target table name."
2331
+ );
2332
+ }
2333
+ this.name = options.materializedViewName;
2334
+ this.targetTable = targetTable;
2335
+ this.selectSql = selectStatement;
2336
+ this.sourceTables = options.selectTables.map((t) => t.name);
2337
+ const stack = new Error().stack;
2338
+ this.sourceFile = getSourceFileFromStack(stack);
2339
+ const materializedViews = getMooseInternal().materializedViews;
2340
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2341
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2342
+ }
2343
+ materializedViews.set(this.name, this);
2344
+ }
2345
+ };
2346
+
2290
2347
  // src/dmv2/sdk/sqlResource.ts
2291
2348
  var SqlResource = class {
2292
2349
  /** @internal */
@@ -2341,66 +2398,18 @@ var SqlResource = class {
2341
2398
  }
2342
2399
  };
2343
2400
 
2344
- // src/dmv2/sdk/materializedView.ts
2345
- var requireTargetTableName = (tableName) => {
2346
- if (typeof tableName === "string") {
2347
- return tableName;
2348
- } else {
2349
- throw new Error("Name of targetTable is not specified.");
2350
- }
2351
- };
2352
- var MaterializedView = class extends SqlResource {
2353
- /** The target OlapTable instance where the materialized data is stored. */
2354
- targetTable;
2355
- constructor(options, targetSchema, targetColumns) {
2356
- let selectStatement = options.selectStatement;
2357
- if (typeof selectStatement !== "string") {
2358
- selectStatement = toStaticQuery(selectStatement);
2359
- }
2360
- if (targetSchema === void 0 || targetColumns === void 0) {
2361
- throw new Error(
2362
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2363
- );
2364
- }
2365
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2366
- requireTargetTableName(
2367
- options.targetTable?.name ?? options.tableName
2368
- ),
2369
- {
2370
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2371
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2372
- },
2373
- targetSchema,
2374
- targetColumns
2375
- );
2376
- if (targetTable.name === options.materializedViewName) {
2377
- throw new Error(
2378
- "Materialized view name cannot be the same as the target table name."
2379
- );
2380
- }
2381
- super(
2382
- options.materializedViewName,
2383
- [
2384
- createMaterializedView({
2385
- name: options.materializedViewName,
2386
- destinationTable: targetTable.name,
2387
- select: selectStatement
2388
- })
2389
- // Population is now handled automatically by Rust infrastructure
2390
- // based on table engine type and whether this is a new or updated view
2391
- ],
2392
- [dropView(options.materializedViewName)],
2393
- {
2394
- pullsDataFrom: options.selectTables,
2395
- pushesDataTo: [targetTable]
2396
- }
2397
- );
2398
- this.targetTable = targetTable;
2399
- }
2400
- };
2401
-
2402
2401
  // src/dmv2/sdk/view.ts
2403
- var View = class extends SqlResource {
2402
+ var View = class {
2403
+ /** @internal */
2404
+ kind = "CustomView";
2405
+ /** The name of the view */
2406
+ name;
2407
+ /** The SELECT SQL statement that defines the view */
2408
+ selectSql;
2409
+ /** Names of source tables/views that the SELECT reads from */
2410
+ sourceTables;
2411
+ /** @internal Source file path where this view was defined */
2412
+ sourceFile;
2404
2413
  /**
2405
2414
  * Creates a new View instance.
2406
2415
  * @param name The name of the view to be created.
@@ -2411,17 +2420,16 @@ var View = class extends SqlResource {
2411
2420
  if (typeof selectStatement !== "string") {
2412
2421
  selectStatement = toStaticQuery(selectStatement);
2413
2422
  }
2414
- super(
2415
- name,
2416
- [
2417
- `CREATE VIEW IF NOT EXISTS ${name}
2418
- AS ${selectStatement}`.trim()
2419
- ],
2420
- [dropView(name)],
2421
- {
2422
- pullsDataFrom: baseTables
2423
- }
2424
- );
2423
+ this.name = name;
2424
+ this.selectSql = selectStatement;
2425
+ this.sourceTables = baseTables.map((t) => t.name);
2426
+ const stack = new Error().stack;
2427
+ this.sourceFile = getSourceFileFromStack(stack);
2428
+ const customViews = getMooseInternal().customViews;
2429
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2430
+ throw new Error(`View with name ${this.name} already exists`);
2431
+ }
2432
+ customViews.set(this.name, this);
2425
2433
  }
2426
2434
  };
2427
2435
 
@@ -2610,6 +2618,18 @@ function getWebApps() {
2610
2618
  function getWebApp(name) {
2611
2619
  return getMooseInternal().webApps.get(name);
2612
2620
  }
2621
+ function getMaterializedViews() {
2622
+ return getMooseInternal().materializedViews;
2623
+ }
2624
+ function getMaterializedView(name) {
2625
+ return getMooseInternal().materializedViews.get(name);
2626
+ }
2627
+ function getCustomViews() {
2628
+ return getMooseInternal().customViews;
2629
+ }
2630
+ function getCustomView(name) {
2631
+ return getMooseInternal().customViews.get(name);
2632
+ }
2613
2633
  // Annotate the CommonJS export names for ESM import in node:
2614
2634
  0 && (module.exports = {
2615
2635
  Api,
@@ -2629,8 +2649,12 @@ function getWebApp(name) {
2629
2649
  Workflow,
2630
2650
  getApi,
2631
2651
  getApis,
2652
+ getCustomView,
2653
+ getCustomViews,
2632
2654
  getIngestApi,
2633
2655
  getIngestApis,
2656
+ getMaterializedView,
2657
+ getMaterializedViews,
2634
2658
  getSqlResource,
2635
2659
  getSqlResources,
2636
2660
  getStream,