@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.
- package/CHANGELOG.md +49 -1
- package/README.md +10 -0
- package/dist/admin-section-registry.d.ts +14 -5
- package/dist/admin-section-registry.js +14 -4
- package/dist/built-in-value-schemas.js +1 -1
- package/dist/built-ins.js +2 -2
- package/dist/capabilities.d.ts +8 -78
- package/dist/capabilities.js +23 -322
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +13 -12
- package/dist/license-verdict-keys.d.ts +4 -3
- package/dist/license-verdict-keys.js +6 -5
- package/dist/manifest-entry.d.ts +3 -3
- package/dist/manifest-entry.js +2 -2
- package/dist/manifest-schema.d.ts +113 -56
- package/dist/manifest-schema.js +192 -295
- package/dist/manifest.d.ts +145 -112
- package/dist/manifest.js +13 -36
- package/dist/media/media-picker.js +21 -12
- package/dist/media/upload-error.d.ts +1 -1
- package/dist/media/upload-error.js +1 -1
- package/dist/plugin-context.d.ts +7 -0
- package/dist/plugin-context.js +7 -0
- package/dist/plugin-screen-context.d.ts +44 -3
- package/dist/plugin-screen-context.js +27 -2
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/richtext/block-panel.js +6 -6
- package/dist/richtext/insert-menu.js +4 -4
- package/dist/richtext/style-listbox.js +4 -4
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/type-equality.d.ts +2 -0
- package/dist/type-equality.js +1 -0
- package/dist/views/content-list-view.js +2 -2
- package/dist/views/html-view.js +1 -1
- package/dist/views/image-view.js +24 -39
- package/dist/views/rich-text-view.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +43 -25
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +60 -8
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +33 -2
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +22 -1
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +50 -15
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +18 -13
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +11 -7
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +143 -57
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +110 -60
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +67 -40
- package/node_modules/@kardalum/api-schemas/dist/index.js +35 -19
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +356 -16
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +93 -10
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +38 -30
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +69 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +76 -9
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +84 -24
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +597 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +503 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +33 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +28 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +11 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +17 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +58 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +198 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +132 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +23 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +4 -4
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +97 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +36 -6
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -5
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +52 -33
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +195 -56
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +19 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +105 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +47 -7
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +30 -2
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +19 -5
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +15 -3
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -2
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +3 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/README.md +4 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +96 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +66 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +346 -0
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +60 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +133 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +158 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +11 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -2
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +7 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +38 -1
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +84 -16
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +4 -6
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -1
- package/node_modules/@kardalum/plugin-package/package.json +9 -2
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/property-field.js +4 -1
- package/node_modules/@kardalum/ui/package.json +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { lstatSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { FILE_NAME_MAX, effectiveDocsPages } from "@kardalum/api-schemas";
|
|
4
|
+
import { declaresClientBundle } from "../client-bundle.js";
|
|
5
|
+
import { docsFilesToShip } from "../docs-contract.js";
|
|
6
|
+
import { ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES, createPathKeyGate, entryViolation, } from "../extract.js";
|
|
7
|
+
import { COVER_PATH } from "../package-contract.js";
|
|
8
|
+
import { walkShipped } from "../shipped-files.js";
|
|
9
|
+
import { formatBinarySize } from "./limits.js";
|
|
10
|
+
import { failed, passed, plural, warning } from "./support.js";
|
|
11
|
+
// S311 fix wave (W2): the marketplace and every install read a package through
|
|
12
|
+
// one entry gate (createEntryGate in extract.ts), which refuses a name that
|
|
13
|
+
// reads differently on a Linux, Windows or macOS host. `validate` used to apply
|
|
14
|
+
// none of it, so a plugin whose public/ held "café.css" passed validate, build
|
|
15
|
+
// and pack and was then refused at the door. This check applies the same rules
|
|
16
|
+
// (entryViolation and the path rule of createPathKeyGate) to every name the
|
|
17
|
+
// build carries from the plugin's own folders; `kardalum plugin pack` applies
|
|
18
|
+
// the whole gate again to the archive it is about to write, the client bundle
|
|
19
|
+
// included.
|
|
20
|
+
/** The folders the build copies whole, through walkShipped. */
|
|
21
|
+
const COPIED_FOLDERS = ["templates", "public", "media"];
|
|
22
|
+
function regularFileSize(path) {
|
|
23
|
+
try {
|
|
24
|
+
const stats = lstatSync(path);
|
|
25
|
+
return stats.isFile() ? stats.size : null;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function isFolder(path) {
|
|
32
|
+
try {
|
|
33
|
+
return lstatSync(path).isDirectory();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isLink(path) {
|
|
40
|
+
try {
|
|
41
|
+
return lstatSync(path).isSymbolicLink();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Every entry the build carries from the plugin's own folders, as the archive
|
|
48
|
+
* will name it: README.md, the cover, sample-content.json, the docs pages and
|
|
49
|
+
* the images they show, the files directly inside locales/, and templates/,
|
|
50
|
+
* public/ and media/ through walkShipped (a folder appears only when nothing
|
|
51
|
+
* inside it ships, as the archive holds it). Each path once. The build's own
|
|
52
|
+
* output (manifest.json, server/, the client bundle) has fixed names or is
|
|
53
|
+
* `pack`'s to judge. */
|
|
54
|
+
export function shippedEntries(dir, manifest) {
|
|
55
|
+
const entries = new Map();
|
|
56
|
+
const addFile = (name, size) => {
|
|
57
|
+
if (size !== null && !entries.has(name))
|
|
58
|
+
entries.set(name, { name, isDirectory: false, size });
|
|
59
|
+
};
|
|
60
|
+
for (const name of ["README.md", COVER_PATH, "sample-content.json"])
|
|
61
|
+
addFile(name, regularFileSize(join(dir, ...name.split("/"))));
|
|
62
|
+
const pages = effectiveDocsPages(manifest.docs, String(manifest.name ?? ""));
|
|
63
|
+
for (const name of docsFilesToShip(dir, pages))
|
|
64
|
+
addFile(name, regularFileSize(join(dir, ...name.split("/"))));
|
|
65
|
+
const locales = join(dir, "locales");
|
|
66
|
+
if (isFolder(locales)) {
|
|
67
|
+
for (const entry of readdirSync(locales, { withFileTypes: true })) {
|
|
68
|
+
if (entry.isFile())
|
|
69
|
+
addFile(`locales/${entry.name}`, regularFileSize(join(locales, entry.name)));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const folder of COPIED_FOLDERS) {
|
|
73
|
+
const root = join(dir, folder);
|
|
74
|
+
const walked = walkShipped(root);
|
|
75
|
+
if (walked.length === 0) {
|
|
76
|
+
if (isFolder(root))
|
|
77
|
+
entries.set(`${folder}/`, { name: folder, isDirectory: true, size: 0 });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
for (const entry of walked) {
|
|
81
|
+
const name = `${folder}/${entry.path}`;
|
|
82
|
+
if (entry.isDirectory) {
|
|
83
|
+
if (entry.empty)
|
|
84
|
+
entries.set(`${name}/`, { name, isDirectory: true, size: 0 });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
addFile(name, regularFileSize(join(root, ...entry.path.split("/"))));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return [...entries.values()];
|
|
92
|
+
}
|
|
93
|
+
/** The client bundle as the archive will name it: `remoteEntry.js` and every
|
|
94
|
+
* regular file under `assets/`, at any depth, links never followed (S311
|
|
95
|
+
* third code fix). `root` is the folder the bundle was built into: the
|
|
96
|
+
* federation build `validate` makes for `bundle size`, or the package itself
|
|
97
|
+
* at the marketplace. */
|
|
98
|
+
export function bundleEntries(root) {
|
|
99
|
+
const entries = [];
|
|
100
|
+
const entry = regularFileSize(join(root, "remoteEntry.js"));
|
|
101
|
+
if (entry !== null)
|
|
102
|
+
entries.push({ name: "remoteEntry.js", isDirectory: false, size: entry });
|
|
103
|
+
if (!isFolder(join(root, "assets")))
|
|
104
|
+
return entries;
|
|
105
|
+
// A queue read by index, as walkShipped reads one.
|
|
106
|
+
const pending = ["assets"];
|
|
107
|
+
for (let next = 0; next < pending.length; next++) {
|
|
108
|
+
const folder = pending[next];
|
|
109
|
+
for (const child of readdirSync(join(root, ...folder.split("/")), { withFileTypes: true })) {
|
|
110
|
+
const name = `${folder}/${child.name}`;
|
|
111
|
+
if (child.isDirectory())
|
|
112
|
+
pending.push(name);
|
|
113
|
+
else if (child.isFile())
|
|
114
|
+
entries.push({ name, isDirectory: false, size: regularFileSize(join(root, ...name.split("/"))) ?? 0 });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return entries;
|
|
118
|
+
}
|
|
119
|
+
/** Every reason the entry gate would refuse one of `entries`: entryViolation's
|
|
120
|
+
* name and size rules, then createPathKeyGate's (each path once, one kind),
|
|
121
|
+
* each in the gate's own words, and then the archive's own ceilings, which
|
|
122
|
+
* what the build carries from the plugin's folders already breaks when it
|
|
123
|
+
* holds more than MAX_ENTRIES entries or MAX_TOTAL_BYTES once expanded (S311
|
|
124
|
+
* second code fix: the build's own files only add to both). */
|
|
125
|
+
export function archiveNameProblems(entries) {
|
|
126
|
+
const { names, entriesOver, bytesOver } = findNameProblems(entries);
|
|
127
|
+
return [...names, ...(entriesOver ? [entriesOver] : []), ...(bytesOver ? [bytesOver] : [])];
|
|
128
|
+
}
|
|
129
|
+
function findNameProblems(entries) {
|
|
130
|
+
const admitPath = createPathKeyGate();
|
|
131
|
+
const problems = [];
|
|
132
|
+
let totalBytes = 0;
|
|
133
|
+
for (const entry of entries) {
|
|
134
|
+
totalBytes += entry.size;
|
|
135
|
+
const name = entry.isDirectory ? `${entry.name}/` : entry.name;
|
|
136
|
+
const violation = entryViolation(name, entry.isDirectory ? "Directory" : "File", entry.size);
|
|
137
|
+
if (violation) {
|
|
138
|
+
problems.push(violation);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const refusal = admitPath(name, entry.isDirectory);
|
|
142
|
+
if (refusal)
|
|
143
|
+
problems.push(refusal);
|
|
144
|
+
}
|
|
145
|
+
const entriesOver = entries.length > MAX_ENTRIES ? `the plugin's folders hold ${entries.length} entries, more than the ${MAX_ENTRIES} an archive may hold` : null;
|
|
146
|
+
const bytesOver = totalBytes > MAX_TOTAL_BYTES
|
|
147
|
+
? `the plugin's folders hold ${(totalBytes / 1024 / 1024).toFixed(1)} MiB once expanded, more than the ${formatBinarySize(MAX_TOTAL_BYTES)} an archive may expand to`
|
|
148
|
+
: null;
|
|
149
|
+
return { names: problems, entriesOver, bytesOver };
|
|
150
|
+
}
|
|
151
|
+
/** The check's headline: what kind of problem it found, the names it refuses,
|
|
152
|
+
* the entries or the bytes past the archive's ceilings, or several. */
|
|
153
|
+
function headline({ names, entriesOver, bytesOver }) {
|
|
154
|
+
const parts = [];
|
|
155
|
+
if (names.length > 0)
|
|
156
|
+
parts.push(`${plural(names.length, "name")} in the package the marketplace and every install refuse`);
|
|
157
|
+
if (entriesOver)
|
|
158
|
+
parts.push("more entries than an archive may hold");
|
|
159
|
+
if (bytesOver)
|
|
160
|
+
parts.push("more bytes than an archive may expand to");
|
|
161
|
+
return parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")}, and ${parts[parts.length - 1]}`;
|
|
162
|
+
}
|
|
163
|
+
export const archiveNamesCheck = {
|
|
164
|
+
name: "archive names",
|
|
165
|
+
// No vertical bar in the text: the rule is a cell of the page's table, so the
|
|
166
|
+
// character is named in words.
|
|
167
|
+
rule: "Every name the build carries from the plugin's folders, and every name in the client bundle it builds, " +
|
|
168
|
+
"reads the same way on Linux, Windows and macOS, as the marketplace and every install require: " +
|
|
169
|
+
`at most ${ENTRY_NAME_MAX} characters in at most ${ENTRY_SEGMENTS_MAX} segments, each segment at most ${FILE_NAME_MAX}; printable ASCII only, with no backslash, colon, ` +
|
|
170
|
+
"`<`, `>`, `\"`, `?`, `*` or vertical bar; no leading `/`; no `..` segment and no segment ending in a dot or a space; " +
|
|
171
|
+
"no `~` followed by a digit (the shape of a Windows short name) and no Windows device name such as `CON` or `NUL`; " +
|
|
172
|
+
"each path once with case ignored, never a file where another entry needs a folder; " +
|
|
173
|
+
`each file within ${formatBinarySize(MAX_ENTRY_BYTES)}, and at most ${MAX_ENTRIES} entries and ${formatBinarySize(MAX_TOTAL_BYTES)} in all. ` +
|
|
174
|
+
"A link in place of `templates/`, `public/` or `media/` warns, since nothing in it ships.",
|
|
175
|
+
gates: ["cli", "door"],
|
|
176
|
+
needsManifest: false,
|
|
177
|
+
run: ({ dir, manifest, bundle }) => {
|
|
178
|
+
// S311 third code fix: the client bundle too, from the build `bundle size`
|
|
179
|
+
// measures (validate's federation build, or the package at the
|
|
180
|
+
// marketplace), so a chunk name pack would refuse fails here first, in the
|
|
181
|
+
// gate's own words.
|
|
182
|
+
const bundled = declaresClientBundle(manifest.contributions) ? bundleEntries(bundle?.dir ?? dir) : [];
|
|
183
|
+
const entries = [...shippedEntries(dir, manifest), ...bundled];
|
|
184
|
+
const findings = findNameProblems(entries);
|
|
185
|
+
const problems = [...findings.names, ...(findings.entriesOver ? [findings.entriesOver] : []), ...(findings.bytesOver ? [findings.bytesOver] : [])];
|
|
186
|
+
// S311 second code fix: a link where the build copies a folder ships
|
|
187
|
+
// nothing (the walker never follows one), which is quietly not what the
|
|
188
|
+
// author meant, so it is said.
|
|
189
|
+
const linked = COPIED_FOLDERS.filter((folder) => isLink(join(dir, folder))).map((folder) => `${folder}/`);
|
|
190
|
+
const linkNote = linked.length === 0
|
|
191
|
+
? null
|
|
192
|
+
: `${listOf(linked)} ${linked.length === 1 ? "is a link" : "are links"}, and the build copies files and folders, never links: nothing in ${linked.length === 1 ? "it" : "them"} ships`;
|
|
193
|
+
if (problems.length > 0)
|
|
194
|
+
return failed(headline(findings), linkNote ? [...problems, linkNote] : problems);
|
|
195
|
+
if (linkNote)
|
|
196
|
+
return warning(linkNote);
|
|
197
|
+
return passed(`${plural(entries.length, "name")}, each read the same way on every host`);
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
/** "a", "a and b", "a, b and c". */
|
|
201
|
+
function listOf(items) {
|
|
202
|
+
return items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
203
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { lstatSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { gzipSync } from "node:zlib";
|
|
4
|
+
import { declaresClientBundle } from "../client-bundle.js";
|
|
5
|
+
import { BUNDLE_MAX_GZIP_BYTES, BUNDLE_WARN_SHARE, formatBinarySize } from "./limits.js";
|
|
6
|
+
import { failed, passed, warning } from "./support.js";
|
|
7
|
+
const kb = (bytes) => `${Math.ceil(bytes / 1024)} KB`;
|
|
8
|
+
/** Every regular file under `dir`, at any depth, never following a link. */
|
|
9
|
+
function filesUnder(dir) {
|
|
10
|
+
const files = [];
|
|
11
|
+
const pending = [dir];
|
|
12
|
+
while (pending.length > 0) {
|
|
13
|
+
const current = pending.pop();
|
|
14
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
15
|
+
const path = join(current, entry.name);
|
|
16
|
+
if (entry.isDirectory())
|
|
17
|
+
pending.push(path);
|
|
18
|
+
else if (entry.isFile())
|
|
19
|
+
files.push(path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return files;
|
|
23
|
+
}
|
|
24
|
+
/** S311 fix wave: what the admin downloads for a plugin's screens, gzipped:
|
|
25
|
+
* remoteEntry.js and every file under assets/, at any depth, against
|
|
26
|
+
* BUNDLE_MAX_GZIP_BYTES. The door measures the delivered package; the CLI
|
|
27
|
+
* measures the federation build it packs, which it hands over as `bundle`,
|
|
28
|
+
* with the build's error when the build failed. */
|
|
29
|
+
function checkBundleSize(root) {
|
|
30
|
+
const entryPath = join(root, "remoteEntry.js");
|
|
31
|
+
let entryIsFile;
|
|
32
|
+
try {
|
|
33
|
+
entryIsFile = lstatSync(entryPath).isFile();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return failed("no remoteEntry.js to measure: a plugin that declares a view-bearing contribution ships one");
|
|
37
|
+
}
|
|
38
|
+
if (!entryIsFile)
|
|
39
|
+
return failed("remoteEntry.js is not a regular file");
|
|
40
|
+
let assets = [];
|
|
41
|
+
const assetsDir = join(root, "assets");
|
|
42
|
+
try {
|
|
43
|
+
if (lstatSync(assetsDir).isDirectory())
|
|
44
|
+
assets = filesUnder(assetsDir);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// No assets/ folder: remoteEntry.js is the whole bundle.
|
|
48
|
+
}
|
|
49
|
+
let total = 0;
|
|
50
|
+
for (const path of [entryPath, ...assets])
|
|
51
|
+
total += gzipSync(readFileSync(path)).length;
|
|
52
|
+
const counted = assets.length > 0 ? "remoteEntry.js and assets/" : "remoteEntry.js";
|
|
53
|
+
if (total > BUNDLE_MAX_GZIP_BYTES)
|
|
54
|
+
return failed(`${kb(total)} gzipped (${counted}) exceeds the ${kb(BUNDLE_MAX_GZIP_BYTES)} limit`);
|
|
55
|
+
if (total >= BUNDLE_MAX_GZIP_BYTES * BUNDLE_WARN_SHARE) {
|
|
56
|
+
return warning(`${kb(total)} gzipped (${counted}), within ${Math.round((1 - BUNDLE_WARN_SHARE) * 100)}% of the ${kb(BUNDLE_MAX_GZIP_BYTES)} limit`);
|
|
57
|
+
}
|
|
58
|
+
return passed(`${kb(total)} gzipped (limit ${kb(BUNDLE_MAX_GZIP_BYTES)})`);
|
|
59
|
+
}
|
|
60
|
+
export const NOT_VIEW_BEARING = "not applicable: this plugin declares nothing view-bearing, so it ships no client bundle";
|
|
61
|
+
export const bundleSizeCheck = {
|
|
62
|
+
name: "bundle size",
|
|
63
|
+
rule: `The gzipped \`remoteEntry.js\` and every file under \`assets/\` together are within ${formatBinarySize(BUNDLE_MAX_GZIP_BYTES)}, with a warning from ${Math.round(BUNDLE_WARN_SHARE * 100)}%; not applicable when nothing view-bearing is declared.`,
|
|
64
|
+
gates: ["cli", "door"],
|
|
65
|
+
needsManifest: true,
|
|
66
|
+
run: ({ dir, manifest, bundle }) => {
|
|
67
|
+
if (!declaresClientBundle(manifest.contributions))
|
|
68
|
+
return { status: "skipped", message: NOT_VIEW_BEARING };
|
|
69
|
+
if (bundle?.buildError !== undefined)
|
|
70
|
+
return failed(`federation build failed: ${bundle.buildError}`);
|
|
71
|
+
return checkBundleSize(bundle?.dir ?? dir);
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { API_ROUTE_ACCESS_TIERS, API_ROUTE_METHODS, TIER1_DIALECTS, checkApiRouteTiers, listIssues } from "@kardalum/api-schemas";
|
|
2
|
+
import { contributionsOf, failed, list, passed, record } from "./support.js";
|
|
3
|
+
export { iconNamesCheck } from "./icons.js";
|
|
4
|
+
function hasContent(value) {
|
|
5
|
+
if (value === null || value === undefined)
|
|
6
|
+
return false;
|
|
7
|
+
if (Array.isArray(value))
|
|
8
|
+
return value.length > 0;
|
|
9
|
+
if (typeof value === "object")
|
|
10
|
+
return Object.keys(value).length > 0;
|
|
11
|
+
return Boolean(value);
|
|
12
|
+
}
|
|
13
|
+
// S268: a schema-valid manifest can still declare an empty contributions
|
|
14
|
+
// object (every key is optional), which is a plugin a host can install and
|
|
15
|
+
// that then does nothing. What a plugin may contribute is the schema's
|
|
16
|
+
// business; the listing label (`type`) is never read here.
|
|
17
|
+
export const requiredViewsCheck = {
|
|
18
|
+
name: "required views/contributions present",
|
|
19
|
+
rule: "`contributions` declares at least one key with content, so there is something for a host to install.",
|
|
20
|
+
gates: ["cli", "door"],
|
|
21
|
+
needsManifest: true,
|
|
22
|
+
run: ({ manifest }) => {
|
|
23
|
+
const contributions = contributionsOf(manifest);
|
|
24
|
+
// Sorted so the message is stable whatever order the author wrote.
|
|
25
|
+
const present = Object.keys(contributions).filter((key) => hasContent(contributions[key])).sort();
|
|
26
|
+
if (present.length === 0) {
|
|
27
|
+
return failed("plugin declares no contributions: every key of `contributions` is absent or empty, so there is nothing for a host to install");
|
|
28
|
+
}
|
|
29
|
+
return passed(`contributes: ${present.join(", ")}`);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export const apiRoutesCheck = {
|
|
33
|
+
name: "api route methods and access",
|
|
34
|
+
rule: `Every apiRoute declares a method (${API_ROUTE_METHODS.join(", ")}) and, if it names an \`access\` tier, one of (${API_ROUTE_ACCESS_TIERS.join(", ")}).`,
|
|
35
|
+
gates: ["cli", "door"],
|
|
36
|
+
needsManifest: true,
|
|
37
|
+
run: ({ manifest }) => {
|
|
38
|
+
const issues = checkApiRouteTiers(manifest);
|
|
39
|
+
if (issues.length > 0)
|
|
40
|
+
return failed(`manifest.json declares its apiRoutes wrongly: ${listIssues(issues)}`);
|
|
41
|
+
const count = list(contributionsOf(manifest).apiRoutes).length;
|
|
42
|
+
return passed(count === 0 ? "no apiRoutes declared" : `${count} apiRoute${count === 1 ? "" : "s"} with a known method and tier`);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
export const databaseCheck = {
|
|
46
|
+
name: "database compatibility declared",
|
|
47
|
+
rule: `\`databaseCompatibility.supported\` is not empty and names only the dialects a listed plugin may claim (${TIER1_DIALECTS.join(", ")}).`,
|
|
48
|
+
gates: ["cli", "door"],
|
|
49
|
+
needsManifest: true,
|
|
50
|
+
run: ({ manifest }) => {
|
|
51
|
+
const supported = list(record(manifest.databaseCompatibility)?.supported);
|
|
52
|
+
if (supported.length === 0)
|
|
53
|
+
return failed("databaseCompatibility.supported is empty");
|
|
54
|
+
const outside = supported.filter((dialect) => !TIER1_DIALECTS.includes(dialect));
|
|
55
|
+
if (outside.length > 0) {
|
|
56
|
+
return failed(`databaseCompatibility.supported names ${outside.map(String).join(", ")}, which a listed plugin cannot claim: the dialects are ${TIER1_DIALECTS.join(", ")}`);
|
|
57
|
+
}
|
|
58
|
+
return passed(`declared: ${supported.map(String).join(", ")}`);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ICON_NAMES: readonly string[];
|