@llm-dev-ops/agentics-cli 1.4.87 → 1.4.90

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.
Files changed (107) hide show
  1. package/dist/__tests__/api_gateway.test.d.ts +1 -0
  2. package/dist/__tests__/api_gateway.test.js +50 -0
  3. package/dist/__tests__/domain_enterprise_solution.test.d.ts +1 -0
  4. package/dist/__tests__/domain_enterprise_solution.test.js +50 -0
  5. package/dist/__tests__/health.test.d.ts +1 -0
  6. package/dist/__tests__/health.test.js +19 -0
  7. package/dist/__tests__/monitoring_alerts.test.d.ts +1 -0
  8. package/dist/__tests__/monitoring_alerts.test.js +50 -0
  9. package/dist/__tests__/ongoing_regular_stakeholder.test.d.ts +1 -0
  10. package/dist/__tests__/ongoing_regular_stakeholder.test.js +50 -0
  11. package/dist/__tests__/re_evaluate_risk.test.d.ts +1 -0
  12. package/dist/__tests__/re_evaluate_risk.test.js +50 -0
  13. package/dist/__tests__/recommendation.test.d.ts +1 -0
  14. package/dist/__tests__/recommendation.test.js +50 -0
  15. package/dist/__tests__/risk_mitigation_plan.test.d.ts +1 -0
  16. package/dist/__tests__/risk_mitigation_plan.test.js +50 -0
  17. package/dist/__tests__/scoped_pilot_reduce.test.d.ts +1 -0
  18. package/dist/__tests__/scoped_pilot_reduce.test.js +50 -0
  19. package/dist/__tests__/target_enterprise_system.test.d.ts +1 -0
  20. package/dist/__tests__/target_enterprise_system.test.js +50 -0
  21. package/dist/__tests__/underwriting.test.d.ts +1 -0
  22. package/dist/__tests__/underwriting.test.js +50 -0
  23. package/dist/api-gateway/infra/api-gateway-adapter.d.ts +27 -0
  24. package/dist/api-gateway/infra/api-gateway-adapter.js +54 -0
  25. package/dist/api-gateway/ports/api-gateway.d.ts +26 -0
  26. package/dist/api-gateway/ports/api-gateway.js +2 -0
  27. package/dist/config/endpoints.js +30 -30
  28. package/dist/config/endpoints.js.map +1 -1
  29. package/dist/contracts/contract-validation.d.ts +11 -0
  30. package/dist/contracts/contract-validation.js +21 -0
  31. package/dist/domain-enterprise-solution/infra/api-gateway-seam-adapter.d.ts +21 -0
  32. package/dist/domain-enterprise-solution/infra/api-gateway-seam-adapter.js +42 -0
  33. package/dist/domain-enterprise-solution/infra/domain-enterprise-solution-adapter.d.ts +25 -0
  34. package/dist/domain-enterprise-solution/infra/domain-enterprise-solution-adapter.js +47 -0
  35. package/dist/domain-enterprise-solution/ports/api-gateway-seam.d.ts +20 -0
  36. package/dist/domain-enterprise-solution/ports/api-gateway-seam.js +2 -0
  37. package/dist/domain-enterprise-solution/ports/domain-enterprise-solution.d.ts +24 -0
  38. package/dist/domain-enterprise-solution/ports/domain-enterprise-solution.js +2 -0
  39. package/dist/enterprise/index.d.ts +15 -0
  40. package/dist/enterprise/index.js +16 -0
  41. package/dist/erp-client/client.d.ts +42 -0
  42. package/dist/erp-client/client.js +235 -0
  43. package/dist/erp-client/mapper.d.ts +9 -0
  44. package/dist/erp-client/mapper.js +116 -0
  45. package/dist/erp-client/retry.d.ts +17 -0
  46. package/dist/erp-client/retry.js +74 -0
  47. package/dist/erp-client/types.d.ts +155 -0
  48. package/dist/erp-client/types.js +2 -0
  49. package/dist/infra/clients.d.ts +27 -0
  50. package/dist/infra/clients.js +16 -0
  51. package/dist/infra/connection-pool.d.ts +16 -0
  52. package/dist/infra/connection-pool.js +13 -0
  53. package/dist/infra/iam-helper.d.ts +1 -0
  54. package/dist/infra/iam-helper.js +138 -0
  55. package/dist/infra/telemetry.d.ts +26 -0
  56. package/dist/infra/telemetry.js +39 -0
  57. package/dist/monitoring-alerts/infra/monitoring-alerts-adapter.d.ts +25 -0
  58. package/dist/monitoring-alerts/infra/monitoring-alerts-adapter.js +47 -0
  59. package/dist/monitoring-alerts/ports/monitoring-alerts.d.ts +24 -0
  60. package/dist/monitoring-alerts/ports/monitoring-alerts.js +2 -0
  61. package/dist/ongoing-regular-stakeholder/infra/ongoing-regular-stakeholder-adapter.d.ts +25 -0
  62. package/dist/ongoing-regular-stakeholder/infra/ongoing-regular-stakeholder-adapter.js +47 -0
  63. package/dist/ongoing-regular-stakeholder/ports/ongoing-regular-stakeholder.d.ts +24 -0
  64. package/dist/ongoing-regular-stakeholder/ports/ongoing-regular-stakeholder.js +2 -0
  65. package/dist/pipeline/phase2/phase2-coordinator.d.ts.map +1 -1
  66. package/dist/pipeline/phase2/phase2-coordinator.js +7 -3
  67. package/dist/pipeline/phase2/phase2-coordinator.js.map +1 -1
  68. package/dist/pipeline/ruflo-phase-executor.js +1 -1
  69. package/dist/pipeline/ruflo-phase-executor.js.map +1 -1
  70. package/dist/re-evaluate-risk/infra/re-evaluate-risk-adapter.d.ts +25 -0
  71. package/dist/re-evaluate-risk/infra/re-evaluate-risk-adapter.js +47 -0
  72. package/dist/re-evaluate-risk/ports/re-evaluate-risk.d.ts +24 -0
  73. package/dist/re-evaluate-risk/ports/re-evaluate-risk.js +2 -0
  74. package/dist/recommendation/infra/recommendation-adapter.d.ts +25 -0
  75. package/dist/recommendation/infra/recommendation-adapter.js +47 -0
  76. package/dist/recommendation/ports/recommendation.d.ts +24 -0
  77. package/dist/recommendation/ports/recommendation.js +2 -0
  78. package/dist/risk-mitigation-plan/infra/risk-mitigation-plan-adapter.d.ts +25 -0
  79. package/dist/risk-mitigation-plan/infra/risk-mitigation-plan-adapter.js +47 -0
  80. package/dist/risk-mitigation-plan/ports/risk-mitigation-plan.d.ts +24 -0
  81. package/dist/risk-mitigation-plan/ports/risk-mitigation-plan.js +2 -0
  82. package/dist/scoped-pilot-reduce/infra/scoped-pilot-reduce-adapter.d.ts +25 -0
  83. package/dist/scoped-pilot-reduce/infra/scoped-pilot-reduce-adapter.js +47 -0
  84. package/dist/scoped-pilot-reduce/ports/scoped-pilot-reduce.d.ts +24 -0
  85. package/dist/scoped-pilot-reduce/ports/scoped-pilot-reduce.js +2 -0
  86. package/dist/server/dependencies.d.ts +178 -0
  87. package/dist/server/dependencies.js +321 -0
  88. package/dist/server/health.d.ts +2 -0
  89. package/dist/server/health.js +9 -0
  90. package/dist/server/main.d.ts +1 -0
  91. package/dist/server/main.js +21 -0
  92. package/dist/server/middleware.d.ts +4 -0
  93. package/dist/server/middleware.js +106 -0
  94. package/dist/server/routes.d.ts +5 -0
  95. package/dist/server/routes.js +1100 -0
  96. package/dist/server/schemas.d.ts +217 -0
  97. package/dist/server/schemas.js +185 -0
  98. package/dist/target-enterprise-system/infra/target-enterprise-system-adapter.d.ts +25 -0
  99. package/dist/target-enterprise-system/infra/target-enterprise-system-adapter.js +47 -0
  100. package/dist/target-enterprise-system/ports/target-enterprise-system.d.ts +24 -0
  101. package/dist/target-enterprise-system/ports/target-enterprise-system.js +2 -0
  102. package/dist/underwriting/infra/underwriting-adapter.d.ts +25 -0
  103. package/dist/underwriting/infra/underwriting-adapter.js +47 -0
  104. package/dist/underwriting/ports/underwriting.d.ts +24 -0
  105. package/dist/underwriting/ports/underwriting.js +2 -0
  106. package/docs/ecosystem.graph.json +295 -214
  107. package/package.json +1 -1
