@rexeus/typeweaver-types 0.10.0 → 0.10.1

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.
@@ -1,19 +1,25 @@
1
+ /**
2
+ * This file was automatically generated by typeweaver.
3
+ * DO NOT EDIT. Instead, modify the source definition file and generate again.
4
+ *
5
+ * @generated by @rexeus/typeweaver
6
+ */
1
7
  import { Validator } from "./Validator";
2
8
  /**
3
- * Abstract base class for HTTP request validation.
4
- *
5
- * This class provides the foundation for request validators that:
6
- * - Validate headers, body, query parameters, and path parameters
7
- * - Support both safe (non-throwing) and unsafe (throwing) validation
8
- * - Integrate with Zod schemas for runtime validation
9
- * - Provide detailed error information for debugging
10
- *
11
- * Implementations should validate all request components and either:
12
- * - Return validated data (for `validate`)
13
- * - Return success/error result (for `safeValidate`)
14
- */
9
+ * Abstract base class for HTTP request validation.
10
+ *
11
+ * This class provides the foundation for request validators that:
12
+ * - Validate headers, body, query parameters, and path parameters
13
+ * - Support both safe (non-throwing) and unsafe (throwing) validation
14
+ * - Integrate with Zod schemas for runtime validation
15
+ * - Provide detailed error information for debugging
16
+ *
17
+ * Implementations should validate all request components and either:
18
+ * - Return validated data (for `validate`)
19
+ * - Return success/error result (for `safeValidate`)
20
+ */
15
21
  export class RequestValidator extends Validator {
16
- constructor() {
17
- super();
18
- }
22
+ constructor() {
23
+ super();
24
+ }
19
25
  }
@@ -1,101 +1,102 @@
1
+ /**
2
+ * This file was automatically generated by typeweaver.
3
+ * DO NOT EDIT. Instead, modify the source definition file and generate again.
4
+ *
5
+ * @generated by @rexeus/typeweaver
6
+ */
1
7
  import { ResponseValidationError } from "@rexeus/typeweaver-core";
2
8
  import { Validator } from "./Validator";
