@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
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { appRoutePathSchema, executionCapabilitiesSchema, executionLogEntrySchema, executionLogListQuerySchema, executionLogListResponseSchema, executionSha256Schema, httpMethodSchema, runtimeKindSchema, } from "./execution.js";
2
+ import { appRoutePathSchema, executionCapabilitiesSchema, executionSha256Schema, httpMethodSchema, } from "./execution.js";
3
3
  /**
4
4
  * Spacefast Functions: tenant workers run as Cloudflare Dynamic Workers.
5
5
  *
@@ -37,6 +37,13 @@ import { appRoutePathSchema, executionCapabilitiesSchema, executionLogEntrySchem
37
37
  * than transactional. That is why capsules are a different product rather
38
38
  * than a placement option — see `endpointIsPortable` in `./execution.js`.
39
39
  */
40
+ /**
41
+ * The tag a compiled worker artifact carries — in `functionsSourceFinalizeSchema`
42
+ * and the runtime config built from it — so the PHP origin can tell what it is
43
+ * dispatching (`functions-dispatch.php` refuses a config tagged anything else).
44
+ * It is a property of the artifact the tree produced, not a kind a space or a
45
+ * version declares: a publish can carry this beside a capsule.
46
+ */
40
47
  export const FUNCTIONS_RUNTIME_KIND = "functions";
41
48
  export const FUNCTIONS_SOURCE_METADATA_KEY = "spacefastFunctions";
42
49
  export const FUNCTIONS_PLATFORM_ROUTE_PREFIX = "/__spacefast/functions";
@@ -45,6 +52,17 @@ export const FUNCTIONS_RUNTIME_ROUTE_PATHS = {
45
52
  /** Where a dispatched worker calls back for brokered capabilities. */
46
53
  relay: `${FUNCTIONS_PLATFORM_ROUTE_PREFIX}/relay`,
47
54
  };
55
+ /**
56
+ * Where invocation counts are reported, on the CONTROL PLANE rather than the
57
+ * space origin.
58
+ *
59
+ * The two destinations are separate on purpose. Logs are the tenant's content
60
+ * and stay on their own origin; usage is a number the platform bills from and
61
+ * goes straight to us. Sharing one channel would make either destination a
62
+ * plausible place to look for the other's data, and would put log volume on the
63
+ * path that has to stay cheap.
64
+ */
65
+ export const FUNCTIONS_USAGE_INTAKE_PATH = "/v1/runtime/functions/usage";
48
66
  /** Public, signed read path. Distinct from storage so the token is never a filename. */
49
67
  export const FUNCTIONS_BUNDLE_ROUTE_PREFIX = `${FUNCTIONS_PLATFORM_ROUTE_PREFIX}/b`;
50
68
  export const FUNCTIONS_RUNTIME_STORAGE_ROOT = "__spacefast/functions";
@@ -221,6 +239,18 @@ export const functionsWorkerArtifactSchema = z
221
239
  * so an injected dependency cannot widen authority at runtime.
222
240
  */
223
241
  capabilities: executionCapabilitiesSchema,
242
+ /**
243
+ * Platform-owned runtime services this build needs. This is deliberately
244
+ * separate from author capabilities: an OpenNext build needs durable cache
245
+ * storage even when the application itself declares no database or fetch
246
+ * access, and that storage must never become a general tenant credential.
247
+ */
248
+ platform: z
249
+ .object({
250
+ nextCache: z.boolean().default(false),
251
+ })
252
+ .strict()
253
+ .default({ nextCache: false }),
224
254
  })
225
255
  .strict();
226
256
  /**
@@ -232,13 +262,24 @@ export const functionsWorkerArtifactSchema = z
232
262
  * *grants*, resolved by the control plane at finalize so the origin forwards a
233
263
  * decision rather than making one. Anything absent fails closed at the relay.
234
264
  */
235
- export const FUNCTIONS_DISPATCH_CAPABILITIES = ["db.read", "db.write", "fetch", "log"];
265
+ export const FUNCTIONS_DISPATCH_CAPABILITIES = [
266
+ "storage.read",
267
+ "storage.write",
268
+ "db.read",
269
+ "db.write",
270
+ "fetch",
271
+ "log",
272
+ "next.cache",
273
+ "gravatar.profile",
274
+ "spam.check",
275
+ "email.send",
276
+ ];
236
277
  export const functionsDispatchCapabilitySchema = z.enum(FUNCTIONS_DISPATCH_CAPABILITIES);
