@porulle/plugin-procurement 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 buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
4
4
  const r = router("Procurement", "/procurement", ctx);
@@ -42,7 +42,7 @@ export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
42
42
  }))
43
43
  .handler(async ({ input, actor, orgId }) => {
44
44
  const body = input;
45
- const result = await poSvc.create(orgId, { ...body, requestedBy: actor.userId });
45
+ const result = await poSvc.create(orgId, { ...body, requestedBy: requireUserId(actor) });
46
46
  if (!result.ok)
47
47
  throw new Error(result.error);
48
48
  return result.value;
@@ -71,7 +71,7 @@ export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
71
71
  });
72
72
  r.post("/purchase-orders/{id}/approve").summary("Approve PO").permission("procurement:admin")
73
73
  .handler(async ({ params, actor, orgId }) => {
74
- const result = await poSvc.approve(orgId, params.id, actor.userId);
74
+ const result = await poSvc.approve(orgId, params.id, requireUserId(actor));
75
75
  if (!result.ok)
76
76
  throw new Error(result.error);
77
77
  return result.value;
@@ -96,7 +96,7 @@ export function buildProcurementRoutes(supplierSvc, poSvc, grnSvc, ctx) {
96
96
  }))
97
97
  .handler(async ({ input, actor, orgId }) => {
98
98
  const body = input;
99
- const result = await grnSvc.create(orgId, { ...body, receivedBy: actor.userId });
99
+ const result = await grnSvc.create(orgId, { ...body, receivedBy: requireUserId(actor) });
100
100
  if (!result.ok)
101
101
  throw new Error(result.error);
102
102
  return result.value;
package/dist/schema.d.ts CHANGED
@@ -516,7 +516,7 @@ export declare const purchaseOrders: import("drizzle-orm/pg-core/table").PgTable
516
516
  tableName: "purchase_orders";
517
517
  dataType: "string";
518
518
  columnType: "PgText";
519
- data: "draft" | "cancelled" | "received" | "pending_approval" | "approved" | "sent" | "partially_received";
519
+ data: "draft" | "approved" | "cancelled" | "received" | "pending_approval" | "sent" | "partially_received";
520
520
  driverParam: string;
521
521
  notNull: true;
522
522
  hasDefault: true;
@@ -1059,7 +1059,7 @@ export declare const goodsReceivedNotes: import("drizzle-orm/pg-core/table").PgT
1059
1059
  tableName: "goods_received_notes";
1060
1060
  dataType: "string";
1061
1061
  columnType: "PgText";
1062
- data: "draft" | "accepted" | "rejected" | "inspecting" | "accepted_with_discrepancy";
1062
+ data: "draft" | "rejected" | "accepted" | "inspecting" | "accepted_with_discrepancy";
1063
1063
  driverParam: string;
1064
1064
  notNull: true;
1065
1065
  hasDefault: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/plugin-procurement",
3
- "version": "0.10.8",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,14 +19,14 @@
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",
26
26
  "typescript": "5.9.2",
27
27
  "vitest": "^3.2.4",
28
- "@porulle/typescript-config": "0.1.0",
29
- "@porulle/eslint-config": "0.1.0"
28
+ "@porulle/eslint-config": "0.1.0",
29
+ "@porulle/typescript-config": "0.1.0"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
@@ -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 { SupplierService } from "../services/supplier-service.js";
4
4
  import type { PurchaseOrderService } from "../services/po-service.js";
@@ -51,7 +51,7 @@ export function buildProcurementRoutes(
51
51
  }))
52
52
  .handler(async ({ input, actor, orgId }) => {
53
53
  const body = input as Parameters<typeof poSvc.create>[1];
54
- const result = await poSvc.create(orgId, { ...body, requestedBy: actor!.userId });
54
+ const result = await poSvc.create(orgId, { ...body, requestedBy: requireUserId(actor) });
55
55
  if (!result.ok) throw new Error(result.error);
56
56
  return result.value;
57
57
  });
@@ -80,7 +80,7 @@ export function buildProcurementRoutes(
80
80
 
81
81
  r.post("/purchase-orders/{id}/approve").summary("Approve PO").permission("procurement:admin")
82
82
  .handler(async ({ params, actor, orgId }) => {
83
- const result = await poSvc.approve(orgId, params.id!, actor!.userId);
83
+ const result = await poSvc.approve(orgId, params.id!, requireUserId(actor));
84
84
  if (!result.ok) throw new Error(result.error);
85
85
  return result.value;
86
86
  });
@@ -105,7 +105,7 @@ export function buildProcurementRoutes(
105
105
  }))
106
106
  .handler(async ({ input, actor, orgId }) => {
107
107
  const body = input as Parameters<typeof grnSvc.create>[1];
108
- const result = await grnSvc.create(orgId, { ...body, receivedBy: actor!.userId });
108
+ const result = await grnSvc.create(orgId, { ...body, receivedBy: requireUserId(actor) });
109
109
  if (!result.ok) throw new Error(result.error);
110
110
  return result.value;
111
111
  });