@spacefast/common 0.0.23 → 0.0.24

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 (176) hide show
  1. package/dist/config/domains.d.ts +1 -1
  2. package/dist/config/domains.js +1 -0
  3. package/dist/config/index.d.ts +0 -1
  4. package/dist/config/index.js +0 -1
  5. package/dist/contracts/abuse.d.ts +2 -0
  6. package/dist/contracts/abuse.js +12 -0
  7. package/dist/contracts/access.d.ts +121 -9
  8. package/dist/contracts/access.js +73 -9
  9. package/dist/contracts/activity.d.ts +1 -1
  10. package/dist/contracts/activity.js +0 -9
  11. package/dist/contracts/api-keys.d.ts +21 -21
  12. package/dist/contracts/beta.js +1 -1
  13. package/dist/contracts/billing.d.ts +1 -34
  14. package/dist/contracts/billing.js +4 -53
  15. package/dist/contracts/builds.d.ts +8 -8
  16. package/dist/contracts/builds.js +10 -3
  17. package/dist/contracts/cli.d.ts +10 -0
  18. package/dist/contracts/cli.js +10 -0
  19. package/dist/contracts/collab-public.d.ts +63 -0
  20. package/dist/contracts/collab-public.js +46 -0
  21. package/dist/contracts/comments.d.ts +283 -54
  22. package/dist/contracts/comments.js +173 -52
  23. package/dist/contracts/common.d.ts +3 -3
  24. package/dist/contracts/device-auth.d.ts +6 -6
  25. package/dist/contracts/device-auth.js +1 -1
  26. package/dist/contracts/docs.d.ts +5 -5
  27. package/dist/contracts/domains.d.ts +36 -36
  28. package/dist/contracts/enums.d.ts +33 -30
  29. package/dist/contracts/enums.js +52 -38
  30. package/dist/contracts/error-code-meta.d.ts +37 -126
  31. package/dist/contracts/error-code-meta.js +12 -41
  32. package/dist/contracts/error-codes.d.ts +1 -1
  33. package/dist/contracts/error-codes.js +10 -32
  34. package/dist/contracts/execution.d.ts +35 -57
  35. package/dist/contracts/execution.js +41 -40
  36. package/dist/contracts/feature-lifecycle-core.d.ts +0 -6
  37. package/dist/contracts/feature-lifecycle-core.js +2 -31
  38. package/dist/contracts/feature-lifecycle.d.ts +8 -38
  39. package/dist/contracts/feature-lifecycle.js +16 -48
  40. package/dist/contracts/features.d.ts +15 -13
  41. package/dist/contracts/features.js +39 -38
  42. package/dist/contracts/functions.d.ts +97 -70
  43. package/dist/contracts/functions.js +101 -34
  44. package/dist/contracts/git.d.ts +1 -1
  45. package/dist/contracts/grants.d.ts +7 -3
  46. package/dist/contracts/grants.js +18 -9
  47. package/dist/contracts/internal.d.ts +14 -1
  48. package/dist/contracts/internal.js +17 -7
  49. package/dist/contracts/oauth-resources.d.ts +4 -3
  50. package/dist/contracts/oauth-resources.js +12 -3
  51. package/dist/contracts/operations.d.ts +90 -5
  52. package/dist/contracts/operations.js +75 -1
  53. package/dist/contracts/pages.d.ts +6 -1
  54. package/dist/contracts/pages.js +24 -1
  55. package/dist/contracts/plan-policy.d.ts +1 -3
  56. package/dist/contracts/plan-policy.js +1 -2
  57. package/dist/contracts/platform.d.ts +61 -148
  58. package/dist/contracts/platform.js +70 -126
  59. package/dist/contracts/publish-archive.d.ts +498 -0
  60. package/dist/contracts/publish-archive.js +25 -0
  61. package/dist/contracts/resources.d.ts +12 -24
  62. package/dist/contracts/resources.js +32 -12
  63. package/dist/contracts/runtime-api.d.ts +369 -175
  64. package/dist/contracts/runtime-api.js +372 -348
  65. package/dist/contracts/runtime-app.d.ts +127 -120
  66. package/dist/contracts/runtime-app.js +19 -10
  67. package/dist/contracts/runtime-db.d.ts +1 -1
  68. package/dist/contracts/runtime-services.d.ts +219 -0
  69. package/dist/contracts/runtime-services.js +437 -0
  70. package/dist/contracts/runtime-storage.d.ts +45 -32
  71. package/dist/contracts/runtime-storage.js +30 -8
  72. package/dist/contracts/space-config.d.ts +10 -16
  73. package/dist/contracts/space-config.js +14 -10
  74. package/dist/contracts/spaces.d.ts +241 -436
  75. package/dist/contracts/spaces.js +128 -145
  76. package/dist/contracts/superadmin-activity.d.ts +57 -4
  77. package/dist/contracts/superadmin-activity.js +48 -2
  78. package/dist/contracts/superadmin-search.d.ts +126 -0
  79. package/dist/contracts/superadmin-search.js +61 -0
  80. package/dist/contracts/superadmin-spaces.d.ts +358 -89
  81. package/dist/contracts/superadmin-spaces.js +97 -24
  82. package/dist/contracts/superadmin-teams.d.ts +28 -10
  83. package/dist/contracts/superadmin-teams.js +5 -8
  84. package/dist/contracts/superadmin.d.ts +0 -32
  85. package/dist/contracts/superadmin.js +3 -11
  86. package/dist/contracts/tags.d.ts +9 -9
  87. package/dist/contracts/teams.d.ts +38 -0
  88. package/dist/contracts/teams.js +34 -16
  89. package/dist/contracts/transfers.d.ts +0 -49
  90. package/dist/contracts/transfers.js +2 -6
  91. package/dist/contracts/usage.d.ts +61 -0
  92. package/dist/contracts/usage.js +64 -0
  93. package/dist/contracts/variables.d.ts +2 -7
  94. package/dist/contracts/variables.js +6 -5
  95. package/dist/contracts/webhooks.d.ts +2 -2
  96. package/dist/contracts/zero.d.ts +87 -56
  97. package/dist/contracts/zero.js +82 -20
  98. package/dist/dashboard-paths/index.d.ts +1 -1
  99. package/dist/dashboard-paths/index.js +1 -0
  100. package/dist/docs/agent-prose.d.ts +1 -1
  101. package/dist/docs/agent-prose.js +57 -61
  102. package/dist/docs/agent-setup.js +40 -13
  103. package/dist/docs/catalog.d.ts +19 -19
  104. package/dist/docs/catalog.js +30 -19
  105. package/dist/docs/error-docs.js +63 -151
  106. package/dist/test-helpers/fetch-stub.d.ts +16 -0
  107. package/dist/test-helpers/fetch-stub.js +24 -0
  108. package/dist/utils/build-settings.js +9 -3
  109. package/dist/utils/canonical-json.d.ts +10 -0
  110. package/dist/utils/canonical-json.js +21 -0
  111. package/dist/utils/cast-transport.d.ts +28 -0
  112. package/dist/utils/cast-transport.js +52 -0
  113. package/dist/utils/claim-token.d.ts +0 -8
  114. package/dist/utils/claim-token.js +3 -15
  115. package/dist/utils/credential-policy.d.ts +1 -1
  116. package/dist/utils/env-file.d.ts +17 -0
  117. package/dist/utils/env-file.js +96 -0
  118. package/dist/utils/error-code.d.ts +2 -0
  119. package/dist/utils/error-code.js +7 -0
  120. package/dist/utils/generate-space-name.d.ts +8 -10
  121. package/dist/utils/generate-space-name.js +206 -21
  122. package/dist/utils/grant-decision.fixtures.json +2938 -0
  123. package/dist/utils/grants.d.ts +2 -0
  124. package/dist/utils/grants.js +25 -2
  125. package/dist/utils/gravatar.d.ts +9 -0
  126. package/dist/utils/gravatar.js +31 -0
  127. package/dist/utils/idempotency.d.ts +6 -0
  128. package/dist/utils/idempotency.js +28 -0
  129. package/dist/utils/local-space-state.d.ts +1 -5
  130. package/dist/utils/local-space-state.js +7 -26
  131. package/dist/utils/page-fonts.d.ts +2 -2
  132. package/dist/utils/page-fonts.js +22 -4
  133. package/dist/utils/pages.d.ts +1 -2
  134. package/dist/utils/pages.js +21 -5
  135. package/dist/utils/publish-form-data.d.ts +12 -0
  136. package/dist/utils/publish-form-data.js +10 -0
  137. package/dist/utils/publish-policy.d.ts +20 -0
  138. package/dist/utils/publish-policy.fixtures.json +397 -0
  139. package/dist/utils/publish-policy.js +36 -19
  140. package/dist/utils/push-new.d.ts +7 -0
  141. package/dist/utils/push-new.js +7 -0
  142. package/dist/utils/query-keys.d.ts +0 -1
  143. package/dist/utils/query-keys.js +0 -1
  144. package/dist/utils/runtime-paths.d.ts +5 -0
  145. package/dist/utils/runtime-paths.js +5 -0
  146. package/dist/utils/runtime-upload-batch.d.ts +0 -5
  147. package/dist/utils/runtime-upload-batch.js +1 -27
  148. package/dist/utils/runtime-upload.d.ts +3 -13
  149. package/dist/utils/runtime-upload.js +4 -14
  150. package/dist/utils/space-config.d.ts +0 -33
  151. package/dist/utils/space-config.js +5 -326
  152. package/dist/utils/storage-policy.d.ts +1 -1
  153. package/dist/utils/storage-policy.js +3 -1
  154. package/dist/utils/structured-error.d.ts +14 -0
  155. package/dist/utils/structured-error.js +22 -0
  156. package/dist/utils/version-path.js +12 -3
  157. package/dist/vocabulary.d.ts +5 -3
  158. package/dist/vocabulary.js +13 -10
  159. package/package.json +10 -5
  160. package/dist/config/postgres-budget.d.ts +0 -129
  161. package/dist/config/postgres-budget.js +0 -140
  162. package/dist/config/postgres-budget.json +0 -51
  163. package/dist/contracts/archives.d.ts +0 -331
  164. package/dist/contracts/archives.js +0 -120
  165. package/dist/contracts/deployments.d.ts +0 -574
  166. package/dist/contracts/deployments.js +0 -97
  167. package/dist/contracts/sites.d.ts +0 -416
  168. package/dist/contracts/sites.js +0 -168
  169. package/dist/contracts/superadmin-queues.d.ts +0 -414
  170. package/dist/contracts/superadmin-queues.js +0 -202
  171. package/dist/contracts/superadmin-runtime.d.ts +0 -27
  172. package/dist/contracts/superadmin-runtime.js +0 -38
  173. package/dist/index.d.ts +0 -1
  174. package/dist/index.js +0 -1
  175. package/dist/utils/api.d.ts +0 -4
  176. package/dist/utils/api.js +0 -13
