@kardalum/plugin-sdk 0.15.0 → 0.17.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 (204) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +10 -0
  3. package/dist/admin-section-registry.d.ts +14 -5
  4. package/dist/admin-section-registry.js +14 -4
  5. package/dist/built-in-value-schemas.js +1 -1
  6. package/dist/built-ins.js +2 -2
  7. package/dist/capabilities.d.ts +8 -78
  8. package/dist/capabilities.js +23 -322
  9. package/dist/host-entry.d.ts +1 -1
  10. package/dist/host-entry.js +1 -1
  11. package/dist/index.d.ts +5 -5
  12. package/dist/index.js +13 -12
  13. package/dist/license-verdict-keys.d.ts +4 -3
  14. package/dist/license-verdict-keys.js +6 -5
  15. package/dist/manifest-entry.d.ts +3 -3
  16. package/dist/manifest-entry.js +2 -2
  17. package/dist/manifest-schema.d.ts +113 -56
  18. package/dist/manifest-schema.js +192 -295
  19. package/dist/manifest.d.ts +145 -112
  20. package/dist/manifest.js +13 -36
  21. package/dist/media/media-picker.js +21 -12
  22. package/dist/media/upload-error.d.ts +1 -1
  23. package/dist/media/upload-error.js +1 -1
  24. package/dist/plugin-context.d.ts +7 -0
  25. package/dist/plugin-context.js +7 -0
  26. package/dist/plugin-screen-context.d.ts +44 -3
  27. package/dist/plugin-screen-context.js +27 -2
  28. package/dist/read-all-pages.d.ts +23 -0
  29. package/dist/read-all-pages.js +30 -0
  30. package/dist/richtext/block-panel.js +6 -6
  31. package/dist/richtext/insert-menu.js +4 -4
  32. package/dist/richtext/style-listbox.js +4 -4
  33. package/dist/tokens/tokens.css +1 -0
  34. package/dist/tokens/tokens.json +2 -1
  35. package/dist/type-equality.d.ts +2 -0
  36. package/dist/type-equality.js +1 -0
  37. package/dist/views/content-list-view.js +2 -2
  38. package/dist/views/html-view.js +1 -1
  39. package/dist/views/image-view.js +24 -39
  40. package/dist/views/rich-text-view.js +3 -3
  41. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
  42. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
  43. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
  44. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
  45. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
  46. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +33 -2
  47. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +22 -1
  48. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +50 -15
  49. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
  50. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
  51. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
  52. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +18 -13
  53. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
  54. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
  55. package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
  56. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
  57. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
  58. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
  59. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
  60. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +143 -57
  61. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +110 -60
  62. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
  63. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
  64. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
  65. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +67 -40
  66. package/node_modules/@kardalum/api-schemas/dist/index.js +35 -19
  67. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
  68. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
  69. package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
  70. package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
  71. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  72. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  73. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +356 -16
  74. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +93 -10
  75. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
  76. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
  77. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
  78. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
  79. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
  80. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
  81. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +69 -4
  82. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
  83. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +76 -9
  84. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +84 -24
  85. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
  86. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
  87. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  88. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  89. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +597 -0
  90. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +503 -0
  91. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
  92. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
  93. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +82 -0
  94. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +228 -0
  95. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +33 -4
  96. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +28 -2
  97. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +11 -3
  98. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +17 -4
  99. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +58 -0
  100. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +198 -0
  101. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
  102. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
  103. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
  104. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
  105. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +74 -0
  106. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +132 -0
  107. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
  108. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
  109. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
  110. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -4
  111. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
  112. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +17 -0
  113. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +13 -0
  114. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +44 -0
  115. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +97 -0
  116. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
  117. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
  118. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
  119. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
  120. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +52 -33
  121. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +195 -56
  122. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +19 -3
  123. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +16 -0
  124. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  125. package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
  126. package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
  127. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +105 -1
  128. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +47 -7
  129. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +30 -2
  130. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +19 -5
  131. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
  132. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
  133. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +15 -3
  134. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
  135. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +19 -0
  136. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +22 -0
  137. package/node_modules/@kardalum/api-schemas/package.json +2 -2
  138. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
  139. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  140. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  141. package/node_modules/@kardalum/design-tokens/dist/tokens.js +3 -0
  142. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  143. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
  144. package/node_modules/@kardalum/plugin-package/README.md +4 -1
  145. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +96 -0
  146. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +66 -0
  147. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  148. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +346 -0
  149. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
  150. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
  151. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
  152. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
  153. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
  154. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
  155. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +5 -0
  156. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +60 -0
  157. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
  158. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
  159. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
  160. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
  161. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
  162. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
  163. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
  164. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
  165. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
  166. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
  167. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
  168. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
  169. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
  170. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
  171. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
  172. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +133 -0
  173. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
  174. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
  175. package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
  176. package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
  177. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +6 -0
  178. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +158 -0
  179. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
  180. package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
  181. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
  182. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
  183. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
  184. package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
  185. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -2
  186. package/node_modules/@kardalum/plugin-package/dist/index.js +8 -2
  187. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
  188. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
  189. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +3 -0
  190. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +7 -0
  191. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +38 -1
  192. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +84 -16
  193. package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
  194. package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
  195. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
  196. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
  197. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
  198. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
  199. package/node_modules/@kardalum/plugin-package/package.json +9 -2
  200. package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
  201. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
  202. package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
  203. package/node_modules/@kardalum/ui/package.json +1 -1
  204. package/package.json +6 -6
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { PluginActionDeclarationSchema, PluginRoleOfferSchema } from "./plugin-actions.schema.js";
3
3
  import { HOSTILE_CHARS_MESSAGE, hasHostileChars } from "./plugin-docs-text.js";
