@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
@@ -1 +1,20 @@
1
- export declare const SAMPLE_CONTENT_MEDIA_FILE_PATTERN: RegExp;
1
+ import { type SampleContentFile, type ShippedInstallFacts } from "@kardalum/api-schemas";
2
+ /** The largest sample-content.json read to decide whether the sample ships,
3
+ * so the door's parse stays inside its validation budget. */
4
+ export declare const SAMPLE_CONTENT_MAX_BYTES: number;
5
+ /** S293: the package's sample-content.json as an install reads it. */
6
+ export type ShippedSampleContent = {
7
+ status: "absent";
8
+ } | {
9
+ status: "unreadable";
10
+ reason: string;
11
+ } | {
12
+ status: "ships";
13
+ file: SampleContentFile;
14
+ };
15
+ /** Absent, unreadable (not a regular file, over SAMPLE_CONTENT_MAX_BYTES, not
16
+ * JSON, or refused by the schema) or the parsed file. Never throws. The
17
+ * server's seeder reads through it, so the cap applies at install too. */
18
+ export declare function readShippedSampleContent(dir: string): ShippedSampleContent;
19
+ /** Never throws: anything unreadable ships nothing. */
20
+ export declare function readShippedInstallFacts(dir: string): ShippedInstallFacts;
@@ -1,17 +1,57 @@
1
- // A template plugin's sample-content.json declares media[].file as
2
- // "media/" plus a flat, traversal-free filename — this is the ONE
3
- // definition both sides that parse that shape validate against, so they
4
- // can never drift apart the way two hand-copied literal-twin regexes did
5
- // (S199 review Minor c). Without this constraint, a `file` of
6
- // "../../.env" would resolve outside the plugin package and get uploaded
7
- // as a PUBLIC media record.
1
+ import { lstatSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { parseSampleContentFile } from "@kardalum/api-schemas";
4
+ // S292 (2026-10-13-s292-what-the-wizard-may-ask-design.md, D8): what a
5
+ // package directory ships that its install's built-in questions are derived
6
+ // from. One definition for `kardalum plugin validate`'s `install options`
7
+ // check, the marketplace door's stored install interface, and (S293) the
8
+ // server's install doors: a sample-content.json at the package root that is
9
+ // a regular file within SAMPLE_CONTENT_MAX_BYTES and parses under
10
+ // SampleContentFileSchema (@kardalum/api-schemas, which also holds the
11
+ // media file pattern this module used to). A file the schema refuses does
12
+ // not ship: the CLI's `sample content valid` check reports it, and the
13
+ // seeder answers "invalid" at install.
8
14
  //
9
- // Consumers:
10
- // - apps/server/src/plugins/seed-template-content.ts
11
- // (SampleContentFileSchema's media[].file Zod regex — the host-side
12
- // seeder that actually uploads the files at install time)
13
- // - packages/cli/src/plugin/checks/templates.ts
14
- // (parseSampleContentFile's own check: the author-side `kardalum plugin
15
- // validate` command that catches this before a plugin is ever
16
- // packaged)
17
- export const SAMPLE_CONTENT_MEDIA_FILE_PATTERN = /^media\/[A-Za-z0-9._-]+$/;
15
+ // S293 (2026-10-13-s293-the-wizard-installed-design.md 3.6, D11): the read
16
+ // itself is readShippedSampleContent, which the server's seeder goes through
17
+ // too, so the seeder parses only what the cap admits and a present but
18
+ // unreadable file is told apart from an absent one.
19
+ /** The largest sample-content.json read to decide whether the sample ships,
20
+ * so the door's parse stays inside its validation budget. */
21
+ export const SAMPLE_CONTENT_MAX_BYTES = 8 * 1024 * 1024;
22
+ /** Absent, unreadable (not a regular file, over SAMPLE_CONTENT_MAX_BYTES, not
23
+ * JSON, or refused by the schema) or the parsed file. Never throws. The
24
+ * server's seeder reads through it, so the cap applies at install too. */
25
+ export function readShippedSampleContent(dir) {
26
+ const path = join(dir, "sample-content.json");
27
+ let size;
28
+ try {
29
+ const stats = lstatSync(path);
30
+ if (!stats.isFile())
31
+ return { status: "unreadable", reason: "sample-content.json is not a regular file" };
32
+ size = stats.size;
33
+ }
34
+ catch (error) {
35
+ return error.code === "ENOENT"
36
+ ? { status: "absent" }
37
+ : { status: "unreadable", reason: "sample-content.json cannot be read" };
38
+ }
39
+ if (size > SAMPLE_CONTENT_MAX_BYTES)
40
+ return { status: "unreadable", reason: `sample-content.json is larger than ${SAMPLE_CONTENT_MAX_BYTES} bytes` };
41
+ let raw;
42
+ try {
43
+ raw = JSON.parse(readFileSync(path, "utf8"));
44
+ }
45
+ catch {
46
+ return { status: "unreadable", reason: "sample-content.json is not valid JSON" };
47
+ }
48
+ const parsed = parseSampleContentFile(raw);
49
+ return parsed.ok ? { status: "ships", file: parsed.file } : { status: "unreadable", reason: `sample-content.json: ${parsed.errors.join("; ")}` };
50
+ }
51
+ /** Never throws: anything unreadable ships nothing. */
52
+ export function readShippedInstallFacts(dir) {
53
+ const sample = readShippedSampleContent(dir);
54
+ if (sample.status !== "ships")
55
+ return { sampleContent: false };
56
+ return sample.file.description ? { sampleContent: true, sampleContentDescription: sample.file.description } : { sampleContent: true };
57
+ }
@@ -26,12 +26,10 @@ export interface TrustedKey {
26
26
  keyId: string;
27
27
  publicKey: string;
28
28
  }
29
- export type VerifyFailureReason = "malformed-sidecar" | "no-trusted-keys" | "unknown-key" | "bad-signature" | "hash-mismatch" | "identity-mismatch"
30
- /** The artifact itself could not be read (missing, unreadable, permission
31
- * denied, or a mid-read failure) — nothing could be verified about it,
32
- * since hashing never completed. Distinct from hash-mismatch, which
33
- * requires a hash to have actually been computed and compared. */
34
- | "artifact-unreadable";
29
+ /** Every reason a verification can fail for, at runtime (S289: the manual's
30
+ * enum test checks the reasons it quotes against this list). */
31
+ export declare const VERIFY_FAILURE_REASONS: readonly ["malformed-sidecar", "no-trusted-keys", "unknown-key", "bad-signature", "hash-mismatch", "identity-mismatch", "artifact-unreadable"];
32
+ export type VerifyFailureReason = (typeof VERIFY_FAILURE_REASONS)[number];
35
33
  export type VerifyResult = {
36
34
  status: "verified";
37
35
  keyId: string;
@@ -1 +1,15 @@
1
- export {};
1
+ /** Every reason a verification can fail for, at runtime (S289: the manual's
2
+ * enum test checks the reasons it quotes against this list). */
3
+ export const VERIFY_FAILURE_REASONS = [
4
+ "malformed-sidecar",
5
+ "no-trusted-keys",
6
+ "unknown-key",
7
+ "bad-signature",
8
+ "hash-mismatch",
9
+ "identity-mismatch",
10
+ /** The artifact itself could not be read (missing, unreadable, permission
11
+ * denied, or a mid-read failure): nothing could be verified about it,
12
+ * since hashing never completed. Distinct from hash-mismatch, which
13
+ * requires a hash to have actually been computed and compared. */
14
+ "artifact-unreadable",
15
+ ];
@@ -15,6 +15,11 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "import": "./dist/index.js",
17
17
  "default": "./dist/index.js"
18
+ },
19
+ "./reference": {
20
+ "types": "./dist/reference-entry.d.ts",
21
+ "import": "./dist/reference-entry.js",
22
+ "default": "./dist/reference-entry.js"
18
23
  }
19
24
  },
