@bayoudhi/moose-lib-serverless 0.1.0 → 0.1.2

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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Tim Delisle, Nicolas Joseph
4
+ Copyright (c) 2026 Hamza MEHRI
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @bayoudhi/moose-lib-serverless
2
+
3
+ Serverless-compatible subset of [`@514labs/moose-lib`](https://www.npmjs.com/package/@514labs/moose-lib) for **AWS Lambda**, **Edge runtimes**, and other environments where native C++ modules cannot be compiled or loaded.
4
+
5
+ This package re-exports the pure-TypeScript surface of the Moose SDK — OlapTable, Stream, View, Workflow, sql helpers, ClickHouse type annotations, and more — without pulling in `@514labs/kafka-javascript`, `@temporalio/client`, or `redis`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @bayoudhi/moose-lib-serverless
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### CommonJS (recommended for Lambda)
16
+
17
+ ```js
18
+ const { OlapTable, Stream, sql } = require("@bayoudhi/moose-lib-serverless");
19
+ ```
20
+
21
+ ### ES Modules
22
+
23
+ ```js
24
+ import { OlapTable, Stream, sql } from "@bayoudhi/moose-lib-serverless";
25
+ ```
26
+
27
+ > **Note**: The CJS bundle is recommended for AWS Lambda because ESM top-level imports cannot be lazily deferred. The CJS bundle keeps the Kafka reference inside a lazy `__esm` block that never executes unless you explicitly call `getClickhouseClient()` or `getKafkaProducer()`.
28
+
29
+ ## What's Included
30
+
31
+ | Export | Description |
32
+ | --- | --- |
33
+ | `OlapTable` | Define ClickHouse OLAP tables |
34
+ | `Stream` | Define streaming ingestion points |
35
+ | `View` | Define materialized/live views |
36
+ | `Workflow` | Define workflow steps |
37
+ | `sql` | Tagged template literal for SQL queries |
38
+ | `Key`, `JWT` | Type annotations for data model keys and JWT auth |
39
+ | ClickHouse column types | `Columns.String`, `Columns.Int32`, `Columns.DateTime`, etc. |
40
+ | `ConsumptionUtil`, `ApiUtil` | Utility types for consumption APIs |
41
+ | `registerDataSource` | Register external data source connectors |
42
+ | `getSecrets` | Retrieve secrets from the Moose secrets store |
43
+ | Utility functions | `compilerLog`, `cliLog`, `mapTstoJs`, `getFileName`, etc. |
44
+
45
+ ## What's Excluded
46
+
47
+ These native/C++ dependencies are **not** bundled and will never be loaded:
48
+
49
+ | Dependency | Reason |
50
+ | --- | --- |
51
+ | `@514labs/kafka-javascript` | Native C++ module (`node-rdkafka`); crashes in Lambda |
52
+ | `@temporalio/client` | Native Rust bridge; not available in serverless |
53
+ | `redis` | TCP connection pooling incompatible with short-lived functions |
54
+
55
+ ## Origin
56
+
57
+ This package is derived from [MooseStack](https://github.com/514-labs/moosestack) by [Fiveonefour Labs](https://www.fiveonefour.com/), published under the MIT license.
58
+
59
+ - **Original project**: https://github.com/514-labs/moosestack
60
+ - **Fork**: https://github.com/bayoudhi/moosestack (branch `feature/serverless-compatibility`)
61
+
62
+ ## License
63
+
64
+ MIT — see [LICENSE](./LICENSE) for details.
@@ -331,12 +331,18 @@ function addJsExtensionToImports(content, fileDir) {
331
331
  result = result.replace(fromPattern, (match, prefix, importPath, quote) => {
332
332
  return rewriteImportPath(match, prefix, importPath, quote, fileDir);
333
333
  });
334
- result = result.replace(bareImportPattern, (match, prefix, importPath, quote) => {
335
- return rewriteImportPath(match, prefix, importPath, quote, fileDir);
336
- });
337
- result = result.replace(dynamicPattern, (match, prefix, importPath, quote) => {
338
- return rewriteImportPath(match, prefix, importPath, quote, fileDir);
339
- });
334
+ result = result.replace(
335
+ bareImportPattern,
336
+ (match, prefix, importPath, quote) => {
337
+ return rewriteImportPath(match, prefix, importPath, quote, fileDir);
338
+ }
339
+ );
340
+ result = result.replace(
341
+ dynamicPattern,
342
+ (match, prefix, importPath, quote) => {
343
+ return rewriteImportPath(match, prefix, importPath, quote, fileDir);
344
+ }
345
+ );
340
346
  return result;
341
347
  }
342
348
  function rewriteImportPath(match, prefix, importPath, quote, fileDir) {
@@ -756,7 +762,13 @@ var dlqSchema = {
756
762
  ]
757
763
  }
758
764
  },
759
- required: ["originalRecord", "errorMessage", "errorType", "failedAt", "source"]
765
+ required: [
766
+ "originalRecord",
767
+ "errorMessage",
768
+ "errorType",
769
+ "failedAt",
770
+ "source"
771
+ ]
760
772
  },
761
773
  Recordstringany: {
762
774
  type: "object",
@@ -1863,13 +1875,18 @@ var Stream = class extends TypedBase {
1863
1875
  } else if ("subjectLatest" in sr.reference) {
1864
1876
  schemaId = await registry.getLatestSchemaId(sr.reference.subjectLatest);
1865
1877
  } else if ("subject" in sr.reference) {
1866
- schemaId = await registry.getRegistryId(sr.reference.subject, sr.reference.version);
1878
+ schemaId = await registry.getRegistryId(
1879
+ sr.reference.subject,
1880
+ sr.reference.version
1881
+ );
1867
1882
  }
1868
1883
  if (schemaId === void 0) {
1869
1884
  throw new Error("Malformed schema reference.");
1870
1885
  }
1871
1886
  const encoded = await Promise.all(
1872
- flat.map((v) => registry.encode(schemaId, v))
1887
+ flat.map(
1888
+ (v) => registry.encode(schemaId, v)
1889
+ )
1873
1890
  );
1874
1891
  await producer.send({
1875
1892
  topic,
@@ -1912,7 +1929,9 @@ var Stream = class extends TypedBase {
1912
1929
  existingTransforms.push([destination, transformation, transformConfig]);
1913
1930
  }
1914
1931
  } else {
1915
- this._transformations.set(destination.name, [[destination, transformation, transformConfig]]);
1932
+ this._transformations.set(destination.name, [
1933
+ [destination, transformation, transformConfig]
1934
+ ]);
1916
1935
  }
1917
1936
  }
1918
1937
  /**