4
+ import { PluginLabelStringSchema } from "./plugin-labels.js";
4
5
  // S286, the docs contract (2026-10-04-s285-the-docs-contract-design.md).
5
6
  // The contract's pure parts live here so the SDK's manifest schema, the
6
7
  // CLI and the package door run the same definitions.
@@ -69,7 +70,7 @@ function present(value) {
69
70
  return value.length > 0;
70
71
  return value === true;
71
72
  }
72
- /** Reads the five facts from a live manifest or from manifest.json. The
73
+ /** Reads the four facts from a live manifest or from manifest.json. The
73
74
  * summary keeps each contribution list as a list of redacted entries,
74
75
  * reduces migrations to their ids, and says `paid: true` where the live
75
76
  * manifest has a price above 0: the amount itself never reaches
@@ -83,7 +84,6 @@ export function docsFactsFrom(manifest) {
83
84
  hasDependencies: present(source.pluginDependencies),
84
85
  hasPrice: (typeof source.price === "number" && source.price > 0) || source.paid === true,
85
86
  hasDocumentTypes: present(contributions.documentTypes),
86
- hasSettingsPages: present(contributions.settingsPages),
87
87
  };
88
88
  }
89
89
  /** Which roles the door requires, each with the declaration that requires
@@ -98,37 +98,97 @@ export function requiredDocRoles(facts) {
98
98
  ].filter((reason) => reason !== null);
99
99
  if (setup.length > 0)
100
100
  required.push({ role: "setup", because: setup.join(", ") });
101
- if (facts.hasSettingsPages)
102
- required.push({ role: "configuration", because: "settingsPages" });
103
101
  return required;
104
102
  }
105
103
  // reference.json: the serialisable facts the generated Reference pages are
106
- // rendered from (spec section 7). Written by `kardalum plugin build`. JSON
107
- // schemas and field definitions are carried as plain data, never validated
108
- // here beyond being JSON.
104
+ // rendered from (S285 section 7, widened to seven pages by S289, six since S313b). Written by
105
+ // `kardalum plugin build` through buildReference in
106
+ // @kardalum/plugin-package/reference; built live from the attached manifest
107
+ // by the server for an installed plugin. JSON schemas and field definitions
108
+ // are carried as plain data, never validated here beyond being JSON. Every
109
+ // string is shown as text, never as markup.
110
+ /** A slot label as reference.json carries it: language code to text, with
111
+ * the English text every slot label must have. */
112
+ export const ReferenceLabelMapSchema = z
113
+ .record(z.string(), z.string())
114
+ .refine((label) => typeof label.en === "string" && label.en.trim().length > 0, 'a label carries its English text under "en"');
115
+ const gated = { id: z.string(), action: z.string() };
116
+ // S311 (D3): a manifest may write an action's or a role's label as a language
117
+ // map; the builder writes its English text, so the reference carries one string
118
+ // per label, as the generated pages print it.
119
+ const ReferenceActionSchema = PluginActionDeclarationSchema.extend({ label: PluginLabelStringSchema });
120
+ const ReferenceRoleSchema = PluginRoleOfferSchema.extend({ label: PluginLabelStringSchema });
121
+ // S292: one row per option a manifest's `install` declares, carrying its
122
+ // step's label, for the lifecycle page's "Install asks" table. `required` is
123
+ // installOptionNeedsAnswer's answer, which buildReference writes inline (it
124
+ // may take only types from this package). The list defaults to empty, so a
125
+ // reference.json written by a CLI older than S292 still parses.
126
+ const ReferenceInstallOptionSchema = z
127
+ .object({
128
+ step: ReferenceLabelMapSchema,
129
+ id: z.string(),
130
+ label: ReferenceLabelMapSchema,
131
+ kind: z.string(),
132
+ choices: z.array(z.object({ id: z.string(), label: ReferenceLabelMapSchema }).strict()),
133
+ default: z.union([z.boolean(), z.string(), z.array(z.string())]).nullable(),
134
+ required: z.boolean(),
135
+ })
136
+ .strict();
109
137
  export const PluginReferenceSchema = z
