@shophost/rest-api 2.0.34 → 2.0.36
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/LICENSE +17 -13
- package/README.md +76 -66
- package/package.json +2 -2
- package/scripts/minify-dist.mjs +45 -0
- package/src/app.js +1 -53
- package/src/app.js.map +1 -1
- package/src/core/auth/auth.schema.js +1 -41
- package/src/core/auth/auth.util.js +1 -44
- package/src/core/auth/better-auth.lib.js +1 -100
- package/src/core/auth/generate-password-hash.util.js +1 -30
- package/src/core/auth/headers.schema.js +1 -22
- package/src/core/auth/user.schema.js +1 -30
- package/src/core/db/__generated__/client/browser.js +1 -18
- package/src/core/db/__generated__/client/client.js +1 -35
- package/src/core/db/__generated__/client/commonInputTypes.js +1 -11
- package/src/core/db/__generated__/client/enums.js +1 -200
- package/src/core/db/__generated__/client/internal/class.js +769 -55
- package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +2 -2
- package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
- package/src/core/db/__generated__/client/models/Account.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Account.js +1 -2
- package/src/core/db/__generated__/client/models/Address.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Address.js +1 -2
- package/src/core/db/__generated__/client/models/Campaign.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Campaign.js +1 -2
- package/src/core/db/__generated__/client/models/ClosingTimes.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
- package/src/core/db/__generated__/client/models/File.d.ts +0 -5
- package/src/core/db/__generated__/client/models/File.js +1 -2
- package/src/core/db/__generated__/client/models/Invitation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Invitation.js +1 -2
- package/src/core/db/__generated__/client/models/LegalEntity.d.ts +0 -5
- package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
- package/src/core/db/__generated__/client/models/Manufacturer.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Member.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Member.js +1 -2
- package/src/core/db/__generated__/client/models/Modifier.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Modifier.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroup.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/OpeningTimes.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
- package/src/core/db/__generated__/client/models/Order.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Order.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItem.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItemTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Organization.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Organization.js +1 -2
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
- package/src/core/db/__generated__/client/models/Payment.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Payment.js +1 -2
- package/src/core/db/__generated__/client/models/PaymentSession.d.ts +0 -5
- package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
- package/src/core/db/__generated__/client/models/Product.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Product.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategory.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/ProductSnapshot.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
- package/src/core/db/__generated__/client/models/ProductTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Reservation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Reservation.js +1 -2
- package/src/core/db/__generated__/client/models/Session.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Session.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingMethod.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingZone.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
- package/src/core/db/__generated__/client/models/User.d.ts +0 -5
- package/src/core/db/__generated__/client/models/User.js +1 -2
- package/src/core/db/__generated__/client/models/Verification.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Verification.js +1 -2
- package/src/core/db/__generated__/client/models.js +1 -2
- package/src/core/db/index.js +1 -2
- package/src/core/email/components.d.ts +16 -0
- package/src/core/email/components.js +1 -0
- package/src/core/email/components.js.map +1 -0
- package/src/core/exceptions/http-exception.js +1 -9
- package/src/core/hono/hono.js +1 -123
- package/src/core/lib/prisma.d.ts +8 -8
- package/src/core/lib/prisma.js +1 -11
- package/src/core/logging/pino.js +1 -5
- package/src/core/notifications/email.service.js +1 -116
- package/src/core/openapi/openapi.lib.js +1 -26
- package/src/core/types/google-maps.types.js +1 -2
- package/src/core/utils/currency.util.js +1 -11
- package/src/core/utils/env.util.js +1 -8
- package/src/core/utils/object.util.js +1 -39
- package/src/core/utils/translations.util.js +0 -1
- package/src/core/utils/zod.util.js +1 -85
- package/src/db.js +1 -3
- package/src/features/access/access.handler.js +1 -91
- package/src/features/access/access.route.js +1 -220
- package/src/features/access/access.schema.js +1 -108
- package/src/features/access/access.service.js +1 -294
- package/src/features/analytics/analytics.handler.d.ts +2 -0
- package/src/features/analytics/analytics.handler.js +1 -0
- package/src/features/analytics/analytics.handler.js.map +1 -0
- package/src/features/analytics/analytics.route.d.ts +3 -0
- package/src/features/analytics/analytics.route.js +1 -0
- package/src/features/analytics/analytics.route.js.map +1 -0
- package/src/features/analytics/analytics.schema.d.ts +86 -0
- package/src/features/analytics/analytics.schema.js +1 -0
- package/src/features/analytics/analytics.schema.js.map +1 -0
- package/src/features/analytics/analytics.service.d.ts +45 -0
- package/src/features/analytics/analytics.service.js +1 -0
- package/src/features/analytics/analytics.service.js.map +1 -0
- package/src/features/cart/cart.handler.js +1 -17
- package/src/features/cart/cart.route.js +1 -32
- package/src/features/cart/cart.schema.d.ts +1 -1
- package/src/features/cart/cart.schema.js +1 -39
- package/src/features/cart/cart.service.d.ts +1 -1
- package/src/features/cart/cart.service.js +1 -97
- package/src/features/cart/cart.util.js +1 -76
- package/src/features/file/file.handler.js +1 -23
- package/src/features/file/file.route.js +1 -34
- package/src/features/file/file.schema.js +1 -77
- package/src/features/file/file.service.js +1 -66
- package/src/features/health/health.handler.js +1 -10
- package/src/features/health/health.route.js +1 -25
- package/src/features/index.d.ts +1 -0
- package/src/features/index.js +1 -16
- package/src/features/index.js.map +1 -1
- package/src/features/location/location.handler.js +1 -25
- package/src/features/location/location.route.js +1 -56
- package/src/features/location/location.schema.js +1 -50
- package/src/features/location/location.service.js +1 -141
- package/src/features/manufacturer/manufacturer.handler.js +1 -53
- package/src/features/manufacturer/manufacturer.route.js +1 -97
- package/src/features/manufacturer/manufacturer.schema.js +1 -125
- package/src/features/manufacturer/manufacturer.service.js +1 -190
- package/src/features/order/emails/order-confirmation.email.js +1 -229
- package/src/features/order/emails/order-confirmation.email.js.map +1 -1
- package/src/features/order/emails/order-notification.email.js +1 -229
- package/src/features/order/emails/order-notification.email.js.map +1 -1
- package/src/features/order/fulfilment.schema.js +1 -3
- package/src/features/order/order.handler.js +1 -54
- package/src/features/order/order.route.js +1 -111
- package/src/features/order/order.schema.d.ts +4 -4
- package/src/features/order/order.schema.js +1 -158
- package/src/features/order/order.service.d.ts +4 -4
- package/src/features/order/order.service.js +1 -306
- package/src/features/order/recipient.schema.js +1 -38
- package/src/features/organization/legal-entity.schema.js +1 -83
- package/src/features/organization/organization-configuration.schema.js +1 -115
- package/src/features/organization/organization.handler.js +1 -48
- package/src/features/organization/organization.route.js +1 -84
- package/src/features/organization/organization.schema.js +1 -64
- package/src/features/organization/organization.service.js +1 -334
- package/src/features/payment/payment.handler.js +1 -16
- package/src/features/payment/payment.route.js +1 -22
- package/src/features/payment/payment.schema.d.ts +3 -3
- package/src/features/payment/payment.schema.js +1 -46
- package/src/features/payment/payment.service.d.ts +1 -1
- package/src/features/payment/payment.service.js +1 -100
- package/src/features/payment/stripe.service.js +1 -164
- package/src/features/product/product-modifier.schema.js +1 -84
- package/src/features/product/product.handler.js +1 -87
- package/src/features/product/product.route.js +1 -179
- package/src/features/product/product.schema.d.ts +3 -3
- package/src/features/product/product.schema.js +1 -143
- package/src/features/product/product.service.d.ts +2 -2
- package/src/features/product/product.service.js +1 -440
- package/src/features/product-category/product-category.handler.js +1 -59
- package/src/features/product-category/product-category.route.js +1 -139
- package/src/features/product-category/product-category.schema.js +1 -86
- package/src/features/product-category/product-category.service.js +1 -220
- package/src/features/reservation/emails/reservation-cancellation.email.js +1 -82
- package/src/features/reservation/emails/reservation-cancellation.email.js.map +1 -1
- package/src/features/reservation/emails/reservation-confirmation.email.js +1 -82
- package/src/features/reservation/emails/reservation-confirmation.email.js.map +1 -1
- package/src/features/reservation/emails/reservation-notification.email.js +1 -93
- package/src/features/reservation/emails/reservation-notification.email.js.map +1 -1
- package/src/features/reservation/reservation.handler.js +1 -65
- package/src/features/reservation/reservation.route.js +1 -167
- package/src/features/reservation/reservation.schema.d.ts +1 -1
- package/src/features/reservation/reservation.schema.js +1 -51
- package/src/features/reservation/reservation.service.js +1 -231
- package/src/features/shipping/shipping.handler.js +1 -32
- package/src/features/shipping/shipping.route.js +1 -51
- package/src/features/shipping/shipping.service.js +1 -96
- package/src/features/shipping-method/shipping-method.handler.js +1 -60
- package/src/features/shipping-method/shipping-method.route.js +1 -144
- package/src/features/shipping-method/shipping-method.schema.js +1 -48
- package/src/features/shipping-method/shipping-method.service.js +1 -229
- package/src/features/shipping-method/shipping-zone.schema.js +1 -31
- package/src/features/webhook/webhook.handler.js +1 -50
- package/src/features/webhook/webhook.route.js +1 -33
- package/src/index.js +1 -6
- package/src/integrations/next.js +1 -82
- package/src/schemas/address.schema.js +1 -112
- package/src/schemas/currency.schema.js +1 -118
- package/src/schemas/error.schema.js +1 -12
- package/src/schemas/index.d.ts +1 -0
- package/src/schemas/index.js +1 -29
- package/src/schemas/index.js.map +1 -1
- package/src/schemas/locales.schema.js +1 -238
- package/src/schemas/number.schema.js +1 -29
- package/src/schemas/pagination.schema.js +1 -54
- package/src/schemas/params.schema.js +1 -20
- package/src/schemas/queries.schema.js +1 -6
- package/src/test/global-setup.js +1 -37
- package/src/test/integration/api-fixtures.js +1 -160
- package/src/test/integration/seed.js +1 -368
- package/src/test/integration/test-helpers.d.ts +2 -0
- package/src/test/integration/test-helpers.js +1 -154
- package/src/test/integration/test-helpers.js.map +1 -1
- package/src/test/setup-test-env.js +1 -7
|
@@ -1,115 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { currency } from "../../schemas/currency.schema";
|
|
3
|
-
import { locale } from "../../schemas/locales.schema";
|
|
4
|
-
export const TimeScheduleSchema = z
|
|
5
|
-
.object({
|
|
6
|
-
monday: z.string().nullable().openapi({
|
|
7
|
-
example: "09:00",
|
|
8
|
-
description: "Opening time for Monday",
|
|
9
|
-
}),
|
|
10
|
-
tuesday: z.string().nullable().openapi({
|
|
11
|
-
example: "09:00",
|
|
12
|
-
description: "Opening time for Tuesday",
|
|
13
|
-
}),
|
|
14
|
-
wednesday: z.string().nullable().openapi({
|
|
15
|
-
example: "09:00",
|
|
16
|
-
description: "Opening time for Wednesday",
|
|
17
|
-
}),
|
|
18
|
-
thursday: z.string().nullable().openapi({
|
|
19
|
-
example: "09:00",
|
|
20
|
-
description: "Opening time for Thursday",
|
|
21
|
-
}),
|
|
22
|
-
friday: z.string().nullable().openapi({
|
|
23
|
-
example: "09:00",
|
|
24
|
-
description: "Opening time for Friday",
|
|
25
|
-
}),
|
|
26
|
-
saturday: z.string().nullable().openapi({
|
|
27
|
-
example: "09:00",
|
|
28
|
-
description: "Opening time for Saturday",
|
|
29
|
-
}),
|
|
30
|
-
sunday: z.string().nullable().openapi({
|
|
31
|
-
example: "09:00",
|
|
32
|
-
description: "Opening time for Sunday",
|
|
33
|
-
}),
|
|
34
|
-
})
|
|
35
|
-
.openapi("TimeSchedule");
|
|
36
|
-
export const OrganizationConfigurationSchema = z
|
|
37
|
-
.object({
|
|
38
|
-
id: z.string().openapi({
|
|
39
|
-
example: "clm1234567890abcdef",
|
|
40
|
-
description: "Unique identifier for the organization configuration",
|
|
41
|
-
}),
|
|
42
|
-
hostname: z.coerce.string().optional().openapi({
|
|
43
|
-
example: "store.example.com",
|
|
44
|
-
description: "Hostname associated with the organization",
|
|
45
|
-
}),
|
|
46
|
-
countriesShipping: z.array(z.string()).openapi({
|
|
47
|
-
example: ["US", "CA"],
|
|
48
|
-
description: "List of countries where shipping is available",
|
|
49
|
-
}),
|
|
50
|
-
stripeAccountId: z.coerce.string().optional().openapi({
|
|
51
|
-
example: "acct_123456789",
|
|
52
|
-
description: "Stripe account ID associated with the organization",
|
|
53
|
-
}),
|
|
54
|
-
enableHostCheckout: z.boolean().openapi({
|
|
55
|
-
example: true,
|
|
56
|
-
description: "Indicates if host checkout is enabled",
|
|
57
|
-
}),
|
|
58
|
-
enableHostTracking: z.boolean().openapi({
|
|
59
|
-
example: true,
|
|
60
|
-
description: "Indicates if host tracking is enabled",
|
|
61
|
-
}),
|
|
62
|
-
isAcceptingOrders: z.boolean().openapi({
|
|
63
|
-
example: true,
|
|
64
|
-
description: "Indicates if the organization is currently accepting orders",
|
|
65
|
-
}),
|
|
66
|
-
isOpen: z.boolean().default(false).openapi({
|
|
67
|
-
example: true,
|
|
68
|
-
description: "Indicates if the organization is currently open",
|
|
69
|
-
}),
|
|
70
|
-
defaultLocale: locale,
|
|
71
|
-
supportedLocales: z.array(locale).openapi({
|
|
72
|
-
description: "List of supported locales for the organization",
|
|
73
|
-
}),
|
|
74
|
-
openingTimes: TimeScheduleSchema.optional(),
|
|
75
|
-
closingTimes: TimeScheduleSchema.optional(),
|
|
76
|
-
facebookProfile: z.string().nullable().optional().openapi({
|
|
77
|
-
example: "https://www.facebook.com/example",
|
|
78
|
-
description: "Facebook profile URL for the organization",
|
|
79
|
-
}),
|
|
80
|
-
instagramProfile: z.string().nullable().optional().openapi({
|
|
81
|
-
example: "https://www.instagram.com/example",
|
|
82
|
-
description: "Instagram profile URL for the organization",
|
|
83
|
-
}),
|
|
84
|
-
xProfile: z.string().nullable().optional().openapi({
|
|
85
|
-
example: "https://www.x.com/example",
|
|
86
|
-
description: "X profile URL for the organization",
|
|
87
|
-
}),
|
|
88
|
-
defaultCurrency: currency.openapi({
|
|
89
|
-
example: "USD",
|
|
90
|
-
description: "Default currency for the organization",
|
|
91
|
-
}),
|
|
92
|
-
createdAt: z.date().openapi({
|
|
93
|
-
description: "Timestamp when the organization configuration was created",
|
|
94
|
-
}),
|
|
95
|
-
})
|
|
96
|
-
.openapi("OrganizationConfiguration");
|
|
97
|
-
export const UpdateOrganizationConfigurationSchema = OrganizationConfigurationSchema.pick({
|
|
98
|
-
hostname: true,
|
|
99
|
-
countriesShipping: true,
|
|
100
|
-
stripeAccountId: true,
|
|
101
|
-
enableHostCheckout: true,
|
|
102
|
-
enableHostTracking: true,
|
|
103
|
-
isAcceptingOrders: true,
|
|
104
|
-
defaultLocale: true,
|
|
105
|
-
supportedLocales: true,
|
|
106
|
-
defaultCurrency: true,
|
|
107
|
-
openingTimes: true,
|
|
108
|
-
closingTimes: true,
|
|
109
|
-
facebookProfile: true,
|
|
110
|
-
instagramProfile: true,
|
|
111
|
-
xProfile: true,
|
|
112
|
-
})
|
|
113
|
-
.partial()
|
|
114
|
-
.openapi("UpdateOrganizationConfiguration");
|
|
115
|
-
//# sourceMappingURL=organization-configuration.schema.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";import{currency as o}from"../../schemas/currency.schema";import{locale as i}from"../../schemas/locales.schema";export const TimeScheduleSchema=e.object({monday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Monday"}),tuesday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Tuesday"}),wednesday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Wednesday"}),thursday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Thursday"}),friday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Friday"}),saturday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Saturday"}),sunday:e.string().nullable().openapi({example:"09:00",description:"Opening time for Sunday"})}).openapi("TimeSchedule"),OrganizationConfigurationSchema=e.object({id:e.string().openapi({example:"clm1234567890abcdef",description:"Unique identifier for the organization configuration"}),hostname:e.coerce.string().optional().openapi({example:"store.example.com",description:"Hostname associated with the organization"}),countriesShipping:e.array(e.string()).openapi({example:["US","CA"],description:"List of countries where shipping is available"}),stripeAccountId:e.coerce.string().optional().openapi({example:"acct_123456789",description:"Stripe account ID associated with the organization"}),enableHostCheckout:e.boolean().openapi({example:!0,description:"Indicates if host checkout is enabled"}),enableHostTracking:e.boolean().openapi({example:!0,description:"Indicates if host tracking is enabled"}),isAcceptingOrders:e.boolean().openapi({example:!0,description:"Indicates if the organization is currently accepting orders"}),isOpen:e.boolean().default(!1).openapi({example:!0,description:"Indicates if the organization is currently open"}),defaultLocale:i,supportedLocales:e.array(i).openapi({description:"List of supported locales for the organization"}),openingTimes:TimeScheduleSchema.optional(),closingTimes:TimeScheduleSchema.optional(),facebookProfile:e.string().nullable().optional().openapi({example:"https://www.facebook.com/example",description:"Facebook profile URL for the organization"}),instagramProfile:e.string().nullable().optional().openapi({example:"https://www.instagram.com/example",description:"Instagram profile URL for the organization"}),xProfile:e.string().nullable().optional().openapi({example:"https://www.x.com/example",description:"X profile URL for the organization"}),defaultCurrency:o.openapi({example:"USD",description:"Default currency for the organization"}),createdAt:e.date().openapi({description:"Timestamp when the organization configuration was created"})}).openapi("OrganizationConfiguration"),UpdateOrganizationConfigurationSchema=OrganizationConfigurationSchema.pick({hostname:!0,countriesShipping:!0,stripeAccountId:!0,enableHostCheckout:!0,enableHostTracking:!0,isAcceptingOrders:!0,defaultLocale:!0,supportedLocales:!0,defaultCurrency:!0,openingTimes:!0,closingTimes:!0,facebookProfile:!0,instagramProfile:!0,xProfile:!0}).partial().openapi("UpdateOrganizationConfiguration");
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createApiRouter } from "../../core/hono/hono";
|
|
3
|
-
import { organizationRoute } from "./organization.route";
|
|
4
|
-
import { OrganizationService } from "./organization.service";
|
|
5
|
-
export const buildOrganizationHandler = (prisma, googleMapsApiKey) => {
|
|
6
|
-
const app = createApiRouter();
|
|
7
|
-
app.openapi(organizationRoute.getOrganizations, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
const auth = c.get("auth");
|
|
9
|
-
const query = c.req.valid("query");
|
|
10
|
-
const user = yield auth.getCurrentUser();
|
|
11
|
-
const service = new OrganizationService(prisma, googleMapsApiKey);
|
|
12
|
-
const result = yield service.getOrganizations(user.id, query);
|
|
13
|
-
return c.json(result, 200);
|
|
14
|
-
}));
|
|
15
|
-
app.openapi(organizationRoute.getOrganization, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const params = c.req.valid("param");
|
|
17
|
-
const service = new OrganizationService(prisma, googleMapsApiKey);
|
|
18
|
-
const organization = yield service.getOrganization(params.organizationId);
|
|
19
|
-
return c.json(organization, 200);
|
|
20
|
-
}));
|
|
21
|
-
app.openapi(organizationRoute.createOrganization, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
const auth = c.get("auth");
|
|
23
|
-
const body = c.req.valid("json");
|
|
24
|
-
const user = yield auth.getCurrentUser();
|
|
25
|
-
const service = new OrganizationService(prisma, googleMapsApiKey);
|
|
26
|
-
const organization = yield service.createOrganization(user.id, body);
|
|
27
|
-
return c.json(organization, 201);
|
|
28
|
-
}));
|
|
29
|
-
app.openapi(organizationRoute.updateOrganization, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const auth = c.get("auth");
|
|
31
|
-
const params = c.req.valid("param");
|
|
32
|
-
const body = c.req.valid("json");
|
|
33
|
-
const user = yield auth.isGranted("update");
|
|
34
|
-
const service = new OrganizationService(prisma, googleMapsApiKey);
|
|
35
|
-
const organization = yield service.updateOrganization(params.organizationId, user.id, body);
|
|
36
|
-
return c.json(organization, 200);
|
|
37
|
-
}));
|
|
38
|
-
app.openapi(organizationRoute.deleteOrganization, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
const auth = c.get("auth");
|
|
40
|
-
const params = c.req.valid("param");
|
|
41
|
-
const user = yield auth.isGranted("delete");
|
|
42
|
-
const service = new OrganizationService(prisma, googleMapsApiKey);
|
|
43
|
-
yield service.deleteOrganization(params.organizationId, user.id);
|
|
44
|
-
return c.body(null, 204);
|
|
45
|
-
}));
|
|
46
|
-
return app;
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=organization.handler.js.map
|
|
1
|
+
import{__awaiter as d}from"tslib";import{createApiRouter as l}from"../../core/hono/hono";import{organizationRoute as s}from"./organization.route";import{OrganizationService as u}from"./organization.service";export const buildOrganizationHandler=(r,a)=>{const o=l();return o.openapi(s.getOrganizations,n=>d(void 0,void 0,void 0,function*(){const t=n.get("auth"),e=n.req.valid("query"),i=yield t.getCurrentUser(),v=yield new u(r,a).getOrganizations(i.id,e);return n.json(v,200)})),o.openapi(s.getOrganization,n=>d(void 0,void 0,void 0,function*(){const t=n.req.valid("param"),i=yield new u(r,a).getOrganization(t.organizationId);return n.json(i,200)})),o.openapi(s.createOrganization,n=>d(void 0,void 0,void 0,function*(){const t=n.get("auth"),e=n.req.valid("json"),i=yield t.getCurrentUser(),v=yield new u(r,a).createOrganization(i.id,e);return n.json(v,201)})),o.openapi(s.updateOrganization,n=>d(void 0,void 0,void 0,function*(){const t=n.get("auth"),e=n.req.valid("param"),i=n.req.valid("json"),c=yield t.isGranted("update"),g=yield new u(r,a).updateOrganization(e.organizationId,c.id,i);return n.json(g,200)})),o.openapi(s.deleteOrganization,n=>d(void 0,void 0,void 0,function*(){const t=n.get("auth"),e=n.req.valid("param"),i=yield t.isGranted("delete");return yield new u(r,a).deleteOrganization(e.organizationId,i.id),n.body(null,204)})),o};
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createApiRoute } from "../../core/hono/hono";
|
|
3
|
-
import { CreateOrganizationSchema, ErrorSchema, HeaderSchema, OrganizationParams, OrganizationSchema, PaginationMetaSchema, PaginationQuerySchema, UpdateOrganizationSchema, } from "../../schemas";
|
|
4
|
-
const getOrganizationsRoute = createApiRoute({
|
|
5
|
-
description: "Fetches a paginated list of organizations",
|
|
6
|
-
headers: HeaderSchema,
|
|
7
|
-
method: "GET",
|
|
8
|
-
operationId: "getOrganizations",
|
|
9
|
-
path: "/organizations",
|
|
10
|
-
query: PaginationQuerySchema,
|
|
11
|
-
responses: {
|
|
12
|
-
200: z.object({
|
|
13
|
-
list: z.array(OrganizationSchema),
|
|
14
|
-
meta: PaginationMetaSchema,
|
|
15
|
-
}),
|
|
16
|
-
},
|
|
17
|
-
summary: "Get Organizations",
|
|
18
|
-
tags: ["Organization"],
|
|
19
|
-
});
|
|
20
|
-
const getOrganizationRoute = createApiRoute({
|
|
21
|
-
description: "Fetches a specific organization by ID",
|
|
22
|
-
headers: HeaderSchema,
|
|
23
|
-
method: "GET",
|
|
24
|
-
operationId: "getOrganization",
|
|
25
|
-
path: "/organizations/:organizationId",
|
|
26
|
-
pathParams: OrganizationParams,
|
|
27
|
-
responses: {
|
|
28
|
-
200: OrganizationSchema,
|
|
29
|
-
404: ErrorSchema,
|
|
30
|
-
},
|
|
31
|
-
summary: "Get Organization",
|
|
32
|
-
tags: ["Organization"],
|
|
33
|
-
});
|
|
34
|
-
const createOrganizationRoute = createApiRoute({
|
|
35
|
-
body: CreateOrganizationSchema,
|
|
36
|
-
description: "Creates a new organization",
|
|
37
|
-
headers: HeaderSchema,
|
|
38
|
-
method: "POST",
|
|
39
|
-
operationId: "createOrganization",
|
|
40
|
-
path: "/organizations",
|
|
41
|
-
responses: {
|
|
42
|
-
201: OrganizationSchema,
|
|
43
|
-
400: ErrorSchema,
|
|
44
|
-
},
|
|
45
|
-
summary: "Create Organization",
|
|
46
|
-
tags: ["Organization"],
|
|
47
|
-
});
|
|
48
|
-
const updateOrganizationRoute = createApiRoute({
|
|
49
|
-
body: UpdateOrganizationSchema,
|
|
50
|
-
description: "Updates a specific organization by ID",
|
|
51
|
-
headers: HeaderSchema,
|
|
52
|
-
method: "PATCH",
|
|
53
|
-
operationId: "updateOrganization",
|
|
54
|
-
path: "/organizations/:organizationId",
|
|
55
|
-
pathParams: OrganizationParams,
|
|
56
|
-
responses: {
|
|
57
|
-
200: OrganizationSchema,
|
|
58
|
-
404: ErrorSchema,
|
|
59
|
-
},
|
|
60
|
-
summary: "Update Organization",
|
|
61
|
-
tags: ["Organization"],
|
|
62
|
-
});
|
|
63
|
-
const deleteOrganizationRoute = createApiRoute({
|
|
64
|
-
description: "Deletes a specific organization by ID",
|
|
65
|
-
headers: HeaderSchema,
|
|
66
|
-
method: "DELETE",
|
|
67
|
-
operationId: "deleteOrganization",
|
|
68
|
-
path: "/organizations/:organizationId",
|
|
69
|
-
pathParams: OrganizationParams,
|
|
70
|
-
responses: {
|
|
71
|
-
204: null,
|
|
72
|
-
404: ErrorSchema,
|
|
73
|
-
},
|
|
74
|
-
summary: "Delete Organization",
|
|
75
|
-
tags: ["Organization"],
|
|
76
|
-
});
|
|
77
|
-
export const organizationRoute = {
|
|
78
|
-
getOrganizations: getOrganizationsRoute,
|
|
79
|
-
getOrganization: getOrganizationRoute,
|
|
80
|
-
createOrganization: createOrganizationRoute,
|
|
81
|
-
updateOrganization: updateOrganizationRoute,
|
|
82
|
-
deleteOrganization: deleteOrganizationRoute,
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=organization.route.js.map
|
|
1
|
+
import{z as o}from"@hono/zod-openapi";import{createApiRoute as a}from"../../core/hono/hono";import{CreateOrganizationSchema as r,ErrorSchema as i,HeaderSchema as t,OrganizationParams as e,OrganizationSchema as n,PaginationMetaSchema as s,PaginationQuerySchema as g,UpdateOrganizationSchema as z}from"../../schemas";const p=a({description:"Fetches a paginated list of organizations",headers:t,method:"GET",operationId:"getOrganizations",path:"/organizations",query:g,responses:{200:o.object({list:o.array(n),meta:s})},summary:"Get Organizations",tags:["Organization"]}),d=a({description:"Fetches a specific organization by ID",headers:t,method:"GET",operationId:"getOrganization",path:"/organizations/:organizationId",pathParams:e,responses:{200:n,404:i},summary:"Get Organization",tags:["Organization"]}),m=a({body:r,description:"Creates a new organization",headers:t,method:"POST",operationId:"createOrganization",path:"/organizations",responses:{201:n,400:i},summary:"Create Organization",tags:["Organization"]}),c=a({body:z,description:"Updates a specific organization by ID",headers:t,method:"PATCH",operationId:"updateOrganization",path:"/organizations/:organizationId",pathParams:e,responses:{200:n,404:i},summary:"Update Organization",tags:["Organization"]}),O=a({description:"Deletes a specific organization by ID",headers:t,method:"DELETE",operationId:"deleteOrganization",path:"/organizations/:organizationId",pathParams:e,responses:{204:null,404:i},summary:"Delete Organization",tags:["Organization"]});export const organizationRoute={getOrganizations:p,getOrganization:d,createOrganization:m,updateOrganization:c,deleteOrganization:O};
|
|
@@ -1,64 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AddressSchema, CreateAddressSchema, UpdateAddressSchema, } from "../../schemas/address.schema";
|
|
3
|
-
import { FileSchema } from "../file/file.schema";
|
|
4
|
-
import { OrganizationConfigurationSchema, UpdateOrganizationConfigurationSchema, } from "./organization-configuration.schema";
|
|
5
|
-
export const OrganizationSchema = z
|
|
6
|
-
.object({
|
|
7
|
-
id: z.string().openapi({
|
|
8
|
-
example: "clm1234567890abcdef",
|
|
9
|
-
description: "The unique identifier of the organization",
|
|
10
|
-
}),
|
|
11
|
-
name: z.string().openapi({
|
|
12
|
-
example: "Acme Store",
|
|
13
|
-
description: "The name of the organization",
|
|
14
|
-
}),
|
|
15
|
-
phone: z.string().min(1, "Phone number is required").openapi({
|
|
16
|
-
example: "+48123456890",
|
|
17
|
-
description: "The phone number of the organization",
|
|
18
|
-
}),
|
|
19
|
-
email: z.string().email().optional().openapi({
|
|
20
|
-
example: "john.doe@example.com",
|
|
21
|
-
description: "The email address of the organization",
|
|
22
|
-
}),
|
|
23
|
-
createdAt: z.date().openapi({
|
|
24
|
-
example: "2022-01-01T00:00:00.000Z",
|
|
25
|
-
description: "The date and time the organization was created",
|
|
26
|
-
}),
|
|
27
|
-
legalEntityId: z.string().nullable().openapi({
|
|
28
|
-
example: "clm1234567890abcdef",
|
|
29
|
-
description: "The unique identifier of the legal entity associated with the organization",
|
|
30
|
-
}),
|
|
31
|
-
address: AddressSchema,
|
|
32
|
-
configuration: OrganizationConfigurationSchema.openapi({
|
|
33
|
-
description: "The configuration settings for the organization",
|
|
34
|
-
}),
|
|
35
|
-
logo: z.string().url().optional().nullable().openapi({
|
|
36
|
-
example: "https://example.com/logo.jpg",
|
|
37
|
-
description: "The logo of the organization",
|
|
38
|
-
}),
|
|
39
|
-
logoFile: FileSchema.optional().nullable().openapi({
|
|
40
|
-
description: "The logo of the organization",
|
|
41
|
-
}),
|
|
42
|
-
})
|
|
43
|
-
.openapi("Organization");
|
|
44
|
-
export const CreateOrganizationSchema = OrganizationSchema.pick({
|
|
45
|
-
name: true,
|
|
46
|
-
phone: true,
|
|
47
|
-
email: true,
|
|
48
|
-
logoFile: true,
|
|
49
|
-
})
|
|
50
|
-
.extend({
|
|
51
|
-
logoId: z.string().optional().nullable().openapi({
|
|
52
|
-
example: "clm1234567890abcdef",
|
|
53
|
-
description: "The unique identifier of the thumbnail image associated with the organization",
|
|
54
|
-
}),
|
|
55
|
-
address: CreateAddressSchema,
|
|
56
|
-
})
|
|
57
|
-
.openapi("CreateOrganization");
|
|
58
|
-
export const UpdateOrganizationSchema = CreateOrganizationSchema.extend({
|
|
59
|
-
address: UpdateAddressSchema,
|
|
60
|
-
configuration: UpdateOrganizationConfigurationSchema,
|
|
61
|
-
})
|
|
62
|
-
.partial()
|
|
63
|
-
.openapi("UpdateOrganization");
|
|
64
|
-
//# sourceMappingURL=organization.schema.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";import{AddressSchema as i,CreateAddressSchema as a,UpdateAddressSchema as o}from"../../schemas/address.schema";import{FileSchema as n}from"../file/file.schema";import{OrganizationConfigurationSchema as t,UpdateOrganizationConfigurationSchema as r}from"./organization-configuration.schema";export const OrganizationSchema=e.object({id:e.string().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the organization"}),name:e.string().openapi({example:"Acme Store",description:"The name of the organization"}),phone:e.string().min(1,"Phone number is required").openapi({example:"+48123456890",description:"The phone number of the organization"}),email:e.string().email().optional().openapi({example:"john.doe@example.com",description:"The email address of the organization"}),createdAt:e.date().openapi({example:"2022-01-01T00:00:00.000Z",description:"The date and time the organization was created"}),legalEntityId:e.string().nullable().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the legal entity associated with the organization"}),address:i,configuration:t.openapi({description:"The configuration settings for the organization"}),logo:e.string().url().optional().nullable().openapi({example:"https://example.com/logo.jpg",description:"The logo of the organization"}),logoFile:n.optional().nullable().openapi({description:"The logo of the organization"})}).openapi("Organization"),CreateOrganizationSchema=OrganizationSchema.pick({name:!0,phone:!0,email:!0,logoFile:!0}).extend({logoId:e.string().optional().nullable().openapi({example:"clm1234567890abcdef",description:"The unique identifier of the thumbnail image associated with the organization"}),address:a}).openapi("CreateOrganization"),UpdateOrganizationSchema=CreateOrganizationSchema.extend({address:o,configuration:r}).partial().openapi("UpdateOrganization");
|