@cosmicdrift/kumiko-bundled-features 0.419.0 → 0.421.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/auth-email-password/seeding.d.ts +11 -0
- package/dist/auth-email-password/seeding.js +17 -2
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/tenant-scoped-subject.d.ts +11 -0
- package/dist/shared/tenant-scoped-subject.js +18 -0
- package/dist/signature/feature.js +1 -1
- package/dist/signature/grant.d.ts +1 -1
- package/dist/signature/grant.js +7 -12
- package/dist/signature/png.js +35 -10
- package/dist/template-resolver/api.d.ts +2 -0
- package/dist/template-resolver/api.js +11 -7
- package/dist/template-resolver/compile-document-body.js +6 -5
- package/dist/template-resolver/compile-document-styles.js +42 -4
- package/dist/template-resolver/document-frames.d.ts +1 -0
- package/dist/template-resolver/document-frames.js +39 -2
- package/dist/template-resolver/document-op-blocks.d.ts +258 -24
- package/dist/template-resolver/document-op-blocks.js +111 -20
- package/dist/template-resolver/document-ops.d.ts +1030 -96
- package/dist/template-resolver/document-ops.js +32 -3
- package/dist/template-resolver/document-print-only.d.ts +2 -1
- package/dist/template-resolver/document-print-only.js +23 -0
- package/dist/template-resolver/document-sanitizer.d.ts +1 -1
- package/dist/template-resolver/document-sanitizer.js +6 -1
- package/dist/template-resolver/handlers/create-layout.write.js +1 -1
- package/dist/template-resolver/handlers/patch-draft.write.d.ts +512 -48
- package/dist/template-resolver/handlers/patch-draft.write.js +2 -1
- package/dist/template-resolver/handlers/tenant-settings.d.ts +7 -1
- package/dist/template-resolver/handlers/tenant-settings.js +25 -15
- package/dist/template-resolver/index.d.ts +3 -3
- package/dist/template-resolver/index.js +3 -3
- package/dist/template-resolver/template-meta.d.ts +10 -0
- package/dist/template-resolver/template-meta.js +7 -1
- package/dist/template-resolver/template-preview.js +16 -4
- package/dist/template-resolver/web/constants.d.ts +1 -1
- package/dist/template-resolver/web/constants.js +1 -1
- package/dist/template-resolver/web/document-editor-extensions.js +44 -19
- package/dist/template-resolver/web/document-editor.js +3 -1
- package/dist/template-resolver/web/document-print-decorations.js +53 -6
- package/dist/template-resolver/web/document-print-style.d.ts +81 -2
- package/dist/template-resolver/web/document-print-style.js +114 -2
- package/dist/template-resolver/web/document-repeat-strip.js +2 -26
- package/dist/template-resolver/web/document-schema.d.ts +5 -0
- package/dist/template-resolver/web/document-schema.js +50 -13
- package/dist/template-resolver/web/document-style-css.d.ts +35 -2
- package/dist/template-resolver/web/document-style-css.js +65 -1
- package/dist/template-resolver/web/document-tiptap-bubble.js +71 -8
- package/dist/template-resolver/web/document-tiptap-content.d.ts +1 -1
- package/dist/template-resolver/web/document-tiptap-content.js +5 -2
- package/dist/template-resolver/web/document-tiptap-editor.d.ts +1 -1
- package/dist/template-resolver/web/document-tiptap-editor.js +2 -2
- package/dist/template-resolver/web/document-tiptap-helpers.d.ts +32 -2
- package/dist/template-resolver/web/document-tiptap-helpers.js +99 -24
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.d.ts +11 -0
- package/dist/template-resolver/web/document-tiptap-toolbar-groups.js +41 -3
- package/dist/template-resolver/web/document-tiptap-toolbar.js +13 -8
- package/dist/template-resolver/web/i18n.js +2 -0
- package/dist/template-resolver/web/index.d.ts +1 -1
- package/dist/template-resolver/web/index.js +1 -1
- package/dist/template-resolver/web/pdf-constants.d.ts +5 -0
- package/dist/template-resolver/web/pdf-constants.js +6 -0
- package/dist/template-resolver/web/placeholder-text.d.ts +2 -1
- package/dist/template-resolver/web/placeholder-text.js +5 -2
- package/dist/tenant/seeding.d.ts +14 -0
- package/dist/tenant/seeding.js +44 -0
- package/package.json +19 -11
- package/src/signature/changes.json +6 -0
- package/src/template-resolver/changes.json +24 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { usePrimitives } from "@cosmicdrift/kumiko-renderer";
|
|
2
2
|
import type { Editor, JSONContent } from "@tiptap/core";
|
|
3
|
+
import type { Node as ProseMirrorNode } from "@tiptap/pm/model";
|
|
4
|
+
import type { DocumentRowLine } from "./document-style-css.ts";
|
|
3
5
|
import type { DocumentPrintBlock, DocumentPrintMode, DocumentResourcePreview, DocumentToolbarBlock } from "./document-toolbar-blocks.ts";
|
|
4
6
|
export declare const NO_LABELS: Readonly<Record<string, string>>;
|
|
5
7
|
export declare const NO_NAMES: readonly string[];
|
|
@@ -25,7 +27,15 @@ export type PrintBlockStyleState = {
|
|
|
25
27
|
export type PrintTableState = {
|
|
26
28
|
readonly bordersOff: boolean;
|
|
27
29
|
readonly cellBackground: string | null;
|
|
30
|
+
readonly cellPaddingMm: number | null;
|
|
31
|
+
readonly widthMm: number | null;
|
|
32
|
+
readonly align: string | null;
|
|
33
|
+
readonly lineAbove: DocumentRowLine | null;
|
|
34
|
+
readonly lineBelow: DocumentRowLine | null;
|
|
28
35
|
};
|
|
36
|
+
export declare const DEFAULT_ROW_LINE: DocumentRowLine;
|
|
37
|
+
export declare function setTableAttributes(editor: Editor, attributes: Readonly<Record<string, unknown>>): void;
|
|
38
|
+
export declare function setRowLine(editor: Editor, edge: "lineAbove" | "lineBelow", line: DocumentRowLine | null): void;
|
|
29
39
|
type TextStylePatch = {
|
|
30
40
|
readonly [K in keyof PrintTextStyleState]?: PrintTextStyleState[K];
|
|
31
41
|
};
|
|
@@ -38,6 +48,8 @@ export type RepeatTableState = {
|
|
|
38
48
|
readonly headerRepeats: boolean;
|
|
39
49
|
readonly firstRowPos: number;
|
|
40
50
|
};
|
|
51
|
+
export declare function repeatListsOf(table: ProseMirrorNode): string[];
|
|
52
|
+
export declare function toggleRepeatHeaderAt(editor: Editor, firstRowPos: number): void;
|
|
41
53
|
export declare function findRepeatTable(editor: Editor): RepeatTableState | null;
|
|
42
54
|
export declare function toggleRepeatHeader(editor: Editor): void;
|
|
43
55
|
declare const PARAGRAPH_STYLES: readonly ["paragraph", "1", "2", "3"];
|
|
@@ -67,10 +79,28 @@ export declare function activeStateOf(e: Editor, showHtml: boolean): {
|
|
|
67
79
|
printTable: PrintTableState | null;
|
|
68
80
|
};
|
|
69
81
|
export type Primitives = ReturnType<typeof usePrimitives>;
|
|
70
|
-
export type
|
|
71
|
-
readonly type: "resource"
|
|
82
|
+
export type ResourceBlock = {
|
|
83
|
+
readonly type: "resource";
|
|
72
84
|
readonly detail: string;
|
|
73
85
|
readonly bleed: boolean;
|
|
86
|
+
readonly widthMm: number | null;
|
|
87
|
+
readonly align: string | null;
|
|
74
88
|
};
|
|
89
|
+
export type ButtonBlock = {
|
|
90
|
+
readonly type: "button";
|
|
91
|
+
readonly detail: string;
|
|
92
|
+
};
|
|
93
|
+
export type DividerBlock = {
|
|
94
|
+
readonly type: "divider";
|
|
95
|
+
readonly color: string | null;
|
|
96
|
+
readonly weightPt: number | null;
|
|
97
|
+
};
|
|
98
|
+
export type VariableBlock = {
|
|
99
|
+
readonly type: "variable";
|
|
100
|
+
readonly detail: string;
|
|
101
|
+
readonly dateStyle: string | null;
|
|
102
|
+
};
|
|
103
|
+
export type SelectedBlock = ResourceBlock | ButtonBlock | DividerBlock | VariableBlock;
|
|
104
|
+
export declare function addPlainRowBelow(editor: Editor): void;
|
|
75
105
|
export type ActiveState = ReturnType<typeof activeStateOf>;
|
|
76
106
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
2
|
import { addressFrameContent, columnsTableContent, insertFrame, textFrameContent, } from "./document-frame-control.js";
|
|
3
|
+
import { readRowLineAttributes } from "./document-print-style.js";
|
|
3
4
|
export const NO_LABELS = {};
|
|
4
5
|
export const NO_NAMES = [];
|
|
5
6
|
export const NO_PREVIEWS = {};
|
|
@@ -27,6 +28,7 @@ export function printModeOf(blocks, hosted, canvas) {
|
|
|
27
28
|
export const FONT_SIZES_PT = [6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 24, 36];
|
|
28
29
|
export const LINE_HEIGHTS = [1, 1.15, 1.2, 1.25, 1.5, 2];
|
|
29
30
|
export const PARAGRAPH_SPACES_PT = [0, 3, 6, 8, 12, 18, 24];
|
|
31
|
+
export const DEFAULT_ROW_LINE = { color: "#000000", weightPt: 0.5 };
|
|
30
32
|
const TEXT_STYLE_MARK = "documentTextStyle";
|
|
31
33
|
function stringOrNull(value) {
|
|
32
34
|
return typeof value === "string" ? value : null;
|
|
@@ -72,7 +74,45 @@ function printTableOf(e) {
|
|
|
72
74
|
break;
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
const row = readRowLineAttributes(rowNodeOf(e)?.attrs ?? {});
|
|
78
|
+
return {
|
|
79
|
+
bordersOff: table.attrs["borders"] === "none",
|
|
80
|
+
cellBackground,
|
|
81
|
+
cellPaddingMm: numberOrNull(table.attrs["cellPaddingMm"]),
|
|
82
|
+
widthMm: numberOrNull(table.attrs["widthMm"]),
|
|
83
|
+
align: stringOrNull(table.attrs["align"]),
|
|
84
|
+
lineAbove: row.lineAbove,
|
|
85
|
+
lineBelow: row.lineBelow,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function rowNodeOf(e) {
|
|
89
|
+
const { $from } = e.state.selection;
|
|
90
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
91
|
+
if ($from.node(depth).type.name === "tableRow")
|
|
92
|
+
return $from.node(depth);
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
// The table's own print attributes; an empty field removes the attribute again.
|
|
97
|
+
export function setTableAttributes(editor, attributes) {
|
|
98
|
+
const table = tableLocationOf(editor);
|
|
99
|
+
if (table === null)
|
|
100
|
+
return;
|
|
101
|
+
editor
|
|
102
|
+
.chain()
|
|
103
|
+
.focus()
|
|
104
|
+
.command(({ tr }) => {
|
|
105
|
+
tr.setNodeMarkup(table.pos, undefined, { ...table.attrs, ...attributes });
|
|
106
|
+
return true;
|
|
107
|
+
})
|
|
108
|
+
.run();
|
|
109
|
+
}
|
|
110
|
+
export function setRowLine(editor, edge, line) {
|
|
111
|
+
editor
|
|
112
|
+
.chain()
|
|
113
|
+
.focus()
|
|
114
|
+
.updateAttributes("tableRow", { [edge]: line })
|
|
115
|
+
.run();
|
|
76
116
|
}
|
|
77
117
|
export function setPrintTextStyle(editor, patch) {
|
|
78
118
|
const next = { ...printTextStyleOf(editor), ...patch };
|
|
@@ -114,6 +154,31 @@ export function insertPrintBlock(editor, block) {
|
|
|
114
154
|
else
|
|
115
155
|
editor.chain().focus().insertContent(columnsTableContent()).run();
|
|
116
156
|
}
|
|
157
|
+
export function repeatListsOf(table) {
|
|
158
|
+
const lists = [];
|
|
159
|
+
table.forEach((row) => {
|
|
160
|
+
const each = row.attrs["each"];
|
|
161
|
+
if (typeof each === "string" && each !== "" && !lists.includes(each))
|
|
162
|
+
lists.push(each);
|
|
163
|
+
});
|
|
164
|
+
return lists;
|
|
165
|
+
}
|
|
166
|
+
export function toggleRepeatHeaderAt(editor, firstRowPos) {
|
|
167
|
+
editor
|
|
168
|
+
.chain()
|
|
169
|
+
.focus()
|
|
170
|
+
.command(({ tr }) => {
|
|
171
|
+
const row = tr.doc.nodeAt(firstRowPos);
|
|
172
|
+
if (row === null)
|
|
173
|
+
return false;
|
|
174
|
+
tr.setNodeMarkup(firstRowPos, undefined, {
|
|
175
|
+
...row.attrs,
|
|
176
|
+
repeatHeader: row.attrs["repeatHeader"] !== true,
|
|
177
|
+
});
|
|
178
|
+
return true;
|
|
179
|
+
})
|
|
180
|
+
.run();
|
|
181
|
+
}
|
|
117
182
|
// print-document moves the leading rows flagged repeatHeader into thead, so the
|
|
118
183
|
// toggle reads and writes the table's first row.
|
|
119
184
|
export function findRepeatTable(editor) {
|
|
@@ -122,12 +187,7 @@ export function findRepeatTable(editor) {
|
|
|
122
187
|
const node = $from.node(depth);
|
|
123
188
|
if (node.type.name !== "table")
|
|
124
189
|
continue;
|
|
125
|
-
const lists =
|
|
126
|
-
node.forEach((row) => {
|
|
127
|
-
const each = row.attrs["each"];
|
|
128
|
-
if (typeof each === "string" && each !== "" && !lists.includes(each))
|
|
129
|
-
lists.push(each);
|
|
130
|
-
});
|
|
190
|
+
const lists = repeatListsOf(node);
|
|
131
191
|
if (lists.length === 0)
|
|
132
192
|
return null;
|
|
133
193
|
return {
|
|
@@ -143,20 +203,7 @@ export function toggleRepeatHeader(editor) {
|
|
|
143
203
|
// skip: the cursor is not inside a repeat table
|
|
144
204
|
if (found === null)
|
|
145
205
|
return;
|
|
146
|
-
editor
|
|
147
|
-
.chain()
|
|
148
|
-
.focus()
|
|
149
|
-
.command(({ tr }) => {
|
|
150
|
-
const row = tr.doc.nodeAt(found.firstRowPos);
|
|
151
|
-
if (row === null)
|
|
152
|
-
return false;
|
|
153
|
-
tr.setNodeMarkup(found.firstRowPos, undefined, {
|
|
154
|
-
...row.attrs,
|
|
155
|
-
repeatHeader: !found.headerRepeats,
|
|
156
|
-
});
|
|
157
|
-
return true;
|
|
158
|
-
})
|
|
159
|
-
.run();
|
|
206
|
+
toggleRepeatHeaderAt(editor, found.firstRowPos);
|
|
160
207
|
}
|
|
161
208
|
const PARAGRAPH_STYLES = ["paragraph", "1", "2", "3"];
|
|
162
209
|
export const HEADING_LEVELS = { "1": 1, "2": 2, "3": 3 };
|
|
@@ -204,12 +251,37 @@ function blockStyleOf(e) {
|
|
|
204
251
|
function selectedBlockOf(e) {
|
|
205
252
|
if (e.isActive("resource")) {
|
|
206
253
|
const attrs = e.getAttributes("resource");
|
|
207
|
-
return {
|
|
254
|
+
return {
|
|
255
|
+
type: "resource",
|
|
256
|
+
detail: String(attrs["resource"]),
|
|
257
|
+
bleed: attrs["bleed"] === true,
|
|
258
|
+
widthMm: numberOrNull(attrs["widthMm"]),
|
|
259
|
+
align: stringOrNull(attrs["align"]),
|
|
260
|
+
};
|
|
208
261
|
}
|
|
209
262
|
if (e.isActive("button")) {
|
|
210
|
-
return {
|
|
263
|
+
return {
|
|
264
|
+
type: "button",
|
|
265
|
+
detail: String(e.getAttributes("button")["href"]),
|
|
266
|
+
};
|
|
211
267
|
}
|
|
212
|
-
|
|
268
|
+
if (e.isActive("divider")) {
|
|
269
|
+
const attrs = e.getAttributes("divider");
|
|
270
|
+
return {
|
|
271
|
+
type: "divider",
|
|
272
|
+
color: stringOrNull(attrs["color"]),
|
|
273
|
+
weightPt: numberOrNull(attrs["weightPt"]),
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
if (e.isActive("variable")) {
|
|
277
|
+
const attrs = e.getAttributes("variable");
|
|
278
|
+
return {
|
|
279
|
+
type: "variable",
|
|
280
|
+
detail: String(attrs["name"]),
|
|
281
|
+
dateStyle: stringOrNull(attrs["dateStyle"]),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return null; // skip: no resource, button, divider or placeholder selected
|
|
213
285
|
}
|
|
214
286
|
export function activeStateOf(e, showHtml) {
|
|
215
287
|
return {
|
|
@@ -228,3 +300,6 @@ export function activeStateOf(e, showHtml) {
|
|
|
228
300
|
printTable: printTableOf(e),
|
|
229
301
|
};
|
|
230
302
|
}
|
|
303
|
+
export function addPlainRowBelow(editor) {
|
|
304
|
+
editor.chain().focus().addRowAfter().run();
|
|
305
|
+
}
|
|
@@ -7,5 +7,16 @@ export declare function iconButton(c: TiptapContext, label: string, icon: ReactN
|
|
|
7
7
|
export declare function renderParagraphStyleSelect(c: TiptapContext): ReactNode;
|
|
8
8
|
export declare function renderMarkButtons(c: TiptapContext): ReactNode;
|
|
9
9
|
export declare function renderListButtons(c: TiptapContext): ReactNode;
|
|
10
|
+
export declare function colorPicker(c: TiptapContext, testId: string, label: string, value: string | null, onPick: (color: string | null) => void): ReactNode;
|
|
10
11
|
export declare function renderPrintTextStyleGroup(c: TiptapContext): ReactNode;
|
|
12
|
+
export declare function renderNumberField(c: TiptapContext, spec: {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly value: number | null;
|
|
16
|
+
readonly range: {
|
|
17
|
+
readonly min: number;
|
|
18
|
+
readonly max: number;
|
|
19
|
+
};
|
|
20
|
+
readonly onChange: (value: number | null) => void;
|
|
21
|
+
}): ReactNode;
|
|
11
22
|
export declare function renderPrintTableGroup(c: TiptapContext): ReactNode;
|
|
@@ -3,7 +3,8 @@ import { cn, EditorToolbarPill } from "@cosmicdrift/kumiko-renderer/web";
|
|
|
3
3
|
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
4
4
|
import { Bold as BoldIcon, Italic as ItalicIcon, Link as LinkIcon, List, ListOrdered, MoveVertical, Underline as UnderlineIcon, } from "lucide-react";
|
|
5
5
|
import { DOCUMENT_FONT_LABELS, DOCUMENT_FONTS } from "./document-fonts.js";
|
|
6
|
-
import {
|
|
6
|
+
import { CELL_PADDING_MM_RANGE, DIVIDER_WEIGHT_PT_RANGE, DOCUMENT_TABLE_ALIGNMENTS, TABLE_WIDTH_MM_RANGE, } from "./document-print-style.js";
|
|
7
|
+
import { addPlainRowBelow, DEFAULT_ROW_LINE, FONT_SIZES_PT, LINE_HEIGHTS, PARAGRAPH_SPACES_PT, setPrintBlockStyle, setPrintTextStyle, setRowLine, setTableAttributes, toggleTableBorders, } from "./document-tiptap-helpers.js";
|
|
7
8
|
export function Separator({ compact = false }) {
|
|
8
9
|
return (_jsx("span", { "aria-hidden": "true", className: cn("h-5 w-px bg-border", compact ? "mx-0.5" : "mx-2") }));
|
|
9
10
|
}
|
|
@@ -59,7 +60,7 @@ function printSelect(c, spec) {
|
|
|
59
60
|
const fieldId = `${id}-${spec.key}`;
|
|
60
61
|
return (_jsxs(EditorToolbarPill, { children: [spec.leading, _jsx(FlatSelectBox, { flat: true, widthClass: "", testId: `document-toolbar-${spec.key}`, children: _jsx(Field, { id: fieldId, label: spec.label, hideLabel: true, children: _jsx(Input, { kind: "select", id: fieldId, name: spec.key, value: spec.value, onChange: spec.onChange, options: spec.options, display: "dropdown", disabled: readOnly }) }) })] }, spec.key));
|
|
61
62
|
}
|
|
62
|
-
function colorPicker(c, testId, label, value, onPick) {
|
|
63
|
+
export function colorPicker(c, testId, label, value, onPick) {
|
|
63
64
|
return (_jsxs(EditorToolbarPill, { children: [_jsx("input", { type: "color", "data-testid": testId, "aria-label": label, title: label, disabled: c.readOnly, value: value ?? FALLBACK_COLOR, onChange: (event) => onPick(event.target.value), className: "ml-1.5 h-5 w-5 cursor-pointer rounded border border-input bg-transparent p-0" }), _jsx("span", { className: "pr-2 pl-1.5 text-xs text-muted-foreground", children: label }), value !== null && (_jsx(c.Button, { type: "button", variant: "ghost", size: "sm", ariaLabel: c.t("documentDesigner.editor.colorReset"), title: c.t("documentDesigner.editor.colorReset"), testId: `${testId}-reset`, onClick: () => onPick(null), children: "\u00D7" }))] }));
|
|
64
65
|
}
|
|
65
66
|
export function renderPrintTextStyleGroup(c) {
|
|
@@ -103,12 +104,49 @@ export function renderPrintTextStyleGroup(c) {
|
|
|
103
104
|
}), block.spaceBeforePt !== null &&
|
|
104
105
|
space("space-before", t("documentDesigner.editor.spaceBefore"), defaults.spaceBefore, block.spaceBeforePt, "spaceBeforePt", defaults.formatSpaceBefore), space("space-after", t("documentDesigner.editor.spaceAfter"), defaults.spaceAfter, block.spaceAfterPt, "spaceAfterPt", defaults.formatSpaceAfter)] }));
|
|
105
106
|
}
|
|
107
|
+
const NUMBER_FIELD_CLASS = "w-16 [&_input]:h-5 [&_input]:px-1 [&_input]:text-[10px]";
|
|
108
|
+
export function renderNumberField(c, spec) {
|
|
109
|
+
const { Field, Input } = c;
|
|
110
|
+
return (_jsxs("span", { className: "inline-flex items-center gap-1", "data-testid": `${spec.id}-field`, children: [_jsx("span", { className: "whitespace-nowrap text-xs text-muted-foreground", children: spec.label }), _jsx("span", { className: NUMBER_FIELD_CLASS, children: _jsx(Field, { id: `${c.id}-${spec.id}`, label: spec.label, hideLabel: true, children: _jsx(Input, { kind: "number", id: `${c.id}-${spec.id}`, name: spec.id, value: spec.value ?? "", onChange: (value) => spec.onChange(value === null || value === undefined
|
|
111
|
+
? null
|
|
112
|
+
: Math.min(spec.range.max, Math.max(spec.range.min, value))), testId: spec.id }) }) })] }));
|
|
113
|
+
}
|
|
114
|
+
function renderRowLineControls(c, edge, line) {
|
|
115
|
+
const { t, editor, Button } = c;
|
|
116
|
+
const id = edge === "lineAbove" ? "document-row-line-above" : "document-row-line-below";
|
|
117
|
+
const label = t(`documentDesigner.editor.table.${edge}`);
|
|
118
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", pressed: line !== null, disabled: c.readOnly, testId: id, onClick: () => setRowLine(editor, edge, line === null ? DEFAULT_ROW_LINE : null), children: label }) }), line !== null && (_jsxs(_Fragment, { children: [colorPicker(c, `${id}-color`, label, line.color, (color) => setRowLine(editor, edge, { ...line, color: color ?? line.color })), renderNumberField(c, {
|
|
119
|
+
id: `${id}-weight`,
|
|
120
|
+
label: t("documentDesigner.editor.table.lineWeight"),
|
|
121
|
+
value: line.weightPt,
|
|
122
|
+
range: DIVIDER_WEIGHT_PT_RANGE,
|
|
123
|
+
onChange: (weightPt) => setRowLine(editor, edge, { ...line, weightPt: weightPt ?? line.weightPt }),
|
|
124
|
+
})] }))] }));
|
|
125
|
+
}
|
|
126
|
+
function renderTableLayoutControls(c, table) {
|
|
127
|
+
const { t, editor, Button } = c;
|
|
128
|
+
return (_jsxs(EditorToolbarPill, { children: [renderNumberField(c, {
|
|
129
|
+
id: "document-table-padding",
|
|
130
|
+
label: t("documentDesigner.editor.table.cellPadding"),
|
|
131
|
+
value: table.cellPaddingMm,
|
|
132
|
+
range: CELL_PADDING_MM_RANGE,
|
|
133
|
+
onChange: (cellPaddingMm) => setTableAttributes(editor, { cellPaddingMm }),
|
|
134
|
+
}), renderNumberField(c, {
|
|
135
|
+
id: "document-table-width",
|
|
136
|
+
label: t("documentDesigner.editor.table.width"),
|
|
137
|
+
value: table.widthMm,
|
|
138
|
+
range: TABLE_WIDTH_MM_RANGE,
|
|
139
|
+
onChange: (widthMm) => setTableAttributes(editor, { widthMm }),
|
|
140
|
+
}), DOCUMENT_TABLE_ALIGNMENTS.map((align) => (_jsx(Button, { type: "button", variant: "ghost", size: "sm", pressed: table.align === align, disabled: c.readOnly, testId: `document-table-align-${align}`, onClick: () => setTableAttributes(editor, { align: table.align === align ? null : align }), children: t(`documentDesigner.editor.imageAlign.${align}`) }, align)))] }));
|
|
141
|
+
}
|
|
106
142
|
export function renderPrintTableGroup(c) {
|
|
107
143
|
const { t, editor, Button } = c;
|
|
108
144
|
const table = c.activeState?.printTable ?? null;
|
|
109
145
|
if (table === null)
|
|
110
146
|
return null;
|
|
111
|
-
return (_jsxs(_Fragment, { children: [_jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", pressed: !table.bordersOff, disabled: c.readOnly, testId: "document-table-borders", onClick: () => toggleTableBorders(editor), children: t("documentDesigner.editor.tableBorders") }) }), colorPicker(c, "document-cell-color", t("documentDesigner.editor.cellColor"), table.cellBackground, (color) => editor.chain().focus().setCellAttribute("background", color).run()), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-add-
|
|
147
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", pressed: !table.bordersOff, disabled: c.readOnly, testId: "document-table-borders", onClick: () => toggleTableBorders(editor), children: t("documentDesigner.editor.tableBorders") }) }), renderTableLayoutControls(c, table), renderRowLineControls(c, "lineAbove", table.lineAbove), renderRowLineControls(c, "lineBelow", table.lineBelow), colorPicker(c, "document-cell-color", t("documentDesigner.editor.cellColor"), table.cellBackground, (color) => editor.chain().focus().setCellAttribute("background", color).run()), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-add-row", onClick: () => addPlainRowBelow(editor), children: t("documentDesigner.editor.table.addRow") }) }), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-remove-row", onClick: () => {
|
|
148
|
+
editor.chain().focus().deleteRow().run();
|
|
149
|
+
}, children: t("documentDesigner.editor.table.removeRow") }) }), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-add-column", onClick: () => {
|
|
112
150
|
editor.chain().focus().addColumnAfter().run();
|
|
113
151
|
}, children: t("documentDesigner.editor.table.addColumn") }) }), _jsx(EditorToolbarPill, { children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: c.readOnly, testId: "document-table-remove-column", onClick: () => {
|
|
114
152
|
editor.chain().focus().deleteColumn().run();
|
|
@@ -106,6 +106,18 @@ function renderPrintStyleRow(c) {
|
|
|
106
106
|
export function renderToolbarBar(c) {
|
|
107
107
|
return (_jsxs(_Fragment, { children: [renderMainToolbarRow(c), c.print !== "none" && renderPrintStyleRow(c)] }));
|
|
108
108
|
}
|
|
109
|
+
function renderPlaceholderButton(c) {
|
|
110
|
+
if (c.variables.length === 0)
|
|
111
|
+
return null;
|
|
112
|
+
return (_jsxs(_Fragment, { children: [_jsx(Separator, { compact: c.compact || c.canvas }), labelledButton(c, {
|
|
113
|
+
label: c.t("template-resolver.documentEditor.insertPlaceholder"),
|
|
114
|
+
icon: _jsx(Braces, { size: 16 }),
|
|
115
|
+
showIcon: true,
|
|
116
|
+
trailingIcon: c.canvas ? _jsx(ChevronDown, { size: 12 }) : undefined,
|
|
117
|
+
expanded: c.openPanel === "placeholder",
|
|
118
|
+
onClick: () => c.togglePanel("placeholder"),
|
|
119
|
+
})] }));
|
|
120
|
+
}
|
|
109
121
|
function renderMainToolbarRow(c) {
|
|
110
122
|
const { t, id, canvas, compact, ActionOverflowMenu } = c;
|
|
111
123
|
const blockButtons = blockButtonsOf(c);
|
|
@@ -117,12 +129,5 @@ function renderMainToolbarRow(c) {
|
|
|
117
129
|
const overflowItems = overflowItemsOf(c, menuBlocks, blockButtons);
|
|
118
130
|
return (_jsxs("div", { className: cn("flex items-center border-b border-input", canvas
|
|
119
131
|
? "min-h-9 flex-nowrap gap-0 overflow-hidden bg-background px-1.5 [&>*]:shrink-0 [&_button]:h-7 [&_button]:gap-1 [&_button]:px-1 [&_button]:text-xs"
|
|
120
|
-
: "flex-wrap gap-1 p-1"), children: [renderParagraphStyleSelect(c), _jsx(Separator, { compact: compact || canvas }), renderMarkButtons(c), _jsx(Separator, { compact: compact || canvas }), renderListButtons(c), _jsx(Separator, { compact: compact || canvas }),
|
|
121
|
-
label: t("template-resolver.documentEditor.insertPlaceholder"),
|
|
122
|
-
icon: _jsx(Braces, { size: 16 }),
|
|
123
|
-
showIcon: true,
|
|
124
|
-
trailingIcon: canvas ? _jsx(ChevronDown, { size: 12 }) : undefined,
|
|
125
|
-
expanded: c.openPanel === "placeholder",
|
|
126
|
-
onClick: () => c.togglePanel("placeholder"),
|
|
127
|
-
}), inlineBlocks.length > 0 && _jsx(Separator, { compact: compact || canvas }), inlineBlocks.map((block) => renderInlineBlock(c, block, blockButtons)), c.print !== "none" && _jsx(Separator, { compact: compact || canvas }), renderPrintBlockMenu(c), overflowItems.length > 0 && ActionOverflowMenu !== undefined && (_jsx("span", { className: "ml-auto shrink-0", children: _jsx(ActionOverflowMenu, { items: overflowItems, label: t("template-resolver.documentEditor.more"), testId: `${id}-toolbar-more` }) }))] }));
|
|
132
|
+
: "flex-wrap gap-1 p-1"), children: [renderParagraphStyleSelect(c), _jsx(Separator, { compact: compact || canvas }), renderMarkButtons(c), _jsx(Separator, { compact: compact || canvas }), renderListButtons(c), renderPlaceholderButton(c), inlineBlocks.length > 0 && _jsx(Separator, { compact: compact || canvas }), inlineBlocks.map((block) => renderInlineBlock(c, block, blockButtons)), c.print !== "none" && _jsx(Separator, { compact: compact || canvas }), renderPrintBlockMenu(c), overflowItems.length > 0 && ActionOverflowMenu !== undefined && (_jsx("span", { className: "ml-auto shrink-0", children: _jsx(ActionOverflowMenu, { items: overflowItems, label: t("template-resolver.documentEditor.more"), testId: `${id}-toolbar-more` }) }))] }));
|
|
128
133
|
}
|
|
@@ -63,6 +63,7 @@ export const defaultTranslations = {
|
|
|
63
63
|
"templateResolver.errors.unknown_placeholder": "The template uses an unknown placeholder.",
|
|
64
64
|
"templateResolver.errors.missing_required_placeholder": "A required placeholder is missing.",
|
|
65
65
|
"templateResolver.errors.document.frameNotTopLevel": "A frame must sit directly in the document body, not inside another block or a layout region.",
|
|
66
|
+
"templateResolver.errors.document.frameOutsidePage": "The frame “{detail}” extends past the largest supported paper size.",
|
|
66
67
|
"templateResolver.errors.document.buttonHrefNotPlaceholder": "The button target “{detail}” must be a placeholder.",
|
|
67
68
|
"templateResolver.errors.document.disallowedLinkHref": "Link target “{detail}” is not allowed; use https, http, mailto, tel, a relative path or a placeholder.",
|
|
68
69
|
"templateResolver.errors.document.relativeLinkWithoutBase": "Link target “{detail}” is relative, but mails and PDF documents have no base address; use an absolute https link.",
|
|
@@ -95,6 +96,7 @@ export const defaultTranslations = {
|
|
|
95
96
|
"templateResolver.errors.patch.textSpansFormatting": "The text {find} crosses a formatting change in the block; replace each formatted part on its own.",
|
|
96
97
|
"templateResolver.errors.patch.placeholderNotReplaceable": "The placeholder {find} cannot be replaced as text; set the text around it with another operation or remove the block.",
|
|
97
98
|
"templateResolver.errors.patch.blockNotAllowed": "The block type {type} is not available in {kind} templates.",
|
|
99
|
+
"templateResolver.errors.patch.bleedNotAllowed": "An image can only run to the paper edge (bleed) in the header or footer of a PDF layout, not in {kind}.",
|
|
98
100
|
"templateResolver.errors.patch.blockTypeMismatch": "This step needs a {expected} block, but the block is a {actual}.",
|
|
99
101
|
"templateResolver.errors.patch.invalidResourceKey": "The image key {resource} is not valid.",
|
|
100
102
|
"templateResolver.errors.patch.invalidButtonHref": "A button target must be a placeholder in double curly braces.",
|
|
@@ -10,7 +10,7 @@ export { FONT_SIZES_PT } from "./document-tiptap-helpers.ts";
|
|
|
10
10
|
export { type DocumentEditorChrome, type DocumentEditorHandle, type DocumentEditorProps, type DocumentLayoutValues, type DocumentPrintBlock, type DocumentPrintMode, type DocumentResourcePreview, type DocumentToolbarBlock, MAIL_DOCUMENT_BLOCKS, PDF_DOCUMENT_BLOCKS, } from "./document-toolbar-blocks.ts";
|
|
11
11
|
export { MAIL_TONES, type MailTone } from "./mail-constants.ts";
|
|
12
12
|
export { HEX_COLOR_PATTERN, MAIL_LAYOUT_ACCENT_LINES, MAIL_LAYOUT_BUTTON_STYLES, MAIL_LAYOUT_FONTS, MAIL_LAYOUT_WIDTHS, } from "./mail-layout-constants.ts";
|
|
13
|
-
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 PdfTableStyle, } from "./pdf-constants.ts";
|
|
13
|
+
export { PDF_CORNER_MARK_INSET_MM, PDF_CORNER_MARK_LEG_MM, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOLD_MARKS, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, type PdfFoldMarks, type PdfTableStyle, } from "./pdf-constants.ts";
|
|
14
14
|
export { PlaceholderLineEditor, type PlaceholderLineEditorProps, } from "./placeholder-line-editor-lazy.tsx";
|
|
15
15
|
export { previewTargetOfKind } from "./preview-targets.ts";
|
|
16
16
|
export { TemplateResolverErrors, TemplateResolverHandlers, TemplateResolverQueries, } from "./qualified-names.ts";
|
|
@@ -13,7 +13,7 @@ export { FONT_SIZES_PT } from "./document-tiptap-helpers.js";
|
|
|
13
13
|
export { MAIL_DOCUMENT_BLOCKS, PDF_DOCUMENT_BLOCKS, } from "./document-toolbar-blocks.js";
|
|
14
14
|
export { MAIL_TONES } from "./mail-constants.js";
|
|
15
15
|
export { HEX_COLOR_PATTERN, MAIL_LAYOUT_ACCENT_LINES, MAIL_LAYOUT_BUTTON_STYLES, MAIL_LAYOUT_FONTS, MAIL_LAYOUT_WIDTHS, } from "./mail-layout-constants.js";
|
|
16
|
-
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";
|
|
16
|
+
export { PDF_CORNER_MARK_INSET_MM, PDF_CORNER_MARK_LEG_MM, PDF_DEFAULT_FONT_SIZE_PT, PDF_DEFAULT_MARGIN_MM, PDF_FOLD_MARKS, PDF_FOOTER_MARGIN_MM, PDF_HEADER_MARGIN_MM, PDF_ORIENTATIONS, PDF_PAGE_FORMATS, PDF_TABLE_STYLES, } from "./pdf-constants.js";
|
|
17
17
|
export { PlaceholderLineEditor, } from "./placeholder-line-editor-lazy.js";
|
|
18
18
|
export { previewTargetOfKind } from "./preview-targets.js";
|
|
19
19
|
export { TemplateResolverErrors, TemplateResolverHandlers, TemplateResolverQueries, } from "./qualified-names.js";
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export declare const PDF_PAGE_FORMATS: readonly ["A4", "Letter"];
|
|
2
2
|
export type PdfPageFormat = (typeof PDF_PAGE_FORMATS)[number];
|
|
3
|
+
export declare const PDF_MAX_PAGE_EDGE_MM = 297;
|
|
3
4
|
export declare const PDF_ORIENTATIONS: readonly ["portrait", "landscape"];
|
|
4
5
|
export type PdfOrientation = (typeof PDF_ORIENTATIONS)[number];
|
|
5
6
|
export declare const PDF_DEFAULT_MARGIN_MM = 15;
|
|
6
7
|
export declare const PDF_HEADER_MARGIN_MM = 30;
|
|
7
8
|
export declare const PDF_FOOTER_MARGIN_MM = 20;
|
|
8
9
|
export declare const PDF_DEFAULT_FONT_SIZE_PT = 10.5;
|
|
10
|
+
export declare const PDF_FOLD_MARKS: readonly ["none", "din-a", "din-b"];
|
|
11
|
+
export type PdfFoldMarks = (typeof PDF_FOLD_MARKS)[number];
|
|
9
12
|
export declare const PDF_TABLE_STYLES: readonly ["plain", "lines", "header", "grid"];
|
|
10
13
|
export type PdfTableStyle = (typeof PDF_TABLE_STYLES)[number];
|
|
14
|
+
export declare const PDF_CORNER_MARK_INSET_MM = 10;
|
|
15
|
+
export declare const PDF_CORNER_MARK_LEG_MM = 5;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// No imports: web/ re-exports these, and constants.ts pulls in the framework engine.
|
|
2
2
|
export const PDF_PAGE_FORMATS = ["A4", "Letter"];
|
|
3
|
+
// Long edge of the largest supported paper; the sanitizer has no template meta, so a frame is held to this on both axes.
|
|
4
|
+
export const PDF_MAX_PAGE_EDGE_MM = 297;
|
|
3
5
|
export const PDF_ORIENTATIONS = ["portrait", "landscape"];
|
|
4
6
|
// Page margins in mm; the header/footer values apply when the layout contributes that region and the template sets no margin itself.
|
|
5
7
|
export const PDF_DEFAULT_MARGIN_MM = 15;
|
|
@@ -7,4 +9,8 @@ export const PDF_HEADER_MARGIN_MM = 30;
|
|
|
7
9
|
export const PDF_FOOTER_MARGIN_MM = 20;
|
|
8
10
|
// Body text size of a printed document; header and footer fall back to it, so no region reads smaller than the body.
|
|
9
11
|
export const PDF_DEFAULT_FONT_SIZE_PT = 10.5;
|
|
12
|
+
export const PDF_FOLD_MARKS = ["none", "din-a", "din-b"];
|
|
10
13
|
export const PDF_TABLE_STYLES = ["plain", "lines", "header", "grid"];
|
|
14
|
+
// Corner marks: an angle in each paper corner, its vertex this far from both edges and its legs running toward the sheet's centre.
|
|
15
|
+
export const PDF_CORNER_MARK_INSET_MM = 10;
|
|
16
|
+
export const PDF_CORNER_MARK_LEG_MM = 5;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { JSONContent } from "@tiptap/core";
|
|
2
|
-
|
|
2
|
+
import { type DocumentDateStyle } from "./document-schema.ts";
|
|
3
|
+
export declare function lineToContent(text: string, dateStyle?: DocumentDateStyle): JSONContent[];
|
|
3
4
|
export declare function contentToLine(nodes: readonly JSONContent[] | undefined): string;
|
|
4
5
|
export declare function singleLine(text: string): string;
|
|
@@ -2,7 +2,7 @@ import { isDocumentReferenceName } from "./document-schema.js";
|
|
|
2
2
|
const PLACEHOLDER_TOKEN = /\{\{([^{}]*)\}\}/g;
|
|
3
3
|
// Names the schema refuses stay plain text, so a typo never becomes a chip
|
|
4
4
|
// that the server would reject.
|
|
5
|
-
export function lineToContent(text) {
|
|
5
|
+
export function lineToContent(text, dateStyle) {
|
|
6
6
|
const content = [];
|
|
7
7
|
let cursor = 0;
|
|
8
8
|
const pushText = (value) => {
|
|
@@ -14,7 +14,10 @@ export function lineToContent(text) {
|
|
|
14
14
|
if (!isDocumentReferenceName(name))
|
|
15
15
|
continue;
|
|
16
16
|
pushText(text.slice(cursor, match.index));
|
|
17
|
-
content.push({
|
|
17
|
+
content.push({
|
|
18
|
+
type: "variable",
|
|
19
|
+
attrs: dateStyle === undefined ? { name } : { name, dateStyle },
|
|
20
|
+
});
|
|
18
21
|
cursor = match.index + match[0].length;
|
|
19
22
|
}
|
|
20
23
|
pushText(text.slice(cursor));
|
package/dist/tenant/seeding.d.ts
CHANGED
|
@@ -62,3 +62,17 @@ export declare function seedTenantMembership(db: DbRunner, options: SeedTenantMe
|
|
|
62
62
|
id: string;
|
|
63
63
|
rowMissing?: true;
|
|
64
64
|
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Add-only top-up for an EXISTING membership: roles the membership lacks are appended through the
|
|
67
|
+
* event-store executor (one update event), nothing is removed. No event when all roles are present;
|
|
68
|
+
* no membership is created.
|
|
69
|
+
*/
|
|
70
|
+
export declare function addTenantMembershipRoles(db: DbRunner, options: {
|
|
71
|
+
readonly userId: string;
|
|
72
|
+
readonly tenantId: TenantId;
|
|
73
|
+
readonly roles: readonly string[];
|
|
74
|
+
/** Only touch a membership this id created and last wrote (boot seeds pass SYSTEM_USER_ID), so a human role change since then is not reverted. */
|
|
75
|
+
readonly onlyIfInsertedBy?: string;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
readonly added: readonly string[];
|
|
78
|
+
}>;
|
package/dist/tenant/seeding.js
CHANGED
|
@@ -31,6 +31,7 @@ import { createEventStoreExecutor, createTenantDb, fetchOne, } from "@cosmicdrif
|
|
|
31
31
|
import { attachOutsideTransaction, createSystemUser, HookPhases, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
32
32
|
import { getUnscopedAggregateStreamMaxVersion } from "@cosmicdrift/kumiko-framework/event-store";
|
|
33
33
|
import { createDeferringNotify, createLifecycleHooks, } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
34
|
+
import { parseRoles } from "@cosmicdrift/kumiko-framework/utils";
|
|
34
35
|
import { assertAssignableMembershipRoles } from "./membership-roles.js";
|
|
35
36
|
import { findLiveMembershipStreamId } from "./membership-stream-history.js";
|
|
36
37
|
import { tenantMembershipEntity, tenantMembershipsTable } from "./membership-table.js";
|
|
@@ -256,3 +257,46 @@ function extractMembershipId(data) {
|
|
|
256
257
|
}
|
|
257
258
|
throw new Error(`seedTenantMembership: executor.create returned no string id (got ${JSON.stringify(data)})`);
|
|
258
259
|
}
|
|
260
|
+
// ponytail: checks creator and last writer only; a human demotion followed by a system write
|
|
261
|
+
// (invite acceptance) passes. Scan the membership's event stream for non-system actors if that matters.
|
|
262
|
+
function wasOnlyWrittenBy(row, actorId) {
|
|
263
|
+
return (row.insertedById === actorId && (row.modifiedById === null || row.modifiedById === actorId));
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Add-only top-up for an EXISTING membership: roles the membership lacks are appended through the
|
|
267
|
+
* event-store executor (one update event), nothing is removed. No event when all roles are present;
|
|
268
|
+
* no membership is created.
|
|
269
|
+
*/
|
|
270
|
+
export async function addTenantMembershipRoles(db, options) {
|
|
271
|
+
assertAssignableMembershipRoles(options.roles);
|
|
272
|
+
// One re-read on version_conflict: a concurrent boot (second pod) may have added the same roles.
|
|
273
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
274
|
+
const existing = await fetchOne(db, tenantMembershipsTable, { userId: options.userId, tenantId: options.tenantId });
|
|
275
|
+
if (!existing)
|
|
276
|
+
return { added: [] };
|
|
277
|
+
if (options.onlyIfInsertedBy !== undefined &&
|
|
278
|
+
!wasOnlyWrittenBy(existing, options.onlyIfInsertedBy)) {
|
|
279
|
+
return { added: [] };
|
|
280
|
+
}
|
|
281
|
+
const currentRoles = parseRoles(existing.roles);
|
|
282
|
+
const added = options.roles.filter((role) => !currentRoles.includes(role));
|
|
283
|
+
if (added.length === 0)
|
|
284
|
+
return { added };
|
|
285
|
+
const result = await executor.update({
|
|
286
|
+
id: existing.id,
|
|
287
|
+
version: existing.version,
|
|
288
|
+
changes: { roles: JSON.stringify([...currentRoles, ...added]) },
|
|
289
|
+
}, createSystemUser(options.tenantId), createTenantDb({
|
|
290
|
+
db,
|
|
291
|
+
tenantId: options.tenantId,
|
|
292
|
+
mode: "system",
|
|
293
|
+
reason: "boot seed tops up the owner's membership roles in the seeded tenant",
|
|
294
|
+
}));
|
|
295
|
+
if (result.isSuccess)
|
|
296
|
+
return { added };
|
|
297
|
+
if (result.error.code === "version_conflict" && attempt === 0)
|
|
298
|
+
continue;
|
|
299
|
+
throw new Error(`addTenantMembershipRoles failed: ${result.error.code} — ${JSON.stringify(result.error.details ?? {})}`);
|
|
300
|
+
}
|
|
301
|
+
return { added: [] };
|
|
302
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-bundled-features",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.421.0",
|
|
4
4
|
"description": "Built-in features — tenant, user, auth, delivery. The stuff you'd rewrite anyway, already typed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -408,6 +408,10 @@
|
|
|
408
408
|
"types": "./dist/shared/row-bound-grant.d.ts",
|
|
409
409
|
"default": "./dist/shared/row-bound-grant.js"
|
|
410
410
|
},
|
|
411
|
+
"./shared/tenant-scoped-subject": {
|
|
412
|
+
"types": "./dist/shared/tenant-scoped-subject.d.ts",
|
|
413
|
+
"default": "./dist/shared/tenant-scoped-subject.js"
|
|
414
|
+
},
|
|
411
415
|
"./shared/mail-template-body": {
|
|
412
416
|
"types": "./dist/shared/mail-template-body.d.ts",
|
|
413
417
|
"default": "./dist/shared/mail-template-body.js"
|
|
@@ -642,9 +646,9 @@
|
|
|
642
646
|
}
|
|
643
647
|
},
|
|
644
648
|
"dependencies": {
|
|
645
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
646
|
-
"@cosmicdrift/kumiko-renderer": "0.
|
|
647
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
649
|
+
"@cosmicdrift/kumiko-framework": "0.421.0",
|
|
650
|
+
"@cosmicdrift/kumiko-renderer": "0.421.0",
|
|
651
|
+
"@cosmicdrift/kumiko-types": "0.421.0",
|
|
648
652
|
"@fontsource/arimo": "^5.3.0",
|
|
649
653
|
"@fontsource/caladea": "^5.3.0",
|
|
650
654
|
"@fontsource/carlito": "^5.3.0",
|
|
@@ -1073,6 +1077,10 @@
|
|
|
1073
1077
|
"types": "./dist/shared/row-bound-grant.d.ts",
|
|
1074
1078
|
"default": "./dist/shared/row-bound-grant.js"
|
|
1075
1079
|
},
|
|
1080
|
+
"./shared/tenant-scoped-subject": {
|
|
1081
|
+
"types": "./dist/shared/tenant-scoped-subject.d.ts",
|
|
1082
|
+
"default": "./dist/shared/tenant-scoped-subject.js"
|
|
1083
|
+
},
|
|
1076
1084
|
"./shared/mail-template-body": {
|
|
1077
1085
|
"types": "./dist/shared/mail-template-body.d.ts",
|
|
1078
1086
|
"default": "./dist/shared/mail-template-body.js"
|
|
@@ -1315,19 +1323,19 @@
|
|
|
1315
1323
|
"LICENSE"
|
|
1316
1324
|
],
|
|
1317
1325
|
"devDependencies": {
|
|
1318
|
-
"@cosmicdrift/kumiko-locale-de": "0.
|
|
1319
|
-
"@cosmicdrift/kumiko-locale-es": "0.
|
|
1320
|
-
"@cosmicdrift/kumiko-locale-fr": "0.
|
|
1321
|
-
"@cosmicdrift/kumiko-locale-it": "0.
|
|
1322
|
-
"@cosmicdrift/kumiko-renderer-mail-html": "0.
|
|
1323
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
1326
|
+
"@cosmicdrift/kumiko-locale-de": "0.421.0",
|
|
1327
|
+
"@cosmicdrift/kumiko-locale-es": "0.421.0",
|
|
1328
|
+
"@cosmicdrift/kumiko-locale-fr": "0.421.0",
|
|
1329
|
+
"@cosmicdrift/kumiko-locale-it": "0.421.0",
|
|
1330
|
+
"@cosmicdrift/kumiko-renderer-mail-html": "0.421.0",
|
|
1331
|
+
"@cosmicdrift/kumiko-testing": "0.421.0",
|
|
1324
1332
|
"@testing-library/user-event": "^14.6.8",
|
|
1325
1333
|
"@types/sanitize-html": "^2.16.2",
|
|
1326
1334
|
"jsqr": "^1.4.0",
|
|
1327
1335
|
"unpdf": "^1.9.1"
|
|
1328
1336
|
},
|
|
1329
1337
|
"peerDependencies": {
|
|
1330
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
1338
|
+
"@cosmicdrift/kumiko-testing": "0.421.0"
|
|
1331
1339
|
},
|
|
1332
1340
|
"peerDependenciesMeta": {
|
|
1333
1341
|
"@cosmicdrift/kumiko-testing": {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.420.0",
|
|
4
|
+
"type": "fix",
|
|
5
|
+
"title": "Empty signature images are rejected on any background",
|
|
6
|
+
"detail": "The background of a signature image is now the dominant opaque colour of its border (within a small tolerance) instead of four identical corners, so an opaque blank image with one differing corner pixel no longer passes as signed. A `linkSecret` of only whitespace is refused when `authorizeSubject` is set. The tenant-scoped subject of the signing link is available as `tenantScopedSubject`, `parseTenantScopedSubject` and `peekTenantScopedSubject` in `@cosmicdrift/kumiko-bundled-features/shared/tenant-scoped-subject`."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.418.0",
|
|
4
10
|
"type": "fix",
|