@deessejs/collections 0.0.23 → 0.0.25
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/collections/define.d.ts +1 -31
- package/dist/config/index.d.ts +3 -11
- package/dist/config/index.js +5 -5
- package/dist/config/types.d.ts +9 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +7 -0
- package/dist/plugins/types.d.ts +1 -0
- package/dist/plugins/types.js +2 -0
- package/dist/utils/exact.d.ts +1 -0
- package/dist/utils/exact.js +1 -0
- package/package.json +1 -1
|
@@ -1,32 +1,2 @@
|
|
|
1
1
|
import { Collection } from "./types";
|
|
2
|
-
export declare const collection: <const Slug extends string, const Fields extends Record<string, any>>(config:
|
|
3
|
-
slug: Slug;
|
|
4
|
-
name?: string;
|
|
5
|
-
admin?: {
|
|
6
|
-
title?: string;
|
|
7
|
-
group?: string;
|
|
8
|
-
};
|
|
9
|
-
fields: Fields;
|
|
10
|
-
hooks?: Collection["hooks"];
|
|
11
|
-
permissions?: {
|
|
12
|
-
create?: (ctx: any) => Promise<boolean>;
|
|
13
|
-
read?: (ctx: any) => Promise<boolean>;
|
|
14
|
-
update?: (ctx: any) => Promise<boolean>;
|
|
15
|
-
delete?: (ctx: any) => Promise<boolean>;
|
|
16
|
-
};
|
|
17
|
-
}) => {
|
|
18
|
-
slug: Slug;
|
|
19
|
-
name?: string;
|
|
20
|
-
admin?: {
|
|
21
|
-
title?: string;
|
|
22
|
-
group?: string;
|
|
23
|
-
};
|
|
24
|
-
fields: Fields;
|
|
25
|
-
hooks?: Collection["hooks"];
|
|
26
|
-
permissions?: {
|
|
27
|
-
create?: (ctx: any) => Promise<boolean>;
|
|
28
|
-
read?: (ctx: any) => Promise<boolean>;
|
|
29
|
-
update?: (ctx: any) => Promise<boolean>;
|
|
30
|
-
delete?: (ctx: any) => Promise<boolean>;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
2
|
+
export declare const collection: <const Slug extends string, const Fields extends Record<string, any>>(config: Collection<Slug, Fields>) => Collection<Slug, Fields>;
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type InferSchema<F extends Record<string, Field>> = {
|
|
5
|
-
[K in keyof F]: F[K] extends Field<infer FT> ? FT extends FieldTypeFinal<any, infer TVal> ? TVal : never : never;
|
|
6
|
-
};
|
|
7
|
-
export declare const defineConfig: <const C extends {
|
|
8
|
-
provider: Provider;
|
|
9
|
-
collections: readonly Collection[];
|
|
10
|
-
}>(config: C) => { [Col in C["collections"][number] as Col["slug"]]: {
|
|
1
|
+
import { InferSchema } from "../fields/types";
|
|
2
|
+
import { Config } from "./types";
|
|
3
|
+
export declare const defineConfig: <C extends Config>(config: Exact<C, Config>) => { [Col in C["collections"][number] as Col["slug"]]: {
|
|
11
4
|
create: (data: InferSchema<Col["fields"]>) => Promise<any>;
|
|
12
5
|
read: (id: string) => Promise<any>;
|
|
13
6
|
update: (id: string, data: Partial<InferSchema<Col["fields"]>>) => Promise<any>;
|
|
14
7
|
delete: (id: string) => Promise<void>;
|
|
15
8
|
}; };
|
|
16
|
-
export {};
|
package/dist/config/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineConfig = void 0;
|
|
4
|
-
const orchestrator_1 = require("./orchestrator");
|
|
4
|
+
const orchestrator_1 = require("./orchestrator");
|
|
5
5
|
const defineConfig = (config) => {
|
|
6
6
|
// 1. Initialisation du Provider (Création tables, connexion DB...)
|
|
7
7
|
// On passe les collections pour qu'il connaisse le schéma
|
|
@@ -11,16 +11,16 @@ const defineConfig = (config) => {
|
|
|
11
11
|
for (const col of config.collections) {
|
|
12
12
|
db[col.slug] = {
|
|
13
13
|
create: async (data) => {
|
|
14
|
-
return (0, orchestrator_1.runOperation)(
|
|
14
|
+
return (0, orchestrator_1.runOperation)("create", col, config.provider, { data });
|
|
15
15
|
},
|
|
16
16
|
read: async (id) => {
|
|
17
|
-
return (0, orchestrator_1.runOperation)(
|
|
17
|
+
return (0, orchestrator_1.runOperation)("read", col, config.provider, { id });
|
|
18
18
|
},
|
|
19
19
|
update: async (id, data) => {
|
|
20
|
-
return (0, orchestrator_1.runOperation)(
|
|
20
|
+
return (0, orchestrator_1.runOperation)("update", col, config.provider, { id, data });
|
|
21
21
|
},
|
|
22
22
|
delete: async (id) => {
|
|
23
|
-
return (0, orchestrator_1.runOperation)(
|
|
23
|
+
return (0, orchestrator_1.runOperation)("delete", col, config.provider, { id });
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { Collection } from "../collections/types";
|
|
2
2
|
import { CollectionsCrud } from "../database/types";
|
|
3
|
+
import { Field, FieldTypeFinal } from "../fields";
|
|
4
|
+
import { Plugin } from "../plugins/types";
|
|
5
|
+
import { Provider } from "../providers/types";
|
|
3
6
|
import { UnionToIntersection } from "../utils/union-intersection";
|
|
4
7
|
export type Config = {
|
|
5
|
-
|
|
8
|
+
provider: Provider;
|
|
9
|
+
readonly collections: Collection[];
|
|
10
|
+
plugins?: Plugin[];
|
|
6
11
|
};
|
|
7
12
|
export type DbFromConfig<C extends Config> = UnionToIntersection<CollectionsCrud<C["collections"][number]>>;
|
|
13
|
+
export type InferSchema<F extends Record<string, Field>> = {
|
|
14
|
+
[K in keyof F]: F[K] extends Field<infer FT> ? FT extends FieldTypeFinal<any, infer TVal> ? TVal : never : never;
|
|
15
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./config";
|
|
2
|
+
export * from "./collections";
|
|
3
|
+
export * from "./fields";
|
|
4
|
+
export * from "./providers";
|
|
5
|
+
export * from "./plugins";
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Plugin = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type Exact<A, B> = A extends B ? Exclude<keyof A, keyof B> extends never ? A : never : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|