@cosmicdrift/kumiko-bundled-features 0.421.0 → 0.424.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.
Files changed (117) hide show
  1. package/dist/document-draft/entity.d.ts +320 -0
  2. package/dist/document-draft/entity.js +98 -0
  3. package/dist/document-draft/feature.d.ts +3 -0
  4. package/dist/document-draft/feature.js +42 -0
  5. package/dist/document-draft/handlers/blocks.query.d.ts +28 -0
  6. package/dist/document-draft/handlers/blocks.query.js +48 -0
  7. package/dist/document-draft/handlers/by-subject.query.d.ts +16 -0
  8. package/dist/document-draft/handlers/by-subject.query.js +42 -0
  9. package/dist/document-draft/handlers/create.write.d.ts +17 -0
  10. package/dist/document-draft/handlers/create.write.js +83 -0
  11. package/dist/document-draft/handlers/discard.write.d.ts +8 -0
  12. package/dist/document-draft/handlers/discard.write.js +27 -0
  13. package/dist/document-draft/handlers/finalize.write.d.ts +21 -0
  14. package/dist/document-draft/handlers/finalize.write.js +73 -0
  15. package/dist/document-draft/handlers/patch.write.d.ts +1420 -0
  16. package/dist/document-draft/handlers/patch.write.js +65 -0
  17. package/dist/document-draft/handlers/revise.write.d.ts +12 -0
  18. package/dist/document-draft/handlers/revise.write.js +39 -0
  19. package/dist/document-draft/handlers/save.write.d.ts +12 -0
  20. package/dist/document-draft/handlers/save.write.js +40 -0
  21. package/dist/document-draft/i18n.d.ts +6 -0
  22. package/dist/document-draft/i18n.js +20 -0
  23. package/dist/document-draft/index.d.ts +5 -0
  24. package/dist/document-draft/index.js +3 -0
  25. package/dist/document-draft/lib.d.ts +13 -0
  26. package/dist/document-draft/lib.js +42 -0
  27. package/dist/document-draft/options.d.ts +35 -0
  28. package/dist/document-draft/options.js +1 -0
  29. package/dist/document-draft/payloads.d.ts +1440 -0
  30. package/dist/document-draft/payloads.js +35 -0
  31. package/dist/document-draft/screens/editor-screen.d.ts +3 -0
  32. package/dist/document-draft/screens/editor-screen.js +13 -0
  33. package/dist/document-draft/user-data.d.ts +13 -0
  34. package/dist/document-draft/user-data.js +43 -0
  35. package/dist/document-draft/web/client-plugin.d.ts +7 -0
  36. package/dist/document-draft/web/client-plugin.js +13 -0
  37. package/dist/document-draft/web/constants.d.ts +41 -0
  38. package/dist/document-draft/web/constants.js +42 -0
  39. package/dist/document-draft/web/editor-screen.d.ts +2 -0
  40. package/dist/document-draft/web/editor-screen.js +181 -0
  41. package/dist/document-draft/web/i18n.d.ts +99 -0
  42. package/dist/document-draft/web/i18n.js +52 -0
  43. package/dist/document-draft/web/index.d.ts +3 -0
  44. package/dist/document-draft/web/index.js +3 -0
  45. package/dist/shared/index.d.ts +1 -0
  46. package/dist/shared/index.js +1 -0
  47. package/dist/shared/subject-scope.d.ts +21 -0
  48. package/dist/signature/feature.js +1 -1
  49. package/dist/signature/handlers/cancel.write.d.ts +1 -1
  50. package/dist/signature/handlers/issue-link.write.d.ts +1 -1
  51. package/dist/signature/handlers/request.write.d.ts +1 -1
  52. package/dist/signature/handlers/revoke-link.write.d.ts +1 -1
  53. package/dist/signature/handlers/sign-in-person.write.d.ts +1 -1
  54. package/dist/signature/options.d.ts +2 -1
  55. package/dist/signature/subject-queries.d.ts +1 -1
  56. package/dist/template-resolver/api.d.ts +3 -1
  57. package/dist/template-resolver/boot-rules.d.ts +5 -0
  58. package/dist/template-resolver/boot-rules.js +5 -0
  59. package/dist/template-resolver/compile-document-body.d.ts +11 -1
  60. package/dist/template-resolver/compile-document-body.js +42 -5
  61. package/dist/template-resolver/document-print-only.d.ts +1 -1
  62. package/dist/template-resolver/document-print-only.js +1 -0
  63. package/dist/template-resolver/feature.d.ts +2 -0
  64. package/dist/template-resolver/feature.js +15 -1
  65. package/dist/template-resolver/handlers/create-variant.write.d.ts +17 -0
  66. package/dist/template-resolver/handlers/create-variant.write.js +112 -0
  67. package/dist/template-resolver/handlers/document-base.d.ts +1 -0
  68. package/dist/template-resolver/handlers/document-base.js +2 -0
  69. package/dist/template-resolver/handlers/overview.query.d.ts +6 -0
  70. package/dist/template-resolver/handlers/overview.query.js +29 -3
  71. package/dist/template-resolver/handlers/patch-draft.write.js +9 -1
  72. package/dist/template-resolver/handlers/template-write.d.ts +8 -2
  73. package/dist/template-resolver/handlers/template-write.js +87 -12
  74. package/dist/template-resolver/handlers/toggle-status.write.js +26 -5
  75. package/dist/template-resolver/handlers/upsert-tenant.write.js +1 -0
  76. package/dist/template-resolver/handlers/variants.query.d.ts +11 -0
  77. package/dist/template-resolver/handlers/variants.query.js +62 -0
  78. package/dist/template-resolver/i18n.js +1 -0
  79. package/dist/template-resolver/index.d.ts +6 -2
  80. package/dist/template-resolver/index.js +6 -2
  81. package/dist/template-resolver/seeding.d.ts +2 -0
  82. package/dist/template-resolver/seeding.js +12 -1
  83. package/dist/template-resolver/template-delivery-policy.d.ts +13 -4
  84. package/dist/template-resolver/template-delivery-policy.js +38 -2
  85. package/dist/template-resolver/template-edit-policy.d.ts +3 -0
  86. package/dist/template-resolver/template-edit-policy.js +2 -2
  87. package/dist/template-resolver/template-meta.d.ts +1 -0
  88. package/dist/template-resolver/template-meta.js +1 -0
  89. package/dist/template-resolver/template-variants.d.ts +11 -0
  90. package/dist/template-resolver/template-variants.js +43 -0
  91. package/dist/template-resolver/web/document-images.d.ts +3 -0
  92. package/dist/template-resolver/web/document-images.js +25 -8
  93. package/dist/template-resolver/web/document-tiptap-content.js +7 -2
  94. package/dist/template-resolver/web/document-tiptap-toolbar.js +8 -4
  95. package/dist/template-resolver/web/i18n.js +22 -0
  96. package/dist/template-resolver/web/index.d.ts +1 -0
  97. package/dist/template-resolver/web/index.js +1 -0
  98. package/dist/template-resolver/web/qualified-names.d.ts +5 -0
  99. package/dist/template-resolver/web/qualified-names.js +5 -0
  100. package/dist/template-resolver/web/system-placeholders.d.ts +4 -0
  101. package/dist/template-resolver/web/system-placeholders.js +13 -0
  102. package/dist/tenant/handlers/update-member-roles.write.js +1 -1
  103. package/dist/tenant/i18n.js +0 -1
  104. package/dist/tenant-inactivity/constants.d.ts +1 -1
  105. package/dist/tenant-inactivity/constants.js +1 -1
  106. package/dist/tenant-lifecycle/constants.d.ts +1 -1
  107. package/dist/tenant-lifecycle/constants.js +1 -1
  108. package/package.json +27 -11
  109. package/src/document-draft/changes.json +8 -0
  110. package/src/helpdesk/changes.json +6 -0
  111. package/src/signature/changes.json +6 -0
  112. package/src/template-resolver/changes.json +36 -0
  113. package/src/tenant/changes.json +7 -0
  114. package/src/tenant-inactivity/changes.json +7 -0
  115. package/src/tenant-lifecycle/changes.json +7 -0
  116. package/dist/signature/subject-scope.d.ts +0 -11
  117. /package/dist/{signature → shared}/subject-scope.js +0 -0
