@superwall/cli 2.6.0-beta.1 → 2.6.0-beta.2

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 (84) hide show
  1. package/dist/{apple-Bmt_iywx.js → apple-Dc5pOPms.js} +14 -14
  2. package/dist/{approve-D2UgqaRx.js → approve-BSbdmOez.js} +11 -8
  3. package/dist/{assets-B_quADds.js → assets-C_RjojkK.js} +3 -3
  4. package/dist/auth.js +3 -3
  5. package/dist/{base-ChTi42M0.js → base-83ZTv6up.js} +5 -5
  6. package/dist/{billing-ZIETn0j4.js → billing-B6HK-F_a.js} +3 -3
  7. package/dist/{bind-ClFjTt0U.js → bind-DcWIIPgk.js} +4 -4
  8. package/dist/{build-BWjXurjs.js → build-DK88pTMW.js} +8 -8
  9. package/dist/{client-CyrYJzBF.js → client-x08fpvay.js} +55 -5
  10. package/dist/{create-C3uklw-U.js → create-B6-Dr3GZ.js} +27 -27
  11. package/dist/create-Du8Fx7W5.js +20 -0
  12. package/dist/{create-BCIgjRHn.js → create-kpqEhqkk.js} +6 -6
  13. package/dist/{doctor-D2Q1EZe8.js → doctor-DYbm8IKQ.js} +6 -6
  14. package/dist/{drivers-BQkO5tHs.js → drivers-Dyi-y9Jn.js} +3 -3
  15. package/dist/entry.js +20 -20
  16. package/dist/{environment-BocmdvZ-.js → environment-BFNzLLPN.js} +1 -1
  17. package/dist/{existing-Cl5x6_5u.js → existing-WQ3pz94o.js} +2 -2
  18. package/dist/{framework-CLmf4swr.js → framework-JFLjmD5Y.js} +1 -1
  19. package/dist/held-DmOhszHR.js +17 -0
  20. package/dist/{held-Bykbwy-m.js → held-sKq3xrsT.js} +6 -6
  21. package/dist/{install-dXZZ79Oe.js → install-DsIsif39.js} +10 -10
  22. package/dist/{integrate-DiSjlOjC.js → integrate-B8eA676b.js} +22 -22
  23. package/dist/{login-5sWIKDI2.js → login-Blhxi20A.js} +6 -6
  24. package/dist/{login-Jp6E6d2e.js → login-BlpfYapG.js} +1 -1
  25. package/dist/login-D9jfRO8w.js +17 -0
  26. package/dist/{lookup-CWzVfPpq.js → lookup-Dg55W9S7.js} +3 -3
  27. package/dist/{migrate-BKiOUsMY.js → migrate-DoRb9jmA.js} +25 -25
  28. package/dist/{migration-Z69tLeHC.js → migration-BUedsREQ.js} +8 -8
  29. package/dist/{notification-url-BDBxbwZq.js → notification-url-D82msWF5.js} +2 -2
  30. package/dist/{open-DNd49kT-.js → open-BAqLpTSI.js} +2 -2
  31. package/dist/{org-Dud1rF9f.js → org-C4G7WjTV.js} +3 -3
  32. package/dist/{organization-7vJA3uy1.js → organization-CmuQwcKN.js} +3 -3
  33. package/dist/{orgs-Z0H9WOs1.js → orgs-1OzwUtpT.js} +1 -1
  34. package/dist/{paths-CzTJVpfi.js → paths-gBbqgkS7.js} +1 -1
  35. package/dist/{playbook-DJ__edOW.js → playbook-BKqlv77S.js} +10 -10
  36. package/dist/{promote-DLtPSvmL.js → promote-D0i8A0CO.js} +19 -19
  37. package/dist/pull-CO5HlqBe.js +36 -0
  38. package/dist/{pull-D-YuT3e0.js → pull-CiIrJ5ik.js} +27 -27
  39. package/dist/{pull-AoUmaiMK.js → pull-DgQ_UmGv.js} +6 -6
  40. package/dist/{push-BMblzg_6.js → push-7N4XIVtg.js} +6 -6
  41. package/dist/push-BIhGDNpL.js +30 -0
  42. package/dist/{push-BrzMFd4Z.js → push-BWsXO7FN.js} +11 -5
  43. package/dist/{push-B42D8fKf.js → push-BgqTddLA.js} +11 -11
  44. package/dist/{registry-DDU10_Ix.js → registry-aAR_8VOw.js} +52 -50
  45. package/dist/{resolve-DpOSDDdr.js → resolve-CcOpO_5s.js} +50 -4
  46. package/dist/{resources-CptT7HD6.js → resources-DNwvf8rg.js} +2 -2
  47. package/dist/{run-c1O2_8pp.js → run-B-YoyB-a.js} +2 -2
  48. package/dist/{run-r3foWfhV.js → run-tVYJ3V5j.js} +9 -9
  49. package/dist/scan-BU41gcQY.js +4 -0
  50. package/dist/{scan-nVQO7JLx.js → scan-dv0rrY4C.js} +1 -1
  51. package/dist/{scope-l1qGLsgz.js → scope-BXoQo30_.js} +5 -5
  52. package/dist/server-BemmM1FV.js +29 -0
  53. package/dist/{server-DLARhh1k.js → server-CcZGdYjE.js} +7 -7
  54. package/dist/session-4aITGsF1.js +6 -0
  55. package/dist/{session-Z0BeaJPf.js → session-dHBtgSN0.js} +1 -1
  56. package/dist/{setup-C6NFy14d.js → setup-m94dpT3t.js} +7 -7
  57. package/dist/skills/superwall-artifacts/SKILL.md +7 -2
  58. package/dist/skills/superwall-artifacts/references/cli.md +4 -1
  59. package/dist/{skills-CdKwaTRS.js → skills-Bqz2l_bx.js} +8 -8
  60. package/dist/{skills-421SFEyF.js → skills-Q7xB784d.js} +4 -4
  61. package/dist/{source-push-B4s6r9bB.js → source-push-CG948HrX.js} +4 -4
  62. package/dist/{spinner-DPdBlZe2.js → spinner-IA6hV8nI.js} +3 -3
  63. package/dist/{starter-0OdVPH4l.js → starter-BtUUQWhd.js} +14 -4
  64. package/dist/{status-Dsc7d3z2.js → status-CB_MrFu5.js} +6 -6
  65. package/dist/{storage-DT_wxwJ8.js → storage-pR0Wb0d9.js} +1 -1
  66. package/dist/storekit-BMxyYAHj.js +17 -0
  67. package/dist/{storekit-B9M2raxe.js → storekit-CQnwlpKV.js} +3 -3
  68. package/dist/{telemetry-ovPiseFm.js → telemetry-DU56L7Cy.js} +1 -1
  69. package/dist/{token-Bu3FaRkv.js → token-BbUeExGJ.js} +1 -1
  70. package/dist/tools.d.ts +5 -0
  71. package/dist/tools.js +61 -3
  72. package/dist/{try-B8FYkTvQ.js → try-CS3jLyoP.js} +13 -13
  73. package/dist/{upgrade-B7TmvEPP.js → upgrade-CKn88PZD.js} +2 -2
  74. package/dist/{upgrade-CAHyrWUL.js → upgrade-DfD3-ClG.js} +2 -2
  75. package/package.json +2 -2
  76. package/dist/create-7HDW3DCl.js +0 -20
  77. package/dist/held-Chw3BtBV.js +0 -17
  78. package/dist/login-DZ8Pipf6.js +0 -17
  79. package/dist/pull-C1xm2zqG.js +0 -36
  80. package/dist/push-Co5jk6Kr.js +0 -30
  81. package/dist/scan-D86kLtM7.js +0 -4
  82. package/dist/server-BEcsQaPu.js +0 -29
  83. package/dist/session-Csuaw6RU.js +0 -6
  84. package/dist/storekit-BWZf-fNE.js +0 -17
