@bilig/workbook 0.67.7 → 0.67.9
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/README.md +12 -5
- package/dist/features.js +0 -3
- package/dist/features.js.map +1 -1
- package/dist/guards.js +233 -226
- package/dist/guards.js.map +1 -1
- package/dist/plan-data.js +52 -25
- package/dist/plan-data.js.map +1 -1
- package/dist/run.js +154 -18
- package/dist/run.js.map +1 -1
- package/package.json +3 -3
package/dist/guards.js
CHANGED
|
@@ -41,7 +41,25 @@ function isSafePositiveInteger(value) {
|
|
|
41
41
|
return typeof value === 'number' && Number.isSafeInteger(value) && value > 0;
|
|
42
42
|
}
|
|
43
43
|
function isStringArray(value) {
|
|
44
|
-
return
|
|
44
|
+
return arrayEvery(value, (entry) => typeof entry === 'string');
|
|
45
|
+
}
|
|
46
|
+
function stringSetHas(values, value) {
|
|
47
|
+
return typeof value === 'string' && values.has(value);
|
|
48
|
+
}
|
|
49
|
+
function arrayEvery(value, predicate) {
|
|
50
|
+
if (!Array.isArray(value)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
54
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
55
|
+
if (descriptor === undefined || !('value' in descriptor) || !predicate(descriptor.value)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function nonEmptyArrayEvery(value, predicate) {
|
|
62
|
+
return Array.isArray(value) && value.length > 0 && arrayEvery(value, predicate);
|
|
45
63
|
}
|
|
46
64
|
function isConditionalFormatArtifacts(value) {
|
|
47
65
|
return isRecord(value) && hasString(value, 'xml');
|
|
@@ -89,64 +107,60 @@ function isWorkbookAxisEntry(value) {
|
|
|
89
107
|
return (isRecord(value) &&
|
|
90
108
|
hasString(value, 'id') &&
|
|
91
109
|
hasSafeNonNegativeInteger(value, 'index') &&
|
|
92
|
-
isOptionalNullableSafePositiveInteger(value
|
|
93
|
-
isOptionalNullableBoolean(value
|
|
94
|
-
isOptionalNullableBoolean(value
|
|
110
|
+
isOptionalNullableSafePositiveInteger(ownValue(value, 'size')) &&
|
|
111
|
+
isOptionalNullableBoolean(ownValue(value, 'hidden')) &&
|
|
112
|
+
isOptionalNullableBoolean(ownValue(value, 'filterHidden')));
|
|
95
113
|
}
|
|
96
114
|
function isCellBorderSide(value) {
|
|
97
115
|
return (isRecord(value) &&
|
|
98
116
|
hasString(value, 'color') &&
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
typeof value['weight'] === 'string' &&
|
|
102
|
-
BORDER_WEIGHT_VALUES.has(value['weight']));
|
|
117
|
+
stringSetHas(BORDER_STYLE_VALUES, ownValue(value, 'style')) &&
|
|
118
|
+
stringSetHas(BORDER_WEIGHT_VALUES, ownValue(value, 'weight')));
|
|
103
119
|
}
|
|
104
120
|
function isCellStyleRecord(value) {
|
|
105
121
|
if (!isRecord(value) || !hasString(value, 'id')) {
|
|
106
122
|
return false;
|
|
107
123
|
}
|
|
108
|
-
const fill = value
|
|
109
|
-
if (fill !== undefined && (!isRecord(fill) || typeof fill
|
|
124
|
+
const fill = ownValue(value, 'fill');
|
|
125
|
+
if (fill !== undefined && (!isRecord(fill) || typeof ownValue(fill, 'backgroundColor') !== 'string')) {
|
|
110
126
|
return false;
|
|
111
127
|
}
|
|
112
|
-
const font = value
|
|
128
|
+
const font = ownValue(value, 'font');
|
|
113
129
|
if (font !== undefined &&
|
|
114
130
|
(!isRecord(font) ||
|
|
115
|
-
!isOptionalString(font
|
|
116
|
-
!isOptionalNumber(font
|
|
117
|
-
!isOptionalBoolean(font
|
|
118
|
-
!isOptionalBoolean(font
|
|
119
|
-
!isOptionalBoolean(font
|
|
120
|
-
!isOptionalString(font
|
|
131
|
+
!isOptionalString(ownValue(font, 'family')) ||
|
|
132
|
+
!isOptionalNumber(ownValue(font, 'size')) ||
|
|
133
|
+
!isOptionalBoolean(ownValue(font, 'bold')) ||
|
|
134
|
+
!isOptionalBoolean(ownValue(font, 'italic')) ||
|
|
135
|
+
!isOptionalBoolean(ownValue(font, 'underline')) ||
|
|
136
|
+
!isOptionalString(ownValue(font, 'color')))) {
|
|
121
137
|
return false;
|
|
122
138
|
}
|
|
123
|
-
const alignment = value
|
|
139
|
+
const alignment = ownValue(value, 'alignment');
|
|
124
140
|
if (alignment !== undefined &&
|
|
125
141
|
(!isRecord(alignment) ||
|
|
126
|
-
!(alignment
|
|
127
|
-
|
|
128
|
-
!(alignment
|
|
129
|
-
|
|
130
|
-
!isOptionalBoolean(alignment
|
|
131
|
-
!isOptionalNumber(alignment
|
|
132
|
-
!
|
|
133
|
-
!
|
|
134
|
-
!isOptionalNumber(alignment['textRotation']) ||
|
|
135
|
-
!isOptionalBoolean(alignment['justifyLastLine']))) {
|
|
142
|
+
!(ownValue(alignment, 'horizontal') === undefined || stringSetHas(HORIZONTAL_ALIGNMENT_VALUES, ownValue(alignment, 'horizontal'))) ||
|
|
143
|
+
!(ownValue(alignment, 'vertical') === undefined || stringSetHas(VERTICAL_ALIGNMENT_VALUES, ownValue(alignment, 'vertical'))) ||
|
|
144
|
+
!isOptionalBoolean(ownValue(alignment, 'wrap')) ||
|
|
145
|
+
!isOptionalNumber(ownValue(alignment, 'indent')) ||
|
|
146
|
+
!isOptionalBoolean(ownValue(alignment, 'shrinkToFit')) ||
|
|
147
|
+
!isOptionalNumber(ownValue(alignment, 'readingOrder')) ||
|
|
148
|
+
!isOptionalNumber(ownValue(alignment, 'textRotation')) ||
|
|
149
|
+
!isOptionalBoolean(ownValue(alignment, 'justifyLastLine')))) {
|
|
136
150
|
return false;
|
|
137
151
|
}
|
|
138
|
-
const borders = value
|
|
152
|
+
const borders = ownValue(value, 'borders');
|
|
139
153
|
if (borders !== undefined &&
|
|
140
154
|
(!isRecord(borders) ||
|
|
141
|
-
!(borders
|
|
142
|
-
!(borders
|
|
143
|
-
!(borders
|
|
144
|
-
!(borders
|
|
155
|
+
!(ownValue(borders, 'top') === undefined || isCellBorderSide(ownValue(borders, 'top'))) ||
|
|
156
|
+
!(ownValue(borders, 'right') === undefined || isCellBorderSide(ownValue(borders, 'right'))) ||
|
|
157
|
+
!(ownValue(borders, 'bottom') === undefined || isCellBorderSide(ownValue(borders, 'bottom'))) ||
|
|
158
|
+
!(ownValue(borders, 'left') === undefined || isCellBorderSide(ownValue(borders, 'left'))))) {
|
|
145
159
|
return false;
|
|
146
160
|
}
|
|
147
|
-
const protection = value
|
|
161
|
+
const protection = ownValue(value, 'protection');
|
|
148
162
|
if (protection !== undefined &&
|
|
149
|
-
(!isRecord(protection) || !isOptionalBoolean(protection
|
|
163
|
+
(!isRecord(protection) || !isOptionalBoolean(ownValue(protection, 'locked')) || !isOptionalBoolean(ownValue(protection, 'hidden')))) {
|
|
150
164
|
return false;
|
|
151
165
|
}
|
|
152
166
|
return true;
|
|
@@ -155,29 +169,24 @@ function isCellNumberFormatRecord(value) {
|
|
|
155
169
|
return (isRecord(value) &&
|
|
156
170
|
hasString(value, 'id') &&
|
|
157
171
|
hasString(value, 'code') &&
|
|
158
|
-
|
|
159
|
-
NUMBER_FORMAT_KIND_VALUES.has(value['kind']));
|
|
172
|
+
stringSetHas(NUMBER_FORMAT_KIND_VALUES, ownValue(value, 'kind')));
|
|
160
173
|
}
|
|
161
174
|
function isWorkbookCalculationSettings(value) {
|
|
162
175
|
return (isRecord(value) &&
|
|
163
|
-
(value
|
|
164
|
-
(value
|
|
165
|
-
(typeof value['compatibilityMode'] === 'string' && COMPATIBILITY_MODE_VALUES.has(value['compatibilityMode']))));
|
|
176
|
+
(ownValue(value, 'mode') === 'automatic' || ownValue(value, 'mode') === 'manual') &&
|
|
177
|
+
(ownValue(value, 'compatibilityMode') === undefined || stringSetHas(COMPATIBILITY_MODE_VALUES, ownValue(value, 'compatibilityMode'))));
|
|
166
178
|
}
|
|
167
179
|
function isWorkbookVolatileContext(value) {
|
|
168
180
|
return isRecord(value) && hasFiniteNumber(value, 'recalcEpoch');
|
|
169
181
|
}
|
|
170
182
|
function isWorkbookSortKey(value) {
|
|
171
|
-
return
|
|
172
|
-
hasString(value, 'keyAddress') &&
|
|
173
|
-
typeof value['direction'] === 'string' &&
|
|
174
|
-
SORT_DIRECTION_VALUES.has(value['direction']));
|
|
183
|
+
return isRecord(value) && hasString(value, 'keyAddress') && stringSetHas(SORT_DIRECTION_VALUES, ownValue(value, 'direction'));
|
|
175
184
|
}
|
|
176
185
|
function isWorkbookValidationListSource(value) {
|
|
177
|
-
if (!isRecord(value) || typeof value
|
|
186
|
+
if (!isRecord(value) || typeof ownValue(value, 'kind') !== 'string') {
|
|
178
187
|
return false;
|
|
179
188
|
}
|
|
180
|
-
switch (value
|
|
189
|
+
switch (ownValue(value, 'kind')) {
|
|
181
190
|
case 'named-range':
|
|
182
191
|
return hasString(value, 'name');
|
|
183
192
|
case 'cell-ref':
|
|
@@ -191,17 +200,17 @@ function isWorkbookValidationListSource(value) {
|
|
|
191
200
|
}
|
|
192
201
|
}
|
|
193
202
|
function isWorkbookDataValidationRule(value) {
|
|
194
|
-
if (!isRecord(value) || typeof value
|
|
203
|
+
if (!isRecord(value) || typeof ownValue(value, 'kind') !== 'string') {
|
|
195
204
|
return false;
|
|
196
205
|
}
|
|
197
|
-
switch (value
|
|
206
|
+
switch (ownValue(value, 'kind')) {
|
|
198
207
|
case 'list': {
|
|
199
|
-
const hasValues =
|
|
200
|
-
const hasSource = value
|
|
208
|
+
const hasValues = arrayEvery(ownValue(value, 'values'), isLiteralInput);
|
|
209
|
+
const hasSource = ownValue(value, 'source') !== undefined && isWorkbookValidationListSource(ownValue(value, 'source'));
|
|
201
210
|
return (hasValues ? 1 : 0) + (hasSource ? 1 : 0) === 1;
|
|
202
211
|
}
|
|
203
212
|
case 'checkbox':
|
|
204
|
-
return isOptionalLiteralInput(value
|
|
213
|
+
return isOptionalLiteralInput(ownValue(value, 'checkedValue')) && isOptionalLiteralInput(ownValue(value, 'uncheckedValue'));
|
|
205
214
|
case 'any':
|
|
206
215
|
return true;
|
|
207
216
|
case 'whole':
|
|
@@ -209,88 +218,90 @@ function isWorkbookDataValidationRule(value) {
|
|
|
209
218
|
case 'date':
|
|
210
219
|
case 'time':
|
|
211
220
|
case 'textLength':
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
(
|
|
217
|
-
?
|
|
218
|
-
:
|
|
221
|
+
const operator = ownValue(value, 'operator');
|
|
222
|
+
const values = ownValue(value, 'values');
|
|
223
|
+
return (stringSetHas(VALIDATION_COMPARISON_OPERATOR_VALUES, operator) &&
|
|
224
|
+
arrayEvery(values, isLiteralInput) &&
|
|
225
|
+
(operator === 'between' || operator === 'notBetween'
|
|
226
|
+
? Array.isArray(values) && values.length === 2
|
|
227
|
+
: Array.isArray(values) && values.length === 1));
|
|
219
228
|
default:
|
|
220
229
|
return false;
|
|
221
230
|
}
|
|
222
231
|
}
|
|
223
232
|
function isWorkbookDataValidation(value) {
|
|
224
233
|
return (isRecord(value) &&
|
|
225
|
-
isCellRangeRef(value
|
|
226
|
-
isWorkbookDataValidationRule(value
|
|
227
|
-
isOptionalBoolean(value
|
|
228
|
-
isOptionalBoolean(value
|
|
229
|
-
isOptionalString(value
|
|
230
|
-
isOptionalString(value
|
|
231
|
-
(value
|
|
232
|
-
|
|
233
|
-
isOptionalString(value
|
|
234
|
-
isOptionalString(value['errorMessage']));
|
|
234
|
+
isCellRangeRef(ownValue(value, 'range')) &&
|
|
235
|
+
isWorkbookDataValidationRule(ownValue(value, 'rule')) &&
|
|
236
|
+
isOptionalBoolean(ownValue(value, 'allowBlank')) &&
|
|
237
|
+
isOptionalBoolean(ownValue(value, 'showDropdown')) &&
|
|
238
|
+
isOptionalString(ownValue(value, 'promptTitle')) &&
|
|
239
|
+
isOptionalString(ownValue(value, 'promptMessage')) &&
|
|
240
|
+
(ownValue(value, 'errorStyle') === undefined || stringSetHas(VALIDATION_ERROR_STYLE_VALUES, ownValue(value, 'errorStyle'))) &&
|
|
241
|
+
isOptionalString(ownValue(value, 'errorTitle')) &&
|
|
242
|
+
isOptionalString(ownValue(value, 'errorMessage')));
|
|
235
243
|
}
|
|
236
244
|
function isCellStylePatch(value) {
|
|
237
245
|
if (!isRecord(value)) {
|
|
238
246
|
return false;
|
|
239
247
|
}
|
|
240
|
-
const fill = value
|
|
248
|
+
const fill = ownValue(value, 'fill');
|
|
241
249
|
if (fill !== undefined &&
|
|
242
250
|
fill !== null &&
|
|
243
|
-
(!isRecord(fill) ||
|
|
251
|
+
(!isRecord(fill) ||
|
|
252
|
+
!(ownValue(fill, 'backgroundColor') === undefined ||
|
|
253
|
+
ownValue(fill, 'backgroundColor') === null ||
|
|
254
|
+
hasString(fill, 'backgroundColor')))) {
|
|
244
255
|
return false;
|
|
245
256
|
}
|
|
246
|
-
const font = value
|
|
257
|
+
const font = ownValue(value, 'font');
|
|
247
258
|
if (font !== undefined &&
|
|
248
259
|
font !== null &&
|
|
249
260
|
(!isRecord(font) ||
|
|
250
|
-
!(font
|
|
251
|
-
!isOptionalNullableNumber(font
|
|
252
|
-
!isOptionalNullableBoolean(font
|
|
253
|
-
!isOptionalNullableBoolean(font
|
|
254
|
-
!isOptionalNullableBoolean(font
|
|
255
|
-
!(font
|
|
261
|
+
!(ownValue(font, 'family') === undefined || ownValue(font, 'family') === null || hasString(font, 'family')) ||
|
|
262
|
+
!isOptionalNullableNumber(ownValue(font, 'size')) ||
|
|
263
|
+
!isOptionalNullableBoolean(ownValue(font, 'bold')) ||
|
|
264
|
+
!isOptionalNullableBoolean(ownValue(font, 'italic')) ||
|
|
265
|
+
!isOptionalNullableBoolean(ownValue(font, 'underline')) ||
|
|
266
|
+
!(ownValue(font, 'color') === undefined || ownValue(font, 'color') === null || hasString(font, 'color')))) {
|
|
256
267
|
return false;
|
|
257
268
|
}
|
|
258
|
-
const alignment = value
|
|
269
|
+
const alignment = ownValue(value, 'alignment');
|
|
259
270
|
if (alignment !== undefined &&
|
|
260
271
|
alignment !== null &&
|
|
261
272
|
(!isRecord(alignment) ||
|
|
262
|
-
!(alignment
|
|
263
|
-
alignment
|
|
264
|
-
(
|
|
265
|
-
!(alignment
|
|
266
|
-
alignment
|
|
267
|
-
(
|
|
268
|
-
!isOptionalNullableBoolean(alignment
|
|
269
|
-
!isOptionalNullableNumber(alignment
|
|
270
|
-
!isOptionalNullableBoolean(alignment
|
|
271
|
-
!isOptionalNullableNumber(alignment
|
|
272
|
-
!isOptionalNullableNumber(alignment
|
|
273
|
-
!isOptionalNullableBoolean(alignment
|
|
273
|
+
!(ownValue(alignment, 'horizontal') === undefined ||
|
|
274
|
+
ownValue(alignment, 'horizontal') === null ||
|
|
275
|
+
stringSetHas(HORIZONTAL_ALIGNMENT_VALUES, ownValue(alignment, 'horizontal'))) ||
|
|
276
|
+
!(ownValue(alignment, 'vertical') === undefined ||
|
|
277
|
+
ownValue(alignment, 'vertical') === null ||
|
|
278
|
+
stringSetHas(VERTICAL_ALIGNMENT_VALUES, ownValue(alignment, 'vertical'))) ||
|
|
279
|
+
!isOptionalNullableBoolean(ownValue(alignment, 'wrap')) ||
|
|
280
|
+
!isOptionalNullableNumber(ownValue(alignment, 'indent')) ||
|
|
281
|
+
!isOptionalNullableBoolean(ownValue(alignment, 'shrinkToFit')) ||
|
|
282
|
+
!isOptionalNullableNumber(ownValue(alignment, 'readingOrder')) ||
|
|
283
|
+
!isOptionalNullableNumber(ownValue(alignment, 'textRotation')) ||
|
|
284
|
+
!isOptionalNullableBoolean(ownValue(alignment, 'justifyLastLine')))) {
|
|
274
285
|
return false;
|
|
275
286
|
}
|
|
276
|
-
const borders = value
|
|
287
|
+
const borders = ownValue(value, 'borders');
|
|
277
288
|
if (borders !== undefined && borders !== null) {
|
|
278
289
|
if (!isRecord(borders)) {
|
|
279
290
|
return false;
|
|
280
291
|
}
|
|
281
292
|
for (const side of ['top', 'right', 'bottom', 'left']) {
|
|
282
|
-
const sideValue = borders
|
|
293
|
+
const sideValue = ownValue(borders, side);
|
|
283
294
|
if (sideValue === undefined || sideValue === null) {
|
|
284
295
|
continue;
|
|
285
296
|
}
|
|
286
297
|
if (!isRecord(sideValue) ||
|
|
287
|
-
!(sideValue
|
|
288
|
-
sideValue
|
|
289
|
-
(
|
|
290
|
-
!(sideValue
|
|
291
|
-
sideValue
|
|
292
|
-
(
|
|
293
|
-
!(sideValue
|
|
298
|
+
!(ownValue(sideValue, 'style') === undefined ||
|
|
299
|
+
ownValue(sideValue, 'style') === null ||
|
|
300
|
+
stringSetHas(BORDER_STYLE_VALUES, ownValue(sideValue, 'style'))) ||
|
|
301
|
+
!(ownValue(sideValue, 'weight') === undefined ||
|
|
302
|
+
ownValue(sideValue, 'weight') === null ||
|
|
303
|
+
stringSetHas(BORDER_WEIGHT_VALUES, ownValue(sideValue, 'weight'))) ||
|
|
304
|
+
!(ownValue(sideValue, 'color') === undefined || ownValue(sideValue, 'color') === null || hasString(sideValue, 'color'))) {
|
|
294
305
|
return false;
|
|
295
306
|
}
|
|
296
307
|
}
|
|
@@ -298,20 +309,20 @@ function isCellStylePatch(value) {
|
|
|
298
309
|
return true;
|
|
299
310
|
}
|
|
300
311
|
function isWorkbookConditionalFormatRule(value) {
|
|
301
|
-
if (!isRecord(value) || typeof value
|
|
312
|
+
if (!isRecord(value) || typeof ownValue(value, 'kind') !== 'string') {
|
|
302
313
|
return false;
|
|
303
314
|
}
|
|
304
|
-
switch (value
|
|
315
|
+
switch (ownValue(value, 'kind')) {
|
|
305
316
|
case 'cellIs':
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
(
|
|
311
|
-
?
|
|
312
|
-
:
|
|
317
|
+
const operator = ownValue(value, 'operator');
|
|
318
|
+
const values = ownValue(value, 'values');
|
|
319
|
+
return (stringSetHas(VALIDATION_COMPARISON_OPERATOR_VALUES, operator) &&
|
|
320
|
+
arrayEvery(values, isLiteralInput) &&
|
|
321
|
+
(operator === 'between' || operator === 'notBetween'
|
|
322
|
+
? Array.isArray(values) && values.length === 2
|
|
323
|
+
: Array.isArray(values) && values.length === 1));
|
|
313
324
|
case 'textContains':
|
|
314
|
-
return hasString(value, 'text') && isOptionalBoolean(value
|
|
325
|
+
return hasString(value, 'text') && isOptionalBoolean(ownValue(value, 'caseSensitive'));
|
|
315
326
|
case 'formula':
|
|
316
327
|
return hasString(value, 'formula');
|
|
317
328
|
case 'blanks':
|
|
@@ -324,37 +335,38 @@ function isWorkbookConditionalFormatRule(value) {
|
|
|
324
335
|
function isWorkbookConditionalFormat(value) {
|
|
325
336
|
return (isRecord(value) &&
|
|
326
337
|
hasString(value, 'id') &&
|
|
327
|
-
isCellRangeRef(value
|
|
328
|
-
isWorkbookConditionalFormatRule(value
|
|
329
|
-
isCellStylePatch(value
|
|
330
|
-
isOptionalBoolean(value
|
|
331
|
-
isOptionalSafeNonNegativeInteger(value
|
|
338
|
+
isCellRangeRef(ownValue(value, 'range')) &&
|
|
339
|
+
isWorkbookConditionalFormatRule(ownValue(value, 'rule')) &&
|
|
340
|
+
isCellStylePatch(ownValue(value, 'style')) &&
|
|
341
|
+
isOptionalBoolean(ownValue(value, 'stopIfTrue')) &&
|
|
342
|
+
isOptionalSafeNonNegativeInteger(ownValue(value, 'priority')));
|
|
332
343
|
}
|
|
333
344
|
function isWorkbookSheetProtection(value) {
|
|
334
|
-
return isRecord(value) && hasString(value, 'sheetName') && isOptionalBoolean(value
|
|
345
|
+
return isRecord(value) && hasString(value, 'sheetName') && isOptionalBoolean(ownValue(value, 'hideFormulas'));
|
|
335
346
|
}
|
|
336
347
|
function isWorkbookRangeProtection(value) {
|
|
337
|
-
return isRecord(value) &&
|
|
348
|
+
return (isRecord(value) &&
|
|
349
|
+
hasString(value, 'id') &&
|
|
350
|
+
isCellRangeRef(ownValue(value, 'range')) &&
|
|
351
|
+
isOptionalBoolean(ownValue(value, 'hideFormulas')));
|
|
338
352
|
}
|
|
339
353
|
function isWorkbookCommentEntry(value) {
|
|
340
354
|
return (isRecord(value) &&
|
|
341
355
|
hasString(value, 'id') &&
|
|
342
356
|
hasString(value, 'body') &&
|
|
343
|
-
isOptionalString(value
|
|
344
|
-
isOptionalString(value
|
|
345
|
-
isOptionalSafeNonNegativeInteger(value
|
|
357
|
+
isOptionalString(ownValue(value, 'authorUserId')) &&
|
|
358
|
+
isOptionalString(ownValue(value, 'authorDisplayName')) &&
|
|
359
|
+
isOptionalSafeNonNegativeInteger(ownValue(value, 'createdAtUnixMs')));
|
|
346
360
|
}
|
|
347
361
|
function isWorkbookCommentThread(value) {
|
|
348
362
|
return (isRecord(value) &&
|
|
349
363
|
hasString(value, 'threadId') &&
|
|
350
364
|
hasString(value, 'sheetName') &&
|
|
351
365
|
hasString(value, 'address') &&
|
|
352
|
-
|
|
353
|
-
value
|
|
354
|
-
value
|
|
355
|
-
|
|
356
|
-
isOptionalString(value['resolvedByUserId']) &&
|
|
357
|
-
isOptionalSafeNonNegativeInteger(value['resolvedAtUnixMs']));
|
|
366
|
+
nonEmptyArrayEvery(ownValue(value, 'comments'), isWorkbookCommentEntry) &&
|
|
367
|
+
isOptionalBoolean(ownValue(value, 'resolved')) &&
|
|
368
|
+
isOptionalString(ownValue(value, 'resolvedByUserId')) &&
|
|
369
|
+
isOptionalSafeNonNegativeInteger(ownValue(value, 'resolvedAtUnixMs')));
|
|
358
370
|
}
|
|
359
371
|
function isWorkbookNote(value) {
|
|
360
372
|
return isRecord(value) && hasString(value, 'sheetName') && hasString(value, 'address') && hasString(value, 'text');
|
|
@@ -364,19 +376,19 @@ function isWorkbookHyperlink(value) {
|
|
|
364
376
|
hasString(value, 'sheetName') &&
|
|
365
377
|
hasString(value, 'address') &&
|
|
366
378
|
hasString(value, 'target') &&
|
|
367
|
-
isOptionalString(value
|
|
368
|
-
isOptionalString(value
|
|
379
|
+
isOptionalString(ownValue(value, 'tooltip')) &&
|
|
380
|
+
isOptionalString(ownValue(value, 'display')));
|
|
369
381
|
}
|
|
370
382
|
function isWorkbookDefinedNameValue(value) {
|
|
371
383
|
if (isLiteralInput(value)) {
|
|
372
384
|
return true;
|
|
373
385
|
}
|
|
374
|
-
if (!isRecord(value) || typeof value
|
|
386
|
+
if (!isRecord(value) || typeof ownValue(value, 'kind') !== 'string') {
|
|
375
387
|
return false;
|
|
376
388
|
}
|
|
377
|
-
switch (value
|
|
389
|
+
switch (ownValue(value, 'kind')) {
|
|
378
390
|
case 'scalar':
|
|
379
|
-
return isLiteralInput(value
|
|
391
|
+
return isLiteralInput(ownValue(value, 'value'));
|
|
380
392
|
case 'cell-ref':
|
|
381
393
|
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
382
394
|
case 'range-ref':
|
|
@@ -395,37 +407,35 @@ function isWorkbookTableOp(value) {
|
|
|
395
407
|
hasString(value, 'sheetName') &&
|
|
396
408
|
hasString(value, 'startAddress') &&
|
|
397
409
|
hasString(value, 'endAddress') &&
|
|
398
|
-
isStringArray(value
|
|
399
|
-
typeof value
|
|
400
|
-
typeof value
|
|
401
|
-
(value
|
|
402
|
-
(value
|
|
403
|
-
(value
|
|
404
|
-
isOptionalString(value
|
|
410
|
+
isStringArray(ownValue(value, 'columnNames')) &&
|
|
411
|
+
typeof ownValue(value, 'headerRow') === 'boolean' &&
|
|
412
|
+
typeof ownValue(value, 'totalsRow') === 'boolean' &&
|
|
413
|
+
(ownValue(value, 'columns') === undefined || isWorkbookTableColumns(ownValue(value, 'columns'))) &&
|
|
414
|
+
(ownValue(value, 'style') === undefined || isWorkbookTableStyle(ownValue(value, 'style'))) &&
|
|
415
|
+
(ownValue(value, 'autoFilter') === undefined || isCellRangeRef(ownValue(value, 'autoFilter'))) &&
|
|
416
|
+
isOptionalString(ownValue(value, 'sortState')));
|
|
405
417
|
}
|
|
406
418
|
function isWorkbookTableColumns(value) {
|
|
407
|
-
return (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
isOptionalString(entry['totalsRowFormula'])));
|
|
419
|
+
return arrayEvery(value, (entry) => isRecord(entry) &&
|
|
420
|
+
hasString(entry, 'name') &&
|
|
421
|
+
isOptionalString(ownValue(entry, 'calculatedColumnFormula')) &&
|
|
422
|
+
isOptionalString(ownValue(entry, 'totalsRowLabel')) &&
|
|
423
|
+
isOptionalString(ownValue(entry, 'totalsRowFunction')) &&
|
|
424
|
+
isOptionalString(ownValue(entry, 'totalsRowFormula')));
|
|
414
425
|
}
|
|
415
426
|
function isWorkbookTableStyle(value) {
|
|
416
427
|
return (isRecord(value) &&
|
|
417
|
-
isOptionalString(value
|
|
418
|
-
isOptionalBoolean(value
|
|
419
|
-
isOptionalBoolean(value
|
|
420
|
-
isOptionalBoolean(value
|
|
421
|
-
isOptionalBoolean(value
|
|
428
|
+
isOptionalString(ownValue(value, 'name')) &&
|
|
429
|
+
isOptionalBoolean(ownValue(value, 'showFirstColumn')) &&
|
|
430
|
+
isOptionalBoolean(ownValue(value, 'showLastColumn')) &&
|
|
431
|
+
isOptionalBoolean(ownValue(value, 'showRowStripes')) &&
|
|
432
|
+
isOptionalBoolean(ownValue(value, 'showColumnStripes')));
|
|
422
433
|
}
|
|
423
434
|
function isWorkbookPivotValue(value) {
|
|
424
435
|
return (isRecord(value) &&
|
|
425
436
|
hasString(value, 'sourceColumn') &&
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
isOptionalString(value['outputLabel']));
|
|
437
|
+
stringSetHas(PIVOT_AGGREGATION_VALUES, ownValue(value, 'summarizeBy')) &&
|
|
438
|
+
isOptionalString(ownValue(value, 'outputLabel')));
|
|
429
439
|
}
|
|
430
440
|
const CHART_TYPE_VALUES = new Set(['column', 'bar', 'line', 'area', 'pie', 'scatter']);
|
|
431
441
|
const CHART_SERIES_ORIENTATION_VALUES = new Set(['rows', 'columns']);
|
|
@@ -436,8 +446,8 @@ function isDrawingAnchorMarker(value) {
|
|
|
436
446
|
return (isRecord(value) &&
|
|
437
447
|
hasSafeNonNegativeInteger(value, 'row') &&
|
|
438
448
|
hasSafeNonNegativeInteger(value, 'col') &&
|
|
439
|
-
isOptionalSafeNonNegativeInteger(value
|
|
440
|
-
isOptionalSafeNonNegativeInteger(value
|
|
449
|
+
isOptionalSafeNonNegativeInteger(ownValue(value, 'rowOffset')) &&
|
|
450
|
+
isOptionalSafeNonNegativeInteger(ownValue(value, 'colOffset')));
|
|
441
451
|
}
|
|
442
452
|
function isDrawingAnchorExtent(value) {
|
|
443
453
|
return isRecord(value) && hasSafePositiveInteger(value, 'width') && hasSafePositiveInteger(value, 'height');
|
|
@@ -446,18 +456,18 @@ function isDrawingAnchorPosition(value) {
|
|
|
446
456
|
return isRecord(value) && hasSafeNonNegativeInteger(value, 'x') && hasSafeNonNegativeInteger(value, 'y');
|
|
447
457
|
}
|
|
448
458
|
function isWorkbookChartAnchor(value) {
|
|
449
|
-
if (!isRecord(value) || typeof value
|
|
459
|
+
if (!isRecord(value) || typeof ownValue(value, 'kind') !== 'string') {
|
|
450
460
|
return false;
|
|
451
461
|
}
|
|
452
|
-
switch (value
|
|
462
|
+
switch (ownValue(value, 'kind')) {
|
|
453
463
|
case 'twoCell':
|
|
454
|
-
return ((value
|
|
455
|
-
isDrawingAnchorMarker(value
|
|
456
|
-
isDrawingAnchorMarker(value
|
|
464
|
+
return ((ownValue(value, 'editAs') === undefined || stringSetHas(DRAWING_ANCHOR_EDIT_AS_VALUES, ownValue(value, 'editAs'))) &&
|
|
465
|
+
isDrawingAnchorMarker(ownValue(value, 'from')) &&
|
|
466
|
+
isDrawingAnchorMarker(ownValue(value, 'to')));
|
|
457
467
|
case 'oneCell':
|
|
458
|
-
return isDrawingAnchorMarker(value
|
|
468
|
+
return isDrawingAnchorMarker(ownValue(value, 'from')) && isDrawingAnchorExtent(ownValue(value, 'extent'));
|
|
459
469
|
case 'absolute':
|
|
460
|
-
return isDrawingAnchorPosition(value
|
|
470
|
+
return isDrawingAnchorPosition(ownValue(value, 'position')) && isDrawingAnchorExtent(ownValue(value, 'extent'));
|
|
461
471
|
default:
|
|
462
472
|
return false;
|
|
463
473
|
}
|
|
@@ -467,17 +477,15 @@ function isWorkbookChart(value) {
|
|
|
467
477
|
hasString(value, 'id') &&
|
|
468
478
|
hasString(value, 'sheetName') &&
|
|
469
479
|
hasString(value, 'address') &&
|
|
470
|
-
isCellRangeRef(value
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
(value
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
isOptionalBoolean(value
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
(value['legendPosition'] === undefined ||
|
|
480
|
-
(typeof value['legendPosition'] === 'string' && CHART_LEGEND_POSITION_VALUES.has(value['legendPosition']))) &&
|
|
480
|
+
isCellRangeRef(ownValue(value, 'source')) &&
|
|
481
|
+
stringSetHas(CHART_TYPE_VALUES, ownValue(value, 'chartType')) &&
|
|
482
|
+
(ownValue(value, 'anchor') === undefined || isWorkbookChartAnchor(ownValue(value, 'anchor'))) &&
|
|
483
|
+
(ownValue(value, 'seriesOrientation') === undefined ||
|
|
484
|
+
stringSetHas(CHART_SERIES_ORIENTATION_VALUES, ownValue(value, 'seriesOrientation'))) &&
|
|
485
|
+
isOptionalBoolean(ownValue(value, 'firstRowAsHeaders')) &&
|
|
486
|
+
isOptionalBoolean(ownValue(value, 'firstColumnAsLabels')) &&
|
|
487
|
+
isOptionalString(ownValue(value, 'title')) &&
|
|
488
|
+
(ownValue(value, 'legendPosition') === undefined || stringSetHas(CHART_LEGEND_POSITION_VALUES, ownValue(value, 'legendPosition'))) &&
|
|
481
489
|
hasSafePositiveInteger(value, 'rows') &&
|
|
482
490
|
hasSafePositiveInteger(value, 'cols'));
|
|
483
491
|
}
|
|
@@ -489,36 +497,35 @@ function isWorkbookImage(value) {
|
|
|
489
497
|
hasString(value, 'sourceUrl') &&
|
|
490
498
|
hasSafePositiveInteger(value, 'rows') &&
|
|
491
499
|
hasSafePositiveInteger(value, 'cols') &&
|
|
492
|
-
isOptionalString(value
|
|
500
|
+
isOptionalString(ownValue(value, 'altText')));
|
|
493
501
|
}
|
|
494
502
|
function isWorkbookShape(value) {
|
|
495
503
|
return (isRecord(value) &&
|
|
496
504
|
hasString(value, 'id') &&
|
|
497
505
|
hasString(value, 'sheetName') &&
|
|
498
506
|
hasString(value, 'address') &&
|
|
499
|
-
|
|
500
|
-
SHAPE_TYPE_VALUES.has(value['shapeType']) &&
|
|
507
|
+
stringSetHas(SHAPE_TYPE_VALUES, ownValue(value, 'shapeType')) &&
|
|
501
508
|
hasSafePositiveInteger(value, 'rows') &&
|
|
502
509
|
hasSafePositiveInteger(value, 'cols') &&
|
|
503
|
-
isOptionalString(value
|
|
504
|
-
isOptionalString(value
|
|
505
|
-
isOptionalString(value
|
|
510
|
+
isOptionalString(ownValue(value, 'text')) &&
|
|
511
|
+
isOptionalString(ownValue(value, 'fillColor')) &&
|
|
512
|
+
isOptionalString(ownValue(value, 'strokeColor')));
|
|
506
513
|
}
|
|
507
514
|
export function isWorkbookOp(value) {
|
|
508
|
-
if (!isRecord(value) || typeof value
|
|
515
|
+
if (!isRecord(value) || typeof ownValue(value, 'kind') !== 'string') {
|
|
509
516
|
return false;
|
|
510
517
|
}
|
|
511
|
-
switch (value
|
|
518
|
+
switch (ownValue(value, 'kind')) {
|
|
512
519
|
case 'upsertWorkbook':
|
|
513
520
|
return hasString(value, 'name');
|
|
514
521
|
case 'setWorkbookMetadata':
|
|
515
|
-
return hasString(value, 'key') && isLiteralInput(value
|
|
522
|
+
return hasString(value, 'key') && isLiteralInput(ownValue(value, 'value'));
|
|
516
523
|
case 'setCalculationSettings':
|
|
517
|
-
return isWorkbookCalculationSettings(value
|
|
524
|
+
return isWorkbookCalculationSettings(ownValue(value, 'settings'));
|
|
518
525
|
case 'setVolatileContext':
|
|
519
|
-
return isWorkbookVolatileContext(value
|
|
526
|
+
return isWorkbookVolatileContext(ownValue(value, 'context'));
|
|
520
527
|
case 'upsertSheet':
|
|
521
|
-
return hasString(value, 'name') && hasSafeNonNegativeInteger(value, 'order') && isOptionalSafePositiveInteger(value
|
|
528
|
+
return hasString(value, 'name') && hasSafeNonNegativeInteger(value, 'order') && isOptionalSafePositiveInteger(ownValue(value, 'id'));
|
|
522
529
|
case 'renameSheet':
|
|
523
530
|
return hasString(value, 'oldName') && hasString(value, 'newName');
|
|
524
531
|
case 'deleteSheet':
|
|
@@ -528,8 +535,7 @@ export function isWorkbookOp(value) {
|
|
|
528
535
|
return (hasString(value, 'sheetName') &&
|
|
529
536
|
hasSafeNonNegativeInteger(value, 'start') &&
|
|
530
537
|
hasSafePositiveInteger(value, 'count') &&
|
|
531
|
-
(value
|
|
532
|
-
(Array.isArray(value['entries']) && value['entries'].every((entry) => isWorkbookAxisEntry(entry)))));
|
|
538
|
+
(ownValue(value, 'entries') === undefined || arrayEvery(ownValue(value, 'entries'), isWorkbookAxisEntry)));
|
|
533
539
|
case 'deleteRows':
|
|
534
540
|
case 'deleteColumns':
|
|
535
541
|
return hasString(value, 'sheetName') && hasSafeNonNegativeInteger(value, 'start') && hasSafePositiveInteger(value, 'count');
|
|
@@ -544,81 +550,80 @@ export function isWorkbookOp(value) {
|
|
|
544
550
|
return (hasString(value, 'sheetName') &&
|
|
545
551
|
hasSafeNonNegativeInteger(value, 'start') &&
|
|
546
552
|
hasSafePositiveInteger(value, 'count') &&
|
|
547
|
-
isOptionalNullableSafePositiveInteger(value
|
|
548
|
-
isOptionalNullableBoolean(value
|
|
549
|
-
isOptionalNullableBoolean(value
|
|
553
|
+
isOptionalNullableSafePositiveInteger(ownValue(value, 'size')) &&
|
|
554
|
+
isOptionalNullableBoolean(ownValue(value, 'hidden')) &&
|
|
555
|
+
isOptionalNullableBoolean(ownValue(value, 'filterHidden')));
|
|
550
556
|
case 'setFreezePane':
|
|
551
557
|
return hasString(value, 'sheetName') && hasSafeNonNegativeInteger(value, 'rows') && hasSafeNonNegativeInteger(value, 'cols');
|
|
552
558
|
case 'clearFreezePane':
|
|
553
559
|
return hasString(value, 'sheetName');
|
|
554
560
|
case 'mergeCells':
|
|
555
561
|
case 'unmergeCells':
|
|
556
|
-
return isCellRangeRef(value
|
|
562
|
+
return isCellRangeRef(ownValue(value, 'range'));
|
|
557
563
|
case 'setSheetProtection':
|
|
558
|
-
return isWorkbookSheetProtection(value
|
|
564
|
+
return isWorkbookSheetProtection(ownValue(value, 'protection'));
|
|
559
565
|
case 'clearSheetProtection':
|
|
560
566
|
return hasString(value, 'sheetName');
|
|
561
567
|
case 'setFilter':
|
|
562
568
|
case 'clearFilter':
|
|
563
569
|
case 'clearSort':
|
|
564
|
-
return hasString(value, 'sheetName') && isCellRangeRef(value
|
|
570
|
+
return hasString(value, 'sheetName') && isCellRangeRef(ownValue(value, 'range'));
|
|
565
571
|
case 'setSort':
|
|
566
|
-
return (hasString(value, 'sheetName') &&
|
|
567
|
-
isCellRangeRef(value['range']) &&
|
|
568
|
-
Array.isArray(value['keys']) &&
|
|
569
|
-
value['keys'].every((entry) => isWorkbookSortKey(entry)));
|
|
572
|
+
return (hasString(value, 'sheetName') && isCellRangeRef(ownValue(value, 'range')) && arrayEvery(ownValue(value, 'keys'), isWorkbookSortKey));
|
|
570
573
|
case 'setDataValidation':
|
|
571
|
-
return isWorkbookDataValidation(value
|
|
574
|
+
return isWorkbookDataValidation(ownValue(value, 'validation'));
|
|
572
575
|
case 'clearDataValidation':
|
|
573
|
-
return hasString(value, 'sheetName') && isCellRangeRef(value
|
|
576
|
+
return hasString(value, 'sheetName') && isCellRangeRef(ownValue(value, 'range'));
|
|
574
577
|
case 'upsertConditionalFormat':
|
|
575
|
-
return isWorkbookConditionalFormat(value
|
|
578
|
+
return isWorkbookConditionalFormat(ownValue(value, 'format'));
|
|
576
579
|
case 'deleteConditionalFormat':
|
|
577
580
|
return hasString(value, 'id') && hasString(value, 'sheetName');
|
|
578
581
|
case 'setConditionalFormatArtifacts':
|
|
579
|
-
return hasString(value, 'sheetName') && isConditionalFormatArtifacts(value
|
|
582
|
+
return hasString(value, 'sheetName') && isConditionalFormatArtifacts(ownValue(value, 'artifacts'));
|
|
580
583
|
case 'clearConditionalFormatArtifacts':
|
|
581
584
|
return hasString(value, 'sheetName');
|
|
582
585
|
case 'upsertRangeProtection':
|
|
583
|
-
return isWorkbookRangeProtection(value
|
|
586
|
+
return isWorkbookRangeProtection(ownValue(value, 'protection'));
|
|
584
587
|
case 'deleteRangeProtection':
|
|
585
588
|
return hasString(value, 'id') && hasString(value, 'sheetName');
|
|
586
589
|
case 'upsertCommentThread':
|
|
587
|
-
return isWorkbookCommentThread(value
|
|
590
|
+
return isWorkbookCommentThread(ownValue(value, 'thread'));
|
|
588
591
|
case 'deleteCommentThread':
|
|
589
592
|
case 'deleteNote':
|
|
590
593
|
case 'deleteHyperlink':
|
|
591
594
|
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
592
595
|
case 'upsertNote':
|
|
593
|
-
return isWorkbookNote(value
|
|
596
|
+
return isWorkbookNote(ownValue(value, 'note'));
|
|
594
597
|
case 'upsertHyperlink':
|
|
595
|
-
return isWorkbookHyperlink(value
|
|
598
|
+
return isWorkbookHyperlink(ownValue(value, 'hyperlink'));
|
|
596
599
|
case 'setCellValue':
|
|
597
600
|
return (hasString(value, 'sheetName') &&
|
|
598
601
|
hasString(value, 'address') &&
|
|
599
|
-
isLiteralInput(value
|
|
600
|
-
(value
|
|
602
|
+
isLiteralInput(ownValue(value, 'value')) &&
|
|
603
|
+
(ownValue(value, 'authoredBlank') === undefined || typeof ownValue(value, 'authoredBlank') === 'boolean'));
|
|
601
604
|
case 'setCellFormula':
|
|
602
605
|
return hasString(value, 'sheetName') && hasString(value, 'address') && hasString(value, 'formula');
|
|
603
606
|
case 'setCellFormat':
|
|
604
|
-
return (hasString(value, 'sheetName') &&
|
|
607
|
+
return (hasString(value, 'sheetName') &&
|
|
608
|
+
hasString(value, 'address') &&
|
|
609
|
+
(ownValue(value, 'format') === null || typeof ownValue(value, 'format') === 'string'));
|
|
605
610
|
case 'upsertCellStyle':
|
|
606
|
-
return isCellStyleRecord(value
|
|
611
|
+
return isCellStyleRecord(ownValue(value, 'style'));
|
|
607
612
|
case 'upsertCellNumberFormat':
|
|
608
|
-
return isCellNumberFormatRecord(value
|
|
613
|
+
return isCellNumberFormatRecord(ownValue(value, 'format'));
|
|
609
614
|
case 'setStyleRange':
|
|
610
|
-
return isCellRangeRef(value
|
|
615
|
+
return isCellRangeRef(ownValue(value, 'range')) && hasString(value, 'styleId');
|
|
611
616
|
case 'setFormatRange':
|
|
612
|
-
return isCellRangeRef(value
|
|
617
|
+
return isCellRangeRef(ownValue(value, 'range')) && hasString(value, 'formatId');
|
|
613
618
|
case 'clearCell':
|
|
614
619
|
return hasString(value, 'sheetName') && hasString(value, 'address');
|
|
615
620
|
case 'upsertDefinedName':
|
|
616
|
-
return hasString(value, 'name') && isWorkbookDefinedNameValue(value
|
|
621
|
+
return hasString(value, 'name') && isWorkbookDefinedNameValue(ownValue(value, 'value'));
|
|
617
622
|
case 'deleteDefinedName':
|
|
618
623
|
case 'deleteTable':
|
|
619
624
|
return hasString(value, 'name');
|
|
620
625
|
case 'upsertTable':
|
|
621
|
-
return isWorkbookTableOp(value
|
|
626
|
+
return isWorkbookTableOp(ownValue(value, 'table'));
|
|
622
627
|
case 'upsertSpillRange':
|
|
623
628
|
return (hasString(value, 'sheetName') &&
|
|
624
629
|
hasString(value, 'address') &&
|
|
@@ -631,22 +636,21 @@ export function isWorkbookOp(value) {
|
|
|
631
636
|
return (hasString(value, 'name') &&
|
|
632
637
|
hasString(value, 'sheetName') &&
|
|
633
638
|
hasString(value, 'address') &&
|
|
634
|
-
isCellRangeRef(value
|
|
635
|
-
isStringArray(value
|
|
636
|
-
|
|
637
|
-
value['values'].every((entry) => isWorkbookPivotValue(entry)) &&
|
|
639
|
+
isCellRangeRef(ownValue(value, 'source')) &&
|
|
640
|
+
isStringArray(ownValue(value, 'groupBy')) &&
|
|
641
|
+
arrayEvery(ownValue(value, 'values'), isWorkbookPivotValue) &&
|
|
638
642
|
hasSafePositiveInteger(value, 'rows') &&
|
|
639
643
|
hasSafePositiveInteger(value, 'cols'));
|
|
640
644
|
case 'upsertChart':
|
|
641
|
-
return isWorkbookChart(value
|
|
645
|
+
return isWorkbookChart(ownValue(value, 'chart'));
|
|
642
646
|
case 'deleteChart':
|
|
643
647
|
return hasString(value, 'id');
|
|
644
648
|
case 'upsertImage':
|
|
645
|
-
return isWorkbookImage(value
|
|
649
|
+
return isWorkbookImage(ownValue(value, 'image'));
|
|
646
650
|
case 'deleteImage':
|
|
647
651
|
return hasString(value, 'id');
|
|
648
652
|
case 'upsertShape':
|
|
649
|
-
return isWorkbookShape(value
|
|
653
|
+
return isWorkbookShape(ownValue(value, 'shape'));
|
|
650
654
|
case 'deleteShape':
|
|
651
655
|
return hasString(value, 'id');
|
|
652
656
|
default:
|
|
@@ -657,14 +661,17 @@ export function isEngineOp(value) {
|
|
|
657
661
|
return isWorkbookOp(value);
|
|
658
662
|
}
|
|
659
663
|
export function isEngineOps(value) {
|
|
660
|
-
return
|
|
664
|
+
return arrayEvery(value, isEngineOp);
|
|
661
665
|
}
|
|
662
666
|
export function isEngineOpBatch(value) {
|
|
663
|
-
|
|
664
|
-
|
|
667
|
+
if (!isRecord(value)) {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
const clock = ownValue(value, 'clock');
|
|
671
|
+
return (hasString(value, 'id') &&
|
|
665
672
|
hasString(value, 'replicaId') &&
|
|
666
|
-
isRecord(
|
|
667
|
-
hasSafeNonNegativeInteger(
|
|
668
|
-
isEngineOps(value
|
|
673
|
+
isRecord(clock) &&
|
|
674
|
+
hasSafeNonNegativeInteger(clock, 'counter') &&
|
|
675
|
+
isEngineOps(ownValue(value, 'ops')));
|
|
669
676
|
}
|
|
670
677
|
//# sourceMappingURL=guards.js.map
|