@@ -0,0 +1,320 @@
1
+ export declare const DEFAULT_DOCUMENT_DRAFT_RETENTION_KEEP_FOR = "10y";
2
+ export type DocumentDraftRetention = {
3
+ readonly keepFor: string;
4
+ };
5
+ export declare function createDocumentDraftEntity(retention?: DocumentDraftRetention): import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
6
+ readonly subjectType: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
7
+ required: true;
8
+ };
9
+ readonly subjectId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
10
+ required: true;
11
+ };
12
+ readonly templateSlug: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
13
+ required: true;
14
+ };
15
+ readonly templateVariant: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
16
+ required: false;
17
+ };
18
+ readonly templateTitle: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
19
+ required: false;
20
+ };
21
+ readonly templateId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
22
+ required: true;
23
+ };
24
+ readonly templateVersion: {
25
+ readonly type: "number";
26
+ readonly description?: string;
27
+ readonly required?: boolean;
28
+ readonly sortable?: boolean;
29
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
30
+ readonly filterable?: boolean;
31
+ readonly sensitive?: boolean;
32
+ readonly default?: number;
33
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
34
+ readonly min?: number;
35
+ readonly max?: number;
36
+ readonly integer?: boolean;
37
+ readonly unit?: string | {
38
+ readonly field: string;
39
+ };
40
+ readonly grouping?: boolean;
41
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
42
+ required: true;
43
+ };
44
+ readonly templateScope: {
45
+ readonly type: "select";
46
+ readonly description?: string;
47
+ readonly options: readonly ["system", "tenant"];
48
+ readonly required?: boolean;
49
+ readonly sortable?: boolean;
50
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
51
+ readonly filterable?: boolean;
52
+ readonly sensitive?: boolean;
53
+ readonly default?: "system" | "tenant" | undefined;
54
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
55
+ readonly display?: "radio" | "dropdown";
56
+ readonly optionTones?: {
57
+ readonly system?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
58
+ readonly tenant?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
59
+ } | undefined;
60
+ readonly optionsQuery?: string;
61
+ readonly optionsQueryPayload?: import("@cosmicdrift/kumiko-types/fields").OptionsQueryPayload;
62
+ readonly optionsAvailabilityQuery?: string;
63
+ readonly conditionalOptions?: readonly import("@cosmicdrift/kumiko-types/fields").SelectConditionalOptions<"system" | "tenant">[] | undefined;
64
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
65
+ required: true;
66
+ };
67
+ readonly locale: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
68
+ required: true;
69
+ };
70
+ readonly templateBody: import("@cosmicdrift/kumiko-types/fields").EntityLongTextFieldDef & {
71
+ required: true;
72
+ };
73
+ readonly body: import("@cosmicdrift/kumiko-types/fields").EntityLongTextFieldDef & {
74
+ required: true;
75
+ };
76
+ readonly variables: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
77
+ readonly meta: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
78
+ readonly variableSchema: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
79
+ readonly status: {
80
+ readonly type: "select";
81
+ readonly description?: string;
82
+ readonly options: readonly ["open", "finalized", "discarded"];
83
+ readonly required?: boolean;
84
+ readonly sortable?: boolean;
85
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
86
+ readonly filterable?: boolean;
87
+ readonly sensitive?: boolean;
88
+ readonly default?: "discarded" | "finalized" | "open" | undefined;
89
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
90
+ readonly display?: "radio" | "dropdown";
91
+ readonly optionTones?: {
92
+ readonly discarded?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
93
+ readonly finalized?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
94
+ readonly open?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
95
+ } | undefined;
96
+ readonly optionsQuery?: string;
97
+ readonly optionsQueryPayload?: import("@cosmicdrift/kumiko-types/fields").OptionsQueryPayload;
98
+ readonly optionsAvailabilityQuery?: string;
99
+ readonly conditionalOptions?: readonly import("@cosmicdrift/kumiko-types/fields").SelectConditionalOptions<"discarded" | "finalized" | "open">[] | undefined;
100
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
101
+ required: true;
102
+ };
103
+ readonly revision: {
104
+ readonly type: "number";
105
+ readonly description?: string;
106
+ readonly required?: boolean;
107
+ readonly sortable?: boolean;
108
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
109
+ readonly filterable?: boolean;
110
+ readonly sensitive?: boolean;
111
+ readonly default?: number;
112
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
113
+ readonly min?: number;
114
+ readonly max?: number;
115
+ readonly integer?: boolean;
116
+ readonly unit?: string | {
117
+ readonly field: string;
118
+ };
119
+ readonly grouping?: boolean;
120
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
121
+ required: true;
122
+ };
123
+ readonly fileRefId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
124
+ required: false;
125
+ };
126
+ readonly fileName: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
127
+ required: false;
128
+ };
129
+ readonly finalizedAt: {
130
+ readonly type: "timestamp";
131
+ readonly description?: string;
132
+ readonly required?: boolean;
133
+ readonly sortable?: boolean;
134
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
135
+ readonly filterable?: boolean;
136
+ readonly sensitive?: boolean;
137
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
138
+ readonly locatedBy?: string;
139
+ readonly min?: string;
140
+ readonly max?: string;
141
+ readonly locale?: string;
142
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
143
+ required: false;
144
+ };
145
+ readonly lastChange: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
146
+ }, "tenant">;
147
+ export declare const documentDraftEntity: import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
148
+ readonly subjectType: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
149
+ required: true;
150
+ };
151
+ readonly subjectId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
152
+ required: true;
153
+ };
154
+ readonly templateSlug: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
155
+ required: true;
156
+ };
157
+ readonly templateVariant: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
158
+ required: false;
159
+ };
160
+ readonly templateTitle: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
161
+ required: false;
162
+ };
163
+ readonly templateId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
164
+ required: true;
165
+ };
166
+ readonly templateVersion: {
167
+ readonly type: "number";
168
+ readonly description?: string;
169
+ readonly required?: boolean;
170
+ readonly sortable?: boolean;
171
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
172
+ readonly filterable?: boolean;
173
+ readonly sensitive?: boolean;
174
+ readonly default?: number;
175
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
176
+ readonly min?: number;
177
+ readonly max?: number;
178
+ readonly integer?: boolean;
179
+ readonly unit?: string | {
180
+ readonly field: string;
181
+ };
182
+ readonly grouping?: boolean;
183
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
184
+ required: true;
185
+ };
186
+ readonly templateScope: {
187
+ readonly type: "select";
188
+ readonly description?: string;
189
+ readonly options: readonly ["system", "tenant"];
190
+ readonly required?: boolean;
191
+ readonly sortable?: boolean;
192
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
193
+ readonly filterable?: boolean;
194
+ readonly sensitive?: boolean;
195
+ readonly default?: "system" | "tenant" | undefined;
196
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
197
+ readonly display?: "radio" | "dropdown";
198
+ readonly optionTones?: {
199
+ readonly system?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
200
+ readonly tenant?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
201
+ } | undefined;
202
+ readonly optionsQuery?: string;
203
+ readonly optionsQueryPayload?: import("@cosmicdrift/kumiko-types/fields").OptionsQueryPayload;
204
+ readonly optionsAvailabilityQuery?: string;
205
+ readonly conditionalOptions?: readonly import("@cosmicdrift/kumiko-types/fields").SelectConditionalOptions<"system" | "tenant">[] | undefined;
206
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
207
+ required: true;
208
+ };
209
+ readonly locale: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
210
+ required: true;
211
+ };
212
+ readonly templateBody: import("@cosmicdrift/kumiko-types/fields").EntityLongTextFieldDef & {
213
+ required: true;
214
+ };
215
+ readonly body: import("@cosmicdrift/kumiko-types/fields").EntityLongTextFieldDef & {
216
+ required: true;
217
+ };
218
+ readonly variables: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
219
+ readonly meta: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
220
+ readonly variableSchema: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
221
+ readonly status: {
222
+ readonly type: "select";
223
+ readonly description?: string;
224
+ readonly options: readonly ["open", "finalized", "discarded"];
225
+ readonly required?: boolean;
226
+ readonly sortable?: boolean;
227
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
228
+ readonly filterable?: boolean;
229
+ readonly sensitive?: boolean;
230
+ readonly default?: "discarded" | "finalized" | "open" | undefined;
231
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
232
+ readonly display?: "radio" | "dropdown";
233
+ readonly optionTones?: {
234
+ readonly discarded?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
235
+ readonly finalized?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
236
+ readonly open?: "accent" | "bad" | "critical" | "neutral" | "ok" | "warn" | undefined;
237
+ } | undefined;
238
+ readonly optionsQuery?: string;
239
+ readonly optionsQueryPayload?: import("@cosmicdrift/kumiko-types/fields").OptionsQueryPayload;
240
+ readonly optionsAvailabilityQuery?: string;
241
+ readonly conditionalOptions?: readonly import("@cosmicdrift/kumiko-types/fields").SelectConditionalOptions<"discarded" | "finalized" | "open">[] | undefined;
242
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
243
+ required: true;
244
+ };
245
+ readonly revision: {
246
+ readonly type: "number";
247
+ readonly description?: string;
248
+ readonly required?: boolean;
249
+ readonly sortable?: boolean;
250
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
251
+ readonly filterable?: boolean;
252
+ readonly sensitive?: boolean;
253
+ readonly default?: number;
254
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
255
+ readonly min?: number;
256
+ readonly max?: number;
257
+ readonly integer?: boolean;
258
+ readonly unit?: string | {
259
+ readonly field: string;
260
+ };
261
+ readonly grouping?: boolean;
262
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
263
+ required: true;
264
+ };
265
+ readonly fileRefId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
266
+ required: false;
267
+ };
268
+ readonly fileName: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
269
+ required: false;
270
+ };
271
+ readonly finalizedAt: {
272
+ readonly type: "timestamp";
273
+ readonly description?: string;
274
+ readonly required?: boolean;
275
+ readonly sortable?: boolean;
276
+ readonly sortNulls?: import("@cosmicdrift/kumiko-types/fields").SortNulls;
277
+ readonly filterable?: boolean;
278
+ readonly sensitive?: boolean;
279
+ readonly access?: import("@cosmicdrift/kumiko-types/fields").FieldAccess;
280
+ readonly locatedBy?: string;
281
+ readonly min?: string;
282
+ readonly max?: string;
283
+ readonly locale?: string;
284
+ } & import("@cosmicdrift/kumiko-types/fields").ResolvedPiiFlags & import("@cosmicdrift/kumiko-types/fields").FieldStateConditions & {
285
+ required: false;
286
+ };
287
+ readonly lastChange: import("@cosmicdrift/kumiko-types/fields").JsonbFieldDef;
288
+ }, "tenant">;
289
+ export declare const documentDraftExecutor: import("@cosmicdrift/kumiko-types/event-store-executor-types").EventStoreExecutor<{
290
+ readonly id: string;
291
+ readonly tenantId: string;
292
+ readonly version: number;
293
+ readonly insertedAt: Temporal.Instant;
294
+ readonly modifiedAt: Temporal.Instant | null;
295
+ readonly insertedById: string | null;
296
+ readonly modifiedById: string | null;
297
+ readonly isDeleted?: boolean | undefined;
298
+ readonly deletedAt?: Temporal.Instant | null | undefined;
299
+ readonly deletedById?: string | null | undefined;
300
+ readonly body: string;
301
+ readonly fileName: string | null;
302
+ readonly fileRefId: string | null;
303
+ readonly finalizedAt: Temporal.Instant | null;
304
+ readonly lastChange: unknown;
305
+ readonly locale: string;
306
+ readonly meta: unknown;
307
+ readonly revision: number;
308
+ readonly status: string;
309
+ readonly subjectId: string;
310
+ readonly subjectType: string;
311
+ readonly templateBody: string;
312
+ readonly templateId: string;
313
+ readonly templateScope: string;
314
+ readonly templateSlug: string;
315
+ readonly templateTitle: string | null;
316
+ readonly templateVariant: string | null;
317
+ readonly templateVersion: number;
318
+ readonly variableSchema: unknown;
319
+ readonly variables: unknown;
320
+ }>, documentDraftTable: import("@cosmicdrift/kumiko-framework/db").EntityTable;
@@ -0,0 +1,98 @@
1
+ import { createEntity, createEntityExecutor, createJsonbField, createLongTextField, createNumberField, createSelectField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { TEMPLATE_SCOPES } from "../template-resolver/index.js";
3
+ import { DOCUMENT_DRAFT_ENTITY, DOCUMENT_DRAFT_STATUS, DOCUMENT_DRAFT_STATUS_TONE, } from "./web/constants.js";
4
+ export const DEFAULT_DOCUMENT_DRAFT_RETENTION_KEEP_FOR = "10y";
5
+ const STATUS_OPTIONS = [
6
+ DOCUMENT_DRAFT_STATUS.Open,
7
+ DOCUMENT_DRAFT_STATUS.Finalized,
8
+ DOCUMENT_DRAFT_STATUS.Discarded,
9
+ ];
10
+ // The body carries the text of one contract with names and amounts filled in by whoever edits it,
11
+ // so the draft row is its own crypto-shredding subject, like a signer row. find: "none": nothing looks it up.
12
+ const DRAFT_PERSONAL = { personal: "self", find: "none" };
13
+ const DRAFT_PERSONAL_JSON = { personal: "self" };
14
+ export function createDocumentDraftEntity(retention = { keepFor: DEFAULT_DOCUMENT_DRAFT_RETENTION_KEEP_FOR }) {
15
+ return createEntity({
16
+ table: "read_document_drafts",
17
+ description: "One editable copy of a PDF document template for one object (for example a lease contract): the template text with its {{placeholders}} frozen at creation, changed with the same structured operations as a template, then finalized to a stored PDF. The template itself stays unchanged; body, variables and the last change are personal data of the draft.",
18
+ retention: { keepFor: retention.keepFor, strategy: "hardDelete", reference: "createdAt" },
19
+ fields: {
20
+ subjectType: createTextField({
21
+ required: true,
22
+ personal: false,
23
+ reason: "technical_reference",
24
+ filterable: true,
25
+ maxLength: 100,
26
+ }),
27
+ subjectId: createTextField({
28
+ required: true,
29
+ personal: false,
30
+ reason: "technical_reference",
31
+ filterable: true,
32
+ maxLength: 100,
33
+ }),
34
+ templateSlug: createTextField({
35
+ required: true,
36
+ personal: false,
37
+ reason: "technical_reference",
38
+ maxLength: 200,
39
+ }),
40
+ templateVariant: createTextField({
41
+ personal: false,
42
+ reason: "technical_reference",
43
+ maxLength: 200,
44
+ }),
45
+ templateTitle: createTextField({
46
+ personal: false,
47
+ reason: "template_content",
48
+ maxLength: 300,
49
+ }),
50
+ templateId: createTextField({
51
+ required: true,
52
+ personal: false,
53
+ reason: "technical_reference",
54
+ maxLength: 64,
55
+ }),
56
+ templateVersion: createNumberField({ required: true }),
57
+ templateScope: createSelectField({ options: [...TEMPLATE_SCOPES], required: true }),
58
+ locale: createTextField({
59
+ required: true,
60
+ personal: false,
61
+ reason: "technical_reference",
62
+ maxLength: 20,
63
+ }),
64
+ templateBody: createLongTextField({
65
+ required: true,
66
+ personal: false,
67
+ reason: "template_content",
68
+ }),
69
+ body: createLongTextField({ required: true, ...DRAFT_PERSONAL }),
70
+ variables: createJsonbField(DRAFT_PERSONAL_JSON),
71
+ meta: createJsonbField({ personal: false, reason: "template_settings" }),
72
+ variableSchema: createJsonbField({
73
+ personal: false,
74
+ reason: "template_definition",
75
+ }),
76
+ status: createSelectField({
77
+ options: STATUS_OPTIONS,
78
+ required: true,
79
+ default: DOCUMENT_DRAFT_STATUS.Open,
80
+ filterable: true,
81
+ sortable: true,
82
+ optionTones: DOCUMENT_DRAFT_STATUS_TONE,
83
+ }),
84
+ revision: createNumberField({ required: true, default: 1 }),
85
+ fileRefId: createTextField({
86
+ personal: false,
87
+ reason: "technical_reference",
88
+ maxLength: 64,
89
+ }),
90
+ fileName: createTextField({ ...DRAFT_PERSONAL, maxLength: 300 }),
91
+ finalizedAt: createTimestampField({ personal: false, reason: "is_business_timestamp" }),
92
+ lastChange: createJsonbField(DRAFT_PERSONAL_JSON),
93
+ },
94
+ indexes: [{ columns: ["tenantId", "subjectType", "subjectId"] }],
95
+ });
96
+ }
97
+ export const documentDraftEntity = createDocumentDraftEntity();
98
+ export const { executor: documentDraftExecutor, table: documentDraftTable } = createEntityExecutor(DOCUMENT_DRAFT_ENTITY, documentDraftEntity);
@@ -0,0 +1,3 @@
1
+ import { type FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
2
+ import type { DocumentDraftOptions } from "./options.ts";
3
+ export declare function createDocumentDraftFeature<TUpload>(opts: DocumentDraftOptions<TUpload>): FeatureDefinition;
@@ -0,0 +1,42 @@
1
+ import { defineFeature, EXT_USER_DATA, } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { createSubjectScope } from "../shared/index.js";
3
+ import { createDocumentDraftEntity } from "./entity.js";
4
+ import { createBlocksQuery } from "./handlers/blocks.query.js";
5
+ import { createBySubjectQuery } from "./handlers/by-subject.query.js";
6
+ import { createCreateHandler } from "./handlers/create.write.js";
7
+ import { createDiscardHandler } from "./handlers/discard.write.js";
8
+ import { createFinalizeHandler } from "./handlers/finalize.write.js";
9
+ import { createPatchHandler } from "./handlers/patch.write.js";
10
+ import { createReviseHandler } from "./handlers/revise.write.js";
11
+ import { createSaveHandler } from "./handlers/save.write.js";
12
+ import { DOCUMENT_DRAFT_I18N } from "./i18n.js";
13
+ import { DEFAULT_DOCUMENT_DRAFT_ACCESS } from "./lib.js";
14
+ import { createDocumentDraftEditorScreen } from "./screens/editor-screen.js";
15
+ import { DOCUMENT_DRAFT_ENTITY, DOCUMENT_DRAFT_FEATURE } from "./web/constants.js";
16
+ export function createDocumentDraftFeature(opts) {
17
+ const access = opts.access ?? DEFAULT_DOCUMENT_DRAFT_ACCESS;
18
+ const scope = createSubjectScope(opts);
19
+ const entity = createDocumentDraftEntity(opts.retention);
20
+ return defineFeature(DOCUMENT_DRAFT_FEATURE, (r) => {
21
+ r.describe("Document drafts: one editable copy of a PDF document template per object (for example a lease contract). A draft is created from a template or one of its variants with the values for its placeholders, changed with the structured operations of template patch-draft or the editor, and finalized to a stored PDF through the injected print function; the template stays unchanged. Revise reopens a finalized draft. Body, variables and the last change are personal data of the draft, which is its own crypto-shredding subject.");
22
+ r.uiHints({ displayLabel: "Document drafts", category: "data", recommended: false });
23
+ r.requires({ features: ["files", "template-resolver", "user-data-rights"] });
24
+ r.translations({ keys: DOCUMENT_DRAFT_I18N });
25
+ r.entity({ name: "documentDraft", ...entity });
26
+ r.writeHandler(createCreateHandler(access, scope, opts.subjectTypes));
27
+ r.writeHandler(createPatchHandler(access, scope));
28
+ r.writeHandler(createSaveHandler(access, scope));
29
+ r.writeHandler(createFinalizeHandler(access, scope, opts.pdf));
30
+ r.writeHandler(createReviseHandler(access, scope));
31
+ r.writeHandler(createDiscardHandler(access, scope));
32
+ r.queryHandler(createBlocksQuery(access, scope, opts.subjectScreens));
33
+ r.queryHandler(createBySubjectQuery(access, scope));
34
+ r.screen(createDocumentDraftEditorScreen(access));
35
+ // A draft belongs to the object it was made for, not to the acting user: the app erases it
36
+ // with forgetDocumentDraftsOfSubject when that object is erased, so the user pipeline has nothing to do.
37
+ r.useExtension(EXT_USER_DATA, DOCUMENT_DRAFT_ENTITY, {
38
+ export: async () => null,
39
+ delete: async () => { },
40
+ });
41
+ });
42
+ }
@@ -0,0 +1,28 @@
1
+ import { type AccessRule } from "@cosmicdrift/kumiko-framework/engine";
2
+ import type { SubjectScope } from "../../shared/index.ts";
3
+ export declare function createBlocksQuery(access: AccessRule, scope: SubjectScope, subjectScreens?: Readonly<Record<string, string>>): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"blocks", import("zod").ZodObject<{
4
+ id: import("zod").ZodUUID;
5
+ }, import("zod/v4/core").$strip>, {
6
+ id: string;
7
+ subjectType: string;
8
+ subjectId: string;
9
+ templateSlug: string;
10
+ templateVariant: string | null;
11
+ templateTitle: string | null;
12
+ templateVersion: number;
13
+ locale: string;
14
+ status: string;
15
+ revision: number;
16
+ version: number;
17
+ fileRefId: string | null;
18
+ fileName: string | null;
19
+ body: string;
20
+ templateBody: string;
21
+ variables: {};
22
+ variableSchema: {};
23
+ subjectScreen: string | null | undefined;
24
+ meta: {} | null;
25
+ blocks: import("../../template-resolver/document-ops.ts").DocumentBlock[];
26
+ deviations: import("../../template-resolver/template-diff.ts").TemplateDiffBlock[];
27
+ allowedBlocks: readonly ("frame" | import("../../template-resolver/web/document-blocks.ts").DocumentToolbarBlock)[];
28
+ }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
@@ -0,0 +1,48 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { allowedBlocksFor, diffTemplateBlocks, documentBlocksOf, parseDocumentJson, splitTemplateBlocks, } from "../../template-resolver/index.js";
4
+ import { loadScopedDraft } from "../lib.js";
5
+ import { DraftIdSchema } from "../payloads.js";
6
+ import { DOCUMENT_DRAFT_ENTITY } from "../web/constants.js";
7
+ export function createBlocksQuery(access, scope, subjectScreens = {}) {
8
+ return defineQueryHandler({
9
+ name: "blocks",
10
+ schema: DraftIdSchema,
11
+ access,
12
+ description: "Reads a document draft as a list of blocks with stable ids (b0, b1, ...) for structured editing with patch: each block has its type, its text with {{name}} placeholders and its settings. Also returns the draft's subject, template, status, revision, the frozen variables, the variable schema, the screen its subject type returns to (subjectScreen, or null) and the settings, the deviations from the template text (blocks added, removed or changed) and the block types allowed in a PDF document. version is the base that patch, save, finalize, revise and discard expect back.",
13
+ handler: async (query, ctx) => {
14
+ const draft = await loadScopedDraft(ctx, query.user, scope, query.payload.id);
15
+ if (draft === null)
16
+ throw new NotFoundError(DOCUMENT_DRAFT_ENTITY, query.payload.id);
17
+ const subjectType = String(draft.subjectType);
18
+ const body = String(draft.body);
19
+ const templateBody = String(draft.templateBody);
20
+ return {
21
+ id: draft.id,
22
+ subjectType: draft.subjectType,
23
+ subjectId: draft.subjectId,
24
+ templateSlug: draft.templateSlug,
25
+ templateVariant: draft.templateVariant ?? null,
26
+ templateTitle: draft.templateTitle ?? null,
27
+ templateVersion: draft.templateVersion,
28
+ locale: draft.locale,
29
+ status: draft.status,
30
+ revision: draft.revision,
31
+ version: draft.version,
32
+ fileRefId: draft.fileRefId ?? null,
33
+ fileName: draft.fileName ?? null,
34
+ body,
35
+ templateBody,
36
+ variables: draft.variables ?? {},
37
+ variableSchema: draft.variableSchema ?? {},
38
+ subjectScreen: Object.hasOwn(subjectScreens, subjectType)
39
+ ? subjectScreens[subjectType]
40
+ : null,
41
+ meta: draft.meta ?? null,
42
+ blocks: documentBlocksOf(parseDocumentJson(body)),
43
+ deviations: diffTemplateBlocks(splitTemplateBlocks(templateBody, "html"), splitTemplateBlocks(body, "html")),
44
+ allowedBlocks: allowedBlocksFor("document-pdf"),
45
+ };
46
+ },
47
+ });
48
+ }
@@ -0,0 +1,16 @@
1
+ import { type AccessRule } from "@cosmicdrift/kumiko-framework/engine";
2
+ import type { SubjectScope } from "../../shared/index.ts";
3
+ export declare function createBySubjectQuery(access: AccessRule, scope: SubjectScope): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"by-subject", import("zod").ZodObject<{
4
+ subjectType: import("zod").ZodString;
5
+ subjectId: import("zod").ZodString;
6
+ }, import("zod/v4/core").$strip>, {
7
+ id: string;
8
+ status: string;
9
+ revision: number;
10
+ version: number;
11
+ templateSlug: string;
12
+ templateVariant: string | null;
13
+ fileRefId: string | null;
14
+ fileName: string | null;
15
+ insertedAt: Temporal.Instant;
16
+ }[], import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
@@ -0,0 +1,42 @@
1
+ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
2
+ import { NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
3
+ import { documentDraftExecutor } from "../entity.js";
4
+ import { BySubjectSchema } from "../payloads.js";
5
+ import { DOCUMENT_DRAFT_ENTITY, DOCUMENT_DRAFT_STATUS } from "../web/constants.js";
6
+ // Equals the executor's MAX_LIST_LIMIT; one object never has more live drafts.
7
+ const LIST_LIMIT = 200;
8
+ export function createBySubjectQuery(access, scope) {
9
+ return defineQueryHandler({
10
+ name: "by-subject",
11
+ schema: BySubjectSchema,
12
+ access,
13
+ description: "Lists the drafts of one object (subjectType, subjectId), newest first, without their text: id, status, revision, version, template, file and creation time (insertedAt). Discarded drafts are left out.",
14
+ handler: async (query, ctx) => {
15
+ const { subjectType, subjectId } = query.payload;
16
+ if (!(await scope.allows(ctx, query.user, subjectType, subjectId))) {
17
+ throw new NotFoundError(DOCUMENT_DRAFT_ENTITY);
18
+ }
19
+ const found = await documentDraftExecutor.list({
20
+ filters: [
21
+ { field: "subjectType", op: "eq", value: subjectType },
22
+ { field: "subjectId", op: "eq", value: subjectId },
23
+ { field: "status", op: "ne", value: DOCUMENT_DRAFT_STATUS.Discarded },
24
+ ],
25
+ sort: "insertedAt",
26
+ sortDirection: "desc",
27
+ limit: LIST_LIMIT,
28
+ }, query.user, ctx.db);
29
+ return found.rows.map((row) => ({
30
+ id: row.id,
31
+ status: row.status,
32
+ revision: row.revision,
33
+ version: row.version,
34
+ templateSlug: row.templateSlug,
35
+ templateVariant: row.templateVariant ?? null,
36
+ fileRefId: row.fileRefId ?? null,
37
+ fileName: row.fileName ?? null,
38
+ insertedAt: row.insertedAt,
39
+ }));
40
+ },
41
+ });
42
+ }
@@ -0,0 +1,17 @@
1
+ import { type AccessRule } from "@cosmicdrift/kumiko-framework/engine";
2
+ import type { SubjectScope } from "../../shared/index.ts";
3
+ type CreateData = {
4
+ readonly id: string;
5
+ readonly version: number;
6
+ };
7
+ export declare function createCreateHandler(access: AccessRule, scope: SubjectScope, subjectTypes: readonly [string, ...string[]]): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"create", import("zod").ZodObject<{
8
+ subjectType: import("zod").ZodEnum<{
9
+ [x: string]: string;
10
+ }>;
11
+ subjectId: import("zod").ZodString;
12
+ templateSlug: import("zod").ZodString;
13
+ variant: import("zod").ZodOptional<import("zod").ZodString>;
14
+ locale: import("zod").ZodDefault<import("zod").ZodString>;
15
+ variables: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
16
+ }, import("zod/v4/core").$strip>, CreateData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
17
+ export {};