@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
@@ -0,0 +1,103 @@
1
+ /**
2
+ * What a plugin can do, computed from what it declares (S267, section 3,
3
+ * implemented by S268 Task 5, moved here from the SDK by S289 so the one
4
+ * reference builder can call it; the SDK re-exports it and keeps the labels).
5
+ *
6
+ * **A capability is derived, not declared.** The author writes
7
+ * `contributions` (concrete, carrying payloads), `assertions` (the short
8
+ * list of claims nothing can check) and `databaseCompatibility`. This
9
+ * module reads those and produces the list. One source of truth, three
10
+ * renderings: the install screen shows it as consent items, the review
11
+ * queue highlights its promised entries for the reviewer, and the
12
+ * generated reference page prints it. An author cannot claim a capability
13
+ * they do not have, and cannot quietly have one they did not claim.
14
+ *
15
+ * **Disclosure, not enforcement** (S267 section 7). Plugin backend code
16
+ * runs unsandboxed and in-process, so this list is what the author says
17
+ * and what review checks, never what the runtime confines. The mediated
18
+ * entries are genuinely enforced, because the host owns the decision. The
19
+ * promised ones are promises.
20
+ */
21
+ /**
22
+ * `mediated`: the host bounds the outcome. It decides where the view
23
+ * renders, which gate the route sits behind, whether the action passes.
24
+ * The host enforces a mediated capability, so there is nothing in the
25
+ * plugin's code to read it against.
26
+ *
27
+ * `promised`: only the plugin's own code can honour it, so a reviewer reads
28
+ * it against that code.
29
+ */
30
+ export type CapabilityMediation = "mediated" | "promised";
31
+ /**
32
+ * The part of the declaration that produced a capability which is safe to
33
+ * store and to render: never a live function, never a Zod schema.
34
+ *
35
+ * `details` is a list of plain identifying strings, not sentences, so each
36
+ * of the three readers can put its own heading in front of them and none
37
+ * has to re-derive them from the manifest. For an assertion the detail IS
38
+ * the author's reason, because a reason is the whole content of an
39
+ * assertion.
40
+ */
41
+ export interface CapabilityPayload {
42
+ /** How many declarations produced this capability. 1 for a declaration
43
+ * that is not a list (themeTokens, an assertion, structured storage). */
44
+ count: number;
45
+ /** One line per declaration, in declaration order. Empty when the
46
+ * declaration carries no readable per-entry detail. */
47
+ details: string[];
48
+ }
49
+ export interface Capability {
50
+ /** Stable, dotted, and never reused for a different meaning. Persisted
51
+ * on a marketplace version row and rendered by three surfaces, so a
52
+ * renamed id is a data migration, not a cosmetic change. */
53
+ id: string;
54
+ payload: CapabilityPayload;
55
+ mediation: CapabilityMediation;
56
+ }
57
+ /**
58
+ * Every contribution key, in the order capabilities are emitted, fixed here
59
+ * rather than taken from the manifest's own key order. Two manifests
60
+ * declaring the same things in a different order must produce the same
61
+ * list, or the install screen, the review queue and the reference page
62
+ * would each print a different ordering of one fact.
63
+ *
64
+ * Storage leads because it is the heaviest thing an operator consents to.
65
+ * The assertions trail because they are the claims with nothing behind
66
+ * them, and they read as a closing caveat rather than as a feature.
67
+ *
68
+ * This package cannot name the SDK's `PluginContributions` (the SDK depends
69
+ * on it), so the SDK asserts at the type level that these 16 keys are
70
+ * exactly `keyof PluginContributions`: a seventeenth contribution added to the
71
+ * contract and not classified here is a compile error in the SDK's build.
72
+ */
73
+ export declare const CONTRIBUTION_EMISSION_ORDER: readonly ["dataTypes", "documentTypes", "adminSections", "railEntries", "dashboardWidgets", "templates", "assets", "themeTokens", "hooks", "scheduledTasks", "mediaProcessors", "serializers", "apiRoutes", "exposedServices", "bundledPlugins", "bundledTemplate"];
74
+ export type ContributionKey = (typeof CONTRIBUTION_EMISSION_ORDER)[number];
75
+ /** The assertion kinds, in emission order. The SDK asserts these are
76
+ * exactly `keyof PluginAssertions`, for the reason above. */
77
+ export declare const ASSERTION_KEYS: readonly ["externalNetwork", "filesystemAccess"];
78
+ export type AssertionKey = (typeof ASSERTION_KEYS)[number];
79
+ /** Whether this contribution kind sits behind a named permission action.
80
+ * Lives on CONTRIBUTION_RULES rather than in a separate list, because that
81
+ * record is compiler-total over the 16 contribution keys: a seventeenth key
82
+ * cannot be added without classifying it here. */
83
+ export declare function isActionGated(key: ContributionKey): boolean;
84
+ /** Every capability id this contract can produce, for the readers that
85
+ * need to be pinned against it (the marketplace's static mirror) and for
86
+ * the reference page S289 generates. */
87
+ export declare const CAPABILITY_IDS: readonly string[];
88
+ /**
89
+ * Compute a manifest's capability list.
90
+ *
91
+ * Accepts both a live `PluginManifest` and the redacted, JSON-safe summary
92
+ * kardalum plugin writes into a package's `manifest.json`, for the same
93
+ * reason `declaresClientBundle` does: the marketplace never executes
94
+ * plugin code, so the only manifest it can read is the redacted one, and
95
+ * the two sides of an install must not disagree about what a package
96
+ * declares.
97
+ *
98
+ * Defensive about its input rather than trusting it. It is handed parsed
99
+ * JSON from an artifact an author built, so a missing or wrongly-shaped
100
+ * field degrades to "declares nothing" for that field instead of throwing
101
+ * inside a review queue listing.
102
+ */
103
+ export declare function deriveCapabilities(manifest: unknown): Capability[];
@@ -0,0 +1,346 @@
1
+ /**
2
+ * What a plugin can do, computed from what it declares (S267, section 3,
3
+ * implemented by S268 Task 5, moved here from the SDK by S289 so the one
4
+ * reference builder can call it; the SDK re-exports it and keeps the labels).
5
+ *
6
+ * **A capability is derived, not declared.** The author writes
7
+ * `contributions` (concrete, carrying payloads), `assertions` (the short
8
+ * list of claims nothing can check) and `databaseCompatibility`. This
9
+ * module reads those and produces the list. One source of truth, three
10
+ * renderings: the install screen shows it as consent items, the review
11
+ * queue highlights its promised entries for the reviewer, and the
12
+ * generated reference page prints it. An author cannot claim a capability
13
+ * they do not have, and cannot quietly have one they did not claim.
14
+ *
15
+ * **Disclosure, not enforcement** (S267 section 7). Plugin backend code
16
+ * runs unsandboxed and in-process, so this list is what the author says
17
+ * and what review checks, never what the runtime confines. The mediated
18
+ * entries are genuinely enforced, because the host owns the decision. The
19
+ * promised ones are promises.
20
+ */
21
+ /**
22
+ * Every contribution key, in the order capabilities are emitted, fixed here
23
+ * rather than taken from the manifest's own key order. Two manifests
24
+ * declaring the same things in a different order must produce the same
25
+ * list, or the install screen, the review queue and the reference page
26
+ * would each print a different ordering of one fact.
27
+ *
28
+ * Storage leads because it is the heaviest thing an operator consents to.
29
+ * The assertions trail because they are the claims with nothing behind
30
+ * them, and they read as a closing caveat rather than as a feature.
31
+ *
32
+ * This package cannot name the SDK's `PluginContributions` (the SDK depends
33
+ * on it), so the SDK asserts at the type level that these 16 keys are
34
+ * exactly `keyof PluginContributions`: a seventeenth contribution added to the
35
+ * contract and not classified here is a compile error in the SDK's build.
36
+ */
37
+ export const CONTRIBUTION_EMISSION_ORDER = [
38
+ "dataTypes",
39
+ "documentTypes",
40
+ "adminSections",
41
+ "railEntries",
42
+ "dashboardWidgets",
43
+ "templates",
44
+ "assets",
45
+ "themeTokens",
46
+ "hooks",
47
+ "scheduledTasks",
48
+ "mediaProcessors",
49
+ "serializers",
50
+ "apiRoutes",
51
+ "exposedServices",
52
+ "bundledPlugins",
53
+ "bundledTemplate",
54
+ ];
55
+ /** The assertion kinds, in emission order. The SDK asserts these are
56
+ * exactly `keyof PluginAssertions`, for the reason above. */
57
+ export const ASSERTION_KEYS = ["externalNetwork", "filesystemAccess"];
58
+ /**
59
+ * Every contribution key, classified. Keyed by `ContributionKey` (which the
60
+ * SDK pins to `keyof PluginContributions`) rather than by a loose string, so
61
+ * a contribution added to the contract and not classified here is a compile
62
+ * error rather than a capability that silently never appears on an install
63
+ * screen.
64
+ *
65
+ * Classification follows S267 section 6 and its stated principle: a
66
+ * capability is mediated when the platform decides the outcome, and promised
67
+ * when the plugin does. Every contribution below is mediated,
68
+ * because every one of them is consumed by the host: it mounts the view,
69
+ * dispatches the hook, runs the task, registers the template. The only
70
+ * contribution that is not wholly mediated is `apiRoutes`, and only for
71
+ * the tiers that let traffic reach a handler without a signed-in session.
72
+ *
73
+ * `exposedServices`, `bundledPlugins` and `bundledTemplate` are not named
74
+ * in section 6's automatic list, which enumerates a policy rather than the
75
+ * contract's keys. They are classified mediated here rather than dropped:
76
+ * the marketplace resolves the two bundle keys, and the cross-plugin
77
+ * service registry (when it exists) is the host's own lookup.
78
+ * `exposedServices` reads promised until you remember that plugin backend
79
+ * code is unsandboxed and in-process already, so handing another plugin a
80
+ * service adds a lookup rather than a privilege it could not otherwise
81
+ * reach. Emitting them highlights nothing for the reviewer, since the host
82
+ * enforces a mediated capability, and not emitting them would be the exact
83
+ * failure this design exists to prevent, a declaration the install screen
84
+ * does not disclose.
85
+ */
86
+ const CONTRIBUTION_RULES = {
87
+ dataTypes: { derives: "one", id: "content.dataType", mediation: "mediated", actionGated: false },
88
+ documentTypes: { derives: "one", id: "content.documentType", mediation: "mediated", actionGated: false },
89
+ adminSections: { derives: "one", id: "admin.section", mediation: "mediated", actionGated: true },
90
+ // S280: a rail entry in a built-in section. Mediated like a section: the
91
+ // host decides where it renders and checks its action before it does. A
92
+ // section's own rail entries are part of the section's declaration, so
93
+ // they are disclosed under admin.section rather than counted here.
94
+ railEntries: { derives: "one", id: "admin.railEntry", mediation: "mediated", actionGated: true },
95
+ dashboardWidgets: { derives: "one", id: "admin.dashboardWidget", mediation: "mediated", actionGated: true },
96
+ templates: { derives: "one", id: "render.template", mediation: "mediated", actionGated: false },
97
+ assets: { derives: "one", id: "render.asset", mediation: "mediated", actionGated: false },
98
+ themeTokens: { derives: "one", id: "theme.tokens", mediation: "mediated", actionGated: false },
99
+ hooks: { derives: "one", id: "server.hook", mediation: "mediated", actionGated: false },
100
+ scheduledTasks: { derives: "one", id: "server.scheduledTask", mediation: "mediated", actionGated: false },
101
+ mediaProcessors: { derives: "one", id: "media.processor", mediation: "mediated", actionGated: false },
102
+ serializers: { derives: "one", id: "api.serializer", mediation: "mediated", actionGated: false },
103
+ exposedServices: { derives: "one", id: "service.exposed", mediation: "mediated", actionGated: false },
104
+ bundledPlugins: { derives: "one", id: "bundle.plugin", mediation: "mediated", actionGated: false },
105
+ bundledTemplate: { derives: "one", id: "bundle.template", mediation: "mediated", actionGated: false },
106
+ apiRoutes: { derives: "perApiRouteTier", actionGated: true },
107
+ };
108
+ /** Whether this contribution kind sits behind a named permission action.
109
+ * Lives on CONTRIBUTION_RULES rather than in a separate list, because that
110
+ * record is compiler-total over the 16 contribution keys: a seventeenth key
111
+ * cannot be added without classifying it here. */
112
+ export function isActionGated(key) {
113
+ return CONTRIBUTION_RULES[key].actionGated;
114
+ }
115
+ /**
116
+ * The access tiers, in emission order, with the classification S267
117
+ * section 6 gives each.
118
+ *
119
+ * `admin` is mediated: the host checks that the session's role holds the
120
+ * route's `action` before the handler runs. `apiKey` and `public` are
121
+ * promised: the host enforces the tier, but a route reachable without a
122
+ * signed-in session is an abuse surface whose handling belongs to the
123
+ * author.
124
+ */
125
+ const API_ROUTE_TIERS = [
126
+ { tier: "admin", id: "api.route.admin", mediation: "mediated" },
127
+ { tier: "apiKey", id: "api.route.apiKey", mediation: "promised" },
128
+ { tier: "public", id: "api.route.public", mediation: "promised" },
129
+ ];
130
+ /**
131
+ * The tier a route actually runs at.
132
+ *
133
+ * This is a real coupling to `apps/server/src/routes/plugin-api-routes.ts`,
134
+ * which resolves `route.access ?? "admin"` and documents that anything
135
+ * unrecognised falls back to `admin`, secure by default. If the two
136
+ * disagreed, the install screen would promise a gate the runtime does not
137
+ * apply, or warn about one it does. The dispatcher is canonical; this
138
+ * follows it.
139
+ */
140
+ function routeTier(access) {
141
+ const match = API_ROUTE_TIERS.find((entry) => entry.tier === access);
142
+ return match ?? API_ROUTE_TIERS[0];
143
+ }
144
+ /**
145
+ * Capability id per assertion, in emission order. The reason the author
146
+ * gave is the capability's only detail, because the reason is the only
147
+ * checkable thing an assertion carries.
148
+ *
149
+ * Keyed by `AssertionKey` (pinned by the SDK to `keyof PluginAssertions`)
150
+ * for the same reason CONTRIBUTION_RULES is keyed by `ContributionKey`, and
151
+ * with more force: an unclassified contribution is at worst an undisclosed
152
+ * mediated addition, while an unclassified assertion is an undisclosed
153
+ * PROMISE, so it would never reach the consent list and never be
154
+ * highlighted for the reviewer. A third kind added to the type and not here
155
+ * is a compile error.
156
+ */
157
+ const ASSERTION_RULES = {
158
+ externalNetwork: "network.external",
159
+ filesystemAccess: "filesystem.access",
160
+ };
161
+ /** The rules as the derivation walks them, in ASSERTION_KEYS order. */
162
+ const ASSERTION_ENTRIES = ASSERTION_KEYS.map((key) => [key, ASSERTION_RULES[key]]);
163
+ /**
164
+ * Derived from `databaseCompatibility.storageType`, and NOT from a
165
+ * contribution: `PluginContributions` has no storage-shaped key and the
166
+ * contract cannot silently grow one. Declaring structured storage IS the
167
+ * declaration that the plugin owns real tables. The server agrees: it
168
+ * persists `storageType` on the installed-plugin row, because uninstall
169
+ * has to answer that question without the manifest.
170
+ */
171
+ const STRUCTURED_STORAGE_ID = "storage.structured";
172
+ /** Every capability id this contract can produce, for the readers that
173
+ * need to be pinned against it (the marketplace's static mirror) and for
174
+ * the reference page S289 generates. */
175
+ export const CAPABILITY_IDS = [
176
+ STRUCTURED_STORAGE_ID,
177
+ ...CONTRIBUTION_EMISSION_ORDER.flatMap((key) => {
178
+ const rule = CONTRIBUTION_RULES[key];
179
+ return rule.derives === "one" ? [rule.id] : API_ROUTE_TIERS.map((entry) => entry.id);
180
+ }),
181
+ ...ASSERTION_ENTRIES.map(([, id]) => id),
182
+ ];
183
+ // ---------------------------------------------------------------------------
184
+ // Reading a declaration's readable detail
185
+ // ---------------------------------------------------------------------------
186
+ /** The plain string fields a contribution entry can be named by, in the
187
+ * order they are preferred. Every one of them survives the redaction
188
+ * kardalum plugin applies when it writes a package's manifest.json, which
189
+ * is the only form the marketplace ever sees. */
190
+ const ENTRY_NAME_FIELDS = ["name", "label", "alias", "file", "id"];
191
+ /** A slot's label is a map of language to text (S280), and the detail is a
192
+ * plain identifying string, so a label map reads as its English text, the
193
+ * one language every label must carry. A map without readable English
194
+ * yields nothing, and the next name field is tried. */
195
+ function readableField(value) {
196
+ if (typeof value === "string")
197
+ return value.trim() ? value : null;
198
+ if (value !== null && typeof value === "object" && !Array.isArray(value)) {
199
+ const en = value.en;
200
+ if (typeof en === "string" && en.trim())
201
+ return en;
202
+ }
203
+ return null;
204
+ }
205
+ function describeEntry(entry) {
206
+ if (typeof entry === "string")
207
+ return entry.trim() || null;
208
+ if (entry === null || typeof entry !== "object")
209
+ return null;
210
+ const record = entry;
211
+ // An apiRoute is named by what it exposes, not by an id it has no field
212
+ // for: "GET /orders" is the thing a reviewer looks up in the code.
213
+ if (typeof record.method === "string" && typeof record.path === "string") {
214
+ return `${record.method} ${record.path}`;
215
+ }
216
+ for (const field of ENTRY_NAME_FIELDS) {
217
+ const value = readableField(record[field]);
218
+ if (value !== null)
219
+ return value;
220
+ }
221
+ return null;
222
+ }
223
+ /**
224
+ * Normalises one declared contribution value into the entries that
225
+ * produced it, handling the three shapes the contract uses: a list, the
226
+ * `hooks` map (whose keys are the events, and which arrives as a plain key
227
+ * array once redacted), and a single object like `themeTokens`.
228
+ *
229
+ * Returns an empty list for a declaration that declares nothing, which is
230
+ * the same rule `declaresClientBundle` applies: a present-but-empty array
231
+ * or object buys nothing. The one shape that is NOT nothing is the
232
+ * redactor's `true`, which is a declaration stripped of its detail rather
233
+ * than an absent one.
234
+ */
235
+ function declaredEntries(key, value) {
236
+ if (value === null || value === undefined)
237
+ return [];
238
+ if (Array.isArray(value))
239
+ return value;
240
+ // `true` is what kardalum plugin's redactor writes for a contribution it
241
+ // can keep no safe per-entry detail from (`serializers` is the only key
242
+ // that lands there today). It means "declared, nothing readable to
243
+ // show", which is exactly one entry with no detail, the same answer the
244
+ // live object form gives. Reading it as "declares nothing" is what made
245
+ // every marketplace surface omit a capability the SDK derived from the
246
+ // same plugin.
247
+ if (value === true)
248
+ return [true];
249
+ if (typeof value !== "object")
250
+ return [];
251
+ // `hooks` is Record<event, handler> live and string[] once redacted; the
252
+ // array branch above already covered the redacted form.
253
+ if (key === "hooks")
254
+ return Object.keys(value);
255
+ // A present-but-empty object buys nothing, which is the rule the array
256
+ // branch gets for free: `themeTokens: {}` declares no tokens, so it is
257
+ // not a theme capability.
258
+ return Object.keys(value).length === 0 ? [] : [value];
259
+ }
260
+ // ---------------------------------------------------------------------------
261
+ // The derivation
262
+ // ---------------------------------------------------------------------------
263
+ /**
264
+ * Compute a manifest's capability list.
265
+ *
266
+ * Accepts both a live `PluginManifest` and the redacted, JSON-safe summary
267
+ * kardalum plugin writes into a package's `manifest.json`, for the same
268
+ * reason `declaresClientBundle` does: the marketplace never executes
269
+ * plugin code, so the only manifest it can read is the redacted one, and
270
+ * the two sides of an install must not disagree about what a package
271
+ * declares.
272
+ *
273
+ * Defensive about its input rather than trusting it. It is handed parsed
274
+ * JSON from an artifact an author built, so a missing or wrongly-shaped
275
+ * field degrades to "declares nothing" for that field instead of throwing
276
+ * inside a review queue listing.
277
+ */
278
+ export function deriveCapabilities(manifest) {
279
+ if (manifest === null || typeof manifest !== "object")
280
+ return [];
281
+ const source = manifest;
282
+ const capabilities = [];
283
+ const databaseCompatibility = source.databaseCompatibility;
284
+ const storageType = databaseCompatibility !== null && typeof databaseCompatibility === "object"
285
+ ? databaseCompatibility.storageType
286
+ : undefined;
287
+ if (storageType === "structured") {
288
+ capabilities.push({
289
+ id: STRUCTURED_STORAGE_ID,
290
+ payload: { count: 1, details: [] },
291
+ mediation: "promised",
292
+ });
293
+ }
294
+ const contributions = source.contributions !== null && typeof source.contributions === "object"
295
+ ? source.contributions
296
+ : {};
297
+ for (const key of CONTRIBUTION_EMISSION_ORDER) {
298
+ const entries = declaredEntries(key, contributions[key]);
299
+ if (entries.length === 0)
300
+ continue;
301
+ const rule = CONTRIBUTION_RULES[key];
302
+ if (rule.derives === "one") {
303
+ capabilities.push({
304
+ id: rule.id,
305
+ payload: {
306
+ count: entries.length,
307
+ details: entries.map(describeEntry).filter((detail) => detail !== null),
308
+ },
309
+ mediation: rule.mediation,
310
+ });
311
+ continue;
312
+ }
313
+ // One contribution, up to three capabilities: the routes are grouped
314
+ // by the tier the dispatcher will actually run them at.
315
+ for (const tier of API_ROUTE_TIERS) {
316
+ const routes = entries.filter((entry) => routeTier(entry !== null && typeof entry === "object" ? entry.access : undefined)
317
+ .tier === tier.tier);
318
+ if (routes.length === 0)
319
+ continue;
320
+ capabilities.push({
321
+ id: tier.id,
322
+ payload: {
323
+ count: routes.length,
324
+ details: routes.map(describeEntry).filter((detail) => detail !== null),
325
+ },
326
+ mediation: tier.mediation,
327
+ });
328
+ }
329
+ }
330
+ const assertions = source.assertions !== null && typeof source.assertions === "object"
331
+ ? source.assertions
332
+ : {};
333
+ for (const [key, id] of ASSERTION_ENTRIES) {
334
+ const declared = assertions[key];
335
+ if (declared === null || typeof declared !== "object")
336
+ continue;
337
+ const reason = declared.reason;
338
+ // An assertion without a readable reason is not consentable and not
339
+ // checkable, so it is dropped rather than rendered as a blank line.
340
+ // The SDK schema refuses it upstream; this guards a parsed artifact.
341
+ if (typeof reason !== "string" || !reason.trim())
342
+ continue;
343
+ capabilities.push({ id, payload: { count: 1, details: [reason] }, mediation: "promised" });
344
+ }
345
+ return capabilities;
346
+ }
@@ -0,0 +1,4 @@
1
+ export declare const VIEW_BEARING_CONTRIBUTIONS: readonly ["dataTypes", "adminSections", "railEntries", "dashboardWidgets"];
2
+ /** An empty array declares nothing and so buys no bundle. Named for what it
3
+ * answers, not `hasClientBundle`: that name once took a `type` string. */
4
+ export declare function declaresClientBundle(contributions: unknown): boolean;
@@ -0,0 +1,25 @@
1
+ // S311 (S341): whether a manifest's contributions need a client bundle, defined
2
+ // once. It was the SDK's (manifest.ts) and a pinned hand mirror in the
3
+ // marketplace door. It reads a live PluginContributions and the function-stripped
4
+ // summary in manifest.json alike: every contribution key and every array length
5
+ // survives that redaction. Pure data, no node: import, so the browser-safe
6
+ // `./reference` subpath can export it.
7
+ export const VIEW_BEARING_CONTRIBUTIONS = [
8
+ "dataTypes",
9
+ "adminSections",
10
+ "railEntries",
11
+ "dashboardWidgets",
12
+ ];
13
+ /** An empty array declares nothing and so buys no bundle. Named for what it
14
+ * answers, not `hasClientBundle`: that name once took a `type` string. */
15
+ export function declaresClientBundle(contributions) {
16
+ if (contributions === null || typeof contributions !== "object")
17
+ return false;
18
+ const declared = contributions;
19
+ return VIEW_BEARING_CONTRIBUTIONS.some((key) => {
20
+ const value = declared[key];
21
+ if (value === null || value === undefined)
22
+ return false;
23
+ return Array.isArray(value) ? value.length > 0 : true;
24
+ });
25
+ }
@@ -0,0 +1,25 @@
1
+ import { type PlannedEntry } from "../extract.js";
2
+ import { type Plain } from "./support.js";
3
+ import type { DeliveryCheck } from "./types.js";
4
+ /** Every entry the build carries from the plugin's own folders, as the archive
5
+ * will name it: README.md, the cover, sample-content.json, the docs pages and
6
+ * the images they show, the files directly inside locales/, and templates/,
7
+ * public/ and media/ through walkShipped (a folder appears only when nothing
8
+ * inside it ships, as the archive holds it). Each path once. The build's own
9
+ * output (manifest.json, server/, the client bundle) has fixed names or is
10
+ * `pack`'s to judge. */
11
+ export declare function shippedEntries(dir: string, manifest: Plain): PlannedEntry[];
12
+ /** The client bundle as the archive will name it: `remoteEntry.js` and every
13
+ * regular file under `assets/`, at any depth, links never followed (S311
14
+ * third code fix). `root` is the folder the bundle was built into: the
15
+ * federation build `validate` makes for `bundle size`, or the package itself
16
+ * at the marketplace. */
17
+ export declare function bundleEntries(root: string): PlannedEntry[];
18
+ /** Every reason the entry gate would refuse one of `entries`: entryViolation's
19
+ * name and size rules, then createPathKeyGate's (each path once, one kind),
20
+ * each in the gate's own words, and then the archive's own ceilings, which
21
+ * what the build carries from the plugin's folders already breaks when it
22
+ * holds more than MAX_ENTRIES entries or MAX_TOTAL_BYTES once expanded (S311
23
+ * second code fix: the build's own files only add to both). */
24
+ export declare function archiveNameProblems(entries: readonly PlannedEntry[]): string[];
25
+ export declare const archiveNamesCheck: DeliveryCheck;