@kardalum/plugin-sdk 0.16.0 → 0.18.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 +105 -0
- package/README.md +4 -3
- package/dist/admin-section-registry.d.ts +14 -5
- package/dist/admin-section-registry.js +14 -4
- package/dist/assets/asset-picker.d.ts +11 -0
- package/dist/assets/asset-picker.js +109 -0
- package/dist/assets/asset-tree.d.ts +30 -0
- package/dist/assets/asset-tree.js +150 -0
- package/dist/built-in-editor-ids.d.ts +1 -0
- package/dist/built-in-editor-ids.js +20 -0
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +27 -0
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +10 -1
- package/dist/capabilities.js +5 -3
- package/dist/datatype-validation.js +18 -4
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/entitlement-entry.d.ts +3 -2
- package/dist/entitlement-entry.js +13 -1
- package/dist/entitlement-gate.d.ts +18 -0
- package/dist/entitlement-gate.js +95 -21
- package/dist/entitlement-plan.d.ts +21 -0
- package/dist/entitlement-plan.js +26 -0
- package/dist/entitlement-types.d.ts +21 -4
- package/dist/entitlement.d.ts +29 -1
- package/dist/entitlement.js +39 -0
- package/dist/grid-arrow-step.d.ts +7 -0
- package/dist/grid-arrow-step.js +20 -0
- package/dist/host-entry.d.ts +1 -1
- package/dist/host-entry.js +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +13 -18
- package/dist/license-verdict-keys.d.ts +4 -3
- package/dist/license-verdict-keys.js +4 -7
- package/dist/manifest-entry.d.ts +6 -2
- package/dist/manifest-entry.js +5 -1
- package/dist/manifest-schema.d.ts +56 -63
- package/dist/manifest-schema.js +103 -249
- package/dist/manifest.d.ts +61 -73
- package/dist/manifest.js +13 -36
- package/dist/media/media-picker.js +32 -32
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- package/dist/plugin-screen-context.d.ts +11 -1
- package/dist/richtext/block-panel.js +19 -20
- package/dist/richtext/extensions.js +10 -1
- package/dist/richtext/insert-menu.js +1 -1
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +4 -4
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/structured-storage-types.d.ts +11 -0
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +2 -0
- package/dist/tokens/tokens.json +4 -2
- package/dist/type-equality.d.ts +2 -0
- package/dist/type-equality.js +1 -0
- package/dist/vendor-check.d.ts +39 -0
- package/dist/vendor-check.js +79 -0
- package/dist/vendor-entry.d.ts +3 -0
- package/dist/vendor-entry.js +9 -0
- package/dist/vendor-service.d.ts +20 -0
- package/dist/vendor-service.js +20 -0
- package/dist/views/asset-view.d.ts +6 -0
- package/dist/views/asset-view.js +55 -0
- package/dist/views/content-list-settings-view.js +1 -1
- package/dist/views/content-list-view.js +1 -1
- package/dist/views/html-code-editor.js +0 -1
- package/dist/views/html-view.js +1 -1
- package/dist/views/image-view.js +1 -1
- package/dist/views/rich-text-view.js +30 -30
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- 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 +43 -10
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +60 -18
- 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/checkout-shown.schema.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +22 -6
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
- 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.js +2 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +52 -10
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +33 -14
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
- package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +73 -31
- package/node_modules/@kardalum/api-schemas/dist/index.js +47 -17
- 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/kardalum-latest.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +216 -63
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +117 -5
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
- 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 +8 -18
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +3 -19
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -15
- 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 +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +97 -85
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +35 -68
- 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 +9 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +22 -7
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +240 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +164 -32
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +4 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
- 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-read-only.schema.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -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 +83 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +152 -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 +5 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +35 -23
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +11 -2
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +21 -3
- 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 +6 -6
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +58 -25
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +194 -48
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +18 -6
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +2 -2
- 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 +115 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +65 -10
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +37 -2
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +34 -8
- 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 +16 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -2
- package/node_modules/@kardalum/design-tokens/README.md +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
- package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +4 -2
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -0
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- package/node_modules/@kardalum/plugin-package/README.md +5 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +6 -21
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +13 -8
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +59 -16
- 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 +8 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +77 -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 +137 -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 +7 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +215 -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 +13 -4
- package/node_modules/@kardalum/plugin-package/dist/index.js +10 -3
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
- 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 +1 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +21 -3
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +37 -9
- 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/vendor-token.d.ts +24 -0
- package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
- package/node_modules/@kardalum/plugin-package/package.json +4 -2
- package/node_modules/@kardalum/ui/README.md +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
- package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
- package/node_modules/@kardalum/ui/dist/index.js +1 -0
- package/node_modules/@kardalum/ui/package.json +1 -1
- package/package.json +19 -6
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { FILE_NAME_MAX, MAX_DOC_PAGE_BYTES, MAX_ASSET_CONTENT_BYTES, MAX_DOC_PAGES, MAX_TEMPLATE_CONTENT_BYTES, MAX_TEMPLATE_PAYLOAD_ENTRIES, PLUGIN_AUTHOR_MAX, PLUGIN_CMS_VERSION_MAX, PLUGIN_DESCRIPTION_MAX, PLUGIN_ID_MAX, PLUGIN_LICENSE_MAX, PLUGIN_LOCALE_KEY_MAX_LENGTH, PLUGIN_LOCALE_MAX_BYTES, PLUGIN_LOCALE_MAX_KEYS, PLUGIN_LOCALE_VALUE_MAX_LENGTH, PLUGIN_NAME_MAX, PLUGIN_VERSION_MAX, SAMPLE_CONTENT_MAX_MEDIA, SAMPLE_CONTENT_MAX_NODES, } from "@kardalum/api-schemas";
|
|
2
|
+
import { ENTRY_NAME_MAX, ENTRY_SEGMENTS_MAX, MAX_ENTRIES, MAX_ENTRY_BYTES, MAX_TOTAL_BYTES } from "../extract.js";
|
|
3
|
+
import { COVER_HEIGHT, COVER_WIDTH } from "../package-contract.js";
|
|
4
|
+
import { archiveNamesCheck } from "./archive-names.js";
|
|
5
|
+
import { bundleSizeCheck } from "./bundle.js";
|
|
6
|
+
import { apiRoutesCheck, databaseCheck, iconNamesCheck, requiredViewsCheck, vendorServiceCheck } from "./contributions.js";
|
|
7
|
+
import { labelLanguagesCheck } from "./label-languages.js";
|
|
8
|
+
import { BUNDLE_MAX_GZIP_BYTES, MANIFEST_MAX_BYTES, formatBinarySize } from "./limits.js";
|
|
9
|
+
import { localeParityCheck, localesCheck } from "./locales.js";
|
|
10
|
+
import { coverCheck, docsContractCheck, docsLinksCheck, readmeCheck } from "./package-files.js";
|
|
11
|
+
import { installOptionsCheck, sampleContentCheck } from "./sample-content.js";
|
|
12
|
+
import { SAMPLE_CONTENT_MAX_BYTES, readShippedSampleContent } from "../sample-content.js";
|
|
13
|
+
import { describeError } from "./support.js";
|
|
14
|
+
import { assetsCheck, entryBudgetCheck, payloadSizesCheck, templateDeclarationsCheck, templateFilesCheck, templateWiringCheck } from "./templates.js";
|
|
15
|
+
/** Runs the checks of one gate in order. A check that cannot run because the
|
|
16
|
+
* manifest did not parse says so; a check that throws is a failed result, never
|
|
17
|
+
* an exception that escapes the gate (a directory where a file belongs is the
|
|
18
|
+
* author's mistake, not an internal error), and it names the path inside the
|
|
19
|
+
* package. sample-content.json is read once, here, unless the caller already
|
|
20
|
+
* has (readShippedSampleContent never throws). */
|
|
21
|
+
export function runChecks(checks, context, gate) {
|
|
22
|
+
const results = [];
|
|
23
|
+
const run = { ...context, manifest: context.manifest ?? {}, sampleContent: context.sampleContent ?? readShippedSampleContent(context.dir) };
|
|
24
|
+
for (const check of checks) {
|
|
25
|
+
if (!check.gates.includes(gate))
|
|
26
|
+
continue;
|
|
27
|
+
if (check.needsManifest && context.manifest === null) {
|
|
28
|
+
results.push({ name: check.name, status: "failed", message: "cannot check: manifest schema invalid" });
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
results.push({ name: check.name, ...check.run(run) });
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
results.push({ name: check.name, status: "failed", message: `could not run: ${describeError(error, context.dir)}` });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
/** Every check both gates run, in report order. */
|
|
41
|
+
export const DELIVERY_CHECKS = [
|
|
42
|
+
requiredViewsCheck,
|
|
43
|
+
apiRoutesCheck,
|
|
44
|
+
databaseCheck,
|
|
45
|
+
vendorServiceCheck,
|
|
46
|
+
iconNamesCheck,
|
|
47
|
+
readmeCheck,
|
|
48
|
+
coverCheck,
|
|
49
|
+
docsContractCheck,
|
|
50
|
+
docsLinksCheck,
|
|
51
|
+
localesCheck,
|
|
52
|
+
localeParityCheck,
|
|
53
|
+
labelLanguagesCheck,
|
|
54
|
+
installOptionsCheck,
|
|
55
|
+
sampleContentCheck,
|
|
56
|
+
templateDeclarationsCheck,
|
|
57
|
+
templateFilesCheck,
|
|
58
|
+
templateWiringCheck,
|
|
59
|
+
assetsCheck,
|
|
60
|
+
payloadSizesCheck,
|
|
61
|
+
entryBudgetCheck,
|
|
62
|
+
archiveNamesCheck,
|
|
63
|
+
bundleSizeCheck,
|
|
64
|
+
];
|
|
65
|
+
/** What only one gate can measure, as data, so the page and the tests see every
|
|
66
|
+
* check either gate can emit. Each CLI name is the one its check module in the
|
|
67
|
+
* CLI emits: the name-registration tests fail on a typo. The rules are the
|
|
68
|
+
* page's words, so they say "the marketplace" for the check of an upload and
|
|
69
|
+
* write a size in binary units, as formatBinarySize does. */
|
|
70
|
+
export const GATE_ONLY_CHECKS = [
|
|
71
|
+
{ name: "manifest schema valid", gate: "cli", rule: "The SDK's full manifest schema, which holds live function references the marketplace cannot run, with the field limits below and a semver `version`.", skippedAtDoor: false },
|
|
72
|
+
{ name: "typescript compiles", gate: "cli", rule: "The plugin's TypeScript compiles; the marketplace receives a built package and reports it skipped.", skippedAtDoor: true },
|
|
73
|
+
{ name: "npm audit", gate: "cli", rule: "No high or critical advisory in the plugin's production dependencies (its devDependencies are build tooling and are not audited); the marketplace reports it skipped.", skippedAtDoor: true },
|
|
74
|
+
{ name: "templates parse", gate: "cli", rule: "Every template parses as Liquid; the marketplace never parses template code and reports it skipped.", skippedAtDoor: true },
|
|
75
|
+
{ name: "template references resolve", gate: "cli", rule: "Every `render` and `layout` target names a declared alias; the marketplace does not read template text and reports it skipped.", skippedAtDoor: true },
|
|
76
|
+
{ name: "reference", gate: "cli", rule: "The manifest yields a valid `reference.json`, which the build writes and the marketplace reads.", skippedAtDoor: false },
|
|
77
|
+
{ name: "plugin SDK federation share key correct", gate: "cli", rule: "The federation config shares the SDK under its package name, and react, react-dom and the SDK each set `singleton: true` and `import: false`, so the bundle carries no fallback copy of what the host provides. The check reads the literal `shared: { ... }` in `vite.config.ts`, so write every entry out in it: it cannot follow a spread, a variable or a helper.", skippedAtDoor: false },
|
|
78
|
+
{ name: "archive-safety", gate: "door", rule: "The archive extracts safely: no unsafe path, no entry that carries a second name for itself, no path twice in any spelling, within the entry and byte ceilings; a link is extracted as a plain file, never as a link. The upload's reader applies the same rules.", skippedAtDoor: false },
|
|
79
|
+
{ name: "manifest-schema", gate: "door", rule: `\`manifest.json\` is at most ${formatBinarySize(MANIFEST_MAX_BYTES)}, parses, and matches the shape rule built from the shared vocabularies, declaration rules and field limits.`, skippedAtDoor: false },
|
|
80
|
+
{ name: "required-files", gate: "door", rule: "`manifest.json`, `server/plugin.js` and `server/package.json` (declaring the ESM marker) are present, plus `remoteEntry.js` when a view-bearing contribution is declared.", skippedAtDoor: false },
|
|
81
|
+
{ name: "manifest-consistency", gate: "door", rule: "The manifest's id and version match the submission record, and the extracted `manifest.json` is byte for byte the one read at upload.", skippedAtDoor: false },
|
|
82
|
+
{ name: "reserved-names", gate: "door", rule: "Nothing at the package root is named `kardalum-license.json`, in any case: the marketplace writes that file into every licensed download.", skippedAtDoor: false },
|
|
83
|
+
{ name: "bundle-members", gate: "door", rule: "Bundles only: every member id is a published listing, and a paid member belongs to the bundle's author.", skippedAtDoor: false },
|
|
84
|
+
{ name: "internal-validation-error", gate: "door", rule: "Not a rule a package breaks: the marketplace could not read the stored package, or could not finish checking it in time. Submit again under a new version number and every check runs afresh.", skippedAtDoor: false },
|
|
85
|
+
];
|
|
86
|
+
export function runDeliveryChecks(context, gate) {
|
|
87
|
+
return runChecks(DELIVERY_CHECKS, context, gate);
|
|
88
|
+
}
|
|
89
|
+
const RUN_BY = { cli: "`kardalum plugin validate`", door: "the marketplace" };
|
|
90
|
+
/** The page's check table, generated so it cannot drift from the code. */
|
|
91
|
+
export function renderDeliveryTable() {
|
|
92
|
+
const lines = ["| Check | Run by | What it requires |", "|---|---|---|"];
|
|
93
|
+
for (const check of DELIVERY_CHECKS)
|
|
94
|
+
lines.push(`| \`${check.name}\` | both | ${check.rule} |`);
|
|
95
|
+
for (const check of GATE_ONLY_CHECKS)
|
|
96
|
+
lines.push(`| \`${check.name}\` | ${RUN_BY[check.gate]} | ${check.rule} |`);
|
|
97
|
+
return lines.join("\n");
|
|
98
|
+
}
|
|
99
|
+
/** The page's limits table, generated from the constants the gates enforce, so
|
|
100
|
+
* a number the page quotes is the number a check holds a package to. */
|
|
101
|
+
export function renderDeliveryLimits() {
|
|
102
|
+
const rows = [
|
|
103
|
+
["Archive entries", `${MAX_ENTRIES} entries`, "files and folders in the `.zip`"],
|
|
104
|
+
["Archive, expanded", formatBinarySize(MAX_TOTAL_BYTES), "all entries together once extracted"],
|
|
105
|
+
["One entry, expanded", formatBinarySize(MAX_ENTRY_BYTES), "any single file in the archive"],
|
|
106
|
+
["A name in the archive", `${ENTRY_NAME_MAX} characters`, "any path in the `.zip`: the longest Windows writes"],
|
|
107
|
+
["Segments in one name", `${ENTRY_SEGMENTS_MAX} segments`, "folders and a file in one path"],
|
|
108
|
+
["A segment of a name", `${FILE_NAME_MAX} characters`, "one file or folder name in a path"],
|
|
109
|
+
["`manifest.json`", formatBinarySize(MANIFEST_MAX_BYTES), "measured by the marketplace before it parses the file"],
|
|
110
|
+
["Plugin id", `${PLUGIN_ID_MAX} characters`, "`id` in the manifest"],
|
|
111
|
+
["Version", `${PLUGIN_VERSION_MAX} characters`, "`version`, a semver such as `1.0.0` or `1.0.0-beta.1`"],
|
|
112
|
+
["Name", `${PLUGIN_NAME_MAX} characters`, "`name`"],
|
|
113
|
+
["Description", `${PLUGIN_DESCRIPTION_MAX} characters`, "`description`"],
|
|
114
|
+
["Author", `${PLUGIN_AUTHOR_MAX} characters`, "`author`"],
|
|
115
|
+
["License", `${PLUGIN_LICENSE_MAX} characters`, "`license`"],
|
|
116
|
+
["CMS version range", `${PLUGIN_CMS_VERSION_MAX} characters`, "`cmsVersion`"],
|
|
117
|
+
["Client bundle", `${formatBinarySize(BUNDLE_MAX_GZIP_BYTES)} gzipped`, "`remoteEntry.js` and `assets/` together"],
|
|
118
|
+
["Cover image", `${COVER_WIDTH} by ${COVER_HEIGHT} pixels`, "`marketplace/cover.png`, exactly"],
|
|
119
|
+
["Docs pages", `${MAX_DOC_PAGES} pages`, "listed in the manifest's `docs`"],
|
|
120
|
+
["One docs page", formatBinarySize(MAX_DOC_PAGE_BYTES), "each page other than `README.md`"],
|
|
121
|
+
["One template file", formatBinarySize(MAX_TEMPLATE_CONTENT_BYTES), "each declared file under `templates/`: a site's default limit, which the site may raise"],
|
|
122
|
+
["One asset", formatBinarySize(MAX_ASSET_CONTENT_BYTES), "each declared asset under `public/`: a site's default limit, which the site may raise"],
|
|
123
|
+
["One locale file", formatBinarySize(PLUGIN_LOCALE_MAX_BYTES), "each `locales/<language>.json`"],
|
|
124
|
+
["Keys in a locale file", `${PLUGIN_LOCALE_MAX_KEYS} keys`, "each `locales/<language>.json`"],
|
|
125
|
+
["A locale key", `${PLUGIN_LOCALE_KEY_MAX_LENGTH} characters`, "letters, digits, `_` and `-`, in segments joined by dots"],
|
|
126
|
+
["A locale value", `${PLUGIN_LOCALE_VALUE_MAX_LENGTH} characters`, "the text of one key"],
|
|
127
|
+
["`sample-content.json`", formatBinarySize(SAMPLE_CONTENT_MAX_BYTES), "the file as shipped"],
|
|
128
|
+
["Sample content nodes", `${SAMPLE_CONTENT_MAX_NODES} nodes`, "`nodes` in `sample-content.json`"],
|
|
129
|
+
["Sample content media", `${SAMPLE_CONTENT_MAX_MEDIA} entries`, "`media` entries in `sample-content.json`"],
|
|
130
|
+
["Payload entries", `${MAX_TEMPLATE_PAYLOAD_ENTRIES} entries`, "`templates/`, `public/` and the docs files together"],
|
|
131
|
+
];
|
|
132
|
+
return [
|
|
133
|
+
"| Limit | Value | What it bounds |",
|
|
134
|
+
"|---|---|---|",
|
|
135
|
+
...rows.map(([limit, value, bounds]) => `| ${limit} | ${value} | ${bounds} |`),
|
|
136
|
+
].join("\n");
|
|
137
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { installInterfaceFor, installOptionNeedsAnswer } from "@kardalum/api-schemas";
|
|
2
|
+
import { SAMPLE_CONTENT_MAX_BYTES, hasSampleContentConsumer, installFactsOf, readShippedSampleContent } from "../sample-content.js";
|
|
3
|
+
import { createShippedLookup } from "../shipped-files.js";
|
|
4
|
+
import { formatBinarySize } from "./limits.js";
|
|
5
|
+
import { contributionsOf, failed, list, listCapped, passed, plural, record } from "./support.js";
|
|
6
|
+
const declaredTypeNames = (manifest) => new Set(list(contributionsOf(manifest).documentTypes).map((entry) => record(entry)?.name).filter((name) => typeof name === "string"));
|
|
7
|
+
/** The run's one read of sample-content.json: the gate's, or this check's own
|
|
8
|
+
* when it runs outside a gate. */
|
|
9
|
+
function sampleOf({ dir, sampleContent }) {
|
|
10
|
+
return sampleContent ?? readShippedSampleContent(dir);
|
|
11
|
+
}
|
|
12
|
+
/** sample-content.json is optional: absent is a passing no-op. When present it
|
|
13
|
+
* must be a regular file within SAMPLE_CONTENT_MAX_BYTES (the limit the install
|
|
14
|
+
* reads by, checked before the file is read), parse under the one schema in
|
|
15
|
+
* @kardalum/api-schemas, which refuses a node or media count past its limits
|
|
16
|
+
* before reading an entry, name only document types this manifest declares
|
|
17
|
+
* (the seeder's cross-check, done here so an author catches it first), and
|
|
18
|
+
* every declared media file must be one the build carries into media/
|
|
19
|
+
* (whyNotShipped, S311 fix wave: not a left-out name, not behind a link). The
|
|
20
|
+
* read is readShippedSampleContent, the install's own; a schema refusal lists
|
|
21
|
+
* every issue in its details. */
|
|
22
|
+
function checkSampleContent(sample, dir, manifest) {
|
|
23
|
+
if (sample.status === "absent")
|
|
24
|
+
return passed("no sample-content.json: nothing to validate");
|
|
25
|
+
if (sample.status === "unreadable") {
|
|
26
|
+
return sample.details ? failed(`sample-content.json failed validation (${plural(sample.details.length, "issue")})`, sample.details) : failed(sample.reason);
|
|
27
|
+
}
|
|
28
|
+
const { nodes } = sample.file;
|
|
29
|
+
const media = sample.file.media ?? [];
|
|
30
|
+
const known = declaredTypeNames(manifest);
|
|
31
|
+
const unknown = [...new Set(nodes.map((node) => node.documentType))].filter((name) => !known.has(name));
|
|
32
|
+
if (unknown.length > 0) {
|
|
33
|
+
return failed(`sample-content.json references documentType(s) not in this manifest's documentTypes: ${listCapped(unknown, "names")}`);
|
|
34
|
+
}
|
|
35
|
+
const problems = [];
|
|
36
|
+
const whyNotShipped = createShippedLookup(dir);
|
|
37
|
+
for (const entry of media) {
|
|
38
|
+
const why = whyNotShipped(entry.file);
|
|
39
|
+
if (why !== null)
|
|
40
|
+
problems.push(why === "does not exist" ? `${entry.file}: does not exist at ${entry.file}` : `${entry.file}: ${why}`);
|
|
41
|
+
}
|
|
42
|
+
if (problems.length > 0) {
|
|
43
|
+
return failed(`sample-content.json declares ${plural(problems.length, "media file")} the package does not carry`, problems);
|
|
44
|
+
}
|
|
45
|
+
return passed(media.length > 0
|
|
46
|
+
? `${plural(nodes.length, "sample content node")} valid, ${plural(media.length, "media file")} present`
|
|
47
|
+
: `${plural(nodes.length, "sample content node")} valid`);
|
|
48
|
+
}
|
|
49
|
+
export const sampleContentCheck = {
|
|
50
|
+
name: "sample content valid",
|
|
51
|
+
rule: `\`sample-content.json\` is a regular file within ${formatBinarySize(SAMPLE_CONTENT_MAX_BYTES)} that parses, names only document types the manifest declares, and whose media files are files under \`media/\` the build carries.`,
|
|
52
|
+
gates: ["cli", "door"],
|
|
53
|
+
needsManifest: true,
|
|
54
|
+
run: (context) => checkSampleContent(sampleOf(context), context.dir, context.manifest),
|
|
55
|
+
};
|
|
56
|
+
function count(n, one, many) {
|
|
57
|
+
return `${n} ${n === 1 ? one : many}`;
|
|
58
|
+
}
|
|
59
|
+
// S292: what an install of this plugin will ask, derived the way the install
|
|
60
|
+
// screen derives it (installInterfaceFor over the manifest and what the
|
|
61
|
+
// package ships). It fails one case only: a sample-content.json nothing
|
|
62
|
+
// consumes, which `build` refuses and an install could never add. A required
|
|
63
|
+
// option is a legitimate design, so it is counted, never warned about.
|
|
64
|
+
export const installOptionsCheck = {
|
|
65
|
+
name: "install options",
|
|
66
|
+
rule: "A `sample-content.json` ships only with a consumer: `documentTypes` or a `bundledTemplate`. The check also reports what the install will ask.",
|
|
67
|
+
gates: ["cli", "door"],
|
|
68
|
+
needsManifest: true,
|
|
69
|
+
run: (context) => {
|
|
70
|
+
const { manifest } = context;
|
|
71
|
+
const shipped = installFactsOf(sampleOf(context));
|
|
72
|
+
if (shipped.sampleContent && !hasSampleContentConsumer(manifest)) {
|
|
73
|
+
return failed("sample-content.json ships, but nothing in the manifest consumes it: declare documentTypes or a bundledTemplate, or remove the file");
|
|
74
|
+
}
|
|
75
|
+
const asks = installInterfaceFor(manifest, shipped);
|
|
76
|
+
const parts = [];
|
|
77
|
+
if (asks.sampleContent)
|
|
78
|
+
parts.push("add the sample content (yes by default)");
|
|
79
|
+
if (asks.roles.length > 0)
|
|
80
|
+
parts.push(`create ${count(asks.roles.length, "offered role", "offered roles")} (no by default)`);
|
|
81
|
+
if (asks.steps.length > 0) {
|
|
82
|
+
const options = asks.steps.flatMap((step) => step.options);
|
|
83
|
+
const needingAnswer = options.filter((option) => installOptionNeedsAnswer(option)).length;
|
|
84
|
+
parts.push(`${count(asks.steps.length, "step", "steps")} with ${count(options.length, "option", "options")}${needingAnswer > 0 ? `, ${needingAnswer} needing an answer` : ""}`);
|
|
85
|
+
}
|
|
86
|
+
if (parts.length === 0)
|
|
87
|
+
return passed("the install asks nothing: no steps declared, no sample content, no offered roles");
|
|
88
|
+
return passed(`the install asks: ${parts.join("; ")}`);
|
|
89
|
+
},
|
|
90
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DeliveryOutcome } from "./types.js";
|
|
2
|
+
export type Plain = Record<string, unknown>;
|
|
3
|
+
export declare function record(value: unknown): Plain | null;
|
|
4
|
+
export declare function list(value: unknown): unknown[];
|
|
5
|
+
export declare function contributionsOf(manifest: Plain): Plain;
|
|
6
|
+
export declare function plural(count: number, word: string): string;
|
|
7
|
+
/** "a, b or c": the items of a rule string that offers a choice. */
|
|
8
|
+
export declare function orList(items: readonly string[]): string;
|
|
9
|
+
export declare const passed: (message: string, details?: string[]) => DeliveryOutcome;
|
|
10
|
+
export declare const failed: (message: string, details?: string[]) => DeliveryOutcome;
|
|
11
|
+
export declare const warning: (message: string, details?: string[]) => DeliveryOutcome;
|
|
12
|
+
/** How many items a message lists before it says how many more there are. */
|
|
13
|
+
export declare const LISTED_MAX = 5;
|
|
14
|
+
/** The first LISTED_MAX items for a message, then how many more (S311): names
|
|
15
|
+
* run on with commas ("a, b and 3 more"), sentences with semicolons ("a; b;
|
|
16
|
+
* and 3 more"). A package can hold thousands of files, and a message that
|
|
17
|
+
* names each one is a message nobody reads and a door that stores megabytes. */
|
|
18
|
+
export declare function listCapped(items: readonly string[], kind?: "names" | "sentences"): string;
|
|
19
|
+
/** A thrown value as a developer-readable string, carrying the offending path
|
|
20
|
+
* when Node's error names one (EISDIR and EACCES do). Given the package
|
|
21
|
+
* directory, every path reads relative to it (S311): the server's extraction
|
|
22
|
+
* directory means nothing to an author and says where the server keeps its
|
|
23
|
+
* files. */
|
|
24
|
+
export declare function describeError(error: unknown, baseDir?: string): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { relative, sep } from "node:path";
|
|
2
|
+
export function record(value) {
|
|
3
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4
|
+
}
|
|
5
|
+
export function list(value) {
|
|
6
|
+
return Array.isArray(value) ? value : [];
|
|
7
|
+
}
|
|
8
|
+
export function contributionsOf(manifest) {
|
|
9
|
+
return record(manifest.contributions) ?? {};
|
|
10
|
+
}
|
|
11
|
+
export function plural(count, word) {
|
|
12
|
+
return `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
13
|
+
}
|
|
14
|
+
/** "a, b or c": the items of a rule string that offers a choice. */
|
|
15
|
+
export function orList(items) {
|
|
16
|
+
if (items.length < 2)
|
|
17
|
+
return items.join("");
|
|
18
|
+
return `${items.slice(0, -1).join(", ")} or ${items[items.length - 1]}`;
|
|
19
|
+
}
|
|
20
|
+
export const passed = (message, details) => details && details.length > 0 ? { status: "passed", message, details } : { status: "passed", message };
|
|
21
|
+
export const failed = (message, details) => details && details.length > 0 ? { status: "failed", message, details } : { status: "failed", message };
|
|
22
|
+
export const warning = (message, details) => details && details.length > 0 ? { status: "warning", message, details } : { status: "warning", message };
|
|
23
|
+
/** How many items a message lists before it says how many more there are. */
|
|
24
|
+
export const LISTED_MAX = 5;
|
|
25
|
+
/** The first LISTED_MAX items for a message, then how many more (S311): names
|
|
26
|
+
* run on with commas ("a, b and 3 more"), sentences with semicolons ("a; b;
|
|
27
|
+
* and 3 more"). A package can hold thousands of files, and a message that
|
|
28
|
+
* names each one is a message nobody reads and a door that stores megabytes. */
|
|
29
|
+
export function listCapped(items, kind = "sentences") {
|
|
30
|
+
const shown = items.slice(0, LISTED_MAX);
|
|
31
|
+
const rest = items.length - shown.length;
|
|
32
|
+
if (kind === "names")
|
|
33
|
+
return rest > 0 ? `${shown.join(", ")} and ${rest} more` : shown.join(", ");
|
|
34
|
+
return rest > 0 ? `${shown.join("; ")}; and ${rest} more` : shown.join("; ");
|
|
35
|
+
}
|
|
36
|
+
/** A path as it reads inside the package: relative to `baseDir`, with "/". */
|
|
37
|
+
function insidePackage(baseDir, path) {
|
|
38
|
+
return relative(baseDir, path).split(sep).join("/") || ".";
|
|
39
|
+
}
|
|
40
|
+
/** A thrown value as a developer-readable string, carrying the offending path
|
|
41
|
+
* when Node's error names one (EISDIR and EACCES do). Given the package
|
|
42
|
+
* directory, every path reads relative to it (S311): the server's extraction
|
|
43
|
+
* directory means nothing to an author and says where the server keeps its
|
|
44
|
+
* files. */
|
|
45
|
+
export function describeError(error, baseDir) {
|
|
46
|
+
const path = error !== null && typeof error === "object" && "path" in error && typeof error.path === "string"
|
|
47
|
+
? error.path
|
|
48
|
+
: null;
|
|
49
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
+
if (path === null)
|
|
51
|
+
return baseDir ? message.split(baseDir + sep).join("") : message;
|
|
52
|
+
const shown = baseDir ? insidePackage(baseDir, path) : path;
|
|
53
|
+
const text = message.includes(path) ? message.split(path).join(shown) : `${message} (${shown})`;
|
|
54
|
+
return baseDir ? text.split(baseDir + sep).join("") : text;
|
|
55
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DeliveryCheck } from "./types.js";
|
|
2
|
+
export declare const templateDeclarationsCheck: DeliveryCheck;
|
|
3
|
+
export declare const templateFilesCheck: DeliveryCheck;
|
|
4
|
+
export declare const templateWiringCheck: DeliveryCheck;
|
|
5
|
+
export declare const assetsCheck: DeliveryCheck;
|
|
6
|
+
export declare const entryBudgetCheck: DeliveryCheck;
|
|
7
|
+
export declare const payloadSizesCheck: DeliveryCheck;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { lstatSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { MAX_ASSET_CONTENT_BYTES, MAX_TEMPLATE_CONTENT_BYTES, MAX_TEMPLATE_PAYLOAD_ENTRIES, PluginAssetPathSchema, PluginTemplateFileSchema, PluginTemplatePayloadSchema, RESERVED_ASSET_ROOTS, TEMPLATE_KINDS, checkTemplateAndAssetDeclarations, effectiveDocsPages, isAssetTextPath, listIssues, } from "@kardalum/api-schemas";
|
|
4
|
+
import { docsFilesToShip } from "../docs-contract.js";
|
|
5
|
+
import { createShippedLookup, walkShipped } from "../shipped-files.js";
|
|
6
|
+
import { formatBinarySize } from "./limits.js";
|
|
7
|
+
import { contributionsOf, failed, list, orList, passed, plural, record } from "./support.js";
|
|
8
|
+
// S196 and S268: any plugin may declare templates and assets, whatever its
|
|
9
|
+
// listing label. Each check here asks its own question of the declaration and
|
|
10
|
+
// passes with "nothing declared" when there is none. The rules themselves are
|
|
11
|
+
// the shared schema in @kardalum/api-schemas (plugin-template-payload.ts),
|
|
12
|
+
// which the SDK and the server's install read too.
|
|
13
|
+
/** The cross-entry issues of a manifest's templates and assets, split by whether
|
|
14
|
+
* they are a page template's unresolved documentType (the wiring check reports
|
|
15
|
+
* those). A documentType on another kind is a declaration error, reported once,
|
|
16
|
+
* by the declarations check. */
|
|
17
|
+
function crossIssues(manifest) {
|
|
18
|
+
const c = contributionsOf(manifest);
|
|
19
|
+
// Entries too malformed to compare are left to the schema; the issue paths are
|
|
20
|
+
// mapped back to each entry's index in the manifest.
|
|
21
|
+
const templates = [];
|
|
22
|
+
list(c.templates).forEach((raw, index) => {
|
|
23
|
+
const e = record(raw);
|
|
24
|
+
if (!e || typeof e.file !== "string" || typeof e.alias !== "string" || typeof e.kind !== "string")
|
|
25
|
+
return;
|
|
26
|
+
templates.push({ index, file: e.file, alias: e.alias, kind: e.kind, ...(typeof e.documentType === "string" ? { documentType: e.documentType } : {}) });
|
|
27
|
+
});
|
|
28
|
+
const assets = [];
|
|
29
|
+
list(c.assets).forEach((raw, index) => {
|
|
30
|
+
if (typeof raw === "string")
|
|
31
|
+
assets.push({ index, path: raw });
|
|
32
|
+
});
|
|
33
|
+
const compared = { templates, assets };
|
|
34
|
+
const issues = checkTemplateAndAssetDeclarations({
|
|
35
|
+
templates,
|
|
36
|
+
assets: assets.map((asset) => asset.path),
|
|
37
|
+
documentTypes: list(c.documentTypes).flatMap((raw) => {
|
|
38
|
+
const name = record(raw)?.name;
|
|
39
|
+
return typeof name === "string" ? [{ name }] : [];
|
|
40
|
+
}),
|
|
41
|
+
}).map((issue) => {
|
|
42
|
+
const [field, position, ...rest] = issue.path;
|
|
43
|
+
const entry = typeof field === "string" && typeof position === "number" ? compared[field]?.[position] : undefined;
|
|
44
|
+
return entry ? { ...issue, path: [field, entry.index, ...rest] } : issue;
|
|
45
|
+
});
|
|
46
|
+
const pageIndexes = new Set(templates.filter((t) => t.kind === "page").map((t) => t.index));
|
|
47
|
+
const isWiring = (i) => i.path[0] === "templates" && i.path[2] === "documentType" && pageIndexes.has(i.path[1]);
|
|
48
|
+
return { wiring: issues.filter(isWiring), rest: issues.filter((i) => !isWiring(i)) };
|
|
49
|
+
}
|
|
50
|
+
/** The first folders an asset path may not start with, sorted as the schema's own message lists them. */
|
|
51
|
+
const RESERVED_FIRST_FOLDERS = [...RESERVED_ASSET_ROOTS].sort().map((root) => `\`${root}\``).join(", ");
|
|
52
|
+
export const templateDeclarationsCheck = {
|
|
53
|
+
name: "template declarations valid",
|
|
54
|
+
rule: "Template entries and asset paths obey the shared schema: kebab-case unique aliases, `.liquid` files, " +
|
|
55
|
+
`and a kind that is ${orList(TEMPLATE_KINDS)}; ` +
|
|
56
|
+
`asset paths that are relative, text, with no reserved first folder (${RESERVED_FIRST_FOLDERS}) and no \`public/\` prefix.`,
|
|
57
|
+
gates: ["cli", "door"],
|
|
58
|
+
needsManifest: true,
|
|
59
|
+
run: ({ manifest }) => {
|
|
60
|
+
const c = contributionsOf(manifest);
|
|
61
|
+
if (c.templates === undefined && c.assets === undefined)
|
|
62
|
+
return passed("no templates or assets declared");
|
|
63
|
+
const parsed = PluginTemplatePayloadSchema.safeParse({ templates: c.templates, assets: c.assets });
|
|
64
|
+
const issues = [...(parsed.success ? [] : parsed.error.issues), ...crossIssues(manifest).rest];
|
|
65
|
+
if (issues.length > 0)
|
|
66
|
+
return failed(listIssues(issues, 10));
|
|
67
|
+
return passed(`${plural(list(c.templates).length, "template")}, ${plural(list(c.assets).length, "asset")}: declarations valid`);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
// S311 fix wave (W1): a declared file is there when the build carries it into
|
|
71
|
+
// the package (whyNotShipped, the rule the CLI's copy follows), not merely when
|
|
72
|
+
// it is on disk: a file under a left-out folder such as dist/, or behind a
|
|
73
|
+
// link, is on disk and never ships. Each detail says which it is.
|
|
74
|
+
export const templateFilesCheck = {
|
|
75
|
+
name: "template files exist",
|
|
76
|
+
rule: "Every declared template file is a file under `templates/` that the build carries: not behind a link, not inside a left-out folder such as `dist/` or `node_modules/`.",
|
|
77
|
+
gates: ["cli", "door"],
|
|
78
|
+
needsManifest: true,
|
|
79
|
+
run: ({ dir, manifest }) => {
|
|
80
|
+
const entries = list(contributionsOf(manifest).templates);
|
|
81
|
+
if (entries.length === 0)
|
|
82
|
+
return passed("no templates declared");
|
|
83
|
+
const problems = [];
|
|
84
|
+
const whyNotShipped = createShippedLookup(dir);
|
|
85
|
+
for (const raw of entries) {
|
|
86
|
+
const file = record(raw)?.file;
|
|
87
|
+
// An unusable path is reported by `template declarations valid`; never join it.
|
|
88
|
+
if (typeof file !== "string" || !PluginTemplateFileSchema.safeParse(file).success)
|
|
89
|
+
continue;
|
|
90
|
+
const why = whyNotShipped(`templates/${file}`);
|
|
91
|
+
if (why !== null)
|
|
92
|
+
problems.push(why === "does not exist" ? `${file}: does not exist under templates/` : `${file}: templates/${file} ${why}`);
|
|
93
|
+
}
|
|
94
|
+
if (problems.length > 0)
|
|
95
|
+
return failed(`${plural(problems.length, "declared template file")} not in the package`, problems);
|
|
96
|
+
return passed(`${plural(entries.length, "template file")} present`);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
export const templateWiringCheck = {
|
|
100
|
+
name: "template document types wired",
|
|
101
|
+
rule: "A page template's `documentType`, when set, names a document type this manifest declares.",
|
|
102
|
+
gates: ["cli", "door"],
|
|
103
|
+
needsManifest: true,
|
|
104
|
+
run: ({ manifest }) => {
|
|
105
|
+
const { wiring } = crossIssues(manifest);
|
|
106
|
+
if (wiring.length > 0)
|
|
107
|
+
return failed(listIssues(wiring, 10));
|
|
108
|
+
return passed("every documentType a template names is declared");
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
export const assetsCheck = {
|
|
112
|
+
name: "assets declared exist",
|
|
113
|
+
rule: "Every declared asset is a file under `public/` that the build carries: not behind a link, not inside a left-out folder such as `dist/` or `node_modules/`.",
|
|
114
|
+
gates: ["cli", "door"],
|
|
115
|
+
needsManifest: true,
|
|
116
|
+
run: ({ dir, manifest }) => {
|
|
117
|
+
const declared = list(contributionsOf(manifest).assets).filter((a) => typeof a === "string");
|
|
118
|
+
if (declared.length === 0)
|
|
119
|
+
return passed("no assets declared");
|
|
120
|
+
const problems = [];
|
|
121
|
+
const whyNotShipped = createShippedLookup(dir);
|
|
122
|
+
for (const path of declared) {
|
|
123
|
+
// An unusable path is reported by `template declarations valid`; never join it.
|
|
124
|
+
if (!PluginAssetPathSchema.safeParse(path).success)
|
|
125
|
+
continue;
|
|
126
|
+
const why = whyNotShipped(`public/${path}`);
|
|
127
|
+
if (why !== null)
|
|
128
|
+
problems.push(why === "does not exist" ? `${path}: does not exist at public/${path}` : `${path}: public/${path} ${why}`);
|
|
129
|
+
}
|
|
130
|
+
if (problems.length > 0) {
|
|
131
|
+
return failed(`${plural(problems.length, "declared asset")} ${problems.length === 1 ? "is" : "are"} not in the package`, problems);
|
|
132
|
+
}
|
|
133
|
+
return passed(`${plural(declared.length, "asset")} present under public/`);
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
/** Past this many entries the check still passes, with a warning detail. */
|
|
137
|
+
const WARN_PAYLOAD_ENTRIES = 1000;
|
|
138
|
+
export const entryBudgetCheck = {
|
|
139
|
+
name: "artifact entry budget",
|
|
140
|
+
rule: `\`templates/\`, \`public/\` and the docs files hold at most ${MAX_TEMPLATE_PAYLOAD_ENTRIES} entries together.`,
|
|
141
|
+
gates: ["cli", "door"],
|
|
142
|
+
needsManifest: false,
|
|
143
|
+
run: ({ dir, manifest }) => {
|
|
144
|
+
// S311 second code fix: what the build carries, through the walker its
|
|
145
|
+
// copy uses: a left-out folder or a link never counts, and a linked top
|
|
146
|
+
// folder is not followed.
|
|
147
|
+
let total = 0;
|
|
148
|
+
for (const sub of ["templates", "public"])
|
|
149
|
+
total += walkShipped(join(dir, sub)).length;
|
|
150
|
+
// The docs pages and the images they show ship in the package too.
|
|
151
|
+
total += docsFilesToShip(dir, effectiveDocsPages(manifest.docs, String(manifest.name ?? ""))).length;
|
|
152
|
+
if (total > MAX_TEMPLATE_PAYLOAD_ENTRIES) {
|
|
153
|
+
return failed(`${total} payload entries exceeds the ${MAX_TEMPLATE_PAYLOAD_ENTRIES}-entry budget`);
|
|
154
|
+
}
|
|
155
|
+
const message = `${total} payload entries (budget ${MAX_TEMPLATE_PAYLOAD_ENTRIES})`;
|
|
156
|
+
if (total > WARN_PAYLOAD_ENTRIES)
|
|
157
|
+
return passed(message, [`warning: over ${WARN_PAYLOAD_ENTRIES} entries, approaching the artifact budget`]);
|
|
158
|
+
return passed(message);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
/** A regular file's size, or null for anything else (a missing file is the files checks' to report). */
|
|
162
|
+
function fileSize(path) {
|
|
163
|
+
try {
|
|
164
|
+
const stat = lstatSync(path, { throwIfNoEntry: false });
|
|
165
|
+
return stat?.isFile() ? stat.size : null;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// S314c3 (D10): a site holds a template to KARDALUM_MAX_TEMPLATE_BYTES and an asset to
|
|
172
|
+
// KARDALUM_MAX_ASSET_BYTES, and an install refuses a package with a larger file whole (D9). A build
|
|
173
|
+
// cannot know the site, so it holds the package to the defaults, and a package that passes installs
|
|
174
|
+
// on any site left at them.
|
|
175
|
+
export const payloadSizesCheck = {
|
|
176
|
+
name: "template and asset sizes",
|
|
177
|
+
rule: `Every declared template file is at most ${formatBinarySize(MAX_TEMPLATE_CONTENT_BYTES)}, and every declared asset and every text file under \`public/\` at most ${formatBinarySize(MAX_ASSET_CONTENT_BYTES)}: ` +
|
|
178
|
+
"the defaults of a site's own limits (`KARDALUM_MAX_TEMPLATE_BYTES`, `KARDALUM_MAX_ASSET_BYTES`), so the package installs on any site left at them.",
|
|
179
|
+
gates: ["cli", "door"],
|
|
180
|
+
needsManifest: true,
|
|
181
|
+
run: ({ dir, manifest }) => {
|
|
182
|
+
const c = contributionsOf(manifest);
|
|
183
|
+
const templates = list(c.templates).flatMap((raw) => {
|
|
184
|
+
const file = record(raw)?.file;
|
|
185
|
+
// An unusable path is reported by `template declarations valid`; never join it.
|
|
186
|
+
return typeof file === "string" && PluginTemplateFileSchema.safeParse(file).success ? [file] : [];
|
|
187
|
+
});
|
|
188
|
+
const assets = list(c.assets).filter((a) => typeof a === "string" && PluginAssetPathSchema.safeParse(a).success);
|
|
189
|
+
// The install also holds an undeclared text file under public/ to the asset limit (it lands as
|
|
190
|
+
// a plain file the asset editor opens), so the build does too, from the same extension list.
|
|
191
|
+
const declared = new Set(assets);
|
|
192
|
+
const undeclaredText = walkShipped(join(dir, "public")).filter((e) => !e.isDirectory && !declared.has(e.path) && isAssetTextPath(e.path)).map((e) => e.path);
|
|
193
|
+
if (templates.length === 0 && assets.length === 0 && undeclaredText.length === 0)
|
|
194
|
+
return passed("no templates or assets declared");
|
|
195
|
+
const problems = [];
|
|
196
|
+
for (const file of templates) {
|
|
197
|
+
const size = fileSize(join(dir, "templates", ...file.split("/")));
|
|
198
|
+
if (size !== null && size > MAX_TEMPLATE_CONTENT_BYTES)
|
|
199
|
+
problems.push(`${file}: ${size} bytes, over the ${formatBinarySize(MAX_TEMPLATE_CONTENT_BYTES)} a template may hold`);
|
|
200
|
+
}
|
|
201
|
+
for (const path of assets) {
|
|
202
|
+
const size = fileSize(join(dir, "public", ...path.split("/")));
|
|
203
|
+
if (size !== null && size > MAX_ASSET_CONTENT_BYTES)
|
|
204
|
+
problems.push(`${path}: ${size} bytes, over the ${formatBinarySize(MAX_ASSET_CONTENT_BYTES)} an asset may hold`);
|
|
205
|
+
}
|
|
206
|
+
for (const path of undeclaredText) {
|
|
207
|
+
const size = fileSize(join(dir, "public", ...path.split("/")));
|
|
208
|
+
if (size !== null && size > MAX_ASSET_CONTENT_BYTES)
|
|
209
|
+
problems.push(`${path}: ${size} bytes, over the ${formatBinarySize(MAX_ASSET_CONTENT_BYTES)} an asset may hold`);
|
|
210
|
+
}
|
|
211
|
+
if (problems.length > 0)
|
|
212
|
+
return failed(`${plural(problems.length, "file")} over the size a site holds by default`, problems);
|
|
213
|
+
return passed(`${plural(templates.length, "template")}, ${plural(assets.length, "asset")}: within the default limits`);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { DocsContractInput } from "../docs-contract.js";
|
|
2
|
+
import type { ShippedSampleContent } from "../sample-content.js";
|
|
3
|
+
export type DeliveryGate = "cli" | "door";
|
|
4
|
+
export type DeliveryStatus = "passed" | "failed" | "warning" | "skipped";
|
|
5
|
+
export interface DeliveryOutcome {
|
|
6
|
+
status: DeliveryStatus;
|
|
7
|
+
message: string;
|
|
8
|
+
details?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface DeliveryResult extends DeliveryOutcome {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
export type DocsInputResult = {
|
|
14
|
+
ok: true;
|
|
15
|
+
input: DocsContractInput;
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
reasons: string[];
|
|
19
|
+
};
|
|
20
|
+
export interface DeliveryContext {
|
|
21
|
+
dir: string;
|
|
22
|
+
manifest: Record<string, unknown> | null;
|
|
23
|
+
docsInput?: DocsInputResult;
|
|
24
|
+
/** Where the client bundle (remoteEntry.js and assets/) is, when not in
|
|
25
|
+
* `dir`: the CLI hands over the federation build it packs, with the build's
|
|
26
|
+
* error when it failed. The door's package directory holds its bundle, so
|
|
27
|
+
* the door passes none. */
|
|
28
|
+
bundle?: {
|
|
29
|
+
dir: string;
|
|
30
|
+
buildError?: string;
|
|
31
|
+
};
|
|
32
|
+
/** The package's sample-content.json, read once for the run (S311): runChecks
|
|
33
|
+
* reads it when the caller has not, and both sample checks take it from
|
|
34
|
+
* here, so a gate parses the file once. The door hands its own read on to
|
|
35
|
+
* the stored install interface. */
|
|
36
|
+
sampleContent?: ShippedSampleContent;
|
|
37
|
+
}
|
|
38
|
+
export interface DeliveryRunContext extends Omit<DeliveryContext, "manifest"> {
|
|
39
|
+
manifest: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
export interface DeliveryCheck {
|
|
42
|
+
name: string;
|
|
43
|
+
rule: string;
|
|
44
|
+
gates: readonly DeliveryGate[];
|
|
45
|
+
needsManifest: boolean;
|
|
46
|
+
run(context: DeliveryRunContext): DeliveryOutcome;
|
|
47
|
+
}
|
|
48
|
+
export interface GateOnlyCheck {
|
|
49
|
+
name: string;
|
|
50
|
+
gate: DeliveryGate;
|
|
51
|
+
rule: string;
|
|
52
|
+
skippedAtDoor: boolean;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,8 +6,9 @@ export interface DocsContractInput {
|
|
|
6
6
|
}
|
|
7
7
|
/** The most a manifest.json or reference.json may weigh. The door parses both
|
|
8
8
|
* synchronously on the event loop, so a schema-valid file of tens of
|
|
9
|
-
* megabytes would block it on every request that reads one.
|
|
10
|
-
|
|
9
|
+
* megabytes would block it on every request that reads one. The manifest's
|
|
10
|
+
* limit, defined once (S311). */
|
|
11
|
+
export declare const MAX_PACKAGE_JSON_BYTES: number;
|
|
11
12
|
/** A posix package-relative path as a native filesystem path. This is the
|
|
12
13
|
* one place such a path becomes a real one, so it is also where leaving the
|
|
13
14
|
* package is made impossible: a path that would is a defect in the checks
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import { join, resolve, sep } from "node:path";
|
|
3
3
|
import { MAX_DOC_PAGE_BYTES, PluginDocsPageSchema, PluginReferenceSchema, checkDocsDeclaration, docsFactsFrom, effectiveDocsPages, extractDocHeadings, isRenderableExternalHref, MAX_DOCS_TARGET_LENGTH, referencePageSlugs, requiredDocRoles, resolveDocsLink, resolveDocsPath, } from "@kardalum/api-schemas";
|
|
4
|
+
import { MANIFEST_MAX_BYTES } from "./delivery/limits.js";
|
|
4
5
|
/** The most a manifest.json or reference.json may weigh. The door parses both
|
|
5
6
|
* synchronously on the event loop, so a schema-valid file of tens of
|
|
6
|
-
* megabytes would block it on every request that reads one.
|
|
7
|
-
|
|
7
|
+
* megabytes would block it on every request that reads one. The manifest's
|
|
8
|
+
* limit, defined once (S311). */
|
|
9
|
+
export const MAX_PACKAGE_JSON_BYTES = MANIFEST_MAX_BYTES;
|
|
8
10
|
const IMAGE_EXTENSION = /\.(png|jpe?g|gif|webp)$/i;
|
|
9
11
|
/** Past this many links and images a page is refused rather than checked. */
|
|
10
12
|
const MAX_TARGETS_PER_PAGE = 2000;
|