@bayoudhi/moose-lib-serverless 0.1.2 → 0.2.0

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,14 +1,71 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // stub-native:@514labs/kafka-javascript
28
+ var require_kafka_javascript = __commonJS({
29
+ "stub-native:@514labs/kafka-javascript"(exports, module) {
30
+ "use strict";
31
+ module.exports = {};
32
+ }
33
+ });
34
+
35
+ // stub-native:@kafkajs/confluent-schema-registry
36
+ var require_confluent_schema_registry = __commonJS({
37
+ "stub-native:@kafkajs/confluent-schema-registry"(exports, module) {
38
+ "use strict";
39
+ module.exports = {};
40
+ }
41
+ });
42
+
43
+ // ../ts-moose-lib/dist/serverless.mjs
44
+ var import_kafka_javascript = __toESM(require_kafka_javascript(), 1);
45
+ import path from "path";
46
+ import * as toml from "toml";
47
+ import { createClient } from "@clickhouse/client";
48
+ import {
49
+ existsSync,
50
+ readdirSync,
51
+ readFileSync,
52
+ writeFileSync
53
+ } from "fs";
54
+ import nodePath from "path";
55
+ import process2 from "process";
56
+ import { Readable } from "stream";
57
+ import { createHash } from "crypto";
58
+ import { createHash as createHash2 } from "crypto";
59
+ import { parse as parse2 } from "csv-parse";
60
+ var __defProp2 = Object.defineProperty;
61
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
3
62
  var __esm = (fn, res) => function __init() {
4
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
63
+ return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
5
64
  };
6
65
  var __export = (target, all) => {
7
66
  for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
67
+ __defProp2(target, name, { get: all[name], enumerable: true });
9
68
  };
