@kardalum/plugin-sdk 0.15.0 → 0.16.0

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 (101) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +10 -0
  3. package/dist/built-in-value-schemas.js +1 -1
  4. package/dist/built-ins.js +2 -2
  5. package/dist/capabilities.d.ts +8 -78
  6. package/dist/capabilities.js +23 -319
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.js +5 -4
  9. package/dist/license-verdict-keys.js +4 -0
  10. package/dist/manifest-entry.d.ts +2 -2
  11. package/dist/manifest-entry.js +1 -1
  12. package/dist/manifest-schema.d.ts +81 -13
  13. package/dist/manifest-schema.js +108 -59
  14. package/dist/manifest.d.ts +105 -40
  15. package/dist/media/media-picker.js +21 -12
  16. package/dist/media/upload-error.d.ts +1 -1
  17. package/dist/media/upload-error.js +1 -1
  18. package/dist/plugin-context.d.ts +7 -0
  19. package/dist/plugin-context.js +7 -0
  20. package/dist/plugin-screen-context.d.ts +33 -2
  21. package/dist/plugin-screen-context.js +27 -2
  22. package/dist/read-all-pages.d.ts +23 -0
  23. package/dist/read-all-pages.js +30 -0
  24. package/dist/richtext/block-panel.js +4 -4
  25. package/dist/richtext/insert-menu.js +3 -3
  26. package/dist/views/content-list-view.js +2 -2
  27. package/dist/views/image-view.js +24 -39
  28. package/dist/views/rich-text-view.js +2 -2
  29. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
  30. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
  31. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
  32. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
  33. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +1 -1
  34. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
  35. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +12 -8
  36. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
  37. package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
  38. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
  39. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +107 -57
  40. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +96 -60
  41. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
  42. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
  43. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
  44. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +39 -28
  45. package/node_modules/@kardalum/api-schemas/dist/index.js +19 -13
  46. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  47. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  48. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +302 -1
  49. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +78 -6
  50. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
  51. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
  52. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
  53. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
  54. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +82 -2
  55. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
  56. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +88 -5
  57. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +79 -17
  58. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  59. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  60. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
  61. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
  62. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
  63. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
  64. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +25 -3
  65. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +21 -1
  66. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +7 -0
  67. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +16 -3
  68. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
  69. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
  70. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
  71. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +11 -1
  72. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
  73. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +6 -0
  74. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +6 -0
  75. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
  76. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
  77. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
  78. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
  79. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +8 -8
  80. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +8 -8
  81. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +4 -0
  82. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +2 -0
  83. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +4 -4
  84. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +11 -3
  85. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +5 -0
  86. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
  87. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
  88. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  89. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
  90. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +3 -1
  91. package/node_modules/@kardalum/plugin-package/dist/index.js +2 -1
  92. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
  93. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
  94. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -1
  95. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +56 -16
  96. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
  97. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
  98. package/node_modules/@kardalum/plugin-package/package.json +5 -0
  99. package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
  100. package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
  101. package/package.json +2 -2
@@ -1,7 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import { PluginActionDeclarationSchema, PluginRoleOfferSchema } from "./plugin-actions.schema.js";
3
- import { MANIFEST_ID_SEGMENT_MAX, PLUGIN_ID_REGEX } from "./plugin-id-rules.js";
3
+ import { MANIFEST_ID_SEGMENT_MAX, PLUGIN_ID_REGEX, isPluginManifestId } from "./plugin-id-rules.js";
4
4
  import { SampleContentOutcomeSchema } from "./sample-content-outcome.schema.js";
5
+ import { InstallAnswersSchema, InstallInterfaceWireSchema } from "./plugin-install.js";
6
+ import { InstallRoleOutcomeSchema } from "./plugin-install-record.schema.js";
5
7
  // S268 Task 5: one derived capability, the wire form of the SDK's
6
8
  // `Capability` (packages/plugin-sdk/src/capabilities.ts, which the
7
9
  // marketplace computes at ingest). Deliberately NOT imported from there:
@@ -63,12 +65,19 @@ export const MarketplaceListingSchema = z.object({
63
65
  // Computed SERVER-SIDE against this CMS's active dialect — the admin
64
66
  // client never guesses compatibility from raw dialect lists.
65
67
  compatible: z.boolean(),
68
+ // S304-94: whether this CMS satisfies the latest version's cmsVersion range,
69
+ // decided server-side with the running version. A newer version that fails
70
+ // it is not offered as an update; a fresh install is not gated by it.
71
+ cmsCompatible: z.boolean(),
66
72
  // S274c: the version installed on THIS CMS, or null when the listing is not
67
73
  // installed. Looked up server-side from the registry, never guessed client-side.
68
74
  installedVersion: z.string().nullable(),
69
- // S274c: true only when the listing's latest version is strictly newer than
70
- // the installed one (semver, decided server-side). A newer or unreadable
71
- // installed version is never offered as an "update".
75
+ // S274c, S294 (2026-10-14-s294-update-available-design.md 3.2): true only
76
+ // when this site can take the listing as an update, decided server-side by
77
+ // the rule the installed list's badge uses too: the plugin is installed and
78
+ // is not a bundle, and the listing's latest published version is strictly
79
+ // newer by semver, has a package to download and supports this site's
80
+ // database. A newer or unreadable installed version is never an "update".
72
81
  updateAvailable: z.boolean(),
73
82
  });
