@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
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { CursorPaginationSchema, baseDiagnosticSchema, cursorListQuerySchema } from "./common.js";
3
- import { executionLogEntrySchema } from "./execution.js";
4
3
  export const domainPurchaseContactSchema = z.object({
5
4
  firstName: z.string().trim().min(1).max(80),
6
5
  lastName: z.string().trim().min(1).max(80),
@@ -29,29 +28,47 @@ export const accessLogEntrySchema = z.object({
29
28
  bytes: z.number().int().nonnegative(),
30
29
  });
31
30
  /**
32
- * One line a space's own code wrote, from whichever execution tier serves it.
31
+ * One line a space's own code wrote, whichever tier wrote it.
33
32
  *
34
- * This is `executionLogEntrySchema` verbatim rather than a platform-shaped
35
- * restatement of it: both tiers already emit that shape, and re-declaring it
36
- * here would be a second definition to keep in sync with the runtimes that
37
- * produce the records.
33
+ * There is exactly one place these come from: the hosting provider's PHP error
34
+ * log for the space's site. A Zero mutation, a PHP function, and a Functions
35
+ * worker on Cloudflare all end up writing to that file on the origin — the
36
+ * worker by tailing its output back to the origin that dispatched it — because
37
+ * it is the only stream the provider ships off the box and serves back. The
38
+ * runtime writes each record as one JSON line behind a marker; this is what the
39
+ * reader gets after pulling that line back out of the provider's message.
40
+ *
41
+ * `id` is minted by the runtime at write time rather than derived on read: the
42
+ * provider's log has no identity of its own, and a caller paging a window needs
43
+ * a stable key for a line it may see again at a page boundary.
38
44
  *
39
45
  * Unlike its access-log sibling there is no `ts` alongside `timestamp`. That
40
46
  * duplication is a compatibility alias the access log carries for callers that
41
47
  * predate the rename; runtime logs have never been served to anyone, so there
42
48
  * is no caller to keep and no reason to inherit the wart.
43
49
  */
44
- export const runtimeLogEntrySchema = executionLogEntrySchema;
50
+ export const runtimeLogEntrySchema = z
51
+ .object({
52
+ id: z.string().min(1),
53
+ timestamp: z.string().datetime(),
54
+ level: z.enum(["debug", "info", "warn", "error"]),
55
+ requestId: z.string().min(1).nullable(),
56
+ versionId: z.string().min(1).nullable(),
57
+ /** Zero names the mutation; Functions names the handler. */
58
+ handlerName: z.string().min(1).nullable(),
59
+ message: z.string(),
60
+ metadata: z.record(z.string(), z.unknown()).default({}),
61
+ })
62
+ .strict();
45
63
  /**
46
- * Handler logs are filtered, not windowed.
47
- *
48
- * The access log takes `since`/`until` because the provider indexes by time.
49
- * Neither execution tier does: Zero pages a local append-only store by cursor,
50
- * and the origin walks day files backwards from newest. Accepting a `since`
51
- * here would mean ignoring it, so it is absent — the filters below are the ones
52
- * both tiers actually honour.
64
+ * Windowed like its access-log sibling, because it reads the same provider
65
+ * index — `atomic_site_id` plus a `@timestamp` range — and that index has no
66
+ * other way in. The two log kinds sit side by side under one command, so they
67
+ * take one query shape; `requestId` and `handlerName` are the extra narrowings
68
+ * only handler output can answer, and they are applied over the pages the
69
+ * server fetched rather than by the provider, which indexes neither.
53
70
  */
54
- export const runtimeLogListQuerySchema = cursorListQuerySchema.extend({
71
+ export const runtimeLogListQuerySchema = logWindowQuerySchema.extend({
55
72
  requestId: z
56
73
  .string()
57
74
  .min(1)
@@ -74,75 +91,63 @@ export const accessLogListResponseSchema = z.object({
74
91
  /**
75
92
  * Paged handler logs.
76
93
  *
77
- * The pagination block is deliberately the same `CursorPaginationSchema` the
78
- * access log uses — the two kinds sit side by side under one command, and a
79
- * caller should not have to learn a second paging idiom to read the other half
80
- * of its own space.
81
- *
82
94
  * One thing about that cursor is worth stating rather than discovering: **an
83
- * empty page does not mean the end.** `hasMore` is true whenever the server
84
- * stopped before reaching the oldest retained line, and the origin reader stops
85
- * on its own per-page bounds day count, line count, bytes scanned — which it
86
- * can hit while a `requestId` or `handlerName` filter matched nothing in the
87
- * stretch it read. Both tiers satisfy the same rule: **`hasMore: false` means
88
- * you have seen everything; `hasMore: true` means keep paging, whatever `data`
89
- * held.** A client that stops on the first empty page will silently truncate a
90
- * filtered search.
95
+ * empty page does not mean the end.** The cursor walks the provider's scroll
96
+ * over every PHP-error-log line in the window, and only some of those lines are
97
+ * handler output a page can come back empty because the stretch it scanned
98
+ * held none, or held none matching `requestId`/`handlerName`. The rule is
99
+ * **`hasMore: false` means you have seen everything; `hasMore: true` means keep
100
+ * paging, whatever `data` held.** A client that stops on the first empty page
101
+ * will silently truncate its own search.
91
102
  *
92
- * No `warnings` array, unlike the access log. Its one diagnostic is
93
- * `log_retention_clamped`, which reports a requested window being cut back to
94
- * the plan's retention — and there is no window to clamp here. An empty
95
- * diagnostics channel would be a field every caller must handle and no server
96
- * ever fills.
103
+ * `warnings` carries the same `log_retention_clamped` diagnostic the access log
104
+ * does, for the same reason: one window, one retention, one way of saying it
105
+ * was cut back.
106
+ *
107
+ * **These lines lag.** A record is written to a file on the origin, shipped off
108
+ * the box, and indexed before it can be read back, so a line a request just
109
+ * wrote will not be in the next page. Nothing here is live, and the delay is
110
+ * the provider's ingest lag rather than anything this surface schedules — it
111
+ * has not been measured against a real client yet, so no surface should quote
112
+ * a figure for it until the gate probe in
113
+ * `e2e-tests/direct/wpcloud-behavior.test.ts` has actually run.
97
114
  */
98
115
  export const runtimeLogListResponseSchema = z.object({
99
116
  data: z.array(runtimeLogEntrySchema),
100
117
  pagination: CursorPaginationSchema,
118
+ warnings: z
119
+ .array(baseDiagnosticSchema)
120
+ .optional()
121
+ .describe("List-level diagnostics; log_retention_clamped names the effective `since` when the requested window exceeds the plan's log retention."),
101
122
  });
102
123
  export const analyticsQuerySchema = z.object({
103
124
  window: z
104
- .enum(["48h", "7d", "30d", "custom"])
125
+ .enum(["48h", "7d", "30d"])
105
126
  .optional()
106
- .describe('Analytics summary window. Defaults to "7d". "custom" requires since/until.'),
107
- since: z.string().datetime().optional().describe("Start of the custom analytics window."),
108
- until: z.string().datetime().optional().describe("End of the custom analytics window."),
127
+ .describe('Analytics summary window. Defaults to "7d".'),
109
128
  });
110
129
  // Served by `GET /v1/spaces/{spaceId}/analytics`: traffic summary over the
111
- // requested window, read from Spacefast's own per-space rollups (ingested on
112
- // demand from provider edge metrics; staleness bounded by the freshness TTL).
113
- // Counts cover main hostnames only: default, custom-domain, and channel.
114
- // Immutable version-URL traffic is ingested but never surfaced here.
130
+ // requested window, read live from the hosting provider's edge metrics no
131
+ // local store exists. Counts cover every hostname mapped to the space's site;
132
+ // a provider outage means this endpoint errors rather than answers stale.
115
133
  export const analyticsResponseSchema = z.object({
116
134
  spaceId: z.string().describe("The space id the traffic was aggregated for."),
117
- window: z.enum(["48h", "7d", "30d", "custom"]).describe("Resolved summary window."),
118
- since: z.string().describe("Resolved window start (ISO 8601), after retention clamping."),
119
- until: z.string().describe("Resolved window end (ISO 8601)."),
120
- granularity: z.enum(["hourly", "daily"]).describe("Series bucket size, resolved from the plan."),
121
- dataAsOf: z
122
- .string()
123
- .nullable()
124
- .describe("End of the last fully-ingested hour; null until the first ingest starts."),
125
- refreshing: z
126
- .boolean()
127
- .describe("Whether an ingest run is active or the server just triggered one."),
135
+ window: z.enum(["48h", "7d", "30d"]).describe("Resolved summary window."),
136
+ since: z.string().describe("Window start (ISO 8601)."),
137
+ until: z.string().describe("Window end (ISO 8601)."),
138
+ granularity: z
139
+ .enum(["hourly", "daily"])
140
+ .describe("Series bucket size: hourly for the 48h window, daily otherwise."),
128
141
  views: z
129
142
  .number()
130
- .describe("Successful non-crawler requests (status < 400, assets included) summed across main hostnames over the window."),
131
- visitors: z
132
- .number()
133
- .nullable()
134
- .describe("Unique-visitor estimate. Always null because per-hostname unique-visitor data is not yet available from the hosting provider."),
143
+ .describe("Successful non-crawler requests (status < 400, assets included) over the window."),
135
144
  bandwidthBytes: z.number().describe("Total response bytes in the window."),
136
- visitorsByHost: z
145
+ visitorsByDay: z
137
146
  .array(z.object({
138
- host: z.string(),
139
- series: z.array(z.object({
140
- date: z.string().describe("UTC day (ISO 8601)."),
141
- visitors: z.number(),
142
- views: z.number(),
143
- })),
147
+ date: z.string().describe("UTC day (ISO 8601)."),
148
+ visitors: z.number(),
144
149
  }))
145
- .describe("Per-hostname daily visitor estimates. Always empty because per-hostname unique-visitor data is not yet available from the hosting provider."),
150
+ .describe("Daily unique-visitor estimates. Daily is the provider's finest uniques resolution, and uniques are never summed across days."),
146
151
  topPaths: z
147
152
  .array(z.object({ path: z.string(), views: z.number() }))
148
153
  .describe("Most-viewed paths, capped at 10."),
@@ -157,65 +162,4 @@ export const analyticsResponseSchema = z.object({
157
162
  bandwidthBytes: z.number(),
158
163
  }))
159
164
  .describe("Time series across the window."),
160
- warnings: z
161
- .array(baseDiagnosticSchema)
162
- .optional()
163
- .describe("Diagnostics; analytics_retention_clamped names the effective `since` when the requested window exceeds the plan's analytics retention."),
164
- });
165
- export const runtimeCertificateSchema = z.object({
166
- id: z.number().int().positive().nullable(),
167
- status: z.string().nullable(),
168
- domains: z.array(z.string()),
169
- expiration: z.string().nullable(),
170
- raw: z.record(z.string(), z.unknown()),
171
- });
172
- export const runtimeCertificatesSchema = z.object({
173
- data: z.array(runtimeCertificateSchema),
174
- pagination: CursorPaginationSchema,
175
- });
176
- const certificatePayload = z.object({
177
- domains: z.array(z.string()).optional(),
178
- certificate: z.string().min(1),
179
- privateKey: z.string().min(1),
180
- csr: z.string().optional(),
181
- trustedCertificates: z.string().optional(),
182
- clientCertificate: z.string().optional(),
183
- });
184
- export const runtimeCertificateStageSchema = certificatePayload;
185
- export const runtimeCertificateUpdateSchema = certificatePayload.extend({
186
- domains: z.array(z.string()).default([]),
187
- });
188
- export const runtimeCertificateValidateSchema = certificatePayload;
189
- export const runtimeCertificateMutationResponseSchema = z.object({
190
- certificate: runtimeCertificateSchema.nullable(),
191
- raw: z.record(z.string(), z.unknown()),
192
- });
193
- export const runtimeCertificateValidationResponseSchema = z.object({
194
- valid: z.boolean(),
195
- errors: z.array(z.string()),
196
- warnings: z.array(z.string()),
197
- validations: z.record(z.string(), z.record(z.string(), z.unknown())),
198
- });
199
- export const runtimeCertificateActivateSchema = z.object({
200
- domains: z.array(z.string()).optional(),
201
- });
202
- export const runtimeCertificateActionResponseSchema = z.object({
203
- ok: z.literal(true),
204
- certificateId: z.number().int().positive(),
205
- raw: z.record(z.string(), z.unknown()),
206
- });
207
- export const runtimeSslInfoSchema = z.object({
208
- domain: z.string().min(1),
209
- raw: z.record(z.string(), z.unknown()),
210
- });
211
- export const runtimeSslDomainSchema = z.object({
212
- domain: z.string().min(1),
213
- });
214
- export const runtimeSslToggleSchema = runtimeSslDomainSchema.extend({
215
- enabled: z.boolean(),
216
- });
217
- export const runtimeSslActionResponseSchema = z.object({
218
- ok: z.literal(true),
219
- domain: z.string().min(1),
220
- raw: z.record(z.string(), z.unknown()),
221
165
  });