ps99-api 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ import { expect, test } from "@jest/globals";
2
+ import { PetSimulator99API } from "../ps99-api";
3
+
4
+
5
+ /**
6
+ * It's hard to snapshot these because certain values will always be changing but useful for dump-result checks
7
+ */
8
+ describe.skip("Pet Simulator Public Live API Test - Changing Items", () => {
9
+ const api = new PetSimulator99API();
10
+
11
+ test('Active Clan Battle', async () => {
12
+ const results = await api.getActiveClanBattle();
13
+ expect(results).toMatchSnapshot();
14
+ });
15
+
16
+ test('Get Clan', async () => {
17
+ const results = await api.getClan('MMFC');
18
+ expect(results).toMatchSnapshot();
19
+ });
20
+
21
+ test('Get Clans', async () => {
22
+ const results = await api.getClans({pageSize: 1});
23
+ expect(results).toMatchSnapshot();
24
+ });
25
+
26
+ test('Get Exists', async () => {
27
+ const results = await api.getExists();
28
+ expect(results).toMatchSnapshot();
29
+ });
30
+
31
+ test('Get RAP', async () => {
32
+ const results = await api.getRAP();
33
+ expect(results).toMatchSnapshot();
34
+ });
35
+
36
+ });
@@ -0,0 +1,177 @@
1
+ import { expect, test } from "@jest/globals";
2
+ import { PetSimulator99API } from "../ps99-api";
3
+
4
+
5
+ describe("Pet Simulator Public Live API Test", () => {
6
+ const api = new PetSimulator99API();
7
+
8
+ test('Collections Have Not Changed', async () => {
9
+ const results = await api.getCollections();
10
+ expect(results).toMatchSnapshot();
11
+ });
12
+
13
+ test("Achievements shape", async () => {
14
+ const results = await api.getCollection('Achievements');
15
+ expect(results).toMatchSnapshot();
16
+ });
17
+
18
+ test("Boosts shape", async () => {
19
+ const results = await api.getCollection('Boosts');
20
+ expect(results).toMatchSnapshot();
21
+ });
22
+
23
+ test("Booths shape", async () => {
24
+ const results = await api.getCollection('Booths');
25
+ expect(results).toMatchSnapshot();
26
+ });
27
+
28
+ test("Boxes shape", async () => {
29
+ const results = await api.getCollection('Boxes');
30
+ expect(results).toMatchSnapshot();
31
+ });
32
+
33
+ test("Buffs shape", async () => {
34
+ const results = await api.getCollection('Buffs');
35
+ expect(results).toMatchSnapshot();
36
+ });
37
+
38
+ test("Charms shape", async () => {
39
+ const results = await api.getCollection('Charms');
40
+ expect(results).toMatchSnapshot();
41
+ });
42
+
43
+ test("Currency shape", async () => {
44
+ const results = await api.getCollection('Currency');
45
+ expect(results).toMatchSnapshot();
46
+ });
47
+
48
+ test("Eggs shape", async () => {
49
+ const results = await api.getCollection('Eggs');
50
+ expect(results).toMatchSnapshot();
51
+ });
52
+
53
+ test("Enchants shape", async () => {
54
+ const results = await api.getCollection('Enchants');
55
+ expect(results).toMatchSnapshot();
56
+ });
57
+
58
+ test("FishingRods shape", async () => {
59
+ const results = await api.getCollection('FishingRods');
60
+ expect(results).toMatchSnapshot();
61
+ });
62
+
63
+ test("Fruits shape", async () => {
64
+ const results = await api.getCollection('Fruits');
65
+ expect(results).toMatchSnapshot();
66
+ });
67
+
68
+ test("GuildBattles shape", async () => {
69
+ const results = await api.getCollection('GuildBattles');
70
+ expect(results).toMatchSnapshot();
71
+ });
72
+
73
+ test("Hoverboards shape", async () => {
74
+ const results = await api.getCollection('Hoverboards');
75
+ expect(results).toMatchSnapshot();
76
+ });
77
+
78
+ test("Lootboxes shape", async () => {
79
+ const results = await api.getCollection('Lootboxes');
80
+ expect(results).toMatchSnapshot();
81
+ });
82
+
83
+ test("Mastery shape", async () => {
84
+ const results = await api.getCollection('Mastery');
85
+ expect(results).toMatchSnapshot();
86
+ });
87
+
88
+ test("MiscItems shape", async () => {
89
+ const results = await api.getCollection('MiscItems');
90
+ expect(results).toMatchSnapshot();
91
+ });
92
+
93
+ test("Pets shape", async () => {
94
+ const results = await api.getCollection('Pets');
95
+ expect(results).toMatchSnapshot();
96
+ });
97
+
98
+ test("Potions shape", async () => {
99
+ const results = await api.getCollection('Potions');
100
+ expect(results).toMatchSnapshot();
101
+ });
102
+
103
+ test("RandomEvents shape", async () => {
104
+ const results = await api.getCollection('RandomEvents');
105
+ expect(results).toMatchSnapshot();
106
+ });
107
+
108
+ test("Ranks shape", async () => {
109
+ const results = await api.getCollection('Ranks');
110
+ expect(results).toMatchSnapshot();
111
+ });
112
+
113
+ test("Rarity shape", async () => {
114
+ const results = await api.getCollection('Rarity');
115
+ expect(results).toMatchSnapshot();
116
+ });
117
+
118
+ test("Rebirths shape", async () => {
119
+ const results = await api.getCollection('Rebirths');
120
+ expect(results).toMatchSnapshot();
121
+ });
122
+
123
+ test("SecretRooms shape", async () => {
124
+ const results = await api.getCollection('SecretRooms');
125
+ expect(results).toMatchSnapshot();
126
+ });
127
+
128
+ test("Seeds shape", async () => {
129
+ const results = await api.getCollection('Seeds');
130
+ expect(results).toMatchSnapshot();
131
+ });
132
+
133
+ test("Shovels shape", async () => {
134
+ const results = await api.getCollection('Shovels');
135
+ expect(results).toMatchSnapshot();
136
+ });
137
+
138
+ test("Sprinklers shape", async () => {
139
+ const results = await api.getCollection('Sprinklers');
140
+ expect(results).toMatchSnapshot();
141
+ });
142
+
143
+ test("Ultimates shape", async () => {
144
+ const results = await api.getCollection('Ultimates');
145
+ expect(results).toMatchSnapshot();
146
+ });
147
+
148
+ test("Upgrades shape", async () => {
149
+ const results = await api.getCollection('Upgrades');
150
+ expect(results).toMatchSnapshot();
151
+ });
152
+
153
+ test("WateringCans shape", async () => {
154
+ const results = await api.getCollection('WateringCans');
155
+ expect(results).toMatchSnapshot();
156
+ });
157
+
158
+ test("Worlds shape", async () => {
159
+ const results = await api.getCollection('Worlds');
160
+ expect(results).toMatchSnapshot();
161
+ });
162
+
163
+ test("ZoneFlags shape", async () => {
164
+ const results = await api.getCollection('ZoneFlags');
165
+ expect(results).toMatchSnapshot();
166
+ });
167
+
168
+ test("Zones shape", async () => {
169
+ const results = await api.getCollection('Zones');
170
+ expect(results).toMatchSnapshot();
171
+ });
172
+
173
+ test("Merchants shape", async () => {
174
+ const results = await api.getCollection('Merchants');
175
+ expect(results).toMatchSnapshot();
176
+ });
177
+ });
package/src/index.ts CHANGED
@@ -2,10 +2,10 @@ export * from "./ps99-api";
2
2
  export * from "./request-client/common";