74
83
  // S148: a starter frontend the marketplace hosts as a versioned archive
@@ -112,6 +121,12 @@ export const MarketplaceListingDetailVersionSchema = MarketplaceListingVersionSc
112
121
  // extending rather than widening is what keeps it off the browse screen,
113
122
  // where the browse handler's response validation strips it back off.
114
123
  readme: z.string().nullable().optional(),
124
+ // S292: what the install asks, derived by the marketplace at ingest.
125
+ // Detail-only, like readme, so it never reaches the browse screen; null for
126
+ // a version ingested before S292. Read through InstallInterfaceWireSchema,
127
+ // which drops a key a newer marketplace adds instead of refusing it, so an
128
+ // older CMS still answers with the listing.
129
+ installInterface: InstallInterfaceWireSchema.nullable().optional(),
115
130
  });
116
131
  export const MarketplaceListingDetailSchema = MarketplaceListingSchema.extend({
117
132
  latestVersion: MarketplaceListingDetailVersionSchema.nullable(),
@@ -143,6 +158,55 @@ export const MarketplaceListResponseSchema = z.object({
143
158
  activeDialect: z.string(),
144
159
  marketplaceBaseUrl: z.string(),
145
160
  });
161
+ /** S294 (2026-10-14-s294-update-available-design.md 3.1): the most plugin ids
162
+ * one GET /api/v1/listings/versions request names. */
163
+ export const MARKETPLACE_VERSIONS_MAX_IDS = 50;
164
+ /** The longest `ids` value that route reads before splitting it. A manifest id
165
+ * has no length cap of its own, so a long enough id could make fifty overrun
166
+ * this; the CMS's client therefore sends no id longer than 199 characters,
167
+ * so that fifty of them and their 49 commas (9,999 characters) always fit. */
168
+ export const MARKETPLACE_VERSIONS_IDS_MAX_LENGTH = 10_000;
169
+ /** What a CMS decides an update with: a listing's latest published version,
170
+ * reduced to four facts. */
171
+ export const MarketplaceLatestVersionSchema = MarketplaceListingVersionSchema.pick({
172
+ version: true,
173
+ cmsVersion: true,
174
+ supportedDialects: true,
175
+ hasArtifact: true,
176
+ });
177
+ /** One item per published listing among the ids asked, in the order asked; an
178
+ * id with no published version is absent. Not strict: a key a newer
179
+ * marketplace adds is dropped, never fatal. */
180
+ export const MarketplaceVersionsResponseSchema = z.object({
181
+ items: z
182
+ .array(z.object({ pluginId: z.string(), latestVersion: MarketplaceLatestVersionSchema }))
183
+ .max(MARKETPLACE_VERSIONS_MAX_IDS),
184
+ });
185
+ /** The route's `ids` value, by the table in 3.1: capped before it is split,
186
+ * each entry checked with isPluginManifestId, a repeat answered once, in the
187
+ * place it first appears. The value is untrusted, so the order bounds the
188
+ * cost: the length cap comes before the split and the entry cap before any
189
+ * entry is checked, so the one pattern that runs (isPluginManifestId's, which
190
+ * the install door already applies to untrusted ids) sees at most
191
+ * MARKETPLACE_VERSIONS_MAX_IDS entries and MARKETPLACE_VERSIONS_IDS_MAX_LENGTH
192
+ * characters in all. Both caps count what was sent, before repeats collapse.
193
+ * Nothing is trimmed: a space or an empty entry is a bad id. */
194
+ export function parseMarketplaceVersionsIds(raw) {
195
+ if (raw === null || raw === "") {
196
+ return { ok: false, error: `ids is required: 1 to ${MARKETPLACE_VERSIONS_MAX_IDS} comma-separated plugin ids` };
197
+ }
198
+ if (raw.length > MARKETPLACE_VERSIONS_IDS_MAX_LENGTH) {
199
+ return { ok: false, error: `ids is longer than ${MARKETPLACE_VERSIONS_IDS_MAX_LENGTH} characters` };
200
+ }
201
+ const entries = raw.split(",");
202
+ if (entries.length > MARKETPLACE_VERSIONS_MAX_IDS) {
203
+ return { ok: false, error: `ids names more than ${MARKETPLACE_VERSIONS_MAX_IDS} plugin ids` };
204
+ }
205
+ if (!entries.every((entry) => isPluginManifestId(entry))) {
206
+ return { ok: false, error: "every entry in ids must be a plugin id such as com.example.plugin" };
207
+ }
208
+ return { ok: true, ids: [...new Set(entries)] };
209
+ }
146
210
  export const MarketplacePluginIdParamsSchema = z.object({ pluginId: z.string().min(1) });
147
211
  // Path-safety gate: pluginId reaches removePluginPackages, which builds a
148
212
  // path from it and does a recursive, forced rmSync. Without this, a bare
@@ -151,7 +215,10 @@ export const MarketplacePluginIdParamsSchema = z.object({ pluginId: z.string().m
151
215
  // rule (PLUGIN_ID_REGEX and the segment cap), not a looser copy: a case
152
216
  // variant such as "COM.KARDALUM.SEO" names another plugin's folder on a
153
217
  // case-insensitive filesystem.
154
- export const MarketplaceInstallBodySchema = z.object({
218
+ // S293: strict, so a misspelt `answers` is refused rather than dropped and the
219
+ // defaults installed.
220
+ export const MarketplaceInstallBodySchema = z
221
+ .object({
155
222
  pluginId: z
156
223
  .string()
157
224
  .min(1)
@@ -159,7 +226,9 @@ export const MarketplaceInstallBodySchema = z.object({
159
226
  .refine((id) => id.split(".").length <= MANIFEST_ID_SEGMENT_MAX, `pluginId has at most ${MANIFEST_ID_SEGMENT_MAX} segments`),
160
227
  version: z.string().min(1),
161
228
  licenseKey: z.string().min(1).optional(),
162
- });
229
+ answers: InstallAnswersSchema.optional(),
230
+ })
231
+ .strict();
163
232
  // S152: a bundle install reports what its fan-out did per member —
164
233
  // "installed" (this operation installed it, ownership recorded) or
165
234
  // "already-installed" (pre-existing, skipped, never claimed). Optional
@@ -185,6 +254,9 @@ export const MarketplaceInstallResponseSchema = z.object({
185
254
  // S277e: what the install did with the plugin's own sample content.
186
255
  // Absent for an update and for a plugin that ships none.
187
256
  sampleContent: SampleContentOutcomeSchema.optional(),
257
+ // S293: what the install did with each offered role its answers named;
258
+ // absent when they named none.
259
+ roles: z.array(InstallRoleOutcomeSchema).optional(),
188
260
  });
189
261
  /** The 409 a marketplace install or update answers. `reason` is present
190
262
  * only for "license-not-recorded" (S284, D4): the plugin IS installed (or
@@ -9,6 +9,13 @@ export declare const UpdateMediaFolderRequestSchema: z.ZodObject<{
9
9
  parentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
10
  }, z.core.$strip>;
11
11
  export type UpdateMediaFolderRequest = z.infer<typeof UpdateMediaFolderRequestSchema>;
12
+ /** The most items one page of a media folder, version or rendition list holds, and the default (S300b). */
13
+ export declare const MEDIA_NESTED_LIST_PAGE_MAX = 200;
14
+ export declare const MediaNestedListQuerySchema: z.ZodObject<{
15
+ cursor: z.ZodOptional<z.ZodString>;
16
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
17
+ }, z.core.$strip>;
18
+ export type MediaNestedListQuery = z.infer<typeof MediaNestedListQuerySchema>;
12
19
  export declare const MediaFolderListResponseSchema: z.ZodObject<{
13
20
  folders: z.ZodArray<z.ZodObject<{
14
21
  id: z.ZodString;
@@ -16,6 +23,7 @@ export declare const MediaFolderListResponseSchema: z.ZodObject<{
16
23
  parentId: z.ZodNullable<z.ZodString>;
17
24
  createdAt: z.ZodString;
18
25
  }, z.core.$strip>>;
26
+ nextCursor: z.ZodNullable<z.ZodString>;
19
27
  }, z.core.$strip>;
20
28
  export type MediaFolderListResponse = z.infer<typeof MediaFolderListResponseSchema>;
21
29
  export declare const MediaFileResponseSchema: z.ZodObject<{
@@ -104,6 +112,7 @@ export declare const MediaVersionListResponseSchema: z.ZodObject<{
104
112
  createdByName: z.ZodNullable<z.ZodString>;
105
113
  }, z.core.$strip>>;
106
114
  currentVersion: z.ZodNumber;
115
+ nextCursor: z.ZodNullable<z.ZodString>;
107
116
  }, z.core.$strip>;
108
117
  export type MediaVersionListResponse = z.infer<typeof MediaVersionListResponseSchema>;
109
118
  export declare const MediaRenditionListResponseSchema: z.ZodObject<{
@@ -125,6 +134,7 @@ export declare const MediaRenditionListResponseSchema: z.ZodObject<{
125
134
  createdAt: z.ZodString;
126
135
  }, z.core.$strip>>;
127
136
  currentVersion: z.ZodNumber;
137
+ nextCursor: z.ZodNullable<z.ZodString>;
128
138
  }, z.core.$strip>;
129
139
  export type MediaRenditionListResponse = z.infer<typeof MediaRenditionListResponseSchema>;
130
140
  export declare const MediaTrashListQuerySchema: z.ZodObject<{
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { MediaFileSchema, MediaFolderSchema, MediaVersionSchema, MediaVisibilitySchema } from "./media.schema.js";
3
3
  import { MediaRenditionSchema } from "./media-rendition.schema.js";
4
- // POST /api/media/folders body (S186e §2) — name required, parentId
4
+ // POST /api/manage/v1/media/folders body (S186e §2): name required, parentId
5
5
  // optional (omitted/undefined = create at the library root). Duplicate
6
6
  // name under the same parent -> 409, enforced by a real database
7
7
  // constraint as of the fix wave (HIGH-1 — see media-service.ts's
@@ -12,7 +12,7 @@ export const CreateMediaFolderRequestSchema = z.object({
12
12
  name: z.string().min(1),
13
13
  parentId: z.string().uuid().optional(),
14
14
  });
15
- // PATCH /api/media/folders/:id body (S186e §2) — rename and/or move, both
15
+ // PATCH /api/manage/v1/media/folders/:id body (S186e §2): rename and/or move, both
16
16
  // optional and independent. name absent = don't rename. parentId absent =
17
17
  // don't move; null = move to the library root; a uuid = move under that
18
18
  // folder. The cycle-guard (a folder cannot move under its own descendant)
@@ -30,27 +30,30 @@ export const UpdateMediaFolderRequestSchema = z
30
30
  .refine((body) => body.name !== undefined || body.parentId !== undefined, {
31
31
  message: "At least one of name or parentId must be present",
32
32
  });
33
- // GET /api/media/folders response (S186e §2/Task 2 obligation 7): the
34
- // WHOLE tree in one response, not cursor-paginated the way /api/media is.
35
- // Fix wave (MEDIUM-1) correction: this is NOT actually bounded by the
36
- // service's depth cap (5) and per-parent sibling sanity limit (500) the
37
- // way an earlier version of this comment claimed — those two caps bound
38
- // one branch's nesting and one parent's children respectively, not the
39
- // whole tree's total folder count, which is their product summed across
40
- // every branch (on the order of 3×10^13 in the worst case at those same
41
- // limits) — nowhere near a real bound in practice. Left unpaginated as a
42
- // deliberate scope decision for this task, not because it's provably
43
- // small; a future task can revisit pagination here if a real library
44
- // ever grows large enough for it to matter. Decision, documented here
45
- // rather than left implicit: a FLAT array of MediaFolderSchema, not a
46
- // server-assembled nested structure — the client groups by `parentId`
47
- // itself (cheap at ordinary scale, and it's exactly the shape
48
- // MediaFolderSchema already has). A folder whose parentId dangles (binding
49
- // obligation 4 from the S186e Task 1 review) is normalized to
50
- // `parentId: null` in this response by the service, so it renders as a
51
- // root folder instead of silently vanishing from the client's grouping.
33
+ /** The most items one page of a media folder, version or rendition list holds, and the default (S300b). */
34
+ export const MEDIA_NESTED_LIST_PAGE_MAX = 200;
35
+ // The query of the three lists that used to be unpaginated: GET /api/manage/v1/media/folders,
36
+ // /api/manage/v1/media/:id/versions and /api/manage/v1/media/:id/renditions. The cursor is the `id`
37
+ // of the previous page's last item, the idiom of GET /api/manage/v1/media.
38
+ export const MediaNestedListQuerySchema = z.object({
39
+ cursor: z.string().uuid().optional(),
40
+ limit: z.coerce.number().int().min(1).max(MEDIA_NESTED_LIST_PAGE_MAX).default(MEDIA_NESTED_LIST_PAGE_MAX),
41
+ });
42
+ // GET /api/manage/v1/media/folders (S186e §2, paged by S300b): the tree as a FLAT array of
43
+ // MediaFolderSchema, `limit` folders at a time (default and maximum
44
+ // MEDIA_NESTED_LIST_PAGE_MAX), ordered by name and then id, with the cursor of
45
+ // the next page. Flat rather than nested: the client groups by `parentId`
46
+ // itself, and a server-assembled tree could not be paged. A folder whose
47
+ // parentId dangles (binding obligation 4 of the S186e Task 1 review) is reported
48
+ // with `parentId: null`, so it renders as a root folder instead of vanishing
49
+ // from the client's grouping; a folder whose parent sits on another page keeps
50
+ // its parentId. The tree's total size is not bounded by the depth cap or the
51
+ // per-parent sibling limit (they bound one branch and one parent), which is why
52
+ // this list is paged.
52
53
  export const MediaFolderListResponseSchema = z.object({
53
54
  folders: z.array(MediaFolderSchema),
55
+ // null = no more pages.
56
+ nextCursor: z.string().uuid().nullable(),
54
57
  });
55
58
  // downloadUrl is the stable app path (S186c §3), computed fresh each
56
59
  // response rather than trusted from storage: for a PUBLIC item it's
@@ -62,7 +65,7 @@ export const MediaFolderListResponseSchema = z.object({
62
65
  export const MediaFileResponseSchema = MediaFileSchema.extend({
63
66
  downloadUrl: z.string().min(1),
64
67
  });
65
- // POST /api/media/:id/link response (S186c §3) — the admin's "Copy
68
+ // POST /api/manage/v1/media/:id/link response (S186c §3): the admin's "Copy
66
69
  // temporary link" mint: a signed `?token=` URL good until `expiresAt`.
67
70
  // Same stable path as `downloadUrl`, just minted on demand rather than
68
71
  // alongside every list/get response.
@@ -73,7 +76,7 @@ export const MediaLinkResponseSchema = z.object({
73
76
  export const MediaDeleteResponseSchema = z.object({
74
77
  success: z.literal(true),
75
78
  });
76
- // PATCH /api/media/:id body (S186c §2, folderId added S186e §2; renamed
79
+ // PATCH /api/manage/v1/media/:id body (S186c §2, folderId added S186e §2; renamed
77
80
  // from UpdateMediaVisibilityRequestSchema in the fix wave — it carries
78
81
  // both visibility and folderId now, not just visibility, and the old
79
82
  // name stopped describing it). Both fields optional and independent, same
@@ -120,7 +123,7 @@ export const UpdateMediaRequestSchema = z
120
123
  data: z.record(z.string(), z.unknown()).optional(),
121
124
  })
122
125
  .refine((body) => body.visibility !== undefined || body.folderId !== undefined || body.data !== undefined, { message: "At least one of visibility, folderId or data must be present" });
123
- // GET /api/media — newest-first pages; cursor = id of the previous
126
+ // GET /api/manage/v1/media: newest-first pages; cursor = id of the previous
124
127
  // page's last item. `search` filters by filename substring,
125
128
  // case-insensitive. `folderId` (S186e §2) is a folder filter: ABSENT
126
129
  // keeps the pre-S186e all-files behavior (compatibility-pinned by a
@@ -149,20 +152,25 @@ export const MediaListResponseSchema = z.object({
149
152
  // null = no more pages.
150
153
  nextCursor: z.string().uuid().nullable(),
151
154
  });
152
- // GET /api/media/:id/versions. Newest first, with the pointer beside them
155
+ // GET /api/manage/v1/media/:id/versions. Newest first, with the pointer beside them
153
156
  // so a client never has to infer which row is live from the list order.
157
+ // Paged like the folder list (S300b).
154
158
  export const MediaVersionListResponseSchema = z.object({
155
159
  items: z.array(MediaVersionSchema),
156
160
  currentVersion: z.number().int().positive(),
161
+ // null = no more pages.
162
+ nextCursor: z.string().uuid().nullable(),
157
163
  });
158
- // GET /api/media/:id/renditions. The renditions of the CURRENT version
164
+ // GET /api/manage/v1/media/:id/renditions. The renditions of the CURRENT version
159
165
  // only, with the pointer beside them so a client never infers which
160
- // version these belong to.
166
+ // version these belong to. Paged like the folder list (S300b).
161
167
  export const MediaRenditionListResponseSchema = z.object({
162
168
  items: z.array(MediaRenditionSchema),
163
169
  currentVersion: z.number().int().positive(),
170
+ // null = no more pages.
171
+ nextCursor: z.string().uuid().nullable(),
164
172
  });
165
- // GET /api/media/trash (S234e). Newest-trashed first; cursor = id of the
173
+ // GET /api/manage/v1/media/trash (S234e). Newest-trashed first; cursor = id of the
166
174
  // previous page's last item, the same cursor idiom the library list uses.
167
175
  export const MediaTrashListQuerySchema = z.object({
168
176
  cursor: z.string().uuid().optional(),
@@ -179,7 +187,7 @@ export const MediaTrashListResponseSchema = z.object({
179
187
  // null = no more pages.
180
188
  nextCursor: z.string().uuid().nullable(),
181
189
  });
182
- // GET /api/media/:id query (S234e). The ONE way to read a trashed item
190
+ // GET /api/manage/v1/media/:id query (S234e). The ONE way to read a trashed item
183
191
  // through the API, and it has to be asked for: every other read, and this
184
192
  // one without the flag, answers 404 for a trashed item so that a trashed
185
193
  // file is not reachable by accident.
@@ -198,7 +206,7 @@ export const MediaReadQuerySchema = z.object({
198
206
  .default(false)
199
207
  .transform((value) => value === true || value === "true"),
200
208
  });
201
- // POST /api/media/trash/empty (S234e). Both numbers, always, because a
209
+ // POST /api/manage/v1/media/trash/empty (S234e). Both numbers, always, because a
202
210
  // purge deletes the row before the objects and can therefore half
203
211
  // succeed. An endpoint that answered only `{ success: true }` would be
204
212
  // claiming something it cannot know.
@@ -69,8 +69,8 @@ export const MediaRenditionSchema = z.object({
69
69
  // "thumb". Three doors refuse that state, and all three ask this function
70
70
  // rather than re-deriving the rule (S234c Task 7):
71
71
  // DocumentTypeService.createDocumentType (which is also the plugin
72
- // manifest install path), PUT /api/document-types/:id, and
73
- // PATCH /api/data-types/:id, which could otherwise edit one crop data
72
+ // manifest install path), PUT /api/manage/v1/document-types/:id, and
73
+ // PATCH /api/manage/v1/data-types/:id, which could otherwise edit one crop data
74
74
  // type's ratio into another's without touching the media type at all.
75
75
  export function renditionName(dataType) {
76
76
  // A union rather than `editorId: string` with a cast. The argument is a
@@ -99,7 +99,7 @@ export const MediaVersionSchema = z.object({
99
99
  // is gone and a user who never set one (`User.name` is itself nullable).
100
100
  //
101
101
  // NAME ONLY, deliberately. Never the email and never the role: those
102
- // live on GET /api/users, which is admin only, and this list is not.
102
+ // live on GET /api/manage/v1/users, which is admin only, and this list is not.
103
103
  createdByName: z.string().nullable(),
104
104
  });
105
105
  /**
@@ -79,9 +79,20 @@ export declare const PluginDocsPageResponseSchema: z.ZodObject<{
79
79
  markdown: z.ZodString;
80
80
  }, z.core.$strip>;
81
81
  export type PluginDocsPageResponse = z.infer<typeof PluginDocsPageResponseSchema>;
82
+ export declare const PluginReferenceSourceSchema: z.ZodEnum<{
83
+ package: "package";
84
+ live: "live";
85
+ }>;
86
+ export type PluginReferenceSource = z.infer<typeof PluginReferenceSourceSchema>;
87
+ /** S289: "live" is built from the manifest the server has attached; "package"
88
+ * is the package's reference.json, used only when no manifest is attached. */
82
89
  export declare const PluginDocsReferenceResponseSchema: z.ZodObject<{
83
90
  pluginId: z.ZodString;
84
91
  version: z.ZodString;
92
+ source: z.ZodEnum<{
93
+ package: "package";
94
+ live: "live";
95
+ }>;
85
96
  reference: z.ZodObject<{
86
97
  actions: z.ZodArray<z.ZodObject<{
87
98
  id: z.ZodString;
@@ -100,8 +111,14 @@ export declare const PluginDocsReferenceResponseSchema: z.ZodObject<{
100
111
  }, z.core.$strict>>;
101
112
  capabilities: z.ZodArray<z.ZodObject<{
102
113
  id: z.ZodString;
103
- mediation: z.ZodString;
104
- payload: z.ZodOptional<z.ZodUnknown>;
114
+ mediation: z.ZodEnum<{
115
+ mediated: "mediated";
116
+ promised: "promised";
117
+ }>;
118
+ payload: z.ZodObject<{
119
+ count: z.ZodNumber;
120
+ details: z.ZodArray<z.ZodString>;
121
+ }, z.core.$strict>;
105
122
  }, z.core.$strict>>;
106
123
  documentTypes: z.ZodArray<z.ZodObject<{
107
124
  name: z.ZodString;
@@ -112,11 +129,74 @@ export declare const PluginDocsReferenceResponseSchema: z.ZodObject<{
112
129
  id: z.ZodString;
113
130
  name: z.ZodString;
114
131
  }, z.core.$loose>>;
132
+ templates: z.ZodArray<z.ZodObject<{
133
+ name: z.ZodString;
134
+ alias: z.ZodString;
135
+ kind: z.ZodString;
136
+ documentType: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$strict>>;
115
138
  settingsPages: z.ZodArray<z.ZodObject<{
116
139
  id: z.ZodString;
117
140
  name: z.ZodString;
118
141
  action: z.ZodString;
119
142
  }, z.core.$strict>>;
143
+ adminSections: z.ZodArray<z.ZodObject<{
144
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
145
+ rail: z.ZodArray<z.ZodObject<{
146
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
147
+ id: z.ZodString;
148
+ action: z.ZodString;
149
+ }, z.core.$strict>>;
150
+ id: z.ZodString;
151
+ action: z.ZodString;
152
+ }, z.core.$strict>>;
153
+ railEntries: z.ZodArray<z.ZodObject<{
154
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
155
+ section: z.ZodString;
156
+ id: z.ZodString;
157
+ action: z.ZodString;
158
+ }, z.core.$strict>>;
159
+ dashboardWidgets: z.ZodArray<z.ZodObject<{
160
+ name: z.ZodString;
161
+ id: z.ZodString;
162
+ action: z.ZodString;
163
+ }, z.core.$strict>>;
164
+ editorToolbar: z.ZodArray<z.ZodObject<{
165
+ label: z.ZodString;
166
+ id: z.ZodString;
167
+ action: z.ZodString;
168
+ }, z.core.$strict>>;
169
+ contentTreeActions: z.ZodArray<z.ZodObject<{
170
+ label: z.ZodString;
171
+ id: z.ZodString;
172
+ action: z.ZodString;
173
+ }, z.core.$strict>>;
174
+ hooks: z.ZodArray<z.ZodString>;
175
+ scheduledTasks: z.ZodArray<z.ZodObject<{
176
+ id: z.ZodString;
177
+ name: z.ZodString;
178
+ cron: z.ZodString;
179
+ }, z.core.$strict>>;
180
+ migrations: z.ZodArray<z.ZodObject<{
181
+ id: z.ZodString;
182
+ name: z.ZodString;
183
+ }, z.core.$strict>>;
184
+ assertions: z.ZodArray<z.ZodObject<{
185
+ key: z.ZodString;
186
+ reason: z.ZodString;
187
+ }, z.core.$strict>>;
188
+ installOptions: z.ZodDefault<z.ZodArray<z.ZodObject<{
189
+ step: z.ZodRecord<z.ZodString, z.ZodString>;
190
+ id: z.ZodString;
191
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
192
+ kind: z.ZodString;
193
+ choices: z.ZodArray<z.ZodObject<{
194
+ id: z.ZodString;
195
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
196
+ }, z.core.$strict>>;
197
+ default: z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodArray<z.ZodString>]>>;
198
+ required: z.ZodBoolean;
199
+ }, z.core.$strict>>>;
120
200
  }, z.core.$strict>;
121
201
  }, z.core.$strip>;
122
202
  export type PluginDocsReferenceResponse = z.infer<typeof PluginDocsReferenceResponseSchema>;
@@ -35,9 +35,13 @@ export const PluginDocsPageResponseSchema = z.object({
35
35
  path: z.string(),
36
36
  markdown: z.string(),
37
37
  });
38
+ export const PluginReferenceSourceSchema = z.enum(["live", "package"]);
39
+ /** S289: "live" is built from the manifest the server has attached; "package"
40
+ * is the package's reference.json, used only when no manifest is attached. */
38
41
  export const PluginDocsReferenceResponseSchema = z.object({
39
42
  pluginId: z.string(),
40
43
  version: z.string(),
44
+ source: PluginReferenceSourceSchema,
41
45
  reference: PluginReferenceSchema,
42
46
  });
43
47
  export const PluginDocsSearchItemSchema = z.object({
@@ -47,6 +47,9 @@ export declare function requiredDocRoles(facts: DocsFacts): Array<{
47
47
  role: PluginDocRole;
48
48
  because: string;
49
49
  }>;
50
+ /** A slot label as reference.json carries it: language code to text, with
51
+ * the English text every slot label must have. */
52
+ export declare const ReferenceLabelMapSchema: z.ZodRecord<z.ZodString, z.ZodString>;
50
53
  export declare const PluginReferenceSchema: z.ZodObject<{
51
54
  actions: z.ZodArray<z.ZodObject<{
52
55
  id: z.ZodString;
@@ -65,8 +68,14 @@ export declare const PluginReferenceSchema: z.ZodObject<{
65
68
  }, z.core.$strict>>;
66
69
  capabilities: z.ZodArray<z.ZodObject<{
67
70
  id: z.ZodString;
68
- mediation: z.ZodString;
69
- payload: z.ZodOptional<z.ZodUnknown>;
71
+ mediation: z.ZodEnum<{
72
+ mediated: "mediated";
73
+ promised: "promised";
74
+ }>;
75
+ payload: z.ZodObject<{
76
+ count: z.ZodNumber;
77
+ details: z.ZodArray<z.ZodString>;
78
+ }, z.core.$strict>;
70
79
  }, z.core.$strict>>;
71
80
  documentTypes: z.ZodArray<z.ZodObject<{
72
81
  name: z.ZodString;
@@ -77,13 +86,87 @@ export declare const PluginReferenceSchema: z.ZodObject<{
77
86
  id: z.ZodString;
78
87
  name: z.ZodString;
79
88
  }, z.core.$loose>>;
89
+ templates: z.ZodArray<z.ZodObject<{
90
+ name: z.ZodString;
91
+ alias: z.ZodString;
92
+ kind: z.ZodString;
93
+ documentType: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strict>>;
80
95
  settingsPages: z.ZodArray<z.ZodObject<{
81
96
  id: z.ZodString;
82
97
  name: z.ZodString;
83
98
  action: z.ZodString;
84
99
  }, z.core.$strict>>;
100
+ adminSections: z.ZodArray<z.ZodObject<{
101
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
102
+ rail: z.ZodArray<z.ZodObject<{
103
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
104
+ id: z.ZodString;
105
+ action: z.ZodString;
106
+ }, z.core.$strict>>;
107
+ id: z.ZodString;
108
+ action: z.ZodString;
109
+ }, z.core.$strict>>;
110
+ railEntries: z.ZodArray<z.ZodObject<{
111
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
112
+ section: z.ZodString;
113
+ id: z.ZodString;
114
+ action: z.ZodString;
115
+ }, z.core.$strict>>;
116
+ dashboardWidgets: z.ZodArray<z.ZodObject<{
117
+ name: z.ZodString;
118
+ id: z.ZodString;
119
+ action: z.ZodString;
120
+ }, z.core.$strict>>;
121
+ editorToolbar: z.ZodArray<z.ZodObject<{
122
+ label: z.ZodString;
123
+ id: z.ZodString;
124
+ action: z.ZodString;
125
+ }, z.core.$strict>>;
126
+ contentTreeActions: z.ZodArray<z.ZodObject<{
127
+ label: z.ZodString;
128
+ id: z.ZodString;
129
+ action: z.ZodString;
130
+ }, z.core.$strict>>;
131
+ hooks: z.ZodArray<z.ZodString>;
132
+ scheduledTasks: z.ZodArray<z.ZodObject<{
133
+ id: z.ZodString;
134
+ name: z.ZodString;
135
+ cron: z.ZodString;
136
+ }, z.core.$strict>>;
137
+ migrations: z.ZodArray<z.ZodObject<{
138
+ id: z.ZodString;
139
+ name: z.ZodString;
140
+ }, z.core.$strict>>;
141
+ assertions: z.ZodArray<z.ZodObject<{
142
+ key: z.ZodString;
143
+ reason: z.ZodString;
144
+ }, z.core.$strict>>;
145
+ installOptions: z.ZodDefault<z.ZodArray<z.ZodObject<{
146
+ step: z.ZodRecord<z.ZodString, z.ZodString>;
147
+ id: z.ZodString;
148
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
149
+ kind: z.ZodString;
150
+ choices: z.ZodArray<z.ZodObject<{
151
+ id: z.ZodString;
152
+ label: z.ZodRecord<z.ZodString, z.ZodString>;
153
+ }, z.core.$strict>>;
154
+ default: z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodArray<z.ZodString>]>>;
155
+ required: z.ZodBoolean;
156
+ }, z.core.$strict>>>;
85
157
  }, z.core.$strict>;
86
158
  export type PluginReference = z.infer<typeof PluginReferenceSchema>;
87
- export declare const REFERENCE_PAGE_SLUGS: readonly ["permissions", "api-routes", "capabilities", "content", "settings"];
88
- /** The generated pages this plugin gets, in their fixed order (spec section 7). */
89
- export declare function referencePageSlugs(reference: PluginReference): string[];
159
+ export declare function emptyPluginReference(): PluginReference;
160
+ export declare const REFERENCE_PAGE_SLUGS: readonly ["permissions", "api-routes", "capabilities", "content", "settings", "admin-surfaces", "lifecycle"];
161
+ export type ReferencePageSlug = (typeof REFERENCE_PAGE_SLUGS)[number];
162
+ /** Which lists each page's tables are drawn from. Every list belongs to
163
+ * exactly one page (pinned by plugin-docs.test.ts), so a list added to the
164
+ * schema without a page is a red test, not a fact nobody sees. */
165
+ export declare const REFERENCE_PAGE_TABLES: Record<ReferencePageSlug, readonly (keyof PluginReference)[]>;
166
+ export declare function isReferencePageSlug(slug: string): slug is ReferencePageSlug;
167
+ /** The one rule (S289): a reference page exists when at least one of its
168
+ * tables has a row. The renderer, the admin, the server, the door, the
169
+ * marketplace and its sitemap all ask this function. */
170
+ export declare function referencePageHasContent(reference: PluginReference, slug: string): boolean;
171
+ /** The generated pages this plugin gets, in their fixed order. */
172
+ export declare function referencePageSlugs(reference: PluginReference): ReferencePageSlug[];