yamchart 0.4.15 → 0.4.16
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/{dev-7XROGYXG.js → dev-XC47BMBS.js} +84 -36
- package/dist/dev-XC47BMBS.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/public/assets/{LoginPage-BMdw0UeV.js → LoginPage-OqFkz_X-.js} +1 -1
- package/dist/public/assets/{PublicViewer-CXSc3vVz.js → PublicViewer-bqV4skXX.js} +1 -1
- package/dist/public/assets/{SetupWizard-Bcnury1N.js → SetupWizard-tGgbMxMZ.js} +1 -1
- package/dist/public/assets/{ShareManagement-C9y5c4sK.js → ShareManagement-T_AFVxIm.js} +1 -1
- package/dist/public/assets/{UserManagement-CP7s55yb.js → UserManagement-tXhwFzPz.js} +1 -1
- package/dist/public/assets/{index-BbU_22FF.css → index-CLYPNLML.css} +1 -1
- package/dist/public/assets/{index-B4-bDimp.js → index-zwep09NU.js} +36 -36
- package/dist/public/assets/{index.es-CYXSYXqH.js → index.es-DOh98lYb.js} +1 -1
- package/dist/public/assets/{jspdf.es.min-DGs_y_ZH.js → jspdf.es.min-C599hpR0.js} +3 -3
- package/dist/public/index.html +2 -2
- package/dist/templates/default/docs/yamchart-reference.md +20 -0
- package/package.json +2 -2
- package/dist/dev-7XROGYXG.js.map +0 -1
|
@@ -61,7 +61,7 @@ import fastifyStatic from "@fastify/static";
|
|
|
61
61
|
|
|
62
62
|
// ../server/dist/services/config-loader.js
|
|
63
63
|
import { readFile, readdir, access } from "fs/promises";
|
|
64
|
-
import { join, extname } from "path";
|
|
64
|
+
import { join, extname, relative, dirname } from "path";
|
|
65
65
|
import { parse as parseYaml } from "yaml";
|
|
66
66
|
import { watch } from "chokidar";
|
|
67
67
|
var ConfigLoader = class {
|
|
@@ -69,8 +69,12 @@ var ConfigLoader = class {
|
|
|
69
69
|
project = null;
|
|
70
70
|
connections = /* @__PURE__ */ new Map();
|
|
71
71
|
charts = /* @__PURE__ */ new Map();
|
|
72
|
+
chartFolders = /* @__PURE__ */ new Map();
|
|
73
|
+
chartFilePaths = /* @__PURE__ */ new Map();
|
|
72
74
|
models = /* @__PURE__ */ new Map();
|
|
73
75
|
dashboards = /* @__PURE__ */ new Map();
|
|
76
|
+
dashboardFolders = /* @__PURE__ */ new Map();
|
|
77
|
+
dashboardFilePaths = /* @__PURE__ */ new Map();
|
|
74
78
|
schedules = /* @__PURE__ */ new Map();
|
|
75
79
|
watcher = null;
|
|
76
80
|
onChangeCallbacks = [];
|
|
@@ -78,6 +82,15 @@ var ConfigLoader = class {
|
|
|
78
82
|
this.projectDir = projectDir;
|
|
79
83
|
}
|
|
80
84
|
async load() {
|
|
85
|
+
this.connections.clear();
|
|
86
|
+
this.charts.clear();
|
|
87
|
+
this.chartFolders.clear();
|
|
88
|
+
this.chartFilePaths.clear();
|
|
89
|
+
this.models.clear();
|
|
90
|
+
this.dashboards.clear();
|
|
91
|
+
this.dashboardFolders.clear();
|
|
92
|
+
this.dashboardFilePaths.clear();
|
|
93
|
+
this.schedules.clear();
|
|
81
94
|
await this.loadProject();
|
|
82
95
|
await this.loadConnections();
|
|
83
96
|
await this.loadCharts();
|
|
@@ -129,18 +142,31 @@ var ConfigLoader = class {
|
|
|
129
142
|
} catch {
|
|
130
143
|
return;
|
|
131
144
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
await this.loadChartsFromDir(chartsDir, chartsDir);
|
|
146
|
+
}
|
|
147
|
+
async loadChartsFromDir(dir, baseDir) {
|
|
148
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
149
|
+
for (const entry of entries) {
|
|
150
|
+
const fullPath = join(dir, entry.name);
|
|
151
|
+
if (entry.isDirectory() && dir === baseDir) {
|
|
152
|
+
await this.loadChartsFromDir(fullPath, baseDir);
|
|
153
|
+
} else if (entry.isFile() && (extname(entry.name) === ".yaml" || extname(entry.name) === ".yml")) {
|
|
154
|
+
const content = await readFile(fullPath, "utf-8");
|
|
155
|
+
const parsed = parseYaml(content);
|
|
156
|
+
const result = ChartSchema.safeParse(parsed);
|
|
157
|
+
if (result.success) {
|
|
158
|
+
const name = result.data.name;
|
|
159
|
+
if (this.charts.has(name)) {
|
|
160
|
+
console.warn(`Duplicate chart name "${name}" in ${relative(baseDir, fullPath)} (already loaded from ${relative(baseDir, this.chartFilePaths.get(name))})`);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
this.charts.set(name, result.data);
|
|
164
|
+
this.chartFilePaths.set(name, fullPath);
|
|
165
|
+
const relDir = relative(baseDir, dirname(fullPath)).replace(/\\/g, "/");
|
|
166
|
+
this.chartFolders.set(name, relDir || "");
|
|
167
|
+
} else {
|
|
168
|
+
console.warn(`Invalid chart file ${entry.name}: ${result.error.message}`);
|
|
169
|
+
}
|
|
144
170
|
}
|
|
145
171
|
}
|
|
146
172
|
}
|
|
@@ -181,18 +207,31 @@ var ConfigLoader = class {
|
|
|
181
207
|
} catch {
|
|
182
208
|
return;
|
|
183
209
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
210
|
+
await this.loadDashboardsFromDir(dashboardsDir, dashboardsDir);
|
|
211
|
+
}
|
|
212
|
+
async loadDashboardsFromDir(dir, baseDir) {
|
|
213
|
+
const entries = await readdir(dir, { withFileTypes: true });
|
|
214
|
+
for (const entry of entries) {
|
|
215
|
+
const fullPath = join(dir, entry.name);
|
|
216
|
+
if (entry.isDirectory() && dir === baseDir) {
|
|
217
|
+
await this.loadDashboardsFromDir(fullPath, baseDir);
|
|
218
|
+
} else if (entry.isFile() && (extname(entry.name) === ".yaml" || extname(entry.name) === ".yml")) {
|
|
219
|
+
const content = await readFile(fullPath, "utf-8");
|
|
220
|
+
const parsed = parseYaml(content);
|
|
221
|
+
const result = DashboardSchema.safeParse(parsed);
|
|
222
|
+
if (result.success) {
|
|
223
|
+
const name = result.data.name;
|
|
224
|
+
if (this.dashboards.has(name)) {
|
|
225
|
+
console.warn(`Duplicate dashboard name "${name}" in ${relative(baseDir, fullPath)} (already loaded from ${relative(baseDir, this.dashboardFilePaths.get(name))})`);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
this.dashboards.set(name, result.data);
|
|
229
|
+
this.dashboardFilePaths.set(name, fullPath);
|
|
230
|
+
const relDir = relative(baseDir, dirname(fullPath)).replace(/\\/g, "/");
|
|
231
|
+
this.dashboardFolders.set(name, relDir || "");
|
|
232
|
+
} else {
|
|
233
|
+
console.warn(`Invalid dashboard file ${entry.name}: ${result.error.message}`);
|
|
234
|
+
}
|
|
196
235
|
}
|
|
197
236
|
}
|
|
198
237
|
}
|
|
@@ -252,11 +291,6 @@ var ConfigLoader = class {
|
|
|
252
291
|
}
|
|
253
292
|
async reload() {
|
|
254
293
|
try {
|
|
255
|
-
this.connections.clear();
|
|
256
|
-
this.charts.clear();
|
|
257
|
-
this.models.clear();
|
|
258
|
-
this.dashboards.clear();
|
|
259
|
-
this.schedules.clear();
|
|
260
294
|
await this.load();
|
|
261
295
|
for (const callback of this.onChangeCallbacks) {
|
|
262
296
|
callback();
|
|
@@ -292,6 +326,12 @@ var ConfigLoader = class {
|
|
|
292
326
|
getChartByName(name) {
|
|
293
327
|
return this.charts.get(name);
|
|
294
328
|
}
|
|
329
|
+
getChartFolder(name) {
|
|
330
|
+
return this.chartFolders.get(name) ?? "";
|
|
331
|
+
}
|
|
332
|
+
getChartFilePath(name) {
|
|
333
|
+
return this.chartFilePaths.get(name);
|
|
334
|
+
}
|
|
295
335
|
getModels() {
|
|
296
336
|
return Array.from(this.models.values());
|
|
297
337
|
}
|
|
@@ -315,6 +355,12 @@ var ConfigLoader = class {
|
|
|
315
355
|
getDashboardByName(name) {
|
|
316
356
|
return this.dashboards.get(name);
|
|
317
357
|
}
|
|
358
|
+
getDashboardFolder(name) {
|
|
359
|
+
return this.dashboardFolders.get(name) ?? "";
|
|
360
|
+
}
|
|
361
|
+
getDashboardFilePath(name) {
|
|
362
|
+
return this.dashboardFilePaths.get(name);
|
|
363
|
+
}
|
|
318
364
|
getSchedules() {
|
|
319
365
|
return Array.from(this.schedules.values());
|
|
320
366
|
}
|
|
@@ -646,7 +692,8 @@ async function configRoutes(fastify, options) {
|
|
|
646
692
|
name: c.name,
|
|
647
693
|
title: c.title,
|
|
648
694
|
description: c.description,
|
|
649
|
-
type: c.chart.type
|
|
695
|
+
type: c.chart.type,
|
|
696
|
+
folder: configLoader.getChartFolder(c.name)
|
|
650
697
|
})),
|
|
651
698
|
connections: connections.map((c) => ({
|
|
652
699
|
name: c.name,
|
|
@@ -906,7 +953,8 @@ async function dashboardRoutes(fastify, options) {
|
|
|
906
953
|
return dashboards.map((d) => ({
|
|
907
954
|
name: d.name,
|
|
908
955
|
title: d.title,
|
|
909
|
-
description: d.description
|
|
956
|
+
description: d.description,
|
|
957
|
+
folder: configLoader.getDashboardFolder(d.name)
|
|
910
958
|
}));
|
|
911
959
|
});
|
|
912
960
|
fastify.get("/api/dashboards/:id", async (request, reply) => {
|
|
@@ -947,7 +995,7 @@ async function dashboardRoutes(fastify, options) {
|
|
|
947
995
|
}
|
|
948
996
|
updated = { ...dashboard, layout };
|
|
949
997
|
}
|
|
950
|
-
const filePath = join3(projectDir, "dashboards", `${id}.yaml`);
|
|
998
|
+
const filePath = configLoader.getDashboardFilePath(id) ?? join3(projectDir, "dashboards", `${id}.yaml`);
|
|
951
999
|
await writeFile(filePath, stringifyYaml(updated));
|
|
952
1000
|
await configLoader.load();
|
|
953
1001
|
const commitMessage = message || `Update ${dashboard.title} layout`;
|
|
@@ -13445,10 +13493,10 @@ data: ${data}
|
|
|
13445
13493
|
}
|
|
13446
13494
|
|
|
13447
13495
|
// ../server/dist/server.js
|
|
13448
|
-
import { join as join4, dirname } from "path";
|
|
13496
|
+
import { join as join4, dirname as dirname2 } from "path";
|
|
13449
13497
|
import { fileURLToPath } from "url";
|
|
13450
13498
|
import { access as access2, readFile as readFile2 } from "fs/promises";
|
|
13451
|
-
var __dirname =
|
|
13499
|
+
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
13452
13500
|
var packageJsonPath = join4(__dirname, "..", "package.json");
|
|
13453
13501
|
var packageJson = JSON.parse(await readFile2(packageJsonPath, "utf-8"));
|
|
13454
13502
|
var VERSION = packageJson.version;
|
|
@@ -13790,4 +13838,4 @@ async function runDevServer(projectDir, options) {
|
|
|
13790
13838
|
export {
|
|
13791
13839
|
runDevServer
|
|
13792
13840
|
};
|
|
13793
|
-
//# sourceMappingURL=dev-
|
|
13841
|
+
//# sourceMappingURL=dev-XC47BMBS.js.map
|