@deessejs/collections 0.0.13 → 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.
@@ -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) => { [K in C["collections"][number]["slug"]]: {
5
- create: (data: C["collections"][number]["fields"]) => Promise<any>;
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<C["collections"][number]["fields"]>) => Promise<any>;
11
+ update: (id: string, data: Partial<InferSchema<Col["fields"]>>) => Promise<any>;
8
12
  delete: (id: string) => Promise<void>;
9
13
  }; };
14
+ export {};
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/collections",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",