@spacefast/common 0.0.26 → 0.2.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.
Files changed (302) hide show
  1. package/dist/agents/connect-targets.d.ts +6 -146
  2. package/dist/agents/connect-targets.js +63 -295
  3. package/dist/agents/private-key-oauth.d.ts +31 -1
  4. package/dist/agents/private-key-oauth.js +124 -33
  5. package/dist/agents/registry/core.d.ts +292 -0
  6. package/dist/agents/registry/core.js +1388 -0
  7. package/dist/agents/registry/deeplink-probes.d.ts +23 -0
  8. package/dist/agents/registry/deeplink-probes.js +18 -0
  9. package/dist/agents/registry/node.d.ts +56 -0
  10. package/dist/agents/registry/node.js +339 -0
  11. package/dist/brand-assets-build.js +1 -2
  12. package/dist/brand-assets.js +4 -7
  13. package/dist/brand.d.ts +17 -0
  14. package/dist/brand.js +24 -4
  15. package/dist/config/domains.d.ts +55 -28
  16. package/dist/config/domains.js +85 -41
  17. package/dist/config/index.js +1 -2
  18. package/dist/contracts/abuse.js +9 -24
  19. package/dist/contracts/access-profiles.d.ts +86 -0
  20. package/dist/contracts/access-profiles.js +89 -0
  21. package/dist/contracts/access.d.ts +21 -27
  22. package/dist/contracts/access.js +33 -64
  23. package/dist/contracts/activity.d.ts +18 -1
  24. package/dist/contracts/activity.js +70 -26
  25. package/dist/contracts/analytics.js +8 -10
  26. package/dist/contracts/api-keys.d.ts +77 -52
  27. package/dist/contracts/api-keys.js +44 -24
  28. package/dist/contracts/application-journal.d.ts +216 -0
  29. package/dist/contracts/application-journal.js +167 -0
  30. package/dist/contracts/auth.d.ts +90 -17
  31. package/dist/contracts/auth.js +86 -17
  32. package/dist/contracts/beta.d.ts +9 -4
  33. package/dist/contracts/beta.js +20 -16
  34. package/dist/contracts/billing.js +7 -11
  35. package/dist/contracts/bootstrap.d.ts +791 -0
  36. package/dist/contracts/bootstrap.js +51 -0
  37. package/dist/contracts/builds.d.ts +192 -7
  38. package/dist/contracts/builds.js +84 -21
  39. package/dist/contracts/channels.d.ts +43 -0
  40. package/dist/contracts/channels.js +25 -9
  41. package/dist/contracts/cli.d.ts +7 -0
  42. package/dist/contracts/cli.js +6 -0
  43. package/dist/contracts/collab-public.d.ts +1 -1
  44. package/dist/contracts/collab-public.js +5 -8
  45. package/dist/contracts/comments.d.ts +45 -35
  46. package/dist/contracts/comments.js +107 -77
  47. package/dist/contracts/commerce.d.ts +165 -0
  48. package/dist/contracts/commerce.js +146 -0
  49. package/dist/contracts/common.d.ts +3 -3
  50. package/dist/contracts/common.js +18 -29
  51. package/dist/contracts/content-contract-verification.d.ts +521 -0
  52. package/dist/contracts/content-contract-verification.js +320 -0
  53. package/dist/contracts/content-platform-fixture.d.ts +1278 -0
  54. package/dist/contracts/content-platform-fixture.js +44 -0
  55. package/dist/contracts/content-program.d.ts +994 -0
  56. package/dist/contracts/content-program.js +658 -0
  57. package/dist/contracts/content-sync.d.ts +290 -0
  58. package/dist/contracts/content-sync.js +167 -0
  59. package/dist/contracts/content.d.ts +432 -0
  60. package/dist/contracts/content.js +303 -0
  61. package/dist/contracts/continuation.d.ts +17 -1
  62. package/dist/contracts/continuation.js +23 -23
  63. package/dist/contracts/countries.js +3 -4
  64. package/dist/contracts/crons.d.ts +17 -0
  65. package/dist/contracts/crons.js +33 -15
  66. package/dist/contracts/dashboard-prefs.d.ts +56 -0
  67. package/dist/contracts/dashboard-prefs.js +51 -0
  68. package/dist/contracts/device-auth.d.ts +234 -37
  69. package/dist/contracts/device-auth.js +267 -53
  70. package/dist/contracts/docs.d.ts +6 -10
  71. package/dist/contracts/docs.js +5 -13
  72. package/dist/contracts/domains.d.ts +499 -102
  73. package/dist/contracts/domains.js +169 -58
  74. package/dist/contracts/email-preferences.d.ts +3 -3
  75. package/dist/contracts/email-preferences.js +6 -7
  76. package/dist/contracts/enums.d.ts +26 -26
  77. package/dist/contracts/enums.js +61 -54
  78. package/dist/contracts/error-code-meta.d.ts +273 -7
  79. package/dist/contracts/error-code-meta.js +81 -5
  80. package/dist/contracts/error-codes.d.ts +5 -5
  81. package/dist/contracts/error-codes.js +79 -16
  82. package/dist/contracts/events.d.ts +100 -20
  83. package/dist/contracts/events.js +107 -20
  84. package/dist/contracts/execution.d.ts +47 -66
  85. package/dist/contracts/execution.js +51 -64
  86. package/dist/contracts/feature-lifecycle.d.ts +70 -14
  87. package/dist/contracts/feature-lifecycle.js +86 -15
  88. package/dist/contracts/features.d.ts +100 -37
  89. package/dist/contracts/features.js +21 -27
  90. package/dist/contracts/fixtures/content-platform-v1.json +1108 -0
  91. package/dist/contracts/frame-session.d.ts +192 -0
  92. package/dist/contracts/frame-session.js +164 -0
  93. package/dist/contracts/functions.d.ts +218 -211
  94. package/dist/contracts/functions.js +273 -260
  95. package/dist/contracts/grant-copy.d.ts +43 -0
  96. package/dist/contracts/grant-copy.js +44 -0
  97. package/dist/contracts/grants.d.ts +64 -56
  98. package/dist/contracts/grants.js +124 -23
  99. package/dist/contracts/ids.d.ts +4 -1
  100. package/dist/contracts/ids.js +4 -1
  101. package/dist/contracts/internal.d.ts +5 -4
  102. package/dist/contracts/internal.js +12 -3
  103. package/dist/contracts/mcp.d.ts +17 -0
  104. package/dist/contracts/mcp.js +23 -0
  105. package/dist/contracts/me.d.ts +6 -1
  106. package/dist/contracts/me.js +12 -6
  107. package/dist/contracts/notifications.d.ts +27 -29
  108. package/dist/contracts/notifications.js +9 -4
  109. package/dist/contracts/oauth-resources.d.ts +121 -10
  110. package/dist/contracts/oauth-resources.js +130 -11
  111. package/dist/contracts/oauth-scope-actions.d.ts +90 -0
  112. package/dist/contracts/oauth-scope-actions.js +126 -0
  113. package/dist/contracts/operations.d.ts +27 -4
  114. package/dist/contracts/operations.js +11 -5
  115. package/dist/contracts/pages.d.ts +29 -5
  116. package/dist/contracts/pages.js +22 -5
  117. package/dist/contracts/partner-notifications.d.ts +3 -0
  118. package/dist/contracts/partner-notifications.js +65 -0
  119. package/dist/contracts/{platform.d.ts → partner.d.ts} +29 -42
  120. package/dist/contracts/{platform.js → partner.js} +27 -40
  121. package/dist/contracts/plan-policy.d.ts +1 -1
  122. package/dist/contracts/principal-assertion.d.ts +43 -0
  123. package/dist/contracts/principal-assertion.js +67 -0
  124. package/dist/contracts/principals.d.ts +73 -0
  125. package/dist/contracts/principals.js +59 -0
  126. package/dist/contracts/privacy.d.ts +11 -0
  127. package/dist/contracts/privacy.js +17 -0
  128. package/dist/contracts/problem-document.js +3 -4
  129. package/dist/contracts/publish-archive.d.ts +116 -18
  130. package/dist/contracts/publish-archive.js +6 -3
  131. package/dist/contracts/push-new.d.ts +4 -4
  132. package/dist/contracts/quotas.js +3 -3
  133. package/dist/contracts/realtime.d.ts +52 -0
  134. package/dist/contracts/realtime.js +54 -0
  135. package/dist/contracts/repository-connections.d.ts +1 -1
  136. package/dist/contracts/repository-connections.js +6 -2
  137. package/dist/contracts/resources.d.ts +105 -14
  138. package/dist/contracts/resources.js +145 -21
  139. package/dist/contracts/route-inventory.d.ts +358 -0
  140. package/dist/contracts/route-inventory.js +141 -0
  141. package/dist/contracts/runtime-api.d.ts +112 -35
  142. package/dist/contracts/runtime-api.js +86 -66
  143. package/dist/contracts/runtime-app.d.ts +11 -21
  144. package/dist/contracts/runtime-app.js +39 -24
  145. package/dist/contracts/runtime-components.d.ts +143 -0
  146. package/dist/contracts/runtime-components.js +199 -0
  147. package/dist/contracts/runtime-db.d.ts +45 -19
  148. package/dist/contracts/runtime-db.js +85 -20
  149. package/dist/contracts/runtime-purge.js +3 -5
  150. package/dist/contracts/runtime-services.d.ts +43 -75
  151. package/dist/contracts/runtime-services.js +29 -49
  152. package/dist/contracts/runtime-storage.d.ts +14 -14
  153. package/dist/contracts/runtime-storage.js +28 -13
  154. package/dist/contracts/sf-config-v1.d.ts +14 -18
  155. package/dist/contracts/slugs.js +13 -4
  156. package/dist/contracts/space-config.d.ts +235 -28
  157. package/dist/contracts/space-config.js +246 -91
  158. package/dist/contracts/spaces.d.ts +360 -255
  159. package/dist/contracts/spaces.js +190 -122
  160. package/dist/contracts/superadmin-activity.d.ts +3 -43
  161. package/dist/contracts/superadmin-activity.js +6 -30
  162. package/dist/contracts/superadmin-emails.d.ts +1 -0
  163. package/dist/contracts/superadmin-emails.js +17 -1
  164. package/dist/contracts/superadmin-runtime.d.ts +199 -0
  165. package/dist/contracts/superadmin-runtime.js +141 -0
  166. package/dist/contracts/superadmin-search.d.ts +22 -2
  167. package/dist/contracts/superadmin-search.js +14 -6
  168. package/dist/contracts/superadmin-spaces.d.ts +435 -186
  169. package/dist/contracts/superadmin-spaces.js +131 -25
  170. package/dist/contracts/superadmin-teams.d.ts +3 -0
  171. package/dist/contracts/superadmin-teams.js +1 -2
  172. package/dist/contracts/superadmin-tenants.d.ts +627 -6
  173. package/dist/contracts/superadmin-tenants.js +32 -7
  174. package/dist/contracts/superadmin.d.ts +98 -16
  175. package/dist/contracts/superadmin.js +63 -10
  176. package/dist/contracts/tags.d.ts +85 -58
  177. package/dist/contracts/tags.js +44 -34
  178. package/dist/contracts/teams.d.ts +72 -9
  179. package/dist/contracts/teams.js +84 -25
  180. package/dist/contracts/tenants.d.ts +135 -0
  181. package/dist/contracts/tenants.js +120 -0
  182. package/dist/contracts/test-triggers.d.ts +70 -0
  183. package/dist/contracts/test-triggers.js +116 -0
  184. package/dist/contracts/theme-json.js +3 -8
  185. package/dist/contracts/transfers.d.ts +1 -0
  186. package/dist/contracts/transfers.js +1 -0
  187. package/dist/contracts/usage.d.ts +209 -0
  188. package/dist/contracts/usage.js +124 -12
  189. package/dist/contracts/variables.d.ts +2 -2
  190. package/dist/contracts/variables.js +9 -13
  191. package/dist/contracts/webhooks.d.ts +13 -5
  192. package/dist/contracts/webhooks.js +3 -1
  193. package/dist/contracts/zero.d.ts +57 -64
  194. package/dist/contracts/zero.js +68 -66
  195. package/dist/dashboard-paths/index.d.ts +24 -21
  196. package/dist/dashboard-paths/index.js +35 -47
  197. package/dist/dashboard-paths/route-reservations.generated.d.ts +2 -0
  198. package/dist/dashboard-paths/route-reservations.generated.js +36 -0
  199. package/dist/docs/agent-arrival.d.ts +92 -0
  200. package/dist/docs/agent-arrival.js +227 -0
  201. package/dist/docs/agent-output-policy.d.ts +6 -0
  202. package/dist/docs/agent-output-policy.js +22 -0
  203. package/dist/docs/agent-prose.d.ts +11 -17
  204. package/dist/docs/agent-prose.js +62 -37
  205. package/dist/docs/agent-setup.d.ts +72 -41
  206. package/dist/docs/agent-setup.js +336 -436
  207. package/dist/docs/catalog.d.ts +147 -89
  208. package/dist/docs/catalog.js +157 -42
  209. package/dist/docs/error-docs.d.ts +2102 -1
  210. package/dist/docs/error-docs.js +285 -16
  211. package/dist/docs/index-build.d.ts +0 -1
  212. package/dist/docs/index-build.js +2 -3
  213. package/dist/docs/page-context-prompt.d.ts +77 -0
  214. package/dist/docs/page-context-prompt.js +131 -0
  215. package/dist/docs/reference-urls.d.ts +46 -0
  216. package/dist/docs/reference-urls.js +79 -0
  217. package/dist/docs/search.d.ts +6 -8
  218. package/dist/docs/search.js +10 -13
  219. package/dist/docs/skill-distribution.d.ts +4 -1
  220. package/dist/docs/skill-distribution.js +10 -5
  221. package/dist/docs/skills.d.ts +117 -117
  222. package/dist/docs/skills.js +120 -72
  223. package/dist/docs/start-prompts.d.ts +45 -0
  224. package/dist/docs/start-prompts.js +62 -0
  225. package/dist/domain-exploration.js +9 -13
  226. package/dist/og-template.d.ts +56 -0
  227. package/dist/og-template.js +56 -0
  228. package/dist/slug-policy/index.js +5 -11
  229. package/dist/utils/browser-credential.d.ts +13 -6
  230. package/dist/utils/browser-credential.js +14 -7
  231. package/dist/utils/build-settings.d.ts +16 -0
  232. package/dist/utils/build-settings.js +63 -17
  233. package/dist/utils/canonical-json.d.ts +3 -5
  234. package/dist/utils/canonical-json.js +3 -5
  235. package/dist/utils/cast-transport.d.ts +5 -17
  236. package/dist/utils/cast-transport.js +6 -19
  237. package/dist/utils/claim-token.js +1 -2
  238. package/dist/utils/comment-avatars.js +4 -6
  239. package/dist/utils/concurrency.js +2 -3
  240. package/dist/utils/content-type.d.ts +7 -6
  241. package/dist/utils/content-type.js +73 -51
  242. package/dist/utils/credential-policy.d.ts +50 -6
  243. package/dist/utils/credential-policy.js +123 -57
  244. package/dist/utils/egress-policy.fixtures.json +1 -1
  245. package/dist/utils/generate-space-name.d.ts +3 -8
  246. package/dist/utils/generate-space-name.js +3 -8
  247. package/dist/utils/grants.d.ts +0 -1
  248. package/dist/utils/grants.js +4 -7
  249. package/dist/utils/gravatar.d.ts +2 -4
  250. package/dist/utils/gravatar.js +6 -12
  251. package/dist/utils/id-hints.js +14 -23
  252. package/dist/utils/idempotency.d.ts +3 -3
  253. package/dist/utils/idempotency.js +6 -7
  254. package/dist/utils/local-space-state.d.ts +15 -15
  255. package/dist/utils/local-space-state.js +34 -23
  256. package/dist/utils/oauth-signed-query.d.ts +3 -5
  257. package/dist/utils/oauth-signed-query.js +6 -9
  258. package/dist/utils/one-shot-replay.d.ts +3 -5
  259. package/dist/utils/one-shot-replay.js +3 -5
  260. package/dist/utils/page-colors.d.ts +4 -10
  261. package/dist/utils/page-colors.js +11 -35
  262. package/dist/utils/page-fonts.js +6 -11
  263. package/dist/utils/page-preview.d.ts +0 -1
  264. package/dist/utils/page-preview.js +0 -1
  265. package/dist/utils/pages.d.ts +22 -11
  266. package/dist/utils/pages.js +70 -30
  267. package/dist/utils/privacy-regions.d.ts +19 -0
  268. package/dist/utils/privacy-regions.js +91 -0
  269. package/dist/utils/publish-form-data.d.ts +4 -5
  270. package/dist/utils/publish-form-data.js +2 -3
  271. package/dist/utils/publish-policy.d.ts +10 -23
  272. package/dist/utils/publish-policy.js +63 -116
  273. package/dist/utils/query-client.d.ts +2 -0
  274. package/dist/utils/query-client.js +10 -1
  275. package/dist/utils/runtime-paths.d.ts +4 -4
  276. package/dist/utils/runtime-paths.js +6 -8
  277. package/dist/utils/runtime-upload.d.ts +4 -0
  278. package/dist/utils/runtime-upload.js +5 -0
  279. package/dist/utils/secure-local-file.d.ts +3 -3
  280. package/dist/utils/secure-local-file.js +18 -24
  281. package/dist/utils/space-config.d.ts +11 -14
  282. package/dist/utils/space-config.js +10 -16
  283. package/dist/utils/static-runtime-policy.d.ts +5 -8
  284. package/dist/utils/static-runtime-policy.generated.d.ts +16 -0
  285. package/dist/utils/static-runtime-policy.generated.js +70 -0
  286. package/dist/utils/static-runtime-policy.js +17 -84
  287. package/dist/utils/storage-policy.js +1 -2
  288. package/dist/utils/upload-session.js +8 -14
  289. package/dist/utils/version-path.js +11 -19
  290. package/dist/utils/wpcom-auth-redirects.d.ts +5 -14
  291. package/dist/utils/wpcom-auth-redirects.js +1 -4
  292. package/dist/vocabulary.d.ts +7 -7
  293. package/dist/vocabulary.js +30 -16
  294. package/package.json +14 -2
  295. package/dist/agents/client-registry.d.ts +0 -22
  296. package/dist/agents/client-registry.js +0 -41
  297. package/dist/docs/agent-handoff-document.d.ts +0 -15
  298. package/dist/docs/agent-handoff-document.js +0 -180
  299. package/dist/docs/agent-solutions.d.ts +0 -110
  300. package/dist/docs/agent-solutions.js +0 -183
  301. package/dist/utils/query-keys.d.ts +0 -84
  302. package/dist/utils/query-keys.js +0 -108
