@514labs/moose-lib 0.6.262-ci-2-g1c866068 → 0.6.262-ci-7-g8a83699f

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-B1HsstjQ.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-B2jILcTY.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-B1HsstjQ.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-B2jILcTY.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -563,16 +563,6 @@ function emptyIfUndefined(value) {
563
563
  return value === void 0 ? "" : value;
564
564
  }
565
565
 
566
- // src/blocks/helpers.ts
567
- function dropView(name) {
568
- return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
569
- }
570
- function createMaterializedView(options) {
571
- return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
572
- TO ${quoteIdentifier(options.destinationTable)}
573
- AS ${options.select}`.trim();
574
- }
575
-
576
566
  // src/dmv2/internal.ts
577
567
  var import_process = __toESM(require("process"));
578
568
 
@@ -623,7 +613,9 @@ var moose_internal = {
623
613
  apis: /* @__PURE__ */ new Map(),
624
614
  sqlResources: /* @__PURE__ */ new Map(),
625
615
  workflows: /* @__PURE__ */ new Map(),
626
- webApps: /* @__PURE__ */ new Map()
616
+ webApps: /* @__PURE__ */ new Map(),
617
+ materializedViews: /* @__PURE__ */ new Map(),
618
+ customViews: /* @__PURE__ */ new Map()
627
619
  };
628
620
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
629
621
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2239,6 +2231,67 @@ var ETLPipeline = class {
2239
2231
  }
2240
2232
  };
2241
2233
 
2234
+ // src/dmv2/sdk/materializedView.ts
2235
+ var requireTargetTableName = (tableName) => {
2236
+ if (typeof tableName === "string") {
2237
+ return tableName;
2238
+ } else {
2239
+ throw new Error("Name of targetTable is not specified.");
2240
+ }
2241
+ };
2242
+ var MaterializedView = class {
2243
+ /** @internal */
2244
+ kind = "MaterializedView";
2245
+ /** The name of the materialized view */
2246
+ name;
2247
+ /** The target OlapTable instance where the materialized data is stored. */
2248
+ targetTable;
2249
+ /** The SELECT SQL statement */
2250
+ selectSql;
2251
+ /** Names of source tables that the SELECT reads from */
2252
+ sourceTables;
2253
+ /** @internal Source file path where this MV was defined */
2254
+ sourceFile;
2255
+ constructor(options, targetSchema, targetColumns) {
2256
+ let selectStatement = options.selectStatement;
2257
+ if (typeof selectStatement !== "string") {
2258
+ selectStatement = toStaticQuery(selectStatement);
2259
+ }
2260
+ if (targetSchema === void 0 || targetColumns === void 0) {
2261
+ throw new Error(
2262
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2263
+ );
2264
+ }
2265
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2266
+ requireTargetTableName(
2267
+ options.targetTable?.name ?? options.tableName
2268
+ ),
2269
+ {
2270
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2271
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2272
+ },
2273
+ targetSchema,
2274
+ targetColumns
2275
+ );
2276
+ if (targetTable.name === options.materializedViewName) {
2277
+ throw new Error(
2278
+ "Materialized view name cannot be the same as the target table name."
2279
+ );
2280
+ }
2281
+ this.name = options.materializedViewName;
2282
+ this.targetTable = targetTable;
2283
+ this.selectSql = selectStatement;
2284
+ this.sourceTables = options.selectTables.map((t) => t.name);
2285
+ const stack = new Error().stack;
2286
+ this.sourceFile = getSourceFileFromStack(stack);
2287
+ const materializedViews = getMooseInternal().materializedViews;
2288
+ if (!isClientOnlyMode() && materializedViews.has(this.name)) {
2289
+ throw new Error(`MaterializedView with name ${this.name} already exists`);
2290
+ }
2291
+ materializedViews.set(this.name, this);
2292
+ }
2293
+ };
2294
+
2242
2295
  // src/dmv2/sdk/sqlResource.ts
2243
2296
  var SqlResource = class {
2244
2297
  /** @internal */
@@ -2284,66 +2337,18 @@ var SqlResource = class {
2284
2337
  }
2285
2338
  };
2286
2339
 
2287
- // src/dmv2/sdk/materializedView.ts
2288
- var requireTargetTableName = (tableName) => {
2289
- if (typeof tableName === "string") {
2290
- return tableName;
2291
- } else {
2292
- throw new Error("Name of targetTable is not specified.");
2293
- }
2294
- };
2295
- var MaterializedView = class extends SqlResource {
2296
- /** The target OlapTable instance where the materialized data is stored. */
2297
- targetTable;
2298
- constructor(options, targetSchema, targetColumns) {
2299
- let selectStatement = options.selectStatement;
2300
- if (typeof selectStatement !== "string") {
2301
- selectStatement = toStaticQuery(selectStatement);
2302
- }
2303
- if (targetSchema === void 0 || targetColumns === void 0) {
2304
- throw new Error(
2305
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2306
- );
2307
- }
2308
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2309
- requireTargetTableName(
2310
- options.targetTable?.name ?? options.tableName
2311
- ),
2312
- {
2313
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2314
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2315
- },
2316
- targetSchema,
2317
- targetColumns
2318
- );
2319
- if (targetTable.name === options.materializedViewName) {
2320
- throw new Error(
2321
- "Materialized view name cannot be the same as the target table name."
2322
- );
2323
- }
2324
- super(
2325
- options.materializedViewName,
2326
- [
2327
- createMaterializedView({
2328
- name: options.materializedViewName,
2329
- destinationTable: targetTable.name,
2330
- select: selectStatement
2331
- })
2332
- // Population is now handled automatically by Rust infrastructure
2333
- // based on table engine type and whether this is a new or updated view
2334
- ],
2335
- [dropView(options.materializedViewName)],
2336
- {
2337
- pullsDataFrom: options.selectTables,
2338
- pushesDataTo: [targetTable]
2339
- }
2340
- );
2341
- this.targetTable = targetTable;
2342
- }
2343
- };
2344
-
2345
2340
  // src/dmv2/sdk/view.ts
2346
- var View = class extends SqlResource {
2341
+ var View = class {
2342
+ /** @internal */
2343
+ kind = "CustomView";
2344
+ /** The name of the view */
2345
+ name;
2346
+ /** The SELECT SQL statement that defines the view */
2347
+ selectSql;
2348
+ /** Names of source tables/views that the SELECT reads from */
2349
+ sourceTables;
2350
+ /** @internal Source file path where this view was defined */
2351
+ sourceFile;
2347
2352
  /**
2348
2353
  * Creates a new View instance.
2349
2354
  * @param name The name of the view to be created.
@@ -2354,17 +2359,16 @@ var View = class extends SqlResource {
2354
2359
  if (typeof selectStatement !== "string") {
2355
2360
  selectStatement = toStaticQuery(selectStatement);
2356
2361
  }
2357
- super(
2358
- name,
2359
- [
2360
- `CREATE VIEW IF NOT EXISTS ${name}
2361
- AS ${selectStatement}`.trim()
2362
- ],
2363
- [dropView(name)],
2364
- {
2365
- pullsDataFrom: baseTables
2366
- }
2367
- );
2362
+ this.name = name;
2363
+ this.selectSql = selectStatement;
2364
+ this.sourceTables = baseTables.map((t) => t.name);
2365
+ const stack = new Error().stack;
2366
+ this.sourceFile = getSourceFileFromStack(stack);
2367
+ const customViews = getMooseInternal().customViews;
2368
+ if (!isClientOnlyMode() && customViews.has(this.name)) {
2369
+ throw new Error(`View with name ${this.name} already exists`);
2370
+ }
2371
+ customViews.set(this.name, this);
2368
2372
  }
2369
2373
  };
2370
2374