@cosmicdrift/kumiko-bundled-features 0.417.0 → 0.419.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/dist/agent-tools/api-docs/schema-fields.js +9 -0
- package/dist/auth-email-password/index.d.ts +2 -1
- package/dist/auth-email-password/index.js +2 -1
- package/dist/auth-email-password/signup-activation.js +2 -1
- package/dist/auth-email-password/signup-token-store.d.ts +1 -6
- package/dist/auth-email-password/signup-token-store.js +0 -5
- package/dist/cap-counter/stock-cap-guard.d.ts +9 -2
- package/dist/cap-counter/stock-cap-guard.js +9 -11
- package/dist/document-ingest-foundation/feature.js +5 -1
- package/dist/document-ingest-foundation/report-ingest-progress.js +19 -6
- package/dist/signature/entity.d.ts +8 -6
- package/dist/signature/entity.js +3 -1
- package/dist/signature/feature.js +11 -4
- package/dist/signature/handlers/lifecycle.write.d.ts +9 -0
- package/dist/signature/handlers/lifecycle.write.js +23 -1
- package/dist/signature/handlers/request.write.d.ts +1 -1
- package/dist/signature/i18n.js +1 -0
- package/dist/signature/list-cursor-seal.d.ts +3 -0
- package/dist/signature/list-cursor-seal.js +44 -0
- package/dist/signature/options.d.ts +2 -2
- package/dist/signature/payloads.d.ts +17 -1
- package/dist/signature/payloads.js +11 -2
- package/dist/signature/png.js +23 -3
- package/dist/signature/subject-queries.d.ts +1 -1
- package/dist/signature/subject-queries.js +30 -8
- package/dist/signature/sweep.js +26 -9
- package/dist/signature/web/constants.d.ts +9 -0
- package/dist/signature/web/constants.js +8 -0
- package/dist/subscription-stripe/plugin-methods.js +2 -0
- package/dist/subscription-stripe/verify-webhook.js +17 -16
- package/dist/template-resolver/compile-document-body.js +3 -6
- package/dist/template-resolver/compile-document-styles.d.ts +3 -0
- package/dist/template-resolver/compile-document-styles.js +84 -0
- package/dist/template-resolver/document-frames.d.ts +3 -0
- package/dist/template-resolver/document-frames.js +19 -0
- package/dist/template-resolver/document-op-blocks.d.ts +495 -0
- package/dist/template-resolver/document-op-blocks.js +430 -0
- package/dist/template-resolver/document-ops.d.ts +1809 -37
- package/dist/template-resolver/document-ops.js +97 -104
- package/dist/template-resolver/document-print-only.d.ts +10 -0
- package/dist/template-resolver/document-print-only.js +24 -0
- package/dist/template-resolver/document-sanitizer.d.ts +1 -1
- package/dist/template-resolver/document-sanitizer.js +24 -13
- package/dist/template-resolver/feature.d.ts +3 -0
- package/dist/template-resolver/feature.js +14 -1
- package/dist/template-resolver/handlers/apply-layout.write.d.ts +29 -0
- package/dist/template-resolver/handlers/apply-layout.write.js +118 -0
- package/dist/template-resolver/handlers/create-layout.write.d.ts +15 -0
- package/dist/template-resolver/handlers/create-layout.write.js +78 -0
- package/dist/template-resolver/handlers/document-base.d.ts +2 -2
- package/dist/template-resolver/handlers/document-blocks.query.d.ts +10 -3
- package/dist/template-resolver/handlers/document-blocks.query.js +13 -8
- package/dist/template-resolver/handlers/document-region.d.ts +19 -0
- package/dist/template-resolver/handlers/document-region.js +27 -0
- package/dist/template-resolver/handlers/failure-reason.d.ts +2 -0
- package/dist/template-resolver/handlers/failure-reason.js +12 -0
- package/dist/template-resolver/handlers/import-bundle-system.write.js +4 -0
- package/dist/template-resolver/handlers/layout-source.query.d.ts +3 -3
- package/dist/template-resolver/handlers/layout-source.query.js +6 -2
- package/dist/template-resolver/handlers/overview.query.d.ts +8 -0
- package/dist/template-resolver/handlers/overview.query.js +12 -6
- package/dist/template-resolver/handlers/patch-draft.write.d.ts +905 -4
- package/dist/template-resolver/handlers/patch-draft.write.js +10 -6
- package/dist/template-resolver/handlers/publish-templates.write.d.ts +40 -0
- package/dist/template-resolver/handlers/publish-templates.write.js +61 -0
- package/dist/template-resolver/handlers/set.write.js +4 -1
- package/dist/template-resolver/handlers/template-write.js +7 -2
- package/dist/template-resolver/handlers/tenant-settings.d.ts +17 -0
- package/dist/template-resolver/handlers/tenant-settings.js +91 -0
- package/dist/template-resolver/handlers/toggle-status.write.d.ts +14 -9
- package/dist/template-resolver/handlers/toggle-status.write.js +11 -7
- package/dist/template-resolver/handlers/upsert-system.write.js +15 -9
- package/dist/template-resolver/handlers/usage.query.d.ts +14 -0
- package/dist/template-resolver/handlers/usage.query.js +80 -12
- package/dist/template-resolver/handlers/validate.query.d.ts +2 -0
- package/dist/template-resolver/handlers/validate.query.js +10 -0
- package/dist/template-resolver/i18n.js +3 -0
- package/dist/template-resolver/index.d.ts +7 -2
- package/dist/template-resolver/index.js +6 -2
- package/dist/template-resolver/layout-regions.d.ts +4 -5
- package/dist/template-resolver/layout-regions.js +38 -11
- package/dist/template-resolver/print-document.js +3 -1
- package/dist/template-resolver/seeding.js +4 -0
- package/dist/template-resolver/template-delivery-policy.d.ts +1 -0
- package/dist/template-resolver/template-delivery-policy.js +9 -1
- package/dist/template-resolver/template-edit-policy.d.ts +5 -1
- package/dist/template-resolver/template-edit-policy.js +29 -1
- package/dist/template-resolver/template-meta.d.ts +27 -2
- package/dist/template-resolver/template-meta.js +21 -5
- package/dist/template-resolver/template-preview.js +8 -8
- package/dist/template-resolver/template-validation.js +10 -3
- package/dist/template-resolver/web/constants.d.ts +7 -1
- package/dist/template-resolver/web/constants.js +21 -1
- package/dist/template-resolver/web/document-blocks.d.ts +1 -0
- package/dist/template-resolver/web/document-blocks.js +2 -0
- package/dist/template-resolver/web/document-editor-extensions.d.ts +9 -1
- package/dist/template-resolver/web/document-editor-extensions.js +27 -2
- package/dist/template-resolver/web/document-editor-fonts.d.ts +10 -0
- package/dist/template-resolver/web/document-editor-fonts.js +13 -0
- package/dist/template-resolver/web/document-fonts.d.ts +4 -0
- package/dist/template-resolver/web/document-fonts.js +18 -0
- package/dist/template-resolver/web/document-frame-control.d.ts +61 -0
- package/dist/template-resolver/web/document-frame-control.js +329 -0
- package/dist/template-resolver/web/document-frame-node-view.d.ts +4 -0
- package/dist/template-resolver/web/document-frame-node-view.js +173 -0
- package/dist/template-resolver/web/document-print-decorations.d.ts +12 -0
- package/dist/template-resolver/web/document-print-decorations.js +147 -0
- package/dist/template-resolver/web/document-print-defaults.d.ts +14 -0
- package/dist/template-resolver/web/document-print-defaults.js +25 -0
- package/dist/template-resolver/web/document-print-style.d.ts +71 -0
- package/dist/template-resolver/web/document-print-style.js +199 -0
- package/dist/template-resolver/web/document-repeat-strip.d.ts +8 -0
- package/dist/template-resolver/web/document-repeat-strip.js +78 -0
- package/dist/template-resolver/web/document-schema.js +23 -9
- package/dist/template-resolver/web/document-style-css.d.ts +29 -0
- package/dist/template-resolver/web/document-style-css.js +76 -0
- package/dist/template-resolver/web/document-tiptap-bubble.js +13 -3
- package/dist/template-resolver/web/document-tiptap-content.d.ts +2 -1
- package/dist/template-resolver/web/document-tiptap-content.js +36 -4
- package/dist/template-resolver/web/document-tiptap-context.d.ts +6 -2
- package/dist/template-resolver/web/document-tiptap-context.js +2 -1
- package/dist/template-resolver/web/document-tiptap-editor.d.ts +1 -1
- package/dist/template-resolver/web/document-tiptap-editor.js +13 -5
- package/dist/template-resolver/web/document-tiptap-helpers.d.ts +30 -1
- package/dist/template-resolver/web/document-tiptap-helpers.js +103 -2
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.d.ts +5 -0
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.js +89 -6
- package/dist/template-resolver/web/document-tiptap-toolbar.js +45 -8
- package/dist/template-resolver/web/document-toolbar-blocks.d.ts +17 -0
- package/dist/template-resolver/web/i18n.js +19 -0
- package/dist/template-resolver/web/index.d.ts +8 -2
- package/dist/template-resolver/web/index.js +6 -1
- package/dist/template-resolver/web/pdf-constants.d.ts +3 -0
- package/dist/template-resolver/web/pdf-constants.js +3 -0
- package/dist/template-resolver/web/qualified-names.d.ts +7 -0
- package/dist/template-resolver/web/qualified-names.js +6 -0
- package/dist/template-resolver/web/use-document-tiptap-model.d.ts +6 -2
- package/dist/template-resolver/web/use-document-tiptap-model.js +38 -3
- package/dist/tenant/company-config.d.ts +6 -0
- package/dist/tenant/company-config.js +41 -0
- package/dist/tenant/feature.js +11 -0
- package/dist/tenant/i18n.js +14 -0
- package/dist/tenant-inactivity/handlers/keep-account.write.js +5 -2
- package/dist/tenant-lifecycle/run-tenant-destroy.js +65 -33
- package/package.json +16 -11
- package/src/agent-tools/changes.json +6 -0
- package/src/cap-counter/changes.json +6 -0
- package/src/channel-whatsapp/changes.json +1 -1
- package/src/document-ingest-foundation/changes.json +6 -0
- package/src/signature/changes.json +18 -0
- package/src/subscription-paddle/changes.json +1 -1
- package/src/subscription-stripe/changes.json +6 -0
- package/src/template-resolver/changes.json +38 -0
- package/src/tenant-lifecycle/changes.json +6 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { isResourceImageContentType } from "../shared/index.ts";
|
|
2
2
|
export { createTemplateResolverApi, type ResolveRequest, requireTemplateResolver, TemplateNotFoundError, type TemplateResolverApi, type TemplateResource, } from "./api.ts";
|
|
3
3
|
export { type CompileDocumentBodyOptions, collectDocumentImageVariables, collectDocumentResourceKeys, compileDocumentBodyToHandlebars, toResourceDataUri, } from "./compile-document-body.ts";
|
|
4
|
+
export { flattenFramesForPreview, readTopLevelFrames } from "./document-frames.ts";
|
|
4
5
|
export { type DocumentViolation, type DocumentViolationCode, documentViolationsToFieldIssues, flattenParagraphsToLineBreaks, type SanitizeBodyResult, type SanitizeHtmlResult, sanitizeDocumentHtml, sanitizeTemplateBody, } from "./document-sanitizer.ts";
|
|
5
6
|
export { createTemplateResolverFeature, type TemplateResolverOptions } from "./feature.ts";
|
|
6
7
|
export type { LayoutSourceResponse, LayoutSourceRow } from "./handlers/layout-source.query.ts";
|
|
7
8
|
export type { OverviewKindGroup, OverviewOrigin, OverviewResponse, OverviewRow, OverviewUsage, } from "./handlers/overview.query.ts";
|
|
8
9
|
export { localeSchema } from "./handlers/shared.ts";
|
|
10
|
+
export { companyConfigKey, defaultPdfLayoutSlug, readTenantConfigText, } from "./handlers/tenant-settings.ts";
|
|
9
11
|
export { isHexColor, type MailLayoutAppearance, mailLayoutAppearance, } from "./layout-appearance.ts";
|
|
10
12
|
export { type LayoutRegions, readLayoutRegions, type SanitizeLayoutResult, sanitizeLayoutHtml, } from "./layout-regions.ts";
|
|
11
13
|
export { fileAttachmentsOf, imageLinksOf, type LinkedResourceEntry, parseLinkedResourceEntries, pdfAttachmentLinksOf, type TemplatePdfAttachmentLink, templatePdfAttachmentLinkSchema, } from "./linked-resources.ts";
|
|
@@ -16,13 +18,16 @@ export { type TemplateResourceRow, templateResourceEntity, templateResourcesTabl
|
|
|
16
18
|
export { type TemplateBundle, templateBundleSchema } from "./template-bundle.ts";
|
|
17
19
|
export type { TemplateDeliveryPolicy } from "./template-delivery-policy.ts";
|
|
18
20
|
export { type TemplateEditPolicy, type TenantEditableTemplate, templateEditAccess, } from "./template-edit-policy.ts";
|
|
19
|
-
export { isMailTemplateMeta, type LayoutTemplateMeta, MAIL_CATEGORIES, MAIL_TONES, type MailCategory, type MailLayoutMeta, type MailTemplateMeta, type MailTone, type PdfTemplateMeta, parseTemplateMeta, pdfAttachmentFileNamePatternSchema, readMailLayoutMeta, readPdfTemplateMeta, type TemplateMeta, type TemplateMetaIssue, type TemplateMetaResult, templateSlugSchema, } from "./template-meta.ts";
|
|
21
|
+
export { isMailTemplateMeta, type LayoutTemplateMeta, MAIL_CATEGORIES, MAIL_TONES, type MailCategory, type MailLayoutMeta, type MailTemplateMeta, type MailTone, type PdfLayoutMeta, type PdfTemplateMeta, parseTemplateMeta, pdfAttachmentFileNamePatternSchema, readMailLayoutMeta, readPdfLayoutMeta, readPdfTemplateMeta, type TemplateMeta, type TemplateMetaIssue, type TemplateMetaResult, templateSlugSchema, } from "./template-meta.ts";
|
|
20
22
|
export { type DocumentDraftOutcome, evaluateDocumentDraft } from "./template-preview.ts";
|
|
21
23
|
export { readTemplateResource, type TemplateResourceFile } from "./template-resources.ts";
|
|
22
24
|
export { isSystemOnlyTemplate } from "./template-system-only.ts";
|
|
23
25
|
export { collectTemplateUsage, type TemplateUsageEntry } from "./template-usage.ts";
|
|
24
26
|
export { hasPlaceholderProblems, resolveTemplateVariables, SYSTEM_PLACEHOLDERS, systemPlaceholdersFor, type TemplateValidation, validateTemplatePlaceholders, } from "./template-validation.ts";
|
|
25
27
|
export { type UserContentEntryRow, userContentEntriesTable, userContentEntryEntity, } from "./user-content-table.ts";
|
|
26
|
-
export { CONTENT_FORMATS, type ContentFormat, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DOCUMENT_HTML_KINDS, type DocumentHtmlKind, FALLBACK_LOCALE, NON_RENDER_KINDS, type NonRenderKind, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, type PdfOrientation, type PdfPageFormat, RENDER_KINDS, type RenderKind, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TEXT_BLOCK_KIND, type TemplateKind, type TemplateScope, type TemplateStatus, UPSERT_KINDS, type UpsertKind, } from "./web/constants.ts";
|
|
28
|
+
export { COMPANY_PLACEHOLDERS, CONTENT_FORMATS, type ContentFormat, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY, DOCUMENT_HTML_KINDS, type DocumentHtmlKind, FALLBACK_LOCALE, NON_RENDER_KINDS, type NonRenderKind, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, type PdfOrientation, type PdfPageFormat, type PdfTableStyle, RENDER_KINDS, type RenderKind, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TENANT_LAYOUT_SLUG_PREFIX, TEXT_BLOCK_KIND, type TemplateKind, type TemplateScope, type TemplateStatus, UPSERT_KINDS, type UpsertKind, } from "./web/constants.ts";
|
|
29
|
+
export { DOCUMENT_FONT_LABELS, DOCUMENT_FONT_PRINT_STACKS, DOCUMENT_FONTS, type DocumentFont, } from "./web/document-fonts.ts";
|
|
30
|
+
export type { DocumentFrameAttributes } from "./web/document-print-style.ts";
|
|
27
31
|
export { DOCUMENT_CONDITION_ATTRIBUTE, DOCUMENT_NODE_NAMES, DOCUMENT_TEXT_ALIGNMENTS, DocumentButton, DocumentCondition, DocumentDivider, DocumentLink, DocumentPageBreak, DocumentResource, DocumentTable, DocumentTableCell, DocumentTableHeader, DocumentTableRow, DocumentTextAlign, type DocumentTextAlignment, DocumentVariable, documentExtensions, isAllowedDocumentLinkHref, isAllowedDocumentUrlHref, isDocumentPlaceholderHref, isDocumentReferenceName, isDocumentResourceKey, } from "./web/document-schema.ts";
|
|
32
|
+
export { addressParagraphCss, DOCUMENT_LINE_VARIABLE, documentLinePt, FRAME_FLOW_GAP_MM, PARAGRAPH_DEFAULT_LINE_HEIGHT, SENDER_LINE_SIZE_PT, } from "./web/document-style-css.ts";
|
|
28
33
|
export { TEMPLATE_RESOLVER_FEATURE, TemplateResolverErrors, TemplateResolverHandlers, TemplateResolverQueries, } from "./web/qualified-names.ts";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { isResourceImageContentType } from "../shared/index.js";
|
|
2
2
|
export { createTemplateResolverApi, requireTemplateResolver, TemplateNotFoundError, } from "./api.js";
|
|
3
3
|
export { collectDocumentImageVariables, collectDocumentResourceKeys, compileDocumentBodyToHandlebars, toResourceDataUri, } from "./compile-document-body.js";
|
|
4
|
+
export { flattenFramesForPreview, readTopLevelFrames } from "./document-frames.js";
|
|
4
5
|
export { documentViolationsToFieldIssues, flattenParagraphsToLineBreaks, sanitizeDocumentHtml, sanitizeTemplateBody, } from "./document-sanitizer.js";
|
|
5
6
|
export { createTemplateResolverFeature } from "./feature.js";
|
|
6
7
|
export { localeSchema } from "./handlers/shared.js";
|
|
8
|
+
export { companyConfigKey, defaultPdfLayoutSlug, readTenantConfigText, } from "./handlers/tenant-settings.js";
|
|
7
9
|
export { isHexColor, mailLayoutAppearance, } from "./layout-appearance.js";
|
|
8
10
|
export { readLayoutRegions, sanitizeLayoutHtml, } from "./layout-regions.js";
|
|
9
11
|
export { fileAttachmentsOf, imageLinksOf, parseLinkedResourceEntries, pdfAttachmentLinksOf, templatePdfAttachmentLinkSchema, } from "./linked-resources.js";
|
|
@@ -13,13 +15,15 @@ export { prepareTemplateResourceBeforeTransaction, readTemplateResourceMaxBytes,
|
|
|
13
15
|
export { templateResourceEntity, templateResourcesTable, } from "./table.js";
|
|
14
16
|
export { templateBundleSchema } from "./template-bundle.js";
|
|
15
17
|
export { templateEditAccess, } from "./template-edit-policy.js";
|
|
16
|
-
export { isMailTemplateMeta, MAIL_CATEGORIES, MAIL_TONES, parseTemplateMeta, pdfAttachmentFileNamePatternSchema, readMailLayoutMeta, readPdfTemplateMeta, templateSlugSchema, } from "./template-meta.js";
|
|
18
|
+
export { isMailTemplateMeta, MAIL_CATEGORIES, MAIL_TONES, parseTemplateMeta, pdfAttachmentFileNamePatternSchema, readMailLayoutMeta, readPdfLayoutMeta, readPdfTemplateMeta, templateSlugSchema, } from "./template-meta.js";
|
|
17
19
|
export { evaluateDocumentDraft } from "./template-preview.js";
|
|
18
20
|
export { readTemplateResource } from "./template-resources.js";
|
|
19
21
|
export { isSystemOnlyTemplate } from "./template-system-only.js";
|
|
20
22
|
export { collectTemplateUsage } from "./template-usage.js";
|
|
21
23
|
export { hasPlaceholderProblems, resolveTemplateVariables, SYSTEM_PLACEHOLDERS, systemPlaceholdersFor, validateTemplatePlaceholders, } from "./template-validation.js";
|
|
22
24
|
export { userContentEntriesTable, userContentEntryEntity, } from "./user-content-table.js";
|
|
23
|
-
export { CONTENT_FORMATS, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DOCUMENT_HTML_KINDS, FALLBACK_LOCALE, NON_RENDER_KINDS, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, RENDER_KINDS, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TEXT_BLOCK_KIND, UPSERT_KINDS, } from "./web/constants.js";
|
|
25
|
+
export { COMPANY_PLACEHOLDERS, CONTENT_FORMATS, DEFAULT_MAIL_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG, DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY, DOCUMENT_HTML_KINDS, FALLBACK_LOCALE, NON_RENDER_KINDS, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, RENDER_KINDS, SYSTEM_TENANT_ID, TEMPLATE_KINDS, TEMPLATE_SCOPES, TEMPLATE_STATUSES, TENANT_LAYOUT_SLUG_PREFIX, TEXT_BLOCK_KIND, UPSERT_KINDS, } from "./web/constants.js";
|
|
26
|
+
export { DOCUMENT_FONT_LABELS, DOCUMENT_FONT_PRINT_STACKS, DOCUMENT_FONTS, } from "./web/document-fonts.js";
|
|
24
27
|
export { DOCUMENT_CONDITION_ATTRIBUTE, DOCUMENT_NODE_NAMES, DOCUMENT_TEXT_ALIGNMENTS, DocumentButton, DocumentCondition, DocumentDivider, DocumentLink, DocumentPageBreak, DocumentResource, DocumentTable, DocumentTableCell, DocumentTableHeader, DocumentTableRow, DocumentTextAlign, DocumentVariable, documentExtensions, isAllowedDocumentLinkHref, isAllowedDocumentUrlHref, isDocumentPlaceholderHref, isDocumentReferenceName, isDocumentResourceKey, } from "./web/document-schema.js";
|
|
28
|
+
export { addressParagraphCss, DOCUMENT_LINE_VARIABLE, documentLinePt, FRAME_FLOW_GAP_MM, PARAGRAPH_DEFAULT_LINE_HEIGHT, SENDER_LINE_SIZE_PT, } from "./web/document-style-css.js";
|
|
25
29
|
export { TEMPLATE_RESOLVER_FEATURE, TemplateResolverErrors, TemplateResolverHandlers, TemplateResolverQueries, } from "./web/qualified-names.js";
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { type DocumentViolation, type SanitizeBodyResult } from "./document-sanitizer.ts";
|
|
2
2
|
import type { ContentFormat } from "./web/constants.ts";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly footer: string;
|
|
7
|
-
};
|
|
3
|
+
export declare const LAYOUT_REGION_NAMES: readonly ["header", "signature", "footer"];
|
|
4
|
+
export type LayoutRegionName = (typeof LAYOUT_REGION_NAMES)[number];
|
|
5
|
+
export type LayoutRegions = Readonly<Record<LayoutRegionName, string>>;
|
|
8
6
|
export type SanitizeLayoutResult = {
|
|
9
7
|
readonly ok: true;
|
|
10
8
|
readonly html: string;
|
|
@@ -14,6 +12,7 @@ export type SanitizeLayoutResult = {
|
|
|
14
12
|
};
|
|
15
13
|
export declare function sanitizeLayoutHtml(html: string): SanitizeLayoutResult;
|
|
16
14
|
export declare function readLayoutRegions(html: string): LayoutRegions;
|
|
15
|
+
export declare function composeLayoutHtml(regions: LayoutRegions): string;
|
|
17
16
|
export type TemplateWriteScope = "system" | "tenant";
|
|
18
17
|
export declare function sanitizeTemplateWriteBody(input: {
|
|
19
18
|
readonly kind: string;
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// mail or PDF body: header, signature and footer regions plus one empty
|
|
3
3
|
// content slot. Everything else is rejected so a layout can never carry markup
|
|
4
4
|
// the renderer did not plan for.
|
|
5
|
+
import { hasFrame, IMAGES_BLOCK_SELECTOR, scanPrintOnlyFeatures } from "./document-print-only.js";
|
|
5
6
|
import { sanitizeDocumentHtml, sanitizeTemplateBody, violation, withParsedDocument, } from "./document-sanitizer.js";
|
|
6
7
|
const REGION_ATTRIBUTES = ["data-header", "data-content", "data-signature", "data-footer"];
|
|
7
8
|
const MAIL_LAYOUT_CONTENT_SLOT = /\{\{\{\s*content\s*\}\}\}/g;
|
|
9
|
+
export const LAYOUT_REGION_NAMES = ["header", "signature", "footer"];
|
|
8
10
|
const ELEMENT_NODE = 1;
|
|
9
11
|
const TEXT_NODE = 3;
|
|
10
12
|
function regionAttributeOf(element) {
|
|
@@ -58,6 +60,10 @@ export function sanitizeLayoutHtml(html) {
|
|
|
58
60
|
const inner = parsed.innerHtml[name];
|
|
59
61
|
if (inner === undefined || inner.trim() === "")
|
|
60
62
|
continue;
|
|
63
|
+
if (withParsedDocument(inner, hasFrame)) {
|
|
64
|
+
violations.push(violation("frame_not_top_level", name, `Frames are not allowed in the ${name} region; they belong in the document body`));
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
61
67
|
const result = sanitizeDocumentHtml(inner);
|
|
62
68
|
if (result.ok)
|
|
63
69
|
cleanedHtml[name] = result.html;
|
|
@@ -66,18 +72,13 @@ export function sanitizeLayoutHtml(html) {
|
|
|
66
72
|
}
|
|
67
73
|
if (violations.length > 0)
|
|
68
74
|
return { ok: false, violations };
|
|
69
|
-
const part = (name) => {
|
|
70
|
-
const regionHtml = cleanedHtml[name];
|
|
71
|
-
return regionHtml === undefined ? "" : `<div ${name}>${regionHtml}</div>`;
|
|
72
|
-
};
|
|
73
75
|
return {
|
|
74
76
|
ok: true,
|
|
75
|
-
html:
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
].join(""),
|
|
77
|
+
html: composeLayoutHtml({
|
|
78
|
+
header: cleanedHtml["data-header"] ?? "",
|
|
79
|
+
signature: cleanedHtml["data-signature"] ?? "",
|
|
80
|
+
footer: cleanedHtml["data-footer"] ?? "",
|
|
81
|
+
}),
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
export function readLayoutRegions(html) {
|
|
@@ -88,12 +89,22 @@ export function readLayoutRegions(html) {
|
|
|
88
89
|
footer: innerHtml["data-footer"] ?? "",
|
|
89
90
|
};
|
|
90
91
|
}
|
|
92
|
+
// Empty regions are left out, the form the sanitizer stores.
|
|
93
|
+
export function composeLayoutHtml(regions) {
|
|
94
|
+
const part = (name, regionHtml) => regionHtml.trim() === "" ? "" : `<div ${name}>${regionHtml}</div>`;
|
|
95
|
+
return [
|
|
96
|
+
part("data-header", regions.header),
|
|
97
|
+
"<div data-content></div>",
|
|
98
|
+
part("data-signature", regions.signature),
|
|
99
|
+
part("data-footer", regions.footer),
|
|
100
|
+
].join("");
|
|
101
|
+
}
|
|
91
102
|
function rejected(violationItem) {
|
|
92
103
|
return { ok: false, violations: [violationItem] };
|
|
93
104
|
}
|
|
94
105
|
function sanitizeMailLayout(scope, contentFormat, content) {
|
|
95
106
|
if (contentFormat === "html")
|
|
96
|
-
return
|
|
107
|
+
return refusePrintOnlyFeatures(sanitizeLayoutHtml(content));
|
|
97
108
|
if (contentFormat !== "mjml") {
|
|
98
109
|
return rejected(violation("layout_requires_mjml_format", contentFormat, `Templates of kind mail-layout require contentFormat mjml or html, got "${contentFormat}"`));
|
|
99
110
|
}
|
|
@@ -105,6 +116,22 @@ function sanitizeMailLayout(scope, contentFormat, content) {
|
|
|
105
116
|
}
|
|
106
117
|
return { ok: true, content };
|
|
107
118
|
}
|
|
119
|
+
// The shared document model survives the rebuild in a mail layout, but only a PDF applies print styling.
|
|
120
|
+
function refusePrintOnlyFeatures(result) {
|
|
121
|
+
if (!result.ok)
|
|
122
|
+
return result;
|
|
123
|
+
const found = withParsedDocument(result.html, scanPrintOnlyFeatures);
|
|
124
|
+
const selectors = [
|
|
125
|
+
...found.printStyleSelectors,
|
|
126
|
+
...(found.hasImagesBlock ? [IMAGES_BLOCK_SELECTOR] : []),
|
|
127
|
+
];
|
|
128
|
+
if (selectors.length === 0)
|
|
129
|
+
return { ok: true, content: result.html };
|
|
130
|
+
return {
|
|
131
|
+
ok: false,
|
|
132
|
+
violations: selectors.map((selector) => violation("print_style_pdf_only", selector, `Print styling (${selector}) is only allowed in layouts of kind pdf-layout`)),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
108
135
|
function fromLayoutResult(result) {
|
|
109
136
|
return result.ok ? { ok: true, content: result.html } : result;
|
|
110
137
|
}
|
|
@@ -27,7 +27,9 @@ function moveRepeatHeadersIntoThead(table) {
|
|
|
27
27
|
row.removeAttribute(REPEAT_HEADER_ATTRIBUTE);
|
|
28
28
|
thead.appendChild(row);
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
// A colgroup has to stay the first child of the table.
|
|
31
|
+
const colgroup = Array.from(table.children).find((child) => child.tagName === "COLGROUP");
|
|
32
|
+
table.insertBefore(thead, colgroup === undefined ? table.firstChild : colgroup.nextSibling);
|
|
31
33
|
}
|
|
32
34
|
export function prepareDocumentForPrint(html) {
|
|
33
35
|
return withParsedDocument(html, (body) => {
|
|
@@ -20,6 +20,7 @@ import { executor } from "./handlers/shared.js";
|
|
|
20
20
|
import { evaluateTemplateWrite } from "./handlers/template-gates.js";
|
|
21
21
|
import { templateResourcesTable } from "./table.js";
|
|
22
22
|
import { activeStampChanges, servedStampChanges } from "./template-draft.js";
|
|
23
|
+
import { refuseReservedLayoutSlug } from "./template-edit-policy.js";
|
|
23
24
|
import { templateSlugSchema } from "./template-meta.js";
|
|
24
25
|
import { variablesFromSchema } from "./template-validation.js";
|
|
25
26
|
import { TEXT_BLOCK_KIND } from "./web/constants.js";
|
|
@@ -68,6 +69,9 @@ export async function seedSystemTemplate(db, opts) {
|
|
|
68
69
|
const slug = templateSlugSchema.safeParse(opts.slug);
|
|
69
70
|
if (!slug.success)
|
|
70
71
|
throw new Error(`${label} rejected: ${slug.error.issues[0]?.message}`);
|
|
72
|
+
if (refuseReservedLayoutSlug({ slug: opts.slug, kind: opts.kind }, "slug") !== null) {
|
|
73
|
+
throw new Error(`${label} rejected: reserved_layout_slug`);
|
|
74
|
+
}
|
|
71
75
|
const title = seedTitleColumn(opts, label);
|
|
72
76
|
const evaluated = evaluateTemplateWrite({
|
|
73
77
|
kind: opts.kind,
|
|
@@ -8,6 +8,7 @@ export type TemplateDeliveryPolicy = {
|
|
|
8
8
|
/** Kinds of collections mounted with an explicit `access`; their tenant rows are edited by design. */
|
|
9
9
|
readonly collectionKinds: readonly string[];
|
|
10
10
|
};
|
|
11
|
+
export declare function isTenantLayout(target: DeliveryTarget): boolean;
|
|
11
12
|
export declare function isTenantOverrideServed(policy: TemplateDeliveryPolicy, target: DeliveryTarget): boolean;
|
|
12
13
|
export declare function isServedByCollectionOnly(policy: TemplateDeliveryPolicy, target: DeliveryTarget): boolean;
|
|
13
14
|
export declare function isRowServed(policy: TemplateDeliveryPolicy, row: DeliveryTarget & {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { isPlainObject, propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
|
-
import { SYSTEM_TENANT_ID } from "./web/constants.js";
|
|
2
|
+
import { SYSTEM_TENANT_ID, TENANT_LAYOUT_SLUG_PREFIX } from "./web/constants.js";
|
|
3
3
|
import { TEMPLATE_RESOLVER_FEATURE } from "./web/qualified-names.js";
|
|
4
4
|
const NOTHING_UNLOCKED = { tenantEditable: [], collectionKinds: [] };
|
|
5
|
+
// Tenant-created layouts have no entry of their own: they are served and edited once the app unlocks any PDF template.
|
|
6
|
+
export function isTenantLayout(target) {
|
|
7
|
+
return target.kind === "pdf-layout" && target.slug.startsWith(TENANT_LAYOUT_SLUG_PREFIX);
|
|
8
|
+
}
|
|
9
|
+
function unlocksTenantLayouts(policy) {
|
|
10
|
+
return policy.tenantEditable.some((entry) => entry.kind === "document-pdf");
|
|
11
|
+
}
|
|
5
12
|
export function isTenantOverrideServed(policy, target) {
|
|
6
13
|
return (policy.collectionKinds.includes(target.kind) ||
|
|
14
|
+
(isTenantLayout(target) && unlocksTenantLayouts(policy)) ||
|
|
7
15
|
policy.tenantEditable.some((entry) => entry.kind === target.kind && entry.slug === target.slug));
|
|
8
16
|
}
|
|
9
17
|
// Served only because its kind belongs to a collection with `access`, not because the template
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type HandlerContext, type RoleAccessRule, type SessionUser } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { type WriteFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TemplateWriteScope } from "./layout-regions.ts";
|
|
4
|
+
import { type TemplateKind } from "./web/constants.ts";
|
|
4
5
|
export type TenantEditableTemplate = {
|
|
5
6
|
readonly kind: TemplateKind;
|
|
6
7
|
readonly slug: string;
|
|
@@ -19,4 +20,7 @@ export declare function mayEditTemplate(policy: TemplateEditPolicy, user: EditUs
|
|
|
19
20
|
export declare function refuseTemplateEdit(policy: TemplateEditPolicy, user: EditUser, target: EditTarget): WriteFailure | null;
|
|
20
21
|
export declare function refuseMissingTemplate(policy: TemplateEditPolicy, user: EditUser): WriteFailure | null;
|
|
21
22
|
export declare function refuseTemplateEditById(db: HandlerContext["db"], policy: TemplateEditPolicy, user: EditUser, tenantId: string, templateId: string): Promise<WriteFailure | null>;
|
|
23
|
+
export declare function mayEditTenantLayouts(policy: TemplateEditPolicy, user: EditUser): boolean;
|
|
24
|
+
export declare function refuseReservedSystemLayoutSlug(scope: TemplateWriteScope, target: EditTarget, path: string): WriteFailure | null;
|
|
25
|
+
export declare function refuseReservedLayoutSlug(target: EditTarget, path: string): WriteFailure | null;
|
|
22
26
|
export {};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { fetchOne } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import { hasAccess, } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
-
import { AccessDeniedError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
+
import { AccessDeniedError, ValidationError, writeFailure, } from "@cosmicdrift/kumiko-framework/errors";
|
|
4
4
|
import { templateResourcesTable } from "./table.js";
|
|
5
|
+
import { isTenantLayout } from "./template-delivery-policy.js";
|
|
5
6
|
import { isSystemAdmin } from "./template-draft.js";
|
|
7
|
+
import { TENANT_LAYOUT_SLUG_PREFIX } from "./web/constants.js";
|
|
6
8
|
import { TemplateResolverErrors } from "./web/qualified-names.js";
|
|
7
9
|
const SYSTEM_ADMIN_ROLE = "SystemAdmin";
|
|
8
10
|
export function templateEditAccess(entries) {
|
|
@@ -16,6 +18,8 @@ export function templateEditAccess(entries) {
|
|
|
16
18
|
export function mayEditTemplate(policy, user, target) {
|
|
17
19
|
if (isSystemAdmin(user))
|
|
18
20
|
return true;
|
|
21
|
+
if (isTenantLayout(target))
|
|
22
|
+
return mayEditTenantLayouts(policy, user);
|
|
19
23
|
const entry = policy.tenantEditable.find((candidate) => candidate.slug === target.slug && candidate.kind === target.kind);
|
|
20
24
|
return entry !== undefined && hasAccess(user, entry.access);
|
|
21
25
|
}
|
|
@@ -43,3 +47,27 @@ export async function refuseTemplateEditById(db, policy, user, tenantId, templat
|
|
|
43
47
|
? refuseMissingTemplate(policy, user)
|
|
44
48
|
: refuseTemplateEdit(policy, user, row);
|
|
45
49
|
}
|
|
50
|
+
// A tenant layout reaches every template that names it, so building one needs the right on all PDF
|
|
51
|
+
// templates (and at least one must exist: every() on an empty list is true).
|
|
52
|
+
export function mayEditTenantLayouts(policy, user) {
|
|
53
|
+
const pdfEntries = policy.tenantEditable.filter((entry) => entry.kind === "document-pdf");
|
|
54
|
+
return pdfEntries.length > 0 && pdfEntries.every((entry) => hasAccess(user, entry.access));
|
|
55
|
+
}
|
|
56
|
+
export function refuseReservedSystemLayoutSlug(scope, target, path) {
|
|
57
|
+
return scope === "system" ? refuseReservedLayoutSlug(target, path) : null;
|
|
58
|
+
}
|
|
59
|
+
// System layouts must not take a slug from the tenant namespace.
|
|
60
|
+
export function refuseReservedLayoutSlug(target, path) {
|
|
61
|
+
if (!isTenantLayout(target))
|
|
62
|
+
return null;
|
|
63
|
+
return writeFailure(new ValidationError({
|
|
64
|
+
fields: [
|
|
65
|
+
{
|
|
66
|
+
path,
|
|
67
|
+
code: "reserved_layout_slug",
|
|
68
|
+
i18nKey: "templateResolver.errors.template.reservedLayoutSlug",
|
|
69
|
+
params: { prefix: TENANT_LAYOUT_SLUG_PREFIX },
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
@@ -61,15 +61,40 @@ declare const mailLayoutMetaSchema: z.ZodObject<{
|
|
|
61
61
|
outline: "outline";
|
|
62
62
|
}>>;
|
|
63
63
|
}, z.core.$strict>;
|
|
64
|
-
declare const pdfLayoutMetaSchema: z.ZodObject<{
|
|
64
|
+
declare const pdfLayoutMetaSchema: z.ZodObject<{
|
|
65
|
+
margins: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
fontFamily: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
arial: "arial";
|
|
73
|
+
calibri: "calibri";
|
|
74
|
+
cambria: "cambria";
|
|
75
|
+
courier: "courier";
|
|
76
|
+
times: "times";
|
|
77
|
+
}>>;
|
|
78
|
+
fontSizePt: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
textColor: z.ZodOptional<z.ZodString>;
|
|
80
|
+
tableStyle: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
grid: "grid";
|
|
82
|
+
header: "header";
|
|
83
|
+
lines: "lines";
|
|
84
|
+
plain: "plain";
|
|
85
|
+
}>>;
|
|
86
|
+
tableHeaderBackground: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strict>;
|
|
65
88
|
export type MailTemplateMeta = z.infer<typeof mailMetaSchema>;
|
|
66
89
|
export type PdfTemplateMeta = z.infer<typeof pdfMetaSchema>;
|
|
67
90
|
export type MailLayoutMeta = z.infer<typeof mailLayoutMetaSchema>;
|
|
68
|
-
export type
|
|
91
|
+
export type PdfLayoutMeta = z.infer<typeof pdfLayoutMetaSchema>;
|
|
92
|
+
export type LayoutTemplateMeta = MailLayoutMeta | PdfLayoutMeta;
|
|
69
93
|
export type TemplateMeta = MailTemplateMeta | PdfTemplateMeta | LayoutTemplateMeta;
|
|
70
94
|
export declare function isMailTemplateMeta(meta: TemplateMeta | null): meta is MailTemplateMeta;
|
|
71
95
|
export declare function readPdfTemplateMeta(meta: TemplateMeta | null): PdfTemplateMeta | null;
|
|
72
96
|
export declare function readMailLayoutMeta(meta: unknown): MailLayoutMeta;
|
|
97
|
+
export declare function readPdfLayoutMeta(meta: unknown): PdfLayoutMeta;
|
|
73
98
|
export type TemplateMetaIssue = {
|
|
74
99
|
readonly path: string;
|
|
75
100
|
/** The setting the issue is about (`subject`), `meta` when it concerns the object as a whole. */
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { HEX_COLOR_PATTERN, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, } from "./web/constants.js";
|
|
3
|
+
import { DOCUMENT_FONTS } from "./web/document-fonts.js";
|
|
3
4
|
import { MAIL_TONES } from "./web/mail-constants.js";
|
|
4
5
|
import { MAIL_LAYOUT_ACCENT_LINES, MAIL_LAYOUT_BUTTON_STYLES, MAIL_LAYOUT_FONTS, MAIL_LAYOUT_WIDTHS, } from "./web/mail-layout-constants.js";
|
|
6
|
+
import { PDF_TABLE_STYLES } from "./web/pdf-constants.js";
|
|
5
7
|
// One or more kebab segments joined by ":" — notification templates are seeded
|
|
6
8
|
// under their qualified name `feature:notify:name`.
|
|
7
9
|
export const templateSlugSchema = z
|
|
@@ -39,6 +41,9 @@ const mailMetaSchema = z.preprocess(withoutLegacySender, z
|
|
|
39
41
|
})
|
|
40
42
|
.strict());
|
|
41
43
|
const marginMm = z.number().finite().min(0).max(100).optional();
|
|
44
|
+
const pdfMargins = z
|
|
45
|
+
.object({ top: marginMm, right: marginMm, bottom: marginMm, left: marginMm })
|
|
46
|
+
.strict();
|
|
42
47
|
// The file name ends up in a Content-Disposition header and on disk.
|
|
43
48
|
const FORBIDDEN_FILE_NAME = /[/\\";]|\.\./;
|
|
44
49
|
// Name of a PDF rendered into a mail; {{placeholders}} are filled at render time.
|
|
@@ -53,10 +58,7 @@ const pdfMetaSchema = z
|
|
|
53
58
|
orientation: z.enum(PDF_ORIENTATIONS).optional(),
|
|
54
59
|
printBackground: z.boolean().optional(),
|
|
55
60
|
layoutHeaderFooter: z.boolean().optional(),
|
|
56
|
-
margins:
|
|
57
|
-
.object({ top: marginMm, right: marginMm, bottom: marginMm, left: marginMm })
|
|
58
|
-
.strict()
|
|
59
|
-
.optional(),
|
|
61
|
+
margins: pdfMargins.optional(),
|
|
60
62
|
fileName: singleLine(200)
|
|
61
63
|
.min(1)
|
|
62
64
|
.refine((value) => !FORBIDDEN_FILE_NAME.test(value), 'must not contain / \\ " ; or ..')
|
|
@@ -81,7 +83,17 @@ const mailLayoutMetaSchema = z
|
|
|
81
83
|
buttonStyle: z.enum(MAIL_LAYOUT_BUTTON_STYLES).optional(),
|
|
82
84
|
})
|
|
83
85
|
.strict();
|
|
84
|
-
const
|
|
86
|
+
const hexColor = z.string().regex(HEX_COLOR_PATTERN, "must be a #rrggbb color");
|
|
87
|
+
const pdfLayoutMetaSchema = z
|
|
88
|
+
.object({
|
|
89
|
+
margins: pdfMargins.optional(),
|
|
90
|
+
fontFamily: z.enum(DOCUMENT_FONTS).optional(),
|
|
91
|
+
fontSizePt: z.number().finite().min(6).max(24).optional(),
|
|
92
|
+
textColor: hexColor.optional(),
|
|
93
|
+
tableStyle: z.enum(PDF_TABLE_STYLES).optional(),
|
|
94
|
+
tableHeaderBackground: hexColor.optional(),
|
|
95
|
+
})
|
|
96
|
+
.strict();
|
|
85
97
|
export function isMailTemplateMeta(meta) {
|
|
86
98
|
return meta !== null && "subject" in meta;
|
|
87
99
|
}
|
|
@@ -93,6 +105,10 @@ export function readMailLayoutMeta(meta) {
|
|
|
93
105
|
const parsed = mailLayoutMetaSchema.safeParse(meta ?? {});
|
|
94
106
|
return parsed.success ? parsed.data : {};
|
|
95
107
|
}
|
|
108
|
+
export function readPdfLayoutMeta(meta) {
|
|
109
|
+
const parsed = pdfLayoutMetaSchema.safeParse(meta ?? {});
|
|
110
|
+
return parsed.success ? parsed.data : {};
|
|
111
|
+
}
|
|
96
112
|
function valueAt(raw, path) {
|
|
97
113
|
let current = raw;
|
|
98
114
|
for (const key of path) {
|
|
@@ -12,6 +12,7 @@ import { collectRendererPlugins, createRendererFoundationApi, RendererError, } f
|
|
|
12
12
|
import { createTemplateResolverApi, isRowDeliveredTo, TemplateNotFoundError, } from "./api.js";
|
|
13
13
|
import { collectDocumentResourceKeys } from "./compile-document-body.js";
|
|
14
14
|
import { parseStoredJson } from "./handlers/template-gates.js";
|
|
15
|
+
import { defaultPdfLayoutSlug } from "./handlers/tenant-settings.js";
|
|
15
16
|
import { validateTemplateDraft } from "./handlers/validate.query.js";
|
|
16
17
|
import { readLayoutRegions, sanitizeLayoutHtml, } from "./layout-regions.js";
|
|
17
18
|
import { parseLinkedResourceEntries } from "./linked-resources.js";
|
|
@@ -19,7 +20,7 @@ import { buildDisplayHtml } from "./preview-display-html.js";
|
|
|
19
20
|
import { templateResourcesTable } from "./table.js";
|
|
20
21
|
import { deliveryPolicyOf } from "./template-delivery-policy.js";
|
|
21
22
|
import { isMailTemplateMeta, parseTemplateMeta, readPdfTemplateMeta, } from "./template-meta.js";
|
|
22
|
-
import { DEFAULT_MAIL_LAYOUT_SLUG,
|
|
23
|
+
import { DEFAULT_MAIL_LAYOUT_SLUG, MAIL_PREVIEW_MAX_BYTES, SYSTEM_TENANT_ID, } from "./web/constants.js";
|
|
23
24
|
import { TemplateResolverErrors } from "./web/qualified-names.js";
|
|
24
25
|
const SAMPLE_LINK = "https://example.com";
|
|
25
26
|
const SAMPLE_DATE = "2026-01-15";
|
|
@@ -59,12 +60,11 @@ function sampleRow(item, labelText, given = {}) {
|
|
|
59
60
|
return { ...given, ...row };
|
|
60
61
|
}
|
|
61
62
|
function sampleList(def, labelText) {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return rows;
|
|
63
|
+
const declared = (def.example ?? []).slice(0, SAMPLE_LIST_ROWS);
|
|
64
|
+
// Declared rows are the whole sample: padding them shows rows the data does not have.
|
|
65
|
+
if (declared.length > 0)
|
|
66
|
+
return declared.map((given) => sampleRow(def.item, labelText, given));
|
|
67
|
+
return Array.from({ length: SAMPLE_LIST_ROWS }, () => sampleRow(def.item, labelText));
|
|
68
68
|
}
|
|
69
69
|
function sampleValueFor(name, def, labelText) {
|
|
70
70
|
// An images variable has no sample: file ids are record data, never preview content.
|
|
@@ -246,7 +246,7 @@ async function renderDocumentPreview(ctx, user, args) {
|
|
|
246
246
|
html: content,
|
|
247
247
|
text: null,
|
|
248
248
|
attachments: [],
|
|
249
|
-
layout: await resolvePdfLayout(ctx, user, pdfMeta?.layoutSlug ??
|
|
249
|
+
layout: await resolvePdfLayout(ctx, user, pdfMeta?.layoutSlug ?? (await defaultPdfLayoutSlug(ctx, user.tenantId, input.locale)), input.locale),
|
|
250
250
|
sampleValues,
|
|
251
251
|
checks: [missingResourceCheck(validation.warnings.map((w) => w.detail)), requiredCheck],
|
|
252
252
|
validation,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
2
|
import { conditionScopeElement, withParsedDocument } from "./document-sanitizer.js";
|
|
3
|
+
import { COMPANY_PLACEHOLDERS } from "./web/constants.js";
|
|
3
4
|
import { DOCUMENT_CONDITION_ATTRIBUTE, isDocumentPlaceholderHref, isDocumentReferenceName, } from "./web/document-schema.js";
|
|
4
5
|
export const SYSTEM_PLACEHOLDERS = new Set([
|
|
5
6
|
"tenantName",
|
|
@@ -9,10 +10,16 @@ export const SYSTEM_PLACEHOLDERS = new Set([
|
|
|
9
10
|
]);
|
|
10
11
|
const PAGE_PLACEHOLDERS = ["page", "pages"];
|
|
11
12
|
const PAGED_KINDS = new Set(["document-pdf", "pdf-layout"]);
|
|
13
|
+
// A PDF has no signature or imprint block, so both stay empty there and are not offered.
|
|
14
|
+
const PDF_EMPTY_PLACEHOLDERS = new Set(["signature", "imprint"]);
|
|
12
15
|
export function systemPlaceholdersFor(kind) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
if (!PAGED_KINDS.has(kind))
|
|
17
|
+
return SYSTEM_PLACEHOLDERS;
|
|
18
|
+
return new Set([
|
|
19
|
+
...[...SYSTEM_PLACEHOLDERS].filter((name) => !PDF_EMPTY_PLACEHOLDERS.has(name)),
|
|
20
|
+
...PAGE_PLACEHOLDERS,
|
|
21
|
+
...COMPANY_PLACEHOLDERS,
|
|
22
|
+
]);
|
|
16
23
|
}
|
|
17
24
|
const BASE_RESOURCE_KEYS = ["logo"];
|
|
18
25
|
// Mirrors TemplateVariableDef: a stored or draft schema keeps its label and example, which the
|
|
@@ -2,6 +2,8 @@ export declare const RENDER_KINDS: readonly ["mail", "document-pdf", "image-snap
|
|
|
2
2
|
export type RenderKind = (typeof RENDER_KINDS)[number];
|
|
3
3
|
export declare const DOCUMENT_HTML_KINDS: readonly ["mail", "document-pdf"];
|
|
4
4
|
export type DocumentHtmlKind = (typeof DOCUMENT_HTML_KINDS)[number];
|
|
5
|
+
export declare const DOCUMENT_OPS_KINDS: readonly ["mail", "document-pdf", "pdf-layout"];
|
|
6
|
+
export type DocumentOpsKind = (typeof DOCUMENT_OPS_KINDS)[number];
|
|
5
7
|
export declare const NON_RENDER_KINDS: readonly ["notification", "text-block", "snippet", "ai-prompt", "mail-layout", "pdf-layout"];
|
|
6
8
|
export type NonRenderKind = (typeof NON_RENDER_KINDS)[number];
|
|
7
9
|
export declare const TEMPLATE_KINDS: readonly ["mail", "document-pdf", "image-snapshot", "notification", "text-block", "snippet", "ai-prompt", "mail-layout", "pdf-layout"];
|
|
@@ -22,9 +24,12 @@ export declare const TEMPLATE_STATUSES: readonly ["draft", "active", "archived"]
|
|
|
22
24
|
export type TemplateStatus = (typeof TEMPLATE_STATUSES)[number];
|
|
23
25
|
export declare const ACTIVE_TEMPLATE_STATUS = "active";
|
|
24
26
|
export { HEX_COLOR_PATTERN } from "./mail-layout-constants.ts";
|
|
25
|
-
export { PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, type PdfOrientation, type PdfPageFormat, } from "./pdf-constants.ts";
|
|
27
|
+
export { PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, type PdfOrientation, type PdfPageFormat, type PdfTableStyle, } from "./pdf-constants.ts";
|
|
26
28
|
export declare const DEFAULT_MAIL_LAYOUT_SLUG = "default";
|
|
27
29
|
export declare const DEFAULT_PDF_LAYOUT_SLUG = "default";
|
|
30
|
+
export declare const COMPANY_PLACEHOLDERS: readonly ["companyAddress", "companyPhone", "companyEmail", "companyWebsite", "companyRegister", "companyVatId", "companyManagement", "companyBank", "companyIban", "companyBic"];
|
|
31
|
+
export declare const MAX_SELECTED_TEMPLATES = 200;
|
|
32
|
+
export declare const DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY = "template-resolver:config:default-pdf-layout-slug";
|
|
28
33
|
export declare const MAIL_PREVIEW_MAX_BYTES: number;
|
|
29
34
|
export declare const TEST_MAIL_SUBJECT_PREFIX = "[TEST] ";
|
|
30
35
|
export declare const TEST_MAIL_NOTIFICATION_TYPE = "template-resolver:test-mail";
|
|
@@ -33,3 +38,4 @@ export declare const FALLBACK_LOCALE = "de";
|
|
|
33
38
|
export declare const DEFAULT_COLLECTION_ACCESS: {
|
|
34
39
|
readonly roles: readonly ["SystemAdmin"];
|
|
35
40
|
};
|
|
41
|
+
export declare const TENANT_LAYOUT_SLUG_PREFIX = "tenant-layout-";
|
|
@@ -9,6 +9,8 @@ export const RENDER_KINDS = ["mail", "document-pdf", "image-snapshot"];
|
|
|
9
9
|
// Kinds whose html body is a rich document: the server rebuilds it through the
|
|
10
10
|
// document schema on every write (see document-sanitizer.ts).
|
|
11
11
|
export const DOCUMENT_HTML_KINDS = ["mail", "document-pdf"];
|
|
12
|
+
// Kinds structured document ops can edit: the two document kinds plus the regions of a PDF layout.
|
|
13
|
+
export const DOCUMENT_OPS_KINDS = [...DOCUMENT_HTML_KINDS, "pdf-layout"];
|
|
12
14
|
// Kinds without a renderer plugin: `notification` is the retired sections-JSON
|
|
13
15
|
// notification kind, kept so rows stored before mails moved to `mail` stay
|
|
14
16
|
// valid on replay; nothing writes or renders it any more. `text-block` is the Markdown text store
|
|
@@ -54,9 +56,25 @@ export const TEMPLATE_SCOPES = ["system", "tenant"];
|
|
|
54
56
|
export const TEMPLATE_STATUSES = ["draft", "active", "archived"];
|
|
55
57
|
export const ACTIVE_TEMPLATE_STATUS = "active";
|
|
56
58
|
export { HEX_COLOR_PATTERN } from "./mail-layout-constants.js";
|
|
57
|
-
export { PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, } from "./pdf-constants.js";
|
|
59
|
+
export { PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, } from "./pdf-constants.js";
|
|
58
60
|
export const DEFAULT_MAIL_LAYOUT_SLUG = "default";
|
|
59
61
|
export const DEFAULT_PDF_LAYOUT_SLUG = "default";
|
|
62
|
+
// Same names as the tenant feature's company config keys: the placeholder is the key name.
|
|
63
|
+
export const COMPANY_PLACEHOLDERS = [
|
|
64
|
+
"companyAddress",
|
|
65
|
+
"companyPhone",
|
|
66
|
+
"companyEmail",
|
|
67
|
+
"companyWebsite",
|
|
68
|
+
"companyRegister",
|
|
69
|
+
"companyVatId",
|
|
70
|
+
"companyManagement",
|
|
71
|
+
"companyBank",
|
|
72
|
+
"companyIban",
|
|
73
|
+
"companyBic",
|
|
74
|
+
];
|
|
75
|
+
export const MAX_SELECTED_TEMPLATES = 200;
|
|
76
|
+
// Tenant setting that picks the layout of PDF templates which name none.
|
|
77
|
+
export const DEFAULT_PDF_LAYOUT_SLUG_CONFIG_KEY = "template-resolver:config:default-pdf-layout-slug";
|
|
60
78
|
// The mail transport enforces no size limit of its own; 10 MiB is a common provider ceiling.
|
|
61
79
|
export const MAIL_PREVIEW_MAX_BYTES = 10 * 1024 * 1024;
|
|
62
80
|
export const TEST_MAIL_SUBJECT_PREFIX = "[TEST] ";
|
|
@@ -69,3 +87,5 @@ export { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-types/identifiers";
|
|
|
69
87
|
export const FALLBACK_LOCALE = "de";
|
|
70
88
|
// A collection mounted without `access` is maintained by the platform only; TenantAdmin access is an explicit mount decision.
|
|
71
89
|
export const DEFAULT_COLLECTION_ACCESS = { roles: ["SystemAdmin"] };
|
|
90
|
+
// Tenant-created PDF layouts live under this slug prefix; system layouts may not use it, so the two namespaces never meet.
|
|
91
|
+
export const TENANT_LAYOUT_SLUG_PREFIX = "tenant-layout-";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type DocumentToolbarBlock = "image" | "table" | "button" | "divider" | "repeat" | "pageBreak" | "align" | "steps" | "images";
|
|
2
2
|
export declare const MAIL_DOCUMENT_BLOCKS: readonly ["image", "table", "button", "divider", "repeat", "steps"];
|
|
3
3
|
export declare const PDF_DOCUMENT_BLOCKS: readonly ["align", "image", "table", "divider", "repeat", "steps", "images", "pageBreak"];
|
|
4
|
+
export declare const PDF_LAYOUT_DOCUMENT_BLOCKS: ("align" | "divider" | "image" | "pageBreak" | "repeat" | "table")[];
|
|
4
5
|
/** Block set for a template-resource kind; every kind except "document-pdf" gets the mail set. */
|
|
5
6
|
export declare function documentBlocksForKind(kind: string | undefined): readonly DocumentToolbarBlock[];
|
|
@@ -16,6 +16,8 @@ export const PDF_DOCUMENT_BLOCKS = [
|
|
|
16
16
|
"images",
|
|
17
17
|
"pageBreak",
|
|
18
18
|
];
|
|
19
|
+
// A layout region has no per-document variables, so a steps block there could never show a stage and an images block no photos.
|
|
20
|
+
export const PDF_LAYOUT_DOCUMENT_BLOCKS = PDF_DOCUMENT_BLOCKS.filter((block) => block !== "steps" && block !== "images");
|
|
19
21
|
/** Block set for a template-resource kind; every kind except "document-pdf" gets the mail set. */
|
|
20
22
|
export function documentBlocksForKind(kind) {
|
|
21
23
|
return kind === "document-pdf" ? PDF_DOCUMENT_BLOCKS : MAIL_DOCUMENT_BLOCKS;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Extensions, NodeViewRenderer } from "@tiptap/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DocumentFrameControl } from "./document-frame-control.ts";
|
|
3
|
+
import { type FrameViewLabels } from "./document-frame-node-view.tsx";
|
|
4
|
+
import type { RepeatStripOptions } from "./document-repeat-strip.ts";
|
|
5
|
+
import type { DocumentPrintMode, DocumentResourcePreview } from "./document-toolbar-blocks.ts";
|
|
3
6
|
export declare const DOCUMENT_BLOCK_ATTRIBUTE = "data-document-block";
|
|
4
7
|
export type DocumentEditorLabels = {
|
|
5
8
|
readonly placeholder: string;
|
|
@@ -15,6 +18,11 @@ export type DocumentEditorLabels = {
|
|
|
15
18
|
readonly resourcePreviews?: Readonly<Record<string, DocumentResourcePreview>>;
|
|
16
19
|
/** Canvas chrome labels every block with its type. */
|
|
17
20
|
readonly blockLabels?: boolean;
|
|
21
|
+
readonly print?: DocumentPrintMode;
|
|
22
|
+
/** Tag text per frame kind; frames render as movable boxes only with these. */
|
|
23
|
+
readonly frameLabels?: FrameViewLabels;
|
|
24
|
+
readonly reportFrameControl?: (control: DocumentFrameControl | null) => void;
|
|
25
|
+
readonly repeatStrip?: RepeatStripOptions;
|
|
18
26
|
};
|
|
19
27
|
export declare function createVariableView(variableLabels: Readonly<Record<string, string>>, systemVariables: readonly string[]): NodeViewRenderer;
|
|
20
28
|
export declare function createDocumentEditorExtensions(labels: DocumentEditorLabels): Extensions;
|