@@ -3,21 +3,14 @@ import { CursorPaginationSchema } from "./common.js";
3
3
  import { functionsAppSchema } from "./functions.js";
4
4
  import { zeroAppSchema, zeroRealtimeEventSchema } from "./zero.js";
5
5
  /**
6
- * The one answer to "what is running on this space".
6
+ * What is running on this space.
7
7
  *
8
- * One published tree can carry static files, a worker and a capsule at once
9
- * every space owns a site, so what answers a request is a routing decision, not
10
- * a kind the space declared. This is therefore two independent members rather
11
- * than a discriminated union: each is `null` when the live tree carries none of
12
- * that product, and both `null` is the overwhelmingly common answer. A static
13
- * space is not a degenerate app, it is the absence of one.
8
+ * A published tree can carry a worker and a capsule at once, so these are two
9
+ * independent nullable members rather than a discriminated union. Each is
10
+ * `null` when the live tree carries none of that product.
14
11
  *
15
- * When both are present the capsule wins a path conflict it is the one that
16
- * owns the space's database and its transaction.
17
- *
18
- * It lives in its own module because it is the only place that needs to know
19
- * about both products at once. `spaces.ts` imports it to describe runtime
20
- * status; neither `zero.ts` nor `functions.ts` has to learn about the other.
12
+ * When both are present the capsule wins a path conflict: it owns the space's
13
+ * database and its transaction.
21
14
  */
