Skip to content

Commit 40f22b4

Browse files
authored
chore: add user-agent, additional sheets & improve docs (#46)
* chore(biomejs): improve config and enable for vscode * chore(vscode): add organizeImports action to code actions on save * chore: add std-env dependency, update types, and improve request handling * chore: refine request parameters handling and cleanup undefined values * chore: add actions and emotes sheets to XIVAPI and update tests for achievements * chore: rename verify-publish job to publish in CI workflow * chore: update README for clarity, improve usage examples, and enhance documentation * chore: improve example section formatting in README * chore: add output example for search sheets in README * chore: add Code of Conduct and contributing guidelines to improve community standards and documentation
1 parent 5f9ae31 commit 40f22b4

15 files changed

Lines changed: 288 additions & 125 deletions

.github/workflows/ci-verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: davelosert/vitest-coverage-report-action@v2
2828
with:
2929
threshold-icons: "{0: '🔴', 80: '🟠', 90: '🟢'}"
30-
verify-publish:
30+
publish:
3131
runs-on: ubuntu-latest
3232
needs: test
3333
permissions:

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.action.useSortedPackageJson.biome": "explicit",
4+
"source.organizeImports.biome": "explicit",
5+
"source.fixAll.biome": "explicit"
6+
}
7+
}

CODE_OF_CONDUCT.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
Our goal is to foster a respectful, welcoming, and collaborative space across every project in this monorepo. Everyone involved shares the responsibility of keeping participation positive and free from harassment.
4+
5+
## Our Standards
6+
7+
We encourage behaviors that help build a healthy and productive community:
8+
9+
- Using welcoming and inclusive language
10+
- Respecting differing viewpoints and experiences
11+
- Offering and receiving constructive feedback gracefully
12+
- Showing empathy and kindness toward others
13+
- Collaborating in ways that support the long‑term health of the project
14+
15+
## Unacceptable Behavior
16+
17+
The following behaviors are not acceptable in any project within this monorepo:
18+
19+
- Harassment, discrimination, or exclusion based on personal characteristics
20+
- Personal attacks, insults, or trolling
21+
- Public or private harassment of any kind
22+
- Deliberate intimidation or threats
23+
- Disruptive behavior that interferes with constructive collaboration
24+
25+
## Enforcement
26+
27+
If you observe or experience behavior that violates this Code of Conduct, please contact the maintainers through the repository’s issue tracker or by opening a private security advisory.
28+
29+
All reports will be handled confidentially.
30+
Maintainers are responsible for reviewing incidents, determining appropriate actions, and enforcing this Code of Conduct fairly and consistently across the monorepo.
31+
32+
## Attribution
33+
34+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/) version 2.1.

CONTRIBUTING

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contributing to xivapi-js
2+
3+
Thanks for your interest in contributing! We welcome contributions of all kinds, including bug fixes, new features, documentation improvements, and — eventually — translations.
4+
5+
## How to Contribute
6+
7+
1. **Fork** the repository.
8+
2. **Create a feature branch**, for example:
9+
```bash
10+
git checkout -b feature/your-feature-name
11+
```
12+
3. Make your changes, following the style and structure of the project or package you are modifying.
13+
4. Add tests or verify that your changes work as expected.
14+
5. Commit your work using clear, descriptive commit messages.
15+
6. Push your branch:
16+
```bash
17+
git push origin feature/your-feature-name
18+
```
19+
7. Open a Pull Request.
20+
In your PR description, include:
21+
22+
- What you changed
23+
- Why you changed it
24+
- Any related issues or context
25+
26+
## Reporting Issues
27+
28+
Before opening a new issue:
29+
30+
- Check existing issues to avoid duplicates.
31+
- Provide a clear description of the problem or feature request.
32+
- For bugs, include steps to reproduce, expected vs. actual behavior, and any relevant logs or screenshots.
33+
- For feature requests, explain the problem the feature solves and any alternatives you’ve considered.
34+
35+
## Code Style & Tests
36+
37+
- Follow the existing coding conventions (formatting, naming, structure).
38+
- Update or add tests when appropriate.
39+
- Ensure all tests pass before submitting your PR (if a test suite is available).
40+
- Keep changes focused—smaller, well‑scoped PRs are easier to review and merge.
41+
42+
## Community Code of Conduct
43+
44+
By contributing to this monorepo, you agree to follow our [Code of Conduct](./CODE_OF_CONDUCT.md).

