@kardalum/plugin-sdk 0.16.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 (164) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/admin-section-registry.d.ts +14 -5
  3. package/dist/admin-section-registry.js +14 -4
  4. package/dist/capabilities.js +0 -3
  5. package/dist/host-entry.d.ts +1 -1
  6. package/dist/host-entry.js +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.js +8 -8
  9. package/dist/license-verdict-keys.d.ts +4 -3
  10. package/dist/license-verdict-keys.js +4 -7
  11. package/dist/manifest-entry.d.ts +2 -2
  12. package/dist/manifest-entry.js +1 -1
  13. package/dist/manifest-schema.d.ts +51 -62
  14. package/dist/manifest-schema.js +97 -249
  15. package/dist/manifest.d.ts +41 -73
  16. package/dist/manifest.js +13 -36
  17. package/dist/plugin-screen-context.d.ts +11 -1
  18. package/dist/richtext/block-panel.js +2 -2
  19. package/dist/richtext/insert-menu.js +1 -1
  20. package/dist/richtext/style-listbox.js +4 -4
  21. package/dist/tokens/tokens.css +1 -0
  22. package/dist/tokens/tokens.json +2 -1
  23. package/dist/type-equality.d.ts +2 -0
  24. package/dist/type-equality.js +1 -0
  25. package/dist/views/html-view.js +1 -1
  26. package/dist/views/rich-text-view.js +1 -1
  27. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
  28. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +32 -1
  29. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +22 -1
  30. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +50 -15
  31. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
  32. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
  33. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +6 -5
  34. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
  35. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
  36. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
  37. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
  38. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +41 -5
  39. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +23 -9
  40. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +36 -20
  41. package/node_modules/@kardalum/api-schemas/dist/index.js +21 -11
  42. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
  43. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
  44. package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
  45. package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
  46. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +101 -62
  47. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +15 -4
  48. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
  49. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
  50. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +1 -16
  51. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +3 -19
  52. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -15
  53. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
  54. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
  55. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +1 -1
  56. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +97 -85
  57. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +35 -68
  58. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
  59. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
  60. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +9 -2
  61. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +22 -7
  62. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +13 -6
  63. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +7 -1
  64. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +4 -3
  65. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +1 -1
  66. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +14 -0
  67. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
  68. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
  69. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
  70. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
  71. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
  72. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +74 -0
  73. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +132 -0
  74. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
  75. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
  76. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +12 -3
  77. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +11 -0
  78. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +7 -0
  79. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +11 -2
  80. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +21 -3
  81. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
  82. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
  83. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +6 -6
  84. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +44 -25
  85. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +187 -48
  86. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +15 -3
  87. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +14 -0
  88. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
  89. package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
  90. package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
  91. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +105 -1
  92. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +43 -3
  93. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +30 -2
  94. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +19 -5
  95. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
  96. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
  97. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +4 -0
  98. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +3 -0
  99. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +19 -0
  100. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +22 -0
  101. package/node_modules/@kardalum/api-schemas/package.json +2 -2
  102. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
  103. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  104. package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
  105. package/node_modules/@kardalum/design-tokens/dist/tokens.js +3 -0
  106. package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
  107. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
  108. package/node_modules/@kardalum/plugin-package/README.md +4 -1
  109. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +6 -21
  110. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +13 -8
  111. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  112. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +9 -14
  113. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
  114. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
  115. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
  116. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
  117. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
  118. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
  119. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +5 -0
  120. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +60 -0
  121. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
  122. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
  123. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
  124. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
  125. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
  126. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
  127. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
  128. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
  129. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
  130. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
  131. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
  132. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
  133. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
  134. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
  135. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
  136. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +133 -0
  137. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
  138. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
  139. package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
  140. package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
  141. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +6 -0
  142. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +158 -0
  143. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
  144. package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
  145. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
  146. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
  147. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
  148. package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
  149. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +9 -2
  150. package/node_modules/@kardalum/plugin-package/dist/index.js +7 -2
  151. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
  152. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
  153. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +1 -0
  154. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +1 -0
  155. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +21 -3
  156. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +37 -9
  157. package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
  158. package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
  159. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
  160. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
  161. package/node_modules/@kardalum/plugin-package/package.json +4 -2
  162. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
  163. package/node_modules/@kardalum/ui/package.json +1 -1
  164. package/package.json +6 -6
@@ -1,9 +1,7 @@
1
1
  import { z } from "zod";
2
- import { CultureSchema } from "./content-api.schema.js";
3
2
  import { PluginRoleOfferSchema } from "./plugin-actions.schema.js";
4
- import { HOSTILE_CHARS_MESSAGE, hasHostileChars } from "./plugin-docs-text.js";
5
3
  import { SLOT_ID_MAX, SLOT_ID_REGEX } from "./plugin-id-rules.js";
6
- import { DOCS_LANGUAGE_MAX_LENGTH } from "./plugin-locales.js";
4
+ import { LABEL_KEY_MAX_LENGTH, LABEL_MAX_LANGUAGES, PluginLabelSchema, labelMapSchema, labelTextSchema, pluginLabelMapSchema } from "./plugin-labels.js";
7
5
  import { RoleIdSchema } from "./role.schema.js";
