@erdoai/cli 0.282.0 → 0.283.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.
Files changed (2) hide show
  1. package/dist/index.js +1 -149
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,18 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // src/ads-container.ts
4
- function advertiserVerificationAction(container) {
5
- const verification = container.advertiser_verification;
6
- if (!verification || verification.action_url) return void 0;
7
- if (verification.status === "check_in_google_ads") {
8
- return `Google cannot expose advertiser verification for card-billed account ${container.customer_id} through the API. Open Admin \u2192 Policy \u2192 Account in Google Ads to check its status, and complete verification there only if Google shows it is pending.`;
9
- }
10
- if (verification.status === "PENDING_USER_ACTION" || verification.status === "FAILURE") {
11
- return `Google shows no business name or logo on ${container.customer_id}'s ads until the advertiser is verified. Get a link with: erdo org managed ads-container ${container.org_slug} --provision --start-verification`;
12
- }
13
- return void 0;
14
- }
15
-
16
3
  // src/refresh.ts
17
4
  function keepRunningCommand(state) {
18
5
  return `erdo datasets refresh keep-running ${state.dataset_slug || "<slug>"}`;
@@ -789,39 +776,6 @@ var ErdoClient = class {
789
776
  { successor_manager_slug: successorManagerSlug }
790
777
  );
791
778
  }
792
- // Reads the Google Ads container a managed org already has under this manager
793
- // and creates nothing, so it is safe to run against an org mid-setup: a 404
794
- // means the org has no container here, not that anything is broken.
795
- getManagedOrganizationAdsContainer(slug) {
796
- return this.request(
797
- "GET",
798
- `/v1/managed-organizations/${encodeURIComponent(slug)}/ads-container`
799
- );
800
- }
801
- // Creates the container — a sub-account under the manager's MCC plus the
802
- // delegated connection inside the managed org. `customerId` switches the call
803
- // from creating an account to adopting one that already sits directly under
804
- // the manager, which is the only way to attach a sub-account somebody made by
805
- // hand: Google Ads cannot delete an account, so creating a second one beside
806
- // it is permanent. `replaceCurrentAccount` is the one input with consequences:
807
- // provisioning refuses outright when the org is already running campaigns in
808
- // another account, and passing this accepts that those campaigns are left
809
- // behind, so the key is sent only when it is asked for rather than as a
810
- // `false` the server has to read.
811
- provisionManagedOrganizationAdsContainer(slug, input) {
812
- const body = {};
813
- if (input.customerId) body.customer_id = input.customerId;
814
- if (input.descriptiveName) body.descriptive_name = input.descriptiveName;
815
- if (input.currencyCode) body.currency_code = input.currencyCode;
816
- if (input.timeZone) body.time_zone = input.timeZone;
817
- if (input.replaceCurrentAccount) body.replace_current_account = true;
818
- if (input.startAdvertiserVerification) body.start_advertiser_verification = true;
819
- return this.request(
820
- "POST",
821
- `/v1/managed-organizations/${encodeURIComponent(slug)}/ads-container`,
822
- body
823
- );
824
- }
825
779
  // --- Custom page domains: the branded hostnames the org's pages serve from ---
826
780
  listCustomDomains() {
827
781
  return this.request("GET", "/v1/custom-domains");
@@ -4047,7 +4001,7 @@ businessProfileCmd.command("set").description("Save the organization's business
4047
4001
  }
4048
4002
  }
4049
4003
  );
