Skip to content

Commit

Permalink
Add default exports and improve the README documentation slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
Pewtro committed Jul 1, 2024
1 parent 0194d5a commit 0fb2bed
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 45 deletions.
8 changes: 8 additions & 0 deletions .changeset/real-hotels-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@blizzard-api/classic-wow': patch
'@blizzard-api/client': patch
'@blizzard-api/wow': patch
'@blizzard-api/d3': patch
---

Add default exports and improve the README documentation slightly
35 changes: 20 additions & 15 deletions packages/classic-wow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,40 @@ You can get paths, namespaces, parameters and more for a specific endpoint by ca

```ts
import { classicWow } from "@blizzard-api/classic-wow"
//or
import classicWow from "@blizzard-api/classic-wow"

const powerType = classicWow.powerType("static-classic", 123);
^ { path: string, namespace: string }
^ { path: string, namespace?: string, parameters?: Record<string, never> }
```

If you don't want to use the exported classicWow object, you can also access the functions directly:

```ts
import { powerType } from "@blizzard-api/classic-wow"

const powerTypeEndpoint = powerType("static-classic", 123);
^ { path: string, namespace?: string, parameters?: Record<string, never> }
```

### Types

If you need the response types, they are also exported with "Response" appended, so to get the response type from the above code, you can import it like this:

```ts
import type { PowerTypeResponse } from '@blizzard-api/classic-wow';
```

If you simply want to use the existing object, you can use the helper from `@blizzard-api/core` like so:
If you simply want to use the existing object, you can use the helper, `ExtractResourceType`, from `@blizzard-api/core` like so:

```ts
import { classicWow } from "@blizzard-api/classic-wow"
import type { ExtractResourceType } from "@blizzard-api/core";

const powerType = classicWow.powerType("static-classic", 123);
^ { path: string, namespace: string }
type PowerTypeResponse = ExtractResourceType<typeof powerType>;
```

If you don't want to use the exported classicWow object, you can also access the functions directly:
^ { path: string, namespace?: string, parameters?: Record<string, never> }

```ts
import { powerType } from "@blizzard-api/wow"

const powerTypeEndpoint = powerType("static-classic", 123);
^ { path: string, namespace: string }
type PowerTypeResponse = ExtractResourceType<typeof powerTypeEndpoint>;
type PowerTypeResponse = ExtractResourceType<typeof powerType>;
```

## Differences to @blizzard-api/wow
Expand All @@ -56,11 +61,11 @@ Because there are multiple classic flavours of the game, each endpoint will take
| World of Warcraft Classic (Era) | static-classic1x-{region} | dynamic-classic1x-{region} | profile-classic1x-{region} |
| Wrath of the Lich King Classic (Progression) | static-classic-{region} | dynamic-classic-{region} | profile-classic-{region} |

## Types
## Notes on Types

The types are manually created from using the Blizzard API documentation, and are as accurate as possible with smoke testing each endpoint. However, no-one is perfect so there is likely be some discrepancies. If you encounter any issues with the types from this package, please open an issue or a pull request.

### Client
## Client

While this package is made to function on it's own, it performs even better when combined with `@blizzard-api/client` where you can easily request data combining the two libraries.

Expand Down
1 change: 1 addition & 0 deletions packages/classic-wow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const classicWow = {
region,
regionIndex,
};
export default classicWow;

//Auction House
export * from './auction-house/auction-house';
Expand Down
2 changes: 2 additions & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ npm i @blizzard-api/client

```ts
import { createBlizzardApiClient } from '@blizzard-api/client';
//or
import createBlizzardApiClient from '@blizzard-api/client';
import { wow } from '@blizzard-api/wow';

const client = await createBlizzardApiClient({
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { createBlizzardApiClient } from './client/create-client';
export { createBlizzardApiClient as default, createBlizzardApiClient } from './client/create-client';
export * from './client/types';
32 changes: 18 additions & 14 deletions packages/d3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,42 @@ You can get paths, namespaces, parameters and more for a specific endpoint by ca

```ts
import { d3 } from "@blizzard-api/d3"
//or
import d3 from "@blizzard-api/d3"

const achievement = d3.achievement(123);
^ { path: string, namespace: string }
^ { path: string, namespace?: string, parameters?: Record<string, never> }
```

If you don't want to use the exported d3 object, you can also access the functions directly:

```ts
import { achievement } from "@blizzard-api/d3"

