schemantic 0.3.0 → 0.4.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.
Files changed (124) hide show
  1. package/CHANGELOG.md +196 -174
  2. package/LICENSE +21 -21
  3. package/README.md +88 -830
  4. package/dist/cli/index.d.ts +4 -1
  5. package/dist/cli/index.d.ts.map +1 -1
  6. package/dist/cli/index.js +185 -61
  7. package/dist/cli/index.js.map +1 -1
  8. package/dist/core/configuration.d.ts +6 -0
  9. package/dist/core/configuration.d.ts.map +1 -0
  10. package/dist/core/configuration.js +64 -0
  11. package/dist/core/configuration.js.map +1 -0
  12. package/dist/core/index.d.ts +1 -0
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js +1 -0
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/core/output-writer.d.ts +7 -0
  17. package/dist/core/output-writer.d.ts.map +1 -0
  18. package/dist/core/output-writer.js +255 -0
  19. package/dist/core/output-writer.js.map +1 -0
  20. package/dist/core/schemantic.d.ts +8 -2
  21. package/dist/core/schemantic.d.ts.map +1 -1
  22. package/dist/core/schemantic.js +196 -71
  23. package/dist/core/schemantic.js.map +1 -1
  24. package/dist/generators/api-client-generator.d.ts +9 -20
  25. package/dist/generators/api-client-generator.d.ts.map +1 -1
  26. package/dist/generators/api-client-generator.js +364 -424
  27. package/dist/generators/api-client-generator.js.map +1 -1
  28. package/dist/generators/base.d.ts.map +1 -1
  29. package/dist/generators/base.js +7 -25
  30. package/dist/generators/base.js.map +1 -1
  31. package/dist/generators/enum-generator.d.ts.map +1 -1
  32. package/dist/generators/enum-generator.js +30 -3
  33. package/dist/generators/enum-generator.js.map +1 -1
  34. package/dist/generators/hook-generator.d.ts +3 -17
  35. package/dist/generators/hook-generator.d.ts.map +1 -1
  36. package/dist/generators/hook-generator.js +51 -445
  37. package/dist/generators/hook-generator.js.map +1 -1
  38. package/dist/generators/naming.d.ts +10 -0
  39. package/dist/generators/naming.d.ts.map +1 -0
  40. package/dist/generators/naming.js +331 -0
  41. package/dist/generators/naming.js.map +1 -0
  42. package/dist/generators/object-generator.d.ts +0 -4
  43. package/dist/generators/object-generator.d.ts.map +1 -1
  44. package/dist/generators/object-generator.js +13 -101
  45. package/dist/generators/object-generator.js.map +1 -1
  46. package/dist/generators/primitive-generator.d.ts +1 -13
  47. package/dist/generators/primitive-generator.d.ts.map +1 -1
  48. package/dist/generators/primitive-generator.js +11 -76
  49. package/dist/generators/primitive-generator.js.map +1 -1
  50. package/dist/generators/projections.d.ts +10 -0
  51. package/dist/generators/projections.d.ts.map +1 -0
  52. package/dist/generators/projections.js +65 -0
  53. package/dist/generators/projections.js.map +1 -0
  54. package/dist/generators/schema-type.d.ts +23 -0
  55. package/dist/generators/schema-type.d.ts.map +1 -0
  56. package/dist/generators/schema-type.js +233 -0
  57. package/dist/generators/schema-type.js.map +1 -0
  58. package/dist/parsers/base.d.ts +2 -0
  59. package/dist/parsers/base.d.ts.map +1 -1
  60. package/dist/parsers/base.js +12 -2
  61. package/dist/parsers/base.js.map +1 -1
  62. package/dist/parsers/factory.d.ts.map +1 -1
  63. package/dist/parsers/factory.js +2 -1
  64. package/dist/parsers/factory.js.map +1 -1
  65. package/dist/parsers/openapi.d.ts +4 -0
  66. package/dist/parsers/openapi.d.ts.map +1 -1
  67. package/dist/parsers/openapi.js +107 -20
  68. package/dist/parsers/openapi.js.map +1 -1
  69. package/dist/plugins/branded-types.d.ts.map +1 -1
  70. package/dist/plugins/branded-types.js +231 -365
  71. package/dist/plugins/branded-types.js.map +1 -1
  72. package/dist/plugins/builtin.d.ts.map +1 -1
  73. package/dist/plugins/builtin.js +6 -141
  74. package/dist/plugins/builtin.js.map +1 -1
  75. package/dist/plugins/index.d.ts +4 -0
  76. package/dist/plugins/index.d.ts.map +1 -1
  77. package/dist/plugins/index.js +17 -0
  78. package/dist/plugins/index.js.map +1 -1
  79. package/dist/plugins/loader.d.ts +5 -1
  80. package/dist/plugins/loader.d.ts.map +1 -1
  81. package/dist/plugins/loader.js +42 -5
  82. package/dist/plugins/loader.js.map +1 -1
  83. package/dist/plugins/manager.d.ts.map +1 -1
  84. package/dist/plugins/manager.js +7 -7
  85. package/dist/plugins/manager.js.map +1 -1
  86. package/dist/plugins/performance-monitoring.d.ts +31 -1
  87. package/dist/plugins/performance-monitoring.d.ts.map +1 -1
  88. package/dist/plugins/performance-monitoring.js +146 -207
  89. package/dist/plugins/performance-monitoring.js.map +1 -1
  90. package/dist/plugins/request-deduplication.d.ts.map +1 -1
  91. package/dist/plugins/request-deduplication.js +151 -586
  92. package/dist/plugins/request-deduplication.js.map +1 -1
  93. package/dist/plugins/zod-validation.d.ts +23 -15
  94. package/dist/plugins/zod-validation.d.ts.map +1 -1
  95. package/dist/plugins/zod-validation.js +390 -268
  96. package/dist/plugins/zod-validation.js.map +1 -1
  97. package/dist/types/core.d.ts +20 -3
  98. package/dist/types/core.d.ts.map +1 -1
  99. package/dist/types/core.js +2 -0
  100. package/dist/types/core.js.map +1 -1
  101. package/dist/types/openapi.d.ts +14 -1
  102. package/dist/types/openapi.d.ts.map +1 -1
  103. package/docs/ADVANCED_PLUGINS_IMPLEMENTATION.md +24 -355
  104. package/docs/ADVANCED_PLUGIN_DEVELOPMENT.md +33 -309
  105. package/docs/API.md +80 -601
  106. package/docs/AUDIT.md +49 -0
  107. package/docs/CONFIGURATION.md +81 -715
  108. package/docs/FASTAPI_TUTORIAL.md +109 -1497
  109. package/docs/NAMING_MIGRATION.md +59 -0
  110. package/docs/PLUGINS.md +49 -687
  111. package/docs/PLUGIN_DEVELOPMENT.md +53 -720
  112. package/docs/REAUDIT.md +399 -0
  113. package/docs/RELEASING.md +88 -0
  114. package/docs/REMEDIATION.md +58 -0
  115. package/docs/superpowers/plans/2026-10-10-audit-remediation.md +113 -0
  116. package/package.json +114 -95
  117. package/dist/__tests__/setup.d.ts +0 -6
  118. package/dist/__tests__/setup.d.ts.map +0 -1
  119. package/dist/__tests__/setup.js +0 -30
  120. package/dist/__tests__/setup.js.map +0 -1
  121. package/dist/__tests__/test-config.d.ts +0 -36
  122. package/dist/__tests__/test-config.d.ts.map +0 -1
  123. package/dist/__tests__/test-config.js +0 -562
  124. package/dist/__tests__/test-config.js.map +0 -1
