@superwall/cli 1.7.0 → 2.1.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 (229) hide show
  1. package/README.md +192 -52
  2. package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.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-C3Q8DBU2.js} +98 -28
  6. package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
  7. package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
  8. package/dist/client-BL0f_yGf.js +176 -0
  9. package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
  10. package/dist/config-BO1Y87kV.js +105 -0
  11. package/dist/create-BSfvpWoD.js +19 -0
  12. package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
  13. package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
  14. package/dist/doctor-BWqIYcMn.js +83 -0
  15. package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
  16. package/dist/entry.d.ts +0 -5
  17. package/dist/entry.js +28072 -1134
  18. package/dist/environment-eBXjELoN.js +58 -0
  19. package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
  20. package/dist/held-CPve03KJ.js +16 -0
  21. package/dist/held-DgnTFMl3.js +1112 -0
  22. package/dist/input-vi0bou04.js +42 -0
  23. package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
  24. package/dist/log-NVhVe_oe.js +62 -0
  25. package/dist/login-BCEH5q0U.js +53 -0
  26. package/dist/login-BPOONe7n.js +16 -0
  27. package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
  28. package/dist/lookup-rr1AkCJA.js +71 -0
  29. package/dist/migrate-C9X2Vz81.js +274 -0
  30. package/dist/notification-url-CV86qiKP.js +100 -0
  31. package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
  32. package/dist/org-BQQDo7wm.js +35 -0
  33. package/dist/output-Ggzq5_-t.js +122 -0
  34. package/dist/paths-CRlU72cq.js +29 -0
  35. package/dist/playbook-DVMXN7fh.js +53 -0
  36. package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
  37. package/dist/promote-Da8xctzy.js +91 -0
  38. package/dist/push-BV-grvQg.js +22 -0
  39. package/dist/push-D6R9icWN.js +495 -0
  40. package/dist/registry-BYVD-_h6.js +10385 -0
  41. package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
  42. package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
  43. package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
  44. package/dist/scan-B88OlWOt.js +4 -0
  45. package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
  46. package/dist/scope-DV22_Ufm.js +198 -0
  47. package/dist/screenshot-file-tVBfUEIi.js +16 -0
  48. package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
  49. package/dist/server-C4f6ccUr.js +22 -0
  50. package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
  51. package/dist/session-B-Uz0cQ7.js +40 -0
  52. package/dist/session-BuvArt1j.js +6 -0
  53. package/dist/session-C4rbE3VS.js +796 -0
  54. package/dist/skills/animate-onboarding/SKILL.md +467 -0
  55. package/dist/skills/animate-onboarding/references/engine.md +494 -0
  56. package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
  57. package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
  58. package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
  59. package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
  60. package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  61. package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
  62. package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
  63. package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  64. package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
  65. package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
  66. package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
  67. package/dist/skills/animate-onboarding/references/performance.md +41 -0
  68. package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
  69. package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  70. package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  71. package/dist/skills/index.json +37 -0
  72. package/dist/skills/mobile-design/SKILL.md +447 -0
  73. package/dist/skills/mobile-design/references/responsive.md +162 -0
  74. package/dist/skills/onboarding-questions/SKILL.md +231 -0
  75. package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
  76. package/dist/skills/onboarding-questions/references/craft.md +142 -0
  77. package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
  78. package/dist/skills/superwall/SKILL.md +82 -9
  79. package/dist/skills/superwall/references/api.md +153 -37
  80. package/dist/skills/superwall/references/apple-setup.md +316 -0
  81. package/dist/skills/superwall/references/asc.md +74 -38
  82. package/dist/skills/superwall/references/data-analytics.md +55 -21
  83. package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
  84. package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
  85. package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
  86. package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
  87. package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
  88. package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
  89. package/dist/skills/superwall/workflows/placements/android.md +2 -2
  90. package/dist/skills/superwall/workflows/placements/expo.md +2 -2
  91. package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
  92. package/dist/skills/superwall/workflows/placements/ios.md +2 -2
  93. package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
  94. package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
  95. package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
  96. package/dist/skills/superwall/workflows/review/playbook.md +1 -1
  97. package/dist/skills/superwall-editor/SKILL.md +61 -0
  98. package/dist/skills/superwall-editor/references/cli.md +135 -0
  99. package/dist/skills/superwall-editor/references/design.md +51 -0
  100. package/dist/skills/superwall-editor/references/native-elements.md +171 -0
  101. package/dist/skills/superwall-editor/references/workflow.md +65 -0
  102. package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
  103. package/dist/skills/superwall-framework/SKILL.md +85 -31
  104. package/dist/skills/superwall-framework/references/cli.md +58 -27
  105. package/dist/skills/superwall-framework/references/examples.md +4 -3
  106. package/dist/skills/superwall-framework/references/layout.md +64 -9
  107. package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
  108. package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
  109. package/dist/skills/wwdc/SKILL.md +22 -0
  110. package/dist/skills/wwdc/references/docs.md +52 -0
  111. package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
  112. package/dist/skills-CLGJuMnF.js +14 -0
  113. package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
  114. package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
  115. package/dist/spinner-C2U6QBJ9.js +294 -0
  116. package/dist/storage-6h9vyiAz.js +31 -0
  117. package/dist/storage-CerJ5KLP.d.ts +16 -0
  118. package/dist/storekit-CK9JmM2D.js +16 -0
  119. package/dist/storekit-CinJra3V.js +47 -0
  120. package/dist/telemetry-DKyDhURo.js +56 -0
  121. package/dist/theme-DUsCh-Vd.js +25 -0
  122. package/dist/timing-BVxPrYq3.js +5 -0
  123. package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
  124. package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
  125. package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
  126. package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
  127. package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
  128. package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
  129. package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
  130. package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
  131. package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
  132. package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
  133. package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
  134. package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
  135. package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
  136. package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
  137. package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
  138. package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
  139. package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
  140. package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
  141. package/dist/tools-skills/mobile-design/SKILL.md +447 -0
  142. package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
  143. package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
  144. package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
  145. package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
  146. package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
  147. package/dist/tools-skills/superwall/SKILL.md +263 -0
  148. package/dist/tools-skills/superwall/references/api.md +303 -0
  149. package/dist/tools-skills/superwall/references/asa.md +166 -0
  150. package/dist/tools-skills/superwall/references/asc.md +95 -0
  151. package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
  152. package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
  153. package/dist/tools-skills/superwall/references/docs.md +51 -0
  154. package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
  155. package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
  156. package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
  157. package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
  158. package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
  159. package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
  160. package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
  161. package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
  162. package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
  163. package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
  164. package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
  165. package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
  166. package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
  167. package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
  168. package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
  169. package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
  170. package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
  171. package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
  172. package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
  173. package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
  174. package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
  175. package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
  176. package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
  177. package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
  178. package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
  179. package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
  180. package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
  181. package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
  182. package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
  183. package/dist/tools-skills/superwall-editor/references/design.md +51 -0
  184. package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
  185. package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
  186. package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
  187. package/dist/tools-skills/wwdc/SKILL.md +22 -0
  188. package/dist/tools-skills/wwdc/references/docs.md +52 -0
  189. package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
  190. package/dist/tools.d.ts +96 -0
  191. package/dist/tools.js +11360 -0
  192. package/dist/ui-D_qf3Gvw.js +53 -0
  193. package/dist/upgrade-DPo0a4Es.js +117 -0
  194. package/dist/upgrade-ffseQDMx.js +7 -0
  195. package/package.json +10 -5
  196. package/dist/api-CZzirVMj.js +0 -151
  197. package/dist/api-output-aJNw7Syy.js +0 -20
  198. package/dist/app-DH6U8yuI.js +0 -190
  199. package/dist/asa-C-sQzPPn.js +0 -1194
  200. package/dist/asc-1ZBJ6DwS.js +0 -778
  201. package/dist/auth-YRhlV3DE.js +0 -140
  202. package/dist/billing-CCYHdApx.js +0 -80
  203. package/dist/bundle-id-CKxl_026.js +0 -121
  204. package/dist/command-CMIz81Da.js +0 -301
  205. package/dist/dev-DZy6pOnB.js +0 -22
  206. package/dist/doctor-H-hf-Yww.js +0 -88
  207. package/dist/feedback-CKf-rpBW.js +0 -152
  208. package/dist/hosted-CXe9TrWx.js +0 -32
  209. package/dist/migrate-C9ERDR6y.js +0 -284
  210. package/dist/org-sj7uyvp-.js +0 -40
  211. package/dist/output-C4o2gJ1K.js +0 -146
  212. package/dist/params-l3CrvRtR.js +0 -51
  213. package/dist/pipeline-BqzqZhX1.js +0 -977
  214. package/dist/print-skill-ZojRSybs.js +0 -74
  215. package/dist/promote-BG8X4Nv_.js +0 -88
  216. package/dist/publish-sxLh-G4G.js +0 -35
  217. package/dist/push-bQ6Vxtg8.js +0 -35
  218. package/dist/query-_FbybaH-.js +0 -53
  219. package/dist/resource-CGIwSd29.js +0 -323
  220. package/dist/revenue-provider-ebsRINY8.js +0 -100
  221. package/dist/scope-BvzD-kO4.js +0 -223
  222. package/dist/skills-D_R-lEsK.js +0 -64
  223. package/dist/spinner-TWa0hia6.js +0 -18
  224. package/dist/storekit-Cj9Cpjcz.js +0 -29
  225. package/dist/telemetry-DeA1mvnT.js +0 -169
  226. package/dist/ui-Dy0b-9L8.js +0 -27738
  227. package/dist/update-B2fWIc4q.js +0 -59
  228. package/dist/upgrade-BmzkTKrh.js +0 -72
  229. /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