3
9
  /**
4
- * Abstract base class for HTTP response validation.
5
- *
6
- * This class provides the foundation for response validators that:
7
- * - Validate response status codes match expected values
8
- * - Validate response headers and body against schemas
9
- * - Support both safe (non-throwing) and unsafe (throwing) validation
10
- * - Integrate with Zod schemas for runtime validation
11
- *
12
- * Response validators are typically used in API clients to ensure
13
- * responses match the expected format before processing.
14
- *
15
- * Subclasses provide response metadata via `responseEntries` and
16
- * `expectedStatusCodes`. All validation logic lives in this base class.
17
- */
10
+ * Abstract base class for HTTP response validation.
11
+ *
12
+ * This class provides the foundation for response validators that:
13
+ * - Validate response status codes match expected values
14
+ * - Validate response headers and body against schemas
15
+ * - Support both safe (non-throwing) and unsafe (throwing) validation
16
+ * - Integrate with Zod schemas for runtime validation
17
+ *
18
+ * Response validators are typically used in API clients to ensure
19
+ * responses match the expected format before processing.
20
+ *
21
+ * Subclasses provide response metadata via `responseEntries` and
22
+ * `expectedStatusCodes`. All validation logic lives in this base class.
23
+ */
18
24
  export class ResponseValidator extends Validator {
19
- /**
20
- * Validates a response without throwing errors.
21
- *
22
- * @param response - The HTTP response to validate
23
- * @returns A result object containing either the validated response or error details
24
- */
25
- safeValidate(response) {
26
- const error = new ResponseValidationError(response.statusCode);
27
- for (const entry of this.responseEntries) {
28
- if (response.statusCode === entry.statusCode) {
29
- const result = this.validateResponseType(entry.name, entry.headerSchema, entry.bodySchema)(response, error);
30
- if (result.isValid) return result;
31
- }
32
- }
33
- if (!error.hasResponseIssues()) {
34
- error.addStatusCodeIssue([...this.expectedStatusCodes]);
35
- }
36
- return {
37
- isValid: false,
38
- error
39
- };
40
- }
41
- /**
42
- * Validates a response and throws if validation fails.
43
- *
44
- * @param response - The HTTP response to validate
45
- * @returns The validated response with proper typing
46
- * @throws {ResponseValidationError} If response structure fails validation
47
- */
48
- validate(response) {
49
- const result = this.safeValidate(response);
50
- if (!result.isValid) throw result.error;
51
- return result.data;
52
- }
53
- /**
54
- * Validates a single response variant against its header and body schemas.
55
- *
56
- * @param responseName - Name of the response type for error reporting
57
- * @param headerSchema - Zod schema for header validation (optional)
58
- * @param bodySchema - Zod schema for body validation (optional)
59
- * @returns Function that validates response and returns result
60
- */
61
- validateResponseType(responseName, headerSchema, bodySchema) {
62
- return (response, error) => {
63
- let isValid = true;
64
- const validatedResponse = {
65
- type: responseName,
66
- statusCode: response.statusCode,
67
- header: undefined,
68
- body: undefined
69
- };
70
- if (bodySchema) {
71
- const validateBodyResult = bodySchema.safeParse(response.body);
72
- if (!validateBodyResult.success) {
73
- error.addBodyIssues(responseName, validateBodyResult.error.issues);
74
- isValid = false;
75
- } else {
76
- validatedResponse.body = validateBodyResult.data;
77
- }
78
- }
79
- if (headerSchema) {
80
- const coercedHeader = this.coerceHeaderToSchema(response.header, this.getSchema(headerSchema));
81
- const validateHeaderResult = headerSchema.safeParse(coercedHeader);
82
- if (!validateHeaderResult.success) {
83
- error.addHeaderIssues(responseName, validateHeaderResult.error.issues);
84
- isValid = false;
85
- } else {
86
- validatedResponse.header = validateHeaderResult.data;
87
- }
88
- }
89
- if (!isValid) {
90
- return {
91
- isValid: false,
92
- error
93
- };
94
- }
95
- return {
96
- isValid: true,
97
- data: validatedResponse
98
- };
99
- };
100
- }
25
+ /**
26
+ * Validates a response without throwing errors.
27
+ *
28
+ * @param response - The HTTP response to validate
29
+ * @returns A result object containing either the validated response or error details
30
+ */
31
+ safeValidate(response) {
32
+ const error = new ResponseValidationError(response.statusCode);
33
+ for (const entry of this.responseEntries) {
34
+ if (response.statusCode === entry.statusCode) {
35
+ const result = this.validateResponseType(entry.name, entry.headerSchema, entry.bodySchema)(response, error);
36
+ if (result.isValid)
37
+ return result;
38
+ }
39
+ }
40
+ if (!error.hasResponseIssues()) {
41
+ error.addStatusCodeIssue([...this.expectedStatusCodes]);
42
+ }
43
+ return { isValid: false, error };
44
+ }
45
+ /**
46
+ * Validates a response and throws if validation fails.
47
+ *
48
+ * @param response - The HTTP response to validate
49
+ * @returns The validated response with proper typing
50
+ * @throws {ResponseValidationError} If response structure fails validation
51
+ */
52
+ validate(response) {
53
+ const result = this.safeValidate(response);
54
+ if (!result.isValid)
55
+ throw result.error;
56
+ return result.data;
57
+ }
58
+ /**
59
+ * Validates a single response variant against its header and body schemas.
60
+ *
61
+ * @param responseName - Name of the response type for error reporting
62
+ * @param headerSchema - Zod schema for header validation (optional)
63
+ * @param bodySchema - Zod schema for body validation (optional)
64
+ * @returns Function that validates response and returns result
65
+ */
66
+ validateResponseType(responseName, headerSchema, bodySchema) {
67
+ return (response, error) => {
68
+ let isValid = true;
69
+ const validatedResponse = {
70
+ type: responseName,
71
+ statusCode: response.statusCode,
72
+ header: undefined,
73
+ body: undefined,
74
+ };
75
+ if (bodySchema) {
76
+ const validateBodyResult = bodySchema.safeParse(response.body);
77
+ if (!validateBodyResult.success) {
78
+ error.addBodyIssues(responseName, validateBodyResult.error.issues);
79
+ isValid = false;
80
+ }
81
+ else {
82
+ validatedResponse.body = validateBodyResult.data;
83
+ }
84
+ }
85
+ if (headerSchema) {
86
+ const coercedHeader = this.coerceHeaderToSchema(response.header, this.getSchema(headerSchema));
87
+ const validateHeaderResult = headerSchema.safeParse(coercedHeader);
88
+ if (!validateHeaderResult.success) {
89
+ error.addHeaderIssues(responseName, validateHeaderResult.error.issues);
90
+ isValid = false;
91
+ }
92
+ else {
93
+ validatedResponse.header = validateHeaderResult.data;
94
+ }
95
+ }
96
+ if (!isValid) {
97
+ return { isValid: false, error };
98
+ }
99
+ return { isValid: true, data: validatedResponse };
100
+ };
101
+ }
101
102
  }
