@514labs/moose-lib 0.6.266-ci-2-g933b2685 → 0.6.266-ci-8-ge6e86870

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-Dd3ZmpTq.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-DSzxmiN9.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-Dd3ZmpTq.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-DSzxmiN9.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -598,16 +598,6 @@ function emptyIfUndefined(value) {
598
598
  return value === void 0 ? "" : value;
599
599
  }
600
600
 
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
601
  // src/dmv2/internal.ts
612
602
  var import_process = __toESM(require("process"));
613
603
 
@@ -658,7 +648,9 @@ var moose_internal = {
658
648
  apis: /* @__PURE__ */ new Map(),
659
649
  sqlResources: /* @__PURE__ */ new Map(),
660
650
  workflows: /* @__PURE__ */ new Map(),
661
- webApps: /* @__PURE__ */ new Map()
651
+ webApps: /* @__PURE__ */ new Map(),
652
+ materializedViews: /* @__PURE__ */ new Map(),
653
+ customViews: /* @__PURE__ */ new Map()
662
654
  };
663
655
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
664
656
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2285,6 +2277,67 @@ var ETLPipeline = class {
2285
2277
  }
2286
2278
  };
2287
2279
 
2280
+ // src/dmv2/sdk/materializedView.ts
2281
+ var requireTargetTableName = (tableName) => {
2282
+ if (typeof tableName === "string") {
2283
+ return tableName;
2284
+ } else {
2285
+ throw new Error("Name of targetTable is not specified.");
2286
+ }
2287
+ };
2288
+ var MaterializedView = class {
2289
+ /** @internal */
2290
+ kind = "MaterializedView";
2291
+ /** The name of the materialized view */
2292
+ name;
2293
+ /** The target OlapTable instance where the materialized data is stored. */
2294
+ targetTable;
2295
+ /** The SELECT SQL statement */
2296
+ selectSql;
2297
+ /** Names of source tables that the SELECT reads from */
2298
+ sourceTables;
2299
+ /** @internal Source file path where this MV was defined */
2300
+ sourceFile;
2301
+ constructor(options, targetSchema, targetColumns) {
2302
+ let selectStatement = options.selectStatement;
2303
+ if (typeof selectStatement !== "string") {
2304
+ selectStatement = toStaticQuery(selectStatement);
2305
+ }
2306
+ if (targetSchema === void 0 || targetColumns === void 0) {
2307
+ throw new Error(
2308
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2309
+ );
2310
+ }
2311
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2312
+ requireTargetTableName(
2313
+ options.targetTable?.name ?? options.tableName
2314
+ ),
2315
+ {
2316
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2317
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2318
+ },
2319
+ targetSchema,
2320
+ targetColumns
2321
+ );
2322
+ if (targetTable.name === options.materializedViewName) {
2323
+ throw new Error(
2324
+ "Materialized view name cannot be the same as the target table name."
2325
+ );
2326
+ }
2327
+ this.name = options.materializedViewName;
2328
+ this.targetTable = targetTable;
2329
+ this.selectSql = selectStatement;
2330
+ this.sourceTables = options.selectTables.map((t) => t.name);
2331
+ const stack = new Error().stack;
2332
+ this.sourceFile = getSourceFileFromStack(stack);
2333
+ const materializedViews = getMooseInternal().materializedViews;
2334
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2335
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2336
+ }
2337
+ materializedViews.set(this.name, this);
2338
+ }
2339
+ };
2340
+
2288
2341
  // src/dmv2/sdk/sqlResource.ts
2289
2342
  var SqlResource = class {
2290
2343
  /** @internal */
@@ -2339,66 +2392,18 @@ var SqlResource = class {
2339
2392
  }
2340
2393
  };
2341
2394
 
2342
- // src/dmv2/sdk/materializedView.ts
2343
- var requireTargetTableName = (tableName) => {
2344
- if (typeof tableName === "string") {
2345
- return tableName;
2346
- } else {
2347
- throw new Error("Name of targetTable is not specified.");
2348
- }
2349
- };
2350
- var MaterializedView = class extends SqlResource {
2351
- /** The target OlapTable instance where the materialized data is stored. */
2352
- targetTable;
2353
- constructor(options, targetSchema, targetColumns) {
2354
- let selectStatement = options.selectStatement;
2355
- if (typeof selectStatement !== "string") {
2356
- selectStatement = toStaticQuery(selectStatement);
2357
- }
2358
- if (targetSchema === void 0 || targetColumns === void 0) {
2359
- throw new Error(
2360
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2361
- );
2362
- }
2363
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2364
- requireTargetTableName(
2365
- options.targetTable?.name ?? options.tableName
2366
- ),
2367
- {
2368
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2369
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2370
- },
2371
- targetSchema,
2372
- targetColumns
2373
- );
2374
- if (targetTable.name === options.materializedViewName) {
2375
- throw new Error(
2376
- "Materialized view name cannot be the same as the target table name."
2377
- );
2378
- }
2379
- super(
2380
- options.materializedViewName,
2381
- [
2382
- createMaterializedView({
2383
- name: options.materializedViewName,
2384
- destinationTable: targetTable.name,
2385
- select: selectStatement
2386
- })
2387
- // Population is now handled automatically by Rust infrastructure
2388
- // based on table engine type and whether this is a new or updated view
2389
- ],
2390
- [dropView(options.materializedViewName)],
2391
- {
2392
- pullsDataFrom: options.selectTables,
2393
- pushesDataTo: [targetTable]
2394
- }
2395
- );
2396
- this.targetTable = targetTable;
2397
- }
2398
- };
2399
-
2400
2395
  // src/dmv2/sdk/view.ts
2401
- var View = class extends SqlResource {
2396
+ var View = class {
2397
+ /** @internal */
2398
+ kind = "CustomView";
2399
+ /** The name of the view */
2400
+ name;
2401
+ /** The SELECT SQL statement that defines the view */
2402
+ selectSql;
2403
+ /** Names of source tables/views that the SELECT reads from */
2404
+ sourceTables;
2405
+ /** @internal Source file path where this view was defined */
2406
+ sourceFile;
2402
2407
  /**
2403
2408
  * Creates a new View instance.
2404
2409
  * @param name The name of the view to be created.
@@ -2409,17 +2414,16 @@ var View = class extends SqlResource {
2409
2414
  if (typeof selectStatement !== "string") {
2410
2415
  selectStatement = toStaticQuery(selectStatement);
2411
2416
  }
2412
- super(
2413
- name,
2414
- [
2415
- `CREATE VIEW IF NOT EXISTS ${name}
2416
- AS ${selectStatement}`.trim()
2417
- ],
2418
- [dropView(name)],
2419
- {
2420
- pullsDataFrom: baseTables
2421
- }
2422
- );
2417
+ this.name = name;
2418
+ this.selectSql = selectStatement;
2419
+ this.sourceTables = baseTables.map((t) => t.name);
2420
+ const stack = new Error().stack;
2421
+ this.sourceFile = getSourceFileFromStack(stack);
2422
+ const customViews = getMooseInternal().customViews;
2423
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2424
+ throw new Error(`View with name ${this.name} already exists`);
2425
+ }
2426
+ customViews.set(this.name, this);
2423
2427
  }
2424
2428
  };
2425
2429