@carrierllc/mcp 0.13.41 → 0.13.48

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 (68) hide show
  1. package/dist/{chunk-6OAZJBLA.js → chunk-H77A3SME.js} +71 -8
  2. package/dist/chunk-H77A3SME.js.map +1 -0
  3. package/dist/cli.js +128 -10
  4. package/dist/cli.js.map +1 -1
  5. package/dist/index.js +66 -15
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -3
  8. package/templates/storefront/CLERK.md +23 -0
  9. package/templates/storefront/src/app/activate/[orderId]/ActivateClient.tsx +29 -22
  10. package/templates/storefront/src/app/activate/[orderId]/page.tsx +2 -2
  11. package/templates/storefront/src/app/api/checkout/claim/route.ts +7 -6
  12. package/templates/storefront/src/app/api/checkout/guest/route.ts +72 -17
  13. package/templates/storefront/src/app/api/orders/[orderId]/route.ts +2 -2
  14. package/templates/storefront/src/app/checkout/[templateId]/CheckoutClient.tsx +51 -25
  15. package/templates/storefront/src/app/checkout/success/CheckoutSuccessClient.tsx +165 -131
  16. package/templates/storefront/src/app/checkout/success/FocusHeading.tsx +20 -0
  17. package/templates/storefront/src/app/checkout/success/page.tsx +136 -15
  18. package/templates/storefront/src/app/dashboard/EsimControls.tsx +20 -24
  19. package/templates/storefront/src/app/dashboard/page.tsx +43 -23
  20. package/templates/storefront/src/app/globals.css +44 -5
  21. package/templates/storefront/src/app/help/page.tsx +2 -2
  22. package/templates/storefront/src/app/layout.tsx +5 -3
  23. package/templates/storefront/src/app/page.tsx +27 -7
  24. package/templates/storefront/src/app/shop/ShopClient.tsx +106 -72
  25. package/templates/storefront/src/app/shop/page.tsx +7 -2
  26. package/templates/storefront/src/app/sign-in/[[...sign-in]]/StorefrontSignInClient.tsx +297 -0
  27. package/templates/storefront/src/app/sign-in/[[...sign-in]]/page.tsx +13 -14
  28. package/templates/storefront/src/app/sign-up/[[...sign-up]]/StorefrontSignUpClient.tsx +31 -28
  29. package/templates/storefront/src/app/sign-up/[[...sign-up]]/page.tsx +5 -2
  30. package/templates/storefront/src/brand.config.ts +16 -0
  31. package/templates/storefront/src/components/Providers.tsx +20 -1
  32. package/templates/storefront/src/components/faq/FaqSection.tsx +2 -2
  33. package/templates/storefront/src/components/footer/StorefrontFooter.tsx +7 -7
  34. package/templates/storefront/src/components/landing/FinalCTA.tsx +4 -9
  35. package/templates/storefront/src/components/landing/HeroSection.tsx +4 -7
  36. package/templates/storefront/src/components/landing/HowItWorks.tsx +1 -1
  37. package/templates/storefront/src/components/landing/PlanCard.tsx +23 -13
  38. package/templates/storefront/src/components/landing/TierPlanBoard.tsx +237 -0
  39. package/templates/storefront/src/components/nav/StorefrontNav.tsx +8 -11
  40. package/templates/storefront/src/components/shop/CountrySearch.tsx +94 -0
  41. package/templates/storefront/src/components/theme/BrandStyles.tsx +2 -2
  42. package/templates/storefront/src/components/theme/ThemeToggle.tsx +1 -1
  43. package/templates/storefront/src/components/theme/brand-accent-css.ts +21 -0
  44. package/templates/storefront/src/components/theme/brand-style.ts +88 -0
  45. package/templates/storefront/src/components/theme/clerk-appearance.ts +18 -2
  46. package/templates/storefront/src/lib/buyer-auth-copy.ts +83 -0
  47. package/templates/storefront/src/lib/buyer-error.ts +32 -0
  48. package/templates/storefront/src/lib/buyer-session.ts +41 -0
  49. package/templates/storefront/src/lib/catalog-countries.ts +179 -0
  50. package/templates/storefront/src/lib/checkout-client-error.ts +28 -0
  51. package/templates/storefront/src/lib/checkout-copy.ts +89 -0
  52. package/templates/storefront/src/lib/checkout-order-claim.ts +8 -7
  53. package/templates/storefront/src/lib/checkout-return.ts +18 -0
  54. package/templates/storefront/src/lib/clerk-instance.ts +89 -0
  55. package/templates/storefront/src/lib/order-reference.ts +15 -0
  56. package/templates/storefront/src/lib/request-origin.ts +28 -0
  57. package/templates/storefront/src/lib/sanitize-auth-redirect.ts +20 -4
  58. package/templates/storefront/src/lib/tap-target.ts +17 -0
  59. package/templates/storefront/src/lib/verify-checkout-session.ts +118 -19
  60. package/templates/storefront/src/middleware.ts +11 -0
  61. package/templates/storefront/src/vendor/carrier/catalog-guard.ts +9 -5
  62. package/templates/storefront/src/vendor/carrier/client.ts +22 -4
  63. package/templates/storefront/src/vendor/carrier/country-offers.ts +106 -0
  64. package/templates/storefront/src/vendor/carrier/stripe-price.ts +134 -0
  65. package/templates/storefront/src/vendor/carrier/tiers.ts +161 -0
  66. package/templates/storefront/src/vendor/carrier/types.ts +22 -0
  67. package/templates/storefront/src/vendor/geo/index.ts +15 -4
  68. package/dist/chunk-6OAZJBLA.js.map +0 -1
