waitad 0.0.6 → 0.0.8
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/cli.js +29 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -15551,19 +15551,33 @@ printf '{"event_id":"%s","user_id":"%s","campaign_id":"%s","ts":"%s","agent":"cl
|
|
|
15551
15551
|
|
|
15552
15552
|
exit 0
|
|
15553
15553
|
`;
|
|
15554
|
-
function makeSyncSh(
|
|
15554
|
+
function makeSyncSh() {
|
|
15555
15555
|
return `#!/usr/bin/env bash
|
|
15556
15556
|
# waitad sync \u2014 refreshes ad cache and flushes impression queue.
|
|
15557
15557
|
# Runs every 5 minutes via launchd (macOS) or cron (Linux).
|
|
15558
15558
|
set -uo pipefail
|
|
15559
15559
|
|
|
15560
|
-
|
|
15561
|
-
INSTALL_KEY="${installKey}"
|
|
15562
|
-
INSTALL_KEY_ID="${installKeyId}"
|
|
15560
|
+
CONFIG="$HOME/.waitad/config.json"
|
|
15563
15561
|
CACHE="$HOME/.waitad/cache.json"
|
|
15564
15562
|
QUEUE="$HOME/.waitad/queue.ndjson"
|
|
15565
15563
|
LOG="$HOME/.waitad/sync.log"
|
|
15566
15564
|
|
|
15565
|
+
# Read credentials from config at runtime so key rotations take effect immediately
|
|
15566
|
+
if ! command -v jq &>/dev/null; then
|
|
15567
|
+
printf '[%s] jq not found \u2014 cannot run sync\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$LOG"
|
|
15568
|
+
exit 1
|
|
15569
|
+
fi
|
|
15570
|
+
[ -f "$CONFIG" ] || { printf '[%s] config not found\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$LOG"; exit 1; }
|
|
15571
|
+
|
|
15572
|
+
API_BASE=$(jq -r '.api_base // "https://waitad.vercel.app"' "$CONFIG")
|
|
15573
|
+
INSTALL_KEY=$(jq -r '.install_key // empty' "$CONFIG")
|
|
15574
|
+
INSTALL_KEY_ID=$(jq -r '.install_key_id // empty' "$CONFIG")
|
|
15575
|
+
|
|
15576
|
+
if [ -z "$INSTALL_KEY" ] || [ -z "$INSTALL_KEY_ID" ]; then
|
|
15577
|
+
printf '[%s] Missing credentials in config \u2014 run waitad login\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$LOG"
|
|
15578
|
+
exit 1
|
|
15579
|
+
fi
|
|
15580
|
+
|
|
15567
15581
|
log() { printf '[%s] %s\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$*" >> "$LOG"; }
|
|
15568
15582
|
|
|
15569
15583
|
# \u2500\u2500 1. Refresh ad cache \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
@@ -15601,7 +15615,15 @@ if ! command -v jq &>/dev/null; then
|
|
|
15601
15615
|
exit 0
|
|
15602
15616
|
fi
|
|
15603
15617
|
|
|
15604
|
-
|
|
15618
|
+
UUID_RE='^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
|
|
15619
|
+
|
|
15620
|
+
# Parse NDJSON, filter to valid events only (skip lines with unknown/missing UUIDs), cap at 100
|
|
15621
|
+
EVENTS=$(jq -s '[.[] | select(
|
|
15622
|
+
(.event_id | test("'"$UUID_RE"'"; "i")) and
|
|
15623
|
+
(.user_id | test("'"$UUID_RE"'"; "i")) and
|
|
15624
|
+
(.campaign_id | test("'"$UUID_RE"'"; "i")) and
|
|
15625
|
+
(.ts // "" | . != "")
|
|
15626
|
+
)] | .[0:100]' "$FLUSH" 2>>"$LOG")
|
|
15605
15627
|
if [ -z "$EVENTS" ] || [ "$EVENTS" = "[]" ]; then
|
|
15606
15628
|
rm -f "$FLUSH"
|
|
15607
15629
|
exit 0
|
|
@@ -15662,7 +15684,7 @@ var installCommand = new import_commander2.Command("install").description("Wire
|
|
|
15662
15684
|
console.warn(" Could not reach API \u2014 will retry on first sync.");
|
|
15663
15685
|
}
|
|
15664
15686
|
import_fs3.default.writeFileSync(STATUSLINE_SCRIPT, STATUSLINE_SH, { mode: 493 });
|
|
15665
|
-
import_fs3.default.writeFileSync(SYNC_SCRIPT, makeSyncSh(
|
|
15687
|
+
import_fs3.default.writeFileSync(SYNC_SCRIPT, makeSyncSh(), {
|
|
15666
15688
|
mode: 493
|
|
15667
15689
|
});
|
|
15668
15690
|
console.log(`\u2713 Scripts written to ~/.waitad/`);
|
|
@@ -15824,7 +15846,7 @@ Queue: ${lines} pending impression(s)`);
|
|
|
15824
15846
|
});
|
|
15825
15847
|
|
|
15826
15848
|
// package.json
|
|
15827
|
-
var version2 = "0.0.
|
|
15849
|
+
var version2 = "0.0.8";
|
|
15828
15850
|
|
|
15829
15851
|
// src/index.ts
|
|
15830
15852
|
var program = new import_commander5.Command().name("waitad").version(version2).description("Status-line ad marketplace for CLI coding agents");
|