@spacefast/common 0.0.13 → 0.0.17

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 (154) hide show
  1. package/dist/agents/client-registry.d.ts +22 -0
  2. package/dist/agents/client-registry.js +41 -0
  3. package/dist/agents/connect-targets.d.ts +51 -6
  4. package/dist/agents/connect-targets.js +93 -28
  5. package/dist/brand.d.ts +0 -11
  6. package/dist/brand.js +0 -20
  7. package/dist/config/domains.d.ts +15 -6
  8. package/dist/config/domains.js +24 -10
  9. package/dist/config/postgres-budget.d.ts +3 -0
  10. package/dist/config/postgres-budget.js +6 -1
  11. package/dist/config/postgres-budget.json +2 -1
  12. package/dist/contracts/abuse.js +1 -1
  13. package/dist/contracts/access.d.ts +149 -44
  14. package/dist/contracts/access.js +94 -8
  15. package/dist/contracts/activity.js +5 -1
  16. package/dist/contracts/api-keys.js +9 -9
  17. package/dist/contracts/archives.js +11 -11
  18. package/dist/contracts/beta.js +1 -1
  19. package/dist/contracts/builds.js +14 -14
  20. package/dist/contracts/channels.js +2 -2
  21. package/dist/contracts/comments.d.ts +86 -15
  22. package/dist/contracts/comments.js +116 -20
  23. package/dist/contracts/common.d.ts +12 -12
  24. package/dist/contracts/common.js +33 -30
  25. package/dist/contracts/continuation.js +5 -5
  26. package/dist/contracts/data-source-routes.js +1 -1
  27. package/dist/contracts/device-auth.d.ts +6 -6
  28. package/dist/contracts/device-auth.js +12 -12
  29. package/dist/contracts/docs.d.ts +10 -10
  30. package/dist/contracts/domains.js +39 -33
  31. package/dist/contracts/enums.d.ts +2 -10
  32. package/dist/contracts/enums.js +0 -2
  33. package/dist/contracts/error-code-meta.d.ts +116 -47
  34. package/dist/contracts/error-code-meta.js +37 -16
  35. package/dist/contracts/error-codes.d.ts +7 -4
  36. package/dist/contracts/error-codes.js +46 -21
  37. package/dist/contracts/events.d.ts +10 -3
  38. package/dist/contracts/events.js +33 -5
  39. package/dist/contracts/execution.d.ts +26 -0
  40. package/dist/contracts/execution.js +21 -0
  41. package/dist/contracts/feature-lifecycle.d.ts +21 -24
  42. package/dist/contracts/feature-lifecycle.js +28 -26
  43. package/dist/contracts/features.js +4 -4
  44. package/dist/contracts/functions.d.ts +8 -140
  45. package/dist/contracts/functions.js +9 -19
  46. package/dist/contracts/git.d.ts +1 -1
  47. package/dist/contracts/grants.d.ts +96 -79
  48. package/dist/contracts/grants.js +130 -43
  49. package/dist/contracts/ids.d.ts +2 -2
  50. package/dist/contracts/ids.js +2 -4
  51. package/dist/contracts/internal.js +2 -2
  52. package/dist/contracts/mcp.d.ts +17 -556
  53. package/dist/contracts/mcp.js +9 -103
  54. package/dist/contracts/me.js +3 -4
  55. package/dist/contracts/notifications.d.ts +108 -0
  56. package/dist/contracts/notifications.js +54 -0
  57. package/dist/contracts/oauth-resources.d.ts +18 -1
  58. package/dist/contracts/oauth-resources.js +22 -2
  59. package/dist/contracts/operations.d.ts +2 -50
  60. package/dist/contracts/operations.js +0 -19
  61. package/dist/contracts/pages.d.ts +8 -4
  62. package/dist/contracts/pages.js +16 -3
  63. package/dist/contracts/platform.js +10 -8
  64. package/dist/contracts/problem-document.d.ts +14 -0
  65. package/dist/contracts/problem-document.js +35 -0
  66. package/dist/contracts/push-new.d.ts +21 -6
  67. package/dist/contracts/push-new.js +3 -7
  68. package/dist/contracts/resources.d.ts +8 -7
  69. package/dist/contracts/resources.js +9 -6
  70. package/dist/contracts/runtime-api.d.ts +162 -92
  71. package/dist/contracts/runtime-api.js +99 -27
  72. package/dist/contracts/runtime-app.d.ts +41 -11
  73. package/dist/contracts/runtime-app.js +22 -1
  74. package/dist/contracts/runtime-db.d.ts +424 -0
  75. package/dist/contracts/runtime-db.js +108 -0
  76. package/dist/contracts/runtime-storage.d.ts +120 -0
  77. package/dist/contracts/runtime-storage.js +40 -0
  78. package/dist/contracts/sf-config-v1.d.ts +49 -1
  79. package/dist/contracts/sf-config-v1.js +2 -2
  80. package/dist/contracts/sites.d.ts +1 -0
  81. package/dist/contracts/sites.js +20 -12
  82. package/dist/contracts/space-config.d.ts +62 -22
  83. package/dist/contracts/space-config.js +173 -47
  84. package/dist/contracts/spaces.d.ts +79 -45
  85. package/dist/contracts/spaces.js +66 -50
  86. package/dist/contracts/superadmin-spaces.d.ts +13 -2
  87. package/dist/contracts/superadmin-spaces.js +15 -0
  88. package/dist/contracts/superadmin-tenants.js +4 -4
  89. package/dist/contracts/superadmin.d.ts +4 -0
  90. package/dist/contracts/superadmin.js +14 -1
  91. package/dist/contracts/tags.d.ts +17 -17
  92. package/dist/contracts/tags.js +1 -1
  93. package/dist/contracts/teams.js +25 -16
  94. package/dist/contracts/theme-json.js +1 -1
  95. package/dist/contracts/transfers.js +4 -4
  96. package/dist/contracts/variables.js +3 -3
  97. package/dist/contracts/zero.d.ts +204 -338
  98. package/dist/contracts/zero.js +94 -98
  99. package/dist/dashboard-paths/index.d.ts +16 -1
  100. package/dist/dashboard-paths/index.js +18 -0
  101. package/dist/docs/agent-handoff-document.d.ts +2 -2
  102. package/dist/docs/agent-handoff-document.js +8 -7
  103. package/dist/docs/agent-prose.d.ts +22 -3
  104. package/dist/docs/agent-prose.js +221 -51
  105. package/dist/docs/agent-setup.d.ts +13 -10
  106. package/dist/docs/agent-setup.js +279 -53
  107. package/dist/docs/agent-solutions.d.ts +6 -6
  108. package/dist/docs/agent-solutions.js +23 -21
  109. package/dist/docs/catalog.d.ts +29 -74
  110. package/dist/docs/catalog.js +65 -92
  111. package/dist/docs/error-docs.js +293 -221
  112. package/dist/docs/skill-distribution.d.ts +2 -0
  113. package/dist/docs/skill-distribution.js +7 -4
  114. package/dist/docs/skills.d.ts +546 -0
  115. package/dist/docs/skills.js +340 -0
  116. package/dist/utils/browser-credential.d.ts +19 -0
  117. package/dist/utils/browser-credential.js +62 -0
  118. package/dist/utils/comment-avatars.d.ts +7 -0
  119. package/dist/utils/comment-avatars.js +42 -0
  120. package/dist/utils/content-type.d.ts +3 -3
  121. package/dist/utils/content-type.js +38 -61
  122. package/dist/utils/domain-diagnostics.d.ts +5 -5
  123. package/dist/utils/domain-diagnostics.js +21 -10
  124. package/dist/utils/local-space-state.d.ts +78 -4
  125. package/dist/utils/local-space-state.js +383 -82
  126. package/dist/utils/one-shot-replay.d.ts +14 -0
  127. package/dist/utils/one-shot-replay.js +21 -0
  128. package/dist/utils/page-preview.d.ts +7 -0
  129. package/dist/utils/page-preview.js +9 -0
  130. package/dist/utils/pages.d.ts +2 -11
  131. package/dist/utils/pages.js +58 -14
  132. package/dist/utils/publish-form-data.d.ts +22 -0
  133. package/dist/utils/publish-form-data.js +26 -0
  134. package/dist/utils/publish-policy.js +20 -4
  135. package/dist/utils/query-keys.d.ts +7 -4
  136. package/dist/utils/query-keys.js +13 -4
  137. package/dist/utils/runtime-paths.d.ts +3 -0
  138. package/dist/utils/runtime-paths.js +7 -0
  139. package/dist/utils/secure-local-file.d.ts +73 -0
  140. package/dist/utils/secure-local-file.js +1373 -0
  141. package/dist/utils/space-config.d.ts +13 -4
  142. package/dist/utils/space-config.js +123 -15
  143. package/dist/utils/storage-policy.d.ts +20 -0
  144. package/dist/utils/storage-policy.fixtures.json +174 -0
  145. package/dist/utils/storage-policy.js +193 -0
  146. package/dist/utils/upload-session.d.ts +12 -1
  147. package/dist/utils/upload-session.js +37 -2
  148. package/dist/utils/version-file-browser.d.ts +13 -0
  149. package/dist/utils/version-file-browser.js +59 -0
  150. package/package.json +19 -1
  151. package/dist/contracts/mounts.d.ts +0 -142
  152. package/dist/contracts/mounts.js +0 -56
  153. package/dist/utils/asset-fingerprint.d.ts +0 -64
  154. package/dist/utils/asset-fingerprint.js +0 -620
