Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
fix: prevent MWSApiError from being exported
Browse files Browse the repository at this point in the history
  • Loading branch information
moltar authored and Roman committed May 21, 2020
1 parent b6af7b8 commit 4328a18
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 57 deletions.
56 changes: 56 additions & 0 deletions src/error-codec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Codec, exactly, oneOf, optional, string } from 'purify-ts/Codec'

export const MWSApiError = Codec.interface({
ErrorResponse: Codec.interface({
Error: Codec.interface({
Type: string,
Code: oneOf(
([
'InputStreamDisconnected',
'InvalidParameterValue',
'AccessDenied',
'InvalidAccessKeyId',
'SignatureDoesNotMatch',
'InvalidAddress',
'InternalError',
'Internal Error',
'QuotaExceeded',
'RequestThrottled',
'ResourceNotFound',
'ScheduledPackageAlreadyExists',
'RegionNotSupported',
'ScheduleWindowExpired',
'InvalidOrderState',
'PickupSlotNotAvailable',
'AccessToFeedProcessingResultDenied',
'ContentMD5Missing',
'ContentMD5DoesNotMatch',
'FeedCanceled',
'FeedProcessingResultNoLongerAvailable',
'FeedProcessingResultNotReady',
'InputDataError',
'InvalidFeedSubmissionId',
'InvalidFeedType',
'InvalidRequest',
'NonRetriableInternalError',
'RetriableInternalError',
'AccessToReportDenied',
'InvalidReportId',
'InvalidReportType',
'InvalidScheduleFrequency',
'ReportNoLongerAvailable',
'ReportNotReady',
'DependencyFatalException',
'DependencyRetriableException',
'DependencyUnauthorizedException',
'InternalErrorFatalException',
'InvalidInputFatalException',
] as const).map((element) => exactly(element)),
),
Message: string,
Detail: optional(string),
}),
RequestID: optional(string),
RequestId: optional(string),
}),
})
59 changes: 3 additions & 56 deletions src/error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable max-classes-per-file */
import { Codec, exactly, GetInterface, oneOf, optional, string } from 'purify-ts/Codec'
import { GetInterface } from 'purify-ts/Codec'
import { ExtendableError } from 'ts-error'

import { MWSApiError } from './error-codec'

export class MWSError extends ExtendableError {}

export class HttpError extends MWSError {
Expand Down Expand Up @@ -66,61 +68,6 @@ export class InvalidInputFatalException extends HttpError {}
export class ParsingError extends MWSError {}
/* eslint-enable max-classes-per-file */

export const MWSApiError = Codec.interface({
ErrorResponse: Codec.interface({
Error: Codec.interface({
Type: string,
Code: oneOf(
([
'InputStreamDisconnected',
'InvalidParameterValue',
'AccessDenied',
'InvalidAccessKeyId',
'SignatureDoesNotMatch',
'InvalidAddress',
'InternalError',
'Internal Error',
'QuotaExceeded',
'RequestThrottled',
'ResourceNotFound',
'ScheduledPackageAlreadyExists',
'RegionNotSupported',
'ScheduleWindowExpired',
'InvalidOrderState',
'PickupSlotNotAvailable',
'AccessToFeedProcessingResultDenied',
'ContentMD5Missing',
'ContentMD5DoesNotMatch',
'FeedCanceled',
'FeedProcessingResultNoLongerAvailable',
'FeedProcessingResultNotReady',
'InputDataError',
'InvalidFeedSubmissionId',
'InvalidFeedType',
'InvalidRequest',
'NonRetriableInternalError',
'RetriableInternalError',
'AccessToReportDenied',
'InvalidReportId',
'InvalidReportType',
'InvalidScheduleFrequency',
'ReportNoLongerAvailable',
'ReportNotReady',
'DependencyFatalException',
'DependencyRetriableException',
'DependencyUnauthorizedException',
'InternalErrorFatalException',
'InvalidInputFatalException',
] as const).map((element) => exactly(element)),
),
Message: string,
Detail: optional(string),
}),
RequestID: optional(string),
RequestId: optional(string),
}),
})

type MWSApiError = GetInterface<typeof MWSApiError>

export const enhanceError = (error: HttpError, response: MWSApiError): HttpError => {
Expand Down
2 changes: 1 addition & 1 deletion src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
InvalidRequest,
InvalidScheduleFrequency,
InvalidUPCIdentifier,
MWSApiError,
NonRetriableInternalError,
PickupSlotNotAvailable,
QuotaExceeded,
Expand All @@ -46,6 +45,7 @@ import {
ScheduleWindowExpired,
SignatureDoesNotMatch,
} from './error'
import { MWSApiError } from './error-codec'
import { sign } from './sign'

export interface MWSOptions {
Expand Down

0 comments on commit 4328a18

Please sign in to comment.