8
6
  // S292 (2026-10-13-s292-what-the-wizard-may-ask-design.md): what a plugin's
9
7
  // install asks, declared as plain data in the manifest's `install`, so the
@@ -28,11 +26,12 @@ export const INSTALL_MAX_CHOICES_PER_OPTION = 64;
28
26
  export const INSTALL_LABEL_MAX_LENGTH = 120;
29
27
  /** The longest a description's text may be, per language. */
30
28
  export const INSTALL_DESCRIPTION_MAX_LENGTH = 500;
31
- /** The most languages one label or description may carry. */
32
- export const INSTALL_LABEL_MAX_LANGUAGES = 32;
29
+ /** The most languages one label or description may carry: every label map's
30
+ * bound (plugin-labels.ts). */
31
+ export const INSTALL_LABEL_MAX_LANGUAGES = LABEL_MAX_LANGUAGES;
33
32
  /** The longest language code a label's key may be: DocsLanguageSchema's
34
33
  * bound, checked before the culture pattern ever sees the key. */
35
- export const INSTALL_LABEL_KEY_MAX_LENGTH = DOCS_LANGUAGE_MAX_LENGTH;
34
+ export const INSTALL_LABEL_KEY_MAX_LENGTH = LABEL_KEY_MAX_LENGTH;
36
35
  /** The most option answers one answers object may carry: every option of a full declaration. */
37
36
  export const INSTALL_MAX_OPTION_ANSWERS = INSTALL_MAX_STEPS * INSTALL_MAX_OPTIONS_PER_STEP;
38
37
  /** The most offered roles one answers object may name. */
@@ -45,58 +44,13 @@ export const INSTALL_OPTION_KINDS = ["boolean", "select", "multiSelect"];
45
44
  * and the answers schema as keys, and no answers object can reach a
46
45
  * prototype. */
47
46
  const RESERVED_ANSWER_KEYS = new Set(["__proto__", "constructor", "prototype"]);
48
- // One text of a label map: at most `max` characters, never empty or only
49
- // whitespace (a blank question on a screen, and a blank English label is one
50
- // the generated reference refuses), and no Trojan-Source character.
51
- function installText(max) {
52
- return z
53
- .string({ error: "must be text" })
54
- .max(max, { message: `is at most ${max} characters` })
55
- .refine((text) => text.trim() !== "", { message: "must not be empty" })
56
- .refine((text) => !hasHostileChars(text), { message: HOSTILE_CHARS_MESSAGE });
57
- }
58
- /** A label map's keys, bounded before the map is read: at most
59
- * INSTALL_LABEL_MAX_LANGUAGES of them, each at most
60
- * INSTALL_LABEL_KEY_MAX_LENGTH characters. An issue raised here ends the
61
- * preprocess's pipe, so the map is not read at all: a map of thousands of
62
- * keys costs one count, and a key too long to be a language code is never
63
- * echoed, neither in a message nor in a path (where reading the map would
64
- * put it, under a text the map refuses). */
65
- function boundLabelKeys(value, ctx) {
66
- if (value === null || typeof value !== "object" || Array.isArray(value))
67
- return value;
68
- const keys = Object.keys(value);
69
- if (keys.length > INSTALL_LABEL_MAX_LANGUAGES) {
70
- ctx.addIssue({ code: "custom", message: `a label holds at most ${INSTALL_LABEL_MAX_LANGUAGES} languages` });
71
- }
72
- if (keys.some((key) => key.length > INSTALL_LABEL_KEY_MAX_LENGTH)) {
73
- ctx.addIssue({ code: "custom", message: `label keys are language codes of at most ${INSTALL_LABEL_KEY_MAX_LENGTH} characters` });
74
- }
75
- return value;
76
- }
77
- // A label map: a language code to the text shown in that language, `en`
78
- // required because every other language falls back to it. Its keys are
79
- // bounded first (boundLabelKeys), then follow a slot label's rule
80
- // (CultureSchema), with the same message.
81
- function installLabelMap(max) {
82
- const text = installText(max);
83
- return z.preprocess(boundLabelKeys, z
84
- .object({ en: text })
85
- .catchall(text)
86
- .superRefine((label, ctx) => {
87
- for (const key of Object.keys(label)) {
88
- if (!CultureSchema.safeParse(key).success) {
89
- ctx.addIssue({
90
- code: "custom",
91
- message: `label keys are language codes such as "en", "de" or "pt-BR", not ${JSON.stringify(key)}`,
92
- path: [key],
93
- });
94
- }
95
- }
96
- }));
97
- }
98
- export const InstallLabelSchema = installLabelMap(INSTALL_LABEL_MAX_LENGTH);
99
- export const InstallDescriptionSchema = installLabelMap(INSTALL_DESCRIPTION_MAX_LENGTH);
47
+ // One text of a label map, and a label map itself: the one bounded rule every
48
+ // label of the manifest follows (plugin-labels.ts), with the install's own text
49
+ // lengths. A blank question on a screen, a key too long to be a language code
50
+ // and a Trojan-Source character are refused here as everywhere else.
51
+ const installText = (max) => labelTextSchema({ max });
52
+ export const InstallLabelSchema = labelMapSchema({ max: INSTALL_LABEL_MAX_LENGTH });
53
+ export const InstallDescriptionSchema = labelMapSchema({ max: INSTALL_DESCRIPTION_MAX_LENGTH });
100
54
  /** A step's, an option's or a choice's id: the slot id rule, so an id needs
101
55
  * no encoding anywhere it travels and can never be "." or "..". */