22
15
  export const runtimeAppSchema = z
23
16
  .object({
@@ -29,23 +22,45 @@ export const runtimeAppSchema = z
29
22
  .describe("The live version's Functions worker, if it carries one."),
30
23
  })
31
24
  .strict();
32
- /**
33
- * Replay of the invalidation events a live runtime emitted.
34
- *
35
- * The event shape itself is Zero's — it names mutations, changed tables and
36
- * changed queries, which only a capsule has — but the route that serves it is
37
- * the runtime family's, so the page contract lives here beside the rest of the
38
- * unified surface rather than inside one product.
39
- */
25
+ /** Replay of the invalidation events a live runtime emitted, in Zero's event shape. */
40
26
  export const runtimeRealtimeEventListQuerySchema = z
41
27
  .object({
42
- afterEventId: z.string().min(1).optional(),
43
- limit: z.coerce.number().int().min(1).max(100).default(50),
28
+ afterEventId: z
29
+ .string()
30
+ .min(1)
31
+ .optional()
32
+ .describe("Walk forward from this event id, exclusive. Omit it to start at the oldest retained event; pass the previous page's `nextAfterEventId` to continue. An id that has aged out of the retention window is rejected."),
33
+ limit: z.coerce
34
+ .number()
35
+ .int()
36
+ .min(1)
37
+ .max(100)
38
+ .default(50)
39
+ .describe("Maximum events to return."),
44
40
  })