@@ -1,185 +1,198 @@
1
+ /**
2
+ * This file was automatically generated by typeweaver.
3
+ * DO NOT EDIT. Instead, modify the source definition file and generate again.
4
+ *
5
+ * @generated by @rexeus/typeweaver
6
+ */
1
7
  import z from "zod";
2
8
  import { $ZodArray, $ZodOptional } from "zod/v4/core";
3
9
  /**
4
- * Abstract base class for HTTP validation.
5
- *
6
- * This class provides the foundation for request and response validators that:
7
- * - Analyze Zod schemas for correct single/multi value handling of headers and query parameters
8
- * - Coerce objects to match schema expectations
9
- */
10
+ * Abstract base class for HTTP validation.
11
+ *
12
+ * This class provides the foundation for request and response validators that:
13
+ * - Analyze Zod schemas for correct single/multi value handling of headers and query parameters
14
+ * - Coerce objects to match schema expectations
15
+ */
10
16
  export class Validator {
11
- static schemaCacheCaseSensitive = new WeakMap();
12
- static schemaCacheCaseInsensitive = new WeakMap();
13
- /**
14
- * Analyzes a Zod schema shape to create an efficient lookup map.
15
- * Results are cached using WeakMap for optimal performance.
16
- *
17
- * @param shape - The Zod schema shape to analyze
18
- * @param caseSensitive - Whether to preserve key casing (true) or normalize to lowercase (false)
19
- * @returns Map with lookup keys pointing to original key and array type information
20
- */
21
- analyzeSchema(shape, caseSensitive) {
22
- const cache = caseSensitive ? Validator.schemaCacheCaseSensitive : Validator.schemaCacheCaseInsensitive;
23
- const cached = cache.get(shape);
24
- if (cached) {
25
- return cached;
26
- }
27
- const schemaMap = this.buildSchemaMap(shape, caseSensitive);
28
- cache.set(shape, schemaMap);
29
- return schemaMap;
30
- }
31
- /**
32
- *
33
- * Extracts a Zod schema shape from header or query schemas.
34
- * This is used to support schema coercion and analysis.
35
- *
36
- * @param headerSchema
37
- * @returns
38
- */
39
- getSchema(headerSchema) {
40
- if (headerSchema instanceof z.ZodObject) {
41
- return headerSchema.shape;
42
- }
43
- if (headerSchema instanceof z.ZodOptional) {
44
- const unwrapped = headerSchema.unwrap();
45
- if (unwrapped instanceof z.ZodObject) {
46
- return unwrapped.shape;
47
- }
48
- }
49
- return {};
50
- }
51
- /**
52
- * Builds a schema map by analyzing the Zod shape structure.
53
- * Extracts type information for each field to support proper coercion.
54
- */
55
- buildSchemaMap(shape, caseSensitive) {
56
- const schemaMap = new Map();
57
- for (const [key, zodType] of Object.entries(shape)) {
58
- if (!zodType) continue;
59
- const isArray = zodType instanceof $ZodArray || zodType instanceof $ZodOptional && zodType._zod.def.innerType instanceof $ZodArray;
60
- const lookupKey = caseSensitive ? key : key.toLowerCase();
61
- schemaMap.set(lookupKey, {
62
- originalKey: key,
63
- isArray
64
- });
65
- }
66
- return schemaMap;
67
- }
68
- /**
69
- * Coerces objects to match schema expectations with configurable case sensitivity.
70
- * Values not in the schema are ignored.
71
- *
72
- * @param data - The data object to coerce
73
- * @param shape - The Zod schema shape to match against
74
- * @param caseSensitive - Whether keys should match exactly (true) or case-insensitively (false)
75
- * @returns Coerced data object with proper key casing and array coercion
76
- */
77
- coerceToSchema(data, shape, caseSensitive) {
78
- if (typeof data !== "object" || data === null) {
79
- return data;
80
- }
81
- const schemaMap = this.analyzeSchema(shape, caseSensitive);
82
- const coerced = {};
83
- for (const [key, value] of Object.entries(data)) {
84
- const normalizedKey = caseSensitive ? key : key.toLowerCase();
85
- const schemaInfo = schemaMap.get(normalizedKey);
86
- if (schemaInfo) {
87
- this.addValueToCoerced(coerced, normalizedKey, value, schemaInfo.isArray);
88
- }
89
- }
90
- // If case-sensitive, return coerced object as is
91
- if (caseSensitive) {
92
- return coerced;
93
- }
94
- // If case-insensitive, map back to original keys from schema
95
- return this.mapToOriginalKeys(coerced, schemaMap);
96
- }
97
- /**
98
- * Adds a value to the coerced object, handling collisions when multiple
99
- * values exist for the same key (e.g., duplicate headers with different casing).
100
- * Preserves all values as arrays when collisions occur to prevent data loss.
101
- */
102
- addValueToCoerced(coerced, key, value, expectsArray) {
103
- const existing = coerced[key];
104
- const newValue = this.coerceValueStructure(value, expectsArray);
105
- if (existing === undefined) {
106
- coerced[key] = newValue;
107
- return;
108
- }
109
- // Merge existing and new values
110
- const existingArray = Array.isArray(existing) ? existing : [existing];
111
- const newArray = Array.isArray(newValue) ? newValue : [newValue];
112
- const merged = [...existingArray, ...newArray];
113
- // If schema expects a single value but we have multiple, preserve as array
114
- // to avoid data loss (validation will catch this later)
115
- coerced[key] = expectsArray || merged.length > 1 ? merged : merged[0];
116
- }
117
- /**
118
- * Coerces a value's structure to match schema expectations.
119
- * Wraps single values in arrays when schema expects array type,
120
- * unwraps single-element arrays when schema expects single value.
121
- */
122
- coerceValueStructure(value, expectsArray) {
123
- if (expectsArray && !Array.isArray(value)) {
124
- return [value];
125
- }
126
- if (!expectsArray && Array.isArray(value) && value.length === 1) {
127
- return value[0];
128
- }
129
- return value;
130
- }
131
- /**
132
- * Maps normalized (lowercase) keys back to their original casing as defined in the schema.
133
- * Used for case-insensitive matching where the output should preserve schema-defined casing.
134
- */
135
- mapToOriginalKeys(coerced, schemaMap) {
136
- const withOriginalKeys = {};
137
- for (const [key, value] of Object.entries(coerced)) {
138
- const originalKey = schemaMap.get(key)?.originalKey ?? key;
139
- withOriginalKeys[originalKey] = value;
140
- }
141
- return withOriginalKeys;
142
- }
143
- /**
144
- * Coerces header data to match schema expectations with case-insensitive matching.
145
- *
146
- * @param header - The header object to coerce
147
- * @param shape - The Zod schema shape for headers
148
- * @returns Coerced header object
149
- */
150
- coerceHeaderToSchema(header, shape) {
151
- if (typeof header !== "object" || header === null) {
152
- return this.coerceToSchema(header ?? {}, shape, false);
153
- }
154
- const preprocessed = this.splitCommaDelimitedValues(header, shape);
155
- return this.coerceToSchema(preprocessed, shape, false);
156
- }
157
- /**
158
- * Splits comma-separated header strings into arrays per RFC 7230.
159
- * Only applies to fields where the schema expects an array type.
160
- * Values that are already arrays pass through unchanged.
161
- */
162
- splitCommaDelimitedValues(header, shape) {
163
- const schemaMap = this.analyzeSchema(shape, false);
164
- const result = {};
165
- for (const [key, value] of Object.entries(header)) {
166
- const schemaInfo = schemaMap.get(key.toLowerCase());
167
- if (schemaInfo?.isArray && typeof value === "string") {
168
- result[key] = value.split(",").map((v) => v.trim()).filter((v) => v !== "");
169
- } else {
170
- result[key] = value;
171
- }
172
- }
173
- return result;
174
- }
175
- /**
176
- * Coerces query data to match schema expectations with case-sensitive matching.
177
- *
178
- * @param query - The query object to coerce
179
- * @param shape - The Zod schema shape for query parameters
180
- * @returns Coerced query object
181
- */
182
- coerceQueryToSchema(query, shape) {
183
- return this.coerceToSchema(query ?? {}, shape, true);
184
- }
17
+ static schemaCacheCaseSensitive = new WeakMap();
18
+ static schemaCacheCaseInsensitive = new WeakMap();
19
+ /**
20
+ * Analyzes a Zod schema shape to create an efficient lookup map.
21
+ * Results are cached using WeakMap for optimal performance.
22
+ *
23
+ * @param shape - The Zod schema shape to analyze
24
+ * @param caseSensitive - Whether to preserve key casing (true) or normalize to lowercase (false)
25
+ * @returns Map with lookup keys pointing to original key and array type information
26
+ */
27
+ analyzeSchema(shape, caseSensitive) {
28
+ const cache = caseSensitive
29
+ ? Validator.schemaCacheCaseSensitive
30
+ : Validator.schemaCacheCaseInsensitive;
31
+ const cached = cache.get(shape);
32
+ if (cached) {
33
+ return cached;
34
+ }
35
+ const schemaMap = this.buildSchemaMap(shape, caseSensitive);
36
+ cache.set(shape, schemaMap);
37
+ return schemaMap;
38
+ }
39
+ /**
40
+ *
41
+ * Extracts a Zod schema shape from header or query schemas.
42
+ * This is used to support schema coercion and analysis.
43
+ *
44
+ * @param headerSchema
45
+ * @returns
46
+ */
47
+ getSchema(headerSchema) {
48
+ if (headerSchema instanceof z.ZodObject) {
49
+ return headerSchema.shape;
50
+ }
51
+ if (headerSchema instanceof z.ZodOptional) {
52
+ const unwrapped = headerSchema.unwrap();
53
+ if (unwrapped instanceof z.ZodObject) {
54
+ return unwrapped.shape;
55
+ }
56
+ }
57
+ return {};
58
+ }
59
+ /**
60
+ * Builds a schema map by analyzing the Zod shape structure.
61
+ * Extracts type information for each field to support proper coercion.
62
+ */
63
+ buildSchemaMap(shape, caseSensitive) {
64
+ const schemaMap = new Map();
65
+ for (const [key, zodType] of Object.entries(shape)) {
66
+ if (!zodType)
67
+ continue;
68
+ const isArray = zodType instanceof $ZodArray ||
69
+ (zodType instanceof $ZodOptional &&
70
+ zodType._zod.def.innerType instanceof $ZodArray);
71
+ const lookupKey = caseSensitive ? key : key.toLowerCase();
72
+ schemaMap.set(lookupKey, { originalKey: key, isArray });
73
+ }
74
+ return schemaMap;
75
+ }
76
+ /**
77
+ * Coerces objects to match schema expectations with configurable case sensitivity.
78
+ * Values not in the schema are ignored.
79
+ *
80
+ * @param data - The data object to coerce
81
+ * @param shape - The Zod schema shape to match against
82
+ * @param caseSensitive - Whether keys should match exactly (true) or case-insensitively (false)
83
+ * @returns Coerced data object with proper key casing and array coercion
84
+ */
85
+ coerceToSchema(data, shape, caseSensitive) {
86
+ if (typeof data !== "object" || data === null) {
87
+ return data;
88
+ }
89
+ const schemaMap = this.analyzeSchema(shape, caseSensitive);
90
+ const coerced = {};
91
+ for (const [key, value] of Object.entries(data)) {
92
+ const normalizedKey = caseSensitive ? key : key.toLowerCase();
93
+ const schemaInfo = schemaMap.get(normalizedKey);
94
+ if (schemaInfo) {
95
+ this.addValueToCoerced(coerced, normalizedKey, value, schemaInfo.isArray);
96
+ }
97
+ // Headers/params not in schema are ignored (strict validation)
98
+ }
99
+ // If case-sensitive, return coerced object as is
100
+ if (caseSensitive) {
101
+ return coerced;
102
+ }
103
+ // If case-insensitive, map back to original keys from schema
104
+ return this.mapToOriginalKeys(coerced, schemaMap);
105
+ }
106
+ /**
107
+ * Adds a value to the coerced object, handling collisions when multiple
108
+ * values exist for the same key (e.g., duplicate headers with different casing).
109
+ * Preserves all values as arrays when collisions occur to prevent data loss.
110
+ */
111
+ addValueToCoerced(coerced, key, value, expectsArray) {
112
+ const existing = coerced[key];
113
+ const newValue = this.coerceValueStructure(value, expectsArray);
114
+ if (existing === undefined) {
115
+ coerced[key] = newValue;
116
+ return;
117
+ }
118
+ // Merge existing and new values
119
+ const existingArray = Array.isArray(existing) ? existing : [existing];
120
+ const newArray = Array.isArray(newValue) ? newValue : [newValue];
121
+ const merged = [...existingArray, ...newArray];
122
+ // If schema expects a single value but we have multiple, preserve as array
123
+ // to avoid data loss (validation will catch this later)
124
+ coerced[key] = expectsArray || merged.length > 1 ? merged : merged[0];
125
+ }
126
+ /**
127
+ * Coerces a value's structure to match schema expectations.
128
+ * Wraps single values in arrays when schema expects array type,
129
+ * unwraps single-element arrays when schema expects single value.
130
+ */
131
+ coerceValueStructure(value, expectsArray) {
132
+ if (expectsArray && !Array.isArray(value)) {
133
+ return [value];
134
+ }
135
+ if (!expectsArray && Array.isArray(value) && value.length === 1) {
136
+ return value[0];
137
+ }
138
+ return value;
139
+ }
140
+ /**
141
+ * Maps normalized (lowercase) keys back to their original casing as defined in the schema.
142
+ * Used for case-insensitive matching where the output should preserve schema-defined casing.
143
+ */
144
+ mapToOriginalKeys(coerced, schemaMap) {
145
+ const withOriginalKeys = {};
146
+ for (const [key, value] of Object.entries(coerced)) {
147
+ const originalKey = schemaMap.get(key)?.originalKey ?? key;
148
+ withOriginalKeys[originalKey] = value;
149
+ }
150
+ return withOriginalKeys;
151
+ }
152
+ /**
153
+ * Coerces header data to match schema expectations with case-insensitive matching.
154
+ *
155
+ * @param header - The header object to coerce
156
+ * @param shape - The Zod schema shape for headers
157
+ * @returns Coerced header object
158
+ */
159
+ coerceHeaderToSchema(header, shape) {
160
+ if (typeof header !== "object" || header === null) {
161
+ return this.coerceToSchema(header ?? {}, shape, false);
162
+ }
163
+ const preprocessed = this.splitCommaDelimitedValues(header, shape);
164
+ return this.coerceToSchema(preprocessed, shape, false);
165
+ }
166
+ /**
167
+ * Splits comma-separated header strings into arrays per RFC 7230.
168
+ * Only applies to fields where the schema expects an array type.
169
+ * Values that are already arrays pass through unchanged.
170
+ */
171
+ splitCommaDelimitedValues(header, shape) {
172
+ const schemaMap = this.analyzeSchema(shape, false);
173
+ const result = {};
174
+ for (const [key, value] of Object.entries(header)) {
175
+ const schemaInfo = schemaMap.get(key.toLowerCase());
176
+ if (schemaInfo?.isArray && typeof value === "string") {
177
+ result[key] = value
178
+ .split(",")
179
+ .map(v => v.trim())
180
+ .filter(v => v !== "");
181
+ }
182
+ else {
183
+ result[key] = value;
184
+ }
185
+ }
186
+ return result;
187
+ }
188
+ /**
189
+ * Coerces query data to match schema expectations with case-sensitive matching.
190
+ *
191
+ * @param query - The query object to coerce
192
+ * @param shape - The Zod schema shape for query parameters
193
+ * @returns Coerced query object
194
+ */
195
+ coerceQueryToSchema(query, shape) {
196
+ return this.coerceToSchema(query ?? {}, shape, true); // case-sensitive
197
+ }
185
198
  }
