@malevich-studio/strapi-sdk-typescript 1.0.16 → 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.mjs CHANGED
@@ -21226,9 +21226,9 @@ class Strapi {
21226
21226
  this.url = url;
21227
21227
  this.token = token;
21228
21228
  }
21229
- async request(endpoint, data = {}, params = {}) {
21229
+ async fetch(endpoint, data = {}, params = {}) {
21230
21230
  const queryString = params.method === 'GET' ? qs.stringify(data) : '';
21231
- return await this.baseRequest(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
21231
+ return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
21232
21232
  headers: {
21233
21233
  'Content-Type': 'application/json',
21234
21234
  },
@@ -21240,31 +21240,31 @@ class Strapi {
21240
21240
  }, params));
21241
21241
  }
21242
21242
  async getDocuments(endpoint, data, params = {}) {
21243
- return await this.request(endpoint, data, {
21243
+ return await this.fetch(endpoint, data, {
21244
21244
  method: 'GET',
21245
21245
  ...params,
21246
21246
  });
21247
21247
  }
21248
21248
  async getDocument(endpoint, data, params = {}) {
21249
- return await this.request(endpoint, data, {
21249
+ return await this.fetch(endpoint, data, {
21250
21250
  method: 'GET',
21251
21251
  ...params,
21252
21252
  });
21253
21253
  }
21254
21254
  async create(endpoint, data, params = {}) {
21255
- return await this.request(endpoint, data, {
21255
+ return await this.fetch(endpoint, data, {
21256
21256
  method: 'POST',
21257
21257
  ...params,
21258
21258
  });
21259
21259
  }
21260
21260
  async update(endpoint, id, data, params = {}) {
21261
- return await this.request(`${endpoint}/${id}`, data, {
21261
+ return await this.fetch(`${endpoint}/${id}`, data, {
21262
21262
  method: 'PUT',
21263
21263
  ...params,
21264
21264
  });
21265
21265
  }
21266
21266
  async delete(endpoint, id, params = {}) {
21267
- return await this.request(`${endpoint}/${id}`, {}, {
21267
+ return await this.fetch(`${endpoint}/${id}`, {}, {
21268
21268
  method: 'DELETE',
21269
21269
  ...params,
21270
21270
  });
@@ -21284,12 +21284,12 @@ class Strapi {
21284
21284
  return await this.uploadForm(form);
21285
21285
  }
21286
21286
  async uploadForm(form) {
21287
- return (await this.baseRequest('upload', {
21287
+ return (await this.baseFetch('upload', {
21288
21288
  method: 'POST',
21289
21289
  body: form,
21290
21290
  }));
21291
21291
  }
21292
- async baseRequest(endpoint, params = {}) {
21292
+ async baseFetch(endpoint, params = {}) {
21293
21293
  const response = await fetch(`${this.url}/api/${endpoint}`, _.merge({
21294
21294
  headers: {
21295
21295
  Authorization: `Bearer ${this.token}`,
@@ -21641,7 +21641,7 @@ class Dynamiczone extends BaseRelation {
21641
21641
  }
21642
21642
  getPopulates() {
21643
21643
  const types = this.attribute.components
21644
- .map(componentItem => `${getComponentName(componentItem)}Query`)
21644
+ .map(componentItem => `{ '${componentItem}': ${getComponentName(componentItem)}Query }`)
21645
21645
  .join(' & ');
21646
21646
  return [{
21647
21647
  name: this.name,
@@ -21791,8 +21791,8 @@ function generateMethodsCode(contentType) {
21791
21791
  * Main function to fetch Strapi (v5) data and generate the d.ts file
21792
21792
  */
21793
21793
  async function generateStrapiTypes(strapi) {
21794
- const contentTypes = (await strapi.request('content-type-builder/content-types')).data;
21795
- const components = (await strapi.request('content-type-builder/components')).data;
21794
+ const contentTypes = (await strapi.fetch('content-type-builder/content-types')).data;
21795
+ const components = (await strapi.fetch('content-type-builder/components')).data;
21796
21796
  const allInterfaces = [];
21797
21797
  const methods = [];
21798
21798
  for (const component of components) {