@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { TrashCursorSchema } from "./trash-cursor.schema.js";
|
|
3
|
+
import { TemplateAliasSchema, TemplateDefinitionSchema, TemplateKindSchema, TemplateVersionMetaSchema, TemplateVersionSchema, TrashedTemplateSchema, } from "./template.schema.js";
|
|
3
4
|
// One template source file is capped at 1MB — kin of the render budget:
|
|
4
5
|
// a template is code a human edits, not a data blob.
|
|
5
6
|
export const MAX_TEMPLATE_CONTENT_BYTES = 1_048_576;
|
|
@@ -32,7 +33,7 @@ export const TemplateConflictResponseSchema = z.object({
|
|
|
32
33
|
message: z.string(),
|
|
33
34
|
currentVersion: z.number().int().min(1),
|
|
34
35
|
});
|
|
35
|
-
// DELETE /api/templates/:id two-step confirm gate, same shape as content
|
|
36
|
+
// DELETE /api/manage/v1/templates/:id two-step confirm gate, same shape as content
|
|
36
37
|
// trash / plugin uninstall: 409 names the blast radius, then a literal
|
|
37
38
|
// "true" query string confirm re-issues the delete.
|
|
38
39
|
export const TemplateDeleteBlockedResponseSchema = z.object({
|
|
@@ -46,7 +47,7 @@ export const TemplateResponseSchema = z.object({
|
|
|
46
47
|
template: TemplateDefinitionSchema,
|
|
47
48
|
content: z.string(),
|
|
48
49
|
});
|
|
49
|
-
// Same shape under the historical name
|
|
50
|
+
// Same shape under the historical name: POST /api/manage/v1/templates responds 201
|
|
50
51
|
// with it and the admin UI imports this name today.
|
|
51
52
|
export const CreateTemplateResponseSchema = TemplateResponseSchema;
|
|
52
53
|
// Per api-design.md, list endpoints are always cursor-paginated. The
|
|
@@ -57,18 +58,57 @@ export const TemplateListQuerySchema = z.object({
|
|
|
57
58
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
58
59
|
documentTypeId: z.string().uuid().optional(),
|
|
59
60
|
});
|
|
61
|
+
// S314g (P6): a list row names the plugin that ships the template (from the
|
|
62
|
+
// plugin tracking table, read by the route), or null for the operator's own.
|
|
63
|
+
// A route-level field: TemplateDefinitionSchema, and every adapter row mapper
|
|
64
|
+
// behind it, stay as they are.
|
|
65
|
+
export const TemplateListItemSchema = TemplateDefinitionSchema.extend({ ownedBy: z.string().min(1).nullable() });
|
|
60
66
|
export const TemplateListResponseSchema = z.object({
|
|
61
|
-
items: z.array(
|
|
67
|
+
items: z.array(TemplateListItemSchema),
|
|
62
68
|
nextCursor: z.string().uuid().nullable(),
|
|
63
69
|
});
|
|
64
|
-
// Body for PATCH /api/document-types/:id/default-template.
|
|
70
|
+
// Body for PATCH /api/manage/v1/document-types/:id/default-template.
|
|
65
71
|
export const SetDefaultTemplateRequestSchema = z.object({
|
|
66
72
|
templateId: z.string().uuid().nullable(),
|
|
67
73
|
});
|
|
68
|
-
// POST /api/templates/sync
|
|
74
|
+
// POST /api/manage/v1/templates/sync: the "Sync files" action's report.
|
|
75
|
+
// S314j (D3, D4, D7): `adopted` lists the .liquid files no template owned that
|
|
76
|
+
// became templates (the file as found, the alias it took, the kind its top
|
|
77
|
+
// folder gave it); `skipped` lists every file the walk did not adopt, with
|
|
78
|
+
// why (an alias taken, a name that cannot be an alias, over 1 MiB, too deep,
|
|
79
|
+
// an .html file, the folder's entry cap).
|
|
69
80
|
export const TemplateSyncReportSchema = z.object({
|
|
70
81
|
checked: z.number().int().min(0),
|
|
71
82
|
updated: z.array(z.object({ id: z.string().uuid(), alias: z.string(), version: z.number().int() })),
|
|
72
83
|
healed: z.array(z.string()),
|
|
73
|
-
|
|
84
|
+
adopted: z.array(z.object({ id: z.string().uuid(), file: z.string(), alias: z.string(), kind: TemplateKindSchema })),
|
|
85
|
+
skipped: z.array(z.object({ file: z.string(), reason: z.string() })),
|
|
74
86
|
});
|
|
87
|
+
// S314g (D5, P3): a template's history. The list is metadata, newest first, a
|
|
88
|
+
// page at a time; its query is content's VersionListQuerySchema (cursor = the
|
|
89
|
+
// last version number of the previous page, limit 1..100, default 20) and its
|
|
90
|
+
// nextCursor is null once version 1 was returned.
|
|
91
|
+
export const TemplateVersionParamsSchema = z.object({
|
|
92
|
+
id: z.string().uuid(),
|
|
93
|
+
version: z.coerce.number().int().positive(),
|
|
94
|
+
});
|
|
95
|
+
export const TemplateVersionListResponseSchema = z.object({
|
|
96
|
+
items: z.array(TemplateVersionMetaSchema),
|
|
97
|
+
nextCursor: z.number().int().positive().nullable(),
|
|
98
|
+
});
|
|
99
|
+
// One version with its text, as content's version read answers `{ version }`.
|
|
100
|
+
export const TemplateVersionResponseSchema = z.object({ version: TemplateVersionSchema });
|
|
101
|
+
// The templates trash, newest first; the cursor is `${deletedAt}|${id}`.
|
|
102
|
+
export const TemplateTrashListQuerySchema = z.object({
|
|
103
|
+
cursor: TrashCursorSchema.optional(),
|
|
104
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
105
|
+
});
|
|
106
|
+
export const TemplateTrashListResponseSchema = z.object({
|
|
107
|
+
items: z.array(TrashedTemplateSchema),
|
|
108
|
+
nextCursor: z.string().nullable(),
|
|
109
|
+
});
|
|
110
|
+
// POST /templates/:id/restore. `foldedFile` is true when a file found at the
|
|
111
|
+
// template's alias held other text than the restored version: that text was
|
|
112
|
+
// kept as a file-sync version after the newest before the file was written
|
|
113
|
+
// back from the restored one (S314g fix wave).
|
|
114
|
+
export const RestoreTemplateResponseSchema = TemplateResponseSchema.extend({ foldedFile: z.boolean() });
|
|
@@ -5,6 +5,7 @@ export declare const TemplateKindSchema: z.ZodEnum<{
|
|
|
5
5
|
partial: "partial";
|
|
6
6
|
}>;
|
|
7
7
|
export type TemplateKind = z.infer<typeof TemplateKindSchema>;
|
|
8
|
+
export declare const TEMPLATE_ALIAS_MAX_SEGMENTS = 8;
|
|
8
9
|
export declare const TemplateAliasSchema: z.ZodString;
|
|
9
10
|
export declare const TemplateDefinitionSchema: z.ZodObject<{
|
|
10
11
|
id: z.ZodString;
|
|
@@ -20,8 +21,8 @@ export declare const TemplateDefinitionSchema: z.ZodObject<{
|
|
|
20
21
|
}, z.core.$strict>;
|
|
21
22
|
export type TemplateDefinition = z.infer<typeof TemplateDefinitionSchema>;
|
|
22
23
|
export declare const TemplateVersionSourceSchema: z.ZodEnum<{
|
|
23
|
-
"plugin-install": "plugin-install";
|
|
24
24
|
admin: "admin";
|
|
25
|
+
"plugin-install": "plugin-install";
|
|
25
26
|
"file-sync": "file-sync";
|
|
26
27
|
}>;
|
|
27
28
|
export type TemplateVersionSource = z.infer<typeof TemplateVersionSourceSchema>;
|
|
@@ -32,10 +33,37 @@ export declare const TemplateVersionSchema: z.ZodObject<{
|
|
|
32
33
|
content: z.ZodString;
|
|
33
34
|
hash: z.ZodString;
|
|
34
35
|
source: z.ZodEnum<{
|
|
35
|
-
"plugin-install": "plugin-install";
|
|
36
36
|
admin: "admin";
|
|
37
|
+
"plugin-install": "plugin-install";
|
|
37
38
|
"file-sync": "file-sync";
|
|
38
39
|
}>;
|
|
39
40
|
createdAt: z.ZodString;
|
|
40
41
|
}, z.core.$strict>;
|
|
41
42
|
export type TemplateVersion = z.infer<typeof TemplateVersionSchema>;
|
|
43
|
+
export declare const TemplateVersionMetaSchema: z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
createdAt: z.ZodString;
|
|
46
|
+
source: z.ZodEnum<{
|
|
47
|
+
admin: "admin";
|
|
48
|
+
"plugin-install": "plugin-install";
|
|
49
|
+
"file-sync": "file-sync";
|
|
50
|
+
}>;
|
|
51
|
+
templateId: z.ZodString;
|
|
52
|
+
version: z.ZodNumber;
|
|
53
|
+
hash: z.ZodString;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export type TemplateVersionMeta = z.infer<typeof TemplateVersionMetaSchema>;
|
|
56
|
+
export declare const TrashedTemplateSchema: z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
alias: z.ZodString;
|
|
60
|
+
kind: z.ZodEnum<{
|
|
61
|
+
page: "page";
|
|
62
|
+
layout: "layout";
|
|
63
|
+
partial: "partial";
|
|
64
|
+
}>;
|
|
65
|
+
documentTypeId: z.ZodNullable<z.ZodString>;
|
|
66
|
+
currentVersion: z.ZodNumber;
|
|
67
|
+
deletedAt: z.ZodString;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
export type TrashedTemplate = z.infer<typeof TrashedTemplateSchema>;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { TEMPLATE_KINDS } from "./plugin-vocabulary.js";
|
|
2
3
|
// A template's persisted identity. Content does NOT live here: the source
|
|
3
4
|
// of a template is its file (`templates/<alias>.liquid`) mirrored into
|
|
4
5
|
// immutable template_versions rows — see the S192 spec §5. currentVersion
|
|
5
6
|
// is a pointer, exactly like content_nodes.current_version.
|
|
6
|
-
export const TemplateKindSchema = z.enum(
|
|
7
|
+
export const TemplateKindSchema = z.enum(TEMPLATE_KINDS);
|
|
7
8
|
// The alias is the cross-reference key ({% layout 'x' %} / {% render 'x' %})
|
|
8
|
-
// AND the file
|
|
9
|
-
//
|
|
10
|
-
//
|
|
9
|
+
// AND the file's path under templates/ (<alias>.liquid). S314j (D6, P3): it
|
|
10
|
+
// may name folders, "pages/about": segments of lowercase kebab joined by "/",
|
|
11
|
+
// at most TEMPLATE_ALIAS_MAX_SEGMENTS of them, 120 characters in all. No
|
|
12
|
+
// dots, no empty segment, no leading or trailing "/", so an alias can never
|
|
13
|
+
// traverse paths or collide case-insensitively on Windows filesystems; the
|
|
14
|
+
// template service still asserts the joined path stays inside its folder.
|
|
15
|
+
// Plugin manifests keep flat aliases (PluginTemplateAliasSchema).
|
|
16
|
+
export const TEMPLATE_ALIAS_MAX_SEGMENTS = 8;
|
|
17
|
+
const ALIAS_SEGMENT = "[a-z0-9]+(?:-[a-z0-9]+)*";
|
|
18
|
+
const TEMPLATE_ALIAS_REGEX = new RegExp(`^${ALIAS_SEGMENT}(?:/${ALIAS_SEGMENT}){0,${TEMPLATE_ALIAS_MAX_SEGMENTS - 1}}$`);
|
|
11
19
|
export const TemplateAliasSchema = z
|
|
12
20
|
.string()
|
|
13
21
|
.min(1)
|
|
14
22
|
.max(120)
|
|
15
|
-
.regex(
|
|
23
|
+
.regex(TEMPLATE_ALIAS_REGEX, "lowercase kebab-case segments joined by /, at most 8");
|
|
16
24
|
export const TemplateDefinitionSchema = z
|
|
17
25
|
.object({
|
|
18
26
|
id: z.string().uuid(),
|
|
@@ -37,3 +45,9 @@ export const TemplateVersionSchema = z
|
|
|
37
45
|
createdAt: z.string().min(1),
|
|
38
46
|
})
|
|
39
47
|
.strict();
|
|
48
|
+
// S314g: a version's facts without its text, for a history list (one read
|
|
49
|
+
// away from the text). Strict, as TemplateVersionSchema is.
|
|
50
|
+
export const TemplateVersionMetaSchema = TemplateVersionSchema.omit({ content: true });
|
|
51
|
+
// S314g: a template in the trash, with the moment it went there; what the
|
|
52
|
+
// trash list shows and what a restore reads first.
|
|
53
|
+
export const TrashedTemplateSchema = TemplateDefinitionSchema.extend({ deletedAt: z.string().min(1) });
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// S314c2 (D14): the one cursor of the three trash lists (content, templates, assets). A list
|
|
3
|
+
// answers `${deletedAt}|${id}` as `nextCursor` (an ISO timestamp, a bar, the row's id); the
|
|
4
|
+
// adapters split it on the first bar (splitTrashCursor) and bind both halves into the keyset
|
|
5
|
+
// comparison. Checked here, a cursor that is not one answers 400 at the route before any
|
|
6
|
+
// dialect reads it; it used to reach a timestamp comparison and answer 500.
|
|
7
|
+
export const TRASH_CURSOR_MAX = 300;
|
|
8
|
+
// S314c2 (fix wave 1): within what every dialect stores, so PostgreSQL's TIMESTAMPTZ never refuses
|
|
9
|
+
// the bound half: a four-digit year from 1000 to 9999 (z.iso.datetime takes 0000) and an offset of
|
|
10
|
+
// at most 14 hours either way (it takes up to 23:59).
|
|
11
|
+
const OFFSET_MAX_MINUTES = 14 * 60;
|
|
12
|
+
function withinStoredRange(stamp) {
|
|
13
|
+
const year = Number(stamp.slice(0, 4));
|
|
14
|
+
if (year < 1000 || year > 9999)
|
|
15
|
+
return false;
|
|
16
|
+
const offset = /([+-])(\d{2}):?(\d{2})$/.exec(stamp);
|
|
17
|
+
return offset === null || Number(offset[2]) * 60 + Number(offset[3]) <= OFFSET_MAX_MINUTES;
|
|
18
|
+
}
|
|
19
|
+
const IsoTimestampSchema = z.iso.datetime({ offset: true }).refine(withinStoredRange);
|
|
20
|
+
export function isTrashCursor(value) {
|
|
21
|
+
const at = value.indexOf("|");
|
|
22
|
+
if (at <= 0 || at === value.length - 1)
|
|
23
|
+
return false;
|
|
24
|
+
return IsoTimestampSchema.safeParse(value.slice(0, at)).success;
|
|
25
|
+
}
|
|
26
|
+
export const TrashCursorSchema = z
|
|
27
|
+
.string()
|
|
28
|
+
.max(TRASH_CURSOR_MAX)
|
|
29
|
+
.refine(isTrashCursor, { message: "cursor must be a nextCursor this list answered: an ISO timestamp, a bar (|) and an id" });
|
|
@@ -5,8 +5,13 @@ export declare const UserSummarySchema: z.ZodObject<{
|
|
|
5
5
|
name: z.ZodNullable<z.ZodString>;
|
|
6
6
|
role: z.ZodString;
|
|
7
7
|
createdAt: z.ZodString;
|
|
8
|
+
system: z.ZodBoolean;
|
|
8
9
|
}, z.core.$strip>;
|
|
9
10
|
export type UserSummary = z.infer<typeof UserSummarySchema>;
|
|
11
|
+
export declare const UserParamsSchema: z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type UserParams = z.infer<typeof UserParamsSchema>;
|
|
10
15
|
export declare const UserListQuerySchema: z.ZodObject<{
|
|
11
16
|
cursor: z.ZodOptional<z.ZodString>;
|
|
12
17
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -19,6 +24,7 @@ export declare const UserListResponseSchema: z.ZodObject<{
|
|
|
19
24
|
name: z.ZodNullable<z.ZodString>;
|
|
20
25
|
role: z.ZodString;
|
|
21
26
|
createdAt: z.ZodString;
|
|
27
|
+
system: z.ZodBoolean;
|
|
22
28
|
}, z.core.$strip>>;
|
|
23
29
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
24
30
|
}, z.core.$strip>;
|
|
@@ -37,6 +43,7 @@ export declare const CreateUserResponseSchema: z.ZodObject<{
|
|
|
37
43
|
name: z.ZodNullable<z.ZodString>;
|
|
38
44
|
role: z.ZodString;
|
|
39
45
|
createdAt: z.ZodString;
|
|
46
|
+
system: z.ZodBoolean;
|
|
40
47
|
}, z.core.$strip>;
|
|
41
48
|
}, z.core.$strip>;
|
|
42
49
|
export type CreateUserResponse = z.infer<typeof CreateUserResponseSchema>;
|
|
@@ -51,15 +58,20 @@ export declare const UpdateUserRoleResponseSchema: z.ZodObject<{
|
|
|
51
58
|
name: z.ZodNullable<z.ZodString>;
|
|
52
59
|
role: z.ZodString;
|
|
53
60
|
createdAt: z.ZodString;
|
|
61
|
+
system: z.ZodBoolean;
|
|
54
62
|
}, z.core.$strip>;
|
|
55
63
|
}, z.core.$strip>;
|
|
56
64
|
export type UpdateUserRoleResponse = z.infer<typeof UpdateUserRoleResponseSchema>;
|
|
65
|
+
export declare const DeleteUserResponseSchema: z.ZodObject<{
|
|
66
|
+
deleted: z.ZodLiteral<true>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type DeleteUserResponse = z.infer<typeof DeleteUserResponseSchema>;
|
|
57
69
|
export declare const ADMIN_LOCALES: readonly ["en", "de"];
|
|
58
70
|
export type AdminLocale = (typeof ADMIN_LOCALES)[number];
|
|
59
71
|
export declare const ThemeModeSchema: z.ZodEnum<{
|
|
72
|
+
system: "system";
|
|
60
73
|
light: "light";
|
|
61
74
|
dark: "dark";
|
|
62
|
-
system: "system";
|
|
63
75
|
}>;
|
|
64
76
|
export declare const UserPreferencesSchema: z.ZodObject<{
|
|
65
77
|
locale: z.ZodNullable<z.ZodEnum<{
|
|
@@ -67,9 +79,9 @@ export declare const UserPreferencesSchema: z.ZodObject<{
|
|
|
67
79
|
de: "de";
|
|
68
80
|
}>>;
|
|
69
81
|
themeMode: z.ZodNullable<z.ZodEnum<{
|
|
82
|
+
system: "system";
|
|
70
83
|
light: "light";
|
|
71
84
|
dark: "dark";
|
|
72
|
-
system: "system";
|
|
73
85
|
}>>;
|
|
74
86
|
themeId: z.ZodNullable<z.ZodString>;
|
|
75
87
|
}, z.core.$strip>;
|
|
@@ -80,9 +92,9 @@ export declare const UpdateUserPreferencesSchema: z.ZodObject<{
|
|
|
80
92
|
de: "de";
|
|
81
93
|
}>>>;
|
|
82
94
|
themeMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
95
|
+
system: "system";
|
|
83
96
|
light: "light";
|
|
84
97
|
dark: "dark";
|
|
85
|
-
system: "system";
|
|
86
98
|
}>>>;
|
|
87
99
|
themeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
88
100
|
}, z.core.$strip>;
|
|
@@ -9,7 +9,12 @@ export const UserSummarySchema = z.object({
|
|
|
9
9
|
name: z.string().nullable(),
|
|
10
10
|
role: RoleIdSchema,
|
|
11
11
|
createdAt: z.string().datetime(),
|
|
12
|
+
// S301: true for the one account the server writes under for an API key (the
|
|
13
|
+
// system account, api-author@kardalum.internal). A person's account is false.
|
|
14
|
+
system: z.boolean(),
|
|
12
15
|
});
|
|
16
|
+
// S301: the params of PATCH /users/:id/role, moved here from the route file.
|
|
17
|
+
export const UserParamsSchema = z.object({ id: z.string().uuid() });
|
|
13
18
|
export const UserListQuerySchema = z.object({
|
|
14
19
|
cursor: z.string().uuid().optional(),
|
|
15
20
|
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
@@ -34,6 +39,9 @@ export const UpdateUserRoleRequestSchema = z.object({
|
|
|
34
39
|
export const UpdateUserRoleResponseSchema = z.object({
|
|
35
40
|
user: UserSummarySchema,
|
|
36
41
|
});
|
|
42
|
+
// S309: DELETE /users/:id answers this. The delete removes the account, ends its
|
|
43
|
+
// sessions and moves its uploads to the system account; it rewrites no authored row.
|
|
44
|
+
export const DeleteUserResponseSchema = z.object({ deleted: z.literal(true) });
|
|
37
45
|
// The admin interface languages that actually ship. ONE list, here,
|
|
38
46
|
// because three consumers have to agree: the server validates against
|
|
39
47
|
// it, the admin registers a bundle per entry, and the user menu offers
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const WhoamiResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
kind: z.ZodLiteral<"key">;
|
|
4
|
+
actions: z.ZodArray<z.ZodString>;
|
|
5
|
+
key: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
expiresAt: z.ZodNullable<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
kind: z.ZodLiteral<"session">;
|
|
12
|
+
actions: z.ZodArray<z.ZodString>;
|
|
13
|
+
user: z.ZodObject<{
|
|
14
|
+
id: z.ZodString;
|
|
15
|
+
name: z.ZodNullable<z.ZodString>;
|
|
16
|
+
role: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
}, z.core.$strip>], "kind">;
|
|
19
|
+
export type WhoamiResponse = z.infer<typeof WhoamiResponseSchema>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// GET /api/manage/v1/whoami: what the calling credential is and what it may do
|
|
3
|
+
// (2026-10-19-s306-the-cli-skeleton-design.md section 3). Never a hash, a
|
|
4
|
+
// plaintext key or an email: the key is described by id, name and expiry, the
|
|
5
|
+
// user by id, name and role. One branch per kind, so an answer always carries
|
|
6
|
+
// exactly the description that matches it.
|
|
7
|
+
export const WhoamiResponseSchema = z.discriminatedUnion("kind", [
|
|
8
|
+
z.object({
|
|
9
|
+
kind: z.literal("key"),
|
|
10
|
+
// Exactly the actions the credential holds, sorted. For a key this includes
|
|
11
|
+
// managementApi.use, because a key that reaches the route holds it.
|
|
12
|
+
actions: z.array(z.string()),
|
|
13
|
+
key: z.object({ id: z.string().uuid(), name: z.string(), expiresAt: z.string().datetime().nullable() }),
|
|
14
|
+
}),
|
|
15
|
+
z.object({
|
|
16
|
+
kind: z.literal("session"),
|
|
17
|
+
// Exactly the actions the session holds, sorted.
|
|
18
|
+
actions: z.array(z.string()),
|
|
19
|
+
// The name is null for a user who never set one.
|
|
20
|
+
user: z.object({ id: z.string(), name: z.string().nullable(), role: z.string() }),
|
|
21
|
+
}),
|
|
22
|
+
]);
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://kardalum.com",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"zod": "4.
|
|
26
|
+
"zod": "4.6.6"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"zod": "4.
|
|
29
|
+
"zod": "4.6.6"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p .",
|
|
@@ -16,6 +16,7 @@ export declare const tailwindTheme: {
|
|
|
16
16
|
artifact: Record<"string" | "base" | "text" | "border" | "strong" | "keyword" | "raised" | "muted" | "highlight", string>;
|
|
17
17
|
footer: Record<"base" | "text" | "border" | "strong" | "muted", string>;
|
|
18
18
|
brand: Record<"tile" | "keep", string>;
|
|
19
|
+
canvas: string;
|
|
19
20
|
};
|
|
20
21
|
fontFamily: {
|
|
21
22
|
sans: string;
|
|
@@ -37,6 +37,8 @@ export const tailwindTheme = {
|
|
|
37
37
|
artifact: scaleRefs(tokens.color.artifact, 'color-artifact'),
|
|
38
38
|
footer: scaleRefs(tokens.color.footer, 'color-footer'),
|
|
39
39
|
brand: scaleRefs(tokens.color.brand, 'color-brand'),
|
|
40
|
+
// A single colour, not a group: bg-canvas.
|
|
41
|
+
canvas: 'var(--color-canvas)',
|
|
40
42
|
},
|
|
41
43
|
fontFamily: {
|
|
42
44
|
sans: 'var(--font-family-sans)',
|
|
@@ -165,6 +165,9 @@ export const tokens = {
|
|
|
165
165
|
tile: '#113D5C',
|
|
166
166
|
keep: '#7CC0E8',
|
|
167
167
|
},
|
|
168
|
+
// S314c: the visitor page's ground in the edit-on-page preview, never
|
|
169
|
+
// themed (see types.ts). Dark mode must not paint it.
|
|
170
|
+
canvas: '#FFFFFF',
|
|
168
171
|
},
|
|
169
172
|
typography: {
|
|
170
173
|
fontFamily: {
|
|
@@ -39,7 +39,10 @@ const result = verifyEnvelope({ envelope, signature }, sha256, [{ keyId, publicK
|
|
|
39
39
|
|
|
40
40
|
**Safe extraction.** `extractArtifact` unpacks a plugin `.zip` with hard
|
|
41
41
|
limits on entry count, per-entry size, and total size, and rejects
|
|
42
|
-
zip-slip-style paths (leading `/`, drive letters, `..` segments)
|
|
42
|
+
zip-slip-style paths (leading `/`, drive letters, `..` segments), any name
|
|
43
|
+
another filesystem would read differently (a backslash, a colon, a control
|
|
44
|
+
or non-ASCII character, a segment ending in `.` or a space, `~` followed by
|
|
45
|
+
a digit), a second name for an entry, and any path held twice, before
|
|
43
46
|
anything is written to disk:
|
|
44
47
|
|
|
45
48
|
```ts
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { PluginInstallDeclaration, PluginLabel, PluginReference } from "@kardalum/api-schemas";
|
|
2
|
+
type LabelMap = {
|
|
3
|
+
en: string;
|
|
4
|
+
[locale: string]: string;
|
|
5
|
+
};
|
|
6
|
+
/** What buildReference reads from a manifest, named structurally because this
|
|
7
|
+
* package cannot import the SDK (the SDK depends on it). The SDK asserts that
|
|
8
|
+
* its PluginManifest is assignable to this, so a field the builder cannot
|
|
9
|
+
* read is an SDK compile error (spec D3). */
|
|
10
|
+
export interface ReferenceManifestInput {
|
|
11
|
+
actions?: ReadonlyArray<{
|
|
12
|
+
id: string;
|
|
13
|
+
label: PluginLabel;
|
|
14
|
+
}>;
|
|
15
|
+
roles?: ReadonlyArray<{
|
|
16
|
+
id: string;
|
|
17
|
+
label: PluginLabel;
|
|
18
|
+
actions: readonly string[];
|
|
19
|
+
}>;
|
|
20
|
+
databaseCompatibility?: {
|
|
21
|
+
storageType?: string;
|
|
22
|
+
};
|
|
23
|
+
assertions?: {
|
|
24
|
+
externalNetwork?: {
|
|
25
|
+
reason: string;
|
|
26
|
+
};
|
|
27
|
+
filesystemAccess?: {
|
|
28
|
+
reason: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
migrations?: ReadonlyArray<{
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
}>;
|
|
35
|
+
install?: PluginInstallDeclaration;
|
|
36
|
+
contributions: {
|
|
37
|
+
apiRoutes?: ReadonlyArray<{
|
|
38
|
+
method: string;
|
|
39
|
+
path: string;
|
|
40
|
+
access?: string;
|
|
41
|
+
action?: string;
|
|
42
|
+
}>;
|
|
43
|
+
documentTypes?: ReadonlyArray<{
|
|
44
|
+
name: string;
|
|
45
|
+
kind: string;
|
|
46
|
+
}>;
|
|
47
|
+
dataTypes?: ReadonlyArray<{
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
icon?: string;
|
|
51
|
+
version?: string;
|
|
52
|
+
schema?: unknown;
|
|
53
|
+
settingsSchema?: unknown;
|
|
54
|
+
defaultSettings?: unknown;
|
|
55
|
+
}>;
|
|
56
|
+
templates?: ReadonlyArray<{
|
|
57
|
+
name: string;
|
|
58
|
+
alias: string;
|
|
59
|
+
kind: string;
|
|
60
|
+
documentType?: string;
|
|
61
|
+
}>;
|
|
62
|
+
adminSections?: ReadonlyArray<{
|
|
63
|
+
id: string;
|
|
64
|
+
label: LabelMap;
|
|
65
|
+
action: string;
|
|
66
|
+
rail?: ReadonlyArray<{
|
|
67
|
+
id: string;
|
|
68
|
+
label: LabelMap;
|
|
69
|
+
action: string;
|
|
70
|
+
}>;
|
|
71
|
+
}>;
|
|
72
|
+
railEntries?: ReadonlyArray<{
|
|
73
|
+
id: string;
|
|
74
|
+
label: LabelMap;
|
|
75
|
+
section: string;
|
|
76
|
+
action: string;
|
|
77
|
+
}>;
|
|
78
|
+
dashboardWidgets?: ReadonlyArray<{
|
|
79
|
+
id: string;
|
|
80
|
+
name: PluginLabel;
|
|
81
|
+
action: string;
|
|
82
|
+
}>;
|
|
83
|
+
hooks?: object;
|
|
84
|
+
scheduledTasks?: ReadonlyArray<{
|
|
85
|
+
id: string;
|
|
86
|
+
name: PluginLabel;
|
|
87
|
+
cron: string;
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** The serialisable facts the six generated Reference pages are rendered
|
|
92
|
+
* from (spec 3.2). Only plain data: never a view, a handler or a hook. The
|
|
93
|
+
* CLI writes it to reference.json; the server builds it live from the
|
|
94
|
+
* attached manifest. */
|
|
95
|
+
export declare function buildReference(manifest: ReferenceManifestInput): PluginReference;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ASSERTION_KEYS, deriveCapabilities } from "./capabilities.js";
|
|
2
|
+
/** Drops functions, components and undefined values by a JSON round trip. */
|
|
3
|
+
function plain(value) {
|
|
4
|
+
return JSON.parse(JSON.stringify(value));
|
|
5
|
+
}
|
|
6
|
+
/** A slot label's string entries only. */
|
|
7
|
+
function labelMap(label) {
|
|
8
|
+
return Object.fromEntries(Object.entries(label).filter(([, text]) => typeof text === "string"));
|
|
9
|
+
}
|
|
10
|
+
/** The English text of a label that may be a language map (S311): the reference
|
|
11
|
+
* carries one string per name, as its pages print it. resolveLabel(label, "en")
|
|
12
|
+
* in @kardalum/api-schemas, written inline because this module may take only
|
|
13
|
+
* types from there (build-reference.test.ts pins the two); a map's only key a
|
|
14
|
+
* language code can read as "en" is "en" itself. */
|
|
15
|
+
function english(label) {
|
|
16
|
+
return typeof label === "object" && label !== null ? label.en : label;
|
|
17
|
+
}
|
|
18
|
+
/** The serialisable facts the six generated Reference pages are rendered
|
|
19
|
+
* from (spec 3.2). Only plain data: never a view, a handler or a hook. The
|
|
20
|
+
* CLI writes it to reference.json; the server builds it live from the
|
|
21
|
+
* attached manifest. */
|
|
22
|
+
export function buildReference(manifest) {
|
|
23
|
+
const c = manifest.contributions;
|
|
24
|
+
return {
|
|
25
|
+
actions: (manifest.actions ?? []).map(({ id, label }) => ({ id, label: english(label) })),
|
|
26
|
+
roles: (manifest.roles ?? []).map(({ id, label, actions }) => ({ id, label: english(label), actions: [...actions] })),
|
|
27
|
+
apiRoutes: (c.apiRoutes ?? []).map((route) => ({
|
|
28
|
+
method: route.method,
|
|
29
|
+
path: route.path,
|
|
30
|
+
// Anything but the three named tiers falls back to "admin" at dispatch.
|
|
31
|
+
access: route.access ?? "admin",
|
|
32
|
+
...(route.action ? { action: route.action } : {}),
|
|
33
|
+
})),
|
|
34
|
+
capabilities: deriveCapabilities(manifest).map(({ id, mediation, payload }) => ({ id, mediation, payload: { count: payload.count, details: [...payload.details] } })),
|
|
35
|
+
documentTypes: plain(c.documentTypes ?? []),
|
|
36
|
+
dataTypes: (c.dataTypes ?? []).map((type) => plain({ id: type.id, name: type.name, icon: type.icon, version: type.version, schema: type.schema, settingsSchema: type.settingsSchema, defaultSettings: type.defaultSettings })),
|
|
37
|
+
templates: (c.templates ?? []).map((t) => ({ name: t.name, alias: t.alias, kind: t.kind, ...(t.documentType ? { documentType: t.documentType } : {}) })),
|
|
38
|
+
adminSections: (c.adminSections ?? []).map((s) => ({
|
|
39
|
+
id: s.id,
|
|
40
|
+
label: labelMap(s.label),
|
|
41
|
+
action: s.action,
|
|
42
|
+
rail: (s.rail ?? []).map((e) => ({ id: e.id, label: labelMap(e.label), action: e.action })),
|
|
43
|
+
})),
|
|
44
|
+
railEntries: (c.railEntries ?? []).map((e) => ({ id: e.id, label: labelMap(e.label), section: e.section, action: e.action })),
|
|
45
|
+
dashboardWidgets: (c.dashboardWidgets ?? []).map(({ id, name, action }) => ({ id, name: english(name), action })),
|
|
46
|
+
hooks: Object.keys(c.hooks ?? {}),
|
|
47
|
+
scheduledTasks: (c.scheduledTasks ?? []).map(({ id, name, cron }) => ({ id, name: english(name), cron })),
|
|
48
|
+
migrations: (manifest.migrations ?? []).map(({ id, name }) => ({ id, name })),
|
|
49
|
+
assertions: ASSERTION_KEYS.flatMap((key) => {
|
|
50
|
+
const reason = manifest.assertions?.[key]?.reason;
|
|
51
|
+
return typeof reason === "string" && reason.trim() ? [{ key, reason }] : [];
|
|
52
|
+
}),
|
|
53
|
+
installOptions: (manifest.install?.steps ?? []).flatMap((step) => step.options.map((option) => ({
|
|
54
|
+
step: labelMap(step.label),
|
|
55
|
+
id: option.id,
|
|
56
|
+
label: labelMap(option.label),
|
|
57
|
+
kind: option.kind,
|
|
58
|
+
choices: option.kind === "boolean" ? [] : option.choices.map((choice) => ({ id: choice.id, label: labelMap(choice.label) })),
|
|
59
|
+
default: option.kind === "select" ? (option.default ?? null) : option.kind === "multiSelect" ? [...option.default] : option.default,
|
|
60
|
+
// installOptionNeedsAnswer in @kardalum/api-schemas, written inline
|
|
61
|
+
// because this module may take only types from there
|
|
62
|
+
// (reference-entry.test.ts); build-reference.test.ts pins the two.
|
|
63
|
+
required: option.kind === "select" && option.default === undefined && option.required !== false,
|
|
64
|
+
}))),
|
|
65
|
+
};
|
|
66
|
+
}
|