@ssg-coop/luic-calculator-core 1.3.0 → 1.4.1

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 (93) hide show
  1. package/README.md +12 -2
  2. package/dist/api/domain.d.ts +5 -0
  3. package/dist/api/domain.js +5 -0
  4. package/dist/config/i18n/en.d.ts +19 -0
  5. package/dist/config/i18n/en.js +19 -0
  6. package/dist/config/i18n/fr.d.ts +19 -0
  7. package/dist/config/i18n/fr.js +19 -0
  8. package/dist/config/types.d.ts +2 -0
  9. package/dist/config/types.js +5 -0
  10. package/dist/generator/WorkbookGenerator.d.ts +4 -0
  11. package/dist/generator/WorkbookGenerator.js +69 -9
  12. package/dist/generator/builders/ChartDataSheetBuilder.d.ts +10 -0
  13. package/dist/generator/builders/ChartDataSheetBuilder.js +160 -7
  14. package/dist/generator/builders/ChartsSheetBuilder.js +103 -2
  15. package/dist/generator/builders/InputDataSheetBuilder.js +4 -3
  16. package/dist/generator/builders/ScenarioDetailsBuilder.d.ts +2 -0
  17. package/dist/generator/builders/ScenarioDetailsBuilder.js +4 -4
  18. package/dist/generator/builders/ScenarioSheetBuilder.d.ts +2 -0
  19. package/dist/generator/builders/ScenarioSheetBuilder.js +205 -25
  20. package/dist/generator/builders/SummarySheetBuilder.d.ts +3 -2
  21. package/dist/generator/builders/SummarySheetBuilder.js +109 -9
  22. package/dist/types/config.types.d.ts +9 -0
  23. package/dist/types/workbook.types.d.ts +52 -1
  24. package/package.json +1 -1
  25. package/dist/package.json +0 -31
  26. package/dist/src/config/appConfig.d.ts +0 -11
  27. package/dist/src/config/appConfig.js +0 -38
  28. package/dist/src/config/core/calculatorUtils.d.ts +0 -17
  29. package/dist/src/config/core/calculatorUtils.js +0 -212
  30. package/dist/src/config/core/genericUtils.d.ts +0 -10
  31. package/dist/src/config/core/genericUtils.js +0 -79
  32. package/dist/src/config/domain/buildings.d.ts +0 -14
  33. package/dist/src/config/domain/buildings.js +0 -282
  34. package/dist/src/config/domain/emissionFactors.d.ts +0 -2
  35. package/dist/src/config/domain/emissionFactors.js +0 -42
  36. package/dist/src/config/domain/energySources.d.ts +0 -18
  37. package/dist/src/config/domain/energySources.js +0 -370
  38. package/dist/src/config/domain/infrastructure.d.ts +0 -8
  39. package/dist/src/config/domain/infrastructure.js +0 -56
  40. package/dist/src/config/domain/neighbourhoodTypes.d.ts +0 -10
  41. package/dist/src/config/domain/neighbourhoodTypes.js +0 -366
  42. package/dist/src/config/domain/regions.d.ts +0 -8
  43. package/dist/src/config/domain/regions.js +0 -423
  44. package/dist/src/config/domain/services.d.ts +0 -8
  45. package/dist/src/config/domain/services.js +0 -48
  46. package/dist/src/config/domain/transportation.d.ts +0 -12
  47. package/dist/src/config/domain/transportation.js +0 -81
  48. package/dist/src/config/i18n/en.d.ts +0 -445
  49. package/dist/src/config/i18n/en.js +0 -488
  50. package/dist/src/config/i18n/fr.d.ts +0 -445
  51. package/dist/src/config/i18n/fr.js +0 -491
  52. package/dist/src/config/types.d.ts +0 -80
  53. package/dist/src/config/types.js +0 -5
  54. package/dist/src/generator/FormulaBuilder.d.ts +0 -58
  55. package/dist/src/generator/FormulaBuilder.js +0 -101
  56. package/dist/src/generator/WorkbookGenerator.d.ts +0 -7
  57. package/dist/src/generator/WorkbookGenerator.js +0 -77
  58. package/dist/src/generator/builders/AssumptionsBuilder.d.ts +0 -20
  59. package/dist/src/generator/builders/AssumptionsBuilder.js +0 -311
  60. package/dist/src/generator/builders/CalculationSheetBuilder.d.ts +0 -20
  61. package/dist/src/generator/builders/CalculationSheetBuilder.js +0 -149
  62. package/dist/src/generator/builders/EmissionFactorsSheetBuilder.d.ts +0 -7
  63. package/dist/src/generator/builders/EmissionFactorsSheetBuilder.js +0 -86
  64. package/dist/src/generator/builders/InputDataSheetBuilder.d.ts +0 -13
  65. package/dist/src/generator/builders/InputDataSheetBuilder.js +0 -114
  66. package/dist/src/generator/builders/ScenarioSheetBuilder.d.ts +0 -19
  67. package/dist/src/generator/builders/ScenarioSheetBuilder.js +0 -1067
  68. package/dist/src/generator/builders/SummarySheetBuilder.d.ts +0 -8
  69. package/dist/src/generator/builders/SummarySheetBuilder.js +0 -304
  70. package/dist/src/index.d.ts +0 -57
  71. package/dist/src/index.js +0 -103
  72. package/dist/src/theme/defaultTheme.d.ts +0 -2
  73. package/dist/src/theme/defaultTheme.js +0 -254
  74. package/dist/src/theme/index.d.ts +0 -2
  75. package/dist/src/theme/index.js +0 -2
  76. package/dist/src/theme/sunsetTheme.d.ts +0 -2
  77. package/dist/src/theme/sunsetTheme.js +0 -310
  78. package/dist/src/types/config.types.d.ts +0 -69
  79. package/dist/src/types/config.types.js +0 -1
  80. package/dist/src/types/scenario.types.d.ts +0 -63
  81. package/dist/src/types/scenario.types.js +0 -1
  82. package/dist/src/types/workbook.types.d.ts +0 -181
  83. package/dist/src/types/workbook.types.js +0 -1
  84. package/dist/src/utils/ReactivityUtils.d.ts +0 -7
  85. package/dist/src/utils/ReactivityUtils.js +0 -26
  86. package/dist/src/utils/cellAddressing.d.ts +0 -16
  87. package/dist/src/utils/cellAddressing.js +0 -35
  88. package/dist/src/utils/formatting.d.ts +0 -9
  89. package/dist/src/utils/formatting.js +0 -32
  90. package/dist/src/writers/JsonExporter.d.ts +0 -11
  91. package/dist/src/writers/JsonExporter.js +0 -14
  92. package/dist/types/blinktagtypes.d.ts +0 -167
  93. package/dist/types/blinktagtypes.js +0 -21
