@spacefast/common 0.0.11 → 0.0.13

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 (160) hide show
  1. package/dist/agents/connect-targets.d.ts +4 -4
  2. package/dist/agents/connect-targets.js +3 -3
  3. package/dist/agents/private-key-oauth.d.ts +37 -0
  4. package/dist/agents/private-key-oauth.js +158 -0
  5. package/dist/config/domains.js +1 -1
  6. package/dist/config/index.d.ts +1 -0
  7. package/dist/config/index.js +1 -0
  8. package/dist/config/postgres-budget.d.ts +126 -0
  9. package/dist/config/postgres-budget.js +135 -0
  10. package/dist/config/postgres-budget.json +50 -0
  11. package/dist/contracts/access.d.ts +386 -1183
  12. package/dist/contracts/access.js +240 -1018
  13. package/dist/contracts/activity.d.ts +1 -1
  14. package/dist/contracts/activity.js +11 -19
  15. package/dist/contracts/api-keys.d.ts +69 -45
  16. package/dist/contracts/api-keys.js +3 -0
  17. package/dist/contracts/archives.d.ts +9 -10
  18. package/dist/contracts/archives.js +4 -6
  19. package/dist/contracts/builds.d.ts +8 -8
  20. package/dist/contracts/builds.js +28 -48
  21. package/dist/contracts/channels.js +1 -2
  22. package/dist/contracts/comments.d.ts +102 -93
  23. package/dist/contracts/comments.js +121 -63
  24. package/dist/contracts/common.d.ts +4 -3
  25. package/dist/contracts/common.js +2 -0
  26. package/dist/contracts/countries.js +2 -7
  27. package/dist/contracts/data-source-routes.d.ts +20 -0
  28. package/dist/contracts/data-source-routes.js +15 -0
  29. package/dist/contracts/deployments.d.ts +3 -3
  30. package/dist/contracts/device-auth.d.ts +21 -15
  31. package/dist/contracts/docs.d.ts +5 -5
  32. package/dist/contracts/domains.d.ts +261 -1330
  33. package/dist/contracts/domains.js +39 -301
  34. package/dist/contracts/email-preferences.d.ts +50 -0
  35. package/dist/contracts/email-preferences.js +44 -0
  36. package/dist/contracts/enums.d.ts +3 -5
  37. package/dist/contracts/enums.js +3 -8
  38. package/dist/contracts/error-code-meta.d.ts +99 -33
  39. package/dist/contracts/error-code-meta.js +36 -9
  40. package/dist/contracts/error-codes.d.ts +1 -1
  41. package/dist/contracts/error-codes.js +28 -11
  42. package/dist/contracts/execution.d.ts +212 -0
  43. package/dist/contracts/execution.js +288 -0
  44. package/dist/contracts/feature-lifecycle.d.ts +498 -2
  45. package/dist/contracts/feature-lifecycle.js +539 -2
  46. package/dist/contracts/features.d.ts +184 -74
  47. package/dist/contracts/features.js +4 -303
  48. package/dist/contracts/functions.d.ts +729 -0
  49. package/dist/contracts/functions.js +485 -0
  50. package/dist/contracts/git.d.ts +1 -1
  51. package/dist/contracts/grants.d.ts +1158 -0
  52. package/dist/contracts/grants.js +696 -0
  53. package/dist/contracts/ids.d.ts +6 -5
  54. package/dist/contracts/ids.js +6 -5
  55. package/dist/contracts/internal.d.ts +3 -3
  56. package/dist/contracts/mcp.d.ts +12 -12
  57. package/dist/contracts/me.js +1 -1
  58. package/dist/contracts/mounts.d.ts +142 -0
  59. package/dist/contracts/mounts.js +56 -0
  60. package/dist/contracts/oauth-resources.d.ts +5 -5
  61. package/dist/contracts/oauth-resources.js +2 -0
  62. package/dist/contracts/operations.d.ts +4 -4
  63. package/dist/contracts/pages.d.ts +6 -14
  64. package/dist/contracts/pages.js +11 -23
  65. package/dist/contracts/plan-policy.d.ts +2 -9
  66. package/dist/contracts/plan-policy.js +1 -4
  67. package/dist/contracts/platform.d.ts +80 -32
  68. package/dist/contracts/platform.js +59 -12
  69. package/dist/contracts/push-new.d.ts +26 -2
  70. package/dist/contracts/push-new.js +8 -0
  71. package/dist/contracts/quotas.d.ts +0 -1
  72. package/dist/contracts/quotas.js +0 -5
  73. package/dist/contracts/repository-connections.d.ts +1 -1
  74. package/dist/contracts/resources.d.ts +21 -85
  75. package/dist/contracts/resources.js +17 -47
  76. package/dist/contracts/runtime-api.d.ts +799 -192
  77. package/dist/contracts/runtime-api.js +231 -100
  78. package/dist/contracts/runtime-app.d.ts +138 -0
  79. package/dist/contracts/runtime-app.js +21 -0
  80. package/dist/contracts/sf-config-v1.d.ts +5 -0
  81. package/dist/contracts/sf-config-v1.js +1 -1
  82. package/dist/contracts/sites.d.ts +17 -12
  83. package/dist/contracts/sites.js +30 -12
  84. package/dist/contracts/space-config.d.ts +46 -117
  85. package/dist/contracts/space-config.js +323 -25
  86. package/dist/contracts/spaces.d.ts +392 -256
  87. package/dist/contracts/spaces.js +163 -83
  88. package/dist/contracts/superadmin-emails.d.ts +27 -3
  89. package/dist/contracts/superadmin-emails.js +10 -15
  90. package/dist/contracts/superadmin-runtime.d.ts +2 -2
  91. package/dist/contracts/superadmin-spaces.d.ts +19 -142
  92. package/dist/contracts/superadmin-spaces.js +7 -0
  93. package/dist/contracts/tags.d.ts +66 -36
  94. package/dist/contracts/tags.js +195 -11
  95. package/dist/contracts/teams.d.ts +9 -9
  96. package/dist/contracts/transfers.d.ts +1 -2
  97. package/dist/contracts/variables.d.ts +4 -4
  98. package/dist/contracts/variables.js +4 -3
  99. package/dist/contracts/webhooks.d.ts +2 -2
  100. package/dist/contracts/zero.d.ts +437 -193
  101. package/dist/contracts/zero.js +149 -158
  102. package/dist/dashboard-paths/index.d.ts +3 -3
  103. package/dist/dashboard-paths/index.js +1 -0
  104. package/dist/docs/agent-prose.js +10 -8
  105. package/dist/docs/agent-setup.d.ts +6 -4
  106. package/dist/docs/agent-setup.js +26 -16
  107. package/dist/docs/agent-solutions.js +1 -1
  108. package/dist/docs/catalog.d.ts +35 -37
  109. package/dist/docs/catalog.js +36 -38
  110. package/dist/docs/error-docs.js +108 -44
  111. package/dist/utils/asset-fingerprint.d.ts +11 -0
  112. package/dist/utils/asset-fingerprint.js +46 -0
  113. package/dist/utils/auth-redirect.d.ts +1 -3
  114. package/dist/utils/auth-redirect.js +1 -21
  115. package/dist/utils/build-settings.d.ts +2 -0
  116. package/dist/utils/build-settings.js +61 -9
  117. package/dist/utils/credential-policy.d.ts +1 -1
  118. package/dist/utils/credential-policy.js +4 -0
  119. package/dist/utils/dns-instructions.d.ts +29 -0
  120. package/dist/utils/dns-instructions.js +78 -0
  121. package/dist/utils/domain-diagnostics.d.ts +29 -0
  122. package/dist/utils/domain-diagnostics.js +63 -0
  123. package/dist/utils/egress-policy.fixtures.json +51 -0
  124. package/dist/utils/grants.d.ts +53 -0
  125. package/dist/utils/grants.js +160 -0
  126. package/dist/utils/id-hints.d.ts +1 -0
  127. package/dist/utils/id-hints.js +55 -13
  128. package/dist/utils/local-space-state.js +1 -0
  129. package/dist/utils/page-colors.d.ts +50 -0
  130. package/dist/utils/page-colors.js +167 -0
  131. package/dist/utils/page-fonts.d.ts +2 -0
  132. package/dist/utils/page-fonts.js +4 -0
  133. package/dist/utils/pages.d.ts +19 -6
  134. package/dist/utils/pages.js +122 -49
  135. package/dist/utils/production-runtime.d.ts +18 -0
  136. package/dist/utils/production-runtime.js +28 -0
  137. package/dist/utils/publish-policy.d.ts +34 -4
  138. package/dist/utils/publish-policy.js +132 -61
  139. package/dist/utils/query-keys.d.ts +7 -13
  140. package/dist/utils/query-keys.js +12 -18
  141. package/dist/utils/source-archive-policy.d.ts +2 -0
  142. package/dist/utils/source-archive-policy.js +2 -0
  143. package/dist/utils/space-config.d.ts +5 -1
  144. package/dist/utils/space-config.js +35 -0
  145. package/dist/utils/static-runtime-policy.d.ts +5 -0
  146. package/dist/utils/static-runtime-policy.fixtures.json +57 -0
  147. package/dist/utils/static-runtime-policy.js +54 -10
  148. package/dist/utils/upload-session.d.ts +3 -0
  149. package/dist/utils/upload-session.js +31 -0
  150. package/package.json +6 -4
  151. package/dist/contracts/annotations.d.ts +0 -327
  152. package/dist/contracts/annotations.js +0 -235
  153. package/dist/contracts/generated-feature-launch-entries.d.ts +0 -2
  154. package/dist/contracts/generated-feature-launch-entries.js +0 -518
  155. package/dist/contracts/publishes.d.ts +0 -135
  156. package/dist/contracts/publishes.js +0 -162
  157. package/dist/utils/access-match.d.ts +0 -39
  158. package/dist/utils/access-match.js +0 -296
  159. package/dist/utils/sf-config-v1.d.ts +0 -2
  160. package/dist/utils/sf-config-v1.js +0 -542
