@porulle/plugin-appointments 0.11.0 → 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.
package/dist/index.js CHANGED
@@ -48,11 +48,11 @@ export function appointmentPlugin(options = {}) {
48
48
  if (!services)
49
49
  return [];
50
50
  return [
51
- ...buildServiceRoutes(services),
52
- ...buildProviderRoutes(services),
53
- ...buildAvailabilityRoutes(services),
54
- ...buildBookingRoutes(services),
55
- ...buildMyBookingRoutes(services),
51
+ ...buildServiceRoutes(services, ctx.config),
52
+ ...buildProviderRoutes(services, ctx.config),
53
+ ...buildAvailabilityRoutes(services, ctx.config),
54
+ ...buildBookingRoutes(services, ctx.config),
55
+ ...buildMyBookingRoutes(services, ctx.config),
56
56
  ];
57
57
  },
58
58
  analyticsModels: () => APPOINTMENT_ANALYTICS_MODELS,
@@ -1,8 +1,9 @@
1
+ import type { CommerceConfig } from "@porulle/core";
1
2
  import type { PluginRouteRegistration } from "@porulle/core";
2
3
  import type { ProviderService } from "../services/provider-service.js";
3
4
  import type { SlotService } from "../services/slot-service.js";
4
5
  export declare function buildAvailabilityRoutes(services: {
5
6
  provider: ProviderService;
6
7
  slots: SlotService;
7
- }): PluginRouteRegistration[];
8
+ }, config: CommerceConfig): PluginRouteRegistration[];
8
9
  //# sourceMappingURL=availability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../../src/routes/availability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAyB/D,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE;IAChD,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;CACpB,GAAG,uBAAuB,EAAE,CAwH5B"}
1
+ {"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../../src/routes/availability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAyB/D,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE;IAChD,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC;CACpB,EAAE,MAAM,EAAE,cAAc,GAAG,uBAAuB,EAAE,CAwHpD"}
@@ -20,8 +20,8 @@ const AddOverrideSchema = z.object({
20
20
  endTime: z.string().regex(/^\d{2}:\d{2}$/).optional(),
21
21
  reason: z.string().optional().openapi({ example: "Christmas Day" }),
22
22
  }).openapi("AddOverrideRequest");
23
- export function buildAvailabilityRoutes(services) {
24
- const r = router("Appointments - Availability", "/appointments/availability");
23
+ export function buildAvailabilityRoutes(services, config) {
24
+ const r = router("Appointments - Availability", "/appointments/availability", { config });
25
25
  // ─── Weekly Schedule ────────────────────────────────────────────────────────
26
26
  r.put("/{providerId}/weekly")
27
27
  .summary("Set weekly availability")
@@ -1,8 +1,9 @@
1
+ import type { CommerceConfig } from "@porulle/core";
1
2
  import type { PluginRouteRegistration } from "@porulle/core";
2
3
  import type { BookingService } from "../services/booking-service.js";
3
4
  import type { ProviderService } from "../services/provider-service.js";
4
5
  export declare function buildBookingRoutes(services: {
5
6
  booking: BookingService;
6
7
  provider: ProviderService;
7
- }): PluginRouteRegistration[];
8
+ }, config: CommerceConfig): PluginRouteRegistration[];
8
9
  //# sourceMappingURL=bookings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bookings.d.ts","sourceRoot":"","sources":["../../src/routes/bookings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAuBvE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;CAC3B,GAAG,uBAAuB,EAAE,CA8G5B"}
