simple-strapi 1.0.0-alpha.13 → 1.0.0-alpha.15
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 +4 -0
- package/dist/client.js +38 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -125,5 +125,9 @@ declare class Client {
|
|
|
125
125
|
meta: any;
|
|
126
126
|
}>;
|
|
127
127
|
private writeRequest;
|
|
128
|
+
/**
|
|
129
|
+
* Elimina un'entità specifica tramite il suo documentId.
|
|
130
|
+
*/
|
|
131
|
+
delete(pluralID: string, documentId: string, options?: EntityRequest): Promise<unknown>;
|
|
128
132
|
}
|
|
129
133
|
export default Client;
|
package/dist/client.js
CHANGED
|
@@ -335,6 +335,44 @@ class Client {
|
|
|
335
335
|
throw ensureSimpleException(exception);
|
|
336
336
|
}
|
|
337
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
|
+
// --- AGGIUNGI QUESTO BLOCCO PER IL DEBUG ---
|
|
358
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
359
|
+
throw createSimpleException({
|
|
360
|
+
code: response.status,
|
|
361
|
+
message: errorBody.error?.message || response.statusText,
|
|
362
|
+
type: "error",
|
|
363
|
+
source: "strapi-utils/client.ts",
|
|
364
|
+
});
|
|
365
|
+
// --------------------------------------------
|
|
366
|
+
}
|
|
367
|
+
const { data, meta } = z
|
|
368
|
+
.object({ data: z.any(), meta: z.any() })
|
|
369
|
+
.parse(await response.json());
|
|
370
|
+
return { data, meta };
|
|
371
|
+
}
|
|
372
|
+
catch (exception) {
|
|
373
|
+
throw ensureSimpleException(exception);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
338
376
|
}
|
|
339
377
|
// #region STATIC
|
|
340
378
|
Client.headers = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-strapi",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"node-fetch": "^3.3.2",
|
|
45
45
|
"qs": "^6.14.0",
|
|
46
|
-
"simple-exception": "
|
|
46
|
+
"simple-exception": "github:hund-studio/simple-exception",
|
|
47
47
|
"zod": "^4.0.5"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|