ps99-api 2.0.0 → 2.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.
package/dist/index.d.ts CHANGED
@@ -39,5 +39,6 @@ export * from "./responses/collection/ultimate";
39
39
  export * from "./responses/collection/upgrade";
40
40
  export * from "./responses/collection/watering-can";
41
41
  export * from "./responses/collection/world";
42
+ export * from "./responses/collection/xp-potion";
42
43
  export * from "./responses/collection/zone-flag";
43
44
  export * from "./responses/collection/zone";
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ __exportStar(require("./responses/collection/ultimate"), exports);
55
55
  __exportStar(require("./responses/collection/upgrade"), exports);
56
56
  __exportStar(require("./responses/collection/watering-can"), exports);
57
57
  __exportStar(require("./responses/collection/world"), exports);
58
+ __exportStar(require("./responses/collection/xp-potion"), exports);
58
59
  __exportStar(require("./responses/collection/zone-flag"), exports);
59
60
  __exportStar(require("./responses/collection/zone"), exports);
60
61
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0DAAwC;AACxC,yDAAuC;AACvC,mDAAiC;AACjC,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC;AACnC,kDAAgC;AAChC,+DAA6C;AAC7C,yDAAuC;AACvC,qEAAmD;AACnD,+DAA6C;AAC7C,+DAA6C;AAC7C,6DAA2C;AAC3C,8DAA4C;AAC5C,+DAA6C;AAC7C,kEAAgD;AAChD,6DAA2C;AAC3C,qEAAmD;AACnD,qEAAmD;AACnD,+DAA6C;AAC7C,sEAAoD;AACpD,oEAAkD;AAClD,iEAA+C;AAC/C,iEAA+C;AAC/C,kEAAgD;AAChD,mEAAiD;AACjD,6DAA2C;AAC3C,gEAA8C;AAC9C,sEAAoD;AACpD,8DAA4C;AAC5C,gEAA8C;AAC9C,iEAA+C;AAC/C,qEAAmD;AACnD,8DAA4C;AAC5C,gEAA8C;AAC9C,mEAAiD;AACjD,kEAAgD;AAChD,iEAA+C;AAC/C,sEAAoD;AACpD,+DAA6C;AAC7C,mEAAiD;AACjD,8DAA4C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0DAAwC;AACxC,yDAAuC;AACvC,mDAAiC;AACjC,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC;AACnC,kDAAgC;AAChC,+DAA6C;AAC7C,yDAAuC;AACvC,qEAAmD;AACnD,+DAA6C;AAC7C,+DAA6C;AAC7C,6DAA2C;AAC3C,8DAA4C;AAC5C,+DAA6C;AAC7C,kEAAgD;AAChD,6DAA2C;AAC3C,qEAAmD;AACnD,qEAAmD;AACnD,+DAA6C;AAC7C,sEAAoD;AACpD,oEAAkD;AAClD,iEAA+C;AAC/C,iEAA+C;AAC/C,kEAAgD;AAChD,mEAAiD;AACjD,6DAA2C;AAC3C,gEAA8C;AAC9C,sEAAoD;AACpD,8DAA4C;AAC5C,gEAA8C;AAC9C,iEAA+C;AAC/C,qEAAmD;AACnD,8DAA4C;AAC5C,gEAA8C;AAC9C,mEAAiD;AACjD,kEAAgD;AAChD,iEAA+C;AAC/C,sEAAoD;AACpD,+DAA6C;AAC7C,mEAAiD;AACjD,mEAAiD;AACjD,8DAA4C"}
@@ -24,7 +24,7 @@ export declare class PetSimulator99API {
24
24
  requestClient: RequestClient;
25
25
  constructor(params?: PetSimulator99APIOptions);
26
26
  private request;
27
- getCollections(): Promise<ApiResponseBody<("Achievements" | "Boosts" | "Booths" | "Boxes" | "Buffs" | "Charms" | "Currency" | "Eggs" | "Enchants" | "FishingRods" | "Fruits" | "GuildBattles" | "Hoverboards" | "Lootboxes" | "Mastery" | "Merchants" | "MiscItems" | "Pets" | "Potions" | "RandomEvents" | "Ranks" | "Rarity" | "Rebirths" | "Seeds" | "SecretRooms" | "Shovels" | "Sprinklers" | "Ultimates" | "Upgrades" | "WateringCans" | "Worlds" | "ZoneFlags" | "Zones")[]>>;
27
+ getCollections(): Promise<ApiResponseBody<("Achievements" | "Boosts" | "Booths" | "Boxes" | "Buffs" | "Charms" | "Currency" | "Eggs" | "Enchants" | "FishingRods" | "Fruits" | "GuildBattles" | "Hoverboards" | "Lootboxes" | "Mastery" | "Merchants" | "MiscItems" | "Pets" | "Potions" | "RandomEvents" | "Ranks" | "Rarity" | "Rebirths" | "Seeds" | "SecretRooms" | "Shovels" | "Sprinklers" | "Ultimates" | "Upgrades" | "WateringCans" | "Worlds" | "XPPotions" | "ZoneFlags" | "Zones")[]>>;
28
28
  getCollection<C extends CollectionName>(collectionName: C): Promise<ApiResponseBody<Collection<C>[]>>;
29
29
  getClans(params?: GetClansParams): Promise<ApiResponseBody<ClansResponseBody>>;
30
30
  getClan(name: string): Promise<ApiResponseBody<ClanResponseBody>>;
@@ -29,9 +29,10 @@ import { UltimateData } from "./ultimate";
29
29
  import { UpgradeData } from "./upgrade";
30
30
  import { WateringCanData } from "./watering-can";
31
31
  import { WorldData } from "./world";
32
+ import { XPPotionData } from "./xp-potion";
32
33
  import { ZoneFlagData } from "./zone-flag";
33
34
  import { ZoneData } from "./zone";
34
- export type Collections = AchievementData | BoostData | BoothData | BoxData | BuffData | CharmData | CurrencyData | EggData | EnchantmentData | FishingRodData | FruitData | GuildBattleData | HoverboardData | LootboxData | MasteryData | MerchantData | MiscItemData | PetData | PotionData | RandomEventData | RankData | RarityData | RebirthData | SecretRoomData | SeedData | ShovelData | SprinklerData | UltimateData | UpgradeData | WateringCanData | WorldData | ZoneFlagData | ZoneData;
35
+ export type Collections = AchievementData | BoostData | BoothData | BoxData | BuffData | CharmData | CurrencyData | EggData | EnchantmentData | FishingRodData | FruitData | GuildBattleData | HoverboardData | LootboxData | MasteryData | MerchantData | MiscItemData | PetData | PotionData | RandomEventData | RankData | RarityData | RebirthData | SecretRoomData | SeedData | ShovelData | SprinklerData | UltimateData | UpgradeData | WateringCanData | WorldData | XPPotionData | ZoneFlagData | ZoneData;
35
36
  export type CollectionName = Collections["collection"];
36
37
  export type Collection<C extends CollectionName> = Extract<Collections, {
37
38
  collection: C;
@@ -0,0 +1,23 @@
1
+ import { CollectionData } from "./collection-data";
2
+ export type XPPotionData = CollectionData<"XPPotions", XPPotionConfigData>;
3
+ export type XPPotionConfigData = {
4
+ Rarity: XPPotionRarity;
5
+ DisplayName: string;
6
+ Amount: number;
7
+ Desc: string;
8
+ Recipe: unknown;
9
+ Icon: string;
10
+ ItemId: string;
11
+ };
12
+ export type XPPotionRarity = {
13
+ RarityNumber: number;
14
+ Lootbag: unknown;
15
+ _id: string;
16
+ Color: unknown;
17
+ DisplayName: string;
18
+ Message: unknown;
19
+ ItemSlot: unknown;
20
+ Gradient: unknown;
21
+ Announce: boolean;
22
+ _script: unknown;
23
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=xp-potion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xp-potion.js","sourceRoot":"","sources":["../../../src/responses/collection/xp-potion.ts"],"names":[],"mappings":""}
@@ -1,9 +1,5 @@
1
1
  import React from "react";
2
- import {
3
- BrowserRouter as Router,
4
- Routes,
5
- Route,
6
- } from "react-router-dom";
2
+ import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
7
3
  import HomePage from "./components/HomePage";
8
4
  import Header from "./components/Header";
9
5
  import CollectionsIndex from "./components/CollectionsIndex";
@@ -1,9 +1,24 @@
1
- import React, { lazy, Suspense, useEffect, useState, useRef, useCallback } from "react";
1
+ import React, {
2
+ lazy,
3
+ Suspense,
4
+ useEffect,
5
+ useState,
6
+ useRef,
7
+ useCallback,
8
+ } from "react";
2
9
  import { useParams } from "react-router-dom";
3
- import { PetSimulator99API, CollectionName, Collection, CollectionConfigData } from "ps99-api";
10
+ import {
11
+ PetSimulator99API,
12
+ CollectionName,
13
+ Collection,
14
+ CollectionConfigData,
15
+ } from "ps99-api";
4
16
 
5
17
  const DynamicCollectionConfigData: React.FC = () => {
6
- const { collectionName, configName } = useParams<{ collectionName: CollectionName; configName: string }>();
18
+ const { collectionName, configName } = useParams<{
19
+ collectionName: CollectionName;
20
+ configName: string;
21
+ }>();
7
22
 
8
23
  if (!collectionName) {
9
24
  return <div>Invalid collection name</div>;
@@ -22,8 +37,12 @@ const DynamicCollectionConfigData: React.FC = () => {
22
37
  );
23
38
  };
24
39
 
25
- const RenderAllConfigs: React.FC<{ collectionName: CollectionName }> = ({ collectionName }) => {
26
- const [configDataList, setConfigDataList] = useState<Array<Collection<CollectionName>>>([]);
40
+ const RenderAllConfigs: React.FC<{ collectionName: CollectionName }> = ({
41
+ collectionName,
42
+ }) => {
43
+ const [configDataList, setConfigDataList] = useState<
44
+ Array<Collection<CollectionName>>
45
+ >([]);
27
46
  const [page, setPage] = useState(0);
28
47
  const [error, setError] = useState<string | null>(null);
29
48
  const observer = useRef<IntersectionObserver | null>(null);
@@ -36,7 +55,10 @@ const RenderAllConfigs: React.FC<{ collectionName: CollectionName }> = ({ collec
36
55
  if (response.status === "ok") {
37
56
  const start = page * 20;
38
57
  const end = start + 20;
39
- setConfigDataList((prev) => [...prev, ...response.data.slice(start, end)]);
58
+ setConfigDataList((prev) => [
59
+ ...prev,
60
+ ...response.data.slice(start, end),
61
+ ]);
40
62
  } else {
41
63
  setError(response.error.message);
42
64
  }
@@ -72,7 +94,13 @@ const RenderAllConfigs: React.FC<{ collectionName: CollectionName }> = ({ collec
72
94
  return (
73
95
  <div ref={lastElementRef} key={index}>
74
96
  <Suspense fallback={<div>Loading...</div>}>
75
- <Component configData={configData.configData as CollectionConfigData<typeof collectionName>} />
97
+ <Component
98
+ configData={
99
+ configData.configData as CollectionConfigData<
100
+ typeof collectionName
101
+ >
102
+ }
103
+ />
76
104
  </Suspense>
77
105
  </div>
78
106
  );
@@ -80,7 +108,13 @@ const RenderAllConfigs: React.FC<{ collectionName: CollectionName }> = ({ collec
80
108
  return (
81
109
  <div key={index}>
82
110
  <Suspense fallback={<div>Loading...</div>}>
83
- <Component configData={configData.configData as CollectionConfigData<typeof collectionName>} />
111
+ <Component
112
+ configData={
113
+ configData.configData as CollectionConfigData<
114
+ typeof collectionName
115
+ >
116
+ }
117
+ />
84
118
  </Suspense>
85
119
  </div>
86
120
  );
@@ -29,7 +29,9 @@ const ImageComponent: React.FC<ImageProps> = ({ src, alt }) => {
29
29
  try {
30
30
  const api = new PetSimulator99API();
31
31
  const imageBlob = await api.getImage(src);
32
- const imageUrl = URL.createObjectURL(new Blob([imageBlob], { type: "image/png" }));
32
+ const imageUrl = URL.createObjectURL(
33
+ new Blob([imageBlob], { type: "image/png" }),
34
+ );
33
35
  setImageUrl(imageUrl);
34
36
  } catch (error) {
35
37
  setError("Error fetching image");
@@ -58,7 +60,9 @@ const ImageComponent: React.FC<ImageProps> = ({ src, alt }) => {
58
60
  return <div>{error}</div>;
59
61
  }
60
62
 
61
- return <div>{imageUrl ? <img src={imageUrl} alt={alt} /> : <p>Loading...</p>}</div>;
63
+ return (
64
+ <div>{imageUrl ? <img src={imageUrl} alt={alt} /> : <p>Loading...</p>}</div>
65
+ );
62
66
  };
63
67
 
64
68
  export default ImageComponent;
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+ import { CollectionConfigData } from "ps99-api";
3
+ import { GenericFetchComponent } from "./GenericFetchComponent";
4
+ import ImageComponent from "./ImageComponent";
5
+
6
+ const XPPotionsComponent: React.FC<{ configData?: CollectionConfigData<"XPPotions"> }> = ({ configData }) => {
7
+ return (
8
+ <GenericFetchComponent<CollectionConfigData<"XPPotions">>
9
+ collectionName="XPPotions"
10
+ configData={configData}
11
+ render={(data) => (
12
+ <div>
13
+ <h2>{data.DisplayName}</h2>
14
+ <ImageComponent src={data.Icon} alt={data.DisplayName} />
15
+ <p>Amount: {data.Amount}</p>
16
+ <p>Description: {data.Desc}</p>
17
+ <p>Item ID: {data.ItemId}</p>
18
+ <h3>Rarity</h3>
19
+ <p>Display Name: {data.Rarity.DisplayName}</p>
20
+ <p>Rarity Number: {data.Rarity.RarityNumber}</p>
21
+ <p>Announce: {data.Rarity.Announce ? "Yes" : "No"}</p>
22
+ </div>
23
+ )}
24
+ />
25
+ );
26
+ };
27
+
28
+ export default XPPotionsComponent;
@@ -25,7 +25,7 @@ module.exports = {
25
25
  output: {
26
26
  filename: "bundle.js",
27
27
  path: path.resolve(__dirname, "dist"),
28
- publicPath: "/"
28
+ publicPath: "/",
29
29
  },
30
30
  devServer: {
31
31
  static: {
@@ -33,6 +33,6 @@ module.exports = {
33
33
  },
34
34
  compress: true,
35
35
  port: 9000,
36
- historyApiFallback: true
36
+ historyApiFallback: true,
37
37
  },
38
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ps99-api",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Pet Simulator Public API wrapper written in Typescript.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",