@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,294 @@
1
+ import { r as NotLoggedInError } from "./token-DzRh7dI1.js";
2
+ import { i as writeJson, n as createCommandOutput } from "./output-Ggzq5_-t.js";
3
+ import { a as CHANNEL } from "./environment-DF1qKlny.js";
4
+ import { t as ApiError } from "./client-DP6Rc0t_.js";
5
+ import { n as ui, r as useRenderer } from "./ui-D_qf3Gvw.js";
6
+ import pc from "picocolors";
7
+
8
+ //#region src/program/host.ts
9
+ let installed;
10
+ function useHost(host) {
11
+ installed = host;
12
+ }
13
+ function currentHost() {
14
+ if (!installed) throw new Error("No host is installed: the terminal or the MCP server installs one before a command runs.");
15
+ return installed;
16
+ }
17
+ function readInput(path) {
18
+ return currentHost().readInput(path);
19
+ }
20
+
21
+ //#endregion
22
+ //#region src/program/lifecycle.ts
23
+ function textOf(value) {
24
+ if (typeof value === "number") return String(value);
25
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
26
+ }
27
+ async function runLifecycle(description, input, runtime, work) {
28
+ const host = {
29
+ ...currentHost(),
30
+ ...runtime
31
+ };
32
+ const flags = input.flags ?? {};
33
+ const json = input.json === true;
34
+ const outputMode = json ? "json" : host.nonInteractive ? "text" : "rich";
35
+ const interactive = description.prompts && !json && input.interactive !== false && !host.nonInteractive;
36
+ const installDir = host.installDir(textOf(flags.installDir));
37
+ const ui$1 = useRenderer(host.renderer(outputMode));
38
+ const { stdout } = host;
39
+ const output = createCommandOutput(outputMode, ui$1, { stdout });
40
+ if (json && !description.json) {
41
+ writeJson(stdout, { error: {
42
+ code: "json_not_supported",
43
+ message: `${description.name} does not support --json.`
44
+ } });
45
+ host.fail();
46
+ return;
47
+ }
48
+ const startedAt = Date.now();
49
+ const base = {
50
+ command: description.name,
51
+ auth: description.auth,
52
+ json,
53
+ prompts: interactive,
54
+ dry_run: flags.dryRun === true,
55
+ skill: flags.skill === true
56
+ };
57
+ ui$1.start();
58
+ const offInterrupt = ui$1.onInterrupt?.(() => {
59
+ ui$1.stop();
60
+ process.stderr.write("\n✗ Cancelled.\n");
61
+ process.exit(130);
62
+ });
63
+ host.starting(ui$1, outputMode);
64
+ host.track("command started", base);
65
+ try {
66
+ const api = resolveApi(description.auth, host.api);
67
+ if (description.auth !== "none") base.logged_in = api !== void 0;
68
+ await work({
69
+ ui: ui$1,
70
+ output,
71
+ outputMode,
72
+ interactive,
73
+ installDir,
74
+ json,
75
+ dryRun: flags.dryRun === true,
76
+ target: {
77
+ app: textOf(flags.app),
78
+ project: textOf(flags.project)
79
+ },
80
+ fail: host.fail,
81
+ ...api ? { api } : {}
82
+ });
83
+ host.track("command finished", {
84
+ ...base,
85
+ status: "success",
86
+ duration_ms: Date.now() - startedAt
87
+ });
88
+ } catch (error) {
89
+ renderError(ui$1, outputMode, stdout, error);
90
+ host.fail();
91
+ const { code, status } = normalizeError(error);
92
+ host.track("command finished", {
93
+ ...base,
94
+ status: "error",
95
+ error_code: code,
96
+ ...status === void 0 ? {} : { http_status: status },
97
+ duration_ms: Date.now() - startedAt
98
+ });
99
+ } finally {
100
+ offInterrupt?.();
101
+ if (outputMode === "rich" && host.waitForPaint) await new Promise((done) => setTimeout(done, 50));
102
+ ui$1.stop();
103
+ host.finishing(stdout, outputMode, description.name);
104
+ }
105
+ }
106
+ function resolveApi(policy, factory) {
107
+ if (policy === "required") return factory();
108
+ if (policy === "optional") try {
109
+ return factory();
110
+ } catch (error) {
111
+ if (error instanceof NotLoggedInError) return void 0;
112
+ throw error;
113
+ }
114
+ }
115
+ function renderError(ui$1, mode, stdout, error) {
116
+ const { code, message, status } = normalizeError(error);
117
+ if (mode === "json") {
118
+ writeJson(stdout, { error: {
119
+ code,
120
+ message,
121
+ ...status === void 0 ? {} : { status }
122
+ } });
123
+ return;
124
+ }
125
+ ui$1.error([message, ...errorAside(error)].join("\n"));
126
+ }
127
+ function errorAside(error) {
128
+ const aside = [];
129
+ if (error instanceof ApiError) {
130
+ if (error.hint) aside.push(error.hint);
131
+ if (error.detail.docUrl) aside.push(error.detail.docUrl);
132
+ if (!error.envelope) aside.push(error.request);
133
+ }
134
+ return aside.map((line) => pc.dim(line));
135
+ }
136
+ function normalizeError(error) {
137
+ if (error instanceof NotLoggedInError) return {
138
+ code: "not_logged_in",
139
+ message: "You aren't logged in. Run `superwall login` first."
140
+ };
141
+ if (error instanceof UsageError) return {
142
+ code: "invalid_arguments",
143
+ message: error.message
144
+ };
145
+ if (error instanceof ApiError) return {
146
+ code: "api_error",
147
+ message: error.message,
148
+ status: error.status
149
+ };
150
+ return {
151
+ code: "command_error",
152
+ message: error instanceof Error ? error.message : String(error)
153
+ };
154
+ }
155
+
156
+ //#endregion
157
+ //#region src/program/command.ts
158
+ function onChannel(specs) {
159
+ return Object.fromEntries(Object.entries(specs).filter(([, spec]) => spec.channel === void 0 || spec.channel === CHANNEL()));
160
+ }
161
+ function summaryOf(command) {
162
+ return command.summaryOn?.[CHANNEL()] ?? command.summary;
163
+ }
164
+ function examplesOf(command) {
165
+ return command.examples.filter(([, , channel]) => channel === void 0 || channel === CHANNEL());
166
+ }
167
+ var UsageError = class extends Error {
168
+ constructor(message, command) {
169
+ super(message);
170
+ this.command = command;
171
+ }
172
+ };
173
+ function flagName(key) {
174
+ const kebab = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
175
+ return kebab.length === 1 ? `-${kebab}` : `--${kebab}`;
176
+ }
177
+ function readFlag(key, spec, raw) {
178
+ const value = raw ?? spec.default;
179
+ if (spec.type === "boolean") return value === true;
180
+ if (spec.type === "list") {
181
+ if (value === void 0 || value === null) return [];
182
+ return (Array.isArray(value) ? value : [value]).map(String);
183
+ }
184
+ if (value === "" && spec.bare) return "";
185
+ if (value === void 0 || value === null || value === "") return void 0;
186
+ if (spec.type === "number") {
187
+ const number = Number(value);
188
+ if (!Number.isFinite(number)) throw new UsageError(`${flagName(key)} takes a number, not "${String(value)}".`);
189
+ return number;
190
+ }
191
+ const text = spec.verbatim ? String(value) : String(value).trim();
192
+ if (text.trim() === "") return void 0;
193
+ if (spec.choices && !spec.choices.includes(text)) throw new UsageError(`${flagName(key)} takes one of: ${spec.choices.join(", ")} (not "${text}").`);
194
+ return text;
195
+ }
196
+ function readArg(key, spec, raw) {
197
+ if (spec.variadic) {
198
+ const values = raw === void 0 || raw === null ? [] : (Array.isArray(raw) ? raw : [raw]).map(String);
199
+ if (spec.required && values.length === 0) throw new UsageError(`Missing <${key}>.`);
200
+ return values;
201
+ }
202
+ const text = raw === void 0 || raw === null ? "" : String(raw).trim();
203
+ if (text === "") {
204
+ if (spec.required) throw new UsageError(`Missing <${key}>.`);
205
+ return;
206
+ }
207
+ if (spec.choices && !spec.choices.includes(text)) throw new UsageError(`<${key}> is one of: ${spec.choices.join(", ")} (not "${text}").`);
208
+ return text;
209
+ }
210
+ function readValues(specs, raw, read) {
211
+ return Object.fromEntries(Object.entries(specs).map(([key, spec]) => [key, read(key, spec, raw[key])]));
212
+ }
213
+ function defineCommand(spec) {
214
+ const args = spec.args ?? {};
215
+ const flags = spec.flags ?? {};
216
+ const read = (input) => {
217
+ return {
218
+ args: readValues(onChannel(args), input.args ?? {}, readArg),
219
+ flags: readValues(onChannel(flags), input.flags ?? {}, readFlag)
220
+ };
221
+ };
222
+ return {
223
+ kind: "command",
224
+ name: spec.name,
225
+ summary: spec.summary,
226
+ summaryOn: spec.summaryOn,
227
+ details: spec.details,
228
+ examples: spec.examples,
229
+ auth: spec.auth,
230
+ json: spec.json,
231
+ prompts: spec.prompts,
232
+ mcp: spec.mcp,
233
+ channel: spec.channel,
234
+ args,
235
+ flags,
236
+ validate: (input) => {
237
+ read(input);
238
+ },
239
+ execute: (input, runtime = {}) => {
240
+ return runLifecycle(spec, input, runtime, (ctx) => spec.run(ctx, read(input)));
241
+ }
242
+ };
243
+ }
244
+ function defineCatalog(spec) {
245
+ return {
246
+ kind: "catalog",
247
+ name: spec.name,
248
+ summary: spec.summary,
249
+ summaryOn: spec.summaryOn,
250
+ details: spec.details,
251
+ examples: spec.examples,
252
+ auth: spec.auth,
253
+ json: spec.json,
254
+ prompts: spec.prompts,
255
+ mcp: spec.mcp,
256
+ channel: spec.channel,
257
+ flags: spec.flags ?? {},
258
+ operations: spec.operations,
259
+ help: spec.help,
260
+ tools: spec.tools,
261
+ execute: (input, runtime = {}) => {
262
+ return runLifecycle(spec, input, runtime, (ctx) => {
263
+ return spec.run(ctx, {
264
+ words: input.words ?? [],
265
+ flags: input.flags ?? {}
266
+ });
267
+ });
268
+ }
269
+ };
270
+ }
271
+
272
+ //#endregion
273
+ //#region src/ui/spinner.ts
274
+ async function spinWhile(spin, label, work) {
275
+ spin.start(label);
276
+ try {
277
+ const result = await work();
278
+ spin.stop(label);
279
+ return result;
280
+ } catch (e) {
281
+ spin.stop("Failed");
282
+ throw e;
283
+ }
284
+ }
285
+ function withSpinner(label, work) {
286
+ return spinWhile(ui.spinner(), label, work);
287
+ }
288
+ function apiCall(ctx, label, work) {
289
+ if (ctx.outputMode !== "rich") return work();
290
+ return spinWhile(ctx.ui.spinner(), label, work);
291
+ }
292
+
293
+ //#endregion
294
+ export { defineCommand as a, onChannel as c, readInput as d, useHost as f, defineCatalog as i, summaryOf as l, withSpinner as n, examplesOf as o, UsageError as r, flagName as s, apiCall as t, currentHost as u };
@@ -0,0 +1,16 @@
1
+ //#region src/core/account/storage.d.ts
2
+ interface Session {
3
+ authMethod?: "oauth" | "api_key";
4
+ apiKey?: string;
5
+ orgName?: string;
6
+ userEmail?: string;
7
+ host: string;
8
+ createdAt: string;
9
+ accessToken?: string;
10
+ refreshToken?: string;
11
+ accessTokenExpiresAt?: number;
12
+ tokenEndpoint?: string;
13
+ oauthClientId?: string;
14
+ }
15
+ //#endregion
16
+ export { Session as t };
@@ -0,0 +1,31 @@
1
+ import { l as readJson, r as formatJson, u as state } from "./output-Ggzq5_-t.js";
2
+ import { n as API_HOST_OVERRIDE, t as API_HOST } from "./environment-DF1qKlny.js";
3
+
4
+ //#region src/core/account/storage.ts
5
+ const sessionOrgName = (session) => {
6
+ return session?.authMethod === "api_key" ? session.orgName : void 0;
7
+ };
8
+ const FILE = "auth.json";
9
+ function writeSession(session) {
10
+ state().write(FILE, `${formatJson(session)}\n`);
11
+ }
12
+ function readSession() {
13
+ return readJson(state(), FILE) ?? null;
14
+ }
15
+ function removeSession() {
16
+ state().remove(FILE);
17
+ }
18
+ function resolveApiHost(session) {
19
+ return API_HOST_OVERRIDE() ?? session.host ?? API_HOST();
20
+ }
21
+ function serializeSession(session) {
22
+ return {
23
+ authenticated: true,
24
+ user: { email: session.userEmail ?? null },
25
+ credential: { type: session.apiKey ? "api_key" : session.accessToken ? "oauth" : "unknown" },
26
+ host: resolveApiHost(session)
27
+ };
28
+ }
29
+
30
+ //#endregion
31
+ export { sessionOrgName as a, serializeSession as i, removeSession as n, writeSession as o, resolveApiHost as r, readSession as t };
@@ -0,0 +1,16 @@
1
+ import "./token-DzRh7dI1.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-DF1qKlny.js";
4
+ import "./storage-s2Dnz-yl.js";
5
+ import "./client-DP6Rc0t_.js";
6
+ import "./config-BO1Y87kV.js";
7
+ import "./spinner-CneRK5rk.js";
8
+ import "./ui-D_qf3Gvw.js";
9
+ import "./resources-Dqr01Dep.js";
10
+ import "./org-D0g_q3mv.js";
11
+ import "./lookup-D-nmmAbw.js";
12
+ import "./scope-V336uz8j.js";
13
+ import "./input-vi0bou04.js";
14
+ import { n as writeStoreKit, t as generateStoreKit } from "./storekit-yY_kS2iR.js";
15
+
16
+ export { generateStoreKit, writeStoreKit };
@@ -0,0 +1,47 @@
1
+ import { r as formatJson } from "./output-Ggzq5_-t.js";
2
+ import { t as apiCall } from "./spinner-CneRK5rk.js";
3
+ import { m as listResource } from "./resources-Dqr01Dep.js";
4
+ import { a as pickScope } from "./scope-V336uz8j.js";
5
+ import { r as textOf } from "./input-vi0bou04.js";
6
+ import { writeFileSync } from "node:fs";
7
+
8
+ //#region src/core/main/storekit.ts
9
+ async function writeStoreKit(context, api, out) {
10
+ const scope = await pickScope(context, api, false);
11
+ const products = await apiCall(context, "Loading products", () => listResource(api, "products", scope));
12
+ const outFile = textOf(out) ?? "Superwall.storekit";
13
+ writeFileSync(outFile, `${formatJson(generateStoreKit(products))}\n`);
14
+ if (context.json) return context.output.data({
15
+ path: outFile,
16
+ products: products.length
17
+ });
18
+ context.ui.success(`Wrote \`${outFile}\` with ${products.length} product${products.length === 1 ? "" : "s"}`);
19
+ }
20
+ function generateStoreKit(products) {
21
+ return {
22
+ identifier: "SUPERWALL",
23
+ nonRenewingSubscriptions: [],
24
+ products: products.map((p) => String(p.identifier ?? p.product_identifier ?? p.name ?? "")).filter(Boolean).map((id, i) => ({
25
+ displayPrice: "9.99",
26
+ familyShareable: false,
27
+ internalID: String(1e3 + i),
28
+ localizations: [{
29
+ description: id,
30
+ displayName: id,
31
+ locale: "en_US"
32
+ }],
33
+ productID: id,
34
+ referenceName: id,
35
+ type: "NonConsumable"
36
+ })),
37
+ settings: { _applicationInternalID: "SUPERWALL" },
38
+ subscriptionGroups: [],
39
+ version: {
40
+ major: 3,
41
+ minor: 0
42
+ }
43
+ };
44
+ }
45
+
46
+ //#endregion
47
+ export { writeStoreKit as n, generateStoreKit as t };
@@ -0,0 +1,56 @@
1
+ import { _ as VERSION, b as isNonInteractive, g as TELEMETRY_KEY, h as TELEMETRY_HOST } from "./environment-DF1qKlny.js";
2
+ import { h as writeTelemetryNoticeShown, l as telemetryNoticeShown, t as readAnonymousId } from "./config-BO1Y87kV.js";
3
+
4
+ //#region src/core/support/telemetry.ts
5
+ const tags = {};
6
+ const pending = [];
7
+ function updateTelemetryTags(next) {
8
+ Object.assign(tags, next);
9
+ }
10
+ function isTelemetryEnabled(env, key) {
11
+ return Boolean(key) && !env.DO_NOT_TRACK && !env.SUPERWALL_TELEMETRY_DISABLED && !env.NODE_TEST_CONTEXT;
12
+ }
13
+ function telemetryEnabled() {
14
+ return isTelemetryEnabled(process.env, TELEMETRY_KEY());
15
+ }
16
+ function buildEvent(event, props, distinctId) {
17
+ return {
18
+ api_key: TELEMETRY_KEY(),
19
+ event,
20
+ distinct_id: distinctId,
21
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
22
+ properties: {
23
+ $process_person_profile: false,
24
+ cli_version: VERSION,
25
+ platform: process.platform,
26
+ ci: process.env.CI === "true",
27
+ interactive: !isNonInteractive(),
28
+ ...tags,
29
+ ...props
30
+ }
31
+ };
32
+ }
33
+ function track(event, props = {}) {
34
+ if (!telemetryEnabled()) return;
35
+ try {
36
+ const payload = buildEvent(event, props, readAnonymousId());
37
+ pending.push(fetch(`${TELEMETRY_HOST()}/capture/`, {
38
+ method: "POST",
39
+ headers: { "content-type": "application/json" },
40
+ body: JSON.stringify(payload),
41
+ signal: AbortSignal.timeout(1500)
42
+ }).catch(() => {}));
43
+ } catch {}
44
+ }
45
+ async function flushTelemetry(capMs = 2e3) {
46
+ if (pending.length === 0) return;
47
+ await Promise.race([Promise.allSettled(pending), new Promise((done) => setTimeout(done, capMs).unref())]);
48
+ }
49
+ function maybeShowTelemetryNotice(ui) {
50
+ if (!telemetryEnabled() || telemetryNoticeShown()) return;
51
+ writeTelemetryNoticeShown();
52
+ ui.info("The CLI collects anonymous usage data - no personal data, ever (see the README). Opt out with `SUPERWALL_TELEMETRY_DISABLED=1`.");
53
+ }
54
+
55
+ //#endregion
56
+ export { updateTelemetryTags as i, maybeShowTelemetryNotice as n, track as r, flushTelemetry as t };
@@ -0,0 +1,25 @@
1
+ import pc from "picocolors";
2
+
3
+ //#region src/ui/theme.ts
4
+ const THEME = {
5
+ primary: "#74FFF1",
6
+ alert: "#E46671"
7
+ };
8
+ function hexToRgb(hex) {
9
+ const h = hex.replace("#", "");
10
+ const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
11
+ const n = parseInt(full, 16);
12
+ return [
13
+ n >> 16 & 255,
14
+ n >> 8 & 255,
15
+ n & 255
16
+ ];
17
+ }
18
+ function fg(hex, text) {
19
+ if (!pc.isColorSupported) return text;
20
+ const [r, g, b] = hexToRgb(hex);
21
+ return `\x1b[38;2;${r};${g};${b}m${text}\x1b[39m`;
22
+ }
23
+
24
+ //#endregion
25
+ export { fg as n, THEME as t };
@@ -0,0 +1,5 @@
1
+ //#region src/core/timing.ts
2
+ const timing = { sleep: (ms) => new Promise((done) => setTimeout(done, ms)) };
3
+
4
+ //#endregion
5
+ export { timing as t };
@@ -1,9 +1,6 @@
1
- import { r as formatJson, v as SUPERWALL_HOME } from "./output-C4o2gJ1K.js";
2
- import { join } from "node:path";
3
- import { homedir } from "node:os";
4
- import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1
+ import { o as writeSession, t as readSession } from "./storage-s2Dnz-yl.js";
5
2
 
