strapi-sdk-js 1.0.2 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [1.1.0](https://github.com/Stun3R/strapi-sdk-js/compare/v1.0.2...v1.1.0) (2021-10-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add axioserror type on error ([1140bbb](https://github.com/Stun3R/strapi-sdk-js/commit/1140bbb990c37e492aa8d457a1e65ff5a0ac24ed))
7
+ * **deps:** update dependency @types/js-cookie to v3 ([88483aa](https://github.com/Stun3R/strapi-sdk-js/commit/88483aa0ff841c440716bbe1014ff8a6ef58c27f))
8
+ * **deps:** update dependency axios to ^0.23.0 ([854e84e](https://github.com/Stun3R/strapi-sdk-js/commit/854e84e02cdb818a69dddfecb8c1530f791609c4))
9
+ * missing comma after dependencies ([6efe03b](https://github.com/Stun3R/strapi-sdk-js/commit/6efe03b1713c5df97a077d3c5db43022d3fcc3f6))
10
+ * **tests:** switch response type to follow latest change ([362b5d9](https://github.com/Stun3R/strapi-sdk-js/commit/362b5d911ffb9fbeb37de7678dd60b97c7dbf2f6))
11
+
12
+
13
+ ### Code Refactoring
14
+
15
+ * drop of graphql methods support ([eebd7a3](https://github.com/Stun3R/strapi-sdk-js/commit/eebd7a34ddbce216ba0e8b3f5a3f95c0a0a5add5))
16
+
17
+
18
+ ### BREAKING CHANGES
19
+
20
+ * GraphQL is no longer supported in v1.1.0
21
+
1
22
  ## [1.0.2](https://github.com/Stun3R/strapi-sdk-js/compare/v1.0.1...v1.0.2) (2021-08-30)
2
23
 
3
24
 
package/dist/index.d.ts CHANGED
@@ -183,13 +183,6 @@ declare class Strapi {
183
183
  * @returns Promise<T>
184
184
  */
185
185
  delete<T>(contentType: string, id: string | number): Promise<T>;
186
- /**
187
- * Fetch Strapi API through graphQL
188
- *
189
- * @param {AxiosRequestConfig["data"]} query - GraphQL Query
190
- * @returns Promise<T>
191
- */
192
- graphql<T>(query: AxiosRequestConfig["data"]): Promise<T>;
193
186
  /**
194
187
  * Define local data of the logged-in user
195
188
  *
package/dist/index.es.js CHANGED
@@ -42,14 +42,15 @@ class Strapi {
42
42
  });
43
43
  return response.data;
44
44
  } catch (error) {
45
- if (!error.response) {
45
+ const e = error;
46
+ if (!e.response) {
46
47
  throw {
47
48
  status: 500,
48
- message: error.message,
49
+ message: e.message,
49
50
  original: error
50
51
  };
51
52
  } else {
52
- const { status, data } = error.response;
53
+ const { status, data } = e.response;
53
54
  let message;
54
55
  if (Array.isArray(data.message)) {
55
56
  if (data.message[0].hasOwnProperty("messages")) {
@@ -145,13 +146,6 @@ class Strapi {
145
146
  delete(contentType, id) {
146
147
  return this.request("delete", `/${contentType}/${id}`);
147
148
  }
148
- async graphql(query) {
149
- const response = await this.request("post", "/graphql", {
150
- data: query
151
- });
152
- response.data = Object.values(response.data)[0];
153
- return response.data;
154
- }
155
149
  setUser(user) {
156
150
  this._user = user;
157
151
  }
package/dist/index.js CHANGED
@@ -28,10 +28,10 @@ const defaults = {
28
28
  class Strapi {
29
29
  constructor(options) {
30
30
  this._user = null;
31
- this.options = defu__default['default'](options || {}, defaults);
32
- this.axios = axios__default['default'].create({
31
+ this.options = defu__default["default"](options || {}, defaults);
32
+ this.axios = axios__default["default"].create({
33
33
  baseURL: this.options.url,
34
- paramsSerializer: qs__default['default'].stringify,
34
+ paramsSerializer: qs__default["default"].stringify,
35
35
  ...this.options.axiosOptions
36
36
  });
37
37
  this.syncToken();
@@ -51,14 +51,15 @@ class Strapi {
51
51
  });
52
52
  return response.data;
53
53
  } catch (error) {
54
- if (!error.response) {
54
+ const e = error;
55
+ if (!e.response) {
55
56
  throw {
56
57
  status: 500,
57
- message: error.message,
58
+ message: e.message,
58
59
  original: error
59
60
  };
60
61
  } else {
61
- const { status, data } = error.response;
62
+ const { status, data } = e.response;
62
63
  let message;
63
64
  if (Array.isArray(data.message)) {
64
65
  if (data.message[0].hasOwnProperty("messages")) {
@@ -119,7 +120,7 @@ class Strapi {
119
120
  async authenticateProvider(provider, access_token) {
120
121
  this.removeToken();
121
122
  if (isBrowser()) {
122
- const params = qs__default['default'].parse(window.location.search, {
123
+ const params = qs__default["default"].parse(window.location.search, {
123
124
  ignoreQueryPrefix: true
124
125
  });
125
126
  if (params.access_token)
@@ -154,13 +155,6 @@ class Strapi {
154
155
  delete(contentType, id) {
155
156
  return this.request("delete", `/${contentType}/${id}`);
156
157
  }
157
- async graphql(query) {
158
- const response = await this.request("post", "/graphql", {
159
- data: query
160
- });
161
- response.data = Object.values(response.data)[0];
162
- return response.data;
163
- }
164
158
  setUser(user) {
165
159
  this._user = user;
166
160
  }
@@ -176,7 +170,7 @@ class Strapi {
176
170
  syncToken() {
177
171
  const { useLocalStorage, key } = this.options.store;
178
172
  if (isBrowser()) {
179
- const token = useLocalStorage ? window.localStorage.getItem(key) : Cookies__default['default'].get(key);
173
+ const token = useLocalStorage ? window.localStorage.getItem(key) : Cookies__default["default"].get(key);
180
174
  if (token) {
181
175
  this.axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
182
176
  }
@@ -186,14 +180,14 @@ class Strapi {
186
180
  const { useLocalStorage, key, cookieOptions } = this.options.store;
187
181
  this.axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
188
182
  if (isBrowser()) {
189
- useLocalStorage ? window.localStorage.setItem(key, token) : Cookies__default['default'].set(key, token, cookieOptions);
183
+ useLocalStorage ? window.localStorage.setItem(key, token) : Cookies__default["default"].set(key, token, cookieOptions);
190
184
  }
191
185
  }
192
186
  removeToken() {
193
187
  const { useLocalStorage, key } = this.options.store;
194
188
  delete this.axios.defaults.headers.common["Authorization"];
195
189
  if (isBrowser()) {
196
- useLocalStorage ? window.localStorage.removeItem(key) : Cookies__default['default'].remove(key);
190
+ useLocalStorage ? window.localStorage.removeItem(key) : Cookies__default["default"].remove(key);
197
191
  }
198
192
  }
199
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-sdk-js",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "📦 Javascript SDK for your Strapi API",
5
5
  "keywords": [
6
6
  "strapi",
@@ -12,7 +12,6 @@
12
12
  "http",
13
13
  "rest",
14
14
  "restful",
15
- "graphqL",
16
15
  "javascript"
17
16
  ],
18
17
  "homepage": "https://strapi-sdk-js.netlify.app",
@@ -70,33 +69,33 @@
70
69
  }
71
70
  },
72
71
  "dependencies": {
73
- "@types/js-cookie": "^2.2.6",
72
+ "@types/js-cookie": "^3.0.0",
74
73
  "@types/qs": "^6.9.6",
75
- "axios": "^0.21.1",
74
+ "axios": "^0.23.0",
76
75
  "defu": "^5.0.0",
77
76
  "js-cookie": "^3.0.0",
78
77
  "qs": "^6.10.1"
79
78
  },
80
79
  "devDependencies": {
81
- "@commitlint/cli": "13.1.0",
82
- "@commitlint/config-conventional": "13.1.0",
80
+ "@commitlint/cli": "13.2.1",
81
+ "@commitlint/config-conventional": "13.2.0",
83
82
  "@release-it/conventional-changelog": "3.3.0",
84
- "@types/jest": "27.0.1",
85
- "@types/sinon": "10.0.2",
86
- "@typescript-eslint/eslint-plugin": "4.30.0",
87
- "@typescript-eslint/parser": "4.30.0",
83
+ "@types/jest": "27.0.2",
84
+ "@types/sinon": "10.0.4",
85
+ "@typescript-eslint/eslint-plugin": "5.1.0",
86
+ "@typescript-eslint/parser": "5.1.0",
88
87
  "commitizen": "4.2.4",
89
88
  "cz-conventional-changelog": "3.3.0",
90
89
  "dotenv-cli": "4.0.0",
91
- "eslint": "7.32.0",
90
+ "eslint": "8.0.1",
92
91
  "husky": "7.0.2",
93
- "jest": "27.1.0",
94
- "lint-staged": "11.1.2",
92
+ "jest": "27.3.1",
93
+ "lint-staged": "11.2.3",
95
94
  "npm-run-all": "4.1.5",
96
- "release-it": "14.11.5",
95
+ "release-it": "14.11.6",
97
96
  "sinon": "11.1.2",
98
97
  "siroc": "0.16.0",
99
- "ts-jest": "27.0.5",
100
- "typescript": "4.3.5"
98
+ "ts-jest": "27.0.7",
99
+ "typescript": "4.4.4"
101
100
  }
102
101
  }