@synergy-server/core 0.0.1 → 0.0.3

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.
@@ -2,7 +2,7 @@ import { PassportStatic } from 'passport';
2
2
  import { Request, Response } from 'express';
3
3
  declare const _default: {
4
4
  initializePassport(passport: PassportStatic): void;
5
- isAuthenticated(req: Request, res: Response, done: Function): Response<any, Record<string, any>>;
6
- isSuperAdmin(req: Request, res: Response, done: Function): Response<any, Record<string, any>>;
5
+ isAuthenticated(req: Request, res: Response, done: Function): Response<any, Record<string, any>> | undefined;
6
+ isSuperAdmin(req: Request, res: Response, done: Function): Response<any, Record<string, any>> | undefined;
7
7
  };
8
8
  export default _default;
@@ -1,9 +1,10 @@
1
+ interface ReturnObject<T = any> {
2
+ value: T | null;
3
+ message: string;
4
+ status: number | null;
5
+ }
1
6
  declare const _default: {
2
- getSetting(settingName: string): Promise<{
3
- value: any;
4
- message: string;
5
- status: any;
6
- }>;
7
- setSetting(settingName: string, settingValue: any, model: string): Promise<Record<string, any>>;
7
+ getSetting(settingName: string): Promise<ReturnObject<any>>;
8
+ setSetting(settingName: string, settingValue: any): Promise<ReturnObject<any>>;
8
9
  };
9
10
  export default _default;
@@ -1,10 +1,29 @@
1
1
  import { Model, ModelStatic } from 'sequelize';
2
2
  import { Request } from 'express';
3
+ interface IncludeOptions {
4
+ model: ModelStatic<Model<any, any>>;
5
+ as: string;
6
+ attributes?: string[];
7
+ where?: Record<string, unknown>;
8
+ include?: IncludeOptions[];
9
+ }
10
+ interface TranslateData {
11
+ [key: string]: any;
12
+ lang?: {
13
+ [key: string]: {
14
+ [langCode: string]: string;
15
+ };
16
+ };
17
+ }
3
18
  declare const _default: {
4
- prepareIncludes(object: ModelStatic<Model<any, any>>, params: Record<string, any>, attributes?: string[], filters?: Record<string, any>, order?: Record<string, any>, extraAttributes?: string[]): Record<string, any>;
5
- setAuthor(objectData: Record<string, any>, req: Request): Promise<void>;
6
- executeConditionCode(str: string, args: any): any;
7
- translateField(rowData: Record<string, any>, fieldName: string, langCode: string): any;
8
- initEnums(): Promise<Record<string, any>>;
19
+ prepareIncludes(object: ModelStatic<Model<any, any>>, params: {
20
+ [key: string]: any;
21
+ }, attributes?: string[], filters?: Record<string, any> | null, order?: any[] | null, extraAttributes?: string[]): IncludeOptions[] | {
22
+ all: true;
23
+ };
24
+ setAuthor(objectData: Record<string, unknown>, req: Request): Promise<void>;
25
+ executeConditionCode(str: string, args: unknown): unknown;
26
+ translateField(rowData: TranslateData, fieldName: string, langCode: string): string;
27
+ initEnums(): Promise<Record<string, string[]>>;
9
28
  };
10
29
  export default _default;
@@ -1,61 +1,26 @@
1
1
  import { StatusCodes } from 'http-status-codes';
2
2
  import { NextFunction, Request, Response } from 'express';
3
3
  import { AppObject } from '@/src/types';