@@ -1,14 +1,20 @@
1
+ /**
2
+ * This file was automatically generated by typeweaver.
3
+ * DO NOT EDIT. Instead, modify the source definition file and generate again.
4
+ *
5
+ * @generated by @rexeus/typeweaver
6
+ */
1
7
  export const getOperationDefinition = (spec, resourceName, operationId) => {
2
- const operation = spec.resources[resourceName]?.operations.find((candidate) => candidate.operationId === operationId);
3
- if (operation === undefined) {
4
- throw new Error(`Missing operation definition '${String(resourceName)}.${String(operationId)}'.`);
5
- }
6
- return operation;
8
+ const operation = spec.resources[resourceName]?.operations.find(candidate => candidate.operationId === operationId);
9
+ if (operation === undefined) {
10
+ throw new Error(`Missing operation definition '${String(resourceName)}.${String(operationId)}'.`);
11
+ }
12
+ return operation;
7
13
  };
8
14
  export const getResponseDefinition = (responses, responseName) => {
9
- const response = responses.find((candidate) => candidate.name === responseName);
10
- if (response === undefined) {
11
- throw new Error(`Missing response definition '${String(responseName)}'.`);
12
- }
13
- return response;
15
+ const response = responses.find(candidate => candidate.name === responseName);
16
+ if (response === undefined) {
17
+ throw new Error(`Missing response definition '${String(responseName)}'.`);
18
+ }
19
+ return response;
14
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexeus/typeweaver-types",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Generates request and response types plus validators aligned with your API contract. Powered by Typeweaver 🧵✨",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -47,22 +47,21 @@
47
47
  },