@@ -1,14 +1,14 @@
1
- import "./token-Bu3FaRkv.js";
1
+ import "./token-BbUeExGJ.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
3
+ import "./environment-BFNzLLPN.js";
4
+ import "./storage-pR0Wb0d9.js";
5
+ import "./client-x08fpvay.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
7
+ import "./telemetry-DU56L7Cy.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
9
+ import "./spinner-IA6hV8nI.js";
10
10
  import "./ui-D_qf3Gvw.js";
11
- import "./paths-CzTJVpfi.js";
12
- import { a as bundledSkills, c as knownSkills, d as readBundledSkill, f as runSkills, h as updateSkills, i as SUPERWALL_SKILLS_SOURCE, l as normalizeSkillFrontmatter, m as skillsRefFor, n as SKILLS_INSTALL_SOURCE, o as checkSkillsSync, p as skillSummary, r as SKILLS_REF, s as ensureSkillsCurrent, t as PLAYBOOKS, u as normalizeSkillsDir } from "./skills-421SFEyF.js";
11
+ import "./paths-gBbqgkS7.js";
12
+ import { a as bundledSkills, c as knownSkills, d as readBundledSkill, f as runSkills, h as updateSkills, i as SUPERWALL_SKILLS_SOURCE, l as normalizeSkillFrontmatter, m as skillsRefFor, n as SKILLS_INSTALL_SOURCE, o as checkSkillsSync, p as skillSummary, r as SKILLS_REF, s as ensureSkillsCurrent, t as PLAYBOOKS, u as normalizeSkillsDir } from "./skills-Q7xB784d.js";
13
13
 
14
14
  export { PLAYBOOKS, SKILLS_INSTALL_SOURCE, SKILLS_REF, SUPERWALL_SKILLS_SOURCE, bundledSkills, checkSkillsSync, ensureSkillsCurrent, knownSkills, normalizeSkillFrontmatter, normalizeSkillsDir, readBundledSkill, runSkills, skillSummary, skillsRefFor, updateSkills };
