@oyinlola141/lattice-serialization 0.1.3 → 0.1.4
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 +21 -0
- package/README.md +22 -42
- package/package.json +20 -17
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lattice Contributors
|
|
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
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
# @oyinlola141/lattice-serialization
|
|
2
2
|
|
|
3
|
-
Data translation layer
|
|
4
|
-
|
|
5
|
-
## When to use
|
|
6
|
-
|
|
7
|
-
Import this when you need:
|
|
8
|
-
|
|
9
|
-
- serialize/deserialize values that contain `Date`, `BigInt`, `Map`, ...
|
|
10
|
-
- register custom transformers for your own types
|
|
11
|
-
- wrap payloads in versioned envelopes
|
|
12
|
-
- safely round-trip unknown JSON
|
|
3
|
+
Data translation layer with JSON serializer, type transformers, envelopes, and registry for Lattice applications.
|
|
13
4
|
|
|
14
5
|
## Installation
|
|
15
6
|
|
|
@@ -17,42 +8,31 @@ Import this when you need:
|
|
|
17
8
|
npm install @oyinlola141/lattice-serialization
|
|
18
9
|
```
|
|
19
10
|
|
|
20
|
-
##
|
|
11
|
+
## Quick Start
|
|
21
12
|
|
|
22
13
|
```typescript
|
|
23
|
-
import {
|
|
24
|
-
JSONSerializer,
|
|
25
|
-
SerializerRegistry,
|
|
26
|
-
TransformerRegistry,
|
|
27
|
-
DateTransformer,
|
|
28
|
-
BigIntTransformer,
|
|
29
|
-
MapTransformer,
|
|
30
|
-
SetTransformer,
|
|
31
|
-
BufferTransformer,
|
|
32
|
-
ErrorTransformer,
|
|
33
|
-
type Serializer,
|
|
34
|
-
type TypeTransformer,
|
|
35
|
-
type SerializedEnvelope,
|
|
36
|
-
} from "@oyinlola141/lattice-serialization";
|
|
37
|
-
```
|
|
14
|
+
import { createSerializer } from "@oyinlola141/lattice-serialization";
|
|
38
15
|
|
|
39
|
-
|
|
16
|
+
const serializer = createSerializer({
|
|
17
|
+
format: "json",
|
|
18
|
+
transformers: [dateTransformer, bigIntTransformer],
|
|
19
|
+
});
|
|
40
20
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
JSONSerializer,
|
|
44
|
-
DateTransformer,
|
|
45
|
-
BigIntTransformer,
|
|
46
|
-
} from "@oyinlola141/lattice-serialization";
|
|
47
|
-
|
|
48
|
-
const serializer = new JSONSerializer();
|
|
49
|
-
serializer.transformers.register(new DateTransformer());
|
|
50
|
-
serializer.transformers.register(new BigIntTransformer());
|
|
51
|
-
|
|
52
|
-
const json = serializer.serialize({ when: new Date(), n: 10n });
|
|
53
|
-
const back = serializer.deserialize<{ when: Date; n: bigint }>(json);
|
|
21
|
+
const json = serializer.stringify({ id: "123", createdAt: new Date() });
|
|
22
|
+
const obj = serializer.parse(json);
|
|
54
23
|
```
|
|
55
24
|
|
|
56
|
-
##
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- JSON serialization with type transformers
|
|
28
|
+
- Envelope pattern for API responses
|
|
29
|
+
- Transformer registry
|
|
30
|
+
- Support for BigInt, Date, Buffer, and custom types
|
|
31
|
+
- Circular reference detection
|
|
32
|
+
|
|
33
|
+
## Use Cases
|
|
57
34
|
|
|
58
|
-
|
|
35
|
+
- API response serialization
|
|
36
|
+
- Event payload serialization
|
|
37
|
+
- Cache serialization
|
|
38
|
+
- Cross-service data transfer
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyinlola141/lattice-serialization",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Data translation layer with JSON serializer, type transformers, envelopes, and registry for Lattice applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -15,17 +15,11 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"LICENSE"
|
|
17
17
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"typecheck": "tsc --noEmit",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"test:watch": "vitest"
|
|
23
|
-
},
|
|
24
18
|
"dependencies": {
|
|
25
|
-
"@oyinlola141/lattice-constants": "
|
|
26
|
-
"@oyinlola141/lattice-errors": "
|
|
27
|
-
"@oyinlola141/lattice-types": "
|
|
28
|
-
"@oyinlola141/lattice-validation": "
|
|
19
|
+
"@oyinlola141/lattice-constants": "0.1.3",
|
|
20
|
+
"@oyinlola141/lattice-errors": "0.1.3",
|
|
21
|
+
"@oyinlola141/lattice-types": "0.1.3",
|
|
22
|
+
"@oyinlola141/lattice-validation": "0.1.3"
|
|
29
23
|
},
|
|
30
24
|
"devDependencies": {
|
|
31
25
|
"typescript": "^5.7.0",
|
|
@@ -36,9 +30,7 @@
|
|
|
36
30
|
"lattice",
|
|
37
31
|
"serialization",
|
|
38
32
|
"json",
|
|
39
|
-
"
|
|
40
|
-
"messagepack",
|
|
41
|
-
"type-preservation"
|
|
33
|
+
"transformers"
|
|
42
34
|
],
|
|
43
35
|
"publishConfig": {
|
|
44
36
|
"access": "public"
|
|
@@ -46,5 +38,16 @@
|
|
|
46
38
|
"engines": {
|
|
47
39
|
"node": ">=24.0.0"
|
|
48
40
|
},
|
|
49
|
-
"module": "./dist/index.js"
|
|
50
|
-
|
|
41
|
+
"module": "./dist/index.js",
|
|
42
|
+
"homepage": "https://github.com/oyinlola-tech/lattice#readme",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/oyinlola-tech/lattice"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"test:watch": "vitest"
|
|
52
|
+
}
|
|
53
|
+
}
|