@514labs/moose-lib 0.6.262-ci-2-g350aed07 → 0.6.262-ci-5-gf85ca97c

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-CQB6bk1i.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-CQB6bk1i.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';
@@ -444,35 +444,8 @@ function getSourceFileInfo(stack) {
444
444
  }
445
445
  return {};
446
446
  }
447
- function getSourceLocationFromStack(stack) {
448
- if (!stack) return void 0;
449
- const lines = stack.split("\n");
450
- for (const line of lines.slice(1)) {
451
- if (shouldSkipStackLine(line)) {
452
- continue;
453
- }
454
- const v8Match = line.match(/at\s+(?:.*?\s+\()?(.+):(\d+):(\d+)\)?/);
455
- if (v8Match) {
456
- return {
457
- file: v8Match[1],
458
- line: parseInt(v8Match[2], 10),
459
- column: parseInt(v8Match[3], 10)
460
- };
461
- }
462
- const smMatch = line.match(/(?:.*@)?(.+):(\d+):(\d+)/);
463
- if (smMatch) {
464
- return {
465
- file: smMatch[1],
466
- line: parseInt(smMatch[2], 10),
467
- column: parseInt(smMatch[3], 10)
468
- };
469
- }
470
- }
471
- return void 0;
472
- }
473
447
  function getSourceFileFromStack(stack) {
474
- const location = getSourceLocationFromStack(stack);
475
- return location?.file;
448
+ return getSourceFileInfo(stack).file;
476
449
  }
477
450
 
478
451
  // src/dmv2/typedBase.ts
@@ -590,16 +563,6 @@ function emptyIfUndefined(value) {
590
563
  return value === void 0 ? "" : value;
591
564
  }
592
565
 
593
- // src/blocks/helpers.ts
594
- function dropView(name) {
595
- return `DROP VIEW IF EXISTS ${quoteIdentifier(name)}`.trim();
596
- }
597
- function createMaterializedView(options) {
598
- return `CREATE MATERIALIZED VIEW IF NOT EXISTS ${quoteIdentifier(options.name)}
599
- TO ${quoteIdentifier(options.destinationTable)}
600
- AS ${options.select}`.trim();
601
- }
602
-
603
566
  // src/dmv2/internal.ts
604
567
  var import_process = __toESM(require("process"));
605
568
 
@@ -650,7 +613,9 @@ var moose_internal = {
650
613
  apis: /* @__PURE__ */ new Map(),
651
614
  sqlResources: /* @__PURE__ */ new Map(),
652
615
  workflows: /* @__PURE__ */ new Map(),
653
- webApps: /* @__PURE__ */ new Map()
616
+ webApps: /* @__PURE__ */ new Map(),
617
+ materializedViews: /* @__PURE__ */ new Map(),
618
+ customViews: /* @__PURE__ */ new Map()
654
619
  };
655
620
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
656
621
  var getMooseInternal = () => globalThis.moose_internal;
@@ -2266,6 +2231,67 @@ var ETLPipeline = class {
2266
2231
  }
2267
2232
  };
2268
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
+
2269
2295
  // src/dmv2/sdk/sqlResource.ts
2270
2296
  var SqlResource = class {
2271
2297
  /** @internal */
@@ -2282,10 +2308,6 @@ var SqlResource = class {
2282
2308
  pushesDataTo;
2283
2309
  /** @internal Source file path where this resource was defined */
2284
2310
  sourceFile;
2285
- /** @internal Source line number where this resource was defined */
2286
- sourceLine;
2287
- /** @internal Source column number where this resource was defined */
2288
- sourceColumn;
2289
2311
  /**
2290
2312
  * Creates a new SqlResource instance.
2291
2313
  * @param name The name of the resource.
@@ -2311,75 +2333,22 @@ var SqlResource = class {
2311
2333
  this.pullsDataFrom = options?.pullsDataFrom ?? [];
2312
2334
  this.pushesDataTo = options?.pushesDataTo ?? [];
2313
2335
  const stack = new Error().stack;
2314
- const location = getSourceLocationFromStack(stack);
2315
- if (location) {
2316
- this.sourceFile = location.file;
2317
- this.sourceLine = location.line;
2318
- this.sourceColumn = location.column;
2319
- }
2320
- }
2321
- };
2322
-
2323
- // src/dmv2/sdk/materializedView.ts
2324
- var requireTargetTableName = (tableName) => {
2325
- if (typeof tableName === "string") {
2326
- return tableName;
2327
- } else {
2328
- throw new Error("Name of targetTable is not specified.");
2329
- }
2330
- };
2331
- var MaterializedView = class extends SqlResource {
2332
- /** The target OlapTable instance where the materialized data is stored. */
2333
- targetTable;
2334
- constructor(options, targetSchema, targetColumns) {
2335
- let selectStatement = options.selectStatement;
2336
- if (typeof selectStatement !== "string") {
2337
- selectStatement = toStaticQuery(selectStatement);
2338
- }
2339
- if (targetSchema === void 0 || targetColumns === void 0) {
2340
- throw new Error(
2341
- "Supply the type param T so that the schema is inserted by the compiler plugin."
2342
- );
2343
- }
2344
- const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
2345
- requireTargetTableName(
2346
- options.targetTable?.name ?? options.tableName
2347
- ),
2348
- {
2349
- orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2350
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2351
- },
2352
- targetSchema,
2353
- targetColumns
2354
- );
2355
- if (targetTable.name === options.materializedViewName) {
2356
- throw new Error(
2357
- "Materialized view name cannot be the same as the target table name."
2358
- );
2359
- }
2360
- super(
2361
- options.materializedViewName,
2362
- [
2363
- createMaterializedView({
2364
- name: options.materializedViewName,
2365
- destinationTable: targetTable.name,
2366
- select: selectStatement
2367
- })
2368
- // Population is now handled automatically by Rust infrastructure
2369
- // based on table engine type and whether this is a new or updated view
2370
- ],
2371
- [dropView(options.materializedViewName)],
2372
- {
2373
- pullsDataFrom: options.selectTables,
2374
- pushesDataTo: [targetTable]
2375
- }
2376
- );
2377
- this.targetTable = targetTable;
2336
+ this.sourceFile = getSourceFileFromStack(stack);
2378
2337
  }
2379
2338
  };
2380
2339
 
2381
2340
  // src/dmv2/sdk/view.ts
2382
- 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;
2383
2352
  /**
2384
2353
  * Creates a new View instance.
2385
2354
  * @param name The name of the view to be created.
@@ -2390,17 +2359,16 @@ var View = class extends SqlResource {
2390
2359
  if (typeof selectStatement !== "string") {
2391
2360
  selectStatement = toStaticQuery(selectStatement);
2392
2361
  }
2393
- super(
2394
- name,
2395
- [
2396
- `CREATE VIEW IF NOT EXISTS ${name}
2397
- AS ${selectStatement}`.trim()
2398
- ],
2399
- [dropView(name)],
2400
- {
2401
- pullsDataFrom: baseTables
2402
- }
2403
- );
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);
2404
2372
  }
2405
2373
  };
2406
2374