@superwall/cli 1.7.0 → 2.0.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 (165) hide show
  1. package/README.md +192 -52
  2. package/dist/{setup-Bxj22rYi.js → apple-CkKlHBZ9.js} +82 -76
  3. package/dist/auth.d.ts +4 -19
  4. package/dist/auth.js +4 -2
  5. package/dist/{actions-B7ym3oVS.js → billing-XCZU_T46.js} +98 -28
  6. package/dist/{bind-YrJvuRF9.js → bind-drne__Ys.js} +38 -33
  7. package/dist/{build-DLoCW5Ri.js → build-Gpdq5QXP.js} +20 -26
  8. package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
  9. package/dist/client-DP6Rc0t_.js +176 -0
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/{notification-url-DuKF2659.js → create-BBrtgUgS.js} +235 -539
  12. package/dist/{create-pkANt1Gs.js → create-Cwc3SRWJ.js} +194 -168
  13. package/dist/create-Yvf2gStM.js +19 -0
  14. package/dist/doctor-C9ldpPFC.js +83 -0
  15. package/dist/{drivers-Qx9LxmRN.js → drivers-DNrx4LWA.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28073 -1134
  18. package/dist/environment-DF1qKlny.js +58 -0
  19. package/dist/{existing-AVEfZu2A.js → existing-78LWSsqS.js} +12 -6
  20. package/dist/held-Cy8Wl4D1.js +1112 -0
  21. package/dist/held-Ddw1XSsr.js +16 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-brmhPG-S.js → integrate-DcJhpXy8.js} +277 -254
  24. package/dist/kinds-GFXB3sYu.js +11 -0
  25. package/dist/log-NVhVe_oe.js +62 -0
  26. package/dist/login-B2TsCE2H.js +53 -0
  27. package/dist/login-BoBe8Psl.js +16 -0
  28. package/dist/{login-Do4wFuLv.js → login-D0lh3_JI.js} +118 -55
  29. package/dist/lookup-D-nmmAbw.js +71 -0
  30. package/dist/migrate-Cfec564E.js +274 -0
  31. package/dist/notification-url-YDbq6FMA.js +100 -0
  32. package/dist/{open-studio-DOw-6ydc.js → open-Ba2vBl1_.js} +34 -43
  33. package/dist/org-D0g_q3mv.js +35 -0
  34. package/dist/output-Ggzq5_-t.js +122 -0
  35. package/dist/paths-DxSLdpOI.js +29 -0
  36. package/dist/playbook-DIeb7hne.js +53 -0
  37. package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
  38. package/dist/promote-COD4fYdz.js +91 -0
  39. package/dist/push-CncywhkQ.js +482 -0
  40. package/dist/push-CtD4FZQV.js +22 -0
  41. package/dist/registry-DSrosOYs.js +10228 -0
  42. package/dist/{reports-CfJqoava.js → reports-DdPq4blM.js} +7 -6
  43. package/dist/{resources-Bf9O1JNM.js → resources-Dqr01Dep.js} +150 -55
  44. package/dist/{run-DsVZ5snL.js → run-C9qg_QlC.js} +16 -22
  45. package/dist/scan-Cv5uOwVY.js +4 -0
  46. package/dist/{scan-zKsddO72.js → scan-DLrsrFS9.js} +48 -37
  47. package/dist/scope-V336uz8j.js +198 -0
  48. package/dist/screenshot-file-0UETadF8.js +16 -0
  49. package/dist/{selection-CxZoX4NT.js → selection-Rdw-ZUoG.js} +94 -51
  50. package/dist/send-BxD9yf6F.js +150 -0
  51. package/dist/{dev-DmB3XqaJ.js → server-D0tGG8C4.js} +82 -92
  52. package/dist/server-z1LH94R_.js +22 -0
  53. package/dist/session-1AV_Bs_d.js +6 -0
  54. package/dist/session-CFAmMhem.js +40 -0
  55. package/dist/session-D_nEWKXT.js +768 -0
  56. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  57. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  58. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  59. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  60. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  61. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  62. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  63. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  64. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  65. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  66. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  67. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  68. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  69. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  71. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  72. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  73. package/dist/skills/index.json +37 -0
  74. package/dist/skills/mobile-design/SKILL.md +447 -0
  75. package/dist/skills/mobile-design/references/responsive.md +162 -0
  76. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  77. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  78. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  79. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  80. package/dist/skills/superwall/SKILL.md +82 -9
  81. package/dist/skills/superwall/references/api.md +153 -37
  82. package/dist/skills/superwall/references/apple-setup.md +316 -0
  83. package/dist/skills/superwall/references/asc.md +74 -38
  84. package/dist/skills/superwall/references/data-analytics.md +55 -21
  85. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  86. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  87. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  88. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  89. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  90. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  91. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  96. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  97. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  98. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  99. package/dist/skills/superwall-editor/SKILL.md +61 -0
  100. package/dist/skills/superwall-editor/references/cli.md +135 -0
  101. package/dist/skills/superwall-editor/references/design.md +51 -0
  102. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  103. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  104. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  105. package/dist/skills/superwall-framework/SKILL.md +78 -28
  106. package/dist/skills/superwall-framework/references/cli.md +58 -28
  107. package/dist/skills/superwall-framework/references/examples.md +4 -3
  108. package/dist/skills/superwall-framework/references/layout.md +30 -8
  109. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  110. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  111. package/dist/skills/wwdc/SKILL.md +22 -0
  112. package/dist/skills/wwdc/references/docs.md +52 -0
  113. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  114. package/dist/{skills-DPzlnfCK.js → skills-BvFOa4y6.js} +99 -122
  115. package/dist/skills-DMG4bpKk.js +14 -0
  116. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  117. package/dist/spinner-CneRK5rk.js +294 -0
  118. package/dist/storage-DYvmIOHa.d.ts +16 -0
  119. package/dist/storage-s2Dnz-yl.js +31 -0
  120. package/dist/storekit-DafAnGkM.js +16 -0
  121. package/dist/storekit-yY_kS2iR.js +47 -0
  122. package/dist/telemetry-DtG92m5O.js +56 -0
  123. package/dist/theme-DUsCh-Vd.js +25 -0
  124. package/dist/timing-BVxPrYq3.js +5 -0
  125. package/dist/{token-C0it-Xh7.js → token-DzRh7dI1.js} +6 -38
  126. package/dist/tools.d.ts +96 -0
  127. package/dist/tools.js +11178 -0
  128. package/dist/ui-D_qf3Gvw.js +53 -0
  129. package/dist/upgrade-Bt4Ouw1y.js +117 -0
  130. package/dist/upgrade-Cqy5orjb.js +7 -0
  131. package/package.json +10 -5
  132. package/dist/api-CZzirVMj.js +0 -151
  133. package/dist/api-output-aJNw7Syy.js +0 -20
  134. package/dist/app-DH6U8yuI.js +0 -190
  135. package/dist/asa-C-sQzPPn.js +0 -1194
  136. package/dist/asc-1ZBJ6DwS.js +0 -778
  137. package/dist/auth-YRhlV3DE.js +0 -140
  138. package/dist/billing-CCYHdApx.js +0 -80
  139. package/dist/bundle-id-CKxl_026.js +0 -121
  140. package/dist/command-CMIz81Da.js +0 -301
  141. package/dist/dev-DZy6pOnB.js +0 -22
  142. package/dist/doctor-H-hf-Yww.js +0 -88
  143. package/dist/feedback-CKf-rpBW.js +0 -152
  144. package/dist/hosted-CXe9TrWx.js +0 -32
  145. package/dist/migrate-C9ERDR6y.js +0 -284
  146. package/dist/org-sj7uyvp-.js +0 -40
  147. package/dist/output-C4o2gJ1K.js +0 -146
  148. package/dist/params-l3CrvRtR.js +0 -51
  149. package/dist/pipeline-BqzqZhX1.js +0 -977
  150. package/dist/print-skill-ZojRSybs.js +0 -74
  151. package/dist/promote-BG8X4Nv_.js +0 -88
  152. package/dist/publish-sxLh-G4G.js +0 -35
  153. package/dist/push-bQ6Vxtg8.js +0 -35
  154. package/dist/query-_FbybaH-.js +0 -53
  155. package/dist/resource-CGIwSd29.js +0 -323
  156. package/dist/revenue-provider-ebsRINY8.js +0 -100
  157. package/dist/scope-BvzD-kO4.js +0 -223
  158. package/dist/skills-D_R-lEsK.js +0 -64
  159. package/dist/spinner-TWa0hia6.js +0 -18
  160. package/dist/storekit-Cj9Cpjcz.js +0 -29
  161. package/dist/telemetry-DeA1mvnT.js +0 -169
  162. package/dist/ui-Dy0b-9L8.js +0 -27738
  163. package/dist/update-B2fWIc4q.js +0 -59
  164. package/dist/upgrade-BmzkTKrh.js +0 -72
  165. /package/dist/{devtools-8EgLo86w.js → devtools-ByZ6XYnn.js} +0 -0