110
138
  .object({
111
- actions: z.array(PluginActionDeclarationSchema),
112
- roles: z.array(PluginRoleOfferSchema),
139
+ actions: z.array(ReferenceActionSchema),
140
+ roles: z.array(ReferenceRoleSchema),
113
141
  apiRoutes: z.array(z.object({ method: z.string(), path: z.string(), access: z.string(), action: z.string().optional() }).strict()),
114
- capabilities: z.array(z.object({ id: z.string(), mediation: z.string(), payload: z.unknown().optional() }).strict()),
142
+ capabilities: z.array(z
143
+ .object({
144
+ id: z.string(),
145
+ mediation: z.enum(["mediated", "promised"]),
146
+ payload: z.object({ count: z.number().int().nonnegative(), details: z.array(z.string()) }).strict(),
147
+ })
148
+ .strict()),
115
149
  documentTypes: z.array(z.object({ name: z.string(), kind: z.string(), fields: z.array(z.unknown()) }).passthrough()),
116
150
  dataTypes: z.array(z.object({ id: z.string(), name: z.string() }).passthrough()),
117
- settingsPages: z.array(z.object({ id: z.string(), name: z.string(), action: z.string() }).strict()),
151
+ templates: z.array(z.object({ name: z.string(), alias: z.string(), kind: z.string(), documentType: z.string().optional() }).strict()),
152
+ adminSections: z.array(z.object({ ...gated, label: ReferenceLabelMapSchema, rail: z.array(z.object({ ...gated, label: ReferenceLabelMapSchema }).strict()) }).strict()),
153
+ railEntries: z.array(z.object({ ...gated, label: ReferenceLabelMapSchema, section: z.string() }).strict()),
154
+ dashboardWidgets: z.array(z.object({ ...gated, name: z.string() }).strict()),
155
+ hooks: z.array(z.string()),
156
+ scheduledTasks: z.array(z.object({ id: z.string(), name: z.string(), cron: z.string() }).strict()),
157
+ migrations: z.array(z.object({ id: z.string(), name: z.string() }).strict()),
158
+ assertions: z.array(z.object({ key: z.string(), reason: z.string() }).strict()),
159
+ installOptions: z.array(ReferenceInstallOptionSchema).default([]),
118
160
  })
119
161
  .strict();
