@deessejs/collections 0.0.9 → 0.0.11

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,5 +1,9 @@
1
1
  import { Collection } from "../collections/types";
2
- import { CollectionsCrud } from "../database/types";
3
2
  export declare const defineConfig: <const C extends {
4
3
  collections: readonly Collection[];
5
- }>(config: C) => UnionToIntersection<CollectionsCrud<C["collections"][number]>>;
4
+ }>(config: C) => { [K in C["collections"][number]["slug"]]: {
5
+ create: (data: C["collections"][number]["fields"]) => Promise<any>;
6
+ read: (id: string) => Promise<any>;
7
+ update: (id: string, data: Partial<C["collections"][number]["fields"]>) => Promise<any>;
8
+ delete: (id: string) => Promise<void>;
9
+ }; };
@@ -5,10 +5,10 @@ const defineConfig = (config) => {
5
5
  const db = {};
6
6
  for (const col of config.collections) {
7
7
  db[col.slug] = {
8
- create: (data) => ({ ...data }),
9
- read: (id) => ({ id }),
10
- update: (id, data) => ({ id, ...data }),
11
- delete: (id) => { },
8
+ create: async (data) => data,
9
+ read: async (id) => ({ id }),
10
+ update: async (id, data) => ({ id, ...data }),
11
+ delete: async (id) => { },
12
12
  };
13
13
  }
14
14
  return db;
@@ -1,5 +1,6 @@
1
1
  import { Collection } from "../collections/types";
2
2
  import { CollectionsCrud } from "../database/types";
3
+ import { UnionToIntersection } from "../utils/union-intersection";
3
4
  export type Config = {
4
5
  collections: Collection[];
5
6
  };
@@ -1 +1 @@
1
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
1
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
@@ -1 +1,2 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deessejs/collections",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",