@deessejs/collections 0.0.14 → 0.0.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.
@@ -1,9 +1,10 @@
1
1
  import { Collection } from "../collections/types";
2
+ import { InferSchema } from "../fields/types";
2
3
  export type CollectionsCrud<C extends Collection> = {
3
4
  [K in C["slug"]]: {
4
- create: (data: C["fields"]) => Promise<any>;
5
+ create: (data: InferSchema<C["fields"]>) => Promise<any>;
5
6
  read: (id: string) => Promise<any>;
6
- update: (id: string, data: Partial<C["fields"]>) => Promise<any>;
7
+ update: (id: string, data: Partial<InferSchema<C["fields"]>>) => Promise<any>;
7
8
  delete: (id: string) => Promise<void>;
8
9
  };
9
10
  };
@@ -5,11 +5,11 @@ export declare const number: (params: {
5
5
  }) => import("./types").FieldTypeFinal<z.ZodObject<{
6
6
  min: z.ZodOptional<z.ZodNumber>;
7
7
  max: z.ZodOptional<z.ZodNumber>;
8
- }, z.core.$strip>>;
8
+ }, z.core.$strip>, number>;
9
9
  export declare const text: (params: {
10
10
  min?: number | undefined;
11
11
  max?: number | undefined;
12
12
  }) => import("./types").FieldTypeFinal<z.ZodObject<{
13
13
  min: z.ZodOptional<z.ZodNumber>;
14
14
  max: z.ZodOptional<z.ZodNumber>;
15
- }, z.core.$strip>>;
15
+ }, z.core.$strip>, string>;
@@ -8,19 +8,11 @@ const zod_1 = __importDefault(require("zod"));
8
8
  const field_1 = require("./field");
9
9
  exports.number = (0, field_1.fieldType)({
10
10
  schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
11
- dsl: {
12
- kind: "number",
13
- },
14
- admin: {
15
- component: undefined,
16
- },
11
+ dsl: { kind: "number" },
12
+ admin: { component: undefined },
17
13
  });
18
14
  exports.text = (0, field_1.fieldType)({
19
15
  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
- },
16
+ dsl: { kind: "text" },
17
+ admin: { component: undefined },
26
18
  });
@@ -1,4 +1,4 @@
1
1
  import z from "zod";
2
2
  import { Field, FieldConfig, FieldTypeConfig, FieldTypeFinal } from "./types";
3
- export declare const fieldType: <TParams extends z.ZodType>(config: FieldTypeConfig<TParams>) => (params: z.infer<TParams>) => FieldTypeFinal<TParams>;
3
+ export declare const fieldType: <TOutput, TParams extends z.ZodType>(config: FieldTypeConfig<TParams>) => (params: z.infer<TParams>) => FieldTypeFinal<TParams, TOutput>;
4
4
  export declare const field: <TType extends FieldTypeFinal>(config: FieldConfig<TType>) => Field<TType>;
@@ -35,3 +35,6 @@ export type Field<TType extends FieldTypeFinal = FieldTypeFinal> = {
35
35
  type: TType;
36
36
  permissions: FieldPermissions;
37
37
  };
38
+ export type InferSchema<F extends Record<string, Field>> = {
39
+ [K in keyof F]: F[K] extends Field<infer FT> ? FT extends FieldTypeFinal<any, infer TVal> ? TVal : never : never;
40
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/collections",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",