@porulle/plugin-warehouse 0.10.8 → 0.13.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.
@@ -1,4 +1,4 @@
1
- import { router } from "@porulle/core";
1
+ import { requireUserId, router } from "@porulle/core";
2
2
  import { z } from "@hono/zod-openapi";
3
3
  export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
4
4
  const r = router("Warehouse", "/warehouse", ctx);
@@ -10,7 +10,7 @@ export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
10
10
  }))
11
11
  .handler(async ({ input, actor, orgId }) => {
12
12
  const body = input;
13
- const result = await transferSvc.create(orgId, { ...body, requestedBy: actor.userId });
13
+ const result = await transferSvc.create(orgId, { ...body, requestedBy: requireUserId(actor) });
14
14
  if (!result.ok)
15
15
  throw new Error(result.error);
16
16
  return result.value;
@@ -32,7 +32,7 @@ export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
32
32
  });
33
33
  r.post("/transfers/{id}/approve").summary("Approve transfer").permission("warehouse:admin")
34
34
  .handler(async ({ params, actor, orgId }) => {
35
- const result = await transferSvc.approve(orgId, params.id, actor.userId);
35
+ const result = await transferSvc.approve(orgId, params.id, requireUserId(actor));
36
36
  if (!result.ok)
37
37
  throw new Error(result.error);
38
38
  return result.value;
@@ -61,7 +61,7 @@ export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
61
61
  }))
62
62
  .handler(async ({ input, actor, orgId }) => {
63
63
  const body = input;
64
- const result = await wastageSvc.create(orgId, { ...body, recordedBy: actor.userId });
64
+ const result = await wastageSvc.create(orgId, { ...body, recordedBy: requireUserId(actor) });
65
65
  if (!result.ok)
66
66
  throw new Error(result.error);
67
67
  return result.value;
@@ -75,7 +75,7 @@ export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
75
75
  });
76
76
  r.post("/wastage/{id}/approve").summary("Approve wastage").permission("warehouse:admin")
77
77
  .handler(async ({ params, actor, orgId }) => {
78
- const result = await wastageSvc.approve(orgId, params.id, actor.userId);
78
+ const result = await wastageSvc.approve(orgId, params.id, requireUserId(actor));
79
79
  if (!result.ok)
80
80
  throw new Error(result.error);
81
81
  return result.value;
@@ -88,7 +88,7 @@ export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
88
88
  }))
