strapi-sdk-js 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +201 -30
- package/dist/index.d.ts +19 -3
- package/dist/index.mjs +191 -13
- package/package.json +33 -25
- package/CHANGELOG.md +0 -100
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
const axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
11
|
-
const defu__default = /*#__PURE__*/_interopDefaultLegacy(defu);
|
|
12
|
-
const qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
|
|
13
|
-
const Cookies__default = /*#__PURE__*/_interopDefaultLegacy(Cookies);
|
|
3
|
+
var axios = require('axios');
|
|
4
|
+
var defu = require('defu');
|
|
5
|
+
var qs = require('qs');
|
|
6
|
+
var Cookies = require('js-cookie');
|
|
7
|
+
var ufo = require('ufo');
|
|
14
8
|
|
|
15
9
|
function isBrowser() {
|
|
16
10
|
return typeof window !== "undefined";
|
|
@@ -27,12 +21,28 @@ const defaults = {
|
|
|
27
21
|
axiosOptions: {}
|
|
28
22
|
};
|
|
29
23
|
class Strapi {
|
|
24
|
+
axios;
|
|
25
|
+
options;
|
|
26
|
+
user = null;
|
|
27
|
+
/**
|
|
28
|
+
* Strapi SDK Constructor
|
|
29
|
+
*
|
|
30
|
+
* @constructor
|
|
31
|
+
* @param {StrapiOptions} options? - Options in order to configure API URL, list your Content Types & extend the axios configuration
|
|
32
|
+
* @param {string} options.url? - Your Strapi API URL, Default: http://localhost::1337
|
|
33
|
+
* @param {StoreConfig} options.store? - Config the way you want to store JWT (Cookie or LocalStorage)
|
|
34
|
+
* @param {AxiosRequestConfig} options.axiosOptions? - The list of your Content type on your Strapi API
|
|
35
|
+
*/
|
|
30
36
|
constructor(options) {
|
|
31
|
-
|
|
32
|
-
this.options =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
const _options = defu(options || {}, defaults);
|
|
38
|
+
this.options = {
|
|
39
|
+
..._options,
|
|
40
|
+
url: ufo.cleanDoubleSlashes(_options?.url),
|
|
41
|
+
prefix: ufo.cleanDoubleSlashes(_options?.prefix)
|
|
42
|
+
};
|
|
43
|
+
this.axios = axios.create({
|
|
44
|
+
baseURL: ufo.joinURL(this.options.url, this.options.prefix),
|
|
45
|
+
paramsSerializer: qs.stringify,
|
|
36
46
|
...this.options.axiosOptions
|
|
37
47
|
});
|
|
38
48
|
this.axios.interceptors.request.use((config) => {
|
|
@@ -46,6 +56,14 @@ class Strapi {
|
|
|
46
56
|
return config;
|
|
47
57
|
});
|
|
48
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Basic axios request
|
|
61
|
+
*
|
|
62
|
+
* @param {Method} method - HTTP method
|
|
63
|
+
* @param {string} url - Custom or Strapi API URL
|
|
64
|
+
* @param {AxiosRequestConfig} axiosConfig? - Custom Axios config
|
|
65
|
+
* @returns Promise<T>
|
|
66
|
+
*/
|
|
49
67
|
async request(method, url, axiosConfig) {
|
|
50
68
|
try {
|
|
51
69
|
const response = await this.axios.request({
|
|
@@ -71,6 +89,14 @@ class Strapi {
|
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Authenticate user & retrieve his JWT
|
|
94
|
+
*
|
|
95
|
+
* @param {StrapiAuthenticationData} data - User authentication form data: `identifier`, `password`
|
|
96
|
+
* @param {string} data.identifier - The email or username of the user
|
|
97
|
+
* @param {string} data.password - The password of the user
|
|
98
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
99
|
+
*/
|
|
74
100
|
async login(data) {
|
|
75
101
|
this.removeToken();
|
|
76
102
|
const { user, jwt } = await this.request("post", "/auth/local", {
|
|
@@ -80,83 +106,212 @@ class Strapi {
|
|
|
80
106
|
this.user = user;
|
|
81
107
|
return { user, jwt };
|
|
82
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Register a new user & retrieve JWT
|
|
111
|
+
*
|
|
112
|
+
* @param {StrapiRegistrationData} data - New user registration data: `username`, `email`, `password`
|
|
113
|
+
* @param {string} data.username - Username of the new user
|
|
114
|
+
* @param {string} data.email - Email of the new user
|
|
115
|
+
* @param {string} data.password - Password of the new user
|
|
116
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
117
|
+
*/
|
|
83
118
|
async register(data) {
|
|
84
119
|
this.removeToken();
|
|
85
|
-
const { user, jwt } = await this.request(
|
|
86
|
-
|
|
87
|
-
|
|
120
|
+
const { user, jwt } = await this.request(
|
|
121
|
+
"post",
|
|
122
|
+
"/auth/local/register",
|
|
123
|
+
{
|
|
124
|
+
data
|
|
125
|
+
}
|
|
126
|
+
);
|
|
88
127
|
this.setToken(jwt);
|
|
89
128
|
this.user = user;
|
|
90
129
|
return { user, jwt };
|
|
91
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Send an email to a user in order to reset his password
|
|
133
|
+
*
|
|
134
|
+
* @param {StrapiForgotPasswordData} data - Forgot password data: `email`
|
|
135
|
+
* @param {string} data.email - Email of the user who forgot his password
|
|
136
|
+
* @returns Promise<void>
|
|
137
|
+
*/
|
|
92
138
|
async forgotPassword(data) {
|
|
93
139
|
this.removeToken();
|
|
94
140
|
return this.request("post", "/auth/forgot-password", { data });
|
|
95
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Change the password of the logged in user.
|
|
144
|
+
* @author AnnikenYT
|
|
145
|
+
*
|
|
146
|
+
* @param {StrapiChangePasswordData} data - Change password data: `currentPassword`, `password`, `passwordConfirmation`
|
|
147
|
+
* @param {string} data.currentPassword - The current password of the user
|
|
148
|
+
* @param {string} data.password - The new password of the user
|
|
149
|
+
* @param {string} data.passwordConfirmation - Confirmation of the new password of the user
|
|
150
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
151
|
+
*/
|
|
152
|
+
async changePassword(data) {
|
|
153
|
+
const { user, jwt } = await this.request(
|
|
154
|
+
"post",
|
|
155
|
+
"/auth/change-password",
|
|
156
|
+
{
|
|
157
|
+
data
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
this.setToken(jwt);
|
|
161
|
+
this.user = user;
|
|
162
|
+
return { jwt, user };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Reset the user password
|
|
166
|
+
*
|
|
167
|
+
* @param {StrapiResetPasswordData} data - Reset password data object: `code`, `password`, `passwordConfirmation`
|
|
168
|
+
* @param {string} data.code - Code received by email after calling the `forgotPassword` method
|
|
169
|
+
* @param {string} data.password - New password of the user
|
|
170
|
+
* @param {string} data.passwordConfirmation - Confirmation of the new password of the user
|
|
171
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
172
|
+
*/
|
|
96
173
|
async resetPassword(data) {
|
|
97
174
|
this.removeToken();
|
|
98
|
-
const { user, jwt } = await this.request(
|
|
99
|
-
|
|
100
|
-
|
|
175
|
+
const { user, jwt } = await this.request(
|
|
176
|
+
"post",
|
|
177
|
+
"/auth/reset-password",
|
|
178
|
+
{
|
|
179
|
+
data
|
|
180
|
+
}
|
|
181
|
+
);
|
|
101
182
|
this.setToken(jwt);
|
|
102
183
|
this.user = user;
|
|
103
184
|
return { user, jwt };
|
|
104
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Send programmatically an email to a user in order to confirm his account
|
|
188
|
+
*
|
|
189
|
+
* @param {StrapiEmailConfirmationData} data - Email confirmation data: `email`
|
|
190
|
+
* @param {string} data.email - Email of the user who want to be confirmed
|
|
191
|
+
* @returns Promise<void>
|
|
192
|
+
*/
|
|
105
193
|
async sendEmailConfirmation(data) {
|
|
106
194
|
return this.request("post", "/auth/send-email-confirmation", {
|
|
107
195
|
data
|
|
108
196
|
});
|
|
109
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Get the correct URL to authenticate with provider
|
|
200
|
+
*
|
|
201
|
+
* @param {StrapiAuthProvider} provider - Provider name
|
|
202
|
+
* @returns string
|
|
203
|
+
*/
|
|
110
204
|
getProviderAuthenticationUrl(provider) {
|
|
111
|
-
return
|
|
205
|
+
return ufo.joinURL(this.options.url, this.options.prefix, "connect", provider);
|
|
112
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Authenticate user with the token present on the URL or in `params`
|
|
209
|
+
*
|
|
210
|
+
* @param {StrapiAuthProvider} provider - Provider name
|
|
211
|
+
* @param {string} access_token? - Access Token return from Strapi
|
|
212
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
213
|
+
*/
|
|
113
214
|
async authenticateProvider(provider, access_token) {
|
|
114
215
|
this.removeToken();
|
|
115
216
|
if (isBrowser()) {
|
|
116
|
-
const params =
|
|
217
|
+
const params = qs.parse(window.location.search, {
|
|
117
218
|
ignoreQueryPrefix: true
|
|
118
219
|
});
|
|
119
220
|
if (params.access_token)
|
|
120
221
|
access_token = params.access_token;
|
|
121
222
|
}
|
|
122
|
-
const { user, jwt } = await this.request(
|
|
123
|
-
|
|
124
|
-
|
|
223
|
+
const { user, jwt } = await this.request(
|
|
224
|
+
"get",
|
|
225
|
+
`/auth/${provider}/callback`,
|
|
226
|
+
{
|
|
227
|
+
params: { access_token }
|
|
228
|
+
}
|
|
229
|
+
);
|
|
125
230
|
this.setToken(jwt);
|
|
126
231
|
this.user = user;
|
|
127
232
|
return { user, jwt };
|
|
128
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Logout by removing authentication token
|
|
236
|
+
*
|
|
237
|
+
* @returns void
|
|
238
|
+
*/
|
|
129
239
|
logout() {
|
|
130
240
|
this.user = null;
|
|
131
241
|
this.removeToken();
|
|
132
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Get a list of {content-type} entries
|
|
245
|
+
*
|
|
246
|
+
* @param {string} contentType - Content type's name pluralized
|
|
247
|
+
* @param {StrapiRequestParams} params? - Query parameters
|
|
248
|
+
* @returns Promise<StrapiResponse<T>>
|
|
249
|
+
*/
|
|
133
250
|
find(contentType, params) {
|
|
134
251
|
return this.request("get", `/${contentType}`, {
|
|
135
252
|
params
|
|
136
253
|
});
|
|
137
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Get a specific {content-type} entry
|
|
257
|
+
*
|
|
258
|
+
* @param {string} contentType - Content type's name pluralized
|
|
259
|
+
* @param {string|number} id - ID of entry
|
|
260
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
261
|
+
* @returns Promise<StrapiResponse<T>>
|
|
262
|
+
*/
|
|
138
263
|
findOne(contentType, id, params) {
|
|
139
264
|
return this.request("get", `/${contentType}/${id}`, {
|
|
140
265
|
params
|
|
141
266
|
});
|
|
142
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Create a {content-type} entry
|
|
270
|
+
*
|
|
271
|
+
* @param {string} contentType - Content type's name pluralized
|
|
272
|
+
* @param {AxiosRequestConfig["data"]} data - New entry
|
|
273
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
274
|
+
* @returns Promise<StrapiResponse<T>>
|
|
275
|
+
*/
|
|
143
276
|
create(contentType, data, params) {
|
|
144
277
|
return this.request("post", `/${contentType}`, {
|
|
145
278
|
data: { data },
|
|
146
279
|
params
|
|
147
280
|
});
|
|
148
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Update a specific entry
|
|
284
|
+
*
|
|
285
|
+
* @param {string} contentType - Content type's name pluralized
|
|
286
|
+
* @param {string|number} id - ID of entry to be updated
|
|
287
|
+
* @param {AxiosRequestConfig["data"]} data - New entry data
|
|
288
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
289
|
+
* @returns Promise<StrapiResponse<T>>
|
|
290
|
+
*/
|
|
149
291
|
update(contentType, id, data, params) {
|
|
150
292
|
return this.request("put", `/${contentType}/${id}`, {
|
|
151
293
|
data: { data },
|
|
152
294
|
params
|
|
153
295
|
});
|
|
154
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Delete en entry
|
|
299
|
+
*
|
|
300
|
+
* @param {string} contentType - Content type's name pluralized
|
|
301
|
+
* @param {string|number} id - ID of entry to be deleted
|
|
302
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
303
|
+
* @returns Promise<StrapiResponse<T>>
|
|
304
|
+
*/
|
|
155
305
|
delete(contentType, id, params) {
|
|
156
306
|
return this.request("delete", `/${contentType}/${id}`, {
|
|
157
307
|
params
|
|
158
308
|
});
|
|
159
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Refresh local data of the logged-in user
|
|
312
|
+
*
|
|
313
|
+
* @returns Promise<StrapiUser>
|
|
314
|
+
*/
|
|
160
315
|
async fetchUser() {
|
|
161
316
|
try {
|
|
162
317
|
const user = await this.request("get", "/users/me");
|
|
@@ -166,26 +321,42 @@ class Strapi {
|
|
|
166
321
|
}
|
|
167
322
|
return this.user;
|
|
168
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Retrieve token from chosen storage
|
|
326
|
+
*
|
|
327
|
+
* @returns string | null
|
|
328
|
+
*/
|
|
169
329
|
getToken() {
|
|
170
330
|
const { useLocalStorage, key } = this.options.store;
|
|
171
331
|
if (isBrowser()) {
|
|
172
|
-
const token = useLocalStorage ? window.localStorage.getItem(key) :
|
|
332
|
+
const token = useLocalStorage ? window.localStorage.getItem(key) : Cookies.get(key);
|
|
173
333
|
if (typeof token === "undefined")
|
|
174
334
|
return null;
|
|
175
335
|
return token;
|
|
176
336
|
}
|
|
177
337
|
return null;
|
|
178
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Set token in chosen storage
|
|
341
|
+
*
|
|
342
|
+
* @param {string} token - Token retrieve from login or register method
|
|
343
|
+
* @returns void
|
|
344
|
+
*/
|
|
179
345
|
setToken(token) {
|
|
180
346
|
const { useLocalStorage, key, cookieOptions } = this.options.store;
|
|
181
347
|
if (isBrowser()) {
|
|
182
|
-
useLocalStorage ? window.localStorage.setItem(key, token) :
|
|
348
|
+
useLocalStorage ? window.localStorage.setItem(key, token) : Cookies.set(key, token, cookieOptions);
|
|
183
349
|
}
|
|
184
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Remove token from chosen storage (Cookies or Local)
|
|
353
|
+
*
|
|
354
|
+
* @returns void
|
|
355
|
+
*/
|
|
185
356
|
removeToken() {
|
|
186
357
|
const { useLocalStorage, key } = this.options.store;
|
|
187
358
|
if (isBrowser()) {
|
|
188
|
-
useLocalStorage ? window.localStorage.removeItem(key) :
|
|
359
|
+
useLocalStorage ? window.localStorage.removeItem(key) : Cookies.remove(key);
|
|
189
360
|
}
|
|
190
361
|
}
|
|
191
362
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AxiosRequestConfig, AxiosInstance, Method } from 'axios';
|
|
2
2
|
import { CookieAttributes } from 'js-cookie';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type StrapiAuthProvider = "github" | "facebook" | "google" | "cognito" | "twitter" | "discord" | "twitch" | "instagram" | "vk" | "linkedin" | "reddit" | "auth0";
|
|
5
|
+
type StrapiLocale = "af" | "af-NA" | "af-ZA" | "agq" | "agq-CM" | "ak" | "ak-GH" | "sq" | "sq-AL" | "am" | "am-ET" | "ar" | "ar-DZ" | "ar-BH" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-OM" | "ar-QA" | "ar-SA" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-AE" | "ar-001" | "ar-YE" | "hy" | "hy-AM" | "as" | "as-IN" | "asa" | "asa-TZ" | "az" | "az-Cyrl" | "az-Cyrl-AZ" | "az-Latn" | "az-Latn-AZ" | "ksf" | "ksf-CM" | "bm" | "bm-ML" | "bas" | "bas-CM" | "eu" | "eu-ES" | "be" | "be-BY" | "bem" | "bem-ZM" | "bez" | "bez-TZ" | "bn" | "bn-BD" | "bn-IN" | "brx" | "brx-IN" | "bs" | "bs-BA" | "br" | "br-FR" | "bg" | "bg-BG" | "my" | "my-MM" | "ca" | "ca-ES" | "ckb" | "tzm" | "tzm-Latn" | "tzm-Latn-MA" | "chr" | "chr-US" | "cgg" | "cgg-UG" | "zh" | "zh-Hans" | "zh-CN" | "zh-Hans-CN" | "zh-Hans-HK" | "zh-Hans-MO" | "zh-Hans-SG" | "zh-Hant" | "zh-Hant-HK" | "zh-Hant-MO" | "zh-Hant-TW" | "swc" | "swc-CD" | "kw" | "kw-GB" | "hr" | "hr-HR" | "cs" | "cs-CZ" | "da" | "da-DK" | "dua" | "dua-CM" | "nl" | "nl-AW" | "nl-BE" | "nl-CW" | "nl-NL" | "nl-SX" | "ebu" | "ebu-KE" | "en" | "en-AS" | "en-AU" | "en-BB" | "en-BE" | "en-BZ" | "en-BM" | "en-BW" | "en-CA" | "en-EG" | "en-EU" | "en-GU" | "en-GY" | "en-HK" | "en-IN" | "en-IE" | "en-JM" | "en-MT" | "en-MH" | "en-MU" | "en-NA" | "en-NZ" | "en-MP" | "en-PK" | "en-PH" | "en-SA" | "en-SG" | "en-ZA" | "en-TT" | "en-AE" | "en-UM" | "en-VI" | "en-US-POSIX" | "en-GB" | "en-US" | "en-ZW" | "eo" | "et" | "et-EE" | "ee" | "ee-GH" | "ee-TG" | "ewo" | "ewo-CM" | "fo" | "fo-FO" | "fil" | "fil-PH" | "fi" | "fi-FI" | "fr" | "fr-BE" | "fr-BJ" | "fr-BF" | "fr-BI" | "fr-CM" | "fr-CA" | "fr-CF" | "fr-TD" | "fr-KM" | "fr-CG" | "fr-CD" | "fr-CI" | "fr-DJ" | "fr-GQ" | "fr-FR" | "fr-GF" | "fr-GA" | "fr-GP" | "fr-GN" | "fr-LU" | "fr-MG" | "fr-ML" | "fr-MQ" | "fr-YT" | "fr-MC" | "fr-NE" | "fr-RW" | "fr-RE" | "fr-BL" | "fr-MF" | "fr-SN" | "fr-CH" | "fr-TG" | "ff" | "ff-SN" | "gl" | "gl-ES" | "lg" | "lg-UG" | "ka" | "ka-GE" | "de" | "de-AT" | "de-BE" | "de-DE" | "de-LI" | "de-LU" | "de-CH" | "el" | "el-CY" | "el-GR" | "gu" | "gu-IN" | "guz" | "guz-KE" | "ha" | "ha-Latn" | "ha-Latn-GH" | "ha-Latn-NE" | "ha-Latn-NG" | "haw" | "haw-US" | "he" | "he-IL" | "hi" | "hi-IN" | "hu" | "hu-HU" | "is" | "is-IS" | "ig" | "ig-NG" | "id" | "id-ID" | "ga" | "ga-IE" | "it" | "it-IT" | "it-CH" | "ja" | "ja-JP" | "dyo" | "dyo-SN" | "kea" | "kea-CV" | "kab" | "kab-DZ" | "kl" | "kl-GL" | "kln" | "kln-KE" | "kam" | "kam-KE" | "kn" | "kn-IN" | "kk" | "kk-Cyrl" | "kk-Cyrl-KZ" | "km" | "km-KH" | "ki" | "ki-KE" | "rw" | "rw-RW" | "kok" | "kok-IN" | "ko" | "ko-KR" | "khq" | "khq-ML" | "ses" | "ses-ML" | "nmg" | "nmg-CM" | "lag" | "lag-TZ" | "lv" | "lv-LV" | "ln" | "ln-CG" | "ln-CD" | "lt" | "lt-LT" | "lu" | "lu-CD" | "luo" | "luo-KE" | "luy" | "luy-KE" | "mk" | "mk-MK" | "jmc" | "jmc-TZ" | "mgh" | "mgh-MZ" | "kde" | "kde-TZ" | "mg" | "mg-MG" | "ms" | "ms-BN" | "ms-MY" | "ml" | "ml-IN" | "mt" | "mt-MT" | "gv" | "gv-GB" | "mr" | "mr-IN" | "mas" | "mas-KE" | "mas-TZ" | "mer" | "mer-KE" | "mfe" | "mfe-MU" | "mua" | "mua-CM" | "naq" | "naq-NA" | "ne" | "ne-IN" | "ne-NP" | "nd" | "nd-ZW" | "nb" | "nb-NO" | "nn" | "nn-NO" | "nus" | "nus-SD" | "nyn" | "nyn-UG" | "or" | "or-IN" | "om" | "om-ET" | "om-KE" | "ps" | "ps-AF" | "fa" | "fa-AF" | "fa-IR" | "pl" | "pl-PL" | "pt" | "pt-AO" | "pt-BR" | "pt-GW" | "pt-MZ" | "pt-PT" | "pt-ST" | "pa" | "pa-Arab" | "pa-Arab-PK" | "pa-Guru" | "pa-Guru-IN" | "ro" | "ro-MD" | "ro-RO" | "rm" | "rm-CH" | "rof" | "rof-TZ" | "rn" | "rn-BI" | "ru" | "ru-MD" | "ru-RU" | "ru-UA" | "rwk" | "rwk-TZ" | "saq" | "saq-KE" | "sg" | "sg-CF" | "sbp" | "sbp-TZ" | "seh" | "seh-MZ" | "sr" | "sr-Cyrl" | "sr-Cyrl-BA" | "sr-Cyrl-ME" | "sr-Cyrl-RS" | "sr-Latn" | "sr-Latn-BA" | "sr-Latn-ME" | "sr-Latn-RS" | "ksb" | "ksb-TZ" | "sn" | "sn-ZW" | "ii" | "ii-CN" | "si" | "si-LK" | "sk" | "sk-SK" | "sl" | "sl-SI" | "xog" | "xog-UG" | "so" | "so-DJ" | "so-ET" | "so-KE" | "so-SO" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-DO" | "es-EC" | "es-SV" | "es-GQ" | "es-GT" | "es-HN" | "es-419" | "es-MX" | "es-NI" | "es-PA" | "es-PY" | "es-PE" | "es-PR" | "es-ES" | "es-US" | "es-UY" | "es-VE" | "sw" | "sw-KE" | "sw-TZ" | "sv" | "sv-FI" | "sv-SE" | "gsw" | "gsw-CH" | "shi" | "shi-Latn" | "shi-Latn-MA" | "shi-Tfng" | "shi-Tfng-MA" | "dav" | "dav-KE" | "ta" | "ta-IN" | "ta-LK" | "twq" | "twq-NE" | "te" | "te-IN" | "teo" | "teo-KE" | "teo-UG" | "th" | "th-TH" | "bo" | "bo-CN" | "bo-IN" | "ti" | "ti-ER" | "ti-ET" | "to" | "to-TO" | "tr" | "tr-TR" | "uk" | "uk-UA" | "ur" | "ur-IN" | "ur-PK" | "uz" | "uz-Arab" | "uz-Arab-AF" | "uz-Cyrl" | "uz-Cyrl-UZ" | "uz-Latn" | "uz-Latn-UZ" | "vai" | "vai-Latn" | "vai-Latn-LR" | "vai-Vaii" | "vai-Vaii-LR" | "vi" | "vi-VN" | "vun" | "vun-TZ" | "cy" | "cy-GB" | "yav" | "yav-CM" | "yo" | "yo-NG" | "dje" | "dje-NE" | "zu" | "zu-ZA";
|
|
6
6
|
interface StoreConfig {
|
|
7
7
|
key: string;
|
|
8
8
|
useLocalStorage?: boolean;
|
|
@@ -20,7 +20,7 @@ interface StrapiDefaultOptions {
|
|
|
20
20
|
store: StoreConfig;
|
|
21
21
|
axiosOptions: AxiosRequestConfig;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
type StrapiUser = Record<string, unknown> | null;
|
|
24
24
|
interface PaginationByPage {
|
|
25
25
|
page: number;
|
|
26
26
|
pageSize: number;
|
|
@@ -71,6 +71,11 @@ interface StrapiRegistrationData {
|
|
|
71
71
|
interface StrapiForgotPasswordData {
|
|
72
72
|
email: string;
|
|
73
73
|
}
|
|
74
|
+
interface StrapiChangePasswordData {
|
|
75
|
+
currentPassword: string;
|
|
76
|
+
password: string;
|
|
77
|
+
passwordConfirmation: string;
|
|
78
|
+
}
|
|
74
79
|
interface StrapiResetPasswordData {
|
|
75
80
|
code: string;
|
|
76
81
|
password: string;
|
|
@@ -130,6 +135,17 @@ declare class Strapi {
|
|
|
130
135
|
* @returns Promise<void>
|
|
131
136
|
*/
|
|
132
137
|
forgotPassword(data: StrapiForgotPasswordData): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Change the password of the logged in user.
|
|
140
|
+
* @author AnnikenYT
|
|
141
|
+
*
|
|
142
|
+
* @param {StrapiChangePasswordData} data - Change password data: `currentPassword`, `password`, `passwordConfirmation`
|
|
143
|
+
* @param {string} data.currentPassword - The current password of the user
|
|
144
|
+
* @param {string} data.password - The new password of the user
|
|
145
|
+
* @param {string} data.passwordConfirmation - Confirmation of the new password of the user
|
|
146
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
147
|
+
*/
|
|
148
|
+
changePassword(data: StrapiChangePasswordData): Promise<StrapiAuthenticationResponse>;
|
|
133
149
|
/**
|
|
134
150
|
* Reset the user password
|
|
135
151
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import axios from 'axios';
|
|
|
2
2
|
import defu from 'defu';
|
|
3
3
|
import qs from 'qs';
|
|
4
4
|
import Cookies from 'js-cookie';
|
|
5
|
+
import { cleanDoubleSlashes, joinURL } from 'ufo';
|
|
5
6
|
|
|
6
7
|
function isBrowser() {
|
|
7
8
|
return typeof window !== "undefined";
|
|
@@ -18,11 +19,27 @@ const defaults = {
|
|
|
18
19
|
axiosOptions: {}
|
|
19
20
|
};
|
|
20
21
|
class Strapi {
|
|
22
|
+
axios;
|
|
23
|
+
options;
|
|
24
|
+
user = null;
|
|
25
|
+
/**
|
|
26
|
+
* Strapi SDK Constructor
|
|
27
|
+
*
|
|
28
|
+
* @constructor
|
|
29
|
+
* @param {StrapiOptions} options? - Options in order to configure API URL, list your Content Types & extend the axios configuration
|
|
30
|
+
* @param {string} options.url? - Your Strapi API URL, Default: http://localhost::1337
|
|
31
|
+
* @param {StoreConfig} options.store? - Config the way you want to store JWT (Cookie or LocalStorage)
|
|
32
|
+
* @param {AxiosRequestConfig} options.axiosOptions? - The list of your Content type on your Strapi API
|
|
33
|
+
*/
|
|
21
34
|
constructor(options) {
|
|
22
|
-
|
|
23
|
-
this.options =
|
|
35
|
+
const _options = defu(options || {}, defaults);
|
|
36
|
+
this.options = {
|
|
37
|
+
..._options,
|
|
38
|
+
url: cleanDoubleSlashes(_options?.url),
|
|
39
|
+
prefix: cleanDoubleSlashes(_options?.prefix)
|
|
40
|
+
};
|
|
24
41
|
this.axios = axios.create({
|
|
25
|
-
baseURL:
|
|
42
|
+
baseURL: joinURL(this.options.url, this.options.prefix),
|
|
26
43
|
paramsSerializer: qs.stringify,
|
|
27
44
|
...this.options.axiosOptions
|
|
28
45
|
});
|
|
@@ -37,6 +54,14 @@ class Strapi {
|
|
|
37
54
|
return config;
|
|
38
55
|
});
|
|
39
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Basic axios request
|
|
59
|
+
*
|
|
60
|
+
* @param {Method} method - HTTP method
|
|
61
|
+
* @param {string} url - Custom or Strapi API URL
|
|
62
|
+
* @param {AxiosRequestConfig} axiosConfig? - Custom Axios config
|
|
63
|
+
* @returns Promise<T>
|
|
64
|
+
*/
|
|
40
65
|
async request(method, url, axiosConfig) {
|
|
41
66
|
try {
|
|
42
67
|
const response = await this.axios.request({
|
|
@@ -62,6 +87,14 @@ class Strapi {
|
|
|
62
87
|
}
|
|
63
88
|
}
|
|
64
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Authenticate user & retrieve his JWT
|
|
92
|
+
*
|
|
93
|
+
* @param {StrapiAuthenticationData} data - User authentication form data: `identifier`, `password`
|
|
94
|
+
* @param {string} data.identifier - The email or username of the user
|
|
95
|
+
* @param {string} data.password - The password of the user
|
|
96
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
97
|
+
*/
|
|
65
98
|
async login(data) {
|
|
66
99
|
this.removeToken();
|
|
67
100
|
const { user, jwt } = await this.request("post", "/auth/local", {
|
|
@@ -71,36 +104,111 @@ class Strapi {
|
|
|
71
104
|
this.user = user;
|
|
72
105
|
return { user, jwt };
|
|
73
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Register a new user & retrieve JWT
|
|
109
|
+
*
|
|
110
|
+
* @param {StrapiRegistrationData} data - New user registration data: `username`, `email`, `password`
|
|
111
|
+
* @param {string} data.username - Username of the new user
|
|
112
|
+
* @param {string} data.email - Email of the new user
|
|
113
|
+
* @param {string} data.password - Password of the new user
|
|
114
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
115
|
+
*/
|
|
74
116
|
async register(data) {
|
|
75
117
|
this.removeToken();
|
|
76
|
-
const { user, jwt } = await this.request(
|
|
77
|
-
|
|
78
|
-
|
|
118
|
+
const { user, jwt } = await this.request(
|
|
119
|
+
"post",
|
|
120
|
+
"/auth/local/register",
|
|
121
|
+
{
|
|
122
|
+
data
|
|
123
|
+
}
|
|
124
|
+
);
|
|
79
125
|
this.setToken(jwt);
|
|
80
126
|
this.user = user;
|
|
81
127
|
return { user, jwt };
|
|
82
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Send an email to a user in order to reset his password
|
|
131
|
+
*
|
|
132
|
+
* @param {StrapiForgotPasswordData} data - Forgot password data: `email`
|
|
133
|
+
* @param {string} data.email - Email of the user who forgot his password
|
|
134
|
+
* @returns Promise<void>
|
|
135
|
+
*/
|
|
83
136
|
async forgotPassword(data) {
|
|
84
137
|
this.removeToken();
|
|
85
138
|
return this.request("post", "/auth/forgot-password", { data });
|
|
86
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Change the password of the logged in user.
|
|
142
|
+
* @author AnnikenYT
|
|
143
|
+
*
|
|
144
|
+
* @param {StrapiChangePasswordData} data - Change password data: `currentPassword`, `password`, `passwordConfirmation`
|
|
145
|
+
* @param {string} data.currentPassword - The current password of the user
|
|
146
|
+
* @param {string} data.password - The new password of the user
|
|
147
|
+
* @param {string} data.passwordConfirmation - Confirmation of the new password of the user
|
|
148
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
149
|
+
*/
|
|
150
|
+
async changePassword(data) {
|
|
151
|
+
const { user, jwt } = await this.request(
|
|
152
|
+
"post",
|
|
153
|
+
"/auth/change-password",
|
|
154
|
+
{
|
|
155
|
+
data
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
this.setToken(jwt);
|
|
159
|
+
this.user = user;
|
|
160
|
+
return { jwt, user };
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Reset the user password
|
|
164
|
+
*
|
|
165
|
+
* @param {StrapiResetPasswordData} data - Reset password data object: `code`, `password`, `passwordConfirmation`
|
|
166
|
+
* @param {string} data.code - Code received by email after calling the `forgotPassword` method
|
|
167
|
+
* @param {string} data.password - New password of the user
|
|
168
|
+
* @param {string} data.passwordConfirmation - Confirmation of the new password of the user
|
|
169
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
170
|
+
*/
|
|
87
171
|
async resetPassword(data) {
|
|
88
172
|
this.removeToken();
|
|
89
|
-
const { user, jwt } = await this.request(
|
|
90
|
-
|
|
91
|
-
|
|
173
|
+
const { user, jwt } = await this.request(
|
|
174
|
+
"post",
|
|
175
|
+
"/auth/reset-password",
|
|
176
|
+
{
|
|
177
|
+
data
|
|
178
|
+
}
|
|
179
|
+
);
|
|
92
180
|
this.setToken(jwt);
|
|
93
181
|
this.user = user;
|
|
94
182
|
return { user, jwt };
|
|
95
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Send programmatically an email to a user in order to confirm his account
|
|
186
|
+
*
|
|
187
|
+
* @param {StrapiEmailConfirmationData} data - Email confirmation data: `email`
|
|
188
|
+
* @param {string} data.email - Email of the user who want to be confirmed
|
|
189
|
+
* @returns Promise<void>
|
|
190
|
+
*/
|
|
96
191
|
async sendEmailConfirmation(data) {
|
|
97
192
|
return this.request("post", "/auth/send-email-confirmation", {
|
|
98
193
|
data
|
|
99
194
|
});
|
|
100
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Get the correct URL to authenticate with provider
|
|
198
|
+
*
|
|
199
|
+
* @param {StrapiAuthProvider} provider - Provider name
|
|
200
|
+
* @returns string
|
|
201
|
+
*/
|
|
101
202
|
getProviderAuthenticationUrl(provider) {
|
|
102
|
-
return
|
|
203
|
+
return joinURL(this.options.url, this.options.prefix, "connect", provider);
|
|
103
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Authenticate user with the token present on the URL or in `params`
|
|
207
|
+
*
|
|
208
|
+
* @param {StrapiAuthProvider} provider - Provider name
|
|
209
|
+
* @param {string} access_token? - Access Token return from Strapi
|
|
210
|
+
* @returns Promise<StrapiAuthenticationResponse>
|
|
211
|
+
*/
|
|
104
212
|
async authenticateProvider(provider, access_token) {
|
|
105
213
|
this.removeToken();
|
|
106
214
|
if (isBrowser()) {
|
|
@@ -110,44 +218,98 @@ class Strapi {
|
|
|
110
218
|
if (params.access_token)
|
|
111
219
|
access_token = params.access_token;
|
|
112
220
|
}
|
|
113
|
-
const { user, jwt } = await this.request(
|
|
114
|
-
|
|
115
|
-
|
|
221
|
+
const { user, jwt } = await this.request(
|
|
222
|
+
"get",
|
|
223
|
+
`/auth/${provider}/callback`,
|
|
224
|
+
{
|
|
225
|
+
params: { access_token }
|
|
226
|
+
}
|
|
227
|
+
);
|
|
116
228
|
this.setToken(jwt);
|
|
117
229
|
this.user = user;
|
|
118
230
|
return { user, jwt };
|
|
119
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Logout by removing authentication token
|
|
234
|
+
*
|
|
235
|
+
* @returns void
|
|
236
|
+
*/
|
|
120
237
|
logout() {
|
|
121
238
|
this.user = null;
|
|
122
239
|
this.removeToken();
|
|
123
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* Get a list of {content-type} entries
|
|
243
|
+
*
|
|
244
|
+
* @param {string} contentType - Content type's name pluralized
|
|
245
|
+
* @param {StrapiRequestParams} params? - Query parameters
|
|
246
|
+
* @returns Promise<StrapiResponse<T>>
|
|
247
|
+
*/
|
|
124
248
|
find(contentType, params) {
|
|
125
249
|
return this.request("get", `/${contentType}`, {
|
|
126
250
|
params
|
|
127
251
|
});
|
|
128
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Get a specific {content-type} entry
|
|
255
|
+
*
|
|
256
|
+
* @param {string} contentType - Content type's name pluralized
|
|
257
|
+
* @param {string|number} id - ID of entry
|
|
258
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
259
|
+
* @returns Promise<StrapiResponse<T>>
|
|
260
|
+
*/
|
|
129
261
|
findOne(contentType, id, params) {
|
|
130
262
|
return this.request("get", `/${contentType}/${id}`, {
|
|
131
263
|
params
|
|
132
264
|
});
|
|
133
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Create a {content-type} entry
|
|
268
|
+
*
|
|
269
|
+
* @param {string} contentType - Content type's name pluralized
|
|
270
|
+
* @param {AxiosRequestConfig["data"]} data - New entry
|
|
271
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
272
|
+
* @returns Promise<StrapiResponse<T>>
|
|
273
|
+
*/
|
|
134
274
|
create(contentType, data, params) {
|
|
135
275
|
return this.request("post", `/${contentType}`, {
|
|
136
276
|
data: { data },
|
|
137
277
|
params
|
|
138
278
|
});
|
|
139
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Update a specific entry
|
|
282
|
+
*
|
|
283
|
+
* @param {string} contentType - Content type's name pluralized
|
|
284
|
+
* @param {string|number} id - ID of entry to be updated
|
|
285
|
+
* @param {AxiosRequestConfig["data"]} data - New entry data
|
|
286
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
287
|
+
* @returns Promise<StrapiResponse<T>>
|
|
288
|
+
*/
|
|
140
289
|
update(contentType, id, data, params) {
|
|
141
290
|
return this.request("put", `/${contentType}/${id}`, {
|
|
142
291
|
data: { data },
|
|
143
292
|
params
|
|
144
293
|
});
|
|
145
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Delete en entry
|
|
297
|
+
*
|
|
298
|
+
* @param {string} contentType - Content type's name pluralized
|
|
299
|
+
* @param {string|number} id - ID of entry to be deleted
|
|
300
|
+
* @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
|
|
301
|
+
* @returns Promise<StrapiResponse<T>>
|
|
302
|
+
*/
|
|
146
303
|
delete(contentType, id, params) {
|
|
147
304
|
return this.request("delete", `/${contentType}/${id}`, {
|
|
148
305
|
params
|
|
149
306
|
});
|
|
150
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Refresh local data of the logged-in user
|
|
310
|
+
*
|
|
311
|
+
* @returns Promise<StrapiUser>
|
|
312
|
+
*/
|
|
151
313
|
async fetchUser() {
|
|
152
314
|
try {
|
|
153
315
|
const user = await this.request("get", "/users/me");
|
|
@@ -157,6 +319,11 @@ class Strapi {
|
|
|
157
319
|
}
|
|
158
320
|
return this.user;
|
|
159
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Retrieve token from chosen storage
|
|
324
|
+
*
|
|
325
|
+
* @returns string | null
|
|
326
|
+
*/
|
|
160
327
|
getToken() {
|
|
161
328
|
const { useLocalStorage, key } = this.options.store;
|
|
162
329
|
if (isBrowser()) {
|
|
@@ -167,12 +334,23 @@ class Strapi {
|
|
|
167
334
|
}
|
|
168
335
|
return null;
|
|
169
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Set token in chosen storage
|
|
339
|
+
*
|
|
340
|
+
* @param {string} token - Token retrieve from login or register method
|
|
341
|
+
* @returns void
|
|
342
|
+
*/
|
|
170
343
|
setToken(token) {
|
|
171
344
|
const { useLocalStorage, key, cookieOptions } = this.options.store;
|
|
172
345
|
if (isBrowser()) {
|
|
173
346
|
useLocalStorage ? window.localStorage.setItem(key, token) : Cookies.set(key, token, cookieOptions);
|
|
174
347
|
}
|
|
175
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Remove token from chosen storage (Cookies or Local)
|
|
351
|
+
*
|
|
352
|
+
* @returns void
|
|
353
|
+
*/
|
|
176
354
|
removeToken() {
|
|
177
355
|
const { useLocalStorage, key } = this.options.store;
|
|
178
356
|
if (isBrowser()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-sdk-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "📦 Javascript SDK for your Strapi API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"exports": {
|
|
39
39
|
".": {
|
|
40
40
|
"require": "./dist/index.cjs",
|
|
41
|
-
"import": "./dist/index.mjs"
|
|
41
|
+
"import": "./dist/index.mjs",
|
|
42
|
+
"types": "./dist/index.d.ts"
|
|
42
43
|
},
|
|
43
44
|
"./package.json": "./package.json"
|
|
44
45
|
},
|
|
@@ -49,8 +50,8 @@
|
|
|
49
50
|
"dist/"
|
|
50
51
|
],
|
|
51
52
|
"scripts": {
|
|
52
|
-
"start": "
|
|
53
|
-
"build": "
|
|
53
|
+
"start": "rollup -c --watch",
|
|
54
|
+
"build": "rollup -c",
|
|
54
55
|
"clean": "rm -rf bin dist coverage",
|
|
55
56
|
"lint": "eslint . --ext .ts,.js",
|
|
56
57
|
"lint:fix": "eslint . --ext .ts,.js --fix",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"test:unit": "jest",
|
|
59
60
|
"commit": "git-cz",
|
|
60
61
|
"release": "dotenv release-it --",
|
|
61
|
-
"prepare": "
|
|
62
|
+
"prepare": "rollup -c"
|
|
62
63
|
},
|
|
63
64
|
"lint-staged": {
|
|
64
65
|
"*.{js,jsx,ts,tsx}": "eslint --cache --fix"
|
|
@@ -71,31 +72,38 @@
|
|
|
71
72
|
"dependencies": {
|
|
72
73
|
"@types/js-cookie": "^3.0.0",
|
|
73
74
|
"@types/qs": "^6.9.6",
|
|
74
|
-
"axios": "^0.
|
|
75
|
+
"axios": "^0.27.0",
|
|
75
76
|
"defu": "^5.0.0",
|
|
76
77
|
"js-cookie": "^3.0.0",
|
|
77
|
-
"qs": "^6.10.1"
|
|
78
|
+
"qs": "^6.10.1",
|
|
79
|
+
"ufo": "^1.2.0"
|
|
78
80
|
},
|
|
79
81
|
"devDependencies": {
|
|
80
|
-
"@commitlint/cli": "
|
|
81
|
-
"@commitlint/config-conventional": "
|
|
82
|
-
"@release-it/conventional-changelog": "4.
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"@
|
|
86
|
-
"@
|
|
87
|
-
"
|
|
82
|
+
"@commitlint/cli": "17.6.7",
|
|
83
|
+
"@commitlint/config-conventional": "17.6.7",
|
|
84
|
+
"@release-it/conventional-changelog": "4.3.0",
|
|
85
|
+
"@rollup/plugin-commonjs": "^25.0.3",
|
|
86
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
87
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
88
|
+
"@types/jest": "27.5.2",
|
|
89
|
+
"@types/sinon": "10.0.16",
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
91
|
+
"@typescript-eslint/parser": "5.62.0",
|
|
92
|
+
"commitizen": "4.3.0",
|
|
88
93
|
"cz-conventional-changelog": "3.3.0",
|
|
89
|
-
"dotenv-cli": "
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
+
"dotenv-cli": "7.2.1",
|
|
95
|
+
"esbuild": "^0.18.19",
|
|
96
|
+
"eslint": "8.46.0",
|
|
97
|
+
"husky": "8.0.3",
|
|
98
|
+
"jest": "27.5.1",
|
|
99
|
+
"lint-staged": "13.2.3",
|
|
94
100
|
"npm-run-all": "4.1.5",
|
|
95
|
-
"release-it": "14.
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
101
|
+
"release-it": "14.14.3",
|
|
102
|
+
"rollup": "^3.27.2",
|
|
103
|
+
"rollup-plugin-dts": "^5.3.1",
|
|
104
|
+
"rollup-plugin-esbuild": "^5.0.0",
|
|
105
|
+
"sinon": "15.2.0",
|
|
106
|
+
"ts-jest": "27.1.5",
|
|
107
|
+
"typescript": "5.1.6"
|
|
100
108
|
}
|
|
101
109
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# [2.2.0](https://github.com/Stun3R/strapi-sdk-js/compare/v2.1.5...v2.2.0) (2022-02-17)
|
|
2
|
-
|
|
3
|
-
## [2.1.5](https://github.com/Stun3R/strapi-sdk-js/compare/v2.1.4...v2.1.5) (2022-01-17)
|
|
4
|
-
|
|
5
|
-
## [2.1.4](https://github.com/Stun3R/strapi-sdk-js/compare/v2.1.3...v2.1.4) (2022-01-14)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
* **options:** remove process usage in default to be compatible with more framework ([aaa162d](https://github.com/Stun3R/strapi-sdk-js/commit/aaa162d53bc656a149da8d2aacc9560a42a11d55))
|
|
11
|
-
|
|
12
|
-
## [2.1.3](https://github.com/Stun3R/strapi-sdk-js/compare/v2.1.2...v2.1.3) (2022-01-05)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Bug Fixes
|
|
16
|
-
|
|
17
|
-
* **deps:** pin dependencies ([2e6e5a9](https://github.com/Stun3R/strapi-sdk-js/commit/2e6e5a984e3c3bce226bdb0a55218d6707cc0488))
|
|
18
|
-
* **deps:** update dependency @nuxt/content-theme-docs to v0.11.1 ([1541e39](https://github.com/Stun3R/strapi-sdk-js/commit/1541e392bb9e70ee7cdc65fa1362358518c0d084))
|
|
19
|
-
* **deps:** update dependency axios to ^0.24.0 ([4e2a41d](https://github.com/Stun3R/strapi-sdk-js/commit/4e2a41d5a3ffca07cf502d488ce9caea809f4bbc))
|
|
20
|
-
|
|
21
|
-
## [2.1.2](https://github.com/Stun3R/strapi-sdk-js/compare/v2.1.1...v2.1.2) (2021-12-30)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### Bug Fixes
|
|
25
|
-
|
|
26
|
-
* **params:** change type to accept object for populate ([bfa835c](https://github.com/Stun3R/strapi-sdk-js/commit/bfa835c6d01425049f7d675f96316516d59bca5d)), closes [#108](https://github.com/Stun3R/strapi-sdk-js/issues/108)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Features
|
|
30
|
-
|
|
31
|
-
* add integrations ([439b292](https://github.com/Stun3R/strapi-sdk-js/commit/439b2926e474c06a0e581f9af7c1ad08c5eb7282))
|
|
32
|
-
|
|
33
|
-
## [2.1.1](https://github.com/Stun3R/strapi-sdk-js/compare/v2.1.0...v2.1.1) (2021-11-29)
|
|
34
|
-
|
|
35
|
-
# [2.0.0](https://github.com/Stun3R/strapi-sdk-js/compare/v1.1.0...v2.0.0) (2021-11-08)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### Features
|
|
39
|
-
|
|
40
|
-
* **Strapi v4 support**
|
|
41
|
-
* add params to create, update, delete methods in order to selecting field in response ([a693dac](https://github.com/Stun3R/strapi-sdk-js/commit/a693dac21101260125db8672229644387b2ee3e4))
|
|
42
|
-
* add StrapiLocale type for better autocompletion ([583c5b8](https://github.com/Stun3R/strapi-sdk-js/commit/583c5b8d561426c581f31ed6d335fc322411be71))
|
|
43
|
-
* replace axios request config params by custom type based on strapi rest api parameters ([2047433](https://github.com/Stun3R/strapi-sdk-js/commit/2047433f93aaae9b4eaeb0c7f4b49cccfb46f770))
|
|
44
|
-
* v4 error handling ([4d0eb3f](https://github.com/Stun3R/strapi-sdk-js/commit/4d0eb3f50ed9796e7dd3837cd45a2d926e9679d5))
|
|
45
|
-
|
|
46
|
-
# [1.1.0](https://github.com/Stun3R/strapi-sdk-js/compare/v1.0.2...v1.1.0) (2021-10-19)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### Bug Fixes
|
|
50
|
-
|
|
51
|
-
* add axioserror type on error ([1140bbb](https://github.com/Stun3R/strapi-sdk-js/commit/1140bbb990c37e492aa8d457a1e65ff5a0ac24ed))
|
|
52
|
-
* **deps:** update dependency @types/js-cookie to v3 ([88483aa](https://github.com/Stun3R/strapi-sdk-js/commit/88483aa0ff841c440716bbe1014ff8a6ef58c27f))
|
|
53
|
-
* **deps:** update dependency axios to ^0.23.0 ([854e84e](https://github.com/Stun3R/strapi-sdk-js/commit/854e84e02cdb818a69dddfecb8c1530f791609c4))
|
|
54
|
-
* missing comma after dependencies ([6efe03b](https://github.com/Stun3R/strapi-sdk-js/commit/6efe03b1713c5df97a077d3c5db43022d3fcc3f6))
|
|
55
|
-
* **tests:** switch response type to follow latest change ([362b5d9](https://github.com/Stun3R/strapi-sdk-js/commit/362b5d911ffb9fbeb37de7678dd60b97c7dbf2f6))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### Code Refactoring
|
|
59
|
-
|
|
60
|
-
* drop of graphql methods support ([eebd7a3](https://github.com/Stun3R/strapi-sdk-js/commit/eebd7a34ddbce216ba0e8b3f5a3f95c0a0a5add5))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
### BREAKING CHANGES
|
|
64
|
-
|
|
65
|
-
* SDK supports Strapi v4. Every CRUD methods response changed. Please refer to [documentation](https://strapi-sdk-js.netlify.app)
|
|
66
|
-
* GraphQL is no longer supported in v1.1.0
|
|
67
|
-
|
|
68
|
-
## [1.0.2](https://github.com/Stun3R/strapi-sdk-js/compare/v1.0.1...v1.0.2) (2021-08-30)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Bug Fixes
|
|
72
|
-
|
|
73
|
-
* **deps:** update dependency js-cookie to v3 ([54be993](https://github.com/Stun3R/strapi-sdk-js/commit/54be993f1c02949fb320786bca409681eb6c9ed0))
|
|
74
|
-
* **deps:** update dependency nuxt to v2.15.7 ([062c012](https://github.com/Stun3R/strapi-sdk-js/commit/062c0121f63746c728f895fcf4b608e3e820826d))
|
|
75
|
-
* **deps:** update dependency nuxt to v2.15.8 ([598dacd](https://github.com/Stun3R/strapi-sdk-js/commit/598dacdeab43252d92405fc67882de2c00609b48))
|
|
76
|
-
|
|
77
|
-
## 1.0.1 (2021-06-17)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
### Bug Fixes
|
|
81
|
-
|
|
82
|
-
* **npm:** dist folder is missing when installing package ([8629d3d](https://github.com/Stun3R/strapi-sdk-js/commit/8629d3d85f399925f1697a5ab39881f47e1fe5fa)) @lhillebrandt
|
|
83
|
-
* **dist:** change path in order to take dist inside npm package ([b494a35](https://github.com/Stun3R/strapi-sdk-js/commit/b494a352cb5559a8e9a2e2e931ee30a67836ef82))
|
|
84
|
-
* **package.json:** remove trailing slash from dist folder in files ([7d3000c](https://github.com/Stun3R/strapi-sdk-js/commit/7d3000c15f63443d03971bc510cecf86ae530983))
|
|
85
|
-
|
|
86
|
-
# 1.0.0 (2021-06-11)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
### Bug Fixes
|
|
90
|
-
|
|
91
|
-
* **deps:** pin dependency docus to v0.1.5 ([9870d86](https://github.com/Stun3R/strapi-sdk-js/commit/9870d8669457bd31bfb184dcafc2e90b6fd0ecba))
|
|
92
|
-
* **deps:** update dependency nuxt to v2.15.6 ([f37aefd](https://github.com/Stun3R/strapi-sdk-js/commit/f37aefdebbcc9fb6bea8628c5b10c8c706dbc287))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
### Features
|
|
96
|
-
|
|
97
|
-
* **user:** add user object, getter, setter & fetch methods ([e18089a](https://github.com/Stun3R/strapi-sdk-js/commit/e18089ae31446eeaff49c6e8a01250bc5cbe14ac))
|
|
98
|
-
* **auth:** add auth & token methods ([a554ee9](https://github.com/Stun3R/strapi-sdk-js/commit/a554ee9930f3dc87e792afaba571e84143707528))
|
|
99
|
-
* **core:** add crud methods, typescript support & graphql method ([cbe3b47](https://github.com/Stun3R/strapi-sdk-js/commit/cbe3b475dcdf49e3d6a37d594de2c69db8e185f3))
|
|
100
|
-
|