@spacefast/common 0.0.21 → 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 (182) hide show
  1. package/dist/agents/connect-targets.d.ts +9 -6
  2. package/dist/agents/connect-targets.js +9 -6
  3. package/dist/config/domains.d.ts +1 -1
  4. package/dist/config/domains.js +1 -0
  5. package/dist/config/index.d.ts +0 -1
  6. package/dist/config/index.js +0 -1
  7. package/dist/contracts/abuse.d.ts +2 -0
  8. package/dist/contracts/abuse.js +12 -0
  9. package/dist/contracts/access.d.ts +121 -9
  10. package/dist/contracts/access.js +73 -9
  11. package/dist/contracts/activity.d.ts +1 -1
  12. package/dist/contracts/activity.js +0 -9
  13. package/dist/contracts/api-keys.d.ts +21 -21
  14. package/dist/contracts/beta.js +1 -1
  15. package/dist/contracts/billing.d.ts +1 -34
  16. package/dist/contracts/billing.js +4 -53
  17. package/dist/contracts/builds.d.ts +8 -8
  18. package/dist/contracts/builds.js +10 -3
  19. package/dist/contracts/cli.d.ts +10 -0
  20. package/dist/contracts/cli.js +10 -0
  21. package/dist/contracts/collab-public.d.ts +63 -0
  22. package/dist/contracts/collab-public.js +46 -0
  23. package/dist/contracts/comments.d.ts +283 -54
  24. package/dist/contracts/comments.js +173 -52
  25. package/dist/contracts/common.d.ts +3 -3
  26. package/dist/contracts/device-auth.d.ts +6 -6
  27. package/dist/contracts/device-auth.js +1 -1
  28. package/dist/contracts/docs.d.ts +5 -5
  29. package/dist/contracts/domains.d.ts +36 -36
  30. package/dist/contracts/enums.d.ts +33 -30
  31. package/dist/contracts/enums.js +52 -38
  32. package/dist/contracts/error-code-meta.d.ts +37 -126
  33. package/dist/contracts/error-code-meta.js +12 -41
  34. package/dist/contracts/error-codes.d.ts +1 -1
  35. package/dist/contracts/error-codes.js +10 -32
  36. package/dist/contracts/execution.d.ts +35 -57
  37. package/dist/contracts/execution.js +41 -40
  38. package/dist/contracts/feature-lifecycle-core.d.ts +0 -6
  39. package/dist/contracts/feature-lifecycle-core.js +2 -31
  40. package/dist/contracts/feature-lifecycle.d.ts +8 -38
  41. package/dist/contracts/feature-lifecycle.js +16 -48
  42. package/dist/contracts/features.d.ts +15 -13
  43. package/dist/contracts/features.js +39 -38
  44. package/dist/contracts/functions.d.ts +97 -70
  45. package/dist/contracts/functions.js +101 -34
  46. package/dist/contracts/git.d.ts +1 -1
  47. package/dist/contracts/grants.d.ts +7 -3
  48. package/dist/contracts/grants.js +18 -9
  49. package/dist/contracts/internal.d.ts +14 -1
  50. package/dist/contracts/internal.js +17 -7
  51. package/dist/contracts/oauth-resources.d.ts +4 -3
  52. package/dist/contracts/oauth-resources.js +12 -3
  53. package/dist/contracts/operations.d.ts +90 -5
  54. package/dist/contracts/operations.js +75 -1
  55. package/dist/contracts/pages.d.ts +6 -1
  56. package/dist/contracts/pages.js +24 -1
  57. package/dist/contracts/plan-policy.d.ts +1 -3
  58. package/dist/contracts/plan-policy.js +1 -2
  59. package/dist/contracts/platform.d.ts +61 -148
  60. package/dist/contracts/platform.js +70 -126
  61. package/dist/contracts/publish-archive.d.ts +498 -0
  62. package/dist/contracts/publish-archive.js +25 -0
  63. package/dist/contracts/resources.d.ts +12 -24
  64. package/dist/contracts/resources.js +32 -12
  65. package/dist/contracts/runtime-api.d.ts +369 -175
  66. package/dist/contracts/runtime-api.js +372 -348
  67. package/dist/contracts/runtime-app.d.ts +127 -120
  68. package/dist/contracts/runtime-app.js +19 -10
  69. package/dist/contracts/runtime-db.d.ts +1 -1
  70. package/dist/contracts/runtime-services.d.ts +219 -0
  71. package/dist/contracts/runtime-services.js +437 -0
  72. package/dist/contracts/runtime-storage.d.ts +45 -32
  73. package/dist/contracts/runtime-storage.js +30 -8
  74. package/dist/contracts/space-config.d.ts +10 -16
  75. package/dist/contracts/space-config.js +14 -10
  76. package/dist/contracts/spaces.d.ts +241 -436
  77. package/dist/contracts/spaces.js +128 -145
  78. package/dist/contracts/superadmin-activity.d.ts +57 -4
  79. package/dist/contracts/superadmin-activity.js +48 -2
  80. package/dist/contracts/superadmin-search.d.ts +126 -0
  81. package/dist/contracts/superadmin-search.js +61 -0
  82. package/dist/contracts/superadmin-spaces.d.ts +358 -89
  83. package/dist/contracts/superadmin-spaces.js +97 -24
  84. package/dist/contracts/superadmin-teams.d.ts +28 -10
  85. package/dist/contracts/superadmin-teams.js +5 -8
  86. package/dist/contracts/superadmin.d.ts +0 -32
  87. package/dist/contracts/superadmin.js +3 -11
  88. package/dist/contracts/tags.d.ts +9 -9
  89. package/dist/contracts/teams.d.ts +44 -2
  90. package/dist/contracts/teams.js +43 -23
  91. package/dist/contracts/transfers.d.ts +0 -49
  92. package/dist/contracts/transfers.js +2 -6
  93. package/dist/contracts/usage.d.ts +61 -0
  94. package/dist/contracts/usage.js +64 -0
  95. package/dist/contracts/variables.d.ts +2 -7
  96. package/dist/contracts/variables.js +6 -5
  97. package/dist/contracts/webhooks.d.ts +2 -2
  98. package/dist/contracts/zero.d.ts +87 -56
  99. package/dist/contracts/zero.js +82 -20
  100. package/dist/dashboard-paths/index.d.ts +1 -1
  101. package/dist/dashboard-paths/index.js +1 -0
  102. package/dist/docs/agent-prose.d.ts +1 -1
  103. package/dist/docs/agent-prose.js +62 -66
  104. package/dist/docs/agent-setup.js +49 -23
  105. package/dist/docs/agent-solutions.d.ts +4 -4
  106. package/dist/docs/agent-solutions.js +8 -8
  107. package/dist/docs/catalog.d.ts +19 -19
  108. package/dist/docs/catalog.js +30 -19
  109. package/dist/docs/error-docs.js +63 -151
  110. package/dist/docs/skills.d.ts +3 -3
  111. package/dist/docs/skills.js +1 -1
  112. package/dist/test-helpers/fetch-stub.d.ts +16 -0
  113. package/dist/test-helpers/fetch-stub.js +24 -0
  114. package/dist/utils/build-settings.js +9 -3
  115. package/dist/utils/canonical-json.d.ts +10 -0
  116. package/dist/utils/canonical-json.js +21 -0
  117. package/dist/utils/cast-transport.d.ts +28 -0
  118. package/dist/utils/cast-transport.js +52 -0
  119. package/dist/utils/claim-token.d.ts +0 -8
  120. package/dist/utils/claim-token.js +3 -15
  121. package/dist/utils/credential-policy.d.ts +1 -1
  122. package/dist/utils/env-file.d.ts +17 -0
  123. package/dist/utils/env-file.js +96 -0
  124. package/dist/utils/error-code.d.ts +2 -0
  125. package/dist/utils/error-code.js +7 -0
  126. package/dist/utils/generate-space-name.d.ts +8 -10
  127. package/dist/utils/generate-space-name.js +206 -21
  128. package/dist/utils/grant-decision.fixtures.json +2938 -0
  129. package/dist/utils/grants.d.ts +2 -0
  130. package/dist/utils/grants.js +25 -2
  131. package/dist/utils/gravatar.d.ts +9 -0
  132. package/dist/utils/gravatar.js +31 -0
  133. package/dist/utils/idempotency.d.ts +6 -0
  134. package/dist/utils/idempotency.js +28 -0
  135. package/dist/utils/local-space-state.d.ts +1 -5
  136. package/dist/utils/local-space-state.js +7 -26
  137. package/dist/utils/page-fonts.d.ts +2 -2
  138. package/dist/utils/page-fonts.js +22 -4
  139. package/dist/utils/pages.d.ts +1 -2
  140. package/dist/utils/pages.js +21 -5
  141. package/dist/utils/publish-form-data.d.ts +12 -0
  142. package/dist/utils/publish-form-data.js +10 -0
  143. package/dist/utils/publish-policy.d.ts +20 -0
  144. package/dist/utils/publish-policy.fixtures.json +397 -0
  145. package/dist/utils/publish-policy.js +36 -19
  146. package/dist/utils/push-new.d.ts +7 -0
  147. package/dist/utils/push-new.js +7 -0
  148. package/dist/utils/query-keys.d.ts +0 -1
  149. package/dist/utils/query-keys.js +0 -1
  150. package/dist/utils/runtime-paths.d.ts +5 -0
  151. package/dist/utils/runtime-paths.js +5 -0
  152. package/dist/utils/runtime-upload-batch.d.ts +0 -5
  153. package/dist/utils/runtime-upload-batch.js +1 -27
  154. package/dist/utils/runtime-upload.d.ts +3 -13
  155. package/dist/utils/runtime-upload.js +4 -14
  156. package/dist/utils/space-config.d.ts +0 -33
  157. package/dist/utils/space-config.js +5 -326
  158. package/dist/utils/storage-policy.d.ts +1 -1
  159. package/dist/utils/storage-policy.js +3 -1
  160. package/dist/utils/structured-error.d.ts +14 -0
  161. package/dist/utils/structured-error.js +22 -0
  162. package/dist/utils/version-path.js +12 -3
  163. package/dist/vocabulary.d.ts +5 -3
  164. package/dist/vocabulary.js +13 -10
  165. package/package.json +10 -5
  166. package/dist/config/postgres-budget.d.ts +0 -129
  167. package/dist/config/postgres-budget.js +0 -140
  168. package/dist/config/postgres-budget.json +0 -51
  169. package/dist/contracts/archives.d.ts +0 -331
  170. package/dist/contracts/archives.js +0 -120
  171. package/dist/contracts/deployments.d.ts +0 -574
  172. package/dist/contracts/deployments.js +0 -97
  173. package/dist/contracts/sites.d.ts +0 -416
  174. package/dist/contracts/sites.js +0 -168
  175. package/dist/contracts/superadmin-queues.d.ts +0 -414
  176. package/dist/contracts/superadmin-queues.js +0 -202
  177. package/dist/contracts/superadmin-runtime.d.ts +0 -27
  178. package/dist/contracts/superadmin-runtime.js +0 -38
  179. package/dist/index.d.ts +0 -1
  180. package/dist/index.js +0 -1
  181. package/dist/utils/api.d.ts +0 -4
  182. package/dist/utils/api.js +0 -13