@@ -1,10 +1,10 @@
1
- import { c as CHANNELS, s as CHANNEL, x as VERSION } from "./environment-BocmdvZ-.js";
1
+ import { c as CHANNELS, s as CHANNEL, x as VERSION } from "./environment-BFNzLLPN.js";
2
2
  import { c as readSkillsSync, g as writeSkillsSync } from "./config-CGcG7GOt.js";
3
- import { r as track } from "./telemetry-ovPiseFm.js";
3
+ import { r as track } from "./telemetry-DU56L7Cy.js";
4
4
  import { r as spawnStream } from "./spawn-DmmmHIP-.js";
5
- import { n as withSpinner } from "./spinner-DPdBlZe2.js";
5
+ import { n as withSpinner } from "./spinner-IA6hV8nI.js";
6
6
  import { n as ui } from "./ui-D_qf3Gvw.js";
7
- import { i as packagedDir, t as AGENT_SKILLS_DIR } from "./paths-CzTJVpfi.js";
7
+ import { i as packagedDir, t as AGENT_SKILLS_DIR } from "./paths-gBbqgkS7.js";
8
8
  import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { tmpdir } from "node:os";
10
10
  import { join } from "node:path";
@@ -1,9 +1,9 @@
1
- import { n as ApiUnreachableError, t as ApiError } from "./client-CyrYJzBF.js";
1
+ import { n as ApiUnreachableError, t as ApiError } from "./client-x08fpvay.js";
2
2
  import { n as ui } from "./ui-D_qf3Gvw.js";
3
- import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-CptT7HD6.js";
4
- import { n as findApplication } from "./lookup-CWzVfPpq.js";
3
+ import { d as linkSourceCommit, f as listAppPaywalls, o as createHeadlessPaywall, v as mintSourceAccess } from "./resources-DNwvf8rg.js";
4
+ import { n as findApplication } from "./lookup-Dg55W9S7.js";
5
5
  import { f as writeBinding, l as readLock } from "./lock-DgSx-p8Y.js";
6
- import { n as writeSourceBase, t as readSourceBase } from "./base-ChTi42M0.js";
6
+ import { n as writeSourceBase, t as readSourceBase } from "./base-83ZTv6up.js";
7
7
  import { i as pushSourceTree, n as gitAvailable } from "./source-BccdO4aL.js";
8
8
  import { setTimeout } from "node:timers/promises";
9
9
  import { productVariables } from "@superwall/studio/products";
@@ -1,7 +1,7 @@
1
- import { r as NotLoggedInError } from "./token-Bu3FaRkv.js";
1
+ import { r as NotLoggedInError } from "./token-BbUeExGJ.js";
2
2
  import { i as writeJson, n as createCommandOutput } from "./output-Ggzq5_-t.js";
3
- import { s as CHANNEL } from "./environment-BocmdvZ-.js";
4
- import { t as ApiError } from "./client-CyrYJzBF.js";
3
+ import { s as CHANNEL } from "./environment-BFNzLLPN.js";
4
+ import { t as ApiError } from "./client-x08fpvay.js";
5
5
  import { n as ui, r as useRenderer } from "./ui-D_qf3Gvw.js";
6
6
  import pc from "picocolors";
7
7
 
@@ -127,17 +127,21 @@ function replaceDirectory(stage, target, rename = fs.renameSync) {
127
127
  force: true
128
128
  });
129
129
  }
130
+ /** Returns whether package.json had to change. */
130
131
  function pointPackageAtSdk(file) {
131
132
  const text = fs.readFileSync(file, "utf8");
132
133
  const parsed = JSON.parse(text);
133
- if (parsed.dependencies?.["@superwall/artifact-sdk"] === "file:vendor/artifact-sdk") return;
134
+ if (parsed.dependencies?.["@superwall/artifact-sdk"] === "file:vendor/artifact-sdk") return false;
134
135
  parsed.dependencies = {
135
136
  ...parsed.dependencies,
136
137
  "@superwall/artifact-sdk": "file:vendor/artifact-sdk"
137
138
  };
138
139
  const indent = /^([ \t]+)"/m.exec(text)?.[1] ?? " ";
139
140
  fs.writeFileSync(file, `${JSON.stringify(parsed, null, indent)}${text.endsWith("\n") ? "\n" : ""}`);
141
+ return true;
140
142
  }
143
+ const readIfPresent = (file) => fs.existsSync(file) ? fs.readFileSync(file, "utf8") : void 0;
144
+ const commitList = (files) => files.length === 1 ? files[0] : `${files.slice(0, -1).join(", ")} and ${files.at(-1)}`;
141
145
  function readStageVersion(stage) {
142
146
  const { version } = JSON.parse(fs.readFileSync(path.join(stage, "package.json"), "utf8"));
143
147
  if (typeof version !== "string") throw new RepoDownloadError("The downloaded artifact SDK has no version.");
@@ -173,17 +177,23 @@ async function runArtifactUpdate(ctx, input, runtime = {}) {
173
177
  });
174
178
  }
175
179
  spin.stop(before === version ? `Already on the latest artifact SDK, ${version}` : `Artifact SDK ${version}`);
