Skip to content
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
19 changes: 19 additions & 0 deletions fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
#
# Add package.json files to cjs/mjs subtrees
#

cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/esm/package.json <<!EOF
{
"type": "module"
}
!EOF

find src -name '*.d.ts' -exec cp {} dist/cjs \;
find src -name '*.d.ts' -exec cp {} dist/esm \;
12 changes: 6 additions & 6 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
"browser": "./dist/esm/index.js",
"import": "./dist/esm/index.js",
Expand All @@ -33,13 +34,13 @@
"homepage": "https://github.com/playt-net/client#readme",
"scripts": {
"clean": "rimraf './dist'",
"build": "npm run clean && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
"build": "npm run clean && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json && ./fixup",
"generate": "openapi-typescript https://playt-backend-xbwjl.ondigitalocean.app/v3/api-docs --output src/types.ts --prettier-config .prettierrc.json",
"test": "jest",
"typecheck": "tsc --noEmit --project tsconfig.json"
},
"dependencies": {
"openapi-typescript-fetch": "git+https://github.com/ajaishankar/openapi-typescript-fetch.git"
"openapi-typescript-fetch": "git+https://github.com/lmachens/openapi-typescript-fetch.git"
},
"devDependencies": {
"@types/jest": "^27.4.1",
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
ApiError,
import type {
ApiResponse,
Fetcher,
Middleware,
ApiError as ApiErrorType,
} from 'openapi-typescript-fetch';
import { ApiError, Fetcher } from 'openapi-typescript-fetch';

import type { paths, components, operations } from './types';
export type { paths, components, operations, ApiResponse };

export { ApiError };

export type ClientCredentials = {
Expand Down Expand Up @@ -49,7 +51,7 @@ export const PlaytClient = ({
const response = await next(url, init);
return response;
} catch (error) {
const { status } = error as ApiError;
const { status } = error as ApiErrorType;

if (status === 401 && userAuth?.refreshToken && onRequestRefresh) {
const refreshedUserAuth = await onRequestRefresh();
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist/cjs"
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2015"
},
"extends": "./tsconfig.json",
"include": ["src"]
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"module": "ES2020",
"outDir": "./dist/esm"
"module": "esnext",
"outDir": "./dist/esm",
"target": "esnext"
},
"extends": "./tsconfig.json",
"include": ["src"]
Expand Down
19 changes: 12 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
"baseUrl": "./src",
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "dom.iterable", "ES2020"],
"lib": ["dom", "dom.iterable", "esnext"],
"moduleResolution": "Node",
"noImplicitReturns": true,
"removeComments": true,
"sourceMap": true,
"strict": true,
"target": "ES2015",
"useDefineForClassFields": true
"allowJs": true,
"allowSyntheticDefaultImports": true,
"inlineSourceMap": false,
"listEmittedFiles": false,
"listFiles": false,
"noFallthroughCasesInSwitch": true,
"pretty": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"traceResolution": false,
"types": ["node", "jest"]
},
"include": ["src", "test"]
}