@monocloud/management-core 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  * The MonoCloud Exception
6
6
  * @export
7
7
  * @class MonoCloudException
8
+ * @hideconstructor
8
9
  */
9
10
  var MonoCloudException = class extends Error {};
10
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/exceptions/monocloud-exception.ts","../src/exceptions/monocloud-request-exception.ts","../src/exceptions/monocloud-bad-request-exception.ts","../src/exceptions/monocloud-conflict-exception.ts","../src/exceptions/monocloud-identity-validation-exception.ts","../src/exceptions/monocloud-forbidden-exception.ts","../src/exceptions/monocloud-key-validation-exception.ts","../src/exceptions/monocloud-model-state-exception.ts","../src/exceptions/monocloud-not-found-exception.ts","../src/exceptions/monocloud-resource-exhausted-exception.ts","../src/exceptions/monocloud-server-exception.ts","../src/exceptions/monocloud-unauthorized-exception.ts","../src/exceptions/monocloud-payment-required-exception.ts","../src/models/identity-error.ts","../src/models/problem-details.ts","../src/models/identity-validation-problem-details.ts","../src/models/key-validation-problem-details.ts","../src/models/monocloud-response.ts","../src/models/monocloud-page-response.ts","../src/exceptions/validation-exception-types.ts","../src/exceptions/monocloud-exception-handler.ts","../src/base/monocloud-client-base.ts"],"sourcesContent":["/**\n * The MonoCloud Exception\n * @export\n * @class MonoCloudException\n */\nexport class MonoCloudException extends Error {}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudException } from './monocloud-exception';\n\nexport class MonoCloudRequestException extends MonoCloudException {\n /**\n * The problem details received from the server.\n * @type {ProblemDetails}\n * @memberof MonoCloudRequestException\n */\n response?: ProblemDetails;\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n * @param message - The error message.\n */\n constructor(response: ProblemDetails, message: string);\n\n constructor(...args: [ProblemDetails, string] | [ProblemDetails] | [string]) {\n let problemDetails: ProblemDetails | undefined;\n let errorMessage: string | undefined;\n\n if (Array.isArray(args)) {\n if (args.length === 2) {\n problemDetails = args[0];\n errorMessage = args[1];\n } else if (args.length === 1 && typeof args[0] === 'string') {\n errorMessage = args[0];\n } else if (args.length === 1 && typeof args[0] === 'object') {\n problemDetails = args[0];\n errorMessage = args[0].title;\n } else {\n throw new Error('Invalid arguments in constructor');\n }\n }\n\n if (!errorMessage) {\n throw new Error('Invalid error message');\n }\n\n super(errorMessage);\n this.response = problemDetails;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Bad Request Exception\n * @export\n * @class MonoCloudBadRequestException\n */\nexport class MonoCloudBadRequestException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Conflict Exception\n * @export\n * @class MonoCloudConflictException\n */\nexport class MonoCloudConflictException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudConflictException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudConflictException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { IdentityError } from '../models/identity-error';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Identity Validation Exception\n * @export\n * @class MonoCloudIdentityValidationException\n */\nexport class MonoCloudIdentityValidationException extends MonoCloudRequestException {\n errors: IdentityError[];\n\n /**\n * Initializes the MonoCloudIdentityValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: IdentityValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Forbidden Exception\n * @export\n * @class MonoCloudForbiddenException\n */\nexport class MonoCloudForbiddenException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Key Validation Exception\n * @export\n * @class MonoCloudKeyValidationException\n */\nexport class MonoCloudKeyValidationException extends MonoCloudRequestException {\n errors: Record<string, string[]>;\n\n /**\n * Initializes the MonoCloudKeyValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: KeyValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Model State Exception\n * @export\n * @class MonoCloudModelStateException\n */\nexport class MonoCloudModelStateException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Not Found Exception\n * @export\n * @class MonoCloudNotFoundException\n */\nexport class MonoCloudNotFoundException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Resource Exhausted Exception\n * @export\n * @class MonoCloudResourceExhaustedException\n */\nexport class MonoCloudResourceExhaustedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Server Exception\n * @export\n * @class MonoCloudServerException\n */\nexport class MonoCloudServerException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudServerException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudServerException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Unauthorized Exception\n * @export\n * @class MonoCloudUnauthorizedException\n */\nexport class MonoCloudUnauthorizedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Payment Required Exception\n * @export\n * @class MonoCloudPaymentRequiredException\n */\nexport class MonoCloudPaymentRequiredException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","/**\n * Identity Error: Represents a validation or processing error returned by the identity system.\n * @export\n * @class IdentityError\n */\nexport class IdentityError {\n /**\n * Machine-readable error code.\n * @type {string}\n * @memberof IdentityError\n */\n code: string;\n\n /**\n * Human-readable description of the error.\n * @type {string}\n * @memberof IdentityError\n */\n description: string;\n\n constructor(code: string, description: string) {\n this.code = code;\n this.description = description;\n }\n}\n","/**\n * The Problem Details\n * @export\n * @class ProblemDetails\n */\nexport class ProblemDetails {\n /**\n * The type of error\n * @type {string}\n * @memberof ProblemDetails\n */\n type: string;\n\n /**\n * The title of the error\n * @type {string}\n * @memberof ProblemDetails\n */\n title: string;\n\n /**\n * The status code representing the error\n * @type {number}\n * @memberof ProblemDetails\n */\n status: number;\n\n /**\n * The error details\n * @type {string}\n * @memberof ProblemDetails\n */\n detail: string;\n\n /**\n * The instance\n * @type {string}\n * @memberof ProblemDetails\n */\n instance: string;\n\n /**\n * Additional data about the error\n */\n\n [key: string]: any;\n\n constructor(response: ProblemDetails) {\n this.type = response.type;\n this.title = response.title;\n this.status = response.status;\n this.detail = response.detail;\n this.instance = response.instance;\n Object.keys(response)\n .filter(\n x => x !== 'type' && x !== 'title' && x !== 'status' && x !== 'instance'\n )\n .forEach(key => {\n this[key] = response[key];\n });\n }\n}\n","import { IdentityError } from './identity-error';\nimport { ProblemDetails } from './problem-details';\n\nexport class IdentityValidationProblemDetails extends ProblemDetails {\n errors: IdentityError[];\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = (response.errors as IdentityError[]).map(\n err => new IdentityError(err.code, err.description)\n );\n }\n}\n","import { ProblemDetails } from './problem-details';\n\n/**\n * The Key Validation Problem Details\n * @export\n * @class KeyValidationProblemDetails\n */\nexport class KeyValidationProblemDetails extends ProblemDetails {\n /**\n * A collection of errors\n * @type {Record<string, string[]>}\n * @memberof KeyValidationProblemDetails\n */\n errors: Record<string, string[]>;\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = response.errors;\n }\n}\n","export class MonoCloudResponse<TResult = unknown> {\n status: number;\n\n headers: Record<string, any>;\n\n result: TResult;\n\n constructor(status: number, headers: Record<string, any>, result: TResult) {\n this.status = status;\n this.headers = headers;\n this.result = result;\n }\n}\n","import { MonoCloudResponse } from './monocloud-response';\nimport { PageModel } from './page-model';\n\nexport class MonoCloudPageResponse<\n TResult = unknown,\n> extends MonoCloudResponse<TResult> {\n pageData: PageModel;\n\n constructor(\n status: number,\n headers: Record<string, any>,\n result: TResult,\n pageData: PageModel\n ) {\n super(status, headers, result);\n this.pageData = pageData;\n }\n}\n","export const ValidationExceptionTypes = {\n ValidationError: 'https://httpstatuses.io/422#validation-error',\n IdentityValidationError:\n 'https://httpstatuses.io/422#identity-validation-error',\n};\n","import { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudBadRequestException } from './monocloud-bad-request-exception';\nimport { MonoCloudConflictException } from './monocloud-conflict-exception';\nimport { MonoCloudIdentityValidationException } from './monocloud-identity-validation-exception';\nimport { MonoCloudException } from './monocloud-exception';\nimport { MonoCloudKeyValidationException } from './monocloud-key-validation-exception';\nimport { MonoCloudModelStateException } from './monocloud-model-state-exception';\nimport { MonoCloudNotFoundException } from './monocloud-not-found-exception';\nimport { MonoCloudResourceExhaustedException } from './monocloud-resource-exhausted-exception';\nimport { MonoCloudServerException } from './monocloud-server-exception';\nimport { MonoCloudUnauthorizedException } from './monocloud-unauthorized-exception';\nimport { MonoCloudPaymentRequiredException } from './monocloud-payment-required-exception';\nimport { MonoCloudForbiddenException } from './monocloud-forbidden-exception';\n\n/**\n * The MonoCloud Exception Handler\n * @export\n * @class MonoCloudExceptionHandler\n */\nexport class MonoCloudExceptionHandler {\n /**\n * Converts the Problem Details returned from the server into an exception\n * @param problemDetails - The problem details returned from the server.\n */\n public static ThrowProblemErr(problemDetails: ProblemDetails): void {\n switch (problemDetails.status) {\n case 400:\n throw new MonoCloudBadRequestException(problemDetails);\n case 401:\n throw new MonoCloudUnauthorizedException(problemDetails);\n case 402:\n throw new MonoCloudPaymentRequiredException(problemDetails);\n case 403:\n throw new MonoCloudForbiddenException(problemDetails);\n case 404:\n throw new MonoCloudNotFoundException(problemDetails);\n case 409:\n throw new MonoCloudConflictException(problemDetails);\n case 422:\n if (problemDetails instanceof IdentityValidationProblemDetails) {\n throw new MonoCloudIdentityValidationException(problemDetails);\n }\n\n if (problemDetails instanceof KeyValidationProblemDetails) {\n throw new MonoCloudKeyValidationException(problemDetails);\n }\n\n throw new MonoCloudModelStateException(problemDetails);\n case 429:\n throw new MonoCloudResourceExhaustedException(problemDetails);\n case 500:\n throw new MonoCloudServerException(problemDetails);\n default:\n throw new MonoCloudException(\n problemDetails.title ?? 'An Unknown Error Occured'\n );\n }\n }\n\n /**\n * Converts the error returned from the server into an exception\n * @param statusCode - The response status code.\n * @param message - The error message returned from the server.\n */\n public static ThrowErr(statusCode: number, message?: string): void {\n switch (statusCode) {\n case 400:\n throw new MonoCloudBadRequestException(message ?? 'Bad Request');\n case 401:\n throw new MonoCloudUnauthorizedException(message ?? 'Unauthorized');\n case 402:\n throw new MonoCloudPaymentRequiredException(\n message ?? 'Payment Required'\n );\n case 403:\n throw new MonoCloudForbiddenException(message ?? 'Forbidden');\n case 404:\n throw new MonoCloudNotFoundException(message ?? 'Not Found');\n case 409:\n throw new MonoCloudConflictException(message ?? 'Conflict');\n case 422:\n throw new MonoCloudModelStateException(\n message ?? 'Unprocessable entity'\n );\n case 429:\n throw new MonoCloudResourceExhaustedException(\n message ?? 'Resource Exhausted'\n );\n case 500:\n throw new MonoCloudServerException(message ?? 'Server Error');\n default:\n throw new MonoCloudException(message ?? 'An Unknown Error Occured');\n }\n }\n}\n","import { MonoCloudConfig } from './monocloud-config';\nimport { MonoCloudResponse } from '../models/monocloud-response';\nimport { MonoCloudException } from '../exceptions/monocloud-exception';\nimport { MonoCloudPageResponse } from '../models/monocloud-page-response';\nimport { PageModel } from '../models/page-model';\nimport { ProblemDetails } from '../models/problem-details';\nimport { ValidationExceptionTypes } from '../exceptions/validation-exception-types';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudExceptionHandler } from '../exceptions/monocloud-exception-handler';\nimport { MonoCloudRequest } from '../models/monocloud-request';\nimport { Fetcher } from '../models/fetcher';\n\nexport abstract class MonoCloudClientBase {\n protected fetcher: Fetcher;\n\n constructor(configuration: MonoCloudConfig, fetcher?: Fetcher) {\n if (fetcher) {\n this.fetcher = fetcher;\n } else {\n if (!configuration) {\n throw new MonoCloudException('Configuration is required');\n }\n\n if (!configuration.domain) {\n throw new MonoCloudException('Tenant Domain is required');\n }\n\n if (!configuration.apiKey) {\n throw new MonoCloudException('Api Key is required');\n }\n\n const headers: Record<string, string> = {\n 'X-API-KEY': configuration.apiKey,\n 'Content-Type': 'application/json',\n };\n\n const baseUrl = `${this.sanitizeUrl(configuration.domain)}/api/`;\n\n this.fetcher = async (\n input: string | URL,\n init?: RequestInit\n ): Promise<Response> => {\n const url = new URL(input, baseUrl);\n\n const signal = AbortSignal.timeout(\n configuration.config?.timeout ?? 10000\n );\n signal.throwIfAborted();\n\n const resp = await fetch(url.toString(), { ...init, headers, signal });\n\n return resp;\n };\n }\n }\n\n protected async processRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const resp = response.body ? await response.text() : null;\n\n return new MonoCloudResponse<T>(\n response.status,\n headers,\n (resp?.length ? JSON.parse(resp) : null) as T\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n protected async processPaginatedRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudPageResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const paginationData = this.resolvePaginationHeader(response.headers);\n\n return new MonoCloudPageResponse<T>(\n response.status,\n headers,\n (response.body ? await response.json() : null) as T,\n paginationData\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n private async HandleErrorResponse(response: Response): Promise<void> {\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith('application/problem+json')) {\n const body = await response.json();\n let result = body\n ? new ProblemDetails(body as ProblemDetails)\n : undefined;\n\n if (result?.type === ValidationExceptionTypes.IdentityValidationError) {\n result = new IdentityValidationProblemDetails(result);\n }\n\n if (result?.type === ValidationExceptionTypes.ValidationError) {\n result = new KeyValidationProblemDetails(result);\n }\n\n if (!result) {\n throw new MonoCloudException('Invalid body');\n }\n\n MonoCloudExceptionHandler.ThrowProblemErr(result);\n }\n\n const respStrng = await response.text();\n MonoCloudExceptionHandler.ThrowErr(\n response.status,\n respStrng && respStrng !== '' ? respStrng : response.statusText\n );\n }\n\n private sanitizeUrl(url: string): string {\n let u = url;\n if (!u.startsWith('https://')) {\n u = `https://${u}`;\n }\n\n if (u.endsWith('/')) {\n u = u.substring(0, u.length - 1);\n }\n\n return u;\n }\n\n private resolvePaginationHeader(headers: Headers): PageModel {\n const paginationHeader = headers.get('x-pagination');\n const pageData = paginationHeader\n ? JSON.parse(paginationHeader)\n : undefined;\n\n return {\n page_size: pageData?.page_size ?? 0,\n current_page: pageData?.current_page ?? 0,\n total_count: pageData?.total_count ?? 0,\n has_previous: pageData?.has_previous ?? false,\n has_next: pageData?.has_next ?? false,\n };\n }\n\n private buildUrl(\n url: string,\n queryParams?: Record<string, string | number | boolean>\n ): string {\n let urlStr = url;\n\n if (urlStr.startsWith('/')) {\n urlStr = urlStr.substring(1, urlStr.length);\n }\n\n if (!queryParams) {\n return urlStr;\n }\n\n urlStr += '?';\n\n Object.keys(queryParams).forEach(key => {\n urlStr += `${key}=${encodeURIComponent(queryParams[key])}&`;\n });\n\n urlStr = urlStr.substring(0, urlStr.length - 1);\n\n return urlStr;\n }\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,qBAAb,cAAwC,MAAM;;;;ACF9C,IAAa,4BAAb,cAA+C,mBAAmB;CA2BhE,YAAY,GAAG,MAA8D;EAC3E,IAAI;EACJ,IAAI;AAEJ,MAAI,MAAM,QAAQ,KAAK,CACrB,KAAI,KAAK,WAAW,GAAG;AACrB,oBAAiB,KAAK;AACtB,kBAAe,KAAK;aACX,KAAK,WAAW,KAAK,OAAO,KAAK,OAAO,SACjD,gBAAe,KAAK;WACX,KAAK,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU;AAC3D,oBAAiB,KAAK;AACtB,kBAAe,KAAK,GAAG;QAEvB,OAAM,IAAI,MAAM,mCAAmC;AAIvD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,wBAAwB;AAG1C,QAAM,aAAa;AACnB,OAAK,WAAW;;;;;;;;;;;AC7CpB,IAAa,+BAAb,cAAkD,0BAA0B;CAa1E,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAAI;MAEV,OAAM,IAAI;;;;;;;;;;;ACjBhB,IAAa,6BAAb,cAAgD,0BAA0B;CAaxE,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAAI;MAEV,OAAM,IAAI;;;;;;;;;;;AChBhB,IAAa,uCAAb,cAA0D,0BAA0B;;;;;CAOlF,YAAY,UAA4C;AACtD,QACE,UACA,GAAG,SAAS,MAAM,KAAK,KAAK,UAAU,SAAS,QAAQ,QAAW,EAAE,GACrE;AACD,OAAK,SAAS,SAAS;;;;;;;;;;;ACb3B,IAAa,8BAAb,cAAiD,0BAA0B;CAazE,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAAI;MAEV,OAAM,IAAI;;;;;;;;;;;ACjBhB,IA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UAAS,OAAO,UAAU,GAAG,OAAO,OAAO;AAG7C,MAAI,CAAC,YACH,QAAO;AAGT,YAAU;AAEV,SAAO,KAAK,YAAY,CAAC,SAAQ,QAAO;AACtC,aAAU,GAAG,IAAI,GAAG,mBAAmB,YAAY,KAAK,CAAC;IACzD;AAEF,WAAS,OAAO,UAAU,GAAG,OAAO,SAAS,EAAE;AAE/C,SAAO"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/exceptions/monocloud-exception.ts","../src/exceptions/monocloud-request-exception.ts","../src/exceptions/monocloud-bad-request-exception.ts","../src/exceptions/monocloud-conflict-exception.ts","../src/exceptions/monocloud-identity-validation-exception.ts","../src/exceptions/monocloud-forbidden-exception.ts","../src/exceptions/monocloud-key-validation-exception.ts","../src/exceptions/monocloud-model-state-exception.ts","../src/exceptions/monocloud-not-found-exception.ts","../src/exceptions/monocloud-resource-exhausted-exception.ts","../src/exceptions/monocloud-server-exception.ts","../src/exceptions/monocloud-unauthorized-exception.ts","../src/exceptions/monocloud-payment-required-exception.ts","../src/models/identity-error.ts","../src/models/problem-details.ts","../src/models/identity-validation-problem-details.ts","../src/models/key-validation-problem-details.ts","../src/models/monocloud-response.ts","../src/models/monocloud-page-response.ts","../src/exceptions/validation-exception-types.ts","../src/exceptions/monocloud-exception-handler.ts","../src/base/monocloud-client-base.ts"],"sourcesContent":["/**\n * The MonoCloud Exception\n * @export\n * @class MonoCloudException\n * @hideconstructor\n */\nexport class MonoCloudException extends Error {}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudException } from './monocloud-exception';\n\nexport class MonoCloudRequestException extends MonoCloudException {\n /**\n * The problem details received from the server.\n * @type {ProblemDetails}\n * @memberof MonoCloudRequestException\n */\n response?: ProblemDetails;\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n * @param message - The error message.\n */\n constructor(response: ProblemDetails, message: string);\n\n constructor(...args: [ProblemDetails, string] | [ProblemDetails] | [string]) {\n let problemDetails: ProblemDetails | undefined;\n let errorMessage: string | undefined;\n\n if (Array.isArray(args)) {\n if (args.length === 2) {\n problemDetails = args[0];\n errorMessage = args[1];\n } else if (args.length === 1 && typeof args[0] === 'string') {\n errorMessage = args[0];\n } else if (args.length === 1 && typeof args[0] === 'object') {\n problemDetails = args[0];\n errorMessage = args[0].title;\n } else {\n throw new Error('Invalid arguments in constructor');\n }\n }\n\n if (!errorMessage) {\n throw new Error('Invalid error message');\n }\n\n super(errorMessage);\n this.response = problemDetails;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Bad Request Exception\n * @export\n * @class MonoCloudBadRequestException\n */\nexport class MonoCloudBadRequestException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Conflict Exception\n * @export\n * @class MonoCloudConflictException\n */\nexport class MonoCloudConflictException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudConflictException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudConflictException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { IdentityError } from '../models/identity-error';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Identity Validation Exception\n * @export\n * @class MonoCloudIdentityValidationException\n */\nexport class MonoCloudIdentityValidationException extends MonoCloudRequestException {\n errors: IdentityError[];\n\n /**\n * Initializes the MonoCloudIdentityValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: IdentityValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Forbidden Exception\n * @export\n * @class MonoCloudForbiddenException\n */\nexport class MonoCloudForbiddenException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Key Validation Exception\n * @export\n * @class MonoCloudKeyValidationException\n */\nexport class MonoCloudKeyValidationException extends MonoCloudRequestException {\n errors: Record<string, string[]>;\n\n /**\n * Initializes the MonoCloudKeyValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: KeyValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Model State Exception\n * @export\n * @class MonoCloudModelStateException\n */\nexport class MonoCloudModelStateException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Not Found Exception\n * @export\n * @class MonoCloudNotFoundException\n */\nexport class MonoCloudNotFoundException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Resource Exhausted Exception\n * @export\n * @class MonoCloudResourceExhaustedException\n */\nexport class MonoCloudResourceExhaustedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Server Exception\n * @export\n * @class MonoCloudServerException\n */\nexport class MonoCloudServerException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudServerException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudServerException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Unauthorized Exception\n * @export\n * @class MonoCloudUnauthorizedException\n */\nexport class MonoCloudUnauthorizedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Payment Required Exception\n * @export\n * @class MonoCloudPaymentRequiredException\n */\nexport class MonoCloudPaymentRequiredException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","/**\n * Identity Error: Represents a validation or processing error returned by the identity system.\n * @export\n * @class IdentityError\n */\nexport class IdentityError {\n /**\n * Machine-readable error code.\n * @type {string}\n * @memberof IdentityError\n */\n code: string;\n\n /**\n * Human-readable description of the error.\n * @type {string}\n * @memberof IdentityError\n */\n description: string;\n\n constructor(code: string, description: string) {\n this.code = code;\n this.description = description;\n }\n}\n","/**\n * The Problem Details\n * @export\n * @class ProblemDetails\n */\nexport class ProblemDetails {\n /**\n * The type of error\n * @type {string}\n * @memberof ProblemDetails\n */\n type: string;\n\n /**\n * The title of the error\n * @type {string}\n * @memberof ProblemDetails\n */\n title: string;\n\n /**\n * The status code representing the error\n * @type {number}\n * @memberof ProblemDetails\n */\n status: number;\n\n /**\n * The error details\n * @type {string}\n * @memberof ProblemDetails\n */\n detail: string;\n\n /**\n * The instance\n * @type {string}\n * @memberof ProblemDetails\n */\n instance: string;\n\n /**\n * Additional data about the error\n */\n\n [key: string]: any;\n\n constructor(response: ProblemDetails) {\n this.type = response.type;\n this.title = response.title;\n this.status = response.status;\n this.detail = response.detail;\n this.instance = response.instance;\n Object.keys(response)\n .filter(\n x => x !== 'type' && x !== 'title' && x !== 'status' && x !== 'instance'\n )\n .forEach(key => {\n this[key] = response[key];\n });\n }\n}\n","import { IdentityError } from './identity-error';\nimport { ProblemDetails } from './problem-details';\n\nexport class IdentityValidationProblemDetails extends ProblemDetails {\n errors: IdentityError[];\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = (response.errors as IdentityError[]).map(\n err => new IdentityError(err.code, err.description)\n );\n }\n}\n","import { ProblemDetails } from './problem-details';\n\n/**\n * The Key Validation Problem Details\n * @export\n * @class KeyValidationProblemDetails\n */\nexport class KeyValidationProblemDetails extends ProblemDetails {\n /**\n * A collection of errors\n * @type {Record<string, string[]>}\n * @memberof KeyValidationProblemDetails\n */\n errors: Record<string, string[]>;\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = response.errors;\n }\n}\n","export class MonoCloudResponse<TResult = unknown> {\n status: number;\n\n headers: Record<string, any>;\n\n result: TResult;\n\n constructor(status: number, headers: Record<string, any>, result: TResult) {\n this.status = status;\n this.headers = headers;\n this.result = result;\n }\n}\n","import { MonoCloudResponse } from './monocloud-response';\nimport { PageModel } from './page-model';\n\nexport class MonoCloudPageResponse<\n TResult = unknown,\n> extends MonoCloudResponse<TResult> {\n pageData: PageModel;\n\n constructor(\n status: number,\n headers: Record<string, any>,\n result: TResult,\n pageData: PageModel\n ) {\n super(status, headers, result);\n this.pageData = pageData;\n }\n}\n","export const ValidationExceptionTypes = {\n ValidationError: 'https://httpstatuses.io/422#validation-error',\n IdentityValidationError:\n 'https://httpstatuses.io/422#identity-validation-error',\n};\n","import { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudBadRequestException } from './monocloud-bad-request-exception';\nimport { MonoCloudConflictException } from './monocloud-conflict-exception';\nimport { MonoCloudIdentityValidationException } from './monocloud-identity-validation-exception';\nimport { MonoCloudException } from './monocloud-exception';\nimport { MonoCloudKeyValidationException } from './monocloud-key-validation-exception';\nimport { MonoCloudModelStateException } from './monocloud-model-state-exception';\nimport { MonoCloudNotFoundException } from './monocloud-not-found-exception';\nimport { MonoCloudResourceExhaustedException } from './monocloud-resource-exhausted-exception';\nimport { MonoCloudServerException } from './monocloud-server-exception';\nimport { MonoCloudUnauthorizedException } from './monocloud-unauthorized-exception';\nimport { MonoCloudPaymentRequiredException } from './monocloud-payment-required-exception';\nimport { MonoCloudForbiddenException } from './monocloud-forbidden-exception';\n\n/**\n * The MonoCloud Exception Handler\n * @export\n * @class MonoCloudExceptionHandler\n */\nexport class MonoCloudExceptionHandler {\n /**\n * Converts the Problem Details returned from the server into an exception\n * @param problemDetails - The problem details returned from the server.\n */\n public static ThrowProblemErr(problemDetails: ProblemDetails): void {\n switch (problemDetails.status) {\n case 400:\n throw new MonoCloudBadRequestException(problemDetails);\n case 401:\n throw new MonoCloudUnauthorizedException(problemDetails);\n case 402:\n throw new MonoCloudPaymentRequiredException(problemDetails);\n case 403:\n throw new MonoCloudForbiddenException(problemDetails);\n case 404:\n throw new MonoCloudNotFoundException(problemDetails);\n case 409:\n throw new MonoCloudConflictException(problemDetails);\n case 422:\n if (problemDetails instanceof IdentityValidationProblemDetails) {\n throw new MonoCloudIdentityValidationException(problemDetails);\n }\n\n if (problemDetails instanceof KeyValidationProblemDetails) {\n throw new MonoCloudKeyValidationException(problemDetails);\n }\n\n throw new MonoCloudModelStateException(problemDetails);\n case 429:\n throw new MonoCloudResourceExhaustedException(problemDetails);\n case 500:\n throw new MonoCloudServerException(problemDetails);\n default:\n throw new MonoCloudException(\n problemDetails.title ?? 'An Unknown Error Occured'\n );\n }\n }\n\n /**\n * Converts the error returned from the server into an exception\n * @param statusCode - The response status code.\n * @param message - The error message returned from the server.\n */\n public static ThrowErr(statusCode: number, message?: string): void {\n switch (statusCode) {\n case 400:\n throw new MonoCloudBadRequestException(message ?? 'Bad Request');\n case 401:\n throw new MonoCloudUnauthorizedException(message ?? 'Unauthorized');\n case 402:\n throw new MonoCloudPaymentRequiredException(\n message ?? 'Payment Required'\n );\n case 403:\n throw new MonoCloudForbiddenException(message ?? 'Forbidden');\n case 404:\n throw new MonoCloudNotFoundException(message ?? 'Not Found');\n case 409:\n throw new MonoCloudConflictException(message ?? 'Conflict');\n case 422:\n throw new MonoCloudModelStateException(\n message ?? 'Unprocessable entity'\n );\n case 429:\n throw new MonoCloudResourceExhaustedException(\n message ?? 'Resource Exhausted'\n );\n case 500:\n throw new MonoCloudServerException(message ?? 'Server Error');\n default:\n throw new MonoCloudException(message ?? 'An Unknown Error Occured');\n }\n }\n}\n","import { MonoCloudConfig } from './monocloud-config';\nimport { MonoCloudResponse } from '../models/monocloud-response';\nimport { MonoCloudException } from '../exceptions/monocloud-exception';\nimport { MonoCloudPageResponse } from '../models/monocloud-page-response';\nimport { PageModel } from '../models/page-model';\nimport { ProblemDetails } from '../models/problem-details';\nimport { ValidationExceptionTypes } from '../exceptions/validation-exception-types';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudExceptionHandler } from '../exceptions/monocloud-exception-handler';\nimport { MonoCloudRequest } from '../models/monocloud-request';\nimport { Fetcher } from '../models/fetcher';\n\nexport abstract class MonoCloudClientBase {\n protected fetcher: Fetcher;\n\n constructor(configuration: MonoCloudConfig, fetcher?: Fetcher) {\n if (fetcher) {\n this.fetcher = fetcher;\n } else {\n if (!configuration) {\n throw new MonoCloudException('Configuration is required');\n }\n\n if (!configuration.domain) {\n throw new MonoCloudException('Tenant Domain is required');\n }\n\n if (!configuration.apiKey) {\n throw new MonoCloudException('Api Key is required');\n }\n\n const headers: Record<string, string> = {\n 'X-API-KEY': configuration.apiKey,\n 'Content-Type': 'application/json',\n };\n\n const baseUrl = `${this.sanitizeUrl(configuration.domain)}/api/`;\n\n this.fetcher = async (\n input: string | URL,\n init?: RequestInit\n ): Promise<Response> => {\n const url = new URL(input, baseUrl);\n\n const signal = AbortSignal.timeout(\n configuration.config?.timeout ?? 10000\n );\n signal.throwIfAborted();\n\n const resp = await fetch(url.toString(), { ...init, headers, signal });\n\n return resp;\n };\n }\n }\n\n protected async processRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const resp = response.body ? await response.text() : null;\n\n return new MonoCloudResponse<T>(\n response.status,\n headers,\n (resp?.length ? JSON.parse(resp) : null) as T\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n protected async processPaginatedRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudPageResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const paginationData = this.resolvePaginationHeader(response.headers);\n\n return new MonoCloudPageResponse<T>(\n response.status,\n headers,\n (response.body ? await response.json() : null) as T,\n paginationData\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n private async HandleErrorResponse(response: Response): Promise<void> {\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith('application/problem+json')) {\n const body = await response.json();\n let result = body\n ? new ProblemDetails(body as ProblemDetails)\n : undefined;\n\n if (result?.type === ValidationExceptionTypes.IdentityValidationError) {\n result = new IdentityValidationProblemDetails(result);\n }\n\n if (result?.type === ValidationExceptionTypes.ValidationError) {\n result = new KeyValidationProblemDetails(result);\n }\n\n if (!result) {\n throw new MonoCloudException('Invalid body');\n }\n\n MonoCloudExceptionHandler.ThrowProblemErr(result);\n }\n\n const respStrng = await response.text();\n MonoCloudExceptionHandler.ThrowErr(\n response.status,\n respStrng && respStrng !== '' ? respStrng : response.statusText\n );\n }\n\n private sanitizeUrl(url: string): string {\n let u = url;\n if (!u.startsWith('https://')) {\n u = `https://${u}`;\n }\n\n if (u.endsWith('/')) {\n u = u.substring(0, u.length - 1);\n }\n\n return u;\n }\n\n private resolvePaginationHeader(headers: Headers): PageModel {\n const paginationHeader = headers.get('x-pagination');\n const pageData = paginationHeader\n ? JSON.parse(paginationHeader)\n : undefined;\n\n return {\n page_size: pageData?.page_size ?? 0,\n current_page: pageData?.current_page ?? 0,\n total_count: pageData?.total_count ?? 0,\n has_previous: pageData?.has_previous ?? false,\n has_next: pageData?.has_next ?? false,\n };\n }\n\n private buildUrl(\n url: string,\n queryParams?: Record<string, string | number | boolean>\n ): string {\n let urlStr = url;\n\n if (urlStr.startsWith('/')) {\n urlStr = urlStr.substring(1, urlStr.length);\n }\n\n if (!queryParams) {\n return urlStr;\n }\n\n urlStr += '?';\n\n Object.keys(queryParams).forEach(key => {\n urlStr += `${key}=${encodeURIComponent(queryParams[key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AAC,YACH,QAAO;AAGT,YAAU;AAEV,SAAO,KAAK,YAAY,CAAC,SAAQ,QAAO;AACtC,aAAU,GAAG,IAAI,GAAG,mBAAmB,YAAY,KAAK,CAAC;IACzD;AAEF,WAAS,OAAO,UAAU,GAAG,OAAO,SAAS,EAAE;AAE/C,SAAO"}
package/dist/index.d.cts CHANGED
@@ -3,6 +3,7 @@
3
3
  * The MonoCloud Exception
4
4
  * @export
5
5
  * @class MonoCloudException
6
+ * @hideconstructor
6
7
  */
7
8
  declare class MonoCloudException extends Error {}
8
9
  //#endregion
package/dist/index.d.mts CHANGED
@@ -3,6 +3,7 @@
3
3
  * The MonoCloud Exception
4
4
  * @export
5
5
  * @class MonoCloudException
6
+ * @hideconstructor
6
7
  */
7
8
  declare class MonoCloudException extends Error {}
8
9
  //#endregion
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@
3
3
  * The MonoCloud Exception
4
4
  * @export
5
5
  * @class MonoCloudException
6
+ * @hideconstructor
6
7
  */
7
8
  var MonoCloudException = class extends Error {};
8
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/exceptions/monocloud-exception.ts","../src/exceptions/monocloud-request-exception.ts","../src/exceptions/monocloud-bad-request-exception.ts","../src/exceptions/monocloud-conflict-exception.ts","../src/exceptions/monocloud-identity-validation-exception.ts","../src/exceptions/monocloud-forbidden-exception.ts","../src/exceptions/monocloud-key-validation-exception.ts","../src/exceptions/monocloud-model-state-exception.ts","../src/exceptions/monocloud-not-found-exception.ts","../src/exceptions/monocloud-resource-exhausted-exception.ts","../src/exceptions/monocloud-server-exception.ts","../src/exceptions/monocloud-unauthorized-exception.ts","../src/exceptions/monocloud-payment-required-exception.ts","../src/models/identity-error.ts","../src/models/problem-details.ts","../src/models/identity-validation-problem-details.ts","../src/models/key-validation-problem-details.ts","../src/models/monocloud-response.ts","../src/models/monocloud-page-response.ts","../src/exceptions/validation-exception-types.ts","../src/exceptions/monocloud-exception-handler.ts","../src/base/monocloud-client-base.ts"],"sourcesContent":["/**\n * The MonoCloud Exception\n * @export\n * @class MonoCloudException\n */\nexport class MonoCloudException extends Error {}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudException } from './monocloud-exception';\n\nexport class MonoCloudRequestException extends MonoCloudException {\n /**\n * The problem details received from the server.\n * @type {ProblemDetails}\n * @memberof MonoCloudRequestException\n */\n response?: ProblemDetails;\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n * @param message - The error message.\n */\n constructor(response: ProblemDetails, message: string);\n\n constructor(...args: [ProblemDetails, string] | [ProblemDetails] | [string]) {\n let problemDetails: ProblemDetails | undefined;\n let errorMessage: string | undefined;\n\n if (Array.isArray(args)) {\n if (args.length === 2) {\n problemDetails = args[0];\n errorMessage = args[1];\n } else if (args.length === 1 && typeof args[0] === 'string') {\n errorMessage = args[0];\n } else if (args.length === 1 && typeof args[0] === 'object') {\n problemDetails = args[0];\n errorMessage = args[0].title;\n } else {\n throw new Error('Invalid arguments in constructor');\n }\n }\n\n if (!errorMessage) {\n throw new Error('Invalid error message');\n }\n\n super(errorMessage);\n this.response = problemDetails;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Bad Request Exception\n * @export\n * @class MonoCloudBadRequestException\n */\nexport class MonoCloudBadRequestException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Conflict Exception\n * @export\n * @class MonoCloudConflictException\n */\nexport class MonoCloudConflictException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudConflictException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudConflictException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { IdentityError } from '../models/identity-error';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Identity Validation Exception\n * @export\n * @class MonoCloudIdentityValidationException\n */\nexport class MonoCloudIdentityValidationException extends MonoCloudRequestException {\n errors: IdentityError[];\n\n /**\n * Initializes the MonoCloudIdentityValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: IdentityValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Forbidden Exception\n * @export\n * @class MonoCloudForbiddenException\n */\nexport class MonoCloudForbiddenException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Key Validation Exception\n * @export\n * @class MonoCloudKeyValidationException\n */\nexport class MonoCloudKeyValidationException extends MonoCloudRequestException {\n errors: Record<string, string[]>;\n\n /**\n * Initializes the MonoCloudKeyValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: KeyValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Model State Exception\n * @export\n * @class MonoCloudModelStateException\n */\nexport class MonoCloudModelStateException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Not Found Exception\n * @export\n * @class MonoCloudNotFoundException\n */\nexport class MonoCloudNotFoundException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Resource Exhausted Exception\n * @export\n * @class MonoCloudResourceExhaustedException\n */\nexport class MonoCloudResourceExhaustedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Server Exception\n * @export\n * @class MonoCloudServerException\n */\nexport class MonoCloudServerException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudServerException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudServerException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Unauthorized Exception\n * @export\n * @class MonoCloudUnauthorizedException\n */\nexport class MonoCloudUnauthorizedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Payment Required Exception\n * @export\n * @class MonoCloudPaymentRequiredException\n */\nexport class MonoCloudPaymentRequiredException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","/**\n * Identity Error: Represents a validation or processing error returned by the identity system.\n * @export\n * @class IdentityError\n */\nexport class IdentityError {\n /**\n * Machine-readable error code.\n * @type {string}\n * @memberof IdentityError\n */\n code: string;\n\n /**\n * Human-readable description of the error.\n * @type {string}\n * @memberof IdentityError\n */\n description: string;\n\n constructor(code: string, description: string) {\n this.code = code;\n this.description = description;\n }\n}\n","/**\n * The Problem Details\n * @export\n * @class ProblemDetails\n */\nexport class ProblemDetails {\n /**\n * The type of error\n * @type {string}\n * @memberof ProblemDetails\n */\n type: string;\n\n /**\n * The title of the error\n * @type {string}\n * @memberof ProblemDetails\n */\n title: string;\n\n /**\n * The status code representing the error\n * @type {number}\n * @memberof ProblemDetails\n */\n status: number;\n\n /**\n * The error details\n * @type {string}\n * @memberof ProblemDetails\n */\n detail: string;\n\n /**\n * The instance\n * @type {string}\n * @memberof ProblemDetails\n */\n instance: string;\n\n /**\n * Additional data about the error\n */\n\n [key: string]: any;\n\n constructor(response: ProblemDetails) {\n this.type = response.type;\n this.title = response.title;\n this.status = response.status;\n this.detail = response.detail;\n this.instance = response.instance;\n Object.keys(response)\n .filter(\n x => x !== 'type' && x !== 'title' && x !== 'status' && x !== 'instance'\n )\n .forEach(key => {\n this[key] = response[key];\n });\n }\n}\n","import { IdentityError } from './identity-error';\nimport { ProblemDetails } from './problem-details';\n\nexport class IdentityValidationProblemDetails extends ProblemDetails {\n errors: IdentityError[];\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = (response.errors as IdentityError[]).map(\n err => new IdentityError(err.code, err.description)\n );\n }\n}\n","import { ProblemDetails } from './problem-details';\n\n/**\n * The Key Validation Problem Details\n * @export\n * @class KeyValidationProblemDetails\n */\nexport class KeyValidationProblemDetails extends ProblemDetails {\n /**\n * A collection of errors\n * @type {Record<string, string[]>}\n * @memberof KeyValidationProblemDetails\n */\n errors: Record<string, string[]>;\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = response.errors;\n }\n}\n","export class MonoCloudResponse<TResult = unknown> {\n status: number;\n\n headers: Record<string, any>;\n\n result: TResult;\n\n constructor(status: number, headers: Record<string, any>, result: TResult) {\n this.status = status;\n this.headers = headers;\n this.result = result;\n }\n}\n","import { MonoCloudResponse } from './monocloud-response';\nimport { PageModel } from './page-model';\n\nexport class MonoCloudPageResponse<\n TResult = unknown,\n> extends MonoCloudResponse<TResult> {\n pageData: PageModel;\n\n constructor(\n status: number,\n headers: Record<string, any>,\n result: TResult,\n pageData: PageModel\n ) {\n super(status, headers, result);\n this.pageData = pageData;\n }\n}\n","export const ValidationExceptionTypes = {\n ValidationError: 'https://httpstatuses.io/422#validation-error',\n IdentityValidationError:\n 'https://httpstatuses.io/422#identity-validation-error',\n};\n","import { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudBadRequestException } from './monocloud-bad-request-exception';\nimport { MonoCloudConflictException } from './monocloud-conflict-exception';\nimport { MonoCloudIdentityValidationException } from './monocloud-identity-validation-exception';\nimport { MonoCloudException } from './monocloud-exception';\nimport { MonoCloudKeyValidationException } from './monocloud-key-validation-exception';\nimport { MonoCloudModelStateException } from './monocloud-model-state-exception';\nimport { MonoCloudNotFoundException } from './monocloud-not-found-exception';\nimport { MonoCloudResourceExhaustedException } from './monocloud-resource-exhausted-exception';\nimport { MonoCloudServerException } from './monocloud-server-exception';\nimport { MonoCloudUnauthorizedException } from './monocloud-unauthorized-exception';\nimport { MonoCloudPaymentRequiredException } from './monocloud-payment-required-exception';\nimport { MonoCloudForbiddenException } from './monocloud-forbidden-exception';\n\n/**\n * The MonoCloud Exception Handler\n * @export\n * @class MonoCloudExceptionHandler\n */\nexport class MonoCloudExceptionHandler {\n /**\n * Converts the Problem Details returned from the server into an exception\n * @param problemDetails - The problem details returned from the server.\n */\n public static ThrowProblemErr(problemDetails: ProblemDetails): void {\n switch (problemDetails.status) {\n case 400:\n throw new MonoCloudBadRequestException(problemDetails);\n case 401:\n throw new MonoCloudUnauthorizedException(problemDetails);\n case 402:\n throw new MonoCloudPaymentRequiredException(problemDetails);\n case 403:\n throw new MonoCloudForbiddenException(problemDetails);\n case 404:\n throw new MonoCloudNotFoundException(problemDetails);\n case 409:\n throw new MonoCloudConflictException(problemDetails);\n case 422:\n if (problemDetails instanceof IdentityValidationProblemDetails) {\n throw new MonoCloudIdentityValidationException(problemDetails);\n }\n\n if (problemDetails instanceof KeyValidationProblemDetails) {\n throw new MonoCloudKeyValidationException(problemDetails);\n }\n\n throw new MonoCloudModelStateException(problemDetails);\n case 429:\n throw new MonoCloudResourceExhaustedException(problemDetails);\n case 500:\n throw new MonoCloudServerException(problemDetails);\n default:\n throw new MonoCloudException(\n problemDetails.title ?? 'An Unknown Error Occured'\n );\n }\n }\n\n /**\n * Converts the error returned from the server into an exception\n * @param statusCode - The response status code.\n * @param message - The error message returned from the server.\n */\n public static ThrowErr(statusCode: number, message?: string): void {\n switch (statusCode) {\n case 400:\n throw new MonoCloudBadRequestException(message ?? 'Bad Request');\n case 401:\n throw new MonoCloudUnauthorizedException(message ?? 'Unauthorized');\n case 402:\n throw new MonoCloudPaymentRequiredException(\n message ?? 'Payment Required'\n );\n case 403:\n throw new MonoCloudForbiddenException(message ?? 'Forbidden');\n case 404:\n throw new MonoCloudNotFoundException(message ?? 'Not Found');\n case 409:\n throw new MonoCloudConflictException(message ?? 'Conflict');\n case 422:\n throw new MonoCloudModelStateException(\n message ?? 'Unprocessable entity'\n );\n case 429:\n throw new MonoCloudResourceExhaustedException(\n message ?? 'Resource Exhausted'\n );\n case 500:\n throw new MonoCloudServerException(message ?? 'Server Error');\n default:\n throw new MonoCloudException(message ?? 'An Unknown Error Occured');\n }\n }\n}\n","import { MonoCloudConfig } from './monocloud-config';\nimport { MonoCloudResponse } from '../models/monocloud-response';\nimport { MonoCloudException } from '../exceptions/monocloud-exception';\nimport { MonoCloudPageResponse } from '../models/monocloud-page-response';\nimport { PageModel } from '../models/page-model';\nimport { ProblemDetails } from '../models/problem-details';\nimport { ValidationExceptionTypes } from '../exceptions/validation-exception-types';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudExceptionHandler } from '../exceptions/monocloud-exception-handler';\nimport { MonoCloudRequest } from '../models/monocloud-request';\nimport { Fetcher } from '../models/fetcher';\n\nexport abstract class MonoCloudClientBase {\n protected fetcher: Fetcher;\n\n constructor(configuration: MonoCloudConfig, fetcher?: Fetcher) {\n if (fetcher) {\n this.fetcher = fetcher;\n } else {\n if (!configuration) {\n throw new MonoCloudException('Configuration is required');\n }\n\n if (!configuration.domain) {\n throw new MonoCloudException('Tenant Domain is required');\n }\n\n if (!configuration.apiKey) {\n throw new MonoCloudException('Api Key is required');\n }\n\n const headers: Record<string, string> = {\n 'X-API-KEY': configuration.apiKey,\n 'Content-Type': 'application/json',\n };\n\n const baseUrl = `${this.sanitizeUrl(configuration.domain)}/api/`;\n\n this.fetcher = async (\n input: string | URL,\n init?: RequestInit\n ): Promise<Response> => {\n const url = new URL(input, baseUrl);\n\n const signal = AbortSignal.timeout(\n configuration.config?.timeout ?? 10000\n );\n signal.throwIfAborted();\n\n const resp = await fetch(url.toString(), { ...init, headers, signal });\n\n return resp;\n };\n }\n }\n\n protected async processRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const resp = response.body ? await response.text() : null;\n\n return new MonoCloudResponse<T>(\n response.status,\n headers,\n (resp?.length ? JSON.parse(resp) : null) as T\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n protected async processPaginatedRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudPageResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const paginationData = this.resolvePaginationHeader(response.headers);\n\n return new MonoCloudPageResponse<T>(\n response.status,\n headers,\n (response.body ? await response.json() : null) as T,\n paginationData\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n private async HandleErrorResponse(response: Response): Promise<void> {\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith('application/problem+json')) {\n const body = await response.json();\n let result = body\n ? new ProblemDetails(body as ProblemDetails)\n : undefined;\n\n if (result?.type === ValidationExceptionTypes.IdentityValidationError) {\n result = new IdentityValidationProblemDetails(result);\n }\n\n if (result?.type === ValidationExceptionTypes.ValidationError) {\n result = new KeyValidationProblemDetails(result);\n }\n\n if (!result) {\n throw new MonoCloudException('Invalid body');\n }\n\n MonoCloudExceptionHandler.ThrowProblemErr(result);\n }\n\n const respStrng = await response.text();\n MonoCloudExceptionHandler.ThrowErr(\n response.status,\n respStrng && respStrng !== '' ? respStrng : response.statusText\n );\n }\n\n private sanitizeUrl(url: string): string {\n let u = url;\n if (!u.startsWith('https://')) {\n u = `https://${u}`;\n }\n\n if (u.endsWith('/')) {\n u = u.substring(0, u.length - 1);\n }\n\n return u;\n }\n\n private resolvePaginationHeader(headers: Headers): PageModel {\n const paginationHeader = headers.get('x-pagination');\n const pageData = paginationHeader\n ? JSON.parse(paginationHeader)\n : undefined;\n\n return {\n page_size: pageData?.page_size ?? 0,\n current_page: pageData?.current_page ?? 0,\n total_count: pageData?.total_count ?? 0,\n has_previous: pageData?.has_previous ?? false,\n has_next: pageData?.has_next ?? false,\n };\n }\n\n private buildUrl(\n url: string,\n queryParams?: Record<string, string | number | boolean>\n ): string {\n let urlStr = url;\n\n if (urlStr.startsWith('/')) {\n urlStr = urlStr.substring(1, urlStr.length);\n }\n\n if (!queryParams) {\n return urlStr;\n }\n\n urlStr += '?';\n\n Object.keys(queryParams).forEach(key => {\n urlStr += `${key}=${encodeURIComponent(queryParams[key])}&`;\n });\n\n urlStr = urlStr.substring(0, urlStr.length - 1);\n\n return urlStr;\n }\n}\n"],"mappings":";;;;;;AAKA,IAAa,qBAAb,cAAwC,MAAM;;;;ACF9C,IAAa,4BAAb,cAA+C,mBAAmB;CA2BhE,YAAY,GAAG,MAA8D;EAC3E,IAAI;EACJ,IAAI;AAEJ,MAAI,MAAM,QAAQ,KAAK,CACrB,KAAI,KAAK,WAAW,GAAG;AACrB,oBAAiB,KAAK;AACtB,kBAAe,KAAK;aACX,KAAK,WAAW,KAAK,OAAO,KAAK,OAAO,SACjD,gBAAe,KAAK;WACX,KAAK,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU;AAC3D,oBAAiB,KAAK;AACtB,kBAAe,KAAK,GAAG;QAEvB,OAAM,IAAI,MAAM,mCAAmC;AAIvD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,wBAAwB;AAG1C,QAAM,aAAa;AACnB,OAAK,WAAW;;;;;;;;;;;AC7CpB,IAAa,+BAAb,cAAkD,0BAA0B;CAa1E,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAAI;MAEV,OAAM,IAAI;;;;;;;;;;;ACjBhB,IAAa,6BAAb,cAAgD,0BAA0B;CAaxE,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAA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AAQ,wBAAwB,SAA6B;;EAC3D,MAAM,mBAAmB,QAAQ,IAAI,eAAe;EACpD,MAAM,WAAW,mBACb,KAAK,MAAM,iBAAiB,GAC5B;AAEJ,SAAO;GACL,sFAAW,SAAU,8EAAa;GAClC,2FAAc,SAAU,qFAAgB;GACxC,0FAAa,SAAU,oFAAe;GACtC,2FAAc,SAAU,qFAAgB;GACxC,oFAAU,SAAU,2EAAY;GACjC;;CAGH,AAAQ,SACN,KACA,aACQ;EACR,IAAI,SAAS;AAEb,MAAI,OAAO,WAAW,IAAI,CACxB,UAAS,OAAO,UAAU,GAAG,OAAO,OAAO;AAG7C,MAAI,CAAC,YACH,QAAO;AAGT,YAAU;AAEV,SAAO,KAAK,YAAY,CAAC,SAAQ,QAAO;AACtC,aAAU,GAAG,IAAI,GAAG,mBAAmB,YAAY,KAAK,CAAC;IACzD;AAEF,WAAS,OAAO,UAAU,GAAG,OAAO,SAAS,EAAE;AAE/C,SAAO"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/exceptions/monocloud-exception.ts","../src/exceptions/monocloud-request-exception.ts","../src/exceptions/monocloud-bad-request-exception.ts","../src/exceptions/monocloud-conflict-exception.ts","../src/exceptions/monocloud-identity-validation-exception.ts","../src/exceptions/monocloud-forbidden-exception.ts","../src/exceptions/monocloud-key-validation-exception.ts","../src/exceptions/monocloud-model-state-exception.ts","../src/exceptions/monocloud-not-found-exception.ts","../src/exceptions/monocloud-resource-exhausted-exception.ts","../src/exceptions/monocloud-server-exception.ts","../src/exceptions/monocloud-unauthorized-exception.ts","../src/exceptions/monocloud-payment-required-exception.ts","../src/models/identity-error.ts","../src/models/problem-details.ts","../src/models/identity-validation-problem-details.ts","../src/models/key-validation-problem-details.ts","../src/models/monocloud-response.ts","../src/models/monocloud-page-response.ts","../src/exceptions/validation-exception-types.ts","../src/exceptions/monocloud-exception-handler.ts","../src/base/monocloud-client-base.ts"],"sourcesContent":["/**\n * The MonoCloud Exception\n * @export\n * @class MonoCloudException\n * @hideconstructor\n */\nexport class MonoCloudException extends Error {}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudException } from './monocloud-exception';\n\nexport class MonoCloudRequestException extends MonoCloudException {\n /**\n * The problem details received from the server.\n * @type {ProblemDetails}\n * @memberof MonoCloudRequestException\n */\n response?: ProblemDetails;\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n /**\n * Initializes the MonoCloudRequestException Class\n * @param response - The problem details returned from the server.\n * @param message - The error message.\n */\n constructor(response: ProblemDetails, message: string);\n\n constructor(...args: [ProblemDetails, string] | [ProblemDetails] | [string]) {\n let problemDetails: ProblemDetails | undefined;\n let errorMessage: string | undefined;\n\n if (Array.isArray(args)) {\n if (args.length === 2) {\n problemDetails = args[0];\n errorMessage = args[1];\n } else if (args.length === 1 && typeof args[0] === 'string') {\n errorMessage = args[0];\n } else if (args.length === 1 && typeof args[0] === 'object') {\n problemDetails = args[0];\n errorMessage = args[0].title;\n } else {\n throw new Error('Invalid arguments in constructor');\n }\n }\n\n if (!errorMessage) {\n throw new Error('Invalid error message');\n }\n\n super(errorMessage);\n this.response = problemDetails;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Bad Request Exception\n * @export\n * @class MonoCloudBadRequestException\n */\nexport class MonoCloudBadRequestException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudBadRequestException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Conflict Exception\n * @export\n * @class MonoCloudConflictException\n */\nexport class MonoCloudConflictException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudConflictException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudConflictException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { IdentityError } from '../models/identity-error';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Identity Validation Exception\n * @export\n * @class MonoCloudIdentityValidationException\n */\nexport class MonoCloudIdentityValidationException extends MonoCloudRequestException {\n errors: IdentityError[];\n\n /**\n * Initializes the MonoCloudIdentityValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: IdentityValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Forbidden Exception\n * @export\n * @class MonoCloudForbiddenException\n */\nexport class MonoCloudForbiddenException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudForbiddenException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Key Validation Exception\n * @export\n * @class MonoCloudKeyValidationException\n */\nexport class MonoCloudKeyValidationException extends MonoCloudRequestException {\n errors: Record<string, string[]>;\n\n /**\n * Initializes the MonoCloudKeyValidationException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: KeyValidationProblemDetails) {\n super(\n response,\n `${response.title} : ${JSON.stringify(response.errors, undefined, 2)}`\n );\n this.errors = response.errors;\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Model State Exception\n * @export\n * @class MonoCloudModelStateException\n */\nexport class MonoCloudModelStateException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudModelStateException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Not Found Exception\n * @export\n * @class MonoCloudNotFoundException\n */\nexport class MonoCloudNotFoundException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudNotFoundException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Resource Exhausted Exception\n * @export\n * @class MonoCloudResourceExhaustedException\n */\nexport class MonoCloudResourceExhaustedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudResourceExhaustedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Server Exception\n * @export\n * @class MonoCloudServerException\n */\nexport class MonoCloudServerException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudServerException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudServerException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Unauthorized Exception\n * @export\n * @class MonoCloudUnauthorizedException\n */\nexport class MonoCloudUnauthorizedException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudUnauthorizedException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","import { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudRequestException } from './monocloud-request-exception';\n\n/**\n * The MonoCloud Payment Required Exception\n * @export\n * @class MonoCloudPaymentRequiredException\n */\nexport class MonoCloudPaymentRequiredException extends MonoCloudRequestException {\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param response - The problem details returned from the server.\n */\n constructor(response: ProblemDetails);\n\n /**\n * Initializes the MonoCloudPaymentRequiredException Class\n * @param message - The error message.\n */\n constructor(message: string);\n\n constructor(arg: ProblemDetails | string) {\n if (typeof arg === 'string') {\n super(arg);\n } else {\n super(arg);\n }\n }\n}\n","/**\n * Identity Error: Represents a validation or processing error returned by the identity system.\n * @export\n * @class IdentityError\n */\nexport class IdentityError {\n /**\n * Machine-readable error code.\n * @type {string}\n * @memberof IdentityError\n */\n code: string;\n\n /**\n * Human-readable description of the error.\n * @type {string}\n * @memberof IdentityError\n */\n description: string;\n\n constructor(code: string, description: string) {\n this.code = code;\n this.description = description;\n }\n}\n","/**\n * The Problem Details\n * @export\n * @class ProblemDetails\n */\nexport class ProblemDetails {\n /**\n * The type of error\n * @type {string}\n * @memberof ProblemDetails\n */\n type: string;\n\n /**\n * The title of the error\n * @type {string}\n * @memberof ProblemDetails\n */\n title: string;\n\n /**\n * The status code representing the error\n * @type {number}\n * @memberof ProblemDetails\n */\n status: number;\n\n /**\n * The error details\n * @type {string}\n * @memberof ProblemDetails\n */\n detail: string;\n\n /**\n * The instance\n * @type {string}\n * @memberof ProblemDetails\n */\n instance: string;\n\n /**\n * Additional data about the error\n */\n\n [key: string]: any;\n\n constructor(response: ProblemDetails) {\n this.type = response.type;\n this.title = response.title;\n this.status = response.status;\n this.detail = response.detail;\n this.instance = response.instance;\n Object.keys(response)\n .filter(\n x => x !== 'type' && x !== 'title' && x !== 'status' && x !== 'instance'\n )\n .forEach(key => {\n this[key] = response[key];\n });\n }\n}\n","import { IdentityError } from './identity-error';\nimport { ProblemDetails } from './problem-details';\n\nexport class IdentityValidationProblemDetails extends ProblemDetails {\n errors: IdentityError[];\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = (response.errors as IdentityError[]).map(\n err => new IdentityError(err.code, err.description)\n );\n }\n}\n","import { ProblemDetails } from './problem-details';\n\n/**\n * The Key Validation Problem Details\n * @export\n * @class KeyValidationProblemDetails\n */\nexport class KeyValidationProblemDetails extends ProblemDetails {\n /**\n * A collection of errors\n * @type {Record<string, string[]>}\n * @memberof KeyValidationProblemDetails\n */\n errors: Record<string, string[]>;\n\n constructor(response: ProblemDetails) {\n super(response);\n this.errors = response.errors;\n }\n}\n","export class MonoCloudResponse<TResult = unknown> {\n status: number;\n\n headers: Record<string, any>;\n\n result: TResult;\n\n constructor(status: number, headers: Record<string, any>, result: TResult) {\n this.status = status;\n this.headers = headers;\n this.result = result;\n }\n}\n","import { MonoCloudResponse } from './monocloud-response';\nimport { PageModel } from './page-model';\n\nexport class MonoCloudPageResponse<\n TResult = unknown,\n> extends MonoCloudResponse<TResult> {\n pageData: PageModel;\n\n constructor(\n status: number,\n headers: Record<string, any>,\n result: TResult,\n pageData: PageModel\n ) {\n super(status, headers, result);\n this.pageData = pageData;\n }\n}\n","export const ValidationExceptionTypes = {\n ValidationError: 'https://httpstatuses.io/422#validation-error',\n IdentityValidationError:\n 'https://httpstatuses.io/422#identity-validation-error',\n};\n","import { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { ProblemDetails } from '../models/problem-details';\nimport { MonoCloudBadRequestException } from './monocloud-bad-request-exception';\nimport { MonoCloudConflictException } from './monocloud-conflict-exception';\nimport { MonoCloudIdentityValidationException } from './monocloud-identity-validation-exception';\nimport { MonoCloudException } from './monocloud-exception';\nimport { MonoCloudKeyValidationException } from './monocloud-key-validation-exception';\nimport { MonoCloudModelStateException } from './monocloud-model-state-exception';\nimport { MonoCloudNotFoundException } from './monocloud-not-found-exception';\nimport { MonoCloudResourceExhaustedException } from './monocloud-resource-exhausted-exception';\nimport { MonoCloudServerException } from './monocloud-server-exception';\nimport { MonoCloudUnauthorizedException } from './monocloud-unauthorized-exception';\nimport { MonoCloudPaymentRequiredException } from './monocloud-payment-required-exception';\nimport { MonoCloudForbiddenException } from './monocloud-forbidden-exception';\n\n/**\n * The MonoCloud Exception Handler\n * @export\n * @class MonoCloudExceptionHandler\n */\nexport class MonoCloudExceptionHandler {\n /**\n * Converts the Problem Details returned from the server into an exception\n * @param problemDetails - The problem details returned from the server.\n */\n public static ThrowProblemErr(problemDetails: ProblemDetails): void {\n switch (problemDetails.status) {\n case 400:\n throw new MonoCloudBadRequestException(problemDetails);\n case 401:\n throw new MonoCloudUnauthorizedException(problemDetails);\n case 402:\n throw new MonoCloudPaymentRequiredException(problemDetails);\n case 403:\n throw new MonoCloudForbiddenException(problemDetails);\n case 404:\n throw new MonoCloudNotFoundException(problemDetails);\n case 409:\n throw new MonoCloudConflictException(problemDetails);\n case 422:\n if (problemDetails instanceof IdentityValidationProblemDetails) {\n throw new MonoCloudIdentityValidationException(problemDetails);\n }\n\n if (problemDetails instanceof KeyValidationProblemDetails) {\n throw new MonoCloudKeyValidationException(problemDetails);\n }\n\n throw new MonoCloudModelStateException(problemDetails);\n case 429:\n throw new MonoCloudResourceExhaustedException(problemDetails);\n case 500:\n throw new MonoCloudServerException(problemDetails);\n default:\n throw new MonoCloudException(\n problemDetails.title ?? 'An Unknown Error Occured'\n );\n }\n }\n\n /**\n * Converts the error returned from the server into an exception\n * @param statusCode - The response status code.\n * @param message - The error message returned from the server.\n */\n public static ThrowErr(statusCode: number, message?: string): void {\n switch (statusCode) {\n case 400:\n throw new MonoCloudBadRequestException(message ?? 'Bad Request');\n case 401:\n throw new MonoCloudUnauthorizedException(message ?? 'Unauthorized');\n case 402:\n throw new MonoCloudPaymentRequiredException(\n message ?? 'Payment Required'\n );\n case 403:\n throw new MonoCloudForbiddenException(message ?? 'Forbidden');\n case 404:\n throw new MonoCloudNotFoundException(message ?? 'Not Found');\n case 409:\n throw new MonoCloudConflictException(message ?? 'Conflict');\n case 422:\n throw new MonoCloudModelStateException(\n message ?? 'Unprocessable entity'\n );\n case 429:\n throw new MonoCloudResourceExhaustedException(\n message ?? 'Resource Exhausted'\n );\n case 500:\n throw new MonoCloudServerException(message ?? 'Server Error');\n default:\n throw new MonoCloudException(message ?? 'An Unknown Error Occured');\n }\n }\n}\n","import { MonoCloudConfig } from './monocloud-config';\nimport { MonoCloudResponse } from '../models/monocloud-response';\nimport { MonoCloudException } from '../exceptions/monocloud-exception';\nimport { MonoCloudPageResponse } from '../models/monocloud-page-response';\nimport { PageModel } from '../models/page-model';\nimport { ProblemDetails } from '../models/problem-details';\nimport { ValidationExceptionTypes } from '../exceptions/validation-exception-types';\nimport { IdentityValidationProblemDetails } from '../models/identity-validation-problem-details';\nimport { KeyValidationProblemDetails } from '../models/key-validation-problem-details';\nimport { MonoCloudExceptionHandler } from '../exceptions/monocloud-exception-handler';\nimport { MonoCloudRequest } from '../models/monocloud-request';\nimport { Fetcher } from '../models/fetcher';\n\nexport abstract class MonoCloudClientBase {\n protected fetcher: Fetcher;\n\n constructor(configuration: MonoCloudConfig, fetcher?: Fetcher) {\n if (fetcher) {\n this.fetcher = fetcher;\n } else {\n if (!configuration) {\n throw new MonoCloudException('Configuration is required');\n }\n\n if (!configuration.domain) {\n throw new MonoCloudException('Tenant Domain is required');\n }\n\n if (!configuration.apiKey) {\n throw new MonoCloudException('Api Key is required');\n }\n\n const headers: Record<string, string> = {\n 'X-API-KEY': configuration.apiKey,\n 'Content-Type': 'application/json',\n };\n\n const baseUrl = `${this.sanitizeUrl(configuration.domain)}/api/`;\n\n this.fetcher = async (\n input: string | URL,\n init?: RequestInit\n ): Promise<Response> => {\n const url = new URL(input, baseUrl);\n\n const signal = AbortSignal.timeout(\n configuration.config?.timeout ?? 10000\n );\n signal.throwIfAborted();\n\n const resp = await fetch(url.toString(), { ...init, headers, signal });\n\n return resp;\n };\n }\n }\n\n protected async processRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const resp = response.body ? await response.text() : null;\n\n return new MonoCloudResponse<T>(\n response.status,\n headers,\n (resp?.length ? JSON.parse(resp) : null) as T\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n protected async processPaginatedRequest<T = unknown>(\n request: MonoCloudRequest\n ): Promise<MonoCloudPageResponse<T>> {\n try {\n const url = this.buildUrl(request.url, request.queryParams);\n\n const response = await this.fetcher(url, {\n method: request.method,\n body: request.body ? JSON.stringify(request.body) : undefined,\n });\n\n if (!response.ok) {\n await this.HandleErrorResponse(response);\n }\n\n const headers: Record<string, any> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n const paginationData = this.resolvePaginationHeader(response.headers);\n\n return new MonoCloudPageResponse<T>(\n response.status,\n headers,\n (response.body ? await response.json() : null) as T,\n paginationData\n );\n } catch (e: any) {\n if (e instanceof MonoCloudException) {\n throw e;\n }\n\n if (e.name === 'TimeoutError') {\n throw new MonoCloudException(e.message);\n }\n\n throw new MonoCloudException('Something went wrong.');\n }\n }\n\n private async HandleErrorResponse(response: Response): Promise<void> {\n const contentType = response.headers.get('content-type');\n if (contentType?.startsWith('application/problem+json')) {\n const body = await response.json();\n let result = body\n ? new ProblemDetails(body as ProblemDetails)\n : undefined;\n\n if (result?.type === ValidationExceptionTypes.IdentityValidationError) {\n result = new IdentityValidationProblemDetails(result);\n }\n\n if (result?.type === ValidationExceptionTypes.ValidationError) {\n result = new KeyValidationProblemDetails(result);\n }\n\n if (!result) {\n throw new MonoCloudException('Invalid body');\n }\n\n MonoCloudExceptionHandler.ThrowProblemErr(result);\n }\n\n const respStrng = await response.text();\n MonoCloudExceptionHandler.ThrowErr(\n response.status,\n respStrng && respStrng !== '' ? respStrng : response.statusText\n );\n }\n\n private sanitizeUrl(url: string): string {\n let u = url;\n if (!u.startsWith('https://')) {\n u = `https://${u}`;\n }\n\n if (u.endsWith('/')) {\n u = u.substring(0, u.length - 1);\n }\n\n return u;\n }\n\n private resolvePaginationHeader(headers: Headers): PageModel {\n const paginationHeader = headers.get('x-pagination');\n const pageData = paginationHeader\n ? JSON.parse(paginationHeader)\n : undefined;\n\n return {\n page_size: pageData?.page_size ?? 0,\n current_page: pageData?.current_page ?? 0,\n total_count: pageData?.total_count ?? 0,\n has_previous: pageData?.has_previous ?? false,\n has_next: pageData?.has_next ?? false,\n };\n }\n\n private buildUrl(\n url: string,\n queryParams?: Record<string, string | number | boolean>\n ): string {\n let urlStr = url;\n\n if (urlStr.startsWith('/')) {\n urlStr = urlStr.substring(1, urlStr.length);\n }\n\n if (!queryParams) {\n return urlStr;\n }\n\n urlStr += '?';\n\n Object.keys(queryParams).forEach(key => {\n urlStr += `${key}=${encodeURIComponent(queryParams[key])}&`;\n });\n\n urlStr = urlStr.substring(0, urlStr.length - 1);\n\n return urlStr;\n }\n}\n"],"mappings":";;;;;;;AAMA,IAAa,qBAAb,cAAwC,MAAM;;;;ACH9C,IAAa,4BAAb,cAA+C,mBAAmB;CA2BhE,YAAY,GAAG,MAA8D;EAC3E,IAAI;EACJ,IAAI;AAEJ,MAAI,MAAM,QAAQ,KAAK,CACrB,KAAI,KAAK,WAAW,GAAG;AACrB,oBAAiB,KAAK;AACtB,kBAAe,KAAK;aACX,KAAK,WAAW,KAAK,OAAO,KAAK,OAAO,SACjD,gBAAe,KAAK;WACX,KAAK,WAAW,KAAK,OAAO,KAAK,OAAO,UAAU;AAC3D,oBAAiB,KAAK;AACtB,kBAAe,KAAK,GAAG;QAEvB,OAAM,IAAI,MAAM,mCAAmC;AAIvD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,wBAAwB;AAG1C,QAAM,aAAa;AACnB,OAAK,WAAW;;;;;;;;;;;AC7CpB,IAAa,+BAAb,cAAkD,0BAA0B;CAa1E,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAAI;MAEV,OAAM,IAAI;;;;;;;;;;;ACjBhB,IAAa,6BAAb,cAAgD,0BAA0B;CAaxE,YAAY,KAA8B;AACxC,MAAI,OAAO,QAAQ,SACjB,OAAM,IAAI;MAEV,OAAM,IAAI;;;;;;;;;;;AChBhB,IAAa,uCAAb,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AAI,eAAe;EACpD,MAAM,WAAW,mBACb,KAAK,MAAM,iBAAiB,GAC5B;AAEJ,SAAO;GACL,sFAAW,SAAU,8EAAa;GAClC,2FAAc,SAAU,qFAAgB;GACxC,0FAAa,SAAU,oFAAe;GACtC,2FAAc,SAAU,qFAAgB;GACxC,oFAAU,SAAU,2EAAY;GACjC;;CAGH,AAAQ,SACN,KACA,aACQ;EACR,IAAI,SAAS;AAEb,MAAI,OAAO,WAAW,IAAI,CACxB,UAAS,OAAO,UAAU,GAAG,OAAO,OAAO;AAG7C,MAAI,CAAC,YACH,QAAO;AAGT,YAAU;AAEV,SAAO,KAAK,YAAY,CAAC,SAAQ,QAAO;AACtC,aAAU,GAAG,IAAI,GAAG,mBAAmB,YAAY,KAAK,CAAC;IACzD;AAEF,WAAS,OAAO,UAAU,GAAG,OAAO,SAAS,EAAE;AAE/C,SAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monocloud/management-core",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "MonoCloud Management JavaScript Core Library",
5
5
  "keywords": [
6
6
  "monocloud",
@@ -23,9 +23,17 @@
23
23
  "name": "MonoCloud",
24
24
  "email": "support@monocloud.com"
25
25
  },
26
- "main": "dist/index.cjs",
27
- "module": "dist/index.mjs",
28
- "types": "dist/index.d.mts",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.mjs",
28
+ "types": "./dist/index.d.mts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.mts",
32
+ "import": "./dist/index.mjs",
33
+ "require": "./dist/index.cjs",
34
+ "default": "./dist/index.mjs"
35
+ }
36
+ },
29
37
  "files": [
30
38
  "dist"
31
39
  ],