1
+ {"version":3,"file":"bookings.d.ts","sourceRoot":"","sources":["../../src/routes/bookings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAuBvE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;CAC3B,EAAE,MAAM,EAAE,cAAc,GAAG,uBAAuB,EAAE,CA8GpD"}
@@ -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
  const CreateBookingSchema = z.object({
4
4
  providerId: z.string().uuid(),
@@ -17,8 +17,8 @@ const RescheduleBookingSchema = z.object({
17
17
  const CancelBookingSchema = z.object({
18
18
  reason: z.string().optional(),
19
19
  }).openapi("CancelBookingRequest");
20
- export function buildBookingRoutes(services) {
21
- const r = router("Appointments - Bookings", "/appointments/bookings");
20
+ export function buildBookingRoutes(services, config) {
21
+ const r = router("Appointments - Bookings", "/appointments/bookings", { config });
22
22
  r.get("/")
23
23
  .summary("List bookings")
24
24
  .permission("appointments:manage")
@@ -42,7 +42,7 @@ export function buildBookingRoutes(services) {
42
42
  const result = await services.booking.create({
43
43
  providerId: body.providerId,
44
44
  serviceTypeId: body.serviceTypeId,
45
- customerId: actor.userId,
45
+ customerId: requireUserId(actor),
46
46
  customerName: body.customerName,
47
47
  customerEmail: body.customerEmail,
48
48
  customerPhone: body.customerPhone,
@@ -1,6 +1,7 @@
1
+ import type { CommerceConfig } from "@porulle/core";
1
2
  import type { PluginRouteRegistration } from "@porulle/core";
2
3
  import type { BookingService } from "../services/booking-service.js";
3
4
  export declare function buildMyBookingRoutes(services: {
4
5
  booking: BookingService;
5
- }): PluginRouteRegistration[];
6
+ }, config: CommerceConfig): PluginRouteRegistration[];
6
7
  //# sourceMappingURL=my-bookings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"my-bookings.d.ts","sourceRoot":"","sources":["../../src/routes/my-bookings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE;IAC7C,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,uBAAuB,EAAE,CAqB5B"}
1
+ {"version":3,"file":"my-bookings.d.ts","sourceRoot":"","sources":["../../src/routes/my-bookings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE;IAC7C,OAAO,EAAE,cAAc,CAAC;CACzB,EAAE,MAAM,EAAE,cAAc,GAAG,uBAAuB,EAAE,CAqBpD"}
@@ -1,11 +1,11 @@
1
- import { router } from "@porulle/core";
2
- export function buildMyBookingRoutes(services) {
3
- const r = router("Appointments - My Bookings", "/appointments/my-bookings");
1
+ import { requireUserId, router } from "@porulle/core";
2
+ export function buildMyBookingRoutes(services, config) {
3
+ const r = router("Appointments - My Bookings", "/appointments/my-bookings", { config });
4
4
  r.get("/")
5
5
  .summary("List my bookings")
6
6
  .auth()
7
7
  .handler(async ({ actor }) => {
8
- return services.booking.listByCustomer(actor.userId);
8
+ return services.booking.listByCustomer(requireUserId(actor));
9
9
  });
10
10
  r.get("/{id}")
11
11
  .summary("Get my booking")
@@ -14,7 +14,7 @@ export function buildMyBookingRoutes(services) {
14
14
  const booking = await services.booking.getById(params.id);
15
15
  if (!booking)
16
16
  throw new Error("Booking not found");
17
- if (booking.customerId !== actor.userId)
17
+ if (booking.customerId !== requireUserId(actor))
18
18
  throw new Error("Booking not found");
19
19
  return booking;
20
20
  });
@@ -1,6 +1,7 @@
1
+ import type { CommerceConfig } from "@porulle/core";
1
2
  import type { PluginRouteRegistration } from "@porulle/core";
2
3
  import type { ProviderService } from "../services/provider-service.js";
3
4
  export declare function buildProviderRoutes(services: {
4
5
  provider: ProviderService;
5
- }): PluginRouteRegistration[];
6
+ }, config: CommerceConfig): PluginRouteRegistration[];
6
7
  //# sourceMappingURL=providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/routes/providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAoBvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,eAAe,CAAC;CAC3B,GAAG,uBAAuB,EAAE,CAuE5B"}
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/routes/providers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAoBvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE;IAC5C,QAAQ,EAAE,eAAe,CAAC;CAC3B,EAAE,MAAM,EAAE,cAAc,GAAG,uBAAuB,EAAE,CAuEpD"}
@@ -1,4 +1,4 @@
1
- import { router, resolveOrgId } from "@porulle/core";
1
+ import { router, resolveOrgIdForCommerce } from "@porulle/core";
2
2
  import { z } from "@hono/zod-openapi";
3
3
  import { stripUndefined } from "./util.js";
4
4
  const CreateProviderSchema = z.object({
@@ -16,8 +16,8 @@ const UpdateProviderSchema = z.object({
16
16
  isActive: z.boolean().optional(),
17
17
  metadata: z.record(z.string(), z.unknown()).optional(),
18
18
  }).openapi("UpdateProviderRequest");
19
- export function buildProviderRoutes(services) {
20
- const r = router("Appointments - Providers", "/appointments/providers");
19
+ export function buildProviderRoutes(services, config) {
20
+ const r = router("Appointments - Providers", "/appointments/providers", { config });
21
21
  r.get("/")
22
22
  .summary("List providers")
23
23
  .handler(async () => {
@@ -29,7 +29,7 @@ export function buildProviderRoutes(services) {
29
29
  .input(CreateProviderSchema)
30
30
  .handler(async ({ input, actor }) => {
31
31
  const body = input;
32
- return services.provider.createProvider(resolveOrgId(actor), stripUndefined(body));
32
+ return services.provider.createProvider(resolveOrgIdForCommerce(actor, config), stripUndefined(body));
33
33
  });
34
34
  r.get("/{id}")
35
35
  .summary("Get provider")
@@ -1,6 +1,7 @@
1
+ import type { CommerceConfig } from "@porulle/core";
1
2
  import type { PluginRouteRegistration } from "@porulle/core";
2
3
  import type { ProviderService } from "../services/provider-service.js";
3
4
  export declare function buildServiceRoutes(services: {
4
5
  provider: ProviderService;
5
- }): PluginRouteRegistration[];
6
+ }, config: CommerceConfig): PluginRouteRegistration[];
6
7
  //# sourceMappingURL=services.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/routes/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAyBvE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,QAAQ,EAAE,eAAe,CAAC;CAC3B,GAAG,uBAAuB,EAAE,CA+C5B"}
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/routes/services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAyBvE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,QAAQ,EAAE,eAAe,CAAC;CAC3B,EAAE,MAAM,EAAE,cAAc,GAAG,uBAAuB,EAAE,CA+CpD"}
@@ -1,4 +1,4 @@
1
- import { router, resolveOrgId } from "@porulle/core";
1
+ import { router, resolveOrgIdForCommerce } from "@porulle/core";
2
2
  import { z } from "@hono/zod-openapi";
3
3
  import { stripUndefined } from "./util.js";
4
4
  const CreateServiceTypeSchema = z.object({
@@ -21,8 +21,8 @@ const UpdateServiceTypeSchema = z.object({
21
21
  bufferAfterMinutes: z.number().int().min(0).optional(),
22
22
  isActive: z.boolean().optional(),
23
23
  }).openapi("UpdateServiceTypeRequest");
24
- export function buildServiceRoutes(services) {
25
- const r = router("Appointments - Services", "/appointments/services");
24
+ export function buildServiceRoutes(services, config) {
25
+ const r = router("Appointments - Services", "/appointments/services", { config });
26
26
  r.get("/")
27
27
  .summary("List service types")
28
28
  .handler(async () => {
@@ -34,7 +34,7 @@ export function buildServiceRoutes(services) {
34
34
  .input(CreateServiceTypeSchema)
35
35
  .handler(async ({ input, actor }) => {
36
36
  const body = input;
37
- return services.provider.createServiceType(resolveOrgId(actor), stripUndefined(body));
37
+ return services.provider.createServiceType(resolveOrgIdForCommerce(actor, config), stripUndefined(body));
38
38
  });
39
39
  r.get("/{id}")
40
40
  .summary("Get service type")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/plugin-appointments",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,15 +19,15 @@
19
19
  "dependencies": {
20
20
  "@hono/zod-openapi": "^1.2.2",
21
21
  "hono": "^4.12.5",
22
- "@porulle/core": "0.11.0"
22
+ "@porulle/core": "0.13.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^24.5.2",
26
26
  "eslint": "^9.39.1",
27
27
  "typescript": "5.9.2",
28
28
  "vitest": "^3.2.4",
29
- "@porulle/typescript-config": "0.1.0",
30
- "@porulle/eslint-config": "0.1.0"
29
+ "@porulle/eslint-config": "0.1.0",
30
+ "@porulle/typescript-config": "0.1.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
package/src/index.ts CHANGED
@@ -61,11 +61,11 @@ export function appointmentPlugin(options: AppointmentPluginOptions = {}) {
61
61
  if (!services) return [];
62
62
 
63
63
  return [
64
- ...buildServiceRoutes(services),
65
- ...buildProviderRoutes(services),
66
- ...buildAvailabilityRoutes(services),
67
- ...buildBookingRoutes(services),
68
- ...buildMyBookingRoutes(services),
64
+ ...buildServiceRoutes(services, ctx.config),
65
+ ...buildProviderRoutes(services, ctx.config),
66
+ ...buildAvailabilityRoutes(services, ctx.config),
67
+ ...buildBookingRoutes(services, ctx.config),
68
+ ...buildMyBookingRoutes(services, ctx.config),
69
69
  ];
70
70
  },
71
71
 
@@ -1,4 +1,5 @@
1
1
  import { router } from "@porulle/core";
2
+ import type { CommerceConfig } from "@porulle/core";
2
3
  import type { PluginRouteRegistration } from "@porulle/core";
3
4
  import { z } from "@hono/zod-openapi";
4
5
  import type { ProviderService } from "../services/provider-service.js";
@@ -30,8 +31,8 @@ const AddOverrideSchema = z.object({
30
31
  export function buildAvailabilityRoutes(services: {
31
32
  provider: ProviderService;
32
33
  slots: SlotService;
33
- }): PluginRouteRegistration[] {
34
- const r = router("Appointments - Availability", "/appointments/availability");
34
+ }, config: CommerceConfig): PluginRouteRegistration[] {
35
+ const r = router("Appointments - Availability", "/appointments/availability", { config });
35
36
 
36
37
  // ─── Weekly Schedule ────────────────────────────────────────────────────────
37
38
 
@@ -1,4 +1,5 @@
1
- import { router } from "@porulle/core";
1
+ import { requireUserId, router } from "@porulle/core";
2
+ import type { CommerceConfig } from "@porulle/core";
2
3
  import type { PluginRouteRegistration } from "@porulle/core";
3
4
  import { z } from "@hono/zod-openapi";
4
5
  import type { BookingService } from "../services/booking-service.js";
@@ -28,8 +29,8 @@ const CancelBookingSchema = z.object({
28
29
  export function buildBookingRoutes(services: {
29
30
  booking: BookingService;
30
31
  provider: ProviderService;
31
- }): PluginRouteRegistration[] {
32
- const r = router("Appointments - Bookings", "/appointments/bookings");
32
+ }, config: CommerceConfig): PluginRouteRegistration[] {
33
+ const r = router("Appointments - Bookings", "/appointments/bookings", { config });
33
34
 
34
35
  r.get("/")
35
36
  .summary("List bookings")
@@ -58,7 +59,7 @@ export function buildBookingRoutes(services: {
58
59
  const result = await services.booking.create({
59
60
  providerId: body.providerId,
60
61
  serviceTypeId: body.serviceTypeId,
61
- customerId: actor!.userId,
62
+ customerId: requireUserId(actor),
62
63
  customerName: body.customerName,
63
64
  customerEmail: body.customerEmail,
64
65
  customerPhone: body.customerPhone,
@@ -1,17 +1,18 @@
1
- import { router } from "@porulle/core";
1
+ import { requireUserId, router } from "@porulle/core";
2
+ import type { CommerceConfig } from "@porulle/core";
2
3
  import type { PluginRouteRegistration } from "@porulle/core";
3
4
  import type { BookingService } from "../services/booking-service.js";
4
5
 
5
6
  export function buildMyBookingRoutes(services: {
6
7
  booking: BookingService;
7
- }): PluginRouteRegistration[] {
8
- const r = router("Appointments - My Bookings", "/appointments/my-bookings");
8
+ }, config: CommerceConfig): PluginRouteRegistration[] {
9
+ const r = router("Appointments - My Bookings", "/appointments/my-bookings", { config });
9
10
 
10
11
  r.get("/")
11
12
  .summary("List my bookings")
12
13
  .auth()
13
14
  .handler(async ({ actor }) => {
14
- return services.booking.listByCustomer(actor!.userId);
15
+ return services.booking.listByCustomer(requireUserId(actor));
15
16
  });
16
17
 
17
18
  r.get("/{id}")
@@ -20,7 +21,7 @@ export function buildMyBookingRoutes(services: {
20
21
  .handler(async ({ params, actor }) => {
21
22
  const booking = await services.booking.getById(params.id!);
22
23
  if (!booking) throw new Error("Booking not found");
23
- if (booking.customerId !== actor!.userId) throw new Error("Booking not found");
24
+ if (booking.customerId !== requireUserId(actor)) throw new Error("Booking not found");
24
25
  return booking;
25
26
  });
26
27
 
@@ -1,4 +1,5 @@
1
- import { router, resolveOrgId } from "@porulle/core";
1
+ import { router, resolveOrgIdForCommerce } from "@porulle/core";
2
+ import type { CommerceConfig } from "@porulle/core";
2
3
  import type { PluginRouteRegistration } from "@porulle/core";
3
4
  import { z } from "@hono/zod-openapi";
4
5
  import type { ProviderService } from "../services/provider-service.js";
@@ -23,8 +24,8 @@ const UpdateProviderSchema = z.object({
23
24
 
24
25
  export function buildProviderRoutes(services: {
25
26
  provider: ProviderService;
26
- }): PluginRouteRegistration[] {
27
- const r = router("Appointments - Providers", "/appointments/providers");
27
+ }, config: CommerceConfig): PluginRouteRegistration[] {
28
+ const r = router("Appointments - Providers", "/appointments/providers", { config });
28
29
 
29
30
  r.get("/")
30
31
  .summary("List providers")
@@ -38,7 +39,7 @@ export function buildProviderRoutes(services: {
38
39
  .input(CreateProviderSchema)
39
40
  .handler(async ({ input, actor }) => {
40
41
  const body = input as z.infer<typeof CreateProviderSchema>;
41
- return services.provider.createProvider(resolveOrgId(actor), stripUndefined(body));
42
+ return services.provider.createProvider(resolveOrgIdForCommerce(actor, config), stripUndefined(body));
42
43
  });
43
44
 
44
45
  r.get("/{id}")
@@ -1,4 +1,5 @@
1
- import { router, resolveOrgId } from "@porulle/core";
1
+ import { router, resolveOrgIdForCommerce } from "@porulle/core";
2
+ import type { CommerceConfig } from "@porulle/core";
2
3
  import type { PluginRouteRegistration } from "@porulle/core";
3
4
  import { z } from "@hono/zod-openapi";
4
5
  import type { ProviderService } from "../services/provider-service.js";
@@ -28,8 +29,8 @@ const UpdateServiceTypeSchema = z.object({
28
29
 
29
30
  export function buildServiceRoutes(services: {
30
31
  provider: ProviderService;
31
- }): PluginRouteRegistration[] {
32
- const r = router("Appointments - Services", "/appointments/services");
32
+ }, config: CommerceConfig): PluginRouteRegistration[] {
33
+ const r = router("Appointments - Services", "/appointments/services", { config });
33
34
 
34
35
  r.get("/")
35
36
  .summary("List service types")
@@ -43,7 +44,7 @@ export function buildServiceRoutes(services: {
43
44
  .input(CreateServiceTypeSchema)
44
45
  .handler(async ({ input, actor }) => {
45
46
  const body = input as z.infer<typeof CreateServiceTypeSchema>;
46
- return services.provider.createServiceType(resolveOrgId(actor), stripUndefined(body));
47
+ return services.provider.createServiceType(resolveOrgIdForCommerce(actor, config), stripUndefined(body));
47
48
  });
48
49
 
49
50
  r.get("/{id}")