Skip to content

Commit

Permalink
fix: properly export types
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland committed Oct 14, 2021
1 parent 01594a8 commit 65f95c5
Show file tree
Hide file tree
Showing 28 changed files with 1,549 additions and 385 deletions.
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ yarn

## Local development

Start a local dev server in watch mode with `yarn dev`.

There is a dev playground set up in _src/\_\_dev-playground.ts_. When changes are made to this file, you will see updates in your terminal.
This package uses [dts-cli](https://github.com/weiran-zsd/dts-cli), a fork of tsdx. Local dev with watch mode can be enabled with `yarn dev`.

Tests can be executed using `yarn test`.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2020 Netanel Basal.
Copyright (c) 2021 Wes Copeland.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions examples/buildUserTrophyList.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from "fs";

import type { Trophy } from "@/index";
import type { Trophy } from "../src";
import {
exchangeCodeForAccessToken,
exchangeNpssoForCode,
getTrophiesEarnedForTitle,
getTrophiesForTitle,
getTrophyTitlesForUser,
TrophyRarity
} from "@/index";
} from "../src";

// To build your own trophy list, use "me" as the `userId`.
export const buildUserTrophyList = async (userId: string, npsso: string) => {
Expand Down
19 changes: 0 additions & 19 deletions jest.config.js

This file was deleted.

42 changes: 23 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
"name": "psn-api",
"description": "A low-level API for getting data from the PlayStation Network.",
"version": "0.0.0-development",
"main": "dist/psn-api.js",
"module": "dist/psn-api.mjs",
"typings": "dist/psn-api.d.ts",
"main": "dist/index.js",
"module": "dist/psn-api.esm.js",
"typings": "dist/index.d.ts",
"author": "Wes Copeland",
"license": "MIT",
"files": [
"dist",
"src"
],
"scripts": {
"preversion": "npm run format && npm run build",
"prepublishOnly": "npm run format && npm run test && npm run build",
"dev": "ts-node-dev --respawn --clear --quiet src/__dev-playground.ts",
"build": "rollup -c",
"dev": "dts watch",
"build": "dts build",
"prepare": "dts build",
"format": "prettier --write . '**/*.{json,md,js,ts,tsx}'",
"format:write": "prettier --write . '**/*.{json,md,js,ts,tsx}'",
"format:check": "prettier --check . '**/*.{json,md,js,ts,tsx}'",
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
"lint:fix": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx . --fix",
"test": "jest",
"test": "dts test",
"size": "size-limit",
"analyze": "size-limit --why",
"semantic-release": "semantic-release"
Expand All @@ -26,6 +29,7 @@
"isomorphic-unfetch": "^3.1.0",
"urlcat": "^2.0.4"
},
"peerDependencies": {},
"devDependencies": {
"@commitlint/cli": "^13.2.1",
"@commitlint/config-conventional": "^13.2.0",
Expand All @@ -36,7 +40,7 @@
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"cz-conventional-changelog": "^3.3.0",
"esbuild": "^0.13.4",
"dts-cli": "^0.19.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
Expand All @@ -46,22 +50,22 @@
"eslint-plugin-unicorn": "^36.0.0",
"faker": "^5.5.3",
"husky": "^4.3.8",
"jest": "^27.2.5",
"msw": "^0.35.0",
"prettier": "2.4.1",
"pretty-quick": "^3.1.1",
"rollup": "^2.58.0",
"rollup-plugin-dts": "^4.0.0",
"rollup-plugin-esbuild": "^4.5.0",
"size-limit": "^6.0.1",
"ts-jest": "^27.0.5",
"ts-node-dev": "^1.1.8",
"typescript": "^4.4.3",
"semantic-release": "^18.0.0"
"semantic-release": "^18.0.0",
"size-limit": "^6.0.3",
"tslib": "^2.3.1",
"typescript": "^4.4.4"
},
"size-limit": [
{
"path": "dist/psn-api.js"
"path": "dist/psn-api.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/psn-api.esm.js",
"limit": "10 KB"
}
],
"husky": {
Expand Down
35 changes: 0 additions & 35 deletions rollup.config.js

This file was deleted.

5 changes: 2 additions & 3 deletions src/authenticate/exchangeCodeForAccessToken.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { rest } from "msw";
import { setupServer } from "msw/node";

import type { AccessTokenResponse } from "@/models";

import type { AccessTokenResponse } from "../models";
import { AUTH_BASE_URL } from "./AUTH_BASE_URL";
import { exchangeCodeForAccessToken } from "./exchangeCodeForAccessToken";

Expand Down Expand Up @@ -32,7 +31,7 @@ describe("Function: exchangeCodeForAccessToken", () => {
};

server.use(
rest.post(`${AUTH_BASE_URL}/token`, (req, res, ctx) => {
rest.post(`${AUTH_BASE_URL}/token`, (_, res, ctx) => {
return res(
ctx.json({
access_token: mockAccessTokenResponse.accessToken,
Expand Down
3 changes: 1 addition & 2 deletions src/authenticate/exchangeCodeForAccessToken.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import fetch from "isomorphic-unfetch";
import urlcat, { query } from "urlcat";

import type { AccessTokenResponse } from "@/models";

import type { AccessTokenResponse } from "../models";
import { AUTH_BASE_URL } from "./AUTH_BASE_URL";

/**
Expand Down
4 changes: 2 additions & 2 deletions src/authenticate/exchangeNpssoForCode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Function: exchangeNpssoForCode", () => {
const mockLocationHeaderResponse = `com.playstation.PlayStationApp://redirect/?code=${mockCode}&cid=36e3823a-8049-4c36-9021-b154315ae2ad`;

server.use(
rest.get(`${AUTH_BASE_URL}/authorize`, (req, res, ctx) => {
rest.get(`${AUTH_BASE_URL}/authorize`, (_, res, ctx) => {
return res(
ctx.status(302),
ctx.set("Location", mockLocationHeaderResponse)
Expand All @@ -41,7 +41,7 @@ describe("Function: exchangeNpssoForCode", () => {
it("throws an error if we receive an unexpected response", async () => {
// ARRANGE
server.use(
rest.get(`${AUTH_BASE_URL}/authorize`, (req, res, ctx) => {
rest.get(`${AUTH_BASE_URL}/authorize`, (_, res, ctx) => {
return res(ctx.json({}));
})
);
Expand Down
3 changes: 1 addition & 2 deletions src/call.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { rest } from "msw";
import { setupServer } from "msw/node";

import type { AuthorizationPayload, CallValidHeaders } from "@/models";

import { call } from "./call";
import type { AuthorizationPayload, CallValidHeaders } from "./models";

const server = setupServer();

Expand Down
2 changes: 1 addition & 1 deletion src/call.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from "isomorphic-unfetch";

import type { AuthorizationPayload, CallValidHeaders } from "@/models";
import type { AuthorizationPayload, CallValidHeaders } from "./models";

export const call = async <T>(
config: {
Expand Down
2 changes: 1 addition & 1 deletion src/test/generators/title-platform.generator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as faker from "faker";

import type { TitlePlatform } from "@/models";
import type { TitlePlatform } from "../../models";

export const generateTitlePlatform = (givenTitlePlatform?: string) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/test/generators/trophy-counts.generator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as faker from "faker";

import type { TrophyCounts } from "@/models";
import type { TrophyCounts } from "../../models";

export const generateTrophyCounts = (
trophyCountsProps?: Partial<TrophyCounts>
Expand Down
3 changes: 1 addition & 2 deletions src/test/generators/trophy-title.generator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as faker from "faker";

import type { TrophyTitle } from "@/models";

import type { TrophyTitle } from "../../models";
import { generateTitlePlatform } from "./title-platform.generator";
import { generateTrophyCounts } from "./trophy-counts.generator";

Expand Down
7 changes: 3 additions & 4 deletions src/trophy/getSummarizedTrophiesByTrophyGroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { setupServer } from "msw/node";
import type {
AuthorizationPayload,
SummarizedTrophiesByTrophyGroupResponse
} from "@/models";
import { generateTrophyCounts } from "@/test/generators";

} from "../models";
import { generateTrophyCounts } from "../test/generators";
import { getSummarizedTrophiesByTrophyGroup } from "./getSummarizedTrophiesByTrophyGroup";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

Expand Down Expand Up @@ -44,7 +43,7 @@ describe("Function: getSummarizedTrophiesByTrophyGroup", () => {
server.use(
rest.get(
`${TROPHY_BASE_URL}/v1/users/${mockAccountId}/npCommunicationIds/${mockNpCommunicationId}/trophyGroups`,
(req, res, ctx) => {
(_, res, ctx) => {
return res(ctx.json(mockResponse));
}
)
Expand Down
5 changes: 2 additions & 3 deletions src/trophy/getSummarizedTrophiesByTrophyGroup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import urlcat from "urlcat";

import { call } from "../call";
import type {
AuthorizationPayload,
CallValidHeaders,
SummarizedTrophiesByTrophyGroupResponse
} from "@/models";

import { call } from "../call";
} from "../models";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

interface GetSummarizedTrophiesByTrophyGroupOptions {
Expand Down
10 changes: 6 additions & 4 deletions src/trophy/getTitleTrophyGroups.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { rest } from "msw";
import { setupServer } from "msw/node";

import type { AuthorizationPayload, TitleTrophyGroupsResponse } from "@/models";
import { generateTrophyCounts } from "@/test/generators";

import type {
AuthorizationPayload,
TitleTrophyGroupsResponse
} from "../models";
import { generateTrophyCounts } from "../test/generators";
import { getTitleTrophyGroups } from "./getTitleTrophyGroups";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

Expand Down Expand Up @@ -40,7 +42,7 @@ describe("Function: getTitleTrophyGroups", () => {
server.use(
rest.get(
`${TROPHY_BASE_URL}/v1/npCommunicationIds/${mockNpCommunicationId}/trophyGroups`,
(req, res, ctx) => {
(_, res, ctx) => {
return res(ctx.json(mockResponse));
}
)
Expand Down
5 changes: 2 additions & 3 deletions src/trophy/getTitleTrophyGroups.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import urlcat from "urlcat";

import { call } from "../call";
import type {
AuthorizationPayload,
CallValidHeaders,
TitleTrophyGroupsResponse
} from "@/models";

import { call } from "../call";
} from "../models";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

interface GetTitleTrophyGroupsOptions {
Expand Down
5 changes: 2 additions & 3 deletions src/trophy/getTrophiesEarnedForTitle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { setupServer } from "msw/node";
import type {
AuthorizationPayload,
TrophiesEarnedForTitleResponse
} from "@/models";

} from "../models";
import { getTrophiesEarnedForTitle } from "./getTrophiesEarnedForTitle";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

Expand Down Expand Up @@ -43,7 +42,7 @@ describe("Function: getTrophiesEarnedForTitle", () => {
server.use(
rest.get(
`${TROPHY_BASE_URL}/v1/users/${mockAccountId}/npCommunicationIds/${mockNpCommunicationId}/trophyGroups/${mockTrophyGroupId}/trophies`,
(req, res, ctx) => {
(_, res, ctx) => {
return res(ctx.json(mockResponse));
}
)
Expand Down
5 changes: 2 additions & 3 deletions src/trophy/getTrophiesEarnedForTitle.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import urlcat from "urlcat";

import { call } from "../call";
import type {
AuthorizationPayload,
CallValidHeaders,
TrophiesEarnedForTitleResponse
} from "@/models";

import { call } from "../call";
} from "../models";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

interface GetTrophiesEarnedForTitleOptions {
Expand Down
5 changes: 2 additions & 3 deletions src/trophy/getTrophiesForTitle.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { rest } from "msw";
import { setupServer } from "msw/node";

import type { AuthorizationPayload, TitleTrophiesResponse } from "@/models";

import type { AuthorizationPayload, TitleTrophiesResponse } from "../models";
import { getTrophiesForTitle } from "./getTrophiesForTitle";
import { TROPHY_BASE_URL } from "./TROPHY_BASE_URL";

Expand Down Expand Up @@ -38,7 +37,7 @@ describe("Function: getTrophiesForTitle", () => {
server.use(
rest.get(
`${TROPHY_BASE_URL}/v1/npCommunicationIds/${mockNpCommunicationId}/trophyGroups/${mockTrophyGroupId}/trophies`,
(req, res, ctx) => {
(_, res, ctx) => {
return res(ctx.json(mockResponse));
}
)
Expand Down
Loading

0 comments on commit 65f95c5

Please sign in to comment.