102
56
  export const InstallIdSchema = z
@@ -453,13 +407,19 @@ export const INSTALL_CONSENT_IDS = ["migrations", "documentTypes", "actions", "t
453
407
  * parts of a manifest no install schema bounds (the door's mirror leaves
454
408
  * `contributions` unvalidated) and shown as text, so it is held to a
455
409
  * label's text rule: at most 120 characters, never only whitespace, no
456
- * control or direction-override character. */
457
- const InstallConsentDetailSchema = installText(INSTALL_LABEL_MAX_LENGTH);
410
+ * control or direction-override character. An action's label may be a
411
+ * language map (S311), carried as declared under the map rule the action's
412
+ * own declaration follows (PluginLabelMapSchema), so a label the manifest
413
+ * accepts is always a name the screen can show in its own language. */
414
+ const InstallConsentTextSchema = installText(INSTALL_LABEL_MAX_LENGTH);
415
+ const InstallConsentLabelMapSchema = pluginLabelMapSchema();
416
+ const InstallConsentDetailSchema = z.union([InstallConsentTextSchema, InstallConsentLabelMapSchema]);
458
417
  // The interface's parts, once: InstallInterfaceSchema holds them closed, and
459
- // InstallInterfaceWireSchema below drops a key it does not know instead.
418
+ // InstallInterfaceWireSchema below drops a key it does not know instead. A
419
+ // role's label is the offer's, a string or a language map (S311).
460
420
  const consentItemShape = { id: z.string(), details: z.array(InstallConsentDetailSchema) };
461
421
  const sampleContentShape = { default: z.literal(true), description: InstallDescriptionSchema.optional() };
462
- const roleOfferShape = { id: z.string(), label: z.string(), actions: z.array(z.string()), default: z.literal(false) };
422
+ const roleOfferShape = { id: z.string(), label: PluginLabelSchema, actions: z.array(z.string()), default: z.literal(false) };
463
423
  /** The install interface: what a screen shows and a script answers, before
464
424
  * anything is installed. The marketplace stores it per version and its
465
425
  * listing API carries it to the admin. A consent id is an open string on
@@ -495,18 +455,25 @@ function asRecord(value) {
495
455
  }
496
456
  /** A consent entry's readable name: the entry itself when it is a string
497
457
  * (manifest.json's migration ids, an asset path), else its `field`, kept
498
- * only when it passes InstallConsentDetailSchema. */
499
- function readableName(entry, field) {
458
+ * only when it passes the detail's text rule. With `map`, the field may be a
459
+ * language map instead (an action's label, S311), kept when it passes
460
+ * PluginLabelMapSchema; every other name is an identifier and stays a string. */
461
+ function readableName(entry, field, map = false) {
500
462
  const value = typeof entry === "string" ? entry : asRecord(entry)?.[field];
501
- return typeof value === "string" && InstallConsentDetailSchema.safeParse(value).success ? value : null;
463
+ if (typeof value === "string")
464
+ return InstallConsentTextSchema.safeParse(value).success ? value : null;
465
+ if (!map)
466
+ return null;
467
+ const parsed = InstallConsentLabelMapSchema.safeParse(value);
468
+ return parsed.success ? parsed.data : null;
502
469
  }
503
470
  /** One consent item when the manifest declares any of it. A detail the text
504
471
  * rule refuses is left out of the list, and the item stays: what it names
505
472
  * is installed whether or not its name can be shown. */
506
- function consentItem(id, declared, field) {
473
+ function consentItem(id, declared, field, map = false) {
507
474
  if (!Array.isArray(declared) || declared.length === 0)
508
475
  return null;
509
- return { id, details: declared.map((entry) => readableName(entry, field)).filter((name) => name !== null) };
476
+ return { id, details: declared.map((entry) => readableName(entry, field, map)).filter((name) => name !== null) };
510
477
  }
511
478
  /** The interface a package's install asks, in the order a screen asks it:
512
479
  * the consent list, the sample content when it ships, one unticked question
@@ -517,7 +484,7 @@ export function installInterfaceFor(manifest, shipped) {
517
484
  const consent = [
518
485
  consentItem("migrations", manifest.migrations, "id"),
519
486
  consentItem("documentTypes", contributions.documentTypes, "name"),
520
- consentItem("actions", manifest.actions, "label"),
487
+ consentItem("actions", manifest.actions, "label", true),
521
488
  consentItem("templates", contributions.templates, "name"),
522
489
  consentItem("assets", contributions.assets, "path"),
523
490
  ].filter((item) => item !== null);
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ export type SlotLabelMap = {
3
+ en: string;
4
+ [language: string]: string;
5
+ };
6
+ export type PluginLabel = string | SlotLabelMap;
7
+ /** The most languages one label map may carry. */
8
+ export declare const LABEL_MAX_LANGUAGES = 32;
9
+ /** The longest language code a label map's key may be: the longest a locale
10
+ * file's name can carry (DocsLanguageSchema's bound), checked before the
11
+ * culture pattern ever sees the key. */
12
+ export declare const LABEL_KEY_MAX_LENGTH = 35;
13
+ export interface LabelTextRule {
14
+ /** The longest the text may be, after trimming when `trim` is set. */
15
+ max?: number;
16
+ /** Trim the text first, as a plain-string label is. */
17
+ trim?: boolean;
18
+ }
19
+ /** One text of a label: never empty or only whitespace (a blank tab or
20
+ * question, and a blank English label is one the generated reference
21
+ * refuses), no control or direction-override character, and at most `max`
22
+ * characters when given. Shown as text, never as markup. */
23
+ export declare function labelTextSchema({ max, trim }?: LabelTextRule): z.ZodString;
24
+ /** A label map: a language code to the text shown in that language, `en`
25
+ * required because every other language falls back to it. Its keys are
26
+ * bounded first (boundLabelKeys), then each is a language code under the
27
+ * same rule as the site's cultures setting (CultureSchema), so "" or
28
+ * "anything" is refused rather than carried as a language no locale can ever
29
+ * pick; every text follows labelTextSchema with `rule`. */
30
+ export declare function labelMapSchema(rule?: LabelTextRule): z.ZodPreprocess<z.ZodObject<{
31
+ en: z.ZodString;
32
+ }, z.core.$catchall<z.ZodString>>, unknown>;
33
+ /** A section's or a rail entry's label (S280): the map rule, at any length. */
34
+ export declare const SlotLabelSchema: z.ZodPreprocess<z.ZodObject<{
35
+ en: z.ZodString;
36
+ }, z.core.$catchall<z.ZodString>>, unknown>;
37
+ /** What the server stores for an action or an offered role is one string of at
38
+ * most 191 characters (MySQL's VARCHAR); 120 leaves room, and holds for every
39
+ * language of a map, since any of them may be the one stored. */
40
+ export declare const PLUGIN_LABEL_MAX = 120;
41
+ /** A label written as one string, trimmed, 1 to 120 characters. The generated
42
+ * reference carries this form, the English text of whatever was declared. */
43
+ export declare const PluginLabelStringSchema: z.ZodString;
44
+ /** A label written as a map, its texts trimmed as a string is: a fresh
45
+ * instance of the rule each call. The install screen's consent list holds an
46
+ * action's label map to exactly this rule through its own instance, because
47
+ * the OpenAPI conversion drops a schema instance that a new union reuses. */
48
+ export declare function pluginLabelMapSchema(): z.ZodPreprocess<z.ZodObject<{
49
+ en: z.ZodString;
50
+ }, z.core.$catchall<z.ZodString>>, unknown>;
51
+ export declare const PluginLabelMapSchema: z.ZodPreprocess<z.ZodObject<{
52
+ en: z.ZodString;
53
+ }, z.core.$catchall<z.ZodString>>, unknown>;
54
+ export declare const PluginLabelSchema: z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
55
+ en: z.ZodString;
56
+ }, z.core.$catchall<z.ZodString>>, unknown>]>;
57
+ /** The text of a label for a language: the language as given, else its primary
58
+ * subtag (`de-AT` reads `de`), else `en`, which every map carries. Codes
59
+ * compare case-insensitively (BCP 47 tags do). A plain string is its own text. */
60
+ export declare function resolveLabel(label: PluginLabel, language: string): string;
@@ -0,0 +1,116 @@
1
+ import { z } from "zod";
2
+ import { CultureSchema } from "./content-api.schema.js";
3
+ import { HOSTILE_CHARS_MESSAGE, hasHostileChars } from "./plugin-docs-text.js";
4
+ import { DOCS_LANGUAGE_MAX_LENGTH } from "./plugin-locales.js";
5
+ /** The most languages one label map may carry. */
6
+ export const LABEL_MAX_LANGUAGES = 32;
7
+ /** The longest language code a label map's key may be: the longest a locale
8
+ * file's name can carry (DocsLanguageSchema's bound), checked before the
9
+ * culture pattern ever sees the key. */
10
+ export const LABEL_KEY_MAX_LENGTH = DOCS_LANGUAGE_MAX_LENGTH;
11
+ /** A label map's keys, bounded before the map is read: at most
12
+ * LABEL_MAX_LANGUAGES of them, each at most LABEL_KEY_MAX_LENGTH characters.
13
+ * An issue raised here ends the preprocess's pipe, so the map is not read at
14
+ * all: a map of thousands of keys costs one count, and a key too long to be a
15
+ * language code is never echoed, neither in a message nor in a path (where
16
+ * reading the map would put it, under a text the map refuses). */
17
+ function boundLabelKeys(value, ctx) {
18
+ if (value === null || typeof value !== "object" || Array.isArray(value))
19
+ return value;
20
+ const keys = Object.keys(value);
21
+ if (keys.length > LABEL_MAX_LANGUAGES) {
22
+ ctx.addIssue({ code: "custom", message: `a label holds at most ${LABEL_MAX_LANGUAGES} languages` });
23
+ }
24
+ if (keys.some((key) => key.length > LABEL_KEY_MAX_LENGTH)) {
25
+ ctx.addIssue({ code: "custom", message: `label keys are language codes of at most ${LABEL_KEY_MAX_LENGTH} characters` });
26
+ }
27
+ return value;
28
+ }
29
+ /** One text of a label: never empty or only whitespace (a blank tab or
30
+ * question, and a blank English label is one the generated reference
31
+ * refuses), no control or direction-override character, and at most `max`
32
+ * characters when given. Shown as text, never as markup. */
33
+ export function labelTextSchema({ max, trim = false } = {}) {
34
+ let text = z.string({ error: "must be text" });
35
+ if (trim)
36
+ text = text.trim();
37
+ if (max !== undefined)
38
+ text = text.max(max, { message: `is at most ${max} characters` });
39
+ return text
40
+ .refine((value) => value.trim() !== "", { message: "must not be empty" })
41
+ .refine((value) => !hasHostileChars(value), { message: HOSTILE_CHARS_MESSAGE });
42
+ }
43
+ /** A label map: a language code to the text shown in that language, `en`
44
+ * required because every other language falls back to it. Its keys are
45
+ * bounded first (boundLabelKeys), then each is a language code under the
46
+ * same rule as the site's cultures setting (CultureSchema), so "" or
47
+ * "anything" is refused rather than carried as a language no locale can ever
48
+ * pick; every text follows labelTextSchema with `rule`. */
49
+ export function labelMapSchema(rule = {}) {
50
+ const text = labelTextSchema(rule);
51
+ return z.preprocess(boundLabelKeys, z
52
+ .object({ en: text })
53
+ .catchall(text)
54
+ .superRefine((label, ctx) => {
55
+ for (const key of Object.keys(label)) {
56
+ if (!CultureSchema.safeParse(key).success) {
57
+ ctx.addIssue({
58
+ code: "custom",
59
+ message: `label keys are language codes such as "en", "de" or "pt-BR", not ${JSON.stringify(key)}`,
60
+ path: [key],
61
+ });
62
+ }
63
+ }
64
+ }));
65
+ }
66
+ /** A section's or a rail entry's label (S280): the map rule, at any length. */
67
+ export const SlotLabelSchema = labelMapSchema();
68
+ /** What the server stores for an action or an offered role is one string of at
69
+ * most 191 characters (MySQL's VARCHAR); 120 leaves room, and holds for every
70
+ * language of a map, since any of them may be the one stored. */
71
+ export const PLUGIN_LABEL_MAX = 120;
72
+ /** A label written as one string, trimmed, 1 to 120 characters. The generated
73
+ * reference carries this form, the English text of whatever was declared. */
74
+ export const PluginLabelStringSchema = labelTextSchema({ max: PLUGIN_LABEL_MAX, trim: true });
75
+ /** A label written as a map, its texts trimmed as a string is: a fresh
76
+ * instance of the rule each call. The install screen's consent list holds an
77
+ * action's label map to exactly this rule through its own instance, because
78
+ * the OpenAPI conversion drops a schema instance that a new union reuses. */
79
+ export function pluginLabelMapSchema() {
80
+ return labelMapSchema({ max: PLUGIN_LABEL_MAX, trim: true });
81
+ }
82
+ export const PluginLabelMapSchema = pluginLabelMapSchema();
83
+ const LABEL_HINT = "a string, or a map with en required";
84
+ /** A label neither branch accepts is explained once: a map that carries its
85
+ * English text by the map's own first problem (too many languages, a key that
86
+ * is not a language code, a text that is not one), anything else by what a
87
+ * label is. */
88
+ function labelUnionError(issue) {
89
+ if (issue.code !== "invalid_union")
90
+ return undefined;
91
+ const value = issue.input;
92
+ const first = issue.errors?.[1]?.[0];
93
+ if (value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.en === "string" && first) {
94
+ return first.path.length > 0 ? `${first.path.map(String).join(".")}: ${first.message}` : first.message;
95
+ }
96
+ return LABEL_HINT;
97
+ }
98
+ export const PluginLabelSchema = z.union([PluginLabelStringSchema, PluginLabelMapSchema], { error: labelUnionError });
99
+ /** The text of a label for a language: the language as given, else its primary
100
+ * subtag (`de-AT` reads `de`), else `en`, which every map carries. Codes
101
+ * compare case-insensitively (BCP 47 tags do). A plain string is its own text. */
102
+ export function resolveLabel(label, language) {
103
+ if (typeof label === "string")
104
+ return label;
105
+ const wanted = language.toLowerCase();
106
+ const primary = wanted.split("-")[0] ?? "";
107
+ let primaryText;
108
+ for (const [code, text] of Object.entries(label)) {
109
+ const lower = code.toLowerCase();
110
+ if (lower === wanted)
111
+ return text;
112
+ if (primaryText === undefined && primary !== "" && lower === primary)
113
+ primaryText = text;
114
+ }
115
+ return primaryText ?? label.en;
116
+ }
@@ -71,5 +71,12 @@ export type PluginLanguages = z.infer<typeof PluginLanguagesSchema>;
71
71
  * (extra keys and placeholder drift are author errors `validate` fails,
72
72
  * not missing words). With no readable en.json there is nothing to compare,
73
73
  * so no other language is complete. `docs` is a language code the caller
74
- * has already checked. */
75
- export declare function summarizePluginLanguages(bundles: ReadonlyMap<string, PluginLocaleFile>, docs: string): PluginLanguages;
74
+ * has already checked.
75
+ *
76
+ * S311: `labelLanguages` are the language codes the manifest's label maps
77
+ * use. A language only labels use is listed too, and is never complete: its
78
+ * screens' words show English. A code is taken under DocsLanguageSchema's
79
+ * rule (a language code of at most 35 characters, the longest a locale
80
+ * file's name can carry), and one a file already lists, in any case, is not
81
+ * listed twice. */
82
+ export declare function summarizePluginLanguages(bundles: ReadonlyMap<string, PluginLocaleFile>, docs: string, labelLanguages?: ReadonlyArray<string>): PluginLanguages;
@@ -196,17 +196,32 @@ export const PluginLanguagesSchema = z
196
196
  * (extra keys and placeholder drift are author errors `validate` fails,
197
197
  * not missing words). With no readable en.json there is nothing to compare,
198
198
  * so no other language is complete. `docs` is a language code the caller
199
- * has already checked. */
200
- export function summarizePluginLanguages(bundles, docs) {
199
+ * has already checked.
200
+ *
201
+ * S311: `labelLanguages` are the language codes the manifest's label maps
202
+ * use. A language only labels use is listed too, and is never complete: its
203
+ * screens' words show English. A code is taken under DocsLanguageSchema's
204
+ * rule (a language code of at most 35 characters, the longest a locale
205
+ * file's name can carry), and one a file already lists, in any case, is not
206
+ * listed twice. */
207
+ export function summarizePluginLanguages(bundles, docs, labelLanguages = []) {
201
208
  const en = bundles.get("en");
202
- const others = [...bundles.keys()].filter((code) => code !== "en").sort();
209
+ const codes = new Set(bundles.keys());
210
+ const listed = new Set([...codes].map((code) => code.toLowerCase()));
211
+ for (const code of labelLanguages) {
212
+ if (listed.has(code.toLowerCase()) || !DocsLanguageSchema.safeParse(code).success)
213
+ continue;
214
+ codes.add(code);
215
+ listed.add(code.toLowerCase());
216
+ }
217
+ const others = [...codes].filter((code) => code !== "en").sort();
203
218
  return {
204
219
  ui: [
205
220
  { code: "en", complete: true },
206
- ...others.map((code) => ({
207
- code,
208
- complete: en !== undefined && compareLocaleFiles(en, bundles.get(code)).missing.length === 0,
209
- })),
221
+ ...others.map((code) => {
222
+ const bundle = bundles.get(code);
223
+ return { code, complete: en !== undefined && bundle !== undefined && compareLocaleFiles(en, bundle).missing.length === 0 };
224
+ }),
210
225
  ],
211
226
  docs,
212
227
  };
@@ -4,7 +4,9 @@ import { z } from "zod";
4
4
  * without reading the roles list (which needs roles.read). */
5
5
  export declare const ManagedPluginRoleOfferSchema: z.ZodObject<{
6
6
  id: z.ZodString;
7
- label: z.ZodString;
7
+ label: z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
8
+ en: z.ZodString;
9
+ }, z.core.$catchall<z.ZodString>>, unknown>]>;
8
10
  actions: z.ZodArray<z.ZodString>;
9
11
  created: z.ZodBoolean;
10
12
  }, z.core.$strip>;
@@ -27,8 +29,8 @@ export declare const ManagedPluginSchema: z.ZodObject<{
27
29
  unverified: "unverified";
28
30
  }>;
29
31
  storageType: z.ZodEnum<{
30
- structured: "structured";
31
32
  simple: "simple";
33
+ structured: "structured";
32
34
  }>;
33
35
  enabled: z.ZodBoolean;
34
36
  licenseStatus: z.ZodNullable<z.ZodString>;
@@ -48,7 +50,9 @@ export declare const ManagedPluginSchema: z.ZodObject<{
48
50
  buyHref: z.ZodNullable<z.ZodString>;
49
51
  roleOffers: z.ZodArray<z.ZodObject<{
50
52
  id: z.ZodString;
51
- label: z.ZodString;
53
+ label: z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
54
+ en: z.ZodString;
55
+ }, z.core.$catchall<z.ZodString>>, unknown>]>;
52
56
  actions: z.ZodArray<z.ZodString>;
53
57
  created: z.ZodBoolean;
54
58
  }, z.core.$strip>>;
@@ -73,8 +77,8 @@ export declare const ManagedPluginListResponseSchema: z.ZodObject<{
73
77
  unverified: "unverified";
74
78
  }>;
75
79
  storageType: z.ZodEnum<{
76
- structured: "structured";
77
80
  simple: "simple";
81
+ structured: "structured";
78
82
  }>;
79
83
  enabled: z.ZodBoolean;
80
84
  licenseStatus: z.ZodNullable<z.ZodString>;
@@ -94,7 +98,9 @@ export declare const ManagedPluginListResponseSchema: z.ZodObject<{
94
98
  buyHref: z.ZodNullable<z.ZodString>;
95
99
  roleOffers: z.ZodArray<z.ZodObject<{
96
100
  id: z.ZodString;
97
- label: z.ZodString;
101
+ label: z.ZodUnion<readonly [z.ZodString, z.ZodPreprocess<z.ZodObject<{
102
+ en: z.ZodString;
103
+ }, z.core.$catchall<z.ZodString>>, unknown>]>;
98
104
  actions: z.ZodArray<z.ZodString>;
99
105
  created: z.ZodBoolean;
100
106
  }, z.core.$strip>>;
@@ -350,11 +356,12 @@ export declare const PluginUploadResponseSchema: z.ZodObject<{
350
356
  roles: z.ZodOptional<z.ZodArray<z.ZodObject<{
351
357
  id: z.ZodString;
352
358
  outcome: z.ZodEnum<{
359
+ failed: "failed";
353
360
  created: "created";
354
361
  "already-exists": "already-exists";
355
- failed: "failed";
356
362
  }>;
357
363
  }, z.core.$strip>>>;
364
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
365
  }, z.core.$strip>;
359
366
  export type PluginUploadResponse = z.infer<typeof PluginUploadResponseSchema>;
360
367
  /** S274c: the upload's confirmation travels as a query flag because the
@@ -2,6 +2,8 @@ import { z } from "zod";
2
2
  import { PluginRoleOfferSchema } from "./plugin-actions.schema.js";
3
3
  import { InstallRoleOutcomeSchema } from "./plugin-install-record.schema.js";
4
4
  import { SampleContentOutcomeSchema } from "./sample-content-outcome.schema.js";
5
+ import { InstallWarningsSchema } from "./install-warnings.schema.js";
6
+ import { STORAGE_TYPES } from "./plugin-vocabulary.js";
5
7
  // The ADMIN management view of the registry (S135): unlike the public
6
8
  // GET /api/plugins (enabled-only, boot-loader metadata), this surface
7
9
  // lists every installed plugin, disabled included. licenseStatus reflects
@@ -55,7 +57,7 @@ export const ManagedPluginSchema = z.object({
55
57
  type: z.string(),
56
58
  version: z.string(),
57
59
  trustTier: z.enum(["verified", "unverified"]),
58
- storageType: z.enum(["simple", "structured"]),
60
+ storageType: z.enum(STORAGE_TYPES),
59
61
  enabled: z.boolean(),
60
62
  licenseStatus: z
61
63
  .string()
@@ -389,6 +391,10 @@ export const PluginUploadResponseSchema = z.object({
389
391
  // S293: what the install did with each offered role its answers named;
390
392
  // absent when they named none.
391
393
  roles: z.array(InstallRoleOutcomeSchema).optional(),
394
+ // S314 (D4, W7): on an update, one sentence per template or asset the
395
+ // update did not apply as shipped, or removed. Absent on a fresh install
396
+ // and when there is nothing to say.
397
+ warnings: InstallWarningsSchema.optional(),
392
398
  });
393
399
  /** S274c: the upload's confirmation travels as a query flag because the
394
400
  * route reads only the multipart file part. */
@@ -1,7 +1,8 @@
1
+ import type { PluginLabel } from "./plugin-labels.js";
1
2
  /** The contribution kinds that sit behind a named action. The SDK classifies
2
3
  * these on its CONTRIBUTION_RULES table; its test pins that table to this
3
4
  * list, so the two cannot drift apart silently. */
4
- export declare const ACTION_GATED_CONTRIBUTION_KEYS: readonly ["adminSections", "railEntries", "dashboardWidgets", "settingsPages", "contentTreeActions", "editorToolbar", "apiRoutes"];
5
+ export declare const ACTION_GATED_CONTRIBUTION_KEYS: readonly ["adminSections", "railEntries", "dashboardWidgets", "apiRoutes"];
5
6
  /** S293 (S283's decision, 2026-10-13-s293-the-wizard-installed-design.md 3.9):
6
7
  * the built-in rights an offered role may grant beside the plugin's own
7
8
  * actions: the read right of each built-in section a rail entry may join
@@ -17,11 +18,11 @@ export interface ActionDeclarationInput {
17
18
  id: string;
18
19
  actions?: ReadonlyArray<{
19
20
  id: string;
20
- label: string;
21
+ label: PluginLabel;
21
22
  }>;
22
23
  roles?: ReadonlyArray<{
23
24
  id: string;
24
- label: string;
25
+ label: PluginLabel;
25
26
  actions: ReadonlyArray<string>;
26
27
  }>;
27
28
  contributions?: unknown;
@@ -10,7 +10,7 @@ import { isPluginActionFor } from "./action.schema.js";
10
10
  /** The contribution kinds that sit behind a named action. The SDK classifies
11
11
  * these on its CONTRIBUTION_RULES table; its test pins that table to this
12
12
  * list, so the two cannot drift apart silently. */
13
- export const ACTION_GATED_CONTRIBUTION_KEYS = ["adminSections", "railEntries", "dashboardWidgets", "settingsPages", "contentTreeActions", "editorToolbar", "apiRoutes"];
13
+ export const ACTION_GATED_CONTRIBUTION_KEYS = ["adminSections", "railEntries", "dashboardWidgets", "apiRoutes"];
14
14
  /** S293 (S283's decision, 2026-10-13-s293-the-wizard-installed-design.md 3.9):
15
15
  * the built-in rights an offered role may grant beside the plugin's own
16
16
  * actions: the read right of each built-in section a rail entry may join
@@ -6,10 +6,12 @@ export declare const API_ROUTE_METHODS: readonly ["GET", "POST", "PUT", "PATCH",
6
6
  export declare const API_ROUTE_RESPONSE_STATUSES_MAX = 4;
7
7
  /** True for a success status code written canonically as a string: "200" to "299". Linear, no pattern. */
8
8
  export declare function isApiRouteResponseStatus(key: string): boolean;
9
+ type ApiRouteMethod = (typeof API_ROUTE_METHODS)[number];
9
10
  /** The longest declared path, checked before the path is split. */
10
11
  export declare const API_ROUTE_PATH_MAX = 200;
11
12
  /** The most apiRoutes one manifest declares, which bounds the pairwise check. */
12
13
  export declare const API_ROUTES_MAX = 200;
14
+ export declare const isApiRouteMethod: (value: unknown) => value is ApiRouteMethod;
13
15
  export interface ApiRouteDeclarationIssue {
14
16
  path: (string | number)[];
15
17
  message: string;
@@ -42,3 +44,15 @@ export declare function checkApiRouteDeclarations(manifest: {
42
44
  export declare function checkApiRouteActions(manifest: {
43
45
  contributions?: unknown;
44
46
  }): ApiRouteDeclarationIssue[];
47
+ /** The `:name` parameters of a route path, in order. The one segment parser the
48
+ * SDK's `schema.params` rule and the path rule share. */
49
+ export declare function apiRoutePathParams(path: string): string[];
50
+ /** S311 (S295): the method and tier of every apiRoute, as the SDK's enums
51
+ * enforce them, for the gate that never sees Zod. checkApiRouteDeclarations
52
+ * skips an entry whose method is not in the list because "the schema reports
53
+ * it"; the door has no such schema, so `"get"` published. An absent `access` is
54
+ * the documented default and stays valid; an unknown string is an error. */
55
+ export declare function checkApiRouteTiers(manifest: {
56
+ contributions?: unknown;
57
+ }): ApiRouteDeclarationIssue[];
58
+ export {};
@@ -1,3 +1,4 @@
1
+ import { API_ROUTE_ACCESS_TIERS } from "./plugin-vocabulary.js";
1
2
  // S295 (2026-10-14-s295-routes-fastify-knows-about-design.md 3.1): the rule for
2
3
  // what a plugin may declare as an apiRoute's address, as plain data, so the
3
4
  // SDK's manifest schema (and through it `kardalum plugin validate`), the
@@ -23,7 +24,7 @@ export const API_ROUTE_PATH_MAX = 200;
23
24
  export const API_ROUTES_MAX = 200;
24
25
  // A string of another length fails each of the five comparisons on its length
25
26
  // alone, so a hostile method costs five length checks and nothing more.
26
- const isApiRouteMethod = (value) => typeof value === "string" && API_ROUTE_METHODS.includes(value);
27
+ export const isApiRouteMethod = (value) => typeof value === "string" && API_ROUTE_METHODS.includes(value);
27
28
  // Fixed, anchored, one character class each, so linear on any input. A
28
29
  // parameter's name starts with a letter and holds no "-" or ".", which the
29
30
  // router reads as the start of a static part inside a parameter segment.
@@ -160,3 +161,38 @@ export function checkApiRouteActions(manifest) {
160
161
  });
161
162
  return issues;
162
163
  }
164
+ /** The `:name` parameters of a route path, in order. The one segment parser the
165
+ * SDK's `schema.params` rule and the path rule share. */
166
+ export function apiRoutePathParams(path) {
167
+ return path
168
+ .split("/")
169
+ .filter((segment) => segment.startsWith(":"))
170
+ .map((segment) => segment.slice(1));
171
+ }
172
+ /** S311 (S295): the method and tier of every apiRoute, as the SDK's enums
173
+ * enforce them, for the gate that never sees Zod. checkApiRouteDeclarations
174
+ * skips an entry whose method is not in the list because "the schema reports
175
+ * it"; the door has no such schema, so `"get"` published. An absent `access` is
176
+ * the documented default and stays valid; an unknown string is an error. */
177
+ export function checkApiRouteTiers(manifest) {
178
+ const contributions = manifest.contributions;
179
+ const routes = contributions !== null && typeof contributions === "object" ? contributions.apiRoutes : undefined;
180
+ if (!Array.isArray(routes))
181
+ return [];
182
+ const issues = [];
183
+ routes.forEach((entry, index) => {
184
+ const base = ["contributions", "apiRoutes", index];
185
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
186
+ issues.push({ path: base, message: "an apiRoute must be an object" });
187
+ return;
188
+ }
189
+ const route = entry;
190
+ if (!isApiRouteMethod(route.method)) {
191
+ issues.push({ path: [...base, "method"], message: `method must be one of ${API_ROUTE_METHODS.join(", ")}, got ${JSON.stringify(route.method)}` });
192
+ }
193
+ if (route.access !== undefined && !API_ROUTE_ACCESS_TIERS.includes(route.access)) {
194
+ issues.push({ path: [...base, "access"], message: `access must be one of ${API_ROUTE_ACCESS_TIERS.join(", ")}, got ${JSON.stringify(route.access)}` });
195
+ }
196
+ });
197
+ return issues;
198
+ }