176
- pointPackageAtSdk(packageFile);
180
+ const sdkChanged = before !== version;
181
+ const packageChanged = pointPackageAtSdk(packageFile);
182
+ const changed = [...sdkChanged ? ["vendor/artifact-sdk"] : [], ...packageChanged ? ["package.json"] : []];
177
183
  if (!input.install) {
178
- ctx.ui.info("Run `npm install` to update package-lock.json, then commit vendor/artifact-sdk and the lockfile.");
184
+ if (changed.length > 0) ctx.ui.info(`Run \`npm install\` to update package-lock.json, then commit ${commitList([...changed, "the lockfile"])}.`);
179
185
  return;
180
186
  }
187
+ const lockFile = path.join(root, "package-lock.json");
188
+ const lockBefore = readIfPresent(lockFile);
181
189
  try {
182
190
  await (runtime.install ?? npmInstall)(root);
183
- ctx.ui.success("Updated package-lock.json. Commit vendor/artifact-sdk and the lockfile.");
184
191
  } catch {
185
192
  ctx.ui.warn("`npm install` failed. Run it yourself to update package-lock.json.");
193
+ return;
186
194
  }
195
+ if (readIfPresent(lockFile) !== lockBefore) ctx.ui.success(`Updated package-lock.json. Commit ${commitList([...changed, "the lockfile"])}.`);
196
+ else if (changed.length > 0) ctx.ui.success(`Commit ${commitList(changed)}.`);
187
197
  }
188
198
 
189
199
  //#endregion
@@ -1,11 +1,11 @@
1
- import "./token-Bu3FaRkv.js";
1
+ import "./token-BbUeExGJ.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import { t as ApiError } from "./client-CyrYJzBF.js";
3
+ import "./environment-BFNzLLPN.js";
4
+ import "./storage-pR0Wb0d9.js";
5
+ import { t as ApiError } from "./client-x08fpvay.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import "./orgs-Z0H9WOs1.js";
8
- import { C as listVersions, S as listMembers, T as requestDeploy, a as newestFirst, d as visibilityOf, i as latestManifest, l as resolveArtifact, n as awaitingInstall, o as openLink, s as pickVersion, u as roleCanApprove, v as getBuild, y as getMe } from "./resolve-DpOSDDdr.js";
7
+ import "./orgs-1OzwUtpT.js";
8
+ import { D as requestDeploy, T as listVersions, a as latestManifest, b as getBuild, c as openLink, d as resolveArtifact, f as roleCanApprove, l as pickVersion, n as awaitingInstall, o as newestFirst, p as visibilityOf, w as listMembers, x as getMe } from "./resolve-CcOpO_5s.js";
9
9
  import { t as ArtifactError } from "./project-NoMtbMyl.js";
10
10
  import "./lock-DgSx-p8Y.js";
11
11
  import "./scope-ehZ7L1nj.js";
@@ -1,5 +1,5 @@
1
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-BocmdvZ-.js";
2
+ import { n as API_HOST_OVERRIDE, t as API_HOST } from "./environment-BFNzLLPN.js";
3
3
 
4
4
  //#region src/core/account/storage.ts
