@hey-api/openapi-ts 0.78.1 → 0.78.2

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/dist/index.d.cts CHANGED
@@ -1,7 +1,348 @@
1
- import { P as PluginHandler, a as Plugin, S as StringCase, U as UserConfig, C as Client, I as IR } from './types.d-DtZlpeRE.cjs';
2
- export { h as Client, D as DefinePlugin, L as LegacyIR, O as OpenApi, b as OpenApiMetaObject, c as OpenApiOperationObject, d as OpenApiParameterObject, e as OpenApiRequestBodyObject, f as OpenApiResponseObject, g as OpenApiSchemaObject } from './types.d-DtZlpeRE.cjs';
1
+ import { C as Comments, I as ImportExportItemObject, t as tsNodeToString, s as stringToTsNodes, P as PluginHandler, a as Plugin, S as StringCase, U as UserConfig, b as Client, c as IR } from './types.d-CaH9PF-K.cjs';
2
+ export { j as Client, D as DefinePlugin, E as ExpressionTransformer, L as LegacyIR, O as OpenApi, d as OpenApiMetaObject, e as OpenApiOperationObject, f as OpenApiParameterObject, g as OpenApiRequestBodyObject, h as OpenApiResponseObject, i as OpenApiSchemaObject } from './types.d-CaH9PF-K.cjs';
3
+ import * as ts from 'typescript';
4
+ import ts__default from 'typescript';
3
5
  import 'node:fs';
