@shophost/rest-api 2.0.29 → 2.0.31
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/package.json +18 -13
- package/scripts/minify.mjs +110 -0
- package/src/app.js +1 -53
- 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.d.ts +0 -3
- 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.d.ts +0 -128
- package/src/core/db/__generated__/client/browser.js +1 -18
- package/src/core/db/__generated__/client/client.d.ts +0 -143
- 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.d.ts +0 -343
- package/src/core/db/__generated__/client/internal/class.js +1 -55
- package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +0 -234
- package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.d.ts +0 -15
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
- package/src/core/db/__generated__/client/models/Account.d.ts +0 -628
- package/src/core/db/__generated__/client/models/Account.js +1 -2
- package/src/core/db/__generated__/client/models/Address.d.ts +0 -701
- package/src/core/db/__generated__/client/models/Address.js +1 -2
- package/src/core/db/__generated__/client/models/Campaign.d.ts +0 -638
- package/src/core/db/__generated__/client/models/Campaign.js +1 -2
- package/src/core/db/__generated__/client/models/ClosingTimes.d.ts +0 -634
- package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
- package/src/core/db/__generated__/client/models/File.d.ts +0 -752
- package/src/core/db/__generated__/client/models/File.js +1 -2
- package/src/core/db/__generated__/client/models/Invitation.d.ts +0 -628
- package/src/core/db/__generated__/client/models/Invitation.js +1 -2
- package/src/core/db/__generated__/client/models/LegalEntity.d.ts +0 -652
- package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
- package/src/core/db/__generated__/client/models/Manufacturer.d.ts +0 -679
- package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.d.ts +0 -628
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Member.d.ts +0 -628
- package/src/core/db/__generated__/client/models/Member.js +1 -2
- package/src/core/db/__generated__/client/models/Modifier.d.ts +0 -662
- package/src/core/db/__generated__/client/models/Modifier.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroup.d.ts +0 -686
- package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.d.ts +0 -628
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/OpeningTimes.d.ts +0 -634
- package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
- package/src/core/db/__generated__/client/models/Order.d.ts +0 -700
- package/src/core/db/__generated__/client/models/Order.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItem.d.ts +0 -686
- package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItemTranslation.d.ts +0 -628
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Organization.d.ts +0 -811
- package/src/core/db/__generated__/client/models/Organization.js +1 -2
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +0 -676
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
- package/src/core/db/__generated__/client/models/Payment.d.ts +0 -668
- package/src/core/db/__generated__/client/models/Payment.js +1 -2
- package/src/core/db/__generated__/client/models/PaymentSession.d.ts +0 -638
- package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
- package/src/core/db/__generated__/client/models/Product.d.ts +0 -746
- package/src/core/db/__generated__/client/models/Product.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategory.d.ts +0 -689
- package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.d.ts +0 -628
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/ProductSnapshot.d.ts +0 -664
- package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
- package/src/core/db/__generated__/client/models/ProductTranslation.d.ts +0 -628
- package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Reservation.d.ts +0 -650
- package/src/core/db/__generated__/client/models/Reservation.js +1 -2
- package/src/core/db/__generated__/client/models/Session.d.ts +0 -628
- package/src/core/db/__generated__/client/models/Session.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingMethod.d.ts +0 -679
- package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingZone.d.ts +0 -638
- package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
- package/src/core/db/__generated__/client/models/User.d.ts +0 -736
- package/src/core/db/__generated__/client/models/User.js +1 -2
- package/src/core/db/__generated__/client/models/Verification.d.ts +0 -592
- 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/exceptions/http-exception.js +1 -9
- package/src/core/hono/hono.js +1 -123
- package/src/core/lib/prisma.d.ts +9 -1
- package/src/core/lib/prisma.js +1 -11
- package/src/core/logging/pino.js +1 -5
- package/src/core/notifications/email.service.d.ts +0 -15
- 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.d.ts +0 -10
- package/src/core/utils/object.util.js +1 -39
- package/src/core/utils/translations.util.js +0 -2
- package/src/core/utils/zod.util.d.ts +0 -12
- 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/cart/cart.handler.js +1 -17
- package/src/features/cart/cart.route.js +1 -32
- package/src/features/cart/cart.schema.js +1 -39
- package/src/features/cart/cart.service.d.ts +0 -7
- 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.d.ts +0 -6
- 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.js +1 -16
- 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.d.ts +0 -3
- 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.d.ts +0 -19
- 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-notification.email.js +1 -229
- 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.js +1 -158
- package/src/features/order/order.service.d.ts +0 -15
- 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.d.ts +0 -15
- 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.js +1 -46
- 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.js +1 -143
- package/src/features/product/product.service.d.ts +0 -25
- 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.d.ts +0 -22
- 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-confirmation.email.js +1 -82
- package/src/features/reservation/emails/reservation-notification.email.js +1 -93
- package/src/features/reservation/reservation.handler.js +1 -65
- package/src/features/reservation/reservation.route.js +1 -167
- package/src/features/reservation/reservation.schema.js +1 -51
- package/src/features/reservation/reservation.service.d.ts +0 -18
- 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.d.ts +0 -7
- 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.d.ts +0 -25
- 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.d.ts +0 -8
- package/src/schemas/address.schema.js +1 -112
- package/src/schemas/currency.schema.d.ts +0 -42
- package/src/schemas/currency.schema.js +1 -118
- package/src/schemas/error.schema.js +1 -12
- package/src/schemas/index.js +1 -29
- 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.d.ts +1 -0
- package/src/test/global-setup.js +1 -0
- package/src/test/integration/api-fixtures.d.ts +4 -16
- package/src/test/integration/api-fixtures.js +1 -225
- package/src/test/integration/seed.d.ts +81 -0
- package/src/test/integration/seed.js +1 -0
- package/src/test/integration/test-helpers.d.ts +107 -924
- package/src/test/integration/test-helpers.js +1 -1100
- package/src/test/setup-test-env.d.ts +1 -1
- package/src/test/setup-test-env.js +1 -29
- package/src/app.js.map +0 -1
- package/src/core/auth/auth.schema.js.map +0 -1
- package/src/core/auth/auth.util.js.map +0 -1
- package/src/core/auth/better-auth.lib.js.map +0 -1
- package/src/core/auth/generate-password-hash.util.js.map +0 -1
- package/src/core/auth/headers.schema.js.map +0 -1
- package/src/core/auth/user.schema.js.map +0 -1
- package/src/core/db/__generated__/client/browser.js.map +0 -1
- package/src/core/db/__generated__/client/client.js.map +0 -1
- package/src/core/db/__generated__/client/commonInputTypes.js.map +0 -1
- package/src/core/db/__generated__/client/enums.js.map +0 -1
- package/src/core/db/__generated__/client/internal/class.js.map +0 -1
- package/src/core/db/__generated__/client/internal/prismaNamespace.js.map +0 -1
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js.map +0 -1
- package/src/core/db/__generated__/client/models/Account.js.map +0 -1
- package/src/core/db/__generated__/client/models/Address.js.map +0 -1
- package/src/core/db/__generated__/client/models/Campaign.js.map +0 -1
- package/src/core/db/__generated__/client/models/ClosingTimes.js.map +0 -1
- package/src/core/db/__generated__/client/models/File.js.map +0 -1
- package/src/core/db/__generated__/client/models/Invitation.js.map +0 -1
- package/src/core/db/__generated__/client/models/LegalEntity.js.map +0 -1
- package/src/core/db/__generated__/client/models/Manufacturer.js.map +0 -1
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Member.js.map +0 -1
- package/src/core/db/__generated__/client/models/Modifier.js.map +0 -1
- package/src/core/db/__generated__/client/models/ModifierGroup.js.map +0 -1
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/OpeningTimes.js.map +0 -1
- package/src/core/db/__generated__/client/models/Order.js.map +0 -1
- package/src/core/db/__generated__/client/models/OrderItem.js.map +0 -1
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Organization.js.map +0 -1
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js.map +0 -1
- package/src/core/db/__generated__/client/models/Payment.js.map +0 -1
- package/src/core/db/__generated__/client/models/PaymentSession.js.map +0 -1
- package/src/core/db/__generated__/client/models/Product.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductCategory.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductSnapshot.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Reservation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Session.js.map +0 -1
- package/src/core/db/__generated__/client/models/ShippingMethod.js.map +0 -1
- package/src/core/db/__generated__/client/models/ShippingZone.js.map +0 -1
- package/src/core/db/__generated__/client/models/User.js.map +0 -1
- package/src/core/db/__generated__/client/models/Verification.js.map +0 -1
- package/src/core/db/__generated__/client/models.js.map +0 -1
- package/src/core/db/index.js.map +0 -1
- package/src/core/exceptions/http-exception.js.map +0 -1
- package/src/core/hono/hono.js.map +0 -1
- package/src/core/lib/prisma.js.map +0 -1
- package/src/core/logging/pino.js.map +0 -1
- package/src/core/notifications/email.service.js.map +0 -1
- package/src/core/openapi/openapi.lib.js.map +0 -1
- package/src/core/types/google-maps.types.js.map +0 -1
- package/src/core/utils/currency.util.js.map +0 -1
- package/src/core/utils/env.util.js.map +0 -1
- package/src/core/utils/object.util.js.map +0 -1
- package/src/core/utils/translations.util.js.map +0 -1
- package/src/core/utils/zod.util.js.map +0 -1
- package/src/db.js.map +0 -1
- package/src/features/access/access.handler.js.map +0 -1
- package/src/features/access/access.route.js.map +0 -1
- package/src/features/access/access.schema.js.map +0 -1
- package/src/features/access/access.service.js.map +0 -1
- package/src/features/cart/cart.handler.js.map +0 -1
- package/src/features/cart/cart.route.js.map +0 -1
- package/src/features/cart/cart.schema.js.map +0 -1
- package/src/features/cart/cart.service.js.map +0 -1
- package/src/features/cart/cart.util.js.map +0 -1
- package/src/features/file/file.handler.js.map +0 -1
- package/src/features/file/file.route.js.map +0 -1
- package/src/features/file/file.schema.js.map +0 -1
- package/src/features/file/file.service.js.map +0 -1
- package/src/features/health/health.handler.js.map +0 -1
- package/src/features/health/health.route.js.map +0 -1
- package/src/features/index.js.map +0 -1
- package/src/features/location/location.handler.js.map +0 -1
- package/src/features/location/location.route.js.map +0 -1
- package/src/features/location/location.schema.js.map +0 -1
- package/src/features/location/location.service.js.map +0 -1
- package/src/features/manufacturer/manufacturer.handler.js.map +0 -1
- package/src/features/manufacturer/manufacturer.route.js.map +0 -1
- package/src/features/manufacturer/manufacturer.schema.js.map +0 -1
- package/src/features/manufacturer/manufacturer.service.js.map +0 -1
- package/src/features/order/emails/order-confirmation.email.js.map +0 -1
- package/src/features/order/emails/order-notification.email.js.map +0 -1
- package/src/features/order/fulfilment.schema.js.map +0 -1
- package/src/features/order/order.handler.js.map +0 -1
- package/src/features/order/order.route.js.map +0 -1
- package/src/features/order/order.schema.js.map +0 -1
- package/src/features/order/order.service.js.map +0 -1
- package/src/features/order/recipient.schema.js.map +0 -1
- package/src/features/organization/legal-entity.schema.js.map +0 -1
- package/src/features/organization/organization-configuration.schema.js.map +0 -1
- package/src/features/organization/organization.handler.js.map +0 -1
- package/src/features/organization/organization.route.js.map +0 -1
- package/src/features/organization/organization.schema.js.map +0 -1
- package/src/features/organization/organization.service.js.map +0 -1
- package/src/features/payment/payment.handler.js.map +0 -1
- package/src/features/payment/payment.route.js.map +0 -1
- package/src/features/payment/payment.schema.js.map +0 -1
- package/src/features/payment/payment.service.js.map +0 -1
- package/src/features/payment/stripe.service.js.map +0 -1
- package/src/features/product/product-modifier.schema.js.map +0 -1
- package/src/features/product/product.handler.js.map +0 -1
- package/src/features/product/product.route.js.map +0 -1
- package/src/features/product/product.schema.js.map +0 -1
- package/src/features/product/product.service.js.map +0 -1
- package/src/features/product-category/product-category.handler.js.map +0 -1
- package/src/features/product-category/product-category.route.js.map +0 -1
- package/src/features/product-category/product-category.schema.js.map +0 -1
- package/src/features/product-category/product-category.service.js.map +0 -1
- package/src/features/reservation/emails/reservation-cancellation.email.js.map +0 -1
- package/src/features/reservation/emails/reservation-confirmation.email.js.map +0 -1
- package/src/features/reservation/emails/reservation-notification.email.js.map +0 -1
- package/src/features/reservation/reservation.handler.js.map +0 -1
- package/src/features/reservation/reservation.route.js.map +0 -1
- package/src/features/reservation/reservation.schema.js.map +0 -1
- package/src/features/reservation/reservation.service.js.map +0 -1
- package/src/features/shipping/shipping.handler.js.map +0 -1
- package/src/features/shipping/shipping.route.js.map +0 -1
- package/src/features/shipping/shipping.service.js.map +0 -1
- package/src/features/shipping-method/shipping-method.handler.js.map +0 -1
- package/src/features/shipping-method/shipping-method.route.js.map +0 -1
- package/src/features/shipping-method/shipping-method.schema.js.map +0 -1
- package/src/features/shipping-method/shipping-method.service.js.map +0 -1
- package/src/features/shipping-method/shipping-zone.schema.js.map +0 -1
- package/src/features/webhook/webhook.handler.js.map +0 -1
- package/src/features/webhook/webhook.route.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/integrations/next.js.map +0 -1
- package/src/schemas/address.schema.js.map +0 -1
- package/src/schemas/currency.schema.js.map +0 -1
- package/src/schemas/error.schema.js.map +0 -1
- package/src/schemas/index.js.map +0 -1
- package/src/schemas/locales.schema.js.map +0 -1
- package/src/schemas/number.schema.js.map +0 -1
- package/src/schemas/pagination.schema.js.map +0 -1
- package/src/schemas/params.schema.js.map +0 -1
- package/src/schemas/queries.schema.js.map +0 -1
- package/src/test/integration/api-fixtures.js.map +0 -1
- package/src/test/integration/test-helpers.js.map +0 -1
- package/src/test/setup-test-env.js.map +0 -1
|
@@ -1,91 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createApiRouter } from "../../core/hono/hono";
|
|
3
|
-
import { accessRoute } from "./access.route";
|
|
4
|
-
import { AccessService } from "./access.service";
|
|
5
|
-
export const buildAccessHandler = (prisma) => {
|
|
6
|
-
const app = createApiRouter();
|
|
7
|
-
app.openapi(accessRoute.getMembers, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
const auth = c.get("auth");
|
|
9
|
-
const params = c.req.valid("param");
|
|
10
|
-
const query = c.req.valid("query");
|
|
11
|
-
yield auth.isGranted("read");
|
|
12
|
-
const service = new AccessService(prisma);
|
|
13
|
-
const result = yield service.getMembers(params.organizationId, Object.assign({}, query));
|
|
14
|
-
return c.json(result, 200);
|
|
15
|
-
}));
|
|
16
|
-
app.openapi(accessRoute.getMember, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
const auth = c.get("auth");
|
|
18
|
-
const params = c.req.valid("param");
|
|
19
|
-
yield auth.isGranted("read");
|
|
20
|
-
const service = new AccessService(prisma);
|
|
21
|
-
const member = yield service.getMember(params.organizationId, params.memberId);
|
|
22
|
-
return c.json(member, 200);
|
|
23
|
-
}));
|
|
24
|
-
app.openapi(accessRoute.updateMemberRole, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
const auth = c.get("auth");
|
|
26
|
-
const params = c.req.valid("param");
|
|
27
|
-
const body = c.req.valid("json");
|
|
28
|
-
const user = yield auth.isGranted("update");
|
|
29
|
-
const service = new AccessService(prisma);
|
|
30
|
-
const updated = yield service.updateMemberRole(params.organizationId, params.memberId, user.id, body);
|
|
31
|
-
return c.json(updated, 200);
|
|
32
|
-
}));
|
|
33
|
-
app.openapi(accessRoute.deleteMember, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const auth = c.get("auth");
|
|
35
|
-
const params = c.req.valid("param");
|
|
36
|
-
const user = yield auth.isGranted("delete");
|
|
37
|
-
const service = new AccessService(prisma);
|
|
38
|
-
yield service.deleteMember(params.organizationId, params.memberId, user.id);
|
|
39
|
-
return c.body(null, 204);
|
|
40
|
-
}));
|
|
41
|
-
app.openapi(accessRoute.createInvitation, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
const auth = c.get("auth");
|
|
43
|
-
const params = c.req.valid("param");
|
|
44
|
-
const body = c.req.valid("json");
|
|
45
|
-
const user = yield auth.isGranted("create");
|
|
46
|
-
const service = new AccessService(prisma);
|
|
47
|
-
const invitation = yield service.createInvitation(params.organizationId, user.id, body);
|
|
48
|
-
return c.json(invitation, 201);
|
|
49
|
-
}));
|
|
50
|
-
app.openapi(accessRoute.getInvitations, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
const auth = c.get("auth");
|
|
52
|
-
const params = c.req.valid("param");
|
|
53
|
-
yield auth.isGranted("read");
|
|
54
|
-
const service = new AccessService(prisma);
|
|
55
|
-
const invitations = yield service.getInvitations(params.organizationId);
|
|
56
|
-
return c.json(invitations, 200);
|
|
57
|
-
}));
|
|
58
|
-
app.openapi(accessRoute.deleteInvitation, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
-
const auth = c.get("auth");
|
|
60
|
-
const params = c.req.valid("param");
|
|
61
|
-
yield auth.isGranted("delete");
|
|
62
|
-
const service = new AccessService(prisma);
|
|
63
|
-
yield service.deleteInvitation(params.organizationId, params.invitationId);
|
|
64
|
-
return c.body(null, 204);
|
|
65
|
-
}));
|
|
66
|
-
app.openapi(accessRoute.getUserInvitations, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
const auth = c.get("auth");
|
|
68
|
-
const user = yield auth.getCurrentUser();
|
|
69
|
-
const service = new AccessService(prisma);
|
|
70
|
-
const invitations = yield service.getUserInvitations(user.email);
|
|
71
|
-
return c.json(invitations, 200);
|
|
72
|
-
}));
|
|
73
|
-
app.openapi(accessRoute.acceptInvitation, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
const auth = c.get("auth");
|
|
75
|
-
const params = c.req.valid("param");
|
|
76
|
-
const user = yield auth.getCurrentUser();
|
|
77
|
-
const service = new AccessService(prisma);
|
|
78
|
-
const member = yield service.acceptInvitation(params.invitationId, user.id);
|
|
79
|
-
return c.json(member, 200);
|
|
80
|
-
}));
|
|
81
|
-
app.openapi(accessRoute.leaveOrganization, (c) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
const auth = c.get("auth");
|
|
83
|
-
const params = c.req.valid("param");
|
|
84
|
-
const user = yield auth.getCurrentUser();
|
|
85
|
-
const service = new AccessService(prisma);
|
|
86
|
-
yield service.leaveOrganization(params.organizationId, user.id);
|
|
87
|
-
return c.body(null, 204);
|
|
88
|
-
}));
|
|
89
|
-
return app;
|
|
90
|
-
};
|
|
91
|
-
//# sourceMappingURL=access.handler.js.map
|
|
1
|
+
import{__awaiter as e}from"tslib";import{createApiRouter as i}from"../../core/hono/hono";import{accessRoute as n}from"./access.route";import{AccessService as t}from"./access.service";export const buildAccessHandler=o=>{const a=i();return a.openapi(n.getMembers,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param"),a=i.req.valid("query");yield e.isGranted("read");const d=new t(o),r=yield d.getMembers(n.organizationId,Object.assign({},a));return i.json(r,200)})),a.openapi(n.getMember,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param");yield e.isGranted("read");const a=new t(o),d=yield a.getMember(n.organizationId,n.memberId);return i.json(d,200)})),a.openapi(n.updateMemberRole,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param"),a=i.req.valid("json"),d=yield e.isGranted("update"),r=new t(o),v=yield r.updateMemberRole(n.organizationId,n.memberId,d.id,a);return i.json(v,200)})),a.openapi(n.deleteMember,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param"),a=yield e.isGranted("delete"),d=new t(o);return yield d.deleteMember(n.organizationId,n.memberId,a.id),i.body(null,204)})),a.openapi(n.createInvitation,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param"),a=i.req.valid("json"),d=yield e.isGranted("create"),r=new t(o),v=yield r.createInvitation(n.organizationId,d.id,a);return i.json(v,201)})),a.openapi(n.getInvitations,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param");yield e.isGranted("read");const a=new t(o),d=yield a.getInvitations(n.organizationId);return i.json(d,200)})),a.openapi(n.deleteInvitation,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param");yield e.isGranted("delete");const a=new t(o);return yield a.deleteInvitation(n.organizationId,n.invitationId),i.body(null,204)})),a.openapi(n.getUserInvitations,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=yield e.getCurrentUser(),a=new t(o),d=yield a.getUserInvitations(n.email);return i.json(d,200)})),a.openapi(n.acceptInvitation,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param"),a=yield e.getCurrentUser(),d=new t(o),r=yield d.acceptInvitation(n.invitationId,a.id);return i.json(r,200)})),a.openapi(n.leaveOrganization,i=>e(void 0,void 0,void 0,function*(){const e=i.get("auth"),n=i.req.valid("param"),a=yield e.getCurrentUser(),d=new t(o);return yield d.leaveOrganization(n.organizationId,a.id),i.body(null,204)})),a};
|
|
@@ -1,220 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createApiRoute } from "../../core/hono/hono";
|
|
3
|
-
import { ErrorSchema, HeaderSchema, OrganizationParams, PaginationMetaSchema, PaginationQuerySchema, } from "../../schemas";
|
|
4
|
-
import { CreateInvitationSchema, InvitationSchema, MemberSchema, UpdateMemberRoleSchema, UserInvitationSchema, } from "./access.schema";
|
|
5
|
-
const memberPathParams = z.object({
|
|
6
|
-
memberId: z.string().openapi({
|
|
7
|
-
description: "ID of the member",
|
|
8
|
-
example: "clf9876543210abcdef",
|
|
9
|
-
param: {
|
|
10
|
-
in: "path",
|
|
11
|
-
name: "memberId",
|
|
12
|
-
},
|
|
13
|
-
}),
|
|
14
|
-
organizationId: z.string().openapi({
|
|
15
|
-
description: "ID of the organization",
|
|
16
|
-
example: "cju0z9k4z0000l1qg5z1z1z1z",
|
|
17
|
-
param: {
|
|
18
|
-
in: "path",
|
|
19
|
-
name: "organizationId",
|
|
20
|
-
},
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
const getMembersRoute = createApiRoute({
|
|
24
|
-
description: "Fetches a paginated list of members for an organization",
|
|
25
|
-
headers: HeaderSchema,
|
|
26
|
-
method: "GET",
|
|
27
|
-
operationId: "getMembers",
|
|
28
|
-
path: "/:organizationId/access/members",
|
|
29
|
-
pathParams: OrganizationParams,
|
|
30
|
-
query: PaginationQuerySchema,
|
|
31
|
-
responses: {
|
|
32
|
-
200: z.object({
|
|
33
|
-
list: z.array(MemberSchema),
|
|
34
|
-
meta: PaginationMetaSchema,
|
|
35
|
-
}),
|
|
36
|
-
400: ErrorSchema,
|
|
37
|
-
401: ErrorSchema,
|
|
38
|
-
},
|
|
39
|
-
summary: "Get Members",
|
|
40
|
-
tags: ["Access"],
|
|
41
|
-
});
|
|
42
|
-
const getMemberRoute = createApiRoute({
|
|
43
|
-
headers: HeaderSchema,
|
|
44
|
-
method: "GET",
|
|
45
|
-
operationId: "getMember",
|
|
46
|
-
path: "/:organizationId/access/members/:memberId",
|
|
47
|
-
pathParams: memberPathParams,
|
|
48
|
-
responses: {
|
|
49
|
-
200: MemberSchema,
|
|
50
|
-
401: ErrorSchema,
|
|
51
|
-
404: ErrorSchema,
|
|
52
|
-
},
|
|
53
|
-
summary: "Get Member",
|
|
54
|
-
tags: ["Access"],
|
|
55
|
-
});
|
|
56
|
-
const updateMemberRoleRoute = createApiRoute({
|
|
57
|
-
body: UpdateMemberRoleSchema,
|
|
58
|
-
description: "Updates a member's role in the organization",
|
|
59
|
-
headers: HeaderSchema,
|
|
60
|
-
method: "PUT",
|
|
61
|
-
operationId: "updateMemberRole",
|
|
62
|
-
path: "/:organizationId/access/members/:memberId",
|
|
63
|
-
pathParams: memberPathParams,
|
|
64
|
-
responses: {
|
|
65
|
-
200: MemberSchema,
|
|
66
|
-
400: ErrorSchema,
|
|
67
|
-
401: ErrorSchema,
|
|
68
|
-
404: ErrorSchema,
|
|
69
|
-
},
|
|
70
|
-
summary: "Update Member Role",
|
|
71
|
-
tags: ["Access"],
|
|
72
|
-
});
|
|
73
|
-
const deleteMemberRoute = createApiRoute({
|
|
74
|
-
description: "Removes a member from the organization",
|
|
75
|
-
headers: HeaderSchema,
|
|
76
|
-
method: "DELETE",
|
|
77
|
-
operationId: "deleteMember",
|
|
78
|
-
path: "/:organizationId/access/members/:memberId",
|
|
79
|
-
pathParams: memberPathParams,
|
|
80
|
-
responses: {
|
|
81
|
-
204: null,
|
|
82
|
-
400: ErrorSchema,
|
|
83
|
-
401: ErrorSchema,
|
|
84
|
-
404: ErrorSchema,
|
|
85
|
-
},
|
|
86
|
-
summary: "Delete Member",
|
|
87
|
-
tags: ["Access"],
|
|
88
|
-
});
|
|
89
|
-
const createInvitationRoute = createApiRoute({
|
|
90
|
-
body: CreateInvitationSchema,
|
|
91
|
-
description: "Creates a new invitation for the organization",
|
|
92
|
-
headers: HeaderSchema,
|
|
93
|
-
method: "POST",
|
|
94
|
-
operationId: "createInvitation",
|
|
95
|
-
path: "/:organizationId/access/invitations",
|
|
96
|
-
pathParams: OrganizationParams,
|
|
97
|
-
responses: {
|
|
98
|
-
201: InvitationSchema,
|
|
99
|
-
400: ErrorSchema,
|
|
100
|
-
401: ErrorSchema,
|
|
101
|
-
},
|
|
102
|
-
summary: "Create Invitation",
|
|
103
|
-
tags: ["Access"],
|
|
104
|
-
});
|
|
105
|
-
const getInvitationsRoute = createApiRoute({
|
|
106
|
-
description: "Fetches a list of pending invitations for an organization",
|
|
107
|
-
headers: HeaderSchema,
|
|
108
|
-
method: "GET",
|
|
109
|
-
operationId: "getInvitations",
|
|
110
|
-
path: "/:organizationId/access/invitations",
|
|
111
|
-
pathParams: OrganizationParams,
|
|
112
|
-
responses: {
|
|
113
|
-
200: z.array(InvitationSchema),
|
|
114
|
-
401: ErrorSchema,
|
|
115
|
-
},
|
|
116
|
-
summary: "Get Invitations",
|
|
117
|
-
tags: ["Access"],
|
|
118
|
-
});
|
|
119
|
-
const invitationPathParams = z.object({
|
|
120
|
-
invitationId: z.string().openapi({
|
|
121
|
-
description: "ID of the invitation",
|
|
122
|
-
example: "inv_123",
|
|
123
|
-
param: {
|
|
124
|
-
in: "path",
|
|
125
|
-
name: "invitationId",
|
|
126
|
-
},
|
|
127
|
-
}),
|
|
128
|
-
});
|
|
129
|
-
const getUserInvitationsRoute = createApiRoute({
|
|
130
|
-
description: "Fetches pending invitations for the currently authenticated user",
|
|
131
|
-
headers: HeaderSchema,
|
|
132
|
-
method: "GET",
|
|
133
|
-
operationId: "getUserInvitations",
|
|
134
|
-
path: "/access/invitations/me",
|
|
135
|
-
responses: {
|
|
136
|
-
200: z.array(UserInvitationSchema),
|
|
137
|
-
401: ErrorSchema,
|
|
138
|
-
},
|
|
139
|
-
summary: "Get User Invitations",
|
|
140
|
-
tags: ["Access"],
|
|
141
|
-
});
|
|
142
|
-
const acceptInvitationRoute = createApiRoute({
|
|
143
|
-
description: "Accepts a pending invitation and adds the user as a member",
|
|
144
|
-
headers: HeaderSchema,
|
|
145
|
-
method: "POST",
|
|
146
|
-
operationId: "acceptInvitation",
|
|
147
|
-
path: "/access/invitations/:invitationId/accept",
|
|
148
|
-
pathParams: invitationPathParams,
|
|
149
|
-
responses: {
|
|
150
|
-
200: MemberSchema,
|
|
151
|
-
400: ErrorSchema,
|
|
152
|
-
401: ErrorSchema,
|
|
153
|
-
404: ErrorSchema,
|
|
154
|
-
},
|
|
155
|
-
summary: "Accept Invitation",
|
|
156
|
-
tags: ["Access"],
|
|
157
|
-
});
|
|
158
|
-
const deleteInvitationPathParams = z.object({
|
|
159
|
-
invitationId: z.string().openapi({
|
|
160
|
-
description: "ID of the invitation",
|
|
161
|
-
example: "inv_123",
|
|
162
|
-
param: {
|
|
163
|
-
in: "path",
|
|
164
|
-
name: "invitationId",
|
|
165
|
-
},
|
|
166
|
-
}),
|
|
167
|
-
organizationId: z.string().openapi({
|
|
168
|
-
description: "ID of the organization",
|
|
169
|
-
example: "cju0z9k4z0000l1qg5z1z1z1z",
|
|
170
|
-
param: {
|
|
171
|
-
in: "path",
|
|
172
|
-
name: "organizationId",
|
|
173
|
-
},
|
|
174
|
-
}),
|
|
175
|
-
});
|
|
176
|
-
const deleteInvitationRoute = createApiRoute({
|
|
177
|
-
description: "Revokes a pending invitation",
|
|
178
|
-
headers: HeaderSchema,
|
|
179
|
-
method: "DELETE",
|
|
180
|
-
operationId: "deleteInvitation",
|
|
181
|
-
path: "/:organizationId/access/invitations/:invitationId",
|
|
182
|
-
pathParams: deleteInvitationPathParams,
|
|
183
|
-
responses: {
|
|
184
|
-
204: null,
|
|
185
|
-
400: ErrorSchema,
|
|
186
|
-
401: ErrorSchema,
|
|
187
|
-
404: ErrorSchema,
|
|
188
|
-
},
|
|
189
|
-
summary: "Delete Invitation",
|
|
190
|
-
tags: ["Access"],
|
|
191
|
-
});
|
|
192
|
-
const leaveOrganizationRoute = createApiRoute({
|
|
193
|
-
description: "Leave an organization by revoking your own membership",
|
|
194
|
-
headers: HeaderSchema,
|
|
195
|
-
method: "POST",
|
|
196
|
-
operationId: "leaveOrganization",
|
|
197
|
-
path: "/:organizationId/access/leave",
|
|
198
|
-
pathParams: OrganizationParams,
|
|
199
|
-
responses: {
|
|
200
|
-
204: null,
|
|
201
|
-
400: ErrorSchema,
|
|
202
|
-
401: ErrorSchema,
|
|
203
|
-
404: ErrorSchema,
|
|
204
|
-
},
|
|
205
|
-
summary: "Leave Organization",
|
|
206
|
-
tags: ["Access"],
|
|
207
|
-
});
|
|
208
|
-
export const accessRoute = {
|
|
209
|
-
getMembers: getMembersRoute,
|
|
210
|
-
getMember: getMemberRoute,
|
|
211
|
-
updateMemberRole: updateMemberRoleRoute,
|
|
212
|
-
deleteMember: deleteMemberRoute,
|
|
213
|
-
createInvitation: createInvitationRoute,
|
|
214
|
-
deleteInvitation: deleteInvitationRoute,
|
|
215
|
-
getInvitations: getInvitationsRoute,
|
|
216
|
-
getUserInvitations: getUserInvitationsRoute,
|
|
217
|
-
acceptInvitation: acceptInvitationRoute,
|
|
218
|
-
leaveOrganization: leaveOrganizationRoute,
|
|
219
|
-
};
|
|
220
|
-
//# sourceMappingURL=access.route.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";import{createApiRoute as a}from"../../core/hono/hono";import{ErrorSchema as t,HeaderSchema as i,OrganizationParams as n,PaginationMetaSchema as o,PaginationQuerySchema as s}from"../../schemas";import{CreateInvitationSchema as r,InvitationSchema as m,MemberSchema as p,UpdateMemberRoleSchema as c,UserInvitationSchema as d}from"./access.schema";const h=e.object({memberId:e.string().openapi({description:"ID of the member",example:"clf9876543210abcdef",param:{in:"path",name:"memberId"}}),organizationId:e.string().openapi({description:"ID of the organization",example:"cju0z9k4z0000l1qg5z1z1z1z",param:{in:"path",name:"organizationId"}})}),g=a({description:"Fetches a paginated list of members for an organization",headers:i,method:"GET",operationId:"getMembers",path:"/:organizationId/access/members",pathParams:n,query:s,responses:{200:e.object({list:e.array(p),meta:o}),400:t,401:t},summary:"Get Members",tags:["Access"]}),I=a({headers:i,method:"GET",operationId:"getMember",path:"/:organizationId/access/members/:memberId",pathParams:h,responses:{200:p,401:t,404:t},summary:"Get Member",tags:["Access"]}),v=a({body:c,description:"Updates a member's role in the organization",headers:i,method:"PUT",operationId:"updateMemberRole",path:"/:organizationId/access/members/:memberId",pathParams:h,responses:{200:p,400:t,401:t,404:t},summary:"Update Member Role",tags:["Access"]}),z=a({description:"Removes a member from the organization",headers:i,method:"DELETE",operationId:"deleteMember",path:"/:organizationId/access/members/:memberId",pathParams:h,responses:{204:null,400:t,401:t,404:t},summary:"Delete Member",tags:["Access"]}),b=a({body:r,description:"Creates a new invitation for the organization",headers:i,method:"POST",operationId:"createInvitation",path:"/:organizationId/access/invitations",pathParams:n,responses:{201:m,400:t,401:t},summary:"Create Invitation",tags:["Access"]}),l=a({description:"Fetches a list of pending invitations for an organization",headers:i,method:"GET",operationId:"getInvitations",path:"/:organizationId/access/invitations",pathParams:n,responses:{200:e.array(m),401:t},summary:"Get Invitations",tags:["Access"]}),u=e.object({invitationId:e.string().openapi({description:"ID of the invitation",example:"inv_123",param:{in:"path",name:"invitationId"}})}),y=a({description:"Fetches pending invitations for the currently authenticated user",headers:i,method:"GET",operationId:"getUserInvitations",path:"/access/invitations/me",responses:{200:e.array(d),401:t},summary:"Get User Invitations",tags:["Access"]}),f=a({description:"Accepts a pending invitation and adds the user as a member",headers:i,method:"POST",operationId:"acceptInvitation",path:"/access/invitations/:invitationId/accept",pathParams:u,responses:{200:p,400:t,401:t,404:t},summary:"Accept Invitation",tags:["Access"]}),P=a({description:"Revokes a pending invitation",headers:i,method:"DELETE",operationId:"deleteInvitation",path:"/:organizationId/access/invitations/:invitationId",pathParams:e.object({invitationId:e.string().openapi({description:"ID of the invitation",example:"inv_123",param:{in:"path",name:"invitationId"}}),organizationId:e.string().openapi({description:"ID of the organization",example:"cju0z9k4z0000l1qg5z1z1z1z",param:{in:"path",name:"organizationId"}})}),responses:{204:null,400:t,401:t,404:t},summary:"Delete Invitation",tags:["Access"]}),A=a({description:"Leave an organization by revoking your own membership",headers:i,method:"POST",operationId:"leaveOrganization",path:"/:organizationId/access/leave",pathParams:n,responses:{204:null,400:t,401:t,404:t},summary:"Leave Organization",tags:["Access"]});export const accessRoute={getMembers:g,getMember:I,updateMemberRole:v,deleteMember:z,createInvitation:b,deleteInvitation:P,getInvitations:l,getUserInvitations:y,acceptInvitation:f,leaveOrganization:A};
|
|
@@ -1,108 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const MemberSchema = z
|
|
3
|
-
.object({
|
|
4
|
-
id: z.string().openapi({
|
|
5
|
-
example: "clf9876543210abcdef",
|
|
6
|
-
description: "ID of the member",
|
|
7
|
-
}),
|
|
8
|
-
organizationId: z.string().openapi({
|
|
9
|
-
example: "cju0z9k4z0000l1qg5z1z1z1z",
|
|
10
|
-
description: "ID of the organization",
|
|
11
|
-
}),
|
|
12
|
-
userId: z.string().openapi({
|
|
13
|
-
example: "usr_123",
|
|
14
|
-
description: "ID of the user",
|
|
15
|
-
}),
|
|
16
|
-
role: z.string().openapi({
|
|
17
|
-
example: "owner",
|
|
18
|
-
description: "Role of the member in the organization",
|
|
19
|
-
}),
|
|
20
|
-
createdAt: z.date(),
|
|
21
|
-
user: z
|
|
22
|
-
.object({
|
|
23
|
-
id: z.string(),
|
|
24
|
-
firstname: z.string(),
|
|
25
|
-
lastname: z.string(),
|
|
26
|
-
email: z.string(),
|
|
27
|
-
image: z.string().nullable().optional(),
|
|
28
|
-
})
|
|
29
|
-
.openapi({ description: "User details" }),
|
|
30
|
-
})
|
|
31
|
-
.openapi("Member");
|
|
32
|
-
export const InvitationSchema = z
|
|
33
|
-
.object({
|
|
34
|
-
id: z.string().openapi({
|
|
35
|
-
example: "inv_123",
|
|
36
|
-
description: "ID of the invitation",
|
|
37
|
-
}),
|
|
38
|
-
organizationId: z.string().openapi({
|
|
39
|
-
example: "cju0z9k4z0000l1qg5z1z1z1z",
|
|
40
|
-
description: "ID of the organization",
|
|
41
|
-
}),
|
|
42
|
-
email: z.string().email().openapi({
|
|
43
|
-
example: "user@example.com",
|
|
44
|
-
description: "Email of the invited user",
|
|
45
|
-
}),
|
|
46
|
-
role: z.string().nullable().optional().openapi({
|
|
47
|
-
example: "member",
|
|
48
|
-
description: "Role assigned to the invitation",
|
|
49
|
-
}),
|
|
50
|
-
status: z.string().openapi({
|
|
51
|
-
example: "pending",
|
|
52
|
-
description: "Status of the invitation",
|
|
53
|
-
}),
|
|
54
|
-
expiresAt: z.date().openapi({
|
|
55
|
-
description: "Expiration date of the invitation",
|
|
56
|
-
}),
|
|
57
|
-
inviterId: z.string().openapi({
|
|
58
|
-
description: "ID of the user who created the invitation",
|
|
59
|
-
}),
|
|
60
|
-
createdAt: z.date().optional(),
|
|
61
|
-
})
|
|
62
|
-
.openapi("Invitation");
|
|
63
|
-
export const CreateInvitationSchema = z
|
|
64
|
-
.object({
|
|
65
|
-
email: z.string().email("A valid email is required").openapi({
|
|
66
|
-
example: "user@example.com",
|
|
67
|
-
description: "Email of the user to invite",
|
|
68
|
-
}),
|
|
69
|
-
role: z.string().min(1, "Role is required").openapi({
|
|
70
|
-
example: "member",
|
|
71
|
-
description: "Role to assign to the invited user",
|
|
72
|
-
}),
|
|
73
|
-
})
|
|
74
|
-
.openapi("CreateInvitation");
|
|
75
|
-
export const UpdateMemberRoleSchema = z
|
|
76
|
-
.object({
|
|
77
|
-
role: z.string().min(1, "Role is required").openapi({
|
|
78
|
-
example: "admin",
|
|
79
|
-
description: "New role for the member",
|
|
80
|
-
}),
|
|
81
|
-
})
|
|
82
|
-
.openapi("UpdateMemberRole");
|
|
83
|
-
export const UserInvitationSchema = z
|
|
84
|
-
.object({
|
|
85
|
-
id: z.string().openapi({
|
|
86
|
-
example: "inv_123",
|
|
87
|
-
description: "ID of the invitation",
|
|
88
|
-
}),
|
|
89
|
-
organizationId: z.string().openapi({
|
|
90
|
-
example: "cju0z9k4z0000l1qg5z1z1z1z",
|
|
91
|
-
description: "ID of the organization",
|
|
92
|
-
}),
|
|
93
|
-
role: z.string().nullable().optional().openapi({
|
|
94
|
-
example: "member",
|
|
95
|
-
description: "Role assigned to the invitation",
|
|
96
|
-
}),
|
|
97
|
-
expiresAt: z.date().openapi({
|
|
98
|
-
description: "Expiration date of the invitation",
|
|
99
|
-
}),
|
|
100
|
-
organization: z
|
|
101
|
-
.object({
|
|
102
|
-
id: z.string(),
|
|
103
|
-
name: z.string(),
|
|
104
|
-
})
|
|
105
|
-
.openapi({ description: "Organization details" }),
|
|
106
|
-
})
|
|
107
|
-
.openapi("UserInvitation");
|
|
108
|
-
//# sourceMappingURL=access.schema.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";export const MemberSchema=e.object({id:e.string().openapi({example:"clf9876543210abcdef",description:"ID of the member"}),organizationId:e.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),userId:e.string().openapi({example:"usr_123",description:"ID of the user"}),role:e.string().openapi({example:"owner",description:"Role of the member in the organization"}),createdAt:e.date(),user:e.object({id:e.string(),firstname:e.string(),lastname:e.string(),email:e.string(),image:e.string().nullable().optional()}).openapi({description:"User details"})}).openapi("Member");export const InvitationSchema=e.object({id:e.string().openapi({example:"inv_123",description:"ID of the invitation"}),organizationId:e.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),email:e.string().email().openapi({example:"user@example.com",description:"Email of the invited user"}),role:e.string().nullable().optional().openapi({example:"member",description:"Role assigned to the invitation"}),status:e.string().openapi({example:"pending",description:"Status of the invitation"}),expiresAt:e.date().openapi({description:"Expiration date of the invitation"}),inviterId:e.string().openapi({description:"ID of the user who created the invitation"}),createdAt:e.date().optional()}).openapi("Invitation");export const CreateInvitationSchema=e.object({email:e.string().email("A valid email is required").openapi({example:"user@example.com",description:"Email of the user to invite"}),role:e.string().min(1,"Role is required").openapi({example:"member",description:"Role to assign to the invited user"})}).openapi("CreateInvitation");export const UpdateMemberRoleSchema=e.object({role:e.string().min(1,"Role is required").openapi({example:"admin",description:"New role for the member"})}).openapi("UpdateMemberRole");export const UserInvitationSchema=e.object({id:e.string().openapi({example:"inv_123",description:"ID of the invitation"}),organizationId:e.string().openapi({example:"cju0z9k4z0000l1qg5z1z1z1z",description:"ID of the organization"}),role:e.string().nullable().optional().openapi({example:"member",description:"Role assigned to the invitation"}),expiresAt:e.date().openapi({description:"Expiration date of the invitation"}),organization:e.object({id:e.string(),name:e.string()}).openapi({description:"Organization details"})}).openapi("UserInvitation");
|