@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,2 @@
1
+ import type { DeliveryCheck } from "./types.js";
2
+ export declare const iconNamesCheck: DeliveryCheck;
@@ -0,0 +1,51 @@
1
+ import { ICON_NAMES } from "./icon-names.generated.js";
2
+ import { contributionsOf, failed, list, passed, record } from "./support.js";
3
+ // Finding 28 and S239: an icon name is a Lucide name, the set the admin's icon
4
+ // picker and the SDK's IconName type are made from. A value Lucide does not
5
+ // have draws the default glyph, a path included (no consumer reads this field
6
+ // as a URL). The list is generated from lucide-react (icon-names.generated.ts),
7
+ // so the door needs no React and no dynamic imports.
8
+ const VALID = new Set(ICON_NAMES);
9
+ // Every contribution kind whose schema carries an `icon`: adminSections (and
10
+ // each entry of its optional `rail`, reported as `adminSections.rail`),
11
+ // railEntries, dataTypes and documentTypes (optional, "" means the default
12
+ // icon). No other contribution has an icon field.
13
+ const ICON_BEARING = ["adminSections", "railEntries", "dataTypes", "documentTypes"];
14
+ /** Every (where, icon) pair the icon-bearing contributions carry, a section's
15
+ * own rail entries included, in declaration order. */
16
+ function declaredIcons(contributions) {
17
+ const found = [];
18
+ for (const kind of ICON_BEARING) {
19
+ for (const entry of list(contributions[kind])) {
20
+ found.push({ where: kind, icon: record(entry)?.icon });
21
+ if (kind !== "adminSections")
22
+ continue;
23
+ for (const railEntry of list(record(entry)?.rail))
24
+ found.push({ where: "adminSections.rail", icon: record(railEntry)?.icon });
25
+ }
26
+ }
27
+ return found;
28
+ }
29
+ export const iconNamesCheck = {
30
+ name: "icon names",
31
+ rule: "Every `icon` a contribution declares is a Lucide icon name in kebab-case.",
32
+ gates: ["cli", "door"],
33
+ needsManifest: true,
34
+ run: ({ manifest }) => {
35
+ const unresolved = [];
36
+ // Counted so a plugin that declares no icons says so rather than
37
+ // claiming a pass for something it never inspected.
38
+ let inspected = 0;
39
+ for (const { where, icon } of declaredIcons(contributionsOf(manifest))) {
40
+ if (typeof icon !== "string" || icon === "")
41
+ continue;
42
+ inspected += 1;
43
+ if (!VALID.has(icon))
44
+ unresolved.push(`${where}: ${icon}`);
45
+ }
46
+ if (unresolved.length === 0) {
47
+ return passed(inspected === 0 ? "not applicable: this plugin declares no icons" : "every icon is a Lucide name");
48
+ }
49
+ return failed(unresolved.length === 1 ? "1 icon value is not a Lucide name" : `${unresolved.length} icon values are not Lucide names`, [...unresolved, "Browse the names at https://lucide.dev/icons/ (kebab-case)."]);
50
+ },
51
+ };
@@ -0,0 +1,8 @@
1
+ export * from "./types.js";
2
+ export * from "./limits.js";
3
+ export { describeError, listCapped } from "./support.js";
4
+ export { DELIVERY_CHECKS, GATE_ONLY_CHECKS, renderDeliveryLimits, renderDeliveryTable, runChecks, runDeliveryChecks } from "./registry.js";
5
+ export { archiveNameProblems, shippedEntries } from "./archive-names.js";
6
+ export { collectLabelLanguages, collectLabelMaps } from "./label-languages.js";
7
+ export type { LabelMapRef } from "./label-languages.js";
8
+ export { ICON_NAMES } from "./icon-names.generated.js";
@@ -0,0 +1,7 @@
1
+ export * from "./types.js";
2
+ export * from "./limits.js";
3
+ export { describeError, listCapped } from "./support.js";
4
+ export { DELIVERY_CHECKS, GATE_ONLY_CHECKS, renderDeliveryLimits, renderDeliveryTable, runChecks, runDeliveryChecks } from "./registry.js";
5
+ export { archiveNameProblems, shippedEntries } from "./archive-names.js";
6
+ export { collectLabelLanguages, collectLabelMaps } from "./label-languages.js";
7
+ export { ICON_NAMES } from "./icon-names.generated.js";
@@ -0,0 +1,17 @@
1
+ import { type Plain } from "./support.js";
2
+ import type { DeliveryCheck } from "./types.js";
3
+ export interface LabelMapRef {
4
+ where: string;
5
+ codes: string[];
6
+ }
7
+ /** Every label written as a language map, in a fixed order: the manifest's
8
+ * actions and roles, the contributions above (a section's rail entries after
9
+ * the section), and the install steps, options and choices, each label then
10
+ * its description (S311 fix wave: a description is a language map too). A
11
+ * plain string is not listed: it opts that label out of translation. `where`
12
+ * reads as the manifest does, a contribution under `contributions.`, as the
13
+ * SDK's errors name it; a description's ends in `.description`. */
14
+ export declare function collectLabelMaps(manifest: Plain): LabelMapRef[];
15
+ /** Each language code any label map uses, once (first spelling wins), sorted. */
16
+ export declare function collectLabelLanguages(manifest: Plain): string[];
17
+ export declare const labelLanguagesCheck: DeliveryCheck;
@@ -0,0 +1,119 @@
1
+ import { readdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { pluginLocaleFileLanguage } from "@kardalum/api-schemas";
4
+ import { LISTED_MAX, contributionsOf, list, listCapped, passed, record, warning } from "./support.js";
5
+ /** The contribution fields whose value is a label (a language map or a plain string). */
6
+ const LABEL_FIELDS = [
7
+ ["adminSections", "label"],
8
+ ["railEntries", "label"],
9
+ ["dashboardWidgets", "name"],
10
+ ["scheduledTasks", "name"],
11
+ ["mediaProcessors", "name"],
12
+ ["exposedServices", "name"],
13
+ ];
14
+ function addMap(into, where, value) {
15
+ const map = record(value);
16
+ if (map !== null)
17
+ into.push({ where, codes: Object.keys(map) });
18
+ }
19
+ /** Every label written as a language map, in a fixed order: the manifest's
20
+ * actions and roles, the contributions above (a section's rail entries after
21
+ * the section), and the install steps, options and choices, each label then
22
+ * its description (S311 fix wave: a description is a language map too). A
23
+ * plain string is not listed: it opts that label out of translation. `where`
24
+ * reads as the manifest does, a contribution under `contributions.`, as the
25
+ * SDK's errors name it; a description's ends in `.description`. */
26
+ export function collectLabelMaps(manifest) {
27
+ const found = [];
28
+ list(manifest.actions).forEach((entry, i) => addMap(found, `actions[${i}]`, record(entry)?.label));
29
+ list(manifest.roles).forEach((entry, i) => addMap(found, `roles[${i}]`, record(entry)?.label));
30
+ const contributions = contributionsOf(manifest);
31
+ for (const [contribution, field] of LABEL_FIELDS) {
32
+ list(contributions[contribution]).forEach((entry, i) => {
33
+ addMap(found, `contributions.${contribution}[${i}]`, record(entry)?.[field]);
34
+ if (contribution !== "adminSections")
35
+ return;
36
+ list(record(entry)?.rail).forEach((rail, j) => addMap(found, `contributions.adminSections[${i}].rail[${j}]`, record(rail)?.label));
37
+ });
38
+ }
39
+ const addText = (where, entry) => {
40
+ addMap(found, where, record(entry)?.label);
41
+ addMap(found, `${where}.description`, record(entry)?.description);
42
+ };
43
+ list(record(manifest.install)?.steps).forEach((step, i) => {
44
+ addText(`install.steps[${i}]`, step);
45
+ list(record(step)?.options).forEach((option, j) => {
46
+ addText(`install.steps[${i}].options[${j}]`, option);
47
+ list(record(option)?.choices).forEach((choice, k) => addText(`install.steps[${i}].options[${j}].choices[${k}]`, choice));
48
+ });
49
+ });
50
+ return found;
51
+ }
52
+ /** Each language code any label map uses, once (first spelling wins), sorted. */
53
+ export function collectLabelLanguages(manifest) {
54
+ const byLower = new Map();
55
+ for (const { codes } of collectLabelMaps(manifest)) {
56
+ for (const code of codes)
57
+ if (!byLower.has(code.toLowerCase()))
58
+ byLower.set(code.toLowerCase(), code);
59
+ }
60
+ return [...byLower.values()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
61
+ }
62
+ /** The languages `locales/` has a file for, lower-cased (`en` among them when
63
+ * en.json is there); none when it cannot be read. */
64
+ function localeFileLanguages(dir) {
65
+ try {
66
+ return new Set(readdirSync(join(dir, "locales"))
67
+ .map((name) => pluginLocaleFileLanguage(name))
68
+ .filter((code) => code !== null)
69
+ .map((code) => code.toLowerCase()));
70
+ }
71
+ catch {
72
+ return new Set();
73
+ }
74
+ }
75
+ /** What to do about label languages no locale file carries: add the files (and
76
+ * English beside them, read with usePluginTranslate, when the package has no
77
+ * locales yet), or drop the languages from the labels. */
78
+ function missingFiles(codes, hasEnglish) {
79
+ const one = codes.length === 1;
80
+ const named = one ? `the label language ${codes[0]} has` : `the label languages ${listCapped(codes, "names")} have`;
81
+ const drop = one ? `drop ${codes[0]} from the labels` : "drop those languages from the labels";
82
+ const why = "(the screens' words show English)";
83
+ if (hasEnglish) {
84
+ return one
85
+ ? `${named} no locales/${codes[0]}.json: add it, or ${drop} ${why}`
86
+ : `${named} no locales/<language>.json: add them, or ${drop} ${why}`;
87
+ }
88
+ const add = one ? `add locales/en.json and locales/${codes[0]}.json and` : "add locales/en.json and a locales/<language>.json for each, and";
89
+ return `${named} no locale file: ${add} read them with usePluginTranslate, or ${drop} ${why}`;
90
+ }
91
+ export const labelLanguagesCheck = {
92
+ name: "label languages",
93
+ rule: "Advisory: every label written as a language map carries the languages the others carry, and each of those languages has a `locales/<language>.json`.",
94
+ gates: ["cli", "door"],
95
+ needsManifest: true,
96
+ run: ({ dir, manifest }) => {
97
+ const maps = collectLabelMaps(manifest);
98
+ if (maps.length === 0)
99
+ return passed("no label is written in more than one language");
100
+ const all = collectLabelLanguages(manifest);
101
+ const problems = [];
102
+ const files = localeFileLanguages(dir);
103
+ const withoutFile = all.filter((code) => code.toLowerCase() !== "en" && !files.has(code.toLowerCase()));
104
+ if (withoutFile.length > 0)
105
+ problems.push(missingFiles(withoutFile, files.has("en")));
106
+ for (const map of maps) {
107
+ // Every code a map holds is one of `all`, so a map with fewer distinct
108
+ // codes lacks one. Only the problems the message prints say which: the
109
+ // rest are counted, so a manifest of many maps costs one pass.
110
+ const has = new Set(map.codes.map((code) => code.toLowerCase()));
111
+ if (has.size >= all.length)
112
+ continue;
113
+ problems.push(problems.length < LISTED_MAX ? `${map.where} lacks ${listCapped(all.filter((code) => !has.has(code.toLowerCase())), "names")}` : map.where);
114
+ }
115
+ if (problems.length === 0)
116
+ return passed(`${listCapped(all, "names")}: every label map carries them all`);
117
+ return warning(listCapped(problems));
118
+ },
119
+ };
@@ -0,0 +1,14 @@
1
+ /** manifest.json is read whole by the marketplace; a hostile archive could inflate it. */
2
+ export declare const MANIFEST_MAX_BYTES: number;
3
+ /** Gzipped remoteEntry.js plus every file under assets/ together (S80's
4
+ * threshold): the shared "bundle size" check fails above it and warns from
5
+ * BUNDLE_WARN_SHARE of it. */
6
+ export declare const BUNDLE_MAX_GZIP_BYTES: number;
7
+ /** At or above this share of BUNDLE_MAX_GZIP_BYTES the "bundle size" check
8
+ * warns: a bundle that close grows past the limit with its next dependency. */
9
+ export declare const BUNDLE_WARN_SHARE = 0.9;
10
+ /** A byte count as the delivery page and every rule string write it (S311 docs
11
+ * wave): binary units, 1 KiB being 1024 bytes, the largest that divides the
12
+ * count exactly, so a limit is never rounded into a different number. A check's
13
+ * own message prints the same size as KB or MB. */
14
+ export declare function formatBinarySize(bytes: number): string;
@@ -0,0 +1,21 @@
1
+ // S311: limits two gates and the page quote, defined once.
2
+ /** manifest.json is read whole by the marketplace; a hostile archive could inflate it. */
3
+ export const MANIFEST_MAX_BYTES = 1024 * 1024;
4
+ /** Gzipped remoteEntry.js plus every file under assets/ together (S80's
5
+ * threshold): the shared "bundle size" check fails above it and warns from
6
+ * BUNDLE_WARN_SHARE of it. */
7
+ export const BUNDLE_MAX_GZIP_BYTES = 250 * 1024;
8
+ /** At or above this share of BUNDLE_MAX_GZIP_BYTES the "bundle size" check
9
+ * warns: a bundle that close grows past the limit with its next dependency. */
10
+ export const BUNDLE_WARN_SHARE = 0.9;
11
+ /** A byte count as the delivery page and every rule string write it (S311 docs
12
+ * wave): binary units, 1 KiB being 1024 bytes, the largest that divides the
13
+ * count exactly, so a limit is never rounded into a different number. A check's
14
+ * own message prints the same size as KB or MB. */
15
+ export function formatBinarySize(bytes) {
16
+ if (bytes % (1024 * 1024) === 0)
17
+ return `${bytes / 1024 / 1024} MiB`;
18
+ if (bytes % 1024 === 0)
19
+ return `${bytes / 1024} KiB`;
20
+ return `${bytes} bytes`;
21
+ }
@@ -0,0 +1,5 @@
1
+ import type { DeliveryCheck, DeliveryOutcome } from "./types.js";
2
+ export declare function checkLocalesFolder(pluginDir: string): DeliveryOutcome;
3
+ export declare function checkLocaleParityFolder(pluginDir: string): DeliveryOutcome;
4
+ export declare const localesCheck: DeliveryCheck;
5
+ export declare const localeParityCheck: DeliveryCheck;
@@ -0,0 +1,148 @@
1
+ import { lstatSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { PLUGIN_LOCALE_MAX_BYTES, compareLocaleFiles, parsePluginLocaleFile, pluginLocaleFileLanguage, } from "@kardalum/api-schemas";
4
+ import { failed, listCapped, passed, warning } from "./support.js";
5
+ // S290: a plugin's own strings ship as locales/<language>.json. The folder
6
+ // is optional (a plugin whose screens hold no words of their own needs
7
+ // none). When it exists, English is what every other language falls back
8
+ // to, so en.json is required, and every file must pass the rules the admin
9
+ // applies when it fetches one (parsePluginLocaleFile in
10
+ // @kardalum/api-schemas). Whether two languages carry the same keys is the
11
+ // parity check below. Both read every file in the folder: the archive's
12
+ // entry ceiling and the per-file cap bound that at the door.
13
+ export function checkLocalesFolder(pluginDir) {
14
+ const dir = join(pluginDir, "locales");
15
+ // lstat, never stat: a symbolic link would pass as the folder or file it
16
+ // points at, the build would carry the link into the package, and the
17
+ // host's extraction refuses a link.
18
+ let folder;
19
+ try {
20
+ folder = lstatSync(dir);
21
+ }
22
+ catch {
23
+ return passed("no locales/ folder: the plugin's screens show the strings in its code");
24
+ }
25
+ if (folder.isSymbolicLink())
26
+ return failed("locales is a symbolic link");
27
+ if (!folder.isDirectory())
28
+ return failed("locales is not a folder");
29
+ const problems = [];
30
+ const languages = [];
31
+ const entries = readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
32
+ for (const entry of entries) {
33
+ if (entry.isSymbolicLink()) {
34
+ problems.push(`locales/${entry.name} is a symbolic link`);
35
+ continue;
36
+ }
37
+ if (!entry.isFile()) {
38
+ problems.push(`locales/${entry.name} is not a file`);
39
+ continue;
40
+ }
41
+ const language = pluginLocaleFileLanguage(entry.name);
42
+ if (language === null) {
43
+ problems.push(`locales/${entry.name} is not named <language>.json (for example de.json)`);
44
+ continue;
45
+ }
46
+ const path = join(dir, entry.name);
47
+ const size = statSync(path).size;
48
+ if (size > PLUGIN_LOCALE_MAX_BYTES) {
49
+ problems.push(`locales/${entry.name}: ${size} bytes, over the ${PLUGIN_LOCALE_MAX_BYTES}-byte limit`);
50
+ continue;
51
+ }
52
+ const parsed = parsePluginLocaleFile(readFileSync(path, "utf8"));
53
+ if (!parsed.ok) {
54
+ problems.push(`locales/${entry.name}: ${parsed.issue}`);
55
+ continue;
56
+ }
57
+ languages.push(language);
58
+ }
59
+ // By name: an en.json that is a link or a folder is reported as that,
60
+ // not also as missing.
61
+ if (!entries.some((entry) => entry.name === "en.json")) {
62
+ problems.unshift("locales/en.json is missing: English is what every other language falls back to");
63
+ }
64
+ if (problems.length > 0)
65
+ return failed(listCapped(problems));
66
+ return passed(`${languages.length} language${languages.length === 1 ? "" : "s"}: ${languages.join(", ")}`);
67
+ }
68
+ // S291: every locale file but en.json, held to en.json. A key English does
69
+ // not have fails (no screen asks for it; usually a typo), and so does a
70
+ // value whose {{placeholders}} differ from the English value's (the
71
+ // sentence renders with a hole or a stray brace). A key a language lacks
72
+ // only warns, with the count: the admin shows the plugin's English for it.
73
+ // The comparison is compareLocaleFiles from @kardalum/api-schemas, the one
74
+ // the marketplace's language line and the admin's own locale-parity test
75
+ // use. A file the `locales` check refuses is skipped here, so one problem is
76
+ // reported once.
77
+ const listKeys = (keys) => listCapped(keys, "names");
78
+ /** A locale file read the way checkLocalesFolder accepts one (a regular file,
79
+ * not a link, within the size limit, passing the S290 rules), or null. */
80
+ function readBundle(dir, fileName) {
81
+ const path = join(dir, fileName);
82
+ try {
83
+ const stats = lstatSync(path);
84
+ if (!stats.isFile() || stats.size > PLUGIN_LOCALE_MAX_BYTES)
85
+ return null;
86
+ const parsed = parsePluginLocaleFile(readFileSync(path, "utf8"));
87
+ return parsed.ok ? parsed.bundle : null;
88
+ }
89
+ catch {
90
+ return null;
91
+ }
92
+ }
93
+ export function checkLocaleParityFolder(pluginDir) {
94
+ const dir = join(pluginDir, "locales");
95
+ let fileNames;
96
+ try {
97
+ if (!lstatSync(dir).isDirectory())
98
+ return passed("nothing to compare: locales is not a folder (see locales)");
99
+ fileNames = readdirSync(dir).sort();
100
+ }
101
+ catch {
102
+ return passed("no locales/ folder: nothing to compare");
103
+ }
104
+ const en = readBundle(dir, "en.json");
105
+ if (en === null)
106
+ return passed("nothing to compare: locales/en.json is missing or refused (see locales)");
107
+ const total = Object.keys(en).length;
108
+ const failures = [];
109
+ const warnings = [];
110
+ const matching = [];
111
+ for (const fileName of fileNames) {
112
+ if (fileName === "en.json" || pluginLocaleFileLanguage(fileName) === null)
113
+ continue;
114
+ const bundle = readBundle(dir, fileName);
115
+ if (bundle === null)
116
+ continue;
117
+ const { extra, missing, mismatched } = compareLocaleFiles(en, bundle);
118
+ if (extra.length > 0)
119
+ failures.push(`${fileName}: ${extra.length} ${extra.length === 1 ? "key" : "keys"} en.json lacks: ${listKeys(extra)}`);
120
+ if (mismatched.length > 0)
121
+ failures.push(`${fileName}: placeholders differ from en.json in ${listKeys(mismatched)}`);
122
+ if (missing.length > 0)
123
+ warnings.push(`${fileName}: ${missing.length} of ${total} keys missing, those show English`);
124
+ if (extra.length === 0 && mismatched.length === 0 && missing.length === 0)
125
+ matching.push(fileName);
126
+ }
127
+ if (failures.length > 0)
128
+ return failed(listCapped([...failures, ...warnings]));
129
+ if (warnings.length > 0)
130
+ return warning(listCapped(warnings));
131
+ if (matching.length === 0)
132
+ return passed("English only: nothing to compare");
133
+ return passed(`${matching.join(", ")}: every one of en.json's ${total} keys, placeholders matching`);
134
+ }
135
+ export const localesCheck = {
136
+ name: "locales",
137
+ rule: "`locales/` holds `en.json` and files named `<language>.json`, each within the size and key limits and the key rules.",
138
+ gates: ["cli", "door"],
139
+ needsManifest: false,
140
+ run: ({ dir }) => checkLocalesFolder(dir),
141
+ };
142
+ export const localeParityCheck = {
143
+ name: "locale parity",
144
+ rule: "A language never has a key English lacks or a different placeholder (both fail); a missing key only warns and shows English.",
145
+ gates: ["cli", "door"],
146
+ needsManifest: false,
147
+ run: ({ dir }) => checkLocaleParityFolder(dir),
148
+ };
@@ -0,0 +1,5 @@
1
+ import type { DeliveryCheck } from "./types.js";
2
+ export declare const readmeCheck: DeliveryCheck;
3
+ export declare const coverCheck: DeliveryCheck;
4
+ export declare const docsContractCheck: DeliveryCheck;
5
+ export declare const docsLinksCheck: DeliveryCheck;
@@ -0,0 +1,76 @@
1
+ import { docsFactsFrom, effectiveDocsPages, referencePageSlugs } from "@kardalum/api-schemas";
2
+ import { buildReference } from "../build-reference.js";
3
+ import { capViolations, checkDocsContract, countRemoteImages } from "../docs-contract.js";
4
+ import { checkCoverContract, checkReadmeContract, COVER_HEIGHT, COVER_PATH, COVER_WIDTH } from "../package-contract.js";
5
+ import { contributionsOf, failed, passed, warning } from "./support.js";
6
+ export const readmeCheck = {
7
+ name: "README present",
8
+ rule: "`README.md` exists and says something: a blank file would render as an empty listing description.",
9
+ gates: ["cli", "door"],
10
+ needsManifest: false,
11
+ run: ({ dir }) => {
12
+ const check = checkReadmeContract(dir);
13
+ return check.ok ? passed("README.md present") : failed(check.reason);
14
+ },
15
+ };
16
+ export const coverCheck = {
17
+ name: "cover image present",
18
+ rule: `\`${COVER_PATH}\` is a real PNG of exactly ${COVER_WIDTH} by ${COVER_HEIGHT} pixels.`,
19
+ gates: ["cli", "door"],
20
+ needsManifest: false,
21
+ run: ({ dir }) => {
22
+ const check = checkCoverContract(dir);
23
+ return check.ok ? passed(`${COVER_PATH} is ${COVER_WIDTH}x${COVER_HEIGHT}`) : failed(check.reason);
24
+ },
25
+ };
26
+ /** What the docs contract judges: the door passes what it read from manifest.json
27
+ * and reference.json; the CLI leaves it to be derived from the live manifest, so
28
+ * an author meets every requirement here first. */
29
+ function docsInputFor(context) {
30
+ if (context.docsInput)
31
+ return context.docsInput;
32
+ const manifest = context.manifest;
33
+ const pages = effectiveDocsPages(manifest.docs, String(manifest.name ?? ""));
34
+ const referenceInput = { ...manifest, contributions: contributionsOf(manifest) };
35
+ return {
36
+ ok: true,
37
+ input: {
38
+ pages,
39
+ facts: docsFactsFrom(manifest),
40
+ referenceSlugs: referencePageSlugs(buildReference(referenceInput)),
41
+ },
42
+ };
43
+ }
44
+ export const docsContractCheck = {
45
+ name: "docs contract",
46
+ rule: "The manifest's `docs` pages exist, carry the roles the contract requires, and keep to its links and image rules.",
47
+ gates: ["cli", "door"],
48
+ needsManifest: true,
49
+ run: (context) => {
50
+ const input = docsInputFor(context);
51
+ if (!input.ok)
52
+ return failed(capViolations(input.reasons).join("; "));
53
+ const { reasons } = checkDocsContract(context.dir, input.input);
54
+ if (reasons.length > 0)
55
+ return failed(capViolations(reasons).join("; "));
56
+ const remote = countRemoteImages(context.dir, input.input.pages);
57
+ const pages = input.input.pages.length;
58
+ const note = remote > 0 ? `, ${remote} remote image${remote === 1 ? "" : "s"} will not be shown` : "";
59
+ return passed(`docs contract satisfied (${pages} page${pages === 1 ? "" : "s"}${note})`);
60
+ },
61
+ };
62
+ export const docsLinksCheck = {
63
+ name: "docs-links",
64
+ rule: "Advisory: a docs link target that never renders as a link (`//host`, `ftp:`, `https:/x`) is shown as plain words.",
65
+ gates: ["cli", "door"],
66
+ needsManifest: true,
67
+ run: (context) => {
68
+ const input = docsInputFor(context);
69
+ if (!input.ok)
70
+ return passed("nothing to check: the docs contract could not read its input (see docs contract)");
71
+ const { warnings } = checkDocsContract(context.dir, input.input);
72
+ if (warnings.length === 0)
73
+ return passed("every docs link renders as a link");
74
+ return warning(capViolations(warnings).join("; "));
75
+ },
76
+ };
@@ -0,0 +1,22 @@
1
+ import type { DeliveryCheck, DeliveryContext, DeliveryGate, DeliveryResult, GateOnlyCheck } from "./types.js";
2
+ /** Runs the checks of one gate in order. A check that cannot run because the
3
+ * manifest did not parse says so; a check that throws is a failed result, never
4
+ * an exception that escapes the gate (a directory where a file belongs is the
5
+ * author's mistake, not an internal error), and it names the path inside the
6
+ * package. sample-content.json is read once, here, unless the caller already
7
+ * has (readShippedSampleContent never throws). */
8
+ export declare function runChecks(checks: readonly DeliveryCheck[], context: DeliveryContext, gate: DeliveryGate): DeliveryResult[];
9
+ /** Every check both gates run, in report order. */
10
+ export declare const DELIVERY_CHECKS: readonly DeliveryCheck[];
11
+ /** What only one gate can measure, as data, so the page and the tests see every
12
+ * check either gate can emit. Each CLI name is the one its check module in the
13
+ * CLI emits: the name-registration tests fail on a typo. The rules are the
14
+ * page's words, so they say "the marketplace" for the check of an upload and
15
+ * write a size in binary units, as formatBinarySize does. */
16
+ export declare const GATE_ONLY_CHECKS: readonly GateOnlyCheck[];
17
+ export declare function runDeliveryChecks(context: DeliveryContext, gate: DeliveryGate): DeliveryResult[];
18
+ /** The page's check table, generated so it cannot drift from the code. */
19
+ export declare function renderDeliveryTable(): string;
20
+ /** The page's limits table, generated from the constants the gates enforce, so
21
+ * a number the page quotes is the number a check holds a package to. */
22
+ export declare function renderDeliveryLimits(): string;
@@ -0,0 +1,133 @@
1
+ import { FILE_NAME_MAX, MAX_DOC_PAGE_BYTES, MAX_DOC_PAGES, MAX_TEMPLATE_PAYLOAD_ENTRIES, PLUGIN_AUTHOR_MAX, PLUGIN_CMS_VERSION_MAX, PLUGIN_DESCRIPTION_MAX, PLUGIN_ID_MAX, PLUGIN_LICENSE_MAX, PLUGIN_LOCALE_KEY_MAX_LENGTH, PLUGIN_LOCALE_MAX_BYTES, PLUGIN_LOCALE_MAX_KEYS, PLUGIN_LOCALE_VALUE_MAX_LENGTH, PLUGIN_NAME_MAX, PLUGIN_VERSION_MAX, SAMPLE_CONTENT_MAX_MEDIA, SAMPLE_CONTENT_MAX_NODES, } from "@kardalum/api-schemas";
2
+ import { ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "../extract.js";
3
+ import { COVER_HEIGHT, COVER_WIDTH } from "../package-contract.js";
4
+ import { archiveNamesCheck } from "./archive-names.js";
5
+ import { bundleSizeCheck } from "./bundle.js";
6
+ import { apiRoutesCheck, databaseCheck, iconNamesCheck, requiredViewsCheck } from "./contributions.js";
7
+ import { labelLanguagesCheck } from "./label-languages.js";
8
+ import { BUNDLE_MAX_GZIP_BYTES, MANIFEST_MAX_BYTES, formatBinarySize } from "./limits.js";
9
+ import { localeParityCheck, localesCheck } from "./locales.js";
10
+ import { coverCheck, docsContractCheck, docsLinksCheck, readmeCheck } from "./package-files.js";
11
+ import { installOptionsCheck, sampleContentCheck } from "./sample-content.js";
12
+ import { SAMPLE_CONTENT_MAX_BYTES, readShippedSampleContent } from "../sample-content.js";
13
+ import { describeError } from "./support.js";
14
+ import { assetsCheck, entryBudgetCheck, templateDeclarationsCheck, templateFilesCheck, templateWiringCheck } from "./templates.js";
15
+ /** Runs the checks of one gate in order. A check that cannot run because the
16
+ * manifest did not parse says so; a check that throws is a failed result, never
17
+ * an exception that escapes the gate (a directory where a file belongs is the
18
+ * author's mistake, not an internal error), and it names the path inside the
19
+ * package. sample-content.json is read once, here, unless the caller already
20
+ * has (readShippedSampleContent never throws). */
21
+ export function runChecks(checks, context, gate) {
22
+ const results = [];
23
+ const run = { ...context, manifest: context.manifest ?? {}, sampleContent: context.sampleContent ?? readShippedSampleContent(context.dir) };
24
+ for (const check of checks) {
25
+ if (!check.gates.includes(gate))
26
+ continue;
27
+ if (check.needsManifest && context.manifest === null) {
28
+ results.push({ name: check.name, status: "failed", message: "cannot check: manifest schema invalid" });
29
+ continue;
30
+ }
31
+ try {
32
+ results.push({ name: check.name, ...check.run(run) });
33
+ }
34
+ catch (error) {
35
+ results.push({ name: check.name, status: "failed", message: `could not run: ${describeError(error, context.dir)}` });
36
+ }
37
+ }
38
+ return results;
39
+ }
40
+ /** Every check both gates run, in report order. */
41
+ export const DELIVERY_CHECKS = [
42
+ requiredViewsCheck,
43
+ apiRoutesCheck,
44
+ databaseCheck,
45
+ iconNamesCheck,
46
+ readmeCheck,
47
+ coverCheck,
48
+ docsContractCheck,
49
+ docsLinksCheck,
50
+ localesCheck,
51
+ localeParityCheck,
52
+ labelLanguagesCheck,
53
+ installOptionsCheck,
54
+ sampleContentCheck,
55
+ templateDeclarationsCheck,
56
+ templateFilesCheck,
57
+ templateWiringCheck,
58
+ assetsCheck,
59
+ entryBudgetCheck,
60
+ archiveNamesCheck,
61
+ bundleSizeCheck,
62
+ ];
63
+ /** What only one gate can measure, as data, so the page and the tests see every
64
+ * check either gate can emit. Each CLI name is the one its check module in the
65
+ * CLI emits: the name-registration tests fail on a typo. The rules are the
66
+ * page's words, so they say "the marketplace" for the check of an upload and
67
+ * write a size in binary units, as formatBinarySize does. */
68
+ export const GATE_ONLY_CHECKS = [
69
+ { name: "manifest schema valid", gate: "cli", rule: "The SDK's full manifest schema, which holds live function references the marketplace cannot run, with the field limits below and a semver `version`.", skippedAtDoor: false },
70
+ { name: "typescript compiles", gate: "cli", rule: "The plugin's TypeScript compiles; the marketplace receives a built package and reports it skipped.", skippedAtDoor: true },
71
+ { name: "npm audit", gate: "cli", rule: "No high or critical advisory in the plugin's production dependencies (its devDependencies are build tooling and are not audited); the marketplace reports it skipped.", skippedAtDoor: true },
72
+ { name: "templates parse", gate: "cli", rule: "Every template parses as Liquid; the marketplace never parses template code and reports it skipped.", skippedAtDoor: true },
73
+ { name: "template references resolve", gate: "cli", rule: "Every `render` and `layout` target names a declared alias; the marketplace does not read template text and reports it skipped.", skippedAtDoor: true },
74
+ { name: "reference", gate: "cli", rule: "The manifest yields a valid `reference.json`, which the build writes and the marketplace reads.", skippedAtDoor: false },
75
+ { name: "plugin SDK federation share key correct", gate: "cli", rule: "The federation config shares the SDK under its package name, and react, react-dom and the SDK each set `singleton: true` and `import: false`, so the bundle carries no fallback copy of what the host provides. The check reads the literal `shared: { ... }` in `vite.config.ts`, so write every entry out in it: it cannot follow a spread, a variable or a helper.", skippedAtDoor: false },
76
+ { name: "archive-safety", gate: "door", rule: "The archive extracts safely: no unsafe path, no entry that carries a second name for itself, no path twice in any spelling, within the entry and byte ceilings; a link is extracted as a plain file, never as a link. The upload's reader applies the same rules.", skippedAtDoor: false },
77
+ { name: "manifest-schema", gate: "door", rule: `\`manifest.json\` is at most ${formatBinarySize(MANIFEST_MAX_BYTES)}, parses, and matches the shape rule built from the shared vocabularies, declaration rules and field limits.`, skippedAtDoor: false },
78
+ { name: "required-files", gate: "door", rule: "`manifest.json`, `server/plugin.js` and `server/package.json` (declaring the ESM marker) are present, plus `remoteEntry.js` when a view-bearing contribution is declared.", skippedAtDoor: false },
79
+ { name: "manifest-consistency", gate: "door", rule: "The manifest's id and version match the submission record, and the extracted `manifest.json` is byte for byte the one read at upload.", skippedAtDoor: false },
80
+ { name: "reserved-names", gate: "door", rule: "Nothing at the package root is named `kardalum-license.json`, in any case: the marketplace writes that file into every licensed download.", skippedAtDoor: false },
81
+ { name: "bundle-members", gate: "door", rule: "Bundles only: every member id is a published, free listing.", skippedAtDoor: false },
82
+ { name: "internal-validation-error", gate: "door", rule: "Not a rule a package breaks: the marketplace could not read the stored package, or could not finish checking it in time. Submit again under a new version number and every check runs afresh.", skippedAtDoor: false },
83
+ ];
84
+ export function runDeliveryChecks(context, gate) {
85
+ return runChecks(DELIVERY_CHECKS, context, gate);
86
+ }
87
+ const RUN_BY = { cli: "`kardalum plugin validate`", door: "the marketplace" };
88
+ /** The page's check table, generated so it cannot drift from the code. */
89
+ export function renderDeliveryTable() {
90
+ const lines = ["| Check | Run by | What it requires |", "|---|---|---|"];
91
+ for (const check of DELIVERY_CHECKS)
92
+ lines.push(`| \`${check.name}\` | both | ${check.rule} |`);
93
+ for (const check of GATE_ONLY_CHECKS)
94
+ lines.push(`| \`${check.name}\` | ${RUN_BY[check.gate]} | ${check.rule} |`);
95
+ return lines.join("\n");
96
+ }
97
+ /** The page's limits table, generated from the constants the gates enforce, so
98
+ * a number the page quotes is the number a check holds a package to. */
99
+ export function renderDeliveryLimits() {
100
+ const rows = [
101
+ ["Archive entries", `${MAX_ENTRIES} entries`, "files and folders in the `.zip`"],
102
+ ["Archive, expanded", formatBinarySize(MAX_TOTAL_BYTES), "all entries together once extracted"],
103
+ ["One entry, expanded", formatBinarySize(MAX_ENTRY_BYTES), "any single file in the archive"],
104
+ ["A name in the archive", `${ENTRY_NAME_MAX} characters`, "any path in the `.zip`: the longest Windows writes"],
105
+ ["Segments in one name", `${ENTRY_SEGMENTS_MAX} segments`, "folders and a file in one path"],
106
+ ["A segment of a name", `${FILE_NAME_MAX} characters`, "one file or folder name in a path"],
107
+ ["`manifest.json`", formatBinarySize(MANIFEST_MAX_BYTES), "measured by the marketplace before it parses the file"],
108
+ ["Plugin id", `${PLUGIN_ID_MAX} characters`, "`id` in the manifest"],
109
+ ["Version", `${PLUGIN_VERSION_MAX} characters`, "`version`, a semver such as `1.0.0` or `1.0.0-beta.1`"],
110
+ ["Name", `${PLUGIN_NAME_MAX} characters`, "`name`"],
111
+ ["Description", `${PLUGIN_DESCRIPTION_MAX} characters`, "`description`"],
112
+ ["Author", `${PLUGIN_AUTHOR_MAX} characters`, "`author`"],
113
+ ["License", `${PLUGIN_LICENSE_MAX} characters`, "`license`"],
114
+ ["CMS version range", `${PLUGIN_CMS_VERSION_MAX} characters`, "`cmsVersion`"],
115
+ ["Client bundle", `${formatBinarySize(BUNDLE_MAX_GZIP_BYTES)} gzipped`, "`remoteEntry.js` and `assets/` together"],
116
+ ["Cover image", `${COVER_WIDTH} by ${COVER_HEIGHT} pixels`, "`marketplace/cover.png`, exactly"],
117
+ ["Docs pages", `${MAX_DOC_PAGES} pages`, "listed in the manifest's `docs`"],
118
+ ["One docs page", formatBinarySize(MAX_DOC_PAGE_BYTES), "each page other than `README.md`"],
119
+ ["One locale file", formatBinarySize(PLUGIN_LOCALE_MAX_BYTES), "each `locales/<language>.json`"],
120
+ ["Keys in a locale file", `${PLUGIN_LOCALE_MAX_KEYS} keys`, "each `locales/<language>.json`"],
121
+ ["A locale key", `${PLUGIN_LOCALE_KEY_MAX_LENGTH} characters`, "letters, digits, `_` and `-`, in segments joined by dots"],
122
+ ["A locale value", `${PLUGIN_LOCALE_VALUE_MAX_LENGTH} characters`, "the text of one key"],
123
+ ["`sample-content.json`", formatBinarySize(SAMPLE_CONTENT_MAX_BYTES), "the file as shipped"],
124
+ ["Sample content nodes", `${SAMPLE_CONTENT_MAX_NODES} nodes`, "`nodes` in `sample-content.json`"],
125
+ ["Sample content media", `${SAMPLE_CONTENT_MAX_MEDIA} entries`, "`media` entries in `sample-content.json`"],
126
+ ["Payload entries", `${MAX_TEMPLATE_PAYLOAD_ENTRIES} entries`, "`templates/`, `public/` and the docs files together"],
127
+ ];
128
+ return [
129
+ "| Limit | Value | What it bounds |",
130
+ "|---|---|---|",
131
+ ...rows.map(([limit, value, bounds]) => `| ${limit} | ${value} | ${bounds} |`),
132
+ ].join("\n");
133
+ }