@wix/web5-core 1.63.29 → 1.63.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/entity/defaultExtractor.js +2 -1
- package/dist/cjs/entity/defaultExtractor.js.map +1 -1
- package/dist/cjs/entity/enrichEntitiesFromPayload.js +4 -2
- package/dist/cjs/entity/enrichEntitiesFromPayload.js.map +1 -1
- package/dist/cjs/entity/entityFamily.js +27 -0
- package/dist/cjs/entity/entityFamily.js.map +1 -1
- package/dist/cjs/entity/entityTypeDefaults.js +68 -0
- package/dist/cjs/entity/entityTypeDefaults.js.map +1 -0
- package/dist/cjs/entity/index.js +7 -3
- package/dist/cjs/entity/index.js.map +1 -1
- package/dist/cjs/index.js +7 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/entity/defaultExtractor.js +2 -1
- package/dist/esm/entity/defaultExtractor.js.map +1 -1
- package/dist/esm/entity/enrichEntitiesFromPayload.js +4 -2
- package/dist/esm/entity/enrichEntitiesFromPayload.js.map +1 -1
- package/dist/esm/entity/entityFamily.js +26 -0
- package/dist/esm/entity/entityFamily.js.map +1 -1
- package/dist/esm/entity/entityTypeDefaults.js +63 -0
- package/dist/esm/entity/entityTypeDefaults.js.map +1 -0
- package/dist/esm/entity/index.js +2 -1
- package/dist/esm/entity/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/entity/defaultExtractor.d.ts.map +1 -1
- package/dist/types/entity/enrichEntitiesFromPayload.d.ts +2 -1
- package/dist/types/entity/enrichEntitiesFromPayload.d.ts.map +1 -1
- package/dist/types/entity/entityFamily.d.ts +7 -0
- package/dist/types/entity/entityFamily.d.ts.map +1 -1
- package/dist/types/entity/entityTypeDefaults.d.ts +38 -0
- package/dist/types/entity/entityTypeDefaults.d.ts.map +1 -0
- package/dist/types/entity/index.d.ts +2 -1
- package/dist/types/entity/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -5,6 +5,7 @@ exports.defaultExtractor = void 0;
|
|
|
5
5
|
exports.transformToBlogPostEntityData = transformToBlogPostEntityData;
|
|
6
6
|
exports.transformToGenericEntityData = transformToGenericEntityData;
|
|
7
7
|
exports.transformToSolutionEntityData = transformToSolutionEntityData;
|
|
8
|
+
var _entityTypeDefaults = require("./entityTypeDefaults");
|
|
8
9
|
var _linkTypes = require("../types/link-types");
|
|
9
10
|
var _entityLinkParser = require("../utils/entityLinkParser");
|
|
10
11
|
var _matchedVariant = require("./matchedVariant");
|
|
@@ -49,7 +50,7 @@ function matchesUrl(payloadItem, entityId, config) {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
function findEntityInPayload(entityType, entityId, payload, entityConfig) {
|
|
52
|
-
const typeConfig = entityConfig
|
|
53
|
+
const typeConfig = (0, _entityTypeDefaults.resolveEntityTypeConfig)(entityConfig, entityType);
|
|
53
54
|
if (!typeConfig) {
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_linkTypes","require","_entityLinkParser","_matchedVariant","extractEntityIdFromUrl","entityUrl","trimmedUrl","trim","isWeb5EntityUrl","parsed","parseWeb5Url","type","Web5UrlType","ENTITY","entityType","entityId","matchesUrl","payloadItem","config","id","urlValue","urlMatchProperty","pattern","urlMatchPattern","endsWith","includes","findEntityInPayload","payload","entityConfig","typeConfig","entityTypes","matchedItem","find","item","transformToSolutionEntityData","transformToGenericEntityData","formatEntityDate","timestamp","_parts$find","_parts$find2","_parts$find3","date","Date","isNaN","getTime","undefined","formatter","Intl","DateTimeFormat","day","month","timeZone","year","parts","formatToParts","part","value","transformToBlogPostEntityData","_payloadItem$labels","_payloadItem$tags","imageUrl","publishTimestamp","publishDate","published_at","img","imgAlreadyAbsolute","startsWith","imageBaseUrl","currency","readCurrencyCode","priceCurrency","url","title","description","excerpt","matchedOptions","toMatchedOptions","options","variantId","price","formatPriceField","priceMin","priceMax","update_ts","author","authorName","cmsItemId","cms_item_id","usage","tags","labels","length","defaultExtractor","exports"],"sources":["../../../src/entity/defaultExtractor.ts"],"sourcesContent":["import type { SolutionEntityData, BlogEntityData, EntityItemData } from '../component/types';\nimport type {\n ApiPayloadItem,\n EntityConfig,\n EntityTypeConfig,\n} from '../types/entity';\nimport type { EntityExtractor } from './types';\nimport { Web5UrlType, isWeb5EntityUrl } from '../types/link-types';\nimport { parseWeb5Url } from '../utils/entityLinkParser';\nimport {\n formatPriceField,\n readCurrencyCode,\n toMatchedOptions,\n} from './matchedVariant';\n\n/**\n * Extract entity type and ID from a web5://entity/ URL.\n * Delegates to the central `parseWeb5Url` parser.\n */\nfunction extractEntityIdFromUrl(\n entityUrl: string,\n): { entityType: string; entityId: string } | null {\n const trimmedUrl = entityUrl?.trim();\n if (!trimmedUrl || !isWeb5EntityUrl(trimmedUrl)) {\n return null;\n }\n const parsed = parseWeb5Url(trimmedUrl);\n if (parsed?.type !== Web5UrlType.ENTITY || !parsed.entityType || !parsed.entityId) {\n return null;\n }\n return { entityType: parsed.entityType, entityId: parsed.entityId };\n}\n\nfunction matchesUrl(\n payloadItem: ApiPayloadItem,\n entityId: string,\n config: EntityTypeConfig,\n): boolean {\n // Entities resolve by `entityId` (the `<id>` in `web5://entity/<type>/<id>`).\n // Accept a direct `id` match, then fall back to the configured url strategy.\n if (payloadItem.id === entityId) {\n return true;\n }\n\n const urlValue = payloadItem[config.urlMatchProperty as keyof ApiPayloadItem];\n\n if (typeof urlValue !== 'string') {\n return false;\n }\n\n const pattern = config.urlMatchPattern || 'endsWith';\n\n switch (pattern) {\n case 'endsWith':\n return urlValue.endsWith(`/${entityId}`);\n case 'contains':\n return urlValue.includes(entityId);\n case 'equals':\n return urlValue === entityId;\n default:\n return urlValue.endsWith(`/${entityId}`);\n }\n}\n\nfunction findEntityInPayload(\n entityType: string,\n entityId: string,\n payload: ApiPayloadItem[],\n entityConfig: EntityConfig,\n): ApiPayloadItem | null {\n const typeConfig = entityConfig.entityTypes[entityType];\n\n if (!typeConfig) {\n return null;\n }\n\n // Resolution keys off `entityId` (not the type): find the payload item whose\n // id/url matches, using the type's configured url strategy.\n const matchedItem = payload.find((item) =>\n matchesUrl(item, entityId, typeConfig),\n );\n\n return matchedItem || null;\n}\n\n/** @deprecated Use transformToGenericEntityData */\nexport function transformToSolutionEntityData(\n payloadItem: ApiPayloadItem,\n config: EntityTypeConfig,\n): SolutionEntityData {\n return transformToGenericEntityData(payloadItem, config);\n}\n\nfunction formatEntityDate(timestamp: string): string | undefined {\n const date = new Date(timestamp);\n if (isNaN(date.getTime())) {\n return undefined;\n }\n const formatter = new Intl.DateTimeFormat('en-US', {\n day: 'numeric',\n month: 'short',\n timeZone: 'Europe/Kiev',\n year: 'numeric',\n });\n const parts = formatter.formatToParts(date);\n const day = parts.find((part) => part.type === 'day')?.value;\n const month = parts.find((part) => part.type === 'month')?.value;\n const year = parts.find((part) => part.type === 'year')?.value;\n\n if (!day || !month || !year) {\n return undefined;\n }\n\n return `${day} ${month} ${year}`;\n}\n\n/** @deprecated Use transformToGenericEntityData */\nexport function transformToBlogPostEntityData(\n payloadItem: ApiPayloadItem,\n config: EntityTypeConfig,\n): BlogEntityData {\n return transformToGenericEntityData(payloadItem, config);\n}\n\nexport function transformToGenericEntityData(\n payloadItem: ApiPayloadItem,\n config: EntityTypeConfig,\n): EntityItemData {\n let imageUrl: string | undefined;\n const publishTimestamp = payloadItem.publishDate || payloadItem.published_at;\n\n if (payloadItem.img) {\n const imgAlreadyAbsolute = payloadItem.img.startsWith('http');\n imageUrl = config.imageBaseUrl && !imgAlreadyAbsolute\n ? `${config.imageBaseUrl}${payloadItem.img}`\n : payloadItem.img;\n }\n\n // A document that retrieval narrowed to one child arrives with that child's\n // presentation fields already overlaid (`url`, `img`, `price`) plus the pairs\n // that identify it and the span its parent covers. The overlay is done\n // server-side; all that is left here is to shape those two for display.\n const currency = readCurrencyCode(\n payloadItem.currency,\n payloadItem.priceCurrency,\n );\n\n return {\n url: payloadItem.url,\n title: payloadItem.title,\n type: payloadItem.type,\n description: payloadItem.description,\n excerpt: payloadItem.excerpt,\n imageUrl,\n matchedOptions: toMatchedOptions(payloadItem.options),\n // Which child the row is wearing. Carried through so the live enricher\n // prices THAT variant (`mergeShopifyEntityData` keeps the turn's value)\n // rather than falling back to the product's default.\n variantId: payloadItem.variantId,\n price: formatPriceField(payloadItem.price, currency),\n priceMin: formatPriceField(payloadItem.priceMin, currency),\n priceMax: formatPriceField(payloadItem.priceMax, currency),\n date: payloadItem.update_ts\n ? formatEntityDate(payloadItem.update_ts)\n : undefined,\n publishDate: publishTimestamp\n ? formatEntityDate(publishTimestamp)\n : undefined,\n author: payloadItem.author || payloadItem.authorName,\n cmsItemId: payloadItem.cms_item_id,\n usage: payloadItem.usage,\n tags: payloadItem.labels?.length\n ? payloadItem.labels\n : payloadItem.tags?.length\n ? payloadItem.tags\n : undefined,\n };\n}\n\n/**\n * Default entity extractor - config-driven extraction for any client.\n * Uses entityConfig from client JSON to resolve web5://entity/ URLs against API payload.\n */\nexport const defaultExtractor: EntityExtractor = {\n extractEntityIdFromUrl,\n findEntityInPayload,\n};\n"],"mappings":";;;;;;;AAOA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAMA;AACA;AACA;AACA;AACA,SAASG,sBAAsBA,CAC7BC,SAAiB,EACgC;EACjD,MAAMC,UAAU,GAAGD,SAAS,oBAATA,SAAS,CAAEE,IAAI,CAAC,CAAC;EACpC,IAAI,CAACD,UAAU,IAAI,CAAC,IAAAE,0BAAe,EAACF,UAAU,CAAC,EAAE;IAC/C,OAAO,IAAI;EACb;EACA,MAAMG,MAAM,GAAG,IAAAC,8BAAY,EAACJ,UAAU,CAAC;EACvC,IAAI,CAAAG,MAAM,oBAANA,MAAM,CAAEE,IAAI,MAAKC,sBAAW,CAAC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,QAAQ,EAAEb,QAAQ,CAAC;IAC1Dc,QAAQ,EAAE,IAAAF,gCAAgB,EAAC/D,WAAW,CAACiE,QAAQ,EAAEd,QAAQ,CAAC;IAC1D3B,IAAI,EAAExB,WAAW,CAACkE,SAAS,GACvB/C,gBAAgB,CAACnB,WAAW,CAACkE,SAAS,CAAC,GACvCtC,SAAS;IACbiB,WAAW,EAAED,gBAAgB,GACzBzB,gBAAgB,CAACyB,gBAAgB,CAAC,GAClChB,SAAS;IACbuC,MAAM,EAAEnE,WAAW,CAACmE,MAAM,IAAInE,WAAW,CAACoE,UAAU;IACpDC,SAAS,EAAErE,WAAW,CAACsE,WAAW;IAClCC,KAAK,EAAEvE,WAAW,CAACuE,KAAK;IACxBC,IAAI,EAAE,CAAA/B,mBAAA,GAAAzC,WAAW,CAACyE,MAAM,aAAlBhC,mBAAA,CAAoBiC,MAAM,GAC5B1E,WAAW,CAACyE,MAAM,GAClB,CAAA/B,iBAAA,GAAA1C,WAAW,CAACwE,IAAI,aAAhB9B,iBAAA,CAAkBgC,MAAM,GACxB1E,WAAW,CAACwE,IAAI,GAChB5C;EACN,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,MAAM+C,gBAAiC,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC/CxF,sBAAsB;EACtBsB;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_entityTypeDefaults","require","_linkTypes","_entityLinkParser","_matchedVariant","extractEntityIdFromUrl","entityUrl","trimmedUrl","trim","isWeb5EntityUrl","parsed","parseWeb5Url","type","Web5UrlType","ENTITY","entityType","entityId","matchesUrl","payloadItem","config","id","urlValue","urlMatchProperty","pattern","urlMatchPattern","endsWith","includes","findEntityInPayload","payload","entityConfig","typeConfig","resolveEntityTypeConfig","matchedItem","find","item","transformToSolutionEntityData","transformToGenericEntityData","formatEntityDate","timestamp","_parts$find","_parts$find2","_parts$find3","date","Date","isNaN","getTime","undefined","formatter","Intl","DateTimeFormat","day","month","timeZone","year","parts","formatToParts","part","value","transformToBlogPostEntityData","_payloadItem$labels","_payloadItem$tags","imageUrl","publishTimestamp","publishDate","published_at","img","imgAlreadyAbsolute","startsWith","imageBaseUrl","currency","readCurrencyCode","priceCurrency","url","title","description","excerpt","matchedOptions","toMatchedOptions","options","variantId","price","formatPriceField","priceMin","priceMax","update_ts","author","authorName","cmsItemId","cms_item_id","usage","tags","labels","length","defaultExtractor","exports"],"sources":["../../../src/entity/defaultExtractor.ts"],"sourcesContent":["import type { SolutionEntityData, BlogEntityData, EntityItemData } from '../component/types';\nimport type {\n ApiPayloadItem,\n EntityConfig,\n EntityTypeConfig,\n} from '../types/entity';\nimport type { EntityExtractor } from './types';\nimport { resolveEntityTypeConfig } from './entityTypeDefaults';\nimport { Web5UrlType, isWeb5EntityUrl } from '../types/link-types';\nimport { parseWeb5Url } from '../utils/entityLinkParser';\nimport {\n formatPriceField,\n readCurrencyCode,\n toMatchedOptions,\n} from './matchedVariant';\n\n/**\n * Extract entity type and ID from a web5://entity/ URL.\n * Delegates to the central `parseWeb5Url` parser.\n */\nfunction extractEntityIdFromUrl(\n entityUrl: string,\n): { entityType: string; entityId: string } | null {\n const trimmedUrl = entityUrl?.trim();\n if (!trimmedUrl || !isWeb5EntityUrl(trimmedUrl)) {\n return null;\n }\n const parsed = parseWeb5Url(trimmedUrl);\n if (parsed?.type !== Web5UrlType.ENTITY || !parsed.entityType || !parsed.entityId) {\n return null;\n }\n return { entityType: parsed.entityType, entityId: parsed.entityId };\n}\n\nfunction matchesUrl(\n payloadItem: ApiPayloadItem,\n entityId: string,\n config: EntityTypeConfig,\n): boolean {\n // Entities resolve by `entityId` (the `<id>` in `web5://entity/<type>/<id>`).\n // Accept a direct `id` match, then fall back to the configured url strategy.\n if (payloadItem.id === entityId) {\n return true;\n }\n\n const urlValue = payloadItem[config.urlMatchProperty as keyof ApiPayloadItem];\n\n if (typeof urlValue !== 'string') {\n return false;\n }\n\n const pattern = config.urlMatchPattern || 'endsWith';\n\n switch (pattern) {\n case 'endsWith':\n return urlValue.endsWith(`/${entityId}`);\n case 'contains':\n return urlValue.includes(entityId);\n case 'equals':\n return urlValue === entityId;\n default:\n return urlValue.endsWith(`/${entityId}`);\n }\n}\n\nfunction findEntityInPayload(\n entityType: string,\n entityId: string,\n payload: ApiPayloadItem[],\n entityConfig: EntityConfig,\n): ApiPayloadItem | null {\n const typeConfig = resolveEntityTypeConfig(entityConfig, entityType);\n\n if (!typeConfig) {\n return null;\n }\n\n // Resolution keys off `entityId` (not the type): find the payload item whose\n // id/url matches, using the type's configured url strategy.\n const matchedItem = payload.find((item) =>\n matchesUrl(item, entityId, typeConfig),\n );\n\n return matchedItem || null;\n}\n\n/** @deprecated Use transformToGenericEntityData */\nexport function transformToSolutionEntityData(\n payloadItem: ApiPayloadItem,\n config: EntityTypeConfig,\n): SolutionEntityData {\n return transformToGenericEntityData(payloadItem, config);\n}\n\nfunction formatEntityDate(timestamp: string): string | undefined {\n const date = new Date(timestamp);\n if (isNaN(date.getTime())) {\n return undefined;\n }\n const formatter = new Intl.DateTimeFormat('en-US', {\n day: 'numeric',\n month: 'short',\n timeZone: 'Europe/Kiev',\n year: 'numeric',\n });\n const parts = formatter.formatToParts(date);\n const day = parts.find((part) => part.type === 'day')?.value;\n const month = parts.find((part) => part.type === 'month')?.value;\n const year = parts.find((part) => part.type === 'year')?.value;\n\n if (!day || !month || !year) {\n return undefined;\n }\n\n return `${day} ${month} ${year}`;\n}\n\n/** @deprecated Use transformToGenericEntityData */\nexport function transformToBlogPostEntityData(\n payloadItem: ApiPayloadItem,\n config: EntityTypeConfig,\n): BlogEntityData {\n return transformToGenericEntityData(payloadItem, config);\n}\n\nexport function transformToGenericEntityData(\n payloadItem: ApiPayloadItem,\n config: EntityTypeConfig,\n): EntityItemData {\n let imageUrl: string | undefined;\n const publishTimestamp = payloadItem.publishDate || payloadItem.published_at;\n\n if (payloadItem.img) {\n const imgAlreadyAbsolute = payloadItem.img.startsWith('http');\n imageUrl = config.imageBaseUrl && !imgAlreadyAbsolute\n ? `${config.imageBaseUrl}${payloadItem.img}`\n : payloadItem.img;\n }\n\n // A document that retrieval narrowed to one child arrives with that child's\n // presentation fields already overlaid (`url`, `img`, `price`) plus the pairs\n // that identify it and the span its parent covers. The overlay is done\n // server-side; all that is left here is to shape those two for display.\n const currency = readCurrencyCode(\n payloadItem.currency,\n payloadItem.priceCurrency,\n );\n\n return {\n url: payloadItem.url,\n title: payloadItem.title,\n type: payloadItem.type,\n description: payloadItem.description,\n excerpt: payloadItem.excerpt,\n imageUrl,\n matchedOptions: toMatchedOptions(payloadItem.options),\n // Which child the row is wearing. Carried through so the live enricher\n // prices THAT variant (`mergeShopifyEntityData` keeps the turn's value)\n // rather than falling back to the product's default.\n variantId: payloadItem.variantId,\n price: formatPriceField(payloadItem.price, currency),\n priceMin: formatPriceField(payloadItem.priceMin, currency),\n priceMax: formatPriceField(payloadItem.priceMax, currency),\n date: payloadItem.update_ts\n ? formatEntityDate(payloadItem.update_ts)\n : undefined,\n publishDate: publishTimestamp\n ? formatEntityDate(publishTimestamp)\n : undefined,\n author: payloadItem.author || payloadItem.authorName,\n cmsItemId: payloadItem.cms_item_id,\n usage: payloadItem.usage,\n tags: payloadItem.labels?.length\n ? payloadItem.labels\n : payloadItem.tags?.length\n ? payloadItem.tags\n : undefined,\n };\n}\n\n/**\n * Default entity extractor - config-driven extraction for any client.\n * Uses entityConfig from client JSON to resolve web5://entity/ URLs against API payload.\n */\nexport const defaultExtractor: EntityExtractor = {\n extractEntityIdFromUrl,\n findEntityInPayload,\n};\n"],"mappings":";;;;;;;AAOA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAMA;AACA;AACA;AACA;AACA,SAASI,sBAAsBA,CAC7BC,SAAiB,EACgC;EACjD,MAAMC,UAAU,GAAGD,SAAS,oBAATA,SAAS,CAAEE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EAAE,IAAAC,gCAAgB,EAAC3D,WAAW,CAAC4D,OAAO,CAAC;IACrD;IACA;IACA;IACAC,SAAS,EAAE7D,WAAW,CAAC6D,SAAS;IAChCC,KAAK,EAAE,IAAAC,gCAAgB,EAAC/D,WAAW,CAAC8D,KAAK,EAAEX,QAAQ,CAAC;IACpDa,QAAQ,EAAE,IAAAD,gCAAgB,EAAC/D,WAAW,CAACgE,QAAQ,EAAEb,QAAQ,CAAC;IAC1Dc,QAAQ,EAAE,IAAAF,gCAAgB,EAAC/D,WAAW,CAACiE,QAAQ,EAAEd,QAAQ,CAAC;IAC1D3B,IAAI,EAAExB,WAAW,CAACkE,SAAS,GACvB/C,gBAAgB,CAACnB,WAAW,CAACkE,SAAS,CAAC,GACvCtC,SAAS;IACbiB,WAAW,EAAED,gBAAgB,GACzBzB,gBAAgB,CAACyB,gBAAgB,CAAC,GAClChB,SAAS;IACbuC,MAAM,EAAEnE,WAAW,CAACmE,MAAM,IAAInE,WAAW,CAACoE,UAAU;IACpDC,SAAS,EAAErE,WAAW,CAACsE,WAAW;IAClCC,KAAK,EAAEvE,WAAW,CAACuE,KAAK;IACxBC,IAAI,EAAE,CAAA/B,mBAAA,GAAAzC,WAAW,CAACyE,MAAM,aAAlBhC,mBAAA,CAAoBiC,MAAM,GAC5B1E,WAAW,CAACyE,MAAM,GAClB,CAAA/B,iBAAA,GAAA1C,WAAW,CAACwE,IAAI,aAAhB9B,iBAAA,CAAkBgC,MAAM,GACxB1E,WAAW,CAACwE,IAAI,GAChB5C;EACN,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,MAAM+C,gBAAiC,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC/CxF,sBAAsB;EACtBsB;AACF,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.enrichEntitiesFromPayload = enrichEntitiesFromPayload;
|
|
5
|
+
var _entityTypeDefaults = require("./entityTypeDefaults");
|
|
5
6
|
/**
|
|
6
7
|
* Pure helper — given a list of entity refs, a payload, an entity config, an
|
|
7
8
|
* extractor, and a per-type transform, return a new array where any entity
|
|
@@ -14,7 +15,8 @@ exports.enrichEntitiesFromPayload = enrichEntitiesFromPayload;
|
|
|
14
15
|
* Skips an entity when:
|
|
15
16
|
* - it already has `.data` (caller-provided wins),
|
|
16
17
|
* - the URL doesn't parse as a `web5://entity/…` URL,
|
|
17
|
-
* - the parsed `entityType` has no config row
|
|
18
|
+
* - the parsed `entityType` has no config row — neither the client's own nor
|
|
19
|
+
* the platform floor in `PLATFORM_ENTITY_TYPES`,
|
|
18
20
|
* - no payload item matches.
|
|
19
21
|
*
|
|
20
22
|
* Returns the same array shape as the input; entities without a match are
|
|
@@ -26,7 +28,7 @@ function enrichEntitiesFromPayload(entities, payload, entityConfig, extractor, t
|
|
|
26
28
|
if (entity.data) return entity;
|
|
27
29
|
const parsed = extractor.extractEntityIdFromUrl(entity.entityUrl);
|
|
28
30
|
if (!parsed) return entity;
|
|
29
|
-
const typeConfig = entityConfig
|
|
31
|
+
const typeConfig = (0, _entityTypeDefaults.resolveEntityTypeConfig)(entityConfig, parsed.entityType);
|
|
30
32
|
if (!typeConfig) return entity;
|
|
31
33
|
const payloadItem = extractor.findEntityInPayload(parsed.entityType, parsed.entityId, payload, entityConfig);
|
|
32
34
|
if (!payloadItem) return entity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["enrichEntitiesFromPayload","entities","payload","entityConfig","extractor","transform","length","map","entity","data","parsed","extractEntityIdFromUrl","entityUrl","typeConfig","
|
|
1
|
+
{"version":3,"names":["_entityTypeDefaults","require","enrichEntitiesFromPayload","entities","payload","entityConfig","extractor","transform","length","map","entity","data","parsed","extractEntityIdFromUrl","entityUrl","typeConfig","resolveEntityTypeConfig","entityType","payloadItem","findEntityInPayload","entityId"],"sources":["../../../src/entity/enrichEntitiesFromPayload.ts"],"sourcesContent":["import type {\n ApiPayloadItem,\n EntityConfig,\n EntityTypeConfig,\n} from '../types/entity';\nimport { resolveEntityTypeConfig } from './entityTypeDefaults';\nimport type { EntityExtractor } from './types';\n\n/**\n * Pure helper — given a list of entity refs, a payload, an entity config, an\n * extractor, and a per-type transform, return a new array where any entity\n * whose `entityUrl` resolves to a payload item has its `.data` populated.\n *\n * Pure / framework-free so both the main app's React hook\n * (`useResolveGenericEntityData`, Step 1) and the placement bundle's\n * resolver (DL #099 PR 4) can share it.\n *\n * Skips an entity when:\n * - it already has `.data` (caller-provided wins),\n * - the URL doesn't parse as a `web5://entity/…` URL,\n * - the parsed `entityType` has no config row — neither the client's own nor\n * the platform floor in `PLATFORM_ENTITY_TYPES`,\n * - no payload item matches.\n *\n * Returns the same array shape as the input; entities without a match are\n * passed through by reference so React memoization upstream stays cheap.\n */\nexport function enrichEntitiesFromPayload<\n TEntity extends {\n entityId: string;\n entityUrl: string;\n entityType: string;\n data?: TEntityData;\n },\n TEntityData,\n>(\n entities: TEntity[],\n payload: ApiPayloadItem[],\n entityConfig: EntityConfig,\n extractor: EntityExtractor,\n transform: (raw: ApiPayloadItem, config: EntityTypeConfig) => TEntityData,\n): TEntity[] {\n if (!payload.length) return entities;\n\n return entities.map((entity) => {\n if (entity.data) return entity;\n\n const parsed = extractor.extractEntityIdFromUrl(entity.entityUrl);\n if (!parsed) return entity;\n\n const typeConfig = resolveEntityTypeConfig(entityConfig, parsed.entityType);\n if (!typeConfig) return entity;\n\n const payloadItem = extractor.findEntityInPayload(\n parsed.entityType,\n parsed.entityId,\n payload,\n entityConfig,\n );\n if (!payloadItem) return entity;\n\n return { ...entity, data: transform(payloadItem, typeConfig) };\n });\n}\n"],"mappings":";;;;AAKA,IAAAA,mBAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CASvCC,QAAmB,EACnBC,OAAyB,EACzBC,YAA0B,EAC1BC,SAA0B,EAC1BC,SAAyE,EAC9D;EACX,IAAI,CAACH,OAAO,CAACI,MAAM,EAAE,OAAOL,QAAQ;EAEpC,OAAOA,QAAQ,CAACM,GAAG,CAAEC,MAAM,IAAK;IAC9B,IAAIA,MAAM,CAACC,IAAI,EAAE,OAAOD,MAAM;IAE9B,MAAME,MAAM,GAAGN,SAAS,CAACO,sBAAsB,CAACH,MAAM,CAACI,SAAS,CAAC;IACjE,IAAI,CAACF,MAAM,EAAE,OAAOF,MAAM;IAE1B,MAAMK,UAAU,GAAG,IAAAC,2CAAuB,EAACX,YAAY,EAAEO,MAAM,CAACK,UAAU,CAAC;IAC3E,IAAI,CAACF,UAAU,EAAE,OAAOL,MAAM;IAE9B,MAAMQ,WAAW,GAAGZ,SAAS,CAACa,mBAAmB,CAC/CP,MAAM,CAACK,UAAU,EACjBL,MAAM,CAACQ,QAAQ,EACfhB,OAAO,EACPC,YACF,CAAC;IACD,IAAI,CAACa,WAAW,EAAE,OAAOR,MAAM;IAE/B,OAAO;MAAE,GAAGA,MAAM;MAAEC,IAAI,EAAEJ,SAAS,CAACW,WAAW,EAAEH,UAAU;IAAE,CAAC;EAChE,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports.isDocumentFamilyEntityType = isDocumentFamilyEntityType;
|
|
4
5
|
exports.isProductFamilyEntityType = isProductFamilyEntityType;
|
|
5
6
|
/**
|
|
6
7
|
* Which entity types a PRODUCT surface may draw.
|
|
@@ -34,4 +35,30 @@ const PRODUCT_FAMILY = new Set(['product', 'variant']);
|
|
|
34
35
|
function isProductFamilyEntityType(entityType) {
|
|
35
36
|
return PRODUCT_FAMILY.has((entityType ?? '').trim().toLowerCase());
|
|
36
37
|
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Which entity types a DOCUMENT surface may draw.
|
|
41
|
+
*
|
|
42
|
+
* A `page` (a static storefront page) and a `policy` (refund, shipping,
|
|
43
|
+
* privacy, terms) are the same shape as each other and a different shape to
|
|
44
|
+
* everything else a turn can link: a title and a URL, and no image, no price
|
|
45
|
+
* and no variant. A product card has nothing to draw them with, and an article
|
|
46
|
+
* card would promise an author and a publish date neither one has.
|
|
47
|
+
*
|
|
48
|
+
* This lives beside `isProductFamilyEntityType` and for the same reason — a
|
|
49
|
+
* surface that routes by type and has never heard of `policy` does not fail
|
|
50
|
+
* loudly, it renders nothing and leaves the shopper an answer with no way to
|
|
51
|
+
* read the policy it just summarised.
|
|
52
|
+
*/
|
|
53
|
+
const DOCUMENT_FAMILY = new Set(['page', 'policy']);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* `true` for the entity types a title-and-link document card can render.
|
|
57
|
+
*
|
|
58
|
+
* Case-insensitive on the trimmed value, like the product predicate: the type
|
|
59
|
+
* is the verbatim `doc_domain` a site's mapping schema chose.
|
|
60
|
+
*/
|
|
61
|
+
function isDocumentFamilyEntityType(entityType) {
|
|
62
|
+
return DOCUMENT_FAMILY.has((entityType ?? '').trim().toLowerCase());
|
|
63
|
+
}
|
|
37
64
|
//# sourceMappingURL=entityFamily.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PRODUCT_FAMILY","Set","isProductFamilyEntityType","entityType","has","trim","toLowerCase"],"sources":["../../../src/entity/entityFamily.ts"],"sourcesContent":["/**\n * Which entity types a PRODUCT surface may draw.\n *\n * Every client re-implemented this as `entityType === 'product'`, and that held\n * for as long as a product was the only purchasable thing a turn could return.\n * It stopped holding when retrieval learned to ENUMERATE an option dimension:\n * asked to see the range of an option (\"all the colours of X\") rather than to\n * filter by one value of it, a turn answers with one row per colourway, and\n * each row is a `variant`.\n *\n * A variant is not a different KIND of thing to a card. It is one purchasable\n * child of a product, carrying its own image, its own price and a\n * `?variant=`-bearing link — everything a product card draws. What it is not is\n * an article or a collection, which are different cards entirely.\n *\n * This lives in core because getting it wrong is silent: the row resolves\n * perfectly, then the product surface filters it out, and the page renders the\n * prose with a hole where the cards belong. That shipped to production once\n * already.\n */\nconst PRODUCT_FAMILY: ReadonlySet<string> = new Set(['product', 'variant']);\n\n/**\n * `true` for the entity types a product card can render.\n *\n * Compares case-insensitively on the trimmed value, because the type is the\n * verbatim `doc_domain` a site's mapping schema chose and nothing normalizes it\n * on the way here.\n */\nexport function isProductFamilyEntityType(entityType: string | undefined): boolean {\n return PRODUCT_FAMILY.has((entityType ?? '').trim().toLowerCase());\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["PRODUCT_FAMILY","Set","isProductFamilyEntityType","entityType","has","trim","toLowerCase","DOCUMENT_FAMILY","isDocumentFamilyEntityType"],"sources":["../../../src/entity/entityFamily.ts"],"sourcesContent":["/**\n * Which entity types a PRODUCT surface may draw.\n *\n * Every client re-implemented this as `entityType === 'product'`, and that held\n * for as long as a product was the only purchasable thing a turn could return.\n * It stopped holding when retrieval learned to ENUMERATE an option dimension:\n * asked to see the range of an option (\"all the colours of X\") rather than to\n * filter by one value of it, a turn answers with one row per colourway, and\n * each row is a `variant`.\n *\n * A variant is not a different KIND of thing to a card. It is one purchasable\n * child of a product, carrying its own image, its own price and a\n * `?variant=`-bearing link — everything a product card draws. What it is not is\n * an article or a collection, which are different cards entirely.\n *\n * This lives in core because getting it wrong is silent: the row resolves\n * perfectly, then the product surface filters it out, and the page renders the\n * prose with a hole where the cards belong. That shipped to production once\n * already.\n */\nconst PRODUCT_FAMILY: ReadonlySet<string> = new Set(['product', 'variant']);\n\n/**\n * `true` for the entity types a product card can render.\n *\n * Compares case-insensitively on the trimmed value, because the type is the\n * verbatim `doc_domain` a site's mapping schema chose and nothing normalizes it\n * on the way here.\n */\nexport function isProductFamilyEntityType(entityType: string | undefined): boolean {\n return PRODUCT_FAMILY.has((entityType ?? '').trim().toLowerCase());\n}\n\n/**\n * Which entity types a DOCUMENT surface may draw.\n *\n * A `page` (a static storefront page) and a `policy` (refund, shipping,\n * privacy, terms) are the same shape as each other and a different shape to\n * everything else a turn can link: a title and a URL, and no image, no price\n * and no variant. A product card has nothing to draw them with, and an article\n * card would promise an author and a publish date neither one has.\n *\n * This lives beside `isProductFamilyEntityType` and for the same reason — a\n * surface that routes by type and has never heard of `policy` does not fail\n * loudly, it renders nothing and leaves the shopper an answer with no way to\n * read the policy it just summarised.\n */\nconst DOCUMENT_FAMILY: ReadonlySet<string> = new Set(['page', 'policy']);\n\n/**\n * `true` for the entity types a title-and-link document card can render.\n *\n * Case-insensitive on the trimmed value, like the product predicate: the type\n * is the verbatim `doc_domain` a site's mapping schema chose.\n */\nexport function isDocumentFamilyEntityType(entityType: string | undefined): boolean {\n return DOCUMENT_FAMILY.has((entityType ?? '').trim().toLowerCase());\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAmC,GAAG,IAAIC,GAAG,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;;AAE3E;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,yBAAyBA,CAACC,UAA8B,EAAW;EACjF,OAAOH,cAAc,CAACI,GAAG,CAAC,CAACD,UAAU,IAAI,EAAE,EAAEE,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAoC,GAAG,IAAIN,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;;AAExE;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,0BAA0BA,CAACL,UAA8B,EAAW;EAClF,OAAOI,eAAe,CAACH,GAAG,CAAC,CAACD,UAAU,IAAI,EAAE,EAAEE,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC;AACrE","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.PLATFORM_ENTITY_TYPES = void 0;
|
|
5
|
+
exports.resolveEntityTypeConfig = resolveEntityTypeConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Entity types every site can resolve, whether or not its client config names
|
|
8
|
+
* them.
|
|
9
|
+
*
|
|
10
|
+
* Resolution is an EXACT-KEY lookup into `entityConfig.entityTypes` with no
|
|
11
|
+
* mapping and no fallback (DL #124: "an unknown key just yields no data"), so a
|
|
12
|
+
* type a client never declared is not a degraded reference — it is no reference
|
|
13
|
+
* at all. That gate is right for a type nobody can serve, and wrong for the
|
|
14
|
+
* static-content domains the platform's own ecom mapping schema publishes on
|
|
15
|
+
* every store: `page` and `policy` (see
|
|
16
|
+
* `web5-collection-mapping/schema/examples/ecom-site.schema.json`). Those rows
|
|
17
|
+
* arrive in the turn's payload with a title and a URL, and were dropped for the
|
|
18
|
+
* sole reason that four hand-written config files had never heard of them.
|
|
19
|
+
*
|
|
20
|
+
* Keys are the semantic `doc_domain` the mapping stamps, so the link's `<type>`
|
|
21
|
+
* and the card's `type` are the same word. A client that needs different
|
|
22
|
+
* matching for one of these declares its own row and wins — this is the floor,
|
|
23
|
+
* not an override.
|
|
24
|
+
*
|
|
25
|
+
* NOT here: `product` / `variant` / `collection` / `article`, which every client
|
|
26
|
+
* already declares and whose matching genuinely differs per store, and `blog` /
|
|
27
|
+
* `catalog`, the two remaining domains of the ecom schema that no answer links
|
|
28
|
+
* to yet.
|
|
29
|
+
*/
|
|
30
|
+
const PLATFORM_ENTITY_TYPES = exports.PLATFORM_ENTITY_TYPES = Object.freeze({
|
|
31
|
+
// A store policy (refund, shipping, privacy, terms). Title + URL, no image,
|
|
32
|
+
// no price, no variant.
|
|
33
|
+
policy: {
|
|
34
|
+
payloadType: 'policy',
|
|
35
|
+
urlMatchProperty: 'url',
|
|
36
|
+
urlMatchPattern: 'endsWith'
|
|
37
|
+
},
|
|
38
|
+
// A static storefront page (`/pages/<handle>`) — "About us", "Delivery
|
|
39
|
+
// information". Same shape as a policy.
|
|
40
|
+
page: {
|
|
41
|
+
payloadType: 'page',
|
|
42
|
+
urlMatchProperty: 'url',
|
|
43
|
+
urlMatchPattern: 'endsWith'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The config row a `web5://entity/<type>/<id>` reference resolves against: the
|
|
49
|
+
* client's own declaration first, then the platform floor above.
|
|
50
|
+
*
|
|
51
|
+
* The client lookup stays verbatim — `entityTypes` keys are compared exactly
|
|
52
|
+
* everywhere else, and a client that keys a row `Solution` means `Solution`.
|
|
53
|
+
* The floor is matched case-insensitively on the trimmed value, for the same
|
|
54
|
+
* reason `isProductFamilyEntityType` is: the type is whatever `doc_domain` a
|
|
55
|
+
* site's mapping schema chose and nothing normalizes it on the way here.
|
|
56
|
+
*/
|
|
57
|
+
function resolveEntityTypeConfig(entityConfig, entityType) {
|
|
58
|
+
var _entityConfig$entityT;
|
|
59
|
+
if (!entityType) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const declared = entityConfig == null || (_entityConfig$entityT = entityConfig.entityTypes) == null ? void 0 : _entityConfig$entityT[entityType];
|
|
63
|
+
if (declared) {
|
|
64
|
+
return declared;
|
|
65
|
+
}
|
|
66
|
+
return PLATFORM_ENTITY_TYPES[entityType.trim().toLowerCase()];
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=entityTypeDefaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PLATFORM_ENTITY_TYPES","exports","Object","freeze","policy","payloadType","urlMatchProperty","urlMatchPattern","page","resolveEntityTypeConfig","entityConfig","entityType","_entityConfig$entityT","undefined","declared","entityTypes","trim","toLowerCase"],"sources":["../../../src/entity/entityTypeDefaults.ts"],"sourcesContent":["import type { EntityConfig, EntityTypeConfig } from '../types/entity';\n\n/**\n * Entity types every site can resolve, whether or not its client config names\n * them.\n *\n * Resolution is an EXACT-KEY lookup into `entityConfig.entityTypes` with no\n * mapping and no fallback (DL #124: \"an unknown key just yields no data\"), so a\n * type a client never declared is not a degraded reference — it is no reference\n * at all. That gate is right for a type nobody can serve, and wrong for the\n * static-content domains the platform's own ecom mapping schema publishes on\n * every store: `page` and `policy` (see\n * `web5-collection-mapping/schema/examples/ecom-site.schema.json`). Those rows\n * arrive in the turn's payload with a title and a URL, and were dropped for the\n * sole reason that four hand-written config files had never heard of them.\n *\n * Keys are the semantic `doc_domain` the mapping stamps, so the link's `<type>`\n * and the card's `type` are the same word. A client that needs different\n * matching for one of these declares its own row and wins — this is the floor,\n * not an override.\n *\n * NOT here: `product` / `variant` / `collection` / `article`, which every client\n * already declares and whose matching genuinely differs per store, and `blog` /\n * `catalog`, the two remaining domains of the ecom schema that no answer links\n * to yet.\n */\nexport const PLATFORM_ENTITY_TYPES: Readonly<Record<string, EntityTypeConfig>> =\n Object.freeze({\n // A store policy (refund, shipping, privacy, terms). Title + URL, no image,\n // no price, no variant.\n policy: {\n payloadType: 'policy',\n urlMatchProperty: 'url',\n urlMatchPattern: 'endsWith' as const,\n },\n // A static storefront page (`/pages/<handle>`) — \"About us\", \"Delivery\n // information\". Same shape as a policy.\n page: {\n payloadType: 'page',\n urlMatchProperty: 'url',\n urlMatchPattern: 'endsWith' as const,\n },\n });\n\n/**\n * The config row a `web5://entity/<type>/<id>` reference resolves against: the\n * client's own declaration first, then the platform floor above.\n *\n * The client lookup stays verbatim — `entityTypes` keys are compared exactly\n * everywhere else, and a client that keys a row `Solution` means `Solution`.\n * The floor is matched case-insensitively on the trimmed value, for the same\n * reason `isProductFamilyEntityType` is: the type is whatever `doc_domain` a\n * site's mapping schema chose and nothing normalizes it on the way here.\n */\nexport function resolveEntityTypeConfig(\n entityConfig: Pick<EntityConfig, 'entityTypes'> | undefined | null,\n entityType: string | undefined,\n): EntityTypeConfig | undefined {\n if (!entityType) {\n return undefined;\n }\n const declared = entityConfig?.entityTypes?.[entityType];\n if (declared) {\n return declared;\n }\n return PLATFORM_ENTITY_TYPES[entityType.trim().toLowerCase()];\n}\n"],"mappings":";;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,qBAAiE,GAAAC,OAAA,CAAAD,qBAAA,GAC5EE,MAAM,CAACC,MAAM,CAAC;EACZ;EACA;EACAC,MAAM,EAAE;IACNC,WAAW,EAAE,QAAQ;IACrBC,gBAAgB,EAAE,KAAK;IACvBC,eAAe,EAAE;EACnB,CAAC;EACD;EACA;EACAC,IAAI,EAAE;IACJH,WAAW,EAAE,MAAM;IACnBC,gBAAgB,EAAE,KAAK;IACvBC,eAAe,EAAE;EACnB;AACF,CAAC,CAAC;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,uBAAuBA,CACrCC,YAAkE,EAClEC,UAA8B,EACA;EAAA,IAAAC,qBAAA;EAC9B,IAAI,CAACD,UAAU,EAAE;IACf,OAAOE,SAAS;EAClB;EACA,MAAMC,QAAQ,GAAGJ,YAAY,aAAAE,qBAAA,GAAZF,YAAY,CAAEK,WAAW,qBAAzBH,qBAAA,CAA4BD,UAAU,CAAC;EACxD,IAAIG,QAAQ,EAAE;IACZ,OAAOA,QAAQ;EACjB;EACA,OAAOd,qBAAqB,CAACW,UAAU,CAACK,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC;AAC/D","ignoreList":[]}
|
package/dist/cjs/entity/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.formatProductPriceLabel = exports.formatPriceField = exports.formatMoney = exports.fetchEntityListData = exports.entityPayloadFromItems = exports.entityHref = exports.enrichEntitiesFromPayload = exports.LIST_ITEMS_ENDPOINT = void 0;
|
|
4
|
+
exports.formatProductPriceLabel = exports.formatPriceField = exports.formatMoney = exports.fetchEntityListData = exports.entityPayloadFromItems = exports.entityHref = exports.enrichEntitiesFromPayload = exports.PLATFORM_ENTITY_TYPES = exports.LIST_ITEMS_ENDPOINT = void 0;
|
|
5
5
|
exports.getEntityExtractor = getEntityExtractor;
|
|
6
|
-
exports.readCurrencyCode = exports.normalizeEntityItem = exports.mergeEntityData = exports.listEntityItems = exports.isProductFamilyEntityType = void 0;
|
|
6
|
+
exports.readCurrencyCode = exports.normalizeEntityItem = exports.mergeEntityData = exports.listEntityItems = exports.isProductFamilyEntityType = exports.isDocumentFamilyEntityType = void 0;
|
|
7
7
|
exports.registerEntityExtractor = registerEntityExtractor;
|
|
8
|
-
exports.transformToSolutionEntityData = exports.transformToGenericEntityData = exports.transformToBlogPostEntityData = exports.toMatchedOptions = exports.toCatalogPath = void 0;
|
|
8
|
+
exports.transformToSolutionEntityData = exports.transformToGenericEntityData = exports.transformToBlogPostEntityData = exports.toMatchedOptions = exports.toCatalogPath = exports.resolveEntityTypeConfig = void 0;
|
|
9
9
|
var _defaultExtractor = require("./defaultExtractor");
|
|
10
10
|
exports.defaultExtractor = _defaultExtractor.defaultExtractor;
|
|
11
11
|
exports.transformToSolutionEntityData = _defaultExtractor.transformToSolutionEntityData;
|
|
@@ -21,6 +21,10 @@ exports.entityPayloadFromItems = _entityPayload.entityPayloadFromItems;
|
|
|
21
21
|
exports.toCatalogPath = _entityPayload.toCatalogPath;
|
|
22
22
|
var _entityFamily = require("./entityFamily");
|
|
23
23
|
exports.isProductFamilyEntityType = _entityFamily.isProductFamilyEntityType;
|
|
24
|
+
exports.isDocumentFamilyEntityType = _entityFamily.isDocumentFamilyEntityType;
|
|
25
|
+
var _entityTypeDefaults = require("./entityTypeDefaults");
|
|
26
|
+
exports.PLATFORM_ENTITY_TYPES = _entityTypeDefaults.PLATFORM_ENTITY_TYPES;
|
|
27
|
+
exports.resolveEntityTypeConfig = _entityTypeDefaults.resolveEntityTypeConfig;
|
|
24
28
|
var _mergeEntityData = require("./mergeEntityData");
|
|
25
29
|
exports.mergeEntityData = _mergeEntityData.mergeEntityData;
|
|
26
30
|
var _matchedVariant = require("./matchedVariant");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_defaultExtractor","require","exports","defaultExtractor","transformToSolutionEntityData","transformToBlogPostEntityData","transformToGenericEntityData","_enrichEntitiesFromPayload","enrichEntitiesFromPayload","_entityHref","entityHref","_entityPayload","normalizeEntityItem","entityPayloadFromItems","toCatalogPath","_entityFamily","isProductFamilyEntityType","_mergeEntityData","mergeEntityData","_matchedVariant","toMatchedOptions","formatMoney","readCurrencyCode","formatPriceField","formatProductPriceLabel","_fetchEntityListData","fetchEntityListData","_listEntityItems","listEntityItems","LIST_ITEMS_ENDPOINT","extractorRegistry","getEntityExtractor","clientId","registerEntityExtractor","extractor"],"sources":["../../../src/entity/index.ts"],"sourcesContent":["import type { EntityExtractor } from './types';\nimport { defaultExtractor } from './defaultExtractor';\n\nexport {\n defaultExtractor,\n transformToSolutionEntityData,\n transformToBlogPostEntityData,\n transformToGenericEntityData,\n} from './defaultExtractor';\n\nexport { enrichEntitiesFromPayload } from './enrichEntitiesFromPayload';\nexport { entityHref } from './entityHref';\nexport {\n normalizeEntityItem,\n entityPayloadFromItems,\n toCatalogPath,\n} from './entityPayload';\nexport {
|
|
1
|
+
{"version":3,"names":["_defaultExtractor","require","exports","defaultExtractor","transformToSolutionEntityData","transformToBlogPostEntityData","transformToGenericEntityData","_enrichEntitiesFromPayload","enrichEntitiesFromPayload","_entityHref","entityHref","_entityPayload","normalizeEntityItem","entityPayloadFromItems","toCatalogPath","_entityFamily","isProductFamilyEntityType","isDocumentFamilyEntityType","_entityTypeDefaults","PLATFORM_ENTITY_TYPES","resolveEntityTypeConfig","_mergeEntityData","mergeEntityData","_matchedVariant","toMatchedOptions","formatMoney","readCurrencyCode","formatPriceField","formatProductPriceLabel","_fetchEntityListData","fetchEntityListData","_listEntityItems","listEntityItems","LIST_ITEMS_ENDPOINT","extractorRegistry","getEntityExtractor","clientId","registerEntityExtractor","extractor"],"sources":["../../../src/entity/index.ts"],"sourcesContent":["import type { EntityExtractor } from './types';\nimport { defaultExtractor } from './defaultExtractor';\n\nexport {\n defaultExtractor,\n transformToSolutionEntityData,\n transformToBlogPostEntityData,\n transformToGenericEntityData,\n} from './defaultExtractor';\n\nexport { enrichEntitiesFromPayload } from './enrichEntitiesFromPayload';\nexport { entityHref } from './entityHref';\nexport {\n normalizeEntityItem,\n entityPayloadFromItems,\n toCatalogPath,\n} from './entityPayload';\nexport {\n isProductFamilyEntityType,\n isDocumentFamilyEntityType,\n} from './entityFamily';\nexport {\n PLATFORM_ENTITY_TYPES,\n resolveEntityTypeConfig,\n} from './entityTypeDefaults';\nexport { mergeEntityData } from './mergeEntityData';\nexport {\n toMatchedOptions,\n formatMoney,\n readCurrencyCode,\n formatPriceField,\n formatProductPriceLabel,\n type MatchedOption,\n type ProductPriceFields,\n} from './matchedVariant';\nexport {\n fetchEntityListData,\n type FetchEntityListDataOptions,\n} from './fetchEntityListData';\nexport {\n listEntityItems,\n LIST_ITEMS_ENDPOINT,\n type ListEntityItemsOptions,\n} from './listEntityItems';\n\nexport type { EntityExtractor } from './types';\n\n/**\n * Registry of client-specific entity extractors.\n * Only needed if a client requires custom extraction logic beyond the config-driven default.\n */\nconst extractorRegistry: Record<string, EntityExtractor> = {};\n\n/**\n * Get the entity extractor for a specific client.\n * The default extractor is config-driven and works for any client with entityConfig.\n */\nexport function getEntityExtractor(clientId?: string): EntityExtractor {\n if (clientId && extractorRegistry[clientId]) {\n return extractorRegistry[clientId];\n }\n return defaultExtractor;\n}\n\n/**\n * Register a custom entity extractor for a client\n * Useful for runtime registration or testing\n */\nexport function registerEntityExtractor(\n clientId: string,\n extractor: EntityExtractor,\n): void {\n extractorRegistry[clientId] = extractor;\n}\n"],"mappings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AAG,gBAAA;AAAAxB,OAAA,CAAAyB,gBAAA,GAAAJ,eAAA,CAAAI,gBAAA;AAAAzB,OAAA,CAAA0B,uBAAA,GAAAL,eAAA,CAAAK,uBAAA;AAC1B,IAAAC,oBAAA,GAAA5B,OAAA;AAG+BC,OAAA,CAAA4B,mBAAA,GAAAD,oBAAA,CAAAC,mBAAA;AAC/B,IAAAC,gBAAA,GAAA9B,OAAA;AAI2BC,OAAA,CAAA8B,eAAA,GAAAD,gBAAA,CAAAC,eAAA;AAAA9B,OAAA,CAAA+B,mBAAA,GAAAF,gBAAA,CAAAE,mBAAA;AAI3B;AACA;AACA;AACA;AACA,MAAMC,iBAAkD,GAAG,CAAC,CAAC;;AAE7D;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAACC,QAAiB,EAAmB;EACrE,IAAIA,QAAQ,IAAIF,iBAAiB,CAACE,QAAQ,CAAC,EAAE;IAC3C,OAAOF,iBAAiB,CAACE,QAAQ,CAAC;EACpC;EACA,OAAOjC,kCAAgB;AACzB;;AAEA;AACA;AACA;AACA;AACO,SAASkC,uBAAuBA,CACrCD,QAAgB,EAChBE,SAA0B,EACpB;EACNJ,iBAAiB,CAACE,QAAQ,CAAC,GAAGE,SAAS;AACzC","ignoreList":[]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.writeProductBackHandoff = exports.validatePatternWithBlocks = void 0;
|
|
4
|
+
exports.WEB5_USER_QUERY_EVENT = exports.WEB5_SCOPES = exports.WEB5_SCOPE = exports.WEB5_ROOT_ID = exports.WEB5_ROOT_CLASS = exports.WEB5_REDIRECT_EVENT = exports.WEB5_GLOBAL_TOKENS = exports.WEB5_ANSWER_UPDATED_EVENT = exports.WEB5_ANSWER_SETTLED_EVENT = exports.UserQueryProvider = exports.UserQuery = exports.UnifiedMarkdownParser = exports.UnifiedLink = exports.UNKNOWN_CONSENT = exports.TextBlockSectionDefinition = exports.TableRow = exports.TableHeader = exports.TableHead = exports.TableFooter = exports.TableCell = exports.TableCaption = exports.TableBody = exports.Table = exports.TOKEN_NAME_PATTERN = exports.THEME_TOKEN_CONTRACT = exports.THEME_OVERRIDE_TOKENS = exports.THEME_DEBUG_QUERY_PARAM = exports.THEME_DEBUG_KEY = exports.TEMPLATES_MANIFEST_URL = exports.TEMPLATES_CDN_BASE = exports.SmartIcon = exports.SkipNodesSectionDefinition = exports.ShopifyStorefrontClient = exports.SectionSkeleton = exports.SearchSectionDefinition = exports.SearchSection = exports.STREAMING_TIMEOUT_MS = exports.REFRESH_PROMPTS_WINDOW_MS = exports.REFRESH_PROMPTS_UNTIL_KEY = exports.PromptEntryEmptyState = exports.PlacementSmoothHeight = exports.PlacementResponseRenderer = exports.PlacementPayloadProvider = exports.PlacementLoader = exports.PRODUCT_BY_HANDLE_QUERY = exports.PRODUCT_BACK_SESSION_KEY = exports.PLATFORM_ENTITY_TYPES = exports.OptimizedImage = exports.NextStepsSectionDefinition = exports.MetricsSectionDefinition = exports.MarkdownText = exports.MATCH_DEBUG_QUERY_PARAM = exports.MATCH_DEBUG_KEY = exports.Loader = exports.ListItemsSectionDefinition = exports.LinkType = exports.LIST_ITEMS_ENDPOINT = exports.KpiSectionDefinition = exports.ImageSlotProvider = exports.ImageSearchFilterToken = exports.HtmlCommentSectionDefinition = exports.HeroSectionDefinition = exports.HeroEntitySectionDefinition = exports.HOST_CONSENT_GLOBAL = exports.FeedbackBar = exports.FeatureToggleProvider = exports.FeatureSection9PlusDefinition = exports.FeatureCardsSectionDefinition = exports.FallbackSectionDefinition = exports.ErrorSectionDefinition = exports.EntitySectionDefinition = exports.EntityCollectionSectionDefinition = exports.EXPERIMENT_IDS = exports.ERROR_MARKDOWN = exports.EDITABLE_TOKENS = exports.Disclaimer = exports.DiagnosticsCollector = exports.DROP_SECTION = exports.DIAGNOSTIC_TYPES = exports.DEFAULT_ERROR_TEMPLATES = exports.DEFAULT_BACKEND_ENVIRONMENT = exports.CtaBannerSectionDefinition = exports.ComponentTracking = exports.ComponentRegistry = exports.ComponentDependenciesProvider = exports.ComparisonSectionDefinition = exports.ChipsProvider = exports.CalloutSectionDefinition = exports.CalloutBlock = exports.CONSENT_OVERRIDE_QUERY_PARAM = exports.CONSENT_OVERRIDE_KEY = exports.COLLECTION_BY_HANDLE_QUERY = exports.CLIENT_IDS = exports.CALLOUT_SEMANTICS = exports.CALLOUT_KINDS = exports.BottomContainer = exports.BRAND_TOKENS = exports.BACKEND_ENVIRONMENT_QUERY_PARAM = exports.BACKEND_ENVIRONMENT_KEY = exports.ARTICLE_BY_HANDLE_QUERY = void 0;
|
|
5
|
+
exports.isSimulationTraffic = exports.isShopifyHost = exports.isProductFamilyEntityType = exports.isOneTrustHost = exports.isNavigableUrl = exports.isMatchDebugEnabled = exports.isLegacyUrl = exports.isHtmlComment = exports.isHslTriplet = exports.isEntityLink = exports.isDocumentFamilyEntityType = exports.installConsentProvider = exports.initConsentGate = exports.hslTripletToHex = exports.hslToRgb = exports.hostAliasFor = exports.hexToHslTriplet = exports.hasImage = exports.hasHostSuppliedConsent = exports.hasAnalyticsConsent = exports.getTemplateOverride = exports.getSessionId = exports.getResizedImageUrl = exports.getRefreshPromptsExpiry = exports.getPartsByType = exports.getPartByRole = exports.getOrCreateSessionId = exports.getLinks = exports.getIntentFromMarkdown = exports.getInstalledProviderName = exports.getImages = exports.getHeading = exports.getGateView = exports.getForwardStack = exports.getErrorTypeFromStatus = exports.getEntityExtractor = exports.getContextualImageFilename = exports.getConsentSnapshot = exports.getConsentOverride = exports.getConsentGateStats = exports.getClientBundleOverride = exports.getChatId = exports.getBackendEnvironment = exports.getAllByRole = exports.generateSectionId = exports.generateId = exports.formatProductPriceLabel = exports.formatPriceField = exports.formatMoney = exports.fixMalformedLinks = exports.findKeywordsInContent = exports.findInvalidWeb5Links = exports.findImageInNode = exports.findImageInChildren = exports.fetchProductsByHandlesMap = exports.fetchProductsByHandles = exports.fetchEntityListData = exports.extractProtocol = exports.extractLinkMetadata = exports.extractIntentFromMarkdown = exports.extractContentMarkdown = exports.extractContent = exports.escapeWeb5Links = exports.entityPayloadFromItems = exports.entityHref = exports.ensureMinLightness = exports.enrichEntitiesFromPayload = exports.enableRefreshPrompts = exports.disableRefreshPrompts = exports.detectLinkType = exports.detectConsentProvider = exports.deriveRole = exports.deriveLightColor = exports.deriveDarkGradient = exports.deriveDarkColor = exports.defaultExtractor = exports.decodeLinkText = exports.createWixAuthFetch = exports.createShopifyConsentProvider = exports.createSdkRegistry = exports.createPageSection = exports.createOneTrustConsentProvider = exports.createHostSuppliedConsentProvider = exports.createFeatureToggleReader = exports.createErrorMarkdown = exports.convertToBlockElementsWithMapping = exports.convertToBlockElements = exports.computeContentBBox = exports.composeSemantic = exports.cn = exports.clearForwardStack = exports.buildProbeUrl = exports.buildPlacementDependencies = exports.buildImageSearchFilter = exports.bucketOf = exports.backgroundFilter = exports.applyThemeOverrides = exports.analyzeBackdrop = exports.addToCart = exports.Web5UrlType = void 0;
|
|
6
|
+
exports.usesStagingBackend = exports.useWeb5Link = exports.useUserQuery = exports.useResolvedImageSources = exports.useResolveShopifyEntityData = exports.useResolveSearchSpringEntityData = exports.useResolveGenericEntityData = exports.usePlacementPayload = exports.useMarkdownUtils = exports.useImageSlotCollector = exports.useImageSlot = exports.useFeatureToggles = exports.useFeatureToggle = exports.useEntityTransforms = exports.useDebugImageContext = exports.useConversation = exports.useComponentDependencies = exports.useChips = exports.unlockOnUserAction = exports.tryParseComponent = exports.trimTrailingWhitespace = exports.transmit = exports.transformToSolutionEntityData = exports.transformToGenericEntityData = exports.transformToBlogPostEntityData = exports.transformShopifyProduct = exports.transformShopifyEntityToItemData = exports.transformShopifyCollection = exports.transformShopifyArticle = exports.transformSSProductToEntityItemData = exports.toRgb = exports.toMatchedOptions = exports.toCatalogPath = exports.subscribeToConsent = exports.stripMarkdown = exports.startNewChatId = exports.shouldRefreshPrompts = exports.setMatchDebug = exports.setForwardStack = exports.setConsentOverride = exports.setConsentBufferLimit = exports.setChatId = exports.setBackendEnvironment = exports.rgbToHsl = exports.resolveShopifyEntity = exports.resolveShopifyConfig = exports.resolveErrorTemplate = exports.resolveEntityTypeConfig = exports.resolveClientBundleUrl = exports.resetMatchDebugCache = exports.resetConsentGateForTests = exports.resetChatIdForTests = exports.registerEntityExtractor = exports.readProductBackHandoff = exports.readCurrencyCode = exports.pushToForwardStack = exports.pushPromptSubmit = exports.pushLinkClick = exports.pushExit = exports.pushEvent = exports.pushError = exports.pushEntityFiltered = exports.publishHostConsent = exports.preprocessMarkdown = exports.popFromForwardStack = exports.parseWeb5Url = exports.parseMarkdownToComponents = exports.parseMarkdownToAst = exports.parseEntityLink = exports.parseAstToMarkdown = exports.normalizeImageUrl = exports.normalizeIconUrls = exports.normalizeEntityItem = exports.nodesToParts = exports.mergeSectionsWithStableReferences = exports.mergeEntityData = exports.mergeClientConfig = exports.mayTransmit = exports.mayPersistIdentity = exports.matchMarkdown = exports.matchAllSections = exports.logMatchDebug = exports.loadImagePixels = exports.loadClientBundle = exports.loadBackdropAnalysis = exports.listEntityItems = exports.isWeb5Url = exports.isWeb5SearchUrl = exports.isWeb5ImageUrl = exports.isWeb5IconUrl = exports.isWeb5EntityUrl = exports.isWeb5AskUrl = exports.isWeb5ActionUrl = exports.isValidWeb5Url = exports.isValidTemplateId = exports.isValidLinkUrl = exports.isUserEngaged = exports.isTrustedBundleHost = exports.isThemeDebugEnabled = exports.isTemplatePickerRequested = void 0;
|
|
7
|
+
exports.writeProductBackHandoff = exports.validatePatternWithBlocks = exports.validatePatternSyntax = exports.validatePattern = exports.validateLinkUrl = void 0;
|
|
8
8
|
var _clients = require("./clients");
|
|
9
9
|
exports.CLIENT_IDS = _clients.CLIENT_IDS;
|
|
10
10
|
exports.EXPERIMENT_IDS = _clients.EXPERIMENT_IDS;
|
|
@@ -122,6 +122,9 @@ exports.readCurrencyCode = _entity.readCurrencyCode;
|
|
|
122
122
|
exports.formatPriceField = _entity.formatPriceField;
|
|
123
123
|
exports.formatProductPriceLabel = _entity.formatProductPriceLabel;
|
|
124
124
|
exports.isProductFamilyEntityType = _entity.isProductFamilyEntityType;
|
|
125
|
+
exports.isDocumentFamilyEntityType = _entity.isDocumentFamilyEntityType;
|
|
126
|
+
exports.PLATFORM_ENTITY_TYPES = _entity.PLATFORM_ENTITY_TYPES;
|
|
127
|
+
exports.resolveEntityTypeConfig = _entity.resolveEntityTypeConfig;
|
|
125
128
|
var _callout = require("./types/callout");
|
|
126
129
|
exports.CALLOUT_KINDS = _callout.CALLOUT_KINDS;
|
|
127
130
|
exports.CALLOUT_SEMANTICS = _callout.CALLOUT_SEMANTICS;
|