@malevich-studio/strapi-sdk-typescript 1.0.17 → 1.1.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/dist/cli.cjs CHANGED
@@ -21246,9 +21246,9 @@ class Strapi {
21246
21246
  this.url = url;
21247
21247
  this.token = token;
21248
21248
  }
21249
- async request(endpoint, data = {}, params = {}) {
21249
+ async fetch(endpoint, data = {}, params = {}) {
21250
21250
  const queryString = params.method === 'GET' ? qs.stringify(data) : '';
21251
- return await this.baseRequest(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
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.request(endpoint, data, {
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.request(endpoint, data, {
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.request(endpoint, data, {
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.request(`${endpoint}/${id}`, data, {
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.request(`${endpoint}/${id}`, {}, {
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.baseRequest('upload', {
21307
+ return (await this.baseFetch('upload', {
21308
21308
  method: 'POST',
21309
21309
  body: form,
21310
21310
  }));
21311
21311
  }
21312
- async baseRequest(endpoint, params = {}) {
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}`,
@@ -21649,13 +21649,13 @@ class Dynamiczone extends BaseRelation {
21649
21649
  }
21650
21650
  getType() {
21651
21651
  const types = this.attribute.components
21652
- .map(componentItem => getComponentName(componentItem))
21652
+ .map(componentItem => `DynamiczoneComponent<'${componentItem}', ${getComponentName(componentItem)}>`)
21653
21653
  .join(' | ');
21654
21654
  return `(${types})[]`;
21655
21655
  }
21656
21656
  getInputType() {
21657
21657
  const types = this.attribute.components
21658
- .map(componentItem => `DynamiczoneInput<'${componentItem}', ${getComponentName(componentItem)}Input>`)
21658
+ .map(componentItem => `DynamiczoneComponent<'${componentItem}', ${getComponentName(componentItem)}Input>`)
21659
21659
  .join(' | ');
21660
21660
  return `(${types})[]`;
21661
21661
  }
@@ -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.request('content-type-builder/content-types')).data;
21815
- const components = (await strapi.request('content-type-builder/components')).data;
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) {
@@ -21853,7 +21853,7 @@ async function generateStrapiTypes(strapi) {
21853
21853
  allInterfaces.push(generateInputTypeCode(modelName, attributes));
21854
21854
  }
21855
21855
  const output = [
21856
- 'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput, DynamiczonePopulate, DynamiczoneInput} from "@malevich-studio/strapi-sdk-typescript";',
21856
+ 'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput, DynamiczonePopulate, DynamiczoneComponent} from "@malevich-studio/strapi-sdk-typescript";',
21857
21857
  'import {BlocksContent} from "@strapi/blocks-react-renderer";',
21858
21858
  '',
21859
21859
  'export default class Strapi extends StrapiBase {',