@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/index.d.ts CHANGED
@@ -108,7 +108,7 @@ type Query<Fields, Sort, Filters, Populate> = {
108
108
  limit?: number;
109
109
  });
110
110
  };
111
- type DynamiczoneInput<ComponentName, ComponentInputType> = ComponentInputType & {
111
+ type DynamiczoneComponent<ComponentName, ComponentInputType> = ComponentInputType & {
112
112
  __component: ComponentName;
113
113
  };
114
114
  type DynamiczonePopulate<T> = {
@@ -120,7 +120,7 @@ declare class Strapi {
120
120
  private readonly url;
121
121
  private readonly token;
122
122
  constructor(url: string, token: string);
123
- request<T>(endpoint: string, data?: object | FormData, params?: RequestInit): Promise<Response<T>>;
123
+ fetch<T>(endpoint: string, data?: object | FormData, params?: RequestInit): Promise<Response<T>>;
124
124
  getDocuments<T, Q extends object>(endpoint: string, data?: Q, params?: RequestInit): Promise<Response<T[]>>;
125
125
  getDocument<T, Q extends object>(endpoint: string, data?: Q, params?: RequestInit): Promise<Response<T>>;
126
126
  create<T, Q extends object>(endpoint: string, data: Q, params?: RequestInit): Promise<Response<T>>;
@@ -136,7 +136,7 @@ declare class Strapi {
136
136
  filename?: string;
137
137
  }[]): Promise<File[]>;
138
138
  uploadForm(form: FormData): Promise<File[]>;
139
- private baseRequest;
139
+ private baseFetch;
140
140
  }
141
141
 
142
- export { type DynamiczoneInput, type DynamiczonePopulate, type File, type FilterValue, type Filters, type Folder, type Query, type RelationInput, Strapi };
142
+ export { type DynamiczoneComponent, type DynamiczonePopulate, type File, type FilterValue, type Filters, type Folder, type Query, type RelationInput, Strapi };
package/dist/index.mjs CHANGED
@@ -21219,9 +21219,9 @@ class Strapi {
21219
21219
  this.url = url;
21220
21220
  this.token = token;
21221
21221
  }
21222
- async request(endpoint, data = {}, params = {}) {
21222
+ async fetch(endpoint, data = {}, params = {}) {
21223
21223
  const queryString = params.method === 'GET' ? qs.stringify(data) : '';
21224
- return await this.baseRequest(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
21224
+ return await this.baseFetch(queryString ? `${endpoint}?${queryString}` : endpoint, _.merge({
21225
21225
  headers: {
21226
21226
  'Content-Type': 'application/json',
21227
21227
  },
@@ -21233,31 +21233,31 @@ class Strapi {
21233
21233
  }, params));
21234
21234
  }
21235
21235
  async getDocuments(endpoint, data, params = {}) {
21236
- return await this.request(endpoint, data, {
21236
+ return await this.fetch(endpoint, data, {
21237
21237
  method: 'GET',
21238
21238
  ...params,
21239
21239
  });
21240
21240
  }
21241
21241
  async getDocument(endpoint, data, params = {}) {
21242
- return await this.request(endpoint, data, {
21242
+ return await this.fetch(endpoint, data, {
21243
21243
  method: 'GET',
21244
21244
  ...params,
21245
21245
  });
21246
21246
  }
21247
21247
  async create(endpoint, data, params = {}) {
21248
- return await this.request(endpoint, data, {
21248
+ return await this.fetch(endpoint, data, {
21249
21249
  method: 'POST',
21250
21250
  ...params,
21251
21251
  });
21252
21252
  }
21253
21253
  async update(endpoint, id, data, params = {}) {
21254
- return await this.request(`${endpoint}/${id}`, data, {
21254
+ return await this.fetch(`${endpoint}/${id}`, data, {
21255
21255
  method: 'PUT',
21256
21256
  ...params,
21257
21257
  });
21258
21258
  }
21259
21259
  async delete(endpoint, id, params = {}) {
21260
- return await this.request(`${endpoint}/${id}`, {}, {
21260
+ return await this.fetch(`${endpoint}/${id}`, {}, {
21261
21261
  method: 'DELETE',
21262
21262
  ...params,
21263
21263
  });
@@ -21277,12 +21277,12 @@ class Strapi {
21277
21277
  return await this.uploadForm(form);
21278
21278
  }
21279
21279
  async uploadForm(form) {
21280
- return (await this.baseRequest('upload', {
21280
+ return (await this.baseFetch('upload', {
21281
21281
  method: 'POST',
21282
21282
  body: form,
21283
21283
  }));
21284
21284
  }
21285
- async baseRequest(endpoint, params = {}) {
21285
+ async baseFetch(endpoint, params = {}) {
21286
21286
  const response = await fetch(`${this.url}/api/${endpoint}`, _.merge({
21287
21287
  headers: {
21288
21288
  Authorization: `Bearer ${this.token}`,