@macroforge/mcp-server 0.1.78 → 0.1.79
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/docs/builtin-macros/clone.md +2 -2
- package/docs/builtin-macros/debug.md +1 -1
- package/docs/builtin-macros/default.md +1 -1
- package/docs/builtin-macros/deserialize/cycleforward-reference-support.md +3 -2
- package/docs/builtin-macros/deserialize/example.md +2 -1
- package/docs/builtin-macros/deserialize/overview.md +10 -10
- package/docs/builtin-macros/deserialize/union-type-deserialization.md +15 -9
- package/docs/builtin-macros/deserialize/validation.md +5 -1
- package/docs/builtin-macros/deserialize.md +3 -308
- package/docs/integration/cli.md +1 -1
- package/docs/language-servers/ls-overview.md +1 -1
- package/docs/language-servers/svelte-ls.md +1 -1
- package/docs/language-servers/svelte.md +1 -1
- package/docs/language-servers/zed-extensions.md +1 -1
- package/docs/language-servers/zed.md +1 -1
- package/docs/roadmap/roadmap.md +1 -1
- package/docs/sections.json +1 -54
- package/package.json +3 -3
|
@@ -13,7 +13,7 @@ independent copies of values.
|
|
|
13
13
|
| Interface | `ifaceNameClone(value): InterfaceName` | Standalone function creating a new object literal |
|
|
14
14
|
| Type Alias | `typeNameClone(value): TypeName` | Standalone function with spread copy for objects |
|
|
15
15
|
|
|
16
|
-
Names use **camelCase** conversion (e.g., `Point`
|
|
16
|
+
Names use **camelCase** conversion (e.g., `Point` -> `pointClone`).
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
## Cloning Strategy
|
|
@@ -25,7 +25,7 @@ The generated clone is **type-aware** when a type registry is available:
|
|
|
25
25
|
- **Arrays**: Spread copy `[...arr]`, or deep map if element type has `Clone`
|
|
26
26
|
- **`Map`/`Set`**: New collection, deep copy if value type has `Clone`
|
|
27
27
|
- **Objects with `@derive(Clone)`**: Deep cloned via their standalone clone function
|
|
28
|
-
- **Optional fields**: Null-checked
|
|
28
|
+
- **Optional fields**: Null-checked -- `null`/`undefined` pass through unchanged
|
|
29
29
|
- **Other objects**: Shallow copy (reference)
|
|
30
30
|
|
|
31
31
|
## Example
|
|
@@ -16,7 +16,7 @@ reverse lookup on numeric enums.
|
|
|
16
16
|
**Type Aliases**: Generates a standalone function using JSON.stringify for
|
|
17
17
|
complex types, or field enumeration for object types.
|
|
18
18
|
|
|
19
|
-
Names use **camelCase** conversion (e.g., `User`
|
|
19
|
+
Names use **camelCase** conversion (e.g., `User` -> `userToString`).
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
## Field-Level Options
|
|
@@ -13,7 +13,7 @@ a standard way to create "zero" or "empty" instances of types.
|
|
|
13
13
|
| Interface | `ifaceNameDefaultValue(): InterfaceName` | Standalone function returning object literal |
|
|
14
14
|
| Type Alias | `typeNameDefaultValue(): TypeName` | Standalone function with type-appropriate default |
|
|
15
15
|
|
|
16
|
-
Names use **camelCase** conversion (e.g., `UserSettings`
|
|
16
|
+
Names use **camelCase** conversion (e.g., `UserSettings` -> `userSettingsDefaultValue`).
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
## Default Values by Type
|
|
@@ -7,5 +7,6 @@ Uses deferred patching to handle references:
|
|
|
7
7
|
3. After all objects are created, `ctx.applyPatches()` resolves all pending references
|
|
8
8
|
|
|
9
9
|
References only apply to object-shaped, serializable values. The generator avoids probing for
|
|
10
|
-
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is
|
|
11
|
-
and it parses `Date` / `Date | null` from ISO strings without treating them as
|
|
10
|
+
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is
|
|
11
|
+
primitive-like), and it parses `Date` / `Date | null` from ISO strings without treating them as
|
|
12
|
+
references.
|
|
@@ -214,4 +214,5 @@ if (Result.isOk(result)) {
|
|
|
214
214
|
## Required Imports
|
|
215
215
|
|
|
216
216
|
The generated code automatically imports:
|
|
217
|
-
|
|
217
|
+
|
|
218
|
+
- `DeserializeContext`, `DeserializeError`, `PendingRef` from `macroforge/serde`
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# Deserialize
|
|
2
2
|
|
|
3
|
-
The `Deserialize` macro generates JSON deserialization methods with **cycle and
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The `Deserialize` macro generates JSON deserialization methods with **cycle and forward-reference
|
|
4
|
+
support**, plus comprehensive runtime validation. This enables safe parsing of complex JSON
|
|
5
|
+
structures including circular references.
|
|
6
6
|
|
|
7
7
|
## Generated Output
|
|
8
8
|
|
|
9
|
-
| Type
|
|
10
|
-
|
|
11
|
-
| Class
|
|
12
|
-
| Enum
|
|
13
|
-
| Interface
|
|
14
|
-
| Type Alias | `typeNameDeserialize(input)`, etc.
|
|
9
|
+
| Type | Generated Code | Description |
|
|
10
|
+
| ---------- | ----------------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
11
|
+
| Class | `classNameDeserialize(input)` + `static deserialize(input)` | Standalone function + static factory method |
|
|
12
|
+
| Enum | `enumNameDeserialize(input)`, `enumNameDeserializeWithContext(data)`, `enumNameIs(value)` | Standalone functions |
|
|
13
|
+
| Interface | `interfaceNameDeserialize(input)`, etc. | Standalone functions |
|
|
14
|
+
| Type Alias | `typeNameDeserialize(input)`, etc. | Standalone functions |
|
|
15
15
|
|
|
16
16
|
## Return Type
|
|
17
17
|
|
|
18
18
|
All public deserialization methods return `Result<T, Array<{ field: string; message: string }>>`:
|
|
19
19
|
|
|
20
20
|
- `Result.ok(value)` - Successfully deserialized value
|
|
21
|
-
- `Result.err(errors)` - Array of validation errors with field names and messages
|
|
21
|
+
- `Result.err(errors)` - Array of validation errors with field names and messages
|
|
@@ -3,25 +3,31 @@
|
|
|
3
3
|
Union types are deserialized based on their member types:
|
|
4
4
|
|
|
5
5
|
### Literal Unions
|
|
6
|
-
|
|
7
|
-
the
|
|
6
|
+
|
|
7
|
+
For unions of literal values (`"A" | "B" | 123`), the value is validated against the allowed
|
|
8
|
+
literals directly.
|
|
8
9
|
|
|
9
10
|
### Primitive Unions
|
|
10
|
-
|
|
11
|
-
`
|
|
11
|
+
|
|
12
|
+
For unions containing primitive types (`string | number`), the deserializer uses `typeof` checks to
|
|
13
|
+
validate the value type. No `__type` discriminator is needed.
|
|
12
14
|
|
|
13
15
|
### Class/Interface Unions
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
For unions of serializable types (`User | Admin`), the deserializer requires a `__type` field in the
|
|
18
|
+
JSON to dispatch to the correct type's `deserializeWithContext` method.
|
|
16
19
|
|
|
17
20
|
### Generic Type Parameters
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
|
|
22
|
+
For generic unions like `type Result<T> = T | Error`, the generic type parameter `T` is passed
|
|
23
|
+
through as-is since its concrete type is only known at the call site.
|
|
20
24
|
|
|
21
25
|
### Mixed Unions
|
|
26
|
+
|
|
22
27
|
Mixed unions (e.g., `string | Date | User`) check in order:
|
|
28
|
+
|
|
23
29
|
1. Literal values
|
|
24
30
|
2. Primitives (via `typeof`)
|
|
25
31
|
3. Date (via `instanceof` or ISO string parsing)
|
|
26
32
|
4. Serializable types (via `__type` dispatch)
|
|
27
|
-
5. Generic type parameters (pass-through)
|
|
33
|
+
5. Generic type parameters (pass-through)
|
|
@@ -3,19 +3,23 @@
|
|
|
3
3
|
The macro supports 30+ validators via `@serde(validate(...))`:
|
|
4
4
|
|
|
5
5
|
### String Validators
|
|
6
|
+
|
|
6
7
|
- `email`, `url`, `uuid` - Format validation
|
|
7
8
|
- `minLength(n)`, `maxLength(n)`, `length(n)` - Length constraints
|
|
8
9
|
- `pattern("regex")` - Regular expression matching
|
|
9
10
|
- `nonEmpty`, `trimmed`, `lowercase`, `uppercase` - String properties
|
|
10
11
|
|
|
11
12
|
### Number Validators
|
|
13
|
+
|
|
12
14
|
- `gt(n)`, `gte(n)`, `lt(n)`, `lte(n)`, `between(min, max)` - Range checks
|
|
13
15
|
- `int`, `positive`, `nonNegative`, `finite` - Number properties
|
|
14
16
|
|
|
15
17
|
### Array Validators
|
|
18
|
+
|
|
16
19
|
- `minItems(n)`, `maxItems(n)`, `itemsCount(n)` - Collection size
|
|
17
20
|
|
|
18
21
|
### Date Validators
|
|
22
|
+
|
|
19
23
|
- `validDate`, `afterDate("ISO")`, `beforeDate("ISO")` - Date validation
|
|
20
24
|
|
|
21
25
|
## Field-Level Options
|
|
@@ -31,4 +35,4 @@ The `@serde` decorator supports:
|
|
|
31
35
|
## Container-Level Options
|
|
32
36
|
|
|
33
37
|
- `denyUnknownFields` - Error on unrecognized JSON properties
|
|
34
|
-
- `renameAll = "camelCase"` - Apply naming convention to all fields
|
|
38
|
+
- `renameAll = "camelCase"` - Apply naming convention to all fields
|
|
@@ -4,311 +4,6 @@ The `Deserialize` macro generates JSON deserialization methods with **cycle and
|
|
|
4
4
|
forward-reference support**, plus comprehensive runtime validation. This enables
|
|
5
5
|
safe parsing of complex JSON structures including circular references.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|------|----------------|-------------|
|
|
11
|
-
| Class | `classNameDeserialize(input)` + `static deserialize(input)` | Standalone function + static factory method |
|
|
12
|
-
| Enum | `enumNameDeserialize(input)`, `enumNameDeserializeWithContext(data)`, `enumNameIs(value)` | Standalone functions |
|
|
13
|
-
| Interface | `interfaceNameDeserialize(input)`, etc. | Standalone functions |
|
|
14
|
-
| Type Alias | `typeNameDeserialize(input)`, etc. | Standalone functions |
|
|
15
|
-
|
|
16
|
-
## Return Type
|
|
17
|
-
|
|
18
|
-
All public deserialization methods return `Result<T, Array<{ field: string; message: string }>>`:
|
|
19
|
-
|
|
20
|
-
- `Result.ok(value)` - Successfully deserialized value
|
|
21
|
-
- `Result.err(errors)` - Array of validation errors with field names and messages
|
|
22
|
-
|
|
23
|
-
## Cycle/Forward-Reference Support
|
|
24
|
-
|
|
25
|
-
Uses deferred patching to handle references:
|
|
26
|
-
|
|
27
|
-
1. When encountering `{ "__ref": id }`, returns a `PendingRef` marker
|
|
28
|
-
2. Continues deserializing other fields
|
|
29
|
-
3. After all objects are created, `ctx.applyPatches()` resolves all pending references
|
|
30
|
-
|
|
31
|
-
References only apply to object-shaped, serializable values. The generator avoids probing for
|
|
32
|
-
`__ref` on primitive-like fields (including literal unions and `T | null` where `T` is primitive-like),
|
|
33
|
-
and it parses `Date` / `Date | null` from ISO strings without treating them as references.
|
|
34
|
-
|
|
35
|
-
## Validation
|
|
36
|
-
|
|
37
|
-
The macro supports 30+ validators via `@serde(validate(...))`:
|
|
38
|
-
|
|
39
|
-
### String Validators
|
|
40
|
-
- `email`, `url`, `uuid` - Format validation
|
|
41
|
-
- `minLength(n)`, `maxLength(n)`, `length(n)` - Length constraints
|
|
42
|
-
- `pattern("regex")` - Regular expression matching
|
|
43
|
-
- `nonEmpty`, `trimmed`, `lowercase`, `uppercase` - String properties
|
|
44
|
-
|
|
45
|
-
### Number Validators
|
|
46
|
-
- `gt(n)`, `gte(n)`, `lt(n)`, `lte(n)`, `between(min, max)` - Range checks
|
|
47
|
-
- `int`, `positive`, `nonNegative`, `finite` - Number properties
|
|
48
|
-
|
|
49
|
-
### Array Validators
|
|
50
|
-
- `minItems(n)`, `maxItems(n)`, `itemsCount(n)` - Collection size
|
|
51
|
-
|
|
52
|
-
### Date Validators
|
|
53
|
-
- `validDate`, `afterDate("ISO")`, `beforeDate("ISO")` - Date validation
|
|
54
|
-
|
|
55
|
-
## Field-Level Options
|
|
56
|
-
|
|
57
|
-
The `@serde` decorator supports:
|
|
58
|
-
|
|
59
|
-
- `skip` / `skipDeserializing` - Exclude field from deserialization
|
|
60
|
-
- `rename = "jsonKey"` - Read from different JSON property
|
|
61
|
-
- `default` / `default = expr` - Use default value if missing
|
|
62
|
-
- `flatten` - Read fields from parent object level
|
|
63
|
-
- `validate(...)` - Apply validators
|
|
64
|
-
|
|
65
|
-
## Container-Level Options
|
|
66
|
-
|
|
67
|
-
- `denyUnknownFields` - Error on unrecognized JSON properties
|
|
68
|
-
- `renameAll = "camelCase"` - Apply naming convention to all fields
|
|
69
|
-
|
|
70
|
-
## Union Type Deserialization
|
|
71
|
-
|
|
72
|
-
Union types are deserialized based on their member types:
|
|
73
|
-
|
|
74
|
-
### Literal Unions
|
|
75
|
-
For unions of literal values (`"A" | "B" | 123`), the value is validated against
|
|
76
|
-
the allowed literals directly.
|
|
77
|
-
|
|
78
|
-
### Primitive Unions
|
|
79
|
-
For unions containing primitive types (`string | number`), the deserializer uses
|
|
80
|
-
`typeof` checks to validate the value type. No `__type` discriminator is needed.
|
|
81
|
-
|
|
82
|
-
### Class/Interface Unions
|
|
83
|
-
For unions of serializable types (`User | Admin`), the deserializer requires a
|
|
84
|
-
`__type` field in the JSON to dispatch to the correct type's `deserializeWithContext` method.
|
|
85
|
-
|
|
86
|
-
### Generic Type Parameters
|
|
87
|
-
For generic unions like `type Result<T> = T | Error`, the generic type parameter `T`
|
|
88
|
-
is passed through as-is since its concrete type is only known at the call site.
|
|
89
|
-
|
|
90
|
-
### Mixed Unions
|
|
91
|
-
Mixed unions (e.g., `string | Date | User`) check in order:
|
|
92
|
-
1. Literal values
|
|
93
|
-
2. Primitives (via `typeof`)
|
|
94
|
-
3. Date (via `instanceof` or ISO string parsing)
|
|
95
|
-
4. Serializable types (via `__type` dispatch)
|
|
96
|
-
5. Generic type parameters (pass-through)
|
|
97
|
-
|
|
98
|
-
## Example
|
|
99
|
-
|
|
100
|
-
```typescript before
|
|
101
|
-
/** @derive(Deserialize) @serde({ denyUnknownFields: true }) */
|
|
102
|
-
class User {
|
|
103
|
-
id: number;
|
|
104
|
-
|
|
105
|
-
/** @serde({ validate: { email: true, maxLength: 255 } }) */
|
|
106
|
-
email: string;
|
|
107
|
-
|
|
108
|
-
/** @serde({ default: "guest" }) */
|
|
109
|
-
name: string;
|
|
110
|
-
|
|
111
|
-
/** @serde({ validate: { positive: true } }) */
|
|
112
|
-
age?: number;
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
```typescript after
|
|
117
|
-
import { DeserializeContext } from 'macroforge/serde';
|
|
118
|
-
import { DeserializeError } from 'macroforge/serde';
|
|
119
|
-
import type { DeserializeOptions } from 'macroforge/serde';
|
|
120
|
-
import { PendingRef } from 'macroforge/serde';
|
|
121
|
-
|
|
122
|
-
/** @serde({ denyUnknownFields: true }) */
|
|
123
|
-
class User {
|
|
124
|
-
id: number;
|
|
125
|
-
|
|
126
|
-
email: string;
|
|
127
|
-
|
|
128
|
-
name: string;
|
|
129
|
-
|
|
130
|
-
age?: number;
|
|
131
|
-
|
|
132
|
-
constructor(props: {
|
|
133
|
-
id: number;
|
|
134
|
-
email: string;
|
|
135
|
-
name?: string;
|
|
136
|
-
age?: number;
|
|
137
|
-
}) {
|
|
138
|
-
this.id = props.id;
|
|
139
|
-
this.email = props.email;
|
|
140
|
-
this.name = props.name as string;
|
|
141
|
-
this.age = props.age as number;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Deserializes input to an instance of this class.
|
|
146
|
-
* Automatically detects whether input is a JSON string or object.
|
|
147
|
-
* @param input - JSON string or object to deserialize
|
|
148
|
-
* @param opts - Optional deserialization options
|
|
149
|
-
* @returns Result containing the deserialized instance or validation errors
|
|
150
|
-
*/
|
|
151
|
-
static deserialize(
|
|
152
|
-
input: unknown,
|
|
153
|
-
opts?: @DESERIALIZE_OPTIONS
|
|
154
|
-
): Result<
|
|
155
|
-
User,
|
|
156
|
-
Array<{
|
|
157
|
-
field: string;
|
|
158
|
-
message: string;
|
|
159
|
-
}>
|
|
160
|
-
> {
|
|
161
|
-
try {
|
|
162
|
-
// Auto-detect: if string, parse as JSON first
|
|
163
|
-
const data = typeof input === 'string' ? JSON.parse(input) : input;
|
|
164
|
-
|
|
165
|
-
const ctx = @DESERIALIZE_CONTEXT.create();
|
|
166
|
-
const resultOrRef = User.deserializeWithContext(data, ctx);
|
|
167
|
-
if (@PENDING_REF.is(resultOrRef)) {
|
|
168
|
-
return Result.err([
|
|
169
|
-
{
|
|
170
|
-
field: '_root',
|
|
171
|
-
message: 'User.deserialize: root cannot be a forward reference'
|
|
172
|
-
}
|
|
173
|
-
]);
|
|
174
|
-
}
|
|
175
|
-
ctx.applyPatches();
|
|
176
|
-
if (opts?.freeze) {
|
|
177
|
-
ctx.freezeAll();
|
|
178
|
-
}
|
|
179
|
-
return Result.ok(resultOrRef);
|
|
180
|
-
} catch (e) {
|
|
181
|
-
if (e instanceof @DESERIALIZE_ERROR) {
|
|
182
|
-
return Result.err(e.errors);
|
|
183
|
-
}
|
|
184
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
185
|
-
return Result.err([
|
|
186
|
-
{
|
|
187
|
-
field: '_root',
|
|
188
|
-
message
|
|
189
|
-
}
|
|
190
|
-
]);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** @internal */
|
|
195
|
-
static deserializeWithContext(value: any, ctx: @DESERIALIZE_CONTEXT): User | @PENDING_REF {
|
|
196
|
-
if (value?.__ref !== undefined) {
|
|
197
|
-
return ctx.getOrDefer(value.__ref);
|
|
198
|
-
}
|
|
199
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
200
|
-
throw new @DESERIALIZE_ERROR([
|
|
201
|
-
{
|
|
202
|
-
field: '_root',
|
|
203
|
-
message: 'User.deserializeWithContext: expected an object'
|
|
204
|
-
}
|
|
205
|
-
]);
|
|
206
|
-
}
|
|
207
|
-
const obj = value as Record<string, unknown>;
|
|
208
|
-
const errors: Array<{
|
|
209
|
-
field: string;
|
|
210
|
-
message: string;
|
|
211
|
-
}> = [];
|
|
212
|
-
const knownKeys = new Set(['__type', '__id', '__ref', 'id', 'email', 'name', 'age']);
|
|
213
|
-
for (const key of Object.keys(obj)) {
|
|
214
|
-
if (!knownKeys.has(key)) {
|
|
215
|
-
errors.push({
|
|
216
|
-
field: key,
|
|
217
|
-
message: 'unknown field'
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (!('id' in obj)) {
|
|
222
|
-
errors.push({
|
|
223
|
-
field: 'id',
|
|
224
|
-
message: 'missing required field'
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
if (!('email' in obj)) {
|
|
228
|
-
errors.push({
|
|
229
|
-
field: 'email',
|
|
230
|
-
message: 'missing required field'
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
if (errors.length > 0) {
|
|
234
|
-
throw new @deserialize_error_expr(errors);
|
|
235
|
-
}
|
|
236
|
-
const instance = Object.create(User.prototype) as User;
|
|
237
|
-
if (obj.__id !== undefined) {
|
|
238
|
-
ctx.register(obj.__id as number, instance);
|
|
239
|
-
}
|
|
240
|
-
ctx.trackForFreeze(instance);
|
|
241
|
-
{
|
|
242
|
-
const __raw_id = obj['id'] as number;
|
|
243
|
-
instance.id = __raw_id;
|
|
244
|
-
}
|
|
245
|
-
{
|
|
246
|
-
const __raw_email = obj['email'] as string;
|
|
247
|
-
instance.email = __raw_email;
|
|
248
|
-
}
|
|
249
|
-
if ('name' in obj && obj['name'] !== undefined) {
|
|
250
|
-
const __raw_name = obj['name'] as string;
|
|
251
|
-
instance.name = __raw_name;
|
|
252
|
-
} else {
|
|
253
|
-
instance.name = "guest";
|
|
254
|
-
}
|
|
255
|
-
if ('age' in obj && obj['age'] !== undefined) {
|
|
256
|
-
const __raw_age = obj['age'] as number;
|
|
257
|
-
instance.age = __raw_age;
|
|
258
|
-
}
|
|
259
|
-
if (errors.length > 0) {
|
|
260
|
-
throw new @deserialize_error_expr(errors);
|
|
261
|
-
}
|
|
262
|
-
return instance;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
static validateField<K extends keyof User>(
|
|
266
|
-
field: K,
|
|
267
|
-
value: User[K]
|
|
268
|
-
): Array<{
|
|
269
|
-
field: string;
|
|
270
|
-
message: string;
|
|
271
|
-
}> {
|
|
272
|
-
return [];
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
static validateFields(partial: Partial<User>): Array<{
|
|
276
|
-
field: string;
|
|
277
|
-
message: string;
|
|
278
|
-
}> {
|
|
279
|
-
return [];
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
static hasShape(obj: unknown): boolean {
|
|
283
|
-
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
const o = obj as Record<string, unknown>;
|
|
287
|
-
return 'id' in o && 'email' in o;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
static is(obj: unknown): obj is User {
|
|
291
|
-
if (obj instanceof User) {
|
|
292
|
-
return true;
|
|
293
|
-
}
|
|
294
|
-
if (!User.hasShape(obj)) {
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
const result = User.deserialize(obj);
|
|
298
|
-
return Result.isOk(result);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// Usage:
|
|
303
|
-
const result = User.deserialize('{"id":1,"email":"test@example.com"}');
|
|
304
|
-
if (Result.isOk(result)) {
|
|
305
|
-
const user = result.value;
|
|
306
|
-
} else {
|
|
307
|
-
console.error(result.error); // [{ field: "email", message: "must be a valid email" }]
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
## Required Imports
|
|
312
|
-
|
|
313
|
-
The generated code automatically imports:
|
|
314
|
-
- `DeserializeContext`, `DeserializeError`, `PendingRef` from `macroforge/serde`
|
|
7
|
+
See the original module documentation for full details on generated output,
|
|
8
|
+
return types, cycle/forward-reference support, validation, field-level options,
|
|
9
|
+
container-level options, and union type deserialization.
|
package/docs/integration/cli.md
CHANGED
|
@@ -25,7 +25,7 @@ and editors.
|
|
|
25
25
|
The language servers are functional and used during development of macroforge itself. However, they
|
|
26
26
|
require manual installation:
|
|
27
27
|
|
|
28
|
-
1. Fork or clone the [macroforge-ts repository](https://github.com/
|
|
28
|
+
1. Fork or clone the [macroforge-ts repository](https://github.com/macroforge-ts/macroforge-ts)
|
|
29
29
|
2. Build the extension you need
|
|
30
30
|
3. Install it as a developer extension in your editor
|
|
31
31
|
|
|
@@ -25,7 +25,7 @@ This package is not yet published as an official extension. You'll need to build
|
|
|
25
25
|
### 1. Clone the Repository
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
git clone https://github.com/
|
|
28
|
+
git clone https://github.com/macroforge-ts/macroforge-ts.git
|
|
29
29
|
cd macroforge-ts
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -20,7 +20,7 @@ These extensions are not yet in the Zed extension registry. You'll need to insta
|
|
|
20
20
|
### 1. Clone the Repository
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
git clone https://github.com/
|
|
23
|
+
git clone https://github.com/macroforge-ts/macroforge-ts.git
|
|
24
24
|
cd macroforge-ts
|
|
25
25
|
```
|
|
26
26
|
|
package/docs/roadmap/roadmap.md
CHANGED
|
@@ -73,7 +73,7 @@ Improvements to the developer experience.
|
|
|
73
73
|
|
|
74
74
|
Interested in helping? We welcome contributions of all kinds:
|
|
75
75
|
|
|
76
|
-
- Feature requests and feedback on [GitHub Issues](https://github.com/
|
|
76
|
+
- Feature requests and feedback on [GitHub Issues](https://github.com/macroforge-ts/macroforge-ts/issues)
|
|
77
77
|
- Pull requests for new macros or improvements
|
|
78
78
|
- Documentation improvements
|
|
79
79
|
- Framework integrations
|
package/docs/sections.json
CHANGED
|
@@ -63,65 +63,12 @@
|
|
|
63
63
|
"path": "builtin-macros/serialize.md",
|
|
64
64
|
"use_cases": "toJSON, serialization, json, api, data transfer"
|
|
65
65
|
},
|
|
66
|
-
{
|
|
67
|
-
"id": "deserialize/overview",
|
|
68
|
-
"title": "Deserialize: Overview",
|
|
69
|
-
"category": "builtin-macros",
|
|
70
|
-
"category_title": "Built-in Macros",
|
|
71
|
-
"path": "builtin-macros/deserialize/overview.md",
|
|
72
|
-
"use_cases": "fromJSON, deserialization, deserialize, classnamedeserialize(input), enumnamedeserialize(input)",
|
|
73
|
-
"parent_id": "deserialize"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"id": "deserialize/cycleforward-reference-support",
|
|
77
|
-
"title": "Deserialize: Cycle/Forward-Reference Support",
|
|
78
|
-
"category": "builtin-macros",
|
|
79
|
-
"category_title": "Built-in Macros",
|
|
80
|
-
"path": "builtin-macros/deserialize/cycleforward-reference-support.md",
|
|
81
|
-
"use_cases": "fromJSON, deserialization, pendingref, ctx.applypatches(), __ref",
|
|
82
|
-
"parent_id": "deserialize"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"id": "deserialize/validation",
|
|
86
|
-
"title": "Deserialize: Validation",
|
|
87
|
-
"category": "builtin-macros",
|
|
88
|
-
"category_title": "Built-in Macros",
|
|
89
|
-
"path": "builtin-macros/deserialize/validation.md",
|
|
90
|
-
"use_cases": "fromJSON, deserialization, @serde(validate(...)), email, url, uuid",
|
|
91
|
-
"parent_id": "deserialize"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"id": "deserialize/union-type-deserialization",
|
|
95
|
-
"title": "Deserialize: Union Type Deserialization",
|
|
96
|
-
"category": "builtin-macros",
|
|
97
|
-
"category_title": "Built-in Macros",
|
|
98
|
-
"path": "builtin-macros/deserialize/union-type-deserialization.md",
|
|
99
|
-
"use_cases": "fromJSON, deserialization, typeof, __type",
|
|
100
|
-
"parent_id": "deserialize"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"id": "deserialize/example",
|
|
104
|
-
"title": "Deserialize: Example",
|
|
105
|
-
"category": "builtin-macros",
|
|
106
|
-
"category_title": "Built-in Macros",
|
|
107
|
-
"path": "builtin-macros/deserialize/example.md",
|
|
108
|
-
"use_cases": "fromJSON, deserialization",
|
|
109
|
-
"parent_id": "deserialize"
|
|
110
|
-
},
|
|
111
66
|
{
|
|
112
67
|
"id": "deserialize",
|
|
113
68
|
"title": "Deserialize",
|
|
114
69
|
"category": "builtin-macros",
|
|
115
70
|
"category_title": "Built-in Macros",
|
|
116
71
|
"path": "builtin-macros/deserialize.md",
|
|
117
|
-
"use_cases": "fromJSON, deserialization, parsing, validation, json"
|
|
118
|
-
"is_chunked": true,
|
|
119
|
-
"chunk_ids": [
|
|
120
|
-
"deserialize/overview",
|
|
121
|
-
"deserialize/cycleforward-reference-support",
|
|
122
|
-
"deserialize/validation",
|
|
123
|
-
"deserialize/union-type-deserialization",
|
|
124
|
-
"deserialize/example"
|
|
125
|
-
]
|
|
72
|
+
"use_cases": "fromJSON, deserialization, parsing, validation, json"
|
|
126
73
|
}
|
|
127
74
|
]
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"main": "dist/index.js",
|
|
26
26
|
"name": "@macroforge/mcp-server",
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"macroforge": "
|
|
28
|
+
"macroforge": "file:../../crates/macroforge_ts"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
31
31
|
"macroforge": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/macroforge-ts/
|
|
37
|
+
"url": "git+https://github.com/macroforge-ts/macroforge-ts.git"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "deno install --node-modules-dir --quiet && deno run -A npm:typescript@5/tsc && chmod +x dist/index.js",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"test": "node --test tests/**/*.test.js"
|
|
47
47
|
},
|
|
48
48
|
"type": "module",
|
|
49
|
-
"version": "0.1.
|
|
49
|
+
"version": "0.1.79"
|
|
50
50
|
}
|