doboxa-js 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { InvalidRequestDataResponse, ServerErrorResponse } from './types/generated/src/models';\n\n/**\n * Base error class for all Doboxa errors\n */\nexport class DoboxaError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DoboxaError';\n Object.setPrototypeOf(this, DoboxaError.prototype);\n }\n}\n\n/**\n * Error thrown when API returns an error response\n */\nexport class DoboxaAPIError extends DoboxaError {\n public readonly statusCode: number;\n public readonly code?: number;\n public readonly errorMessage?: string;\n public readonly invalidParameters?: Array<{ parameter: string; error_cause: string }>;\n\n constructor(\n statusCode: number,\n message: string,\n body?: InvalidRequestDataResponse | ServerErrorResponse\n ) {\n super(message);\n this.name = 'DoboxaAPIError';\n this.statusCode = statusCode;\n\n if (body) {\n if ('result_code' in body) {\n this.code = body.result_code;\n }\n if ('error_message' in body) {\n this.errorMessage = body.error_message || undefined;\n }\n if ('invalid_parameters' in body && body.invalid_parameters) {\n this.invalidParameters = body.invalid_parameters.map((param) => ({\n parameter: param.parameter,\n error_cause: param.error_cause,\n }));\n }\n }\n\n Object.setPrototypeOf(this, DoboxaAPIError.prototype);\n }\n}\n\n/**\n * Error thrown when authentication fails\n */\nexport class DoboxaAuthenticationError extends DoboxaError {\n constructor(message: string = 'Authentication failed') {\n super(message);\n this.name = 'DoboxaAuthenticationError';\n Object.setPrototypeOf(this, DoboxaAuthenticationError.prototype);\n }\n}\n\n/**\n * Error thrown when request validation fails\n */\nexport class DoboxaValidationError extends DoboxaAPIError {\n constructor(statusCode: number, message: string, body?: InvalidRequestDataResponse) {\n super(statusCode, message, body);\n this.name = 'DoboxaValidationError';\n Object.setPrototypeOf(this, DoboxaValidationError.prototype);\n }\n}\n\n/**\n * Parse error response from API\n */\nexport function parseErrorResponse(\n statusCode: number,\n body: unknown\n): InvalidRequestDataResponse | ServerErrorResponse | undefined {\n if (typeof body === 'object' && body !== null) {\n if ('invalid_parameters' in body || 'error_message' in body) {\n return body as InvalidRequestDataResponse;\n }\n if ('error_message' in body && 'result_code' in body) {\n return body as ServerErrorResponse;\n }\n }\n return undefined;\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAM,cAAN,MAAM,qBAAoB,MAAM;AAAA,EACrC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,aAAY,SAAS;AAAA,EACnD;AACF;AAKO,IAAM,iBAAN,MAAM,wBAAuB,YAAY;AAAA,EAM9C,YACE,YACA,SACA,MACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAElB,QAAI,MAAM;AACR,UAAI,iBAAiB,MAAM;AACzB,aAAK,OAAO,KAAK;AAAA,MACnB;AACA,UAAI,mBAAmB,MAAM;AAC3B,aAAK,eAAe,KAAK,iBAAiB;AAAA,MAC5C;AACA,UAAI,wBAAwB,QAAQ,KAAK,oBAAoB;AAC3D,aAAK,oBAAoB,KAAK,mBAAmB,IAAI,CAAC,WAAW;AAAA,UAC/D,WAAW,MAAM;AAAA,UACjB,aAAa,MAAM;AAAA,QACrB,EAAE;AAAA,MACJ;AAAA,IACF;AAEA,WAAO,eAAe,MAAM,gBAAe,SAAS;AAAA,EACtD;AACF;AAKO,IAAM,4BAAN,MAAM,mCAAkC,YAAY;AAAA,EACzD,YAAY,UAAkB,yBAAyB;AACrD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA0B,SAAS;AAAA,EACjE;AACF;AAKO,IAAM,wBAAN,MAAM,+BAA8B,eAAe;AAAA,EACxD,YAAY,YAAoB,SAAiB,MAAmC;AAClF,UAAM,YAAY,SAAS,IAAI;AAC/B,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAsB,SAAS;AAAA,EAC7D;AACF;AAKO,SAAS,mBACd,YACA,MAC8D;AAC9D,MAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC7C,QAAI,wBAAwB,QAAQ,mBAAmB,MAAM;AAC3D,aAAO;AAAA,IACT;AACA,QAAI,mBAAmB,QAAQ,iBAAiB,MAAM;AACpD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}