recurram 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Recurram Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # Recurram (JS)
2
+
3
+ JavaScript/TypeScript bindings for `recurram-rust` with two backends:
4
+
5
+ - Node.js: N-API (`recurram-napi`)
6
+ - Browser/JS runtime: WebAssembly (`recurram-wasm`)
7
+
8
+ Integers decode as `bigint` by default (i64/u64 safe handling).
9
+
10
+ ## Requirements
11
+
12
+ - Node.js 24+
13
+ - Rust stable
14
+ - `wasm-pack` for WASM builds
15
+
16
+ ## Build
17
+
18
+ ```bash
19
+ pnpm install
20
+ pnpm build
21
+ ```
22
+
23
+ Build steps:
24
+
25
+ 1. Build N-API addon (`native/recurram_napi.node`)
26
+ 2. Build WASM package (`wasm/pkg/*`)
27
+ 3. Build TypeScript output (`dist/*`)
28
+
29
+ ## Formatting
30
+
31
+ ```bash
32
+ pnpm format
33
+ pnpm format:check
34
+ ```
35
+
36
+ ## Test
37
+
38
+ ```bash
39
+ pnpm test
40
+ ```
41
+
42
+ What it validates:
43
+
44
+ - Rust bridge tests (`test:rust`)
45
+ - Node API tests (`test:node`) covering `init`, `encode`, `decode`, schema, batch, and session APIs
46
+ - TypeScript API usage against built output
47
+
48
+ ## Usage (Node)
49
+
50
+ ```ts
51
+ import {
52
+ init,
53
+ encode,
54
+ decode,
55
+ createSessionEncoder,
56
+ toTransportJson,
57
+ encodeTransportJson,
58
+ type RecurramValue,
59
+ } from "recurram";
60
+
61
+ await init({ prefer: "napi" });
62
+
63
+ const value: RecurramValue = {
64
+ id: 1001n,
65
+ name: "alice",
66
+ active: true,
67
+ };
68
+
69
+ const bytes = encode(value);
70
+ const roundtrip = decode(bytes);
71
+
72
+ const session = createSessionEncoder();
73
+ const first = session.encode(value);
74
+ const patch = session.encodePatch({ ...value, name: "alicia" });
75
+
76
+ const prepared = toTransportJson(value);
77
+ const fastest = encodeTransportJson(prepared);
78
+ ```
79
+
80
+ ## High-throughput transport JSON APIs
81
+
82
+ For hot paths where you can prepare payloads ahead of time, use transport JSON APIs to reduce JS-side conversion overhead:
83
+
84
+ - `toTransportJson(value)` / `fromTransportJson(json)`
85
+ - `toTransportJsonBatch(values)`
86
+ - `encodeTransportJson(valueJson)` / `decodeToTransportJson(bytes)`
87
+ - `encodeBatchTransportJson(valuesJson)`
88
+
89
+ `SessionEncoder` also supports raw methods:
90
+
91
+ - `encodeTransportJson(valueJson)`
92
+ - `encodeBatchTransportJson(valuesJson)`
93
+ - `encodePatchTransportJson(valueJson)`
94
+ - `encodeMicroBatchTransportJson(valuesJson)`
95
+
96
+ ## Usage (Browser)
97
+
98
+ ```ts
99
+ import { init, encode, decode } from "recurram";
100
+
101
+ await init({ prefer: "wasm" });
102
+
103
+ const bytes = encode({ id: 1n, role: "admin" });
104
+ const value = decode(bytes);
105
+ ```
106
+
107
+ If you want to pass a custom WASM source, use `wasmInput`:
108
+
109
+ ```ts
110
+ await init({ prefer: "wasm", wasmInput: "/assets/recurram_wasm_bg.wasm" });
111
+ ```
112
+
113
+ ## TypeScript types
114
+
115
+ Main exported types:
116
+
117
+ - `RecurramValue`
118
+ - `Schema`, `SchemaField`
119
+ - `SessionOptions`
120
+
121
+ `RecurramValue` includes `bigint` and `Uint8Array` support:
122
+
123
+ ```ts
124
+ type RecurramValue =
125
+ | null
126
+ | boolean
127
+ | number
128
+ | bigint
129
+ | string
130
+ | Uint8Array
131
+ | RecurramValue[]
132
+ | { [key: string]: RecurramValue };
133
+ ```
134
+
135
+ ## Publish to npm
136
+
137
+ The package is configured for npm publish and ships build artifacts from `dist/`, `native/`, and `wasm/pkg/`.
138
+
139
+ Local dry run:
140
+
141
+ ```bash
142
+ pnpm build
143
+ pnpm pack
144
+ ```
145
+
146
+ GitHub Actions publish:
147
+
148
+ 1. Add repository secret `NPM_TOKEN`.
149
+ 2. Bump `version` in `package.json`.
150
+ 3. Create and push matching tag `v<version>`.
151
+
152
+ Example:
153
+
154
+ ```bash
155
+ git tag v0.1.0
156
+ git push origin v0.1.0
157
+ ```
158
+
159
+ The workflow `.github/workflows/publish-npm.yml` verifies tag/version match and then runs `pnpm publish`.
160
+
161
+ ## License
162
+
163
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,13 @@
1
+ [package]
2
+ name = "recurram-bridge"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ base64 = "0.22"
8
+ recurram = { git = "https://github.com/recurram/recurram-rust.git" }
9
+ itoa = "1.0"
10
+ ryu = "1.0"
11
+ serde = { version = "1.0", features = ["derive"] }
12
+ serde_json = { version = "1.0", features = ["raw_value"] }
13
+ simd-json = "0.17"