← back to Designer Wallcoverings
TK-135: stamp custom.color_normalized_at per SKU (durable dedup + audit) on normalize
16012764297a0b3e3985528ae8b458b68412e956 · 2026-07-27 20:20:01 -0700 · Steve
Files touched
M shopify/scripts/tk135-apply-normalize.js
Diff
commit 16012764297a0b3e3985528ae8b458b68412e956
Author: Steve <steve@designerwallcoverings.com>
Date: Mon Jul 27 20:20:01 2026 -0700
TK-135: stamp custom.color_normalized_at per SKU (durable dedup + audit) on normalize
---
shopify/scripts/tk135-apply-normalize.js | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/shopify/scripts/tk135-apply-normalize.js b/shopify/scripts/tk135-apply-normalize.js
index 2e8f09a4..2bb09527 100644
--- a/shopify/scripts/tk135-apply-normalize.js
+++ b/shopify/scripts/tk135-apply-normalize.js
@@ -25,6 +25,7 @@ const PROGRESS = arg('--progress', path.join(__dirname, 'data/tk135/normalize-pr
const env = fs.readFileSync(os.homedir() + '/Projects/secrets-manager/.env', 'utf8');
const TOKEN = (env.match(/^SHOPIFY_ADMIN_TOKEN=(.*)$/m) || [])[1].replace(/['"]/g, '').trim();
const STORE = 'designer-laboratory-sandbox.myshopify.com', API = '2024-10';
+const NOW = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z'); // per-SKU action timestamp (durable dedup + audit)
const sleep = ms => new Promise(r => setTimeout(r, ms));
function gql(query, variables = {}) {
@@ -80,7 +81,10 @@ function load() {
for (const r of rows) {
let errs = [];
- if (r.palette) { const mf = await gqlR(M_MF, { mf: [{ ownerId: r.gid, namespace: 'custom', key: 'color_palette', type: 'json', value: r.palette }] }); errs = errs.concat(mf.data?.metafieldsSet?.userErrors || []); }
+ // per-SKU action timestamp (+ palette when present) — durable dedup/audit so re-runs never duplicate
+ const mfs = [{ ownerId: r.gid, namespace: 'custom', key: 'color_normalized_at', type: 'date_time', value: NOW }];
+ if (r.palette) mfs.push({ ownerId: r.gid, namespace: 'custom', key: 'color_palette', type: 'json', value: r.palette });
+ const mf = await gqlR(M_MF, { mf: mfs }); errs = errs.concat(mf.data?.metafieldsSet?.userErrors || []);
if (r.remove.length) { const d = await gqlR(M_DEL, { id: r.gid, tags: r.remove }); errs = errs.concat(d.data?.tagsRemove?.userErrors || []); }
if (r.add.length) { const a = await gqlR(M_ADD, { id: r.gid, tags: r.add }); errs = errs.concat(a.data?.tagsAdd?.userErrors || []); }
if (errs.length) { report.failed.push({ gid: r.gid, errs }); console.log(` ❌ ${r.gid.split('/').pop()} ${JSON.stringify(errs)}`); }
← 5d19295d TK-135: motif classifier (bare)
·
back to Designer Wallcoverings
·
auto-save: 2026-07-27T20:24:23 (9 files) — shopify/scripts/d 7ff5efd7 →