From dacfae07d81a881a575d289644b2248bdb967db7 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 Jan 2021 12:04:31 +0100 Subject: [PATCH 1/9] feat: added typescript support and updated docs accordingly --- .eslintignore | 3 + docs/content/en/index.md | 4 + docs/content/en/proxy.md | 2 +- docs/content/en/typescript.md | 153 ++++++++++++++++++++++++ lib/index.d.ts | 160 +++++++++++++++++++++++++ package.json | 1 + yarn.lock | 219 +++++++++++++++++++++++++++++++++- 7 files changed, 537 insertions(+), 5 deletions(-) create mode 100644 docs/content/en/typescript.md create mode 100644 lib/index.d.ts diff --git a/.eslintignore b/.eslintignore index b4eaf65a..f055f571 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,3 +6,6 @@ coverage # Plugin lib/plugin.js + +# Typings +/**/*.d.ts diff --git a/docs/content/en/index.md b/docs/content/en/index.md index 5b3d9fde..ab329e6d 100644 --- a/docs/content/en/index.md +++ b/docs/content/en/index.md @@ -8,6 +8,7 @@ features: - RESTful methods - Adaptive SDK for API entities - Handle errors with hooks + - TypeScript support --- @@ -15,6 +16,9 @@ features: This module is a wrapper around [Strapi](https://strapi.io/) for [NuxtJS](https://nuxtjs.org). +If you want to know how to use this module with TypeScript, +check out [this page](https://strapi.nuxtjs.org/typescript) of the docs. + ## Features diff --git a/docs/content/en/proxy.md b/docs/content/en/proxy.md index a0ff8d97..bd479e9e 100644 --- a/docs/content/en/proxy.md +++ b/docs/content/en/proxy.md @@ -1,7 +1,7 @@ --- title: Using a proxy description: 'Use Strapi behind a proxy with Nuxt Proxy module' -position: 7 +position: 8 category: Advanced fullscreen: true --- diff --git a/docs/content/en/typescript.md b/docs/content/en/typescript.md new file mode 100644 index 00000000..547badc0 --- /dev/null +++ b/docs/content/en/typescript.md @@ -0,0 +1,153 @@ +--- +title: Usage with Typescript +description: 'Discover how you can setup your project to integrate Strapi with TypeScript' +position: 7 +category: Advanced +--- + +## Setup + +Thanks to [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html), +you can tell the TypeScript compiler where to find the `$strapi` types by adding these lines to your +`tsconfig.json`. + +```json[tsconfig.json] +{ + "compilerOptions": { + "types": [ + "@nuxtjs/strapi" + ] + } +} +``` + +## Usage + +You now have access to `this.$strapi` inside your components and to `ctx.$strapi` inside +`asyncData`, `fetch`, `plugins`, `middlewares` and `nuxtServerInit`. + +### In component methods +```vue + +``` + +> Notice how you can define the type of the query parameters and of the returned value using generics. + +### Inside methods that use `context` +```vue + +``` + +## Known issues + +There are some known issues with the current implementation of TypeScript in the library, +so we have listed some workarounds. + +### Entity shortcuts + +The current TypeScript implementation doesn't support entity shortcuts: your code may work, +but it will throw type checking errors. This is why we made the `entity` parameter needed in +every method which involves a query. + +You can however define the entities available to your Vue methods with +[string literal types](https://www.typescriptlang.org/docs/handbook/literal-types.html#string-literal-types) +as described below. + +```vue + +``` + +### Query params + +Some query methods won't be accepted by the compiler if you define generics as in `$strapi.find` +(e.g.: the array methods described [here](https://strapi.nuxtjs.org/strapi#findentity-params)). + +You can get around this issue by doing something like below. + +```vue + +``` + +> You can always declare the return type by assigning a type to the variable instead of the method. diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 00000000..47c3e611 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,160 @@ +import Vue from 'vue'; +import { Context } from '@nuxt/types'; +import { NuxtHTTPInstance } from '@nuxt/http'; +import { NuxtCookies } from 'cookie-universal-nuxt'; + +type NuxtStrapiQueryParams = T | { [key: string]: any }; + +interface NuxtStrapiGraphQLParams { + query: string; +} + +interface NuxtStrapiRegistrationData { + username: string; + email: string; + password: string; +} + +interface NuxtStrapiLoginData { + /** + * Can be either the email or the username set by the user. + * */ + identifier: string; + password: string; +} + +interface NuxtStrapiEmailData { + email: string; +} + +interface NuxtStrapiResetPasswordData { + code: string; + password: string; + passwordConfirmation: string; +} + +export interface NuxtStrapi { + /** + * Use this object to access details about the + * authenticated user or to directly set a user prop. + * */ + user: { [key: string]: any }; + + /** + * Get entries. + * Returns entries matching the query filters. + * You can read more about parameters + * [here](https://strapi.io/documentation/developer-docs/latest/content-api/parameters.html). + * */ + find(entity: Entities, params?: NuxtStrapiQueryParams ): Promise; + + /** + * Count entries. + * Returns the count of entries matching the query filters. + * You can read more about parameters + * [here](https://strapi.io/documentation/developer-docs/latest/content-api/parameters.html). + * */ + count(entity: Entities, params?: NuxtStrapiQueryParams): Promise; + + /** + * Get an entry by id and returns its value. + * */ + findOne(entity: Entities, id?: string): Promise; + + /** + * Creates an entry and returns its value. + * */ + create(entity: Entities, data?: NuxtStrapiQueryParams): Promise; + + /** + * Partially updates an entry by id and returns its value. + * Fields that aren't sent in the query are not changed in the db. + * Send a null value if you want to clear them. + * */ + update(entity: Entities, id: string, data?: NuxtStrapiQueryParams): Promise; + + /** + * Deletes an entry by id and returns its value. + * */ + delete(entity: Entities, id: string): Promise; + + /** + * Performs an HTTP request to GraphQL API and returns the requested data. + * */ + graphql(data: NuxtStrapiGraphQLParams): Promise; + + /** + * Register using local strategy. Sets the User and Token. + * */ + register(data: NuxtStrapiRegistrationData): Promise; + + /** + * Login using local strategy. Sets the User and Token. + * */ + login(data: NuxtStrapiLoginData): Promise; + + /** + * Send a request to the forgot-password endpoint of the server. + * */ + forgotPassword(data: NuxtStrapiEmailData): Promise; + + /** + * Send a request to the reset-password endpoint of the server. + * */ + resetPassword(data: NuxtStrapiResetPasswordData): Promise; + + /** + * Send an email confirmation for the login. + * */ + sendEmailConfirmation(data: NuxtStrapiEmailData): Promise; + + /** + * Clears the user and jwt in cookies. + * */ + logout(): void; + + /** + * Fetch me user from /users/me route if a jwt is present in the cookies. + * Sets the jwt inside $http. Sets the User. + * */ + fetchUser(): Promise; + + /** + * This method fully overrides the user object, avoid using it. + * You can use the $strapi.user property to mutate single + * object properties instead of overriding it completely. + * */ + setUser(user: T): void; + + /** + * Returns jwt from cookies. + * */ + getToken(): string; + + /** + * Sets token inside $http as a jwt Bearer. + * Store jwt in cookies. + * */ + setToken(token: string): void; + + /** + * Remove jwt from $http and $cookies. + * */ + clearToken(): void; + + $http: NuxtHTTPInstance; + + $cookies: NuxtCookies; +} + +declare module 'vue/types/vue' { + interface Vue { + $strapi: NuxtStrapi; + } +} + +declare module '@nuxt/types' { + interface Context { + $strapi: NuxtStrapi; + } +} diff --git a/package.json b/package.json index 849c01b0..829521e6 100755 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@babel/preset-env": "^7.12.11", "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^11.0.0", + "@nuxt/types": "^2.14.12", "@nuxtjs/eslint-config": "^5.0.0", "@nuxtjs/module-test-utils": "latest", "babel-eslint": "latest", diff --git a/yarn.lock b/yarn.lock index f9cd6764..e6dacc27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1465,6 +1465,30 @@ rc9 "^1.2.0" std-env "^2.2.1" +"@nuxt/types@^2.14.12": + version "2.14.12" + resolved "https://registry.yarnpkg.com/@nuxt/types/-/types-2.14.12.tgz#4e5aa642b67081890b3b7aab03db62855ef71a25" + integrity sha512-x58uEVygHual/kHDTrLAwXjKNYn+5udR4HJOmHd2gXgYonZu8E2UpsShIkyMRZ0nRoEAZ72i4OfcHKqGsVSI6w== + dependencies: + "@types/autoprefixer" "^9.7.2" + "@types/babel__core" "^7.1.12" + "@types/compression" "^1.7.0" + "@types/connect" "^3.4.33" + "@types/etag" "^1.8.0" + "@types/file-loader" "^4.2.0" + "@types/html-minifier" "^4.0.0" + "@types/less" "^3.0.1" + "@types/node" "^12.19.8" + "@types/node-sass" "^4.11.1" + "@types/optimize-css-assets-webpack-plugin" "^5.0.1" + "@types/pug" "^2.0.4" + "@types/serve-static" "^1.13.8" + "@types/terser-webpack-plugin" "^2.2.0" + "@types/webpack" "^4.41.25" + "@types/webpack-bundle-analyzer" "^3.9.0" + "@types/webpack-dev-middleware" "^3.7.2" + "@types/webpack-hot-middleware" "^2.25.3" + "@nuxt/ufo@^0.5.0": version "0.5.2" resolved "https://registry.yarnpkg.com/@nuxt/ufo/-/ufo-0.5.2.tgz#cb40e4b3001739baebddfd65d0f03d6070e2c0e5" @@ -1629,7 +1653,15 @@ resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a" integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA== -"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7": +"@types/autoprefixer@^9.7.2": + version "9.7.2" + resolved "https://registry.yarnpkg.com/@types/autoprefixer/-/autoprefixer-9.7.2.tgz#64b3251c9675feef5a631b7dd34cfea50a8fdbcc" + integrity sha512-QX7U7YW3zX3ex6MECtWO9folTGsXeP4b8bSjTq3I1ODM+H+sFHwGKuof+T+qBcDClGlCGtDb3SVfiTVfmcxw4g== + dependencies: + "@types/browserslist" "*" + postcss "7.x.x" + +"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.12", "@types/babel__core@^7.1.7": version "7.1.12" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.12.tgz#4d8e9e51eb265552a7e4f1ff2219ab6133bdfb2d" integrity sha512-wMTHiiTiBAAPebqaPiPDLFA4LYPKr6Ph0Xq/6rq1Ur3v66HXyG+clfR9CNETkD7MQS8ZHvpQOtA53DLws5WAEQ== @@ -1662,11 +1694,79 @@ dependencies: "@babel/types" "^7.3.0" +"@types/body-parser@*": + version "1.19.0" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.0.tgz#0685b3c47eb3006ffed117cdd55164b61f80538f" + integrity sha512-W98JrE0j2K78swW4ukqMleo8R7h/pFETjM2DQ90MF6XK2i4LO4W3gQ71Lt4w3bfm2EvVSyWHplECvB5sK22yFQ== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/browserslist@*": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@types/browserslist/-/browserslist-4.8.0.tgz#60489aefdf0fcb56c2d8eb65267ff08dad7a526d" + integrity sha512-4PyO9OM08APvxxo1NmQyQKlJdowPCOQIy5D/NLO3aO0vGC57wsMptvGp3b8IbYnupFZr92l1dlVief1JvS6STQ== + +"@types/clean-css@*": + version "4.2.3" + resolved "https://registry.yarnpkg.com/@types/clean-css/-/clean-css-4.2.3.tgz#12c13cc815f5e793014ee002c6324455907d851c" + integrity sha512-ET0ldU/vpXecy5vO8JRIhtJWSrk1vzXdJcp3Bjf8bARZynl6vfkhEKY/A7njfNIRlmyTGuVFuqnD6I3tOGdXpQ== + dependencies: + "@types/node" "*" + source-map "^0.6.0" + +"@types/compression@^1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@types/compression/-/compression-1.7.0.tgz#8dc2a56604873cf0dd4e746d9ae4d31ae77b2390" + integrity sha512-3LzWUM+3k3XdWOUk/RO+uSjv7YWOatYq2QADJntK1pjkk4DfVP0KrIEPDnXRJxAAGKe0VpIPRmlINLDuCedZWw== + dependencies: + "@types/express" "*" + +"@types/connect@*", "@types/connect@^3.4.33": + version "3.4.34" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.34.tgz#170a40223a6d666006d93ca128af2beb1d9b1901" + integrity sha512-ePPA/JuI+X0vb+gSWlPKOY0NdNAie/rPUqX2GUPpbZwiKTkSPhjXWuee47E4MtE54QVzGCQMQkAL6JhV2E1+cQ== + dependencies: + "@types/node" "*" + "@types/cookie@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803" integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow== +"@types/etag@^1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@types/etag/-/etag-1.8.0.tgz#37f0b1f3ea46da7ae319bbedb607e375b4c99f7e" + integrity sha512-EdSN0x+Y0/lBv7YAb8IU4Jgm6DWM+Bqtz7o5qozl96fzaqdqbdfHS5qjdpFeIv7xQ8jSLyjMMNShgYtMajEHyQ== + dependencies: + "@types/node" "*" + +"@types/express-serve-static-core@*": + version "4.17.17" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.17.tgz#6ba02465165b6c9c3d8db3a28def6b16fc9b70f5" + integrity sha512-YYlVaCni5dnHc+bLZfY908IG1+x5xuibKZMGv8srKkvtul3wUuanYvpIj9GXXoWkQbaAdR+kgX46IETKUALWNQ== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + +"@types/express@*": + version "4.17.9" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.9.tgz#f5f2df6add703ff28428add52bdec8a1091b0a78" + integrity sha512-SDzEIZInC4sivGIFY4Sz1GG6J9UObPwCInYJjko2jzOf/Imx/dlpume6Xxwj1ORL82tBbmN4cPDIDkLbWHk9hw== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "*" + "@types/qs" "*" + "@types/serve-static" "*" + +"@types/file-loader@^4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@types/file-loader/-/file-loader-4.2.0.tgz#ec8e793e275b7f90cdec3ff286518c6bf7bb8fc3" + integrity sha512-N3GMqKiKSNd41q4/lZlkdvNXKKWVdOXrA8Rniu64+25X0K2U1mWmTSu1CIqXKKsZUCwfaFcaioviLQtQ+EowLg== + dependencies: + "@types/webpack" "*" + "@types/graceful-fs@^4.1.2": version "4.1.4" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.4.tgz#4ff9f641a7c6d1a3508ff88bc3141b152772e753" @@ -1679,6 +1779,15 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50" integrity sha512-giAlZwstKbmvMk1OO7WXSj4OZ0keXAcl2TQq4LWHiiPH2ByaH7WeUzng+Qej8UPxxv+8lRTuouo0iaNDBuzIBA== +"@types/html-minifier@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/html-minifier/-/html-minifier-4.0.0.tgz#2065cb9944f2d1b241146707c6935aa7b947d279" + integrity sha512-eFnGhrKmjWBlnSGNtunetE3UU2Tc/LUl92htFslSSTmpp9EKHQVcYQadCyYfnzUEFB5G/3wLWo/USQS/mEPKrA== + dependencies: + "@types/clean-css" "*" + "@types/relateurl" "*" + "@types/uglify-js" "*" + "@types/http-proxy@^1.17.4": version "1.17.4" resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b" @@ -1715,21 +1824,57 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/less@^3.0.1": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@types/less/-/less-3.0.2.tgz#2761d477678c8374cb9897666871662eb1d1115e" + integrity sha512-62vfe65cMSzYaWmpmhqCMMNl0khen89w57mByPi1OseGfcV/LV03fO8YVrNj7rFQsRWNJo650WWyh6m7p8vZmA== + +"@types/memory-fs@*": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@types/memory-fs/-/memory-fs-0.3.2.tgz#5d4753f9b390cb077c8c8af97bc96463399ceccd" + integrity sha512-j5AcZo7dbMxHoOimcHEIh0JZe5e1b8q8AqGSpZJrYc7xOgCIP79cIjTdx5jSDLtySnQDwkDTqwlC7Xw7uXw7qg== + dependencies: + "@types/node" "*" + +"@types/mime@*": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.3.tgz#c893b73721db73699943bfc3653b1deb7faa4a3a" + integrity sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q== + "@types/minimist@^1.2.0": version "1.2.1" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== +"@types/node-sass@^4.11.1": + version "4.11.1" + resolved "https://registry.yarnpkg.com/@types/node-sass/-/node-sass-4.11.1.tgz#bda27c5181cbf7c090c3058e119633dfb2b6504c" + integrity sha512-wPOmOEEtbwQiPTIgzUuRSQZ3H5YHinsxRGeZzPSDefAm4ylXWnZG9C0adses8ymyplKK0gwv3JkDNO8GGxnWfg== + dependencies: + "@types/node" "*" + "@types/node@*": version "14.14.14" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae" integrity sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ== +"@types/node@^12.19.8": + version "12.19.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.12.tgz#04793c2afa4ce833a9972e4c476432e30f9df47b" + integrity sha512-UwfL2uIU9arX/+/PRcIkT08/iBadGN2z6ExOROA2Dh5mAuWTBj6iJbQX4nekiV5H8cTrEG569LeX+HRco9Cbxw== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== +"@types/optimize-css-assets-webpack-plugin@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@types/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-5.0.1.tgz#1f437ef9ef937b393687a8819be2d2fddc03b069" + integrity sha512-qyi5xmSl+DTmLFtVtelhso3VnNQYxltfgMa+Ed02xqNZCZBD0uYR6i64FmcwfieDzZRdwkJxt9o2JHq/5PBKQg== + dependencies: + "@types/webpack" "*" + "@types/parse-json@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" @@ -1740,11 +1885,39 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.5.tgz#b6ab3bba29e16b821d84e09ecfaded462b816b00" integrity sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ== +"@types/pug@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/pug/-/pug-2.0.4.tgz#8772fcd0418e3cd2cc171555d73007415051f4b2" + integrity sha1-h3L80EGOPNLMFxVV1zAHQVBR9LI= + "@types/q@^1.5.1": version "1.5.4" resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24" integrity sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug== +"@types/qs@*": + version "6.9.5" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.5.tgz#434711bdd49eb5ee69d90c1d67c354a9a8ecb18b" + integrity sha512-/JHkVHtx/REVG0VVToGRGH2+23hsYLHdyG+GrvoUGlGAd0ErauXDyvHtRI/7H7mzLm+tBCKA7pfcpkQ1lf58iQ== + +"@types/range-parser@*": + version "1.2.3" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c" + integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== + +"@types/relateurl@*": + version "0.2.28" + resolved "https://registry.yarnpkg.com/@types/relateurl/-/relateurl-0.2.28.tgz#6bda7db8653fa62643f5ee69e9f69c11a392e3a6" + integrity sha1-a9p9uGU/piZD9e5p6facEaOS46Y= + +"@types/serve-static@*", "@types/serve-static@^1.13.8": + version "1.13.8" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.8.tgz#851129d434433c7082148574ffec263d58309c46" + integrity sha512-MoJhSQreaVoL+/hurAZzIm8wafFR6ajiTM1m4A0kv6AGeVBl4r4pOV8bGFrjjq1sGxDTnCoF8i22o0/aE5XCyA== + dependencies: + "@types/mime" "*" + "@types/node" "*" + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" @@ -1760,6 +1933,14 @@ resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.6.tgz#a9ca4b70a18b270ccb2bc0aaafefd1d486b7ea74" integrity sha512-W+bw9ds02rAQaMvaLYxAbJ6cvguW/iJXNT6lTssS1ps6QdrMKttqEAMEG/b5CR8TZl3/L7/lH0ZV5nNR1LXikA== +"@types/terser-webpack-plugin@^2.2.0": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@types/terser-webpack-plugin/-/terser-webpack-plugin-2.2.1.tgz#d6687ed29026532764b031209a5d6dc6d44b33f2" + integrity sha512-Z/6t/7qz4LeO64owJ9x7JQ6X791qfLxp1M1eCp6hFQlj7xuB5+Ol7DpEn5kWClTARZ7GlPLRsEWzFzQjZShF6w== + dependencies: + "@types/webpack" "*" + terser "^4.3.9" + "@types/uglify-js@*": version "3.11.1" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.11.1.tgz#97ff30e61a0aa6876c270b5f538737e2d6ab8ceb" @@ -1767,6 +1948,31 @@ dependencies: source-map "^0.6.1" +"@types/webpack-bundle-analyzer@^3.9.0": + version "3.9.0" + resolved "https://registry.yarnpkg.com/@types/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.9.0.tgz#bf2f3fd7f1fe6a71dff8968afeb12785d1ce737b" + integrity sha512-O4Dsmml4T+emssdk3t6/N1vwtYRx1VfWCx0Oph4jRY62DZGNOL9IAS6mSX0XG1LdZuFSX0g42DXj1otQuPXRGQ== + dependencies: + "@types/webpack" "*" + +"@types/webpack-dev-middleware@^3.7.2": + version "3.7.2" + resolved "https://registry.yarnpkg.com/@types/webpack-dev-middleware/-/webpack-dev-middleware-3.7.2.tgz#31030c7cca7f98d56debfd859bb57f9040f0d3c5" + integrity sha512-PvETiS//pjVZBK48aJfbxzT7+9LIxanbnk9eXXYUfefGyPdsCkNrMDxRlOVrBvxukXUhD5B6N/pkPMdWrtuFkA== + dependencies: + "@types/connect" "*" + "@types/memory-fs" "*" + "@types/webpack" "*" + loglevel "^1.6.2" + +"@types/webpack-hot-middleware@^2.25.3": + version "2.25.3" + resolved "https://registry.yarnpkg.com/@types/webpack-hot-middleware/-/webpack-hot-middleware-2.25.3.tgz#ba6265ada359cae4f437d8ac08ac5b8c616f7521" + integrity sha512-zGkTzrwQnhSadIXGYGZLu7tpXQwn4+6y9nGeql+5UeRtW/k54Jp4SnzB0Qw00ednw0ZFoZOvqTFfXSbFXohc5Q== + dependencies: + "@types/connect" "*" + "@types/webpack" "*" + "@types/webpack-sources@*": version "2.1.0" resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-2.1.0.tgz#8882b0bd62d1e0ce62f183d0d01b72e6e82e8c10" @@ -1776,7 +1982,7 @@ "@types/source-list-map" "*" source-map "^0.7.3" -"@types/webpack@^4.41.8": +"@types/webpack@*", "@types/webpack@^4.41.25", "@types/webpack@^4.41.8": version "4.41.25" resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.25.tgz#4d3b5aecc4e44117b376280fbfd2dc36697968c4" integrity sha512-cr6kZ+4m9lp86ytQc1jPOJXgINQyz3kLLunZ57jznW+WIAL0JqZbGubQk4GlD42MuQL5JGOABrxdpqqWeovlVQ== @@ -7168,6 +7374,11 @@ lodash@^4.15.0, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17. resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== +loglevel@^1.6.2: + version "1.7.1" + resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" + integrity sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw== + loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -9022,7 +9233,7 @@ postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1: indexes-of "^1.0.1" uniq "^1.0.1" -postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.27, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0.6: +postcss@7.x.x, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.27, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0.6: version "7.0.35" resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.35.tgz#d2be00b998f7f211d8a276974079f2e92b970e24" integrity sha512-3QT8bBJeX/S5zKTTjTCIjRF3If4avAT6kqxcASlTWEtAFCb9NH0OUxNDfgZSWdP5fJnBYCMEWkIFfWeugjzYMg== @@ -10601,7 +10812,7 @@ terser-webpack-plugin@^2.3.5: terser "^4.6.12" webpack-sources "^1.4.3" -terser@^4.1.2, terser@^4.6.12, terser@^4.6.3: +terser@^4.1.2, terser@^4.3.9, terser@^4.6.12, terser@^4.6.3: version "4.8.0" resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17" integrity sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw== From 5030c1b96fed95ad638ec92dd1d9fd01c18ba545 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 Jan 2021 12:04:31 +0100 Subject: [PATCH 2/9] feat: added typescript support and updated docs accordingly --- .eslintignore | 3 + docs/content/en/index.md | 4 + docs/content/en/proxy.md | 2 +- docs/content/en/typescript.md | 153 ++++++++++++++++++++++++ lib/index.d.ts | 160 +++++++++++++++++++++++++ package.json | 1 + yarn.lock | 219 +++++++++++++++++++++++++++++++++- 7 files changed, 537 insertions(+), 5 deletions(-) create mode 100644 docs/content/en/typescript.md create mode 100644 lib/index.d.ts diff --git a/.eslintignore b/.eslintignore index b4eaf65a..f055f571 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,3 +6,6 @@ coverage # Plugin lib/plugin.js + +# Typings +/**/*.d.ts diff --git a/docs/content/en/index.md b/docs/content/en/index.md index 5b3d9fde..ab329e6d 100644 --- a/docs/content/en/index.md +++ b/docs/content/en/index.md @@ -8,6 +8,7 @@ features: - RESTful methods - Adaptive SDK for API entities - Handle errors with hooks + - TypeScript support --- @@ -15,6 +16,9 @@ features: This module is a wrapper around [Strapi](https://strapi.io/) for [NuxtJS](https://nuxtjs.org). +If you want to know how to use this module with TypeScript, +check out [this page](https://strapi.nuxtjs.org/typescript) of the docs. + ## Features diff --git a/docs/content/en/proxy.md b/docs/content/en/proxy.md index a0ff8d97..bd479e9e 100644 --- a/docs/content/en/proxy.md +++ b/docs/content/en/proxy.md @@ -1,7 +1,7 @@ --- title: Using a proxy description: 'Use Strapi behind a proxy with Nuxt Proxy module' -position: 7 +position: 8 category: Advanced fullscreen: true --- diff --git a/docs/content/en/typescript.md b/docs/content/en/typescript.md new file mode 100644 index 00000000..547badc0 --- /dev/null +++ b/docs/content/en/typescript.md @@ -0,0 +1,153 @@ +--- +title: Usage with Typescript +description: 'Discover how you can setup your project to integrate Strapi with TypeScript' +position: 7 +category: Advanced +--- + +## Setup + +Thanks to [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html), +you can tell the TypeScript compiler where to find the `$strapi` types by adding these lines to your +`tsconfig.json`. + +```json[tsconfig.json] +{ + "compilerOptions": { + "types": [ + "@nuxtjs/strapi" + ] + } +} +``` + +## Usage + +You now have access to `this.$strapi` inside your components and to `ctx.$strapi` inside +`asyncData`, `fetch`, `plugins`, `middlewares` and `nuxtServerInit`. + +### In component methods +```vue + +``` + +> Notice how you can define the type of the query parameters and of the returned value using generics. + +### Inside methods that use `context` +```vue + +``` + +## Known issues + +There are some known issues with the current implementation of TypeScript in the library, +so we have listed some workarounds. + +### Entity shortcuts + +The current TypeScript implementation doesn't support entity shortcuts: your code may work, +but it will throw type checking errors. This is why we made the `entity` parameter needed in +every method which involves a query. + +You can however define the entities available to your Vue methods with +[string literal types](https://www.typescriptlang.org/docs/handbook/literal-types.html#string-literal-types) +as described below. + +```vue + +``` + +### Query params + +Some query methods won't be accepted by the compiler if you define generics as in `$strapi.find` +(e.g.: the array methods described [here](https://strapi.nuxtjs.org/strapi#findentity-params)). + +You can get around this issue by doing something like below. + +```vue + +``` + +> You can always declare the return type by assigning a type to the variable instead of the method. diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 00000000..47c3e611 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,160 @@ +import Vue from 'vue'; +import { Context } from '@nuxt/types'; +import { NuxtHTTPInstance } from '@nuxt/http'; +import { NuxtCookies } from 'cookie-universal-nuxt'; + +type NuxtStrapiQueryParams = T | { [key: string]: any }; + +interface NuxtStrapiGraphQLParams { + query: string; +} + +interface NuxtStrapiRegistrationData { + username: string; + email: string; + password: string; +} + +interface NuxtStrapiLoginData { + /** + * Can be either the email or the username set by the user. + * */ + identifier: string; + password: string; +} + +interface NuxtStrapiEmailData { + email: string; +} + +interface NuxtStrapiResetPasswordData { + code: string; + password: string; + passwordConfirmation: string; +} + +export interface NuxtStrapi { + /** + * Use this object to access details about the + * authenticated user or to directly set a user prop. + * */ + user: { [key: string]: any }; + + /** + * Get entries. + * Returns entries matching the query filters. + * You can read more about parameters + * [here](https://strapi.io/documentation/developer-docs/latest/content-api/parameters.html). + * */ + find(entity: Entities, params?: NuxtStrapiQueryParams ): Promise; + + /** + * Count entries. + * Returns the count of entries matching the query filters. + * You can read more about parameters + * [here](https://strapi.io/documentation/developer-docs/latest/content-api/parameters.html). + * */ + count(entity: Entities, params?: NuxtStrapiQueryParams): Promise; + + /** + * Get an entry by id and returns its value. + * */ + findOne(entity: Entities, id?: string): Promise; + + /** + * Creates an entry and returns its value. + * */ + create(entity: Entities, data?: NuxtStrapiQueryParams): Promise; + + /** + * Partially updates an entry by id and returns its value. + * Fields that aren't sent in the query are not changed in the db. + * Send a null value if you want to clear them. + * */ + update(entity: Entities, id: string, data?: NuxtStrapiQueryParams): Promise; + + /** + * Deletes an entry by id and returns its value. + * */ + delete(entity: Entities, id: string): Promise; + + /** + * Performs an HTTP request to GraphQL API and returns the requested data. + * */ + graphql(data: NuxtStrapiGraphQLParams): Promise; + + /** + * Register using local strategy. Sets the User and Token. + * */ + register(data: NuxtStrapiRegistrationData): Promise; + + /** + * Login using local strategy. Sets the User and Token. + * */ + login(data: NuxtStrapiLoginData): Promise; + + /** + * Send a request to the forgot-password endpoint of the server. + * */ + forgotPassword(data: NuxtStrapiEmailData): Promise; + + /** + * Send a request to the reset-password endpoint of the server. + * */ + resetPassword(data: NuxtStrapiResetPasswordData): Promise; + + /** + * Send an email confirmation for the login. + * */ + sendEmailConfirmation(data: NuxtStrapiEmailData): Promise; + + /** + * Clears the user and jwt in cookies. + * */ + logout(): void; + + /** + * Fetch me user from /users/me route if a jwt is present in the cookies. + * Sets the jwt inside $http. Sets the User. + * */ + fetchUser(): Promise; + + /** + * This method fully overrides the user object, avoid using it. + * You can use the $strapi.user property to mutate single + * object properties instead of overriding it completely. + * */ + setUser(user: T): void; + + /** + * Returns jwt from cookies. + * */ + getToken(): string; + + /** + * Sets token inside $http as a jwt Bearer. + * Store jwt in cookies. + * */ + setToken(token: string): void; + + /** + * Remove jwt from $http and $cookies. + * */ + clearToken(): void; + + $http: NuxtHTTPInstance; + + $cookies: NuxtCookies; +} + +declare module 'vue/types/vue' { + interface Vue { + $strapi: NuxtStrapi; + } +} + +declare module '@nuxt/types' { + interface Context { + $strapi: NuxtStrapi; + } +} diff --git a/package.json b/package.json index 849c01b0..829521e6 100755 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@babel/preset-env": "^7.12.11", "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^11.0.0", + "@nuxt/types": "^2.14.12", "@nuxtjs/eslint-config": "^5.0.0", "@nuxtjs/module-test-utils": "latest", "babel-eslint": "latest", diff --git a/yarn.lock b/yarn.lock index f9cd6764..e6dacc27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1465,6 +1465,30 @@ rc9 "^1.2.0" std-env "^2.2.1" +"@nuxt/types@^2.14.12": + version "2.14.12" + resolved "https://registry.yarnpkg.com/@nuxt/types/-/types-2.14.12.tgz#4e5aa642b67081890b3b7aab03db62855ef71a25" + integrity sha512-x58uEVygHual/kHDTrLAwXjKNYn+5udR4HJOmHd2gXgYonZu8E2UpsShIkyMRZ0nRoEAZ72i4OfcHKqGsVSI6w== + dependencies: + "@types/autoprefixer" "^9.7.2" + "@types/babel__core" "^7.1.12" + "@types/compression" "^1.7.0" + "@types/connect" "^3.4.33" + "@types/etag" "^1.8.0" + "@types/file-loader" "^4.2.0" + "@types/html-minifier" "^4.0.0" + "@types/less" "^3.0.1" + "@types/node" "^12.19.8" + "@types/node-sass" "^4.11.1" + "@types/optimize-css-assets-webpack-plugin" "^5.0.1" + "@types/pug" "^2.0.4" + "@types/serve-static" "^1.13.8" + "@types/terser-webpack-plugin" "^2.2.0" + "@types/webpack" "^4.41.25" + "@types/webpack-bundle-analyzer" "^3.9.0" + "@types/webpack-dev-middleware" "^3.7.2" + "@types/webpack-hot-middleware" "^2.25.3" + "@nuxt/ufo@^0.5.0": version "0.5.2" resolved "https://registry.yarnpkg.com/@nuxt/ufo/-/ufo-0.5.2.tgz#cb40e4b3001739baebddfd65d0f03d6070e2c0e5" @@ -1629,7 +1653,15 @@ resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a" integrity sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA== -"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7": +"@types/autoprefixer@^9.7.2": + version "9.7.2" + resolved "https://registry.yarnpkg.com/@types/autoprefixer/-/autoprefixer-9.7.2.tgz#64b3251c9675feef5a631b7dd34cfea50a8fdbcc" + integrity sha512-QX7U7YW3zX3ex6MECtWO9folTGsXeP4b8bSjTq3I1ODM+H+sFHwGKuof+T+qBcDClGlCGtDb3SVfiTVfmcxw4g== + dependencies: + "@types/browserslist" "*" + postcss "7.x.x" + +"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.12", "@types/babel__core@^7.1.7": version "7.1.12" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.12.tgz#4d8e9e51eb265552a7e4f1ff2219ab6133bdfb2d" integrity sha512-wMTHiiTiBAAPebqaPiPDLFA4LYPKr6Ph0Xq/6rq1Ur3v66HXyG+clfR9CNETkD7MQS8ZHvpQOtA53DLws5WAEQ== @@ -1662,11 +1694,79 @@ dependencies: "@babel/types" "^7.3.0" +"@types/body-parser@*": + version "1.19.0" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.0.tgz#0685b3c47eb3006ffed117cdd55164b61f80538f" + integrity sha512-W98JrE0j2K78swW4ukqMleo8R7h/pFETjM2DQ90MF6XK2i4LO4W3gQ71Lt4w3bfm2EvVSyWHplECvB5sK22yFQ== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/browserslist@*": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@types/browserslist/-/browserslist-4.8.0.tgz#60489aefdf0fcb56c2d8eb65267ff08dad7a526d" + integrity sha512-4PyO9OM08APvxxo1NmQyQKlJdowPCOQIy5D/NLO3aO0vGC57wsMptvGp3b8IbYnupFZr92l1dlVief1JvS6STQ== + +"@types/clean-css@*": + version "4.2.3" + resolved "https://registry.yarnpkg.com/@types/clean-css/-/clean-css-4.2.3.tgz#12c13cc815f5e793014ee002c6324455907d851c" + integrity sha512-ET0ldU/vpXecy5vO8JRIhtJWSrk1vzXdJcp3Bjf8bARZynl6vfkhEKY/A7njfNIRlmyTGuVFuqnD6I3tOGdXpQ== + dependencies: + "@types/node" "*" + source-map "^0.6.0" + +"@types/compression@^1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@types/compression/-/compression-1.7.0.tgz#8dc2a56604873cf0dd4e746d9ae4d31ae77b2390" + integrity sha512-3LzWUM+3k3XdWOUk/RO+uSjv7YWOatYq2QADJntK1pjkk4DfVP0KrIEPDnXRJxAAGKe0VpIPRmlINLDuCedZWw== + dependencies: + "@types/express" "*" + +"@types/connect@*", "@types/connect@^3.4.33": + version "3.4.34" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.34.tgz#170a40223a6d666006d93ca128af2beb1d9b1901" + integrity sha512-ePPA/JuI+X0vb+gSWlPKOY0NdNAie/rPUqX2GUPpbZwiKTkSPhjXWuee47E4MtE54QVzGCQMQkAL6JhV2E1+cQ== + dependencies: + "@types/node" "*" + "@types/cookie@^0.3.3": version "0.3.3" resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803" integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow== +"@types/etag@^1.8.0": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@types/etag/-/etag-1.8.0.tgz#37f0b1f3ea46da7ae319bbedb607e375b4c99f7e" + integrity sha512-EdSN0x+Y0/lBv7YAb8IU4Jgm6DWM+Bqtz7o5qozl96fzaqdqbdfHS5qjdpFeIv7xQ8jSLyjMMNShgYtMajEHyQ== + dependencies: + "@types/node" "*" + +"@types/express-serve-static-core@*": + version "4.17.17" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.17.tgz#6ba02465165b6c9c3d8db3a28def6b16fc9b70f5" + integrity sha512-YYlVaCni5dnHc+bLZfY908IG1+x5xuibKZMGv8srKkvtul3wUuanYvpIj9GXXoWkQbaAdR+kgX46IETKUALWNQ== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + +"@types/express@*": + version "4.17.9" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.9.tgz#f5f2df6add703ff28428add52bdec8a1091b0a78" + integrity sha512-SDzEIZInC4sivGIFY4Sz1GG6J9UObPwCInYJjko2jzOf/Imx/dlpume6Xxwj1ORL82tBbmN4cPDIDkLbWHk9hw== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "*" + "@types/qs" "*" + "@types/serve-static" "*" + +"@types/file-loader@^4.2.0": + version "4.2.0" + resolved "https://registry.yarnpkg.com/@types/file-loader/-/file-loader-4.2.0.tgz#ec8e793e275b7f90cdec3ff286518c6bf7bb8fc3" + integrity sha512-N3GMqKiKSNd41q4/lZlkdvNXKKWVdOXrA8Rniu64+25X0K2U1mWmTSu1CIqXKKsZUCwfaFcaioviLQtQ+EowLg== + dependencies: + "@types/webpack" "*" + "@types/graceful-fs@^4.1.2": version "4.1.4" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.4.tgz#4ff9f641a7c6d1a3508ff88bc3141b152772e753" @@ -1679,6 +1779,15 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50" integrity sha512-giAlZwstKbmvMk1OO7WXSj4OZ0keXAcl2TQq4LWHiiPH2ByaH7WeUzng+Qej8UPxxv+8lRTuouo0iaNDBuzIBA== +"@types/html-minifier@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/html-minifier/-/html-minifier-4.0.0.tgz#2065cb9944f2d1b241146707c6935aa7b947d279" + integrity sha512-eFnGhrKmjWBlnSGNtunetE3UU2Tc/LUl92htFslSSTmpp9EKHQVcYQadCyYfnzUEFB5G/3wLWo/USQS/mEPKrA== + dependencies: + "@types/clean-css" "*" + "@types/relateurl" "*" + "@types/uglify-js" "*" + "@types/http-proxy@^1.17.4": version "1.17.4" resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b" @@ -1715,21 +1824,57 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/less@^3.0.1": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@types/less/-/less-3.0.2.tgz#2761d477678c8374cb9897666871662eb1d1115e" + integrity sha512-62vfe65cMSzYaWmpmhqCMMNl0khen89w57mByPi1OseGfcV/LV03fO8YVrNj7rFQsRWNJo650WWyh6m7p8vZmA== + +"@types/memory-fs@*": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@types/memory-fs/-/memory-fs-0.3.2.tgz#5d4753f9b390cb077c8c8af97bc96463399ceccd" + integrity sha512-j5AcZo7dbMxHoOimcHEIh0JZe5e1b8q8AqGSpZJrYc7xOgCIP79cIjTdx5jSDLtySnQDwkDTqwlC7Xw7uXw7qg== + dependencies: + "@types/node" "*" + +"@types/mime@*": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.3.tgz#c893b73721db73699943bfc3653b1deb7faa4a3a" + integrity sha512-Jus9s4CDbqwocc5pOAnh8ShfrnMcPHuJYzVcSUU7lrh8Ni5HuIqX3oilL86p3dlTrk0LzHRCgA/GQ7uNCw6l2Q== + "@types/minimist@^1.2.0": version "1.2.1" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== +"@types/node-sass@^4.11.1": + version "4.11.1" + resolved "https://registry.yarnpkg.com/@types/node-sass/-/node-sass-4.11.1.tgz#bda27c5181cbf7c090c3058e119633dfb2b6504c" + integrity sha512-wPOmOEEtbwQiPTIgzUuRSQZ3H5YHinsxRGeZzPSDefAm4ylXWnZG9C0adses8ymyplKK0gwv3JkDNO8GGxnWfg== + dependencies: + "@types/node" "*" + "@types/node@*": version "14.14.14" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae" integrity sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ== +"@types/node@^12.19.8": + version "12.19.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.19.12.tgz#04793c2afa4ce833a9972e4c476432e30f9df47b" + integrity sha512-UwfL2uIU9arX/+/PRcIkT08/iBadGN2z6ExOROA2Dh5mAuWTBj6iJbQX4nekiV5H8cTrEG569LeX+HRco9Cbxw== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA== +"@types/optimize-css-assets-webpack-plugin@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@types/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-5.0.1.tgz#1f437ef9ef937b393687a8819be2d2fddc03b069" + integrity sha512-qyi5xmSl+DTmLFtVtelhso3VnNQYxltfgMa+Ed02xqNZCZBD0uYR6i64FmcwfieDzZRdwkJxt9o2JHq/5PBKQg== + dependencies: + "@types/webpack" "*" + "@types/parse-json@^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" @@ -1740,11 +1885,39 @@ resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.1.5.tgz#b6ab3bba29e16b821d84e09ecfaded462b816b00" integrity sha512-UEyp8LwZ4Dg30kVU2Q3amHHyTn1jEdhCIE59ANed76GaT1Vp76DD3ZWSAxgCrw6wJ0TqeoBpqmfUHiUDPs//HQ== +"@types/pug@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/pug/-/pug-2.0.4.tgz#8772fcd0418e3cd2cc171555d73007415051f4b2" + integrity sha1-h3L80EGOPNLMFxVV1zAHQVBR9LI= + "@types/q@^1.5.1": version "1.5.4" resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.4.tgz#15925414e0ad2cd765bfef58842f7e26a7accb24" integrity sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug== +"@types/qs@*": + version "6.9.5" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.5.tgz#434711bdd49eb5ee69d90c1d67c354a9a8ecb18b" + integrity sha512-/JHkVHtx/REVG0VVToGRGH2+23hsYLHdyG+GrvoUGlGAd0ErauXDyvHtRI/7H7mzLm+tBCKA7pfcpkQ1lf58iQ== + +"@types/range-parser@*": + version "1.2.3" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c" + integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== + +"@types/relateurl@*": + version "0.2.28" + resolved "https://registry.yarnpkg.com/@types/relateurl/-/relateurl-0.2.28.tgz#6bda7db8653fa62643f5ee69e9f69c11a392e3a6" + integrity sha1-a9p9uGU/piZD9e5p6facEaOS46Y= + +"@types/serve-static@*", "@types/serve-static@^1.13.8": + version "1.13.8" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.8.tgz#851129d434433c7082148574ffec263d58309c46" + integrity sha512-MoJhSQreaVoL+/hurAZzIm8wafFR6ajiTM1m4A0kv6AGeVBl4r4pOV8bGFrjjq1sGxDTnCoF8i22o0/aE5XCyA== + dependencies: + "@types/mime" "*" + "@types/node" "*" + "@types/source-list-map@*": version "0.1.2" resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9" @@ -1760,6 +1933,14 @@ resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.6.tgz#a9ca4b70a18b270ccb2bc0aaafefd1d486b7ea74" integrity sha512-W+bw9ds02rAQaMvaLYxAbJ6cvguW/iJXNT6lTssS1ps6QdrMKttqEAMEG/b5CR8TZl3/L7/lH0ZV5nNR1LXikA== +"@types/terser-webpack-plugin@^2.2.0": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@types/terser-webpack-plugin/-/terser-webpack-plugin-2.2.1.tgz#d6687ed29026532764b031209a5d6dc6d44b33f2" + integrity sha512-Z/6t/7qz4LeO64owJ9x7JQ6X791qfLxp1M1eCp6hFQlj7xuB5+Ol7DpEn5kWClTARZ7GlPLRsEWzFzQjZShF6w== + dependencies: + "@types/webpack" "*" + terser "^4.3.9" + "@types/uglify-js@*": version "3.11.1" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.11.1.tgz#97ff30e61a0aa6876c270b5f538737e2d6ab8ceb" @@ -1767,6 +1948,31 @@ dependencies: source-map "^0.6.1" +"@types/webpack-bundle-analyzer@^3.9.0": + version "3.9.0" + resolved "https://registry.yarnpkg.com/@types/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.9.0.tgz#bf2f3fd7f1fe6a71dff8968afeb12785d1ce737b" + integrity sha512-O4Dsmml4T+emssdk3t6/N1vwtYRx1VfWCx0Oph4jRY62DZGNOL9IAS6mSX0XG1LdZuFSX0g42DXj1otQuPXRGQ== + dependencies: + "@types/webpack" "*" + +"@types/webpack-dev-middleware@^3.7.2": + version "3.7.2" + resolved "https://registry.yarnpkg.com/@types/webpack-dev-middleware/-/webpack-dev-middleware-3.7.2.tgz#31030c7cca7f98d56debfd859bb57f9040f0d3c5" + integrity sha512-PvETiS//pjVZBK48aJfbxzT7+9LIxanbnk9eXXYUfefGyPdsCkNrMDxRlOVrBvxukXUhD5B6N/pkPMdWrtuFkA== + dependencies: + "@types/connect" "*" + "@types/memory-fs" "*" + "@types/webpack" "*" + loglevel "^1.6.2" + +"@types/webpack-hot-middleware@^2.25.3": + version "2.25.3" + resolved "https://registry.yarnpkg.com/@types/webpack-hot-middleware/-/webpack-hot-middleware-2.25.3.tgz#ba6265ada359cae4f437d8ac08ac5b8c616f7521" + integrity sha512-zGkTzrwQnhSadIXGYGZLu7tpXQwn4+6y9nGeql+5UeRtW/k54Jp4SnzB0Qw00ednw0ZFoZOvqTFfXSbFXohc5Q== + dependencies: + "@types/connect" "*" + "@types/webpack" "*" + "@types/webpack-sources@*": version "2.1.0" resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-2.1.0.tgz#8882b0bd62d1e0ce62f183d0d01b72e6e82e8c10" @@ -1776,7 +1982,7 @@ "@types/source-list-map" "*" source-map "^0.7.3" -"@types/webpack@^4.41.8": +"@types/webpack@*", "@types/webpack@^4.41.25", "@types/webpack@^4.41.8": version "4.41.25" resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.25.tgz#4d3b5aecc4e44117b376280fbfd2dc36697968c4" integrity sha512-cr6kZ+4m9lp86ytQc1jPOJXgINQyz3kLLunZ57jznW+WIAL0JqZbGubQk4GlD42MuQL5JGOABrxdpqqWeovlVQ== @@ -7168,6 +7374,11 @@ lodash@^4.15.0, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17. resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== +loglevel@^1.6.2: + version "1.7.1" + resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" + integrity sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw== + loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -9022,7 +9233,7 @@ postcss-values-parser@^2.0.0, postcss-values-parser@^2.0.1: indexes-of "^1.0.1" uniq "^1.0.1" -postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.27, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0.6: +postcss@7.x.x, postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, postcss@^7.0.2, postcss@^7.0.27, postcss@^7.0.32, postcss@^7.0.5, postcss@^7.0.6: version "7.0.35" resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.35.tgz#d2be00b998f7f211d8a276974079f2e92b970e24" integrity sha512-3QT8bBJeX/S5zKTTjTCIjRF3If4avAT6kqxcASlTWEtAFCb9NH0OUxNDfgZSWdP5fJnBYCMEWkIFfWeugjzYMg== @@ -10601,7 +10812,7 @@ terser-webpack-plugin@^2.3.5: terser "^4.6.12" webpack-sources "^1.4.3" -terser@^4.1.2, terser@^4.6.12, terser@^4.6.3: +terser@^4.1.2, terser@^4.3.9, terser@^4.6.12, terser@^4.6.3: version "4.8.0" resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17" integrity sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw== From 22d79a181151ccbccddc404247bef7fa4bfa7d57 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 Jan 2021 12:35:33 +0100 Subject: [PATCH 3/9] fix: added a line to the README about typescript support --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 597fa7b6..b45f9141 100755 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - RESTful methods - Adaptive SDK for API entities - Handle errors with hooks +- TypeScript support [📖  Read the documentation](https://strapi.nuxtjs.org) From 4e758441fb5c300e5817347a5cb4f3ed8ee29228 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 Jan 2021 12:42:43 +0100 Subject: [PATCH 4/9] fix: added "types" field in package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 829521e6..43513cf4 100755 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "lib" ], "main": "lib/module.js", + "types": "lib/index.d.ts", "scripts": { "dev": "nuxt example", "docs": "nuxt docs", From 69ca806ff2d1f97398805bdf88f6b0db9ea34a14 Mon Sep 17 00:00:00 2001 From: LuckeeDev <61506420+LuckeeDev@users.noreply.github.com> Date: Thu, 7 Jan 2021 13:05:45 +0100 Subject: [PATCH 5/9] added store module declaration Co-authored-by: Daniel Roe --- lib/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/index.d.ts b/lib/index.d.ts index 47c3e611..85ba5560 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -153,6 +153,12 @@ declare module 'vue/types/vue' { } } +declare module 'vuex/types/index' { + interface Store { + $strapi: NuxtStrapi; + } +} + declare module '@nuxt/types' { interface Context { $strapi: NuxtStrapi; From e3ae2bab747f7824dfec056bee243f6b9f3f2591 Mon Sep 17 00:00:00 2001 From: LuckeeDev <61506420+LuckeeDev@users.noreply.github.com> Date: Thu, 7 Jan 2021 13:06:15 +0100 Subject: [PATCH 6/9] refactored user type into a Record Co-authored-by: Daniel Roe --- lib/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index 85ba5560..1b95de65 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -38,7 +38,7 @@ export interface NuxtStrapi { * Use this object to access details about the * authenticated user or to directly set a user prop. * */ - user: { [key: string]: any }; + user: Record; /** * Get entries. From 2a4dbbe4e899789d06f63d70f41b26db67337c35 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 7 Jan 2021 13:14:49 +0100 Subject: [PATCH 7/9] fix: linted code samples in the docs, refactored NuxtStrapiQueryParams into a Record type --- docs/content/en/typescript.md | 52 ++++++++++++++++++----------------- lib/index.d.ts | 2 +- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/docs/content/en/typescript.md b/docs/content/en/typescript.md index 547badc0..51379f3d 100644 --- a/docs/content/en/typescript.md +++ b/docs/content/en/typescript.md @@ -32,21 +32,23 @@ You now have access to `this.$strapi` inside your components and to `ctx.$strapi import Vue from 'vue' interface BlogPost { - title: string; - description: string; + title: string; + description: string; } export default Vue.extend({ - mounted() { - this.$strapi.create( + async data () { + const post = await this.$strapi.create( 'posts', { title: 'Welcome to Strapi', - description: 'Strapi is awesome!', + description: 'Strapi is awesome!' } - ).then((post) => { - console.log(post); - }); + ) + + return { + post + } } }) @@ -61,18 +63,18 @@ import Vue from 'vue' import { Context } from '@nuxt/types' interface BlogPost { - title: string; - description: string; + title: string; + description: string; } export default Vue.extend({ - async asyncData(ctx: Context) { - const posts = await ctx.$strapi.find( - 'posts', - ); - - return { - posts, + async asyncData (ctx: Context) { + const posts = await ctx.$strapi.find( + 'posts' + ) + + return { + posts } } }) @@ -107,13 +109,13 @@ interface BlogPost { type Entities = 'posts' | 'projects' export default Vue.extend({ - async asyncData(ctx: Context) { + async asyncData (ctx: Context) { const posts = await ctx.$strapi.find( - 'posts', - ); + 'posts' + ) return { - posts, + posts } } }) @@ -137,13 +139,13 @@ interface BlogPost { } export default Vue.extend({ - async asyncData(ctx: Context) { + async asyncData (ctx: Context) { const posts: BlogPost[] = await this.$strapi.find( - 'posts', - ); + 'posts' + ) return { - posts, + posts } } }) diff --git a/lib/index.d.ts b/lib/index.d.ts index 1b95de65..948fc72e 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -3,7 +3,7 @@ import { Context } from '@nuxt/types'; import { NuxtHTTPInstance } from '@nuxt/http'; import { NuxtCookies } from 'cookie-universal-nuxt'; -type NuxtStrapiQueryParams = T | { [key: string]: any }; +type NuxtStrapiQueryParams = T | Record; interface NuxtStrapiGraphQLParams { query: string; From 2791b64d01326b49db289ec6bce7ed141058e3bb Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 8 Jan 2021 12:04:33 +0100 Subject: [PATCH 8/9] fix: removed line from index.md about ts, added declaration for NuxtAppOptions --- docs/content/en/index.md | 3 --- lib/index.d.ts | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/content/en/index.md b/docs/content/en/index.md index ab329e6d..05e07509 100644 --- a/docs/content/en/index.md +++ b/docs/content/en/index.md @@ -16,9 +16,6 @@ features: This module is a wrapper around [Strapi](https://strapi.io/) for [NuxtJS](https://nuxtjs.org). -If you want to know how to use this module with TypeScript, -check out [this page](https://strapi.nuxtjs.org/typescript) of the docs. - ## Features diff --git a/lib/index.d.ts b/lib/index.d.ts index 948fc72e..cb1dc919 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,5 +1,5 @@ import Vue from 'vue'; -import { Context } from '@nuxt/types'; +import { Context, NuxtAppOptions } from '@nuxt/types'; import { NuxtHTTPInstance } from '@nuxt/http'; import { NuxtCookies } from 'cookie-universal-nuxt'; @@ -160,6 +160,10 @@ declare module 'vuex/types/index' { } declare module '@nuxt/types' { + interface NuxtAppOptions { + $strapi: NuxtStrapi; + } + interface Context { $strapi: NuxtStrapi; } From 3a9c6254ac6aa0e43a9fb2d85c8f3b3ba772d247 Mon Sep 17 00:00:00 2001 From: Luca Date: Fri, 8 Jan 2021 12:11:56 +0100 Subject: [PATCH 9/9] fix: made a link in the ts page relative to the current url; removed declaration imports --- docs/content/en/typescript.md | 2 +- lib/index.d.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/content/en/typescript.md b/docs/content/en/typescript.md index 51379f3d..77fd2f71 100644 --- a/docs/content/en/typescript.md +++ b/docs/content/en/typescript.md @@ -125,7 +125,7 @@ export default Vue.extend({ ### Query params Some query methods won't be accepted by the compiler if you define generics as in `$strapi.find` -(e.g.: the array methods described [here](https://strapi.nuxtjs.org/strapi#findentity-params)). +(e.g.: the array methods described [here](/strapi#findentity-params)). You can get around this issue by doing something like below. diff --git a/lib/index.d.ts b/lib/index.d.ts index cb1dc919..84c932b0 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,5 +1,3 @@ -import Vue from 'vue'; -import { Context, NuxtAppOptions } from '@nuxt/types'; import { NuxtHTTPInstance } from '@nuxt/http'; import { NuxtCookies } from 'cookie-universal-nuxt';