89
89
  .handler(async ({ input, actor, orgId }) => {
90
90
  const body = input;
91
- const result = await recSvc.create(orgId, { ...body, countedBy: actor.userId });
91
+ const result = await recSvc.create(orgId, { ...body, countedBy: requireUserId(actor) });
92
92
  if (!result.ok)
93
93
  throw new Error(result.error);
94
94
  return result.value;
@@ -116,7 +116,7 @@ export function buildWarehouseRoutes(transferSvc, wastageSvc, recSvc, ctx) {
116
116
  });
117
117
  r.post("/reconciliations/{id}/approve").summary("Approve reconciliation").permission("warehouse:admin")
118
118
  .handler(async ({ params, actor, orgId }) => {
119
- const result = await recSvc.approve(orgId, params.id, actor.userId);
119
+ const result = await recSvc.approve(orgId, params.id, requireUserId(actor));
120
120
  if (!result.ok)
121
121
  throw new Error(result.error);
122
122
  return result.value;
package/dist/schema.d.ts CHANGED
@@ -92,7 +92,7 @@ export declare const warehouseBins: import("drizzle-orm/pg-core/table").PgTableW
92
92
  tableName: "warehouse_bins";
93
93
  dataType: "string";
94
94
  columnType: "PgText";
95
- data: "general" | "cold" | "frozen" | "dry" | "hazardous" | "display";
95
+ data: "general" | "display" | "cold" | "frozen" | "dry" | "hazardous";
96
96
  driverParam: string;
97
97
  notNull: true;
98
98
  hasDefault: true;
@@ -252,7 +252,7 @@ export declare const stockTransfers: import("drizzle-orm/pg-core/table").PgTable
252
252
  tableName: "stock_transfers";
253
253
  dataType: "string";
254
254
  columnType: "PgText";
255
- data: "draft" | "cancelled" | "received" | "pending_approval" | "approved" | "in_transit";
255
+ data: "draft" | "approved" | "cancelled" | "received" | "pending_approval" | "in_transit";
256
256
  driverParam: string;
257
257
  notNull: true;
258
258
  hasDefault: true;
@@ -1064,7 +1064,7 @@ export declare const stockReconciliations: import("drizzle-orm/pg-core/table").P
1064
1064
  tableName: "stock_reconciliations";
1065
1065
  dataType: "string";
1066
1066
  columnType: "PgText";
1067
- data: "draft" | "adjusted" | "approved" | "counting" | "submitted";
1067
+ data: "draft" | "approved" | "adjusted" | "counting" | "submitted";
1068
1068
  driverParam: string;
1069
1069
  notNull: true;
1070
1070
  hasDefault: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/plugin-warehouse",
3
- "version": "0.10.8",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@
19
19
  "dependencies": {
20
20
  "@hono/zod-openapi": "^1.2.2",
21
21
  "hono": "^4.12.5",
22
- "@porulle/core": "0.10.8"
22
+ "@porulle/core": "0.13.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^24.5.2",
@@ -1,4 +1,4 @@
1
- import { router } from "@porulle/core";
1
+ import { requireUserId, router } from "@porulle/core";
2
2
  import { z } from "@hono/zod-openapi";
3
3
  import type { TransferService } from "../services/transfer-service.js";
4
4
  import type { WastageService } from "../services/wastage-service.js";
@@ -19,7 +19,7 @@ export function buildWarehouseRoutes(
19
19
  }))
20
20
  .handler(async ({ input, actor, orgId }) => {
21
21
  const body = input as Parameters<typeof transferSvc.create>[1];
22
- const result = await transferSvc.create(orgId, { ...body, requestedBy: actor!.userId });
22
+ const result = await transferSvc.create(orgId, { ...body, requestedBy: requireUserId(actor) });
23
23
  if (!result.ok) throw new Error(result.error);
24
24
  return result.value;
25
25
  });
@@ -41,7 +41,7 @@ export function buildWarehouseRoutes(
41
41
 
42
42
  r.post("/transfers/{id}/approve").summary("Approve transfer").permission("warehouse:admin")
43
43
  .handler(async ({ params, actor, orgId }) => {
44
- const result = await transferSvc.approve(orgId, params.id!, actor!.userId);
44
+ const result = await transferSvc.approve(orgId, params.id!, requireUserId(actor));
45
45
  if (!result.ok) throw new Error(result.error);
46
46
  return result.value;
47
47
  });
@@ -70,7 +70,7 @@ export function buildWarehouseRoutes(
70
70
  }))
71
71
  .handler(async ({ input, actor, orgId }) => {
72
72
  const body = input as Parameters<typeof wastageSvc.create>[1];
73
- const result = await wastageSvc.create(orgId, { ...body, recordedBy: actor!.userId });
73
+ const result = await wastageSvc.create(orgId, { ...body, recordedBy: requireUserId(actor) });
74
74
  if (!result.ok) throw new Error(result.error);
75
75
  return result.value;
76
76
  });
@@ -84,7 +84,7 @@ export function buildWarehouseRoutes(
84
84
 
85
85
  r.post("/wastage/{id}/approve").summary("Approve wastage").permission("warehouse:admin")
86
86
  .handler(async ({ params, actor, orgId }) => {
87
- const result = await wastageSvc.approve(orgId, params.id!, actor!.userId);
87
+ const result = await wastageSvc.approve(orgId, params.id!, requireUserId(actor));
88
88
  if (!result.ok) throw new Error(result.error);
89
89
  return result.value;
90
90
  });
@@ -97,7 +97,7 @@ export function buildWarehouseRoutes(
97
97
  }))
98
98
  .handler(async ({ input, actor, orgId }) => {
99
99
  const body = input as Parameters<typeof recSvc.create>[1];
100
- const result = await recSvc.create(orgId, { ...body, countedBy: actor!.userId });
100
+ const result = await recSvc.create(orgId, { ...body, countedBy: requireUserId(actor) });
101
101
  if (!result.ok) throw new Error(result.error);
102
102
  return result.value;
103
103
  });
@@ -125,7 +125,7 @@ export function buildWarehouseRoutes(
125
125
 
126
126
  r.post("/reconciliations/{id}/approve").summary("Approve reconciliation").permission("warehouse:admin")
127
127
  .handler(async ({ params, actor, orgId }) => {
128
- const result = await recSvc.approve(orgId, params.id!, actor!.userId);
128
+ const result = await recSvc.approve(orgId, params.id!, requireUserId(actor));
129
129
  if (!result.ok) throw new Error(result.error);
130
130
  return result.value;
131
131
  });