@voyantjs/suppliers 0.105.2 → 0.106.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/routes.d.ts.map +1 -1
- package/dist/routes.js +7 -0
- package/dist/service-aggregates.d.ts.map +1 -1
- package/dist/service-aggregates.js +13 -14
- package/package.json +5 -5
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAqBjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAqBjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAgBD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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uerySchema, insertAvailabilitySchema, insertContractSchema, insertRateSchema, insertServiceSchema, insertSupplierNoteSchema, insertSupplierSchema, supplierAggregatesQuerySchema, supplierListQuerySchema, updateContractSchema, updateRateSchema, updateServiceSchema, updateSupplierSchema, } from "./validation.js";
|
|
7
|
+
const DASHBOARD_AGGREGATES_CACHE_CONTROL = "private, max-age=60";
|
|
8
|
+
function cacheDashboardAggregates(c) {
|
|
9
|
+
c.header("Cache-Control", DASHBOARD_AGGREGATES_CACHE_CONTROL);
|
|
10
|
+
c.header("Vary", "Authorization", { append: true });
|
|
11
|
+
c.header("Vary", "Cookie", { append: true });
|
|
12
|
+
}
|
|
7
13
|
// ==========================================================================
|
|
8
14
|
// Suppliers — method-chained for Hono RPC type inference
|
|
9
15
|
// ==========================================================================
|
|
@@ -14,6 +20,7 @@ export const supplierRoutes = new Hono()
|
|
|
14
20
|
// GET /aggregates — dashboard KPIs (before /:id so the matcher doesn't swallow it)
|
|
15
21
|
.get("/aggregates", async (c) => {
|
|
16
22
|
const query = parseQuery(c, supplierAggregatesQuerySchema);
|
|
23
|
+
cacheDashboardAggregates(c);
|
|
17
24
|
return c.json({ data: await suppliersService.getSupplierAggregates(c.get("db"), query) });
|
|
18
25
|
})
|
|
19
26
|
// ========================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-aggregates.d.ts","sourceRoot":"","sources":["../src/service-aggregates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,KAAK,cAAc,GAAG,CAAC,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CAAA;AAC/D,KAAK,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAa3D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,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IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3C,OAAO,CAAC,kBAAkB,CAAC,CAsC7B"}
|
|
@@ -19,20 +19,19 @@ export async function getSupplierAggregates(db, options = {}) {
|
|
|
19
19
|
if (toDate)
|
|
20
20
|
rangeConditions.push(sql `${suppliers.createdAt} < ${toDate}`);
|
|
21
21
|
const rangeWhere = rangeConditions.length ? and(...rangeConditions) : undefined;
|
|
22
|
-
const [totalRow] = await
|
|
23
|
-
.select({ count: sql `count(*)::int` })
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.groupBy(suppliers.type);
|
|
22
|
+
const [[totalRow], statusRows, typeRows] = await Promise.all([
|
|
23
|
+
db.select({ count: sql `count(*)::int` }).from(suppliers).where(rangeWhere),
|
|
24
|
+
db
|
|
25
|
+
.select({ status: suppliers.status, count: sql `count(*)::int` })
|
|
26
|
+
.from(suppliers)
|
|
27
|
+
.where(rangeWhere)
|
|
28
|
+
.groupBy(suppliers.status),
|
|
29
|
+
db
|
|
30
|
+
.select({ type: suppliers.type, count: sql `count(*)::int` })
|
|
31
|
+
.from(suppliers)
|
|
32
|
+
.where(rangeWhere)
|
|
33
|
+
.groupBy(suppliers.type),
|
|
34
|
+
]);
|
|
36
35
|
const statusMap = new Map(statusRows.map((r) => [r.status, r.count]));
|
|
37
36
|
const typeMap = new Map(typeRows.map((r) => [r.type, r.count]));
|
|
38
37
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/suppliers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.106.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"drizzle-orm": "^0.45.2",
|
|
30
30
|
"hono": "^4.12.10",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@voyantjs/core": "^0.105.
|
|
32
|
+
"@voyantjs/core": "^0.105.1",
|
|
33
33
|
"@voyantjs/db": "^0.104.3",
|
|
34
|
-
"@voyantjs/facilities": "^0.
|
|
35
|
-
"@voyantjs/hono": "^0.105.
|
|
36
|
-
"@voyantjs/identity": "^0.
|
|
34
|
+
"@voyantjs/facilities": "^0.106.0",
|
|
35
|
+
"@voyantjs/hono": "^0.105.2",
|
|
36
|
+
"@voyantjs/identity": "^0.109.0",
|
|
37
37
|
"@voyantjs/suppliers-contracts": "^0.104.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|