simple-strapi 1.0.0-alpha.16 → 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 +3 -2
- package/dist/fields/boolean.d.ts +8 -0
- package/dist/fields/boolean.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/schema.js +8 -2
- package/package.json +1 -1
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
|
|
@@ -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>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/utils/schema.js
CHANGED
|
@@ -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);
|