@spacefast/common 0.0.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 (202) hide show
  1. package/README.md +42 -0
  2. package/dist/brand.d.ts +15 -0
  3. package/dist/brand.js +24 -0
  4. package/dist/config/domains.d.ts +30 -0
  5. package/dist/config/domains.js +75 -0
  6. package/dist/config/index.d.ts +1 -0
  7. package/dist/config/index.js +3 -0
  8. package/dist/contracts/abuse.d.ts +93 -0
  9. package/dist/contracts/abuse.js +50 -0
  10. package/dist/contracts/access.d.ts +409 -0
  11. package/dist/contracts/access.js +396 -0
  12. package/dist/contracts/account.d.ts +28 -0
  13. package/dist/contracts/account.js +54 -0
  14. package/dist/contracts/activity.d.ts +118 -0
  15. package/dist/contracts/activity.js +180 -0
  16. package/dist/contracts/analytics.d.ts +56 -0
  17. package/dist/contracts/analytics.js +91 -0
  18. package/dist/contracts/annotations.d.ts +327 -0
  19. package/dist/contracts/annotations.js +234 -0
  20. package/dist/contracts/api-keys.d.ts +517 -0
  21. package/dist/contracts/api-keys.js +235 -0
  22. package/dist/contracts/archives.d.ts +332 -0
  23. package/dist/contracts/archives.js +120 -0
  24. package/dist/contracts/auth.d.ts +86 -0
  25. package/dist/contracts/auth.js +82 -0
  26. package/dist/contracts/beta.d.ts +106 -0
  27. package/dist/contracts/beta.js +104 -0
  28. package/dist/contracts/billing.d.ts +328 -0
  29. package/dist/contracts/billing.js +203 -0
  30. package/dist/contracts/builds.d.ts +504 -0
  31. package/dist/contracts/builds.js +248 -0
  32. package/dist/contracts/channels.d.ts +49 -0
  33. package/dist/contracts/channels.js +51 -0
  34. package/dist/contracts/common.d.ts +238 -0
  35. package/dist/contracts/common.js +175 -0
  36. package/dist/contracts/deployments.d.ts +574 -0
  37. package/dist/contracts/deployments.js +97 -0
  38. package/dist/contracts/device-auth.d.ts +194 -0
  39. package/dist/contracts/device-auth.js +162 -0
  40. package/dist/contracts/domains.d.ts +6115 -0
  41. package/dist/contracts/domains.js +1435 -0
  42. package/dist/contracts/enums.d.ts +196 -0
  43. package/dist/contracts/enums.js +211 -0
  44. package/dist/contracts/error-code-meta.d.ts +1560 -0
  45. package/dist/contracts/error-code-meta.js +400 -0
  46. package/dist/contracts/error-codes.d.ts +13 -0
  47. package/dist/contracts/error-codes.js +416 -0
  48. package/dist/contracts/events.d.ts +398 -0
  49. package/dist/contracts/events.js +320 -0
  50. package/dist/contracts/fast-domain-search.d.ts +19 -0
  51. package/dist/contracts/fast-domain-search.js +22 -0
  52. package/dist/contracts/features.d.ts +240 -0
  53. package/dist/contracts/features.js +406 -0
  54. package/dist/contracts/git.d.ts +288 -0
  55. package/dist/contracts/git.js +116 -0
  56. package/dist/contracts/ids.d.ts +35 -0
  57. package/dist/contracts/ids.js +45 -0
  58. package/dist/contracts/intercom.d.ts +6 -0
  59. package/dist/contracts/intercom.js +5 -0
  60. package/dist/contracts/internal.d.ts +103 -0
  61. package/dist/contracts/internal.js +92 -0
  62. package/dist/contracts/mcp.d.ts +788 -0
  63. package/dist/contracts/mcp.js +161 -0
  64. package/dist/contracts/me.d.ts +81 -0
  65. package/dist/contracts/me.js +104 -0
  66. package/dist/contracts/oauth-resources.d.ts +30 -0
  67. package/dist/contracts/oauth-resources.js +61 -0
  68. package/dist/contracts/operations.d.ts +54 -0
  69. package/dist/contracts/operations.js +14 -0
  70. package/dist/contracts/plan-policy.d.ts +85 -0
  71. package/dist/contracts/plan-policy.js +75 -0
  72. package/dist/contracts/platform.d.ts +359 -0
  73. package/dist/contracts/platform.js +216 -0
  74. package/dist/contracts/push-new.d.ts +156 -0
  75. package/dist/contracts/push-new.js +52 -0
  76. package/dist/contracts/quotas.d.ts +16 -0
  77. package/dist/contracts/quotas.js +36 -0
  78. package/dist/contracts/repository-connections.d.ts +231 -0
  79. package/dist/contracts/repository-connections.js +106 -0
  80. package/dist/contracts/resources.d.ts +529 -0
  81. package/dist/contracts/resources.js +209 -0
  82. package/dist/contracts/routes.d.ts +45 -0
  83. package/dist/contracts/routes.js +31 -0
  84. package/dist/contracts/runtime-api.d.ts +449 -0
  85. package/dist/contracts/runtime-api.js +513 -0
  86. package/dist/contracts/sites.d.ts +393 -0
  87. package/dist/contracts/sites.js +121 -0
  88. package/dist/contracts/slugs.d.ts +31 -0
  89. package/dist/contracts/slugs.js +47 -0
  90. package/dist/contracts/space-config.d.ts +216 -0
  91. package/dist/contracts/space-config.js +237 -0
  92. package/dist/contracts/space-theme.d.ts +25 -0
  93. package/dist/contracts/space-theme.js +49 -0
  94. package/dist/contracts/spaces.d.ts +2760 -0
  95. package/dist/contracts/spaces.js +589 -0
  96. package/dist/contracts/superadmin-activity.d.ts +205 -0
  97. package/dist/contracts/superadmin-activity.js +107 -0
  98. package/dist/contracts/superadmin-emails.d.ts +212 -0
  99. package/dist/contracts/superadmin-emails.js +112 -0
  100. package/dist/contracts/superadmin-queues.d.ts +414 -0
  101. package/dist/contracts/superadmin-queues.js +202 -0
  102. package/dist/contracts/superadmin-runtime.d.ts +27 -0
  103. package/dist/contracts/superadmin-runtime.js +38 -0
  104. package/dist/contracts/superadmin-spaces.d.ts +429 -0
  105. package/dist/contracts/superadmin-spaces.js +82 -0
  106. package/dist/contracts/superadmin-tenants.d.ts +180 -0
  107. package/dist/contracts/superadmin-tenants.js +117 -0
  108. package/dist/contracts/superadmin.d.ts +654 -0
  109. package/dist/contracts/superadmin.js +309 -0
  110. package/dist/contracts/tags.d.ts +1140 -0
  111. package/dist/contracts/tags.js +1050 -0
  112. package/dist/contracts/teams.d.ts +233 -0
  113. package/dist/contracts/teams.js +174 -0
  114. package/dist/contracts/telemetry.d.ts +2 -0
  115. package/dist/contracts/telemetry.js +1 -0
  116. package/dist/contracts/transfers.d.ts +105 -0
  117. package/dist/contracts/transfers.js +48 -0
  118. package/dist/contracts/variables.d.ts +189 -0
  119. package/dist/contracts/variables.js +82 -0
  120. package/dist/contracts/webhooks.d.ts +159 -0
  121. package/dist/contracts/webhooks.js +59 -0
  122. package/dist/contracts/zero.d.ts +1538 -0
  123. package/dist/contracts/zero.js +755 -0
  124. package/dist/docs/agent-prose.d.ts +35 -0
  125. package/dist/docs/agent-prose.js +153 -0
  126. package/dist/docs/agent-setup.d.ts +6 -0
  127. package/dist/docs/agent-setup.js +164 -0
  128. package/dist/docs/agent-solutions.d.ts +110 -0
  129. package/dist/docs/agent-solutions.js +181 -0
  130. package/dist/docs/error-docs.d.ts +12 -0
  131. package/dist/docs/error-docs.js +1601 -0
  132. package/dist/docs/skill-distribution.d.ts +12 -0
  133. package/dist/docs/skill-distribution.js +18 -0
  134. package/dist/domain-exploration.d.ts +108 -0
  135. package/dist/domain-exploration.js +488 -0
  136. package/dist/domain-normalize.d.ts +1 -0
  137. package/dist/domain-normalize.js +14 -0
  138. package/dist/domain-zones.d.ts +1 -0
  139. package/dist/domain-zones.js +5272 -0
  140. package/dist/index.d.ts +1 -0
  141. package/dist/index.js +1 -0
  142. package/dist/utils/access-policy.d.ts +39 -0
  143. package/dist/utils/access-policy.js +232 -0
  144. package/dist/utils/api.d.ts +4 -0
  145. package/dist/utils/api.js +13 -0
  146. package/dist/utils/auth-redirect.d.ts +1 -0
  147. package/dist/utils/auth-redirect.js +48 -0
  148. package/dist/utils/auth.d.ts +5 -0
  149. package/dist/utils/auth.js +13 -0
  150. package/dist/utils/build-settings.d.ts +49 -0
  151. package/dist/utils/build-settings.js +366 -0
  152. package/dist/utils/claim-token.d.ts +1 -0
  153. package/dist/utils/claim-token.js +9 -0
  154. package/dist/utils/collections.d.ts +1 -0
  155. package/dist/utils/collections.js +5 -0
  156. package/dist/utils/concurrency.d.ts +1 -0
  157. package/dist/utils/concurrency.js +18 -0
  158. package/dist/utils/content-type.d.ts +10 -0
  159. package/dist/utils/content-type.js +145 -0
  160. package/dist/utils/error-display.d.ts +7 -0
  161. package/dist/utils/error-display.js +42 -0
  162. package/dist/utils/error.d.ts +1 -0
  163. package/dist/utils/error.js +3 -0
  164. package/dist/utils/generate-space-name.d.ts +14 -0
  165. package/dist/utils/generate-space-name.js +95 -0
  166. package/dist/utils/git-repository.d.ts +5 -0
  167. package/dist/utils/git-repository.js +99 -0
  168. package/dist/utils/guards.d.ts +1 -0
  169. package/dist/utils/guards.js +3 -0
  170. package/dist/utils/publish-detection.d.ts +10 -0
  171. package/dist/utils/publish-detection.js +118 -0
  172. package/dist/utils/publish-policy.d.ts +69 -0
  173. package/dist/utils/publish-policy.js +429 -0
  174. package/dist/utils/query-client.d.ts +7 -0
  175. package/dist/utils/query-client.js +21 -0
  176. package/dist/utils/query-keys.d.ts +75 -0
  177. package/dist/utils/query-keys.js +78 -0
  178. package/dist/utils/runtime-paths.d.ts +7 -0
  179. package/dist/utils/runtime-paths.js +28 -0
  180. package/dist/utils/runtime-upload.d.ts +19 -0
  181. package/dist/utils/runtime-upload.js +27 -0
  182. package/dist/utils/slug.d.ts +5 -0
  183. package/dist/utils/slug.js +13 -0
  184. package/dist/utils/space-config.d.ts +75 -0
  185. package/dist/utils/space-config.js +415 -0
  186. package/dist/utils/space-theme.d.ts +16 -0
  187. package/dist/utils/space-theme.js +89 -0
  188. package/dist/utils/static-runtime-policy.d.ts +17 -0
  189. package/dist/utils/static-runtime-policy.js +103 -0
  190. package/dist/utils/upload-session.d.ts +34 -0
  191. package/dist/utils/upload-session.js +69 -0
  192. package/dist/utils/urls.d.ts +2 -0
  193. package/dist/utils/urls.js +7 -0
  194. package/dist/utils/version-path.d.ts +6 -0
  195. package/dist/utils/version-path.js +51 -0
  196. package/dist/utils/wpcom-auth-redirects.d.ts +14 -0
  197. package/dist/utils/wpcom-auth-redirects.js +49 -0
  198. package/dist/utils/zero-realtime-signature.d.ts +12 -0
  199. package/dist/utils/zero-realtime-signature.js +45 -0
  200. package/dist/vocabulary.d.ts +230 -0
  201. package/dist/vocabulary.js +218 -0
  202. package/package.json +58 -0