@@ -1,5 +1,5 @@
1
- import { join } from "node:path";
2
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
3
 
4
4
  //#region src/core/state/reports.ts
5
5
  function dir(appPath) {
@@ -8,20 +8,21 @@ function dir(appPath) {
8
8
  function path(appPath, id) {
9
9
  return join(dir(appPath), `${id}.md`);
10
10
  }
11
- function saveReport(appPath, id, text) {
11
+ function writeReport(appPath, id, text) {
12
12
  try {
13
13
  mkdirSync(dir(appPath), { recursive: true });
14
14
  writeFileSync(path(appPath, id), text, "utf8");
15
15
  } catch {}
16
16
  }
17
- function loadReport(appPath, id) {
17
+ function readReport(appPath, id) {
18
18
  try {
19
- const p = path(appPath, id);
20
- return existsSync(p) ? readFileSync(p, "utf8") : void 0;
19
+ const file = path(appPath, id);
20
+ if (!existsSync(file)) return void 0;
21
+ return readFileSync(file, "utf8");
21
22
  } catch {
22
23
  return;
23
24
  }
24
25
  }
25
26
 
26
27
  //#endregion
27
- export { saveReport as n, loadReport as t };
28
+ export { writeReport as n, readReport as t };
@@ -1,3 +1,108 @@
1
+ import { n as ApiUnreachableError, t as ApiError } from "./client-BL0f_yGf.js";
2
+ import { o as readOpenedOrgs, p as writeOpenedOrgs } from "./config-BO1Y87kV.js";
3
+
4
+ //#region src/core/api/orgs.ts
5
+ async function listOrganizations(api) {
6
+ const res = await api.get("/v2/me/organizations");
7
+ return [...new Map((res.data ?? []).map((org) => [String(org.id), org])).values()];
8
+ }
9
+ function orgProjects(api, orgId) {
10
+ return api.list(`/v2/projects?organization_id=${encodeURIComponent(orgId)}`).then((projects) => projects.map((project) => ({
11
+ organization_id: orgId,
12
+ ...project
13
+ })));
14
+ }
15
+ function orgIdOf(project) {
16
+ return project.organization_id === void 0 ? void 0 : String(project.organization_id);
17
+ }
18
+ function asksForOrg(error) {
19
+ return error instanceof ApiError && error.status === 400 && /organization_id/.test(error.message);
20
+ }
21
+ async function listReachableProjects(api) {
22
+ let members = await api.list("/v2/projects").catch(async (error) => {
23
+ if (!asksForOrg(error)) throw error;
24
+ const orgs = await listOrganizations(api);
25
+ return (await Promise.all(orgs.map((org) => orgProjects(api, String(org.id))))).flat();
26
+ });
27
+ members = unique(members);
28
+ const seen = new Set(members.map(orgIdOf).filter((id) => id !== void 0));
29
+ const opened = readOpenedOrgs().filter((id) => !seen.has(id));
30
+ if (opened.length === 0) return members;
31
+ const reached = await Promise.all(opened.map((id) => {
32
+ return orgProjects(api, id).catch((error) => {
33
+ if (error instanceof ApiError && [
34
+ 400,
35
+ 403,
36
+ 404
37
+ ].includes(error.status)) return [];
38
+ throw error;
39
+ });
40
+ }));
41
+ writeOpenedOrgs(opened.filter((_, index) => (reached[index]?.length ?? 0) > 0));
42
+ return [...members, ...reached.flat()];
43
+ }
44
+ function unique(projects) {
45
+ return [...new Map(projects.map((project) => [String(project.id), project])).values()];
46
+ }
47
+ function rememberOrg(project) {
48
+ const id = project && orgIdOf(project);
49
+ if (id) writeOpenedOrgs([...readOpenedOrgs(), id]);
50
+ }
51
+ async function listOrgGroups(api) {
52
+ const [projects, memberships] = await Promise.all([listReachableProjects(api), listOrganizations(api).catch(() => [])]);
53
+ const members = new Map(memberships.map((org) => [String(org.id), org]));
54
+ const groups = /* @__PURE__ */ new Map();
55
+ for (const project of projects) {
56
+ const id = orgIdOf(project) ?? "";
57
+ const name = members.get(id)?.name;
58
+ const group = groups.get(id) ?? {
59
+ id,
60
+ name: typeof name === "string" ? name : void 0,
61
+ member: members.has(id) || id === "",
62
+ projects: []
63
+ };
64
+ group.projects.push(project);
65
+ groups.set(id, group);
66
+ }
67
+ await Promise.all([...groups.values()].filter((group) => !group.member && !group.name).map(async (group) => {
68
+ const org = await api.get(`/v2/organizations/${encodeURIComponent(group.id)}`).catch(() => void 0);
69
+ if (typeof org?.name === "string") group.name = org.name;
70
+ }));
71
+ return [...groups.values()].sort((a, b) => Number(b.member) - Number(a.member));
72
+ }
73
+ async function organizationOf(api, projectId, known) {
74
+ const local = known?.find((project) => String(project.id) === projectId);
75
+ const id = (local && orgIdOf(local)) ?? orgIdOf(await api.get(`/v2/projects/${encodeURIComponent(projectId)}`));
76
+ if (!id) throw new Error(`Couldn't tell which account project ${projectId} belongs to.`);
77
+ return id;
78
+ }
79
+
80
+ //#endregion
81
+ //#region src/core/json.ts
82
+ function isRecord(value) {
83
+ return typeof value === "object" && value !== null && !Array.isArray(value);
84
+ }
85
+ function parseJson(body) {
86
+ if (body.trim() === "") return void 0;
87
+ try {
88
+ return JSON.parse(body);
89
+ } catch {
90
+ return;
91
+ }
92
+ }
93
+ function field(value, key) {
94
+ return typeof value === "object" && value !== null ? Reflect.get(value, key) : void 0;
95
+ }
96
+ function textField(value, key) {
97
+ const found = field(value, key);
98
+ return typeof found === "string" && found.trim() !== "" ? found.trim() : void 0;
99
+ }
100
+ function listField(value, key) {
101
+ const found = field(value, key);
102
+ return Array.isArray(found) ? found : [];
103
+ }
104
+
105
+ //#endregion
1
106
  //#region src/core/api/resources.ts
2
107
  const RESOURCES = {
3
108
  products: "/v2/products",
@@ -15,7 +120,7 @@ function isAppScoped(name) {
15
120
  return RESOURCE_SCOPE[name] === "application";
16
121
  }
17
122
  function titleCase(s) {
18
- return s ? s[0].toUpperCase() + s.slice(1).toLowerCase() : s;
123
+ return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
19
124
  }
20
125
  function platformLabel(platform) {
21
126
  switch ((platform ?? "").toLowerCase()) {
@@ -25,12 +130,11 @@ function platformLabel(platform) {
25
130
  case "react_native":
26
131
  case "react-native": return "React Native";
27
132
  case "web": return "Web";
28
- default: return platform ? platform[0].toUpperCase() + platform.slice(1) : "?";
133
+ default: return platform ? platform.charAt(0).toUpperCase() + platform.slice(1) : "?";
29
134
  }
30
135
  }
31
136
  async function listProjects(api) {
32
- const org = api.org?.id;
33
- return api.list(org ? `/v2/projects?organization_id=${encodeURIComponent(org)}` : "/v2/projects");
137
+ return listReachableProjects(api);
34
138
  }
35
139
  async function listApplications(api) {
36
140
  return (await listProjects(api)).flatMap((p) => p.applications ?? []);
@@ -51,6 +155,7 @@ function createEntitlement(api, scope, identifier) {
51
155
  function createProduct(api, scope, identifier, opts = {}) {
52
156
  return api.post("/v2/products", {
53
157
  project_id: scope.projectId,
158
+ ...opts.applicationId ? { application_id: opts.applicationId } : {},
54
159
  identifier,
55
160
  ...opts.name ? { name: opts.name } : {},
56
161
  ...opts.price ? { price: opts.price } : {},
@@ -58,15 +163,10 @@ function createProduct(api, scope, identifier, opts = {}) {
58
163
  ...opts.entitlements?.length ? { entitlements: opts.entitlements } : {}
59
164
  });
60
165
  }
61
- async function listOrganizations(api) {
62
- return (await api.get("/v2/me/organizations")).data ?? [];
63
- }
64
- function createProject(api, name) {
65
- const orgId = api.org.id;
66
- if (!orgId) throw new Error("No organization selected - run `superwall orgs use <id|name>` first.");
166
+ function createProject(api, name, organizationId) {
67
167
  return api.post("/v2/projects", {
68
168
  name,
69
- organization_id: Number(orgId)
169
+ organization_id: Number(organizationId)
70
170
  });
71
171
  }
72
172
  function createApplication(api, scope, opts) {
@@ -89,9 +189,6 @@ function createCampaign(api, scope, description, placement) {
89
189
  }] }]
90
190
  });
91
191
  }
92
- function addPlacement(api, campaignId, placement) {
93
- return api.post(`/v2/campaigns/${campaignId}/placements`, { event_name: placement });
94
- }
95
192
  function rowName(row) {
96
193
  for (const key of [
97
194
  "name",
@@ -108,25 +205,24 @@ function rowName(row) {
108
205
  return String(row.id ?? " - ");
109
206
  }
110
207
  async function listAppPaywalls(api, applicationId, options = {}) {
111
- return (await api.list(`/v2/paywalls?application_id=${encodeURIComponent(applicationId)}` + (options.archived ? "&archived=true" : ""))).map((row) => {
112
- const metadata = {};
113
- if (typeof row.metadata === "object" && row.metadata !== null) {
114
- for (const [key, value] of Object.entries(row.metadata)) if (typeof value === "string") metadata[key] = value;
115
- }
116
- return {
117
- id: String(row.id),
118
- identifier: typeof row.identifier === "string" ? row.identifier : void 0,
119
- archived: options.archived === true,
120
- metadata
121
- };
122
- });
208
+ return (await api.list(`/v2/paywalls?application_id=${encodeURIComponent(applicationId)}` + (options.archived ? "&archived=true" : ""))).map((row) => ({
209
+ id: String(row.id),
210
+ identifier: typeof row.identifier === "string" ? row.identifier : void 0,
211
+ archived: options.archived === true,
212
+ metadata: parseMetadata(row.metadata)
213
+ }));
214
+ }
215
+ function parseMetadata(value) {
216
+ const metadata = {};
217
+ if (!isRecord(value)) return metadata;
218
+ for (const [key, entry] of Object.entries(value)) if (typeof entry === "string") metadata[key] = entry;
219
+ return metadata;
123
220
  }
124
- const productRefsOf = (value) => {
221
+ function parseProductRefs(value) {
125
222
  if (!Array.isArray(value)) return [];
126
223
  const refs = [];
127
- for (const entry of value) {
128
- if (typeof entry !== "object" || entry === null) continue;
129
- const row = entry;
224
+ for (const row of value) {
225
+ if (!isRecord(row)) continue;
130
226
  if (typeof row.reference_name !== "string" || typeof row.identifier !== "string") continue;
131
227
  refs.push({
132
228
  reference: row.reference_name,
@@ -135,20 +231,16 @@ const productRefsOf = (value) => {
135
231
  });
136
232
  }
137
233
  return refs;
138
- };
139
- async function getPaywall(api, paywallId) {
234
+ }
235
+ async function findPaywall(api, paywallId) {
140
236
  const row = await api.get(`/v2/paywalls/${encodeURIComponent(paywallId)}`);
141
- const metadata = {};
142
- if (typeof row.metadata === "object" && row.metadata !== null) {
143
- for (const [key, value] of Object.entries(row.metadata)) if (typeof value === "string") metadata[key] = value;
144
- }
145
237
  const applicationId = row.application_id;
146
238
  return {
147
239
  id: String(row.id ?? paywallId),
148
240
  identifier: typeof row.identifier === "string" ? row.identifier : void 0,
149
241
  name: typeof row.name === "string" ? row.name : void 0,
150
242
  archived: row.archived === true,
151
- metadata,
243
+ metadata: parseMetadata(row.metadata),
152
244
  applicationId: typeof applicationId === "string" || typeof applicationId === "number" ? String(applicationId) : void 0,
153
245
  projectId: typeof row.project_id === "string" || typeof row.project_id === "number" ? String(row.project_id) : void 0,
154
246
  platform: typeof row.application_platform === "string" ? row.application_platform : void 0,
@@ -158,28 +250,28 @@ async function getPaywall(api, paywallId) {
158
250
  headless: row.headless === true,
159
251
  presentationStyle: typeof row.presentation_style === "string" ? row.presentation_style : void 0,
160
252
  featureGating: typeof row.feature_gating === "string" ? row.feature_gating : void 0,
161
- products: productRefsOf(row.products)
253
+ products: parseProductRefs(row.products)
162
254
  };
163
255
  }
164
- async function projectOrganizationId(api, projectId) {
165
- const organization = (await api.get(`/v2/projects/${encodeURIComponent(projectId)}`)).organization_id;
166
- return typeof organization === "string" || typeof organization === "number" ? String(organization) : void 0;
167
- }
168
256
  const SNAPSHOT_IN_URL = /([a-f0-9]{64})\.html/;
169
257
  async function livePaywall(api, paywallId) {
170
- return getPaywall(api, paywallId).then((paywall) => ({
258
+ return findPaywall(api, paywallId).then((paywall) => ({
171
259
  version: paywall.version,
172
260
  snapshotId: paywall.url?.match(SNAPSHOT_IN_URL)?.[1]
173
- }), () => ({}));
261
+ }), (error) => {
262
+ if (error instanceof ApiUnreachableError) return {};
263
+ if (error instanceof ApiError && error.status >= 500) return {};
264
+ throw error;
265
+ });
266
+ }
267
+ async function pushedProducts(api, paywallId, snapshotId) {
268
+ const body = await api.get(`/v2/paywalls/${encodeURIComponent(paywallId)}/versions`);
269
+ const pushed = (Array.isArray(body.data) ? body.data.filter(isRecord) : []).filter((row) => row.snapshot_id === snapshotId && typeof row.version === "number").sort((a, b) => Number(b.version) - Number(a.version))[0];
270
+ return pushed === void 0 ? void 0 : parseProductRefs(pushed.products);
174
271
  }
175
272
  async function livePaywallVersion(api, paywallId) {
176
273
  return livePaywall(api, paywallId).then((live) => live.version);
177
274
  }
178
- async function getPaywallApplicationId(api, paywallId) {
179
- const { applicationId } = await getPaywall(api, paywallId);
180
- if (applicationId !== void 0) return applicationId;
181
- throw new Error(`Superwall returned no application for paywall ${paywallId}.`);
182
- }
183
275
  async function createHeadlessPaywall(api, opts) {
184
276
  const row = await api.post("/v2/paywalls", {
185
277
  application_id: opts.applicationId,
@@ -194,11 +286,26 @@ async function createHeadlessPaywall(api, opts) {
194
286
  metadata: {}
195
287
  };
196
288
  }
197
- const versionProducts = (products, platform) => Object.entries(products ?? {}).map(([reference, identifier]) => ({
198
- store: /^(test|live):price_[^:]+/.test(identifier) ? "stripe" : platform === "android" ? "play-store" : "app-store",
199
- identifier,
200
- reference_name: reference
201
- }));
289
+ function platformStore(platform) {
290
+ return platform === "android" ? "play-store" : "app-store";
291
+ }
292
+ function resolveStore(identifier, platform, known) {
293
+ if (/^(test|live):price_[^:]+/.test(identifier)) return "stripe";
294
+ const fallback = platformStore(platform);
295
+ if (known.includes(fallback)) return fallback;
296
+ if (known.includes("custom")) return "custom";
297
+ if (known.includes("stripe")) return "stripe";
298
+ return fallback;
299
+ }
300
+ function versionProducts(products, platform, stores = {}) {
301
+ return Object.entries(products ?? {}).map(([reference, identifier]) => {
302
+ return {
303
+ store: resolveStore(identifier, platform, Object.hasOwn(stores, identifier) ? stores[identifier] ?? [] : []),
304
+ identifier,
305
+ reference_name: reference
306
+ };
307
+ });
308
+ }
202
309
  function pushPaywallVersion(api, paywallId, opts) {
203
310
  return api.post(`/v2/paywalls/${encodeURIComponent(paywallId)}/versions`, {
204
311
  html: opts.html,
@@ -257,4 +364,4 @@ function promotePaywallVersion(api, paywallId, opts = {}) {
257
364
  }
258
365
 
259
366
  //#endregion
260
- export { pushPaywallAssets as C, versionProducts as D, titleCase as E, promotePaywallVersion as S, rowName as T, livePaywall as _, createHeadlessPaywall as a, platformLabel as b, getPaywall as c, linkSourceCommit as d, listAppPaywalls as f, listResource as g, listProjects as h, createEntitlement as i, getPaywallApplicationId as l, listOrganizations as m, createApplication as n, createProduct as o, listApplications as p, createCampaign as r, createProject as s, addPlacement as t, isAppScoped as u, livePaywallVersion as v, pushPaywallVersion as w, projectOrganizationId as x, mintSourceAccess as y };
367
+ export { parseJson as A, pushedProducts as C, field as D, versionProducts as E, orgProjects as F, organizationOf as I, rememberOrg as L, listOrgGroups as M, listOrganizations as N, isRecord as O, orgIdOf as P, pushPaywallVersion as S, titleCase as T, mintSourceAccess as _, createHeadlessPaywall as a, promotePaywallVersion as b, findPaywall as c, listAppPaywalls as d, listApplications as f, livePaywallVersion as g, livePaywall as h, createEntitlement as i, textField as j, listField as k, isAppScoped as l, listResource as m, createApplication as n, createProduct as o, listProjects as p, createCampaign as r, createProject as s, RESOURCES as t, linkSourceCommit as u, platformLabel as v, rowName as w, pushPaywallAssets as x, platformStore as y };
@@ -1,13 +1,12 @@
1
- import { f as DASHBOARD_URL } from "./output-C4o2gJ1K.js";
2
- import { s as packagedDir } from "./skills-DPzlnfCK.js";
3
- import { join } from "node:path";
4
- import { readFileSync } from "node:fs";
1
+ import { c as DASHBOARD_URL } from "./environment-eBXjELoN.js";
2
+ import { i as packagedDir } from "./paths-CRlU72cq.js";
5
3
  import { spawn } from "node:child_process";
4
+ import { readFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
6
 
7
- //#region src/clipboard.ts
7
+ //#region src/ui/clipboard.ts
8
8
  async function copyToClipboard(text) {
9
- const cmd = clipboardCommand();
10
- if (!cmd) return false;
9
+ const cmd = resolveClipboardCommand();
11
10
  return new Promise((resolve$1) => {
12
11
  try {
13
12
  const child = spawn(cmd.command, cmd.args, { stdio: [
@@ -25,7 +24,7 @@ async function copyToClipboard(text) {
25
24
  }
26
25
  });
27
26
  }
28
- function clipboardCommand() {
27
+ function resolveClipboardCommand() {
29
28
  switch (process.platform) {
30
29
  case "darwin": return {
31
30
  command: "pbcopy",
@@ -43,14 +42,9 @@ function clipboardCommand() {
43
42
  }
44
43
 
45
44
  //#endregion
46
- //#region src/core/agent/prompt.ts
45
+ //#region src/core/workflows/agent/prompt.ts
47
46
  const cache = /* @__PURE__ */ new Map();
48
- /**
49
- * Load a prompt from prompts/ and interpolate it.
50
- * `{{#var}}…{{/var}}` blocks are kept only when `vars[var]` is non-empty;
51
- * `{{var}}` is a plain substitution and throws when the variable is missing.
52
- */
53
- function loadPrompt(rel, vars = {}) {
47
+ function readPrompt(rel, vars = {}) {
54
48
  let raw = cache.get(rel);
55
49
  if (raw === void 0) {
56
50
  raw = readFileSync(join(packagedDir("prompts"), rel), "utf8");
@@ -62,11 +56,11 @@ function loadPrompt(rel, vars = {}) {
62
56
  return value;
63
57
  }).replace(/\n{3,}/g, "\n\n").trim();
64
58
  }
65
- function getCommandments() {
66
- return loadPrompt("commandments.xml");
59
+ function readCommandments() {
60
+ return readPrompt("commandments.xml");
67
61
  }
68
62
  function buildActionPrompt(action, ctx) {
69
- return `${loadPrompt("context.xml", {
63
+ return `${readPrompt("context.xml", {
70
64
  platform: `${ctx.app.framework.name}${ctx.app.details ? ` (${ctx.app.details})` : ""}`,
71
65
  app_dir: ctx.app.path,
72
66
  api_key: ctx.apiKey || "(not provided)",
@@ -74,19 +68,19 @@ function buildActionPrompt(action, ctx) {
74
68
  configure_present: ctx.existing.configureFound ? "yes" : "no",
75
69
  docs_url: ctx.app.framework.docsUrl,
76
70
  dashboard_url: DASHBOARD_URL
77
- })}\n\n${loadPrompt(`actions/${action.id}.xml`, action.vars(ctx))}`;
71
+ })}\n\n${readPrompt(`actions/${action.id}.xml`, action.vars(ctx))}`;
78
72
  }
79
73
  function buildCopyPrompt(action, ctx) {
80
74
  return buildActionPrompt(action, ctx).split("\n").filter((line) => !line.includes("[STATUS]")).join("\n").trimEnd();
81
75
  }
82
76
 
83
77
  //#endregion
84
- //#region src/core/agent/run.ts
78
+ //#region src/core/workflows/agent/run.ts
85
79
  async function runAction(opts) {
86
80
  return runWithDriverFallback([opts.driver, ...opts.fallbackDrivers ?? []], {
87
81
  prompt: buildActionPrompt(opts.action, opts.ctx),
88
82
  cwd: opts.ctx.app.path,
89
- systemAppend: getCommandments(),
83
+ systemAppend: readCommandments(),
90
84
  capabilities: opts.action.capabilities,
91
85
  onEvent: opts.onEvent,
92
86
  signal: opts.signal
@@ -103,4 +97,4 @@ async function runWithDriverFallback(drivers, options) {
103
97
  }
104
98
 
105
99
  //#endregion
106
- export { copyToClipboard as a, loadPrompt as i, runWithDriverFallback as n, buildCopyPrompt as r, runAction as t };
100
+ export { copyToClipboard as a, readPrompt as i, runWithDriverFallback as n, buildCopyPrompt as r, runAction as t };
@@ -0,0 +1,4 @@
1
+ import "./environment-eBXjELoN.js";
2
+ import { t as scanProject } from "./scan-CKuk-_6W.js";
3
+
4
+ export { scanProject };
@@ -1,9 +1,26 @@
1
- import { g as Integration } from "./output-C4o2gJ1K.js";
2
- import { basename, dirname, join, relative, sep } from "node:path";
1
+ import { f as Integration } from "./environment-eBXjELoN.js";
3
2
  import { existsSync, readFileSync } from "node:fs";
3
+ import { basename, dirname, join, relative, sep } from "node:path";
4
4
  import fg from "fast-glob";
5
5
 
6
- //#region src/core/project/frameworks.ts
6
+ //#region src/core/codebase/package.ts
7
+ function readPackageJson(dir) {
8
+ try {
9
+ return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
10
+ } catch {
11
+ return null;
12
+ }
13
+ }
14
+ function allDeps(pkg) {
15
+ if (!pkg) return {};
16
+ return {
17
+ ...pkg.dependencies ?? {},
18
+ ...pkg.devDependencies ?? {}
19
+ };
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/core/codebase/frameworks.ts
7
24
  const frameworkByIntegration = {
8
25
  [Integration.swift]: {
9
26
  integration: Integration.swift,
@@ -49,27 +66,10 @@ const frameworkByIntegration = {
49
66
  }
50
67
  };
51
68
  const supportedNames = Object.values(frameworkByIntegration).filter((f) => f.supported).map((f) => f.name);
52
- const SUPPORTED_LABEL = supportedNames.length > 1 ? `${supportedNames.slice(0, -1).join(", ")}, or ${supportedNames.at(-1)}` : supportedNames[0] ?? "";
53
-
54
- //#endregion
55
- //#region src/core/project/package.ts
56
- function readPackageJson(dir) {
57
- try {
58
- return JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
59
- } catch {
60
- return null;
61
- }
62
- }
63
- function allDeps(pkg) {
64
- if (!pkg) return {};
65
- return {
66
- ...pkg.dependencies ?? {},
67
- ...pkg.devDependencies ?? {}
68
- };
69
- }
69
+ const SUPPORTED_LABEL = `${supportedNames.slice(0, -1).join(", ")}, or ${supportedNames.at(-1)}`;
70
70
 
71
71
  //#endregion
72
- //#region src/core/project/scan.ts
72
+ //#region src/core/codebase/scan.ts
73
73
  const IGNORE = [
74
74
  "**/node_modules/**",
75
75
  "**/.git/**",
@@ -130,9 +130,15 @@ function androidUiKind(dir, gradle) {
130
130
  absolute: true,
131
131
  deep: 8
132
132
  });
133
- for (const f of files.slice(0, 300)) try {
134
- if (readFileSync(f, "utf8").includes("@Composable")) return "Jetpack Compose";
135
- } catch {}
133
+ for (const f of files.slice(0, 300)) {
134
+ let content;
135
+ try {
136
+ content = readFileSync(f, "utf8");
137
+ } catch {
138
+ continue;
139
+ }
140
+ if (content.includes("@Composable")) return "Jetpack Compose";
141
+ }
136
142
  return "Views";
137
143
  }
138
144
  const ANDROID_APP_PLUGIN = /com\.android\.application|alias\(libs\.plugins\.android\.application\)|libs\.plugins\.androidApplication/;
@@ -146,12 +152,17 @@ function swiftUiKind(dir) {
146
152
  let swiftui = false;
147
153
  let uikit = false;
148
154
  for (const f of files.slice(0, 300)) {
155
+ let content;
149
156
  try {
150
- const c = readFileSync(f, "utf8");
151
- if (c.includes("import SwiftUI")) swiftui = true;
152
- else if (c.includes("import UIKit")) uikit = true;
153
- } catch {}
154
- if (swiftui) break;
157
+ content = readFileSync(f, "utf8");
158
+ } catch {
159
+ continue;
160
+ }
161
+ if (content.includes("import SwiftUI")) {
162
+ swiftui = true;
163
+ break;
164
+ }
165
+ if (content.includes("import UIKit")) uikit = true;
155
166
  }
156
167
  if (swiftui) return "SwiftUI";
157
168
  if (uikit) return "UIKit";
@@ -172,7 +183,7 @@ function isGeneratedNative(swiftDir, jsRoots) {
172
183
  function isLibraryPath(dir) {
173
184
  return dir.includes(`${sep}packages${sep}`) || dir.includes(`${sep}libs${sep}`) || dir.includes(`${sep}node_modules${sep}`);
174
185
  }
175
- function makeApp(root, dir, c) {
186
+ function createDetectedApp(root, dir, c) {
176
187
  const rel = relative(root, dir) || ".";
177
188
  return {
178
189
  path: dir,
@@ -185,7 +196,7 @@ function makeApp(root, dir, c) {
185
196
  };
186
197
  }
187
198
  function looksLikeMonorepoRoot(root) {
188
- return existsSync(join(root, "turbo.json")) || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "nx.json")) || existsSync(join(root, "lerna.json")) || Array.isArray((readPackageJson(root) ?? {}).workspaces) || typeof (readPackageJson(root) ?? {}).workspaces === "object";
199
+ return existsSync(join(root, "turbo.json")) || existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "nx.json")) || existsSync(join(root, "lerna.json")) || typeof readPackageJson(root)?.workspaces === "object";
189
200
  }
190
201
  async function scanProject(root) {
191
202
  const opts = {
@@ -211,7 +222,7 @@ async function scanProject(root) {
211
222
  for (const dir of jsRoots) {
212
223
  if (isLibraryPath(dir)) continue;
213
224
  const c = classifyJs(dir);
214
- if (c) apps.push(makeApp(root, dir, c));
225
+ if (c) apps.push(createDetectedApp(root, dir, c));
215
226
  else if (dir !== root) skipped.push(basename(dir));
216
227
  }
217
228
  const swiftDirs = /* @__PURE__ */ new Set();
@@ -224,7 +235,7 @@ async function scanProject(root) {
224
235
  for (const t of tuistProjects) swiftDirs.add(dirname(join(root, t)));
225
236
  for (const dir of swiftDirs) {
226
237
  if (isGeneratedNative(dir, jsRootSet)) continue;
227
- apps.push(makeApp(root, dir, {
238
+ apps.push(createDetectedApp(root, dir, {
228
239
  integration: Integration.swift,
229
240
  details: swiftUiKind(dir),
230
241
  score: .95
@@ -242,7 +253,7 @@ async function scanProject(root) {
242
253
  if (!gradle.split("\n").some((line) => ANDROID_APP_PLUGIN.test(line) && !/apply\s+false/.test(line))) continue;
243
254
  const moduleDir = dirname(file);
244
255
  if (isGeneratedNative(moduleDir, nativeRoots)) continue;
245
- apps.push(makeApp(root, moduleDir, {
256
+ apps.push(createDetectedApp(root, moduleDir, {
246
257
  integration: Integration.android,
247
258
  details: androidUiKind(moduleDir, gradle),
248
259
  score: .95
@@ -250,7 +261,7 @@ async function scanProject(root) {
250
261
  }
251
262
  for (const p of pubspecs) {
252
263
  const dir = dirname(join(root, p));
253
- apps.push(makeApp(root, dir, {
264
+ apps.push(createDetectedApp(root, dir, {
254
265
  integration: Integration.flutter,
255
266
  score: .9
256
267
  }));
@@ -273,4 +284,4 @@ async function scanProject(root) {
273
284
  }
274
285
 
275
286
  //#endregion
276
- export { SUPPORTED_LABEL as i, allDeps as n, readPackageJson as r, scanProject as t };
287
+ export { readPackageJson as i, SUPPORTED_LABEL as n, allDeps as r, scanProject as t };