@pd4castr/cli 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.
- package/dist/index.js +51 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -88,6 +88,12 @@ var sensitivitySchema = z.object({
|
|
|
88
88
|
name: z.string(),
|
|
89
89
|
query: z.string()
|
|
90
90
|
});
|
|
91
|
+
var inputAggregationSchema = z.object({
|
|
92
|
+
name: z.string(),
|
|
93
|
+
query: z.string(),
|
|
94
|
+
description: z.string().optional().default(""),
|
|
95
|
+
colours: z.array(z.string()).optional().default([])
|
|
96
|
+
});
|
|
91
97
|
var CONFIG_WARNING_KEY = "// WARNING: DO NOT MODIFY THESE SYSTEM MANAGED VALUES";
|
|
92
98
|
var projectConfigSchema = z.object({
|
|
93
99
|
name: z.string(),
|
|
@@ -95,14 +101,16 @@ var projectConfigSchema = z.object({
|
|
|
95
101
|
"price"
|
|
96
102
|
]),
|
|
97
103
|
timeHorizon: z.enum([
|
|
98
|
-
"actual",
|
|
99
104
|
"day_ahead",
|
|
100
105
|
"week_ahead",
|
|
101
106
|
"quarterly"
|
|
102
107
|
]),
|
|
103
108
|
displayTimezone: z.string().refine(isIanaTimeZone, "invalid IANA time zone").optional().default("Australia/Brisbane"),
|
|
104
109
|
metadata: z.record(z.string(), z.any()).optional(),
|
|
110
|
+
public: z.boolean().optional().default(false),
|
|
111
|
+
runDatetimeQuery: z.string().optional().nullable().default(null),
|
|
105
112
|
inputs: z.array(modelInputSchema),
|
|
113
|
+
inputAggregations: z.array(inputAggregationSchema).optional().default([]),
|
|
106
114
|
outputs: z.array(modelOutputSchema),
|
|
107
115
|
sensitivities: z.array(sensitivitySchema).optional().default([]),
|
|
108
116
|
[CONFIG_WARNING_KEY]: z.string().optional().default(""),
|
|
@@ -798,6 +806,8 @@ import path9 from "path";
|
|
|
798
806
|
async function getModelConfigFromProjectConfig(ctx) {
|
|
799
807
|
const inputs = await getInputsWithInlinedSQL(ctx);
|
|
800
808
|
const sensitivities = await getSensitivitiesWithInlinedSQL(ctx);
|
|
809
|
+
const inputAggregations = await getInputAggregationsWithInlinedSQL(ctx);
|
|
810
|
+
const runDatetimeQuery = await getrunDatetimeQuerySQL(ctx);
|
|
801
811
|
const { $$id, $$modelGroupID, $$revision, $$dockerImage, ...config } = ctx.config;
|
|
802
812
|
return {
|
|
803
813
|
...config,
|
|
@@ -806,7 +816,9 @@ async function getModelConfigFromProjectConfig(ctx) {
|
|
|
806
816
|
revision: $$revision ?? 0,
|
|
807
817
|
dockerImage: $$dockerImage,
|
|
808
818
|
inputs,
|
|
809
|
-
sensitivities
|
|
819
|
+
sensitivities,
|
|
820
|
+
inputAggregations,
|
|
821
|
+
runDatetimeQuery
|
|
810
822
|
};
|
|
811
823
|
}
|
|
812
824
|
__name(getModelConfigFromProjectConfig, "getModelConfigFromProjectConfig");
|
|
@@ -860,6 +872,36 @@ async function getSensitivitiesWithInlinedSQL(ctx) {
|
|
|
860
872
|
return sensitivitiesWithSQL;
|
|
861
873
|
}
|
|
862
874
|
__name(getSensitivitiesWithInlinedSQL, "getSensitivitiesWithInlinedSQL");
|
|
875
|
+
async function getInputAggregationsWithInlinedSQL(ctx) {
|
|
876
|
+
const inputAggregationsWithSQL = [];
|
|
877
|
+
for (const inputAggregation of ctx.config.inputAggregations) {
|
|
878
|
+
const queryPath = path9.resolve(ctx.projectRoot, inputAggregation.query);
|
|
879
|
+
try {
|
|
880
|
+
const sql = await fs8.readFile(queryPath, "utf8");
|
|
881
|
+
inputAggregationsWithSQL.push({
|
|
882
|
+
...inputAggregation,
|
|
883
|
+
query: sql
|
|
884
|
+
});
|
|
885
|
+
} catch {
|
|
886
|
+
throw new Error(`Input aggregation query file not found (${inputAggregation.query})`);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
return inputAggregationsWithSQL;
|
|
890
|
+
}
|
|
891
|
+
__name(getInputAggregationsWithInlinedSQL, "getInputAggregationsWithInlinedSQL");
|
|
892
|
+
async function getrunDatetimeQuerySQL(ctx) {
|
|
893
|
+
if (!ctx.config.runDatetimeQuery) {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
const queryPath = path9.resolve(ctx.projectRoot, ctx.config.runDatetimeQuery);
|
|
897
|
+
try {
|
|
898
|
+
const sql = await fs8.readFile(queryPath, "utf8");
|
|
899
|
+
return sql;
|
|
900
|
+
} catch {
|
|
901
|
+
throw new Error(`Run datetime query file not found (${ctx.config.runDatetimeQuery})`);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
__name(getrunDatetimeQuerySQL, "getrunDatetimeQuerySQL");
|
|
863
905
|
|
|
864
906
|
// src/utils/log-empty-line.ts
|
|
865
907
|
function logEmptyLine() {
|
|
@@ -883,10 +925,15 @@ function getModelSummaryLines(ctx) {
|
|
|
883
925
|
` ${chalk2.bold("Revision:")} ${ctx.config.$$revision}`,
|
|
884
926
|
` ${chalk2.bold("Forecast variable:")} ${ctx.config.forecastVariable}`,
|
|
885
927
|
` ${chalk2.bold("Time horizon:")} ${ctx.config.timeHorizon}`,
|
|
928
|
+
` ${chalk2.bold("Public:")} ${ctx.config.public}`,
|
|
886
929
|
` ${chalk2.bold("Inputs:")}`,
|
|
887
930
|
...ctx.config.inputs.map((input2) => ` \u2022 ${input2.key} - ${getInputType(input2)}`),
|
|
888
931
|
` ${chalk2.bold("Outputs:")}`,
|
|
889
932
|
...ctx.config.outputs.map((output) => ` \u2022 ${output.name} - ${output.type}`),
|
|
933
|
+
...ctx.config.inputAggregations.length > 0 ? [
|
|
934
|
+
` ${chalk2.bold("Input aggregations:")}`,
|
|
935
|
+
...ctx.config.inputAggregations.map((agg) => ` \u2022 ${agg.name}`)
|
|
936
|
+
] : [],
|
|
890
937
|
...ctx.config.sensitivities.length > 0 ? [
|
|
891
938
|
` ${chalk2.bold("Sensitivities:")}`,
|
|
892
939
|
...ctx.config.sensitivities.map((s) => ` \u2022 ${s.name}`)
|
|
@@ -1642,7 +1689,7 @@ import { Command } from "commander";
|
|
|
1642
1689
|
// package.json
|
|
1643
1690
|
var package_default = {
|
|
1644
1691
|
name: "@pd4castr/cli",
|
|
1645
|
-
version: "1.
|
|
1692
|
+
version: "1.4.1",
|
|
1646
1693
|
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
1647
1694
|
license: "UNLICENSED",
|
|
1648
1695
|
main: "dist/index.js",
|
|
@@ -1659,7 +1706,7 @@ var package_default = {
|
|
|
1659
1706
|
scripts: {
|
|
1660
1707
|
build: "tsup",
|
|
1661
1708
|
dev: "tsup --watch",
|
|
1662
|
-
|
|
1709
|
+
pd4castr: "node dist/index.js",
|
|
1663
1710
|
release: "semantic-release -e semantic-release-monorepo",
|
|
1664
1711
|
format: "prettier --write .",
|
|
1665
1712
|
lint: "eslint .",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pd4castr/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "CLI tool for creating, testing, and publishing pd4castr models",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsup",
|
|
19
19
|
"dev": "tsup --watch",
|
|
20
|
-
"
|
|
20
|
+
"pd4castr": "node dist/index.js",
|
|
21
21
|
"release": "semantic-release -e semantic-release-monorepo",
|
|
22
22
|
"format": "prettier --write .",
|
|
23
23
|
"lint": "eslint .",
|