@runtimescope/collector 0.9.1 → 0.9.2
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-HZWALDZM.js → chunk-GENCCHYK.js} +162 -8
- package/dist/chunk-GENCCHYK.js.map +1 -0
- package/dist/chunk-UP2VWCW5.js +38 -0
- package/dist/chunk-UP2VWCW5.js.map +1 -0
- package/dist/dashboard.d.ts +1 -0
- package/dist/dashboard.js +145 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/excel-3DUFQWCD.js +64818 -0
- package/dist/excel-3DUFQWCD.js.map +1 -0
- package/dist/index.d.ts +87 -1
- package/dist/index.js +79 -3
- package/dist/index.js.map +1 -1
- package/dist/standalone.js +2 -1
- package/dist/standalone.js.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-HZWALDZM.js.map +0 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-UP2VWCW5.js";
|
|
7
4
|
|
|
8
5
|
// src/ring-buffer.ts
|
|
9
6
|
var RingBuffer = class {
|
|
@@ -2757,6 +2754,41 @@ function createPmRouter(pmStore, discovery, helpers, broadcastDevServer) {
|
|
|
2757
2754
|
});
|
|
2758
2755
|
res.end(csv);
|
|
2759
2756
|
});
|
|
2757
|
+
route("GET", "/api/pm/capex-report/:projectId", async (_req, res, params) => {
|
|
2758
|
+
const projectId = params.get("projectId");
|
|
2759
|
+
const startDate = params.get("start_date") ?? void 0;
|
|
2760
|
+
const endDate = params.get("end_date") ?? void 0;
|
|
2761
|
+
try {
|
|
2762
|
+
const buffer = await pmStore.exportCapexXlsx(projectId, { startDate, endDate });
|
|
2763
|
+
res.writeHead(200, {
|
|
2764
|
+
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2765
|
+
"Content-Disposition": `attachment; filename="capex-${projectId}.xlsx"`
|
|
2766
|
+
});
|
|
2767
|
+
res.end(buffer);
|
|
2768
|
+
} catch {
|
|
2769
|
+
const csv = pmStore.exportCapexCsv(projectId, { startDate, endDate });
|
|
2770
|
+
res.writeHead(200, {
|
|
2771
|
+
"Content-Type": "text/csv",
|
|
2772
|
+
"Content-Disposition": `attachment; filename="capex-${projectId}.csv"`
|
|
2773
|
+
});
|
|
2774
|
+
res.end(csv);
|
|
2775
|
+
}
|
|
2776
|
+
});
|
|
2777
|
+
route("GET", "/api/pm/capex-report-all", async (_req, res, params) => {
|
|
2778
|
+
const startDate = params.get("start_date") ?? void 0;
|
|
2779
|
+
const endDate = params.get("end_date") ?? void 0;
|
|
2780
|
+
const category = params.get("category") ?? void 0;
|
|
2781
|
+
try {
|
|
2782
|
+
const buffer = await pmStore.exportCapexXlsxAll({ startDate, endDate, category });
|
|
2783
|
+
res.writeHead(200, {
|
|
2784
|
+
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2785
|
+
"Content-Disposition": 'attachment; filename="capex-all-projects.xlsx"'
|
|
2786
|
+
});
|
|
2787
|
+
res.end(buffer);
|
|
2788
|
+
} catch (err) {
|
|
2789
|
+
helpers.json(res, { error: err.message }, 500);
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2760
2792
|
return {
|
|
2761
2793
|
match(method, pathname) {
|
|
2762
2794
|
const pathSegments = pathname.split("/");
|
|
@@ -4345,6 +4377,129 @@ var PmStore = class {
|
|
|
4345
4377
|
});
|
|
4346
4378
|
return [headers.join(","), ...rows].join("\n");
|
|
4347
4379
|
}
|
|
4380
|
+
async exportCapexXlsx(projectId, opts) {
|
|
4381
|
+
const ExcelJS = await import("./excel-3DUFQWCD.js");
|
|
4382
|
+
const workbook = new ExcelJS.Workbook();
|
|
4383
|
+
const project = this.getProject(projectId);
|
|
4384
|
+
const summary = this.getCapexSummary(projectId, opts);
|
|
4385
|
+
const entries = this.listCapexEntries(projectId, { month: opts?.startDate });
|
|
4386
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
4387
|
+
for (const entry of entries) {
|
|
4388
|
+
if (!sessions.has(entry.sessionId)) {
|
|
4389
|
+
const s = this.getSession(entry.sessionId);
|
|
4390
|
+
if (s) sessions.set(entry.sessionId, s);
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
const summarySheet = workbook.addWorksheet("Summary");
|
|
4394
|
+
const summaryData = [
|
|
4395
|
+
["Project", project?.name ?? projectId],
|
|
4396
|
+
["Phase", project?.phase ?? ""],
|
|
4397
|
+
["Status", project?.projectStatus ?? ""],
|
|
4398
|
+
["Total Active Hours", (summary.totalActiveMinutes / 60).toFixed(2)],
|
|
4399
|
+
["Total Cost", `$${(summary.totalCostMicrodollars / 1e6).toFixed(2)}`],
|
|
4400
|
+
["Capitalizable", `$${(summary.capitalizableCostMicrodollars / 1e6).toFixed(2)}`],
|
|
4401
|
+
["Expensed", `$${(summary.expensedCostMicrodollars / 1e6).toFixed(2)}`],
|
|
4402
|
+
["Sessions", String(summary.totalSessions)],
|
|
4403
|
+
["Confirmed", `${summary.confirmedCount}/${summary.totalSessions}`]
|
|
4404
|
+
];
|
|
4405
|
+
summaryData.forEach(([field, value]) => {
|
|
4406
|
+
const row = summarySheet.addRow([field, value]);
|
|
4407
|
+
row.getCell(1).font = { bold: true };
|
|
4408
|
+
});
|
|
4409
|
+
summarySheet.getColumn(1).width = 20;
|
|
4410
|
+
summarySheet.getColumn(2).width = 30;
|
|
4411
|
+
const detailSheet = workbook.addWorksheet("Daily Detail");
|
|
4412
|
+
detailSheet.addRow(["Date", "Session", "Model", "Active Hours", "Cost (USD)", "Classification", "Work Type", "Confirmed", "Notes"]);
|
|
4413
|
+
detailSheet.getRow(1).font = { bold: true };
|
|
4414
|
+
for (const e of entries) {
|
|
4415
|
+
const s = sessions.get(e.sessionId);
|
|
4416
|
+
const date = s?.startedAt ? new Date(s.startedAt).toISOString().split("T")[0] : e.period;
|
|
4417
|
+
detailSheet.addRow([
|
|
4418
|
+
date,
|
|
4419
|
+
s?.slug ?? e.sessionId.slice(0, 12),
|
|
4420
|
+
s?.model ?? "",
|
|
4421
|
+
Number((e.activeMinutes / 60).toFixed(2)),
|
|
4422
|
+
Number((e.costMicrodollars / 1e6).toFixed(4)),
|
|
4423
|
+
e.classification,
|
|
4424
|
+
e.workType ?? "",
|
|
4425
|
+
e.confirmed ? "Yes" : "No",
|
|
4426
|
+
e.notes ?? ""
|
|
4427
|
+
]);
|
|
4428
|
+
}
|
|
4429
|
+
detailSheet.columns.forEach((col) => {
|
|
4430
|
+
col.width = 16;
|
|
4431
|
+
});
|
|
4432
|
+
detailSheet.getColumn(1).width = 12;
|
|
4433
|
+
detailSheet.getColumn(2).width = 24;
|
|
4434
|
+
const monthlySheet = workbook.addWorksheet("Monthly Totals");
|
|
4435
|
+
monthlySheet.addRow(["Period", "Active Hours", "Capitalizable ($)", "Expensed ($)", "Total ($)"]);
|
|
4436
|
+
monthlySheet.getRow(1).font = { bold: true };
|
|
4437
|
+
for (const m of summary.byMonth) {
|
|
4438
|
+
monthlySheet.addRow([
|
|
4439
|
+
m.period,
|
|
4440
|
+
Number((m.activeMinutes / 60).toFixed(2)),
|
|
4441
|
+
Number((m.capitalizable / 1e6).toFixed(2)),
|
|
4442
|
+
Number((m.expensed / 1e6).toFixed(2)),
|
|
4443
|
+
Number(((m.capitalizable + m.expensed) / 1e6).toFixed(2))
|
|
4444
|
+
]);
|
|
4445
|
+
}
|
|
4446
|
+
monthlySheet.columns.forEach((col) => {
|
|
4447
|
+
col.width = 18;
|
|
4448
|
+
});
|
|
4449
|
+
return Buffer.from(await workbook.xlsx.writeBuffer());
|
|
4450
|
+
}
|
|
4451
|
+
async exportCapexXlsxAll(opts) {
|
|
4452
|
+
const ExcelJS = await import("./excel-3DUFQWCD.js");
|
|
4453
|
+
const workbook = new ExcelJS.Workbook();
|
|
4454
|
+
let projects = this.listProjects();
|
|
4455
|
+
if (opts?.category) {
|
|
4456
|
+
projects = projects.filter((p) => p.category === opts.category);
|
|
4457
|
+
}
|
|
4458
|
+
const overviewSheet = workbook.addWorksheet("Overview");
|
|
4459
|
+
overviewSheet.addRow(["Project", "Category", "Phase", "Total Hours", "Capitalizable ($)", "Expensed ($)", "Total ($)"]);
|
|
4460
|
+
overviewSheet.getRow(1).font = { bold: true };
|
|
4461
|
+
for (const p of projects) {
|
|
4462
|
+
const summary = this.getCapexSummary(p.id, opts);
|
|
4463
|
+
overviewSheet.addRow([
|
|
4464
|
+
p.name,
|
|
4465
|
+
p.category ?? "",
|
|
4466
|
+
p.phase,
|
|
4467
|
+
Number((summary.totalActiveMinutes / 60).toFixed(2)),
|
|
4468
|
+
Number((summary.capitalizableCostMicrodollars / 1e6).toFixed(2)),
|
|
4469
|
+
Number((summary.expensedCostMicrodollars / 1e6).toFixed(2)),
|
|
4470
|
+
Number((summary.totalCostMicrodollars / 1e6).toFixed(2))
|
|
4471
|
+
]);
|
|
4472
|
+
}
|
|
4473
|
+
overviewSheet.columns.forEach((col) => {
|
|
4474
|
+
col.width = 18;
|
|
4475
|
+
});
|
|
4476
|
+
overviewSheet.getColumn(1).width = 28;
|
|
4477
|
+
const allSheet = workbook.addWorksheet("All Entries");
|
|
4478
|
+
allSheet.addRow(["Project", "Date", "Session", "Active Hours", "Cost (USD)", "Classification", "Work Type"]);
|
|
4479
|
+
allSheet.getRow(1).font = { bold: true };
|
|
4480
|
+
for (const p of projects) {
|
|
4481
|
+
const entries = this.listCapexEntries(p.id, { month: opts?.startDate });
|
|
4482
|
+
for (const e of entries) {
|
|
4483
|
+
const s = this.getSession(e.sessionId);
|
|
4484
|
+
const date = s?.startedAt ? new Date(s.startedAt).toISOString().split("T")[0] : e.period;
|
|
4485
|
+
allSheet.addRow([
|
|
4486
|
+
p.name,
|
|
4487
|
+
date,
|
|
4488
|
+
s?.slug ?? e.sessionId.slice(0, 12),
|
|
4489
|
+
Number((e.activeMinutes / 60).toFixed(2)),
|
|
4490
|
+
Number((e.costMicrodollars / 1e6).toFixed(4)),
|
|
4491
|
+
e.classification,
|
|
4492
|
+
e.workType ?? ""
|
|
4493
|
+
]);
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
allSheet.columns.forEach((col) => {
|
|
4497
|
+
col.width = 16;
|
|
4498
|
+
});
|
|
4499
|
+
allSheet.getColumn(1).width = 24;
|
|
4500
|
+
allSheet.getColumn(3).width = 24;
|
|
4501
|
+
return Buffer.from(await workbook.xlsx.writeBuffer());
|
|
4502
|
+
}
|
|
4348
4503
|
mapCapexRow(row) {
|
|
4349
4504
|
return {
|
|
4350
4505
|
id: row.id,
|
|
@@ -5141,7 +5296,6 @@ var ProjectDiscovery = class {
|
|
|
5141
5296
|
};
|
|
5142
5297
|
|
|
5143
5298
|
export {
|
|
5144
|
-
__require,
|
|
5145
5299
|
RingBuffer,
|
|
5146
5300
|
EventStore,
|
|
5147
5301
|
generateProjectId,
|
|
@@ -5172,4 +5326,4 @@ export {
|
|
|
5172
5326
|
parseSessionJsonl,
|
|
5173
5327
|
ProjectDiscovery
|
|
5174
5328
|
};
|
|
5175
|
-
//# sourceMappingURL=chunk-
|
|
5329
|
+
//# sourceMappingURL=chunk-GENCCHYK.js.map
|