@514labs/moose-lib 0.6.262-ci-6-gd6cda938 → 0.6.262-ci-3-ge15fe9de

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-B2jILcTY.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-B1HsstjQ.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-B2jILcTY.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-B1HsstjQ.js';
2
2
  import 'typia';
3
3
  import 'typia/src/schemas/json/IJsonSchemaCollection';
4
4
  import 'node:stream';
@@ -563,6 +563,16 @@ 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
+
566
576
  // src/dmv2/internal.ts
567
577
  var import_process = __toESM(require("process"));
568
578
 
@@ -613,9 +623,7 @@ var moose_internal = {
613
623
  apis: /* @__PURE__ */ new Map(),
614
624
  sqlResources: /* @__PURE__ */ new Map(),
615
625
  workflows: /* @__PURE__ */ new Map(),
616
- webApps: /* @__PURE__ */ new Map(),
617
- materializedViews: /* @__PURE__ */ new Map(),
618
- customViews: /* @__PURE__ */ new Map()
626
+ webApps: /* @__PURE__ */ new Map()
619
627
  };
620
628
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
621
629
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2025,6 +2033,7 @@ var IngestPipeline = class extends TypedBase {
2025
2033
  if (config.table) {
2026
2034
  const tableConfig = typeof config.table === "object" ? {
2027
2035
  ...config.table,
2036
+ lifeCycle: config.table.lifeCycle ?? config.lifeCycle,
2028
2037
  ...config.version && { version: config.version }
2029
2038
  } : {
2030
2039
  lifeCycle: config.lifeCycle,
@@ -2055,7 +2064,10 @@ var IngestPipeline = class extends TypedBase {
2055
2064
  const streamConfig = {
2056
2065
  destination: this.table,
2057
2066
  defaultDeadLetterQueue: this.deadLetterQueue,
2058
- ...typeof config.stream === "object" ? config.stream : { lifeCycle: config.lifeCycle },
2067
+ ...typeof config.stream === "object" ? {
2068
+ ...config.stream,
2069
+ lifeCycle: config.stream.lifeCycle ?? config.lifeCycle
2070
+ } : { lifeCycle: config.lifeCycle },
2059
2071
  ...config.version && { version: config.version }
2060
2072
  };
2061
2073
  this.stream = new Stream(
@@ -2231,67 +2243,6 @@ var ETLPipeline = class {
2231
2243
  }
2232
2244
  };
2233
2245
 
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
-
2295
2246
  // src/dmv2/sdk/sqlResource.ts
2296
2247
  var SqlResource = class {
2297
2248
  /** @internal */
@@ -2337,18 +2288,66 @@ var SqlResource = class {
2337
2288
  }
2338
2289
  };
2339
2290
 
2291
+ // src/dmv2/sdk/materializedView.ts
2292
+ var requireTargetTableName = (tableName) => {
2293
+ if (typeof tableName === "string") {
2294
+ return tableName;
2295
+ } else {
2296
+ throw new Error("Name of targetTable is not specified.");
2297
+ }
2298
+ };
2299
+ var MaterializedView = class extends SqlResource {
2300
+ /** The target OlapTable instance where the materialized data is stored. */
2301
+ targetTable;
2302
+ constructor(options, targetSchema, targetColumns) {
2303
+ let selectStatement = options.selectStatement;
2304
+ if (typeof selectStatement !== "string") {
2305
+ selectStatement = toStaticQuery(selectStatement);
2306
+ }
2307
+ if (targetSchema === void 0 || targetColumns === void 0) {
2308
+ throw new Error(
2309
+ "Supply the type param T so that the schema is inserted by the compiler plugin."
2310
+ );
2311
+ }
2312
+ const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2313
+ requireTargetTableName(
2314
+ options.targetTable?.name ?? options.tableName
2315
+ ),
2316
+ {
2317
+ orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2318
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2319
+ },
2320
+ targetSchema,
2321
+ targetColumns
2322
+ );
2323
+ if (targetTable.name === options.materializedViewName) {
2324
+ throw new Error(
2325
+ "Materialized view name cannot be the same as the target table name."
2326
+ );
2327
+ }
2328
+ super(
2329
+ options.materializedViewName,
2330
+ [
2331
+ createMaterializedView({
2332
+ name: options.materializedViewName,
2333
+ destinationTable: targetTable.name,
2334
+ select: selectStatement
2335
+ })
2336
+ // Population is now handled automatically by Rust infrastructure
2337
+ // based on table engine type and whether this is a new or updated view
2338
+ ],
2339
+ [dropView(options.materializedViewName)],
2340
+ {
2341
+ pullsDataFrom: options.selectTables,
2342
+ pushesDataTo: [targetTable]
2343
+ }
2344
+ );
2345
+ this.targetTable = targetTable;
2346
+ }
2347
+ };
2348
+
2340
2349
  // src/dmv2/sdk/view.ts
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;
2350
+ var View = class extends SqlResource {
2352
2351
  /**
2353
2352
  * Creates a new View instance.
2354
2353
  * @param name The name of the view to be created.
@@ -2359,16 +2358,17 @@ var View = class {
2359
2358
  if (typeof selectStatement !== "string") {
2360
2359
  selectStatement = toStaticQuery(selectStatement);
2361
2360
  }
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);
2361
+ super(
2362
+ name,
2363
+ [
2364
+ `CREATE VIEW IF NOT EXISTS ${name}
2365
+ AS ${selectStatement}`.trim()
2366
+ ],
2367
+ [dropView(name)],
2368
+ {
2369
+ pullsDataFrom: baseTables
2370
+ }
2371
+ );
2372
2372
  }
2373
2373
  };
2374
2374