[object Object]

← back to Gmc Titlefix

price-override: --apply self-resolves DS (file→DEFAULT_DS), no <DS> placeholder — auto-executor safe

9204be4bc11d27c4676f8b0b11073a03c80eeed6 · 2026-07-27 13:38:08 -0700 · Steve Abrams

Files touched

Diff

commit 9204be4bc11d27c4676f8b0b11073a03c80eeed6
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Jul 27 13:38:08 2026 -0700

    price-override: --apply self-resolves DS (file→DEFAULT_DS), no <DS> placeholder — auto-executor safe
---
 gmc-price-override.js | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/gmc-price-override.js b/gmc-price-override.js
index 3b65ace..fa07c74 100644
--- a/gmc-price-override.js
+++ b/gmc-price-override.js
@@ -6,8 +6,10 @@
 //
 //   node gmc-price-override.js                 # DRY-RUN: build override list from feed⋈MC, no writes
 //   node gmc-price-override.js --dwla-pid-join # DRY-RUN (DWLA only): build override list via pid join, no writes
-//   node gmc-price-override.js --create-ds      # GATED: create the supplemental datasource (prints its name)
-//   node gmc-price-override.js --apply <DS>     # GATED: push price overrides to datasource <DS>
+//   node gmc-price-override.js --create-ds      # GATED: create the supplemental datasource (prints + PERSISTS its name)
+//   node gmc-price-override.js --apply [<DS>]   # GATED: push price overrides. <DS> optional — resolves
+//                                               #        explicit arg → .price-override-ds file → DEFAULT_DS.
+//                                               #        (no placeholder to substitute → auto-executor safe)
 //
 // Cost: $0 (Google Content/Merchant API + local feed read; no per-call charge).
 const { token, MERCHANT } = require('./_auth.js');
@@ -21,7 +23,19 @@ const OUT_DWLA = '/Users/macstudio3/.claude/yolo-queue/gmc-price-override-dwla-l
 const args = process.argv.slice(2);
 const CREATE_DS = args.includes('--create-ds');
 const APPLY = args.includes('--apply');
-const DS = APPLY ? args[args.indexOf('--apply') + 1] : null;
+// Where --create-ds persists the datasource name so a later --apply needs NO argument.
+const DS_FILE = '/Users/macstudio3/.claude/yolo-queue/gmc-price-override-ds.txt';
+// The datasource already created live on 2026-07-27 (step b of the approval run). Fallback of last resort.
+const DEFAULT_DS = 'accounts/146735262/dataSources/10693978453';
+// Resolve the datasource for --apply WITHOUT depending on a shell-substituted <DS> placeholder:
+//   1) an explicit, non-flag arg after --apply   2) the persisted DS_FILE   3) DEFAULT_DS.
+function resolveDS() {
+  const a = args[args.indexOf('--apply') + 1];
+  if (a && !a.startsWith('--')) return a;
+  try { const f = fs.readFileSync(DS_FILE, 'utf8').trim(); if (f) return f; } catch {}
+  return DEFAULT_DS;
+}
+const DS = APPLY ? resolveDS() : null;
 // OPT-IN, guarded DWLA path — pid-based feed↔MC join (see 2026-07-16 memo EXECUTION LOG).
 // Off by default; does NOT change the default SKU/mpn-join dry-run behavior above.
 const DWLA_PID_JOIN = args.includes('--dwla-pid-join');
@@ -130,7 +144,11 @@ async function createDataSource() {
     const body = { displayName: 'DW Real-Price Overrides', supplementalProductDataSource: supp };
     const r = await fetch(url, { method: 'POST', headers: { Authorization: 'Bearer ' + tok, 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
     const j = await r.json();
-    if (r.status >= 200 && r.status < 300 && j.name) { console.log('DATASOURCE CREATED:\n' + j.name); return; }
+    if (r.status >= 200 && r.status < 300 && j.name) {
+      try { fs.writeFileSync(DS_FILE, j.name + '\n'); } catch (e) { console.error('  (warn) could not persist DS to', DS_FILE, e.message); }
+      console.log('DATASOURCE CREATED:\n' + j.name + '\n(persisted to ' + DS_FILE + ' — `--apply` will now find it with no argument)');
+      return;
+    }
     console.error('  shape', JSON.stringify(supp), '->', r.status, (j.error?.message || '').slice(0, 120));
   }
   console.error('all datasource shapes failed');

← c10e177 auto-save: 2026-07-26T17:14:46 (1 files) — gmc-price-overrid  ·  back to Gmc Titlefix  ·  (newest)