@jarwizz/create-jarshop 0.1.9 → 0.4.0
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/README.md +15 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/generator.d.ts +11 -1
- package/dist/generator.js +45 -11
- package/dist/generator.js.map +1 -1
- package/dist/presets.d.ts +28 -0
- package/dist/presets.js +105 -0
- package/dist/presets.js.map +1 -0
- package/dist/template/CONTEXT.md +4 -2
- package/dist/template/README.md +255 -3
- package/dist/template/env.example.template +19 -0
- package/dist/template/gitignore.template +1 -0
- package/dist/template/jarshop.config.ts +37 -0
- package/dist/template/package.json +4 -0
- package/dist/template/pnpm-lock.yaml +3284 -1815
- package/dist/template/pnpm-workspace.yaml +6 -1
- package/dist/template/src/client/features.ts +41 -0
- package/dist/template/src/client/invoicing.ts +29 -0
- package/dist/template/src/dev-storefront-environment.test.ts +45 -0
- package/dist/template/src/dev-storefront-environment.ts +32 -0
- package/dist/template/src/dev-storefront.ts +3 -12
- package/dist/template/src/environment.d.ts +8 -0
- package/dist/template/src/invoice-email-recover.ts +59 -0
- package/dist/template/src/jarshop-config-loader.ts +118 -0
- package/dist/template/src/jarshop-config.test.ts +365 -0
- package/dist/template/src/jarshop-config.ts +462 -0
- package/dist/template/src/jarshop-features.test.ts +222 -0
- package/dist/template/src/jarshop-features.ts +112 -0
- package/dist/template/src/migrations/1788100000000-jarshop-guest-order-session.ts +27 -0
- package/dist/template/src/operation-codes.ts +34 -0
- package/dist/template/src/packeta-config.test.ts +95 -0
- package/dist/template/src/packeta-countries.test.ts +161 -0
- package/dist/template/src/packeta-countries.ts +120 -0
- package/dist/template/src/packeta-validation.test.ts +35 -0
- package/dist/template/src/packeta-validation.ts +52 -0
- package/dist/template/src/payment-return-url.test.ts +57 -0
- package/dist/template/src/payment-return-url.ts +34 -0
- package/dist/template/src/plugins/jarshop-checkout/confirmation-view.test.ts +79 -0
- package/dist/template/src/plugins/jarshop-checkout/confirmation.ts +51 -0
- package/dist/template/src/plugins/jarshop-checkout/dashboard/index.tsx +1 -0
- package/dist/template/src/plugins/jarshop-checkout/index.ts +4 -0
- package/dist/template/src/plugins/jarshop-checkout/invoice-delivery.plugin.ts +79 -0
- package/dist/template/src/plugins/jarshop-checkout/invoice-email-events.ts +35 -0
- package/dist/template/src/plugins/jarshop-checkout/invoice-email-lifecycle.ts +235 -0
- package/dist/template/src/plugins/jarshop-checkout/invoice-email-worker.test.ts +426 -0
- package/dist/template/src/plugins/jarshop-checkout/invoice-email.test.ts +107 -0
- package/dist/template/src/plugins/jarshop-checkout/jarshop-checkout.plugin.ts +167 -58
- package/dist/template/src/plugins/jarshop-checkout/market-active-order-core.ts +108 -0
- package/dist/template/src/plugins/jarshop-checkout/market-active-order.test.ts +205 -0
- package/dist/template/src/plugins/jarshop-checkout/market-active-order.ts +186 -0
- package/dist/template/src/plugins/jarshop-checkout/market-channels.test.ts +58 -0
- package/dist/template/src/plugins/jarshop-checkout/market-channels.ts +87 -0
- package/dist/template/src/plugins/jarshop-checkout/operation-code-check.ts +36 -0
- package/dist/template/src/plugins/jarshop-checkout/order-email-configuration.entity.ts +1 -1
- package/dist/template/src/plugins/jarshop-checkout/order-email-configuration.ts +1 -0
- package/dist/template/src/plugins/jarshop-checkout/order-email-delivery-core.ts +94 -1
- package/dist/template/src/plugins/jarshop-checkout/order-email-delivery.entity.ts +1 -0
- package/dist/template/src/plugins/jarshop-checkout/order-email-outbox.ts +83 -1
- package/dist/template/src/plugins/jarshop-checkout/order-email-worker.ts +136 -1
- package/dist/template/src/plugins/jarshop-checkout/shipping-tax.test.ts +109 -0
- package/dist/template/src/plugins/jarshop-checkout/shipping.test.ts +156 -0
- package/dist/template/src/plugins/jarshop-checkout/shipping.ts +75 -11
- package/dist/template/src/seed.ts +473 -185
- package/dist/template/src/vendure-config.ts +258 -113
- package/dist/template/storefront/README.md +7 -0
- package/dist/template/storefront/app/[locale]/[slug]/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/account/login/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/account/page.tsx +10 -4
- package/dist/template/storefront/app/[locale]/account/password-reset/callback/route.ts +4 -2
- package/dist/template/storefront/app/[locale]/account/password-reset/complete/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/account/password-reset/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/account/register/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/account/verify/complete/route.ts +4 -2
- package/dist/template/storefront/app/[locale]/account/verify/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/cart/page.tsx +3 -2
- package/dist/template/storefront/app/[locale]/checkout/actions.ts +43 -0
- package/dist/template/storefront/app/[locale]/checkout/checkout-form.tsx +188 -36
- package/dist/template/storefront/app/[locale]/checkout/confirmation/route.ts +2 -2
- package/dist/template/storefront/app/[locale]/checkout/packeta-chooser.tsx +96 -0
- package/dist/template/storefront/app/[locale]/checkout/page.tsx +60 -2
- package/dist/template/storefront/app/[locale]/checkout/payment-return/actions.ts +55 -0
- package/dist/template/storefront/app/[locale]/checkout/payment-return/page.tsx +32 -0
- package/dist/template/storefront/app/[locale]/checkout/payment-return/payment-return.tsx +84 -0
- package/dist/template/storefront/app/[locale]/checkout/success/page.tsx +32 -2
- package/dist/template/storefront/app/[locale]/layout.tsx +3 -2
- package/dist/template/storefront/app/[locale]/page.tsx +3 -2
- package/dist/template/storefront/app/globals.css +16 -0
- package/dist/template/storefront/app/layout.tsx +6 -2
- package/dist/template/storefront/lib/cart.ts +2 -4
- package/dist/template/storefront/lib/checkout-contract.test.ts +18 -1
- package/dist/template/storefront/lib/checkout-contract.ts +8 -0
- package/dist/template/storefront/lib/checkout-countries.test.ts +61 -0
- package/dist/template/storefront/lib/checkout-countries.ts +67 -0
- package/dist/template/storefront/lib/checkout.ts +22 -11
- package/dist/template/storefront/lib/commerce.ts +262 -2
- package/dist/template/storefront/lib/confirmation.test.ts +116 -0
- package/dist/template/storefront/lib/confirmation.ts +13 -7
- package/dist/template/storefront/lib/i18n.test.ts +32 -12
- package/dist/template/storefront/lib/i18n.ts +29 -8
- package/dist/template/storefront/lib/market-config.ts +40 -0
- package/dist/template/storefront/lib/market-routing.test.ts +107 -0
- package/dist/template/storefront/lib/market-routing.ts +57 -0
- package/dist/template/storefront/lib/market.ts +51 -0
- package/dist/template/storefront/lib/packeta-selection.test.ts +141 -0
- package/dist/template/storefront/lib/packeta-selection.ts +98 -0
- package/dist/template/storefront/lib/payment-return-actions.test.ts +61 -0
- package/dist/template/storefront/lib/payment-return-page.test.ts +30 -0
- package/dist/template/storefront/lib/payment-return-polling.test.ts +37 -0
- package/dist/template/storefront/lib/payment-return-polling.ts +58 -0
- package/dist/template/storefront/messages/en.json +13 -1
- package/dist/template/storefront/messages/sk.json +13 -1
- package/dist/template/storefront/package.json +2 -1
- package/dist/template/storefront/proxy.ts +35 -0
- package/dist/template/turbo.json +5 -1
- package/dist/template-manifest.json +1 -1
- package/dist/template.js +1 -0
- package/dist/template.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
DefaultSchedulerPlugin,
|
|
4
4
|
DefaultSearchPlugin,
|
|
5
5
|
LanguageCode,
|
|
6
|
+
type RequestContext,
|
|
6
7
|
VendureConfig,
|
|
7
8
|
} from "@vendure/core";
|
|
8
9
|
import { AssetServerPlugin } from "@vendure/asset-server-plugin";
|
|
@@ -14,16 +15,97 @@ import {
|
|
|
14
15
|
} from "@vendure/email-plugin";
|
|
15
16
|
import { GraphiqlPlugin } from "@vendure/graphiql-plugin";
|
|
16
17
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
JarShopShippingSelectionPlugin,
|
|
19
|
+
JarShopRedirectPaymentPlugin,
|
|
20
|
+
createAdapterShippingCalculator,
|
|
21
|
+
createAdapterShippingEligibilityChecker,
|
|
22
|
+
jarShopKitMigrations,
|
|
23
|
+
registerJarShopShippingSelectionOrderProcess,
|
|
24
|
+
} from "@jarwizz/feature-adapter-kit/server";
|
|
25
|
+
import {
|
|
26
|
+
JarShopPacketaPlugin,
|
|
27
|
+
createPacketaShippingAdapter,
|
|
28
|
+
} from "@jarwizz/feature-packeta/server";
|
|
29
|
+
import { JarShopCheckoutPlugin } from "./plugins/jarshop-checkout/index.js";
|
|
30
|
+
import { JarShopInvoiceDeliveryPlugin } from "./plugins/jarshop-checkout/invoice-delivery.plugin.js";
|
|
20
31
|
import "dotenv/config";
|
|
21
32
|
import path from "node:path";
|
|
33
|
+
import {
|
|
34
|
+
JarShopInvoicingPlugin,
|
|
35
|
+
jarShopInvoicingMigrations,
|
|
36
|
+
} from "@jarwizz/jarshop-invoicing/server";
|
|
37
|
+
import clientFeatures from "./client/features.js";
|
|
38
|
+
import {
|
|
39
|
+
assertUniqueOperationCodes,
|
|
40
|
+
isPacketaRequested,
|
|
41
|
+
type JarShopFeatures,
|
|
42
|
+
} from "./jarshop-features.js";
|
|
43
|
+
import {
|
|
44
|
+
packetaServedCountries,
|
|
45
|
+
scopePacketaToMarkets,
|
|
46
|
+
} from "./packeta-countries.js";
|
|
47
|
+
import { createPacketaValidationFetch } from "./packeta-validation.js";
|
|
48
|
+
import { marketPaymentReturnUrls } from "./payment-return-url.js";
|
|
49
|
+
import {
|
|
50
|
+
loadDefaultMarket,
|
|
51
|
+
loadJarShopConfig,
|
|
52
|
+
marketForChannel,
|
|
53
|
+
storefrontMarketUrl,
|
|
54
|
+
} from "./jarshop-config-loader.js";
|
|
22
55
|
|
|
23
56
|
const isDev = process.env.APP_ENV === "dev";
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
57
|
+
// The client-owned jarshop.config.ts decides the markets. Its default market
|
|
58
|
+
// is served by Vendure's default Channel.
|
|
59
|
+
const jarShopConfig = loadJarShopConfig();
|
|
60
|
+
const defaultMarket = loadDefaultMarket();
|
|
61
|
+
/**
|
|
62
|
+
* A provider Feature takes these server-owned values when it creates its
|
|
63
|
+
* transaction, for the request's Channel: each market returns the shopper to
|
|
64
|
+
* its own domain and language. The reference gateway is an in-memory fixture
|
|
65
|
+
* and has no real browser return, so it intentionally does not consume them.
|
|
66
|
+
*/
|
|
67
|
+
export function redirectPaymentReturnUrls(
|
|
68
|
+
ctx: Pick<RequestContext, "channel" | "languageCode">,
|
|
69
|
+
): Readonly<{ paid: string; cancelled: string; pending: string }> {
|
|
70
|
+
return marketPaymentReturnUrls(
|
|
71
|
+
marketForChannel(ctx.channel.token),
|
|
72
|
+
ctx.languageCode,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Packeta serves the destination countries of the configured markets that have
|
|
77
|
+
* a Packeta network. A market with none of them has no Packeta shipping method
|
|
78
|
+
* in its Channel, and a project with no such market boots without the Feature.
|
|
79
|
+
*/
|
|
80
|
+
function createPacketaFeature(environment: NodeJS.ProcessEnv) {
|
|
81
|
+
const servedCountries = packetaServedCountries(jarShopConfig);
|
|
82
|
+
if (servedCountries.length === 0) return null;
|
|
83
|
+
const installation = {
|
|
84
|
+
apiKey: environment.PACKETA_API_KEY ?? "",
|
|
85
|
+
servedCountries,
|
|
86
|
+
zboxEnabled: environment.JARSHOP_PACKETA_ZBOX_ENABLED !== "0",
|
|
87
|
+
} as const;
|
|
88
|
+
const validationFetch = createPacketaValidationFetch(environment);
|
|
89
|
+
const adapter = scopePacketaToMarkets(
|
|
90
|
+
createPacketaShippingAdapter({
|
|
91
|
+
...installation,
|
|
92
|
+
...(validationFetch ? { fetch: validationFetch } : {}),
|
|
93
|
+
diagnostics(diagnostic) {
|
|
94
|
+
console.warn("Packeta selection refused", diagnostic);
|
|
95
|
+
},
|
|
96
|
+
}),
|
|
97
|
+
jarShopConfig,
|
|
98
|
+
);
|
|
99
|
+
return {
|
|
100
|
+
plugin: JarShopPacketaPlugin.init(installation),
|
|
101
|
+
eligibility: createAdapterShippingEligibilityChecker(() => adapter, {
|
|
102
|
+
code: "packeta-eligibility",
|
|
103
|
+
}),
|
|
104
|
+
calculator: createAdapterShippingCalculator(() => adapter, {
|
|
105
|
+
code: "packeta-calculator",
|
|
106
|
+
}),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
27
109
|
|
|
28
110
|
function requiredEnvironment(name: string): string {
|
|
29
111
|
const value = process.env[name]?.trim();
|
|
@@ -31,118 +113,181 @@ function requiredEnvironment(name: string): string {
|
|
|
31
113
|
return value;
|
|
32
114
|
}
|
|
33
115
|
|
|
34
|
-
function storefrontAccountUrl(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
116
|
+
function storefrontAccountUrl(
|
|
117
|
+
channelToken: string | undefined,
|
|
118
|
+
locale: string,
|
|
119
|
+
path: string,
|
|
120
|
+
): string {
|
|
121
|
+
return storefrontMarketUrl(
|
|
122
|
+
marketForChannel(channelToken),
|
|
123
|
+
locale,
|
|
124
|
+
`account/${path}`,
|
|
125
|
+
);
|
|
40
126
|
}
|
|
41
127
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Builds the Vendure configuration from JarShop Core and the client-owned
|
|
130
|
+
* features. `config` below uses `src/client/features.ts`; tests pass their own.
|
|
131
|
+
*/
|
|
132
|
+
export function createVendureConfig(
|
|
133
|
+
features: JarShopFeatures,
|
|
134
|
+
environment: NodeJS.ProcessEnv = process.env,
|
|
135
|
+
): VendureConfig {
|
|
136
|
+
const packeta = isPacketaRequested(features, environment)
|
|
137
|
+
? createPacketaFeature(environment)
|
|
138
|
+
: null;
|
|
139
|
+
const invoicing = features.invoicing;
|
|
140
|
+
const shippingEligibilityCheckers = [
|
|
141
|
+
...features.shippingEligibilityCheckers,
|
|
142
|
+
...(packeta ? [packeta.eligibility] : []),
|
|
143
|
+
];
|
|
144
|
+
const shippingCalculators = [
|
|
145
|
+
...features.shippingCalculators,
|
|
146
|
+
...(packeta ? [packeta.calculator] : []),
|
|
147
|
+
];
|
|
148
|
+
assertUniqueOperationCodes({
|
|
149
|
+
"Payment method handler": features.paymentMethodHandlers,
|
|
150
|
+
"Shipping eligibility checker": shippingEligibilityCheckers,
|
|
151
|
+
"Shipping calculator": shippingCalculators,
|
|
152
|
+
});
|
|
153
|
+
return registerJarShopShippingSelectionOrderProcess({
|
|
154
|
+
// The default market's language is read when a new installation populates
|
|
155
|
+
// its default channel and global settings, so it decides which translation
|
|
156
|
+
// the Dashboard and Shop API fall back to.
|
|
157
|
+
defaultLanguageCode: defaultMarket.defaultLanguage as LanguageCode,
|
|
158
|
+
// Vendure's default Channel serves the default market. Pinning its token
|
|
159
|
+
// lets the storefront address every market, the default one included, by
|
|
160
|
+
// the token declared in jarshop.config.ts.
|
|
161
|
+
defaultChannelToken: defaultMarket.channelToken,
|
|
162
|
+
apiOptions: {
|
|
163
|
+
port: Number(process.env.PORT ?? 3000),
|
|
164
|
+
adminApiPath: "admin-api",
|
|
165
|
+
shopApiPath: "shop-api",
|
|
166
|
+
trustProxy: isDev ? false : 1,
|
|
167
|
+
...(isDev ? { adminApiDebug: true, shopApiDebug: true } : {}),
|
|
61
168
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
169
|
+
authOptions: {
|
|
170
|
+
tokenMethod: ["bearer", "cookie"],
|
|
171
|
+
requireVerification: true,
|
|
172
|
+
sessionDuration: "30d",
|
|
173
|
+
superadminCredentials: {
|
|
174
|
+
identifier: process.env.SUPERADMIN_USERNAME ?? "",
|
|
175
|
+
password: process.env.SUPERADMIN_PASSWORD ?? "",
|
|
176
|
+
},
|
|
177
|
+
cookieOptions: {
|
|
178
|
+
name: {
|
|
179
|
+
admin: "jarshop-admin-session",
|
|
180
|
+
shop: "jarshop-shop-session",
|
|
181
|
+
},
|
|
182
|
+
secret: process.env.COOKIE_SECRET ?? "",
|
|
183
|
+
httpOnly: true,
|
|
184
|
+
path: "/",
|
|
185
|
+
sameSite: "lax",
|
|
186
|
+
secure: !isDev,
|
|
66
187
|
},
|
|
67
|
-
secret: process.env.COOKIE_SECRET ?? "",
|
|
68
|
-
httpOnly: true,
|
|
69
|
-
path: "/",
|
|
70
|
-
sameSite: "lax",
|
|
71
|
-
secure: !isDev,
|
|
72
188
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
189
|
+
dbConnectionOptions: {
|
|
190
|
+
type: "postgres",
|
|
191
|
+
synchronize: false,
|
|
192
|
+
migrationsRun: false,
|
|
193
|
+
migrations: [
|
|
194
|
+
path.join(__dirname, "./migrations/*.+(js|ts)"),
|
|
195
|
+
...jarShopKitMigrations,
|
|
196
|
+
// A Feature that is switched off registers no migrations; tables it
|
|
197
|
+
// created earlier stay untouched (ADR-0009).
|
|
198
|
+
...(invoicing ? jarShopInvoicingMigrations : []),
|
|
199
|
+
...(features.migrations ?? []),
|
|
200
|
+
],
|
|
201
|
+
logging: false,
|
|
202
|
+
database: process.env.DB_NAME,
|
|
203
|
+
schema: process.env.DB_SCHEMA,
|
|
204
|
+
host: process.env.DB_HOST,
|
|
205
|
+
port: Number(process.env.DB_PORT),
|
|
206
|
+
username: process.env.DB_USERNAME,
|
|
207
|
+
password: process.env.DB_PASSWORD,
|
|
208
|
+
},
|
|
209
|
+
paymentOptions: {
|
|
210
|
+
paymentMethodHandlers: [...features.paymentMethodHandlers],
|
|
211
|
+
},
|
|
212
|
+
shippingOptions: {
|
|
213
|
+
shippingEligibilityCheckers,
|
|
214
|
+
shippingCalculators,
|
|
215
|
+
},
|
|
216
|
+
plugins: [
|
|
217
|
+
JarShopCheckoutPlugin,
|
|
218
|
+
JarShopRedirectPaymentPlugin,
|
|
219
|
+
...(invoicing
|
|
220
|
+
? [JarShopInvoicingPlugin.init(invoicing), JarShopInvoiceDeliveryPlugin]
|
|
221
|
+
: []),
|
|
222
|
+
JarShopShippingSelectionPlugin,
|
|
223
|
+
...(packeta ? [packeta.plugin] : []),
|
|
224
|
+
...(features.plugins ?? []),
|
|
225
|
+
// A GraphQL IDE is a development convenience, not something a live
|
|
226
|
+
// storefront's admin needs exposed - and its own page is titled
|
|
227
|
+
// "Vendure GraphiQL", which JarShop has no override for.
|
|
228
|
+
...(isDev ? [GraphiqlPlugin.init()] : []),
|
|
229
|
+
AssetServerPlugin.init({
|
|
230
|
+
route: "assets",
|
|
231
|
+
assetUploadDir: path.join(__dirname, "../static/assets"),
|
|
232
|
+
}),
|
|
233
|
+
DefaultSchedulerPlugin.init(),
|
|
234
|
+
DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
|
|
235
|
+
DefaultSearchPlugin.init({
|
|
236
|
+
bufferUpdates: false,
|
|
237
|
+
indexStockStatus: true,
|
|
238
|
+
}),
|
|
239
|
+
EmailPlugin.init({
|
|
240
|
+
globalTemplateVars: (ctx) => ({
|
|
241
|
+
fromAddress:
|
|
242
|
+
process.env.JARSHOP_EMAIL_SMTP_FROM ??
|
|
243
|
+
"JarShop <noreply@localhost>",
|
|
244
|
+
verifyEmailAddressUrl: storefrontAccountUrl(
|
|
245
|
+
ctx.channel.token,
|
|
246
|
+
ctx.languageCode,
|
|
247
|
+
"verify/complete",
|
|
248
|
+
),
|
|
249
|
+
passwordResetUrl: storefrontAccountUrl(
|
|
250
|
+
ctx.channel.token,
|
|
251
|
+
ctx.languageCode,
|
|
252
|
+
"password-reset/callback",
|
|
253
|
+
),
|
|
254
|
+
}),
|
|
255
|
+
// JarShop owns confirmation delivery through its durable outbox. Retain
|
|
256
|
+
// Vendure's account and password handlers but prevent a second receipt.
|
|
257
|
+
handlers: defaultEmailHandlers.filter(
|
|
258
|
+
(handler) => handler.type !== "order-confirmation",
|
|
107
259
|
),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"password-reset/callback",
|
|
260
|
+
templateLoader: new FileBasedTemplateLoader(
|
|
261
|
+
path.join(__dirname, "../static/email/templates"),
|
|
111
262
|
),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
host: requiredEnvironment("JARSHOP_EMAIL_SMTP_HOST"),
|
|
131
|
-
port: Number(requiredEnvironment("JARSHOP_EMAIL_SMTP_PORT")),
|
|
132
|
-
secure:
|
|
133
|
-
requiredEnvironment("JARSHOP_EMAIL_SMTP_SECURE") === "true",
|
|
134
|
-
auth: {
|
|
135
|
-
user: requiredEnvironment("JARSHOP_EMAIL_SMTP_USERNAME"),
|
|
136
|
-
pass: requiredEnvironment("JARSHOP_EMAIL_SMTP_PASSWORD"),
|
|
137
|
-
},
|
|
263
|
+
...(isDev
|
|
264
|
+
? {
|
|
265
|
+
devMode: true as const,
|
|
266
|
+
outputPath: path.join(__dirname, "../static/email/test-emails"),
|
|
267
|
+
route: "mailbox",
|
|
268
|
+
}
|
|
269
|
+
: {
|
|
270
|
+
transport: () => ({
|
|
271
|
+
type: "smtp" as const,
|
|
272
|
+
host: requiredEnvironment("JARSHOP_EMAIL_SMTP_HOST"),
|
|
273
|
+
port: Number(requiredEnvironment("JARSHOP_EMAIL_SMTP_PORT")),
|
|
274
|
+
secure:
|
|
275
|
+
requiredEnvironment("JARSHOP_EMAIL_SMTP_SECURE") === "true",
|
|
276
|
+
auth: {
|
|
277
|
+
user: requiredEnvironment("JARSHOP_EMAIL_SMTP_USERNAME"),
|
|
278
|
+
pass: requiredEnvironment("JARSHOP_EMAIL_SMTP_PASSWORD"),
|
|
279
|
+
},
|
|
280
|
+
}),
|
|
138
281
|
}),
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
282
|
+
}),
|
|
283
|
+
DashboardPlugin.init({
|
|
284
|
+
route: "dashboard",
|
|
285
|
+
appDir: isDev
|
|
286
|
+
? path.join(__dirname, "../dist/dashboard")
|
|
287
|
+
: path.join(__dirname, "dashboard"),
|
|
288
|
+
}),
|
|
289
|
+
],
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export const config: VendureConfig = createVendureConfig(clientFeatures);
|
|
@@ -6,3 +6,10 @@ over `@jarwizz/commerce-sdk`.
|
|
|
6
6
|
|
|
7
7
|
The `/sk` and `/en` routes intentionally render a safe empty state when the
|
|
8
8
|
Shop API is unavailable. A production build must not require a live API.
|
|
9
|
+
|
|
10
|
+
Packeta is applied as client-owned checkout source. The page receives the
|
|
11
|
+
runtime widget configuration from `lib/commerce.ts`, while selection crosses
|
|
12
|
+
`lib/commerce.ts` and the generic Commerce SDK through a Server Action. The UI
|
|
13
|
+
never accepts browser-authored point labels or addresses; it displays only the
|
|
14
|
+
server-returned pickup snapshot and treats script or validation failures as
|
|
15
|
+
retryable.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getProduct } from "../../../lib/commerce";
|
|
2
2
|
import { addToCart } from "../../../lib/cart";
|
|
3
|
-
import { createTranslator
|
|
3
|
+
import { createTranslator } from "../../../lib/i18n";
|
|
4
|
+
import { resolveRequestLocale } from "../../../lib/market";
|
|
4
5
|
import { AddToCartForm } from "./add-to-cart-form";
|
|
5
6
|
|
|
6
7
|
interface ProductPageProps {
|
|
@@ -9,7 +10,7 @@ interface ProductPageProps {
|
|
|
9
10
|
|
|
10
11
|
export default async function ProductPage({ params }: ProductPageProps) {
|
|
11
12
|
const { locale, slug } = await params;
|
|
12
|
-
const language =
|
|
13
|
+
const { language } = await resolveRequestLocale(locale);
|
|
13
14
|
const result = await getProduct(slug, language);
|
|
14
15
|
const t = createTranslator(language);
|
|
15
16
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { login } from "../../../../lib/account";
|
|
2
|
-
import { createTranslator
|
|
2
|
+
import { createTranslator } from "../../../../lib/i18n";
|
|
3
|
+
import { resolveRequestLocale } from "../../../../lib/market";
|
|
3
4
|
import { LoginForm } from "./login-form";
|
|
4
5
|
|
|
5
6
|
interface LoginPageProps {
|
|
@@ -8,7 +9,7 @@ interface LoginPageProps {
|
|
|
8
9
|
|
|
9
10
|
export default async function LoginPage({ params }: LoginPageProps) {
|
|
10
11
|
const { locale } = await params;
|
|
11
|
-
const language =
|
|
12
|
+
const { language } = await resolveRequestLocale(locale);
|
|
12
13
|
const t = createTranslator(language);
|
|
13
14
|
|
|
14
15
|
return (
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
updateAddress,
|
|
11
11
|
updateProfile,
|
|
12
12
|
} from "../../../lib/account";
|
|
13
|
-
import { createTranslator
|
|
13
|
+
import { createTranslator } from "../../../lib/i18n";
|
|
14
|
+
import { resolveRequestLocale } from "../../../lib/market";
|
|
15
|
+
import { formattingLocale } from "../../../lib/market-config";
|
|
14
16
|
import { ChangePasswordForm } from "./change-password-form";
|
|
15
17
|
import { AccountMutationForm } from "./account-mutation-form";
|
|
16
18
|
|
|
@@ -25,7 +27,7 @@ export default async function AccountPage({
|
|
|
25
27
|
}: AccountPageProps) {
|
|
26
28
|
const { locale } = await params;
|
|
27
29
|
const query = await searchParams;
|
|
28
|
-
const language =
|
|
30
|
+
const { market, language } = await resolveRequestLocale(locale);
|
|
29
31
|
const requestedOrders =
|
|
30
32
|
typeof query.orders === "string" ? Number(query.orders) : 10;
|
|
31
33
|
const orderTake =
|
|
@@ -171,7 +173,11 @@ export default async function AccountPage({
|
|
|
171
173
|
</label>
|
|
172
174
|
<label>
|
|
173
175
|
{t("account.country")}
|
|
174
|
-
<input
|
|
176
|
+
<input
|
|
177
|
+
defaultValue={market.countries[0]}
|
|
178
|
+
name="countryCode"
|
|
179
|
+
required
|
|
180
|
+
/>
|
|
175
181
|
</label>
|
|
176
182
|
<label>
|
|
177
183
|
{t("account.phone")}
|
|
@@ -196,7 +202,7 @@ export default async function AccountPage({
|
|
|
196
202
|
{account.orders.map((order) => (
|
|
197
203
|
<li key={order.id}>
|
|
198
204
|
{order.code} — {order.state} —{" "}
|
|
199
|
-
{new Intl.NumberFormat(language
|
|
205
|
+
{new Intl.NumberFormat(formattingLocale(market, language), {
|
|
200
206
|
style: "currency",
|
|
201
207
|
currency: order.total.currencyCode,
|
|
202
208
|
}).format(order.total.amount / 100)}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
PASSWORD_RESET_TOKEN_COOKIE,
|
|
5
5
|
passwordResetTokenCookieOptions,
|
|
6
6
|
} from "../../../../../lib/password-reset-token";
|
|
7
|
-
import {
|
|
7
|
+
import { resolveRequestLocale } from "../../../../../lib/market";
|
|
8
8
|
|
|
9
9
|
interface PasswordResetCallbackContext {
|
|
10
10
|
params: Promise<{ locale: string }>;
|
|
@@ -14,7 +14,9 @@ export async function GET(
|
|
|
14
14
|
request: NextRequest,
|
|
15
15
|
context: PasswordResetCallbackContext,
|
|
16
16
|
): Promise<NextResponse> {
|
|
17
|
-
const locale =
|
|
17
|
+
const { language: locale } = await resolveRequestLocale(
|
|
18
|
+
(await context.params).locale,
|
|
19
|
+
);
|
|
18
20
|
const resetUrl = new URL(
|
|
19
21
|
`/${locale}/account/password-reset/complete`,
|
|
20
22
|
request.url,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resetPassword } from "../../../../../lib/account";
|
|
2
|
-
import { createTranslator
|
|
2
|
+
import { createTranslator } from "../../../../../lib/i18n";
|
|
3
|
+
import { resolveRequestLocale } from "../../../../../lib/market";
|
|
3
4
|
import { ResetPasswordForm } from "../password-reset-forms";
|
|
4
5
|
|
|
5
6
|
interface CompletePasswordResetPageProps {
|
|
@@ -9,7 +10,7 @@ interface CompletePasswordResetPageProps {
|
|
|
9
10
|
export default async function CompletePasswordResetPage({
|
|
10
11
|
params,
|
|
11
12
|
}: CompletePasswordResetPageProps) {
|
|
12
|
-
const language =
|
|
13
|
+
const { language } = await resolveRequestLocale((await params).locale);
|
|
13
14
|
const t = createTranslator(language);
|
|
14
15
|
|
|
15
16
|
return (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { requestPasswordReset } from "../../../../lib/account";
|
|
2
|
-
import { createTranslator
|
|
2
|
+
import { createTranslator } from "../../../../lib/i18n";
|
|
3
|
+
import { resolveRequestLocale } from "../../../../lib/market";
|
|
3
4
|
import { PasswordResetRequestForm } from "./password-reset-forms";
|
|
4
5
|
import { redirect } from "next/navigation";
|
|
5
6
|
|
|
@@ -14,7 +15,7 @@ export default async function PasswordResetPage({
|
|
|
14
15
|
}: PasswordResetPageProps) {
|
|
15
16
|
const { locale } = await params;
|
|
16
17
|
const { token } = await searchParams;
|
|
17
|
-
const language =
|
|
18
|
+
const { language } = await resolveRequestLocale(locale);
|
|
18
19
|
if (typeof token === "string" && token.trim()) {
|
|
19
20
|
redirect(
|
|
20
21
|
`/${language}/account/password-reset/callback?token=${encodeURIComponent(token)}`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { register } from "../../../../lib/account";
|
|
2
|
-
import { createTranslator
|
|
2
|
+
import { createTranslator } from "../../../../lib/i18n";
|
|
3
|
+
import { resolveRequestLocale } from "../../../../lib/market";
|
|
3
4
|
import { RegisterForm } from "./register-form";
|
|
4
5
|
|
|
5
6
|
interface RegisterPageProps {
|
|
@@ -8,7 +9,7 @@ interface RegisterPageProps {
|
|
|
8
9
|
|
|
9
10
|
export default async function RegisterPage({ params }: RegisterPageProps) {
|
|
10
11
|
const { locale } = await params;
|
|
11
|
-
const language =
|
|
12
|
+
const { language } = await resolveRequestLocale(locale);
|
|
12
13
|
const t = createTranslator(language);
|
|
13
14
|
|
|
14
15
|
return (
|
|
@@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
|
|
|
2
2
|
|
|
3
3
|
import { completeAccountVerification } from "../../../../../lib/account";
|
|
4
4
|
import { createCommerceSessionStore } from "../../../../../lib/commerce-session";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveRequestLocale } from "../../../../../lib/market";
|
|
6
6
|
|
|
7
7
|
interface VerifyAccountCallbackContext {
|
|
8
8
|
params: Promise<{ locale: string }>;
|
|
@@ -12,7 +12,9 @@ export async function GET(
|
|
|
12
12
|
request: NextRequest,
|
|
13
13
|
context: VerifyAccountCallbackContext,
|
|
14
14
|
): Promise<NextResponse> {
|
|
15
|
-
const locale =
|
|
15
|
+
const { language: locale } = await resolveRequestLocale(
|
|
16
|
+
(await context.params).locale,
|
|
17
|
+
);
|
|
16
18
|
const accountUrl = new URL(`/${locale}/account`, request.url);
|
|
17
19
|
const invalidUrl = new URL(`/${locale}/account/verify`, request.url);
|
|
18
20
|
const response = NextResponse.redirect(accountUrl);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createTranslator
|
|
1
|
+
import { createTranslator } from "../../../../lib/i18n";
|
|
2
|
+
import { resolveRequestLocale } from "../../../../lib/market";
|
|
2
3
|
import { redirect } from "next/navigation";
|
|
3
4
|
import { refreshVerification } from "../../../../lib/account";
|
|
4
5
|
import { RefreshVerificationForm } from "./refresh-form";
|
|
@@ -14,7 +15,7 @@ export default async function VerifyPage({
|
|
|
14
15
|
}: VerifyPageProps) {
|
|
15
16
|
const { locale } = await params;
|
|
16
17
|
const { token } = await searchParams;
|
|
17
|
-
const language =
|
|
18
|
+
const { language } = await resolveRequestLocale(locale);
|
|
18
19
|
const t = createTranslator(language);
|
|
19
20
|
|
|
20
21
|
if (typeof token === "string" && token) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCart, removeCartLine, updateCartLine } from "../../../lib/cart";
|
|
2
|
-
import { createTranslator
|
|
2
|
+
import { createTranslator } from "../../../lib/i18n";
|
|
3
|
+
import { resolveRequestLocale } from "../../../lib/market";
|
|
3
4
|
|
|
4
5
|
interface CartPageProps {
|
|
5
6
|
params: Promise<{ locale: string }>;
|
|
@@ -11,7 +12,7 @@ function formatMoney(amount: number, currencyCode: string): string {
|
|
|
11
12
|
|
|
12
13
|
export default async function CartPage({ params }: CartPageProps) {
|
|
13
14
|
const { locale } = await params;
|
|
14
|
-
const language =
|
|
15
|
+
const { language } = await resolveRequestLocale(locale);
|
|
15
16
|
const t = createTranslator(language);
|
|
16
17
|
const cart = await getCart(language);
|
|
17
18
|
|