@sdflc/backend-helpers 1.0.104 → 1.0.106
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/package.json +25 -25
- package/build/BaseCore.d.ts +0 -88
- package/build/BaseCore.js +0 -723
- package/build/BaseGateway.d.ts +0 -56
- package/build/BaseGateway.js +0 -480
- package/build/DataCache.d.ts +0 -16
- package/build/DataCache.js +0 -112
- package/build/Database.d.ts +0 -36
- package/build/Database.js +0 -195
- package/build/DbMigratorAndSeeder.d.ts +0 -49
- package/build/DbMigratorAndSeeder.js +0 -212
- package/build/RedisDataLoader.d.ts +0 -41
- package/build/RedisDataLoader.js +0 -212
- package/build/apiContext.d.ts +0 -11
- package/build/apiContext.js +0 -146
- package/build/baseController.d.ts +0 -17
- package/build/baseController.js +0 -59
- package/build/checkItHelpers.d.ts +0 -3
- package/build/checkItHelpers.js +0 -28
- package/build/commonValidators.d.ts +0 -17
- package/build/commonValidators.js +0 -311
- package/build/configBulder.d.ts +0 -2
- package/build/configBulder.js +0 -36
- package/build/constants.d.ts +0 -30
- package/build/constants.js +0 -80
- package/build/dbHelpers.d.ts +0 -43
- package/build/dbHelpers.js +0 -156
- package/build/dbSeeder.d.ts +0 -2
- package/build/dbSeeder.js +0 -83
- package/build/dbTableHelpers.d.ts +0 -14
- package/build/dbTableHelpers.js +0 -118
- package/build/downloadHelpers.d.ts +0 -2
- package/build/downloadHelpers.js +0 -73
- package/build/esm/BaseCore.d.ts +0 -88
- package/build/esm/BaseCore.js +0 -717
- package/build/esm/BaseGateway.d.ts +0 -56
- package/build/esm/BaseGateway.js +0 -474
- package/build/esm/DataCache.d.ts +0 -16
- package/build/esm/DataCache.js +0 -106
- package/build/esm/Database.d.ts +0 -36
- package/build/esm/Database.js +0 -189
- package/build/esm/DbMigratorAndSeeder.d.ts +0 -49
- package/build/esm/DbMigratorAndSeeder.js +0 -173
- package/build/esm/RedisDataLoader.d.ts +0 -41
- package/build/esm/RedisDataLoader.js +0 -206
- package/build/esm/apiContext.d.ts +0 -11
- package/build/esm/apiContext.js +0 -138
- package/build/esm/baseController.d.ts +0 -17
- package/build/esm/baseController.js +0 -53
- package/build/esm/checkItHelpers.d.ts +0 -3
- package/build/esm/checkItHelpers.js +0 -23
- package/build/esm/commonValidators.d.ts +0 -17
- package/build/esm/commonValidators.js +0 -291
- package/build/esm/configBulder.d.ts +0 -2
- package/build/esm/configBulder.js +0 -32
- package/build/esm/constants.d.ts +0 -30
- package/build/esm/constants.js +0 -69
- package/build/esm/dbHelpers.d.ts +0 -43
- package/build/esm/dbHelpers.js +0 -144
- package/build/esm/dbSeeder.d.ts +0 -2
- package/build/esm/dbSeeder.js +0 -44
- package/build/esm/dbTableHelpers.d.ts +0 -14
- package/build/esm/dbTableHelpers.js +0 -106
- package/build/esm/downloadHelpers.d.ts +0 -2
- package/build/esm/downloadHelpers.js +0 -66
- package/build/esm/index.d.ts +0 -21
- package/build/esm/index.js +0 -21
- package/build/esm/interfaces/ApiContext.d.ts +0 -25
- package/build/esm/interfaces/ApiContext.js +0 -1
- package/build/esm/interfaces/ApiContextInterface.d.ts +0 -12
- package/build/esm/interfaces/ApiContextInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreActionsInterface.d.ts +0 -38
- package/build/esm/interfaces/BaseCoreActionsInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreDoAuthOnActionInterface.d.ts +0 -12
- package/build/esm/interfaces/BaseCoreDoAuthOnActionInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreDoingWhatInterface.d.ts +0 -13
- package/build/esm/interfaces/BaseCoreDoingWhatInterface.js +0 -1
- package/build/esm/interfaces/BaseCorePropsInterface.d.ts +0 -37
- package/build/esm/interfaces/BaseCorePropsInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreValidatorsInterface.d.ts +0 -13
- package/build/esm/interfaces/BaseCoreValidatorsInterface.js +0 -1
- package/build/esm/interfaces/BaseGatewayPropsInterface.d.ts +0 -39
- package/build/esm/interfaces/BaseGatewayPropsInterface.js +0 -1
- package/build/esm/interfaces/BuildConfigOptions.d.ts +0 -6
- package/build/esm/interfaces/BuildConfigOptions.js +0 -1
- package/build/esm/interfaces/BuildDefaultResolversOptions.d.ts +0 -17
- package/build/esm/interfaces/BuildDefaultResolversOptions.js +0 -1
- package/build/esm/interfaces/BuildListQueryArgsInterface.d.ts +0 -6
- package/build/esm/interfaces/BuildListQueryArgsInterface.js +0 -1
- package/build/esm/interfaces/CacheInterface.d.ts +0 -15
- package/build/esm/interfaces/CacheInterface.js +0 -1
- package/build/esm/interfaces/CommonValidatorArgs.d.ts +0 -3
- package/build/esm/interfaces/CommonValidatorArgs.js +0 -1
- package/build/esm/interfaces/CoreActionInterface.d.ts +0 -14
- package/build/esm/interfaces/CoreActionInterface.js +0 -1
- package/build/esm/interfaces/CreateUserTokenArgs.d.ts +0 -11
- package/build/esm/interfaces/CreateUserTokenArgs.js +0 -1
- package/build/esm/interfaces/CreateUserTokenResult.d.ts +0 -4
- package/build/esm/interfaces/CreateUserTokenResult.js +0 -1
- package/build/esm/interfaces/DatabaseOptions.d.ts +0 -26
- package/build/esm/interfaces/DatabaseOptions.js +0 -1
- package/build/esm/interfaces/DatabaseReadInterface.d.ts +0 -14
- package/build/esm/interfaces/DatabaseReadInterface.js +0 -1
- package/build/esm/interfaces/DbFieldAddDefaultInterface.d.ts +0 -9
- package/build/esm/interfaces/DbFieldAddDefaultInterface.js +0 -1
- package/build/esm/interfaces/DownloadFileArgs.d.ts +0 -6
- package/build/esm/interfaces/DownloadFileArgs.js +0 -1
- package/build/esm/interfaces/ExtractCredentialsArgs.d.ts +0 -19
- package/build/esm/interfaces/ExtractCredentialsArgs.js +0 -1
- package/build/esm/interfaces/JwtTokenSecretAndSettings.d.ts +0 -5
- package/build/esm/interfaces/JwtTokenSecretAndSettings.js +0 -1
- package/build/esm/interfaces/ListArgsInterface.d.ts +0 -7
- package/build/esm/interfaces/ListArgsInterface.js +0 -1
- package/build/esm/interfaces/LoaderInterface.d.ts +0 -7
- package/build/esm/interfaces/LoaderInterface.js +0 -1
- package/build/esm/interfaces/PaginationInterface.d.ts +0 -10
- package/build/esm/interfaces/PaginationInterface.js +0 -1
- package/build/esm/interfaces/SortItemInterface.d.ts +0 -4
- package/build/esm/interfaces/SortItemInterface.js +0 -1
- package/build/esm/interfaces/UserTokenParams.d.ts +0 -8
- package/build/esm/interfaces/UserTokenParams.js +0 -1
- package/build/esm/interfaces/VerifyUserTokenArgs.d.ts +0 -13
- package/build/esm/interfaces/VerifyUserTokenArgs.js +0 -1
- package/build/esm/interfaces/index.d.ts +0 -28
- package/build/esm/interfaces/index.js +0 -27
- package/build/esm/knexConfigBuilder.d.ts +0 -1
- package/build/esm/knexConfigBuilder.js +0 -84
- package/build/esm/passwordHelpers.d.ts +0 -5
- package/build/esm/passwordHelpers.js +0 -13
- package/build/esm/redisClient.d.ts +0 -17
- package/build/esm/redisClient.js +0 -94
- package/build/esm/resolversHelpers.d.ts +0 -3
- package/build/esm/resolversHelpers.js +0 -66
- package/build/esm/userToken.d.ts +0 -8
- package/build/esm/userToken.js +0 -74
- package/build/esm/utils.d.ts +0 -2
- package/build/esm/utils.js +0 -13
- package/build/index.d.ts +0 -21
- package/build/index.js +0 -37
- package/build/interfaces/ApiContext.d.ts +0 -25
- package/build/interfaces/ApiContext.js +0 -2
- package/build/interfaces/ApiContextInterface.d.ts +0 -12
- package/build/interfaces/ApiContextInterface.js +0 -2
- package/build/interfaces/BaseCoreActionsInterface.d.ts +0 -38
- package/build/interfaces/BaseCoreActionsInterface.js +0 -2
- package/build/interfaces/BaseCoreDoAuthOnActionInterface.d.ts +0 -12
- package/build/interfaces/BaseCoreDoAuthOnActionInterface.js +0 -2
- package/build/interfaces/BaseCoreDoingWhatInterface.d.ts +0 -13
- package/build/interfaces/BaseCoreDoingWhatInterface.js +0 -2
- package/build/interfaces/BaseCorePropsInterface.d.ts +0 -37
- package/build/interfaces/BaseCorePropsInterface.js +0 -2
- package/build/interfaces/BaseCoreValidatorsInterface.d.ts +0 -13
- package/build/interfaces/BaseCoreValidatorsInterface.js +0 -2
- package/build/interfaces/BaseGatewayPropsInterface.d.ts +0 -39
- package/build/interfaces/BaseGatewayPropsInterface.js +0 -2
- package/build/interfaces/BuildConfigOptions.d.ts +0 -6
- package/build/interfaces/BuildConfigOptions.js +0 -2
- package/build/interfaces/BuildDefaultResolversOptions.d.ts +0 -17
- package/build/interfaces/BuildDefaultResolversOptions.js +0 -2
- package/build/interfaces/BuildListQueryArgsInterface.d.ts +0 -6
- package/build/interfaces/BuildListQueryArgsInterface.js +0 -2
- package/build/interfaces/CacheInterface.d.ts +0 -15
- package/build/interfaces/CacheInterface.js +0 -2
- package/build/interfaces/CommonValidatorArgs.d.ts +0 -3
- package/build/interfaces/CommonValidatorArgs.js +0 -2
- package/build/interfaces/CoreActionInterface.d.ts +0 -14
- package/build/interfaces/CoreActionInterface.js +0 -2
- package/build/interfaces/CreateUserTokenArgs.d.ts +0 -11
- package/build/interfaces/CreateUserTokenArgs.js +0 -2
- package/build/interfaces/CreateUserTokenResult.d.ts +0 -4
- package/build/interfaces/CreateUserTokenResult.js +0 -2
- package/build/interfaces/DatabaseOptions.d.ts +0 -26
- package/build/interfaces/DatabaseOptions.js +0 -2
- package/build/interfaces/DatabaseReadInterface.d.ts +0 -14
- package/build/interfaces/DatabaseReadInterface.js +0 -2
- package/build/interfaces/DbFieldAddDefaultInterface.d.ts +0 -9
- package/build/interfaces/DbFieldAddDefaultInterface.js +0 -2
- package/build/interfaces/DownloadFileArgs.d.ts +0 -6
- package/build/interfaces/DownloadFileArgs.js +0 -2
- package/build/interfaces/ExtractCredentialsArgs.d.ts +0 -19
- package/build/interfaces/ExtractCredentialsArgs.js +0 -2
- package/build/interfaces/JwtTokenSecretAndSettings.d.ts +0 -5
- package/build/interfaces/JwtTokenSecretAndSettings.js +0 -2
- package/build/interfaces/ListArgsInterface.d.ts +0 -7
- package/build/interfaces/ListArgsInterface.js +0 -2
- package/build/interfaces/LoaderInterface.d.ts +0 -7
- package/build/interfaces/LoaderInterface.js +0 -2
- package/build/interfaces/PaginationInterface.d.ts +0 -10
- package/build/interfaces/PaginationInterface.js +0 -2
- package/build/interfaces/SortItemInterface.d.ts +0 -4
- package/build/interfaces/SortItemInterface.js +0 -2
- package/build/interfaces/UserTokenParams.d.ts +0 -8
- package/build/interfaces/UserTokenParams.js +0 -2
- package/build/interfaces/VerifyUserTokenArgs.d.ts +0 -13
- package/build/interfaces/VerifyUserTokenArgs.js +0 -2
- package/build/interfaces/index.d.ts +0 -28
- package/build/interfaces/index.js +0 -43
- package/build/knexConfigBuilder.d.ts +0 -1
- package/build/knexConfigBuilder.js +0 -91
- package/build/passwordHelpers.d.ts +0 -5
- package/build/passwordHelpers.js +0 -21
- package/build/redisClient.d.ts +0 -17
- package/build/redisClient.js +0 -97
- package/build/resolversHelpers.d.ts +0 -3
- package/build/resolversHelpers.js +0 -69
- package/build/userToken.d.ts +0 -8
- package/build/userToken.js +0 -86
- package/build/utils.d.ts +0 -2
- package/build/utils.js +0 -21
package/build/esm/dbHelpers.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes all the records from provided table.
|
|
3
|
-
* If appSettings has cleanTable object with table names then
|
|
4
|
-
* it is used to add extra filters to clear the table to avoid for example users data
|
|
5
|
-
* @param table Name of table from which to remove all the records
|
|
6
|
-
* @param knexHandle Knex handle object with configured connection to DB
|
|
7
|
-
* @param appSettings settings with db related information
|
|
8
|
-
*/
|
|
9
|
-
declare const dbCleanTable: (table: string, knexHandle: any, appSettings: any) => Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Returns a list of tables in db schedm specified in settings
|
|
12
|
-
* @param knexHandle Knex handle object with configured connection to DB
|
|
13
|
-
* @param appSettings settings with db related information
|
|
14
|
-
* @returns arrays of table names in the provided db schema
|
|
15
|
-
*/
|
|
16
|
-
declare const dbListTables: (knexHandle: any, appSettings: any) => Promise<any>;
|
|
17
|
-
/**
|
|
18
|
-
* Removes all the records from provided list of tables
|
|
19
|
-
* @param tablesToClean array of table names
|
|
20
|
-
* @param knexHandle Knex handle object with configured connection to DB
|
|
21
|
-
* @param appSettings settings with db related information
|
|
22
|
-
* @returns promise
|
|
23
|
-
*/
|
|
24
|
-
declare const dbClean: (tablesToClean: any[], knexHandle: any, appSettings: any) => Promise<unknown>;
|
|
25
|
-
/**
|
|
26
|
-
* Selects all the tables in the schema and drops them.
|
|
27
|
-
* This approach does not work in case we have constraints.
|
|
28
|
-
* TODO: Remove all constraints and then drop tables.
|
|
29
|
-
*/
|
|
30
|
-
declare const dbWipe: (knexHandle: any, appSettings: any) => any;
|
|
31
|
-
/**
|
|
32
|
-
* Drop all tables, run migrations, then seed
|
|
33
|
-
*/
|
|
34
|
-
declare const dbReset: (knexHandle: any, appSettings: any) => any;
|
|
35
|
-
/**
|
|
36
|
-
* Go from array of objects which contain keys of object names which have an array value of seeded objects
|
|
37
|
-
* to a single object with keys of object names and arrays of seeded objects
|
|
38
|
-
* ie from [{table1: [], table2: [] }, { table3: [] }]
|
|
39
|
-
* to { table1: [], table2: [], table3: []}
|
|
40
|
-
*/
|
|
41
|
-
declare const dbTransformSeedsToObject: (generatedSeedArrays: any[]) => any;
|
|
42
|
-
declare const dbRunMigrations: (knexHandle: any, appSettings: any) => any;
|
|
43
|
-
export { dbCleanTable, dbListTables, dbClean, dbWipe, dbReset, dbTransformSeedsToObject, dbRunMigrations };
|
package/build/esm/dbHelpers.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import BPromise from 'bluebird';
|
|
2
|
-
import { reduce } from 'lodash';
|
|
3
|
-
const SQLS = {
|
|
4
|
-
pg: {
|
|
5
|
-
listTablesSchema: (appSettings) => `
|
|
6
|
-
SELECT TABLE_NAME as table_name
|
|
7
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
8
|
-
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
9
|
-
`,
|
|
10
|
-
listTables: () => `
|
|
11
|
-
SELECT TABLE_NAME as table_name
|
|
12
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
13
|
-
`,
|
|
14
|
-
dropTablesSchema: (appSettings) => `
|
|
15
|
-
SELECT 'DROP TABLE IF EXISTS ${appSettings?.dbSchema}.' || TABLE_NAME || ';' as cmd
|
|
16
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
17
|
-
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
18
|
-
`,
|
|
19
|
-
dropTables: () => `
|
|
20
|
-
SELECT 'DROP TABLE IF EXISTS ' || TABLE_NAME || ';' as cmd
|
|
21
|
-
FROM INFORMATION_SCHEMA.TABLES';
|
|
22
|
-
`,
|
|
23
|
-
},
|
|
24
|
-
mssql: {
|
|
25
|
-
listTablesSchema: (appSettings) => `
|
|
26
|
-
SELECT TABLE_NAME as table_name
|
|
27
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
28
|
-
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
29
|
-
`,
|
|
30
|
-
listTables: () => `
|
|
31
|
-
SELECT TABLE_NAME as table_name
|
|
32
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
33
|
-
`,
|
|
34
|
-
dropTablesSchema: (appSettings) => `
|
|
35
|
-
SELECT 'DROP TABLE IF EXISTS [${appSettings?.dbSchema}].[' + TABLE_NAME + '];' as cmd
|
|
36
|
-
FROM INFORMATION_SCHEMA.TABLES
|
|
37
|
-
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
38
|
-
`,
|
|
39
|
-
dropTables: () => `
|
|
40
|
-
SELECT 'DROP TABLE IF EXISTS ' + TABLE_NAME + ';' as cmd
|
|
41
|
-
FROM INFORMATION_SCHEMA.TABLES';
|
|
42
|
-
`,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Removes all the records from provided table.
|
|
47
|
-
* If appSettings has cleanTable object with table names then
|
|
48
|
-
* it is used to add extra filters to clear the table to avoid for example users data
|
|
49
|
-
* @param table Name of table from which to remove all the records
|
|
50
|
-
* @param knexHandle Knex handle object with configured connection to DB
|
|
51
|
-
* @param appSettings settings with db related information
|
|
52
|
-
*/
|
|
53
|
-
const dbCleanTable = async (table, knexHandle, appSettings) => {
|
|
54
|
-
const query = knexHandle(table).withSchema(appSettings.dbSchema).delete();
|
|
55
|
-
const cleanTableFilters = appSettings?.cleanTableFilters?.[table];
|
|
56
|
-
if (cleanTableFilters != undefined) {
|
|
57
|
-
if (Array.isArray(cleanTableFilters.where)) {
|
|
58
|
-
cleanTableFilters.where.forEach((whereItem) => {
|
|
59
|
-
query.where(whereItem.fieldName, whereItem.operand, whereItem.value);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
await query;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Returns a list of tables in db schedm specified in settings
|
|
67
|
-
* @param knexHandle Knex handle object with configured connection to DB
|
|
68
|
-
* @param appSettings settings with db related information
|
|
69
|
-
* @returns arrays of table names in the provided db schema
|
|
70
|
-
*/
|
|
71
|
-
const dbListTables = async (knexHandle, appSettings) => {
|
|
72
|
-
const skipTables = (appSettings || {}).skipTables || [];
|
|
73
|
-
let query = SQLS[appSettings.dbType].listTablesSchema(appSettings);
|
|
74
|
-
if (!appSettings.dbSchema) {
|
|
75
|
-
query = SQLS[appSettings.dbType].listTables(appSettings);
|
|
76
|
-
}
|
|
77
|
-
const tables = await knexHandle.raw(query);
|
|
78
|
-
return (tables.rows || [])
|
|
79
|
-
.map((row) => row.table_name)
|
|
80
|
-
.filter((table) => skipTables.indexOf(table) === -1);
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Removes all the records from provided list of tables
|
|
84
|
-
* @param tablesToClean array of table names
|
|
85
|
-
* @param knexHandle Knex handle object with configured connection to DB
|
|
86
|
-
* @param appSettings settings with db related information
|
|
87
|
-
* @returns promise
|
|
88
|
-
*/
|
|
89
|
-
const dbClean = async (tablesToClean, knexHandle, appSettings) => {
|
|
90
|
-
for (let idx = 0, len = tablesToClean.length; idx < len; ++idx) {
|
|
91
|
-
await dbCleanTable(tablesToClean[idx], knexHandle, appSettings);
|
|
92
|
-
}
|
|
93
|
-
return new BPromise((resolve) => {
|
|
94
|
-
resolve(tablesToClean);
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Selects all the tables in the schema and drops them.
|
|
99
|
-
* This approach does not work in case we have constraints.
|
|
100
|
-
* TODO: Remove all constraints and then drop tables.
|
|
101
|
-
*/
|
|
102
|
-
const dbWipe = (knexHandle, appSettings) => {
|
|
103
|
-
let query = SQLS[appSettings.dbType].dropTablesSchema(appSettings);
|
|
104
|
-
if (!appSettings.dbSchema) {
|
|
105
|
-
query = SQLS[appSettings.dbType].dropTables(appSettings);
|
|
106
|
-
}
|
|
107
|
-
return knexHandle
|
|
108
|
-
.raw(query)
|
|
109
|
-
.then((result) => result.rows.map((r) => r.cmd))
|
|
110
|
-
.then((commands) => BPromise.each(commands, (cmd) => knexHandle.raw(cmd)));
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* Drop all tables, run migrations, then seed
|
|
114
|
-
*/
|
|
115
|
-
const dbReset = (knexHandle, appSettings) => {
|
|
116
|
-
return dbWipe(knexHandle, appSettings)
|
|
117
|
-
.then(() => dbRunMigrations(knexHandle, appSettings))
|
|
118
|
-
.catch((error) => console.log('An exception has occurred on resetting database: ', error));
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Go from array of objects which contain keys of object names which have an array value of seeded objects
|
|
122
|
-
* to a single object with keys of object names and arrays of seeded objects
|
|
123
|
-
* ie from [{table1: [], table2: [] }, { table3: [] }]
|
|
124
|
-
* to { table1: [], table2: [], table3: []}
|
|
125
|
-
*/
|
|
126
|
-
const dbTransformSeedsToObject = (generatedSeedArrays) => reduce(generatedSeedArrays, (acc, cur) => {
|
|
127
|
-
for (const key in cur) {
|
|
128
|
-
acc[key] = cur[key];
|
|
129
|
-
}
|
|
130
|
-
return acc;
|
|
131
|
-
}, {});
|
|
132
|
-
const dbRunMigrations = (knexHandle, appSettings) => {
|
|
133
|
-
return knexHandle.migrate
|
|
134
|
-
.latest()
|
|
135
|
-
.then(async (result) => {
|
|
136
|
-
if (appSettings && appSettings.runDbSeed && result[1].length > 0) {
|
|
137
|
-
await knexHandle.seed.run();
|
|
138
|
-
}
|
|
139
|
-
console.log('Ran', result[1].length, 'migration(s)');
|
|
140
|
-
return knexHandle.migrate.currentVersion();
|
|
141
|
-
})
|
|
142
|
-
.then((version) => console.log('Current version of database: ', version));
|
|
143
|
-
};
|
|
144
|
-
export { dbCleanTable, dbListTables, dbClean, dbWipe, dbReset, dbTransformSeedsToObject, dbRunMigrations };
|
package/build/esm/dbSeeder.d.ts
DELETED
package/build/esm/dbSeeder.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { camelCase, flatten, map } from 'lodash';
|
|
3
|
-
import { dbClean } from './dbHelpers';
|
|
4
|
-
const generateSeeds = async (dirname, seedFiles) => {
|
|
5
|
-
let seedGroups = [];
|
|
6
|
-
const seedFileNames = flatten(seedFiles);
|
|
7
|
-
const seedFnExports = await Promise.all(map(seedFileNames, (filename) => import(path.join(dirname, `./objects/${filename}.js`))));
|
|
8
|
-
const seedFns = map(seedFnExports, 'default');
|
|
9
|
-
const seedFnsMap = {};
|
|
10
|
-
for (let i = 0; i < seedFileNames.length; i++) {
|
|
11
|
-
const seedFileName = seedFileNames[i];
|
|
12
|
-
seedFnsMap[seedFileName] = seedFns[i];
|
|
13
|
-
}
|
|
14
|
-
seedFiles.reduce((seeds, fileGroup) => {
|
|
15
|
-
seedGroups = seedGroups.concat(fileGroup.reduce((group, filename) => {
|
|
16
|
-
const seedFn = seedFnsMap[filename];
|
|
17
|
-
const seed = seedFn(seeds);
|
|
18
|
-
const filenameCamel = camelCase(filename);
|
|
19
|
-
seeds[filenameCamel] = seed;
|
|
20
|
-
return Object.assign({ [filenameCamel]: seed }, group);
|
|
21
|
-
}, {}));
|
|
22
|
-
return seeds;
|
|
23
|
-
}, {});
|
|
24
|
-
return seedGroups;
|
|
25
|
-
};
|
|
26
|
-
const removeSeedsFromDb = (seedFiles, knexHandle, config) => {
|
|
27
|
-
const tablesToReset = flatten(seedFiles).reverse();
|
|
28
|
-
console.log('Deleting records from tables: ', tablesToReset);
|
|
29
|
-
return dbClean(tablesToReset, knexHandle, config);
|
|
30
|
-
};
|
|
31
|
-
const insertRecords = (seedGroups, knexHandle, config) => {
|
|
32
|
-
const { dbSchema } = config || {};
|
|
33
|
-
console.log('Inserting seeds records tables tables...');
|
|
34
|
-
return seedGroups.reduce(async (previousGroup, group) => {
|
|
35
|
-
await previousGroup;
|
|
36
|
-
return Promise.all(Object.keys(group).map((table) => knexHandle(table).withSchema(dbSchema).insert(group[table])));
|
|
37
|
-
}, Promise.resolve());
|
|
38
|
-
};
|
|
39
|
-
const dbSeed = async (dirname, seedFiles, knexHandle, config) => {
|
|
40
|
-
const groups = await generateSeeds(dirname, seedFiles);
|
|
41
|
-
await removeSeedsFromDb(seedFiles, knexHandle, config);
|
|
42
|
-
return await insertRecords(groups, knexHandle, config);
|
|
43
|
-
};
|
|
44
|
-
export { dbSeed };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DbFieldAddDefaultInterface } from './interfaces';
|
|
2
|
-
import { FIELDS } from './constants';
|
|
3
|
-
export declare const dbFieldAddDefaults: (table: any, opt?: DbFieldAddDefaultInterface) => void;
|
|
4
|
-
export declare const addOrderNo: (table: any, opt?: any) => any;
|
|
5
|
-
export declare const addOrderNoNum: (table: any, opt?: any) => any;
|
|
6
|
-
export declare const addAmount: (table: any, fieldName: string) => any;
|
|
7
|
-
export declare const addSpaceId: (table: any, opt?: any) => any;
|
|
8
|
-
export declare const addUserId: (table: any, opt?: any) => any;
|
|
9
|
-
export declare const addAccountId: (table: any, opt?: any) => any;
|
|
10
|
-
export declare const addLang: (table: any, opt?: any) => any;
|
|
11
|
-
export declare const defaultFields: (opt?: any) => {
|
|
12
|
-
[FIELDS.CREATED_AT]: string;
|
|
13
|
-
[FIELDS.UPDATED_AT]: string;
|
|
14
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { STATUSES, UUID_EMPTY } from '@sdflc/utils';
|
|
2
|
-
import { FIELDS } from './constants';
|
|
3
|
-
export const dbFieldAddDefaults = (table, opt) => {
|
|
4
|
-
const { addUserInfo, addVersion, addStatus, skipTimestamps, skipRemovedAtStr } = opt || {};
|
|
5
|
-
if (addStatus) {
|
|
6
|
-
table
|
|
7
|
-
.integer(FIELDS.STATUS)
|
|
8
|
-
.defaultTo(STATUSES.ACTIVE)
|
|
9
|
-
.comment(opt?.statusComment ||
|
|
10
|
-
'The field is used to specify record status: 50 - Test, 100 - Active, 200 - Draft, 300 - Pending, 1000 - Blocked, 5000 - Disabled, 10000 - Removed');
|
|
11
|
-
}
|
|
12
|
-
if (addVersion) {
|
|
13
|
-
table
|
|
14
|
-
.integer(FIELDS.VERSION)
|
|
15
|
-
.defaultTo(0)
|
|
16
|
-
.comment(opt?.versionComment || 'The field is used to control versioning');
|
|
17
|
-
}
|
|
18
|
-
if (addUserInfo) {
|
|
19
|
-
table.uuid(FIELDS.CREATED_BY).comment('ID of user who created the record');
|
|
20
|
-
table.uuid(FIELDS.UPDATED_BY).comment('ID of the last user who update the record');
|
|
21
|
-
table.uuid(FIELDS.REMOVED_BY).comment('ID of user who removed the record');
|
|
22
|
-
}
|
|
23
|
-
if (skipTimestamps !== true) {
|
|
24
|
-
table.timestamps(true, true);
|
|
25
|
-
table
|
|
26
|
-
.dateTime(FIELDS.REMOVED_AT)
|
|
27
|
-
.comment('Date and time of removal. As it is nullable it cannot be used in any unique index');
|
|
28
|
-
if (skipRemovedAtStr !== true) {
|
|
29
|
-
table.string(FIELDS.REMOVED_AT_STR, 32).defaultTo('').comment('Used to create unique indexes.');
|
|
30
|
-
}
|
|
31
|
-
table.index([FIELDS.CREATED_AT]);
|
|
32
|
-
table.index([FIELDS.UPDATED_AT]);
|
|
33
|
-
}
|
|
34
|
-
if (addStatus) {
|
|
35
|
-
table.index([FIELDS.STATUS]);
|
|
36
|
-
}
|
|
37
|
-
if (skipRemovedAtStr !== true) {
|
|
38
|
-
table.index([FIELDS.REMOVED_AT_STR]);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export const addOrderNo = (table, opt) => {
|
|
42
|
-
const chain = table.text(FIELDS.ORDER_NO).notNullable().defaultTo('10000000');
|
|
43
|
-
if (opt?.addIndex === true) {
|
|
44
|
-
table.index([FIELDS.ORDER_NO]);
|
|
45
|
-
}
|
|
46
|
-
return chain;
|
|
47
|
-
};
|
|
48
|
-
export const addOrderNoNum = (table, opt) => {
|
|
49
|
-
const chain = table.decimal(FIELDS.ORDER_NO, 30, 15).notNullable().defaultTo(1000000).comment('Display order');
|
|
50
|
-
if (opt?.addIndex === true) {
|
|
51
|
-
table.index([FIELDS.ORDER_NO]);
|
|
52
|
-
}
|
|
53
|
-
return chain;
|
|
54
|
-
};
|
|
55
|
-
export const addAmount = (table, fieldName) => {
|
|
56
|
-
return table.decimal(fieldName, 19, 4);
|
|
57
|
-
};
|
|
58
|
-
export const addSpaceId = (table, opt) => {
|
|
59
|
-
const chain = table.string(FIELDS.SPACE_ID, 128).notNullable().comment('Reference to the space table');
|
|
60
|
-
if (opt?.addForeignKey === true) {
|
|
61
|
-
table.foreign(FIELDS.SPACE_ID).references(`space.${FIELDS.ID}`).onUpdate('CASCADE').onDelete('CASCADE');
|
|
62
|
-
}
|
|
63
|
-
return chain;
|
|
64
|
-
};
|
|
65
|
-
export const addUserId = (table, opt) => {
|
|
66
|
-
const chain = table.uuid(FIELDS.USER_ID).notNullable().comment('Reference to the user table');
|
|
67
|
-
if (opt?.addForeignKey === true) {
|
|
68
|
-
table.foreign(FIELDS.USER_ID).references(`user.${FIELDS.ID}`).onUpdate('CASCADE').onDelete('CASCADE');
|
|
69
|
-
}
|
|
70
|
-
if (opt?.addIndex === true) {
|
|
71
|
-
table.index([FIELDS.USER_ID]);
|
|
72
|
-
}
|
|
73
|
-
return chain;
|
|
74
|
-
};
|
|
75
|
-
export const addAccountId = (table, opt) => {
|
|
76
|
-
const chain = table.uuid(FIELDS.ACCOUNT_ID).notNullable().comment('Reference to the account table');
|
|
77
|
-
if (opt?.addForeignKey === true) {
|
|
78
|
-
table.foreign(FIELDS.ACCOUNT_ID).references(`account.${FIELDS.ID}`).onUpdate('CASCADE').onDelete('CASCADE');
|
|
79
|
-
}
|
|
80
|
-
if (opt?.addIndex === true) {
|
|
81
|
-
table.index([FIELDS.ACCOUNT_ID]);
|
|
82
|
-
}
|
|
83
|
-
return chain;
|
|
84
|
-
};
|
|
85
|
-
export const addLang = (table, opt) => {
|
|
86
|
-
const chain = table.text(FIELDS.LANG).defaultTo('en').notNullable().comment('Language, example: en, ru, en_CA, etc');
|
|
87
|
-
if (opt?.addForeignKey === true) {
|
|
88
|
-
table.foreign(FIELDS.LANG).references(`language.${FIELDS.ID}`).onUpdate('CASCADE').onDelete('CASCADE');
|
|
89
|
-
}
|
|
90
|
-
if (opt?.addIndex === true) {
|
|
91
|
-
table.index([FIELDS.LANG]);
|
|
92
|
-
}
|
|
93
|
-
return chain;
|
|
94
|
-
};
|
|
95
|
-
export const defaultFields = (opt) => {
|
|
96
|
-
const { addUserInfo } = opt || {};
|
|
97
|
-
const obj = {
|
|
98
|
-
[FIELDS.CREATED_AT]: '2021-01-01T00:00:00Z', // dh.dbUtcNow(),
|
|
99
|
-
[FIELDS.UPDATED_AT]: '2021-01-01T00:00:00Z', // dh.dbUtcNow(),
|
|
100
|
-
};
|
|
101
|
-
if (addUserInfo === true) {
|
|
102
|
-
obj[FIELDS.CREATED_BY] = UUID_EMPTY;
|
|
103
|
-
obj[FIELDS.UPDATED_BY] = UUID_EMPTY;
|
|
104
|
-
}
|
|
105
|
-
return obj;
|
|
106
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import util from 'util';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import stream from 'stream';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { URL } from 'url';
|
|
6
|
-
import axios from 'axios';
|
|
7
|
-
import { OpResult, OP_RESULT_CODES } from '@sdflc/api-helpers';
|
|
8
|
-
import { MeasureTool } from '@sdflc/utils';
|
|
9
|
-
import { HEADERS } from './constants';
|
|
10
|
-
const pipeline = util.promisify(stream.pipeline);
|
|
11
|
-
const MESSAGES = {
|
|
12
|
-
NO_URL: 'Failed to download file as "url" prop was not provided',
|
|
13
|
-
NO_FILENAME: 'Failed to download file as "fileName" prop was not provided and no file name was in the "url"',
|
|
14
|
-
};
|
|
15
|
-
const CHARSET = 'charset=';
|
|
16
|
-
export const downloadFile = async (args) => {
|
|
17
|
-
const measureTool = new MeasureTool();
|
|
18
|
-
const { durationMs, result } = await measureTool.measureExecTime('', async () => {
|
|
19
|
-
if (!args?.url) {
|
|
20
|
-
return OpResult.fail(OP_RESULT_CODES.VALIDATION_FAILED, {}, MESSAGES.NO_URL);
|
|
21
|
-
}
|
|
22
|
-
const url = new URL(args?.url);
|
|
23
|
-
const fileName = !args?.fileName ? url.pathname.split('/').pop() || `${url.hostname}.html` : args?.fileName || '';
|
|
24
|
-
if (!fileName) {
|
|
25
|
-
return OpResult.fail(OP_RESULT_CODES.VALIDATION_FAILED, {}, MESSAGES.NO_FILENAME);
|
|
26
|
-
}
|
|
27
|
-
const fullPathName = path.resolve(args?.folder || '', fileName);
|
|
28
|
-
try {
|
|
29
|
-
const response = await axios.get(url.toString(), {
|
|
30
|
-
responseType: 'stream',
|
|
31
|
-
});
|
|
32
|
-
const strease2use = args?.stream || fs.createWriteStream(fullPathName);
|
|
33
|
-
await pipeline(response.data, strease2use);
|
|
34
|
-
const contentType = response?.headers?.[HEADERS.CONTENT_TYPE] || '';
|
|
35
|
-
const [mimeType, charset] = contentType.split('; ');
|
|
36
|
-
const encoding = charset?.startsWith(CHARSET) ? charset.slice(CHARSET.length) : '';
|
|
37
|
-
return OpResult.ok({
|
|
38
|
-
url: url.toString(),
|
|
39
|
-
fileName,
|
|
40
|
-
fullPathName,
|
|
41
|
-
size: Number(response.headers?.[HEADERS.CONTENT_LENGTH] ?? 0),
|
|
42
|
-
mimeType,
|
|
43
|
-
encoding,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
catch (ex) {
|
|
47
|
-
return OpResult.fail(OP_RESULT_CODES.FAILED, { url: url.toString(), fileName, fullPathName, size: 0, mimeType: '' }, ex.message);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
const data = result.getDataFirst();
|
|
51
|
-
result.setData({ ...data, speed: (data.size * 1000) / durationMs, durationMs });
|
|
52
|
-
return result;
|
|
53
|
-
};
|
|
54
|
-
// const run = async () => {
|
|
55
|
-
// // const result = await downloadFile({
|
|
56
|
-
// // url: 'https://sushitei.com/wp-content/uploads/2022/08/2022-Sushi-Tei-Autumn-Menu.pdf',
|
|
57
|
-
// // fileName: '',
|
|
58
|
-
// // });
|
|
59
|
-
// const result = await downloadFile({
|
|
60
|
-
// url: 'https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v6.15/windows/pgadmin4-6.15-x64.exe',
|
|
61
|
-
// fileName: '',
|
|
62
|
-
// folder: path.resolve('d:\\Users\\dcerge\\Downloads'),
|
|
63
|
-
// });
|
|
64
|
-
// console.log('result', JSON.stringify(result, null, 2));
|
|
65
|
-
// };
|
|
66
|
-
// run();
|
package/build/esm/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './interfaces';
|
|
3
|
-
export * from './configBulder';
|
|
4
|
-
export * from './Database';
|
|
5
|
-
export * from './dbHelpers';
|
|
6
|
-
export * from './DbMigratorAndSeeder';
|
|
7
|
-
export * from './dbSeeder';
|
|
8
|
-
export * from './knexConfigBuilder';
|
|
9
|
-
export * from './redisClient';
|
|
10
|
-
export * from './checkItHelpers';
|
|
11
|
-
export * from './DataCache';
|
|
12
|
-
export * from './BaseGateway';
|
|
13
|
-
export * from './BaseCore';
|
|
14
|
-
export * from './apiContext';
|
|
15
|
-
export * from './baseController';
|
|
16
|
-
export * from './dbTableHelpers';
|
|
17
|
-
export * from './resolversHelpers';
|
|
18
|
-
export * from './userToken';
|
|
19
|
-
export * from './passwordHelpers';
|
|
20
|
-
export * from './commonValidators';
|
|
21
|
-
export * from './downloadHelpers';
|
package/build/esm/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './interfaces';
|
|
3
|
-
export * from './configBulder';
|
|
4
|
-
export * from './Database';
|
|
5
|
-
export * from './dbHelpers';
|
|
6
|
-
export * from './DbMigratorAndSeeder';
|
|
7
|
-
export * from './dbSeeder';
|
|
8
|
-
export * from './knexConfigBuilder';
|
|
9
|
-
export * from './redisClient';
|
|
10
|
-
export * from './checkItHelpers';
|
|
11
|
-
export * from './DataCache';
|
|
12
|
-
export * from './BaseGateway';
|
|
13
|
-
export * from './BaseCore';
|
|
14
|
-
export * from './apiContext';
|
|
15
|
-
export * from './baseController';
|
|
16
|
-
export * from './dbTableHelpers';
|
|
17
|
-
export * from './resolversHelpers';
|
|
18
|
-
export * from './userToken';
|
|
19
|
-
export * from './passwordHelpers';
|
|
20
|
-
export * from './commonValidators';
|
|
21
|
-
export * from './downloadHelpers';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface of application API interface which should be created on receiving of a request
|
|
3
|
-
*/
|
|
4
|
-
export interface ApiContext {
|
|
5
|
-
requestId: string;
|
|
6
|
-
cores: any;
|
|
7
|
-
gateways: any;
|
|
8
|
-
req: any;
|
|
9
|
-
res?: any;
|
|
10
|
-
spaceId?: string;
|
|
11
|
-
apiKey?: string;
|
|
12
|
-
managementApiKey?: string;
|
|
13
|
-
userAgent?: string;
|
|
14
|
-
referer?: string;
|
|
15
|
-
ipAddress?: string;
|
|
16
|
-
acceptLanguage?: string;
|
|
17
|
-
languages?: string[];
|
|
18
|
-
requestedLang?: string;
|
|
19
|
-
authorization?: string;
|
|
20
|
-
accountId?: string;
|
|
21
|
-
roleId?: string;
|
|
22
|
-
userId?: string;
|
|
23
|
-
lang?: string;
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseCorePropsInterface } from './BaseCorePropsInterface';
|
|
2
|
-
import { BaseGatewayPropsInterface } from './BaseGatewayPropsInterface';
|
|
3
|
-
export interface ApiContextInterface {
|
|
4
|
-
cores: any;
|
|
5
|
-
gateways: any;
|
|
6
|
-
req: any;
|
|
7
|
-
res: any;
|
|
8
|
-
requestId: any;
|
|
9
|
-
getCoreContext?(args: any): Promise<BaseCorePropsInterface>;
|
|
10
|
-
getGatewayContext?(args: any): Promise<BaseGatewayPropsInterface>;
|
|
11
|
-
extendContext?(args: any): any;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseCore } from '..';
|
|
2
|
-
export interface BaseCoreActionsInterface {
|
|
3
|
-
/**
|
|
4
|
-
* Reference to the core object that processes the request
|
|
5
|
-
*/
|
|
6
|
-
core: BaseCore;
|
|
7
|
-
/**
|
|
8
|
-
* Sets current step when processing an action
|
|
9
|
-
* @param str Name of step
|
|
10
|
-
*/
|
|
11
|
-
setStep?(str: string): void;
|
|
12
|
-
/**
|
|
13
|
-
* The sameRequest is true when we call a core method when handling the same request (actual for GraphQL resolvers)
|
|
14
|
-
*/
|
|
15
|
-
sameRequest?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The transaction is active when processing some of actions that configured to open transaction
|
|
18
|
-
*/
|
|
19
|
-
hasTransaction?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* The validatedItems exists after validator execution.
|
|
22
|
-
* It is expected that validator return an array in which second element is some
|
|
23
|
-
* items that were read from data or created otherwise during validation
|
|
24
|
-
*/
|
|
25
|
-
validatedItems?: any;
|
|
26
|
-
/**
|
|
27
|
-
* The exception object exists only when exception happened when processing an action
|
|
28
|
-
*/
|
|
29
|
-
exception?: any;
|
|
30
|
-
/**
|
|
31
|
-
* Name of action for exception error messages
|
|
32
|
-
*/
|
|
33
|
-
doingWhat?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Object with incoming request params
|
|
36
|
-
*/
|
|
37
|
-
args?: any;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface BaseCoreDoAuthOnActionInterface {
|
|
2
|
-
list?: boolean;
|
|
3
|
-
get?: boolean;
|
|
4
|
-
getMany?: boolean;
|
|
5
|
-
create?: boolean;
|
|
6
|
-
createMany?: boolean;
|
|
7
|
-
update?: boolean;
|
|
8
|
-
updateMany?: boolean;
|
|
9
|
-
set?: boolean;
|
|
10
|
-
remove?: boolean;
|
|
11
|
-
removeMany?: boolean;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface BaseCoreDoingWhatInterface {
|
|
2
|
-
list: string;
|
|
3
|
-
get: string;
|
|
4
|
-
getMany: string;
|
|
5
|
-
create: string;
|
|
6
|
-
createMany: string;
|
|
7
|
-
update: string;
|
|
8
|
-
updateMany: string;
|
|
9
|
-
set: string;
|
|
10
|
-
remove: string;
|
|
11
|
-
removeMany: string;
|
|
12
|
-
[key: string]: string;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@sdflc/utils';
|
|
2
|
-
import { Database } from '../Database';
|
|
3
|
-
import { BaseGateway } from '../BaseGateway';
|
|
4
|
-
import { BaseCoreValidatorsInterface } from './BaseCoreValidatorsInterface';
|
|
5
|
-
import { BaseCoreDoingWhatInterface } from './BaseCoreDoingWhatInterface';
|
|
6
|
-
import { VerifyUserTokenArgs } from './VerifyUserTokenArgs';
|
|
7
|
-
import { ApiContext } from './ApiContext';
|
|
8
|
-
import { ID_TYPES } from '../constants';
|
|
9
|
-
import { BaseCoreDoAuthOnActionInterface } from './BaseCoreDoAuthOnActionInterface';
|
|
10
|
-
export interface BaseCorePropsInterface {
|
|
11
|
-
/**
|
|
12
|
-
* Application API context with all necessary information about request
|
|
13
|
-
*/
|
|
14
|
-
context: ApiContext;
|
|
15
|
-
/**
|
|
16
|
-
* Database instance to handle queries to DB within one request
|
|
17
|
-
*/
|
|
18
|
-
db: Database;
|
|
19
|
-
/**
|
|
20
|
-
* Name of a gateway that will perform default CRUD operations, it should be initialized in the API context
|
|
21
|
-
*/
|
|
22
|
-
gatewayName: string;
|
|
23
|
-
isProduction: boolean;
|
|
24
|
-
logger: Logger;
|
|
25
|
-
name?: string;
|
|
26
|
-
doAuth: boolean;
|
|
27
|
-
doAuthOnAction?: BaseCoreDoAuthOnActionInterface;
|
|
28
|
-
doingWhat?: BaseCoreDoingWhatInterface;
|
|
29
|
-
validators?: BaseCoreValidatorsInterface;
|
|
30
|
-
spaceGw?: BaseGateway;
|
|
31
|
-
interserviceApiKey?: string;
|
|
32
|
-
jwtSecret?: string;
|
|
33
|
-
verifyTokenArgs?: VerifyUserTokenArgs;
|
|
34
|
-
hasOrderNo?: boolean;
|
|
35
|
-
orderNoAsDecimal?: boolean;
|
|
36
|
-
idType?: ID_TYPES;
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseCoreActionsInterface } from './BaseCoreActionsInterface';
|
|
2
|
-
export interface BaseCoreValidatorsInterface {
|
|
3
|
-
list?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
4
|
-
get?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
5
|
-
getMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
6
|
-
create?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
7
|
-
createMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
8
|
-
update?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
9
|
-
updateMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
10
|
-
set?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
11
|
-
remove?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
12
|
-
removeMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|