@@ -1,8 +0,0 @@
1
- import { SheetSpec } from '../../types/workbook.types';
2
- import { Scenario } from '../../types/scenario.types';
3
- import { GeneratorConfig } from '../../types/config.types';
4
- export declare class SummarySheetBuilder {
5
- private config;
6
- constructor(config: GeneratorConfig);
7
- build(scenarios: Scenario[], scenarioSheets: SheetSpec[]): SheetSpec;
8
- }
@@ -1,304 +0,0 @@
1
- import { getColumnLetter } from '../../utils/cellAddressing';
2
- export class SummarySheetBuilder {
3
- config;
4
- constructor(config) {
5
- this.config = config;
6
- }
7
- build(scenarios, scenarioSheets) {
8
- const rows = [];
9
- let currentRow = 1;
10
- const c = this.config.theme.summary;
11
- // 1. Title
12
- rows.push({
13
- rowIndex: currentRow++,
14
- cells: [{ column: 'A', value: 'i18n:worksheets.scenariosSummary', format: { ...c.fonts.title, ...c.headers.general } }]
15
- });
16
- // 2. LUIC Hyperlink
17
- rows.push({
18
- rowIndex: currentRow++,
19
- cells: [{
20
- column: 'A',
21
- value: 'i18n:appInfo.worksheetAttribution',
22
- format: { ...c.fonts.hyperlink, ...c.headers.general },
23
- hyperlink: { address: 'https://luic-ciut.ssg.coop', textToDisplay: 'i18n:appInfo.worksheetAttribution' }
24
- }]
25
- });
26
- // 3. Modified Date
27
- rows.push({
28
- rowIndex: currentRow++,
29
- cells: [
30
- { column: 'A', value: 'i18n:general.modified', format: c.fonts.modified },
31
- { column: 'B', value: new Date().toLocaleString(this.config.locale, { month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric' }) }
32
- ]
33
- });
34
- currentRow++; // empty row 4
35
- // Helpers references
36
- const getEscapedSheetName = (rIdx) => scenarioSheets[rIdx].name.replace(/'/g, "''");
37
- const getRef = (sIdx, targetCol, rIdxValue) => `'${getEscapedSheetName(sIdx)}'!${targetCol}${rIdxValue}`;
38
- const getBuildingQtyRef = (sIdx, label) => {
39
- const sheet = scenarioSheets[sIdx];
40
- const idx = sheet.rows.findIndex(r => r.cells.some(c => c.column === 'B' && c.value === label));
41
- if (idx !== -1 && idx + 1 < sheet.rows.length)
42
- return `=${getRef(sIdx, 'D', sheet.rows[idx + 1].rowIndex)}`;
43
- return '0';
44
- };
45
- const getTransportVktRef = (sIdx, label, isTotal) => {
46
- const sheet = scenarioSheets[sIdx];
47
- const idx = sheet.rows.findIndex(r => r.cells.some(c => c.column === 'B' && c.value === label));
48
- if (idx !== -1 && idx + 1 < sheet.rows.length) {
49
- if (!isTotal)
50
- return `=${getRef(sIdx, 'D', sheet.rows[idx + 1].rowIndex)}`;
51
- if (idx + 2 < sheet.rows.length)
52
- return `=${getRef(sIdx, 'D', sheet.rows[idx + 2].rowIndex)}`;
53
- }
54
- return '0';
55
- };
56
- const getTotalsSumFormula = (sIdx, searchA, searchCol2, searchVal2, targetCol) => {
57
- const sheet = scenarioSheets[sIdx];
58
- let inSection = false;
59
- let sumRef = '0';
60
- for (const row of sheet.rows) {
61
- const aVal = row.cells.find(c => c.column === 'A')?.value;
62
- if (aVal === searchA)
63
- inSection = true;
64
- if (aVal && aVal !== searchA && typeof aVal === 'string' && aVal.length > 0 && aVal !== 'i18n:scenario.outputs' && aVal !== 'i18n:scenario.inputsDefaults') {
65
- if (inSection)
66
- break;
67
- }
68
- const val2 = row.cells.find(c => c.column === searchCol2)?.value;
69
- if (inSection && val2 === searchVal2) {
70
- sumRef = `=${getRef(sIdx, targetCol, row.rowIndex)}`;
71
- }
72
- }
73
- return sumRef; // returns '0' explicitly if not found
74
- };
75
- const getSumAllFormula = (sIdx, colName, searchVal, targetCol) => {
76
- const sheet = scenarioSheets[sIdx];
77
- const refs = sheet.rows
78
- .filter(r => r.cells.some(c => c.column === colName && c.value === searchVal))
79
- .map(r => getRef(sIdx, targetCol, r.rowIndex));
80
- return refs.length > 0 ? `=${refs.join('+')}` : '0';
81
- };
82
- // Headers Row 5: Scenarios
83
- const scenarioLabel = scenarios.length > 1 ? 'i18n:general.scenarios' : 'i18n:general.scenario';
84
- const scenariosHeaderRow = [
85
- { column: 'B', value: scenarioLabel, format: { ...c.fonts.bold, ...c.colors.orange } }
86
- ];
87
- scenarios.forEach((s, i) => {
88
- scenariosHeaderRow.push({ column: getColumnLetter(i + 2), value: s.title, format: { ...c.fonts.bold, ...c.colors.orange } });
89
- });
90
- rows.push({ rowIndex: currentRow++, cells: scenariosHeaderRow });
91
- // Row 6: Neighbourhood Type
92
- const neighRow = [
93
- { column: 'B', value: 'i18n:forms.fields.neighbourhoodType', format: { ...c.fonts.bold, ...c.colors.orange } }
94
- ];
95
- scenarios.forEach((s, i) => {
96
- neighRow.push({
97
- column: getColumnLetter(i + 2),
98
- value: s.neighbourhoodType ? `i18n:appConfig.neighbourhoods.neighbourhoodTypes.${s.neighbourhoodType}` : 'Custom',
99
- format: c.colors.orange
100
- });
101
- });
102
- rows.push({ rowIndex: currentRow++, cells: neighRow });
103
- // Row 7: Province
104
- const provRow = [
105
- { column: 'B', value: 'i18n:forms.fields.province', format: { ...c.fonts.bold, ...c.colors.orange } }
106
- ];
107
- scenarios.forEach((s, i) => {
108
- provRow.push({ column: getColumnLetter(i + 2), value: s.provId, format: c.colors.orange });
109
- });
110
- rows.push({ rowIndex: currentRow++, cells: provRow });
111
- // Row 8: Year
112
- const yearRow = [
113
- { column: 'B', value: 'i18n:general.year', format: { ...c.fonts.bold, ...c.colors.orange } }
114
- ];
115
- scenarios.forEach((s, i) => {
116
- yearRow.push({ column: getColumnLetter(i + 2), value: s.year, format: c.colors.orange });
117
- });
118
- rows.push({ rowIndex: currentRow++, cells: yearRow });
119
- const createDataRow = (catLabel, subLabel, catFormat, rowFormat, getValueRef, numberFormat) => {
120
- const r = [];
121
- if (catLabel !== null) {
122
- r.push({ column: 'A', value: catLabel, format: { ...c.fonts.bold, ...catFormat } });
123
- }
124
- else {
125
- r.push({ column: 'A', value: '', format: catFormat });
126
- }
127
- r.push({ column: 'B', value: subLabel, format: { ...c.fonts.bold, ...rowFormat } });
128
- scenarios.forEach((s, i) => {
129
- const valOrRef = getValueRef(i);
130
- if (typeof valOrRef === 'string' && valOrRef.startsWith('=')) {
131
- r.push({ column: getColumnLetter(i + 2), formula: valOrRef, format: { numberFormat, ...rowFormat } });
132
- }
133
- else {
134
- r.push({ column: getColumnLetter(i + 2), value: valOrRef, format: { numberFormat, ...rowFormat } });
135
- }
136
- });
137
- return r;
138
- };
139
- // 1. Buildings Section
140
- const buildingLabels = {
141
- single: 'i18n:appConfig.buildings.homeTypes.single',
142
- row: 'i18n:appConfig.buildings.homeTypes.row',
143
- apt: 'i18n:appConfig.buildings.homeTypes.apt'
144
- };
145
- const b1 = currentRow;
146
- rows.push({ rowIndex: currentRow++, cells: createDataRow('i18n:scenario.modules.buildings', buildingLabels.single, c.headers.buildings, c.data.buildings, i => getBuildingQtyRef(i, buildingLabels.single), '#,##0') });
147
- const b2 = currentRow;
148
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, buildingLabels.row, c.headers.buildings, c.data.buildings, i => getBuildingQtyRef(i, buildingLabels.row), '#,##0') });
149
- const b3 = currentRow;
150
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, buildingLabels.apt, c.headers.buildings, c.data.buildings, i => getBuildingQtyRef(i, buildingLabels.apt), '#,##0') });
151
- const totalDwellingRowIndices = [];
152
- scenarios.forEach((s, i) => {
153
- const col = getColumnLetter(i + 2);
154
- totalDwellingRowIndices.push(`${col}${b1}+${col}${b2}+${col}${b3}`);
155
- });
156
- rows.push({
157
- rowIndex: currentRow++,
158
- cells: createDataRow(null, 'i18n:scenario.totalDwellings', c.headers.buildings, c.data.buildings, i => `=${totalDwellingRowIndices[i]}`, '#,##0')
159
- });
160
- const totalDwellingsRow = currentRow - 1;
161
- // 2. Services Cost Section
162
- const srvSearchLabel = 'i18n:scenario.modules.services';
163
- const srvDisplayLabel = 'i18n:scenario.modules.servicesCost';
164
- rows.push({
165
- rowIndex: currentRow++,
166
- cells: createDataRow(srvDisplayLabel, 'i18n:general.capital ($/i18n:general.dwelling)', c.headers.services, {}, i => {
167
- const tot = getTotalsSumFormula(i, srvSearchLabel, 'B', 'i18n:general.total', 'C');
168
- const col = getColumnLetter(i + 2);
169
- return tot === '0' ? '0' : `=${tot.replace('=', '')}/${col}${totalDwellingsRow}`;
170
- }, '$#,##0')
171
- });
172
- rows.push({
173
- rowIndex: currentRow++,
174
- cells: createDataRow(null, 'i18n:general.maintenance ($/i18n:general.dwelling/i18n:general.yearAbbr)', c.headers.services, {}, i => {
175
- const tot = getTotalsSumFormula(i, srvSearchLabel, 'B', 'i18n:general.total', 'D');
176
- const col = getColumnLetter(i + 2);
177
- return tot === '0' ? '0' : `=${tot.replace('=', '')}/${col}${totalDwellingsRow}`;
178
- }, '$#,##0')
179
- });
180
- rows.push({
181
- rowIndex: currentRow++,
182
- cells: createDataRow(null, 'i18n:general.capital (i18n:general.total)', c.headers.services, c.data.services, i => getTotalsSumFormula(i, srvSearchLabel, 'B', 'i18n:general.total', 'C'), '$#,##0')
183
- });
184
- rows.push({
185
- rowIndex: currentRow++,
186
- cells: createDataRow(null, 'i18n:general.maintenance (i18n:general.total/i18n:general.yearAbbr)', c.headers.services, c.data.services, i => getTotalsSumFormula(i, srvSearchLabel, 'B', 'i18n:general.total', 'D'), '$#,##0')
187
- });
188
- // 3. Infrastructure Cost Section
189
- const infSearchLabel = 'i18n:scenario.modules.infrastructure';
190
- const infDisplayLabel = 'i18n:scenario.modules.infrastructureCost';
191
- rows.push({
192
- rowIndex: currentRow++,
193
- cells: createDataRow(infDisplayLabel, 'i18n:general.capital ($/i18n:general.dwelling)', c.headers.infrastructure, {}, i => {
194
- const tot = getTotalsSumFormula(i, infSearchLabel, 'B', 'i18n:general.total', 'C');
195
- const col = getColumnLetter(i + 2);
196
- return tot === '0' ? '0' : `=${tot.replace('=', '')}/${col}${totalDwellingsRow}`;
197
- }, '$#,##0')
198
- });
199
- rows.push({
200
- rowIndex: currentRow++,
201
- cells: createDataRow(null, 'i18n:general.maintenance ($/i18n:general.dwelling/i18n:general.yearAbbr)', c.headers.infrastructure, {}, i => {
202
- const tot = getTotalsSumFormula(i, infSearchLabel, 'B', 'i18n:general.total', 'D');
203
- const col = getColumnLetter(i + 2);
204
- return tot === '0' ? '0' : `=${tot.replace('=', '')}/${col}${totalDwellingsRow}`;
205
- }, '$#,##0')
206
- });
207
- rows.push({
208
- rowIndex: currentRow++,
209
- cells: createDataRow(null, 'i18n:general.capital (i18n:general.total)', c.headers.infrastructure, c.data.infrastructure, i => getTotalsSumFormula(i, infSearchLabel, 'B', 'i18n:general.total', 'C'), '$#,##0')
210
- });
211
- rows.push({
212
- rowIndex: currentRow++,
213
- cells: createDataRow(null, 'i18n:general.maintenance (i18n:general.total/i18n:general.yearAbbr)', c.headers.infrastructure, c.data.infrastructure, i => getTotalsSumFormula(i, infSearchLabel, 'B', 'i18n:general.total', 'D'), '$#,##0')
214
- });
215
- // 4. Transportation Section
216
- const tptLabels = {
217
- puv: 'i18n:appConfig.transportation.transportationTypes.puv',
218
- transit: 'i18n:appConfig.transportation.transportationTypes.transit',
219
- walk: 'i18n:appConfig.transportation.transportationTypes.walk',
220
- bike: 'i18n:appConfig.transportation.transportationTypes.bike'
221
- };
222
- rows.push({ rowIndex: currentRow++, cells: createDataRow('i18n:scenario.modules.transportation', `${tptLabels.puv} (VKT/i18n:general.dwelling/i18n:general.yearAbbr)`, c.headers.transportation, {}, i => getTransportVktRef(i, tptLabels.puv, false), '#,##0') });
223
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.transit} (VKT/i18n:general.dwelling/i18n:general.yearAbbr)`, c.headers.transportation, {}, i => getTransportVktRef(i, tptLabels.transit, false), '#,##0') });
224
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.walk} (VKT/i18n:general.dwelling/i18n:general.yearAbbr)`, c.headers.transportation, {}, i => getTransportVktRef(i, tptLabels.walk, false), '#,##0') });
225
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.bike} (VKT/i18n:general.dwelling/i18n:general.yearAbbr)`, c.headers.transportation, {}, i => getTransportVktRef(i, tptLabels.bike, false), '#,##0') });
226
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.puv} (i18n:general.total VKT/i18n:general.yearAbbr)`, c.headers.transportation, c.data.transportation, i => getTransportVktRef(i, tptLabels.puv, true), '#,##0') });
227
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.transit} (i18n:general.total VKT/i18n:general.yearAbbr)`, c.headers.transportation, c.data.transportation, i => getTransportVktRef(i, tptLabels.transit, true), '#,##0') });
228
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.walk} (i18n:general.total VKT/i18n:general.yearAbbr)`, c.headers.transportation, c.data.transportation, i => getTransportVktRef(i, tptLabels.walk, true), '#,##0') });
229
- rows.push({ rowIndex: currentRow++, cells: createDataRow(null, `${tptLabels.bike} (i18n:general.total VKT/i18n:general.yearAbbr)`, c.headers.transportation, c.data.transportation, i => getTransportVktRef(i, tptLabels.bike, true), '#,##0') });
230
- // 5. Municipal Revenue Section
231
- const revLabel = 'i18n:scenario.modules.revenueLong';
232
- rows.push({
233
- rowIndex: currentRow++,
234
- cells: createDataRow('i18n:scenario.modules.revenueLong', 'i18n:appConfig.revenue.revenueTypes.developmentCharges ($/i18n:general.dwelling)', c.headers.revenue, {}, i => {
235
- const tot = getTotalsSumFormula(i, revLabel, 'C', 'i18n:appConfig.revenue.revenueTypes.developmentCharges', 'D');
236
- const col = getColumnLetter(i + 2);
237
- return tot === '0' ? '0' : `=${tot.replace('=', '')}/${col}${totalDwellingsRow}`;
238
- }, '$#,##0')
239
- });
240
- rows.push({
241
- rowIndex: currentRow++,
242
- cells: createDataRow(null, 'i18n:appConfig.revenue.revenueTypes.propertyTaxes ($/i18n:general.dwelling/i18n:general.yearAbbr)', c.headers.revenue, {}, i => {
243
- const tot = getTotalsSumFormula(i, revLabel, 'C', 'i18n:appConfig.revenue.revenueTypes.propertyTaxes', 'D');
244
- const col = getColumnLetter(i + 2);
245
- return tot === '0' ? '0' : `=${tot.replace('=', '')}/${col}${totalDwellingsRow}`;
246
- }, '$#,##0')
247
- });
248
- rows.push({
249
- rowIndex: currentRow++,
250
- cells: createDataRow(null, 'i18n:appConfig.revenue.revenueTypes.developmentCharges (i18n:general.total)', c.headers.revenue, c.data.revenue, i => getTotalsSumFormula(i, revLabel, 'C', 'i18n:appConfig.revenue.revenueTypes.developmentCharges', 'D'), '$#,##0')
251
- });
252
- rows.push({
253
- rowIndex: currentRow++,
254
- // Property taxes (total) is uncolored in original (has `{}` in rowFormat position). Preserving layout.
255
- cells: createDataRow(null, 'i18n:appConfig.revenue.revenueTypes.propertyTaxes (i18n:general.total/i18n:general.yearAbbr)', c.headers.revenue, {}, i => getTotalsSumFormula(i, revLabel, 'C', 'i18n:appConfig.revenue.revenueTypes.propertyTaxes', 'D'), '$#,##0')
256
- });
257
- // 6. Energy Use Section
258
- const energyTotalRowIdx = currentRow + 1;
259
- rows.push({
260
- rowIndex: currentRow++,
261
- cells: createDataRow('i18n:scenario.energyUse', 'GJ/i18n:general.dwelling/i18n:general.yearLower', c.headers.energy, {}, i => {
262
- const col = getColumnLetter(i + 2);
263
- return `=${col}${energyTotalRowIdx}/${col}${totalDwellingsRow}`;
264
- }, '#,##0.00')
265
- });
266
- rows.push({
267
- rowIndex: currentRow++,
268
- cells: createDataRow(null, 'i18n:general.total GJ/i18n:general.yearLower', c.headers.energy, c.data.energy, i => getSumAllFormula(i, 'C', 'i18n:scenario.energyUse', 'D'), '#,##0.00')
269
- });
270
- // 7. Emissions Section
271
- const emTotalRowIdx = currentRow + 1;
272
- rows.push({
273
- rowIndex: currentRow++,
274
- cells: createDataRow('i18n:scenario.emissions', 'tCO2e/i18n:general.dwelling/i18n:general.yearLower', c.headers.emissions, {}, i => {
275
- const col = getColumnLetter(i + 2);
276
- return `=${col}${emTotalRowIdx}/${col}${totalDwellingsRow}`;
277
- }, '#,##0.00')
278
- });
279
- rows.push({
280
- rowIndex: currentRow++,
281
- cells: createDataRow(null, 'i18n:general.total tCO2e/i18n:general.yearLower', c.headers.emissions, c.data.emissions, i => getSumAllFormula(i, 'C', 'i18n:general.total', 'D'), '#,##0.00')
282
- });
283
- // Create the final sheet
284
- const sheet = {
285
- name: 'i18n:worksheets.scenariosSummary',
286
- sheetType: 'summary',
287
- visibility: 'Visible',
288
- tabColor: null,
289
- showGridlines: false,
290
- customProperties: {
291
- 'ssg-type': 'summary'
292
- },
293
- columnWidths: [
294
- { range: 'A:A', width: c.columns.A.width },
295
- { range: 'B:B', width: c.columns.B.width },
296
- { range: `C:${getColumnLetter(scenarios.length + 1)}`, width: c.columns.C.width },
297
- { range: 'D:D', width: c.columns.D.width }
298
- ],
299
- rows,
300
- mergedRanges: ['A1:D1', 'A2:D2']
301
- };
302
- return sheet;
303
- }
304
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * luic-calculator-core — public API
3
- *
4
- * This library has three distinct use surfaces:
5
- *
6
- * 1. **Workbook generation** (`Generator`) — call `generateWorkbook(scenarios)` to
7
- * produce a serializable `WorkbookSpec` consumable by Excel add-ins or Python writers.
8
- *
9
- * 2. **Domain data** (`Domain`) — populate UI dropdowns and forms with province,
10
- * building type, energy code, neighbourhood type, and energy source helpers.
11
- *
12
- * 3. **Live calculations** (`Calculator`) — run the math engine directly (energy,
13
- * emissions, costs) without generating a workbook.
14
- *
15
- * ── Namespace imports (recommended) ──────────────────────────────────────────
16
- * ```ts
17
- * import { Generator, Domain, Calculator, Themes, i18n } from 'luic-calculator-core';
18
- *
19
- * const spec = Generator.generateWorkbook(scenarios, { locale: 'en' });
20
- * const provinces = Domain.getProvinces();
21
- * const energyMJ = Calculator.calcBuildingEnergyUse(qty, 'single', 'passiveHouse');
22
- * ```
23
- *
24
- * ── Sub-path imports (optimal tree-shaking) ───────────────────────────────────
25
- * ```ts
26
- * import { generateWorkbook } from 'luic-calculator-core/generator';
27
- * import { getProvinces } from 'luic-calculator-core/domain';
28
- * import { calcBuildingEnergyUse } from 'luic-calculator-core/calculator';
29
- * ```
30
- *
31
- * ── Flat named imports (backward-compatible) ──────────────────────────────────
32
- * ```ts
33
- * import { generateWorkbook, getProvinces, calcBuildingEnergyUse } from 'luic-calculator-core';
34
- * ```
35
- */
36
- export * as Generator from './api/generator';
37
- export * as Domain from './api/domain';
38
- export * as Calculator from './api/calculator';
39
- export * as Themes from './theme';
40
- export * as i18n from './api/i18n';
41
- export * from './types/workbook.types';
42
- export * from './types/scenario.types';
43
- export * from './types/config.types';
44
- export { generateWorkbook } from './generator/WorkbookGenerator';
45
- export { JsonExporter } from './writers/JsonExporter';
46
- export { AssumptionsBuilder } from './generator/builders/AssumptionsBuilder';
47
- export type { AssumptionsResult } from './generator/builders/AssumptionsBuilder';
48
- export { ScenarioSheetBuilder } from './generator/builders/ScenarioSheetBuilder';
49
- export { SummarySheetBuilder } from './generator/builders/SummarySheetBuilder';
50
- export { FormulaBuilder } from './generator/FormulaBuilder';
51
- export { FormattingUtils } from './utils/formatting';
52
- export { getColumnLetter, colLetterToIndex, getRangeAcrossColumns } from './utils/cellAddressing';
53
- export * from './theme';
54
- export { default as i18n_en } from './config/i18n/en';
55
- export { default as i18n_fr } from './config/i18n/fr';
56
- export * from './api/domain';
57
- export declare const getEUIForCode: any, calcBuildingEnergyUse: any, calcServiceCapCost: any, calcServiceMaintCost: any, calcInfraCapCost: any, calcInfraMaintCost: any, calcTotalVKT: any, computeTransportEnergyFromSourcesList: (t: any, sourcesList: any, transportationType: string, vkt: number) => number, computeGhGsFromSourcesList: (t: any, provId: string | undefined, sourcesList: any, year: number | string, sourceListMode: string, energyExisting: number, energyFactor?: number | null) => any, computeGHGsFromSourceForYear: any, computeGHGsFromSource: (t: any, sourceId: string, year: number | string, srcEnergy: number, provId?: string) => any, sumEnergyFromObjCollection: (obj: any) => number, sumEmissionsFromObjCollection: (obj: any) => number, sumEnergyForScenario: (scenario: any) => number, sumEnergyForScenarioGJ: (scenario: any) => number, sumEmissionsForScenario: (scenario: any) => number, sumCostsForObj: (scenario: any, obj: string, key: string) => number, sumRevenueForObj: (scenario: any, obj: string, key: string) => number, sumEnergyFromSources: (energySources: any, units: any, t: any, provId?: string) => number, convert: (value?: number) => import("convert-units").Converter<"energy" | "length" | "volumeToEnergy" | "area", string, string, number>, stripUnitsYr: (units: string) => string, stripUnits: (units: string, strip_units: string) => string, convertMPGtoLP100km: (MPG: number) => number;
package/dist/src/index.js DELETED
@@ -1,103 +0,0 @@
1
- /**
2
- * luic-calculator-core — public API
3
- *
4
- * This library has three distinct use surfaces:
5
- *
6
- * 1. **Workbook generation** (`Generator`) — call `generateWorkbook(scenarios)` to
7
- * produce a serializable `WorkbookSpec` consumable by Excel add-ins or Python writers.
8
- *
9
- * 2. **Domain data** (`Domain`) — populate UI dropdowns and forms with province,
10
- * building type, energy code, neighbourhood type, and energy source helpers.
11
- *
12
- * 3. **Live calculations** (`Calculator`) — run the math engine directly (energy,
13
- * emissions, costs) without generating a workbook.
14
- *
15
- * ── Namespace imports (recommended) ──────────────────────────────────────────
16
- * ```ts
17
- * import { Generator, Domain, Calculator, Themes, i18n } from 'luic-calculator-core';
18
- *
19
- * const spec = Generator.generateWorkbook(scenarios, { locale: 'en' });
20
- * const provinces = Domain.getProvinces();
21
- * const energyMJ = Calculator.calcBuildingEnergyUse(qty, 'single', 'passiveHouse');
22
- * ```
23
- *
24
- * ── Sub-path imports (optimal tree-shaking) ───────────────────────────────────
25
- * ```ts
26
- * import { generateWorkbook } from 'luic-calculator-core/generator';
27
- * import { getProvinces } from 'luic-calculator-core/domain';
28
- * import { calcBuildingEnergyUse } from 'luic-calculator-core/calculator';
29
- * ```
30
- *
31
- * ── Flat named imports (backward-compatible) ──────────────────────────────────
32
- * ```ts
33
- * import { generateWorkbook, getProvinces, calcBuildingEnergyUse } from 'luic-calculator-core';
34
- * ```
35
- */
36
- // ── NAMESPACE EXPORTS ─────────────────────────────────────────────────────────
37
- // Grouped namespaces for ergonomic, self-documenting imports.
38
- export * as Generator from './api/generator';
39
- export * as Domain from './api/domain';
40
- export * as Calculator from './api/calculator';
41
- export * as Themes from './theme';
42
- export * as i18n from './api/i18n';
43
- // ─────────────────────────────────────────────────────────────────────────────
44
- // TYPES
45
- // Core data shapes used across the entire library.
46
- // ─────────────────────────────────────────────────────────────────────────────
47
- export * from './types/workbook.types';
48
- export * from './types/scenario.types';
49
- export * from './types/config.types';
50
- // ─────────────────────────────────────────────────────────────────────────────
51
- // WORKBOOK GENERATION
52
- // Turn Scenario[] into a fully serializable WorkbookSpec blueprint.
53
- // ─────────────────────────────────────────────────────────────────────────────
54
- export { generateWorkbook } from './generator/WorkbookGenerator';
55
- export { JsonExporter } from './writers/JsonExporter';
56
- // Low-level builders — use these only if you need to assemble individual sheets
57
- export { AssumptionsBuilder } from './generator/builders/AssumptionsBuilder';
58
- export { ScenarioSheetBuilder } from './generator/builders/ScenarioSheetBuilder';
59
- export { SummarySheetBuilder } from './generator/builders/SummarySheetBuilder';
60
- export { FormulaBuilder } from './generator/FormulaBuilder';
61
- // Workbook styling helpers
62
- export { FormattingUtils } from './utils/formatting';
63
- export { getColumnLetter, colLetterToIndex, getRangeAcrossColumns } from './utils/cellAddressing';
64
- // ─────────────────────────────────────────────────────────────────────────────
65
- // THEMES
66
- // Pre-built WorkbookTheme objects — pass as `config.theme` to generateWorkbook.
67
- // ─────────────────────────────────────────────────────────────────────────────
68
- export * from './theme';
69
- // ─────────────────────────────────────────────────────────────────────────────
70
- // I18N
71
- // Source-of-truth translation dictionaries. All `.name` / `.description` fields
72
- // in domain config objects are raw i18n keys — pass through your t() before use.
73
- // ─────────────────────────────────────────────────────────────────────────────
74
- export { default as i18n_en } from './config/i18n/en';
75
- export { default as i18n_fr } from './config/i18n/fr';
76
- // ─────────────────────────────────────────────────────────────────────────────
77
- // DOMAIN DATA — UI POPULATION
78
- // Populate dropdowns, menus, and form fields. Config factories are exported for
79
- // advanced consumers who need direct access to raw config objects.
80
- // ─────────────────────────────────────────────────────────────────────────────
81
- // Config factories (advanced use — prefer named helpers below for most cases)
82
- export * from './api/domain';
83
- // ─────────────────────────────────────────────────────────────────────────────
84
- // CALCULATION ENGINE — LIVE MATH
85
- // All functions are pure (no side effects). Use these to drive live UI feedback
86
- // or to verify scenario values without producing a full workbook.
87
- // ─────────────────────────────────────────────────────────────────────────────
88
- import useCalculatorUtils from './config/core/calculatorUtils';
89
- export const {
90
- // Building energy
91
- getEUIForCode, calcBuildingEnergyUse,
92
- // Service costs
93
- calcServiceCapCost, calcServiceMaintCost,
94
- // Infrastructure costs
95
- calcInfraCapCost, calcInfraMaintCost,
96
- // Transportation
97
- calcTotalVKT, computeTransportEnergyFromSourcesList,
98
- // GHG emissions
99
- computeGhGsFromSourcesList, computeGHGsFromSourceForYear, computeGHGsFromSource,
100
- // Scenario aggregates
101
- sumEnergyFromObjCollection, sumEmissionsFromObjCollection, sumEnergyForScenario, sumEnergyForScenarioGJ, sumEmissionsForScenario, sumCostsForObj, sumRevenueForObj, sumEnergyFromSources,
102
- // Unit conversion utilities
103
- convert, stripUnitsYr, stripUnits, convertMPGtoLP100km, } = useCalculatorUtils();
@@ -1,2 +0,0 @@
1
- import { WorkbookTheme } from "../types/config.types";
2
- export declare const defaultTheme: WorkbookTheme;