@bilig/workbook 0.107.8 → 0.119.1

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 (77) 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 +93 -40
  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 +26 -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.js +555 -25
  41. package/dist/op-schema.js.map +1 -1
  42. package/dist/plan-data.js +184 -51
  43. package/dist/plan-data.js.map +1 -1
  44. package/dist/readback.js +44 -1
  45. package/dist/readback.js.map +1 -1
  46. package/dist/requirements.js +41 -3
  47. package/dist/requirements.js.map +1 -1
  48. package/dist/result.d.ts +7 -0
  49. package/dist/result.js.map +1 -1
  50. package/dist/run-apply.js +5 -2
  51. package/dist/run-apply.js.map +1 -1
  52. package/dist/run-command-receipts.js +133 -3
  53. package/dist/run-command-receipts.js.map +1 -1
  54. package/dist/run-data.js +6 -2
  55. package/dist/run-data.js.map +1 -1
  56. package/dist/run-description-noop.d.ts +2 -0
  57. package/dist/run-description-noop.js +330 -0
  58. package/dist/run-description-noop.js.map +1 -0
  59. package/dist/run-description.js +23 -2
  60. package/dist/run-description.js.map +1 -1
  61. package/dist/run-runtime-boundary.js +39 -5
  62. package/dist/run-runtime-boundary.js.map +1 -1
  63. package/dist/run.d.ts +1 -0
  64. package/dist/run.js.map +1 -1
  65. package/dist/schema-fragments.d.ts +16 -0
  66. package/dist/schema-fragments.js +246 -0
  67. package/dist/schema-fragments.js.map +1 -0
  68. package/dist/schema-noop.d.ts +9 -0
  69. package/dist/schema-noop.js +128 -0
  70. package/dist/schema-noop.js.map +1 -0
  71. package/dist/schema.js +227 -130
  72. package/dist/schema.js.map +1 -1
  73. package/dist/testing.js +19 -4
  74. package/dist/testing.js.map +1 -1
  75. package/dist/verify.js +34 -0
  76. package/dist/verify.js.map +1 -1
  77. package/package.json +12 -5
package/dist/op-schema.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CELL_BORDER_STYLE_VALUES, CELL_BORDER_WEIGHT_VALUES, CELL_HORIZONTAL_ALIGNMENT_VALUES, CELL_VERTICAL_ALIGNMENT_VALUES, } from '@bilig/protocol';
2
2
  const nonEmptyStringSchema = { type: 'string', minLength: 1 };