README.md

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ If you need help or run into any issues, please [open an issue](https://github.c
1313
## Installation
1414

1515
```bash
16-
npm install @xivapi/js@latest # or use yarn, pnpm, or bun
16+
npm install @xivapi/js
1717
```
1818

19-
## Usage Examples
19+
Supports Node, Bun, Deno, and modern bundlers.
2020

21-
#### 1. Importing and Initialization
21+
## Quick Start
2222

2323
```js
2424
import xivapi from "@xivapi/js";
@@ -34,29 +34,24 @@ const xivCustom = new xivapi({
3434
});
3535
```
3636

37-
#### 2. Get an Item
37+
## Examples
38+
39+
#### Get an Item
3840

3941
```js
40-
// Fetch the Gil item (item ID 1)
4142
const item = await xiv.items.get(1);
42-
43-
console.log(item.fields.Name); // "Gil" (or equivalent in your language)
43+
console.log(item.fields.Name); // "Gil"
4444
```
4545

46-
#### 3. Search Example
46+
#### Search sheets
4747

4848
```js
49-
// Find all items named "gil"
50-
const params = {
51-
query: 'Name~"gil"',
52-
sheets: "Item",
53-
};
54-
49+
const params = { query: 'Name~"gil"', sheets: "Item" };
5550
const { results } = await xiv.search(params);
5651
console.log(results[0]);
5752

5853
/*
59-
Output example:
54+
Output:
6055
{
6156
"score": 1,
6257
"sheet": "Item",
@@ -74,17 +69,17 @@ Output example:
7469
*/
7570
```
7671

77-
#### 4. Using Raw XIVAPI v2 Endpoints
72+
#### Using raw XIVAPI v2 endpoints
7873

7974
```js
80-
// Fetch a raw asset file (e.g. icon image)
75+
// Fetch an asset (e.g., icon)
8176
const assets = await xiv.data.assets();
8277
const asset = await assets.get({
8378
path: "ui/icon/051000/051474_hr1.tex",
8479
format: "png", // jpg or webp also supported
8580
});
8681

87-
// List all quests
82+
// List all rows from the "Quest" sheet
8883
const sheets = await xiv.data.sheets();
8984
const quests = await sheets.list("Quest");
9085
console.log(quests);
@@ -96,17 +91,8 @@ console.log(versions[0]); // e.g. "7.0"
9691

9792
## Contributing
9893

99-
We welcome all contributions! Whether you'd like to report a bug, suggest a feature, improve the documentation, or submit a pull request, your help is appreciated.
100-
101-
To get started, clone the repository with: `git clone https://github.com/xivapi/xivapi-js.git`
102-
103-
Before opening a pull request, please:
104-
105-
- Make sure your code passes linting and all current tests (`npm run lint && npm test`).
106-
- Clearly explain your changes and reference any relevant issues in your PR description.
107-
108-
If you have questions, suggestions, or want to discuss changes before contributing, feel free to open an issue!
94+
Contributions, bug reports, and feature requests are welcome! See [`CONTRIBUTING`](CONTRIBUTING) for guidelines on how to get started.
10995

11096
## License
11197

112-
MIT License - see [LICENSE](LICENSE) file for details.
98+
This project is licensed under the MIT License. See [`LICENSE`](LICENSE) for details.

biome.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
},
4848
"assist": {
4949
"enabled": true,
50-
"actions": { "source": { "organizeImports": "on" } }
50+
"actions": {
51+
"source": {
52+
"preset": "recommended",
53+
"organizeImports": "on",
54+
"useSortedPackageJson": "on"
55+
}
56+
}
5157
}
5258
}

package-lock.json

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,37 @@
22
"name": "@xivapi/js",
33
"version": "1.0.5",
44
"description": "A Node.JS wrapper for xivapi.com",
5+
"keywords": ["xivapi", "ffxiv"],
6+
"homepage": "https://github.com/xivapi/xivapi-js",
7+
"bugs": {
8+
"url": "https://github.com/xivapi/xivapi-js/issues"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/xivapi/xivapi-js.git"
13+
},
514
"license": "MIT",
615
"author": "Kai <mail@kai.moe> (https://kai.moe/)",
716
"type": "module",
817
"main": "./dist/index.cjs",
918
"module": "./dist/index.js",
1019
"types": "./dist/index.d.ts",
20+
"files": ["dist"],
1121
"scripts": {
1222
"build": "tsdown",
13-
"test": "vitest --coverage",
23+
"format": "biome format --write",
1424
"lint": "biome check --write",
1525
"lint:check": "biome check",
16-
"format": "biome format --write"
26+
"test": "vitest --coverage"
27+
},
28+
"dependencies": {
29+
"std-env": "^4.1.0"
1730
},
1831
"devDependencies": {
1932
"@biomejs/biome": "2.5.1",
2033
"@eslint/js": "^10.0.1",
2134
"@tsconfig/node22": "^22.0.5",
22-
"@types/node": "^26.0.0",
35+
"@types/node": "^26.0.1",
2336
"@vitest/coverage-v8": "^4.1.9",
2437
"eslint": "^10.5.0",
2538
"eslint-config-prettier": "^10.1.8",
@@ -32,16 +45,6 @@
3245
"typescript-eslint": "^8.61.1",
3346
"vitest": "^4.1.9"
3447
},
35-
"homepage": "https://github.com/xivapi/xivapi-js#readme",
36-
"bugs": {
37-
"url": "https://github.com/xivapi/xivapi-js/issues"
38-
},
39-
"repository": {
40-
"type": "git",
41-
"url": "git+https://github.com/xivapi/xivapi-js.git"
42-
},
43-
"keywords": ["xivapi", "ffxiv"],
44-
"files": ["dist"],
4548
"engines": {
4649
"node": ">=20.0.0"
4750
}