120
- export const REFERENCE_PAGE_SLUGS = ["permissions", "api-routes", "capabilities", "content", "settings"];
121
- /** The generated pages this plugin gets, in their fixed order (spec section 7). */
162
+ export function emptyPluginReference() {
163
+ return {
164
+ actions: [], roles: [], apiRoutes: [], capabilities: [], documentTypes: [], dataTypes: [], templates: [],
165
+ adminSections: [], railEntries: [], dashboardWidgets: [], hooks: [], scheduledTasks: [], migrations: [], assertions: [], installOptions: [],
166
+ };
167
+ }
168
+ export const REFERENCE_PAGE_SLUGS = ["permissions", "api-routes", "capabilities", "content", "admin-surfaces", "lifecycle"];
169
+ /** Which lists each page's tables are drawn from. Every list belongs to
170
+ * exactly one page (pinned by plugin-docs.test.ts), so a list added to the
171
+ * schema without a page is a red test, not a fact nobody sees. */
172
+ export const REFERENCE_PAGE_TABLES = {
173
+ permissions: ["actions", "roles"],
174
+ "api-routes": ["apiRoutes"],
175
+ capabilities: ["capabilities"],
176
+ content: ["documentTypes", "dataTypes", "templates"],
177
+ "admin-surfaces": ["adminSections", "railEntries", "dashboardWidgets"],
178
+ lifecycle: ["installOptions", "hooks", "scheduledTasks", "migrations", "assertions"],
179
+ };
180
+ export function isReferencePageSlug(slug) {
181
+ return REFERENCE_PAGE_SLUGS.includes(slug);
182
+ }
183
+ /** The one rule (S289): a reference page exists when at least one of its
184
+ * tables has a row. The renderer, the admin, the server, the door, the
185
+ * marketplace and its sitemap all ask this function. */
186
+ export function referencePageHasContent(reference, slug) {
187
+ if (!isReferencePageSlug(slug))
188
+ return false;
189
+ return REFERENCE_PAGE_TABLES[slug].some((list) => reference[list].length > 0);
190
+ }
191
+ /** The generated pages this plugin gets, in their fixed order. */
122
192
  export function referencePageSlugs(reference) {
123
- const slugs = [];
124
- if (reference.actions.length > 0 || reference.roles.length > 0)
125
- slugs.push("permissions");
126
- if (reference.apiRoutes.length > 0)
127
- slugs.push("api-routes");
128
- slugs.push("capabilities");
129
- if (reference.documentTypes.length > 0 || reference.dataTypes.length > 0)
130
- slugs.push("content");
131
- if (reference.settingsPages.length > 0)
132
- slugs.push("settings");
133
- return slugs;
193
+ return REFERENCE_PAGE_SLUGS.filter((slug) => referencePageHasContent(reference, slug));
134
194
  }
@@ -12,13 +12,23 @@ export declare const PLUGIN_ID_REGEX: RegExp;
12
12
  */
13
13
  export declare const MANIFEST_ID_SEGMENT_MAX: number;
14
14
  /**
15
- * Whether `id` is an id a plugin manifest may have: PLUGIN_ID_REGEX and at
16
- * most MANIFEST_ID_SEGMENT_MAX segments, exactly what the SDK's manifest
17
- * validator applies. Every door that turns a plugin id into a directory name
18
- * (an install, an upload, a marketplace submission) runs this first, so an id
19
- * the validator would refuse never reaches the filesystem: a lookalike such
20
- * as "COM.KARDALUM.SEO" names another plugin's folder on a case-insensitive
21
- * filesystem (S283).
15
+ * The longest a plugin manifest's own id may be. The id names the plugin's
16
+ * folder at every install and is part of every file name a version is (see
17
+ * PLUGIN_VERSION_MAX), so the cap is checked before the pattern ever reads it
18
+ * (S311 fix wave). A reverse-domain id of at most MANIFEST_ID_SEGMENT_MAX (4)
19
+ * segments never comes near it in practice: "com.vendor.plugin-name" is 22
20
+ * characters. 128 (S311 third code fix, from npm's 214) leaves the version
21
+ * room beside it.
22
+ */
23
+ export declare const PLUGIN_ID_MAX = 128;
24
+ /**
25
+ * Whether `id` is an id a plugin manifest may have: at most PLUGIN_ID_MAX
26
+ * characters, PLUGIN_ID_REGEX and at most MANIFEST_ID_SEGMENT_MAX segments,
27
+ * exactly what the SDK's manifest validator applies. Every door that turns a
28
+ * plugin id into a directory name (an install, an upload, a marketplace
29
+ * submission) runs this first, so an id the validator would refuse never
30
+ * reaches the filesystem: a lookalike such as "COM.KARDALUM.SEO" names another
31
+ * plugin's folder on a case-insensitive filesystem (S283).
22
32
  */
23
33
  export declare function isPluginManifestId(id: string): boolean;
24
34
  /**
@@ -17,16 +17,26 @@ export const PLUGIN_ID_REGEX = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/;
17
17
  */
18
18
  export const MANIFEST_ID_SEGMENT_MAX = ACTION_SEGMENT_MAX - 2;
