springnext 0.0.1 → 0.0.2

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.
@@ -0,0 +1,74 @@
1
+ import type { PaginationModel } from '../value-objects/pagination.value-object';
2
+ export type CRUD<Models extends {
3
+ list: unknown;
4
+ detail: unknown;
5
+ }, SearchPayload extends {
6
+ list: unknown;
7
+ specific: unknown;
8
+ }, ActionsPayload extends {
9
+ create: unknown;
10
+ update: unknown;
11
+ }> = {
12
+ list: (data: {
13
+ filter: SearchPayload['list'];
14
+ pagination?: PaginationModel;
15
+ }) => Promise<Models['list'][]>;
16
+ details: (data: {
17
+ filter: SearchPayload['specific'];
18
+ }) => Promise<Models['detail'] | null>;
19
+ create: (data: {
20
+ payload: ActionsPayload['create'];
21
+ }) => Promise<{
22
+ id: string;
23
+ }>;
24
+ updateOne: (data: {
25
+ filter: SearchPayload['specific'];
26
+ payload: ActionsPayload['update'];
27
+ }) => Promise<{
28
+ success: boolean;
29
+ }>;
30
+ deleteOne: (data: {
31
+ filter: SearchPayload['specific'];
32
+ }) => Promise<{
33
+ success: boolean;
34
+ }>;
35
+ };
36
+ type ExtractCRUDParams<T> = T extends {
37
+ list: (data: {
38
+ filter: infer SList;
39
+ pagination?: any;
40
+ }) => Promise<Array<infer MList>>;
41
+ details: (data: {
42
+ filter: infer SDetail;
43
+ }) => Promise<infer MDetail>;
44
+ create: (data: {
45
+ payload: infer ACreate;
46
+ }) => Promise<any>;
47
+ updateOne: (data: {
48
+ filter: any;
49
+ payload: infer AUpdate;
50
+ }) => Promise<any>;
51
+ deleteOne: (payload: any) => Promise<any>;
52
+ } ? {
53
+ Models: {
54
+ list: NonNullable<MList>;
55
+ detail: NonNullable<MDetail>;
56
+ };
57
+ SearchPayload: {
58
+ list: SList;
59
+ specific: SDetail;
60
+ };
61
+ ActionsPayload: {
62
+ create: ACreate;
63
+ update: AUpdate;
64
+ };
65
+ } : never;
66
+ export type Types<T> = {
67
+ listModel: ExtractCRUDParams<T>['Models']['list'];
68
+ details: ExtractCRUDParams<T>['Models']['detail'];
69
+ findOnePayload: ExtractCRUDParams<T>['SearchPayload']['specific'];
70
+ findListPayload: ExtractCRUDParams<T>['SearchPayload']['list'];
71
+ createPayload: ExtractCRUDParams<T>['ActionsPayload']['create'];
72
+ updatePayload: ExtractCRUDParams<T>['ActionsPayload']['update'];
73
+ };
74
+ export {};