@shophost/rest-api 2.0.58 → 2.0.60
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/src/bootstrap.js +1 -1
- package/src/bootstrap.js.map +1 -1
- package/src/container.d.ts +3 -1
- package/src/container.js +1 -1
- package/src/container.js.map +1 -1
- package/src/core/notifications/email.service.d.ts +1 -1
- package/src/core/notifications/email.service.js +1 -1
- package/src/core/notifications/email.service.js.map +1 -1
- package/src/features/customer/customer.handler.d.ts +2 -0
- package/src/features/customer/customer.handler.js +1 -0
- package/src/features/customer/customer.handler.js.map +1 -0
- package/src/features/customer/customer.route.d.ts +712 -0
- package/src/features/customer/customer.route.js +1 -0
- package/src/features/customer/customer.route.js.map +1 -0
- package/src/features/customer/customer.schema.d.ts +576 -0
- package/src/features/customer/customer.schema.js +1 -0
- package/src/features/customer/customer.schema.js.map +1 -0
- package/src/features/customer/customer.service.d.ts +166 -0
- package/src/features/customer/customer.service.js +1 -0
- package/src/features/customer/customer.service.js.map +1 -0
- package/src/features/index.d.ts +1 -0
- package/src/features/index.js +1 -1
- package/src/features/index.js.map +1 -1
- package/src/features/integration/integration.handler.js +1 -1
- package/src/features/integration/integration.handler.js.map +1 -1
- package/src/features/integration/integration.route.d.ts +175 -0
- package/src/features/integration/integration.route.js +1 -1
- package/src/features/integration/integration.route.js.map +1 -1
- package/src/features/integration/integration.schema.d.ts +13 -0
- package/src/features/integration/integration.schema.js +1 -1
- package/src/features/integration/integration.schema.js.map +1 -1
- package/src/features/integration/integration.service.d.ts +7 -0
- package/src/features/integration/integration.service.js +1 -1
- package/src/features/integration/integration.service.js.map +1 -1
- package/src/features/payment/payment.service.js +1 -1
- package/src/features/payment/payment.service.js.map +1 -1
- package/src/features/payment/stripe.service.d.ts +10 -0
- package/src/features/payment/stripe.service.js +1 -1
- package/src/features/payment/stripe.service.js.map +1 -1
- package/src/features/reservation/reservation.service.d.ts +1 -0
- package/src/features/reservation/reservation.service.js +1 -1
- package/src/features/reservation/reservation.service.js.map +1 -1
- package/src/schemas/index.d.ts +1 -0
- package/src/schemas/index.js +1 -1
- package/src/schemas/index.js.map +1 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { PrismaClientType } from "../../core/lib/prisma";
|
|
2
|
+
import { CustomerListQuery } from "../../schemas";
|
|
3
|
+
declare class CustomerService {
|
|
4
|
+
private readonly prisma;
|
|
5
|
+
constructor(prisma: PrismaClientType);
|
|
6
|
+
private getCustomerActivityFilter;
|
|
7
|
+
private getCustomerSearchFilter;
|
|
8
|
+
private getCustomerCounts;
|
|
9
|
+
private toCustomerSummary;
|
|
10
|
+
getCustomers(organizationId: string, query: CustomerListQuery): Promise<{
|
|
11
|
+
meta: {
|
|
12
|
+
isFirstPage: boolean;
|
|
13
|
+
isLastPage: boolean;
|
|
14
|
+
currentPage: number;
|
|
15
|
+
previousPage: number | null;
|
|
16
|
+
nextPage: number | null;
|
|
17
|
+
pageCount: number;
|
|
18
|
+
totalCount: number;
|
|
19
|
+
};
|
|
20
|
+
list: {
|
|
21
|
+
id: string;
|
|
22
|
+
email: string;
|
|
23
|
+
firstname: string;
|
|
24
|
+
lastname: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
orderCount: number;
|
|
27
|
+
reservationCount: number;
|
|
28
|
+
image?: string | null | undefined;
|
|
29
|
+
name?: string | null | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
}>;
|
|
32
|
+
getCustomer(organizationId: string, userId: string): Promise<{
|
|
33
|
+
customer: {
|
|
34
|
+
id: string;
|
|
35
|
+
email: string;
|
|
36
|
+
firstname: string;
|
|
37
|
+
lastname: string;
|
|
38
|
+
createdAt: Date;
|
|
39
|
+
orderCount: number;
|
|
40
|
+
reservationCount: number;
|
|
41
|
+
image?: string | null | undefined;
|
|
42
|
+
name?: string | null | undefined;
|
|
43
|
+
};
|
|
44
|
+
orders: {
|
|
45
|
+
status: "pending" | "accepted" | "ready-for-dispatch" | "dispatched" | "completed" | "cancelled";
|
|
46
|
+
id: string;
|
|
47
|
+
referenceId: string;
|
|
48
|
+
token: string;
|
|
49
|
+
expiresAt: Date;
|
|
50
|
+
items: {
|
|
51
|
+
translations: {
|
|
52
|
+
locale: "id" | "af" | "sq" | "ar_dz" | "ar_bh" | "ar_eg" | "ar_iq" | "ar_jo" | "ar_kw" | "ar_lb" | "ar_ly" | "ar_ma" | "ar_om" | "ar_qa" | "ar_sa" | "ar_sy" | "ar_tn" | "ar_ae" | "ar_ye" | "eu" | "be" | "bg" | "ca" | "zh_hk" | "zh_cn" | "zh_sg" | "zh_tw" | "hr" | "cs" | "da" | "nl_be" | "nl" | "en" | "en_au" | "en_bz" | "en_ca" | "en_ie" | "en_jm" | "en_nz" | "en_za" | "en_tt" | "en_gb" | "en_us" | "et" | "fo" | "fa" | "fi" | "fr_be" | "fr_ca" | "fr_lu" | "fr" | "fr_ch" | "gd" | "de_at" | "de_li" | "de_lu" | "de" | "de_ch" | "el" | "he" | "hi" | "hu" | "is" | "ga" | "it" | "it_ch" | "ja" | "ko" | "ku" | "lv" | "lt" | "mk" | "ml" | "ms" | "mt" | "no" | "nb" | "nn" | "pl" | "pt_br" | "pt" | "pa" | "rm" | "ro" | "ro_md" | "ru" | "ru_md" | "sr" | "sk" | "sl" | "sb" | "es_ar" | "es_bo" | "es_cl" | "es_co" | "es_cr" | "es_do" | "es_ec" | "es_sv" | "es_gt" | "es_hn" | "es_mx" | "es" | "sv" | "sv_fi" | "th" | "tr" | "uk" | "ur" | "vi" | "cy" | "ji" | "zu";
|
|
53
|
+
title: string;
|
|
54
|
+
subtitle: string;
|
|
55
|
+
}[];
|
|
56
|
+
rawData: {
|
|
57
|
+
productId: string;
|
|
58
|
+
modifierGroups: {
|
|
59
|
+
id: string;
|
|
60
|
+
modifiers: {
|
|
61
|
+
id: string;
|
|
62
|
+
quantity: number;
|
|
63
|
+
}[];
|
|
64
|
+
}[];
|
|
65
|
+
quantity?: number | undefined;
|
|
66
|
+
};
|
|
67
|
+
unitPrice: number;
|
|
68
|
+
totalPrice: number;
|
|
69
|
+
quantity: number;
|
|
70
|
+
productSnapshotId: string;
|
|
71
|
+
image?: {
|
|
72
|
+
id: string;
|
|
73
|
+
url: string;
|
|
74
|
+
mimeType: string;
|
|
75
|
+
size: number;
|
|
76
|
+
filename: string;
|
|
77
|
+
} | null | undefined;
|
|
78
|
+
}[];
|
|
79
|
+
shippingMethod: {
|
|
80
|
+
id: string;
|
|
81
|
+
title: string;
|
|
82
|
+
providerName: string;
|
|
83
|
+
shippingZones: {
|
|
84
|
+
title: string;
|
|
85
|
+
distanceUpto: number;
|
|
86
|
+
price: number;
|
|
87
|
+
minimumOrderAmount: number | null;
|
|
88
|
+
eta: string;
|
|
89
|
+
id?: string | undefined;
|
|
90
|
+
}[];
|
|
91
|
+
createdAt: Date;
|
|
92
|
+
updatedAt: Date;
|
|
93
|
+
providerLogo?: {
|
|
94
|
+
id: string;
|
|
95
|
+
url: string;
|
|
96
|
+
mimeType: string;
|
|
97
|
+
size: number;
|
|
98
|
+
filename: string;
|
|
99
|
+
} | null | undefined;
|
|
100
|
+
requireDateOfDelivery?: boolean | undefined;
|
|
101
|
+
eligibleShippingZone?: {
|
|
102
|
+
title: string;
|
|
103
|
+
distanceUpto: number;
|
|
104
|
+
price: number;
|
|
105
|
+
minimumOrderAmount: number | null;
|
|
106
|
+
eta: string;
|
|
107
|
+
id?: string | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
} | null;
|
|
110
|
+
createdAt: Date;
|
|
111
|
+
fulfilmentMethod: "delivery" | "pickup";
|
|
112
|
+
currency: "USD" | "EUR" | "GBP" | "JPY" | "AUD" | "CAD" | "CHF" | "CNY" | "SEK" | "NZD" | "MXN" | "SGD" | "HKD" | "NOK" | "KRW" | "TRY" | "RUB" | "INR" | "BRL" | "ZAR" | "DKK" | "PLN" | "THB" | "IDR" | "HUF" | "CZK" | "ILS" | "PHP" | "AED" | "COP" | "SAR" | "MYR" | "RON";
|
|
113
|
+
payment: {
|
|
114
|
+
id: string;
|
|
115
|
+
method: "card" | "blik" | "paypal" | "cash_on_delivery";
|
|
116
|
+
provider: "stripe" | "revolut" | "payu" | "not_applicable";
|
|
117
|
+
status: "pending" | "succeeded" | "refunded" | "failed" | "canceled";
|
|
118
|
+
shipping: number;
|
|
119
|
+
subtotal: number;
|
|
120
|
+
total: number;
|
|
121
|
+
discount: number;
|
|
122
|
+
currency: "USD" | "EUR" | "GBP" | "JPY" | "AUD" | "CAD" | "CHF" | "CNY" | "SEK" | "NZD" | "MXN" | "SGD" | "HKD" | "NOK" | "KRW" | "TRY" | "RUB" | "INR" | "BRL" | "ZAR" | "DKK" | "PLN" | "THB" | "IDR" | "HUF" | "CZK" | "ILS" | "PHP" | "AED" | "COP" | "SAR" | "MYR" | "RON";
|
|
123
|
+
};
|
|
124
|
+
acceptedAt?: Date | null | undefined;
|
|
125
|
+
dispatchedAt?: Date | null | undefined;
|
|
126
|
+
readyForDispatchAt?: Date | null | undefined;
|
|
127
|
+
completedAt?: Date | null | undefined;
|
|
128
|
+
cancelledAt?: Date | null | undefined;
|
|
129
|
+
inventoryDeductedAt?: Date | null | undefined;
|
|
130
|
+
inventoryConflictAt?: Date | null | undefined;
|
|
131
|
+
inventoryConflictItems?: {
|
|
132
|
+
productId: string;
|
|
133
|
+
title: string;
|
|
134
|
+
requestedQuantity: number;
|
|
135
|
+
availableQuantity: number;
|
|
136
|
+
}[] | null | undefined;
|
|
137
|
+
shippingAddress?: {
|
|
138
|
+
id: string;
|
|
139
|
+
addressLineOne: string;
|
|
140
|
+
city: string;
|
|
141
|
+
country: string;
|
|
142
|
+
placeId: string;
|
|
143
|
+
firstname?: string | null | undefined;
|
|
144
|
+
lastname?: string | null | undefined;
|
|
145
|
+
phone?: string | null | undefined;
|
|
146
|
+
doorNumber?: string | null | undefined;
|
|
147
|
+
addressLineTwo?: string | null | undefined;
|
|
148
|
+
zipCode?: string | undefined;
|
|
149
|
+
deliveryInstructions?: string | null | undefined;
|
|
150
|
+
} | null | undefined;
|
|
151
|
+
}[];
|
|
152
|
+
reservations: {
|
|
153
|
+
id: string;
|
|
154
|
+
firstname: string;
|
|
155
|
+
lastname: string;
|
|
156
|
+
guests: number;
|
|
157
|
+
phone: string;
|
|
158
|
+
date: Date;
|
|
159
|
+
referenceId: string;
|
|
160
|
+
acceptedAt?: Date | null | undefined;
|
|
161
|
+
cancelledAt?: Date | null | undefined;
|
|
162
|
+
createdAt?: Date | null | undefined;
|
|
163
|
+
}[];
|
|
164
|
+
}>;
|
|
165
|
+
}
|
|
166
|
+
export { CustomerService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as o}from"tslib";import{z as n}from"@hono/zod-openapi";import{HttpException as C}from"../../core/exceptions/http-exception";import{AdminCustomerDetailSchema as y,AdminCustomerSchema as c,OrderSchema as f,PaginationMetaSchema as g,ReservationSchema as A}from"../../schemas";const S={items:{include:{translations:!0,image:!0}},payment:!0,shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}}};class w{constructor(e){this.prisma=e}getCustomerActivityFilter(e){return{OR:[{orders:{some:{organizationId:e,deletedAt:null}}},{reservations:{some:{organizationId:e}}}]}}getCustomerSearchFilter(e){return{OR:[{firstname:{contains:e,mode:"insensitive"}},{lastname:{contains:e,mode:"insensitive"}},{name:{contains:e,mode:"insensitive"}},{email:{contains:e,mode:"insensitive"}}]}}getCustomerCounts(e,t){return o(this,void 0,void 0,function*(){const[r,s]=yield this.prisma.$transaction([this.prisma.order.count({where:{organizationId:e,userId:t,deletedAt:null}}),this.prisma.reservation.count({where:{organizationId:e,userId:t}})]);return{orderCount:r,reservationCount:s}})}toCustomerSummary(e,t){return c.parse(Object.assign(Object.assign({},e),t))}getCustomers(e,t){return o(this,void 0,void 0,function*(){var r;const{page:s=1,limit:m=10}=t,i=(r=t.search)===null||r===void 0?void 0:r.trim(),a=this.getCustomerActivityFilter(e),d=i?{AND:[a,this.getCustomerSearchFilter(i)]}:a,[l,h]=yield this.prisma.user.paginate({where:d,orderBy:{createdAt:"desc"}}).withPages({page:s,limit:m}),p=yield Promise.all(l.map(u=>o(this,void 0,void 0,function*(){const v=yield this.getCustomerCounts(e,u.id);return this.toCustomerSummary(u,v)})));return n.object({meta:g,list:n.array(c)}).parse({meta:h,list:p})})}getCustomer(e,t){return o(this,void 0,void 0,function*(){const r=yield this.prisma.user.findFirst({where:{AND:[{id:t},this.getCustomerActivityFilter(e)]}});if(!r)throw new C(404,"Customer not found");const[s,m,i]=yield Promise.all([this.prisma.order.findMany({where:{organizationId:e,userId:t,deletedAt:null},include:S,orderBy:{createdAt:"desc"}}),this.prisma.reservation.findMany({where:{organizationId:e,userId:t},orderBy:{createdAt:"desc"}}),this.getCustomerCounts(e,t)]);return y.parse({customer:this.toCustomerSummary(r,i),orders:n.array(f).parse(s),reservations:n.array(A).parse(m)})})}}export{w as CustomerService};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.service.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/customer/customer.service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EAEnB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE;QACL,OAAO,EAAE;YACP,YAAY,EAAE,IAAI;YAClB,KAAK,EAAE,IAAI;SACZ;KACF;IACD,OAAO,EAAE,IAAI;IACb,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE;QACd,OAAO,EAAE;YACP,aAAa,EAAE,IAAI;SACpB;KACF;CACO,CAAC;AAEX,MAAM,eAAe;IACnB,YAA6B,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAEjD,yBAAyB,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C,YAAY,CAAC;aAC7D,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
package/src/features/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { registerAnalyticsHandlers } from "./analytics/analytics.handler";
|
|
2
2
|
export { registerAccessHandlers } from "./access/access.handler";
|
|
3
3
|
export { registerCartHandlers } from "./cart/cart.handler";
|
|
4
|
+
export { registerCustomerHandlers } from "./customer/customer.handler";
|
|
4
5
|
export { registerFileHandlers } from "./file/file.handler";
|
|
5
6
|
export { registerHealthHandlers } from "./health/health.handler";
|
|
6
7
|
export { registerIntegrationHandlers } from "./integration/integration.handler";
|
package/src/features/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{registerAnalyticsHandlers}from"./analytics/analytics.handler";export{registerAccessHandlers}from"./access/access.handler";export{registerCartHandlers}from"./cart/cart.handler";export{registerFileHandlers}from"./file/file.handler";export{registerHealthHandlers}from"./health/health.handler";export{registerIntegrationHandlers}from"./integration/integration.handler";export{registerLocationHandlers}from"./location/location.handler";export{registerManufacturerHandlers}from"./manufacturer/manufacturer.handler";export{registerOrderHandlers}from"./order/order.handler";export{registerOrganizationHandlers}from"./organization/organization.handler";export{registerPaymentHandlers}from"./payment/payment.handler";export{registerProductCategoryHandlers}from"./product-category/product-category.handler";export{registerProductHandlers}from"./product/product.handler";export{registerReservationHandlers}from"./reservation/reservation.handler";export{registerShippingHandlers}from"./shipping/shipping.handler";export{registerShippingMethodHandlers}from"./shipping-method/shipping-method.handler";export{registerWebhookHandlers}from"./webhook/webhook.handler";
|
|
1
|
+
export{registerAnalyticsHandlers}from"./analytics/analytics.handler";export{registerAccessHandlers}from"./access/access.handler";export{registerCartHandlers}from"./cart/cart.handler";export{registerCustomerHandlers}from"./customer/customer.handler";export{registerFileHandlers}from"./file/file.handler";export{registerHealthHandlers}from"./health/health.handler";export{registerIntegrationHandlers}from"./integration/integration.handler";export{registerLocationHandlers}from"./location/location.handler";export{registerManufacturerHandlers}from"./manufacturer/manufacturer.handler";export{registerOrderHandlers}from"./order/order.handler";export{registerOrganizationHandlers}from"./organization/organization.handler";export{registerPaymentHandlers}from"./payment/payment.handler";export{registerProductCategoryHandlers}from"./product-category/product-category.handler";export{registerProductHandlers}from"./product/product.handler";export{registerReservationHandlers}from"./reservation/reservation.handler";export{registerShippingHandlers}from"./shipping/shipping.handler";export{registerShippingMethodHandlers}from"./shipping-method/shipping-method.handler";export{registerWebhookHandlers}from"./webhook/webhook.handler";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rest-api/src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rest-api/src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as d}from"tslib";import{createApiRouter as u}from"../../core/hono/hono";import{integrationRoutes as s}from"./integration.route";export const registerIntegrationHandlers=i=>{const a=u();return a.openapi(s.getIntegrations,t=>d(void 0,void 0,void 0,function*(){const o=t.get("auth"),n=t.req.valid("param");yield o.isGranted("read");const e=yield i.getIntegrations(n.organizationId);return t.json(e,200)})),a.openapi(s.upsertIntegration,t=>d(void 0,void 0,void 0,function*(){const o=t.get("auth"),n=t.req.valid("param"),e=t.req.valid("json"),r=yield o.isGranted("update"),p=yield i.upsertIntegration(n.organizationId,n.type,r.id,e);return t.json(p,200)})),a.openapi(s.deleteIntegration,t=>d(void 0,void 0,void 0,function*(){const o=t.get("auth"),n=t.req.valid("param");return yield o.isGranted("update"),yield i.deleteIntegration(n.organizationId,n.type),t.body(null,204)})),a.openapi(s.sendTestEmail,t=>d(void 0,void 0,void 0,function*(){const o=t.get("auth"),n=t.req.valid("param"),e=t.req.valid("json");yield o.isGranted("update");const r=yield i.sendTestEmail(n.organizationId,e.to);return t.json(r,200)})),a.openapi(s.createStripeTestCheckout,t=>d(void 0,void 0,void 0,function*(){const o=t.get("auth"),n=t.req.valid("param"),e=t.req.valid("json"),r=yield o.isGranted("update"),p=yield i.createStripeTestCheckout(n.organizationId,r.email,e.returnUrl);return t.json(p,200)})),a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.handler.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.handler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,OAA2B,EAAE,EAAE;IACzE,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;IAE9B,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAO,CAAC,EAAE,EAAE;QACzD,M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pC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE/B,MAAM,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpE,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC,CAAA,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"integration.handler.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.handler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,OAA2B,EAAE,EAAE;IACzE,MAAM,GAAG,GAAG,eAAe,EAAE,CAAC;IAE9B,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,eAAe,EAAE,CAAO,CAAC,EAAE,EAAE;QACzD,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEpC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAE7B,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAE1E,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC,CAAA,CAAC,CAAC;IAEH,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,CAAO,CAAC,EAAE,EAAE;QAC3D,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAA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CAAC;QAEjC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAE3E,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAA,CAAC,CAAC;IAEH,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,CAAO,CAAC,EAAE,EAAE;QAClE,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,wBAAwB,CACnD,MAAM,CAAC,cAAc,EACrB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,SAAS,CACf,CAAC;QAEF,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAA,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -209,4 +209,179 @@ export declare const integrationRoutes: {
|
|
|
209
209
|
} & {
|
|
210
210
|
getRoutingPath(): string;
|
|
211
211
|
};
|
|
212
|
+
sendTestEmail: {
|
|
213
|
+
description: string | undefined;
|
|
214
|
+
method: import("@hono/zod-openapi").RouteConfig["method"];
|
|
215
|
+
operationId: string;
|
|
216
|
+
path: string;
|
|
217
|
+
request: {
|
|
218
|
+
body: {
|
|
219
|
+
content: {
|
|
220
|
+
"application/json": {
|
|
221
|
+
schema: z.ZodObject<{
|
|
222
|
+
to: z.ZodString;
|
|
223
|
+
}, z.core.$strict>;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
required: boolean;
|
|
227
|
+
};
|
|
228
|
+
} & {
|
|
229
|
+
headers: z.ZodObject<{
|
|
230
|
+
"accept-language": z.ZodOptional<z.ZodString>;
|
|
231
|
+
cookie: z.ZodOptional<z.ZodString>;
|
|
232
|
+
}, z.core.$strip>;
|
|
233
|
+
} & {
|
|
234
|
+
params: z.ZodObject<{
|
|
235
|
+
organizationId: z.ZodString;
|
|
236
|
+
}, z.core.$strip>;
|
|
237
|
+
} & Record<never, never>;
|
|
238
|
+
responses: {
|
|
239
|
+
200: {
|
|
240
|
+
content: {
|
|
241
|
+
"application/json": {
|
|
242
|
+
schema: z.ZodObject<{
|
|
243
|
+
success: z.ZodBoolean;
|
|
244
|
+
message: z.ZodString;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
description: string;
|
|
249
|
+
};
|
|
250
|
+
400: {
|
|
251
|
+
content: {
|
|
252
|
+
"application/json": {
|
|
253
|
+
schema: z.ZodObject<{
|
|
254
|
+
status: z.ZodNumber;
|
|
255
|
+
message: z.ZodString;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
description: string;
|
|
260
|
+
};
|
|
261
|
+
401: {
|
|
262
|
+
content: {
|
|
263
|
+
"application/json": {
|
|
264
|
+
schema: z.ZodObject<{
|
|
265
|
+
status: z.ZodNumber;
|
|
266
|
+
message: z.ZodString;
|
|
267
|
+
}, z.core.$strip>;
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
description: string;
|
|
271
|
+
};
|
|
272
|
+
404: {
|
|
273
|
+
content: {
|
|
274
|
+
"application/json": {
|
|
275
|
+
schema: z.ZodObject<{
|
|
276
|
+
status: z.ZodNumber;
|
|
277
|
+
message: z.ZodString;
|
|
278
|
+
}, z.core.$strip>;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
description: string;
|
|
282
|
+
};
|
|
283
|
+
500: {
|
|
284
|
+
content: {
|
|
285
|
+
"application/json": {
|
|
286
|
+
schema: z.ZodObject<{
|
|
287
|
+
status: z.ZodNumber;
|
|
288
|
+
message: z.ZodString;
|
|
289
|
+
}, z.core.$strip>;
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
description: string;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
summary: string;
|
|
296
|
+
tags: string[];
|
|
297
|
+
} & {
|
|
298
|
+
getRoutingPath(): string;
|
|
299
|
+
};
|
|
300
|
+
createStripeTestCheckout: {
|
|
301
|
+
description: string | undefined;
|
|
302
|
+
method: import("@hono/zod-openapi").RouteConfig["method"];
|
|
303
|
+
operationId: string;
|
|
304
|
+
path: string;
|
|
305
|
+
request: {
|
|
306
|
+
body: {
|
|
307
|
+
content: {
|
|
308
|
+
"application/json": {
|
|
309
|
+
schema: z.ZodObject<{
|
|
310
|
+
returnUrl: z.ZodString;
|
|
311
|
+
}, z.core.$strict>;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
required: boolean;
|
|
315
|
+
};
|
|
316
|
+
} & {
|
|
317
|
+
headers: z.ZodObject<{
|
|
318
|
+
"accept-language": z.ZodOptional<z.ZodString>;
|
|
319
|
+
cookie: z.ZodOptional<z.ZodString>;
|
|
320
|
+
}, z.core.$strip>;
|
|
321
|
+
} & {
|
|
322
|
+
params: z.ZodObject<{
|
|
323
|
+
organizationId: z.ZodString;
|
|
324
|
+
}, z.core.$strip>;
|
|
325
|
+
} & Record<never, never>;
|
|
326
|
+
responses: {
|
|
327
|
+
200: {
|
|
328
|
+
content: {
|
|
329
|
+
"application/json": {
|
|
330
|
+
schema: z.ZodObject<{
|
|
331
|
+
redirectUrl: z.ZodString;
|
|
332
|
+
}, z.core.$strip>;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
description: string;
|
|
336
|
+
};
|
|
337
|
+
400: {
|
|
338
|
+
content: {
|
|
339
|
+
"application/json": {
|
|
340
|
+
schema: z.ZodObject<{
|
|
341
|
+
status: z.ZodNumber;
|
|
342
|
+
message: z.ZodString;
|
|
343
|
+
}, z.core.$strip>;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
description: string;
|
|
347
|
+
};
|
|
348
|
+
401: {
|
|
349
|
+
content: {
|
|
350
|
+
"application/json": {
|
|
351
|
+
schema: z.ZodObject<{
|
|
352
|
+
status: z.ZodNumber;
|
|
353
|
+
message: z.ZodString;
|
|
354
|
+
}, z.core.$strip>;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
description: string;
|
|
358
|
+
};
|
|
359
|
+
404: {
|
|
360
|
+
content: {
|
|
361
|
+
"application/json": {
|
|
362
|
+
schema: z.ZodObject<{
|
|
363
|
+
status: z.ZodNumber;
|
|
364
|
+
message: z.ZodString;
|
|
365
|
+
}, z.core.$strip>;
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
description: string;
|
|
369
|
+
};
|
|
370
|
+
500: {
|
|
371
|
+
content: {
|
|
372
|
+
"application/json": {
|
|
373
|
+
schema: z.ZodObject<{
|
|
374
|
+
status: z.ZodNumber;
|
|
375
|
+
message: z.ZodString;
|
|
376
|
+
}, z.core.$strip>;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
description: string;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
summary: string;
|
|
383
|
+
tags: string[];
|
|
384
|
+
} & {
|
|
385
|
+
getRoutingPath(): string;
|
|
386
|
+
};
|
|
212
387
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as i}from"@hono/zod-openapi";import{createApiRoute as
|
|
1
|
+
import{z as i}from"@hono/zod-openapi";import{createApiRoute as t}from"../../core/hono/hono";import{ErrorSchema as e,HeaderSchema as a,OrganizationParams as n}from"../../schemas";import{CreateStripeTestCheckoutResponseSchema as s,CreateStripeTestCheckoutSchema as p,IntegrationSchema as o,IntegrationTypeSchema as g,SendTestEmailResponseSchema as m,SendTestEmailSchema as d,UpsertIntegrationSchema as h}from"./integration.schema";const r=n.extend({type:g.openapi({param:{in:"path",name:"type"}})}),c=t({description:"Fetches integrations configured for an organization",headers:a,method:"GET",operationId:"getIntegrations",path:"/:organizationId/integrations",pathParams:n,responses:{200:i.array(o),400:e,401:e,404:e},summary:"Get Integrations",tags:["Integration"]}),u=t({body:h,description:"Creates or updates an integration configuration",headers:a,method:"PUT",operationId:"upsertIntegration",path:"/:organizationId/integrations/:type",pathParams:r,responses:{200:o,400:e,401:e,404:e},summary:"Upsert Integration",tags:["Integration"]}),I=t({description:"Deletes an integration configuration",headers:a,method:"DELETE",operationId:"deleteIntegration",path:"/:organizationId/integrations/:type",pathParams:r,responses:{204:null,400:e,401:e,404:e},summary:"Delete Integration",tags:["Integration"]}),S=t({body:d,description:"Sends a test email using the configured Resend integration",headers:a,method:"POST",operationId:"sendTestEmail",path:"/:organizationId/integrations/resend/test",pathParams:n,responses:{200:m,400:e,401:e,404:e,500:e},summary:"Send Test Email",tags:["Integration"]}),T=t({body:p,description:"Creates a Stripe Checkout session with mock products to test the configured Stripe integration",headers:a,method:"POST",operationId:"createStripeTestCheckout",path:"/:organizationId/integrations/stripe/test",pathParams:n,responses:{200:s,400:e,401:e,404:e,500:e},summary:"Create Stripe Test Checkout",tags:["Integration"]});export const integrationRoutes={getIntegrations:c,upsertIntegration:u,deleteIntegration:I,sendTestEmail:S,createStripeTestCheckout:T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.route.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB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O,EAAE,YAAY;IACrB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,mBAAmB;IAChC,IAAI,EAAE,qCAAqC;IAC3C,UAAU,EAAE,iBAAiB;IAC7B,SAAS,EAAE;QACT,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;KACjB;IACD,OAAO,EAAE,oBAAoB;IAC7B,IAAI,EAAE,CAAC,aAAa,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,eAAe,EAAE,oBAAoB;IACrC,iBAAiB,EAAE,sBAAsB;IACzC,iBAAiB,EAAE,sBAAsB;
|
|
1
|
+
{"version":3,"file":"integration.route.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EACL,sCAAsC,EACtC,8BAA8B,EAC9B,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAClD,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC;QAClC,KAAK,EAAE;YACL,EAAE,EAAE,MAAM;YACV,IAAI,EAAE,MAAM;SACb;KACF,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,cAAc,CAAC;IAC1C,WAAW,EAAE,qDAAqD;IAClE,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,iBAAiB;IAC9B,IAAI,EAAE,+BAA+B;IACrC,UA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AAe;IAC5B,IAAI,EAAE,2CAA2C;IACjD,UAAU,EAAE,kBAAkB;IAC9B,SAAS,EAAE;QACT,GAAG,EAAE,2BAA2B;QAChC,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;KACjB;IACD,OAAO,EAAE,iBAAiB;IAC1B,IAAI,EAAE,CAAC,aAAa,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,6BAA6B,GAAG,cAAc,CAAC;IACnD,IAAI,EAAE,8BAA8B;IACpC,WAAW,EACT,gGAAgG;IAClG,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,MAAM;IACd,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE,2CAA2C;IACjD,UAAU,EAAE,kBAAkB;IAC9B,SAAS,EAAE;QACT,GAAG,EAAE,sCAAsC;QAC3C,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;QAChB,GAAG,EAAE,WAAW;KACjB;IACD,OAAO,EAAE,6BAA6B;IACtC,IAAI,EAAE,CAAC,aAAa,CAAC;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,eAAe,EAAE,oBAAoB;IACrC,iBAAiB,EAAE,sBAAsB;IACzC,iBAAiB,EAAE,sBAAsB;IACzC,aAAa,EAAE,kBAAkB;IACjC,wBAAwB,EAAE,6BAA6B;CACxD,CAAC"}
|
|
@@ -57,3 +57,16 @@ export type UpsertStripeIntegrationConfig = z.infer<typeof UpsertStripeIntegrati
|
|
|
57
57
|
export type ResendIntegrationConfig = z.infer<typeof ResendIntegrationConfigSchema>;
|
|
58
58
|
export type ResendIntegrationStoredConfig = z.infer<typeof ResendIntegrationStoredConfigSchema>;
|
|
59
59
|
export type UpsertResendIntegrationConfig = z.infer<typeof UpsertResendIntegrationConfigSchema>;
|
|
60
|
+
export declare const SendTestEmailSchema: z.ZodObject<{
|
|
61
|
+
to: z.ZodString;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
export declare const SendTestEmailResponseSchema: z.ZodObject<{
|
|
64
|
+
success: z.ZodBoolean;
|
|
65
|
+
message: z.ZodString;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export declare const CreateStripeTestCheckoutSchema: z.ZodObject<{
|
|
68
|
+
returnUrl: z.ZodString;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export declare const CreateStripeTestCheckoutResponseSchema: z.ZodObject<{
|
|
71
|
+
redirectUrl: z.ZodString;
|
|
72
|
+
}, z.core.$strip>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"@hono/zod-openapi";export const IntegrationTypeSchema=e.string().min(1).openapi({example:"stripe",description:"Integration type key"}),StripePaymentMethodSchema=e.enum(["card","blik"]).openapi({example:"card",description:"Stripe payment method"}),StripeIntegrationStoredConfigSchema=e.object({paymentMethods:e.array(StripePaymentMethodSchema).max(2).optional(),secretKey:e.string().trim().min(1).optional(),webhookSecret:e.string().trim().min(1).optional()}).strict(),ResendIntegrationStoredConfigSchema=e.object({apiKey:e.string().trim().min(1).optional(),fromEmail:e.string().trim().email().optional()}).strict(),StripeIntegrationConfigSchema=e.object({paymentMethods:e.array(StripePaymentMethodSchema).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),hasSecretKey:e.boolean().openapi({example:!0,description:"Whether the Stripe API key has been configured"}),hasWebhookSecret:e.boolean().openapi({example:!0,description:"Whether the Stripe webhook signing secret has been configured"})}).strict().openapi("StripeIntegrationConfig"),UpsertStripeIntegrationConfigSchema=e.object({paymentMethods:e.array(StripePaymentMethodSchema).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),secretKey:e.string().trim().min(1).optional().openapi({example:"sk_live_123456789",description:"Stripe secret API key for the organization"}),webhookSecret:e.string().trim().min(1).optional().openapi({example:"whsec_123456789",description:"Stripe webhook signing secret for the organization"})}).strict().openapi("UpsertStripeIntegrationConfig"),ResendIntegrationConfigSchema=e.object({hasApiKey:e.boolean().openapi({example:!0,description:"Whether the Resend API key has been configured"}),fromEmail:e.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("ResendIntegrationConfig"),UpsertResendIntegrationConfigSchema=e.object({apiKey:e.string().trim().min(1).optional().openapi({example:"re_123456789",description:"Resend API key for the organization"}),fromEmail:e.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("UpsertResendIntegrationConfig"),IntegrationConfigSchema=e.record(e.string(),e.unknown()).openapi("IntegrationConfig"),IntegrationSchema=e.object({organizationId:e.string().openapi({example:"clm1234567890abcdef",description:"Organization ID"}),type:IntegrationTypeSchema,config:IntegrationConfigSchema.openapi({description:"Stored integration configuration JSON"}),createdAt:e.date().openapi({description:"Timestamp when the integration was created"}),updatedAt:e.date().openapi({description:"Timestamp when the integration was last updated"})}).openapi("Integration"),UpsertIntegrationSchema=e.object({config:e.unknown().openapi({example:{paymentMethods:["card","blik"],secretKey:"sk_live_123456789",webhookSecret:"whsec_123456789"},description:"Integration configuration payload. Validation depends on the integration type."})}).openapi("UpsertIntegration");
|
|
1
|
+
import{z as e}from"@hono/zod-openapi";export const IntegrationTypeSchema=e.string().min(1).openapi({example:"stripe",description:"Integration type key"}),StripePaymentMethodSchema=e.enum(["card","blik"]).openapi({example:"card",description:"Stripe payment method"}),StripeIntegrationStoredConfigSchema=e.object({paymentMethods:e.array(StripePaymentMethodSchema).max(2).optional(),secretKey:e.string().trim().min(1).optional(),webhookSecret:e.string().trim().min(1).optional()}).strict(),ResendIntegrationStoredConfigSchema=e.object({apiKey:e.string().trim().min(1).optional(),fromEmail:e.string().trim().email().optional()}).strict(),StripeIntegrationConfigSchema=e.object({paymentMethods:e.array(StripePaymentMethodSchema).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),hasSecretKey:e.boolean().openapi({example:!0,description:"Whether the Stripe API key has been configured"}),hasWebhookSecret:e.boolean().openapi({example:!0,description:"Whether the Stripe webhook signing secret has been configured"})}).strict().openapi("StripeIntegrationConfig"),UpsertStripeIntegrationConfigSchema=e.object({paymentMethods:e.array(StripePaymentMethodSchema).max(2).openapi({example:["card","blik"],description:"Enabled Stripe payment methods for the organization"}),secretKey:e.string().trim().min(1).optional().openapi({example:"sk_live_123456789",description:"Stripe secret API key for the organization"}),webhookSecret:e.string().trim().min(1).optional().openapi({example:"whsec_123456789",description:"Stripe webhook signing secret for the organization"})}).strict().openapi("UpsertStripeIntegrationConfig"),ResendIntegrationConfigSchema=e.object({hasApiKey:e.boolean().openapi({example:!0,description:"Whether the Resend API key has been configured"}),fromEmail:e.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("ResendIntegrationConfig"),UpsertResendIntegrationConfigSchema=e.object({apiKey:e.string().trim().min(1).optional().openapi({example:"re_123456789",description:"Resend API key for the organization"}),fromEmail:e.string().trim().email().optional().openapi({example:"orders@example.com",description:"Verified sender email used for transactional messages"})}).strict().openapi("UpsertResendIntegrationConfig"),IntegrationConfigSchema=e.record(e.string(),e.unknown()).openapi("IntegrationConfig"),IntegrationSchema=e.object({organizationId:e.string().openapi({example:"clm1234567890abcdef",description:"Organization ID"}),type:IntegrationTypeSchema,config:IntegrationConfigSchema.openapi({description:"Stored integration configuration JSON"}),createdAt:e.date().openapi({description:"Timestamp when the integration was created"}),updatedAt:e.date().openapi({description:"Timestamp when the integration was last updated"})}).openapi("Integration"),UpsertIntegrationSchema=e.object({config:e.unknown().openapi({example:{paymentMethods:["card","blik"],secretKey:"sk_live_123456789",webhookSecret:"whsec_123456789"},description:"Integration configuration payload. Validation depends on the integration type."})}).openapi("UpsertIntegration"),SendTestEmailSchema=e.object({to:e.string().trim().email("Enter a valid recipient email.").openapi({example:"test@example.com",description:"Recipient email for the test message"})}).strict().openapi("SendTestEmail"),SendTestEmailResponseSchema=e.object({success:e.boolean().openapi({example:!0,description:"Whether the test email was sent successfully"}),message:e.string().openapi({example:"Test email sent to test@example.com",description:"Result message"})}).openapi("SendTestEmailResponse"),CreateStripeTestCheckoutSchema=e.object({returnUrl:e.string().url().openapi({example:"https://app.shophost.test/admin/settings/integrations/stripe",description:"URL to return to after the Stripe test checkout is completed or cancelled"})}).strict().openapi("CreateStripeTestCheckout"),CreateStripeTestCheckoutResponseSchema=e.object({redirectUrl:e.string().url().openapi({example:"https://checkout.stripe.com/c/pay/cs_test_123",description:"Stripe Checkout URL for the mock test session"})}).openapi("CreateStripeTestCheckoutResponse");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.schema.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7D,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,sBAAsB;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IACxE,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,uBAAuB;CACrC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC;KACjD,MAAM,CAAC;IACN,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC9C,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE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AC5D,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC;QAC1B,OAAO,EAAE,qCAAqC;QAC9C,WAAW,EAAE,gBAAgB;KAC9B,CAAC;CACH,CAAC;KACD,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC;KAC5C,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;QAClC,OAAO,EAAE,8DAA8D;QACvE,WAAW,EACT,2EAA2E;KAC9E,CAAC;CACH,CAAC;KACD,MAAM,EAAE;KACR,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC;KACpD,MAAM,CAAC;IACN,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC;QACpC,OAAO,EAAE,+CAA+C;QACxD,WAAW,EAAE,+CAA+C;KAC7D,CAAC;CACH,CAAC;KACD,OAAO,CAAC,kCAAkC,CAAC,CAAC"}
|
|
@@ -25,5 +25,12 @@ declare class IntegrationService {
|
|
|
25
25
|
updatedAt: Date;
|
|
26
26
|
}>;
|
|
27
27
|
deleteIntegration(organizationId: string, type: string): Promise<void>;
|
|
28
|
+
sendTestEmail(organizationId: string, to: string): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
message: string;
|
|
31
|
+
}>;
|
|
32
|
+
createStripeTestCheckout(organizationId: string, customerEmail: string, returnUrl: string): Promise<{
|
|
33
|
+
redirectUrl: string;
|
|
34
|
+
}>;
|
|
28
35
|
}
|
|
29
36
|
export { IntegrationService };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as g}from"tslib";import{HttpException as o}from"../../core/exceptions/http-exception";import{EmailService as S}from"../../core/notifications/email.service";import{IntegrationSchema as b,ResendIntegrationConfigSchema as E,StripeIntegrationConfigSchema as k,UpsertResendIntegrationConfigSchema as z,UpsertStripeIntegrationConfigSchema as x}from"./integration.schema";import{getStoredStripeConfig as C,getStoredResendConfig as R,normalizeEmail as K,normalizeSecret as y,normalizeStripePaymentMethods as _,parseResendStoredConfig as v,parseStripeStoredConfig as w}from"./integration-config";import{StripeService as M}from"../payment/stripe.service";class U{constructor(e,i){this.prisma=e,this.integrationRegistry=i}sanitizeConfig(e,i){var n;switch(e){case"stripe":{const t=w(i);return k.parse({paymentMethods:(n=t?.paymentMethods)!==null&&n!==void 0?n:[],hasSecretKey:!!t?.secretKey,hasWebhookSecret:!!t?.webhookSecret})}case"resend":{const t=v(i);return E.parse({hasApiKey:!!t?.apiKey,fromEmail:t?.fromEmail})}default:return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}}sanitizeIntegration(e){return b.parse(Object.assign(Object.assign({},e),{config:this.sanitizeConfig(e.type,e.config)}))}ensureOrganizationExists(e){return g(this,void 0,void 0,function*(){if(!(yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0}})))throw new o(404,"Organization not found")})}validateConfig(e,i,n){var t,r,c,d,u,l,h,m;switch(e){case"stripe":{const s=x.safeParse(i);if(!s.success)throw new o(400,(r=(t=s.error.issues[0])===null||t===void 0?void 0:t.message)!==null&&r!==void 0?r:"Invalid Stripe configuration");const a=w(n),f=(c=y(s.data.secretKey))!==null&&c!==void 0?c:a?.secretKey,p=(d=y(s.data.webhookSecret))!==null&&d!==void 0?d:a?.webhookSecret;if(!f)throw new o(400,"Stripe API key is required");if(!p)throw new o(400,"Stripe webhook secret is required");return{paymentMethods:_(s.data.paymentMethods),secretKey:f,webhookSecret:p}}case"resend":{const s=z.safeParse(i);if(!s.success)throw new o(400,(l=(u=s.error.issues[0])===null||u===void 0?void 0:u.message)!==null&&l!==void 0?l:"Invalid Resend configuration");const a=v(n),f=(h=y(s.data.apiKey))!==null&&h!==void 0?h:a?.apiKey,p=(m=K(s.data.fromEmail))!==null&&m!==void 0?m:a?.fromEmail;if(!f)throw new o(400,"Resend API key is required");if(!p)throw new o(400,"Resend sender email is required");return{apiKey:f,fromEmail:p}}default:throw new o(400,`Unsupported integration type: ${e}`)}}getIntegrations(e){return g(this,void 0,void 0,function*(){return yield this.ensureOrganizationExists(e),(yield this.integrationRegistry.list(e)).map(n=>this.sanitizeIntegration(n))})}upsertIntegration(e,i,n,t){return g(this,void 0,void 0,function*(){yield this.ensureOrganizationExists(e);const r=yield this.integrationRegistry.get(e,i),c=this.validateConfig(i,t.config,r?.config),d=yield this.prisma.integration.upsert({where:{organizationId_type:{organizationId:e,type:i}},update:{config:c,updatedBy:n},create:{organization:{connect:{id:e}},type:i,config:c,createdBy:n,updatedBy:n}});return yield this.integrationRegistry.upsert(d),this.sanitizeIntegration(d)})}deleteIntegration(e,i){return g(this,void 0,void 0,function*(){if(yield this.ensureOrganizationExists(e),(yield this.prisma.integration.deleteMany({where:{organizationId:e,type:i}})).count===0)throw new o(404,"Integration not found");yield this.integrationRegistry.delete(e,i)})}sendTestEmail(e,i){return g(this,void 0,void 0,function*(){const n=yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0,name:!0,email:!0}});if(!n)throw new o(404,"Organization not found");const t=yield this.integrationRegistry.get(e,"resend"),r=R(t);if(!r?.apiKey)throw new o(400,"Resend API key is not configured. Save the integration first.");if(!r.fromEmail)throw new o(400,"Sender email is not configured. Save the integration first.");const c=new S({apiKey:r.apiKey,fromEmail:r.fromEmail});try{return yield c.sendEmail({from:`${n.name} <${r.fromEmail}>`,to:[i],subject:`Test Email from ${n.name}`,html:[`<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 560px; margin: 0 auto; padding: 40px 20px;">`,'<h1 style="font-size: 20px; font-weight: 600; color: #111827; margin: 0 0 16px;">Email integration is working</h1>','<p style="font-size: 14px; line-height: 1.6; color: #6b7280; margin: 0 0 24px;">',`This is a test email sent from <strong style="color: #111827;">${n.name}</strong> to verify that your Resend integration is configured correctly.`,"</p>",'<hr style="border: none; border-top: 1px solid #e5e7eb; margin: 24px 0;" />','<p style="font-size: 12px; color: #9ca3af; margin: 0;">',`Sent via Shophost · Sender: ${r.fromEmail}`,"</p>","</div>"].join("")}),{success:!0,message:`Test email sent to ${i}`}}catch(d){const u=d instanceof Error?d.message:"Unknown error";throw new o(500,`Failed to send test email: ${u}`)}})}createStripeTestCheckout(e,i,n){return g(this,void 0,void 0,function*(){var t,r,c;const d=yield this.prisma.organization.findUnique({where:{id:e,deletedAt:null},select:{id:!0,name:!0,configuration:{select:{defaultCurrency:!0}}}});if(!d)throw new o(404,"Organization not found");const u=yield this.integrationRegistry.get(e,"stripe"),l=C(u);if(!l?.secretKey)throw new o(400,"Stripe API key is not configured. Save the integration first.");if(!l.webhookSecret)throw new o(400,"Stripe webhook secret is not configured. Save the integration first.");const h=!((t=l.paymentMethods)===null||t===void 0)&&t.includes("card")?"card":(r=l.paymentMethods)===null||r===void 0?void 0:r[0];if(!h)throw new o(400,"Enable at least one Stripe payment method before testing.");const m=new M(this.prisma,{secretKey:l.secretKey,webhookSecret:l.webhookSecret,paymentMethods:(c=l.paymentMethods)!==null&&c!==void 0?c:[]});try{const s=yield m.createTestCheckoutSession({cancelUrl:n,currency:h==="blik"?"pln":d.configuration.defaultCurrency.toLowerCase(),customerEmail:i,organizationName:d.name,paymentMethod:h,successUrl:n});if(!s.url)throw new o(500,"Stripe did not return a checkout URL for the test session.");return{redirectUrl:s.url}}catch(s){if(s instanceof o)throw s;const a=s instanceof Error?s.message:"Unknown error";throw new o(500,`Failed to create Stripe test checkout: ${a}`)}})}}export{U as IntegrationService};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.service.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.service.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,6BAA6B,EAE7B,mCAAmC,EACnC,mCAAmC,GACpC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,EACd,eAAe,EACf,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration.service.js","sourceRoot":"","sources":["../../../../../../packages/rest-api/src/features/integration/integration.service.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,6BAA6B,EAE7B,mCAAmC,EACnC,mCAAmC,GACpC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,6BAA6B,EAC7B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,kBAAkB;IACtB,YACmB,MAAwB,EACxB,mBAAwC;QADxC,WAAM,GAAN,MAAM,CAAkB;QACxB,wBAAmB,GAAnB,mBAAmB,CAAqB;IACxD,CAAC;IAEI,cAAc,CAAC,IAAY,EAAE,MAAe;;QAClD,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;gBAE/C,OAAO,6BAA6B,CAAC,KAAK,CAAC;oBACzC,cAAc,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,mCAAI,EAAE;oBAC5C,YAAY,EAAE,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAC;oBACxC,gBAAgB,EAAE,OAAO,CAA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,IAAI,aAAa,CACrB,GAAG,EACH,4DAA4D,CAC7D,CAAC;gBACJ,CAAC;gBAED,OAAO;oBACL,WAAW,EAAE,OAAO,CAAC,GAAG;iBACzB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,aAAa,EAAE,CAAC;oBACnC,MAAM,KAAK,CAAC;gBACd,CAAC;gBAED,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;gBAE3D,MAAM,IAAI,aAAa,CACrB,GAAG,EACH,0CAA0C,YAAY,EAAE,CACzD,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as u}from"tslib";import{HttpException as
|
|
1
|
+
import{__awaiter as u}from"tslib";import{HttpException as a}from"../../core/exceptions/http-exception";import{getStoredResendConfig as l,getStoredStripeConfig as v}from"../integration/integration-config";import{StripeService as h}from"./stripe.service";class m{constructor(t,r,e,i){this.prisma=t,this.options=r,this.integrationRegistry=e,this.inventoryService=i,this.stripeRuntimes=new Map}getStripeNotConfiguredMessage(t){return t?"Stripe integration is not configured for this organization":"Stripe integration is not configured"}resolveStripeRuntime(t){return u(this,void 0,void 0,function*(){var r;if(!t)return;const e=v(yield this.integrationRegistry.get(t,"stripe")),i=e?.secretKey;if(!i){this.stripeRuntimes.delete(t);return}const n=l(yield this.integrationRegistry.get(t,"resend")),s={secretKey:i,paymentMethods:(r=e?.paymentMethods)!==null&&r!==void 0?r:[],resendApiKey:n?.apiKey,resendFromEmail:n?.fromEmail,webhookSecret:e?.webhookSecret},c=JSON.stringify({resend:n??null,stripe:e??null}),d=this.stripeRuntimes.get(t);if(d?.signature===c)return d;const o={options:s,service:new h(this.prisma,s),signature:c};return this.stripeRuntimes.set(t,o),o})}requireStripeRuntime(t){return u(this,void 0,void 0,function*(){const r=yield this.resolveStripeRuntime(t);if(!r)throw new a(400,this.getStripeNotConfiguredMessage(t));return r})}getPaymentMethods(t){return u(this,void 0,void 0,function*(){var r;const e=[],i=(r=yield this.resolveStripeRuntime(t))===null||r===void 0?void 0:r.options;return i?.paymentMethods.includes("card")&&e.push({id:"stripe:card",provider:"stripe",description:"Visa, Mastercard, American Express etc..",method:"card"}),i?.paymentMethods.includes("blik")&&e.push({id:"stripe:blik",provider:"stripe",description:"Popular payment method in Poland",method:"blik"}),this.options.revolut&&this.options.revolut.paymentMethods.includes("card")&&e.push({id:"revolut:card",provider:"revolut",description:"Visa, Mastercard, American Express etc..",method:"card"}),this.options.revolut&&this.options.revolut.paymentMethods.includes("blik")&&e.push({id:"revolut:blik",provider:"revolut",description:"Popular payment method in Poland",method:"blik"}),e})}handleCheckoutSessionByProvider(t,r,e,i){return u(this,void 0,void 0,function*(){if(e.payment.provider==="stripe")return(yield this.requireStripeRuntime(t)).service.createCheckoutSession(r,e,i);throw new a(400,"Payment provider not supported")})}createCheckoutSession(t,r,e,i){return u(this,void 0,void 0,function*(){const n=yield this.handleCheckoutSessionByProvider(t,r,e,i);return yield this.prisma.paymentSession.create({data:{payment:{connect:{id:e.payment.id}},referenceId:n.id,amount:e.payment.total,currency:e.payment.currency,rawData:JSON.stringify(n)}}),{sessionId:n.id,redirectUrl:n.url}})}processWebhookEvent(t,r,e,i){return u(this,void 0,void 0,function*(){if(!r)throw new a(401,"Signature is required");if(t==="stripe"){const n=yield this.requireStripeRuntime(i),s=n.service.constructWebhookEvent(r,e);return s.type==="checkout.session.completed"?this.handleStripeCheckoutCompleted(s.data.object,n.service,i):void 0}else throw new a(400,"Payment provider not supported")})}handleStripeCheckoutCompleted(t,r,e){return u(this,void 0,void 0,function*(){var i,n,s,c,d;if(((i=t.metadata)===null||i===void 0?void 0:i.testIntegration)==="true")return;const o=yield this.prisma.paymentSession.findFirst({where:Object.assign({referenceId:t.id},e?{payment:{order:{organizationId:e}}}:{}),include:{payment:{include:{order:!0}}}});if(!o)throw new a(404,"Payment session not found");const p=(n=o.payment)===null||n===void 0?void 0:n.order;if(!p)throw new a(404,"Order not found");o.capturedAt&&(p.inventoryDeductedAt||p.inventoryConflictAt)||((!o.capturedAt||o.payment.status!=="succeeded")&&(yield this.prisma.paymentSession.update({where:{id:o.id},data:{capturedAt:(s=o.capturedAt)!==null&&s!==void 0?s:new Date,payment:{update:{status:"succeeded"}}}})),(yield this.inventoryService.processPaidOrderInventory(p.id)).status!=="deducted")||(yield r.sendOrderNotifications(p.id,(d=(c=t.metadata)===null||c===void 0?void 0:c.userId)!==null&&d!==void 0?d:p.userId))})}}export{m as PaymentService};
|