48
48
  "homepage": "https://github.com/rexeus/typeweaver#readme",
49
49
  "peerDependencies": {
50
- "@rexeus/typeweaver-core": "^0.10.0",
51
- "@rexeus/typeweaver-gen": "^0.10.0"
50
+ "@rexeus/typeweaver-core": "^0.10.1",
51
+ "@rexeus/typeweaver-gen": "^0.10.1"
52
52
  },
53
53
  "devDependencies": {
54
- "oxc-transform": "^0.121.0",
55
54
  "test-utils": "file:../test-utils",
56
- "@rexeus/typeweaver-core": "^0.10.0",
57
- "@rexeus/typeweaver-gen": "^0.10.0"
55
+ "@rexeus/typeweaver-gen": "^0.10.1",
56
+ "@rexeus/typeweaver-core": "^0.10.1"
58
57
  },
59
58
  "dependencies": {
60
- "@rexeus/typeweaver-zod-to-ts": "^0.10.0"
59
+ "@rexeus/typeweaver-zod-to-ts": "^0.10.1"
61
60
  },
62
61
  "scripts": {
63
62
  "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
64
63
  "format": "oxfmt",
65
- "build": "tsdown && mkdir -p ./dist/templates ./dist/lib && cp -r ./src/templates/* ./dist/templates/ && node scripts/compile-lib.mjs && cp src/lib-declarations/*.d.ts dist/lib/ && cp src/lib/index.ts dist/lib/ && cp ../../LICENSE ../../NOTICE ./dist/",
64
+ "build": "tsdown",
66
65
  "test": "vitest --run",
67
66
  "preversion": "npm run build"
68
67
  }