@malevich-studio/strapi-sdk-typescript 1.1.2 → 1.2.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
@@ -13,7 +13,7 @@ type RelationInput = {
13
13
  set?: RelationData[];
14
14
  } | RelationData[];
15
15
 
16
- type Response<T> = {
16
+ type SuccessResponse<T> = {
17
17
  data: T;
18
18
  meta: {
19
19
  pagination: {
@@ -28,6 +28,18 @@ type Response<T> = {
28
28
  });
29
29
  };
30
30
  };
31
+ type ErrorResponse = {
32
+ data: null;
33
+ "error": {
34
+ "status": string;
35
+ "name": 'ApplicationError' | 'ValidationError';
36
+ "message": string;
37
+ "details": {
38
+ [key: string]: any;
39
+ };
40
+ };
41
+ };
42
+ type Response<T> = SuccessResponse<T> | ErrorResponse;
31
43
  type File = {
32
44
  id?: number;
33
45
  documentId?: string;
@@ -128,8 +140,8 @@ type DynamiczonePopulate<T> = {
128
140
  };
129
141
  declare class Strapi {
130
142
  private readonly url;
131
- private readonly token;
132
- constructor(url: string, token: string);
143
+ private readonly token?;
144
+ constructor(url: string, token?: string | undefined);
133
145
  fetch<T>(endpoint: string, data?: object | FormData, params?: RequestInit): Promise<Response<T>>;
134
146
  getLocales(params: RequestInit): Promise<Locale[]>;
135
147
  getDocuments<T, Q extends object>(endpoint: string, data?: Q, params?: RequestInit): Promise<Response<T[]>>;
@@ -137,15 +149,6 @@ declare class Strapi {
137
149
  create<T, Q extends object>(endpoint: string, data: Q, params?: RequestInit): Promise<Response<T>>;
138
150
  update<T, Q extends object>(endpoint: string, id: string, data: Q, params?: RequestInit): Promise<Response<T>>;
139
151
  delete<T>(endpoint: string, id: string, params?: RequestInit): Promise<Response<T>>;
140
- /**
141
- * For Node.js
142
- *
143
- * @param files list of files names which will be uploaded, example: ['/app/data/cover.js']
144
- */
145
- upload(files: {
146
- path: string;
147
- filename?: string;
148
- }[]): Promise<File[]>;
149
152
  uploadForm(form: FormData): Promise<File[]>;
150
153
  private baseFetch;
151
154
  }