@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.
Files changed (120) hide show
  1. package/README.md +15 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +1 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/generator.d.ts +11 -1
  6. package/dist/generator.js +45 -11
  7. package/dist/generator.js.map +1 -1
  8. package/dist/presets.d.ts +28 -0
  9. package/dist/presets.js +105 -0
  10. package/dist/presets.js.map +1 -0
  11. package/dist/template/CONTEXT.md +4 -2
  12. package/dist/template/README.md +255 -3
  13. package/dist/template/env.example.template +19 -0
  14. package/dist/template/gitignore.template +1 -0
  15. package/dist/template/jarshop.config.ts +37 -0
  16. package/dist/template/package.json +4 -0
  17. package/dist/template/pnpm-lock.yaml +3284 -1815
  18. package/dist/template/pnpm-workspace.yaml +6 -1
  19. package/dist/template/src/client/features.ts +41 -0
  20. package/dist/template/src/client/invoicing.ts +29 -0
  21. package/dist/template/src/dev-storefront-environment.test.ts +45 -0
  22. package/dist/template/src/dev-storefront-environment.ts +32 -0
  23. package/dist/template/src/dev-storefront.ts +3 -12
  24. package/dist/template/src/environment.d.ts +8 -0
  25. package/dist/template/src/invoice-email-recover.ts +59 -0
  26. package/dist/template/src/jarshop-config-loader.ts +118 -0
  27. package/dist/template/src/jarshop-config.test.ts +365 -0
  28. package/dist/template/src/jarshop-config.ts +462 -0
  29. package/dist/template/src/jarshop-features.test.ts +222 -0
  30. package/dist/template/src/jarshop-features.ts +112 -0
  31. package/dist/template/src/migrations/1788100000000-jarshop-guest-order-session.ts +27 -0
  32. package/dist/template/src/operation-codes.ts +34 -0
  33. package/dist/template/src/packeta-config.test.ts +95 -0
  34. package/dist/template/src/packeta-countries.test.ts +161 -0
  35. package/dist/template/src/packeta-countries.ts +120 -0
  36. package/dist/template/src/packeta-validation.test.ts +35 -0
  37. package/dist/template/src/packeta-validation.ts +52 -0
  38. package/dist/template/src/payment-return-url.test.ts +57 -0
  39. package/dist/template/src/payment-return-url.ts +34 -0
  40. package/dist/template/src/plugins/jarshop-checkout/confirmation-view.test.ts +79 -0
  41. package/dist/template/src/plugins/jarshop-checkout/confirmation.ts +51 -0
  42. package/dist/template/src/plugins/jarshop-checkout/dashboard/index.tsx +1 -0
  43. package/dist/template/src/plugins/jarshop-checkout/index.ts +4 -0
  44. package/dist/template/src/plugins/jarshop-checkout/invoice-delivery.plugin.ts +79 -0
  45. package/dist/template/src/plugins/jarshop-checkout/invoice-email-events.ts +35 -0
  46. package/dist/template/src/plugins/jarshop-checkout/invoice-email-lifecycle.ts +235 -0
  47. package/dist/template/src/plugins/jarshop-checkout/invoice-email-worker.test.ts +426 -0
  48. package/dist/template/src/plugins/jarshop-checkout/invoice-email.test.ts +107 -0
  49. package/dist/template/src/plugins/jarshop-checkout/jarshop-checkout.plugin.ts +167 -58
  50. package/dist/template/src/plugins/jarshop-checkout/market-active-order-core.ts +108 -0
  51. package/dist/template/src/plugins/jarshop-checkout/market-active-order.test.ts +205 -0
  52. package/dist/template/src/plugins/jarshop-checkout/market-active-order.ts +186 -0
  53. package/dist/template/src/plugins/jarshop-checkout/market-channels.test.ts +58 -0
  54. package/dist/template/src/plugins/jarshop-checkout/market-channels.ts +87 -0
  55. package/dist/template/src/plugins/jarshop-checkout/operation-code-check.ts +36 -0
  56. package/dist/template/src/plugins/jarshop-checkout/order-email-configuration.entity.ts +1 -1
  57. package/dist/template/src/plugins/jarshop-checkout/order-email-configuration.ts +1 -0
  58. package/dist/template/src/plugins/jarshop-checkout/order-email-delivery-core.ts +94 -1
  59. package/dist/template/src/plugins/jarshop-checkout/order-email-delivery.entity.ts +1 -0
  60. package/dist/template/src/plugins/jarshop-checkout/order-email-outbox.ts +83 -1
  61. package/dist/template/src/plugins/jarshop-checkout/order-email-worker.ts +136 -1
  62. package/dist/template/src/plugins/jarshop-checkout/shipping-tax.test.ts +109 -0
  63. package/dist/template/src/plugins/jarshop-checkout/shipping.test.ts +156 -0
  64. package/dist/template/src/plugins/jarshop-checkout/shipping.ts +75 -11
  65. package/dist/template/src/seed.ts +473 -185
  66. package/dist/template/src/vendure-config.ts +258 -113
  67. package/dist/template/storefront/README.md +7 -0
  68. package/dist/template/storefront/app/[locale]/[slug]/page.tsx +3 -2
  69. package/dist/template/storefront/app/[locale]/account/login/page.tsx +3 -2
  70. package/dist/template/storefront/app/[locale]/account/page.tsx +10 -4
  71. package/dist/template/storefront/app/[locale]/account/password-reset/callback/route.ts +4 -2
  72. package/dist/template/storefront/app/[locale]/account/password-reset/complete/page.tsx +3 -2
  73. package/dist/template/storefront/app/[locale]/account/password-reset/page.tsx +3 -2
  74. package/dist/template/storefront/app/[locale]/account/register/page.tsx +3 -2
  75. package/dist/template/storefront/app/[locale]/account/verify/complete/route.ts +4 -2
  76. package/dist/template/storefront/app/[locale]/account/verify/page.tsx +3 -2
  77. package/dist/template/storefront/app/[locale]/cart/page.tsx +3 -2
  78. package/dist/template/storefront/app/[locale]/checkout/actions.ts +43 -0
  79. package/dist/template/storefront/app/[locale]/checkout/checkout-form.tsx +188 -36
  80. package/dist/template/storefront/app/[locale]/checkout/confirmation/route.ts +2 -2
  81. package/dist/template/storefront/app/[locale]/checkout/packeta-chooser.tsx +96 -0
  82. package/dist/template/storefront/app/[locale]/checkout/page.tsx +60 -2
  83. package/dist/template/storefront/app/[locale]/checkout/payment-return/actions.ts +55 -0
  84. package/dist/template/storefront/app/[locale]/checkout/payment-return/page.tsx +32 -0
  85. package/dist/template/storefront/app/[locale]/checkout/payment-return/payment-return.tsx +84 -0
  86. package/dist/template/storefront/app/[locale]/checkout/success/page.tsx +32 -2
  87. package/dist/template/storefront/app/[locale]/layout.tsx +3 -2
  88. package/dist/template/storefront/app/[locale]/page.tsx +3 -2
  89. package/dist/template/storefront/app/globals.css +16 -0
  90. package/dist/template/storefront/app/layout.tsx +6 -2
  91. package/dist/template/storefront/lib/cart.ts +2 -4
  92. package/dist/template/storefront/lib/checkout-contract.test.ts +18 -1
  93. package/dist/template/storefront/lib/checkout-contract.ts +8 -0
  94. package/dist/template/storefront/lib/checkout-countries.test.ts +61 -0
  95. package/dist/template/storefront/lib/checkout-countries.ts +67 -0
  96. package/dist/template/storefront/lib/checkout.ts +22 -11
  97. package/dist/template/storefront/lib/commerce.ts +262 -2
  98. package/dist/template/storefront/lib/confirmation.test.ts +116 -0
  99. package/dist/template/storefront/lib/confirmation.ts +13 -7
  100. package/dist/template/storefront/lib/i18n.test.ts +32 -12
  101. package/dist/template/storefront/lib/i18n.ts +29 -8
  102. package/dist/template/storefront/lib/market-config.ts +40 -0
  103. package/dist/template/storefront/lib/market-routing.test.ts +107 -0
  104. package/dist/template/storefront/lib/market-routing.ts +57 -0
  105. package/dist/template/storefront/lib/market.ts +51 -0
  106. package/dist/template/storefront/lib/packeta-selection.test.ts +141 -0
  107. package/dist/template/storefront/lib/packeta-selection.ts +98 -0
  108. package/dist/template/storefront/lib/payment-return-actions.test.ts +61 -0
  109. package/dist/template/storefront/lib/payment-return-page.test.ts +30 -0
  110. package/dist/template/storefront/lib/payment-return-polling.test.ts +37 -0
  111. package/dist/template/storefront/lib/payment-return-polling.ts +58 -0
  112. package/dist/template/storefront/messages/en.json +13 -1
  113. package/dist/template/storefront/messages/sk.json +13 -1
  114. package/dist/template/storefront/package.json +2 -1
  115. package/dist/template/storefront/proxy.ts +35 -0
  116. package/dist/template/turbo.json +5 -1
  117. package/dist/template-manifest.json +1 -1
  118. package/dist/template.js +1 -0
  119. package/dist/template.js.map +1 -1
  120. 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