@@ -0,0 +1,167 @@
1
+ // Readability engine for Spacefast-authored pages.
2
+ //
3
+ // Theme colors are intent, not CSS: users and agents push any accent or
4
+ // background (dashboard, spacefast.jsonc, API) and the platform guarantees
5
+ // every rendered page stays readable. This module derives the full set of
6
+ // colors the templates actually paint with:
7
+ //
8
+ // - `onAccent` — button-label color on accent fills (black or white).
9
+ // - `link` — the accent, lightness-adjusted until it meets WCAG AA
10
+ // against the surface it sits on. Hue and chroma survive,
11
+ // so it still reads as the brand color.
12
+ // - `pinned` — when a background is set, a complete coherent scheme
13
+ // (fg/muted/surface/border) derived from it and pinned for
14
+ // every visitor. A chosen background IS the page; the
15
+ // visitor's OS dark-mode setting must not repaint half the
16
+ // variables into an unreadable hybrid.
17
+ //
18
+ // Everything is pure and deterministic: publish finalize, dashboard previews,
19
+ // and tests all call the same functions and get the same pixels.
20
+ import { formatHex, oklch, parse, wcagContrast } from "culori";
21
+ /** Default page palette (mirrored into the shared template CSS). */
22
+ export const PAGE_COLOR_DEFAULTS = {
23
+ accent: "#ff4217",
24
+ bg: "#f9f8f4",
25
+ fg: "#1a1913",
26
+ muted: "#6f6b62",
27
+ card: "#f9f8f4",
28
+ border: "#ddd9cf",
29
+ darkBg: "#141313",
30
+ darkFg: "#e9e7e2",
31
+ darkMuted: "#8f8b84",
32
+ darkCard: "#141313",
33
+ darkBorder: "#2b2a27",
34
+ };
35
+ /** WCAG AA for body-size text. */
36
+ const TEXT_CONTRAST = 4.5;
37
+ /** Body-size button labels on accent fills. */
38
+ const UI_CONTRAST = 4.5;
39
+ /** Essential control boundaries against their painted surface. */
40
+ const CONTROL_CONTRAST = 3;
41
+ /** Primary foreground meets AA even on mid-tone custom backgrounds. */
42
+ const FG_CONTRAST = 4.5;
43
+ function safeParse(value) {
44
+ if (!value)
45
+ return undefined;
46
+ try {
47
+ return parse(value.trim());
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ }
53
+ function contrast(a, b) {
54
+ return wcagContrast(a, b);
55
+ }
56
+ function isLightSurface(surface) {
57
+ return contrast("#000000", surface) >= contrast("#ffffff", surface);
58
+ }
59
+ /**
60
+ * Return `color` unchanged when it already meets `target` on `surface`;
61
+ * otherwise move its OKLCH lightness (hue/chroma preserved) just far enough
62
+ * to meet it. Falls back to plain black/white when even full lightness range
63
+ * cannot reach the target (e.g. a mid-gray surface).
64
+ */
65
+ export function readableOn(color, surface, target) {
66
+ if (contrast(color, surface) >= target)
67
+ return color;
68
+ const parsed = safeParse(color);
69
+ const converted = parsed ? oklch(parsed) : undefined;
70
+ if (!converted)
71
+ return isLightSurface(surface) ? "#000000" : "#ffffff";
72
+ const base = { mode: "oklch", l: converted.l, c: converted.c, h: converted.h ?? 0 };
73
+ const darken = isLightSurface(surface);
74
+ const limit = darken ? 0 : 1;
75
+ const atLimit = formatHex({ ...base, l: limit });
76
+ if (contrast(atLimit, surface) < target) {
77
+ return isLightSurface(surface) ? "#000000" : "#ffffff";
78
+ }
79
+ // Binary search for the lightness closest to the original that still meets
80
+ // the target; contrast is monotonic in lightness on a fixed surface side.
81
+ let searchLimit = limit;
82
+ let searchStart = base.l;
83
+ for (let i = 0; i < 24; i += 1) {
84
+ const mid = (searchStart + searchLimit) / 2;
85
+ if (contrast(formatHex({ ...base, l: mid }), surface) >= target) {
86
+ searchLimit = mid;
87
+ }
88
+ else {
89
+ searchStart = mid;
90
+ }
91
+ }
92
+ return formatHex({ ...base, l: searchLimit });
93
+ }
94
+ /** Button-label color for an accent fill: white when it can carry, else ink. */
95
+ export function onAccentColor(accent) {
96
+ return contrast("#ffffff", accent) >= UI_CONTRAST ? "#ffffff" : "#000000";
97
+ }
98
+ function clamp(value, min, max) {
99
+ return Math.min(max, Math.max(min, value));
100
+ }
101
+ /** Derive a complete coherent scheme from a pushed background color. */
102
+ function schemeFromBackground(background) {
103
+ const parsed = safeParse(background);
104
+ const bg = parsed ? formatHex(parsed) : PAGE_COLOR_DEFAULTS.bg;
105
+ const base = (parsed ? oklch(parsed) : undefined) ?? {
106
+ mode: "oklch",
107
+ l: 0.98,
108
+ c: 0.004,
109
+ h: 80,
110
+ };
111
+ const hue = base.h ?? 0;
112
+ const tint = Math.min(base.c ?? 0, 0.02);
113
+ if (isLightSurface(bg)) {
114
+ return {
115
+ polarity: "light",
116
+ colors: {
117
+ bg,
118
+ card: bg,
119
+ fg: readableOn(PAGE_COLOR_DEFAULTS.fg, bg, FG_CONTRAST),
120
+ muted: readableOn(formatHex({ mode: "oklch", l: 0.55, c: tint, h: hue }), bg, TEXT_CONTRAST),
121
+ border: readableOn(formatHex({ mode: "oklch", l: 0.9, c: Math.min(tint, 0.015), h: hue }), bg, CONTROL_CONTRAST),
122
+ error: readableOn("#a82d1a", bg, TEXT_CONTRAST),
123
+ },
124
+ };
125
+ }
126
+ const borderL = clamp(base.l + 0.1, 0.28, 0.45);
127
+ return {
128
+ polarity: "dark",
129
+ colors: {
130
+ bg,
131
+ card: bg,
132
+ fg: readableOn(PAGE_COLOR_DEFAULTS.darkFg, bg, FG_CONTRAST),
133
+ muted: readableOn(formatHex({ mode: "oklch", l: 0.72, c: tint, h: hue }), bg, TEXT_CONTRAST),
134
+ border: readableOn(formatHex({ mode: "oklch", l: borderL, c: tint, h: hue }), bg, CONTROL_CONTRAST),
135
+ error: readableOn("#ff8a7a", bg, TEXT_CONTRAST),
136
+ },
137
+ };
138
+ }
139
+ /** The one entry point: raw theme in, everything the templates paint with out. */
140
+ export function derivePageColors(theme) {
141
+ const accentInput = theme.accent?.trim();
142
+ const accent = safeParse(accentInput) ? accentInput : PAGE_COLOR_DEFAULTS.accent;
143
+ const onAccent = onAccentColor(accent);
144
+ const background = theme.background?.trim();
145
+ if (background && safeParse(background)) {
146
+ const { polarity, colors } = schemeFromBackground(background);
147
+ return {
148
+ scheme: polarity,
149
+ accent,
150
+ onAccent,
151
+ link: readableOn(accent, colors.card, TEXT_CONTRAST),
152
+ pinned: colors,
153
+ };
154
+ }
155
+ return {
156
+ scheme: "adaptive",
157
+ accent,
158
+ onAccent,
159
+ link: readableOn(accent, PAGE_COLOR_DEFAULTS.card, TEXT_CONTRAST),
160
+ linkDark: readableOn(accent, PAGE_COLOR_DEFAULTS.darkCard, TEXT_CONTRAST),
161
+ };
162
+ }
163
+ /** Hex form of any schema-accepted color, for color-picker inputs. */
164
+ export function pageColorToHex(value) {
165
+ const parsed = safeParse(value);
166
+ return parsed ? formatHex(parsed) : null;
167
+ }