@bilig/workbook-domain 0.1.83 → 0.1.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/guards.d.ts +4 -4
- package/dist/guards.js +363 -410
- package/dist/guards.js.map +1 -1
- package/dist/index.d.ts +59 -59
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/guards.js
CHANGED
|
@@ -1,44 +1,34 @@
|
|
|
1
|
-
import { isCellRangeRef, isLiteralInput } from
|
|
2
|
-
const HORIZONTAL_ALIGNMENT_VALUES = new Set([
|
|
3
|
-
const VERTICAL_ALIGNMENT_VALUES = new Set([
|
|
4
|
-
const BORDER_STYLE_VALUES = new Set([
|
|
5
|
-
const BORDER_WEIGHT_VALUES = new Set([
|
|
6
|
-
const NUMBER_FORMAT_KIND_VALUES = new Set([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"accounting",
|
|
11
|
-
"percent",
|
|
12
|
-
"date",
|
|
13
|
-
"time",
|
|
14
|
-
"datetime",
|
|
15
|
-
"text",
|
|
16
|
-
]);
|
|
17
|
-
const COMPATIBILITY_MODE_VALUES = new Set(["excel-modern", "odf-1.4"]);
|
|
18
|
-
const SORT_DIRECTION_VALUES = new Set(["asc", "desc"]);
|
|
19
|
-
const PIVOT_AGGREGATION_VALUES = new Set(["sum", "count"]);
|
|
1
|
+
import { isCellRangeRef, isLiteralInput } from '@bilig/protocol';
|
|
2
|
+
const HORIZONTAL_ALIGNMENT_VALUES = new Set(['general', 'left', 'center', 'right']);
|
|
3
|
+
const VERTICAL_ALIGNMENT_VALUES = new Set(['top', 'middle', 'bottom']);
|
|
4
|
+
const BORDER_STYLE_VALUES = new Set(['solid', 'dashed', 'dotted', 'double']);
|
|
5
|
+
const BORDER_WEIGHT_VALUES = new Set(['thin', 'medium', 'thick']);
|
|
6
|
+
const NUMBER_FORMAT_KIND_VALUES = new Set(['general', 'number', 'currency', 'accounting', 'percent', 'date', 'time', 'datetime', 'text']);
|
|
7
|
+
const COMPATIBILITY_MODE_VALUES = new Set(['excel-modern', 'odf-1.4']);
|
|
8
|
+
const SORT_DIRECTION_VALUES = new Set(['asc', 'desc']);
|
|
9
|
+
const PIVOT_AGGREGATION_VALUES = new Set(['sum', 'count']);
|
|
20
10
|
const VALIDATION_COMPARISON_OPERATOR_VALUES = new Set([
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
'between',
|
|
12
|
+
'notBetween',
|
|
13
|
+
'equal',
|
|
14
|
+
'notEqual',
|
|
15
|
+
'greaterThan',
|
|
16
|
+
'greaterThanOrEqual',
|
|
17
|
+
'lessThan',
|
|
18
|
+
'lessThanOrEqual',
|
|
29
19
|
]);
|
|
30
|
-
const VALIDATION_ERROR_STYLE_VALUES = new Set([
|
|
20
|
+
const VALIDATION_ERROR_STYLE_VALUES = new Set(['stop', 'warning', 'information']);
|
|
31
21
|
function isRecord(value) {
|
|
32
|
-
return typeof value ===
|
|
22
|
+
return typeof value === 'object' && value !== null;
|
|
33
23
|
}
|
|
34
24
|
function isFiniteNumber(value) {
|
|
35
|
-
return typeof value ===
|
|
25
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
36
26
|
}
|
|
37
27
|
function isStringArray(value) {
|
|
38
|
-
return Array.isArray(value) && value.every((entry) => typeof entry ===
|
|
28
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === 'string');
|
|
39
29
|
}
|
|
40
30
|
function isOptionalString(value) {
|
|
41
|
-
return value === undefined || typeof value ===
|
|
31
|
+
return value === undefined || typeof value === 'string';
|
|
42
32
|
}
|
|
43
33
|
function isOptionalNumber(value) {
|
|
44
34
|
return value === undefined || isFiniteNumber(value);
|
|
@@ -47,222 +37,210 @@ function isOptionalNullableNumber(value) {
|
|
|
47
37
|
return value === undefined || value === null || isFiniteNumber(value);
|
|
48
38
|
}
|
|
49
39
|
function isOptionalBoolean(value) {
|
|
50
|
-
return value === undefined || typeof value ===
|
|
40
|
+
return value === undefined || typeof value === 'boolean';
|
|
51
41
|
}
|
|
52
42
|
function isOptionalLiteralInput(value) {
|
|
53
43
|
return value === undefined || isLiteralInput(value);
|
|
54
44
|
}
|
|
55
45
|
function isOptionalNullableBoolean(value) {
|
|
56
|
-
return value === undefined || value === null || typeof value ===
|
|
46
|
+
return value === undefined || value === null || typeof value === 'boolean';
|
|
57
47
|
}
|
|
58
48
|
function hasString(value, key) {
|
|
59
|
-
return typeof value[key] ===
|
|
49
|
+
return typeof value[key] === 'string';
|
|
60
50
|
}
|
|
61
51
|
function hasFiniteNumber(value, key) {
|
|
62
52
|
return isFiniteNumber(value[key]);
|
|
63
53
|
}
|
|
64
54
|
function isWorkbookAxisEntry(value) {
|
|
65
55
|
return (isRecord(value) &&
|
|
66
|
-
hasString(value,
|
|
67
|
-
hasFiniteNumber(value,
|
|
68
|
-
isOptionalNullableNumber(value[
|
|
69
|
-
isOptionalNullableBoolean(value[
|
|
56
|
+
hasString(value, 'id') &&
|
|
57
|
+
hasFiniteNumber(value, 'index') &&
|
|
58
|
+
isOptionalNullableNumber(value['size']) &&
|
|
59
|
+
isOptionalNullableBoolean(value['hidden']));
|
|
70
60
|
}
|
|
71
61
|
function isCellBorderSide(value) {
|
|
72
62
|
return (isRecord(value) &&
|
|
73
|
-
hasString(value,
|
|
74
|
-
typeof value[
|
|
75
|
-
BORDER_STYLE_VALUES.has(value[
|
|
76
|
-
typeof value[
|
|
77
|
-
BORDER_WEIGHT_VALUES.has(value[
|
|
63
|
+
hasString(value, 'color') &&
|
|
64
|
+
typeof value['style'] === 'string' &&
|
|
65
|
+
BORDER_STYLE_VALUES.has(value['style']) &&
|
|
66
|
+
typeof value['weight'] === 'string' &&
|
|
67
|
+
BORDER_WEIGHT_VALUES.has(value['weight']));
|
|
78
68
|
}
|
|
79
69
|
function isCellStyleRecord(value) {
|
|
80
|
-
if (!isRecord(value) || !hasString(value,
|
|
70
|
+
if (!isRecord(value) || !hasString(value, 'id')) {
|
|
81
71
|
return false;
|
|
82
72
|
}
|
|
83
|
-
const fill = value[
|
|
84
|
-
if (fill !== undefined && (!isRecord(fill) || typeof fill[
|
|
73
|
+
const fill = value['fill'];
|
|
74
|
+
if (fill !== undefined && (!isRecord(fill) || typeof fill['backgroundColor'] !== 'string')) {
|
|
85
75
|
return false;
|
|
86
76
|
}
|
|
87
|
-
const font = value[
|
|
77
|
+
const font = value['font'];
|
|
88
78
|
if (font !== undefined &&
|
|
89
79
|
(!isRecord(font) ||
|
|
90
|
-
!isOptionalString(font[
|
|
91
|
-
!isOptionalNumber(font[
|
|
92
|
-
!isOptionalBoolean(font[
|
|
93
|
-
!isOptionalBoolean(font[
|
|
94
|
-
!isOptionalBoolean(font[
|
|
95
|
-
!isOptionalString(font[
|
|
80
|
+
!isOptionalString(font['family']) ||
|
|
81
|
+
!isOptionalNumber(font['size']) ||
|
|
82
|
+
!isOptionalBoolean(font['bold']) ||
|
|
83
|
+
!isOptionalBoolean(font['italic']) ||
|
|
84
|
+
!isOptionalBoolean(font['underline']) ||
|
|
85
|
+
!isOptionalString(font['color']))) {
|
|
96
86
|
return false;
|
|
97
87
|
}
|
|
98
|
-
const alignment = value[
|
|
88
|
+
const alignment = value['alignment'];
|
|
99
89
|
if (alignment !== undefined &&
|
|
100
90
|
(!isRecord(alignment) ||
|
|
101
|
-
!(alignment[
|
|
102
|
-
(typeof alignment[
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
!isOptionalBoolean(alignment["wrap"]) ||
|
|
108
|
-
!isOptionalNumber(alignment["indent"]))) {
|
|
91
|
+
!(alignment['horizontal'] === undefined ||
|
|
92
|
+
(typeof alignment['horizontal'] === 'string' && HORIZONTAL_ALIGNMENT_VALUES.has(alignment['horizontal']))) ||
|
|
93
|
+
!(alignment['vertical'] === undefined ||
|
|
94
|
+
(typeof alignment['vertical'] === 'string' && VERTICAL_ALIGNMENT_VALUES.has(alignment['vertical']))) ||
|
|
95
|
+
!isOptionalBoolean(alignment['wrap']) ||
|
|
96
|
+
!isOptionalNumber(alignment['indent']))) {
|
|
109
97
|
return false;
|
|
110
98
|
}
|
|
111
|
-
const borders = value[
|
|
99
|
+
const borders = value['borders'];
|
|
112
100
|
if (borders !== undefined &&
|
|
113
101
|
(!isRecord(borders) ||
|
|
114
|
-
!(borders[
|
|
115
|
-
!(borders[
|
|
116
|
-
!(borders[
|
|
117
|
-
!(borders[
|
|
102
|
+
!(borders['top'] === undefined || isCellBorderSide(borders['top'])) ||
|
|
103
|
+
!(borders['right'] === undefined || isCellBorderSide(borders['right'])) ||
|
|
104
|
+
!(borders['bottom'] === undefined || isCellBorderSide(borders['bottom'])) ||
|
|
105
|
+
!(borders['left'] === undefined || isCellBorderSide(borders['left'])))) {
|
|
118
106
|
return false;
|
|
119
107
|
}
|
|
120
108
|
return true;
|
|
121
109
|
}
|
|
122
110
|
function isCellNumberFormatRecord(value) {
|
|
123
111
|
return (isRecord(value) &&
|
|
124
|
-
hasString(value,
|
|
125
|
-
hasString(value,
|
|
126
|
-
typeof value[
|
|
127
|
-
NUMBER_FORMAT_KIND_VALUES.has(value[
|
|
112
|
+
hasString(value, 'id') &&
|
|
113
|
+
hasString(value, 'code') &&
|
|
114
|
+
typeof value['kind'] === 'string' &&
|
|
115
|
+
NUMBER_FORMAT_KIND_VALUES.has(value['kind']));
|
|
128
116
|
}
|
|
129
117
|
function isWorkbookCalculationSettings(value) {
|
|
130
118
|
return (isRecord(value) &&
|
|
131
|
-
(value[
|
|
132
|
-
(value[
|
|
133
|
-
(typeof value[
|
|
134
|
-
COMPATIBILITY_MODE_VALUES.has(value["compatibilityMode"]))));
|
|
119
|
+
(value['mode'] === 'automatic' || value['mode'] === 'manual') &&
|
|
120
|
+
(value['compatibilityMode'] === undefined ||
|
|
121
|
+
(typeof value['compatibilityMode'] === 'string' && COMPATIBILITY_MODE_VALUES.has(value['compatibilityMode']))));
|
|
135
122
|
}
|
|
136
123
|
function isWorkbookVolatileContext(value) {
|
|
137
|
-
return isRecord(value) && hasFiniteNumber(value,
|
|
124
|
+
return isRecord(value) && hasFiniteNumber(value, 'recalcEpoch');
|
|
138
125
|
}
|
|
139
126
|
function isWorkbookSortKey(value) {
|
|
140
127
|
return (isRecord(value) &&
|
|
141
|
-
hasString(value,
|
|
142
|
-
typeof value[
|
|
143
|
-
SORT_DIRECTION_VALUES.has(value[
|
|
128
|
+
hasString(value, 'keyAddress') &&
|
|
129
|
+
typeof value['direction'] === 'string' &&
|
|
130
|
+
SORT_DIRECTION_VALUES.has(value['direction']));
|
|
144
131
|
}
|
|
145
132
|
function isWorkbookValidationListSource(value) {
|
|
146
|
-
if (!isRecord(value) || typeof value[
|
|
133
|
+
if (!isRecord(value) || typeof value['kind'] !== 'string') {
|
|
147
134
|
return false;
|
|
148
135
|
}
|
|
149
|
-
switch (value[
|
|
150
|
-
case
|
|
151
|
-
return hasString(value,
|
|
152
|
-
case
|
|
153
|
-
return hasString(value,
|
|
154
|
-
case
|
|
136
|
+
switch (value['kind']) {
|
|
137
|
+
case 'named-range':
|
|
138
|
+
return hasString(value, 'name');
|
|
139
|
+
case 'cell-ref':
|
|
140
|
+
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
141
|
+
case 'range-ref':
|
|
155
142
|
return isCellRangeRef(value);
|
|
156
|
-
case
|
|
157
|
-
return hasString(value,
|
|
143
|
+
case 'structured-ref':
|
|
144
|
+
return hasString(value, 'tableName') && hasString(value, 'columnName');
|
|
158
145
|
default:
|
|
159
146
|
return false;
|
|
160
147
|
}
|
|
161
148
|
}
|
|
162
149
|
function isWorkbookDataValidationRule(value) {
|
|
163
|
-
if (!isRecord(value) || typeof value[
|
|
150
|
+
if (!isRecord(value) || typeof value['kind'] !== 'string') {
|
|
164
151
|
return false;
|
|
165
152
|
}
|
|
166
|
-
switch (value[
|
|
167
|
-
case
|
|
168
|
-
const hasValues = Array.isArray(value[
|
|
169
|
-
const hasSource = value[
|
|
153
|
+
switch (value['kind']) {
|
|
154
|
+
case 'list': {
|
|
155
|
+
const hasValues = Array.isArray(value['values']) && value['values'].every((entry) => isLiteralInput(entry));
|
|
156
|
+
const hasSource = value['source'] !== undefined && isWorkbookValidationListSource(value['source']);
|
|
170
157
|
return (hasValues ? 1 : 0) + (hasSource ? 1 : 0) === 1;
|
|
171
158
|
}
|
|
172
|
-
case
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
case
|
|
176
|
-
case
|
|
177
|
-
case
|
|
178
|
-
case
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
value[
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
: value["values"].length === 1));
|
|
159
|
+
case 'checkbox':
|
|
160
|
+
return isOptionalLiteralInput(value['checkedValue']) && isOptionalLiteralInput(value['uncheckedValue']);
|
|
161
|
+
case 'whole':
|
|
162
|
+
case 'decimal':
|
|
163
|
+
case 'date':
|
|
164
|
+
case 'time':
|
|
165
|
+
case 'textLength':
|
|
166
|
+
return (typeof value['operator'] === 'string' &&
|
|
167
|
+
VALIDATION_COMPARISON_OPERATOR_VALUES.has(value['operator']) &&
|
|
168
|
+
Array.isArray(value['values']) &&
|
|
169
|
+
value['values'].every((entry) => isLiteralInput(entry)) &&
|
|
170
|
+
(value['operator'] === 'between' || value['operator'] === 'notBetween'
|
|
171
|
+
? value['values'].length === 2
|
|
172
|
+
: value['values'].length === 1));
|
|
187
173
|
default:
|
|
188
174
|
return false;
|
|
189
175
|
}
|
|
190
176
|
}
|
|
191
177
|
function isWorkbookDataValidation(value) {
|
|
192
178
|
return (isRecord(value) &&
|
|
193
|
-
isCellRangeRef(value[
|
|
194
|
-
isWorkbookDataValidationRule(value[
|
|
195
|
-
isOptionalBoolean(value[
|
|
196
|
-
isOptionalBoolean(value[
|
|
197
|
-
isOptionalString(value[
|
|
198
|
-
isOptionalString(value[
|
|
199
|
-
(value[
|
|
200
|
-
(typeof value[
|
|
201
|
-
|
|
202
|
-
isOptionalString(value[
|
|
203
|
-
isOptionalString(value["errorMessage"]));
|
|
179
|
+
isCellRangeRef(value['range']) &&
|
|
180
|
+
isWorkbookDataValidationRule(value['rule']) &&
|
|
181
|
+
isOptionalBoolean(value['allowBlank']) &&
|
|
182
|
+
isOptionalBoolean(value['showDropdown']) &&
|
|
183
|
+
isOptionalString(value['promptTitle']) &&
|
|
184
|
+
isOptionalString(value['promptMessage']) &&
|
|
185
|
+
(value['errorStyle'] === undefined ||
|
|
186
|
+
(typeof value['errorStyle'] === 'string' && VALIDATION_ERROR_STYLE_VALUES.has(value['errorStyle']))) &&
|
|
187
|
+
isOptionalString(value['errorTitle']) &&
|
|
188
|
+
isOptionalString(value['errorMessage']));
|
|
204
189
|
}
|
|
205
190
|
function isCellStylePatch(value) {
|
|
206
191
|
if (!isRecord(value)) {
|
|
207
192
|
return false;
|
|
208
193
|
}
|
|
209
|
-
const fill = value[
|
|
194
|
+
const fill = value['fill'];
|
|
210
195
|
if (fill !== undefined &&
|
|
211
196
|
fill !== null &&
|
|
212
|
-
(!isRecord(fill) ||
|
|
213
|
-
!(fill["backgroundColor"] === undefined ||
|
|
214
|
-
fill["backgroundColor"] === null ||
|
|
215
|
-
hasString(fill, "backgroundColor")))) {
|
|
197
|
+
(!isRecord(fill) || !(fill['backgroundColor'] === undefined || fill['backgroundColor'] === null || hasString(fill, 'backgroundColor')))) {
|
|
216
198
|
return false;
|
|
217
199
|
}
|
|
218
|
-
const font = value[
|
|
200
|
+
const font = value['font'];
|
|
219
201
|
if (font !== undefined &&
|
|
220
202
|
font !== null &&
|
|
221
203
|
(!isRecord(font) ||
|
|
222
|
-
!(font[
|
|
223
|
-
!isOptionalNullableNumber(font[
|
|
224
|
-
!isOptionalNullableBoolean(font[
|
|
225
|
-
!isOptionalNullableBoolean(font[
|
|
226
|
-
!isOptionalNullableBoolean(font[
|
|
227
|
-
!(font[
|
|
204
|
+
!(font['family'] === undefined || font['family'] === null || hasString(font, 'family')) ||
|
|
205
|
+
!isOptionalNullableNumber(font['size']) ||
|
|
206
|
+
!isOptionalNullableBoolean(font['bold']) ||
|
|
207
|
+
!isOptionalNullableBoolean(font['italic']) ||
|
|
208
|
+
!isOptionalNullableBoolean(font['underline']) ||
|
|
209
|
+
!(font['color'] === undefined || font['color'] === null || hasString(font, 'color')))) {
|
|
228
210
|
return false;
|
|
229
211
|
}
|
|
230
|
-
const alignment = value[
|
|
212
|
+
const alignment = value['alignment'];
|
|
231
213
|
if (alignment !== undefined &&
|
|
232
214
|
alignment !== null &&
|
|
233
215
|
(!isRecord(alignment) ||
|
|
234
|
-
!(alignment[
|
|
235
|
-
alignment[
|
|
236
|
-
(typeof alignment[
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
alignment[
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
!isOptionalNullableBoolean(alignment["wrap"]) ||
|
|
243
|
-
!isOptionalNullableNumber(alignment["indent"]))) {
|
|
216
|
+
!(alignment['horizontal'] === undefined ||
|
|
217
|
+
alignment['horizontal'] === null ||
|
|
218
|
+
(typeof alignment['horizontal'] === 'string' && HORIZONTAL_ALIGNMENT_VALUES.has(alignment['horizontal']))) ||
|
|
219
|
+
!(alignment['vertical'] === undefined ||
|
|
220
|
+
alignment['vertical'] === null ||
|
|
221
|
+
(typeof alignment['vertical'] === 'string' && VERTICAL_ALIGNMENT_VALUES.has(alignment['vertical']))) ||
|
|
222
|
+
!isOptionalNullableBoolean(alignment['wrap']) ||
|
|
223
|
+
!isOptionalNullableNumber(alignment['indent']))) {
|
|
244
224
|
return false;
|
|
245
225
|
}
|
|
246
|
-
const borders = value[
|
|
226
|
+
const borders = value['borders'];
|
|
247
227
|
if (borders !== undefined && borders !== null) {
|
|
248
228
|
if (!isRecord(borders)) {
|
|
249
229
|
return false;
|
|
250
230
|
}
|
|
251
|
-
for (const side of [
|
|
231
|
+
for (const side of ['top', 'right', 'bottom', 'left']) {
|
|
252
232
|
const sideValue = borders[side];
|
|
253
233
|
if (sideValue === undefined || sideValue === null) {
|
|
254
234
|
continue;
|
|
255
235
|
}
|
|
256
236
|
if (!isRecord(sideValue) ||
|
|
257
|
-
!(sideValue[
|
|
258
|
-
sideValue[
|
|
259
|
-
(typeof sideValue[
|
|
260
|
-
!(sideValue[
|
|
261
|
-
sideValue[
|
|
262
|
-
(typeof sideValue[
|
|
263
|
-
!(sideValue[
|
|
264
|
-
sideValue["color"] === null ||
|
|
265
|
-
hasString(sideValue, "color"))) {
|
|
237
|
+
!(sideValue['style'] === undefined ||
|
|
238
|
+
sideValue['style'] === null ||
|
|
239
|
+
(typeof sideValue['style'] === 'string' && BORDER_STYLE_VALUES.has(sideValue['style']))) ||
|
|
240
|
+
!(sideValue['weight'] === undefined ||
|
|
241
|
+
sideValue['weight'] === null ||
|
|
242
|
+
(typeof sideValue['weight'] === 'string' && BORDER_WEIGHT_VALUES.has(sideValue['weight']))) ||
|
|
243
|
+
!(sideValue['color'] === undefined || sideValue['color'] === null || hasString(sideValue, 'color'))) {
|
|
266
244
|
return false;
|
|
267
245
|
}
|
|
268
246
|
}
|
|
@@ -270,24 +248,24 @@ function isCellStylePatch(value) {
|
|
|
270
248
|
return true;
|
|
271
249
|
}
|
|
272
250
|
function isWorkbookConditionalFormatRule(value) {
|
|
273
|
-
if (!isRecord(value) || typeof value[
|
|
251
|
+
if (!isRecord(value) || typeof value['kind'] !== 'string') {
|
|
274
252
|
return false;
|
|
275
253
|
}
|
|
276
|
-
switch (value[
|
|
277
|
-
case
|
|
278
|
-
return (typeof value[
|
|
279
|
-
VALIDATION_COMPARISON_OPERATOR_VALUES.has(value[
|
|
280
|
-
Array.isArray(value[
|
|
281
|
-
value[
|
|
282
|
-
(value[
|
|
283
|
-
? value[
|
|
284
|
-
: value[
|
|
285
|
-
case
|
|
286
|
-
return hasString(value,
|
|
287
|
-
case
|
|
288
|
-
return hasString(value,
|
|
289
|
-
case
|
|
290
|
-
case
|
|
254
|
+
switch (value['kind']) {
|
|
255
|
+
case 'cellIs':
|
|
256
|
+
return (typeof value['operator'] === 'string' &&
|
|
257
|
+
VALIDATION_COMPARISON_OPERATOR_VALUES.has(value['operator']) &&
|
|
258
|
+
Array.isArray(value['values']) &&
|
|
259
|
+
value['values'].every((entry) => isLiteralInput(entry)) &&
|
|
260
|
+
(value['operator'] === 'between' || value['operator'] === 'notBetween'
|
|
261
|
+
? value['values'].length === 2
|
|
262
|
+
: value['values'].length === 1));
|
|
263
|
+
case 'textContains':
|
|
264
|
+
return hasString(value, 'text') && isOptionalBoolean(value['caseSensitive']);
|
|
265
|
+
case 'formula':
|
|
266
|
+
return hasString(value, 'formula');
|
|
267
|
+
case 'blanks':
|
|
268
|
+
case 'notBlanks':
|
|
291
269
|
return true;
|
|
292
270
|
default:
|
|
293
271
|
return false;
|
|
@@ -295,282 +273,257 @@ function isWorkbookConditionalFormatRule(value) {
|
|
|
295
273
|
}
|
|
296
274
|
function isWorkbookConditionalFormat(value) {
|
|
297
275
|
return (isRecord(value) &&
|
|
298
|
-
hasString(value,
|
|
299
|
-
isCellRangeRef(value[
|
|
300
|
-
isWorkbookConditionalFormatRule(value[
|
|
301
|
-
isCellStylePatch(value[
|
|
302
|
-
isOptionalBoolean(value[
|
|
303
|
-
isOptionalNumber(value[
|
|
276
|
+
hasString(value, 'id') &&
|
|
277
|
+
isCellRangeRef(value['range']) &&
|
|
278
|
+
isWorkbookConditionalFormatRule(value['rule']) &&
|
|
279
|
+
isCellStylePatch(value['style']) &&
|
|
280
|
+
isOptionalBoolean(value['stopIfTrue']) &&
|
|
281
|
+
isOptionalNumber(value['priority']));
|
|
304
282
|
}
|
|
305
283
|
function isWorkbookSheetProtection(value) {
|
|
306
|
-
return
|
|
284
|
+
return isRecord(value) && hasString(value, 'sheetName') && isOptionalBoolean(value['hideFormulas']);
|
|
307
285
|
}
|
|
308
286
|
function isWorkbookRangeProtection(value) {
|
|
309
|
-
return
|
|
310
|
-
hasString(value, "id") &&
|
|
311
|
-
isCellRangeRef(value["range"]) &&
|
|
312
|
-
isOptionalBoolean(value["hideFormulas"]));
|
|
287
|
+
return isRecord(value) && hasString(value, 'id') && isCellRangeRef(value['range']) && isOptionalBoolean(value['hideFormulas']);
|
|
313
288
|
}
|
|
314
289
|
function isWorkbookCommentEntry(value) {
|
|
315
290
|
return (isRecord(value) &&
|
|
316
|
-
hasString(value,
|
|
317
|
-
hasString(value,
|
|
318
|
-
isOptionalString(value[
|
|
319
|
-
isOptionalString(value[
|
|
320
|
-
isOptionalNumber(value[
|
|
291
|
+
hasString(value, 'id') &&
|
|
292
|
+
hasString(value, 'body') &&
|
|
293
|
+
isOptionalString(value['authorUserId']) &&
|
|
294
|
+
isOptionalString(value['authorDisplayName']) &&
|
|
295
|
+
isOptionalNumber(value['createdAtUnixMs']));
|
|
321
296
|
}
|
|
322
297
|
function isWorkbookCommentThread(value) {
|
|
323
298
|
return (isRecord(value) &&
|
|
324
|
-
hasString(value,
|
|
325
|
-
hasString(value,
|
|
326
|
-
hasString(value,
|
|
327
|
-
Array.isArray(value[
|
|
328
|
-
value[
|
|
329
|
-
value[
|
|
330
|
-
isOptionalBoolean(value[
|
|
331
|
-
isOptionalString(value[
|
|
332
|
-
isOptionalNumber(value[
|
|
299
|
+
hasString(value, 'threadId') &&
|
|
300
|
+
hasString(value, 'sheetName') &&
|
|
301
|
+
hasString(value, 'address') &&
|
|
302
|
+
Array.isArray(value['comments']) &&
|
|
303
|
+
value['comments'].length > 0 &&
|
|
304
|
+
value['comments'].every((entry) => isWorkbookCommentEntry(entry)) &&
|
|
305
|
+
isOptionalBoolean(value['resolved']) &&
|
|
306
|
+
isOptionalString(value['resolvedByUserId']) &&
|
|
307
|
+
isOptionalNumber(value['resolvedAtUnixMs']));
|
|
333
308
|
}
|
|
334
309
|
function isWorkbookNote(value) {
|
|
335
|
-
return
|
|
336
|
-
hasString(value, "sheetName") &&
|
|
337
|
-
hasString(value, "address") &&
|
|
338
|
-
hasString(value, "text"));
|
|
310
|
+
return isRecord(value) && hasString(value, 'sheetName') && hasString(value, 'address') && hasString(value, 'text');
|
|
339
311
|
}
|
|
340
312
|
function isWorkbookDefinedNameValue(value) {
|
|
341
313
|
if (isLiteralInput(value)) {
|
|
342
314
|
return true;
|
|
343
315
|
}
|
|
344
|
-
if (!isRecord(value) || typeof value[
|
|
316
|
+
if (!isRecord(value) || typeof value['kind'] !== 'string') {
|
|
345
317
|
return false;
|
|
346
318
|
}
|
|
347
|
-
switch (value[
|
|
348
|
-
case
|
|
349
|
-
return isLiteralInput(value[
|
|
350
|
-
case
|
|
351
|
-
return hasString(value,
|
|
352
|
-
case
|
|
319
|
+
switch (value['kind']) {
|
|
320
|
+
case 'scalar':
|
|
321
|
+
return isLiteralInput(value['value']);
|
|
322
|
+
case 'cell-ref':
|
|
323
|
+
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
324
|
+
case 'range-ref':
|
|
353
325
|
return isCellRangeRef(value);
|
|
354
|
-
case
|
|
355
|
-
return hasString(value,
|
|
356
|
-
case
|
|
357
|
-
return hasString(value,
|
|
326
|
+
case 'structured-ref':
|
|
327
|
+
return hasString(value, 'tableName') && hasString(value, 'columnName');
|
|
328
|
+
case 'formula':
|
|
329
|
+
return hasString(value, 'formula');
|
|
358
330
|
default:
|
|
359
331
|
return false;
|
|
360
332
|
}
|
|
361
333
|
}
|
|
362
334
|
function isWorkbookTableOp(value) {
|
|
363
335
|
return (isRecord(value) &&
|
|
364
|
-
hasString(value,
|
|
365
|
-
hasString(value,
|
|
366
|
-
hasString(value,
|
|
367
|
-
hasString(value,
|
|
368
|
-
isStringArray(value[
|
|
369
|
-
typeof value[
|
|
370
|
-
typeof value[
|
|
336
|
+
hasString(value, 'name') &&
|
|
337
|
+
hasString(value, 'sheetName') &&
|
|
338
|
+
hasString(value, 'startAddress') &&
|
|
339
|
+
hasString(value, 'endAddress') &&
|
|
340
|
+
isStringArray(value['columnNames']) &&
|
|
341
|
+
typeof value['headerRow'] === 'boolean' &&
|
|
342
|
+
typeof value['totalsRow'] === 'boolean');
|
|
371
343
|
}
|
|
372
344
|
function isWorkbookPivotValue(value) {
|
|
373
345
|
return (isRecord(value) &&
|
|
374
|
-
hasString(value,
|
|
375
|
-
typeof value[
|
|
376
|
-
PIVOT_AGGREGATION_VALUES.has(value[
|
|
377
|
-
isOptionalString(value[
|
|
378
|
-
}
|
|
379
|
-
const CHART_TYPE_VALUES = new Set([
|
|
380
|
-
const CHART_SERIES_ORIENTATION_VALUES = new Set([
|
|
381
|
-
const CHART_LEGEND_POSITION_VALUES = new Set([
|
|
382
|
-
const SHAPE_TYPE_VALUES = new Set([
|
|
383
|
-
"rectangle",
|
|
384
|
-
"roundedRectangle",
|
|
385
|
-
"ellipse",
|
|
386
|
-
"line",
|
|
387
|
-
"arrow",
|
|
388
|
-
"textBox",
|
|
389
|
-
]);
|
|
346
|
+
hasString(value, 'sourceColumn') &&
|
|
347
|
+
typeof value['summarizeBy'] === 'string' &&
|
|
348
|
+
PIVOT_AGGREGATION_VALUES.has(value['summarizeBy']) &&
|
|
349
|
+
isOptionalString(value['outputLabel']));
|
|
350
|
+
}
|
|
351
|
+
const CHART_TYPE_VALUES = new Set(['column', 'bar', 'line', 'area', 'pie', 'scatter']);
|
|
352
|
+
const CHART_SERIES_ORIENTATION_VALUES = new Set(['rows', 'columns']);
|
|
353
|
+
const CHART_LEGEND_POSITION_VALUES = new Set(['top', 'right', 'bottom', 'left', 'hidden']);
|
|
354
|
+
const SHAPE_TYPE_VALUES = new Set(['rectangle', 'roundedRectangle', 'ellipse', 'line', 'arrow', 'textBox']);
|
|
390
355
|
function isWorkbookChart(value) {
|
|
391
356
|
return (isRecord(value) &&
|
|
392
|
-
hasString(value,
|
|
393
|
-
hasString(value,
|
|
394
|
-
hasString(value,
|
|
395
|
-
isCellRangeRef(value[
|
|
396
|
-
typeof value[
|
|
397
|
-
CHART_TYPE_VALUES.has(value[
|
|
398
|
-
(value[
|
|
399
|
-
(typeof value[
|
|
400
|
-
|
|
401
|
-
isOptionalBoolean(value[
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
hasFiniteNumber(value, "rows") &&
|
|
408
|
-
hasFiniteNumber(value, "cols"));
|
|
357
|
+
hasString(value, 'id') &&
|
|
358
|
+
hasString(value, 'sheetName') &&
|
|
359
|
+
hasString(value, 'address') &&
|
|
360
|
+
isCellRangeRef(value['source']) &&
|
|
361
|
+
typeof value['chartType'] === 'string' &&
|
|
362
|
+
CHART_TYPE_VALUES.has(value['chartType']) &&
|
|
363
|
+
(value['seriesOrientation'] === undefined ||
|
|
364
|
+
(typeof value['seriesOrientation'] === 'string' && CHART_SERIES_ORIENTATION_VALUES.has(value['seriesOrientation']))) &&
|
|
365
|
+
isOptionalBoolean(value['firstRowAsHeaders']) &&
|
|
366
|
+
isOptionalBoolean(value['firstColumnAsLabels']) &&
|
|
367
|
+
isOptionalString(value['title']) &&
|
|
368
|
+
(value['legendPosition'] === undefined ||
|
|
369
|
+
(typeof value['legendPosition'] === 'string' && CHART_LEGEND_POSITION_VALUES.has(value['legendPosition']))) &&
|
|
370
|
+
hasFiniteNumber(value, 'rows') &&
|
|
371
|
+
hasFiniteNumber(value, 'cols'));
|
|
409
372
|
}
|
|
410
373
|
function isWorkbookImage(value) {
|
|
411
374
|
return (isRecord(value) &&
|
|
412
|
-
hasString(value,
|
|
413
|
-
hasString(value,
|
|
414
|
-
hasString(value,
|
|
415
|
-
hasString(value,
|
|
416
|
-
hasFiniteNumber(value,
|
|
417
|
-
hasFiniteNumber(value,
|
|
418
|
-
isOptionalString(value[
|
|
375
|
+
hasString(value, 'id') &&
|
|
376
|
+
hasString(value, 'sheetName') &&
|
|
377
|
+
hasString(value, 'address') &&
|
|
378
|
+
hasString(value, 'sourceUrl') &&
|
|
379
|
+
hasFiniteNumber(value, 'rows') &&
|
|
380
|
+
hasFiniteNumber(value, 'cols') &&
|
|
381
|
+
isOptionalString(value['altText']));
|
|
419
382
|
}
|
|
420
383
|
function isWorkbookShape(value) {
|
|
421
384
|
return (isRecord(value) &&
|
|
422
|
-
hasString(value,
|
|
423
|
-
hasString(value,
|
|
424
|
-
hasString(value,
|
|
425
|
-
typeof value[
|
|
426
|
-
SHAPE_TYPE_VALUES.has(value[
|
|
427
|
-
hasFiniteNumber(value,
|
|
428
|
-
hasFiniteNumber(value,
|
|
429
|
-
isOptionalString(value[
|
|
430
|
-
isOptionalString(value[
|
|
431
|
-
isOptionalString(value[
|
|
385
|
+
hasString(value, 'id') &&
|
|
386
|
+
hasString(value, 'sheetName') &&
|
|
387
|
+
hasString(value, 'address') &&
|
|
388
|
+
typeof value['shapeType'] === 'string' &&
|
|
389
|
+
SHAPE_TYPE_VALUES.has(value['shapeType']) &&
|
|
390
|
+
hasFiniteNumber(value, 'rows') &&
|
|
391
|
+
hasFiniteNumber(value, 'cols') &&
|
|
392
|
+
isOptionalString(value['text']) &&
|
|
393
|
+
isOptionalString(value['fillColor']) &&
|
|
394
|
+
isOptionalString(value['strokeColor']));
|
|
432
395
|
}
|
|
433
396
|
export function isWorkbookOp(value) {
|
|
434
|
-
if (!isRecord(value) || typeof value[
|
|
397
|
+
if (!isRecord(value) || typeof value['kind'] !== 'string') {
|
|
435
398
|
return false;
|
|
436
399
|
}
|
|
437
|
-
switch (value[
|
|
438
|
-
case
|
|
439
|
-
return hasString(value,
|
|
440
|
-
case
|
|
441
|
-
return hasString(value,
|
|
442
|
-
case
|
|
443
|
-
return isWorkbookCalculationSettings(value[
|
|
444
|
-
case
|
|
445
|
-
return isWorkbookVolatileContext(value[
|
|
446
|
-
case
|
|
447
|
-
return
|
|
448
|
-
case
|
|
449
|
-
return hasString(value,
|
|
450
|
-
case
|
|
451
|
-
return hasString(value,
|
|
452
|
-
case
|
|
453
|
-
case
|
|
454
|
-
return (hasString(value,
|
|
455
|
-
hasFiniteNumber(value,
|
|
456
|
-
hasFiniteNumber(value,
|
|
457
|
-
(value[
|
|
458
|
-
(Array.isArray(value[
|
|
459
|
-
|
|
460
|
-
case
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
case
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
case
|
|
493
|
-
return (
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
case
|
|
508
|
-
return hasString(value,
|
|
509
|
-
case
|
|
510
|
-
return
|
|
511
|
-
case
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
case
|
|
517
|
-
return
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
case
|
|
534
|
-
return
|
|
535
|
-
case
|
|
536
|
-
return
|
|
537
|
-
case
|
|
538
|
-
return hasString(value,
|
|
539
|
-
case
|
|
540
|
-
case
|
|
541
|
-
return hasString(value,
|
|
542
|
-
case
|
|
543
|
-
return
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
case
|
|
553
|
-
return (
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
case
|
|
563
|
-
return
|
|
564
|
-
case "deleteChart":
|
|
565
|
-
return hasString(value, "id");
|
|
566
|
-
case "upsertImage":
|
|
567
|
-
return isWorkbookImage(value["image"]);
|
|
568
|
-
case "deleteImage":
|
|
569
|
-
return hasString(value, "id");
|
|
570
|
-
case "upsertShape":
|
|
571
|
-
return isWorkbookShape(value["shape"]);
|
|
572
|
-
case "deleteShape":
|
|
573
|
-
return hasString(value, "id");
|
|
400
|
+
switch (value['kind']) {
|
|
401
|
+
case 'upsertWorkbook':
|
|
402
|
+
return hasString(value, 'name');
|
|
403
|
+
case 'setWorkbookMetadata':
|
|
404
|
+
return hasString(value, 'key') && isLiteralInput(value['value']);
|
|
405
|
+
case 'setCalculationSettings':
|
|
406
|
+
return isWorkbookCalculationSettings(value['settings']);
|
|
407
|
+
case 'setVolatileContext':
|
|
408
|
+
return isWorkbookVolatileContext(value['context']);
|
|
409
|
+
case 'upsertSheet':
|
|
410
|
+
return hasString(value, 'name') && hasFiniteNumber(value, 'order') && isOptionalNumber(value['id']);
|
|
411
|
+
case 'renameSheet':
|
|
412
|
+
return hasString(value, 'oldName') && hasString(value, 'newName');
|
|
413
|
+
case 'deleteSheet':
|
|
414
|
+
return hasString(value, 'name');
|
|
415
|
+
case 'insertRows':
|
|
416
|
+
case 'insertColumns':
|
|
417
|
+
return (hasString(value, 'sheetName') &&
|
|
418
|
+
hasFiniteNumber(value, 'start') &&
|
|
419
|
+
hasFiniteNumber(value, 'count') &&
|
|
420
|
+
(value['entries'] === undefined ||
|
|
421
|
+
(Array.isArray(value['entries']) && value['entries'].every((entry) => isWorkbookAxisEntry(entry)))));
|
|
422
|
+
case 'deleteRows':
|
|
423
|
+
case 'deleteColumns':
|
|
424
|
+
return hasString(value, 'sheetName') && hasFiniteNumber(value, 'start') && hasFiniteNumber(value, 'count');
|
|
425
|
+
case 'moveRows':
|
|
426
|
+
case 'moveColumns':
|
|
427
|
+
return (hasString(value, 'sheetName') &&
|
|
428
|
+
hasFiniteNumber(value, 'start') &&
|
|
429
|
+
hasFiniteNumber(value, 'count') &&
|
|
430
|
+
hasFiniteNumber(value, 'target'));
|
|
431
|
+
case 'updateRowMetadata':
|
|
432
|
+
case 'updateColumnMetadata':
|
|
433
|
+
return (hasString(value, 'sheetName') &&
|
|
434
|
+
hasFiniteNumber(value, 'start') &&
|
|
435
|
+
hasFiniteNumber(value, 'count') &&
|
|
436
|
+
isOptionalNullableNumber(value['size']) &&
|
|
437
|
+
isOptionalNullableBoolean(value['hidden']));
|
|
438
|
+
case 'setFreezePane':
|
|
439
|
+
return hasString(value, 'sheetName') && hasFiniteNumber(value, 'rows') && hasFiniteNumber(value, 'cols');
|
|
440
|
+
case 'clearFreezePane':
|
|
441
|
+
return hasString(value, 'sheetName');
|
|
442
|
+
case 'setSheetProtection':
|
|
443
|
+
return isWorkbookSheetProtection(value['protection']);
|
|
444
|
+
case 'clearSheetProtection':
|
|
445
|
+
return hasString(value, 'sheetName');
|
|
446
|
+
case 'setFilter':
|
|
447
|
+
case 'clearFilter':
|
|
448
|
+
case 'clearSort':
|
|
449
|
+
return hasString(value, 'sheetName') && isCellRangeRef(value['range']);
|
|
450
|
+
case 'setSort':
|
|
451
|
+
return (hasString(value, 'sheetName') &&
|
|
452
|
+
isCellRangeRef(value['range']) &&
|
|
453
|
+
Array.isArray(value['keys']) &&
|
|
454
|
+
value['keys'].every((entry) => isWorkbookSortKey(entry)));
|
|
455
|
+
case 'setDataValidation':
|
|
456
|
+
return isWorkbookDataValidation(value['validation']);
|
|
457
|
+
case 'clearDataValidation':
|
|
458
|
+
return hasString(value, 'sheetName') && isCellRangeRef(value['range']);
|
|
459
|
+
case 'upsertConditionalFormat':
|
|
460
|
+
return isWorkbookConditionalFormat(value['format']);
|
|
461
|
+
case 'deleteConditionalFormat':
|
|
462
|
+
return hasString(value, 'id') && hasString(value, 'sheetName');
|
|
463
|
+
case 'upsertRangeProtection':
|
|
464
|
+
return isWorkbookRangeProtection(value['protection']);
|
|
465
|
+
case 'deleteRangeProtection':
|
|
466
|
+
return hasString(value, 'id') && hasString(value, 'sheetName');
|
|
467
|
+
case 'upsertCommentThread':
|
|
468
|
+
return isWorkbookCommentThread(value['thread']);
|
|
469
|
+
case 'deleteCommentThread':
|
|
470
|
+
case 'deleteNote':
|
|
471
|
+
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
472
|
+
case 'upsertNote':
|
|
473
|
+
return isWorkbookNote(value['note']);
|
|
474
|
+
case 'setCellValue':
|
|
475
|
+
return (hasString(value, 'sheetName') &&
|
|
476
|
+
hasString(value, 'address') &&
|
|
477
|
+
isLiteralInput(value['value']) &&
|
|
478
|
+
(value['authoredBlank'] === undefined || typeof value['authoredBlank'] === 'boolean'));
|
|
479
|
+
case 'setCellFormula':
|
|
480
|
+
return hasString(value, 'sheetName') && hasString(value, 'address') && hasString(value, 'formula');
|
|
481
|
+
case 'setCellFormat':
|
|
482
|
+
return (hasString(value, 'sheetName') && hasString(value, 'address') && (value['format'] === null || typeof value['format'] === 'string'));
|
|
483
|
+
case 'upsertCellStyle':
|
|
484
|
+
return isCellStyleRecord(value['style']);
|
|
485
|
+
case 'upsertCellNumberFormat':
|
|
486
|
+
return isCellNumberFormatRecord(value['format']);
|
|
487
|
+
case 'setStyleRange':
|
|
488
|
+
return isCellRangeRef(value['range']) && hasString(value, 'styleId');
|
|
489
|
+
case 'setFormatRange':
|
|
490
|
+
return isCellRangeRef(value['range']) && hasString(value, 'formatId');
|
|
491
|
+
case 'clearCell':
|
|
492
|
+
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
493
|
+
case 'upsertDefinedName':
|
|
494
|
+
return hasString(value, 'name') && isWorkbookDefinedNameValue(value['value']);
|
|
495
|
+
case 'deleteDefinedName':
|
|
496
|
+
case 'deleteTable':
|
|
497
|
+
return hasString(value, 'name');
|
|
498
|
+
case 'upsertTable':
|
|
499
|
+
return isWorkbookTableOp(value['table']);
|
|
500
|
+
case 'upsertSpillRange':
|
|
501
|
+
return (hasString(value, 'sheetName') && hasString(value, 'address') && hasFiniteNumber(value, 'rows') && hasFiniteNumber(value, 'cols'));
|
|
502
|
+
case 'deleteSpillRange':
|
|
503
|
+
case 'deletePivotTable':
|
|
504
|
+
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
505
|
+
case 'upsertPivotTable':
|
|
506
|
+
return (hasString(value, 'name') &&
|
|
507
|
+
hasString(value, 'sheetName') &&
|
|
508
|
+
hasString(value, 'address') &&
|
|
509
|
+
isCellRangeRef(value['source']) &&
|
|
510
|
+
isStringArray(value['groupBy']) &&
|
|
511
|
+
Array.isArray(value['values']) &&
|
|
512
|
+
value['values'].every((entry) => isWorkbookPivotValue(entry)) &&
|
|
513
|
+
hasFiniteNumber(value, 'rows') &&
|
|
514
|
+
hasFiniteNumber(value, 'cols'));
|
|
515
|
+
case 'upsertChart':
|
|
516
|
+
return isWorkbookChart(value['chart']);
|
|
517
|
+
case 'deleteChart':
|
|
518
|
+
return hasString(value, 'id');
|
|
519
|
+
case 'upsertImage':
|
|
520
|
+
return isWorkbookImage(value['image']);
|
|
521
|
+
case 'deleteImage':
|
|
522
|
+
return hasString(value, 'id');
|
|
523
|
+
case 'upsertShape':
|
|
524
|
+
return isWorkbookShape(value['shape']);
|
|
525
|
+
case 'deleteShape':
|
|
526
|
+
return hasString(value, 'id');
|
|
574
527
|
default:
|
|
575
528
|
return false;
|
|
576
529
|
}
|
|
@@ -583,10 +536,10 @@ export function isEngineOps(value) {
|
|
|
583
536
|
}
|
|
584
537
|
export function isEngineOpBatch(value) {
|
|
585
538
|
return (isRecord(value) &&
|
|
586
|
-
hasString(value,
|
|
587
|
-
hasString(value,
|
|
588
|
-
isRecord(value[
|
|
589
|
-
hasFiniteNumber(value[
|
|
590
|
-
isEngineOps(value[
|
|
539
|
+
hasString(value, 'id') &&
|
|
540
|
+
hasString(value, 'replicaId') &&
|
|
541
|
+
isRecord(value['clock']) &&
|
|
542
|
+
hasFiniteNumber(value['clock'], 'counter') &&
|
|
543
|
+
isEngineOps(value['ops']));
|
|
591
544
|
}
|
|
592
545
|
//# sourceMappingURL=guards.js.map
|