3
3
  export * from "./request-client/axios";
4
4
  export * from "./responses/collections";
5
- export * from "./common";
6
5
  export * from "./responses/clan";
7
6
  export * from "./responses/clans";
8
7
  export * from "./params/clans";
9
8
  export * from "./responses/exists";
10
9
  export * from "./responses/rap";
11
10
  export * from "./responses/activeClanBattle";
11
+ export * from "./responses/collection";
package/src/ps99-api.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { ApiRequestParams, RequestClient } from "./request-client/common";
2
2
  import { getAxiosRequest } from "./request-client/axios";
3
3
  import { CollectionsResponseBody } from "./responses/collections";
4
- import { Collection } from "./common";
5
- import { CollectionResponseBody } from "./responses/collection";
4
+ import {Collection, GetCollectionResponse} from "./responses/collection";
6
5
  import { ClanResponseBody } from "./responses/clan";
7
6
  import { ClansResponseBody } from "./responses/clans";
8
7
  import { ClansSort, GetClansParams, SortOrder } from "./params/clans";
@@ -53,8 +52,8 @@ export class PetSimulator99API {
53
52
  return this.request<CollectionsResponseBody>("/api/collections");
54
53
  }
55
54
 
56
- getCollection(collection: Collection) {
57
- return this.request<CollectionResponseBody>(
55
+ getCollection<C extends Collection>(collection: C) {
56
+ return this.request<GetCollectionResponse<C>>(
58
57
  `/api/collection/${collection}`,
59
58
  );
60
59
  }
@@ -1,20 +1,43 @@
1
+ export type ActiveBattleData = {
2
+ _id: string
3
+ category: string
4
+ configData: ActiveBattleConfigData
5
+ configName: string
6
+ }
7
+
8
+ export type ActiveBattleConfigData = {
9
+ FinishTime: number
10
+ PlacementRewards: ActiveBattlePlacementReward[]
11
+ Rewards: ActiveBattleRewards
12
+ StartTime: number
13
+ Title: string
14
+ _id: string
15
+ _script: any
16
+ }
17
+
18
+ export type ActiveBattlePlacementReward = {
19
+ Best: number
20
+ Item: ActiveBattleItem
21
+ Worst: number
22
+ }
23
+
24
+ export type ActiveBattleItem = {
25
+ _data: ActiveBattleItemData
26
+ }
27
+
28
+ export type ActiveBattleItemData = {
29
+ id: string
30
+ pt?: number
31
+ }
32
+
33
+ export type ActiveBattleRewards = {
34
+ Bronze: any[]
35
+ Gold: any[]
36
+ Good: any[]
37
+ Silver: any[]
38
+ }
39
+
1
40
  export type ActiveClanBattleResponseBody = {
2
- status: string;
3
- data: {
4
- _id: string;
5
- configName: string;
6
- category: string;
7
- configData: {
8
- _script: {};
9
- FinishTime: number;
10
- Title: string;
11
- _id: string;
12
- StartTime: number;
13
- Rewards: {
14
- Bronze: { _data: { id: string } }[];
15
- Silver: { _data: { id: string } }[];
16
- Gold: { _data: { id: string } }[];
17
- };
18
- };
19
- };
20
- };
41
+ status: string
42
+ data: ActiveBattleData
43
+ }
@@ -1,65 +1,91 @@
1
1
  export type ClanResponseBody = {
2
- status: string;
3
- data: {
4
- Created: number;
5
- Owner: number;
6
- Name: string;
7
- Icon: string;
8
- Desc: string;
9
- MemberCapacity: number;
10
- OfficerCapacity: number;
11
- GuildLevel: number;
12
- Members: { UserID: number; PermissionLevel: number; JoinTime: number }[];
13
- DepositedDiamonds: number;
14
- DiamondContributions: {
15
- AllTime: { Sum: number; Data: { UserID: number; Diamonds: number }[] };
16
- };
17
- Status: string;
18
- StatusTimestamp: number;
19
- StatusUsername: string;
20
- Battles: {
21
- Christmas2023: {
22
- ProcessedAwards: boolean;
23
- AwardUserIDs: number[];
24
- BattleID: string;
25
- Points: number;
26
- PointContributions: { UserID: number; Points: number }[];
27
- EarnedMedal: string;
28
- };
29
- DecemberActiveHugePets: {
30
- ProcessedAwards: boolean;
31
- AwardUserIDs: number[];
32
- BattleID: string;
33
- Points: number;
34
- PointContributions: { UserID: number; Points: number }[];
35
- EarnedMedal: string;
36
- };
37
- IndexBattle: {
38
- ProcessedAwards: boolean;
39
- AwardUserIDs: number[];
40
- BattleID: string;
41
- Points: number;
42
- PointContributions: { UserID: number; Points: number }[];
43
- EarnedMedal: string;
44
- };
45
- AchBattle: {
46
- ProcessedAwards: boolean;
47
- AwardUserIDs: number[];
48
- BattleID: string;
49
- Points: number;
50
- PointContributions: { UserID: number; Points: number }[];
51
- EarnedMedal: string;
52
- };
53
- RaidBattle: {
54
- ProcessedAwards: boolean;
55
- AwardUserIDs: any[];
56
- BattleID: string;
57
- Points: number;
58
- PointContributions: { UserID: number; Points: number }[];
59
- };
60
- };
61
- CountryCode: string;
62
- BronzeMedals: number;
63
- LastKickTimestamp: number;
64
- };
65
- };
2
+ Battles: Battles
3
+ BronzeMedals: number
4
+ CountryCode: string
5
+ Created: number
6
+ DepositedDiamonds: number
7
+ Desc: string
8
+ DiamondContributions: DiamondContributions
9
+ GoodMedals: number
10
+ GuildLevel: number
11
+ Icon: string
12
+ LastKickTimestamp: number
13
+ MemberCapacity: number
14
+ Members: Member[]
15
+ Name: string
16
+ OfficerCapacity: number
17
+ Owner: number
18
+ SilverMedals: number
19
+ Status: string
20
+ StatusTimestamp: number
21
+ StatusUsername: string
22
+ }
23
+
24
+ export type Battles = {[key: string]: PointsBattle | GoalBattle}
25
+
26
+ export type PointsBattle = {
27
+ AwardUserIDs: number[]
28
+ BattleID: string
29
+ EarnedMedal?: string
30
+ Place?: number
31
+ PointContributions: PointContribution[]
32
+ Points: number
33
+ ProcessedAwards: boolean
34
+ }
35
+
36
+ export type PointContribution = {
37
+ Points: number
38
+ UserID: number
39
+ }
40
+
41
+ export type GoalBattle = {
42
+ AwardUserIDs: any[]
43
+ BattleID: string
44
+ EarnedMedal?: string
45
+ Goals: Goal[]
46
+ Place?: number
47
+ PointContributions: PointContribution[]
48
+ Points: number
49
+ ProcessedAwards: boolean
50
+ }
51
+
52
+ export type Goal = {
53
+ Amount: number
54
+ Contributions: Contributions
55
+ Progress: number
56
+ Stars: number
57
+ Tier: number
58
+ Type: number
59
+ }
60
+
61
+ export type Contributions = {[key: string]: number}
62
+
63
+ export type HackerBattle = {
64
+ AwardUserIDs: any[]
65
+ BattleID: string
66
+ Place: number
67
+ PointContributions: PointContribution[]
68
+ Points: number
69
+ ProcessedAwards: boolean
70
+ }
71
+
72
+
73
+ export type DiamondContributions = {
74
+ AllTime: AllTime
75
+ }
76
+
77
+ export type AllTime = {
78
+ Data: Daum[]
79
+ Sum: number
80
+ }
81
+
82
+ export type Daum = {
83
+ Diamonds: number
84
+ UserID: number
85
+ }
86
+
87
+ export type Member = {
88
+ JoinTime: number
89
+ PermissionLevel: number
90
+ UserID: number
91
+ }
@@ -1,25 +1,15 @@
1
- import { ClanName } from "../common";
1
+ export type ClansData = {
2
+ CountryCode: string
3
+ Created: number
4
+ DepositedDiamonds: number
5
+ Icon: string
6
+ MemberCapacity: number
7
+ Members: number
8
+ Name: string
9
+ Points: number
10
+ }
2
11
 
3
12
  export type ClansResponseBody = {
4
13
  status: string;
5
- data: (
6
- | {
7
- Created: number;
8
- Name: string;
9
- MemberCapacity: number;
10
- DepositedDiamonds: number;
11
- CountryCode: string;
12
- Members: number;
13
- Points: number;
14
- }
15
- | {
16
- Created: number;
17
- Name: ClanName;
18
- CountryCode: string;
19
- MemberCapacity: number;
20
- DepositedDiamonds: number;
21
- Members: number;
22
- Points: number;
23
- }
24
- )[];
14
+ data: ClansData[];
25
15
  };