@superwall/cli 2.6.0-beta.1 → 2.6.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 (147) hide show
  1. package/README.md +47 -16
  2. package/dist/{apple-Bmt_iywx.js → apple-D-rfsuDA.js} +17 -19
  3. package/dist/{approve-D2UgqaRx.js → approve-aPc5RoXB.js} +14 -13
  4. package/dist/{assets-B_quADds.js → assets-PyuXe45Y.js} +3 -3
  5. package/dist/auth.d.ts +11 -4
  6. package/dist/auth.js +4 -5
  7. package/dist/base-CAU0hWoI.js +82 -0
  8. package/dist/{billing-ZIETn0j4.js → billing-Dt6L_l9R.js} +3 -3
  9. package/dist/{build-BWjXurjs.js → build-CY5FnMNY.js} +35 -16
  10. package/dist/config-DOp5oChe.js +377 -0
  11. package/dist/{create-C3uklw-U.js → create-BZL5VH4L.js} +41 -41
  12. package/dist/{create-BCIgjRHn.js → create-D6w3UL0m.js} +9 -9
  13. package/dist/create-DM5Y1Pyk.js +18 -0
  14. package/dist/{doctor-D2Q1EZe8.js → doctor-C9FR0qw3.js} +50 -10
  15. package/dist/entry.js +45 -40
  16. package/dist/{environment-BocmdvZ-.js → environment-sE2wZYdg.js} +1 -1
  17. package/dist/{drivers-BQkO5tHs.js → existing--peXpOZj.js} +305 -8
  18. package/dist/framework-DW5fqjh4.js +65 -0
  19. package/dist/{source-BccdO4aL.js → git-Hf9Wc7Hp.js} +34 -92
  20. package/dist/{held-Bykbwy-m.js → held-CUBCOCGP.js} +8 -8
  21. package/dist/held-DVxvPMSG.js +15 -0
  22. package/dist/{install-dXZZ79Oe.js → install-C5d82gZF.js} +15 -17
  23. package/dist/{integrate-DiSjlOjC.js → integrate-D8J_X1bj.js} +33 -38
  24. package/dist/{login-5sWIKDI2.js → login-C6X7JrhM.js} +8 -9
  25. package/dist/{login-Jp6E6d2e.js → login-DXhm9L0F.js} +3 -3
  26. package/dist/login-et319ESO.js +13 -0
  27. package/dist/{lookup-CWzVfPpq.js → lookup-DqmIbUkv.js} +28 -4
  28. package/dist/{migrate-BKiOUsMY.js → migrate-BYF6hKZ2.js} +66 -45
  29. package/dist/{notification-url-BDBxbwZq.js → notification-url-Bo54nkXv.js} +4 -4
  30. package/dist/{open-DNd49kT-.js → open-xdgXUzaF.js} +2 -2
  31. package/dist/{org-Dud1rF9f.js → org-BD8U3D1_.js} +4 -4
  32. package/dist/{organization-7vJA3uy1.js → organization-D-ZlB3qU.js} +4 -4
  33. package/dist/{orgs-Z0H9WOs1.js → orgs-DQQJ3sw_.js} +1 -2
  34. package/dist/{paths-CzTJVpfi.js → paths-CIlyzF2I.js} +1 -1
  35. package/dist/{playbook-DJ__edOW.js → playbook-ecggWGFi.js} +10 -14
  36. package/dist/{products-Cqq59DBQ.js → products-CJq_iXv5.js} +1 -1
  37. package/dist/{promote-DLtPSvmL.js → promote-QVMLGYlU.js} +27 -28
  38. package/dist/{pull-AoUmaiMK.js → pull-CCXhb2a7.js} +72 -26
  39. package/dist/{pull-D-YuT3e0.js → pull-CrdsfsAl.js} +33 -39
  40. package/dist/pull-h71pL3r_.js +30 -0
  41. package/dist/push-BIq6R8Ro.js +29 -0
  42. package/dist/push-D6pJM_vv.js +21 -0
  43. package/dist/{push-BMblzg_6.js → push-DJMGG7zW.js} +23 -12
  44. package/dist/{push-BrzMFd4Z.js → push-DiMDwGfe.js} +15 -8
  45. package/dist/{registry-DDU10_Ix.js → registry-BSnQXft4.js} +1288 -901
  46. package/dist/registry-YwzTfCNc.js +22 -0
  47. package/dist/{resolve-DpOSDDdr.js → resolve-DO7bPota.js} +52 -6
  48. package/dist/{resources-CptT7HD6.js → resources-XwvXA20E.js} +15 -2
  49. package/dist/{run-r3foWfhV.js → run-B-YvxfRc.js} +15 -17
  50. package/dist/scan-B36wkZmI.js +4 -0
  51. package/dist/{scan-nVQO7JLx.js → scan-ViBhmrB7.js} +1 -1
  52. package/dist/{scope-l1qGLsgz.js → scope-BLLUxbrA.js} +24 -18
  53. package/dist/{scope-ehZ7L1nj.js → scope-Cg1AdAfO.js} +33 -3
  54. package/dist/screenshot-file-Dix2Qynm.js +127 -0
  55. package/dist/{sdk-DEfQttek.js → sdk-BFunw4Hc.js} +1 -1
  56. package/dist/{framework-CLmf4swr.js → selection-C07e_GGY.js} +4 -54
  57. package/dist/{series-D2ZpZ8cx.js → series-B8NJK4yS.js} +1 -1
  58. package/dist/{server-DLARhh1k.js → server-CBtHzl9y.js} +40 -18
  59. package/dist/server-CZwSfzKe.js +33 -0
  60. package/dist/{base-ChTi42M0.js → session-BfVx50iA.js} +8 -83
  61. package/dist/{session-Z0BeaJPf.js → session-BlrwAdGN.js} +1 -1
  62. package/dist/session-Cip4j99n.js +5 -0
  63. package/dist/{migration-Z69tLeHC.js → setup-a4B72xJ8.js} +290 -28
  64. package/dist/skills/superwall/SKILL.md +37 -10
  65. package/dist/skills/superwall/references/api.md +66 -21
  66. package/dist/skills/superwall/references/asa.md +109 -64
  67. package/dist/skills/superwall/references/dashboard-links.md +65 -28
  68. package/dist/skills/superwall/references/data-analytics.md +1 -1
  69. package/dist/skills/superwall/workflows/dashboard/setup.md +15 -5
  70. package/dist/skills/superwall/workflows/integrate/flutter.md +9 -7
  71. package/dist/skills/superwall-artifacts/SKILL.md +7 -2
  72. package/dist/skills/superwall-artifacts/references/cli.md +4 -1
  73. package/dist/skills/superwall-framework/SKILL.md +197 -14
  74. package/dist/skills/superwall-framework/references/cli.md +98 -7
  75. package/dist/skills/superwall-framework/references/examples.md +2 -2
  76. package/dist/skills/superwall-framework/references/migrate-from-editor.md +5 -0
  77. package/dist/skills/superwall-framework/references/migrate-from-native.md +5 -0
  78. package/dist/{skills-421SFEyF.js → skills-BB1uIt8t.js} +139 -9
  79. package/dist/{skills-CdKwaTRS.js → skills-SnxFa2in.js} +8 -12
  80. package/dist/source-DQs6iLtC.js +82 -0
  81. package/dist/{source-push-B4s6r9bB.js → source-push-w7miTr6m.js} +38 -14
  82. package/dist/{spinner-DPdBlZe2.js → spinner-BQp7fQvK.js} +7 -5
  83. package/dist/{starter-0OdVPH4l.js → starter-BlJ_InZJ.js} +16 -6
  84. package/dist/{status-Dsc7d3z2.js → status-DxsIw9zq.js} +9 -11
  85. package/dist/{output-Ggzq5_-t.js → storage-BR6imSqm.js} +40 -1
  86. package/dist/storekit-BqyujKQ_.js +203 -0
  87. package/dist/storekit-ELVCMF0X.js +15 -0
  88. package/dist/{bind-ClFjTt0U.js → theme-Ed0gz6hr.js} +29 -6
  89. package/dist/token-CWQ6tdva.js +100 -0
  90. package/dist/tools-skills/animate-onboarding/SKILL.md +1 -1
  91. package/dist/tools-skills/mobile-design/SKILL.md +1 -1
  92. package/dist/tools-skills/onboarding-questions/SKILL.md +1 -1
  93. package/dist/tools-skills/superwall/SKILL.md +43 -17
  94. package/dist/tools-skills/superwall/references/api.md +74 -24
  95. package/dist/tools-skills/superwall/references/asa.md +109 -64
  96. package/dist/tools-skills/superwall/references/dashboard-links.md +65 -28
  97. package/dist/tools-skills/superwall/references/data-analytics.md +1 -1
  98. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +4 -3
  99. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +21 -8
  100. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +9 -7
  101. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +4 -3
  102. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +2 -2
  103. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +4 -3
  104. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +4 -3
  105. package/dist/tools-skills/superwall-editor/SKILL.md +2 -3
  106. package/dist/tools.d.ts +6 -1
  107. package/dist/tools.js +1290 -747
  108. package/dist/{try-B8FYkTvQ.js → try-C3HW3hPZ.js} +20 -22
  109. package/dist/{lock-DgSx-p8Y.js → types-Dc9U_4kp.js} +86 -80
  110. package/dist/upgrade-Cw9jVt-r.js +348 -0
  111. package/dist/upgrade-DVsonzDF.js +27 -0
  112. package/package.json +11 -3
  113. package/dist/client-CyrYJzBF.js +0 -180
  114. package/dist/config-CGcG7GOt.js +0 -113
  115. package/dist/create-7HDW3DCl.js +0 -20
  116. package/dist/existing-Cl5x6_5u.js +0 -97
  117. package/dist/held-Chw3BtBV.js +0 -17
  118. package/dist/log-C0MDCfA2.js +0 -62
  119. package/dist/login-DZ8Pipf6.js +0 -17
  120. package/dist/pull-C1xm2zqG.js +0 -36
  121. package/dist/push-B42D8fKf.js +0 -22
  122. package/dist/push-Co5jk6Kr.js +0 -30
  123. package/dist/run-c1O2_8pp.js +0 -100
  124. package/dist/scan-D86kLtM7.js +0 -4
  125. package/dist/screenshot-file-XAS0Xy0e.js +0 -16
  126. package/dist/server-BEcsQaPu.js +0 -29
  127. package/dist/session-Csuaw6RU.js +0 -6
  128. package/dist/setup-C6NFy14d.js +0 -217
  129. package/dist/spawn-DmmmHIP-.js +0 -71
  130. package/dist/storage-DT_wxwJ8.js +0 -41
  131. package/dist/storekit-B9M2raxe.js +0 -47
  132. package/dist/storekit-BWZf-fNE.js +0 -17
  133. package/dist/telemetry-ovPiseFm.js +0 -56
  134. package/dist/theme-DUsCh-Vd.js +0 -25
  135. package/dist/token-Bu3FaRkv.js +0 -70
  136. package/dist/upgrade-B7TmvEPP.js +0 -206
  137. package/dist/upgrade-CAHyrWUL.js +0 -7
  138. /package/dist/{browser-Bp3yRKlU.js → browser-BVjaf98V.js} +0 -0
  139. /package/dist/{client-BJQXl62Q.js → client-BwYhzITp.js} +0 -0
  140. /package/dist/{design-lint-CiFc78aM.js → design-lint-mgO-2SGS.js} +0 -0
  141. /package/dist/{devtools-ByZ6XYnn.js → devtools-B6Vp6HMy.js} +0 -0
  142. /package/dist/{input-MDd67UIp.js → input-DOT_2Zvb.js} +0 -0
  143. /package/dist/{project-NoMtbMyl.js → project-BomArwSj.js} +0 -0
  144. /package/dist/{reports-HYVp169R.js → reports-hbxsd3Zo.js} +0 -0
  145. /package/dist/{storage-Bdz5AmqS.d.ts → storage-Bh3wT1Rn.d.ts} +0 -0
  146. /package/dist/{timing-Ca0TXY-A.js → timing-BKEEIBij.js} +0 -0
  147. /package/dist/{ui-D_qf3Gvw.js → ui-hFgji1e8.js} +0 -0
@@ -1,23 +1,21 @@
1
- import { r as NotLoggedInError } from "./token-Bu3FaRkv.js";
2
- import { a as stripAnsi, l as readJson, o as cache, r as formatJson, t as blocks } from "./output-Ggzq5_-t.js";
3
- import { o as AUTO_UPDATE_TARGET, s as CHANNEL, t as API_HOST, v as TELEMETRY_HOST, w as detectAgent, x as VERSION, y as TELEMETRY_KEY } from "./environment-BocmdvZ-.js";
4
- import { n as readSession } from "./storage-DT_wxwJ8.js";
5
- import { a as withQuery$1, n as ApiUnreachableError, t as ApiError } from "./client-CyrYJzBF.js";
6
- import { C as listKeySources, S as listBundleIdSuggestions, T as replaceRevenueProvider, _ as checkServerNotifications, b as importAppKey, c as resolveAscOrgApi, d as runAscDocs, f as parseParams, h as REVENUE_INTEGRATIONS, i as savedKey, l as resolveAscTeam, m as KEY_LABEL, n as testModeWarning, p as KEY_KINDS, r as chooseKeyApp, t as upsertHeldKey, u as sendAscRequest, v as copyAppKey, w as removeAppKey, x as keyKind, y as findIntegrations } from "./held-Bykbwy-m.js";
7
- import { f as writeDefaultApp, i as readOnboardedApp, r as readDefaultApp, t as readAnonymousId } from "./config-CGcG7GOt.js";
8
- import { a as defineCommand, d as readInput, i as defineCatalog, r as UsageError, t as apiCall } from "./spinner-DPdBlZe2.js";
9
- import { n as fg, t as THEME } from "./theme-DUsCh-Vd.js";
10
- import { n as runWhoami } from "./session-Z0BeaJPf.js";
11
- import { i as orgIdOf, t as listOrgGroups } from "./orgs-Z0H9WOs1.js";
12
- import { M as textField, O as field, T as rowName, a as createEntitlement, c as createProject, h as listResource, i as createCampaign, j as parseJson, k as isRecord, m as listProjects, r as createApplication, s as createProduct, t as RESOURCES, u as isAppScoped, y as platformLabel } from "./resources-CptT7HD6.js";
13
- import { n as orgForNewProject } from "./org-Dud1rF9f.js";
14
- import { i as parseDashboardUrl, n as findApplication, r as findProject, t as appNotFound } from "./lookup-CWzVfPpq.js";
15
- import { a as pickScope, i as pickProject, n as chooseApp, r as pickOrganization, t as boundOrganization } from "./scope-l1qGLsgz.js";
16
- import { a as listAscConfigs, i as findAppNotificationUrl, o as removeAscConfig, t as ascProxy } from "./client-BJQXl62Q.js";
17
- import { i as listUnimportedAscProducts, n as findAscAppId, r as listAscApps, t as ascTypeDisplay } from "./products-Cqq59DBQ.js";
18
- import { n as readResourceFlags, r as textOf, t as fieldName } from "./input-MDd67UIp.js";
19
- import { a as runAscNotificationUrlSet, i as printServerNotifications, t as describeNotificationUrl } from "./notification-url-BDBxbwZq.js";
20
- import { t as platformForIntegration } from "./bind-ClFjTt0U.js";
1
+ import { i as NotLoggedInError } from "./token-CWQ6tdva.js";
2
+ import { f as formatJson, h as cache, m as stripAnsi, n as readSession, u as blocks, v as readJson } from "./storage-BR6imSqm.js";
3
+ import { o as AUTO_UPDATE_TARGET, s as CHANNEL, t as API_HOST, v as TELEMETRY_HOST, w as detectAgent, x as VERSION, y as TELEMETRY_KEY } from "./environment-sE2wZYdg.js";
4
+ import { C as withQuery$1, b as ApiUnreachableError, f as writeDefaultApp, i as readOnboardedApp, r as readDefaultApp, t as readAnonymousId, y as ApiError } from "./config-DOp5oChe.js";
5
+ import { C as listKeySources, S as listBundleIdSuggestions, T as replaceRevenueProvider, _ as checkServerNotifications, b as importAppKey, c as resolveAscOrgApi, d as runAscDocs, f as parseParams, h as REVENUE_INTEGRATIONS, i as savedKey, l as resolveAscTeam, m as KEY_LABEL, n as testModeWarning, p as KEY_KINDS, r as chooseKeyApp, t as upsertHeldKey, u as sendAscRequest, v as copyAppKey, w as removeAppKey, x as keyKind, y as findIntegrations } from "./held-CUBCOCGP.js";
6
+ import { M as textField, O as field, T as rowName, a as createEntitlement, c as createProject, h as listResource, i as createCampaign, j as parseJson, k as isRecord, m as listProjects, r as createApplication, s as createProduct, t as RESOURCES, u as isAppScoped, y as platformLabel } from "./resources-XwvXA20E.js";
7
+ import { i as orgIdOf, t as listOrgGroups } from "./orgs-DQQJ3sw_.js";
8
+ import { a as defineCommand, d as readInput, i as defineCatalog, r as UsageError, t as apiCall } from "./spinner-BQp7fQvK.js";
9
+ import { n as orgForNewProject } from "./org-BD8U3D1_.js";
10
+ import { n as fg, r as platformForIntegration, t as THEME } from "./theme-Ed0gz6hr.js";
11
+ import { a as parseDashboardUrl, i as findProject, n as findApplication, t as appNotFound } from "./lookup-DqmIbUkv.js";
12
+ import { n as runWhoami } from "./session-BlrwAdGN.js";
13
+ import { a as pickScope, i as pickProject, n as chooseApp, r as pickOrganization, t as boundOrganization } from "./scope-BLLUxbrA.js";
14
+ import { a as listAscConfigs, i as findAppNotificationUrl, o as removeAscConfig, t as ascProxy } from "./client-BwYhzITp.js";
15
+ import { i as listUnimportedAscProducts, n as findAscAppId, r as listAscApps, t as ascTypeDisplay } from "./products-CJq_iXv5.js";
16
+ import { n as readResourceFlags, r as textOf, t as fieldName } from "./input-DOT_2Zvb.js";
17
+ import { t as timing } from "./timing-BKEEIBij.js";
18
+ import { a as runAscNotificationUrlSet, i as printServerNotifications, t as describeNotificationUrl } from "./notification-url-Bo54nkXv.js";
21
19
  import pc from "picocolors";
22
20
 
23
21
  //#region src/ui/help-layout.ts
@@ -144,7 +142,7 @@ const command = defineCommand({
144
142
  prompts: true,
145
143
  mcp: false,
146
144
  async run(ctx, input) {
147
- const { runLogin } = await import("./login-DZ8Pipf6.js");
145
+ const { runLogin } = await import("./login-et319ESO.js");
148
146
  return runLogin(ctx, input);
149
147
  }
150
148
  });
@@ -160,7 +158,7 @@ const command$1 = defineCommand({
160
158
  prompts: true,
161
159
  mcp: false,
162
160
  async run(ctx) {
163
- const { runLogout } = await import("./session-Csuaw6RU.js");
161
+ const { runLogout } = await import("./session-Cip4j99n.js");
164
162
  return runLogout(ctx);
165
163
  }
166
164
  });
@@ -279,9 +277,9 @@ async function runQuery(ctx, { args, flags }) {
279
277
  for (const [name, value$1] of parseUserParams(flags.param)) params.set(`param_${name}`, value$1);
280
278
  if (!ctx.json) ctx.ui.intro("Superwall query");
281
279
  if (ctx.target.app) for (const [name, value$1] of await appParams(ctx, ctx.target.app)) params.set(`param_${name}`, value$1);
282
- const query = params.toString();
280
+ const query$1 = params.toString();
283
281
  const output = await apiCall(ctx, "Querying ClickHouse", () => {
284
- return ctx.api.postText(`/v2/organizations/${encodeURIComponent(organizationId)}/query${query ? `?${query}` : ""}`, sql);
282
+ return ctx.api.postText(`/v2/organizations/${encodeURIComponent(organizationId)}/query${query$1 ? `?${query$1}` : ""}`, sql);
285
283
  });
286
284
  if (ctx.json) {
287
285
  let parsed;
@@ -380,12 +378,12 @@ function objectOf$1(schema) {
380
378
  if (found) return found;
381
379
  }
382
380
  }
383
- function fieldsOf(schema, depth = 0) {
381
+ function fieldsOf$1(schema, depth = 0) {
384
382
  const object = objectOf$1(schema);
385
383
  if (!object?.properties || depth >= MAX_DEPTH$1) return void 0;
386
384
  const required = new Set(object.required ?? []);
387
385
  return Object.entries(object.properties).map(([name, field$1]) => {
388
- const nested = fieldsOf(field$1, depth + 1);
386
+ const nested = fieldsOf$1(field$1, depth + 1);
389
387
  return {
390
388
  name,
391
389
  type: typeOf(field$1),
@@ -429,7 +427,7 @@ function deriveApiIndex(spec) {
429
427
  ...param.description ? { description: oneLine(param.description) } : {}
430
428
  };
431
429
  }),
432
- ...op$1.requestBody ? { body: fieldsOf(op$1.requestBody.content?.["application/json"]?.schema) ?? [] } : {},
430
+ ...op$1.requestBody ? { body: fieldsOf$1(op$1.requestBody.content?.["application/json"]?.schema) ?? [] } : {},
433
431
  returns: Object.keys(returned?.properties ?? {})
434
432
  });
435
433
  }
@@ -440,8 +438,15 @@ function deriveApiIndex(spec) {
440
438
  operations
441
439
  };
442
440
  }
443
- async function downloadApiIndex() {
444
- const res = await fetch(specUrl());
441
+ const DOWNLOAD_TIMEOUT_MS = 1e4;
442
+ async function downloadApiIndex(timeoutMs = DOWNLOAD_TIMEOUT_MS) {
443
+ let res;
444
+ try {
445
+ res = await fetch(specUrl(), { signal: AbortSignal.timeout(timeoutMs) });
446
+ } catch (error) {
447
+ if (!(error instanceof Error) || error.name !== "TimeoutError") throw error;
448
+ throw new Error(`The Superwall API reference at ${specUrl()} didn't answer within ${timeoutMs / 1e3}s.`, { cause: error });
449
+ }
445
450
  if (!res.ok) throw new Error(`Couldn't fetch the Superwall API reference (HTTP ${res.status}).`);
446
451
  return deriveApiIndex(await res.json());
447
452
  }
@@ -508,8 +513,8 @@ function score(op$1, terms) {
508
513
  }
509
514
  return total;
510
515
  }