@@ -0,0 +1,59 @@
1
+ # Generated naming migration
2
+
3
+ Status: implemented. CamelCase application properties are now the default, with schema-aware request serialization and JSON response deserialization. API wire names stay intact. `propertyNaming: "preserve"` retains payload-shaped types for existing consumers.
4
+
5
+ ## Agreed default
6
+
7
+ Use PascalCase for classes, interfaces, type aliases and enum names, and camelCase for methods, parameters, local variables and application-facing properties. Normalize common acronyms consistently: `user_id` becomes `userId`, `HTTP_response` becomes `httpResponse`, and `user_profile` becomes `UserProfile` as a type name. Keep enum wire values unchanged. Use conventional uppercase enum member names.
8
+
9
+ The new property behavior defaults to camelCase with generated request serialization and response deserialization. Projects that want payload-shaped types can select preservation:
10
+
11
+ ```typescript
12
+ // Current configuration.
13
+ propertyNaming: "camelCase" // default
14
+ // or
15
+ propertyNaming: "preserve" // retain user_id, x-label, etc.
16
+ ```
17
+
18
+ Property naming is separate from method/type naming. `namingConvention` continues to control method/parameter naming for compatibility; types and classes use PascalCase. Numeric modes are not used. Component names that shadow built-in generic utility types or client declarations receive a `Model` suffix; further collisions fail generation explicitly.
19
+
20
+ ## Expected output
21
+
22
+ For a payload `{ "user_id": "42", "display_name": "Ada" }`:
23
+
24
+ ```typescript
25
+ export interface User {
26
+ userId: string;
27
+ displayName: string;
28
+ }
29
+
30
+ // Generated schema-aware functions. Conversion does not validate payloads.
31
+ export function deserializeUser(payload: unknown): User;
32
+ export function serializeUser(value: User): unknown;
33
+ ```
34
+
35
+ `client.getUser()` returns application-shaped `User`. `client.updateUser({ userId: "42", displayName: "Ada" })` sends the original API keys. Preservation mode retains the wire-shaped interface and avoids property conversion. Types-only projects receive the converters when selecting camelCase, so the same contract works without a generated HTTP client.
36
+
37
+ ## Conversion contract
38
+
39
+ - Generate an explicit wire-to-property mapping from the schema, shared by types, clients, hooks and validation plugins. Keep parameter wire names independently for path/query/header/cookie serialization.
40
+ - Convert declared object properties recursively through arrays, references, nullable values, compositions and nested objects. Preserve absent versus present properties, optional fields and `null`.
41
+ - Preserve dictionary keys, unknown payload fields, enum values and strings. For `Record<string, User>`, keep the keys and convert each `User` value. Do not run a global recursive casing function over arbitrary JSON.
42
+ - Treat binary values, `Blob`, `File`, `FormData`, dates and other non-JSON inputs according to their explicit schema/media conversion rules. Do not turn arbitrary objects into JSON while renaming keys.
43
+ - Keep string dates as strings unless a separate runtime conversion setting explicitly requests dates. Custom TypeScript mappings alone are not runtime parsers.
44
+ - Select union variants using wire discriminators before renaming the discriminator property. Ambiguous unions need a deterministic documented policy and a diagnostic when safe conversion cannot be established.
45
+ - Retain source wire metadata on generated members. Generated Zod validators validate application-shaped values. Validation helpers remain explicit integrations; enabling a plugin does not automatically validate HTTP traffic. Hooks expose the same application properties as clients.
46
+ - Fail generation for normalized property/type/export collisions (`user_id` and `userId`) with the schema path and both source names. Rename the conflicting source property or select preserve mode; explicit property overrides are not implemented. Reserved identifiers and invalid leading characters use shared formatters. Conflicting method identifiers receive deterministic suffixes.
47
+ - Avoid mutation of input payloads and schemas. Build new converted values; guard recursive references in generated converter definitions.
48
+
49
+ ## Implementation sequence
50
+
51
+ 1. Add naming metadata and one shared formatter. Audit all first-party and plugin generators against it; add separate property configuration and explicit collision diagnostics. Preserve existing type-prefix/suffix behavior and review API-title-derived client names for duplicate `Api`/`Client` words.
52
+ 2. Generate and export schema-aware serializers/deserializers. Add preservation mode first, then implement camelCase conversion with fixtures for arrays, dictionaries, optional/null values, recursive references and unions.
53
+ 3. Connect converters at HTTP boundaries for JSON requests/responses and declared form fields. Align hooks and Zod output. Ensure errors, headers and dictionary keys retain their intended semantics.
54
+ 4. Validate both modes using compiled consumer code and real local HTTP round trips. Test spelling, wire bytes, decoded objects, validation failures and collision errors, including custom prefixes and nested filenames.
55
+ 5. The camelCase default and preservation mode are implemented in the working tree, with before/after examples in maintained guides. Publishing a migration release and a separate generated-name mapping report remain future release work.
56
+
57
+ ## Release acceptance
58
+
59
+ Every repository schema compiles under strict TypeScript in both modes. A camelCase request reaches the server with unchanged wire keys; a wire response returns camelCase application properties. Preservation mode returns the original payload shape. Dictionaries, enums and binary inputs survive round trips unchanged where specified. Plugins and hooks use the same names and converters. No public naming change ships without a documented compatibility setting.