@@ -0,0 +1,176 @@
1
+ import { n as resolveAuthToken, r as NotLoggedInError } from "./token-DzRh7dI1.js";
2
+ import { r as resolveApiHost, t as readSession } from "./storage-s2Dnz-yl.js";
3
+
4
+ //#region src/core/api/client.ts
5
+ const BODY_SNIPPET = 200;
6
+ function parseErrorEnvelope(body) {
7
+ let parsed;
8
+ try {
9
+ parsed = JSON.parse(body);
10
+ } catch {
11
+ return;
12
+ }
13
+ if (typeof parsed !== "object" || parsed === null) return void 0;
14
+ const text = (key) => {
15
+ const value = Reflect.get(parsed, key);
16
+ return typeof value === "string" && value !== "" ? value : void 0;
17
+ };
18
+ const message = text("message");
19
+ if (message === void 0) return void 0;
20
+ return {
21
+ message,
22
+ detail: {
23
+ type: text("type"),
24
+ code: text("code"),
25
+ param: text("param"),
26
+ docUrl: text("doc_url"),
27
+ resourceType: text("resource_type"),
28
+ resourceId: text("resource_id")
29
+ }
30
+ };
31
+ }
32
+ var ApiError = class extends Error {
33
+ detail;
34
+ request;
35
+ envelope;
36
+ hint;
37
+ constructor(request, status, body) {
38
+ const envelope = body === void 0 ? void 0 : parseErrorEnvelope(body);
39
+ const snippet = body?.trim().slice(0, BODY_SNIPPET);
40
+ super(envelope?.message ?? (snippet ? `HTTP ${status} — ${snippet}` : `HTTP ${status}`));
41
+ this.status = status;
42
+ this.body = body;
43
+ this.detail = envelope?.detail ?? {};
44
+ this.request = request;
45
+ this.envelope = envelope !== void 0;
46
+ }
47
+ };
48
+ var ApiUnreachableError = class extends Error {
49
+ constructor(host, cause) {
50
+ const local = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])/.test(host);
51
+ super(`Couldn't reach the Superwall API at ${host}.\n` + (local ? " That's a local address — start the API, or unset SUPERWALL_API_HOST to use production." : " Check your network or proxy, then try again."));
52
+ this.name = "ApiUnreachableError";
53
+ this.cause = cause;
54
+ }
55
+ };
56
+ const PAGE_LIMIT = 50;
57
+ const GET_RETRIES = 3;
58
+ const RETRYABLE = new Set([
59
+ 429,
60
+ 502,
61
+ 503,
62
+ 504
63
+ ]);
64
+ async function parseApiError(request, res) {
65
+ const text = await res.text().catch(() => "");
66
+ return new ApiError(request, res.status, text);
67
+ }
68
+ function retryDelay(res, retry) {
69
+ const after = Number(res.headers.get("retry-after"));
70
+ if (Number.isFinite(after) && after >= 0 && res.headers.has("retry-after")) return after * 1e3;
71
+ return 400 * 2 ** retry;
72
+ }
73
+ const createSuperwallApi = (initial) => {
74
+ let session = initial;
75
+ const host = () => resolveApiHost(session);
76
+ const send = async (url, init) => {
77
+ try {
78
+ return await fetch(url, init);
79
+ } catch (error) {
80
+ throw new ApiUnreachableError(host(), error);
81
+ }
82
+ };
83
+ const authorized = async () => {
84
+ const resolved = await resolveAuthToken(session);
85
+ session = resolved.session;
86
+ return resolved.token;
87
+ };
88
+ const request = async (method, path, body, options = {}) => {
89
+ const token = await authorized();
90
+ const attempt = () => {
91
+ return send(`${host()}${path}`, {
92
+ method,
93
+ headers: {
94
+ ...options.headers,
95
+ authorization: `Bearer ${token}`,
96
+ accept: "application/json",
97
+ ...body !== void 0 ? { "content-type": "application/json" } : {}
98
+ },
99
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
100
+ });
101
+ };
102
+ let res = await attempt();
103
+ for (let retry = 0; method === "GET" && RETRYABLE.has(res.status) && retry < GET_RETRIES; retry++) {
104
+ await new Promise((done) => setTimeout(done, retryDelay(res, retry)));
105
+ res = await attempt();
106
+ }
107
+ if (!res.ok) throw await parseApiError(`${method} ${path}`, res);
108
+ if (res.status === 204) return void 0;
109
+ return await res.json();
110
+ };
111
+ const api = {
112
+ org: {},
113
+ get userEmail() {
114
+ return session.userEmail;
115
+ },
116
+ get host() {
117
+ return host();
118
+ },
119
+ forOrg: (id) => ({
120
+ ...api,
121
+ org: { id },
122
+ forOrg: api.forOrg
123
+ }),
124
+ get: (path, options) => request("GET", path, void 0, options),
125
+ post: (path, body, options) => request("POST", path, body, options),
126
+ put: (path, body, options) => request("PUT", path, body, options),
127
+ patch: (path, body, options) => request("PATCH", path, body, options),
128
+ del: (path, options) => request("DELETE", path, void 0, options),
129
+ async postText(path, body) {
130
+ const token = await authorized();
131
+ const res = await send(`${host()}${path}`, {
132
+ method: "POST",
133
+ headers: {
134
+ authorization: `Bearer ${token}`,
135
+ accept: "text/plain",
136
+ "content-type": "text/plain; charset=utf-8"
137
+ },
138
+ body
139
+ });
140
+ if (!res.ok) throw await parseApiError(`POST ${path}`, res);
141
+ return res.text();
142
+ },
143
+ async list(path) {
144
+ const out = [];
145
+ let after;
146
+ for (let page = 0; page < PAGE_LIMIT; page++) {
147
+ const url = `${path}${path.includes("?") ? "&" : "?"}limit=100${after ? `&starting_after=${after}` : ""}`;
148
+ const batch = await api.get(url);
149
+ out.push(...batch.data);
150
+ if (!batch.has_more || batch.data.length === 0) break;
151
+ const last = batch.data.at(-1);
152
+ if (typeof last !== "object" || last === null || !("id" in last) || last.id == null) break;
153
+ after = String(last.id);
154
+ }
155
+ return out;
156
+ }
157
+ };
158
+ return api;
159
+ };
160
+ const superwallApi = () => {
161
+ const session = readSession();
162
+ if (!session) throw new NotLoggedInError();
163
+ return createSuperwallApi(session);
164
+ };
165
+ function withQuery(path, qs) {
166
+ const params = qs instanceof URLSearchParams ? qs : new URLSearchParams();
167
+ if (!(qs instanceof URLSearchParams)) for (const [key, value] of Object.entries(qs)) {
168
+ if (typeof value === "object" && value !== null) throw new Error(`Nested -d params aren't supported on GET/DELETE (got "${key}").`);
169
+ params.set(key, String(value));
170
+ }
171
+ const s = params.toString();
172
+ return s ? `${path}${path.includes("?") ? "&" : "?"}${s}` : path;
173
+ }
174
+
175
+ //#endregion
176
+ export { withQuery as a, superwallApi as i, ApiUnreachableError as n, createSuperwallApi as r, ApiError as t };
@@ -0,0 +1,105 @@
1
+ import { l as readJson, r as formatJson, u as state } from "./output-Ggzq5_-t.js";
2
+
3
+ //#region src/core/state/config.ts
4
+ const FILE = "config.json";
5
+ function read() {
6
+ return readJson(state(), FILE) ?? {};
7
+ }
8
+ function write(config) {
9
+ state().write(FILE, `${formatJson(config)}\n`);
10
+ }
11
+ function readDefaultApp(projectId) {
12
+ return read().defaultApp?.[projectId];
13
+ }
14
+ function writeDefaultApp(projectId, applicationId) {
15
+ const config = read();
16
+ config.defaultApp = {
17
+ ...config.defaultApp ?? {},
18
+ [projectId]: applicationId
19
+ };
20
+ write(config);
21
+ }
22
+ function readOpenedOrgs() {
23
+ return read().openedOrgs ?? [];
24
+ }
25
+ function writeOpenedOrgs(ids) {
26
+ const config = read();
27
+ const next = [...new Set(ids)];
28
+ if (next.join() === (config.openedOrgs ?? []).join()) return;
29
+ config.openedOrgs = next;
30
+ write(config);
31
+ }
32
+ function readSkillsSync() {
33
+ return read().skillsSync;
34
+ }
35
+ function writeSkillsSync(sync) {
36
+ const config = read();
37
+ config.skillsSync = sync;
38
+ write(config);
39
+ }
40
+ function readAnonymousId() {
41
+ const config = read();
42
+ if (config.telemetry?.anonymousId) return config.telemetry.anonymousId;
43
+ const anonymousId = crypto.randomUUID();
44
+ config.telemetry = {
45
+ ...config.telemetry,
46
+ anonymousId
47
+ };
48
+ write(config);
49
+ return anonymousId;
50
+ }
51
+ function readOnboardedOrg() {
52
+ return read().onboarded?.org;
53
+ }
54
+ function writeOnboardedOrg(org) {
55
+ const config = read();
56
+ config.onboarded = {
57
+ ...config.onboarded,
58
+ org
59
+ };
60
+ write(config);
61
+ }
62
+ function readOnboardedApp(appPath) {
63
+ return read().onboarded?.apps?.[appPath];
64
+ }
65
+ function writeOnboardedApp(appPath, app) {
66
+ const config = read();
67
+ config.onboarded = {
68
+ ...config.onboarded,
69
+ apps: {
70
+ ...config.onboarded?.apps,
71
+ [appPath]: app
72
+ }
73
+ };
74
+ write(config);
75
+ }
76
+ function readUpdateCheck() {
77
+ return read().updateCheck;
78
+ }
79
+ function writeUpdateCheck(check) {
80
+ const config = read();
81
+ config.updateCheck = check;
82
+ write(config);
83
+ }
84
+ function readOnboardingIdempotencyKey() {
85
+ const config = read();
86
+ if (config.onboardingIdempotencyKey) return config.onboardingIdempotencyKey;
87
+ const key = crypto.randomUUID();
88
+ config.onboardingIdempotencyKey = key;
89
+ write(config);
90
+ return key;
91
+ }
92
+ function telemetryNoticeShown() {
93
+ return Boolean(read().telemetry?.noticeShown);
94
+ }
95
+ function writeTelemetryNoticeShown() {
96
+ const config = read();
97
+ config.telemetry = {
98
+ ...config.telemetry,
99
+ noticeShown: true
100
+ };
101
+ write(config);
102
+ }
103
+
104
+ //#endregion
105
+ export { readOnboardingIdempotencyKey as a, readUpdateCheck as c, writeOnboardedApp as d, writeOnboardedOrg as f, writeUpdateCheck as g, writeTelemetryNoticeShown as h, readOnboardedOrg as i, telemetryNoticeShown as l, writeSkillsSync as m, readDefaultApp as n, readOpenedOrgs as o, writeOpenedOrgs as p, readOnboardedApp as r, readSkillsSync as s, readAnonymousId as t, writeDefaultApp as u };