Skip to content

Commit f89b88a

Browse files
authored
Update v1.2.0 (#12)
Features - Add `data_count` to overview model - Add `etag`, `length` and `quota` params to RequestResult Changes - Update dependencies - Update HawAPIOptions documentation Fixes - Fix wrong `languages` type in overview model *Bump version to 1.2.0* *Upgrade to yarn 4.X*
1 parent 9b4e0e5 commit f89b88a

File tree

9 files changed

+5162
-3289
lines changed

9 files changed

+5162
-3289
lines changed

.gitignore

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Docs
22
docs/
33

4+
# Output
5+
dist
6+
47
# Logs
58
logs
69
*.log
@@ -12,12 +15,6 @@ lerna-debug.log*
1215
# Diagnostic reports (https://nodejs.org/api/report.html)
1316
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
1417

15-
# Runtime data
16-
pids
17-
*.pid
18-
*.seed
19-
*.pid.lock
20-
2118
# Directory for instrumented libs generated by jscoverage/JSCover
2219
lib-cov
2320

@@ -28,15 +25,6 @@ coverage
2825
# nyc test coverage
2926
.nyc_output
3027

31-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32-
.grunt
33-
34-
# Bower dependency directory (https://bower.io/)
35-
bower_components
36-
37-
# node-waf configuration
38-
.lock-wscript
39-
4028
# Compiled binary addons (https://nodejs.org/api/addons.html)
4129
build/Release
4230

@@ -57,52 +45,15 @@ types/
5745
# Optional eslint cache
5846
.eslintcache
5947

60-
# Microbundle cache
61-
.rpt2_cache/
62-
.rts2_cache_cjs/
63-
.rts2_cache_es/
64-
.rts2_cache_umd/
65-
66-
# Optional REPL history
67-
.node_repl_history
68-
69-
# Output of 'npm pack'
70-
*.tgz
71-
72-
# Yarn Integrity file
73-
.yarn-integrity
48+
# Yarn
49+
.pnp.*
50+
.yarn/*
51+
!.yarn/patches
52+
!.yarn/plugins
53+
!.yarn/releases
54+
!.yarn/sdks
55+
!.yarn/versions
7456

7557
# dotenv environment variables file
7658
.env
77-
.env.test
78-
79-
# parcel-bundler cache (https://parceljs.org/)
80-
.cache
81-
82-
# Next.js build output
83-
.next
84-
85-
# Nuxt.js build / generate output
86-
.nuxt
87-
dist
88-
89-
# Gatsby files
90-
.cache/
91-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
92-
# https://nextjs.org/blog/next-9-1#public-directory-support
93-
# public
94-
95-
# vuepress build output
96-
.vuepress/dist
97-
98-
# Serverless directories
99-
.serverless/
100-
101-
# FuseBox cache
102-
.fusebox/
103-
104-
# DynamoDB Local files
105-
.dynamodb/
106-
107-
# TernJS port file
108-
.tern-port
59+
.env.test

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@hawapi/js-sdk",
3+
"packageManager": "yarn@4.0.1",
34
"description": "HawAPI SDK for JavaScript",
4-
"version": "1.1.0",
5+
"version": "1.2.0",
56
"repository": "git@github.com:HawAPI/js-sdk.git",
67
"author": {
78
"name": "Lucas Josino",
@@ -62,23 +63,23 @@
6263
"publish:dry-wot": "yarn lint && yarn build"
6364
},
6465
"devDependencies": {
65-
"@mxssfd/typedoc-theme": "^1.1.2",
66-
"@rollup/plugin-terser": "^0.4.3",
67-
"@types/eslint": "^8.44.2",
68-
"@types/jest": "^29.5.4",
66+
"@mxssfd/typedoc-theme": "^1.1.3",
67+
"@rollup/plugin-terser": "^0.4.4",
68+
"@types/eslint": "^8.44.7",
69+
"@types/jest": "^29.5.8",
6970
"@types/prettier": "^2.7.2",
7071
"@typescript-eslint/eslint-plugin": "^5.47.0",
7172
"@typescript-eslint/parser": "^5.47.0",
72-
"eslint": "^8.48.0",
73+
"eslint": "^8.53.0",
7374
"eslint-config-prettier": "^8.5.0",
7475
"eslint-plugin-prettier": "^4.2.1",
75-
"jest": "^29.6.4",
76+
"jest": "^29.7.0",
7677
"prettier": "^2.8.1",
7778
"rollup": "^2.79.1",
78-
"rollup-plugin-typescript2": "^0.34.1",
79+
"rollup-plugin-typescript2": "^0.36.0",
7980
"ts-jest": "^29.1.1",
8081
"ts-jest-resolver": "^2.0.1",
81-
"typedoc": "^0.24.8",
82+
"typedoc": "^0.25.3",
8283
"typescript": "^4.9.4"
8384
}
8485
}

src/Constants.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export const API_VERSION = 'v1';
1313
*/
1414
export const API_DEFAULT_LANG = 'en-US';
1515

16+
/**
17+
* The API rate limit remaining
18+
*/
19+
export const API_HEADER_RATE_LIMIT_REMAINING = 'X-Rate-Limit-Remaining';
20+
1621
/**
1722
* The API page index header
1823
*/
@@ -37,3 +42,13 @@ export const API_HEADER_ITEM_TOTAL = 'X-Pagination-Item-Total';
3742
* The API language header
3843
*/
3944
export const API_HEADER_CONTENT_LANGUAGE = 'Content-Language';
45+
46+
/**
47+
* The API content length
48+
*/
49+
export const API_HEADER_CONTENT_LENGTH = 'Content-Length';
50+
51+
/**
52+
* The API content etag
53+
*/
54+
export const API_HEADER_ETAG = 'ETag';

src/HawAPIOptions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class HawAPIOptions {
4545

4646
/**
4747
* The HawAPI token (JWT) \
48-
* By default, all requests are made with **'ANONYMOUS'** tier with limit of **8 req/60s**
48+
* By default, all requests are made with **'ANONYMOUS'** tier with limit of **16 req/60s**
4949
*
5050
* See more {@link https://hawapi.theproject.id/docs/guides/rate-limiting}
5151
*/

src/Utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import {
22
API_HEADER_CONTENT_LANGUAGE,
3+
API_HEADER_CONTENT_LENGTH,
4+
API_HEADER_ETAG,
35
API_HEADER_ITEM_TOTAL,
46
API_HEADER_PAGE_INDEX,
57
API_HEADER_PAGE_SIZE,
68
API_HEADER_PAGE_TOTAL,
9+
API_HEADER_RATE_LIMIT_REMAINING,
710
} from './Constants';
811
import HawAPIOptions from './HawAPIOptions';
912
import { EndpointType, Endpoints } from './enums';
@@ -39,6 +42,10 @@ export function buildResult<T>(
3942
const item_total = headers.get(API_HEADER_ITEM_TOTAL);
4043
const language = headers.get(API_HEADER_CONTENT_LANGUAGE);
4144

45+
const etag = headers.get(API_HEADER_ETAG)!;
46+
const length = headers.get(API_HEADER_CONTENT_LENGTH)!;
47+
const remaining = headers.get(API_HEADER_RATE_LIMIT_REMAINING)!;
48+
4249
return {
4350
page: Number(page) || undefined,
4451
page_size: Number(page_size) || undefined,
@@ -48,6 +55,11 @@ export function buildResult<T>(
4855
prev_page: handlePagination(Number(page), false) || undefined,
4956
language: language || undefined,
5057
status: status,
58+
quota: {
59+
remaining: Number(remaining),
60+
},
61+
length: Number(length),
62+
etag,
5163
data: body,
5264
};
5365
}

src/models/OverviewModel.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import { BaseModel } from './base/BaseModel';
22

3+
interface DataCount {
4+
actors: number;
5+
characters: number;
6+
episodes: number;
7+
games: number;
8+
locations: number;
9+
seasons: number;
10+
soundtracks: number;
11+
}
12+
313
export interface OverviewModel extends BaseModel {
414
title: string;
515
description: string;
616
language: string;
7-
languages: string;
17+
languages: string[];
818
creators: string;
19+
data_count: DataCount;
920
}

src/models/http/RequestResult.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export interface Quota {
2+
remaining?: number;
3+
}
4+
15
/**
26
* Formatted result from request
37
*/
@@ -44,6 +48,21 @@ export interface RequestResult<T> {
4448
*/
4549
status: number;
4650

51+
/**
52+
* The quota status
53+
*/
54+
quota: Quota;
55+
56+
/**
57+
* The etag value for the data
58+
*/
59+
etag: string;
60+
61+
/**
62+
* The total content size/length
63+
*/
64+
length: number;
65+
4766
/**
4867
* Determine if data is from cache
4968
*/

0 commit comments

Comments
 (0)