← back to Sanderson Onboard

scripts/lib/inventory-stamp-guard.mjs

24 lines

// inventory-stamp-guard.mjs — RE-EXPORT SHIM -> canonical master (2026-09-22 Option-B decouple).
// The $0-orderable guard (TK-11357) has ONE source of truth: ~/Projects/_shared/dw-guards/.
// Original preserved as inventory-stamp-guard.mjs.pre-shared-lift.
//
// PORTABLE resolution (TK-11786 review fix): resolve the master via DW_SHARED_GUARDS or the
// per-user home dir, NOT a hardcoded /Users/macstudio3 path — mirrors validate-before-activate.js
// and internal-guard.js so this works on Kamatera (/root), Mac1, and any other home.
// ESM .mjs — CJS require() is NOT supported (would need to resolve async or switch to .js wrapper).
// For CJS consumers: change to `const m = await import('./...')` or convert to ESM.
// Fail-safe: if require() is attempted, Node throws ERR_REQUIRE_ASYNC_MODULE, preventing silent bad defaults.

import os from 'node:os';
import path from 'node:path';
import { pathToFileURL } from 'node:url';

const base = process.env.DW_SHARED_GUARDS || path.join(os.homedir(), 'Projects', '_shared', 'dw-guards');
const _m = await import(pathToFileURL(path.join(base, 'inventory-stamp-guard.mjs')).href);

export const PRICE_SUPPRESSED_TAGS = _m.PRICE_SUPPRESSED_TAGS;
export const isPriceSuppressed = _m.isPriceSuppressed;
export const isSellableVariant = _m.isSellableVariant;
export const isZeroPriceOrderableRisk = _m.isZeroPriceOrderableRisk;
export const safeStampQuantity = _m.safeStampQuantity;