5
5
  const sessionOrgName = (session) => {
@@ -0,0 +1,17 @@
1
+ import "./token-BbUeExGJ.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-BFNzLLPN.js";
4
+ import "./storage-pR0Wb0d9.js";
5
+ import "./client-x08fpvay.js";
6
+ import "./config-CGcG7GOt.js";
7
+ import "./spinner-IA6hV8nI.js";
8
+ import "./ui-D_qf3Gvw.js";
9
+ import "./orgs-1OzwUtpT.js";
10
+ import "./resources-DNwvf8rg.js";
11
+ import "./org-C4G7WjTV.js";
12
+ import "./lookup-Dg55W9S7.js";
13
+ import "./scope-BXoQo30_.js";
14
+ import "./input-MDd67UIp.js";
15
+ import { n as writeStoreKit, t as generateStoreKit } from "./storekit-CQnwlpKV.js";
16
+
17
+ export { generateStoreKit, writeStoreKit };
@@ -1,7 +1,7 @@
1
1
  import { r as formatJson } from "./output-Ggzq5_-t.js";
2
- import { t as apiCall } from "./spinner-DPdBlZe2.js";
3
- import { h as listResource } from "./resources-CptT7HD6.js";
4
- import { a as pickScope } from "./scope-l1qGLsgz.js";
2
+ import { t as apiCall } from "./spinner-IA6hV8nI.js";
3
+ import { h as listResource } from "./resources-DNwvf8rg.js";
4
+ import { a as pickScope } from "./scope-BXoQo30_.js";
5
5
  import { r as textOf } from "./input-MDd67UIp.js";
6
6
  import { writeFileSync } from "node:fs";
7
7
 
@@ -1,4 +1,4 @@
1
- import { T as isNonInteractive, v as TELEMETRY_HOST, x as VERSION, y as TELEMETRY_KEY } from "./environment-BocmdvZ-.js";
1
+ import { T as isNonInteractive, v as TELEMETRY_HOST, x as VERSION, y as TELEMETRY_KEY } from "./environment-BFNzLLPN.js";
2
2
  import { _ as writeTelemetryNoticeShown, t as readAnonymousId, u as telemetryNoticeShown } from "./config-CGcG7GOt.js";
3
3
 
4
4
  //#region src/core/support/telemetry.ts
@@ -1,4 +1,4 @@
1
- import { l as writeSession, n as readSession } from "./storage-DT_wxwJ8.js";
1
+ import { l as writeSession, n as readSession } from "./storage-pR0Wb0d9.js";
2
2
 
3
3
  //#region src/core/account/errors.ts
4
4
  var NotLoggedInError = class extends Error {
package/dist/tools.d.ts CHANGED
@@ -4,6 +4,11 @@ import "./storage-Bdz5AmqS.js";
4
4
 
5
5
  interface RequestOptions {
6
6
  headers?: Record<string, string>;
7
+ /**
8
+ * Sending this request twice does what sending it once does. A connection that drops mid-request is
9
+ * then retried, three attempts in all, since nobody can tell whether the API got it.
10
+ */
11
+ idempotent?: boolean;
7
12
  }
8
13
  type SuperwallApi = {
9
14
  readonly org: {
package/dist/tools.js CHANGED
@@ -47,7 +47,7 @@ var require_picocolors_browser = __commonJS((exports, module) => {
47
47
  module.exports.createColors = create;
48
48
  });
49
49
  // package.json
50
- var version = "2.6.0-beta.1";
50
+ var version = "2.6.0-beta.2";
51
51
 
52
52
  // src/environment.ts
53
53
  var VERSION = version;
@@ -324,19 +324,62 @@ class ApiError extends Error {
324
324
  this.envelope = envelope !== undefined;
325
325
  }
326
326
  }
327
+ var DROPPED_CODES = new Set([
328
+ "EPIPE",
329
+ "ECONNRESET",
330
+ "ECONNABORTED",
331
+ "UND_ERR_SOCKET",
332
+ "UND_ERR_CLOSED"
333
+ ]);
334
+ var DROPPED_MESSAGE = /other side closed|socket hang up|socket connection was closed/i;
335
+ function fetchFailureOf(error) {
336
+ let found = {};
337
+ const seen = new Set;
338
+ let current2 = error;
339
+ while (typeof current2 === "object" && current2 !== null && !seen.has(current2)) {
340
+ seen.add(current2);
341
+ const code = Reflect.get(current2, "code");
342
+ const message = Reflect.get(current2, "message");
343
+ const useful = typeof message === "string" && message !== "" && message !== "fetch failed" ? message : undefined;
344
+ if (typeof code === "string" && code !== "")
345
+ found = { code, message: useful };
346
+ else if (found.code === undefined && useful !== undefined)
347
+ found = { message: useful };
348
+ const errors = Reflect.get(current2, "errors");
349
+ current2 = Reflect.get(current2, "cause") ?? (Array.isArray(errors) ? errors[0] : undefined);
350
+ }
351
+ return found;
352
+ }
353
+ var failureLabel = ({ code, message }) => {
354
+ if (code === undefined)
355
+ return message;
356
+ return message === undefined || message.includes(code) ? code : `${code}: ${message}`;
357
+ };
327
358
 
328
359
  class ApiUnreachableError extends Error {
360
+ dropped;
361
+ code;
329
362
  constructor(host, cause) {
330
363
  const local = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])/.test(host);
331
- super(`Couldn't reach the Superwall API at ${host}.
364
+ const failure = fetchFailureOf(cause);
365
+ const dropped = failure.code !== undefined && DROPPED_CODES.has(failure.code) || DROPPED_MESSAGE.test(failure.message ?? "");
366
+ const label = failureLabel(failure);
367
+ const why = label === undefined ? "" : ` (${label})`;
368
+ super(dropped ? `Lost the connection ${failure.code === "EPIPE" ? "while sending to" : "to"} the Superwall API at ${host}${why}.
369
+ ` + " It closed before the request finished. Try again." : `Couldn't reach the Superwall API at ${host}${why}.
332
370
  ` + (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."));
333
371
  this.name = "ApiUnreachableError";
334
372
  this.cause = cause;
373
+ this.dropped = dropped;
374
+ if (failure.code !== undefined)
375
+ this.code = failure.code;
335
376
  }
336
377
  }
337
378
  var PAGE_LIMIT = 50;
338
379
  var GET_RETRIES = 3;
339
380
  var RETRYABLE = new Set([429, 502, 503, 504]);
381
+ var DROPPED_ATTEMPTS = 3;
382
+ var DROPPED_BACKOFF_MS = 250;
340
383
  async function parseApiError(request, res) {
341
384
  const text = await res.text().catch(() => "");
342
385
  return new ApiError(request, res.status, text);
@@ -365,7 +408,7 @@ var createSuperwallApi = (initial, { userAgent = USER_AGENT() } = {}) => {
365
408
  };
366
409
  const request = async (method, path, body, options = {}) => {
367
410
  const token = await authorized();
368
- const attempt = () => {
411
+ const once = () => {
369
412
  return send(`${host()}${path}`, {
370
413
  method,
371
414
  headers: {
@@ -378,6 +421,18 @@ var createSuperwallApi = (initial, { userAgent = USER_AGENT() } = {}) => {
378
421
  ...body !== undefined ? { body: JSON.stringify(body) } : {}
379
422
  });
380
423
  };
424
+ const attempt = async () => {
425
+ for (let tried = 1;; tried++) {
426
+ try {
427
+ return await once();
428
+ } catch (error) {
429
+ const again = options.idempotent === true && error instanceof ApiUnreachableError && error.dropped;
430
+ if (!again || tried >= DROPPED_ATTEMPTS)
431
+ throw error;
432
+ await new Promise((done) => setTimeout(done, DROPPED_BACKOFF_MS * 2 ** (tried - 1)));
433
+ }
434
+ }
435
+ };
381
436
  let res = await attempt();
382
437
  for (let retry = 0;method === "GET" && RETRYABLE.has(res.status) && retry < GET_RETRIES; retry++) {
383
438
  await new Promise((done) => setTimeout(done, retryDelay(res, retry)));
@@ -2102,11 +2157,14 @@ async function runApiRequest(ctx, api, request) {
2102
2157
  }).catch(async (error) => {
2103
2158
  if (!(error instanceof ApiError) || error.status >= 500 || error.status === 401)
2104
2159
  throw error;
2160
+ if (namesMissingResource(error))
2161
+ throw error;
2105
2162
  throw new Error(`${error.message}
2106
2163
  ${await resolveReferenceHint(verb, path)}`, { cause: error });
2107
2164
  });
2108
2165
  ctx.output.data(res ?? { ok: true });
2109
2166
  }
2167
+ var namesMissingResource = ({ status, detail }) => status === 404 && (detail.code === "resource_missing" || detail.type === "resource_missing" || detail.resourceType !== undefined);
2110
2168
  async function resolveReferenceHint(verb, path) {
2111
2169
  const index = await resolveApiIndex().catch(() => {
2112
2170
  return;
@@ -1,28 +1,28 @@
1
- import "./token-Bu3FaRkv.js";
1
+ import "./token-BbUeExGJ.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import { t as ApiError } from "./client-CyrYJzBF.js";
3
+ import "./environment-BFNzLLPN.js";
4
+ import "./storage-pR0Wb0d9.js";
5
+ import { t as ApiError } from "./client-x08fpvay.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import "./spinner-DPdBlZe2.js";
7
+ import "./spinner-IA6hV8nI.js";
8
8
  import "./ui-D_qf3Gvw.js";
9
- import "./orgs-Z0H9WOs1.js";
10
- import "./resources-CptT7HD6.js";
11
- import "./lookup-CWzVfPpq.js";
9
+ import "./orgs-1OzwUtpT.js";
10
+ import "./resources-DNwvf8rg.js";
11
+ import "./lookup-Dg55W9S7.js";
12
12
  import { n as openBrowser } from "./browser-Bp3yRKlU.js";
13
- import { r as dashboardOrigin } from "./resolve-DpOSDDdr.js";
13
+ import { r as dashboardOrigin } from "./resolve-CcOpO_5s.js";
14
14
  import { a as findEntrypoint, s as readProject, t as ArtifactError } from "./project-NoMtbMyl.js";
15
15
  import "./lock-DgSx-p8Y.js";
16
16
  import "./scope-ehZ7L1nj.js";
17
17
  import { _ as DRAFT_MODULE_MAX_BYTES, a as summarizeSeries, c as defaultRange, n as parseFilters, u as bundleArtifact } from "./series-D2ZpZ8cx.js";
18
- import { n as resolveOrganization, t as resolveAppScope } from "./organization-7vJA3uy1.js";
18
+ import { n as resolveOrganization, t as resolveAppScope } from "./organization-CmuQwcKN.js";
19
19
  import "./download-DhGd4hOB.js";
20
20
  import { i as warnIfSdkBehind } from "./sdk-DEfQttek.js";
21
21
 
22
22
  //#region src/core/artifacts/try.ts
23
- async function postDraft(ctx, path, body) {
23
+ async function postDraft(ctx, path, body, options = {}) {
24
24
  try {
25
- return await ctx.api.post(path, body);
25
+ return await ctx.api.post(path, body, options);
26
26
  } catch (error) {
27
27
  if (error instanceof ApiError && error.status === 400) throw new ArtifactError(error.message);
28
28
  throw error;
@@ -35,7 +35,7 @@ async function uploadDraft(ctx, project, organizationId, wrangler) {
35
35
  organization_id: Number(organizationId),
36
36
  manifest: project.manifest,
37
37
  module
38
- });
38
+ }, { idempotent: true });
39
39
  }
40
40
  async function tryMetric(ctx, project, entrypoint, input, wrangler) {
41
41
  if (input.app === void 0) throw new ArtifactError("A metric runs for one app. Say which with --app <id>.");
@@ -1,4 +1,4 @@
1
- import { _ as RUNNING_VIA_NPX, a as AUTO_UPDATE, x as VERSION } from "./environment-BocmdvZ-.js";
1
+ import { _ as RUNNING_VIA_NPX, a as AUTO_UPDATE, x as VERSION } from "./environment-BFNzLLPN.js";
2
2
  import { c as readSkillsSync, d as writeAutoUpdate, l as readUpdateCheck, n as readAutoUpdate, v as writeUpdateCheck } from "./config-CGcG7GOt.js";
3
3
  import { r as spawnStream } from "./spawn-DmmmHIP-.js";
4
4
  import { execFileSync } from "node:child_process";
@@ -111,7 +111,7 @@ async function updateAgentSkills(ctx, work) {
111
111
  return skills;
112
112
  }
113
113
  async function updateSkillsInProcess() {
114
- const { updateSkills } = await import("./skills-CdKwaTRS.js");
114
+ const { updateSkills } = await import("./skills-Bqz2l_bx.js");
115
115
  return updateSkills();
116
116
  }
117
117
  async function updateSkillsWithInstalledCli(version) {
@@ -1,7 +1,7 @@
1
1
  import "./output-Ggzq5_-t.js";
2
- import "./environment-BocmdvZ-.js";
2
+ import "./environment-BFNzLLPN.js";
3
3
  import "./config-CGcG7GOt.js";
4
4
  import "./spawn-DmmmHIP-.js";
5
- import { a as printAutoUpdate, c as runUpgrade, i as maybeNotifyUpdate, l as selectAutoUpdate, n as isGlobalInstall, o as recordAutoUpdate, r as isNewerVersion, s as refreshUpdateCheck, t as flushUpdateCheck } from "./upgrade-B7TmvEPP.js";
5
+ import { a as printAutoUpdate, c as runUpgrade, i as maybeNotifyUpdate, l as selectAutoUpdate, n as isGlobalInstall, o as recordAutoUpdate, r as isNewerVersion, s as refreshUpdateCheck, t as flushUpdateCheck } from "./upgrade-CKn88PZD.js";
6
6
 
7
7
  export { flushUpdateCheck, isGlobalInstall, isNewerVersion, maybeNotifyUpdate, printAutoUpdate, recordAutoUpdate, refreshUpdateCheck, runUpgrade, selectAutoUpdate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superwall/cli",
3
- "version": "2.6.0-beta.1",
3
+ "version": "2.6.0-beta.2",
4
4
  "description": "The official CLI for managing Superwall from your terminal or coding agent.",
5
5
  "keywords": [
6
6
  "agent",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "dependencies": {
66
66
  "@anthropic-ai/claude-agent-sdk": "0.3.201",
67
- "@superwall/studio": "2.6.0-beta.1",
67
+ "@superwall/studio": "2.6.0-beta.2",
68
68
  "ansi-escapes": "^7.3.0",
69
69
  "fast-glob": "^3.3.3",
70
70
  "ink": "^5.2.1",
@@ -1,20 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./held-Bykbwy-m.js";
7
- import "./config-CGcG7GOt.js";
8
- import "./spinner-DPdBlZe2.js";
9
- import "./ui-D_qf3Gvw.js";
10
- import "./paths-CzTJVpfi.js";
11
- import "./orgs-Z0H9WOs1.js";
12
- import "./resources-CptT7HD6.js";
13
- import "./org-Dud1rF9f.js";
14
- import "./lookup-CWzVfPpq.js";
15
- import "./scope-l1qGLsgz.js";
16
- import "./client-BJQXl62Q.js";
17
- import "./timing-Ca0TXY-A.js";
18
- import { i as runAscKeysCreate, n as keyAccess, r as keyRole, t as createAndSaveKey } from "./create-BCIgjRHn.js";
19
-
20
- export { createAndSaveKey, keyAccess, keyRole, runAscKeysCreate };
@@ -1,17 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import { t as upsertHeldKey } from "./held-Bykbwy-m.js";
7
- import "./config-CGcG7GOt.js";
8
- import "./spinner-DPdBlZe2.js";
9
- import "./ui-D_qf3Gvw.js";
10
- import "./orgs-Z0H9WOs1.js";
11
- import "./resources-CptT7HD6.js";
12
- import "./org-Dud1rF9f.js";
13
- import "./lookup-CWzVfPpq.js";
14
- import "./scope-l1qGLsgz.js";
15
- import "./client-BJQXl62Q.js";
16
-
17
- export { upsertHeldKey };
@@ -1,17 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-nVQO7JLx.js";
12
- import "./paths-CzTJVpfi.js";
13
- import { i as startLogin, n as pollLogin, r as runLogin, t as performLogin } from "./login-5sWIKDI2.js";
14
- import "./skills-421SFEyF.js";
15
- import "./browser-Bp3yRKlU.js";
16
-
17
- export { performLogin, pollLogin, runLogin, startLogin };
@@ -1,36 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./theme-DUsCh-Vd.js";
12
- import "./log-C0MDCfA2.js";
13
- import "./scan-nVQO7JLx.js";
14
- import "./existing-Cl5x6_5u.js";
15
- import "./paths-CzTJVpfi.js";
16
- import "./orgs-Z0H9WOs1.js";
17
- import "./resources-CptT7HD6.js";
18
- import "./org-Dud1rF9f.js";
19
- import "./lookup-CWzVfPpq.js";
20
- import "./bind-ClFjTt0U.js";
21
- import "./login-5sWIKDI2.js";
22
- import "./skills-421SFEyF.js";
23
- import "./browser-Bp3yRKlU.js";
24
- import "./lock-DgSx-p8Y.js";
25
- import "./scope-ehZ7L1nj.js";
26
- import "./base-ChTi42M0.js";
27
- import "./framework-CLmf4swr.js";
28
- import "./run-c1O2_8pp.js";
29
- import "./drivers-BQkO5tHs.js";
30
- import "./migration-Z69tLeHC.js";
31
- import "./login-Jp6E6d2e.js";
32
- import "./source-BccdO4aL.js";
33
- import "./setup-C6NFy14d.js";
34
- import { a as cloneInto, c as pullInto, i as boundPaywall, l as runPull, n as applyPulledChanges, o as cloneTarget, r as appsToPull, s as mergePulledLock, t as PullPathError } from "./pull-AoUmaiMK.js";
35
-
36
- export { PullPathError, applyPulledChanges, appsToPull, boundPaywall, cloneInto, cloneTarget, mergePulledLock, pullInto, runPull };
@@ -1,30 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-nVQO7JLx.js";
12
- import "./paths-CzTJVpfi.js";
13
- import "./orgs-Z0H9WOs1.js";
14
- import "./resources-CptT7HD6.js";
15
- import "./lookup-CWzVfPpq.js";
16
- import "./login-5sWIKDI2.js";
17
- import "./skills-421SFEyF.js";
18
- import "./browser-Bp3yRKlU.js";
19
- import "./lock-DgSx-p8Y.js";
20
- import "./scope-ehZ7L1nj.js";
21
- import "./base-ChTi42M0.js";
22
- import "./framework-CLmf4swr.js";
23
- import "./login-Jp6E6d2e.js";
24
- import "./source-BccdO4aL.js";
25
- import "./assets-B_quADds.js";
26
- import "./design-lint-CiFc78aM.js";
27
- import "./source-push-B4s6r9bB.js";
28
- import { i as timed, n as runPush, r as runPushPipeline, t as group } from "./push-BMblzg_6.js";
29
-
30
- export { group, runPush, runPushPipeline, timed };
@@ -1,4 +0,0 @@
1
- import "./environment-BocmdvZ-.js";
2
- import { t as scanProject } from "./scan-nVQO7JLx.js";
3
-
4
- export { scanProject };
@@ -1,29 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./telemetry-ovPiseFm.js";
8
- import "./spawn-DmmmHIP-.js";
9
- import "./spinner-DPdBlZe2.js";
10
- import "./ui-D_qf3Gvw.js";
11
- import "./scan-nVQO7JLx.js";
12
- import "./paths-CzTJVpfi.js";
13
- import "./orgs-Z0H9WOs1.js";
14
- import "./resources-CptT7HD6.js";
15
- import "./lookup-CWzVfPpq.js";
16
- import "./login-5sWIKDI2.js";
17
- import "./skills-421SFEyF.js";
18
- import "./browser-Bp3yRKlU.js";
19
- import "./lock-DgSx-p8Y.js";
20
- import "./scope-ehZ7L1nj.js";
21
- import "./base-ChTi42M0.js";
22
- import "./framework-CLmf4swr.js";
23
- import "./login-Jp6E6d2e.js";
24
- import "./source-BccdO4aL.js";
25
- import "./assets-B_quADds.js";
26
- import "./source-push-B4s6r9bB.js";
27
- import { t as runStudio } from "./server-DLARhh1k.js";
28
-
29
- export { runStudio };
@@ -1,6 +0,0 @@
1
- import "./output-Ggzq5_-t.js";
2
- import "./environment-BocmdvZ-.js";
3
- import "./storage-DT_wxwJ8.js";
4
- import { n as runWhoami, t as runLogout } from "./session-Z0BeaJPf.js";
5
-
6
- export { runLogout, runWhoami };
@@ -1,17 +0,0 @@
1
- import "./token-Bu3FaRkv.js";
2
- import "./output-Ggzq5_-t.js";
3
- import "./environment-BocmdvZ-.js";
4
- import "./storage-DT_wxwJ8.js";
5
- import "./client-CyrYJzBF.js";
6
- import "./config-CGcG7GOt.js";
7
- import "./spinner-DPdBlZe2.js";
8
- import "./ui-D_qf3Gvw.js";
9
- import "./orgs-Z0H9WOs1.js";
10
- import "./resources-CptT7HD6.js";
11
- import "./org-Dud1rF9f.js";
12
- import "./lookup-CWzVfPpq.js";
13
- import "./scope-l1qGLsgz.js";
14
- import "./input-MDd67UIp.js";
15
- import { n as writeStoreKit, t as generateStoreKit } from "./storekit-B9M2raxe.js";
16
-
17
- export { generateStoreKit, writeStoreKit };