@@ -2,137 +2,144 @@ import { z } from "zod";
2
2
  /**
3
3
  * The one answer to "what is running on this space".
4
4
  *
5
- * A space is exactly one runtime kind `versionRuntimeKind()` returns a single
6
- * value and a publish carrying both declarations is refused at finalize — so
7
- * this is a discriminated union rather than a bag of optional per-product
8
- * fields. Anything that is not an execution tier has no member here and reads
9
- * as `null`, which is the overwhelmingly common answer: a static space is not a
10
- * degenerate app, it is the absence of one.
5
+ * One published tree can carry static files, a worker and a capsule at once —
6
+ * every space owns a site, so what answers a request is a routing decision, not
7
+ * a kind the space declared. This is therefore two independent members rather
8
+ * than a discriminated union: each is `null` when the live tree carries none of
9
+ * that product, and both `null` is the overwhelmingly common answer. A static
10
+ * space is not a degenerate app, it is the absence of one.
11
+ *
12
+ * When both are present the capsule wins a path conflict — it is the one that
13
+ * owns the space's database and its transaction.
11
14
  *
12
15
  * It lives in its own module because it is the only place that needs to know
13
16
  * about both products at once. `spaces.ts` imports it to describe runtime
14
17
  * status; neither `zero.ts` nor `functions.ts` has to learn about the other.
15
18
  */