@@ -12,7 +12,7 @@ export const spaceExportRequestSchema = z
12
12
  includeFiles: z
13
13
  .boolean()
14
14
  .default(true)
15
- .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
+ .describe("Pass `true` to include version file trees and compiled serving artifacts. Pass `false` for a config-only archive that is not self-servable and cannot be re-imported."),
16
16
  })
17
17
  .strict();
18
18
  export const spaceExportArchiveSchema = z.object({
@@ -33,8 +33,8 @@ export const spaceExportArchiveSchema = z.object({
33
33
  .describe("SHA-256 of the archive bytes (64 lowercase hex characters), for verification."),
34
34
  });
35
35
  export const spaceExportSchema = z.object({
36
- id: z.string().describe("Export handle id (exp_)."),
37
- spaceId: z.string().describe("Source space id (spc_)."),
36
+ id: z.string().describe("The export handle id (`exp_…`)."),
37
+ spaceId: z.string().describe("The source space id (`spc_…`)."),
38
38
  status: z
39
39
  .enum(["queued", "running", "ready", "failed", "expired"])
40
40
  .describe("Export lifecycle. `expired` means the archive download window has passed."),
@@ -52,8 +52,8 @@ export const spaceExportSchema = z.object({
52
52
  .string()
53
53
  .nullable()
54
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."),
55
+ createdAt: z.string().datetime().describe("Instant when the export handle was created."),
56
+ updatedAt: z.string().datetime().describe("Instant when the export handle last changed."),
57
57
  });
58
58
  export const spaceExportListResponseSchema = z.object({
59
59
  data: z.array(spaceExportSchema),
@@ -81,11 +81,11 @@ export const spaceImportRequestSchema = z.object({
81
81
  publish: z
82
82
  .boolean()
83
83
  .default(false)
84
- .describe("Promote the newest imported version to the live channel once materialized. Imported versions never go public implicitly."),
84
+ .describe("Pass `true` to promote the newest imported version to the live channel after it materializes. Imported versions never go public implicitly."),
85
85
  });
86
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."),
87
+ id: z.string().describe("The import handle id (`imp_…`)."),
88
+ targetSpaceId: z.string().describe("The target space id (`spc_…`) the import materializes into."),
89
89
  status: z
90
90
  .enum([
91
91
  "created",
@@ -99,7 +99,7 @@ export const spaceImportSchema = z.object({
99
99
  .describe("Import lifecycle. Upload-kind imports wait in `waiting_for_archive` until the archive is uploaded and the import is finalized."),
100
100
  archiveUpload: uploadInstructionsSchema
101
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."),
102
+ .describe("Archive upload instructions. This is 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 mints a fresh token."),
103
103
  draftVersionIds: z
104
104
  .array(z.string())
105
105
  .describe("Version ids (ver_…) minted and owned by this import."),
@@ -111,8 +111,8 @@ export const spaceImportSchema = z.object({
111
111
  .string()
112
112
  .nullable()
113
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."),
114
+ createdAt: z.string().datetime().describe("Instant when the import handle was created."),
115
+ updatedAt: z.string().datetime().describe("Instant when the import handle last changed."),
116
116
  });
117
117
  export const spaceImportListResponseSchema = z.object({
118
118
  data: z.array(spaceImportSchema),
@@ -91,7 +91,7 @@ export const SuperadminBetaSignupSchema = z.object({
91
91
  invitedBy: z
92
92
  .string()
93
93
  .nullable()
94
- .describe("Inviting operator's user id; null = auto-approved (Automattician signup)."),
94
+ .describe("Inviting operator user id; null when auto-approved (Automattician signup)."),
95
95
  enrolledUserId: z.string().nullable(),
96
96
  createdAt: z.string().datetime(),
97
97
  });
@@ -27,7 +27,7 @@ export const BuildSettingsSchema = z
27
27
  allowUnsupportedPlatformFeatures: z.boolean().default(false),
28
28
  timeoutSeconds: buildTimeoutSecondsSchema,
29
29
  })
30
- .describe("Resolved build settings. Builds persist this as an immutable settingsSnapshot.");
30
+ .describe("Resolved build settings. Builds persist this as an immutable `settingsSnapshot`.");
31
31
  export const BuildTargetSchema = z
32
32
  .object({
33
33
  channel: z
@@ -39,7 +39,7 @@ export const BuildTargetSchema = z
39
39
  .describe("Channel to promote when the build succeeds; null means no automatic promotion."),
40
40
  preview: z.boolean().default(false).describe("Whether the build targets preview behavior."),
41
41
  })
42
- .describe("Where a successful build should publish or preview.");
42
+ .describe("Where a successful build should publish or run in preview mode.");
43
43
  // Shared by InternalBuildSourceSchema and InternalBuildInputSchema: both carry
44
44
  // this exact archive-source member in their `kind` discriminated union.
45
45
  const internalArchiveBuildSourceSchema = z.object({
@@ -48,7 +48,7 @@ const internalArchiveBuildSourceSchema = z.object({
48
48
  sourceMetadata: z
49
49
  .record(z.string(), z.unknown())
50
50
  .optional()
51
- .describe("Internal source provenance copied to the produced Version."),
51
+ .describe("Internal source provenance copied to the produced version."),
52
52
  objectKey: z.string().optional().describe("Internal staged archive object key."),
53
53
  uploadedAt: z.string().datetime().optional().describe("When the archive finished staging."),
54
54
  recoveredAt: z
@@ -76,7 +76,7 @@ const InternalBuildSourceSchema = z
76
76
  }),
77
77
  internalArchiveBuildSourceSchema,
78
78
  ])
79
- .describe("Legacy internal build source shape retained while build routes migrate to input.");
79
+ .describe("Legacy internal build source shape, retained while build routes migrate to input.");
80
80
  const InternalBuildInputSchema = z
81
81
  .discriminatedUnion("kind", [
82
82
  internalArchiveBuildSourceSchema,
@@ -126,7 +126,7 @@ export const PublicBuildInputSchema = z
126
126
  })
127
127
  .strict(),
128
128
  ])
129
- .describe("Public build input. Internal clone URLs and staged object keys are not exposed.");
129
+ .describe("Public build input. Internal clone URLs and staged object keys are hidden.");
130
130
  export const BuildCreateInputSchema = z
131
131
  .discriminatedUnion("kind", [
132
132
  z
@@ -135,7 +135,7 @@ export const BuildCreateInputSchema = z
135
135
  sourceMetadata: z
136
136
  .record(z.string(), z.unknown())
137
137
  .optional()
138
- .describe("Optional source provenance for the produced Version."),
138
+ .describe("Optional source provenance for the produced version."),
139
139
  })
140
140
  .strict(),
141
141
  z.object({
@@ -153,7 +153,7 @@ export const BuildCreateInputSchema = z
153
153
  // plain string here since the runner's specific phase vocabulary is an
154
154
  // app-level concern, not a shared contract.
155
155
  const buildExecutionPhaseSchema = z.object({
156
- phase: z.string().min(1).describe("Build phase name; see BUILD_PHASES in builds/runner.ts."),
156
+ phase: z.string().min(1).describe("Build phase name. See `BUILD_PHASES` in `builds/runner.ts`."),
157
157
  at: z.string().datetime(),
158
158
  });
159
159
  const buildExecutionLaunchSchema = z.object({
@@ -188,11 +188,11 @@ const InternalBuildExecutionSchema = z
188
188
  phases: z
189
189
  .array(buildExecutionPhaseSchema)
190
190
  .optional()
191
- .describe("Phase timeline the runner appends to via recordBuildPhase."),
191
+ .describe("Phase timeline that the runner appends to with `recordBuildPhase`."),
192
192
  })
193
193
  .describe("Internal runner execution metadata surfaced only where appropriate.");
194
194
  export const BuildSchema = z.object({
195
- id: z.string().describe("Build id (`bld_`); opaque, never derived from a version id."),
195
+ id: z.string().describe("Build id (`bld_`); opaque and never derived from a version id."),
196
196
  spaceId: z.string().describe("Space (`spc_`) the build produces a version for."),
197
197
  status: buildStatus.describe("Build lifecycle status."),
198
198
  input: PublicBuildInputSchema,
@@ -206,12 +206,12 @@ export const BuildSchema = z.object({
206
206
  producedVersionId: z
207
207
  .string()
208
208
  .nullable()
209
- .describe("Version (`ver_`) minted by a succeeded build; null otherwise."),
209
+ .describe("Version (`ver_`) minted by a successful build; null otherwise."),
210
210
  reusedVersionId: z
211
211
  .string()
212
212
  .nullable()
213
213
  .default(null)
214
- .describe("Existing version reused by a succeeded no-change build; null otherwise."),
214
+ .describe("Existing version reused by a successful no-change build; null otherwise."),
215
215
  diagnostics: z.array(baseDiagnosticSchema).default([]),
216
216
  createdAt: z.string().datetime(),
217
217
  startedAt: z.string().datetime().nullable().describe("When the runner picked the build up."),
@@ -221,7 +221,7 @@ export const buildCreateRequestSchema = z.object({
221
221
  input: BuildCreateInputSchema,
222
222
  settings: BuildSettingsSchema.partial()
223
223
  .optional()
224
- .describe("Per-run settings overrides; persisted as settingsSnapshot after resolution."),
224
+ .describe("Per-run settings overrides, persisted as `settingsSnapshot` after resolution."),
225
225
  target: BuildTargetSchema.partial().optional(),
226
226
  diagnostics: z
227
227
  .array(baseDiagnosticSchema)
@@ -253,9 +253,9 @@ export const spaceBuildIntegrationSchema = z
253
253
  .object({
254
254
  branchChannels: z
255
255
  .record(z.string().min(1).describe("Git branch or ref name."), z.literal("live").describe("Channel the branch's builds promote to."))
256
- .describe("Exact branch/ref name to channel name, e.g. { main: 'live' }."),
256
+ .describe("Exact branch or ref name to channel name, for example `{ main: 'live' }`."),
257
257
  })
258
- .describe("Per-space build integration config: where repository builds promote.");
258
+ .describe("Per-space build integration config that defines where repository builds promote.");
259
259
  /** Channel a repository build promotes to, or null when the ref is unmapped (default channel applies). */
260
260
  export function resolveBuildChannel(integration, ref) {
261
261
  return integration?.branchChannels[ref] ?? null;
@@ -21,7 +21,7 @@ export const channelListItemSchema = z.object({
21
21
  .nullable()
22
22
  .optional()
23
23
  .describe("Last version this channel served before the current pointer (rollback target)."),
24
- updatedAt: z.string().datetime().describe("When this channel pointer last moved."),
24
+ updatedAt: z.string().datetime().describe("Instant when this channel pointer last moved."),
25
25
  });
26
26
  // One entry of a channel's promotion history (the deploy log): a single
27
27
  // `channel.promoted` event, newest first. This is the audit trail of every
@@ -40,7 +40,7 @@ export const channelHistoryEntrySchema = z.object({
40
40
  .optional()
41
41
  .describe("Kind of actor that performed the promotion."),
42
42
  actorId: z.string().nullable().optional().describe("Identifier of the promoting actor."),
43
- at: z.string().datetime().describe("When the promotion happened."),
43
+ at: z.string().datetime().describe("Instant when the promotion happened."),
44
44
  });
45
45
  export const channelListResponseSchema = z.object({
46
46
  data: z.array(channelListItemSchema),
@@ -28,9 +28,26 @@ export declare const collaborationGuestProjectionSchema: z.ZodObject<{
28
28
  }>>;
29
29
  }, z.core.$strip>;
30
30
  export type CollaborationGuestProjection = z.infer<typeof collaborationGuestProjectionSchema>;
31
+ export declare const commentsGuestIdentitySchema: z.ZodObject<{
32
+ name: z.ZodString;
33
+ anonymousId: z.ZodString;
34
+ namedByUser: z.ZodBoolean;
35
+ }, z.core.$strip>;
36
+ export declare function commentCapabilitiesOf(capabilities: readonly string[]): CommentCapabilities;
37
+ export declare const collaborationPublicProfileSchema: z.ZodObject<{
38
+ name: z.ZodNullable<z.ZodString>;
39
+ username: z.ZodNullable<z.ZodString>;
40
+ avatar_url: z.ZodNullable<z.ZodURL>;
41
+ }, z.core.$strict>;
42
+ export type CollaborationPublicProfile = z.infer<typeof collaborationPublicProfileSchema>;
31
43
  export declare const collaborationTicketClaimsSchema: z.ZodObject<{
32
44
  sub: z.ZodString;
33
45
  email: z.ZodOptional<z.ZodString>;
46
+ profile: z.ZodOptional<z.ZodObject<{
47
+ name: z.ZodNullable<z.ZodString>;
48
+ username: z.ZodNullable<z.ZodString>;
49
+ avatar_url: z.ZodNullable<z.ZodURL>;
50
+ }, z.core.$strict>>;
34
51
  role: z.ZodEnum<{
35
52
  viewer: "viewer";
36
53
  commenter: "commenter";
@@ -41,12 +58,14 @@ export declare const collaborationTicketClaimsSchema: z.ZodObject<{
41
58
  user: "user";
42
59
  guest: "guest";
43
60
  }>;
61
+ authorities: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
62
  capabilities: z.ZodArray<z.ZodEnum<{
45
63
  "page.view": "page.view";
46
64
  "comments.read": "comments.read";
47
65
  "comments.write": "comments.write";
48
66
  }>>;
49
67
  anonymousId: z.ZodOptional<z.ZodString>;
68
+ grantId: z.ZodOptional<z.ZodString>;
50
69
  namedByUser: z.ZodOptional<z.ZodBoolean>;
51
70
  admittedBy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"anyone">, z.ZodTemplateLiteral<`link:${string}`>, z.ZodTemplateLiteral<`password:${string}`>]>>;
52
71
  emailVerified: z.ZodOptional<z.ZodBoolean>;
@@ -74,6 +93,7 @@ export declare const collaborationSettingsSchema: z.ZodObject<{
74
93
  }, z.core.$strict>;
75
94
  export declare const collaborationSchema: z.ZodObject<{
76
95
  spaceId: z.ZodString;
96
+ revision: z.ZodNumber;
77
97
  enabled: z.ZodBoolean;
78
98
  castResourceId: z.ZodNullable<z.ZodString>;
79
99
  castResourceKey: z.ZodNullable<z.ZodString>;
@@ -90,15 +110,16 @@ export declare const collaborationSchema: z.ZodObject<{
90
110
  updatedAt: z.ZodNullable<z.ZodString>;
91
111
  }, z.core.$strip>;
92
112
  export declare const collaborationUpdateSchema: z.ZodObject<{
93
- enabled: z.ZodBoolean;
113
+ expectedRevision: z.ZodNumber;
114
+ enabled: z.ZodOptional<z.ZodBoolean>;
94
115
  settings: z.ZodOptional<z.ZodObject<{
95
116
  spamFilterEnabled: z.ZodOptional<z.ZodBoolean>;
96
117
  publishedComments: z.ZodOptional<z.ZodBoolean>;
97
118
  notificationPreferences: z.ZodOptional<z.ZodObject<{
98
- newThreads: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
99
- newReplies: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
100
- statusChanges: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
101
- }, z.core.$strip>>;
119
+ newThreads: z.ZodOptional<z.ZodBoolean>;
120
+ newReplies: z.ZodOptional<z.ZodBoolean>;
121
+ statusChanges: z.ZodOptional<z.ZodBoolean>;
122
+ }, z.core.$strict>>;
102
123
  }, z.core.$strict>>;
103
124
  }, z.core.$strip>;
104
125
  export declare const commentsTicketRequestSchema: z.ZodObject<{
@@ -106,6 +127,11 @@ export declare const commentsTicketRequestSchema: z.ZodObject<{
106
127
  pagePath: z.ZodDefault<z.ZodString>;
107
128
  origin: z.ZodString;
108
129
  versionId: z.ZodOptional<z.ZodString>;
130
+ identity: z.ZodOptional<z.ZodObject<{
131
+ name: z.ZodString;
132
+ anonymousId: z.ZodString;
133
+ namedByUser: z.ZodBoolean;
134
+ }, z.core.$strip>>;
109
135
  }, z.core.$strip>;
110
136
  export declare const commentsTicketResponseSchema: z.ZodObject<{
111
137
  token: z.ZodString;
@@ -150,15 +176,6 @@ export declare const noticePublishResponseSchema: z.ZodObject<{
150
176
  event: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
151
177
  broadcast: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
152
178
  }, z.core.$strip>;
153
- export declare const collabOverlayConfigQuerySchema: z.ZodObject<{
154
- path: z.ZodOptional<z.ZodString>;
155
- versionId: z.ZodOptional<z.ZodString>;
156
- host: z.ZodOptional<z.ZodString>;
157
- }, z.core.$strip>;
158
- export declare const collabOverlayConfigSchema: z.ZodObject<{
159
- enabled: z.ZodBoolean;
160
- surface_url: z.ZodNullable<z.ZodString>;
161
- }, z.core.$strip>;
162
179
  export declare const COLLAB_VERSION_URLS_MAX_IDS = 50;
163
180
  export declare const collabVersionUrlSchema: z.ZodObject<{
164
181
  id: z.ZodString;
@@ -169,10 +186,37 @@ export declare const collabVersionUrlSchema: z.ZodObject<{
169
186
  export declare const commentAuthorSchema: z.ZodObject<{
170
187
  kind: z.ZodNullable<z.ZodString>;
171
188
  id: z.ZodNullable<z.ZodString>;
189
+ profileId: z.ZodNullable<z.ZodString>;
172
190
  name: z.ZodNullable<z.ZodString>;
191
+ username: z.ZodNullable<z.ZodString>;
192
+ avatarUrl: z.ZodNullable<z.ZodURL>;
173
193
  color: z.ZodNullable<z.ZodString>;
174
194
  }, z.core.$strip>;
175
195
  export declare const commentTargetSchema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
196
+ export declare const commentReactionActorSchema: z.ZodObject<{
197
+ name: z.ZodNullable<z.ZodString>;
198
+ }, z.core.$strip>;
199
+ export declare const commentReactionEntrySchema: z.ZodObject<{
200
+ count: z.ZodNumber;
201
+ actors: z.ZodRecord<z.ZodString, z.ZodObject<{
202
+ name: z.ZodNullable<z.ZodString>;
203
+ }, z.core.$strip>>;
204
+ }, z.core.$strip>;
205
+ export declare const COMMENT_REACTION_EMOJIS: readonly ["👍", "❤️", "🎉", "👀", "🚀", "🙏"];
206
+ export declare const commentReactionUpdateSchema: z.ZodObject<{
207
+ emoji: z.ZodEnum<{
208
+ "\uD83D\uDC4D": "👍";
209
+ "\u2764\uFE0F": "❤️";
210
+ "\uD83C\uDF89": "🎉";
211
+ "\uD83D\uDC40": "👀";
212
+ "\uD83D\uDE80": "🚀";
213
+ "\uD83D\uDE4F": "🙏";
214
+ }>;
215
+ op: z.ZodEnum<{
216
+ remove: "remove";
217
+ add: "add";
218
+ }>;
219
+ }, z.core.$strip>;
176
220
  export declare const commentThreadSchema: z.ZodObject<{
177
221
  id: z.ZodString;
178
222
  castThreadId: z.ZodString;
@@ -196,10 +240,19 @@ export declare const commentThreadSchema: z.ZodObject<{
196
240
  author: z.ZodNullable<z.ZodObject<{
197
241
  kind: z.ZodNullable<z.ZodString>;
198
242
  id: z.ZodNullable<z.ZodString>;
243
+ profileId: z.ZodNullable<z.ZodString>;
199
244
  name: z.ZodNullable<z.ZodString>;
245
+ username: z.ZodNullable<z.ZodString>;
246
+ avatarUrl: z.ZodNullable<z.ZodURL>;
200
247
  color: z.ZodNullable<z.ZodString>;
201
248
  }, z.core.$strip>>;
202
249
  target: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
250
+ reactions: z.ZodRecord<z.ZodString, z.ZodObject<{
251
+ count: z.ZodNumber;
252
+ actors: z.ZodRecord<z.ZodString, z.ZodObject<{
253
+ name: z.ZodNullable<z.ZodString>;
254
+ }, z.core.$strip>>;
255
+ }, z.core.$strip>>;
203
256
  comments: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
204
257
  permalink: z.ZodNullable<z.ZodString>;
205
258
  updatedAt: z.ZodNullable<z.ZodString>;
@@ -247,6 +300,16 @@ export declare const commentScreenshotSchema: z.ZodObject<{
247
300
  url: z.ZodString;
248
301
  expiresAt: z.ZodString;
249
302
  }, z.core.$strip>;
303
+ export declare const commentScreenshotRefreshSchema: z.ZodObject<{
304
+ versionId: z.ZodString;
305
+ pagePath: z.ZodDefault<z.ZodString>;
306
+ key: z.ZodString;
307
+ }, z.core.$strip>;
308
+ export declare const commentScreenshotRefreshResponseSchema: z.ZodObject<{
309
+ key: z.ZodString;
310
+ url: z.ZodString;
311
+ expiresAt: z.ZodString;
312
+ }, z.core.$strip>;
250
313
  export declare const commentReplySchema: z.ZodObject<{
251
314
  body: z.ZodString;
252
315
  idempotencyKey: z.ZodOptional<z.ZodString>;
@@ -291,10 +354,19 @@ export declare const commentListResponseSchema: z.ZodObject<{
291
354
  author: z.ZodNullable<z.ZodObject<{
292
355
  kind: z.ZodNullable<z.ZodString>;
293
356
  id: z.ZodNullable<z.ZodString>;
357
+ profileId: z.ZodNullable<z.ZodString>;
294
358
  name: z.ZodNullable<z.ZodString>;
359
+ username: z.ZodNullable<z.ZodString>;
360
+ avatarUrl: z.ZodNullable<z.ZodURL>;
295
361
  color: z.ZodNullable<z.ZodString>;
296
362
  }, z.core.$strip>>;
297
363
  target: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
364
+ reactions: z.ZodRecord<z.ZodString, z.ZodObject<{
365
+ count: z.ZodNumber;
366
+ actors: z.ZodRecord<z.ZodString, z.ZodObject<{
367
+ name: z.ZodNullable<z.ZodString>;
368
+ }, z.core.$strip>>;
369
+ }, z.core.$strip>>;
298
370
  comments: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
299
371
  permalink: z.ZodNullable<z.ZodString>;
300
372
  updatedAt: z.ZodNullable<z.ZodString>;
@@ -313,6 +385,5 @@ export declare const commentExportResponseSchema: z.ZodObject<{
313
385
  }, z.core.$strip>;
314
386
  export type Collaboration = z.infer<typeof collaborationSchema>;
315
387
  export type CollaborationUpdate = z.infer<typeof collaborationUpdateSchema>;
316
- export type CollabOverlayConfig = z.infer<typeof collabOverlayConfigSchema>;
317
388
  export type CollabVersionUrl = z.infer<typeof collabVersionUrlSchema>;
318
389
  export type CommentThread = z.infer<typeof commentThreadSchema>;
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { accessRoleSchema } from "./access.js";
2
+ import { accessRoleSchema, authorityReferenceSchema } from "./access.js";
3
3
  import { CursorPaginationSchema, cursorListQuerySchema } from "./common.js";
4
4
  export const commentThreadStatusSchema = z.enum(["open", "archived"]);
5
5
  export const COMMENT_SEARCH_QUERY_MAX_LENGTH = 160;
@@ -32,7 +32,14 @@ export const commentCapabilitiesSchema = z
32
32
  });
33
33
  export const collaborationGuestProjectionSchema = z.object({
34
34
  anonymousId: z.string().min(8).max(160),
35
- name: z.string().trim().min(1).max(160),
35
+ // No control or format characters: newlines, bidi overrides, and zero-width
36
+ // joiners in a self-asserted display name are only ever spoofing material.
37
+ name: z
38
+ .string()
39
+ .trim()
40
+ .min(1)
41
+ .max(160)
42
+ .regex(/^[^\p{Cc}\p{Cf}]+$/u),
36
43
  namedByUser: z.boolean(),
37
44
  grantId: z.string().min(1).max(128),
38
45
  admittedBy: z.union([
@@ -43,14 +50,41 @@ export const collaborationGuestProjectionSchema = z.object({
43
50
  emailVerified: z.boolean().default(false),
44
51
  capabilities: commentCapabilitiesSchema,
45
52
  });
53
+ // The identity a browser asserts when requesting a guest ticket — the
54
+ // self-asserted subset of the guest projection.
55
+ export const commentsGuestIdentitySchema = collaborationGuestProjectionSchema.pick({
56
+ anonymousId: true,
57
+ name: true,
58
+ namedByUser: true,
59
+ });
60
+ export function commentCapabilitiesOf(capabilities) {
61
+ return capabilities.filter((capability) => COMMENT_CAPABILITIES.includes(capability));
62
+ }
63
+ // The only account metadata exposed to Comments clients. Keep this shape
64
+ // deliberately smaller than the private account record carried server-side.
65
+ export const collaborationPublicProfileSchema = z
66
+ .object({
67
+ name: z.string().trim().min(1).max(120).nullable(),
68
+ username: z.string().trim().min(1).max(160).nullable(),
69
+ avatar_url: z
70
+ .url({ protocol: /^https?$/ })
71
+ .max(2_048)
72
+ .nullable(),
73
+ })
74
+ .strict();
46
75
  export const collaborationTicketClaimsSchema = z
47
76
  .object({
48
77
  sub: z.string().min(1),
49
78
  email: z.string().email().optional(),
79
+ profile: collaborationPublicProfileSchema.optional(),
50
80
  role: accessRoleSchema,
81
+ // The session's principal, never the class of authority that admitted it:
82
+ // a signed-in account is "user" even when a share Link carried it in.
51
83
  actorKind: z.enum(["user", "guest"]),
84
+ authorities: z.array(authorityReferenceSchema).max(16).optional(),
52
85
  capabilities: commentCapabilitiesSchema,
53
86
  anonymousId: z.string().min(8).max(160).optional(),
87
+ grantId: z.string().min(1).max(128).optional(),
54
88
  namedByUser: z.boolean().optional(),
55
89
  admittedBy: z
56
90
  .union([
@@ -73,7 +107,18 @@ export const collaborationTicketClaimsSchema = z
73
107
  .superRefine((claims, context) => {
74
108
  if (claims.actorKind !== "guest")
75
109
  return;
76
- for (const field of ["anonymousId", "namedByUser", "admittedBy", "emailVerified"]) {
110
+ // A guest ticket names an anonymous browser identity, and one grant always
111
+ // admitted it: the guest projection the mint builds carries all five of
112
+ // these or it is not a guest at all. Capabilities still come from the union
113
+ // of every authority the session holds — the admitting grant describes the
114
+ // admission, not the reach.
115
+ for (const field of [
116
+ "anonymousId",
117
+ "grantId",
118
+ "namedByUser",
119
+ "admittedBy",
120
+ "emailVerified",
121
+ ]) {
77
122
  if (claims[field] === undefined) {
78
123
  context.addIssue({
79
124
  code: "custom",
@@ -82,6 +127,18 @@ export const collaborationTicketClaimsSchema = z
82
127
  });
83
128
  }
84
129
  }
130
+ // Identity never follows from an authority, but the reverse still holds:
131
+ // an anonymous principal can only ever have acquired credential-class
132
+ // authorities. Account-class references on a guest ticket are a forgery.
133
+ for (const [index, authority] of (claims.authorities ?? []).entries()) {
134
+ if (!authority.startsWith("link:") && !authority.startsWith("password:")) {
135
+ context.addIssue({
136
+ code: "custom",
137
+ path: ["authorities", index],
138
+ message: "a guest ticket carries only link or password authorities",
139
+ });
140
+ }
141
+ }
85
142
  });
86
143
  export const collaborationSettingsSchema = z
87
144
  .object({
@@ -89,7 +146,8 @@ export const collaborationSettingsSchema = z
89
146
  // Whether comments are surfaced on the live/published host (vs preview-only).
90
147
  // The published loader (SPACEFAST-CAST-PLAN §4.2) mounts the orb on a live
91
148
  // host only when this is true; toggling it never requires a republish — the
92
- // always-injected inert tag reads behavior from the ETag'd overlay-config.
149
+ // always-injected inert tag re-reads it through the runtime's same-origin
150
+ // Comments config exchange on every load.
93
151
  publishedComments: z.boolean().optional(),
94
152
  notificationPreferences: z
95
153
  .object({
@@ -101,8 +159,23 @@ export const collaborationSettingsSchema = z
101
159
  .optional(),
102
160
  })
103
161
  .strict();
162
+ const collaborationSettingsPatchSchema = z
163
+ .object({
164
+ spamFilterEnabled: z.boolean().optional(),
165
+ publishedComments: z.boolean().optional(),
166
+ notificationPreferences: z
167
+ .object({
168
+ newThreads: z.boolean().optional(),
169
+ newReplies: z.boolean().optional(),
170
+ statusChanges: z.boolean().optional(),
171
+ })
172
+ .strict()
173
+ .optional(),
174
+ })
175
+ .strict();
104
176
  export const collaborationSchema = z.object({
105
177
  spaceId: z.string(),
178
+ revision: z.number().int().nonnegative(),
106
179
  enabled: z.boolean(),
107
180
  castResourceId: z.string().nullable(),
108
181
  castResourceKey: z.string().nullable(),
@@ -110,15 +183,21 @@ export const collaborationSchema = z.object({
110
183
  createdAt: z.string().datetime().nullable(),
111
184
  updatedAt: z.string().datetime().nullable(),
112
185
  });
113
- export const collaborationUpdateSchema = z.object({
114
- enabled: z.boolean(),
115
- settings: collaborationSettingsSchema.optional(),
186
+ export const collaborationUpdateSchema = z
187
+ .object({
188
+ expectedRevision: z.number().int().nonnegative(),
189
+ enabled: z.boolean().optional(),
190
+ settings: collaborationSettingsPatchSchema.optional(),
191
+ })
192
+ .refine((update) => update.enabled !== undefined || update.settings !== undefined, {
193
+ message: "At least one collaboration field is required",
116
194
  });
117
195
  export const commentsTicketRequestSchema = z.object({
118
196
  spaceId: z.string().min(1),
119
197
  pagePath: z.string().min(1).max(COMMENT_PAGE_PATH_MAX_LENGTH).default("/"),
120
198
  origin: z.string().url(),
121
199
  versionId: z.string().min(1).optional(),
200
+ identity: commentsGuestIdentitySchema.optional(),
122
201
  });
123
202
  export const commentsTicketResponseSchema = z.object({
124
203
  token: z.string(),
@@ -155,19 +234,7 @@ export const noticePublishResponseSchema = z.object({
155
234
  event: z.record(z.string(), z.unknown()).nullable(),
156
235
  broadcast: z.record(z.string(), z.unknown()).nullable(),
157
236
  });
158
- export const collabOverlayConfigQuerySchema = z.object({
159
- path: z.string().min(1).max(COMMENT_PAGE_PATH_MAX_LENGTH).optional(),
160
- versionId: z.string().min(1).optional(),
161
- host: z.string().min(1).optional(),
162
- });
163
- // Customer pages receive launcher state only. Room ids, Cast endpoints, resource
164
- // keys, tickets, and platform session state never cross the customer-origin
165
- // boundary.
166
- export const collabOverlayConfigSchema = z.object({
167
- enabled: z.boolean(),
168
- surface_url: z.string().url().nullable(),
169
- });
170
- // Cross-version navigation directory: the platform Comments page asks for the
237
+ // Cross-version navigation directory: the Comments overlay asks for the
171
238
  // immutable URLs of version ids present in a room's threads.
172
239
  export const COLLAB_VERSION_URLS_MAX_IDS = 50;
173
240
  export const collabVersionUrlSchema = z.object({
@@ -181,10 +248,28 @@ export const collabVersionUrlSchema = z.object({
181
248
  export const commentAuthorSchema = z.object({
182
249
  kind: z.string().nullable(),
183
250
  id: z.string().nullable(),
251
+ profileId: z.string().nullable(),
184
252
  name: z.string().nullable(),
253
+ username: z.string().max(160).nullable(),
254
+ avatarUrl: z
255
+ .url({ protocol: /^https?$/ })
256
+ .max(2_048)
257
+ .nullable(),
185
258
  color: z.string().max(64).nullable(),
186
259
  });
187
260
  export const commentTargetSchema = z.record(z.string(), z.unknown()).nullable();
261
+ export const commentReactionActorSchema = z.object({
262
+ name: z.string().nullable(),
263
+ });
264
+ export const commentReactionEntrySchema = z.object({
265
+ count: z.number().int().min(0),
266
+ actors: z.record(z.string(), commentReactionActorSchema),
267
+ });
268
+ export const COMMENT_REACTION_EMOJIS = ["👍", "❤️", "🎉", "👀", "🚀", "🙏"];
269
+ export const commentReactionUpdateSchema = z.object({
270
+ emoji: z.enum(COMMENT_REACTION_EMOJIS),
271
+ op: z.enum(["add", "remove"]),
272
+ });
188
273
  export const commentThreadSchema = z.object({
189
274
  id: z.string(),
190
275
  castThreadId: z.string(),
@@ -201,6 +286,7 @@ export const commentThreadSchema = z.object({
201
286
  body: z.string().nullable(),
202
287
  author: commentAuthorSchema.nullable(),
203
288
  target: commentTargetSchema,
289
+ reactions: z.record(z.string(), commentReactionEntrySchema),
204
290
  comments: z.array(z.record(z.string(), z.unknown())),
205
291
  permalink: z.string().nullable(),
206
292
  updatedAt: z.string().datetime().nullable(),
@@ -237,6 +323,16 @@ export const commentScreenshotSchema = z.object({
237
323
  url: z.string().url(),
238
324
  expiresAt: z.string().datetime(),
239
325
  });
326
+ export const commentScreenshotRefreshSchema = z.object({
327
+ versionId: z.string().min(1),
328
+ pagePath: z.string().min(1).max(COMMENT_PAGE_PATH_MAX_LENGTH).default("/"),
329
+ key: z.string().min(1).max(2_048),
330
+ });
331
+ export const commentScreenshotRefreshResponseSchema = z.object({
332
+ key: z.string(),
333
+ url: z.string().url(),
334
+ expiresAt: z.string().datetime(),
335
+ });
240
336
  export const commentReplySchema = z.object({
241
337
  body: z.string().min(1).max(16_000),
242
338
  idempotencyKey: z.string().min(1).max(320).optional(),