@platform-modules/foreign-ministry 1.3.351 → 1.3.358
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/dist/helpers/employee-evaluation-request.utils.d.ts +12 -0
- package/dist/helpers/employee-evaluation-request.utils.js +85 -0
- 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/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 +54 -54
- package/dist/models/SlaMyRequestsViewModel.d.ts +3 -0
- package/dist/models/SlaMyRequestsViewModel.js +73 -53
- package/dist/models/UuidAuditModel.d.ts +9 -0
- package/dist/models/UuidAuditModel.js +41 -0
- package/package.json +2 -2
- 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/sla-reports-sync.manifest.json +9 -9
- package/sql/sla_reports_admin_procedures.sql +321 -322
- package/sql/sla_reports_approvals_workbook.sql +427 -430
- package/sql/sla_reports_procedures.sql +883 -886
- package/sql/sla_requests_status_to_varchar.sql +28 -28
- package/sql/vw_sla_approvals.sql +115 -115
- package/sql/vw_sla_my_requests.sql +60 -55
- package/src/helpers/employee-evaluation-request.utils.ts +127 -0
- 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/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 +142 -142
- package/src/models/SlaMyRequestsViewModel.ts +192 -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
|
@@ -36,58 +36,63 @@ exports.SLA_MY_REQUESTS_REQUEST_OBJ_EXCLUDED_KEYS = [
|
|
|
36
36
|
"sla_request",
|
|
37
37
|
"sla_request_id",
|
|
38
38
|
];
|
|
39
|
-
const VW_SLA_MY_REQUESTS_SQL = `
|
|
40
|
-
SELECT
|
|
41
|
-
sr.id AS sla_request_id,
|
|
42
|
-
sr.user_id,
|
|
43
|
-
sr.service_id AS service_id,
|
|
44
|
-
sr.sub_service_id AS sub_service_id,
|
|
45
|
-
TRIM(COALESCE(creator.employee_name, ''))::TEXT AS created_by,
|
|
46
|
-
sr.created_at,
|
|
47
|
-
TRIM(COALESCE(dept.department_name, ''))::TEXT AS req_user_department_id,
|
|
48
|
-
TRIM(COALESCE(sec.section_name, ''))::TEXT AS req_user_section_id,
|
|
49
|
-
TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
|
|
50
|
-
TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
|
|
51
|
-
sr.status::TEXT AS status,
|
|
52
|
-
sr.request_id,
|
|
53
|
-
(
|
|
54
|
-
COALESCE(sr.request_obj, '{}'::jsonb)
|
|
55
|
-
- 'id'
|
|
56
|
-
- 'status'
|
|
57
|
-
- 'role_id'
|
|
58
|
-
- 'user_id'
|
|
59
|
-
- 'createdBy'
|
|
60
|
-
- 'created_at'
|
|
61
|
-
- 'updated_by'
|
|
62
|
-
- 'updated_at'
|
|
63
|
-
- 'req_user_department_id'
|
|
64
|
-
- 'workflow_execution_id'
|
|
65
|
-
- 'department_id'
|
|
66
|
-
- 'req_user_section_id'
|
|
67
|
-
- 'service_type_id'
|
|
68
|
-
- 'service_type'
|
|
69
|
-
- 'created_by'
|
|
70
|
-
- 'service_id'
|
|
71
|
-
- 'sub_service_id'
|
|
72
|
-
- 'attachments'
|
|
73
|
-
- 'is_deleted'
|
|
74
|
-
- 'sla_request'
|
|
75
|
-
- 'sla_request_id'
|
|
76
|
-
) AS request_fields
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
39
|
+
const VW_SLA_MY_REQUESTS_SQL = `
|
|
40
|
+
SELECT
|
|
41
|
+
sr.id AS sla_request_id,
|
|
42
|
+
sr.user_id,
|
|
43
|
+
sr.service_id AS service_id,
|
|
44
|
+
sr.sub_service_id AS sub_service_id,
|
|
45
|
+
TRIM(COALESCE(creator.employee_name, ''))::TEXT AS created_by,
|
|
46
|
+
sr.created_at,
|
|
47
|
+
TRIM(COALESCE(dept.department_name, ''))::TEXT AS req_user_department_id,
|
|
48
|
+
TRIM(COALESCE(sec.section_name, ''))::TEXT AS req_user_section_id,
|
|
49
|
+
TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
|
|
50
|
+
TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
|
|
51
|
+
sr.status::TEXT AS status,
|
|
52
|
+
sr.request_id,
|
|
53
|
+
(
|
|
54
|
+
COALESCE(sr.request_obj, '{}'::jsonb)
|
|
55
|
+
- 'id'
|
|
56
|
+
- 'status'
|
|
57
|
+
- 'role_id'
|
|
58
|
+
- 'user_id'
|
|
59
|
+
- 'createdBy'
|
|
60
|
+
- 'created_at'
|
|
61
|
+
- 'updated_by'
|
|
62
|
+
- 'updated_at'
|
|
63
|
+
- 'req_user_department_id'
|
|
64
|
+
- 'workflow_execution_id'
|
|
65
|
+
- 'department_id'
|
|
66
|
+
- 'req_user_section_id'
|
|
67
|
+
- 'service_type_id'
|
|
68
|
+
- 'service_type'
|
|
69
|
+
- 'created_by'
|
|
70
|
+
- 'service_id'
|
|
71
|
+
- 'sub_service_id'
|
|
72
|
+
- 'attachments'
|
|
73
|
+
- 'is_deleted'
|
|
74
|
+
- 'sla_request'
|
|
75
|
+
- 'sla_request_id'
|
|
76
|
+
) AS request_fields,
|
|
77
|
+
TRIM(COALESCE(dept.department_arabic_name, ''))::TEXT AS req_user_department_arabicname,
|
|
78
|
+
TRIM(COALESCE(sec.section_arabic_name, ''))::TEXT AS req_user_section_arabicname,
|
|
79
|
+
TRIM(COALESCE(req_user.employee_arabic_name, ''))::TEXT AS req_user_arabicname
|
|
80
|
+
FROM sla_requests sr
|
|
81
|
+
LEFT JOIN users req_user
|
|
82
|
+
ON req_user.id = sr.user_id AND COALESCE(req_user.is_deleted, false) = false
|
|
83
|
+
LEFT JOIN users creator
|
|
84
|
+
ON sr.created_by ~ '^[0-9]+$'
|
|
85
|
+
AND creator.id = sr.created_by::integer
|
|
86
|
+
AND COALESCE(creator.is_deleted, false) = false
|
|
87
|
+
LEFT JOIN departments dept
|
|
88
|
+
ON dept.id = sr.req_user_department_id AND COALESCE(dept.is_deleted, false) = false
|
|
89
|
+
LEFT JOIN sections sec
|
|
90
|
+
ON sec.id = sr.req_user_section_id AND COALESCE(sec.is_deleted, false) = false
|
|
91
|
+
LEFT JOIN fm_services svc
|
|
92
|
+
ON svc.id = sr.service_id AND COALESCE(svc.is_deleted, false) = false
|
|
93
|
+
LEFT JOIN fm_sub_services subsvc
|
|
94
|
+
ON subsvc.id = sr.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
|
|
95
|
+
WHERE COALESCE(sr.is_deleted, false) = false
|
|
91
96
|
`;
|
|
92
97
|
/**
|
|
93
98
|
* Read-only view for SLA "my requests" listings.
|
|
@@ -149,6 +154,18 @@ __decorate([
|
|
|
149
154
|
(0, typeorm_1.ViewColumn)(),
|
|
150
155
|
__metadata("design:type", Object)
|
|
151
156
|
], SlaMyRequestsView.prototype, "request_fields", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
(0, typeorm_1.ViewColumn)(),
|
|
159
|
+
__metadata("design:type", String)
|
|
160
|
+
], SlaMyRequestsView.prototype, "req_user_department_arabicname", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
(0, typeorm_1.ViewColumn)(),
|
|
163
|
+
__metadata("design:type", String)
|
|
164
|
+
], SlaMyRequestsView.prototype, "req_user_section_arabicname", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, typeorm_1.ViewColumn)(),
|
|
167
|
+
__metadata("design:type", String)
|
|
168
|
+
], SlaMyRequestsView.prototype, "req_user_arabicname", void 0);
|
|
152
169
|
exports.SlaMyRequestsView = SlaMyRequestsView = __decorate([
|
|
153
170
|
(0, typeorm_1.ViewEntity)({
|
|
154
171
|
name: "vw_sla_my_requests",
|
|
@@ -157,7 +174,7 @@ exports.SlaMyRequestsView = SlaMyRequestsView = __decorate([
|
|
|
157
174
|
], SlaMyRequestsView);
|
|
158
175
|
/** Flatten view row: fixed columns plus each entry in `request_fields`. */
|
|
159
176
|
function flattenSlaMyRequestsViewRow(row) {
|
|
160
|
-
const { sla_request_id, user_id, service_id, sub_service_id, created_by, created_at, req_user_department_id, req_user_section_id, service_name, sub_service_name, status, request_id, request_fields, } = row;
|
|
177
|
+
const { sla_request_id, user_id, service_id, sub_service_id, created_by, created_at, req_user_department_id, req_user_section_id, service_name, sub_service_name, status, request_id, request_fields, req_user_department_arabicname, req_user_section_arabicname, req_user_arabicname, } = row;
|
|
161
178
|
return {
|
|
162
179
|
sla_request_id,
|
|
163
180
|
user_id,
|
|
@@ -171,6 +188,9 @@ function flattenSlaMyRequestsViewRow(row) {
|
|
|
171
188
|
sub_service_name,
|
|
172
189
|
status,
|
|
173
190
|
request_id,
|
|
191
|
+
req_user_department_arabicname,
|
|
192
|
+
req_user_section_arabicname,
|
|
193
|
+
req_user_arabicname,
|
|
174
194
|
...(request_fields ?? {}),
|
|
175
195
|
};
|
|
176
196
|
}
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platform-modules/foreign-ministry",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.358",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@platform-modules/foreign-ministry": "^1.3.
|
|
25
|
+
"@platform-modules/foreign-ministry": "^1.3.355",
|
|
26
26
|
"moment-timezone": "^0.6.0",
|
|
27
27
|
"pg": "^8.16.0",
|
|
28
28
|
"typeorm": "^0.3.17"
|
|
@@ -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
|
+
]
|