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