@bilig/workbook 0.107.3 → 0.119.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 (78) hide show
  1. package/README.md +39 -38
  2. package/dist/check.js +4 -1
  3. package/dist/check.js.map +1 -1
  4. package/dist/command-bundle.js +18 -3
  5. package/dist/command-bundle.js.map +1 -1
  6. package/dist/command-ops.js +257 -4
  7. package/dist/command-ops.js.map +1 -1
  8. package/dist/command-ranges.js +5 -1
  9. package/dist/command-ranges.js.map +1 -1
  10. package/dist/command-receipt-ranges.js +5 -1
  11. package/dist/command-receipt-ranges.js.map +1 -1
  12. package/dist/command-result-undo.js +6 -2
  13. package/dist/command-result-undo.js.map +1 -1
  14. package/dist/command-result.js +64 -3
  15. package/dist/command-result.js.map +1 -1
  16. package/dist/data-properties.d.ts +1 -0
  17. package/dist/data-properties.js +3 -0
  18. package/dist/data-properties.js.map +1 -1
  19. package/dist/describe.d.ts +6 -0
  20. package/dist/describe.js +10 -0
  21. package/dist/describe.js.map +1 -1
  22. package/dist/feature-plugin.d.ts +7 -1
  23. package/dist/feature-plugin.js +23 -1
  24. package/dist/feature-plugin.js.map +1 -1
  25. package/dist/features.d.ts +0 -6
  26. package/dist/features.js +17 -26
  27. package/dist/features.js.map +1 -1
  28. package/dist/find.js +94 -103
  29. package/dist/find.js.map +1 -1
  30. package/dist/formula.js +5 -2
  31. package/dist/formula.js.map +1 -1
  32. package/dist/index.d.ts +0 -1
  33. package/dist/index.js +0 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/model-action-validation.d.ts +2 -0
  36. package/dist/model-action-validation.js +71 -3
  37. package/dist/model-action-validation.js.map +1 -1
  38. package/dist/model.js +4 -1
  39. package/dist/model.js.map +1 -1
  40. package/dist/op-schema.d.ts +4 -0
  41. package/dist/op-schema.js +895 -0
  42. package/dist/op-schema.js.map +1 -0
  43. package/dist/plan-data.js +210 -55
  44. package/dist/plan-data.js.map +1 -1
  45. package/dist/readback.js +44 -1
  46. package/dist/readback.js.map +1 -1
  47. package/dist/requirements.js +41 -3
  48. package/dist/requirements.js.map +1 -1
  49. package/dist/result.d.ts +7 -0
  50. package/dist/result.js.map +1 -1
  51. package/dist/run-apply.js +5 -2
  52. package/dist/run-apply.js.map +1 -1
  53. package/dist/run-command-receipts.js +133 -3
  54. package/dist/run-command-receipts.js.map +1 -1
  55. package/dist/run-data.js +6 -2
  56. package/dist/run-data.js.map +1 -1
  57. package/dist/run-description-noop.d.ts +2 -0
  58. package/dist/run-description-noop.js +330 -0
  59. package/dist/run-description-noop.js.map +1 -0
  60. package/dist/run-description.js +23 -2
  61. package/dist/run-description.js.map +1 -1
  62. package/dist/run-runtime-boundary.js +39 -5
  63. package/dist/run-runtime-boundary.js.map +1 -1
  64. package/dist/run.d.ts +1 -0
  65. package/dist/run.js.map +1 -1
  66. package/dist/schema-fragments.d.ts +16 -0
  67. package/dist/schema-fragments.js +246 -0
  68. package/dist/schema-fragments.js.map +1 -0
  69. package/dist/schema-noop.d.ts +9 -0
  70. package/dist/schema-noop.js +128 -0
  71. package/dist/schema-noop.js.map +1 -0
  72. package/dist/schema.js +266 -145
  73. package/dist/schema.js.map +1 -1
  74. package/dist/testing.js +19 -4
  75. package/dist/testing.js.map +1 -1
  76. package/dist/verify.js +34 -0
  77. package/dist/verify.js.map +1 -1
  78. package/package.json +12 -5