@@ -0,0 +1,178 @@
1
+ import type { DbClient, ErpClient } from '../infra/clients.js';
2
+ export interface AuditEntry {
3
+ id: string;
4
+ entity_type: string;
5
+ entity_id: string;
6
+ action: string;
7
+ actor: string;
8
+ payload: unknown;
9
+ created_at: string;
10
+ }
11
+ export interface IAuditPort {
12
+ log(entityType: string, entityId: string, action: string, actor: string, payload: unknown): Promise<AuditEntry>;
13
+ }
14
+ export interface DomainEnterpriseSolutionRecord {
15
+ id: string;
16
+ status: string;
17
+ created_at: string;
18
+ updated_at: string;
19
+ data: Record<string, unknown>;
20
+ }
21
+ export interface IDomainEnterpriseSolutionPort {
22
+ execute(command: string, payload: Record<string, unknown>): Promise<DomainEnterpriseSolutionRecord>;
23
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
24
+ rows: DomainEnterpriseSolutionRecord[];
25
+ total: number;
26
+ }>;
27
+ getById(id: string): Promise<DomainEnterpriseSolutionRecord | null>;
28
+ }
29
+ export interface MonitoringAlertsRecord {
30
+ id: string;
31
+ status: string;
32
+ created_at: string;
33
+ updated_at: string;
34
+ data: Record<string, unknown>;
35
+ }
36
+ export interface IMonitoringAlertsPort {
37
+ execute(command: string, payload: Record<string, unknown>): Promise<MonitoringAlertsRecord>;
38
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
39
+ rows: MonitoringAlertsRecord[];
40
+ total: number;
41
+ }>;
42
+ getById(id: string): Promise<MonitoringAlertsRecord | null>;
43
+ }
44
+ export interface OngoingRegularStakeholderRecord {
45
+ id: string;
46
+ status: string;
47
+ created_at: string;
48
+ updated_at: string;
49
+ data: Record<string, unknown>;
50
+ }
51
+ export interface IOngoingRegularStakeholderPort {
52
+ execute(command: string, payload: Record<string, unknown>): Promise<OngoingRegularStakeholderRecord>;
53
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
54
+ rows: OngoingRegularStakeholderRecord[];
55
+ total: number;
56
+ }>;
57
+ getById(id: string): Promise<OngoingRegularStakeholderRecord | null>;
58
+ }
59
+ export interface RiskMitigationPlanRecord {
60
+ id: string;
61
+ status: string;
62
+ created_at: string;
63
+ updated_at: string;
64
+ data: Record<string, unknown>;
65
+ }
66
+ export interface IRiskMitigationPlanPort {
67
+ execute(command: string, payload: Record<string, unknown>): Promise<RiskMitigationPlanRecord>;
68
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
69
+ rows: RiskMitigationPlanRecord[];
70
+ total: number;
71
+ }>;
72
+ getById(id: string): Promise<RiskMitigationPlanRecord | null>;
73
+ }
74
+ export interface TargetEnterpriseSystemRecord {
75
+ id: string;
76
+ status: string;
77
+ created_at: string;
78
+ updated_at: string;
79
+ data: Record<string, unknown>;
80
+ }
81
+ export interface ITargetEnterpriseSystemPort {
82
+ execute(command: string, payload: Record<string, unknown>): Promise<TargetEnterpriseSystemRecord>;
83
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
84
+ rows: TargetEnterpriseSystemRecord[];
85
+ total: number;
86
+ }>;
87
+ getById(id: string): Promise<TargetEnterpriseSystemRecord | null>;
88
+ }
89
+ export interface UnderwritingRecord {
90
+ id: string;
91
+ status: string;
92
+ created_at: string;
93
+ updated_at: string;
94
+ data: Record<string, unknown>;
95
+ }
96
+ export interface IUnderwritingPort {
97
+ execute(command: string, payload: Record<string, unknown>): Promise<UnderwritingRecord>;
98
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
99
+ rows: UnderwritingRecord[];
100
+ total: number;
101
+ }>;
102
+ getById(id: string): Promise<UnderwritingRecord | null>;
103
+ }
104
+ export interface ScopedPilotReduceRecord {
105
+ id: string;
106
+ status: string;
107
+ created_at: string;
108
+ updated_at: string;
109
+ data: Record<string, unknown>;
110
+ }
111
+ export interface IScopedPilotReducePort {
112
+ execute(command: string, payload: Record<string, unknown>): Promise<ScopedPilotReduceRecord>;
113
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
114
+ rows: ScopedPilotReduceRecord[];
115
+ total: number;
116
+ }>;
117
+ getById(id: string): Promise<ScopedPilotReduceRecord | null>;
118
+ }
119
+ export interface ReEvaluateRiskRecord {
120
+ id: string;
121
+ status: string;
122
+ created_at: string;
123
+ updated_at: string;
124
+ data: Record<string, unknown>;
125
+ }
126
+ export interface IReEvaluateRiskPort {
127
+ execute(command: string, payload: Record<string, unknown>): Promise<ReEvaluateRiskRecord>;
128
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
129
+ rows: ReEvaluateRiskRecord[];
130
+ total: number;
131
+ }>;
132
+ getById(id: string): Promise<ReEvaluateRiskRecord | null>;
133
+ }
134
+ export interface RecommendationRecord {
135
+ id: string;
136
+ status: string;
137
+ created_at: string;
138
+ updated_at: string;
139
+ data: Record<string, unknown>;
140
+ }
141
+ export interface IRecommendationPort {
142
+ execute(command: string, payload: Record<string, unknown>): Promise<RecommendationRecord>;
143
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
144
+ rows: RecommendationRecord[];
145
+ total: number;
146
+ }>;
147
+ getById(id: string): Promise<RecommendationRecord | null>;
148
+ }
149
+ export interface ApiGatewayRecord {
150
+ id: string;
151
+ status: string;
152
+ created_at: string;
153
+ updated_at: string;
154
+ data: Record<string, unknown>;
155
+ }
156
+ export interface IApiGatewayPort {
157
+ execute(command: string, payload: Record<string, unknown>): Promise<ApiGatewayRecord>;
158
+ query(filters: Record<string, unknown>, limit: number, offset: number): Promise<{
159
+ rows: ApiGatewayRecord[];
160
+ total: number;
161
+ }>;
162
+ getById(id: string): Promise<ApiGatewayRecord | null>;
163
+ }
164
+ export interface Dependencies {
165
+ readonly domainEnterpriseSolution: IDomainEnterpriseSolutionPort;
166
+ readonly monitoringAlerts: IMonitoringAlertsPort;
167
+ readonly ongoingRegularStakeholder: IOngoingRegularStakeholderPort;
168
+ readonly riskMitigationPlan: IRiskMitigationPlanPort;
169
+ readonly targetEnterpriseSystem: ITargetEnterpriseSystemPort;
170
+ readonly underwriting: IUnderwritingPort;
171
+ readonly scopedPilotReduce: IScopedPilotReducePort;
172
+ readonly reEvaluateRisk: IReEvaluateRiskPort;
173
+ readonly recommendation: IRecommendationPort;
174
+ readonly apiGateway: IApiGatewayPort;
175
+ readonly audit: IAuditPort;
176
+ readonly erp: ErpClient;
177
+ }
178
+ export declare function createDependencies(db: DbClient, erp: ErpClient): Dependencies;
@@ -0,0 +1,321 @@
1
+ // Generated by Phase 4 pipeline — do not edit manually
2
+ import { ConsoleTelemetry } from '../infra/telemetry.js';
3
+ class AuditAdapter {
4
+ db;
5
+ constructor(db) {
6
+ this.db = db;
7
+ }
8
+ async log(entityType, entityId, action, actor, payload) {
9
+ const id = crypto.randomUUID();
10
+ const now = new Date().toISOString();
11
+ await this.db.execute('INSERT INTO audit_log (id, entity_type, entity_id, action, actor, payload, created_at) VALUES (:1, :2, :3, :4, :5, :6, :7)', [id, entityType, entityId, action, actor, JSON.stringify(payload), now]);
12
+ return { id, entity_type: entityType, entity_id: entityId, action, actor, payload, created_at: now };
13
+ }
14
+ }
15
+ class DomainEnterpriseSolutionAdapter {
16
+ db;
17
+ telemetry;
18
+ constructor(db, telemetry) {
19
+ this.db = db;
20
+ this.telemetry = telemetry;
21
+ }
22
+ async execute(command, payload) {
23
+ return this.telemetry.withSpan('domain_enterprise_solution', command, {}, async () => {
24
+ const id = crypto.randomUUID();
25
+ const now = new Date().toISOString();
26
+ await this.db.execute('INSERT INTO domain_enterprise_solution_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
27
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
28
+ });
29
+ }
30
+ async query(filters, limit, offset) {
31
+ return this.telemetry.withSpan('domain_enterprise_solution', 'query', {}, async () => {
32
+ void filters;
33
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM domain_enterprise_solution_records', []);
34
+ const total = countRows[0]?.cnt ?? 0;
35
+ const dataRows = await this.db.query(`SELECT * FROM domain_enterprise_solution_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
36
+ return { rows: dataRows, total };
37
+ });
38
+ }
39
+ async getById(id) {
40
+ const rows = await this.db.query('SELECT * FROM domain_enterprise_solution_records WHERE id = :1', [id]);
41
+ return rows[0] ?? null;
42
+ }
43
+ }
44
+ class MonitoringAlertsAdapter {
45
+ db;
46
+ telemetry;
47
+ constructor(db, telemetry) {
48
+ this.db = db;
49
+ this.telemetry = telemetry;
50
+ }
51
+ async execute(command, payload) {
52
+ return this.telemetry.withSpan('monitoring_alerts', command, {}, async () => {
53
+ const id = crypto.randomUUID();
54
+ const now = new Date().toISOString();
55
+ await this.db.execute('INSERT INTO monitoring_alerts_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
56
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
57
+ });
58
+ }
59
+ async query(filters, limit, offset) {
60
+ return this.telemetry.withSpan('monitoring_alerts', 'query', {}, async () => {
61
+ void filters;
62
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM monitoring_alerts_records', []);
63
+ const total = countRows[0]?.cnt ?? 0;
64
+ const dataRows = await this.db.query(`SELECT * FROM monitoring_alerts_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
65
+ return { rows: dataRows, total };
66
+ });
67
+ }
68
+ async getById(id) {
69
+ const rows = await this.db.query('SELECT * FROM monitoring_alerts_records WHERE id = :1', [id]);
70
+ return rows[0] ?? null;
71
+ }
72
+ }
73
+ class OngoingRegularStakeholderAdapter {
74
+ db;
75
+ telemetry;
76
+ constructor(db, telemetry) {
77
+ this.db = db;
78
+ this.telemetry = telemetry;
79
+ }
80
+ async execute(command, payload) {
81
+ return this.telemetry.withSpan('ongoing_regular_stakeholder', command, {}, async () => {
82
+ const id = crypto.randomUUID();
83
+ const now = new Date().toISOString();
84
+ await this.db.execute('INSERT INTO ongoing_regular_stakeholder_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
85
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
86
+ });
87
+ }
88
+ async query(filters, limit, offset) {
89
+ return this.telemetry.withSpan('ongoing_regular_stakeholder', 'query', {}, async () => {
90
+ void filters;
91
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM ongoing_regular_stakeholder_records', []);
92
+ const total = countRows[0]?.cnt ?? 0;
93
+ const dataRows = await this.db.query(`SELECT * FROM ongoing_regular_stakeholder_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
94
+ return { rows: dataRows, total };
95
+ });
96
+ }
97
+ async getById(id) {
98
+ const rows = await this.db.query('SELECT * FROM ongoing_regular_stakeholder_records WHERE id = :1', [id]);
99
+ return rows[0] ?? null;
100
+ }
101
+ }
102
+ class RiskMitigationPlanAdapter {
103
+ db;
104
+ telemetry;
105
+ constructor(db, telemetry) {
106
+ this.db = db;
107
+ this.telemetry = telemetry;
108
+ }
109
+ async execute(command, payload) {
110
+ return this.telemetry.withSpan('risk_mitigation_plan', command, {}, async () => {
111
+ const id = crypto.randomUUID();
112
+ const now = new Date().toISOString();
113
+ await this.db.execute('INSERT INTO risk_mitigation_plan_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
114
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
115
+ });
116
+ }
117
+ async query(filters, limit, offset) {
118
+ return this.telemetry.withSpan('risk_mitigation_plan', 'query', {}, async () => {
119
+ void filters;
120
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM risk_mitigation_plan_records', []);
121
+ const total = countRows[0]?.cnt ?? 0;
122
+ const dataRows = await this.db.query(`SELECT * FROM risk_mitigation_plan_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
123
+ return { rows: dataRows, total };
124
+ });
125
+ }
126
+ async getById(id) {
127
+ const rows = await this.db.query('SELECT * FROM risk_mitigation_plan_records WHERE id = :1', [id]);
128
+ return rows[0] ?? null;
129
+ }
130
+ }
131
+ class TargetEnterpriseSystemAdapter {
132
+ db;
133
+ telemetry;
134
+ constructor(db, telemetry) {
135
+ this.db = db;
136
+ this.telemetry = telemetry;
137
+ }
138
+ async execute(command, payload) {
139
+ return this.telemetry.withSpan('target_enterprise_system', command, {}, async () => {
140
+ const id = crypto.randomUUID();
141
+ const now = new Date().toISOString();
142
+ await this.db.execute('INSERT INTO target_enterprise_system_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
143
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
144
+ });
145
+ }
146
+ async query(filters, limit, offset) {
147
+ return this.telemetry.withSpan('target_enterprise_system', 'query', {}, async () => {
148
+ void filters;
149
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM target_enterprise_system_records', []);
150
+ const total = countRows[0]?.cnt ?? 0;
151
+ const dataRows = await this.db.query(`SELECT * FROM target_enterprise_system_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
152
+ return { rows: dataRows, total };
153
+ });
154
+ }
155
+ async getById(id) {
156
+ const rows = await this.db.query('SELECT * FROM target_enterprise_system_records WHERE id = :1', [id]);
157
+ return rows[0] ?? null;
158
+ }
159
+ }
160
+ class UnderwritingAdapter {
161
+ db;
162
+ telemetry;
163
+ constructor(db, telemetry) {
164
+ this.db = db;
165
+ this.telemetry = telemetry;
166
+ }
167
+ async execute(command, payload) {
168
+ return this.telemetry.withSpan('underwriting', command, {}, async () => {
169
+ const id = crypto.randomUUID();
170
+ const now = new Date().toISOString();
171
+ await this.db.execute('INSERT INTO underwriting_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
172
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
173
+ });
174
+ }
175
+ async query(filters, limit, offset) {
176
+ return this.telemetry.withSpan('underwriting', 'query', {}, async () => {
177
+ void filters;
178
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM underwriting_records', []);
179
+ const total = countRows[0]?.cnt ?? 0;
180
+ const dataRows = await this.db.query(`SELECT * FROM underwriting_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
181
+ return { rows: dataRows, total };
182
+ });
183
+ }
184
+ async getById(id) {
185
+ const rows = await this.db.query('SELECT * FROM underwriting_records WHERE id = :1', [id]);
186
+ return rows[0] ?? null;
187
+ }
188
+ }
189
+ class ScopedPilotReduceAdapter {
190
+ db;
191
+ telemetry;
192
+ constructor(db, telemetry) {
193
+ this.db = db;
194
+ this.telemetry = telemetry;
195
+ }
196
+ async execute(command, payload) {
197
+ return this.telemetry.withSpan('scoped_pilot_reduce', command, {}, async () => {
198
+ const id = crypto.randomUUID();
199
+ const now = new Date().toISOString();
200
+ await this.db.execute('INSERT INTO scoped_pilot_reduce_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
201
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
202
+ });
203
+ }
204
+ async query(filters, limit, offset) {
205
+ return this.telemetry.withSpan('scoped_pilot_reduce', 'query', {}, async () => {
206
+ void filters;
207
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM scoped_pilot_reduce_records', []);
208
+ const total = countRows[0]?.cnt ?? 0;
209
+ const dataRows = await this.db.query(`SELECT * FROM scoped_pilot_reduce_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
210
+ return { rows: dataRows, total };
211
+ });
212
+ }
213
+ async getById(id) {
214
+ const rows = await this.db.query('SELECT * FROM scoped_pilot_reduce_records WHERE id = :1', [id]);
215
+ return rows[0] ?? null;
216
+ }
217
+ }
218
+ class ReEvaluateRiskAdapter {
219
+ db;
220
+ telemetry;
221
+ constructor(db, telemetry) {
222
+ this.db = db;
223
+ this.telemetry = telemetry;
224
+ }
225
+ async execute(command, payload) {
226
+ return this.telemetry.withSpan('re_evaluate_risk', command, {}, async () => {
227
+ const id = crypto.randomUUID();
228
+ const now = new Date().toISOString();
229
+ await this.db.execute('INSERT INTO re_evaluate_risk_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
230
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
231
+ });
232
+ }
233
+ async query(filters, limit, offset) {
234
+ return this.telemetry.withSpan('re_evaluate_risk', 'query', {}, async () => {
235
+ void filters;
236
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM re_evaluate_risk_records', []);
237
+ const total = countRows[0]?.cnt ?? 0;
238
+ const dataRows = await this.db.query(`SELECT * FROM re_evaluate_risk_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
239
+ return { rows: dataRows, total };
240
+ });
241
+ }
242
+ async getById(id) {
243
+ const rows = await this.db.query('SELECT * FROM re_evaluate_risk_records WHERE id = :1', [id]);
244
+ return rows[0] ?? null;
245
+ }
246
+ }
247
+ class RecommendationAdapter {
248
+ db;
249
+ telemetry;
250
+ constructor(db, telemetry) {
251
+ this.db = db;
252
+ this.telemetry = telemetry;
253
+ }
254
+ async execute(command, payload) {
255
+ return this.telemetry.withSpan('recommendation', command, {}, async () => {
256
+ const id = crypto.randomUUID();
257
+ const now = new Date().toISOString();
258
+ await this.db.execute('INSERT INTO recommendation_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
259
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
260
+ });
261
+ }
262
+ async query(filters, limit, offset) {
263
+ return this.telemetry.withSpan('recommendation', 'query', {}, async () => {
264
+ void filters;
265
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM recommendation_records', []);
266
+ const total = countRows[0]?.cnt ?? 0;
267
+ const dataRows = await this.db.query(`SELECT * FROM recommendation_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
268
+ return { rows: dataRows, total };
269
+ });
270
+ }
271
+ async getById(id) {
272
+ const rows = await this.db.query('SELECT * FROM recommendation_records WHERE id = :1', [id]);
273
+ return rows[0] ?? null;
274
+ }
275
+ }
276
+ class ApiGatewayAdapter {
277
+ db;
278
+ telemetry;
279
+ constructor(db, telemetry) {
280
+ this.db = db;
281
+ this.telemetry = telemetry;
282
+ }
283
+ async execute(command, payload) {
284
+ return this.telemetry.withSpan('api_gateway', command, {}, async () => {
285
+ const id = crypto.randomUUID();
286
+ const now = new Date().toISOString();
287
+ await this.db.execute('INSERT INTO api_gateway_records (id, status, created_at, updated_at, data) VALUES (:1, :2, :3, :4, :5)', [id, 'active', now, now, JSON.stringify(payload)]);
288
+ return { id, status: 'active', created_at: now, updated_at: now, data: payload };
289
+ });
290
+ }
291
+ async query(filters, limit, offset) {
292
+ return this.telemetry.withSpan('api_gateway', 'query', {}, async () => {
293
+ void filters;
294
+ const countRows = await this.db.query('SELECT COUNT(*) as cnt FROM api_gateway_records', []);
295
+ const total = countRows[0]?.cnt ?? 0;
296
+ const dataRows = await this.db.query(`SELECT * FROM api_gateway_records ORDER BY created_at DESC LIMIT ${limit} OFFSET ${offset}`, []);
297
+ return { rows: dataRows, total };
298
+ });
299
+ }
300
+ async getById(id) {
301
+ const rows = await this.db.query('SELECT * FROM api_gateway_records WHERE id = :1', [id]);
302
+ return rows[0] ?? null;
303
+ }
304
+ }
305
+ export function createDependencies(db, erp) {
306
+ const telemetry = new ConsoleTelemetry();
307
+ return {
308
+ domainEnterpriseSolution: new DomainEnterpriseSolutionAdapter(db, telemetry),
309
+ monitoringAlerts: new MonitoringAlertsAdapter(db, telemetry),
310
+ ongoingRegularStakeholder: new OngoingRegularStakeholderAdapter(db, telemetry),
311
+ riskMitigationPlan: new RiskMitigationPlanAdapter(db, telemetry),
312
+ targetEnterpriseSystem: new TargetEnterpriseSystemAdapter(db, telemetry),
313
+ underwriting: new UnderwritingAdapter(db, telemetry),
314
+ scopedPilotReduce: new ScopedPilotReduceAdapter(db, telemetry),
315
+ reEvaluateRisk: new ReEvaluateRiskAdapter(db, telemetry),
316
+ recommendation: new RecommendationAdapter(db, telemetry),
317
+ apiGateway: new ApiGatewayAdapter(db, telemetry),
318
+ audit: new AuditAdapter(db),
319
+ erp,
320
+ };
321
+ }
@@ -0,0 +1,2 @@
1
+ import { Hono } from 'hono';
2
+ export declare const healthRouter: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,9 @@
1
+ // Generated by Phase 4 pipeline — do not edit manually
2
+ import { Hono } from 'hono';
3
+ export const healthRouter = new Hono();
4
+ healthRouter.get('/healthz', (c) => {
5
+ return c.json({ status: 'ok' }, 200);
6
+ });
7
+ healthRouter.get('/readyz', (c) => {
8
+ return c.json({ status: 'ready' }, 200);
9
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ // Generated by Phase 4 pipeline — do not edit manually
2
+ import { serve } from '@hono/node-server';
3
+ import { app } from './routes.js';
4
+ const PORT = parseInt(process.env.PORT ?? '8080', 10);
5
+ serve({ fetch: app.fetch, port: PORT }, (info) => {
6
+ process.stdout.write(JSON.stringify({
7
+ severity: 'INFO',
8
+ message: 'HTTP server started',
9
+ port: info.port,
10
+ pid: process.pid,
11
+ timestamp: new Date().toISOString(),
12
+ }) + '\n');
13
+ });
14
+ process.on('SIGTERM', () => {
15
+ process.stdout.write(JSON.stringify({
16
+ severity: 'INFO',
17
+ message: 'Received SIGTERM — shutting down gracefully',
18
+ timestamp: new Date().toISOString(),
19
+ }) + '\n');
20
+ process.exit(0);
21
+ });
@@ -0,0 +1,4 @@
1
+ import type { MiddlewareHandler } from 'hono';
2
+ export declare const correlationMiddleware: MiddlewareHandler;
3
+ export declare const iamMiddleware: MiddlewareHandler;
4
+ export declare const loggingMiddleware: MiddlewareHandler;
@@ -0,0 +1,106 @@
1
+ // Generated by Phase 4 pipeline — do not edit manually
2
+ import { createMiddleware } from 'hono/factory';
3
+ import * as crypto from 'node:crypto';
4
+ import * as jwt from 'jsonwebtoken';
5
+ import jwksClient from 'jwks-rsa';
6
+ // ---------------------------------------------------------------------------
7
+ // Correlation ID middleware
8
+ // ---------------------------------------------------------------------------
9
+ export const correlationMiddleware = createMiddleware(async (c, next) => {
10
+ const correlationId = c.req.header('X-Correlation-ID') ?? crypto.randomUUID();
11
+ c.set('correlationId', correlationId);
12
+ c.header('X-Correlation-ID', correlationId);
13
+ await next();
14
+ });
15
+ // ---------------------------------------------------------------------------
16
+ // IAM token validation middleware (JWKS-backed JWT verification)
17
+ // ---------------------------------------------------------------------------
18
+ const JWKS_URI = process.env.IAM_JWKS_URI ?? 'https://www.googleapis.com/oauth2/v3/certs';
19
+ const IAM_AUDIENCE = process.env.IAM_AUDIENCE ?? '';
20
+ const IAM_ISSUERS = (process.env.IAM_ISSUERS ?? 'https://accounts.google.com').split(',').map(s => s.trim());
21
+ const jwksRsa = jwksClient({
22
+ jwksUri: JWKS_URI,
23
+ cache: true,
24
+ cacheMaxAge: 600_000,
25
+ rateLimit: true,
26
+ jwksRequestsPerMinute: 10,
27
+ });
28
+ function getSigningKey(kid) {
29
+ return new Promise((resolve, reject) => {
30
+ jwksRsa.getSigningKey(kid, (err, key) => {
31
+ if (err || !key)
32
+ return reject(err ?? new Error('No signing key found'));
33
+ resolve(key.getPublicKey());
34
+ });
35
+ });
36
+ }
37
+ export const iamMiddleware = createMiddleware(async (c, next) => {
38
+ const path = new URL(c.req.url).pathname;
39
+ if (path === '/health/healthz' || path === '/health/readyz') {
40
+ await next();
41
+ return;
42
+ }
43
+ const authHeader = c.req.header('Authorization');
44
+ if (!authHeader?.startsWith('Bearer ')) {
45
+ return c.json({ error: { code: 'UNAUTHORIZED', message: 'Missing Bearer token' } }, 401);
46
+ }
47
+ const token = authHeader.slice(7);
48
+ if (!token) {
49
+ return c.json({ error: { code: 'UNAUTHORIZED', message: 'Empty token' } }, 401);
50
+ }
51
+ try {
52
+ const decoded = jwt.decode(token, { complete: true });
53
+ if (!decoded || typeof decoded === 'string' || !decoded.header.kid) {
54
+ return c.json({ error: { code: 'UNAUTHORIZED', message: 'Malformed token: missing kid' } }, 401);
55
+ }
56
+ const signingKey = await getSigningKey(decoded.header.kid);
57
+ const verifyOptions = {
58
+ algorithms: ['RS256', 'RS384', 'RS512', 'ES256', 'ES384'],
59
+ };
60
+ if (IAM_ISSUERS.length > 0 && IAM_ISSUERS[0] !== '') {
61
+ verifyOptions.issuer = IAM_ISSUERS;
62
+ }
63
+ if (IAM_AUDIENCE) {
64
+ verifyOptions.audience = IAM_AUDIENCE;
65
+ }
66
+ const payload = jwt.verify(token, signingKey, verifyOptions);
67
+ c.set('iamClaims', payload);
68
+ }
69
+ catch (err) {
70
+ const message = err instanceof Error ? err.message : 'Token verification failed';
71
+ return c.json({ error: { code: 'UNAUTHORIZED', message } }, 401);
72
+ }
73
+ await next();
74
+ });
75
+ // ---------------------------------------------------------------------------
76
+ // Structured JSON request/response logging middleware
77
+ // ---------------------------------------------------------------------------
78
+ export const loggingMiddleware = createMiddleware(async (c, next) => {
79
+ const startTime = Date.now();
80
+ const correlationId = c.get('correlationId');
81
+ process.stdout.write(JSON.stringify({
82
+ severity: 'INFO',
83
+ message: 'request received',
84
+ httpRequest: {
85
+ method: c.req.method,
86
+ url: c.req.url,
87
+ userAgent: c.req.header('user-agent'),
88
+ },
89
+ correlationId,
90
+ timestamp: new Date().toISOString(),
91
+ }) + '\n');
92
+ await next();
93
+ const durationMs = Date.now() - startTime;
94
+ process.stdout.write(JSON.stringify({
95
+ severity: 'INFO',
96
+ message: 'request completed',
97
+ httpRequest: {
98
+ method: c.req.method,
99
+ url: c.req.url,
100
+ status: c.res.status,
101
+ latency: `${durationMs}ms`,
102
+ },
103
+ correlationId,
104
+ timestamp: new Date().toISOString(),
105
+ }) + '\n');
106
+ });
@@ -0,0 +1,5 @@
1
+ import { Hono } from 'hono';
2
+ import { InforClient } from '../erp-client/client.js';
3
+ declare const erpClientInstance: InforClient;
4
+ declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
5
+ export { app, erpClientInstance };