20
25
  "files": [
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
3
  import { cn } from '../lib/cn.js';
4
4
  function Checkbox({ className, ...props }) {
5
- return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-border-default bg-background-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 data-[state=checked]:text-text-inverse', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { className: "flex items-center justify-center text-current", children: _jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "h-3.5 w-3.5", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8.5L6.5 11.5L12.5 4.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }) }));
5
+ return (_jsx(CheckboxPrimitive.Root, { "data-slot": "checkbox", className: cn('peer h-4 w-4 shrink-0 rounded-sm border border-neutral-500 bg-background-elevated focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-600 focus-visible:ring-offset-2 focus-visible:ring-offset-background-base disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary-600 data-[state=checked]:bg-primary-600 data-[state=checked]:text-text-inverse data-[state=indeterminate]:border-primary-600 data-[state=indeterminate]:text-primary-600', className), ...props, children: _jsxs(CheckboxPrimitive.Indicator, { className: "group flex items-center justify-center text-current", children: [_jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "h-3 w-3 group-data-[state=indeterminate]:hidden", "aria-hidden": "true", children: _jsx("path", { d: "M3.5 8.5L6.5 11.5L12.5 4.5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }), _jsx("svg", { viewBox: "0 0 16 16", fill: "none", className: "hidden h-3 w-3 group-data-[state=indeterminate]:block", "aria-hidden": "true", children: _jsx("path", { d: "M4 8h8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) })] }) }));
6
6
  }
