Skip to content

Commit

Permalink
Update v1.2.0 (#12)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
LucJosin authored Nov 8, 2023
1 parent 9b4e0e5 commit f89b88a
Show file tree
Hide file tree
Showing 9 changed files with 5,162 additions and 3,289 deletions.
73 changes: 12 additions & 61 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Docs
docs/

# Output
dist

# Logs
logs
*.log
Expand All @@ -12,12 +15,6 @@ lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

Expand All @@ -28,15 +25,6 @@ coverage
# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

Expand All @@ -57,52 +45,15 @@ types/
# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity
# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
.env.test
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@hawapi/js-sdk",
"packageManager": "yarn@4.0.1",
"description": "HawAPI SDK for JavaScript",
"version": "1.1.0",
"version": "1.2.0",
"repository": "git@github.com:HawAPI/js-sdk.git",
"author": {
"name": "Lucas Josino",
Expand Down Expand Up @@ -62,23 +63,23 @@
"publish:dry-wot": "yarn lint && yarn build"
},
"devDependencies": {
"@mxssfd/typedoc-theme": "^1.1.2",
"@rollup/plugin-terser": "^0.4.3",
"@types/eslint": "^8.44.2",
"@types/jest": "^29.5.4",
"@mxssfd/typedoc-theme": "^1.1.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/eslint": "^8.44.7",
"@types/jest": "^29.5.8",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.47.0",
"@typescript-eslint/parser": "^5.47.0",
"eslint": "^8.48.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.6.4",
"jest": "^29.7.0",
"prettier": "^2.8.1",
"rollup": "^2.79.1",
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-typescript2": "^0.36.0",
"ts-jest": "^29.1.1",
"ts-jest-resolver": "^2.0.1",
"typedoc": "^0.24.8",
"typedoc": "^0.25.3",
"typescript": "^4.9.4"
}
}
15 changes: 15 additions & 0 deletions src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export const API_VERSION = 'v1';
*/
export const API_DEFAULT_LANG = 'en-US';

/**
* The API rate limit remaining
*/
export const API_HEADER_RATE_LIMIT_REMAINING = 'X-Rate-Limit-Remaining';

/**
* The API page index header
*/
Expand All @@ -37,3 +42,13 @@ export const API_HEADER_ITEM_TOTAL = 'X-Pagination-Item-Total';
* The API language header
*/
export const API_HEADER_CONTENT_LANGUAGE = 'Content-Language';

/**
* The API content length
*/
export const API_HEADER_CONTENT_LENGTH = 'Content-Length';

/**
* The API content etag
*/
export const API_HEADER_ETAG = 'ETag';
2 changes: 1 addition & 1 deletion src/HawAPIOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class HawAPIOptions {

/**
* The HawAPI token (JWT) \
* By default, all requests are made with **'ANONYMOUS'** tier with limit of **8 req/60s**
* By default, all requests are made with **'ANONYMOUS'** tier with limit of **16 req/60s**
*
* See more {@link https://hawapi.theproject.id/docs/guides/rate-limiting}
*/
Expand Down
12 changes: 12 additions & 0 deletions src/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
API_HEADER_CONTENT_LANGUAGE,
API_HEADER_CONTENT_LENGTH,
API_HEADER_ETAG,
API_HEADER_ITEM_TOTAL,
API_HEADER_PAGE_INDEX,
API_HEADER_PAGE_SIZE,
API_HEADER_PAGE_TOTAL,
API_HEADER_RATE_LIMIT_REMAINING,
} from './Constants';
import HawAPIOptions from './HawAPIOptions';
import { EndpointType, Endpoints } from './enums';
Expand Down Expand Up @@ -39,6 +42,10 @@ export function buildResult<T>(
const item_total = headers.get(API_HEADER_ITEM_TOTAL);
const language = headers.get(API_HEADER_CONTENT_LANGUAGE);

const etag = headers.get(API_HEADER_ETAG)!;
const length = headers.get(API_HEADER_CONTENT_LENGTH)!;
const remaining = headers.get(API_HEADER_RATE_LIMIT_REMAINING)!;

return {
page: Number(page) || undefined,
page_size: Number(page_size) || undefined,
Expand All @@ -48,6 +55,11 @@ export function buildResult<T>(
prev_page: handlePagination(Number(page), false) || undefined,
language: language || undefined,
status: status,
quota: {
remaining: Number(remaining),
},
length: Number(length),
etag,
data: body,
};
}
Expand Down
13 changes: 12 additions & 1 deletion src/models/OverviewModel.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { BaseModel } from './base/BaseModel';

interface DataCount {
actors: number;
characters: number;
episodes: number;
games: number;
locations: number;
seasons: number;
soundtracks: number;
}

export interface OverviewModel extends BaseModel {
title: string;
description: string;
language: string;
languages: string;
languages: string[];
creators: string;
data_count: DataCount;
}
19 changes: 19 additions & 0 deletions src/models/http/RequestResult.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export interface Quota {
remaining?: number;
}

/**
* Formatted result from request
*/
Expand Down Expand Up @@ -44,6 +48,21 @@ export interface RequestResult<T> {
*/
status: number;

/**
* The quota status
*/
quota: Quota;

/**
* The etag value for the data
*/
etag: string;

/**
* The total content size/length
*/
length: number;

/**
* Determine if data is from cache
*/
Expand Down
Loading

0 comments on commit f89b88a

Please sign in to comment.