@gtsc/api-models
Advanced tools
Comparing version 0.0.3-next.9 to 0.0.3-next.10
@@ -31,6 +31,6 @@ import type { IRequestContext } from "@gtsc/services"; | ||
* @param method The http method. | ||
* @param requestData Request to send to the endpoint. | ||
* @param request Request to send to the endpoint. | ||
* @returns The response. | ||
*/ | ||
fetch<T extends IHttpRequest, U extends IHttpResponse>(requestContext: IRequestContext, route: string, method: HttpMethods, requestData?: T): Promise<U>; | ||
fetch<T extends IHttpRequest, U extends IHttpResponse>(requestContext: IRequestContext, route: string, method: HttpMethods, request?: T): Promise<U>; | ||
} |
@@ -10,15 +10,13 @@ export * from "./clients/baseRestClient"; | ||
export * from "./models/protocol/IHttpResponse"; | ||
export * from "./models/responses/IAcceptedResponse"; | ||
export * from "./models/responses/ICreatedResponse"; | ||
export * from "./models/responses/IErrorResponse"; | ||
export * from "./models/responses/INoContentResponse"; | ||
export * from "./models/responses/ISuccessResponse"; | ||
export * from "./models/responses/errors/IBadRequestErrorResponse"; | ||
export * from "./models/responses/errors/IConflictResponse"; | ||
export * from "./models/responses/errors/IErrorResponse"; | ||
export * from "./models/responses/errors/IForbiddenResponse"; | ||
export * from "./models/responses/errors/IInternalServerErrorResponse"; | ||
export * from "./models/responses/errors/INotFoundResponse"; | ||
export * from "./models/responses/errors/IServiceUnavailableResponse"; | ||
export * from "./models/responses/errors/IUnauthorizedResponse"; | ||
export * from "./models/responses/errors/IUnprocessableEntityResponse"; | ||
export * from "./models/responses/success/IAcceptedResponse"; | ||
export * from "./models/responses/success/ICreatedResponse"; | ||
export * from "./models/responses/success/INoContentResponse"; | ||
export * from "./models/responses/success/IOkResponse"; | ||
export * from "./models/routes/IBaseRoute"; | ||
@@ -25,0 +23,0 @@ export * from "./models/routes/IRestRoute"; |
@@ -13,9 +13,9 @@ import type { IHttpRequestQuery } from "./IHttpRequestQuery"; | ||
/** | ||
* Request query parameters. | ||
* The query parameters. | ||
*/ | ||
query?: IHttpRequestQuery; | ||
/** | ||
* Data to return as the main payload. | ||
* Data to return send as the body. | ||
*/ | ||
data?: T; | ||
body?: T; | ||
} |
import type { HttpStatusCodes, IHttpRequestHeaders } from "@gtsc/web"; | ||
/** | ||
* Model used when a REST route wants to return custom response. | ||
* Model for the standard parameters for an http response. | ||
*/ | ||
export interface IHttpResponse<T = unknown> { | ||
/** | ||
* Alternative response status code. | ||
* Response status code. | ||
*/ | ||
statusCode?: HttpStatusCodes; | ||
/** | ||
* Additional response headers. | ||
* Response headers. | ||
*/ | ||
@@ -17,3 +17,3 @@ headers?: IHttpRequestHeaders; | ||
*/ | ||
data?: T; | ||
body?: T; | ||
} |
@@ -1,6 +0,5 @@ | ||
import type { IErrorResponse } from "../IErrorResponse"; | ||
import type { IErrorResponse } from "./IErrorResponse"; | ||
/** | ||
* Something went wrong with the request see the error field for more details. | ||
*/ | ||
export interface IBadRequestResponse extends IErrorResponse { | ||
} | ||
export type IBadRequestResponse = IErrorResponse; |
@@ -1,2 +0,2 @@ | ||
import type { IErrorResponse } from "../IErrorResponse"; | ||
import type { IErrorResponse } from "./IErrorResponse"; | ||
/** | ||
@@ -3,0 +3,0 @@ * The request resulted in a conflicting operation, see the error field for more details. |
@@ -1,6 +0,5 @@ | ||
import type { IErrorResponse } from "../IErrorResponse"; | ||
import type { IErrorResponse } from "./IErrorResponse"; | ||
/** | ||
* The operation that you tried to perform is not possible, see the error field for more details. | ||
*/ | ||
export interface IForbiddenResponse extends IErrorResponse { | ||
} | ||
export type IForbiddenResponse = IErrorResponse; |
@@ -1,2 +0,2 @@ | ||
import type { IErrorResponse } from "../IErrorResponse"; | ||
import type { IErrorResponse } from "./IErrorResponse"; | ||
/** | ||
@@ -3,0 +3,0 @@ * The resource you tried to access does not exist, see the error field for more details. |
@@ -1,6 +0,5 @@ | ||
import type { IErrorResponse } from "../IErrorResponse"; | ||
import type { IErrorResponse } from "./IErrorResponse"; | ||
/** | ||
* You are not authorized to use the API or no credentials were supplied. | ||
*/ | ||
export interface IUnauthorizedResponse extends IErrorResponse { | ||
} | ||
export type IUnauthorizedResponse = IErrorResponse; |
@@ -1,2 +0,2 @@ | ||
import type { IErrorResponse } from "../IErrorResponse"; | ||
import type { IErrorResponse } from "./IErrorResponse"; | ||
/** | ||
@@ -3,0 +3,0 @@ * The operation could not be processed, see the error field for more details. |
@@ -37,3 +37,3 @@ # Class: BaseRestClient | ||
▸ **fetch**\<`T`, `U`\>(`requestContext`, `route`, `method`, `requestData?`): `Promise`\<`U`\> | ||
▸ **fetch**\<`T`, `U`\>(`requestContext`, `route`, `method`, `request?`): `Promise`\<`U`\> | ||
@@ -56,3 +56,3 @@ Perform a request in json format. | ||
| `method` | `HttpMethods` | The http method. | | ||
| `requestData?` | `T` | Request to send to the endpoint. | | ||
| `request?` | `T` | Request to send to the endpoint. | | ||
@@ -59,0 +59,0 @@ #### Returns |
@@ -25,2 +25,2 @@ # Interface: IAcceptedResponse | ||
Alternative response status code. | ||
Response status code. |
@@ -7,3 +7,3 @@ # Interface: IConflictResponse | ||
- [`IErrorResponse`](IErrorResponse.md) | ||
- [`IErrorResponse`](../modules.md#ierrorresponse) | ||
@@ -22,10 +22,74 @@ ↳ **`IConflictResponse`** | ||
### error | ||
### inner | ||
• `Optional` **error**: `string` | ||
• `Optional` **inner**: `IError` | ||
A message for the response. | ||
The inner error if there was one. | ||
#### Inherited from | ||
[IErrorResponse](IErrorResponse.md).[error](IErrorResponse.md#error) | ||
IErrorResponse.inner | ||
___ | ||
### message | ||
• **message**: `string` | ||
The message for the error. | ||
#### Inherited from | ||
IErrorResponse.message | ||
___ | ||
### name | ||
• **name**: `string` | ||
The name for the error. | ||
#### Inherited from | ||
IErrorResponse.name | ||
___ | ||
### properties | ||
• `Optional` **properties**: `Object` | ||
Any additional information for the error. | ||
#### Index signature | ||
▪ [id: `string`]: `unknown` | ||
#### Inherited from | ||
IErrorResponse.properties | ||
___ | ||
### source | ||
• `Optional` **source**: `string` | ||
The source of the error. | ||
#### Inherited from | ||
IErrorResponse.source | ||
___ | ||
### stack | ||
• `Optional` **stack**: `string` | ||
The stack trace for the error. | ||
#### Inherited from | ||
IErrorResponse.stack |
@@ -25,2 +25,2 @@ # Interface: ICreatedResponse | ||
Alternative response status code. | ||
Response status code. |
@@ -13,7 +13,7 @@ # Interface: IHttpRequest\<T\> | ||
### data | ||
### body | ||
• `Optional` **data**: `T` | ||
• `Optional` **body**: `T` | ||
Data to return as the main payload. | ||
Data to return send as the body. | ||
@@ -38,2 +38,2 @@ ___ | ||
Request query parameters. | ||
The query parameters. |
# Interface: IHttpResponse\<T\> | ||
Model used when a REST route wants to return custom response. | ||
Model for the standard parameters for an http response. | ||
@@ -13,5 +13,5 @@ ## Type parameters | ||
### data | ||
### body | ||
• `Optional` **data**: `T` | ||
• `Optional` **body**: `T` | ||
@@ -26,3 +26,3 @@ Data to return as the main payload. | ||
Additional response headers. | ||
Response headers. | ||
@@ -35,2 +35,2 @@ ___ | ||
Alternative response status code. | ||
Response status code. |
@@ -7,3 +7,3 @@ # Interface: INotFoundResponse | ||
- [`IErrorResponse`](IErrorResponse.md) | ||
- [`IErrorResponse`](../modules.md#ierrorresponse) | ||
@@ -14,14 +14,38 @@ ↳ **`INotFoundResponse`** | ||
### error | ||
### inner | ||
• `Optional` **error**: `string` | ||
• `Optional` **inner**: `IError` | ||
A message for the response. | ||
The inner error if there was one. | ||
#### Inherited from | ||
[IErrorResponse](IErrorResponse.md).[error](IErrorResponse.md#error) | ||
IErrorResponse.inner | ||
___ | ||
### message | ||
• **message**: `string` | ||
The message for the error. | ||
#### Inherited from | ||
IErrorResponse.message | ||
___ | ||
### name | ||
• **name**: `string` | ||
The name for the error. | ||
#### Inherited from | ||
IErrorResponse.name | ||
___ | ||
### notFoundId | ||
@@ -32,1 +56,41 @@ | ||
The id if the item that was not found. | ||
___ | ||
### properties | ||
• `Optional` **properties**: `Object` | ||
Any additional information for the error. | ||
#### Index signature | ||
▪ [id: `string`]: `unknown` | ||
#### Inherited from | ||
IErrorResponse.properties | ||
___ | ||
### source | ||
• `Optional` **source**: `string` | ||
The source of the error. | ||
#### Inherited from | ||
IErrorResponse.source | ||
___ | ||
### stack | ||
• `Optional` **stack**: `string` | ||
The stack trace for the error. | ||
#### Inherited from | ||
IErrorResponse.stack |
@@ -7,3 +7,3 @@ # Interface: IUnprocessableEntityResponse | ||
- [`IErrorResponse`](IErrorResponse.md) | ||
- [`IErrorResponse`](../modules.md#ierrorresponse) | ||
@@ -14,18 +14,82 @@ ↳ **`IUnprocessableEntityResponse`** | ||
### error | ||
### existingId | ||
• `Optional` **error**: `string` | ||
• `Optional` **existingId**: `string` | ||
A message for the response. | ||
The id which caused the unprocessable entity response. | ||
___ | ||
### inner | ||
• `Optional` **inner**: `IError` | ||
The inner error if there was one. | ||
#### Inherited from | ||
[IErrorResponse](IErrorResponse.md).[error](IErrorResponse.md#error) | ||
IErrorResponse.inner | ||
___ | ||
### existingId | ||
### message | ||
• `Optional` **existingId**: `string` | ||
• **message**: `string` | ||
The id which caused the unprocessable entity response. | ||
The message for the error. | ||
#### Inherited from | ||
IErrorResponse.message | ||
___ | ||
### name | ||
• **name**: `string` | ||
The name for the error. | ||
#### Inherited from | ||
IErrorResponse.name | ||
___ | ||
### properties | ||
• `Optional` **properties**: `Object` | ||
Any additional information for the error. | ||
#### Index signature | ||
▪ [id: `string`]: `unknown` | ||
#### Inherited from | ||
IErrorResponse.properties | ||
___ | ||
### source | ||
• `Optional` **source**: `string` | ||
The source of the error. | ||
#### Inherited from | ||
IErrorResponse.source | ||
___ | ||
### stack | ||
• `Optional` **stack**: `string` | ||
The stack trace for the error. | ||
#### Inherited from | ||
IErrorResponse.stack |
@@ -12,3 +12,2 @@ # @gtsc/api-models | ||
- [IAuthConnector](interfaces/IAuthConnector.md) | ||
- [IBadRequestResponse](interfaces/IBadRequestResponse.md) | ||
- [IBaseRestClientConfig](interfaces/IBaseRestClientConfig.md) | ||
@@ -19,4 +18,2 @@ - [IBaseRoute](interfaces/IBaseRoute.md) | ||
- [ICreatedResponse](interfaces/ICreatedResponse.md) | ||
- [IErrorResponse](interfaces/IErrorResponse.md) | ||
- [IForbiddenResponse](interfaces/IForbiddenResponse.md) | ||
- [IHttpRequest](interfaces/IHttpRequest.md) | ||
@@ -26,11 +23,40 @@ - [IHttpRequestContext](interfaces/IHttpRequestContext.md) | ||
- [IHttpResponse](interfaces/IHttpResponse.md) | ||
- [IInternalServerErrorResponse](interfaces/IInternalServerErrorResponse.md) | ||
- [INoContentResponse](interfaces/INoContentResponse.md) | ||
- [INotFoundResponse](interfaces/INotFoundResponse.md) | ||
- [IOkResponse](interfaces/IOkResponse.md) | ||
- [IRestRoute](interfaces/IRestRoute.md) | ||
- [IServiceUnavailableResponse](interfaces/IServiceUnavailableResponse.md) | ||
- [ISocketRoute](interfaces/ISocketRoute.md) | ||
- [ISuccessResponse](interfaces/ISuccessResponse.md) | ||
- [ITag](interfaces/ITag.md) | ||
- [IUnauthorizedResponse](interfaces/IUnauthorizedResponse.md) | ||
- [IUnprocessableEntityResponse](interfaces/IUnprocessableEntityResponse.md) | ||
## Type Aliases | ||
### IBadRequestResponse | ||
Ƭ **IBadRequestResponse**: [`IErrorResponse`](modules.md#ierrorresponse) | ||
Something went wrong with the request see the error field for more details. | ||
___ | ||
### IErrorResponse | ||
Ƭ **IErrorResponse**: `IError` | ||
Response to be used when returning an error. | ||
___ | ||
### IForbiddenResponse | ||
Ƭ **IForbiddenResponse**: [`IErrorResponse`](modules.md#ierrorresponse) | ||
The operation that you tried to perform is not possible, see the error field for more details. | ||
___ | ||
### IUnauthorizedResponse | ||
Ƭ **IUnauthorizedResponse**: [`IErrorResponse`](modules.md#ierrorresponse) | ||
You are not authorized to use the API or no credentials were supplied. |
{ | ||
"name": "@gtsc/api-models", | ||
"version": "0.0.3-next.9", | ||
"version": "0.0.3-next.10", | ||
"description": "Contains models and classes for use with APIs", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67597
55
1019