package/dist/cli.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  verifyStorefront,
45
45
  walletScreen,
46
46
  which
47
- } from "./chunk-6OAZJBLA.js";
47
+ } from "./chunk-H77A3SME.js";
48
48
  import {
49
49
  copyTree,
50
50
  exists,
@@ -194,7 +194,17 @@ function installAuthGuidance() {
194
194
  import { join as join3 } from "path";
195
195
  function preserveClerkFromEnv(existing, fresh) {
196
196
  let out = fresh;
197
- for (const key of ["NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY", "CLERK_SECRET_KEY"]) {
197
+ for (const key of [
198
+ "NEXT_PUBLIC_CLERK_INSTANCE",
199
+ "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
200
+ "CLERK_SECRET_KEY",
201
+ "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY_PRODUCTION",
202
+ "CLERK_SECRET_KEY_PRODUCTION",
203
+ "NEXT_PUBLIC_PASSWORD_RESET_ENABLED",
204
+ "NEXT_PUBLIC_CLERK_SIGN_IN_URL",
205
+ "NEXT_PUBLIC_CLERK_SIGN_UP_URL",
206
+ "NEXT_PUBLIC_COUNTRY_CATALOG"
207
+ ]) {
198
208
  const line = existing.split("\n").find((l) => l.startsWith(`${key}=`));
199
209
  if (!line) continue;
200
210
  const value = line.slice(key.length + 1);
@@ -2121,6 +2131,8 @@ function regionLabel(code) {
2121
2131
  }
2122
2132
 
2123
2133
  // ../../packages/sdk/src/storefront-write.ts
2134
+ var STRIPE_PRICE_ID_RE = /^price_[A-Za-z0-9_]+$/;
2135
+ var STRIPE_PRICE_ID_MAX_LENGTH = 255;
2124
2136
  var THEME_FIELDS = [
2125
2137
  ["accent", "accent"],
2126
2138
  ["accentDark", "accentDark"],
@@ -2132,7 +2144,17 @@ var COPY_FIELDS = [
2132
2144
  ["hero", "hero"],
2133
2145
  ["tagline", "tagline"],
2134
2146
  ["supportEmail", "supportEmail"],
2135
- ["legalName", "legalName"]
2147
+ ["legalName", "legalName"],
2148
+ ["address", "address"],
2149
+ ["locale", "locale"],
2150
+ ["intro", "intro"],
2151
+ ["ctaLabel", "ctaLabel"],
2152
+ ["howHeading", "howHeading"],
2153
+ ["plansHeading", "plansHeading"],
2154
+ ["buyLabel", "buyLabel"],
2155
+ ["emptyPlansText", "emptyPlansText"],
2156
+ ["searchHeading", "searchHeading"],
2157
+ ["searchPlaceholder", "searchPlaceholder"]
2136
2158
  ];
2137
2159
  function storefrontBrandPatch(input, existing) {
2138
2160
  const theme = overlay(existing?.theme, input, THEME_FIELDS);
@@ -2157,7 +2179,12 @@ function completePlanInput(input, plans) {
2157
2179
  input.regions,
2158
2180
  input.description,
2159
2181
  input.active,
2160
- input.sortOrder
2182
+ input.sortOrder,
2183
+ input.group,
2184
+ input.availableFrom,
2185
+ input.availableUntil,
2186
+ input.stripePriceId,
2187
+ input.stripePriceMode
2161
2188
  ].some((value) => value !== void 0);
2162
2189
  if (!touched) return input;
2163
2190
  const slug2 = input.slug?.trim();
@@ -2184,6 +2211,10 @@ function storefrontPlanBody(input) {
2184
2211
  if (input.accountId !== void 0 && (!Number.isSafeInteger(input.accountId) || input.accountId <= 0)) {
2185
2212
  return { error: "OCS account id must be a positive integer." };
2186
2213
  }
2214
+ const stripe = stripePriceFields(input.stripePriceId, input.stripePriceMode);
2215
+ if (stripe && "error" in stripe) return stripe;
2216
+ const windowFields = planWindowFields(input);
2217
+ if (windowFields && "error" in windowFields) return windowFields;
2187
2218
  const productId = input.productId?.trim() ?? "";
2188
2219
  if (productId !== "") {
2189
2220
  const body2 = { product_id: productId };
@@ -2191,7 +2222,7 @@ function storefrontPlanBody(input) {
2191
2222
  if (input.priceCents !== void 0) body2.price_cents = input.priceCents;
2192
2223
  if (input.active !== void 0) body2.active = input.active;
2193
2224
  if (input.sortOrder !== void 0) body2.sort_order = input.sortOrder;
2194
- return body2;
2225
+ return { ...body2, ...windowFields ?? {}, ...stripe ?? {} };
2195
2226
  }
2196
2227
  const touched = [
2197
2228
  input.slug,
@@ -2206,7 +2237,12 @@ function storefrontPlanBody(input) {
2206
2237
  input.regions,
2207
2238
  input.description,
2208
2239
  input.active,
2209
- input.sortOrder
2240
+ input.sortOrder,
2241
+ input.group,
2242
+ input.availableFrom,
2243
+ input.availableUntil,
2244
+ input.stripePriceId,
2245
+ input.stripePriceMode
2210
2246
  ].some((value) => value !== void 0);
2211
2247
  if (!touched) return null;
2212
2248
  if (!input.slug || !input.name || input.priceCents === void 0 || !input.currency || input.templateId === void 0) {
@@ -2230,7 +2266,61 @@ function storefrontPlanBody(input) {
2230
2266
  if (input.description !== void 0) body.description = input.description;
2231
2267
  if (input.active !== void 0) body.active = input.active;
2232
2268
  if (input.sortOrder !== void 0) body.sort_order = input.sortOrder;
2233
- return body;
2269
+ return { ...body, ...windowFields ?? {}, ...stripe ?? {} };
2270
+ }
2271
+ function planWindowFields(input) {
2272
+ const out = {};
2273
+ let touched = false;
2274
+ if (input.group !== void 0) {
2275
+ out.group = input.group === null || input.group.trim() === "" ? null : input.group.trim().slice(0, 80);
2276
+ touched = true;
2277
+ }
2278
+ if (input.availableFrom !== void 0) {
2279
+ if (input.availableFrom === null || input.availableFrom.trim() === "") {
2280
+ out.available_from = null;
2281
+ } else {
2282
+ const ms = Date.parse(input.availableFrom.trim());
2283
+ if (!Number.isFinite(ms)) return { error: "available_from must be an ISO-8601 date or timestamp." };
2284
+ out.available_from = new Date(ms).toISOString();
2285
+ }
2286
+ touched = true;
2287
+ }
2288
+ if (input.availableUntil !== void 0) {
2289
+ if (input.availableUntil === null || input.availableUntil.trim() === "") {
2290
+ out.available_until = null;
2291
+ } else {
2292
+ const trimmed = input.availableUntil.trim();
2293
+ const expanded = /^\d{4}-\d{2}-\d{2}$/.test(trimmed) ? `${trimmed}T23:59:59.999Z` : trimmed;
2294
+ const ms = Date.parse(expanded);
2295
+ if (!Number.isFinite(ms)) return { error: "available_until must be an ISO-8601 date or timestamp." };
2296
+ out.available_until = new Date(ms).toISOString();
2297
+ }
2298
+ touched = true;
2299
+ }
2300
+ if (out.available_from && out.available_until && Date.parse(out.available_from) > Date.parse(out.available_until)) {
2301
+ return { error: "available_from must not be after available_until." };
2302
+ }
2303
+ return touched ? out : void 0;
2304
+ }
2305
+ function stripePriceFields(id, mode) {
2306
+ if (id === void 0 && mode === void 0) return void 0;
2307
+ if (typeof id === "string") {
2308
+ const trimmed = id.trim();
2309
+ if (trimmed.length < 1 || trimmed.length > STRIPE_PRICE_ID_MAX_LENGTH || !STRIPE_PRICE_ID_RE.test(trimmed)) {
2310
+ return { error: "stripe_price_id must look like price_\u2026 and be 1-255 characters." };
2311
+ }
2312
+ id = trimmed;
2313
+ }
2314
+ if (id === null || mode === null) {
2315
+ if (id !== void 0 && id !== null || mode !== void 0 && mode !== null) {
2316
+ return { error: "Sending null clears both stripe_price_id and stripe_price_mode." };
2317
+ }
2318
+ return { stripe_price_id: null, stripe_price_mode: null };
2319
+ }
2320
+ if (id === void 0 || mode === void 0) {
2321
+ return { error: "stripe_price_id and stripe_price_mode must be set together." };
2322
+ }
2323
+ return { stripe_price_id: id, stripe_price_mode: mode };
2234
2324
  }
2235
2325
  function isStorefrontPlanError(value) {
2236
2326
  return value !== null && "error" in value;
@@ -2327,6 +2417,14 @@ function hostedPublishInputFromFlags(flags) {
2327
2417
  if (!logo.ok) return { ok: false, text: logo.text };
2328
2418
  const sortOrder = parseWholeNumber(flags.planSortOrder, "Plan sort order");
2329
2419
  if (!sortOrder.ok) return { ok: false, text: sortOrder.message };
2420
+ const stripeMode = flags.stripePriceMode;
2421
+ if (stripeMode !== void 0 && stripeMode !== "test" && stripeMode !== "live") {
2422
+ return { ok: false, text: "stripe_price_mode must be test or live." };
2423
+ }
2424
+ const locale = flags.locale === void 0 ? void 0 : flags.locale.trim().toLowerCase();
2425
+ if (locale !== void 0 && locale !== "en" && locale !== "nl") {
2426
+ return { ok: false, text: "Locale must be en or nl." };
2427
+ }
2330
2428
  return {
2331
2429
  ok: true,
2332
2430
  input: {
@@ -2342,6 +2440,16 @@ function hostedPublishInputFromFlags(flags) {
2342
2440
  tagline: flags.tagline,
2343
2441
  supportEmail: flags.supportEmail,
2344
2442
  legalName: flags.legalName,
2443
+ address: flags.address,
2444
+ locale,
2445
+ intro: flags.intro,
2446
+ ctaLabel: flags.ctaLabel,
2447
+ howHeading: flags.howHeading,
2448
+ plansHeading: flags.plansHeading,
2449
+ buyLabel: flags.buyLabel,
2450
+ emptyPlansText: flags.emptyPlansText,
2451
+ searchHeading: flags.searchHeading,
2452
+ searchPlaceholder: flags.searchPlaceholder,
2345
2453
  productId: flags.product,
2346
2454
  planSlug: flags.plan,
2347
2455
  planName: flags.planName,
@@ -2355,7 +2463,12 @@ function hostedPublishInputFromFlags(flags) {
2355
2463
  regions: countries.value,
2356
2464
  description: flags.planText,
2357
2465
  planActive: flags.inactive ? false : void 0,
2358
- planSortOrder: sortOrder.value
2466
+ planSortOrder: sortOrder.value,
2467
+ planGroup: flags.planGroup,
2468
+ availableFrom: flags.availableFrom,
2469
+ availableUntil: flags.availableUntil,
2470
+ stripePriceId: flags.stripePriceId,
2471
+ stripePriceMode: stripeMode
2359
2472
  }
2360
2473
  };
2361
2474
  }
@@ -2416,7 +2529,12 @@ function planInput(input) {
2416
2529
  regions: input.regions,
2417
2530
  description: input.description,
2418
2531
  active: input.planActive,
2419
- sortOrder: input.planSortOrder
2532
+ sortOrder: input.planSortOrder,
2533
+ group: input.planGroup,
2534
+ availableFrom: input.availableFrom,
2535
+ availableUntil: input.availableUntil,
2536
+ stripePriceId: input.stripePriceId,
2537
+ stripePriceMode: input.stripePriceMode
2420
2538
  };
2421
2539
  }
2422
2540
  function findStore(body, slug2) {
@@ -7235,7 +7353,7 @@ site.command("deploy [dir]").description("Build + deploy a storefront to whichev
7235
7353
  p3.outro("");
7236
7354
  }
7237
7355
  );
7238
- site.command("publish").description("Publish a Carrier-hosted storefront. Does not deploy a self-hosted copy.").requiredOption("--slug <slug>", "Shop address, such as acme or Acme Mobile").requiredOption("--name <name>", "Brand name").option("--status <status>", "draft or published", "published").option("--accent <hex>", "Accent color, such as #112233").option("--accent-dark <hex>", "Darker accent").option("--bg <hex>", "Page background").option("--text <hex>", "Body text color").option("--logo <url-or-file>", "https logo address, or a PNG, JPEG, WebP, or GIF under 70 KB").option("--hero <text>", "Shop headline").option("--tagline <text>", "Line under the headline").option("--support-email <email>", "Support address").option("--legal-name <name>", "Legal name in the footer").option("--product <id>", "Connectivity plan id. Copies its template, price, and allowance.").option("--plan <slug>", "Plan slug, such as eu-1gb").option("--plan-name <name>", "Plan name on the shop").option("--price <amount>", "Retail price, such as 9.00").option("--price-cents <cents>", "Retail price in minor units").option("--currency <code>", "Three-letter currency code").option("--template-id <id>", "OCS package template id").option("--ocs-account-id <id>", "Owned OCS account override; omit for automatic resolution").option("--data-gb <gb>", "Data allowance, such as 1 or 1 GB, or the text Unlimited").option("--unlimited", "The only way to sell an unlimited plan. A 0 or missing --data-gb without this is refused.").option("--validity-days <days>", "Validity, such as 7 or 7 days").option("--countries <names>", "Country names or codes, such as France, DE").option("--plan-text <text>", "Buyer-facing sentence. Omit to leave the saved text unchanged.").option("--inactive", "Keep the plan off the shop").option("--plan-sort-order <n>", "Plan display order on the shop (ascending, default 0)").action(async (o) => {
7356
+ site.command("publish").description("Publish a Carrier-hosted storefront. Does not deploy a self-hosted copy.").requiredOption("--slug <slug>", "Shop address, such as acme or Acme Mobile").requiredOption("--name <name>", "Brand name").option("--status <status>", "draft or published", "published").option("--accent <hex>", "Accent color, such as #112233").option("--accent-dark <hex>", "Darker accent").option("--bg <hex>", "Page background").option("--text <hex>", "Body text color").option("--logo <url-or-file>", "https logo address, or a PNG, JPEG, WebP, or GIF under 70 KB").option("--hero <text>", "Shop headline").option("--tagline <text>", "Line under the headline").option("--support-email <email>", "Support address").option("--legal-name <name>", "Legal name in the footer").option("--address <text>", "Seller address in the footer").option("--locale <locale>", "Storefront language: en or nl").option("--cta-label <text>", "Hero primary button text").option("--plans-heading <text>", "Heading for the plans section").option("--buy-label <text>", "Button text on each plan card").option("--product <id>", "Connectivity plan id. Copies its template, price, and allowance.").option("--plan <slug>", "Plan slug, such as eu-1gb").option("--plan-name <name>", "Plan name on the shop").option("--price <amount>", "Retail price, such as 9.00").option("--price-cents <cents>", "Retail price in minor units").option("--currency <code>", "Three-letter currency code").option("--template-id <id>", "OCS package template id").option("--ocs-account-id <id>", "Owned OCS account override; omit for automatic resolution").option("--data-gb <gb>", "Data allowance, such as 1 or 1 GB, or the text Unlimited").option("--unlimited", "The only way to sell an unlimited plan. A 0 or missing --data-gb without this is refused.").option("--validity-days <days>", "Validity, such as 7 or 7 days").option("--countries <names>", "Country names or codes, such as France, DE").option("--plan-text <text>", "Buyer-facing sentence. Omit to leave the saved text unchanged.").option("--inactive", "Keep the plan off the shop").option("--plan-sort-order <n>", "Plan display order on the shop (ascending, default 0)").option("--plan-group <label>", "Optional section/group label on the storefront (e.g. Uitwedstrijden)").option("--available-from <iso>", "Optional ISO-8601 start timestamp from which the plan is visible").option("--available-until <iso>", "Optional ISO-8601 end timestamp until which the plan is visible").option("--stripe-price-id <id>", "Existing Stripe Price id (price_\u2026, 1-255 characters), stored, not yet charged. Set with --stripe-price-mode.").option("--stripe-price-mode <mode>", "test or live. Set with --stripe-price-id.").action(async (o) => {
7239
7357
  header();
7240
7358
  const built = hostedPublishInputFromFlags(o);
7241
7359
  if (!built.ok) {