@kardalum/plugin-sdk 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +10 -0
  3. package/dist/built-in-value-schemas.js +1 -1
  4. package/dist/built-ins.js +2 -2
  5. package/dist/capabilities.d.ts +8 -78
  6. package/dist/capabilities.js +23 -319
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.js +5 -4
  9. package/dist/license-verdict-keys.js +4 -0
  10. package/dist/manifest-entry.d.ts +2 -2
  11. package/dist/manifest-entry.js +1 -1
  12. package/dist/manifest-schema.d.ts +81 -13
  13. package/dist/manifest-schema.js +108 -59
  14. package/dist/manifest.d.ts +105 -40
  15. package/dist/media/media-picker.js +21 -12
  16. package/dist/media/upload-error.d.ts +1 -1
  17. package/dist/media/upload-error.js +1 -1
  18. package/dist/plugin-context.d.ts +7 -0
  19. package/dist/plugin-context.js +7 -0
  20. package/dist/plugin-screen-context.d.ts +33 -2
  21. package/dist/plugin-screen-context.js +27 -2
  22. package/dist/read-all-pages.d.ts +23 -0
  23. package/dist/read-all-pages.js +30 -0
  24. package/dist/richtext/block-panel.js +4 -4
  25. package/dist/richtext/insert-menu.js +3 -3
  26. package/dist/views/content-list-view.js +2 -2
  27. package/dist/views/image-view.js +24 -39
  28. package/dist/views/rich-text-view.js +2 -2
  29. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
  30. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
  31. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
  32. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
  33. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +1 -1
  34. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
  35. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +12 -8
  36. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
  37. package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
  38. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
  39. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +107 -57
  40. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +96 -60
  41. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
  42. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
  43. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
  44. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +39 -28
  45. package/node_modules/@kardalum/api-schemas/dist/index.js +19 -13
  46. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  47. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  48. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +302 -1
  49. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +78 -6
  50. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
  51. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
  52. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
  53. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
  54. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +82 -2
  55. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
  56. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +88 -5
  57. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +79 -17
  58. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  59. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  60. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
  61. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
  62. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
  63. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
  64. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +25 -3
  65. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +21 -1
  66. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +7 -0
  67. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +16 -3
  68. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
  69. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
  70. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
  71. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +11 -1
  72. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
  73. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +6 -0
  74. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +6 -0
  75. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
  76. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
  77. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
  78. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
  79. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +8 -8
  80. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +8 -8
  81. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +4 -0
  82. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +2 -0
  83. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +4 -4
  84. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +11 -3
  85. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +5 -0
  86. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
  87. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
  88. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  89. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
  90. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +3 -1
  91. package/node_modules/@kardalum/plugin-package/dist/index.js +2 -1
  92. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
  93. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
  94. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -1
  95. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +56 -16
  96. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
  97. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
  98. package/node_modules/@kardalum/plugin-package/package.json +5 -0
  99. package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
  100. package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
  101. package/package.json +2 -2
@@ -103,32 +103,94 @@ export function requiredDocRoles(facts) {
103
103
  return required;
104
104
  }
105
105
  // reference.json: the serialisable facts the generated Reference pages are
106
- // rendered from (spec section 7). Written by `kardalum plugin build`. JSON
107
- // schemas and field definitions are carried as plain data, never validated
108
- // here beyond being JSON.
106
+ // rendered from (S285 section 7, widened to seven pages by S289). Written by
107
+ // `kardalum plugin build` through buildReference in
108
+ // @kardalum/plugin-package/reference; built live from the attached manifest
109
+ // by the server for an installed plugin. JSON schemas and field definitions
110
+ // are carried as plain data, never validated here beyond being JSON. Every
111
+ // string is shown as text, never as markup.
112
+ /** A slot label as reference.json carries it: language code to text, with
113
+ * the English text every slot label must have. */
114
+ export const ReferenceLabelMapSchema = z
115
+ .record(z.string(), z.string())
116
+ .refine((label) => typeof label.en === "string" && label.en.trim().length > 0, 'a label carries its English text under "en"');
117
+ const gated = { id: z.string(), action: z.string() };
118
+ // S292: one row per option a manifest's `install` declares, carrying its
119
+ // step's label, for the lifecycle page's "Install asks" table. `required` is
120
+ // installOptionNeedsAnswer's answer, which buildReference writes inline (it
121
+ // may take only types from this package). The list defaults to empty, so a
122
+ // reference.json written by a CLI older than S292 still parses.
123
+ const ReferenceInstallOptionSchema = z
124
+ .object({
125
+ step: ReferenceLabelMapSchema,
126
+ id: z.string(),
127
+ label: ReferenceLabelMapSchema,
128
+ kind: z.string(),
129
+ choices: z.array(z.object({ id: z.string(), label: ReferenceLabelMapSchema }).strict()),
130
+ default: z.union([z.boolean(), z.string(), z.array(z.string())]).nullable(),
131
+ required: z.boolean(),
132
+ })
133
+ .strict();
109
134
  export const PluginReferenceSchema = z
