yamchart 0.4.8 → 0.4.9
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/{chunk-DMGAHFXP.js → chunk-23E6YT4S.js} +137 -2
- package/dist/chunk-23E6YT4S.js.map +1 -0
- package/dist/{chunk-6PGM2RLB.js → chunk-6XQITSPY.js} +4 -4
- package/dist/{chunk-HKPB7YHA.js → chunk-R7EULFJG.js} +6 -4
- package/dist/chunk-R7EULFJG.js.map +1 -0
- package/dist/{chunk-ZWLCG3KF.js → chunk-UDJXQQKL.js} +3 -3
- package/dist/{connection-utils-RQT2X365.js → connection-utils-U6MCBYCX.js} +4 -4
- package/dist/{describe-ESHPHGUD.js → describe-LTV7YMPM.js} +4 -4
- package/dist/{dev-2Z5XKOIX.js → dev-WS4UALYA.js} +74 -4
- package/dist/dev-WS4UALYA.js.map +1 -0
- package/dist/{dist-A7VMHB26.js → dist-LJOCG7C5.js} +10 -2
- package/dist/index.js +12 -12
- package/dist/public/assets/LoginPage-8kMwzXQY.js +1 -0
- package/dist/public/assets/PublicViewer-CCd0694Q.js +1 -0
- package/dist/public/assets/SetupWizard-FRVXmmVV.js +1 -0
- package/dist/public/assets/ShareManagement-WkjpLgIb.js +1 -0
- package/dist/public/assets/UserManagement-Yir6iim5.js +1 -0
- package/dist/public/assets/echarts-DtOYsfLX.js +69 -0
- package/dist/public/assets/html2canvas.esm-QH1iLAAe.js +22 -0
- package/dist/public/assets/index-BPNqaKrL.js +164 -0
- package/dist/public/assets/{index-DxvctgSd.css → index-DIn_Wjra.css} +1 -1
- package/dist/public/assets/{index.es-C499FQ32.js → index.es-CkGh6XRY.js} +2 -2
- package/dist/public/assets/jspdf.es.min-BllGrT6z.js +170 -0
- package/dist/public/index.html +3 -2
- package/dist/{query-5VJ75PZ2.js → query-J2SD4BID.js} +4 -4
- package/dist/{sample-XO2LUSL4.js → sample-3PF7ZJFO.js} +4 -4
- package/dist/{search-AKDGIJT6.js → search-IUXXHMPL.js} +4 -4
- package/dist/{tables-5INA5OWJ.js → tables-I3WOUJ2I.js} +4 -4
- package/dist/{test-ZZRTZ34Y.js → test-IL3UPLUJ.js} +2 -2
- package/package.json +4 -4
- package/dist/chunk-DMGAHFXP.js.map +0 -1
- package/dist/chunk-HKPB7YHA.js.map +0 -1
- package/dist/dev-2Z5XKOIX.js.map +0 -1
- package/dist/public/assets/index-CySnvaJ-.js +0 -426
- /package/dist/{chunk-6PGM2RLB.js.map → chunk-6XQITSPY.js.map} +0 -0
- /package/dist/{chunk-ZWLCG3KF.js.map → chunk-UDJXQQKL.js.map} +0 -0
- /package/dist/{connection-utils-RQT2X365.js.map → connection-utils-U6MCBYCX.js.map} +0 -0
- /package/dist/{describe-ESHPHGUD.js.map → describe-LTV7YMPM.js.map} +0 -0
- /package/dist/{dist-A7VMHB26.js.map → dist-LJOCG7C5.js.map} +0 -0
- /package/dist/{query-5VJ75PZ2.js.map → query-J2SD4BID.js.map} +0 -0
- /package/dist/{sample-XO2LUSL4.js.map → sample-3PF7ZJFO.js.map} +0 -0
- /package/dist/{search-AKDGIJT6.js.map → search-IUXXHMPL.js.map} +0 -0
- /package/dist/{tables-5INA5OWJ.js.map → tables-I3WOUJ2I.js.map} +0 -0
- /package/dist/{test-ZZRTZ34Y.js.map → test-IL3UPLUJ.js.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadEnvFile,
|
|
3
3
|
validateProject
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6XQITSPY.js";
|
|
5
5
|
import {
|
|
6
6
|
ChartSchema,
|
|
7
7
|
ConnectionSchema,
|
|
8
8
|
DashboardSchema,
|
|
9
9
|
ProjectSchema,
|
|
10
10
|
ScheduleSchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-R7EULFJG.js";
|
|
12
12
|
import {
|
|
13
13
|
AuthDatabase,
|
|
14
14
|
generateSessionToken,
|
|
@@ -33,13 +33,21 @@ import {
|
|
|
33
33
|
QueryCompiler,
|
|
34
34
|
SQLiteConnector,
|
|
35
35
|
SnowflakeConnector,
|
|
36
|
+
computePreviousPeriod,
|
|
36
37
|
createTemplateContext,
|
|
38
|
+
expandCustomDateRange,
|
|
39
|
+
expandDatePreset,
|
|
40
|
+
expandRelativeDateRange,
|
|
41
|
+
formatPeriodLabel,
|
|
42
|
+
isCustomDateRange,
|
|
43
|
+
isDatePreset,
|
|
44
|
+
isRelativeDateRange,
|
|
37
45
|
parseModelMetadata,
|
|
38
46
|
renderTemplate,
|
|
39
47
|
resolveMySQLAuth,
|
|
40
48
|
resolvePostgresAuth,
|
|
41
49
|
resolveSnowflakeAuth
|
|
42
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-23E6YT4S.js";
|
|
43
51
|
import "./chunk-DGUM43GV.js";
|
|
44
52
|
|
|
45
53
|
// src/commands/dev.ts
|
|
@@ -695,6 +703,23 @@ function getUserContext(request) {
|
|
|
695
703
|
...user.attributes
|
|
696
704
|
};
|
|
697
705
|
}
|
|
706
|
+
function buildComparisonResponse(input) {
|
|
707
|
+
const { currentRows, previousRows, valueField, changeType, currentStart, currentEnd, previousStart, previousEnd } = input;
|
|
708
|
+
if (!previousRows.length)
|
|
709
|
+
return null;
|
|
710
|
+
const previousValue = previousRows[0]?.[valueField];
|
|
711
|
+
if (!previousValue || previousValue === 0)
|
|
712
|
+
return null;
|
|
713
|
+
const currentValue = currentRows[0]?.[valueField];
|
|
714
|
+
const change = changeType === "percent_change" ? (currentValue - previousValue) / previousValue * 100 : currentValue - previousValue;
|
|
715
|
+
return {
|
|
716
|
+
previousValue,
|
|
717
|
+
change,
|
|
718
|
+
changeType,
|
|
719
|
+
currentPeriodLabel: formatPeriodLabel(currentStart, currentEnd),
|
|
720
|
+
previousPeriodLabel: formatPeriodLabel(previousStart, previousEnd)
|
|
721
|
+
};
|
|
722
|
+
}
|
|
698
723
|
async function chartRoutes(fastify, options) {
|
|
699
724
|
const { configLoader, queryService } = options;
|
|
700
725
|
fastify.get("/api/charts/:name", async (request, reply) => {
|
|
@@ -722,6 +747,48 @@ async function chartRoutes(fastify, options) {
|
|
|
722
747
|
}
|
|
723
748
|
try {
|
|
724
749
|
const result = await queryService.executeChart(chart, params, getUserContext(request));
|
|
750
|
+
let comparison = void 0;
|
|
751
|
+
if (chart.chart?.type === "kpi" && chart.chart?.comparison?.period === "previous") {
|
|
752
|
+
let startDate = params.start_date;
|
|
753
|
+
let endDate = params.end_date;
|
|
754
|
+
const dateRange = params.date_range;
|
|
755
|
+
if (!startDate || !endDate) {
|
|
756
|
+
if (isRelativeDateRange(params.date_range)) {
|
|
757
|
+
const resolved = expandRelativeDateRange(params.date_range);
|
|
758
|
+
startDate = resolved.start_date;
|
|
759
|
+
endDate = resolved.end_date;
|
|
760
|
+
} else if (isCustomDateRange(params.date_range)) {
|
|
761
|
+
const resolved = expandCustomDateRange(params.date_range);
|
|
762
|
+
startDate = resolved.start_date;
|
|
763
|
+
endDate = resolved.end_date;
|
|
764
|
+
} else if (dateRange && isDatePreset(dateRange)) {
|
|
765
|
+
const resolved = expandDatePreset(dateRange);
|
|
766
|
+
if (resolved) {
|
|
767
|
+
startDate = resolved.start_date;
|
|
768
|
+
endDate = resolved.end_date;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
if (startDate && endDate) {
|
|
773
|
+
const prev = computePreviousPeriod(startDate, endDate, dateRange);
|
|
774
|
+
try {
|
|
775
|
+
const { date_range: _, ...restParams } = params;
|
|
776
|
+
const prevParams = { ...restParams, start_date: prev.start_date, end_date: prev.end_date };
|
|
777
|
+
const prevResult = await queryService.executeChart(chart, prevParams, getUserContext(request));
|
|
778
|
+
comparison = buildComparisonResponse({
|
|
779
|
+
currentRows: result.rows,
|
|
780
|
+
previousRows: prevResult.rows,
|
|
781
|
+
valueField: chart.chart.value?.field ?? "",
|
|
782
|
+
changeType: chart.chart.comparison.type,
|
|
783
|
+
currentStart: startDate,
|
|
784
|
+
currentEnd: endDate,
|
|
785
|
+
previousStart: prev.start_date,
|
|
786
|
+
previousEnd: prev.end_date
|
|
787
|
+
});
|
|
788
|
+
} catch {
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
725
792
|
reply.header("X-Cache", result.cached ? "HIT" : "MISS");
|
|
726
793
|
reply.header("X-Query-Duration-Ms", result.durationMs.toFixed(0));
|
|
727
794
|
const meta = {
|
|
@@ -745,6 +812,9 @@ async function chartRoutes(fastify, options) {
|
|
|
745
812
|
chart: chart.chart
|
|
746
813
|
};
|
|
747
814
|
}
|
|
815
|
+
if (comparison) {
|
|
816
|
+
response.comparison = comparison;
|
|
817
|
+
}
|
|
748
818
|
return response;
|
|
749
819
|
} catch (error2) {
|
|
750
820
|
const message = error2 instanceof Error ? error2.message : "Query execution failed";
|
|
@@ -13720,4 +13790,4 @@ async function runDevServer(projectDir, options) {
|
|
|
13720
13790
|
export {
|
|
13721
13791
|
runDevServer
|
|
13722
13792
|
};
|
|
13723
|
-
//# sourceMappingURL=dev-
|
|
13793
|
+
//# sourceMappingURL=dev-WS4UALYA.js.map
|