@platform-modules/foreign-ministry 1.3.342 → 1.3.350
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/.env +4 -4
- package/dist/helpers/employee-evaluation-request.utils.d.ts +6 -0
- package/dist/helpers/employee-evaluation-request.utils.js +83 -5
- package/dist/helpers/sla-request-status.helper.d.ts +3 -0
- package/dist/helpers/sla-request-status.helper.js +36 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/dist/models/EmbassyEvaluationDepartmentSettingModel.d.ts +14 -0
- package/dist/models/EmbassyEvaluationDepartmentSettingModel.js +56 -0
- package/dist/models/EmployeeEvaluationRequestModel.d.ts +1 -0
- package/dist/models/EmployeeEvaluationRequestModel.js +4 -0
- package/dist/models/EvaluationMastersModel.d.ts +16 -0
- package/dist/models/EvaluationMastersModel.js +67 -0
- package/dist/models/EvaluationQuestionMasterModel.d.ts +10 -0
- package/dist/models/EvaluationQuestionMasterModel.js +42 -0
- package/dist/models/EvaluationSectionMasterModel.d.ts +7 -0
- package/dist/models/EvaluationSectionMasterModel.js +36 -0
- package/dist/models/EvaluationWorkflowModel.d.ts +60 -0
- package/dist/models/EvaluationWorkflowModel.js +215 -0
- package/dist/models/IneligibleForEvaluationModel.d.ts +8 -0
- package/dist/models/IneligibleForEvaluationModel.js +44 -0
- package/dist/models/MissionTravelClassConfigModel.d.ts +10 -0
- package/dist/models/MissionTravelClassConfigModel.js +50 -0
- package/dist/models/MissionTravelPerdiemModel.d.ts +10 -0
- package/dist/models/MissionTravelPerdiemModel.js +54 -0
- package/dist/models/SlaApprovalsViewModel.js +47 -47
- package/dist/models/SlaMyRequestsViewModel.js +52 -52
- package/dist/models/UuidAuditModel.d.ts +9 -0
- package/dist/models/UuidAuditModel.js +41 -0
- package/package.json +1 -1
- package/scripts/check-column-types.js +38 -38
- package/scripts/check-service-tables.js +42 -42
- package/scripts/sync-sla-reports-sql.js +92 -92
- package/sql/add_employee_evaluation_requests_is_draft.sql +2 -0
- package/sql/sla-reports-sync.manifest.json +9 -9
- package/sql/sla_reports_admin_procedures.sql +304 -304
- package/sql/sla_reports_approvals_workbook.sql +383 -383
- package/sql/sla_reports_procedures.sql +886 -886
- package/sql/sla_requests_status_to_varchar.sql +28 -28
- package/sql/vw_sla_approvals.sql +108 -108
- package/sql/vw_sla_my_requests.sql +55 -55
- package/src/data-source.ts +686 -686
- package/src/helpers/employee-evaluation-request.utils.ts +87 -7
- package/src/helpers/evaluation-eligibility.utils.ts +126 -126
- package/src/index.ts +1 -0
- package/src/models/DiplomaticAcademyRequestModel.ts +80 -80
- package/src/models/DocumentationFileModel.ts +40 -40
- package/src/models/EmbassyEvaluationCycleModel.ts +45 -45
- package/src/models/EmbassyEvaluationRequestModel.ts +59 -59
- package/src/models/EmployeeEvaluationAnswerModel.ts +26 -26
- package/src/models/EmployeeEvaluationRequestModel.ts +3 -0
- package/src/models/EvaluationEligibilitySettingModel.ts +51 -51
- package/src/models/EvaluationFormModel.ts +44 -44
- package/src/models/LanguageCourseRequestModel.ts +67 -67
- package/src/models/LeaveApprovalsModel.ts +66 -66
- package/src/models/LeaveConfigModel.ts +71 -71
- package/src/models/MissionTravelApprovalModel.ts +101 -101
- package/src/models/MissionTravelAttachmentModel.ts +56 -56
- package/src/models/MissionTravelChatModel.ts +52 -52
- package/src/models/MissionTravelPersonModel.ts +105 -105
- package/src/models/MissionTravelWorkflowModel.ts +54 -54
- package/src/models/ProjectContactsModel.ts +51 -51
- package/src/models/ProjectFaqModel.ts +36 -36
- package/src/models/ProjectInvoicesModel.ts +41 -41
- package/src/models/ProjectModel.ts +75 -75
- package/src/models/ProjectTasksModel.ts +75 -75
- package/src/models/ServiceSlaApprovalModel.ts +63 -63
- package/src/models/ServicesNotificationConfigsModel.ts +55 -55
- package/src/models/SlaApprovalsViewModel.ts +135 -135
- package/src/models/SlaMyRequestsViewModel.ts +172 -172
- package/src/models/SlaRequestModel.ts +57 -57
- package/src/sla-report-views.ts +3 -3
- package/dist/auth/authenticate-jwt-session.d.ts +0 -19
- package/dist/auth/authenticate-jwt-session.js +0 -35
- package/dist/auth/jwt-token.helper.d.ts +0 -18
- package/dist/auth/jwt-token.helper.js +0 -58
- package/dist/auth/user-session-validation.d.ts +0 -42
- package/dist/auth/user-session-validation.js +0 -95
- package/dist/i18n/workflow-chat-i18n.d.ts +0 -5
- package/dist/i18n/workflow-chat-i18n.js +0 -21
- package/dist/i18n/workflow-chat-i18n.json +0 -320
- package/dist/i18n/workflow-chat-message.builder.d.ts +0 -325
- package/dist/i18n/workflow-chat-message.builder.js +0 -924
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UuidAuditModel = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
/** UUID primary key + audit columns + soft delete via deleted_at. */
|
|
15
|
+
class UuidAuditModel {
|
|
16
|
+
}
|
|
17
|
+
exports.UuidAuditModel = UuidAuditModel;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], UuidAuditModel.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 128, nullable: false, default: '' }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], UuidAuditModel.prototype, "created_by", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.CreateDateColumn)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
|
|
28
|
+
__metadata("design:type", Date)
|
|
29
|
+
], UuidAuditModel.prototype, "created_at", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: 'varchar', length: 128, nullable: true }),
|
|
32
|
+
__metadata("design:type", Object)
|
|
33
|
+
], UuidAuditModel.prototype, "updated_by", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.UpdateDateColumn)({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' }),
|
|
36
|
+
__metadata("design:type", Date)
|
|
37
|
+
], UuidAuditModel.prototype, "updated_at", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.DeleteDateColumn)({ type: 'timestamptz', nullable: true }),
|
|
40
|
+
__metadata("design:type", Object)
|
|
41
|
+
], UuidAuditModel.prototype, "deleted_at", void 0);
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
const dotenv = require('dotenv');
|
|
2
|
-
const { Client } = require('pg');
|
|
3
|
-
|
|
4
|
-
dotenv.config({ path: '../Reports_Service/.env' });
|
|
5
|
-
dotenv.config({ path: '.env', override: true });
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
const client = new Client({
|
|
9
|
-
host: process.env.DB_HOST.trim(),
|
|
10
|
-
port: 5432,
|
|
11
|
-
user: process.env.DB_USER.trim(),
|
|
12
|
-
password: process.env.DB_PASS,
|
|
13
|
-
database: process.env.DB_NAME.trim(),
|
|
14
|
-
});
|
|
15
|
-
await client.connect();
|
|
16
|
-
|
|
17
|
-
const tables = ['sla_requests', 'users', 'departments', 'sections', 'fm_services', 'fm_sub_services'];
|
|
18
|
-
for (const table of tables) {
|
|
19
|
-
const { rows } = await client.query(
|
|
20
|
-
`SELECT column_name, data_type
|
|
21
|
-
FROM information_schema.columns
|
|
22
|
-
WHERE table_schema = 'public' AND table_name = $1
|
|
23
|
-
ORDER BY ordinal_position`,
|
|
24
|
-
[table]
|
|
25
|
-
);
|
|
26
|
-
console.log(`\n${table}:`);
|
|
27
|
-
for (const row of rows) {
|
|
28
|
-
console.log(` ${row.column_name}: ${row.data_type}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await client.end();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
main().catch((err) => {
|
|
36
|
-
console.error(err.message);
|
|
37
|
-
process.exit(1);
|
|
38
|
-
});
|
|
1
|
+
const dotenv = require('dotenv');
|
|
2
|
+
const { Client } = require('pg');
|
|
3
|
+
|
|
4
|
+
dotenv.config({ path: '../Reports_Service/.env' });
|
|
5
|
+
dotenv.config({ path: '.env', override: true });
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
const client = new Client({
|
|
9
|
+
host: process.env.DB_HOST.trim(),
|
|
10
|
+
port: 5432,
|
|
11
|
+
user: process.env.DB_USER.trim(),
|
|
12
|
+
password: process.env.DB_PASS,
|
|
13
|
+
database: process.env.DB_NAME.trim(),
|
|
14
|
+
});
|
|
15
|
+
await client.connect();
|
|
16
|
+
|
|
17
|
+
const tables = ['sla_requests', 'users', 'departments', 'sections', 'fm_services', 'fm_sub_services'];
|
|
18
|
+
for (const table of tables) {
|
|
19
|
+
const { rows } = await client.query(
|
|
20
|
+
`SELECT column_name, data_type
|
|
21
|
+
FROM information_schema.columns
|
|
22
|
+
WHERE table_schema = 'public' AND table_name = $1
|
|
23
|
+
ORDER BY ordinal_position`,
|
|
24
|
+
[table]
|
|
25
|
+
);
|
|
26
|
+
console.log(`\n${table}:`);
|
|
27
|
+
for (const row of rows) {
|
|
28
|
+
console.log(` ${row.column_name}: ${row.data_type}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await client.end();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main().catch((err) => {
|
|
36
|
+
console.error(err.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const dotenv = require('dotenv');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { Client } = require('pg');
|
|
4
|
-
|
|
5
|
-
async function listTables(label, config) {
|
|
6
|
-
const client = new Client(config);
|
|
7
|
-
await client.connect();
|
|
8
|
-
const { rows } = await client.query(`
|
|
9
|
-
SELECT table_name
|
|
10
|
-
FROM information_schema.tables
|
|
11
|
-
WHERE table_schema = 'public'
|
|
12
|
-
AND (table_name LIKE '%service%' OR table_name LIKE 'sla%')
|
|
13
|
-
ORDER BY table_name
|
|
14
|
-
`);
|
|
15
|
-
console.log(`${label} (${config.database}):`, rows.map((r) => r.table_name).join(', ') || '(none)');
|
|
16
|
-
await client.end();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function main() {
|
|
20
|
-
dotenv.config({ path: path.join(__dirname, '..', '.env') });
|
|
21
|
-
await listTables('FM shared_models/.env', {
|
|
22
|
-
host: process.env.DB_HOST.trim(),
|
|
23
|
-
port: 5432,
|
|
24
|
-
user: process.env.DB_USER.trim(),
|
|
25
|
-
password: process.env.DB_PASS,
|
|
26
|
-
database: process.env.DB_NAME.trim(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
dotenv.config({ path: path.join(__dirname, '..', '..', 'Reports_Service', '.env') });
|
|
30
|
-
await listTables('Reports_Service/.env', {
|
|
31
|
-
host: (process.env.TYPEORM_HOST || '').trim(),
|
|
32
|
-
port: 5432,
|
|
33
|
-
user: (process.env.TYPEORM_USERNAME || '').trim(),
|
|
34
|
-
password: process.env.TYPEORM_PASSWORD,
|
|
35
|
-
database: (process.env.TYPEORM_DATABASE || '').trim(),
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
main().catch((err) => {
|
|
40
|
-
console.error(err.message);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
});
|
|
1
|
+
const dotenv = require('dotenv');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { Client } = require('pg');
|
|
4
|
+
|
|
5
|
+
async function listTables(label, config) {
|
|
6
|
+
const client = new Client(config);
|
|
7
|
+
await client.connect();
|
|
8
|
+
const { rows } = await client.query(`
|
|
9
|
+
SELECT table_name
|
|
10
|
+
FROM information_schema.tables
|
|
11
|
+
WHERE table_schema = 'public'
|
|
12
|
+
AND (table_name LIKE '%service%' OR table_name LIKE 'sla%')
|
|
13
|
+
ORDER BY table_name
|
|
14
|
+
`);
|
|
15
|
+
console.log(`${label} (${config.database}):`, rows.map((r) => r.table_name).join(', ') || '(none)');
|
|
16
|
+
await client.end();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function main() {
|
|
20
|
+
dotenv.config({ path: path.join(__dirname, '..', '.env') });
|
|
21
|
+
await listTables('FM shared_models/.env', {
|
|
22
|
+
host: process.env.DB_HOST.trim(),
|
|
23
|
+
port: 5432,
|
|
24
|
+
user: process.env.DB_USER.trim(),
|
|
25
|
+
password: process.env.DB_PASS,
|
|
26
|
+
database: process.env.DB_NAME.trim(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
dotenv.config({ path: path.join(__dirname, '..', '..', 'Reports_Service', '.env') });
|
|
30
|
+
await listTables('Reports_Service/.env', {
|
|
31
|
+
host: (process.env.TYPEORM_HOST || '').trim(),
|
|
32
|
+
port: 5432,
|
|
33
|
+
user: (process.env.TYPEORM_USERNAME || '').trim(),
|
|
34
|
+
password: process.env.TYPEORM_PASSWORD,
|
|
35
|
+
database: (process.env.TYPEORM_DATABASE || '').trim(),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main().catch((err) => {
|
|
40
|
+
console.error(err.message);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
});
|
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Applies SLA report views + stored procedures to PostgreSQL (idempotent CREATE OR REPLACE).
|
|
3
|
-
*
|
|
4
|
-
* Env from shared_models/.env only:
|
|
5
|
-
* DB_HOST / TYPEORM_HOST
|
|
6
|
-
* DB_PORT / TYPEORM_PORT
|
|
7
|
-
* DB_USER / TYPEORM_USERNAME
|
|
8
|
-
* DB_PASS / TYPEORM_PASSWORD
|
|
9
|
-
* DB_NAME / TYPEORM_DATABASE
|
|
10
|
-
*
|
|
11
|
-
* Usage:
|
|
12
|
-
* node scripts/sync-sla-reports-sql.js
|
|
13
|
-
* npm run sync:sla-sql (from shared_models)
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const fs = require('fs');
|
|
17
|
-
const path = require('path');
|
|
18
|
-
const { Client } = require('pg');
|
|
19
|
-
|
|
20
|
-
function loadEnvFiles() {
|
|
21
|
-
const dotenv = require('dotenv');
|
|
22
|
-
const packageRoot = path.resolve(__dirname, '..');
|
|
23
|
-
const packageEnv = path.join(packageRoot, '.env');
|
|
24
|
-
|
|
25
|
-
if (!fs.existsSync(packageEnv)) {
|
|
26
|
-
throw new Error(`Missing env file: ${packageEnv}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
dotenv.config({ path: packageEnv, override: true });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getDbConfig() {
|
|
33
|
-
const host = (process.env.DB_HOST || process.env.TYPEORM_HOST || '').trim();
|
|
34
|
-
const port = parseInt(process.env.DB_PORT || process.env.TYPEORM_PORT || '5432', 10);
|
|
35
|
-
const user = (process.env.DB_USER || process.env.TYPEORM_USERNAME || '').trim();
|
|
36
|
-
const password = process.env.DB_PASS || process.env.TYPEORM_PASSWORD || '';
|
|
37
|
-
const database = (process.env.DB_NAME || process.env.TYPEORM_DATABASE || '').trim();
|
|
38
|
-
|
|
39
|
-
if (!host || !user || !database) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
'Missing DB config. Set DB_HOST, DB_USER, DB_NAME (and DB_PASS) in shared_models/.env'
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return { host, port, user, password, database };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function main() {
|
|
49
|
-
const skipSync = process.argv.includes('--skip');
|
|
50
|
-
if (skipSync || process.env.SKIP_SLA_SQL_SYNC === 'true') {
|
|
51
|
-
console.log('[sync-sla-reports-sql] skipped (SKIP_SLA_SQL_SYNC or --skip)');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
loadEnvFiles();
|
|
56
|
-
const config = getDbConfig();
|
|
57
|
-
const sqlDir = path.join(__dirname, '..', 'sql');
|
|
58
|
-
const manifestPath = path.join(sqlDir, 'sla-reports-sync.manifest.json');
|
|
59
|
-
|
|
60
|
-
if (!fs.existsSync(manifestPath)) {
|
|
61
|
-
throw new Error(`Manifest not found: ${manifestPath}`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const files = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
65
|
-
if (!Array.isArray(files) || files.length === 0) {
|
|
66
|
-
throw new Error('sla-reports-sync.manifest.json must be a non-empty array');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const client = new Client(config);
|
|
70
|
-
await client.connect();
|
|
71
|
-
console.log(`[sync-sla-reports-sql] connected to ${config.host}/${config.database}`);
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
for (const file of files) {
|
|
75
|
-
const filePath = path.join(sqlDir, file);
|
|
76
|
-
if (!fs.existsSync(filePath)) {
|
|
77
|
-
throw new Error(`SQL file missing: ${filePath}`);
|
|
78
|
-
}
|
|
79
|
-
const sql = fs.readFileSync(filePath, 'utf8');
|
|
80
|
-
await client.query(sql);
|
|
81
|
-
console.log(`[sync-sla-reports-sql] applied ${file}`);
|
|
82
|
-
}
|
|
83
|
-
console.log('[sync-sla-reports-sql] done');
|
|
84
|
-
} finally {
|
|
85
|
-
await client.end();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
main().catch((err) => {
|
|
90
|
-
console.error('[sync-sla-reports-sql] failed:', err.message);
|
|
91
|
-
process.exit(1);
|
|
92
|
-
});
|
|
1
|
+
/**
|
|
2
|
+
* Applies SLA report views + stored procedures to PostgreSQL (idempotent CREATE OR REPLACE).
|
|
3
|
+
*
|
|
4
|
+
* Env from shared_models/.env only:
|
|
5
|
+
* DB_HOST / TYPEORM_HOST
|
|
6
|
+
* DB_PORT / TYPEORM_PORT
|
|
7
|
+
* DB_USER / TYPEORM_USERNAME
|
|
8
|
+
* DB_PASS / TYPEORM_PASSWORD
|
|
9
|
+
* DB_NAME / TYPEORM_DATABASE
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* node scripts/sync-sla-reports-sql.js
|
|
13
|
+
* npm run sync:sla-sql (from shared_models)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const { Client } = require('pg');
|
|
19
|
+
|
|
20
|
+
function loadEnvFiles() {
|
|
21
|
+
const dotenv = require('dotenv');
|
|
22
|
+
const packageRoot = path.resolve(__dirname, '..');
|
|
23
|
+
const packageEnv = path.join(packageRoot, '.env');
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(packageEnv)) {
|
|
26
|
+
throw new Error(`Missing env file: ${packageEnv}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
dotenv.config({ path: packageEnv, override: true });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getDbConfig() {
|
|
33
|
+
const host = (process.env.DB_HOST || process.env.TYPEORM_HOST || '').trim();
|
|
34
|
+
const port = parseInt(process.env.DB_PORT || process.env.TYPEORM_PORT || '5432', 10);
|
|
35
|
+
const user = (process.env.DB_USER || process.env.TYPEORM_USERNAME || '').trim();
|
|
36
|
+
const password = process.env.DB_PASS || process.env.TYPEORM_PASSWORD || '';
|
|
37
|
+
const database = (process.env.DB_NAME || process.env.TYPEORM_DATABASE || '').trim();
|
|
38
|
+
|
|
39
|
+
if (!host || !user || !database) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'Missing DB config. Set DB_HOST, DB_USER, DB_NAME (and DB_PASS) in shared_models/.env'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return { host, port, user, password, database };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function main() {
|
|
49
|
+
const skipSync = process.argv.includes('--skip');
|
|
50
|
+
if (skipSync || process.env.SKIP_SLA_SQL_SYNC === 'true') {
|
|
51
|
+
console.log('[sync-sla-reports-sql] skipped (SKIP_SLA_SQL_SYNC or --skip)');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
loadEnvFiles();
|
|
56
|
+
const config = getDbConfig();
|
|
57
|
+
const sqlDir = path.join(__dirname, '..', 'sql');
|
|
58
|
+
const manifestPath = path.join(sqlDir, 'sla-reports-sync.manifest.json');
|
|
59
|
+
|
|
60
|
+
if (!fs.existsSync(manifestPath)) {
|
|
61
|
+
throw new Error(`Manifest not found: ${manifestPath}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const files = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
65
|
+
if (!Array.isArray(files) || files.length === 0) {
|
|
66
|
+
throw new Error('sla-reports-sync.manifest.json must be a non-empty array');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const client = new Client(config);
|
|
70
|
+
await client.connect();
|
|
71
|
+
console.log(`[sync-sla-reports-sql] connected to ${config.host}/${config.database}`);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
const filePath = path.join(sqlDir, file);
|
|
76
|
+
if (!fs.existsSync(filePath)) {
|
|
77
|
+
throw new Error(`SQL file missing: ${filePath}`);
|
|
78
|
+
}
|
|
79
|
+
const sql = fs.readFileSync(filePath, 'utf8');
|
|
80
|
+
await client.query(sql);
|
|
81
|
+
console.log(`[sync-sla-reports-sql] applied ${file}`);
|
|
82
|
+
}
|
|
83
|
+
console.log('[sync-sla-reports-sql] done');
|
|
84
|
+
} finally {
|
|
85
|
+
await client.end();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main().catch((err) => {
|
|
90
|
+
console.error('[sync-sla-reports-sql] failed:', err.message);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
[
|
|
2
|
-
"sla_requests_status_to_varchar.sql",
|
|
3
|
-
"sla_requests_status_data_fix.sql",
|
|
4
|
-
"vw_sla_my_requests.sql",
|
|
5
|
-
"vw_sla_approvals.sql",
|
|
6
|
-
"sla_reports_procedures.sql",
|
|
7
|
-
"sla_reports_approvals_workbook.sql",
|
|
8
|
-
"sla_reports_admin_procedures.sql"
|
|
9
|
-
]
|
|
1
|
+
[
|
|
2
|
+
"sla_requests_status_to_varchar.sql",
|
|
3
|
+
"sla_requests_status_data_fix.sql",
|
|
4
|
+
"vw_sla_my_requests.sql",
|
|
5
|
+
"vw_sla_approvals.sql",
|
|
6
|
+
"sla_reports_procedures.sql",
|
|
7
|
+
"sla_reports_approvals_workbook.sql",
|
|
8
|
+
"sla_reports_admin_procedures.sql"
|
|
9
|
+
]
|