511
- function searchOperations(index, query) {
512
- const terms = query.toLowerCase().split(/\s+/).filter(Boolean);
516
+ function searchOperations(index, query$1) {
517
+ const terms = query$1.toLowerCase().split(/\s+/).filter(Boolean);
513
518
  return index.operations.map((op$1) => ({
514
519
  op: op$1,
515
520
  score: score(op$1, terms)
@@ -526,21 +531,24 @@ function renderFields(fields, indent = " ") {
526
531
  return [`${indent}${field$1.name}${field$1.required ? "" : "?"}: ${field$1.type}${field$1.description ? ` — ${field$1.description}` : ""}`, ...renderFields(field$1.fields ?? [], `${indent} `)];
527
532
  });
528
533
  }
529
- function renderOperation(op$1) {
534
+ function renderOperation(op$1, commandFor) {
530
535
  const out = [`${op$1.method} ${op$1.path}`, `${op$1.summary} · ${op$1.group}${op$1.scope ? ` · needs ${op$1.scope}` : ""}`];
531
536
  if (op$1.description) out.push("", op$1.description);
532
537
  const path = op$1.params.filter((param) => param.in === "path");
533
- const query = op$1.params.filter((param) => param.in === "query");
538
+ const query$1 = op$1.params.filter((param) => param.in === "query");
534
539
  if (path.length) out.push("", "Path:", ...renderFields(path));
535
- if (query.length) out.push("", "Query:", ...renderFields(query));
540
+ if (query$1.length) out.push("", "Query:", ...renderFields(query$1));
536
541
  if (op$1.body) out.push("", "Body (JSON):", ...op$1.body.length ? renderFields(op$1.body) : [" (empty)"]);
537
542
  if (op$1.returns.length) out.push("", `Returns: ${op$1.returns.join(", ")}`);
538
- out.push("", `Call it: superwall ${op$1.method.toLowerCase()} ${op$1.path}${op$1.body?.length ? " -d field=value …" : ""}`);
543
+ const fields = op$1.body?.length ? " -d field=value …" : "";
544
+ const raw = `superwall ${op$1.method.toLowerCase()} ${op$1.path}${fields}`;
545
+ const command$83 = commandFor?.(op$1);
546
+ out.push("", ...command$83 ? [`Call it: ${command$83}${fields}`, `Or: ${raw}`] : [`Call it: ${raw}`]);
539
547
  return out.join("\n");
540
548
  }
541
- function renderApiDocs(index, query = "", method) {
549
+ function renderApiDocs(index, query$1 = "", method, commandFor) {
542
550
  const header = `Superwall API ${index.version} — ${index.operations.length} endpoints`;
543
- const q = query.trim();
551
+ const q = query$1.trim();
544
552
  if (!q) {
545
553
  const groups = /* @__PURE__ */ new Map();
546
554
  for (const op$1 of index.operations) groups.set(op$1.group, (groups.get(op$1.group) ?? 0) + 1);
@@ -554,16 +562,16 @@ function renderApiDocs(index, query = "", method) {
554
562
  ].join("\n");
555
563
  }
556
564
  const [first = "", ...rest] = q.split(/\s+/);
557
- if (/^(get|post|put|patch|delete)$/i.test(first) && rest[0]?.startsWith("/")) return renderApiDocs(index, rest.join(" "), first);
565
+ if (/^(get|post|put|patch|delete)$/i.test(first) && rest[0]?.startsWith("/")) return renderApiDocs(index, rest.join(" "), first, commandFor);
558
566
  if (q.startsWith("/")) {
559
567
  const ops = findOperations(index, q, method);
560
568
  if (ops.length === 0) return `${header}\n\nNo endpoint matches ${q}. Search instead: superwall api docs <words>.`;
561
- return ops.map(renderOperation).join("\n\n────────\n\n");
569
+ return ops.map((op$1) => renderOperation(op$1, commandFor)).join("\n\n────────\n\n");
562
570
  }
563
571
  const hits = searchOperations(index, q);
564
572
  if (hits.length === 0) return `${header}\n\nNothing matches "${q}". Run \`superwall api docs\` for every group.`;
565
573
  const [only] = hits;
566
- if (hits.length === 1 && only) return renderOperation(only);
574
+ if (hits.length === 1 && only) return renderOperation(only, commandFor);
567
575
  const shown = hits.slice(0, SEARCH_HITS);
568
576
  return [
569
577
  `${hits.length} endpoints match "${q}":`,
@@ -575,9 +583,9 @@ function renderApiDocs(index, query = "", method) {
575
583
  ].join("\n");
576
584
  }
577
585
  const METHOD = /^(get|post|put|patch|delete)$/i;
578
- function listMatchingOperations(index, query, method) {
579
- if (query.startsWith("/")) return findOperations(index, query, method);
580
- if (query) return searchOperations(index, query);
586
+ function listMatchingOperations(index, query$1, method) {
587
+ if (query$1.startsWith("/")) return findOperations(index, query$1, method);
588
+ if (query$1) return searchOperations(index, query$1);
581
589
  return index.operations;
582
590
  }
583
591
 
@@ -592,14 +600,17 @@ async function runApiRequest(ctx, api, request) {
592
600
  case "get": return api.get(withQuery$1(path, params));
593
601
  case "delete": return api.del(withQuery$1(path, params));
594
602
  case "post": return api.post(path, params);
603
+ case "put": return api.put(path, params);
595
604
  case "patch": return api.patch(path, params);
596
605
  }
597
606
  }).catch(async (error) => {
598
607
  if (!(error instanceof ApiError) || error.status >= 500 || error.status === 401) throw error;
608
+ if (namesMissingResource(error)) throw error;
599
609
  throw new Error(`${error.message}\n${await resolveReferenceHint(verb, path)}`, { cause: error });
600
610
  });
601
611
  ctx.output.data(res ?? { ok: true });
602
612
  }
613
+ const namesMissingResource = ({ status, detail }) => status === 404 && (detail.code === "resource_missing" || detail.type === "resource_missing" || detail.resourceType !== void 0);
603
614
  async function resolveReferenceHint(verb, path) {
604
615
  const index = await resolveApiIndex().catch(() => void 0);
605
616
  if (!index) return "The API reference: superwall api docs <words>";
@@ -635,6 +646,26 @@ const command$4 = defineCommand({
635
646
  }
636
647
  });
637
648
 
649
+ //#endregion
650
+ //#region src/core/api/commands.ts
651
+ async function resolveCommandLookup() {
652
+ const { listGroups: listGroups$1 } = await import("./registry-YwzTfCNc.js");
653
+ const catalogs = listGroups$1().flatMap((group$1) => group$1.commands.flatMap((command$83) => command$83.kind === "catalog" && command$83.commandFor ? [command$83.commandFor] : []));
654
+ return (endpoint) => {
655
+ for (const commandFor of catalogs) {
656
+ const found = commandFor(endpoint);
657
+ if (found) return found;
658
+ }
659
+ };
660
+ }
661
+ function withCommand(op$1, lookup) {
662
+ const command$83 = lookup(op$1);
663
+ return command$83 ? {
664
+ ...op$1,
665
+ command: command$83
666
+ } : op$1;
667
+ }
668
+
638
669
  //#endregion
639
670
  //#region src/commands/api/docs.ts
640
671
  const command$5 = defineCommand({
@@ -655,14 +686,15 @@ const command$5 = defineCommand({
655
686
  mcp: "read",
656
687
  async run(ctx, { args, flags }) {
657
688
  const found = args.query.find((word) => METHOD.test(word));
658
- const query = args.query.filter((word) => word !== found).join(" ");
689
+ const query$1 = args.query.filter((word) => word !== found).join(" ");
659
690
  const method = found?.toUpperCase();
660
691
  const index = await apiCall(ctx, "Loading the API reference", () => resolveApiIndex({ refresh: flags.refresh }));
692
+ const lookup = await resolveCommandLookup();
661
693
  if (ctx.json) return ctx.output.data({
662
694
  version: index.version,
663
- operations: listMatchingOperations(index, query, method)
695
+ operations: listMatchingOperations(index, query$1, method).map((op$1) => withCommand(op$1, lookup))
664
696
  });
665
- ctx.output.text(renderApiDocs(index, query, method));
697
+ ctx.output.text(renderApiDocs(index, query$1, method, lookup));
666
698
  }
667
699
  });
668
700
 
@@ -742,8 +774,33 @@ const command$8 = defineCommand({
742
774
  });
743
775
 
744
776
  //#endregion
745
- //#region src/commands/app-store-connect/store/apps.ts
777
+ //#region src/commands/api/put.ts
746
778
  const command$9 = defineCommand({
779
+ name: "put",
780
+ summary: "Make PUT requests to the Superwall API",
781
+ details: "Executes an arbitrary Superwall PUT endpoint. Depending on the path, it replaces account configuration whole, such as an audience's traffic weights.",
782
+ args: { path: {
783
+ describe: "API path, e.g. /v2/products",
784
+ required: true
785
+ } },
786
+ flags: { d: data },
787
+ examples: [[`put /v2/campaigns/<id>/audiences/<audience_id>/weights -d 'weights:=[{"variant_id":"<variant_id>","percentage":100}]'`, "Replace an audience's traffic weights"]],
788
+ auth: "required",
789
+ json: true,
790
+ prompts: false,
791
+ mcp: "destructive",
792
+ run(ctx, { args, flags }) {
793
+ return runApiRequest(ctx, ctx.api, {
794
+ verb: "put",
795
+ path: args.path,
796
+ data: flags.d
797
+ });
798
+ }
799
+ });
800
+
801
+ //#endregion
802
+ //#region src/commands/app-store-connect/store/apps.ts
803
+ const command$10 = defineCommand({
747
804
  name: "asc apps",
748
805
  summary: "Your apps in App Store Connect: name, bundle ID and id",
749
806
  flags: {
@@ -932,6 +989,15 @@ function describeAppleError$1(error) {
932
989
  });
933
990
  return `App Store Connect refused ${error.request.replace(/^(\w+) \/v2\/organizations\/[^/]+\/app-store-connect\/proxy\/[^/]+/, "$1 ")} (${error.status}):\n${lines.join("\n")}`;
934
991
  }
992
+ var AscRequestError = class extends Error {
993
+ constructor(message, status) {
994
+ super(message);
995
+ this.status = status;
996
+ }
997
+ };
998
+ function statusOf(error) {
999
+ return error instanceof ApiError || error instanceof AscRequestError ? error.status : void 0;
1000
+ }
935
1001
  var AscSession = class {
936
1002
  planned = [];
937
1003
  created = [];
@@ -954,7 +1020,7 @@ var AscSession = class {
954
1020
  const described = describeAppleError$1(error);
955
1021
  const made = this.created.map((resource) => `${resource.type} ${resource.id}`).join(", ");
956
1022
  if (!described && !made) throw error;
957
- throw new Error([described ?? error.message, ...made ? [`Already created: ${made}.`] : []].join("\n"));
1023
+ throw new AscRequestError([described ?? error.message, ...made ? [`Already created: ${made}.`] : []].join("\n"), error.status);
958
1024
  }
959
1025
  }
960
1026
  async get(path) {
@@ -990,7 +1056,7 @@ var AscSession = class {
990
1056
  try {
991
1057
  return (await this.get(path))?.one ?? void 0;
992
1058
  } catch (error) {
993
- if (error instanceof ApiError && error.status === 404) return void 0;
1059
+ if (statusOf(error) === 404) return void 0;
994
1060
  throw error;
995
1061
  }
996
1062
  }
@@ -1061,23 +1127,23 @@ async function assertConfirmed(session, yes$1, what) {
1061
1127
  async function list(context, api, resource, flags) {
1062
1128
  const { json } = context;
1063
1129
  if (resource === "apps") {
1064
- const query$1 = flags.search;
1130
+ const query$2 = flags.search;
1065
1131
  let room = limitOf(flags.limit) ?? Number.POSITIVE_INFINITY;
1066
1132
  const groups = (await apiCall(context, "Loading projects", () => listOrgGroups(api))).map((group$1) => {
1067
- const projects = matchingProjects(group$1.projects, query$1).slice(0, room);
1133
+ const projects = matchingProjects(group$1.projects, query$2).slice(0, room);
1068
1134
  room -= projects.length;
1069
1135
  return {
1070
1136
  ...group$1,
1071
1137
  projects
1072
1138
  };
1073
- }).filter((group$1) => group$1.projects.length > 0 || !query$1 && room > 0);
1139
+ }).filter((group$1) => group$1.projects.length > 0 || !query$2 && room > 0);
1074
1140
  if (json) return context.output.data(groups.flatMap(({ projects,...organization }) => projects.map((project$1) => organization.id ? {
1075
1141
  ...project$1,
1076
1142
  organization
1077
1143
  } : project$1)));
1078
1144
  if (groups.flatMap((group$1) => group$1.projects).length === 0) return context.output.render(blocks.list({
1079
1145
  items: [],
1080
- empty: query$1 ? `No project or app matches "${query$1}".` : "No projects yet - run `superwall apps create --name <name> --platform ios`."
1146
+ empty: query$2 ? `No project or app matches "${query$2}".` : "No projects yet - run `superwall apps create --name <name> --platform ios`."
1081
1147
  }));
1082
1148
  for (const group$1 of groups) {
1083
1149
  const heading$1 = groups.length > 1 ? `\`${group$1.name ?? `Organization ${group$1.id}`}\`${group$1.member ? "" : " (not a member)"} · ${formatCount(group$1.projects.length, "project")}` : formatCount(group$1.projects.length, "project");
@@ -1095,13 +1161,13 @@ async function list(context, api, resource, flags) {
1095
1161
  }
1096
1162
  const scope = await pickScope(context, api, isAppScoped(resource));
1097
1163
  const all = await apiCall(context, `Loading ${resource}`, () => listResource(api, resource, scope));
1098
- const query = flags.search;
1099
- const matched = query ? all.filter((row) => rowMatches(row, query)) : all;
1164
+ const query$1 = flags.search;
1165
+ const matched = query$1 ? all.filter((row) => rowMatches(row, query$1)) : all;
1100
1166
  const limit = limitOf(flags.limit);
1101
1167
  if (json) return context.output.data(limit === void 0 ? matched : matched.slice(0, limit));
1102
1168
  const shown = matched.slice(0, limit ?? RICH_ROWS);
1103
1169
  const noun = resource.replace(/s$/, "");
1104
- const heading = query ? `${formatCount(matched.length, noun)} matching "${query}", of ${all.length}` : formatCount(all.length, noun);
1170
+ const heading = query$1 ? `${formatCount(matched.length, noun)} matching "${query$1}", of ${all.length}` : formatCount(all.length, noun);
1105
1171
  context.output.render(blocks.step(`${heading}${scopeLabel(resource, scope)}`), blocks.list({
1106
1172
  items: shown.map((row) => {
1107
1173
  const label = rowName(row);
@@ -1111,7 +1177,7 @@ async function list(context, api, resource, flags) {
1111
1177
  meta: [identifier && identifier !== label ? identifier : void 0, secondaryId(label, row.id)].filter(Boolean).join(" ") || void 0
1112
1178
  };
1113
1179
  }),
1114
- empty: query ? `No ${resource} match "${query}".` : `No ${resource} yet.`
1180
+ empty: query$1 ? `No ${resource} match "${query$1}".` : `No ${resource} yet.`
1115
1181
  }));
1116
1182
  if (matched.length > shown.length) context.ui.info(`…${matched.length - shown.length} more. Narrow with --search <text>, or pass --limit <n> or --json for all.`);
1117
1183
  }
@@ -1166,17 +1232,17 @@ const SEARCHED_FIELDS = [
1166
1232
  "description",
1167
1233
  "public_api_key"
1168
1234
  ];
1169
- function rowMatches(row, query) {
1170
- const needle = query.toLowerCase();
1235
+ function rowMatches(row, query$1) {
1236
+ const needle = query$1.toLowerCase();
1171
1237
  return Object.entries(row).some(([field$1, value$1]) => {
1172
1238
  return SEARCHED_FIELDS.includes(field$1) && (typeof value$1 === "string" || typeof value$1 === "number") && String(value$1).toLowerCase().includes(needle);
1173
1239
  });
1174
1240
  }
1175
- function matchingProjects(projects, query) {
1176
- if (!query) return projects;
1241
+ function matchingProjects(projects, query$1) {
1242
+ if (!query$1) return projects;
1177
1243
  return projects.flatMap((project$1) => {
1178
- if (rowMatches(project$1, query)) return [project$1];
1179
- const apps = (project$1.applications ?? []).filter((app$1) => rowMatches(app$1, query));
1244
+ if (rowMatches(project$1, query$1)) return [project$1];
1245
+ const apps = (project$1.applications ?? []).filter((app$1) => rowMatches(app$1, query$1));
1180
1246
  return apps.length ? [{
1181
1247
  ...project$1,
1182
1248
  applications: apps
@@ -1261,13 +1327,13 @@ function rowsOf(response) {
1261
1327
  return response === void 0 || response === null ? [] : [response];
1262
1328
  }
1263
1329
  function renderRows(ctx, rows, noun, flags) {
1264
- const query = flags.search;
1265
- const matched = query ? rows.filter((row) => rowMatches(row, query)) : rows;
1330
+ const query$1 = flags.search;
1331
+ const matched = query$1 ? rows.filter((row) => rowMatches(row, query$1)) : rows;
1266
1332
  const limit = limitOf(flags.limit);
1267
1333
  if (ctx.json) return ctx.output.data(matched.slice(0, limit));
1268
1334
  const shown = matched.slice(0, limit ?? RICH_ROWS);
1269
1335
  const count = `${matched.length} ${matched.length === 1 ? noun : `${noun}s`}`;
1270
- ctx.output.render(blocks.step(query ? `${count} matching "${query}", of ${rows.length}` : count), blocks.list({
1336
+ ctx.output.render(blocks.step(query$1 ? `${count} matching "${query$1}", of ${rows.length}` : count), blocks.list({
1271
1337
  items: shown.map((row) => {
1272
1338
  const label = labelOf(row);
1273
1339
  return {
@@ -1275,7 +1341,7 @@ function renderRows(ctx, rows, noun, flags) {
1275
1341
  meta: [row.identifier, row.id].filter((part) => part !== void 0 && part !== null && String(part) !== label).map(String).join(" ") || void 0
1276
1342
  };
1277
1343
  }),
1278
- empty: query ? `Nothing matches "${query}".` : `No ${noun}s yet.`
1344
+ empty: query$1 ? `Nothing matches "${query$1}".` : `No ${noun}s yet.`
1279
1345
  }));
1280
1346
  if (matched.length > shown.length) ctx.ui.info(`…${matched.length - shown.length} more. Narrow with --search, or pass --limit or --json.`);
1281
1347
  }
@@ -1464,21 +1530,21 @@ function parseFlag(key, flag$1, raw) {
1464
1530
  }
1465
1531
  return parseChoice(key, flag$1, text);
1466
1532
  }
1467
- function parseArg(command$82, arg, word) {
1533
+ function parseArg(command$83, arg, word) {
1468
1534
  if (word === void 0 || !arg.choices) return word;
1469
1535
  const found = arg.choices.find((choice) => choice.toLowerCase() === word.toLowerCase());
1470
- if (!found) throw new UsageError(`${command$82} takes <${arg.name}> as one of: ${arg.choices.join(", ")} (not "${word}").`);
1536
+ if (!found) throw new UsageError(`${command$83} takes <${arg.name}> as one of: ${arg.choices.join(", ")} (not "${word}").`);
1471
1537
  return found;
1472
1538
  }
1473
- function parseInput(command$82, operation, words, raw) {
1539
+ function parseInput(command$83, operation, words, raw) {
1474
1540
  const specs = operation.flags ?? {};
1475
- for (const key of Object.keys(raw)) if (!(key in specs) && !(key in COMMON_FLAGS)) throw new UsageError(`${command$82} has no --${kebab(key)}. Run superwall ${command$82} --help for its flags.`);
1541
+ for (const key of Object.keys(raw)) if (!(key in specs) && !(key in COMMON_FLAGS)) throw new UsageError(`${command$83} has no --${kebab(key)}. Run superwall ${command$83} --help for its flags.`);
1476
1542
  const flags = Object.fromEntries(Object.entries(specs).map(([key, flag$1]) => [key, parseFlag(key, flag$1, raw[key])]));
1477
- for (const [key, flag$1] of Object.entries(specs)) if (flag$1.required && flags[key] === void 0) throw new UsageError(`${command$82} needs --${kebab(key)}.`);
1543
+ for (const [key, flag$1] of Object.entries(specs)) if (flag$1.required && flags[key] === void 0) throw new UsageError(`${command$83} needs --${kebab(key)}.`);
1478
1544
  const specArgs = operation.args ?? [];
1479
- if (words.length > specArgs.length) throw new UsageError(`${command$82} doesn't take "${words.slice(specArgs.length).join(" ")}".`);
1480
- const args = Object.fromEntries(specArgs.map((arg, index) => [arg.name, parseArg(command$82, arg, words[index])]));
1481
- for (const arg of specArgs) if (arg.required && args[arg.name] === void 0) throw new UsageError(`${command$82} needs <${arg.name}>.`);
1545
+ if (words.length > specArgs.length) throw new UsageError(`${command$83} doesn't take "${words.slice(specArgs.length).join(" ")}".`);
1546
+ const args = Object.fromEntries(specArgs.map((arg, index) => [arg.name, parseArg(command$83, arg, words[index])]));
1547
+ for (const arg of specArgs) if (arg.required && args[arg.name] === void 0) throw new UsageError(`${command$83} needs <${arg.name}>.`);
1482
1548
  return {
1483
1549
  args,
1484
1550
  flags,
@@ -1744,7 +1810,7 @@ async function runAvailabilitySet(session, input) {
1744
1810
 
1745
1811
  //#endregion
1746
1812
  //#region src/commands/app-store-connect/store/availability.ts
1747
- const command$10 = defineAscResource({
1813
+ const command$11 = defineAscResource({
1748
1814
  name: "asc availability",
1749
1815
  summary: "Where a subscription or in-app purchase is sold",
1750
1816
  operations: [{
@@ -1894,8 +1960,8 @@ async function resolveVersionId(session, input) {
1894
1960
  return id$1;
1895
1961
  }
1896
1962
  async function findVersion(session, id$1, include = []) {
1897
- const query = [`fields[appStoreVersions]=${[VERSION_FIELDS, ...include].join(",")}`, ...include.length ? [`include=${include.join(",")}`] : []];
1898
- const document = await session.next(`/v1/appStoreVersions/${id$1}?${query.join("&")}`);
1963
+ const query$1 = [`fields[appStoreVersions]=${[VERSION_FIELDS, ...include].join(",")}`, ...include.length ? [`include=${include.join(",")}`] : []];
1964
+ const document = await session.next(`/v1/appStoreVersions/${id$1}?${query$1.join("&")}`);
1899
1965
  const version = document.one;
1900
1966
  if (!version) throw new Error(`No App Store version ${id$1}.`);
1901
1967
  return {
@@ -1918,9 +1984,9 @@ async function runVersionsList(session, input) {
1918
1984
  versionString: textOf$1(input, "versionString"),
1919
1985
  appVersionState: textOf$1(input, "appVersionState")
1920
1986
  });
1921
- const query = Object.entries(filters).map(([key, value$1]) => `filter[${key}]=${encodeURIComponent(String(value$1))}`);
1987
+ const query$1 = Object.entries(filters).map(([key, value$1]) => `filter[${key}]=${encodeURIComponent(String(value$1))}`);
1922
1988
  const rows = ((await session.list(`/v1/apps/${app$1}/appStoreVersions?${[
1923
- ...query,
1989
+ ...query$1,
1924
1990
  `fields[appStoreVersions]=${VERSION_FIELDS}`,
1925
1991
  "limit=200"
1926
1992
  ].join("&")}`))?.data ?? []).map(rowOfVersion);
@@ -2065,7 +2131,7 @@ async function runBuildsList(session, input) {
2065
2131
  processingState: textOf$1(input, "processingState"),
2066
2132
  "preReleaseVersion.platform": textOf$1(input, "platform")
2067
2133
  });
2068
- const query = [
2134
+ const query$1 = [
2069
2135
  `filter[app]=${app$1}`,
2070
2136
  ...Object.entries(filters).map(([key, value$1]) => `filter[${key}]=${encodeURIComponent(String(value$1))}`),
2071
2137
  "sort=-uploadedDate",
@@ -2074,7 +2140,7 @@ async function runBuildsList(session, input) {
2074
2140
  "fields[preReleaseVersions]=version,platform",
2075
2141
  `limit=${limit}`
2076
2142
  ];
2077
- const document = await session.next(`/v1/builds?${query.join("&")}`);
2143
+ const document = await session.next(`/v1/builds?${query$1.join("&")}`);
2078
2144
  const rows = document.data.map((build) => rowOf$2(build, document));
2079
2145
  return {
2080
2146
  rows: buildRows(rows),
@@ -2130,7 +2196,7 @@ async function runBuildsExpire(session, input) {
2130
2196
 
2131
2197
  //#endregion
2132
2198
  //#region src/commands/app-store-connect/release/builds.ts
2133
- const command$11 = defineAscResource({
2199
+ const command$12 = defineAscResource({
2134
2200
  name: "asc builds",
2135
2201
  summary: "The app's uploaded builds: list, inspect, attach to a version, expire",
2136
2202
  operations: [
@@ -2216,7 +2282,7 @@ const command$11 = defineAscResource({
2216
2282
 
2217
2283
  //#endregion
2218
2284
  //#region src/commands/app-store-connect/api/delete.ts
2219
- const command$12 = defineCommand({
2285
+ const command$13 = defineCommand({
2220
2286
  name: "asc delete",
2221
2287
  summary: "Any App Store Connect DELETE request, through the signed proxy",
2222
2288
  args: { path: {
@@ -2251,7 +2317,7 @@ const command$12 = defineCommand({
2251
2317
 
2252
2318
  //#endregion
2253
2319
  //#region src/commands/app-store-connect/api/docs.ts
2254
- const command$13 = defineCommand({
2320
+ const command$14 = defineCommand({
2255
2321
  name: "asc docs",
2256
2322
  summary: "Apple's exact request schema for an endpoint",
2257
2323
  details: `A path (/v1/…), optionally with a verb, shows that endpoint's schema; words search every
@@ -2288,7 +2354,7 @@ in the background; --refresh downloads it now.`,
2288
2354
 
2289
2355
  //#endregion
2290
2356
  //#region src/commands/app-store-connect/api/get.ts
2291
- const command$14 = defineCommand({
2357
+ const command$15 = defineCommand({
2292
2358
  name: "asc get",
2293
2359
  summary: "Any App Store Connect GET request, through the signed proxy",
2294
2360
  args: { path: {
@@ -2498,7 +2564,7 @@ async function resolveTerritoryPoints(session, base, territories) {
2498
2564
  const equalized = await listEqualizations(session, base.point);
2499
2565
  const points = /* @__PURE__ */ new Map();
2500
2566
  const skipped = [];
2501
- for (const territory of new Set([base.territory, ...territories])) {
2567
+ for (const territory of new Set(territories)) {
2502
2568
  const point = territory === base.territory ? base.point : equalized ? equalized.get(territory) : placeholder(`price-point-${territory}`);
2503
2569
  if (point) points.set(territory, point);
2504
2570
  else skipped.push(territory);
@@ -2712,20 +2778,24 @@ async function runPricesSet(session, input) {
2712
2778
  const PRICED = ["subscription", "iap"];
2713
2779
  const POLL_INTERVAL_MS = 1e3;
2714
2780
  const POLL_ATTEMPTS = 60;
2781
+ const COMMIT_ATTEMPTS = 3;
2782
+ const COMMIT_PAUSE_MS = 2e3;
2715
2783
  const SCREENSHOT = {
2716
2784
  subscription: {
2717
2785
  of: (id$1) => `/v1/subscriptions/${id$1}/appStoreReviewScreenshot`,
2718
2786
  path: "/v1/subscriptionAppStoreReviewScreenshots",
2719
2787
  type: "subscriptionAppStoreReviewScreenshots",
2720
2788
  owner: "subscription",
2721
- ownerType: "subscriptions"
2789
+ ownerType: "subscriptions",
2790
+ label: "subscription"
2722
2791
  },
2723
2792
  iap: {
2724
2793
  of: (id$1) => `/v2/inAppPurchases/${id$1}/appStoreReviewScreenshot`,
2725
2794
  path: "/v1/inAppPurchaseAppStoreReviewScreenshots",
2726
2795
  type: "inAppPurchaseAppStoreReviewScreenshots",
2727
2796
  owner: "inAppPurchaseV2",
2728
- ownerType: "inAppPurchases"
2797
+ ownerType: "inAppPurchases",
2798
+ label: "in-app purchase"
2729
2799
  }
2730
2800
  };
2731
2801
  function deliveryState(resource) {
@@ -2763,14 +2833,57 @@ async function resolveDeliveryState(session, path) {
2763
2833
  const errors = resource.attributes.assetDeliveryState;
2764
2834
  throw new Error(`Apple couldn't process the screenshot: ${JSON.stringify(isRecord(errors) ? errors.errors : errors)}`);
2765
2835
  }
2766
- await new Promise((done) => setTimeout(done, POLL_INTERVAL_MS));
2836
+ await timing.sleep(POLL_INTERVAL_MS);
2767
2837
  }
2768
2838
  return "PROCESSING";
2769
2839
  }
2840
+ async function readReservation(session, path) {
2841
+ try {
2842
+ const resource = await session.select(path);
2843
+ return resource ? { state: deliveryState(resource) } : "gone";
2844
+ } catch {
2845
+ return "unknown";
2846
+ }
2847
+ }
2848
+ function accepted(reservation) {
2849
+ return typeof reservation === "object" && reservation.state !== void 0 && reservation.state !== "AWAITING_UPLOAD";
2850
+ }
2851
+ async function commitUpload(session, path, body) {
2852
+ for (let attempt = 1;; attempt++) try {
2853
+ await session.send("patch", path, body);
2854
+ return;
2855
+ } catch (error) {
2856
+ const status = statusOf(error);
2857
+ if (status === void 0 || status < 500) throw error;
2858
+ const reservation = await readReservation(session, path);
2859
+ if (accepted(reservation)) return void 0;
2860
+ if (reservation === "gone" || attempt >= COMMIT_ATTEMPTS) return {
2861
+ failure: error,
2862
+ reservation,
2863
+ attempts: attempt
2864
+ };
2865
+ await timing.sleep(COMMIT_PAUSE_MS * attempt);
2866
+ }
2867
+ }
2868
+ async function failedCommitMessage(session, path, failure, label, replaced) {
2869
+ const id$1 = path.slice(path.lastIndexOf("/") + 1);
2870
+ const lines = [`Apple failed to commit the screenshot after its bytes were uploaded (${failure.attempts === 1 ? "1 attempt" : `${failure.attempts} attempts`}):`, ...failure.failure.message.split("\n").filter((line$1) => !line$1.startsWith("Already created:"))];
2871
+ if (failure.reservation === "gone") lines.push(`Apple no longer has the unfinished screenshot ${id$1}.`);
2872
+ else if (failure.reservation === "unknown") lines.push(`Couldn't read the unfinished screenshot ${id$1} to check its state, so it was left in place; it may stay in AWAITING_UPLOAD.`);
2873
+ else try {
2874
+ await session.send("delete", path);
2875
+ lines.push(`Deleted the unfinished screenshot ${id$1} so it doesn't stay in AWAITING_UPLOAD.`);
2876
+ } catch (error) {
2877
+ lines.push(`Couldn't delete the unfinished screenshot ${id$1}, so it stays in AWAITING_UPLOAD: ${error.message}`);
2878
+ }
2879
+ if (replaced) lines.push(`The earlier screenshot ${replaced} was deleted before the upload, so this ${label} has no review screenshot now.`);
2880
+ lines.push("This is an error on Apple's side. Try the upload again later.");
2881
+ return lines.join("\n");
2882
+ }
2770
2883
  async function runScreenshotsUpload(session, input) {
2771
2884
  const { kind, id: id$1 } = resolveTarget(input, PRICED);
2772
2885
  const spec = SCREENSHOT[kind];
2773
- const { readScreenshotFile } = await import("./screenshot-file-XAS0Xy0e.js");
2886
+ const { readScreenshotFile } = await import("./screenshot-file-Dix2Qynm.js");
2774
2887
  const file = readScreenshotFile(argOf(input, "file"));
2775
2888
  const existing = await selectScreenshot(session, kind, id$1);
2776
2889
  if (existing) await session.send("delete", `${spec.path}/${existing.id}`);
@@ -2784,7 +2897,7 @@ async function runScreenshotsUpload(session, input) {
2784
2897
  } }, "screenshot");
2785
2898
  if (!reserved) throw new Error("Apple reserved no upload for the screenshot.");
2786
2899
  await session.upload(uploadOperationsOf(reserved), file.bytes);
2787
- await session.send("patch", `${spec.path}/${reserved.id}`, { data: {
2900
+ const failed = await commitUpload(session, `${spec.path}/${reserved.id}`, { data: {
2788
2901
  type: spec.type,
2789
2902
  id: reserved.id,
2790
2903
  attributes: {
@@ -2792,6 +2905,7 @@ async function runScreenshotsUpload(session, input) {
2792
2905
  sourceFileChecksum: file.checksum
2793
2906
  }
2794
2907
  } });
2908
+ if (failed) throw new Error(await failedCommitMessage(session, `${spec.path}/${reserved.id}`, failed, spec.label, existing?.id));
2795
2909
  const state = await resolveDeliveryState(session, `${spec.path}/${reserved.id}`);
2796
2910
  return {
2797
2911
  value: {
@@ -2950,7 +3064,7 @@ async function runIapsDelete(session, input) {
2950
3064
 
2951
3065
  //#endregion
2952
3066
  //#region src/commands/app-store-connect/store/iaps.ts
2953
- const command$15 = defineAscResource({
3067
+ const command$16 = defineAscResource({
2954
3068
  name: "asc iaps",
2955
3069
  summary: "In-app purchases: consumables, non-consumables and non-renewing subscriptions",
2956
3070
  operations: [
@@ -3116,7 +3230,7 @@ const command$15 = defineAscResource({
3116
3230
 
3117
3231
  //#endregion
3118
3232
  //#region src/commands/app-store-connect/store/localizations.ts
3119
- const command$16 = defineAscResource({
3233
+ const command$17 = defineAscResource({
3120
3234
  name: "asc localizations",
3121
3235
  summary: "The App Store names and descriptions of a subscription, group or in-app purchase",
3122
3236
  details: `Each takes one of --subscription, --group or --iap. A localization belongs to a version
@@ -3314,7 +3428,7 @@ async function runMetadataAdd(session, input) {
3314
3428
 
3315
3429
  //#endregion
3316
3430
  //#region src/commands/app-store-connect/release/metadata.ts
3317
- const command$17 = defineAscResource({
3431
+ const command$18 = defineAscResource({
3318
3432
  name: "asc metadata",
3319
3433
  summary: "A version's App Store text per locale: What's New, description, keywords, URLs",
3320
3434
  operations: [
@@ -3383,7 +3497,7 @@ const command$17 = defineAscResource({
3383
3497
 
3384
3498
  //#endregion
3385
3499
  //#region src/commands/app-store-connect/keys/create.ts
3386
- const command$18 = defineCommand({
3500
+ const command$19 = defineCommand({
3387
3501
  name: "asc keys create",
3388
3502
  summary: "Create a key at Apple and save it, or save one you hold with --key-file",
3389
3503
  details: `Without --key-file it signs in to Apple, creates one key named "Superwall" on the team
@@ -3481,7 +3595,7 @@ A purchase_key is for the app's bundle ID; an app with none gets --bundle-id sav
3481
3595
  prompts: true,
3482
3596
  mcp: false,
3483
3597
  async run(ctx, input) {
3484
- const { runAscKeysCreate } = await import("./create-7HDW3DCl.js");
3598
+ const { runAscKeysCreate } = await import("./create-DM5Y1Pyk.js");
3485
3599
  return runAscKeysCreate(ctx, input);
3486
3600
  }
3487
3601
  });
@@ -3678,7 +3792,7 @@ async function runAscKeysSources(ctx, { flags }) {
3678
3792
 
3679
3793
  //#endregion
3680
3794
  //#region src/commands/app-store-connect/keys/delete.ts
3681
- const command$19 = defineCommand({
3795
+ const command$20 = defineCommand({
3682
3796
  name: "asc keys delete",
3683
3797
  summary: "Remove the app's saved key; with a team id instead, your organization's",
3684
3798
  details: "Nothing is revoked at Apple.",
@@ -3711,7 +3825,7 @@ const command$19 = defineCommand({
3711
3825
 
3712
3826
  //#endregion
3713
3827
  //#region src/commands/app-store-connect/keys/import.ts
3714
- const command$20 = defineCommand({
3828
+ const command$21 = defineCommand({
3715
3829
  name: "asc keys import",
3716
3830
  summary: "Reuse a key your organization already has, once Apple confirms it here",
3717
3831
  details: `Without --from it tries every key your organization has and saves the first Apple
@@ -3763,7 +3877,7 @@ With --from, replaces the target app's saved key.`,
3763
3877
 
3764
3878
  //#endregion
3765
3879
  //#region src/commands/app-store-connect/keys/list.ts
3766
- const command$21 = defineCommand({
3880
+ const command$22 = defineCommand({
3767
3881
  name: "asc keys list",
3768
3882
  summary: "Which keys the app has; without --app, your organization's",
3769
3883
  details: "Key id and issuer id of each. Changes nothing.",
@@ -3790,7 +3904,7 @@ const command$21 = defineCommand({
3790
3904
 
3791
3905
  //#endregion
3792
3906
  //#region src/commands/app-store-connect/keys/sources.ts
3793
- const command$22 = defineCommand({
3907
+ const command$23 = defineCommand({
3794
3908
  name: "asc keys sources",
3795
3909
  summary: "Keys on your organization's other iOS apps that import could use",
3796
3910
  flags: {
@@ -3812,7 +3926,7 @@ const command$22 = defineCommand({
3812
3926
 
3813
3927
  //#endregion
3814
3928
  //#region src/commands/app-store-connect/keys/update.ts
3815
- const command$23 = defineCommand({
3929
+ const command$24 = defineCommand({
3816
3930
  name: "asc keys update",
3817
3931
  summary: "Replace your organization's key for an Apple team",
3818
3932
  details: `Refused unless Apple confirms the new key belongs to the same team.
@@ -3868,7 +3982,7 @@ With --app it saves the key you hold on that app instead, as asc keys create --k
3868
3982
  prompts: true,
3869
3983
  mcp: false,
3870
3984
  async run(ctx, { args, flags }) {
3871
- const { upsertHeldKey: upsertHeldKey$1 } = await import("./held-Chw3BtBV.js");
3985
+ const { upsertHeldKey: upsertHeldKey$1 } = await import("./held-DVxvPMSG.js");
3872
3986
  return upsertHeldKey$1(ctx, {
3873
3987
  action: "update",
3874
3988
  key: {
@@ -3890,7 +4004,7 @@ With --app it saves the key you hold on that app instead, as asc keys create --k
3890
4004
 
3891
4005
  //#endregion
3892
4006
  //#region src/commands/app-store-connect/notification-url/check.ts
3893
- const command$24 = defineCommand({
4007
+ const command$25 = defineCommand({
3894
4008
  name: "asc notification-url check",
3895
4009
  summary: "Ask Apple whose URL each environment has",
3896
4010
  details: `For production and sandbox: this_app, superwall_app (another Superwall app's), other
@@ -3922,7 +4036,7 @@ const command$24 = defineCommand({
3922
4036
 
3923
4037
  //#endregion
3924
4038
  //#region src/commands/app-store-connect/notification-url/set.ts
3925
- const command$25 = defineCommand({
4039
+ const command$26 = defineCommand({
3926
4040
  name: "asc notification-url set",
3927
4041
  summary: "Write this app's URL where Apple has none",
3928
4042
  details: `Never replaces another server's URL: a conflict is reported and left alone (exit 1).
@@ -4097,7 +4211,7 @@ async function runOffersDelete(session, input) {
4097
4211
 
4098
4212
  //#endregion
4099
4213
  //#region src/commands/app-store-connect/store/offers.ts
4100
- const command$26 = defineAscResource({
4214
+ const command$27 = defineAscResource({
4101
4215
  name: "asc offers",
4102
4216
  summary: "Introductory offers of a subscription: free trials and discounted first periods",
4103
4217
  details: `Apple keeps one introductory offer per territory. create writes it to every territory the
@@ -4119,7 +4233,7 @@ priced in --territory and equalized.`,
4119
4233
  {
4120
4234
  name: "create",
4121
4235
  summary: "Create an introductory offer in every territory",
4122
- details: "Creates introductory offers in the selected territories. New offers with overlapping dates overwrite existing introductory offers.",
4236
+ details: "Creates introductory offers in the selected territories only; --territory just sets the price that is equalized. Apple rejects an offer whose dates overlap an existing one in the same territory (409): end it with asc offers update or remove it with asc offers delete first.",
4123
4237
  flags: {
4124
4238
  subscription: {
4125
4239
  type: "string",
@@ -4215,7 +4329,7 @@ priced in --territory and equalized.`,
4215
4329
 
4216
4330
  //#endregion
4217
4331
  //#region src/commands/app-store-connect/api/patch.ts
4218
- const command$27 = defineCommand({
4332
+ const command$28 = defineCommand({
4219
4333
  name: "asc patch",
4220
4334
  summary: "Any App Store Connect PATCH request, its body checked against Apple's schema",
4221
4335
  details: `Each -d names an attribute or a relationship of the body; its type comes from Apple's
@@ -4264,7 +4378,7 @@ Executes an arbitrary App Store Connect PATCH through the signed proxy, with sch
4264
4378
 
4265
4379
  //#endregion
4266
4380
  //#region src/commands/app-store-connect/api/post.ts
4267
- const command$28 = defineCommand({
4381
+ const command$29 = defineCommand({
4268
4382
  name: "asc post",
4269
4383
  summary: "Any App Store Connect POST request, its body checked against Apple's schema",
4270
4384
  details: `Each -d names an attribute or a relationship of the body; its type comes from Apple's
@@ -4313,7 +4427,7 @@ Executes an arbitrary App Store Connect POST through the signed proxy, with sche
4313
4427
 
4314
4428
  //#endregion
4315
4429
  //#region src/commands/app-store-connect/store/prices.ts
4316
- const command$29 = defineAscResource({
4430
+ const command$30 = defineAscResource({
4317
4431
  name: "asc prices",
4318
4432
  summary: "Prices of a subscription or in-app purchase, and Apple's price points",
4319
4433
  details: `Each takes --subscription or --iap. set on a subscription prices it in --territory and
@@ -4404,7 +4518,7 @@ async function printAscProducts(ctx, app$1, team$1) {
4404
4518
 
4405
4519
  //#endregion
4406
4520
  //#region src/commands/app-store-connect/store/products.ts
4407
- const command$30 = defineCommand({
4521
+ const command$31 = defineCommand({
4408
4522
  name: "asc products",
4409
4523
  summary: "The products of one App Store app: subscriptions and in-app purchases",
4410
4524
  args: { id: {
@@ -4660,7 +4774,7 @@ async function runReleaseStatus(session, input) {
4660
4774
 
4661
4775
  //#endregion
4662
4776
  //#region src/commands/app-store-connect/release/release.ts
4663
- const command$31 = defineAscResource({
4777
+ const command$32 = defineAscResource({
4664
4778
  name: "asc release",
4665
4779
  summary: "Ship a version: submit it for review, release it, run its phased release, check where it is",
4666
4780
  details: `submit adds the version to the app's open review submission, or a new one, with any
@@ -4736,7 +4850,7 @@ release on before the version is released; pause, resume and complete steer it a
4736
4850
 
4737
4851
  //#endregion
4738
4852
  //#region src/commands/app-store-connect/store/screenshots.ts
4739
- const command$32 = defineAscResource({
4853
+ const command$33 = defineAscResource({
4740
4854
  name: "asc screenshots",
4741
4855
  summary: "The App Review screenshot of a subscription or in-app purchase",
4742
4856
  operations: [{
@@ -4759,7 +4873,7 @@ const command$32 = defineAscResource({
4759
4873
 
4760
4874
  //#endregion
4761
4875
  //#region src/commands/app-store-connect/store/submit.ts
4762
- const command$33 = defineCommand({
4876
+ const command$34 = defineCommand({
4763
4877
  name: "asc submit",
4764
4878
  summary: "Submit subscriptions, groups and in-app purchases for App Review",
4765
4879
  details: `Adds the latest version of each to the app's open review submission, or a new one,
@@ -4916,7 +5030,7 @@ async function runSubscriptionGroupsDelete(session, input) {
4916
5030
 
4917
5031
  //#endregion
4918
5032
  //#region src/commands/app-store-connect/store/subscription-groups.ts
4919
- const command$34 = defineAscResource({
5033
+ const command$35 = defineAscResource({
4920
5034
  name: "asc subscription-groups",
4921
5035
  summary: "Subscription groups of an App Store app, and their localizations",
4922
5036
  operations: [
@@ -5013,7 +5127,7 @@ const command$34 = defineAscResource({
5013
5127
 
5014
5128
  //#endregion
5015
5129
  //#region src/commands/app-store-connect/setup/apple.ts
5016
- const command$35 = defineCommand({
5130
+ const command$36 = defineCommand({
5017
5131
  name: "setup apple",
5018
5132
  summary: "One Apple sign-in: create the keys an app is missing, set its notification URL",
5019
5133
  details: `What it does
@@ -5120,7 +5234,7 @@ Exit codes
5120
5234
  prompts: true,
5121
5235
  mcp: false,
5122
5236
  async run(ctx, input) {
5123
- const { runSetupApple } = await import("./apple-Bmt_iywx.js");
5237
+ const { runSetupApple } = await import("./apple-D-rfsuDA.js");
5124
5238
  return runSetupApple(ctx, input);
5125
5239
  }
5126
5240
  });
@@ -5316,7 +5430,7 @@ async function runSubscriptionsDelete(session, input) {
5316
5430
 
5317
5431
  //#endregion
5318
5432
  //#region src/commands/app-store-connect/store/subscriptions.ts
5319
- const command$36 = defineAscResource({
5433
+ const command$37 = defineAscResource({
5320
5434
  name: "asc subscriptions",
5321
5435
  summary: "Auto-renewable subscriptions: list, inspect, create one ready for review, change, delete",
5322
5436
  details: `create runs every step Apple needs, in order: the subscription, its localization
@@ -5500,7 +5614,7 @@ state and what is still missing.`,
5500
5614
 
5501
5615
  //#endregion
5502
5616
  //#region src/commands/app-store-connect/release/versions.ts
5503
- const command$37 = defineAscResource({
5617
+ const command$38 = defineAscResource({
5504
5618
  name: "asc versions",
5505
5619
  summary: "App Store versions: list, inspect, create, change, delete",
5506
5620
  details: `A <version> is the version's id, or its version string (1.2.0) with --asc-app and,
@@ -5638,7 +5752,7 @@ off iOS, --platform. --earliest-release-date (2026-11-01T08:00:00-07:00) goes wi
5638
5752
 
5639
5753
  //#endregion
5640
5754
  //#region src/core/apple-search-ads/catalog.ts
5641
- const APPLE_DOCS_BASE = "https://developer.apple.com/documentation/apple_ads";
5755
+ const APPLE_DOCS_BASE = "https://developer.apple.com/documentation/apple-ads-platform-api";
5642
5756
  const flag = (flag$1, key, type, describe$1) => ({
5643
5757
  flag: flag$1,
5644
5758
  key,
@@ -5647,73 +5761,66 @@ const flag = (flag$1, key, type, describe$1) => ({
5647
5761
  });
5648
5762
  const NAME = flag("name", "name", "string", "Name");
5649
5763
  const STATUS = flag("status", "status", "string", "ENABLED or PAUSED");
5650
- const ADAM_ID = flag("adam-id", "adamId", "number", "App Store app id (adamId)");
5651
- const MATCH_TYPE = flag("match-type", "matchType", "string", "BROAD or EXACT");
5764
+ const START = flag("start", "startTime", "string", "Start (yyyy-MM-ddTHH:mm:ss.SSS, UTC)");
5765
+ const END = flag("end", "endTime", "string", "End (yyyy-MM-ddTHH:mm:ss.SSS, UTC)");
5766
+ const BID_STRATEGY = flag("bid-strategy", "bidStrategy.bidStrategyType", "string", "MANUAL_CPT, MAX_CONVERSIONS, ... (with --bid-goal)");
5767
+ const BID_GOAL = flag("bid-goal", "bidStrategy.bidStrategyGoal", "string", "TAP, INSTALL, ... (with --bid-strategy)");
5768
+ const MATCH_TYPE = flag("match-type", "matchType", "string", "EXACT, BROAD, PHRASE or CATEGORY");
5652
5769
  const TEXT = flag("text", "text", "string", "Keyword text");
5653
- const KEYWORD_STATUS = flag("status", "status", "string", "ACTIVE or PAUSED");
5654
- const START = flag("start", "startTime", "string", "Start (YYYY-MM-DD or ISO timestamp)");
5655
- const END = flag("end", "endTime", "string", "End (YYYY-MM-DD or ISO timestamp)");
5656
- const CAMPAIGN_FIELDS = [
5770
+ const BID = flag("bid", "bid", "money", "Keyword bid");
5771
+ const IN_CAMPAIGN = flag("campaign", "campaignId", "number", "Campaign id");
5772
+ const IN_ADGROUP = flag("adgroup", "adGroupId", "number", "Ad group id");
5773
+ const CAMPAIGN_UPDATE = [
5657
5774
  NAME,
5658
- ADAM_ID,
5659
- flag("countries", "countriesOrRegions", "list", "Comma-separated country codes"),
5660
- flag("budget", "budgetAmount", "money", "Lifetime budget"),
5661
- flag("daily-budget", "dailyBudgetAmount", "money", "Daily budget"),
5662
- flag("supply-sources", "supplySources", "list", "Comma-separated supply sources"),
5663
- flag("ad-channel-type", "adChannelType", "string", "SEARCH or DISPLAY"),
5664
- flag("billing-event", "billingEvent", "string", "TAPS or IMPRESSIONS"),
5775
+ flag("countries", "targeting.countryOrRegion.include", "list", "Comma-separated country or region codes"),
5776
+ flag("daily-budget", "dailyBudget.value", "money", "Daily budget"),
5777
+ flag("supply-sources", "targeting.supplySource.include", "list", "Comma-separated supply sources (APPSTORE, MAPS)"),
5778
+ flag("supply-placements", "targeting.supplyPlacement.include", "list", "Comma-separated placements (APPSTORE_SEARCH_RESULTS, APPSTORE_TODAY_TAB, ...)"),
5779
+ BID_STRATEGY,
5780
+ BID_GOAL,
5665
5781
  START,
5666
5782
  END,
5667
5783
  STATUS
5668
5784
  ];
5669
- const ADGROUP_FIELDS = [
5785
+ const ADGROUP_UPDATE = [
5670
5786
  NAME,
5671
- flag("default-bid", "defaultBidAmount", "money", "Default CPT bid"),
5672
- flag("cpa-goal", "cpaGoal", "money", "CPA goal"),
5787
+ flag("bid", "bidStrategy.bid", "money", "Default bid"),
5788
+ BID_STRATEGY,
5789
+ BID_GOAL,
5673
5790
  flag("search-match", "automatedKeywordsOptIn", "boolean", "Enable Search Match"),
5674
5791
  START,
5675
5792
  END,
5676
5793
  STATUS
5677
5794
  ];
5678
- const KEYWORD_FIELDS = [
5795
+ const KEYWORD_CREATE = [
5796
+ IN_ADGROUP,
5679
5797
  TEXT,
5680
5798
  MATCH_TYPE,
5681
- flag("bid", "bidAmount", "money", "Keyword bid"),
5682
- KEYWORD_STATUS
5799
+ BID,
5800
+ STATUS
5683
5801
  ];
5684
- const NEGATIVE_FIELDS = [
5802
+ const KEYWORD_UPDATE = [BID, STATUS];
5803
+ const NEGATIVE_CREATE = [
5804
+ IN_CAMPAIGN,
5805
+ IN_ADGROUP,
5685
5806
  TEXT,
5686
5807
  MATCH_TYPE,
5687
- KEYWORD_STATUS
5688
- ];
5689
- const AD_FIELDS = [
5690
- NAME,
5691
- flag("creative-id", "creativeId", "number", "Creative id"),
5692
5808
  STATUS
5693
5809
  ];
5694
- const REPORT_FLAGS = [
5695
- flag("start", "startTime", "string", "Report start (YYYY-MM-DD)"),
5696
- flag("end", "endTime", "string", "Report end (YYYY-MM-DD)"),
5697
- flag("granularity", "granularity", "string", "HOURLY, DAILY, WEEKLY, or MONTHLY"),
5698
- flag("group-by", "groupBy", "list", "Group rows by dimension (e.g. countryOrRegion)")
5699
- ];
5700
- const SELECTOR_QUERY = [
5701
- "selector",
5702
- "field",
5703
- "op",
5704
- "values",
5705
- "order-by",
5706
- "fields",
5707
- "limit",
5708
- "offset",
5709
- "all"
5710
- ];
5711
- const LIST_QUERY = [
5712
- "fields",
5713
- "limit",
5714
- "offset",
5715
- "all"
5810
+ const BUDGET_UPDATE = [
5811
+ NAME,
5812
+ START,
5813
+ END,
5814
+ flag("amount", "value", "money", "Total budget")
5716
5815
  ];
5816
+ const CAMPAIGN_SCOPE = {
5817
+ flag: "campaign",
5818
+ field: "campaignId"
5819
+ };
5820
+ const ADGROUP_SCOPE = {
5821
+ flag: "adgroup",
5822
+ field: "adGroupId"
5823
+ };
5717
5824
  const op = (group$1, action, effect, method, path, summary, doc, rest = {}) => ({
5718
5825
  group: group$1,
5719
5826
  action,
@@ -5724,264 +5831,376 @@ const op = (group$1, action, effect, method, path, summary, doc, rest = {}) => (
5724
5831
  ...rest,
5725
5832
  effect
5726
5833
  });
5727
- const list$1 = (group$1, path, summary, doc, rest = {}) => {
5728
- return op(group$1, "list", "read", "GET", path, summary, doc, {
5729
- paged: "query",
5730
- query: LIST_QUERY,
5834
+ const query = (group$1, path, summary, doc, rest = {}) => {
5835
+ return op(group$1, "list", "read", "POST", path, summary, doc, {
5836
+ body: "query",
5837
+ paged: true,
5838
+ details: "Queries with POST; changes nothing.",
5731
5839
  ...rest
5732
5840
  });
5733
5841
  };
5734
5842
  const byId = (group$1, path, summary, doc, rest = {}) => {
5735
5843
  return op(group$1, "get", "read", "GET", path, summary, doc, {
5736
5844
  positional: "id",
5737
- query: ["fields"],
5738
5845
  ...rest
5739
5846
  });
5740
5847
  };
5741
- const find = (group$1, path, summary, doc, rest = {}) => {
5742
- return op(group$1, "find", "read", "POST", path, summary, doc, {
5743
- body: "selector",
5744
- paged: "selector",
5745
- query: SELECTOR_QUERY,
5848
+ const remove = (group$1, path, summary, doc, rest = {}) => {
5849
+ return op(group$1, "delete", "destructive", "DELETE", path, summary, doc, {
5850
+ positional: "id",
5746
5851
  ...rest
5747
5852
  });
5748
5853
  };
5854
+ const appReport = (action, path, summary, doc, scoped) => {
5855
+ return op("reports", action, "read", "POST", `/reports/apps/${path}/query`, summary, doc, {
5856
+ body: "report",
5857
+ paged: true,
5858
+ zoned: true,
5859
+ filters: [{
5860
+ ...CAMPAIGN_SCOPE,
5861
+ text: true,
5862
+ required: scoped
5863
+ }, {
5864
+ ...ADGROUP_SCOPE,
5865
+ text: true
5866
+ }]
5867
+ });
5868
+ };
5869
+ const brandReport = (action, path, summary, doc, scoped) => {
5870
+ return op("brand-reports", action, "read", "POST", `/reports/business-brands/${path}/query`, summary, doc, {
5871
+ body: "report",
5872
+ paged: true,
5873
+ zoned: true,
5874
+ filters: [{
5875
+ ...CAMPAIGN_SCOPE,
5876
+ text: true,
5877
+ required: scoped
5878
+ }, {
5879
+ ...ADGROUP_SCOPE,
5880
+ text: true
5881
+ }]
5882
+ });
5883
+ };
5884
+ const PROMOTED_APP = {
5885
+ flag: "adam-id",
5886
+ field: "promotedObjectId",
5887
+ text: true,
5888
+ list: true
5889
+ };
5749
5890
  const ASA_OPERATIONS = [
5750
- list$1("campaigns", "/campaigns", "List campaigns", "get-all-campaigns"),
5751
- byId("campaigns", "/campaigns/{id}", "Get a campaign", "get-a-campaign"),
5752
- find("campaigns", "/campaigns/find", "Find campaigns with a selector", "find-campaigns"),
5753
- op("campaigns", "create", "destructive", "POST", "/campaigns", "Create a campaign", "create-a-campaign", {
5754
- details: "Creates a campaign with a budget and caller-selected status. ENABLED permits advertising once Apple’s serving requirements are met; this is not restricted to paused drafts.",
5891
+ query("campaigns", "/campaigns/query", "List campaigns", "post-campaigns-query"),
5892
+ byId("campaigns", "/campaigns/{id}", "Get a campaign", "get-campaigns-_id_"),
5893
+ op("campaigns", "create", "destructive", "POST", "/campaigns", "Create a campaign", "post-campaigns", {
5894
+ details: "Creates a campaign with a daily budget and caller-selected status. ENABLED permits advertising once Apple’s serving requirements are met; this is not restricted to paused drafts.",
5755
5895
  body: "object",
5756
- flags: CAMPAIGN_FIELDS
5896
+ flags: [
5897
+ NAME,
5898
+ flag("adam-id", "promotedObjectId", "string", "App Store app id (adamId) to promote"),
5899
+ flag("promoted-type", "promotedObjectType", "string", "APPSTORE_APP (default) or BUSINESS_BRAND"),
5900
+ flag("billing-event", "billingEvent", "string", "TAPS or IMPRESSIONS"),
5901
+ ...CAMPAIGN_UPDATE.slice(1)
5902
+ ],
5903
+ defaults: { promotedObjectType: "APPSTORE_APP" },
5904
+ account: "adAccountId"
5757
5905
  }),
5758
- op("campaigns", "update", "destructive", "PUT", "/campaigns/{id}", "Update a campaign", "update-a-campaign", {
5759
- details: "Overwrites campaign status, countries and daily/lifetime budgets; can enable spending or pause delivery.",
5906
+ op("campaigns", "update", "destructive", "PUT", "/campaigns/{id}", "Update a campaign", "put-campaigns-_id_", {
5907
+ details: "Overwrites campaign status, targeting, bid strategy and daily budget; can enable spending or pause delivery.",
5760
5908
  positional: "id",
5761
5909
  body: "object",
5762
- envelope: "campaign",
5763
- flags: CAMPAIGN_FIELDS
5910
+ flags: CAMPAIGN_UPDATE
5764
5911
  }),
5765
- op("campaigns", "delete", "destructive", "DELETE", "/campaigns/{id}", "Delete a campaign", "delete-a-campaign", { positional: "id" }),
5766
- list$1("adgroups", "/campaigns/{campaign}/adgroups", "List ad groups in a campaign", "get-all-ad-groups"),
5767
- byId("adgroups", "/campaigns/{campaign}/adgroups/{id}", "Get an ad group", "get-an-ad-group"),
5768
- find("adgroups", "/campaigns/{campaign}/adgroups/find", "Find ad groups in a campaign", "find-ad-groups"),
5769
- find("adgroups", "/adgroups/find", "Find ad groups across the org", "find-ad-groups-(org-level)"),
5770
- op("adgroups", "create", "destructive", "POST", "/campaigns/{campaign}/adgroups", "Create an ad group", "create-an-ad-group", {
5912
+ remove("campaigns", "/campaigns/{id}", "Delete a campaign", "delete-campaigns-_id_"),
5913
+ op("campaigns", "limited-reasons", "read", "GET", "/campaigns/{id}/legacy-app-limited-status-reason-details", "Why a legacy app campaign is limited", "get-campaigns-_id_-legacy-app-limited-status-reason-details", { positional: "id" }),
5914
+ query("adgroups", "/adgroups/query", "List ad groups", "post-adgroups-query", { filters: [CAMPAIGN_SCOPE] }),
5915
+ byId("adgroups", "/adgroups/{id}", "Get an ad group", "get-adgroups-_id_"),
5916
+ op("adgroups", "create", "destructive", "POST", "/adgroups", "Create an ad group", "post-adgroups", {
5771
5917
  details: "Creates a bid-bearing ad group. An enabled group in an eligible live campaign can begin serving and spending immediately.",
5772
5918
  body: "object",
5773
- flags: ADGROUP_FIELDS
5919
+ flags: [
5920
+ NAME,
5921
+ IN_CAMPAIGN,
5922
+ flag("pricing-model", "pricingModel", "string", "CPT, CPM or CPA (must match the campaign's billing event)"),
5923
+ ...ADGROUP_UPDATE.slice(1)
5924
+ ]
5774
5925
  }),
5775
- op("adgroups", "update", "destructive", "PUT", "/campaigns/{campaign}/adgroups/{id}", "Update an ad group", "update-an-ad-group", {
5776
- details: "Overwrites ad-group status, bids, CPA goal, dates and Search Match behavior.",
5926
+ op("adgroups", "update", "destructive", "PUT", "/adgroups/{id}", "Update an ad group", "put-adgroups-_id_", {
5927
+ details: "Overwrites ad-group status, bids, bid strategy, dates and Search Match behavior.",
5777
5928
  positional: "id",
5778
5929
  body: "object",
5779
- flags: ADGROUP_FIELDS
5930
+ flags: ADGROUP_UPDATE
5780
5931
  }),
5781
- op("adgroups", "delete", "destructive", "DELETE", "/campaigns/{campaign}/adgroups/{id}", "Delete an ad group", "delete-an-ad-group", { positional: "id" }),
5782
- list$1("keywords", "/campaigns/{campaign}/adgroups/{adgroup}/targetingkeywords", "List targeting keywords in an ad group", "get-all-targeting-keywords-in-an-ad-group"),
5783
- byId("keywords", "/campaigns/{campaign}/adgroups/{adgroup}/targetingkeywords/{id}", "Get a targeting keyword", "get-a-targeting-keyword-in-an-ad-group"),
5784
- find("keywords", "/campaigns/{campaign}/adgroups/targetingkeywords/find", "Find targeting keywords across a campaign", "find-targeting-keywords-in-a-campaign"),
5785
- op("keywords", "create", "destructive", "POST", "/campaigns/{campaign}/adgroups/{adgroup}/targetingkeywords/bulk", "Create targeting keywords (bulk)", "create-targeting-keywords", {
5786
- details: "Creates targeting keywords, which can be ACTIVE with bids in a live ad group and enable spending.",
5787
- body: "array",
5788
- flags: KEYWORD_FIELDS
5932
+ remove("adgroups", "/adgroups/{id}", "Delete an ad group", "delete-adgroups-_id_"),
5933
+ query("keywords", "/keywords/query", "List targeting keywords", "post-keywords-query", { filters: [CAMPAIGN_SCOPE, ADGROUP_SCOPE] }),
5934
+ byId("keywords", "/keywords/{id}", "Get a targeting keyword", "get-keywords-_id_"),
5935
+ op("keywords", "create", "destructive", "POST", "/keywords", "Create a targeting keyword", "post-keywords", {
5936
+ details: "Creates targeting keywords, which can be ENABLED with bids in a live ad group and enable spending.",
5937
+ body: "object",
5938
+ flags: KEYWORD_CREATE
5789
5939
  }),
5790
- op("keywords", "update", "destructive", "PUT", "/campaigns/{campaign}/adgroups/{adgroup}/targetingkeywords/bulk", "Update targeting keywords (bulk)", "update-targeting-keywords", {
5791
- details: "Bulk-overwrites targeting keyword status, match type or bids.",
5792
- positional: "id",
5793
- body: "array",
5794
- flags: KEYWORD_FIELDS
5940
+ op("keywords", "create", "destructive", "POST", "/keywords/bulk-create", "Create targeting keywords (bulk)", "post-keywords-bulk-create", {
5941
+ body: "bulk",
5942
+ flags: KEYWORD_CREATE
5943
+ }),
5944
+ op("keywords", "update", "destructive", "PUT", "/keywords/{id}", "Update a targeting keyword", "put-keywords-_id_", {
5945
+ details: "Overwrites targeting keyword status or bids.",
5946
+ positional: "ids",
5947
+ body: "object",
5948
+ flags: KEYWORD_UPDATE
5795
5949
  }),
5796
- op("keywords", "delete", "destructive", "DELETE", "/campaigns/{campaign}/adgroups/{adgroup}/targetingkeywords/{id}", "Delete a targeting keyword", "delete-a-targeting-keyword", { positional: "ids" }),
5797
- op("keywords", "delete", "destructive", "POST", "/campaigns/{campaign}/adgroups/{adgroup}/targetingkeywords/delete/bulk", "Delete targeting keywords (bulk)", "delete-targeting-keywords", {
5950
+ op("keywords", "update", "destructive", "POST", "/keywords/bulk-update", "Update targeting keywords (bulk)", "post-keywords-bulk-update", {
5798
5951
  positional: "ids",
5799
- body: "ids"
5952
+ body: "bulk",
5953
+ flags: KEYWORD_UPDATE
5800
5954
  }),
5801
- list$1("negative-keywords", "/campaigns/{campaign}/negativekeywords", "List campaign negative keywords", "get-all-campaign-negative-keywords"),
5802
- list$1("negative-keywords", "/campaigns/{campaign}/adgroups/{adgroup}/negativekeywords", "List ad group negative keywords", "get-all-ad-group-negative-keywords"),
5803
- byId("negative-keywords", "/campaigns/{campaign}/negativekeywords/{id}", "Get a campaign negative keyword", "get-a-campaign-negative-keyword"),
5804
- byId("negative-keywords", "/campaigns/{campaign}/adgroups/{adgroup}/negativekeywords/{id}", "Get an ad group negative keyword", "get-an-ad-group-negative-keyword"),
5805
- find("negative-keywords", "/campaigns/{campaign}/negativekeywords/find", "Find campaign negative keywords", "find-campaign-negative-keywords"),
5806
- find("negative-keywords", "/campaigns/{campaign}/adgroups/negativekeywords/find", "Find ad group negative keywords across a campaign", "find-ad-group-negative-keywords", { level: "adgroup" }),
5807
- op("negative-keywords", "create", "write", "POST", "/campaigns/{campaign}/negativekeywords/bulk", "Create campaign negative keywords (bulk)", "create-campaign-negative-keywords", {
5808
- body: "array",
5809
- flags: NEGATIVE_FIELDS
5955
+ remove("keywords", "/keywords/{id}", "Delete a targeting keyword", "delete-keywords-_id_", { positional: "ids" }),
5956
+ op("keywords", "delete", "destructive", "POST", "/keywords/bulk-delete", "Delete targeting keywords (bulk)", "post-keywords-bulk-delete", {
5957
+ positional: "ids",
5958
+ body: "bulk"
5810
5959
  }),
5811
- op("negative-keywords", "create", "write", "POST", "/campaigns/{campaign}/adgroups/{adgroup}/negativekeywords/bulk", "Create ad group negative keywords (bulk)", "create-ad-group-negative-keywords", {
5812
- body: "array",
5813
- flags: NEGATIVE_FIELDS
5960
+ query("negative-keywords", "/negative-keywords/query", "List negative keywords", "post-negative-keywords-query", { filters: [CAMPAIGN_SCOPE, ADGROUP_SCOPE] }),
5961
+ byId("negative-keywords", "/negative-keywords/{id}", "Get a negative keyword", "get-negative-keywords-_id_"),
5962
+ op("negative-keywords", "create", "write", "POST", "/negative-keywords", "Create a negative keyword", "post-negative-keywords", {
5963
+ details: "Creates a campaign negative keyword, or an ad group one with --adgroup.",
5964
+ body: "object",
5965
+ flags: NEGATIVE_CREATE
5814
5966
  }),
5815
- op("negative-keywords", "update", "destructive", "PUT", "/campaigns/{campaign}/negativekeywords/bulk", "Update campaign negative keywords (bulk)", "update-campaign-negative-keywords", {
5816
- details: "Bulk-overwrites negative keyword configuration and can change which traffic is excluded.",
5817
- positional: "id",
5818
- body: "array",
5819
- flags: NEGATIVE_FIELDS
5967
+ op("negative-keywords", "create", "write", "POST", "/negative-keywords/bulk-create", "Create negative keywords (bulk)", "post-negative-keywords-bulk-create", {
5968
+ body: "bulk",
5969
+ flags: NEGATIVE_CREATE
5820
5970
  }),
5821
- op("negative-keywords", "update", "destructive", "PUT", "/campaigns/{campaign}/adgroups/{adgroup}/negativekeywords/bulk", "Update ad group negative keywords (bulk)", "update-ad-group-negative-keywords", {
5822
- details: "Bulk-overwrites negative keyword configuration and can change which traffic is excluded.",
5823
- positional: "id",
5824
- body: "array",
5825
- flags: NEGATIVE_FIELDS
5971
+ op("negative-keywords", "update", "destructive", "PUT", "/negative-keywords/{id}", "Update a negative keyword", "put-negative-keywords-_id_", {
5972
+ details: "Overwrites negative keyword status and can change which traffic is excluded.",
5973
+ positional: "ids",
5974
+ body: "object",
5975
+ flags: [STATUS]
5826
5976
  }),
5827
- op("negative-keywords", "delete", "destructive", "POST", "/campaigns/{campaign}/negativekeywords/delete/bulk", "Delete campaign negative keywords", "delete-campaign-negative-keywords", {
5977
+ op("negative-keywords", "update", "destructive", "POST", "/negative-keywords/bulk-update", "Update negative keywords (bulk)", "post-negative-keywords-bulk-update", {
5828
5978
  positional: "ids",
5829
- body: "ids"
5979
+ body: "bulk",
5980
+ flags: [STATUS]
5830
5981
  }),
5831
- op("negative-keywords", "delete", "destructive", "POST", "/campaigns/{campaign}/adgroups/{adgroup}/negativekeywords/delete/bulk", "Delete ad group negative keywords", "delete-ad-group-negative-keywords", {
5982
+ remove("negative-keywords", "/negative-keywords/{id}", "Delete a negative keyword", "delete-negative-keywords-_id_", { positional: "ids" }),
5983
+ op("negative-keywords", "delete", "destructive", "POST", "/negative-keywords/bulk-delete", "Delete negative keywords (bulk)", "post-negative-keywords-bulk-delete", {
5832
5984
  positional: "ids",
5833
- body: "ids"
5985
+ body: "bulk"
5834
5986
  }),
5835
- list$1("ads", "/campaigns/{campaign}/adgroups/{adgroup}/ads", "List ads in an ad group", "get-all-ads"),
5836
- byId("ads", "/campaigns/{campaign}/adgroups/{adgroup}/ads/{id}", "Get an ad", "get-an-ad"),
5837
- find("ads", "/campaigns/{campaign}/ads/find", "Find ads in a campaign", "find-ads"),
5838
- find("ads", "/ads/find", "Find ads across the org", "find-ads-(org-level)"),
5839
- op("ads", "create", "destructive", "POST", "/campaigns/{campaign}/adgroups/{adgroup}/ads", "Create an ad", "create-an-ad", {
5987
+ query("ads", "/ads/query", "List ads", "post-ads-query", { filters: [CAMPAIGN_SCOPE, ADGROUP_SCOPE] }),
5988
+ byId("ads", "/ads/{id}", "Get an ad", "get-ads-_id_"),
5989
+ op("ads", "create", "destructive", "POST", "/ads", "Create an ad", "post-ads", {
5840
5990
  details: "Creates an ad assigned to a creative. An ENABLED ad in an eligible live group can begin serving and spending immediately.",
5841
5991
  body: "object",
5842
- flags: AD_FIELDS
5992
+ flags: [
5993
+ IN_ADGROUP,
5994
+ flag("creative-id", "creativeId", "number", "Creative id"),
5995
+ NAME,
5996
+ STATUS
5997
+ ]
5843
5998
  }),
5844
- op("ads", "update", "destructive", "PUT", "/campaigns/{campaign}/adgroups/{adgroup}/ads/{id}", "Update an ad", "update-an-ad", {
5999
+ op("ads", "update", "destructive", "PUT", "/ads/{id}", "Update an ad", "put-ads-_id_", {
5845
6000
  details: "Overwrites ad status/name; pausing or enabling changes delivery.",
5846
6001
  positional: "id",
5847
6002
  body: "object",
5848
6003
  flags: [NAME, STATUS]
5849
6004
  }),
5850
- op("ads", "delete", "destructive", "DELETE", "/campaigns/{campaign}/adgroups/{adgroup}/ads/{id}", "Delete an ad", "delete-an-ad", { positional: "id" }),
5851
- list$1("creatives", "/creatives", "List creatives", "get-all-creatives"),
5852
- byId("creatives", "/creatives/{id}", "Get a creative", "get-a-creative", { query: ["fields", "include-deleted-assets"] }),
5853
- find("creatives", "/creatives/find", "Find creatives with a selector", "find-creatives"),
5854
- op("creatives", "create", "write", "POST", "/creatives", "Create a creative", "create-a-creative", {
6005
+ remove("ads", "/ads/{id}", "Delete an ad", "delete-ads-_id_"),
6006
+ query("creatives", "/creatives/query", "List creatives", "post-creatives-query"),
6007
+ byId("creatives", "/creatives/{id}", "Get a creative", "get-creatives-_id_"),
6008
+ op("creatives", "create", "write", "POST", "/creatives", "Create a creative", "post-creatives", {
5855
6009
  body: "object",
5856
6010
  flags: [
5857
- ADAM_ID,
5858
6011
  NAME,
5859
- flag("type", "type", "string", "CUSTOM_PRODUCT_PAGE or DEFAULT_PRODUCT_PAGE"),
5860
- flag("product-page-id", "productPageId", "string", "Custom product page id")
5861
- ]
5862
- }),
5863
- list$1("product-pages", "/apps/{adamId}/product-pages", "List an app's custom product pages", "get-product-pages", {
5864
- paged: void 0,
5865
- query: [
5866
- "adam-id",
5867
- "name",
5868
- "states"
5869
- ]
6012
+ flag("type", "creativeType", "string", "CUSTOM_PRODUCT_PAGE, DEFAULT_PRODUCT_PAGE, ..."),
6013
+ flag("adam-id", "destination.parameters.adamId", "string", "App Store app id (adamId)"),
6014
+ flag("product-page-id", "destination.parameters.productPageId", "string", "Custom product page id")
6015
+ ],
6016
+ defaults: {
6017
+ creativeSpec: {},
6018
+ destination: { destinationType: "APP_STORE_PRODUCT_PAGE" }
6019
+ }
5870
6020
  }),
5871
- byId("product-pages", "/apps/{adamId}/product-pages/{id}", "Get a product page", "get-product-pages-by-identifier", { query: ["adam-id"] }),
5872
- op("product-pages", "locales", "read", "GET", "/apps/{adamId}/product-pages/{id}/locale-details", "Get a product page's locales", "get-product-page-locales", {
6021
+ op("creatives", "update", "write", "PUT", "/creatives/{id}", "Update a creative", "put-creatives-_id_", {
6022
+ details: "Renames a creative or replaces its spec; a new spec sends it back to review.",
5873
6023
  positional: "id",
5874
- query: [
5875
- "adam-id",
5876
- "device-classes",
5877
- "language-codes",
5878
- "expand"
5879
- ]
5880
- }),
5881
- op("product-pages", "countries", "read", "GET", "/countries-or-regions", "List supported countries or regions", "get-supported-countries-or-regions", { query: ["countries"] }),
5882
- op("product-pages", "device-sizes", "read", "GET", "/creativeappmappings/devices", "List app preview device sizes", "get-app-preview-device-sizes"),
5883
- find("ad-rejections", "/product-page-reasons/find", "Find ad creative rejection reasons", "find-ad-creative-rejection-reasons"),
5884
- byId("ad-rejections", "/product-page-reasons/{id}", "Get an ad creative rejection reason", "gets-a-product-page-reason"),
5885
- find("ad-rejections", "/apps/{adamId}/assets/find", "Find an app's assets", "find-app-assets", {
5886
- action: "assets",
5887
- details: "Retrieves asset metadata with a selector using POST; does not modify assets or start a job.",
5888
- query: [...SELECTOR_QUERY, "adam-id"]
5889
- }),
5890
- op("reports", "campaigns", "read", "POST", "/reports/campaigns", "Campaign-level report", "get-campaign-level-reports", {
5891
- body: "report",
5892
- flags: REPORT_FLAGS
5893
- }),
5894
- op("reports", "adgroups", "read", "POST", "/reports/campaigns/{campaign}/adgroups", "Ad group-level report", "get-ad-group-level-reports", {
5895
- body: "report",
5896
- flags: REPORT_FLAGS
5897
- }),
5898
- op("reports", "keywords", "read", "POST", "/reports/campaigns/{campaign}/keywords", "Keyword-level report", "get-keyword-level-reports", {
5899
- body: "report",
5900
- flags: REPORT_FLAGS
5901
- }),
5902
- op("reports", "keywords", "read", "POST", "/reports/campaigns/{campaign}/adgroups/{adgroup}/keywords", "Keyword-level report within an ad group", "get-keyword-level-within-ad-group-reports", {
5903
- body: "report",
5904
- flags: REPORT_FLAGS
6024
+ body: "object",
6025
+ flags: [NAME]
5905
6026
  }),
5906
- op("reports", "searchterms", "read", "POST", "/reports/campaigns/{campaign}/searchterms", "Search term-level report", "get-search-term-level-reports", {
5907
- body: "report",
5908
- flags: REPORT_FLAGS
6027
+ remove("creatives", "/creatives/{id}", "Delete a creative", "delete-creatives-_id_"),
6028
+ query("assets", "/assets/query", "List assets", "query-assets", { filters: [{
6029
+ ...PROMOTED_APP,
6030
+ list: false
6031
+ }] }),
6032
+ byId("assets", "/assets/{id}", "Get an asset", "get-asset-by-id"),
6033
+ remove("assets", "/assets/{id}", "Delete an asset", "delete-asset-by-id"),
6034
+ query("product-pages", "/product-pages/query", "List an app's custom product pages", "query-product-pages", { filters: [{
6035
+ flag: "adam-id",
6036
+ field: "adamId",
6037
+ required: true
6038
+ }] }),
6039
+ byId("product-pages", "/product-pages/{id}", "Get a product page", "get-product-page-by-id"),
6040
+ query("product-pages", "/product-pages/locale-details/query", "Get a product page's locales", "query-product-page-locale-details", {
6041
+ action: "locales",
6042
+ positional: "id",
6043
+ filters: [{
6044
+ flag: "id",
6045
+ field: "productPageId",
6046
+ required: true,
6047
+ text: true
6048
+ }]
5909
6049
  }),
5910
- op("reports", "searchterms", "read", "POST", "/reports/campaigns/{campaign}/adgroups/{adgroup}/searchterms", "Search term-level report within an ad group", "get-search-term-level-within-ad-group-reports", {
6050
+ query("ad-rejections", "/rejection-reasons/apps/query", "List ad creative rejection reasons", "find-rejection-reasons", { filters: [{
6051
+ flag: "adam-id",
6052
+ field: "adamId"
6053
+ }] }),
6054
+ byId("ad-rejections", "/rejection-reasons/apps/{id}", "Get an ad creative rejection reason", "gets-rejection-reasons-by-id"),
6055
+ appReport("campaigns", "campaigns", "Campaign-level report", "get-app-campaign-reports", false),
6056
+ appReport("adgroups", "adgroups", "Ad group-level report", "get-app-ad-group-reports", true),
6057
+ appReport("keywords", "keywords", "Keyword-level report", "get-app-keyword-reports", true),
6058
+ appReport("searchterms", "searchterms", "Search term-level report", "get-app-search-term-reports", true),
6059
+ appReport("ads", "ads", "Ad-level report", "get-app-ad-reports", true),
6060
+ brandReport("campaigns", "campaigns", "Apple Maps campaign-level report", "get-brand-campaign-reports", false),
6061
+ brandReport("adgroups", "adgroups", "Apple Maps ad group-level report", "get-brand-ad-group-reports", true),
6062
+ brandReport("keywords", "keywords", "Apple Maps keyword-level report", "get-brand-keyword-reports", true),
6063
+ brandReport("searchterms", "searchterms", "Apple Maps search term-level report", "get-brand-search-term-reports", true),
6064
+ brandReport("ads", "ads", "Apple Maps ad-level report", "get-brand-ad-reports", true),
6065
+ op("insights", "impression-share", "read", "POST", "/insights/apps/impression-share/query", "App impression share", "query-app-impression-share-data", {
5911
6066
  body: "report",
5912
- flags: REPORT_FLAGS
6067
+ paged: true,
6068
+ filters: [{
6069
+ ...PROMOTED_APP,
6070
+ list: false
6071
+ }]
5913
6072
  }),
5914
- op("reports", "ads", "read", "POST", "/reports/campaigns/{campaign}/ads", "Ad-level report", "get-ad-level-reports", {
6073
+ op("insights", "search-term-popularity", "read", "POST", "/insights/apps/search-term-popularity/query", "Search term popularity", "query-app-search-term-popularity-data", {
5915
6074
  body: "report",
5916
- flags: REPORT_FLAGS
5917
- }),
5918
- list$1("impression-share", "/custom-reports", "List impression share reports", "get-all-impression-share-reports"),
5919
- byId("impression-share", "/custom-reports/{id}", "Get an impression share report", "get-a-single-impression-share-report"),
5920
- op("impression-share", "create", "write", "POST", "/custom-reports", "Request an impression share report", "impression-share-report", {
5921
- body: "object",
5922
- flags: [
5923
- NAME,
5924
- START,
5925
- END,
5926
- flag("granularity", "granularity", "string", "DAILY, WEEKLY, or MONTHLY"),
5927
- flag("dimensions", "dimensions", "list", "Comma-separated dimensions (appName, adamId, countryOrRegion, searchTerm)"),
5928
- flag("metrics", "metrics", "list", "Comma-separated metrics")
5929
- ]
6075
+ paged: true
5930
6076
  }),
5931
- op("apps", "search", "read", "GET", "/search/apps", "Search the App Store for apps", "search-for-ios-apps", {
6077
+ op("apps", "search", "read", "GET", "/search/apps", "Search the App Store for apps", "searches-for-a-list-of-apps", {
5932
6078
  positional: "query",
5933
- paged: "query",
6079
+ paged: true,
5934
6080
  query: [
5935
6081
  "owned",
6082
+ "store-fronts",
5936
6083
  "limit",
5937
6084
  "offset",
5938
6085
  "all"
5939
6086
  ]
5940
6087
  }),
5941
- find("apps", "/apps/{adamId}/eligibilities/find", "Find an app's eligibility records", "find-app-eligibility-records", {
6088
+ query("apps", "/eligibilities/apps/query", "Check an app's eligibility", "find-apps-eligibilities", {
5942
6089
  action: "eligibility",
5943
- details: "Retrieves app eligibility records using POST; does not change eligibility or start a job.",
6090
+ positional: "adam-id",
6091
+ filters: [{
6092
+ flag: "adam-id",
6093
+ field: "adamId",
6094
+ required: true
6095
+ }]
6096
+ }),
6097
+ op("apps", "get", "read", "GET", "/apps/{adamId}", "Get app details", "get-app-details-by-adam-id", { positional: "adam-id" }),
6098
+ query("apps", "/apps/{adamId}/locale-details/query", "Get an app's default product page locales", "query-default-product-page-locale-details-by-adam-id", {
6099
+ action: "localized",
5944
6100
  positional: "adam-id"
5945
6101
  }),
5946
- op("apps", "get", "read", "GET", "/apps/{adamId}", "Get app details", "get-app-details", { positional: "adam-id" }),
5947
- op("apps", "localized", "read", "GET", "/apps/{adamId}/locale-details", "Get localized app details", "get-localized-app-details", { positional: "adam-id" }),
5948
- op("geo", "search", "read", "GET", "/search/geo", "Search geolocations", "search-for-geolocations", {
6102
+ query("apps", "/metadata/apps/supported-languages/query", "List supported app languages", "query-supported-app-languages", { action: "languages" }),
6103
+ op("geo", "search", "read", "GET", "/search/geo", "Search geolocations", "searches-for-a-list-of-geo-locations", {
5949
6104
  positional: "query",
5950
- paged: "query",
6105
+ paged: true,
6106
+ pageSize: "pageSize",
6107
+ defaults: { supplySource: "APPSTORE" },
5951
6108
  query: [
6109
+ "supply-source",
5952
6110
  "country",
5953
6111
  "entity",
6112
+ "eligible",
5954
6113
  "limit",
5955
6114
  "offset",
5956
6115
  "all"
5957
6116
  ]
5958
6117
  }),
5959
- op("geo", "get", "read", "POST", "/search/geo", "Look up geolocations by id", "get-a-list-of-geo-locations", {
6118
+ op("geo", "get", "read", "POST", "/search/geo", "Look up geolocations by id", "gets-a-list-of-geo-locations", {
5960
6119
  details: "Retrieves geolocations by ID using POST; does not create locations or start a job.",
5961
6120
  positional: "ids",
5962
- body: "geo",
5963
- query: ["entity"]
6121
+ body: "geo"
5964
6122
  }),
5965
- list$1("budget-orders", "/budgetorders", "List budget orders", "get-all-budget-orders"),
5966
- byId("budget-orders", "/budgetorders/{id}", "Get a budget order", "get-a-budget-order"),
5967
- op("budget-orders", "create", "destructive", "POST", "/budgetorders", "Create a budget order", "create-a-budget-order", {
5968
- details: "Creates a financial budget order for the organization. Apple can return it ACTIVE; the request is not restricted to a draft allocation.",
5969
- body: "object"
6123
+ query("budget-orders", "/shared-budgets/query", "List budget orders", "post-shared-budgets-query"),
6124
+ byId("budget-orders", "/shared-budgets/{id}", "Get a budget order", "get-shared-budgets-_id_"),
6125
+ op("budget-orders", "create", "destructive", "POST", "/shared-budgets", "Create a budget order", "post-shared-budgets", {
6126
+ details: "Creates a financial budget order that ad accounts can draw from; it needs invoice details in --body or -d.",
6127
+ body: "object",
6128
+ flags: BUDGET_UPDATE,
6129
+ account: "adAccountIds"
5970
6130
  }),
5971
- op("budget-orders", "update", "destructive", "PUT", "/budgetorders/{id}", "Update a budget order", "update-a-budget-order", {
5972
- details: "Overwrites a financial budget order using an unrestricted request body.",
6131
+ op("budget-orders", "update", "destructive", "PUT", "/shared-budgets/{id}", "Update a budget order", "put-shared-budgets-_id_", {
6132
+ details: "Overwrites a financial budget order's amount, dates, accounts or invoice details.",
5973
6133
  positional: "id",
5974
- body: "object"
6134
+ body: "object",
6135
+ flags: BUDGET_UPDATE
5975
6136
  }),
5976
- op("acls", "list", "read", "GET", "/acls", "List the orgs this API user can access", "get-user-acl"),
5977
- op("me", "get", "read", "GET", "/me", "Show the calling API user", "get-me-details")
5978
- ];
5979
- const PLACEHOLDERS = [
5980
- "campaign",
5981
- "adgroup",
5982
- "adamId",
5983
- "id"
6137
+ remove("budget-orders", "/shared-budgets/{id}", "Delete a budget order", "delete-shared-budgets-_id_"),
6138
+ query("recommendations", "/recommendations/target-cpas/query", "Target CPA recommendations", "query-target-cpa-recommendations", {
6139
+ action: "target-cpas",
6140
+ filters: [PROMOTED_APP]
6141
+ }),
6142
+ op("recommendations", "apply-target-cpas", "destructive", "POST", "/recommendations/target-cpas/apply", "Apply target CPA recommendations", "apply-target-cpa-recommendations", {
6143
+ details: "Applies recommended target CPAs, which changes how ad groups bid and spend.",
6144
+ body: "array"
6145
+ }),
6146
+ op("recommendations", "dismiss-target-cpas", "write", "POST", "/recommendations/target-cpas/dismiss", "Dismiss target CPA recommendations", "dismiss-target-cpa-recommendations", { body: "array" }),
6147
+ query("recommendations", "/recommendations/daily-budgets/query", "Daily budget recommendations", "query-daily-budget-recommendations", {
6148
+ action: "daily-budgets",
6149
+ filters: [PROMOTED_APP]
6150
+ }),
6151
+ op("recommendations", "apply-daily-budgets", "destructive", "POST", "/recommendations/daily-budgets/apply", "Apply daily budget recommendations", "apply-daily-budget-recommendations", {
6152
+ details: "Applies recommended daily budgets, which changes how much campaigns can spend.",
6153
+ body: "array"
6154
+ }),
6155
+ op("recommendations", "dismiss-daily-budgets", "write", "POST", "/recommendations/daily-budgets/dismiss", "Dismiss daily budget recommendations", "dismiss-daily-budget-recommendations", { body: "array" }),
6156
+ query("suggestions", "/suggestions/keywords/query", "Keyword suggestions", "query-keyword-suggestions", {
6157
+ action: "keywords",
6158
+ filters: [PROMOTED_APP]
6159
+ }),
6160
+ query("suggestions", "/suggestions/phrases/query", "Phrase suggestions", "query-phrase-suggestions", {
6161
+ action: "phrases",
6162
+ filters: [PROMOTED_APP]
6163
+ }),
6164
+ query("suggestions", "/suggestions/categories/query", "Category suggestions", "query-category-suggestions", {
6165
+ action: "categories",
6166
+ filters: [PROMOTED_APP]
6167
+ }),
6168
+ query("suggestions", "/suggestions/target-cpas/query", "Target CPA suggestion", "query-target-cpa-suggestion", {
6169
+ action: "target-cpa",
6170
+ filters: [PROMOTED_APP]
6171
+ }),
6172
+ query("change-history", "/change-history/query", "List changes", "query-audit-summary-_-grouped-by-transaction"),
6173
+ byId("change-history", "/change-history/{id}", "Get a change's details", "get-change-details-by-detailid", {
6174
+ paged: true,
6175
+ query: [
6176
+ "limit",
6177
+ "offset",
6178
+ "all"
6179
+ ]
6180
+ }),
6181
+ query("brands", "/business-brands/query", "List Apple Maps brands", "query-brands"),
6182
+ byId("brands", "/business-brands/{id}", "Get an Apple Maps brand", "get-brand-by-id"),
6183
+ query("brands", "/business-categories/query", "List business categories", "query-categories", { action: "categories" }),
6184
+ op("brands", "category", "read", "GET", "/business-categories/{id}", "Get a business category", "get-category-by-id", { positional: "id" }),
6185
+ query("brands", "/rejection-reasons/business-brands/query", "List brand rejection reasons", "query-policy-assignments-(rejection-reasons)-for-external-consumers", { action: "rejections" }),
6186
+ byId("ad-accounts", "/ad-accounts/{id}", "Get an ad account", "get-ad-accounts-_id_"),
6187
+ op("ad-accounts", "create", "write", "POST", "/ad-accounts", "Create ad accounts", "post-ad-accounts", {
6188
+ details: "Creates ad accounts with their product features and advertiser delegations.",
6189
+ body: "object",
6190
+ flags: [NAME]
6191
+ }),
6192
+ op("ad-accounts", "update", "destructive", "PUT", "/ad-accounts/{id}", "Update an ad account", "put-ad-accounts-_id_", {
6193
+ details: "Overwrites an ad account's name, product features or delegations, which can change what it may advertise.",
6194
+ positional: "id",
6195
+ body: "object",
6196
+ flags: [NAME]
6197
+ }),
6198
+ op("ad-accounts", "resources", "read", "GET", "/advertiser-resources", "List advertiser resources", "get-advertiser-resources", { query: ["resource-type"] }),
6199
+ op("orgs", "get", "read", "GET", "/orgs/{id}", "Get an org", "get-orgs-_id_", { positional: "id" }),
6200
+ op("acls", "list", "read", "GET", "/acls", "List the ad accounts this API user can access", "get-user-acls"),
6201
+ op("me", "get", "read", "GET", "/me", "Show the calling API user", "get-current-user-details")
5984
6202
  ];
6203
+ const PLACEHOLDERS = ["adamId", "id"];
5985
6204
  function placeholdersOf(path) {
5986
6205
  return PLACEHOLDERS.filter((p) => path.includes(`{${p}}`));
5987
6206
  }
@@ -5994,24 +6213,25 @@ function asaActions(group$1) {
5994
6213
  function asaVariants(group$1, action) {
5995
6214
  return ASA_OPERATIONS.filter((o) => o.group === group$1 && o.action === action);
5996
6215
  }
6216
+ const filterFlag = (filter) => {
6217
+ return filter.flag === "id" ? "an id" : `--${filter.flag} <id>`;
6218
+ };
6219
+ function filterValue(filter, scope) {
6220
+ if (filter.flag === "campaign") return scope.campaign;
6221
+ if (filter.flag === "adgroup") return scope.adgroup;
6222
+ if (filter.flag === "adam-id") return scope.adamId;
6223
+ return scope.ids[0];
6224
+ }
5997
6225
  function selectVariant(variants, scope) {
5998
- const have = (p) => {
5999
- return p === "id" ? scope.ids.length === 1 : Boolean(scope[p]);
6000
- };
6001
- const leveled = variants.some((v) => v.level === "adgroup");
6002
- const pick = variants.filter((v) => !leveled || v.level === "adgroup" === Boolean(scope.adgroupLevel)).filter((v) => placeholdersOf(v.path).every(have)).sort((a, b) => placeholdersOf(b.path).length - placeholdersOf(a.path).length)[0];
6003
- if (pick) return pick;
6004
- const [simplest] = [...variants].sort((a, b) => placeholdersOf(a.path).length - placeholdersOf(b.path).length);
6005
- if (!simplest) throw new Error("No Apple Search Ads operation to choose from.");
6006
- const missing$1 = placeholdersOf(simplest.path).filter((p) => !have(p)).map((p) => {
6007
- if (p === "id") return "exactly one id";
6008
- if (p === "adamId") return "--adam-id <id>";
6009
- return `--${p} <id>`;
6010
- });
6011
- throw new Error(`asa ${simplest.group} ${simplest.action} needs ${missing$1.join(" and ")}.`);
6226
+ const bulk = scope.bulk === true || scope.ids.length > 1;
6227
+ const pick = variants.find((v) => v.body === "bulk" === bulk) ?? variants[0];
6228
+ if (!pick) throw new Error("No Apple Search Ads operation to choose from.");
6229
+ const missing$1 = [...placeholdersOf(pick.path).filter((p) => p === "id" ? scope.ids.length !== 1 : !scope.adamId).map((p) => p === "id" ? "exactly one id" : "--adam-id <id>"), ...(pick.filters ?? []).filter((f) => f.required && !filterValue(f, scope)).map(filterFlag)];
6230
+ if (missing$1.length) throw new Error(`asa ${pick.group} ${pick.action} needs ${missing$1.join(" and ")}.`);
6231
+ return pick;
6012
6232
  }
6013
6233
  function fillPath(path, scope) {
6014
- return path.replace("{campaign}", encodeURIComponent(scope.campaign ?? "")).replace("{adgroup}", encodeURIComponent(scope.adgroup ?? "")).replace("{adamId}", encodeURIComponent(scope.adamId ?? "")).replace("{id}", encodeURIComponent(scope.ids[0] ?? ""));
6234
+ return path.replace("{adamId}", encodeURIComponent(scope.adamId ?? "")).replace("{id}", encodeURIComponent(scope.ids[0] ?? ""));
6015
6235
  }
6016
6236
  function appleDocUrl(op$1) {
6017
6237
  return `${APPLE_DOCS_BASE}/${op$1.doc}`;
@@ -6063,10 +6283,10 @@ function formatAsaUsage(op$1) {
6063
6283
  if (op$1.positional === "ids") parts.push("<id[,id…]>");
6064
6284
  if (op$1.positional === "query") parts.push("<query>");
6065
6285
  if (op$1.positional === "adam-id") parts.push("<adam-id>");
6066
- for (const placeholder$1 of placeholdersOf(op$1.path)) {
6067
- if (placeholder$1 === "campaign") parts.push("--campaign <id>");
6068
- if (placeholder$1 === "adgroup") parts.push("--adgroup <id>");
6069
- if (placeholder$1 === "adamId" && op$1.positional !== "adam-id") parts.push("--adam-id <id>");
6286
+ if (placeholdersOf(op$1.path).includes("adamId") && op$1.positional !== "adam-id") parts.push("--adam-id <id>");
6287
+ for (const filter of op$1.filters ?? []) {
6288
+ if (filter.flag === "id" || filter.flag === "adam-id" && op$1.positional === "adam-id") continue;
6289
+ parts.push(filter.required ? `--${filter.flag} <id>` : `[--${filter.flag} <id>]`);
6070
6290
  }
6071
6291
  return parts.join(" ");
6072
6292
  }
@@ -6082,20 +6302,28 @@ function formatAsaFlags(op$1, variants) {
6082
6302
  return [`${cmd(`--${flag$1.flag}`)}${pc.dim(value$1)}`, flag$1.describe];
6083
6303
  });
6084
6304
  const add = (flag$1, text) => rows.push([cmd(flag$1), text]);
6085
- if (op$1.body === "object" || op$1.body === "array") {
6305
+ const bulk = variants.find((variant) => variant.body === "bulk");
6306
+ if (op$1.body === "object" || bulk?.flags) {
6086
6307
  add("-d key=value", "Another body field; key:=json for numbers and objects");
6087
- add("--body <json|@file|@->", "The whole request body");
6088
- }
6089
- if (op$1.body === "selector" || op$1.body === "report") add("--selector <json|@file|@->", "An Apple selector");
6090
- if (op$1.body === "selector") {
6091
- add("--field --op --values", "One condition, e.g. --field status --op EQUALS --values ENABLED");
6308
+ add("--body <json|@file|@->", bulk ? "The whole request body; an array goes to the bulk endpoint" : "The whole request body");
6309
+ } else if (bulk) add("--body <json|@file|@->", "Bulk items instead of ids, as Apple documents them");
6310
+ if (op$1.body === "array") add("--body <json|@file|@->", "The request body: an array, as Apple documents it");
6311
+ if (op$1.body === "query" || op$1.body === "report") {
6312
+ add("--query <json|@file|@->", "An Apple query request: filters, sorting, pagination");
6313
+ add("--field --op --values", "One filter, e.g. --field status --op EQUALS --values ENABLED");
6092
6314
  add("--order-by <field[:asc|desc]>", "Sort");
6093
6315
  }
6094
- if (op$1.body === "report") add("--time-zone <UTC|ORTZ>", "Report time zone (default UTC)");
6095
- if (op$1.body === "selector" || op$1.query?.includes("fields")) add("--fields <a,b>", "Only these fields");
6316
+ if (op$1.body === "report") {
6317
+ add("--start --end <YYYY-MM-DD>", "Report range");
6318
+ add("--granularity <HOURLY|DAILY|WEEKLY|MONTHLY>", "Rows per period (default DAILY)");
6319
+ add("--group-by <a,b>", "Group rows by dimension");
6320
+ add("--fields <a,b>", "Only these fields");
6321
+ if (op$1.zoned) add("--time-zone <UTC|ORTZ>", "Report time zone (default UTC)");
6322
+ }
6323
+ if (op$1.body === "geo") add("--entity <Country|AdminArea|Locality>", "What kind of place the ids are");
6096
6324
  if (op$1.paged) add("--limit <n> --offset <n> --all", "Paging; --all walks every page");
6097
- if (variants.some((variant) => variant.level === "adgroup")) add("--adgroup-level", "Ad group negatives instead of the campaign's");
6098
6325
  rows.push([cmd("--app <app>"), "The Superwall app whose Apple Search Ads account to use"]);
6326
+ rows.push([cmd("--ad-account-id <id>"), "The Apple Ads ad account (default: the only one the key reaches)"]);
6099
6327
  return rows;
6100
6328
  }
6101
6329
  function renderAsaHelp(words) {
@@ -6104,7 +6332,7 @@ function renderAsaHelp(words) {
6104
6332
  if (!group$1 || !groups.includes(group$1)) return renderAsaPage({
6105
6333
  path: "asa",
6106
6334
  usage: "<resource> <operation>",
6107
- summary: "The Apple Search Ads API through Superwall's proxy: no key or token handling",
6335
+ summary: "The Apple Ads Platform API (v1) through Superwall's proxy: no key or token handling",
6108
6336
  children: [
6109
6337
  ...groups.map((name) => ({
6110
6338
  path: `asa ${name}`,
@@ -6187,11 +6415,12 @@ function asaBase(api) {
6187
6415
  }
6188
6416
  function asaUpstreamPath(path) {
6189
6417
  if (!path.startsWith("/")) throw new Error(`Path must start with "/", e.g. /campaigns`);
6190
- return path.startsWith("/api/") ? path : `/api/v5${path}`;
6418
+ if (path.startsWith("/api/") || path === "/v1" || path.startsWith("/v1/") || path.startsWith("/v1?")) return path;
6419
+ return `/v1${path}`;
6191
6420
  }
6192
6421
  async function asaProxy(api, appId, method, asaPath, body, options = {}) {
6193
6422
  const path = `${asaBase(api)}/proxy/${appId}${asaUpstreamPath(asaPath)}`;
6194
- const request = options.orgId ? { headers: { "x-ap-context": `orgId=${options.orgId}` } } : {};
6423
+ const request = options.adAccountId ? { headers: { "x-ap-context": `adAccountId=${options.adAccountId}` } } : {};
6195
6424
  switch (method.toUpperCase()) {
6196
6425
  case "GET": return api.get(path, request);
6197
6426
  case "POST": return api.post(path, body ?? {}, request);
@@ -6255,6 +6484,25 @@ function numeric(value$1, label) {
6255
6484
  function idValue(id$1) {
6256
6485
  return /^\d+$/.test(id$1) ? Number(id$1) : id$1;
6257
6486
  }
6487
+ function assignField(target, path, value$1) {
6488
+ const [key = "", ...rest] = path.split(".");
6489
+ if (rest.length === 0) {
6490
+ target[key] = value$1;
6491
+ return;
6492
+ }
6493
+ const current = target[key];
6494
+ const child = isRecord(current) ? { ...current } : {};
6495
+ target[key] = child;
6496
+ assignField(child, rest.join("."), value$1);
6497
+ }
6498
+ function deepMerge(base, extra) {
6499
+ const out = { ...base };
6500
+ for (const [key, value$1] of Object.entries(extra)) {
6501
+ const current = out[key];
6502
+ out[key] = isRecord(current) && isRecord(value$1) ? deepMerge(current, value$1) : value$1;
6503
+ }
6504
+ return out;
6505
+ }
6258
6506
  async function convertFlag(f, value$1, currency) {
6259
6507
  switch (f.type) {
6260
6508
  case "string": return String(value$1);
@@ -6267,49 +6515,69 @@ async function convertFlag(f, value$1, currency) {
6267
6515
  };
6268
6516
  }
6269
6517
  }
6270
- function buildSelector(input) {
6271
- const base = given(input.selector) ? readJsonInput(input.selector, "--selector") : {};
6272
- if (!isRecord(base)) throw new Error("--selector must be a JSON object.");
6273
- const selector = { ...base };
6274
- if (input.field || input.op || input.values) {
6275
- if (!input.field || !input.op || !input.values) throw new Error("--field, --op and --values go together (e.g. --field status --op EQUALS --values ENABLED).");
6276
- const conditions = Array.isArray(selector.conditions) ? [...selector.conditions] : [];
6277
- conditions.push({
6278
- field: input.field,
6279
- operator: input.op.toUpperCase(),
6280
- values: splitList(input.values)
6281
- });
6282
- selector.conditions = conditions;
6283
- }
6518
+ function shorthandFilter(input) {
6519
+ if (!input.field && !input.op && input.values === void 0) return void 0;
6520
+ const operator = input.op?.toUpperCase();
6521
+ const valueless = operator === "IS_NULL" || operator === "IS_NOT_NULL";
6522
+ if (!input.field || !operator || !valueless && !input.values) throw new Error("--field, --op and --values go together (e.g. --field status --op EQUALS --values ENABLED).");
6523
+ if (valueless) return {
6524
+ field: input.field,
6525
+ operator
6526
+ };
6527
+ const values = splitList(input.values);
6528
+ const value$1 = [
6529
+ "IN",
6530
+ "NOT_IN",
6531
+ "CONTAINS_ANY",
6532
+ "NOT_CONTAINS_ANY",
6533
+ "CONTAINS_ALL",
6534
+ "NOT_CONTAINS_ALL",
6535
+ "BETWEEN"
6536
+ ].includes(operator) || values.length > 1 ? values : values[0];
6537
+ return {
6538
+ field: input.field,
6539
+ operator,
6540
+ value: value$1
6541
+ };
6542
+ }
6543
+ function buildQuery(input) {
6544
+ const base = given(input.query) ? readJsonInput(input.query, "--query") : {};
6545
+ if (!isRecord(base)) throw new Error("--query must be a JSON object.");
6546
+ const request = { ...base };
6547
+ const own = Array.isArray(base.filters) ? base.filters : [];
6548
+ const shorthand = shorthandFilter(input);
6549
+ const filters = [
6550
+ ...own,
6551
+ ...input.filters ?? [],
6552
+ ...shorthand ? [shorthand] : []
6553
+ ];
6554
+ if (filters.length) request.filters = filters;
6284
6555
  if (input.orderBy) {
6285
6556
  const [field$1, dir] = input.orderBy.split(":");
6286
- selector.orderBy = [{
6557
+ request.sorting = [{
6287
6558
  field: field$1,
6288
- sortOrder: (dir ?? "asc").toLowerCase().startsWith("desc") ? "DESCENDING" : "ASCENDING"
6559
+ order: (dir ?? "asc").toLowerCase().startsWith("desc") ? "DESC" : "ASC"
6289
6560
  }];
6290
6561
  }
6291
- if (input.fields) selector.fields = splitList(input.fields);
6292
- if (input.limit !== void 0 || input.offset !== void 0) selector.pagination = {
6562
+ if (input.fields) request.fields = splitList(input.fields);
6563
+ if (input.limit !== void 0 || input.offset !== void 0) request.pagination = {
6564
+ ...isRecord(base.pagination) ? base.pagination : {},
6293
6565
  offset: input.offset ?? 0,
6294
- limit: input.limit ?? 20
6566
+ pageSize: input.limit ?? 20
6295
6567
  };
6296
- return selector;
6568
+ return request;
6297
6569
  }
6298
6570
  function buildReport(input) {
6299
- if (!input.start || !input.end) throw new Error("Reports need --start and --end (YYYY-MM-DD).");
6300
- const report = {
6301
- startTime: input.start,
6302
- endTime: input.end,
6303
- timeZone: input.timeZone ?? "UTC",
6304
- returnRowTotals: true,
6305
- returnGrandTotals: true,
6306
- selector: given(input.selector) ? readJsonInput(input.selector, "--selector") : { orderBy: [{
6307
- field: "localSpend",
6308
- sortOrder: "DESCENDING"
6309
- }] }
6310
- };
6311
- if (input.granularity) report.granularity = input.granularity.toUpperCase();
6312
- else if (!input.searchTerms) report.granularity = "DAILY";
6571
+ const report = buildQuery(input);
6572
+ const range = isRecord(report.timeRange) ? { ...report.timeRange } : {};
6573
+ if (input.start) range.start = input.start;
6574
+ if (input.end) range.end = input.end;
6575
+ if (!range.start || !range.end) throw new Error("Reports need --start and --end (YYYY-MM-DD).");
6576
+ if (input.granularity) range.granularity = input.granularity.toUpperCase();
6577
+ else range.granularity ??= "DAILY";
6578
+ if (input.timeZone) range.timeZone = input.timeZone;
6579
+ else if (input.zoned) range.timeZone ??= "UTC";
6580
+ report.timeRange = range;
6313
6581
  if (input.groupBy) report.groupBy = splitList(input.groupBy);
6314
6582
  return report;
6315
6583
  }
@@ -6324,62 +6592,76 @@ function numberFlag(flags, name) {
6324
6592
  const v = flagValue(flags, name);
6325
6593
  return v === void 0 || v === null || v === "" ? void 0 : numeric(v, name);
6326
6594
  }
6327
- async function objectBody(op$1, flags, params, currency) {
6328
- const bodyInput = flagValue(flags, "body");
6329
- const base = given(bodyInput) ? readJsonInput(bodyInput, "--body") : {};
6330
- if (!isRecord(base)) throw new Error("--body must be a JSON object for this command.");
6331
- const body = { ...base };
6595
+ async function fieldsOf(op$1, flags, currency) {
6596
+ const data$1 = {};
6332
6597
  for (const f of op$1.flags ?? []) {
6333
6598
  const v = flagValue(flags, f.flag);
6334
6599
  if (v === void 0 || v === null || v === "") continue;
6335
- body[f.key] = await convertFlag(f, v, currency);
6600
+ assignField(data$1, f.key, await convertFlag(f, v, currency));
6336
6601
  }
6337
- Object.assign(body, params);
6338
- return body;
6602
+ return data$1;
6339
6603
  }
6340
- async function arrayBody(op$1, flags, params, ids, currency) {
6341
- const bodyInput = flagValue(flags, "body");
6342
- if (given(bodyInput)) {
6343
- const parsed = readJsonInput(bodyInput, "--body");
6344
- if (Array.isArray(parsed)) return parsed;
6345
- if (isRecord(parsed)) return [parsed];
6346
- throw new Error("--body must be a JSON array (or one object) for this command.");
6604
+ async function objectBody(op$1, flags, params, body, options) {
6605
+ if (body !== void 0 && !isRecord(body)) throw new Error("--body must be a JSON object for this command.");
6606
+ let out = deepMerge(op$1.defaults ?? {}, body ?? {});
6607
+ out = deepMerge(out, await fieldsOf(op$1, flags, options.account.currency));
6608
+ out = deepMerge(out, params);
6609
+ if (op$1.account && out[op$1.account] === void 0) {
6610
+ const id$1 = idValue(await options.account.id());
6611
+ out[op$1.account] = op$1.account === "adAccountIds" ? [id$1] : id$1;
6347
6612
  }
6348
- const item = await objectBody({
6349
- ...op$1,
6350
- envelope: void 0
6351
- }, flags, params, currency);
6352
- if (ids[0] !== void 0) item.id = idValue(ids[0]);
6353
- if (Object.keys(item).length === 0) {
6613
+ return out;
6614
+ }
6615
+ const bulkItem = (data$1, index) => {
6616
+ if (isRecord(data$1) && isRecord(data$1.data)) return {
6617
+ correlationId: index,
6618
+ ...data$1
6619
+ };
6620
+ return {
6621
+ correlationId: index,
6622
+ data: data$1
6623
+ };
6624
+ };
6625
+ async function bulkBody(op$1, flags, params, body, ids, currency) {
6626
+ if (isRecord(body) && Array.isArray(body.items)) return body;
6627
+ if (Array.isArray(body)) return { items: body.map(bulkItem) };
6628
+ if (body !== void 0 && !isRecord(body)) throw new Error("--body must be a JSON array (or one object) for this command.");
6629
+ const data$1 = deepMerge(deepMerge(body ?? {}, await fieldsOf(op$1, flags, currency)), params);
6630
+ if (Object.keys(data$1).length === 0) {
6354
6631
  const hint = (op$1.flags ?? []).map((f) => `--${f.flag}`).join(", ");
6355
6632
  throw new Error(`Nothing to send. Pass fields (${hint}) or --body '[...]'.`);
6356
6633
  }
6357
- return [item];
6634
+ if (ids.length) return { items: ids.map((id$1, index) => bulkItem({
6635
+ ...data$1,
6636
+ id: idValue(id$1)
6637
+ }, index)) };
6638
+ return { items: [bulkItem(data$1, 0)] };
6639
+ }
6640
+ function arrayBody(op$1, body) {
6641
+ if (Array.isArray(body)) return body;
6642
+ if (isRecord(body)) return [body];
6643
+ throw new Error(`asa ${op$1.group} ${op$1.action} needs --body '[...]', as Apple documents it.`);
6358
6644
  }
6359
6645
  const QUERY_NAMES = {
6360
- fields: "fields",
6361
6646
  limit: "limit",
6362
6647
  offset: "offset",
6363
- name: "name",
6364
- states: "states",
6648
+ owned: "returnOwnedApps",
6649
+ "store-fronts": "storeFronts",
6365
6650
  country: "countrycode",
6366
6651
  entity: "entity",
6367
- countries: "countriesOrRegions",
6368
- "device-classes": "deviceClasses",
6369
- "language-codes": "languageCodes",
6370
- expand: "expand",
6371
- owned: "returnOwnedApps",
6372
- "include-deleted-assets": "includeDeletedCreativeSetAssets"
6652
+ "supply-source": "supplySource",
6653
+ eligible: "eligible",
6654
+ "resource-type": "resourceType"
6373
6655
  };
6374
6656
  function queryFor(op$1, flags, positional) {
6375
6657
  const qs = new URLSearchParams();
6658
+ for (const [key, value$1] of Object.entries(op$1.defaults ?? {})) qs.set(key, String(value$1));
6376
6659
  if (op$1.positional === "query") {
6377
6660
  if (!positional) throw new Error(`asa ${op$1.group} ${op$1.action} needs a search query.`);
6378
6661
  qs.set("query", positional);
6379
6662
  }
6380
6663
  for (const name of op$1.query ?? []) {
6381
- if (name === "all" || name === "adam-id") continue;
6382
- const key = QUERY_NAMES[name];
6664
+ const key = name === "limit" ? op$1.pageSize ?? "limit" : QUERY_NAMES[name];
6383
6665
  if (!key) continue;
6384
6666
  const v = flagValue(flags, name);
6385
6667
  if (v === void 0 || v === null || v === "" || v === false) continue;
@@ -6387,29 +6669,42 @@ function queryFor(op$1, flags, positional) {
6387
6669
  }
6388
6670
  return qs;
6389
6671
  }
6672
+ function scopeFilters(op$1, scope) {
6673
+ return (op$1.filters ?? []).flatMap((filter) => {
6674
+ const value$1 = filterValue(filter, scope);
6675
+ if (!value$1) return [];
6676
+ const typed = filter.text ? value$1 : idValue(value$1);
6677
+ return [{
6678
+ field: filter.field,
6679
+ operator: "EQUALS",
6680
+ value: filter.list ? [typed] : typed
6681
+ }];
6682
+ });
6683
+ }
6390
6684
  async function collectPages(fetchPage, startOffset, limit) {
6391
6685
  const out = [];
6392
6686
  let offset = startOffset;
6393
6687
  for (let i = 0; i < MAX_PAGES; i++) {
6394
6688
  const page = await fetchPage(offset, limit);
6395
- const items = Array.isArray(page.data) ? page.data : [];
6689
+ const items = Array.isArray(page.result) ? page.result : [];
6396
6690
  out.push(...items);
6397
6691
  if (items.length === 0) break;
6398
6692
  offset += items.length;
6399
- const total = page.pagination?.totalResults;
6693
+ const total = page.pagination?.totalCount;
6400
6694
  if (typeof total === "number" && offset >= total) break;
6401
6695
  if (items.length < limit) break;
6402
6696
  }
6403
6697
  return {
6404
- data: out,
6698
+ result: out,
6405
6699
  pagination: {
6406
- totalResults: out.length,
6407
- startIndex: startOffset,
6408
- itemsPerPage: out.length
6700
+ offset: startOffset,
6701
+ pageSize: out.length,
6702
+ totalCount: out.length
6409
6703
  }
6410
6704
  };
6411
6705
  }
6412
- function resolveOperation(input) {
6706
+ const isBulkBody = (body) => Array.isArray(body) || isRecord(body) && Array.isArray(body.items);
6707
+ function resolveOperation(input, body) {
6413
6708
  const variants = asaVariants(input.group, input.action);
6414
6709
  if (variants.length === 0) {
6415
6710
  if (!asaGroups().includes(input.group)) throw new Error(`Unknown "asa ${input.group}". Use get|post|put|delete <path>, a raw path, docs, keys, or: ${asaGroups().join(" | ")}`);
@@ -6417,15 +6712,16 @@ function resolveOperation(input) {
6417
6712
  }
6418
6713
  const positional = variants[0]?.positional;
6419
6714
  const ids = positional === "id" || positional === "ids" ? splitList(input.positional) : [];
6715
+ const bulk = variants.some((v) => v.body === "bulk") && isBulkBody(body);
6420
6716
  const scope = {
6421
6717
  campaign: stringFlag(input.flags, "campaign"),
6422
6718
  adgroup: stringFlag(input.flags, "adgroup"),
6423
6719
  adamId: stringFlag(input.flags, "adam-id") ?? (positional === "adam-id" ? input.positional : void 0),
6424
6720
  ids,
6425
- adgroupLevel: input.flags.adgroupLevel === true
6721
+ bulk
6426
6722
  };
6427
- const needsId = variants.every((v) => placeholdersOf(v.path).includes("id") || v.body === "ids");
6428
- if ((positional === "id" || positional === "ids") && ids.length === 0 && needsId) throw new Error(`asa ${input.group} ${input.action} needs an id.`);
6723
+ const needsId = variants.every((v) => placeholdersOf(v.path).includes("id") || v.body === "bulk");
6724
+ if ((positional === "id" || positional === "ids") && ids.length === 0 && needsId && !bulk) throw new Error(`asa ${input.group} ${input.action} needs an id.`);
6429
6725
  if (positional === "adam-id" && !scope.adamId) throw new Error(`asa ${input.group} ${input.action} needs an App Store app id (adamId).`);
6430
6726
  return {
6431
6727
  op: selectVariant(variants, scope),
@@ -6433,113 +6729,103 @@ function resolveOperation(input) {
6433
6729
  };
6434
6730
  }
6435
6731
  async function runAsaOperation(api, appId, input, options) {
6436
- const { op: op$1, scope } = resolveOperation(input);
6437
- const path = fillPath(op$1.path, scope);
6438
6732
  const flags = input.flags;
6439
- const proxy = (method, p, body) => {
6440
- return asaProxy(api, appId, method, p, body, { orgId: options.orgId });
6733
+ const bodyInput = flagValue(flags, "body");
6734
+ const body = given(bodyInput) ? readJsonInput(bodyInput, "--body") : void 0;
6735
+ const { op: op$1, scope } = resolveOperation(input, body);
6736
+ const path = fillPath(op$1.path, scope);
6737
+ const proxy = (method, p, payload) => {
6738
+ return asaProxy(api, appId, method, p, payload, { adAccountId: options.adAccountId });
6441
6739
  };
6442
6740
  const all = flags.all === true;
6443
6741
  const limit = numberFlag(flags, "limit");
6444
6742
  const offset = numberFlag(flags, "offset") ?? 0;
6445
- if (op$1.body === "selector") {
6446
- const selector = buildSelector({
6447
- selector: flagValue(flags, "selector"),
6743
+ const send = async (payload) => ({
6744
+ op: op$1,
6745
+ path,
6746
+ response: await proxy(op$1.method, path, payload)
6747
+ });
6748
+ if (op$1.body === "query" || op$1.body === "report") {
6749
+ const query$1 = {
6750
+ query: flagValue(flags, "query"),
6448
6751
  field: stringFlag(flags, "field"),
6449
6752
  op: stringFlag(flags, "op"),
6450
6753
  values: stringFlag(flags, "values"),
6451
6754
  orderBy: stringFlag(flags, "order-by"),
6452
6755
  fields: stringFlag(flags, "fields"),
6453
6756
  limit,
6454
- offset: numberFlag(flags, "offset")
6455
- });
6456
- if (all) return {
6457
- op: op$1,
6458
- path,
6459
- response: await collectPages((pageOffset, pageLimit) => {
6460
- const pagination = {
6461
- offset: pageOffset,
6462
- limit: pageLimit
6463
- };
6464
- return proxy(op$1.method, path, {
6465
- ...selector,
6466
- pagination
6467
- });
6468
- }, offset, limit ?? DEFAULT_PAGE)
6757
+ offset: numberFlag(flags, "offset"),
6758
+ filters: scopeFilters(op$1, scope)
6469
6759
  };
6470
- return {
6471
- op: op$1,
6472
- path,
6473
- response: await proxy(op$1.method, path, selector)
6474
- };
6475
- }
6476
- if (op$1.body === "report") {
6477
- const report = buildReport({
6760
+ const request = op$1.body === "report" ? buildReport({
6761
+ ...query$1,
6478
6762
  start: stringFlag(flags, "start"),
6479
6763
  end: stringFlag(flags, "end"),
6480
6764
  granularity: stringFlag(flags, "granularity"),
6481
6765
  groupBy: stringFlag(flags, "group-by"),
6482
- selector: flagValue(flags, "selector"),
6483
6766
  timeZone: stringFlag(flags, "time-zone"),
6484
- searchTerms: op$1.action === "searchterms"
6485
- });
6767
+ zoned: op$1.zoned === true
6768
+ }) : buildQuery(query$1);
6769
+ if (!all) return send(request);
6486
6770
  return {
6487
6771
  op: op$1,
6488
6772
  path,
6489
- response: await proxy(op$1.method, path, report)
6773
+ response: await collectPages((pageOffset, pageSize) => {
6774
+ return proxy(op$1.method, path, {
6775
+ ...request,
6776
+ pagination: {
6777
+ offset: pageOffset,
6778
+ pageSize,
6779
+ fetchTotalCount: true
6780
+ }
6781
+ });
6782
+ }, offset, limit ?? DEFAULT_PAGE)
6490
6783
  };
6491
6784
  }
6492
- if (op$1.body === "ids") return {
6493
- op: op$1,
6494
- path,
6495
- response: await proxy(op$1.method, path, scope.ids.map(idValue))
6496
- };
6785
+ if (op$1.body === "bulk") {
6786
+ if (op$1.flags === void 0) {
6787
+ if (isBulkBody(body)) return send(await bulkBody(op$1, {}, {}, body, [], options.account.currency));
6788
+ return send({ items: scope.ids.map((id$1, index) => bulkItem({ id: idValue(id$1) }, index)) });
6789
+ }
6790
+ return send(await bulkBody(op$1, flags, input.params, body, scope.ids, options.account.currency));
6791
+ }
6792
+ if (op$1.body === "array") return send(arrayBody(op$1, body));
6497
6793
  if (op$1.body === "geo") {
6498
6794
  const entity = stringFlag(flags, "entity");
6499
6795
  if (!entity) throw new Error("asa geo get needs --entity <Country|AdminArea|Locality>.");
6500
- const body = scope.ids.map((id$1) => ({
6501
- id: id$1,
6502
- entity
6503
- }));
6504
- return {
6505
- op: op$1,
6506
- path,
6507
- response: await proxy(op$1.method, path, body)
6508
- };
6509
- }
6510
- if (op$1.body === "array") {
6511
- const body = await arrayBody(op$1, flags, input.params, scope.ids, options.currency);
6512
- return {
6513
- op: op$1,
6514
- path,
6515
- response: await proxy(op$1.method, path, body)
6796
+ const request = {
6797
+ geoRequest: scope.ids.map((id$1) => ({
6798
+ id: id$1,
6799
+ entity
6800
+ })),
6801
+ supplySource: stringFlag(flags, "supply-source") ?? "APPSTORE"
6516
6802
  };
6517
- }
6518
- if (op$1.body === "object") {
6519
- const body = await objectBody(op$1, flags, input.params, options.currency);
6520
- const payload = op$1.envelope ? { [op$1.envelope]: body } : body;
6521
- return {
6522
- op: op$1,
6523
- path,
6524
- response: await proxy(op$1.method, path, payload)
6803
+ if (limit !== void 0 || numberFlag(flags, "offset") !== void 0) request.pagination = {
6804
+ offset,
6805
+ pageSize: limit ?? 20
6525
6806
  };
6807
+ return send(request);
6526
6808
  }
6809
+ if (op$1.body === "object") return send(await objectBody(op$1, flags, input.params, body, options));
6527
6810
  if (op$1.method === "GET") {
6528
6811
  const qs = queryFor(op$1, flags, input.positional);
6529
6812
  for (const [key, value$1] of Object.entries(input.params)) {
6530
6813
  if (typeof value$1 === "object" && value$1 !== null) throw new Error(`Nested -d params aren't supported on GET (got "${key}").`);
6531
6814
  qs.set(key, String(value$1));
6532
6815
  }
6533
- if (op$1.paged === "query" && all) return {
6534
- op: op$1,
6535
- path,
6536
- response: await collectPages((pageOffset, pageLimit) => {
6537
- const page = new URLSearchParams(qs);
6538
- page.set("offset", String(pageOffset));
6539
- page.set("limit", String(pageLimit));
6540
- return proxy("GET", withQuery$1(path, page));
6541
- }, offset, limit ?? DEFAULT_PAGE)
6542
- };
6816
+ if (op$1.paged && all) {
6817
+ const sizeParam = op$1.pageSize ?? "limit";
6818
+ return {
6819
+ op: op$1,
6820
+ path,
6821
+ response: await collectPages((pageOffset, pageLimit) => {
6822
+ const page = new URLSearchParams(qs);
6823
+ page.set("offset", String(pageOffset));
6824
+ page.set(sizeParam, String(pageLimit));
6825
+ return proxy("GET", withQuery$1(path, page));
6826
+ }, offset, limit ?? DEFAULT_PAGE)
6827
+ };
6828
+ }
6543
6829
  return {
6544
6830
  op: op$1,
6545
6831
  path,
@@ -6549,26 +6835,49 @@ async function runAsaOperation(api, appId, input, options) {
6549
6835
  return {
6550
6836
  op: op$1,
6551
6837
  path,
6552
- response: await proxy(op$1.method, path) ?? { data: null }
6838
+ response: await proxy(op$1.method, path) ?? { result: null }
6553
6839
  };
6554
6840
  }
6555
- function currencyResolver(api, appId, explicit, orgId) {
6556
- let cached;
6557
- return () => {
6558
- if (explicit) return Promise.resolve(explicit.toUpperCase());
6559
- cached ??= (async () => {
6560
- const acls = await asaProxy(api, appId, "GET", "/acls");
6561
- const rows = Array.isArray(acls.data) ? acls.data.filter(isRecord) : [];
6562
- if (orgId) {
6563
- const match = rows.find((r) => String(r.orgId) === orgId && typeof r.currency === "string");
6564
- if (match) return String(match.currency).toUpperCase();
6565
- }
6566
- const currencies = [...new Set(rows.map((r) => r.currency).filter((c) => typeof c === "string"))];
6567
- const [only] = currencies;
6568
- if (currencies.length === 1 && only) return only.toUpperCase();
6569
- throw new Error(currencies.length === 0 ? "Couldn't determine the account currency from Apple Search Ads. Pass --currency (e.g. USD)." : `This API user spans several currencies (${currencies.join(", ")}). Pass --currency or --org-id.`);
6570
- })();
6571
- return cached;
6841
+ function aclAccounts(acls) {
6842
+ const result = acls && isRecord(acls.result) ? acls.result : {};
6843
+ return (Array.isArray(result.acls) ? result.acls.filter(isRecord) : []).map((r) => r.adAccount).filter(isRecord);
6844
+ }
6845
+ const currencyOf = (account) => {
6846
+ return account && typeof account.currency === "string" && account.currency ? account.currency.toUpperCase() : void 0;
6847
+ };
6848
+ function accountResolver(api, appId, explicitCurrency, adAccountId) {
6849
+ let accounts;
6850
+ let cachedCurrency;
6851
+ const choose = async (forCurrency) => {
6852
+ accounts ??= asaProxy(api, appId, "GET", "/acls").then(aclAccounts);
6853
+ const list$1 = await accounts;
6854
+ const account = adAccountId ? list$1.find((a) => String(a.id) === adAccountId) : list$1.length === 1 ? list$1[0] : void 0;
6855
+ if (account) return account;
6856
+ const ids = list$1.map((a) => String(a.id)).join(", ");
6857
+ if (adAccountId) {
6858
+ const reach = ids ? ` It reaches: ${ids}.` : "";
6859
+ const skip = forCurrency ? " Pass --currency (e.g. USD) to skip the lookup." : "";
6860
+ throw new Error(`This API user can't reach ad account ${adAccountId}.${reach}${skip}`);
6861
+ }
6862
+ if (!ids) throw new Error(`This API user can't reach any Apple Ads ad account.${forCurrency ? " Pass --currency (e.g. USD)." : ""}`);
6863
+ throw new Error(`This API user reaches several ad accounts (${ids}). Pass --ad-account-id${forCurrency ? " or --currency" : ""}.`);
6864
+ };
6865
+ return {
6866
+ id: async () => adAccountId ?? String((await choose(false)).id),
6867
+ currency: () => {
6868
+ if (explicitCurrency) return Promise.resolve(explicitCurrency.toUpperCase());
6869
+ cachedCurrency ??= (async () => {
6870
+ const account = await choose(true);
6871
+ const listed = currencyOf(account);
6872
+ if (listed) return listed;
6873
+ const id$1 = String(account.id);
6874
+ const detail = await asaProxy(api, appId, "GET", `/ad-accounts/${encodeURIComponent(id$1)}`, void 0, { adAccountId: id$1 });
6875
+ const currency = currencyOf(detail && isRecord(detail.result) ? detail.result : void 0);
6876
+ if (!currency) throw new Error(`Couldn't read ad account ${id$1}'s currency from Apple Ads. Pass --currency (e.g. USD).`);
6877
+ return currency;
6878
+ })();
6879
+ return cachedCurrency;
6880
+ }
6572
6881
  };
6573
6882
  }
6574
6883
 
@@ -6596,7 +6905,7 @@ function rowMeta(row) {
6596
6905
  const parts = [];
6597
6906
  for (const key of [
6598
6907
  "status",
6599
- "servingStatus",
6908
+ "displayStatus",
6600
6909
  "matchType",
6601
6910
  "state",
6602
6911
  "type",
@@ -6606,7 +6915,9 @@ function rowMeta(row) {
6606
6915
  const v = row[key];
6607
6916
  if (typeof v === "string" && v) parts.push(v);
6608
6917
  }
6609
- const bid = row.bidAmount ?? row.dailyBudgetAmount ?? row.defaultBidAmount;
6918
+ const budget = isRecord(row.dailyBudget) ? row.dailyBudget.value : void 0;
6919
+ const strategyBid = isRecord(row.bidStrategy) ? row.bidStrategy.bid : void 0;
6920
+ const bid = row.bid ?? strategyBid ?? budget;
6610
6921
  if (isRecord(bid) && bid.amount !== void 0) parts.push(`${String(bid.amount)} ${String(bid.currency ?? "")}`.trim());
6611
6922
  const id$1 = row.id ?? row.adamId ?? row.orgId;
6612
6923
  if (id$1 !== void 0) parts.push(String(id$1));
@@ -6614,11 +6925,11 @@ function rowMeta(row) {
6614
6925
  }
6615
6926
  function printResult(ctx, op$1, response) {
6616
6927
  if (ctx.json) return ctx.output.data(response);
6617
- const rows = Array.isArray(response.data) ? response.data.filter(isRecord) : void 0;
6618
- const listing = op$1.action === "list" || op$1.action === "find" || op$1.action === "search" || op$1.action === "assets";
6928
+ const rows = Array.isArray(response.result) ? response.result.filter(isRecord) : void 0;
6929
+ const listing = op$1.body === "query" || op$1.action === "search";
6619
6930
  if (!rows || !listing) return ctx.output.data(response);
6620
6931
  if (rows.length === 0) return ctx.ui.step(`No ${op$1.group} found`);
6621
- const total = response.pagination?.totalResults;
6932
+ const total = response.pagination?.totalCount;
6622
6933
  const count = typeof total === "number" && total > rows.length ? `${rows.length} of ${total}` : String(rows.length);
6623
6934
  ctx.ui.step(`${count} ${op$1.group}`);
6624
6935
  for (const row of rows) ctx.ui.info(`\`${rowLabel(row)}\` ${rowMeta(row)}`);
@@ -6631,14 +6942,26 @@ function describeAppleError(error, request) {
6631
6942
  const parsed = error.body ? parseJson(error.body) : void 0;
6632
6943
  if (!isRecord(parsed)) return void 0;
6633
6944
  if (parsed.error === "credentials_not_found" || parsed.error === "invalid_credentials") return /* @__PURE__ */ new Error(`${error.message}\n${CONNECT_HINT}`);
6634
- const apple = isRecord(parsed.error) && Array.isArray(parsed.error.errors) ? parsed.error.errors : void 0;
6635
- if (!apple || apple.length === 0) return void 0;
6636
- const lines = apple.filter(isRecord).map((e) => {
6945
+ const lines = appleErrorLines(parsed.error);
6946
+ if (lines.length === 0) return void 0;
6947
+ return /* @__PURE__ */ new Error(`Apple Search Ads rejected ${request} (${error.status}):\n${lines.join("\n")}`);
6948
+ }
6949
+ function appleErrorLines(error) {
6950
+ if (!isRecord(error)) return [];
6951
+ if (Array.isArray(error.errors)) return error.errors.filter(isRecord).map((e) => {
6637
6952
  const field$1 = typeof e.field === "string" && e.field ? `${e.field}: ` : "";
6638
6953
  const code = typeof e.messageCode === "string" && e.messageCode ? ` (${e.messageCode})` : "";
6639
6954
  return ` • ${field$1}${String(e.message ?? "")}${code}`;
6640
6955
  });
6641
- return /* @__PURE__ */ new Error(`Apple Search Ads rejected ${request} (${error.status}):\n${lines.join("\n")}`);
6956
+ if (typeof error.code !== "string") return [];
6957
+ const details = Array.isArray(error.details) ? error.details.filter(isRecord) : [];
6958
+ if (details.length === 0) return [` • ${String(error.message ?? error.code)} (${error.code})`];
6959
+ return details.map((d) => {
6960
+ const info = isRecord(d.info) ? d.info : {};
6961
+ const field$1 = typeof info.field === "string" && info.field ? `${info.field}: ` : "";
6962
+ const code = typeof d.code === "string" && d.code ? ` (${d.code})` : "";
6963
+ return ` • ${field$1}${String(d.message ?? error.message ?? "")}${code}`;
6964
+ });
6642
6965
  }
6643
6966
  async function withAppleErrors(request, work) {
6644
6967
  try {
@@ -6666,20 +6989,20 @@ async function resolveAsaApp(ctx, base) {
6666
6989
  };
6667
6990
  }
6668
6991
  async function runAsaRequest(ctx, base, request) {
6669
- const { verb, path, orgId } = request;
6992
+ const { verb, path, adAccountId } = request;
6670
6993
  const params = parseParams(request.data);
6671
6994
  if (!path.startsWith("/")) throw new Error(`Path must start with "/", e.g. /campaigns`);
6672
6995
  const { app: app$1, api } = await resolveAsaApp(ctx, base);
6673
6996
  const label = `${verb.toUpperCase()} ${path}`;
6674
6997
  return withAppleErrors(label, () => {
6675
6998
  return apiCall(ctx, label, () => {
6676
- if (verb === "get" || verb === "delete") return asaProxy(api, app$1.id, verb, withQuery$1(path, params), void 0, { orgId });
6999
+ if (verb === "get" || verb === "delete") return asaProxy(api, app$1.id, verb, withQuery$1(path, params), void 0, { adAccountId });
6677
7000
  const body = request.body ? readJsonInput(request.body, "--body") : params;
6678
7001
  const payload = isRecord(body) ? {
6679
7002
  ...body,
6680
7003
  ...params
6681
7004
  } : body;
6682
- return asaProxy(api, app$1.id, verb, path, payload, { orgId });
7005
+ return asaProxy(api, app$1.id, verb, path, payload, { adAccountId });
6683
7006
  });
6684
7007
  });
6685
7008
  }
@@ -6707,12 +7030,12 @@ async function runAsa(ctx, { words, flags }) {
6707
7030
  }
6708
7031
  if (extra.length) throw new Error(`\`superwall asa\` doesn't take "${extra.join(" ")}".`);
6709
7032
  const data$1 = listOf(flags.d);
6710
- const orgId = textField(flags, "orgId");
7033
+ const adAccountId = textField(flags, "adAccountId");
6711
7034
  if (target.startsWith("/")) return ctx.output.data(await runAsaRequest(ctx, ctx.api, {
6712
7035
  verb: "get",
6713
7036
  path: target,
6714
7037
  data: data$1,
6715
- orgId
7038
+ adAccountId
6716
7039
  }));
6717
7040
  const params = parseParams(data$1);
6718
7041
  if (!asaGroups().includes(target)) throw new Error(`asa has no "${target}". It takes: ${asaGroups().join(", ")}, docs, keys, get, post, put, delete, or a /path.\nRun superwall asa --help for what each does.`);
@@ -6726,12 +7049,12 @@ async function runAsa(ctx, { words, flags }) {
6726
7049
  flags,
6727
7050
  params
6728
7051
  };
6729
- const currency = currencyResolver(api, asaApp.id, textField(flags, "currency"), orgId);
7052
+ const account = accountResolver(api, asaApp.id, textField(flags, "currency"), adAccountId);
6730
7053
  const label = `asa ${input.group} ${input.action}`;
6731
7054
  const result = await withAppleErrors(label, () => {
6732
7055
  return apiCall(ctx, label, () => runAsaOperation(api, asaApp.id, input, {
6733
- orgId,
6734
- currency
7056
+ adAccountId,
7057
+ account
6735
7058
  }));
6736
7059
  });
6737
7060
  printResult(ctx, result.op, result.response);
@@ -6769,7 +7092,7 @@ const POSITIONAL = {
6769
7092
  }
6770
7093
  }
6771
7094
  };
6772
- const PLACEHOLDER = {
7095
+ const SCOPE = {
6773
7096
  campaign: {
6774
7097
  name: "campaign",
6775
7098
  describe: "Campaign id"
@@ -6778,7 +7101,7 @@ const PLACEHOLDER = {
6778
7101
  name: "adgroup",
6779
7102
  describe: "Ad group id"
6780
7103
  },
6781
- adamId: {
7104
+ "adam-id": {
6782
7105
  name: "adam_id",
6783
7106
  describe: "App Store app id (adamId)"
6784
7107
  }
@@ -6806,34 +7129,19 @@ function schemaOfFlag$1(flag$1) {
6806
7129
  description: flag$1.describe
6807
7130
  };
6808
7131
  }
7132
+ const SUPPLY_SOURCE = {
7133
+ type: "string",
7134
+ enum: ["APPSTORE", "MAPS"],
7135
+ description: "Supply source (default APPSTORE)"
7136
+ };
6809
7137
  const QUERY = {
6810
- fields: {
6811
- type: "string",
6812
- description: "Comma-separated fields to return"
6813
- },
6814
- field: {
6815
- type: "string",
6816
- description: "Selector shorthand: field name (with op and values)"
6817
- },
6818
- op: {
6819
- type: "string",
6820
- description: "Selector shorthand: EQUALS, IN, CONTAINS, STARTSWITH, ..."
6821
- },
6822
- values: {
6823
- type: "string",
6824
- description: "Selector shorthand: comma-separated values"
6825
- },
6826
- "order-by": {
6827
- type: "string",
6828
- description: "Selector sort: field[:asc|desc]"
6829
- },
6830
- name: {
6831
- type: "string",
6832
- description: "Name to filter by"
7138
+ owned: {
7139
+ type: "boolean",
7140
+ description: "Only apps this account owns"
6833
7141
  },
6834
- states: {
7142
+ "store-fronts": {
6835
7143
  type: "string",
6836
- description: "Comma-separated states"
7144
+ description: "Comma-separated storefronts"
6837
7145
  },
6838
7146
  country: {
6839
7147
  type: "string",
@@ -6848,29 +7156,36 @@ const QUERY = {
6848
7156
  ],
6849
7157
  description: "What kind of place to search for"
6850
7158
  },
6851
- countries: {
6852
- type: "string",
6853
- description: "Comma-separated country codes"
7159
+ "supply-source": SUPPLY_SOURCE,
7160
+ eligible: {
7161
+ type: "boolean",
7162
+ description: "Only places that can be targeted"
6854
7163
  },
6855
- "device-classes": {
7164
+ "resource-type": {
6856
7165
  type: "string",
6857
- description: "Comma-separated device classes"
7166
+ description: "Advertiser resource type, e.g. CONTENT_PROVIDER"
7167
+ }
7168
+ };
7169
+ const QUERY_BODY = {
7170
+ query: {
7171
+ type: "object",
7172
+ description: "An Apple query request: filters, sorting, pagination"
6858
7173
  },
6859
- "language-codes": {
7174
+ field: {
6860
7175
  type: "string",
6861
- description: "Comma-separated language codes"
7176
+ description: "Filter shorthand: field name (with op and values)"
6862
7177
  },
6863
- expand: {
6864
- type: "boolean",
6865
- description: "Include nested versions"
7178
+ op: {
7179
+ type: "string",
7180
+ description: "Filter shorthand: EQUALS, IN, LIKE, STARTS_WITH, BETWEEN, ..."
6866
7181
  },
6867
- owned: {
6868
- type: "boolean",
6869
- description: "Only apps this org owns"
7182
+ values: {
7183
+ type: "string",
7184
+ description: "Filter shorthand: comma-separated values"
6870
7185
  },
6871
- "include-deleted-assets": {
6872
- type: "boolean",
6873
- description: "Include deleted assets"
7186
+ order_by: {
7187
+ type: "string",
7188
+ description: "Sort: field[:asc|desc]"
6874
7189
  }
6875
7190
  };
6876
7191
  const snake = (flag$1) => flag$1.replace(/-/g, "_");
@@ -6882,9 +7197,9 @@ function toolOf$1(group$1, action) {
6882
7197
  type: "string",
6883
7198
  description: "The Superwall app whose Apple Search Ads account to use, when several have it connected"
6884
7199
  },
6885
- org_id: {
7200
+ ad_account_id: {
6886
7201
  type: "string",
6887
- description: "Apple Search Ads org id, when the API user spans several"
7202
+ description: "Apple Ads ad account id, when the API user reaches several"
6888
7203
  }
6889
7204
  };
6890
7205
  const positionals = [];
@@ -6893,33 +7208,36 @@ function toolOf$1(group$1, action) {
6893
7208
  if (positional) {
6894
7209
  properties[positional.name] = positional.schema;
6895
7210
  positionals.push(positional.name);
6896
- if (variants.every((variant) => variant.positional === first?.positional)) required.push(positional.name);
6897
- }
6898
- for (const placeholder$1 of first ? placeholdersOf(first.path) : []) {
6899
- const named = PLACEHOLDER[placeholder$1];
6900
- if (named && variants.every((variant) => placeholdersOf(variant.path).includes(placeholder$1))) required.push(named.name);
7211
+ if (!variants.some((variant) => variant.body === "bulk") && variants.every((variant) => variant.positional === first?.positional)) required.push(positional.name);
6901
7212
  }
6902
7213
  for (const variant of variants) {
6903
- for (const placeholder$1 of placeholdersOf(variant.path)) {
6904
- const named = PLACEHOLDER[placeholder$1];
6905
- if (named && !properties[named.name]) properties[named.name] = {
7214
+ if (placeholdersOf(variant.path).includes("adamId") && variant.positional !== "adam-id") {
7215
+ properties.adam_id ??= {
6906
7216
  type: "string",
6907
- description: named.describe
7217
+ description: "App Store app id (adamId)"
6908
7218
  };
7219
+ required.push("adam_id");
7220
+ }
7221
+ for (const filter of variant.filters ?? []) {
7222
+ const scope = SCOPE[filter.flag];
7223
+ if (!scope) continue;
7224
+ properties[scope.name] ??= {
7225
+ type: "string",
7226
+ description: `${scope.describe}: only rows for it`
7227
+ };
7228
+ if (filter.required) required.push(scope.name);
6909
7229
  }
6910
7230
  for (const flag$1 of variant.flags ?? []) properties[snake(flag$1.flag)] ??= schemaOfFlag$1(flag$1);
6911
7231
  for (const name of variant.query ?? []) {
6912
7232
  const schema = QUERY[name];
6913
7233
  if (schema) properties[snake(name)] ??= schema;
6914
7234
  }
6915
- if (variant.body === "object" || variant.body === "array") properties.body = {
7235
+ if (variant.body === "object" || variant.body === "bulk" || variant.body === "array") properties.body = {
6916
7236
  type: ["object", "array"],
6917
7237
  description: "The whole request body, as Apple documents it"
6918
7238
  };
6919
- if (variant.body === "selector" || variant.body === "report") properties.selector = {
6920
- type: "object",
6921
- description: "An Apple selector: conditions, orderBy, pagination"
6922
- };
7239
+ if (variant.body === "array") required.push("body");
7240
+ if (variant.body === "query" || variant.body === "report") Object.assign(properties, QUERY_BODY);
6923
7241
  if (variant.body === "report") {
6924
7242
  properties.start = {
6925
7243
  type: "string",
@@ -6929,10 +7247,22 @@ function toolOf$1(group$1, action) {
6929
7247
  type: "string",
6930
7248
  description: "Last day, YYYY-MM-DD"
6931
7249
  };
6932
- properties.time_zone = {
7250
+ properties.granularity = {
7251
+ type: "string",
7252
+ description: "HOURLY, DAILY, WEEKLY or MONTHLY (default DAILY)"
7253
+ };
7254
+ properties.group_by = {
7255
+ type: "string",
7256
+ description: "Comma-separated dimensions, e.g. countryOrRegion"
7257
+ };
7258
+ properties.fields = {
7259
+ type: "string",
7260
+ description: "Comma-separated fields to return"
7261
+ };
7262
+ if (variant.zoned) properties.time_zone = {
6933
7263
  type: "string",
6934
7264
  enum: ["UTC", "ORTZ"],
6935
- description: "Report time zone"
7265
+ description: "Report time zone (default UTC)"
6936
7266
  };
6937
7267
  required.push("start", "end");
6938
7268
  }
@@ -6946,6 +7276,7 @@ function toolOf$1(group$1, action) {
6946
7276
  ],
6947
7277
  description: "What kind of place the ids are"
6948
7278
  };
7279
+ properties.supply_source = SUPPLY_SOURCE;
6949
7280
  required.push("entity");
6950
7281
  }
6951
7282
  if (variant.paged) {
@@ -6966,10 +7297,6 @@ function toolOf$1(group$1, action) {
6966
7297
  type: "string",
6967
7298
  description: "Currency for amounts"
6968
7299
  };
6969
- if (variant.level === "adgroup") properties.adgroup_level = {
6970
- type: "boolean",
6971
- description: "Ad group negative keywords instead of the campaign's"
6972
- };
6973
7300
  }
6974
7301
  const effect = variants.some((variant) => variant.effect === "destructive") ? "destructive" : variants.every((variant) => variant.effect === "read") ? "read" : "write";
6975
7302
  return {
@@ -6990,18 +7317,19 @@ async function listAsaTools() {
6990
7317
 
6991
7318
  //#endregion
6992
7319
  //#region src/commands/apple-search-ads/asa.ts
6993
- const command$38 = defineCatalog({
7320
+ const command$39 = defineCatalog({
6994
7321
  name: "asa",
6995
- summary: "The Apple Search Ads API through Superwall's proxy: no key or token handling",
7322
+ summary: "The Apple Ads Platform API (v1) through Superwall's proxy: no key or token handling",
7323
+ strictFlags: true,
6996
7324
  flags: {
6997
7325
  app: {
6998
7326
  ...app,
6999
7327
  describe: "Superwall app id or name (if several have Apple Search Ads connected)"
7000
7328
  },
7001
- orgId: {
7329
+ adAccountId: {
7002
7330
  type: "string",
7003
7331
  value: "id",
7004
- describe: "Apple Search Ads org id (X-AP-Context), if the API user spans several"
7332
+ describe: "Apple Ads ad account id (X-AP-Context), if the API user reaches several"
7005
7333
  },
7006
7334
  campaign: {
7007
7335
  type: "string",
@@ -7027,32 +7355,32 @@ const command$38 = defineCatalog({
7027
7355
  value: "json",
7028
7356
  describe: "Request body as JSON: inline, @file, or @- for stdin"
7029
7357
  },
7030
- selector: {
7358
+ query: {
7031
7359
  type: "string",
7032
7360
  value: "json",
7033
- describe: "Apple selector as JSON (find, reports): inline, @file, or @-"
7361
+ describe: "Apple query request as JSON (lists, reports): filters, sorting, pagination"
7034
7362
  },
7035
7363
  field: {
7036
7364
  type: "string",
7037
- describe: "Selector shorthand: field name (with --op and --values)"
7365
+ describe: "Filter shorthand: field name (with --op and --values)"
7038
7366
  },
7039
7367
  op: {
7040
7368
  type: "string",
7041
- describe: "Selector shorthand: EQUALS, IN, CONTAINS, STARTSWITH, ..."
7369
+ describe: "Filter shorthand: EQUALS, IN, LIKE, STARTS_WITH, BETWEEN, ..."
7042
7370
  },
7043
7371
  values: {
7044
7372
  type: "string",
7045
- describe: "Selector shorthand: comma-separated values"
7373
+ describe: "Filter shorthand: comma-separated values"
7046
7374
  },
7047
7375
  orderBy: {
7048
7376
  type: "string",
7049
7377
  value: "field[:asc|desc]",
7050
- describe: "Selector sort: field[:asc|desc]"
7378
+ describe: "Sort: field[:asc|desc]"
7051
7379
  },
7052
7380
  fields: {
7053
7381
  type: "string",
7054
7382
  value: "a,b",
7055
- describe: "Comma-separated fields to return (partial fetch)"
7383
+ describe: "Comma-separated fields to return (reports)"
7056
7384
  },
7057
7385
  limit: {
7058
7386
  type: "number",
@@ -7068,7 +7396,7 @@ const command$38 = defineCatalog({
7068
7396
  },
7069
7397
  currency: {
7070
7398
  type: "string",
7071
- describe: "Currency for money flags (defaults to the account's)"
7399
+ describe: "Currency for money flags (defaults to the ad account's)"
7072
7400
  },
7073
7401
  name: {
7074
7402
  type: "string",
@@ -7076,39 +7404,47 @@ const command$38 = defineCatalog({
7076
7404
  },
7077
7405
  status: {
7078
7406
  type: "string",
7079
- describe: "ENABLED, PAUSED (keywords: ACTIVE, PAUSED)"
7407
+ describe: "ENABLED or PAUSED"
7080
7408
  },
7081
7409
  countries: {
7082
7410
  type: "string",
7083
- describe: "Comma-separated country codes"
7084
- },
7085
- budget: {
7086
- type: "string",
7087
- describe: "Lifetime budget amount"
7411
+ describe: "Comma-separated country or region codes"
7088
7412
  },
7089
7413
  dailyBudget: {
7090
7414
  type: "string",
7091
7415
  describe: "Daily budget amount"
7092
7416
  },
7417
+ amount: {
7418
+ type: "string",
7419
+ describe: "Budget order amount"
7420
+ },
7093
7421
  supplySources: {
7094
7422
  type: "string",
7095
- describe: "Comma-separated supply sources"
7423
+ describe: "Comma-separated supply sources (APPSTORE, MAPS)"
7096
7424
  },
7097
- adChannelType: {
7425
+ supplyPlacements: {
7098
7426
  type: "string",
7099
- describe: "SEARCH or DISPLAY"
7427
+ describe: "Comma-separated placements"
7428
+ },
7429
+ promotedType: {
7430
+ type: "string",
7431
+ describe: "APPSTORE_APP (default) or BUSINESS_BRAND"
7100
7432
  },
7101
7433
  billingEvent: {
7102
7434
  type: "string",
7103
7435
  describe: "TAPS or IMPRESSIONS"
7104
7436
  },
7105
- defaultBid: {
7437
+ bidStrategy: {
7438
+ type: "string",
7439
+ describe: "Bid strategy type, e.g. MANUAL_CPT"
7440
+ },
7441
+ bidGoal: {
7106
7442
  type: "string",
7107
- describe: "Ad group default bid"
7443
+ describe: "Bid strategy goal, e.g. TAP"
7108
7444
  },
7109
- cpaGoal: {
7445
+ pricingModel: {
7110
7446
  type: "string",
7111
- describe: "Ad group CPA goal"
7447
+ describe: "Ad group pricing model: CPT, CPM or CPA"
7112
7448
  },
7113
7449
  searchMatch: {
7114
7450
  type: "boolean",
@@ -7120,11 +7456,11 @@ const command$38 = defineCatalog({
7120
7456
  },
7121
7457
  matchType: {
7122
7458
  type: "string",
7123
- describe: "BROAD or EXACT"
7459
+ describe: "EXACT, BROAD, PHRASE or CATEGORY"
7124
7460
  },
7125
7461
  bid: {
7126
7462
  type: "string",
7127
- describe: "Keyword bid amount"
7463
+ describe: "Bid amount"
7128
7464
  },
7129
7465
  creativeId: {
7130
7466
  type: "string",
@@ -7140,11 +7476,11 @@ const command$38 = defineCatalog({
7140
7476
  },
7141
7477
  start: {
7142
7478
  type: "string",
7143
- describe: "Start date (YYYY-MM-DD)"
7479
+ describe: "Start (reports: YYYY-MM-DD)"
7144
7480
  },
7145
7481
  end: {
7146
7482
  type: "string",
7147
- describe: "End date (YYYY-MM-DD)"
7483
+ describe: "End (reports: YYYY-MM-DD)"
7148
7484
  },
7149
7485
  granularity: {
7150
7486
  type: "string",
@@ -7152,23 +7488,19 @@ const command$38 = defineCatalog({
7152
7488
  },
7153
7489
  groupBy: {
7154
7490
  type: "string",
7155
- describe: "Report dimension (e.g. countryOrRegion)"
7491
+ describe: "Report dimensions (e.g. countryOrRegion)"
7156
7492
  },
7157
7493
  timeZone: {
7158
7494
  type: "string",
7159
7495
  describe: "Report time zone: UTC or ORTZ"
7160
7496
  },
7161
- dimensions: {
7162
- type: "string",
7163
- describe: "Impression share dimensions"
7164
- },
7165
- metrics: {
7166
- type: "string",
7167
- describe: "Impression share metrics"
7168
- },
7169
7497
  owned: {
7170
7498
  type: "boolean",
7171
- describe: "apps search: only apps this org owns"
7499
+ describe: "apps search: only apps this account owns"
7500
+ },
7501
+ storeFronts: {
7502
+ type: "string",
7503
+ describe: "apps search: comma-separated storefronts"
7172
7504
  },
7173
7505
  country: {
7174
7506
  type: "string",
@@ -7178,29 +7510,17 @@ const command$38 = defineCatalog({
7178
7510
  type: "string",
7179
7511
  describe: "geo: Country, AdminArea, or Locality"
7180
7512
  },
7181
- adgroupLevel: {
7182
- type: "boolean",
7183
- describe: "negative-keywords find: search ad group negatives"
7184
- },
7185
- states: {
7513
+ supplySource: {
7186
7514
  type: "string",
7187
- describe: "product-pages list: comma-separated states"
7515
+ describe: "geo: APPSTORE (default) or MAPS"
7188
7516
  },
7189
- deviceClasses: {
7190
- type: "string",
7191
- describe: "product-pages: comma-separated device classes"
7192
- },
7193
- languageCodes: {
7194
- type: "string",
7195
- describe: "product-pages: comma-separated language codes"
7196
- },
7197
- expand: {
7517
+ eligible: {
7198
7518
  type: "boolean",
7199
- describe: "product-pages: include nested versions"
7519
+ describe: "geo search: only targetable places"
7200
7520
  },
7201
- includeDeletedAssets: {
7202
- type: "boolean",
7203
- describe: "product-pages: include deleted assets"
7521
+ resourceType: {
7522
+ type: "string",
7523
+ describe: "ad-accounts resources: e.g. CONTENT_PROVIDER"
7204
7524
  }
7205
7525
  },
7206
7526
  operations: asaGroups,
@@ -7222,11 +7542,11 @@ const command$38 = defineCatalog({
7222
7542
 
7223
7543
  //#endregion
7224
7544
  //#region src/commands/apple-search-ads/api/delete.ts
7225
- const command$39 = defineCommand({
7545
+ const command$40 = defineCommand({
7226
7546
  name: "asa delete",
7227
7547
  summary: "Any DELETE request to the Apple Search Ads API",
7228
7548
  args: { path: {
7229
- describe: "Apple Search Ads API path, e.g. /campaigns (the /api/v5 prefix is added)",
7549
+ describe: "Apple Search Ads API path, e.g. /campaigns (the /v1 prefix is added)",
7230
7550
  required: true
7231
7551
  } },
7232
7552
  flags: {
@@ -7234,10 +7554,10 @@ const command$39 = defineCommand({
7234
7554
  ...app,
7235
7555
  describe: "Superwall app id or name (if several have Apple Search Ads connected)"
7236
7556
  },
7237
- orgId: {
7557
+ adAccountId: {
7238
7558
  type: "string",
7239
7559
  value: "id",
7240
- describe: "Apple Search Ads org id (X-AP-Context), if the API user spans several"
7560
+ describe: "Apple Ads ad account id (X-AP-Context), if the API user reaches several"
7241
7561
  },
7242
7562
  d: {
7243
7563
  ...data,
@@ -7254,7 +7574,7 @@ const command$39 = defineCommand({
7254
7574
  verb: "delete",
7255
7575
  path: args.path,
7256
7576
  data: flags.d,
7257
- orgId: flags.orgId
7577
+ adAccountId: flags.adAccountId
7258
7578
  });
7259
7579
  ctx.output.data(res ?? { ok: true });
7260
7580
  }
@@ -7262,7 +7582,7 @@ const command$39 = defineCommand({
7262
7582
 
7263
7583
  //#endregion
7264
7584
  //#region src/core/apple-search-ads/docs.ts
7265
- const APPLE_DOC_DATA_BASE = "https://developer.apple.com/tutorials/data/documentation/apple_ads";
7585
+ const APPLE_DOC_DATA_BASE = "https://developer.apple.com/tutorials/data/documentation/apple-ads-platform-api";
7266
7586
  async function downloadAppleDoc(url) {
7267
7587
  const res = await fetch(url, { headers: { accept: "application/json" } });
7268
7588
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
@@ -7275,10 +7595,10 @@ function usageOf$1(op$1) {
7275
7595
  if (op$1.positional === "ids") parts.push("<id[,id...]>");
7276
7596
  if (op$1.positional === "query") parts.push("<query>");
7277
7597
  if (op$1.positional === "adam-id") parts.push("<adam-id>");
7278
- for (const p of placeholdersOf(op$1.path)) {
7279
- if (p === "campaign") parts.push("--campaign <id>");
7280
- if (p === "adgroup") parts.push("--adgroup <id>");
7281
- if (p === "adamId" && op$1.positional !== "adam-id") parts.push("--adam-id <id>");
7598
+ if (placeholdersOf(op$1.path).includes("adamId") && op$1.positional !== "adam-id") parts.push("--adam-id <id>");
7599
+ for (const filter of op$1.filters ?? []) {
7600
+ if (filter.flag === "id" || filter.flag === "adam-id" && op$1.positional === "adam-id") continue;
7601
+ parts.push(filter.required ? `--${filter.flag} <id>` : `[--${filter.flag} <id>]`);
7282
7602
  }
7283
7603
  return parts.join(" ");
7284
7604
  }
@@ -7288,39 +7608,40 @@ function flagLines(op$1) {
7288
7608
  const value$1 = f.type === "boolean" ? "" : f.type === "money" ? " <amount>" : f.type === "list" ? " <a,b,c>" : f.type === "number" ? " <n>" : " <value>";
7289
7609
  lines.push(` --${f.flag}${value$1} ${f.describe} → \`${f.key}\``);
7290
7610
  }
7291
- if (op$1.body === "object" || op$1.body === "array") {
7611
+ if (op$1.body === "object" || op$1.body === "bulk") {
7292
7612
  lines.push(" -d key=value / key:=json Extra body fields (nesting via key[sub])");
7293
- lines.push(" --body <json|@file|@-> Full request body, sent as-is (merged under flags)");
7613
+ lines.push(" --body <json|@file|@-> Full request body (bulk: an array of items), merged under flags");
7294
7614
  }
7295
- if (op$1.body === "selector") {
7296
- lines.push(" --selector <json|@file|@-> Full Apple selector");
7297
- lines.push(" --field <f> --op <OP> --values <a,b> One-condition shorthand");
7615
+ if (op$1.body === "array") lines.push(" --body <json|@file|@-> The request body: an array, as Apple documents it");
7616
+ if (op$1.body === "query" || op$1.body === "report") {
7617
+ lines.push(" --query <json|@file|@-> Full Apple query request: filters, sorting, pagination");
7618
+ lines.push(" --field <f> --op <OP> --values <a,b> One-filter shorthand");
7298
7619
  lines.push(" --order-by <field[:asc|desc]> Sort");
7299
- lines.push(" --fields <a,b> Partial fetch");
7300
- lines.push(" --limit <n> --offset <n> --all Paging (--all walks every page)");
7301
7620
  }
7302
7621
  if (op$1.body === "report") {
7303
- lines.push(" --selector <json|@file|@-> Filter/sort rows (Apple selector)");
7304
- lines.push(" --time-zone <UTC|ORTZ> Report time zone (default UTC)");
7305
- }
7306
- if (op$1.body === "ids") lines.push(" ids Comma-separated ids in the positional");
7307
- if (op$1.body === "geo") lines.push(" --entity <Country|AdminArea|Locality> Entity type for each id");
7308
- if (op$1.query?.includes("all") && op$1.body !== "selector") lines.push(" --limit <n> --offset <n> --all Paging (--all walks every page)");
7309
- if (op$1.query?.includes("fields") && op$1.body !== "selector") lines.push(" --fields <a,b> Partial fetch");
7310
- if (op$1.query?.includes("owned")) lines.push(" --owned Only apps this org owns");
7622
+ lines.push(" --start <YYYY-MM-DD> --end <YYYY-MM-DD> Report range");
7623
+ lines.push(" --granularity <HOURLY|DAILY|WEEKLY|MONTHLY> Rows per period (default DAILY)");
7624
+ lines.push(" --group-by <a,b> Group rows by dimension");
7625
+ lines.push(" --fields <a,b> Only these fields");
7626
+ if (op$1.zoned) lines.push(" --time-zone <UTC|ORTZ> Report time zone (default UTC)");
7627
+ }
7628
+ if (op$1.body === "geo") {
7629
+ lines.push(" --entity <Country|AdminArea|Locality> Entity type for each id");
7630
+ lines.push(" --supply-source <APPSTORE|MAPS> Supply source (default APPSTORE)");
7631
+ }
7632
+ if (op$1.paged) lines.push(" --limit <n> --offset <n> --all Paging (--all walks every page)");
7633
+ if (op$1.query?.includes("owned")) lines.push(" --owned Only apps this account owns");
7634
+ if (op$1.query?.includes("store-fronts")) lines.push(" --store-fronts <a,b> Restrict to storefronts");
7311
7635
  if (op$1.query?.includes("country")) lines.push(" --country <CC> Restrict to a country code");
7312
- if (op$1.query?.includes("entity") && op$1.body !== "geo") lines.push(" --entity <Country|AdminArea|Locality>");
7313
- if (op$1.level === "adgroup") lines.push(" --adgroup-level Search ad group negatives instead of campaign negatives");
7314
- if (op$1.query?.includes("name")) lines.push(" --name <text> Filter by name");
7315
- if (op$1.query?.includes("states")) lines.push(" --states <a,b> Filter by state");
7316
- if (op$1.query?.includes("countries")) lines.push(" --countries <a,b> Restrict to country codes");
7317
- if (op$1.query?.includes("device-classes")) lines.push(" --device-classes <a,b> --language-codes <a,b> --expand");
7318
- if (op$1.query?.includes("include-deleted-assets")) lines.push(" --include-deleted-assets");
7636
+ if (op$1.query?.includes("entity")) lines.push(" --entity <Country|AdminArea|Locality>");
7637
+ if (op$1.query?.includes("supply-source")) lines.push(" --supply-source <APPSTORE|MAPS> Supply source (default APPSTORE)");
7638
+ if (op$1.query?.includes("eligible")) lines.push(" --eligible Only places that can be targeted");
7639
+ if (op$1.query?.includes("resource-type")) lines.push(" --resource-type <type> e.g. CONTENT_PROVIDER");
7319
7640
  return lines;
7320
7641
  }
7321
7642
  function renderAsaCatalog() {
7322
7643
  const lines = ["# Apple Search Ads — `superwall asa`", ""];
7323
- lines.push("Every Apple Ads Campaign Management API v5 endpoint, through Superwall's proxy.");
7644
+ lines.push("Every Apple Ads Platform API v1 endpoint, through Superwall's proxy.");
7324
7645
  lines.push("`superwall asa docs <group>` lists a group, `superwall asa docs <group> <action>` fetches Apple's page.");
7325
7646
  lines.push("");
7326
7647
  for (const group$1 of asaGroups()) {
@@ -7349,16 +7670,16 @@ function renderAsaGroup(group$1) {
7349
7670
  }
7350
7671
  return lines.join("\n").trimEnd();
7351
7672
  }
7352
- function searchAsaCatalog(query) {
7353
- const q = query.toLowerCase();
7673
+ function searchAsaCatalog(query$1) {
7674
+ const q = query$1.toLowerCase();
7354
7675
  return ASA_OPERATIONS.filter((o) => {
7355
7676
  return o.group.includes(q) || o.action.includes(q) || o.summary.toLowerCase().includes(q) || o.path.toLowerCase().includes(q);
7356
7677
  });
7357
7678
  }
7358
- function renderAsaSearch(query) {
7359
- const hits = searchAsaCatalog(query);
7360
- if (hits.length === 0) return `No Apple Search Ads endpoint matches "${query}". Run \`superwall asa docs\` for the catalog.`;
7361
- const lines = [`# Endpoints matching "${query}"`, ""];
7679
+ function renderAsaSearch(query$1) {
7680
+ const hits = searchAsaCatalog(query$1);
7681
+ if (hits.length === 0) return `No Apple Search Ads endpoint matches "${query$1}". Run \`superwall asa docs\` for the catalog.`;
7682
+ const lines = [`# Endpoints matching "${query$1}"`, ""];
7362
7683
  for (const v of hits) lines.push(`- \`${usageOf$1(v)}\` — ${v.summary} (${v.method} ${v.path})`);
7363
7684
  return lines.join("\n");
7364
7685
  }
@@ -7446,7 +7767,7 @@ function parameterLines(items, refs) {
7446
7767
  }
7447
7768
  return out;
7448
7769
  }
7449
- function renderAppleDoc(doc) {
7770
+ function renderAppleDoc(doc, body) {
7450
7771
  if (!isNode(doc)) return "";
7451
7772
  const refs = isNode(doc.references) ? doc.references : {};
7452
7773
  const metadata = isNode(doc.metadata) ? doc.metadata : {};
@@ -7473,6 +7794,7 @@ function renderAppleDoc(doc) {
7473
7794
  const typeLine = `${type ? `\`${type}\`` : ""}${desc ? ` — ${desc}` : ""}`.trim();
7474
7795
  if (typeLine) lines.push(typeLine);
7475
7796
  lines.push(...parameterLines(section$1.parameters, refs));
7797
+ if (body) lines.push("", body);
7476
7798
  break;
7477
7799
  }
7478
7800
  case "restResponses": {
@@ -7508,6 +7830,15 @@ function bodyTypeIdentifier(doc) {
7508
7830
  }
7509
7831
  }
7510
7832
  }
7833
+ async function bodyDocs(doc, fetchDoc) {
7834
+ const bodyType = bodyTypeIdentifier(doc);
7835
+ if (!bodyType) return void 0;
7836
+ try {
7837
+ return renderAppleDoc(await fetchDoc(`${APPLE_DOC_DATA_BASE}/${bodyType.toLowerCase()}.json`));
7838
+ } catch (error) {
7839
+ return `Couldn't fetch the \`${bodyType}\` object page (${describe(error)}) — see ${APPLE_DOCS_BASE}/${bodyType.toLowerCase()}.`;
7840
+ }
7841
+ }
7511
7842
  async function renderAsaOperationDocs(group$1, action, fetchDoc = downloadAppleDoc) {
7512
7843
  const variants = asaVariants(group$1, action);
7513
7844
  if (variants.length === 0) throw new Error(`Unknown "asa ${group$1} ${action}". Run \`superwall asa docs ${group$1}\` for its actions.`);
@@ -7520,14 +7851,7 @@ async function renderAsaOperationDocs(group$1, action, fetchDoc = downloadAppleD
7520
7851
  const url = `${APPLE_DOC_DATA_BASE}/${v.doc}.json`;
7521
7852
  try {
7522
7853
  const doc = await fetchDoc(url);
7523
- lines.push("", renderAppleDoc(doc));
7524
- const bodyType = bodyTypeIdentifier(doc);
7525
- if (bodyType) try {
7526
- const bodyDoc = await fetchDoc(`${APPLE_DOC_DATA_BASE}/${bodyType.toLowerCase()}.json`);
7527
- lines.push("", renderAppleDoc(bodyDoc));
7528
- } catch (error) {
7529
- lines.push("", `Couldn't fetch the \`${bodyType}\` object page (${describe(error)}) — see ${APPLE_DOCS_BASE}/${bodyType.toLowerCase()}.`);
7530
- }
7854
+ lines.push("", renderAppleDoc(doc, await bodyDocs(doc, fetchDoc)));
7531
7855
  } catch (error) {
7532
7856
  lines.push("", `Couldn't fetch Apple's page (${describe(error)}) — read it at ${appleDocUrl(v)}.`);
7533
7857
  }
@@ -7547,7 +7871,7 @@ async function renderDocs(ctx, resource, operation) {
7547
7871
 
7548
7872
  //#endregion
7549
7873
  //#region src/commands/apple-search-ads/api/docs.ts
7550
- const command$40 = defineCommand({
7874
+ const command$41 = defineCommand({
7551
7875
  name: "asa docs",
7552
7876
  summary: "Every endpoint, with Apple's own schema",
7553
7877
  args: {
@@ -7573,11 +7897,11 @@ const command$40 = defineCommand({
7573
7897
 
7574
7898
  //#endregion
7575
7899
  //#region src/commands/apple-search-ads/api/get.ts
7576
- const command$41 = defineCommand({
7900
+ const command$42 = defineCommand({
7577
7901
  name: "asa get",
7578
7902
  summary: "Any GET request to the Apple Search Ads API",
7579
7903
  args: { path: {
7580
- describe: "Apple Search Ads API path, e.g. /campaigns (the /api/v5 prefix is added)",
7904
+ describe: "Apple Search Ads API path, e.g. /campaigns (the /v1 prefix is added)",
7581
7905
  required: true
7582
7906
  } },
7583
7907
  flags: {
@@ -7585,10 +7909,10 @@ const command$41 = defineCommand({
7585
7909
  ...app,
7586
7910
  describe: "Superwall app id or name (if several have Apple Search Ads connected)"
7587
7911
  },
7588
- orgId: {
7912
+ adAccountId: {
7589
7913
  type: "string",
7590
7914
  value: "id",
7591
- describe: "Apple Search Ads org id (X-AP-Context), if the API user spans several"
7915
+ describe: "Apple Ads ad account id (X-AP-Context), if the API user reaches several"
7592
7916
  },
7593
7917
  d: {
7594
7918
  ...data,
@@ -7605,7 +7929,7 @@ const command$41 = defineCommand({
7605
7929
  verb: "get",
7606
7930
  path: args.path,
7607
7931
  data: flags.d,
7608
- orgId: flags.orgId
7932
+ adAccountId: flags.adAccountId
7609
7933
  });
7610
7934
  ctx.output.data(res ?? { ok: true });
7611
7935
  }
@@ -7613,7 +7937,7 @@ const command$41 = defineCommand({
7613
7937
 
7614
7938
  //#endregion
7615
7939
  //#region src/commands/apple-search-ads/keys.ts
7616
- const command$42 = defineCommand({
7940
+ const command$43 = defineCommand({
7617
7941
  name: "asa keys",
7618
7942
  summary: "Which apps have Apple Search Ads connected",
7619
7943
  details: CONNECT_HINT,
@@ -7630,12 +7954,12 @@ const command$42 = defineCommand({
7630
7954
 
7631
7955
  //#endregion
7632
7956
  //#region src/commands/apple-search-ads/api/post.ts
7633
- const command$43 = defineCommand({
7957
+ const command$44 = defineCommand({
7634
7958
  name: "asa post",
7635
7959
  summary: "Any POST request to the Apple Search Ads API",
7636
7960
  details: "Executes an arbitrary Apple Ads POST. It can bulk-delete resources, activate advertising or create financial budget orders; repeating a call may repeat its effects.",
7637
7961
  args: { path: {
7638
- describe: "Apple Search Ads API path, e.g. /campaigns (the /api/v5 prefix is added)",
7962
+ describe: "Apple Search Ads API path, e.g. /campaigns (the /v1 prefix is added)",
7639
7963
  required: true
7640
7964
  } },
7641
7965
  flags: {
@@ -7643,10 +7967,10 @@ const command$43 = defineCommand({
7643
7967
  ...app,
7644
7968
  describe: "Superwall app id or name (if several have Apple Search Ads connected)"
7645
7969
  },
7646
- orgId: {
7970
+ adAccountId: {
7647
7971
  type: "string",
7648
7972
  value: "id",
7649
- describe: "Apple Search Ads org id (X-AP-Context), if the API user spans several"
7973
+ describe: "Apple Ads ad account id (X-AP-Context), if the API user reaches several"
7650
7974
  },
7651
7975
  d: {
7652
7976
  ...data,
@@ -7658,7 +7982,7 @@ const command$43 = defineCommand({
7658
7982
  describe: "Request body as JSON: inline, @file, or @- for stdin; -d fields merge into it"
7659
7983
  }
7660
7984
  },
7661
- examples: [["asa post /campaigns/find --body '{\"conditions\":[]}'", "A raw selector query"]],
7985
+ examples: [["asa post /campaigns/query --body '{\"filters\":[]}'", "A raw query"]],
7662
7986
  auth: "required",
7663
7987
  json: true,
7664
7988
  prompts: false,
@@ -7668,7 +7992,7 @@ const command$43 = defineCommand({
7668
7992
  verb: "post",
7669
7993
  path: args.path,
7670
7994
  data: flags.d,
7671
- orgId: flags.orgId,
7995
+ adAccountId: flags.adAccountId,
7672
7996
  body: flags.body
7673
7997
  });
7674
7998
  ctx.output.data(res ?? { ok: true });
@@ -7677,12 +8001,12 @@ const command$43 = defineCommand({
7677
8001
 
7678
8002
  //#endregion
7679
8003
  //#region src/commands/apple-search-ads/api/put.ts
7680
- const command$44 = defineCommand({
8004
+ const command$45 = defineCommand({
7681
8005
  name: "asa put",
7682
8006
  summary: "Any PUT request to the Apple Search Ads API",
7683
8007
  details: "Executes an arbitrary Apple Ads PUT. It can overwrite bids, targeting, budgets and delivery status.",
7684
8008
  args: { path: {
7685
- describe: "Apple Search Ads API path, e.g. /campaigns (the /api/v5 prefix is added)",
8009
+ describe: "Apple Search Ads API path, e.g. /campaigns (the /v1 prefix is added)",
7686
8010
  required: true
7687
8011
  } },
7688
8012
  flags: {
@@ -7690,10 +8014,10 @@ const command$44 = defineCommand({
7690
8014
  ...app,
7691
8015
  describe: "Superwall app id or name (if several have Apple Search Ads connected)"
7692
8016
  },
7693
- orgId: {
8017
+ adAccountId: {
7694
8018
  type: "string",
7695
8019
  value: "id",
7696
- describe: "Apple Search Ads org id (X-AP-Context), if the API user spans several"
8020
+ describe: "Apple Ads ad account id (X-AP-Context), if the API user reaches several"
7697
8021
  },
7698
8022
  d: {
7699
8023
  ...data,
@@ -7715,7 +8039,7 @@ const command$44 = defineCommand({
7715
8039
  verb: "put",
7716
8040
  path: args.path,
7717
8041
  data: flags.d,
7718
- orgId: flags.orgId,
8042
+ adAccountId: flags.adAccountId,
7719
8043
  body: flags.body
7720
8044
  });
7721
8045
  ctx.output.data(res ?? { ok: true });
@@ -7724,7 +8048,7 @@ const command$44 = defineCommand({
7724
8048
 
7725
8049
  //#endregion
7726
8050
  //#region src/commands/paywalls/build.ts
7727
- const command$45 = defineCommand({
8051
+ const command$46 = defineCommand({
7728
8052
  name: "build",
7729
8053
  summary: "Build your paywalls into the snapshot documents a push would version, without pushing",
7730
8054
  args: { dir: { describe: "Project directory (default: cwd)" } },
@@ -7751,7 +8075,7 @@ const command$45 = defineCommand({
7751
8075
  prompts: true,
7752
8076
  mcp: false,
7753
8077
  async run(ctx, { args, flags }) {
7754
- const { runBuildPipeline } = await import("./build-BWjXurjs.js");
8078
+ const { runBuildPipeline } = await import("./build-CY5FnMNY.js");
7755
8079
  await runBuildPipeline({
7756
8080
  output: ctx.output,
7757
8081
  json: ctx.json
@@ -7766,7 +8090,7 @@ const command$45 = defineCommand({
7766
8090
 
7767
8091
  //#endregion
7768
8092
  //#region src/commands/paywalls/create.ts
7769
- const command$46 = defineCommand({
8093
+ const command$47 = defineCommand({
7770
8094
  name: "create",
7771
8095
  summary: "Set up paywalls in your app - creates a superwall/ directory inside it",
7772
8096
  args: { dir: { describe: "Your app's root (default: cwd) - paywalls land in superwall/ inside it" } },
@@ -7799,20 +8123,26 @@ const command$46 = defineCommand({
7799
8123
  type: "boolean",
7800
8124
  default: true,
7801
8125
  describe: "Connect a Superwall app when possible (--no-connect to skip)"
8126
+ },
8127
+ git: {
8128
+ type: "boolean",
8129
+ default: true,
8130
+ describe: "Create a git repository and commit the scaffold when the app is outside git (--no-git to skip)"
7802
8131
  }
7803
8132
  },
7804
8133
  examples: [
7805
8134
  ["create", "Set up superwall/ in the current app"],
7806
8135
  ["create --example with-rive", "Start from an example"],
7807
8136
  ["create --from 65920", "Rebuild dashboard paywall 65920 as code"],
7808
- ["create --app <app>", "Connect a specific Superwall app"]
8137
+ ["create --app <app>", "Connect a specific Superwall app"],
8138
+ ["create --no-git", "Scaffold without creating a git repository or commit"]
7809
8139
  ],
7810
8140
  auth: "none",
7811
8141
  json: false,
7812
8142
  prompts: true,
7813
8143
  mcp: false,
7814
8144
  async run(ctx, { args, flags }) {
7815
- const { runCreate } = await import("./create-C3uklw-U.js");
8145
+ const { runCreate } = await import("./create-BZL5VH4L.js");
7816
8146
  return runCreate(ctx, {
7817
8147
  dir: args.dir,
7818
8148
  ...flags
@@ -7822,7 +8152,7 @@ const command$46 = defineCommand({
7822
8152
 
7823
8153
  //#endregion
7824
8154
  //#region src/commands/paywalls/dev.ts
7825
- const command$47 = defineCommand({
8155
+ const command$48 = defineCommand({
7826
8156
  name: "dev",
7827
8157
  summary: "Host the studio: browse and preview your paywalls and funnels",
7828
8158
  args: { dir: {
@@ -7855,7 +8185,7 @@ const command$47 = defineCommand({
7855
8185
  prompts: true,
7856
8186
  mcp: false,
7857
8187
  async run(ctx, { args, flags }) {
7858
- const { runStudio } = await import("./server-BEcsQaPu.js");
8188
+ const { runStudio } = await import("./server-CZwSfzKe.js");
7859
8189
  await runStudio({
7860
8190
  dirs: args.dir,
7861
8191
  port: flags.port,
@@ -7868,7 +8198,7 @@ const command$47 = defineCommand({
7868
8198
 
7869
8199
  //#endregion
7870
8200
  //#region src/commands/paywalls/promote.ts
7871
- const command$48 = defineCommand({
8201
+ const command$49 = defineCommand({
7872
8202
  name: "promote",
7873
8203
  summary: "Point production at a pushed version (the latest by default)",
7874
8204
  args: { dir: { describe: "Project directory (default: cwd)" } },
@@ -7895,14 +8225,14 @@ const command$48 = defineCommand({
7895
8225
  prompts: true,
7896
8226
  mcp: false,
7897
8227
  async run(ctx, input) {
7898
- const { runPromote } = await import("./promote-DLtPSvmL.js");
8228
+ const { runPromote } = await import("./promote-QVMLGYlU.js");
7899
8229
  return runPromote(ctx, input);
7900
8230
  }
7901
8231
  });
7902
8232
 
7903
8233
  //#endregion
7904
8234
  //#region src/commands/paywalls/publish.ts
7905
- const command$49 = defineCommand({
8235
+ const command$50 = defineCommand({
7906
8236
  name: "publish",
7907
8237
  summary: "Push and promote in one step - build, version, and ship to production",
7908
8238
  args: { dir: { describe: "Project directory (default: cwd)" } },
@@ -7951,14 +8281,14 @@ const command$49 = defineCommand({
7951
8281
  prompts: true,
7952
8282
  mcp: false,
7953
8283
  async run(ctx, input) {
7954
- const { runPush } = await import("./push-Co5jk6Kr.js");
8284
+ const { runPush } = await import("./push-BIq6R8Ro.js");
7955
8285
  return runPush(ctx, input, true);
7956
8286
  }
7957
8287
  });
7958
8288
 
7959
8289
  //#endregion
7960
8290
  //#region src/commands/paywalls/pull.ts
7961
- const command$50 = defineCommand({
8291
+ const command$51 = defineCommand({
7962
8292
  name: "pull",
7963
8293
  summary: "Bring teammates' published source into this project, merged with your edits",
7964
8294
  args: { dir: { describe: "Project directory, or with --app the folder to create superwall/ in (default: cwd)" } },
@@ -7987,14 +8317,14 @@ const command$50 = defineCommand({
7987
8317
  prompts: true,
7988
8318
  mcp: false,
7989
8319
  async run(ctx, input) {
7990
- const { runPull } = await import("./pull-C1xm2zqG.js");
8320
+ const { runPull } = await import("./pull-h71pL3r_.js");
7991
8321
  return runPull(ctx, input);
7992
8322
  }
7993
8323
  });
7994
8324
 
7995
8325
  //#endregion
7996
8326
  //#region src/commands/paywalls/push.ts
7997
- const command$51 = defineCommand({
8327
+ const command$52 = defineCommand({
7998
8328
  name: "push",
7999
8329
  summary: "Build and push your paywalls as immutable versions (production untouched)",
8000
8330
  args: { dir: { describe: "Project directory (default: cwd)" } },
@@ -8039,7 +8369,7 @@ const command$51 = defineCommand({
8039
8369
  prompts: true,
8040
8370
  mcp: false,
8041
8371
  async run(ctx, input) {
8042
- const { runPush } = await import("./push-Co5jk6Kr.js");
8372
+ const { runPush } = await import("./push-BIq6R8Ro.js");
8043
8373
  return runPush(ctx, input, false);
8044
8374
  }
8045
8375
  });
@@ -8077,7 +8407,7 @@ function scopeParams(op$1) {
8077
8407
  return bound;
8078
8408
  }
8079
8409
  function scopeFields(op$1, spec) {
8080
- const query = (spec?.params ?? []).flatMap((param) => {
8410
+ const query$1 = (spec?.params ?? []).flatMap((param) => {
8081
8411
  const kind = SCOPE_PARAMS[param.name];
8082
8412
  return param.in === "query" && kind && (param.required || kind === "app") ? [{
8083
8413
  location: "query",
@@ -8086,7 +8416,7 @@ function scopeFields(op$1, spec) {
8086
8416
  type: param.type
8087
8417
  }] : [];
8088
8418
  });
8089
- if (op$1.method === "GET" || op$1.method === "DELETE") return query;
8419
+ if (op$1.method === "GET" || op$1.method === "DELETE") return query$1;
8090
8420
  const body = (spec?.body ?? []).flatMap((field$1) => {
8091
8421
  const kind = SCOPE_PARAMS[field$1.name];
8092
8422
  return kind && (field$1.required || op$1.method === "POST") ? [{
@@ -8096,7 +8426,7 @@ function scopeFields(op$1, spec) {
8096
8426
  type: field$1.type
8097
8427
  }] : [];
8098
8428
  });
8099
- return [...query, ...body];
8429
+ return [...query$1, ...body];
8100
8430
  }
8101
8431
  function argLabel(resource, param) {
8102
8432
  if (param === "app_user_id") return "<user>";
@@ -8111,6 +8441,22 @@ function usageOf(resource, op$1) {
8111
8441
  if (resource.appArg) return "<app>";
8112
8442
  return positionalParams(op$1).map((param) => argLabel(resource, param)).join(" ");
8113
8443
  }
8444
+ function resourceCommandFor(owner, endpoint) {
8445
+ for (const resource of [owner, ...owner.nested ?? []]) {
8446
+ const op$1 = resource.operations.find((candidate) => candidate.method === endpoint.method && candidate.path === endpoint.path);
8447
+ if (!op$1) continue;
8448
+ const usage = usageOf(owner, op$1);
8449
+ return [
8450
+ "superwall",
8451
+ ...owner === resource ? [owner.name, op$1.name] : [
8452
+ owner.name,
8453
+ resource.name,
8454
+ op$1.name
8455
+ ],
8456
+ ...usage ? [usage] : []
8457
+ ].join(" ");
8458
+ }
8459
+ }
8114
8460
 
8115
8461
  //#endregion
8116
8462
  //#region src/core/main/help.ts
@@ -8156,7 +8502,7 @@ function resourceHelp(resource) {
8156
8502
  })),
8157
8503
  {
8158
8504
  title: "Related",
8159
- lines: table((resource.related ?? []).map(([command$82, text]) => [`superwall ${command$82}`, pc.dim(text)]), ([left]) => left.length)
8505
+ lines: table((resource.related ?? []).map(([command$83, text]) => [`superwall ${command$83}`, pc.dim(text)]), ([left]) => left.length)
8160
8506
  },
8161
8507
  {
8162
8508
  title: "Examples",
@@ -8395,7 +8741,7 @@ async function create(context, api, resource, rawValue, value2, flags) {
8395
8741
  if (resource === "apps") return createApp(context, api, value$1, flags.fields);
8396
8742
  if (!value$1) throw new Error(resource === "campaigns" ? "Usage: superwall campaigns create --description \"<description>\" --placement <placement>" : `Usage: superwall ${resource} create --identifier <identifier>`);
8397
8743
  if (resource === "campaigns" && !value2) throw new Error("Usage: superwall campaigns create --description \"<description>\" --placement <placement> (campaigns need at least one placement)");
8398
- const scope = await pickScope(context, api, isAppScoped(resource) || resource === "products" && context.target.app !== void 0);
8744
+ const scope = await pickScope(context, api, isAppScoped(resource) || resource === "products" && context.target.app !== void 0, { customStores: resource === "products" });
8399
8745
  const grants = resource === "products" ? await resolveProductEntitlements(context, api, scope, entitlementValues(flags.fields)) : void 0;
8400
8746
  if (dryRun$1) {
8401
8747
  const { projectCount: _projects, appCount: _apps,...where } = scope;
@@ -8434,7 +8780,7 @@ async function createApp(context, api, nameArg, fields) {
8434
8780
  let name = nameArg;
8435
8781
  let platform = textOf(fields.platform);
8436
8782
  if (interactive && (!name || !platform)) {
8437
- const { scanProject } = await import("./scan-D86kLtM7.js");
8783
+ const { scanProject } = await import("./scan-B36wkZmI.js");
8438
8784
  const detected = (await scanProject(context.installDir).catch(() => null))?.apps[0];
8439
8785
  if (detected && !name && !platform) {
8440
8786
  ui.info(`Detected \`${detected.framework.name}\`` + (detected.details ? ` · \`${detected.details}\`` : ""));
@@ -8516,8 +8862,11 @@ function createOne(api, resource, scope, value$1, value2, fields, grants) {
8516
8862
  case "entitlements": return createEntitlement(api, scope, value$1, scope.boundApplicationId);
8517
8863
  case "products": {
8518
8864
  const applicationId = grants?.app ? String(grants.app.id) : scope.applicationId;
8865
+ const options = productOptions(fields);
8866
+ const store = options.store ?? (scope.appPlatform === "custom" ? "custom" : void 0);
8519
8867
  return createProduct(api, scope, value$1, {
8520
- ...productOptions(fields),
8868
+ ...options,
8869
+ ...store ? { store } : {},
8521
8870
  ...applicationId ? { applicationId } : {},
8522
8871
  ...grants?.ids.length ? { entitlements: grants.ids } : {}
8523
8872
  });
@@ -8526,13 +8875,47 @@ function createOne(api, resource, scope, value$1, value2, fields, grants) {
8526
8875
  default: throw new Error(`create is not supported for ${resource} yet.`);
8527
8876
  }
8528
8877
  }
8878
+ /**
8879
+ * The API takes a price as a whole number of the currency's smallest unit; `--price` is in major
8880
+ * units, so 9.99 USD is 999 and 1200 JPY (no minor unit) is 1200.
8881
+ */
8882
+ function minorUnits(price, currency) {
8883
+ const major = Number(price);
8884
+ if (price.trim() === "" || !Number.isFinite(major) || major < 0) throw new Error(`--price is an amount in ${currency}, such as 9.99, not "${price}".`);
8885
+ let digits;
8886
+ try {
8887
+ digits = new Intl.NumberFormat("en", {
8888
+ style: "currency",
8889
+ currency
8890
+ }).resolvedOptions().maximumFractionDigits ?? 2;
8891
+ } catch {
8892
+ throw new Error(`--currency is an ISO 4217 code, such as USD, not "${currency}".`);
8893
+ }
8894
+ const amount = major * 10 ** digits;
8895
+ const whole = Math.round(amount);
8896
+ if (Math.abs(amount - whole) > 1e-6) throw new Error(`--price ${price} has more decimals than ${currency} allows (${digits}).`);
8897
+ return whole;
8898
+ }
8899
+ const PRODUCT_STORES = [
8900
+ "app_store",
8901
+ "play_store",
8902
+ "custom"
8903
+ ];
8529
8904
  function productOptions(fields) {
8530
8905
  const options = {};
8531
8906
  if (fields.name) options.name = String(fields.name);
8532
- if (fields.price !== void 0) options.price = {
8533
- amount: Math.round(Number(fields.price) * 100),
8534
- currency: String(fields.currency ?? "USD").toUpperCase()
8535
- };
8907
+ if (fields.store !== void 0) {
8908
+ const store = String(fields.store);
8909
+ if (!PRODUCT_STORES.includes(store)) throw new Error(`--store is one of ${PRODUCT_STORES.join(", ")}, not "${store}".`);
8910
+ options.store = store;
8911
+ }
8912
+ if (fields.price !== void 0) {
8913
+ const currency = String(fields.currency ?? "USD").toUpperCase();
8914
+ options.price = {
8915
+ amount: minorUnits(String(fields.price), currency),
8916
+ currency
8917
+ };
8918
+ }
8536
8919
  if (fields.period) options.subscription = {
8537
8920
  period: String(fields.period),
8538
8921
  period_count: fields.periodCount !== void 0 ? Number(fields.periodCount) : 1,
@@ -8744,7 +9127,7 @@ async function runResource(ctx, resource, action, value$1, value2, flags) {
8744
9127
  if (action === "create") return create(ctx, ctx.api, resource, value$1, value2, flags);
8745
9128
  if (action === "use" && resource === "apps") return useApp(ctx, ctx.api, value$1);
8746
9129
  if (action === "storekit" && resource === "products") {
8747
- const { writeStoreKit } = await import("./storekit-BWZf-fNE.js");
9130
+ const { writeStoreKit } = await import("./storekit-ELVCMF0X.js");
8748
9131
  return writeStoreKit(ctx, ctx.api, flags.fields.out);
8749
9132
  }
8750
9133
  throw new Error(`Unknown action "${action}" for ${resource}.`);
@@ -8758,22 +9141,22 @@ async function runOperation(ctx, owner, resource, op$1, args, flags) {
8758
9141
  }
8759
9142
  const toFlag = (field$1) => `--${field$1.replace(/_/g, "-")}`;
8760
9143
  async function callOperation(context, owner, resource, op$1, ids, flags, merged = {}) {
8761
- const command$82 = `superwall ${owner === resource ? "" : `${owner.name} `}${resource.name} ${op$1.name}`;
9144
+ const command$83 = `superwall ${owner === resource ? "" : `${owner.name} `}${resource.name} ${op$1.name}`;
8762
9145
  const { method, path: template } = op$1;
8763
- if (!method || !template) throw new Error(`${command$82} has no API endpoint.`);
9146
+ if (!method || !template) throw new Error(`${command$83} has no API endpoint.`);
8764
9147
  const spec = await apiCall(context, "Loading the API reference", () => findSpec(op$1));
8765
9148
  const args = [...ids];
8766
9149
  const ctx = owner.appArg && args[0] && !context.target.app ? withApp(context, args.shift()) : context;
8767
9150
  const positional = positionalParams(op$1);
8768
- if (args.length < positional.length) throw new Error(`Usage: ${command$82} ${usageOf(owner, op$1)}\nRun \`${command$82} --help\` for its flags.`);
8769
- if (args.length > positional.length) throw new Error(`${command$82} takes ${positional.length || "no"} argument${positional.length === 1 ? "" : "s"}; got "${args.slice(positional.length).join(" ")}".`);
9151
+ if (args.length < positional.length) throw new Error(`Usage: ${command$83} ${usageOf(owner, op$1)}\nRun \`${command$83} --help\` for its flags.`);
9152
+ if (args.length > positional.length) throw new Error(`${command$83} takes ${positional.length || "no"} argument${positional.length === 1 ? "" : "s"}; got "${args.slice(positional.length).join(" ")}".`);
8770
9153
  const pathValues = /* @__PURE__ */ new Map();
8771
- const query = {};
9154
+ const query$1 = {};
8772
9155
  const queryNames = new Set(spec?.params.filter((param) => param.in === "query").map((param) => param.name));
8773
9156
  for (const [index, param] of positional.entries()) {
8774
9157
  const value$1 = args[index];
8775
9158
  if (value$1 === void 0) continue;
8776
- if (queryNames.has(param)) query[param] = value$1;
9159
+ if (queryNames.has(param)) query$1[param] = value$1;
8777
9160
  else pathValues.set(param, value$1);
8778
9161
  }
8779
9162
  const body = {};
@@ -8783,25 +9166,25 @@ async function callOperation(context, owner, resource, op$1, ids, flags, merged
8783
9166
  const field$1 = fieldName(flag$1);
8784
9167
  const queryParam = spec?.params.find((param) => param.in === "query" && param.name === field$1);
8785
9168
  const bodyField = bodyFields.get(field$1);
8786
- if (queryParam) query[field$1] = coerce(raw, queryParam.type);
9169
+ if (queryParam) query$1[field$1] = coerce(raw, queryParam.type);
8787
9170
  else if (bodyField) body[field$1] = coerce(raw, bodyField.type);
8788
- else if (!spec) (sendsBody ? body : query)[field$1] = raw;
8789
- else throw new Error(`${command$82} has no ${toFlag(field$1)}. \`${command$82} --help\` lists what it takes.`);
9171
+ else if (!spec) (sendsBody ? body : query$1)[field$1] = raw;
9172
+ else throw new Error(`${command$83} has no ${toFlag(field$1)}. \`${command$83} --help\` lists what it takes.`);
8790
9173
  }
8791
- Object.assign(sendsBody ? body : query, parseParams(flags.data));
8792
- await fillScope(ctx, op$1, spec, pathValues, query, body);
9174
+ Object.assign(sendsBody ? body : query$1, parseParams(flags.data));
9175
+ await fillScope(ctx, op$1, spec, pathValues, query$1, body);
8793
9176
  const missing$1 = (spec?.params ?? []).filter((param) => {
8794
- return param.in === "query" && param.required && query[param.name] === void 0;
9177
+ return param.in === "query" && param.required && query$1[param.name] === void 0;
8795
9178
  });
8796
9179
  if (missing$1.length > 0) {
8797
9180
  const needs = missing$1.map((param) => `${toFlag(param.name)} <${param.type.replace(/"/g, "").replace(/ \| /g, "|")}>`);
8798
- throw new Error(`${command$82} needs ${needs.join(" and ")}.`);
9181
+ throw new Error(`${command$83} needs ${needs.join(" and ")}.`);
8799
9182
  }
8800
9183
  const url = withQuery(template.replace(/\{([^}]+)\}/g, (_, param) => {
8801
9184
  const value$1 = pathValues.get(param);
8802
- if (value$1 === void 0) throw new Error(`${command$82} needs ${param}.`);
9185
+ if (value$1 === void 0) throw new Error(`${command$83} needs ${param}.`);
8803
9186
  return encodeURIComponent(value$1);
8804
- }), query);
9187
+ }), query$1);
8805
9188
  if (ctx.dryRun) return renderValue(ctx, {
8806
9189
  method,
8807
9190
  path: url,
@@ -8828,14 +9211,14 @@ async function callOperation(context, owner, resource, op$1, ids, flags, merged
8828
9211
  ...merged
8829
9212
  }, done);
8830
9213
  }
8831
- async function fillScope(ctx, op$1, spec, pathValues, query, body) {
9214
+ async function fillScope(ctx, op$1, spec, pathValues, query$1, body) {
8832
9215
  const wanted = /* @__PURE__ */ new Map();
8833
9216
  for (const [param, kind] of scopeParams(op$1)) if (!pathValues.has(param)) wanted.set(`path:${param}`, {
8834
9217
  kind,
8835
9218
  assign: (v) => pathValues.set(param, v)
8836
9219
  });
8837
9220
  for (const field$1 of scopeFields(op$1, spec)) {
8838
- const target = field$1.location === "query" ? query : body;
9221
+ const target = field$1.location === "query" ? query$1 : body;
8839
9222
  if (target[field$1.name] !== void 0) continue;
8840
9223
  const typed = (value$1) => field$1.location === "query" ? value$1 : coerce(value$1, field$1.type);
8841
9224
  wanted.set(`${field$1.location}:${field$1.name}`, {
@@ -8911,7 +9294,7 @@ async function dispatch(ctx, owner, words, flags) {
8911
9294
  const nested = rest[0] ? findNested(owner, rest[0]) : void 0;
8912
9295
  if (nested) rest = rest.slice(1);
8913
9296
  const resource = nested ?? owner;
8914
- const command$82 = nested ? `${owner.name} ${nested.name}` : owner.name;
9297
+ const command$83 = nested ? `${owner.name} ${nested.name}` : owner.name;
8915
9298
  if (rest[0] && /^(\d+|https?:\/\/.*)$/.test(rest[0]) && findOperation(resource, "get")) rest = ["get", ...rest];
8916
9299
  const [opName, ...args] = rest;
8917
9300
  if (!opName) {
@@ -8923,7 +9306,7 @@ async function dispatch(ctx, owner, words, flags) {
8923
9306
  if (!op$1) {
8924
9307
  const known = resource.operations.map((candidate) => candidate.name);
8925
9308
  const nestedNames = nested ? [] : (owner.nested ?? []).map((candidate) => candidate.name);
8926
- throw new UsageError(`${command$82} has no "${opName}". It takes: ${[...known, ...nestedNames].join(", ")}.\nRun superwall ${command$82} --help for what each does.`, command$82);
9309
+ throw new UsageError(`${command$83} has no "${opName}". It takes: ${[...known, ...nestedNames].join(", ")}.\nRun superwall ${command$83} --help for what each does.`, command$83);
8927
9310
  }
8928
9311
  await runOperation(ctx, owner, resource, op$1, args, flags);
8929
9312
  }
@@ -9111,13 +9494,14 @@ function defineResource(resource) {
9111
9494
  operations: () => [...resource.operations.map((operation) => operation.name), ...(resource.nested ?? []).map((nested) => `${nested.name} …`)],
9112
9495
  help: async (words) => renderResourceHelp(resource, words),
9113
9496
  tools: () => listResourceTools(resource, FLAGS),
9497
+ commandFor: (endpoint) => resourceCommandFor(resource, endpoint),
9114
9498
  run: (ctx, { words, flags }) => dispatch(ctx, resource, words, readResourceFlags(flags))
9115
9499
  });
9116
9500
  }
9117
9501
 
9118
9502
  //#endregion
9119
9503
  //#region src/commands/main/annotations.ts
9120
- const command$52 = defineResource({
9504
+ const command$53 = defineResource({
9121
9505
  name: "annotations",
9122
9506
  summary: "Releases, campaigns and incidents marked on an app's charts",
9123
9507
  operations: [
@@ -9167,7 +9551,7 @@ const command$52 = defineResource({
9167
9551
 
9168
9552
  //#endregion
9169
9553
  //#region src/commands/main/apps.ts
9170
- const command$53 = defineResource({
9554
+ const command$54 = defineResource({
9171
9555
  name: "apps",
9172
9556
  summary: "Every app you can open",
9173
9557
  appArg: true,
@@ -9420,7 +9804,7 @@ function renderAccountTree(tree) {
9420
9804
 
9421
9805
  //#endregion
9422
9806
  //#region src/commands/main/bootstrap.ts
9423
- const command$54 = defineCommand({
9807
+ const command$55 = defineCommand({
9424
9808
  name: "bootstrap",
9425
9809
  summary: "Everything at once: projects, apps, campaigns, products",
9426
9810
  details: "The complete account tree: organizations, projects, apps, campaigns and their placements,\npaywalls, products and entitlements.",
@@ -9453,7 +9837,7 @@ const command$54 = defineCommand({
9453
9837
 
9454
9838
  //#endregion
9455
9839
  //#region src/commands/main/campaigns.ts
9456
- const command$55 = defineResource({
9840
+ const command$56 = defineResource({
9457
9841
  name: "campaigns",
9458
9842
  summary: "Who sees which paywall, and when",
9459
9843
  operations: [
@@ -9678,7 +10062,7 @@ const command$55 = defineResource({
9678
10062
 
9679
10063
  //#endregion
9680
10064
  //#region src/commands/main/entitlements.ts
9681
- const command$56 = defineResource({
10065
+ const command$57 = defineResource({
9682
10066
  name: "entitlements",
9683
10067
  summary: "What a purchase unlocks",
9684
10068
  operations: [
@@ -9756,7 +10140,7 @@ const command$56 = defineResource({
9756
10140
 
9757
10141
  //#endregion
9758
10142
  //#region src/commands/main/events.ts
9759
- const command$57 = defineResource({
10143
+ const command$58 = defineResource({
9760
10144
  name: "events",
9761
10145
  summary: "Events sent to your webhooks",
9762
10146
  operations: [
@@ -9797,7 +10181,7 @@ const command$57 = defineResource({
9797
10181
 
9798
10182
  //#endregion
9799
10183
  //#region src/commands/main/paywalls.ts
9800
- const command$58 = defineResource({
10184
+ const command$59 = defineResource({
9801
10185
  name: "paywalls",
9802
10186
  summary: "Paywalls in the dashboard",
9803
10187
  operations: [
@@ -9867,7 +10251,7 @@ const command$58 = defineResource({
9867
10251
 
9868
10252
  //#endregion
9869
10253
  //#region src/commands/main/products.ts
9870
- const command$59 = defineResource({
10254
+ const command$60 = defineResource({
9871
10255
  name: "products",
9872
10256
  summary: "Products and their store prices",
9873
10257
  operations: [
@@ -9894,7 +10278,8 @@ const command$59 = defineResource({
9894
10278
  flags: [
9895
10279
  ["--identifier <id>", "The store product ID"],
9896
10280
  ["--name <name>", "Display name"],
9897
- ["--price <amount>", "Price in major units, e.g. 9.99"],
10281
+ ["--store <store>", "app_store | play_store | custom; custom without --app uses the project's default custom store"],
10282
+ ["--price <amount>", "Price in the currency's main unit, e.g. 9.99 (sent to the API as 999 cents)"],
9898
10283
  ["--currency <code>", "ISO currency, default USD"],
9899
10284
  ["--period <p>", "day | week | month | year"],
9900
10285
  ["--period-count <n>", "Periods per cycle, default 1"],
@@ -9937,13 +10322,14 @@ const command$59 = defineResource({
9937
10322
  examples: [
9938
10323
  ["products list --app <app>", "Products of an app's project"],
9939
10324
  ["products create --identifier <id> --price 9.99 --period month", "A monthly subscription"],
9940
- ["products create --identifier <id> --price 9.99 --period month --entitlement pro", "One that grants pro"]
10325
+ ["products create --identifier <id> --price 9.99 --period month --entitlement pro", "One that grants pro"],
10326
+ ["products create --identifier <id> --app <custom store> --price 9.99 --period month", "One in a custom store"]
9941
10327
  ]
9942
10328
  });
9943
10329
 
9944
10330
  //#endregion
9945
10331
  //#region src/commands/main/users.ts
9946
- const command$60 = defineResource({
10332
+ const command$61 = defineResource({
9947
10333
  name: "users",
9948
10334
  summary: "Your app's users: subscriptions, entitlements, attributes",
9949
10335
  operations: [
@@ -10014,7 +10400,7 @@ const command$60 = defineResource({
10014
10400
 
10015
10401
  //#endregion
10016
10402
  //#region src/commands/main/webhooks.ts
10017
- const command$61 = defineResource({
10403
+ const command$62 = defineResource({
10018
10404
  name: "webhooks",
10019
10405
  summary: "Endpoints that receive your events",
10020
10406
  operations: [
@@ -10088,7 +10474,7 @@ Overwrites destination, filters, headers and disabled state; can stop or redirec
10088
10474
 
10089
10475
  //#endregion
10090
10476
  //#region src/commands/support/doctor.ts
10091
- const command$62 = defineCommand({
10477
+ const command$63 = defineCommand({
10092
10478
  name: "doctor",
10093
10479
  summary: "Check the health of your Superwall integration",
10094
10480
  flags: { installDir },
@@ -10098,7 +10484,7 @@ const command$62 = defineCommand({
10098
10484
  prompts: true,
10099
10485
  mcp: false,
10100
10486
  async run(ctx) {
10101
- const { runDoctor } = await import("./doctor-D2Q1EZe8.js");
10487
+ const { runDoctor } = await import("./doctor-C9FR0qw3.js");
10102
10488
  return runDoctor(ctx);
10103
10489
  }
10104
10490
  });
@@ -10342,7 +10728,7 @@ async function runFeedback(ctx, { args, flags }) {
10342
10728
 
10343
10729
  //#endregion
10344
10730
  //#region src/commands/support/feedback.ts
10345
- const command$63 = defineCommand({
10731
+ const command$64 = defineCommand({
10346
10732
  name: "feedback",
10347
10733
  summary: "Report a bug or send feedback to the Superwall team",
10348
10734
  details: `Goes straight to the Superwall team, who read every report. Send one yourself, without asking first (Superwall's terms cover it), when you confirm a Superwall bug, a doc that is wrong or missing, or a capability the user needed that Superwall lacks; then tell the user in one line. Confirm it first: reproduce the bug, check the doc against what happens.
@@ -10414,7 +10800,7 @@ Sending cannot be undone; repeating the call sends a duplicate report.`,
10414
10800
 
10415
10801
  //#endregion
10416
10802
  //#region src/commands/support/skills.ts
10417
- const command$64 = defineCommand({
10803
+ const command$65 = defineCommand({
10418
10804
  name: "skills",
10419
10805
  summary: "Install or update the Superwall agent skills for your coding agents",
10420
10806
  flags: {
@@ -10443,14 +10829,14 @@ const command$64 = defineCommand({
10443
10829
  prompts: true,
10444
10830
  mcp: false,
10445
10831
  async run(ctx, input) {
10446
- const { runSkills } = await import("./skills-CdKwaTRS.js");
10832
+ const { runSkills } = await import("./skills-SnxFa2in.js");
10447
10833
  return runSkills(ctx, input);
10448
10834
  }
10449
10835
  });
10450
10836
 
10451
10837
  //#endregion
10452
10838
  //#region src/commands/support/upgrade.ts
10453
- const command$65 = defineCommand({
10839
+ const command$66 = defineCommand({
10454
10840
  name: "upgrade",
10455
10841
  summary: "Update the CLI and its agent skills to the latest version",
10456
10842
  examples: [["upgrade", "Install the latest version globally with npm, then its skills"]],
@@ -10459,14 +10845,14 @@ const command$65 = defineCommand({
10459
10845
  prompts: true,
10460
10846
  mcp: false,
10461
10847
  async run(ctx) {
10462
- const { runUpgrade } = await import("./upgrade-CAHyrWUL.js");
10848
+ const { runUpgrade } = await import("./upgrade-DVsonzDF.js");
10463
10849
  return runUpgrade(ctx, AUTO_UPDATE_TARGET());
10464
10850
  }
10465
10851
  });
10466
10852
 
10467
10853
  //#endregion
10468
10854
  //#region src/commands/artifacts/approve.ts
10469
- const command$66 = defineCommand({
10855
+ const command$67 = defineCommand({
10470
10856
  name: "artifacts approve",
10471
10857
  summary: "Review what a version can do and make it live",
10472
10858
  details: "Admins only. Shows the version's manifest and how it differs from the live version, then asks. Without a terminal it needs --yes, and --accept-changes too when what the artifact can do changes.",
@@ -10499,7 +10885,7 @@ const command$66 = defineCommand({
10499
10885
  mcp: false,
10500
10886
  channel: "next",
10501
10887
  async run(ctx, { args, flags }) {
10502
- const { runArtifactApprove } = await import("./approve-D2UgqaRx.js");
10888
+ const { runArtifactApprove } = await import("./approve-aPc5RoXB.js");
10503
10889
  await runArtifactApprove(ctx, {
10504
10890
  version: args.version,
10505
10891
  ...flags
@@ -10509,7 +10895,7 @@ const command$66 = defineCommand({
10509
10895
 
10510
10896
  //#endregion
10511
10897
  //#region src/commands/artifacts/create.ts
10512
- const command$67 = defineCommand({
10898
+ const command$68 = defineCommand({
10513
10899
  name: "artifacts create",
10514
10900
  summary: "Start an artifact: a mini-app that adds to the Superwall dashboard",
10515
10901
  args: { dir: { describe: "Where to put it (default: my-artifact)" } },
@@ -10525,7 +10911,7 @@ const command$67 = defineCommand({
10525
10911
  mcp: false,
10526
10912
  channel: "next",
10527
10913
  async run(ctx, { args, flags }) {
10528
- const { runArtifactCreate } = await import("./starter-0OdVPH4l.js");
10914
+ const { runArtifactCreate } = await import("./starter-BlJ_InZJ.js");
10529
10915
  await runArtifactCreate(ctx, {
10530
10916
  dir: args.dir,
10531
10917
  install: flags.install
@@ -10535,7 +10921,7 @@ const command$67 = defineCommand({
10535
10921
 
10536
10922
  //#endregion
10537
10923
  //#region src/commands/artifacts/dev.ts
10538
- const command$68 = defineCommand({
10924
+ const command$69 = defineCommand({
10539
10925
  name: "artifacts dev",
10540
10926
  summary: "Run an artifact on localhost against your real data, read-only",
10541
10927
  details: "Bundles the artifact the way the builder does, including its client.entry, and runs it in workerd. A local page plays the dashboard: it mounts pages and widgets, sends them context and theme over the bridge, and runs metrics and readouts. API calls go out with a short-lived, read-only token as you, limited to one organization and to the routes an artifact can read. It reads everything you can read in that organization, so only run code you trust. A staff account reaches only that organization too. Writes, outside hosts and raw sockets are refused. Every change rebuilds it.",
@@ -10609,7 +10995,7 @@ const command$68 = defineCommand({
10609
10995
  mcp: false,
10610
10996
  channel: "next",
10611
10997
  async run(ctx, { args, flags }) {
10612
- const { runArtifactDev } = await import("./run-r3foWfhV.js");
10998
+ const { runArtifactDev } = await import("./run-B-YvxfRc.js");
10613
10999
  await runArtifactDev(ctx, {
10614
11000
  dir: args.dir,
10615
11001
  ...flags
@@ -10619,7 +11005,7 @@ const command$68 = defineCommand({
10619
11005
 
10620
11006
  //#endregion
10621
11007
  //#region src/commands/artifacts/install.ts
10622
- const command$69 = defineCommand({
11008
+ const command$70 = defineCommand({
10623
11009
  name: "artifacts install",
10624
11010
  summary: "Choose where an entrypoint shows",
10625
11011
  details: "Admins only. Installs an entrypoint of the live version for the whole organization, or one app with --app. An app's row overrides the organization's there. Without an entrypoint, lists what's installed.",
@@ -10665,7 +11051,7 @@ const command$69 = defineCommand({
10665
11051
  mcp: false,
10666
11052
  channel: "next",
10667
11053
  async run(ctx, { args, flags }) {
10668
- const { runArtifactInstall } = await import("./install-dXZZ79Oe.js");
11054
+ const { runArtifactInstall } = await import("./install-C5d82gZF.js");
10669
11055
  await runArtifactInstall(ctx, {
10670
11056
  entrypoint: args.entrypoint,
10671
11057
  ...flags
@@ -10675,7 +11061,7 @@ const command$69 = defineCommand({
10675
11061
 
10676
11062
  //#endregion
10677
11063
  //#region src/commands/artifacts/list.ts
10678
- const command$70 = defineCommand({
11064
+ const command$71 = defineCommand({
10679
11065
  name: "artifacts list",
10680
11066
  summary: "List an organization's artifacts",
10681
11067
  flags: {
@@ -10693,14 +11079,14 @@ const command$70 = defineCommand({
10693
11079
  mcp: false,
10694
11080
  channel: "next",
10695
11081
  async run(ctx, { flags }) {
10696
- const { runArtifactList } = await import("./install-dXZZ79Oe.js");
11082
+ const { runArtifactList } = await import("./install-C5d82gZF.js");
10697
11083
  await runArtifactList(ctx, flags);
10698
11084
  }
10699
11085
  });
10700
11086
 
10701
11087
  //#endregion
10702
11088
  //#region src/commands/artifacts/logs.ts
10703
- const command$71 = defineCommand({
11089
+ const command$72 = defineCommand({
10704
11090
  name: "artifacts logs",
10705
11091
  summary: "Show a version's build log",
10706
11092
  details: "The last 128 KiB, once the build has finished. The latest version by default.",
@@ -10721,7 +11107,7 @@ const command$71 = defineCommand({
10721
11107
  mcp: false,
10722
11108
  channel: "next",
10723
11109
  async run(ctx, { args, flags }) {
10724
- const { runArtifactLogs } = await import("./status-Dsc7d3z2.js");
11110
+ const { runArtifactLogs } = await import("./status-DxsIw9zq.js");
10725
11111
  await runArtifactLogs(ctx, {
10726
11112
  version: args.version,
10727
11113
  ...flags
@@ -10731,7 +11117,7 @@ const command$71 = defineCommand({
10731
11117
 
10732
11118
  //#endregion
10733
11119
  //#region src/commands/artifacts/open.ts
10734
- const command$72 = defineCommand({
11120
+ const command$73 = defineCommand({
10735
11121
  name: "artifacts open",
10736
11122
  summary: "Open an artifact in the dashboard",
10737
11123
  args: { entrypoint: { describe: "An entrypoint to open inside an app, with --app" } },
@@ -10760,7 +11146,7 @@ const command$72 = defineCommand({
10760
11146
  mcp: false,
10761
11147
  channel: "next",
10762
11148
  async run(ctx, { args, flags }) {
10763
- const { runArtifactOpen } = await import("./install-dXZZ79Oe.js");
11149
+ const { runArtifactOpen } = await import("./install-C5d82gZF.js");
10764
11150
  await runArtifactOpen(ctx, {
10765
11151
  entrypoint: args.entrypoint,
10766
11152
  ...flags
@@ -10770,7 +11156,7 @@ const command$72 = defineCommand({
10770
11156
 
10771
11157
  //#endregion
10772
11158
  //#region src/commands/artifacts/pull.ts
10773
- const command$73 = defineCommand({
11159
+ const command$74 = defineCommand({
10774
11160
  name: "artifacts pull",
10775
11161
  summary: "Bring teammates' pushes into this project, merged with your edits",
10776
11162
  args: { dir: { describe: "The artifact project, or with --artifact an empty folder to fill (default: cwd)" } },
@@ -10797,7 +11183,7 @@ const command$73 = defineCommand({
10797
11183
  mcp: false,
10798
11184
  channel: "next",
10799
11185
  async run(ctx, { args, flags }) {
10800
- const { runArtifactPull } = await import("./pull-D-YuT3e0.js");
11186
+ const { runArtifactPull } = await import("./pull-CrdsfsAl.js");
10801
11187
  await runArtifactPull(ctx, {
10802
11188
  dir: args.dir,
10803
11189
  ...flags
@@ -10807,7 +11193,7 @@ const command$73 = defineCommand({
10807
11193
 
10808
11194
  //#endregion
10809
11195
  //#region src/commands/artifacts/push.ts
10810
- const command$74 = defineCommand({
11196
+ const command$75 = defineCommand({
10811
11197
  name: "artifacts push",
10812
11198
  summary: "Push this artifact's source and build it",
10813
11199
  details: "The first push creates the artifact from the manifest's name and records its id in superwall.artifact.json. Each push makes a version from the commit. Only you can see it until an admin approves it. When the source repo has commits this project doesn't, the push merges them, and your own copy runs them with your reads, so it asks first. Without a terminal it stops unless you pass --accept-merged-commits.",
@@ -10843,7 +11229,7 @@ const command$74 = defineCommand({
10843
11229
  mcp: false,
10844
11230
  channel: "next",
10845
11231
  async run(ctx, { args, flags }) {
10846
- const { runArtifactPush } = await import("./push-B42D8fKf.js");
11232
+ const { runArtifactPush } = await import("./push-D6pJM_vv.js");
10847
11233
  await runArtifactPush(ctx, {
10848
11234
  dir: args.dir,
10849
11235
  ...flags
@@ -10853,7 +11239,7 @@ const command$74 = defineCommand({
10853
11239
 
10854
11240
  //#endregion
10855
11241
  //#region src/commands/artifacts/share.ts
10856
- const command$75 = defineCommand({
11242
+ const command$76 = defineCommand({
10857
11243
  name: "artifacts share",
10858
11244
  summary: "Ask an admin to review a version",
10859
11245
  details: "The latest built version by default. Until an organization owner or admin approves it, only its author can see it. Nobody is told automatically, so it says who to ask.",
@@ -10874,7 +11260,7 @@ const command$75 = defineCommand({
10874
11260
  mcp: false,
10875
11261
  channel: "next",
10876
11262
  async run(ctx, { args, flags }) {
10877
- const { runArtifactShare } = await import("./status-Dsc7d3z2.js");
11263
+ const { runArtifactShare } = await import("./status-DxsIw9zq.js");
10878
11264
  await runArtifactShare(ctx, {
10879
11265
  version: args.version,
10880
11266
  ...flags
@@ -10884,7 +11270,7 @@ const command$75 = defineCommand({
10884
11270
 
10885
11271
  //#endregion
10886
11272
  //#region src/commands/artifacts/status.ts
10887
- const command$76 = defineCommand({
11273
+ const command$77 = defineCommand({
10888
11274
  name: "artifacts status",
10889
11275
  summary: "Show an artifact's state and its latest versions",
10890
11276
  flags: {
@@ -10907,14 +11293,14 @@ const command$76 = defineCommand({
10907
11293
  mcp: false,
10908
11294
  channel: "next",
10909
11295
  async run(ctx, { flags }) {
10910
- const { runArtifactStatus } = await import("./status-Dsc7d3z2.js");
11296
+ const { runArtifactStatus } = await import("./status-DxsIw9zq.js");
10911
11297
  await runArtifactStatus(ctx, flags);
10912
11298
  }
10913
11299
  });
10914
11300
 
10915
11301
  //#endregion
10916
11302
  //#region src/commands/artifacts/try.ts
10917
- const command$77 = defineCommand({
11303
+ const command$78 = defineCommand({
10918
11304
  name: "artifacts try",
10919
11305
  summary: "Upload a draft and run an entrypoint on the real runtime",
10920
11306
  details: "Nothing is saved: the draft runs as you, read-only and with no outside hosts, and only you can reach it for a day. A metric prints its series. A page, panel, tab, card or action opens in the dashboard. Readouts run with artifacts dev until the runtime takes them.",
@@ -11009,7 +11395,7 @@ const command$77 = defineCommand({
11009
11395
  mcp: false,
11010
11396
  channel: "next",
11011
11397
  async run(ctx, { args, flags }) {
11012
- const { runArtifactTry } = await import("./try-B8FYkTvQ.js");
11398
+ const { runArtifactTry } = await import("./try-C3HW3hPZ.js");
11013
11399
  await runArtifactTry(ctx, {
11014
11400
  entrypoint: args.entrypoint,
11015
11401
  ...flags
@@ -11019,7 +11405,7 @@ const command$77 = defineCommand({
11019
11405
 
11020
11406
  //#endregion
11021
11407
  //#region src/commands/artifacts/update.ts
11022
- const command$78 = defineCommand({
11408
+ const command$79 = defineCommand({
11023
11409
  name: "artifacts update",
11024
11410
  summary: "Refresh an artifact's vendored SDK from the public repo",
11025
11411
  args: { dir: { describe: "The artifact (default: cwd)" } },
@@ -11041,7 +11427,7 @@ const command$78 = defineCommand({
11041
11427
  mcp: false,
11042
11428
  channel: "next",
11043
11429
  async run(ctx, { args, flags }) {
11044
- const { runArtifactUpdate } = await import("./starter-0OdVPH4l.js");
11430
+ const { runArtifactUpdate } = await import("./starter-BlJ_InZJ.js");
11045
11431
  await runArtifactUpdate(ctx, {
11046
11432
  dir: args.dir,
11047
11433
  install: flags.install,
@@ -11052,7 +11438,7 @@ const command$78 = defineCommand({
11052
11438
 
11053
11439
  //#endregion
11054
11440
  //#region src/commands/workflows/integrate.ts
11055
- const command$79 = defineCommand({
11441
+ const command$80 = defineCommand({
11056
11442
  name: "integrate",
11057
11443
  summary: "Set up the SDK, placements, and dashboard in your app",
11058
11444
  flags: {
@@ -11084,8 +11470,8 @@ const command$79 = defineCommand({
11084
11470
  prompts: true,
11085
11471
  mcp: false,
11086
11472
  async run(ctx, { flags }) {
11087
- const { runIntegrate } = await import("./integrate-DiSjlOjC.js");
11088
- const { printPlaybook } = await import("./playbook-DJ__edOW.js");
11473
+ const { runIntegrate } = await import("./integrate-D8J_X1bj.js");
11474
+ const { printPlaybook } = await import("./playbook-ecggWGFi.js");
11089
11475
  if (flags.skill) return printPlaybook(ctx.installDir, "integrate");
11090
11476
  await runIntegrate({
11091
11477
  ...ctx,
@@ -11097,7 +11483,7 @@ const command$79 = defineCommand({
11097
11483
 
11098
11484
  //#endregion
11099
11485
  //#region src/commands/workflows/migrate.ts
11100
- const command$80 = defineCommand({
11486
+ const command$81 = defineCommand({
11101
11487
  name: "migrate",
11102
11488
  summary: "Migrate from RevenueCat / Adapty / Qonversion, or rebuild a paywall or native screen as code",
11103
11489
  args: { paywall: { describe: "A dashboard paywall id: scaffold it as code (if not already) and rebuild its pages with your agent, or copy the prompt" } },
@@ -11131,8 +11517,8 @@ const command$80 = defineCommand({
11131
11517
  prompts: true,
11132
11518
  mcp: false,
11133
11519
  async run(ctx, { args, flags }) {
11134
- const { runPaywallMigration, runProviderMigration, runScreenMigration } = await import("./migrate-BKiOUsMY.js");
11135
- const { printPlaybook } = await import("./playbook-DJ__edOW.js");
11520
+ const { runPaywallMigration, runProviderMigration, runScreenMigration } = await import("./migrate-BYF6hKZ2.js");
11521
+ const { printPlaybook } = await import("./playbook-ecggWGFi.js");
11136
11522
  if (flags.screen !== void 0) return runScreenMigration(ctx, {
11137
11523
  path: flags.screen,
11138
11524
  screenshot: flags.screenshot
@@ -11145,7 +11531,7 @@ const command$80 = defineCommand({
11145
11531
 
11146
11532
  //#endregion
11147
11533
  //#region src/commands/workflows/review.ts
11148
- const command$81 = defineCommand({
11534
+ const command$82 = defineCommand({
11149
11535
  name: "review",
11150
11536
  summary: "Review an existing Superwall setup end to end",
11151
11537
  flags: {
@@ -11166,8 +11552,8 @@ const command$81 = defineCommand({
11166
11552
  prompts: true,
11167
11553
  mcp: false,
11168
11554
  async run(ctx, { flags }) {
11169
- const { runReview } = await import("./integrate-DiSjlOjC.js");
11170
- const { printPlaybook } = await import("./playbook-DJ__edOW.js");
11555
+ const { runReview } = await import("./integrate-D8J_X1bj.js");
11556
+ const { printPlaybook } = await import("./playbook-ecggWGFi.js");
11171
11557
  if (flags.skill) return printPlaybook(ctx.installDir, flags.fix ? "review-fix" : "review");
11172
11558
  await runReview(ctx, flags.fix);
11173
11559
  }
@@ -11181,9 +11567,9 @@ const GROUPS = [
11181
11567
  title: "Workflows",
11182
11568
  notes: ["Each takes --skill to print the playbook instead of running."],
11183
11569
  commands: [
11184
- command$79,
11185
- command$81,
11186
- command$80
11570
+ command$80,
11571
+ command$82,
11572
+ command$81
11187
11573
  ]
11188
11574
  },
11189
11575
  {
@@ -11191,13 +11577,13 @@ const GROUPS = [
11191
11577
  title: "Paywalls & funnels",
11192
11578
  notes: ["push and publish take -m <note> to record why, in the source commit.", "build, push, promote, publish and pull take --platform <p> when a project pushes to several platforms."],
11193
11579
  commands: [
11194
- command$46,
11195
11580
  command$47,
11196
- command$45,
11197
- command$51,
11198
11581
  command$48,
11582
+ command$46,
11583
+ command$52,
11199
11584
  command$49,
11200
- command$50
11585
+ command$50,
11586
+ command$51
11201
11587
  ]
11202
11588
  },
11203
11589
  {
@@ -11211,19 +11597,19 @@ const GROUPS = [
11211
11597
  details: "An artifact is a Worker with a superwall.json manifest. It holds no credential: it calls Superwall as whoever is viewing it."
11212
11598
  }],
11213
11599
  commands: [
11214
- command$67,
11215
11600
  command$68,
11216
- command$77,
11601
+ command$69,
11217
11602
  command$78,
11603
+ command$79,
11604
+ command$75,
11218
11605
  command$74,
11219
- command$73,
11606
+ command$77,
11607
+ command$72,
11220
11608
  command$76,
11221
- command$71,
11222
- command$75,
11223
- command$66,
11224
- command$69,
11609
+ command$67,
11225
11610
  command$70,
11226
- command$72
11611
+ command$71,
11612
+ command$73
11227
11613
  ]
11228
11614
  },
11229
11615
  {
@@ -11231,16 +11617,16 @@ const GROUPS = [
11231
11617
  title: "Commands",
11232
11618
  notes: ["superwall <command> --help lists its operations; <operation> --help, its flags."],
11233
11619
  commands: [
11234
- command$54,
11235
- command$53,
11236
- command$59,
11237
- command$56,
11238
11620
  command$55,
11239
- command$58,
11621
+ command$54,
11240
11622
  command$60,
11241
- command$61,
11242
11623
  command$57,
11243
- command$52
11624
+ command$56,
11625
+ command$59,
11626
+ command$61,
11627
+ command$62,
11628
+ command$58,
11629
+ command$53
11244
11630
  ]
11245
11631
  },
11246
11632
  {
@@ -11255,12 +11641,13 @@ const GROUPS = [
11255
11641
  topics: [{
11256
11642
  name: "api",
11257
11643
  summary: "The Superwall API reference",
11258
- details: "Search the reference for any endpoint, its parameters and body. get, post, patch and delete send any request to it."
11644
+ details: "Search the reference for any endpoint, its parameters and body. get, post, put, patch and delete send any request to it."
11259
11645
  }],
11260
11646
  commands: [
11261
11647
  command$5,
11262
11648
  command$6,
11263
11649
  command$8,
11650
+ command$9,
11264
11651
  command$7,
11265
11652
  command$4
11266
11653
  ]
@@ -11376,35 +11763,35 @@ proxy uses. No command prints a private key, and none revokes a key at Apple.`
11376
11763
  }
11377
11764
  ],
11378
11765
  commands: [
11379
- command$35,
11380
- command$21,
11381
- command$18,
11382
- command$23,
11383
- command$19,
11384
- command$20,
11766
+ command$36,
11385
11767
  command$22,
11768
+ command$19,
11386
11769
  command$24,
11770
+ command$20,
11771
+ command$21,
11772
+ command$23,
11387
11773
  command$25,
11388
- command$9,
11389
- command$30,
11390
- command$34,
11391
- command$36,
11392
- command$15,
11393
- command$16,
11394
- command$29,
11395
11774
  command$26,
11396
11775
  command$10,
11397
- command$32,
11398
- command$33,
11776
+ command$31,
11777
+ command$35,
11399
11778
  command$37,
11400
- command$11,
11779
+ command$16,
11401
11780
  command$17,
11402
- command$31,
11403
- command$14,
11404
- command$28,
11781
+ command$30,
11405
11782
  command$27,
11783
+ command$11,
11784
+ command$33,
11785
+ command$34,
11786
+ command$38,
11406
11787
  command$12,
11407
- command$13
11788
+ command$18,
11789
+ command$32,
11790
+ command$15,
11791
+ command$29,
11792
+ command$28,
11793
+ command$13,
11794
+ command$14
11408
11795
  ]
11409
11796
  },
11410
11797
  {
@@ -11419,13 +11806,13 @@ proxy uses. No command prints a private key, and none revokes a key at Apple.`
11419
11806
  "asa docs"
11420
11807
  ] },
11421
11808
  commands: [
11422
- command$38,
11423
- command$42,
11424
- command$41,
11809
+ command$39,
11425
11810
  command$43,
11811
+ command$42,
11426
11812
  command$44,
11427
- command$39,
11428
- command$40
11813
+ command$45,
11814
+ command$40,
11815
+ command$41
11429
11816
  ]
11430
11817
  },
11431
11818
  {
@@ -11441,10 +11828,10 @@ proxy uses. No command prints a private key, and none revokes a key at Apple.`
11441
11828
  id: "support",
11442
11829
  title: "Support & updates",
11443
11830
  commands: [
11444
- command$62,
11445
- command$64,
11831
+ command$63,
11446
11832
  command$65,
11447
- command$63
11833
+ command$66,
11834
+ command$64
11448
11835
  ]
11449
11836
  }
11450
11837
  ];
@@ -11454,9 +11841,9 @@ function visible(channel) {
11454
11841
  function listGroups() {
11455
11842
  return GROUPS.filter((group$1) => visible(group$1.channel)).map((group$1) => ({
11456
11843
  ...group$1,
11457
- commands: group$1.commands.filter((command$82) => visible(command$82.channel))
11844
+ commands: group$1.commands.filter((command$83) => visible(command$83.channel))
11458
11845
  }));
11459
11846
  }
11460
11847
 
11461
11848
  //#endregion
11462
- export { renderPage as a, exampleLines as i, cmd as n, detailLines as r, listGroups as t };
11849
+ export { exampleLines as a, detailLines as i, listGroups as n, renderPage as o, cmd as r, GROUPS as t };