@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.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}`,
@@ -21629,13 +21629,13 @@ class Dynamiczone extends BaseRelation {
21629
21629
  }
21630
21630
  getType() {
21631
21631
  const types = this.attribute.components
21632
- .map(componentItem => getComponentName(componentItem))
21632
+ .map(componentItem => `DynamiczoneComponent<'${componentItem}', ${getComponentName(componentItem)}>`)
21633
21633
  .join(' | ');
21634
21634
  return `(${types})[]`;
21635
21635
  }
21636
21636
  getInputType() {
21637
21637
  const types = this.attribute.components
21638
- .map(componentItem => `DynamiczoneInput<'${componentItem}', ${getComponentName(componentItem)}Input>`)
21638
+ .map(componentItem => `DynamiczoneComponent<'${componentItem}', ${getComponentName(componentItem)}Input>`)
21639
21639
  .join(' | ');
21640
21640
  return `(${types})[]`;
21641
21641
  }
@@ -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) {
@@ -21833,7 +21833,7 @@ async function generateStrapiTypes(strapi) {
21833
21833
  allInterfaces.push(generateInputTypeCode(modelName, attributes));
21834
21834
  }
21835
21835
  const output = [
21836
- 'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput, DynamiczonePopulate, DynamiczoneInput} from "@malevich-studio/strapi-sdk-typescript";',
21836
+ 'import {Strapi as StrapiBase, Query, Filters, FilterValue, RelationInput, DynamiczonePopulate, DynamiczoneComponent} from "@malevich-studio/strapi-sdk-typescript";',
21837
21837
  'import {BlocksContent} from "@strapi/blocks-react-renderer";',
21838
21838
  '',
21839
21839
  'export default class Strapi extends StrapiBase {',