@superwall/cli 2.2.1 → 2.3.1

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 (87) hide show
  1. package/README.md +24 -11
  2. package/dist/{apple-DaqaI4vD.js → apple-z2qjOzIZ.js} +13 -13
  3. package/dist/assets-DXXegdDt.js +89 -0
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/auth.js +3 -3
  6. package/dist/{billing-DyKr2kmd.js → billing-B8tOjsnY.js} +3 -3
  7. package/dist/{bind-BpxebZf4.js → bind-Bx9K6LwP.js} +4 -4
  8. package/dist/{build-DzbdRThf.js → build-Bu2kkzRe.js} +7 -6
  9. package/dist/{client-BF9rCULI.js → client-DOgk9gAS.js} +3 -3
  10. package/dist/{create-D7AZHYGH.js → create-B03MAuPe.js} +6 -6
  11. package/dist/create-BdZS_T68.js +19 -0
  12. package/dist/{create-B55V99TD.js → create-DzC_89gq.js} +28 -226
  13. package/dist/{doctor-B2mPKiaJ.js → doctor-BGZSKY_B.js} +6 -6
  14. package/dist/{drivers-DOMky8Ug.js → drivers-DqLgQxkC.js} +3 -3
  15. package/dist/entry.js +19 -19
  16. package/dist/{environment-DBwo79dy.js → environment-i8BhiBDB.js} +1 -1
  17. package/dist/{existing-B4VK4BCL.js → existing-BPOG5zLO.js} +2 -2
  18. package/dist/{held-DjcZPCwn.js → held-C56PYMRH.js} +6 -6
  19. package/dist/held-DSNUY-NZ.js +16 -0
  20. package/dist/{integrate-B8oHbvwz.js → integrate-DZ4Qvoch.js} +22 -22
  21. package/dist/login-Blrkm6oi.js +16 -0
  22. package/dist/{login-DfhqWY9C.js → login-ONZdK8vN.js} +6 -6
  23. package/dist/{login-B8hgMLhS.js → login-p9GVEKzD.js} +1 -1
  24. package/dist/{lookup-r8p6H2ZC.js → lookup-flTi0at0.js} +2 -2
  25. package/dist/{migrate-DQf2Fosc.js → migrate-DnXpbhL1.js} +25 -22
  26. package/dist/{open-CrEnSL4v.js → migration-DJ1uNKhk.js} +11 -49
  27. package/dist/{notification-url-BxPTEmkv.js → notification-url-CCDeS5S-.js} +2 -2
  28. package/dist/open-QdsZ_N47.js +41 -0
  29. package/dist/{org-Cc2WGvl1.js → org-BiFPjoHD.js} +2 -2
  30. package/dist/{paths-BcNbJfpw.js → paths-yRgm5Jpa.js} +1 -1
  31. package/dist/{playbook-D9J8frkE.js → playbook-B-pRKNa4.js} +10 -10
  32. package/dist/{promote-C8T7DCFF.js → promote-Djzk4C81.js} +18 -16
  33. package/dist/pull-BLA9XwHj.js +303 -0
  34. package/dist/push-BkMgOT6X.js +24 -0
  35. package/dist/{push-Bzs1l_5C.js → push-gSBxGDik.js} +8 -6
  36. package/dist/{registry-CpxZbmxp.js → registry-D3xmWk9p.js} +230 -115
  37. package/dist/{resources-Bo6i7wBi.js → resources-BTnczJCA.js} +21 -7
  38. package/dist/{run-BUp4r8Kk.js → run-C1SoizcJ.js} +2 -2
  39. package/dist/{scan-8cxu2fx0.js → scan-Dwk_lT5q.js} +1 -1
  40. package/dist/scan-Kp-MAutK.js +4 -0
  41. package/dist/{scope-CPG_wWXL.js → scope-Db7blD-l.js} +5 -4
  42. package/dist/{selection-CMA4aG4V.js → selection-u2KiKu_d.js} +16 -96
  43. package/dist/{server-Xb3wp-mx.js → server-Cb2N75JL.js} +9 -7
  44. package/dist/server-psYghr9K.js +24 -0
  45. package/dist/{session-eZeXR9xU.js → session-BDLQUJyV.js} +444 -243
  46. package/dist/session-CehHJWZk.js +6 -0
  47. package/dist/{session-DOZV1TP6.js → session-CnDJp_HO.js} +1 -1
  48. package/dist/setup-BLahHpgy.js +216 -0
  49. package/dist/skills/animate-onboarding/SKILL.md +1 -1
  50. package/dist/skills/mobile-design/SKILL.md +1 -1
  51. package/dist/skills/onboarding-questions/SKILL.md +1 -1
  52. package/dist/skills/superwall/SKILL.md +6 -7
  53. package/dist/skills/superwall/references/api.md +8 -3
  54. package/dist/skills/superwall/workflows/dashboard/playbook.md +4 -3
  55. package/dist/skills/superwall/workflows/dashboard/setup.md +7 -4
  56. package/dist/skills/superwall/workflows/migrate/adapty.md +4 -3
  57. package/dist/skills/superwall/workflows/migrate/playbook.md +2 -2
  58. package/dist/skills/superwall/workflows/migrate/qonversion.md +4 -3
  59. package/dist/skills/superwall/workflows/migrate/revenuecat.md +4 -3
  60. package/dist/skills/superwall-editor/SKILL.md +2 -3
  61. package/dist/skills/superwall-framework/SKILL.md +83 -13
  62. package/dist/skills/superwall-framework/references/cli.md +92 -21
  63. package/dist/skills/superwall-framework/references/migrate-from-editor.md +5 -1
  64. package/dist/{skills-BI19OGlS.js → skills-DDV4zcLR.js} +8 -8
  65. package/dist/{skills-DDf10ufO.js → skills-zebMTZyr.js} +4 -4
  66. package/dist/source-push-DxuJuwEf.js +205 -0
  67. package/dist/{spinner-BClMQGGN.js → spinner-BN3U1CVB.js} +3 -3
  68. package/dist/{storage-Po9E-CHL.js → storage-VagEaaJC.js} +1 -1
  69. package/dist/storekit-BcBb2jXB.js +16 -0
  70. package/dist/{storekit-Cbn9DBLA.js → storekit-CoOf4Rvh.js} +3 -3
  71. package/dist/{telemetry-s6dag6tb.js → telemetry-CM0BDwCK.js} +1 -1
  72. package/dist/{token-CPplNMVa.js → token-lUUOkTJA.js} +1 -1
  73. package/dist/tools.d.ts +1 -1
  74. package/dist/tools.js +215 -89
  75. package/dist/{upgrade-1OYm5NQU.js → upgrade-CpTJv_M7.js} +2 -2
  76. package/dist/{upgrade-ahapZeex.js → upgrade-DZbKb67W.js} +1 -1
  77. package/package.json +2 -2
  78. package/dist/create-BYAPuhhf.js +0 -19
  79. package/dist/held-C9FqvNbn.js +0 -16
  80. package/dist/login-D-a7oS_8.js +0 -16
  81. package/dist/push-snV3SrnH.js +0 -22
  82. package/dist/scan-nUeXs9a1.js +0 -4
  83. package/dist/server-Boqa8jh_.js +0 -22
  84. package/dist/session-DtBpdlF-.js +0 -6
  85. package/dist/storekit-BU6Eq_UO.js +0 -16
  86. /package/dist/{reports-D_qbl7_u.js → reports-CwwKLUh0.js} +0 -0
  87. /package/dist/{storage-BbJF7z3l.d.ts → storage-gRyQetN9.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- # CLI — dev, push, promote, publish
1
+ # CLI — dev, push, promote, publish, pull
2
2
 
3
3
  Git semantics on purpose: **push saves, promote ships.** Every push mints
4
4
  a sealed version; nothing users see changes until promote points
@@ -11,6 +11,8 @@ superwall push # build + version. Production untouched.
11
11
  superwall promote # point production at the latest push
12
12
  superwall publish # push + promote in one step
13
13
  superwall publish -m "Q3 test" # record why
14
+ superwall pull # merge teammates' work from the app's source repo
15
+ superwall pull --app <id> # get an app's paywalls into an empty folder
14
16
  ```
15
17
 
16
18
  The scaffolded package scripts mirror these (`dev`, `push`, `promote`,
@@ -97,8 +99,8 @@ Three consequences for you, not the user:
97
99
  paywall, shared by every thread and teammate, one turn at a time; its
98
100
  preview is a `superwall build` snapshot taken when a turn ends, not a live
99
101
  server. So edits may have arrived that a local checkout has never seen —
100
- `main` carries the source commit of the last published version, and there
101
- is no `superwall pull` yet.
102
+ `main` carries the source commit of the last published version; run
103
+ `superwall pull` to bring them into the local project.
102
104
 
103
105
  The mechanism behind both (the envelope, the `ping` reply, hosting a paywall
104
106
  yourself) is `curl -sL superwall.com/docs/framework/host-protocol.md`.
@@ -152,15 +154,19 @@ A push refuses if a `config.ts` names a product the dashboard doesn't have.
152
154
  "the dashboard needs products" is work you can do, not a dependency:
153
155
 
154
156
  ```sh
155
- superwall entitlements list --json # grab the NUMERIC entitlement id
157
+ superwall entitlements create --identifier pro --app <id> --json # skip if it exists
156
158
  superwall products create --identifier <identifier> \
157
159
  --app <id|dashboard link> \
158
160
  --name "Annual" --price 39.99 --period year \
159
- --trial-days 7 --entitlement <numeric-id> --json
161
+ --trial-days 7 --entitlement pro --json
160
162
  ```
161
163
 
162
- - `--entitlement` takes the **numeric id** (`55688`), not the identifier
163
- (`pro`) — the identifier fails with a decode error.
164
+ - `--entitlement` takes the entitlement's identifier (`pro`) or id. Pass
165
+ the same `--app` to both commands: a product only grants entitlements on
166
+ its own app, and a mismatch is refused with the fix in the message.
167
+ - CLI 2.2.1 and older take only the numeric id from
168
+ `superwall entitlements list --json`; run `superwall upgrade` once a
169
+ newer CLI is out.
164
170
  - Pass `--app <id|dashboard link>` (or `--project <id>`) when the account
165
171
  has several projects, or it stops with "You can open N projects" and
166
172
  lists them.
@@ -199,8 +205,8 @@ The hosted studio's chat runs this at the end of every turn for its preview.
199
205
  Builds every paywall, versions the changed ones, and leaves production
200
206
  alone. Re-running with nothing changed is a no-op. Flags: `--id <id>`
201
207
  (limit, repeatable), `--platform <p>` (repeatable or comma-separated; limits the platforms),
202
- `--rename <old>=<new>`, `-m <note>`, `--overwrite-source` (below; `publish`
203
- takes it too).
208
+ `--rename <old>=<new>`, `-m <note>`, `--overwrite-source` (replaces only the
209
+ pushed paywalls' source — below; `publish` takes it too).
204
210
 
205
211
  A push refuses — before anything is written — when:
206
212
 
@@ -273,6 +279,22 @@ export default definePaywall({ platforms: ["web"], checkout: "sheet", products:
273
279
  per-platform slot must name every platform in `platforms` (push error:
274
280
  `` `annual` has no product id for web ``). The dashboard product check
275
281
  runs per platform, so create the Play product too.
282
+ - An App Store product can offer Apple's monthly plan (a 12-month
283
+ commitment billed monthly) next to the year paid up front. A slot picks
284
+ which one it sells with `billingPlan: "monthly" | "upFront"`, on a slot
285
+ object or a per-platform slot:
286
+ `annual: { productId: "pro_annual", billingPlan: "upFront" }` or
287
+ `annual: { ios: "pro_annual", android: "pro_annual_play", billingPlan:
288
+ "upFront" }`. Omitted, it is `"monthly"` for a product that offers the
289
+ monthly plan and has no effect on one that does not. To offer both plans
290
+ side by side, use two slots on the same product:
291
+ `annual: { productId: "pro_annual", billingPlan: "upFront" },
292
+ annualMonthly: { productId: "pro_annual", billingPlan: "monthly" }`.
293
+ iOS / App Store only: Android and web have no such plan and ignore it,
294
+ and Play, Stripe and custom slots never carry it. `superwall push` sends
295
+ the plan with each version, and changing only `billingPlan` pushes a new
296
+ version. An unknown value fails the build (`` paywalls/<id>: `annual`
297
+ billingPlan must be one of "monthly", "upFront", got "upfront". ``).
276
298
 
277
299
  ### Renames
278
300
 
@@ -314,16 +336,28 @@ Every push also saves the `superwall/` source to the app's source repo on
314
336
  Superwall, so the dashboard can show and diff the code each version was
315
337
  built from — and `-m "why"` records the reason there.
316
338
 
317
- - **Teammates' work is kept.** The repo is shared by everyone who pushes to
318
- the app. A push applies this project's changes on top of whatever others
319
- published since its last push, from the commit `superwall.lock` records
320
- under `sources` (commit the lock). It stops and names the files rather
321
- than overwrite: `Someone else published changes to …` (the same files
322
- changed on both sides: pull their commits, push again) or `The source
323
- repo differs from this project in …` (no sync point recorded: pull the
324
- latest `superwall.lock`). `--overwrite-source` replaces the remote
325
- source with this project's. It discards a teammate's work, so it is the
326
- user's decision, never a fix you reach for on your own.
339
+ - **A push writes only its own paywall.** The repo is shared by everyone
340
+ who pushes to the app. A push of paywall `a` writes `paywalls/a/`, the
341
+ shared files outside every paywall and funnel directory (`package.json`,
342
+ components, config), and `a`'s own entries in `superwall.lock`. Every
343
+ other paywall and funnel stays as the repo has it — even from a checkout
344
+ with no sync point, and even if the local copy of another paywall is
345
+ stale or missing. `superwall.lock` merges entry by entry; `superwall.d.ts`
346
+ takes this project's copy.
347
+ - **Teammates' work is kept.** With a sync point (the commit
348
+ `superwall.lock` records under `sources` — commit the lock), a push
349
+ merges this project's changes on top of whatever others published since.
350
+ It stops and names only the conflicting files rather than overwrite:
351
+ `Someone else published changes to …` (a teammate changed the same file),
352
+ or, with no sync point, `The source repo differs from this project in …`
353
+ (the push would change an existing file in this paywall or a shared
354
+ file). Files the repo doesn't have yet never block. Both say to run
355
+ `superwall pull` (below), then publish again.
356
+ - **`--overwrite-source` replaces only the pushed paywall's source** (its
357
+ directory, the shared files and its lock entries); teammates' other
358
+ paywalls stay. It still discards a teammate's edits to that paywall, so
359
+ it is the user's decision, never a fix you reach for on your own —
360
+ reach for `superwall pull` first.
327
361
  - **No version ships without its source.** A version whose source didn't
328
362
  land is recorded in `superwall.lock` (`sourcePending`); the next push
329
363
  finishes its source before anything else, `promote` refuses it (`version
@@ -360,6 +394,40 @@ Promote never rebuilds — it only moves the live pointer.
360
394
  Push + promote in one step. Also warns about other paywalls that are
361
395
  pushed-but-not-live, so nothing ships half-forgotten.
362
396
 
397
+ ## `superwall pull`
398
+
399
+ Merges the app's source repo into this project: teammates' paywalls and
400
+ shared files, their `superwall.lock` bindings, and the sync point the next
401
+ push merges from. Run it inside a project; it pulls the repo of every app
402
+ `superwall.lock` binds (`--platform <p>` limits it to those platforms).
403
+
404
+ - **Local edits stay.** Uncommitted changes in the project are merged with
405
+ the repo's, and only the files that changed are written.
406
+ - **A conflict changes nothing.** If both sides changed a file (with no
407
+ sync point: any file both have with different content), it stops:
408
+ `Your project and the source repo both changed …, so nothing was
409
+ pulled`. `superwall pull --theirs` takes the repo's whole copy of those
410
+ files — the local edits to them are lost, so copy them aside first if
411
+ the user wants to keep them. Never add `--theirs` on your own.
412
+ - **Bindings:** the repo's lock entries are taken only for platforms this
413
+ project binds to the same app (or doesn't bind yet); a platform bound to
414
+ a different app keeps its local bindings.
415
+ - **No source-less version ships.** A local version whose source never
416
+ landed stays `sourcePending`, so `promote` still refuses it until a push
417
+ finishes its source.
418
+ - **Safety:** a gitignored local file is never overwritten (it is listed
419
+ as left alone), and a symlink or `..` in a path refuses the whole pull.
420
+
421
+ With no project, `superwall pull --app <id|name|dashboard link> [dir]`
422
+ clones the app's source into an empty `<dir>/superwall/` (default: the
423
+ current directory), with its `superwall.lock` bindings, `superwall.d.ts`
424
+ and sync point — the way to work on an app's paywalls without its codebase
425
+ or GitHub. It installs nothing; it prints the next step, `cd superwall &&
426
+ <manager> install && <dev>`. It refuses a directory that is already a
427
+ superwall project (run `superwall pull` there instead) or one that already
428
+ has files, and an app with no code paywall or an empty source repo (start
429
+ one with `superwall create --app <id>`).
430
+
363
431
  ## The studio's Push / Publish / Promote buttons
364
432
 
365
433
  Same operations from the `dev` UI — good for iteration. Prefer the CLI
@@ -405,7 +473,10 @@ than listing none.
405
473
  | `paywall x has never been pushed` (promote) | Push first |
406
474
  | `superwall publish requires git` | Install git — the source snapshot is part of every publish |
407
475
  | `… version N has no source yet` (promote) | Run `superwall push` to finish that version's source, then promote |
408
- | `Someone else published changes to …` | Pull their commits, push again; `--overwrite-source` only on the user's say-so |
409
- | `The source repo differs from this project in …` | Pull the latest `superwall.lock`, push again; `--overwrite-source` only on the user's say-so |
476
+ | `Someone else published changes to …` | Run `superwall pull`, then publish again; `--overwrite-source` (this paywall only) only on the user's say-so |
477
+ | `The source repo differs from this project in …` | Run `superwall pull`, then publish again; `--overwrite-source` (this paywall only) only on the user's say-so |
478
+ | `Your project and the source repo both changed …, so nothing was pulled` | Ask the user which copy wins; to take the repo's, copy their edits aside if wanted, then `superwall pull --theirs` |
479
+ | `… already has files — pull --app only fills an empty folder` | Pick an empty directory, or run `superwall pull` inside the existing project without `--app` |
480
+ | `App … has no code paywall on Superwall yet` / `source repo is empty` (pull) | Nothing to pull — start one with `superwall create --app <id>` |
410
481
  | `The source in … is N MB, over the 250 MB limit` | Gitignore what doesn't belong in the source, push again |
411
482
  | Not signed in | `superwall login`, or `SUPERWALL_API_KEY` in CI |
@@ -92,7 +92,11 @@ signatures before writing them.
92
92
  2. **Fix the products.** A `"missing"` identifier in `config.ts` blocks
93
93
  push. The dashboard paywall's product slots name the real products
94
94
  on a published paywall; on a template they don't exist, and the user
95
- has to choose (or you create them, see [cli.md](cli.md)).
95
+ has to choose (or you create them, see [cli.md](cli.md)). A slot the
96
+ dashboard set to an Apple billing plan comes over as
97
+ `{ productId: "pro_annual", billingPlan: "upFront" }` (or `"monthly"`);
98
+ keep it, since dropping it sells the monthly plan wherever the product
99
+ offers one. Slots without a plan stay plain strings.
96
100
  3. **Rebuild page by page, in the store's order.** Each navigation child
97
101
  is a route; shared chrome (close, back, step indicator) that the editor
98
102
  drew outside the navigation goes in `layout.tsx`. Use the framework's
@@ -1,14 +1,14 @@
1
- import "./token-CPplNMVa.js";
1
+ import "./token-lUUOkTJA.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-DBwo79dy.js";
4
- import "./storage-Po9E-CHL.js";
5
- import "./client-BF9rCULI.js";
3
+ import "./environment-i8BhiBDB.js";
4
+ import "./storage-VagEaaJC.js";
5
+ import "./client-DOgk9gAS.js";
6
6
  import "./config-BO1Y87kV.js";
7
- import "./telemetry-s6dag6tb.js";
7
+ import "./telemetry-CM0BDwCK.js";
8
8
  import "./spawn-DmmmHIP-.js";
9
- import "./spinner-BClMQGGN.js";
9
+ import "./spinner-BN3U1CVB.js";
10
10
  import "./ui-D_qf3Gvw.js";
11
- import "./paths-BcNbJfpw.js";
12
- import { a as bundledSkills, c as knownSkills, d as readBundledSkill, f as runSkills, 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-DDf10ufO.js";
11
+ import "./paths-yRgm5Jpa.js";
12
+ import { a as bundledSkills, c as knownSkills, d as readBundledSkill, f as runSkills, 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-zebMTZyr.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 };
@@ -1,10 +1,10 @@
1
- import { a as CHANNEL, o as CHANNELS, v as VERSION } from "./environment-DBwo79dy.js";
1
+ import { a as CHANNEL, o as CHANNELS, v as VERSION } from "./environment-i8BhiBDB.js";
2
2
  import { m as writeSkillsSync, s as readSkillsSync } from "./config-BO1Y87kV.js";
3
- import { r as track } from "./telemetry-s6dag6tb.js";
3
+ import { r as track } from "./telemetry-CM0BDwCK.js";
4
4
  import { r as spawnStream } from "./spawn-DmmmHIP-.js";
5
- import { n as withSpinner } from "./spinner-BClMQGGN.js";
5
+ import { n as withSpinner } from "./spinner-BN3U1CVB.js";
6
6
  import { n as ui } from "./ui-D_qf3Gvw.js";
7
- import { i as packagedDir, t as AGENT_SKILLS_DIR } from "./paths-BcNbJfpw.js";
7
+ import { i as packagedDir, t as AGENT_SKILLS_DIR } from "./paths-yRgm5Jpa.js";
8
8
  import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { join } from "node:path";
10
10
  import { tmpdir } from "node:os";
@@ -0,0 +1,205 @@
1
+ import { n as ApiUnreachableError, t as ApiError } from "./client-DOgk9gAS.js";
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-BTnczJCA.js";
4
+ import { n as findApplication } from "./lookup-flTi0at0.js";
5
+ import { M as writeBinding, k as readLock } from "./selection-u2KiKu_d.js";
6
+ import { a as pushSourceTree, c as writeSourceBase, r as gitAvailable, s as readSourceBase } from "./session-BDLQUJyV.js";
7
+ import { setTimeout } from "node:timers/promises";
8
+ import { productVariables } from "@superwall/studio/products";
9
+
10
+ //#region src/core/paywalls/binding/binding.ts
11
+ var BindingError = class extends Error {};
12
+ const describe = (surface) => `${surface.kind} \`${surface.id}\``;
13
+ const humanize = (surfaceId) => surfaceId.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
14
+ async function resolveBinding(input) {
15
+ const { api, superwallDir, surface, app } = input;
16
+ const { platform, applicationId } = app;
17
+ const create = input.create ?? true;
18
+ const lock = readLock(superwallDir);
19
+ const section = surface.kind === "paywall" ? lock.paywalls : lock.funnels;
20
+ const locked = section[surface.id]?.[platform];
21
+ if (locked) return {
22
+ paywallId: locked.paywallId,
23
+ applicationId,
24
+ platform,
25
+ source: "lock"
26
+ };
27
+ const matches = (paywalls) => {
28
+ const headless = paywalls.filter((paywall) => paywall.metadata.headless === "true");
29
+ return headless.find((paywall) => paywall.metadata.headlessSurface === surface.id) ?? headless.find((paywall) => paywall.identifier === surface.id);
30
+ };
31
+ const match = matches(await listAppPaywalls(api, applicationId));
32
+ if (match) {
33
+ await requireAdoption(input.confirmAdopt, {
34
+ surface,
35
+ paywallId: match.id,
36
+ applicationId,
37
+ platform
38
+ });
39
+ writeBinding(superwallDir, surface.kind, surface.id, platform, { paywallId: match.id });
40
+ return {
41
+ paywallId: match.id,
42
+ applicationId,
43
+ platform,
44
+ source: "matched"
45
+ };
46
+ }
47
+ if (!create) throw new BindingError(`${describe(surface)} has never been pushed to \`${platform}\` — run \`superwall push\` first.`);
48
+ if (!input.renamesResolved) {
49
+ const onDisk = new Set(input.surfaces.filter((candidate) => candidate.kind === surface.kind).map((c) => c.id));
50
+ const orphans = Object.keys(section).filter((id) => !onDisk.has(id));
51
+ if (orphans.length > 0) throw new BindingError(`\`${surface.id}\` is unbound while superwall.lock still binds ${orphans.join(", ")}, which no longer exist on disk. Resolve the renames first — \`superwall push\` asks, or declare them with \`--rename <old>=<new>\`.`);
52
+ }
53
+ const archived = matches(await listAppPaywalls(api, applicationId, { archived: true }));
54
+ if (archived) throw new BindingError(`${describe(surface)} matches archived paywall ${archived.id} on \`${platform}\`. Restore it in the dashboard to push to it, or rename the directory.`);
55
+ const created = await createHeadlessPaywall(api, {
56
+ applicationId,
57
+ name: input.name?.trim() || humanize(surface.id),
58
+ identifier: surface.id
59
+ });
60
+ writeBinding(superwallDir, surface.kind, surface.id, platform, { paywallId: created.id });
61
+ return {
62
+ paywallId: created.id,
63
+ applicationId,
64
+ platform,
65
+ source: "created"
66
+ };
67
+ }
68
+ async function requireAdoption(confirm, candidate) {
69
+ if (confirm && await confirm(candidate)) return;
70
+ const { surface, paywallId, applicationId, platform } = candidate;
71
+ const lockLine = `"${surface.id}": { "${platform}": { "paywallId": "${paywallId}" } }`;
72
+ throw new BindingError([
73
+ `App ${applicationId} already has a paywall \`${surface.id}\` (${paywallId}) that superwall.lock doesn't bind, so nothing was pushed.`,
74
+ ` - It's yours: run \`superwall push\` interactively and confirm, or add ${lockLine} under "${surface.kind === "paywall" ? "paywalls" : "funnels"}" in superwall.lock.`,
75
+ ` - It isn't: rename the directory, and the next push creates a new paywall.`
76
+ ].join("\n"));
77
+ }
78
+
79
+ //#endregion
80
+ //#region src/core/paywalls/products.ts
81
+ function storeOf(row) {
82
+ if (row.platform === "stripe") return "stripe";
83
+ if (row.store === "custom" || row.platform === "custom") return "custom";
84
+ if (row.store === "app_store") return "app-store";
85
+ if (row.store === "play_store") return "play-store";
86
+ }
87
+ async function listProjectCatalogue(api, projectId) {
88
+ const rows = await api.list(`/v2/products?project_id=${encodeURIComponent(projectId)}`);
89
+ const variables = /* @__PURE__ */ new Map();
90
+ const stores = /* @__PURE__ */ new Map();
91
+ for (const row of rows) {
92
+ if (!row.identifier) continue;
93
+ variables.set(row.identifier, productVariables(row));
94
+ const store = storeOf(row);
95
+ if (store === void 0) continue;
96
+ const known = stores.get(row.identifier) ?? [];
97
+ if (!known.includes(store)) stores.set(row.identifier, [...known, store]);
98
+ }
99
+ return {
100
+ variables: Object.fromEntries(variables),
101
+ stores: Object.fromEntries(stores)
102
+ };
103
+ }
104
+ async function listProjectProducts(api, projectId) {
105
+ return (await listProjectCatalogue(api, projectId)).variables;
106
+ }
107
+ async function listApplicationCatalogue(api, applicationId) {
108
+ const projectId = await projectForApplication(api, applicationId);
109
+ if (projectId === void 0) return {
110
+ variables: {},
111
+ stores: {}
112
+ };
113
+ return listProjectCatalogue(api, projectId);
114
+ }
115
+ async function projectForApplication(api, applicationId) {
116
+ const found = await findApplication(api, applicationId).catch(() => void 0);
117
+ return found ? String(found.project.id) : void 0;
118
+ }
119
+ var MissingProductError = class extends Error {};
120
+ function requireProducts(catalogue, surfaces) {
121
+ const gaps = surfaces.flatMap((surface) => Object.entries(surface.products ?? {}).filter(([, identifier]) => !Object.hasOwn(catalogue, identifier)).map(([reference, identifier]) => ` ${surface.id}: ${reference} → ${identifier}`));
122
+ if (gaps.length === 0) return;
123
+ throw new MissingProductError([
124
+ gaps.length === 1 ? "This product does not exist on Superwall:" : `These ${gaps.length} products do not exist on Superwall:`,
125
+ ...gaps,
126
+ "",
127
+ "Every variable on them would be undefined on device. Add them in the",
128
+ "dashboard, or point the config at products that exist."
129
+ ].join("\n"));
130
+ }
131
+
132
+ //#endregion
133
+ //#region src/core/paywalls/source/portability.ts
134
+ const SHOWN = 5;
135
+ function portabilityWarning(external) {
136
+ const names = [...new Set(external)].filter((entry) => entry.trim() !== "").sort();
137
+ if (names.length === 0) return void 0;
138
+ const shown = names.slice(0, SHOWN).join(", ");
139
+ const rest = names.length - SHOWN;
140
+ return `${names.length} ${names.length === 1 ? "import resolves" : "imports resolve"} outside superwall/ (${shown}${rest > 0 ? `, and ${rest} more` : ""}) — this project can be edited locally only; remote editing and rebuilds won't be available. For full feature access, move them into superwall/components/ or install from a package registry.`;
141
+ }
142
+ function warnNotPortable(external) {
143
+ const message = portabilityWarning(external);
144
+ if (message) ui.warn(message);
145
+ }
146
+
147
+ //#endregion
148
+ //#region src/core/paywalls/source/source-push.ts
149
+ var GitRequiredError = class extends Error {
150
+ constructor() {
151
+ super("superwall publish requires git for the source step — install git");
152
+ }
153
+ };
154
+ async function assertGit(hasGit = gitAvailable) {
155
+ if (!await hasGit()) throw new GitRequiredError();
156
+ }
157
+ async function pushSource(input) {
158
+ for (let attempt = 0;; attempt++) {
159
+ const access = await mintSourceAccess(input.api, input.paywallId);
160
+ const pushed = await pushSourceTree({
161
+ access,
162
+ base: readSourceBase(input.superwallDir, access.repo),
163
+ overwrite: input.overwrite,
164
+ files: input.files,
165
+ message: {
166
+ kind: input.kind,
167
+ surface: input.surface,
168
+ version: input.version,
169
+ paywallId: input.paywallId,
170
+ applicationId: input.applicationId,
171
+ snapshotSha: input.snapshotId,
172
+ framework: input.framework,
173
+ cli: input.cli,
174
+ note: input.note,
175
+ external: input.external
176
+ }
177
+ });
178
+ if (pushed.syncedTo) writeSourceBase(input.superwallDir, access.repo, pushed.syncedTo);
179
+ try {
180
+ await linkCommit(input, access, pushed.commitSha);
181
+ return pushed;
182
+ } catch (error) {
183
+ if (attempt === 0 && error instanceof ApiError && error.status === 409) continue;
184
+ throw error;
185
+ }
186
+ }
187
+ }
188
+ const LINK_ATTEMPTS = 2;
189
+ const LINK_RETRY_DELAY_MS = 300;
190
+ async function linkCommit(input, access, commitSha) {
191
+ for (let attempt = 1;; attempt++) try {
192
+ await linkSourceCommit(input.api, input.paywallId, input.version, {
193
+ commitSha,
194
+ tokenId: access.tokenId
195
+ });
196
+ return;
197
+ } catch (error) {
198
+ if (attempt >= LINK_ATTEMPTS || !isTransient(error)) throw error;
199
+ await setTimeout(LINK_RETRY_DELAY_MS);
200
+ }
201
+ }
202
+ const isTransient = (error) => error instanceof ApiUnreachableError || error instanceof ApiError && error.status >= 500;
203
+
204
+ //#endregion
205
+ export { listProjectCatalogue as a, requireProducts as c, listApplicationCatalogue as i, resolveBinding as l, pushSource as n, listProjectProducts as o, warnNotPortable as r, projectForApplication as s, assertGit as t };
@@ -1,7 +1,7 @@
1
- import { r as NotLoggedInError } from "./token-CPplNMVa.js";
1
+ import { r as NotLoggedInError } from "./token-lUUOkTJA.js";
2
2
  import { i as writeJson, n as createCommandOutput } from "./output-Ggzq5_-t.js";
3
- import { a as CHANNEL } from "./environment-DBwo79dy.js";
4
- import { t as ApiError } from "./client-BF9rCULI.js";
3
+ import { a as CHANNEL } from "./environment-i8BhiBDB.js";
4
+ import { t as ApiError } from "./client-DOgk9gAS.js";
5
5
  import { n as ui, r as useRenderer } from "./ui-D_qf3Gvw.js";
6
6
  import pc from "picocolors";
7
7
 
@@ -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-DBwo79dy.js";
2
+ import { n as API_HOST_OVERRIDE, t as API_HOST } from "./environment-i8BhiBDB.js";
3
3
 
4
4
  //#region src/core/account/storage.ts
5
5
  const sessionOrgName = (session) => {
@@ -0,0 +1,16 @@
1
+ import "./token-lUUOkTJA.js";
2
+ import "./output-Ggzq5_-t.js";
3
+ import "./environment-i8BhiBDB.js";
4
+ import "./storage-VagEaaJC.js";
5
+ import "./client-DOgk9gAS.js";
6
+ import "./config-BO1Y87kV.js";
7
+ import "./spinner-BN3U1CVB.js";
8
+ import "./ui-D_qf3Gvw.js";
9
+ import "./resources-BTnczJCA.js";
10
+ import "./org-BiFPjoHD.js";
11
+ import "./lookup-flTi0at0.js";
12
+ import "./scope-Db7blD-l.js";
13
+ import "./input-vi0bou04.js";
14
+ import { n as writeStoreKit, t as generateStoreKit } from "./storekit-CoOf4Rvh.js";
15
+
16
+ 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-BClMQGGN.js";
3
- import { m as listResource } from "./resources-Bo6i7wBi.js";
4
- import { a as pickScope } from "./scope-CPG_wWXL.js";
2
+ import { t as apiCall } from "./spinner-BN3U1CVB.js";
3
+ import { h as listResource } from "./resources-BTnczJCA.js";
4
+ import { a as pickScope } from "./scope-Db7blD-l.js";
5
5
  import { r as textOf } from "./input-vi0bou04.js";
6
6
  import { writeFileSync } from "node:fs";
7
7
 
@@ -1,4 +1,4 @@
1
- import { S as isNonInteractive, g as TELEMETRY_KEY, h as TELEMETRY_HOST, v as VERSION } from "./environment-DBwo79dy.js";
1
+ import { S as isNonInteractive, g as TELEMETRY_KEY, h as TELEMETRY_HOST, v as VERSION } from "./environment-i8BhiBDB.js";
2
2
  import { h as writeTelemetryNoticeShown, l as telemetryNoticeShown, t as readAnonymousId } from "./config-BO1Y87kV.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-Po9E-CHL.js";
1
+ import { l as writeSession, n as readSession } from "./storage-VagEaaJC.js";
2
2
 
3
3
  //#region src/core/account/errors.ts
4
4
  var NotLoggedInError = class extends Error {
package/dist/tools.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "./storage-BbJF7z3l.js";
1
+ import "./storage-gRyQetN9.js";
2
2
 
3
3
  //#region src/core/api/client.d.ts
4
4