19
19
  /**
20
- * Whether `id` is an id a plugin manifest may have: PLUGIN_ID_REGEX and at
21
- * most MANIFEST_ID_SEGMENT_MAX segments, exactly what the SDK's manifest
22
- * validator applies. Every door that turns a plugin id into a directory name
23
- * (an install, an upload, a marketplace submission) runs this first, so an id
24
- * the validator would refuse never reaches the filesystem: a lookalike such
25
- * as "COM.KARDALUM.SEO" names another plugin's folder on a case-insensitive
26
- * filesystem (S283).
20
+ * The longest a plugin manifest's own id may be. The id names the plugin's
21
+ * folder at every install and is part of every file name a version is (see
22
+ * PLUGIN_VERSION_MAX), so the cap is checked before the pattern ever reads it
23
+ * (S311 fix wave). A reverse-domain id of at most MANIFEST_ID_SEGMENT_MAX (4)
24
+ * segments never comes near it in practice: "com.vendor.plugin-name" is 22
25
+ * characters. 128 (S311 third code fix, from npm's 214) leaves the version
26
+ * room beside it.
27
+ */
28
+ export const PLUGIN_ID_MAX = 128;
29
+ /**
30
+ * Whether `id` is an id a plugin manifest may have: at most PLUGIN_ID_MAX
31
+ * characters, PLUGIN_ID_REGEX and at most MANIFEST_ID_SEGMENT_MAX segments,
32
+ * exactly what the SDK's manifest validator applies. Every door that turns a
33
+ * plugin id into a directory name (an install, an upload, a marketplace
34
+ * submission) runs this first, so an id the validator would refuse never
35
+ * reaches the filesystem: a lookalike such as "COM.KARDALUM.SEO" names another
36
+ * plugin's folder on a case-insensitive filesystem (S283).
27
37
  */
28
38
  export function isPluginManifestId(id) {
29
- return PLUGIN_ID_REGEX.test(id) && id.split(".").length <= MANIFEST_ID_SEGMENT_MAX;
39
+ return id.length <= PLUGIN_ID_MAX && PLUGIN_ID_REGEX.test(id) && id.split(".").length <= MANIFEST_ID_SEGMENT_MAX;
30
40
  }
