simple-strapi 1.0.0-alpha.15 → 1.0.0-alpha.17

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
@@ -1,3 +1,4 @@
1
+ import { InferBoolean, BooleanField, BooleanOptions } from "./fields/boolean";
1
2
  import { InferNumber, NumberField, NumberOptions } from "./fields/number";
2
3
  import { InferText, TextField, TextOptions } from "./fields/text";
3
4
  import { InferRelationHasMany, InferRelationHasOne, RelationHasManyField, RelationHasManyOptions, RelationHasOneField, RelationHasOneOptions } from "./fields/relation";
@@ -14,10 +15,10 @@ type EntityRequest<P = {}> = {
14
15
  params?: RequestParams;
15
16
  headers?: Record<string, string>;
16
17
  } & P;
17
- export type SchemaField = TextField | NumberField | RelationHasManyField | RelationHasOneField | DynamicField | ComponentSingleField | ComponentRepeatableField | MediaSingleField | EnumerationField | RichTextBlocksField;
18
+ export type SchemaField = TextField | NumberField | BooleanField | RelationHasManyField | RelationHasOneField | DynamicField | ComponentSingleField | ComponentRepeatableField | MediaSingleField | EnumerationField | RichTextBlocksField;
18
19
  export type Schema = Record<string, SchemaField>;
19
20
  export type InferSchema<S extends Schema> = {
20
- [K in keyof S]: S[K] extends ["text", infer O extends TextOptions] ? InferText<O> : S[K] extends ["number", infer O extends NumberOptions] ? InferNumber<O> : S[K] extends [
21
+ [K in keyof S]: S[K] extends ["text", infer O extends TextOptions] ? InferText<O> : S[K] extends ["number", infer O extends NumberOptions] ? InferNumber<O> : S[K] extends ["boolean", infer O extends BooleanOptions] ? InferBoolean<O> : S[K] extends [
21
22
  "relation.hasMany",
22
23
  infer R extends Schema,
23
24
  infer O extends RelationHasManyOptions
@@ -128,6 +129,9 @@ declare class Client {
128
129
  /**
129
130
  * Elimina un'entità specifica tramite il suo documentId.
130
131
  */
131
- delete(pluralID: string, documentId: string, options?: EntityRequest): Promise<unknown>;
132
+ delete(pluralID: string, documentId: string, options?: EntityRequest): Promise<{
133
+ data: any;
134
+ meta: any;
135
+ }>;
132
136
  }
133
137
  export default Client;
package/dist/client.js CHANGED
@@ -354,7 +354,6 @@ class Client {
354
354
  },
355
355
  });
356
356
  if (!response.ok) {
357
- // --- AGGIUNGI QUESTO BLOCCO PER IL DEBUG ---
358
357
  const errorBody = await response.json().catch(() => ({}));
359
358
  throw createSimpleException({
360
359
  code: response.status,
@@ -362,7 +361,9 @@ class Client {
362
361
  type: "error",
363
362
  source: "strapi-utils/client.ts",
364
363
  });
365
- // --------------------------------------------
364
+ }
365
+ if (response.status === 204) {
366
+ return { data: { documentId }, meta: {} };
366
367
  }
367
368
  const { data, meta } = z
368
369
  .object({ data: z.any(), meta: z.any() })
@@ -0,0 +1,8 @@
1
+ import { ZodType } from "zod";
2
+ export type BooleanOptions = {
3
+ required?: boolean;
4
+ };
5
+ export type InferBoolean<O extends BooleanOptions> = O["required"] extends true ? boolean : boolean | null | undefined;
6
+ export declare const boolean: <O extends BooleanOptions = {}>(options?: O) => ["boolean", O];
7
+ export declare const booleanSchema: (opts: BooleanOptions) => ZodType;
8
+ export type BooleanField = ReturnType<typeof boolean>;
@@ -0,0 +1,10 @@
1
+ import z from "zod";
2
+ export const boolean = (options = {}) => {
3
+ return ["boolean", options];
4
+ };
5
+ export const booleanSchema = (opts) => {
6
+ let schema = z.boolean();
7
+ if (!opts.required)
8
+ schema = schema.nullable().optional();
9
+ return schema;
10
+ };
package/dist/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./fields/component";
7
7
  export * from "./fields/media";
8
8
  export * from "./fields/enumeration";
9
9
  export * from "./fields/richText";
10
+ export * from "./fields/boolean";
package/dist/index.js CHANGED
@@ -7,3 +7,4 @@ export * from "./fields/component";
7
7
  export * from "./fields/media";
8
8
  export * from "./fields/enumeration";
9
9
  export * from "./fields/richText";
10
+ export * from "./fields/boolean";
@@ -1,11 +1,12 @@
1
+ import { booleanSchema } from "../fields/boolean";
1
2
  import { dynamicSchema } from "../fields/dynamic";
3
+ import { enumerationSchema } from "../fields/enumeration";
2
4
  import { mediaSingleSchema } from "../fields/media";
3
5
  import { numberSchema } from "../fields/number";
4
6
  import { repeatableSchema, singleSchema } from "../fields/component";
7
+ import { richTextBlocksSchema } from "../fields/richText";
5
8
  import { textSchema } from "../fields/text";
6
9
  import z from "zod";
7
- import { enumerationSchema } from "../fields/enumeration";
8
- import { richTextBlocksSchema } from "../fields/richText";
9
10
  export const defaultStrapiFields = {
10
11
  id: z.number(),
11
12
  documentId: z.string().optional(),
@@ -28,6 +29,11 @@ export const schemaToParser = (schema) => {
28
29
  shape[key] = numberSchema(args);
29
30
  break;
30
31
  }
32
+ case "boolean": {
33
+ const [, args] = field;
34
+ shape[key] = booleanSchema(args);
35
+ break;
36
+ }
31
37
  case "dynamic": {
32
38
  const [, ...args] = field;
33
39
  shape[key] = dynamicSchema(...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-strapi",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",