oksy 0.1.24 → 0.1.26

Sign up to get free protection for your applications and to get access to all the features.
package/public/index.html CHANGED
@@ -22,7 +22,7 @@
22
22
  height: 100% !important;
23
23
  }
24
24
  </style>
25
- <script type="module" crossorigin src="/assets/index.45dac613.js"></script>
25
+ <script type="module" crossorigin src="/assets/index.a7675a50.js"></script>
26
26
  <link rel="stylesheet" href="/assets/index.ef68285e.css">
27
27
  </head>
28
28
  <body class="tw-flex tw-flex-col tw-bg-gray-50">
@@ -0,0 +1,9 @@
1
+ import { BlueprintFieldMany, BlueprintFieldOne, BlueprintFieldSingle } from './Blueprint';
2
+ type Field = (BlueprintFieldSingle | BlueprintFieldOne | BlueprintFieldMany);
3
+ export declare const getGlobalEntityFields: () => Field[];
4
+ export declare const getBaseEntityFields: () => Field[];
5
+ export declare const getBaseFileFields: () => Field[];
6
+ export declare const getBaseUserFields: () => Field[];
7
+ export declare const getBaseWorkspaceFields: () => Field[];
8
+ export declare const getBaseMembershipFields: () => Field[];
9
+ export {};
@@ -12,6 +12,7 @@ export type BlueprintFieldOne = {
12
12
  backrefName: string;
13
13
  backrefField: BlueprintFieldOne | BlueprintFieldMany;
14
14
  backrefBlueprint: Blueprint;
15
+ draft: boolean;
15
16
  lineNumber: null | number;
16
17
  nullable: boolean;
17
18
  cascade: 'DELETE' | 'SET NULL';
@@ -29,10 +30,12 @@ export type BlueprintFieldMany = {
29
30
  };
30
31
  export declare class Blueprint {
31
32
  className: string;
32
- extendsClasses: string[];
33
+ extendsClass: string;
33
34
  filePath: null | string;
34
35
  fileContent: null | string;
36
+ extendsClasses: string[];
35
37
  fields: (BlueprintFieldSingle | BlueprintFieldOne | BlueprintFieldMany)[];
38
+ constructor(className: string, extendsClass: string, filePath?: null | string, fileContent?: null | string);
36
39
  getAllOneFields(): BlueprintFieldOne[];
37
40
  getAllSingleFields(): BlueprintFieldSingle[];
38
41
  getAllManyFields(): BlueprintFieldMany[];
@@ -40,7 +40,7 @@ type DataTableOptions<T> = {
40
40
  view: (options: {
41
41
  refresh: () => void;
42
42
  }) => any[];
43
- search?: () => string;
43
+ search?: () => null | number | string;
44
44
  sort?: () => null | string | number | boolean | Dayjs;
45
45
  }[];
46
46
  actions?: DataTableAction[];
@@ -66,7 +66,7 @@ export declare class UI<TFile extends BaseFile> {
66
66
  view: (options: {
67
67
  refresh: () => void;
68
68
  }) => any[];
69
- search?: (() => string) | undefined;
69
+ search?: (() => string | number | null) | undefined;
70
70
  sort?: (() => string | number | boolean | import("dayjs").Dayjs | null) | undefined;
71
71
  }[];
72
72
  actions?: import("./Components/DataTable").DataTableAction[] | undefined;
@@ -152,7 +152,7 @@ export declare class UI<TFile extends BaseFile> {
152
152
  view: (options: {
153
153
  refresh: () => void;
154
154
  }) => any[];
155
- search?: (() => string) | undefined;
155
+ search?: (() => string | number | null) | undefined;
156
156
  sort?: (() => string | number | boolean | import("dayjs").Dayjs | null) | undefined;
157
157
  }[];
158
158
  actions?: import("./Components/DataTable").DataTableAction[] | undefined;
@@ -1,7 +1,7 @@
1
1
  import { Many, GlobalEntity } from 'oksy';
2
2
  import { Draft } from 'src/ReactiveStore/BaseEntity';
3
3
  type ValueFields<T1> = {
4
- [K in keyof T1]: T1[K] extends GlobalEntity ? never : (T1[K] extends Many<any, any> ? never : K);
4
+ [K in keyof T1]: T1[K] extends GlobalEntity ? never : (T1[K] extends Many ? never : K);
5
5
  }[keyof T1];
6
6
  type EntityArray = Array<Draft<GlobalEntity>>;
7
7
  export declare function sort<T extends EntityArray>(items: T, key: ValueFields<T[number]>, order?: 'ASC' | 'DESC'): T;
@@ -4,16 +4,19 @@ import { Database } from 'oksy';
4
4
  import { Many } from 'oksy';
5
5
  import { EmailValidator } from '../ReactiveStore/Validators/EmailValidator';
6
6
  import { IValidator } from './Validators/IValidator';
7
- export type Draft<T> = {
8
- [P in keyof T]: T[P] extends Function ? T[P] : (P extends 'id' | 'workspaceId' ? T[P] : null | T[P]);
7
+ export type Draft<T extends GlobalEntity> = {
8
+ [P in keyof T]: (T[P] extends Function ? T[P] : (T[P] extends Many ? T[P] : (P extends 'id' | 'workspaceId' | 'isValid' | 'createdAt' | 'updatedAt' ? T[P] : (null | T[P]))));
9
9
  };
10
- type ManyFields<T1 extends GlobalEntity> = {
11
- [K in keyof T1]: T1[K] extends Many<any, any> ? K : never;
10
+ export type UnDraft<T extends Draft<any>> = T extends Draft<infer U> ? U : never;
11
+ export type RelationFields<T1> = {
12
+ [K in keyof T1]: T1[K] extends (null | GlobalEntity | Draft<GlobalEntity>) ? K : (T1[K] extends Many ? K : never);
12
13
  }[keyof T1];
13
- export type One<T1 extends GlobalEntity, T2 extends ManyFields<T1>, T3 extends BlueprintFieldOne['cascade'] = 'DELETE'> = T1;
14
+ export type One<T1 extends (GlobalEntity | Draft<GlobalEntity>), T2 extends RelationFields<UnDraft<T1>>, T3 extends BlueprintFieldOne['cascade'] = 'DELETE'> = T1;
15
+ export declare function isValid<T extends Draft<any>>(model: T): model is UnDraft<T>;
14
16
  export declare abstract class GlobalEntity {
15
17
  id: string;
16
18
  isValid: boolean;
19
+ isBeingDeleted: boolean;
17
20
  createdAt: Dayjs;
18
21
  updatedAt: Dayjs;
19
22
  validators(): {
@@ -51,4 +54,3 @@ export declare abstract class BaseFile extends Entity {
51
54
  size: number;
52
55
  type: string;
53
56
  }
54
- export {};
@@ -1,8 +1,8 @@
1
1
  import { SqliteClient } from './../Bootstrap/SqliteClient';
2
2
  import { Blueprint, BlueprintFieldMany } from './../Bootstrap/TsFilesToBlueprint/Blueprint';
3
- import { Draft, GlobalEntity } from './BaseEntity';
3
+ import { Draft, GlobalEntity, RelationFields, UnDraft } from './BaseEntity';
4
4
  import { Storage } from './ReactiveStore';
5
- export declare class Many<T1 extends GlobalEntity = any, T2 extends keyof T1 = any> {
5
+ export declare class Many<T1 extends GlobalEntity = any, T2 extends RelationFields<UnDraft<T1>> = any> {
6
6
  private sqliteClient;
7
7
  private model;
8
8
  private blueprint;
@@ -17,7 +17,8 @@ export declare class Many<T1 extends GlobalEntity = any, T2 extends keyof T1 = a
17
17
  size(): number;
18
18
  removeId(idToRemove: string): void;
19
19
  addId(idToAdd: string): void;
20
- add(modelToAdd: T1): void;
21
- remove(modelToRemove: T1): void;
20
+ addDraft(modelToAdd: null | undefined | T1 | Draft<T1>): void;
21
+ add(modelToAdd: null | undefined | T1): void;
22
+ remove(modelToRemove: null | undefined | T1 | Draft<T1>): void;
22
23
  private getManyToManyRow;
23
24
  }
@@ -40,7 +40,7 @@ export declare class Database implements Storage {
40
40
  getById(tableName: string, id: undefined | null | string): null | any;
41
41
  getAll(tableName: string): any[];
42
42
  getAllWithDraft(tableName: string): any[];
43
- create(moduleName: string): any;
43
+ create<T extends GlobalEntity = any>(moduleName: string): Draft<T>;
44
44
  delete(model: null | Draft<InstanceType<typeof GlobalEntity>>): void;
45
45
  }
46
46
  declare class Table {
@@ -1,4 +1,4 @@
1
- import { BaseFile, BaseMembership, BaseUser, BaseWorkspace, Entity, One, GlobalEntity } from './ReactiveStore/BaseEntity';
1
+ import { BaseFile, BaseMembership, BaseUser, BaseWorkspace, Entity, One, GlobalEntity, isValid } from './ReactiveStore/BaseEntity';
2
2
  import { Config } from './../types/config';
3
3
  import { Many } from './ReactiveStore/Many';
4
4
  import { Database } from './ReactiveStore/ReactiveStore';
@@ -8,4 +8,4 @@ import { hash } from './Helper/Hash';
8
8
  import { googleIcons, type GoogleIconType } from './Frontend/GoogleIcons';
9
9
  import { IValidator } from './ReactiveStore/Validators/IValidator';
10
10
  import { sort } from './Helper/Sort';
11
- export { Config, GlobalEntity, Entity, One, Many, BaseUser, BaseWorkspace, BaseMembership, BaseFile, BasePage, Database, seed, hash, googleIcons, GoogleIconType, IValidator, sort, };
11
+ export { Config, GlobalEntity, Entity, One, Many, BaseUser, BaseWorkspace, BaseMembership, BaseFile, BasePage, Database, seed, hash, googleIcons, GoogleIconType, IValidator, sort, isValid, };
@@ -1,4 +1,4 @@
1
- import { BaseFile, BaseMembership, BaseUser, BaseWorkspace, Draft, Entity, One } from './ReactiveStore/BaseEntity';
1
+ import { BaseFile, BaseMembership, BaseUser, BaseWorkspace, Draft, Entity, isValid, One, UnDraft } from './ReactiveStore/BaseEntity';
2
2
  import { Config } from './../types/config';
3
3
  import { IValidator } from './ReactiveStore/Validators/IValidator';
4
4
  import { UI } from './Frontend/View/UI';
@@ -14,15 +14,15 @@ declare abstract class GlobalEntity {
14
14
  [key: string]: IValidator[];
15
15
  };
16
16
  }
17
- type RelationFields<T1 extends GlobalEntity> = {
18
- [K in keyof T1]: T1[K] extends GlobalEntity ? K : (T1[K] extends Many<any, any> ? K : never);
17
+ export type RelationFields<T1 extends GlobalEntity> = {
18
+ [K in keyof T1]: T1[K] extends (null | GlobalEntity) ? K : (T1[K] extends Many ? K : never);
19
19
  }[keyof T1];
20
- declare class Many<T1 extends GlobalEntity = any, T2 extends RelationFields<T1> = any> {
20
+ declare class Many<T1 extends GlobalEntity = any, T2 extends RelationFields<UnDraft<T1>> = any> {
21
21
  all(): T1[];
22
- allWithDraft(): Draft<T1>[];
22
+ allWithDraft(): Draft<UnDraft<T1>>[];
23
23
  size(): number;
24
- add(model: T1): void;
25
- remove(model: T1): void;
24
+ add(modelToAdd: null | undefined | T1): void;
25
+ remove(modelToRemove: null | undefined | T1): void;
26
26
  }
27
27
  declare abstract class BasePage {
28
28
  URL: string;
@@ -41,6 +41,7 @@ declare abstract class BasePage {
41
41
  confirm: InstanceType<typeof WebSocketServerClient>['confirm'];
42
42
  navigate: InstanceType<typeof WebSocketServerClient>['navigate'];
43
43
  toLocalDate: InstanceType<typeof WebSocketServerClient>['toLocalDate'];
44
+ download: InstanceType<typeof WebSocketServerClient>['download'];
44
45
  };
45
46
  }
46
47
  type MODULE_KEY = keyof typeof MODULES;
@@ -49,7 +50,7 @@ declare class Database {
49
50
  getById<T extends MODULE_KEY>(tableName: T, id: undefined | null | string): null | MODEL<T>;
50
51
  getAll<T extends MODULE_KEY>(tableName: T): MODEL<T>[];
51
52
  getAllWithDraft<T extends MODULE_KEY>(tableName: T): Draft<MODEL<T>>[];
52
- create<T extends MODULE_KEY>(moduleName: T): MODEL<T>;
53
+ create<T extends MODULE_KEY>(moduleName: T): Draft<MODEL<T>>;
53
54
  delete(model: any): void;
54
55
  }
55
- export { Config, GlobalEntity, Entity, One, Many, BaseUser, BaseWorkspace, BaseMembership, BaseFile, BasePage, Database, seed, hash, googleIcons, GoogleIconType, IValidator, sort, };
56
+ export { Config, GlobalEntity, Entity, One, Many, BaseUser, BaseWorkspace, BaseMembership, BaseFile, BasePage, Database, seed, hash, googleIcons, GoogleIconType, IValidator, sort, isValid, };