31
41
  /**
32
42
  * A slot's id (S280): a segment of its screen's URL, so lowercase letters,
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ /** What the install itself created; a role whose id was already taken is never here. */
3
+ export declare const PluginInstallCreatedSchema: z.ZodObject<{
4
+ sampleContentNodeIds: z.ZodArray<z.ZodString>;
5
+ mediaIds: z.ZodArray<z.ZodString>;
6
+ roleIds: z.ZodArray<z.ZodString>;
7
+ }, z.core.$strict>;
8
+ export declare const PluginInstallRecordSchema: z.ZodObject<{
9
+ answers: z.ZodObject<{
10
+ sampleContent: z.ZodBoolean;
11
+ roles: z.ZodArray<z.ZodString>;
12
+ options: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodArray<z.ZodString>]>>;
13
+ }, z.core.$strict>;
14
+ created: z.ZodObject<{
15
+ sampleContentNodeIds: z.ZodArray<z.ZodString>;
16
+ mediaIds: z.ZodArray<z.ZodString>;
17
+ roleIds: z.ZodArray<z.ZodString>;
18
+ }, z.core.$strict>;
19
+ }, z.core.$strict>;
20
+ export type PluginInstallRecord = z.infer<typeof PluginInstallRecordSchema>;
21
+ /** A fresh `created`, never a shared one. */
22
+ export declare function emptyInstallCreated(): PluginInstallRecord["created"];
23
+ /** The stored column through the schema: null for a plugin installed before
24
+ * S293 (the column is null) or a value that does not parse. */
25
+ export declare function readInstallRecord(value: unknown): PluginInstallRecord | null;
26
+ /** What the install did with each offered role its answers named. */
27
+ export declare const INSTALL_ROLE_OUTCOMES: readonly ["created", "already-exists", "failed"];
28
+ export declare const InstallRoleOutcomeSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ outcome: z.ZodEnum<{
31
+ failed: "failed";
32
+ created: "created";
33
+ "already-exists": "already-exists";
34
+ }>;
35
+ }, z.core.$strip>;
36
+ export type InstallRoleOutcome = z.infer<typeof InstallRoleOutcomeSchema>;
37
+ /** The 400 every install door answers for answers it refuses, every issue at
38
+ * once: `message` is "The answers were refused: " and the reasons joined with
39
+ * "; ", each reason "path: message". */
40
+ export declare const InstallAnswersRefusedSchema: z.ZodObject<{
41
+ message: z.ZodString;
42
+ reason: z.ZodLiteral<"answers-refused">;
43
+ reasons: z.ZodArray<z.ZodString>;
44
+ }, z.core.$strip>;
45
+ export type InstallAnswersRefused = z.infer<typeof InstallAnswersRefusedSchema>;
46
+ /** The most page titles a record summary names. */
47
+ export declare const INSTALL_RECORD_SUMMARY_TITLES = 20;
48
+ /** What the admin is told about a plugin's record (the uninstall dialog, an update). */
49
+ export declare const PluginInstallRecordSummarySchema: z.ZodObject<{
50
+ answers: z.ZodNullable<z.ZodObject<{
51
+ sampleContent: z.ZodBoolean;
52
+ roles: z.ZodArray<z.ZodString>;
53
+ options: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodArray<z.ZodString>]>>;
54
+ }, z.core.$strict>>;
55
+ pages: z.ZodObject<{
56
+ liveCount: z.ZodNumber;
57
+ titles: z.ZodArray<z.ZodObject<{
58
+ id: z.ZodString;
59
+ title: z.ZodString;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>;
62
+ mediaCount: z.ZodNumber;
63
+ roles: z.ZodArray<z.ZodObject<{
64
+ id: z.ZodString;
65
+ label: z.ZodString;
66
+ userCount: z.ZodNumber;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>;
69
+ export type PluginInstallRecordSummary = z.infer<typeof PluginInstallRecordSummarySchema>;
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { ResolvedInstallAnswersSchema } from "./plugin-install.js";
3
+ import { RoleIdSchema } from "./role.schema.js";
4
+ // S293 (2026-10-13-s293-the-wizard-installed-design.md 3.1): what a plugin's
5
+ // install is remembered by, on its registry row (PluginRegistry.installRecord):
6
+ // the answers it was installed with, every default filled, and what the install
7
+ // itself created, so an update can carry the answers over and an uninstall can
8
+ // offer to remove exactly that. Written by the server only.
9
+ /** What the install itself created; a role whose id was already taken is never here. */
10
+ export const PluginInstallCreatedSchema = z
11
+ .object({
12
+ /** The sample's pages, in the order the seeder created them (parents first). */
13
+ sampleContentNodeIds: z.array(z.string().min(1)),
14
+ /** The media items the sample's `media` section uploaded. */
15
+ mediaIds: z.array(z.string().min(1)),
16
+ /** The offered roles this install created. */
17
+ roleIds: z.array(RoleIdSchema),
18
+ })
19
+ .strict();
20
+ export const PluginInstallRecordSchema = z
21
+ .object({ answers: ResolvedInstallAnswersSchema, created: PluginInstallCreatedSchema })
22
+ .strict();
23
+ /** A fresh `created`, never a shared one. */
24
+ export function emptyInstallCreated() {
25
+ return { sampleContentNodeIds: [], mediaIds: [], roleIds: [] };
26
+ }
27
+ /** The stored column through the schema: null for a plugin installed before
28
+ * S293 (the column is null) or a value that does not parse. */
29
+ export function readInstallRecord(value) {
30
+ const parsed = PluginInstallRecordSchema.safeParse(value);
31
+ return parsed.success ? parsed.data : null;
32
+ }
33
+ /** What the install did with each offered role its answers named. */
34
+ export const INSTALL_ROLE_OUTCOMES = ["created", "already-exists", "failed"];
35
+ export const InstallRoleOutcomeSchema = z.object({ id: RoleIdSchema, outcome: z.enum(INSTALL_ROLE_OUTCOMES) });
36
+ /** The 400 every install door answers for answers it refuses, every issue at
37
+ * once: `message` is "The answers were refused: " and the reasons joined with
38
+ * "; ", each reason "path: message". */
39
+ export const InstallAnswersRefusedSchema = z.object({
40
+ message: z.string(),
41
+ reason: z.literal("answers-refused"),
42
+ reasons: z.array(z.string()),
43
+ });
44
+ /** The most page titles a record summary names. */
45
+ export const INSTALL_RECORD_SUMMARY_TITLES = 20;
46
+ /** What the admin is told about a plugin's record (the uninstall dialog, an update). */
47
+ export const PluginInstallRecordSummarySchema = z.object({
48
+ /** Null for a plugin installed before S293. */
49
+ answers: ResolvedInstallAnswersSchema.nullable(),
50
+ pages: z.object({
51
+ /** Recorded pages not in the Recycle Bin. */
52
+ liveCount: z.number().int().nonnegative(),
53
+ titles: z.array(z.object({ id: z.string(), title: z.string() })).max(INSTALL_RECORD_SUMMARY_TITLES),
54
+ }),
55
+ /** Recorded media not in the media Recycle Bin; an uninstall keeps them. */
56
+ mediaCount: z.number().int().nonnegative(),
57
+ /** The recorded roles that still exist. */
58
+ roles: z.array(z.object({ id: RoleIdSchema, label: z.string(), userCount: z.number().int().nonnegative() })),
59
+ });