@aglyn/plugins-commerce 1.29.2 → 1.29.3

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.
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import type { SitePageResolver } from '@aglyn/aglyn/server';
17
+ import type { SiteEditContextResolver, SitePageResolver } from '@aglyn/aglyn/server';
18
18
  import * as Aglyn from '@aglyn/aglyn/server';
19
19
  import * as CommerceModel from '../model';
20
20
  /**
@@ -26,6 +26,17 @@ import * as CommerceModel from '../model';
26
26
  * undefined for everything else so the loader falls through.
27
27
  */
28
28
  export declare const commerceSitePageResolver: SitePageResolver;
29
+ /**
30
+ * What the admin edit bar says on the pages the resolver above composes. They
31
+ * are in no routing map, so the bar called a product page "Unrouted page" with
32
+ * no edit link. It answers from the same reads the page is built from: the
33
+ * store's designated template (`pdpScreenId`, `collectionScreenId`), and for
34
+ * a product page the product itself, whose editor the bar links beside the
35
+ * template's Besigner, as it does for a blog post. A product the page would
36
+ * not render (not live, or not sold online) gets no answer, as it gets no
37
+ * page.
38
+ */
39
+ export declare const commerceEditContextResolver: SiteEditContextResolver;
29
40
  export { productPriceText } from '../model';
30
41
  /**
31
42
  * The store's built-in product page (AGL-3676), root first, for the layout's
@@ -29,6 +29,7 @@ import * as CommerceModel from "../model/index.js";
29
29
  import { productAsksUseDateAnywhere, toPublicProductDetail } from "./product.js";
30
30
  import { readStoreDay } from "./store-day.js";
31
31
  import { readProductReviews } from "./reviews.js";
32
+ import { productEditPath } from "../model/commerce-record-routes.js";
32
33
  /**
33
34
  * Commerce page resolver (AGL-292/298/418), relocated verbatim from the
34
35
  * tenant loader: /products/{slug} renders the host's designated PDP
@@ -107,7 +108,12 @@ import { readProductReviews } from "./reviews.js";
107
108
  // The head shares this page as the template's image, then the site
108
109
  // default, so their documents are read in the template's own batch
109
110
  // (AGL-2850).
111
+ const shareImage = productShareImage(product);
110
112
  const card = collectSocialImageFacts([
113
+ // Only when there is one: the list is the card's precedence.
114
+ ...shareImage ? [
115
+ shareImage
116
+ ] : [],
111
117
  (_templateRes_screen_seo = templateRes.screen.seo) == null ? void 0 : _templateRes_screen_seo.image,
112
118
  (_hostRes_host = hostRes.host) == null ? void 0 : (_hostRes_host_seo = _hostRes_host.seo) == null ? void 0 : _hostRes_host_seo.image
113
119
  ]);
@@ -169,7 +175,7 @@ import { readProductReviews } from "./reviews.js";
169
175
  // product with its own SEO title gets exactly that, and
170
176
  // one without gets "Blue Widget – Acme Store".
171
177
  displayName: product.name,
172
- seo: _extends({}, (_templateRes_screen_seo1 = templateRes.screen.seo) != null ? _templateRes_screen_seo1 : {}, {
178
+ seo: _extends({}, (_templateRes_screen_seo1 = templateRes.screen.seo) != null ? _templateRes_screen_seo1 : {}, shareCard(shareImage, product.name), {
173
179
  // Only when the PRODUCT authored one: inheriting the
174
180
  // template screen's title would give every product
175
181
  // page in the store the same `<title>`.
@@ -222,7 +228,12 @@ import { readProductReviews } from "./reviews.js";
222
228
  var _templateRes_screen_seo2, _hostRes_host_seo1, _hostRes_host1;
223
229
  // As on the PDP above: the template's image, then the site default
224
230
  // (AGL-2850).
231
+ const shareImage = shopCollection.imageUrl || undefined;
225
232
  const card = collectSocialImageFacts([
233
+ // Only when there is one: the list is the card's precedence.
234
+ ...shareImage ? [
235
+ shareImage
236
+ ] : [],
226
237
  (_templateRes_screen_seo2 = templateRes.screen.seo) == null ? void 0 : _templateRes_screen_seo2.image,
227
238
  (_hostRes_host1 = hostRes.host) == null ? void 0 : (_hostRes_host_seo1 = _hostRes_host1.seo) == null ? void 0 : _hostRes_host_seo1.image
228
239
  ]);
@@ -264,7 +275,7 @@ import { readProductReviews } from "./reviews.js";
264
275
  // collection has no SEO title field of its own, so the
265
276
  // template's must not stand in for one.
266
277
  displayName: shopCollection.name,
267
- seo: _extends({}, (_templateRes_screen_seo3 = templateRes.screen.seo) != null ? _templateRes_screen_seo3 : {}, {
278
+ seo: _extends({}, (_templateRes_screen_seo3 = templateRes.screen.seo) != null ? _templateRes_screen_seo3 : {}, shareCard(shareImage, shopCollection.name), {
268
279
  title: undefined,
269
280
  description: (_shopCollection_description1 = shopCollection.description) != null ? _shopCollection_description1 : undefined
270
281
  })
@@ -281,6 +292,53 @@ import { readProductReviews } from "./reviews.js";
281
292
  }
282
293
  return undefined;
283
294
  };
295
+ /**
296
+ * What the admin edit bar says on the pages the resolver above composes. They
297
+ * are in no routing map, so the bar called a product page "Unrouted page" with
298
+ * no edit link. It answers from the same reads the page is built from: the
299
+ * store's designated template (`pdpScreenId`, `collectionScreenId`), and for
300
+ * a product page the product itself, whose editor the bar links beside the
301
+ * template's Besigner, as it does for a blog post. A product the page would
302
+ * not render (not live, or not sold online) gets no answer, as it gets no
303
+ * page.
304
+ */ export const commerceEditContextResolver = async ({ hostId, path })=>{
305
+ const segments = path.split('/').filter(Boolean);
306
+ if (segments.length !== 2) return undefined;
307
+ const [section, slug] = segments;
308
+ if (section !== 'products' && section !== 'collections') return undefined;
309
+ const hostDocRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId);
310
+ const storeSettings = await hostDocRef.collection('settings').doc('store').get();
311
+ const screenField = (name)=>{
312
+ const value = storeSettings.get(name);
313
+ return typeof value === 'string' && value ? value : null;
314
+ };
315
+ if (section === 'products') {
316
+ const productSnapshot = await hostDocRef.collection('products').where('slug', '==', slug).limit(1).get();
317
+ const productDoc = productSnapshot.docs[0];
318
+ if (!productDoc || !CommerceModel.productListedOnline(productDoc.data())) {
319
+ return undefined;
320
+ }
321
+ return {
322
+ templateScreenId: screenField('pdpScreenId'),
323
+ collectionName: 'Products',
324
+ entry: true,
325
+ entryNoun: 'product',
326
+ recordEditPath: productEditPath(productDoc.id)
327
+ };
328
+ }
329
+ const collectionSnapshot = await hostDocRef.collection('collections').where('slug', '==', slug).limit(5).get();
330
+ const shopCollection = collectionSnapshot.docs.find((docSnapshot)=>hostCollectionKind(docSnapshot.data()) === 'catalog');
331
+ const templateScreenId = screenField('collectionScreenId');
332
+ // Without a template the page is not served (no built-in collection page).
333
+ if (!shopCollection || !templateScreenId) return undefined;
334
+ return {
335
+ templateScreenId,
336
+ collectionName: 'Store collections',
337
+ entry: true,
338
+ entryNoun: 'collection',
339
+ recordEditPath: null
340
+ };
341
+ };
284
342
  // What `{{product.price}}` says (AGL-3676) lives with the model now, so the
285
343
  // site's search can caption a product the same way without loading this page.
286
344
  export { productPriceText } from "../model/index.js";
@@ -388,8 +446,8 @@ const PRODUCT_PAGE_RELATED_NODE = 'pdp__related';
388
446
  }
