@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,235 @@
1
+ import { z } from "zod";
2
+ import { AnyObjectSchema, CursorPaginationSchema, cursorListQuerySchema } from "./common.js";
3
+ export const SPACEFAST_ACCESS_POLICY_VERSION = "2026-06-09";
4
+ export const StatticActionSchema = z.enum([
5
+ "sites:read",
6
+ "sites:create",
7
+ "sites:write",
8
+ "sites:delete",
9
+ "sites:policy.write",
10
+ "spaces:read",
11
+ "spaces:create",
12
+ "spaces:write",
13
+ "spaces:delete",
14
+ "spaces:publish",
15
+ "spaces:transfer",
16
+ "spaces:export",
17
+ "spaces:import",
18
+ "versions:read",
19
+ "versions:promote",
20
+ "versions:delete",
21
+ "versions:download",
22
+ "domains:read",
23
+ "domains:create",
24
+ "domains:verify",
25
+ "domains:assign",
26
+ "domains:bind",
27
+ "domains:delete",
28
+ "domains:dns.write",
29
+ "domains:dns.credentials.write",
30
+ "domains:purchase",
31
+ "webhooks:read",
32
+ "webhooks:write",
33
+ "builds:read",
34
+ "builds:create",
35
+ "teams:read",
36
+ "teams:write",
37
+ "teams:members.write",
38
+ "billing:read",
39
+ "billing:write",
40
+ "tokens:read",
41
+ "tokens:create",
42
+ "tokens:revoke",
43
+ "mcp:tools",
44
+ "runtime:manage",
45
+ "*",
46
+ ]);
47
+ const DescribedStatticActionSchema = StatticActionSchema.describe("A namespaced IAM-lite action (`noun:verb`) or `*` for all actions.");
48
+ const RESOURCE_PREFIX = "stt://tenant/";
49
+ function isResourceSegment(value) {
50
+ return Boolean(value && value.length > 0 && !/[\s/\\]/.test(value));
51
+ }
52
+ export function parseStatticResource(value) {
53
+ if (!value.startsWith(RESOURCE_PREFIX) || value.length > 512) {
54
+ return null;
55
+ }
56
+ const segments = value.slice(RESOURCE_PREFIX.length).split("/");
57
+ const tenantId = segments.shift();
58
+ if (!isResourceSegment(tenantId)) {
59
+ return null;
60
+ }
61
+ if (segments.length === 0) {
62
+ return { kind: "tenant", tenantId };
63
+ }
64
+ const wildcard = segments.at(-1) === "*";
65
+ const path = wildcard ? segments.slice(0, -1) : segments;
66
+ const [head, a, b, c] = path;
67
+ if (head === "principal" && (a === "team" || a === "external") && isResourceSegment(b)) {
68
+ if (path.length !== 3) {
69
+ return null;
70
+ }
71
+ return { kind: "principal", tenantId, principalType: a, principalId: b, wildcard };
72
+ }
73
+ if (head === "site" && isResourceSegment(a)) {
74
+ if (path.length === 2) {
75
+ return { kind: "site", tenantId, siteId: a, wildcard };
76
+ }
77
+ if (path.length === 4 && b === "space" && isResourceSegment(c)) {
78
+ return { kind: "space", tenantId, siteId: a, spaceId: c, wildcard };
79
+ }
80
+ return null;
81
+ }
82
+ if (head === "domain" && isResourceSegment(a) && path.length === 2 && !wildcard) {
83
+ return { kind: "domain", tenantId, domainId: a };
84
+ }
85
+ if (head === "domain-group" && isResourceSegment(a) && path.length === 2 && !wildcard) {
86
+ return { kind: "domain-group", tenantId, domainGroupId: a };
87
+ }
88
+ return null;
89
+ }
90
+ const StatticResourceSchema = z
91
+ .string()
92
+ .max(512)
93
+ .refine((value) => parseStatticResource(value) !== null, {
94
+ message: "Resource must be a stt:// URI from the StatticResource union (tenant, principal, site, site space, domain, or domain-group).",
95
+ })
96
+ .describe("A resource URI from the StatticResource union: stt://tenant/{t}, …/principal/(team|external)/{id}[/*], …/site/{id}[/*], …/site/{id}/space/{id}[/*], …/domain/{id}, or …/domain-group/{id}.");
97
+ export const StatticAccessPolicySchema = z
98
+ .object({
99
+ version: z
100
+ .literal(SPACEFAST_ACCESS_POLICY_VERSION)
101
+ .describe("Policy schema version. Must be the current platform policy version."),
102
+ statements: z
103
+ .array(z
104
+ .object({
105
+ effect: z
106
+ .enum(["allow", "deny"])
107
+ .describe("Statement effect. Explicit deny always wins over allow."),
108
+ actions: z
109
+ .array(DescribedStatticActionSchema)
110
+ .min(1)
111
+ .describe("Actions this statement covers."),
112
+ resources: z
113
+ .array(StatticResourceSchema)
114
+ .min(1)
115
+ .describe("Resource URIs this statement covers (wildcards cover subtrees)."),
116
+ conditions: z
117
+ .object({
118
+ "request.client": z
119
+ .enum(["dashboard", "cli", "api", "worker"])
120
+ .optional()
121
+ .describe("Restricts the statement to one resolved request client."),
122
+ })
123
+ .strict()
124
+ .optional()
125
+ .describe("ANDed condition attributes. Unresolvable attributes fail closed: no-match for allow, match for deny."),
126
+ })
127
+ .strict())
128
+ .min(1)
129
+ .describe("Evaluation: explicit deny wins, explicit allow permits, otherwise implicit deny."),
130
+ })
131
+ .strict()
132
+ .describe("IAM-lite access policy evaluated for every credentialed request.");
133
+ export const ApiKeyPresetSchema = z
134
+ .enum([
135
+ "ci_deploy",
136
+ "space_publisher",
137
+ "space_admin",
138
+ "site_admin",
139
+ "domain_manager",
140
+ "team_admin",
141
+ "billing_viewer",
142
+ ])
143
+ .describe("Named policy preset compiled into a concrete access policy at key creation.");
144
+ // `system` is never a principal type: runtime/internal credentials are
145
+ // platform-owned and omit ownerPrincipal entirely (internal-docs/platform.md).
146
+ const ApiKeyOwnerPrincipalSchema = z.object({
147
+ type: z.enum(["team", "external"]).describe("Principal type that owns this key."),
148
+ id: z.string().min(1).describe("Stable principal id (Better Auth team id or external id)."),
149
+ });
150
+ const ApiKeySubjectSchema = z.object({
151
+ type: z
152
+ .enum(["user", "team", "external", "system"])
153
+ .describe("Subject kind the key acts as in audit records."),
154
+ id: z.string().min(1).describe("Stable subject id."),
155
+ });
156
+ export const ApiKeySchema = z.object({
157
+ id: z.string().describe("API key id."),
158
+ name: z.string().nullable().describe("Human-readable key name."),
159
+ tenantId: z.string().nullable().describe("Tenant the key belongs to."),
160
+ subject: ApiKeySubjectSchema.nullable().describe("Subject the key acts as."),
161
+ ownerPrincipal: ApiKeyOwnerPrincipalSchema.nullable().describe("Owning principal (ownership metadata, never the authorization gate)."),
162
+ createdByUserId: z.string().describe("User who created the key."),
163
+ preset: ApiKeyPresetSchema.nullable().describe("Preset the policy was compiled from, if any."),
164
+ policy: StatticAccessPolicySchema.nullable().describe("Effective access policy. A key authorizes by policy only."),
165
+ metadata: AnyObjectSchema.describe("Caller-supplied metadata."),
166
+ secretPreview: z.string().describe("Masked secret preview (prefix and last characters)."),
167
+ secret: z.string().optional().describe("Full secret. Returned once, at creation only."),
168
+ notBefore: z.string().datetime().nullable().describe("Key is rejected before this instant."),
169
+ expiresAt: z.string().datetime().nullable().describe("Key is rejected from this instant."),
170
+ ipAllowlist: z
171
+ .array(z.string())
172
+ .nullable()
173
+ .describe("CIDR/IP allowlist. Requests from other addresses are rejected."),
174
+ revokedAt: z.string().datetime().nullable().describe("Revocation instant, if revoked."),
175
+ enabled: z.boolean().describe("Whether the key currently authenticates."),
176
+ createdAt: z.string().datetime().describe("Creation instant."),
177
+ updatedAt: z.string().datetime().describe("Last update instant."),
178
+ lastRequestAt: z.string().datetime().nullable().describe("Last authenticated request instant."),
179
+ });
180
+ export const ApiKeyListQuerySchema = cursorListQuerySchema.extend({
181
+ teamId: z
182
+ .string()
183
+ .min(1)
184
+ .optional()
185
+ .describe("Owning team whose keys to list. Defaults to the caller's own team; any team the credential's policy reaches is allowed."),
186
+ });
187
+ export const ApiKeyListResponseSchema = z.object({
188
+ data: z.array(ApiKeySchema),
189
+ pagination: CursorPaginationSchema,
190
+ });
191
+ export const ApiKeyCreateRequestSchema = z.object({
192
+ name: z.string().trim().min(1).max(255).optional().describe("Human-readable key name."),
193
+ teamId: z
194
+ .string()
195
+ .min(1)
196
+ .optional()
197
+ .describe("Owning team for the new key. Defaults to the caller's own team; authorization is by the credential's policy, not key ownership."),
198
+ preset: ApiKeyPresetSchema.optional(),
199
+ policy: StatticAccessPolicySchema.nullable()
200
+ .optional()
201
+ .describe("Explicit policy. Must be a subset of the calling credential's policy."),
202
+ metadata: AnyObjectSchema.optional().describe("Caller-supplied metadata."),
203
+ ipAllowlist: z
204
+ .array(z.string().trim().min(1).max(255))
205
+ .max(100)
206
+ .nullable()
207
+ .optional()
208
+ .describe("CIDR/IP allowlist for the new key."),
209
+ expiresAt: z.string().datetime().nullable().optional().describe("Expiry instant."),
210
+ notBefore: z.string().datetime().nullable().optional().describe("Activation instant."),
211
+ });
212
+ export const ApiKeyPatchRequestSchema = z
213
+ .object({
214
+ metadata: AnyObjectSchema.optional().describe("Replacement caller-supplied metadata."),
215
+ ipAllowlist: z
216
+ .array(z.string().trim().min(1).max(255))
217
+ .max(100)
218
+ .nullable()
219
+ .optional()
220
+ .describe("Replacement CIDR/IP allowlist."),
221
+ expiresAt: z.string().datetime().nullable().optional().describe("Replacement expiry instant."),
222
+ notBefore: z
223
+ .string()
224
+ .datetime()
225
+ .nullable()
226
+ .optional()
227
+ .describe("Replacement activation instant."),
228
+ policy: StatticAccessPolicySchema.optional().describe("Replacement policy. Must be a subset of the calling credential's policy at mutation time."),
229
+ })
230
+ .refine((value) => Object.keys(value).length > 0, {
231
+ message: "At least one mutable API key field is required.",
232
+ });
233
+ export const ApiKeyParamsSchema = z.object({
234
+ apiKeyId: z.string().min(1).describe("API key id."),
235
+ });
@@ -0,0 +1,332 @@
1
+ import { z } from "zod";
2
+ export declare const archiveListQuerySchema: z.ZodObject<{
3
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
4
+ cursor: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export declare const spaceExportRequestSchema: z.ZodObject<{
7
+ versionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
+ includeFiles: z.ZodDefault<z.ZodBoolean>;
9
+ includeExplicitConfig: z.ZodDefault<z.ZodBoolean>;
10
+ }, z.core.$strip>;
11
+ export declare const spaceExportArchiveSchema: z.ZodObject<{
12
+ contentType: z.ZodLiteral<"application/zip">;
13
+ downloadUrl: z.ZodString;
14
+ expiresAt: z.ZodString;
15
+ sizeBytes: z.ZodOptional<z.ZodNumber>;
16
+ sha256: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ export declare const spaceExportSchema: z.ZodObject<{
19
+ id: z.ZodString;
20
+ spaceId: z.ZodString;
21
+ status: z.ZodEnum<{
22
+ failed: "failed";
23
+ queued: "queued";
24
+ running: "running";
25
+ ready: "ready";
26
+ expired: "expired";
27
+ }>;
28
+ format: z.ZodLiteral<"stattic_export_v1">;
29
+ diagnostics: z.ZodDefault<z.ZodArray<z.ZodObject<{
30
+ code: z.ZodString;
31
+ severity: z.ZodEnum<{
32
+ info: "info";
33
+ warning: "warning";
34
+ error: "error";
35
+ }>;
36
+ message: z.ZodString;
37
+ path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
39
+ wpcloud: "wpcloud";
40
+ dns: "dns";
41
+ registrar: "registrar";
42
+ runtime: "runtime";
43
+ }>>>;
44
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
45
+ fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
46
+ retryable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
47
+ }, z.core.$strip>>>;
48
+ archive: z.ZodOptional<z.ZodObject<{
49
+ contentType: z.ZodLiteral<"application/zip">;
50
+ downloadUrl: z.ZodString;
51
+ expiresAt: z.ZodString;
52
+ sizeBytes: z.ZodOptional<z.ZodNumber>;
53
+ sha256: z.ZodOptional<z.ZodString>;
54
+ }, z.core.$strip>>;
55
+ operationId: z.ZodNullable<z.ZodString>;
56
+ createdAt: z.ZodString;
57
+ updatedAt: z.ZodString;
58
+ }, z.core.$strip>;
59
+ export declare const spaceExportListResponseSchema: z.ZodObject<{
60
+ data: z.ZodArray<z.ZodObject<{
61
+ id: z.ZodString;
62
+ spaceId: z.ZodString;
63
+ status: z.ZodEnum<{
64
+ failed: "failed";
65
+ queued: "queued";
66
+ running: "running";
67
+ ready: "ready";
68
+ expired: "expired";
69
+ }>;
70
+ format: z.ZodLiteral<"stattic_export_v1">;
71
+ diagnostics: z.ZodDefault<z.ZodArray<z.ZodObject<{
72
+ code: z.ZodString;
73
+ severity: z.ZodEnum<{
74
+ info: "info";
75
+ warning: "warning";
76
+ error: "error";
77
+ }>;
78
+ message: z.ZodString;
79
+ path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
80
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
81
+ wpcloud: "wpcloud";
82
+ dns: "dns";
83
+ registrar: "registrar";
84
+ runtime: "runtime";
85
+ }>>>;
86
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
87
+ fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
88
+ retryable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
89
+ }, z.core.$strip>>>;
90
+ archive: z.ZodOptional<z.ZodObject<{
91
+ contentType: z.ZodLiteral<"application/zip">;
92
+ downloadUrl: z.ZodString;
93
+ expiresAt: z.ZodString;
94
+ sizeBytes: z.ZodOptional<z.ZodNumber>;
95
+ sha256: z.ZodOptional<z.ZodString>;
96
+ }, z.core.$strip>>;
97
+ operationId: z.ZodNullable<z.ZodString>;
98
+ createdAt: z.ZodString;
99
+ updatedAt: z.ZodString;
100
+ }, z.core.$strip>>;
101
+ pagination: z.ZodObject<{
102
+ nextCursor: z.ZodNullable<z.ZodString>;
103
+ hasMore: z.ZodBoolean;
104
+ }, z.core.$strip>;
105
+ }, z.core.$strip>;
106
+ export declare const spaceImportSourceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
107
+ kind: z.ZodLiteral<"upload">;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ kind: z.ZodLiteral<"url">;
110
+ url: z.ZodString;
111
+ }, z.core.$strip>, z.ZodObject<{
112
+ kind: z.ZodLiteral<"export">;
113
+ exportId: z.ZodString;
114
+ }, z.core.$strip>], "kind">;
115
+ export declare const spaceImportRequestSchema: z.ZodObject<{
116
+ source: z.ZodDiscriminatedUnion<[z.ZodObject<{
117
+ kind: z.ZodLiteral<"upload">;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ kind: z.ZodLiteral<"url">;
120
+ url: z.ZodString;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ kind: z.ZodLiteral<"export">;
123
+ exportId: z.ZodString;
124
+ }, z.core.$strip>], "kind">;
125
+ publish: z.ZodDefault<z.ZodBoolean>;
126
+ }, z.core.$strip>;
127
+ export declare const spaceImportSchema: z.ZodObject<{
128
+ id: z.ZodString;
129
+ targetSpaceId: z.ZodString;
130
+ status: z.ZodEnum<{
131
+ failed: "failed";
132
+ canceled: "canceled";
133
+ ready: "ready";
134
+ created: "created";
135
+ waiting_for_archive: "waiting_for_archive";
136
+ validating: "validating";
137
+ materializing: "materializing";
138
+ }>;
139
+ archiveUpload: z.ZodOptional<z.ZodObject<{
140
+ id: z.ZodString;
141
+ mode: z.ZodEnum<{
142
+ dist: "dist";
143
+ source: "source";
144
+ }>;
145
+ expiresAt: z.ZodString;
146
+ summary: z.ZodObject<{
147
+ upload: z.ZodNumber;
148
+ reused: z.ZodNumber;
149
+ ignored: z.ZodNumber;
150
+ }, z.core.$strip>;
151
+ targets: z.ZodDefault<z.ZodArray<z.ZodObject<{
152
+ path: z.ZodString;
153
+ method: z.ZodEnum<{
154
+ PUT: "PUT";
155
+ POST: "POST";
156
+ }>;
157
+ url: z.ZodUnion<[z.ZodString, z.ZodString]>;
158
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
159
+ body: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
160
+ kind: z.ZodLiteral<"url">;
161
+ url: z.ZodString;
162
+ }, z.core.$strip>], "kind">>;
163
+ size: z.ZodOptional<z.ZodNumber>;
164
+ maxBytes: z.ZodOptional<z.ZodNumber>;
165
+ sha256: z.ZodOptional<z.ZodString>;
166
+ contentType: z.ZodOptional<z.ZodString>;
167
+ }, z.core.$strip>>>;
168
+ links: z.ZodObject<{
169
+ resume: z.ZodString;
170
+ finalize: z.ZodString;
171
+ }, z.core.$strip>;
172
+ details: z.ZodOptional<z.ZodObject<{
173
+ reused: z.ZodOptional<z.ZodArray<z.ZodObject<{
174
+ path: z.ZodString;
175
+ reason: z.ZodString;
176
+ }, z.core.$strip>>>;
177
+ ignored: z.ZodOptional<z.ZodArray<z.ZodObject<{
178
+ path: z.ZodString;
179
+ reason: z.ZodString;
180
+ }, z.core.$strip>>>;
181
+ diagnostics: z.ZodOptional<z.ZodArray<z.ZodObject<{
182
+ code: z.ZodString;
183
+ severity: z.ZodEnum<{
184
+ info: "info";
185
+ warning: "warning";
186
+ error: "error";
187
+ }>;
188
+ message: z.ZodString;
189
+ path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
191
+ wpcloud: "wpcloud";
192
+ dns: "dns";
193
+ registrar: "registrar";
194
+ runtime: "runtime";
195
+ }>>>;
196
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
197
+ fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
198
+ retryable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
199
+ }, z.core.$strip>>>;
200
+ }, z.core.$strip>>;
201
+ }, z.core.$strip>>;
202
+ draftVersionIds: z.ZodArray<z.ZodString>;
203
+ diagnostics: z.ZodDefault<z.ZodArray<z.ZodObject<{
204
+ code: z.ZodString;
205
+ severity: z.ZodEnum<{
206
+ info: "info";
207
+ warning: "warning";
208
+ error: "error";
209
+ }>;
210
+ message: z.ZodString;
211
+ path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
212
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
213
+ wpcloud: "wpcloud";
214
+ dns: "dns";
215
+ registrar: "registrar";
216
+ runtime: "runtime";
217
+ }>>>;
218
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
219
+ fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
220
+ retryable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
221
+ }, z.core.$strip>>>;
222
+ operationId: z.ZodNullable<z.ZodString>;
223
+ createdAt: z.ZodString;
224
+ updatedAt: z.ZodString;
225
+ }, z.core.$strip>;
226
+ export declare const spaceImportListResponseSchema: z.ZodObject<{
227
+ data: z.ZodArray<z.ZodObject<{
228
+ id: z.ZodString;
229
+ targetSpaceId: z.ZodString;
230
+ status: z.ZodEnum<{
231
+ failed: "failed";
232
+ canceled: "canceled";
233
+ ready: "ready";
234
+ created: "created";
235
+ waiting_for_archive: "waiting_for_archive";
236
+ validating: "validating";
237
+ materializing: "materializing";
238
+ }>;
239
+ archiveUpload: z.ZodOptional<z.ZodObject<{
240
+ id: z.ZodString;
241
+ mode: z.ZodEnum<{
242
+ dist: "dist";
243
+ source: "source";
244
+ }>;
245
+ expiresAt: z.ZodString;
246
+ summary: z.ZodObject<{
247
+ upload: z.ZodNumber;
248
+ reused: z.ZodNumber;
249
+ ignored: z.ZodNumber;
250
+ }, z.core.$strip>;
251
+ targets: z.ZodDefault<z.ZodArray<z.ZodObject<{
252
+ path: z.ZodString;
253
+ method: z.ZodEnum<{
254
+ PUT: "PUT";
255
+ POST: "POST";
256
+ }>;
257
+ url: z.ZodUnion<[z.ZodString, z.ZodString]>;
258
+ headers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
259
+ body: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
260
+ kind: z.ZodLiteral<"url">;
261
+ url: z.ZodString;
262
+ }, z.core.$strip>], "kind">>;
263
+ size: z.ZodOptional<z.ZodNumber>;
264
+ maxBytes: z.ZodOptional<z.ZodNumber>;
265
+ sha256: z.ZodOptional<z.ZodString>;
266
+ contentType: z.ZodOptional<z.ZodString>;
267
+ }, z.core.$strip>>>;
268
+ links: z.ZodObject<{
269
+ resume: z.ZodString;
270
+ finalize: z.ZodString;
271
+ }, z.core.$strip>;
272
+ details: z.ZodOptional<z.ZodObject<{
273
+ reused: z.ZodOptional<z.ZodArray<z.ZodObject<{
274
+ path: z.ZodString;
275
+ reason: z.ZodString;
276
+ }, z.core.$strip>>>;
277
+ ignored: z.ZodOptional<z.ZodArray<z.ZodObject<{
278
+ path: z.ZodString;
279
+ reason: z.ZodString;
280
+ }, z.core.$strip>>>;
281
+ diagnostics: z.ZodOptional<z.ZodArray<z.ZodObject<{
282
+ code: z.ZodString;
283
+ severity: z.ZodEnum<{
284
+ info: "info";
285
+ warning: "warning";
286
+ error: "error";
287
+ }>;
288
+ message: z.ZodString;
289
+ path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
290
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
291
+ wpcloud: "wpcloud";
292
+ dns: "dns";
293
+ registrar: "registrar";
294
+ runtime: "runtime";
295
+ }>>>;
296
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
297
+ fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
298
+ retryable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
299
+ }, z.core.$strip>>>;
300
+ }, z.core.$strip>>;
301
+ }, z.core.$strip>>;
302
+ draftVersionIds: z.ZodArray<z.ZodString>;
303
+ diagnostics: z.ZodDefault<z.ZodArray<z.ZodObject<{
304
+ code: z.ZodString;
305
+ severity: z.ZodEnum<{
306
+ info: "info";
307
+ warning: "warning";
308
+ error: "error";
309
+ }>;
310
+ message: z.ZodString;
311
+ path: z.ZodOptional<z.ZodNullable<z.ZodString>>;
312
+ provider: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
313
+ wpcloud: "wpcloud";
314
+ dns: "dns";
315
+ registrar: "registrar";
316
+ runtime: "runtime";
317
+ }>>>;
318
+ details: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
319
+ fix: z.ZodOptional<z.ZodNullable<z.ZodString>>;
320
+ retryable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
321
+ }, z.core.$strip>>>;
322
+ operationId: z.ZodNullable<z.ZodString>;
323
+ createdAt: z.ZodString;
324
+ updatedAt: z.ZodString;
325
+ }, z.core.$strip>>;
326
+ pagination: z.ZodObject<{
327
+ nextCursor: z.ZodNullable<z.ZodString>;
328
+ hasMore: z.ZodBoolean;
329
+ }, z.core.$strip>;
330
+ }, z.core.$strip>;
331
+ export type SpaceExport = z.infer<typeof spaceExportSchema>;
332
+ export type SpaceImport = z.infer<typeof spaceImportSchema>;
@@ -0,0 +1,120 @@
1
+ import { z } from "zod";
2
+ import { baseDiagnosticSchema, CursorPaginationSchema, cursorListQuerySchema } from "./common.js";
3
+ import { uploadInstructionsSchema } from "./internal.js";
4
+ export const archiveListQuerySchema = cursorListQuerySchema;
5
+ export const spaceExportRequestSchema = z.object({
6
+ versionIds: z
7
+ .array(z.string().min(1))
8
+ .min(1)
9
+ .optional()
10
+ .describe("Version ids (ver_…) to export. Every id must belong to the space; omit to export all versions."),
11
+ includeFiles: z
12
+ .boolean()
13
+ .default(true)
14
+ .describe("Include version file trees and compiled serving artifacts. `false` produces a config-only archive that is not self-servable and cannot be re-imported."),
15
+ includeExplicitConfig: z
16
+ .boolean()
17
+ .default(true)
18
+ .describe("Include explicit space config (the space access policy) in the archive. Version manifests are always included."),
19
+ });
20
+ export const spaceExportArchiveSchema = z.object({
21
+ // Zip-only contract: stattic_export_v1 archives are always zip (the spec
22
+ // allows "zip or tar"; one format keeps the enum honest).
23
+ contentType: z.literal("application/zip").describe("Archive media type. Always zip."),
24
+ downloadUrl: z
25
+ .string()
26
+ .describe("API-relative URL streaming the archive while it has not expired."),
27
+ expiresAt: z
28
+ .string()
29
+ .datetime()
30
+ .describe("When the archive download expires; the export flips to `expired` afterwards."),
31
+ sizeBytes: z.number().int().nonnegative().optional().describe("Archive size in bytes."),
32
+ sha256: z
33
+ .string()
34
+ .optional()
35
+ .describe("SHA-256 of the archive bytes (64 lowercase hex characters), for verification."),
36
+ });
37
+ export const spaceExportSchema = z.object({
38
+ id: z.string().describe("Export handle id (exp_…)."),
39
+ spaceId: z.string().describe("Source space id (spc_…)."),
40
+ status: z
41
+ .enum(["queued", "running", "ready", "failed", "expired"])
42
+ .describe("Export lifecycle. `expired` means the archive download window has passed."),
43
+ format: z.literal("stattic_export_v1").describe("Archive format identifier."),
44
+ diagnostics: z
45
+ .array(baseDiagnosticSchema)
46
+ .default([])
47
+ .describe("Diagnostics collected while producing the export."),
48
+ archive: spaceExportArchiveSchema
49
+ .optional()
50
+ .describe("Archive download details; present only while status is `ready`."),
51
+ operationId: z
52
+ .string()
53
+ .nullable()
54
+ .describe("Operation (op_…) tracking the asynchronous export work."),
55
+ createdAt: z.string().datetime().describe("When the export handle was created."),
56
+ updatedAt: z.string().datetime().describe("When the export handle last changed."),
57
+ });
58
+ export const spaceExportListResponseSchema = z.object({
59
+ data: z.array(spaceExportSchema),
60
+ pagination: CursorPaginationSchema,
61
+ });
62
+ export const spaceImportSourceSchema = z
63
+ .discriminatedUnion("kind", [
64
+ z.object({
65
+ kind: z
66
+ .literal("upload")
67
+ .describe("Upload an archive; the response carries `archiveUpload` instructions."),
68
+ }),
69
+ z.object({
70
+ kind: z.literal("url").describe("Fetch the archive from a public HTTPS URL."),
71
+ url: z.string().url().describe("Public HTTPS URL of a stattic_export_v1 archive."),
72
+ }),
73
+ z.object({
74
+ kind: z.literal("export").describe("Import directly from an export on this control plane."),
75
+ exportId: z.string().min(1).describe("Source export id (exp_…) accessible to the caller."),
76
+ }),
77
+ ])
78
+ .describe("Where the stattic_export_v1 archive comes from.");
79
+ export const spaceImportRequestSchema = z.object({
80
+ source: spaceImportSourceSchema,
81
+ publish: z
82
+ .boolean()
83
+ .default(false)
84
+ .describe("Promote the newest imported version to the live channel once materialized. Imported versions never go public implicitly."),
85
+ });
86
+ export const spaceImportSchema = z.object({
87
+ id: z.string().describe("Import handle id (imp_…)."),
88
+ targetSpaceId: z.string().describe("Target space id (spc_…) the import materializes into."),
89
+ status: z
90
+ .enum([
91
+ "created",
92
+ "waiting_for_archive",
93
+ "validating",
94
+ "materializing",
95
+ "ready",
96
+ "failed",
97
+ "canceled",
98
+ ])
99
+ .describe("Import lifecycle. Upload-kind imports wait in `waiting_for_archive` until the archive is uploaded and the import is finalized."),
100
+ archiveUpload: uploadInstructionsSchema
101
+ .optional()
102
+ .describe("Archive upload instructions — the same upload contract as publish. Present while status is `waiting_for_archive`: PUT the archive to `{baseUrl}/{files[0]}` with the session token, then POST `links.finalize`. Each fetch of the import re-mints a fresh token."),
103
+ draftVersionIds: z
104
+ .array(z.string())
105
+ .describe("Version ids (ver_…) minted and owned by this import."),
106
+ diagnostics: z
107
+ .array(baseDiagnosticSchema)
108
+ .default([])
109
+ .describe("Diagnostics collected during validation and materialization, including warnings for imported config overridden by the target space/parent policy."),
110
+ operationId: z
111
+ .string()
112
+ .nullable()
113
+ .describe("Operation (op_…) tracking the asynchronous import work."),
114
+ createdAt: z.string().datetime().describe("When the import handle was created."),
115
+ updatedAt: z.string().datetime().describe("When the import handle last changed."),
116
+ });
117
+ export const spaceImportListResponseSchema = z.object({
118
+ data: z.array(spaceImportSchema),
119
+ pagination: CursorPaginationSchema,
120
+ });