monora-ai 2.0.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 (202) hide show
  1. package/README.md +441 -150
  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 +269 -0
  12. package/dist/assessment.d.ts.map +1 -0
  13. package/dist/assessment.js +1232 -0
  14. package/dist/attestation.js +23 -1
  15. package/dist/attribution.d.ts +349 -0
  16. package/dist/attribution.d.ts.map +1 -0
  17. package/dist/attribution.js +987 -0
  18. package/dist/autodetect.d.ts +69 -1
  19. package/dist/autodetect.d.ts.map +1 -1
  20. package/dist/autodetect.js +644 -1
  21. package/dist/bias.d.ts +130 -0
  22. package/dist/bias.d.ts.map +1 -0
  23. package/dist/bias.js +223 -0
  24. package/dist/circuit_breaker.js +3 -3
  25. package/dist/cli/diagnostics.d.ts +5 -1
  26. package/dist/cli/diagnostics.d.ts.map +1 -1
  27. package/dist/cli/diagnostics.js +31 -8
  28. package/dist/cli/doctor.d.ts +25 -0
  29. package/dist/cli/doctor.d.ts.map +1 -0
  30. package/dist/cli/doctor.js +381 -0
  31. package/dist/cli/fix.d.ts +16 -0
  32. package/dist/cli/fix.d.ts.map +1 -0
  33. package/dist/cli/fix.js +284 -0
  34. package/dist/cli/init.d.ts +57 -0
  35. package/dist/cli/init.d.ts.map +1 -0
  36. package/dist/cli/init.js +205 -0
  37. package/dist/cli.js +1611 -126
  38. package/dist/complianceTargets.d.ts +111 -0
  39. package/dist/complianceTargets.d.ts.map +1 -0
  40. package/dist/complianceTargets.js +521 -0
  41. package/dist/config.d.ts +301 -17
  42. package/dist/config.d.ts.map +1 -1
  43. package/dist/config.js +428 -36
  44. package/dist/config_migrations.d.ts +41 -0
  45. package/dist/config_migrations.d.ts.map +1 -1
  46. package/dist/config_migrations.js +205 -0
  47. package/dist/config_schema.d.ts +2900 -731
  48. package/dist/config_schema.d.ts.map +1 -1
  49. package/dist/config_schema.js +257 -55
  50. package/dist/context.d.ts +34 -0
  51. package/dist/context.d.ts.map +1 -1
  52. package/dist/context.js +118 -7
  53. package/dist/control_backbone.d.ts +122 -0
  54. package/dist/control_backbone.d.ts.map +1 -0
  55. package/dist/control_backbone.js +698 -0
  56. package/dist/data-governance.d.ts +187 -0
  57. package/dist/data-governance.d.ts.map +1 -0
  58. package/dist/data-governance.js +424 -0
  59. package/dist/dataResidency.d.ts +44 -0
  60. package/dist/dataResidency.d.ts.map +1 -0
  61. package/dist/dataResidency.js +203 -0
  62. package/dist/dispatcher.d.ts +32 -0
  63. package/dist/dispatcher.d.ts.map +1 -1
  64. package/dist/dispatcher.js +91 -4
  65. package/dist/events.d.ts.map +1 -1
  66. package/dist/events.js +38 -0
  67. package/dist/evidence_store.d.ts +103 -0
  68. package/dist/evidence_store.d.ts.map +1 -0
  69. package/dist/evidence_store.js +459 -0
  70. package/dist/executiveSummary.d.ts +65 -8
  71. package/dist/executiveSummary.d.ts.map +1 -1
  72. package/dist/executiveSummary.js +289 -26
  73. package/dist/identity.d.ts +143 -0
  74. package/dist/identity.d.ts.map +1 -0
  75. package/dist/identity.js +231 -0
  76. package/dist/impact-assessment.d.ts +350 -0
  77. package/dist/impact-assessment.d.ts.map +1 -0
  78. package/dist/impact-assessment.js +580 -0
  79. package/dist/index.d.ts +25 -5
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +300 -4
  82. package/dist/instrumentation.d.ts +1 -1
  83. package/dist/instrumentation.d.ts.map +1 -1
  84. package/dist/instrumentation.js +243 -27
  85. package/dist/integrations/anthropic.d.ts +3 -0
  86. package/dist/integrations/anthropic.d.ts.map +1 -1
  87. package/dist/integrations/anthropic.js +284 -79
  88. package/dist/integrations/governance.d.ts +33 -0
  89. package/dist/integrations/governance.d.ts.map +1 -0
  90. package/dist/integrations/governance.js +208 -0
  91. package/dist/integrations/langchain.d.ts +7 -0
  92. package/dist/integrations/langchain.d.ts.map +1 -1
  93. package/dist/integrations/langchain.js +387 -143
  94. package/dist/integrations/openai.d.ts +9 -0
  95. package/dist/integrations/openai.d.ts.map +1 -1
  96. package/dist/integrations/openai.js +673 -73
  97. package/dist/iso42001_consolidation.d.ts +16 -0
  98. package/dist/iso42001_consolidation.d.ts.map +1 -0
  99. package/dist/iso42001_consolidation.js +413 -0
  100. package/dist/iso42001_workflows.d.ts +263 -0
  101. package/dist/iso42001_workflows.d.ts.map +1 -0
  102. package/dist/iso42001_workflows.js +781 -0
  103. package/dist/lifecycle.d.ts +299 -0
  104. package/dist/lifecycle.d.ts.map +1 -0
  105. package/dist/lifecycle.js +624 -0
  106. package/dist/lineage.d.ts +2 -2
  107. package/dist/lineage.d.ts.map +1 -1
  108. package/dist/lineage.js +12 -17
  109. package/dist/middleware/express.d.ts.map +1 -1
  110. package/dist/middleware/express.js +33 -3
  111. package/dist/middleware/nextjs.d.ts.map +1 -1
  112. package/dist/middleware/nextjs.js +42 -68
  113. package/dist/model.d.ts +143 -0
  114. package/dist/model.d.ts.map +1 -0
  115. package/dist/model.js +371 -0
  116. package/dist/onboarding.d.ts +42 -0
  117. package/dist/onboarding.d.ts.map +1 -0
  118. package/dist/onboarding.js +1022 -0
  119. package/dist/oversight.d.ts +264 -0
  120. package/dist/oversight.d.ts.map +1 -0
  121. package/dist/oversight.js +497 -0
  122. package/dist/pdf_report.d.ts.map +1 -1
  123. package/dist/pdf_report.js +42 -21
  124. package/dist/presets.d.ts +88 -0
  125. package/dist/presets.d.ts.map +1 -0
  126. package/dist/presets.js +520 -0
  127. package/dist/propagation.d.ts.map +1 -1
  128. package/dist/propagation.js +34 -2
  129. package/dist/quotas.d.ts +171 -0
  130. package/dist/quotas.d.ts.map +1 -0
  131. package/dist/quotas.js +259 -0
  132. package/dist/register.d.ts +13 -0
  133. package/dist/register.d.ts.map +1 -0
  134. package/dist/register.js +99 -0
  135. package/dist/registry.d.ts +1 -0
  136. package/dist/registry.d.ts.map +1 -1
  137. package/dist/registry.js +7 -0
  138. package/dist/registryData.json +43 -6
  139. package/dist/report.d.ts +2 -1
  140. package/dist/report.d.ts.map +1 -1
  141. package/dist/report.js +189 -2
  142. package/dist/reporting.d.ts +125 -0
  143. package/dist/reporting.d.ts.map +1 -1
  144. package/dist/reporting.js +196 -5
  145. package/dist/resources.d.ts +285 -0
  146. package/dist/resources.d.ts.map +1 -0
  147. package/dist/resources.js +643 -0
  148. package/dist/risk.d.ts +120 -0
  149. package/dist/risk.d.ts.map +1 -0
  150. package/dist/risk.js +220 -0
  151. package/dist/runtime.d.ts +74 -1
  152. package/dist/runtime.d.ts.map +1 -1
  153. package/dist/runtime.js +598 -22
  154. package/dist/schemaInference.d.ts +92 -0
  155. package/dist/schemaInference.d.ts.map +1 -0
  156. package/dist/schemaInference.js +466 -0
  157. package/dist/schema_validation.js +2 -2
  158. package/dist/schemas/config.schema.json +169 -6
  159. package/dist/schemas/event.schema.json +4 -0
  160. package/dist/security_report.js +4 -4
  161. package/dist/signing.d.ts +1 -1
  162. package/dist/signing.d.ts.map +1 -1
  163. package/dist/signing.js +4 -0
  164. package/dist/sinks/file.d.ts +19 -1
  165. package/dist/sinks/file.d.ts.map +1 -1
  166. package/dist/sinks/file.js +82 -13
  167. package/dist/sinks/https.d.ts +10 -0
  168. package/dist/sinks/https.d.ts.map +1 -1
  169. package/dist/sinks/https.js +76 -16
  170. package/dist/sinks/stdout.d.ts +1 -0
  171. package/dist/sinks/stdout.d.ts.map +1 -1
  172. package/dist/sinks/stdout.js +12 -1
  173. package/dist/spec.d.ts +159 -0
  174. package/dist/spec.d.ts.map +1 -0
  175. package/dist/spec.js +391 -0
  176. package/dist/stakeholders.d.ts +199 -0
  177. package/dist/stakeholders.d.ts.map +1 -0
  178. package/dist/stakeholders.js +398 -0
  179. package/dist/standards.d.ts.map +1 -1
  180. package/dist/standards.js +160 -2
  181. package/dist/standards_ingest.d.ts +2 -2
  182. package/dist/standards_ingest.d.ts.map +1 -1
  183. package/dist/standards_ingest.js +105 -23
  184. package/dist/streaming.d.ts.map +1 -1
  185. package/dist/streaming.js +7 -2
  186. package/dist/telemetry.d.ts +16 -2
  187. package/dist/telemetry.d.ts.map +1 -1
  188. package/dist/telemetry.js +79 -14
  189. package/dist/templates/controls/iso42001_control_catalog.json +1443 -0
  190. package/dist/traced_emitter.d.ts +3 -0
  191. package/dist/traced_emitter.d.ts.map +1 -1
  192. package/dist/traced_emitter.js +142 -25
  193. package/dist/trust_package.d.ts +21 -1
  194. package/dist/trust_package.d.ts.map +1 -1
  195. package/dist/trust_package.js +101 -4
  196. package/dist/verify.d.ts.map +1 -1
  197. package/dist/verify.js +9 -2
  198. package/dist/wal.d.ts.map +1 -1
  199. package/dist/wal.js +2 -1
  200. package/package.json +14 -1
  201. package/scripts/postinstall.js +119 -97
  202. package/templates/controls/iso42001_control_catalog.json +1443 -0