10
-
11
- // src/commons-types.ts
12
69
  function isTruthy(value) {
13
70
  if (!value) return false;
14
71
  switch (value.trim().toLowerCase()) {
@@ -24,7 +81,17 @@ function isTruthy(value) {
24
81
  function mapTstoJs(filePath) {
25
82
  return filePath.replace(/\.ts$/, ".js").replace(/\.cts$/, ".cjs").replace(/\.mts$/, ".mjs");
26
83
  }
27
- var compilerLog, antiCachePath, getFileName, cliLog, MAX_RETRIES, MAX_RETRY_TIME_MS, RETRY_INITIAL_TIME_MS, MAX_RETRIES_PRODUCER, RETRY_FACTOR_PRODUCER, ACKs, logError;
84
+ var compilerLog;
85
+ var antiCachePath;
86
+ var getFileName;
87
+ var cliLog;
88
+ var MAX_RETRIES;
89
+ var MAX_RETRY_TIME_MS;
90
+ var RETRY_INITIAL_TIME_MS;
91
+ var MAX_RETRIES_PRODUCER;
92
+ var RETRY_FACTOR_PRODUCER;
93
+ var ACKs;
94
+ var logError;
28
95
  var init_commons_types = __esm({
29
96
  "src/commons-types.ts"() {
30
97
  "use strict";
@@ -70,10 +137,6 @@ var init_commons_types = __esm({
70
137
  };
71
138
  }
72
139
  });
73
-
74
- // src/config/configFile.ts
75
- import path from "path";
76
- import * as toml from "toml";
77
140
  async function findConfigFile(startDir = process.cwd()) {
78
141
  const fs = await import("fs");
79
142
  let currentDir = path.resolve(startDir);
@@ -118,8 +181,6 @@ var init_configFile = __esm({
118
181
  };
119
182
  }
120
183
  });
121
-
122
- // src/config/runtime.ts
123
184
  var runtime_exports = {};
124
185
  var ConfigurationRegistry;
125
186
  var init_runtime = __esm({
@@ -254,8 +315,6 @@ var init_runtime = __esm({
254
315
  globalThis._mooseConfigRegistry = ConfigurationRegistry.getInstance();
255
316
  }
256
317
  });
257
-
258
- // src/commons.ts
259
318
  var commons_exports = {};
260
319
  __export(commons_exports, {
261
320
  ACKs: () => ACKs,
@@ -276,15 +335,6 @@ __export(commons_exports, {
276
335
  mapTstoJs: () => mapTstoJs,
277
336
  rewriteImportExtensions: () => rewriteImportExtensions
278
337
  });
279
- import { KafkaJS } from "@514labs/kafka-javascript";
280
- import { createClient } from "@clickhouse/client";
281
- import {
282
- existsSync,
283
- readdirSync,
284
- readFileSync,
285
- writeFileSync
286
- } from "fs";
287
- import nodePath from "path";
288
338
  function walkDirectory(dir, extensions) {
289
339
  const results = [];
290
340
  if (!existsSync(dir)) {
@@ -395,13 +445,17 @@ async function getKafkaProducer(cfg, logger, maxMessageBytes) {
395
445
  await producer.connect();
396
446
  return producer;
397
447
  }
398
- var Kafka, getClickhouseClient, parseBrokerString, buildSaslConfig, getKafkaClient;
448
+ var Kafka;
449
+ var getClickhouseClient;
450
+ var parseBrokerString;
451
+ var buildSaslConfig;
452
+ var getKafkaClient;
399
453
  var init_commons = __esm({
400
454
  "src/commons.ts"() {
401
455
  "use strict";
402
456
  init_commons_types();
403
457
  init_commons_types();
404
- ({ Kafka } = KafkaJS);
458
+ ({ Kafka } = import_kafka_javascript.KafkaJS);
405
459
  getClickhouseClient = ({
406
460
  username,
407
461
  password,
@@ -464,8 +518,6 @@ var init_commons = __esm({
464
518
  };
465
519
  }
466
520
  });
467
-
468
- // src/dataModels/types.ts
469
521
  var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
470
522
  ClickHouseEngines2["MergeTree"] = "MergeTree";
471
523
  ClickHouseEngines2["ReplacingMergeTree"] = "ReplacingMergeTree";
@@ -488,8 +540,6 @@ var ClickHouseEngines = /* @__PURE__ */ ((ClickHouseEngines2) => {
488
540
  ClickHouseEngines2["ReplicatedVersionedCollapsingMergeTree"] = "ReplicatedVersionedCollapsingMergeTree";
489
541
  return ClickHouseEngines2;
490
542
  })(ClickHouseEngines || {});
491
-
492
- // src/dmv2/utils/stackTrace.ts
493
543
  function shouldSkipStackLine(line) {
494
544
  return line.includes("node_modules") || // Skip npm installed packages (prod)
495
545
  line.includes("node:internal") || // Skip Node.js internals (modern format)
@@ -550,8 +600,6 @@ function getSourceFileFromStack(stack) {
550
600
  const location = getSourceLocationFromStack(stack);
551
601
  return location?.file;
552
602
  }
553
-
554
- // src/dmv2/typedBase.ts
555
603
  var TypedBase = class {
556
604
  /** The JSON schema representation of type T. Injected by the compiler plugin. */
557
605
  schema;
@@ -610,18 +658,13 @@ var TypedBase = class {
610
658
  }
611
659
  }
612
660
  };
613
-
614
- // src/dataModels/dataModelTypes.ts
615
661
  function isArrayNestedType(dt) {
616
662
  return typeof dt === "object" && dt !== null && dt.elementType !== null && typeof dt.elementType === "object" && dt.elementType.hasOwnProperty("columns") && Array.isArray(dt.elementType.columns);
617
663
  }
618
664
  function isNestedType(dt) {
619
665
  return typeof dt === "object" && dt !== null && Array.isArray(dt.columns);
620
666
  }
621
-
622
- // src/dmv2/internal.ts
623
667
  init_commons_types();
624
- import process2 from "process";
625
668
  var isClientOnlyMode = () => process2.env.MOOSE_CLIENT_ONLY === "true";
626
669
  var moose_internal = {
627
670
  tables: /* @__PURE__ */ new Map(),
@@ -763,12 +806,6 @@ var dlqColumns = [
763
806
  comment: null
764
807
  }
765
808
  ];
766
-
767
- // src/dmv2/sdk/olapTable.ts
768
- import { Readable } from "stream";
769
- import { createHash } from "crypto";
770
-
771
- // src/sqlHelpers.ts
772
809
  var quoteIdentifier = (name) => {
773
810
  return name.startsWith("`") && name.endsWith("`") ? name : `\`${name}\``;
774
811
  };
@@ -939,8 +976,6 @@ var mapToClickHouseType = (value) => {
939
976
  function emptyIfUndefined(value) {
940
977
  return value === void 0 ? "" : value;
941
978
  }
942
-
943
- // src/dmv2/sdk/olapTable.ts
944
979
  var OlapTable = class extends TypedBase {
945
980
  name;
946
981
  /** @internal */
@@ -952,7 +987,14 @@ var OlapTable = class extends TypedBase {
952
987
  /** @internal Cached table name to avoid repeated generation */
953
988
  _cachedTableName;
954
989
  constructor(name, config, schema, columns, validators) {
955
- const resolvedConfig = config ? "engine" in config ? config : { ...config, engine: "MergeTree" /* MergeTree */ } : { engine: "MergeTree" /* MergeTree */ };
990
+ const resolvedConfig = config ? "engine" in config ? config : {
991
+ ...config,
992
+ engine: "MergeTree"
993
+ /* MergeTree */
994
+ } : {
995
+ engine: "MergeTree"
996
+ /* MergeTree */
997
+ };
956
998
  const hasFields = Array.isArray(resolvedConfig.orderByFields) && resolvedConfig.orderByFields.length > 0;
957
999
  const hasExpr = typeof resolvedConfig.orderByExpression === "string" && resolvedConfig.orderByExpression.length > 0;
958
1000
  if (hasFields && hasExpr) {
@@ -1622,9 +1664,6 @@ var OlapTable = class extends TypedBase {
1622
1664
  // were removed in ENG-856. Use direct configuration instead, e.g.:
1623
1665
  // new OlapTable(name, { engine: ClickHouseEngines.ReplacingMergeTree, orderByFields: ["id"], ver: "updated_at" })
1624
1666
  };
1625
-
1626
- // src/dmv2/sdk/stream.ts
1627
- import { createHash as createHash2 } from "crypto";
1628
1667
  var RoutedMessage = class {
1629
1668
  /** The destination stream for the message */
1630
1669
  destination;
@@ -1778,7 +1817,7 @@ var Stream = class extends TypedBase {
1778
1817
  }
1779
1818
  const {
1780
1819
  default: { SchemaRegistry }
1781
- } = await import("@kafkajs/confluent-schema-registry");
1820
+ } = await Promise.resolve().then(() => __toESM(require_confluent_schema_registry(), 1));
1782
1821
  const registry = new SchemaRegistry({ host: schemaRegistryUrl });
1783
1822
  let schemaId;
1784
1823
  if ("id" in sr.reference) {
@@ -1958,8 +1997,6 @@ var DeadLetterQueue = class extends Stream {
1958
1997
  super.addMultiTransform(withValidate);
1959
1998
  }
1960
1999
  };
1961
-
1962
- // src/dmv2/sdk/workflow.ts
1963
2000
  var Task = class {
1964
2001
  /**
1965
2002
  * Creates a new Task instance.
@@ -2067,8 +2104,6 @@ var Workflow = class {
2067
2104
  validateTask(startingTask, []);
2068
2105
  }
2069
2106
  };
2070
-
2071
- // src/dmv2/sdk/ingestApi.ts
2072
2107
  var IngestApi = class extends TypedBase {
2073
2108
  constructor(name, config, schema, columns, validators, allowExtraFields) {
2074
2109
  super(name, config, schema, columns, void 0, allowExtraFields);
@@ -2079,8 +2114,6 @@ var IngestApi = class extends TypedBase {
2079
2114
  ingestApis.set(name, this);
2080
2115
  }
2081
2116
  };
2082
-
2083
- // src/dmv2/sdk/consumptionApi.ts
2084
2117
  var Api = class extends TypedBase {
2085
2118
  /** @internal The handler function that processes requests and generates responses. */
2086
2119
  _handler;
@@ -2187,8 +2220,6 @@ var Api = class extends TypedBase {
2187
2220
  }
2188
2221
  };
2189
2222
  var ConsumptionApi = Api;
2190
-
2191
- // src/dmv2/sdk/ingestPipeline.ts
2192
2223
  var IngestPipeline = class extends TypedBase {
2193
2224
  /**
2194
2225
  * The OLAP table component of the pipeline, if configured.
@@ -2227,7 +2258,7 @@ var IngestPipeline = class extends TypedBase {
2227
2258
  ...config.version && { version: config.version }
2228
2259
  } : {
2229
2260
  lifeCycle: config.lifeCycle,
2230
- engine: "MergeTree" /* MergeTree */,
2261
+ engine: "MergeTree",
2231
2262
  ...config.version && { version: config.version }
2232
2263
  };
2233
2264
  this.table = new OlapTable(
@@ -2297,8 +2328,6 @@ var IngestPipeline = class extends TypedBase {
2297
2328
  }
2298
2329
  }
2299
2330
  };
2300
-
2301
- // src/dmv2/sdk/etlPipeline.ts
2302
2331
  var InternalBatcher = class {
2303
2332
  iterator;
2304
2333
  batchSize;
@@ -2439,8 +2468,6 @@ var ETLPipeline = class {
2439
2468
  console.log(`Completed ETL Pipeline: ${this.name}`);
2440
2469
  }
2441
2470
  };
2442
-
2443
- // src/dmv2/sdk/materializedView.ts
2444
2471
  function formatTableReference(table) {
2445
2472
  const database = table instanceof OlapTable ? table.config.database : void 0;
2446
2473
  if (database) {
@@ -2484,7 +2511,8 @@ var MaterializedView = class {
2484
2511
  ),
2485
2512
  {
2486
2513
  orderByFields: options.targetTable?.orderByFields ?? options.orderByFields,
2487
- engine: options.targetTable?.engine ?? options.engine ?? "MergeTree" /* MergeTree */
2514
+ engine: options.targetTable?.engine ?? options.engine ?? "MergeTree"
2515
+ /* MergeTree */
2488
2516
  },
2489
2517
  targetSchema,
2490
2518
  targetColumns
@@ -2515,8 +2543,6 @@ var MaterializedView = class {
2515
2543
  materializedViews.set(this.name, this);
2516
2544
  }
2517
2545
  };
2518
-
2519
- // src/dmv2/sdk/sqlResource.ts
2520
2546
  var SqlResource = class {
2521
2547
  /** @internal */
2522
2548
  kind = "SqlResource";
@@ -2569,8 +2595,6 @@ var SqlResource = class {
2569
2595
  }
2570
2596
  }
2571
2597
  };
2572
-
2573
- // src/dmv2/sdk/view.ts
2574
2598
  function formatTableReference2(table) {
2575
2599
  const database = table instanceof OlapTable ? table.config.database : void 0;
2576
2600
  if (database) {
@@ -2618,16 +2642,12 @@ var View = class {
2618
2642
  views.set(this.name, this);
2619
2643
  }
2620
2644
  };
2621
-
2622
- // src/dmv2/sdk/lifeCycle.ts
2623
2645
  var LifeCycle = /* @__PURE__ */ ((LifeCycle2) => {
2624
2646
  LifeCycle2["FULLY_MANAGED"] = "FULLY_MANAGED";
2625
2647
  LifeCycle2["DELETION_PROTECTED"] = "DELETION_PROTECTED";
2626
2648
  LifeCycle2["EXTERNALLY_MANAGED"] = "EXTERNALLY_MANAGED";
2627
2649
  return LifeCycle2;
2628
2650
  })(LifeCycle || {});
2629
-
2630
- // src/dmv2/sdk/webApp.ts
2631
2651
  var RESERVED_MOUNT_PATHS = [
2632
2652
  "/admin",
2633
2653
  "/api",
@@ -2740,8 +2760,6 @@ Examples:
2740
2760
  return this._rawApp;
2741
2761
  }
2742
2762
  };
2743
-
2744
- // src/dmv2/registry.ts
2745
2763
  function getTables() {
2746
2764
  return getMooseInternal().tables;
2747
2765
  }
@@ -2817,11 +2835,7 @@ function getViews() {
2817
2835
  function getView(name) {
2818
2836
  return getMooseInternal().views.get(name);
2819
2837
  }
2820
-
2821
- // src/serverless.ts
2822
2838
  init_commons_types();
2823
-
2824
- // src/connectors/dataSource.ts
2825
2839
  var DataSource = class {
2826
2840
  name;
2827
2841
  supportsIncremental;
@@ -2830,8 +2844,6 @@ var DataSource = class {
2830
2844
  this.supportsIncremental = config.supportsIncremental ?? false;
2831
2845
  }
2832
2846
  };
2833
-
2834
- // src/secrets.ts
2835
2847
  var MOOSE_RUNTIME_ENV_PREFIX = "__MOOSE_RUNTIME_ENV__:";
2836
2848
  var mooseRuntimeEnv = {
2837
2849
  /**
@@ -2876,11 +2888,6 @@ var mooseRuntimeEnv = {
2876
2888
  }
2877
2889
  };
2878
2890
  var mooseEnvSecrets = mooseRuntimeEnv;
2879
-
2880
- // src/utilities/dataParser.ts
2881
- import { parse as parse2 } from "csv-parse";
2882
-
2883
- // src/utilities/json.ts
2884
2891
  function jsonDateReviver(key, value) {
2885
2892
  const iso8601Format = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)$/;
2886
2893
  if (typeof value === "string" && iso8601Format.test(value)) {
@@ -2888,8 +2895,6 @@ function jsonDateReviver(key, value) {
2888
2895
  }
2889
2896
  return value;
2890
2897
  }
2891
-
2892
- // src/utilities/dataParser.ts
2893
2898
  function parseCSV(content, config) {
2894
2899
  return new Promise((resolve, reject) => {
2895
2900
  const results = [];
@@ -3010,4 +3015,4 @@ export {
3010
3015
  toQueryPreview,
3011
3016
  toStaticQuery
3012
3017
  };
3013
- //# sourceMappingURL=serverless.mjs.map
3018
+ //# sourceMappingURL=index.mjs.map