strapi-sdk-js 2.3.5 → 3.0.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/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  ## 🚀 Features
17
17
 
18
- - Strapi v4 supports
18
+ - Strapi v5 supports
19
19
  - RESTful methods
20
20
  - Simplified request responses
21
21
  - Formatted error handling
package/dist/index.cjs CHANGED
@@ -264,14 +264,18 @@ class Strapi {
264
264
  * Get a specific {content-type} entry
265
265
  *
266
266
  * @param {string} contentType - Content type's name pluralized
267
- * @param {string|number} id - ID of entry
267
+ * @param {string} documentId - documentId of the entry
268
268
  * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
269
269
  * @returns Promise<StrapiResponse<T>>
270
270
  */
271
- findOne(contentType, id, params) {
272
- return this.request("get", `/${contentType}/${id}`, {
273
- params
274
- });
271
+ findOne(contentType, documentId, params) {
272
+ return this.request(
273
+ "get",
274
+ `/${contentType}/${documentId}`,
275
+ {
276
+ params
277
+ }
278
+ );
275
279
  }
276
280
  /**
277
281
  * Create a {content-type} entry
@@ -291,29 +295,30 @@ class Strapi {
291
295
  * Update a specific entry
292
296
  *
293
297
  * @param {string} contentType - Content type's name pluralized
294
- * @param {string|number} id - ID of entry to be updated
298
+ * @param {string} documentId - documentId of entry to be updated
295
299
  * @param {AxiosRequestConfig["data"]} data - New entry data
296
300
  * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
297
301
  * @returns Promise<StrapiResponse<T>>
298
302
  */
299
- update(contentType, id, data, params) {
300
- return this.request("put", `/${contentType}/${id}`, {
301
- data: { data },
302
- params
303
- });
303
+ update(contentType, documentId, data, params) {
304
+ return this.request(
305
+ "put",
306
+ `/${contentType}/${documentId}`,
307
+ {
308
+ data: { data },
309
+ params
310
+ }
311
+ );
304
312
  }
305
313
  /**
306
314
  * Delete en entry
307
315
  *
308
316
  * @param {string} contentType - Content type's name pluralized
309
- * @param {string|number} id - ID of entry to be deleted
310
- * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
311
- * @returns Promise<StrapiResponse<T>>
317
+ * @param {string} documentId - documentId of entry to be deleted
318
+ * @returns Promise<void>
312
319
  */
313
- delete(contentType, id, params) {
314
- return this.request("delete", `/${contentType}/${id}`, {
315
- params
316
- });
320
+ delete(contentType, documentId) {
321
+ return this.request("delete", `/${contentType}/${documentId}`);
317
322
  }
318
323
  /**
319
324
  * Refresh local data of the logged-in user
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ interface StrapiRequestParams extends StrapiBaseRequestParams {
39
39
  sort?: string | Array<string>;
40
40
  pagination?: PaginationByOffset | PaginationByPage;
41
41
  filters?: Record<string, unknown>;
42
- publicationState?: "live" | "preview";
42
+ state?: "draft" | "published";
43
43
  locale?: StrapiLocale;
44
44
  }
45
45
  interface StrapiError {
@@ -51,9 +51,25 @@ interface StrapiError {
51
51
  details: Record<string, unknown>;
52
52
  };
53
53
  }
54
+ interface StrapiSystemFields {
55
+ /** @deprecated use documentId instead */
56
+ id: number | string;
57
+ documentId: string;
58
+ locale?: string;
59
+ }
60
+ type StrapiResponseData<T> = T extends undefined | null ? StrapiSystemFields : T extends object ? T extends Array<infer U> ? Array<StrapiResponseData<U>> : T extends Record<string, unknown> ? {
61
+ [K in keyof T]: StrapiResponseData<T[K]>;
62
+ } & StrapiSystemFields : T : T;
54
63
  interface StrapiResponse<T> {
55
- data: T;
56
- meta: Record<string, unknown>;
64
+ data: StrapiResponseData<T> & StrapiSystemFields;
65
+ meta: StrapiResponseMeta;
66
+ }
67
+ interface StrapiResponseMetaPagination {
68
+ page: number;
69
+ pageSize: number;
70
+ }
71
+ interface StrapiResponseMeta extends Record<string, unknown> {
72
+ pagination?: StrapiResponseMetaPagination;
57
73
  }
58
74
  interface StrapiAuthenticationResponse {
59
75
  user: Record<string, unknown>;
@@ -193,16 +209,16 @@ declare class Strapi {
193
209
  * @param {StrapiRequestParams} params? - Query parameters
194
210
  * @returns Promise<StrapiResponse<T>>
195
211
  */
196
- find<T>(contentType: string, params?: StrapiRequestParams): Promise<StrapiResponse<T>>;
212
+ find<T>(contentType: string, params?: StrapiRequestParams): Promise<StrapiResponse<T[]>>;
197
213
  /**
198
214
  * Get a specific {content-type} entry
199
215
  *
200
216
  * @param {string} contentType - Content type's name pluralized
201
- * @param {string|number} id - ID of entry
217
+ * @param {string} documentId - documentId of the entry
202
218
  * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
203
219
  * @returns Promise<StrapiResponse<T>>
204
220
  */
205
- findOne<T>(contentType: string, id: string | number, params?: StrapiBaseRequestParams): Promise<StrapiResponse<T>>;
221
+ findOne<T>(contentType: string, documentId: string, params?: StrapiBaseRequestParams): Promise<StrapiResponse<T>>;
206
222
  /**
207
223
  * Create a {content-type} entry
208
224
  *
@@ -216,21 +232,20 @@ declare class Strapi {
216
232
  * Update a specific entry
217
233
  *
218
234
  * @param {string} contentType - Content type's name pluralized
219
- * @param {string|number} id - ID of entry to be updated
235
+ * @param {string} documentId - documentId of entry to be updated
220
236
  * @param {AxiosRequestConfig["data"]} data - New entry data
221
237
  * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
222
238
  * @returns Promise<StrapiResponse<T>>
223
239
  */
224
- update<T>(contentType: string, id: string | number, data: AxiosRequestConfig["data"], params?: StrapiBaseRequestParams): Promise<StrapiResponse<T>>;
240
+ update<T>(contentType: string, documentId: string, data: AxiosRequestConfig["data"], params?: StrapiBaseRequestParams): Promise<StrapiResponse<T>>;
225
241
  /**
226
242
  * Delete en entry
227
243
  *
228
244
  * @param {string} contentType - Content type's name pluralized
229
- * @param {string|number} id - ID of entry to be deleted
230
- * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
231
- * @returns Promise<StrapiResponse<T>>
245
+ * @param {string} documentId - documentId of entry to be deleted
246
+ * @returns Promise<void>
232
247
  */
233
- delete<T>(contentType: string, id: string | number, params?: StrapiBaseRequestParams): Promise<StrapiResponse<T>>;
248
+ delete(contentType: string, documentId: string): Promise<void>;
234
249
  /**
235
250
  * Refresh local data of the logged-in user
236
251
  *
package/dist/index.mjs CHANGED
@@ -262,14 +262,18 @@ class Strapi {
262
262
  * Get a specific {content-type} entry
263
263
  *
264
264
  * @param {string} contentType - Content type's name pluralized
265
- * @param {string|number} id - ID of entry
265
+ * @param {string} documentId - documentId of the entry
266
266
  * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
267
267
  * @returns Promise<StrapiResponse<T>>
268
268
  */
269
- findOne(contentType, id, params) {
270
- return this.request("get", `/${contentType}/${id}`, {
271
- params
272
- });
269
+ findOne(contentType, documentId, params) {
270
+ return this.request(
271
+ "get",
272
+ `/${contentType}/${documentId}`,
273
+ {
274
+ params
275
+ }
276
+ );
273
277
  }
274
278
  /**
275
279
  * Create a {content-type} entry
@@ -289,29 +293,30 @@ class Strapi {
289
293
  * Update a specific entry
290
294
  *
291
295
  * @param {string} contentType - Content type's name pluralized
292
- * @param {string|number} id - ID of entry to be updated
296
+ * @param {string} documentId - documentId of entry to be updated
293
297
  * @param {AxiosRequestConfig["data"]} data - New entry data
294
298
  * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
295
299
  * @returns Promise<StrapiResponse<T>>
296
300
  */
297
- update(contentType, id, data, params) {
298
- return this.request("put", `/${contentType}/${id}`, {
299
- data: { data },
300
- params
301
- });
301
+ update(contentType, documentId, data, params) {
302
+ return this.request(
303
+ "put",
304
+ `/${contentType}/${documentId}`,
305
+ {
306
+ data: { data },
307
+ params
308
+ }
309
+ );
302
310
  }
303
311
  /**
304
312
  * Delete en entry
305
313
  *
306
314
  * @param {string} contentType - Content type's name pluralized
307
- * @param {string|number} id - ID of entry to be deleted
308
- * @param {StrapiBaseRequestParams} params? - Fields selection & Relations population
309
- * @returns Promise<StrapiResponse<T>>
315
+ * @param {string} documentId - documentId of entry to be deleted
316
+ * @returns Promise<void>
310
317
  */
311
- delete(contentType, id, params) {
312
- return this.request("delete", `/${contentType}/${id}`, {
313
- params
314
- });
318
+ delete(contentType, documentId) {
319
+ return this.request("delete", `/${contentType}/${documentId}`);
315
320
  }
316
321
  /**
317
322
  * Refresh local data of the logged-in user
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-sdk-js",
3
- "version": "2.3.5",
3
+ "version": "3.0.1",
4
4
  "description": "📦 Javascript SDK for your Strapi API",
5
5
  "keywords": [
6
6
  "strapi",
@@ -50,7 +50,7 @@
50
50
  "dist/"
51
51
  ],
52
52
  "engines": {
53
- "node": ">=16"
53
+ "node": ">=20"
54
54
  },
55
55
  "scripts": {
56
56
  "start": "rollup -c --watch",
@@ -73,9 +73,6 @@
73
73
  "path": "./node_modules/cz-conventional-changelog"
74
74
  }
75
75
  },
76
- "publishConfig": {
77
- "registry": "https://registry.npmjs.org"
78
- },
79
76
  "dependencies": {
80
77
  "@types/js-cookie": "^3.0.0",
81
78
  "@types/qs": "^6.9.6",
@@ -86,24 +83,24 @@
86
83
  "ufo": "^1.2.0"
87
84
  },
88
85
  "devDependencies": {
89
- "@commitlint/cli": "17.6.7",
90
- "@commitlint/config-conventional": "17.6.7",
86
+ "@commitlint/cli": "17.8.1",
87
+ "@commitlint/config-conventional": "17.8.1",
91
88
  "@release-it/conventional-changelog": "4.3.0",
92
89
  "@rollup/plugin-commonjs": "^25.0.3",
93
90
  "@rollup/plugin-json": "^6.0.0",
94
91
  "@rollup/plugin-node-resolve": "^15.1.0",
95
92
  "@types/jest": "27.5.2",
96
- "@types/sinon": "10.0.16",
93
+ "@types/sinon": "10.0.20",
97
94
  "@typescript-eslint/eslint-plugin": "5.62.0",
98
95
  "@typescript-eslint/parser": "5.62.0",
99
- "commitizen": "4.3.0",
96
+ "commitizen": "4.3.1",
100
97
  "cz-conventional-changelog": "3.3.0",
101
- "dotenv-cli": "7.2.1",
98
+ "dotenv-cli": "7.4.4",
102
99
  "esbuild": "^0.18.19",
103
- "eslint": "8.46.0",
100
+ "eslint": "8.57.1",
104
101
  "husky": "8.0.3",
105
102
  "jest": "27.5.1",
106
- "lint-staged": "13.2.3",
103
+ "lint-staged": "13.3.0",
107
104
  "npm-run-all": "4.1.5",
108
105
  "release-it": "14.14.3",
109
106
  "rollup": "^3.27.2",