16
- export declare const runtimeAppSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
17
- runtimeKind: z.ZodLiteral<"zero">;
18
- artifactId: z.ZodString;
19
- appName: z.ZodString;
20
- serverRuntime: z.ZodLiteral<"quickjs-rust">;
21
- inspect: z.ZodObject<{
22
- policy: z.ZodEnum<{
23
- public: "public";
24
- private: "private";
25
- }>;
26
- }, z.core.$strict>;
27
- install: z.ZodObject<{
28
- runtimeKind: z.ZodLiteral<"zero">;
29
- engine: z.ZodLiteral<"quickjs-rust">;
30
- storageRoot: z.ZodLiteral<"__spacefast/zero">;
31
- artifactPath: z.ZodLiteral<"__spacefast/zero/artifact.json">;
32
- configPath: z.ZodLiteral<"__spacefast/zero/config.json">;
33
- binary: z.ZodObject<{
34
- path: z.ZodLiteral<"__spacefast/zero/bin/stattic-runtime">;
35
- compatibilityTarget: z.ZodObject<{
36
- profile: z.ZodLiteral<"wpcloud-linux-x86_64-gnu-v1">;
37
- os: z.ZodLiteral<"linux">;
38
- cpu: z.ZodLiteral<"x86_64">;
39
- libc: z.ZodLiteral<"glibc">;
40
- linking: z.ZodLiteral<"dynamic">;
41
- requireExecutableBit: z.ZodLiteral<true>;
19
+ export declare const runtimeAppSchema: z.ZodObject<{
20
+ capsule: z.ZodNullable<z.ZodObject<{
21
+ artifactId: z.ZodString;
22
+ appName: z.ZodString;
23
+ serverRuntime: z.ZodLiteral<"quickjs-rust">;
24
+ inspect: z.ZodObject<{
25
+ policy: z.ZodEnum<{
26
+ public: "public";
27
+ private: "private";
28
+ }>;
29
+ }, z.core.$strict>;
30
+ install: z.ZodObject<{
31
+ runtimeKind: z.ZodLiteral<"zero">;
32
+ engine: z.ZodLiteral<"quickjs-rust">;
33
+ storageRoot: z.ZodLiteral<"__spacefast/zero">;
34
+ artifactPath: z.ZodLiteral<"__spacefast/zero/artifact.json">;
35
+ configPath: z.ZodLiteral<"__spacefast/zero/config.json">;
36
+ binary: z.ZodObject<{
37
+ path: z.ZodLiteral<"__spacefast/zero/bin/stattic-runtime">;
38
+ compatibilityTarget: z.ZodObject<{
39
+ profile: z.ZodLiteral<"wpcloud-linux-x86_64-gnu-v1">;
40
+ os: z.ZodLiteral<"linux">;
41
+ cpu: z.ZodLiteral<"x86_64">;
42
+ libc: z.ZodLiteral<"glibc">;
43
+ linking: z.ZodLiteral<"dynamic">;
44
+ requireExecutableBit: z.ZodLiteral<true>;
45
+ }, z.core.$strict>;
46
+ sha256: z.ZodDefault<z.ZodNullable<z.ZodString>>;
47
+ required: z.ZodLiteral<true>;
48
+ }, z.core.$strict>;
49
+ mysql: z.ZodObject<{
50
+ migrateAtFinalize: z.ZodLiteral<true>;
51
+ blockIncompatibleRollback: z.ZodLiteral<true>;
52
+ }, z.core.$strict>;
53
+ realtime: z.ZodObject<{
54
+ production: z.ZodLiteral<"central">;
55
+ local: z.ZodLiteral<"foreground-cli-ws">;
42
56
  }, z.core.$strict>;
43
- sha256: z.ZodDefault<z.ZodNullable<z.ZodString>>;
44
- required: z.ZodLiteral<true>;
45
57
  }, z.core.$strict>;
46
- mysql: z.ZodObject<{
47
- migrateAtFinalize: z.ZodLiteral<true>;
48
- blockIncompatibleRollback: z.ZodLiteral<true>;
58
+ tables: z.ZodDefault<z.ZodArray<z.ZodString>>;
59
+ queries: z.ZodDefault<z.ZodArray<z.ZodString>>;
60
+ mutations: z.ZodDefault<z.ZodArray<z.ZodString>>;
61
+ actions: z.ZodDefault<z.ZodArray<z.ZodString>>;
62
+ endpoints: z.ZodDefault<z.ZodArray<z.ZodObject<{
63
+ method: z.ZodEnum<{
64
+ POST: "POST";
65
+ PUT: "PUT";
66
+ GET: "GET";
67
+ HEAD: "HEAD";
68
+ PATCH: "PATCH";
69
+ DELETE: "DELETE";
70
+ OPTIONS: "OPTIONS";
71
+ }>;
72
+ path: z.ZodString;
73
+ }, z.core.$strict>>>;
74
+ sockets: z.ZodDefault<z.ZodArray<z.ZodString>>;
75
+ migrationCount: z.ZodNumber;
76
+ schemaHash: z.ZodNullable<z.ZodString>;
77
+ variables: z.ZodObject<{
78
+ source: z.ZodLiteral<"stattic-variables">;
79
+ names: z.ZodDefault<z.ZodArray<z.ZodString>>;
49
80
  }, z.core.$strict>;
50
81
  realtime: z.ZodObject<{
51
- production: z.ZodLiteral<"central">;
52
- local: z.ZodLiteral<"foreground-cli-ws">;
82
+ mode: z.ZodEnum<{
83
+ local: "local";
84
+ cast: "cast";
85
+ central: "central";
86
+ }>;
87
+ centralUrl: z.ZodDefault<z.ZodNullable<z.ZodString>>;
88
+ path: z.ZodOptional<z.ZodString>;
89
+ replayPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
90
+ replayUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
+ runPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
92
+ runUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
+ resourceKey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
+ ticketPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
+ socketPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ spaceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
97
+ versionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
98
  }, z.core.$strict>;
54
- }, z.core.$strict>;
55
- tables: z.ZodDefault<z.ZodArray<z.ZodString>>;
56
- queries: z.ZodDefault<z.ZodArray<z.ZodString>>;
57
- mutations: z.ZodDefault<z.ZodArray<z.ZodString>>;
58
- actions: z.ZodDefault<z.ZodArray<z.ZodString>>;
59
- endpoints: z.ZodDefault<z.ZodArray<z.ZodObject<{
60
- method: z.ZodEnum<{
61
- POST: "POST";
62
- PUT: "PUT";
63
- GET: "GET";
64
- HEAD: "HEAD";
65
- PATCH: "PATCH";
66
- DELETE: "DELETE";
67
- OPTIONS: "OPTIONS";
68
- }>;
69
- path: z.ZodString;
70
- }, z.core.$strict>>>;
71
- sockets: z.ZodDefault<z.ZodArray<z.ZodString>>;
72
- migrationCount: z.ZodNumber;
73
- schemaHash: z.ZodNullable<z.ZodString>;
74
- variables: z.ZodObject<{
75
- source: z.ZodLiteral<"stattic-variables">;
76
- names: z.ZodDefault<z.ZodArray<z.ZodString>>;
77
- }, z.core.$strict>;
78
- realtime: z.ZodObject<{
79
- mode: z.ZodEnum<{
80
- local: "local";
81
- cast: "cast";
82
- central: "central";
99
+ }, z.core.$strict>>;
100
+ worker: z.ZodNullable<z.ZodObject<{
101
+ artifactId: z.ZodString;
102
+ appName: z.ZodString;
103
+ entry: z.ZodString;
104
+ compatibilityDate: z.ZodString;
105
+ compatibilityFlags: z.ZodDefault<z.ZodArray<z.ZodString>>;
106
+ routes: z.ZodDefault<z.ZodArray<z.ZodObject<{
107
+ method: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
108
+ POST: "POST";
109
+ PUT: "PUT";
110
+ GET: "GET";
111
+ HEAD: "HEAD";
112
+ PATCH: "PATCH";
113
+ DELETE: "DELETE";
114
+ OPTIONS: "OPTIONS";
115
+ }>>>;
116
+ path: z.ZodString;
117
+ subtree: z.ZodDefault<z.ZodBoolean>;
118
+ }, z.core.$strict>>>;
119
+ capabilities: z.ZodDefault<z.ZodObject<{
120
+ db: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
121
+ fetch: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
122
+ auth: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
123
+ env: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
124
+ realtime: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
125
+ logging: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
126
+ gravatar: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
127
+ spam: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
128
+ email: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
129
+ }, z.core.$strip>>;
130
+ executionState: z.ZodEnum<{
131
+ ready: "ready";
132
+ absent: "absent";
133
+ serving: "serving";
83
134
  }>;
84
- centralUrl: z.ZodDefault<z.ZodNullable<z.ZodString>>;
85
- path: z.ZodOptional<z.ZodString>;
86
- replayPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
- replayUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
88
- runPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
89
- runUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
90
- resourceKey: z.ZodOptional<z.ZodNullable<z.ZodString>>;
91
- ticketPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
92
- socketPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
- spaceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
- versionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
- }, z.core.$strict>;
96
- }, z.core.$strict>, z.ZodObject<{
97
- runtimeKind: z.ZodLiteral<"functions">;
98
- artifactId: z.ZodString;
99
- appName: z.ZodString;
100
- entry: z.ZodString;
101
- compatibilityDate: z.ZodString;
102
- compatibilityFlags: z.ZodDefault<z.ZodArray<z.ZodString>>;
103
- routes: z.ZodDefault<z.ZodArray<z.ZodObject<{
104
- method: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
105
- POST: "POST";
106
- PUT: "PUT";
107
- GET: "GET";
108
- HEAD: "HEAD";
109
- PATCH: "PATCH";
110
- DELETE: "DELETE";
111
- OPTIONS: "OPTIONS";
112
- }>>>;
113
- path: z.ZodString;
114
- subtree: z.ZodDefault<z.ZodBoolean>;
115
- }, z.core.$strict>>>;
116
- capabilities: z.ZodDefault<z.ZodObject<{
117
- db: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
118
- fetch: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
119
- auth: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
120
- env: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
121
- realtime: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
122
- logging: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
123
- }, z.core.$strip>>;
124
- executionState: z.ZodEnum<{
125
- ready: "ready";
126
- absent: "absent";
127
- serving: "serving";
128
- }>;
129
- bundleSize: z.ZodNumber;
130
- bundleSha256: z.ZodString;
131
- variables: z.ZodObject<{
132
- source: z.ZodLiteral<"spacefast-variables">;
133
- names: z.ZodDefault<z.ZodArray<z.ZodString>>;
134
- }, z.core.$strict>;
135
- }, z.core.$strict>], "runtimeKind">;
135
+ bundleSize: z.ZodNumber;
136
+ bundleSha256: z.ZodString;
137
+ variables: z.ZodObject<{
138
+ source: z.ZodLiteral<"spacefast-variables">;
139
+ names: z.ZodDefault<z.ZodArray<z.ZodString>>;
140
+ }, z.core.$strict>;
141
+ }, z.core.$strict>>;
142
+ }, z.core.$strict>;
136
143
  export type RuntimeApp = z.infer<typeof runtimeAppSchema>;