@@ -55,24 +55,40 @@ const SENSITIVE_FILE_PATTERNS = [
55
55
  /\.(pem|key|p12|pfx)$/i,
56
56
  ];
57
57
  // Denied runtime private/control paths (spec "Static path policy").
58
- const STATIC_EXECUTION_CONTROL_FILES = new Set([".htaccess", ".user.ini"]);
58
+ // Every list below is generated verbatim into runtime/engine/admin/upload-policy.php
59
+ // by apps/control-plane/src/scripts/codegen-php-policy.ts, so the two enforcers
60
+ // cannot hold different literals. Lowercase only — both sides fold the path first.
61
+ export const STATIC_EXECUTION_CONTROL_FILES = [".htaccess", ".user.ini"];
59
62
  // Reserved runtime namespace segments are matched by PREFIX: the runtime owns
60
63
  // `/__spacefast/*` plus `__spacefast_generated/`, and the `__stattic` spelling
61
64
  // (`/__stattic_probe` today, more `/__stattic/*` routes planned) stays
62
65
  // reserved the same way. Mid-segment occurrences are ordinary content.
63
- const STATIC_RUNTIME_CONTROL_SEGMENT_PREFIXES = ["__spacefast", "__stattic"];
64
- // Compact platform endpoints live below `/__sf`. Reserve the complete root
65
- // segment prefix before the first endpoint ships so uploaded content can never
66
- // shadow a later platform route. Nested `__sf*` directories remain content.
67
- const STATIC_RUNTIME_ROOT_SEGMENT_PREFIXES = ["__sf"];
66
+ export const STATIC_RUNTIME_CONTROL_SEGMENT_PREFIXES = ["__spacefast", "__stattic"];
67
+ // Reserved as WHOLE root segments. In runtime/engine/shared/context.php the
68
+ // control table gives `/__sf` and `/__span` `match => 'namespace', fold => true`
69
+ // rows, and `_stattic_control_path_row()` reads `namespace` as `=== '/__sf' ||
70
+ // starts_with('/__sf/')`, so `/__sfx/...` and `/__spanish/page` are ordinary
71
+ // tenant paths. Reserving more than the front door claims would refuse a publish
72
+ // of content the front door then happily serves as tenant content.
73
+ //
74
+ // This is a SUBSET of what the control table reserves, not a mirror of it: the
75
+ // table also reserves the nested exact path `/__/collab` (the review link),
76
+ // while the `/__/` prefix around it is tenant-publishable. Publish deliberately
77
+ // does not claim that one — the reservation that matters is enforced at request
78
+ // time, where serve.php refuses to let either a published file or a routing rule
79
+ // answer a reserved route, and that refusal is what runtime/tests/collab-frame.test.ts
80
+ // exercises by publishing a file at `__/collab` on purpose. The control table is
81
+ // the authority; this list is a publish-time convenience, so keep it a subset
82
+ // and never let it contradict the table.
83
+ export const STATIC_RUNTIME_ROOT_SEGMENTS = ["__sf", "__span"];
68
84
  // Both the current and the legacy control-path spellings stay denied: spaces
