strapi-sdk-js 2.3.0 → 2.3.2-rc.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 +32 -7
- package/dist/index.mjs +14 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,35 @@ var qs = require('qs');
|
|
|
6
6
|
var Cookies = require('js-cookie');
|
|
7
7
|
var ufo = require('ufo');
|
|
8
8
|
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var ufo__namespace = /*#__PURE__*/_interopNamespaceDefault(ufo);
|
|
27
|
+
|
|
9
28
|
function isBrowser() {
|
|
10
29
|
return typeof window !== "undefined";
|
|
11
30
|
}
|
|
12
31
|
|
|
32
|
+
var __defProp = Object.defineProperty;
|
|
33
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
34
|
+
var __publicField = (obj, key, value) => {
|
|
35
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
13
38
|
const defaults = {
|
|
14
39
|
url: "http://localhost:1337",
|
|
15
40
|
prefix: "/api",
|
|
@@ -21,9 +46,6 @@ const defaults = {
|
|
|
21
46
|
axiosOptions: {}
|
|
22
47
|
};
|
|
23
48
|
class Strapi {
|
|
24
|
-
axios;
|
|
25
|
-
options;
|
|
26
|
-
user = null;
|
|
27
49
|
/**
|
|
28
50
|
* Strapi SDK Constructor
|
|
29
51
|
*
|
|
@@ -34,14 +56,17 @@ class Strapi {
|
|
|
34
56
|
* @param {AxiosRequestConfig} options.axiosOptions? - The list of your Content type on your Strapi API
|
|
35
57
|
*/
|
|
36
58
|
constructor(options) {
|
|
59
|
+
__publicField(this, "axios");
|
|
60
|
+
__publicField(this, "options");
|
|
61
|
+
__publicField(this, "user", null);
|
|
37
62
|
const _options = defu(options || {}, defaults);
|
|
38
63
|
this.options = {
|
|
39
64
|
..._options,
|
|
40
|
-
url:
|
|
41
|
-
prefix:
|
|
65
|
+
url: ufo__namespace.cleanDoubleSlashes(_options == null ? void 0 : _options.url),
|
|
66
|
+
prefix: ufo__namespace.cleanDoubleSlashes(_options == null ? void 0 : _options.prefix)
|
|
42
67
|
};
|
|
43
68
|
this.axios = axios.create({
|
|
44
|
-
baseURL:
|
|
69
|
+
baseURL: ufo__namespace.joinURL(this.options.url, this.options.prefix),
|
|
45
70
|
paramsSerializer: qs.stringify,
|
|
46
71
|
...this.options.axiosOptions
|
|
47
72
|
});
|
|
@@ -202,7 +227,7 @@ class Strapi {
|
|
|
202
227
|
* @returns string
|
|
203
228
|
*/
|
|
204
229
|
getProviderAuthenticationUrl(provider) {
|
|
205
|
-
return
|
|
230
|
+
return ufo__namespace.joinURL(this.options.url, this.options.prefix, "connect", provider);
|
|
206
231
|
}
|
|
207
232
|
/**
|
|
208
233
|
* 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 * as 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,7 @@ class Strapi {
|
|
|
200
206
|
* @returns string
|
|
201
207
|
*/
|
|
202
208
|
getProviderAuthenticationUrl(provider) {
|
|
203
|
-
return joinURL(this.options.url, this.options.prefix, "connect", provider);
|
|
209
|
+
return ufo.joinURL(this.options.url, this.options.prefix, "connect", provider);
|
|
204
210
|
}
|
|
205
211
|
/**
|
|
206
212
|
* Authenticate user with the token present on the URL or in `params`
|