237
278
  /**
238
279
  * Resolves a build's declared capabilities into the grant a dispatch carries.
239
280
  *
240
- * Three of the six declared capabilities have no dispatch counterpart, and each
241
- * for its own reason:
281
+ * Three declared capabilities have no dispatch counterpart, each for its own
282
+ * reason:
242
283
  *
243
284
  * - `env` is not a runtime call at all. Values are resolved at finalize and
244
285
  * travel in the config, so a worker reading `env` reaches nothing.
@@ -250,9 +291,17 @@ export const functionsDispatchCapabilitySchema = z.enum(FUNCTIONS_DISPATCH_CAPAB
250
291
  * touches the database, not how. Narrowing it would take per-statement analysis
251
292
  * we do not do, and guessing "read-only" from a declaration would be a grant
252
293
  * the author never asked for and cannot see.
294
+ *
295
+ * The three platform-service grants are named for the operation an author
296
+ * reaches for, and each covers its service's whole operation set for the same
297
+ * reason `db` widens: a declaration says a handler uses spam checking, not that
298
+ * it never files a correction.
253
299
  */
254
- export function functionsDispatchCapabilities(capabilities) {
255
- const granted = new Set();
300
+ export function functionsDispatchCapabilities(capabilities, platform = {}) {
301
+ // Storage is the durable, unversioned substrate every app receives. It is a
302
+ // base binding like the Zero client's `storage`, not a source-declared
303
+ // capability that disappears when a new version omits an import.
304
+ const granted = new Set(["storage.read", "storage.write"]);
256
305
  if (capabilities.db) {
257
306
  granted.add("db.read");
258
307
  granted.add("db.write");
@@ -263,14 +312,26 @@ export function functionsDispatchCapabilities(capabilities) {
263
312
  if (capabilities.logging) {
264
313
  granted.add("log");
265
314
  }
315
+ if (capabilities.gravatar) {
316
+ granted.add("gravatar.profile");
317
+ }
318
+ if (capabilities.spam) {
319
+ granted.add("spam.check");
320
+ }
321
+ if (capabilities.email) {
322
+ granted.add("email.send");
323
+ }
324
+ if (platform.nextCache) {
325
+ granted.add("next.cache");
326
+ }
266
327
  // Filtered from the canonical list so the order is stable: the grant is part
267
328
  // of the host's isolate identity, and a reordering would retire warm isolates
268
329
  // for no reason.
269
330
  return FUNCTIONS_DISPATCH_CAPABILITIES.filter((capability) => granted.has(capability));
270
331
  }
271
- /** Everything except `log` needs the relay to mean anything. */
332
+ /** Logs and the host-local Next cache do not transit the origin relay. */
272
333
  export function functionsGrantNeedsRelay(granted) {
273
- return granted.some((capability) => capability !== "log");
334
+ return granted.some((capability) => capability !== "log" && capability !== "next.cache");
274
335
  }
275
336
  /**
276
337
  * What the space origin needs in order to dispatch to the host on its own. The
@@ -321,6 +382,26 @@ export const functionsRelayConfigSchema = z
321
382
  maxConcurrentCalls: z.number().int().min(1).max(64),
322
383
  })
323
384
  .strict();
385
+ /**
386
+ * Where the execution host reports how much this version ran.
387
+ *
388
+ * Absent means uncounted, not refused: a space whose configuration predates
389
+ * usage reporting must keep serving, and an execution tier that cannot reach
390
+ * the control plane must never fail a request over it. Counting is reporting
391
+ * only — nothing here throttles, and no limit is enforced anywhere from it.
392
+ */
393
+ export const functionsUsageConfigSchema = z
394
+ .object({
395
+ url: z.string().url(),
396
+ /**
397
+ * Minted and verified by the control plane alone; the space only forwards
398
+ * it. Version-scoped like the relay credential, and folded into the host's
399
+ * isolate identity for the same reason: a rotated credential must not
400
+ * outlive its rotation inside a warm isolate.
401
+ */
402
+ token: z.string().min(1),
403
+ })
404
+ .strict();
324
405
  /**
325
406
  * What a build declares about its worker — everything the CLI can know from the
326
407
  * author's project alone.
@@ -349,15 +430,17 @@ export const functionsSourceFinalizeSchema = z
349
430
  * The document the control plane sends to the runtime, which the engine stores
350
431
  * beside the version's files and the origin reads on every dispatch.
351
432
  *
352
- * It is the build's declaration plus the four things only the platform can
353
- * supply: where to dispatch, what the worker is allowed to do, the credential
354
- * that lets it do those things, and the resolved values of its variables.
433
+ * It is the build's declaration plus the things only the platform can supply:
434
+ * where to dispatch, what the worker is allowed to do, the credentials that let
435
+ * it do those things and report what it did, and the resolved values of its
436
+ * variables.
355
437
  */
356
438
  export const functionsRuntimeConfigSchema = functionsSourceFinalizeSchema
357
439
  .extend({
358
440
  host: functionsHostConfigSchema,
359
- grantedCapabilities: z.array(functionsDispatchCapabilitySchema).max(8).default([]),
441
+ grantedCapabilities: z.array(functionsDispatchCapabilitySchema).max(10).default([]),
360
442
  relay: functionsRelayConfigSchema.nullable().default(null),
443
+ usage: functionsUsageConfigSchema.nullable().default(null),
361
444
  /**
362
445
  * Resolved at finalize, so a worker reading configuration never calls back
363
446
  * to us for it — and so rotating a variable is a republish with an audit
@@ -396,6 +479,7 @@ export function createFunctionsSourceFinalize(input) {
396
479
  compatibilityFlags: input.compatibilityFlags ?? [],
397
480
  routes: input.routes ?? [],
398
481
  capabilities: input.capabilities ?? {},
482
+ platform: { nextCache: input.nextCache ?? false },
399
483
  },
400
484
  variables: {
401
485
  source: "spacefast-variables",
@@ -421,10 +505,12 @@ export const functionsExecutionStateSchema = z.enum([
421
505
  "serving",
422
506
  ]);
423
507
  /**
424
- * What a live worker is, as the `app` member of a space's runtime status.
508
+ * What a live worker is, as the `worker` member of a space's runtime status.
509
+ *
510
+ * It carries no kind tag. The member it rides in already says which product
511
+ * answered, and the same tree can carry a capsule beside it — a discriminant
512
+ * here could only repeat the field name or contradict its sibling.
425
513
  *
426
- * Shaped like `zeroAppSchema` and discriminated by the same `runtimeKind`, so a
427
- * reader switches on one field rather than probing for which product answered.
428
514
  * No `versionId`: the status response it rides in already names the live
429
515
  * version.
430
516
  *
@@ -435,7 +521,6 @@ export const functionsExecutionStateSchema = z.enum([
435
521
  */
436
522
  export const functionsAppSchema = z
437
523
  .object({
438
- runtimeKind: z.literal(FUNCTIONS_RUNTIME_KIND),
439
524
  artifactId: z.string().min(1),
440
525
  appName: z.string().min(1),
441
526
  entry: z.string().min(1),
@@ -455,21 +540,3 @@ export const functionsAppSchema = z
455
540
  .strict(),
456
541
  })
457
542
  .strict();
458
- /**
459
- * The wire shape of the origin's log-read route, not a public API contract.
460
- *
461
- * Handler logs reach callers through `GET /v1/spaces/:spaceId/logs/runtime`,
462
- * which serves the platform's own `runtimeLogListResponseSchema` for both
463
- * execution tiers. These aliases describe the hop underneath it: a worker tails
464
- * its output to the origin that dispatched it, and the control plane reads it
465
- * back from there. Keeping them named after this product is the point — the
466
- * origin is the only place a wp.cloud-hosted space keeps anything, and Zero's
467
- * records never travel this path at all.
468
- */
469
- export const functionsLogEntrySchema = executionLogEntrySchema;
470
- export const functionsLogListQuerySchema = executionLogListQuerySchema;
471
- export const functionsLogListResponseSchema = executionLogListResponseSchema;
472
- /** Narrows a space's live runtime kind to this product. */
473
- export function isFunctionsRuntime(kind) {
474
- return kind === FUNCTIONS_RUNTIME_KIND;
475
- }
@@ -8,8 +8,8 @@ export declare const buildTarget: z.ZodEnum<{
8
8
  export declare const buildTrigger: z.ZodEnum<{
9
9
  push: "push";
10
10
  manual: "manual";
11
- pull_request: "pull_request";
12
11
  retry: "retry";
12
+ pull_request: "pull_request";
13
13
  }>;
14
14
  export declare const buildEnvironmentScopeValues: readonly ["runtime", "build", "build:production", "build:preview"];
15
15
  export declare const buildEnvironmentScope: z.ZodEnum<{
@@ -8,9 +8,6 @@ export declare const grantCapabilitySchema: z.ZodEnum<{
8
8
  "access.manage": "access.manage";
9
9
  }>;
10
10
  export type GrantCapability = z.infer<typeof grantCapabilitySchema>;
11
- export declare const GRANT_CAPABILITY_PRESETS: readonly ["view", "comment", "publish", "manage"];
12
- export type GrantCapabilityPreset = (typeof GRANT_CAPABILITY_PRESETS)[number];
13
- export declare const GRANT_PRESET_CAPABILITIES: Record<GrantCapabilityPreset, GrantCapability[]>;
14
11
  export declare const GRANT_AUDIENCE_KINDS: readonly ["public", "team", "person", "link", "password", "machine", "external"];
15
12
  export declare const grantAudienceKindSchema: z.ZodEnum<{
16
13
  link: "link";
@@ -1079,6 +1076,13 @@ export declare const identityConnectionPublicKeySchema: z.ZodObject<{
1079
1076
  publicKey: z.ZodString;
1080
1077
  }, z.core.$strict>;
1081
1078
  export type IdentityConnectionPublicKey = z.infer<typeof identityConnectionPublicKeySchema>;
1079
+ /**
1080
+ * Issuers the platform stamps on its own external Grants. A Team-configured
1081
+ * connection may not claim one: the authority reference an external audience
1082
+ * resolves to is derived from (issuer, subject), and these three resolve into
1083
+ * the platform's own `member:` / `claim-preview:` / owner namespaces.
1084
+ */
1085
+ export declare const RESERVED_IDENTITY_CONNECTION_ISSUERS: readonly ["spacefast-membership", "claim-preview", "spacefast-owner"];
1082
1086
  export declare const identityConnectionCreateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1083
1087
  type: z.ZodLiteral<"oidc">;
1084
1088
  name: z.ZodString;
@@ -9,13 +9,6 @@ export const GRANT_CAPABILITIES = [
9
9
  "access.manage",
10
10
  ];
11
11
  export const grantCapabilitySchema = z.enum(GRANT_CAPABILITIES);
12
- export const GRANT_CAPABILITY_PRESETS = ["view", "comment", "publish", "manage"];
13
- export const GRANT_PRESET_CAPABILITIES = {
14
- view: ["page.view"],
15
- comment: ["page.view", "comments.read", "comments.write"],
16
- publish: ["page.view", "content.publish"],
17
- manage: ["page.view", "comments.read", "comments.write", "content.publish", "access.manage"],
18
- };
19
12
  export const GRANT_AUDIENCE_KINDS = [
20
13
  "public",
21
14
  "team",
@@ -714,12 +707,28 @@ export const identityConnectionPublicKeySchema = z
714
707
  .regex(/^[A-Za-z0-9_-]{43}$/, "publicKey must be a raw Ed25519 public key"),
715
708
  })
716
709
  .strict();
710
+ /**
711
+ * Issuers the platform stamps on its own external Grants. A Team-configured
712
+ * connection may not claim one: the authority reference an external audience
713
+ * resolves to is derived from (issuer, subject), and these three resolve into
714
+ * the platform's own `member:` / `claim-preview:` / owner namespaces.
715
+ */
716
+ export const RESERVED_IDENTITY_CONNECTION_ISSUERS = [
717
+ "spacefast-membership",
718
+ "claim-preview",
719
+ "spacefast-owner",
720
+ ];
721
+ const identityConnectionIssuerSchema = z
722
+ .string()
723
+ .min(1)
724
+ .max(1024)
725
+ .refine((issuer) => !RESERVED_IDENTITY_CONNECTION_ISSUERS.includes(issuer.trim()), { message: "issuer is reserved by Spacefast" });
717
726
  export const identityConnectionCreateSchema = z.discriminatedUnion("type", [
718
727
  z
719
728
  .object({
720
729
  type: z.literal("oidc"),
721
730
  name: z.string().trim().min(1).max(200),
722
- issuer: z.string().min(1).max(1024),
731
+ issuer: identityConnectionIssuerSchema,
723
732
  clientId: z.string().min(1).max(512),
724
733
  clientSecret: z.string().min(1).max(2048),
725
734
  sessionTtlSeconds: z
@@ -734,7 +743,7 @@ export const identityConnectionCreateSchema = z.discriminatedUnion("type", [
734
743
  .object({
735
744
  type: z.literal("signer"),
736
745
  name: z.string().trim().min(1).max(200),
737
- issuer: z.string().min(1).max(1024),
746
+ issuer: identityConnectionIssuerSchema,
738
747
  authorizeUrl: z.string().min(1).max(2048),
739
748
  publicKeys: z.array(identityConnectionPublicKeySchema).min(1).max(5),
740
749
  sessionTtlSeconds: z.number().int().min(60).max(EXTERNAL_IDENTITY_MAX_TTL_SECONDS).optional(),
@@ -11,6 +11,19 @@ export declare const manifestFileSchema: z.ZodObject<{
11
11
  contentType: z.ZodOptional<z.ZodString>;
12
12
  sourceUrl: z.ZodOptional<z.ZodString>;
13
13
  }, z.core.$strip>;
14
+ export declare const uploadManifestFileSchema: z.ZodUnion<readonly [z.ZodObject<{
15
+ path: z.ZodString;
16
+ size: z.ZodNumber;
17
+ contentType: z.ZodOptional<z.ZodString>;
18
+ sourceUrl: z.ZodOptional<z.ZodString>;
19
+ sha256: z.ZodString;
20
+ }, z.core.$strip>, z.ZodObject<{
21
+ path: z.ZodString;
22
+ size: z.ZodNumber;
23
+ sha256: z.ZodOptional<z.ZodString>;
24
+ contentType: z.ZodOptional<z.ZodString>;
25
+ sourceUrl: z.ZodString;
26
+ }, z.core.$strip>]>;
14
27
  export declare const pendingUploadSchema: z.ZodObject<{
15
28
  path: z.ZodString;
16
29
  size: z.ZodNumber;
@@ -84,8 +97,8 @@ export declare const uploadInstructionsSchema: z.ZodObject<{
84
97
  code: z.ZodString;
85
98
  severity: z.ZodEnum<{
86
99
  info: "info";
87
- error: "error";
88
100
  warning: "warning";
101
+ error: "error";
89
102
  }>;
90
103
  message: z.ZodString;
91
104
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -5,23 +5,33 @@ export const conventionFilesSchema = z.object({
5
5
  headers: z.string().optional(),
6
6
  routes: z.string().optional(),
7
7
  });
8
+ const manifestSha256Schema = z
9
+ .string()
10
+ .regex(/^[0-9a-f]{64}$/, "sha256 must be 64 lowercase hex characters without a prefix.")
11
+ .describe("SHA-256 content digest: exactly 64 lowercase hex characters, no `sha256:` prefix (Version.manifestHash is the only prefixed form).");
12
+ const manifestSourceUrlSchema = z
13
+ .string()
14
+ .url()
15
+ .describe("HTTPS URL the runtime can fetch directly instead of receiving local bytes.");
8
16
  export const manifestFileSchema = z.object({
9
17
  path: z
10
18
  .string()
11
19
  .describe("Version-relative POSIX path. Canonicalized at intake to UTF-8 NFC, percent-decoded exactly once; max 1,024 bytes in canonical form."),
12
20
  size: z.number().int().nonnegative().describe("File size in bytes."),
13
- sha256: z
14
- .string()
15
- .regex(/^[0-9a-f]{64}$/, "sha256 must be 64 lowercase hex characters without a prefix.")
21
+ sha256: manifestSha256Schema
16
22
  .optional()
17
- .describe("Optional SHA-256 content digest: exactly 64 lowercase hex characters, no `sha256:` prefix (Version.manifestHash is the only prefixed form). Omit it for fastest first uploads; include it on updates so unchanged files are never re-uploaded."),
23
+ .describe("SHA-256 content digest: exactly 64 lowercase hex characters, no `sha256:` prefix (Version.manifestHash is the only prefixed form). Required when the caller uploads local bytes; may be absent on historical records and sourceUrl entries."),
18
24
  contentType: z.string().optional().describe("Optional content type for serving metadata."),
19
- sourceUrl: z
20
- .string()
21
- .url()
25
+ sourceUrl: manifestSourceUrlSchema
22
26
  .optional()
23
27
  .describe("Optional HTTPS URL the runtime can fetch directly for this file instead of receiving bytes from the client."),
24
28
  });
29
+ export const uploadManifestFileSchema = z
30
+ .union([
31
+ manifestFileSchema.extend({ sha256: manifestSha256Schema }),
32
+ manifestFileSchema.extend({ sourceUrl: manifestSourceUrlSchema }),
33
+ ])
34
+ .describe("A declared upload file. Local bytes require sha256. A sourceUrl entry may omit sha256 because the runtime computes it while fetching.");
25
35
  export const pendingUploadSchema = manifestFileSchema.pick({
26
36
  path: true,
27
37
  size: true,
@@ -3,7 +3,7 @@ export declare const OAUTH_AUTHORIZATION_SERVER_PATH: "/v1/auth";
3
3
  * mcp origin (`https://mcp.<domain>`), so it has no path entry here. */
4
4
  export declare const OAUTH_API_RESOURCE_PATH: "/v1";
5
5
  export type OAuthResourceKey = "api" | "mcp";
6
- export declare const OAUTH_API_RESOURCE_SCOPES: readonly ["teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write"];
6
+ export declare const OAUTH_API_RESOURCE_SCOPES: readonly ["teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "spaces:publish", "builds:trigger"];
7
7
  export declare const OAUTH_MCP_TOOL_SCOPE: "mcp:tools";
8
8
  export declare const OAUTH_OFFLINE_ACCESS_SCOPE: "offline_access";
9
9
  export declare const OAUTH_MCP_RESOURCE_SCOPES: readonly ["mcp:tools", "teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write"];
@@ -16,6 +16,7 @@ export declare const OAUTH_MCP_RESOURCE_SCOPES: readonly ["mcp:tools", "teams:re
16
16
  * is the list of capabilities the dashboard and CLI offer per agent account.
17
17
  */
18
18
  export declare const OAUTH_MCP_RESOURCE_ALLOWED_SCOPES: readonly ["mcp:tools", "teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "offline_access"];
19
+ export declare const OAUTH_API_RESOURCE_ALLOWED_SCOPES: readonly ["teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "spaces:publish", "builds:trigger", "offline_access"];
19
20
  /**
20
21
  * Interactive MCP clients should be useful after one consent. Authorization is
21
22
  * still bounded by the user's live team role and by approval gates around
@@ -23,13 +24,13 @@ export declare const OAUTH_MCP_RESOURCE_ALLOWED_SCOPES: readonly ["mcp:tools", "
23
24
  * capabilities. Machine clients may continue to request a narrower set.
24
25
  */
25
26
  export declare const OAUTH_MCP_DEFAULT_SCOPES: readonly ["mcp:tools", "teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "offline_access"];
26
- export declare const OAUTH_PROVIDER_SCOPES: readonly ["openid", "profile", "email", "offline_access", "teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "mcp:tools"];
27
+ export declare const OAUTH_PROVIDER_SCOPES: readonly ["openid", "profile", "email", "offline_access", "teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "spaces:publish", "builds:trigger", "mcp:tools"];
27
28
  export declare const OAUTH_RESOURCE_DEFINITIONS: {
28
29
  readonly api: {
29
30
  readonly key: "api";
30
31
  readonly name: "Spacefast API";
31
32
  readonly accessTokenTtlSeconds: number;
32
- readonly allowedScopes: readonly ["teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write"];
33
+ readonly allowedScopes: readonly ["teams:read", "teams:create", "spaces:read", "spaces:write", "spaces:rename", "publish:write", "domains:read", "domains:write", "spaces:publish", "builds:trigger", "offline_access"];
33
34
  };
34
35
  readonly mcp: {
35
36
  readonly key: "mcp";
@@ -2,7 +2,7 @@ export const OAUTH_AUTHORIZATION_SERVER_PATH = "/v1/auth";
2
2
  /** The API resource is a path on the api origin; the MCP resource is the whole
3
3
  * mcp origin (`https://mcp.<domain>`), so it has no path entry here. */
4
4
  export const OAUTH_API_RESOURCE_PATH = "/v1";
5
- export const OAUTH_API_RESOURCE_SCOPES = [
5
+ const OAUTH_SHARED_API_RESOURCE_SCOPES = [
6
6
  "teams:read",
7
7
  "teams:create",
8
8
  "spaces:read",
@@ -12,11 +12,16 @@ export const OAUTH_API_RESOURCE_SCOPES = [
12
12
  "domains:read",
13
13
  "domains:write",
14
14
  ];
15
+ export const OAUTH_API_RESOURCE_SCOPES = [
16
+ ...OAUTH_SHARED_API_RESOURCE_SCOPES,
17
+ "spaces:publish",
18
+ "builds:trigger",
19
+ ];
15
20
  export const OAUTH_MCP_TOOL_SCOPE = "mcp:tools";
16
21
  export const OAUTH_OFFLINE_ACCESS_SCOPE = "offline_access";
17
22
  export const OAUTH_MCP_RESOURCE_SCOPES = [
18
23
  OAUTH_MCP_TOOL_SCOPE,
19
- ...OAUTH_API_RESOURCE_SCOPES,
24
+ ...OAUTH_SHARED_API_RESOURCE_SCOPES,
20
25
  ];
21
26
  /**
22
27
  * A resource's `allowedScopes` is intersected with the requested scopes on every
@@ -30,6 +35,10 @@ export const OAUTH_MCP_RESOURCE_ALLOWED_SCOPES = [
30
35
  ...OAUTH_MCP_RESOURCE_SCOPES,
31
36
  OAUTH_OFFLINE_ACCESS_SCOPE,
32
37
  ];
38
+ export const OAUTH_API_RESOURCE_ALLOWED_SCOPES = [
39
+ ...OAUTH_API_RESOURCE_SCOPES,
40
+ OAUTH_OFFLINE_ACCESS_SCOPE,
41
+ ];
33
42
  /**
34
43
  * Interactive MCP clients should be useful after one consent. Authorization is
35
44
  * still bounded by the user's live team role and by approval gates around
@@ -50,7 +59,7 @@ export const OAUTH_RESOURCE_DEFINITIONS = {
50
59
  key: "api",
51
60
  name: "Spacefast API",
52
61
  accessTokenTtlSeconds: 15 * 60,
53
- allowedScopes: OAUTH_API_RESOURCE_SCOPES,
62
+ allowedScopes: OAUTH_API_RESOURCE_ALLOWED_SCOPES,
54
63
  },
55
64
  mcp: {
56
65
  key: "mcp",
@@ -10,7 +10,6 @@ export declare const userOperationKindSchema: z.ZodEnum<{
10
10
  domain_transfer_submit: "domain_transfer_submit";
11
11
  domain_dns_apply: "domain_dns_apply";
12
12
  domain_lifecycle: "domain_lifecycle";
13
- variable_cascade: "variable_cascade";
14
13
  webhook_deliver: "webhook_deliver";
15
14
  integration_release: "integration_release";
16
15
  }>;
@@ -37,8 +36,8 @@ export declare const UserOperationSchema: z.ZodObject<{
37
36
  code: z.ZodString;
38
37
  severity: z.ZodEnum<{
39
38
  info: "info";
40
- error: "error";
41
39
  warning: "warning";
40
+ error: "error";
42
41
  }>;
43
42
  message: z.ZodString;
44
43
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -65,7 +64,6 @@ export declare const UserOperationSchema: z.ZodObject<{
65
64
  domain_transfer_submit: "domain_transfer_submit";
66
65
  domain_dns_apply: "domain_dns_apply";
67
66
  domain_lifecycle: "domain_lifecycle";
68
- variable_cascade: "variable_cascade";
69
67
  webhook_deliver: "webhook_deliver";
70
68
  integration_release: "integration_release";
71
69
  }>;
@@ -112,8 +110,8 @@ export declare const operationListResponseSchema: z.ZodObject<{
112
110
  code: z.ZodString;
113
111
  severity: z.ZodEnum<{
114
112
  info: "info";
115
- error: "error";
116
113
  warning: "warning";
114
+ error: "error";
117
115
  }>;
118
116
  message: z.ZodString;
119
117
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -140,7 +138,6 @@ export declare const operationListResponseSchema: z.ZodObject<{
140
138
  domain_transfer_submit: "domain_transfer_submit";
141
139
  domain_dns_apply: "domain_dns_apply";
142
140
  domain_lifecycle: "domain_lifecycle";
143
- variable_cascade: "variable_cascade";
144
141
  webhook_deliver: "webhook_deliver";
145
142
  integration_release: "integration_release";
146
143
  }>;
@@ -162,3 +159,91 @@ export declare const operationListResponseSchema: z.ZodObject<{
162
159
  hasMore: z.ZodBoolean;
163
160
  }, z.core.$strip>;
164
161
  }, z.core.$strip>;
162
+ /** Buckets an operator triages by. Live buckets partition the live population:
163
+ * a queued row is exactly one of ready / scheduled / blocked. */
164
+ export declare const SUPERADMIN_OPERATION_FILTERS: readonly ["all", "ready", "scheduled", "blocked", "running", "stuck", "retrying", "failed", "succeeded", "canceled"];
165
+ export type SuperadminOperationFilter = (typeof SUPERADMIN_OPERATION_FILTERS)[number];
166
+ export declare const superadminOperationListQuerySchema: z.ZodObject<{
167
+ filter: z.ZodDefault<z.ZodEnum<{
168
+ all: "all";
169
+ failed: "failed";
170
+ canceled: "canceled";
171
+ ready: "ready";
172
+ running: "running";
173
+ succeeded: "succeeded";
174
+ scheduled: "scheduled";
175
+ blocked: "blocked";
176
+ stuck: "stuck";
177
+ retrying: "retrying";
178
+ }>>;
179
+ eventType: z.ZodOptional<z.ZodString>;
180
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
181
+ order: z.ZodDefault<z.ZodEnum<{
182
+ newest: "newest";
183
+ oldest: "oldest";
184
+ }>>;
185
+ }, z.core.$strip>;
186
+ export type SuperadminOperationListQuery = z.infer<typeof superadminOperationListQuerySchema>;
187
+ export declare const SuperadminOperationRowSchema: z.ZodObject<{
188
+ id: z.ZodString;
189
+ eventType: z.ZodString;
190
+ status: z.ZodString;
191
+ resourceType: z.ZodString;
192
+ resourceId: z.ZodString;
193
+ attempts: z.ZodNumber;
194
+ dueAt: z.ZodNullable<z.ZodString>;
195
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
196
+ stuck: z.ZodBoolean;
197
+ blockedByOperationId: z.ZodNullable<z.ZodString>;
198
+ inflightKey: z.ZodNullable<z.ZodString>;
199
+ lastError: z.ZodNullable<z.ZodString>;
200
+ createdAt: z.ZodString;
201
+ updatedAt: z.ZodString;
202
+ finishedAt: z.ZodNullable<z.ZodString>;
203
+ }, z.core.$strip>;
204
+ export declare const SuperadminOperationListSchema: z.ZodObject<{
205
+ operations: z.ZodArray<z.ZodObject<{
206
+ id: z.ZodString;
207
+ eventType: z.ZodString;
208
+ status: z.ZodString;
209
+ resourceType: z.ZodString;
210
+ resourceId: z.ZodString;
211
+ attempts: z.ZodNumber;
212
+ dueAt: z.ZodNullable<z.ZodString>;
213
+ leaseExpiresAt: z.ZodNullable<z.ZodString>;
214
+ stuck: z.ZodBoolean;
215
+ blockedByOperationId: z.ZodNullable<z.ZodString>;
216
+ inflightKey: z.ZodNullable<z.ZodString>;
217
+ lastError: z.ZodNullable<z.ZodString>;
218
+ createdAt: z.ZodString;
219
+ updatedAt: z.ZodString;
220
+ finishedAt: z.ZodNullable<z.ZodString>;
221
+ }, z.core.$strip>>;
222
+ total: z.ZodNumber;
223
+ windowHours: z.ZodNumber;
224
+ }, z.core.$strip>;
225
+ export declare const SuperadminOperationSummarySchema: z.ZodObject<{
226
+ windowHours: z.ZodNumber;
227
+ live: z.ZodObject<{
228
+ ready: z.ZodNumber;
229
+ scheduled: z.ZodNumber;
230
+ blocked: z.ZodNumber;
231
+ running: z.ZodNumber;
232
+ stuck: z.ZodNumber;
233
+ retrying: z.ZodNumber;
234
+ }, z.core.$strip>;
235
+ recent: z.ZodObject<{
236
+ succeeded: z.ZodNumber;
237
+ failed: z.ZodNumber;
238
+ canceled: z.ZodNumber;
239
+ }, z.core.$strip>;
240
+ oldestReadyAt: z.ZodNullable<z.ZodString>;
241
+ oldestRunningAt: z.ZodNullable<z.ZodString>;
242
+ kinds: z.ZodArray<z.ZodObject<{
243
+ eventType: z.ZodString;
244
+ ready: z.ZodNumber;
245
+ running: z.ZodNumber;
246
+ stuck: z.ZodNumber;
247
+ failed: z.ZodNumber;
248
+ }, z.core.$strip>>;
249
+ }, z.core.$strip>;