69
85
  // published before the `.stattic` → `.spacefast` rename still serve from the
70
86
  // legacy on-disk layout, and user archives may carry either name.
71
- const STATIC_RUNTIME_CONTROL_PATHS = new Set([
87
+ export const STATIC_RUNTIME_CONTROL_PATHS = [
72
88
  ".well-known/spacefast-runtime",
73
89
  ".well-known/stattic-runtime",
74
- ]);
75
- const STATIC_RUNTIME_CONTROL_PREFIXES = [
90
+ ];
91
+ export const STATIC_RUNTIME_CONTROL_PREFIXES = [
76
92
  ".spacefast/storage",
77
93
  ".spacefast/engine",
78
94
  ".stattic/storage",
@@ -95,7 +111,7 @@ export function normalizePublishPath(relativePath) {
95
111
  * minted with, and a publish that could overwrite it would be a publish that
96
112
  * could mint its own tokens.
97
113
  */
98
- const PUBLISHABLE_BUILD_ARTIFACT_PREFIX = "__spacefast/functions/bundles/";
114
+ export const PUBLISHABLE_BUILD_ARTIFACT_PREFIX = "__spacefast/functions/bundles/";
99
115
  /**
100
116
  * The one FILE inside the control prefix a publish may write.
101
117
  *
@@ -137,8 +153,9 @@ export function publishPathIsConvention(relativePath) {
137
153
  }
138
154
  // Provider runtime features that have no Spacefast equivalent (spec "Routing And
139
155
  // Headers", migration diagnostics): Cloudflare Pages `_worker.js`/`_routes.json`
140
- // and Pages/Netlify function directories publish as inert content with a
141
- // warning so migrations are never silent.
156
+ // and Netlify's provider-specific function directory publish as inert content
157
+ // with a warning so migrations are never silent. A root `functions/` directory
158
+ // is Spacefast's own file-router convention and must never reach this warning.
142
159
  function providerRuntimeFeatureForPath(path) {
143
160
  if (path === "_worker.js") {
144
161
  return "Cloudflare Pages _worker.js";
@@ -146,9 +163,6 @@ function providerRuntimeFeatureForPath(path) {
146
163
  if (path === "_routes.json") {
147
164
  return "Cloudflare Pages _routes.json";
148
165
  }
149
- if (path.startsWith("functions/")) {
150
- return "Pages Functions (functions/)";
151
- }
152
166
  if (path.startsWith("netlify/functions/")) {
153
167
  return "Netlify Functions (netlify/functions/)";
154
168
  }
@@ -196,7 +210,10 @@ export function staticUploadPathViolation(path, options = {}) {
196
210
  return pathViolation("invalid_file_path", "File path is invalid.", rawPath);
197
211
  }
198
212
  if (normalizedPath !== rawPath) {
199
- return pathViolation("invalid_file_path", "File path is invalid.", normalizedPath);
213
+ // The path the caller sent, not the normal form it missed: echoing a
214
+ // rewritten path suggests the rewrite was accepted, and it is the one place
215
+ // this policy used to report a different string than the runtime's copy.
216
+ return pathViolation("invalid_file_path", "File path is invalid.", rawPath);
200
217
  }
201
218
  if (new TextEncoder().encode(normalizedPath).length > MANIFEST_MAX_PATH_BYTES) {
202
219
  return pathViolation("path_too_long", `File paths support up to ${MANIFEST_MAX_PATH_BYTES} bytes in canonical form.`, normalizedPath);
@@ -208,7 +225,7 @@ export function staticUploadPathViolation(path, options = {}) {
208
225
  if (invalidSegment) {
209
226
  return pathViolation("invalid_file_path", "File path is invalid.", normalizedPath);
210
227
  }
211
- if (STATIC_EXECUTION_CONTROL_FILES.has(lowerName)) {
228
+ if (STATIC_EXECUTION_CONTROL_FILES.includes(lowerName)) {
212
229
  return pathViolation("static_control_file_not_supported", "Static deploys cannot upload execution-control files.", normalizedPath);
213
230
  }
214
231
  const reservedRuntimeControlFiles = options.reservedRuntimeControlFiles
@@ -218,7 +235,7 @@ export function staticUploadPathViolation(path, options = {}) {
218
235
  return pathViolation("static_runtime_control_path_not_supported", "Static deploys cannot upload runtime control paths.", normalizedPath);
219
236
  }
220
237
  const lowerRootSegment = segments[0]?.toLowerCase() ?? "";
221
- if (STATIC_RUNTIME_ROOT_SEGMENT_PREFIXES.some((prefix) => lowerRootSegment.startsWith(prefix))) {
238
+ if (STATIC_RUNTIME_ROOT_SEGMENTS.includes(lowerRootSegment)) {
222
239
  return pathViolation("static_runtime_control_path_not_supported", "Static deploys cannot upload runtime control paths.", normalizedPath);
223
240
  }
224
241
  const controlSegment = segments.find((segment) => {
@@ -231,7 +248,7 @@ export function staticUploadPathViolation(path, options = {}) {
231
248
  if (STATIC_RUNTIME_CONTROL_PREFIXES.some((prefix) => lowerPath === prefix || lowerPath.startsWith(`${prefix}/`))) {
232
249
  return pathViolation("static_runtime_control_path_not_supported", "Static deploys cannot upload runtime control paths.", normalizedPath);
233
250
  }
234
- if (STATIC_RUNTIME_CONTROL_PATHS.has(lowerPath)) {
251
+ if (STATIC_RUNTIME_CONTROL_PATHS.includes(lowerPath)) {
235
252
  return pathViolation("static_runtime_control_path_not_supported", "Static deploys cannot upload runtime control paths.", normalizedPath);
236
253
  }
237
254
  return null;
@@ -0,0 +1,7 @@
1
+ import { type DeployEnv } from "../config/domains.js";
2
+ export declare function pushNewRemoteUrl(input: {
3
+ slug: string;
4
+ token: string;
5
+ origin?: string;
6
+ environment?: Extract<DeployEnv, "dev" | "prod">;
7
+ }): string;
@@ -0,0 +1,7 @@
1
+ import { serviceOrigin } from "../config/domains.js";
2
+ export function pushNewRemoteUrl(input) {
3
+ const url = new URL(`/${encodeURIComponent(input.slug)}`, input.origin ?? serviceOrigin("push", input.environment ?? "prod"));
4
+ url.username = "t";
5
+ url.password = input.token;
6
+ return url.toString();
7
+ }
@@ -31,7 +31,6 @@ export declare const qk: {
31
31
  spaceComments: (id: string) => readonly ["spaces", string, "comments"];
32
32
  spaceCommentThread: (id: string, threadId: string) => readonly ["spaces", string, "comments", string];
33
33
  spaceActivity: (id: string, limit: number) => readonly ["spaces", string, "activity", number];
34
- spaceDeployments: (id: string) => readonly ["spaces", string, "deployments"];
35
34
  spaceTags: (id: string) => readonly ["spaces", string, "tags"];
36
35
  spaceTagVersion: (id: string, versionId: string) => readonly ["spaces", string, "tags", string];
37
36
  spaceTagDiff: (id: string, versionId: string) => readonly ["spaces", string, "tags", string, "diff"];
@@ -39,7 +39,6 @@ export const qk = {
39
39
  spaceComments: (id) => ["spaces", id, "comments"],
40
40
  spaceCommentThread: (id, threadId) => [...qk.spaceComments(id), threadId],
41
41
  spaceActivity: (id, limit) => ["spaces", id, "activity", limit],
42
- spaceDeployments: (id) => ["spaces", id, "deployments"],
43
42
  spaceTags: (id) => ["spaces", id, "tags"],
44
43
  spaceTagVersion: (id, versionId) => ["spaces", id, "tags", versionId],
45
44
  spaceTagDiff: (id, versionId) => ["spaces", id, "tags", versionId, "diff"],
@@ -5,5 +5,10 @@ export declare const RUNTIME_HEALTH_PATH: "/__spacefast/health.php";
5
5
  export declare const RUNTIME_COMMENTS_CONFIG_PATH: "/__spacefast/comments/config";
6
6
  export declare const RUNTIME_COMMENTS_TICKET_PATH: "/__spacefast/comments/ticket";
7
7
  export declare const RUNTIME_COMMENTS_VERSION_URLS_PATH: "/__spacefast/comments/version-urls";
8
+ /** The review workspace the orb expands into — a reserved control path on the
9
+ * Space's own origin (collab-frame-plan §4), not part of the `/__spacefast`
10
+ * exchange namespace because people paste this one into Slack.
11
+ * The PHP mirror is SPACEFAST_COLLAB_FRAME_PATH in runtime/engine/shared/context.php. */
12
+ export declare const RUNTIME_COLLAB_FRAME_PATH: "/__/collab";
8
13
  export declare function runtimeManagementPath(suffix: string): string;
9
14
  export declare function runtimeUploadPath(params: URLSearchParams | Record<string, string>): string;
@@ -9,6 +9,11 @@ export const RUNTIME_HEALTH_PATH = `${SPACEFAST_RUNTIME_NAMESPACE}/health.php`;
9
9
  export const RUNTIME_COMMENTS_CONFIG_PATH = `${SPACEFAST_RUNTIME_NAMESPACE}/comments/config`;
10
10
  export const RUNTIME_COMMENTS_TICKET_PATH = `${SPACEFAST_RUNTIME_NAMESPACE}/comments/ticket`;
11
11
  export const RUNTIME_COMMENTS_VERSION_URLS_PATH = `${SPACEFAST_RUNTIME_NAMESPACE}/comments/version-urls`;
12
+ /** The review workspace the orb expands into — a reserved control path on the
13
+ * Space's own origin (collab-frame-plan §4), not part of the `/__spacefast`
14
+ * exchange namespace because people paste this one into Slack.
15
+ * The PHP mirror is SPACEFAST_COLLAB_FRAME_PATH in runtime/engine/shared/context.php. */
16
+ export const RUNTIME_COLLAB_FRAME_PATH = "/__/collab";
12
17
  export function runtimeManagementPath(suffix) {
13
18
  const route = normalizeRuntimeRoute(suffix);
14
19
  if (route === "/") {
@@ -1,13 +1,8 @@
1
1
  import { Buffer } from "node:buffer";
2
- import { RUNTIME_UPLOAD_BATCH_MAX_BYTES, RUNTIME_UPLOAD_BATCH_MAX_FILES } from "./runtime-upload.js";
3
- import { type UploadTarget } from "./upload-session.js";
4
- export { RUNTIME_UPLOAD_BATCH_MAX_BYTES, RUNTIME_UPLOAD_BATCH_MAX_FILES };
5
2
  export type RuntimeBatchArchiveEntry = {
6
3
  path: string;
7
4
  getBytes(): Buffer | Promise<Buffer>;
8
5
  };
9
- export declare function runtimeBatchUploadUnsupported(error: unknown): boolean;
10
- export declare function batchTargetForUploadTarget(uploadId: string, target: UploadTarget): UploadTarget | null;
11
6
  export declare function tarPathParts(filePath: string): {
12
7
  name: string;
13
8
  prefix: string;
@@ -1,31 +1,4 @@
1
1
  import { Buffer } from "node:buffer";
2
- import { RUNTIME_UPLOAD_BATCH_MAX_BYTES, RUNTIME_UPLOAD_BATCH_MAX_FILES, } from "./runtime-upload.js";
3
- import { UploadTargetError } from "./upload-session.js";
4
- // Batch planning + tar-writing wire contract shared by the CLI and the control
5
- // plane's inline publish path. This is the sender half of the runtime's tar
6
- // batch parser (runtime/engine/admin/upload.php); any change here must stay in
7
- // lockstep with that file.
8
- export { RUNTIME_UPLOAD_BATCH_MAX_BYTES, RUNTIME_UPLOAD_BATCH_MAX_FILES };
9
- export function runtimeBatchUploadUnsupported(error) {
10
- return error instanceof UploadTargetError && (error.status === 404 || error.status === 405);
11
- }
12
- export function batchTargetForUploadTarget(uploadId, target) {
13
- const url = new URL(target.url);
14
- if (!url.pathname.endsWith("/upload.php")) {
15
- return null;
16
- }
17
- url.search = new URLSearchParams({ op: "batch", upload_id: uploadId }).toString();
18
- return {
19
- ...target,
20
- path: "__spacefast_batch.tar",
21
- method: "POST",
22
- url: url.toString(),
23
- headers: {
24
- ...target.headers,
25
- "content-type": "application/x-tar",
26
- },
27
- };
28
- }
29
2
  export function tarPathParts(filePath) {
30
3
  if (Buffer.byteLength(filePath) <= 100) {
31
4
  return { name: filePath, prefix: "" };
@@ -57,6 +30,7 @@ export async function tarArchive(entries, pathTooLongError) {
57
30
  if (!parts) {
58
31
  throw pathTooLongError(entry.path);
59
32
  }
33
+ // oxlint-disable-next-line no-await-in-loop -- Tar entries must retain declared order.
60
34
  const body = Buffer.from(await entry.getBytes());
61
35
  const header = Buffer.alloc(512);
62
36
  header.write(parts.name, 0, Math.min(100, Buffer.byteLength(parts.name)), "utf8");
@@ -1,21 +1,11 @@
1
- export declare const RUNTIME_UPLOAD_METHOD: "PUT";
2
- export declare const RUNTIME_UPLOAD_BATCH_MAX_FILES = 500;
3
- export declare const RUNTIME_UPLOAD_BATCH_MAX_BYTES: number;
4
1
  export declare function runtimeUploadCanonicalPath(path: string): string;
5
- export declare function runtimeUploadSessionBaseUrl(input: {
6
- baseUrl: string;
7
- uploadId: string;
8
- }): string;
9
- export declare function runtimeUploadBatchUrl(input: {
10
- baseUrl: string;
11
- uploadId: string;
12
- }): string;
13
2
  export declare function runtimeUploadFetchUrl(input: {
14
3
  baseUrl: string;
15
4
  uploadId: string;
16
5
  path: string;
17
6
  }): string;
18
- export declare function runtimeUploadFileUrl(input: {
7
+ export declare function runtimeUploadBlobUrl(input: {
19
8
  baseUrl: string;
20
- path: string;
9
+ spaceId: string;
10
+ sha256: string;
21
11
  }): string;
@@ -1,10 +1,4 @@
1
1
  import { runtimeUploadPath } from "./runtime-paths.js";
2
- export const RUNTIME_UPLOAD_METHOD = "PUT";
3
- // Mirrors STATTIC_RUNTIME_UPLOAD_BATCH_MAX_FILES/_MAX_BYTES in
4
- // runtime/engine/admin/upload.php (parity-guarded in
5
- // apps/control-plane/src/runtime/php-policy-parity.test.ts).
6
- export const RUNTIME_UPLOAD_BATCH_MAX_FILES = 500;
7
- export const RUNTIME_UPLOAD_BATCH_MAX_BYTES = 8 * 1024 * 1024;
8
2
  export function runtimeUploadCanonicalPath(path) {
9
3
  // Canonical path form (spec "Upload Contract"): UTF-8, Unicode NFC,
10
4
  // percent-encoded once. The runtime rejects non-canonical encodings.
@@ -14,12 +8,6 @@ export function runtimeUploadCanonicalPath(path) {
14
8
  .map((segment) => encodeURIComponent(segment))
15
9
  .join("/");
16
10
  }
17
- export function runtimeUploadSessionBaseUrl(input) {
18
- return new URL(runtimeUploadPath({ op: "file", upload_id: input.uploadId, path: "" }), input.baseUrl).toString();
19
- }
20
- export function runtimeUploadBatchUrl(input) {
21
- return new URL(runtimeUploadPath({ op: "batch", upload_id: input.uploadId }), input.baseUrl).toString();
22
- }
23
11
  export function runtimeUploadFetchUrl(input) {
24
12
  return new URL(runtimeUploadPath({
25
13
  op: "fetch",
@@ -27,6 +15,8 @@ export function runtimeUploadFetchUrl(input) {
27
15
  path: runtimeUploadCanonicalPath(input.path),
28
16
  }), input.baseUrl).toString();
29
17
  }
30
- export function runtimeUploadFileUrl(input) {
31
- return `${input.baseUrl}${runtimeUploadCanonicalPath(input.path)}`;
18
+ export function runtimeUploadBlobUrl(input) {
19
+ return new URL(runtimeUploadPath({
20
+ route: `/spaces/${encodeURIComponent(input.spaceId)}/blobs/${encodeURIComponent(input.sha256)}`,
21
+ }), input.baseUrl).toString();
32
22
  }
@@ -1,5 +1,4 @@
1
1
  import { type Grant } from "../contracts/grants.js";
2
- import type { RuntimeKind } from "../contracts/execution.js";
3
2
  import { type SpaceConfig, type SpaceConfigFile } from "../contracts/space-config.js";
4
3
  export type SpaceConfigBlockingIssueCode = "config_file_too_large" | "config_templates_over_limit" | "config_meta_too_long" | "config_name_too_long" | "config_functions_key_removed" | "config_invalid" | "config_runtime_invalid_kind" | "config_runtime_entry_missing" | "inject_snippet_too_large" | "inject_invalid";
5
4
  export type SpaceConfigIssue = {
@@ -32,19 +31,6 @@ export declare const SPACE_CONFIG_FILE_ONLY_KEYS: readonly ["access", "name", "r
32
31
  */
33
32
  export declare function spaceConfigOverlayIssue(config: unknown): SpaceConfigBlockingIssue | null;
34
33
  export declare function stripJsonComments(raw: string): string;
35
- export type ParsedSpaceConfigFile = {
36
- /** Parsed config (cap- and shape-valid keys only); null when unusable. */
37
- config: SpaceConfigFile | null;
38
- issues: SpaceConfigIssue[];
39
- };
40
- /**
41
- * Parses a raw `sf.jsonc` at finalize: 256 KB cap, JSONC tolerance,
42
- * routing-key rejection, unknown-key diagnostics, shared shape caps. Errors
43
- * fail the version; warnings ride version diagnostics.
44
- */
45
- export declare function parseSpaceConfigFile(raw: string, options?: {
46
- path?: string;
47
- }): ParsedSpaceConfigFile;
48
34
  export type ResolvedServingConfig = {
49
35
  index: string | false;
50
36
  fallback: {
@@ -63,25 +49,6 @@ export type ResolvedServingConfig = {
63
49
  /** Resolved inject snippets; only honored when experimentalGutenberg is true. */
64
50
  inject: NonNullable<SpaceConfig["inject"]> | null;
65
51
  };
66
- export type EffectiveSpaceConfig = {
67
- /** The merged SpaceConfig (defaults + file + overlay, key-wise). */
68
- config: SpaceConfig;
69
- /** Compiled serving primitives the runtime artifact stores. */
70
- serving: ResolvedServingConfig;
71
- issues: SpaceConfigIssue[];
72
- };
73
- /**
74
- * Resolves the effective SpaceConfig for a version at finalize (or
75
- * config-only regeneration). `manifestPaths` is the canonical committed file
76
- * set; `fileConfig` the parsed sf.jsonc (null when absent); `overlay`
77
- * the stored space config overlay (null when nothing overridden).
78
- */
79
- export declare function resolveEffectiveSpaceConfig(input: {
80
- manifestPaths: ReadonlySet<string>;
81
- fileConfig: SpaceConfig | null;
82
- overlay: SpaceConfig | null;
83
- runtimeKind?: RuntimeKind;
84
- }): EffectiveSpaceConfig;
85
52
  export type SpaceSettingsPatch = {
86
53
  mode?: "website" | "files" | undefined;
87
54
  spa?: boolean | undefined;