@@ -0,0 +1,895 @@
1
+ import { CELL_BORDER_STYLE_VALUES, CELL_BORDER_WEIGHT_VALUES, CELL_HORIZONTAL_ALIGNMENT_VALUES, CELL_VERTICAL_ALIGNMENT_VALUES, } from '@bilig/protocol';
2
+ const nonEmptyStringSchema = { type: 'string', minLength: 1 };
3
+ const nonNegativeIntegerSchema = { type: 'integer', minimum: 0, maximum: Number.MAX_SAFE_INTEGER };
4
+ const positiveIntegerSchema = { type: 'integer', minimum: 1, maximum: Number.MAX_SAFE_INTEGER };
5
+ const booleanSchema = { type: 'boolean' };
6
+ const numberSchema = { type: 'number' };
7
+ const cellRangeRefSchema = { $ref: '#/$defs/cellRange' };
8
+ const literalInputRefSchema = { $ref: '#/$defs/literalInput' };
9
+ export const literalInputSchema = {
10
+ oneOf: [{ type: 'null' }, booleanSchema, numberSchema, { type: 'string' }],
11
+ };
12
+ const nullableStringSchema = { oneOf: [{ type: 'string' }, { type: 'null' }] };
13
+ const nullableNumberSchema = { oneOf: [numberSchema, { type: 'null' }] };
14
+ const nullableBooleanSchema = { oneOf: [booleanSchema, { type: 'null' }] };
15
+ const styleFillPatchSchema = {
16
+ oneOf: [
17
+ { type: 'null' },
18
+ {
19
+ type: 'object',
20
+ additionalProperties: false,
21
+ properties: {
22
+ backgroundColor: nullableStringSchema,
23
+ },
24
+ },
25
+ ],
26
+ };
27
+ const styleFontPatchSchema = {
28
+ oneOf: [
29
+ { type: 'null' },
30
+ {
31
+ type: 'object',
32
+ additionalProperties: false,
33
+ properties: {
34
+ family: nullableStringSchema,
35
+ size: nullableNumberSchema,
36
+ bold: nullableBooleanSchema,
37
+ italic: nullableBooleanSchema,
38
+ underline: nullableBooleanSchema,
39
+ color: nullableStringSchema,
40
+ },
41
+ },
42
+ ],
43
+ };
44
+ const styleAlignmentPatchSchema = {
45
+ oneOf: [
46
+ { type: 'null' },
47
+ {
48
+ type: 'object',
49
+ additionalProperties: false,
50
+ properties: {
51
+ horizontal: { oneOf: [{ enum: CELL_HORIZONTAL_ALIGNMENT_VALUES }, { type: 'null' }] },
52
+ vertical: { oneOf: [{ enum: CELL_VERTICAL_ALIGNMENT_VALUES }, { type: 'null' }] },
53
+ wrap: nullableBooleanSchema,
54
+ indent: nullableNumberSchema,
55
+ shrinkToFit: nullableBooleanSchema,
56
+ readingOrder: nullableNumberSchema,
57
+ textRotation: nullableNumberSchema,
58
+ justifyLastLine: nullableBooleanSchema,
59
+ },
60
+ },
61
+ ],
62
+ };
63
+ const styleBorderSidePatchSchema = {
64
+ oneOf: [
65
+ { type: 'null' },
66
+ {
67
+ type: 'object',
68
+ additionalProperties: false,
69
+ properties: {
70
+ style: { oneOf: [{ enum: CELL_BORDER_STYLE_VALUES }, { type: 'null' }] },
71
+ weight: { oneOf: [{ enum: CELL_BORDER_WEIGHT_VALUES }, { type: 'null' }] },
72
+ color: nullableStringSchema,
73
+ },
74
+ },
75
+ ],
76
+ };
77
+ const styleBordersPatchSchema = {
78
+ oneOf: [
79
+ { type: 'null' },
80
+ {
81
+ type: 'object',
82
+ additionalProperties: false,
83
+ properties: {
84
+ top: styleBorderSidePatchSchema,
85
+ right: styleBorderSidePatchSchema,
86
+ bottom: styleBorderSidePatchSchema,
87
+ left: styleBorderSidePatchSchema,
88
+ },
89
+ },
90
+ ],
91
+ };
92
+ export const cellStylePatchSchema = {
93
+ type: 'object',
94
+ additionalProperties: false,
95
+ properties: {
96
+ fill: styleFillPatchSchema,
97
+ font: styleFontPatchSchema,
98
+ alignment: styleAlignmentPatchSchema,
99
+ borders: styleBordersPatchSchema,
100
+ },
101
+ };
102
+ const styleFillRecordSchema = {
103
+ type: 'object',
104
+ required: ['backgroundColor'],
105
+ additionalProperties: true,
106
+ properties: {
107
+ backgroundColor: { type: 'string' },
108
+ },
109
+ };
110
+ const styleFontRecordSchema = {
111
+ type: 'object',
112
+ additionalProperties: true,
113
+ properties: {
114
+ family: { type: 'string' },
115
+ size: numberSchema,
116
+ bold: booleanSchema,
117
+ italic: booleanSchema,
118
+ underline: booleanSchema,
119
+ color: { type: 'string' },
120
+ },
121
+ };
122
+ const styleAlignmentRecordSchema = {
123
+ type: 'object',
124
+ additionalProperties: true,
125
+ properties: {
126
+ horizontal: { enum: CELL_HORIZONTAL_ALIGNMENT_VALUES },
127
+ vertical: { enum: CELL_VERTICAL_ALIGNMENT_VALUES },
128
+ wrap: booleanSchema,
129
+ indent: numberSchema,
130
+ shrinkToFit: booleanSchema,
131
+ readingOrder: numberSchema,
132
+ textRotation: numberSchema,
133
+ justifyLastLine: booleanSchema,
134
+ },
135
+ };
136
+ const styleBorderSideRecordSchema = {
137
+ type: 'object',
138
+ required: ['style', 'weight', 'color'],
139
+ additionalProperties: true,
140
+ properties: {
141
+ style: { enum: CELL_BORDER_STYLE_VALUES },
142
+ weight: { enum: CELL_BORDER_WEIGHT_VALUES },
143
+ color: { type: 'string' },
144
+ },
145
+ };
146
+ const styleBordersRecordSchema = {
147
+ type: 'object',
148
+ additionalProperties: true,
149
+ properties: {
150
+ top: styleBorderSideRecordSchema,
151
+ right: styleBorderSideRecordSchema,
152
+ bottom: styleBorderSideRecordSchema,
153
+ left: styleBorderSideRecordSchema,
154
+ },
155
+ };
156
+ const cellStyleRecordSchema = {
157
+ type: 'object',
158
+ required: ['id'],
159
+ additionalProperties: true,
160
+ properties: {
161
+ id: nonEmptyStringSchema,
162
+ fill: styleFillRecordSchema,
163
+ font: styleFontRecordSchema,
164
+ alignment: styleAlignmentRecordSchema,
165
+ borders: styleBordersRecordSchema,
166
+ protection: {
167
+ type: 'object',
168
+ additionalProperties: true,
169
+ properties: {
170
+ locked: booleanSchema,
171
+ hidden: booleanSchema,
172
+ },
173
+ },
174
+ },
175
+ };
176
+ const cellNumberFormatRecordSchema = {
177
+ type: 'object',
178
+ required: ['id', 'code', 'kind'],
179
+ additionalProperties: true,
180
+ properties: {
181
+ id: nonEmptyStringSchema,
182
+ code: { type: 'string' },
183
+ kind: { enum: ['general', 'number', 'currency', 'accounting', 'percent', 'date', 'time', 'datetime', 'text'] },
184
+ },
185
+ };
186
+ const axisEntrySchema = {
187
+ type: 'object',
188
+ required: ['id', 'index'],
189
+ additionalProperties: true,
190
+ properties: {
191
+ id: nonEmptyStringSchema,
192
+ index: nonNegativeIntegerSchema,
193
+ size: { oneOf: [positiveIntegerSchema, { type: 'null' }] },
194
+ hidden: nullableBooleanSchema,
195
+ filterHidden: nullableBooleanSchema,
196
+ },
197
+ };
198
+ const sortKeySchema = {
199
+ type: 'object',
200
+ required: ['keyAddress', 'direction'],
201
+ additionalProperties: true,
202
+ properties: {
203
+ keyAddress: nonEmptyStringSchema,
204
+ direction: { enum: ['asc', 'desc'] },
205
+ },
206
+ };
207
+ const workbookCalculationSettingsSchema = {
208
+ type: 'object',
209
+ required: ['mode'],
210
+ additionalProperties: true,
211
+ properties: {
212
+ mode: { enum: ['automatic', 'manual'] },
213
+ compatibilityMode: { enum: ['excel-modern', 'odf-1.4'] },
214
+ dateSystem: { enum: ['1900', '1904'] },
215
+ calcId: nullableNumberSchema,
216
+ iterate: nullableBooleanSchema,
217
+ iterateCount: nullableNumberSchema,
218
+ iterateDelta: nullableStringSchema,
219
+ fullPrecision: nullableBooleanSchema,
220
+ fullCalcOnLoad: nullableBooleanSchema,
221
+ forceFullCalc: nullableBooleanSchema,
222
+ calcOnSave: nullableBooleanSchema,
223
+ calcCompleted: nullableBooleanSchema,
224
+ concurrentCalc: nullableBooleanSchema,
225
+ },
226
+ };
227
+ const workbookVolatileContextSchema = {
228
+ type: 'object',
229
+ required: ['recalcEpoch'],
230
+ additionalProperties: true,
231
+ properties: {
232
+ recalcEpoch: numberSchema,
233
+ },
234
+ };
235
+ const sheetProtectionSchema = {
236
+ type: 'object',
237
+ required: ['sheetName'],
238
+ additionalProperties: true,
239
+ properties: {
240
+ sheetName: nonEmptyStringSchema,
241
+ hideFormulas: booleanSchema,
242
+ },
243
+ };
244
+ const rangeProtectionSchema = {
245
+ type: 'object',
246
+ required: ['id', 'range'],
247
+ additionalProperties: true,
248
+ properties: {
249
+ id: nonEmptyStringSchema,
250
+ range: cellRangeRefSchema,
251
+ hideFormulas: booleanSchema,
252
+ },
253
+ };
254
+ const validationListSourceSchema = {
255
+ oneOf: [
256
+ {
257
+ type: 'object',
258
+ required: ['kind', 'name'],
259
+ additionalProperties: true,
260
+ properties: { kind: { const: 'named-range' }, name: nonEmptyStringSchema },
261
+ },
262
+ {
263
+ type: 'object',
264
+ required: ['kind', 'sheetName', 'address'],
265
+ additionalProperties: true,
266
+ properties: { kind: { const: 'cell-ref' }, sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema },
267
+ },
268
+ {
269
+ type: 'object',
270
+ required: ['kind', 'sheetName', 'startAddress', 'endAddress'],
271
+ additionalProperties: true,
272
+ properties: {
273
+ kind: { const: 'range-ref' },
274
+ sheetName: nonEmptyStringSchema,
275
+ startAddress: nonEmptyStringSchema,
276
+ endAddress: nonEmptyStringSchema,
277
+ },
278
+ },
279
+ {
280
+ type: 'object',
281
+ required: ['kind', 'tableName', 'columnName'],
282
+ additionalProperties: true,
283
+ properties: { kind: { const: 'structured-ref' }, tableName: nonEmptyStringSchema, columnName: nonEmptyStringSchema },
284
+ },
285
+ {
286
+ type: 'object',
287
+ required: ['kind', 'formula'],
288
+ additionalProperties: true,
289
+ properties: { kind: { const: 'formula' }, formula: { type: 'string' } },
290
+ },
291
+ ],
292
+ };
293
+ const rangeComparisonOperatorSchema = {
294
+ enum: ['between', 'notBetween'],
295
+ };
296
+ const singleComparisonOperatorSchema = {
297
+ enum: ['equal', 'notEqual', 'greaterThan', 'greaterThanOrEqual', 'lessThan', 'lessThanOrEqual'],
298
+ };
299
+ const scalarValidationKindSchema = {
300
+ enum: ['whole', 'decimal', 'date', 'time', 'textLength'],
301
+ };
302
+ const twoValueComparisonValuesSchema = {
303
+ type: 'array',
304
+ minItems: 2,
305
+ maxItems: 2,
306
+ items: literalInputRefSchema,
307
+ };
308
+ const oneValueComparisonValuesSchema = {
309
+ type: 'array',
310
+ minItems: 1,
311
+ maxItems: 1,
312
+ items: literalInputRefSchema,
313
+ };
314
+ const validationRuleSchema = {
315
+ oneOf: [
316
+ {
317
+ type: 'object',
318
+ required: ['kind'],
319
+ additionalProperties: true,
320
+ properties: {
321
+ kind: { const: 'list' },
322
+ values: { type: 'array', items: literalInputRefSchema },
323
+ source: validationListSourceSchema,
324
+ },
325
+ oneOf: [
326
+ { required: ['values'], not: { required: ['source'] } },
327
+ { required: ['source'], not: { required: ['values'] } },
328
+ ],
329
+ },
330
+ {
331
+ type: 'object',
332
+ required: ['kind'],
333
+ additionalProperties: true,
334
+ properties: {
335
+ kind: { const: 'checkbox' },
336
+ checkedValue: literalInputRefSchema,
337
+ uncheckedValue: literalInputRefSchema,
338
+ },
339
+ },
340
+ { type: 'object', required: ['kind'], additionalProperties: true, properties: { kind: { const: 'any' } } },
341
+ {
342
+ type: 'object',
343
+ required: ['kind', 'operator', 'values'],
344
+ additionalProperties: true,
345
+ properties: {
346
+ kind: scalarValidationKindSchema,
347
+ operator: rangeComparisonOperatorSchema,
348
+ values: twoValueComparisonValuesSchema,
349
+ },
350
+ },
351
+ {
352
+ type: 'object',
353
+ required: ['kind', 'operator', 'values'],
354
+ additionalProperties: true,
355
+ properties: {
356
+ kind: scalarValidationKindSchema,
357
+ operator: singleComparisonOperatorSchema,
358
+ values: oneValueComparisonValuesSchema,
359
+ },
360
+ },
361
+ ],
362
+ };
363
+ const dataValidationSchema = {
364
+ type: 'object',
365
+ required: ['range', 'rule'],
366
+ additionalProperties: true,
367
+ properties: {
368
+ range: cellRangeRefSchema,
369
+ rule: validationRuleSchema,
370
+ allowBlank: booleanSchema,
371
+ showDropdown: booleanSchema,
372
+ promptTitle: { type: 'string' },
373
+ promptMessage: { type: 'string' },
374
+ errorStyle: { enum: ['stop', 'warning', 'information'] },
375
+ errorTitle: { type: 'string' },
376
+ errorMessage: { type: 'string' },
377
+ },
378
+ };
379
+ const conditionalFormatRuleSchema = {
380
+ oneOf: [
381
+ {
382
+ type: 'object',
383
+ required: ['kind', 'operator', 'values'],
384
+ additionalProperties: true,
385
+ properties: {
386
+ kind: { const: 'cellIs' },
387
+ operator: rangeComparisonOperatorSchema,
388
+ values: twoValueComparisonValuesSchema,
389
+ },
390
+ },
391
+ {
392
+ type: 'object',
393
+ required: ['kind', 'operator', 'values'],
394
+ additionalProperties: true,
395
+ properties: {
396
+ kind: { const: 'cellIs' },
397
+ operator: singleComparisonOperatorSchema,
398
+ values: oneValueComparisonValuesSchema,
399
+ },
400
+ },
401
+ {
402
+ type: 'object',
403
+ required: ['kind', 'text'],
404
+ additionalProperties: true,
405
+ properties: {
406
+ kind: { const: 'textContains' },
407
+ text: { type: 'string' },
408
+ caseSensitive: booleanSchema,
409
+ },
410
+ },
411
+ {
412
+ type: 'object',
413
+ required: ['kind', 'formula'],
414
+ additionalProperties: true,
415
+ properties: { kind: { const: 'formula' }, formula: { type: 'string' } },
416
+ },
417
+ { type: 'object', required: ['kind'], additionalProperties: true, properties: { kind: { const: 'blanks' } } },
418
+ { type: 'object', required: ['kind'], additionalProperties: true, properties: { kind: { const: 'notBlanks' } } },
419
+ ],
420
+ };
421
+ const conditionalFormatSchema = {
422
+ type: 'object',
423
+ required: ['id', 'range', 'rule', 'style'],
424
+ additionalProperties: true,
425
+ properties: {
426
+ id: nonEmptyStringSchema,
427
+ range: cellRangeRefSchema,
428
+ rule: conditionalFormatRuleSchema,
429
+ style: cellStylePatchSchema,
430
+ stopIfTrue: booleanSchema,
431
+ priority: nonNegativeIntegerSchema,
432
+ },
433
+ };
434
+ const conditionalFormatArtifactsSchema = {
435
+ type: 'object',
436
+ required: ['xml'],
437
+ additionalProperties: true,
438
+ properties: {
439
+ xml: { type: 'string' },
440
+ },
441
+ };
442
+ const commentEntrySchema = {
443
+ type: 'object',
444
+ required: ['id', 'body'],
445
+ additionalProperties: true,
446
+ properties: {
447
+ id: nonEmptyStringSchema,
448
+ body: { type: 'string' },
449
+ authorUserId: { type: 'string' },
450
+ authorDisplayName: { type: 'string' },
451
+ createdAtUnixMs: nonNegativeIntegerSchema,
452
+ },
453
+ };
454
+ const commentThreadSchema = {
455
+ type: 'object',
456
+ required: ['threadId', 'sheetName', 'address', 'comments'],
457
+ additionalProperties: true,
458
+ properties: {
459
+ threadId: nonEmptyStringSchema,
460
+ sheetName: nonEmptyStringSchema,
461
+ address: nonEmptyStringSchema,
462
+ comments: { type: 'array', minItems: 1, items: commentEntrySchema },
463
+ resolved: booleanSchema,
464
+ resolvedByUserId: { type: 'string' },
465
+ resolvedAtUnixMs: nonNegativeIntegerSchema,
466
+ },
467
+ };
468
+ const noteSchema = {
469
+ type: 'object',
470
+ required: ['sheetName', 'address', 'text'],
471
+ additionalProperties: true,
472
+ properties: {
473
+ sheetName: nonEmptyStringSchema,
474
+ address: nonEmptyStringSchema,
475
+ text: { type: 'string' },
476
+ },
477
+ };
478
+ const hyperlinkSchema = {
479
+ type: 'object',
480
+ required: ['sheetName', 'address', 'target'],
481
+ additionalProperties: true,
482
+ properties: {
483
+ sheetName: nonEmptyStringSchema,
484
+ address: nonEmptyStringSchema,
485
+ target: { type: 'string' },
486
+ tooltip: { type: 'string' },
487
+ display: { type: 'string' },
488
+ },
489
+ };
490
+ const definedNameValueSchema = {
491
+ oneOf: [
492
+ literalInputRefSchema,
493
+ {
494
+ type: 'object',
495
+ required: ['kind', 'value'],
496
+ additionalProperties: true,
497
+ properties: { kind: { const: 'scalar' }, value: literalInputRefSchema },
498
+ },
499
+ {
500
+ type: 'object',
501
+ required: ['kind', 'sheetName', 'address'],
502
+ additionalProperties: true,
503
+ properties: { kind: { const: 'cell-ref' }, sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema },
504
+ },
505
+ {
506
+ type: 'object',
507
+ required: ['kind', 'sheetName', 'startAddress', 'endAddress'],
508
+ additionalProperties: true,
509
+ properties: {
510
+ kind: { const: 'range-ref' },
511
+ sheetName: nonEmptyStringSchema,
512
+ startAddress: nonEmptyStringSchema,
513
+ endAddress: nonEmptyStringSchema,
514
+ },
515
+ },
516
+ {
517
+ type: 'object',
518
+ required: ['kind', 'tableName', 'columnName'],
519
+ additionalProperties: true,
520
+ properties: { kind: { const: 'structured-ref' }, tableName: nonEmptyStringSchema, columnName: nonEmptyStringSchema },
521
+ },
522
+ {
523
+ type: 'object',
524
+ required: ['kind', 'formula'],
525
+ additionalProperties: true,
526
+ properties: { kind: { const: 'formula' }, formula: { type: 'string' } },
527
+ },
528
+ ],
529
+ };
530
+ const autoFilterValueCriteriaSchema = {
531
+ type: 'object',
532
+ required: ['values'],
533
+ additionalProperties: true,
534
+ properties: {
535
+ blank: booleanSchema,
536
+ values: { type: 'array', items: { type: 'string' } },
537
+ },
538
+ };
539
+ const autoFilterCustomCriterionSchema = {
540
+ type: 'object',
541
+ required: ['value'],
542
+ additionalProperties: true,
543
+ properties: {
544
+ operator: { enum: ['equal', 'lessThan', 'lessThanOrEqual', 'notEqual', 'greaterThanOrEqual', 'greaterThan'] },
545
+ value: { type: 'string' },
546
+ },
547
+ };
548
+ const autoFilterCustomCriteriaSchema = {
549
+ type: 'object',
550
+ required: ['filters'],
551
+ additionalProperties: true,
552
+ properties: {
553
+ and: booleanSchema,
554
+ filters: { type: 'array', items: autoFilterCustomCriterionSchema },
555
+ },
556
+ };
557
+ const autoFilterColumnSchema = {
558
+ type: 'object',
559
+ required: ['colId'],
560
+ additionalProperties: true,
561
+ properties: {
562
+ colId: nonNegativeIntegerSchema,
563
+ hiddenButton: booleanSchema,
564
+ showButton: booleanSchema,
565
+ filters: autoFilterValueCriteriaSchema,
566
+ customFilters: autoFilterCustomCriteriaSchema,
567
+ },
568
+ };
569
+ const autoFilterSchema = {
570
+ type: 'object',
571
+ required: ['sheetName', 'startAddress', 'endAddress'],
572
+ additionalProperties: true,
573
+ properties: {
574
+ sheetName: nonEmptyStringSchema,
575
+ startAddress: nonEmptyStringSchema,
576
+ endAddress: nonEmptyStringSchema,
577
+ criteria: { type: 'array', items: autoFilterColumnSchema },
578
+ },
579
+ };
580
+ const tableColumnSchema = {
581
+ type: 'object',
582
+ required: ['name'],
583
+ additionalProperties: true,
584
+ properties: {
585
+ name: nonEmptyStringSchema,
586
+ calculatedColumnFormula: { type: 'string' },
587
+ totalsRowLabel: { type: 'string' },
588
+ totalsRowFunction: { type: 'string' },
589
+ totalsRowFormula: { type: 'string' },
590
+ },
591
+ };
592
+ const tableStyleSchema = {
593
+ type: 'object',
594
+ additionalProperties: true,
595
+ properties: {
596
+ name: { type: 'string' },
597
+ showFirstColumn: booleanSchema,
598
+ showLastColumn: booleanSchema,
599
+ showRowStripes: booleanSchema,
600
+ showColumnStripes: booleanSchema,
601
+ },
602
+ };
603
+ const tableSchema = {
604
+ type: 'object',
605
+ required: ['name', 'sheetName', 'startAddress', 'endAddress', 'columnNames', 'headerRow', 'totalsRow'],
606
+ additionalProperties: true,
607
+ properties: {
608
+ name: nonEmptyStringSchema,
609
+ sheetName: nonEmptyStringSchema,
610
+ startAddress: nonEmptyStringSchema,
611
+ endAddress: nonEmptyStringSchema,
612
+ columnNames: { type: 'array', items: { type: 'string' } },
613
+ columns: { type: 'array', items: tableColumnSchema },
614
+ headerRow: booleanSchema,
615
+ totalsRow: booleanSchema,
616
+ style: tableStyleSchema,
617
+ autoFilter: autoFilterSchema,
618
+ sortState: { type: 'string' },
619
+ },
620
+ };
621
+ const pivotValueSchema = {
622
+ type: 'object',
623
+ required: ['sourceColumn', 'summarizeBy'],
624
+ additionalProperties: true,
625
+ properties: {
626
+ sourceColumn: nonEmptyStringSchema,
627
+ summarizeBy: { enum: ['sum', 'count'] },
628
+ outputLabel: { type: 'string' },
629
+ },
630
+ };
631
+ const drawingAnchorMarkerSchema = {
632
+ type: 'object',
633
+ required: ['row', 'col'],
634
+ additionalProperties: true,
635
+ properties: {
636
+ row: nonNegativeIntegerSchema,
637
+ col: nonNegativeIntegerSchema,
638
+ rowOffset: nonNegativeIntegerSchema,
639
+ colOffset: nonNegativeIntegerSchema,
640
+ },
641
+ };
642
+ const drawingAnchorExtentSchema = {
643
+ type: 'object',
644
+ required: ['width', 'height'],
645
+ additionalProperties: true,
646
+ properties: {
647
+ width: positiveIntegerSchema,
648
+ height: positiveIntegerSchema,
649
+ },
650
+ };
651
+ const drawingAnchorPositionSchema = {
652
+ type: 'object',
653
+ required: ['x', 'y'],
654
+ additionalProperties: true,
655
+ properties: {
656
+ x: nonNegativeIntegerSchema,
657
+ y: nonNegativeIntegerSchema,
658
+ },
659
+ };
660
+ const chartAnchorSchema = {
661
+ oneOf: [
662
+ {
663
+ type: 'object',
664
+ required: ['kind', 'from', 'to'],
665
+ additionalProperties: true,
666
+ properties: {
667
+ kind: { const: 'twoCell' },
668
+ editAs: { enum: ['twoCell', 'oneCell', 'absolute'] },
669
+ from: drawingAnchorMarkerSchema,
670
+ to: drawingAnchorMarkerSchema,
671
+ },
672
+ },
673
+ {
674
+ type: 'object',
675
+ required: ['kind', 'from', 'extent'],
676
+ additionalProperties: true,
677
+ properties: { kind: { const: 'oneCell' }, from: drawingAnchorMarkerSchema, extent: drawingAnchorExtentSchema },
678
+ },
679
+ {
680
+ type: 'object',
681
+ required: ['kind', 'position', 'extent'],
682
+ additionalProperties: true,
683
+ properties: { kind: { const: 'absolute' }, position: drawingAnchorPositionSchema, extent: drawingAnchorExtentSchema },
684
+ },
685
+ ],
686
+ };
687
+ const chartSchema = {
688
+ type: 'object',
689
+ required: ['id', 'sheetName', 'address', 'source', 'chartType', 'rows', 'cols'],
690
+ additionalProperties: true,
691
+ properties: {
692
+ id: nonEmptyStringSchema,
693
+ sheetName: nonEmptyStringSchema,
694
+ address: nonEmptyStringSchema,
695
+ source: cellRangeRefSchema,
696
+ chartType: { enum: ['column', 'bar', 'line', 'area', 'pie', 'scatter'] },
697
+ anchor: chartAnchorSchema,
698
+ seriesOrientation: { enum: ['rows', 'columns'] },
699
+ firstRowAsHeaders: booleanSchema,
700
+ firstColumnAsLabels: booleanSchema,
701
+ title: { type: 'string' },
702
+ legendPosition: { enum: ['top', 'right', 'bottom', 'left', 'hidden'] },
703
+ rows: positiveIntegerSchema,
704
+ cols: positiveIntegerSchema,
705
+ },
706
+ };
707
+ const imageSchema = {
708
+ type: 'object',
709
+ required: ['id', 'sheetName', 'address', 'sourceUrl', 'rows', 'cols'],
710
+ additionalProperties: true,
711
+ properties: {
712
+ id: nonEmptyStringSchema,
713
+ sheetName: nonEmptyStringSchema,
714
+ address: nonEmptyStringSchema,
715
+ sourceUrl: { type: 'string' },
716
+ rows: positiveIntegerSchema,
717
+ cols: positiveIntegerSchema,
718
+ altText: { type: 'string' },
719
+ },
720
+ };
721
+ const shapeSchema = {
722
+ type: 'object',
723
+ required: ['id', 'sheetName', 'address', 'shapeType', 'rows', 'cols'],
724
+ additionalProperties: true,
725
+ properties: {
726
+ id: nonEmptyStringSchema,
727
+ sheetName: nonEmptyStringSchema,
728
+ address: nonEmptyStringSchema,
729
+ shapeType: { enum: ['rectangle', 'roundedRectangle', 'ellipse', 'line', 'arrow', 'textBox'] },
730
+ rows: positiveIntegerSchema,
731
+ cols: positiveIntegerSchema,
732
+ text: { type: 'string' },
733
+ fillColor: { type: 'string' },
734
+ strokeColor: { type: 'string' },
735
+ },
736
+ };
737
+ function opSchema(kind, required, properties) {
738
+ return {
739
+ type: 'object',
740
+ required: ['kind', ...required],
741
+ additionalProperties: true,
742
+ properties: {
743
+ kind: { const: kind },
744
+ ...properties,
745
+ },
746
+ };
747
+ }
748
+ export const workbookOpSchema = {
749
+ oneOf: [
750
+ opSchema('upsertWorkbook', ['name'], { name: nonEmptyStringSchema }),
751
+ opSchema('setWorkbookMetadata', ['key', 'value'], { key: nonEmptyStringSchema, value: literalInputRefSchema }),
752
+ opSchema('setCalculationSettings', ['settings'], { settings: workbookCalculationSettingsSchema }),
753
+ opSchema('setVolatileContext', ['context'], { context: workbookVolatileContextSchema }),
754
+ opSchema('upsertSheet', ['name', 'order'], { name: nonEmptyStringSchema, order: nonNegativeIntegerSchema, id: positiveIntegerSchema }),
755
+ opSchema('renameSheet', ['oldName', 'newName'], { oldName: nonEmptyStringSchema, newName: nonEmptyStringSchema }),
756
+ opSchema('deleteSheet', ['name'], { name: nonEmptyStringSchema }),
757
+ opSchema('insertRows', ['sheetName', 'start', 'count'], {
758
+ sheetName: nonEmptyStringSchema,
759
+ start: nonNegativeIntegerSchema,
760
+ count: positiveIntegerSchema,
761
+ entries: { type: 'array', items: axisEntrySchema },
762
+ }),
763
+ opSchema('deleteRows', ['sheetName', 'start', 'count'], {
764
+ sheetName: nonEmptyStringSchema,
765
+ start: nonNegativeIntegerSchema,
766
+ count: positiveIntegerSchema,
767
+ }),
768
+ opSchema('moveRows', ['sheetName', 'start', 'count', 'target'], {
769
+ sheetName: nonEmptyStringSchema,
770
+ start: nonNegativeIntegerSchema,
771
+ count: positiveIntegerSchema,
772
+ target: nonNegativeIntegerSchema,
773
+ }),
774
+ opSchema('insertColumns', ['sheetName', 'start', 'count'], {
775
+ sheetName: nonEmptyStringSchema,
776
+ start: nonNegativeIntegerSchema,
777
+ count: positiveIntegerSchema,
778
+ entries: { type: 'array', items: axisEntrySchema },
779
+ }),
780
+ opSchema('deleteColumns', ['sheetName', 'start', 'count'], {
781
+ sheetName: nonEmptyStringSchema,
782
+ start: nonNegativeIntegerSchema,
783
+ count: positiveIntegerSchema,
784
+ }),
785
+ opSchema('moveColumns', ['sheetName', 'start', 'count', 'target'], {
786
+ sheetName: nonEmptyStringSchema,
787
+ start: nonNegativeIntegerSchema,
788
+ count: positiveIntegerSchema,
789
+ target: nonNegativeIntegerSchema,
790
+ }),
791
+ opSchema('updateRowMetadata', ['sheetName', 'start', 'count'], {
792
+ sheetName: nonEmptyStringSchema,
793
+ start: nonNegativeIntegerSchema,
794
+ count: positiveIntegerSchema,
795
+ size: { oneOf: [positiveIntegerSchema, { type: 'null' }] },
796
+ hidden: nullableBooleanSchema,
797
+ filterHidden: nullableBooleanSchema,
798
+ }),
799
+ opSchema('updateColumnMetadata', ['sheetName', 'start', 'count'], {
800
+ sheetName: nonEmptyStringSchema,
801
+ start: nonNegativeIntegerSchema,
802
+ count: positiveIntegerSchema,
803
+ size: { oneOf: [positiveIntegerSchema, { type: 'null' }] },
804
+ hidden: nullableBooleanSchema,
805
+ }),
806
+ opSchema('setFreezePane', ['sheetName', 'rows', 'cols'], {
807
+ sheetName: nonEmptyStringSchema,
808
+ rows: nonNegativeIntegerSchema,
809
+ cols: nonNegativeIntegerSchema,
810
+ }),
811
+ opSchema('clearFreezePane', ['sheetName'], { sheetName: nonEmptyStringSchema }),
812
+ opSchema('mergeCells', ['range'], { range: cellRangeRefSchema }),
813
+ opSchema('unmergeCells', ['range'], { range: cellRangeRefSchema }),
814
+ opSchema('setSheetProtection', ['protection'], { protection: sheetProtectionSchema }),
815
+ opSchema('clearSheetProtection', ['sheetName'], { sheetName: nonEmptyStringSchema }),
816
+ opSchema('setFilter', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
817
+ opSchema('clearFilter', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
818
+ opSchema('setSort', ['sheetName', 'range', 'keys'], {
819
+ sheetName: nonEmptyStringSchema,
820
+ range: cellRangeRefSchema,
821
+ keys: { type: 'array', items: sortKeySchema },
822
+ }),
823
+ opSchema('clearSort', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
824
+ opSchema('setDataValidation', ['validation'], { validation: dataValidationSchema }),
825
+ opSchema('clearDataValidation', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
826
+ opSchema('upsertConditionalFormat', ['format'], { format: conditionalFormatSchema }),
827
+ opSchema('deleteConditionalFormat', ['id', 'sheetName'], { id: nonEmptyStringSchema, sheetName: nonEmptyStringSchema }),
828
+ opSchema('setConditionalFormatArtifacts', ['sheetName', 'artifacts'], {
829
+ sheetName: nonEmptyStringSchema,
830
+ artifacts: conditionalFormatArtifactsSchema,
831
+ }),
832
+ opSchema('clearConditionalFormatArtifacts', ['sheetName'], { sheetName: nonEmptyStringSchema }),
833
+ opSchema('upsertRangeProtection', ['protection'], { protection: rangeProtectionSchema }),
834
+ opSchema('deleteRangeProtection', ['id', 'sheetName'], { id: nonEmptyStringSchema, sheetName: nonEmptyStringSchema }),
835
+ opSchema('upsertCommentThread', ['thread'], { thread: commentThreadSchema }),
836
+ opSchema('deleteCommentThread', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
837
+ opSchema('upsertNote', ['note'], { note: noteSchema }),
838
+ opSchema('deleteNote', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
839
+ opSchema('upsertHyperlink', ['hyperlink'], { hyperlink: hyperlinkSchema }),
840
+ opSchema('deleteHyperlink', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
841
+ opSchema('setCellValue', ['sheetName', 'address', 'value'], {
842
+ sheetName: nonEmptyStringSchema,
843
+ address: nonEmptyStringSchema,
844
+ value: literalInputRefSchema,
845
+ authoredBlank: booleanSchema,
846
+ }),
847
+ opSchema('setCellFormula', ['sheetName', 'address', 'formula'], {
848
+ sheetName: nonEmptyStringSchema,
849
+ address: nonEmptyStringSchema,
850
+ formula: { type: 'string' },
851
+ }),
852
+ opSchema('setCellFormat', ['sheetName', 'address', 'format'], {
853
+ sheetName: nonEmptyStringSchema,
854
+ address: nonEmptyStringSchema,
855
+ format: { oneOf: [{ type: 'string' }, { type: 'null' }] },
856
+ }),
857
+ opSchema('upsertCellStyle', ['style'], { style: cellStyleRecordSchema }),
858
+ opSchema('upsertCellNumberFormat', ['format'], { format: cellNumberFormatRecordSchema }),
859
+ opSchema('setStyleRange', ['range', 'styleId'], { range: cellRangeRefSchema, styleId: nonEmptyStringSchema }),
860
+ opSchema('setFormatRange', ['range', 'formatId'], { range: cellRangeRefSchema, formatId: nonEmptyStringSchema }),
861
+ opSchema('clearCell', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
862
+ opSchema('upsertDefinedName', ['name', 'value'], {
863
+ name: nonEmptyStringSchema,
864
+ value: definedNameValueSchema,
865
+ }),
866
+ opSchema('deleteDefinedName', ['name'], { name: nonEmptyStringSchema }),
867
+ opSchema('upsertTable', ['table'], { table: tableSchema }),
868
+ opSchema('deleteTable', ['name'], { name: nonEmptyStringSchema }),
869
+ opSchema('upsertSpillRange', ['sheetName', 'address', 'rows', 'cols'], {
870
+ sheetName: nonEmptyStringSchema,
871
+ address: nonEmptyStringSchema,
872
+ rows: positiveIntegerSchema,
873
+ cols: positiveIntegerSchema,
874
+ }),
875
+ opSchema('deleteSpillRange', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
876
+ opSchema('upsertPivotTable', ['name', 'sheetName', 'address', 'source', 'groupBy', 'values', 'rows', 'cols'], {
877
+ name: nonEmptyStringSchema,
878
+ sheetName: nonEmptyStringSchema,
879
+ address: nonEmptyStringSchema,
880
+ source: cellRangeRefSchema,
881
+ groupBy: { type: 'array', items: { type: 'string' } },
882
+ values: { type: 'array', items: pivotValueSchema },
883
+ rows: positiveIntegerSchema,
884
+ cols: positiveIntegerSchema,
885
+ }),
886
+ opSchema('deletePivotTable', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
887
+ opSchema('upsertChart', ['chart'], { chart: chartSchema }),
888
+ opSchema('deleteChart', ['id'], { id: nonEmptyStringSchema }),
889
+ opSchema('upsertImage', ['image'], { image: imageSchema }),
890
+ opSchema('deleteImage', ['id'], { id: nonEmptyStringSchema }),
891
+ opSchema('upsertShape', ['shape'], { shape: shapeSchema }),
892
+ opSchema('deleteShape', ['id'], { id: nonEmptyStringSchema }),
893
+ ],
894
+ };
895
+ //# sourceMappingURL=op-schema.js.map