@uwmd/core 1.1.2 → 1.5.0
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/README.md +3 -3
- package/dist/agents/bancroft.d.ts +22 -1
- package/dist/agents/bancroft.d.ts.map +1 -1
- package/dist/agents/bancroft.js +86 -60
- package/dist/agents/bancroft.js.map +1 -1
- package/dist/agents/provider.d.ts +62 -0
- package/dist/agents/provider.d.ts.map +1 -0
- package/dist/agents/provider.js +28 -0
- package/dist/agents/provider.js.map +1 -0
- package/dist/agents/providers/anthropic.d.ts +20 -0
- package/dist/agents/providers/anthropic.d.ts.map +1 -0
- package/dist/agents/providers/anthropic.js +104 -0
- package/dist/agents/providers/anthropic.js.map +1 -0
- package/dist/agents/providers/replay.d.ts +46 -0
- package/dist/agents/providers/replay.d.ts.map +1 -0
- package/dist/agents/providers/replay.js +162 -0
- package/dist/agents/providers/replay.js.map +1 -0
- package/dist/agents/schemas.d.ts +3 -3
- package/dist/agents/schemas.d.ts.map +1 -1
- package/dist/agents/schemas.js.map +1 -1
- package/dist/browser.d.ts +33 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +26 -3
- package/dist/browser.js.map +1 -1
- package/dist/calc/builtins.d.ts +10 -0
- package/dist/calc/builtins.d.ts.map +1 -1
- package/dist/calc/builtins.js +64 -42
- package/dist/calc/builtins.js.map +1 -1
- package/dist/calc/errors.js +1 -1
- package/dist/calc/evaluator.js +6 -2
- package/dist/calc/evaluator.js.map +1 -1
- package/dist/calc/index.d.ts +7 -0
- package/dist/calc/index.d.ts.map +1 -1
- package/dist/calc/index.js +13 -1
- package/dist/calc/index.js.map +1 -1
- package/dist/calc/quantize.d.ts +56 -0
- package/dist/calc/quantize.d.ts.map +1 -0
- package/dist/calc/quantize.js +116 -0
- package/dist/calc/quantize.js.map +1 -0
- package/dist/cascade.d.ts +60 -6
- package/dist/cascade.d.ts.map +1 -1
- package/dist/cascade.js +93 -14
- package/dist/cascade.js.map +1 -1
- package/dist/cli-packages.d.ts +11 -0
- package/dist/cli-packages.d.ts.map +1 -0
- package/dist/cli-packages.js +177 -0
- package/dist/cli-packages.js.map +1 -0
- package/dist/cli.js +691 -37
- package/dist/cli.js.map +1 -1
- package/dist/composition.d.ts +182 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +536 -0
- package/dist/composition.js.map +1 -0
- package/dist/deal-package-context.d.ts +52 -0
- package/dist/deal-package-context.d.ts.map +1 -0
- package/dist/deal-package-context.js +132 -0
- package/dist/deal-package-context.js.map +1 -0
- package/dist/deal-package-zip.d.ts +36 -0
- package/dist/deal-package-zip.d.ts.map +1 -0
- package/dist/deal-package-zip.js +132 -0
- package/dist/deal-package-zip.js.map +1 -0
- package/dist/deal-package.d.ts +82 -0
- package/dist/deal-package.d.ts.map +1 -0
- package/dist/deal-package.js +189 -0
- package/dist/deal-package.js.map +1 -0
- package/dist/defaults.d.ts +48 -0
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +512 -0
- package/dist/defaults.js.map +1 -1
- package/dist/index.d.ts +39 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/integrity.d.ts +9 -0
- package/dist/integrity.d.ts.map +1 -1
- package/dist/integrity.js +12 -2
- package/dist/integrity.js.map +1 -1
- package/dist/lease-abstract.d.ts +82 -0
- package/dist/lease-abstract.d.ts.map +1 -0
- package/dist/lease-abstract.js +183 -0
- package/dist/lease-abstract.js.map +1 -0
- package/dist/lite-bridge.d.ts +67 -0
- package/dist/lite-bridge.d.ts.map +1 -0
- package/dist/lite-bridge.js +564 -0
- package/dist/lite-bridge.js.map +1 -0
- package/dist/lite.d.ts +63 -0
- package/dist/lite.d.ts.map +1 -0
- package/dist/lite.js +398 -0
- package/dist/lite.js.map +1 -0
- package/dist/market-data.d.ts +134 -0
- package/dist/market-data.d.ts.map +1 -0
- package/dist/market-data.js +292 -0
- package/dist/market-data.js.map +1 -0
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js +278 -13
- package/dist/modules.js.map +1 -1
- package/dist/packs/excel-emit.d.ts +18 -1
- package/dist/packs/excel-emit.d.ts.map +1 -1
- package/dist/packs/excel-emit.js +18 -1
- package/dist/packs/excel-emit.js.map +1 -1
- package/dist/packs/hospitality.d.ts +3 -0
- package/dist/packs/hospitality.d.ts.map +1 -0
- package/dist/packs/hospitality.js +122 -0
- package/dist/packs/hospitality.js.map +1 -0
- package/dist/packs/index.d.ts +5 -1
- package/dist/packs/index.d.ts.map +1 -1
- package/dist/packs/index.js +13 -1
- package/dist/packs/index.js.map +1 -1
- package/dist/packs/land.d.ts +3 -0
- package/dist/packs/land.d.ts.map +1 -0
- package/dist/packs/land.js +124 -0
- package/dist/packs/land.js.map +1 -0
- package/dist/packs/senior-housing.d.ts +3 -0
- package/dist/packs/senior-housing.d.ts.map +1 -0
- package/dist/packs/senior-housing.js +123 -0
- package/dist/packs/senior-housing.js.map +1 -0
- package/dist/packs/student-housing.d.ts +3 -0
- package/dist/packs/student-housing.d.ts.map +1 -0
- package/dist/packs/student-housing.js +124 -0
- package/dist/packs/student-housing.js.map +1 -0
- package/dist/parser.d.ts +9 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +40 -6
- package/dist/parser.js.map +1 -1
- package/dist/protocol.d.ts +125 -9
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +182 -4
- package/dist/protocol.js.map +1 -1
- package/dist/receipts.d.ts +396 -0
- package/dist/receipts.d.ts.map +1 -0
- package/dist/receipts.js +913 -0
- package/dist/receipts.js.map +1 -0
- package/dist/runner.d.ts +13 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +5 -5
- package/dist/runner.js.map +1 -1
- package/dist/source-representation.d.ts +40 -0
- package/dist/source-representation.d.ts.map +1 -0
- package/dist/source-representation.js +114 -0
- package/dist/source-representation.js.map +1 -0
- package/dist/types.d.ts +63 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -1
- package/dist/uwcsv.d.ts.map +1 -1
- package/dist/uwcsv.js +10 -78
- package/dist/uwcsv.js.map +1 -1
- package/dist/uwxml.d.ts.map +1 -1
- package/dist/uwxml.js +10 -2
- package/dist/uwxml.js.map +1 -1
- package/dist/validator.d.ts.map +1 -1
- package/dist/validator.js +27 -10
- package/dist/validator.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +8 -0
- package/dist/version.js.map +1 -0
- package/dist/zip-safety.d.ts +15 -0
- package/dist/zip-safety.d.ts.map +1 -0
- package/dist/zip-safety.js +109 -0
- package/dist/zip-safety.js.map +1 -0
- package/package.json +12 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease-abstract.js","sourceRoot":"","sources":["../src/lease-abstract.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,gFAAgF;AAChF,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,wCAAwC;AACxC,EAAE;AACF,8DAA8D;AAC9D,gFAAgF;AAChF,0DAA0D;AAC1D,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,sCAAsC;AAItC,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAA4B,CAAC;AAEtE,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,eAAe;IACf,YAAY;IACZ,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;IACd,yBAAyB;CACjB,CAAC,CAAC;AAOZ,MAAM,CAAC,MAAM,mBAAmB,GAA+B,MAAM,CAAC,MAAM,CAAC;IAC3E,YAAY;IACZ,WAAW;IACX,cAAc;CACf,CAAC,CAAC;AA0BH,MAAM,CAAC,MAAM,oBAAoB,GAAiC,MAAM,CAAC,MAAM,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AC1F,SAAS;QACX,CAAC;QACD,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { UWDocumentEnvelope } from './envelope.js';
|
|
2
|
+
import type { ParsedUWLite } from './lite.js';
|
|
3
|
+
export declare const UW_LITE_BRIDGE_PROFILE: "deal-summary-v1";
|
|
4
|
+
export declare const UW_LITE_SOURCE_EXTENSION: "x_uw_lite_source";
|
|
5
|
+
export interface UWLiteFieldMapping {
|
|
6
|
+
lite_path: string;
|
|
7
|
+
target_path: string;
|
|
8
|
+
expected_unit?: string;
|
|
9
|
+
label: string;
|
|
10
|
+
}
|
|
11
|
+
export interface UWLiteCompilationIssue {
|
|
12
|
+
code: string;
|
|
13
|
+
severity: 'error' | 'warning';
|
|
14
|
+
message: string;
|
|
15
|
+
field_path?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface UWLiteCompilationReport {
|
|
18
|
+
profile: typeof UW_LITE_BRIDGE_PROFILE;
|
|
19
|
+
mappings: Array<{
|
|
20
|
+
lite_path: string;
|
|
21
|
+
target_path: string;
|
|
22
|
+
}>;
|
|
23
|
+
defaults: Array<{
|
|
24
|
+
path: string;
|
|
25
|
+
value: unknown;
|
|
26
|
+
reason: string;
|
|
27
|
+
}>;
|
|
28
|
+
issues: UWLiteCompilationIssue[];
|
|
29
|
+
source_preserved_in: typeof UW_LITE_SOURCE_EXTENSION;
|
|
30
|
+
}
|
|
31
|
+
export type UWLiteCompilationResult = {
|
|
32
|
+
ok: true;
|
|
33
|
+
envelope: UWDocumentEnvelope;
|
|
34
|
+
report: UWLiteCompilationReport;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
report: UWLiteCompilationReport;
|
|
38
|
+
};
|
|
39
|
+
export interface UWLiteProjectionReport {
|
|
40
|
+
profile: typeof UW_LITE_BRIDGE_PROFILE;
|
|
41
|
+
projected_paths: string[];
|
|
42
|
+
omitted_paths: string[];
|
|
43
|
+
/**
|
|
44
|
+
* Sections the source record externalized into `.uwpart.md` fragments
|
|
45
|
+
* (RFC 0021 §3), in envelope order. Projection is UWX→Lite only and never
|
|
46
|
+
* resolves fragments, so the content of these sections is absent from the
|
|
47
|
+
* projection *and* absent from `omitted_paths` — nothing in the envelope
|
|
48
|
+
* enumerates rows the record does not carry. Naming the section is the only
|
|
49
|
+
* complete account available, and §3 requires it.
|
|
50
|
+
*/
|
|
51
|
+
externalized_sections: string[];
|
|
52
|
+
warnings: string[];
|
|
53
|
+
lossy: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface UWLiteProjectionResult {
|
|
56
|
+
content: string;
|
|
57
|
+
report: UWLiteProjectionReport;
|
|
58
|
+
}
|
|
59
|
+
export declare class UWLiteBridgeError extends Error {
|
|
60
|
+
readonly code: string;
|
|
61
|
+
constructor(code: string, message: string);
|
|
62
|
+
}
|
|
63
|
+
export declare const UW_LITE_FIELD_MAPPINGS: readonly UWLiteFieldMapping[];
|
|
64
|
+
export declare function compileUWLite(document: ParsedUWLite): UWLiteCompilationResult;
|
|
65
|
+
export declare function projectUWEnvelopeToLite(envelope: UWDocumentEnvelope): UWLiteProjectionResult;
|
|
66
|
+
export declare function stringifyUWX(envelope: UWDocumentEnvelope): string;
|
|
67
|
+
//# sourceMappingURL=lite-bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lite-bridge.d.ts","sourceRoot":"","sources":["../src/lite-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAiC,MAAM,WAAW,CAAC;AAM7E,eAAO,MAAM,sBAAsB,EAAG,iBAA0B,CAA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AAO,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,sBAAsB,CAAC;CAChC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,eAAO,MAAM,sBAAsB,EAAE,SAAS,kBAAkB,EA+CtD,CAAC;AA8BX,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,uBAAuB,CA8H7E;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,kBAAkB,GAC3B,sBAAsB,CAsExB;AA4BD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CA4CjE"}
|
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
import { EXTERNAL_ANNOTATION_KEY } from './composition.js';
|
|
2
|
+
import { isBlockedSegment } from './parser.js';
|
|
3
|
+
import { FORMAT_VERSION } from './protocol.js';
|
|
4
|
+
import { UW_LITE_REPRESENTATION_VERSION } from './source-representation.js';
|
|
5
|
+
export const UW_LITE_BRIDGE_PROFILE = 'deal-summary-v1';
|
|
6
|
+
export const UW_LITE_SOURCE_EXTENSION = 'x_uw_lite_source';
|
|
7
|
+
export class UWLiteBridgeError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(`[${code}] ${message}`);
|
|
11
|
+
this.name = 'UWLiteBridgeError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const UW_LITE_FIELD_MAPPINGS = [
|
|
16
|
+
{
|
|
17
|
+
lite_path: 'acquisition.purchase_price',
|
|
18
|
+
target_path: 'valuation.purchase_price',
|
|
19
|
+
expected_unit: 'USD',
|
|
20
|
+
label: 'Purchase price',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
lite_path: 'valuation.going_in_cap_rate',
|
|
24
|
+
target_path: 'valuation.going_in_cap_rate',
|
|
25
|
+
expected_unit: 'fraction',
|
|
26
|
+
label: 'Going-in cap rate',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
lite_path: 'noi.net_operating_income',
|
|
30
|
+
target_path: 'noi_model.net_operating_income',
|
|
31
|
+
expected_unit: 'USD',
|
|
32
|
+
label: 'Net operating income',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
lite_path: 'debt.loan_amount',
|
|
36
|
+
target_path: 'debt_structure.loan_amount',
|
|
37
|
+
expected_unit: 'USD',
|
|
38
|
+
label: 'Loan amount',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
lite_path: 'debt.interest_rate',
|
|
42
|
+
target_path: 'debt_structure.interest_rate',
|
|
43
|
+
expected_unit: 'fraction',
|
|
44
|
+
label: 'Interest rate',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
lite_path: 'debt.annual_debt_service',
|
|
48
|
+
target_path: 'debt_structure.annual_debt_service',
|
|
49
|
+
expected_unit: 'USD',
|
|
50
|
+
label: 'Annual debt service',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
lite_path: 'property.total_units',
|
|
54
|
+
target_path: 'property.total_units',
|
|
55
|
+
label: 'Total units',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
lite_path: 'property.total_nra_sqft',
|
|
59
|
+
target_path: 'property.total_nra_sqft',
|
|
60
|
+
label: 'Total NRA',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
const MAPPING_BY_LITE_PATH = new Map(UW_LITE_FIELD_MAPPINGS.map((mapping) => [mapping.lite_path, mapping]));
|
|
64
|
+
const _MAPPING_BY_TARGET_PATH = new Map(UW_LITE_FIELD_MAPPINGS.map((mapping) => [mapping.target_path, mapping]));
|
|
65
|
+
const KNOWN_SECTIONS = new Set([
|
|
66
|
+
'deal_context',
|
|
67
|
+
'property',
|
|
68
|
+
'ownership',
|
|
69
|
+
'rent_roll',
|
|
70
|
+
'operating_statement',
|
|
71
|
+
'noi_model',
|
|
72
|
+
'valuation',
|
|
73
|
+
'debt_structure',
|
|
74
|
+
'sources_uses',
|
|
75
|
+
'dcf',
|
|
76
|
+
'stress_tests',
|
|
77
|
+
'market_analysis',
|
|
78
|
+
'borrower_sponsor',
|
|
79
|
+
'due_diligence',
|
|
80
|
+
'risk_assessment',
|
|
81
|
+
'compliance',
|
|
82
|
+
'assumptions',
|
|
83
|
+
'validation',
|
|
84
|
+
'gaps',
|
|
85
|
+
]);
|
|
86
|
+
export function compileUWLite(document) {
|
|
87
|
+
const report = {
|
|
88
|
+
profile: UW_LITE_BRIDGE_PROFILE,
|
|
89
|
+
mappings: [],
|
|
90
|
+
defaults: [],
|
|
91
|
+
issues: document.issues.map((issue) => ({
|
|
92
|
+
code: issue.code,
|
|
93
|
+
severity: issue.severity,
|
|
94
|
+
message: issue.message,
|
|
95
|
+
...(issue.field_path ? { field_path: issue.field_path } : {}),
|
|
96
|
+
})),
|
|
97
|
+
source_preserved_in: UW_LITE_SOURCE_EXTENSION,
|
|
98
|
+
};
|
|
99
|
+
const frontmatter = compileFrontmatter(document, report);
|
|
100
|
+
const timestamp = readRequiredString(document.frontmatter, 'created', report);
|
|
101
|
+
if (report.issues.some((issue) => issue.severity === 'error') || !frontmatter || !timestamp) {
|
|
102
|
+
return { ok: false, report };
|
|
103
|
+
}
|
|
104
|
+
const actor = typeof document.frontmatter['created_by'] === 'string'
|
|
105
|
+
? document.frontmatter['created_by']
|
|
106
|
+
: 'unknown';
|
|
107
|
+
if (actor === 'unknown') {
|
|
108
|
+
report.defaults.push({
|
|
109
|
+
path: 'frontmatter.created_by',
|
|
110
|
+
value: actor,
|
|
111
|
+
reason: 'Lite bridge provenance default for an unspecified author.',
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const sectionValues = new Map();
|
|
115
|
+
for (const field of document.fields) {
|
|
116
|
+
const mapping = resolveFieldMapping(field, report);
|
|
117
|
+
if (!mapping)
|
|
118
|
+
continue;
|
|
119
|
+
if (field.period) {
|
|
120
|
+
report.issues.push({
|
|
121
|
+
code: 'LITE_COMPILE_PERIOD_UNSUPPORTED',
|
|
122
|
+
severity: 'error',
|
|
123
|
+
message: 'Period-qualified fields require a versioned period profile.',
|
|
124
|
+
field_path: field.path,
|
|
125
|
+
});
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (field.scenario && field.scenario !== 'base') {
|
|
129
|
+
report.issues.push({
|
|
130
|
+
code: 'LITE_COMPILE_SCENARIO_UNSUPPORTED',
|
|
131
|
+
severity: 'error',
|
|
132
|
+
message: 'Only the base scenario maps to a current UWX section in this profile.',
|
|
133
|
+
field_path: field.path,
|
|
134
|
+
});
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (mapping.expected_unit && field.unit !== mapping.expected_unit) {
|
|
138
|
+
report.issues.push({
|
|
139
|
+
code: 'LITE_COMPILE_UNIT_MISMATCH',
|
|
140
|
+
severity: 'error',
|
|
141
|
+
message: `Expected unit ${mapping.expected_unit}, received ${field.unit ?? 'none'}.`,
|
|
142
|
+
field_path: field.path,
|
|
143
|
+
});
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const [section, ...path] = mapping.target_path.split('.');
|
|
147
|
+
if (!section || path.length === 0 || [section, ...path].some(isBlockedSegment)) {
|
|
148
|
+
throw new UWLiteBridgeError('LITE_MAPPING_INVALID', `Invalid target mapping ${mapping.target_path}.`);
|
|
149
|
+
}
|
|
150
|
+
const content = sectionValues.get(section) ?? {};
|
|
151
|
+
if (!setPath(content, path, field.value)) {
|
|
152
|
+
report.issues.push({
|
|
153
|
+
code: 'LITE_COMPILE_TARGET_CONFLICT',
|
|
154
|
+
severity: 'error',
|
|
155
|
+
message: `Multiple Lite fields map to ${mapping.target_path}.`,
|
|
156
|
+
field_path: field.path,
|
|
157
|
+
});
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
sectionValues.set(section, content);
|
|
161
|
+
report.mappings.push({
|
|
162
|
+
lite_path: field.path,
|
|
163
|
+
target_path: mapping.target_path,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (report.issues.some((issue) => issue.severity === 'error')) {
|
|
167
|
+
return { ok: false, report };
|
|
168
|
+
}
|
|
169
|
+
const sections = {};
|
|
170
|
+
for (const [section, values] of [...sectionValues.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
|
171
|
+
sections[section] = createEnvelopeBlock(section, values, timestamp, actor);
|
|
172
|
+
}
|
|
173
|
+
const sourceExtension = createEnvelopeBlock(UW_LITE_SOURCE_EXTENSION, {
|
|
174
|
+
representation: 'uw-lite-markdown',
|
|
175
|
+
representation_version: document.representation_version,
|
|
176
|
+
profile: UW_LITE_BRIDGE_PROFILE,
|
|
177
|
+
markdown: document.raw,
|
|
178
|
+
}, timestamp, actor);
|
|
179
|
+
return {
|
|
180
|
+
ok: true,
|
|
181
|
+
envelope: {
|
|
182
|
+
envelope_version: '1.0',
|
|
183
|
+
format_version: FORMAT_VERSION,
|
|
184
|
+
frontmatter,
|
|
185
|
+
sections,
|
|
186
|
+
pipeline_log: [],
|
|
187
|
+
custom_calculations: [],
|
|
188
|
+
custom_scenarios: [],
|
|
189
|
+
extensions: { [UW_LITE_SOURCE_EXTENSION]: sourceExtension },
|
|
190
|
+
superseded: {},
|
|
191
|
+
},
|
|
192
|
+
report,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export function projectUWEnvelopeToLite(envelope) {
|
|
196
|
+
const lines = [
|
|
197
|
+
'---',
|
|
198
|
+
`uw_lite_version: ${UW_LITE_REPRESENTATION_VERSION}`,
|
|
199
|
+
...projectFrontmatter(envelope.frontmatter),
|
|
200
|
+
'---',
|
|
201
|
+
'',
|
|
202
|
+
];
|
|
203
|
+
const projectedPaths = [];
|
|
204
|
+
const groups = new Map();
|
|
205
|
+
for (const mapping of UW_LITE_FIELD_MAPPINGS) {
|
|
206
|
+
const value = getEnvelopePath(envelope, mapping.target_path);
|
|
207
|
+
if (value === undefined)
|
|
208
|
+
continue;
|
|
209
|
+
const section = mapping.target_path.split('.')[0] ?? 'deal';
|
|
210
|
+
const group = groups.get(section) ?? [];
|
|
211
|
+
group.push(`- ${mapping.label}: ${formatProjectedValue(value, mapping.expected_unit)} <!-- uw:${mapping.lite_path} -->`);
|
|
212
|
+
groups.set(section, group);
|
|
213
|
+
projectedPaths.push(mapping.target_path);
|
|
214
|
+
}
|
|
215
|
+
for (const [section, fields] of groups) {
|
|
216
|
+
lines.push(`# ${headingLabel(section)}`, '', ...fields, '');
|
|
217
|
+
}
|
|
218
|
+
const externalizedSections = collectExternalizedSections(envelope);
|
|
219
|
+
const allPaths = collectEnvelopeLeafPaths(envelope);
|
|
220
|
+
const ignored = new Set([
|
|
221
|
+
...projectedPaths,
|
|
222
|
+
...Object.keys(envelope.frontmatter).map((key) => `frontmatter.${key}`),
|
|
223
|
+
]);
|
|
224
|
+
const omittedPaths = allPaths.filter((path) => !ignored.has(path) &&
|
|
225
|
+
!path.includes('._meta.') &&
|
|
226
|
+
!path.startsWith(`extensions.${UW_LITE_SOURCE_EXTENSION}.`) &&
|
|
227
|
+
// The directive's own keys — `parts`, `part_count`, `collection_key` —
|
|
228
|
+
// are packaging, not underwriting data. Listing them here would report
|
|
229
|
+
// the wrapper in place of the contents it stands for, which is worse
|
|
230
|
+
// than silence: an externalized record would appear to omit *fewer*
|
|
231
|
+
// paths than its inline twin. The section is named instead.
|
|
232
|
+
!externalizedSections.some((section) => path.startsWith(`${section}.${EXTERNAL_ANNOTATION_KEY}.`)));
|
|
233
|
+
const warnings = [];
|
|
234
|
+
if (omittedPaths.length > 0) {
|
|
235
|
+
warnings.push('Projection omits data that is not represented by the selected Lite profile.');
|
|
236
|
+
}
|
|
237
|
+
if (externalizedSections.length > 0) {
|
|
238
|
+
warnings.push(`Projection omits ${externalizedSections.length} externalized section(s) whose contents live in fragments this projection does not resolve: ${externalizedSections.join(', ')}.`);
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
content: lines.join('\n').replace(/\n+$/g, '\n'),
|
|
242
|
+
report: {
|
|
243
|
+
profile: UW_LITE_BRIDGE_PROFILE,
|
|
244
|
+
projected_paths: projectedPaths.sort(),
|
|
245
|
+
omitted_paths: omittedPaths.sort(),
|
|
246
|
+
externalized_sections: externalizedSections,
|
|
247
|
+
warnings,
|
|
248
|
+
lossy: omittedPaths.length > 0 || externalizedSections.length > 0,
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Sections carrying an RFC 0021 externalization directive, named by the same
|
|
254
|
+
* path prefix `collectEnvelopeLeafPaths` uses so the two agree on what to drop.
|
|
255
|
+
*
|
|
256
|
+
* Presence of the key is the whole test — whether the directive is *well-formed*
|
|
257
|
+
* is composition's business (`readExternalDirective` throws on a bad one). A
|
|
258
|
+
* projection must not throw over a malformed directive, and a section pointing
|
|
259
|
+
* at fragments is externalized either way.
|
|
260
|
+
*/
|
|
261
|
+
function collectExternalizedSections(envelope) {
|
|
262
|
+
const sections = [];
|
|
263
|
+
const isExternal = (block) => isRecord(block.content) && EXTERNAL_ANNOTATION_KEY in block.content;
|
|
264
|
+
for (const [section, entry] of Object.entries(envelope.sections)) {
|
|
265
|
+
if (isEnvelopeBlock(entry)) {
|
|
266
|
+
if (isExternal(entry))
|
|
267
|
+
sections.push(section);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
for (const [variant, block] of Object.entries(entry)) {
|
|
271
|
+
if (isExternal(block))
|
|
272
|
+
sections.push(`${section}.${variant}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return sections;
|
|
276
|
+
}
|
|
277
|
+
export function stringifyUWX(envelope) {
|
|
278
|
+
const output = [serializeFrontmatter(envelope.frontmatter), ''];
|
|
279
|
+
for (const [, blocks] of Object.entries(envelope.superseded).sort(([left], [right]) => left.localeCompare(right))) {
|
|
280
|
+
for (const block of blocks) {
|
|
281
|
+
output.push(serializeEnvelopeBlock(block), '');
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (const [_section, entry] of Object.entries(envelope.sections).sort(([left], [right]) => left.localeCompare(right))) {
|
|
285
|
+
if (isEnvelopeBlock(entry)) {
|
|
286
|
+
output.push(serializeEnvelopeBlock(entry), '');
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
for (const [, block] of Object.entries(entry).sort(([left], [right]) => left.localeCompare(right))) {
|
|
290
|
+
output.push(serializeEnvelopeBlock(block), '');
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
for (const [id, block] of Object.entries(envelope.extensions).sort(([left], [right]) => left.localeCompare(right))) {
|
|
294
|
+
if (block.annotation.section !== id) {
|
|
295
|
+
throw new UWLiteBridgeError('UWX_EXTENSION_ID_MISMATCH', `Extension key ${id} disagrees with its block annotation.`);
|
|
296
|
+
}
|
|
297
|
+
output.push(serializeEnvelopeBlock(block), '');
|
|
298
|
+
}
|
|
299
|
+
for (const block of envelope.custom_calculations) {
|
|
300
|
+
output.push(serializeEnvelopeBlock(block), '');
|
|
301
|
+
}
|
|
302
|
+
for (const block of envelope.custom_scenarios) {
|
|
303
|
+
output.push(serializeEnvelopeBlock(block), '');
|
|
304
|
+
}
|
|
305
|
+
for (const block of envelope.pipeline_log) {
|
|
306
|
+
output.push(serializeEnvelopeBlock(block), '');
|
|
307
|
+
}
|
|
308
|
+
return output.join('\n').replace(/\n+$/g, '\n');
|
|
309
|
+
}
|
|
310
|
+
function compileFrontmatter(document, report) {
|
|
311
|
+
const dealId = readRequiredString(document.frontmatter, 'deal_id', report);
|
|
312
|
+
const dealName = readRequiredString(document.frontmatter, 'deal_name', report);
|
|
313
|
+
const created = readRequiredString(document.frontmatter, 'created', report);
|
|
314
|
+
if (!dealId || !dealName || !created)
|
|
315
|
+
return null;
|
|
316
|
+
const semanticVersion = typeof document.frontmatter['uw_version'] === 'string'
|
|
317
|
+
? document.frontmatter['uw_version']
|
|
318
|
+
: FORMAT_VERSION;
|
|
319
|
+
if (document.frontmatter['uw_version'] === undefined) {
|
|
320
|
+
report.defaults.push({
|
|
321
|
+
path: 'frontmatter.uw_version',
|
|
322
|
+
value: FORMAT_VERSION,
|
|
323
|
+
reason: 'RFC 0017 keeps UW semantic format 1.1 for the initial bridge.',
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
const output = {
|
|
327
|
+
...document.frontmatter,
|
|
328
|
+
uw_version: semanticVersion,
|
|
329
|
+
deal_id: dealId,
|
|
330
|
+
deal_name: dealName,
|
|
331
|
+
created,
|
|
332
|
+
last_modified: typeof document.frontmatter['last_modified'] === 'string'
|
|
333
|
+
? document.frontmatter['last_modified']
|
|
334
|
+
: created,
|
|
335
|
+
};
|
|
336
|
+
delete output['uw_lite_version'];
|
|
337
|
+
return output;
|
|
338
|
+
}
|
|
339
|
+
function readRequiredString(frontmatter, key, report) {
|
|
340
|
+
const value = frontmatter[key];
|
|
341
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
342
|
+
return value;
|
|
343
|
+
report.issues.push({
|
|
344
|
+
code: 'LITE_COMPILE_FRONTMATTER_REQUIRED',
|
|
345
|
+
severity: 'error',
|
|
346
|
+
message: `Compilation requires frontmatter.${key}.`,
|
|
347
|
+
});
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
function resolveFieldMapping(field, report) {
|
|
351
|
+
const mapped = MAPPING_BY_LITE_PATH.get(field.path);
|
|
352
|
+
if (mapped)
|
|
353
|
+
return mapped;
|
|
354
|
+
const [section, ...rest] = field.path.split('.');
|
|
355
|
+
if (section && rest.length > 0 && KNOWN_SECTIONS.has(section)) {
|
|
356
|
+
return {
|
|
357
|
+
lite_path: field.path,
|
|
358
|
+
target_path: field.path,
|
|
359
|
+
...(field.unit ? { expected_unit: field.unit } : {}),
|
|
360
|
+
label: field.label,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
report.issues.push({
|
|
364
|
+
code: 'LITE_COMPILE_FIELD_UNKNOWN',
|
|
365
|
+
severity: 'error',
|
|
366
|
+
message: 'Field is not recognized by the selected bridge profile.',
|
|
367
|
+
field_path: field.path,
|
|
368
|
+
});
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
function createEnvelopeBlock(section, values, timestamp, actor) {
|
|
372
|
+
const meta = {
|
|
373
|
+
section,
|
|
374
|
+
version: 1,
|
|
375
|
+
superseded: false,
|
|
376
|
+
source: 'manual',
|
|
377
|
+
agent_id: null,
|
|
378
|
+
agent_version: null,
|
|
379
|
+
actor,
|
|
380
|
+
timestamp,
|
|
381
|
+
confidence: 'high',
|
|
382
|
+
human_review_required: false,
|
|
383
|
+
flags: [],
|
|
384
|
+
input_hash: null,
|
|
385
|
+
notes: null,
|
|
386
|
+
};
|
|
387
|
+
return {
|
|
388
|
+
annotation: {
|
|
389
|
+
section,
|
|
390
|
+
source: 'manual',
|
|
391
|
+
ts: timestamp,
|
|
392
|
+
v: 1,
|
|
393
|
+
confidence: 'high',
|
|
394
|
+
},
|
|
395
|
+
content: { _meta: meta, ...values },
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function setPath(target, path, value) {
|
|
399
|
+
let cursor = target;
|
|
400
|
+
for (let index = 0; index < path.length - 1; index++) {
|
|
401
|
+
const key = path[index];
|
|
402
|
+
const existing = cursor[key];
|
|
403
|
+
if (existing !== undefined && !isRecord(existing))
|
|
404
|
+
return false;
|
|
405
|
+
const next = isRecord(existing) ? existing : {};
|
|
406
|
+
cursor[key] = next;
|
|
407
|
+
cursor = next;
|
|
408
|
+
}
|
|
409
|
+
const leaf = path.at(-1);
|
|
410
|
+
if (!leaf || Object.hasOwn(cursor, leaf))
|
|
411
|
+
return false;
|
|
412
|
+
cursor[leaf] = value;
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
function projectFrontmatter(frontmatter) {
|
|
416
|
+
const keys = ['deal_id', 'deal_name', 'created', 'last_modified', 'asset_class', 'created_by'];
|
|
417
|
+
return keys.flatMap((key) => {
|
|
418
|
+
const value = frontmatter[key];
|
|
419
|
+
return value === undefined ? [] : [`${key}: ${serializeYamlScalar(value)}`];
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function getEnvelopePath(envelope, path) {
|
|
423
|
+
const [section, ...rest] = path.split('.');
|
|
424
|
+
const entry = envelope.sections[section];
|
|
425
|
+
if (!entry || !isEnvelopeBlock(entry))
|
|
426
|
+
return undefined;
|
|
427
|
+
let value = entry.content;
|
|
428
|
+
for (const segment of rest) {
|
|
429
|
+
if (!isRecord(value))
|
|
430
|
+
return undefined;
|
|
431
|
+
value = value[segment];
|
|
432
|
+
}
|
|
433
|
+
return value;
|
|
434
|
+
}
|
|
435
|
+
function collectEnvelopeLeafPaths(envelope) {
|
|
436
|
+
const output = [];
|
|
437
|
+
flattenLeaves(envelope.frontmatter, 'frontmatter', output);
|
|
438
|
+
for (const [section, entry] of Object.entries(envelope.sections)) {
|
|
439
|
+
if (isEnvelopeBlock(entry)) {
|
|
440
|
+
flattenLeaves(entry.content, section, output);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
for (const [variant, block] of Object.entries(entry)) {
|
|
444
|
+
flattenLeaves(block.content, `${section}.${variant}`, output);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
for (const [id, block] of Object.entries(envelope.extensions)) {
|
|
449
|
+
flattenLeaves(block.content, `extensions.${id}`, output);
|
|
450
|
+
}
|
|
451
|
+
return output;
|
|
452
|
+
}
|
|
453
|
+
function flattenLeaves(value, prefix, output) {
|
|
454
|
+
if (Array.isArray(value)) {
|
|
455
|
+
value.forEach((item, index) => flattenLeaves(item, `${prefix}[${index}]`, output));
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
if (isRecord(value)) {
|
|
459
|
+
for (const [key, child] of Object.entries(value)) {
|
|
460
|
+
flattenLeaves(child, `${prefix}.${key}`, output);
|
|
461
|
+
}
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
output.push(prefix);
|
|
465
|
+
}
|
|
466
|
+
function formatProjectedValue(value, unit) {
|
|
467
|
+
if (typeof value !== 'number')
|
|
468
|
+
return String(value);
|
|
469
|
+
if (unit === 'USD') {
|
|
470
|
+
return `$${value.toLocaleString('en-US', { maximumFractionDigits: 2 })}`;
|
|
471
|
+
}
|
|
472
|
+
if (unit === 'fraction') {
|
|
473
|
+
return `${(value * 100).toLocaleString('en-US', { maximumFractionDigits: 6 })}%`;
|
|
474
|
+
}
|
|
475
|
+
if (unit === 'ratio')
|
|
476
|
+
return `${value}x`;
|
|
477
|
+
return value.toLocaleString('en-US', { maximumFractionDigits: 12 });
|
|
478
|
+
}
|
|
479
|
+
function headingLabel(section) {
|
|
480
|
+
return section
|
|
481
|
+
.split('_')
|
|
482
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
483
|
+
.join(' ');
|
|
484
|
+
}
|
|
485
|
+
function serializeFrontmatter(frontmatter) {
|
|
486
|
+
const priority = ['uw_version', 'deal_id', 'deal_name', 'created', 'last_modified'];
|
|
487
|
+
const keys = Object.keys(frontmatter).sort((left, right) => {
|
|
488
|
+
const leftPriority = priority.indexOf(left);
|
|
489
|
+
const rightPriority = priority.indexOf(right);
|
|
490
|
+
if (leftPriority >= 0 || rightPriority >= 0) {
|
|
491
|
+
if (leftPriority < 0)
|
|
492
|
+
return 1;
|
|
493
|
+
if (rightPriority < 0)
|
|
494
|
+
return -1;
|
|
495
|
+
return leftPriority - rightPriority;
|
|
496
|
+
}
|
|
497
|
+
return left.localeCompare(right);
|
|
498
|
+
});
|
|
499
|
+
const lines = ['---'];
|
|
500
|
+
for (const key of keys) {
|
|
501
|
+
const value = frontmatter[key];
|
|
502
|
+
if (Array.isArray(value)) {
|
|
503
|
+
lines.push(`${key}:`);
|
|
504
|
+
for (const item of value)
|
|
505
|
+
lines.push(` - ${serializeYamlScalar(item)}`);
|
|
506
|
+
}
|
|
507
|
+
else if (isRecord(value)) {
|
|
508
|
+
lines.push(`${key}:`);
|
|
509
|
+
for (const [childKey, child] of Object.entries(value).sort(([left], [right]) => left.localeCompare(right))) {
|
|
510
|
+
lines.push(` ${childKey}: ${serializeYamlScalar(child)}`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
lines.push(`${key}: ${serializeYamlScalar(value)}`);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
lines.push('---');
|
|
518
|
+
return lines.join('\n');
|
|
519
|
+
}
|
|
520
|
+
function serializeYamlScalar(value) {
|
|
521
|
+
if (value === null || value === undefined)
|
|
522
|
+
return 'null';
|
|
523
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
524
|
+
return String(value);
|
|
525
|
+
const text = String(value);
|
|
526
|
+
if (text === '' ||
|
|
527
|
+
/^(?:true|false|null|~|-?\d+(?:\.\d+)?)$/i.test(text) ||
|
|
528
|
+
/[:#\[\]{},&*!|>'"%@\`\s]/.test(text)) {
|
|
529
|
+
return JSON.stringify(text);
|
|
530
|
+
}
|
|
531
|
+
return text;
|
|
532
|
+
}
|
|
533
|
+
function serializeEnvelopeBlock(block) {
|
|
534
|
+
const annotation = Object.entries(block.annotation)
|
|
535
|
+
.filter(([key]) => key !== 'section')
|
|
536
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
537
|
+
.map(([key, value]) => `${key}=${String(value)}`)
|
|
538
|
+
.join(' ');
|
|
539
|
+
const fence = `\`\`\`json uw:section=${block.annotation.section}${annotation ? ` ${annotation}` : ''}`;
|
|
540
|
+
const content = JSON.stringify(sortObject(block.content), null, 2);
|
|
541
|
+
return [block.prose?.trim(), fence, content, '\`\`\`'].filter(Boolean).join('\n');
|
|
542
|
+
}
|
|
543
|
+
function sortObject(value) {
|
|
544
|
+
if (Array.isArray(value))
|
|
545
|
+
return value.map(sortObject);
|
|
546
|
+
if (!isRecord(value))
|
|
547
|
+
return value;
|
|
548
|
+
return Object.fromEntries(Object.entries(value)
|
|
549
|
+
.sort(([left], [right]) => {
|
|
550
|
+
if (left === '_meta')
|
|
551
|
+
return -1;
|
|
552
|
+
if (right === '_meta')
|
|
553
|
+
return 1;
|
|
554
|
+
return left.localeCompare(right);
|
|
555
|
+
})
|
|
556
|
+
.map(([key, child]) => [key, sortObject(child)]));
|
|
557
|
+
}
|
|
558
|
+
function isEnvelopeBlock(value) {
|
|
559
|
+
return isRecord(value) && 'annotation' in value && 'content' in value;
|
|
560
|
+
}
|
|
561
|
+
function isRecord(value) {
|
|
562
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
563
|
+
}
|
|
564
|
+
//# sourceMappingURL=lite-bridge.js.map
|