Types
Since this package has been designed using TypeScript, it inherently provides native support for it. 🖥
Axios
Here is the list of all axios interfaces and types used in this package:
AxiosInstance: used for thestrapi.axiosproperty.AxiosRequestConfig: used for the axiosOptions in theStrapi Constructorand the customrequestmethod.Method: (which is atype) used for the parametermethodin the customrequestmethod.
Internal
Below is a list of all the custom types and interfaces used in this package.
You can easily use them by importing them.
import Strapi, { StrapiOptions } from "strapi-sdk-js"
const options: StrapiOptions = {
url: "http://strapi-host/",
}
const strapi = new Strapi(options)StrapiOptions
Options to configure a new Strapi SDK instance.
interface StrapiConfig {
url?: string
store?: StoreConfig
axiosOptions?: AxiosRequestConfig
}StoreConfig
Used for store configuration in Strapi SDK instanciation.
interface StoreConfig {
key: string
useLocalStorage?: boolean
cookieOptions?: CookieAttributes
}StrapiBaseRequestParams
Strapi query filters used in findOne, create, update methods.
interface StrapiBaseRequestParams {
fields?: Array<string>
populate?: string | Array<string> | Record<string, unknown>
}Check out the Strapi REST API documentation for more information.
StrapiRequestParams
Strapi query filters used in find methods.
interface StrapiRequestParams extends StrapiBaseRequestParams {
sort?: string | Array<string>
pagination?: PaginationByOffset | PaginationByPage
filters?: Record<string, unknown>
publicationState?: "live" | "preview"
locale?: StrapiLocale
}Check out the Strapi REST API documentation for more information.
PaginationByPage
Results can be paginated. This type is used in StrapiRequestParams to paginate the results by page.
interface PaginationByPage {
page: number
pageSize: number
withCount?: boolean
}Check out the Strapi Pagination documentation for more information.
PaginationByOffset
Results can be paginated. This type is used in StrapiRequestParams to paginate the results by offset.
interface PaginationByOffset {
start: number
limit: number
withCount?: boolean
}Check out the Strapi Pagination documentation for more information.
StrapiLocale
This type is used in StrapiRequestParams to retrieve content by locale.
type StrapiLocale = | "af" | "af-NA" | "af-ZA" | "agq" ...Check out the Strapi i18n documentation for more information.
StrapiResponse<T>
Strapi v5 introduces a unique identifier - documentId - in order to access documents. With the v5 version, the response will always return system fields (id, documentId & locale).
interface StrapiResponse<T> {
data: T & StrapiSystemFields
meta: Record<string, unknown>
}
interface StrapiSystemFields {
// @deprecated use documentId instead
id: integer
documentId: string
}Check out the Strapi Requests documentation for more information.
StrapiError
Errors are included in the response object with the error key and include information such as the HTTP status code, the name of the error, and additional information.
interface StrapiError {
data: null
error: {
status: number
name: string
message: string
details: Record<string, unknown>
}
}Check out the Strapi Error handling documentation for more information.
StrapiUser
Types of the user returned by Strapi. Returned by fetchUser method.
StrapiAuthProvider
Used for the provider parameter in the getProviderAuthenticationUrl and authenticateProvider methods.
type StrapiAuthProvider =
| "github"
| "facebook"
| "google"
| "cognito"
| "twitter"
| "discord"
| "twitch"
| "instagram"
| "vk"
| "linkedin"
| "reddit"
| "auth0"Check out the Strapi Authentication Provider documentation for more information.
StrapiAuthenticationResponse
The return object type in the register, login, changePassword, resetPassword, forgotPassword, resetPassword and authenticateProvider methods.
interface StrapiAuthenticationResponse {
user: Record<string, unknown>
jwt: string
}StrapiAuthenticationData
Used for the data parameter in the login method.
interface StrapiAuthenticationData {
identifier: string
password: string
}StrapiRegistrationData
Used for the data parameter in the register method.
interface StrapiRegistrationData {
username: string
email: string
password: string
}StrapiChangePasswordData
Used for the data parameter in the changePassword method.
interface StrapiChangePasswordData {
currentPassword: string
password: string
passwordConfirmation: string
}StrapiForgotPasswordData
Used for the data parameter in the forgotPassword method.
interface StrapiForgotPasswordData {
email: string
}StrapiResetPasswordData
Used for the data parameter in the resetPassword method.
interface StrapiResetPasswordData {
code: string
password: string
passwordConfirmation: string
}StrapiEmailConfirmationData
Used for the data parameter in the sendEmailConfirmation method.
interface StrapiEmailConfirmationData {
email: string
}- Axios
- Internal
- StrapiOptions
- StoreConfig
- StrapiBaseRequestParams
- StrapiRequestParams
- PaginationByPage
- PaginationByOffset
- StrapiLocale
- StrapiResponse<T>
- StrapiError
- StrapiUser
- StrapiAuthProvider
- StrapiAuthenticationResponse
- StrapiAuthenticationData
- StrapiRegistrationData
- StrapiChangePasswordData
- StrapiForgotPasswordData
- StrapiResetPasswordData
- StrapiEmailConfirmationData
