@macroforge/mcp-server 0.1.37 → 0.1.39

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.
Files changed (43) hide show
  1. package/docs/api/api-overview.md +13 -13
  2. package/docs/api/expand-sync.md +8 -8
  3. package/docs/api/native-plugin.md +15 -15
  4. package/docs/api/position-mapper.md +6 -6
  5. package/docs/api/transform-sync.md +11 -11
  6. package/docs/builtin-macros/clone.md +43 -23
  7. package/docs/builtin-macros/debug.md +50 -18
  8. package/docs/builtin-macros/default.md +79 -28
  9. package/docs/builtin-macros/deserialize/cycleforward-reference-support.md +11 -0
  10. package/docs/builtin-macros/deserialize/example.md +1625 -0
  11. package/docs/builtin-macros/deserialize/overview.md +15 -10
  12. package/docs/builtin-macros/deserialize/union-type-deserialization.md +27 -0
  13. package/docs/builtin-macros/deserialize/validation.md +34 -0
  14. package/docs/builtin-macros/deserialize.md +1608 -23
  15. package/docs/builtin-macros/hash.md +87 -20
  16. package/docs/builtin-macros/macros-overview.md +40 -40
  17. package/docs/builtin-macros/ord.md +56 -31
  18. package/docs/builtin-macros/partial-eq/example.md +526 -0
  19. package/docs/builtin-macros/partial-eq/overview.md +39 -0
  20. package/docs/builtin-macros/partial-eq.md +184 -26
  21. package/docs/builtin-macros/partial-ord.md +68 -30
  22. package/docs/builtin-macros/serialize/example.md +139 -0
  23. package/docs/builtin-macros/serialize/overview.md +32 -0
  24. package/docs/builtin-macros/serialize/type-specific-serialization.md +22 -0
  25. package/docs/builtin-macros/serialize.md +130 -28
  26. package/docs/concepts/architecture.md +2 -2
  27. package/docs/concepts/derive-system.md +25 -39
  28. package/docs/concepts/how-macros-work.md +8 -4
  29. package/docs/custom-macros/custom-overview.md +23 -23
  30. package/docs/custom-macros/rust-setup.md +31 -31
  31. package/docs/custom-macros/ts-macro-derive.md +107 -107
  32. package/docs/custom-macros/ts-quote.md +226 -226
  33. package/docs/getting-started/first-macro.md +38 -28
  34. package/docs/getting-started/installation.md +15 -15
  35. package/docs/integration/cli.md +9 -9
  36. package/docs/integration/configuration.md +16 -16
  37. package/docs/integration/mcp-server.md +6 -6
  38. package/docs/integration/svelte-preprocessor.md +40 -41
  39. package/docs/integration/typescript-plugin.md +13 -12
  40. package/docs/integration/vite-plugin.md +12 -12
  41. package/docs/language-servers/zed.md +1 -1
  42. package/docs/sections.json +88 -2
  43. package/package.json +2 -2
@@ -1,16 +1,21 @@
1
1
  # Deserialize
2
2
 
3
- *The `Deserialize` macro generates a static `fromJSON()` method that parses JSON data into your class with runtime validation and automatic type conversion.*
3
+ The `Deserialize` macro generates JSON deserialization methods with **cycle and
4
+ forward-reference support**, plus comprehensive runtime validation. This enables
5
+ safe parsing of complex JSON structures including circular references.
4
6
 
5
- ## Basic Usage
7
+ ## Generated Output
6
8
 
7
- <MacroExample before={data.examples.basic.before} after={data.examples.basic.after} />
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 |
8
15
 
9
- ```typescript
10
- const json = '{"name":"Alice","age":30,"createdAt":"2024-01-15T10:30:00.000Z"}';
11
- const user = User.fromJSON(JSON.parse(json));
16
+ ## Return Type
12
17
 
13
- console.log(user.name); // "Alice"
14
- console.log(user.age); // 30
15
- console.log(user.createdAt instanceof Date); // true
16
- ```
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
@@ -0,0 +1,27 @@
1
+ ## Union Type Deserialization
2
+
3
+ Union types are deserialized based on their member types:
4
+
5
+ ### Literal Unions
6
+ For unions of literal values (`"A" | "B" | 123`), the value is validated against
7
+ the allowed literals directly.
8
+
9
+ ### Primitive Unions
10
+ For unions containing primitive types (`string | number`), the deserializer uses
11
+ `typeof` checks to validate the value type. No `__type` discriminator is needed.
12
+
13
+ ### Class/Interface Unions
14
+ For unions of serializable types (`User | Admin`), the deserializer requires a
15
+ `__type` field in the JSON to dispatch to the correct type's `deserializeWithContext` method.
16
+
17
+ ### Generic Type Parameters
18
+ For generic unions like `type Result<T> = T | Error`, the generic type parameter `T`
19
+ is passed through as-is since its concrete type is only known at the call site.
20
+
21
+ ### Mixed Unions
22
+ Mixed unions (e.g., `string | Date | User`) check in order:
23
+ 1. Literal values
24
+ 2. Primitives (via `typeof`)
25
+ 3. Date (via `instanceof` or ISO string parsing)
26
+ 4. Serializable types (via `__type` dispatch)
27
+ 5. Generic type parameters (pass-through)
@@ -0,0 +1,34 @@
1
+ ## Validation
2
+
3
+ The macro supports 30+ validators via `@serde(validate(...))`:
4
+
5
+ ### String Validators
6
+ - `email`, `url`, `uuid` - Format validation
7
+ - `minLength(n)`, `maxLength(n)`, `length(n)` - Length constraints
8
+ - `pattern("regex")` - Regular expression matching
9
+ - `nonEmpty`, `trimmed`, `lowercase`, `uppercase` - String properties
10
+
11
+ ### Number Validators
12
+ - `gt(n)`, `gte(n)`, `lt(n)`, `lte(n)`, `between(min, max)` - Range checks
13
+ - `int`, `positive`, `nonNegative`, `finite` - Number properties
14
+
15
+ ### Array Validators
16
+ - `minItems(n)`, `maxItems(n)`, `itemsCount(n)` - Collection size
17
+
18
+ ### Date Validators
19
+ - `validDate`, `afterDate("ISO")`, `beforeDate("ISO")` - Date validation
20
+
21
+ ## Field-Level Options
22
+
23
+ The `@serde` decorator supports:
24
+
25
+ - `skip` / `skipDeserializing` - Exclude field from deserialization
26
+ - `rename = "jsonKey"` - Read from different JSON property
27
+ - `default` / `default = expr` - Use default value if missing
28
+ - `flatten` - Read fields from parent object level
29
+ - `validate(...)` - Apply validators
30
+
31
+ ## Container-Level Options
32
+
33
+ - `denyUnknownFields` - Error on unrecognized JSON properties
34
+ - `renameAll = "camelCase"` - Apply naming convention to all fields