const achi = achievement(123);
^ { path: string, namespace?: string, parameters?: Record<string, never> }
```

### Types

If you need the response types, they are also exported with "Response" appended, so to get the response type from the above code, you can import it like this:

```ts
import type { AchievementResponse } from '@blizzard-api/d3';
```

If you simply want to use the existing object, you can use the helper from `@blizzard-api/core` like so:
If you simply want to use the existing object, you can use the helper, `ExtractResourceType`, from `@blizzard-api/core` like so:

```ts
import { d3 } from "@blizzard-api/d3"

const achievement = d3.achievement(123);
^ { path: string, namespace: string }
type AchievementResponse = ExtractResourceType<typeof achievement>;
```
^ { path: string, namespace?: string, parameters?: Record<string, never> }

If you don't want to use the exported d3 object, you can also access the functions directly:

```ts
import { achievement } from "@blizzard-api/d3"

const achi = achievement(123);
^ { path: string, namespace: string }
type AchievementResponse = ExtractResourceType<typeof achi>;
type AchievementResponse = ExtractResourceType<typeof achievement>;
```

## Types
## Notes on Types

The types are manually created from using the Blizzard API documentation, and are as accurate as possible with smoke testing each endpoint. However, no-one is perfect so there is likely be some discrepancies. If you encounter any issues with the types from this package, please open an issue or a pull request.

Expand Down
1 change: 1 addition & 0 deletions packages/d3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const d3 = {
seasonIndex,
seasonLeaderboard,
};
export default d3;

//Act
export * from './act/act';
Expand Down
35 changes: 20 additions & 15 deletions packages/wow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,51 @@ You can get paths, namespaces, parameters and more for a specific endpoint by ca

```ts
import { wow } from "@blizzard-api/wow"
//or
import wow from "@blizzard-api/wow"

const achievement = wow.achievement(123);
^ { path: string, namespace: string }
^ { path: string, namespace?: string, parameters?: Record<string, never> }
```

If you don't want to use the exported wow object, you can also access the functions directly:

```ts
import { achievement } from "@blizzard-api/wow"

const achi = achievement(123);
^ { path: string, namespace?: string, parameters?: Record<string, never> }
```

### Types

If you need the response types, they are also exported with "Response" appended, so to get the response type from the above code, you can import it like this:

```ts
import type { AchievementResponse } from '@blizzard-api/wow';
```

If you simply want to use the existing object, you can use the helper from `@blizzard-api/core` like so:
If you simply want to use the existing object, you can use the helper, `ExtractResourceType`, from `@blizzard-api/core` like so:

```ts
import type { ExtractResourceType } from "@blizzard-api/core";
import { wow } from "@blizzard-api/wow"

const achievement = wow.achievement(123);
^ { path: string, namespace: string }
type AchievementResponse = ExtractResourceType<typeof achievement>;
```
^ { path: string, namespace?: string, parameters?: Record<string, never> }

If you don't want to use the exported wow object, you can also access the functions directly:

```ts
import { achievement } from "@blizzard-api/wow"

const achi = achievement(123);
^ { path: string, namespace: string }
type AchievementResponse = ExtractResourceType<typeof achi>;
type AchievementResponse = ExtractResourceType<typeof achievement>;
```

## Differences to @blizzard-api/classic-wow

This package is specifically for World of Warcraft (retail or modern), and as such, the endpoints and responses are different from the classic variants. If you are looking for the classic version of World of Warcraft, you should use `@blizzard-api/classic-wow` instead.

## Types
## Notes on Types

The types are manually created from using the Blizzard API documentation, and are as accurate as possible with smoke testing each endpoint. However, no-one is perfect so there is likely be some discrepancies. If you encounter any issues with the types from this package, please open an issue or a pull request.

### Client
## Client

While this package is made to function on it's own, it performs even better when combined with `@blizzard-api/client` where you can easily request data combining the two libraries.

Expand Down
1 change: 1 addition & 0 deletions packages/wow/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export const wow = {
//WoW Token
wowToken,
};
export default wow;

//Achievements
export * from './achievements/achievements';
Expand Down

0 comments on commit 0fb2bed

Please sign in to comment.