@cosmicdrift/kumiko-samples 0.418.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/package.json +1 -1
- package/packages/bundled-features/package.json +6 -1
- package/packages/bundled-features/src/template-resolver/changes.json +38 -0
- package/packages/bundled-features/src/template-resolver/compile-document-body.ts +3 -8
- package/packages/bundled-features/src/template-resolver/compile-document-styles.ts +102 -0
- package/packages/bundled-features/src/template-resolver/document-frames.ts +25 -0
- package/packages/bundled-features/src/template-resolver/document-op-blocks.ts +568 -0
- package/packages/bundled-features/src/template-resolver/document-ops.ts +136 -126
- package/packages/bundled-features/src/template-resolver/document-print-only.ts +41 -0
- package/packages/bundled-features/src/template-resolver/document-sanitizer.ts +41 -19
- package/packages/bundled-features/src/template-resolver/feature.ts +15 -0
- package/packages/bundled-features/src/template-resolver/handlers/apply-layout.write.ts +137 -0
- package/packages/bundled-features/src/template-resolver/handlers/create-layout.write.ts +87 -0
- package/packages/bundled-features/src/template-resolver/handlers/document-base.ts +2 -2
- package/packages/bundled-features/src/template-resolver/handlers/document-blocks.query.ts +13 -8
- package/packages/bundled-features/src/template-resolver/handlers/document-region.ts +47 -0
- package/packages/bundled-features/src/template-resolver/handlers/failure-reason.ts +13 -0
- package/packages/bundled-features/src/template-resolver/handlers/import-bundle-system.write.ts +3 -0
- package/packages/bundled-features/src/template-resolver/handlers/layout-source.query.ts +17 -5
- package/packages/bundled-features/src/template-resolver/handlers/overview.query.ts +16 -4
- package/packages/bundled-features/src/template-resolver/handlers/patch-draft.write.ts +19 -6
- package/packages/bundled-features/src/template-resolver/handlers/publish-templates.write.ts +69 -0
- package/packages/bundled-features/src/template-resolver/handlers/set.write.ts +7 -0
- package/packages/bundled-features/src/template-resolver/handlers/template-write.ts +15 -3
- package/packages/bundled-features/src/template-resolver/handlers/tenant-settings.ts +122 -0
- package/packages/bundled-features/src/template-resolver/handlers/toggle-status.write.ts +25 -10
- package/packages/bundled-features/src/template-resolver/handlers/upsert-system.write.ts +7 -3
- package/packages/bundled-features/src/template-resolver/handlers/usage.query.ts +131 -18
- package/packages/bundled-features/src/template-resolver/handlers/validate.query.ts +10 -0
- package/packages/bundled-features/src/template-resolver/i18n.ts +3 -0
- package/packages/bundled-features/src/template-resolver/index.ts +29 -0
- package/packages/bundled-features/src/template-resolver/layout-regions.ts +54 -16
- package/packages/bundled-features/src/template-resolver/print-document.ts +3 -1
- package/packages/bundled-features/src/template-resolver/seeding.ts +4 -0
- package/packages/bundled-features/src/template-resolver/template-delivery-policy.ts +11 -1
- package/packages/bundled-features/src/template-resolver/template-edit-policy.ts +37 -1
- package/packages/bundled-features/src/template-resolver/template-meta.ts +25 -6
- package/packages/bundled-features/src/template-resolver/template-preview.ts +6 -7
- package/packages/bundled-features/src/template-resolver/template-validation.ts +10 -3
- package/packages/bundled-features/src/template-resolver/web/constants.ts +29 -0
- package/packages/bundled-features/src/template-resolver/web/document-blocks.ts +5 -0
- package/packages/bundled-features/src/template-resolver/web/document-editor-extensions.ts +34 -2
- package/packages/bundled-features/src/template-resolver/web/document-editor-fonts.ts +13 -0
- package/packages/bundled-features/src/template-resolver/web/document-fonts.ts +21 -0
- package/packages/bundled-features/src/template-resolver/web/document-frame-control.ts +428 -0
- package/packages/bundled-features/src/template-resolver/web/document-frame-node-view.tsx +207 -0
- package/packages/bundled-features/src/template-resolver/web/document-print-decorations.ts +196 -0
- package/packages/bundled-features/src/template-resolver/web/document-print-defaults.ts +59 -0
- package/packages/bundled-features/src/template-resolver/web/document-print-style.ts +246 -0
- package/packages/bundled-features/src/template-resolver/web/document-repeat-strip.ts +104 -0
- package/packages/bundled-features/src/template-resolver/web/document-schema.ts +29 -9
- package/packages/bundled-features/src/template-resolver/web/document-style-css.ts +107 -0
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-bubble.tsx +24 -2
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-content.tsx +66 -7
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-context.ts +13 -1
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-editor.tsx +24 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-helpers.ts +149 -4
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar-groups.tsx +290 -10
- package/packages/bundled-features/src/template-resolver/web/document-tiptap-toolbar.tsx +90 -8
- package/packages/bundled-features/src/template-resolver/web/document-toolbar-blocks.ts +20 -0
- package/packages/bundled-features/src/template-resolver/web/fontsource-css.d.ts +2 -0
- package/packages/bundled-features/src/template-resolver/web/i18n.ts +28 -0
- package/packages/bundled-features/src/template-resolver/web/index.ts +34 -0
- package/packages/bundled-features/src/template-resolver/web/pdf-constants.ts +6 -0
- package/packages/bundled-features/src/template-resolver/web/qualified-names.ts +7 -0
- package/packages/bundled-features/src/template-resolver/web/use-document-tiptap-model.ts +74 -5
- package/packages/bundled-features/src/tenant/company-config.ts +48 -0
- package/packages/bundled-features/src/tenant/feature.ts +11 -0
- package/packages/bundled-features/src/tenant/i18n.ts +14 -0
- package/samples/apps/ui-walkthrough/src/app/auth-constants.ts +51 -0
- package/samples/apps/ui-walkthrough/src/app/seed-print-editor-tenants.ts +118 -0
- package/samples/apps/ui-walkthrough/src/app/seed-templates.ts +2 -0
- package/samples/apps/ui-walkthrough/src/app/server.ts +9 -1
- package/samples/apps/ui-walkthrough/src/app/template-seed-data.ts +27 -1
- package/samples/apps/ui-walkthrough/src/run-config.ts +1 -0
- package/samples/apps/use-all-bundled/feature-manifest.json +236 -0
- package/samples/recipes/pdf-letterhead/README.md +23 -0
- package/samples/recipes/pdf-letterhead/package.json +12 -0
- package/samples/recipes/pdf-letterhead/src/letterhead.ts +92 -0
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { Translate } from "@cosmicdrift/kumiko-renderer/headless";
|
|
2
2
|
import { useEditor, useEditorState } from "@tiptap/react";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { createDocumentEditorExtensions } from "./document-editor-extensions.ts";
|
|
5
|
-
import
|
|
6
|
-
import type {
|
|
5
|
+
import type { DocumentFrameControl } from "./document-frame-control.ts";
|
|
6
|
+
import type { FrameViewLabels } from "./document-frame-node-view.tsx";
|
|
7
|
+
import {
|
|
8
|
+
activeStateOf,
|
|
9
|
+
type PanelKind,
|
|
10
|
+
previewsKey,
|
|
11
|
+
variableLabelOf,
|
|
12
|
+
} from "./document-tiptap-helpers.ts";
|
|
13
|
+
import type {
|
|
14
|
+
DocumentEditorProps,
|
|
15
|
+
DocumentPrintMode,
|
|
16
|
+
DocumentResourcePreview,
|
|
17
|
+
} from "./document-toolbar-blocks.ts";
|
|
7
18
|
import { useEditorHandleReport } from "./editor-handle.ts";
|
|
8
19
|
import { useStableByKey } from "./use-stable-by-key.ts";
|
|
9
20
|
|
|
@@ -21,14 +32,38 @@ export function documentEditorLabels(t: Translate) {
|
|
|
21
32
|
|
|
22
33
|
export type DocumentEditorLabels = ReturnType<typeof documentEditorLabels>;
|
|
23
34
|
|
|
35
|
+
function frameLabelsOf(t: Translate): FrameViewLabels {
|
|
36
|
+
return {
|
|
37
|
+
addressFormA: t("documentDesigner.editor.frame.addressFormA"),
|
|
38
|
+
addressFormB: t("documentDesigner.editor.frame.addressFormB"),
|
|
39
|
+
address: t("documentDesigner.editor.frame.address"),
|
|
40
|
+
text: t("documentDesigner.editor.frame.text"),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
function useDocumentExtensions(input: {
|
|
25
45
|
readonly labels: DocumentEditorLabels;
|
|
26
46
|
readonly canvas: boolean;
|
|
47
|
+
readonly print: DocumentPrintMode;
|
|
48
|
+
readonly frameLabels: FrameViewLabels | undefined;
|
|
49
|
+
readonly reportFrameControl: (control: DocumentFrameControl | null) => void;
|
|
50
|
+
readonly repeatStripName: (listLabel: string) => string;
|
|
51
|
+
readonly repeatHeaderLabel: string;
|
|
27
52
|
readonly variableLabels: Readonly<Record<string, string>>;
|
|
28
53
|
readonly systemVariables: readonly string[];
|
|
29
54
|
readonly resourcePreviews: Readonly<Record<string, DocumentResourcePreview>>;
|
|
30
55
|
}) {
|
|
31
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
canvas,
|
|
58
|
+
print,
|
|
59
|
+
reportFrameControl,
|
|
60
|
+
repeatStripName,
|
|
61
|
+
repeatHeaderLabel,
|
|
62
|
+
variableLabels,
|
|
63
|
+
systemVariables,
|
|
64
|
+
resourcePreviews,
|
|
65
|
+
} = input;
|
|
66
|
+
const frameLabels = useStableByKey(input.frameLabels, JSON.stringify(input.frameLabels ?? null));
|
|
32
67
|
const {
|
|
33
68
|
placeholderLabel,
|
|
34
69
|
imageLabel,
|
|
@@ -55,6 +90,16 @@ function useDocumentExtensions(input: {
|
|
|
55
90
|
systemVariables: stableSystem,
|
|
56
91
|
resourcePreviews: stablePreviews,
|
|
57
92
|
blockLabels: canvas,
|
|
93
|
+
print,
|
|
94
|
+
reportFrameControl,
|
|
95
|
+
...(print !== "none" && {
|
|
96
|
+
repeatStrip: {
|
|
97
|
+
label: (lists: readonly string[]) =>
|
|
98
|
+
repeatStripName(lists.map((list) => variableLabelOf(list, stableLabels)).join(", ")),
|
|
99
|
+
headerLabel: repeatHeaderLabel,
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
...(frameLabels !== undefined && { frameLabels }),
|
|
58
103
|
}),
|
|
59
104
|
[
|
|
60
105
|
placeholderLabel,
|
|
@@ -68,6 +113,11 @@ function useDocumentExtensions(input: {
|
|
|
68
113
|
stableSystem,
|
|
69
114
|
stablePreviews,
|
|
70
115
|
canvas,
|
|
116
|
+
print,
|
|
117
|
+
reportFrameControl,
|
|
118
|
+
repeatStripName,
|
|
119
|
+
repeatHeaderLabel,
|
|
120
|
+
frameLabels,
|
|
71
121
|
],
|
|
72
122
|
);
|
|
73
123
|
return { extensions, stableLabels };
|
|
@@ -75,8 +125,9 @@ function useDocumentExtensions(input: {
|
|
|
75
125
|
|
|
76
126
|
export type DocumentTiptapModelInput = Pick<
|
|
77
127
|
DocumentEditorProps,
|
|
78
|
-
"id" | "value" | "onChange" | "readOnly" | "onEditorReady"
|
|
128
|
+
"id" | "value" | "onChange" | "readOnly" | "onEditorReady" | "onFrameControlChange"
|
|
79
129
|
> & {
|
|
130
|
+
readonly print: DocumentPrintMode;
|
|
80
131
|
readonly variableLabels: Readonly<Record<string, string>>;
|
|
81
132
|
readonly systemVariables: readonly string[];
|
|
82
133
|
readonly resourcePreviews: Readonly<Record<string, DocumentResourcePreview>>;
|
|
@@ -89,9 +140,27 @@ export function useDocumentTiptapModel(input: DocumentTiptapModelInput, t: Trans
|
|
|
89
140
|
const [canvasScroller, setCanvasScroller] = useState<HTMLElement | null>(null);
|
|
90
141
|
const [showHtml, setShowHtml] = useState(false);
|
|
91
142
|
const labels = documentEditorLabels(t);
|
|
143
|
+
// Callers pass a fresh function per render; the extension list must not rebuild the editor for it.
|
|
144
|
+
const frameControlRef = useRef(input.onFrameControlChange);
|
|
145
|
+
frameControlRef.current = input.onFrameControlChange;
|
|
146
|
+
const translateRef = useRef(t);
|
|
147
|
+
translateRef.current = t;
|
|
148
|
+
const repeatStripName = useCallback(
|
|
149
|
+
(name: string) => translateRef.current("documentDesigner.editor.table.repeatStrip", { name }),
|
|
150
|
+
[],
|
|
151
|
+
);
|
|
152
|
+
const reportFrameControl = useCallback(
|
|
153
|
+
(control: DocumentFrameControl | null) => frameControlRef.current?.(control),
|
|
154
|
+
[],
|
|
155
|
+
);
|
|
92
156
|
const { extensions, stableLabels } = useDocumentExtensions({
|
|
93
157
|
labels,
|
|
94
158
|
canvas: input.canvas,
|
|
159
|
+
print: input.print,
|
|
160
|
+
frameLabels: input.print === "page" ? frameLabelsOf(t) : undefined,
|
|
161
|
+
reportFrameControl,
|
|
162
|
+
repeatStripName,
|
|
163
|
+
repeatHeaderLabel: t("template-resolver.documentEditor.repeatHeader"),
|
|
95
164
|
variableLabels: input.variableLabels,
|
|
96
165
|
systemVariables: input.systemVariables,
|
|
97
166
|
resourcePreviews: input.resourcePreviews,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ConfigKeyDefinition, createTenantConfig } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import type { NavIconKey } from "@cosmicdrift/kumiko-types/nav";
|
|
3
|
+
|
|
4
|
+
export const COMPANY_DATA_KEYS = [
|
|
5
|
+
"companyAddress",
|
|
6
|
+
"companyPhone",
|
|
7
|
+
"companyEmail",
|
|
8
|
+
"companyWebsite",
|
|
9
|
+
"companyRegister",
|
|
10
|
+
"companyVatId",
|
|
11
|
+
"companyManagement",
|
|
12
|
+
"companyBank",
|
|
13
|
+
"companyIban",
|
|
14
|
+
"companyBic",
|
|
15
|
+
] as const;
|
|
16
|
+
export type CompanyDataKey = (typeof COMPANY_DATA_KEYS)[number];
|
|
17
|
+
|
|
18
|
+
export const COMPANY_SECTION_I18N_KEY = "tenant.company.section";
|
|
19
|
+
|
|
20
|
+
const COMPANY_KEY_ICONS: Readonly<Record<CompanyDataKey, NavIconKey>> = {
|
|
21
|
+
companyAddress: "map-pin",
|
|
22
|
+
companyPhone: "phone",
|
|
23
|
+
companyEmail: "mail",
|
|
24
|
+
companyWebsite: "link",
|
|
25
|
+
companyRegister: "file",
|
|
26
|
+
companyVatId: "receipt",
|
|
27
|
+
companyManagement: "user",
|
|
28
|
+
companyBank: "building",
|
|
29
|
+
companyIban: "coins",
|
|
30
|
+
companyBic: "hash",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function companyI18nKey(key: CompanyDataKey): string {
|
|
34
|
+
return `tenant.company.${key}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Printed on documents (letterhead, footer); the generated settings screen groups them in one section.
|
|
38
|
+
export function companyDataConfig(key: CompanyDataKey): ConfigKeyDefinition<"text"> {
|
|
39
|
+
return createTenantConfig("text", {
|
|
40
|
+
default: "",
|
|
41
|
+
mask: {
|
|
42
|
+
title: companyI18nKey(key),
|
|
43
|
+
icon: COMPANY_KEY_ICONS[key],
|
|
44
|
+
order: 10 + COMPANY_DATA_KEYS.indexOf(key),
|
|
45
|
+
section: COMPANY_SECTION_I18N_KEY,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
i18nKey,
|
|
15
15
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
16
16
|
import { TENANT_BOOT_RULES } from "./boot-rules.ts";
|
|
17
|
+
import { companyDataConfig } from "./company-config.ts";
|
|
17
18
|
import { activeTenantIdsQuery } from "./handlers/active-tenant-ids.query.ts";
|
|
18
19
|
import { addMemberWrite } from "./handlers/add-member.write.ts";
|
|
19
20
|
import { cancelInvitationWrite } from "./handlers/cancel-invitation.write.ts";
|
|
@@ -103,6 +104,16 @@ export function createTenantFeature(options?: TenantFeatureOptions): FeatureDefi
|
|
|
103
104
|
keys: {
|
|
104
105
|
// Core tenant settings — tenant admins can change them; all users can read them.
|
|
105
106
|
companyName: createTenantConfig("text", { default: "" }),
|
|
107
|
+
companyAddress: companyDataConfig("companyAddress"),
|
|
108
|
+
companyPhone: companyDataConfig("companyPhone"),
|
|
109
|
+
companyEmail: companyDataConfig("companyEmail"),
|
|
110
|
+
companyWebsite: companyDataConfig("companyWebsite"),
|
|
111
|
+
companyRegister: companyDataConfig("companyRegister"),
|
|
112
|
+
companyVatId: companyDataConfig("companyVatId"),
|
|
113
|
+
companyManagement: companyDataConfig("companyManagement"),
|
|
114
|
+
companyBank: companyDataConfig("companyBank"),
|
|
115
|
+
companyIban: companyDataConfig("companyIban"),
|
|
116
|
+
companyBic: companyDataConfig("companyBic"),
|
|
106
117
|
// Curated subset of IANA time zones covering the most relevant practical cases.
|
|
107
118
|
// Extend it when a real need arises.
|
|
108
119
|
timezone: createTenantConfig("select", {
|
|
@@ -7,6 +7,20 @@ export const TENANT_I18N: Readonly<Record<string, LocalizedString>> = {
|
|
|
7
7
|
"screen:invite-create.title": { en: "New invitation" },
|
|
8
8
|
"screen:member-roles-edit.title": { en: "Edit roles" },
|
|
9
9
|
"tenant.nav.members": { en: "Team" },
|
|
10
|
+
"tenant.company.section": { en: "Company details" },
|
|
11
|
+
"screen:tenant-tenant.title": { en: "Company details" },
|
|
12
|
+
"screen:tenant-system.title": { en: "Company details of all tenants" },
|
|
13
|
+
"tenant.settings": { en: "Company details" },
|
|
14
|
+
"tenant.company.companyAddress": { en: "Address" },
|
|
15
|
+
"tenant.company.companyPhone": { en: "Phone" },
|
|
16
|
+
"tenant.company.companyEmail": { en: "Email" },
|
|
17
|
+
"tenant.company.companyWebsite": { en: "Website" },
|
|
18
|
+
"tenant.company.companyRegister": { en: "Commercial register" },
|
|
19
|
+
"tenant.company.companyVatId": { en: "VAT ID" },
|
|
20
|
+
"tenant.company.companyManagement": { en: "Management" },
|
|
21
|
+
"tenant.company.companyBank": { en: "Bank" },
|
|
22
|
+
"tenant.company.companyIban": { en: "IBAN" },
|
|
23
|
+
"tenant.company.companyBic": { en: "BIC" },
|
|
10
24
|
"tenant.members.actions.editRoles": { en: "Edit roles" },
|
|
11
25
|
"tenant.members.col.email": { en: "Email" },
|
|
12
26
|
"tenant.members.col.roles": { en: "Roles" },
|
|
@@ -28,6 +28,57 @@ export const TENANT_ADMIN_PASSWORD = "nordlicht-berger";
|
|
|
28
28
|
export const PLATFORM_ADMIN_EMAIL = "plattform@kumiko.dev";
|
|
29
29
|
export const PLATFORM_ADMIN_PASSWORD = "kumiko-plattform";
|
|
30
30
|
|
|
31
|
+
// Tenants of the print-editor e2e specs. Specs may share a tenant they only read; whatever a test
|
|
32
|
+
// writes lives in a tenant no parallel test reads, so no test sees a layout, template or setting
|
|
33
|
+
// change mid-run.
|
|
34
|
+
export type PrintEditorTenant = {
|
|
35
|
+
readonly tenantId: string;
|
|
36
|
+
readonly tenantKey: string;
|
|
37
|
+
readonly tenantName: string;
|
|
38
|
+
readonly adminEmail: string;
|
|
39
|
+
readonly adminName: string;
|
|
40
|
+
};
|
|
41
|
+
export const PRINT_EDITOR_PASSWORD = "druckeditor-verwaltung";
|
|
42
|
+
export const PRINT_EDITOR_TENANTS = {
|
|
43
|
+
editor: {
|
|
44
|
+
tenantId: "00000000-0000-4000-8000-000000000011",
|
|
45
|
+
tenantKey: "hafenkontor",
|
|
46
|
+
tenantName: "Hafenkontor Verwaltung GmbH",
|
|
47
|
+
adminEmail: "t.brandt@hafenkontor-verwaltung.de",
|
|
48
|
+
adminName: "T. Brandt",
|
|
49
|
+
},
|
|
50
|
+
appearance: {
|
|
51
|
+
tenantId: "00000000-0000-4000-8000-000000000012",
|
|
52
|
+
tenantKey: "werftstrasse",
|
|
53
|
+
tenantName: "Werftstraße Immobilien KG",
|
|
54
|
+
adminEmail: "s.otto@werftstrasse-immobilien.de",
|
|
55
|
+
adminName: "S. Otto",
|
|
56
|
+
},
|
|
57
|
+
applySelected: {
|
|
58
|
+
tenantId: "00000000-0000-4000-8000-000000000013",
|
|
59
|
+
tenantKey: "gartenstadt",
|
|
60
|
+
tenantName: "Gartenstadt Wohnbau eG",
|
|
61
|
+
adminEmail: "m.krause@gartenstadt-wohnbau.de",
|
|
62
|
+
adminName: "M. Krause",
|
|
63
|
+
},
|
|
64
|
+
applyAll: {
|
|
65
|
+
tenantId: "00000000-0000-4000-8000-000000000014",
|
|
66
|
+
tenantKey: "marschland",
|
|
67
|
+
tenantName: "Marschland Hausverwaltung GmbH",
|
|
68
|
+
adminEmail: "j.feddersen@marschland-hausverwaltung.de",
|
|
69
|
+
adminName: "J. Feddersen",
|
|
70
|
+
},
|
|
71
|
+
// Same seed as `editor`. The print-editor tests that save a draft use it, so the parallel tests
|
|
72
|
+
// and specs reading `editor` never see a draft appear mid-test.
|
|
73
|
+
drafts: {
|
|
74
|
+
tenantId: "00000000-0000-4000-8000-000000000015",
|
|
75
|
+
tenantKey: "lotsenhaus",
|
|
76
|
+
tenantName: "Lotsenhaus Verwaltung GmbH",
|
|
77
|
+
adminEmail: "h.lange@lotsenhaus-verwaltung.de",
|
|
78
|
+
adminName: "H. Lange",
|
|
79
|
+
},
|
|
80
|
+
} as const satisfies Record<string, PrintEditorTenant>;
|
|
81
|
+
|
|
31
82
|
// Signs the unsubscribe links of the sample's mails; the e2e signs its own links with it.
|
|
32
83
|
// A real app reads it from its secret store.
|
|
33
84
|
export const UNSUBSCRIBE_SECRET = "ui-walkthrough-unsubscribe-secret-sample-only";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// One tenant per print-editor e2e spec (see PRINT_EDITOR_TENANTS). Everything goes through the
|
|
2
|
+
// template and config write handlers, never straight into the tables.
|
|
3
|
+
|
|
4
|
+
import { seedAdmin } from "@cosmicdrift/kumiko-bundled-features/auth-email-password/seeding";
|
|
5
|
+
import {
|
|
6
|
+
TemplateResolverHandlers,
|
|
7
|
+
TemplateResolverQueries,
|
|
8
|
+
} from "@cosmicdrift/kumiko-bundled-features/template-resolver";
|
|
9
|
+
import type { SeedFn } from "@cosmicdrift/kumiko-dev-server";
|
|
10
|
+
import type { SessionUser, TenantId } from "@cosmicdrift/kumiko-framework/engine";
|
|
11
|
+
import {
|
|
12
|
+
PRINT_EDITOR_PASSWORD,
|
|
13
|
+
PRINT_EDITOR_TENANTS,
|
|
14
|
+
type PrintEditorTenant,
|
|
15
|
+
} from "./auth-constants";
|
|
16
|
+
import {
|
|
17
|
+
type SeedTemplate,
|
|
18
|
+
SYSTEM_PDF_LAYOUT,
|
|
19
|
+
TENANT_UTILITY_STATEMENT,
|
|
20
|
+
} from "./template-seed-data";
|
|
21
|
+
|
|
22
|
+
const COMPANY_DATA = {
|
|
23
|
+
"company-address": "Kaistraße 18\n20457 Hamburg",
|
|
24
|
+
"company-phone": "+49 40 5550 1100",
|
|
25
|
+
"company-email": "verwaltung@hafenkontor-beispiel.de",
|
|
26
|
+
"company-register": "HRB 120045 Amtsgericht Hamburg",
|
|
27
|
+
"company-iban": "DE89 3704 0044 0532 0130 00",
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
const LETTER_MARGINS_MM = { top: 32, right: 22, bottom: 27, left: 26 } as const;
|
|
31
|
+
|
|
32
|
+
// Follows the tenant default layout, since it names none of its own.
|
|
33
|
+
const UTILITY_STATEMENT_WITHOUT_LAYOUT: SeedTemplate = {
|
|
34
|
+
...TENANT_UTILITY_STATEMENT,
|
|
35
|
+
meta: { pageFormat: "A4", fileName: "Nebenkostenabrechnung.pdf" },
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
async function seedTenant(
|
|
39
|
+
stack: Parameters<SeedFn>[0],
|
|
40
|
+
tenant: PrintEditorTenant,
|
|
41
|
+
setup: (user: SessionUser, write: WriteTemplate) => Promise<void>,
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
const tenantId = tenant.tenantId as TenantId;
|
|
44
|
+
const account = await seedAdmin(stack.db, {
|
|
45
|
+
email: tenant.adminEmail,
|
|
46
|
+
password: PRINT_EDITOR_PASSWORD,
|
|
47
|
+
displayName: tenant.adminName,
|
|
48
|
+
emailVerified: true,
|
|
49
|
+
memberships: [
|
|
50
|
+
{
|
|
51
|
+
tenantId,
|
|
52
|
+
tenantKey: tenant.tenantKey,
|
|
53
|
+
tenantName: tenant.tenantName,
|
|
54
|
+
roles: ["TenantAdmin"],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
const admin: SessionUser = {
|
|
59
|
+
id: account.id as SessionUser["id"],
|
|
60
|
+
tenantId,
|
|
61
|
+
roles: ["TenantAdmin"],
|
|
62
|
+
};
|
|
63
|
+
const overview = await stack.http.queryOk<{ rows: { origin: string }[] }>(
|
|
64
|
+
TemplateResolverQueries.overview,
|
|
65
|
+
{},
|
|
66
|
+
admin,
|
|
67
|
+
);
|
|
68
|
+
if (overview.rows.some((row) => row.origin === "tenant")) return;
|
|
69
|
+
const write: WriteTemplate = (template) =>
|
|
70
|
+
stack.http.writeOk(
|
|
71
|
+
TemplateResolverHandlers.upsertTenant,
|
|
72
|
+
{
|
|
73
|
+
slug: template.slug,
|
|
74
|
+
kind: template.kind,
|
|
75
|
+
locale: template.locale,
|
|
76
|
+
contentFormat: "html",
|
|
77
|
+
content: template.content,
|
|
78
|
+
status: "active",
|
|
79
|
+
...(template.title !== undefined && { title: template.title }),
|
|
80
|
+
...(template.meta !== undefined && { meta: template.meta }),
|
|
81
|
+
...(template.variableSchema !== undefined && { variableSchema: template.variableSchema }),
|
|
82
|
+
},
|
|
83
|
+
admin,
|
|
84
|
+
);
|
|
85
|
+
await setup(admin, write);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type WriteTemplate = (template: SeedTemplate) => Promise<unknown>;
|
|
89
|
+
|
|
90
|
+
export const seedPrintEditorTenants: SeedFn = async (stack) => {
|
|
91
|
+
const { editor, drafts, appearance, applySelected, applyAll } = PRINT_EDITOR_TENANTS;
|
|
92
|
+
const setCompanyData = async (user: SessionUser): Promise<void> => {
|
|
93
|
+
for (const [name, value] of Object.entries(COMPANY_DATA)) {
|
|
94
|
+
await stack.http.writeOk("config:write:set", { key: `tenant:config:${name}`, value }, user);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const setUpEditorTenant = async (user: SessionUser, write: WriteTemplate): Promise<void> => {
|
|
98
|
+
await setCompanyData(user);
|
|
99
|
+
await write(TENANT_UTILITY_STATEMENT);
|
|
100
|
+
// The ruler's margin marks read the layout's own margins.
|
|
101
|
+
await write({
|
|
102
|
+
...SYSTEM_PDF_LAYOUT,
|
|
103
|
+
meta: { margins: LETTER_MARGINS_MM },
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
await seedTenant(stack, editor, setUpEditorTenant);
|
|
108
|
+
await seedTenant(stack, drafts, setUpEditorTenant);
|
|
109
|
+
await seedTenant(stack, appearance, async (user) => {
|
|
110
|
+
await setCompanyData(user);
|
|
111
|
+
});
|
|
112
|
+
await seedTenant(stack, applySelected, async (_user, write) => {
|
|
113
|
+
await write(TENANT_UTILITY_STATEMENT);
|
|
114
|
+
});
|
|
115
|
+
await seedTenant(stack, applyAll, async (_user, write) => {
|
|
116
|
+
await write(UTILITY_STATEMENT_WITHOUT_LAYOUT);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
PAYMENT_REMINDER_TEMPLATES,
|
|
29
29
|
type SeedTemplate,
|
|
30
30
|
SYSTEM_AUTH_MAILS,
|
|
31
|
+
SYSTEM_BRIEFBOGEN_LAYOUT,
|
|
31
32
|
SYSTEM_INVOICE_DOCUMENTS,
|
|
32
33
|
SYSTEM_INVOICE_ISSUED,
|
|
33
34
|
SYSTEM_PDF_LAYOUT,
|
|
@@ -165,6 +166,7 @@ export const seedTemplates: SeedFn = async (stack) => {
|
|
|
165
166
|
platformAdmin,
|
|
166
167
|
);
|
|
167
168
|
await upsertSystem(SYSTEM_PDF_LAYOUT);
|
|
169
|
+
await upsertSystem(SYSTEM_BRIEFBOGEN_LAYOUT);
|
|
168
170
|
for (const mail of SYSTEM_AUTH_MAILS) await upsertSystem(mail);
|
|
169
171
|
await upsertSystem(SYSTEM_INVOICE_ISSUED);
|
|
170
172
|
await upsertSystem(SYSTEM_TERMS_CHANGED);
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
UNSUBSCRIBE_SECRET,
|
|
24
24
|
} from "./auth-constants";
|
|
25
25
|
import { seedTasks } from "./seed";
|
|
26
|
+
import { seedPrintEditorTenants } from "./seed-print-editor-tenants";
|
|
26
27
|
import { seedRental } from "./seed-rental";
|
|
27
28
|
import { seedTemplates } from "./seed-templates";
|
|
28
29
|
import { seedVehicles } from "./seed-vehicles";
|
|
@@ -35,7 +36,14 @@ import { seedVehicles } from "./seed-vehicles";
|
|
|
35
36
|
|
|
36
37
|
await runDevApp({
|
|
37
38
|
features: [...APP_FEATURES],
|
|
38
|
-
seeds: [
|
|
39
|
+
seeds: [
|
|
40
|
+
seedTasks,
|
|
41
|
+
seedRental,
|
|
42
|
+
seedVehicles,
|
|
43
|
+
seedTemplates,
|
|
44
|
+
seedPrintEditorTenants,
|
|
45
|
+
seedPlanTerms,
|
|
46
|
+
],
|
|
39
47
|
// PORT env var override for Playwright e2e runs (config points to 4174);
|
|
40
48
|
// otherwise local default 4173.
|
|
41
49
|
port: Number.parseInt(process.env["PORT"] ?? "4173", 10),
|
|
@@ -174,10 +174,36 @@ export const SYSTEM_PDF_LAYOUT: SeedTemplate = {
|
|
|
174
174
|
`<div data-header><table><tbody><tr><td><img data-resource="logo" alt="Nordlicht"></td><td><p data-align="right" data-size="small">Am Hafen 12 · 24103 Kiel</p></td></tr></tbody></table></div>`,
|
|
175
175
|
"<div data-content></div>",
|
|
176
176
|
"<div data-signature></div>",
|
|
177
|
-
`<div data-footer><p
|
|
177
|
+
`<div data-footer><table data-borders="none"><tbody><tr><td><p>${v("tenantName")}</p></td><td><p>${v("companyAddress")}</p></td><td><p>${v("companyIban")}</p></td><td><p data-align="right">Seite ${v("page")} von ${v("pages")}</p></td></tr></tbody></table></div>`,
|
|
178
178
|
].join(""),
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
+
// A second letterhead for the layout-transfer walkthrough: other header and footer text, serif
|
|
182
|
+
// body and its own margins, so a template that switches to it changes visibly.
|
|
183
|
+
export const BRIEFBOGEN_LAYOUT_SLUG = "briefbogen";
|
|
184
|
+
export const BRIEFBOGEN_HEADER_TEXT = "Hausverwaltung am Sund";
|
|
185
|
+
export const BRIEFBOGEN_FOOTER_TEXT = "Sundstraße 3 · 18439 Stralsund";
|
|
186
|
+
export const BRIEFBOGEN_MARGINS_MM = { top: 36, right: 24, bottom: 28, left: 30 } as const;
|
|
187
|
+
|
|
188
|
+
export const SYSTEM_BRIEFBOGEN_LAYOUT: SeedTemplate = {
|
|
189
|
+
slug: BRIEFBOGEN_LAYOUT_SLUG,
|
|
190
|
+
kind: "pdf-layout",
|
|
191
|
+
locale: "en",
|
|
192
|
+
title: "Briefbogen Stralsund",
|
|
193
|
+
content: [
|
|
194
|
+
`<div data-header><p data-align="center"><strong>${BRIEFBOGEN_HEADER_TEXT}</strong></p></div>`,
|
|
195
|
+
"<div data-content></div>",
|
|
196
|
+
"<div data-signature></div>",
|
|
197
|
+
`<div data-footer><p data-align="center">${BRIEFBOGEN_FOOTER_TEXT}</p><p data-align="center">Seite ${v("page")} von ${v("pages")}</p></div>`,
|
|
198
|
+
].join(""),
|
|
199
|
+
meta: {
|
|
200
|
+
margins: BRIEFBOGEN_MARGINS_MM,
|
|
201
|
+
fontFamily: "times",
|
|
202
|
+
fontSizePt: 11,
|
|
203
|
+
tableStyle: "lines",
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
181
207
|
export const TENANT_MAIL_LAYOUT_VERSIONS: readonly string[] = [
|
|
182
208
|
[
|
|
183
209
|
`<div data-header><p><strong>${v("tenantName")}</strong></p></div>`,
|
|
@@ -54,6 +54,7 @@ const TENANT_EDITABLE_TEMPLATES: readonly TenantEditableTemplate[] = [
|
|
|
54
54
|
slug: "default",
|
|
55
55
|
access: { roles: ["TenantAdmin"] },
|
|
56
56
|
})),
|
|
57
|
+
{ kind: "pdf-layout" as const, slug: "briefbogen", access: { roles: ["TenantAdmin"] } },
|
|
57
58
|
];
|
|
58
59
|
|
|
59
60
|
export const APP_FEATURES = [
|