From 9a60a88629706685b109f4943a4aa9c2d1d50d4c Mon Sep 17 00:00:00 2001 From: JOY <5027251+JOY@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:16:38 +0700 Subject: [PATCH 1/2] fix(importer): remove unsourced seed templates and tighten 1758 test - Replace unsourced "6.0, A2DP, LE" Bluetooth text on iPhone 18 Pro, iPhone 18 Pro Max, and Galaxy S26 Ultra with sourced versions ("6" and "6.0") in flagship-seed-sourced-2026.ts and product-normalizer.ts (#1803 item 6). - Replace unsourced 5G band labels on iPad Pro M5 and Apple Watch Ultra 3 with official Apple NR band lists and field-level sources. - Drop remaining unsourced Bluetooth profile strings, CE/FCC/QCVN certifications, and cross-category laptop camera and Wi-Fi-only cellular placeholders across flagship-seed-data.ts, recording every removed seed field in retract_spec_fields. - Require field-level sources[path] in seed-template-values-1758.test.ts so group-level sources. cannot mask template or placeholder values (#1855). --- .../__tests__/seed-earbuds-gpu-1793.test.ts | 13 +- .../seed-template-values-1758.test.ts | 446 ++++++++++++++++-- .../shopee/__tests__/sourced-seeds.test.ts | 4 +- .../importer/src/shopee/flagship-seed-data.ts | 207 ++++---- .../src/shopee/flagship-seed-sourced-2026.ts | 10 +- .../importer/src/shopee/product-normalizer.ts | 6 +- apps/importer/src/shopee/test-ai-enricher.ts | 16 +- 7 files changed, 549 insertions(+), 153 deletions(-) diff --git a/apps/importer/src/shopee/__tests__/seed-earbuds-gpu-1793.test.ts b/apps/importer/src/shopee/__tests__/seed-earbuds-gpu-1793.test.ts index baf23fb4d..23c80caff 100644 --- a/apps/importer/src/shopee/__tests__/seed-earbuds-gpu-1793.test.ts +++ b/apps/importer/src/shopee/__tests__/seed-earbuds-gpu-1793.test.ts @@ -119,6 +119,12 @@ const STORED_TEMPLATE_TEXT = { technology: 'Bluetooth 5.3 + Ultra Wideband (U1)', sim_type: 'Wireless Audio Accessory', }, + connectivity: { + bluetooth: '5.4, A2DP, LE', + }, + regulatory: { + certifications: 'CE, FCC, RoHS, QCVN', + }, battery: { capacity_mah: 1 }, }, key_specs: { @@ -157,6 +163,7 @@ const RETRACTED_EVERYWHERE = [ 'connectivity.nfc', 'cellular.has_5g', 'multimedia.headphone_jack_35mm', + 'regulatory.certifications', ]; // The fields only some earlier seeds set. @@ -169,11 +176,12 @@ const RETRACTED_ALSO: Record = { 'cellular.volte', 'cellular.vowifi', ], - 'apple:airpods-pro-3:standard': ['connectivity.location'], + 'apple:airpods-pro-3:standard': ['connectivity.bluetooth', 'connectivity.location'], 'sony:wf-1000xm5:64gb': [ 'display.ppi', 'display.protection', 'camera.video_recording', + 'connectivity.bluetooth', 'connectivity.location', 'cellular.volte', 'cellular.vowifi', @@ -182,11 +190,12 @@ const RETRACTED_ALSO: Record = { 'display.ppi', 'display.protection', 'camera.video_recording', + 'connectivity.bluetooth', 'connectivity.location', 'cellular.volte', 'cellular.vowifi', ], - 'sony:wf-1000xm6:standard': [], + 'sony:wf-1000xm6:standard': ['connectivity.bluetooth'], }; test('the backfill removes the stored earbud template text from masters and Items', async () => { diff --git a/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts b/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts index 6259324e5..37c70c288 100644 --- a/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts +++ b/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts @@ -1,28 +1,39 @@ /** - * DOS/Rate#1758: flagship seed and canonical entries carried template values copied from the - * arena spec syncer's old defaults and the normalizer's generic fallbacks, and the backfill - * wrote them to Production. Each one is now a value a cited source states, or gone (with a - * retraction, since the backfill's merge never deletes a stored field). + * DOS/Rate#1758 & DOS/Rate#1855: flagship seed and canonical entries carried template values + * copied from the arena spec syncer's old defaults, the normalizer's generic fallbacks, and + * cross-category placeholders, and the backfill wrote them to Production. Each one is now a + * value an explicit per-field source states, or gone (with a retraction in + * `retract_spec_fields`, since the backfill's merge never deletes a stored field). Group-level + * `sources.` entries never excuse template-shaped or cross-category field values. */ import assert from 'node:assert/strict'; import test from 'node:test'; -import type { ProductSpecifications } from '@repo/shared-data'; +import { ProductSpecificationsSchema, type ProductSpecifications } from '@repo/shared-data'; import { CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY, FLAGSHIP_DEVICES_TO_SEED, flagshipSeedsByItem, + type FlagshipDeviceSeed, } from '../flagship-seed-data.js'; -import { seedMasterSpecUpdate } from '../jobs/backfill-specs.js'; +import { requiredSpecGroups, seedMasterSpecUpdate } from '../jobs/backfill-specs.js'; +import { ProductNormalizer } from '../product-normalizer.js'; +import type { ShopeeProduct } from '../types.js'; interface Entry { key: string; + categorySlug?: FlagshipDeviceSeed['categorySlug']; + has_5g?: boolean; specifications: ProductSpecifications; sources?: Readonly>; } const ENTRIES: Entry[] = [ ...FLAGSHIP_DEVICES_TO_SEED.map(s => ({ ...s, key: s.model_key })), - ...Object.entries(CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY).map(([key, e]) => ({ ...e, key })), + ...Object.entries(CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY).map(([key, e]) => ({ + ...e, + key, + categorySlug: 'smartphones' as const, + })), ]; const at = (specs: ProductSpecifications, path: string): unknown => { @@ -30,9 +41,8 @@ const at = (specs: ProductSpecifications, path: string): unknown => { return (specs as Record | undefined>)[group]?.[field]; }; -// The arena syncer's former page-omitted defaults (removed in DOS/Rate#1754, still in -// `arena-spec-syncer.ts` for the cellular ones) and the normalizer's generic fallbacks. -// A seed may hold one only where its `sources` cite that field. +// The arena syncer's former page-omitted defaults (removed in DOS/Rate#1754) and the +// normalizer's generic fallbacks. const TEMPLATE_VALUES: ReadonlyArray = [ ['regulatory.certifications', 'CE, FCC, RoHS, QCVN (BTTTT Vietnam)'], ['multimedia.audio_features', '24-bit/192kHz Hi-Res & Hi-Res Wireless audio'], @@ -45,32 +55,205 @@ const TEMPLATE_VALUES: ReadonlyArray = [ ['connectivity.bluetooth', '5.3, A2DP, LE'], ]; -// A field counts as sourced when `sources` cites it or its whole group. -const cites = (entry: Entry, path: string): boolean => - Boolean(entry.sources?.[path] ?? entry.sources?.[path.split('.')[0]!]); +const BLUETOOTH_PROFILES_RE = /\b\d+(?:\.\d+)?,\s*A2DP\b/i; +const CERT_CODES_RE = /\b(?:CE|FCC|NCC|KC|VCCI|SRRC|SDPPI|SIRIM|NBTC|IMDA|NTRA)\b|\bQCVN\d*\b/; +const TWO_BAND_NUMBERS_RE = /\bn?\d{1,3}\b.*\bn?\d{1,3}\b/; +const BARE_NEGATIVE_PLACEHOLDER_RE = /^\s*(?:none|no|n\/a)\s*$/i; +const NON_CELLULAR_PLACEHOLDER_RE = /^\s*(?:no\b|none\b|n\/a\b|wi-?fi\b|bluetooth\b)/i; -test('no seed or canonical entry holds an unsourced template value', () => { - for (const entry of ENTRIES) { - for (const [path, value] of TEMPLATE_VALUES) { - if (at(entry.specifications, path) !== value) continue; - assert.ok(cites(entry, path), `${entry.key}: unsourced template ${path} = ${value}`); +const LAPTOP_REAR_CAMERA_PATHS = [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'camera.third_camera', + 'camera.fourth_camera', + 'camera.flash', +] as const; + +const CELLULAR_DETAIL_PATHS = [ + 'cellular.bands_5g', + 'cellular.bands_4g', + 'cellular.bands_3g', + 'cellular.bands_2g', + 'cellular.technology', + 'cellular.data_speed', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', +] as const; + +// DOS/Rate#1855: template-shaped and cross-category values require an explicit field-level +// `sources[path]` URL. A group-level `sources.` never excuses them. +const citesField = (entry: Entry, path: string): boolean => Boolean(entry.sources?.[path]); + +function findTemplateViolations(entry: Entry): string[] { + const issues: string[] = []; + + for (const [path, value] of TEMPLATE_VALUES) { + if (at(entry.specifications, path) === value && !citesField(entry, path)) { + issues.push(`${entry.key}: unsourced template ${path} = ${JSON.stringify(value)}`); } - // The normalizer's Bluetooth shape with any version ("5.4, A2DP, LE"). - const bluetooth = at(entry.specifications, 'connectivity.bluetooth'); - if (typeof bluetooth === 'string' && /^\d+(\.\d+)?, A2DP, LE$/.test(bluetooth)) { - assert.ok(cites(entry, 'connectivity.bluetooth'), `${entry.key}: bluetooth ${bluetooth}`); + } + + const bluetooth = at(entry.specifications, 'connectivity.bluetooth'); + if ( + typeof bluetooth === 'string' && + BLUETOOTH_PROFILES_RE.test(bluetooth) && + !citesField(entry, 'connectivity.bluetooth') + ) { + issues.push(`${entry.key}: unsourced Bluetooth profile connectivity.bluetooth = ${bluetooth}`); + } + + const certifications = at(entry.specifications, 'regulatory.certifications'); + if ( + typeof certifications === 'string' && + CERT_CODES_RE.test(certifications) && + !citesField(entry, 'regulatory.certifications') + ) { + issues.push( + `${entry.key}: unsourced regulatory codes regulatory.certifications = ${certifications}` + ); + } + + const bands5g = at(entry.specifications, 'cellular.bands_5g'); + if (bands5g !== undefined) { + const text = String(bands5g); + const hasExplicitBands = + TWO_BAND_NUMBERS_RE.test(text) && !BARE_NEGATIVE_PLACEHOLDER_RE.test(text); + if (!hasExplicitBands && !citesField(entry, 'cellular.bands_5g')) { + issues.push(`${entry.key}: unsourced 5G band text cellular.bands_5g = ${text}`); + } + if (/SA\/NSA\/Sub6/i.test(text) && !TWO_BAND_NUMBERS_RE.test(text)) { + if (!citesField(entry, 'cellular.bands_5g')) { + issues.push(`${entry.key}: bare SA/NSA/Sub6 cellular.bands_5g = ${text}`); + } + } + } + + if (entry.categorySlug === 'laptops') { + for (const path of LAPTOP_REAR_CAMERA_PATHS) { + const val = at(entry.specifications, path); + if (val !== undefined && !citesField(entry, path)) { + issues.push(`${entry.key}: unsourced laptop rear-camera field ${path} = ${String(val)}`); + } + } + } + + if ( + entry.has_5g === false && + (entry.categorySlug === 'tablets' || entry.categorySlug === 'laptops') + ) { + for (const path of CELLULAR_DETAIL_PATHS) { + const val = at(entry.specifications, path); + if (val !== undefined && !citesField(entry, path)) { + issues.push( + `${entry.key}: unsourced Wi-Fi-only ${entry.categorySlug} cellular field ${path} = ${String(val)}` + ); + } + } + } + + for (const group of ['camera', 'cellular', 'connectivity'] as const) { + const groupObj = entry.specifications[group]; + if (!groupObj || typeof groupObj !== 'object') continue; + for (const [field, val] of Object.entries(groupObj)) { + if (typeof val !== 'string') continue; + const path = `${group}.${field}`; + if (citesField(entry, path)) continue; + if (BARE_NEGATIVE_PLACEHOLDER_RE.test(val)) { + issues.push(`${entry.key}: unsourced placeholder ${path} = ${JSON.stringify(val)}`); + } else if (group === 'cellular' && NON_CELLULAR_PLACEHOLDER_RE.test(val)) { + issues.push( + `${entry.key}: unsourced non-cellular placeholder ${path} = ${JSON.stringify(val)}` + ); + } } } + + return issues; +} + +test('no seed or canonical entry holds an unsourced template or cross-category value', () => { + for (const entry of ENTRIES) { + assert.deepEqual(findTemplateViolations(entry), [], entry.key); + } }); -test('a 5G band field always lists bands', () => { +test('group-level sources never mask template-shaped or cross-category field values (#1855)', () => { + const groupSourcesOnly: Readonly> = { + camera: 'https://www.apple.com/macbook-air/specs/', + cellular: 'https://www.apple.com/ipad-pro/specs/', + connectivity: 'https://www.apple.com/iphone-18-pro/specs/', + multimedia: 'https://www.gsmarena.com/example.php', + regulatory: 'https://www.apple.com/vn/iphone-18-pro/specs/', + }; + + const masked: Entry = { + key: 'test:masked-by-group:256gb', + categorySlug: 'laptops', + has_5g: false, + specifications: { + camera: { + rear_setup: 'None', + second_camera: 'None', + front_camera: '1080p FaceTime HD', + }, + cellular: { + has_5g: false, + bands_5g: 'SA/NSA/Sub6', + sim_type: 'No cellular', + }, + connectivity: { + bluetooth: '6.0, A2DP, LE', + }, + multimedia: { + audio_features: '24-bit/192kHz Hi-Res & Hi-Res Wireless audio', + }, + regulatory: { + certifications: 'CE, FCC, QCVN127', + }, + }, + sources: groupSourcesOnly, + }; + + const violations = findTemplateViolations(masked); + assert.ok(violations.some(v => v.includes('connectivity.bluetooth'))); + assert.ok(violations.some(v => v.includes('regulatory.certifications'))); + assert.ok(violations.some(v => v.includes('cellular.bands_5g'))); + assert.ok(violations.some(v => v.includes('multimedia.audio_features'))); + assert.ok(violations.some(v => v.includes('camera.rear_setup'))); + assert.ok(violations.some(v => v.includes('camera.second_camera'))); + assert.ok(violations.some(v => v.includes('cellular.sim_type'))); + + // Explicit field-level sources clear only the exact cited paths. + const fieldCited: Entry = { + ...masked, + sources: { + ...groupSourcesOnly, + 'camera.rear_setup': 'https://www.apple.com/macbook-air/specs/', + 'camera.second_camera': 'https://www.apple.com/macbook-air/specs/', + 'cellular.bands_5g': 'https://www.apple.com/ipad-pro/specs/', + 'cellular.sim_type': 'https://www.apple.com/ipad-pro/specs/', + 'connectivity.bluetooth': 'https://www.apple.com/iphone-18-pro/specs/', + 'multimedia.audio_features': 'https://www.gsmarena.com/example.php', + 'regulatory.certifications': 'https://www.apple.com/vn/iphone-18-pro/specs/', + }, + }; + assert.deepEqual(findTemplateViolations(fieldCited), []); +}); + +test('a 5G band field lists explicit bands or cites an official field-level source', () => { for (const entry of ENTRIES) { const bands = at(entry.specifications, 'cellular.bands_5g'); if (bands === undefined) continue; - // "SA/NSA/Sub6" with no band number, bare or with a note ("(Snapdragon X75 Modem)"). - if (/SA\/NSA\/Sub6/i.test(String(bands))) { - assert.match(String(bands), /\bn?\d{1,3}\b.*\bn?\d{1,3}\b/, `${entry.key}: ${bands}`); + const text = String(bands); + if (/SA\/NSA\/Sub6/i.test(text)) { + assert.match(text, TWO_BAND_NUMBERS_RE, `${entry.key}: ${text}`); } + assert.ok( + TWO_BAND_NUMBERS_RE.test(text) || citesField(entry, 'cellular.bands_5g'), + `${entry.key}: ${text}` + ); } }); @@ -88,7 +271,7 @@ const byKey = (key: string): Entry => { return found; }; -test('the replaced values are the sourced ones', () => { +test('the replaced values are the sourced ones (seeds and 2026 normalizer registry)', () => { const expected: Record> = { 'apple:iphone-16:128gb': { 'cellular.bands_5g': @@ -135,47 +318,227 @@ test('the replaced values are the sourced ones', () => { }, 'oppo:find-x9-pro:512gb': { 'cellular.sim_type': 'Nano-SIM + Nano-SIM + eSIM' }, 'apple:ipad-pro-m5-11:256gb': { + 'cellular.bands_5g': + '5G NR n1/n2/n3/n5/n7/n8/n12/n14/n20/n25/n26/n28/n29/n30/n38/n40/n41/n48/n66/n70/n71/n75/n77/n78/n79', 'cellular.data_speed': '5G (sub-6 GHz) with 4x4 MIMO, Gigabit LTE with 4x4 MIMO', 'connectivity.bluetooth': '6', }, + 'apple:watch-ultra-3-49mm:64gb': { + 'cellular.bands_5g': + 'FDD-5G NR n1/n2/n3/n5/n7/n8/n12/n14/n20/n25/n26/n28/n66/n71; TDD-5G NR n38/n40/n41/n53', + 'connectivity.bluetooth': '5.3', + }, + 'apple:iphone-18-pro-max:256gb': { 'connectivity.bluetooth': '6' }, + 'apple:iphone-18-pro:256gb': { 'connectivity.bluetooth': '6' }, + 'samsung:galaxy-s26-ultra:256gb': { 'connectivity.bluetooth': '6.0' }, }; for (const [key, fields] of Object.entries(expected)) { const entry = byKey(key); for (const [path, value] of Object.entries(fields)) { assert.equal(at(entry.specifications, path), value, `${key}: ${path}`); - assert.ok(entry.sources?.[path], `${key}: ${path} has no source`); + assert.ok(entry.sources?.[path], `${key}: ${path} has no field-level source`); } } + + // DOS/Rate#1803 item 6: the normalizer registry carries the sourced Bluetooth versions too. + const normalizer = new ProductNormalizer(); + const normalize = (title: string) => + normalizer.normalize({ + itemId: '1', + shopId: '2', + title, + priceMin: 30_000_000, + priceMax: 30_000_000, + priceBeforeDiscount: 0, + currency: 'VND', + stock: 1, + historicalSold: 1, + ratingStar: 5, + ratingCount: 1, + images: [], + models: [], + attributes: [], + shop: { shopId: '2' }, + } as unknown as ShopeeProduct); + + for (const [title, bt] of [ + ['Apple iPhone 18 Pro Max 256GB', '6'], + ['Apple iPhone 18 Pro 256GB', '6'], + ['Samsung Galaxy S26 Ultra 256GB', '6.0'], + ] as const) { + const out = normalize(title).specifications; + assert.equal(out.connectivity?.bluetooth, bt, title); + assert.doesNotMatch(out.connectivity?.bluetooth ?? '', BLUETOOTH_PROFILES_RE, title); + } }); -// Fields no checked source states: dropped from the seed and retracted from stored rows. -const RETRACTED: Record = { - 'samsung:galaxy-a55:256gb': ['cellular.bands_5g', 'connectivity.bluetooth'], +// Fields no checked source states (including cross-category laptop/Wi-Fi placeholders): +// dropped from each seed and listed in `retract_spec_fields` so `seedMasterSpecUpdate` +// removes stale stored copies instead of keeping them on merge. +const RETRACTED_SUBSETS: Record = { + 'samsung:galaxy-s24-ultra:256gb': ['regulatory.certifications'], + 'apple:iphone-16-pro-max:256gb': ['regulatory.certifications'], + 'samsung:galaxy-a55:256gb': [ + 'cellular.bands_5g', + 'connectivity.bluetooth', + 'regulatory.certifications', + ], + 'xiaomi:14-ultra:512gb': ['connectivity.bluetooth', 'regulatory.certifications'], + 'oppo:find-x8:256gb': ['connectivity.bluetooth', 'regulatory.certifications'], + 'apple:ipad-pro-m4-11:256gb': [ + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], + 'apple:macbook-air-m3-13:256gb': [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], + 'apple:iphone-16-pro:256gb': ['regulatory.certifications'], + 'apple:watch-series-10-42mm:64gb': [ + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], + 'apple:airpods-pro-2-usbc:64gb': ['regulatory.certifications'], + 'samsung:galaxy-tab-s10-ultra:256gb': ['regulatory.certifications'], + 'xiaomi:pad-6s-pro:256gb': [ + 'connectivity.bluetooth', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], + 'asus:zenbook-s-14:1024gb': [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + ], + 'lenovo:thinkpad-x1-carbon-gen-12:512gb': [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + ], + 'apple:watch-ultra-2:64gb': ['regulatory.certifications'], + 'samsung:galaxy-watch-ultra:32gb': ['connectivity.bluetooth', 'regulatory.certifications'], + 'garmin:forerunner-265:8gb': ['cellular.volte', 'cellular.vowifi', 'regulatory.certifications'], + 'sony:wf-1000xm5:64gb': ['connectivity.bluetooth', 'regulatory.certifications'], + 'samsung:galaxy-buds3-pro:64gb': ['connectivity.bluetooth', 'regulatory.certifications'], + 'xiaomi:18-pro-max:512gb': ['connectivity.bluetooth', 'regulatory.certifications'], 'xiaomi:17-pro-max:512gb': [ 'cellular.sim_type', + 'connectivity.bluetooth', 'multimedia.audio_features', 'regulatory.certifications', ], - 'xiaomi:pad-7-pro:256gb': ['multimedia.audio_features'], + 'oppo:find-x9-pro:512gb': ['connectivity.bluetooth', 'regulatory.certifications'], + 'apple:ipad-pro-m5-11:256gb': ['regulatory.certifications'], + 'xiaomi:pad-7-pro:256gb': [ + 'cellular.sim_type', + 'cellular.technology', + 'connectivity.bluetooth', + 'multimedia.audio_features', + 'regulatory.certifications', + ], + 'apple:macbook-air-m4-13:256gb': [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.sim_type', + 'cellular.technology', + 'regulatory.certifications', + ], + 'apple:macbook-pro-m4-pro-14:512gb': [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.sim_type', + 'cellular.technology', + 'regulatory.certifications', + ], + 'apple:watch-series-11-46mm:64gb': ['regulatory.certifications'], + 'apple:watch-ultra-3-49mm:64gb': ['regulatory.certifications'], + 'apple:airpods-pro-3:standard': ['connectivity.bluetooth', 'regulatory.certifications'], + 'sony:wf-1000xm6:standard': ['connectivity.bluetooth', 'regulatory.certifications'], }; test('fields no source states are dropped and retracted from stored rows', () => { - for (const [key, paths] of Object.entries(RETRACTED)) { + // Every seed's `retract_spec_fields` is deduplicated and never overlaps a field the seed sets. + for (const seed of FLAGSHIP_DEVICES_TO_SEED) { + const retracted = seed.retract_spec_fields ?? []; + assert.equal(new Set(retracted).size, retracted.length, `${seed.model_key}: duplicate retract`); + for (const path of retracted) { + if (path.startsWith('key_specs.')) { + const keyField = path.slice('key_specs.'.length); + assert.equal( + (seed.key_specs as Record)[keyField], + undefined, + `${seed.model_key} still sets ${path}` + ); + } else { + assert.equal( + at(seed.specifications, path), + undefined, + `${seed.model_key} still sets ${path}` + ); + } + } + } + + const items = flagshipSeedsByItem(); + for (const [key, paths] of Object.entries(RETRACTED_SUBSETS)) { const seed = FLAGSHIP_DEVICES_TO_SEED.find(s => s.model_key === key); assert.ok(seed, key); - assert.deepEqual(seed.retract_spec_fields, paths, key); + const retractedSet = new Set(seed.retract_spec_fields ?? []); for (const path of paths) { + assert.ok(retractedSet.has(path), `${key}: missing retract_spec_fields entry ${path}`); assert.equal(at(seed.specifications, path), undefined, `${key} still sets ${path}`); } - // The Item carries the retraction too. - const item = flagshipSeedsByItem().find(i => key.startsWith(`${i.itemKey}:`)); + + // The Item carries every retraction of its variants too. + const item = items.find(i => key.startsWith(`${i.itemKey}:`)); assert.ok(item, key); - for (const path of paths) assert.ok(item.retract_spec_fields.includes(path), key); + for (const path of paths) { + assert.ok(item.retract_spec_fields.includes(path), `${key}: Item missing ${path}`); + } - // The master update removes the stored template value instead of keeping it. + // `seedMasterSpecUpdate` removes the stale stored template/placeholder values instead of + // keeping them, and the resulting specifications pass schema and 10-group checks. const stored = { specifications: { - cellular: { bands_5g: 'SA/NSA/Sub6', sim_type: 'Dual SIM (Nano-SIM + eSIM)' }, + camera: { + rear_setup: 'None', + main_camera: '1080p Webcam', + second_camera: 'None', + front_camera: '1080p Webcam', + }, + cellular: { + has_5g: false, + bands_5g: 'SA/NSA/Sub6', + technology: 'Wi-Fi Only', + sim_type: 'No cellular', + volte: false, + vowifi: true, + }, connectivity: { bluetooth: '5.3, A2DP, LE' }, multimedia: { audio_features: '24-bit/192kHz Hi-Res & Hi-Res Wireless audio' }, regulatory: { certifications: 'CE, FCC, RoHS, QCVN (BTTTT Vietnam)' }, @@ -188,6 +551,11 @@ test('fields no source states are dropped and retracted from stored rows', () => for (const path of paths) { assert.equal(at(update.specifications, path), undefined, `${key} keeps stored ${path}`); } + const parsed = ProductSpecificationsSchema.safeParse(update.specifications); + assert.equal(parsed.success, true, `${key}: ${parsed.error?.message}`); + for (const grp of requiredSpecGroups(seed.categorySlug)) { + assert.ok(update.specifications[grp], `${key}: missing group ${grp} after retraction`); + } } }); diff --git a/apps/importer/src/shopee/__tests__/sourced-seeds.test.ts b/apps/importer/src/shopee/__tests__/sourced-seeds.test.ts index 963146c6c..0410f1aa0 100644 --- a/apps/importer/src/shopee/__tests__/sourced-seeds.test.ts +++ b/apps/importer/src/shopee/__tests__/sourced-seeds.test.ts @@ -211,9 +211,7 @@ for (const key of [ assert.equal((update as Record).battery_mah, 5000); assert.deepEqual((update as Record).colors, seed.colors); // A seed with nothing to retract keeps its stored label. - const plain = FLAGSHIP_DEVICES_TO_SEED.find( - s => s.model_key === 'samsung:galaxy-s24-ultra:256gb' - )!; + const plain = FLAGSHIP_DEVICES_TO_SEED.find(s => s.model_key === 'apple:iphone-16e:128gb')!; assert.equal('variant_name' in seedMasterSpecUpdate(null, plain), false); } diff --git a/apps/importer/src/shopee/flagship-seed-data.ts b/apps/importer/src/shopee/flagship-seed-data.ts index ffe25aa0d..bb2123f57 100644 --- a/apps/importer/src/shopee/flagship-seed-data.ts +++ b/apps/importer/src/shopee/flagship-seed-data.ts @@ -150,7 +150,6 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< fcc_approval: 'FCC ID BCG-E8692A', sar_head: '1.08 W/kg', sar_body: '1.17 W/kg', - certifications: 'CE, FCC, RoHS, QCVN (Bộ TT&TT Việt Nam)', }, }, key_specs: { @@ -256,7 +255,6 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< fcc_approval: 'FCC ID BCG-E8693A', sar_head: '1.12 W/kg', sar_body: '1.14 W/kg', - certifications: 'CE, FCC, RoHS, QCVN (Bộ TT&TT Việt Nam)', }, }, key_specs: { @@ -358,7 +356,6 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< fcc_approval: 'FCC ID BCG-E8431A', sar_head: '1.12 W/kg', sar_body: '1.14 W/kg', - certifications: 'CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -484,7 +481,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID A3LSMS928U', sar_head: '1.06 W/kg', sar_body: '0.66 W/kg', - certifications: 'CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -500,6 +496,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.bands_5g': 'https://www.samsung.com/vn/smartphones/galaxy-s24-ultra/specs/', 'connectivity.bluetooth': 'https://www.samsung.com/vn/smartphones/galaxy-s24-ultra/specs/', }, + retract_spec_fields: ['regulatory.certifications'], }, // 2. Apple iPhone 16 Pro Max 256GB (Triple Camera + LiDAR Flagship) @@ -606,7 +603,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID BCG-E8695A', sar_head: '1.16 W/kg', sar_body: '1.17 W/kg', - certifications: 'CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -621,6 +617,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.bands_5g': 'https://support.apple.com/vi-vn/121032', 'connectivity.bluetooth': 'https://support.apple.com/en-us/121032', }, + retract_spec_fields: ['regulatory.certifications'], }, // 3. Samsung Galaxy A55 5G 256GB (Mid-range Champion - Triple Camera) @@ -721,7 +718,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID A3LSMA556E', sar_head: '0.68 W/kg', sar_body: '1.04 W/kg', - certifications: 'CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -732,7 +728,11 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ storage: '256GB', ram: '8GB', }, - retract_spec_fields: ['cellular.bands_5g', 'connectivity.bluetooth'], + retract_spec_fields: [ + 'cellular.bands_5g', + 'connectivity.bluetooth', + 'regulatory.certifications', + ], }, // 4. Xiaomi 14 Ultra 5G 16GB/512GB (Quad Camera Leica 1-inch Sensor Flagship) @@ -814,7 +814,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ '8K@24/30fps, 4K@24/30/60/120fps, 1080p@30/60/120/240/480/960/1920fps, gyro-EIS, Dolby Vision HDR 10-bit rec., 4-mic array', }, connectivity: { - bluetooth: '5.4, A2DP, LE, aptX HD, aptX Adaptive, LHDC', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, tri-band, Wi-Fi Direct', usb: 'USB Type-C 3.2 Gen 2 (10Gbps), DisplayPort, OTG', sensors: @@ -843,7 +842,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID 2AFZZPN82G', sar_head: '0.99 W/kg', sar_body: '1.19 W/kg', - certifications: 'CE, FCC, RoHS, TÜV Rheinland Triple Eye Protection, QCVN', }, }, key_specs: { @@ -857,6 +855,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ sources: { 'cellular.bands_5g': 'https://www.mi.com/global/product/xiaomi-14-ultra/specs/', }, + retract_spec_fields: ['connectivity.bluetooth', 'regulatory.certifications'], }, // 5. OPPO Find X8 5G 16GB/256GB (Hasselblad Triple Periscope Flagship) @@ -932,7 +931,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ video_recording: '4K@30/60fps (Dolby Vision 10-bit), 1080p@30/60/240fps, gyro-EIS', }, connectivity: { - bluetooth: '5.4, A2DP, LE, aptX HD, LHDC 5.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6/7, tri-band', usb: 'USB Type-C 3.0, OTG', sensors: @@ -960,7 +958,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'CPH2651', sar_head: '0.98 W/kg', sar_body: '1.12 W/kg', - certifications: 'CE, RoHS, TÜV Rheinland Eye Comfort 4.0, IP69, QCVN', }, }, key_specs: { @@ -975,6 +972,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.bands_5g': 'https://www.oppo.com/vn/smartphones/series-find-x/find-x8/specs/', 'cellular.sim_type': 'https://www.oppo.com/vn/smartphones/series-find-x/find-x8/specs/', }, + retract_spec_fields: ['connectivity.bluetooth', 'regulatory.certifications'], }, // 6. Apple iPad Pro M4 11 inch Wi-Fi 256GB (Tablets Flagship) @@ -1058,10 +1056,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - technology: 'Wi-Fi Only', - sim_type: 'No cellular connectivity (Wi-Fi model)', - volte: false, - vowifi: true, }, multimedia: { loudspeaker: 'Hệ thống 4 loa Four-speaker audio chuẩn phòng thu', @@ -1071,7 +1065,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { fcc_approval: 'FCC ID BCG-A2836', sar_body: '0.95 W/kg', - certifications: 'ENERGY STAR, CE, FCC, QCVN', }, }, key_specs: { @@ -1085,6 +1078,13 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ sources: { 'connectivity.bluetooth': 'https://support.apple.com/en-us/119892', }, + retract_spec_fields: [ + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], }, // 7. Apple MacBook Air 13 inch M3 16GB/256GB (Laptops Flagship) @@ -1149,9 +1149,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ reverse_charging: true, }, camera: { - rear_setup: 'FaceTime HD System', - main_camera: '1080p FaceTime HD camera với bộ xử lý tín hiệu hình ảnh ISP trên chip M3', - second_camera: '3-mic array with directional beamforming (Voice Isolation & Wide Spectrum)', front_camera: '1080p FaceTime HD (f/2.0)', video_recording: '1080p@30fps HD video recording', }, @@ -1166,10 +1163,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - technology: 'Wi-Fi 6E', - sim_type: 'No cellular slot', - volte: false, - vowifi: true, }, multimedia: { loudspeaker: 'Hệ thống 4 loa Four-speaker sound system', @@ -1179,7 +1172,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { fcc_approval: 'FCC ID BCGA3113', - certifications: 'ENERGY STAR, EPEAT Gold, CE, FCC, QCVN', }, }, key_specs: { @@ -1190,6 +1182,16 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ storage: '256GB', ram: '16GB', }, + retract_spec_fields: [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], }, // 8. Apple iPhone 16 Pro 256GB (Compact Flagship - Triple Camera 5x) @@ -1294,7 +1296,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID BCG-E8694A', sar_head: '1.09 W/kg', sar_body: '1.19 W/kg', - certifications: 'CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -1311,6 +1312,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'regulatory.sar_head': 'https://www.apple.com/legal/rfexposure/iphone17,1/en/', 'regulatory.sar_body': 'https://www.apple.com/legal/rfexposure/iphone17,1/en/', }, + retract_spec_fields: ['regulatory.certifications'], }, // 9. Apple Watch Series 10 42mm GPS Viền Nhôm (Smartwatches Flagship) @@ -1390,8 +1392,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - volte: false, - vowifi: true, }, multimedia: { loudspeaker: 'Loa tích hợp phát nhạc trực tiếp (Media playback speaker)', @@ -1402,7 +1402,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID BCG-A2997', sar_head: '0.28 W/kg', sar_body: '0.35 W/kg', - certifications: 'CE, FCC, RoHS, WR50, IP6X, QCVN', }, }, key_specs: { @@ -1426,6 +1425,9 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'key_specs.camera', 'cellular.technology', 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', ], }, @@ -1496,7 +1498,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { fcc_approval: 'FCC ID BCG-A3047 / A3048', sar_head: '0.09 W/kg', - certifications: 'CE, FCC, RoHS, IP54, QCVN', }, }, key_specs: { @@ -1534,6 +1535,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.volte', 'cellular.vowifi', 'multimedia.headphone_jack_35mm', + 'regulatory.certifications', 'key_specs.screen', 'key_specs.camera', 'key_specs.storage', @@ -1636,7 +1638,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { fcc_approval: 'FCC ID A3LSMX926B', sar_body: '0.88 W/kg', - certifications: 'CE, FCC, RoHS, IP68, QCVN', }, }, key_specs: { @@ -1653,6 +1654,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'connectivity.bluetooth': 'https://samsungmobilepress.com/media-assets/galaxy-tab-s10-ultra?tab=specs', }, + retract_spec_fields: ['regulatory.certifications'], }, // 12. Xiaomi Pad 6S Pro 12.4 256GB (Tablet High-Value Flagship) @@ -1725,7 +1727,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ video_recording: '4K@30/60fps, 1080p@30/60fps', }, connectivity: { - bluetooth: '5.3, A2DP, LE, LHDC', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6/7, dual-band, Wi-Fi Direct', usb: 'USB Type-C 3.2 Gen 1, DisplayPort, accessory connector', sensors: 'Fingerprint (side-mounted), accelerometer, gyro, proximity, compass', @@ -1735,10 +1736,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - technology: 'Wi-Fi 7 (802.11be) + Bluetooth 5.3', - sim_type: 'Wi-Fi Only', - volte: false, - vowifi: false, }, multimedia: { loudspeaker: '6 loa Stereo (4 woofer + 2 tweeter)', @@ -1748,7 +1745,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { fcc_approval: 'CE / CMIIT ID 2024AP1092', sar_body: '0.72 W/kg', - certifications: 'CE, RoHS, TÜV Rheinland Low Blue Light, QCVN', }, }, key_specs: { @@ -1759,6 +1755,14 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ storage: '256GB UFS 4.0', ram: '8GB LPDDR5X', }, + retract_spec_fields: [ + 'connectivity.bluetooth', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + 'regulatory.certifications', + ], }, // 13. ASUS Zenbook S 14 OLED UX5406 32GB/1TB (Ultrabook Copilot+ PC Flagship) @@ -1821,9 +1825,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ reverse_charging: true, }, camera: { - rear_setup: 'Dual-Sensor AI Webcam & Ambient Color Array', - main_camera: '1080p FHD ASUS AiSense camera with 3DNR', - second_camera: 'Infrared (IR) depth sensor for Windows Hello + Ambient RGB color sensor', front_camera: '1080p FHD IR Webcam supporting Windows Studio Effects', video_recording: '1080p@30fps với AI Noise-Canceling 3D array microphone', }, @@ -1838,10 +1839,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - technology: 'Wi-Fi 7 (802.11be) + Bluetooth 5.4', - sim_type: 'No Cellular Slot (Wi-Fi 7)', - volte: false, - vowifi: false, }, multimedia: { loudspeaker: 'Hệ thống 4 loa Harman Kardon (2 tweeter + 2 woofer) Smart Amp', @@ -1861,6 +1858,15 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ storage: '1TB PCIe 4.0 NVMe SSD', ram: '32GB LPDDR5X-8533', }, + retract_spec_fields: [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + ], }, // 14. Lenovo ThinkPad X1 Carbon Gen 12 32GB/512GB (Enterprise Ultrabook Flagship) @@ -1925,9 +1931,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ reverse_charging: true, }, camera: { - rear_setup: 'Communications Bar Dual-Sensor Array', - main_camera: 'FHD 1080p MIPI Webcam with Privacy Shutter', - second_camera: 'Discrete Infrared (IR) Camera + Ultrasonic Human Presence Detection', front_camera: '1080p FHD + IR Camera with Computer Vision Presence Detection', video_recording: '1080p@30fps với 2 micro 360 độ tầm xa Dolby Voice', }, @@ -1942,10 +1945,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - technology: 'Wi-Fi 6E / Wi-Fi 7 + WWAN Upgradable option', - sim_type: 'Optional Nano-SIM / eSIM on WWAN SKU', - volte: false, - vowifi: false, }, multimedia: { loudspeaker: 'Stereo speakers (2W x2) hidden under keyboard', @@ -1965,6 +1964,15 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ storage: '512GB PCIe 4.0x4 NVMe SSD', ram: '32GB LPDDR5X', }, + retract_spec_fields: [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.technology', + 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', + ], }, // 15. Apple Watch Ultra 2 49mm GPS + Cellular 64GB (Smartwatch Rugged Flagship) @@ -2062,7 +2070,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID BCG-E8411A', sar_head: '0.48 W/kg', sar_body: '0.35 W/kg', - certifications: 'EN13319 Dive Accessory, MIL-STD 810H, IP6X, CE, FCC, QCVN', }, }, key_specs: { @@ -2086,6 +2093,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'camera.video_recording', 'key_specs.camera', 'hardware.storage_expansion', + 'regulatory.certifications', ], }, @@ -2157,7 +2165,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ // (DOS/Rate#1796). camera: {}, connectivity: { - bluetooth: '5.3, A2DP, AVRCP, HFP, HSP', wlan: 'Wi-Fi 802.11 a/b/g/n, dual-band (2.4GHz + 5GHz)', usb: 'Magnetic Wireless Charging Puck', sensors: @@ -2182,7 +2189,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ fcc_approval: 'FCC ID A3LSML705U', sar_head: '0.32 W/kg', sar_body: '0.68 W/kg', - certifications: 'IP68, 10ATM, MIL-STD-810H, CE, FCC, QCVN', }, }, key_specs: { @@ -2203,6 +2209,8 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'hardware.storage_expansion', // Stray CJK text, and no Samsung spec page value for it (DOS/Rate#1798). 'cellular.technology', + 'connectivity.bluetooth', + 'regulatory.certifications', ], }, @@ -2281,8 +2289,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - volte: false, - vowifi: false, }, multimedia: { loudspeaker: 'Beeper cảnh báo Pace / Nhịp tim + Phát nhạc qua tai nghe Bluetooth', @@ -2291,7 +2297,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { fcc_approval: 'FCC ID IPH-04428', - certifications: '5 ATM, CE, FCC, ANT+ Certified, QCVN', }, }, key_specs: { @@ -2312,7 +2317,10 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'key_specs.camera', 'cellular.technology', 'cellular.sim_type', + 'cellular.volte', + 'cellular.vowifi', 'hardware.storage_expansion', + 'regulatory.certifications', ], }, @@ -2366,7 +2374,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, camera: {}, connectivity: { - bluetooth: '5.3, A2DP, AVRCP, HFP, HSP, TMAP, CSIP, MCP, VCP, CCP (SBC, AAC, LDAC, LC3)', usb: 'USB Type-C port', sensors: 'Bone conduction sensor, IR proximity sensor, gyro head-tracking sensor', other: @@ -2381,7 +2388,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { fcc_approval: 'FCC ID AK8YY2963', - certifications: 'Hi-Res Audio Wireless Certified, IPX4, CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -2410,6 +2416,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'camera.second_camera', 'camera.front_camera', 'camera.video_recording', + 'connectivity.bluetooth', 'connectivity.wlan', 'connectivity.location', 'connectivity.nfc', @@ -2419,6 +2426,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.volte', 'cellular.vowifi', 'multimedia.headphone_jack_35mm', + 'regulatory.certifications', 'key_specs.screen', 'key_specs.camera', 'key_specs.storage', @@ -2477,8 +2485,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, camera: {}, connectivity: { - bluetooth: - '5.4, A2DP, AVRCP, HFP, PBP, TMAP (SSC HiFi, SSC UHQ 24-bit/96kHz, AAC, SBC, LC3)', usb: 'USB Type-C port', sensors: 'Accelerometer, Gyro Sensor, Hall Sensor, Pressure Sensor, Proximity Sensor, Touch Sensor, VPU', @@ -2493,7 +2499,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { fcc_approval: 'FCC ID A3LSMR630', - certifications: 'IP57, Bluetooth 5.4 SIG, CE, FCC, RoHS, QCVN', }, }, key_specs: { @@ -2522,6 +2527,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'camera.second_camera', 'camera.front_camera', 'camera.video_recording', + 'connectivity.bluetooth', 'connectivity.wlan', 'connectivity.location', 'connectivity.nfc', @@ -2531,6 +2537,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.volte', 'cellular.vowifi', 'multimedia.headphone_jack_35mm', + 'regulatory.certifications', 'key_specs.screen', 'key_specs.camera', 'key_specs.storage', @@ -2623,7 +2630,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ technology: 'GSM / HSPA / LTE / 5G', }, connectivity: { - bluetooth: '6.0, A2DP, LE, aptX HD, aptX Adaptive, LHDC 5.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, tri-band, Wi-Fi Direct', usb: 'USB Type-C 3.2 Gen 2, DisplayPort, OTG', nfc: true, @@ -2644,9 +2650,9 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { sar_head: '0.98 W/kg', sar_body: '1.05 W/kg', - certifications: 'CE, FCC, RoHS, TÜV Rheinland Flicker-Free, QCVN (BTTTT Vietnam)', }, }, + retract_spec_fields: ['connectivity.bluetooth', 'regulatory.certifications'], }, { categorySlug: 'smartphones', @@ -2725,7 +2731,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ technology: 'GSM / HSPA / LTE / 5G', }, connectivity: { - bluetooth: '5.4, A2DP, LE, aptX HD, aptX Adaptive, LHDC 5.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, dual-band or tri-band', usb: 'USB Type-C 3.2 Gen 2, DisplayPort, OTG', nfc: true, @@ -2749,6 +2754,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, retract_spec_fields: [ 'cellular.sim_type', + 'connectivity.bluetooth', 'multimedia.audio_features', 'regulatory.certifications', ], @@ -2831,7 +2837,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ technology: 'GSM / HSPA / LTE / 5G', }, connectivity: { - bluetooth: '5.4, A2DP, LE, aptX HD, LHDC 5.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, tri-band', usb: 'USB Type-C 3.2, OTG', nfc: true, @@ -2852,12 +2857,12 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { sar_head: '0.97 W/kg', sar_body: '1.11 W/kg', - certifications: 'CE, RoHS, QCVN (BTTTT Vietnam)', }, }, sources: { 'cellular.sim_type': 'https://www.oppo.com/vn/smartphones/series-find-x/find-x9-pro/specs/', }, + retract_spec_fields: ['connectivity.bluetooth', 'regulatory.certifications'], }, // 29. Apple iPad Pro M5 11 inch 256GB (2025/2026 Flagship Tablet) { @@ -2930,7 +2935,8 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: true, - bands_5g: '5G Sub-6GHz (trên bản Wi-Fi + Cellular)', + bands_5g: + '5G NR n1/n2/n3/n5/n7/n8/n12/n14/n20/n25/n26/n28/n29/n30/n38/n40/n41/n48/n66/n70/n71/n75/n77/n78/n79', bands_4g: 'Gigabit LTE', sim_type: 'eSIM', data_speed: '5G (sub-6 GHz) with 4x4 MIMO, Gigabit LTE with 4x4 MIMO', @@ -2957,13 +2963,14 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { sar_head: '0.98 W/kg', sar_body: '1.12 W/kg', - certifications: 'CE, FCC, Energy Star, QCVN (BTTTT Vietnam)', }, }, sources: { + 'cellular.bands_5g': 'https://www.apple.com/ipad-pro/specs/', 'cellular.data_speed': 'https://www.apple.com/ipad-pro/specs/', 'connectivity.bluetooth': 'https://www.apple.com/ipad-pro/specs/', }, + retract_spec_fields: ['regulatory.certifications'], }, // 30. Xiaomi Pad 7 Pro 256GB (2025/2026 Flagship Android Tablet) { @@ -3036,11 +3043,8 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - sim_type: 'No cellular connectivity (Wi-Fi 7 edition)', - technology: 'Wi-Fi Only', }, connectivity: { - bluetooth: '5.4, A2DP, LE, LHDC 5.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, dual-band, Wi-Fi Direct', usb: 'USB Type-C 3.2 Gen 1, magnetic accessory connector', nfc: true, @@ -3058,14 +3062,19 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { sar_body: '0.89 W/kg', - certifications: 'CE, RoHS, TÜV Low Blue Light, QCVN (BTTTT Vietnam)', }, }, sources: { 'hardware.ram_gb': 'https://www.mi.com/global/product/xiaomi-pad-7-pro/specs/', 'hardware.storage_gb': 'https://www.mi.com/global/product/xiaomi-pad-7-pro/specs/', }, - retract_spec_fields: ['multimedia.audio_features'], + retract_spec_fields: [ + 'cellular.sim_type', + 'cellular.technology', + 'connectivity.bluetooth', + 'multimedia.audio_features', + 'regulatory.certifications', + ], }, // 31. Apple MacBook Air M4 13 inch 256GB (2025/2026 Flagship Ultrabook) { @@ -3117,10 +3126,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ os: 'macOS Sequoia', }, camera: { - rear_setup: 'Dual External 6K Display Engine via Thunderbolt 4', - main_camera: '12MP Center Stage camera with support for Desk View', - second_camera: - 'Desk View Top-Down Workspace Framing + Continuity Camera Wireless iPhone Array', video_recording: '1080p HD video recording with Advanced ISP', front_camera: '12MP Center Stage 1080p FaceTime HD camera', }, @@ -3142,8 +3147,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - sim_type: 'No cellular (Continuity Instant Hotspot via iPhone)', - technology: 'Wi-Fi 6E + Bluetooth 5.3', }, connectivity: { bluetooth: '5.3', @@ -3163,10 +3166,16 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ status: 'Available. Released 2025, March 12', prices_msrp: '26.990.000₫', }, - regulatory: { - certifications: 'ENERGY STAR, EPEAT Gold, CE, FCC, QCVN (BTTTT Vietnam)', - }, + regulatory: {}, }, + retract_spec_fields: [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.sim_type', + 'cellular.technology', + 'regulatory.certifications', + ], }, // 32. Apple MacBook Pro M4 Pro 14 inch 512GB (2025/2026 Flagship Workstation Laptop) { @@ -3214,10 +3223,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ os: 'macOS Sequoia', }, camera: { - rear_setup: '3x Thunderbolt 5 (120Gb/s) + HDMI 2.1 (8K@60Hz / 4K@240Hz) + SDXC', - main_camera: '12MP Center Stage camera with Desk View support', - second_camera: - 'Desk View Top-Down Workspace Framing + Studio-Quality 3-Mic Directional Array', video_recording: '1080p HD video recording with computational video ISP', front_camera: '12MP Center Stage 1080p FaceTime HD camera', }, @@ -3239,8 +3244,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: false, - sim_type: 'No cellular', - technology: 'Wi-Fi 6E + Bluetooth 5.3', }, connectivity: { bluetooth: '5.3', @@ -3259,10 +3262,16 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ status: 'Available. Released 2024, November 08', prices_msrp: '49.990.000₫', }, - regulatory: { - certifications: 'ENERGY STAR, EPEAT Gold, CE, FCC, QCVN (BTTTT Vietnam)', - }, + regulatory: {}, }, + retract_spec_fields: [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'cellular.sim_type', + 'cellular.technology', + 'regulatory.certifications', + ], }, // 33. Apple Watch Series 11 46mm GPS 64GB (2025/2026 Flagship Smartwatch) { @@ -3356,7 +3365,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { sar_head: '0.32 W/kg', sar_body: '0.45 W/kg', - certifications: 'FDA Cleared ECG & Sleep Apnea, CE, FCC, QCVN (BTTTT Vietnam)', }, }, sources: { @@ -3373,6 +3381,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'key_specs.camera', 'cellular.technology', 'cellular.sim_type', + 'regulatory.certifications', ], }, // 34. Apple Watch Ultra 3 49mm 64GB (2025/2026 Flagship Adventure Smartwatch) @@ -3442,7 +3451,8 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: { has_5g: true, - bands_5g: '5G RedCap + LTE + Satellite Emergency SOS', + bands_5g: + 'FDD-5G NR n1/n2/n3/n5/n7/n8/n12/n14/n20/n25/n26/n28/n66/n71; TDD-5G NR n38/n40/n41/n53', sim_type: 'eSIM', technology: 'GSM / HSPA / LTE / 5G RedCap / Satellite', }, @@ -3469,10 +3479,10 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ regulatory: { sar_head: '0.38 W/kg', sar_body: '0.52 W/kg', - certifications: 'MIL-STD-810H, EN13319 Dive Certified, CE, FCC, QCVN (BTTTT Vietnam)', }, }, sources: { + 'cellular.bands_5g': 'https://support.apple.com/en-us/125095', 'connectivity.bluetooth': 'https://support.apple.com/en-us/125095', }, // Health sensors as cameras (DOS/Rate#1796). @@ -3483,6 +3493,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'camera.front_camera', 'camera.video_recording', 'key_specs.camera', + 'regulatory.certifications', ], }, // 35. Apple AirPods Pro 3 USB-C (2025/2026 Flagship ANC Earbuds) @@ -3533,7 +3544,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: {}, connectivity: { - bluetooth: '5.4, A2DP, LE Audio, AAC-ELD, Apple Lossless Audio Protocol', usb: 'USB Type-C', sensors: 'In-ear heart rate sensor, in-ear temperature sensor, skin-detect sensor, motion-detecting accelerometer, speech-detecting accelerometer', @@ -3550,7 +3560,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { sar_head: '0.09 W/kg', - certifications: 'FDA OTC Hearing Aid Authorized, IP54, CE, FCC, QCVN (BTTTT Vietnam)', }, }, // Template text an earlier version of this seed wrote: a display, cameras, a cellular @@ -3575,10 +3584,12 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.has_5g', 'cellular.sim_type', 'cellular.technology', + 'connectivity.bluetooth', 'connectivity.wlan', 'connectivity.nfc', 'connectivity.location', 'multimedia.headphone_jack_35mm', + 'regulatory.certifications', 'key_specs.screen', 'key_specs.ram', 'key_specs.storage', @@ -3640,7 +3651,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, cellular: {}, connectivity: { - bluetooth: '5.4, A2DP, AVRCP, HFP, HSP, TMAP, CSIP, MCP, VCP, CCP (SBC, AAC, LDAC, LC3)', usb: 'USB Type-C + Qi Wireless Charging', sensors: 'Bone conduction sensor, dual proximity sensors, gyro/accelerometer for head gestures', @@ -3657,7 +3667,6 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, regulatory: { sar_head: '0.08 W/kg', - certifications: 'Hi-Res Audio Wireless Certified, IPX4, CE, FCC, QCVN (BTTTT Vietnam)', }, }, // Template text an earlier version of this seed wrote: a display, cameras, a cellular @@ -3682,9 +3691,11 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ 'cellular.has_5g', 'cellular.sim_type', 'cellular.technology', + 'connectivity.bluetooth', 'connectivity.wlan', 'connectivity.nfc', 'multimedia.headphone_jack_35mm', + 'regulatory.certifications', 'key_specs.screen', 'key_specs.ram', 'key_specs.storage', diff --git a/apps/importer/src/shopee/flagship-seed-sourced-2026.ts b/apps/importer/src/shopee/flagship-seed-sourced-2026.ts index 025b3738c..5759d2328 100644 --- a/apps/importer/src/shopee/flagship-seed-sourced-2026.ts +++ b/apps/importer/src/shopee/flagship-seed-sourced-2026.ts @@ -102,7 +102,7 @@ export const SOURCED_SEEDS_2026: FlagshipDeviceSeed[] = [ sim_type: 'Nano-SIM + eSIM (dual eSIM supported)', }, connectivity: { - bluetooth: '6.0, A2DP, LE', + bluetooth: '6', wlan: 'Wi-Fi 7 (802.11be) 2x2 MIMO, tri-band, hotspot (Apple N1 wireless chip)', usb: 'USB-C, USB 3 (up to 10Gb/s), DisplayPort', nfc: true, @@ -145,6 +145,7 @@ export const SOURCED_SEEDS_2026: FlagshipDeviceSeed[] = [ 'cellular.sim_type': 'https://www.apple.com/vn/iphone-18-pro/specs/', 'cellular.technology': 'https://www.apple.com/iphone-18-pro/specs/', connectivity: 'https://www.apple.com/iphone-18-pro/specs/', + 'connectivity.bluetooth': 'https://www.apple.com/iphone-18-pro/specs/', multimedia: 'https://www.gsmarena.com/apple_iphone_18_pro_max-14716.php', 'availability.announced': 'https://www.gsmarena.com/apple_iphone_18_pro_max-14716.php', 'availability.vn_sale_date': 'https://cellphones.com.vn/iphone-18-pro.html', @@ -255,7 +256,7 @@ export const SOURCED_SEEDS_2026: FlagshipDeviceSeed[] = [ sim_type: 'Nano-SIM + eSIM (dual eSIM supported)', }, connectivity: { - bluetooth: '6.0, A2DP, LE', + bluetooth: '6', wlan: 'Wi-Fi 7 (802.11be) 2x2 MIMO, tri-band, hotspot (Apple N1 wireless chip)', usb: 'USB-C, USB 3 (up to 10Gb/s), DisplayPort', nfc: true, @@ -297,6 +298,7 @@ export const SOURCED_SEEDS_2026: FlagshipDeviceSeed[] = [ 'cellular.sim_type': 'https://www.apple.com/vn/iphone-18-pro/specs/', 'cellular.technology': 'https://www.apple.com/iphone-18-pro/specs/', connectivity: 'https://www.apple.com/iphone-18-pro/specs/', + 'connectivity.bluetooth': 'https://www.apple.com/iphone-18-pro/specs/', multimedia: 'https://www.gsmarena.com/apple_iphone_18_pro_5g-14934.php', 'availability.announced': 'https://www.gsmarena.com/apple_iphone_18_pro_5g-14934.php', 'availability.vn_sale_date': 'https://cellphones.com.vn/iphone-18-pro.html', @@ -415,7 +417,7 @@ export const SOURCED_SEEDS_2026: FlagshipDeviceSeed[] = [ sim_type: 'Nano-SIM + Nano-SIM + eSIM (max 2 at a time) (International)', }, connectivity: { - bluetooth: '6.0, A2DP, LE', + bluetooth: '6.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, tri-band, Wi-Fi Direct', usb: 'USB Type-C 3.2, DisplayPort 1.2, OTG', sensors: @@ -454,6 +456,8 @@ export const SOURCED_SEEDS_2026: FlagshipDeviceSeed[] = [ 'https://fptshop.com.vn/dien-thoai/samsung-galaxy-s26-ultra', cellular: 'https://www.gsmarena.com/samsung_galaxy_s26_ultra_5g-14320.php', connectivity: 'https://www.gsmarena.com/samsung_galaxy_s26_ultra_5g-14320.php', + 'connectivity.bluetooth': + 'https://www.samsungmobilepress.com/media-assets/galaxy-s26-ultra?tab=specs', multimedia: 'https://www.gsmarena.com/samsung_galaxy_s26_ultra_5g-14320.php', 'availability.announced_status': 'https://www.gsmarena.com/samsung_galaxy_s26_ultra_5g-14320.php', diff --git a/apps/importer/src/shopee/product-normalizer.ts b/apps/importer/src/shopee/product-normalizer.ts index ffcb46cfe..45edc65e7 100644 --- a/apps/importer/src/shopee/product-normalizer.ts +++ b/apps/importer/src/shopee/product-normalizer.ts @@ -1493,7 +1493,7 @@ const CANONICAL_PHONE_REGISTRY: Record< loudspeaker: 'Yes, stereo speakers', // As the sourced seed states them (DOS/Rate#1761). flash: 'Adaptive True Tone flash', - bluetooth: '6.0, A2DP, LE', + bluetooth: '6', wlan: 'Wi-Fi 7 (802.11be) 2x2 MIMO, tri-band, hotspot (Apple N1 wireless chip)', usb: 'USB-C, USB 3 (up to 10Gb/s), DisplayPort', location: 'Dual-frequency GPS (L1+L5), GLONASS, Galileo, QZSS, BeiDou, NavIC', @@ -1558,7 +1558,7 @@ const CANONICAL_PHONE_REGISTRY: Record< loudspeaker: 'Yes, stereo speakers', // As the sourced seed states them (DOS/Rate#1761). flash: 'Adaptive True Tone flash', - bluetooth: '6.0, A2DP, LE', + bluetooth: '6', wlan: 'Wi-Fi 7 (802.11be) 2x2 MIMO, tri-band, hotspot (Apple N1 wireless chip)', usb: 'USB-C, USB 3 (up to 10Gb/s), DisplayPort', location: 'Dual-frequency GPS (L1+L5), GLONASS, Galileo, QZSS, BeiDou, NavIC', @@ -1625,7 +1625,7 @@ const CANONICAL_PHONE_REGISTRY: Record< // As the sourced seed states them (GSMArena); its sources state no certifications // (DOS/Rate#1761). flash: 'LED flash, laser AF, auto-HDR, panorama', - bluetooth: '6.0, A2DP, LE', + bluetooth: '6.0', wlan: 'Wi-Fi 802.11 a/b/g/n/ac/6e/7, tri-band, Wi-Fi Direct', usb: 'USB Type-C 3.2, DisplayPort 1.2, OTG', location: 'GPS, GLONASS, BDS, GALILEO, QZSS', diff --git a/apps/importer/src/shopee/test-ai-enricher.ts b/apps/importer/src/shopee/test-ai-enricher.ts index feebfd728..691adeb60 100644 --- a/apps/importer/src/shopee/test-ai-enricher.ts +++ b/apps/importer/src/shopee/test-ai-enricher.ts @@ -12,7 +12,6 @@ import http from 'node:http'; import assert from 'node:assert/strict'; import dotenv from 'dotenv'; import { ProductSpecificationsSchema, KeySpecsSchema } from '@repo/shared-data'; -import { getCategorySpecTemplate } from '@repo/shared-data/rules'; import { ProductNormalizer } from './product-normalizer.js'; import { AiSpecEnricher, @@ -25,7 +24,7 @@ import { CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY, FLAGSHIP_DEVICES_TO_SEED, } from './flagship-seed-data.js'; -import { hasSingleRearCamera } from './jobs/backfill-specs.js'; +import { hasSingleRearCamera, statesRearCamera } from './jobs/backfill-specs.js'; import type { ShopeeProduct } from './types.js'; dotenv.config(); @@ -306,9 +305,11 @@ async function runTests() { `Flagship seed ${device.model_key} missing group ${grp}` ); } - // Earbuds and watches have no cameras: their seeds keep the group, empty or not, for - // the spec audit (DOS/Rate#1793). - if (getCategorySpecTemplate(device.categorySlug).groups.includes('camera')) { + // Phones and tablets always state rear cameras; laptops carry only their front webcam, and + // earbuds and watches have no cameras (DOS/Rate#1787, #1793, #1855). + const rearCameraExpected = + device.categorySlug === 'smartphones' || device.categorySlug === 'tablets'; + if (rearCameraExpected || statesRearCamera(device.specifications.camera)) { assert.ok( device.specifications.camera?.main_camera, `Flagship seed ${device.model_key} missing main_camera` @@ -318,6 +319,11 @@ async function runTests() { device.specifications.camera?.second_camera, `Flagship seed ${device.model_key} missing second_camera` ); + } else if (device.categorySlug === 'laptops') { + assert.ok( + device.specifications.camera?.front_camera, + `Flagship seed ${device.model_key} missing front_camera` + ); } console.log( `✅ [Seed Validation] ${device.name} (${device.categorySlug}) -> 10/10 groups, camera=${device.specifications.camera?.rear_setup}` From cd59a1aa39e94e047d9c99eb7c67dd186d9bd82f Mon Sep 17 00:00:00 2001 From: JOY <5027251+JOY@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:43:25 +0700 Subject: [PATCH 2/2] fix(importer): address round 1 provenance and retraction review - Replace unsourced certifications on the 3 canonical iPhone entries with sourced Apple Vietnam model identifiers (A3287, A3290, A3090) so canonicalMasterUpdate overwrites stale stored values (#1855). - Replace AirPods Pro 2 USB-C Bluetooth codec string with sourced "5.3" citing Apple Tech Specs, and remove port/mic text from MacBook key camera specs. - Broaden Bluetooth profile, QCVN, 5G band-pair, and mid-string non-cellular regexes in seed-template-values-1758.test.ts, extend checks to watches/earbuds, and verify 10-group + rear-camera audit invariants after retraction. --- .../seed-template-values-1758.test.ts | 186 +++++++++++++++--- .../importer/src/shopee/flagship-seed-data.ts | 15 +- 2 files changed, 171 insertions(+), 30 deletions(-) diff --git a/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts b/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts index 37c70c288..cddcf64e5 100644 --- a/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts +++ b/apps/importer/src/shopee/__tests__/seed-template-values-1758.test.ts @@ -8,14 +8,25 @@ */ import assert from 'node:assert/strict'; import test from 'node:test'; -import { ProductSpecificationsSchema, type ProductSpecifications } from '@repo/shared-data'; +import { + ProductSpecificationsSchema, + type KeySpecs, + type ProductSpecifications, +} from '@repo/shared-data'; import { CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY, FLAGSHIP_DEVICES_TO_SEED, flagshipSeedsByItem, type FlagshipDeviceSeed, } from '../flagship-seed-data.js'; -import { requiredSpecGroups, seedMasterSpecUpdate } from '../jobs/backfill-specs.js'; +import { + canonicalMasterUpdate, + hasSingleRearCamera, + REQUIRED_10_SPEC_GROUPS, + requiredSpecGroups, + seedMasterSpecUpdate, + statesRearCamera, +} from '../jobs/backfill-specs.js'; import { ProductNormalizer } from '../product-normalizer.js'; import type { ShopeeProduct } from '../types.js'; @@ -24,6 +35,7 @@ interface Entry { categorySlug?: FlagshipDeviceSeed['categorySlug']; has_5g?: boolean; specifications: ProductSpecifications; + key_specs?: KeySpecs; sources?: Readonly>; } @@ -55,11 +67,25 @@ const TEMPLATE_VALUES: ReadonlyArray = [ ['connectivity.bluetooth', '5.3, A2DP, LE'], ]; -const BLUETOOTH_PROFILES_RE = /\b\d+(?:\.\d+)?,\s*A2DP\b/i; -const CERT_CODES_RE = /\b(?:CE|FCC|NCC|KC|VCCI|SRRC|SDPPI|SIRIM|NBTC|IMDA|NTRA)\b|\bQCVN\d*\b/; -const TWO_BAND_NUMBERS_RE = /\bn?\d{1,3}\b.*\bn?\d{1,3}\b/; +const BLUETOOTH_PROFILES_RE = + /\b\d+(?:\.\d+)?,\s*(?:A2DP|AVRCP|HFP|HSP|LE\b|AAC|SBC|aptX|LDAC|LHDC)/i; +const CERT_CODES_RE = /\b(?:CE|FCC|NCC|KC|VCCI|SRRC|SDPPI|SIRIM|NBTC|IMDA|NTRA)\b|\bQCVN/; +const TWO_BAND_NUMBERS_RE = /\bn?\d{1,3}\s*[,/]\s*n?\d{1,3}\b/; const BARE_NEGATIVE_PLACEHOLDER_RE = /^\s*(?:none|no|n\/a)\s*$/i; -const NON_CELLULAR_PLACEHOLDER_RE = /^\s*(?:no\b|none\b|n\/a\b|wi-?fi\b|bluetooth\b)/i; +const CELLULAR_NON_CELLULAR_RE = + /^\s*(?:no|none|n\/a)\b|\b(?:wi-?fi|bluetooth)\b|\bno\s+(?:cellular|sim)\b/i; +const LAPTOP_KEY_CAMERA_NON_WEBCAM_RE = /\b(?:Thunderbolt|HDMI|SDXC|\d+-Mic\b|Mic\s+Array)\b/i; + +const ALL_CAMERA_PATHS = [ + 'camera.rear_setup', + 'camera.main_camera', + 'camera.second_camera', + 'camera.third_camera', + 'camera.fourth_camera', + 'camera.flash', + 'camera.video_recording', + 'camera.front_camera', +] as const; const LAPTOP_REAR_CAMERA_PATHS = [ 'camera.rear_setup', @@ -118,15 +144,10 @@ function findTemplateViolations(entry: Entry): string[] { const bands5g = at(entry.specifications, 'cellular.bands_5g'); if (bands5g !== undefined) { const text = String(bands5g); - const hasExplicitBands = - TWO_BAND_NUMBERS_RE.test(text) && !BARE_NEGATIVE_PLACEHOLDER_RE.test(text); - if (!hasExplicitBands && !citesField(entry, 'cellular.bands_5g')) { - issues.push(`${entry.key}: unsourced 5G band text cellular.bands_5g = ${text}`); - } if (/SA\/NSA\/Sub6/i.test(text) && !TWO_BAND_NUMBERS_RE.test(text)) { - if (!citesField(entry, 'cellular.bands_5g')) { - issues.push(`${entry.key}: bare SA/NSA/Sub6 cellular.bands_5g = ${text}`); - } + issues.push(`${entry.key}: bare SA/NSA/Sub6 cellular.bands_5g = ${text}`); + } else if (!TWO_BAND_NUMBERS_RE.test(text) && !citesField(entry, 'cellular.bands_5g')) { + issues.push(`${entry.key}: unsourced 5G band text cellular.bands_5g = ${text}`); } } @@ -137,17 +158,50 @@ function findTemplateViolations(entry: Entry): string[] { issues.push(`${entry.key}: unsourced laptop rear-camera field ${path} = ${String(val)}`); } } + const keyCam = entry.key_specs?.camera; + if ( + typeof keyCam === 'string' && + LAPTOP_KEY_CAMERA_NON_WEBCAM_RE.test(keyCam) && + !citesField(entry, 'key_specs.camera') + ) { + issues.push(`${entry.key}: non-webcam laptop key_specs.camera = ${keyCam}`); + } } - if ( + if (entry.categorySlug === 'smartwatches' || entry.categorySlug === 'earbuds') { + for (const path of ALL_CAMERA_PATHS) { + const val = at(entry.specifications, path); + if (val !== undefined && !citesField(entry, path)) { + issues.push( + `${entry.key}: unsourced ${entry.categorySlug} camera field ${path} = ${String(val)}` + ); + } + } + } + + if (entry.categorySlug === 'earbuds') { + for (const path of ['cellular.has_5g', ...CELLULAR_DETAIL_PATHS] as const) { + const val = at(entry.specifications, path); + if (val !== undefined && !citesField(entry, path)) { + issues.push(`${entry.key}: unsourced earbuds cellular field ${path} = ${String(val)}`); + } + } + } + + const isNonCellularWatch = + entry.categorySlug === 'smartwatches' && entry.has_5g === false && - (entry.categorySlug === 'tablets' || entry.categorySlug === 'laptops') - ) { + at(entry.specifications, 'cellular.bands_4g') === undefined; + const isWifiOnlyTabletOrLaptop = + entry.has_5g === false && + (entry.categorySlug === 'tablets' || entry.categorySlug === 'laptops'); + + if (isWifiOnlyTabletOrLaptop || isNonCellularWatch) { for (const path of CELLULAR_DETAIL_PATHS) { const val = at(entry.specifications, path); if (val !== undefined && !citesField(entry, path)) { issues.push( - `${entry.key}: unsourced Wi-Fi-only ${entry.categorySlug} cellular field ${path} = ${String(val)}` + `${entry.key}: unsourced non-cellular ${entry.categorySlug} cellular field ${path} = ${String(val)}` ); } } @@ -162,7 +216,7 @@ function findTemplateViolations(entry: Entry): string[] { if (citesField(entry, path)) continue; if (BARE_NEGATIVE_PLACEHOLDER_RE.test(val)) { issues.push(`${entry.key}: unsourced placeholder ${path} = ${JSON.stringify(val)}`); - } else if (group === 'cellular' && NON_CELLULAR_PLACEHOLDER_RE.test(val)) { + } else if (group === 'cellular' && CELLULAR_NON_CELLULAR_RE.test(val)) { issues.push( `${entry.key}: unsourced non-cellular placeholder ${path} = ${JSON.stringify(val)}` ); @@ -200,19 +254,24 @@ test('group-level sources never mask template-shaped or cross-category field val }, cellular: { has_5g: false, - bands_5g: 'SA/NSA/Sub6', + bands_5g: '5G Sub-6 (LTE Cat 20)', + technology: 'GPS + Wi-Fi + Bluetooth', sim_type: 'No cellular', + volte: false, }, connectivity: { - bluetooth: '6.0, A2DP, LE', + bluetooth: '5.3, AAC, Ultra-low latency Lossless', }, multimedia: { audio_features: '24-bit/192kHz Hi-Res & Hi-Res Wireless audio', }, regulatory: { - certifications: 'CE, FCC, QCVN127', + certifications: 'QCVN127B', }, }, + key_specs: { + camera: '12MP Center Stage + 3x Thunderbolt 5', + }, sources: groupSourcesOnly, }; @@ -220,23 +279,57 @@ test('group-level sources never mask template-shaped or cross-category field val assert.ok(violations.some(v => v.includes('connectivity.bluetooth'))); assert.ok(violations.some(v => v.includes('regulatory.certifications'))); assert.ok(violations.some(v => v.includes('cellular.bands_5g'))); + assert.ok(violations.some(v => v.includes('cellular.technology'))); + assert.ok(violations.some(v => v.includes('cellular.sim_type'))); + assert.ok(violations.some(v => v.includes('cellular.volte'))); assert.ok(violations.some(v => v.includes('multimedia.audio_features'))); assert.ok(violations.some(v => v.includes('camera.rear_setup'))); assert.ok(violations.some(v => v.includes('camera.second_camera'))); - assert.ok(violations.some(v => v.includes('cellular.sim_type'))); + assert.ok(violations.some(v => v.includes('key_specs.camera'))); + + // Bare SA/NSA/Sub6 without band numbers is always rejected, even if cited. + const bareSaNsa: Entry = { + key: 'test:bare-sa-nsa:256gb', + categorySlug: 'smartphones', + has_5g: true, + specifications: { cellular: { has_5g: true, bands_5g: 'SA/NSA/Sub6' } }, + sources: { 'cellular.bands_5g': 'https://example.com/specs' }, + }; + assert.ok(findTemplateViolations(bareSaNsa).some(v => v.includes('bare SA/NSA/Sub6'))); - // Explicit field-level sources clear only the exact cited paths. + // GPS smartwatch with volte/vowifi is rejected without field-level citation. + const gpsWatch: Entry = { + key: 'test:gps-watch:64gb', + categorySlug: 'smartwatches', + has_5g: false, + specifications: { cellular: { has_5g: false, volte: false, vowifi: true } }, + sources: { cellular: 'https://example.com/watch' }, + }; + assert.ok(findTemplateViolations(gpsWatch).some(v => v.includes('cellular.volte'))); + assert.ok(findTemplateViolations(gpsWatch).some(v => v.includes('cellular.vowifi'))); + + // Explicit field-level sources clear only non-bare-SA/NSA/Sub6 cited paths. const fieldCited: Entry = { ...masked, + specifications: { + ...masked.specifications, + cellular: { + ...masked.specifications.cellular, + bands_5g: '5G (Sub-6)', + }, + }, sources: { ...groupSourcesOnly, 'camera.rear_setup': 'https://www.apple.com/macbook-air/specs/', 'camera.second_camera': 'https://www.apple.com/macbook-air/specs/', 'cellular.bands_5g': 'https://www.apple.com/ipad-pro/specs/', + 'cellular.technology': 'https://www.apple.com/ipad-pro/specs/', 'cellular.sim_type': 'https://www.apple.com/ipad-pro/specs/', + 'cellular.volte': 'https://www.apple.com/ipad-pro/specs/', 'connectivity.bluetooth': 'https://www.apple.com/iphone-18-pro/specs/', 'multimedia.audio_features': 'https://www.gsmarena.com/example.php', 'regulatory.certifications': 'https://www.apple.com/vn/iphone-18-pro/specs/', + 'key_specs.camera': 'https://www.apple.com/macbook-pro/specs/', }, }; assert.deepEqual(findTemplateViolations(fieldCited), []); @@ -271,7 +364,7 @@ const byKey = (key: string): Entry => { return found; }; -test('the replaced values are the sourced ones (seeds and 2026 normalizer registry)', () => { +test('the replaced values are the sourced ones (seeds, canonical entries, and 2026 normalizer)', () => { const expected: Record> = { 'apple:iphone-16:128gb': { 'cellular.bands_5g': @@ -279,6 +372,7 @@ test('the replaced values are the sourced ones (seeds and 2026 normalizer regist 'connectivity.bluetooth': '5.3', 'regulatory.sar_head': '1.08 W/kg', 'regulatory.sar_body': '1.17 W/kg', + 'regulatory.certifications': 'Model A3287 (Vietnam and other countries and regions)', }, 'apple:iphone-16-pro-max:256gb': { 'cellular.bands_5g': @@ -287,10 +381,12 @@ test('the replaced values are the sourced ones (seeds and 2026 normalizer regist 'apple:iphone-16-plus:256gb': { 'cellular.bands_5g': 'FDD-5G NR n1/n2/n3/n5/n7/n8/n12/n20/n25/n26/n28/n30/n66/n70/n75/n76; TDD-5G NR n38/n40/n41/n48/n53/n77/n78/n79', + 'regulatory.certifications': 'Model A3290 (Vietnam and other countries and regions)', }, 'apple:iphone-15:128gb': { 'cellular.bands_5g': '5G NR n1/n2/n3/n5/n7/n8/n12/n20/n25/n26/n28/n30/n38/n40/n41/n48/n53/n66/n70/n75/n76/n77/n78/n79', + 'regulatory.certifications': 'Model A3090 (Vietnam and other countries and regions)', }, 'apple:iphone-16-pro:256gb': { 'cellular.bands_5g': @@ -308,6 +404,9 @@ test('the replaced values are the sourced ones (seeds and 2026 normalizer regist 'cellular.bands_5g': '5G (Sub-6)', 'connectivity.bluetooth': '5.3', }, + 'apple:airpods-pro-2-usbc:64gb': { + 'connectivity.bluetooth': '5.3', + }, 'xiaomi:14-ultra:512gb': { 'cellular.bands_5g': '5G NR n1/n2/n3/n5/n7/n8/n20/n28/n38/n40/n41/n48/n66/n77/n78/n79 (n66 varies by region)', @@ -340,6 +439,25 @@ test('the replaced values are the sourced ones (seeds and 2026 normalizer regist } } + // Canonical backfill updates overwrite stale stored CE/FCC/QCVN certifications on all 3 rows. + for (const [key, entry] of Object.entries(CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY)) { + const update = canonicalMasterUpdate( + { + specifications: { + regulatory: { certifications: 'CE, FCC, RoHS, QCVN (Bộ TT&TT Việt Nam)' }, + }, + key_specs: {}, + }, + entry + ) as { specifications: ProductSpecifications }; + assert.equal( + update.specifications.regulatory?.certifications, + entry.specifications.regulatory?.certifications, + key + ); + assert.doesNotMatch(update.specifications.regulatory?.certifications ?? '', CERT_CODES_RE, key); + } + // DOS/Rate#1803 item 6: the normalizer registry carries the sourced Bluetooth versions too. const normalizer = new ProductNormalizer(); const normalize = (title: string) => @@ -522,7 +640,8 @@ test('fields no source states are dropped and retracted from stored rows', () => } // `seedMasterSpecUpdate` removes the stale stored template/placeholder values instead of - // keeping them, and the resulting specifications pass schema and 10-group checks. + // keeping them, and the resulting specifications pass `auditMasterSpecs` runtime checks + // (schema, all 10 groups since seed specs omit `category_slug`, and rear-camera completeness). const stored = { specifications: { camera: { @@ -553,9 +672,22 @@ test('fields no source states are dropped and retracted from stored rows', () => } const parsed = ProductSpecificationsSchema.safeParse(update.specifications); assert.equal(parsed.success, true, `${key}: ${parsed.error?.message}`); - for (const grp of requiredSpecGroups(seed.categorySlug)) { + assert.deepEqual( + requiredSpecGroups(update.specifications.category_slug), + REQUIRED_10_SPEC_GROUPS, + key + ); + for (const grp of REQUIRED_10_SPEC_GROUPS) { assert.ok(update.specifications[grp], `${key}: missing group ${grp} after retraction`); } + if (statesRearCamera(update.specifications.camera)) { + assert.ok(update.specifications.camera?.main_camera?.trim(), `${key}: missing main_camera`); + assert.ok( + hasSingleRearCamera(update.specifications.camera) || + update.specifications.camera?.second_camera?.trim(), + `${key}: missing second_camera` + ); + } } }); diff --git a/apps/importer/src/shopee/flagship-seed-data.ts b/apps/importer/src/shopee/flagship-seed-data.ts index bb2123f57..0902b38ba 100644 --- a/apps/importer/src/shopee/flagship-seed-data.ts +++ b/apps/importer/src/shopee/flagship-seed-data.ts @@ -150,6 +150,7 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< fcc_approval: 'FCC ID BCG-E8692A', sar_head: '1.08 W/kg', sar_body: '1.17 W/kg', + certifications: 'Model A3287 (Vietnam and other countries and regions)', }, }, key_specs: { @@ -165,6 +166,7 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< 'connectivity.bluetooth': 'https://support.apple.com/en-us/121029', 'regulatory.sar_head': 'https://www.apple.com/legal/rfexposure/iphone17,3/en/', 'regulatory.sar_body': 'https://www.apple.com/legal/rfexposure/iphone17,3/en/', + 'regulatory.certifications': 'https://support.apple.com/vi-vn/121029', }, }, 'apple:iphone-16-plus:256gb': { @@ -255,6 +257,7 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< fcc_approval: 'FCC ID BCG-E8693A', sar_head: '1.12 W/kg', sar_body: '1.14 W/kg', + certifications: 'Model A3290 (Vietnam and other countries and regions)', }, }, key_specs: { @@ -268,6 +271,7 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< sources: { 'cellular.bands_5g': 'https://support.apple.com/vi-vn/121030', 'connectivity.bluetooth': 'https://support.apple.com/en-us/121030', + 'regulatory.certifications': 'https://support.apple.com/vi-vn/121030', }, }, 'apple:iphone-15:128gb': { @@ -356,6 +360,7 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< fcc_approval: 'FCC ID BCG-E8431A', sar_head: '1.12 W/kg', sar_body: '1.14 W/kg', + certifications: 'Model A3090 (Vietnam and other countries and regions)', }, }, key_specs: { @@ -369,6 +374,7 @@ export const CANONICAL_BACKFILL_SPECS_BY_MODEL_KEY: Record< sources: { 'cellular.bands_5g': 'https://support.apple.com/vi-vn/111831', 'connectivity.bluetooth': 'https://support.apple.com/en-us/111831', + 'regulatory.certifications': 'https://support.apple.com/vi-vn/111831', }, }, }; @@ -1177,7 +1183,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ key_specs: { screen: '13.6" Liquid Retina (2560x1664, 500 nits)', chip: 'Apple M3 (8-core CPU / 8-core GPU)', - camera: '1080p FaceTime HD + 3-Mic Studio Array', + camera: '1080p FaceTime HD', battery: '52.6 Wh (Lên tới 18 giờ, MagSafe 3)', storage: '256GB', ram: '16GB', @@ -1482,7 +1488,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ }, camera: {}, connectivity: { - bluetooth: '5.3, AAC, Ultra-low latency 20-bit/48kHz Lossless Audio Protocol', + bluetooth: '5.3', usb: 'USB Type-C charging port', sensors: 'Skin-detect sensor, motion-detecting accelerometer, speech-detecting accelerometer, touch control', @@ -1504,6 +1510,9 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ chip: 'Apple H2 + Apple U1 Ultra Wideband', battery: '6h tai nghe / 30h hộp sạc (523 mAh)', }, + sources: { + 'connectivity.bluetooth': 'https://support.apple.com/en-us/111836', + }, // Template text an earlier version of this seed wrote: a display, cameras, a cellular // network and phone hardware earbuds do not have (DOS/Rate#1793). retract_spec_fields: [ @@ -3200,7 +3209,7 @@ export const FLAGSHIP_DEVICES_TO_SEED: FlagshipDeviceSeed[] = [ chip: 'Apple M4 Pro (12-core CPU, 16-core GPU)', ram: '24GB', storage: '512GB', - camera: '12MP Center Stage + 3x Thunderbolt 5 (120Gb/s)', + camera: '12MP Center Stage Camera with Desk View', battery: '72.4Wh (22h) 96W MagSafe 3', }, specifications: {