@superwall/cli 1.7.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -52
- package/dist/{setup-Bxj22rYi.js → apple-CSzNTGHM.js} +82 -76
- package/dist/auth.d.ts +4 -19
- package/dist/auth.js +4 -2
- package/dist/{actions-B7ym3oVS.js → billing-C3Q8DBU2.js} +98 -28
- package/dist/{bind-YrJvuRF9.js → bind-BumHTi9O.js} +38 -33
- package/dist/{build-DLoCW5Ri.js → build-Bpviiclc.js} +20 -26
- package/dist/client-BL0f_yGf.js +176 -0
- package/dist/{asc-Bf7zBbyS.js → client-BZ1UbpXz.js} +16 -15
- package/dist/config-BO1Y87kV.js +105 -0
- package/dist/create-BSfvpWoD.js +19 -0
- package/dist/{create-pkANt1Gs.js → create-BUcVG4Ab.js} +195 -169
- package/dist/{notification-url-DuKF2659.js → create-CfK3PeKA.js} +235 -539
- package/dist/doctor-BWqIYcMn.js +83 -0
- package/dist/{drivers-Qx9LxmRN.js → drivers-CPhdPkW5.js} +185 -172
- package/dist/entry.d.ts +0 -5
- package/dist/entry.js +28072 -1134
- package/dist/environment-eBXjELoN.js +58 -0
- package/dist/{existing-AVEfZu2A.js → existing-BltvQiX5.js} +12 -6
- package/dist/held-CPve03KJ.js +16 -0
- package/dist/held-DgnTFMl3.js +1112 -0
- package/dist/input-vi0bou04.js +42 -0
- package/dist/{integrate-brmhPG-S.js → integrate-BRsqoe01.js} +277 -254
- package/dist/log-NVhVe_oe.js +62 -0
- package/dist/login-BCEH5q0U.js +53 -0
- package/dist/login-BPOONe7n.js +16 -0
- package/dist/{login-Do4wFuLv.js → login-BbTIrCFT.js} +118 -55
- package/dist/lookup-rr1AkCJA.js +71 -0
- package/dist/migrate-C9X2Vz81.js +274 -0
- package/dist/notification-url-CV86qiKP.js +100 -0
- package/dist/{open-studio-DOw-6ydc.js → open-CcpXotHG.js} +34 -43
- package/dist/org-BQQDo7wm.js +35 -0
- package/dist/output-Ggzq5_-t.js +122 -0
- package/dist/paths-CRlU72cq.js +29 -0
- package/dist/playbook-DVMXN7fh.js +53 -0
- package/dist/{asc-products-9JXtDxI4.js → products-DH_fK9tY.js} +6 -6
- package/dist/promote-Da8xctzy.js +91 -0
- package/dist/push-BV-grvQg.js +22 -0
- package/dist/push-D6R9icWN.js +495 -0
- package/dist/registry-BYVD-_h6.js +10385 -0
- package/dist/{reports-CfJqoava.js → reports-D_qbl7_u.js} +7 -6
- package/dist/{resources-Bf9O1JNM.js → resources-DLON3-61.js} +162 -55
- package/dist/{run-DsVZ5snL.js → run-Co-BwhOg.js} +16 -22
- package/dist/scan-B88OlWOt.js +4 -0
- package/dist/{scan-zKsddO72.js → scan-CKuk-_6W.js} +48 -37
- package/dist/scope-DV22_Ufm.js +198 -0
- package/dist/screenshot-file-tVBfUEIi.js +16 -0
- package/dist/{selection-CxZoX4NT.js → selection-C2_KbLuo.js} +100 -51
- package/dist/server-C4f6ccUr.js +22 -0
- package/dist/{dev-DmB3XqaJ.js → server-D0d2oP-5.js} +86 -94
- package/dist/session-B-Uz0cQ7.js +40 -0
- package/dist/session-BuvArt1j.js +6 -0
- package/dist/session-C4rbE3VS.js +796 -0
- package/dist/skills/animate-onboarding/SKILL.md +467 -0
- package/dist/skills/animate-onboarding/references/engine.md +494 -0
- package/dist/skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/skills/animate-onboarding/references/performance.md +41 -0
- package/dist/skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/skills/index.json +37 -0
- package/dist/skills/mobile-design/SKILL.md +447 -0
- package/dist/skills/mobile-design/references/responsive.md +162 -0
- package/dist/skills/onboarding-questions/SKILL.md +231 -0
- package/dist/skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/skills/onboarding-questions/references/craft.md +142 -0
- package/dist/skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/skills/superwall/SKILL.md +82 -9
- package/dist/skills/superwall/references/api.md +153 -37
- package/dist/skills/superwall/references/apple-setup.md +316 -0
- package/dist/skills/superwall/references/asc.md +74 -38
- package/dist/skills/superwall/references/data-analytics.md +55 -21
- package/dist/skills/superwall/workflows/dashboard/playbook.md +3 -3
- package/dist/skills/superwall/workflows/dashboard/setup.md +8 -8
- package/dist/skills/superwall/workflows/migrate/adapty.md +6 -6
- package/dist/skills/superwall/workflows/migrate/playbook.md +4 -4
- package/dist/skills/superwall/workflows/migrate/qonversion.md +5 -5
- package/dist/skills/superwall/workflows/migrate/revenuecat.md +6 -6
- package/dist/skills/superwall/workflows/placements/android.md +2 -2
- package/dist/skills/superwall/workflows/placements/expo.md +2 -2
- package/dist/skills/superwall/workflows/placements/flutter.md +2 -2
- package/dist/skills/superwall/workflows/placements/ios.md +2 -2
- package/dist/skills/superwall/workflows/placements/playbook.md +2 -2
- package/dist/skills/superwall/workflows/placements/react-native.md +2 -2
- package/dist/skills/superwall/workflows/placements/strategy.md +2 -2
- package/dist/skills/superwall/workflows/review/playbook.md +1 -1
- package/dist/skills/superwall-editor/SKILL.md +61 -0
- package/dist/skills/superwall-editor/references/cli.md +135 -0
- package/dist/skills/superwall-editor/references/design.md +51 -0
- package/dist/skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/skills/superwall-editor/references/workflow.md +65 -0
- package/dist/skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/skills/superwall-framework/SKILL.md +85 -31
- package/dist/skills/superwall-framework/references/cli.md +58 -27
- package/dist/skills/superwall-framework/references/examples.md +4 -3
- package/dist/skills/superwall-framework/references/layout.md +64 -9
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +1 -1
- package/dist/skills/superwall-framework/references/onboarding-state.md +245 -0
- package/dist/skills/wwdc/SKILL.md +22 -0
- package/dist/skills/wwdc/references/docs.md +52 -0
- package/dist/skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/skills-CLGJuMnF.js +14 -0
- package/dist/{skills-DPzlnfCK.js → skills-CZcpnEnG.js} +100 -122
- package/dist/{spawn-DSoTXy_j.js → spawn-DmmmHIP-.js} +14 -12
- package/dist/spinner-C2U6QBJ9.js +294 -0
- package/dist/storage-6h9vyiAz.js +31 -0
- package/dist/storage-CerJ5KLP.d.ts +16 -0
- package/dist/storekit-CK9JmM2D.js +16 -0
- package/dist/storekit-CinJra3V.js +47 -0
- package/dist/telemetry-DKyDhURo.js +56 -0
- package/dist/theme-DUsCh-Vd.js +25 -0
- package/dist/timing-BVxPrYq3.js +5 -0
- package/dist/{token-C0it-Xh7.js → token-DaxQgQkv.js} +6 -38
- package/dist/tools-skills/animate-onboarding/SKILL.md +467 -0
- package/dist/tools-skills/animate-onboarding/references/engine.md +494 -0
- package/dist/tools-skills/animate-onboarding/references/framework/Question.tsx +71 -0
- package/dist/tools-skills/animate-onboarding/references/framework/README.md +40 -0
- package/dist/tools-skills/animate-onboarding/references/framework/answers.ts +19 -0
- package/dist/tools-skills/animate-onboarding/references/framework/flow.ts +80 -0
- package/dist/tools-skills/animate-onboarding/references/framework/handoffs.ts +869 -0
- package/dist/tools-skills/animate-onboarding/references/framework/layout.tsx +113 -0
- package/dist/tools-skills/animate-onboarding/references/framework/motion.css +559 -0
- package/dist/tools-skills/animate-onboarding/references/framework/useStoryRouter.ts +48 -0
- package/dist/tools-skills/animate-onboarding/references/handoffs.md +375 -0
- package/dist/tools-skills/animate-onboarding/references/imageReady.ts +92 -0
- package/dist/tools-skills/animate-onboarding/references/morphFrame.ts +356 -0
- package/dist/tools-skills/animate-onboarding/references/performance.md +41 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/README.md +17 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/handoffs.ts +858 -0
- package/dist/tools-skills/animate-onboarding/references/web-runtime/story-motion.css +301 -0
- package/dist/tools-skills/mobile-design/SKILL.md +447 -0
- package/dist/tools-skills/mobile-design/references/responsive.md +162 -0
- package/dist/tools-skills/onboarding-questions/SKILL.md +231 -0
- package/dist/tools-skills/onboarding-questions/references/arpu-questions.md +139 -0
- package/dist/tools-skills/onboarding-questions/references/craft.md +142 -0
- package/dist/tools-skills/onboarding-questions/references/example-reflective.md +117 -0
- package/dist/tools-skills/superwall/SKILL.md +263 -0
- package/dist/tools-skills/superwall/references/api.md +303 -0
- package/dist/tools-skills/superwall/references/asa.md +166 -0
- package/dist/tools-skills/superwall/references/asc.md +95 -0
- package/dist/tools-skills/superwall/references/dashboard-links.md +57 -0
- package/dist/tools-skills/superwall/references/data-analytics.md +896 -0
- package/dist/tools-skills/superwall/references/docs.md +51 -0
- package/dist/tools-skills/superwall/references/sdk-integration.md +104 -0
- package/dist/tools-skills/superwall/references/sdk-source.md +18 -0
- package/dist/tools-skills/superwall/workflows/dashboard/playbook.md +76 -0
- package/dist/tools-skills/superwall/workflows/dashboard/setup.md +100 -0
- package/dist/tools-skills/superwall/workflows/integrate/android.md +292 -0
- package/dist/tools-skills/superwall/workflows/integrate/expo.md +272 -0
- package/dist/tools-skills/superwall/workflows/integrate/flutter.md +285 -0
- package/dist/tools-skills/superwall/workflows/integrate/ios.md +314 -0
- package/dist/tools-skills/superwall/workflows/integrate/playbook.md +83 -0
- package/dist/tools-skills/superwall/workflows/integrate/react-native.md +246 -0
- package/dist/tools-skills/superwall/workflows/migrate/adapty.md +229 -0
- package/dist/tools-skills/superwall/workflows/migrate/playbook.md +78 -0
- package/dist/tools-skills/superwall/workflows/migrate/qonversion.md +227 -0
- package/dist/tools-skills/superwall/workflows/migrate/revenuecat.md +414 -0
- package/dist/tools-skills/superwall/workflows/placements/android.md +175 -0
- package/dist/tools-skills/superwall/workflows/placements/expo.md +161 -0
- package/dist/tools-skills/superwall/workflows/placements/flutter.md +139 -0
- package/dist/tools-skills/superwall/workflows/placements/ios.md +165 -0
- package/dist/tools-skills/superwall/workflows/placements/playbook.md +69 -0
- package/dist/tools-skills/superwall/workflows/placements/react-native.md +145 -0
- package/dist/tools-skills/superwall/workflows/placements/strategy.md +222 -0
- package/dist/tools-skills/superwall/workflows/review/android.md +120 -0
- package/dist/tools-skills/superwall/workflows/review/expo.md +100 -0
- package/dist/tools-skills/superwall/workflows/review/flutter.md +99 -0
- package/dist/tools-skills/superwall/workflows/review/ios.md +108 -0
- package/dist/tools-skills/superwall/workflows/review/playbook.md +70 -0
- package/dist/tools-skills/superwall/workflows/review/react-native.md +100 -0
- package/dist/tools-skills/superwall-editor/SKILL.md +113 -0
- package/dist/tools-skills/superwall-editor/references/cli.md +135 -0
- package/dist/tools-skills/superwall-editor/references/design.md +51 -0
- package/dist/tools-skills/superwall-editor/references/native-elements.md +171 -0
- package/dist/tools-skills/superwall-editor/references/workflow.md +65 -0
- package/dist/tools-skills/superwall-editor/scripts/sw-editor.sh +662 -0
- package/dist/tools-skills/wwdc/SKILL.md +22 -0
- package/dist/tools-skills/wwdc/references/docs.md +52 -0
- package/dist/tools-skills/wwdc/scripts/wwdc.sh +266 -0
- package/dist/tools.d.ts +96 -0
- package/dist/tools.js +11360 -0
- package/dist/ui-D_qf3Gvw.js +53 -0
- package/dist/upgrade-DPo0a4Es.js +117 -0
- package/dist/upgrade-ffseQDMx.js +7 -0
- package/package.json +10 -5
- package/dist/api-CZzirVMj.js +0 -151
- package/dist/api-output-aJNw7Syy.js +0 -20
- package/dist/app-DH6U8yuI.js +0 -190
- package/dist/asa-C-sQzPPn.js +0 -1194
- package/dist/asc-1ZBJ6DwS.js +0 -778
- package/dist/auth-YRhlV3DE.js +0 -140
- package/dist/billing-CCYHdApx.js +0 -80
- package/dist/bundle-id-CKxl_026.js +0 -121
- package/dist/command-CMIz81Da.js +0 -301
- package/dist/dev-DZy6pOnB.js +0 -22
- package/dist/doctor-H-hf-Yww.js +0 -88
- package/dist/feedback-CKf-rpBW.js +0 -152
- package/dist/hosted-CXe9TrWx.js +0 -32
- package/dist/migrate-C9ERDR6y.js +0 -284
- package/dist/org-sj7uyvp-.js +0 -40
- package/dist/output-C4o2gJ1K.js +0 -146
- package/dist/params-l3CrvRtR.js +0 -51
- package/dist/pipeline-BqzqZhX1.js +0 -977
- package/dist/print-skill-ZojRSybs.js +0 -74
- package/dist/promote-BG8X4Nv_.js +0 -88
- package/dist/publish-sxLh-G4G.js +0 -35
- package/dist/push-bQ6Vxtg8.js +0 -35
- package/dist/query-_FbybaH-.js +0 -53
- package/dist/resource-CGIwSd29.js +0 -323
- package/dist/revenue-provider-ebsRINY8.js +0 -100
- package/dist/scope-BvzD-kO4.js +0 -223
- package/dist/skills-D_R-lEsK.js +0 -64
- package/dist/spinner-TWa0hia6.js +0 -18
- package/dist/storekit-Cj9Cpjcz.js +0 -29
- package/dist/telemetry-DeA1mvnT.js +0 -169
- package/dist/ui-Dy0b-9L8.js +0 -27738
- package/dist/update-B2fWIc4q.js +0 -59
- package/dist/upgrade-BmzkTKrh.js +0 -72
- /package/dist/{devtools-8EgLo86w.js → devtools-pBl_vt03.js} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
1
|
+
import { f as Integration } from "./environment-eBXjELoN.js";
|
|
2
|
+
import { i as readPackageJson, r as allDeps } from "./scan-CKuk-_6W.js";
|
|
3
|
+
import { d as readBundledSkill } from "./skills-CZcpnEnG.js";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import fg from "fast-glob";
|
|
3
6
|
|
|
4
|
-
//#region src/core/agent/actions.ts
|
|
5
|
-
/** Skill reference file per framework, so an agent only sees its own platform's docs. */
|
|
7
|
+
//#region src/core/workflows/agent/actions.ts
|
|
6
8
|
const FRAMEWORK_REF = {
|
|
7
9
|
[Integration.swift]: "ios",
|
|
8
10
|
[Integration.android]: "android",
|
|
@@ -25,84 +27,78 @@ const READ_CAPABILITIES = {
|
|
|
25
27
|
network: true,
|
|
26
28
|
shell: "read-only"
|
|
27
29
|
};
|
|
28
|
-
const
|
|
29
|
-
{
|
|
30
|
+
const actionById = {
|
|
31
|
+
integrate: {
|
|
30
32
|
id: "integrate",
|
|
31
33
|
title: "Integrate the SDK",
|
|
32
34
|
hint: "Install + configure the Superwall SDK",
|
|
33
35
|
runningLabel: "Starting the integration",
|
|
34
36
|
successLabel: "Integration complete",
|
|
35
|
-
requiresIntegration: false,
|
|
36
37
|
requiresOrgKey: false,
|
|
37
38
|
outputMode: "silent",
|
|
38
39
|
capabilities: WRITE_CAPABILITIES,
|
|
39
|
-
vars: (ctx) => ({ skill:
|
|
40
|
+
vars: (ctx) => ({ skill: readBundledSkill("superwall-integrate", FRAMEWORK_REF[ctx.app.framework.integration]) })
|
|
40
41
|
},
|
|
41
|
-
{
|
|
42
|
+
review: {
|
|
42
43
|
id: "review",
|
|
43
44
|
title: "Review the setup",
|
|
44
45
|
hint: "Audit the SDK, purchasing, identity, deep links, placements & dashboard",
|
|
45
46
|
runningLabel: "Reviewing your Superwall setup",
|
|
46
47
|
successLabel: "Setup review complete",
|
|
47
|
-
requiresIntegration: true,
|
|
48
48
|
requiresOrgKey: false,
|
|
49
49
|
outputMode: "report",
|
|
50
50
|
capabilities: READ_CAPABILITIES,
|
|
51
|
-
vars: (ctx) => ({ skill:
|
|
51
|
+
vars: (ctx) => ({ skill: readBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration]) })
|
|
52
52
|
},
|
|
53
|
-
{
|
|
53
|
+
"review-fix": {
|
|
54
54
|
id: "review-fix",
|
|
55
55
|
title: "Fix setup issues",
|
|
56
56
|
hint: "Apply verified, safe fixes from the setup review",
|
|
57
57
|
runningLabel: "Fixing your Superwall setup",
|
|
58
58
|
successLabel: "Setup fixes complete",
|
|
59
|
-
requiresIntegration: true,
|
|
60
59
|
requiresOrgKey: false,
|
|
61
60
|
outputMode: "silent",
|
|
62
61
|
capabilities: WRITE_CAPABILITIES,
|
|
63
62
|
vars: (ctx) => ({
|
|
64
63
|
prior_report: ctx.priorReport ?? "",
|
|
65
|
-
skill:
|
|
64
|
+
skill: readBundledSkill("superwall-review", FRAMEWORK_REF[ctx.app.framework.integration])
|
|
66
65
|
})
|
|
67
66
|
},
|
|
68
|
-
{
|
|
67
|
+
"placements-review": {
|
|
69
68
|
id: "placements-review",
|
|
70
69
|
title: "Review placements",
|
|
71
70
|
hint: "Audit every register() call + positioning",
|
|
72
71
|
runningLabel: "Reviewing placements",
|
|
73
72
|
successLabel: "Placement review complete",
|
|
74
|
-
requiresIntegration: true,
|
|
75
73
|
requiresOrgKey: false,
|
|
76
74
|
outputMode: "report",
|
|
77
75
|
capabilities: READ_CAPABILITIES,
|
|
78
76
|
vars: (ctx) => ({
|
|
79
77
|
campaigns: ctx.campaigns ?? "",
|
|
80
|
-
skill:
|
|
78
|
+
skill: readBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
|
|
81
79
|
})
|
|
82
80
|
},
|
|
83
|
-
{
|
|
81
|
+
"placements-implement": {
|
|
84
82
|
id: "placements-implement",
|
|
85
83
|
title: "Implement placements",
|
|
86
84
|
hint: "Add register() calls at the right feature gates",
|
|
87
85
|
runningLabel: "Implementing placements",
|
|
88
86
|
successLabel: "Placements implemented",
|
|
89
|
-
requiresIntegration: true,
|
|
90
87
|
requiresOrgKey: false,
|
|
91
88
|
outputMode: "silent",
|
|
92
89
|
capabilities: WRITE_CAPABILITIES,
|
|
93
90
|
vars: (ctx) => ({
|
|
94
91
|
prior_report: ctx.priorReport ?? "",
|
|
95
92
|
campaigns: ctx.campaigns ?? "",
|
|
96
|
-
skill:
|
|
93
|
+
skill: readBundledSkill("superwall-placements", ["strategy", FRAMEWORK_REF[ctx.app.framework.integration]])
|
|
97
94
|
})
|
|
98
95
|
},
|
|
99
|
-
{
|
|
96
|
+
"dashboard-setup": {
|
|
100
97
|
id: "dashboard-setup",
|
|
101
98
|
title: "Set up the dashboard",
|
|
102
99
|
hint: "Create a campaign + placement so paywalls present",
|
|
103
100
|
runningLabel: "Setting up the dashboard",
|
|
104
101
|
successLabel: "Dashboard configured",
|
|
105
|
-
requiresIntegration: false,
|
|
106
102
|
requiresOrgKey: true,
|
|
107
103
|
outputMode: "report",
|
|
108
104
|
capabilities: {
|
|
@@ -111,17 +107,16 @@ const ACTIONS = [
|
|
|
111
107
|
shell: "unrestricted"
|
|
112
108
|
},
|
|
113
109
|
vars: (ctx) => ({
|
|
114
|
-
skill:
|
|
110
|
+
skill: readBundledSkill("superwall-dashboard"),
|
|
115
111
|
app_key: ctx.apiKey || "(the app you're working on)"
|
|
116
112
|
})
|
|
117
113
|
},
|
|
118
|
-
{
|
|
114
|
+
migrate: {
|
|
119
115
|
id: "migrate",
|
|
120
116
|
title: "Migrate to Superwall",
|
|
121
117
|
hint: "Move products, entitlements & paywalls off your current provider",
|
|
122
118
|
runningLabel: "Migrating to Superwall",
|
|
123
119
|
successLabel: "Migration complete",
|
|
124
|
-
requiresIntegration: false,
|
|
125
120
|
requiresOrgKey: false,
|
|
126
121
|
outputMode: "report",
|
|
127
122
|
capabilities: WRITE_CAPABILITIES,
|
|
@@ -130,12 +125,87 @@ const ACTIONS = [
|
|
|
130
125
|
return {
|
|
131
126
|
provider,
|
|
132
127
|
goal: ctx.migrateIntent === "paywalls" ? `paywalls only, keep ${provider} for billing` : "full migration",
|
|
133
|
-
skill:
|
|
128
|
+
skill: readBundledSkill("superwall-migrate", PROVIDER_REF[provider.toLowerCase()])
|
|
134
129
|
};
|
|
135
130
|
}
|
|
136
131
|
}
|
|
132
|
+
};
|
|
133
|
+
const ACTIONS = Object.values(actionById);
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/core/codebase/billing.ts
|
|
137
|
+
const IGNORE = [
|
|
138
|
+
"**/node_modules/**",
|
|
139
|
+
"**/.git/**",
|
|
140
|
+
"**/Pods/**",
|
|
141
|
+
"**/build/**",
|
|
142
|
+
"**/.build/**",
|
|
143
|
+
"**/dist/**"
|
|
137
144
|
];
|
|
138
|
-
|
|
145
|
+
function detectBilling(app) {
|
|
146
|
+
const deps = allDeps(readPackageJson(app.path));
|
|
147
|
+
const inDeps = (names) => names.some((n) => n in deps);
|
|
148
|
+
let revenueCat = inDeps([
|
|
149
|
+
"react-native-purchases",
|
|
150
|
+
"@revenuecat/purchases-js",
|
|
151
|
+
"purchases-capacitor",
|
|
152
|
+
"purchases_flutter"
|
|
153
|
+
]);
|
|
154
|
+
let adapty = inDeps(["react-native-adapty", "adapty_flutter"]);
|
|
155
|
+
let qonversion = inDeps(["react-native-qonversion", "qonversion_flutter"]);
|
|
156
|
+
const manifests = fg.sync([
|
|
157
|
+
"**/Package.resolved",
|
|
158
|
+
"**/Package.swift",
|
|
159
|
+
"**/Project.swift",
|
|
160
|
+
"**/Podfile",
|
|
161
|
+
"**/Podfile.lock",
|
|
162
|
+
"**/project.pbxproj",
|
|
163
|
+
"**/*.gradle",
|
|
164
|
+
"**/*.gradle.kts",
|
|
165
|
+
"**/pubspec.yaml",
|
|
166
|
+
"**/pubspec.lock"
|
|
167
|
+
], {
|
|
168
|
+
cwd: app.path,
|
|
169
|
+
ignore: IGNORE,
|
|
170
|
+
absolute: true,
|
|
171
|
+
deep: 5
|
|
172
|
+
});
|
|
173
|
+
for (const f of manifests) {
|
|
174
|
+
let c;
|
|
175
|
+
try {
|
|
176
|
+
c = readFileSync(f, "utf8");
|
|
177
|
+
} catch {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (/RevenueCat|\bPurchases\b|purchases_flutter/i.test(c)) revenueCat = true;
|
|
181
|
+
if (/Adapty/i.test(c)) adapty = true;
|
|
182
|
+
if (/Qonversion/i.test(c)) qonversion = true;
|
|
183
|
+
}
|
|
184
|
+
if (!revenueCat || !adapty || !qonversion) {
|
|
185
|
+
const sources = fg.sync(["**/*.swift", "**/*.kt"], {
|
|
186
|
+
cwd: app.path,
|
|
187
|
+
ignore: IGNORE,
|
|
188
|
+
absolute: true,
|
|
189
|
+
deep: 6
|
|
190
|
+
}).slice(0, 600);
|
|
191
|
+
for (const f of sources) {
|
|
192
|
+
let c;
|
|
193
|
+
try {
|
|
194
|
+
c = readFileSync(f, "utf8");
|
|
195
|
+
} catch {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (/import RevenueCat|com\.revenuecat/.test(c)) revenueCat = true;
|
|
199
|
+
if (/import Adapty|com\.adapty/.test(c)) adapty = true;
|
|
200
|
+
if (/import Qonversion|com\.qonversion/.test(c)) qonversion = true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
revenueCat,
|
|
205
|
+
adapty,
|
|
206
|
+
qonversion
|
|
207
|
+
};
|
|
208
|
+
}
|
|
139
209
|
|
|
140
210
|
//#endregion
|
|
141
|
-
export { FRAMEWORK_REF as n, actionById as r,
|
|
211
|
+
export { FRAMEWORK_REF as n, actionById as r, detectBilling as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { f as Integration } from "./environment-eBXjELoN.js";
|
|
2
|
+
import { n as withSpinner } from "./spinner-C2U6QBJ9.js";
|
|
3
|
+
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
4
|
+
import { n as createApplication, p as listProjects, s as createProject, v as platformLabel } from "./resources-DLON3-61.js";
|
|
5
|
+
import { n as orgForNewProject } from "./org-BQQDo7wm.js";
|
|
5
6
|
|
|
6
7
|
//#region src/core/account/bind.ts
|
|
7
8
|
const NEW = "__new__";
|
|
@@ -16,18 +17,18 @@ function platformForIntegration(integration) {
|
|
|
16
17
|
case Integration.expo:
|
|
17
18
|
case Integration.reactNative: return "react_native";
|
|
18
19
|
case Integration.web: return "web";
|
|
19
|
-
default: return "ios";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
async function resolveAppBinding(api, opts) {
|
|
23
|
-
const projects = await
|
|
23
|
+
const projects = await withSpinner("Loading your projects", () => listProjects(api));
|
|
24
24
|
let lastProjectId;
|
|
25
25
|
for (;;) {
|
|
26
26
|
const project = await pickProject(api, projects, opts.appName, lastProjectId);
|
|
27
27
|
if (project === "cancel") return null;
|
|
28
28
|
lastProjectId = String(project.id);
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
29
|
+
const picked = await pickApp(api, project, opts);
|
|
30
|
+
if (picked === "back") continue;
|
|
31
|
+
const { app } = picked;
|
|
31
32
|
if (!app.public_api_key) {
|
|
32
33
|
ui.warn(`\`${app.name ?? app.id}\` has no SDK key yet - pick another or add a new app.`);
|
|
33
34
|
return null;
|
|
@@ -35,7 +36,7 @@ async function resolveAppBinding(api, opts) {
|
|
|
35
36
|
return {
|
|
36
37
|
apiKey: app.public_api_key,
|
|
37
38
|
app,
|
|
38
|
-
projectId: String(project.id),
|
|
39
|
+
projectId: String(picked.project.id),
|
|
39
40
|
applicationId: String(app.id)
|
|
40
41
|
};
|
|
41
42
|
}
|
|
@@ -56,7 +57,8 @@ async function resolveScopeFromKey(api, publicApiKey) {
|
|
|
56
57
|
}
|
|
57
58
|
async function pickProject(api, projects, defaultName, preselect) {
|
|
58
59
|
for (;;) {
|
|
59
|
-
|
|
60
|
+
const first = projects[0];
|
|
61
|
+
if (!first) {
|
|
60
62
|
const created = await createProjectFlow(api, defaultName);
|
|
61
63
|
return created === "back" ? "cancel" : created;
|
|
62
64
|
}
|
|
@@ -70,7 +72,7 @@ async function pickProject(api, projects, defaultName, preselect) {
|
|
|
70
72
|
value: NEW,
|
|
71
73
|
label: "+ Create a new project"
|
|
72
74
|
}],
|
|
73
|
-
initialValue: preselect ?? String(
|
|
75
|
+
initialValue: preselect ?? String(first.id),
|
|
74
76
|
footer: CANCEL,
|
|
75
77
|
transient: true
|
|
76
78
|
});
|
|
@@ -80,14 +82,16 @@ async function pickProject(api, projects, defaultName, preselect) {
|
|
|
80
82
|
if (created === "back") continue;
|
|
81
83
|
return created;
|
|
82
84
|
}
|
|
83
|
-
|
|
85
|
+
const picked = projects.find((p) => String(p.id) === sel);
|
|
86
|
+
if (picked) return picked;
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
async function pickApp(api, project, opts) {
|
|
87
90
|
for (;;) {
|
|
88
91
|
const apps = project.applications ?? [];
|
|
89
92
|
const label = platformLabel(opts.platform);
|
|
90
|
-
|
|
93
|
+
const first = apps[0];
|
|
94
|
+
if (!first) {
|
|
91
95
|
if (await ui.select({
|
|
92
96
|
message: `No apps in \`${project.name ?? "this project"}\` yet.`,
|
|
93
97
|
options: [{
|
|
@@ -101,10 +105,13 @@ async function pickApp(api, project, opts) {
|
|
|
101
105
|
}) === null) return "back";
|
|
102
106
|
const created = await createAppFlow(api, project, opts);
|
|
103
107
|
if (created === "back") continue;
|
|
104
|
-
return
|
|
108
|
+
return {
|
|
109
|
+
project,
|
|
110
|
+
app: created
|
|
111
|
+
};
|
|
105
112
|
}
|
|
106
113
|
const platformTaken = apps.some((a) => a.platform === opts.platform);
|
|
107
|
-
const match = apps.find((a) => a.platform === opts.platform) ??
|
|
114
|
+
const match = apps.find((a) => a.platform === opts.platform) ?? first;
|
|
108
115
|
const options = apps.map((a) => ({
|
|
109
116
|
value: String(a.id),
|
|
110
117
|
label: a.name ?? String(a.id),
|
|
@@ -129,20 +136,30 @@ async function pickApp(api, project, opts) {
|
|
|
129
136
|
if (sel === NEW) {
|
|
130
137
|
const created = await createAppFlow(api, project, opts);
|
|
131
138
|
if (created === "back") continue;
|
|
132
|
-
return
|
|
139
|
+
return {
|
|
140
|
+
project,
|
|
141
|
+
app: created
|
|
142
|
+
};
|
|
133
143
|
}
|
|
134
144
|
if (sel === NEW_PROJECT) {
|
|
135
145
|
const fresh = await createProjectFlow(api, opts.appName);
|
|
136
146
|
if (fresh === "back") continue;
|
|
137
147
|
const created = await createAppFlow(api, fresh, opts);
|
|
138
148
|
if (created === "back") continue;
|
|
139
|
-
return
|
|
149
|
+
return {
|
|
150
|
+
project: fresh,
|
|
151
|
+
app: created
|
|
152
|
+
};
|
|
140
153
|
}
|
|
141
|
-
|
|
154
|
+
const picked = apps.find((a) => String(a.id) === sel);
|
|
155
|
+
if (picked) return {
|
|
156
|
+
project,
|
|
157
|
+
app: picked
|
|
158
|
+
};
|
|
142
159
|
}
|
|
143
160
|
}
|
|
144
161
|
async function createProjectFlow(api, defaultName) {
|
|
145
|
-
await
|
|
162
|
+
const organizationId = await orgForNewProject(api, true);
|
|
146
163
|
const name = await ui.text({
|
|
147
164
|
message: "Name your new project",
|
|
148
165
|
placeholder: defaultName,
|
|
@@ -151,7 +168,7 @@ async function createProjectFlow(api, defaultName) {
|
|
|
151
168
|
transient: true
|
|
152
169
|
});
|
|
153
170
|
if (name === null) return "back";
|
|
154
|
-
const created = await
|
|
171
|
+
const created = await withSpinner("Creating project", () => createProject(api, name.trim(), organizationId));
|
|
155
172
|
ui.success(`Created project \`${created.name ?? name.trim()}\``);
|
|
156
173
|
return {
|
|
157
174
|
id: created.id,
|
|
@@ -179,7 +196,7 @@ async function createAppFlow(api, project, opts) {
|
|
|
179
196
|
});
|
|
180
197
|
if (bundle === null) continue;
|
|
181
198
|
const bundleId = bundle.trim() || opts.bundleId;
|
|
182
|
-
const parent = await
|
|
199
|
+
const parent = await withSpinner(`Adding the ${label} app`, () => createApplication(api, { projectId: String(project.id) }, {
|
|
183
200
|
name: name.trim(),
|
|
184
201
|
platform: opts.platform,
|
|
185
202
|
bundleId
|
|
@@ -197,18 +214,6 @@ function appCountHint(p) {
|
|
|
197
214
|
const n = (p.applications ?? []).length;
|
|
198
215
|
return `${n} app${n === 1 ? "" : "s"}`;
|
|
199
216
|
}
|
|
200
|
-
async function loading(label, work) {
|
|
201
|
-
const spin = ui.spinner();
|
|
202
|
-
spin.start(label);
|
|
203
|
-
try {
|
|
204
|
-
const result = await work();
|
|
205
|
-
spin.stop(label);
|
|
206
|
-
return result;
|
|
207
|
-
} catch (e) {
|
|
208
|
-
spin.stop("Failed");
|
|
209
|
-
throw e;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
217
|
|
|
213
218
|
//#endregion
|
|
214
219
|
export { resolveAppBinding as n, resolveScopeFromKey as r, platformForIntegration as t };
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import * as path from "node:path";
|
|
1
|
+
import "./token-DaxQgQkv.js";
|
|
2
|
+
import "./output-Ggzq5_-t.js";
|
|
3
|
+
import { _ as VERSION } from "./environment-eBXjELoN.js";
|
|
4
|
+
import "./storage-6h9vyiAz.js";
|
|
5
|
+
import "./client-BL0f_yGf.js";
|
|
6
|
+
import "./config-BO1Y87kV.js";
|
|
7
|
+
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
8
|
+
import "./resources-DLON3-61.js";
|
|
9
|
+
import { N as resolveFramework, P as assetBaseUrl, a as resolveProjectDir, d as kb, h as took, i as requireProject, n as parseIds, s as selectSurfaces, v as collectProjectDeclarations, w as readLock, y as writeProjectTypes } from "./selection-C2_KbLuo.js";
|
|
11
10
|
import * as fs from "node:fs";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import pc from "picocolors";
|
|
12
13
|
|
|
13
|
-
//#region src/
|
|
14
|
+
//#region src/core/paywalls/pipeline/build.ts
|
|
14
15
|
const PLATFORMS = new Set([
|
|
15
16
|
"ios",
|
|
16
17
|
"android",
|
|
17
18
|
"web"
|
|
18
19
|
]);
|
|
19
|
-
function parseBuildPlatforms(
|
|
20
|
-
const platforms = parseIds(
|
|
20
|
+
function parseBuildPlatforms(values) {
|
|
21
|
+
const platforms = parseIds(values);
|
|
21
22
|
for (const platform of platforms) if (!PLATFORMS.has(platform)) throw new Error(`Unknown platform "${platform}" — use ios, android or web.`);
|
|
22
23
|
return platforms.length === 0 ? [void 0] : platforms;
|
|
23
24
|
}
|
|
@@ -33,13 +34,13 @@ function boundAssetBaseUrl(project, surface, platform) {
|
|
|
33
34
|
return assetBaseUrl(applicationId);
|
|
34
35
|
}
|
|
35
36
|
async function runBuildPipeline(context, options = {}) {
|
|
36
|
-
const dir =
|
|
37
|
-
const framework = await (options.load ??
|
|
37
|
+
const dir = resolveProjectDir(options.dir);
|
|
38
|
+
const framework = await (options.load ?? resolveFramework)(dir);
|
|
38
39
|
const project = requireProject(framework.discoverProject(dir), dir);
|
|
39
40
|
writeProjectTypes(project, (await collectProjectDeclarations(framework, project.root)).products);
|
|
40
|
-
const surfaces = selectSurfaces(project,
|
|
41
|
-
const platforms = parseBuildPlatforms(
|
|
42
|
-
const out = path.resolve(
|
|
41
|
+
const surfaces = selectSurfaces(project, options.ids ?? []);
|
|
42
|
+
const platforms = parseBuildPlatforms(options.platforms ?? []);
|
|
43
|
+
const out = path.resolve(options.out ?? path.join(project.superwallDir, ".superwall", "build"));
|
|
43
44
|
context.output.render({
|
|
44
45
|
kind: "intro",
|
|
45
46
|
text: `Superwall ${pc.dim(`v${VERSION}`)}`
|
|
@@ -75,13 +76,6 @@ async function runBuildPipeline(context, options = {}) {
|
|
|
75
76
|
if (context.json) context.output.data({ builds: outcomes });
|
|
76
77
|
return outcomes;
|
|
77
78
|
}
|
|
78
|
-
const runBuild = defineCommand({
|
|
79
|
-
name: "build",
|
|
80
|
-
output: "both",
|
|
81
|
-
async run(context) {
|
|
82
|
-
await runBuildPipeline(context);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
79
|
|
|
86
80
|
//#endregion
|
|
87
|
-
export { outputFile, parseBuildPlatforms,
|
|
81
|
+
export { outputFile, parseBuildPlatforms, runBuildPipeline };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { n as resolveAuthToken, r as NotLoggedInError } from "./token-DaxQgQkv.js";
|
|
2
|
+
import { r as resolveApiHost, t as readSession } from "./storage-6h9vyiAz.js";
|
|
3
|
+
|
|
4
|
+
//#region src/core/api/client.ts
|
|
5
|
+
const BODY_SNIPPET = 200;
|
|
6
|
+
function parseErrorEnvelope(body) {
|
|
7
|
+
let parsed;
|
|
8
|
+
try {
|
|
9
|
+
parsed = JSON.parse(body);
|
|
10
|
+
} catch {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (typeof parsed !== "object" || parsed === null) return void 0;
|
|
14
|
+
const text = (key) => {
|
|
15
|
+
const value = Reflect.get(parsed, key);
|
|
16
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
17
|
+
};
|
|
18
|
+
const message = text("message");
|
|
19
|
+
if (message === void 0) return void 0;
|
|
20
|
+
return {
|
|
21
|
+
message,
|
|
22
|
+
detail: {
|
|
23
|
+
type: text("type"),
|
|
24
|
+
code: text("code"),
|
|
25
|
+
param: text("param"),
|
|
26
|
+
docUrl: text("doc_url"),
|
|
27
|
+
resourceType: text("resource_type"),
|
|
28
|
+
resourceId: text("resource_id")
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var ApiError = class extends Error {
|
|
33
|
+
detail;
|
|
34
|
+
request;
|
|
35
|
+
envelope;
|
|
36
|
+
hint;
|
|
37
|
+
constructor(request, status, body) {
|
|
38
|
+
const envelope = body === void 0 ? void 0 : parseErrorEnvelope(body);
|
|
39
|
+
const snippet = body?.trim().slice(0, BODY_SNIPPET);
|
|
40
|
+
super(envelope?.message ?? (snippet ? `HTTP ${status} — ${snippet}` : `HTTP ${status}`));
|
|
41
|
+
this.status = status;
|
|
42
|
+
this.body = body;
|
|
43
|
+
this.detail = envelope?.detail ?? {};
|
|
44
|
+
this.request = request;
|
|
45
|
+
this.envelope = envelope !== void 0;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var ApiUnreachableError = class extends Error {
|
|
49
|
+
constructor(host, cause) {
|
|
50
|
+
const local = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])/.test(host);
|
|
51
|
+
super(`Couldn't reach the Superwall API at ${host}.\n` + (local ? " That's a local address — start the API, or unset SUPERWALL_API_HOST to use production." : " Check your network or proxy, then try again."));
|
|
52
|
+
this.name = "ApiUnreachableError";
|
|
53
|
+
this.cause = cause;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const PAGE_LIMIT = 50;
|
|
57
|
+
const GET_RETRIES = 3;
|
|
58
|
+
const RETRYABLE = new Set([
|
|
59
|
+
429,
|
|
60
|
+
502,
|
|
61
|
+
503,
|
|
62
|
+
504
|
|
63
|
+
]);
|
|
64
|
+
async function parseApiError(request, res) {
|
|
65
|
+
const text = await res.text().catch(() => "");
|
|
66
|
+
return new ApiError(request, res.status, text);
|
|
67
|
+
}
|
|
68
|
+
function retryDelay(res, retry) {
|
|
69
|
+
const after = Number(res.headers.get("retry-after"));
|
|
70
|
+
if (Number.isFinite(after) && after >= 0 && res.headers.has("retry-after")) return after * 1e3;
|
|
71
|
+
return 400 * 2 ** retry;
|
|
72
|
+
}
|
|
73
|
+
const createSuperwallApi = (initial) => {
|
|
74
|
+
let session = initial;
|
|
75
|
+
const host = () => resolveApiHost(session);
|
|
76
|
+
const send = async (url, init) => {
|
|
77
|
+
try {
|
|
78
|
+
return await fetch(url, init);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw new ApiUnreachableError(host(), error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const authorized = async () => {
|
|
84
|
+
const resolved = await resolveAuthToken(session);
|
|
85
|
+
session = resolved.session;
|
|
86
|
+
return resolved.token;
|
|
87
|
+
};
|
|
88
|
+
const request = async (method, path, body, options = {}) => {
|
|
89
|
+
const token = await authorized();
|
|
90
|
+
const attempt = () => {
|
|
91
|
+
return send(`${host()}${path}`, {
|
|
92
|
+
method,
|
|
93
|
+
headers: {
|
|
94
|
+
...options.headers,
|
|
95
|
+
authorization: `Bearer ${token}`,
|
|
96
|
+
accept: "application/json",
|
|
97
|
+
...body !== void 0 ? { "content-type": "application/json" } : {}
|
|
98
|
+
},
|
|
99
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
let res = await attempt();
|
|
103
|
+
for (let retry = 0; method === "GET" && RETRYABLE.has(res.status) && retry < GET_RETRIES; retry++) {
|
|
104
|
+
await new Promise((done) => setTimeout(done, retryDelay(res, retry)));
|
|
105
|
+
res = await attempt();
|
|
106
|
+
}
|
|
107
|
+
if (!res.ok) throw await parseApiError(`${method} ${path}`, res);
|
|
108
|
+
if (res.status === 204) return void 0;
|
|
109
|
+
return await res.json();
|
|
110
|
+
};
|
|
111
|
+
const api = {
|
|
112
|
+
org: {},
|
|
113
|
+
get userEmail() {
|
|
114
|
+
return session.userEmail;
|
|
115
|
+
},
|
|
116
|
+
get host() {
|
|
117
|
+
return host();
|
|
118
|
+
},
|
|
119
|
+
forOrg: (id) => ({
|
|
120
|
+
...api,
|
|
121
|
+
org: { id },
|
|
122
|
+
forOrg: api.forOrg
|
|
123
|
+
}),
|
|
124
|
+
get: (path, options) => request("GET", path, void 0, options),
|
|
125
|
+
post: (path, body, options) => request("POST", path, body, options),
|
|
126
|
+
put: (path, body, options) => request("PUT", path, body, options),
|
|
127
|
+
patch: (path, body, options) => request("PATCH", path, body, options),
|
|
128
|
+
del: (path, options) => request("DELETE", path, void 0, options),
|
|
129
|
+
async postText(path, body) {
|
|
130
|
+
const token = await authorized();
|
|
131
|
+
const res = await send(`${host()}${path}`, {
|
|
132
|
+
method: "POST",
|
|
133
|
+
headers: {
|
|
134
|
+
authorization: `Bearer ${token}`,
|
|
135
|
+
accept: "text/plain",
|
|
136
|
+
"content-type": "text/plain; charset=utf-8"
|
|
137
|
+
},
|
|
138
|
+
body
|
|
139
|
+
});
|
|
140
|
+
if (!res.ok) throw await parseApiError(`POST ${path}`, res);
|
|
141
|
+
return res.text();
|
|
142
|
+
},
|
|
143
|
+
async list(path) {
|
|
144
|
+
const out = [];
|
|
145
|
+
let after;
|
|
146
|
+
for (let page = 0; page < PAGE_LIMIT; page++) {
|
|
147
|
+
const url = `${path}${path.includes("?") ? "&" : "?"}limit=100${after ? `&starting_after=${after}` : ""}`;
|
|
148
|
+
const batch = await api.get(url);
|
|
149
|
+
out.push(...batch.data);
|
|
150
|
+
if (!batch.has_more || batch.data.length === 0) break;
|
|
151
|
+
const last = batch.data.at(-1);
|
|
152
|
+
if (typeof last !== "object" || last === null || !("id" in last) || last.id == null) break;
|
|
153
|
+
after = String(last.id);
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
return api;
|
|
159
|
+
};
|
|
160
|
+
const superwallApi = () => {
|
|
161
|
+
const session = readSession();
|
|
162
|
+
if (!session) throw new NotLoggedInError();
|
|
163
|
+
return createSuperwallApi(session);
|
|
164
|
+
};
|
|
165
|
+
function withQuery(path, qs) {
|
|
166
|
+
const params = qs instanceof URLSearchParams ? qs : new URLSearchParams();
|
|
167
|
+
if (!(qs instanceof URLSearchParams)) for (const [key, value] of Object.entries(qs)) {
|
|
168
|
+
if (typeof value === "object" && value !== null) throw new Error(`Nested -d params aren't supported on GET/DELETE (got "${key}").`);
|
|
169
|
+
params.set(key, String(value));
|
|
170
|
+
}
|
|
171
|
+
const s = params.toString();
|
|
172
|
+
return s ? `${path}${path.includes("?") ? "&" : "?"}${s}` : path;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
export { withQuery as a, superwallApi as i, ApiUnreachableError as n, createSuperwallApi as r, ApiError as t };
|