@nuxx/torn-fetch 0.3.0 → 0.3.1
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/README.md +23 -23
- package/dist/index.d.ts +5 -3
- package/package.json +23 -6
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A TypeScript wrapper around `openapi-fetch` that provides a better developer exp
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm install @nuxx/
|
|
15
|
+
npm install @nuxx/torn-fetch
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -20,7 +20,7 @@ npm install @nuxx/use-torn-fetch
|
|
|
20
20
|
### Basic Usage
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import { useTornFetch } from '@nuxx/
|
|
23
|
+
import { useTornFetch } from '@nuxx/torn-fetch'
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
26
|
const userAttacks = await useTornFetch(
|
|
@@ -34,7 +34,7 @@ try {
|
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
|
-
import { useTornFetch } from '@nuxx/
|
|
37
|
+
import { useTornFetch } from '@nuxx/torn-fetch'
|
|
38
38
|
|
|
39
39
|
// Use with path parameters
|
|
40
40
|
const attacks = await useTornFetch(
|
|
@@ -49,7 +49,7 @@ const attacks = await useTornFetch(
|
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
import { useTornFetch } from '@nuxx/
|
|
52
|
+
import { useTornFetch } from '@nuxx/torn-fetch'
|
|
53
53
|
|
|
54
54
|
// Use with query parameters
|
|
55
55
|
const attacks = await useTornFetch(
|
|
@@ -69,7 +69,7 @@ const attacks = await useTornFetch(
|
|
|
69
69
|
The library automatically throws JavaScript errors when the Torn API returns error responses:
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
|
-
import { useTornFetch } from '@nuxx/
|
|
72
|
+
import { useTornFetch } from '@nuxx/torn-fetch'
|
|
73
73
|
|
|
74
74
|
try {
|
|
75
75
|
const userAttacks = await useTornFetch(
|
|
@@ -104,28 +104,28 @@ Creates a specialized fetcher function for a specific API endpoint.
|
|
|
104
104
|
### Prerequisites
|
|
105
105
|
|
|
106
106
|
- Node.js 18+
|
|
107
|
-
-
|
|
107
|
+
- Bun
|
|
108
108
|
|
|
109
109
|
### Setup
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
112
|
# Install dependencies
|
|
113
|
-
|
|
113
|
+
bun install
|
|
114
114
|
|
|
115
115
|
# Get the latest Torn API schema and build
|
|
116
|
-
|
|
116
|
+
bun run build
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
### Scripts
|
|
120
120
|
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
- `
|
|
126
|
-
- `
|
|
127
|
-
- `
|
|
128
|
-
- `
|
|
121
|
+
- `bun run get-schema` - Downloads the latest Torn API OpenAPI schema and generates TypeScript types
|
|
122
|
+
- `bun run build` - Builds the project using tsup
|
|
123
|
+
- `bun run lint` - Runs ESLint on the codebase
|
|
124
|
+
- `bun run type-check` - Runs TypeScript type checking
|
|
125
|
+
- `bun run test` - Runs the test suite
|
|
126
|
+
- `bun run test:watch` - Runs tests in watch mode
|
|
127
|
+
- `bun run test:coverage` - Runs tests with coverage reporting
|
|
128
|
+
- `bun run ci` - Runs the complete CI pipeline (schema, lint, type-check, test, build)
|
|
129
129
|
|
|
130
130
|
## Testing
|
|
131
131
|
|
|
@@ -138,9 +138,9 @@ This package includes comprehensive tests with 100% code coverage. The test suit
|
|
|
138
138
|
|
|
139
139
|
Run tests with:
|
|
140
140
|
```bash
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
bun run test # Run tests once
|
|
142
|
+
bun run test:watch # Run tests in watch mode
|
|
143
|
+
bun run test:coverage # Run tests with coverage report
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
See [TESTING.md](./TESTING.md) for detailed testing documentation.
|
|
@@ -148,7 +148,7 @@ See [TESTING.md](./TESTING.md) for detailed testing documentation.
|
|
|
148
148
|
## Project Structure
|
|
149
149
|
|
|
150
150
|
```
|
|
151
|
-
|
|
151
|
+
torn-fetch/
|
|
152
152
|
├── coverage/ # Test coverage reports
|
|
153
153
|
├── dist/ # Compiled output
|
|
154
154
|
├── src/
|
|
@@ -161,10 +161,10 @@ use-torn-fetch/
|
|
|
161
161
|
│ └── torn-api.ts # Generated TypeScript types
|
|
162
162
|
├── eslint.config.js # ESLint configuration
|
|
163
163
|
├── package.json
|
|
164
|
-
├── pnpm-workspace.yaml # pnpm workspace configuration
|
|
165
164
|
├── tsconfig.json # TypeScript configuration
|
|
166
|
-
├── tsup.config.ts # Build configuration
|
|
165
|
+
├── tsup.config.ts # Build configuration
|
|
167
166
|
├── vitest.config.ts # Test configuration
|
|
167
|
+
├── bun.lock # Bun lock file
|
|
168
168
|
├── TESTING.md # Testing documentation
|
|
169
169
|
└── README.md
|
|
170
170
|
```
|
|
@@ -174,7 +174,7 @@ use-torn-fetch/
|
|
|
174
174
|
1. Fork the repository
|
|
175
175
|
2. Create a feature branch
|
|
176
176
|
3. Make your changes
|
|
177
|
-
4. Run the full CI pipeline: `
|
|
177
|
+
4. Run the full CI pipeline: `bun run ci`
|
|
178
178
|
5. Submit a pull request
|
|
179
179
|
|
|
180
180
|
All contributions should include appropriate tests and maintain 100% code coverage.
|
package/dist/index.d.ts
CHANGED
|
@@ -5300,6 +5300,8 @@ interface components {
|
|
|
5300
5300
|
forgery: number;
|
|
5301
5301
|
/** Format: int32 */
|
|
5302
5302
|
scamming: number;
|
|
5303
|
+
/** Format: int32 */
|
|
5304
|
+
arson: number;
|
|
5303
5305
|
};
|
|
5304
5306
|
version: string;
|
|
5305
5307
|
};
|
|
@@ -5826,7 +5828,7 @@ interface components {
|
|
|
5826
5828
|
/** @enum {string} */
|
|
5827
5829
|
PersonalStatsCategoryEnum: "all" | "popular" | "attacking" | "battle_stats" | "jobs" | "trading" | "jail" | "hospital" | "finishing_hits" | "communication" | "crimes" | "bounties" | "investments" | "items" | "travel" | "drugs" | "missions" | "racing" | "networth" | "other" | "itemmarketcustomers" | "itemmarketsales" | "itemmarketrevenue" | "itemmarketfees";
|
|
5828
5830
|
/** @enum {string} */
|
|
5829
|
-
PersonalStatsStatName: "attackswon" | "attackslost" | "attacksdraw" | "attacksassisted" | "defendswon" | "defendslost" | "defendsstalemated" | "elo" | "yourunaway" | "theyrunaway" | "unarmoredwon" | "bestkillstreak" | "attackhits" | "attackmisses" | "attackdamage" | "bestdamage" | "onehitkills" | "attackcriticalhits" | "roundsfired" | "specialammoused" | "hollowammoused" | "tracerammoused" | "piercingammoused" | "incendiaryammoused" | "attacksstealthed" | "retals" | "moneymugged" | "largestmug" | "itemslooted" | "highestbeaten" | "respectforfaction" | "rankedwarhits" | "raidhits" | "territoryjoins" | "territoryclears" | "territorytime" | "jobpointsused" | "trainsreceived" | "marketitemsbought" | "auctionswon" | "auctionsells" | "itemssent" | "trades" | "cityitemsbought" | "pointsbought" | "pointssold" | "bazaarcustomers" | "bazaarsales" | "bazaarprofit" | "jailed" | "peoplebusted" | "failedbusts" | "peoplebought" | "peopleboughtspent" | "hospital" | "medicalitemsused" | "bloodwithdrawn" | "reviveskill" | "revives" | "revivesreceived" | "heavyhits" | "machinehits" | "riflehits" | "smghits" | "shotgunhits" | "pistolhits" | "temphits" | "piercinghits" | "slashinghits" | "clubbinghits" | "mechanicalhits" | "h2hhits" | "mailssent" | "friendmailssent" | "factionmailssent" | "companymailssent" | "spousemailssent" | "classifiedadsplaced" | "personalsplaced" | "criminaloffensesold" | "sellillegalgoods" | "theftold" | "autotheftcrime" | "drugdealscrime" | "computercrime" | "fraudold" | "murdercrime" | "othercrime" | "organizedcrimes" | "bountiesplaced" | "totalbountyspent" | "bountiescollected" | "totalbountyreward" | "bountiesreceived" | "receivedbountyvalue" | "cityfinds" | "dumpfinds" | "itemsdumped" | "booksread" | "boostersused" | "consumablesused" | "candyused" | "alcoholused" | "energydrinkused" | "statenhancersused" | "eastereggsfound" | "eastereggsused" | "virusescoded" | "traveltimes" | "timespenttraveling" | "itemsboughtabroad" | "attackswonabroad" | "defendslostabroad" | "argtravel" | "mextravel" | "uaetravel" | "hawtravel" | "japtravel" | "uktravel" | "satravel" | "switravel" | "chitravel" | "cantravel" | "caytravel" | "drugsused" | "overdosed" | "rehabs" | "rehabcost" | "cantaken" | "exttaken" | "kettaken" | "lsdtaken" | "opitaken" | "pcptaken" | "shrtaken" | "spetaken" | "victaken" | "xantaken" | "missionscompleted" | "contractscompleted" | "dukecontractscompleted" | "missioncreditsearned" | "racingskill" | "racingpointsearned" | "racesentered" | "raceswon" | "networth" | "timeplayed" | "activestreak" | "bestactivestreak" | "awards" | "refills" | "nerverefills" | "tokenrefills" | "meritsbought" | "daysbeendonator" | "criminaloffenses" | "vandalism" | "theft" | "counterfeiting" | "fraud" | "illicitservices" | "cybercrime" | "extortion" | "illegalproduction" | "currentkillstreak" | "strength" | "defense" | "speed" | "dexterity" | "totalstats" | "manuallabor" | "intelligence" | "endurance" | "totalworkingstats" | "moneyinvested" | "investedprofit" | "investamount" | "banktimeleft" | "stockprofits" | "stocklosses" | "stockfees" | "stocknetprofits" | "stockpayouts" | "networthwallet" | "networthvault" | "networthbank" | "networthcayman" | "networthpoints" | "networthitems" | "networthdisplaycase" | "networthbazaar" | "networthitemmarket" | "networthproperties" | "networthstockmarket" | "networthauctionhouse" | "networthbookie" | "networthcompany" | "networthenlistedcars" | "networthpiggybank" | "networthpending" | "networthloan" | "networthunpaidfees" | "huntingskill" | "searchforcashskill" | "bootleggingskill" | "graffitiskill" | "shopliftingskill" | "pickpocketingskill" | "cardskimmingskill" | "burglaryskill" | "hustlingskill" | "disposalskill" | "crackingskill" | "forgeryskill" | "scammingskill";
|
|
5831
|
+
PersonalStatsStatName: "attackswon" | "attackslost" | "attacksdraw" | "attacksassisted" | "defendswon" | "defendslost" | "defendsstalemated" | "elo" | "yourunaway" | "theyrunaway" | "unarmoredwon" | "bestkillstreak" | "attackhits" | "attackmisses" | "attackdamage" | "bestdamage" | "onehitkills" | "attackcriticalhits" | "roundsfired" | "specialammoused" | "hollowammoused" | "tracerammoused" | "piercingammoused" | "incendiaryammoused" | "attacksstealthed" | "retals" | "moneymugged" | "largestmug" | "itemslooted" | "highestbeaten" | "respectforfaction" | "rankedwarhits" | "raidhits" | "territoryjoins" | "territoryclears" | "territorytime" | "jobpointsused" | "trainsreceived" | "marketitemsbought" | "auctionswon" | "auctionsells" | "itemssent" | "trades" | "cityitemsbought" | "pointsbought" | "pointssold" | "bazaarcustomers" | "bazaarsales" | "bazaarprofit" | "jailed" | "peoplebusted" | "failedbusts" | "peoplebought" | "peopleboughtspent" | "hospital" | "medicalitemsused" | "bloodwithdrawn" | "reviveskill" | "revives" | "revivesreceived" | "heavyhits" | "machinehits" | "riflehits" | "smghits" | "shotgunhits" | "pistolhits" | "temphits" | "piercinghits" | "slashinghits" | "clubbinghits" | "mechanicalhits" | "h2hhits" | "mailssent" | "friendmailssent" | "factionmailssent" | "companymailssent" | "spousemailssent" | "classifiedadsplaced" | "personalsplaced" | "criminaloffensesold" | "sellillegalgoods" | "theftold" | "autotheftcrime" | "drugdealscrime" | "computercrime" | "fraudold" | "murdercrime" | "othercrime" | "organizedcrimes" | "bountiesplaced" | "totalbountyspent" | "bountiescollected" | "totalbountyreward" | "bountiesreceived" | "receivedbountyvalue" | "cityfinds" | "dumpfinds" | "itemsdumped" | "booksread" | "boostersused" | "consumablesused" | "candyused" | "alcoholused" | "energydrinkused" | "statenhancersused" | "eastereggsfound" | "eastereggsused" | "virusescoded" | "traveltimes" | "timespenttraveling" | "itemsboughtabroad" | "attackswonabroad" | "defendslostabroad" | "argtravel" | "mextravel" | "uaetravel" | "hawtravel" | "japtravel" | "uktravel" | "satravel" | "switravel" | "chitravel" | "cantravel" | "caytravel" | "drugsused" | "overdosed" | "rehabs" | "rehabcost" | "cantaken" | "exttaken" | "kettaken" | "lsdtaken" | "opitaken" | "pcptaken" | "shrtaken" | "spetaken" | "victaken" | "xantaken" | "missionscompleted" | "contractscompleted" | "dukecontractscompleted" | "missioncreditsearned" | "racingskill" | "racingpointsearned" | "racesentered" | "raceswon" | "networth" | "timeplayed" | "activestreak" | "bestactivestreak" | "awards" | "refills" | "nerverefills" | "tokenrefills" | "meritsbought" | "daysbeendonator" | "criminaloffenses" | "vandalism" | "theft" | "counterfeiting" | "fraud" | "illicitservices" | "cybercrime" | "extortion" | "illegalproduction" | "currentkillstreak" | "strength" | "defense" | "speed" | "dexterity" | "totalstats" | "manuallabor" | "intelligence" | "endurance" | "totalworkingstats" | "moneyinvested" | "investedprofit" | "investamount" | "banktimeleft" | "stockprofits" | "stocklosses" | "stockfees" | "stocknetprofits" | "stockpayouts" | "networthwallet" | "networthvault" | "networthbank" | "networthcayman" | "networthpoints" | "networthitems" | "networthdisplaycase" | "networthbazaar" | "networthitemmarket" | "networthproperties" | "networthstockmarket" | "networthauctionhouse" | "networthbookie" | "networthcompany" | "networthenlistedcars" | "networthpiggybank" | "networthpending" | "networthloan" | "networthunpaidfees" | "huntingskill" | "searchforcashskill" | "bootleggingskill" | "graffitiskill" | "shopliftingskill" | "pickpocketingskill" | "cardskimmingskill" | "burglaryskill" | "hustlingskill" | "disposalskill" | "crackingskill" | "forgeryskill" | "scammingskill" | "arsonskill";
|
|
5830
5832
|
FactionRaidReport: {
|
|
5831
5833
|
id: components["schemas"]["RaidWarId"];
|
|
5832
5834
|
/** Format: int32 */
|
|
@@ -6568,7 +6570,7 @@ interface components {
|
|
|
6568
6570
|
/** @description Details of item required for the slot, if applicable. */
|
|
6569
6571
|
item_requirement: {
|
|
6570
6572
|
id: components["schemas"]["ItemId"];
|
|
6571
|
-
/** @description Shows if the item is reusable or consumed during the crime
|
|
6573
|
+
/** @description Shows if the item is reusable or consumed during the crime.<br><b>Important note: There may be alternative paths which won't consume the item, even if the item is non-reusable.</b> */
|
|
6572
6574
|
is_reusable: boolean;
|
|
6573
6575
|
/** @description Shows if user has the required item. */
|
|
6574
6576
|
is_available: boolean;
|
|
@@ -6916,7 +6918,7 @@ interface components {
|
|
|
6916
6918
|
property: components["schemas"]["BasicProperty"];
|
|
6917
6919
|
};
|
|
6918
6920
|
MarketRentalsResponse: {
|
|
6919
|
-
|
|
6921
|
+
rentals: components["schemas"]["MarketRentalDetails"];
|
|
6920
6922
|
_metadata: components["schemas"]["RequestMetadataWithLinks"];
|
|
6921
6923
|
};
|
|
6922
6924
|
MarketPropertyDetails: {
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxx/torn-fetch",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"packageManager": "
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"packageManager": "bun@1.2.23",
|
|
5
5
|
"description": "provides a wrapper around openapi-fetch that throws an error when Torn's API returns an error",
|
|
6
6
|
"license": "Unlicense",
|
|
7
7
|
"author": "nuxx [3054747]",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"source": "src/index.ts",
|
|
10
|
-
"main": "dist/index.js",
|
|
11
|
-
"
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"COPYING",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
12
19
|
"keywords": [
|
|
13
20
|
"torn",
|
|
14
21
|
"api",
|
|
@@ -20,6 +27,13 @@
|
|
|
20
27
|
"type": "git",
|
|
21
28
|
"url": "https://github.com/nuxx-3054747/torn-fetch.git"
|
|
22
29
|
},
|
|
30
|
+
"homepage": "https://github.com/nuxx-3054747/torn-fetch#readme",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/nuxx-3054747/torn-fetch/issues"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
23
37
|
"scripts": {
|
|
24
38
|
"get-schema": "curl -A 'nuxx-torn-fetch' https://www.torn.com/swagger/openapi.json > ./src/openapi.json && openapi-typescript ./src/openapi.json -o ./src/torn-api.ts",
|
|
25
39
|
"build": "tsup",
|
|
@@ -28,7 +42,9 @@
|
|
|
28
42
|
"test": "vitest run",
|
|
29
43
|
"test:watch": "vitest",
|
|
30
44
|
"test:coverage": "vitest run --coverage",
|
|
31
|
-
"ci": "
|
|
45
|
+
"ci": "bun run get-schema && bun run lint && bun run type-check && bun run test && bun run build",
|
|
46
|
+
"prepublishOnly": "bun run ci",
|
|
47
|
+
"prepack": "bun run build"
|
|
32
48
|
},
|
|
33
49
|
"dependencies": {
|
|
34
50
|
"openapi-fetch": "^0.14.1"
|
|
@@ -48,7 +64,8 @@
|
|
|
48
64
|
"exports": {
|
|
49
65
|
".": {
|
|
50
66
|
"types": "./dist/index.d.ts",
|
|
51
|
-
"import": "./dist/index.js"
|
|
67
|
+
"import": "./dist/index.js",
|
|
68
|
+
"default": "./dist/index.js"
|
|
52
69
|
}
|
|
53
70
|
}
|
|
54
71
|
}
|