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

Commit

Permalink
Merge pull request #241 from ScaleLeap/renovate/purify-ts-0.x
Browse files Browse the repository at this point in the history
fix(deps): update dependency purify-ts to v0.16.0-beta.6
  • Loading branch information
justinemmanuelmercado committed Nov 7, 2020
2 parents 726d5ea + d71d51f commit 7a1be27
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 67 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"axios": "0.21.0",
"fast-xml-parser": "3.17.4",
"html-entities": "1.3.1",
"purify-ts": "0.16.0-beta.5",
"purify-ts": "0.16.0-beta.6",
"ts-error": "1.0.6"
},
"devDependencies": {
Expand Down
88 changes: 44 additions & 44 deletions src/error-codec.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import { Codec, exactly, oneOf, optional, string } from 'purify-ts/Codec'

export enum CodeEnum {
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,
InvalidReportRequestId,
InvalidReportType,
InvalidScheduleFrequency,
ReportNoLongerAvailable,
ReportNotReady,
DependencyFatalException,
DependencyRetriableException,
DependencyUnauthorizedException,
InternalErrorFatalException,
InvalidInputFatalException,
}

export const 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',
'InvalidReportRequestId',
'InvalidReportType',
'InvalidScheduleFrequency',
'ReportNoLongerAvailable',
'ReportNotReady',
'DependencyFatalException',
'DependencyRetriableException',
'DependencyUnauthorizedException',
'InternalErrorFatalException',
'InvalidInputFatalException',
] as const).map((element) => exactly(element)),
),
Code: oneOf(Object.keys(CodeEnum).map((x) => exactly(x)) as [Codec<string>, ...Codec<string>[]]),
Message: string,
Detail: optional(string),
})
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-classes-per-file */
import { GetInterface } from 'purify-ts/Codec'
import { GetInterface } from 'purify-ts'
import { ExtendableError } from 'ts-error'

import { MWSApiError } from './error-codec'
Expand Down
2 changes: 1 addition & 1 deletion src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class HttpClient {
InvalidInputFatalException: InvalidInputFatalExceptionError,
}

const ErrorToThrow = errorMap[errorCode]
const ErrorToThrow = errorMap[errorCode as keyof typeof errorMap]

throw enhanceError(new ErrorToThrow(`${info.action} request failed`), response)
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/sections/fulfillment-inventory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Codec, exactly, GetInterface, number, oneOf, optional, string } from 'purify-ts'
import { Codec, enumeration, GetInterface, number, optional, string } from 'purify-ts'

import { ParsingError } from '../error'
import { HttpClient, RequestMeta, Resource } from '../http'
Expand Down Expand Up @@ -50,13 +50,13 @@ export enum SupplyType {
}

const Timepoint = Codec.interface({
TimepointType: oneOf(Object.values(TimepointType).map((x) => exactly(x))),
TimepointType: enumeration(TimepointType),
DateTime: optional(mwsDate),
})

const InventorySupplyDetail = Codec.interface({
Quantity: number,
SupplyType: oneOf(Object.values(SupplyType).map((x) => exactly(x))),
SupplyType: enumeration(SupplyType),
EarliestAvailableToPick: Timepoint,
LatestAvailableToPick: Timepoint,
})
Expand All @@ -65,7 +65,7 @@ const InventorySupply = Codec.interface({
SellerSKU: optional(string),
FNSKU: string,
ASIN: optional(ensureString),
Condition: optional(oneOf(Object.values(InventoryCondition).map((x) => exactly(x)))),
Condition: optional(enumeration(InventoryCondition)),
TotalSupplyQuantity: number,
InStockSupplyQuantity: number,
EarliestAvailability: optional(Timepoint),
Expand Down
19 changes: 6 additions & 13 deletions src/sections/orders.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {
boolean,
Codec,
exactly,
enumeration,
GetInterface,
number,
oneOf,
optional,
string,
} from 'purify-ts/Codec'
Expand Down Expand Up @@ -84,17 +83,11 @@ export enum ConditionSubtype {
Other = 'Other',
}

const orderStatus: Codec<OrderStatusEnum> = oneOf(
Object.values(OrderStatusEnum).map((x) => exactly(x)),
)
const fulfillmentChannel: Codec<FulfillmentChannelEnum> = oneOf(
Object.values(FulfillmentChannelEnum).map((x) => exactly(x)),
)
const adddressType: Codec<AddressType> = oneOf(Object.values(AddressType).map((x) => exactly(x)))
const condition: Codec<Condition> = oneOf(Object.values(Condition).map((x) => exactly(x)))
const conditionSubtype: Codec<ConditionSubtype> = oneOf(
Object.values(ConditionSubtype).map((x) => exactly(x)),
)
const orderStatus = enumeration(OrderStatusEnum)
const fulfillmentChannel = enumeration(FulfillmentChannelEnum)
const adddressType = enumeration(AddressType)
const condition = enumeration(Condition)
const conditionSubtype = enumeration(ConditionSubtype)

const Address = Codec.interface({
Name: optional(string),
Expand Down

0 comments on commit 7a1be27

Please sign in to comment.