@pd4castr/cli 1.5.0 → 1.7.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/dist/index.js +79 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,6 +94,62 @@ var inputAggregationSchema = z.object({
|
|
|
94
94
|
description: z.string().optional().default(""),
|
|
95
95
|
colours: z.array(z.string()).optional().default([])
|
|
96
96
|
});
|
|
97
|
+
var performanceMetricsOptionValueEntrySchema = z.object({
|
|
98
|
+
label: z.string(),
|
|
99
|
+
key: z.string()
|
|
100
|
+
});
|
|
101
|
+
var performanceMetricsSelectOptionSchema = z.object({
|
|
102
|
+
label: z.string(),
|
|
103
|
+
key: z.string(),
|
|
104
|
+
type: z.literal("select"),
|
|
105
|
+
values: z.array(performanceMetricsOptionValueEntrySchema).min(1),
|
|
106
|
+
defaultValue: z.string().optional()
|
|
107
|
+
});
|
|
108
|
+
var performanceMetricsNumberOptionSchema = z.object({
|
|
109
|
+
label: z.string(),
|
|
110
|
+
key: z.string(),
|
|
111
|
+
type: z.literal("number"),
|
|
112
|
+
defaultValue: z.number().optional()
|
|
113
|
+
});
|
|
114
|
+
var performanceMetricsDateOptionSchema = z.object({
|
|
115
|
+
label: z.string(),
|
|
116
|
+
key: z.string(),
|
|
117
|
+
type: z.literal("date"),
|
|
118
|
+
defaultValue: z.string().optional(),
|
|
119
|
+
maxDate: z.string().optional()
|
|
120
|
+
});
|
|
121
|
+
var performanceMetricsBooleanOptionSchema = z.object({
|
|
122
|
+
label: z.string(),
|
|
123
|
+
key: z.string(),
|
|
124
|
+
type: z.literal("boolean"),
|
|
125
|
+
defaultValue: z.boolean().optional()
|
|
126
|
+
});
|
|
127
|
+
var performanceMetricsRangeInputOptionSchema = z.discriminatedUnion("type", [
|
|
128
|
+
performanceMetricsSelectOptionSchema,
|
|
129
|
+
performanceMetricsNumberOptionSchema,
|
|
130
|
+
performanceMetricsDateOptionSchema
|
|
131
|
+
]);
|
|
132
|
+
var performanceMetricsRangeOptionSchema = z.object({
|
|
133
|
+
label: z.string(),
|
|
134
|
+
key: z.string(),
|
|
135
|
+
type: z.literal("range"),
|
|
136
|
+
inputs: z.tuple([
|
|
137
|
+
performanceMetricsRangeInputOptionSchema,
|
|
138
|
+
performanceMetricsRangeInputOptionSchema
|
|
139
|
+
])
|
|
140
|
+
});
|
|
141
|
+
var performanceMetricsOptionSchema = z.discriminatedUnion("type", [
|
|
142
|
+
performanceMetricsSelectOptionSchema,
|
|
143
|
+
performanceMetricsNumberOptionSchema,
|
|
144
|
+
performanceMetricsDateOptionSchema,
|
|
145
|
+
performanceMetricsBooleanOptionSchema,
|
|
146
|
+
performanceMetricsRangeOptionSchema
|
|
147
|
+
]);
|
|
148
|
+
var performanceMetricsSchema = z.object({
|
|
149
|
+
options: z.array(performanceMetricsOptionSchema).optional().default([]),
|
|
150
|
+
comparisonModels: z.record(z.string(), z.string()).optional().default({}),
|
|
151
|
+
query: z.string().min(1)
|
|
152
|
+
});
|
|
97
153
|
var CONFIG_WARNING_KEY = "// WARNING: DO NOT MODIFY THESE SYSTEM MANAGED VALUES";
|
|
98
154
|
var projectConfigSchema = z.object({
|
|
99
155
|
name: z.string(),
|
|
@@ -103,7 +159,8 @@ var projectConfigSchema = z.object({
|
|
|
103
159
|
timeHorizon: z.enum([
|
|
104
160
|
"day_ahead",
|
|
105
161
|
"week_ahead",
|
|
106
|
-
"quarterly"
|
|
162
|
+
"quarterly",
|
|
163
|
+
"historical"
|
|
107
164
|
]),
|
|
108
165
|
displayTimezone: z.string().refine(isIanaTimeZone, "invalid IANA time zone").optional().default("Australia/Brisbane"),
|
|
109
166
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
@@ -113,6 +170,7 @@ var projectConfigSchema = z.object({
|
|
|
113
170
|
inputAggregations: z.array(inputAggregationSchema).optional().default([]),
|
|
114
171
|
outputs: z.array(modelOutputSchema),
|
|
115
172
|
sensitivities: z.array(sensitivitySchema).optional().default([]),
|
|
173
|
+
performanceMetrics: performanceMetricsSchema.nullable().optional().default(null),
|
|
116
174
|
[CONFIG_WARNING_KEY]: z.string().optional().default(""),
|
|
117
175
|
$$id: z.string().nullable().optional().default(null),
|
|
118
176
|
$$modelGroupID: z.string().nullable().optional().default(null),
|
|
@@ -810,6 +868,7 @@ async function getModelConfigFromProjectConfig(ctx) {
|
|
|
810
868
|
const sensitivities = await getSensitivitiesWithInlinedSQL(ctx);
|
|
811
869
|
const inputAggregations = await getInputAggregationsWithInlinedSQL(ctx);
|
|
812
870
|
const runDatetimeQuery = await getrunDatetimeQuerySQL(ctx);
|
|
871
|
+
const performanceMetrics = await getPerformanceMetricsWithInlinedSQL(ctx);
|
|
813
872
|
const { $$id, $$modelGroupID, $$revision, $$dockerImage, ...config } = ctx.config;
|
|
814
873
|
return {
|
|
815
874
|
...config,
|
|
@@ -820,7 +879,8 @@ async function getModelConfigFromProjectConfig(ctx) {
|
|
|
820
879
|
inputs,
|
|
821
880
|
sensitivities,
|
|
822
881
|
inputAggregations,
|
|
823
|
-
runDatetimeQuery
|
|
882
|
+
runDatetimeQuery,
|
|
883
|
+
performanceMetrics
|
|
824
884
|
};
|
|
825
885
|
}
|
|
826
886
|
__name(getModelConfigFromProjectConfig, "getModelConfigFromProjectConfig");
|
|
@@ -904,6 +964,22 @@ async function getrunDatetimeQuerySQL(ctx) {
|
|
|
904
964
|
}
|
|
905
965
|
}
|
|
906
966
|
__name(getrunDatetimeQuerySQL, "getrunDatetimeQuerySQL");
|
|
967
|
+
async function getPerformanceMetricsWithInlinedSQL(ctx) {
|
|
968
|
+
if (ctx.config.performanceMetrics === null) {
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
971
|
+
try {
|
|
972
|
+
const queryPath = path9.resolve(ctx.projectRoot, ctx.config.performanceMetrics.query);
|
|
973
|
+
const sql = await fs8.readFile(queryPath, "utf8");
|
|
974
|
+
return {
|
|
975
|
+
...ctx.config.performanceMetrics,
|
|
976
|
+
query: sql
|
|
977
|
+
};
|
|
978
|
+
} catch {
|
|
979
|
+
throw new Error(`Performance metrics query file not found (${ctx.config.performanceMetrics.query})`);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
__name(getPerformanceMetricsWithInlinedSQL, "getPerformanceMetricsWithInlinedSQL");
|
|
907
983
|
|
|
908
984
|
// src/utils/log-empty-line.ts
|
|
909
985
|
function logEmptyLine() {
|
|
@@ -1691,7 +1767,7 @@ import { Command } from "commander";
|
|
|
1691
1767
|
// package.json
|
|
1692
1768
|
var package_default = {
|
|
1693
1769
|
name: "@pd4castr/cli",
|
|
1694
|
-
version: "1.
|
|
1770
|
+
version: "1.7.0",
|
|
1695
1771
|
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
1696
1772
|
license: "UNLICENSED",
|
|
1697
1773
|
main: "dist/index.js",
|