@kardalum/plugin-sdk 0.17.0 → 0.19.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 +109 -0
- package/README.md +4 -3
- 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-serializers.js +1 -1
- package/dist/built-in-settings-schemas.d.ts +2 -0
- package/dist/built-in-settings-schemas.js +31 -4
- package/dist/built-in-value-schemas.js +3 -0
- package/dist/built-ins.js +20 -11
- package/dist/capabilities.js +5 -0
- package/dist/data-type-plugin.d.ts +2 -2
- package/dist/datatype-validation.d.ts +2 -2
- package/dist/datatype-validation.js +20 -6
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +1 -0
- package/dist/define-plugin.d.ts +4 -4
- package/dist/define-plugin.js +5 -5
- 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/index.d.ts +8 -1
- package/dist/index.js +11 -12
- package/dist/manifest-entry.d.ts +4 -0
- package/dist/manifest-entry.js +4 -0
- package/dist/manifest-schema.d.ts +5 -1
- package/dist/manifest-schema.js +14 -2
- package/dist/manifest.d.ts +21 -1
- package/dist/media/media-picker.js +34 -34
- package/dist/notify.d.ts +17 -0
- package/dist/notify.js +17 -0
- package/dist/plugin-context.js +3 -3
- package/dist/register-built-ins.js +6 -6
- package/dist/registry.js +1 -1
- package/dist/richtext/block-panel.js +19 -20
- package/dist/richtext/extensions.js +17 -8
- package/dist/richtext/insert-menu.js +4 -4
- package/dist/richtext/kardalum-block.js +17 -17
- package/dist/richtext/style-listbox.js +2 -2
- package/dist/richtext/text-style-class.js +1 -1
- package/dist/richtext-html-entry.d.ts +35 -0
- package/dist/richtext-html-entry.js +73 -0
- package/dist/simple-storage-value-provider.js +3 -3
- package/dist/structured-storage-types.d.ts +12 -1
- package/dist/structured-storage-types.js +2 -2
- package/dist/tailwind.js +10 -3
- package/dist/tokens/tailwind-theme.css +176 -0
- package/dist/tokens/tokens.css +1 -0
- package/dist/tokens/tokens.json +2 -1
- package/dist/ui-entry.js +3 -3
- 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/date-range-view.js +5 -5
- package/dist/views/html-code-editor.js +2 -3
- package/dist/views/html-view.js +7 -7
- package/dist/views/image-view.js +5 -5
- package/dist/views/rich-text-view.js +33 -32
- package/node_modules/@kardalum/api-schemas/README.md +1 -1
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +17 -15
- 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 +1 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +10 -3
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +1 -1
- 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 +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +30 -9
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +12 -6
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +11 -6
- 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 +26 -6
- 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 +6 -3
- 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.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +56 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +8 -8
- 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 +48 -19
- package/node_modules/@kardalum/api-schemas/dist/index.js +34 -12
- 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/listing-categories.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/listing-categories.schema.js +52 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +162 -1
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +144 -9
- 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 +15 -9
- 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/media.schema.js +5 -5
- 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-docs-api.schema.d.ts +7 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +251 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +196 -31
- 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.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +3 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +10 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +24 -4
- 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 +23 -20
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +4 -4
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +1 -1
- 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/server-settings-api.schema.d.ts +207 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +17 -8
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +27 -12
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +6 -1
- 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 +13 -0
- package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +5 -0
- package/node_modules/@kardalum/design-tokens/README.md +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +2 -2
- 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 +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +2 -2
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +2 -2
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +3 -3
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +3 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -5
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/types.js +1 -1
- package/node_modules/@kardalum/design-tokens/package.json +6 -3
- package/node_modules/@kardalum/plugin-package/README.md +1 -1
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +54 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +18 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +58 -1
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +3 -3
- package/node_modules/@kardalum/plugin-package/dist/extract.js +10 -10
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/hash.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +3 -1
- 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/package-contract.d.ts +2 -2
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +5 -5
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +1 -1
- 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/ui/README.md +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +8 -3
- package/node_modules/@kardalum/ui/dist/components/badge.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/button.js +2 -2
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/dialog.js +52 -4
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +5 -1
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +20 -7
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +4 -4
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -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/property-field.js +3 -3
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +1 -1
- package/node_modules/@kardalum/ui/dist/components/sheet.js +15 -9
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +3 -3
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/toast.js +4 -3
- package/node_modules/@kardalum/ui/dist/components/tooltip.d.ts +27 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +82 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +94 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +2 -2
- package/node_modules/@kardalum/ui/dist/index.d.ts +4 -1
- package/node_modules/@kardalum/ui/dist/index.js +4 -1
- package/node_modules/@kardalum/ui/dist/lib/menu-host.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/lib/menu-host.js +17 -0
- package/node_modules/@kardalum/ui/package.json +8 -6
- package/package.json +21 -7
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ActionStringSchema } from "./action.schema.js";
|
|
3
|
+
import { HomeCountSchema } from "./home.schema.js";
|
|
4
|
+
import { RoleIdSchema } from "./role.schema.js";
|
|
5
|
+
import { ADMIN_LOCALES } from "./user-api.schema.js";
|
|
6
|
+
// S314n2 (2026-10-28-s314n2-user-notifications-design.md): the inbox every signed-in
|
|
7
|
+
// person has. A notification is sent once to roles, people or both; each person it
|
|
8
|
+
// reaches holds a copy of their own, read and archived alone, and every copy goes when
|
|
9
|
+
// the notification is older than the retention period.
|
|
10
|
+
export const NOTIFICATION_TITLE_MAX = 120;
|
|
11
|
+
export const NOTIFICATION_TEXT_MAX = 1000;
|
|
12
|
+
export const NOTIFICATION_URL_MAX = 500;
|
|
13
|
+
export const NOTIFICATION_ROLES_MAX = 20;
|
|
14
|
+
export const NOTIFICATION_USERS_MAX = 50;
|
|
15
|
+
/** S314n3 (D2): the most actions ("everyone who may publish") one send names. */
|
|
16
|
+
export const NOTIFICATION_ACTIONS_MAX = 10;
|
|
17
|
+
/** More people than this in one send is refused. */
|
|
18
|
+
export const NOTIFICATION_RECIPIENTS_MAX = 5000;
|
|
19
|
+
/** One page of an inbox list, newest first. */
|
|
20
|
+
export const NOTIFICATION_PAGE_SIZE = 20;
|
|
21
|
+
/** The unread count is exact up to this, and "99+" beyond it. */
|
|
22
|
+
export const NOTIFICATION_UNREAD_CAP = 99;
|
|
23
|
+
/** The bell's popover and the Home card show this many. */
|
|
24
|
+
export const NOTIFICATION_PREVIEW_ROWS = 5;
|
|
25
|
+
/** How often the bell asks for the unread count. */
|
|
26
|
+
export const NOTIFICATION_POLL_MS = 60_000;
|
|
27
|
+
/** The most roles, and the most people, the audience search answers. */
|
|
28
|
+
export const NOTIFICATION_AUDIENCE_SEARCH_MAX = 20;
|
|
29
|
+
export const NOTIFICATION_RETENTION_DEFAULT_DAYS = 90;
|
|
30
|
+
export const NOTIFICATION_RETENTION_MIN_DAYS = 7;
|
|
31
|
+
export const NOTIFICATION_RETENTION_MAX_DAYS = 3650;
|
|
32
|
+
/** `kardalumUpdate` (S314n3, D4): a newer Kardalum is out. */
|
|
33
|
+
export const NOTIFICATION_KINDS = ["message", "pluginUpdate", "kardalumUpdate"];
|
|
34
|
+
export const NotificationKindSchema = z.enum(NOTIFICATION_KINDS);
|
|
35
|
+
/** `system` is Kardalum itself; `plugin` (S314n3) a plugin that declared notifications. */
|
|
36
|
+
export const NOTIFICATION_SENDER_KINDS = ["person", "key", "system", "plugin"];
|
|
37
|
+
export const NotificationSenderKindSchema = z.enum(NOTIFICATION_SENDER_KINDS);
|
|
38
|
+
/** `all` is every copy not archived. */
|
|
39
|
+
export const NOTIFICATION_BOXES = ["unread", "all", "archived"];
|
|
40
|
+
export const NotificationBoxSchema = z.enum(NOTIFICATION_BOXES);
|
|
41
|
+
/** A linked page as the reader sees it now: `noAccess` names nothing. */
|
|
42
|
+
export const NOTIFICATION_PAGE_STATES = ["draft", "published", "removed", "noAccess"];
|
|
43
|
+
export const NotificationPageStateSchema = z.enum(NOTIFICATION_PAGE_STATES);
|
|
44
|
+
/** A system notice is written once per key, ever. */
|
|
45
|
+
export function pluginUpdateDedupeKey(pluginId, version) {
|
|
46
|
+
return `pluginUpdate:${pluginId}:${version}`;
|
|
47
|
+
}
|
|
48
|
+
/** S314n3 (D4): the Kardalum update notice is written once per version. */
|
|
49
|
+
export function kardalumUpdateDedupeKey(version) {
|
|
50
|
+
return `kardalumUpdate:${version}`;
|
|
51
|
+
}
|
|
52
|
+
/** https only, so a notification cannot carry a script or data link into every inbox. */
|
|
53
|
+
const httpsUrl = () => z
|
|
54
|
+
.url({ protocol: /^https$/, error: "A web address starts with https://." })
|
|
55
|
+
.max(NOTIFICATION_URL_MAX, `A web address has at most ${NOTIFICATION_URL_MAX} characters.`);
|
|
56
|
+
export const NotificationLinkInputSchema = z.discriminatedUnion("kind", [
|
|
57
|
+
z.object({ kind: z.literal("none") }).strict(),
|
|
58
|
+
z.object({ kind: z.literal("page"), nodeId: z.string().uuid() }).strict(),
|
|
59
|
+
z.object({ kind: z.literal("url"), url: httpsUrl() }).strict(),
|
|
60
|
+
]);
|
|
61
|
+
export const NotificationTargetsSchema = z
|
|
62
|
+
.object({
|
|
63
|
+
roles: z.array(RoleIdSchema).max(NOTIFICATION_ROLES_MAX, `A notification names at most ${NOTIFICATION_ROLES_MAX} roles.`).default([]),
|
|
64
|
+
users: z.array(z.string().uuid()).max(NOTIFICATION_USERS_MAX, `A notification names at most ${NOTIFICATION_USERS_MAX} people.`).default([]),
|
|
65
|
+
/** S314n3 (D2): every person whose role holds the action when it is sent, administrators always among them. */
|
|
66
|
+
actions: z.array(ActionStringSchema).max(NOTIFICATION_ACTIONS_MAX, `A notification names at most ${NOTIFICATION_ACTIONS_MAX} actions.`).default([]),
|
|
67
|
+
})
|
|
68
|
+
.strict()
|
|
69
|
+
.refine((to) => to.roles.length + to.users.length + to.actions.length > 0, { message: "Name at least one role, person or action." })
|
|
70
|
+
// S314c6 (D6): the reference generator takes an example before a default, and the defaults
|
|
71
|
+
// (three empty lists) are exactly what the refinement refuses.
|
|
72
|
+
.meta({ example: { roles: ["editor"], users: [], actions: [] } });
|
|
73
|
+
export const SendNotificationRequestSchema = z
|
|
74
|
+
.object({
|
|
75
|
+
to: NotificationTargetsSchema,
|
|
76
|
+
title: z
|
|
77
|
+
.string()
|
|
78
|
+
.trim()
|
|
79
|
+
.min(1, "A notification needs a title.")
|
|
80
|
+
.max(NOTIFICATION_TITLE_MAX, `A title has at most ${NOTIFICATION_TITLE_MAX} characters.`),
|
|
81
|
+
text: z.string().max(NOTIFICATION_TEXT_MAX, `A text has at most ${NOTIFICATION_TEXT_MAX} characters.`).default(""),
|
|
82
|
+
link: NotificationLinkInputSchema.default({ kind: "none" }),
|
|
83
|
+
})
|
|
84
|
+
.strict();
|
|
85
|
+
export const SendNotificationResponseSchema = z.object({
|
|
86
|
+
id: z.string().uuid(),
|
|
87
|
+
/** How many people it reached. */
|
|
88
|
+
recipients: z.number().int().min(1).max(NOTIFICATION_RECIPIENTS_MAX),
|
|
89
|
+
});
|
|
90
|
+
export const NotificationReachRequestSchema = z.object({ to: NotificationTargetsSchema }).strict();
|
|
91
|
+
export const NotificationReachResponseSchema = z.object({
|
|
92
|
+
/** Distinct people, at most NOTIFICATION_RECIPIENTS_MAX. */
|
|
93
|
+
count: z.number().int().min(0).max(NOTIFICATION_RECIPIENTS_MAX),
|
|
94
|
+
/** More people than a send may reach: the send would be refused. */
|
|
95
|
+
overLimit: z.boolean(),
|
|
96
|
+
/** The signed-in sender is among them; always false for an API key. */
|
|
97
|
+
includesYou: z.boolean(),
|
|
98
|
+
});
|
|
99
|
+
export const NotificationAudienceQuerySchema = z.object({
|
|
100
|
+
q: z.string().trim().max(100).optional(),
|
|
101
|
+
/** S314n3 (3e): the caller's admin language, in which a nameless person's label is worded. */
|
|
102
|
+
lang: z.enum(ADMIN_LOCALES).default("en"),
|
|
103
|
+
});
|
|
104
|
+
const AudienceOptionSchema = z.object({ id: z.string(), label: z.string() });
|
|
105
|
+
export const NotificationAudienceResponseSchema = z.object({
|
|
106
|
+
roles: z.array(AudienceOptionSchema).max(NOTIFICATION_AUDIENCE_SEARCH_MAX),
|
|
107
|
+
/** A person's label is their name, or "Unnamed person (role)" when they have none; never their email. */
|
|
108
|
+
users: z.array(AudienceOptionSchema).max(NOTIFICATION_AUDIENCE_SEARCH_MAX),
|
|
109
|
+
});
|
|
110
|
+
/** The targets as they were named at send time, for "to Publishers". */
|
|
111
|
+
export const NotificationAudienceEntrySchema = z.discriminatedUnion("kind", [
|
|
112
|
+
z.object({ kind: z.literal("role"), id: z.string(), label: z.string() }),
|
|
113
|
+
/** S314n3 (3e): `name` is null for a person with no name, who is shown by their role, worded by the reader's admin. */
|
|
114
|
+
z.object({
|
|
115
|
+
kind: z.literal("user"),
|
|
116
|
+
id: z.string(),
|
|
117
|
+
name: z.string().nullable(),
|
|
118
|
+
role: z.object({ id: z.string(), label: z.string() }).optional(),
|
|
119
|
+
}),
|
|
120
|
+
/** S314n3 (D2): "people who may <label>"; the label as the action had it when sent. */
|
|
121
|
+
z.object({ kind: z.literal("action"), action: z.string(), label: z.string() }),
|
|
122
|
+
]);
|
|
123
|
+
export const NotificationAudienceSchema = z
|
|
124
|
+
.array(NotificationAudienceEntrySchema)
|
|
125
|
+
.max(NOTIFICATION_ROLES_MAX + NOTIFICATION_USERS_MAX + NOTIFICATION_ACTIONS_MAX);
|
|
126
|
+
export const NotificationPageSummarySchema = z.object({
|
|
127
|
+
state: NotificationPageStateSchema,
|
|
128
|
+
/** Null for `noAccess`, and for a page whose row is gone. */
|
|
129
|
+
name: z.string().nullable(),
|
|
130
|
+
path: z.string().nullable(),
|
|
131
|
+
});
|
|
132
|
+
export const NotificationLinkSchema = z.discriminatedUnion("kind", [
|
|
133
|
+
z.object({ kind: z.literal("none") }),
|
|
134
|
+
z.object({ kind: z.literal("page"), nodeId: z.string().uuid(), page: NotificationPageSummarySchema }),
|
|
135
|
+
z.object({ kind: z.literal("url"), url: z.string() }),
|
|
136
|
+
]);
|
|
137
|
+
/** `name` is null for a person with no name (S314n3, 3e); the admin says "Unnamed person". */
|
|
138
|
+
export const NotificationSenderSchema = z.object({ kind: NotificationSenderKindSchema, name: z.string().nullable() });
|
|
139
|
+
/** What a plugin update notice is about, so the admin can word it in the reader's language. */
|
|
140
|
+
export const NotificationPluginUpdateDataSchema = z.object({
|
|
141
|
+
pluginId: z.string(),
|
|
142
|
+
pluginName: z.string(),
|
|
143
|
+
installedVersion: z.string(),
|
|
144
|
+
version: z.string(),
|
|
145
|
+
});
|
|
146
|
+
/** S314n3 (D4): what a Kardalum update notice is about. */
|
|
147
|
+
export const NotificationKardalumUpdateDataSchema = z.object({
|
|
148
|
+
installedVersion: z.string(),
|
|
149
|
+
version: z.string(),
|
|
150
|
+
});
|
|
151
|
+
/** The facts of a system notice, by its kind; null for a message. */
|
|
152
|
+
export const NotificationDataSchema = z.union([NotificationPluginUpdateDataSchema, NotificationKardalumUpdateDataSchema]);
|
|
153
|
+
/** One person's copy of a notification. */
|
|
154
|
+
export const NotificationItemSchema = z.object({
|
|
155
|
+
id: z.string().uuid(),
|
|
156
|
+
kind: NotificationKindSchema,
|
|
157
|
+
title: z.string(),
|
|
158
|
+
text: z.string(),
|
|
159
|
+
link: NotificationLinkSchema,
|
|
160
|
+
sender: NotificationSenderSchema,
|
|
161
|
+
audience: NotificationAudienceSchema,
|
|
162
|
+
/** A system notice's facts (a plugin update's or a Kardalum update's); null for a message. `title` and `text` are its English form, for API readers. */
|
|
163
|
+
data: NotificationDataSchema.nullable(),
|
|
164
|
+
createdAt: z.string().datetime(),
|
|
165
|
+
readAt: z.string().datetime().nullable(),
|
|
166
|
+
archivedAt: z.string().datetime().nullable(),
|
|
167
|
+
});
|
|
168
|
+
export const NotificationInboxQuerySchema = z.object({
|
|
169
|
+
box: NotificationBoxSchema.default("all"),
|
|
170
|
+
/** The previous page's nextCursor, passed back as it came. */
|
|
171
|
+
cursor: z.string().max(200).optional(),
|
|
172
|
+
limit: z.coerce.number().int().min(1).max(NOTIFICATION_PAGE_SIZE).default(NOTIFICATION_PAGE_SIZE),
|
|
173
|
+
});
|
|
174
|
+
export const NotificationInboxPageSchema = z.object({
|
|
175
|
+
items: z.array(NotificationItemSchema).max(NOTIFICATION_PAGE_SIZE),
|
|
176
|
+
nextCursor: z.string().nullable(),
|
|
177
|
+
/** How many days a notification is kept, so every person can be told. */
|
|
178
|
+
retentionDays: z.number().int(),
|
|
179
|
+
});
|
|
180
|
+
/** `{ count, more }`: exact up to 99; `more` when there are more than 99. */
|
|
181
|
+
export const NotificationUnreadCountSchema = HomeCountSchema;
|
|
182
|
+
export const NotificationParamsSchema = z.object({ id: z.string().uuid() });
|
|
183
|
+
export const NotificationStateSchema = z.object({
|
|
184
|
+
id: z.string().uuid(),
|
|
185
|
+
readAt: z.string().datetime().nullable(),
|
|
186
|
+
archivedAt: z.string().datetime().nullable(),
|
|
187
|
+
});
|
|
188
|
+
export const NotificationReadAllResponseSchema = z.object({ marked: z.number().int().min(0) });
|
|
189
|
+
export const NotificationRetentionSchema = z
|
|
190
|
+
.object({
|
|
191
|
+
retentionDays: z.number().int().min(NOTIFICATION_RETENTION_MIN_DAYS).max(NOTIFICATION_RETENTION_MAX_DAYS),
|
|
192
|
+
})
|
|
193
|
+
.strict();
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const PLAN_KEY_MAX = 64;
|
|
3
|
+
export declare const PLAN_NAME_MAX = 200;
|
|
4
|
+
export declare const PLAN_DESCRIPTION_MAX = 2000;
|
|
5
|
+
/** $1 floor (Stripe's charge minimum with margin) and a $10,000 sanity cap. */
|
|
6
|
+
export declare const PLAN_MIN_PRICE_CENTS = 100;
|
|
7
|
+
export declare const PLAN_MAX_PRICE_CENTS = 1000000;
|
|
8
|
+
export declare const PLAN_SHAPE_VALUES: readonly ["free", "one_time", "monthly", "yearly"];
|
|
9
|
+
export type PlanShapeValue = (typeof PLAN_SHAPE_VALUES)[number];
|
|
10
|
+
/**
|
|
11
|
+
* A plan key: 1 to 64 characters, lowercase ASCII letters, digits and single
|
|
12
|
+
* hyphens, starting with a letter and ending with a letter or digit. A linear
|
|
13
|
+
* scan with the length checked first, never a regex (untrusted text).
|
|
14
|
+
*/
|
|
15
|
+
export declare function isPlanKey(value: string): boolean;
|
|
16
|
+
/** S315 section 3a: a free plan costs 0, every other shape whole cents from $1 to $10,000. */
|
|
17
|
+
export declare function planPriceAgrees(shape: string, priceCents: number): boolean;
|
|
18
|
+
export declare const PlanKeySchema: z.ZodString;
|
|
19
|
+
export declare const PlanNameSchema: z.ZodString;
|
|
20
|
+
export declare const PlanDescriptionSchema: z.ZodString;
|
|
21
|
+
export declare const PlanShapeSchema: z.ZodEnum<{
|
|
22
|
+
free: "free";
|
|
23
|
+
one_time: "one_time";
|
|
24
|
+
monthly: "monthly";
|
|
25
|
+
yearly: "yearly";
|
|
26
|
+
}>;
|
|
27
|
+
export declare const PlanAddInputSchema: z.ZodObject<{
|
|
28
|
+
listingId: z.ZodString;
|
|
29
|
+
key: z.ZodString;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
description: z.ZodString;
|
|
32
|
+
shape: z.ZodEnum<{
|
|
33
|
+
free: "free";
|
|
34
|
+
one_time: "one_time";
|
|
35
|
+
monthly: "monthly";
|
|
36
|
+
yearly: "yearly";
|
|
37
|
+
}>;
|
|
38
|
+
priceCents: z.ZodNumber;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export type PlanAddInput = z.infer<typeof PlanAddInputSchema>;
|
|
41
|
+
/** Name and description always; key, shape and price only while the plan was never held (D4, S315 D8). */
|
|
42
|
+
export declare const PlanEditInputSchema: z.ZodObject<{
|
|
43
|
+
planId: z.ZodString;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
description: z.ZodString;
|
|
46
|
+
key: z.ZodOptional<z.ZodString>;
|
|
47
|
+
shape: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
free: "free";
|
|
49
|
+
one_time: "one_time";
|
|
50
|
+
monthly: "monthly";
|
|
51
|
+
yearly: "yearly";
|
|
52
|
+
}>>;
|
|
53
|
+
priceCents: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export type PlanEditInput = z.infer<typeof PlanEditInputSchema>;
|
|
56
|
+
export declare const PlanRefInputSchema: z.ZodObject<{
|
|
57
|
+
planId: z.ZodString;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
export type PlanRefInput = z.infer<typeof PlanRefInputSchema>;
|
|
60
|
+
export declare const PlanMoveInputSchema: z.ZodObject<{
|
|
61
|
+
planId: z.ZodString;
|
|
62
|
+
direction: z.ZodEnum<{
|
|
63
|
+
up: "up";
|
|
64
|
+
down: "down";
|
|
65
|
+
}>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
export type PlanMoveInput = z.infer<typeof PlanMoveInputSchema>;
|
|
68
|
+
export declare const PlanPriceInputSchema: z.ZodObject<{
|
|
69
|
+
planId: z.ZodString;
|
|
70
|
+
priceCents: z.ZodNumber;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export type PlanPriceInput = z.infer<typeof PlanPriceInputSchema>;
|
|
73
|
+
/** S321c (spec 3c): a price change's background notices as the plans page
|
|
74
|
+
* reads them. While the sweep runs, `waiting` counts the subscribers not
|
|
75
|
+
* reached yet and those whose email has not gone out; after the walk, only
|
|
76
|
+
* the latter. `walking` while the walk has subscribers left to reach (the
|
|
77
|
+
* page reads its progress again only then); `finished` once every subscriber
|
|
78
|
+
* was told. */
|
|
79
|
+
export declare const PriceSweepProgressSchema: z.ZodObject<{
|
|
80
|
+
total: z.ZodNumber;
|
|
81
|
+
told: z.ZodNumber;
|
|
82
|
+
waiting: z.ZodNumber;
|
|
83
|
+
walking: z.ZodBoolean;
|
|
84
|
+
finished: z.ZodBoolean;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
export type PriceSweepProgress = z.infer<typeof PriceSweepProgressSchema>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// S321 (spec 3b, D4; S315 section 3a): what the author's plans editor sends.
|
|
3
|
+
// The plan key is what a plugin reads as planId (S317) and what the vendor
|
|
4
|
+
// token carries (S320), so its caps live here and vendor-service.schema.ts
|
|
5
|
+
// reads them: a longer key or name could never be signed.
|
|
6
|
+
export const PLAN_KEY_MAX = 64;
|
|
7
|
+
export const PLAN_NAME_MAX = 200;
|
|
8
|
+
export const PLAN_DESCRIPTION_MAX = 2000;
|
|
9
|
+
/** $1 floor (Stripe's charge minimum with margin) and a $10,000 sanity cap. */
|
|
10
|
+
export const PLAN_MIN_PRICE_CENTS = 100;
|
|
11
|
+
export const PLAN_MAX_PRICE_CENTS = 1_000_000;
|
|
12
|
+
export const PLAN_SHAPE_VALUES = ["free", "one_time", "monthly", "yearly"];
|
|
13
|
+
/**
|
|
14
|
+
* A plan key: 1 to 64 characters, lowercase ASCII letters, digits and single
|
|
15
|
+
* hyphens, starting with a letter and ending with a letter or digit. A linear
|
|
16
|
+
* scan with the length checked first, never a regex (untrusted text).
|
|
17
|
+
*/
|
|
18
|
+
export function isPlanKey(value) {
|
|
19
|
+
if (value.length < 1 || value.length > PLAN_KEY_MAX)
|
|
20
|
+
return false;
|
|
21
|
+
for (let i = 0; i < value.length; i++) {
|
|
22
|
+
const c = value.charCodeAt(i);
|
|
23
|
+
const lower = c >= 97 && c <= 122;
|
|
24
|
+
const digit = c >= 48 && c <= 57;
|
|
25
|
+
const hyphen = c === 45;
|
|
26
|
+
if (i === 0 && !lower)
|
|
27
|
+
return false;
|
|
28
|
+
if (!lower && !digit && !hyphen)
|
|
29
|
+
return false;
|
|
30
|
+
if (hyphen && (i === value.length - 1 || value.charCodeAt(i + 1) === 45))
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
/** S315 section 3a: a free plan costs 0, every other shape whole cents from $1 to $10,000. */
|
|
36
|
+
export function planPriceAgrees(shape, priceCents) {
|
|
37
|
+
if (!Number.isInteger(priceCents))
|
|
38
|
+
return false;
|
|
39
|
+
if (shape === "free")
|
|
40
|
+
return priceCents === 0;
|
|
41
|
+
return priceCents >= PLAN_MIN_PRICE_CENTS && priceCents <= PLAN_MAX_PRICE_CENTS;
|
|
42
|
+
}
|
|
43
|
+
const PRICE_SHAPE_MESSAGE = "A free plan costs 0; any other plan costs from $1.00 to $10,000.00";
|
|
44
|
+
// A listing or plan id is never validated beyond its length: a wrong one
|
|
45
|
+
// reads as "not found" from the owner-scoped query, like someone else's.
|
|
46
|
+
const RowIdSchema = z.string().min(1).max(64);
|
|
47
|
+
export const PlanKeySchema = z
|
|
48
|
+
.string()
|
|
49
|
+
.max(PLAN_KEY_MAX, `A plan key is at most ${PLAN_KEY_MAX} characters`)
|
|
50
|
+
.refine(isPlanKey, "A plan key uses lowercase letters, digits and single hyphens, starts with a letter and ends with a letter or digit");
|
|
51
|
+
export const PlanNameSchema = z.string().trim().min(1, "Give the plan a name").max(PLAN_NAME_MAX, `A plan name is at most ${PLAN_NAME_MAX} characters`);
|
|
52
|
+
export const PlanDescriptionSchema = z.string().trim().max(PLAN_DESCRIPTION_MAX, `A plan description is at most ${PLAN_DESCRIPTION_MAX} characters`);
|
|
53
|
+
export const PlanShapeSchema = z.enum(PLAN_SHAPE_VALUES, "Choose free, one-time, monthly or yearly");
|
|
54
|
+
const PlanCentsSchema = z.number().int().min(0).max(PLAN_MAX_PRICE_CENTS, "Maximum price is $10,000.00");
|
|
55
|
+
export const PlanAddInputSchema = z
|
|
56
|
+
.object({ listingId: RowIdSchema, key: PlanKeySchema, name: PlanNameSchema, description: PlanDescriptionSchema, shape: PlanShapeSchema, priceCents: PlanCentsSchema })
|
|
57
|
+
.strict()
|
|
58
|
+
.refine((input) => planPriceAgrees(input.shape, input.priceCents), { message: PRICE_SHAPE_MESSAGE, path: ["priceCents"] });
|
|
59
|
+
/** Name and description always; key, shape and price only while the plan was never held (D4, S315 D8). */
|
|
60
|
+
export const PlanEditInputSchema = z
|
|
61
|
+
.object({
|
|
62
|
+
planId: RowIdSchema,
|
|
63
|
+
name: PlanNameSchema,
|
|
64
|
+
description: PlanDescriptionSchema,
|
|
65
|
+
key: PlanKeySchema.optional(),
|
|
66
|
+
shape: PlanShapeSchema.optional(),
|
|
67
|
+
priceCents: PlanCentsSchema.optional(),
|
|
68
|
+
})
|
|
69
|
+
.strict();
|
|
70
|
+
export const PlanRefInputSchema = z.object({ planId: RowIdSchema }).strict();
|
|
71
|
+
export const PlanMoveInputSchema = z.object({ planId: RowIdSchema, direction: z.enum(["up", "down"]) }).strict();
|
|
72
|
+
export const PlanPriceInputSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
planId: RowIdSchema,
|
|
75
|
+
priceCents: z.number().int().min(PLAN_MIN_PRICE_CENTS, "A paid plan costs at least $1.00").max(PLAN_MAX_PRICE_CENTS, "Maximum price is $10,000.00"),
|
|
76
|
+
})
|
|
77
|
+
.strict();
|
|
78
|
+
/** S321c (spec 3c): a price change's background notices as the plans page
|
|
79
|
+
* reads them. While the sweep runs, `waiting` counts the subscribers not
|
|
80
|
+
* reached yet and those whose email has not gone out; after the walk, only
|
|
81
|
+
* the latter. `walking` while the walk has subscribers left to reach (the
|
|
82
|
+
* page reads its progress again only then); `finished` once every subscriber
|
|
83
|
+
* was told. */
|
|
84
|
+
export const PriceSweepProgressSchema = z
|
|
85
|
+
.object({
|
|
86
|
+
total: z.number().int().nonnegative(),
|
|
87
|
+
told: z.number().int().nonnegative(),
|
|
88
|
+
waiting: z.number().int().nonnegative(),
|
|
89
|
+
walking: z.boolean(),
|
|
90
|
+
finished: z.boolean(),
|
|
91
|
+
})
|
|
92
|
+
.strict();
|
|
@@ -63,6 +63,11 @@ export declare const PluginDocsPluginParamsSchema: z.ZodObject<{
|
|
|
63
63
|
pluginId: z.ZodString;
|
|
64
64
|
}, z.core.$strip>;
|
|
65
65
|
export type PluginDocsPluginParams = z.infer<typeof PluginDocsPluginParamsSchema>;
|
|
66
|
+
export declare const PluginDocsImageParamsSchema: z.ZodObject<{
|
|
67
|
+
pluginId: z.ZodString;
|
|
68
|
+
"*": z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type PluginDocsImageParams = z.infer<typeof PluginDocsImageParamsSchema>;
|
|
66
71
|
export declare const PluginDocsPageResponseSchema: z.ZodObject<{
|
|
67
72
|
pluginId: z.ZodString;
|
|
68
73
|
version: z.ZodString;
|
|
@@ -80,8 +85,8 @@ export declare const PluginDocsPageResponseSchema: z.ZodObject<{
|
|
|
80
85
|
}, z.core.$strip>;
|
|
81
86
|
export type PluginDocsPageResponse = z.infer<typeof PluginDocsPageResponseSchema>;
|
|
82
87
|
export declare const PluginReferenceSourceSchema: z.ZodEnum<{
|
|
83
|
-
package: "package";
|
|
84
88
|
live: "live";
|
|
89
|
+
package: "package";
|
|
85
90
|
}>;
|
|
86
91
|
export type PluginReferenceSource = z.infer<typeof PluginReferenceSourceSchema>;
|
|
87
92
|
/** S289: "live" is built from the manifest the server has attached; "package"
|
|
@@ -90,8 +95,8 @@ export declare const PluginDocsReferenceResponseSchema: z.ZodObject<{
|
|
|
90
95
|
pluginId: z.ZodString;
|
|
91
96
|
version: z.ZodString;
|
|
92
97
|
source: z.ZodEnum<{
|
|
93
|
-
package: "package";
|
|
94
98
|
live: "live";
|
|
99
|
+
package: "package";
|
|
95
100
|
}>;
|
|
96
101
|
reference: z.ZodObject<{
|
|
97
102
|
actions: z.ZodArray<z.ZodObject<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { PLUGIN_DOC_ROLES, PluginReferenceSchema } from "./plugin-docs.js";
|
|
3
|
+
import { MAX_DOCS_TARGET_LENGTH } from "./plugin-docs-text.js";
|
|
3
4
|
// S287. The shapes of the four JSON routes the server serves to the admin:
|
|
4
5
|
// the docs index, one page, the reference tables and the search index.
|
|
5
6
|
export const PluginDocsPageRefSchema = z.object({
|
|
@@ -26,6 +27,12 @@ export const PluginDocsPageParamsSchema = z.object({
|
|
|
26
27
|
export const PluginDocsPluginParamsSchema = z.object({
|
|
27
28
|
pluginId: z.string().min(1),
|
|
28
29
|
});
|
|
30
|
+
// S314c3 (D2): GET /plugin-docs/:pluginId/images/*, an image of the stored package by its package
|
|
31
|
+
// path (the `*` param, as Fastify names a wildcard).
|
|
32
|
+
export const PluginDocsImageParamsSchema = z.object({
|
|
33
|
+
pluginId: z.string().min(1),
|
|
34
|
+
"*": z.string().min(1).max(MAX_DOCS_TARGET_LENGTH),
|
|
35
|
+
});
|
|
29
36
|
export const PluginDocsPageResponseSchema = z.object({
|
|
30
37
|
pluginId: z.string(),
|
|
31
38
|
version: z.string(),
|
|
@@ -34,6 +34,7 @@ const HOSTILE_CHARS_PATTERN = new RegExp("[\u0000-\u001f\u007f\u200b-\u200f\u202
|
|
|
34
34
|
export function hasHostileChars(text) {
|
|
35
35
|
return HOSTILE_CHARS_PATTERN.test(text);
|
|
36
36
|
}
|
|
37
|
+
// The URL global is declared once for the package, in whatwg-url.d.ts.
|
|
37
38
|
const HAS_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
|
|
38
39
|
const RENDERABLE_SCHEMES = new Set(["http:", "https:", "mailto:"]);
|
|
39
40
|
/** Whether an absolute link target is one the renderers draw as a link:
|