@malevich-studio/strapi-sdk-typescript 1.0.17 → 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/dist/cli.cjs +11 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +11 -11
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -21246,9 +21246,9 @@ class Strapi {
|
|
|
21246
21246
|
this.url = url;
|
|
21247
21247
|
this.token = token;
|
|
21248
21248
|
}
|
|
21249
|
-
async
|
|
21249
|
+
async fetch(endpoint, data = {}, params = {}) {
|
|
21250
21250
|
const queryString = params.method === 'GET' ? qs.stringify(data) : '';
|
|
21251
|
-
return await this.
|
|
21251
|
+
return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
|
|
21252
21252
|
headers: {
|
|
21253
21253
|
'Content-Type': 'application/json',
|
|
21254
21254
|
},
|
|
@@ -21260,31 +21260,31 @@ class Strapi {
|
|
|
21260
21260
|
}, params));
|
|
21261
21261
|
}
|
|
21262
21262
|
async getDocuments(endpoint, data, params = {}) {
|
|
21263
|
-
return await this.
|
|
21263
|
+
return await this.fetch(endpoint, data, {
|
|
21264
21264
|
method: 'GET',
|
|
21265
21265
|
...params,
|
|
21266
21266
|
});
|
|
21267
21267
|
}
|
|
21268
21268
|
async getDocument(endpoint, data, params = {}) {
|
|
21269
|
-
return await this.
|
|
21269
|
+
return await this.fetch(endpoint, data, {
|
|
21270
21270
|
method: 'GET',
|
|
21271
21271
|
...params,
|
|
21272
21272
|
});
|
|
21273
21273
|
}
|
|
21274
21274
|
async create(endpoint, data, params = {}) {
|
|
21275
|
-
return await this.
|
|
21275
|
+
return await this.fetch(endpoint, data, {
|
|
21276
21276
|
method: 'POST',
|
|
21277
21277
|
...params,
|
|
21278
21278
|
});
|
|
21279
21279
|
}
|
|
21280
21280
|
async update(endpoint, id, data, params = {}) {
|
|
21281
|
-
return await this.
|
|
21281
|
+
return await this.fetch(`${endpoint}/${id}`, data, {
|
|
21282
21282
|
method: 'PUT',
|
|
21283
21283
|
...params,
|
|
21284
21284
|
});
|
|
21285
21285
|
}
|
|
21286
21286
|
async delete(endpoint, id, params = {}) {
|
|
21287
|
-
return await this.
|
|
21287
|
+
return await this.fetch(`${endpoint}/${id}`, {}, {
|
|
21288
21288
|
method: 'DELETE',
|
|
21289
21289
|
...params,
|
|
21290
21290
|
});
|
|
@@ -21304,12 +21304,12 @@ class Strapi {
|
|
|
21304
21304
|
return await this.uploadForm(form);
|
|
21305
21305
|
}
|
|
21306
21306
|
async uploadForm(form) {
|
|
21307
|
-
return (await this.
|
|
21307
|
+
return (await this.baseFetch('upload', {
|
|
21308
21308
|
method: 'POST',
|
|
21309
21309
|
body: form,
|
|
21310
21310
|
}));
|
|
21311
21311
|
}
|
|
21312
|
-
async
|
|
21312
|
+
async baseFetch(endpoint, params = {}) {
|
|
21313
21313
|
const response = await fetch(`${this.url}/api/${endpoint}`, _.merge({
|
|
21314
21314
|
headers: {
|
|
21315
21315
|
Authorization: `Bearer ${this.token}`,
|
|
@@ -21811,8 +21811,8 @@ function generateMethodsCode(contentType) {
|
|
|
21811
21811
|
* Main function to fetch Strapi (v5) data and generate the d.ts file
|
|
21812
21812
|
*/
|
|
21813
21813
|
async function generateStrapiTypes(strapi) {
|
|
21814
|
-
const contentTypes = (await strapi.
|
|
21815
|
-
const components = (await strapi.
|
|
21814
|
+
const contentTypes = (await strapi.fetch('content-type-builder/content-types')).data;
|
|
21815
|
+
const components = (await strapi.fetch('content-type-builder/components')).data;
|
|
21816
21816
|
const allInterfaces = [];
|
|
21817
21817
|
const methods = [];
|
|
21818
21818
|
for (const component of components) {
|