@spacefast/common 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/brand.d.ts +15 -0
- package/dist/brand.js +24 -0
- package/dist/config/domains.d.ts +30 -0
- package/dist/config/domains.js +75 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +3 -0
- package/dist/contracts/abuse.d.ts +93 -0
- package/dist/contracts/abuse.js +50 -0
- package/dist/contracts/access.d.ts +409 -0
- package/dist/contracts/access.js +396 -0
- package/dist/contracts/account.d.ts +28 -0
- package/dist/contracts/account.js +54 -0
- package/dist/contracts/activity.d.ts +118 -0
- package/dist/contracts/activity.js +180 -0
- package/dist/contracts/analytics.d.ts +56 -0
- package/dist/contracts/analytics.js +91 -0
- package/dist/contracts/annotations.d.ts +327 -0
- package/dist/contracts/annotations.js +234 -0
- package/dist/contracts/api-keys.d.ts +517 -0
- package/dist/contracts/api-keys.js +235 -0
- package/dist/contracts/archives.d.ts +332 -0
- package/dist/contracts/archives.js +120 -0
- package/dist/contracts/auth.d.ts +86 -0
- package/dist/contracts/auth.js +82 -0
- package/dist/contracts/beta.d.ts +106 -0
- package/dist/contracts/beta.js +104 -0
- package/dist/contracts/billing.d.ts +328 -0
- package/dist/contracts/billing.js +203 -0
- package/dist/contracts/builds.d.ts +504 -0
- package/dist/contracts/builds.js +248 -0
- package/dist/contracts/channels.d.ts +49 -0
- package/dist/contracts/channels.js +51 -0
- package/dist/contracts/common.d.ts +238 -0
- package/dist/contracts/common.js +175 -0
- package/dist/contracts/deployments.d.ts +574 -0
- package/dist/contracts/deployments.js +97 -0
- package/dist/contracts/device-auth.d.ts +194 -0
- package/dist/contracts/device-auth.js +162 -0
- package/dist/contracts/domains.d.ts +6115 -0
- package/dist/contracts/domains.js +1435 -0
- package/dist/contracts/enums.d.ts +196 -0
- package/dist/contracts/enums.js +211 -0
- package/dist/contracts/error-code-meta.d.ts +1560 -0
- package/dist/contracts/error-code-meta.js +400 -0
- package/dist/contracts/error-codes.d.ts +13 -0
- package/dist/contracts/error-codes.js +416 -0
- package/dist/contracts/events.d.ts +398 -0
- package/dist/contracts/events.js +320 -0
- package/dist/contracts/fast-domain-search.d.ts +19 -0
- package/dist/contracts/fast-domain-search.js +22 -0
- package/dist/contracts/features.d.ts +240 -0
- package/dist/contracts/features.js +406 -0
- package/dist/contracts/git.d.ts +288 -0
- package/dist/contracts/git.js +116 -0
- package/dist/contracts/ids.d.ts +35 -0
- package/dist/contracts/ids.js +45 -0
- package/dist/contracts/intercom.d.ts +6 -0
- package/dist/contracts/intercom.js +5 -0
- package/dist/contracts/internal.d.ts +103 -0
- package/dist/contracts/internal.js +92 -0
- package/dist/contracts/mcp.d.ts +788 -0
- package/dist/contracts/mcp.js +161 -0
- package/dist/contracts/me.d.ts +81 -0
- package/dist/contracts/me.js +104 -0
- package/dist/contracts/oauth-resources.d.ts +30 -0
- package/dist/contracts/oauth-resources.js +61 -0
- package/dist/contracts/operations.d.ts +54 -0
- package/dist/contracts/operations.js +14 -0
- package/dist/contracts/plan-policy.d.ts +85 -0
- package/dist/contracts/plan-policy.js +75 -0
- package/dist/contracts/platform.d.ts +359 -0
- package/dist/contracts/platform.js +216 -0
- package/dist/contracts/push-new.d.ts +156 -0
- package/dist/contracts/push-new.js +52 -0
- package/dist/contracts/quotas.d.ts +16 -0
- package/dist/contracts/quotas.js +36 -0
- package/dist/contracts/repository-connections.d.ts +231 -0
- package/dist/contracts/repository-connections.js +106 -0
- package/dist/contracts/resources.d.ts +529 -0
- package/dist/contracts/resources.js +209 -0
- package/dist/contracts/routes.d.ts +45 -0
- package/dist/contracts/routes.js +31 -0
- package/dist/contracts/runtime-api.d.ts +449 -0
- package/dist/contracts/runtime-api.js +513 -0
- package/dist/contracts/sites.d.ts +393 -0
- package/dist/contracts/sites.js +121 -0
- package/dist/contracts/slugs.d.ts +31 -0
- package/dist/contracts/slugs.js +47 -0
- package/dist/contracts/space-config.d.ts +216 -0
- package/dist/contracts/space-config.js +237 -0
- package/dist/contracts/space-theme.d.ts +25 -0
- package/dist/contracts/space-theme.js +49 -0
- package/dist/contracts/spaces.d.ts +2760 -0
- package/dist/contracts/spaces.js +589 -0
- package/dist/contracts/superadmin-activity.d.ts +205 -0
- package/dist/contracts/superadmin-activity.js +107 -0
- package/dist/contracts/superadmin-emails.d.ts +212 -0
- package/dist/contracts/superadmin-emails.js +112 -0
- package/dist/contracts/superadmin-queues.d.ts +414 -0
- package/dist/contracts/superadmin-queues.js +202 -0
- package/dist/contracts/superadmin-runtime.d.ts +27 -0
- package/dist/contracts/superadmin-runtime.js +38 -0
- package/dist/contracts/superadmin-spaces.d.ts +429 -0
- package/dist/contracts/superadmin-spaces.js +82 -0
- package/dist/contracts/superadmin-tenants.d.ts +180 -0
- package/dist/contracts/superadmin-tenants.js +117 -0
- package/dist/contracts/superadmin.d.ts +654 -0
- package/dist/contracts/superadmin.js +309 -0
- package/dist/contracts/tags.d.ts +1140 -0
- package/dist/contracts/tags.js +1050 -0
- package/dist/contracts/teams.d.ts +233 -0
- package/dist/contracts/teams.js +174 -0
- package/dist/contracts/telemetry.d.ts +2 -0
- package/dist/contracts/telemetry.js +1 -0
- package/dist/contracts/transfers.d.ts +105 -0
- package/dist/contracts/transfers.js +48 -0
- package/dist/contracts/variables.d.ts +189 -0
- package/dist/contracts/variables.js +82 -0
- package/dist/contracts/webhooks.d.ts +159 -0
- package/dist/contracts/webhooks.js +59 -0
- package/dist/contracts/zero.d.ts +1538 -0
- package/dist/contracts/zero.js +755 -0
- package/dist/docs/agent-prose.d.ts +35 -0
- package/dist/docs/agent-prose.js +153 -0
- package/dist/docs/agent-setup.d.ts +6 -0
- package/dist/docs/agent-setup.js +164 -0
- package/dist/docs/agent-solutions.d.ts +110 -0
- package/dist/docs/agent-solutions.js +181 -0
- package/dist/docs/error-docs.d.ts +12 -0
- package/dist/docs/error-docs.js +1601 -0
- package/dist/docs/skill-distribution.d.ts +12 -0
- package/dist/docs/skill-distribution.js +18 -0
- package/dist/domain-exploration.d.ts +108 -0
- package/dist/domain-exploration.js +488 -0
- package/dist/domain-normalize.d.ts +1 -0
- package/dist/domain-normalize.js +14 -0
- package/dist/domain-zones.d.ts +1 -0
- package/dist/domain-zones.js +5272 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/access-policy.d.ts +39 -0
- package/dist/utils/access-policy.js +232 -0
- package/dist/utils/api.d.ts +4 -0
- package/dist/utils/api.js +13 -0
- package/dist/utils/auth-redirect.d.ts +1 -0
- package/dist/utils/auth-redirect.js +48 -0
- package/dist/utils/auth.d.ts +5 -0
- package/dist/utils/auth.js +13 -0
- package/dist/utils/build-settings.d.ts +49 -0
- package/dist/utils/build-settings.js +366 -0
- package/dist/utils/claim-token.d.ts +1 -0
- package/dist/utils/claim-token.js +9 -0
- package/dist/utils/collections.d.ts +1 -0
- package/dist/utils/collections.js +5 -0
- package/dist/utils/concurrency.d.ts +1 -0
- package/dist/utils/concurrency.js +18 -0
- package/dist/utils/content-type.d.ts +10 -0
- package/dist/utils/content-type.js +145 -0
- package/dist/utils/error-display.d.ts +7 -0
- package/dist/utils/error-display.js +42 -0
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +3 -0
- package/dist/utils/generate-space-name.d.ts +14 -0
- package/dist/utils/generate-space-name.js +95 -0
- package/dist/utils/git-repository.d.ts +5 -0
- package/dist/utils/git-repository.js +99 -0
- package/dist/utils/guards.d.ts +1 -0
- package/dist/utils/guards.js +3 -0
- package/dist/utils/publish-detection.d.ts +10 -0
- package/dist/utils/publish-detection.js +118 -0
- package/dist/utils/publish-policy.d.ts +69 -0
- package/dist/utils/publish-policy.js +429 -0
- package/dist/utils/query-client.d.ts +7 -0
- package/dist/utils/query-client.js +21 -0
- package/dist/utils/query-keys.d.ts +75 -0
- package/dist/utils/query-keys.js +78 -0
- package/dist/utils/runtime-paths.d.ts +7 -0
- package/dist/utils/runtime-paths.js +28 -0
- package/dist/utils/runtime-upload.d.ts +19 -0
- package/dist/utils/runtime-upload.js +27 -0
- package/dist/utils/slug.d.ts +5 -0
- package/dist/utils/slug.js +13 -0
- package/dist/utils/space-config.d.ts +75 -0
- package/dist/utils/space-config.js +415 -0
- package/dist/utils/space-theme.d.ts +16 -0
- package/dist/utils/space-theme.js +89 -0
- package/dist/utils/static-runtime-policy.d.ts +17 -0
- package/dist/utils/static-runtime-policy.js +103 -0
- package/dist/utils/upload-session.d.ts +34 -0
- package/dist/utils/upload-session.js +69 -0
- package/dist/utils/urls.d.ts +2 -0
- package/dist/utils/urls.js +7 -0
- package/dist/utils/version-path.d.ts +6 -0
- package/dist/utils/version-path.js +51 -0
- package/dist/utils/wpcom-auth-redirects.d.ts +14 -0
- package/dist/utils/wpcom-auth-redirects.js +49 -0
- package/dist/utils/zero-realtime-signature.d.ts +12 -0
- package/dist/utils/zero-realtime-signature.js +45 -0
- package/dist/vocabulary.d.ts +230 -0
- package/dist/vocabulary.js +218 -0
- package/package.json +58 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a whimsical, WordPress-flavored space title.
|
|
3
|
+
*
|
|
4
|
+
* The pool mixes WordPress jargon (Codex, Permalink, Gutenberg, Pingback)
|
|
5
|
+
* with engineering/web adjectives so the output reads like a tiny inside
|
|
6
|
+
* joke instead of an auto-increment. Users can rename later, so the only
|
|
7
|
+
* requirement is that two back-to-back calls almost never collide.
|
|
8
|
+
*
|
|
9
|
+
* Pool size: 32 × 32 = 1024 combinations. Combined with the collision
|
|
10
|
+
* handling in `uniqueSpaceSlug`, per-team conflicts are very
|
|
11
|
+
* unlikely. The generator is intentionally dependency-free so it can be
|
|
12
|
+
* shared by the control-plane, the CLI, and any future surface.
|
|
13
|
+
*/
|
|
14
|
+
const ADJECTIVES = [
|
|
15
|
+
"Atomic",
|
|
16
|
+
"Recursive",
|
|
17
|
+
"Verbose",
|
|
18
|
+
"Quantum",
|
|
19
|
+
"Fractal",
|
|
20
|
+
"Paginated",
|
|
21
|
+
"Cached",
|
|
22
|
+
"Distributed",
|
|
23
|
+
"Serialized",
|
|
24
|
+
"Minified",
|
|
25
|
+
"Gzipped",
|
|
26
|
+
"Semantic",
|
|
27
|
+
"Canonical",
|
|
28
|
+
"Nested",
|
|
29
|
+
"Inlined",
|
|
30
|
+
"Anchored",
|
|
31
|
+
"Kerned",
|
|
32
|
+
"Monospaced",
|
|
33
|
+
"Syndicated",
|
|
34
|
+
"Bootstrapped",
|
|
35
|
+
"Rendered",
|
|
36
|
+
"Rasterized",
|
|
37
|
+
"Pixelated",
|
|
38
|
+
"Vectorized",
|
|
39
|
+
"Indexed",
|
|
40
|
+
"Dithered",
|
|
41
|
+
"Escaped",
|
|
42
|
+
"Wrapped",
|
|
43
|
+
"Hooked",
|
|
44
|
+
"Templated",
|
|
45
|
+
"Responsive",
|
|
46
|
+
"Trackbacked",
|
|
47
|
+
];
|
|
48
|
+
const NOUNS = [
|
|
49
|
+
"Codex",
|
|
50
|
+
"Permalink",
|
|
51
|
+
"Trackback",
|
|
52
|
+
"Pingback",
|
|
53
|
+
"Sidebar",
|
|
54
|
+
"Widget",
|
|
55
|
+
"Excerpt",
|
|
56
|
+
"Blockquote",
|
|
57
|
+
"Taxonomy",
|
|
58
|
+
"Emoji",
|
|
59
|
+
"Slug",
|
|
60
|
+
"Draft",
|
|
61
|
+
"Shortcode",
|
|
62
|
+
"Hook",
|
|
63
|
+
"Filter",
|
|
64
|
+
"Action",
|
|
65
|
+
"Feed",
|
|
66
|
+
"Atom",
|
|
67
|
+
"Webmention",
|
|
68
|
+
"Fediverse",
|
|
69
|
+
"Loop",
|
|
70
|
+
"Query",
|
|
71
|
+
"Nonce",
|
|
72
|
+
"Transient",
|
|
73
|
+
"Theme",
|
|
74
|
+
"Cron",
|
|
75
|
+
"Sitemap",
|
|
76
|
+
"Gutenberg",
|
|
77
|
+
"Webhook",
|
|
78
|
+
"Gravatar",
|
|
79
|
+
"Reblog",
|
|
80
|
+
"Opengraph",
|
|
81
|
+
];
|
|
82
|
+
function pickRandom(list) {
|
|
83
|
+
if (list.length === 0) {
|
|
84
|
+
throw new Error("generateSpaceName: word list is empty.");
|
|
85
|
+
}
|
|
86
|
+
const index = Math.floor(Math.random() * list.length);
|
|
87
|
+
const value = list[index];
|
|
88
|
+
if (value === undefined) {
|
|
89
|
+
throw new Error("generateSpaceName: word list contained a hole.");
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
export function generateSpaceTitle() {
|
|
94
|
+
return `${pickRandom(ADJECTIVES)} ${pickRandom(NOUNS)}`;
|
|
95
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type GitRepositoryProvider = "github" | "gitlab" | "bitbucket" | "git";
|
|
2
|
+
export declare function isGitRepositoryRemote(value: string): boolean;
|
|
3
|
+
export declare function gitProviderFromRepositoryRemote(value: string): GitRepositoryProvider;
|
|
4
|
+
export declare function repositoryFullNameFromGitRemote(value: string): string | null;
|
|
5
|
+
export declare function safeRepositoryUrlFromGitRemote(value: string): string | null;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const SCP_LIKE_REMOTE_PATTERN = /^[A-Za-z0-9._-]+@([A-Za-z0-9.-]+):(.+)$/;
|
|
2
|
+
const ALLOWED_URL_PROTOCOLS = new Set(["http:", "https:", "ssh:", "git:", "file:"]);
|
|
3
|
+
function normalizedRemote(value) {
|
|
4
|
+
const trimmed = value.trim();
|
|
5
|
+
for (let index = 0; index < trimmed.length; index += 1) {
|
|
6
|
+
const code = trimmed.charCodeAt(index);
|
|
7
|
+
if (code <= 32 || code === 127) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return trimmed || null;
|
|
12
|
+
}
|
|
13
|
+
function parseGitRemote(value) {
|
|
14
|
+
const remote = normalizedRemote(value);
|
|
15
|
+
if (!remote) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const scpLike = remote.match(SCP_LIKE_REMOTE_PATTERN);
|
|
19
|
+
if (scpLike) {
|
|
20
|
+
const hostname = scpLike[1]?.toLowerCase() ?? null;
|
|
21
|
+
const remotePath = scpLike[2]?.replace(/^\/+/, "") ?? "";
|
|
22
|
+
return hostname && remotePath ? { hostname, path: remotePath } : null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const url = new URL(remote);
|
|
26
|
+
if (!ALLOWED_URL_PROTOCOLS.has(url.protocol)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (url.protocol !== "file:" && !url.hostname) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const remotePath = decodeURIComponent(url.pathname).replace(/^\/+/, "");
|
|
33
|
+
if (!remotePath) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
hostname: url.hostname ? url.hostname.toLowerCase() : null,
|
|
38
|
+
path: remotePath,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function isGitRepositoryRemote(value) {
|
|
46
|
+
return parseGitRemote(value) !== null;
|
|
47
|
+
}
|
|
48
|
+
export function gitProviderFromRepositoryRemote(value) {
|
|
49
|
+
const hostname = parseGitRemote(value)?.hostname;
|
|
50
|
+
if (!hostname)
|
|
51
|
+
return "git";
|
|
52
|
+
if (hostname.includes("github"))
|
|
53
|
+
return "github";
|
|
54
|
+
if (hostname.includes("gitlab"))
|
|
55
|
+
return "gitlab";
|
|
56
|
+
if (hostname.includes("bitbucket"))
|
|
57
|
+
return "bitbucket";
|
|
58
|
+
return "git";
|
|
59
|
+
}
|
|
60
|
+
export function repositoryFullNameFromGitRemote(value) {
|
|
61
|
+
const parsed = parseGitRemote(value);
|
|
62
|
+
if (!parsed?.hostname) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
const path = parsed.path.replace(/\.git$/, "");
|
|
66
|
+
return path.includes("/") ? path : null;
|
|
67
|
+
}
|
|
68
|
+
export function safeRepositoryUrlFromGitRemote(value) {
|
|
69
|
+
const parsed = parseGitRemote(value);
|
|
70
|
+
if (!parsed) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const repository = parsed.hostname ? repositoryFullNameFromGitRemote(value) : null;
|
|
74
|
+
if (parsed.hostname && repository && gitProviderFromRepositoryRemote(value) !== "git") {
|
|
75
|
+
return `https://${parsed.hostname}/${repository}`;
|
|
76
|
+
}
|
|
77
|
+
const remote = normalizedRemote(value);
|
|
78
|
+
if (!remote) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const url = new URL(remote);
|
|
83
|
+
if (!ALLOWED_URL_PROTOCOLS.has(url.protocol)) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (url.protocol === "file:") {
|
|
87
|
+
return url.toString();
|
|
88
|
+
}
|
|
89
|
+
url.username = "";
|
|
90
|
+
url.password = "";
|
|
91
|
+
return url.toString();
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
if (parsed.hostname && repository) {
|
|
95
|
+
return `https://${parsed.hostname}/${repository}`;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isOneOf<const Values extends readonly unknown[]>(values: Values, value: unknown): value is Values[number];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SpaceConfig } from "../contracts/space-config.js";
|
|
2
|
+
import type { SpaceSettingsPatch } from "./space-config.js";
|
|
3
|
+
export declare function detectSpaFromPaths(paths: Iterable<string>): boolean;
|
|
4
|
+
export declare function detectSpaFallbackFromPaths(paths: Iterable<string>): string | null;
|
|
5
|
+
export type SpaceSettingsFromConfigJson = SpaceSettingsPatch & {
|
|
6
|
+
title?: string;
|
|
7
|
+
password?: string | null;
|
|
8
|
+
};
|
|
9
|
+
export declare function parseSpaceSettingsFromConfigJson(raw: string | undefined): SpaceSettingsFromConfigJson | null;
|
|
10
|
+
export declare function spaceConfigFromSettings(base: SpaceConfig | null | undefined, patch: SpaceSettingsPatch): SpaceConfig;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
function isRecord(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
export function detectSpaFromPaths(paths) {
|
|
5
|
+
return detectSpaFallbackFromPaths(paths) !== null;
|
|
6
|
+
}
|
|
7
|
+
export function detectSpaFallbackFromPaths(paths) {
|
|
8
|
+
const normalized = new Set(Array.from(paths, (path) => path.replace(/^\/+/g, "")));
|
|
9
|
+
if (normalized.has("_redirects")) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (normalized.has("_shell.html")) {
|
|
13
|
+
return "/_shell.html";
|
|
14
|
+
}
|
|
15
|
+
if (!normalized.has("index.html")) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const htmlPages = [...normalized].filter((entry) => entry.endsWith(".html") && entry !== "404.html");
|
|
19
|
+
if (htmlPages.length > 1) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const hasSpaAssets = [...normalized].some((entry) => /^assets\/.+\.(js|mjs)$/i.test(entry) ||
|
|
23
|
+
/^static\/js\/.+\.js$/i.test(entry) ||
|
|
24
|
+
entry.startsWith("_app/") ||
|
|
25
|
+
entry.startsWith("_next/static/") ||
|
|
26
|
+
entry === "asset-manifest.json");
|
|
27
|
+
return hasSpaAssets ? "/index.html" : null;
|
|
28
|
+
}
|
|
29
|
+
// Parses the legacy-vocabulary keys of a local `.stattic/config.json` file
|
|
30
|
+
// (title/mode/spa/password/viewer). Platform SpaceConfig keys are handled
|
|
31
|
+
// separately by the publish flow.
|
|
32
|
+
export function parseSpaceSettingsFromConfigJson(raw) {
|
|
33
|
+
if (!raw) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
let parsedJson;
|
|
37
|
+
try {
|
|
38
|
+
parsedJson = JSON.parse(raw);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (!isRecord(parsedJson)) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const settings = {};
|
|
47
|
+
if (parsedJson.title && typeof parsedJson.title === "string") {
|
|
48
|
+
settings.title = parsedJson.title;
|
|
49
|
+
}
|
|
50
|
+
if (parsedJson.mode === "website" || parsedJson.mode === "files") {
|
|
51
|
+
settings.mode = parsedJson.mode;
|
|
52
|
+
}
|
|
53
|
+
if (typeof parsedJson.spa === "boolean") {
|
|
54
|
+
settings.spa = parsedJson.spa;
|
|
55
|
+
}
|
|
56
|
+
if (parsedJson.password === null || typeof parsedJson.password === "string") {
|
|
57
|
+
settings.password = parsedJson.password;
|
|
58
|
+
}
|
|
59
|
+
if (isRecord(parsedJson.viewer)) {
|
|
60
|
+
const viewer = {};
|
|
61
|
+
for (const key of ["title", "description", "ogImagePath"]) {
|
|
62
|
+
const value = parsedJson.viewer[key];
|
|
63
|
+
if (value === null || typeof value === "string") {
|
|
64
|
+
viewer[key] = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (Object.keys(viewer).length > 0) {
|
|
68
|
+
settings.viewer = viewer;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Object.keys(settings).length > 0 ? settings : null;
|
|
72
|
+
}
|
|
73
|
+
// Compiles the legacy `.stattic/config.json` serving vocabulary (mode/spa/viewer)
|
|
74
|
+
// onto a SpaceConfig overlay. Files mode = directory listing with no index; SPA =
|
|
75
|
+
// the legacy "/index.html" fallback; viewer fields map onto meta. Only the publish flow
|
|
76
|
+
// reads a legacy config.json, so this translation lives beside its parser.
|
|
77
|
+
export function spaceConfigFromSettings(base, patch) {
|
|
78
|
+
const config = { ...base };
|
|
79
|
+
if (patch.mode === "files") {
|
|
80
|
+
config.listing = true;
|
|
81
|
+
config.index = false;
|
|
82
|
+
}
|
|
83
|
+
else if (patch.mode === "website") {
|
|
84
|
+
delete config.listing;
|
|
85
|
+
delete config.index;
|
|
86
|
+
}
|
|
87
|
+
if (patch.spa === true) {
|
|
88
|
+
config.fallback = "/index.html";
|
|
89
|
+
}
|
|
90
|
+
else if (patch.spa === false) {
|
|
91
|
+
delete config.fallback;
|
|
92
|
+
}
|
|
93
|
+
if (patch.viewer) {
|
|
94
|
+
const meta = { ...config.meta };
|
|
95
|
+
const entries = [
|
|
96
|
+
["title", patch.viewer.title],
|
|
97
|
+
["description", patch.viewer.description],
|
|
98
|
+
["image", patch.viewer.ogImagePath],
|
|
99
|
+
];
|
|
100
|
+
for (const [key, value] of entries) {
|
|
101
|
+
if (value === undefined)
|
|
102
|
+
continue;
|
|
103
|
+
if (value === null || value === "") {
|
|
104
|
+
delete meta[key];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
meta[key] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (Object.keys(meta).length > 0) {
|
|
111
|
+
config.meta = meta;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
delete config.meta;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return config;
|
|
118
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ErrorCode } from "../contracts/error-codes.js";
|
|
2
|
+
export declare const MANIFEST_MAX_FILES_CEILING = 100000;
|
|
3
|
+
export declare const MANIFEST_MAX_PATH_BYTES = 1024;
|
|
4
|
+
export declare const MANIFEST_MAX_BODY_BYTES: number;
|
|
5
|
+
export declare const MAX_VERSION_FILE_SIZE_BYTES: number;
|
|
6
|
+
export declare const MAX_VERSION_TOTAL_BYTES: number;
|
|
7
|
+
export declare function normalizePublishPath(relativePath: string): string;
|
|
8
|
+
export declare function publishPathIgnored(relativePath: string): boolean;
|
|
9
|
+
export declare function publishPathIsConvention(relativePath: string): boolean;
|
|
10
|
+
export declare function providerRuntimeFeatureWarnings(paths: readonly string[]): PublishManifestWarning[];
|
|
11
|
+
export type StaticUploadPolicyOptions = {
|
|
12
|
+
reservedRuntimeControlFiles?: Iterable<string>;
|
|
13
|
+
};
|
|
14
|
+
export type StaticUploadPathViolation = {
|
|
15
|
+
code: ErrorCode;
|
|
16
|
+
message: string;
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function staticUploadPathViolation(path: string, options?: StaticUploadPolicyOptions): StaticUploadPathViolation | null;
|
|
20
|
+
export declare function firstStaticUploadPathViolation(paths: string[], options?: StaticUploadPolicyOptions): StaticUploadPathViolation | null;
|
|
21
|
+
export type PublishManifestCaps = {
|
|
22
|
+
maxFiles?: number | null | undefined;
|
|
23
|
+
maxFileBytes?: number | null | undefined;
|
|
24
|
+
};
|
|
25
|
+
export type PublishManifestError = {
|
|
26
|
+
code: ErrorCode;
|
|
27
|
+
message: string;
|
|
28
|
+
details?: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
export type PublishManifestWarning = {
|
|
31
|
+
severity: "warning";
|
|
32
|
+
code: ErrorCode;
|
|
33
|
+
message: string;
|
|
34
|
+
path: string;
|
|
35
|
+
};
|
|
36
|
+
export type PublishManifestResult<T extends {
|
|
37
|
+
path: string;
|
|
38
|
+
size: number;
|
|
39
|
+
}> = {
|
|
40
|
+
error: PublishManifestError;
|
|
41
|
+
files: null;
|
|
42
|
+
warnings: [];
|
|
43
|
+
} | {
|
|
44
|
+
error: null;
|
|
45
|
+
files: T[];
|
|
46
|
+
warnings: PublishManifestWarning[];
|
|
47
|
+
};
|
|
48
|
+
export declare function resolveManifestFileCap(maxFiles?: number | null): number;
|
|
49
|
+
export declare function validatePublishManifest<T extends {
|
|
50
|
+
path: string;
|
|
51
|
+
size: number;
|
|
52
|
+
}>(files: readonly T[], caps?: PublishManifestCaps): PublishManifestResult<T>;
|
|
53
|
+
export declare function freePlanCanUploadPath(filePath: string, options?: {
|
|
54
|
+
claimedSpace?: boolean;
|
|
55
|
+
}): boolean;
|
|
56
|
+
export declare function freePlanCanUploadContentType(contentType: string | undefined): boolean;
|
|
57
|
+
export declare function filterFreePlanManifest<T extends {
|
|
58
|
+
path: string;
|
|
59
|
+
contentType?: string | undefined;
|
|
60
|
+
}>(files: readonly T[], options?: {
|
|
61
|
+
claimedSpace?: boolean;
|
|
62
|
+
}): {
|
|
63
|
+
allowed: T[];
|
|
64
|
+
ignored: string[];
|
|
65
|
+
};
|
|
66
|
+
export declare function filterFreePlanHeaders(content: string): {
|
|
67
|
+
headers: string | undefined;
|
|
68
|
+
droppedBasicAuthCount: number;
|
|
69
|
+
};
|