@shophost/rest-api 2.0.34 → 2.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -13
- package/README.md +76 -66
- package/package.json +2 -2
- package/scripts/minify-dist.mjs +45 -0
- package/src/app.js +1 -53
- package/src/app.js.map +1 -1
- package/src/core/auth/auth.schema.js +1 -41
- package/src/core/auth/auth.util.js +1 -44
- package/src/core/auth/better-auth.lib.js +1 -100
- package/src/core/auth/generate-password-hash.util.js +1 -30
- package/src/core/auth/headers.schema.js +1 -22
- package/src/core/auth/user.schema.js +1 -30
- package/src/core/db/__generated__/client/browser.js +1 -18
- package/src/core/db/__generated__/client/client.js +1 -35
- package/src/core/db/__generated__/client/commonInputTypes.js +1 -11
- package/src/core/db/__generated__/client/enums.js +1 -200
- package/src/core/db/__generated__/client/internal/class.js +769 -55
- package/src/core/db/__generated__/client/internal/prismaNamespace.d.ts +2 -2
- package/src/core/db/__generated__/client/internal/prismaNamespace.js +1 -541
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js +1 -512
- package/src/core/db/__generated__/client/models/Account.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Account.js +1 -2
- package/src/core/db/__generated__/client/models/Address.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Address.js +1 -2
- package/src/core/db/__generated__/client/models/Campaign.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Campaign.js +1 -2
- package/src/core/db/__generated__/client/models/ClosingTimes.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ClosingTimes.js +1 -2
- package/src/core/db/__generated__/client/models/File.d.ts +0 -5
- package/src/core/db/__generated__/client/models/File.js +1 -2
- package/src/core/db/__generated__/client/models/Invitation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Invitation.js +1 -2
- package/src/core/db/__generated__/client/models/LegalEntity.d.ts +0 -5
- package/src/core/db/__generated__/client/models/LegalEntity.js +1 -2
- package/src/core/db/__generated__/client/models/Manufacturer.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Manufacturer.js +1 -2
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Member.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Member.js +1 -2
- package/src/core/db/__generated__/client/models/Modifier.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Modifier.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroup.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ModifierGroup.js +1 -2
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/OpeningTimes.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OpeningTimes.js +1 -2
- package/src/core/db/__generated__/client/models/Order.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Order.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItem.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OrderItem.js +1 -2
- package/src/core/db/__generated__/client/models/OrderItemTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Organization.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Organization.js +1 -2
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.d.ts +0 -5
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js +1 -2
- package/src/core/db/__generated__/client/models/Payment.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Payment.js +1 -2
- package/src/core/db/__generated__/client/models/PaymentSession.d.ts +0 -5
- package/src/core/db/__generated__/client/models/PaymentSession.js +1 -2
- package/src/core/db/__generated__/client/models/Product.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Product.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategory.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductCategory.js +1 -2
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/ProductSnapshot.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductSnapshot.js +1 -2
- package/src/core/db/__generated__/client/models/ProductTranslation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ProductTranslation.js +1 -2
- package/src/core/db/__generated__/client/models/Reservation.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Reservation.js +1 -2
- package/src/core/db/__generated__/client/models/Session.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Session.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingMethod.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ShippingMethod.js +1 -2
- package/src/core/db/__generated__/client/models/ShippingZone.d.ts +0 -5
- package/src/core/db/__generated__/client/models/ShippingZone.js +1 -2
- package/src/core/db/__generated__/client/models/User.d.ts +0 -5
- package/src/core/db/__generated__/client/models/User.js +1 -2
- package/src/core/db/__generated__/client/models/Verification.d.ts +0 -5
- package/src/core/db/__generated__/client/models/Verification.js +1 -2
- package/src/core/db/__generated__/client/models.js +1 -2
- package/src/core/db/index.js +1 -2
- package/src/core/email/components.d.ts +16 -0
- package/src/core/email/components.js +1 -0
- package/src/core/email/components.js.map +1 -0
- package/src/core/exceptions/http-exception.js +1 -9
- package/src/core/hono/hono.js +1 -123
- package/src/core/lib/prisma.d.ts +8 -8
- package/src/core/lib/prisma.js +1 -11
- package/src/core/logging/pino.js +1 -5
- package/src/core/notifications/email.service.js +1 -116
- package/src/core/openapi/openapi.lib.js +1 -26
- package/src/core/types/google-maps.types.js +1 -2
- package/src/core/utils/currency.util.js +1 -11
- package/src/core/utils/env.util.js +1 -8
- package/src/core/utils/object.util.js +1 -39
- package/src/core/utils/translations.util.js +0 -1
- package/src/core/utils/zod.util.js +1 -85
- package/src/db.js +1 -3
- package/src/features/access/access.handler.js +1 -91
- package/src/features/access/access.route.js +1 -220
- package/src/features/access/access.schema.js +1 -108
- package/src/features/access/access.service.js +1 -294
- package/src/features/analytics/analytics.handler.d.ts +2 -0
- package/src/features/analytics/analytics.handler.js +1 -0
- package/src/features/analytics/analytics.handler.js.map +1 -0
- package/src/features/analytics/analytics.route.d.ts +3 -0
- package/src/features/analytics/analytics.route.js +1 -0
- package/src/features/analytics/analytics.route.js.map +1 -0
- package/src/features/analytics/analytics.schema.d.ts +86 -0
- package/src/features/analytics/analytics.schema.js +1 -0
- package/src/features/analytics/analytics.schema.js.map +1 -0
- package/src/features/analytics/analytics.service.d.ts +45 -0
- package/src/features/analytics/analytics.service.js +1 -0
- package/src/features/analytics/analytics.service.js.map +1 -0
- package/src/features/cart/cart.handler.js +1 -17
- package/src/features/cart/cart.route.js +1 -32
- package/src/features/cart/cart.schema.d.ts +1 -1
- package/src/features/cart/cart.schema.js +1 -39
- package/src/features/cart/cart.service.d.ts +1 -1
- package/src/features/cart/cart.service.js +1 -97
- package/src/features/cart/cart.util.js +1 -76
- package/src/features/file/file.handler.js +1 -23
- package/src/features/file/file.route.js +1 -34
- package/src/features/file/file.schema.js +1 -77
- package/src/features/file/file.service.js +1 -66
- package/src/features/health/health.handler.js +1 -10
- package/src/features/health/health.route.js +1 -25
- package/src/features/index.d.ts +1 -0
- package/src/features/index.js +1 -16
- package/src/features/index.js.map +1 -1
- package/src/features/location/location.handler.js +1 -25
- package/src/features/location/location.route.js +1 -56
- package/src/features/location/location.schema.js +1 -50
- package/src/features/location/location.service.js +1 -141
- package/src/features/manufacturer/manufacturer.handler.js +1 -53
- package/src/features/manufacturer/manufacturer.route.js +1 -97
- package/src/features/manufacturer/manufacturer.schema.js +1 -125
- package/src/features/manufacturer/manufacturer.service.js +1 -190
- package/src/features/order/emails/order-confirmation.email.js +1 -229
- package/src/features/order/emails/order-confirmation.email.js.map +1 -1
- package/src/features/order/emails/order-notification.email.js +1 -229
- package/src/features/order/emails/order-notification.email.js.map +1 -1
- package/src/features/order/fulfilment.schema.js +1 -3
- package/src/features/order/order.handler.js +1 -54
- package/src/features/order/order.route.js +1 -111
- package/src/features/order/order.schema.d.ts +4 -4
- package/src/features/order/order.schema.js +1 -158
- package/src/features/order/order.service.d.ts +4 -4
- package/src/features/order/order.service.js +1 -306
- package/src/features/order/recipient.schema.js +1 -38
- package/src/features/organization/legal-entity.schema.js +1 -83
- package/src/features/organization/organization-configuration.schema.js +1 -115
- package/src/features/organization/organization.handler.js +1 -48
- package/src/features/organization/organization.route.js +1 -84
- package/src/features/organization/organization.schema.js +1 -64
- package/src/features/organization/organization.service.js +1 -334
- package/src/features/payment/payment.handler.js +1 -16
- package/src/features/payment/payment.route.js +1 -22
- package/src/features/payment/payment.schema.d.ts +3 -3
- package/src/features/payment/payment.schema.js +1 -46
- package/src/features/payment/payment.service.d.ts +1 -1
- package/src/features/payment/payment.service.js +1 -100
- package/src/features/payment/stripe.service.js +1 -164
- package/src/features/product/product-modifier.schema.js +1 -84
- package/src/features/product/product.handler.js +1 -87
- package/src/features/product/product.route.js +1 -179
- package/src/features/product/product.schema.d.ts +3 -3
- package/src/features/product/product.schema.js +1 -143
- package/src/features/product/product.service.d.ts +2 -2
- package/src/features/product/product.service.js +1 -440
- package/src/features/product-category/product-category.handler.js +1 -59
- package/src/features/product-category/product-category.route.js +1 -139
- package/src/features/product-category/product-category.schema.js +1 -86
- package/src/features/product-category/product-category.service.js +1 -220
- package/src/features/reservation/emails/reservation-cancellation.email.js +1 -82
- package/src/features/reservation/emails/reservation-cancellation.email.js.map +1 -1
- package/src/features/reservation/emails/reservation-confirmation.email.js +1 -82
- package/src/features/reservation/emails/reservation-confirmation.email.js.map +1 -1
- package/src/features/reservation/emails/reservation-notification.email.js +1 -93
- package/src/features/reservation/emails/reservation-notification.email.js.map +1 -1
- package/src/features/reservation/reservation.handler.js +1 -65
- package/src/features/reservation/reservation.route.js +1 -167
- package/src/features/reservation/reservation.schema.d.ts +1 -1
- package/src/features/reservation/reservation.schema.js +1 -51
- package/src/features/reservation/reservation.service.js +1 -231
- package/src/features/shipping/shipping.handler.js +1 -32
- package/src/features/shipping/shipping.route.js +1 -51
- package/src/features/shipping/shipping.service.js +1 -96
- package/src/features/shipping-method/shipping-method.handler.js +1 -60
- package/src/features/shipping-method/shipping-method.route.js +1 -144
- package/src/features/shipping-method/shipping-method.schema.js +1 -48
- package/src/features/shipping-method/shipping-method.service.js +1 -229
- package/src/features/shipping-method/shipping-zone.schema.js +1 -31
- package/src/features/webhook/webhook.handler.js +1 -50
- package/src/features/webhook/webhook.route.js +1 -33
- package/src/index.js +1 -6
- package/src/integrations/next.js +1 -82
- package/src/schemas/address.schema.js +1 -112
- package/src/schemas/currency.schema.js +1 -118
- package/src/schemas/error.schema.js +1 -12
- package/src/schemas/index.d.ts +1 -0
- package/src/schemas/index.js +1 -29
- package/src/schemas/index.js.map +1 -1
- package/src/schemas/locales.schema.js +1 -238
- package/src/schemas/number.schema.js +1 -29
- package/src/schemas/pagination.schema.js +1 -54
- package/src/schemas/params.schema.js +1 -20
- package/src/schemas/queries.schema.js +1 -6
- package/src/test/global-setup.js +1 -37
- package/src/test/integration/api-fixtures.js +1 -160
- package/src/test/integration/seed.js +1 -368
- package/src/test/integration/test-helpers.d.ts +2 -0
- package/src/test/integration/test-helpers.js +1 -154
- package/src/test/integration/test-helpers.js.map +1 -1
- package/src/test/setup-test-env.js +1 -7
|
@@ -1,160 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import { vi } from "vitest";
|
|
4
|
-
import { LocationService } from "../../features/location/location.service";
|
|
5
|
-
export const requestJson = (context, path, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6
|
-
return context.app.request(path, {
|
|
7
|
-
method: options.method,
|
|
8
|
-
headers: options.body === undefined
|
|
9
|
-
? undefined
|
|
10
|
-
: {
|
|
11
|
-
"content-type": "application/json",
|
|
12
|
-
},
|
|
13
|
-
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
export const mockPlaceDetails = () => {
|
|
17
|
-
return vi
|
|
18
|
-
.spyOn(LocationService.prototype, "getPlaceDetails")
|
|
19
|
-
.mockResolvedValue({
|
|
20
|
-
addressLineOne: "123 Main Street",
|
|
21
|
-
city: "New York",
|
|
22
|
-
country: "US",
|
|
23
|
-
latitude: 40.7128,
|
|
24
|
-
longitude: -74.006,
|
|
25
|
-
zipCode: "10001",
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
export const buildOrganizationPayload = (suffix = randomUUID()) => ({
|
|
29
|
-
name: `Integration Org ${suffix}`,
|
|
30
|
-
phone: "+15550001111",
|
|
31
|
-
email: `org-${suffix}@shophost.test`,
|
|
32
|
-
address: {
|
|
33
|
-
addressLineOne: "123 Main Street",
|
|
34
|
-
addressLineTwo: "Suite 10",
|
|
35
|
-
city: "New York",
|
|
36
|
-
country: "US",
|
|
37
|
-
doorNumber: "10A",
|
|
38
|
-
placeId: `place-${suffix}`,
|
|
39
|
-
zipCode: "10001",
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
export const buildManufacturerPayload = (suffix = randomUUID()) => ({
|
|
43
|
-
name: `Manufacturer ${suffix}`,
|
|
44
|
-
defaultLocale: "en",
|
|
45
|
-
translations: [
|
|
46
|
-
{
|
|
47
|
-
locale: "en",
|
|
48
|
-
about: `About ${suffix} in English`,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
locale: "pl",
|
|
52
|
-
about: `O producencie ${suffix} po polsku`,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
});
|
|
56
|
-
export const buildProductCategoryPayload = (suffix = randomUUID()) => ({
|
|
57
|
-
slug: `category-${suffix}`,
|
|
58
|
-
defaultLocale: "en",
|
|
59
|
-
translations: [
|
|
60
|
-
{
|
|
61
|
-
locale: "en",
|
|
62
|
-
title: `Category ${suffix}`,
|
|
63
|
-
description: `Description for ${suffix} in English`,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
locale: "pl",
|
|
67
|
-
title: `Kategoria ${suffix}`,
|
|
68
|
-
description: `Opis ${suffix} po polsku`,
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
});
|
|
72
|
-
export const buildProductPayload = ({ categoryIds = [], manufacturerId = null, modifierGroups = [
|
|
73
|
-
{
|
|
74
|
-
defaultLocale: "en",
|
|
75
|
-
selectMin: 0,
|
|
76
|
-
selectMax: 1,
|
|
77
|
-
translations: [
|
|
78
|
-
{ locale: "en", title: "Size" },
|
|
79
|
-
{ locale: "pl", title: "Rozmiar" },
|
|
80
|
-
],
|
|
81
|
-
modifiers: [{ title: "Large", price: 2.5 }],
|
|
82
|
-
},
|
|
83
|
-
], suffix = randomUUID(), } = {}) => ({
|
|
84
|
-
slug: `product-${suffix}`,
|
|
85
|
-
sku: `sku-${suffix}`,
|
|
86
|
-
basePrice: 24.99,
|
|
87
|
-
discountedBasePrice: 19.99,
|
|
88
|
-
currency: "USD",
|
|
89
|
-
defaultLocale: "en",
|
|
90
|
-
manufacturerId,
|
|
91
|
-
categories: categoryIds,
|
|
92
|
-
modifierGroups,
|
|
93
|
-
translations: [
|
|
94
|
-
{
|
|
95
|
-
locale: "en",
|
|
96
|
-
title: `Product ${suffix}`,
|
|
97
|
-
description: `Description for ${suffix} in English`,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
locale: "pl",
|
|
101
|
-
title: `Produkt ${suffix}`,
|
|
102
|
-
description: `Opis ${suffix} po polsku`,
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
metadata: {
|
|
106
|
-
origin: "integration-test",
|
|
107
|
-
skuSuffix: suffix,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
export const buildShippingAddressPayload = (suffix = randomUUID()) => ({
|
|
111
|
-
firstname: "Integration",
|
|
112
|
-
lastname: "Tester",
|
|
113
|
-
phone: "+15550009999",
|
|
114
|
-
addressLineOne: "500 Market Street",
|
|
115
|
-
addressLineTwo: `Suite ${suffix}`,
|
|
116
|
-
doorNumber: "10A",
|
|
117
|
-
city: "New York",
|
|
118
|
-
country: "US",
|
|
119
|
-
zipCode: "10001",
|
|
120
|
-
placeId: `shipping-${suffix}`,
|
|
121
|
-
deliveryInstructions: "Leave at reception",
|
|
122
|
-
});
|
|
123
|
-
export const buildShippingMethodPayload = (suffix = randomUUID()) => ({
|
|
124
|
-
title: `Shipping ${suffix}`,
|
|
125
|
-
providerName: `Provider ${suffix}`,
|
|
126
|
-
requireDateOfDelivery: false,
|
|
127
|
-
shippingZones: [
|
|
128
|
-
{
|
|
129
|
-
title: `Zone ${suffix}`,
|
|
130
|
-
distanceUpto: 10,
|
|
131
|
-
price: 4.99,
|
|
132
|
-
minimumOrderAmount: 0,
|
|
133
|
-
eta: "30-45 min",
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
});
|
|
137
|
-
export const buildReservationPayload = (suffix = randomUUID()) => ({
|
|
138
|
-
firstname: "Reservation",
|
|
139
|
-
lastname: `Guest ${suffix}`,
|
|
140
|
-
guests: 4,
|
|
141
|
-
phone: "+15550002222",
|
|
142
|
-
date: "2030-01-01T18:30:00.000Z",
|
|
143
|
-
});
|
|
144
|
-
export const buildOrderPayload = ({ checkoutBaseUrl = "https://example.com", productId, shippingMethodId, }) => ({
|
|
145
|
-
items: [
|
|
146
|
-
{
|
|
147
|
-
productId,
|
|
148
|
-
quantity: 2,
|
|
149
|
-
modifierGroups: [],
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
fulfilmentMethod: shippingMethodId ? "delivery" : "pickup",
|
|
153
|
-
shippingMethodId,
|
|
154
|
-
payment: {
|
|
155
|
-
provider: "stripe",
|
|
156
|
-
method: "card",
|
|
157
|
-
},
|
|
158
|
-
checkoutBaseUrl,
|
|
159
|
-
});
|
|
160
|
-
//# sourceMappingURL=api-fixtures.js.map
|
|
1
|
+
import{__awaiter as a}from"tslib";import{randomUUID as r}from"node:crypto";import{vi as n}from"vitest";import{LocationService as l}from"../../features/location/location.service";export const requestJson=(e,i,t)=>a(void 0,void 0,void 0,function*(){return e.app.request(i,{method:t.method,headers:t.body===void 0?void 0:{"content-type":"application/json"},body:t.body===void 0?void 0:JSON.stringify(t.body)})}),mockPlaceDetails=()=>n.spyOn(l.prototype,"getPlaceDetails").mockResolvedValue({addressLineOne:"123 Main Street",city:"New York",country:"US",latitude:40.7128,longitude:-74.006,zipCode:"10001"}),buildOrganizationPayload=(e=r())=>({name:`Integration Org ${e}`,phone:"+15550001111",email:`org-${e}@shophost.test`,address:{addressLineOne:"123 Main Street",addressLineTwo:"Suite 10",city:"New York",country:"US",doorNumber:"10A",placeId:`place-${e}`,zipCode:"10001"}}),buildManufacturerPayload=(e=r())=>({name:`Manufacturer ${e}`,defaultLocale:"en",translations:[{locale:"en",about:`About ${e} in English`},{locale:"pl",about:`O producencie ${e} po polsku`}]}),buildProductCategoryPayload=(e=r())=>({slug:`category-${e}`,defaultLocale:"en",translations:[{locale:"en",title:`Category ${e}`,description:`Description for ${e} in English`},{locale:"pl",title:`Kategoria ${e}`,description:`Opis ${e} po polsku`}]}),buildProductPayload=({categoryIds:e=[],manufacturerId:i=null,modifierGroups:t=[{defaultLocale:"en",selectMin:0,selectMax:1,translations:[{locale:"en",title:"Size"},{locale:"pl",title:"Rozmiar"}],modifiers:[{title:"Large",price:2.5}]}],suffix:o=r()}={})=>({slug:`product-${o}`,sku:`sku-${o}`,basePrice:24.99,discountedBasePrice:19.99,currency:"USD",defaultLocale:"en",manufacturerId:i,categories:e,modifierGroups:t,translations:[{locale:"en",title:`Product ${o}`,description:`Description for ${o} in English`},{locale:"pl",title:`Produkt ${o}`,description:`Opis ${o} po polsku`}],metadata:{origin:"integration-test",skuSuffix:o}}),buildShippingAddressPayload=(e=r())=>({firstname:"Integration",lastname:"Tester",phone:"+15550009999",addressLineOne:"500 Market Street",addressLineTwo:`Suite ${e}`,doorNumber:"10A",city:"New York",country:"US",zipCode:"10001",placeId:`shipping-${e}`,deliveryInstructions:"Leave at reception"}),buildShippingMethodPayload=(e=r())=>({title:`Shipping ${e}`,providerName:`Provider ${e}`,requireDateOfDelivery:!1,shippingZones:[{title:`Zone ${e}`,distanceUpto:10,price:4.99,minimumOrderAmount:0,eta:"30-45 min"}]}),buildReservationPayload=(e=r())=>({firstname:"Reservation",lastname:`Guest ${e}`,guests:4,phone:"+15550002222",date:"2030-01-01T18:30:00.000Z"}),buildOrderPayload=({checkoutBaseUrl:e="https://example.com",productId:i,shippingMethodId:t})=>({items:[{productId:i,quantity:2,modifierGroups:[]}],fulfilmentMethod:t?"delivery":"pickup",shippingMethodId:t,payment:{provider:"stripe",method:"card"},checkoutBaseUrl:e});
|
|
@@ -1,368 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const SEED = {
|
|
3
|
-
users: {
|
|
4
|
-
owner: {
|
|
5
|
-
id: "test-owner-user-00000001",
|
|
6
|
-
email: "owner@shophost.test",
|
|
7
|
-
firstname: "Test",
|
|
8
|
-
lastname: "Owner",
|
|
9
|
-
name: "Test Owner",
|
|
10
|
-
image: null,
|
|
11
|
-
},
|
|
12
|
-
outsider: {
|
|
13
|
-
id: "test-outsider-user-00002",
|
|
14
|
-
email: "outsider@shophost.test",
|
|
15
|
-
firstname: "Test",
|
|
16
|
-
lastname: "Outsider",
|
|
17
|
-
name: "Test Outsider",
|
|
18
|
-
image: null,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
organizations: {
|
|
22
|
-
primary: {
|
|
23
|
-
id: "cseedorgprimary000001",
|
|
24
|
-
slug: "test-primary",
|
|
25
|
-
name: "Test Primary Organization",
|
|
26
|
-
email: "primary@shophost.test",
|
|
27
|
-
phone: "+15550001111",
|
|
28
|
-
addressId: "cseedaddrorgprim00001",
|
|
29
|
-
configurationId: "cseedcfgprimary000001",
|
|
30
|
-
},
|
|
31
|
-
secondary: {
|
|
32
|
-
id: "cseedorgsecondary0001",
|
|
33
|
-
slug: "test-secondary",
|
|
34
|
-
name: "Test Secondary Organization",
|
|
35
|
-
email: "secondary@shophost.test",
|
|
36
|
-
phone: "+15550002222",
|
|
37
|
-
addressId: "cseedaddrorgsec000001",
|
|
38
|
-
configurationId: "cseedcfgsecondary0001",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
memberships: {
|
|
42
|
-
ownerPrimary: { id: "cseedmbrownerprim0001" },
|
|
43
|
-
ownerSecondary: { id: "cseedmbrownersec00001" },
|
|
44
|
-
},
|
|
45
|
-
catalog: {
|
|
46
|
-
primary: {
|
|
47
|
-
categoryId: "cseedcatprimary000001",
|
|
48
|
-
manufacturerId: "cseedmfgprimary000001",
|
|
49
|
-
productId: "cseedprdprimary000001",
|
|
50
|
-
productSnapshotId: "cseedsnpprimary000001",
|
|
51
|
-
},
|
|
52
|
-
secondary: {
|
|
53
|
-
categoryId: "cseedcatsecondary0001",
|
|
54
|
-
manufacturerId: "cseedmfgsecondary0001",
|
|
55
|
-
productId: "cseedprdsecondary0001",
|
|
56
|
-
productSnapshotId: "cseedsnpsecondary0001",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
shipping: {
|
|
60
|
-
primary: {
|
|
61
|
-
methodId: "cseedshpprimary000001",
|
|
62
|
-
zoneId: "cseedzneprimary000001",
|
|
63
|
-
},
|
|
64
|
-
secondary: {
|
|
65
|
-
methodId: "cseedshpsecondary0001",
|
|
66
|
-
zoneId: "cseedznrsecondary0001",
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
addresses: {
|
|
70
|
-
defaultShipping: {
|
|
71
|
-
id: "cseedaddrshipping0001",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
const now = new Date();
|
|
76
|
-
const userId = SEED.users.owner.id;
|
|
77
|
-
export const seedDatabase = (prisma) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
-
// Users
|
|
79
|
-
yield prisma.user.createMany({
|
|
80
|
-
data: [
|
|
81
|
-
{
|
|
82
|
-
id: SEED.users.owner.id,
|
|
83
|
-
email: SEED.users.owner.email,
|
|
84
|
-
emailVerified: false,
|
|
85
|
-
firstname: SEED.users.owner.firstname,
|
|
86
|
-
lastname: SEED.users.owner.lastname,
|
|
87
|
-
name: SEED.users.owner.name,
|
|
88
|
-
image: null,
|
|
89
|
-
createdAt: now,
|
|
90
|
-
updatedAt: now,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: SEED.users.outsider.id,
|
|
94
|
-
email: SEED.users.outsider.email,
|
|
95
|
-
emailVerified: false,
|
|
96
|
-
firstname: SEED.users.outsider.firstname,
|
|
97
|
-
lastname: SEED.users.outsider.lastname,
|
|
98
|
-
name: SEED.users.outsider.name,
|
|
99
|
-
image: null,
|
|
100
|
-
createdAt: now,
|
|
101
|
-
updatedAt: now,
|
|
102
|
-
},
|
|
103
|
-
],
|
|
104
|
-
});
|
|
105
|
-
// Addresses (for organizations)
|
|
106
|
-
yield prisma.address.createMany({
|
|
107
|
-
data: [
|
|
108
|
-
{
|
|
109
|
-
id: SEED.organizations.primary.addressId,
|
|
110
|
-
addressLineOne: "123 Main Street",
|
|
111
|
-
addressLineTwo: "Suite 10",
|
|
112
|
-
city: "New York",
|
|
113
|
-
country: "US",
|
|
114
|
-
doorNumber: "10A",
|
|
115
|
-
latitude: 40.7128,
|
|
116
|
-
longitude: -74.006,
|
|
117
|
-
zipCode: "10001",
|
|
118
|
-
isDefault: false,
|
|
119
|
-
createdBy: userId,
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
id: SEED.organizations.secondary.addressId,
|
|
123
|
-
addressLineOne: "500 Lake Shore Drive",
|
|
124
|
-
addressLineTwo: "Floor 4",
|
|
125
|
-
city: "Chicago",
|
|
126
|
-
country: "US",
|
|
127
|
-
doorNumber: "4B",
|
|
128
|
-
latitude: 41.8781,
|
|
129
|
-
longitude: -87.6298,
|
|
130
|
-
zipCode: "60601",
|
|
131
|
-
isDefault: false,
|
|
132
|
-
createdBy: userId,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
id: SEED.addresses.defaultShipping.id,
|
|
136
|
-
firstname: "Test",
|
|
137
|
-
lastname: "Owner",
|
|
138
|
-
phone: "+15550009999",
|
|
139
|
-
addressLineOne: "500 Market Street",
|
|
140
|
-
addressLineTwo: "Suite A",
|
|
141
|
-
city: "New York",
|
|
142
|
-
country: "US",
|
|
143
|
-
doorNumber: "10A",
|
|
144
|
-
latitude: 40.713,
|
|
145
|
-
longitude: -74.0055,
|
|
146
|
-
zipCode: "10001",
|
|
147
|
-
placeId: "seed-shipping-address",
|
|
148
|
-
deliveryInstructions: "Leave at reception",
|
|
149
|
-
isDefault: true,
|
|
150
|
-
createdBy: userId,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
});
|
|
154
|
-
// Link shipping address to owner user
|
|
155
|
-
yield prisma.user.update({
|
|
156
|
-
where: { id: userId },
|
|
157
|
-
data: {
|
|
158
|
-
shippingAddresses: {
|
|
159
|
-
connect: { id: SEED.addresses.defaultShipping.id },
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
// Organization configurations
|
|
164
|
-
yield prisma.organizationConfiguration.createMany({
|
|
165
|
-
data: [
|
|
166
|
-
{
|
|
167
|
-
id: SEED.organizations.primary.configurationId,
|
|
168
|
-
countriesShipping: ["US"],
|
|
169
|
-
defaultCurrency: "USD",
|
|
170
|
-
defaultLocale: "en",
|
|
171
|
-
enableHostCheckout: true,
|
|
172
|
-
enableHostTracking: true,
|
|
173
|
-
hostname: "test-primary.shophost.test",
|
|
174
|
-
isAcceptingOrders: true,
|
|
175
|
-
supportedLocales: ["en", "pl"],
|
|
176
|
-
createdBy: userId,
|
|
177
|
-
updatedBy: userId,
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
id: SEED.organizations.secondary.configurationId,
|
|
181
|
-
countriesShipping: ["US"],
|
|
182
|
-
defaultCurrency: "USD",
|
|
183
|
-
defaultLocale: "en",
|
|
184
|
-
enableHostCheckout: true,
|
|
185
|
-
enableHostTracking: true,
|
|
186
|
-
hostname: "test-secondary.shophost.test",
|
|
187
|
-
isAcceptingOrders: true,
|
|
188
|
-
supportedLocales: ["en", "pl"],
|
|
189
|
-
createdBy: userId,
|
|
190
|
-
updatedBy: userId,
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
});
|
|
194
|
-
// Organizations
|
|
195
|
-
yield prisma.organization.createMany({
|
|
196
|
-
data: [
|
|
197
|
-
{
|
|
198
|
-
id: SEED.organizations.primary.id,
|
|
199
|
-
name: SEED.organizations.primary.name,
|
|
200
|
-
slug: SEED.organizations.primary.slug,
|
|
201
|
-
email: SEED.organizations.primary.email,
|
|
202
|
-
phone: SEED.organizations.primary.phone,
|
|
203
|
-
addressId: SEED.organizations.primary.addressId,
|
|
204
|
-
configurationId: SEED.organizations.primary.configurationId,
|
|
205
|
-
createdBy: userId,
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
id: SEED.organizations.secondary.id,
|
|
209
|
-
name: SEED.organizations.secondary.name,
|
|
210
|
-
slug: SEED.organizations.secondary.slug,
|
|
211
|
-
email: SEED.organizations.secondary.email,
|
|
212
|
-
phone: SEED.organizations.secondary.phone,
|
|
213
|
-
addressId: SEED.organizations.secondary.addressId,
|
|
214
|
-
configurationId: SEED.organizations.secondary.configurationId,
|
|
215
|
-
createdBy: userId,
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
});
|
|
219
|
-
// Memberships (owner belongs to both orgs)
|
|
220
|
-
yield prisma.member.createMany({
|
|
221
|
-
data: [
|
|
222
|
-
{
|
|
223
|
-
id: SEED.memberships.ownerPrimary.id,
|
|
224
|
-
organizationId: SEED.organizations.primary.id,
|
|
225
|
-
userId,
|
|
226
|
-
role: "owner",
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
id: SEED.memberships.ownerSecondary.id,
|
|
230
|
-
organizationId: SEED.organizations.secondary.id,
|
|
231
|
-
userId,
|
|
232
|
-
role: "owner",
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
});
|
|
236
|
-
// Manufacturers
|
|
237
|
-
for (const [variant, catalog] of Object.entries(SEED.catalog)) {
|
|
238
|
-
const orgId = SEED.organizations[variant].id;
|
|
239
|
-
yield prisma.manufacturer.create({
|
|
240
|
-
data: {
|
|
241
|
-
id: catalog.manufacturerId,
|
|
242
|
-
name: `Seed Manufacturer ${variant}`,
|
|
243
|
-
organizationId: orgId,
|
|
244
|
-
createdBy: userId,
|
|
245
|
-
translations: {
|
|
246
|
-
create: [
|
|
247
|
-
{ locale: "en", about: `About seed manufacturer ${variant}`, createdBy: userId },
|
|
248
|
-
{ locale: "pl", about: `O producencie ${variant}`, createdBy: userId },
|
|
249
|
-
],
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
});
|
|
253
|
-
// Product categories
|
|
254
|
-
yield prisma.productCategory.create({
|
|
255
|
-
data: {
|
|
256
|
-
id: catalog.categoryId,
|
|
257
|
-
slug: `seed-category-${variant}`,
|
|
258
|
-
organizationId: orgId,
|
|
259
|
-
createdBy: userId,
|
|
260
|
-
translations: {
|
|
261
|
-
create: [
|
|
262
|
-
{ locale: "en", title: `Seed Category ${variant}`, description: `Seed category ${variant} in English`, createdBy: userId },
|
|
263
|
-
{ locale: "pl", title: `Kategoria ${variant}`, description: `Kategoria ${variant} po polsku`, createdBy: userId },
|
|
264
|
-
],
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
// Products
|
|
269
|
-
yield prisma.product.create({
|
|
270
|
-
data: {
|
|
271
|
-
id: catalog.productId,
|
|
272
|
-
slug: `seed-product-${variant}`,
|
|
273
|
-
sku: `seed-sku-${variant}`,
|
|
274
|
-
basePrice: 24.99,
|
|
275
|
-
discountedBasePrice: 19.99,
|
|
276
|
-
currency: "USD",
|
|
277
|
-
organizationId: orgId,
|
|
278
|
-
manufacturerId: catalog.manufacturerId,
|
|
279
|
-
tags: [],
|
|
280
|
-
metadata: { seed: "true", variant },
|
|
281
|
-
publishedAt: now,
|
|
282
|
-
createdBy: userId,
|
|
283
|
-
categories: { connect: { id: catalog.categoryId } },
|
|
284
|
-
translations: {
|
|
285
|
-
create: [
|
|
286
|
-
{ locale: "en", title: `Seed Product ${variant}`, description: `Seed product ${variant} in English`, createdBy: userId },
|
|
287
|
-
{ locale: "pl", title: `Produkt ${variant}`, description: `Produkt ${variant} po polsku`, createdBy: userId },
|
|
288
|
-
],
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
});
|
|
292
|
-
// Product snapshot
|
|
293
|
-
yield prisma.productSnapshot.create({
|
|
294
|
-
data: {
|
|
295
|
-
id: catalog.productSnapshotId,
|
|
296
|
-
productId: catalog.productId,
|
|
297
|
-
data: { id: catalog.productId, sku: `seed-sku-${variant}`, title: `Seed Product ${variant}` },
|
|
298
|
-
createdBy: userId,
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
yield prisma.product.update({
|
|
302
|
-
where: { id: catalog.productId },
|
|
303
|
-
data: { latestSnapshotId: catalog.productSnapshotId },
|
|
304
|
-
});
|
|
305
|
-
// Shipping methods
|
|
306
|
-
const shipping = SEED.shipping[variant];
|
|
307
|
-
yield prisma.shippingMethod.create({
|
|
308
|
-
data: {
|
|
309
|
-
id: shipping.methodId,
|
|
310
|
-
title: `Seed Shipping ${variant}`,
|
|
311
|
-
providerName: `Seed Provider ${variant}`,
|
|
312
|
-
requireDateOfDelivery: false,
|
|
313
|
-
organizationId: orgId,
|
|
314
|
-
createdBy: userId,
|
|
315
|
-
shippingZones: {
|
|
316
|
-
create: {
|
|
317
|
-
id: shipping.zoneId,
|
|
318
|
-
title: `Seed Zone ${variant}`,
|
|
319
|
-
distanceUpto: 10,
|
|
320
|
-
price: 4.99,
|
|
321
|
-
minimumOrderAmount: 0,
|
|
322
|
-
eta: "30-45 min",
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
export const TABLES = [
|
|
330
|
-
"OrderItemTranslation",
|
|
331
|
-
"OrderItem",
|
|
332
|
-
"Order",
|
|
333
|
-
"PaymentSession",
|
|
334
|
-
"Payment",
|
|
335
|
-
"Reservation",
|
|
336
|
-
"Campaign",
|
|
337
|
-
"ShippingZone",
|
|
338
|
-
"ShippingMethod",
|
|
339
|
-
"ProductSnapshot",
|
|
340
|
-
"ProductTranslation",
|
|
341
|
-
"Modifier",
|
|
342
|
-
"ModifierGroupTranslation",
|
|
343
|
-
"ModifierGroup",
|
|
344
|
-
"Product",
|
|
345
|
-
"ProductCategoryTranslation",
|
|
346
|
-
"ProductCategory",
|
|
347
|
-
"ManufacturerTranslation",
|
|
348
|
-
"Manufacturer",
|
|
349
|
-
"File",
|
|
350
|
-
"Invitation",
|
|
351
|
-
"Member",
|
|
352
|
-
"Organization",
|
|
353
|
-
"OrganizationConfiguration",
|
|
354
|
-
"OpeningTimes",
|
|
355
|
-
"ClosingTimes",
|
|
356
|
-
"LegalEntity",
|
|
357
|
-
"Address",
|
|
358
|
-
"Session",
|
|
359
|
-
"Account",
|
|
360
|
-
"Verification",
|
|
361
|
-
"User",
|
|
362
|
-
];
|
|
363
|
-
export const resetToSeed = (prisma) => __awaiter(void 0, void 0, void 0, function* () {
|
|
364
|
-
const tableNames = TABLES.map((t) => `"${t}"`).join(", ");
|
|
365
|
-
yield prisma.$executeRawUnsafe(`TRUNCATE TABLE ${tableNames} CASCADE`);
|
|
366
|
-
yield seedDatabase(prisma);
|
|
367
|
-
});
|
|
368
|
-
//# sourceMappingURL=seed.js.map
|
|
1
|
+
import{__awaiter as n}from"tslib";export const SEED={users:{owner:{id:"test-owner-user-00000001",email:"owner@shophost.test",firstname:"Test",lastname:"Owner",name:"Test Owner",image:null},outsider:{id:"test-outsider-user-00002",email:"outsider@shophost.test",firstname:"Test",lastname:"Outsider",name:"Test Outsider",image:null}},organizations:{primary:{id:"cseedorgprimary000001",slug:"test-primary",name:"Test Primary Organization",email:"primary@shophost.test",phone:"+15550001111",addressId:"cseedaddrorgprim00001",configurationId:"cseedcfgprimary000001"},secondary:{id:"cseedorgsecondary0001",slug:"test-secondary",name:"Test Secondary Organization",email:"secondary@shophost.test",phone:"+15550002222",addressId:"cseedaddrorgsec000001",configurationId:"cseedcfgsecondary0001"}},memberships:{ownerPrimary:{id:"cseedmbrownerprim0001"},ownerSecondary:{id:"cseedmbrownersec00001"}},catalog:{primary:{categoryId:"cseedcatprimary000001",manufacturerId:"cseedmfgprimary000001",productId:"cseedprdprimary000001",productSnapshotId:"cseedsnpprimary000001"},secondary:{categoryId:"cseedcatsecondary0001",manufacturerId:"cseedmfgsecondary0001",productId:"cseedprdsecondary0001",productSnapshotId:"cseedsnpsecondary0001"}},shipping:{primary:{methodId:"cseedshpprimary000001",zoneId:"cseedzneprimary000001"},secondary:{methodId:"cseedshpsecondary0001",zoneId:"cseedznrsecondary0001"}},addresses:{defaultShipping:{id:"cseedaddrshipping0001"}}};const d=new Date,a=SEED.users.owner.id;export const seedDatabase=r=>n(void 0,void 0,void 0,function*(){yield r.user.createMany({data:[{id:SEED.users.owner.id,email:SEED.users.owner.email,emailVerified:!1,firstname:SEED.users.owner.firstname,lastname:SEED.users.owner.lastname,name:SEED.users.owner.name,image:null,createdAt:d,updatedAt:d},{id:SEED.users.outsider.id,email:SEED.users.outsider.email,emailVerified:!1,firstname:SEED.users.outsider.firstname,lastname:SEED.users.outsider.lastname,name:SEED.users.outsider.name,image:null,createdAt:d,updatedAt:d}]}),yield r.address.createMany({data:[{id:SEED.organizations.primary.addressId,addressLineOne:"123 Main Street",addressLineTwo:"Suite 10",city:"New York",country:"US",doorNumber:"10A",latitude:40.7128,longitude:-74.006,zipCode:"10001",isDefault:!1,createdBy:a},{id:SEED.organizations.secondary.addressId,addressLineOne:"500 Lake Shore Drive",addressLineTwo:"Floor 4",city:"Chicago",country:"US",doorNumber:"4B",latitude:41.8781,longitude:-87.6298,zipCode:"60601",isDefault:!1,createdBy:a},{id:SEED.addresses.defaultShipping.id,firstname:"Test",lastname:"Owner",phone:"+15550009999",addressLineOne:"500 Market Street",addressLineTwo:"Suite A",city:"New York",country:"US",doorNumber:"10A",latitude:40.713,longitude:-74.0055,zipCode:"10001",placeId:"seed-shipping-address",deliveryInstructions:"Leave at reception",isDefault:!0,createdBy:a}]}),yield r.user.update({where:{id:a},data:{shippingAddresses:{connect:{id:SEED.addresses.defaultShipping.id}}}}),yield r.organizationConfiguration.createMany({data:[{id:SEED.organizations.primary.configurationId,countriesShipping:["US"],defaultCurrency:"USD",defaultLocale:"en",enableHostCheckout:!0,enableHostTracking:!0,hostname:"test-primary.shophost.test",isAcceptingOrders:!0,supportedLocales:["en","pl"],createdBy:a,updatedBy:a},{id:SEED.organizations.secondary.configurationId,countriesShipping:["US"],defaultCurrency:"USD",defaultLocale:"en",enableHostCheckout:!0,enableHostTracking:!0,hostname:"test-secondary.shophost.test",isAcceptingOrders:!0,supportedLocales:["en","pl"],createdBy:a,updatedBy:a}]}),yield r.organization.createMany({data:[{id:SEED.organizations.primary.id,name:SEED.organizations.primary.name,slug:SEED.organizations.primary.slug,email:SEED.organizations.primary.email,phone:SEED.organizations.primary.phone,addressId:SEED.organizations.primary.addressId,configurationId:SEED.organizations.primary.configurationId,createdBy:a},{id:SEED.organizations.secondary.id,name:SEED.organizations.secondary.name,slug:SEED.organizations.secondary.slug,email:SEED.organizations.secondary.email,phone:SEED.organizations.secondary.phone,addressId:SEED.organizations.secondary.addressId,configurationId:SEED.organizations.secondary.configurationId,createdBy:a}]}),yield r.member.createMany({data:[{id:SEED.memberships.ownerPrimary.id,organizationId:SEED.organizations.primary.id,userId:a,role:"owner"},{id:SEED.memberships.ownerSecondary.id,organizationId:SEED.organizations.secondary.id,userId:a,role:"owner"}]});for(const[e,t]of Object.entries(SEED.catalog)){const i=SEED.organizations[e].id;yield r.manufacturer.create({data:{id:t.manufacturerId,name:`Seed Manufacturer ${e}`,organizationId:i,createdBy:a,translations:{create:[{locale:"en",about:`About seed manufacturer ${e}`,createdBy:a},{locale:"pl",about:`O producencie ${e}`,createdBy:a}]}}}),yield r.productCategory.create({data:{id:t.categoryId,slug:`seed-category-${e}`,organizationId:i,createdBy:a,translations:{create:[{locale:"en",title:`Seed Category ${e}`,description:`Seed category ${e} in English`,createdBy:a},{locale:"pl",title:`Kategoria ${e}`,description:`Kategoria ${e} po polsku`,createdBy:a}]}}}),yield r.product.create({data:{id:t.productId,slug:`seed-product-${e}`,sku:`seed-sku-${e}`,basePrice:24.99,discountedBasePrice:19.99,currency:"USD",organizationId:i,manufacturerId:t.manufacturerId,tags:[],metadata:{seed:"true",variant:e},publishedAt:d,createdBy:a,categories:{connect:{id:t.categoryId}},translations:{create:[{locale:"en",title:`Seed Product ${e}`,description:`Seed product ${e} in English`,createdBy:a},{locale:"pl",title:`Produkt ${e}`,description:`Produkt ${e} po polsku`,createdBy:a}]}}}),yield r.productSnapshot.create({data:{id:t.productSnapshotId,productId:t.productId,data:{id:t.productId,sku:`seed-sku-${e}`,title:`Seed Product ${e}`},createdBy:a}}),yield r.product.update({where:{id:t.productId},data:{latestSnapshotId:t.productSnapshotId}});const o=SEED.shipping[e];yield r.shippingMethod.create({data:{id:o.methodId,title:`Seed Shipping ${e}`,providerName:`Seed Provider ${e}`,requireDateOfDelivery:!1,organizationId:i,createdBy:a,shippingZones:{create:{id:o.zoneId,title:`Seed Zone ${e}`,distanceUpto:10,price:4.99,minimumOrderAmount:0,eta:"30-45 min"}}}})}}),TABLES=["OrderItemTranslation","OrderItem","Order","PaymentSession","Payment","Reservation","Campaign","ShippingZone","ShippingMethod","ProductSnapshot","ProductTranslation","Modifier","ModifierGroupTranslation","ModifierGroup","Product","ProductCategoryTranslation","ProductCategory","ManufacturerTranslation","Manufacturer","File","Invitation","Member","Organization","OrganizationConfiguration","OpeningTimes","ClosingTimes","LegalEntity","Address","Session","Account","Verification","User"],resetToSeed=r=>n(void 0,void 0,void 0,function*(){const e=TABLES.map(t=>`"${t}"`).join(", ");yield r.$executeRawUnsafe(`TRUNCATE TABLE ${e} CASCADE`),yield seedDatabase(r)});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type BuildApiAppOptions } from "../../app";
|
|
2
|
+
import { type PrismaClientType } from "../../core/lib/prisma";
|
|
2
3
|
export { SEED } from "./seed";
|
|
4
|
+
export declare const getTestPrisma: () => PrismaClientType;
|
|
3
5
|
export declare const resetToSeed: () => Promise<void>;
|
|
4
6
|
type SeedUser = {
|
|
5
7
|
id: string;
|