Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: module not found in @scaleleap/amazon-marketplaces #1025

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'prettier/@typescript-eslint',
'plugin:prettier/recommended'
],
rules: {
'@typescript-eslint/explicit-function-return-type': ['off'],
'@typescript-eslint/camelcase': ['warn', { 'properties': 'always' }],
'explicit-function-return-type': ['off'],
'camelcase': ['warn', { 'properties': 'always' }],
'no-console': [1, { allow: ['warn', 'error'] }],
'curly': 'error'
}
Expand Down
546 changes: 237 additions & 309 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": "tsc --build tsconfig.build.json",
"docs": "typedoc",
"clean": "rimraf lib",
"lint": "eslint --ext .js,.ts src test examples",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint --ext .js,.ts src test examples",
"lint:fix": "npm run lint -- --fix",
"test": "jest",
"api-extractor": "api-extractor run --local --verbose",
Expand All @@ -31,7 +31,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@scaleleap/amazon-marketplaces": "^17.1.0",
"@scaleleap/amazon-marketplaces": "^18.0.1",
"agentkeepalive": "4.5.0",
"axios": "0.28.1",
"client-oauth2": "4.3.3",
Expand All @@ -46,21 +46,21 @@
"ts-error": "1.0.6"
},
"devDependencies": {
"@microsoft/api-extractor": "7.47.1",
"@microsoft/api-extractor": "7.43.4",
"@scaleleap/config": "2.0.8",
"@scaleleap/jest-polly": "1.5.27",
"@scaleleap/semantic-release-config": "1.1.41",
"@types/jest": "27.4.0",
"@types/lodash": "4.17.7",
"@types/node": "16.11.21",
"@types/node": "18.19.50",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
"eslint": "9.9.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.8.0",
"eslint-plugin-prettier": "5.2.1",
"jest": "26.6.3",
"prettier": "2.8.8",
"prettier": "3.3.3",
"rimraf": "3.0.2",
"ts-jest": "26.5.6",
"ts-node": "10.9.2",
Expand Down
5 changes: 4 additions & 1 deletion src/amazon-advertising.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import { Marketplace } from './maketplace'
export class AmazonAdvertising {
private operationProvider: OperationProvider

constructor(private marketplace: Marketplace, private auth: HttpClientAuth) {
constructor(
private marketplace: Marketplace,
private auth: HttpClientAuth,
) {
const httpClient: HttpClient = new HttpClient(marketplace.advertising.region.endpoint, auth)
this.operationProvider = new OperationProvider(httpClient)
}
Expand Down
4 changes: 2 additions & 2 deletions src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Operation } from './operations/operation'
type Descriptor = TypedPropertyDescriptor<any>
type Decoder = t.Mixed

export function Decode(decoder: Decoder): Function {
export function Decode(decoder: Decoder) {
return (target: Operation, propertyKey: string, descriptor: Descriptor) => {
const originalMethod = descriptor.value

Expand All @@ -26,6 +26,6 @@ export function Decode(decoder: Decoder): Function {
}
}

export function DecodeArray(decoder: Decoder): Function {
export function DecodeArray(decoder: Decoder) {
return Decode(t.array(decoder))
}
8 changes: 4 additions & 4 deletions src/http-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { axios, Method, AxiosResponse } from './axios'
import { axios, Method, AxiosResponse, AxiosResponseHeaders } from './axios'
import HttpStatus from 'http-status-codes'

import { JSON_CONTENT_TYPE } from './constants'
Expand All @@ -15,7 +15,7 @@ export interface HttpClientAuth {

export type RequestBody = object | object[]

export type Headers = Record<string, string>
export type Headers = AxiosResponseHeaders

interface HttpClientRequestParams {
method: Method
Expand Down Expand Up @@ -193,7 +193,7 @@ export class HttpClient {
// if any failures are detected
this.handleApiResponse(res)

const location: string | null = res.headers['location']
const location: string | undefined = res.headers['location']
if (res.status !== this.httpStatus.TEMPORARY_REDIRECT || !location) {
throw new InvalidProgramStateError(['Expected a signed URL.', res.statusText].join(' '))
}
Expand All @@ -207,7 +207,7 @@ export class HttpClient {
}

const buffer = Buffer.from(download.data)
const contentType: string = download.headers['content-type']
const contentType: string | undefined = download.headers['content-type']

const bufferToJson = (buf: Buffer): T => {
return JSON.parse(buf.toString())
Expand Down
5 changes: 4 additions & 1 deletion src/o-auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export class OAuthClient {

private client: ClientOAuth2

public constructor(private readonly opts: Options, marketplace: Marketplace) {
public constructor(
private readonly opts: Options,
marketplace: Marketplace,
) {
const amazonOptions = {
accessTokenUri: marketplace.advertising.region.accessTokenUri,
authorizationUri: marketplace.advertising.region.authorizationUri,
Expand Down
2 changes: 1 addition & 1 deletion src/operations/commons/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@scaleleap/amazon-marketplaces'

export class EnumType<A> extends t.Type<A> {
public readonly _tag: 'EnumType' = 'EnumType'
public readonly _tag: 'EnumType' = 'EnumType' as const
public enumObject!: object
public constructor(e: object, name?: string) {
super(
Expand Down
6 changes: 3 additions & 3 deletions src/operations/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type WithOperationParameterKeys<T extends OperationParameter> = {
[K in keyof T]: OperationParameterValues
}

export type OperationParameterTransformer<T> = (
export type OperationParameterTransformer<T extends OperationParameter> = (
originalQuery: T,
clonedQuery: WithOperationParameterKeys<T>,
) => WithOperationParameterKeys<T>
Expand Down Expand Up @@ -49,11 +49,11 @@ export class Operation {
}

// eslint-disable-next-line class-methods-use-this
private hasKey<T>(obj: T, key: string | number | symbol): key is keyof T {
private hasKey<T extends object>(obj: T, key: string | number | symbol): key is keyof T {
return key in obj
}

protected paramsFilterTransformerReal<T>(
protected paramsFilterTransformerReal<T extends OperationParameter>(
params: T,
keys?: string[],
): WithOperationParameterKeys<T> {
Expand Down
4 changes: 2 additions & 2 deletions test/o-auth-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe(OAuthClient.name, () => {
jestPollyContext.polly.server
.post('https://api.amazon.com/auth/o2/token')
.on('beforeResponse', (req, res) => {
/* eslint-disable @typescript-eslint/camelcase */
/* eslint-disable camelcase */
req.body = stringify(
Object.assign(parse(req.body), {
refresh_token: PLACEHOLDER,
Expand All @@ -43,7 +43,7 @@ describe(OAuthClient.name, () => {
refresh_token: PLACEHOLDER,
}),
)
/* eslint-enable @typescript-eslint/camelcase */
/* eslint-enable camelcase */
})
})

Expand Down
Loading