4
+ interface ControllerResult<T> {
5
+ status: number;
6
+ responseData: T;
7
+ }
4
8
  declare const _default: {
5
- findAllItems(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<{
6
- status: StatusCodes;
7
- responseData: Record<string, any>[];
8
- } | {
9
- status: StatusCodes;
10
- responseData: {
11
- message: any;
12
- };
13
- }>;
14
- findItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<any>;
15
- findOne(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<{
16
- status: StatusCodes;
17
- responseData: {
18
- message: string;
19
- };
20
- }>;
21
- findPredefinedItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<any>;
22
- createItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>, afterCreate?: any): Promise<{
23
- status: StatusCodes;
24
- responseData: any;
25
- }>;
26
- updateItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>, afterUpdate?: any): Promise<{
27
- status: StatusCodes;
28
- responseData: any;
29
- }>;
30
- confirmItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<{
31
- status: StatusCodes;
32
- data: any;
33
- message: string;
34
- responseData?: undefined;
35
- } | {
36
- status: StatusCodes;
37
- responseData: {
38
- message: any;
39
- };
40
- data?: undefined;
41
- message?: undefined;
42
- }>;
9
+ findAllItems(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<ControllerResult<any>>;
10
+ findItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<ControllerResult<any>>;
11
+ findOne(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<ControllerResult<any>>;
12
+ findPredefinedItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<ControllerResult<any>>;
13
+ createItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>, afterCreate?: Function | undefined): Promise<ControllerResult<any>>;
14
+ updateItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>, afterUpdate?: Function | undefined): Promise<ControllerResult<any>>;
15
+ confirmItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<ControllerResult<any>>;
43
16
  undoConfirmItem(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>): Promise<{
44
17
  status: StatusCodes;
45
18
  responseData: {
46
19
  message: any;
47
20
  };
48
21
  }>;
49
- deleteItem(req: Request, res: Response, next: NextFunction, object: AppObject, params: Record<string, any>, afterDelete: any): Promise<{
50
- status: StatusCodes;
51
- responseData: {
52
- message: any;
53
- };
54
- }>;
55
- changeItemDeletionMark(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>, afterUpdate?: any): Promise<{
56
- status: StatusCodes;
57
- responseData: any;
58
- }>;
22
+ deleteItem(req: Request, res: Response, next: NextFunction, object: AppObject, params: Record<string, any> | undefined, afterDelete: Function | undefined): Promise<ControllerResult<any>>;
23
+ changeItemDeletionMark(req: Request, res: Response, next: NextFunction, object: AppObject, params?: Record<string, any>, afterUpdate?: Function | undefined): Promise<ControllerResult<any>>;
59
24
  calculateRegisterTotals(req: Request, res: Response, next: NextFunction, object: AppObject): Promise<{
60
25
  status: StatusCodes;
61
26
  responseData: {
@@ -18,6 +18,6 @@ declare const _default: {
18
18
  };
19
19
  }>;
20
20
  exportProcessor(req: Request, res: Response, next: NextFunction, object: AppObject): Promise<any>;
21
- importProcessor(req: Request, res: Response, next: NextFunction, object: AppObject): Promise<Response<any, Record<string, any>>>;
21
+ importProcessor(req: Request, res: Response, next: NextFunction, object: AppObject): Promise<Response<any, Record<string, any>> | undefined>;
22
22
  };
23
23
  export default _default;
@@ -2,6 +2,6 @@ import { ModelStatic, Model, Transaction } from 'sequelize';
2
2
  import { AppObject } from '@/src/types';
3
3
  declare const _default: {
4
4
  setNumber(object: AppObject, objectData: Record<string, any>, t: Transaction): Promise<void>;
5
- nextNumber(object: ModelStatic<Model<any, any>>, prefix: string, numberPeriod: any, t: Transaction): Promise<number>;
5
+ nextNumber(object: ModelStatic<Model<any, any>>, prefix: string, numberPeriod: undefined, t: Transaction): Promise<number>;
6
6
  };
7
7
  export default _default;
@@ -1,6 +1,50 @@
1
1
  import { StatusCodes } from 'http-status-codes';
2
2
  import { NextFunction, Request, Response } from 'express';
3
3
  import { AppObject } from '@/src/types';
4
+ interface Field {
5
+ id: string;
6
+ dbName: string;
7
+ type: string;
8
+ isTablePart?: boolean;
9
+ virtual?: boolean;
10
+ index?: boolean;
11
+ primaryKey?: boolean;
12
+ unique?: boolean;
13
+ notNull?: boolean;
14
+ defaultValue?: string | number | null;
15
+ autoIncrement?: boolean;
16
+ typeOptions?: {
17
+ length?: number;
18
+ precision?: number;
19
+ scale?: number;
20
+ };
21
+ multiType?: boolean;
22
+ ref?: string;
23
+ fields: Field[];
24
+ }
25
+ interface CreateTableAction {
26
+ action: 'createTable';
27
+ newTable: Field;
28
+ }
29
+ interface ChangeTableAction {
30
+ action: 'changeTable';
31
+ oldTable: Field;
32
+ newTable: Field;
33
+ }
34
+ interface DropTableAction {
35
+ action: 'dropTable';
36
+ oldTable: Field;
37
+ }
38
+ type TablePartAction = CreateTableAction | ChangeTableAction | DropTableAction;
39
+ interface MigrationAction {
40
+ action: 'addField' | 'dropField' | 'renameField' | 'changeField' | 'addIndex' | 'removeIndex';
41
+ fieldName?: string;
42
+ oldName?: string;
43
+ newName?: string;
44
+ field?: Field;
45
+ oldField?: Field;
46
+ newField?: Field;
47
+ }
4
48
  declare const _default: {
5
49
  executeMigrations(req: Request, res: Response, next: NextFunction, object: AppObject): Promise<{
6
50
  status: StatusCodes;
@@ -8,7 +52,7 @@ declare const _default: {
8
52
  message: string;
9
53
  };
10
54
  }>;
11
- prepareFieldsDifs(oldFields: Record<string, any>[], newFields: Record<string, any>[], tableParts: Record<string, any>[]): any[];
55
+ prepareFieldsDifs(oldFields: Field[], newFields: Field[], tableParts: TablePartAction[]): MigrationAction[];
12
56
  createTable(appObject: AppObject): Promise<boolean>;
13
57
  updateTable(tableData: Record<string, any>): Promise<boolean>;
14
58
  };
@@ -1,6 +1,6 @@
1
1
  import xl from 'exceljs';
2
2
  import { Request, Response } from 'express';
3
3
  declare const _default: {
4
- generateExcel(req: Request, res?: Response): Promise<xl.Workbook>;
4
+ generateExcel(req: Request, res?: Response | null): Promise<xl.Workbook>;
5
5
  };
6
6
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { Request, Response } from 'express';
2
2
  declare const _default: {
3
- generatePdf(req: Request, res?: Response): Promise<void>;
3
+ generatePdf(req: Request, res?: Response | null): Promise<void>;
4
4
  };
5
5
  export default _default;
@@ -1,7 +1,15 @@
1
1
  import { ModelStatic, Model } from 'sequelize';
2
2
  import { AppObject } from '@/src/types';
3
+ interface Params {
4
+ event?: 'update' | 'delete';
5
+ oldValue?: AppObject;
6
+ newValue?: Record<string, unknown>;
7
+ objectId?: string;
8
+ changeDeletionMark?: boolean;
9
+ serverModule?: string;
10
+ }
3
11
  declare const _default: {
4
- updateInitialData(object: ModelStatic<Model<any, any>>, filename: string, params?: Record<string, any>): Promise<void>;
12
+ updateInitialData(object: ModelStatic<Model<any, any>>, filename: string, params: Params): Promise<void>;
5
13
  updatePredefinedInitialData(object: AppObject): Promise<void>;
6
14
  };
7
15
  export default _default;
@@ -5,17 +5,18 @@ interface UserAccessRole {
5
5
  canRead: boolean;
6
6
  canModify: boolean;
7
7
  }
8
+ interface Restrictions {
9
+ use: boolean;
10
+ users: string[];
11
+ }
8
12
  declare const _default: {
9
13
  getUserAccessRoles(userId: string, canRead?: boolean, canModify?: boolean): Promise<UserAccessRole[]>;
10
- getUserAccessRoleId(userId: any, canRead?: boolean, canModify?: boolean): Promise<Record<any, any>[]>;
11
- getUserRoleByKey(roleKey: any): Promise<Record<any, any>>;
12
- getUserRoleById(roleId: string): Promise<Record<any, any>>;
14
+ getUserAccessRoleId(userId: string, canRead?: boolean, canModify?: boolean): Promise<Record<any, any>[]>;
15
+ getUserRoleByKey(roleKey: string): Promise<Record<any, any> | null>;
16
+ getUserRoleById(roleId: string): Promise<Record<any, any> | null>;
13
17
  checkUserAccess(userId: string, role: Record<string, any>, canRead?: boolean, canModify?: boolean): Promise<boolean | Error>;
14
- getAllSubDepartments(department: Record<string, any>, include: Record<string, any>): Promise<any[]>;
15
- accessRestrictions(req: Request, object: AppObject): Promise<{
16
- use: boolean;
17
- users: any[];
18
- }>;
18
+ getAllSubDepartments(department: Record<string, any>, include: Record<string, any>): Promise<Record<any, any>[]>;
19
+ accessRestrictions(req: Request, object: AppObject): Promise<Restrictions>;
19
20
  getUserAccessNavigation(userId: string): Promise<any[]>;
20
21
  };
21
22
  export default _default;
@@ -1,14 +1,14 @@
1
1
  import { Request } from 'express';
2
2
  declare const _default: {
3
- getUserExecutorRoles(executorId: string): Promise<any[]>;
3
+ getUserExecutorRoles(executorId: string): Promise<import("sequelize").Model<any, any>[]>;
4
4
  getVendorsAndCustomersFilter(counterparies: string[]): Promise<string[]>;
5
5
  getCustomerFilter(req: Request): Promise<{
6
6
  fullAccess: boolean;
7
- counterparties: any[];
7
+ counterparties: string[];
8
8
  }>;
9
9
  getForwarderFilter(req: Request): Promise<{
10
10
  fullAccess: boolean;
11
- forwarder: string;
11
+ forwarder: string | undefined;
12
12
  }>;
13
13
  getRoleGroups(req: Request): Promise<string[]>;
14
14
  };
@@ -1,28 +1,28 @@
1
1
  declare const _default: {
2
2
  development: {
3
- username: string;
4
- password: string;
5
- database: string;
6
- host: string;
7
- port: string;
3
+ username: string | undefined;
4
+ password: string | undefined;
5
+ database: string | undefined;
6
+ host: string | undefined;
7
+ port: string | undefined;
8
8
  dialect: string;
9
9
  migrationStorageTableName: string;
10
10
  };
11
11
  test: {
12
- username: string;
13
- password: string;
14
- database: string;
15
- host: string;
16
- port: string;
12
+ username: string | undefined;
13
+ password: string | undefined;
14
+ database: string | undefined;
15
+ host: string | undefined;
16
+ port: string | undefined;
17
17
  dialect: string;
18
18
  migrationStorageTableName: string;
19
19
  };
20
20
  production: {
21
- username: string;
22
- password: string;
23
- database: string;
24
- host: string;
25
- port: string;
21
+ username: string | undefined;
22
+ password: string | undefined;
23
+ database: string | undefined;
24
+ host: string | undefined;
25
+ port: string | undefined;
26
26
  dialect: string;
27
27
  migrationStorageTableName: string;
28
28
  };