4
- import 'typescript';
6
+
7
+ type AccessLevel = 'private' | 'protected' | 'public';
8
+ type FunctionParameter = {
9
+ accessLevel?: AccessLevel;
10
+ default?: any;
11
+ isReadOnly?: boolean;
12
+ isRequired?: boolean;
13
+ name: string;
14
+ type?: any | ts__default.TypeNode;
15
+ } | {
16
+ destructure: ReadonlyArray<FunctionParameter>;
17
+ type?: any | ts__default.TypeNode;
18
+ };
19
+ interface FunctionTypeParameter {
20
+ default?: any;
21
+ extends?: string | ts__default.TypeNode;
22
+ name: string | ts__default.Identifier;
23
+ }
24
+ type SyntaxKindKeyword = 'any' | 'async' | 'boolean' | 'export' | 'never' | 'number' | 'private' | 'protected' | 'public' | 'readonly' | 'static' | 'string' | 'undefined' | 'unknown' | 'void';
25
+ type ObjectValue = {
26
+ assertion?: 'any' | ts__default.TypeNode;
27
+ comments?: Comments;
28
+ spread: string;
29
+ } | {
30
+ comments?: Comments;
31
+ isValueAccess?: boolean;
32
+ key: string;
33
+ shorthand?: boolean;
34
+ value: any;
35
+ };
36
+
37
+ type ImportExportItem = ImportExportItemObject | string;
38
+
39
+ type Property = {
40
+ comment?: Comments;
41
+ isReadOnly?: boolean;
42
+ isRequired?: boolean;
43
+ name: string | ts__default.PropertyName;
44
+ type: any | ts__default.TypeNode;
45
+ };
46
+
47
+ declare const compiler: {
48
+ anonymousFunction: ({ async, comment, multiLine, parameters, returnType, statements, types, }: {
49
+ async?: boolean;
50
+ comment?: Comments;
51
+ multiLine?: boolean;
52
+ parameters?: FunctionParameter[];
53
+ returnType?: string | ts.TypeNode;
54
+ statements?: ts.Statement[];
55
+ types?: FunctionTypeParameter[];
56
+ }) => ts.FunctionExpression;
57
+ arrayLiteralExpression: <T>({ elements, multiLine, }: {
58
+ elements: T[];
59
+ multiLine?: boolean;
60
+ }) => ts.ArrayLiteralExpression;
61
+ arrowFunction: ({ async, comment, multiLine, parameters, returnType, statements, types, }: {
62
+ async?: boolean;
63
+ comment?: Comments;
64
+ multiLine?: boolean;
65
+ parameters?: ReadonlyArray<FunctionParameter>;
66
+ returnType?: string | ts.TypeNode;
67
+ statements?: ts.Statement[] | ts.Expression;
68
+ types?: FunctionTypeParameter[];
69
+ }) => ts.ArrowFunction;
70
+ asExpression: ({ expression, type, }: {
71
+ expression: ts.Expression;
72
+ type: ts.TypeNode;
73
+ }) => ts.AsExpression;
74
+ assignment: ({ left, right, }: {
75
+ left: ts.Expression;
76
+ right: ts.Expression;
77
+ }) => ts.AssignmentExpression<ts.EqualsToken>;
78
+ awaitExpression: ({ expression, }: {
79
+ expression: ts.Expression;
80
+ }) => ts.AwaitExpression;
81
+ binaryExpression: ({ left, operator, right, }: {
82
+ left: ts.Expression;
83
+ operator?: "=" | "===" | "in" | "??";
84
+ right: ts.Expression | string;
85
+ }) => ts.BinaryExpression;
86
+ block: ({ multiLine, statements, }: {
87
+ multiLine?: boolean;
88
+ statements: Array<ts.Statement>;
89
+ }) => ts.Block;
90
+ callExpression: ({ functionName, parameters, types, }: {
91
+ functionName: string | ts.PropertyAccessExpression | ts.PropertyAccessChain | ts.ElementAccessExpression | ts.Expression;
92
+ parameters?: Array<string | ts.Expression | undefined>;
93
+ types?: ReadonlyArray<ts.TypeNode>;
94
+ }) => ts.CallExpression;
95
+ classDeclaration: ({ decorator, exportClass, extendedClasses, name, nodes, }: {
96
+ decorator?: {
97
+ args: any[];
98
+ name: string;
99
+ };
100
+ exportClass?: boolean;
101
+ extendedClasses?: ReadonlyArray<string>;
102
+ name: string;
103
+ nodes: ReadonlyArray<ts.ClassElement>;
104
+ }) => ts.ClassDeclaration;
105
+ conditionalExpression: ({ condition, whenFalse, whenTrue, }: {
106
+ condition: ts.Expression;
107
+ whenFalse: ts.Expression;
108
+ whenTrue: ts.Expression;
109
+ }) => ts.ConditionalExpression;
110
+ constVariable: ({ assertion, comment, destructure, exportConst, expression, name, typeName, }: {
111
+ assertion?: "const" | ts.TypeNode;
112
+ comment?: Comments;
113
+ destructure?: boolean;
114
+ exportConst?: boolean;
115
+ expression: ts.Expression;
116
+ name: string;
117
+ typeName?: string | ts.IndexedAccessTypeNode | ts.TypeNode;
118
+ }) => ts.VariableStatement;
119
+ constructorDeclaration: ({ accessLevel, comment, multiLine, parameters, statements, }: {
120
+ accessLevel?: AccessLevel;
121
+ comment?: Comments;
122
+ multiLine?: boolean;
123
+ parameters?: FunctionParameter[];
124
+ statements?: ts.Statement[];
125
+ }) => ts.ConstructorDeclaration;
126
+ enumDeclaration: <T extends Record<string, any> | Array<ObjectValue>>({ comments: enumMemberComments, leadingComment: comments, name, obj, }: {
127
+ comments?: Record<string | number, Comments>;
128
+ leadingComment?: Comments;
129
+ name: string;
130
+ obj: T;
131
+ }) => ts.EnumDeclaration;
132
+ exportAllDeclaration: ({ module, }: {
133
+ module: string;
134
+ }) => ts.ExportDeclaration;
135
+ exportNamedDeclaration: ({ exports, module, }: {
136
+ exports: Array<ImportExportItem> | ImportExportItem;
137
+ module: string;
138
+ }) => ts.ExportDeclaration;
139
+ expressionToStatement: ({ expression, }: {
140
+ expression: ts.Expression;
141
+ }) => ts.ExpressionStatement;
142
+ forOfStatement: ({ awaitModifier, expression, initializer, statement, }: {
143
+ awaitModifier?: ts.AwaitKeyword;
144
+ expression: ts.Expression;
145
+ initializer: ts.ForInitializer;
146
+ statement: ts.Statement;
147
+ }) => ts.ForOfStatement;
148
+ functionTypeNode: ({ parameters, returnType, typeParameters, }: {
149
+ parameters?: ts.ParameterDeclaration[];
150
+ returnType: ts.TypeNode;
151
+ typeParameters?: ts.TypeParameterDeclaration[];
152
+ }) => ts.FunctionTypeNode;
153
+ identifier: ({ text }: {
154
+ text: string;
155
+ }) => ts.Identifier;
156
+ ifStatement: ({ elseStatement, expression, thenStatement, }: {
157
+ elseStatement?: ts.Statement;
158
+ expression: ts.Expression;
159
+ thenStatement: ts.Statement;
160
+ }) => ts.IfStatement;
161
+ indexedAccessTypeNode: ({ indexType, objectType, }: {
162
+ indexType: ts.TypeNode;
163
+ objectType: ts.TypeNode;
164
+ }) => ts.IndexedAccessTypeNode;
165
+ isTsNode: (node: any) => node is ts.Expression;
166
+ keywordTypeNode: ({ keyword, }: {
167
+ keyword: Extract<SyntaxKindKeyword, "any" | "boolean" | "never" | "number" | "string" | "undefined" | "unknown" | "void">;
168
+ }) => ts.KeywordTypeNode<ts.SyntaxKind.VoidKeyword | ts.SyntaxKind.AnyKeyword | ts.SyntaxKind.BooleanKeyword | ts.SyntaxKind.NeverKeyword | ts.SyntaxKind.NumberKeyword | ts.SyntaxKind.StringKeyword | ts.SyntaxKind.UndefinedKeyword | ts.SyntaxKind.UnknownKeyword>;
169
+ literalTypeNode: ({ literal, }: {
170
+ literal: ts.LiteralTypeNode["literal"];
171
+ }) => ts.LiteralTypeNode;
172
+ mappedTypeNode: ({ members, nameType, questionToken, readonlyToken, type, typeParameter, }: {
173
+ members?: ts.NodeArray<ts.TypeElement>;
174
+ nameType?: ts.TypeNode;
175
+ questionToken?: ts.QuestionToken | ts.PlusToken | ts.MinusToken;
176
+ readonlyToken?: ts.ReadonlyKeyword | ts.PlusToken | ts.MinusToken;
177
+ type?: ts.TypeNode;
178
+ typeParameter: ts.TypeParameterDeclaration;
179
+ }) => ts.MappedTypeNode;
180
+ methodDeclaration: ({ accessLevel, comment, isStatic, multiLine, name, parameters, returnType, statements, types, }: {
181
+ accessLevel?: AccessLevel;
182
+ comment?: Comments;
183
+ isStatic?: boolean;
184
+ multiLine?: boolean;
185
+ name: string;
186
+ parameters?: ReadonlyArray<FunctionParameter>;
187
+ returnType?: string | ts.TypeNode;
188
+ statements?: ts.Statement[];
189
+ types?: FunctionTypeParameter[];
190
+ }) => ts.MethodDeclaration;
191
+ namedImportDeclarations: ({ imports, module, }: {
192
+ imports: Array<ImportExportItem> | ImportExportItem;
193
+ module: string;
194
+ }) => ts.ImportDeclaration;
195
+ namespaceDeclaration: ({ name, statements, }: {
196
+ name: string;
197
+ statements: Array<ts.Statement>;
198
+ }) => ts.ModuleDeclaration;
199
+ newExpression: ({ argumentsArray, expression, typeArguments, }: {
200
+ argumentsArray?: Array<ts.Expression>;
201
+ expression: ts.Expression;
202
+ typeArguments?: Array<ts.TypeNode>;
203
+ }) => ts.NewExpression;
204
+ nodeToString: typeof tsNodeToString;
205
+ null: () => ts.NullLiteral;
206
+ objectExpression: <T extends Record<string, any> | Array<ObjectValue>>({ comments, identifiers, multiLine, obj, shorthand, unescape, }: {
207
+ comments?: Comments;
208
+ identifiers?: string[];
209
+ multiLine?: boolean;
210
+ obj: T;
211
+ shorthand?: boolean;
212
+ unescape?: boolean;
213
+ }) => ts.ObjectLiteralExpression;
214
+ ots: {
215
+ boolean: (value: boolean) => ts.TrueLiteral | ts.FalseLiteral;
216
+ export: ({ alias, asType, name }: ImportExportItemObject) => ts.ExportSpecifier;
217
+ import: ({ alias, asType, name }: ImportExportItemObject) => ts.ImportSpecifier;
218
+ number: (value: number) => ts.NumericLiteral | ts.PrefixUnaryExpression;
219
+ string: (value: string, unescape?: boolean) => ts.Identifier | ts.StringLiteral;
220
+ };
221
+ parameterDeclaration: ({ initializer, modifiers, name, required, type, }: {
222
+ initializer?: ts.Expression;
223
+ modifiers?: ReadonlyArray<ts.ModifierLike>;
224
+ name: string | ts.BindingName;
225
+ required?: boolean;
226
+ type?: ts.TypeNode;
227
+ }) => ts.ParameterDeclaration;
228
+ propertyAccessExpression: ({ expression, isOptional, name, }: {
229
+ expression: string | ts.Expression;
230
+ isOptional?: boolean;
231
+ name: string | number | ts.MemberName;
232
+ }) => ts.PropertyAccessChain | ts.PropertyAccessExpression | ts.ElementAccessExpression;
233
+ propertyAccessExpressions: ({ expressions, }: {
234
+ expressions: Array<string | ts.Expression | ts.MemberName>;
235
+ }) => ts.PropertyAccessExpression;
236
+ propertyAssignment: ({ initializer, name, }: {
237
+ initializer: ts.Expression;
238
+ name: string | ts.PropertyName;
239
+ }) => ts.PropertyAssignment;
240
+ propertyDeclaration: ({ initializer, modifier, name, type, }: {
241
+ initializer?: ts.Expression;
242
+ modifier?: AccessLevel | "async" | "export" | "readonly" | "static";
243
+ name: string | ts.PropertyName;
244
+ type?: ts.TypeNode;
245
+ }) => ts.PropertyDeclaration;
246
+ regularExpressionLiteral: ({ flags, text, }: {
247
+ flags?: ReadonlyArray<"g" | "i" | "m" | "s" | "u" | "y">;
248
+ text: string;
249
+ }) => ts.RegularExpressionLiteral;
250
+ returnFunctionCall: ({ args, name, types, }: {
251
+ args: any[];
252
+ name: string | ts.Expression;
253
+ types?: ReadonlyArray<string | ts.StringLiteral>;
254
+ }) => ts.ReturnStatement;
255
+ returnStatement: ({ expression, }: {
256
+ expression?: ts.Expression;
257
+ }) => ts.ReturnStatement;
258
+ returnVariable: ({ expression, }: {
259
+ expression: string | ts.Expression;
260
+ }) => ts.ReturnStatement;
261
+ safeAccessExpression: (path: string[]) => ts.Expression;
262
+ stringLiteral: ({ isSingleQuote, text, }: {
263
+ isSingleQuote?: boolean;
264
+ text: string;
265
+ }) => ts.StringLiteral;
266
+ stringToTsNodes: typeof stringToTsNodes;
267
+ templateLiteralType: ({ value, }: {
268
+ value: ReadonlyArray<string | ts.TypeNode>;
269
+ }) => ts.TemplateLiteralTypeNode;
270
+ this: () => ts.ThisExpression;
271
+ transformArrayMap: ({ path, transformExpression, }: {
272
+ path: string[];
273
+ transformExpression: ts.Expression;
274
+ }) => ts.IfStatement;
275
+ transformArrayMutation: ({ path, transformerName, }: {
276
+ path: string[];
277
+ transformerName: string;
278
+ }) => ts.Statement;
279
+ transformDateMutation: ({ path, }: {
280
+ path: string[];
281
+ }) => ts.Statement;
282
+ transformFunctionMutation: ({ path, transformerName, }: {
283
+ path: string[];
284
+ transformerName: string;
285
+ }) => ts.IfStatement[];
286
+ transformNewDate: ({ parameterName, }: {
287
+ parameterName: string;
288
+ }) => ts.NewExpression;
289
+ typeAliasDeclaration: ({ comment, exportType, name, type, typeParameters, }: {
290
+ comment?: Comments;
291
+ exportType?: boolean;
292
+ name: string;
293
+ type: string | ts.TypeNode;
294
+ typeParameters?: FunctionTypeParameter[];
295
+ }) => ts.TypeAliasDeclaration;
296
+ typeArrayNode: (types: (any | ts.TypeNode)[] | ts.TypeNode | string, isNullable?: boolean) => ts.TypeNode;
297
+ typeInterfaceNode: ({ indexKey, indexProperty, isNullable, properties, useLegacyResolution, }: {
298
+ indexKey?: string;
299
+ indexProperty?: Property;
300
+ isNullable?: boolean;
301
+ properties: Property[];
302
+ useLegacyResolution: boolean;
303
+ }) => ts.TypeNode;
304
+ typeIntersectionNode: ({ isNullable, types, }: {
305
+ isNullable?: boolean;
306
+ types: (any | ts.TypeNode)[];
307
+ }) => ts.TypeNode;
308
+ typeNode: (base: any | ts.TypeNode, args?: (any | ts.TypeNode)[]) => ts.TypeNode;
309
+ typeOfExpression: ({ text }: {
310
+ text: string;
311
+ }) => ts.TypeOfExpression;
312
+ typeOperatorNode: ({ operator, type, }: {
313
+ operator: "keyof" | "readonly" | "unique";
314
+ type: ts.TypeNode;
315
+ }) => ts.TypeOperatorNode;
316
+ typeParameterDeclaration: ({ constraint, defaultType, modifiers, name, }: {
317
+ constraint?: ts.TypeNode;
318
+ defaultType?: ts.TypeNode;
319
+ modifiers?: Array<ts.Modifier>;
320
+ name: string | ts.Identifier;
321
+ }) => ts.TypeParameterDeclaration;
322
+ typeParenthesizedNode: ({ type, }: {
323
+ type: ts.TypeNode;
324
+ }) => ts.ParenthesizedTypeNode;
325
+ typeRecordNode: (keys: (any | ts.TypeNode)[], values: (any | ts.TypeNode)[], isNullable?: boolean, useLegacyResolution?: boolean) => ts.TypeNode;
326
+ typeReferenceNode: ({ typeArguments, typeName, }: {
327
+ typeArguments?: ts.TypeNode[];
328
+ typeName: string | ts.EntityName;
329
+ }) => ts.TypeReferenceNode;
330
+ typeTupleNode: ({ isNullable, types, }: {
331
+ isNullable?: boolean;
332
+ types: Array<any | ts.TypeNode>;
333
+ }) => ts.TypeNode;
334
+ typeUnionNode: ({ isNullable, types, }: {
335
+ isNullable?: boolean;
336
+ types: (any | ts.TypeNode)[];
337
+ }) => ts.TypeNode;
338
+ valueToExpression: <T = unknown>({ identifiers, isValueAccess, shorthand, unescape, value, }: {
339
+ identifiers?: string[];
340
+ isValueAccess?: boolean;
341
+ shorthand?: boolean;
342
+ unescape?: boolean;
343
+ value: T;
344
+ }) => ts.Expression | undefined;
345
+ };
5
346
 
6
347
  declare const defaultPaginationKeywords: readonly ["after", "before", "cursor", "offset", "page", "start"];
7
348
 
@@ -53,4 +394,4 @@ declare const createClient: (userConfig?: Configs) => Promise<ReadonlyArray<Clie
53
394
  */
54
395
  declare const defineConfig: (config: Configs) => Promise<UserConfig>;
55
396
 
56
- export { IR, Plugin, UserConfig, clientDefaultConfig, clientDefaultMeta, clientPluginHandler, createClient, defaultPaginationKeywords, defaultPlugins, defineConfig, definePluginConfig, utils };
397
+ export { IR, Plugin, UserConfig, clientDefaultConfig, clientDefaultMeta, clientPluginHandler, compiler, createClient, defaultPaginationKeywords, defaultPlugins, defineConfig, definePluginConfig, utils };