45
41
  .strict();
42
+ // Keyset, not the platform's opaque cursor: replay walks forward by event id
43
+ // and an aged-out id is a hard error, so the response names the next
44
+ // `afterEventId` rather than advertising a `pagination` envelope the request
45
+ // has no `cursor` to feed. The legacy `pagination` member below is a temporary
46
+ // back-compat exception, not the canonical shape — see its note.
46
47
  export const runtimeRealtimeEventListResponseSchema = z
47
48
  .object({
48
49
  data: z.array(zeroRealtimeEventSchema),
49
- pagination: CursorPaginationSchema,
50
+ nextAfterEventId: z
51
+ .string()
52
+ .nullable()
53
+ .describe("Event id to pass as `afterEventId` for the next page; null when this page reached the newest retained event."),
54
+ // COMPAT (temporary back-compat, effectively durable): pre-cutover Zero
55
+ // capsule clients are baked per-capsule at build time and cannot be
56
+ // rebuilt (we don't always have capsule source). Those frozen clients page
57
+ // replay by reading `pagination.nextCursor` and never look at
58
+ // `nextAfterEventId`, so the server keeps emitting this legacy envelope
59
+ // alongside the flat field. `nextCursor` carries the exact same
60
+ // continuation value as `nextAfterEventId`, and `hasMore` mirrors it.
61
+ // Remove only once no frozen pre-cutover capsules remain (which may be
62
+ // never); until then this is the sole reason the field survives the
63
+ // cutover.
64
+ pagination: CursorPaginationSchema.describe("Legacy pagination envelope kept only for frozen pre-cutover Zero capsule clients that page by `pagination.nextCursor`. New clients read `nextAfterEventId`; `nextCursor` mirrors it exactly."),
50
65
  })
51
66
  .strict();
