@sdflc/backend-helpers 1.0.82 → 1.0.84
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/build/BaseCore.js +1 -1
- package/build/{DbMigratorAndSeeder.js → dbMigratorAndSeeder.js} +20 -0
- package/build/dbTableHelpers.d.ts +3 -1
- package/build/esm/BaseCore.js +1 -1
- package/build/esm/{DbMigratorAndSeeder.js → dbMigratorAndSeeder.js} +20 -0
- package/build/esm/dbTableHelpers.d.ts +3 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/knexConfigBuilder.js +5 -4
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/knexConfigBuilder.js +5 -4
- package/package.json +9 -9
- /package/build/{DbMigratorAndSeeder.d.ts → dbMigratorAndSeeder.d.ts} +0 -0
- /package/build/esm/{DbMigratorAndSeeder.d.ts → dbMigratorAndSeeder.d.ts} +0 -0
package/build/BaseCore.js
CHANGED
|
@@ -612,7 +612,7 @@ class BaseCore {
|
|
|
612
612
|
}
|
|
613
613
|
async extractCredentials(args) {
|
|
614
614
|
const { req, space, authorization } = args;
|
|
615
|
-
const token = req.cookies?.[space.cookieName] || authorization;
|
|
615
|
+
const token = req.cookies?.[space.cookieName] || req.headers?.[constants_1.HEADERS.AUTHORIZATION] || authorization;
|
|
616
616
|
const fingerprint = req.cookies?.[space.fingerprintCookieName] || req.headers?.[constants_1.HEADERS.FINGERPRINT] || args.fingerprint || '';
|
|
617
617
|
return {
|
|
618
618
|
token,
|
|
@@ -62,6 +62,26 @@ const SQLS = {
|
|
|
62
62
|
FROM INFORMATION_SCHEMA.TABLES';
|
|
63
63
|
`,
|
|
64
64
|
},
|
|
65
|
+
mssql: {
|
|
66
|
+
listTablesSchema: (appSettings) => `
|
|
67
|
+
SELECT TABLE_NAME as table_name
|
|
68
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
69
|
+
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
70
|
+
`,
|
|
71
|
+
listTables: () => `
|
|
72
|
+
SELECT TABLE_NAME as table_name
|
|
73
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
74
|
+
`,
|
|
75
|
+
dropTablesSchema: (appSettings) => `
|
|
76
|
+
SELECT 'DROP TABLE IF EXISTS [${appSettings?.dbSchema}].[' + TABLE_NAME + '];' as cmd
|
|
77
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
78
|
+
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
79
|
+
`,
|
|
80
|
+
dropTables: () => `
|
|
81
|
+
SELECT 'DROP TABLE IF EXISTS ' + TABLE_NAME + ';' as cmd
|
|
82
|
+
FROM INFORMATION_SCHEMA.TABLES';
|
|
83
|
+
`,
|
|
84
|
+
},
|
|
65
85
|
};
|
|
66
86
|
class DbMigratorAndSeeder {
|
|
67
87
|
knexHandle;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DbFieldAddDefaultInterface } from './interfaces';
|
|
2
|
+
import { FIELDS } from './constants';
|
|
2
3
|
export declare const dbFieldAddDefaults: (table: any, opt?: DbFieldAddDefaultInterface) => void;
|
|
3
4
|
export declare const addOrderNo: (table: any, opt?: any) => any;
|
|
4
5
|
export declare const addAmount: (table: any, fieldName: string) => any;
|
|
@@ -7,5 +8,6 @@ export declare const addUserId: (table: any, opt?: any) => any;
|
|
|
7
8
|
export declare const addAccountId: (table: any, opt?: any) => any;
|
|
8
9
|
export declare const addLang: (table: any, opt?: any) => any;
|
|
9
10
|
export declare const defaultFields: (opt?: any) => {
|
|
10
|
-
[
|
|
11
|
+
[FIELDS.CREATED_AT]: string;
|
|
12
|
+
[FIELDS.UPDATED_AT]: string;
|
|
11
13
|
};
|
package/build/esm/BaseCore.js
CHANGED
|
@@ -606,7 +606,7 @@ class BaseCore {
|
|
|
606
606
|
}
|
|
607
607
|
async extractCredentials(args) {
|
|
608
608
|
const { req, space, authorization } = args;
|
|
609
|
-
const token = req.cookies?.[space.cookieName] || authorization;
|
|
609
|
+
const token = req.cookies?.[space.cookieName] || req.headers?.[HEADERS.AUTHORIZATION] || authorization;
|
|
610
610
|
const fingerprint = req.cookies?.[space.fingerprintCookieName] || req.headers?.[HEADERS.FINGERPRINT] || args.fingerprint || '';
|
|
611
611
|
return {
|
|
612
612
|
token,
|
|
@@ -23,6 +23,26 @@ const SQLS = {
|
|
|
23
23
|
FROM INFORMATION_SCHEMA.TABLES';
|
|
24
24
|
`,
|
|
25
25
|
},
|
|
26
|
+
mssql: {
|
|
27
|
+
listTablesSchema: (appSettings) => `
|
|
28
|
+
SELECT TABLE_NAME as table_name
|
|
29
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
30
|
+
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
31
|
+
`,
|
|
32
|
+
listTables: () => `
|
|
33
|
+
SELECT TABLE_NAME as table_name
|
|
34
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
35
|
+
`,
|
|
36
|
+
dropTablesSchema: (appSettings) => `
|
|
37
|
+
SELECT 'DROP TABLE IF EXISTS [${appSettings?.dbSchema}].[' + TABLE_NAME + '];' as cmd
|
|
38
|
+
FROM INFORMATION_SCHEMA.TABLES
|
|
39
|
+
WHERE TABLE_SCHEMA = '${appSettings?.dbSchema}';
|
|
40
|
+
`,
|
|
41
|
+
dropTables: () => `
|
|
42
|
+
SELECT 'DROP TABLE IF EXISTS ' + TABLE_NAME + ';' as cmd
|
|
43
|
+
FROM INFORMATION_SCHEMA.TABLES';
|
|
44
|
+
`,
|
|
45
|
+
},
|
|
26
46
|
};
|
|
27
47
|
class DbMigratorAndSeeder {
|
|
28
48
|
knexHandle;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DbFieldAddDefaultInterface } from './interfaces';
|
|
2
|
+
import { FIELDS } from './constants';
|
|
2
3
|
export declare const dbFieldAddDefaults: (table: any, opt?: DbFieldAddDefaultInterface) => void;
|
|
3
4
|
export declare const addOrderNo: (table: any, opt?: any) => any;
|
|
4
5
|
export declare const addAmount: (table: any, fieldName: string) => any;
|
|
@@ -7,5 +8,6 @@ export declare const addUserId: (table: any, opt?: any) => any;
|
|
|
7
8
|
export declare const addAccountId: (table: any, opt?: any) => any;
|
|
8
9
|
export declare const addLang: (table: any, opt?: any) => any;
|
|
9
10
|
export declare const defaultFields: (opt?: any) => {
|
|
10
|
-
[
|
|
11
|
+
[FIELDS.CREATED_AT]: string;
|
|
12
|
+
[FIELDS.UPDATED_AT]: string;
|
|
11
13
|
};
|
package/build/esm/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './interfaces';
|
|
|
3
3
|
export * from './configBulder';
|
|
4
4
|
export * from './Database';
|
|
5
5
|
export * from './dbHelpers';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './dbMigratorAndSeeder';
|
|
7
7
|
export * from './dbSeeder';
|
|
8
8
|
export * from './knexConfigBuilder';
|
|
9
9
|
export * from './redisClient';
|
package/build/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export * from './interfaces';
|
|
|
3
3
|
export * from './configBulder';
|
|
4
4
|
export * from './Database';
|
|
5
5
|
export * from './dbHelpers';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './dbMigratorAndSeeder';
|
|
7
7
|
export * from './dbSeeder';
|
|
8
8
|
export * from './knexConfigBuilder';
|
|
9
9
|
export * from './redisClient';
|
|
@@ -53,10 +53,11 @@ export const buildKnexConfig = (dirName, appConfig) => {
|
|
|
53
53
|
...sharedConfig,
|
|
54
54
|
debug,
|
|
55
55
|
migrations: {
|
|
56
|
+
// https://knexjs.org/guide/migrations.html#migration-api
|
|
56
57
|
stub: path.join(dirName, migrationsTemplateFileName || defaultMigrationsTemplateFileName),
|
|
57
58
|
directory: path.join(dirName, migrationsFolder || defaultMigrationsFolder),
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
schemaName: useSchemaForMigrationsTable ? dbSchema : undefined,
|
|
60
|
+
tableName: migrationsTable || defaultMigrationsTable,
|
|
60
61
|
},
|
|
61
62
|
seeds: {
|
|
62
63
|
directory: path.join(dirName, seedsFolderDev || seedsFolder || defaultSeedsFolder),
|
|
@@ -67,8 +68,8 @@ export const buildKnexConfig = (dirName, appConfig) => {
|
|
|
67
68
|
debug,
|
|
68
69
|
migrations: {
|
|
69
70
|
directory: path.join(dirName, migrationsFolder || defaultMigrationsFolder),
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
schemaName: useSchemaForMigrationsTable ? dbSchema : undefined,
|
|
72
|
+
tableName: migrationsTable || defaultMigrationsTable,
|
|
72
73
|
},
|
|
73
74
|
seeds: {
|
|
74
75
|
directory: path.join(dirName, seedsFolderProd || seedsFolder || defaultSeedsFolder),
|
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './interfaces';
|
|
|
3
3
|
export * from './configBulder';
|
|
4
4
|
export * from './Database';
|
|
5
5
|
export * from './dbHelpers';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './dbMigratorAndSeeder';
|
|
7
7
|
export * from './dbSeeder';
|
|
8
8
|
export * from './knexConfigBuilder';
|
|
9
9
|
export * from './redisClient';
|
package/build/index.js
CHANGED
|
@@ -19,7 +19,7 @@ __exportStar(require("./interfaces"), exports);
|
|
|
19
19
|
__exportStar(require("./configBulder"), exports);
|
|
20
20
|
__exportStar(require("./Database"), exports);
|
|
21
21
|
__exportStar(require("./dbHelpers"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./dbMigratorAndSeeder"), exports);
|
|
23
23
|
__exportStar(require("./dbSeeder"), exports);
|
|
24
24
|
__exportStar(require("./knexConfigBuilder"), exports);
|
|
25
25
|
__exportStar(require("./redisClient"), exports);
|
|
@@ -59,10 +59,11 @@ const buildKnexConfig = (dirName, appConfig) => {
|
|
|
59
59
|
...sharedConfig,
|
|
60
60
|
debug,
|
|
61
61
|
migrations: {
|
|
62
|
+
// https://knexjs.org/guide/migrations.html#migration-api
|
|
62
63
|
stub: path_1.default.join(dirName, migrationsTemplateFileName || defaultMigrationsTemplateFileName),
|
|
63
64
|
directory: path_1.default.join(dirName, migrationsFolder || defaultMigrationsFolder),
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
schemaName: useSchemaForMigrationsTable ? dbSchema : undefined,
|
|
66
|
+
tableName: migrationsTable || defaultMigrationsTable,
|
|
66
67
|
},
|
|
67
68
|
seeds: {
|
|
68
69
|
directory: path_1.default.join(dirName, seedsFolderDev || seedsFolder || defaultSeedsFolder),
|
|
@@ -73,8 +74,8 @@ const buildKnexConfig = (dirName, appConfig) => {
|
|
|
73
74
|
debug,
|
|
74
75
|
migrations: {
|
|
75
76
|
directory: path_1.default.join(dirName, migrationsFolder || defaultMigrationsFolder),
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
schemaName: useSchemaForMigrationsTable ? dbSchema : undefined,
|
|
78
|
+
tableName: migrationsTable || defaultMigrationsTable,
|
|
78
79
|
},
|
|
79
80
|
seeds: {
|
|
80
81
|
directory: path_1.default.join(dirName, seedsFolderProd || seedsFolder || defaultSeedsFolder),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdflc/backend-helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.84",
|
|
4
4
|
"description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"exports": {
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"@types/lodash": "^4.17.15",
|
|
42
42
|
"@types/node": "^22.13.4",
|
|
43
43
|
"@types/uuid": "^10.0.0",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
45
|
-
"@typescript-eslint/parser": "^8.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
45
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
46
46
|
"eslint": "^9.20.1",
|
|
47
|
-
"eslint-config-prettier": "^10.
|
|
47
|
+
"eslint-config-prettier": "^10.1.2",
|
|
48
48
|
"eslint-plugin-jest": "^28.11.0",
|
|
49
|
-
"eslint-plugin-prettier": "^5.2.
|
|
49
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
51
|
"jest": "^29.7.0",
|
|
52
|
-
"prettier": "^3.5.
|
|
52
|
+
"prettier": "^3.5.3",
|
|
53
53
|
"rimraf": "^6.0.1",
|
|
54
54
|
"run-script-os": "^1.1.6",
|
|
55
|
-
"ts-jest": "^29.2
|
|
55
|
+
"ts-jest": "^29.3.2",
|
|
56
56
|
"ts-node": "^10.9.2",
|
|
57
|
-
"typescript": "^5.
|
|
57
|
+
"typescript": "^5.8.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@sdflc/api-helpers": "^1.1.13",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"jsonwebtoken": "^9.0.2",
|
|
72
72
|
"knex": "^3.1.0",
|
|
73
73
|
"lodash": "^4.17.21",
|
|
74
|
-
"pg": "^8.
|
|
74
|
+
"pg": "^8.14.1",
|
|
75
75
|
"redis": "^4.7.0",
|
|
76
76
|
"uuid": "^11.1.0"
|
|
77
77
|
}
|
|
File without changes
|
|
File without changes
|