src/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
import { Assets } from "./lib/assets.js";
22
import { Sheet, Sheets } from "./lib/sheets.js";
33
import { Versions } from "./lib/versions.js";
4-
import * as Models from "./models.js";
4+
import type * as Models from "./models.d.ts";
55
import { CustomError, request } from "./utils.js";
66

77
export default class XIVAPI {
8-
public readonly options: XIVAPIOptions;
9-
108
public readonly achievements: Sheet<"Achievement">;
9+
public readonly actions: Sheet<"Action">;
10+
public readonly emotes: Sheet<"Emote">;
11+
public readonly items: Sheet<"Item">;
1112
public readonly minions: Sheet<"Companion">;
1213
public readonly mounts: Sheet<"Mount">;
13-
public readonly items: Sheet<"Item">;
14+
public readonly options: XIVAPIOptions;
1415

1516
/**
1617
* Raw endpoints for the API. Please consider using the typed endpoints instead.
1718
* @see https://v2.xivapi.com/api/docs
18-
* @since 0.5.0
19+
* @since 1.0.0
1920
*/
2021
public readonly data = {
2122
/**
2223
* @see https://v2.xivapi.com/api/docs#tag/sheets
23-
* @since 0.5.0
24+
* @since 1.0.0
2425
*/
2526
sheets: () => new Sheets(this.options),
2627
/**
2728
* @see https://v2.xivapi.com/api/docs#tag/versions
28-
* @since 0.5.0
29+
* @since 1.0.0
2930
*/
3031
versions: () =>
3132
new Versions()
@@ -35,7 +36,7 @@ export default class XIVAPI {
3536
),
3637
/**
3738
* @see https://v2.xivapi.com/api/docs#tag/assets
38-
* @since 0.5.0
39+
* @since 1.0.0
3940
*/
4041
assets: () => new Assets(),
4142
};
@@ -44,7 +45,7 @@ export default class XIVAPI {
4445
* A wrapper for the XIVAPI v2 API.
4546
* @param {XIVAPIOptions} [options] The client options to fetch with.
4647
* @see https://v2.xivapi.com/api/docs
47-
* @since 0.5.0
48+
* @since 1.0.0
4849
*/
4950
constructor(
5051
options: XIVAPIOptions = {
@@ -54,10 +55,11 @@ export default class XIVAPI {
5455
}
5556
) {
5657
this.achievements = new Sheet("Achievement", options);
58+
this.actions = new Sheet("Action", options);
59+
this.emotes = new Sheet("Emote", options);
60+
this.items = new Sheet("Item", options);
5761
this.minions = new Sheet("Companion", options);
5862
this.mounts = new Sheet("Mount", options);
59-
this.items = new Sheet("Item", options);
60-
6163
this.options = options;
6264
}
6365

@@ -66,12 +68,13 @@ export default class XIVAPI {
6668
* @param {SearchParams} params Query paramters accepted by the search endpoint.
6769
* @returns {Promise<Models.SearchResponse>} Response structure for the search endpoint.
6870
* @see https://v2.xivapi.com/api/docs#tag/search/get/search
69-
* @since 0.5.0
71+
* @since 1.0.0
7072
*/
7173
public async search(params: SearchParams): Promise<Models.SearchResponse> {
7274
const { data, errors } = await request({
7375
path: "/search",
7476
params: params as Record<string, unknown>,
77+
options: this.options
7578
});
7679
if (errors) throw new CustomError(errors[0].message);
7780
return data as Models.SearchResponse;
@@ -103,4 +106,4 @@ export type SearchParams = Models.SearchQuery &
103106
Models.VersionQuery &
104107
Models.RowReaderQuery & { verbose?: boolean };
105108

106-
export { Models, XIVAPI };
109+
export { type Models, XIVAPI };

0 commit comments

Comments
 (0)