@@ -0,0 +1,143 @@
1
+ import { z } from "zod";
2
+ export declare const runtimeCapabilityIdSchema: z.core.$ZodBranded<z.ZodString, "RuntimeCapabilityId", "out">;
3
+ export declare const runtimeComponentIdSchema: z.core.$ZodBranded<z.ZodString, "RuntimeComponentId", "out">;
4
+ export type RuntimeCapabilityId = z.infer<typeof runtimeCapabilityIdSchema>;
5
+ export type RuntimeComponentId = z.infer<typeof runtimeComponentIdSchema>;
6
+ export declare const RUNTIME_COMPONENT_V1_REQUIRED_IDS: readonly ["wordpress-core", "runtime-engine", "immutable-loader", "content-kernel", "managed-theme", "secure-custom-fields", "redirection", "block-transformer", "quickjs-abi"];
7
+ export declare const RUNTIME_COMPONENT_KINDS: readonly ["wordpress-core", "runtime-engine", "mu-plugin", "plugin", "theme", "block-transformer", "quickjs-abi"];
8
+ export declare const runtimeComponentKindSchema: z.ZodEnum<{
9
+ plugin: "plugin";
10
+ theme: "theme";
11
+ "wordpress-core": "wordpress-core";
12
+ "runtime-engine": "runtime-engine";
13
+ "block-transformer": "block-transformer";
14
+ "quickjs-abi": "quickjs-abi";
15
+ "mu-plugin": "mu-plugin";
16
+ }>;
17
+ export type RuntimeComponentKind = z.infer<typeof runtimeComponentKindSchema>;
18
+ export declare const runtimeComponentV1Schema: z.ZodObject<{
19
+ id: z.core.$ZodBranded<z.ZodString, "RuntimeComponentId", "out">;
20
+ kind: z.ZodEnum<{
21
+ plugin: "plugin";
22
+ theme: "theme";
23
+ "wordpress-core": "wordpress-core";
24
+ "runtime-engine": "runtime-engine";
25
+ "block-transformer": "block-transformer";
26
+ "quickjs-abi": "quickjs-abi";
27
+ "mu-plugin": "mu-plugin";
28
+ }>;
29
+ version: z.ZodString;
30
+ sha256: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
31
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
+ kind: z.ZodLiteral<"archive">;
33
+ url: z.ZodString;
34
+ bytes: z.ZodNumber;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ kind: z.ZodLiteral<"embedded">;
37
+ path: z.ZodString;
38
+ }, z.core.$strict>], "kind">;
39
+ provides: z.ZodArray<z.core.$ZodBranded<z.ZodString, "RuntimeCapabilityId", "out">>;
40
+ activation: z.ZodEnum<{
41
+ always: "always";
42
+ "on-demand": "on-demand";
43
+ }>;
44
+ }, z.core.$strict>;
45
+ export type RuntimeComponentV1 = z.infer<typeof runtimeComponentV1Schema>;
46
+ export declare const runtimeComponentInventoryV1Schema: z.ZodObject<{
47
+ format: z.ZodLiteral<"spacefast.wordpress-components">;
48
+ version: z.ZodLiteral<1>;
49
+ platformRelease: z.ZodString;
50
+ digest: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
51
+ components: z.ZodArray<z.ZodObject<{
52
+ id: z.core.$ZodBranded<z.ZodString, "RuntimeComponentId", "out">;
53
+ kind: z.ZodEnum<{
54
+ plugin: "plugin";
55
+ theme: "theme";
56
+ "wordpress-core": "wordpress-core";
57
+ "runtime-engine": "runtime-engine";
58
+ "block-transformer": "block-transformer";
59
+ "quickjs-abi": "quickjs-abi";
60
+ "mu-plugin": "mu-plugin";
61
+ }>;
62
+ version: z.ZodString;
63
+ sha256: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
64
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
+ kind: z.ZodLiteral<"archive">;
66
+ url: z.ZodString;
67
+ bytes: z.ZodNumber;
68
+ }, z.core.$strict>, z.ZodObject<{
69
+ kind: z.ZodLiteral<"embedded">;
70
+ path: z.ZodString;
71
+ }, z.core.$strict>], "kind">;
72
+ provides: z.ZodArray<z.core.$ZodBranded<z.ZodString, "RuntimeCapabilityId", "out">>;
73
+ activation: z.ZodEnum<{
74
+ always: "always";
75
+ "on-demand": "on-demand";
76
+ }>;
77
+ }, z.core.$strict>>;
78
+ }, z.core.$strict>;
79
+ export type RuntimeComponentInventoryV1 = z.infer<typeof runtimeComponentInventoryV1Schema>;
80
+ export declare const programRequirementsV1Schema: z.ZodObject<{
81
+ format: z.ZodLiteral<"spacefast.program-requirements">;
82
+ version: z.ZodLiteral<1>;
83
+ inputDigest: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
84
+ wordpressAbi: z.ZodLiteral<1>;
85
+ capabilities: z.ZodArray<z.core.$ZodBranded<z.ZodString, "RuntimeCapabilityId", "out">>;
86
+ }, z.core.$strict>;
87
+ export type ProgramRequirementsV1 = z.infer<typeof programRequirementsV1Schema>;
88
+ export declare const runtimeComponentPlacementTargetV1Schema: z.ZodObject<{
89
+ spaceId: z.ZodTemplateLiteral<`spc_${string}`>;
90
+ runtimeInstanceId: z.ZodString;
91
+ siteId: z.ZodString;
92
+ }, z.core.$strict>;
93
+ export type RuntimeComponentPlacementTargetV1 = z.infer<typeof runtimeComponentPlacementTargetV1Schema>;
94
+ export declare const runtimeComponentPlacementReceiptV1Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
95
+ status: z.ZodLiteral<"ready">;
96
+ observedInventoryDigest: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
97
+ substrate: z.ZodObject<{
98
+ wordpress: z.ZodObject<{
99
+ boot: z.ZodLiteral<"ready">;
100
+ database: z.ZodLiteral<"ready">;
101
+ tables: z.ZodLiteral<"ready">;
102
+ }, z.core.$strict>;
103
+ routing: z.ZodObject<{
104
+ state: z.ZodLiteral<"ready">;
105
+ snapshotRevision: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
106
+ inventoryDigest: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
107
+ }, z.core.$strict>;
108
+ mail: z.ZodObject<{
109
+ state: z.ZodLiteral<"ready">;
110
+ }, z.core.$strict>;
111
+ journal: z.ZodObject<{
112
+ state: z.ZodLiteral<"ready">;
113
+ }, z.core.$strict>;
114
+ }, z.core.$strict>;
115
+ format: z.ZodLiteral<"spacefast.component-placement">;
116
+ version: z.ZodLiteral<1>;
117
+ operationId: z.ZodString;
118
+ target: z.ZodObject<{
119
+ spaceId: z.ZodTemplateLiteral<`spc_${string}`>;
120
+ runtimeInstanceId: z.ZodString;
121
+ siteId: z.ZodString;
122
+ }, z.core.$strict>;
123
+ platformRelease: z.ZodString;
124
+ expectedInventoryDigest: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
125
+ }, z.core.$strict>, z.ZodObject<{
126
+ status: z.ZodLiteral<"blocked">;
127
+ problems: z.ZodArray<z.ZodObject<{
128
+ componentId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "RuntimeComponentId", "out">>;
129
+ code: z.ZodString;
130
+ detail: z.ZodString;
131
+ }, z.core.$strict>>;
132
+ format: z.ZodLiteral<"spacefast.component-placement">;
133
+ version: z.ZodLiteral<1>;
134
+ operationId: z.ZodString;
135
+ target: z.ZodObject<{
136
+ spaceId: z.ZodTemplateLiteral<`spc_${string}`>;
137
+ runtimeInstanceId: z.ZodString;
138
+ siteId: z.ZodString;
139
+ }, z.core.$strict>;
140
+ platformRelease: z.ZodString;
141
+ expectedInventoryDigest: z.core.$ZodBranded<z.ZodString, "ContentProgramSha256", "out">;
142
+ }, z.core.$strict>], "status">;
143
+ export type RuntimeComponentPlacementReceiptV1 = z.infer<typeof runtimeComponentPlacementReceiptV1Schema>;
@@ -0,0 +1,199 @@
1
+ import { z } from "zod";
2
+ import { contentProgramSha256Schema } from "./content-program.js";
3
+ import { registeredIdSchema } from "./ids.js";
4
+ export const runtimeCapabilityIdSchema = z
5
+ .string()
6
+ .min(1)
7
+ .max(160)
8
+ .regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/)
9
+ .brand();
10
+ export const runtimeComponentIdSchema = z
11
+ .string()
12
+ .min(1)
13
+ .max(160)
14
+ .regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/)
15
+ .brand();
16
+ export const RUNTIME_COMPONENT_V1_REQUIRED_IDS = [
17
+ "wordpress-core",
18
+ "runtime-engine",
19
+ "immutable-loader",
20
+ "content-kernel",
21
+ "managed-theme",
22
+ "secure-custom-fields",
23
+ "redirection",
24
+ "block-transformer",
25
+ "quickjs-abi",
26
+ ];
27
+ export const RUNTIME_COMPONENT_KINDS = [
28
+ "wordpress-core",
29
+ "runtime-engine",
30
+ "mu-plugin",
31
+ "plugin",
32
+ "theme",
33
+ "block-transformer",
34
+ "quickjs-abi",
35
+ ];
36
+ export const runtimeComponentKindSchema = z.enum(RUNTIME_COMPONENT_KINDS);
37
+ const runtimeComponentV1RequiredKinds = {
38
+ "wordpress-core": "wordpress-core",
39
+ "runtime-engine": "runtime-engine",
40
+ "immutable-loader": "mu-plugin",
41
+ "content-kernel": "mu-plugin",
42
+ "managed-theme": "theme",
43
+ "secure-custom-fields": "plugin",
44
+ redirection: "plugin",
45
+ "block-transformer": "block-transformer",
46
+ "quickjs-abi": "quickjs-abi",
47
+ };
48
+ const runtimeComponentSourceSchema = z.discriminatedUnion("kind", [
49
+ z
50
+ .object({
51
+ kind: z.literal("archive"),
52
+ url: z.string().url(),
53
+ bytes: z.number().int().positive(),
54
+ })
55
+ .strict(),
56
+ z
57
+ .object({
58
+ kind: z.literal("embedded"),
59
+ path: z
60
+ .string()
61
+ .min(1)
62
+ .max(512)
63
+ .refine((path) => !path.startsWith("/") && !path.split("/").includes(".."), {
64
+ message: "embedded component paths must be relative and cannot traverse",
65
+ }),
66
+ })
67
+ .strict(),
68
+ ]);
69
+ export const runtimeComponentV1Schema = z
70
+ .object({
71
+ id: runtimeComponentIdSchema,
72
+ kind: runtimeComponentKindSchema,
73
+ version: z.string().min(1).max(160),
74
+ sha256: contentProgramSha256Schema,
75
+ source: runtimeComponentSourceSchema,
76
+ provides: z.array(runtimeCapabilityIdSchema).max(100),
77
+ activation: z.enum(["always", "on-demand"]),
78
+ })
79
+ .strict()
80
+ .refine((component) => new Set(component.provides).size === component.provides.length, {
81
+ path: ["provides"],
82
+ message: "provided capabilities must be unique",
83
+ });
84
+ export const runtimeComponentInventoryV1Schema = z
85
+ .object({
86
+ format: z.literal("spacefast.wordpress-components"),
87
+ version: z.literal(1),
88
+ platformRelease: z.string().min(1).max(160),
89
+ digest: contentProgramSha256Schema,
90
+ components: z.array(runtimeComponentV1Schema).min(1).max(100),
91
+ })
92
+ .strict()
93
+ .superRefine((inventory, context) => {
94
+ const ids = inventory.components.map((component) => component.id);
95
+ if (new Set(ids).size !== ids.length) {
96
+ context.addIssue({
97
+ code: "custom",
98
+ path: ["components"],
99
+ message: "component ids must be unique",
100
+ });
101
+ }
102
+ for (const required of RUNTIME_COMPONENT_V1_REQUIRED_IDS) {
103
+ const matching = inventory.components.filter((component) => component.id === required);
104
+ if (matching.length !== 1) {
105
+ context.addIssue({
106
+ code: "custom",
107
+ path: ["components"],
108
+ message: `component inventory requires exactly one ${required} component`,
109
+ });
110
+ }
111
+ else if (matching[0]?.kind !== runtimeComponentV1RequiredKinds[required]) {
112
+ context.addIssue({
113
+ code: "custom",
114
+ path: ["components"],
115
+ message: `${required} must use component kind ${runtimeComponentV1RequiredKinds[required]}`,
116
+ });
117
+ }
118
+ }
119
+ });
120
+ export const programRequirementsV1Schema = z
121
+ .object({
122
+ format: z.literal("spacefast.program-requirements"),
123
+ version: z.literal(1),
124
+ inputDigest: contentProgramSha256Schema,
125
+ wordpressAbi: z.literal(1),
126
+ capabilities: z.array(runtimeCapabilityIdSchema).max(100),
127
+ })
128
+ .strict()
129
+ .refine((requirements) => new Set(requirements.capabilities).size === requirements.capabilities.length, {
130
+ path: ["capabilities"],
131
+ message: "program capabilities must be unique",
132
+ });
133
+ export const runtimeComponentPlacementTargetV1Schema = z
134
+ .object({
135
+ spaceId: registeredIdSchema("spc"),
136
+ runtimeInstanceId: z.string().min(1).max(255),
137
+ siteId: z.string().min(1).max(255),
138
+ })
139
+ .strict();
140
+ const runtimeComponentPlacementReceiptFields = {
141
+ format: z.literal("spacefast.component-placement"),
142
+ version: z.literal(1),
143
+ operationId: z.string().min(1).max(160),
144
+ target: runtimeComponentPlacementTargetV1Schema,
145
+ platformRelease: z.string().min(1).max(160),
146
+ expectedInventoryDigest: contentProgramSha256Schema,
147
+ };
148
+ const readyPlacementSubstrateV1Schema = z
149
+ .object({
150
+ wordpress: z
151
+ .object({
152
+ boot: z.literal("ready"),
153
+ database: z.literal("ready"),
154
+ tables: z.literal("ready"),
155
+ })
156
+ .strict(),
157
+ routing: z
158
+ .object({
159
+ state: z.literal("ready"),
160
+ snapshotRevision: contentProgramSha256Schema,
161
+ inventoryDigest: contentProgramSha256Schema,
162
+ })
163
+ .strict(),
164
+ mail: z.object({ state: z.literal("ready") }).strict(),
165
+ journal: z.object({ state: z.literal("ready") }).strict(),
166
+ })
167
+ .strict();
168
+ export const runtimeComponentPlacementReceiptV1Schema = z
169
+ .discriminatedUnion("status", [
170
+ z
171
+ .object({
172
+ ...runtimeComponentPlacementReceiptFields,
173
+ status: z.literal("ready"),
174
+ observedInventoryDigest: contentProgramSha256Schema,
175
+ substrate: readyPlacementSubstrateV1Schema,
176
+ })
177
+ .strict(),
178
+ z
179
+ .object({
180
+ ...runtimeComponentPlacementReceiptFields,
181
+ status: z.literal("blocked"),
182
+ problems: z
183
+ .array(z
184
+ .object({
185
+ componentId: runtimeComponentIdSchema.optional(),
186
+ code: z.string().min(1).max(160),
187
+ detail: z.string().min(1).max(2_000),
188
+ })
189
+ .strict())
190
+ .min(1)
191
+ .max(100),
192
+ })
193
+ .strict(),
194
+ ])
195
+ .refine((receipt) => receipt.status !== "ready" ||
196
+ receipt.observedInventoryDigest === receipt.expectedInventoryDigest, {
197
+ path: ["observedInventoryDigest"],
198
+ message: "a ready receipt must observe the expected inventory digest",
199
+ });
@@ -2,18 +2,29 @@ import { z } from "zod";
2
2
  /**
3
3
  * The database surface, for whichever runtime a space is carrying.
4
4
  *
5
- * There is one database per space the site's own MySQL and at most one
6
- * runtime with a claim on it, so these contracts are runtime-neutral by
7
- * default. The two exceptions are stated explicitly: a migration plan is a
8
- * capsule's declaration and no worker has one, and the console hand-off is a
9
- * property of the wp.cloud site rather than of anything a version declared.
5
+ * One database per space, the site's own MySQL, and at most one runtime with a
6
+ * claim on it, so these contracts are runtime-neutral. Two exceptions: a
7
+ * migration plan is a capsule's declaration and no worker has one, and the
8
+ * console hand-off is a property of the wp.cloud site.
10
9
  *
11
- * The reads answer in the capsule's declaration shapes (`zeroTableSchema`,
12
- * `zeroMigrationOperationSchema`) because a capsule's declared schema is the
13
- * richest answer either runtime can give and a worker's is the same answer with
14
- * the declaration-shaped fields empty. Those shapes stay Zero-named and stay in
15
- * `./zero.js`: a declared table is the capsule's own statement about itself.
10
+ * Reads answer in the capsule's declaration shapes (`zeroTableSchema`,
11
+ * `zeroMigrationOperationSchema`); a worker's answer is the same shape with the
12
+ * declaration-shaped fields empty.
16
13
  */
