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