@vibiz/cli 0.2.4 → 0.3.0
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/vibiz.js
CHANGED
|
@@ -6,11 +6,12 @@ import {
|
|
|
6
6
|
connectHostMessage,
|
|
7
7
|
deployDirectory,
|
|
8
8
|
deployPathProblem,
|
|
9
|
+
formatMinor,
|
|
9
10
|
formatUnits,
|
|
10
11
|
formatUsd,
|
|
11
12
|
mergeEnvFile,
|
|
12
13
|
oneKeyMessage
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ICBMMOJM.js";
|
|
14
15
|
|
|
15
16
|
// packages/cli/src/main.ts
|
|
16
17
|
import { spawn } from "node:child_process";
|
|
@@ -373,6 +374,11 @@ var VibizApp = class _VibizApp {
|
|
|
373
374
|
* first call, before the owner has verified anything. Refunds and
|
|
374
375
|
* withdrawals are the owner's, in the console.
|
|
375
376
|
*/
|
|
377
|
+
entitlementList(user) {
|
|
378
|
+
return this.request(
|
|
379
|
+
`/app/payments/entitlements?user=${encodeURIComponent(user)}`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
376
382
|
payments = {
|
|
377
383
|
/** A hosted checkout page for a price (one-time or a subscription) or an ad-hoc item. */
|
|
378
384
|
checkout: (input) => this.request(
|
|
@@ -386,8 +392,33 @@ var VibizApp = class _VibizApp {
|
|
|
386
392
|
);
|
|
387
393
|
return r.data[0] ?? null;
|
|
388
394
|
},
|
|
389
|
-
/**
|
|
395
|
+
/**
|
|
396
|
+
* What the user has now, across web checkout subscriptions and App Store / Google Play
|
|
397
|
+
* purchases: one entry per thing it gives, with its `source`. Server-side only.
|
|
398
|
+
*/
|
|
399
|
+
entitlements: async (user) => (await this.entitlementList(user)).data,
|
|
400
|
+
/**
|
|
401
|
+
* Whether the user has it now: anything (no `key`), or one thing, matched in this order:
|
|
402
|
+
* an entitlement key (`pro`; a string that is one of the project's entitlement keys is
|
|
403
|
+
* matched only as that), else a lookup key (`pro-monthly`), a price id, a store product id.
|
|
404
|
+
* Counts the web checkout and the App Store / Google Play alike.
|
|
405
|
+
*/
|
|
390
406
|
hasActive: async (user, price) => {
|
|
407
|
+
let list2 = null;
|
|
408
|
+
try {
|
|
409
|
+
list2 = await this.entitlementList(user);
|
|
410
|
+
} catch (err) {
|
|
411
|
+
if (!(err instanceof VibizAppError) || err.status !== 404) throw err;
|
|
412
|
+
}
|
|
413
|
+
if (list2) {
|
|
414
|
+
const grants = list2.data;
|
|
415
|
+
if (!price) return grants.length > 0;
|
|
416
|
+
if (grants.some((g) => g.key === price)) return true;
|
|
417
|
+
if (list2.entitlement_keys?.includes(price)) return false;
|
|
418
|
+
return grants.some(
|
|
419
|
+
(g) => g.lookup_key === price || g.price_id === price || g.store_product_id === price
|
|
420
|
+
);
|
|
421
|
+
}
|
|
391
422
|
const r = await this.request(
|
|
392
423
|
`/app/payments/subscriptions?user=${encodeURIComponent(user)}&status=active,trialing`
|
|
393
424
|
);
|
|
@@ -3008,9 +3039,12 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
3008
3039
|
vibiz payments [--dev] [--json] take payments: balance, getting paid, the next step
|
|
3009
3040
|
(production for full-access keys; --dev test mode)
|
|
3010
3041
|
vibiz payments products [--dev] the catalog; add one with
|
|
3011
|
-
products add <name> --amount <cents> [--interval month|year] [--lookup-key k]
|
|
3042
|
+
products add <name> --amount <cents> [--currency eur] [--interval month|year] [--lookup-key k]
|
|
3043
|
+
(--amount in the currency's smallest unit; usd by default)
|
|
3012
3044
|
vibiz payments checkout <price_id|lookup_key> --success-url <u> --cancel-url <u> [--user id]
|
|
3013
|
-
|
|
3045
|
+
[--brand-name n] [--brand-logo https://\u2026] [--brand-icon https://\u2026] [--brand-color #hex]
|
|
3046
|
+
[--brand-background #hex] [--brand-font inter] [--brand-border pill|rounded|rectangular]
|
|
3047
|
+
a checkout link to pay right now, in your brand
|
|
3014
3048
|
vibiz payments list [--dev] payments, newest first
|
|
3015
3049
|
vibiz payments webhook <url|none> [--dev] where Vibiz POSTs payment events (the app verifies
|
|
3016
3050
|
them with VIBIZ_WEBHOOK_SECRET: vibiz docs webhooks)
|
|
@@ -3024,7 +3058,30 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
3024
3058
|
vibiz payments connect [--dev] [--open] a link for the owner to connect their own Stripe
|
|
3025
3059
|
account instead (sales charged and paid out there);
|
|
3026
3060
|
give it to them: only they can complete it
|
|
3027
|
-
vibiz payments disconnect [--dev] owner: back to payments through Vibiz
|
|
3061
|
+
vibiz payments disconnect [--dev] owner: back to payments through Vibiz (an opt-out:
|
|
3062
|
+
account apply leaves the project alone)
|
|
3063
|
+
vibiz payments use-account [--dev] owner: put the project on your Stripe account for
|
|
3064
|
+
every project
|
|
3065
|
+
vibiz payments account [--json] your Stripe connected once for every project: each
|
|
3066
|
+
environment, and how each project uses it
|
|
3067
|
+
vibiz payments account connect [--dev] [--open]
|
|
3068
|
+
a link for the owner to connect it once (Settings \u25B8
|
|
3069
|
+
Payments); only they can complete it
|
|
3070
|
+
vibiz payments account default <on|off> owner: new projects start on it (or not)
|
|
3071
|
+
vibiz payments account apply [--dev] [--yes]
|
|
3072
|
+
owner: switch existing projects to it for new sales;
|
|
3073
|
+
lists what changes and asks you to confirm
|
|
3074
|
+
vibiz payments account disconnect [--dev] owner: projects on it go back to payments through Vibiz
|
|
3075
|
+
vibiz payments app-store connect [--open] a link for the owner to connect their own RevenueCat
|
|
3076
|
+
account (they paste its secret key there, once)
|
|
3077
|
+
vibiz payments app-store setup --ios <bundle id> [--android <package>] [--store-project <id>] [--dev]
|
|
3078
|
+
iOS/Android in-app purchases: the app in their
|
|
3079
|
+
RevenueCat account, this catalog mirrored, the public
|
|
3080
|
+
SDK key and the App Store product ids (safe to re-run)
|
|
3081
|
+
vibiz payments app-store [--dev] [--json] what is set up and the steps left (no Vibiz fee on
|
|
3082
|
+
store purchases)
|
|
3083
|
+
vibiz payments app-store subscriptions [--user id] [--dev]
|
|
3084
|
+
App Store and Google Play purchases recorded
|
|
3028
3085
|
vibiz social [--dev] [--json] the project's social and ad accounts, posts waiting for
|
|
3029
3086
|
you, scheduled and failed (docs/SOCIAL.md); --dev is the
|
|
3030
3087
|
sandbox: nothing is posted, nothing is spent
|
|
@@ -3044,6 +3101,13 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
3044
3101
|
vibiz social campaigns [--dev] ad campaigns with budget and spend
|
|
3045
3102
|
vibiz social pause|resume <campaign> [--dev] | budget <campaign> --budget <cents>
|
|
3046
3103
|
change a campaign (live: you confirm; agents ask the owner)
|
|
3104
|
+
vibiz social campaigns create --type search|display|pmax --name "<name>" --budget <minor units/day>
|
|
3105
|
+
--final-url <https> --headline "\u2026"\u2026 --desc "\u2026"\u2026 --country US[,CA] [--keyword "text[:phrase|exact]"]\u2026
|
|
3106
|
+
[--language en] [--business-name n] [--long-headline t] [--image landscape|square|logo=<file|url>]\u2026
|
|
3107
|
+
[--bidding maximize_clicks|maximize_conversions] [--max-cpc c] [--target-cpa c]
|
|
3108
|
+
[--start-date YYYY-MM-DD] [--end-date \u2026] [--file campaign.json] [--active] [--dev]
|
|
3109
|
+
a Google Ads campaign, created PAUSED (--active starts
|
|
3110
|
+
spending; live: you confirm; agents ask the owner)
|
|
3047
3111
|
vibiz connectors [list] [--json] your own APIs, called through Vibiz, which holds their
|
|
3048
3112
|
keys (docs/CONNECTORS.md)
|
|
3049
3113
|
vibiz connectors import <spec-url|file> [--name n] [--enable op,op] [--add]
|
|
@@ -3084,6 +3148,11 @@ var HELP = `vibiz \u2014 website, database and sign-in for a new business, in on
|
|
|
3084
3148
|
vibiz replays [--errors] [--rage] [--dead] [--path /x] [--period 7d] [--json]
|
|
3085
3149
|
what went wrong for visitors, then sessions to watch
|
|
3086
3150
|
vibiz replay <id> [--json] one session's signals and a link to watch it
|
|
3151
|
+
vibiz replays frames <id> [--at <ms>] [--moments error,rage_click] [--limit 6] [--out dir] [--open] [--json]
|
|
3152
|
+
pictures of what the visitor saw at each page, error,
|
|
3153
|
+
rage/dead click, abandoned form and the end (or at one
|
|
3154
|
+
instant): look for broken layout. --out saves the PNGs.
|
|
3155
|
+
Each new picture is one page screenshot; repeats free
|
|
3087
3156
|
vibiz projects list your projects
|
|
3088
3157
|
Web data (billed per call; every run is kept: vibiz runs, console \u25B8 Web data)
|
|
3089
3158
|
vibiz scrape <url> [--json] one page as markdown
|
|
@@ -3639,6 +3708,84 @@ async function emailForwardCommand(io, vibiz2, values, positionals) {
|
|
|
3639
3708
|
);
|
|
3640
3709
|
}
|
|
3641
3710
|
var positionalsAfter = (a, b) => b ? `${a} ${b}` : a;
|
|
3711
|
+
async function framesCommand(io, id, values) {
|
|
3712
|
+
if (!id) {
|
|
3713
|
+
throw new Error(
|
|
3714
|
+
"usage: vibiz replays frames <replay id> [--at <ms>] [--moments error,rage_click] [--limit 6] [--out dir] [--open]"
|
|
3715
|
+
);
|
|
3716
|
+
}
|
|
3717
|
+
const at = values.at === void 0 ? void 0 : Number(values.at);
|
|
3718
|
+
if (at !== void 0 && (!Number.isFinite(at) || at < 0)) {
|
|
3719
|
+
throw new Error(
|
|
3720
|
+
"--at is milliseconds from the session start (offset_ms in `vibiz replay <id>`)"
|
|
3721
|
+
);
|
|
3722
|
+
}
|
|
3723
|
+
const limit = values.limit === void 0 ? void 0 : Number(values.limit);
|
|
3724
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1 || limit > 12)) {
|
|
3725
|
+
throw new Error("--limit is 1 to 12");
|
|
3726
|
+
}
|
|
3727
|
+
const kinds = values.moments?.split(",").map((k) => k.trim()).filter(Boolean);
|
|
3728
|
+
const out = await (await io.client()).replays.frames(id, {
|
|
3729
|
+
...at !== void 0 ? { at } : {},
|
|
3730
|
+
...limit !== void 0 ? { limit } : {},
|
|
3731
|
+
...kinds?.length ? { moments: kinds } : {}
|
|
3732
|
+
});
|
|
3733
|
+
const saved = /* @__PURE__ */ new Map();
|
|
3734
|
+
if (values.out) {
|
|
3735
|
+
const local = io.local();
|
|
3736
|
+
const dir = resolve2(local.cwd(), values.out);
|
|
3737
|
+
await local.mkdir(dir, { recursive: true });
|
|
3738
|
+
const vibiz2 = await io.client();
|
|
3739
|
+
for (const f of out.frames) {
|
|
3740
|
+
if (!f.image || !f.id) continue;
|
|
3741
|
+
const bytes = await vibiz2.replays.frameImage(f.image.url).catch((err) => {
|
|
3742
|
+
io.error(` could not download ${f.id}: ${err instanceof Error ? err.message : err}`);
|
|
3743
|
+
return null;
|
|
3744
|
+
});
|
|
3745
|
+
if (!bytes) continue;
|
|
3746
|
+
const file = join7(dir, `${String(f.offset_ms).padStart(7, "0")}-${f.kind}-${f.id}.png`);
|
|
3747
|
+
await local.writeFile(file, bytes);
|
|
3748
|
+
saved.set(f.id, file);
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
if (values.open) {
|
|
3752
|
+
for (const f of out.frames) if (f.image) io.openUrl(f.image.url);
|
|
3753
|
+
}
|
|
3754
|
+
if (values.json) {
|
|
3755
|
+
io.log(
|
|
3756
|
+
JSON.stringify(
|
|
3757
|
+
{
|
|
3758
|
+
...out,
|
|
3759
|
+
frames: out.frames.map((f) => ({
|
|
3760
|
+
...f,
|
|
3761
|
+
...f.id && saved.has(f.id) ? { file: saved.get(f.id) } : {}
|
|
3762
|
+
}))
|
|
3763
|
+
},
|
|
3764
|
+
null,
|
|
3765
|
+
2
|
|
3766
|
+
)
|
|
3767
|
+
);
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
io.log(`Frames of ${out.replay_id} (${clock(out.duration_ms)}):`);
|
|
3771
|
+
if (!out.frames.length) io.log(" none");
|
|
3772
|
+
for (const f of out.frames) {
|
|
3773
|
+
const where = `${clock(f.offset_ms).padStart(6)} ${f.kind.padEnd(14)} ${f.page}`;
|
|
3774
|
+
const size = f.viewport ? ` ${f.viewport.width}x${f.viewport.height}` : "";
|
|
3775
|
+
const label = f.label === f.page ? "" : ` ${f.label}`;
|
|
3776
|
+
io.log(` ${dot(f.status === "ready" ? "ready" : "failed")} ${where}${size}${label}`);
|
|
3777
|
+
if (f.id && saved.has(f.id)) io.log(` saved ${saved.get(f.id)}`);
|
|
3778
|
+
else if (f.image) io.log(` ${f.image.url}`);
|
|
3779
|
+
if (f.error) io.log(` ${f.error.message} ${f.error.next_step}`);
|
|
3780
|
+
}
|
|
3781
|
+
const usd5 = (out.cost_micro_usd / 1e6).toFixed(4);
|
|
3782
|
+
const n = out.new_frames;
|
|
3783
|
+
io.log(
|
|
3784
|
+
`
|
|
3785
|
+
${n} new picture${n === 1 ? "" : "s"} ($${usd5}); pictures taken before are free. Links work for an hour.`
|
|
3786
|
+
);
|
|
3787
|
+
io.log(` ${out.note}`);
|
|
3788
|
+
}
|
|
3642
3789
|
var RESOURCE_NAMES = [
|
|
3643
3790
|
"hosting",
|
|
3644
3791
|
"database",
|
|
@@ -3755,6 +3902,19 @@ var SOCIAL_LABELS = {
|
|
|
3755
3902
|
};
|
|
3756
3903
|
var socialLabel = (platform3) => SOCIAL_LABELS[platform3] ?? platform3;
|
|
3757
3904
|
var cents2 = (n) => `$${(n / 100).toFixed(2)}`;
|
|
3905
|
+
var money2 = (n, currency = "usd") => {
|
|
3906
|
+
if (currency === "usd") return cents2(n);
|
|
3907
|
+
try {
|
|
3908
|
+
const f = new Intl.NumberFormat("en-US", {
|
|
3909
|
+
style: "currency",
|
|
3910
|
+
currency: currency.toUpperCase()
|
|
3911
|
+
});
|
|
3912
|
+
const digits = f.resolvedOptions().maximumFractionDigits ?? 2;
|
|
3913
|
+
return f.format(n / 10 ** digits);
|
|
3914
|
+
} catch {
|
|
3915
|
+
return `${n} ${currency}`;
|
|
3916
|
+
}
|
|
3917
|
+
};
|
|
3758
3918
|
var companyName = (c) => c.legal_name ?? (c.names[0] ? `${c.names[0].name} ${c.names[0].ending}` : "(no name yet)");
|
|
3759
3919
|
function printCompany(io, c) {
|
|
3760
3920
|
const label = c.entity_type === "llc" ? "LLC" : "C-Corp";
|
|
@@ -3784,6 +3944,101 @@ function printCompany(io, c) {
|
|
|
3784
3944
|
if (next) io.log(`
|
|
3785
3945
|
next: ${next}`);
|
|
3786
3946
|
}
|
|
3947
|
+
var USAGE_WORDS = {
|
|
3948
|
+
account: "your Stripe account (every project)",
|
|
3949
|
+
other_account: "its own Stripe account",
|
|
3950
|
+
vibiz: "through Vibiz",
|
|
3951
|
+
opted_out: "through Vibiz (opted out)",
|
|
3952
|
+
not_started: "no payments yet"
|
|
3953
|
+
};
|
|
3954
|
+
async function ownerStripeCommand(io, vibiz2, [sub, arg], flags) {
|
|
3955
|
+
const env = flags.dev ? "development" : "production";
|
|
3956
|
+
const out = (x, text) => flags.json ? io.log(JSON.stringify(x, null, 2)) : text();
|
|
3957
|
+
const print = (s) => {
|
|
3958
|
+
for (const e of ["production", "development"]) {
|
|
3959
|
+
const x = s.environments[e];
|
|
3960
|
+
io.log(
|
|
3961
|
+
`${e}: ${x.connected ? `connected${x.account_name ? ` (${x.account_name})` : ""}` : x.available ? "not connected" : "not available right now"}`
|
|
3962
|
+
);
|
|
3963
|
+
}
|
|
3964
|
+
io.log(`Use for every new project: ${s.use_for_all_projects ? "on" : "off"}`);
|
|
3965
|
+
for (const p of s.projects) {
|
|
3966
|
+
io.log(
|
|
3967
|
+
` ${p.name} production: ${USAGE_WORDS[p.production]} \xB7 development: ${USAGE_WORDS[p.development]}`
|
|
3968
|
+
);
|
|
3969
|
+
}
|
|
3970
|
+
io.log(`
|
|
3971
|
+
${s.note}`);
|
|
3972
|
+
};
|
|
3973
|
+
if (!sub) {
|
|
3974
|
+
const s = await vibiz2.payments.ownAccount.get();
|
|
3975
|
+
out(s, () => print(s));
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3978
|
+
if (sub === "connect") {
|
|
3979
|
+
const link = await vibiz2.payments.ownAccount.link(env);
|
|
3980
|
+
out(link, () => {
|
|
3981
|
+
io.log(
|
|
3982
|
+
`Give this link to the account's owner (until ${link.expires_at.slice(0, 16).replace("T", " ")}):
|
|
3983
|
+
${link.url}`
|
|
3984
|
+
);
|
|
3985
|
+
io.log(
|
|
3986
|
+
"\n They sign in to the console and connect their Stripe account once, for every project. Nobody else can complete it."
|
|
3987
|
+
);
|
|
3988
|
+
});
|
|
3989
|
+
if (flags.open) io.openUrl(link.url);
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3992
|
+
if (sub === "default") {
|
|
3993
|
+
if (arg !== "on" && arg !== "off")
|
|
3994
|
+
throw new Error("usage: vibiz payments account default <on|off>");
|
|
3995
|
+
const s = await vibiz2.payments.ownAccount.update({ use_for_all_projects: arg === "on" });
|
|
3996
|
+
out(s, () => print(s));
|
|
3997
|
+
return;
|
|
3998
|
+
}
|
|
3999
|
+
if (sub === "apply") {
|
|
4000
|
+
const input = flags.dev ? { env } : {};
|
|
4001
|
+
const preview = await vibiz2.payments.ownAccount.apply({ ...input, dry_run: true });
|
|
4002
|
+
const show = (r2) => {
|
|
4003
|
+
for (const c of r2.changed) {
|
|
4004
|
+
io.log(
|
|
4005
|
+
` ${r2.dry_run ? "will switch" : "switched"}: ${c.name} (${c.environment})${c.balance_cents ? ` \xB7 ${cents2(c.balance_cents)} stays in its balance to withdraw` : ""}${c.vibiz_subscriptions ? ` \xB7 ${c.vibiz_subscriptions} subscription(s) keep billing through Vibiz` : ""}`
|
|
4006
|
+
);
|
|
4007
|
+
}
|
|
4008
|
+
for (const x of r2.skipped) io.log(` skipped: ${x.name} (${x.environment}): ${x.message}`);
|
|
4009
|
+
io.log(`
|
|
4010
|
+
${r2.note}`);
|
|
4011
|
+
};
|
|
4012
|
+
if (!preview.changed.length || flags.json) {
|
|
4013
|
+
if (flags.yes && preview.changed.length) {
|
|
4014
|
+
const r2 = await vibiz2.payments.ownAccount.apply(input);
|
|
4015
|
+
out(r2, () => show(r2));
|
|
4016
|
+
return;
|
|
4017
|
+
}
|
|
4018
|
+
out(preview, () => {
|
|
4019
|
+
if (!preview.changed.length) io.log("Nothing to switch.");
|
|
4020
|
+
show(preview);
|
|
4021
|
+
});
|
|
4022
|
+
return;
|
|
4023
|
+
}
|
|
4024
|
+
show(preview);
|
|
4025
|
+
if (!flags.yes) {
|
|
4026
|
+
const typed = await io.promptLine('Type "yes" to switch these projects: ');
|
|
4027
|
+
if (typed.trim().toLowerCase() !== "yes") throw new Error("Not confirmed: nothing changed.");
|
|
4028
|
+
}
|
|
4029
|
+
const r = await vibiz2.payments.ownAccount.apply(input);
|
|
4030
|
+
out(r, () => show(r));
|
|
4031
|
+
return;
|
|
4032
|
+
}
|
|
4033
|
+
if (sub === "disconnect") {
|
|
4034
|
+
const r = await vibiz2.payments.ownAccount.disconnect(env);
|
|
4035
|
+
out(r, () => io.log(r.note));
|
|
4036
|
+
return;
|
|
4037
|
+
}
|
|
4038
|
+
throw new Error(
|
|
4039
|
+
"usage: vibiz payments account [connect | default <on|off> | apply | disconnect]"
|
|
4040
|
+
);
|
|
4041
|
+
}
|
|
3787
4042
|
function printPayments(io, a) {
|
|
3788
4043
|
const b = a.balance;
|
|
3789
4044
|
const own = a.account?.mode === "own";
|
|
@@ -3956,6 +4211,82 @@ function commandHelp(command) {
|
|
|
3956
4211
|
|
|
3957
4212
|
Everything: vibiz help` : HELP;
|
|
3958
4213
|
}
|
|
4214
|
+
async function campaignCreateInputFrom(values, vibiz2, id, env, mediaUrl, readFile4) {
|
|
4215
|
+
const v = values;
|
|
4216
|
+
let base = {};
|
|
4217
|
+
if (v.file) {
|
|
4218
|
+
const file = String(v.file);
|
|
4219
|
+
const text = await readFile4(file);
|
|
4220
|
+
try {
|
|
4221
|
+
base = JSON.parse(text);
|
|
4222
|
+
} catch (e) {
|
|
4223
|
+
throw new Error(
|
|
4224
|
+
`${file} is not valid JSON (${e instanceof Error ? e.message : String(e)}): fix it, or use the flags instead.`
|
|
4225
|
+
);
|
|
4226
|
+
}
|
|
4227
|
+
if (!base || typeof base !== "object" || Array.isArray(base))
|
|
4228
|
+
throw new Error(`${file} must hold one JSON object with the campaign's fields.`);
|
|
4229
|
+
delete base.confirm;
|
|
4230
|
+
}
|
|
4231
|
+
const list2 = (k) => Array.isArray(v[k]) ? v[k] : void 0;
|
|
4232
|
+
const str = (k) => typeof v[k] === "string" ? v[k] : void 0;
|
|
4233
|
+
const cents3 = (k, what) => {
|
|
4234
|
+
const raw = str(k);
|
|
4235
|
+
if (raw === void 0) return void 0;
|
|
4236
|
+
const n = Number(raw);
|
|
4237
|
+
if (!Number.isInteger(n) || n < 1) throw new Error(`--${k} is ${what} in cents, such as 2000`);
|
|
4238
|
+
return n;
|
|
4239
|
+
};
|
|
4240
|
+
const input = { ...base };
|
|
4241
|
+
if (str("type")) input.campaign_type = str("type");
|
|
4242
|
+
if (str("name")) input.name = str("name");
|
|
4243
|
+
const budget = cents3("budget", "the daily budget");
|
|
4244
|
+
if (budget) input.daily_budget_cents = budget;
|
|
4245
|
+
if (str("final-url")) input.final_url = str("final-url");
|
|
4246
|
+
if (list2("headline")) input.headlines = list2("headline");
|
|
4247
|
+
if (list2("desc")) input.descriptions = list2("desc");
|
|
4248
|
+
if (str("long-headline")) input.long_headline = str("long-headline");
|
|
4249
|
+
if (str("business-name")) input.business_name = str("business-name");
|
|
4250
|
+
if (list2("keyword")) {
|
|
4251
|
+
input.keywords = (list2("keyword") ?? []).map((k) => {
|
|
4252
|
+
const m = /^(.*):(broad|phrase|exact)$/.exec(k);
|
|
4253
|
+
return m?.[1] ? { text: m[1], match_type: m[2] } : k;
|
|
4254
|
+
});
|
|
4255
|
+
}
|
|
4256
|
+
if (str("country"))
|
|
4257
|
+
input.countries = String(str("country")).split(",").map((c) => c.trim().toUpperCase()).filter(Boolean);
|
|
4258
|
+
if (input.countries) input.countries = input.countries.map((c) => c.trim().toUpperCase());
|
|
4259
|
+
if (str("language")) input.languages = String(str("language")).split(",").filter(Boolean);
|
|
4260
|
+
if (str("start-date")) input.start_date = str("start-date");
|
|
4261
|
+
if (str("end-date")) input.end_date = str("end-date");
|
|
4262
|
+
if (str("bidding")) input.bidding = str("bidding");
|
|
4263
|
+
const maxCpc = cents3("max-cpc", "a cap per click");
|
|
4264
|
+
if (maxCpc) input.max_cpc_cents = maxCpc;
|
|
4265
|
+
const cpa = cents3("target-cpa", "a target cost per conversion");
|
|
4266
|
+
if (cpa) input.target_cpa_cents = cpa;
|
|
4267
|
+
if (v.active) input.start = "active";
|
|
4268
|
+
for (const spec of list2("image") ?? []) {
|
|
4269
|
+
const m = /^(landscape|square|logo)=(.+)$/.exec(spec);
|
|
4270
|
+
if (!m?.[1] || !m[2]) throw new Error("--image is landscape=<file|url>, square=\u2026 or logo=\u2026");
|
|
4271
|
+
const role = m[1];
|
|
4272
|
+
input.images = {
|
|
4273
|
+
...input.images,
|
|
4274
|
+
[role]: [...input.images?.[role] ?? [], await mediaUrl(m[2])]
|
|
4275
|
+
};
|
|
4276
|
+
}
|
|
4277
|
+
if (!input.account_id || !input.ad_account_id) {
|
|
4278
|
+
const accounts = (await vibiz2.projects.social.accounts(id, { env, kind: "ads" })).data;
|
|
4279
|
+
const google = str("account") ? accounts.find((a) => a.id === str("account")) : accounts.find((a) => a.platform === "google" && a.status === "connected");
|
|
4280
|
+
if (!google)
|
|
4281
|
+
throw new Error(
|
|
4282
|
+
"No Google Ads connection on this project: vibiz social connect google --ads (add --dev for the sandbox)."
|
|
4283
|
+
);
|
|
4284
|
+
input.account_id ??= google.id;
|
|
4285
|
+
const adAccounts = google.details.ad_accounts ?? [];
|
|
4286
|
+
input.ad_account_id ??= str("ad-account") ?? adAccounts[0]?.id;
|
|
4287
|
+
}
|
|
4288
|
+
return input;
|
|
4289
|
+
}
|
|
3959
4290
|
async function runCli(argv2, io) {
|
|
3960
4291
|
const [command, ...all] = argv2;
|
|
3961
4292
|
const cut = all.indexOf("--");
|
|
@@ -4018,6 +4349,17 @@ async function runCli(argv2, io) {
|
|
|
4018
4349
|
amount: { type: "string" },
|
|
4019
4350
|
interval: { type: "string" },
|
|
4020
4351
|
"lookup-key": { type: "string" },
|
|
4352
|
+
ios: { type: "string" },
|
|
4353
|
+
android: { type: "string" },
|
|
4354
|
+
"store-project": { type: "string" },
|
|
4355
|
+
currency: { type: "string" },
|
|
4356
|
+
"brand-name": { type: "string" },
|
|
4357
|
+
"brand-logo": { type: "string" },
|
|
4358
|
+
"brand-icon": { type: "string" },
|
|
4359
|
+
"brand-color": { type: "string" },
|
|
4360
|
+
"brand-background": { type: "string" },
|
|
4361
|
+
"brand-font": { type: "string" },
|
|
4362
|
+
"brand-border": { type: "string" },
|
|
4021
4363
|
user: { type: "string" },
|
|
4022
4364
|
"success-url": { type: "string" },
|
|
4023
4365
|
"cancel-url": { type: "string" },
|
|
@@ -4035,6 +4377,7 @@ async function runCli(argv2, io) {
|
|
|
4035
4377
|
ads: { type: "boolean", default: false },
|
|
4036
4378
|
media: { type: "string", multiple: true },
|
|
4037
4379
|
at: { type: "string" },
|
|
4380
|
+
moments: { type: "string" },
|
|
4038
4381
|
draft: { type: "boolean", default: false },
|
|
4039
4382
|
opt: { type: "string", multiple: true },
|
|
4040
4383
|
status: { type: "string" },
|
|
@@ -4118,7 +4461,22 @@ async function runCli(argv2, io) {
|
|
|
4118
4461
|
"business-name": { type: "string" },
|
|
4119
4462
|
"double-opt-in": { type: "string" },
|
|
4120
4463
|
"agent-limit": { type: "string" },
|
|
4121
|
-
description: { type: "string" }
|
|
4464
|
+
description: { type: "string" },
|
|
4465
|
+
// vibiz social campaigns create
|
|
4466
|
+
headline: { type: "string", multiple: true },
|
|
4467
|
+
desc: { type: "string", multiple: true },
|
|
4468
|
+
keyword: { type: "string", multiple: true },
|
|
4469
|
+
image: { type: "string", multiple: true },
|
|
4470
|
+
"final-url": { type: "string" },
|
|
4471
|
+
"long-headline": { type: "string" },
|
|
4472
|
+
"start-date": { type: "string" },
|
|
4473
|
+
"end-date": { type: "string" },
|
|
4474
|
+
bidding: { type: "string" },
|
|
4475
|
+
"max-cpc": { type: "string" },
|
|
4476
|
+
"target-cpa": { type: "string" },
|
|
4477
|
+
account: { type: "string" },
|
|
4478
|
+
"ad-account": { type: "string" },
|
|
4479
|
+
active: { type: "boolean", default: false }
|
|
4122
4480
|
}
|
|
4123
4481
|
});
|
|
4124
4482
|
const usagePeriod = (fallback) => {
|
|
@@ -4385,9 +4743,91 @@ ${await oneKeyLines(vibiz2, project.id)}`);
|
|
|
4385
4743
|
}
|
|
4386
4744
|
case "company": {
|
|
4387
4745
|
const vibiz2 = await io.client();
|
|
4746
|
+
if (positionals[0] === "app-store" && positionals[1] === "connect") {
|
|
4747
|
+
const link = await vibiz2.payments.appStore.link();
|
|
4748
|
+
if (values.json) io.log(JSON.stringify(link, null, 2));
|
|
4749
|
+
else {
|
|
4750
|
+
io.log(
|
|
4751
|
+
`Give this link to the account's owner (until ${link.expires_at.slice(0, 16).replace("T", " ")}):
|
|
4752
|
+
${link.url}`
|
|
4753
|
+
);
|
|
4754
|
+
io.log(
|
|
4755
|
+
"\n Signed in to the console, they paste a V2 secret key from their RevenueCat dashboard \u25B8 Project settings \u25B8 API keys. Never paste it in a chat."
|
|
4756
|
+
);
|
|
4757
|
+
}
|
|
4758
|
+
if (values.open) io.openUrl(link.url);
|
|
4759
|
+
return;
|
|
4760
|
+
}
|
|
4388
4761
|
const id = await io.project();
|
|
4389
4762
|
const env = values.dev ? "development" : void 0;
|
|
4390
4763
|
const [sub, arg, arg2] = positionals;
|
|
4764
|
+
if (sub === "app-store") {
|
|
4765
|
+
const out = (x, text) => values.json ? io.log(JSON.stringify(x, null, 2)) : text();
|
|
4766
|
+
const steps = (next) => {
|
|
4767
|
+
for (const n of next) io.log(` - ${n}`);
|
|
4768
|
+
};
|
|
4769
|
+
if (arg === "setup") {
|
|
4770
|
+
const r2 = await vibiz2.projects.payments.appStore.setup(
|
|
4771
|
+
id,
|
|
4772
|
+
{
|
|
4773
|
+
...values.ios ? { ios_bundle_id: values.ios } : {},
|
|
4774
|
+
...values.android ? { android_package: values.android } : {},
|
|
4775
|
+
...values["store-project"] ? { store_project_id: values["store-project"] } : {}
|
|
4776
|
+
},
|
|
4777
|
+
env
|
|
4778
|
+
);
|
|
4779
|
+
out(r2, () => {
|
|
4780
|
+
io.log(`App Store & Google Play (${r2.environment}) on ${r2.store_project.name}`);
|
|
4781
|
+
if (r2.ios)
|
|
4782
|
+
io.log(` iOS ${r2.ios.bundle_id}: ${r2.ios.env_var}=${r2.ios.public_key ?? "\u2013"}`);
|
|
4783
|
+
if (r2.android)
|
|
4784
|
+
io.log(
|
|
4785
|
+
` Android ${r2.android.package}: ${r2.android.env_var}=${r2.android.public_key ?? "\u2013"}`
|
|
4786
|
+
);
|
|
4787
|
+
for (const p of r2.products) {
|
|
4788
|
+
io.log(
|
|
4789
|
+
` ${p.lookup_key} \u2192 entitlement ${p.entitlement}${p.app_store_product_id ? ` \xB7 App Store ${p.app_store_product_id}` : ""}${p.play_product_id ? ` \xB7 Play ${p.play_product_id}` : ""}`
|
|
4790
|
+
);
|
|
4791
|
+
}
|
|
4792
|
+
io.log(
|
|
4793
|
+
` webhook: ${r2.webhook.registered ? "registered" : "not registered"} (${r2.webhook.url})`
|
|
4794
|
+
);
|
|
4795
|
+
io.log("\nNext:");
|
|
4796
|
+
steps(r2.next);
|
|
4797
|
+
});
|
|
4798
|
+
return;
|
|
4799
|
+
}
|
|
4800
|
+
if (arg === "subscriptions") {
|
|
4801
|
+
const r2 = await vibiz2.projects.payments.appStore.subscriptions(id, {
|
|
4802
|
+
...env ? { env } : {},
|
|
4803
|
+
...values.user ? { user: values.user } : {}
|
|
4804
|
+
});
|
|
4805
|
+
out(r2, () => {
|
|
4806
|
+
if (!r2.data.length) io.log("No App Store or Google Play purchases yet.");
|
|
4807
|
+
for (const x of r2.data) {
|
|
4808
|
+
io.log(
|
|
4809
|
+
`${x.id} ${x.source} ${x.user} ${x.store_product_id} ${x.status}${x.current_period_end ? ` until ${x.current_period_end.slice(0, 10)}` : ""}`
|
|
4810
|
+
);
|
|
4811
|
+
}
|
|
4812
|
+
});
|
|
4813
|
+
return;
|
|
4814
|
+
}
|
|
4815
|
+
if (arg) {
|
|
4816
|
+
throw new Error(
|
|
4817
|
+
"usage: vibiz payments app-store [connect | setup --ios <bundle id> [--android <package>] | subscriptions]"
|
|
4818
|
+
);
|
|
4819
|
+
}
|
|
4820
|
+
const r = await vibiz2.projects.payments.appStore.get(id, env);
|
|
4821
|
+
out(r, () => {
|
|
4822
|
+
io.log(
|
|
4823
|
+
`App Store & Google Play (${r.environment}): ${r.connected ? r.app ? "set up" : "connected, not set up" : "not connected"}`
|
|
4824
|
+
);
|
|
4825
|
+
steps(r.next);
|
|
4826
|
+
io.log(`
|
|
4827
|
+
${r.fees_note}`);
|
|
4828
|
+
});
|
|
4829
|
+
return;
|
|
4830
|
+
}
|
|
4391
4831
|
const show = (c) => values.json ? io.log(JSON.stringify(c, null, 2)) : printCompany(io, c);
|
|
4392
4832
|
if (!sub) {
|
|
4393
4833
|
try {
|
|
@@ -4475,13 +4915,24 @@ ${link.url}`);
|
|
|
4475
4915
|
}
|
|
4476
4916
|
case "payments": {
|
|
4477
4917
|
const vibiz2 = await io.client();
|
|
4918
|
+
if (positionals[0] === "account") {
|
|
4919
|
+
await ownerStripeCommand(io, vibiz2, positionals.slice(1), {
|
|
4920
|
+
dev: !!values.dev,
|
|
4921
|
+
json: !!values.json,
|
|
4922
|
+
open: !!values.open,
|
|
4923
|
+
yes: !!values.yes
|
|
4924
|
+
});
|
|
4925
|
+
return;
|
|
4926
|
+
}
|
|
4478
4927
|
const id = await io.project();
|
|
4479
4928
|
const env = values.dev ? "development" : void 0;
|
|
4480
4929
|
const [sub, arg, arg2] = positionals;
|
|
4481
4930
|
const out = (x, text) => values.json ? io.log(JSON.stringify(x, null, 2)) : text();
|
|
4482
4931
|
const amount = values.amount !== void 0 ? Number(values.amount) : void 0;
|
|
4483
4932
|
if (amount !== void 0 && !Number.isInteger(amount)) {
|
|
4484
|
-
throw new Error(
|
|
4933
|
+
throw new Error(
|
|
4934
|
+
"--amount is in the currency's smallest unit (cents; whole yen for jpy): --amount 1500"
|
|
4935
|
+
);
|
|
4485
4936
|
}
|
|
4486
4937
|
if (!sub) {
|
|
4487
4938
|
const a = await vibiz2.projects.payments.get(id, env);
|
|
@@ -4502,6 +4953,7 @@ ${link.url}`);
|
|
|
4502
4953
|
name: arg2,
|
|
4503
4954
|
price: {
|
|
4504
4955
|
unit_amount_cents: amount,
|
|
4956
|
+
...values.currency ? { currency: values.currency.toLowerCase() } : {},
|
|
4505
4957
|
type: interval ? "recurring" : "one_time",
|
|
4506
4958
|
...interval ? { interval } : {},
|
|
4507
4959
|
...values["lookup-key"] ? { lookup_key: values["lookup-key"] } : {}
|
|
@@ -4521,7 +4973,7 @@ ${link.url}`);
|
|
|
4521
4973
|
for (const x of p.prices) {
|
|
4522
4974
|
const every = x.interval ? ` / ${x.interval_count && x.interval_count > 1 ? `${x.interval_count} ` : ""}${x.interval}` : "";
|
|
4523
4975
|
io.log(
|
|
4524
|
-
` ${x.id} ${
|
|
4976
|
+
` ${x.id} ${money2(x.unit_amount_cents, x.currency)}${every}${x.lookup_key ? ` ${x.lookup_key}` : ""}${x.active ? "" : " (inactive)"}`
|
|
4525
4977
|
);
|
|
4526
4978
|
}
|
|
4527
4979
|
}
|
|
@@ -4534,11 +4986,23 @@ ${link.url}`);
|
|
|
4534
4986
|
"usage: vibiz payments checkout <price_id|lookup_key> --success-url <u> --cancel-url <u> [--user id]"
|
|
4535
4987
|
);
|
|
4536
4988
|
}
|
|
4989
|
+
const brand = Object.fromEntries(
|
|
4990
|
+
[
|
|
4991
|
+
["name", values["brand-name"]],
|
|
4992
|
+
["logo_url", values["brand-logo"]],
|
|
4993
|
+
["icon_url", values["brand-icon"]],
|
|
4994
|
+
["button_color", values["brand-color"]],
|
|
4995
|
+
["background_color", values["brand-background"]],
|
|
4996
|
+
["font", values["brand-font"]],
|
|
4997
|
+
["border_style", values["brand-border"]]
|
|
4998
|
+
].filter(([, v]) => v !== void 0)
|
|
4999
|
+
);
|
|
4537
5000
|
const c = await vibiz2.projects.payments.checkout(
|
|
4538
5001
|
id,
|
|
4539
5002
|
{
|
|
4540
5003
|
...arg.startsWith("pprice_") ? { price_id: arg } : { lookup_key: arg },
|
|
4541
5004
|
...values.user ? { user: values.user } : {},
|
|
5005
|
+
...Object.keys(brand).length ? { brand } : {},
|
|
4542
5006
|
success_url: values["success-url"],
|
|
4543
5007
|
cancel_url: values["cancel-url"]
|
|
4544
5008
|
},
|
|
@@ -4555,7 +5019,7 @@ ${c.url}`));
|
|
|
4555
5019
|
if (!list2.data.length) io.log("No payments yet.");
|
|
4556
5020
|
for (const p of list2.data) {
|
|
4557
5021
|
io.log(
|
|
4558
|
-
`${p.created_at.slice(0, 10)} ${p.id} ${
|
|
5022
|
+
`${p.created_at.slice(0, 10)} ${p.id} ${money2(p.amount_cents, p.currency).padStart(10)} net ${p.account === "own" ? money2(p.net_cents, p.currency) : cents2(p.net_cents)} ${p.status}${p.customer_email ? ` ${p.customer_email}` : ""}`
|
|
4559
5023
|
);
|
|
4560
5024
|
}
|
|
4561
5025
|
});
|
|
@@ -4651,8 +5115,13 @@ ${link.url}`
|
|
|
4651
5115
|
out(a, () => printPayments(io, a));
|
|
4652
5116
|
return;
|
|
4653
5117
|
}
|
|
5118
|
+
if (sub === "use-account") {
|
|
5119
|
+
const a = await vibiz2.projects.payments.ownAccount.useAccount(id, env);
|
|
5120
|
+
out(a, () => printPayments(io, a));
|
|
5121
|
+
return;
|
|
5122
|
+
}
|
|
4654
5123
|
throw new Error(
|
|
4655
|
-
"usage: vibiz payments [products [add] | checkout <price> | list | webhook <url> | withdraw | simulate <event> | connect | disconnect]"
|
|
5124
|
+
"usage: vibiz payments [products [add] | checkout <price> | list | webhook <url> | withdraw | simulate <event> | connect | disconnect | use-account | account | app-store]"
|
|
4656
5125
|
);
|
|
4657
5126
|
}
|
|
4658
5127
|
case "social": {
|
|
@@ -4676,6 +5145,29 @@ ${link.url}`
|
|
|
4676
5145
|
if (typed.trim().toLowerCase() !== "yes")
|
|
4677
5146
|
throw new Error("Not confirmed: nothing was sent.");
|
|
4678
5147
|
};
|
|
5148
|
+
const mediaUrl = async (m) => {
|
|
5149
|
+
if (/^https?:\/\//.test(m)) return m;
|
|
5150
|
+
const bytes = new Uint8Array(await io.local().readFile(m));
|
|
5151
|
+
const ext = m.split(".").pop()?.toLowerCase() ?? "";
|
|
5152
|
+
const contentType = {
|
|
5153
|
+
jpg: "image/jpeg",
|
|
5154
|
+
jpeg: "image/jpeg",
|
|
5155
|
+
png: "image/png",
|
|
5156
|
+
webp: "image/webp",
|
|
5157
|
+
gif: "image/gif",
|
|
5158
|
+
mp4: "video/mp4",
|
|
5159
|
+
mov: "video/quicktime",
|
|
5160
|
+
webm: "video/webm",
|
|
5161
|
+
pdf: "application/pdf"
|
|
5162
|
+
}[ext];
|
|
5163
|
+
if (!contentType) throw new Error(`${m}: jpg, png, webp, gif, mp4, mov, webm or pdf`);
|
|
5164
|
+
const up = await vibiz2.projects.social.upload(
|
|
5165
|
+
id,
|
|
5166
|
+
{ bytes, contentType, filename: m.split("/").pop() },
|
|
5167
|
+
env
|
|
5168
|
+
);
|
|
5169
|
+
return up.url;
|
|
5170
|
+
};
|
|
4679
5171
|
if (!sub) {
|
|
4680
5172
|
const o = await vibiz2.projects.social.get(id, env);
|
|
4681
5173
|
out(o, () => {
|
|
@@ -4746,31 +5238,7 @@ ${link.url}`
|
|
|
4746
5238
|
options[kv.slice(0, i)] = v === "true" ? true : v === "false" ? false : v;
|
|
4747
5239
|
}
|
|
4748
5240
|
const media = [];
|
|
4749
|
-
for (const m of values.media ?? []) {
|
|
4750
|
-
if (/^https?:\/\//.test(m)) media.push({ url: m });
|
|
4751
|
-
else {
|
|
4752
|
-
const bytes = new Uint8Array(await io.local().readFile(m));
|
|
4753
|
-
const ext = m.split(".").pop()?.toLowerCase() ?? "";
|
|
4754
|
-
const contentType = {
|
|
4755
|
-
jpg: "image/jpeg",
|
|
4756
|
-
jpeg: "image/jpeg",
|
|
4757
|
-
png: "image/png",
|
|
4758
|
-
webp: "image/webp",
|
|
4759
|
-
gif: "image/gif",
|
|
4760
|
-
mp4: "video/mp4",
|
|
4761
|
-
mov: "video/quicktime",
|
|
4762
|
-
webm: "video/webm",
|
|
4763
|
-
pdf: "application/pdf"
|
|
4764
|
-
}[ext];
|
|
4765
|
-
if (!contentType) throw new Error(`${m}: jpg, png, webp, gif, mp4, mov, webm or pdf`);
|
|
4766
|
-
const up = await vibiz2.projects.social.upload(
|
|
4767
|
-
id,
|
|
4768
|
-
{ bytes, contentType, filename: m.split("/").pop() },
|
|
4769
|
-
env
|
|
4770
|
-
);
|
|
4771
|
-
media.push({ url: up.url });
|
|
4772
|
-
}
|
|
4773
|
-
}
|
|
5241
|
+
for (const m of values.media ?? []) media.push({ url: await mediaUrl(m) });
|
|
4774
5242
|
const input = {
|
|
4775
5243
|
text: arg ?? "",
|
|
4776
5244
|
media,
|
|
@@ -4818,15 +5286,51 @@ ${link.url}`
|
|
|
4818
5286
|
showPost(p);
|
|
4819
5287
|
return;
|
|
4820
5288
|
}
|
|
5289
|
+
if (sub === "campaigns" && arg === "create") {
|
|
5290
|
+
const input = await campaignCreateInputFrom(
|
|
5291
|
+
values,
|
|
5292
|
+
vibiz2,
|
|
5293
|
+
id,
|
|
5294
|
+
env,
|
|
5295
|
+
mediaUrl,
|
|
5296
|
+
(f) => io.local().readFile(f, "utf8")
|
|
5297
|
+
);
|
|
5298
|
+
let ch;
|
|
5299
|
+
try {
|
|
5300
|
+
ch = await vibiz2.projects.social.createCampaign(id, input, env);
|
|
5301
|
+
} catch (e) {
|
|
5302
|
+
if (!(e instanceof VibizApiError) || e.details?.reason !== "confirmation_required")
|
|
5303
|
+
throw e;
|
|
5304
|
+
const google = (await vibiz2.projects.social.accounts(id, { env, kind: "ads" })).data.find(
|
|
5305
|
+
(a) => a.id === input.account_id
|
|
5306
|
+
);
|
|
5307
|
+
const currency = google?.details.ad_accounts?.find((a) => a.id === input.ad_account_id)?.currency ?? null;
|
|
5308
|
+
const money3 = formatMinor(input.daily_budget_cents, currency);
|
|
5309
|
+
await sure(
|
|
5310
|
+
`This creates the ${input.campaign_type} campaign "${input.name}" (${money3} a day) on the live Google Ads account, ${input.start === "active" ? "ACTIVE: it starts spending" : "paused: nothing is spent until you resume it"}.`
|
|
5311
|
+
);
|
|
5312
|
+
ch = await vibiz2.projects.social.createCampaign(id, { ...input, confirm: true }, env);
|
|
5313
|
+
}
|
|
5314
|
+
out(ch, () => {
|
|
5315
|
+
io.log(`${ch.id} create_campaign ${ch.status}`);
|
|
5316
|
+
if (ch.result?.campaign_id)
|
|
5317
|
+
io.log(
|
|
5318
|
+
` campaign ${ch.result.campaign_id} (${input.start === "active" ? "active" : "paused"}): vibiz social resume ${ch.result.campaign_id} starts it`
|
|
5319
|
+
);
|
|
5320
|
+
if (ch.next_step) io.log(` ${ch.next_step}`);
|
|
5321
|
+
if (ch.error) io.log(` ${ch.error}`);
|
|
5322
|
+
});
|
|
5323
|
+
return;
|
|
5324
|
+
}
|
|
4821
5325
|
if (sub === "campaigns") {
|
|
4822
5326
|
const list2 = await vibiz2.projects.social.campaigns(id, { env });
|
|
4823
5327
|
out(list2.data, () => {
|
|
4824
5328
|
if (!list2.data.length)
|
|
4825
5329
|
io.log("No campaigns (connect ads: vibiz social connect meta --ads).");
|
|
4826
5330
|
for (const c of list2.data) {
|
|
4827
|
-
const
|
|
5331
|
+
const money3 = (v) => formatMinor(v, c.currency);
|
|
4828
5332
|
io.log(
|
|
4829
|
-
`${c.id} ${c.status.padEnd(14)} ${
|
|
5333
|
+
`${c.id} ${c.status.padEnd(14)} ${money3(c.daily_budget_cents)}/day spent ${money3(c.spend_cents)} ${c.name}`
|
|
4830
5334
|
);
|
|
4831
5335
|
}
|
|
4832
5336
|
});
|
|
@@ -4855,7 +5359,7 @@ ${link.url}`
|
|
|
4855
5359
|
if (!(e instanceof VibizApiError) || e.details?.reason !== "confirmation_required")
|
|
4856
5360
|
throw e;
|
|
4857
5361
|
await sure(
|
|
4858
|
-
`This ${sub === "pause" ? "pauses" : sub === "resume" ? "resumes (spends money on)" : `sets ${budget}
|
|
5362
|
+
`This ${sub === "pause" ? "pauses" : sub === "resume" ? "resumes (spends money on)" : `sets ${formatMinor(budget, c.currency)} a day on`} the live campaign "${c.name}".`
|
|
4859
5363
|
);
|
|
4860
5364
|
ch = await vibiz2.projects.social.adChange(id, { ...input, confirm: true }, env);
|
|
4861
5365
|
}
|
|
@@ -4867,7 +5371,7 @@ ${link.url}`
|
|
|
4867
5371
|
return;
|
|
4868
5372
|
}
|
|
4869
5373
|
throw new Error(
|
|
4870
|
-
"usage: vibiz social [connect|accounts|post|posts|approve|reject|cancel|campaigns|pause|resume|budget]"
|
|
5374
|
+
"usage: vibiz social [connect|accounts|post|posts|approve|reject|cancel|campaigns [create]|pause|resume|budget]"
|
|
4871
5375
|
);
|
|
4872
5376
|
}
|
|
4873
5377
|
case "connectors": {
|
|
@@ -5441,6 +5945,10 @@ ${await oneKeyLines(vibiz2, id)}`);
|
|
|
5441
5945
|
return;
|
|
5442
5946
|
}
|
|
5443
5947
|
case "replays": {
|
|
5948
|
+
if (positionals[0] === "frames") {
|
|
5949
|
+
await framesCommand(io, positionals[1], values);
|
|
5950
|
+
return;
|
|
5951
|
+
}
|
|
5444
5952
|
const period = values.period ?? "7d";
|
|
5445
5953
|
if (!["24h", "7d", "30d"].includes(period)) throw new Error("--period is 24h, 7d or 30d");
|
|
5446
5954
|
const vibiz2 = await io.client();
|
|
@@ -5876,7 +6384,7 @@ Store the key now: it is not shown again.`
|
|
|
5876
6384
|
return;
|
|
5877
6385
|
}
|
|
5878
6386
|
case "docs": {
|
|
5879
|
-
const { DOC_TOPICS, DOCS } = await import("./src-
|
|
6387
|
+
const { DOC_TOPICS, DOCS } = await import("./src-MRGQURG7.js");
|
|
5880
6388
|
const topic = positionals[0];
|
|
5881
6389
|
if (!topic || !DOC_TOPICS.includes(topic)) {
|
|
5882
6390
|
for (const t of DOC_TOPICS) io.log(` vibiz docs ${t.padEnd(13)} ${DOCS[t].title}`);
|
|
@@ -5901,7 +6409,7 @@ ${DOCS[topic].body}`);
|
|
|
5901
6409
|
if (positionals[0])
|
|
5902
6410
|
throw new Error('usage: vibiz mcp (serve over stdio) | vibiz mcp add --clients "<client>"');
|
|
5903
6411
|
io.local();
|
|
5904
|
-
const { serveStdio } = await import("./src-
|
|
6412
|
+
const { serveStdio } = await import("./src-MRGQURG7.js");
|
|
5905
6413
|
await serveStdio({ version: cliVersion() });
|
|
5906
6414
|
return;
|
|
5907
6415
|
}
|