14
+ /**
15
+ * Whether the live version's declared migration plan has actually run against
16
+ * the space database. `applied` compares the recorded application against the
17
+ * plan's target `schemaHash`; it is `null` when no application record exists —
18
+ * a version finalized before this record existed, or a finalize whose ready
19
+ * receipt was a replay — because the control plane then cannot prove the plan
20
+ * ran. Honest unknown, never a guess.
21
+ */
22
+ export declare const runtimeDbPlanStateSchema: z.ZodObject<{
23
+ applied: z.ZodNullable<z.ZodBoolean>;
24
+ appliedSchemaHash: z.ZodNullable<z.ZodString>;
25
+ pendingOperationCount: z.ZodNumber;
26
+ }, z.core.$strict>;
27
+ export type RuntimeDbPlanState = z.infer<typeof runtimeDbPlanStateSchema>;
17
28
  export declare const runtimeDbInspectResponseSchema: z.ZodObject<{
18
29
  versionId: z.ZodNullable<z.ZodString>;
19
30
  artifactId: z.ZodNullable<z.ZodString>;
@@ -91,6 +102,11 @@ export declare const runtimeDbInspectResponseSchema: z.ZodObject<{
91
102
  to: z.ZodString;
92
103
  explicit: z.ZodLiteral<"rename">;
93
104
  }, z.core.$strict>], "op">>>;
