strapi-sdk-js 2.3.0 → 2.3.1
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 +17 -6
- package/dist/index.mjs +19 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10,6 +10,12 @@ function isBrowser() {
|
|
|
10
10
|
return typeof window !== "undefined";
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __publicField = (obj, key, value) => {
|
|
16
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
17
|
+
return value;
|
|
18
|
+
};
|
|
13
19
|
const defaults = {
|
|
14
20
|
url: "http://localhost:1337",
|
|
15
21
|
prefix: "/api",
|
|
@@ -21,9 +27,6 @@ const defaults = {
|
|
|
21
27
|
axiosOptions: {}
|
|
22
28
|
};
|
|
23
29
|
class Strapi {
|
|
24
|
-
axios;
|
|
25
|
-
options;
|
|
26
|
-
user = null;
|
|
27
30
|
/**
|
|
28
31
|
* Strapi SDK Constructor
|
|
29
32
|
*
|
|
@@ -34,11 +37,14 @@ class Strapi {
|
|
|
34
37
|
* @param {AxiosRequestConfig} options.axiosOptions? - The list of your Content type on your Strapi API
|
|
35
38
|
*/
|
|
36
39
|
constructor(options) {
|
|
40
|
+
__publicField(this, "axios");
|
|
41
|
+
__publicField(this, "options");
|
|
42
|
+
__publicField(this, "user", null);
|
|
37
43
|
const _options = defu(options || {}, defaults);
|
|
38
44
|
this.options = {
|
|
39
45
|
..._options,
|
|
40
|
-
url: ufo.cleanDoubleSlashes(_options
|
|
41
|
-
prefix: ufo.cleanDoubleSlashes(_options
|
|
46
|
+
url: ufo.cleanDoubleSlashes(_options == null ? void 0 : _options.url),
|
|
47
|
+
prefix: ufo.cleanDoubleSlashes(_options == null ? void 0 : _options.prefix)
|
|
42
48
|
};
|
|
43
49
|
this.axios = axios.create({
|
|
44
50
|
baseURL: ufo.joinURL(this.options.url, this.options.prefix),
|
|
@@ -202,7 +208,12 @@ class Strapi {
|
|
|
202
208
|
* @returns string
|
|
203
209
|
*/
|
|
204
210
|
getProviderAuthenticationUrl(provider) {
|
|
205
|
-
return ufo.joinURL(
|
|
211
|
+
return ufo.joinURL(
|
|
212
|
+
this.options.url,
|
|
213
|
+
this.options.prefix,
|
|
214
|
+
"connect",
|
|
215
|
+
provider
|
|
216
|
+
);
|
|
206
217
|
}
|
|
207
218
|
/**
|
|
208
219
|
* Authenticate user with the token present on the URL or in `params`
|
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,18 @@ 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
|
|
5
|
+
import ufo from 'ufo';
|
|
6
6
|
|
|
7
7
|
function isBrowser() {
|
|
8
8
|
return typeof window !== "undefined";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __publicField = (obj, key, value) => {
|
|
14
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
11
17
|
const defaults = {
|
|
12
18
|
url: "http://localhost:1337",
|
|
13
19
|
prefix: "/api",
|
|
@@ -19,9 +25,6 @@ const defaults = {
|
|
|
19
25
|
axiosOptions: {}
|
|
20
26
|
};
|
|
21
27
|
class Strapi {
|
|
22
|
-
axios;
|
|
23
|
-
options;
|
|
24
|
-
user = null;
|
|
25
28
|
/**
|
|
26
29
|
* Strapi SDK Constructor
|
|
27
30
|
*
|
|
@@ -32,14 +35,17 @@ class Strapi {
|
|
|
32
35
|
* @param {AxiosRequestConfig} options.axiosOptions? - The list of your Content type on your Strapi API
|
|
33
36
|
*/
|
|
34
37
|
constructor(options) {
|
|
38
|
+
__publicField(this, "axios");
|
|
39
|
+
__publicField(this, "options");
|
|
40
|
+
__publicField(this, "user", null);
|
|
35
41
|
const _options = defu(options || {}, defaults);
|
|
36
42
|
this.options = {
|
|
37
43
|
..._options,
|
|
38
|
-
url: cleanDoubleSlashes(_options
|
|
39
|
-
prefix: cleanDoubleSlashes(_options
|
|
44
|
+
url: ufo.cleanDoubleSlashes(_options == null ? void 0 : _options.url),
|
|
45
|
+
prefix: ufo.cleanDoubleSlashes(_options == null ? void 0 : _options.prefix)
|
|
40
46
|
};
|
|
41
47
|
this.axios = axios.create({
|
|
42
|
-
baseURL: joinURL(this.options.url, this.options.prefix),
|
|
48
|
+
baseURL: ufo.joinURL(this.options.url, this.options.prefix),
|
|
43
49
|
paramsSerializer: qs.stringify,
|
|
44
50
|
...this.options.axiosOptions
|
|
45
51
|
});
|
|
@@ -200,7 +206,12 @@ class Strapi {
|
|
|
200
206
|
* @returns string
|
|
201
207
|
*/
|
|
202
208
|
getProviderAuthenticationUrl(provider) {
|
|
203
|
-
return joinURL(
|
|
209
|
+
return ufo.joinURL(
|
|
210
|
+
this.options.url,
|
|
211
|
+
this.options.prefix,
|
|
212
|
+
"connect",
|
|
213
|
+
provider
|
|
214
|
+
);
|
|
204
215
|
}
|
|
205
216
|
/**
|
|
206
217
|
* Authenticate user with the token present on the URL or in `params`
|