- JarShopCheckoutPlugin,
18
- jarShopCodPaymentHandler,
19
- } from "./plugins/jarshop-checkout/index.js";
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
- const storefrontUrl = new URL(
25
- process.env.JARSHOP_STOREFRONT_URL ?? "http://localhost:3001",
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(locale: string, path: string): string {
35
- const supportedLocale = locale === "en" ? "en" : "sk";
36
- return new URL(
37
- `/${supportedLocale}/account/${path}`,
38
- storefrontUrl,
39
- ).toString();
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
- export const config: VendureConfig = {
43
- // JarShop sells in Slovakia first. This is read when a new installation
44
- // populates its default channel and global settings, so it decides which
45
- // translation the Dashboard and Shop API fall back to.
46
- defaultLanguageCode: LanguageCode.sk,
47
- apiOptions: {
48
- port: Number(process.env.PORT ?? 3000),
49
- adminApiPath: "admin-api",
50
- shopApiPath: "shop-api",
51
- trustProxy: isDev ? false : 1,
52
- ...(isDev ? { adminApiDebug: true, shopApiDebug: true } : {}),
53
- },
54
- authOptions: {
55
- tokenMethod: ["bearer", "cookie"],
56
- requireVerification: true,
57
- sessionDuration: "30d",
58
- superadminCredentials: {
59
- identifier: process.env.SUPERADMIN_USERNAME ?? "",
60
- password: process.env.SUPERADMIN_PASSWORD ?? "",
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
- cookieOptions: {
63
- name: {
64
- admin: "jarshop-admin-session",
65
- shop: "jarshop-shop-session",
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
- dbConnectionOptions: {
75
- type: "postgres",
76
- synchronize: false,
77
- migrations: [path.join(__dirname, "./migrations/*.+(js|ts)")],
78
- logging: false,
79
- database: process.env.DB_NAME,
80
- schema: process.env.DB_SCHEMA,
81
- host: process.env.DB_HOST,
82
- port: Number(process.env.DB_PORT),
83
- username: process.env.DB_USERNAME,
84
- password: process.env.DB_PASSWORD,
85
- },
86
- paymentOptions: { paymentMethodHandlers: [jarShopCodPaymentHandler] },
87
- plugins: [
88
- JarShopCheckoutPlugin,
89
- // A GraphQL IDE is a development convenience, not something a live
90
- // storefront's admin needs exposed - and its own page is titled
91
- // "Vendure GraphiQL", which JarShop has no override for.
92
- ...(isDev ? [GraphiqlPlugin.init()] : []),
93
- AssetServerPlugin.init({
94
- route: "assets",
95
- assetUploadDir: path.join(__dirname, "../static/assets"),
96
- }),
97
- DefaultSchedulerPlugin.init(),
98
- DefaultJobQueuePlugin.init({ useDatabaseForBuffer: true }),
99
- DefaultSearchPlugin.init({ bufferUpdates: false, indexStockStatus: true }),
100
- EmailPlugin.init({
101
- globalTemplateVars: (ctx) => ({
102
- fromAddress:
103
- process.env.JARSHOP_EMAIL_SMTP_FROM ?? "JarShop <noreply@localhost>",
104
- verifyEmailAddressUrl: storefrontAccountUrl(
105
- ctx.languageCode,
106
- "verify/complete",
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
- passwordResetUrl: storefrontAccountUrl(
109
- ctx.languageCode,
110
- "password-reset/callback",
260
+ templateLoader: new FileBasedTemplateLoader(
261
+ path.join(__dirname, "../static/email/templates"),
111
262
  ),
112
- }),
113
- // JarShop owns confirmation delivery through its durable outbox. Retain
114
- // Vendure's account and password handlers but prevent a second receipt.
115
- handlers: defaultEmailHandlers.filter(
116
- (handler) => handler.type !== "order-confirmation",
117
- ),
118
- templateLoader: new FileBasedTemplateLoader(
119
- path.join(__dirname, "../static/email/templates"),
120
- ),
121
- ...(isDev
122
- ? {
123
- devMode: true as const,
124
- outputPath: path.join(__dirname, "../static/email/test-emails"),
125
- route: "mailbox",
126
- }
127
- : {
128
- transport: () => ({
129
- type: "smtp" as const,
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
- DashboardPlugin.init({
142
- route: "dashboard",
143
- appDir: isDev
144
- ? path.join(__dirname, "../dist/dashboard")
145
- : path.join(__dirname, "dashboard"),
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, parseLocale } from "../../../lib/i18n";
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 = parseLocale(locale);
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, parseLocale } from "../../../../lib/i18n";
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 = parseLocale(locale);
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, parseLocale } from "../../../lib/i18n";
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 = parseLocale(locale);
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 defaultValue="SK" name="countryCode" required />
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 === "sk" ? "sk-SK" : "en-GB", {
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 { parseLocale } from "../../../../../lib/i18n";
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 = parseLocale((await context.params).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, parseLocale } from "../../../../../lib/i18n";
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 = parseLocale((await params).locale);
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, parseLocale } from "../../../../lib/i18n";
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 = parseLocale(locale);
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, parseLocale } from "../../../../lib/i18n";
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 = parseLocale(locale);
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 { parseLocale } from "../../../../../lib/i18n";
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 = parseLocale((await context.params).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, parseLocale } from "../../../../lib/i18n";
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 = parseLocale(locale);
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, parseLocale } from "../../../lib/i18n";
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 = parseLocale(locale);
15
+ const { language } = await resolveRequestLocale(locale);
15
16
  const t = createTranslator(language);
16
17
  const cart = await getCart(language);
17
18