@ansonlai/docx-redline-js 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -1
- package/README.md +28 -13
- package/core/list-targeting.js +12 -10
- package/dist/docx-redline-js.esm.js +837 -549
- package/dist/docx-redline-js.esm.js.map +4 -4
- package/dist/docx-redline-js.esm.min.js +93 -90
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/dist/docx-redline.bundle.cjs +837 -549
- package/dist/docx-redline.bundle.cjs.map +4 -4
- package/dist/docx-redline.bundle.js +837 -549
- package/dist/docx-redline.bundle.js.map +4 -4
- package/docs/AGENT_KNOWLEDGE_BASE.md +4 -1
- package/docs/schemas/document-operations.schema.json +168 -168
- package/engine/oxml-engine.js +215 -195
- package/engine/reconstruction-mode.js +183 -183
- package/index.d.ts +4 -0
- package/index.js +36 -1
- package/node/cli.js +2 -1
- package/orchestration/list-structural-fallback.js +530 -518
- package/package.json +1 -1
- package/pipeline/list-generation.js +203 -168
- package/pipeline/serialization.js +111 -94
- package/services/batch-operation-orchestrator.js +6 -0
- package/services/document-inspection.js +10 -7
- package/services/document-operation-applier.js +2 -0
- package/services/document-operation-contract.js +553 -537
- package/services/document-operation-mutations.js +1140 -1011
- package/services/numbering-helpers.js +108 -0
- package/services/operation-batch-compiler.js +440 -436
- package/services/operation-heuristics.js +197 -173
- package/services/revision-comment-management.js +601 -594
- package/services/standalone-operation-runner.d.ts +429 -427
- package/services/table-reconciliation.js +48 -46
|
@@ -1,427 +1,429 @@
|
|
|
1
|
-
import type { ExistingRevisionsPolicy, RedlineError, RedlineStatus, RevisionToken } from '../index.js';
|
|
2
|
-
|
|
3
|
-
export interface ParagraphTargetDescriptor {
|
|
4
|
-
text?: string;
|
|
5
|
-
exactText?: string;
|
|
6
|
-
index?: number | string;
|
|
7
|
-
paragraphIndex?: number | string;
|
|
8
|
-
paragraphId?: string;
|
|
9
|
-
occurrence?: number;
|
|
10
|
-
inTable?: boolean;
|
|
11
|
-
fingerprint?: string;
|
|
12
|
-
sourceFingerprint?: string;
|
|
13
|
-
/** Defaults to rejected for restore operations and accepted for all other operations. */
|
|
14
|
-
revisionView?: 'accepted' | 'rejected';
|
|
15
|
-
captureRef?: string;
|
|
16
|
-
select?: string;
|
|
17
|
-
createdByOperation?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface InsertionAffinity {
|
|
21
|
-
formatting?: 'left' | 'right' | 'none';
|
|
22
|
-
hyperlink?: 'inside' | 'outside' | 'preserve';
|
|
23
|
-
revision?: 'coalesce_same_author' | 'separate';
|
|
24
|
-
bookmark?: 'inside' | 'outside';
|
|
25
|
-
comment?: 'inside' | 'outside';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface RejectedTextInsertionAnchor {
|
|
29
|
-
exactText: string;
|
|
30
|
-
occurrence?: number;
|
|
31
|
-
offset: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface LocalizedReplacement {
|
|
35
|
-
find: string;
|
|
36
|
-
replace: string;
|
|
37
|
-
occurrence?: number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** A header/footer part path from `inspect().headersFooters`, or a selector. */
|
|
41
|
-
export type HeaderFooterPartSelector =
|
|
42
|
-
| string
|
|
43
|
-
| { kind: 'header' | 'footer'; type?: 'default' | 'first' | 'even'; section?: number };
|
|
44
|
-
|
|
45
|
-
export interface DocumentOperationBase {
|
|
46
|
-
operationId?: string;
|
|
47
|
-
/** Target a header or footer instead of the body. Comments are not supported there. */
|
|
48
|
-
part?: HeaderFooterPartSelector;
|
|
49
|
-
captureKey?: string;
|
|
50
|
-
target?: string | ParagraphTargetDescriptor;
|
|
51
|
-
targetRef?: number | string | null;
|
|
52
|
-
author?: string;
|
|
53
|
-
generateRedlines?: boolean;
|
|
54
|
-
existingRevisions?: ExistingRevisionsPolicy;
|
|
55
|
-
pairReplacements?: boolean;
|
|
56
|
-
insertionAffinity?: InsertionAffinity;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface RedlineDocumentOperationCommon extends DocumentOperationBase {
|
|
60
|
-
structuredContent?: boolean;
|
|
61
|
-
targetEnd?: ParagraphTargetDescriptor;
|
|
62
|
-
targetEndRef?: number | string | null;
|
|
63
|
-
/** Required when type is insert and target.revisionView is rejected. */
|
|
64
|
-
anchor?: RejectedTextInsertionAnchor;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type RedlineDocumentOperation =
|
|
68
|
-
| (RedlineDocumentOperationCommon & {
|
|
69
|
-
type: 'redline' | 'replace';
|
|
70
|
-
modified: string;
|
|
71
|
-
replacements?: never;
|
|
72
|
-
})
|
|
73
|
-
| (RedlineDocumentOperationCommon & {
|
|
74
|
-
type: 'redline' | 'replace';
|
|
75
|
-
modified?: never;
|
|
76
|
-
/** Exact, case-sensitive replacements in one batch-start accepted-view paragraph. */
|
|
77
|
-
replacements: LocalizedReplacement[];
|
|
78
|
-
})
|
|
79
|
-
| (RedlineDocumentOperationCommon & {
|
|
80
|
-
type: 'format' | 'list-change' | 'table-reconciliation' | 'insert';
|
|
81
|
-
modified: string;
|
|
82
|
-
replacements?: never;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
interface RestoreDocumentOperationCommon extends DocumentOperationBase {
|
|
86
|
-
type: 'restore';
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export type RestoreDocumentOperation =
|
|
90
|
-
| (RestoreDocumentOperationCommon & {
|
|
91
|
-
modified: string | string[];
|
|
92
|
-
replacements?: never;
|
|
93
|
-
targetEnd?: ParagraphTargetDescriptor;
|
|
94
|
-
targetEndRef?: number | string | null;
|
|
95
|
-
})
|
|
96
|
-
| (RestoreDocumentOperationCommon & {
|
|
97
|
-
modified?: never;
|
|
98
|
-
/** Exact, case-sensitive replacements in one strong rejected-view paragraph. */
|
|
99
|
-
replacements: LocalizedReplacement[];
|
|
100
|
-
targetEnd?: never;
|
|
101
|
-
targetEndRef?: never;
|
|
102
|
-
})
|
|
103
|
-
| (RestoreDocumentOperationCommon & {
|
|
104
|
-
/** Omit modified to restore one strong rejected-view paragraph verbatim. */
|
|
105
|
-
modified?: never;
|
|
106
|
-
replacements?: never;
|
|
107
|
-
targetEnd?: never;
|
|
108
|
-
targetEndRef?: never;
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
export interface DeleteDocumentOperation extends DocumentOperationBase {
|
|
112
|
-
type: 'delete';
|
|
113
|
-
modified?: '';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface CommentDocumentOperation extends DocumentOperationBase {
|
|
117
|
-
type: 'comment';
|
|
118
|
-
textToComment?: string;
|
|
119
|
-
commentContent: string;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export interface CommentReplyDocumentOperation {
|
|
123
|
-
type: 'comment_reply';
|
|
124
|
-
operationId?: string;
|
|
125
|
-
parentCommentId: number | string;
|
|
126
|
-
commentContent: string;
|
|
127
|
-
author?: string;
|
|
128
|
-
date?: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Resolves (or with `resolved: false`, reopens) the whole thread containing `commentId`. Body-only. */
|
|
132
|
-
export interface CommentResolveDocumentOperation {
|
|
133
|
-
type: 'comment_resolve';
|
|
134
|
-
operationId?: string;
|
|
135
|
-
commentId: number | string;
|
|
136
|
-
resolved?: boolean;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export interface CharacterFormatProperties {
|
|
140
|
-
bold?: boolean;
|
|
141
|
-
italic?: boolean;
|
|
142
|
-
underline?: boolean;
|
|
143
|
-
strike?: boolean;
|
|
144
|
-
strikethrough?: boolean;
|
|
145
|
-
highlight?: string | null;
|
|
146
|
-
color?: string | null;
|
|
147
|
-
fontSize?: number | string | null;
|
|
148
|
-
fontFamily?: string | null;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface ParagraphFormatProperties {
|
|
152
|
-
alignment?: 'left' | 'center' | 'right' | 'both';
|
|
153
|
-
keepNext?: boolean;
|
|
154
|
-
keepLines?: boolean;
|
|
155
|
-
pageBreakBefore?: boolean;
|
|
156
|
-
style?: string | null;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export interface HighlightDocumentOperation extends DocumentOperationBase {
|
|
160
|
-
type: 'highlight';
|
|
161
|
-
textToHighlight: string;
|
|
162
|
-
color?: string;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export interface CharacterFormatDocumentOperation extends DocumentOperationBase {
|
|
166
|
-
type: 'format' | 'character-format';
|
|
167
|
-
textToFormat: string;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
|
|
|
183
|
-
|
|
|
184
|
-
|
|
|
185
|
-
|
|
|
186
|
-
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
export function
|
|
405
|
-
|
|
406
|
-
export function
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
1
|
+
import type { ExistingRevisionsPolicy, RedlineError, RedlineStatus, RevisionToken } from '../index.js';
|
|
2
|
+
|
|
3
|
+
export interface ParagraphTargetDescriptor {
|
|
4
|
+
text?: string;
|
|
5
|
+
exactText?: string;
|
|
6
|
+
index?: number | string;
|
|
7
|
+
paragraphIndex?: number | string;
|
|
8
|
+
paragraphId?: string;
|
|
9
|
+
occurrence?: number;
|
|
10
|
+
inTable?: boolean;
|
|
11
|
+
fingerprint?: string;
|
|
12
|
+
sourceFingerprint?: string;
|
|
13
|
+
/** Defaults to rejected for restore operations and accepted for all other operations. */
|
|
14
|
+
revisionView?: 'accepted' | 'rejected';
|
|
15
|
+
captureRef?: string;
|
|
16
|
+
select?: string;
|
|
17
|
+
createdByOperation?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface InsertionAffinity {
|
|
21
|
+
formatting?: 'left' | 'right' | 'none';
|
|
22
|
+
hyperlink?: 'inside' | 'outside' | 'preserve';
|
|
23
|
+
revision?: 'coalesce_same_author' | 'separate';
|
|
24
|
+
bookmark?: 'inside' | 'outside';
|
|
25
|
+
comment?: 'inside' | 'outside';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RejectedTextInsertionAnchor {
|
|
29
|
+
exactText: string;
|
|
30
|
+
occurrence?: number;
|
|
31
|
+
offset: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface LocalizedReplacement {
|
|
35
|
+
find: string;
|
|
36
|
+
replace: string;
|
|
37
|
+
occurrence?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A header/footer part path from `inspect().headersFooters`, or a selector. */
|
|
41
|
+
export type HeaderFooterPartSelector =
|
|
42
|
+
| string
|
|
43
|
+
| { kind: 'header' | 'footer'; type?: 'default' | 'first' | 'even'; section?: number };
|
|
44
|
+
|
|
45
|
+
export interface DocumentOperationBase {
|
|
46
|
+
operationId?: string;
|
|
47
|
+
/** Target a header or footer instead of the body. Comments are not supported there. */
|
|
48
|
+
part?: HeaderFooterPartSelector;
|
|
49
|
+
captureKey?: string;
|
|
50
|
+
target?: string | ParagraphTargetDescriptor;
|
|
51
|
+
targetRef?: number | string | null;
|
|
52
|
+
author?: string;
|
|
53
|
+
generateRedlines?: boolean;
|
|
54
|
+
existingRevisions?: ExistingRevisionsPolicy;
|
|
55
|
+
pairReplacements?: boolean;
|
|
56
|
+
insertionAffinity?: InsertionAffinity;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface RedlineDocumentOperationCommon extends DocumentOperationBase {
|
|
60
|
+
structuredContent?: boolean;
|
|
61
|
+
targetEnd?: ParagraphTargetDescriptor;
|
|
62
|
+
targetEndRef?: number | string | null;
|
|
63
|
+
/** Required when type is insert and target.revisionView is rejected. */
|
|
64
|
+
anchor?: RejectedTextInsertionAnchor;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type RedlineDocumentOperation =
|
|
68
|
+
| (RedlineDocumentOperationCommon & {
|
|
69
|
+
type: 'redline' | 'replace';
|
|
70
|
+
modified: string;
|
|
71
|
+
replacements?: never;
|
|
72
|
+
})
|
|
73
|
+
| (RedlineDocumentOperationCommon & {
|
|
74
|
+
type: 'redline' | 'replace';
|
|
75
|
+
modified?: never;
|
|
76
|
+
/** Exact, case-sensitive replacements in one batch-start accepted-view paragraph. */
|
|
77
|
+
replacements: LocalizedReplacement[];
|
|
78
|
+
})
|
|
79
|
+
| (RedlineDocumentOperationCommon & {
|
|
80
|
+
type: 'format' | 'list-change' | 'table-reconciliation' | 'insert';
|
|
81
|
+
modified: string;
|
|
82
|
+
replacements?: never;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
interface RestoreDocumentOperationCommon extends DocumentOperationBase {
|
|
86
|
+
type: 'restore';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type RestoreDocumentOperation =
|
|
90
|
+
| (RestoreDocumentOperationCommon & {
|
|
91
|
+
modified: string | string[];
|
|
92
|
+
replacements?: never;
|
|
93
|
+
targetEnd?: ParagraphTargetDescriptor;
|
|
94
|
+
targetEndRef?: number | string | null;
|
|
95
|
+
})
|
|
96
|
+
| (RestoreDocumentOperationCommon & {
|
|
97
|
+
modified?: never;
|
|
98
|
+
/** Exact, case-sensitive replacements in one strong rejected-view paragraph. */
|
|
99
|
+
replacements: LocalizedReplacement[];
|
|
100
|
+
targetEnd?: never;
|
|
101
|
+
targetEndRef?: never;
|
|
102
|
+
})
|
|
103
|
+
| (RestoreDocumentOperationCommon & {
|
|
104
|
+
/** Omit modified to restore one strong rejected-view paragraph verbatim. */
|
|
105
|
+
modified?: never;
|
|
106
|
+
replacements?: never;
|
|
107
|
+
targetEnd?: never;
|
|
108
|
+
targetEndRef?: never;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export interface DeleteDocumentOperation extends DocumentOperationBase {
|
|
112
|
+
type: 'delete';
|
|
113
|
+
modified?: '';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface CommentDocumentOperation extends DocumentOperationBase {
|
|
117
|
+
type: 'comment';
|
|
118
|
+
textToComment?: string;
|
|
119
|
+
commentContent: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface CommentReplyDocumentOperation {
|
|
123
|
+
type: 'comment_reply';
|
|
124
|
+
operationId?: string;
|
|
125
|
+
parentCommentId: number | string;
|
|
126
|
+
commentContent: string;
|
|
127
|
+
author?: string;
|
|
128
|
+
date?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Resolves (or with `resolved: false`, reopens) the whole thread containing `commentId`. Body-only. */
|
|
132
|
+
export interface CommentResolveDocumentOperation {
|
|
133
|
+
type: 'comment_resolve';
|
|
134
|
+
operationId?: string;
|
|
135
|
+
commentId: number | string;
|
|
136
|
+
resolved?: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface CharacterFormatProperties {
|
|
140
|
+
bold?: boolean;
|
|
141
|
+
italic?: boolean;
|
|
142
|
+
underline?: boolean;
|
|
143
|
+
strike?: boolean;
|
|
144
|
+
strikethrough?: boolean;
|
|
145
|
+
highlight?: string | null;
|
|
146
|
+
color?: string | null;
|
|
147
|
+
fontSize?: number | string | null;
|
|
148
|
+
fontFamily?: string | null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface ParagraphFormatProperties {
|
|
152
|
+
alignment?: 'left' | 'center' | 'right' | 'both';
|
|
153
|
+
keepNext?: boolean;
|
|
154
|
+
keepLines?: boolean;
|
|
155
|
+
pageBreakBefore?: boolean;
|
|
156
|
+
style?: string | null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface HighlightDocumentOperation extends DocumentOperationBase {
|
|
160
|
+
type: 'highlight';
|
|
161
|
+
textToHighlight: string;
|
|
162
|
+
color?: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface CharacterFormatDocumentOperation extends DocumentOperationBase {
|
|
166
|
+
type: 'format' | 'character-format';
|
|
167
|
+
textToFormat: string;
|
|
168
|
+
/** 1-based match of `textToFormat` inside the resolved paragraph (default 1). Independent of `target.occurrence`. */
|
|
169
|
+
textOccurrence?: number;
|
|
170
|
+
properties: CharacterFormatProperties;
|
|
171
|
+
formattingRevisionPolicy?: 'always' | 'coalesce-own-insertion';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ParagraphFormatDocumentOperation extends DocumentOperationBase {
|
|
175
|
+
type: 'paragraph-format';
|
|
176
|
+
properties: ParagraphFormatProperties;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export type DocumentOperation =
|
|
180
|
+
| RedlineDocumentOperation
|
|
181
|
+
| RestoreDocumentOperation
|
|
182
|
+
| DeleteDocumentOperation
|
|
183
|
+
| CommentDocumentOperation
|
|
184
|
+
| CommentReplyDocumentOperation
|
|
185
|
+
| CommentResolveDocumentOperation
|
|
186
|
+
| HighlightDocumentOperation
|
|
187
|
+
| CharacterFormatDocumentOperation
|
|
188
|
+
| ParagraphFormatDocumentOperation;
|
|
189
|
+
|
|
190
|
+
export interface ResolvedDocumentTarget {
|
|
191
|
+
index: number;
|
|
192
|
+
paragraphId: string | null;
|
|
193
|
+
text: string;
|
|
194
|
+
fingerprint?: string;
|
|
195
|
+
revisionView?: 'accepted' | 'rejected';
|
|
196
|
+
inTable?: boolean;
|
|
197
|
+
targetTextMatch?: {
|
|
198
|
+
mode: 'exact' | 'space_equivalent' | 'normalized';
|
|
199
|
+
differences?: Array<{
|
|
200
|
+
offset: number;
|
|
201
|
+
sourceCodePoint: string;
|
|
202
|
+
requestedCodePoint: string;
|
|
203
|
+
}>;
|
|
204
|
+
sourceExcerpt?: string;
|
|
205
|
+
requestedExcerpt?: string;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface ResolvedCommentAnchor {
|
|
210
|
+
requestIndex: number;
|
|
211
|
+
paragraphIndex: number;
|
|
212
|
+
text: string;
|
|
213
|
+
resolvedBy: 'exact_anchor' | 'space_equivalent_anchor';
|
|
214
|
+
start: number;
|
|
215
|
+
end: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface StandaloneRunnerOptions {
|
|
219
|
+
atomic?: boolean;
|
|
220
|
+
continueOnError?: boolean;
|
|
221
|
+
generateRedlines?: boolean;
|
|
222
|
+
existingRevisions?: ExistingRevisionsPolicy;
|
|
223
|
+
strictTargets?: boolean;
|
|
224
|
+
expectedRevision?: RevisionToken;
|
|
225
|
+
pairReplacements?: boolean;
|
|
226
|
+
insertionAffinity?: InsertionAffinity;
|
|
227
|
+
onInfo?: (message: string) => void;
|
|
228
|
+
onWarn?: (message: string) => void;
|
|
229
|
+
[key: string]: unknown;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface MutationReceiptRevisionItem {
|
|
233
|
+
id: string;
|
|
234
|
+
kind: 'ins' | 'del' | 'move_from' | 'move_to' | 'rPrChange' | 'pPrChange' | 'structural';
|
|
235
|
+
partName: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface MutationReceipt {
|
|
239
|
+
operationIndex: number;
|
|
240
|
+
operationId?: string;
|
|
241
|
+
attemptedDisposition: 'applied' | 'no_change' | 'refused' | 'not_attempted';
|
|
242
|
+
finalDisposition: 'applied' | 'no_change' | 'refused' | 'rolled_back' | 'not_attempted';
|
|
243
|
+
committed: boolean;
|
|
244
|
+
authorUsed?: string;
|
|
245
|
+
revisionItems: MutationReceiptRevisionItem[];
|
|
246
|
+
commentIds: string[];
|
|
247
|
+
numberingIds: string[];
|
|
248
|
+
relationshipIds: string[];
|
|
249
|
+
affectedTargets: ResolvedDocumentTarget[];
|
|
250
|
+
warnings: string[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export interface LocalizedReplacementChange {
|
|
254
|
+
kind: 'localized_replacement';
|
|
255
|
+
committed: boolean;
|
|
256
|
+
finalDisposition: 'applied' | 'rolled_back';
|
|
257
|
+
target: {
|
|
258
|
+
paragraphId?: string;
|
|
259
|
+
index?: number;
|
|
260
|
+
fingerprint?: string;
|
|
261
|
+
humanReference?: string;
|
|
262
|
+
};
|
|
263
|
+
context?: {
|
|
264
|
+
search?: string;
|
|
265
|
+
range?: string;
|
|
266
|
+
anchorMatchCount?: number;
|
|
267
|
+
humanReference?: string;
|
|
268
|
+
};
|
|
269
|
+
replacements: Array<{
|
|
270
|
+
find: string;
|
|
271
|
+
replace: string;
|
|
272
|
+
occurrence?: number;
|
|
273
|
+
matchMode?: 'space_equivalent';
|
|
274
|
+
beforeExcerpt: string;
|
|
275
|
+
afterExcerpt: string;
|
|
276
|
+
}>;
|
|
277
|
+
verification: {
|
|
278
|
+
acceptedViewMatchesCompiledText: boolean;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface DocumentOperationResult {
|
|
283
|
+
documentXml: string;
|
|
284
|
+
hasChanges: boolean;
|
|
285
|
+
numberingXml?: string | null;
|
|
286
|
+
commentsXml?: string | null;
|
|
287
|
+
commentsExtendedXml?: string | null;
|
|
288
|
+
commentsXmlMode?: 'merge' | 'replace';
|
|
289
|
+
commentsExtendedXmlMode?: 'merge' | 'replace';
|
|
290
|
+
warnings?: string[];
|
|
291
|
+
status?: RedlineStatus;
|
|
292
|
+
error?: RedlineError;
|
|
293
|
+
operationType: 'redline' | 'comment' | 'comment_reply' | 'comment_resolve' | 'highlight' | 'format' | 'paragraph-format';
|
|
294
|
+
authorUsed: string;
|
|
295
|
+
resolvedBy?: string;
|
|
296
|
+
resolvedTarget?: ResolvedDocumentTarget;
|
|
297
|
+
resolvedAnchor?: ResolvedCommentAnchor;
|
|
298
|
+
receipt?: MutationReceipt;
|
|
299
|
+
change?: LocalizedReplacementChange;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface BatchOperationItemResult {
|
|
303
|
+
index: number;
|
|
304
|
+
type: string;
|
|
305
|
+
operationType: 'redline' | 'comment' | 'comment_reply' | 'comment_resolve' | 'highlight' | 'format' | 'paragraph-format';
|
|
306
|
+
status: 'applied' | 'no_change' | 'error';
|
|
307
|
+
authorUsed: string;
|
|
308
|
+
resolvedBy?: string;
|
|
309
|
+
resolvedTarget?: ResolvedDocumentTarget;
|
|
310
|
+
resolvedAnchor?: ResolvedCommentAnchor;
|
|
311
|
+
warnings?: string[];
|
|
312
|
+
error?: RedlineError;
|
|
313
|
+
receipt?: MutationReceipt;
|
|
314
|
+
change?: LocalizedReplacementChange;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface DocumentOperationBatchResult {
|
|
318
|
+
documentXml: string;
|
|
319
|
+
hasChanges: boolean;
|
|
320
|
+
commentsXml: string | null;
|
|
321
|
+
commentsExtendedXml?: string | null;
|
|
322
|
+
commentsXmlMode?: 'merge' | 'replace';
|
|
323
|
+
commentsExtendedXmlMode?: 'merge' | 'replace';
|
|
324
|
+
numberingXmlParts: string[];
|
|
325
|
+
results: BatchOperationItemResult[];
|
|
326
|
+
receipts?: MutationReceipt[];
|
|
327
|
+
executionOrder: number[];
|
|
328
|
+
/** Authors attached to committed changes. Empty when an atomic batch rolls back. */
|
|
329
|
+
authorsUsed: string[];
|
|
330
|
+
rolledBack?: boolean;
|
|
331
|
+
status?: RedlineStatus;
|
|
332
|
+
error?: RedlineError;
|
|
333
|
+
warnings?: string[];
|
|
334
|
+
conflicts?: OperationConflict[];
|
|
335
|
+
retryPlan?: MutationRetryPlan;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface MutationRetryPlan {
|
|
339
|
+
base: 'original' | 'output';
|
|
340
|
+
committedIndexes: number[];
|
|
341
|
+
failedIndexes: number[];
|
|
342
|
+
unattemptedIndexes: number[];
|
|
343
|
+
replayWholeBatch: boolean;
|
|
344
|
+
sameArgumentsSafe: false;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface OperationPreflightItemResult {
|
|
348
|
+
index: number;
|
|
349
|
+
type: string;
|
|
350
|
+
operationType: 'redline' | 'comment' | 'comment_reply' | 'comment_resolve' | 'highlight' | 'format' | 'paragraph-format';
|
|
351
|
+
status: 'ready' | 'deferred' | 'error';
|
|
352
|
+
authorUsed: string;
|
|
353
|
+
resolvedBy?: string;
|
|
354
|
+
captureRef?: string;
|
|
355
|
+
select?: string;
|
|
356
|
+
resolvedTarget?: ResolvedDocumentTarget;
|
|
357
|
+
matchDiagnostics?: {
|
|
358
|
+
exactTextMatch: boolean;
|
|
359
|
+
normalizedTextMatch: boolean;
|
|
360
|
+
suppliedText: string;
|
|
361
|
+
actualText: string;
|
|
362
|
+
};
|
|
363
|
+
anchor?: {
|
|
364
|
+
text: string;
|
|
365
|
+
found: boolean;
|
|
366
|
+
resolvedBy?: 'exact_anchor' | 'space_equivalent_anchor';
|
|
367
|
+
start?: number;
|
|
368
|
+
end?: number;
|
|
369
|
+
candidates?: Array<{ start: number; end: number }>;
|
|
370
|
+
} | null;
|
|
371
|
+
hasRevisions?: boolean;
|
|
372
|
+
existingRevisions?: ExistingRevisionsPolicy;
|
|
373
|
+
warnings?: string[];
|
|
374
|
+
error?: RedlineError & { candidates?: ResolvedDocumentTarget[] };
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export interface OperationConflict {
|
|
378
|
+
code: 'OVERLAPPING_SOURCE_TARGETS' | 'OVERLAPPING_TEXT_EDITS' | 'REVISION_ORDER_CONFLICT' | 'CAPTURE_FANOUT_CONFLICT' | string;
|
|
379
|
+
message: string;
|
|
380
|
+
operationIndexes: number[];
|
|
381
|
+
target: ResolvedDocumentTarget;
|
|
382
|
+
recoveryVersion?: number;
|
|
383
|
+
category?: string;
|
|
384
|
+
recovery?: RedlineError['recovery'];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface OperationPreflightResult {
|
|
388
|
+
valid: boolean;
|
|
389
|
+
status: 'ok' | 'error';
|
|
390
|
+
results: OperationPreflightItemResult[];
|
|
391
|
+
conflicts: OperationConflict[];
|
|
392
|
+
authorsUsed: string[];
|
|
393
|
+
requiredArtifacts: { comments: boolean; numbering: boolean };
|
|
394
|
+
error?: RedlineError;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface OperationDependencyPlan {
|
|
398
|
+
valid: boolean;
|
|
399
|
+
scheduled?: Array<{ operation: DocumentOperation; index: number }>;
|
|
400
|
+
captureProducers?: Map<string, number>;
|
|
401
|
+
error?: RedlineError;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export function buildOperationDependencyPlan(operations?: DocumentOperation[]): OperationDependencyPlan;
|
|
405
|
+
|
|
406
|
+
export function orderOperationsForStableTargets(operations?: DocumentOperation[]): DocumentOperation[];
|
|
407
|
+
|
|
408
|
+
export function preflightOperations(
|
|
409
|
+
documentXml: string,
|
|
410
|
+
operations: DocumentOperation[],
|
|
411
|
+
author?: string,
|
|
412
|
+
options?: StandaloneRunnerOptions
|
|
413
|
+
): OperationPreflightResult;
|
|
414
|
+
|
|
415
|
+
export function applyOperationToDocumentXml(
|
|
416
|
+
documentXml: string,
|
|
417
|
+
operation: DocumentOperation,
|
|
418
|
+
author?: string,
|
|
419
|
+
runtimeContext?: Record<string, unknown> | null,
|
|
420
|
+
options?: StandaloneRunnerOptions
|
|
421
|
+
): Promise<DocumentOperationResult>;
|
|
422
|
+
|
|
423
|
+
export function applyOperationsToDocumentXml(
|
|
424
|
+
documentXml: string,
|
|
425
|
+
operations: DocumentOperation[],
|
|
426
|
+
author?: string,
|
|
427
|
+
runtimeContext?: Record<string, unknown> | null,
|
|
428
|
+
options?: StandaloneRunnerOptions
|
|
429
|
+
): Promise<DocumentOperationBatchResult>;
|