@deessejs/collections 0.0.12 → 0.0.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/config/index.d.ts +8 -3
- package/dist/fields/core.d.ts +11 -4
- package/dist/fields/core.js +11 -2
- package/dist/fields/field.js +1 -1
- package/dist/fields/types.d.ts +3 -2
- package/package.json +1 -1
package/dist/config/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Collection } from "../collections/types";
|
|
2
|
+
import { Field, FieldTypeFinal } from "../fields/types";
|
|
3
|
+
type InferSchema<F extends Record<string, Field>> = {
|
|
4
|
+
[K in keyof F]: F[K] extends Field<infer FT> ? FT extends FieldTypeFinal<any, infer TVal> ? TVal : never : never;
|
|
5
|
+
};
|
|
2
6
|
export declare const defineConfig: <const C extends {
|
|
3
7
|
collections: readonly Collection[];
|
|
4
|
-
}>(config: C) => { [
|
|
5
|
-
create: (data:
|
|
8
|
+
}>(config: C) => { [Col in C["collections"][number] as Col["slug"]]: {
|
|
9
|
+
create: (data: InferSchema<Col["fields"]>) => Promise<any>;
|
|
6
10
|
read: (id: string) => Promise<any>;
|
|
7
|
-
update: (id: string, data: Partial<
|
|
11
|
+
update: (id: string, data: Partial<InferSchema<Col["fields"]>>) => Promise<any>;
|
|
8
12
|
delete: (id: string) => Promise<void>;
|
|
9
13
|
}; };
|
|
14
|
+
export {};
|
package/dist/fields/core.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
2
|
export declare const number: (params: {
|
|
3
|
-
min
|
|
4
|
-
max
|
|
3
|
+
min?: number | undefined;
|
|
4
|
+
max?: number | undefined;
|
|
5
5
|
}) => import("./types").FieldTypeFinal<z.ZodObject<{
|
|
6
|
-
min: z.ZodNumber
|
|
7
|
-
max: z.ZodNumber
|
|
6
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
}, z.core.$strip>>;
|
|
9
|
+
export declare const text: (params: {
|
|
10
|
+
min?: number | undefined;
|
|
11
|
+
max?: number | undefined;
|
|
12
|
+
}) => import("./types").FieldTypeFinal<z.ZodObject<{
|
|
13
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
8
15
|
}, z.core.$strip>>;
|
package/dist/fields/core.js
CHANGED
|
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.number = void 0;
|
|
6
|
+
exports.text = exports.number = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const field_1 = require("./field");
|
|
9
9
|
exports.number = (0, field_1.fieldType)({
|
|
10
|
-
schema: zod_1.default.object({ min: zod_1.default.number(), max: zod_1.default.number() }),
|
|
10
|
+
schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
|
|
11
11
|
dsl: {
|
|
12
12
|
kind: "number",
|
|
13
13
|
},
|
|
@@ -15,3 +15,12 @@ exports.number = (0, field_1.fieldType)({
|
|
|
15
15
|
component: undefined,
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
|
+
exports.text = (0, field_1.fieldType)({
|
|
19
|
+
schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
|
|
20
|
+
dsl: {
|
|
21
|
+
kind: "text",
|
|
22
|
+
},
|
|
23
|
+
admin: {
|
|
24
|
+
component: undefined,
|
|
25
|
+
},
|
|
26
|
+
});
|
package/dist/fields/field.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.field = exports.fieldType = void 0;
|
|
4
4
|
const fieldType = (config) => (params) => {
|
|
5
|
-
const validated = config.schema.parse(params);
|
|
5
|
+
const validated = config.schema ? config.schema.parse(params) : params;
|
|
6
6
|
return {
|
|
7
7
|
kind: config.dsl.kind,
|
|
8
8
|
params: validated,
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
|
|
3
|
-
schema
|
|
3
|
+
schema?: TParams;
|
|
4
4
|
dsl: {
|
|
5
5
|
kind: string;
|
|
6
6
|
config?: Record<string, any>;
|
|
@@ -9,7 +9,7 @@ export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
|
|
|
9
9
|
component: any;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export type FieldTypeFinal<TParams extends z.ZodType = z.ZodType> = {
|
|
12
|
+
export type FieldTypeFinal<TParams extends z.ZodType = z.ZodType, TOutput = any> = {
|
|
13
13
|
kind: string;
|
|
14
14
|
params: z.infer<TParams>;
|
|
15
15
|
dsl: {
|
|
@@ -19,6 +19,7 @@ export type FieldTypeFinal<TParams extends z.ZodType = z.ZodType> = {
|
|
|
19
19
|
admin: {
|
|
20
20
|
component: any;
|
|
21
21
|
};
|
|
22
|
+
_output?: TOutput;
|
|
22
23
|
};
|
|
23
24
|
export type FieldPermissions = {
|
|
24
25
|
create: (ctx: any) => Promise<boolean>;
|