equilibria-mcp-server 1.0.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/CHANGELOG.md +142 -0
- package/LICENSE +21 -0
- package/README.md +240 -0
- package/dist/builders/YAMLBuilder.d.ts +77 -0
- package/dist/builders/YAMLBuilder.d.ts.map +1 -0
- package/dist/builders/YAMLBuilder.js +251 -0
- package/dist/builders/YAMLBuilder.js.map +1 -0
- package/dist/economics/constants.d.ts +39 -0
- package/dist/economics/constants.d.ts.map +1 -0
- package/dist/economics/constants.js +46 -0
- package/dist/economics/constants.js.map +1 -0
- package/dist/economics/formulas.d.ts +19 -0
- package/dist/economics/formulas.d.ts.map +1 -0
- package/dist/economics/formulas.js +260 -0
- package/dist/economics/formulas.js.map +1 -0
- package/dist/economics/index.d.ts +9 -0
- package/dist/economics/index.d.ts.map +1 -0
- package/dist/economics/index.js +9 -0
- package/dist/economics/index.js.map +1 -0
- package/dist/economics/validators.d.ts +18 -0
- package/dist/economics/validators.d.ts.map +1 -0
- package/dist/economics/validators.js +111 -0
- package/dist/economics/validators.js.map +1 -0
- package/dist/errors/index.d.ts +172 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +313 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/formatters/index.d.ts +8 -0
- package/dist/formatters/index.d.ts.map +1 -0
- package/dist/formatters/index.js +8 -0
- package/dist/formatters/index.js.map +1 -0
- package/dist/formatters/redux.d.ts +15 -0
- package/dist/formatters/redux.d.ts.map +1 -0
- package/dist/formatters/redux.js +35 -0
- package/dist/formatters/redux.js.map +1 -0
- package/dist/formatters/yaml.d.ts +18 -0
- package/dist/formatters/yaml.d.ts.map +1 -0
- package/dist/formatters/yaml.js +40 -0
- package/dist/formatters/yaml.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +14 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +86 -0
- package/dist/server.js.map +1 -0
- package/dist/templates/advancedMicro.d.ts +8 -0
- package/dist/templates/advancedMicro.d.ts.map +1 -0
- package/dist/templates/advancedMicro.js +834 -0
- package/dist/templates/advancedMicro.js.map +1 -0
- package/dist/templates/consumer.d.ts +12 -0
- package/dist/templates/consumer.d.ts.map +1 -0
- package/dist/templates/consumer.js +1978 -0
- package/dist/templates/consumer.js.map +1 -0
- package/dist/templates/elasticity.d.ts +8 -0
- package/dist/templates/elasticity.d.ts.map +1 -0
- package/dist/templates/elasticity.js +500 -0
- package/dist/templates/elasticity.js.map +1 -0
- package/dist/templates/externalities.d.ts +11 -0
- package/dist/templates/externalities.d.ts.map +1 -0
- package/dist/templates/externalities.js +997 -0
- package/dist/templates/externalities.js.map +1 -0
- package/dist/templates/financeBehavioral.d.ts +8 -0
- package/dist/templates/financeBehavioral.d.ts.map +1 -0
- package/dist/templates/financeBehavioral.js +860 -0
- package/dist/templates/financeBehavioral.js.map +1 -0
- package/dist/templates/growth.d.ts +8 -0
- package/dist/templates/growth.d.ts.map +1 -0
- package/dist/templates/growth.js +740 -0
- package/dist/templates/growth.js.map +1 -0
- package/dist/templates/index.d.ts +31 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +91 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/inequality.d.ts +8 -0
- package/dist/templates/inequality.d.ts.map +1 -0
- package/dist/templates/inequality.js +562 -0
- package/dist/templates/inequality.js.map +1 -0
- package/dist/templates/intertemporalMacro.d.ts +8 -0
- package/dist/templates/intertemporalMacro.d.ts.map +1 -0
- package/dist/templates/intertemporalMacro.js +550 -0
- package/dist/templates/intertemporalMacro.js.map +1 -0
- package/dist/templates/isLM.d.ts +8 -0
- package/dist/templates/isLM.d.ts.map +1 -0
- package/dist/templates/isLM.js +747 -0
- package/dist/templates/isLM.js.map +1 -0
- package/dist/templates/macro.d.ts +8 -0
- package/dist/templates/macro.d.ts.map +1 -0
- package/dist/templates/macro.js +600 -0
- package/dist/templates/macro.js.map +1 -0
- package/dist/templates/marketStructures.d.ts +11 -0
- package/dist/templates/marketStructures.d.ts.map +1 -0
- package/dist/templates/marketStructures.js +1135 -0
- package/dist/templates/marketStructures.js.map +1 -0
- package/dist/templates/newKeynesian.d.ts +8 -0
- package/dist/templates/newKeynesian.d.ts.map +1 -0
- package/dist/templates/newKeynesian.js +633 -0
- package/dist/templates/newKeynesian.js.map +1 -0
- package/dist/templates/oligopoly.d.ts +11 -0
- package/dist/templates/oligopoly.d.ts.map +1 -0
- package/dist/templates/oligopoly.js +1113 -0
- package/dist/templates/oligopoly.js.map +1 -0
- package/dist/templates/ppf.d.ts +8 -0
- package/dist/templates/ppf.d.ts.map +1 -0
- package/dist/templates/ppf.js +439 -0
- package/dist/templates/ppf.js.map +1 -0
- package/dist/templates/producer.d.ts +11 -0
- package/dist/templates/producer.d.ts.map +1 -0
- package/dist/templates/producer.js +979 -0
- package/dist/templates/producer.js.map +1 -0
- package/dist/templates/production.d.ts +8 -0
- package/dist/templates/production.d.ts.map +1 -0
- package/dist/templates/production.js +574 -0
- package/dist/templates/production.js.map +1 -0
- package/dist/templates/supplyDemand.d.ts +8 -0
- package/dist/templates/supplyDemand.d.ts.map +1 -0
- package/dist/templates/supplyDemand.js +1282 -0
- package/dist/templates/supplyDemand.js.map +1 -0
- package/dist/templates/tradeGrowth.d.ts +8 -0
- package/dist/templates/tradeGrowth.d.ts.map +1 -0
- package/dist/templates/tradeGrowth.js +637 -0
- package/dist/templates/tradeGrowth.js.map +1 -0
- package/dist/tools/index.d.ts +25 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +54 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/models.d.ts +8 -0
- package/dist/tools/models.d.ts.map +1 -0
- package/dist/tools/models.js +828 -0
- package/dist/tools/models.js.map +1 -0
- package/dist/tools/output.d.ts +8 -0
- package/dist/tools/output.d.ts.map +1 -0
- package/dist/tools/output.js +236 -0
- package/dist/tools/output.js.map +1 -0
- package/dist/tools/templates.d.ts +8 -0
- package/dist/tools/templates.d.ts.map +1 -0
- package/dist/tools/templates.js +247 -0
- package/dist/tools/templates.js.map +1 -0
- package/dist/tools/validation.d.ts +8 -0
- package/dist/tools/validation.d.ts.map +1 -0
- package/dist/tools/validation.js +181 -0
- package/dist/tools/validation.js.map +1 -0
- package/dist/types/index.d.ts +187 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/cache.d.ts +99 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +192 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +128 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +251 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/validation/index.d.ts +42 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +282 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML Document Builder
|
|
3
|
+
*
|
|
4
|
+
* Fluent API for constructing Equilibria YAML documents programmatically.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Builder class for constructing Equilibria documents
|
|
8
|
+
*/
|
|
9
|
+
export class YAMLBuilder {
|
|
10
|
+
state;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.state = {
|
|
13
|
+
metadata: {
|
|
14
|
+
specVersion: '1.3',
|
|
15
|
+
},
|
|
16
|
+
parameters: {},
|
|
17
|
+
charts: [],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set document title
|
|
22
|
+
*/
|
|
23
|
+
setTitle(title) {
|
|
24
|
+
this.state.metadata.title = title;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Set document description
|
|
29
|
+
*/
|
|
30
|
+
setDescription(description) {
|
|
31
|
+
this.state.metadata.description = description;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Set spec version
|
|
36
|
+
*/
|
|
37
|
+
setSpecVersion(version) {
|
|
38
|
+
this.state.metadata.specVersion = version;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Add a global parameter
|
|
43
|
+
*/
|
|
44
|
+
addParameter(name, config, chartId) {
|
|
45
|
+
if (chartId) {
|
|
46
|
+
const chart = this.state.charts.find((c) => c.id === chartId);
|
|
47
|
+
if (chart) {
|
|
48
|
+
if (!chart.parameters) {
|
|
49
|
+
chart.parameters = {};
|
|
50
|
+
}
|
|
51
|
+
chart.parameters[name] = config;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.state.parameters[name] = config;
|
|
56
|
+
}
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Add multiple parameters at once
|
|
61
|
+
*/
|
|
62
|
+
addParameters(params, chartId) {
|
|
63
|
+
for (const [name, config] of Object.entries(params)) {
|
|
64
|
+
this.addParameter(name, config, chartId);
|
|
65
|
+
}
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Add a chart
|
|
70
|
+
*/
|
|
71
|
+
addChart(config) {
|
|
72
|
+
this.state.charts.push(config);
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get a chart by ID
|
|
77
|
+
*/
|
|
78
|
+
getChart(chartId) {
|
|
79
|
+
return this.state.charts.find((c) => c.id === chartId);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Add an element to a chart
|
|
83
|
+
*/
|
|
84
|
+
addElement(chartId, element) {
|
|
85
|
+
const chart = this.state.charts.find((c) => c.id === chartId);
|
|
86
|
+
if (chart) {
|
|
87
|
+
chart.elements.push(element);
|
|
88
|
+
}
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Add an annotation to a chart
|
|
93
|
+
*/
|
|
94
|
+
addAnnotation(chartId, annotation) {
|
|
95
|
+
const chart = this.state.charts.find((c) => c.id === chartId);
|
|
96
|
+
if (chart) {
|
|
97
|
+
if (!chart.annotations) {
|
|
98
|
+
chart.annotations = [];
|
|
99
|
+
}
|
|
100
|
+
chart.annotations.push(annotation);
|
|
101
|
+
}
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Build the final document object
|
|
106
|
+
*/
|
|
107
|
+
build() {
|
|
108
|
+
const doc = {
|
|
109
|
+
metadata: {
|
|
110
|
+
specVersion: this.state.metadata.specVersion,
|
|
111
|
+
title: this.state.metadata.title || 'Untitled',
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
if (this.state.metadata.description) {
|
|
115
|
+
doc.metadata.description =
|
|
116
|
+
this.state.metadata.description;
|
|
117
|
+
}
|
|
118
|
+
// Add global parameters if any
|
|
119
|
+
if (Object.keys(this.state.parameters).length > 0) {
|
|
120
|
+
doc.parameters = this.formatParameters(this.state.parameters);
|
|
121
|
+
}
|
|
122
|
+
// Add charts
|
|
123
|
+
doc.charts = this.state.charts.map((chart) => this.formatChart(chart));
|
|
124
|
+
return doc;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Format parameters for output
|
|
128
|
+
*/
|
|
129
|
+
formatParameters(params) {
|
|
130
|
+
const result = {};
|
|
131
|
+
for (const [name, config] of Object.entries(params)) {
|
|
132
|
+
const param = {};
|
|
133
|
+
if (config.value !== undefined)
|
|
134
|
+
param.value = config.value;
|
|
135
|
+
if (config.expression)
|
|
136
|
+
param.expression = config.expression;
|
|
137
|
+
if (config.min !== undefined)
|
|
138
|
+
param.min = config.min;
|
|
139
|
+
if (config.max !== undefined)
|
|
140
|
+
param.max = config.max;
|
|
141
|
+
if (config.step !== undefined)
|
|
142
|
+
param.step = config.step;
|
|
143
|
+
if (config.label)
|
|
144
|
+
param.label = config.label;
|
|
145
|
+
if (config.hidden !== undefined)
|
|
146
|
+
param.hidden = config.hidden;
|
|
147
|
+
result[name] = param;
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Format a chart for output
|
|
153
|
+
*/
|
|
154
|
+
formatChart(chart) {
|
|
155
|
+
const result = {
|
|
156
|
+
id: chart.id,
|
|
157
|
+
xAxis: chart.xAxis,
|
|
158
|
+
yAxis: chart.yAxis,
|
|
159
|
+
elements: chart.elements,
|
|
160
|
+
};
|
|
161
|
+
if (chart.title)
|
|
162
|
+
result.title = chart.title;
|
|
163
|
+
if (chart.parameters) {
|
|
164
|
+
result.parameters = this.formatParameters(chart.parameters);
|
|
165
|
+
}
|
|
166
|
+
if (chart.annotations && chart.annotations.length > 0) {
|
|
167
|
+
result.annotations = chart.annotations;
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Reset the builder to initial state
|
|
173
|
+
*/
|
|
174
|
+
reset() {
|
|
175
|
+
this.state = {
|
|
176
|
+
metadata: {
|
|
177
|
+
specVersion: '1.3',
|
|
178
|
+
},
|
|
179
|
+
parameters: {},
|
|
180
|
+
charts: [],
|
|
181
|
+
};
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Convenience function to create a supply and demand document
|
|
187
|
+
*/
|
|
188
|
+
export function createSupplyDemandDocument(options) {
|
|
189
|
+
const { title = 'Supply and Demand', demandIntercept = 100, demandSlope = 1, supplyIntercept = 0, supplySlope = 1, showSurplus = false, } = options;
|
|
190
|
+
// Calculate equilibrium
|
|
191
|
+
const eqQuantity = (demandIntercept - supplyIntercept) / (demandSlope + supplySlope);
|
|
192
|
+
const eqPrice = supplyIntercept + supplySlope * eqQuantity;
|
|
193
|
+
const builder = new YAMLBuilder()
|
|
194
|
+
.setTitle(title)
|
|
195
|
+
.addChart({
|
|
196
|
+
id: 'main',
|
|
197
|
+
xAxis: { label: 'Quantity', min: 0, max: demandIntercept },
|
|
198
|
+
yAxis: { label: 'Price', min: 0, max: demandIntercept },
|
|
199
|
+
elements: [
|
|
200
|
+
{
|
|
201
|
+
id: 'demand',
|
|
202
|
+
type: 'line',
|
|
203
|
+
equation: `${demandIntercept} - ${demandSlope} * x`,
|
|
204
|
+
label: 'Demand',
|
|
205
|
+
color: '#2563EB',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: 'supply',
|
|
209
|
+
type: 'line',
|
|
210
|
+
equation: `${supplyIntercept} + ${supplySlope} * x`,
|
|
211
|
+
label: 'Supply',
|
|
212
|
+
color: '#DC2626',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
id: 'equilibrium',
|
|
216
|
+
type: 'point',
|
|
217
|
+
x: eqQuantity,
|
|
218
|
+
y: eqPrice,
|
|
219
|
+
label: 'E',
|
|
220
|
+
color: '#16A34A',
|
|
221
|
+
droplines: { x: true, y: true },
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
});
|
|
225
|
+
if (showSurplus) {
|
|
226
|
+
builder.addElement('main', {
|
|
227
|
+
id: 'consumer-surplus',
|
|
228
|
+
type: 'area',
|
|
229
|
+
topBoundary: 'demand',
|
|
230
|
+
bottomBoundary: String(eqPrice),
|
|
231
|
+
leftBoundary: '0',
|
|
232
|
+
rightBoundary: String(eqQuantity),
|
|
233
|
+
color: '#3B82F6',
|
|
234
|
+
opacity: 0.3,
|
|
235
|
+
label: 'Consumer Surplus',
|
|
236
|
+
});
|
|
237
|
+
builder.addElement('main', {
|
|
238
|
+
id: 'producer-surplus',
|
|
239
|
+
type: 'area',
|
|
240
|
+
topBoundary: String(eqPrice),
|
|
241
|
+
bottomBoundary: 'supply',
|
|
242
|
+
leftBoundary: '0',
|
|
243
|
+
rightBoundary: String(eqQuantity),
|
|
244
|
+
color: '#EF4444',
|
|
245
|
+
opacity: 0.3,
|
|
246
|
+
label: 'Producer Surplus',
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return builder.build();
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=YAMLBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YAMLBuilder.js","sourceRoot":"","sources":["../../src/builders/YAMLBuilder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,OAAO,WAAW;IACd,KAAK,CAAe;IAE5B;QACE,IAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE;gBACR,WAAW,EAAE,KAAK;aACnB;YACD,UAAU,EAAE,EAAE;YACd,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,WAAmB;QAChC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,OAAe;QAC5B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,GAAG,OAAO,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,YAAY,CACV,IAAY,EACZ,MAAuB,EACvB,OAAgB;QAEhB,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,C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AE,MAAM;YACZ,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC;YAC5B,cAAc,EAAE,QAAQ;YACxB,YAAY,EAAE,GAAG;YACjB,aAAa,EAAE,MAAM,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,GAAG;YACZ,KAAK,EAAE,kBAAkB;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Economic Constants
|
|
3
|
+
*
|
|
4
|
+
* Standard values and defaults for economic models.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Common economic constants and typical values
|
|
8
|
+
*/
|
|
9
|
+
export declare const ECONOMIC_CONSTANTS: {
|
|
10
|
+
readonly TYPICAL_CAPITAL_SHARE: 0.33;
|
|
11
|
+
readonly TYPICAL_LABOR_SHARE: 0.67;
|
|
12
|
+
readonly TYPICAL_SAVING_RATE: 0.2;
|
|
13
|
+
readonly TYPICAL_DEPRECIATION_RATE: 0.05;
|
|
14
|
+
readonly TYPICAL_POPULATION_GROWTH: 0.01;
|
|
15
|
+
readonly TYPICAL_TFP_GROWTH: 0.02;
|
|
16
|
+
readonly UNIT_ELASTIC: -1;
|
|
17
|
+
readonly PERFECTLY_ELASTIC: number;
|
|
18
|
+
readonly PERFECTLY_INELASTIC: 0;
|
|
19
|
+
readonly TYPICAL_MPC: 0.75;
|
|
20
|
+
readonly TYPICAL_MPS: 0.25;
|
|
21
|
+
readonly TYPICAL_INVESTMENT_SENSITIVITY: 0.5;
|
|
22
|
+
readonly TYPICAL_MONEY_DEMAND_SENSITIVITY: 0.5;
|
|
23
|
+
readonly TYPICAL_NAIRU: 0.05;
|
|
24
|
+
readonly TYPICAL_PHILLIPS_SLOPE: 0.5;
|
|
25
|
+
readonly DEFAULT_QUANTITY_MAX: 100;
|
|
26
|
+
readonly DEFAULT_PRICE_MAX: 100;
|
|
27
|
+
readonly COLORS: {
|
|
28
|
+
readonly DEMAND: "#2563EB";
|
|
29
|
+
readonly SUPPLY: "#DC2626";
|
|
30
|
+
readonly EQUILIBRIUM: "#16A34A";
|
|
31
|
+
readonly CONSUMER_SURPLUS: "#3B82F6";
|
|
32
|
+
readonly PRODUCER_SURPLUS: "#EF4444";
|
|
33
|
+
readonly DEADWEIGHT_LOSS: "#A855F7";
|
|
34
|
+
readonly TAX_REVENUE: "#22C55E";
|
|
35
|
+
readonly PRICE_CONTROL: "#7C3AED";
|
|
36
|
+
readonly SHIFT: "#F59E0B";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/economics/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CrB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Economic Constants
|
|
3
|
+
*
|
|
4
|
+
* Standard values and defaults for economic models.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Common economic constants and typical values
|
|
8
|
+
*/
|
|
9
|
+
export const ECONOMIC_CONSTANTS = {
|
|
10
|
+
// Cobb-Douglas parameters
|
|
11
|
+
TYPICAL_CAPITAL_SHARE: 0.33,
|
|
12
|
+
TYPICAL_LABOR_SHARE: 0.67,
|
|
13
|
+
// Solow model defaults
|
|
14
|
+
TYPICAL_SAVING_RATE: 0.2,
|
|
15
|
+
TYPICAL_DEPRECIATION_RATE: 0.05,
|
|
16
|
+
TYPICAL_POPULATION_GROWTH: 0.01,
|
|
17
|
+
TYPICAL_TFP_GROWTH: 0.02,
|
|
18
|
+
// Elasticity benchmarks
|
|
19
|
+
UNIT_ELASTIC: -1,
|
|
20
|
+
PERFECTLY_ELASTIC: Infinity,
|
|
21
|
+
PERFECTLY_INELASTIC: 0,
|
|
22
|
+
// IS-LM parameters
|
|
23
|
+
TYPICAL_MPC: 0.75, // Marginal propensity to consume
|
|
24
|
+
TYPICAL_MPS: 0.25, // Marginal propensity to save
|
|
25
|
+
TYPICAL_INVESTMENT_SENSITIVITY: 0.5,
|
|
26
|
+
TYPICAL_MONEY_DEMAND_SENSITIVITY: 0.5,
|
|
27
|
+
// Phillips Curve
|
|
28
|
+
TYPICAL_NAIRU: 0.05, // 5% natural rate of unemployment
|
|
29
|
+
TYPICAL_PHILLIPS_SLOPE: 0.5,
|
|
30
|
+
// Default graph ranges
|
|
31
|
+
DEFAULT_QUANTITY_MAX: 100,
|
|
32
|
+
DEFAULT_PRICE_MAX: 100,
|
|
33
|
+
// Colors for economic concepts
|
|
34
|
+
COLORS: {
|
|
35
|
+
DEMAND: '#2563EB', // Blue
|
|
36
|
+
SUPPLY: '#DC2626', // Red
|
|
37
|
+
EQUILIBRIUM: '#16A34A', // Green
|
|
38
|
+
CONSUMER_SURPLUS: '#3B82F6', // Light blue
|
|
39
|
+
PRODUCER_SURPLUS: '#EF4444', // Light red
|
|
40
|
+
DEADWEIGHT_LOSS: '#A855F7', // Purple
|
|
41
|
+
TAX_REVENUE: '#22C55E', // Light green
|
|
42
|
+
PRICE_CONTROL: '#7C3AED', // Violet
|
|
43
|
+
SHIFT: '#F59E0B', // Amber (for curve shifts)
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/economics/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,0BAA0B;IAC1B,qBAAqB,EAAE,IAAI;IAC3B,mBAAmB,EAAE,IAAI;IAEzB,uBAAuB;IACvB,mBAAmB,EAAE,GAAG;IACxB,yBAAyB,EAAE,IAAI;IAC/B,yBAAyB,EAAE,IAAI;IAC/B,kBAAkB,EAAE,IAAI;IAExB,wBAAwB;IACxB,YAAY,EAAE,CAAC,CAAC;IAChB,iBAAiB,EAAE,QAAQ;IAC3B,mBAAmB,EAAE,CAAC;IAEtB,mBAAmB;IACnB,WAAW,EAAE,IAAI,EAAE,iCAAiC;IACpD,WAAW,EAAE,IAAI,EAAE,8BAA8B;IACjD,8BAA8B,EAAE,GAAG;IACnC,gCAAgC,EAAE,GAAG;IAErC,iBAAiB;IACjB,aAAa,EAAE,IAAI,EAAE,kCAAkC;IACvD,sBAAsB,EAAE,GAAG;IAE3B,uBAAuB;IACvB,oBAAoB,EAAE,GAAG;IACzB,iBAAiB,EAAE,GAAG;IAEtB,+BAA+B;IAC/B,MAAM,EAAE;QACN,MAAM,EAAE,SAAS,EAAE,OAAO;QAC1B,MAAM,EAAE,SAAS,EAAE,MAAM;QACzB,WAAW,EAAE,SAAS,EAAE,QAAQ;QAChC,gBAAgB,EAAE,SAAS,EAAE,aAAa;QAC1C,gBAAgB,EAAE,SAAS,EAAE,YAAY;QACzC,eAAe,EAAE,SAAS,EAAE,SAAS;QACrC,WAAW,EAAE,SAAS,EAAE,cAAc;QACtC,aAAa,EAAE,SAAS,EAAE,SAAS;QACnC,KAAK,EAAE,SAAS,EAAE,2BAA2B;KAC9C;CACO,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Economic Formulas Library
|
|
3
|
+
*
|
|
4
|
+
* Standard economic formulas for use in templates and calculations.
|
|
5
|
+
*/
|
|
6
|
+
import type { EconomicFormula } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Collection of standard economic formulas
|
|
9
|
+
*/
|
|
10
|
+
export declare const economicFormulas: EconomicFormula[];
|
|
11
|
+
/**
|
|
12
|
+
* Get formula by ID
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFormula(id: string): EconomicFormula | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Get formulas by category
|
|
17
|
+
*/
|
|
18
|
+
export declare function getFormulasByCategory(category: string): EconomicFormula[];
|
|
19
|
+
//# sourceMappingURL=formulas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formulas.d.ts","sourceRoot":"","sources":["../../src/economics/formulas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,eAAe,EAoP7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAElE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,CAEzE"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Economic Formulas Library
|
|
3
|
+
*
|
|
4
|
+
* Standard economic formulas for use in templates and calculations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Collection of standard economic formulas
|
|
8
|
+
*/
|
|
9
|
+
export const economicFormulas = [
|
|
10
|
+
// === EQUILIBRIUM ===
|
|
11
|
+
{
|
|
12
|
+
id: 'linear_demand',
|
|
13
|
+
name: 'Linear Demand',
|
|
14
|
+
expression: 'a - b * P',
|
|
15
|
+
inputs: ['a', 'b', 'P'],
|
|
16
|
+
output: 'Qd',
|
|
17
|
+
category: 'equilibrium',
|
|
18
|
+
notes: 'a = demand intercept (choke price), b = slope (sensitivity)',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'linear_supply',
|
|
22
|
+
name: 'Linear Supply',
|
|
23
|
+
expression: 'c + d * P',
|
|
24
|
+
inputs: ['c', 'd', 'P'],
|
|
25
|
+
output: 'Qs',
|
|
26
|
+
category: 'equilibrium',
|
|
27
|
+
notes: 'c = supply intercept, d = slope',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'equilibrium_price',
|
|
31
|
+
name: 'Equilibrium Price (Linear)',
|
|
32
|
+
expression: '(a - c) / (b + d)',
|
|
33
|
+
inputs: ['a', 'b', 'c', 'd'],
|
|
34
|
+
output: 'P*',
|
|
35
|
+
category: 'equilibrium',
|
|
36
|
+
notes: 'Market clearing price for linear supply and demand',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'equilibrium_quantity',
|
|
40
|
+
name: 'Equilibrium Quantity (Linear)',
|
|
41
|
+
expression: '(a * d + b * c) / (b + d)',
|
|
42
|
+
inputs: ['a', 'b', 'c', 'd'],
|
|
43
|
+
output: 'Q*',
|
|
44
|
+
category: 'equilibrium',
|
|
45
|
+
},
|
|
46
|
+
// === SURPLUS ===
|
|
47
|
+
{
|
|
48
|
+
id: 'consumer_surplus_linear',
|
|
49
|
+
name: 'Consumer Surplus (Linear)',
|
|
50
|
+
expression: '0.5 * (Pmax - P) * Q',
|
|
51
|
+
inputs: ['Pmax', 'P', 'Q'],
|
|
52
|
+
output: 'CS',
|
|
53
|
+
category: 'surplus',
|
|
54
|
+
notes: 'Area of triangle below demand curve and above price',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'producer_surplus_linear',
|
|
58
|
+
name: 'Producer Surplus (Linear)',
|
|
59
|
+
expression: '0.5 * (P - Pmin) * Q',
|
|
60
|
+
inputs: ['Pmin', 'P', 'Q'],
|
|
61
|
+
output: 'PS',
|
|
62
|
+
category: 'surplus',
|
|
63
|
+
notes: 'Area of triangle above supply curve and below price',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'total_surplus',
|
|
67
|
+
name: 'Total Surplus',
|
|
68
|
+
expression: 'CS + PS',
|
|
69
|
+
inputs: ['CS', 'PS'],
|
|
70
|
+
output: 'TS',
|
|
71
|
+
category: 'surplus',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'deadweight_loss_tax',
|
|
75
|
+
name: 'Deadweight Loss from Tax',
|
|
76
|
+
expression: '0.5 * t * (Q0 - Q1)',
|
|
77
|
+
inputs: ['t', 'Q0', 'Q1'],
|
|
78
|
+
output: 'DWL',
|
|
79
|
+
category: 'surplus',
|
|
80
|
+
notes: 't = tax amount, Q0 = original quantity, Q1 = new quantity',
|
|
81
|
+
},
|
|
82
|
+
// === ELASTICITY ===
|
|
83
|
+
{
|
|
84
|
+
id: 'price_elasticity_demand_point',
|
|
85
|
+
name: 'Point Price Elasticity of Demand',
|
|
86
|
+
expression: '(dQ/dP) * (P / Q)',
|
|
87
|
+
inputs: ['dQ/dP', 'P', 'Q'],
|
|
88
|
+
output: 'Ed',
|
|
89
|
+
category: 'elasticity',
|
|
90
|
+
notes: 'For linear demand: Ed = -b * (P/Q)',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'price_elasticity_demand_midpoint',
|
|
94
|
+
name: 'Midpoint Price Elasticity of Demand',
|
|
95
|
+
expression: '((Q2 - Q1) / ((Q2 + Q1) / 2)) / ((P2 - P1) / ((P2 + P1) / 2))',
|
|
96
|
+
inputs: ['Q1', 'Q2', 'P1', 'P2'],
|
|
97
|
+
output: 'Ed',
|
|
98
|
+
category: 'elasticity',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'tax_burden_consumer',
|
|
102
|
+
name: 'Tax Burden on Consumers',
|
|
103
|
+
expression: 'Es / (Es - Ed)',
|
|
104
|
+
inputs: ['Es', 'Ed'],
|
|
105
|
+
output: 'Consumer Share',
|
|
106
|
+
category: 'elasticity',
|
|
107
|
+
notes: 'Share of tax burden paid by consumers',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'tax_burden_producer',
|
|
111
|
+
name: 'Tax Burden on Producers',
|
|
112
|
+
expression: '-Ed / (Es - Ed)',
|
|
113
|
+
inputs: ['Es', 'Ed'],
|
|
114
|
+
output: 'Producer Share',
|
|
115
|
+
category: 'elasticity',
|
|
116
|
+
},
|
|
117
|
+
// === PRODUCTION ===
|
|
118
|
+
{
|
|
119
|
+
id: 'cobb_douglas_production',
|
|
120
|
+
name: 'Cobb-Douglas Production Function',
|
|
121
|
+
expression: 'A * K^alpha * L^(1 - alpha)',
|
|
122
|
+
inputs: ['A', 'K', 'L', 'alpha'],
|
|
123
|
+
output: 'Y',
|
|
124
|
+
category: 'production',
|
|
125
|
+
notes: 'A = TFP, K = capital, L = labor, alpha = capital share',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: 'marginal_product_labor',
|
|
129
|
+
name: 'Marginal Product of Labor (Cobb-Douglas)',
|
|
130
|
+
expression: '(1 - alpha) * A * K^alpha * L^(-alpha)',
|
|
131
|
+
inputs: ['A', 'K', 'L', 'alpha'],
|
|
132
|
+
output: 'MPL',
|
|
133
|
+
category: 'production',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: 'marginal_product_capital',
|
|
137
|
+
name: 'Marginal Product of Capital (Cobb-Douglas)',
|
|
138
|
+
expression: 'alpha * A * K^(alpha - 1) * L^(1 - alpha)',
|
|
139
|
+
inputs: ['A', 'K', 'L', 'alpha'],
|
|
140
|
+
output: 'MPK',
|
|
141
|
+
category: 'production',
|
|
142
|
+
},
|
|
143
|
+
// === UTILITY ===
|
|
144
|
+
{
|
|
145
|
+
id: 'cobb_douglas_utility',
|
|
146
|
+
name: 'Cobb-Douglas Utility',
|
|
147
|
+
expression: 'x^a * y^(1 - a)',
|
|
148
|
+
inputs: ['x', 'y', 'a'],
|
|
149
|
+
output: 'U',
|
|
150
|
+
category: 'utility',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: 'budget_constraint',
|
|
154
|
+
name: 'Budget Constraint',
|
|
155
|
+
expression: 'Px * x + Py * y = M',
|
|
156
|
+
inputs: ['Px', 'Py', 'x', 'y', 'M'],
|
|
157
|
+
output: 'constraint',
|
|
158
|
+
category: 'utility',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: 'mrs_cobb_douglas',
|
|
162
|
+
name: 'MRS (Cobb-Douglas)',
|
|
163
|
+
expression: '(a / (1 - a)) * (y / x)',
|
|
164
|
+
inputs: ['a', 'x', 'y'],
|
|
165
|
+
output: 'MRS',
|
|
166
|
+
category: 'utility',
|
|
167
|
+
notes: 'Marginal Rate of Substitution',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: 'optimal_x_cobb_douglas',
|
|
171
|
+
name: 'Optimal x (Cobb-Douglas)',
|
|
172
|
+
expression: 'a * M / Px',
|
|
173
|
+
inputs: ['a', 'M', 'Px'],
|
|
174
|
+
output: 'x*',
|
|
175
|
+
category: 'utility',
|
|
176
|
+
},
|
|
177
|
+
// === COST ===
|
|
178
|
+
{
|
|
179
|
+
id: 'total_cost',
|
|
180
|
+
name: 'Total Cost',
|
|
181
|
+
expression: 'FC + VC',
|
|
182
|
+
inputs: ['FC', 'VC'],
|
|
183
|
+
output: 'TC',
|
|
184
|
+
category: 'cost',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
id: 'average_total_cost',
|
|
188
|
+
name: 'Average Total Cost',
|
|
189
|
+
expression: 'TC / Q',
|
|
190
|
+
inputs: ['TC', 'Q'],
|
|
191
|
+
output: 'ATC',
|
|
192
|
+
category: 'cost',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'marginal_cost',
|
|
196
|
+
name: 'Marginal Cost',
|
|
197
|
+
expression: 'dTC / dQ',
|
|
198
|
+
inputs: ['TC', 'Q'],
|
|
199
|
+
output: 'MC',
|
|
200
|
+
category: 'cost',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
id: 'profit_maximization',
|
|
204
|
+
name: 'Profit Maximization Condition',
|
|
205
|
+
expression: 'MR = MC',
|
|
206
|
+
inputs: ['MR', 'MC'],
|
|
207
|
+
output: 'condition',
|
|
208
|
+
category: 'cost',
|
|
209
|
+
notes: 'Firm produces where marginal revenue equals marginal cost',
|
|
210
|
+
},
|
|
211
|
+
// === MACRO ===
|
|
212
|
+
{
|
|
213
|
+
id: 'is_curve',
|
|
214
|
+
name: 'IS Curve',
|
|
215
|
+
expression: 'Y = C(Y - T) + I(r) + G',
|
|
216
|
+
inputs: ['C', 'Y', 'T', 'I', 'r', 'G'],
|
|
217
|
+
output: 'Y',
|
|
218
|
+
category: 'macro',
|
|
219
|
+
notes: 'Goods market equilibrium',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
id: 'lm_curve',
|
|
223
|
+
name: 'LM Curve',
|
|
224
|
+
expression: 'M/P = L(r, Y)',
|
|
225
|
+
inputs: ['M', 'P', 'r', 'Y'],
|
|
226
|
+
output: 'equilibrium',
|
|
227
|
+
category: 'macro',
|
|
228
|
+
notes: 'Money market equilibrium',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
id: 'solow_capital_accumulation',
|
|
232
|
+
name: 'Solow Capital Accumulation',
|
|
233
|
+
expression: 's * f(k) - (n + delta) * k',
|
|
234
|
+
inputs: ['s', 'k', 'n', 'delta'],
|
|
235
|
+
output: 'dk/dt',
|
|
236
|
+
category: 'macro',
|
|
237
|
+
notes: 's = saving rate, n = population growth, delta = depreciation',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
id: 'solow_steady_state',
|
|
241
|
+
name: 'Solow Steady State',
|
|
242
|
+
expression: 's * f(k*) = (n + delta) * k*',
|
|
243
|
+
inputs: ['s', 'n', 'delta'],
|
|
244
|
+
output: 'k*',
|
|
245
|
+
category: 'macro',
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
/**
|
|
249
|
+
* Get formula by ID
|
|
250
|
+
*/
|
|
251
|
+
export function getFormula(id) {
|
|
252
|
+
return economicFormulas.find((f) => f.id === id);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Get formulas by category
|
|
256
|
+
*/
|
|
257
|
+
export function getFormulasByCategory(category) {
|
|
258
|
+
return economicFormulas.filter((f) => f.category === category);
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=formulas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formulas.js","sourceRoot":"","sources":["../../src/economics/formulas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,sBAAsB;IACtB;QACE,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE,WAAW;QACvB,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QACvB,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,6DAA6D;KACrE;IACD;QACE,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE,WAAW;QACvB,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QACvB,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,iCAAiC;KACzC;IACD;QACE,EAAE,EAAE,mBAAmB;QACvB,IAAI,EAAE,4BAA4B;QAClC,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QAC5B,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,aAAa;QACvB,KAAK,EAAE,oDAAoD;KAC5D;IACD;QACE,EAAE,EAAE,sBAAsB;QAC1B,IAAI,EAAE,+BAA+B;QACrC,UAAU,EAAE,2BAA2B;QACvC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;QAC5B,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,aAAa;KACxB;IAED,kBAAkB;IAClB;QACE,EAAE,EAAE,yBAAyB;QAC7B,IAAI,EAAE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F;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Economics Module
|
|
3
|
+
*
|
|
4
|
+
* Economic formulas, validators, and constants.
|
|
5
|
+
*/
|
|
6
|
+
export { economicFormulas, getFormula, getFormulasByCategory } from './formulas.js';
|
|
7
|
+
export { validateEconomicConstraints } from './validators.js';
|
|
8
|
+
export { ECONOMIC_CONSTANTS } from './constants.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/economics/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Economics Module
|
|
3
|
+
*
|
|
4
|
+
* Economic formulas, validators, and constants.
|
|
5
|
+
*/
|
|
6
|
+
export { economicFormulas, getFormula, getFormulasByCategory } from './formulas.js';
|
|
7
|
+
export { validateEconomicConstraints } from './validators.js';
|
|
8
|
+
export { ECONOMIC_CONSTANTS } from './constants.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|