105
+ plan: z.ZodNullable<z.ZodObject<{
106
+ applied: z.ZodNullable<z.ZodBoolean>;
107
+ appliedSchemaHash: z.ZodNullable<z.ZodString>;
108
+ pendingOperationCount: z.ZodNumber;
109
+ }, z.core.$strict>>;
94
110
  }, z.core.$strict>;
95
111
  export type RuntimeDbInspectResponse = z.infer<typeof runtimeDbInspectResponseSchema>;
96
112
  export declare const runtimeDbInspectPublicResponseSchema: z.ZodObject<{
@@ -171,15 +187,24 @@ export declare const runtimeDbInspectPublicResponseSchema: z.ZodObject<{
171
187
  to: z.ZodString;
172
188
  explicit: z.ZodLiteral<"rename">;
173
189
  }, z.core.$strict>], "op">>>;
190
+ plan: z.ZodNullable<z.ZodObject<{
191
+ applied: z.ZodNullable<z.ZodBoolean>;
192
+ appliedSchemaHash: z.ZodNullable<z.ZodString>;
193
+ pendingOperationCount: z.ZodNumber;
194
+ }, z.core.$strict>>;
174
195
  }, z.core.$strict>;
175
196
  }, z.core.$strip>;
176
197
  export declare const runtimeDbDumpQuerySchema: z.ZodObject<{
177
198
  table: z.ZodOptional<z.ZodString>;
178
199
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
179
200
  }, z.core.$strict>;
