@bayoudhi/moose-lib-serverless 0.2.1 → 0.3.1
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/README.md +59 -0
- package/dist/compilerPlugin.js +1644 -0
- package/package.json +18 -5
package/README.md
CHANGED
|
@@ -10,6 +10,65 @@ This package re-exports the pure-TypeScript surface of the Moose SDK — OlapTab
|
|
|
10
10
|
npm install @bayoudhi/moose-lib-serverless
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
If you use `OlapTable<T>`, `Stream<T>`, or other generic Moose resources that require compile-time schema injection, you also need the compiler plugin dependencies:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -D ts-patch typia typescript
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Compiler Plugin Setup
|
|
20
|
+
|
|
21
|
+
The Moose compiler plugin transforms generic resource declarations like `new OlapTable<MyType>(...)` at compile time, injecting JSON schemas, column definitions, and runtime validators. Without it, you'll get:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Supply the type param T so that the schema is inserted by the compiler plugin.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 1. Configure `tsconfig.json`
|
|
28
|
+
|
|
29
|
+
Add the compiler plugin and typia transform to your `tsconfig.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"compilerOptions": {
|
|
34
|
+
"plugins": [
|
|
35
|
+
{
|
|
36
|
+
"transform": "@bayoudhi/moose-lib-serverless/compilerPlugin"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"transform": "typia/lib/transform"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Both `@bayoudhi/moose-lib-serverless/compilerPlugin` and `@bayoudhi/moose-lib-serverless/dist/compilerPlugin.js` work — use whichever you prefer.
|
|
47
|
+
|
|
48
|
+
### 2. Install ts-patch
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx ts-patch install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Build with `tspc` instead of `tsc`
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx tspc
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or add it to your `package.json` scripts:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tspc"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> **Note**: `tspc` is a drop-in replacement for `tsc` that loads the compiler plugins defined in `tsconfig.json`. Standard `tsc` ignores the `plugins` array.
|
|
71
|
+
|
|
13
72
|
## Usage
|
|
14
73
|
|
|
15
74
|
### CommonJS (recommended for Lambda)
|