package/dist/model.js ADDED
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ /**
3
+ * MonoraModel - Registered AI model/application with its specification.
4
+ *
5
+ * Provides the MonoraModel class for registering and managing AI models/applications
6
+ * being monitored by Monora.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.createValidationResult = createValidationResult;
43
+ exports.validationResultToDict = validationResultToDict;
44
+ exports.createMonoraModel = createMonoraModel;
45
+ exports.modelFromData = modelFromData;
46
+ exports.modelFromSpec = modelFromSpec;
47
+ exports.validateEvent = validateEvent;
48
+ exports.generateConfig = generateConfig;
49
+ exports.modelToDict = modelToDict;
50
+ exports.modelToJson = modelToJson;
51
+ exports.modelFromDict = modelFromDict;
52
+ exports.modelFromJson = modelFromJson;
53
+ exports.saveModel = saveModel;
54
+ exports.loadModel = loadModel;
55
+ exports.saveSchemaContract = saveSchemaContract;
56
+ exports.saveConfig = saveConfig;
57
+ exports.modelToString = modelToString;
58
+ const fs = __importStar(require("fs"));
59
+ const path = __importStar(require("path"));
60
+ const spec_1 = require("./spec");
61
+ const schemaInference_1 = require("./schemaInference");
62
+ /**
63
+ * Create a ValidationResult.
64
+ */
65
+ function createValidationResult(valid, errors = [], warnings = []) {
66
+ return { valid, errors, warnings };
67
+ }
68
+ /**
69
+ * Convert ValidationResult to dictionary.
70
+ */
71
+ function validationResultToDict(result) {
72
+ return {
73
+ valid: result.valid,
74
+ errors: result.errors.map((e) => ({
75
+ field: e.field,
76
+ message: e.message,
77
+ expected: e.expected,
78
+ actual: e.actual,
79
+ })),
80
+ warnings: result.warnings,
81
+ };
82
+ }
83
+ /**
84
+ * Create a MonoraModel instance.
85
+ */
86
+ function createMonoraModel(options) {
87
+ return {
88
+ modelId: options.modelId,
89
+ spec: options.spec,
90
+ riskCategory: options.riskCategory ?? 'limited',
91
+ intendedUse: options.intendedUse,
92
+ createdAt: new Date().toISOString(),
93
+ updatedAt: undefined,
94
+ tags: options.tags ?? [],
95
+ owner: options.owner,
96
+ };
97
+ }
98
+ /**
99
+ * Create a MonoraModel from sample data using schema inference.
100
+ *
101
+ * This is the primary way to create a model when you have sample events.
102
+ * It analyzes the events to infer the schema, detect PII, and configure
103
+ * appropriate enrichments.
104
+ */
105
+ function modelFromData(options) {
106
+ const { source, modelName = 'unnamed-model', modelVersion = '1.0.0', complianceTargets, riskCategory = 'limited', intendedUse, detectPii = true, sampleSize = 100, tags = [], owner, } = options;
107
+ // Load events if source is a path
108
+ let events;
109
+ if (typeof source === 'string') {
110
+ events = (0, schemaInference_1.loadEventsFromFile)(source);
111
+ }
112
+ else {
113
+ events = source;
114
+ }
115
+ // Infer schema
116
+ const spec = (0, schemaInference_1.inferSchemaFromEvents)(events, {
117
+ modelName,
118
+ modelVersion,
119
+ complianceTargets,
120
+ detectPii,
121
+ sampleSize,
122
+ });
123
+ return createMonoraModel({
124
+ modelId: modelName,
125
+ spec,
126
+ riskCategory,
127
+ intendedUse,
128
+ tags,
129
+ owner,
130
+ });
131
+ }
132
+ /**
133
+ * Create a MonoraModel from an existing MonoraSpec.
134
+ */
135
+ function modelFromSpec(spec, options = {}) {
136
+ return createMonoraModel({
137
+ modelId: options.modelId || spec.modelName || 'unnamed-model',
138
+ spec,
139
+ riskCategory: options.riskCategory ?? 'limited',
140
+ intendedUse: options.intendedUse,
141
+ tags: options.tags ?? [],
142
+ owner: options.owner,
143
+ });
144
+ }
145
+ /**
146
+ * Flatten nested dictionary to dot-notation keys.
147
+ */
148
+ function flattenDict(obj, parentKey = '', sep = '.') {
149
+ const items = [];
150
+ for (const [k, v] of Object.entries(obj)) {
151
+ const newKey = parentKey ? `${parentKey}${sep}${k}` : k;
152
+ if (v && typeof v === 'object' && !Array.isArray(v)) {
153
+ const nested = flattenDict(v, newKey, sep);
154
+ items.push(...Object.entries(nested));
155
+ }
156
+ else {
157
+ items.push([newKey, v]);
158
+ }
159
+ }
160
+ return Object.fromEntries(items);
161
+ }
162
+ /**
163
+ * Get Python type(s) for a FieldType.
164
+ */
165
+ function getExpectedTypes(fieldType) {
166
+ const typeMapping = {
167
+ string: ['string'],
168
+ number: ['number'],
169
+ integer: ['number'],
170
+ boolean: ['boolean'],
171
+ array: ['array'],
172
+ object: ['object'],
173
+ };
174
+ return typeMapping[fieldType] || ['string'];
175
+ }
176
+ /**
177
+ * Check if a value matches the expected field type.
178
+ */
179
+ function matchesType(value, fieldType) {
180
+ const expectedTypes = getExpectedTypes(fieldType);
181
+ if (expectedTypes.includes('string') && typeof value === 'string')
182
+ return true;
183
+ if (expectedTypes.includes('number') && typeof value === 'number')
184
+ return true;
185
+ if (expectedTypes.includes('boolean') && typeof value === 'boolean')
186
+ return true;
187
+ if (expectedTypes.includes('array') && Array.isArray(value))
188
+ return true;
189
+ if (expectedTypes.includes('object') && typeof value === 'object' && !Array.isArray(value))
190
+ return true;
191
+ return false;
192
+ }
193
+ /**
194
+ * Validate an event against a model's specification.
195
+ */
196
+ function validateEvent(model, event) {
197
+ const errors = [];
198
+ const warnings = [];
199
+ // Flatten the event for field checking
200
+ const flatEvent = flattenDict(event);
201
+ const allFields = (0, spec_1.getAllFields)(model.spec);
202
+ // Check all required fields
203
+ for (const fieldSpec of allFields) {
204
+ if (fieldSpec.required) {
205
+ if (!(fieldSpec.name in flatEvent)) {
206
+ errors.push({
207
+ field: fieldSpec.name,
208
+ message: `Required field '${fieldSpec.name}' is missing`,
209
+ });
210
+ }
211
+ else if (flatEvent[fieldSpec.name] === null && !fieldSpec.nullable) {
212
+ errors.push({
213
+ field: fieldSpec.name,
214
+ message: `Field '${fieldSpec.name}' cannot be null`,
215
+ });
216
+ }
217
+ }
218
+ }
219
+ // Check field types
220
+ for (const fieldSpec of allFields) {
221
+ if (fieldSpec.name in flatEvent) {
222
+ const value = flatEvent[fieldSpec.name];
223
+ if (value !== null && value !== undefined) {
224
+ if (!matchesType(value, fieldSpec.dataType)) {
225
+ errors.push({
226
+ field: fieldSpec.name,
227
+ message: `Field '${fieldSpec.name}' has wrong type`,
228
+ expected: fieldSpec.dataType,
229
+ actual: typeof value,
230
+ });
231
+ }
232
+ }
233
+ }
234
+ }
235
+ // Check identifiers
236
+ for (const fieldSpec of model.spec.identifiers || []) {
237
+ if (!(fieldSpec.name in flatEvent)) {
238
+ warnings.push(`Identifier field '${fieldSpec.name}' is missing`);
239
+ }
240
+ }
241
+ return createValidationResult(errors.length === 0, errors, warnings);
242
+ }
243
+ /**
244
+ * Generate a complete Monora configuration from a model.
245
+ */
246
+ function generateConfig(model) {
247
+ const config = (0, spec_1.specToConfig)(model.spec);
248
+ // Add model-specific configuration
249
+ config.defaults = config.defaults || {};
250
+ config.defaults.service_name = model.modelId;
251
+ // Add risk category for AI Act compliance
252
+ config.ai_act = config.ai_act || { enabled: true };
253
+ config.ai_act.default_risk_category = model.riskCategory;
254
+ // Add model metadata to onboarding section
255
+ config.onboarding = config.onboarding || { enabled: true };
256
+ config.onboarding.model_spec = {
257
+ name: model.modelId,
258
+ version: model.spec.modelVersion,
259
+ event_ts_field: model.spec.eventTimestampField,
260
+ risk_category: model.riskCategory,
261
+ intended_use: model.intendedUse,
262
+ roles: {
263
+ inputs: model.spec.inputs.map((f) => f.name),
264
+ outputs: model.spec.outputs.map((f) => f.name),
265
+ metadata: (model.spec.metadata || []).map((f) => f.name),
266
+ identifiers: (model.spec.identifiers || []).map((f) => f.name),
267
+ },
268
+ };
269
+ return config;
270
+ }
271
+ /**
272
+ * Convert MonoraModel to dictionary representation.
273
+ */
274
+ function modelToDict(model) {
275
+ return {
276
+ model_id: model.modelId,
277
+ spec: (0, spec_1.specToDict)(model.spec),
278
+ risk_category: model.riskCategory,
279
+ intended_use: model.intendedUse,
280
+ created_at: model.createdAt,
281
+ updated_at: model.updatedAt,
282
+ tags: model.tags,
283
+ owner: model.owner,
284
+ };
285
+ }
286
+ /**
287
+ * Convert MonoraModel to JSON string.
288
+ */
289
+ function modelToJson(model, indent = 2) {
290
+ return JSON.stringify(modelToDict(model), null, indent);
291
+ }
292
+ /**
293
+ * Create MonoraModel from dictionary representation.
294
+ */
295
+ function modelFromDict(data) {
296
+ return {
297
+ modelId: data.model_id || data.modelId,
298
+ spec: (0, spec_1.specFromDict)(data.spec),
299
+ riskCategory: data.risk_category || data.riskCategory || 'limited',
300
+ intendedUse: data.intended_use || data.intendedUse,
301
+ createdAt: data.created_at || data.createdAt || new Date().toISOString(),
302
+ updatedAt: data.updated_at || data.updatedAt,
303
+ tags: data.tags || [],
304
+ owner: data.owner,
305
+ };
306
+ }
307
+ /**
308
+ * Create MonoraModel from JSON string.
309
+ */
310
+ function modelFromJson(jsonStr) {
311
+ return modelFromDict(JSON.parse(jsonStr));
312
+ }
313
+ /**
314
+ * Save MonoraModel to a JSON file.
315
+ */
316
+ function saveModel(model, filePath) {
317
+ const resolvedPath = path.resolve(filePath);
318
+ const dir = path.dirname(resolvedPath);
319
+ // Create directory if it doesn't exist
320
+ fs.mkdirSync(dir, { recursive: true });
321
+ // Update timestamp
322
+ model.updatedAt = new Date().toISOString();
323
+ fs.writeFileSync(resolvedPath, modelToJson(model), 'utf-8');
324
+ }
325
+ /**
326
+ * Load MonoraModel from a JSON file.
327
+ */
328
+ function loadModel(filePath) {
329
+ const resolvedPath = path.resolve(filePath);
330
+ const content = fs.readFileSync(resolvedPath, 'utf-8');
331
+ return modelFromJson(content);
332
+ }
333
+ /**
334
+ * Save just the schema contract for use with onboarding validation.
335
+ */
336
+ function saveSchemaContract(model, filePath) {
337
+ const contract = (0, spec_1.specToSchemaContract)(model.spec);
338
+ const resolvedPath = path.resolve(filePath);
339
+ const dir = path.dirname(resolvedPath);
340
+ fs.mkdirSync(dir, { recursive: true });
341
+ fs.writeFileSync(resolvedPath, JSON.stringify(contract, null, 2), 'utf-8');
342
+ }
343
+ /**
344
+ * Save the generated Monora configuration.
345
+ */
346
+ function saveConfig(model, filePath, format = 'yaml') {
347
+ const config = generateConfig(model);
348
+ const resolvedPath = path.resolve(filePath);
349
+ const dir = path.dirname(resolvedPath);
350
+ fs.mkdirSync(dir, { recursive: true });
351
+ if (format === 'yaml') {
352
+ try {
353
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
354
+ const yaml = require('js-yaml');
355
+ fs.writeFileSync(resolvedPath, yaml.dump(config, { sortKeys: false }), 'utf-8');
356
+ }
357
+ catch {
358
+ // Fall back to JSON if js-yaml not available
359
+ fs.writeFileSync(resolvedPath, JSON.stringify(config, null, 2), 'utf-8');
360
+ }
361
+ }
362
+ else {
363
+ fs.writeFileSync(resolvedPath, JSON.stringify(config, null, 2), 'utf-8');
364
+ }
365
+ }
366
+ /**
367
+ * Get a string representation of a MonoraModel.
368
+ */
369
+ function modelToString(model) {
370
+ return `MonoraModel(modelId='${model.modelId}', riskCategory='${model.riskCategory}', inputs=${model.spec.inputs.length}, outputs=${model.spec.outputs.length})`;
371
+ }
@@ -0,0 +1,42 @@
1
+ import { MonoraConfig } from './config';
2
+ export interface BuildModelSpecOptions {
3
+ name?: string;
4
+ version?: string;
5
+ eventTsField?: string;
6
+ schemaRef?: string;
7
+ roles?: {
8
+ inputs?: string[];
9
+ outputs?: string[];
10
+ metadata?: string[];
11
+ identifiers?: string[];
12
+ };
13
+ }
14
+ export interface OnboardingResult {
15
+ status: string;
16
+ errors: string[];
17
+ warnings: string[];
18
+ coverage: Record<string, any>;
19
+ artifacts: Record<string, any>;
20
+ }
21
+ export interface ValidateOnboardingOptions {
22
+ configPath?: string;
23
+ configDict?: MonoraConfig;
24
+ inputPathOverride?: string;
25
+ persist?: boolean;
26
+ }
27
+ export interface CompleteOnboardingOptions {
28
+ configPath?: string;
29
+ configDict?: MonoraConfig;
30
+ completedBy?: string;
31
+ }
32
+ export declare function buildModelSpec(options?: BuildModelSpecOptions): Record<string, any>;
33
+ export declare function validateOnboarding(options?: ValidateOnboardingOptions): OnboardingResult;
34
+ export declare function completeOnboarding(options?: CompleteOnboardingOptions): OnboardingResult;
35
+ export declare function getOnboardingStatus(options?: {
36
+ configPath?: string;
37
+ configDict?: MonoraConfig;
38
+ }): Record<string, any>;
39
+ export declare function resolveEnrichmentPlan(config: MonoraConfig, options?: {
40
+ apply?: boolean;
41
+ }): Record<string, any>;
42
+ //# sourceMappingURL=onboarding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../src/onboarding.ts"],"names":[],"mappings":"AAIA,OAAO,EAA8B,YAAY,EAAE,MAAM,UAAU,CAAC;AAKpE,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA+CD,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAcvF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,gBAAgB,CA8I5F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,gBAAgB,CAgH5F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,YAAY,CAAA;CAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAsEzH;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAkErB"}