201
+ export type RuntimeDbCellValue = string | number | boolean | null | RuntimeDbCellValue[] | {
202
+ [key: string]: RuntimeDbCellValue;
203
+ };
204
+ export declare const runtimeDbCellValueSchema: z.ZodType<RuntimeDbCellValue>;
180
205
  export declare const runtimeDbDumpTableSchema: z.ZodObject<{
181
206
  name: z.ZodString;
182
- rows: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
207
+ rows: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodType<RuntimeDbCellValue, unknown, z.core.$ZodTypeInternals<RuntimeDbCellValue, unknown>>>>>;
183
208
  }, z.core.$strict>;
184
209
  export declare const runtimeDbDumpResponseSchema: z.ZodObject<{
185
210
  versionId: z.ZodNullable<z.ZodString>;
@@ -187,7 +212,7 @@ export declare const runtimeDbDumpResponseSchema: z.ZodObject<{
187
212
  schemaHash: z.ZodNullable<z.ZodString>;
188
213
  tables: z.ZodDefault<z.ZodArray<z.ZodObject<{
189
214
  name: z.ZodString;
190
- rows: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
215
+ rows: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodType<RuntimeDbCellValue, unknown, z.core.$ZodTypeInternals<RuntimeDbCellValue, unknown>>>>>;
191
216
  }, z.core.$strict>>>;
192
217
  }, z.core.$strict>;
193
218
  export type RuntimeDbDumpResponse = z.infer<typeof runtimeDbDumpResponseSchema>;
@@ -198,7 +223,7 @@ export declare const runtimeDbDumpPublicResponseSchema: z.ZodObject<{
198
223
  schemaHash: z.ZodNullable<z.ZodString>;
199
224
  tables: z.ZodDefault<z.ZodArray<z.ZodObject<{
200
225
  name: z.ZodString;
201
- rows: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
226
+ rows: z.ZodDefault<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>>;
202
227
  }, z.core.$strict>>>;
203
228
  }, z.core.$strict>;
204
229
  }, z.core.$strip>;
@@ -237,15 +262,16 @@ export declare const runtimeDbExportPageQuerySchema: z.ZodObject<{
237
262
  limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
238
263
  }, z.core.$strict>;
239
264
  export declare const runtimeDbExportPageSchema: z.ZodObject<{
240
- rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
265
+ rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodType<RuntimeDbCellValue, unknown, z.core.$ZodTypeInternals<RuntimeDbCellValue, unknown>>>>;
241
266
  cursor: z.ZodNullable<z.ZodString>;
242
267
  }, z.core.$strict>;
243
268
  export type RuntimeDbExportPage = z.infer<typeof runtimeDbExportPageSchema>;
244
269
  export declare const runtimeDbExportPagePublicResponseSchema: z.ZodObject<{
245
- data: z.ZodObject<{
246
- rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
247
- cursor: z.ZodNullable<z.ZodString>;
248
- }, z.core.$strict>;
270
+ data: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull, z.ZodArray<z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>>;
271
+ pagination: z.ZodObject<{
272
+ nextCursor: z.ZodNullable<z.ZodString>;
273
+ hasMore: z.ZodBoolean;
274
+ }, z.core.$strip>;
249
275
  }, z.core.$strip>;
250
276
  export declare const runtimeDbMigrateResultSchema: z.ZodObject<{
251
277
  versionId: z.ZodString;
@@ -392,8 +418,8 @@ export declare const runtimeDbMigrateResponseSchema: z.ZodObject<{
392
418
  code: z.ZodString;
393
419
  severity: z.ZodEnum<{
394
420
  info: "info";
395
- error: "error";
396
421
  warning: "warning";
422
+ error: "error";
397
423
  }>;
398
424
  message: z.ZodString;
399
425
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;