137
144
  /**
138
145
  * Replay of the invalidation events a live runtime emitted.
@@ -5,21 +5,30 @@ import { zeroAppSchema, zeroRealtimeEventSchema } from "./zero.js";
5
5
  /**
6
6
  * The one answer to "what is running on this space".
7
7
  *
8
- * A space is exactly one runtime kind `versionRuntimeKind()` returns a single
9
- * value and a publish carrying both declarations is refused at finalize — so
10
- * this is a discriminated union rather than a bag of optional per-product
11
- * fields. Anything that is not an execution tier has no member here and reads
12
- * as `null`, which is the overwhelmingly common answer: a static space is not a
13
- * degenerate app, it is the absence of one.
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.
14
+ *
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.
14
17
  *
15
18
  * It lives in its own module because it is the only place that needs to know
16
19
  * about both products at once. `spaces.ts` imports it to describe runtime
17
20
  * status; neither `zero.ts` nor `functions.ts` has to learn about the other.
18
21
  */
19
- export const runtimeAppSchema = z.discriminatedUnion("runtimeKind", [
20
- zeroAppSchema,
21
- functionsAppSchema,
22
- ]);
22
+ export const runtimeAppSchema = z
23
+ .object({
24
+ capsule: zeroAppSchema
25
+ .nullable()
26
+ .describe("The live version's Zero capsule, if it carries one."),
27
+ worker: functionsAppSchema
28
+ .nullable()
29
+ .describe("The live version's Functions worker, if it carries one."),
30
+ })
31
+ .strict();
23
32
  /**
24
33
  * Replay of the invalidation events a live runtime emitted.
25
34
  *
@@ -392,8 +392,8 @@ export declare const runtimeDbMigrateResponseSchema: z.ZodObject<{
392
392
  code: z.ZodString;
393
393
  severity: z.ZodEnum<{
394
394
  info: "info";
395
- error: "error";
396
395
  warning: "warning";
396
+ error: "error";
397
397
  }>;
398
398
  message: z.ZodString;
399
399
  path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Platform services that tenant code reaches through the runtime rather than
3
+ * through a credential of its own: Gravatar, spam checking, and mail.
4
+ *
5
+ * Three properties hold for all three, and they are the reason this file
6
+ * exists instead of three unrelated ones:
7
+ *
8
+ * - **The credential is never in tenant reach.** An Akismet key or a Gravatar
9
+ * token in a bundle is a published secret, and a wp.cloud `SMTP_PASS` in a
10
+ * capsule is worse. Every call below is brokered: the runtime attaches
11
+ * authority outside the code that asked for the call.
12
+ * - **The interface is the contract, not the accessor.** Zero hands these to a
13
+ * handler as `ctx.gravatar` / `ctx.spam` / `ctx.email`; Functions binds them
14
+ * as `env.GRAVATAR` / `env.SPAM` / `env.EMAIL`. Method names and semantic
15
+ * fields stay shared. Zero's `check` narrows the input because its HTTP host
16
+ * can add request metadata; a detached Functions call supplies that metadata
17
+ * explicitly.
18
+ * - **The client is the same source on both tiers.** See
19
+ * `RUNTIME_SERVICE_CLIENT_SOURCE`: normalization, validation and the pure
20
+ * avatar-URL construction are one implementation injected into both runtimes,
21
+ * so the two tiers cannot drift into behaving differently.
22
+ *
23
+ * What differs between tiers is the transport under `call()`, and only that.
24
+ */
25
+ /**
26
+ * What Gravatar serves when an address has no image. `404` is here so callers
27
+ * can detect absence by status instead of receiving a generated face they then
28
+ * have to recognise as a placeholder.
29
+ */
30
+ export declare const GRAVATAR_DEFAULTS: readonly ["404", "mp", "identicon", "monsterid", "wavatar", "retro", "robohash", "blank"];
31
+ export type GravatarDefault = (typeof GRAVATAR_DEFAULTS)[number];
32
+ export declare const GRAVATAR_RATINGS: readonly ["g", "pg", "r", "x"];
33
+ export type GravatarRating = (typeof GRAVATAR_RATINGS)[number];
34
+ /** Gravatar's own ceiling. Larger values are refused rather than clamped. */
35
+ export declare const GRAVATAR_AVATAR_MAX_SIZE = 2048;
36
+ export type GravatarAvatarOptions = {
37
+ /** Requested square edge in pixels, 1–2048. */
38
+ size?: number;
39
+ /** Image to serve when the address has no Gravatar. */
40
+ default?: GravatarDefault;
41
+ /** Maximum permitted self-rating. */
42
+ rating?: GravatarRating;
43
+ /** Serve `default` even when the address does have a Gravatar. */
44
+ forceDefault?: boolean;
45
+ };
46
+ export type GravatarVerifiedAccount = {
47
+ service: string;
48
+ url: string;
49
+ label: string | null;
50
+ };
51
+ /**
52
+ * The subset of the Gravatar profile that is stable, public, and useful to a
53
+ * page. Deliberately not the raw upstream document: passing that through would
54
+ * make every upstream field addition a silent contract change here.
55
+ */
56
+ export type GravatarProfile = {
57
+ hash: string;
58
+ displayName: string | null;
59
+ profileUrl: string | null;
60
+ avatarUrl: string | null;
61
+ location: string | null;
62
+ description: string | null;
63
+ pronouns: string | null;
64
+ verifiedAccounts: GravatarVerifiedAccount[];
65
+ };
66
+ export type Gravatar = {
67
+ /**
68
+ * Pure and synchronous: an avatar URL is a hash and a query string, so it
69
+ * costs no network call and cannot fail. It stays on this interface anyway
70
+ * because an author looking for an avatar looks here, not in a utility
71
+ * module.
72
+ */
73
+ avatarUrl(email: string, options?: GravatarAvatarOptions): string;
74
+ /** The profile behind an address, or null when the address has none. */
75
+ profile(email: string): Promise<GravatarProfile | null>;
76
+ };
77
+ /**
78
+ * Akismet's recognised content types. The vendor is not in the name of
79
+ * anything an author touches — `ctx.spam` outlives whichever service answers
80
+ * it — but the vocabulary is Akismet's because the classifier is trained on
81
+ * it, and inventing synonyms would only lose signal.
82
+ */
83
+ export declare const SPAM_CONTENT_TYPES: readonly ["comment", "reply", "forum-post", "contact-form", "signup", "message"];
84
+ export type SpamContentType = (typeof SPAM_CONTENT_TYPES)[number];
85
+ /**
86
+ * One complete submission, as the classifier sees it. Detached runtimes such
87
+ * as Functions use this shape; Zero uses {@link RequestSpamSubmission} while
88
+ * handling an HTTP invocation and fills the network fields itself.
89
+ *
90
+ * `userIp` and `userAgent` are the two heaviest signals Akismet uses, and
91
+ * accuracy drops sharply without them — hence `userIp` being required rather
92
+ * than another optional field an author would skip.
93
+ */
94
+ export type SpamSubmission = {
95
+ /** The text being classified. */
96
+ content: string;
97
+ /** The submitting visitor's IP. Required: without it the verdict is weak. */
98
+ userIp: string;
99
+ userAgent?: string;
100
+ referrer?: string;
101
+ /** Permalink of the page the content was submitted on. */
102
+ permalink?: string;
103
+ type?: SpamContentType;
104
+ authorName?: string;
105
+ authorEmail?: string;
106
+ authorUrl?: string;
107
+ /**
108
+ * Set to `"administrator"` for a trusted, authenticated operator of the
109
+ * space. Akismet passes that role unconditionally, so this is an author's
110
+ * own escape hatch for their own team — it grants nothing beyond skipping a
111
+ * check the author asked for.
112
+ */
113
+ authorRole?: "administrator";
114
+ /** ISO-8601 UTC. Defaults to the moment of the call. */
115
+ createdAt?: string;
116
+ /** ISO-639-1 hints, e.g. `["en"]`. */
117
+ languages?: string[];
118
+ };
119
+ /**
120
+ * A spam check made while handling a visitor request.
121
+ *
122
+ * Network evidence is deliberately absent. The runtime, not capsule code,
123
+ * supplies the visitor IP, user agent, referrer, and current URL from the
124
+ * trusted invocation envelope. This keeps a browser from claiming its own IP
125
+ * through mutation arguments or an endpoint body.
126
+ */
127
+ export type RequestSpamSubmission = Omit<SpamSubmission, "userIp" | "userAgent" | "referrer" | "permalink">;
128
+ export type SpamVerdict = {
129
+ /** Whether the submission classifies as spam. */
130
+ spam: boolean;
131
+ /**
132
+ * Blatant, pervasive spam. Akismet's own guidance is that this may be
133
+ * dropped outright rather than held for review, so it is surfaced instead of
134
+ * being folded into `spam`.
135
+ */
136
+ discard: boolean;
137
+ };
138
+ export type SpamCheck = {
139
+ check(submission: SpamSubmission): Promise<SpamVerdict>;
140
+ /** Correct a false negative: this passed, and should not have. */
141
+ reportSpam(submission: SpamSubmission): Promise<void>;
142
+ /** Correct a false positive: this was held, and should not have been. */
143
+ reportHam(submission: SpamSubmission): Promise<void>;
144
+ };
145
+ /**
146
+ * Zero's request-aware spam surface. Corrections retain the original full
147
+ * submission because they usually run later, outside the visitor request.
148
+ */
149
+ export type RequestSpamCheck = Omit<SpamCheck, "check"> & {
150
+ check(submission: RequestSpamSubmission): Promise<SpamVerdict>;
151
+ };
152
+ /** Trusted runtime metadata. This is host input, never capsule input. */
153
+ export type RuntimeSpamRequestContext = {
154
+ userIp: string;
155
+ userAgent?: string;
156
+ referrer?: string;
157
+ permalink?: string;
158
+ };
159
+ /**
160
+ * The structured subset of Cloudflare's `SendEmail` binding, field for field.
161
+ *
162
+ * Matching it is a portability decision, not an aesthetic one: a worker
163
+ * deployed straight to Cloudflare gets the native binding and the same
164
+ * message-building code has to typecheck against both.
165
+ */
166
+ export type EmailAddress = {
167
+ email: string;
168
+ name?: string;
169
+ };
170
+ export type EmailMessage = {
171
+ from: string | EmailAddress;
172
+ to: string | EmailAddress | Array<string | EmailAddress>;
173
+ subject: string;
174
+ text?: string;
175
+ html?: string;
176
+ cc?: string | EmailAddress | Array<string | EmailAddress>;
177
+ bcc?: string | EmailAddress | Array<string | EmailAddress>;
178
+ replyTo?: string | EmailAddress;
179
+ headers?: Record<string, string>;
180
+ };
181
+ export type SendEmail = {
182
+ /**
183
+ * Accepts one email effect. The identifier names the message; it is not a
184
+ * claim that anything was delivered, and no state beyond "queued" is
185
+ * observable from here — see the runtime's message views for that.
186
+ */
187
+ send(message: EmailMessage): Promise<{
188
+ messageId: string;
189
+ }>;
190
+ };
191
+ /**
192
+ * The hosts a broker may reach on a tenant's behalf are deliberately NOT listed
193
+ * here. That table lives in `stattic-runtime-core`'s egress policy, where it is
194
+ * generated into both the runtime's PHP constants and the Rust broker, so one
195
+ * declaration is enforced at both places a connection is actually made. A copy
196
+ * in this file would be a third statement of the same fact that nothing checks.
197
+ *
198
+ * The `gravatar.com` in the avatar URL below is not that table: it is a public
199
+ * URL handed to a browser, not an egress target.
200
+ */
201
+ /**
202
+ * The client both runtimes inject, as source.
203
+ *
204
+ * It is a string rather than a module because neither runtime can import from
205
+ * npm at the point it needs this: Zero compiles a capsule to QuickJS bytecode
206
+ * with a generated prelude, and the Functions host injects modules into a
207
+ * tenant isolate it does not build. Shipping one source to both is what makes
208
+ * "the same API" a fact about the code rather than a promise in a doc.
209
+ *
210
+ * It closes over nothing of ours. The host defines `call(service, operation,
211
+ * payload)` and everything else — normalization, the pure avatar URL, the
212
+ * shapes returned to tenant code — is here, identical on both tiers.
213
+ *
214
+ * The SHA-256 is hand-rolled for the same reason: QuickJS has no WebCrypto,
215
+ * and Cloudflare's `crypto.subtle` is async, which would force `avatarUrl` to
216
+ * return a promise on one tier and a string on the other. A synchronous
217
+ * implementation is the only way the signature can be identical.
218
+ */
219
+ export declare const RUNTIME_SERVICE_CLIENT_SOURCE: string;