6
- //#region src/core/auth/errors.ts
3
+ //#region src/core/account/errors.ts
7
4
  var NotLoggedInError = class extends Error {
8
5
  constructor() {
9
6
  super("You aren't logged in. Run `superwall login` first.");
@@ -12,36 +9,7 @@ var NotLoggedInError = class extends Error {
12
9
  };
13
10
 
14
11
  //#endregion
15
- //#region src/core/auth/storage.ts
16
- function dir() {
17
- return SUPERWALL_HOME() ?? join(homedir(), ".superwall");
18
- }
19
- function file() {
20
- return join(dir(), "auth.json");
21
- }
22
- function saveSession(session) {
23
- mkdirSync(dir(), {
24
- recursive: true,
25
- mode: 448
26
- });
27
- writeFileSync(file(), `${formatJson(session)}\n`, { mode: 384 });
28
- }
29
- function loadSession() {
30
- try {
31
- if (!existsSync(file())) return null;
32
- return JSON.parse(readFileSync(file(), "utf8"));
33
- } catch {
34
- return null;
35
- }
36
- }
37
- function clearSession() {
38
- try {
39
- rmSync(file(), { force: true });
40
- } catch {}
41
- }
42
-
43
- //#endregion
44
- //#region src/core/auth/token.ts
12
+ //#region src/core/account/token.ts
45
13
  const EXPIRY_SKEW_MS = 6e4;
46
14
  function accessTokenIsFresh(session) {
47
15
  return session.accessTokenExpiresAt !== void 0 && session.accessTokenExpiresAt - EXPIRY_SKEW_MS > Date.now();
@@ -67,14 +35,14 @@ async function refreshAccessToken(session) {
67
35
  refreshToken: d.refresh_token ?? session.refreshToken,
68
36
  accessTokenExpiresAt: d.expires_in ? Date.now() + d.expires_in * 1e3 : void 0
69
37
  };
70
- saveSession(updated);
38
+ writeSession(updated);
71
39
  return updated;
72
40
  } catch {
73
41
  return null;
74
42
  }
75
43
  }
76
44
  async function getOAuthAccessToken() {
77
- const session = loadSession();
45
+ const session = readSession();
78
46
  if (!session?.accessToken || !session.refreshToken) return null;
79
47
  if (accessTokenIsFresh(session)) return session.accessToken;
80
48
  return (await refreshAccessToken(session))?.accessToken ?? null;
@@ -99,4 +67,4 @@ async function resolveAuthToken(session) {
99
67
  }
100
68
 
101
69
  //#endregion
102
- export { saveSession as a, loadSession as i, resolveAuthToken as n, NotLoggedInError as o, clearSession as r, getOAuthAccessToken as t };
70
+ export { resolveAuthToken as n, NotLoggedInError as r, getOAuthAccessToken as t };
@@ -0,0 +1,96 @@
1
+ import "./storage-DYvmIOHa.js";
2
+
3
+ //#region src/core/api/client.d.ts
4
+
5
+ interface RequestOptions {
6
+ headers?: Record<string, string>;
7
+ }
8
+ type SuperwallApi = {
9
+ readonly org: {
10
+ id?: string;
11
+ };
12
+ readonly userEmail: string | undefined;
13
+ readonly host: string;
14
+ forOrg(id: string): SuperwallApi;
15
+ get<T>(path: string, options?: RequestOptions): Promise<T>;
16
+ post<T>(path: string, body: unknown, options?: RequestOptions): Promise<T>;
17
+ put<T>(path: string, body: unknown, options?: RequestOptions): Promise<T>;
18
+ patch<T>(path: string, body: unknown, options?: RequestOptions): Promise<T>;
19
+ del<T>(path: string, options?: RequestOptions): Promise<T>;
20
+ postText(path: string, body: string): Promise<string>;
21
+ list<T>(path: string): Promise<T[]>;
22
+ };
23
+ //#endregion
24
+ //#region src/core/state/store.d.ts
25
+ interface Store {
26
+ read(name: string): string | undefined;
27
+ write(name: string, text: string): void;
28
+ remove(name: string): void;
29
+ }
30
+ //#endregion
31
+ //#region src/program/command.d.ts
32
+
33
+ interface JsonSchema {
34
+ type?: string | string[];
35
+ description?: string;
36
+ enum?: readonly unknown[];
37
+ items?: JsonSchema;
38
+ properties?: Record<string, JsonSchema>;
39
+ required?: string[];
40
+ additionalProperties?: boolean | JsonSchema;
41
+ }
42
+ //#endregion
43
+ //#region src/tools.d.ts
44
+ interface ToolAnnotations {
45
+ title: string;
46
+ readOnlyHint: boolean;
47
+ destructiveHint: boolean;
48
+ idempotentHint: boolean;
49
+ openWorldHint: boolean;
50
+ }
51
+ interface ToolResult {
52
+ ok: boolean;
53
+ data: unknown;
54
+ }
55
+ interface Tool {
56
+ name: string;
57
+ title: string;
58
+ description: string;
59
+ inputSchema: {
60
+ type: "object";
61
+ properties: Record<string, JsonSchema>;
62
+ required: string[];
63
+ additionalProperties: false;
64
+ };
65
+ annotations: ToolAnnotations;
66
+ run: (input: Record<string, unknown>, api: SuperwallApi) => Promise<ToolResult>;
67
+ cli: (input: Record<string, unknown>) => string[];
68
+ }
69
+ declare function apiFor({
70
+ token,
71
+ host
72
+ }: {
73
+ token: string;
74
+ host: string;
75
+ }): SuperwallApi;
76
+ declare function useToolCache(store: Store): void;
77
+ interface SkillFile {
78
+ uri: string;
79
+ name: string;
80
+ description: string;
81
+ text: string;
82
+ }
83
+ declare function listSkills(): SkillFile[];
84
+ declare function readSkill(uri: string): SkillFile | undefined;
85
+ declare function listTools(): Promise<Tool[]>;
86
+ declare function instructions(): string;
87
+ declare function callResult(result: ToolResult): {
88
+ content: {
89
+ type: "text";
90
+ text: string;
91
+ }[];
92
+ structuredContent?: Record<string, unknown>;
93
+ isError: boolean;
94
+ };
95
+ //#endregion
96
+ export { SkillFile, Tool, ToolAnnotations, ToolResult, apiFor, callResult, instructions, listSkills, listTools, readSkill, useToolCache };