@sebspark/openapi-core 0.1.0 → 1.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/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosError } from 'axios';
2
+ import { RetrySettings } from '@sebspark/retry';
2
3
  import { Request, Response, NextFunction } from 'express';
3
4
 
4
5
  type ClientErrorCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
@@ -140,13 +141,30 @@ declare class NetworkAuthenticationRequiredError extends HttpError {
140
141
  declare const createHttpError: (statusCode: ErrorCode, message?: string, internalError?: Error) => HttpError;
141
142
  declare const fromAxiosError: (axiosError: AxiosError) => HttpError;
142
143
 
144
+ type Empty = Record<never, never>;
145
+ type Serialized<T> = {
146
+ [P in keyof T]: T[P] extends Date ? string : T[P] extends Array<infer U> ? Array<Serialized<U>> : T[P] extends (...args: any) => any ? T[P] : T[P] extends object ? Serialized<T[P]> : T[P];
147
+ };
148
+ type PartiallySerialized<T> = T | Serialized<T>;
149
+
143
150
  type Verb = 'get' | 'post' | 'put' | 'patch' | 'delete';
151
+ type APIResponse<Data = undefined, Headers = undefined> = Data extends undefined ? Headers extends undefined ? Empty : {
152
+ headers: Headers;
153
+ } : Headers extends undefined ? {
154
+ data: Data;
155
+ } : {
156
+ data: Data;
157
+ headers: Headers;
158
+ };
144
159
  type GenericRouteHandler = (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
145
160
  type RouteHandler = {
146
161
  pre?: GenericRouteHandler | GenericRouteHandler[];
147
- handler: <A = any, R = any>(arg?: A) => Promise<R>;
162
+ handler: <RequestArgs, Response extends [
163
+ number,
164
+ APIResponse<unknown | undefined, Record<string, string> | undefined>
165
+ ]>(args?: RequestArgs) => Promise<Response>;
148
166
  };
149
- type Route<R extends RouteHandler = RouteHandler> = Record<Verb, R>;
167
+ type Route<Handler extends RouteHandler = RouteHandler> = Record<Verb, Handler>;
150
168
  type APIServerDefinition = Record<string, Partial<Route>>;
151
169
  type APIServerOptions = {
152
170
  pre?: GenericRouteHandler | GenericRouteHandler[];
@@ -159,23 +177,536 @@ type RequestArgs = Request & {
159
177
  type PayloadRequestArgs = RequestArgs & {
160
178
  body?: Record<string, string>;
161
179
  };
162
- type RetryConditionFunction = (error: any) => boolean;
163
- interface RetrySettings {
164
- maxRetries: number;
165
- interval: (retryCount: number) => number;
166
- retryCondition?: RetryConditionFunction;
167
- maxDelay?: number;
168
- }
169
180
  type RequestOptions = {
170
181
  retry: RetrySettings;
171
182
  };
172
183
  type ClientOptions = RequestOptions & {};
173
184
  type BaseClient = {
174
- get: <U extends string, A extends RequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
175
- post: <U extends string, A extends PayloadRequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
176
- put: <U extends string, A extends PayloadRequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
177
- patch: <U extends string, A extends PayloadRequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
178
- delete: <U extends string, A extends RequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
185
+ get: <U extends string, A extends RequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
186
+ post: <U extends string, A extends PayloadRequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
187
+ put: <U extends string, A extends PayloadRequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
188
+ patch: <U extends string, A extends PayloadRequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
189
+ delete: <U extends string, A extends RequestArgs | never, R extends APIResponse<unknown, unknown>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
190
+ };
191
+
192
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
193
+ type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
194
+ type SchemaEnum = string[] | number[] | boolean[];
195
+ type DefaultValue = string | number | boolean | any[] | any;
196
+ type Example = any;
197
+ type ExampleObject = {
198
+ summary?: string;
199
+ description?: string;
200
+ value?: Example;
201
+ externalValue?: string;
202
+ };
203
+ type SchemaObject = {
204
+ title?: string;
205
+ multipleOf?: number;
206
+ maximum?: number;
207
+ exclusiveMaximum?: boolean;
208
+ minimum?: number;
209
+ exclusiveMinimum?: boolean;
210
+ maxLength?: number;
211
+ minLength?: number;
212
+ pattern?: string;
213
+ maxItems?: number;
214
+ minItems?: number;
215
+ uniqueItems?: boolean;
216
+ maxProperties?: number;
217
+ minProperties?: number;
218
+ required?: string[];
219
+ enum?: SchemaEnum;
220
+ type?: SchemaType | SchemaType[];
221
+ allOf?: (SchemaObject | ReferenceObject)[];
222
+ oneOf?: (SchemaObject | ReferenceObject)[];
223
+ anyOf?: (SchemaObject | ReferenceObject)[];
224
+ not?: SchemaObject | ReferenceObject;
225
+ items?: SchemaObject | ReferenceObject;
226
+ properties?: Record<string, SchemaObject | ReferenceObject>;
227
+ additionalProperties?: boolean | SchemaObject | ReferenceObject;
228
+ description?: string;
229
+ format?: string;
230
+ default?: DefaultValue;
231
+ nullable?: boolean;
232
+ discriminator?: DiscriminatorObject;
233
+ readOnly?: boolean;
234
+ writeOnly?: boolean;
235
+ xml?: XMLObject;
236
+ externalDocs?: ExternalDocumentationObject;
237
+ example?: Example;
238
+ deprecated?: boolean;
239
+ };
240
+ type XMLObject = {
241
+ name?: string;
242
+ namespace?: string;
243
+ prefix?: string;
244
+ attribute?: boolean;
245
+ wrapped?: boolean;
246
+ };
247
+ type ParameterIn = 'query' | 'header' | 'path' | 'cookie';
248
+ type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
249
+ type ParameterObject = {
250
+ name: string;
251
+ in: ParameterIn;
252
+ description?: string;
253
+ required?: boolean;
254
+ deprecated?: boolean;
255
+ allowEmptyValue?: boolean;
256
+ style?: ParameterStyle;
257
+ explode?: boolean;
258
+ allowReserved?: boolean;
259
+ schema?: SchemaObject | ReferenceObject;
260
+ example?: Example;
261
+ examples?: Record<string, ExampleObject | ReferenceObject>;
262
+ content?: Record<string, MediaTypeObject>;
263
+ };
264
+ type MediaTypeObject = {
265
+ schema?: SchemaObject | ReferenceObject;
266
+ example?: Example;
267
+ examples?: Record<string, ExampleObject | ReferenceObject>;
268
+ encoding?: Record<string, EncodingObject>;
269
+ };
270
+ type EncodingObject = {
271
+ contentType?: string;
272
+ headers?: Record<string, HeaderObject | ReferenceObject>;
273
+ style?: string;
274
+ explode?: boolean;
275
+ allowReserved?: boolean;
276
+ };
277
+ type HeaderStyle = 'simple';
278
+ type HeaderObject = {
279
+ description?: string;
280
+ required?: boolean;
281
+ deprecated?: boolean;
282
+ allowEmptyValue?: boolean;
283
+ style?: HeaderStyle;
284
+ explode?: boolean;
285
+ allowReserved?: boolean;
286
+ schema?: SchemaObject | ReferenceObject;
287
+ example?: Example;
288
+ examples?: Record<string, ExampleObject | ReferenceObject>;
289
+ content?: Record<string, MediaTypeObject>;
290
+ };
291
+ type DiscriminatorObject = {
292
+ propertyName: string;
293
+ mapping?: Record<string, string>;
294
+ };
295
+ type ReferenceObject = {
296
+ $ref: string;
297
+ };
298
+ type InfoObject = {
299
+ title: string;
300
+ summary?: string;
301
+ description?: string;
302
+ termsOfService?: string;
303
+ contact?: ContactObject;
304
+ license?: LicenseObject;
305
+ version: string;
306
+ };
307
+ type ContactObject = {
308
+ name?: string;
309
+ url?: string;
310
+ email?: string;
311
+ };
312
+ type LicenseObject = {
313
+ name: string;
314
+ url?: string;
315
+ };
316
+ type ServerObject = {
317
+ url: string;
318
+ description?: string;
319
+ variables?: Record<string, ServerVariableObject>;
320
+ };
321
+ type ServerVariableObject = {
322
+ default: string;
323
+ enum?: string[];
324
+ description?: string;
325
+ };
326
+ type TagObject = {
327
+ name: string;
328
+ description?: string;
329
+ externalDocs?: ExternalDocumentationObject;
330
+ };
331
+ type ExternalDocumentationObject = {
332
+ description?: string;
333
+ url: string;
334
+ };
335
+ type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
336
+ type SecuritySchemeObject = {
337
+ type: SecuritySchemeType;
338
+ description?: string;
339
+ name?: string;
340
+ in?: ParameterIn;
341
+ scheme?: string;
342
+ bearerFormat?: string;
343
+ flows?: OAuthFlowsObject;
344
+ openIdConnectUrl?: string;
345
+ };
346
+ type OAuthFlowsObject = {
347
+ implicit?: OAuthFlowObject;
348
+ password?: OAuthFlowObject;
349
+ clientCredentials?: OAuthFlowObject;
350
+ authorizationCode?: OAuthFlowObject;
351
+ };
352
+ type OAuthFlowObject = {
353
+ authorizationUrl?: string;
354
+ tokenUrl?: string;
355
+ refreshUrl?: string;
356
+ scopes: Record<string, string>;
357
+ };
358
+
359
+ type ChannelBindingsObject = {
360
+ http?: HttpChannelBindingObject;
361
+ ws?: WebSocketChannelBindingObject;
362
+ kafka?: KafkaChannelBindingObject;
363
+ redis?: RedisChannelBindingObject;
364
+ rabbitmq?: RabbitMQChannelBindingObject;
365
+ googlepubsub?: GooglePubSubChannelBindingObject;
366
+ };
367
+ type HttpChannelBindingObject = {
368
+ type: string;
369
+ method: string;
370
+ query: SchemaObject | ReferenceObject;
371
+ bindingVersion?: string;
372
+ };
373
+ type WebSocketChannelBindingObject = {
374
+ type: string;
375
+ method: string;
376
+ query: SchemaObject | ReferenceObject;
377
+ headers: SchemaObject | ReferenceObject;
378
+ bindingVersion?: string;
379
+ };
380
+ type KafkaChannelBindingObject = {
381
+ groupId?: SchemaObject | ReferenceObject;
382
+ clientId?: SchemaObject | ReferenceObject;
383
+ bindingVersion?: string;
384
+ };
385
+ type RedisChannelBindingObject = {
386
+ type: string;
387
+ method: string;
388
+ query: SchemaObject | ReferenceObject;
389
+ bindingVersion?: string;
390
+ };
391
+ type RabbitMQChannelBindingObject = {
392
+ is: string;
393
+ exchange: {
394
+ name: string;
395
+ type: string;
396
+ durable: boolean;
397
+ autoDelete: boolean;
398
+ vhost: string;
399
+ };
400
+ queue: {
401
+ name: string;
402
+ durable: boolean;
403
+ exclusive: boolean;
404
+ autoDelete: boolean;
405
+ vhost: string;
406
+ };
407
+ bindingVersion?: string;
408
+ };
409
+ type GooglePubSubChannelBindingObject = {
410
+ topic: {
411
+ name: string;
412
+ };
413
+ subscription: {
414
+ name: string;
415
+ };
416
+ bindingVersion?: string;
417
+ };
418
+ type OperationBindingsObject = {
419
+ ws?: WebSocketOperationBindingObject;
420
+ http?: HttpOperationBindingObject;
421
+ kafka?: KafkaOperationBindingObject;
422
+ redis?: RedisOperationBindingObject;
423
+ rabbitmq?: RabbitMQOperationBindingObject;
424
+ googlepubsub?: GooglePubSubOperationBindingObject;
425
+ };
426
+ type OperationType = 'publish' | 'subscribe';
427
+ type MessageFormat = 'json' | 'xml' | 'text' | 'binary';
428
+ type WebSocketOperationBindingObject = {
429
+ type?: OperationType;
430
+ method?: 'GET';
431
+ query?: SchemaObject | ReferenceObject;
432
+ headers?: SchemaObject | ReferenceObject;
433
+ messageFormat?: MessageFormat;
434
+ persistent?: boolean;
435
+ bindingVersion?: string;
436
+ };
437
+ type HttpOperationBindingObject = {
438
+ type: 'request' | 'response';
439
+ method: HttpMethod;
440
+ query?: SchemaObject | ReferenceObject;
441
+ bindingVersion?: string;
442
+ };
443
+ type KafkaOperationBindingObject = {
444
+ groupId?: {
445
+ type: 'string';
446
+ description?: string;
447
+ };
448
+ clientId?: {
449
+ type: 'string';
450
+ description?: string;
451
+ };
452
+ bindingVersion?: string;
453
+ };
454
+ type RedisOperationBindingObject = {
455
+ command?: 'PUBLISH' | 'SUBSCRIBE';
456
+ channel?: string;
457
+ bindingVersion?: string;
458
+ };
459
+ type RabbitMQOperationBindingObject = {
460
+ exchangeType?: 'direct' | 'fanout' | 'topic' | 'headers';
461
+ exchangeName?: string;
462
+ durable?: boolean;
463
+ autoDelete?: boolean;
464
+ vhost?: string;
465
+ bindingVersion?: string;
466
+ };
467
+ type GooglePubSubOperationBindingObject = {
468
+ ackDeadlineSeconds?: number;
469
+ retryPolicy?: GooglePubSubRetryPolicy;
470
+ deadLetterPolicy?: GooglePubSubDeadLetterPolicy;
471
+ detachSubscription?: boolean;
472
+ messageRetentionDuration?: string;
473
+ filter?: string;
474
+ bindingVersion?: string;
475
+ };
476
+ type GooglePubSubRetryPolicy = {
477
+ minimumBackoff?: string;
478
+ maximumBackoff?: string;
479
+ };
480
+ type GooglePubSubDeadLetterPolicy = {
481
+ deadLetterTopic?: string;
482
+ maxDeliveryAttempts?: number;
483
+ };
484
+ type MessageBindingsObject = {
485
+ http?: HttpMessageBindingObject;
486
+ ws?: WebSocketMessageBindingObject;
487
+ kafka?: KafkaMessageBindingObject;
488
+ redis?: RedisMessageBindingObject;
489
+ rabbitmq?: RabbitMQMessageBindingObject;
490
+ googlepubsub?: GooglePubSubMessageBindingObject;
491
+ };
492
+ type MessageBindingObject = {
493
+ headers?: SchemaObject | ReferenceObject;
494
+ bindingVersion?: string;
495
+ };
496
+ type HttpMessageBindingObject = MessageBindingObject & {};
497
+ type WebSocketMessageBindingObject = MessageBindingObject & {};
498
+ type KafkaMessageBindingObject = MessageBindingObject & {};
499
+ type RedisMessageBindingObject = MessageBindingObject & {};
500
+ type RabbitMQMessageBindingObject = MessageBindingObject & {};
501
+ type GooglePubSubMessageBindingObject = MessageBindingObject & {};
502
+ type ServerBindingsObject = {
503
+ http?: HttpServerBindingObject;
504
+ ws?: WebSocketServerBindingObject;
505
+ kafka?: KafkaServerBindingObject;
506
+ mqtt?: MqttServerBindingObject;
507
+ amqp?: AmqpServerBindingObject;
508
+ };
509
+ type BaseServerBindingObject = {
510
+ bindingVersion?: string;
511
+ };
512
+ type HttpServerBindingObject = BaseServerBindingObject & {};
513
+ type WebSocketServerBindingObject = BaseServerBindingObject & {};
514
+ type KafkaServerBindingObject = BaseServerBindingObject & {};
515
+ type MqttServerBindingObject = BaseServerBindingObject & {};
516
+ type AmqpServerBindingObject = BaseServerBindingObject & {};
517
+
518
+ type AsyncApiDocument = {
519
+ asyncapi: string;
520
+ id?: string;
521
+ info: InfoObject;
522
+ servers?: Record<string, ServerObject>;
523
+ defaultContentType?: string;
524
+ channels: Record<string, ChannelItemObject>;
525
+ components?: AsyncApiComponentsObject;
526
+ tags?: TagObject[];
527
+ externalDocs?: ExternalDocumentationObject;
528
+ };
529
+ type ChannelItemObject = {
530
+ $ref?: string;
531
+ description?: string;
532
+ subscribe?: AsyncOperationObject;
533
+ publish?: AsyncOperationObject;
534
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
535
+ bindings?: ChannelBindingsObject;
536
+ };
537
+ type AsyncOperationObject = {
538
+ tags?: TagObject[];
539
+ summary?: string;
540
+ description?: string;
541
+ externalDocs?: ExternalDocumentationObject;
542
+ operationId?: string;
543
+ traits?: OperationTraitObject[];
544
+ message?: MessageObject | ReferenceObject;
545
+ };
546
+ type MessageObject = {
547
+ headers?: SchemaObject | ReferenceObject;
548
+ payload?: SchemaObject | ReferenceObject;
549
+ correlationId?: CorrelationIdObject | ReferenceObject;
550
+ schemaFormat?: string;
551
+ contentType?: string;
552
+ name?: string;
553
+ title?: string;
554
+ summary?: string;
555
+ description?: string;
556
+ tags?: TagObject[];
557
+ externalDocs?: ExternalDocumentationObject;
558
+ bindings?: MessageBindingsObject;
559
+ examples?: Example[];
560
+ traits?: MessageTraitObject[];
561
+ };
562
+ type AsyncApiComponentsObject = {
563
+ schemas?: Record<string, SchemaObject | ReferenceObject>;
564
+ messages?: Record<string, MessageObject | ReferenceObject>;
565
+ securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
566
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
567
+ correlationIds?: Record<string, CorrelationIdObject | ReferenceObject>;
568
+ operationTraits?: Record<string, OperationTraitObject | ReferenceObject>;
569
+ messageTraits?: Record<string, MessageTraitObject | ReferenceObject>;
570
+ serverBindings?: Record<string, ServerBindingsObject | ReferenceObject>;
571
+ channelBindings?: Record<string, ChannelBindingsObject | ReferenceObject>;
572
+ messageBindings?: Record<string, MessageBindingsObject | ReferenceObject>;
573
+ };
574
+ type OperationTraitObject = {
575
+ operationId?: string;
576
+ summary?: string;
577
+ description?: string;
578
+ tags?: TagObject[];
579
+ externalDocs?: ExternalDocumentationObject;
580
+ bindings?: OperationBindingsObject;
581
+ message?: MessageTraitObject | ReferenceObject;
582
+ };
583
+ type MessageTraitObject = {
584
+ headers?: SchemaObject | ReferenceObject;
585
+ correlationId?: CorrelationIdObject | ReferenceObject;
586
+ schemaFormat?: string;
587
+ contentType?: string;
588
+ name?: string;
589
+ title?: string;
590
+ summary?: string;
591
+ description?: string;
592
+ tags?: TagObject[];
593
+ externalDocs?: ExternalDocumentationObject;
594
+ examples?: Example[];
595
+ bindings?: MessageBindingsObject;
596
+ };
597
+ type CorrelationIdObject = {
598
+ description?: string;
599
+ location: string;
600
+ };
601
+
602
+ type AvroSchema = AvroRecord | AvroEnum | AvroArray | AvroMap | AvroPrimitive | AvroUnion;
603
+ type AvroRecord = {
604
+ type: 'record';
605
+ name: string;
606
+ namespace?: string;
607
+ doc?: string;
608
+ fields: AvroField[];
609
+ };
610
+ type AvroField = {
611
+ name: string;
612
+ type: AvroSchema;
613
+ doc?: string;
614
+ default?: any;
615
+ order?: 'ascending' | 'descending' | 'ignore';
616
+ };
617
+ type AvroEnum = {
618
+ type: 'enum';
619
+ name: string;
620
+ symbols: string[];
621
+ doc?: string;
622
+ };
623
+ type AvroArray = {
624
+ type: 'array';
625
+ items: AvroSchema;
626
+ doc?: string;
627
+ };
628
+ type AvroMap = {
629
+ type: 'map';
630
+ values: AvroSchema;
631
+ doc?: string;
632
+ };
633
+ type AvroUnion = AvroSchema[];
634
+ type AvroPrimitive = 'null' | 'boolean' | 'int' | 'long' | 'float' | 'double' | 'bytes' | 'string';
635
+
636
+ type OpenApiDocument = {
637
+ openapi: string;
638
+ info: InfoObject;
639
+ jsonSchemaDialect?: string;
640
+ servers?: ServerObject[];
641
+ paths: Record<string, PathItemObject | ReferenceObject>;
642
+ webhooks?: Record<string, PathItemObject | ReferenceObject>;
643
+ components?: ComponentsObject;
644
+ security?: SecurityRequirementObject[];
645
+ tags?: TagObject[];
646
+ externalDocs?: ExternalDocumentationObject;
647
+ };
648
+ type PathItemObject = {
649
+ summary?: string;
650
+ description?: string;
651
+ get?: OperationObject;
652
+ put?: OperationObject;
653
+ post?: OperationObject;
654
+ delete?: OperationObject;
655
+ options?: OperationObject;
656
+ head?: OperationObject;
657
+ patch?: OperationObject;
658
+ trace?: OperationObject;
659
+ servers?: ServerObject[];
660
+ parameters?: (ParameterObject | ReferenceObject)[];
661
+ };
662
+ type OperationObject = {
663
+ tags?: string[];
664
+ summary?: string;
665
+ description?: string;
666
+ externalDocs?: ExternalDocumentationObject;
667
+ operationId?: string;
668
+ parameters?: (ParameterObject | ReferenceObject)[];
669
+ requestBody?: RequestBodyObject | ReferenceObject;
670
+ responses: ResponsesObject;
671
+ callbacks?: Record<string, CallbackObject | ReferenceObject>;
672
+ deprecated?: boolean;
673
+ security?: SecurityRequirementObject[];
674
+ servers?: ServerObject[];
675
+ };
676
+ type RequestBodyObject = {
677
+ description?: string;
678
+ content: Record<'application/json' | (string & {}), MediaTypeObject>;
679
+ required?: boolean;
680
+ };
681
+ type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
682
+ type ResponseObject = {
683
+ description: string;
684
+ headers?: Record<string, HeaderObject | ReferenceObject>;
685
+ content?: Record<'application/json' | (string & {}), MediaTypeObject>;
686
+ links?: Record<string, LinkObject | ReferenceObject>;
687
+ };
688
+ type ComponentsObject = {
689
+ schemas?: Record<string, SchemaObject>;
690
+ responses?: Record<string, ResponseObject>;
691
+ parameters?: Record<string, ParameterObject>;
692
+ examples?: Record<string, ExampleObject>;
693
+ requestBodies?: Record<string, RequestBodyObject>;
694
+ headers?: Record<string, HeaderObject>;
695
+ securitySchemes?: Record<string, SecuritySchemeObject>;
696
+ links?: Record<string, LinkObject>;
697
+ callbacks?: Record<string, CallbackObject>;
698
+ pathItems?: Record<string, PathItemObject>;
699
+ };
700
+ type RequestBody = any;
701
+ type LinkObject = {
702
+ operationRef?: string;
703
+ operationId?: string;
704
+ parameters?: Record<string, string>;
705
+ requestBody?: RequestBody;
706
+ description?: string;
707
+ server?: ServerObject;
179
708
  };
709
+ type CallbackObject = Record<string, PathItemObject | ReferenceObject>;
710
+ type SecurityRequirementObject = Record<string, string[]>;
180
711
 
181
- export { APIServerDefinition, APIServerOptions, BadGatewayError, BadRequestError, BaseClient, ClientErrorCode, ClientOptions, ConflictError, ErrorCode, ExpectationFailedError, FailedDependencyError, ForbiddenError, GatewayTimeoutError, GenericRouteHandler, GoneError, HTTPVersionNotSupportedError, HttpError, IMATeapotError, InsufficientStorageError, InternalServerError, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, PayloadRequestArgs, PayloadTooLargeError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, RequestArgs, RequestHeaderFieldsTooLargeError, RequestOptions, RequestTimeoutError, RetryConditionFunction, RetrySettings, Route, RouteHandler, ServerErrorCode, ServiceUnavailableError, TooEarlyError, TooManyRequestsError, URITooLongError, UnauthorizedError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, Verb, createHttpError, fromAxiosError };
712
+ export { type APIResponse, type APIServerDefinition, type APIServerOptions, type AsyncApiComponentsObject, type AsyncApiDocument, type AsyncOperationObject, type AvroArray, type AvroEnum, type AvroField, type AvroMap, type AvroPrimitive, type AvroRecord, type AvroSchema, type AvroUnion, BadGatewayError, BadRequestError, type BaseClient, type CallbackObject, type ChannelItemObject, type ClientErrorCode, type ClientOptions, type ComponentsObject, ConflictError, type ContactObject, type CorrelationIdObject, type DefaultValue, type DiscriminatorObject, type EncodingObject, type ErrorCode, type Example, type ExampleObject, ExpectationFailedError, type ExternalDocumentationObject, FailedDependencyError, ForbiddenError, GatewayTimeoutError, type GenericRouteHandler, GoneError, HTTPVersionNotSupportedError, type HeaderObject, type HeaderStyle, HttpError, type HttpMethod, IMATeapotError, type InfoObject, InsufficientStorageError, InternalServerError, LengthRequiredError, type LicenseObject, type LinkObject, LockedError, LoopDetectedError, type MediaTypeObject, type MessageObject, type MessageTraitObject, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, type OAuthFlowObject, type OAuthFlowsObject, type OpenApiDocument, type OperationObject, type OperationTraitObject, type ParameterIn, type ParameterObject, type ParameterStyle, type PartiallySerialized, type PathItemObject, type PayloadRequestArgs, PayloadTooLargeError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, type ReferenceObject, type RequestArgs, type RequestBodyObject, RequestHeaderFieldsTooLargeError, type RequestOptions, RequestTimeoutError, type ResponseObject, type ResponsesObject, type Route, type RouteHandler, type SchemaEnum, type SchemaObject, type SchemaType, type SecurityRequirementObject, type SecuritySchemeObject, type SecuritySchemeType, type Serialized, type ServerErrorCode, type ServerObject, type ServerVariableObject, ServiceUnavailableError, type TagObject, TooEarlyError, TooManyRequestsError, URITooLongError, UnauthorizedError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, type Verb, type XMLObject, createHttpError, fromAxiosError };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AxiosError } from 'axios';
2
+ import { RetrySettings } from '@sebspark/retry';
2
3
  import { Request, Response, NextFunction } from 'express';
3
4
 
4
5
  type ClientErrorCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
@@ -140,13 +141,30 @@ declare class NetworkAuthenticationRequiredError extends HttpError {
140
141
  declare const createHttpError: (statusCode: ErrorCode, message?: string, internalError?: Error) => HttpError;
141
142
  declare const fromAxiosError: (axiosError: AxiosError) => HttpError;
142
143
 
144
+ type Empty = Record<never, never>;
145
+ type Serialized<T> = {
146
+ [P in keyof T]: T[P] extends Date ? string : T[P] extends Array<infer U> ? Array<Serialized<U>> : T[P] extends (...args: any) => any ? T[P] : T[P] extends object ? Serialized<T[P]> : T[P];
147
+ };
148
+ type PartiallySerialized<T> = T | Serialized<T>;
149
+
143
150
  type Verb = 'get' | 'post' | 'put' | 'patch' | 'delete';
151
+ type APIResponse<Data = undefined, Headers = undefined> = Data extends undefined ? Headers extends undefined ? Empty : {
152
+ headers: Headers;
153
+ } : Headers extends undefined ? {
154
+ data: Data;
155
+ } : {
156
+ data: Data;
157
+ headers: Headers;
158
+ };
144
159
  type GenericRouteHandler = (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
145
160
  type RouteHandler = {
146
161
  pre?: GenericRouteHandler | GenericRouteHandler[];
147
- handler: <A = any, R = any>(arg?: A) => Promise<R>;
162
+ handler: <RequestArgs, Response extends [
163
+ number,
164
+ APIResponse<unknown | undefined, Record<string, string> | undefined>
165
+ ]>(args?: RequestArgs) => Promise<Response>;
148
166
  };
149
- type Route<R extends RouteHandler = RouteHandler> = Record<Verb, R>;
167
+ type Route<Handler extends RouteHandler = RouteHandler> = Record<Verb, Handler>;
150
168
  type APIServerDefinition = Record<string, Partial<Route>>;
151
169
  type APIServerOptions = {
152
170
  pre?: GenericRouteHandler | GenericRouteHandler[];
@@ -159,23 +177,536 @@ type RequestArgs = Request & {
159
177
  type PayloadRequestArgs = RequestArgs & {
160
178
  body?: Record<string, string>;
161
179
  };
162
- type RetryConditionFunction = (error: any) => boolean;
163
- interface RetrySettings {
164
- maxRetries: number;
165
- interval: (retryCount: number) => number;
166
- retryCondition?: RetryConditionFunction;
167
- maxDelay?: number;
168
- }
169
180
  type RequestOptions = {
170
181
  retry: RetrySettings;
171
182
  };
172
183
  type ClientOptions = RequestOptions & {};
173
184
  type BaseClient = {
174
- get: <U extends string, A extends RequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
175
- post: <U extends string, A extends PayloadRequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
176
- put: <U extends string, A extends PayloadRequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
177
- patch: <U extends string, A extends PayloadRequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
178
- delete: <U extends string, A extends RequestArgs | never, R>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
185
+ get: <U extends string, A extends RequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
186
+ post: <U extends string, A extends PayloadRequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
187
+ put: <U extends string, A extends PayloadRequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
188
+ patch: <U extends string, A extends PayloadRequestArgs | never, R extends APIResponse<unknown | undefined, Record<string, string> | undefined>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
189
+ delete: <U extends string, A extends RequestArgs | never, R extends APIResponse<unknown, unknown>>(url: U, args?: A, opts?: RequestOptions) => Promise<R>;
190
+ };
191
+
192
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
193
+ type SchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
194
+ type SchemaEnum = string[] | number[] | boolean[];
195
+ type DefaultValue = string | number | boolean | any[] | any;
196
+ type Example = any;
197
+ type ExampleObject = {
198
+ summary?: string;
199
+ description?: string;
200
+ value?: Example;
201
+ externalValue?: string;
202
+ };
203
+ type SchemaObject = {
204
+ title?: string;
205
+ multipleOf?: number;
206
+ maximum?: number;
207
+ exclusiveMaximum?: boolean;
208
+ minimum?: number;
209
+ exclusiveMinimum?: boolean;
210
+ maxLength?: number;
211
+ minLength?: number;
212
+ pattern?: string;
213
+ maxItems?: number;
214
+ minItems?: number;
215
+ uniqueItems?: boolean;
216
+ maxProperties?: number;
217
+ minProperties?: number;
218
+ required?: string[];
219
+ enum?: SchemaEnum;
220
+ type?: SchemaType | SchemaType[];
221
+ allOf?: (SchemaObject | ReferenceObject)[];
222
+ oneOf?: (SchemaObject | ReferenceObject)[];
223
+ anyOf?: (SchemaObject | ReferenceObject)[];
224
+ not?: SchemaObject | ReferenceObject;
225
+ items?: SchemaObject | ReferenceObject;
226
+ properties?: Record<string, SchemaObject | ReferenceObject>;
227
+ additionalProperties?: boolean | SchemaObject | ReferenceObject;
228
+ description?: string;
229
+ format?: string;
230
+ default?: DefaultValue;
231
+ nullable?: boolean;
232
+ discriminator?: DiscriminatorObject;
233
+ readOnly?: boolean;
234
+ writeOnly?: boolean;
235
+ xml?: XMLObject;
236
+ externalDocs?: ExternalDocumentationObject;
237
+ example?: Example;
238
+ deprecated?: boolean;
239
+ };
240
+ type XMLObject = {
241
+ name?: string;
242
+ namespace?: string;
243
+ prefix?: string;
244
+ attribute?: boolean;
245
+ wrapped?: boolean;
246
+ };
247
+ type ParameterIn = 'query' | 'header' | 'path' | 'cookie';
248
+ type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
249
+ type ParameterObject = {
250
+ name: string;
251
+ in: ParameterIn;
252
+ description?: string;
253
+ required?: boolean;
254
+ deprecated?: boolean;
255
+ allowEmptyValue?: boolean;
256
+ style?: ParameterStyle;
257
+ explode?: boolean;
258
+ allowReserved?: boolean;
259
+ schema?: SchemaObject | ReferenceObject;
260
+ example?: Example;
261
+ examples?: Record<string, ExampleObject | ReferenceObject>;
262
+ content?: Record<string, MediaTypeObject>;
263
+ };
264
+ type MediaTypeObject = {
265
+ schema?: SchemaObject | ReferenceObject;
266
+ example?: Example;
267
+ examples?: Record<string, ExampleObject | ReferenceObject>;
268
+ encoding?: Record<string, EncodingObject>;
269
+ };
270
+ type EncodingObject = {
271
+ contentType?: string;
272
+ headers?: Record<string, HeaderObject | ReferenceObject>;
273
+ style?: string;
274
+ explode?: boolean;
275
+ allowReserved?: boolean;
276
+ };
277
+ type HeaderStyle = 'simple';
278
+ type HeaderObject = {
279
+ description?: string;
280
+ required?: boolean;
281
+ deprecated?: boolean;
282
+ allowEmptyValue?: boolean;
283
+ style?: HeaderStyle;
284
+ explode?: boolean;
285
+ allowReserved?: boolean;
286
+ schema?: SchemaObject | ReferenceObject;
287
+ example?: Example;
288
+ examples?: Record<string, ExampleObject | ReferenceObject>;
289
+ content?: Record<string, MediaTypeObject>;
290
+ };
291
+ type DiscriminatorObject = {
292
+ propertyName: string;
293
+ mapping?: Record<string, string>;
294
+ };
295
+ type ReferenceObject = {
296
+ $ref: string;
297
+ };
298
+ type InfoObject = {
299
+ title: string;
300
+ summary?: string;
301
+ description?: string;
302
+ termsOfService?: string;
303
+ contact?: ContactObject;
304
+ license?: LicenseObject;
305
+ version: string;
306
+ };
307
+ type ContactObject = {
308
+ name?: string;
309
+ url?: string;
310
+ email?: string;
311
+ };
312
+ type LicenseObject = {
313
+ name: string;
314
+ url?: string;
315
+ };
316
+ type ServerObject = {
317
+ url: string;
318
+ description?: string;
319
+ variables?: Record<string, ServerVariableObject>;
320
+ };
321
+ type ServerVariableObject = {
322
+ default: string;
323
+ enum?: string[];
324
+ description?: string;
325
+ };
326
+ type TagObject = {
327
+ name: string;
328
+ description?: string;
329
+ externalDocs?: ExternalDocumentationObject;
330
+ };
331
+ type ExternalDocumentationObject = {
332
+ description?: string;
333
+ url: string;
334
+ };
335
+ type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
336
+ type SecuritySchemeObject = {
337
+ type: SecuritySchemeType;
338
+ description?: string;
339
+ name?: string;
340
+ in?: ParameterIn;
341
+ scheme?: string;
342
+ bearerFormat?: string;
343
+ flows?: OAuthFlowsObject;
344
+ openIdConnectUrl?: string;
345
+ };
346
+ type OAuthFlowsObject = {
347
+ implicit?: OAuthFlowObject;
348
+ password?: OAuthFlowObject;
349
+ clientCredentials?: OAuthFlowObject;
350
+ authorizationCode?: OAuthFlowObject;
351
+ };
352
+ type OAuthFlowObject = {
353
+ authorizationUrl?: string;
354
+ tokenUrl?: string;
355
+ refreshUrl?: string;
356
+ scopes: Record<string, string>;
357
+ };
358
+
359
+ type ChannelBindingsObject = {
360
+ http?: HttpChannelBindingObject;
361
+ ws?: WebSocketChannelBindingObject;
362
+ kafka?: KafkaChannelBindingObject;
363
+ redis?: RedisChannelBindingObject;
364
+ rabbitmq?: RabbitMQChannelBindingObject;
365
+ googlepubsub?: GooglePubSubChannelBindingObject;
366
+ };
367
+ type HttpChannelBindingObject = {
368
+ type: string;
369
+ method: string;
370
+ query: SchemaObject | ReferenceObject;
371
+ bindingVersion?: string;
372
+ };
373
+ type WebSocketChannelBindingObject = {
374
+ type: string;
375
+ method: string;
376
+ query: SchemaObject | ReferenceObject;
377
+ headers: SchemaObject | ReferenceObject;
378
+ bindingVersion?: string;
379
+ };
380
+ type KafkaChannelBindingObject = {
381
+ groupId?: SchemaObject | ReferenceObject;
382
+ clientId?: SchemaObject | ReferenceObject;
383
+ bindingVersion?: string;
384
+ };
385
+ type RedisChannelBindingObject = {
386
+ type: string;
387
+ method: string;
388
+ query: SchemaObject | ReferenceObject;
389
+ bindingVersion?: string;
390
+ };
391
+ type RabbitMQChannelBindingObject = {
392
+ is: string;
393
+ exchange: {
394
+ name: string;
395
+ type: string;
396
+ durable: boolean;
397
+ autoDelete: boolean;
398
+ vhost: string;
399
+ };
400
+ queue: {
401
+ name: string;
402
+ durable: boolean;
403
+ exclusive: boolean;
404
+ autoDelete: boolean;
405
+ vhost: string;
406
+ };
407
+ bindingVersion?: string;
408
+ };
409
+ type GooglePubSubChannelBindingObject = {
410
+ topic: {
411
+ name: string;
412
+ };
413
+ subscription: {
414
+ name: string;
415
+ };
416
+ bindingVersion?: string;
417
+ };
418
+ type OperationBindingsObject = {
419
+ ws?: WebSocketOperationBindingObject;
420
+ http?: HttpOperationBindingObject;
421
+ kafka?: KafkaOperationBindingObject;
422
+ redis?: RedisOperationBindingObject;
423
+ rabbitmq?: RabbitMQOperationBindingObject;
424
+ googlepubsub?: GooglePubSubOperationBindingObject;
425
+ };
426
+ type OperationType = 'publish' | 'subscribe';
427
+ type MessageFormat = 'json' | 'xml' | 'text' | 'binary';
428
+ type WebSocketOperationBindingObject = {
429
+ type?: OperationType;
430
+ method?: 'GET';
431
+ query?: SchemaObject | ReferenceObject;
432
+ headers?: SchemaObject | ReferenceObject;
433
+ messageFormat?: MessageFormat;
434
+ persistent?: boolean;
435
+ bindingVersion?: string;
436
+ };
437
+ type HttpOperationBindingObject = {
438
+ type: 'request' | 'response';
439
+ method: HttpMethod;
440
+ query?: SchemaObject | ReferenceObject;
441
+ bindingVersion?: string;
442
+ };
443
+ type KafkaOperationBindingObject = {
444
+ groupId?: {
445
+ type: 'string';
446
+ description?: string;
447
+ };
448
+ clientId?: {
449
+ type: 'string';
450
+ description?: string;
451
+ };
452
+ bindingVersion?: string;
453
+ };
454
+ type RedisOperationBindingObject = {
455
+ command?: 'PUBLISH' | 'SUBSCRIBE';
456
+ channel?: string;
457
+ bindingVersion?: string;
458
+ };
459
+ type RabbitMQOperationBindingObject = {
460
+ exchangeType?: 'direct' | 'fanout' | 'topic' | 'headers';
461
+ exchangeName?: string;
462
+ durable?: boolean;
463
+ autoDelete?: boolean;
464
+ vhost?: string;
465
+ bindingVersion?: string;
466
+ };
467
+ type GooglePubSubOperationBindingObject = {
468
+ ackDeadlineSeconds?: number;
469
+ retryPolicy?: GooglePubSubRetryPolicy;
470
+ deadLetterPolicy?: GooglePubSubDeadLetterPolicy;
471
+ detachSubscription?: boolean;
472
+ messageRetentionDuration?: string;
473
+ filter?: string;
474
+ bindingVersion?: string;
475
+ };
476
+ type GooglePubSubRetryPolicy = {
477
+ minimumBackoff?: string;
478
+ maximumBackoff?: string;
479
+ };
480
+ type GooglePubSubDeadLetterPolicy = {
481
+ deadLetterTopic?: string;
482
+ maxDeliveryAttempts?: number;
483
+ };
484
+ type MessageBindingsObject = {
485
+ http?: HttpMessageBindingObject;
486
+ ws?: WebSocketMessageBindingObject;
487
+ kafka?: KafkaMessageBindingObject;
488
+ redis?: RedisMessageBindingObject;
489
+ rabbitmq?: RabbitMQMessageBindingObject;
490
+ googlepubsub?: GooglePubSubMessageBindingObject;
491
+ };
492
+ type MessageBindingObject = {
493
+ headers?: SchemaObject | ReferenceObject;
494
+ bindingVersion?: string;
495
+ };
496
+ type HttpMessageBindingObject = MessageBindingObject & {};
497
+ type WebSocketMessageBindingObject = MessageBindingObject & {};
498
+ type KafkaMessageBindingObject = MessageBindingObject & {};
499
+ type RedisMessageBindingObject = MessageBindingObject & {};
500
+ type RabbitMQMessageBindingObject = MessageBindingObject & {};
501
+ type GooglePubSubMessageBindingObject = MessageBindingObject & {};
502
+ type ServerBindingsObject = {
503
+ http?: HttpServerBindingObject;
504
+ ws?: WebSocketServerBindingObject;
505
+ kafka?: KafkaServerBindingObject;
506
+ mqtt?: MqttServerBindingObject;
507
+ amqp?: AmqpServerBindingObject;
508
+ };
509
+ type BaseServerBindingObject = {
510
+ bindingVersion?: string;
511
+ };
512
+ type HttpServerBindingObject = BaseServerBindingObject & {};
513
+ type WebSocketServerBindingObject = BaseServerBindingObject & {};
514
+ type KafkaServerBindingObject = BaseServerBindingObject & {};
515
+ type MqttServerBindingObject = BaseServerBindingObject & {};
516
+ type AmqpServerBindingObject = BaseServerBindingObject & {};
517
+
518
+ type AsyncApiDocument = {
519
+ asyncapi: string;
520
+ id?: string;
521
+ info: InfoObject;
522
+ servers?: Record<string, ServerObject>;
523
+ defaultContentType?: string;
524
+ channels: Record<string, ChannelItemObject>;
525
+ components?: AsyncApiComponentsObject;
526
+ tags?: TagObject[];
527
+ externalDocs?: ExternalDocumentationObject;
528
+ };
529
+ type ChannelItemObject = {
530
+ $ref?: string;
531
+ description?: string;
532
+ subscribe?: AsyncOperationObject;
533
+ publish?: AsyncOperationObject;
534
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
535
+ bindings?: ChannelBindingsObject;
536
+ };
537
+ type AsyncOperationObject = {
538
+ tags?: TagObject[];
539
+ summary?: string;
540
+ description?: string;
541
+ externalDocs?: ExternalDocumentationObject;
542
+ operationId?: string;
543
+ traits?: OperationTraitObject[];
544
+ message?: MessageObject | ReferenceObject;
545
+ };
546
+ type MessageObject = {
547
+ headers?: SchemaObject | ReferenceObject;
548
+ payload?: SchemaObject | ReferenceObject;
549
+ correlationId?: CorrelationIdObject | ReferenceObject;
550
+ schemaFormat?: string;
551
+ contentType?: string;
552
+ name?: string;
553
+ title?: string;
554
+ summary?: string;
555
+ description?: string;
556
+ tags?: TagObject[];
557
+ externalDocs?: ExternalDocumentationObject;
558
+ bindings?: MessageBindingsObject;
559
+ examples?: Example[];
560
+ traits?: MessageTraitObject[];
561
+ };
562
+ type AsyncApiComponentsObject = {
563
+ schemas?: Record<string, SchemaObject | ReferenceObject>;
564
+ messages?: Record<string, MessageObject | ReferenceObject>;
565
+ securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
566
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
567
+ correlationIds?: Record<string, CorrelationIdObject | ReferenceObject>;
568
+ operationTraits?: Record<string, OperationTraitObject | ReferenceObject>;
569
+ messageTraits?: Record<string, MessageTraitObject | ReferenceObject>;
570
+ serverBindings?: Record<string, ServerBindingsObject | ReferenceObject>;
571
+ channelBindings?: Record<string, ChannelBindingsObject | ReferenceObject>;
572
+ messageBindings?: Record<string, MessageBindingsObject | ReferenceObject>;
573
+ };
574
+ type OperationTraitObject = {
575
+ operationId?: string;
576
+ summary?: string;
577
+ description?: string;
578
+ tags?: TagObject[];
579
+ externalDocs?: ExternalDocumentationObject;
580
+ bindings?: OperationBindingsObject;
581
+ message?: MessageTraitObject | ReferenceObject;
582
+ };
583
+ type MessageTraitObject = {
584
+ headers?: SchemaObject | ReferenceObject;
585
+ correlationId?: CorrelationIdObject | ReferenceObject;
586
+ schemaFormat?: string;
587
+ contentType?: string;
588
+ name?: string;
589
+ title?: string;
590
+ summary?: string;
591
+ description?: string;
592
+ tags?: TagObject[];
593
+ externalDocs?: ExternalDocumentationObject;
594
+ examples?: Example[];
595
+ bindings?: MessageBindingsObject;
596
+ };
597
+ type CorrelationIdObject = {
598
+ description?: string;
599
+ location: string;
600
+ };
601
+
602
+ type AvroSchema = AvroRecord | AvroEnum | AvroArray | AvroMap | AvroPrimitive | AvroUnion;
603
+ type AvroRecord = {
604
+ type: 'record';
605
+ name: string;
606
+ namespace?: string;
607
+ doc?: string;
608
+ fields: AvroField[];
609
+ };
610
+ type AvroField = {
611
+ name: string;
612
+ type: AvroSchema;
613
+ doc?: string;
614
+ default?: any;
615
+ order?: 'ascending' | 'descending' | 'ignore';
616
+ };
617
+ type AvroEnum = {
618
+ type: 'enum';
619
+ name: string;
620
+ symbols: string[];
621
+ doc?: string;
622
+ };
623
+ type AvroArray = {
624
+ type: 'array';
625
+ items: AvroSchema;
626
+ doc?: string;
627
+ };
628
+ type AvroMap = {
629
+ type: 'map';
630
+ values: AvroSchema;
631
+ doc?: string;
632
+ };
633
+ type AvroUnion = AvroSchema[];
634
+ type AvroPrimitive = 'null' | 'boolean' | 'int' | 'long' | 'float' | 'double' | 'bytes' | 'string';
635
+
636
+ type OpenApiDocument = {
637
+ openapi: string;
638
+ info: InfoObject;
639
+ jsonSchemaDialect?: string;
640
+ servers?: ServerObject[];
641
+ paths: Record<string, PathItemObject | ReferenceObject>;
642
+ webhooks?: Record<string, PathItemObject | ReferenceObject>;
643
+ components?: ComponentsObject;
644
+ security?: SecurityRequirementObject[];
645
+ tags?: TagObject[];
646
+ externalDocs?: ExternalDocumentationObject;
647
+ };
648
+ type PathItemObject = {
649
+ summary?: string;
650
+ description?: string;
651
+ get?: OperationObject;
652
+ put?: OperationObject;
653
+ post?: OperationObject;
654
+ delete?: OperationObject;
655
+ options?: OperationObject;
656
+ head?: OperationObject;
657
+ patch?: OperationObject;
658
+ trace?: OperationObject;
659
+ servers?: ServerObject[];
660
+ parameters?: (ParameterObject | ReferenceObject)[];
661
+ };
662
+ type OperationObject = {
663
+ tags?: string[];
664
+ summary?: string;
665
+ description?: string;
666
+ externalDocs?: ExternalDocumentationObject;
667
+ operationId?: string;
668
+ parameters?: (ParameterObject | ReferenceObject)[];
669
+ requestBody?: RequestBodyObject | ReferenceObject;
670
+ responses: ResponsesObject;
671
+ callbacks?: Record<string, CallbackObject | ReferenceObject>;
672
+ deprecated?: boolean;
673
+ security?: SecurityRequirementObject[];
674
+ servers?: ServerObject[];
675
+ };
676
+ type RequestBodyObject = {
677
+ description?: string;
678
+ content: Record<'application/json' | (string & {}), MediaTypeObject>;
679
+ required?: boolean;
680
+ };
681
+ type ResponsesObject = Record<string, ResponseObject | ReferenceObject>;
682
+ type ResponseObject = {
683
+ description: string;
684
+ headers?: Record<string, HeaderObject | ReferenceObject>;
685
+ content?: Record<'application/json' | (string & {}), MediaTypeObject>;
686
+ links?: Record<string, LinkObject | ReferenceObject>;
687
+ };
688
+ type ComponentsObject = {
689
+ schemas?: Record<string, SchemaObject>;
690
+ responses?: Record<string, ResponseObject>;
691
+ parameters?: Record<string, ParameterObject>;
692
+ examples?: Record<string, ExampleObject>;
693
+ requestBodies?: Record<string, RequestBodyObject>;
694
+ headers?: Record<string, HeaderObject>;
695
+ securitySchemes?: Record<string, SecuritySchemeObject>;
696
+ links?: Record<string, LinkObject>;
697
+ callbacks?: Record<string, CallbackObject>;
698
+ pathItems?: Record<string, PathItemObject>;
699
+ };
700
+ type RequestBody = any;
701
+ type LinkObject = {
702
+ operationRef?: string;
703
+ operationId?: string;
704
+ parameters?: Record<string, string>;
705
+ requestBody?: RequestBody;
706
+ description?: string;
707
+ server?: ServerObject;
179
708
  };
709
+ type CallbackObject = Record<string, PathItemObject | ReferenceObject>;
710
+ type SecurityRequirementObject = Record<string, string[]>;
180
711
 
181
- export { APIServerDefinition, APIServerOptions, BadGatewayError, BadRequestError, BaseClient, ClientErrorCode, ClientOptions, ConflictError, ErrorCode, ExpectationFailedError, FailedDependencyError, ForbiddenError, GatewayTimeoutError, GenericRouteHandler, GoneError, HTTPVersionNotSupportedError, HttpError, IMATeapotError, InsufficientStorageError, InternalServerError, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, PayloadRequestArgs, PayloadTooLargeError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, RequestArgs, RequestHeaderFieldsTooLargeError, RequestOptions, RequestTimeoutError, RetryConditionFunction, RetrySettings, Route, RouteHandler, ServerErrorCode, ServiceUnavailableError, TooEarlyError, TooManyRequestsError, URITooLongError, UnauthorizedError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, Verb, createHttpError, fromAxiosError };
712
+ export { type APIResponse, type APIServerDefinition, type APIServerOptions, type AsyncApiComponentsObject, type AsyncApiDocument, type AsyncOperationObject, type AvroArray, type AvroEnum, type AvroField, type AvroMap, type AvroPrimitive, type AvroRecord, type AvroSchema, type AvroUnion, BadGatewayError, BadRequestError, type BaseClient, type CallbackObject, type ChannelItemObject, type ClientErrorCode, type ClientOptions, type ComponentsObject, ConflictError, type ContactObject, type CorrelationIdObject, type DefaultValue, type DiscriminatorObject, type EncodingObject, type ErrorCode, type Example, type ExampleObject, ExpectationFailedError, type ExternalDocumentationObject, FailedDependencyError, ForbiddenError, GatewayTimeoutError, type GenericRouteHandler, GoneError, HTTPVersionNotSupportedError, type HeaderObject, type HeaderStyle, HttpError, type HttpMethod, IMATeapotError, type InfoObject, InsufficientStorageError, InternalServerError, LengthRequiredError, type LicenseObject, type LinkObject, LockedError, LoopDetectedError, type MediaTypeObject, type MessageObject, type MessageTraitObject, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, type OAuthFlowObject, type OAuthFlowsObject, type OpenApiDocument, type OperationObject, type OperationTraitObject, type ParameterIn, type ParameterObject, type ParameterStyle, type PartiallySerialized, type PathItemObject, type PayloadRequestArgs, PayloadTooLargeError, PaymentRequiredError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, type ReferenceObject, type RequestArgs, type RequestBodyObject, RequestHeaderFieldsTooLargeError, type RequestOptions, RequestTimeoutError, type ResponseObject, type ResponsesObject, type Route, type RouteHandler, type SchemaEnum, type SchemaObject, type SchemaType, type SecurityRequirementObject, type SecuritySchemeObject, type SecuritySchemeType, type Serialized, type ServerErrorCode, type ServerObject, type ServerVariableObject, ServiceUnavailableError, type TagObject, TooEarlyError, TooManyRequestsError, URITooLongError, UnauthorizedError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, VariantAlsoNegotiatesError, type Verb, type XMLObject, createHttpError, fromAxiosError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/openapi-core",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -11,14 +11,15 @@
11
11
  "scripts": {
12
12
  "build": "tsup-node src/index.ts --format esm,cjs --dts",
13
13
  "dev": "tsc --watch --noEmit",
14
- "lint": "eslint \"src/**/*.ts*\"",
14
+ "lint": "biome check .",
15
15
  "test": "vitest --passWithNoTests --coverage",
16
- "typecheck": "vitest typecheck --passWithNoTests"
16
+ "typecheck": "vitest --typecheck.only --passWithNoTests"
17
17
  },
18
18
  "devDependencies": {
19
19
  "tsconfig": "*"
20
20
  },
21
21
  "dependencies": {
22
- "axios": "1.6.1"
22
+ "@sebspark/retry": "*",
23
+ "axios": "1.6.7"
23
24
  }
24
25
  }