@nextage/omics-lib 1.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.
- package/build/constants.d.ts +57 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +24 -0
- package/build/constants.js.map +1 -0
- package/build/enums.d.ts +26 -0
- package/build/enums.d.ts.map +1 -0
- package/build/enums.js +44 -0
- package/build/enums.js.map +1 -0
- package/build/errors/app-error.d.ts +13 -0
- package/build/errors/app-error.d.ts.map +1 -0
- package/build/errors/app-error.js +18 -0
- package/build/errors/app-error.js.map +1 -0
- package/build/errors/authentication-error.d.ts +6 -0
- package/build/errors/authentication-error.d.ts.map +1 -0
- package/build/errors/authentication-error.js +11 -0
- package/build/errors/authentication-error.js.map +1 -0
- package/build/errors/custom-error.d.ts +9 -0
- package/build/errors/custom-error.d.ts.map +1 -0
- package/build/errors/custom-error.js +11 -0
- package/build/errors/custom-error.js.map +1 -0
- package/build/errors/forbidden-error.d.ts +6 -0
- package/build/errors/forbidden-error.d.ts.map +1 -0
- package/build/errors/forbidden-error.js +11 -0
- package/build/errors/forbidden-error.js.map +1 -0
- package/build/errors/index.d.ts +5 -0
- package/build/errors/index.d.ts.map +1 -0
- package/build/errors/index.js +21 -0
- package/build/errors/index.js.map +1 -0
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +23 -0
- package/build/index.js.map +1 -0
- package/build/interfaces.d.ts +54 -0
- package/build/interfaces.d.ts.map +1 -0
- package/build/interfaces.js +14 -0
- package/build/interfaces.js.map +1 -0
- package/build/models/genotype.d.ts +19 -0
- package/build/models/genotype.d.ts.map +1 -0
- package/build/models/genotype.js +34 -0
- package/build/models/genotype.js.map +1 -0
- package/build/models/index.d.ts +4 -0
- package/build/models/index.d.ts.map +1 -0
- package/build/models/index.js +20 -0
- package/build/models/index.js.map +1 -0
- package/build/models/sample.d.ts +19 -0
- package/build/models/sample.d.ts.map +1 -0
- package/build/models/sample.js +36 -0
- package/build/models/sample.js.map +1 -0
- package/build/models/variant.d.ts +19 -0
- package/build/models/variant.d.ts.map +1 -0
- package/build/models/variant.js +45 -0
- package/build/models/variant.js.map +1 -0
- package/build/routes/express.interfaces.d.ts +11 -0
- package/build/routes/express.interfaces.d.ts.map +1 -0
- package/build/routes/express.interfaces.js +10 -0
- package/build/routes/express.interfaces.js.map +1 -0
- package/build/routes/index.d.ts +3 -0
- package/build/routes/index.d.ts.map +1 -0
- package/build/routes/index.js +19 -0
- package/build/routes/index.js.map +1 -0
- package/build/routes/swagger.d.ts +13 -0
- package/build/routes/swagger.d.ts.map +1 -0
- package/build/routes/swagger.js +13 -0
- package/build/routes/swagger.js.map +1 -0
- package/build/routes/validators.d.ts +11 -0
- package/build/routes/validators.d.ts.map +1 -0
- package/build/routes/validators.js +17 -0
- package/build/routes/validators.js.map +1 -0
- package/build/services/index.d.ts +2 -0
- package/build/services/index.d.ts.map +1 -0
- package/build/services/index.js +18 -0
- package/build/services/index.js.map +1 -0
- package/build/services/password.d.ts +5 -0
- package/build/services/password.d.ts.map +1 -0
- package/build/services/password.js +20 -0
- package/build/services/password.js.map +1 -0
- package/build/types/genotype.d.ts +11 -0
- package/build/types/genotype.d.ts.map +1 -0
- package/build/types/genotype.js +3 -0
- package/build/types/genotype.js.map +1 -0
- package/build/types/index.d.ts +4 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +20 -0
- package/build/types/index.js.map +1 -0
- package/build/types/sample.d.ts +13 -0
- package/build/types/sample.d.ts.map +1 -0
- package/build/types/sample.js +3 -0
- package/build/types/sample.js.map +1 -0
- package/build/types/variant.d.ts +22 -0
- package/build/types/variant.d.ts.map +1 -0
- package/build/types/variant.js +3 -0
- package/build/types/variant.js.map +1 -0
- package/build/utils/express.d.ts +37 -0
- package/build/utils/express.d.ts.map +1 -0
- package/build/utils/express.js +114 -0
- package/build/utils/express.js.map +1 -0
- package/build/utils/functs.d.ts +46 -0
- package/build/utils/functs.d.ts.map +1 -0
- package/build/utils/functs.js +128 -0
- package/build/utils/functs.js.map +1 -0
- package/build/utils/index.d.ts +3 -0
- package/build/utils/index.d.ts.map +1 -0
- package/build/utils/index.js +19 -0
- package/build/utils/index.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.pathExists = pathExists;
|
|
7
|
+
exports.getAttr = getAttr;
|
|
8
|
+
exports.setAttr = setAttr;
|
|
9
|
+
exports.findFilesRecursive = findFilesRecursive;
|
|
10
|
+
exports.setTenant = setTenant;
|
|
11
|
+
exports.getTenant = getTenant;
|
|
12
|
+
exports.validateUrl = validateUrl;
|
|
13
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
14
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
15
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
16
|
+
const validator_1 = __importDefault(require("validator"));
|
|
17
|
+
// /**
|
|
18
|
+
// *
|
|
19
|
+
// * @param item
|
|
20
|
+
// * @returns
|
|
21
|
+
// */
|
|
22
|
+
// export function docToAttrs(item: BaseMongoDoc, getters: boolean = true): NxObject | null {
|
|
23
|
+
// const obj = item?.toObject({ getters });
|
|
24
|
+
// if (!obj)
|
|
25
|
+
// return null;
|
|
26
|
+
// obj.id = obj._id?.toString();
|
|
27
|
+
// return obj;
|
|
28
|
+
// }
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param path
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
async function pathExists(path = '') {
|
|
35
|
+
if (!path)
|
|
36
|
+
return false;
|
|
37
|
+
try {
|
|
38
|
+
await node_fs_1.default.promises.access(path);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param object
|
|
48
|
+
* @param path
|
|
49
|
+
*/
|
|
50
|
+
function getAttr(object, path) {
|
|
51
|
+
return lodash_1.default.get(object, path);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param object
|
|
56
|
+
* @param path
|
|
57
|
+
* @param value
|
|
58
|
+
*/
|
|
59
|
+
function setAttr(object, path, value) {
|
|
60
|
+
return lodash_1.default.set(object, path, value);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Scan recoursively a directory to find files ending with fname
|
|
64
|
+
* @param dir Directory to use to explore
|
|
65
|
+
*/
|
|
66
|
+
function findFilesRecursive(dir, fname) {
|
|
67
|
+
const initFiles = [];
|
|
68
|
+
const files = node_fs_1.default.readdirSync(dir);
|
|
69
|
+
for (const file of files) {
|
|
70
|
+
const fullPath = node_path_1.default.join(dir, file);
|
|
71
|
+
if (node_fs_1.default.statSync(fullPath).isDirectory())
|
|
72
|
+
initFiles.push(...findFilesRecursive(fullPath, fname)); // Recursion for subdirectories.
|
|
73
|
+
else if (file.includes(fname) && !file.includes('init.d.') && !file.endsWith('.map'))
|
|
74
|
+
initFiles.push(fullPath); // Adds file
|
|
75
|
+
}
|
|
76
|
+
return initFiles;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Sets the tenantId on the given payload based on the user's role and organizations.
|
|
80
|
+
* - Normal users: tenantId is always set to their first organization
|
|
81
|
+
* - Admin users (CONFIG_ROLES):
|
|
82
|
+
* - If applyDefaultForAdmin = false → can access all tenants
|
|
83
|
+
* - If applyDefaultForAdmin = true and tenantId not provided → tenantId set to first org (subset view)
|
|
84
|
+
*/
|
|
85
|
+
function setTenant(item, user, applyDefaultForAdmin = false) {
|
|
86
|
+
// const isAdmin = user?.hasRole(CONFIG_ROLES);
|
|
87
|
+
// // Admins who can see all tenants or already have tenantId specified → exit
|
|
88
|
+
// if (isAdmin && (!applyDefaultForAdmin || item.tenantId))
|
|
89
|
+
// return;
|
|
90
|
+
// if (!user?.organizations?.length)
|
|
91
|
+
// throw new Error('Cannot proceed: organization not set');
|
|
92
|
+
// // Admin with applyDefaultForAdmin=true and tenantId absent
|
|
93
|
+
// // OR normal user → force tenantId
|
|
94
|
+
// item.tenantId = user.organizations[0].id;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param user
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
function getTenant(user) {
|
|
102
|
+
return '';
|
|
103
|
+
// if (!user?.organizations?.length)
|
|
104
|
+
// throw new Error('Cannot proceed: organization not set');
|
|
105
|
+
// return user.organizations[0].id;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param input
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
function validateUrl(input) {
|
|
113
|
+
if (!validator_1.default.isURL(input, {
|
|
114
|
+
protocols: ['http', 'https'],
|
|
115
|
+
require_protocol: true,
|
|
116
|
+
require_valid_protocol: true,
|
|
117
|
+
allow_underscores: false,
|
|
118
|
+
allow_trailing_dot: false,
|
|
119
|
+
allow_protocol_relative_urls: false
|
|
120
|
+
})) {
|
|
121
|
+
throw new Error('Invalid URL');
|
|
122
|
+
}
|
|
123
|
+
const parsed = new URL(input);
|
|
124
|
+
if (parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1')
|
|
125
|
+
throw new Error('Forbidden URL');
|
|
126
|
+
return parsed.toString();
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=functs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functs.js","sourceRoot":"","sources":["../../src/utils/functs.ts"],"names":[],"mappings":";;;;;AA6BA,gCAYC;AAOD,0BAGC;AAQD,0BAGC;AAMD,gDAgBC;AASD,8BAcC;AA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e,CAAC,CAAC;IAEnC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./express"), exports);
|
|
18
|
+
__exportStar(require("./functs"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nextage/omics-lib",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"main": "./build/index.js",
|
|
5
|
+
"types": "./build/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"build/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "del ./build/*",
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"pub": "git add . && git commit -m \"App Library updates\" && npm version patch && npm run build && npm publish"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"description": "",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@types/cookie-parser": "^1.4.7",
|
|
20
|
+
"@types/csurf": "^1.11.5",
|
|
21
|
+
"@types/express": "^4.17.21",
|
|
22
|
+
"@types/express-jwt": "^7.4.2",
|
|
23
|
+
"@types/express-rate-limit": "^6.0.0",
|
|
24
|
+
"@types/express-session": "^1.18.2",
|
|
25
|
+
"@types/express-validator": "^3.0.0",
|
|
26
|
+
"@types/helmet": "^4.0.0",
|
|
27
|
+
"@types/i18n": "^0.13.12",
|
|
28
|
+
"@types/lodash": "^4.17.24",
|
|
29
|
+
"@types/morgan": "^1.9.9",
|
|
30
|
+
"@types/passport": "^1.0.16",
|
|
31
|
+
"@types/passport-local": "^1.0.38",
|
|
32
|
+
"@types/validator": "^13.15.10",
|
|
33
|
+
"@types/winston": "^2.4.4",
|
|
34
|
+
"@types/ws": "^8.5.12",
|
|
35
|
+
"cookie-parser": "^1.4.6",
|
|
36
|
+
"csurf": "^1.11.0",
|
|
37
|
+
"dotenv": "^16.4.5",
|
|
38
|
+
"express": "^4.19.2",
|
|
39
|
+
"express-jwt": "^8.4.1",
|
|
40
|
+
"express-rate-limit": "^7.4.0",
|
|
41
|
+
"express-session": "^1.18.2",
|
|
42
|
+
"express-validator": "^7.3.1",
|
|
43
|
+
"flatted": "^3.3.1",
|
|
44
|
+
"helmet": "^7.1.0",
|
|
45
|
+
"i18n": "^0.15.1",
|
|
46
|
+
"lodash": "^4.17.23",
|
|
47
|
+
"mongoose": "^9.3.0",
|
|
48
|
+
"mongoose-update-if-current": "^1.4.0",
|
|
49
|
+
"morgan": "^1.10.0",
|
|
50
|
+
"nats": "^2.29.3",
|
|
51
|
+
"openid-client": "^5.7.1",
|
|
52
|
+
"passport": "^0.7.0",
|
|
53
|
+
"passport-local": "^1.0.0",
|
|
54
|
+
"ts-node-dev": "^2.0.0",
|
|
55
|
+
"typescript": "^5.8.3",
|
|
56
|
+
"validator": "^13.15.26",
|
|
57
|
+
"winston": "^3.14.2",
|
|
58
|
+
"ws": "^8.18.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/jest": "^30.0.0",
|
|
62
|
+
"del-cli": "^6.0.0",
|
|
63
|
+
"jest": "^30.0.5",
|
|
64
|
+
"mongodb-memory-server": "^10.1.4"
|
|
65
|
+
}
|
|
66
|
+
}
|