From b5034bfa9c8f23f516126ebffb12d18db6798e41 Mon Sep 17 00:00:00 2001 From: Blake Joynes Date: Mon, 31 May 2021 14:48:00 -0400 Subject: [PATCH] added certifactions and configurations, util function for constructing image paths --- package.json | 7 +++---- src/index.ts | 3 +++ src/types/{certification.d.ts => certification.ts} | 0 src/types/{changes.d.ts => changes.ts} | 0 src/types/{configuration.d.ts => configuration.ts} | 0 src/types/{credits.d.ts => credits.ts} | 1 + src/types/{index.d.ts => index.ts} | 7 ------- src/types/{movie.d.ts => movie.ts} | 0 src/utils/getImagePath.ts | 8 ++++++-- src/utils/index.ts | 1 + tsconfig.json | 5 ++++- 11 files changed, 18 insertions(+), 14 deletions(-) rename src/types/{certification.d.ts => certification.ts} (100%) rename src/types/{changes.d.ts => changes.ts} (100%) rename src/types/{configuration.d.ts => configuration.ts} (100%) rename src/types/{credits.d.ts => credits.ts} (95%) rename src/types/{index.d.ts => index.ts} (97%) rename src/types/{movie.d.ts => movie.ts} (100%) create mode 100644 src/utils/index.ts diff --git a/package.json b/package.json index 53ef35f..998aa9d 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,15 @@ { "name": "tmdb-ts", - "version": "0.0.3", + "version": "0.0.7", "description": "TMDB v3 library wrapper", - "main": "dist/index.ts", - "types": "dist/types/index.d.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { "compile": "rm -rf dist && tsc -d && npm run copy-types", "lint": "eslint --ext .ts src/", "lint:fix": "eslint --ext .ts src/ --fix", "prepublish": "tsc", "copy-types": "mkdir dist/types && cp src/types/*.d.ts dist/types" - }, "bugs": { "url": "https://github.com/blakejoy/tmdb-ts/issues", diff --git a/src/index.ts b/src/index.ts index 01632a6..b815434 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,6 @@ import TMDB from './tmdb'; +export * from './types'; +export * from './utils'; + export default TMDB; diff --git a/src/types/certification.d.ts b/src/types/certification.ts similarity index 100% rename from src/types/certification.d.ts rename to src/types/certification.ts diff --git a/src/types/changes.d.ts b/src/types/changes.ts similarity index 100% rename from src/types/changes.d.ts rename to src/types/changes.ts diff --git a/src/types/configuration.d.ts b/src/types/configuration.ts similarity index 100% rename from src/types/configuration.d.ts rename to src/types/configuration.ts diff --git a/src/types/credits.d.ts b/src/types/credits.ts similarity index 95% rename from src/types/credits.d.ts rename to src/types/credits.ts index eac562b..b0da2ce 100644 --- a/src/types/credits.d.ts +++ b/src/types/credits.ts @@ -1,3 +1,4 @@ +import { Person } from './'; export interface CreditSeason { air_date?: string; diff --git a/src/types/index.d.ts b/src/types/index.ts similarity index 97% rename from src/types/index.d.ts rename to src/types/index.ts index 3c3ac25..fdcebbf 100644 --- a/src/types/index.d.ts +++ b/src/types/index.ts @@ -93,10 +93,3 @@ export interface ExternalIds { twitter_id: string; id: number; } - - -export { - certs, - credits, - changes, -}; diff --git a/src/types/movie.d.ts b/src/types/movie.ts similarity index 100% rename from src/types/movie.d.ts rename to src/types/movie.ts diff --git a/src/utils/getImagePath.ts b/src/utils/getImagePath.ts index 793a9ca..05e54d2 100644 --- a/src/utils/getImagePath.ts +++ b/src/utils/getImagePath.ts @@ -6,7 +6,11 @@ * @param {string} baseUrl base image url * @param {string} fileSize file size * @param {string} imagePath raw image path + * @param {boolean} svg get svg version if true */ -export const getFullImagePath = (baseUrl: string, fileSize: string, imagePath: string): string => { - return `${baseUrl}${fileSize}${imagePath}`; +export const getFullImagePath = (baseUrl: string, fileSize: string, imagePath: string, svg = false): string => { + const imagePathArr = imagePath.split('.'); + const imageFormat = svg ? 'svg' : imagePathArr[1]; + + return `${baseUrl}${fileSize}${imagePathArr[0]}.${imageFormat}`; }; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..eb42ebf --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1 @@ +export * from './getImagePath'; diff --git a/tsconfig.json b/tsconfig.json index 62c9f66..03b2f6a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,10 @@ "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */, "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ + "typeRoots": [ + "./src/types" + ] }, "types": ["node"], "include": [