@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
package/dist/manifest.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ComponentType } from "react";
|
|
2
|
-
import type { CreateDocumentTypeRequest, PluginDocsPage } from "@kardalum/api-schemas";
|
|
2
|
+
import type { CreateDocumentTypeRequest, PluginDocsPage, PluginInstallDeclaration, PluginLabel, ResolvedInstallAnswers } from "@kardalum/api-schemas";
|
|
3
|
+
export type { InstallChoice, InstallOption, InstallStep, PluginInstallDeclaration, ResolvedInstallAnswers } from "@kardalum/api-schemas";
|
|
3
4
|
import type { ThemeTokenOverrides } from "@kardalum/design-tokens";
|
|
5
|
+
import { VIEW_BEARING_CONTRIBUTIONS, declaresClientBundle } from "@kardalum/plugin-package/reference";
|
|
4
6
|
import type { ZodType } from "zod";
|
|
5
7
|
import type { DataTypePlugin } from "./data-type-plugin.js";
|
|
6
8
|
import type { BUILT_IN_RAIL_SECTIONS } from "./manifest-schema.js";
|
|
@@ -18,13 +20,13 @@ export type PluginType = "datatype" | "section" | "template" | "theme" | "integr
|
|
|
18
20
|
/**
|
|
19
21
|
* Databases a plugin can declare support for. Deliberately NOT
|
|
20
22
|
* db-adapter's DatabaseDialect: that union includes 'mock' (the in-memory
|
|
21
|
-
* test adapter), which no plugin may target
|
|
23
|
+
* test adapter), which no plugin may target, and the SDK is a published
|
|
22
24
|
* package that must not depend on the unpublished adapter internals.
|
|
23
25
|
*/
|
|
24
26
|
export type DatabaseDialect = "postgresql" | "mysql" | "sqlite" | "mssql" | "mongodb";
|
|
25
27
|
/**
|
|
26
28
|
* How the plugin stores data and where it can run. Required on every
|
|
27
|
-
* manifest (plugin-sdk.md)
|
|
29
|
+
* manifest (plugin-sdk.md): the marketplace pre-filters by the site's
|
|
28
30
|
* active database and install is blocked with a clear reason, never a
|
|
29
31
|
* silent failure.
|
|
30
32
|
*/
|
|
@@ -32,14 +34,15 @@ export interface DatabaseCompatibility {
|
|
|
32
34
|
/** 'simple' = JSON key-value SimpleStorageAPI (default, ~80% of
|
|
33
35
|
* plugins); 'structured' = relational StructuredStorageAPI. Declaring
|
|
34
36
|
* 'structured' IS the declaration that this plugin owns real tables:
|
|
35
|
-
* it derives the `storage.structured` capability, which
|
|
36
|
-
*
|
|
37
|
-
* boolean beside it, because a second place to
|
|
38
|
-
* second place for the manifest to disagree with
|
|
37
|
+
* it derives the `storage.structured` capability, which is a promised
|
|
38
|
+
* capability, so a reviewer reads it against your code (S267 section 6).
|
|
39
|
+
* There is deliberately no boolean beside it, because a second place to
|
|
40
|
+
* say the same thing is a second place for the manifest to disagree with
|
|
41
|
+
* itself. */
|
|
39
42
|
storageType: "simple" | "structured";
|
|
40
43
|
supported: DatabaseDialect[];
|
|
41
44
|
/** Optional human-readable reason per UNSUPPORTED dialect (shown on the
|
|
42
|
-
* blocked-install screen)
|
|
45
|
+
* blocked-install screen), hence Partial: supported dialects carry no
|
|
43
46
|
* reason. */
|
|
44
47
|
unsupportedReason?: Partial<Record<DatabaseDialect, string>>;
|
|
45
48
|
}
|
|
@@ -63,9 +66,10 @@ export interface PluginAssertion {
|
|
|
63
66
|
* be claimed falsely or held quietly.
|
|
64
67
|
*
|
|
65
68
|
* These two survive as explicit assertions precisely because no
|
|
66
|
-
* declaration can derive what a plugin's code does at runtime, and
|
|
67
|
-
*
|
|
68
|
-
* the manifest with nothing
|
|
69
|
+
* declaration can derive what a plugin's code does at runtime, and each
|
|
70
|
+
* is a promised capability, so a reviewer reads it against your code, for
|
|
71
|
+
* the same reason: they are the only claims in the manifest with nothing
|
|
72
|
+
* behind them.
|
|
69
73
|
*
|
|
70
74
|
* Presence is the claim. There is no `false`: a key that is absent is an
|
|
71
75
|
* assertion not made. The whole field is optional, so a plugin that
|
|
@@ -115,8 +119,8 @@ export interface PluginMigrationHooks {
|
|
|
115
119
|
validateMigration?: (from: DatabaseDialect, to: DatabaseDialect) => PluginMigrationValidation | Promise<PluginMigrationValidation>;
|
|
116
120
|
}
|
|
117
121
|
/** The events a plugin can hook. The hook engine (S159) actually FIRES
|
|
118
|
-
* only three of these
|
|
119
|
-
* content:afterTrash, content:afterRestore
|
|
122
|
+
* only three of these: content:afterPublish (including rollbacks),
|
|
123
|
+
* content:afterTrash, content:afterRestore, with the
|
|
120
124
|
* ContentLifecycleHookPayload shape declared below; every other event in
|
|
121
125
|
* this catalog is declared for forward compatibility and stays inert. */
|
|
122
126
|
export type HookEvent = "content:beforeSave" | "content:afterSave" | "content:beforePublish" | "content:afterPublish" | "content:afterTrash" | "content:afterRestore" | "content:beforeDelete" | "media:afterUpload" | "user:afterLogin" | "api:beforeResponse";
|
|
@@ -141,8 +145,12 @@ export type HookHandler = (payload: unknown, context?: PluginHookContext) => voi
|
|
|
141
145
|
export type PluginHooks = Partial<Record<HookEvent, HookHandler>>;
|
|
142
146
|
/** A slot's label: a map of language code to text, `en` required (spec D5).
|
|
143
147
|
* Each key is a language code such as `en`, `de` or `pt-BR`. The admin
|
|
144
|
-
* shows the active language's text, else English; `
|
|
145
|
-
* place that choice is made
|
|
148
|
+
* shows the active language's text, else English; `resolveLabel` in
|
|
149
|
+
* @kardalum/api-schemas is the one place that choice is made (S311), and
|
|
150
|
+
* `slotLabel` is it for a map. Since S311 the display names of the other
|
|
151
|
+
* surfaces (an action's label, a role's, a widget's or a scheduled task's
|
|
152
|
+
* name, and the rest typed `PluginLabel` below) take the same map or a
|
|
153
|
+
* plain string. */
|
|
146
154
|
export interface SlotLabel {
|
|
147
155
|
en: string;
|
|
148
156
|
[locale: string]: string;
|
|
@@ -200,7 +208,7 @@ export interface BuiltInRailEntryContribution extends RailEntryContribution {
|
|
|
200
208
|
}
|
|
201
209
|
export interface DashboardWidgetContribution {
|
|
202
210
|
id: string;
|
|
203
|
-
name:
|
|
211
|
+
name: PluginLabel;
|
|
204
212
|
view: ComponentType;
|
|
205
213
|
/** The named permission action a subject must hold to reach this
|
|
206
214
|
* (S270, theme G1). Required: a contribution that declares no action
|
|
@@ -210,56 +218,78 @@ export interface DashboardWidgetContribution {
|
|
|
210
218
|
action: string;
|
|
211
219
|
}
|
|
212
220
|
/** Mounted under /api/plugins/:pluginId/… so two plugins can never
|
|
213
|
-
* collide on a path (api-design.md)
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* boundary (same cross-boundary
|
|
217
|
-
*
|
|
218
|
-
* passes real FastifyRequest
|
|
221
|
+
* collide on a path (api-design.md). The host routes every declaration
|
|
222
|
+
* through Fastify's own router, rebuilt whenever a plugin is attached or
|
|
223
|
+
* detached (S295, 2026-10-14-s295-routes-fastify-knows-about-design.md).
|
|
224
|
+
* `handler` stays untyped at the SDK boundary (the same cross-boundary
|
|
225
|
+
* erasure as view ComponentType fields): the host casts to real Fastify
|
|
226
|
+
* types internally, since it always passes real FastifyRequest and
|
|
227
|
+
* FastifyReply instances. */
|
|
219
228
|
export interface ApiRouteContribution {
|
|
220
229
|
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
221
|
-
/** Relative to /api/plugins/:pluginId
|
|
230
|
+
/** Relative to /api/plugins/:pluginId/: starting with "/" and holding one or
|
|
231
|
+
* more segments, each letters, digits, "-" and "_", or a parameter ":name"
|
|
232
|
+
* (a letter, then letters, digits or "_") matching one segment of the
|
|
233
|
+
* request; at most 200 characters. Two routes of one method that the
|
|
234
|
+
* router would read as one, or that one request could match both of, are
|
|
235
|
+
* refused (api-schemas' checkApiRouteDeclarations). */
|
|
222
236
|
path: string;
|
|
223
237
|
/** Who may call this route.
|
|
224
|
-
* - "admin" (the default when omitted) requires a JWT
|
|
225
|
-
* for admin-facing plugin UIs like Commerce Orders or
|
|
226
|
-
* builder.
|
|
227
|
-
* - "apiKey" requires a
|
|
228
|
-
* headless callers like a
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* Anything unrecognized falls back to "admin" — secure by default. */
|
|
238
|
+
* - "admin" (the default when omitted) requires a JWT session whose role
|
|
239
|
+
* holds `action`: for admin-facing plugin UIs like Commerce Orders or
|
|
240
|
+
* the Forms builder.
|
|
241
|
+
* - "apiKey" requires a live API key that holds `action`, for a read and a
|
|
242
|
+
* write alike (S299): for credentialed headless callers like a
|
|
243
|
+
* storefront checkout.
|
|
244
|
+
* - "public" requires NO credentials: for genuinely anonymous browser
|
|
245
|
+
* traffic such as a contact-form submission (Session 160's Forms plugin
|
|
246
|
+
* was the first consumer). A public route owns its own abuse controls
|
|
247
|
+
* (honeypot, per-IP bucket, body caps) and only reaches browsers
|
|
248
|
+
* cross-origin when the operator allowlists their origin in
|
|
249
|
+
* KARDALUM_CORS_ORIGINS.
|
|
250
|
+
* Anything unrecognized falls back to "admin": secure by default. */
|
|
238
251
|
access?: "admin" | "apiKey" | "public";
|
|
239
|
-
/** Optional
|
|
240
|
-
*
|
|
241
|
-
*
|
|
252
|
+
/** Optional validation, compiled with the host's validator compiler when the
|
|
253
|
+
* host routes the plugin (again on every attach or detach), never per
|
|
254
|
+
* request; the handler receives the parsed values. `response` is the other
|
|
255
|
+
* direction (S297): the success bodies the handler answers, which the host
|
|
256
|
+
* checks and documents. */
|
|
242
257
|
schema?: {
|
|
243
258
|
body?: ZodType;
|
|
244
259
|
querystring?: ZodType;
|
|
260
|
+
/** The path's parameters: a Zod object keyed by the names the path
|
|
261
|
+
* declares. Without it each parameter reaches request.params as a
|
|
262
|
+
* string. */
|
|
245
263
|
params?: ZodType;
|
|
264
|
+
/** The success responses, keyed by status code written as a string,
|
|
265
|
+
* "200" to "299", at most four. When the handler RETURNS a value (it does
|
|
266
|
+
* not send it with `reply.send`), the value is checked against the
|
|
267
|
+
* schema for the status the reply carries (200 unless the handler set
|
|
268
|
+
* another with `reply.code`), and the PARSED value is what is sent:
|
|
269
|
+
* unknown keys dropped, defaults and transforms applied. A value that
|
|
270
|
+
* does not match answers a 500 and is logged with the problems. A status
|
|
271
|
+
* with no entry is sent unchecked, and so is anything the handler sends
|
|
272
|
+
* through `reply.send`. The schemas also document the response in the
|
|
273
|
+
* server's OpenAPI documents. */
|
|
274
|
+
response?: Record<string, ZodType>;
|
|
246
275
|
};
|
|
247
|
-
/** Third argument added Month 8, Session 90
|
|
276
|
+
/** Third argument added Month 8, Session 90, the first server-side
|
|
248
277
|
* consumer needing privileged host access. Existing two-argument (or
|
|
249
278
|
* fewer) handlers remain perfectly valid: TypeScript allows a function
|
|
250
279
|
* with fewer declared parameters to satisfy a type expecting more. */
|
|
251
280
|
handler: (request: unknown, reply: unknown, context: PluginApiRouteContext) => unknown;
|
|
252
281
|
/** The named permission action a caller must hold (S270, theme G1).
|
|
253
|
-
* Required
|
|
254
|
-
*
|
|
255
|
-
*
|
|
282
|
+
* Required unless `access` is "public": on an "admin" route (or one that
|
|
283
|
+
* omits `access`) the session's role must hold it, and on an "apiKey"
|
|
284
|
+
* route the key must hold it, for a read and a write alike (S299). Only a
|
|
285
|
+
* "public" route, which needs no credential, may omit it.
|
|
256
286
|
* `access` decides WHICH CREDENTIAL reaches the handler; this decides
|
|
257
287
|
* WHAT THAT SUBJECT MAY DO. They are orthogonal. */
|
|
258
288
|
action?: string;
|
|
259
289
|
}
|
|
260
290
|
export interface ScheduledTaskContribution {
|
|
261
291
|
id: string;
|
|
262
|
-
name:
|
|
292
|
+
name: PluginLabel;
|
|
263
293
|
/** Standard 5-field cron expression. */
|
|
264
294
|
cron: string;
|
|
265
295
|
run: (context?: PluginTaskContext) => void | Promise<void>;
|
|
@@ -268,55 +298,19 @@ export interface ScheduledTaskContribution {
|
|
|
268
298
|
* contract firms up when the BullMQ media pipeline lands. */
|
|
269
299
|
export interface MediaProcessorContribution {
|
|
270
300
|
id: string;
|
|
271
|
-
name:
|
|
301
|
+
name: PluginLabel;
|
|
272
302
|
process: (file: unknown) => unknown | Promise<unknown>;
|
|
273
303
|
}
|
|
274
|
-
export interface SettingsPageContribution {
|
|
275
|
-
id: string;
|
|
276
|
-
name: string;
|
|
277
|
-
view: ComponentType;
|
|
278
|
-
/** The named permission action a subject must hold to reach this
|
|
279
|
-
* (S270, theme G1). Required: a contribution that declares no action
|
|
280
|
-
* would be a gate nobody chose, and omission is how a permission
|
|
281
|
-
* silently loosens. Must be prefixed with this plugin's own id, so one
|
|
282
|
-
* plugin cannot declare an action in another's namespace or in core's. */
|
|
283
|
-
action: string;
|
|
284
|
-
}
|
|
285
|
-
export interface ContentTreeActionContribution {
|
|
286
|
-
id: string;
|
|
287
|
-
label: string;
|
|
288
|
-
onSelect: (nodeId: string) => void | Promise<void>;
|
|
289
|
-
/** The named permission action a subject must hold to reach this
|
|
290
|
-
* (S270, theme G1). Required: a contribution that declares no action
|
|
291
|
-
* would be a gate nobody chose, and omission is how a permission
|
|
292
|
-
* silently loosens. Must be prefixed with this plugin's own id, so one
|
|
293
|
-
* plugin cannot declare an action in another's namespace or in core's. */
|
|
294
|
-
action: string;
|
|
295
|
-
}
|
|
296
|
-
/** A button in the rich-text editor's toolbar. TipTap wiring comes with
|
|
297
|
-
* the first consumer. */
|
|
298
|
-
export interface EditorToolbarContribution {
|
|
299
|
-
id: string;
|
|
300
|
-
label: string;
|
|
301
|
-
icon: string;
|
|
302
|
-
onClick: () => void | Promise<void>;
|
|
303
|
-
/** The named permission action a subject must hold to reach this
|
|
304
|
-
* (S270, theme G1). Required: a contribution that declares no action
|
|
305
|
-
* would be a gate nobody chose, and omission is how a permission
|
|
306
|
-
* silently loosens. Must be prefixed with this plugin's own id, so one
|
|
307
|
-
* plugin cannot declare an action in another's namespace or in core's. */
|
|
308
|
-
action: string;
|
|
309
|
-
}
|
|
310
304
|
/** A service an integration plugin exposes for other plugins to consume
|
|
311
305
|
* (e.g. a Stripe client). Shape intentionally opaque until the
|
|
312
306
|
* cross-plugin service registry exists. */
|
|
313
307
|
export interface ExposedServiceContribution {
|
|
314
308
|
id: string;
|
|
315
|
-
name:
|
|
309
|
+
name: PluginLabel;
|
|
316
310
|
service: unknown;
|
|
317
311
|
}
|
|
318
312
|
/** A ready-made frontend starter shipped alongside a plugin (e.g. the
|
|
319
|
-
* Commerce plugin's "Online Store" Next.js starter)
|
|
313
|
+
* Commerce plugin's "Online Store" Next.js starter), one marketplace
|
|
320
314
|
* listing, working site immediately. Packaging lands Month 13. */
|
|
321
315
|
export interface BundledTemplateContribution {
|
|
322
316
|
name: string;
|
|
@@ -324,14 +318,14 @@ export interface BundledTemplateContribution {
|
|
|
324
318
|
/** Where the starter's source lives until marketplace packaging exists. */
|
|
325
319
|
repository?: string;
|
|
326
320
|
}
|
|
327
|
-
/** One render template a plugin ships under its own `templates/` dir
|
|
328
|
-
* per S192 §8 ("a new `templates` contribution
|
|
321
|
+
/** One render template a plugin ships under its own `templates/` dir,
|
|
322
|
+
* per S192 §8 ("a new `templates` contribution: template files declared
|
|
329
323
|
* with alias/kind and, for pages, which contributed document type they
|
|
330
324
|
* render"). Any plugin may declare templates (S268): a `page` kind entry
|
|
331
325
|
* may only name a document type this same manifest declares. */
|
|
332
326
|
export interface TemplateContribution {
|
|
333
327
|
/** Relative path under the plugin's `templates/` directory, forward
|
|
334
|
-
* slashes, ending in `.liquid
|
|
328
|
+
* slashes, ending in `.liquid`: this is the file S192 §5 says the
|
|
335
329
|
* developer edits and the mirror-on-edit versioning tracks. */
|
|
336
330
|
file: string;
|
|
337
331
|
name: string;
|
|
@@ -340,7 +334,7 @@ export interface TemplateContribution {
|
|
|
340
334
|
alias: string;
|
|
341
335
|
kind: "page" | "layout" | "partial";
|
|
342
336
|
/** `page` kind only: a NAME from THIS manifest's own `documentTypes`
|
|
343
|
-
* contribution
|
|
337
|
+
* contribution: the document type this page template renders.
|
|
344
338
|
* Optional: a catch-all-ish page template with no specific type is
|
|
345
339
|
* legal (S193 allows a null `documentTypeId`). Forbidden on
|
|
346
340
|
* `layout`/`partial` entries, which never render a document type. */
|
|
@@ -355,7 +349,7 @@ export interface SerializerContext {
|
|
|
355
349
|
publishedAt: string | null;
|
|
356
350
|
version: number;
|
|
357
351
|
};
|
|
358
|
-
/** SERIALIZED field data
|
|
352
|
+
/** SERIALIZED field data: contributions run after core serialization. */
|
|
359
353
|
data: Record<string, unknown>;
|
|
360
354
|
documentType: {
|
|
361
355
|
id: string;
|
|
@@ -363,7 +357,7 @@ export interface SerializerContext {
|
|
|
363
357
|
};
|
|
364
358
|
}
|
|
365
359
|
export interface CustomFormatContribution {
|
|
366
|
-
/** Plugin-scoped name, /^[a-z0-9-]
|
|
360
|
+
/** Plugin-scoped name, /^[a-z0-9-]+$/, addressed as `<pluginId>:<name>`. */
|
|
367
361
|
name: string;
|
|
368
362
|
build: (context: SerializerContext) => unknown | Promise<unknown>;
|
|
369
363
|
}
|
|
@@ -384,9 +378,6 @@ export interface PluginContributions {
|
|
|
384
378
|
hooks?: PluginHooks;
|
|
385
379
|
scheduledTasks?: ScheduledTaskContribution[];
|
|
386
380
|
mediaProcessors?: MediaProcessorContribution[];
|
|
387
|
-
settingsPages?: SettingsPageContribution[];
|
|
388
|
-
contentTreeActions?: ContentTreeActionContribution[];
|
|
389
|
-
editorToolbar?: EditorToolbarContribution[];
|
|
390
381
|
exposedServices?: ExposedServiceContribution[];
|
|
391
382
|
serializers?: SerializerContribution;
|
|
392
383
|
/** Document types the plugin provisions at install: the creation shape
|
|
@@ -414,10 +405,10 @@ export interface PluginContributions {
|
|
|
414
405
|
/**
|
|
415
406
|
* The contributions that put code in the browser, and so the ones that
|
|
416
407
|
* make a plugin ship a client bundle (S267 section 5, implemented by
|
|
417
|
-
* S268 Task 3). `dataTypes`, `adminSections`, `railEntries` (S280)
|
|
418
|
-
* `dashboardWidgets`
|
|
419
|
-
* `
|
|
420
|
-
*
|
|
408
|
+
* S268 Task 3). `dataTypes`, `adminSections`, `railEntries` (S280) and
|
|
409
|
+
* `dashboardWidgets` carry React views. S313b retired `settingsPages`,
|
|
410
|
+
* `contentTreeActions` and `editorToolbar`, which no admin screen hosted;
|
|
411
|
+
* the last two return when a host and an editor-handle API are designed.
|
|
421
412
|
*
|
|
422
413
|
* Everything else is absent on purpose: `apiRoutes`, `hooks`,
|
|
423
414
|
* `scheduledTasks`, `mediaProcessors` and `serializers` run on the
|
|
@@ -429,7 +420,7 @@ export interface PluginContributions {
|
|
|
429
420
|
* than that list was, not merely equivalent: a plugin listed as
|
|
430
421
|
* `section` with no views had to ship a remoteEntry.js it did not have.
|
|
431
422
|
*/
|
|
432
|
-
export
|
|
423
|
+
export { VIEW_BEARING_CONTRIBUTIONS };
|
|
433
424
|
export type ViewBearingContribution = (typeof VIEW_BEARING_CONTRIBUTIONS)[number];
|
|
434
425
|
/**
|
|
435
426
|
* Whether a manifest's declared contributions require a client bundle:
|
|
@@ -458,9 +449,39 @@ export type ViewBearingContribution = (typeof VIEW_BEARING_CONTRIBUTIONS)[number
|
|
|
458
449
|
* 'hasClientBundle'", before it can decide anything. The old name is
|
|
459
450
|
* gone rather than aliased: a name that outlives its meaning is how these
|
|
460
451
|
* get recombined later. A caller passing a string to THIS name is a
|
|
461
|
-
* compile error against the signature
|
|
452
|
+
* compile error against the signature in plugin-package.
|
|
462
453
|
*/
|
|
463
|
-
export
|
|
454
|
+
export { declaresClientBundle };
|
|
455
|
+
/** S292: what onInstall is told. */
|
|
456
|
+
export interface PluginInstallContext {
|
|
457
|
+
/** The install's answers with every default filled: what the operator
|
|
458
|
+
* chose for the sample content, the offered roles and the plugin's own
|
|
459
|
+
* `install` options (resolveInstallAnswers in @kardalum/api-schemas). */
|
|
460
|
+
answers: ResolvedInstallAnswers;
|
|
461
|
+
/** S293: the plugin's own structured storage, for a manifest declaring
|
|
462
|
+
* `storageType: 'structured'`, scoped to this plugin as a route's is and
|
|
463
|
+
* usable before it is active (onInstall runs before its row exists). A
|
|
464
|
+
* table onInstall defines is dropped again if the install fails. The handle
|
|
465
|
+
* is for the hook alone: once onInstall returns or throws it refuses while
|
|
466
|
+
* the plugin is not active, like any plugin storage, so keeping it for later
|
|
467
|
+
* gains nothing. Absent for a simple-storage plugin. */
|
|
468
|
+
structuredStorage?: ScopedStructuredStorage;
|
|
469
|
+
}
|
|
470
|
+
/** S292: what onUpdate is told. */
|
|
471
|
+
export interface PluginUpdateContext {
|
|
472
|
+
/** The version that was installed before. */
|
|
473
|
+
fromVersion: string;
|
|
474
|
+
answers: ResolvedInstallAnswers;
|
|
475
|
+
/** S293: the plugin's own structured storage, for a manifest declaring
|
|
476
|
+
* `storageType: 'structured'`, scoped to this plugin as a route's is and
|
|
477
|
+
* usable while it is not active (an update may run while the plugin is
|
|
478
|
+
* off). A table onUpdate defines is kept if the update fails: storage only
|
|
479
|
+
* grows, and an uninstall snapshots and drops it. The handle is for the
|
|
480
|
+
* hook alone: once onUpdate returns or throws it refuses while the plugin
|
|
481
|
+
* is not active, like any plugin storage, so keeping it for later gains
|
|
482
|
+
* nothing. Absent for a simple-storage plugin. */
|
|
483
|
+
structuredStorage?: ScopedStructuredStorage;
|
|
484
|
+
}
|
|
464
485
|
/** Fields shared by every plugin type. */
|
|
465
486
|
export interface PluginManifestBase {
|
|
466
487
|
/** Reverse domain, e.g. 'com.yourname.googlemaps'. */
|
|
@@ -477,7 +498,7 @@ export interface PluginManifestBase {
|
|
|
477
498
|
/**
|
|
478
499
|
* Marketplace verification hash. Optional BY DESIGN, not oversight:
|
|
479
500
|
* per the Trust model, sideloaded/local dev plugins are unsigned by
|
|
480
|
-
* definition (Tier 2 'unverified')
|
|
501
|
+
* definition (Tier 2 'unverified'): only marketplace-signed plugins
|
|
481
502
|
* carry one. Signing is authenticity, not a sandbox; the safety layer
|
|
482
503
|
* is identical for both tiers.
|
|
483
504
|
*/
|
|
@@ -488,10 +509,10 @@ export interface PluginManifestBase {
|
|
|
488
509
|
pluginDependencies?: string[];
|
|
489
510
|
databaseCompatibility: DatabaseCompatibility;
|
|
490
511
|
assertions?: PluginAssertions;
|
|
491
|
-
/** DB changes applied on install (through plugin storage
|
|
512
|
+
/** DB changes applied on install (through plugin storage, never raw
|
|
492
513
|
* SQL). */
|
|
493
514
|
migrations?: PluginMigration[];
|
|
494
|
-
onInstall?: () => void | Promise<void>;
|
|
515
|
+
onInstall?: (ctx: PluginInstallContext) => void | Promise<void>;
|
|
495
516
|
onUninstall?: () => void | Promise<void>;
|
|
496
517
|
onActivate?: () => void | Promise<void>;
|
|
497
518
|
onDeactivate?: () => void | Promise<void>;
|
|
@@ -499,39 +520,51 @@ export interface PluginManifestBase {
|
|
|
499
520
|
* the new migrations and document types and before the new actions sync.
|
|
500
521
|
* A throw rolls the update back and the old version stays installed.
|
|
501
522
|
* `onInstall` never runs on an update. */
|
|
502
|
-
onUpdate?: (ctx:
|
|
503
|
-
fromVersion: string;
|
|
504
|
-
}) => void | Promise<void>;
|
|
523
|
+
onUpdate?: (ctx: PluginUpdateContext) => void | Promise<void>;
|
|
505
524
|
migrationHooks?: PluginMigrationHooks;
|
|
506
525
|
/**
|
|
507
526
|
* The actions this plugin brings (S273). Each gated contribution above
|
|
508
527
|
* names one of these, and each of these is named by at least one, so the
|
|
509
528
|
* install screen shows exactly what installing adds to the permission
|
|
510
529
|
* surface. Ids carry this plugin's prefix and have a label, because
|
|
511
|
-
* nothing ever shows an operator a raw action string.
|
|
530
|
+
* nothing ever shows an operator a raw action string. A label is a string
|
|
531
|
+
* or a map of language code to text with `en` required (S311); the install
|
|
532
|
+
* stores the text of the site's default language.
|
|
512
533
|
*/
|
|
513
534
|
actions?: Array<{
|
|
514
535
|
id: string;
|
|
515
|
-
label:
|
|
536
|
+
label: PluginLabel;
|
|
516
537
|
}>;
|
|
517
538
|
/**
|
|
518
539
|
* Roles this plugin offers (S273). An offer is never applied unasked: the
|
|
519
540
|
* operator accepts it on the install screen or from the installed-plugins
|
|
520
541
|
* view, and the result is an ordinary editable role holding exactly these
|
|
521
|
-
* actions,
|
|
542
|
+
* actions: the plugin's own and, beside them, only the built-in read rights
|
|
543
|
+
* an offer may grant (S293, OFFERABLE_BUILT_IN_ACTIONS in
|
|
544
|
+
* @kardalum/api-schemas).
|
|
522
545
|
*/
|
|
523
546
|
roles?: Array<{
|
|
524
547
|
id: string;
|
|
525
|
-
label:
|
|
548
|
+
label: PluginLabel;
|
|
526
549
|
actions: string[];
|
|
527
550
|
}>;
|
|
528
551
|
/** S286: the plugin's docs pages, in reading order. Omit it and the
|
|
529
552
|
* README is the one page (the overview). Which roles the marketplace
|
|
530
553
|
* requires is derived from what the manifest declares, never listed
|
|
531
554
|
* here: a "setup" page when the plugin has migrations, dependencies, a
|
|
532
|
-
* price or document types
|
|
533
|
-
*
|
|
555
|
+
* price or document types. The "configuration" role stays declarable
|
|
556
|
+
* but is never required. */
|
|
534
557
|
docs?: PluginDocsPage[];
|
|
558
|
+
/** S291: the language the docs pages are written in, as a language code
|
|
559
|
+
* such as "en", "de" or "pt-BR". Absent means English. The marketplace
|
|
560
|
+
* shows it on the listing and the docs index. One language per plugin
|
|
561
|
+
* before v1: translated docs pages are not supported yet. */
|
|
562
|
+
docsLanguage?: string;
|
|
563
|
+
/** S292: what the plugin's install asks, as plain data, so a person, a
|
|
564
|
+
* script and the CLI can answer it before any of the plugin's code runs.
|
|
565
|
+
* The built-in questions (the sample content, the offered roles) are never
|
|
566
|
+
* declared here: they follow from what the package ships. */
|
|
567
|
+
install?: PluginInstallDeclaration;
|
|
535
568
|
}
|
|
536
569
|
/**
|
|
537
570
|
* The full plugin manifest. One shape for every plugin: `type` is a
|
package/dist/manifest.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolveLabel } from "@kardalum/api-schemas";
|
|
2
|
+
import { VIEW_BEARING_CONTRIBUTIONS, declaresClientBundle } from "@kardalum/plugin-package/reference";
|
|
1
3
|
/**
|
|
2
4
|
* The text of a slot's label for a locale: the locale as given, else its
|
|
3
5
|
* primary subtag (`de-AT` reads `de`), else `en`, which every label carries.
|
|
@@ -5,25 +7,15 @@
|
|
|
5
7
|
* case-insensitive and a label written `pt-BR` must answer `pt-br`.
|
|
6
8
|
*/
|
|
7
9
|
export function slotLabel(label, locale) {
|
|
8
|
-
|
|
9
|
-
const primary = wanted.split("-")[0] ?? "";
|
|
10
|
-
let primaryText;
|
|
11
|
-
for (const [code, text] of Object.entries(label)) {
|
|
12
|
-
const lower = code.toLowerCase();
|
|
13
|
-
if (lower === wanted)
|
|
14
|
-
return text;
|
|
15
|
-
if (primaryText === undefined && primary !== "" && lower === primary)
|
|
16
|
-
primaryText = text;
|
|
17
|
-
}
|
|
18
|
-
return primaryText ?? label.en;
|
|
10
|
+
return resolveLabel(label, locale);
|
|
19
11
|
}
|
|
20
12
|
/**
|
|
21
13
|
* The contributions that put code in the browser, and so the ones that
|
|
22
14
|
* make a plugin ship a client bundle (S267 section 5, implemented by
|
|
23
|
-
* S268 Task 3). `dataTypes`, `adminSections`, `railEntries` (S280)
|
|
24
|
-
* `dashboardWidgets`
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
15
|
+
* S268 Task 3). `dataTypes`, `adminSections`, `railEntries` (S280) and
|
|
16
|
+
* `dashboardWidgets` carry React views. S313b retired `settingsPages`,
|
|
17
|
+
* `contentTreeActions` and `editorToolbar`, which no admin screen hosted;
|
|
18
|
+
* the last two return when a host and an editor-handle API are designed.
|
|
27
19
|
*
|
|
28
20
|
* Everything else is absent on purpose: `apiRoutes`, `hooks`,
|
|
29
21
|
* `scheduledTasks`, `mediaProcessors` and `serializers` run on the
|
|
@@ -35,15 +27,10 @@ export function slotLabel(label, locale) {
|
|
|
35
27
|
* than that list was, not merely equivalent: a plugin listed as
|
|
36
28
|
* `section` with no views had to ship a remoteEntry.js it did not have.
|
|
37
29
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"dashboardWidgets",
|
|
43
|
-
"settingsPages",
|
|
44
|
-
"contentTreeActions",
|
|
45
|
-
"editorToolbar",
|
|
46
|
-
];
|
|
30
|
+
// S311: the list and the rule live in @kardalum/plugin-package (browser-safe,
|
|
31
|
+
// shared with the marketplace door and the CLI, imported at the top of this
|
|
32
|
+
// file); the SDK re-exports them.
|
|
33
|
+
export { VIEW_BEARING_CONTRIBUTIONS };
|
|
47
34
|
/**
|
|
48
35
|
* Whether a manifest's declared contributions require a client bundle:
|
|
49
36
|
* whether a built artifact must contain a `remoteEntry.js`, and whether
|
|
@@ -71,16 +58,6 @@ export const VIEW_BEARING_CONTRIBUTIONS = [
|
|
|
71
58
|
* 'hasClientBundle'", before it can decide anything. The old name is
|
|
72
59
|
* gone rather than aliased: a name that outlives its meaning is how these
|
|
73
60
|
* get recombined later. A caller passing a string to THIS name is a
|
|
74
|
-
* compile error against the signature
|
|
61
|
+
* compile error against the signature in plugin-package.
|
|
75
62
|
*/
|
|
76
|
-
export
|
|
77
|
-
if (contributions === null || typeof contributions !== "object")
|
|
78
|
-
return false;
|
|
79
|
-
const declared = contributions;
|
|
80
|
-
return VIEW_BEARING_CONTRIBUTIONS.some((key) => {
|
|
81
|
-
const value = declared[key];
|
|
82
|
-
if (value === null || value === undefined)
|
|
83
|
-
return false;
|
|
84
|
-
return Array.isArray(value) ? value.length > 0 : true;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
63
|
+
export { declaresClientBundle };
|
|
@@ -3,14 +3,18 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
3
3
|
import { ChevronRight, Folder as FolderIcon } from "lucide-react";
|
|
4
4
|
import { renditionShape, } from "@kardalum/api-schemas";
|
|
5
5
|
import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, } from "@kardalum/ui";
|
|
6
|
-
import { usePluginApi } from "../plugin-context.js";
|
|
6
|
+
import { MANAGE_API, usePluginApi } from "../plugin-context.js";
|
|
7
|
+
import { readAllPages } from "../read-all-pages.js";
|
|
7
8
|
import { isRenditionIneligible } from "../rendition-eligibility.js";
|
|
8
9
|
import { uploadFailureMessage } from "./upload-error.js";
|
|
9
|
-
// GET /api/media page size for the picker's grid (S197 Task 2). Additional
|
|
10
|
+
// GET /api/manage/v1/media page size for the picker's grid (S197 Task 2). Additional
|
|
10
11
|
// pages are fetched on demand via the "Load more" button below, following
|
|
11
12
|
// MediaListQuerySchema's cursor contract (media-api.schema.ts) rather than
|
|
12
13
|
// assuming a library's whole image set fits on one page.
|
|
13
14
|
const PAGE_LIMIT = 50;
|
|
15
|
+
// The folder list is paged by the server (S300b): read it to its end, 200 folders a page, at most 50 pages.
|
|
16
|
+
const FOLDER_PAGE_LIMIT = 200;
|
|
17
|
+
const FOLDER_PAGE_CAP = 50;
|
|
14
18
|
// What the picker offers when the caller names nothing. Rich text has no
|
|
15
19
|
// accepted-types setting of its own and has always shown images only, so
|
|
16
20
|
// this is that behaviour written down rather than a new default.
|
|
@@ -124,7 +128,7 @@ function folderPath(folderId, byId) {
|
|
|
124
128
|
// controlled-open pattern as IconPickerDialog
|
|
125
129
|
// (apps/admin-ui/src/icons/icon-picker-dialog.tsx).
|
|
126
130
|
//
|
|
127
|
-
// downloadUrl is resolved fresh from each GET /api/media response, never
|
|
131
|
+
// downloadUrl is resolved fresh from each GET /api/manage/v1/media response, never
|
|
128
132
|
// cached across renders: a private item's URL carries a short-lived
|
|
129
133
|
// token, so a stale one would go dead (image-view.tsx's useMediaPreview
|
|
130
134
|
// :21-24 doctrine, mirrored here for the same reason).
|
|
@@ -199,13 +203,18 @@ export function MediaPicker({ onPick, onClose, collectAlt, acceptedTypes, rendit
|
|
|
199
203
|
// banner, whichever fetch failed most recently.
|
|
200
204
|
useEffect(() => {
|
|
201
205
|
let cancelled = false;
|
|
202
|
-
fetchApi
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
readAllPages(fetchApi, `${MANAGE_API}/media/folders`, "media folders", {
|
|
207
|
+
itemKey: "folders",
|
|
208
|
+
limit: FOLDER_PAGE_LIMIT,
|
|
209
|
+
cap: FOLDER_PAGE_CAP,
|
|
210
|
+
})
|
|
211
|
+
.then(({ items, complete }) => {
|
|
212
|
+
if (cancelled)
|
|
213
|
+
return;
|
|
214
|
+
setFolders(items);
|
|
215
|
+
// A tree that was not read to its end is a subset of the folders: say so through the banner the list uses.
|
|
216
|
+
if (!complete)
|
|
217
|
+
setError(`Only the first ${FOLDER_PAGE_CAP * FOLDER_PAGE_LIMIT} media folders could be read`);
|
|
209
218
|
})
|
|
210
219
|
.catch((err) => {
|
|
211
220
|
if (!cancelled)
|
|
@@ -227,7 +236,7 @@ export function MediaPicker({ onPick, onClose, collectAlt, acceptedTypes, rendit
|
|
|
227
236
|
params.set("cursor", cursor);
|
|
228
237
|
if (rendition)
|
|
229
238
|
params.set("rendition", rendition);
|
|
230
|
-
return
|
|
239
|
+
return `${MANAGE_API}/media?${params.toString()}`;
|
|
231
240
|
}, [rendition]);
|
|
232
241
|
// A generation counter, bumped on every call. It guards against a stale
|
|
233
242
|
// response (e.g. two rapid folder switches) overwriting the newer one,
|
|
@@ -331,7 +340,7 @@ export function MediaPicker({ onPick, onClose, collectAlt, acceptedTypes, rendit
|
|
|
331
340
|
if (currentFolderId)
|
|
332
341
|
formData.append("folderId", currentFolderId);
|
|
333
342
|
formData.append("file", file);
|
|
334
|
-
const response = await fetchApi(
|
|
343
|
+
const response = await fetchApi(`${MANAGE_API}/media`, { method: "POST", body: formData });
|
|
335
344
|
// The server's own sentence, not a status code (S234d Task 8).
|
|
336
345
|
// This drawer has no size check of its own and cannot usefully have
|
|
337
346
|
// one: the ceiling belongs to the media document type the file will
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The sentence a failed `POST /api/media` should show. The server's own
|
|
2
|
+
* The sentence a failed `POST /api/manage/v1/media` should show. The server's own
|
|
3
3
|
* message when there is one (every refusal on that route answers with
|
|
4
4
|
* `ApiErrorSchema`, which is `{ message }`), and the status otherwise:
|
|
5
5
|
* a failure with nothing to say still has to say something, and the
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// a person meeting two different sentences for one refusal would have no
|
|
13
13
|
// way to tell they are the same rule.
|
|
14
14
|
/**
|
|
15
|
-
* The sentence a failed `POST /api/media` should show. The server's own
|
|
15
|
+
* The sentence a failed `POST /api/manage/v1/media` should show. The server's own
|
|
16
16
|
* message when there is one (every refusal on that route answers with
|
|
17
17
|
* `ApiErrorSchema`, which is `{ message }`), and the status otherwise:
|
|
18
18
|
* a failure with nothing to say still has to say something, and the
|