110
135
  .object({
111
136
  actions: z.array(PluginActionDeclarationSchema),
112
137
  roles: z.array(PluginRoleOfferSchema),
113
138
  apiRoutes: z.array(z.object({ method: z.string(), path: z.string(), access: z.string(), action: z.string().optional() }).strict()),
114
- capabilities: z.array(z.object({ id: z.string(), mediation: z.string(), payload: z.unknown().optional() }).strict()),
139
+ capabilities: z.array(z
140
+ .object({
141
+ id: z.string(),
142
+ mediation: z.enum(["mediated", "promised"]),
143
+ payload: z.object({ count: z.number().int().nonnegative(), details: z.array(z.string()) }).strict(),
144
+ })
145
+ .strict()),
115
146
  documentTypes: z.array(z.object({ name: z.string(), kind: z.string(), fields: z.array(z.unknown()) }).passthrough()),
116
147
  dataTypes: z.array(z.object({ id: z.string(), name: z.string() }).passthrough()),
148
+ templates: z.array(z.object({ name: z.string(), alias: z.string(), kind: z.string(), documentType: z.string().optional() }).strict()),
117
149
  settingsPages: z.array(z.object({ id: z.string(), name: z.string(), action: z.string() }).strict()),
150
+ adminSections: z.array(z.object({ ...gated, label: ReferenceLabelMapSchema, rail: z.array(z.object({ ...gated, label: ReferenceLabelMapSchema }).strict()) }).strict()),
151
+ railEntries: z.array(z.object({ ...gated, label: ReferenceLabelMapSchema, section: z.string() }).strict()),
152
+ dashboardWidgets: z.array(z.object({ ...gated, name: z.string() }).strict()),
153
+ editorToolbar: z.array(z.object({ ...gated, label: z.string() }).strict()),
154
+ contentTreeActions: z.array(z.object({ ...gated, label: z.string() }).strict()),
155
+ hooks: z.array(z.string()),
156
+ scheduledTasks: z.array(z.object({ id: z.string(), name: z.string(), cron: z.string() }).strict()),
157
+ migrations: z.array(z.object({ id: z.string(), name: z.string() }).strict()),
158
+ assertions: z.array(z.object({ key: z.string(), reason: z.string() }).strict()),
159
+ installOptions: z.array(ReferenceInstallOptionSchema).default([]),
118
160
  })
119
161
  .strict();
