@shophost/rest-api 2.0.33 → 2.0.35
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 +1 -1
- package/scripts/minify-dist.mjs +45 -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.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.js +1 -541
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
- package/src/core/db/__generated__/client/models/Account.js +1 -2
- package/src/core/db/__generated__/client/models/Address.js +1 -2
- package/src/core/db/__generated__/client/models/Campaign.js +1 -2
- package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
- package/src/core/db/__generated__/client/models/File.js +1 -2
- package/src/core/db/__generated__/client/models/Invitation.js +1 -2
- package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
- package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Member.js +1 -2
- package/src/core/db/__generated__/client/models/Modifier.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
- package/src/core/db/__generated__/client/models/Order.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Organization.js +1 -2
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
- package/src/core/db/__generated__/client/models/Payment.js +1 -2
- package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
- package/src/core/db/__generated__/client/models/Product.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
- package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Reservation.js +1 -2
- package/src/core/db/__generated__/client/models/Session.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
- package/src/core/db/__generated__/client/models/User.js +1 -2
- 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.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/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.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.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.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-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.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.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.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-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.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.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.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.js +1 -154
- package/src/test/setup-test-env.js +1 -7
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=Reservation.js.map
|
|
1
|
+
export{};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=Session.js.map
|
|
1
|
+
export{};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=ShippingMethod.js.map
|
|
1
|
+
export{};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=ShippingZone.js.map
|
|
1
|
+
export{};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=User.js.map
|
|
1
|
+
export{};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=Verification.js.map
|
|
1
|
+
export{};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=models.js.map
|
|
1
|
+
export{};
|
package/src/core/db/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./__generated__/client/client";
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
class
|
|
2
|
-
constructor(status, message) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.status = status;
|
|
5
|
-
this.message = message;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export { HttpException };
|
|
9
|
-
//# sourceMappingURL=http-exception.js.map
|
|
1
|
+
class r extends Error{constructor(s,t){super(t),this.status=s,this.message=t}}export{r as HttpException};
|
package/src/core/hono/hono.js
CHANGED
|
@@ -1,123 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createRoute, OpenAPIHono } from "@hono/zod-openapi";
|
|
3
|
-
import { getReasonPhrase, StatusCodes } from "http-status-codes";
|
|
4
|
-
import { HttpException } from "../exceptions/http-exception";
|
|
5
|
-
const toOpenApiPath = (path) => {
|
|
6
|
-
return path.replace(/:([A-Za-z0-9_]+)/g, "{$1}");
|
|
7
|
-
};
|
|
8
|
-
const buildResponse = (status, schema) => {
|
|
9
|
-
const description = status === StatusCodes.NO_CONTENT
|
|
10
|
-
? "No Content"
|
|
11
|
-
: getReasonPhrase(status);
|
|
12
|
-
if (!schema || status === StatusCodes.NO_CONTENT) {
|
|
13
|
-
return { description };
|
|
14
|
-
}
|
|
15
|
-
return {
|
|
16
|
-
content: {
|
|
17
|
-
"application/json": {
|
|
18
|
-
schema,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
description,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export const createApiRoute = ({ body, bodyRequired = true, description, headers, method, operationId, path, pathParams, query, responses, summary, tags, }) => {
|
|
25
|
-
return createRoute({
|
|
26
|
-
description,
|
|
27
|
-
method: method.toLowerCase(),
|
|
28
|
-
operationId,
|
|
29
|
-
path: toOpenApiPath(path),
|
|
30
|
-
request: Object.assign(Object.assign(Object.assign(Object.assign({}, (body
|
|
31
|
-
? {
|
|
32
|
-
body: {
|
|
33
|
-
content: {
|
|
34
|
-
"application/json": {
|
|
35
|
-
schema: body,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
required: bodyRequired,
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
: {})), (headers ? { headers } : {})), (pathParams ? { params: pathParams } : {})), (query ? { query } : {})),
|
|
42
|
-
responses: Object.fromEntries(Object.entries(responses).map(([status, schema]) => [
|
|
43
|
-
Number(status),
|
|
44
|
-
buildResponse(Number(status), schema),
|
|
45
|
-
])),
|
|
46
|
-
summary,
|
|
47
|
-
tags,
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
export const createApiRouter = () => {
|
|
51
|
-
return new OpenAPIHono({
|
|
52
|
-
defaultHook: (result, c) => {
|
|
53
|
-
if (result.success) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
return c.json({
|
|
57
|
-
error: result.error.flatten(),
|
|
58
|
-
message: "Validation Error",
|
|
59
|
-
status: StatusCodes.BAD_REQUEST,
|
|
60
|
-
}, StatusCodes.BAD_REQUEST);
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
export const createUnavailableAuth = () => ({
|
|
65
|
-
getCurrentUser: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
-
throw new Error("Auth is not available for OpenAPI generation.");
|
|
67
|
-
}),
|
|
68
|
-
isGranted: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
throw new Error("Auth is not available for OpenAPI generation.");
|
|
70
|
-
}),
|
|
71
|
-
});
|
|
72
|
-
export const attachAuthContext = (app, auth) => {
|
|
73
|
-
app.use("*", (c, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
c.set("auth", auth);
|
|
75
|
-
Object.assign(c.req.raw, { auth });
|
|
76
|
-
yield next();
|
|
77
|
-
}));
|
|
78
|
-
return app;
|
|
79
|
-
};
|
|
80
|
-
export const handleAppError = (error) => {
|
|
81
|
-
var _a;
|
|
82
|
-
if (error instanceof HttpException) {
|
|
83
|
-
return new Response(JSON.stringify({
|
|
84
|
-
message: error.message,
|
|
85
|
-
status: error.status,
|
|
86
|
-
}), {
|
|
87
|
-
headers: {
|
|
88
|
-
"content-type": "application/json",
|
|
89
|
-
},
|
|
90
|
-
status: error.status,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
const authStatus = typeof (error === null || error === void 0 ? void 0 : error.statusCode) === "number"
|
|
94
|
-
? error.statusCode
|
|
95
|
-
: undefined;
|
|
96
|
-
if (!authStatus || authStatus >= StatusCodes.INTERNAL_SERVER_ERROR) {
|
|
97
|
-
console.error(error);
|
|
98
|
-
}
|
|
99
|
-
if (authStatus) {
|
|
100
|
-
const message = ((_a = error === null || error === void 0 ? void 0 : error.body) === null || _a === void 0 ? void 0 : _a.message) ||
|
|
101
|
-
(error === null || error === void 0 ? void 0 : error.message) ||
|
|
102
|
-
getReasonPhrase(authStatus);
|
|
103
|
-
return new Response(JSON.stringify({
|
|
104
|
-
message,
|
|
105
|
-
status: authStatus,
|
|
106
|
-
}), {
|
|
107
|
-
headers: {
|
|
108
|
-
"content-type": "application/json",
|
|
109
|
-
},
|
|
110
|
-
status: authStatus,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return new Response(JSON.stringify({
|
|
114
|
-
message: "Internal Server Error",
|
|
115
|
-
status: StatusCodes.INTERNAL_SERVER_ERROR,
|
|
116
|
-
}), {
|
|
117
|
-
headers: {
|
|
118
|
-
"content-type": "application/json",
|
|
119
|
-
},
|
|
120
|
-
status: StatusCodes.INTERNAL_SERVER_ERROR,
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=hono.js.map
|
|
1
|
+
import{__awaiter as i}from"tslib";import{createRoute as m,OpenAPIHono as O}from"@hono/zod-openapi";import{getReasonPhrase as c,StatusCodes as o}from"http-status-codes";import{HttpException as g}from"../exceptions/http-exception";const N=t=>t.replace(/:([A-Za-z0-9_]+)/g,"{$1}"),A=(t,n)=>{const e=t===o.NO_CONTENT?"No Content":c(t);return!n||t===o.NO_CONTENT?{description:e}:{content:{"application/json":{schema:n}},description:e}};export const createApiRoute=({body:t,bodyRequired:n=!0,description:e,headers:s,method:p,operationId:d,path:R,pathParams:a,query:r,responses:l,summary:E,tags:f})=>m({description:e,method:p.toLowerCase(),operationId:d,path:N(R),request:Object.assign(Object.assign(Object.assign(Object.assign({},t?{body:{content:{"application/json":{schema:t}},required:n}}:{}),s?{headers:s}:{}),a?{params:a}:{}),r?{query:r}:{}),responses:Object.fromEntries(Object.entries(l).map(([u,v])=>[Number(u),A(Number(u),v)])),summary:E,tags:f}),createApiRouter=()=>new O({defaultHook:(t,n)=>{if(!t.success)return n.json({error:t.error.flatten(),message:"Validation Error",status:o.BAD_REQUEST},o.BAD_REQUEST)}}),createUnavailableAuth=()=>({getCurrentUser:()=>i(void 0,void 0,void 0,function*(){throw new Error("Auth is not available for OpenAPI generation.")}),isGranted:()=>i(void 0,void 0,void 0,function*(){throw new Error("Auth is not available for OpenAPI generation.")})}),attachAuthContext=(t,n)=>(t.use("*",(e,s)=>i(void 0,void 0,void 0,function*(){e.set("auth",n),Object.assign(e.req.raw,{auth:n}),yield s()})),t),handleAppError=t=>{var n;if(t instanceof g)return new Response(JSON.stringify({message:t.message,status:t.status}),{headers:{"content-type":"application/json"},status:t.status});const e=typeof t?.statusCode=="number"?t.statusCode:void 0;if((!e||e>=o.INTERNAL_SERVER_ERROR)&&console.error(t),e){const s=((n=t?.body)===null||n===void 0?void 0:n.message)||t?.message||c(e);return new Response(JSON.stringify({message:s,status:e}),{headers:{"content-type":"application/json"},status:e})}return new Response(JSON.stringify({message:"Internal Server Error",status:o.INTERNAL_SERVER_ERROR}),{headers:{"content-type":"application/json"},status:o.INTERNAL_SERVER_ERROR})};
|
package/src/core/lib/prisma.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PrismaClient } from "../db";
|
|
3
|
-
export const createPrismaClient = (options) => {
|
|
4
|
-
return new PrismaClient(options).$extends(pagination({
|
|
5
|
-
pages: {
|
|
6
|
-
limit: 15,
|
|
7
|
-
includePageCount: true,
|
|
8
|
-
},
|
|
9
|
-
}));
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=prisma.js.map
|
|
1
|
+
import{pagination as t}from"prisma-extension-pagination";import{PrismaClient as i}from"../db";export const createPrismaClient=e=>new i(e).$extends(t({pages:{limit:15,includePageCount:!0}}));
|
package/src/core/logging/pino.js
CHANGED
|
@@ -1,116 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Resend } from "resend";
|
|
3
|
-
import { OrderConfirmationEmail } from "../../features/order/emails/order-confirmation.email";
|
|
4
|
-
import OrderNotificationEmail from "../../features/order/emails/order-notification.email";
|
|
5
|
-
import { ReservationCancellationEmail } from "../../features/reservation/emails/reservation-cancellation.email";
|
|
6
|
-
import { ReservationConfirmationEmail } from "../../features/reservation/emails/reservation-confirmation.email";
|
|
7
|
-
import ReservationNotificationEmail from "../../features/reservation/emails/reservation-notification.email";
|
|
8
|
-
class EmailService {
|
|
9
|
-
constructor(apiKey) {
|
|
10
|
-
this.resend = new Resend(apiKey);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Sends an email
|
|
14
|
-
*/
|
|
15
|
-
sendEmail(payload, options) {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const { data, error } = yield this.resend.emails.send(payload);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Sends an order confirmation email
|
|
22
|
-
*/
|
|
23
|
-
sendOrderConfirmationEmail(user, organization, order) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
console.log(`Sending order confirmation email to ${user.email}`);
|
|
26
|
-
yield this.sendEmail({
|
|
27
|
-
from: `${organization.name} <info@shophost.io>`,
|
|
28
|
-
to: [user.email],
|
|
29
|
-
subject: `Order Confirmation - Order #${order.referenceId} | ${organization.name}`,
|
|
30
|
-
react: OrderConfirmationEmail({
|
|
31
|
-
user,
|
|
32
|
-
organization,
|
|
33
|
-
order,
|
|
34
|
-
}),
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Sends an order confirmation email
|
|
40
|
-
*/
|
|
41
|
-
sendOrderNotificationEmail(user, member, organization, order) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
console.log(`Sending order notification email to ${member.email}`);
|
|
44
|
-
yield this.sendEmail({
|
|
45
|
-
from: `${organization.name} <info@shophost.io>`,
|
|
46
|
-
to: [member.email],
|
|
47
|
-
subject: `You have received a new order | ${organization.name}`,
|
|
48
|
-
react: OrderNotificationEmail({
|
|
49
|
-
user,
|
|
50
|
-
organization,
|
|
51
|
-
order,
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
sendReservationConfirmationEmail(reservation) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const user = reservation.user;
|
|
59
|
-
const organization = reservation.organization;
|
|
60
|
-
console.log(`Sending reservation confirmation email to ${user.email}`);
|
|
61
|
-
yield this.sendEmail({
|
|
62
|
-
from: `${organization.name} <info@shophost.io>`,
|
|
63
|
-
to: [user.email],
|
|
64
|
-
subject: `Reservation Confirmation - ${organization.name}`,
|
|
65
|
-
react: ReservationConfirmationEmail({
|
|
66
|
-
user,
|
|
67
|
-
organization,
|
|
68
|
-
reservation,
|
|
69
|
-
}),
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Sends a reservation cancellation email
|
|
75
|
-
*/
|
|
76
|
-
sendReservationCancellationEmail(reservation) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const user = reservation.user;
|
|
79
|
-
const organization = reservation.organization;
|
|
80
|
-
console.log(`Sending reservation cancellation email to ${user.email}`);
|
|
81
|
-
yield this.sendEmail({
|
|
82
|
-
from: `${organization.name} <info@shophost.io>`,
|
|
83
|
-
to: [user.email],
|
|
84
|
-
subject: `Reservation Cancelled - ${organization.name}`,
|
|
85
|
-
react: ReservationCancellationEmail({
|
|
86
|
-
user,
|
|
87
|
-
organization,
|
|
88
|
-
reservation,
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Sends a reservation notification email to an organization member
|
|
95
|
-
*/
|
|
96
|
-
sendReservationNotificationEmail(member, reservation) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const user = reservation.user;
|
|
99
|
-
const organization = reservation.organization;
|
|
100
|
-
console.log(`Sending reservation notification email to ${member.email}`);
|
|
101
|
-
yield this.sendEmail({
|
|
102
|
-
from: `${organization.name} <info@shophost.io>`,
|
|
103
|
-
to: [member.email],
|
|
104
|
-
subject: `New Reservation Request | ${organization.name}`,
|
|
105
|
-
react: ReservationNotificationEmail({
|
|
106
|
-
user,
|
|
107
|
-
member,
|
|
108
|
-
organization,
|
|
109
|
-
reservation,
|
|
110
|
-
}),
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export { EmailService };
|
|
116
|
-
//# sourceMappingURL=email.service.js.map
|
|
1
|
+
import{__awaiter as t}from"tslib";import{Resend as a}from"resend";import{OrderConfirmationEmail as r}from"../../features/order/emails/order-confirmation.email";import s from"../../features/order/emails/order-notification.email";import{ReservationCancellationEmail as m}from"../../features/reservation/emails/reservation-cancellation.email";import{ReservationConfirmationEmail as l}from"../../features/reservation/emails/reservation-confirmation.email";import d from"../../features/reservation/emails/reservation-notification.email";class c{constructor(i){this.resend=new a(i)}sendEmail(i,o){return t(this,void 0,void 0,function*(){const{data:e,error:n}=yield this.resend.emails.send(i)})}sendOrderConfirmationEmail(i,o,e){return t(this,void 0,void 0,function*(){console.log(`Sending order confirmation email to ${i.email}`),yield this.sendEmail({from:`${o.name} <info@shophost.io>`,to:[i.email],subject:`Order Confirmation - Order #${e.referenceId} | ${o.name}`,react:r({user:i,organization:o,order:e})})})}sendOrderNotificationEmail(i,o,e,n){return t(this,void 0,void 0,function*(){console.log(`Sending order notification email to ${o.email}`),yield this.sendEmail({from:`${e.name} <info@shophost.io>`,to:[o.email],subject:`You have received a new order | ${e.name}`,react:s({user:i,organization:e,order:n})})})}sendReservationConfirmationEmail(i){return t(this,void 0,void 0,function*(){const o=i.user,e=i.organization;console.log(`Sending reservation confirmation email to ${o.email}`),yield this.sendEmail({from:`${e.name} <info@shophost.io>`,to:[o.email],subject:`Reservation Confirmation - ${e.name}`,react:l({user:o,organization:e,reservation:i})})})}sendReservationCancellationEmail(i){return t(this,void 0,void 0,function*(){const o=i.user,e=i.organization;console.log(`Sending reservation cancellation email to ${o.email}`),yield this.sendEmail({from:`${e.name} <info@shophost.io>`,to:[o.email],subject:`Reservation Cancelled - ${e.name}`,react:m({user:o,organization:e,reservation:i})})})}sendReservationNotificationEmail(i,o){return t(this,void 0,void 0,function*(){const e=o.user,n=o.organization;console.log(`Sending reservation notification email to ${i.email}`),yield this.sendEmail({from:`${n.name} <info@shophost.io>`,to:[i.email],subject:`New Reservation Request | ${n.name}`,react:d({user:e,member:i,organization:n,reservation:o})})})}}export{c as EmailService};
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const defaultOpenApiDocument = {
|
|
3
|
-
info: {
|
|
4
|
-
description: "API for Shophost Organization API",
|
|
5
|
-
title: "Shophost API",
|
|
6
|
-
version: "1.0",
|
|
7
|
-
},
|
|
8
|
-
openapi: "3.1.0",
|
|
9
|
-
servers: [
|
|
10
|
-
{
|
|
11
|
-
description: "Local",
|
|
12
|
-
url: "http://localhost:3001/api",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
description: "Production",
|
|
16
|
-
url: "https://api.shophost.io/api",
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
};
|
|
20
|
-
export const generateOpenApiSpec = (apiDoc = defaultOpenApiDocument, buildApiAppOptions = {}) => {
|
|
21
|
-
const app = buildApiApp(buildApiAppOptions);
|
|
22
|
-
return app.getOpenAPI31Document(apiDoc, {
|
|
23
|
-
unionPreferredType: "oneOf",
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=openapi.lib.js.map
|
|
1
|
+
import{buildApiApp as e}from"../../app";export const defaultOpenApiDocument={info:{description:"API for Shophost Organization API",title:"Shophost API",version:"1.0"},openapi:"3.1.0",servers:[{description:"Local",url:"http://localhost:3001/api"},{description:"Production",url:"https://api.shophost.io/api"}]},generateOpenApiSpec=(o=defaultOpenApiDocument,p={})=>e(p).getOpenAPI31Document(o,{unionPreferredType:"oneOf"});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
//# sourceMappingURL=google-maps.types.js.map
|
|
1
|
+
export{};
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
export const formatCurrencyAmount
|
|
2
|
-
// Stripe amounts are in the smallest currency unit (e.g., cents for USD)
|
|
3
|
-
const amountInMainUnit = amount / 100;
|
|
4
|
-
return new Intl.NumberFormat(locale, {
|
|
5
|
-
style: "currency",
|
|
6
|
-
currency: currency,
|
|
7
|
-
minimumFractionDigits: 2,
|
|
8
|
-
maximumFractionDigits: 2,
|
|
9
|
-
}).format(amountInMainUnit);
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=currency.util.js.map
|
|
1
|
+
export const formatCurrencyAmount=(n,t="USD",r="en-US")=>{const m=n/100;return new Intl.NumberFormat(r,{style:"currency",currency:t,minimumFractionDigits:2,maximumFractionDigits:2}).format(m)};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export function requireEnv(type, key) {
|
|
3
|
-
if (type === "string") {
|
|
4
|
-
return z.string().min(1, `${key} is required`).parse(process.env[key]);
|
|
5
|
-
}
|
|
6
|
-
return z.coerce.number().min(1, `${key} is required`).parse(process.env[key]);
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=env.util.js.map
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";export function requireEnv(i,r){return i==="string"?e.string().min(1,`${r} is required`).parse(process.env[r]):e.coerce.number().min(1,`${r} is required`).parse(process.env[r])}
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* A standalone implementation of Lodash's `_.get` in TypeScript.
|
|
3
|
-
*
|
|
4
|
-
* @param object The object to query.
|
|
5
|
-
* @param path The path to get. Can be:
|
|
6
|
-
* - a string in dot/bracket notation, e.g. "a.b[0].c"
|
|
7
|
-
* - an array of string/number keys, e.g. ["a", "b", 0, "c"].
|
|
8
|
-
* @param defaultValue The value returned if the resolved value is undefined.
|
|
9
|
-
* @returns The resolved value, or defaultValue if it's undefined.
|
|
10
|
-
*/
|
|
11
|
-
export const get = (object, path, defaultValue) => {
|
|
12
|
-
// If the object is null or undefined, return the defaultValue right away.
|
|
13
|
-
if (object == null) {
|
|
14
|
-
return defaultValue;
|
|
15
|
-
}
|
|
16
|
-
// Convert path into an array if it's not already.
|
|
17
|
-
// This regex handles bracket-notation -> dot-notation, e.g. "a[0].b" -> "a.0.b".
|
|
18
|
-
// Then we split on '.' to create an array of keys.
|
|
19
|
-
const pathArray = Array.isArray(path)
|
|
20
|
-
? path
|
|
21
|
-
: path
|
|
22
|
-
.replace(/\[(\d+)\]/g, ".$1")
|
|
23
|
-
.split(".")
|
|
24
|
-
// filter out empty strings (e.g., if path had a leading or trailing dot)
|
|
25
|
-
.filter(Boolean);
|
|
26
|
-
// Start traversing
|
|
27
|
-
let result = object;
|
|
28
|
-
for (let i = 0; i < pathArray.length; i++) {
|
|
29
|
-
const key = pathArray[i];
|
|
30
|
-
// If the current value is null/undefined or doesn't have the key, return defaultValue.
|
|
31
|
-
if (result == null || !(key in result)) {
|
|
32
|
-
return defaultValue;
|
|
33
|
-
}
|
|
34
|
-
result = result[key];
|
|
35
|
-
}
|
|
36
|
-
// If we finally get `undefined`, return defaultValue, else the resolved value
|
|
37
|
-
return result === undefined ? defaultValue : result;
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=object.util.js.map
|
|
1
|
+
export const get=(i,n,e)=>{if(i==null)return e;const l=Array.isArray(n)?n:n.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let r=i;for(let t=0;t<l.length;t++){const o=l[t];if(r==null||!(o in r))return e;r=r[o]}return r===void 0?e:r};
|
|
@@ -1,85 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* A helper function that, given an array of field names,
|
|
4
|
-
* ensures that each of these fields is present and non-empty
|
|
5
|
-
* in the translation that matches the `defaultLocale`.
|
|
6
|
-
*/
|
|
7
|
-
export const validateRequiredForDefaultLocale = (...requiredFields) => (data, ctx) => {
|
|
8
|
-
const { translations, defaultLocale } = data;
|
|
9
|
-
// Find the index of the translation that matches the defaultLocale
|
|
10
|
-
const defaultTranslationIndex = translations.findIndex((t) => t.locale === defaultLocale);
|
|
11
|
-
// If there's no translation for the default locale, add an error
|
|
12
|
-
if (defaultTranslationIndex === -1) {
|
|
13
|
-
ctx.addIssue({
|
|
14
|
-
code: z.ZodIssueCode.custom,
|
|
15
|
-
message: "Missing translation for the default locale",
|
|
16
|
-
path: ["translations"],
|
|
17
|
-
});
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
// For each required field, check if it's present and non-empty
|
|
21
|
-
requiredFields.forEach((fieldName) => {
|
|
22
|
-
const fieldValue = translations[defaultTranslationIndex][fieldName];
|
|
23
|
-
// Depending on your exact needs, this could be a more nuanced check,
|
|
24
|
-
// e.g., for non-empty arrays, numeric values, etc.
|
|
25
|
-
// Here, we assume "non-empty string" is the requirement.
|
|
26
|
-
if (typeof fieldValue !== "string" || !fieldValue.trim()) {
|
|
27
|
-
ctx.addIssue({
|
|
28
|
-
code: z.ZodIssueCode.custom,
|
|
29
|
-
message: `This field is required`,
|
|
30
|
-
path: ["translations", defaultTranslationIndex, fieldName],
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Recursively processes an object and extracts values from 'translations' arrays.
|
|
37
|
-
* If a field called 'translations' is found and it's an array with at least one object,
|
|
38
|
-
* the values from that object are added to the parent object.
|
|
39
|
-
* @param data The object to process
|
|
40
|
-
* @returns A new object with translations extracted
|
|
41
|
-
*/
|
|
42
|
-
export const flattenTranslationData = (data) => {
|
|
43
|
-
// If data is null, undefined, or not an object, return it as is
|
|
44
|
-
if (data === null ||
|
|
45
|
-
data === undefined ||
|
|
46
|
-
typeof data !== "object" ||
|
|
47
|
-
data instanceof Date) {
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
// If data is an array, process each item recursively
|
|
51
|
-
if (Array.isArray(data)) {
|
|
52
|
-
return data.map((item) => flattenTranslationData(item));
|
|
53
|
-
}
|
|
54
|
-
// Create a new object to hold the result
|
|
55
|
-
const result = {};
|
|
56
|
-
// Process each property in the object
|
|
57
|
-
for (const [key, value] of Object.entries(data)) {
|
|
58
|
-
if (key === "translations" && Array.isArray(value) && value.length > 0) {
|
|
59
|
-
// If we found a translations array with at least one object,
|
|
60
|
-
// merge its properties into the result object
|
|
61
|
-
const translationObj = value[0];
|
|
62
|
-
if (translationObj && typeof translationObj === "object") {
|
|
63
|
-
// Copy all properties from the first translation object to the result
|
|
64
|
-
// except for the 'id' field
|
|
65
|
-
for (const [translationKey, translationValue] of Object.entries(translationObj)) {
|
|
66
|
-
if (translationKey !== "id") {
|
|
67
|
-
result[translationKey] = translationValue;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else if (typeof value === "object" &&
|
|
73
|
-
value !== null &&
|
|
74
|
-
!(value instanceof Date)) {
|
|
75
|
-
// Recursively process nested objects
|
|
76
|
-
result[key] = flattenTranslationData(value);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// Copy primitive values and dates as is
|
|
80
|
-
result[key] = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=zod.util.js.map
|
|
1
|
+
import{z as l}from"@hono/zod-openapi";export const validateRequiredForDefaultLocale=(...t)=>(s,o)=>{const{translations:e,defaultLocale:i}=s,n=e.findIndex(r=>r.locale===i);if(n===-1){o.addIssue({code:l.ZodIssueCode.custom,message:"Missing translation for the default locale",path:["translations"]});return}t.forEach(r=>{const a=e[n][r];(typeof a!="string"||!a.trim())&&o.addIssue({code:l.ZodIssueCode.custom,message:"This field is required",path:["translations",n,r]})})},flattenTranslationData=t=>{if(t==null||typeof t!="object"||t instanceof Date)return t;if(Array.isArray(t))return t.map(o=>flattenTranslationData(o));const s={};for(const[o,e]of Object.entries(t))if(o==="translations"&&Array.isArray(e)&&e.length>0){const i=e[0];if(i&&typeof i=="object")for(const[n,r]of Object.entries(i))n!=="id"&&(s[n]=r)}else typeof e=="object"&&e!==null&&!(e instanceof Date)?s[o]=flattenTranslationData(e):s[o]=e;return s};
|
package/src/db.js
CHANGED
|
@@ -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 s}from"tslib";import{createApiRouter as l}from"../../core/hono/hono";import{accessRoute as d}from"./access.route";import{AccessService as v}from"./access.service";export const buildAccessHandler=r=>{const a=l();return a.openapi(d.getMembers,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param"),i=e.req.valid("query");yield n.isGranted("read");const c=yield new v(r).getMembers(t.organizationId,Object.assign({},i));return e.json(c,200)})),a.openapi(d.getMember,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param");yield n.isGranted("read");const o=yield new v(r).getMember(t.organizationId,t.memberId);return e.json(o,200)})),a.openapi(d.updateMemberRole,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param"),i=e.req.valid("json"),o=yield n.isGranted("update"),u=yield new v(r).updateMemberRole(t.organizationId,t.memberId,o.id,i);return e.json(u,200)})),a.openapi(d.deleteMember,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param"),i=yield n.isGranted("delete");return yield new v(r).deleteMember(t.organizationId,t.memberId,i.id),e.body(null,204)})),a.openapi(d.createInvitation,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param"),i=e.req.valid("json"),o=yield n.isGranted("create"),u=yield new v(r).createInvitation(t.organizationId,o.id,i);return e.json(u,201)})),a.openapi(d.getInvitations,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param");yield n.isGranted("read");const o=yield new v(r).getInvitations(t.organizationId);return e.json(o,200)})),a.openapi(d.deleteInvitation,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param");return yield n.isGranted("delete"),yield new v(r).deleteInvitation(t.organizationId,t.invitationId),e.body(null,204)})),a.openapi(d.getUserInvitations,e=>s(void 0,void 0,void 0,function*(){const t=yield e.get("auth").getCurrentUser(),o=yield new v(r).getUserInvitations(t.email);return e.json(o,200)})),a.openapi(d.acceptInvitation,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param"),i=yield n.getCurrentUser(),c=yield new v(r).acceptInvitation(t.invitationId,i.id);return e.json(c,200)})),a.openapi(d.leaveOrganization,e=>s(void 0,void 0,void 0,function*(){const n=e.get("auth"),t=e.req.valid("param"),i=yield n.getCurrentUser();return yield new v(r).leaveOrganization(t.organizationId,i.id),e.body(null,204)})),a};
|