simple-strapi 1.0.0-alpha.12 → 1.0.0-alpha.14

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/client.d.ts CHANGED
@@ -107,18 +107,27 @@ declare class Client {
107
107
  data: any[];
108
108
  meta: any;
109
109
  }>;
110
- update<S extends Schema>(pluralID: string, documentId: string, payload: Partial<InferSchema<S>>, options?: EntityRequest<{
110
+ /**
111
+ *
112
+ * WRITE ACTIONS
113
+ *
114
+ */
115
+ update<S extends Schema>(pluralID: string, documentId: string, payload: any, options?: EntityRequest<{
111
116
  schema?: S;
112
117
  }>): Promise<{
113
118
  data: InferSchemaWithDefaults<S>;
114
119
  meta: any;
115
120
  }>;
116
- create<S extends Schema>(pluralID: string, payload: Partial<InferSchema<S>>, options?: EntityRequest<{
121
+ create<S extends Schema>(pluralID: string, payload: any, options?: EntityRequest<{
117
122
  schema?: S;
118
123
  }>): Promise<{
119
124
  data: InferSchemaWithDefaults<S>;
120
125
  meta: any;
121
126
  }>;
122
127
  private writeRequest;
128
+ /**
129
+ * Elimina un'entità specifica tramite il suo documentId.
130
+ */
131
+ delete(pluralID: string, documentId: string, options?: EntityRequest): Promise<unknown>;
123
132
  }
124
133
  export default Client;
package/dist/client.js CHANGED
@@ -270,6 +270,11 @@ class Client {
270
270
  throw ensureSimpleException(exception);
271
271
  }
272
272
  }
273
+ /**
274
+ *
275
+ * WRITE ACTIONS
276
+ *
277
+ */
273
278
  async update(pluralID, documentId, payload, options = {}) {
274
279
  const path = join(pluralID, documentId);
275
280
  return this.writeRequest("PUT", path, payload, options);
@@ -330,6 +335,41 @@ class Client {
330
335
  throw ensureSimpleException(exception);
331
336
  }
332
337
  }
338
+ /**
339
+ * Elimina un'entità specifica tramite il suo documentId.
340
+ */
341
+ async delete(pluralID, documentId, options = {}) {
342
+ try {
343
+ const { params = {}, headers = {} } = options;
344
+ const requestURL = Client.getRequestURL({
345
+ origin: this.origin,
346
+ pathname: join(this.pathname, pluralID, documentId),
347
+ params,
348
+ });
349
+ const response = await fetch(requestURL, {
350
+ method: "DELETE",
351
+ headers: {
352
+ ...this.getAuthorizedHeaders(),
353
+ ...headers,
354
+ },
355
+ });
356
+ if (!response.ok) {
357
+ throw createSimpleException({
358
+ code: response.status,
359
+ message: response.statusText,
360
+ type: "error",
361
+ source: "strapi-utils/client.ts",
362
+ });
363
+ }
364
+ const { data, meta } = z
365
+ .object({ data: z.any(), meta: z.any() })
366
+ .parse(await response.json());
367
+ return { data, meta };
368
+ }
369
+ catch (exception) {
370
+ throw ensureSimpleException(exception);
371
+ }
372
+ }
333
373
  }
334
374
  // #region STATIC
335
375
  Client.headers = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-strapi",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",