schemantic 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/CHANGELOG.md +92 -0
- package/LICENSE +21 -0
- package/README.md +827 -0
- package/dist/__tests__/setup.d.ts +6 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +30 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/__tests__/test-config.d.ts +36 -0
- package/dist/__tests__/test-config.d.ts.map +1 -0
- package/dist/__tests__/test-config.js +563 -0
- package/dist/__tests__/test-config.js.map +1 -0
- package/dist/cli/index.d.ts +118 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +657 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +21 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/schemantic.d.ts +95 -0
- package/dist/core/schemantic.d.ts.map +1 -0
- package/dist/core/schemantic.js +543 -0
- package/dist/core/schemantic.js.map +1 -0
- package/dist/generators/api-client-generator.d.ts +145 -0
- package/dist/generators/api-client-generator.d.ts.map +1 -0
- package/dist/generators/api-client-generator.js +856 -0
- package/dist/generators/api-client-generator.js.map +1 -0
- package/dist/generators/base.d.ts +117 -0
- package/dist/generators/base.d.ts.map +1 -0
- package/dist/generators/base.js +232 -0
- package/dist/generators/base.js.map +1 -0
- package/dist/generators/enum-generator.d.ts +52 -0
- package/dist/generators/enum-generator.d.ts.map +1 -0
- package/dist/generators/enum-generator.js +178 -0
- package/dist/generators/enum-generator.js.map +1 -0
- package/dist/generators/factory.d.ts +59 -0
- package/dist/generators/factory.d.ts.map +1 -0
- package/dist/generators/factory.js +127 -0
- package/dist/generators/factory.js.map +1 -0
- package/dist/generators/hook-generator.d.ts +36 -0
- package/dist/generators/hook-generator.d.ts.map +1 -0
- package/dist/generators/hook-generator.js +495 -0
- package/dist/generators/hook-generator.js.map +1 -0
- package/dist/generators/index.d.ts +10 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +26 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/object-generator.d.ts +48 -0
- package/dist/generators/object-generator.d.ts.map +1 -0
- package/dist/generators/object-generator.js +280 -0
- package/dist/generators/object-generator.js.map +1 -0
- package/dist/generators/primitive-generator.d.ts +40 -0
- package/dist/generators/primitive-generator.d.ts.map +1 -0
- package/dist/generators/primitive-generator.js +150 -0
- package/dist/generators/primitive-generator.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/base.d.ts +101 -0
- package/dist/parsers/base.d.ts.map +1 -0
- package/dist/parsers/base.js +77 -0
- package/dist/parsers/base.js.map +1 -0
- package/dist/parsers/factory.d.ts +64 -0
- package/dist/parsers/factory.d.ts.map +1 -0
- package/dist/parsers/factory.js +116 -0
- package/dist/parsers/factory.js.map +1 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +23 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/openapi.d.ts +52 -0
- package/dist/parsers/openapi.d.ts.map +1 -0
- package/dist/parsers/openapi.js +396 -0
- package/dist/parsers/openapi.js.map +1 -0
- package/dist/plugins/branded-types.d.ts +28 -0
- package/dist/plugins/branded-types.d.ts.map +1 -0
- package/dist/plugins/branded-types.js +568 -0
- package/dist/plugins/branded-types.js.map +1 -0
- package/dist/plugins/builtin.d.ts +38 -0
- package/dist/plugins/builtin.d.ts.map +1 -0
- package/dist/plugins/builtin.js +283 -0
- package/dist/plugins/builtin.js.map +1 -0
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +23 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/loader.d.ts +92 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +245 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/manager.d.ts +99 -0
- package/dist/plugins/manager.d.ts.map +1 -0
- package/dist/plugins/manager.js +233 -0
- package/dist/plugins/manager.js.map +1 -0
- package/dist/plugins/performance-monitoring.d.ts +98 -0
- package/dist/plugins/performance-monitoring.d.ts.map +1 -0
- package/dist/plugins/performance-monitoring.js +596 -0
- package/dist/plugins/performance-monitoring.js.map +1 -0
- package/dist/plugins/request-deduplication.d.ts +27 -0
- package/dist/plugins/request-deduplication.d.ts.map +1 -0
- package/dist/plugins/request-deduplication.js +650 -0
- package/dist/plugins/request-deduplication.js.map +1 -0
- package/dist/plugins/zod-validation.d.ts +63 -0
- package/dist/plugins/zod-validation.d.ts.map +1 -0
- package/dist/plugins/zod-validation.js +743 -0
- package/dist/plugins/zod-validation.js.map +1 -0
- package/dist/types/core.d.ts +203 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +24 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/openapi.d.ts +250 -0
- package/dist/types/openapi.d.ts.map +1 -0
- package/dist/types/openapi.js +8 -0
- package/dist/types/openapi.js.map +1 -0
- package/dist/types/schema.d.ts +68 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +22 -0
- package/dist/types/schema.js.map +1 -0
- package/docs/ADVANCED_PLUGINS_IMPLEMENTATION.md +355 -0
- package/docs/ADVANCED_PLUGIN_DEVELOPMENT.md +309 -0
- package/docs/API.md +600 -0
- package/docs/CONFIGURATION.md +722 -0
- package/docs/FASTAPI_TUTORIAL.md +1497 -0
- package/docs/PLUGINS.md +683 -0
- package/docs/PLUGIN_DEVELOPMENT.md +720 -0
- package/package.json +90 -0
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Advanced Branded Types Plugin
|
|
4
|
+
*
|
|
5
|
+
* Implements sophisticated branded types for compile-time safety guarantees,
|
|
6
|
+
* phantom type parameters for state management, and discriminated unions with
|
|
7
|
+
* runtime type guards for enhanced type system capabilities.
|
|
8
|
+
*
|
|
9
|
+
* Key Features:
|
|
10
|
+
* - Branded types for compile-time safety (prevents primitive obsession)
|
|
11
|
+
* - Phantom type parameters for authentication state management
|
|
12
|
+
* - Discriminated unions with exhaustive type checking
|
|
13
|
+
* - Runtime type guards with brand preservation
|
|
14
|
+
* - Type-level computations for advanced validations
|
|
15
|
+
* - Nominal typing simulation in TypeScript's structural system
|
|
16
|
+
*
|
|
17
|
+
* Architecture:
|
|
18
|
+
* - Zero-runtime-cost type safety through brands
|
|
19
|
+
* - Compile-time state tracking via phantom types
|
|
20
|
+
* - Type-level programming for validation pipelines
|
|
21
|
+
* - Integration with existing validation systems
|
|
22
|
+
*/
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.brandedTypesPlugin = void 0;
|
|
25
|
+
const schema_1 = require("../types/schema");
|
|
26
|
+
/**
|
|
27
|
+
* Advanced Branded Types Plugin Implementation
|
|
28
|
+
*/
|
|
29
|
+
exports.brandedTypesPlugin = {
|
|
30
|
+
name: "branded-types",
|
|
31
|
+
version: "2.0.0",
|
|
32
|
+
description: "Advanced branded types with phantom parameters and type-level safety guarantees",
|
|
33
|
+
/**
|
|
34
|
+
* Transform schema to include brand metadata
|
|
35
|
+
*/
|
|
36
|
+
transformSchema: (schema, context) => {
|
|
37
|
+
const options = getPluginOptions(context);
|
|
38
|
+
if (!options.enabled) {
|
|
39
|
+
return schema;
|
|
40
|
+
}
|
|
41
|
+
if ((0, schema_1.isOpenAPISchemaObject)(schema)) {
|
|
42
|
+
const extendedSchema = schema;
|
|
43
|
+
// Add brand metadata
|
|
44
|
+
extendedSchema._brandMetadata = {
|
|
45
|
+
shouldBrand: shouldGenerateBrand(schema),
|
|
46
|
+
brandType: determineBrandType(schema),
|
|
47
|
+
validationConstraints: extractValidationConstraints(schema),
|
|
48
|
+
};
|
|
49
|
+
// Process nested properties recursively
|
|
50
|
+
if (schema.properties) {
|
|
51
|
+
for (const [propName, propSchema] of Object.entries(schema.properties)) {
|
|
52
|
+
if (typeof propSchema === "object" && propSchema !== null) {
|
|
53
|
+
schema.properties[propName] = exports.brandedTypesPlugin.transformSchema(propSchema, context);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return schema;
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Enhance type generation with branded types
|
|
62
|
+
*/
|
|
63
|
+
afterTypeGeneration: async (typeName, generatedType, context) => {
|
|
64
|
+
const options = getPluginOptions(context);
|
|
65
|
+
if (!options.enabled || !generatedType.isInterface) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const brandedCode = generateBrandedTypeEnhancements(typeName, generatedType, options);
|
|
70
|
+
if (brandedCode) {
|
|
71
|
+
generatedType.content += brandedCode;
|
|
72
|
+
// Update exports
|
|
73
|
+
generatedType.exports.push(`Branded${typeName}`, `create${typeName}`, `is${typeName}`, `assert${typeName}`);
|
|
74
|
+
if (options.enablePhantomTypes) {
|
|
75
|
+
generatedType.exports.push(`${typeName}WithAuth`, `authorize${typeName}`, `unauthorize${typeName}`);
|
|
76
|
+
}
|
|
77
|
+
if (options.enableDiscriminatedUnions) {
|
|
78
|
+
generatedType.exports.push(`${typeName}Union`, `match${typeName}`, `is${typeName}Variant`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.warn(`Branded types plugin afterTypeGeneration failed for ${typeName}:`, error);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* Enhance API client with branded type integration
|
|
88
|
+
*/
|
|
89
|
+
afterClientGeneration: async (generatedClient, context) => {
|
|
90
|
+
const options = getPluginOptions(context);
|
|
91
|
+
if (!options.enabled) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const clientEnhancements = generateClientBrandedTypeIntegration(generatedClient, options);
|
|
96
|
+
if (clientEnhancements) {
|
|
97
|
+
generatedClient.content += clientEnhancements;
|
|
98
|
+
// Update exports
|
|
99
|
+
generatedClient.exports.push("BrandedApiClient", "TypeSafeApiClient", "withBrandValidation");
|
|
100
|
+
if (options.enablePhantomTypes) {
|
|
101
|
+
generatedClient.exports.push("AuthenticatedApiClient", "UnauthenticatedApiClient");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.warn("Branded types plugin afterClientGeneration failed:", error);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Get plugin options from generation context
|
|
112
|
+
*/
|
|
113
|
+
function getPluginOptions(context) {
|
|
114
|
+
const pluginConfig = context?.config?.plugins?.find((p) => p.name === "branded-types");
|
|
115
|
+
return {
|
|
116
|
+
enabled: true,
|
|
117
|
+
enablePhantomTypes: true,
|
|
118
|
+
enableRuntimeGuards: true,
|
|
119
|
+
enableDiscriminatedUnions: true,
|
|
120
|
+
enableTypeLevelValidations: false,
|
|
121
|
+
brandNamingConvention: "prefix",
|
|
122
|
+
brandIdentifier: "Brand",
|
|
123
|
+
enableAssertionFunctions: true,
|
|
124
|
+
enableOpaqueTypes: true,
|
|
125
|
+
enableTypePredicates: true,
|
|
126
|
+
...(pluginConfig?.options || {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Determine if a schema should generate a branded type
|
|
131
|
+
*/
|
|
132
|
+
function shouldGenerateBrand(schema) {
|
|
133
|
+
// Generate brands for types with validation constraints or specific patterns
|
|
134
|
+
return !!(schema.pattern ||
|
|
135
|
+
schema.format ||
|
|
136
|
+
schema.minimum !== undefined ||
|
|
137
|
+
schema.maximum !== undefined ||
|
|
138
|
+
schema.minLength !== undefined ||
|
|
139
|
+
schema.maxLength !== undefined ||
|
|
140
|
+
schema.enum ||
|
|
141
|
+
(schema.type === "string" &&
|
|
142
|
+
(schema.description?.includes("id") ||
|
|
143
|
+
schema.description?.includes("Id"))));
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Determine the type of brand to generate
|
|
147
|
+
*/
|
|
148
|
+
function determineBrandType(schema) {
|
|
149
|
+
if (schema.format) {
|
|
150
|
+
return `${schema.format}Brand`;
|
|
151
|
+
}
|
|
152
|
+
if (schema.pattern) {
|
|
153
|
+
return "PatternBrand";
|
|
154
|
+
}
|
|
155
|
+
if (schema.minimum !== undefined || schema.maximum !== undefined) {
|
|
156
|
+
return "NumericBrand";
|
|
157
|
+
}
|
|
158
|
+
if (schema.enum) {
|
|
159
|
+
return "EnumBrand";
|
|
160
|
+
}
|
|
161
|
+
return "DefaultBrand";
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Extract validation constraints from schema
|
|
165
|
+
*/
|
|
166
|
+
function extractValidationConstraints(schema) {
|
|
167
|
+
const constraints = [];
|
|
168
|
+
if (schema.minLength !== undefined) {
|
|
169
|
+
constraints.push(`minLength:${schema.minLength}`);
|
|
170
|
+
}
|
|
171
|
+
if (schema.maxLength !== undefined) {
|
|
172
|
+
constraints.push(`maxLength:${schema.maxLength}`);
|
|
173
|
+
}
|
|
174
|
+
if (schema.minimum !== undefined) {
|
|
175
|
+
constraints.push(`minimum:${schema.minimum}`);
|
|
176
|
+
}
|
|
177
|
+
if (schema.maximum !== undefined) {
|
|
178
|
+
constraints.push(`maximum:${schema.maximum}`);
|
|
179
|
+
}
|
|
180
|
+
if (schema.pattern) {
|
|
181
|
+
constraints.push(`pattern:${schema.pattern}`);
|
|
182
|
+
}
|
|
183
|
+
if (schema.format) {
|
|
184
|
+
constraints.push(`format:${schema.format}`);
|
|
185
|
+
}
|
|
186
|
+
return constraints;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Generate branded type enhancements for a given type
|
|
190
|
+
*/
|
|
191
|
+
function generateBrandedTypeEnhancements(typeName, generatedType, options) {
|
|
192
|
+
if (!(0, schema_1.isOpenAPISchemaObject)(generatedType.sourceSchema)) {
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
const schema = generatedType.sourceSchema;
|
|
196
|
+
const brandMetadata = schema._brandMetadata || {};
|
|
197
|
+
if (!brandMetadata.shouldBrand) {
|
|
198
|
+
return generateBasicBrandedType(typeName, options);
|
|
199
|
+
}
|
|
200
|
+
return generateAdvancedBrandedType(typeName, schema, options, brandMetadata);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Generate basic branded type without specific validation
|
|
204
|
+
*/
|
|
205
|
+
function generateBasicBrandedType(typeName, options) {
|
|
206
|
+
const brandName = `${typeName}${options.brandIdentifier || "Brand"}`;
|
|
207
|
+
return `
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Branded type for ${typeName} with compile-time safety guarantees
|
|
211
|
+
*/
|
|
212
|
+
export type Branded${typeName} = ${typeName} & { readonly __brand: '${brandName}' };
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Create a branded ${typeName} instance
|
|
216
|
+
*/
|
|
217
|
+
export function create${typeName}(data: ${typeName}): Branded${typeName} {
|
|
218
|
+
// Runtime validation would go here
|
|
219
|
+
return data as Branded${typeName};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Type guard for Branded${typeName}
|
|
224
|
+
*/
|
|
225
|
+
export function is${typeName}(value: unknown): value is Branded${typeName} {
|
|
226
|
+
// Basic type checking
|
|
227
|
+
return typeof value === 'object' && value !== null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Assertion function for ${typeName}
|
|
232
|
+
*/
|
|
233
|
+
export function assert${typeName}(value: unknown): asserts value is Branded${typeName} {
|
|
234
|
+
if (!is${typeName}(value)) {
|
|
235
|
+
throw new Error(\`Expected ${typeName}, got \${typeof value}\`);
|
|
236
|
+
}
|
|
237
|
+
}${options.enablePhantomTypes ? generatePhantomTypes(typeName) : ""}${options.enableDiscriminatedUnions
|
|
238
|
+
? generateDiscriminatedUnions(typeName)
|
|
239
|
+
: ""}`;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Generate advanced branded type with validation constraints
|
|
243
|
+
*/
|
|
244
|
+
function generateAdvancedBrandedType(typeName, schema, options, brandMetadata) {
|
|
245
|
+
const brandName = `${typeName}${options.brandIdentifier || "Brand"}`;
|
|
246
|
+
const validationCode = generateValidationCode(schema, brandMetadata);
|
|
247
|
+
return `
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Advanced branded type for ${typeName} with validation constraints
|
|
251
|
+
* Constraints: ${Array.isArray(brandMetadata.validationConstraints)
|
|
252
|
+
? brandMetadata.validationConstraints.join(", ")
|
|
253
|
+
: "none"}
|
|
254
|
+
*/
|
|
255
|
+
export type Branded${typeName} = ${typeName} & {
|
|
256
|
+
readonly __brand: '${brandName}';
|
|
257
|
+
readonly __constraints: {${generateConstraintTypes(schema)}};
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Create a validated branded ${typeName} instance
|
|
262
|
+
*/
|
|
263
|
+
export function create${typeName}(data: ${typeName}): Branded${typeName} {
|
|
264
|
+
${validationCode}
|
|
265
|
+
return data as Branded${typeName};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Advanced type guard with constraint validation
|
|
270
|
+
*/
|
|
271
|
+
export function is${typeName}(value: unknown): value is Branded${typeName} {
|
|
272
|
+
if (typeof value !== 'object' || value === null) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
create${typeName}(value as ${typeName});
|
|
278
|
+
return true;
|
|
279
|
+
} catch {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Assertion function with detailed error messages
|
|
286
|
+
*/
|
|
287
|
+
export function assert${typeName}(value: unknown): asserts value is Branded${typeName} {
|
|
288
|
+
if (!is${typeName}(value)) {
|
|
289
|
+
throw new TypeError(\`Value does not satisfy ${typeName} constraints\`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
${options.enableOpaqueTypes ? generateOpaqueTypeHelpers(typeName) : ""}${options.enablePhantomTypes ? generatePhantomTypes(typeName) : ""}${options.enableDiscriminatedUnions
|
|
294
|
+
? generateDiscriminatedUnions(typeName)
|
|
295
|
+
: ""}`;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Generate validation code based on schema constraints
|
|
299
|
+
*/
|
|
300
|
+
function generateValidationCode(schema, _brandMetadata) {
|
|
301
|
+
const validations = [];
|
|
302
|
+
if (schema.type === "string") {
|
|
303
|
+
if (schema.minLength !== undefined) {
|
|
304
|
+
validations.push(`if (typeof data !== 'string' || data.length < ${schema.minLength}) throw new Error('String too short');`);
|
|
305
|
+
}
|
|
306
|
+
if (schema.maxLength !== undefined) {
|
|
307
|
+
validations.push(`if (typeof data !== 'string' || data.length > ${schema.maxLength}) throw new Error('String too long');`);
|
|
308
|
+
}
|
|
309
|
+
if (schema.pattern) {
|
|
310
|
+
validations.push(`if (typeof data !== 'string' || !/${schema.pattern}/.test(data)) throw new Error('Pattern mismatch');`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (schema.type === "number" || schema.type === "integer") {
|
|
314
|
+
if (schema.minimum !== undefined) {
|
|
315
|
+
validations.push(`if (typeof data !== 'number' || data < ${schema.minimum}) throw new Error('Number too small');`);
|
|
316
|
+
}
|
|
317
|
+
if (schema.maximum !== undefined) {
|
|
318
|
+
validations.push(`if (typeof data !== 'number' || data > ${schema.maximum}) throw new Error('Number too large');`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return validations.join("\n ");
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Generate constraint types for the brand
|
|
325
|
+
*/
|
|
326
|
+
function generateConstraintTypes(schema) {
|
|
327
|
+
const constraints = [];
|
|
328
|
+
if (schema.minLength !== undefined) {
|
|
329
|
+
constraints.push(`minLength: ${schema.minLength}`);
|
|
330
|
+
}
|
|
331
|
+
if (schema.maxLength !== undefined) {
|
|
332
|
+
constraints.push(`maxLength: ${schema.maxLength}`);
|
|
333
|
+
}
|
|
334
|
+
if (schema.minimum !== undefined) {
|
|
335
|
+
constraints.push(`minimum: ${schema.minimum}`);
|
|
336
|
+
}
|
|
337
|
+
if (schema.maximum !== undefined) {
|
|
338
|
+
constraints.push(`maximum: ${schema.maximum}`);
|
|
339
|
+
}
|
|
340
|
+
if (schema.pattern) {
|
|
341
|
+
constraints.push(`pattern: '${schema.pattern}'`);
|
|
342
|
+
}
|
|
343
|
+
return constraints.join("; ");
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Generate opaque type helpers
|
|
347
|
+
*/
|
|
348
|
+
function generateOpaqueTypeHelpers(typeName) {
|
|
349
|
+
return `
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Opaque type for ${typeName} - completely hides the underlying type
|
|
353
|
+
*/
|
|
354
|
+
declare const __${typeName}Opaque: unique symbol;
|
|
355
|
+
export type Opaque${typeName} = ${typeName} & { readonly [__${typeName}Opaque]: true };
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Create opaque ${typeName}
|
|
359
|
+
*/
|
|
360
|
+
export function createOpaque${typeName}(data: ${typeName}): Opaque${typeName} {
|
|
361
|
+
return data as Opaque${typeName};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Unwrap opaque ${typeName}
|
|
366
|
+
*/
|
|
367
|
+
export function unwrapOpaque${typeName}(data: Opaque${typeName}): ${typeName} {
|
|
368
|
+
return data as ${typeName};
|
|
369
|
+
}`;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Generate phantom types for authentication state management
|
|
373
|
+
*/
|
|
374
|
+
function generatePhantomTypes(typeName) {
|
|
375
|
+
return `
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Phantom types for authentication state management
|
|
379
|
+
*/
|
|
380
|
+
export type AuthState = 'authenticated' | 'unauthenticated';
|
|
381
|
+
|
|
382
|
+
export type ${typeName}WithAuth<TAuth extends AuthState = 'unauthenticated'> =
|
|
383
|
+
Branded${typeName} & { readonly __auth: TAuth };
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Authorize a ${typeName} instance
|
|
387
|
+
*/
|
|
388
|
+
export function authorize${typeName}(
|
|
389
|
+
data: ${typeName}WithAuth<'unauthenticated'>
|
|
390
|
+
): ${typeName}WithAuth<'authenticated'> {
|
|
391
|
+
return data as ${typeName}WithAuth<'authenticated'>;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Remove authorization from ${typeName} instance
|
|
396
|
+
*/
|
|
397
|
+
export function unauthorize${typeName}(
|
|
398
|
+
data: ${typeName}WithAuth<'authenticated'>
|
|
399
|
+
): ${typeName}WithAuth<'unauthenticated'> {
|
|
400
|
+
return data as ${typeName}WithAuth<'unauthenticated'>;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Type guard for authenticated ${typeName}
|
|
405
|
+
*/
|
|
406
|
+
export function isAuthenticated${typeName}(
|
|
407
|
+
value: ${typeName}WithAuth<AuthState>
|
|
408
|
+
): value is ${typeName}WithAuth<'authenticated'> {
|
|
409
|
+
// In practice, this would check actual auth state
|
|
410
|
+
return true; // Placeholder implementation
|
|
411
|
+
}`;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Generate discriminated unions
|
|
415
|
+
*/
|
|
416
|
+
function generateDiscriminatedUnions(typeName) {
|
|
417
|
+
return `
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Discriminated union variants for ${typeName}
|
|
421
|
+
*/
|
|
422
|
+
export type ${typeName}Union =
|
|
423
|
+
| { type: 'valid'; data: Branded${typeName} }
|
|
424
|
+
| { type: 'invalid'; error: string }
|
|
425
|
+
| { type: 'pending'; progress?: number };
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Pattern matching for ${typeName}Union
|
|
429
|
+
*/
|
|
430
|
+
export function match${typeName}<T>(
|
|
431
|
+
union: ${typeName}Union,
|
|
432
|
+
handlers: {
|
|
433
|
+
valid: (data: Branded${typeName}) => T;
|
|
434
|
+
invalid: (error: string) => T;
|
|
435
|
+
pending: (progress?: number) => T;
|
|
436
|
+
}
|
|
437
|
+
): T {
|
|
438
|
+
switch (union.type) {
|
|
439
|
+
case 'valid':
|
|
440
|
+
return handlers.valid(union.data);
|
|
441
|
+
case 'invalid':
|
|
442
|
+
return handlers.invalid(union.error);
|
|
443
|
+
case 'pending':
|
|
444
|
+
return handlers.pending(union.progress);
|
|
445
|
+
default:
|
|
446
|
+
// Exhaustiveness check
|
|
447
|
+
const _exhaustive: never = union;
|
|
448
|
+
throw new Error(\`Unhandled union type: \${JSON.stringify(_exhaustive)}\`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Type guard for ${typeName}Union variants
|
|
454
|
+
*/
|
|
455
|
+
export function is${typeName}Variant<T extends ${typeName}Union['type']>(
|
|
456
|
+
union: ${typeName}Union,
|
|
457
|
+
type: T
|
|
458
|
+
): union is Extract<${typeName}Union, { type: T }> {
|
|
459
|
+
return union.type === type;
|
|
460
|
+
}`;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Generate client integration with branded types
|
|
464
|
+
*/
|
|
465
|
+
function generateClientBrandedTypeIntegration(_generatedClient, options) {
|
|
466
|
+
return `
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Branded type integration for API client
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Type-safe API client with branded type validation
|
|
474
|
+
*/
|
|
475
|
+
export class BrandedApiClient {
|
|
476
|
+
/**
|
|
477
|
+
* Validate and brand response data
|
|
478
|
+
*/
|
|
479
|
+
static validateResponse<T, B extends T & { __brand: any }>(
|
|
480
|
+
data: T,
|
|
481
|
+
validator: (data: T) => B
|
|
482
|
+
): B {
|
|
483
|
+
try {
|
|
484
|
+
return validator(data);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
throw new Error(\`Response validation failed: \${error instanceof Error ? error.message : 'Unknown error'}\`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Wrap request with branded type validation
|
|
492
|
+
*/
|
|
493
|
+
static withBrandValidation<TRequest, TResponse, TBrandedResponse extends TResponse & { __brand: any }>(
|
|
494
|
+
requestFn: (data: TRequest) => Promise<TResponse>,
|
|
495
|
+
responseValidator: (data: TResponse) => TBrandedResponse
|
|
496
|
+
) {
|
|
497
|
+
return async (data: TRequest): Promise<TBrandedResponse> => {
|
|
498
|
+
const response = await requestFn(data);
|
|
499
|
+
return this.validateResponse(response, responseValidator);
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Type-safe wrapper function
|
|
506
|
+
*/
|
|
507
|
+
export function withBrandValidation<T extends (...args: any[]) => Promise<any>, R>(
|
|
508
|
+
fn: T,
|
|
509
|
+
validator: (result: Awaited<ReturnType<T>>) => R
|
|
510
|
+
): (...args: Parameters<T>) => Promise<R> {
|
|
511
|
+
return async (...args: Parameters<T>): Promise<R> => {
|
|
512
|
+
const result = await fn(...args);
|
|
513
|
+
return validator(result);
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
${options.enablePhantomTypes ? generatePhantomApiClient() : ""}`;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Generate phantom type API client integration
|
|
521
|
+
*/
|
|
522
|
+
function generatePhantomApiClient() {
|
|
523
|
+
return `
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* API client with phantom authentication state
|
|
527
|
+
*/
|
|
528
|
+
export class AuthenticatedApiClient {
|
|
529
|
+
private readonly isAuthenticated = true;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Execute authenticated request
|
|
533
|
+
*/
|
|
534
|
+
async executeAuthenticatedRequest<T>(
|
|
535
|
+
request: () => Promise<T>
|
|
536
|
+
): Promise<T> {
|
|
537
|
+
if (!this.isAuthenticated) {
|
|
538
|
+
throw new Error('Client is not authenticated');
|
|
539
|
+
}
|
|
540
|
+
return request();
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export class UnauthenticatedApiClient {
|
|
545
|
+
private readonly isAuthenticated = false;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Execute public request
|
|
549
|
+
*/
|
|
550
|
+
async executePublicRequest<T>(
|
|
551
|
+
request: () => Promise<T>
|
|
552
|
+
): Promise<T> {
|
|
553
|
+
return request();
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Authenticate and return authenticated client
|
|
558
|
+
*/
|
|
559
|
+
async authenticate(credentials: { token: string }): Promise<AuthenticatedApiClient> {
|
|
560
|
+
// Authentication logic would go here
|
|
561
|
+
console.log('Authenticating with token:', credentials.token);
|
|
562
|
+
return new AuthenticatedApiClient();
|
|
563
|
+
}
|
|
564
|
+
}`;
|
|
565
|
+
}
|
|
566
|
+
// Export plugin for registration
|
|
567
|
+
exports.default = exports.brandedTypesPlugin;
|
|
568
|
+
//# sourceMappingURL=branded-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branded-types.js","sourceRoot":"","sources":["../../src/plugins/branded-types.ts"],"names":[],"mappings":";AAAA;;;;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AAQ;UACzB,QAAQ;KACb,QAAQ;mBACM,QAAQ;;;;+BAII,QAAQ;;6BAEV,QAAQ;UAC3B,QAAQ;KACb,QAAQ;mBACM,QAAQ;;;;kCAIO,QAAQ;;iCAET,QAAQ;WAC9B,QAAQ;cACL,QAAQ;;;EAGpB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,2BAA2B,CAAC,QAAgB;IACnD,OAAO;;;sCAG6B,QAAQ;;cAEhC,QAAQ;oCACc,QAAQ;;;;;0BAKlB,QAAQ;;uBAEX,QAAQ;WACpB,QAAQ;;2BAEQ,QAAQ;;;;;;;;;;;;;;;;;;;;oBAoBf,QAAQ;;oBAER,QAAQ,qBAAqB,QAAQ;WAC9C,QAAQ;;sBAEG,QAAQ;;EAE5B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,oCAAoC,CAC3C,gBAAoC,EACpC,OAA4B;IAE5B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDP,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,SAAS,wBAAwB;IAC/B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCP,CAAC;AACH,CAAC;AAED,iCAAiC;AACjC,kBAAe,0BAAkB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in plugins for common transformations and enhancements
|
|
3
|
+
* Provides standard plugins that can be used out of the box
|
|
4
|
+
*/
|
|
5
|
+
import { SchemanticPlugin } from "../types/core";
|
|
6
|
+
/**
|
|
7
|
+
* Built-in plugin for adding JSDoc comments
|
|
8
|
+
*/
|
|
9
|
+
export declare const jsdocPlugin: SchemanticPlugin;
|
|
10
|
+
/**
|
|
11
|
+
* Built-in plugin for adding validation decorators
|
|
12
|
+
*/
|
|
13
|
+
export declare const validationPlugin: SchemanticPlugin;
|
|
14
|
+
/**
|
|
15
|
+
* Built-in plugin for adding React hooks generation
|
|
16
|
+
*/
|
|
17
|
+
export declare const reactHooksPlugin: SchemanticPlugin;
|
|
18
|
+
/**
|
|
19
|
+
* Built-in plugin for adding TypeScript strict mode enhancements
|
|
20
|
+
*/
|
|
21
|
+
export declare const strictModePlugin: SchemanticPlugin;
|
|
22
|
+
/**
|
|
23
|
+
* Get all built-in plugins (including advanced plugins)
|
|
24
|
+
*/
|
|
25
|
+
export declare function getBuiltinPlugins(): SchemanticPlugin[];
|
|
26
|
+
/**
|
|
27
|
+
* Get basic built-in plugins only
|
|
28
|
+
*/
|
|
29
|
+
export declare function getBasicBuiltinPlugins(): SchemanticPlugin[];
|
|
30
|
+
/**
|
|
31
|
+
* Get advanced built-in plugins only
|
|
32
|
+
*/
|
|
33
|
+
export declare function getAdvancedBuiltinPlugins(): SchemanticPlugin[];
|
|
34
|
+
/**
|
|
35
|
+
* Get built-in plugin by name
|
|
36
|
+
*/
|
|
37
|
+
export declare function getBuiltinPlugin(name: string): SchemanticPlugin | undefined;
|
|
38
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/plugins/builtin.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,gBAAgB,EAIjB,MAAM,eAAe,CAAC;AAcvB;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,gBA+CzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAuF9B,CAAC;AAgEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAwB9B,CAAC;AAqBF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,gBAqD9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,gBAAgB,EAAE,CActD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,EAAE,CAE3D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,gBAAgB,EAAE,CAO9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAE3E"}
|