3
- const nonNegativeIntegerSchema = { type: 'integer', minimum: 0 };
4
- const positiveIntegerSchema = { type: 'integer', minimum: 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
5
  const booleanSchema = { type: 'boolean' };
6
6
  const numberSchema = { type: 'number' };
7
7
  const cellRangeRefSchema = { $ref: '#/$defs/cellRange' };
@@ -17,7 +17,7 @@ const styleFillPatchSchema = {
17
17
  { type: 'null' },
18
18
  {
19
19
  type: 'object',
20
- additionalProperties: true,
20
+ additionalProperties: false,
21
21
  properties: {
22
22
  backgroundColor: nullableStringSchema,
23
23
  },
@@ -29,7 +29,7 @@ const styleFontPatchSchema = {
29
29
  { type: 'null' },
30
30
  {
31
31
  type: 'object',
32
- additionalProperties: true,
32
+ additionalProperties: false,
33
33
  properties: {
34
34
  family: nullableStringSchema,
35
35
  size: nullableNumberSchema,
@@ -46,7 +46,7 @@ const styleAlignmentPatchSchema = {
46
46
  { type: 'null' },
47
47
  {
48
48
  type: 'object',
49
- additionalProperties: true,
49
+ additionalProperties: false,
50
50
  properties: {
51
51
  horizontal: { oneOf: [{ enum: CELL_HORIZONTAL_ALIGNMENT_VALUES }, { type: 'null' }] },
52
52
  vertical: { oneOf: [{ enum: CELL_VERTICAL_ALIGNMENT_VALUES }, { type: 'null' }] },
@@ -65,7 +65,7 @@ const styleBorderSidePatchSchema = {
65
65
  { type: 'null' },
66
66
  {
67
67
  type: 'object',
68
- additionalProperties: true,
68
+ additionalProperties: false,
69
69
  properties: {
70
70
  style: { oneOf: [{ enum: CELL_BORDER_STYLE_VALUES }, { type: 'null' }] },
71
71
  weight: { oneOf: [{ enum: CELL_BORDER_WEIGHT_VALUES }, { type: 'null' }] },
@@ -79,7 +79,7 @@ const styleBordersPatchSchema = {
79
79
  { type: 'null' },
80
80
  {
81
81
  type: 'object',
82
- additionalProperties: true,
82
+ additionalProperties: false,
83
83
  properties: {
84
84
  top: styleBorderSidePatchSchema,
85
85
  right: styleBorderSidePatchSchema,
@@ -91,7 +91,7 @@ const styleBordersPatchSchema = {
91
91
  };
92
92
  export const cellStylePatchSchema = {
93
93
  type: 'object',
94
- additionalProperties: true,
94
+ additionalProperties: false,
95
95
  properties: {
96
96
  fill: styleFillPatchSchema,
97
97
  font: styleFontPatchSchema,
@@ -101,6 +101,7 @@ export const cellStylePatchSchema = {
101
101
  };
102
102
  const styleFillRecordSchema = {
103
103
  type: 'object',
104
+ required: ['backgroundColor'],
104
105
  additionalProperties: true,
105
106
  properties: {
106
107
  backgroundColor: { type: 'string' },
@@ -203,7 +204,536 @@ const sortKeySchema = {
203
204
  direction: { enum: ['asc', 'desc'] },
204
205
  },
205
206
  };
206
- const looseObjectSchema = { type: 'object', additionalProperties: true };
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
+ };
207
737
  function opSchema(kind, required, properties) {
208
738
  return {
209
739
  type: 'object',
@@ -219,8 +749,8 @@ export const workbookOpSchema = {
219
749
  oneOf: [
220
750
  opSchema('upsertWorkbook', ['name'], { name: nonEmptyStringSchema }),
221
751
  opSchema('setWorkbookMetadata', ['key', 'value'], { key: nonEmptyStringSchema, value: literalInputRefSchema }),
222
- opSchema('setCalculationSettings', ['settings'], { settings: looseObjectSchema }),
223
- opSchema('setVolatileContext', ['context'], { context: looseObjectSchema }),
752
+ opSchema('setCalculationSettings', ['settings'], { settings: workbookCalculationSettingsSchema }),
753
+ opSchema('setVolatileContext', ['context'], { context: workbookVolatileContextSchema }),
224
754
  opSchema('upsertSheet', ['name', 'order'], { name: nonEmptyStringSchema, order: nonNegativeIntegerSchema, id: positiveIntegerSchema }),
225
755
  opSchema('renameSheet', ['oldName', 'newName'], { oldName: nonEmptyStringSchema, newName: nonEmptyStringSchema }),
226
756
  opSchema('deleteSheet', ['name'], { name: nonEmptyStringSchema }),
@@ -281,7 +811,7 @@ export const workbookOpSchema = {
281
811
  opSchema('clearFreezePane', ['sheetName'], { sheetName: nonEmptyStringSchema }),
282
812
  opSchema('mergeCells', ['range'], { range: cellRangeRefSchema }),
283
813
  opSchema('unmergeCells', ['range'], { range: cellRangeRefSchema }),
284
- opSchema('setSheetProtection', ['protection'], { protection: looseObjectSchema }),
814
+ opSchema('setSheetProtection', ['protection'], { protection: sheetProtectionSchema }),
285
815
  opSchema('clearSheetProtection', ['sheetName'], { sheetName: nonEmptyStringSchema }),
286
816
  opSchema('setFilter', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
287
817
  opSchema('clearFilter', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
@@ -291,22 +821,22 @@ export const workbookOpSchema = {
291
821
  keys: { type: 'array', items: sortKeySchema },
292
822
  }),
293
823
  opSchema('clearSort', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
294
- opSchema('setDataValidation', ['validation'], { validation: looseObjectSchema }),
824
+ opSchema('setDataValidation', ['validation'], { validation: dataValidationSchema }),
295
825
  opSchema('clearDataValidation', ['sheetName', 'range'], { sheetName: nonEmptyStringSchema, range: cellRangeRefSchema }),
296
- opSchema('upsertConditionalFormat', ['format'], { format: looseObjectSchema }),
826
+ opSchema('upsertConditionalFormat', ['format'], { format: conditionalFormatSchema }),
297
827
  opSchema('deleteConditionalFormat', ['id', 'sheetName'], { id: nonEmptyStringSchema, sheetName: nonEmptyStringSchema }),
298
828
  opSchema('setConditionalFormatArtifacts', ['sheetName', 'artifacts'], {
299
829
  sheetName: nonEmptyStringSchema,
300
- artifacts: looseObjectSchema,
830
+ artifacts: conditionalFormatArtifactsSchema,
301
831
  }),
302
832
  opSchema('clearConditionalFormatArtifacts', ['sheetName'], { sheetName: nonEmptyStringSchema }),
303
- opSchema('upsertRangeProtection', ['protection'], { protection: looseObjectSchema }),
833
+ opSchema('upsertRangeProtection', ['protection'], { protection: rangeProtectionSchema }),
304
834
  opSchema('deleteRangeProtection', ['id', 'sheetName'], { id: nonEmptyStringSchema, sheetName: nonEmptyStringSchema }),
305
- opSchema('upsertCommentThread', ['thread'], { thread: looseObjectSchema }),
835
+ opSchema('upsertCommentThread', ['thread'], { thread: commentThreadSchema }),
306
836
  opSchema('deleteCommentThread', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
307
- opSchema('upsertNote', ['note'], { note: looseObjectSchema }),
837
+ opSchema('upsertNote', ['note'], { note: noteSchema }),
308
838
  opSchema('deleteNote', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
309
- opSchema('upsertHyperlink', ['hyperlink'], { hyperlink: looseObjectSchema }),
839
+ opSchema('upsertHyperlink', ['hyperlink'], { hyperlink: hyperlinkSchema }),
310
840
  opSchema('deleteHyperlink', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
311
841
  opSchema('setCellValue', ['sheetName', 'address', 'value'], {
312
842
  sheetName: nonEmptyStringSchema,
@@ -331,10 +861,10 @@ export const workbookOpSchema = {
331
861
  opSchema('clearCell', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
332
862
  opSchema('upsertDefinedName', ['name', 'value'], {
333
863
  name: nonEmptyStringSchema,
334
- value: { oneOf: [literalInputRefSchema, looseObjectSchema] },
864
+ value: definedNameValueSchema,
335
865
  }),
336
866
  opSchema('deleteDefinedName', ['name'], { name: nonEmptyStringSchema }),
337
- opSchema('upsertTable', ['table'], { table: looseObjectSchema }),
867
+ opSchema('upsertTable', ['table'], { table: tableSchema }),
338
868
  opSchema('deleteTable', ['name'], { name: nonEmptyStringSchema }),
339
869
  opSchema('upsertSpillRange', ['sheetName', 'address', 'rows', 'cols'], {
340
870
  sheetName: nonEmptyStringSchema,
@@ -349,16 +879,16 @@ export const workbookOpSchema = {
349
879
  address: nonEmptyStringSchema,
350
880
  source: cellRangeRefSchema,
351
881
  groupBy: { type: 'array', items: { type: 'string' } },
352
- values: { type: 'array', items: looseObjectSchema },
882
+ values: { type: 'array', items: pivotValueSchema },
353
883
  rows: positiveIntegerSchema,
354
884
  cols: positiveIntegerSchema,
355
885
  }),
356
886
  opSchema('deletePivotTable', ['sheetName', 'address'], { sheetName: nonEmptyStringSchema, address: nonEmptyStringSchema }),
357
- opSchema('upsertChart', ['chart'], { chart: looseObjectSchema }),
887
+ opSchema('upsertChart', ['chart'], { chart: chartSchema }),
358
888
  opSchema('deleteChart', ['id'], { id: nonEmptyStringSchema }),
359
- opSchema('upsertImage', ['image'], { image: looseObjectSchema }),
889
+ opSchema('upsertImage', ['image'], { image: imageSchema }),
360
890
  opSchema('deleteImage', ['id'], { id: nonEmptyStringSchema }),
361
- opSchema('upsertShape', ['shape'], { shape: looseObjectSchema }),
891
+ opSchema('upsertShape', ['shape'], { shape: shapeSchema }),
362
892
  opSchema('deleteShape', ['id'], { id: nonEmptyStringSchema }),
363
893
  ],
364
894
  };