@@ -0,0 +1,320 @@
1
+ import { z } from "zod";
2
+ const analyticsIdSchema = z
3
+ .string()
4
+ .min(1)
5
+ .max(64)
6
+ .describe("Opaque analytics id minted by the platform; never an email or a name.");
7
+ const idSchema = z.string().min(1).max(128);
8
+ const occurredAtSchema = z
9
+ .string()
10
+ .datetime()
11
+ .optional()
12
+ .describe("Client-side event time; the server receive time is authoritative when omitted.");
13
+ const pathSchema = z
14
+ .string()
15
+ .min(1)
16
+ .max(2048)
17
+ .describe("Client route or URL path the event happened on, without query strings.");
18
+ const propertyValueSchema = z.union([z.string().max(512), z.number(), z.boolean(), z.null()]);
19
+ const propertyBagSchema = z
20
+ .record(z.string().max(64), propertyValueSchema)
21
+ .refine((value) => Object.keys(value).length <= 32, {
22
+ message: "Events carry at most 32 properties.",
23
+ });
24
+ const optionalPropertyBagSchema = propertyBagSchema.optional().default({});
25
+ export const eventSourceSchema = z.enum([
26
+ "dashboard",
27
+ "www",
28
+ "cli",
29
+ "domain-ssh",
30
+ "control-plane",
31
+ "other",
32
+ ]);
33
+ export const eventActorSchema = z.discriminatedUnion("type", [
34
+ z.object({ type: z.literal("analytics_id"), id: analyticsIdSchema }).strict(),
35
+ z.object({ type: z.literal("anonymous_id"), id: idSchema }).strict(),
36
+ z.object({ type: z.literal("anonymous_machine"), id: idSchema }).strict(),
37
+ z
38
+ .object({
39
+ type: z.literal("anonymous_session"),
40
+ namespace: z.string().min(1).max(64),
41
+ id: idSchema,
42
+ })
43
+ .strict(),
44
+ z.object({ type: z.literal("system"), id: idSchema }).strict(),
45
+ ]);
46
+ const eventContextSchema = z
47
+ .object({
48
+ team_id: z.string().min(1).max(128).nullable().optional(),
49
+ space_id: z.string().min(1).max(128).nullable().optional(),
50
+ user_id: z.string().min(1).max(128).nullable().optional(),
51
+ version_id: z.string().min(1).max(128).nullable().optional(),
52
+ client: z.string().min(1).max(128).nullable().optional(),
53
+ surface: z.string().min(1).max(128).nullable().optional(),
54
+ })
55
+ .strict()
56
+ .optional()
57
+ .default({});
58
+ const pageViewedPropertiesSchema = z
59
+ .object({
60
+ path: pathSchema,
61
+ referrer: z.string().max(2048).nullable().optional(),
62
+ })
63
+ .strict();
64
+ const webVitalPropertiesSchema = z
65
+ .object({
66
+ metric: z.enum(["CLS", "FCP", "INP", "LCP", "TTFB"]),
67
+ value: z.number(),
68
+ path: pathSchema,
69
+ })
70
+ .strict();
71
+ const clientErrorPropertiesSchema = z
72
+ .object({
73
+ error_class: z.string().min(1).max(128),
74
+ path: pathSchema.nullable().optional(),
75
+ })
76
+ .strict();
77
+ const cliCommandPropertiesSchema = z
78
+ .object({
79
+ command: z.string().min(1).max(128),
80
+ version: z.string().min(1).max(64),
81
+ error_class: z.string().min(1).max(128).optional(),
82
+ })
83
+ .strict();
84
+ const browserFunnelPropertiesSchema = propertyBagSchema.default({});
85
+ const domainSearchPropertiesSchema = z
86
+ .object({
87
+ action: z.enum(["suggestions", "availability", "whois"]).nullable().optional(),
88
+ cols: z.number().int().min(1).max(500).nullable().optional(),
89
+ duration_ms: z
90
+ .number()
91
+ .int()
92
+ .min(0)
93
+ .max(24 * 60 * 60 * 1000)
94
+ .nullable()
95
+ .optional(),
96
+ reason: z
97
+ .enum([
98
+ "closed",
99
+ "ended",
100
+ "exec_rejected",
101
+ "lookup_rate_limited",
102
+ "renderer_failed",
103
+ "session_limit",
104
+ "shutdown",
105
+ "started",
106
+ ])
107
+ .nullable()
108
+ .optional(),
109
+ rows: z.number().int().min(1).max(200).nullable().optional(),
110
+ source: z.literal("ssh"),
111
+ source_family: z.enum(["ipv4", "ipv6", "unknown"]),
112
+ source_hash: z
113
+ .string()
114
+ .trim()
115
+ .regex(/^[a-f0-9]{64}$/)
116
+ .nullable()
117
+ .optional(),
118
+ units: z.number().int().min(1).max(160).nullable().optional(),
119
+ })
120
+ .strict();
121
+ const publishReceiptPropertiesSchema = z
122
+ .object({
123
+ access: z.string().min(1).max(64),
124
+ anonymous: z.boolean(),
125
+ upload_count: z.number().int().nonnegative(),
126
+ reused_count: z.number().int().nonnegative(),
127
+ ignored_count: z.number().int().nonnegative(),
128
+ no_changes: z.boolean(),
129
+ })
130
+ .strict();
131
+ const versionIntentPropertiesSchema = z
132
+ .object({
133
+ access: z.string().min(1).max(64),
134
+ file_count: z.number().int().nonnegative(),
135
+ open_session: z.boolean(),
136
+ upload_count: z.number().int().nonnegative(),
137
+ skipped_count: z.number().int().nonnegative(),
138
+ ignored_count: z.number().int().nonnegative(),
139
+ no_changes: z.boolean(),
140
+ finalize_required: z.boolean(),
141
+ source_kind: z.string().min(1).max(64),
142
+ })
143
+ .strict();
144
+ const versionFinalizePropertiesSchema = z
145
+ .object({
146
+ access: z.string().min(1).max(64),
147
+ async: z.boolean(),
148
+ operation_id: z.string().min(1).max(128),
149
+ has_redirects: z.boolean(),
150
+ has_headers: z.boolean(),
151
+ })
152
+ .strict();
153
+ const versionPromotePropertiesSchema = z
154
+ .object({
155
+ access: z.string().min(1).max(64),
156
+ async: z.boolean(),
157
+ operation_id: z.string().min(1).max(128),
158
+ })
159
+ .strict();
160
+ const featureBlockedPropertiesSchema = z
161
+ .object({
162
+ feature: z.string().min(1).max(128),
163
+ plan: z.string().min(1).max(64).nullable(),
164
+ outcome: z.literal("blocked"),
165
+ })
166
+ .strict();
167
+ const abuseLimitPropertiesSchema = z
168
+ .object({
169
+ kind: z.enum(["rate_limit", "quota"]),
170
+ code: z.string().min(1).max(128),
171
+ key_class: z.string().min(1).max(128).nullable(),
172
+ limit: z.number().nullable(),
173
+ })
174
+ .strict();
175
+ export const EVENT_CATALOG = {
176
+ "client.page_viewed": {
177
+ sources: ["dashboard", "www"],
178
+ actors: ["analytics_id", "anonymous_id"],
179
+ properties: pageViewedPropertiesSchema,
180
+ },
181
+ "client.web_vital.measured": {
182
+ sources: ["dashboard", "www"],
183
+ actors: ["analytics_id", "anonymous_id"],
184
+ properties: webVitalPropertiesSchema,
185
+ },
186
+ "client.error.observed": {
187
+ sources: ["dashboard", "www", "cli", "other"],
188
+ actors: ["analytics_id", "anonymous_id", "anonymous_machine"],
189
+ properties: clientErrorPropertiesSchema,
190
+ },
191
+ "cli.command.completed": {
192
+ sources: ["cli"],
193
+ actors: ["anonymous_machine"],
194
+ properties: cliCommandPropertiesSchema,
195
+ },
196
+ "browser.funnel.claim_page_viewed": {
197
+ sources: ["dashboard", "www"],
198
+ actors: ["analytics_id", "anonymous_id"],
199
+ properties: browserFunnelPropertiesSchema,
200
+ },
201
+ "browser.funnel.claim_token_validated": {
202
+ sources: ["dashboard", "www"],
203
+ actors: ["analytics_id", "anonymous_id"],
204
+ properties: browserFunnelPropertiesSchema,
205
+ },
206
+ "browser.funnel.space_claimed": {
207
+ sources: ["dashboard", "www"],
208
+ actors: ["analytics_id", "anonymous_id"],
209
+ properties: browserFunnelPropertiesSchema,
210
+ },
211
+ "browser.funnel.claim_rescue_countdown_viewed": {
212
+ sources: ["dashboard", "www"],
213
+ actors: ["analytics_id", "anonymous_id"],
214
+ properties: browserFunnelPropertiesSchema,
215
+ },
216
+ "browser.funnel.claim_reminder_requested": {
217
+ sources: ["dashboard", "www"],
218
+ actors: ["analytics_id", "anonymous_id"],
219
+ properties: browserFunnelPropertiesSchema,
220
+ },
221
+ "domain.search.session_started": {
222
+ sources: ["domain-ssh"],
223
+ actors: ["anonymous_session"],
224
+ properties: domainSearchPropertiesSchema,
225
+ },
226
+ "domain.search.session_ended": {
227
+ sources: ["domain-ssh"],
228
+ actors: ["anonymous_session"],
229
+ properties: domainSearchPropertiesSchema,
230
+ },
231
+ "domain.search.lookup_requested": {
232
+ sources: ["domain-ssh"],
233
+ actors: ["anonymous_session"],
234
+ properties: domainSearchPropertiesSchema,
235
+ },
236
+ "publish.receipt.created": {
237
+ sources: ["control-plane"],
238
+ actors: ["analytics_id", "anonymous_id", "system"],
239
+ properties: publishReceiptPropertiesSchema,
240
+ },
241
+ "version.intent.created": {
242
+ sources: ["control-plane"],
243
+ actors: ["analytics_id", "anonymous_id", "system"],
244
+ properties: versionIntentPropertiesSchema,
245
+ },
246
+ "version.finalize.queued": {
247
+ sources: ["control-plane"],
248
+ actors: ["analytics_id", "anonymous_id", "system"],
249
+ properties: versionFinalizePropertiesSchema,
250
+ },
251
+ "version.promote.queued": {
252
+ sources: ["control-plane"],
253
+ actors: ["analytics_id", "anonymous_id", "system"],
254
+ properties: versionPromotePropertiesSchema,
255
+ },
256
+ "feature.blocked": {
257
+ sources: ["control-plane"],
258
+ actors: ["analytics_id", "anonymous_id", "system"],
259
+ properties: featureBlockedPropertiesSchema,
260
+ },
261
+ "abuse.limit_tripped": {
262
+ sources: ["control-plane"],
263
+ actors: ["system"],
264
+ properties: abuseLimitPropertiesSchema,
265
+ },
266
+ };
267
+ export const eventNameSchema = z.enum(Object.keys(EVENT_CATALOG));
268
+ export const eventPayloadSchema = z
269
+ .object({
270
+ id: z.string().min(1).max(128).optional(),
271
+ name: eventNameSchema,
272
+ actor: eventActorSchema,
273
+ context: eventContextSchema,
274
+ properties: optionalPropertyBagSchema,
275
+ occurredAt: occurredAtSchema,
276
+ })
277
+ .strict();
278
+ export const EVENT_MAX_EVENTS_PER_REQUEST = 20;
279
+ export const EVENT_BODY_CAP_BYTES = 64 * 1024;
280
+ function addSchemaIssues(ctx, path, issues) {
281
+ for (const issue of issues) {
282
+ ctx.addIssue({
283
+ code: "custom",
284
+ message: issue.message,
285
+ path: [...path, ...issue.path],
286
+ });
287
+ }
288
+ }
289
+ export const eventIngestSchema = z
290
+ .object({
291
+ source: eventSourceSchema.default("other"),
292
+ events: z.array(eventPayloadSchema).min(1).max(EVENT_MAX_EVENTS_PER_REQUEST),
293
+ })
294
+ .strict()
295
+ .superRefine((value, ctx) => {
296
+ value.events.forEach((event, index) => {
297
+ const spec = EVENT_CATALOG[event.name];
298
+ if (!spec.sources.includes(value.source)) {
299
+ ctx.addIssue({
300
+ code: "custom",
301
+ message: `Event ${event.name} is not registered for source ${value.source}.`,
302
+ path: ["events", index, "name"],
303
+ });
304
+ }
305
+ if (!spec.actors.includes(event.actor.type)) {
306
+ ctx.addIssue({
307
+ code: "custom",
308
+ message: `Event ${event.name} does not accept actor type ${event.actor.type}.`,
309
+ path: ["events", index, "actor", "type"],
310
+ });
311
+ }
312
+ const parsedProperties = spec.properties.safeParse(event.properties ?? {});
313
+ if (!parsedProperties.success) {
314
+ addSchemaIssues(ctx, ["events", index, "properties"], parsedProperties.error.issues);
315
+ }
316
+ });
317
+ });
318
+ export const eventAcceptedSchema = z.object({
319
+ accepted: z.number().int().nonnegative(),
320
+ });
@@ -0,0 +1,19 @@
1
+ export declare const FAST_DOMAIN_SEARCH_SERVICE_NAME = "fastdomainsearch";
2
+ export declare const FAST_DOMAIN_SEARCH_SERVICE_HEADERS: {
3
+ readonly bodySha256: "x-spacefast-service-body-sha256";
4
+ readonly nonce: "x-spacefast-service-nonce";
5
+ readonly service: "x-spacefast-service";
6
+ readonly signature: "x-spacefast-service-signature";
7
+ readonly timestamp: "x-spacefast-service-timestamp";
8
+ };
9
+ export declare const FAST_DOMAIN_SEARCH_SIGNATURE_VERSION = "v1";
10
+ export declare const FAST_DOMAIN_SEARCH_MIN_SERVICE_SECRET_LENGTH = 32;
11
+ export declare function normalizeFastDomainSearchServiceSecret(secret: string | undefined): string | null;
12
+ export declare function fastDomainSearchServiceSignaturePayload(input: {
13
+ bodySha256: string;
14
+ method: string;
15
+ nonce: string;
16
+ path: string;
17
+ service?: string;
18
+ timestamp: string;
19
+ }): string;
@@ -0,0 +1,22 @@
1
+ export const FAST_DOMAIN_SEARCH_SERVICE_NAME = "fastdomainsearch";
2
+ export const FAST_DOMAIN_SEARCH_SERVICE_HEADERS = {
3
+ bodySha256: "x-spacefast-service-body-sha256",
4
+ nonce: "x-spacefast-service-nonce",
5
+ service: "x-spacefast-service",
6
+ signature: "x-spacefast-service-signature",
7
+ timestamp: "x-spacefast-service-timestamp",
8
+ };
9
+ export const FAST_DOMAIN_SEARCH_SIGNATURE_VERSION = "v1";
10
+ export const FAST_DOMAIN_SEARCH_MIN_SERVICE_SECRET_LENGTH = 32;
11
+ export function normalizeFastDomainSearchServiceSecret(secret) {
12
+ const value = secret?.trim();
13
+ if (!value ||
14
+ value === "replace-me" ||
15
+ value.length < FAST_DOMAIN_SEARCH_MIN_SERVICE_SECRET_LENGTH) {
16
+ return null;
17
+ }
18
+ return value;
19
+ }
20
+ export function fastDomainSearchServiceSignaturePayload(input) {
21
+ return `${input.service ?? FAST_DOMAIN_SEARCH_SERVICE_NAME}\n${input.method.toUpperCase()}\n${input.path}\n${input.timestamp}\n${input.nonce}\n${input.bodySha256}`;
22
+ }
@@ -0,0 +1,240 @@
1
+ import { z } from "zod";
2
+ export declare const PLAN_CODES: readonly ["free", "personal", "work", "enterprise", "internal"];
3
+ export declare const planCodeSchema: z.ZodEnum<{
4
+ free: "free";
5
+ personal: "personal";
6
+ work: "work";
7
+ enterprise: "enterprise";
8
+ internal: "internal";
9
+ }>;
10
+ export type PlanCode = z.infer<typeof planCodeSchema>;
11
+ export declare const DEFAULT_PLAN_CODE: PlanCode;
12
+ export declare const FEATURE_KEYS: readonly ["plans.paid.available", "anonymous.publishing", "beta.enrollment_gate", "domains.search", "domains.registration", "domains.dns_management", "domains.proxy_bindings", "annotations.preview_loader", "annotations.comments", "annotations.anonymous_reviewers", "annotations.cli", "annotations.notices", "annotations.spacefast_token", "annotations.published_comments", "sites.dedicated_runtime", "shelf", "tags", "zero"];
13
+ export declare const featureKeySchema: z.ZodEnum<{
14
+ "plans.paid.available": "plans.paid.available";
15
+ "anonymous.publishing": "anonymous.publishing";
16
+ "beta.enrollment_gate": "beta.enrollment_gate";
17
+ "domains.search": "domains.search";
18
+ "domains.registration": "domains.registration";
19
+ "domains.dns_management": "domains.dns_management";
20
+ "domains.proxy_bindings": "domains.proxy_bindings";
21
+ "annotations.preview_loader": "annotations.preview_loader";
22
+ "annotations.comments": "annotations.comments";
23
+ "annotations.anonymous_reviewers": "annotations.anonymous_reviewers";
24
+ "annotations.cli": "annotations.cli";
25
+ "annotations.notices": "annotations.notices";
26
+ "annotations.spacefast_token": "annotations.spacefast_token";
27
+ "annotations.published_comments": "annotations.published_comments";
28
+ "sites.dedicated_runtime": "sites.dedicated_runtime";
29
+ shelf: "shelf";
30
+ tags: "tags";
31
+ zero: "zero";
32
+ }>;
33
+ export type FeatureKey = z.infer<typeof featureKeySchema>;
34
+ export declare const FEATURE_OVERRIDE_STATES: readonly ["enabled", "disabled", "kill_switch"];
35
+ export declare const featureOverrideStateSchema: z.ZodEnum<{
36
+ enabled: "enabled";
37
+ disabled: "disabled";
38
+ kill_switch: "kill_switch";
39
+ }>;
40
+ export type FeatureOverrideState = z.infer<typeof featureOverrideStateSchema>;
41
+ export declare const planLimitValueSchema: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
42
+ export type PlanLimitValue = z.infer<typeof planLimitValueSchema>;
43
+ export declare const planLimitsSchema: z.ZodObject<{
44
+ storageBytes: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
45
+ teamMembers: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
46
+ subTeams: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
47
+ externalDomainGroups: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
48
+ publicImmutableVersionWindowDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
49
+ versionRetentionDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
50
+ versionGatedKeepDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
51
+ egressBytesPerDay: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
52
+ maxFileBytes: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
53
+ maxVersionFiles: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
54
+ routingRules: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
55
+ auditLogRetentionHours: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
56
+ buildAccessLogRetentionHours: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
57
+ buildsDeploysMonthly: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
58
+ analyticsRetentionDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
59
+ }, z.core.$strip>;
60
+ export type PlanLimits = z.infer<typeof planLimitsSchema>;
61
+ export declare const teamEntitlementsSchema: z.ZodObject<{
62
+ planCode: z.ZodEnum<{
63
+ free: "free";
64
+ personal: "personal";
65
+ work: "work";
66
+ enterprise: "enterprise";
67
+ internal: "internal";
68
+ }>;
69
+ limits: z.ZodObject<{
70
+ storageBytes: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
71
+ teamMembers: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
72
+ subTeams: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
73
+ externalDomainGroups: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
74
+ publicImmutableVersionWindowDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
75
+ versionRetentionDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
76
+ versionGatedKeepDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
77
+ egressBytesPerDay: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
78
+ maxFileBytes: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
79
+ maxVersionFiles: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
80
+ routingRules: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
81
+ auditLogRetentionHours: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
82
+ buildAccessLogRetentionHours: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
83
+ buildsDeploysMonthly: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
84
+ analyticsRetentionDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
85
+ }, z.core.$strip>;
86
+ headersBasicAuth: z.ZodBoolean;
87
+ externalProxy: z.ZodBoolean;
88
+ runtimePhpWorkers: z.ZodNumber;
89
+ analyticsHourlyGranularity: z.ZodBoolean;
90
+ versionDiagnosticsIncluded: z.ZodBoolean;
91
+ }, z.core.$strip>;
92
+ export type TeamEntitlements = z.infer<typeof teamEntitlementsSchema>;
93
+ export declare const teamEntitlementsResponseSchema: z.ZodObject<{
94
+ planCode: z.ZodEnum<{
95
+ free: "free";
96
+ personal: "personal";
97
+ work: "work";
98
+ enterprise: "enterprise";
99
+ internal: "internal";
100
+ }>;
101
+ headersBasicAuth: z.ZodBoolean;
102
+ externalProxy: z.ZodBoolean;
103
+ runtimePhpWorkers: z.ZodNumber;
104
+ analyticsHourlyGranularity: z.ZodBoolean;
105
+ versionDiagnosticsIncluded: z.ZodBoolean;
106
+ limits: z.ZodObject<{
107
+ storageBytes: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
108
+ teamMembers: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
109
+ subTeams: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
110
+ externalDomainGroups: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
111
+ publicImmutableVersionWindowDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
112
+ maxFileBytes: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
113
+ maxVersionFiles: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
114
+ routingRules: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
115
+ auditLogRetentionHours: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
116
+ buildAccessLogRetentionHours: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
117
+ buildsDeploysMonthly: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
118
+ analyticsRetentionDays: z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"unlimited">]>;
119
+ }, z.core.$strip>;
120
+ }, z.core.$strip>;
121
+ export type TeamEntitlementsResponse = z.infer<typeof teamEntitlementsResponseSchema>;
122
+ export type PlanDefinition = {
123
+ code: PlanCode;
124
+ name: string;
125
+ monthlyPriceUsd: number | null;
126
+ limits: PlanLimits;
127
+ headersBasicAuth: boolean;
128
+ externalProxy: boolean;
129
+ runtimePhpWorkers: number;
130
+ analyticsHourlyGranularity: boolean;
131
+ };
132
+ export type FeatureDefinition = {
133
+ key: FeatureKey;
134
+ name: string;
135
+ description: string;
136
+ defaultEnabled: boolean;
137
+ enabledInDevelopment?: boolean;
138
+ enabledForA8c: boolean;
139
+ planDefaults: Partial<Record<PlanCode, boolean>>;
140
+ };
141
+ export declare const PLAN_DEFINITIONS: Record<PlanCode, PlanDefinition>;
142
+ export declare const FEATURE_DEFINITIONS: Record<FeatureKey, FeatureDefinition>;
143
+ export declare const featureStateSourceSchema: z.ZodEnum<{
144
+ default: "default";
145
+ kill_switch: "kill_switch";
146
+ env: "env";
147
+ override: "override";
148
+ }>;
149
+ export declare const FeatureStateSchema: z.ZodObject<{
150
+ key: z.ZodEnum<{
151
+ "plans.paid.available": "plans.paid.available";
152
+ "anonymous.publishing": "anonymous.publishing";
153
+ "beta.enrollment_gate": "beta.enrollment_gate";
154
+ "domains.search": "domains.search";
155
+ "domains.registration": "domains.registration";
156
+ "domains.dns_management": "domains.dns_management";
157
+ "domains.proxy_bindings": "domains.proxy_bindings";
158
+ "annotations.preview_loader": "annotations.preview_loader";
159
+ "annotations.comments": "annotations.comments";
160
+ "annotations.anonymous_reviewers": "annotations.anonymous_reviewers";
161
+ "annotations.cli": "annotations.cli";
162
+ "annotations.notices": "annotations.notices";
163
+ "annotations.spacefast_token": "annotations.spacefast_token";
164
+ "annotations.published_comments": "annotations.published_comments";
165
+ "sites.dedicated_runtime": "sites.dedicated_runtime";
166
+ shelf: "shelf";
167
+ tags: "tags";
168
+ zero: "zero";
169
+ }>;
170
+ enabled: z.ZodBoolean;
171
+ source: z.ZodEnum<{
172
+ default: "default";
173
+ kill_switch: "kill_switch";
174
+ env: "env";
175
+ override: "override";
176
+ }>;
177
+ }, z.core.$strip>;
178
+ export declare const FeatureStateResponseSchema: z.ZodObject<{
179
+ planCode: z.ZodEnum<{
180
+ free: "free";
181
+ personal: "personal";
182
+ work: "work";
183
+ enterprise: "enterprise";
184
+ internal: "internal";
185
+ }>;
186
+ features: z.ZodRecord<z.ZodEnum<{
187
+ "plans.paid.available": "plans.paid.available";
188
+ "anonymous.publishing": "anonymous.publishing";
189
+ "beta.enrollment_gate": "beta.enrollment_gate";
190
+ "domains.search": "domains.search";
191
+ "domains.registration": "domains.registration";
192
+ "domains.dns_management": "domains.dns_management";
193
+ "domains.proxy_bindings": "domains.proxy_bindings";
194
+ "annotations.preview_loader": "annotations.preview_loader";
195
+ "annotations.comments": "annotations.comments";
196
+ "annotations.anonymous_reviewers": "annotations.anonymous_reviewers";
197
+ "annotations.cli": "annotations.cli";
198
+ "annotations.notices": "annotations.notices";
199
+ "annotations.spacefast_token": "annotations.spacefast_token";
200
+ "annotations.published_comments": "annotations.published_comments";
201
+ "sites.dedicated_runtime": "sites.dedicated_runtime";
202
+ shelf: "shelf";
203
+ tags: "tags";
204
+ zero: "zero";
205
+ }>, z.ZodObject<{
206
+ key: z.ZodEnum<{
207
+ "plans.paid.available": "plans.paid.available";
208
+ "anonymous.publishing": "anonymous.publishing";
209
+ "beta.enrollment_gate": "beta.enrollment_gate";
210
+ "domains.search": "domains.search";
211
+ "domains.registration": "domains.registration";
212
+ "domains.dns_management": "domains.dns_management";
213
+ "domains.proxy_bindings": "domains.proxy_bindings";
214
+ "annotations.preview_loader": "annotations.preview_loader";
215
+ "annotations.comments": "annotations.comments";
216
+ "annotations.anonymous_reviewers": "annotations.anonymous_reviewers";
217
+ "annotations.cli": "annotations.cli";
218
+ "annotations.notices": "annotations.notices";
219
+ "annotations.spacefast_token": "annotations.spacefast_token";
220
+ "annotations.published_comments": "annotations.published_comments";
221
+ "sites.dedicated_runtime": "sites.dedicated_runtime";
222
+ shelf: "shelf";
223
+ tags: "tags";
224
+ zero: "zero";
225
+ }>;
226
+ enabled: z.ZodBoolean;
227
+ source: z.ZodEnum<{
228
+ default: "default";
229
+ kill_switch: "kill_switch";
230
+ env: "env";
231
+ override: "override";
232
+ }>;
233
+ }, z.core.$strip>>;
234
+ }, z.core.$strip>;
235
+ export type FeatureState = z.infer<typeof FeatureStateSchema>;
236
+ export type FeatureStateResponse = z.infer<typeof FeatureStateResponseSchema>;
237
+ export declare function normalizePlanCode(planCode: string | null | undefined): PlanCode;
238
+ export declare function featureDefaultForPlan(key: FeatureKey, planCode: string | null | undefined): boolean;
239
+ /** Numeric value of a plan limit; `null` means unlimited. */
240
+ export declare function planLimitNumber(value: PlanLimitValue): number | null;