7
7
  export { Checkbox };
@@ -81,6 +81,9 @@ function PropertyField({ label, htmlFor, required, requiredText, helpText, error
81
81
  // wired. With neither there is no labelable control to name, and a `for`
82
82
  // that resolves to a <div> (or to nothing) is worse than none at all.
83
83
  const labelFor = htmlFor ?? (wiredChild ? controlId : undefined);
84
- return (_jsxs("div", { "data-slot": "property-field", className: cn('flex flex-col gap-1.5', className), ...props, children: [_jsxs("label", { id: labelId, htmlFor: labelFor, className: "text-sm font-medium text-text-primary", children: [label, required && (_jsxs(_Fragment, { children: [_jsxs("span", { "aria-hidden": "true", className: "text-danger-600", children: [' ', "*"] }), requiredText && _jsxs("span", { className: "sr-only", children: [" (", requiredText, ")"] })] }))] }), _jsx(PropertyFieldContext.Provider, { value: controlProps, children: control }), error ? (_jsx("p", { id: errorId, role: "alert", className: "text-xs text-danger-600", children: error })) : (helpText && (_jsx("p", { id: helpId, className: "text-xs text-text-tertiary", children: helpText })))] }));
84
+ // gap-2 (8px) between the label, the control and the help text: a half step
85
+ // such as gap-1.5 emits no rule under the token preset, which replaces
86
+ // Tailwind's spacing scale, so the label sat flush against its field.
87
+ return (_jsxs("div", { "data-slot": "property-field", className: cn('flex flex-col gap-2', className), ...props, children: [_jsxs("label", { id: labelId, htmlFor: labelFor, className: "text-sm font-medium text-text-primary", children: [label, required && (_jsxs(_Fragment, { children: [_jsxs("span", { "aria-hidden": "true", className: "text-danger-600", children: [' ', "*"] }), requiredText && _jsxs("span", { className: "sr-only", children: [" (", requiredText, ")"] })] }))] }), _jsx(PropertyFieldContext.Provider, { value: controlProps, children: control }), error ? (_jsx("p", { id: errorId, role: "alert", className: "text-xs text-danger-600", children: error })) : (helpText && (_jsx("p", { id: helpId, className: "text-xs text-text-tertiary", children: helpText })))] }));
85
88
  }
86
89
  export { PropertyField };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kardalum/plugin-sdk",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "The SDK for building Kardalum plugins: manifest declaration, data type and admin section registries, storage-value providers, and shared UI components.",
6
6
  "engines": {
@@ -115,8 +115,8 @@
115
115
  "yauzl": "3.4.0",
116
116
  "zod": "4.4.3",
117
117
  "@kardalum/api-schemas": "0.14.0",
118
- "@kardalum/plugin-package": "0.14.0",
119
118
  "@kardalum/design-tokens": "0.14.0",
119
+ "@kardalum/plugin-package": "0.14.0",
120
120
  "@kardalum/ui": "0.14.0"
121
121
  },
122
122
  "peerDependencies": {