120
- export const REFERENCE_PAGE_SLUGS = ["permissions", "api-routes", "capabilities", "content", "settings"];
121
- /** The generated pages this plugin gets, in their fixed order (spec section 7). */
162
+ export function emptyPluginReference() {
163
+ return {
164
+ actions: [], roles: [], apiRoutes: [], capabilities: [], documentTypes: [], dataTypes: [], templates: [],
165
+ settingsPages: [], adminSections: [], railEntries: [], dashboardWidgets: [], editorToolbar: [],
166
+ contentTreeActions: [], hooks: [], scheduledTasks: [], migrations: [], assertions: [], installOptions: [],
167
+ };
168
+ }
169
+ export const REFERENCE_PAGE_SLUGS = ["permissions", "api-routes", "capabilities", "content", "settings", "admin-surfaces", "lifecycle"];
170
+ /** Which lists each page's tables are drawn from. Every list belongs to
171
+ * exactly one page (pinned by plugin-docs.test.ts), so a list added to the
172
+ * schema without a page is a red test, not a fact nobody sees. */
173
+ export const REFERENCE_PAGE_TABLES = {
174
+ permissions: ["actions", "roles"],
175
+ "api-routes": ["apiRoutes"],
176
+ capabilities: ["capabilities"],
177
+ content: ["documentTypes", "dataTypes", "templates"],
178
+ settings: ["settingsPages"],
179
+ "admin-surfaces": ["adminSections", "railEntries", "dashboardWidgets", "editorToolbar", "contentTreeActions"],
180
+ lifecycle: ["installOptions", "hooks", "scheduledTasks", "migrations", "assertions"],
181
+ };
182
+ export function isReferencePageSlug(slug) {
183
+ return REFERENCE_PAGE_SLUGS.includes(slug);
184
+ }
185
+ /** The one rule (S289): a reference page exists when at least one of its
186
+ * tables has a row. The renderer, the admin, the server, the door, the
187
+ * marketplace and its sitemap all ask this function. */
188
+ export function referencePageHasContent(reference, slug) {
189
+ if (!isReferencePageSlug(slug))
190
+ return false;
191
+ return REFERENCE_PAGE_TABLES[slug].some((list) => reference[list].length > 0);
192
+ }
193
+ /** The generated pages this plugin gets, in their fixed order. */
122
194
  export function referencePageSlugs(reference) {
123
- const slugs = [];
124
- if (reference.actions.length > 0 || reference.roles.length > 0)
125
- slugs.push("permissions");
126
- if (reference.apiRoutes.length > 0)
127
- slugs.push("api-routes");
128
- slugs.push("capabilities");
129
- if (reference.documentTypes.length > 0 || reference.dataTypes.length > 0)
130
- slugs.push("content");
131
- if (reference.settingsPages.length > 0)
132
- slugs.push("settings");
133
- return slugs;
195
+ return REFERENCE_PAGE_SLUGS.filter((slug) => referencePageHasContent(reference, slug));
134
196
  }
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ /** What the install itself created; a role whose id was already taken is never here. */
3
+ export declare const PluginInstallCreatedSchema: z.ZodObject<{
4
+ sampleContentNodeIds: z.ZodArray<z.ZodString>;
5
+ mediaIds: z.ZodArray<z.ZodString>;
6
+ roleIds: z.ZodArray<z.ZodString>;
7
+ }, z.core.$strict>;
8
+ export declare const PluginInstallRecordSchema: z.ZodObject<{
9
+ answers: z.ZodObject<{
10
+ sampleContent: z.ZodBoolean;
11
+ roles: z.ZodArray<z.ZodString>;
12
+ options: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodArray<z.ZodString>]>>;
13
+ }, z.core.$strict>;
14
+ created: z.ZodObject<{
15
+ sampleContentNodeIds: z.ZodArray<z.ZodString>;
16
+ mediaIds: z.ZodArray<z.ZodString>;
17
+ roleIds: z.ZodArray<z.ZodString>;
18
+ }, z.core.$strict>;
19
+ }, z.core.$strict>;
20
+ export type PluginInstallRecord = z.infer<typeof PluginInstallRecordSchema>;
21
+ /** A fresh `created`, never a shared one. */
22
+ export declare function emptyInstallCreated(): PluginInstallRecord["created"];
23
+ /** The stored column through the schema: null for a plugin installed before
24
+ * S293 (the column is null) or a value that does not parse. */
25
+ export declare function readInstallRecord(value: unknown): PluginInstallRecord | null;
26
+ /** What the install did with each offered role its answers named. */
27
+ export declare const INSTALL_ROLE_OUTCOMES: readonly ["created", "already-exists", "failed"];
28
+ export declare const InstallRoleOutcomeSchema: z.ZodObject<{
29
+ id: z.ZodString;
30
+ outcome: z.ZodEnum<{
31
+ created: "created";
32
+ "already-exists": "already-exists";
33
+ failed: "failed";
34
+ }>;
35
+ }, z.core.$strip>;
36
+ export type InstallRoleOutcome = z.infer<typeof InstallRoleOutcomeSchema>;
37
+ /** The 400 every install door answers for answers it refuses, every issue at
38
+ * once: `message` is "The answers were refused: " and the reasons joined with
39
+ * "; ", each reason "path: message". */
40
+ export declare const InstallAnswersRefusedSchema: z.ZodObject<{
41
+ message: z.ZodString;
42
+ reason: z.ZodLiteral<"answers-refused">;
43
+ reasons: z.ZodArray<z.ZodString>;
44
+ }, z.core.$strip>;
45
+ export type InstallAnswersRefused = z.infer<typeof InstallAnswersRefusedSchema>;
46
+ /** The most page titles a record summary names. */
47
+ export declare const INSTALL_RECORD_SUMMARY_TITLES = 20;
48
+ /** What the admin is told about a plugin's record (the uninstall dialog, an update). */
49
+ export declare const PluginInstallRecordSummarySchema: z.ZodObject<{
50
+ answers: z.ZodNullable<z.ZodObject<{
51
+ sampleContent: z.ZodBoolean;
52
+ roles: z.ZodArray<z.ZodString>;
53
+ options: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodString, z.ZodArray<z.ZodString>]>>;
54
+ }, z.core.$strict>>;
55
+ pages: z.ZodObject<{
56
+ liveCount: z.ZodNumber;
57
+ titles: z.ZodArray<z.ZodObject<{
58
+ id: z.ZodString;
59
+ title: z.ZodString;
60
+ }, z.core.$strip>>;
61
+ }, z.core.$strip>;
62
+ mediaCount: z.ZodNumber;
63
+ roles: z.ZodArray<z.ZodObject<{
64
+ id: z.ZodString;
65
+ label: z.ZodString;
66
+ userCount: z.ZodNumber;
67
+ }, z.core.$strip>>;
68
+ }, z.core.$strip>;
69
+ export type PluginInstallRecordSummary = z.infer<typeof PluginInstallRecordSummarySchema>;
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { ResolvedInstallAnswersSchema } from "./plugin-install.js";
3
+ import { RoleIdSchema } from "./role.schema.js";
4
+ // S293 (2026-10-13-s293-the-wizard-installed-design.md 3.1): what a plugin's
5
+ // install is remembered by, on its registry row (PluginRegistry.installRecord):
6
+ // the answers it was installed with, every default filled, and what the install
7
+ // itself created, so an update can carry the answers over and an uninstall can
8
+ // offer to remove exactly that. Written by the server only.
9
+ /** What the install itself created; a role whose id was already taken is never here. */
10
+ export const PluginInstallCreatedSchema = z
11
+ .object({
12
+ /** The sample's pages, in the order the seeder created them (parents first). */
13
+ sampleContentNodeIds: z.array(z.string().min(1)),
14
+ /** The media items the sample's `media` section uploaded. */
15
+ mediaIds: z.array(z.string().min(1)),
16
+ /** The offered roles this install created. */
17
+ roleIds: z.array(RoleIdSchema),
18
+ })
19
+ .strict();
20
+ export const PluginInstallRecordSchema = z
21
+ .object({ answers: ResolvedInstallAnswersSchema, created: PluginInstallCreatedSchema })
22
+ .strict();
23
+ /** A fresh `created`, never a shared one. */
24
+ export function emptyInstallCreated() {
25
+ return { sampleContentNodeIds: [], mediaIds: [], roleIds: [] };
26
+ }
27
+ /** The stored column through the schema: null for a plugin installed before
28
+ * S293 (the column is null) or a value that does not parse. */
29
+ export function readInstallRecord(value) {
30
+ const parsed = PluginInstallRecordSchema.safeParse(value);
31
+ return parsed.success ? parsed.data : null;
32
+ }
33
+ /** What the install did with each offered role its answers named. */
34
+ export const INSTALL_ROLE_OUTCOMES = ["created", "already-exists", "failed"];
35
+ export const InstallRoleOutcomeSchema = z.object({ id: RoleIdSchema, outcome: z.enum(INSTALL_ROLE_OUTCOMES) });
36
+ /** The 400 every install door answers for answers it refuses, every issue at
37
+ * once: `message` is "The answers were refused: " and the reasons joined with
38
+ * "; ", each reason "path: message". */
39
+ export const InstallAnswersRefusedSchema = z.object({
40
+ message: z.string(),
41
+ reason: z.literal("answers-refused"),
42
+ reasons: z.array(z.string()),
43
+ });
44
+ /** The most page titles a record summary names. */
45
+ export const INSTALL_RECORD_SUMMARY_TITLES = 20;
46
+ /** What the admin is told about a plugin's record (the uninstall dialog, an update). */
47
+ export const PluginInstallRecordSummarySchema = z.object({
48
+ /** Null for a plugin installed before S293. */
49
+ answers: ResolvedInstallAnswersSchema.nullable(),
50
+ pages: z.object({
51
+ /** Recorded pages not in the Recycle Bin. */
52
+ liveCount: z.number().int().nonnegative(),
53
+ titles: z.array(z.object({ id: z.string(), title: z.string() })).max(INSTALL_RECORD_SUMMARY_TITLES),
54
+ }),
55
+ /** Recorded media not in the media Recycle Bin; an uninstall keeps them. */
56
+ mediaCount: z.number().int().nonnegative(),
57
+ /** The recorded roles that still exist. */
58
+ roles: z.array(z.object({ id: RoleIdSchema, label: z.string(), userCount: z.number().int().nonnegative() })),
59
+ });