389
447
  async function composeBuiltInProductPage(hostId, host, productId, product, rawReturns) {
390
448
  try {
391
- var _ref, _ref1, _ref2, _ref3;
392
- var _product_mediaUrls, _host_seo, _product_seo, _product_seo1;
449
+ var _ref, _ref1, _ref2;
450
+ var _host_seo, _product_seo, _product_seo1;
393
451
  const [layoutId, productReviews, reviewsOn] = await Promise.all([
394
452
  resolveBuiltInPageLayoutId({
395
453
  hostId,
@@ -408,8 +466,11 @@ async function composeBuiltInProductPage(hostId, host, productId, product, rawRe
408
466
  storeTakesReviews(hostId)
409
467
  ]);
410
468
  const returns = productReturnWindow(product, rawReturns);
469
+ const shareImage = productShareImage(product);
411
470
  const card = collectSocialImageFacts([
412
- (_ref = (_product_mediaUrls = product.mediaUrls) == null ? void 0 : _product_mediaUrls[0]) != null ? _ref : product.imageUrl,
471
+ ...shareImage ? [
472
+ shareImage
473
+ ] : [],
413
474
  host == null ? void 0 : (_host_seo = host.seo) == null ? void 0 : _host_seo.image
414
475
  ]);
415
476
  const nodes = await composeNodesWithChrome({
@@ -442,10 +503,10 @@ async function composeBuiltInProductPage(hostId, host, productId, product, rawRe
442
503
  screen: {
443
504
  data: {
444
505
  displayName: product.name,
445
- seo: {
446
- title: (_ref1 = (_product_seo = product.seo) == null ? void 0 : _product_seo.title) != null ? _ref1 : undefined,
447
- description: (_ref2 = (_ref3 = (_product_seo1 = product.seo) == null ? void 0 : _product_seo1.description) != null ? _ref3 : product.description) != null ? _ref2 : undefined
448
- }
506
+ seo: _extends({}, shareCard(shareImage, product.name), {
507
+ title: (_ref = (_product_seo = product.seo) == null ? void 0 : _product_seo.title) != null ? _ref : undefined,
508
+ description: (_ref1 = (_ref2 = (_product_seo1 = product.seo) == null ? void 0 : _product_seo1.description) != null ? _ref2 : product.description) != null ? _ref1 : undefined
509
+ })
449
510
  }
450
511
  }
451
512
  },
@@ -493,6 +554,36 @@ const ORDER_STATUS_NODE = 'order-status__block';
493
554
  }
494
555
  };
495
556
  }
557
+ /**
558
+ * The image a product page shares: the one picked in the product editor's
559
+ * "OG image" field (`seo.imageUrl`), else the product's first photo.
560
+ *
561
+ * Both product pages used to share the template's image, then the site
562
+ * default, so every product in a store shared one card and the editor's
563
+ * OG image was saved and never read. A product's own photo is the most
564
+ * specific card there is; the template's image stays the fallback for a
565
+ * product with no photo.
566
+ */ function productShareImage(product) {
567
+ var _product_seo, _product_mediaUrls;
568
+ return ((_product_seo = product.seo) == null ? void 0 : _product_seo.imageUrl) || ((_product_mediaUrls = product.mediaUrls) == null ? void 0 : _product_mediaUrls[0]) || product.imageUrl || undefined;
569
+ }
570
+ /**
571
+ * The page's own card fields for a routed product or collection image.
572
+ *
573
+ * The template's pixel pair and alt describe the template's image, not this
574
+ * one, so they are cleared beside it: a stale 1200x630 on a square product
575
+ * photo is a wrong claim, and no pair is an honest one. The alt names what
576
+ * the page is about. Nothing when there is no image, so the template's card
577
+ * stands.
578
+ */ function shareCard(image, name) {
579
+ if (!image) return {};
580
+ return {
581
+ image,
582
+ imageWidth: undefined,
583
+ imageHeight: undefined,
584
+ imageAlt: name || undefined
585
+ };
586
+ }
496
587
  async function composeOrderStatusPage(hostId, host) {
497
588
  try {
498
589
  const layoutId = await resolveBuiltInPageLayoutId({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/site-page-resolver.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SitePageResolver } from '@aglyn/aglyn/server'\nimport { hostCollectionKind } from '@aglyn/aglyn/server'\nimport composeScreenNodes, {\n composeNodesWithChrome,\n} from '@aglyn/tenant-runtime/compose-screen-nodes'\nimport { resolveBuiltInPageLayoutId } from '@aglyn/tenant-runtime/built-in-page-layout'\nimport * as Aglyn from '@aglyn/aglyn/server'\nimport { ORDER_STATUS_PATH } from './order-status-token'\nimport { ORDER_STATUS_COMPONENT_ID } from '../constants/order-status'\nimport { RETURN_REQUEST_COMPONENT_ID, RETURN_REQUEST_PATH } from '../constants/return-request'\nimport { QUOTE_PAGE_COMPONENT_ID, QUOTE_PAGE_PATH } from '../constants/quote-page'\nimport getScreen from '@aglyn/tenant-runtime/get-screen'\nimport { collectSocialImageFacts } from '@aglyn/tenant-runtime/social-image-facts'\nimport { firebaseAdmin, getOrgForHost } from '@aglyn/tenant-data-admin'\nimport * as CommerceModel from '../model'\nimport { productAsksUseDateAnywhere, toPublicProductDetail } from './product'\nimport { readStoreDay } from './store-day'\nimport { readProductReviews } from './reviews'\n\n/**\n * Commerce page resolver (AGL-292/298/418), relocated verbatim from the\n * tenant loader: /products/{slug} renders the host's designated PDP\n * template with product tokens, /collections/{slug} the collection\n * template — both compose server-side and return complete page props.\n * Runs only for paths that didn't match a published screen; returns\n * undefined for everything else so the loader falls through.\n */\nexport const commerceSitePageResolver: SitePageResolver = async ({\n hostId,\n host,\n path,\n}) => {\n const hostRes = { host }\n // Product detail routes (AGL-292): /products/{slug} renders the\n // host's designated PDP template screen (settings/store\n // `pdpScreenId`, AGL-295) with product tokens; the product-detail\n // block hydrates variants client-side from the same slug. Same\n // mechanism as entry-template screens below.\n const pdpSegments = path.split('/').filter(Boolean)\n // The guest order-status page (AGL-3610), at /order-status — reached only\n // when the site has no page of its own there. The site's header and footer\n // around the order-status block, which reads the signed `?o=&t=` link after\n // hydration, so this page holds no order and is safe to cache. UNLISTED, so\n // the head says noindex: it is a private page, not a landing page.\n if (pdpSegments.length === 1 && pdpSegments[0] === ORDER_STATUS_PATH) {\n return composeOrderStatusPage(hostId, host)\n }\n // The buyer's return form (AGL-3611), at /order-return, under the same\n // terms: no page of the site's own there, the order read after hydration\n // from the link's `?o=&t=` (or the member's session), UNLISTED.\n if (pdpSegments.length === 1 && pdpSegments[0] === RETURN_REQUEST_PATH) {\n return composeReturnRequestPage(hostId, host)\n }\n // The customer's quote page (AGL-4094), at /pay-quote, under the same\n // terms: no page of the site's own there, the quote read after hydration\n // from the pay link's `?q=&t=`, UNLISTED.\n if (pdpSegments.length === 1 && pdpSegments[0] === QUOTE_PAGE_PATH) {\n return composeQuotePage(hostId, host)\n }\n if (pdpSegments.length === 2 && pdpSegments[0] === 'products') {\n const adminFirestore = firebaseAdmin.app().firestore()\n const hostDocRef = adminFirestore.collection('hosts').doc(hostId)\n const [storeSettings, productSnapshot] = await Promise.all([\n hostDocRef.collection('settings').doc('store').get(),\n hostDocRef\n .collection('products')\n .where('slug', '==', pdpSegments[1])\n .limit(1)\n .get(),\n ])\n const pdpScreenId = storeSettings.get('pdpScreenId')\n const productRaw = productSnapshot.docs[0]?.data() as any\n // Live, active and sold online (AGL-4060): a product sold in person only\n // has no page here, designed or built in, and falls through to the 404.\n const listedOnline = CommerceModel.productListedOnline(productRaw)\n if (pdpScreenId && listedOnline) {\n const product = CommerceModel.liftLegacyProduct(productRaw)\n const templateRes = await getScreen({\n hostId,\n screenId: pdpScreenId,\n // A PDP template renders against a routed PRODUCT, never at an address\n // of its own, so it is served here and 404s everywhere else (AGL-1400).\n allowTemplate: true,\n })\n if (templateRes.screen) {\n const [minPrice, maxPrice] = CommerceModel.productPriceRange(product)\n // Best-effort: a reviews read that fails costs the page its rating\n // snippet, not the page.\n const productReviews = await readProductReviews(\n hostId,\n productSnapshot.docs[0].id,\n ).catch((error) => {\n console.error('product review aggregate failed', error)\n return { reviews: [], aggregate: { count: 0, average: 0 } }\n })\n // The head shares this page as the template's image, then the site\n // default, so their documents are read in the template's own batch\n // (AGL-2850).\n const card = collectSocialImageFacts([\n (templateRes.screen as any).seo?.image,\n hostRes.host?.seo?.image,\n ])\n const templateNodes = await composeScreenNodes({\n hostId,\n screenId: pdpScreenId,\n screen: templateRes.screen,\n socialImages: card.socialImages,\n // The template's host variables, and its layout's, fill in from\n // this site as they do on every other page (AGL-2883).\n host: hostRes.host,\n tokens: {\n 'product.name': product.name,\n 'product.description': product.description ?? '',\n 'product.price': CommerceModel.productPriceText(product, minPrice, maxPrice),\n 'product.image':\n product.mediaUrls?.[0] ?? product.imageUrl ?? '',\n 'product.slug': product.slug,\n },\n // Named as the product template it is if the page review holds it\n // (AGL-3374); without it the route has no page.\n page: {\n template: {\n role: 'entry',\n route: '/products/:slug',\n collectionName: 'Products',\n entryPath: `/products/${product.slug}`,\n fallback: 'not-found',\n },\n },\n })\n if (templateNodes) {\n return {\n props: JSON.parse(\n JSON.stringify({\n // The PDP block used to fetch this in an effect, so the\n // server rendered a skeleton and crawlers saw a product page\n // with no product in it (AGL-659). The product is already\n // loaded here — hand it down so it renders server-side.\n pageData: {\n commerce: {\n product: toPublicProductDetail(\n productSnapshot.docs[0].id,\n product,\n // The store's calendar, for a pass that asks for a day.\n { timeZone: await passDayTimeZone(hostId, hostRes.host, product) },\n ),\n // Rating aggregate (AGL-686): needed HERE because\n // `aggregateRating` belongs nested inside the Product\n // structured data, and that is emitted server-side.\n // The reviews block used to publish a free-standing\n // AggregateRating node, which schema.org ignores.\n ...(productReviews.aggregate.count\n ? { reviews: productReviews }\n : {}),\n },\n },\n data: {\n host: hostRes.host,\n screen: {\n data: {\n ...templateRes.screen,\n // The product NAMES this page; the template's own name\n // (\"Product detail\") describes none of the products it\n // renders. Kept distinct from the SEO title because the\n // head treats an authored title as verbatim and a name\n // as the side the site title joins (AGL-1341) — so a\n // product with its own SEO title gets exactly that, and\n // one without gets \"Blue Widget – Acme Store\".\n displayName: product.name,\n seo: {\n ...((templateRes.screen as any).seo ?? {}),\n // Only when the PRODUCT authored one: inheriting the\n // template screen's title would give every product\n // page in the store the same `<title>`.\n title: product.seo?.title ?? undefined,\n description:\n product.seo?.description ??\n product.description ??\n undefined,\n },\n },\n },\n },\n nodes: templateNodes,\n ...card.collected(),\n }),\n ),\n revalidate: 60,\n }\n }\n }\n }\n // No product template designated, or none that renders: the store's\n // built-in product page (AGL-3676), in the site's own header and footer,\n // rather than a 404 behind every card the product grid links. A store a\n // guided start built has no template of its own, and its grid links each\n // product here.\n if (listedOnline) {\n return composeBuiltInProductPage(\n hostId,\n host,\n productSnapshot.docs[0].id,\n CommerceModel.liftLegacyProduct(productRaw),\n storeSettings.get('returns'),\n )\n }\n }\n // Commerce collection routes (AGL-298): /collections/{slug} renders\n // the designated collection template with collection tokens; the\n // product-grid block derives the same slug from the URL.\n if (pdpSegments.length === 2 && pdpSegments[0] === 'collections') {\n const adminFirestore = firebaseAdmin.app().firestore()\n const hostDocRef = adminFirestore.collection('hosts').doc(hostId)\n const [storeSettings, collectionSnapshot] = await Promise.all([\n hostDocRef.collection('settings').doc('store').get(),\n hostDocRef\n .collection('collections')\n .where('slug', '==', pdpSegments[1])\n .limit(5)\n .get(),\n ])\n const collectionScreenId = storeSettings.get('collectionScreenId')\n // Content collections share this path and a slug is only unique within a\n // kind (AGL-954), so take the first CATALOG match rather than the first\n // doc — otherwise a blog with the same slug renders as a product page.\n const shopCollection = collectionSnapshot.docs\n .find((docSnapshot) => hostCollectionKind(docSnapshot.data()) === 'catalog')\n ?.data() as CommerceModel.HostCollection | undefined\n if (collectionScreenId && shopCollection) {\n const templateRes = await getScreen({\n hostId,\n screenId: collectionScreenId,\n allowTemplate: true,\n })\n if (templateRes.screen) {\n // As on the PDP above: the template's image, then the site default\n // (AGL-2850).\n const card = collectSocialImageFacts([\n (templateRes.screen as any).seo?.image,\n hostRes.host?.seo?.image,\n ])\n const templateNodes = await composeScreenNodes({\n hostId,\n screenId: collectionScreenId,\n screen: templateRes.screen,\n socialImages: card.socialImages,\n // As on the PDP above (AGL-2883).\n host: hostRes.host,\n tokens: {\n 'collection.name': shopCollection.name,\n 'collection.description': shopCollection.description ?? '',\n 'collection.image': shopCollection.imageUrl ?? '',\n 'collection.slug': shopCollection.slug,\n },\n // As on the PDP above (AGL-3374).\n page: {\n template: {\n role: 'entry',\n route: '/collections/:slug',\n collectionName: 'Store collections',\n entryPath: `/collections/${shopCollection.slug}`,\n fallback: 'not-found',\n },\n },\n })\n if (templateNodes) {\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host: hostRes.host,\n screen: {\n data: {\n ...templateRes.screen,\n // As on the PDP above: the catalog collection names the\n // page, and a name takes the site title after it while\n // an authored SEO title would not (AGL-1341). A shop\n // collection has no SEO title field of its own, so the\n // template's must not stand in for one.\n displayName: shopCollection.name,\n seo: {\n ...((templateRes.screen as any).seo ?? {}),\n title: undefined,\n description:\n shopCollection.description ?? undefined,\n },\n },\n },\n },\n nodes: templateNodes,\n ...card.collected(),\n }),\n ),\n revalidate: 60,\n }\n }\n }\n }\n }\n return undefined\n}\n\n// What `{{product.price}}` says (AGL-3676) lives with the model now, so the\n// site's search can caption a product the same way without loading this page.\nexport { productPriceText } from '../model'\n\nconst PRODUCT_PAGE_NODE = 'pdp__detail'\nconst PRODUCT_PAGE_REVIEWS_NODE = 'pdp__reviews'\nconst PRODUCT_PAGE_RELATED_NODE = 'pdp__related'\n\n/**\n * The store's built-in product page (AGL-3676), root first, for the layout's\n * slot: the product block for the routed slug — with its Details and\n * Shipping & returns folds under the description, as a designer theme's\n * product page has them — then the product's reviews where the store's plan\n * collects them, then the related products as a grid of photo cards.\n */\nexport function buildProductPageNodes(\n slug: string,\n options: { reviews?: boolean } = {},\n): Record<string, Aglyn.AglynNodeSchema> {\n const reviews = Boolean(options.reviews)\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['pdp__container'],\n } as Aglyn.AglynNodeSchema,\n pdp__container: {\n $id: 'pdp__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'lg', sx: { paddingTop: 6, paddingBottom: 10 } },\n nodes: [\n PRODUCT_PAGE_NODE,\n ...(reviews ? [PRODUCT_PAGE_REVIEWS_NODE] : []),\n PRODUCT_PAGE_RELATED_NODE,\n ],\n } as Aglyn.AglynNodeSchema,\n [PRODUCT_PAGE_NODE]: {\n $id: PRODUCT_PAGE_NODE,\n parentId: 'pdp__container',\n componentId: 'product-detail',\n pluginId: 'commerce',\n props: { slug, showDetails: true, showShipping: true },\n } as Aglyn.AglynNodeSchema,\n ...(reviews\n ? {\n [PRODUCT_PAGE_REVIEWS_NODE]: {\n $id: PRODUCT_PAGE_REVIEWS_NODE,\n parentId: 'pdp__container',\n componentId: 'product-reviews',\n pluginId: 'commerce',\n props: { heading: 'Reviews', sx: { marginTop: 8 } },\n } as Aglyn.AglynNodeSchema,\n }\n : {}),\n [PRODUCT_PAGE_RELATED_NODE]: {\n $id: PRODUCT_PAGE_RELATED_NODE,\n parentId: 'pdp__container',\n componentId: 'related-products',\n pluginId: 'commerce',\n props: {\n heading: 'You may also like',\n maxItems: 4,\n layout: 'grid',\n sx: { marginTop: 8 },\n },\n } as Aglyn.AglynNodeSchema,\n }\n}\n\n/**\n * The store's return window for this product, when the store takes returns of\n * its kind: the settings the return form enforces (`readReturnSettings`), so\n * the page never states a policy the store does not keep.\n */\nexport function productReturnWindow(\n product: Pick<CommerceModel.HostProduct, 'type'>,\n rawReturns: unknown,\n): { windowDays: number } | undefined {\n const settings = CommerceModel.readReturnSettings(rawReturns)\n if (!settings.enabled || settings.windowDays <= 0) return undefined\n if (!settings.eligibleTypes.includes(product.type ?? 'physical')) return undefined\n return { windowDays: settings.windowDays }\n}\n\n/** Whether the store's plan collects reviews; a failed read leaves them off. */\nasync function storeTakesReviews(hostId: string): Promise<boolean> {\n try {\n const org = await getOrgForHost(hostId)\n return Aglyn.checkEntitlement(org?.org as never, 'productReviews')\n } catch (error) {\n console.error('reviews entitlement read failed', error)\n return false\n }\n}\n\nasync function composeBuiltInProductPage(\n hostId: string,\n host: unknown,\n productId: string,\n product: ReturnType<typeof CommerceModel.liftLegacyProduct>,\n rawReturns?: unknown,\n) {\n try {\n const [layoutId, productReviews, reviewsOn] = await Promise.all([\n resolveBuiltInPageLayoutId({ hostId, host: host as never }),\n readProductReviews(hostId, productId).catch((error) => {\n console.error('product review aggregate failed', error)\n return { reviews: [], aggregate: { count: 0, average: 0 } }\n }),\n storeTakesReviews(hostId),\n ])\n const returns = productReturnWindow(product, rawReturns)\n const card = collectSocialImageFacts([\n product.mediaUrls?.[0] ?? product.imageUrl,\n (host as { seo?: { image?: string } } | null)?.seo?.image,\n ])\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildProductPageNodes(product.slug, { reviews: reviewsOn }),\n socialImages: card.socialImages,\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n // Seeded, so the product renders server-side and the head writes\n // its Product structured data, as on a template page (AGL-659).\n pageData: {\n commerce: {\n product: toPublicProductDetail(productId, product, {\n timeZone: await passDayTimeZone(hostId, host, product),\n }),\n ...(productReviews.aggregate.count ? { reviews: productReviews } : {}),\n // The Shipping & returns fold's return line, only when the\n // store takes returns of this product's kind.\n ...(returns ? { returns } : {}),\n },\n },\n data: {\n host,\n screen: {\n data: {\n displayName: product.name,\n seo: {\n title: product.seo?.title ?? undefined,\n description: product.seo?.description ?? product.description ?? undefined,\n },\n },\n },\n },\n nodes,\n ...card.collected(),\n }),\n ),\n revalidate: 60,\n }\n } catch (error) {\n console.error('built-in product page composition failed', error)\n return undefined\n }\n}\n\nconst ORDER_STATUS_NODE = 'order-status__block'\n\n/** The order-status page's node tree, root first, for the layout's slot. */\nexport function buildOrderStatusNodes(): Record<string, Aglyn.AglynNodeSchema> {\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['order-status__container'],\n } as Aglyn.AglynNodeSchema,\n 'order-status__container': {\n $id: 'order-status__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'md', sx: { paddingTop: 6, paddingBottom: 8 } },\n nodes: [ORDER_STATUS_NODE],\n } as Aglyn.AglynNodeSchema,\n [ORDER_STATUS_NODE]: {\n $id: ORDER_STATUS_NODE,\n parentId: 'order-status__container',\n componentId: ORDER_STATUS_COMPONENT_ID,\n pluginId: 'commerce',\n props: {},\n } as Aglyn.AglynNodeSchema,\n }\n}\n\nasync function composeOrderStatusPage(hostId: string, host: unknown) {\n try {\n const layoutId = await resolveBuiltInPageLayoutId({ hostId, host: host as never })\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildOrderStatusNodes(),\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host,\n screen: {\n data: {\n displayName: 'Order status',\n visibility: Aglyn.HostScreenVisibility.UNLISTED,\n },\n },\n },\n nodes,\n }),\n ),\n revalidate: 3600,\n }\n } catch (error) {\n console.error('order status page composition failed', error)\n return undefined\n }\n}\n\nconst RETURN_REQUEST_NODE = 'ret__block'\n\n/** The return form's node tree, root first, for the layout's slot. */\nexport function buildReturnRequestNodes(): Record<string, Aglyn.AglynNodeSchema> {\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['ret__container'],\n } as Aglyn.AglynNodeSchema,\n ret__container: {\n $id: 'ret__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'md', sx: { paddingTop: 6, paddingBottom: 8 } },\n nodes: [RETURN_REQUEST_NODE],\n } as Aglyn.AglynNodeSchema,\n [RETURN_REQUEST_NODE]: {\n $id: RETURN_REQUEST_NODE,\n parentId: 'ret__container',\n componentId: RETURN_REQUEST_COMPONENT_ID,\n pluginId: 'commerce',\n props: {},\n } as Aglyn.AglynNodeSchema,\n }\n}\n\nasync function composeReturnRequestPage(hostId: string, host: unknown) {\n try {\n const layoutId = await resolveBuiltInPageLayoutId({ hostId, host: host as never })\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildReturnRequestNodes(),\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host,\n screen: {\n data: {\n displayName: 'Request a return',\n visibility: Aglyn.HostScreenVisibility.UNLISTED,\n },\n },\n },\n nodes,\n }),\n ),\n revalidate: 3600,\n }\n } catch (error) {\n console.error('return request page composition failed', error)\n return undefined\n }\n}\n\nconst QUOTE_PAGE_NODE = 'quote-page__block'\n\n/** The quote page's node tree, root first, for the layout's slot. */\nexport function buildQuotePageNodes(): Record<string, Aglyn.AglynNodeSchema> {\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['quote-page__container'],\n } as Aglyn.AglynNodeSchema,\n 'quote-page__container': {\n $id: 'quote-page__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'md', sx: { paddingTop: 6, paddingBottom: 8 } },\n nodes: [QUOTE_PAGE_NODE],\n } as Aglyn.AglynNodeSchema,\n [QUOTE_PAGE_NODE]: {\n $id: QUOTE_PAGE_NODE,\n parentId: 'quote-page__container',\n componentId: QUOTE_PAGE_COMPONENT_ID,\n pluginId: 'commerce',\n props: {},\n } as Aglyn.AglynNodeSchema,\n }\n}\n\nasync function composeQuotePage(hostId: string, host: unknown) {\n try {\n const layoutId = await resolveBuiltInPageLayoutId({ hostId, host: host as never })\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildQuotePageNodes(),\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host,\n screen: {\n data: {\n // The page is the same for a quote's link and an invoice's (AGL-4099).\n displayName: 'Your quote or invoice',\n visibility: Aglyn.HostScreenVisibility.UNLISTED,\n },\n },\n },\n nodes,\n }),\n ),\n revalidate: 3600,\n }\n } catch (error) {\n console.error('quote page composition failed', error)\n return undefined\n }\n}\n\n/**\n * The store's time zone for a product page whose product asks for a use day\n * (AGL-4043), so the seeded page offers the same days the API's does; null\n * otherwise, without a read.\n */\nasync function passDayTimeZone(\n hostId: string,\n host: unknown,\n product: ReturnType<typeof CommerceModel.liftLegacyProduct>,\n): Promise<string | null> {\n if (!productAsksUseDateAnywhere(product)) return null\n const hostRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId)\n return (await readStoreDay(hostRef, { host: (host ?? null) as Record<string, unknown> | null })).timeZone\n}\n"],"names":["hostCollectionKind","composeScreenNodes","composeNodesWithChrome","resolveBuiltInPageLayoutId","Aglyn","ORDER_STATUS_PATH","ORDER_STATUS_COMPONENT_ID","RETURN_REQUEST_COMPONENT_ID","RETURN_REQUEST_PATH","QUOTE_PAGE_COMPONENT_ID","QUOTE_PAGE_PATH","getScreen","collectSocialImageFacts","firebaseAdmin","getOrgForHost","CommerceModel","productAsksUseDateAnywhere","toPublicProductDetail","readStoreDay","readProductReviews","commerceSitePageResolver","hostId","host","path","hostRes","pdpSegments","split","filter","Boolean","length","composeOrderStatusPage","composeReturnRequestPage","composeQuotePage","productSnapshot","adminFirestore","app","firestore","hostDocRef","collection","doc","storeSettings","Promise","all","get","where","limit","pdpScreenId","productRaw","docs","data","listedOnline","productListedOnline","product","liftLegacyProduct","templateRes","screenId","allowTemplate","screen","minPrice","maxPrice","productPriceRange","productReviews","id","catch","error","console","reviews","aggregate","count","average","card","seo","image","templateNodes","socialImages","tokens","name","description","productPriceText","mediaUrls","imageUrl","slug","page","template","role","route","collectionName","entryPath","fallback","props","JSON","parse","stringify","pageData","commerce","timeZone","passDayTimeZone","displayName","title","undefined","nodes","collected","revalidate","composeBuiltInProductPage","collectionSnapshot","collectionScreenId","shopCollection","find","docSnapshot","PRODUCT_PAGE_NODE","PRODUCT_PAGE_REVIEWS_NODE","PRODUCT_PAGE_RELATED_NODE","buildProductPageNodes","options","NODE_ROOT_ID","$id","componentId","pdp__container","parentId","pluginId","maxWidth","sx","paddingTop","paddingBottom","showDetails","showShipping","heading","marginTop","maxItems","layout","productReturnWindow","rawReturns","settings","readReturnSettings","enabled","windowDays","eligibleTypes","includes","type","storeTakesReviews","org","checkEntitlement","productId","layoutId","reviewsOn","returns","screenNodes","ORDER_STATUS_NODE","buildOrderStatusNodes","visibility","HostScreenVisibility","UNLISTED","RETURN_REQUEST_NODE","buildReturnRequestNodes","ret__container","QUOTE_PAGE_NODE","buildQuotePageNodes","hostRef"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,sBAAqB;AACxD,OAAOC,sBACLC,sBAAsB,QACjB,6CAA4C;AACnD,SAASC,0BAA0B,QAAQ,6CAA4C;AACvF,YAAYC,WAAW,sBAAqB;AAC5C,SAASC,iBAAiB,QAAQ,0BAAsB;AACxD,SAASC,yBAAyB,QAAQ,+BAA2B;AACrE,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,iCAA6B;AAC9F,SAASC,uBAAuB,EAAEC,eAAe,QAAQ,6BAAyB;AAClF,OAAOC,eAAe,mCAAkC;AACxD,SAASC,uBAAuB,QAAQ,2CAA0C;AAClF,SAASC,aAAa,EAAEC,aAAa,QAAQ,2BA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B,GAAG,GAAGC,SAAS,GAAGE,UAAU,CAAC,SAASC,GAAG,CAAClB;IACxE,OAAO,AAAC,CAAA,MAAMH,aAAa2I,SAAS;QAAEvI,IAAI,EAAGA,eAAAA,OAAQ;IAAwC,EAAC,EAAGyE,QAAQ;AAC3G"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/server/site-page-resolver.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SiteEditContextResolver, SitePageResolver } from '@aglyn/aglyn/server'\nimport { hostCollectionKind } from '@aglyn/aglyn/server'\nimport composeScreenNodes, {\n composeNodesWithChrome,\n} from '@aglyn/tenant-runtime/compose-screen-nodes'\nimport { resolveBuiltInPageLayoutId } from '@aglyn/tenant-runtime/built-in-page-layout'\nimport * as Aglyn from '@aglyn/aglyn/server'\nimport { ORDER_STATUS_PATH } from './order-status-token'\nimport { ORDER_STATUS_COMPONENT_ID } from '../constants/order-status'\nimport { RETURN_REQUEST_COMPONENT_ID, RETURN_REQUEST_PATH } from '../constants/return-request'\nimport { QUOTE_PAGE_COMPONENT_ID, QUOTE_PAGE_PATH } from '../constants/quote-page'\nimport getScreen from '@aglyn/tenant-runtime/get-screen'\nimport { collectSocialImageFacts } from '@aglyn/tenant-runtime/social-image-facts'\nimport { firebaseAdmin, getOrgForHost } from '@aglyn/tenant-data-admin'\nimport * as CommerceModel from '../model'\nimport { productAsksUseDateAnywhere, toPublicProductDetail } from './product'\nimport { readStoreDay } from './store-day'\nimport { readProductReviews } from './reviews'\nimport { productEditPath } from '../model/commerce-record-routes'\n\n/**\n * Commerce page resolver (AGL-292/298/418), relocated verbatim from the\n * tenant loader: /products/{slug} renders the host's designated PDP\n * template with product tokens, /collections/{slug} the collection\n * template — both compose server-side and return complete page props.\n * Runs only for paths that didn't match a published screen; returns\n * undefined for everything else so the loader falls through.\n */\nexport const commerceSitePageResolver: SitePageResolver = async ({\n hostId,\n host,\n path,\n}) => {\n const hostRes = { host }\n // Product detail routes (AGL-292): /products/{slug} renders the\n // host's designated PDP template screen (settings/store\n // `pdpScreenId`, AGL-295) with product tokens; the product-detail\n // block hydrates variants client-side from the same slug. Same\n // mechanism as entry-template screens below.\n const pdpSegments = path.split('/').filter(Boolean)\n // The guest order-status page (AGL-3610), at /order-status — reached only\n // when the site has no page of its own there. The site's header and footer\n // around the order-status block, which reads the signed `?o=&t=` link after\n // hydration, so this page holds no order and is safe to cache. UNLISTED, so\n // the head says noindex: it is a private page, not a landing page.\n if (pdpSegments.length === 1 && pdpSegments[0] === ORDER_STATUS_PATH) {\n return composeOrderStatusPage(hostId, host)\n }\n // The buyer's return form (AGL-3611), at /order-return, under the same\n // terms: no page of the site's own there, the order read after hydration\n // from the link's `?o=&t=` (or the member's session), UNLISTED.\n if (pdpSegments.length === 1 && pdpSegments[0] === RETURN_REQUEST_PATH) {\n return composeReturnRequestPage(hostId, host)\n }\n // The customer's quote page (AGL-4094), at /pay-quote, under the same\n // terms: no page of the site's own there, the quote read after hydration\n // from the pay link's `?q=&t=`, UNLISTED.\n if (pdpSegments.length === 1 && pdpSegments[0] === QUOTE_PAGE_PATH) {\n return composeQuotePage(hostId, host)\n }\n if (pdpSegments.length === 2 && pdpSegments[0] === 'products') {\n const adminFirestore = firebaseAdmin.app().firestore()\n const hostDocRef = adminFirestore.collection('hosts').doc(hostId)\n const [storeSettings, productSnapshot] = await Promise.all([\n hostDocRef.collection('settings').doc('store').get(),\n hostDocRef\n .collection('products')\n .where('slug', '==', pdpSegments[1])\n .limit(1)\n .get(),\n ])\n const pdpScreenId = storeSettings.get('pdpScreenId')\n const productRaw = productSnapshot.docs[0]?.data() as any\n // Live, active and sold online (AGL-4060): a product sold in person only\n // has no page here, designed or built in, and falls through to the 404.\n const listedOnline = CommerceModel.productListedOnline(productRaw)\n if (pdpScreenId && listedOnline) {\n const product = CommerceModel.liftLegacyProduct(productRaw)\n const templateRes = await getScreen({\n hostId,\n screenId: pdpScreenId,\n // A PDP template renders against a routed PRODUCT, never at an address\n // of its own, so it is served here and 404s everywhere else (AGL-1400).\n allowTemplate: true,\n })\n if (templateRes.screen) {\n const [minPrice, maxPrice] = CommerceModel.productPriceRange(product)\n // Best-effort: a reviews read that fails costs the page its rating\n // snippet, not the page.\n const productReviews = await readProductReviews(\n hostId,\n productSnapshot.docs[0].id,\n ).catch((error) => {\n console.error('product review aggregate failed', error)\n return { reviews: [], aggregate: { count: 0, average: 0 } }\n })\n // The head shares this page as the template's image, then the site\n // default, so their documents are read in the template's own batch\n // (AGL-2850).\n const shareImage = productShareImage(product)\n const card = collectSocialImageFacts([\n // Only when there is one: the list is the card's precedence.\n ...(shareImage ? [shareImage] : []),\n (templateRes.screen as any).seo?.image,\n hostRes.host?.seo?.image,\n ])\n const templateNodes = await composeScreenNodes({\n hostId,\n screenId: pdpScreenId,\n screen: templateRes.screen,\n socialImages: card.socialImages,\n // The template's host variables, and its layout's, fill in from\n // this site as they do on every other page (AGL-2883).\n host: hostRes.host,\n tokens: {\n 'product.name': product.name,\n 'product.description': product.description ?? '',\n 'product.price': CommerceModel.productPriceText(product, minPrice, maxPrice),\n 'product.image':\n product.mediaUrls?.[0] ?? product.imageUrl ?? '',\n 'product.slug': product.slug,\n },\n // Named as the product template it is if the page review holds it\n // (AGL-3374); without it the route has no page.\n page: {\n template: {\n role: 'entry',\n route: '/products/:slug',\n collectionName: 'Products',\n entryPath: `/products/${product.slug}`,\n fallback: 'not-found',\n },\n },\n })\n if (templateNodes) {\n return {\n props: JSON.parse(\n JSON.stringify({\n // The PDP block used to fetch this in an effect, so the\n // server rendered a skeleton and crawlers saw a product page\n // with no product in it (AGL-659). The product is already\n // loaded here — hand it down so it renders server-side.\n pageData: {\n commerce: {\n product: toPublicProductDetail(\n productSnapshot.docs[0].id,\n product,\n // The store's calendar, for a pass that asks for a day.\n { timeZone: await passDayTimeZone(hostId, hostRes.host, product) },\n ),\n // Rating aggregate (AGL-686): needed HERE because\n // `aggregateRating` belongs nested inside the Product\n // structured data, and that is emitted server-side.\n // The reviews block used to publish a free-standing\n // AggregateRating node, which schema.org ignores.\n ...(productReviews.aggregate.count\n ? { reviews: productReviews }\n : {}),\n },\n },\n data: {\n host: hostRes.host,\n screen: {\n data: {\n ...templateRes.screen,\n // The product NAMES this page; the template's own name\n // (\"Product detail\") describes none of the products it\n // renders. Kept distinct from the SEO title because the\n // head treats an authored title as verbatim and a name\n // as the side the site title joins (AGL-1341) — so a\n // product with its own SEO title gets exactly that, and\n // one without gets \"Blue Widget – Acme Store\".\n displayName: product.name,\n seo: {\n ...((templateRes.screen as any).seo ?? {}),\n ...shareCard(shareImage, product.name),\n // Only when the PRODUCT authored one: inheriting the\n // template screen's title would give every product\n // page in the store the same `<title>`.\n title: product.seo?.title ?? undefined,\n description:\n product.seo?.description ??\n product.description ??\n undefined,\n },\n },\n },\n },\n nodes: templateNodes,\n ...card.collected(),\n }),\n ),\n revalidate: 60,\n }\n }\n }\n }\n // No product template designated, or none that renders: the store's\n // built-in product page (AGL-3676), in the site's own header and footer,\n // rather than a 404 behind every card the product grid links. A store a\n // guided start built has no template of its own, and its grid links each\n // product here.\n if (listedOnline) {\n return composeBuiltInProductPage(\n hostId,\n host,\n productSnapshot.docs[0].id,\n CommerceModel.liftLegacyProduct(productRaw),\n storeSettings.get('returns'),\n )\n }\n }\n // Commerce collection routes (AGL-298): /collections/{slug} renders\n // the designated collection template with collection tokens; the\n // product-grid block derives the same slug from the URL.\n if (pdpSegments.length === 2 && pdpSegments[0] === 'collections') {\n const adminFirestore = firebaseAdmin.app().firestore()\n const hostDocRef = adminFirestore.collection('hosts').doc(hostId)\n const [storeSettings, collectionSnapshot] = await Promise.all([\n hostDocRef.collection('settings').doc('store').get(),\n hostDocRef\n .collection('collections')\n .where('slug', '==', pdpSegments[1])\n .limit(5)\n .get(),\n ])\n const collectionScreenId = storeSettings.get('collectionScreenId')\n // Content collections share this path and a slug is only unique within a\n // kind (AGL-954), so take the first CATALOG match rather than the first\n // doc — otherwise a blog with the same slug renders as a product page.\n const shopCollection = collectionSnapshot.docs\n .find((docSnapshot) => hostCollectionKind(docSnapshot.data()) === 'catalog')\n ?.data() as CommerceModel.HostCollection | undefined\n if (collectionScreenId && shopCollection) {\n const templateRes = await getScreen({\n hostId,\n screenId: collectionScreenId,\n allowTemplate: true,\n })\n if (templateRes.screen) {\n // As on the PDP above: the template's image, then the site default\n // (AGL-2850).\n const shareImage = shopCollection.imageUrl || undefined\n const card = collectSocialImageFacts([\n // Only when there is one: the list is the card's precedence.\n ...(shareImage ? [shareImage] : []),\n (templateRes.screen as any).seo?.image,\n hostRes.host?.seo?.image,\n ])\n const templateNodes = await composeScreenNodes({\n hostId,\n screenId: collectionScreenId,\n screen: templateRes.screen,\n socialImages: card.socialImages,\n // As on the PDP above (AGL-2883).\n host: hostRes.host,\n tokens: {\n 'collection.name': shopCollection.name,\n 'collection.description': shopCollection.description ?? '',\n 'collection.image': shopCollection.imageUrl ?? '',\n 'collection.slug': shopCollection.slug,\n },\n // As on the PDP above (AGL-3374).\n page: {\n template: {\n role: 'entry',\n route: '/collections/:slug',\n collectionName: 'Store collections',\n entryPath: `/collections/${shopCollection.slug}`,\n fallback: 'not-found',\n },\n },\n })\n if (templateNodes) {\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host: hostRes.host,\n screen: {\n data: {\n ...templateRes.screen,\n // As on the PDP above: the catalog collection names the\n // page, and a name takes the site title after it while\n // an authored SEO title would not (AGL-1341). A shop\n // collection has no SEO title field of its own, so the\n // template's must not stand in for one.\n displayName: shopCollection.name,\n seo: {\n ...((templateRes.screen as any).seo ?? {}),\n ...shareCard(shareImage, shopCollection.name),\n title: undefined,\n description:\n shopCollection.description ?? undefined,\n },\n },\n },\n },\n nodes: templateNodes,\n ...card.collected(),\n }),\n ),\n revalidate: 60,\n }\n }\n }\n }\n }\n return undefined\n}\n\n/**\n * What the admin edit bar says on the pages the resolver above composes. They\n * are in no routing map, so the bar called a product page \"Unrouted page\" with\n * no edit link. It answers from the same reads the page is built from: the\n * store's designated template (`pdpScreenId`, `collectionScreenId`), and for\n * a product page the product itself, whose editor the bar links beside the\n * template's Besigner, as it does for a blog post. A product the page would\n * not render (not live, or not sold online) gets no answer, as it gets no\n * page.\n */\nexport const commerceEditContextResolver: SiteEditContextResolver = async ({\n hostId,\n path,\n}) => {\n const segments = path.split('/').filter(Boolean)\n if (segments.length !== 2) return undefined\n const [section, slug] = segments\n if (section !== 'products' && section !== 'collections') return undefined\n const hostDocRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId)\n const storeSettings = await hostDocRef.collection('settings').doc('store').get()\n const screenField = (name: string) => {\n const value = storeSettings.get(name)\n return typeof value === 'string' && value ? value : null\n }\n if (section === 'products') {\n const productSnapshot = await hostDocRef\n .collection('products')\n .where('slug', '==', slug)\n .limit(1)\n .get()\n const productDoc = productSnapshot.docs[0]\n if (!productDoc || !CommerceModel.productListedOnline(productDoc.data() as any)) {\n return undefined\n }\n return {\n templateScreenId: screenField('pdpScreenId'),\n collectionName: 'Products',\n entry: true,\n entryNoun: 'product',\n recordEditPath: productEditPath(productDoc.id),\n }\n }\n const collectionSnapshot = await hostDocRef\n .collection('collections')\n .where('slug', '==', slug)\n .limit(5)\n .get()\n const shopCollection = collectionSnapshot.docs.find(\n (docSnapshot) => hostCollectionKind(docSnapshot.data()) === 'catalog',\n )\n const templateScreenId = screenField('collectionScreenId')\n // Without a template the page is not served (no built-in collection page).\n if (!shopCollection || !templateScreenId) return undefined\n return {\n templateScreenId,\n collectionName: 'Store collections',\n entry: true,\n entryNoun: 'collection',\n recordEditPath: null,\n }\n}\n\n// What `{{product.price}}` says (AGL-3676) lives with the model now, so the\n// site's search can caption a product the same way without loading this page.\nexport { productPriceText } from '../model'\n\nconst PRODUCT_PAGE_NODE = 'pdp__detail'\nconst PRODUCT_PAGE_REVIEWS_NODE = 'pdp__reviews'\nconst PRODUCT_PAGE_RELATED_NODE = 'pdp__related'\n\n/**\n * The store's built-in product page (AGL-3676), root first, for the layout's\n * slot: the product block for the routed slug — with its Details and\n * Shipping & returns folds under the description, as a designer theme's\n * product page has them — then the product's reviews where the store's plan\n * collects them, then the related products as a grid of photo cards.\n */\nexport function buildProductPageNodes(\n slug: string,\n options: { reviews?: boolean } = {},\n): Record<string, Aglyn.AglynNodeSchema> {\n const reviews = Boolean(options.reviews)\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['pdp__container'],\n } as Aglyn.AglynNodeSchema,\n pdp__container: {\n $id: 'pdp__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'lg', sx: { paddingTop: 6, paddingBottom: 10 } },\n nodes: [\n PRODUCT_PAGE_NODE,\n ...(reviews ? [PRODUCT_PAGE_REVIEWS_NODE] : []),\n PRODUCT_PAGE_RELATED_NODE,\n ],\n } as Aglyn.AglynNodeSchema,\n [PRODUCT_PAGE_NODE]: {\n $id: PRODUCT_PAGE_NODE,\n parentId: 'pdp__container',\n componentId: 'product-detail',\n pluginId: 'commerce',\n props: { slug, showDetails: true, showShipping: true },\n } as Aglyn.AglynNodeSchema,\n ...(reviews\n ? {\n [PRODUCT_PAGE_REVIEWS_NODE]: {\n $id: PRODUCT_PAGE_REVIEWS_NODE,\n parentId: 'pdp__container',\n componentId: 'product-reviews',\n pluginId: 'commerce',\n props: { heading: 'Reviews', sx: { marginTop: 8 } },\n } as Aglyn.AglynNodeSchema,\n }\n : {}),\n [PRODUCT_PAGE_RELATED_NODE]: {\n $id: PRODUCT_PAGE_RELATED_NODE,\n parentId: 'pdp__container',\n componentId: 'related-products',\n pluginId: 'commerce',\n props: {\n heading: 'You may also like',\n maxItems: 4,\n layout: 'grid',\n sx: { marginTop: 8 },\n },\n } as Aglyn.AglynNodeSchema,\n }\n}\n\n/**\n * The store's return window for this product, when the store takes returns of\n * its kind: the settings the return form enforces (`readReturnSettings`), so\n * the page never states a policy the store does not keep.\n */\nexport function productReturnWindow(\n product: Pick<CommerceModel.HostProduct, 'type'>,\n rawReturns: unknown,\n): { windowDays: number } | undefined {\n const settings = CommerceModel.readReturnSettings(rawReturns)\n if (!settings.enabled || settings.windowDays <= 0) return undefined\n if (!settings.eligibleTypes.includes(product.type ?? 'physical')) return undefined\n return { windowDays: settings.windowDays }\n}\n\n/** Whether the store's plan collects reviews; a failed read leaves them off. */\nasync function storeTakesReviews(hostId: string): Promise<boolean> {\n try {\n const org = await getOrgForHost(hostId)\n return Aglyn.checkEntitlement(org?.org as never, 'productReviews')\n } catch (error) {\n console.error('reviews entitlement read failed', error)\n return false\n }\n}\n\nasync function composeBuiltInProductPage(\n hostId: string,\n host: unknown,\n productId: string,\n product: ReturnType<typeof CommerceModel.liftLegacyProduct>,\n rawReturns?: unknown,\n) {\n try {\n const [layoutId, productReviews, reviewsOn] = await Promise.all([\n resolveBuiltInPageLayoutId({ hostId, host: host as never }),\n readProductReviews(hostId, productId).catch((error) => {\n console.error('product review aggregate failed', error)\n return { reviews: [], aggregate: { count: 0, average: 0 } }\n }),\n storeTakesReviews(hostId),\n ])\n const returns = productReturnWindow(product, rawReturns)\n const shareImage = productShareImage(product)\n const card = collectSocialImageFacts([\n ...(shareImage ? [shareImage] : []),\n (host as { seo?: { image?: string } } | null)?.seo?.image,\n ])\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildProductPageNodes(product.slug, { reviews: reviewsOn }),\n socialImages: card.socialImages,\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n // Seeded, so the product renders server-side and the head writes\n // its Product structured data, as on a template page (AGL-659).\n pageData: {\n commerce: {\n product: toPublicProductDetail(productId, product, {\n timeZone: await passDayTimeZone(hostId, host, product),\n }),\n ...(productReviews.aggregate.count ? { reviews: productReviews } : {}),\n // The Shipping & returns fold's return line, only when the\n // store takes returns of this product's kind.\n ...(returns ? { returns } : {}),\n },\n },\n data: {\n host,\n screen: {\n data: {\n displayName: product.name,\n seo: {\n ...shareCard(shareImage, product.name),\n title: product.seo?.title ?? undefined,\n description: product.seo?.description ?? product.description ?? undefined,\n },\n },\n },\n },\n nodes,\n ...card.collected(),\n }),\n ),\n revalidate: 60,\n }\n } catch (error) {\n console.error('built-in product page composition failed', error)\n return undefined\n }\n}\n\nconst ORDER_STATUS_NODE = 'order-status__block'\n\n/** The order-status page's node tree, root first, for the layout's slot. */\nexport function buildOrderStatusNodes(): Record<string, Aglyn.AglynNodeSchema> {\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['order-status__container'],\n } as Aglyn.AglynNodeSchema,\n 'order-status__container': {\n $id: 'order-status__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'md', sx: { paddingTop: 6, paddingBottom: 8 } },\n nodes: [ORDER_STATUS_NODE],\n } as Aglyn.AglynNodeSchema,\n [ORDER_STATUS_NODE]: {\n $id: ORDER_STATUS_NODE,\n parentId: 'order-status__container',\n componentId: ORDER_STATUS_COMPONENT_ID,\n pluginId: 'commerce',\n props: {},\n } as Aglyn.AglynNodeSchema,\n }\n}\n\n/**\n * The image a product page shares: the one picked in the product editor's\n * \"OG image\" field (`seo.imageUrl`), else the product's first photo.\n *\n * Both product pages used to share the template's image, then the site\n * default, so every product in a store shared one card and the editor's\n * OG image was saved and never read. A product's own photo is the most\n * specific card there is; the template's image stays the fallback for a\n * product with no photo.\n */\nfunction productShareImage(product: CommerceModel.HostProduct): string | undefined {\n return product.seo?.imageUrl || product.mediaUrls?.[0] || product.imageUrl || undefined\n}\n\n/**\n * The page's own card fields for a routed product or collection image.\n *\n * The template's pixel pair and alt describe the template's image, not this\n * one, so they are cleared beside it: a stale 1200x630 on a square product\n * photo is a wrong claim, and no pair is an honest one. The alt names what\n * the page is about. Nothing when there is no image, so the template's card\n * stands.\n */\nfunction shareCard(image: string | undefined, name: string | undefined) {\n if (!image) return {}\n return {\n image,\n imageWidth: undefined,\n imageHeight: undefined,\n imageAlt: name || undefined,\n }\n}\n\nasync function composeOrderStatusPage(hostId: string, host: unknown) {\n try {\n const layoutId = await resolveBuiltInPageLayoutId({ hostId, host: host as never })\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildOrderStatusNodes(),\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host,\n screen: {\n data: {\n displayName: 'Order status',\n visibility: Aglyn.HostScreenVisibility.UNLISTED,\n },\n },\n },\n nodes,\n }),\n ),\n revalidate: 3600,\n }\n } catch (error) {\n console.error('order status page composition failed', error)\n return undefined\n }\n}\n\nconst RETURN_REQUEST_NODE = 'ret__block'\n\n/** The return form's node tree, root first, for the layout's slot. */\nexport function buildReturnRequestNodes(): Record<string, Aglyn.AglynNodeSchema> {\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['ret__container'],\n } as Aglyn.AglynNodeSchema,\n ret__container: {\n $id: 'ret__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'md', sx: { paddingTop: 6, paddingBottom: 8 } },\n nodes: [RETURN_REQUEST_NODE],\n } as Aglyn.AglynNodeSchema,\n [RETURN_REQUEST_NODE]: {\n $id: RETURN_REQUEST_NODE,\n parentId: 'ret__container',\n componentId: RETURN_REQUEST_COMPONENT_ID,\n pluginId: 'commerce',\n props: {},\n } as Aglyn.AglynNodeSchema,\n }\n}\n\nasync function composeReturnRequestPage(hostId: string, host: unknown) {\n try {\n const layoutId = await resolveBuiltInPageLayoutId({ hostId, host: host as never })\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildReturnRequestNodes(),\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host,\n screen: {\n data: {\n displayName: 'Request a return',\n visibility: Aglyn.HostScreenVisibility.UNLISTED,\n },\n },\n },\n nodes,\n }),\n ),\n revalidate: 3600,\n }\n } catch (error) {\n console.error('return request page composition failed', error)\n return undefined\n }\n}\n\nconst QUOTE_PAGE_NODE = 'quote-page__block'\n\n/** The quote page's node tree, root first, for the layout's slot. */\nexport function buildQuotePageNodes(): Record<string, Aglyn.AglynNodeSchema> {\n return {\n [Aglyn.NODE_ROOT_ID]: {\n $id: Aglyn.NODE_ROOT_ID,\n componentId: 'div',\n nodes: ['quote-page__container'],\n } as Aglyn.AglynNodeSchema,\n 'quote-page__container': {\n $id: 'quote-page__container',\n parentId: Aglyn.NODE_ROOT_ID,\n componentId: 'muiContainer',\n pluginId: 'mui',\n props: { maxWidth: 'md', sx: { paddingTop: 6, paddingBottom: 8 } },\n nodes: [QUOTE_PAGE_NODE],\n } as Aglyn.AglynNodeSchema,\n [QUOTE_PAGE_NODE]: {\n $id: QUOTE_PAGE_NODE,\n parentId: 'quote-page__container',\n componentId: QUOTE_PAGE_COMPONENT_ID,\n pluginId: 'commerce',\n props: {},\n } as Aglyn.AglynNodeSchema,\n }\n}\n\nasync function composeQuotePage(hostId: string, host: unknown) {\n try {\n const layoutId = await resolveBuiltInPageLayoutId({ hostId, host: host as never })\n const nodes = await composeNodesWithChrome({\n hostId,\n layoutId,\n screenNodes: buildQuotePageNodes(),\n host: host as Aglyn.HostTokenSource,\n })\n if (!nodes) return undefined\n return {\n props: JSON.parse(\n JSON.stringify({\n data: {\n host,\n screen: {\n data: {\n // The page is the same for a quote's link and an invoice's (AGL-4099).\n displayName: 'Your quote or invoice',\n visibility: Aglyn.HostScreenVisibility.UNLISTED,\n },\n },\n },\n nodes,\n }),\n ),\n revalidate: 3600,\n }\n } catch (error) {\n console.error('quote page composition failed', error)\n return undefined\n }\n}\n\n/**\n * The store's time zone for a product page whose product asks for a use day\n * (AGL-4043), so the seeded page offers the same days the API's does; null\n * otherwise, without a read.\n */\nasync function passDayTimeZone(\n hostId: string,\n host: unknown,\n product: ReturnType<typeof CommerceModel.liftLegacyProduct>,\n): Promise<string | null> {\n if (!productAsksUseDateAnywhere(product)) return null\n const hostRef = firebaseAdmin.app().firestore().collection('hosts').doc(hostId)\n return (await readStoreDay(hostRef, { host: (host ?? null) as Record<string, unknown> | null })).timeZone\n}\n"],"names":["hostCollectionKind","composeScreenNodes","composeNodesWithChrome","resolveBuiltInPageLayoutId","Aglyn","ORDER_STATUS_PATH","ORDER_STATUS_COMPONENT_ID","RETURN_REQUEST_COMPONENT_ID","RETURN_REQUEST_PATH","QUOTE_PAGE_COMPONENT_ID","QUOTE_PAGE_PATH","getScreen","collectSocialImageFacts","firebaseAdmin","getOrgForHost","CommerceModel","productAsksUseDateAnywhere","toPublicProductDetail","readStoreDay","readProductReviews","productEditPath","commerceSitePageResolver","hostId","host","path","hostRes","pdpSegments","split","filter","Boolean","length","composeOrderStatusPage","composeReturnRequestPage","composeQuotePage","productSnapshot","adminFirestore","app","firestore","hostDocRef","collection","doc","storeSettings","Promise","all","get","where","limit","pdpScreenId","productRaw","docs","data","listedOnline","productListedOnline","product","liftLegacyProduct","templateRes","screenId","allowTemplate","screen","minPrice","maxPrice","productPriceRange","productReviews","id","catch","error","console","reviews","aggregate","count","average","shareImage","productShareImage","card","seo","image","templateNodes","socialImages","tokens","name","description","productPriceText","mediaUrls","imageUrl","slug","page","template","role","route","collectionName","entryPath","fallback","props","JSON","parse","stringify","pageData","commerce","timeZone","passDayTimeZone","displayName","shareCard","title","undefined","nodes","collected","revalidate","composeBuiltInProductPage","collectionSnapshot","collectionScreenId","shopCollection","find","docSnapshot","commerceEditContextResolver","segments","section","screenField","value","productDoc","templateScreenId","entry","entryNoun","recordEditPath","PRODUCT_PAGE_NODE","PRODUCT_PAGE_REVIEWS_NODE","PRODUCT_PAGE_RELATED_NODE","buildProductPageNodes","options","NODE_ROOT_ID","$id","componentId","pdp__container","parentId","pluginId","maxWidth","sx","paddingTop","paddingBottom","showDetails","showShipping","heading","marginTop","maxItems","layout","productReturnWindow","rawReturns","settings","readReturnSettings","enabled","windowDays","eligibleTypes","includes","type","storeTakesReviews","org","checkEntitlement","productId","layoutId","reviewsOn","returns","screenNodes","ORDER_STATUS_NODE","buildOrderStatusNodes","imageWidth","imageHeight","imageAlt","visibility","HostScreenVisibility","UNLISTED","RETURN_REQUEST_NODE","buildReturnRequestNodes","ret__container","QUOTE_PAGE_NODE","buildQuotePageNodes","hostRef"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SAASA,kBAAkB,QAAQ,sBAAqB;AACxD,OAAOC,sBACLC,sBAAsB,QACjB,6CAA4C;AACnD,SAASC,0BAA0B,QAAQ,6CAA4C;AACvF,YAAYC,WAAW,sBAAqB;AAC5C,SAASC,iBAAiB,QAAQ,0BAAsB;AACxD,SAASC,yBAAyB,QAAQ,+BAA2B;AACrE,SAASC,2BAA2B,EAAEC,mBAAmB,QAAQ,iCAA6B;AAC9F,SAASC,uBAAuB,EAAEC,eAAe,QAAQ,6BAAyB;AAClF,OAAOC,eAAe,mCAAkC;AACxD,SAASC,uBAAuB,QAAQ,2CAA0C;AAClF,SAASC,aAAa,EAAEC,aAAa,QAAQ,2BAA0B;AACvE,YAAYC,mBAAmB,oBAAU;AACzC,SAASC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAW;AAC7E,SAASC,YAAY,QAAQ,iBAAa;AAC1C,SAASC,kBAAkB,QAAQ,eAAW;AAC9C,SAASC,eAAe,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;YACb4H,UAAU;YACVzC,OAAO,CAAC;QACV;IACF;AACF;AAEA,eAAe3D,iBAAiBX,MAAc,EAAEC,IAAa;IAC3D,IAAI;QACF,MAAMsI,WAAW,MAAM1J,2BAA2B;YAAEmB;YAAQC,MAAMA;QAAc;QAChF,MAAMiF,QAAQ,MAAMtG,uBAAuB;YACzCoB;YACAuI;YACAG,aAAaa;YACbtJ,MAAMA;QACR;QACA,IAAI,CAACiF,OAAO,OAAOD;QACnB,OAAO;YACLX,OAAOC,KAAKC,KAAK,CACfD,KAAKE,SAAS,CAAC;gBACb7C,MAAM;oBACJ3B;oBACAmC,QAAQ;wBACNR,MAAM;4BACJ,uEAAuE;4BACvEkD,aAAa;4BACbkE,YAAYlK,MAAMmK,oBAAoB,CAACC,QAAQ;wBACjD;oBACF;gBACF;gBACAhE;YACF;YAEFE,YAAY;QACd;IACF,EAAE,OAAOzC,OAAO;QACdC,QAAQD,KAAK,CAAC,iCAAiCA;QAC/C,OAAOsC;IACT;AACF;AAEA;;;;CAIC,GACD,eAAeJ,gBACb7E,MAAc,EACdC,IAAa,EACb8B,OAA2D;IAE3D,IAAI,CAACrC,2BAA2BqC,UAAU,OAAO;IACjD,MAAMyH,UAAUjK,cAAcuB,GAAG,GAAGC,SAAS,GAAGE,UAAU,CAAC,SAASC,GAAG,CAAClB;IACxE,OAAO,AAAC,CAAA,MAAMJ,aAAa4J,SAAS;QAAEvJ,IAAI,EAAGA,eAAAA,OAAQ;IAAwC,EAAC,EAAG2E,QAAQ;AAC3G"}
package/src/lib/server.js CHANGED
@@ -20,7 +20,7 @@
20
20
  * pulls in firebase-admin + Stripe, so it is NOT re-exported from the client
21
21
  * barrel — apps import `@aglyn/plugins-commerce/server` only from their
22
22
  * (server-only) API dispatcher registration.
23
- */ import { registerBillingWebhookHandler, registerPluginApiRoute, registerPluginJob, registerSitePageEnricher, registerSitePageResolver, registerPluginPermissions, registerPluginConfigSchema } from "@aglyn/aglyn/server";
23
+ */ import { registerBillingWebhookHandler, registerPluginApiRoute, registerPluginJob, registerSitePageEnricher, registerSiteEditContextResolver, registerSitePageResolver, registerPluginPermissions, registerPluginConfigSchema } from "@aglyn/aglyn/server";
24
24
  import { isEmailConfigured } from "@aglyn/shared-util-email";
25
25
  import { firebaseAdmin } from "@aglyn/tenant-data-admin";
26
26
  import { BUNDLE_ID } from "./constants/bundle-common.js";
@@ -42,7 +42,7 @@ import { registerOrderFigureReaders } from "./server/order-figures.js";
42
42
  import { COMMERCE_PERMISSIONS } from "./model/plugin-permissions.js";
43
43
  import { COMMERCE_CONFIG_SCHEMA } from "./plugin-config.js";
44
44
  import { commerceSitePageEnricher } from "./server/site-page-enricher.js";
45
- import { commerceSitePageResolver } from "./server/site-page-resolver.js";
45
+ import { commerceEditContextResolver, commerceSitePageResolver } from "./server/site-page-resolver.js";
46
46
  import { cartCheckoutHandler } from "./server/cart-checkout.js";
47
47
  import { cartHandler } from "./server/cart.js";
48
48
  import { cartExtrasHandler } from "./server/checkout-extras.js";
@@ -366,6 +366,8 @@ registerPluginJob({
366
366
  registerPluginConfigSchema(COMMERCE_CONFIG_SCHEMA);
367
367
  // PDP/PLP template pages (AGL-418): /products/* + /collections/*.
368
368
  registerSitePageResolver(commerceSitePageResolver);
369
+ // What the admin edit bar names those pages, and where it edits them.
370
+ registerSiteEditContextResolver(commerceEditContextResolver);
369
371
  // Seeds product grids on ordinary screens (AGL-659) — the resolver above
370
372
  // only covers /products/* and /collections/*, so /products itself, and any
371
373
  // designed page with a grid on it, needed this to render server-side.