4050
- var managed = org.command("managed").description("Operate client orgs via a manager account");
4004
+ var managed = org.command("managed").description("Operate client orgs through manager authority");
4051
4005
  managed.command("list").description("List the client orgs your org manages").action(async () => {
4052
4006
  try {
4053
4007
  const { organizations } = await new ErdoClient().listManagedOrganizations();
@@ -4130,108 +4084,6 @@ managed.command("add-member <orgSlug> <email>").description("Seat a person in a
4130
4084
  fail(e);
4131
4085
  }
4132
4086
  });
4133
- function printAdsContainer(c) {
4134
- console.log(`org: ${c.org_slug}`);
4135
- console.log(`customer id: ${c.customer_id}`);
4136
- console.log(`manager (login customer id): ${c.login_customer_id}`);
4137
- console.log(`integration: ${c.integration_id}`);
4138
- if (c.descriptive_name) {
4139
- console.log(`name: ${c.descriptive_name}`);
4140
- }
4141
- console.log(`billing: ${c.billing_status}`);
4142
- if (c.billing_status === "unknown") {
4143
- process.stderr.write(
4144
- `Billing could not be checked for ${c.customer_id} \u2014 open the account in the Google Ads UI and confirm; this is not evidence that billing is missing.
4145
- `
4146
- );
4147
- } else if (!c.billing_configured) {
4148
- process.stderr.write(
4149
- `Billing is ${c.billing_status}: ${c.customer_id} cannot serve until a payments profile is linked to it in the Google Ads UI.
4150
- `
4151
- );
4152
- }
4153
- const v = c.advertiser_verification;
4154
- if (v) {
4155
- console.log(`advertiser verification: ${v.status}`);
4156
- if (v.action_url) console.log(`verification link: ${v.action_url}`);
4157
- if (v.completion_deadline) console.log(`verification deadline: ${v.completion_deadline}`);
4158
- const action = advertiserVerificationAction(c);
4159
- if (action) process.stderr.write(`${action}
4160
- `);
4161
- }
4162
- }
4163
- managed.command("ads-container <orgSlug>").description(
4164
- "Read the Google Ads account a managed org runs its campaigns in, or --provision one under your manager account"
4165
- ).option("--provision", "create the account and the org's delegated google_ads connection instead of reading them").option(
4166
- "--adopt <customerId>",
4167
- "with --provision: connect an existing client account already sitting directly under your manager account instead of creating a new one \u2014 for a sub-account created by hand in the Google Ads UI"
4168
- ).option(
4169
- "--replace-current-account",
4170
- "with --provision: go ahead even though the org already runs campaigns in another account. Google Ads cannot move a campaign, so those campaigns stay behind and have to be rebuilt"
4171
- ).option("--name <descriptiveName>", "display name for the new account (default: the org's name and slug)").option("--currency <code>", "ISO currency code for the new account, e.g. USD").option("--time-zone <tz>", "IANA time zone for the new account, e.g. America/New_York").option(
4172
- "--start-verification",
4173
- "with --provision: open a Google advertiser-verification session when the account still needs one, so the output carries the link a person finishes it on"
4174
- ).action(
4175
- async (orgSlug, opts) => {
4176
- try {
4177
- if (opts.replaceCurrentAccount && !opts.provision) {
4178
- fail(new Error("--replace-current-account only applies with --provision"));
4179
- }
4180
- if (opts.startVerification && !opts.provision) {
4181
- fail(new Error("--start-verification only applies with --provision"));
4182
- }
4183
- if (opts.adopt && !opts.provision) {
4184
- fail(new Error("--adopt only applies with --provision"));
4185
- }
4186
- if (opts.adopt && (opts.name || opts.currency || opts.timeZone)) {
4187
- fail(
4188
- new Error(
4189
- "--adopt takes an account that already exists, so --name, --currency and --time-zone do not apply \u2014 they describe an account being created"
4190
- )
4191
- );
4192
- }
4193
- const api = new ErdoClient();
4194
- if (!opts.provision) {
4195
- try {
4196
- printAdsContainer(await api.getManagedOrganizationAdsContainer(orgSlug));
4197
- } catch (e) {
4198
- if (e instanceof ErdoApiError && e.status === 404) {
4199
- fail(
4200
- new Error(
4201
- `${orgSlug} has no Google Ads container under this manager. Create one with: erdo org managed ads-container ${orgSlug} --provision`
4202
- )
4203
- );
4204
- }
4205
- throw e;
4206
- }
4207
- return;
4208
- }
4209
- const c = await api.provisionManagedOrganizationAdsContainer(orgSlug, {
4210
- customerId: opts.adopt,
4211
- descriptiveName: opts.name,
4212
- currencyCode: opts.currency,
4213
- timeZone: opts.timeZone,
4214
- replaceCurrentAccount: opts.replaceCurrentAccount,
4215
- startAdvertiserVerification: opts.startVerification
4216
- });
4217
- let outcome;
4218
- if (c.already_provisioned) outcome = `Google Ads container already existed for ${c.org_slug}`;
4219
- else if (c.adopted) outcome = `Adopted Google Ads account ${c.customer_id} as the container for ${c.org_slug}`;
4220
- else outcome = `Created Google Ads container for ${c.org_slug}`;
4221
- console.log(outcome);
4222
- printAdsContainer(c);
4223
- const leftBehind = c.previous_campaign_count ?? 0;
4224
- if (c.previous_customer_id && leftBehind > 0) {
4225
- process.stderr.write(
4226
- `${leftBehind} campaign${leftBehind === 1 ? "" : "s"} stayed in ${c.previous_customer_id}, the account this replaced. Google Ads cannot move a campaign between accounts and nothing in ${c.org_slug} resolves that account any more, so they have to be rebuilt in ${c.customer_id}.
4227
- `
4228
- );
4229
- }
4230
- } catch (e) {
4231
- fail(e);
4232
- }
4233
- }
4234
- );
4235
4087
  managed.command("handoff-token <orgSlug>").description("Mint a one-time token offering an ownerless managed org to another manager; shown ONCE").requiredOption("--successor <managerOrgSlug>", "the manager org allowed to redeem the token").action(async (orgSlug, opts) => {
4236
4088
  try {
4237
4089
  const res = await new ErdoClient().createManagedOrganizationHandoffToken(orgSlug, opts.successor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.282.0",
3
+ "version": "0.283.0",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {