@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
@@ -0,0 +1,203 @@
1
+ import { f as formatJson } from "./storage-BR6imSqm.js";
2
+ import { O as field, h as listResource, k as isRecord } from "./resources-XwvXA20E.js";
3
+ import { t as apiCall } from "./spinner-BQp7fQvK.js";
4
+ import { a as pickScope } from "./scope-BLLUxbrA.js";
5
+ import { r as textOf } from "./input-DOT_2Zvb.js";
6
+ import { writeFileSync } from "node:fs";
7
+
8
+ //#region src/core/main/storekit.ts
9
+ const GROUP_ID = "20000000";
10
+ const PERIOD_UNITS = {
11
+ day: "D",
12
+ week: "W",
13
+ month: "M",
14
+ year: "Y"
15
+ };
16
+ const TRIAL_PERIODS = {
17
+ 7: "P1W",
18
+ 14: "P2W",
19
+ 30: "P1M",
20
+ 60: "P2M",
21
+ 90: "P3M",
22
+ 180: "P6M",
23
+ 365: "P1Y"
24
+ };
25
+ async function writeStoreKit(context, api, out) {
26
+ const scope = await pickScope(context, api, false);
27
+ const products = await apiCall(context, "Loading products", () => listResource(api, "products", scope));
28
+ const outFile = textOf(out) ?? "Superwall.storekit";
29
+ const { file, written, skipped } = generateStoreKit(products);
30
+ writeFileSync(outFile, `${formatJson(file)}\n`);
31
+ if (context.json) return context.output.data({
32
+ path: outFile,
33
+ products: written,
34
+ skipped
35
+ });
36
+ context.ui.success(`Wrote \`${outFile}\` with ${written} product${written === 1 ? "" : "s"}`);
37
+ for (const line of describeSkipped(skipped)) context.ui.warn(line);
38
+ }
39
+ const SKIP_REASONS = [
40
+ ["other_store", "not sold on the App Store"],
41
+ ["no_price", "with no price in Superwall"],
42
+ ["no_identifier", "with no store identifier"]
43
+ ];
44
+ function describeSkipped(skipped) {
45
+ const lines = [];
46
+ for (const [reason, label] of SKIP_REASONS) {
47
+ const names = skipped.filter((product) => product.reason === reason).map((product) => product.identifier);
48
+ if (names.length === 0) continue;
49
+ const listed = names.filter(Boolean).map((name) => `\`${name}\``).join(", ");
50
+ lines.push(`Left out ${names.length} product${names.length === 1 ? "" : "s"} ${label}${listed ? `: ${listed}` : ""}`);
51
+ if (reason !== "no_price") continue;
52
+ for (const product of skipped.filter((entry) => entry.reason === reason)) lines.push(`Price \`${product.identifier}\` in minor units (399 is 3.99) with \`superwall products update ${product.id} --price '{"amount":<amount>,"currency":"USD"}'\`, then export again`);
53
+ }
54
+ return lines;
55
+ }
56
+ function generateStoreKit(products, options = {}) {
57
+ const skipped = [];
58
+ const mapped = [];
59
+ for (const product of products) {
60
+ const identifier = textOf(product.identifier) ?? textOf(product.product_identifier) ?? textOf(product.name);
61
+ if (!identifier) {
62
+ skipped.push({
63
+ id: String(product.id ?? ""),
64
+ identifier: String(product.id ?? ""),
65
+ reason: "no_identifier"
66
+ });
67
+ continue;
68
+ }
69
+ if (!isAppStore(product)) {
70
+ skipped.push({
71
+ id: String(product.id ?? ""),
72
+ identifier,
73
+ reason: "other_store"
74
+ });
75
+ continue;
76
+ }
77
+ const amount = amountOf(product.price);
78
+ if (amount === void 0) {
79
+ skipped.push({
80
+ id: String(product.id ?? ""),
81
+ identifier,
82
+ reason: "no_price"
83
+ });
84
+ continue;
85
+ }
86
+ const internalID = String(1e3 + mapped.length);
87
+ const name = textOf(product.name) ?? identifier;
88
+ const subscription = isRecord(product.subscription) ? product.subscription : void 0;
89
+ const period = subscription ? periodOf(subscription) : void 0;
90
+ mapped.push({
91
+ identifier,
92
+ internalID,
93
+ amount,
94
+ base: {
95
+ displayPrice: displayPrice(amount, currencyOf(product.price)),
96
+ familyShareable: false,
97
+ internalID,
98
+ localizations: [{
99
+ description: name,
100
+ displayName: name,
101
+ locale: "en_US"
102
+ }],
103
+ productID: identifier,
104
+ referenceName: name
105
+ },
106
+ period,
107
+ introductoryOffer: subscription && period ? introductoryOffer(product, subscription, internalID) : null
108
+ });
109
+ }
110
+ const subscriptions = mapped.filter((product) => product.period !== void 0);
111
+ const ranked = [...subscriptions].sort((a, b) => b.amount - a.amount);
112
+ return {
113
+ file: {
114
+ identifier: "SUPERWALL",
115
+ nonRenewingSubscriptions: [],
116
+ products: mapped.filter((product) => product.period === void 0).map((product) => ({
117
+ ...product.base,
118
+ type: "NonConsumable"
119
+ })),
120
+ settings: options.teamId ? { _developerTeamID: options.teamId } : {},
121
+ subscriptionGroups: subscriptions.length === 0 ? [] : [{
122
+ id: GROUP_ID,
123
+ localizations: [],
124
+ name: "Subscriptions",
125
+ subscriptions: subscriptions.map((product) => ({
126
+ adHocOffers: [],
127
+ codeOffers: [],
128
+ ...product.base,
129
+ groupNumber: ranked.indexOf(product) + 1,
130
+ introductoryOffer: product.introductoryOffer,
131
+ recurringSubscriptionPeriod: product.period,
132
+ subscriptionGroupID: GROUP_ID,
133
+ type: "RecurringSubscription"
134
+ }))
135
+ }],
136
+ version: {
137
+ major: 3,
138
+ minor: 0
139
+ }
140
+ },
141
+ written: mapped.length,
142
+ skipped
143
+ };
144
+ }
145
+ function isAppStore(product) {
146
+ const store = textOf(product.store);
147
+ if (store) return store === "app_store";
148
+ const platform = textOf(product.platform);
149
+ return platform === void 0 || platform === "ios";
150
+ }
151
+ function amountOf(price) {
152
+ const amount = field(price, "amount");
153
+ return typeof amount === "number" && Number.isFinite(amount) && amount >= 0 ? amount : void 0;
154
+ }
155
+ function currencyOf(price) {
156
+ return textOf(field(price, "currency")) ?? "USD";
157
+ }
158
+ function displayPrice(amount, currency) {
159
+ const digits = minorDigits(currency);
160
+ return (amount / 10 ** digits).toFixed(digits);
161
+ }
162
+ function minorDigits(currency) {
163
+ try {
164
+ return new Intl.NumberFormat("en-US", {
165
+ style: "currency",
166
+ currency
167
+ }).resolvedOptions().maximumFractionDigits ?? 2;
168
+ } catch {
169
+ return 2;
170
+ }
171
+ }
172
+ function positiveInteger(value) {
173
+ const number = typeof value === "number" ? value : void 0;
174
+ return number !== void 0 && Number.isInteger(number) && number > 0 ? number : void 0;
175
+ }
176
+ function periodOf(subscription) {
177
+ const unit = PERIOD_UNITS[String(subscription.period)];
178
+ if (!unit) return void 0;
179
+ return `P${positiveInteger(subscription.period_count) ?? 1}${unit}`;
180
+ }
181
+ function introductoryOffer(product, subscription, internalID) {
182
+ const days = positiveInteger(subscription.trial_period_days);
183
+ if (days === void 0) return null;
184
+ const offerID = Number(internalID).toString(16).toUpperCase().padStart(8, "0");
185
+ const subscriptionPeriod = TRIAL_PERIODS[days] ?? `P${days}D`;
186
+ const trialAmount = amountOf(product.trial_price) ?? 0;
187
+ if (trialAmount === 0) return {
188
+ internalID: offerID,
189
+ numberOfPeriods: 1,
190
+ paymentMode: "free",
191
+ subscriptionPeriod
192
+ };
193
+ return {
194
+ displayPrice: displayPrice(trialAmount, textOf(field(product.trial_price, "currency")) ?? currencyOf(product.price)),
195
+ internalID: offerID,
196
+ numberOfPeriods: 1,
197
+ paymentMode: "payUpFront",
198
+ subscriptionPeriod
199
+ };
200
+ }
201
+
202
+ //#endregion
203
+ export { generateStoreKit as n, writeStoreKit as r, describeSkipped as t };
@@ -0,0 +1,15 @@
1
+ import "./token-CWQ6tdva.js";
2
+ import "./storage-BR6imSqm.js";
3
+ import "./environment-sE2wZYdg.js";
4
+ import "./config-DOp5oChe.js";
5
+ import "./resources-XwvXA20E.js";
6
+ import "./orgs-DQQJ3sw_.js";
7
+ import "./ui-hFgji1e8.js";
8
+ import "./spinner-BQp7fQvK.js";
9
+ import "./org-BD8U3D1_.js";
10
+ import "./lookup-DqmIbUkv.js";
11
+ import "./scope-BLLUxbrA.js";
12
+ import "./input-DOT_2Zvb.js";
13
+ import { n as generateStoreKit, r as writeStoreKit, t as describeSkipped } from "./storekit-BqyujKQ_.js";
14
+
15
+ export { describeSkipped, generateStoreKit, writeStoreKit };
@@ -1,8 +1,9 @@
1
- import { h as Integration } from "./environment-BocmdvZ-.js";
2
- import { n as withSpinner } from "./spinner-DPdBlZe2.js";
3
- import { n as ui } from "./ui-D_qf3Gvw.js";
4
- import { c as createProject, m as listProjects, r as createApplication, y as platformLabel } from "./resources-CptT7HD6.js";
5
- import { n as orgForNewProject } from "./org-Dud1rF9f.js";
1
+ import { h as Integration } from "./environment-sE2wZYdg.js";
2
+ import { c as createProject, m as listProjects, r as createApplication, y as platformLabel } from "./resources-XwvXA20E.js";
3
+ import { n as ui } from "./ui-hFgji1e8.js";
4
+ import { n as withSpinner } from "./spinner-BQp7fQvK.js";
5
+ import { n as orgForNewProject } from "./org-BD8U3D1_.js";
6
+ import pc from "picocolors";
6
7
 
7
8
  //#region src/core/account/bind.ts
8
9
  const NEW = "__new__";
@@ -216,4 +217,26 @@ function appCountHint(p) {
216
217
  }
217
218
 
218
219
  //#endregion
219
- export { resolveAppBinding as n, resolveScopeFromKey as r, platformForIntegration as t };
220
+ //#region src/ui/theme.ts
221
+ const THEME = {
222
+ primary: "#74FFF1",
223
+ alert: "#E46671"
224
+ };
225
+ function hexToRgb(hex) {
226
+ const h = hex.replace("#", "");
227
+ const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
228
+ const n = parseInt(full, 16);
229
+ return [
230
+ n >> 16 & 255,
231
+ n >> 8 & 255,
232
+ n & 255
233
+ ];
234
+ }
235
+ function fg(hex, text) {
236
+ if (!pc.isColorSupported) return text;
237
+ const [r, g, b] = hexToRgb(hex);
238
+ return `\x1b[38;2;${r};${g};${b}m${text}\x1b[39m`;
239
+ }
240
+
241
+ //#endregion
242
+ export { resolveScopeFromKey as a, resolveAppBinding as i, fg as n, platformForIntegration as r, THEME as t };
@@ -0,0 +1,100 @@
1
+ import { l as writeSession, n as readSession } from "./storage-BR6imSqm.js";
2
+
3
+ //#region src/core/account/errors.ts
4
+ var NotLoggedInError = class extends Error {
5
+ constructor() {
6
+ super("You aren't logged in. Run `superwall login` first.");
7
+ this.name = "NotLoggedInError";
8
+ }
9
+ };
10
+ var LoginUnreachableError = class extends Error {
11
+ timedOut;
12
+ constructor(endpoint, cause, timeoutMs) {
13
+ const origin = URL.canParse(endpoint) ? new URL(endpoint).origin : endpoint;
14
+ super(timeoutMs === void 0 ? `Couldn't reach the Superwall login service at ${origin} to refresh your session.\n Check your network or proxy, then try again.` : `The Superwall login service at ${origin} didn't answer within ${timeoutMs / 1e3}s, so your session wasn't refreshed.\n Try again.`);
15
+ this.name = "LoginUnreachableError";
16
+ this.cause = cause;
17
+ this.timedOut = timeoutMs !== void 0;
18
+ }
19
+ };
20
+
21
+ //#endregion
22
+ //#region src/core/account/token.ts
23
+ const EXPIRY_SKEW_MS = 6e4;
24
+ const REFRESH_TIMEOUT_MS = 15e3;
25
+ function accessTokenIsFresh(session) {
26
+ return session.accessTokenExpiresAt !== void 0 && session.accessTokenExpiresAt - EXPIRY_SKEW_MS > Date.now();
27
+ }
28
+ async function refreshAccessToken(session, timeoutMs) {
29
+ if (!session.refreshToken || !session.tokenEndpoint || !session.oauthClientId) return null;
30
+ let res;
31
+ try {
32
+ res = await fetch(session.tokenEndpoint, {
33
+ method: "POST",
34
+ headers: { "content-type": "application/x-www-form-urlencoded" },
35
+ body: new URLSearchParams({
36
+ grant_type: "refresh_token",
37
+ refresh_token: session.refreshToken,
38
+ client_id: session.oauthClientId
39
+ }),
40
+ signal: AbortSignal.timeout(timeoutMs)
41
+ });
42
+ } catch (error) {
43
+ const timedOut = error instanceof Error && error.name === "TimeoutError";
44
+ throw new LoginUnreachableError(session.tokenEndpoint, error, timedOut ? timeoutMs : void 0);
45
+ }
46
+ if (!res.ok) return null;
47
+ let d;
48
+ try {
49
+ d = await res.json();
50
+ } catch (error) {
51
+ if (error instanceof SyntaxError) return null;
52
+ const timedOut = error instanceof Error && error.name === "TimeoutError";
53
+ throw new LoginUnreachableError(session.tokenEndpoint, error, timedOut ? timeoutMs : void 0);
54
+ }
55
+ if (!d.access_token) return null;
56
+ const updated = {
57
+ ...session,
58
+ accessToken: d.access_token,
59
+ refreshToken: d.refresh_token ?? session.refreshToken,
60
+ accessTokenExpiresAt: d.expires_in ? Date.now() + d.expires_in * 1e3 : void 0
61
+ };
62
+ writeSession(updated);
63
+ return updated;
64
+ }
65
+ async function getOAuthAccessToken(options = {}) {
66
+ const session = readSession();
67
+ if (!session?.accessToken || !session.refreshToken) return null;
68
+ if (accessTokenIsFresh(session)) return session.accessToken;
69
+ try {
70
+ return (await refreshAccessToken(session, options.timeoutMs ?? REFRESH_TIMEOUT_MS))?.accessToken ?? null;
71
+ } catch (error) {
72
+ if (error instanceof LoginUnreachableError) return null;
73
+ throw error;
74
+ }
75
+ }
76
+ async function resolveAuthToken(session, options = {}) {
77
+ if (session.accessToken && session.refreshToken) {
78
+ if (accessTokenIsFresh(session)) return {
79
+ token: session.accessToken,
80
+ session
81
+ };
82
+ try {
83
+ const refreshed = await refreshAccessToken(session, options.timeoutMs ?? REFRESH_TIMEOUT_MS);
84
+ if (refreshed) return {
85
+ token: refreshed.accessToken,
86
+ session: refreshed
87
+ };
88
+ } catch (error) {
89
+ if (!(error instanceof LoginUnreachableError) || !session.apiKey) throw error;
90
+ }
91
+ }
92
+ if (session.apiKey) return {
93
+ token: session.apiKey,
94
+ session
95
+ };
96
+ throw new NotLoggedInError();
97
+ }
98
+
99
+ //#endregion
100
+ export { NotLoggedInError as i, resolveAuthToken as n, LoginUnreachableError as r, getOAuthAccessToken as t };
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: animate-onboarding
3
- description: Animate a tap-through onboarding or web funnel (quiz, survey, web2app flow) so the motion tells the flow's story — each page-to-page hand-off gets its own choreography tied to what the two pages say, the chosen answer physically becomes the progress it earns or the next page's hero, and everything stays fluid, physical and smooth on real phones. Built for flows shipped as Superwall surfaces (the superwall framework: pages, router transitions, layout chrome), with the engine mapped onto the router; the same direction applies to any tap-through web flow. Motion only; no new screens. Use when the user asks to "animate the onboarding", "make the funnel feel premium", "add transitions between onboarding pages", or when a flow's page transitions feel flat, generic, choppy, or cheap.
3
+ description: "Animate a tap-through onboarding or web funnel (quiz, survey, web2app flow) so the motion tells the flow's story — each page-to-page hand-off gets its own choreography tied to what the two pages say, the chosen answer physically becomes the progress it earns or the next page's hero, and everything stays fluid, physical and smooth on real phones. Built for flows shipped as Superwall surfaces (the superwall framework: pages, router transitions, layout chrome), with the engine mapped onto the router; the same direction applies to any tap-through web flow. Motion only; no new screens. Use when the user asks to \"animate the onboarding\", \"make the funnel feel premium\", \"add transitions between onboarding pages\", or when a flow's page transitions feel flat, generic, choppy, or cheap."
4
4
  user-invocable: true
5
5
  ---
6
6
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mobile-design
3
- description: Make a web screen feel native inside a phone app — a paywall, an onboarding or quiz, an offer, an update screen, any screen rendered in a WKWebView / Android WebView or shipped as a Superwall surface. The rules a native screen follows and a web page doesn't: press feedback on every control, hover gated to real pointers, 16px inputs and the keyboard, motion with real easing and durations, size-aware type, worst-case content, dark mode from the host, iOS vs Android conventions, and the audit before it ships. Use when building or reviewing any screen of that kind for iOS or Android, with or without a design reference, or when a screen "feels like a website" on a phone. For the Superwall framework's own mechanics (insets, routing, products, push) read superwall-framework; for React Native / Expo screens use the platform's own components instead.
3
+ description: "Make a web screen feel native inside a phone app — a paywall, an onboarding or quiz, an offer, an update screen, any screen rendered in a WKWebView / Android WebView or shipped as a Superwall surface. The rules a native screen follows and a web page doesn't: press feedback on every control, hover gated to real pointers, 16px inputs and the keyboard, motion with real easing and durations, size-aware type, worst-case content, dark mode from the host, iOS vs Android conventions, and the audit before it ships. Use when building or reviewing any screen of that kind for iOS or Android, with or without a design reference, or when a screen \"feels like a website\" on a phone. For the Superwall framework's own mechanics (insets, routing, products, push) read superwall-framework; for React Native / Expo screens use the platform's own components instead."
4
4
  ---
5
5
 
6
6
  # Mobile design
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: onboarding-questions
3
- description: Write the brains of an app's onboarding or web2app funnel — every question, its answers, the order, the branching, the statements and explainer screens between them, image descriptions and the meaning of each transition — so the flow primes the user to finish and to buy, and collects the answers that predict revenue (from ARPU data across 411 apps). Starts from an App Store URL (and the website, if there is one), researches the app, and hands over a spec that ships fastest as a Superwall surface (the superwall framework: one page per screen, answers sent as user attributes). Design, UI and code agnostic; no paywall, pricing or checkout. Use when the user asks "what should we ask in onboarding", "write our onboarding questions", "design a quiz/survey funnel", "which questions predict who pays", "make our onboarding convert", or wants inspiration for onboarding screens.
3
+ description: "Write the brains of an app's onboarding or web2app funnel — every question, its answers, the order, the branching, the statements and explainer screens between them, image descriptions and the meaning of each transition — so the flow primes the user to finish and to buy, and collects the answers that predict revenue (from ARPU data across 411 apps). Starts from an App Store URL (and the website, if there is one), researches the app, and hands over a spec that ships fastest as a Superwall surface (the superwall framework: one page per screen, answers sent as user attributes). Design, UI and code agnostic; no paywall, pricing or checkout. Use when the user asks \"what should we ask in onboarding\", \"write our onboarding questions\", \"design a quiz/survey funnel\", \"which questions predict who pays\", \"make our onboarding convert\", or wants inspiration for onboarding screens."
4
4
  user-invocable: true
5
5
  ---
6
6
 
@@ -27,9 +27,8 @@ Work that needs the user's machine has no tool. Ask the user to run it in a
27
27
  terminal (`npx superwall <command>`, after `npx superwall login`): `integrate`,
28
28
  `review`, `migrate`, `setup apple`, `asc keys create`, `asc keys update`,
29
29
  `asc screenshots upload`, `products storekit`, `apps use`, `login`, `logout`,
30
- `whoami`, `doctor`, `skills`, `upgrade`, and on the `next` channel the
31
- paywall-as-code commands (`create`, `dev`, `build`, `push`, `promote`,
32
- `publish`).
30
+ `whoami`, `doctor`, `skills`, `upgrade`, and the paywall-as-code commands
31
+ (`create`, `dev`, `build`, `push`, `promote`, `publish`).
33
32
 
34
33
  ## CLI prerequisite — use the installed version
35
34
 
@@ -39,9 +38,10 @@ CLI tasks require a one-time user installation:
39
38
  npm install --global superwall
40
39
  ```
41
40
 
42
- Use `superwall ...` directly once it is installed. Do not automatically install
43
- or upgrade the CLI, or use a download-and-run fallback, with one exception:
44
- before reporting a bug, upgrade and retry (see Feedback below). Ask the user to install
41
+ Use `superwall ...` directly once it is installed. Do not install or upgrade
42
+ the CLI on your own, or use a download-and-run fallback, with two exceptions:
43
+ when the CLI itself prints an upgrade prompt (see below), and before reporting
44
+ a bug, upgrade and retry (see Feedback below). Ask the user to install
45
45
  it if a requested CLI task cannot proceed. Bundled playbooks, references, local
46
46
  SDK review, and documentation tasks remain available without the CLI.
47
47
 
@@ -65,6 +65,30 @@ These playbooks use the 2.x command syntax (`apps get`, `create --identifier`,
65
65
  below 2.0.0, ask the user to run `superwall upgrade` before account commands; an
66
66
  older CLI rejects these commands rather than guessing.
67
67
 
68
+ ### When the CLI prints an upgrade prompt
69
+
70
+ When a newer release is out, any command ends with an upgrade prompt on
71
+ stderr, also under `--json` (stdout stays pure JSON). Act on it before you
72
+ carry on:
73
+
74
+ - **Patch or minor** — one line:
75
+ `Update available 2.5.2 → 2.6.0 · run superwall upgrade`. Tell the user in
76
+ one line, run the command it names, then continue the task.
77
+ - **Major** — three lines:
78
+ ```
79
+ Major update available 2.5.2 → 3.0.0
80
+ A major release may contain breaking changes. Read https://github.com/superwall/superwall/releases/tag/v3.0.0
81
+ Update: superwall upgrade
82
+ ```
83
+ Tell the user, link the release notes, and ask before running anything: a
84
+ major can break paywalls. Carry on with the current version if they decline.
85
+
86
+ Run the command exactly as printed. It is `superwall upgrade`, or, when the
87
+ project pins its own `superwall`, that project's bump, e.g.
88
+ `cd superwall && pnpm add superwall@latest`. A beta follows npm's `next` tag,
89
+ so its prompt says `superwall@next`: never swap it for `@latest`. With no
90
+ prompt, nothing needs upgrading.
91
+
68
92
  The session lives under `~/.superwall`; account commands act as the logged-in
69
93
  user. A plugin installation already includes these skills, so use its bundled
70
94
  files rather than assuming a separate standalone skill installation is needed.
@@ -100,7 +124,7 @@ viewing the account with `bootstrap`.
100
124
 
101
125
  [Read the CLI reference](references/api.md).
102
126
 
103
- **Before any `post`/`patch` to `/v2/...`, run `superwall api docs`** to find the
127
+ **Before any `post`/`put`/`patch` to `/v2/...`, run `superwall api docs`** to find the
104
128
  endpoint and its exact body. The API covers far more than the resource commands
105
129
  (campaign audiences, variants and traffic weights, users, webhooks, charts,
106
130
  retention): search it, never guess a path or a body.
@@ -111,7 +135,9 @@ everywhere the API has them. **Run `superwall <resource> --help` for its
111
135
  operations and `superwall <resource> <operation> --help` for the exact flags**
112
136
  (read from the live API reference) - never guess a flag. For an endpoint no
113
137
  resource covers, find it with `superwall api docs` and call it with the raw
114
- `get|post|patch|delete /v2/...` verbs.
138
+ `get|post|put|patch|delete /v2/...` verbs (`put` needs a CLI newer than 2.5.2;
139
+ audience weights and order have resource commands:
140
+ `campaigns variants weights` and `campaigns audiences reorder`).
115
141
 
116
142
  ```bash
117
143
  superwall apps list --json
@@ -165,9 +191,9 @@ superwall apps update <app> --revenue-provider <p> # only after the user d
165
191
  ## Apple Search Ads - Apple Ads API
166
192
 
167
193
  Use when: reading or managing Apple Search Ads - campaigns, ad groups,
168
- keywords, negative keywords, ads, creatives, reports, budget orders.
169
- `superwall asa` proxies the entire Apple Ads Campaign Management API v5 with the
170
- credentials connected in the dashboard (no client secret, token, or org id).
194
+ keywords, negative keywords, ads, creatives, reports, insights, budget orders.
195
+ `superwall asa` proxies the Apple Ads Platform API v1 (`api.ads.apple.com/v1`)
196
+ with the credentials connected in the dashboard (no client secret or token).
171
197
 
172
198
  **Before any `asa <resource> create|update`, run `superwall asa docs <resource> <action>`**
173
199
  for Apple's exact fields and enums. Typed flags cover the common fields; `--body`
@@ -178,8 +204,8 @@ sends a full payload. Never guess a body.
178
204
  ```bash
179
205
  superwall asa docs # every endpoint, grouped
180
206
  superwall asa docs campaigns create # Apple's page: fields, enums, examples
181
- superwall asa campaigns find --field status --op EQUALS --values ENABLED --all --json
182
- superwall asa keywords create --campaign <id> --adgroup <id> \
207
+ superwall asa campaigns list --field status --op EQUALS --values ENABLED --all --json
208
+ superwall asa keywords create --adgroup <id> \
183
209
  --text "grammar checker" --match-type EXACT --bid 1.25 --json
184
210
  ```
185
211
 
@@ -239,10 +265,10 @@ Prefer it if installed (`superwall-framework`); otherwise install it:
239
265
  npx skills add https://github.com/superwall/skills --skill superwall-framework --global --yes --agent claude-code universal --full-depth
240
266
  ```
241
267
 
242
- The framework is in public beta. Until the CLI turns these commands on by
243
- default, it has them only while `SUPERWALL_CHANNEL=next` is set in the environment. If
244
- `superwall create` answers `Unknown command`, the variable is missing from
245
- your environment: ask the user to set it globally (shell rc) and relaunch.
268
+ The framework is in public beta, and the CLI has these commands by default.
269
+ If `superwall create` answers `Unknown command`, the installed CLI is older
270
+ than the framework commands: ask the user to run `superwall upgrade`, then
271
+ try again.
246
272
 
247
273
  ## Docs - documentation, SDK integration, dashboard links
248
274