@superwall/cli 2.4.0 → 2.5.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/dist/{apple-Bx_fm5M-.js → apple-Dyr7OFBx.js} +16 -15
- package/dist/approve-Czs1-JO9.js +186 -0
- package/dist/{assets-W5yvyf0V.js → assets-BrB9jQPQ.js} +3 -3
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/{billing-C4lXR0xG.js → billing-D5qqIlVb.js} +3 -3
- package/dist/{bind-82oTpHZ3.js → bind-B3eEcRyp.js} +4 -4
- package/dist/browser-Bp3yRKlU.js +36 -0
- package/dist/{build-7_8cBgBm.js → build-DD9pSwHX.js} +9 -7
- package/dist/{client-ltxxHuxn.js → client-AI9H4GGB.js} +3 -3
- package/dist/{create-Dk8U_B49.js → create-B4m-IKlr.js} +8 -8
- package/dist/create-CJljlkJK.js +20 -0
- package/dist/{create-DEyveHS6.js → create-ChfgWpiM.js} +39 -67
- package/dist/{doctor-Df2GwS4K.js → doctor-XtXW6tKE.js} +6 -6
- package/dist/download-2Zu2I_Og.js +58 -0
- package/dist/{drivers-CTyYdBL7.js → drivers-CMEL13gp.js} +3 -3
- package/dist/entry.js +25 -24
- package/dist/{environment-djS0ik60.js → environment-BWT2S4qC.js} +3 -2
- package/dist/{existing-Das3PHGG.js → existing-b0GxFcnc.js} +2 -2
- package/dist/{session-CV0P8BjK.js → git-D7AVdugb.js} +96 -334
- package/dist/held-CX7Zf8u-.js +17 -0
- package/dist/{held-B8EFWDEc.js → held-D3PUNky2.js} +7 -7
- package/dist/install-CVUXsx8c.js +103 -0
- package/dist/{integrate-Cz48dm_h.js → integrate-qvKd9pVW.js} +27 -25
- package/dist/{login-girc324T.js → login-COmGHrU5.js} +2 -1
- package/dist/login-ClnJi1Ea.js +17 -0
- package/dist/{login-CiK5T4w8.js → login-PMoXUGqq.js} +8 -41
- package/dist/{lookup-us5vu5od.js → lookup-gjcKIZvh.js} +3 -2
- package/dist/{migrate-DaVwhdov.js → migrate-SkkLLdmr.js} +30 -25
- package/dist/{migration-cS6UGeUj.js → migration-DS44-3Zr.js} +9 -9
- package/dist/{notification-url-Hg42tAbW.js → notification-url-BjQPLf4-.js} +4 -4
- package/dist/{open-BIuOZ9ka.js → open-DQpm2yVs.js} +2 -2
- package/dist/{org-BrR4HGvl.js → org-C04eAO-j.js} +3 -2
- package/dist/organization-BOECL3vZ.js +39 -0
- package/dist/orgs-D6Kk96mG.js +81 -0
- package/dist/{paths-CdwjySxK.js → paths-REb-GrbX.js} +1 -1
- package/dist/{playbook-BJ3opYIS.js → playbook-Du4Oydbf.js} +10 -10
- package/dist/{products-DH_fK9tY.js → products-Cqq59DBQ.js} +1 -1
- package/dist/project-CP6hiHra.js +47 -0
- package/dist/{promote-BQO-1ScY.js → promote-Dm2_b1WK.js} +23 -18
- package/dist/pull-DsdOoG-D.js +36 -0
- package/dist/{pull-BhRswq6x.js → pull-F6pvO4To.js} +9 -28
- package/dist/pull-zYAbqo9n.js +106 -0
- package/dist/{push-CR110qRh.js → push-BIFLhAiO.js} +8 -6
- package/dist/push-CJVfvFZq.js +29 -0
- package/dist/push-D_l9KJZN.js +290 -0
- package/dist/push-SVzv7fzE.js +22 -0
- package/dist/{registry-DZsWoWqH.js → registry-DIJB0mJa.js} +687 -64
- package/dist/resolve--GsHj0Q1.js +171 -0
- package/dist/{resources-BMspgZO1.js → resources-BaP3p_LY.js} +3 -80
- package/dist/{run-D4V6mq8_.js → run-C5OPwhvS.js} +2 -2
- package/dist/run-CgLmD2vR.js +1345 -0
- package/dist/{scan-CRexsHOE.js → scan-Bj5y0zTZ.js} +1 -1
- package/dist/scan-v_WTE722.js +4 -0
- package/dist/{scope-Ct0_HoNq.js → scope-Bp_zwJOo.js} +5 -4
- package/dist/scope-CCb_7UvN.js +89 -0
- package/dist/sdk-TvT0p_nO.js +71 -0
- package/dist/selection-BltBpyp5.js +179 -0
- package/dist/series-TAixFBWW.js +685 -0
- package/dist/{server-Dv1VwbNh.js → server-CdVIboQn.js} +10 -8
- package/dist/server-CvJVusw3.js +29 -0
- package/dist/session-B8JNXkwN.js +6 -0
- package/dist/session-D3fgXQBt.js +219 -0
- package/dist/{session-UiPlLFn6.js → session-Ywim-P8M.js} +1 -1
- package/dist/{setup-UWLhQG3M.js → setup-zzjtTy8k.js} +9 -8
- package/dist/skills/index.json +5 -0
- package/dist/skills/superwall/SKILL.md +48 -30
- package/dist/skills/superwall/references/api.md +3 -2
- package/dist/skills/superwall-editor/SKILL.md +7 -5
- package/dist/skills/superwall-framework/SKILL.md +7 -5
- package/dist/skills/superwall-workspaces/SKILL.md +313 -0
- package/dist/skills/superwall-workspaces/references/cli.md +174 -0
- package/dist/skills/superwall-workspaces/references/slots.md +103 -0
- package/dist/{skills-CiWxt6vS.js → skills-2qYaUXGE.js} +4 -4
- package/dist/{skills-DzOvse9L.js → skills-8um2fBPS.js} +8 -8
- package/dist/{source-push-CX_k_yZD.js → source-push-kAep4gPe.js} +6 -5
- package/dist/{spinner-1uuKKZMc.js → spinner-BANVLncC.js} +16 -4
- package/dist/starter-CiLrp1cN.js +190 -0
- package/dist/status-CoYMK7QL.js +139 -0
- package/dist/{storage-CrXGgIbS.js → storage-DzP22xKn.js} +1 -1
- package/dist/storekit-D5eopLM0.js +17 -0
- package/dist/{storekit-CptdG4RJ.js → storekit-n1x0bWkQ.js} +4 -4
- package/dist/{telemetry-BqaPbM0k.js → telemetry-CXN6f-ZX.js} +1 -1
- package/dist/{token-zjjlkNDF.js → token-FmeHywYt.js} +1 -1
- package/dist/tools-skills/superwall/SKILL.md +49 -31
- package/dist/tools-skills/superwall/references/api.md +3 -2
- package/dist/tools-skills/superwall-editor/SKILL.md +7 -5
- package/dist/tools.d.ts +1 -1
- package/dist/tools.js +452 -27
- package/dist/try-BWbzgelb.js +120 -0
- package/dist/{selection-CgZJJ3FD.js → types-JdxmnCko.js} +1 -178
- package/dist/{upgrade-BBnmcyY2.js → upgrade-Bk5boOgW.js} +2 -2
- package/dist/{upgrade-AdyF7wXk.js → upgrade-CoWCEnoi.js} +2 -2
- package/package.json +5 -3
- package/dist/create-CBCDWuyo.js +0 -19
- package/dist/held-BL4oizD6.js +0 -16
- package/dist/login-DdrOmi6m.js +0 -16
- package/dist/push-B3Onn_mL.js +0 -24
- package/dist/scan-DUQjxOZf.js +0 -4
- package/dist/server-Cv-Ug9JF.js +0 -24
- package/dist/session-BCQuMcQ0.js +0 -6
- package/dist/storekit-B675ZNiA.js +0 -16
- /package/dist/{client-BZ1UbpXz.js → client-BJQXl62Q.js} +0 -0
- /package/dist/{devtools-pBl_vt03.js → devtools-ByZ6XYnn.js} +0 -0
- /package/dist/{input-vi0bou04.js → input-MDd67UIp.js} +0 -0
- /package/dist/{reports-CwwKLUh0.js → reports-CuhB1_ub.js} +0 -0
- /package/dist/{screenshot-file-tVBfUEIi.js → screenshot-file-XAS0Xy0e.js} +0 -0
- /package/dist/{storage-gRyQetN9.d.ts → storage-BjQCiTuz.d.ts} +0 -0
- /package/dist/{timing-BVxPrYq3.js → timing-Ca0TXY-A.js} +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { u as DASHBOARD_ORIGIN_OVERRIDE } from "./environment-BWT2S4qC.js";
|
|
2
|
+
import { a as orgProjects, n as listOrganizations } from "./orgs-D6Kk96mG.js";
|
|
3
|
+
import { i as WORKSPACE_FILE } from "./scope-CCb_7UvN.js";
|
|
4
|
+
import { r as WorkspaceError } from "./project-CP6hiHra.js";
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
|
|
8
|
+
//#region src/core/workspaces/api.ts
|
|
9
|
+
const workspacePath = (id) => `/v2/workspaces/${encodeURIComponent(String(id))}`;
|
|
10
|
+
const versionPath = (id, version) => `${workspacePath(id)}/versions/${encodeURIComponent(String(version))}`;
|
|
11
|
+
const getMe = (api) => api.get("/v2/me");
|
|
12
|
+
const listMembers = async (api, organizationId) => (await api.get(`/v2/organizations/${encodeURIComponent(String(organizationId))}/access/members`)).data ?? [];
|
|
13
|
+
const getWorkspace = (api, id) => api.get(workspacePath(id));
|
|
14
|
+
const listWorkspaces = async (api, organizationId, slug) => {
|
|
15
|
+
const search = new URLSearchParams({
|
|
16
|
+
organization_id: organizationId,
|
|
17
|
+
...slug ? { slug } : {}
|
|
18
|
+
});
|
|
19
|
+
return (await api.get(`/v2/workspaces?${search}`)).data;
|
|
20
|
+
};
|
|
21
|
+
const createWorkspace = (api, organizationId, name, slug) => api.post("/v2/workspaces", {
|
|
22
|
+
organization_id: Number(organizationId),
|
|
23
|
+
name,
|
|
24
|
+
slug
|
|
25
|
+
});
|
|
26
|
+
const listVersions = async (api, id) => (await api.get(`${workspacePath(id)}/versions`)).data;
|
|
27
|
+
const mintSourceAccess = (api, id) => api.post(`${workspacePath(id)}/source-access`, {});
|
|
28
|
+
const startBuild = (api, id, commitSha, tokenId) => api.post(`${workspacePath(id)}/builds`, {
|
|
29
|
+
commit_sha: commitSha,
|
|
30
|
+
token_id: tokenId
|
|
31
|
+
});
|
|
32
|
+
const getBuild = (api, id, version) => api.get(`${versionPath(id, version)}/build`);
|
|
33
|
+
const requestDeploy = (api, id, version) => api.post(`${versionPath(id, version)}/request-deploy`, {});
|
|
34
|
+
const approveVersion = (api, id, version) => api.post(`${versionPath(id, version)}/approve`, {});
|
|
35
|
+
const listInstallations = async (api, id) => (await api.get(`${workspacePath(id)}/installations`)).data;
|
|
36
|
+
const setInstallation = (api, id, body) => api.put(`${workspacePath(id)}/installations`, body);
|
|
37
|
+
const deleteInstallation = (api, id, entrypoint, application) => {
|
|
38
|
+
const search = new URLSearchParams({
|
|
39
|
+
entrypoint_id: entrypoint,
|
|
40
|
+
...application ? { application_id: application } : {}
|
|
41
|
+
});
|
|
42
|
+
return api.del(`${workspacePath(id)}/installations?${search}`);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/core/workspaces/binding.ts
|
|
47
|
+
function readBinding(root) {
|
|
48
|
+
const file = path.join(root, WORKSPACE_FILE);
|
|
49
|
+
let text;
|
|
50
|
+
try {
|
|
51
|
+
text = fs.readFileSync(file, "utf8");
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = JSON.parse(text);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
throw new WorkspaceError(`${WORKSPACE_FILE} is not valid JSON: ${error.message}`);
|
|
60
|
+
}
|
|
61
|
+
const { workspace_id: workspaceId, organization_id: organizationId, slug, synced_commit: syncedCommit, reviewed_commit: reviewedCommit } = parsed;
|
|
62
|
+
if (typeof workspaceId !== "number" || typeof organizationId !== "number" || typeof slug !== "string") throw new WorkspaceError(`${WORKSPACE_FILE} needs workspace_id, organization_id and slug.`);
|
|
63
|
+
return {
|
|
64
|
+
workspaceId: String(workspaceId),
|
|
65
|
+
organizationId: String(organizationId),
|
|
66
|
+
slug,
|
|
67
|
+
...typeof syncedCommit === "string" ? { syncedCommit } : {},
|
|
68
|
+
...typeof reviewedCommit === "string" ? { reviewedCommit } : {}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const formatBinding = (binding, includeSync) => `${JSON.stringify({
|
|
72
|
+
workspace_id: Number(binding.workspaceId),
|
|
73
|
+
organization_id: Number(binding.organizationId),
|
|
74
|
+
slug: binding.slug,
|
|
75
|
+
...includeSync && binding.syncedCommit ? { synced_commit: binding.syncedCommit } : {},
|
|
76
|
+
...includeSync && binding.reviewedCommit ? { reviewed_commit: binding.reviewedCommit } : {}
|
|
77
|
+
}, null, 2)}\n`;
|
|
78
|
+
function writeBinding(root, binding) {
|
|
79
|
+
fs.writeFileSync(path.join(root, WORKSPACE_FILE), formatBinding(binding, true));
|
|
80
|
+
}
|
|
81
|
+
function readSourceFile(root, relative$1) {
|
|
82
|
+
const file = path.join(root, relative$1);
|
|
83
|
+
if (relative$1 !== WORKSPACE_FILE) return fs.readFileSync(file);
|
|
84
|
+
const binding = readBinding(root);
|
|
85
|
+
return binding ? Buffer.from(formatBinding(binding, false)) : fs.readFileSync(file);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/core/workspaces/resolve.ts
|
|
90
|
+
const projectRoot = (dir) => path.resolve(dir ?? process.cwd());
|
|
91
|
+
async function resolveWorkspace(ctx, ref) {
|
|
92
|
+
if (ref.workspace !== void 0) {
|
|
93
|
+
if (/^\d+$/.test(ref.workspace)) return getWorkspace(ctx.api, ref.workspace);
|
|
94
|
+
if (ref.org === void 0) throw new WorkspaceError(`A slug needs its organization: add --org <id>, or pass the workspace's id.`);
|
|
95
|
+
const [found] = await listWorkspaces(ctx.api, ref.org, ref.workspace);
|
|
96
|
+
if (!found) throw new WorkspaceError(`No workspace \`${ref.workspace}\` in organization ${ref.org}.`);
|
|
97
|
+
return found;
|
|
98
|
+
}
|
|
99
|
+
const binding = readBinding(projectRoot(ref.dir));
|
|
100
|
+
if (!binding) throw new WorkspaceError("This project isn't linked to a workspace yet. Run `superwall workspaces push`, or say which with --workspace <id>.");
|
|
101
|
+
return getWorkspace(ctx.api, binding.workspaceId);
|
|
102
|
+
}
|
|
103
|
+
function dashboardOrigin(apiHost) {
|
|
104
|
+
return DASHBOARD_ORIGIN_OVERRIDE() ?? (new URL(apiHost).hostname.endsWith(".dev") ? "https://app.superwall.dev" : "https://app.superwall.com");
|
|
105
|
+
}
|
|
106
|
+
const workspaceUrl = (apiHost, workspace) => `${dashboardOrigin(apiHost)}/${workspace.organization_id}/workspaces/${encodeURIComponent(workspace.slug)}`;
|
|
107
|
+
const appEntrypointUrl = (apiHost, workspace, applicationId, entrypoint) => `${dashboardOrigin(apiHost)}/${workspace.organization_id}/${applicationId}/apps/${workspace.id}/${encodeURIComponent(entrypoint)}`;
|
|
108
|
+
async function openLink(ctx, workspace, manifest) {
|
|
109
|
+
const fallback = { url: workspaceUrl(ctx.api.host, workspace) };
|
|
110
|
+
const entrypoints = manifest?.entrypoints ?? [];
|
|
111
|
+
const appPage = entrypoints.find((entrypoint) => entrypoint.slot === "app.page@1");
|
|
112
|
+
if (!appPage || entrypoints.some((entrypoint) => entrypoint.slot === "org.page@1")) return fallback;
|
|
113
|
+
const apps = (await orgProjects(ctx.api, String(workspace.organization_id)).catch(() => [])).flatMap((project) => project.applications ?? []);
|
|
114
|
+
const [first] = apps;
|
|
115
|
+
if (first === void 0) return fallback;
|
|
116
|
+
return {
|
|
117
|
+
url: appEntrypointUrl(ctx.api.host, workspace, String(first.id), appPage.id),
|
|
118
|
+
entrypoint: appPage.id,
|
|
119
|
+
app: String(first.name ?? first.id),
|
|
120
|
+
otherApps: apps.length > 1
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const latestManifest = (versions) => newestFirst(versions).find((version) => version.manifest !== null)?.manifest;
|
|
124
|
+
async function visibilityOf(ctx, workspaceId, version) {
|
|
125
|
+
const [workspace, me] = await Promise.all([getWorkspace(ctx.api, workspaceId).catch(() => void 0), getMe(ctx.api).catch(() => void 0)]);
|
|
126
|
+
if (workspace?.state === "turned_off") return {
|
|
127
|
+
visibleTo: "nobody",
|
|
128
|
+
sentence: `This workspace is turned off, so nobody can see version ${version}.`
|
|
129
|
+
};
|
|
130
|
+
if (workspace?.active_version_id === version) return {
|
|
131
|
+
visibleTo: "everyone",
|
|
132
|
+
sentence: `Version ${version} is live.`
|
|
133
|
+
};
|
|
134
|
+
if (workspace?.author_version_id === version) return {
|
|
135
|
+
visibleTo: "you",
|
|
136
|
+
sentence: `Only you can see version ${version} until an admin approves it.`
|
|
137
|
+
};
|
|
138
|
+
if (me?.role === "SUPERADMIN") return {
|
|
139
|
+
visibleTo: "nobody",
|
|
140
|
+
sentence: `Nobody can see version ${version} until an admin approves it, because a staff account doesn't get a copy of its own.`
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
visibleTo: "its_author",
|
|
144
|
+
sentence: `Only its author can see version ${version} until an admin approves it.`
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async function roleCanApprove(ctx, workspace) {
|
|
148
|
+
const role = (await listOrganizations(ctx.api).catch(() => [])).find((organization) => String(organization.id) === String(workspace.organization_id))?.role;
|
|
149
|
+
return typeof role !== "string" || role === "OWNER" || role === "ADMIN";
|
|
150
|
+
}
|
|
151
|
+
const newestFirst = (versions) => [...versions].sort((a, b) => b.id - a.id);
|
|
152
|
+
async function pickVersion(ctx, workspace, requested, matches = () => true) {
|
|
153
|
+
const versions = newestFirst(await listVersions(ctx.api, workspace.id));
|
|
154
|
+
if (requested !== void 0) {
|
|
155
|
+
const version$1 = versions.find((candidate) => String(candidate.id) === requested);
|
|
156
|
+
if (!version$1) throw new WorkspaceError(`No version ${requested} of \`${workspace.slug}\`.`);
|
|
157
|
+
return {
|
|
158
|
+
version: version$1,
|
|
159
|
+
versions
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const version = versions.find(matches);
|
|
163
|
+
if (!version) throw new WorkspaceError(`\`${workspace.slug}\` has no version for this yet. Run \`superwall workspaces push\`.`);
|
|
164
|
+
return {
|
|
165
|
+
version,
|
|
166
|
+
versions
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
//#endregion
|
|
171
|
+
export { mintSourceAccess as C, startBuild as E, listWorkspaces as S, setInstallation as T, getBuild as _, openLink as a, listMembers as b, resolveWorkspace as c, readBinding as d, readSourceFile as f, deleteInstallation as g, createWorkspace as h, newestFirst as i, roleCanApprove as l, approveVersion as m, dashboardOrigin as n, pickVersion as o, writeBinding as p, latestManifest as r, projectRoot as s, appEntrypointUrl as t, visibilityOf as u, getMe as v, requestDeploy as w, listVersions as x, listInstallations as y };
|
|
@@ -1,83 +1,6 @@
|
|
|
1
|
-
import { n as ApiUnreachableError, t as ApiError } from "./client-
|
|
2
|
-
import {
|
|
1
|
+
import { n as ApiUnreachableError, t as ApiError } from "./client-AI9H4GGB.js";
|
|
2
|
+
import { r as listReachableProjects } from "./orgs-D6Kk96mG.js";
|
|
3
3
|
|
|
4
|
-
//#region src/core/api/orgs.ts
|
|
5
|
-
async function listOrganizations(api) {
|
|
6
|
-
const res = await api.get("/v2/me/organizations");
|
|
7
|
-
return [...new Map((res.data ?? []).map((org) => [String(org.id), org])).values()];
|
|
8
|
-
}
|
|
9
|
-
function orgProjects(api, orgId) {
|
|
10
|
-
return api.list(`/v2/projects?organization_id=${encodeURIComponent(orgId)}`).then((projects) => projects.map((project) => ({
|
|
11
|
-
organization_id: orgId,
|
|
12
|
-
...project
|
|
13
|
-
})));
|
|
14
|
-
}
|
|
15
|
-
function orgIdOf(project) {
|
|
16
|
-
return project.organization_id === void 0 ? void 0 : String(project.organization_id);
|
|
17
|
-
}
|
|
18
|
-
function asksForOrg(error) {
|
|
19
|
-
return error instanceof ApiError && error.status === 400 && /organization_id/.test(error.message);
|
|
20
|
-
}
|
|
21
|
-
async function listReachableProjects(api) {
|
|
22
|
-
let members = await api.list("/v2/projects").catch(async (error) => {
|
|
23
|
-
if (!asksForOrg(error)) throw error;
|
|
24
|
-
const orgs = await listOrganizations(api);
|
|
25
|
-
return (await Promise.all(orgs.map((org) => orgProjects(api, String(org.id))))).flat();
|
|
26
|
-
});
|
|
27
|
-
members = unique(members);
|
|
28
|
-
const seen = new Set(members.map(orgIdOf).filter((id) => id !== void 0));
|
|
29
|
-
const opened = readOpenedOrgs().filter((id) => !seen.has(id));
|
|
30
|
-
if (opened.length === 0) return members;
|
|
31
|
-
const reached = await Promise.all(opened.map((id) => {
|
|
32
|
-
return orgProjects(api, id).catch((error) => {
|
|
33
|
-
if (error instanceof ApiError && [
|
|
34
|
-
400,
|
|
35
|
-
403,
|
|
36
|
-
404
|
|
37
|
-
].includes(error.status)) return [];
|
|
38
|
-
throw error;
|
|
39
|
-
});
|
|
40
|
-
}));
|
|
41
|
-
writeOpenedOrgs(opened.filter((_, index) => (reached[index]?.length ?? 0) > 0));
|
|
42
|
-
return [...members, ...reached.flat()];
|
|
43
|
-
}
|
|
44
|
-
function unique(projects) {
|
|
45
|
-
return [...new Map(projects.map((project) => [String(project.id), project])).values()];
|
|
46
|
-
}
|
|
47
|
-
function rememberOrg(project) {
|
|
48
|
-
const id = project && orgIdOf(project);
|
|
49
|
-
if (id) writeOpenedOrgs([...readOpenedOrgs(), id]);
|
|
50
|
-
}
|
|
51
|
-
async function listOrgGroups(api) {
|
|
52
|
-
const [projects, memberships] = await Promise.all([listReachableProjects(api), listOrganizations(api).catch(() => [])]);
|
|
53
|
-
const members = new Map(memberships.map((org) => [String(org.id), org]));
|
|
54
|
-
const groups = /* @__PURE__ */ new Map();
|
|
55
|
-
for (const project of projects) {
|
|
56
|
-
const id = orgIdOf(project) ?? "";
|
|
57
|
-
const name = members.get(id)?.name;
|
|
58
|
-
const group = groups.get(id) ?? {
|
|
59
|
-
id,
|
|
60
|
-
name: typeof name === "string" ? name : void 0,
|
|
61
|
-
member: members.has(id) || id === "",
|
|
62
|
-
projects: []
|
|
63
|
-
};
|
|
64
|
-
group.projects.push(project);
|
|
65
|
-
groups.set(id, group);
|
|
66
|
-
}
|
|
67
|
-
await Promise.all([...groups.values()].filter((group) => !group.member && !group.name).map(async (group) => {
|
|
68
|
-
const org = await api.get(`/v2/organizations/${encodeURIComponent(group.id)}`).catch(() => void 0);
|
|
69
|
-
if (typeof org?.name === "string") group.name = org.name;
|
|
70
|
-
}));
|
|
71
|
-
return [...groups.values()].sort((a, b) => Number(b.member) - Number(a.member));
|
|
72
|
-
}
|
|
73
|
-
async function organizationOf(api, projectId, known) {
|
|
74
|
-
const local = known?.find((project) => String(project.id) === projectId);
|
|
75
|
-
const id = (local && orgIdOf(local)) ?? orgIdOf(await api.get(`/v2/projects/${encodeURIComponent(projectId)}`));
|
|
76
|
-
if (!id) throw new Error(`Couldn't tell which account project ${projectId} belongs to.`);
|
|
77
|
-
return id;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
4
|
//#region src/core/json.ts
|
|
82
5
|
function isRecord(value) {
|
|
83
6
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -378,4 +301,4 @@ function promotePaywallVersion(api, paywallId, opts = {}) {
|
|
|
378
301
|
}
|
|
379
302
|
|
|
380
303
|
//#endregion
|
|
381
|
-
export { listField as A, pushPaywallVersion as C, versionProducts as D, titleCase as E,
|
|
304
|
+
export { listField as A, pushPaywallVersion as C, versionProducts as D, titleCase as E, textField as M, field as O, pushPaywallAssets as S, rowName as T, livePaywallVersion as _, createEntitlement as a, platformStore as b, createProject as c, linkSourceCommit as d, listAppPaywalls as f, livePaywall as g, listResource as h, createCampaign as i, parseJson as j, isRecord as k, findPaywall as l, listProjects as m, billingPlanOf as n, createHeadlessPaywall as o, listApplications as p, createApplication as r, createProduct as s, RESOURCES as t, isAppScoped as u, mintSourceAccess as v, pushedProducts as w, promotePaywallVersion as x, platformLabel as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as packagedDir } from "./paths-
|
|
1
|
+
import { d as DASHBOARD_URL } from "./environment-BWT2S4qC.js";
|
|
2
|
+
import { i as packagedDir } from "./paths-REb-GrbX.js";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|