monora-ai 2.1.0 → 2.1.3

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 (184) hide show
  1. package/README.md +333 -159
  2. package/dist/aims_governance.d.ts +238 -0
  3. package/dist/aims_governance.d.ts.map +1 -0
  4. package/dist/aims_governance.js +922 -0
  5. package/dist/alerts.d.ts +16 -0
  6. package/dist/alerts.d.ts.map +1 -1
  7. package/dist/alerts.js +16 -0
  8. package/dist/api.d.ts +6 -0
  9. package/dist/api.d.ts.map +1 -1
  10. package/dist/api.js +6 -0
  11. package/dist/assessment.d.ts +85 -0
  12. package/dist/assessment.d.ts.map +1 -1
  13. package/dist/assessment.js +506 -13
  14. package/dist/attribution.d.ts +44 -3
  15. package/dist/attribution.d.ts.map +1 -1
  16. package/dist/attribution.js +197 -10
  17. package/dist/autodetect.d.ts +68 -0
  18. package/dist/autodetect.d.ts.map +1 -1
  19. package/dist/autodetect.js +639 -0
  20. package/dist/bias.d.ts +130 -0
  21. package/dist/bias.d.ts.map +1 -0
  22. package/dist/bias.js +223 -0
  23. package/dist/cli/diagnostics.d.ts +5 -1
  24. package/dist/cli/diagnostics.d.ts.map +1 -1
  25. package/dist/cli/diagnostics.js +23 -6
  26. package/dist/cli/doctor.d.ts +25 -0
  27. package/dist/cli/doctor.d.ts.map +1 -0
  28. package/dist/cli/doctor.js +381 -0
  29. package/dist/cli/fix.d.ts +16 -0
  30. package/dist/cli/fix.d.ts.map +1 -0
  31. package/dist/cli/fix.js +284 -0
  32. package/dist/cli/init.d.ts +57 -0
  33. package/dist/cli/init.d.ts.map +1 -0
  34. package/dist/cli/init.js +205 -0
  35. package/dist/cli.js +1550 -176
  36. package/dist/complianceTargets.d.ts +111 -0
  37. package/dist/complianceTargets.d.ts.map +1 -0
  38. package/dist/complianceTargets.js +521 -0
  39. package/dist/config.d.ts +261 -16
  40. package/dist/config.d.ts.map +1 -1
  41. package/dist/config.js +381 -32
  42. package/dist/config_migrations.d.ts.map +1 -1
  43. package/dist/config_migrations.js +38 -1
  44. package/dist/config_schema.d.ts +2490 -1035
  45. package/dist/config_schema.d.ts.map +1 -1
  46. package/dist/config_schema.js +233 -64
  47. package/dist/context.d.ts +34 -0
  48. package/dist/context.d.ts.map +1 -1
  49. package/dist/context.js +118 -7
  50. package/dist/control_backbone.d.ts +122 -0
  51. package/dist/control_backbone.d.ts.map +1 -0
  52. package/dist/control_backbone.js +698 -0
  53. package/dist/data-governance.d.ts +187 -0
  54. package/dist/data-governance.d.ts.map +1 -0
  55. package/dist/data-governance.js +424 -0
  56. package/dist/dataResidency.d.ts +44 -0
  57. package/dist/dataResidency.d.ts.map +1 -0
  58. package/dist/dataResidency.js +203 -0
  59. package/dist/dispatcher.d.ts.map +1 -1
  60. package/dist/dispatcher.js +17 -5
  61. package/dist/evidence_store.d.ts +103 -0
  62. package/dist/evidence_store.d.ts.map +1 -0
  63. package/dist/evidence_store.js +459 -0
  64. package/dist/executiveSummary.d.ts +15 -0
  65. package/dist/executiveSummary.d.ts.map +1 -1
  66. package/dist/executiveSummary.js +135 -22
  67. package/dist/identity.d.ts +143 -0
  68. package/dist/identity.d.ts.map +1 -0
  69. package/dist/identity.js +231 -0
  70. package/dist/impact-assessment.d.ts +350 -0
  71. package/dist/impact-assessment.d.ts.map +1 -0
  72. package/dist/impact-assessment.js +580 -0
  73. package/dist/index.d.ts +20 -4
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +247 -5
  76. package/dist/instrumentation.d.ts +1 -1
  77. package/dist/instrumentation.d.ts.map +1 -1
  78. package/dist/instrumentation.js +123 -22
  79. package/dist/integrations/anthropic.d.ts +3 -0
  80. package/dist/integrations/anthropic.d.ts.map +1 -1
  81. package/dist/integrations/anthropic.js +282 -80
  82. package/dist/integrations/governance.d.ts +33 -0
  83. package/dist/integrations/governance.d.ts.map +1 -0
  84. package/dist/integrations/governance.js +208 -0
  85. package/dist/integrations/langchain.d.ts +4 -0
  86. package/dist/integrations/langchain.d.ts.map +1 -1
  87. package/dist/integrations/langchain.js +362 -142
  88. package/dist/integrations/openai.d.ts +9 -0
  89. package/dist/integrations/openai.d.ts.map +1 -1
  90. package/dist/integrations/openai.js +673 -73
  91. package/dist/iso42001_consolidation.d.ts +16 -0
  92. package/dist/iso42001_consolidation.d.ts.map +1 -0
  93. package/dist/iso42001_consolidation.js +413 -0
  94. package/dist/iso42001_workflows.d.ts +263 -0
  95. package/dist/iso42001_workflows.d.ts.map +1 -0
  96. package/dist/iso42001_workflows.js +781 -0
  97. package/dist/lifecycle.d.ts +299 -0
  98. package/dist/lifecycle.d.ts.map +1 -0
  99. package/dist/lifecycle.js +624 -0
  100. package/dist/lineage.d.ts +2 -2
  101. package/dist/lineage.d.ts.map +1 -1
  102. package/dist/lineage.js +9 -16
  103. package/dist/middleware/express.d.ts.map +1 -1
  104. package/dist/middleware/express.js +18 -3
  105. package/dist/middleware/nextjs.js +2 -2
  106. package/dist/model.d.ts +143 -0
  107. package/dist/model.d.ts.map +1 -0
  108. package/dist/model.js +371 -0
  109. package/dist/onboarding.d.ts +42 -0
  110. package/dist/onboarding.d.ts.map +1 -0
  111. package/dist/onboarding.js +1022 -0
  112. package/dist/oversight.d.ts +264 -0
  113. package/dist/oversight.d.ts.map +1 -0
  114. package/dist/oversight.js +497 -0
  115. package/dist/presets.js +7 -7
  116. package/dist/quotas.d.ts +171 -0
  117. package/dist/quotas.d.ts.map +1 -0
  118. package/dist/quotas.js +259 -0
  119. package/dist/register.d.ts +13 -0
  120. package/dist/register.d.ts.map +1 -0
  121. package/dist/register.js +99 -0
  122. package/dist/registry.d.ts +1 -0
  123. package/dist/registry.d.ts.map +1 -1
  124. package/dist/registry.js +7 -0
  125. package/dist/registryData.json +43 -6
  126. package/dist/report.d.ts +2 -1
  127. package/dist/report.d.ts.map +1 -1
  128. package/dist/report.js +189 -2
  129. package/dist/reporting.d.ts +125 -0
  130. package/dist/reporting.d.ts.map +1 -1
  131. package/dist/reporting.js +192 -2
  132. package/dist/resources.d.ts +285 -0
  133. package/dist/resources.d.ts.map +1 -0
  134. package/dist/resources.js +643 -0
  135. package/dist/risk.d.ts +120 -0
  136. package/dist/risk.d.ts.map +1 -0
  137. package/dist/risk.js +220 -0
  138. package/dist/runtime.d.ts +73 -0
  139. package/dist/runtime.d.ts.map +1 -1
  140. package/dist/runtime.js +415 -18
  141. package/dist/schemaInference.d.ts +92 -0
  142. package/dist/schemaInference.d.ts.map +1 -0
  143. package/dist/schemaInference.js +466 -0
  144. package/dist/schema_validation.js +2 -2
  145. package/dist/schemas/config.schema.json +118 -4
  146. package/dist/security_report.js +4 -4
  147. package/dist/signing.d.ts +1 -1
  148. package/dist/signing.d.ts.map +1 -1
  149. package/dist/signing.js +4 -0
  150. package/dist/sinks/file.d.ts +19 -1
  151. package/dist/sinks/file.d.ts.map +1 -1
  152. package/dist/sinks/file.js +82 -13
  153. package/dist/sinks/https.d.ts +10 -0
  154. package/dist/sinks/https.d.ts.map +1 -1
  155. package/dist/sinks/https.js +76 -16
  156. package/dist/sinks/stdout.d.ts +1 -0
  157. package/dist/sinks/stdout.d.ts.map +1 -1
  158. package/dist/sinks/stdout.js +12 -1
  159. package/dist/spec.d.ts +159 -0
  160. package/dist/spec.d.ts.map +1 -0
  161. package/dist/spec.js +391 -0
  162. package/dist/stakeholders.d.ts +199 -0
  163. package/dist/stakeholders.d.ts.map +1 -0
  164. package/dist/stakeholders.js +398 -0
  165. package/dist/standards.d.ts.map +1 -1
  166. package/dist/standards.js +160 -2
  167. package/dist/standards_ingest.d.ts.map +1 -1
  168. package/dist/standards_ingest.js +1 -4
  169. package/dist/telemetry.d.ts +16 -2
  170. package/dist/telemetry.d.ts.map +1 -1
  171. package/dist/telemetry.js +77 -14
  172. package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
  173. package/dist/traced_emitter.d.ts.map +1 -1
  174. package/dist/traced_emitter.js +19 -9
  175. package/dist/trust_package.d.ts +19 -1
  176. package/dist/trust_package.d.ts.map +1 -1
  177. package/dist/trust_package.js +89 -2
  178. package/dist/verify.d.ts.map +1 -1
  179. package/dist/verify.js +9 -2
  180. package/dist/wal.d.ts.map +1 -1
  181. package/dist/wal.js +2 -1
  182. package/package.json +14 -1
  183. package/scripts/postinstall.js +105 -210
  184. package/templates/controls/iso42001_control_catalog.json +1443 -0
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Stakeholder & Third-Party Management for ISO 42001 A.8/A.10 compliance.
3
+ *
4
+ * This module provides stakeholder and third-party management supporting ISO 42001:
5
+ * - A.8.2: System documentation for users
6
+ * - A.10.2: Allocating responsibilities
7
+ * - A.10.3: Suppliers
8
+ * - A.10.4: Customers
9
+ *
10
+ * Cross-SDK Parity:
11
+ * Both Python and Node.js SDKs provide identical stakeholder APIs:
12
+ * - registerStakeholder() / register_stakeholder()
13
+ * - registerSupplier() / register_supplier()
14
+ * - registerCustomer() / register_customer()
15
+ * - allocateResponsibility() / allocate_responsibility()
16
+ */
17
+ import { MonoraConfig } from './config';
18
+ export type StakeholderType = 'user' | 'customer' | 'supplier' | 'regulator' | 'internal' | 'public';
19
+ export type SupplierRiskLevel = 'low' | 'medium' | 'high' | 'critical';
20
+ export type SupplierStatus = 'approved' | 'conditional' | 'under_review' | 'blocked';
21
+ export type ResponsibilityCategory = 'development' | 'operation' | 'governance' | 'compliance' | 'support';
22
+ /**
23
+ * Reference to documentation provided to stakeholder (A.8.2).
24
+ */
25
+ export interface DocumentRef {
26
+ docId: string;
27
+ title: string;
28
+ docType: string;
29
+ pathOrUrl: string;
30
+ version: string;
31
+ lastUpdated: string;
32
+ }
33
+ export declare function documentRefToDict(doc: DocumentRef): Record<string, any>;
34
+ /**
35
+ * A responsibility allocation (A.10.2).
36
+ */
37
+ export interface Responsibility {
38
+ responsibilityId: string;
39
+ description: string;
40
+ category: ResponsibilityCategory;
41
+ assignedTo: string;
42
+ agreedAt: string;
43
+ }
44
+ export declare function responsibilityToDict(resp: Responsibility): Record<string, any>;
45
+ /**
46
+ * Stakeholder record for ISO 42001 A.8/A.10.
47
+ */
48
+ export interface StakeholderRecord {
49
+ partyId: string;
50
+ name: string;
51
+ type: StakeholderType;
52
+ informationRequirements: string[];
53
+ documentationProvided: DocumentRef[];
54
+ responsibilities: Responsibility[];
55
+ contact: string;
56
+ communicationChannel: string;
57
+ notificationPreferences: Record<string, any>;
58
+ createdAt: string;
59
+ updatedAt: string;
60
+ }
61
+ export declare function stakeholderRecordToDict(record: StakeholderRecord): Record<string, any>;
62
+ /**
63
+ * Supplier record for ISO 42001 A.10.3.
64
+ */
65
+ export interface SupplierRecord {
66
+ supplierId: string;
67
+ name: string;
68
+ services: string[];
69
+ riskLevel: SupplierRiskLevel;
70
+ complianceRequirements: string[];
71
+ certifications: string[];
72
+ lastAssessmentDate?: string;
73
+ assessmentResults: Record<string, any>;
74
+ status: SupplierStatus;
75
+ contractRef: string;
76
+ contractExpiry?: string;
77
+ slaRequirements: Record<string, any>;
78
+ createdAt: string;
79
+ updatedAt: string;
80
+ }
81
+ export declare function supplierRecordToDict(record: SupplierRecord): Record<string, any>;
82
+ /**
83
+ * Customer record for ISO 42001 A.10.4.
84
+ */
85
+ export interface CustomerRecord {
86
+ customerId: string;
87
+ name: string;
88
+ statedNeeds: string[];
89
+ expectations: string[];
90
+ constraints: string[];
91
+ supportLevel: string;
92
+ escalationContact: string;
93
+ createdAt: string;
94
+ updatedAt: string;
95
+ }
96
+ export declare function customerRecordToDict(record: CustomerRecord): Record<string, any>;
97
+ /**
98
+ * Register a stakeholder.
99
+ */
100
+ export interface RegisterStakeholderOptions {
101
+ name: string;
102
+ stakeholderType: StakeholderType;
103
+ informationRequirements?: string[];
104
+ contact?: string;
105
+ communicationChannel?: string;
106
+ }
107
+ export declare function registerStakeholder(options: RegisterStakeholderOptions): StakeholderRecord;
108
+ export declare function getStakeholder(partyId: string): StakeholderRecord | undefined;
109
+ export declare function getAllStakeholders(): StakeholderRecord[];
110
+ /**
111
+ * Add documentation provided to stakeholder (A.8.2).
112
+ */
113
+ export interface AddStakeholderDocumentationOptions {
114
+ partyId: string;
115
+ title: string;
116
+ docType: string;
117
+ pathOrUrl: string;
118
+ version?: string;
119
+ }
120
+ export declare function addStakeholderDocumentation(options: AddStakeholderDocumentationOptions): DocumentRef;
121
+ /**
122
+ * Allocate a responsibility to a stakeholder (A.10.2).
123
+ */
124
+ export interface AllocateResponsibilityOptions {
125
+ partyId: string;
126
+ description: string;
127
+ category: ResponsibilityCategory;
128
+ }
129
+ export declare function allocateResponsibility(options: AllocateResponsibilityOptions): Responsibility;
130
+ /**
131
+ * Register a supplier (A.10.3).
132
+ */
133
+ export interface RegisterSupplierOptions {
134
+ name: string;
135
+ services?: string[];
136
+ riskLevel?: SupplierRiskLevel;
137
+ complianceRequirements?: string[];
138
+ certifications?: string[];
139
+ contractRef?: string;
140
+ config?: MonoraConfig;
141
+ }
142
+ export declare function registerSupplier(options: RegisterSupplierOptions): SupplierRecord;
143
+ export declare function getSupplier(supplierId: string): SupplierRecord | undefined;
144
+ export declare function getAllSuppliers(): SupplierRecord[];
145
+ /**
146
+ * Record supplier assessment results.
147
+ */
148
+ export interface AssessSupplierOptions {
149
+ supplierId: string;
150
+ assessmentResults: Record<string, any>;
151
+ assessedBy?: string;
152
+ }
153
+ export declare function assessSupplier(options: AssessSupplierOptions): SupplierRecord;
154
+ /**
155
+ * Update supplier approval status.
156
+ */
157
+ export interface UpdateSupplierStatusOptions {
158
+ supplierId: string;
159
+ status: SupplierStatus;
160
+ config?: MonoraConfig;
161
+ }
162
+ export declare function updateSupplierStatus(options: UpdateSupplierStatusOptions): SupplierRecord;
163
+ /**
164
+ * Register a customer (A.10.4).
165
+ */
166
+ export interface RegisterCustomerOptions {
167
+ name: string;
168
+ statedNeeds?: string[];
169
+ expectations?: string[];
170
+ constraints?: string[];
171
+ supportLevel?: string;
172
+ escalationContact?: string;
173
+ }
174
+ export declare function registerCustomer(options: RegisterCustomerOptions): CustomerRecord;
175
+ export declare function getCustomer(customerId: string): CustomerRecord | undefined;
176
+ export declare function getAllCustomers(): CustomerRecord[];
177
+ /**
178
+ * Update customer needs and expectations.
179
+ */
180
+ export interface UpdateCustomerNeedsOptions {
181
+ customerId: string;
182
+ statedNeeds?: string[];
183
+ expectations?: string[];
184
+ constraints?: string[];
185
+ }
186
+ export declare function updateCustomerNeeds(options: UpdateCustomerNeedsOptions): CustomerRecord;
187
+ export declare function clearStakeholders(): void;
188
+ export declare function clearSuppliers(): void;
189
+ export declare function clearCustomers(): void;
190
+ export declare function clearAll(): void;
191
+ /**
192
+ * Get summary of supplier risk levels.
193
+ */
194
+ export declare function getSupplierRiskSummary(config?: MonoraConfig): Record<string, any>;
195
+ /**
196
+ * Get aggregate stakeholder report.
197
+ */
198
+ export declare function getStakeholderReport(config?: MonoraConfig): Record<string, any>;
199
+ //# sourceMappingURL=stakeholders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stakeholders.d.ts","sourceRoot":"","sources":["../src/stakeholders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AACrG,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AACvE,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,aAAa,GAAG,cAAc,GAAG,SAAS,CAAC;AACrF,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,CAAC;AAY3G;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CA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,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwC/E"}
@@ -0,0 +1,398 @@
1
+ "use strict";
2
+ /**
3
+ * Stakeholder & Third-Party Management for ISO 42001 A.8/A.10 compliance.
4
+ *
5
+ * This module provides stakeholder and third-party management supporting ISO 42001:
6
+ * - A.8.2: System documentation for users
7
+ * - A.10.2: Allocating responsibilities
8
+ * - A.10.3: Suppliers
9
+ * - A.10.4: Customers
10
+ *
11
+ * Cross-SDK Parity:
12
+ * Both Python and Node.js SDKs provide identical stakeholder APIs:
13
+ * - registerStakeholder() / register_stakeholder()
14
+ * - registerSupplier() / register_supplier()
15
+ * - registerCustomer() / register_customer()
16
+ * - allocateResponsibility() / allocate_responsibility()
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.documentRefToDict = documentRefToDict;
20
+ exports.responsibilityToDict = responsibilityToDict;
21
+ exports.stakeholderRecordToDict = stakeholderRecordToDict;
22
+ exports.supplierRecordToDict = supplierRecordToDict;
23
+ exports.customerRecordToDict = customerRecordToDict;
24
+ exports.registerStakeholder = registerStakeholder;
25
+ exports.getStakeholder = getStakeholder;
26
+ exports.getAllStakeholders = getAllStakeholders;
27
+ exports.addStakeholderDocumentation = addStakeholderDocumentation;
28
+ exports.allocateResponsibility = allocateResponsibility;
29
+ exports.registerSupplier = registerSupplier;
30
+ exports.getSupplier = getSupplier;
31
+ exports.getAllSuppliers = getAllSuppliers;
32
+ exports.assessSupplier = assessSupplier;
33
+ exports.updateSupplierStatus = updateSupplierStatus;
34
+ exports.registerCustomer = registerCustomer;
35
+ exports.getCustomer = getCustomer;
36
+ exports.getAllCustomers = getAllCustomers;
37
+ exports.updateCustomerNeeds = updateCustomerNeeds;
38
+ exports.clearStakeholders = clearStakeholders;
39
+ exports.clearSuppliers = clearSuppliers;
40
+ exports.clearCustomers = clearCustomers;
41
+ exports.clearAll = clearAll;
42
+ exports.getSupplierRiskSummary = getSupplierRiskSummary;
43
+ exports.getStakeholderReport = getStakeholderReport;
44
+ const crypto_1 = require("crypto");
45
+ const logger_1 = require("./logger");
46
+ function generateId(prefix, ...parts) {
47
+ const combined = parts.join(':');
48
+ const hash = (0, crypto_1.createHash)('sha256').update(combined).digest('hex').slice(0, 12);
49
+ return `${prefix}_${hash}`;
50
+ }
51
+ function nowIso() {
52
+ return new Date().toISOString();
53
+ }
54
+ function documentRefToDict(doc) {
55
+ return {
56
+ doc_id: doc.docId,
57
+ title: doc.title,
58
+ doc_type: doc.docType,
59
+ path_or_url: doc.pathOrUrl,
60
+ version: doc.version,
61
+ last_updated: doc.lastUpdated,
62
+ };
63
+ }
64
+ function responsibilityToDict(resp) {
65
+ return {
66
+ responsibility_id: resp.responsibilityId,
67
+ description: resp.description,
68
+ category: resp.category,
69
+ assigned_to: resp.assignedTo,
70
+ agreed_at: resp.agreedAt,
71
+ };
72
+ }
73
+ function stakeholderRecordToDict(record) {
74
+ return {
75
+ party_id: record.partyId,
76
+ name: record.name,
77
+ type: record.type,
78
+ information_requirements: record.informationRequirements,
79
+ documentation_provided: record.documentationProvided.map(documentRefToDict),
80
+ responsibilities: record.responsibilities.map(responsibilityToDict),
81
+ contact: record.contact,
82
+ communication_channel: record.communicationChannel,
83
+ notification_preferences: record.notificationPreferences,
84
+ created_at: record.createdAt,
85
+ updated_at: record.updatedAt,
86
+ };
87
+ }
88
+ function supplierRecordToDict(record) {
89
+ const result = {
90
+ supplier_id: record.supplierId,
91
+ name: record.name,
92
+ services: record.services,
93
+ risk_level: record.riskLevel,
94
+ compliance_requirements: record.complianceRequirements,
95
+ certifications: record.certifications,
96
+ status: record.status,
97
+ contract_ref: record.contractRef,
98
+ sla_requirements: record.slaRequirements,
99
+ created_at: record.createdAt,
100
+ updated_at: record.updatedAt,
101
+ };
102
+ if (record.lastAssessmentDate) {
103
+ result.last_assessment_date = record.lastAssessmentDate;
104
+ }
105
+ if (Object.keys(record.assessmentResults).length > 0) {
106
+ result.assessment_results = record.assessmentResults;
107
+ }
108
+ if (record.contractExpiry) {
109
+ result.contract_expiry = record.contractExpiry;
110
+ }
111
+ return result;
112
+ }
113
+ function customerRecordToDict(record) {
114
+ return {
115
+ customer_id: record.customerId,
116
+ name: record.name,
117
+ stated_needs: record.statedNeeds,
118
+ expectations: record.expectations,
119
+ constraints: record.constraints,
120
+ support_level: record.supportLevel,
121
+ escalation_contact: record.escalationContact,
122
+ created_at: record.createdAt,
123
+ updated_at: record.updatedAt,
124
+ };
125
+ }
126
+ // Runtime registries
127
+ const stakeholders = new Map();
128
+ const suppliers = new Map();
129
+ const customers = new Map();
130
+ function registerStakeholder(options) {
131
+ const partyId = generateId('stk', options.name, options.stakeholderType);
132
+ const record = {
133
+ partyId,
134
+ name: options.name,
135
+ type: options.stakeholderType,
136
+ informationRequirements: options.informationRequirements || [],
137
+ documentationProvided: [],
138
+ responsibilities: [],
139
+ contact: options.contact || '',
140
+ communicationChannel: options.communicationChannel || 'email',
141
+ notificationPreferences: {},
142
+ createdAt: nowIso(),
143
+ updatedAt: nowIso(),
144
+ };
145
+ stakeholders.set(partyId, record);
146
+ return record;
147
+ }
148
+ function getStakeholder(partyId) {
149
+ return stakeholders.get(partyId);
150
+ }
151
+ function getAllStakeholders() {
152
+ return Array.from(stakeholders.values());
153
+ }
154
+ function addStakeholderDocumentation(options) {
155
+ const stakeholder = stakeholders.get(options.partyId);
156
+ if (!stakeholder) {
157
+ throw new Error(`Stakeholder ${options.partyId} not found`);
158
+ }
159
+ const docId = generateId('doc', options.partyId, options.title);
160
+ const doc = {
161
+ docId,
162
+ title: options.title,
163
+ docType: options.docType,
164
+ pathOrUrl: options.pathOrUrl,
165
+ version: options.version || '1.0',
166
+ lastUpdated: nowIso(),
167
+ };
168
+ stakeholder.documentationProvided.push(doc);
169
+ stakeholder.updatedAt = nowIso();
170
+ return doc;
171
+ }
172
+ function allocateResponsibility(options) {
173
+ const stakeholder = stakeholders.get(options.partyId);
174
+ if (!stakeholder) {
175
+ throw new Error(`Stakeholder ${options.partyId} not found`);
176
+ }
177
+ const respId = generateId('resp', options.partyId, options.description.slice(0, 20));
178
+ const responsibility = {
179
+ responsibilityId: respId,
180
+ description: options.description,
181
+ category: options.category,
182
+ assignedTo: options.partyId,
183
+ agreedAt: nowIso(),
184
+ };
185
+ stakeholder.responsibilities.push(responsibility);
186
+ stakeholder.updatedAt = nowIso();
187
+ return responsibility;
188
+ }
189
+ function registerSupplier(options) {
190
+ const supplierId = generateId('sup', options.name);
191
+ const record = {
192
+ supplierId,
193
+ name: options.name,
194
+ services: options.services || [],
195
+ riskLevel: options.riskLevel || 'medium',
196
+ complianceRequirements: options.complianceRequirements || [],
197
+ certifications: options.certifications || [],
198
+ assessmentResults: {},
199
+ status: 'under_review',
200
+ contractRef: options.contractRef || '',
201
+ slaRequirements: {},
202
+ createdAt: nowIso(),
203
+ updatedAt: nowIso(),
204
+ };
205
+ suppliers.set(supplierId, record);
206
+ return record;
207
+ }
208
+ function getSupplier(supplierId) {
209
+ return suppliers.get(supplierId);
210
+ }
211
+ function getAllSuppliers() {
212
+ return Array.from(suppliers.values());
213
+ }
214
+ function assessSupplier(options) {
215
+ const supplier = suppliers.get(options.supplierId);
216
+ if (!supplier) {
217
+ throw new Error(`Supplier ${options.supplierId} not found`);
218
+ }
219
+ supplier.lastAssessmentDate = new Date().toISOString().split('T')[0];
220
+ supplier.assessmentResults = {
221
+ ...options.assessmentResults,
222
+ assessed_by: options.assessedBy || '',
223
+ };
224
+ supplier.updatedAt = nowIso();
225
+ return supplier;
226
+ }
227
+ function updateSupplierStatus(options) {
228
+ const supplier = suppliers.get(options.supplierId);
229
+ if (!supplier) {
230
+ throw new Error(`Supplier ${options.supplierId} not found`);
231
+ }
232
+ const stakeholderConfig = options.config?.stakeholders;
233
+ const riskThresholds = stakeholderConfig?.risk_thresholds;
234
+ if (options.status === 'approved') {
235
+ if (supplier.riskLevel === 'critical' && riskThresholds?.critical_requires_approval !== false) {
236
+ if (Object.keys(supplier.assessmentResults).length === 0) {
237
+ throw new Error('Critical suppliers require assessment before approval');
238
+ }
239
+ }
240
+ if (supplier.riskLevel === 'high' && riskThresholds?.high_requires_review !== false) {
241
+ if (Object.keys(supplier.assessmentResults).length === 0) {
242
+ throw new Error('High risk suppliers require review before approval');
243
+ }
244
+ }
245
+ }
246
+ supplier.status = options.status;
247
+ supplier.updatedAt = nowIso();
248
+ // Emit supplier event
249
+ emitStakeholderEvent(supplier, 'supplier_status_change', options.config);
250
+ return supplier;
251
+ }
252
+ function registerCustomer(options) {
253
+ const customerId = generateId('cust', options.name);
254
+ const record = {
255
+ customerId,
256
+ name: options.name,
257
+ statedNeeds: options.statedNeeds || [],
258
+ expectations: options.expectations || [],
259
+ constraints: options.constraints || [],
260
+ supportLevel: options.supportLevel || 'standard',
261
+ escalationContact: options.escalationContact || '',
262
+ createdAt: nowIso(),
263
+ updatedAt: nowIso(),
264
+ };
265
+ customers.set(customerId, record);
266
+ return record;
267
+ }
268
+ function getCustomer(customerId) {
269
+ return customers.get(customerId);
270
+ }
271
+ function getAllCustomers() {
272
+ return Array.from(customers.values());
273
+ }
274
+ function updateCustomerNeeds(options) {
275
+ const customer = customers.get(options.customerId);
276
+ if (!customer) {
277
+ throw new Error(`Customer ${options.customerId} not found`);
278
+ }
279
+ if (options.statedNeeds !== undefined) {
280
+ customer.statedNeeds = options.statedNeeds;
281
+ }
282
+ if (options.expectations !== undefined) {
283
+ customer.expectations = options.expectations;
284
+ }
285
+ if (options.constraints !== undefined) {
286
+ customer.constraints = options.constraints;
287
+ }
288
+ customer.updatedAt = nowIso();
289
+ return customer;
290
+ }
291
+ function clearStakeholders() {
292
+ stakeholders.clear();
293
+ }
294
+ function clearSuppliers() {
295
+ suppliers.clear();
296
+ }
297
+ function clearCustomers() {
298
+ customers.clear();
299
+ }
300
+ function clearAll() {
301
+ stakeholders.clear();
302
+ suppliers.clear();
303
+ customers.clear();
304
+ }
305
+ /**
306
+ * Get summary of supplier risk levels.
307
+ */
308
+ function getSupplierRiskSummary(config) {
309
+ if (suppliers.size === 0) {
310
+ return {
311
+ total_suppliers: 0,
312
+ by_risk_level: {},
313
+ by_status: {},
314
+ };
315
+ }
316
+ const byRisk = {};
317
+ const byStatus = {};
318
+ suppliers.forEach(supplier => {
319
+ byRisk[supplier.riskLevel] = (byRisk[supplier.riskLevel] || 0) + 1;
320
+ byStatus[supplier.status] = (byStatus[supplier.status] || 0) + 1;
321
+ });
322
+ return {
323
+ total_suppliers: suppliers.size,
324
+ by_risk_level: byRisk,
325
+ by_status: byStatus,
326
+ };
327
+ }
328
+ /**
329
+ * Get aggregate stakeholder report.
330
+ */
331
+ function getStakeholderReport(config) {
332
+ const stakeholderSummary = [];
333
+ stakeholders.forEach(s => {
334
+ stakeholderSummary.push({
335
+ party_id: s.partyId,
336
+ name: s.name,
337
+ type: s.type,
338
+ responsibilities_count: s.responsibilities.length,
339
+ documentation_count: s.documentationProvided.length,
340
+ });
341
+ });
342
+ const supplierSummary = [];
343
+ suppliers.forEach(s => {
344
+ supplierSummary.push({
345
+ supplier_id: s.supplierId,
346
+ name: s.name,
347
+ risk_level: s.riskLevel,
348
+ status: s.status,
349
+ });
350
+ });
351
+ const customerSummary = [];
352
+ customers.forEach(c => {
353
+ customerSummary.push({
354
+ customer_id: c.customerId,
355
+ name: c.name,
356
+ support_level: c.supportLevel,
357
+ });
358
+ });
359
+ return {
360
+ total_stakeholders: stakeholders.size,
361
+ total_suppliers: suppliers.size,
362
+ total_customers: customers.size,
363
+ stakeholders: stakeholderSummary,
364
+ suppliers: supplierSummary,
365
+ customers: customerSummary,
366
+ supplier_risk_summary: getSupplierRiskSummary(config),
367
+ };
368
+ }
369
+ /**
370
+ * Emit a stakeholder event.
371
+ */
372
+ function emitStakeholderEvent(record, eventType, config) {
373
+ try {
374
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
375
+ const { getState } = require('./runtime');
376
+ const state = getState();
377
+ if (state && typeof state.emitInternal === 'function') {
378
+ let body;
379
+ if ('supplierId' in record) {
380
+ body = supplierRecordToDict(record);
381
+ }
382
+ else if ('partyId' in record) {
383
+ body = stakeholderRecordToDict(record);
384
+ }
385
+ else {
386
+ body = customerRecordToDict(record);
387
+ }
388
+ state.emitInternal({
389
+ event_type: eventType,
390
+ timestamp: nowIso(),
391
+ body,
392
+ });
393
+ }
394
+ }
395
+ catch (err) {
396
+ logger_1.logger.warning('Failed to emit stakeholder event:', err);
397
+ }
398
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"standards.d.ts","sourceRoot":"","sources":["../src/standards.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA24BxC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkDtB"}
1
+ {"version":3,"file":"standards.d.ts","sourceRoot":"","sources":["../src/standards.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAkkCxC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwDtB"}