@routevn/creator-model 1.1.9 → 1.1.11
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/package.json +1 -1
- package/src/model.js +565 -73
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -1141,7 +1141,12 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
|
|
|
1141
1141
|
}
|
|
1142
1142
|
};
|
|
1143
1143
|
|
|
1144
|
-
const validateTweenProperty = ({
|
|
1144
|
+
const validateTweenProperty = ({
|
|
1145
|
+
config,
|
|
1146
|
+
path,
|
|
1147
|
+
allowEmptyKeyframes = false,
|
|
1148
|
+
errorFactory,
|
|
1149
|
+
}) => {
|
|
1145
1150
|
{
|
|
1146
1151
|
const result = validateAllowedKeys({
|
|
1147
1152
|
value: config,
|
|
@@ -1181,6 +1186,13 @@ const validateTweenProperty = ({ config, path, errorFactory }) => {
|
|
|
1181
1186
|
return result;
|
|
1182
1187
|
}
|
|
1183
1188
|
}
|
|
1189
|
+
|
|
1190
|
+
if (!allowEmptyKeyframes && config.keyframes.length === 0) {
|
|
1191
|
+
return invalidFromErrorFactory(
|
|
1192
|
+
errorFactory,
|
|
1193
|
+
`${path}.keyframes must contain at least one keyframe`,
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1184
1196
|
};
|
|
1185
1197
|
|
|
1186
1198
|
const validateTweenDefinition = ({
|
|
@@ -1188,6 +1200,7 @@ const validateTweenDefinition = ({
|
|
|
1188
1200
|
allowedProperties,
|
|
1189
1201
|
path,
|
|
1190
1202
|
unsupportedMessage,
|
|
1203
|
+
allowEmptyKeyframes = false,
|
|
1191
1204
|
errorFactory,
|
|
1192
1205
|
}) => {
|
|
1193
1206
|
if (!isPlainObject(tween)) {
|
|
@@ -1215,6 +1228,7 @@ const validateTweenDefinition = ({
|
|
|
1215
1228
|
const result = validateTweenProperty({
|
|
1216
1229
|
config,
|
|
1217
1230
|
path: propertyPath,
|
|
1231
|
+
allowEmptyKeyframes,
|
|
1218
1232
|
errorFactory,
|
|
1219
1233
|
});
|
|
1220
1234
|
if (result?.valid === false) {
|
|
@@ -1230,6 +1244,8 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1230
1244
|
value: mask,
|
|
1231
1245
|
allowedKeys: [
|
|
1232
1246
|
"kind",
|
|
1247
|
+
"imageId",
|
|
1248
|
+
"imageIds",
|
|
1233
1249
|
"texture",
|
|
1234
1250
|
"textures",
|
|
1235
1251
|
"items",
|
|
@@ -1239,6 +1255,8 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1239
1255
|
"invert",
|
|
1240
1256
|
"sample",
|
|
1241
1257
|
"progress",
|
|
1258
|
+
"progressDuration",
|
|
1259
|
+
"progressEasing",
|
|
1242
1260
|
],
|
|
1243
1261
|
path,
|
|
1244
1262
|
errorFactory,
|
|
@@ -1273,6 +1291,13 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1273
1291
|
);
|
|
1274
1292
|
}
|
|
1275
1293
|
|
|
1294
|
+
if (mask.imageId !== undefined && !isNonEmptyString(mask.imageId)) {
|
|
1295
|
+
return invalidFromErrorFactory(
|
|
1296
|
+
errorFactory,
|
|
1297
|
+
`${path}.imageId must be a non-empty string when provided`,
|
|
1298
|
+
);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1276
1301
|
if (mask.textures !== undefined) {
|
|
1277
1302
|
if (!Array.isArray(mask.textures) || mask.textures.length === 0) {
|
|
1278
1303
|
return invalidFromErrorFactory(
|
|
@@ -1291,6 +1316,24 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1291
1316
|
}
|
|
1292
1317
|
}
|
|
1293
1318
|
|
|
1319
|
+
if (mask.imageIds !== undefined) {
|
|
1320
|
+
if (!Array.isArray(mask.imageIds) || mask.imageIds.length === 0) {
|
|
1321
|
+
return invalidFromErrorFactory(
|
|
1322
|
+
errorFactory,
|
|
1323
|
+
`${path}.imageIds must be a non-empty array when provided`,
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
for (const [index, imageId] of mask.imageIds.entries()) {
|
|
1328
|
+
if (!isNonEmptyString(imageId)) {
|
|
1329
|
+
return invalidFromErrorFactory(
|
|
1330
|
+
errorFactory,
|
|
1331
|
+
`${path}.imageIds[${index}] must be a non-empty string`,
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1294
1337
|
if (mask.items !== undefined) {
|
|
1295
1338
|
if (!Array.isArray(mask.items) || mask.items.length === 0) {
|
|
1296
1339
|
return invalidFromErrorFactory(
|
|
@@ -1305,7 +1348,7 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1305
1348
|
{
|
|
1306
1349
|
const result = validateAllowedKeys({
|
|
1307
1350
|
value: item,
|
|
1308
|
-
allowedKeys: ["texture", "channel", "invert"],
|
|
1351
|
+
allowedKeys: ["texture", "imageId", "channel", "invert"],
|
|
1309
1352
|
path: itemPath,
|
|
1310
1353
|
errorFactory,
|
|
1311
1354
|
});
|
|
@@ -1314,10 +1357,33 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1314
1357
|
}
|
|
1315
1358
|
}
|
|
1316
1359
|
|
|
1317
|
-
if (
|
|
1360
|
+
if (
|
|
1361
|
+
item.texture !== undefined &&
|
|
1362
|
+
!isNonEmptyString(item.texture)
|
|
1363
|
+
) {
|
|
1318
1364
|
return invalidFromErrorFactory(
|
|
1319
1365
|
errorFactory,
|
|
1320
|
-
`${itemPath}.texture must be a non-empty string`,
|
|
1366
|
+
`${itemPath}.texture must be a non-empty string when provided`,
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
if (
|
|
1371
|
+
item.imageId !== undefined &&
|
|
1372
|
+
!isNonEmptyString(item.imageId)
|
|
1373
|
+
) {
|
|
1374
|
+
return invalidFromErrorFactory(
|
|
1375
|
+
errorFactory,
|
|
1376
|
+
`${itemPath}.imageId must be a non-empty string when provided`,
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
if (
|
|
1381
|
+
!isNonEmptyString(item.texture) &&
|
|
1382
|
+
!isNonEmptyString(item.imageId)
|
|
1383
|
+
) {
|
|
1384
|
+
return invalidFromErrorFactory(
|
|
1385
|
+
errorFactory,
|
|
1386
|
+
`${itemPath} must define texture or imageId`,
|
|
1321
1387
|
);
|
|
1322
1388
|
}
|
|
1323
1389
|
|
|
@@ -1388,17 +1454,45 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1388
1454
|
}
|
|
1389
1455
|
}
|
|
1390
1456
|
|
|
1391
|
-
if (
|
|
1457
|
+
if (
|
|
1458
|
+
mask.progressDuration !== undefined &&
|
|
1459
|
+
(!isFiniteNumber(mask.progressDuration) || mask.progressDuration < 1)
|
|
1460
|
+
) {
|
|
1392
1461
|
return invalidFromErrorFactory(
|
|
1393
1462
|
errorFactory,
|
|
1394
|
-
`${path}.
|
|
1463
|
+
`${path}.progressDuration must be a finite number greater than or equal to 1 when provided`,
|
|
1395
1464
|
);
|
|
1396
1465
|
}
|
|
1397
1466
|
|
|
1398
|
-
if (
|
|
1467
|
+
if (
|
|
1468
|
+
mask.progressEasing !== undefined &&
|
|
1469
|
+
!ANIMATION_EASING_KEYS.includes(mask.progressEasing)
|
|
1470
|
+
) {
|
|
1471
|
+
return invalidFromErrorFactory(
|
|
1472
|
+
errorFactory,
|
|
1473
|
+
`${path}.progressEasing must be a supported Route Graphics easing`,
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
if (
|
|
1478
|
+
mask.kind === "single" &&
|
|
1479
|
+
!isNonEmptyString(mask.texture) &&
|
|
1480
|
+
!isNonEmptyString(mask.imageId)
|
|
1481
|
+
) {
|
|
1482
|
+
return invalidFromErrorFactory(
|
|
1483
|
+
errorFactory,
|
|
1484
|
+
`${path}.texture or ${path}.imageId is required when ${path}.kind is 'single'`,
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
if (
|
|
1489
|
+
mask.kind === "sequence" &&
|
|
1490
|
+
mask.textures === undefined &&
|
|
1491
|
+
mask.imageIds === undefined
|
|
1492
|
+
) {
|
|
1399
1493
|
return invalidFromErrorFactory(
|
|
1400
1494
|
errorFactory,
|
|
1401
|
-
`${path}.textures is required when ${path}.kind is 'sequence'`,
|
|
1495
|
+
`${path}.textures or ${path}.imageIds is required when ${path}.kind is 'sequence'`,
|
|
1402
1496
|
);
|
|
1403
1497
|
}
|
|
1404
1498
|
|
|
@@ -1513,6 +1607,7 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
|
|
|
1513
1607
|
allowedProperties: TRANSITION_TWEEN_PROPERTY_KEYS,
|
|
1514
1608
|
path: `${path}.${side}.tween`,
|
|
1515
1609
|
unsupportedMessage: "is not a supported transition tween property",
|
|
1610
|
+
allowEmptyKeyframes: true,
|
|
1516
1611
|
errorFactory,
|
|
1517
1612
|
});
|
|
1518
1613
|
if (result?.valid === false) {
|
|
@@ -1551,8 +1646,8 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
|
|
|
1551
1646
|
value: item,
|
|
1552
1647
|
allowedKeys:
|
|
1553
1648
|
item.type === "folder"
|
|
1554
|
-
? ["id", "type", "name"]
|
|
1555
|
-
: ["id", "type", "name", "animation"],
|
|
1649
|
+
? ["id", "type", "name", "description"]
|
|
1650
|
+
: ["id", "type", "name", "description", "animation"],
|
|
1556
1651
|
path: itemPath,
|
|
1557
1652
|
errorFactory,
|
|
1558
1653
|
});
|
|
@@ -1582,6 +1677,13 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
|
|
|
1582
1677
|
);
|
|
1583
1678
|
}
|
|
1584
1679
|
|
|
1680
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
1681
|
+
return invalidFromErrorFactory(
|
|
1682
|
+
errorFactory,
|
|
1683
|
+
`${itemPath}.description must be a string when provided`,
|
|
1684
|
+
);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1585
1687
|
if (item.type === "animation") {
|
|
1586
1688
|
{
|
|
1587
1689
|
const result = validateAnimationDefinition({
|
|
@@ -1613,11 +1715,12 @@ const validateFontItems = ({ items, path, errorFactory }) => {
|
|
|
1613
1715
|
value: item,
|
|
1614
1716
|
allowedKeys:
|
|
1615
1717
|
item.type === "folder"
|
|
1616
|
-
? ["id", "type", "name"]
|
|
1718
|
+
? ["id", "type", "name", "description"]
|
|
1617
1719
|
: [
|
|
1618
1720
|
"id",
|
|
1619
1721
|
"type",
|
|
1620
1722
|
"name",
|
|
1723
|
+
"description",
|
|
1621
1724
|
"fileId",
|
|
1622
1725
|
"fontFamily",
|
|
1623
1726
|
"fileType",
|
|
@@ -1652,6 +1755,13 @@ const validateFontItems = ({ items, path, errorFactory }) => {
|
|
|
1652
1755
|
);
|
|
1653
1756
|
}
|
|
1654
1757
|
|
|
1758
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
1759
|
+
return invalidFromErrorFactory(
|
|
1760
|
+
errorFactory,
|
|
1761
|
+
`${itemPath}.description must be a string when provided`,
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1655
1765
|
if (item.type === "font") {
|
|
1656
1766
|
if (!isNonEmptyString(item.fileId)) {
|
|
1657
1767
|
return invalidFromErrorFactory(
|
|
@@ -1700,8 +1810,8 @@ const validateColorItems = ({ items, path, errorFactory }) => {
|
|
|
1700
1810
|
value: item,
|
|
1701
1811
|
allowedKeys:
|
|
1702
1812
|
item.type === "folder"
|
|
1703
|
-
? ["id", "type", "name"]
|
|
1704
|
-
: ["id", "type", "name", "hex"],
|
|
1813
|
+
? ["id", "type", "name", "description"]
|
|
1814
|
+
: ["id", "type", "name", "description", "hex"],
|
|
1705
1815
|
path: itemPath,
|
|
1706
1816
|
errorFactory,
|
|
1707
1817
|
});
|
|
@@ -1731,6 +1841,13 @@ const validateColorItems = ({ items, path, errorFactory }) => {
|
|
|
1731
1841
|
);
|
|
1732
1842
|
}
|
|
1733
1843
|
|
|
1844
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
1845
|
+
return invalidFromErrorFactory(
|
|
1846
|
+
errorFactory,
|
|
1847
|
+
`${itemPath}.description must be a string when provided`,
|
|
1848
|
+
);
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1734
1851
|
if (item.type === "color" && !isHexColor(item.hex)) {
|
|
1735
1852
|
return invalidFromErrorFactory(
|
|
1736
1853
|
errorFactory,
|
|
@@ -1756,11 +1873,12 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
|
|
|
1756
1873
|
value: item,
|
|
1757
1874
|
allowedKeys:
|
|
1758
1875
|
item.type === "folder"
|
|
1759
|
-
? ["id", "type", "name"]
|
|
1876
|
+
? ["id", "type", "name", "description"]
|
|
1760
1877
|
: [
|
|
1761
1878
|
"id",
|
|
1762
1879
|
"type",
|
|
1763
1880
|
"name",
|
|
1881
|
+
"description",
|
|
1764
1882
|
"x",
|
|
1765
1883
|
"y",
|
|
1766
1884
|
"scaleX",
|
|
@@ -1798,6 +1916,13 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
|
|
|
1798
1916
|
);
|
|
1799
1917
|
}
|
|
1800
1918
|
|
|
1919
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
1920
|
+
return invalidFromErrorFactory(
|
|
1921
|
+
errorFactory,
|
|
1922
|
+
`${itemPath}.description must be a string when provided`,
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1801
1926
|
if (item.type === "transform") {
|
|
1802
1927
|
for (const key of [
|
|
1803
1928
|
"x",
|
|
@@ -1861,8 +1986,8 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
|
|
|
1861
1986
|
value: item,
|
|
1862
1987
|
allowedKeys:
|
|
1863
1988
|
variableType === "folder"
|
|
1864
|
-
? ["id", "type", "name"]
|
|
1865
|
-
: ["id", "type", "name", "scope", "default", "value"],
|
|
1989
|
+
? ["id", "type", "name", "description"]
|
|
1990
|
+
: ["id", "type", "name", "description", "scope", "default", "value"],
|
|
1866
1991
|
path: itemPath,
|
|
1867
1992
|
errorFactory,
|
|
1868
1993
|
});
|
|
@@ -1892,6 +2017,13 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
|
|
|
1892
2017
|
);
|
|
1893
2018
|
}
|
|
1894
2019
|
|
|
2020
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
2021
|
+
return invalidFromErrorFactory(
|
|
2022
|
+
errorFactory,
|
|
2023
|
+
`${itemPath}.description must be a string when provided`,
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
1895
2027
|
if (variableType !== "folder") {
|
|
1896
2028
|
if (!VARIABLE_SCOPE_KEYS.includes(item.scope)) {
|
|
1897
2029
|
return invalidFromErrorFactory(
|
|
@@ -1942,11 +2074,12 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
|
1942
2074
|
value: item,
|
|
1943
2075
|
allowedKeys:
|
|
1944
2076
|
item.type === "folder"
|
|
1945
|
-
? ["id", "type", "name"]
|
|
2077
|
+
? ["id", "type", "name", "description"]
|
|
1946
2078
|
: [
|
|
1947
2079
|
"id",
|
|
1948
2080
|
"type",
|
|
1949
2081
|
"name",
|
|
2082
|
+
"description",
|
|
1950
2083
|
"fontId",
|
|
1951
2084
|
"colorId",
|
|
1952
2085
|
"fontSize",
|
|
@@ -1991,6 +2124,13 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
|
1991
2124
|
);
|
|
1992
2125
|
}
|
|
1993
2126
|
|
|
2127
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
2128
|
+
return invalidFromErrorFactory(
|
|
2129
|
+
errorFactory,
|
|
2130
|
+
`${itemPath}.description must be a string when provided`,
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
1994
2134
|
if (item.type === "textStyle") {
|
|
1995
2135
|
if (!isNonEmptyString(item.fontId)) {
|
|
1996
2136
|
return invalidFromErrorFactory(
|
|
@@ -2121,11 +2261,12 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
|
|
|
2121
2261
|
value: item,
|
|
2122
2262
|
allowedKeys:
|
|
2123
2263
|
item.type === "folder"
|
|
2124
|
-
? ["id", "type", "name"]
|
|
2264
|
+
? ["id", "type", "name", "description"]
|
|
2125
2265
|
: [
|
|
2126
2266
|
"id",
|
|
2127
2267
|
"type",
|
|
2128
2268
|
"name",
|
|
2269
|
+
"description",
|
|
2129
2270
|
"thumbnailFileId",
|
|
2130
2271
|
"fileId",
|
|
2131
2272
|
"fileType",
|
|
@@ -2162,6 +2303,13 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
|
|
|
2162
2303
|
);
|
|
2163
2304
|
}
|
|
2164
2305
|
|
|
2306
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
2307
|
+
return invalidFromErrorFactory(
|
|
2308
|
+
errorFactory,
|
|
2309
|
+
`${itemPath}.description must be a string when provided`,
|
|
2310
|
+
);
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2165
2313
|
if (item.type === "image") {
|
|
2166
2314
|
if (
|
|
2167
2315
|
item.thumbnailFileId !== undefined &&
|
|
@@ -2326,6 +2474,7 @@ const validateLayoutElementData = ({
|
|
|
2326
2474
|
"y",
|
|
2327
2475
|
"width",
|
|
2328
2476
|
"height",
|
|
2477
|
+
"aspectRatioLock",
|
|
2329
2478
|
"anchorX",
|
|
2330
2479
|
"anchorY",
|
|
2331
2480
|
"scaleX",
|
|
@@ -2426,6 +2575,16 @@ const validateLayoutElementData = ({
|
|
|
2426
2575
|
}
|
|
2427
2576
|
}
|
|
2428
2577
|
|
|
2578
|
+
if (
|
|
2579
|
+
data.aspectRatioLock !== undefined &&
|
|
2580
|
+
(!isFiniteNumber(data.aspectRatioLock) || data.aspectRatioLock <= 0)
|
|
2581
|
+
) {
|
|
2582
|
+
return invalidFromErrorFactory(
|
|
2583
|
+
errorFactory,
|
|
2584
|
+
`${path}.aspectRatioLock must be a finite number greater than 0 when provided`,
|
|
2585
|
+
);
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2429
2588
|
if (
|
|
2430
2589
|
data.initialValue !== undefined &&
|
|
2431
2590
|
!isFiniteNumber(data.initialValue) &&
|
|
@@ -2811,6 +2970,7 @@ const validateLayoutElementItems = ({ items, path, errorFactory }) => {
|
|
|
2811
2970
|
"y",
|
|
2812
2971
|
"width",
|
|
2813
2972
|
"height",
|
|
2973
|
+
"aspectRatioLock",
|
|
2814
2974
|
"anchorX",
|
|
2815
2975
|
"anchorY",
|
|
2816
2976
|
"scaleX",
|
|
@@ -2907,7 +3067,7 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
2907
3067
|
value: item,
|
|
2908
3068
|
allowedKeys:
|
|
2909
3069
|
item.type === "folder"
|
|
2910
|
-
? ["id", "type", "name"]
|
|
3070
|
+
? ["id", "type", "name", "description"]
|
|
2911
3071
|
: [
|
|
2912
3072
|
"id",
|
|
2913
3073
|
"type",
|
|
@@ -2948,14 +3108,14 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
2948
3108
|
);
|
|
2949
3109
|
}
|
|
2950
3110
|
|
|
2951
|
-
if (item.
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
}
|
|
3111
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
3112
|
+
return invalidFromErrorFactory(
|
|
3113
|
+
errorFactory,
|
|
3114
|
+
`${itemPath}.description must be a string when provided`,
|
|
3115
|
+
);
|
|
3116
|
+
}
|
|
2958
3117
|
|
|
3118
|
+
if (item.type === "character") {
|
|
2959
3119
|
if (item.shortcut !== undefined && !isString(item.shortcut)) {
|
|
2960
3120
|
return invalidFromErrorFactory(
|
|
2961
3121
|
errorFactory,
|
|
@@ -3048,7 +3208,7 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
|
|
|
3048
3208
|
value: item,
|
|
3049
3209
|
allowedKeys:
|
|
3050
3210
|
item.type === "folder"
|
|
3051
|
-
? ["id", "type", "name"]
|
|
3211
|
+
? ["id", "type", "name", "description"]
|
|
3052
3212
|
: [
|
|
3053
3213
|
"id",
|
|
3054
3214
|
"type",
|
|
@@ -3155,8 +3315,16 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
3155
3315
|
value: item,
|
|
3156
3316
|
allowedKeys:
|
|
3157
3317
|
item.type === "folder"
|
|
3158
|
-
? ["id", "type", "name"]
|
|
3159
|
-
: [
|
|
3318
|
+
? ["id", "type", "name", "description"]
|
|
3319
|
+
: [
|
|
3320
|
+
"id",
|
|
3321
|
+
"type",
|
|
3322
|
+
"name",
|
|
3323
|
+
"description",
|
|
3324
|
+
"thumbnailFileId",
|
|
3325
|
+
"elements",
|
|
3326
|
+
"keyboard",
|
|
3327
|
+
],
|
|
3160
3328
|
path: itemPath,
|
|
3161
3329
|
errorFactory,
|
|
3162
3330
|
});
|
|
@@ -3186,6 +3354,13 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
3186
3354
|
);
|
|
3187
3355
|
}
|
|
3188
3356
|
|
|
3357
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
3358
|
+
return invalidFromErrorFactory(
|
|
3359
|
+
errorFactory,
|
|
3360
|
+
`${itemPath}.description must be a string when provided`,
|
|
3361
|
+
);
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3189
3364
|
if (
|
|
3190
3365
|
item.thumbnailFileId !== undefined &&
|
|
3191
3366
|
!isNonEmptyString(item.thumbnailFileId)
|
|
@@ -3996,6 +4171,108 @@ const validateFileReference = ({
|
|
|
3996
4171
|
return VALID_RESULT;
|
|
3997
4172
|
};
|
|
3998
4173
|
|
|
4174
|
+
const validateImageReference = ({
|
|
4175
|
+
state,
|
|
4176
|
+
imageId,
|
|
4177
|
+
path,
|
|
4178
|
+
details = {},
|
|
4179
|
+
errorFactory = createPreconditionValidationError,
|
|
4180
|
+
}) => {
|
|
4181
|
+
if (imageId === undefined || imageId === null) {
|
|
4182
|
+
return VALID_RESULT;
|
|
4183
|
+
}
|
|
4184
|
+
|
|
4185
|
+
const image = state.images?.items?.[imageId];
|
|
4186
|
+
if (!isPlainObject(image) || image.type === "folder") {
|
|
4187
|
+
return invalidFromErrorFactory(
|
|
4188
|
+
errorFactory,
|
|
4189
|
+
`${path} must reference an existing non-folder image`,
|
|
4190
|
+
details,
|
|
4191
|
+
);
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
return VALID_RESULT;
|
|
4195
|
+
};
|
|
4196
|
+
|
|
4197
|
+
const validateAnimationMaskImageReferences = ({
|
|
4198
|
+
state,
|
|
4199
|
+
animation,
|
|
4200
|
+
path,
|
|
4201
|
+
details = {},
|
|
4202
|
+
errorFactory = createPreconditionValidationError,
|
|
4203
|
+
}) => {
|
|
4204
|
+
if (
|
|
4205
|
+
!isPlainObject(animation) ||
|
|
4206
|
+
animation.type !== "transition" ||
|
|
4207
|
+
!isPlainObject(animation.mask)
|
|
4208
|
+
) {
|
|
4209
|
+
return VALID_RESULT;
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
const { mask } = animation;
|
|
4213
|
+
|
|
4214
|
+
if (mask.imageId !== undefined) {
|
|
4215
|
+
const result = validateImageReference({
|
|
4216
|
+
state,
|
|
4217
|
+
imageId: mask.imageId,
|
|
4218
|
+
path: `${path}.mask.imageId`,
|
|
4219
|
+
details: {
|
|
4220
|
+
...details,
|
|
4221
|
+
field: "imageId",
|
|
4222
|
+
imageId: mask.imageId,
|
|
4223
|
+
},
|
|
4224
|
+
errorFactory,
|
|
4225
|
+
});
|
|
4226
|
+
if (!result.valid) {
|
|
4227
|
+
return result;
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
if (Array.isArray(mask.imageIds)) {
|
|
4232
|
+
for (const [index, imageId] of mask.imageIds.entries()) {
|
|
4233
|
+
const result = validateImageReference({
|
|
4234
|
+
state,
|
|
4235
|
+
imageId,
|
|
4236
|
+
path: `${path}.mask.imageIds[${index}]`,
|
|
4237
|
+
details: {
|
|
4238
|
+
...details,
|
|
4239
|
+
field: `imageIds[${index}]`,
|
|
4240
|
+
imageId,
|
|
4241
|
+
},
|
|
4242
|
+
errorFactory,
|
|
4243
|
+
});
|
|
4244
|
+
if (!result.valid) {
|
|
4245
|
+
return result;
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
|
|
4250
|
+
if (Array.isArray(mask.items)) {
|
|
4251
|
+
for (const [index, item] of mask.items.entries()) {
|
|
4252
|
+
if (item?.imageId === undefined) {
|
|
4253
|
+
continue;
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
const result = validateImageReference({
|
|
4257
|
+
state,
|
|
4258
|
+
imageId: item.imageId,
|
|
4259
|
+
path: `${path}.mask.items[${index}].imageId`,
|
|
4260
|
+
details: {
|
|
4261
|
+
...details,
|
|
4262
|
+
field: `items[${index}].imageId`,
|
|
4263
|
+
imageId: item.imageId,
|
|
4264
|
+
},
|
|
4265
|
+
errorFactory,
|
|
4266
|
+
});
|
|
4267
|
+
if (!result.valid) {
|
|
4268
|
+
return result;
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
return VALID_RESULT;
|
|
4274
|
+
};
|
|
4275
|
+
|
|
3999
4276
|
export const assertInvariants = ({ state }) => {
|
|
4000
4277
|
if (!isPlainObject(state)) {
|
|
4001
4278
|
return invalidInvariant("state must be an object");
|
|
@@ -4225,6 +4502,23 @@ export const assertInvariants = ({ state }) => {
|
|
|
4225
4502
|
}
|
|
4226
4503
|
}
|
|
4227
4504
|
|
|
4505
|
+
for (const [animationId, animation] of Object.entries(state.animations.items)) {
|
|
4506
|
+
if (animation.type !== "animation") {
|
|
4507
|
+
continue;
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
const result = validateAnimationMaskImageReferences({
|
|
4511
|
+
state,
|
|
4512
|
+
animation: animation.animation,
|
|
4513
|
+
path: "animation",
|
|
4514
|
+
details: { animationId },
|
|
4515
|
+
errorFactory: createInvariantValidationError,
|
|
4516
|
+
});
|
|
4517
|
+
if (!result.valid) {
|
|
4518
|
+
return result;
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
|
|
4228
4522
|
for (const [characterId, character] of Object.entries(
|
|
4229
4523
|
state.characters.items,
|
|
4230
4524
|
)) {
|
|
@@ -5550,8 +5844,16 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
5550
5844
|
value: data,
|
|
5551
5845
|
allowedKeys:
|
|
5552
5846
|
data.type === "folder"
|
|
5553
|
-
? ["type", "name"]
|
|
5554
|
-
: [
|
|
5847
|
+
? ["type", "name", "description"]
|
|
5848
|
+
: [
|
|
5849
|
+
"type",
|
|
5850
|
+
"name",
|
|
5851
|
+
"description",
|
|
5852
|
+
"fileId",
|
|
5853
|
+
"fontFamily",
|
|
5854
|
+
"fileType",
|
|
5855
|
+
"fileSize",
|
|
5856
|
+
],
|
|
5555
5857
|
path: "payload.data",
|
|
5556
5858
|
errorFactory,
|
|
5557
5859
|
});
|
|
@@ -5567,6 +5869,13 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
5567
5869
|
);
|
|
5568
5870
|
}
|
|
5569
5871
|
|
|
5872
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
5873
|
+
return invalidFromErrorFactory(
|
|
5874
|
+
errorFactory,
|
|
5875
|
+
"payload.data.description must be a string when provided",
|
|
5876
|
+
);
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5570
5879
|
if (data.type === "font") {
|
|
5571
5880
|
if (!isNonEmptyString(data.fileId)) {
|
|
5572
5881
|
return invalidFromErrorFactory(
|
|
@@ -5602,7 +5911,14 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
5602
5911
|
{
|
|
5603
5912
|
const result = validateAllowedKeys({
|
|
5604
5913
|
value: data,
|
|
5605
|
-
allowedKeys: [
|
|
5914
|
+
allowedKeys: [
|
|
5915
|
+
"name",
|
|
5916
|
+
"description",
|
|
5917
|
+
"fileId",
|
|
5918
|
+
"fontFamily",
|
|
5919
|
+
"fileType",
|
|
5920
|
+
"fileSize",
|
|
5921
|
+
],
|
|
5606
5922
|
path: "payload.data",
|
|
5607
5923
|
errorFactory,
|
|
5608
5924
|
});
|
|
@@ -5625,6 +5941,13 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
5625
5941
|
);
|
|
5626
5942
|
}
|
|
5627
5943
|
|
|
5944
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
5945
|
+
return invalidFromErrorFactory(
|
|
5946
|
+
errorFactory,
|
|
5947
|
+
"payload.data.description must be a string when provided",
|
|
5948
|
+
);
|
|
5949
|
+
}
|
|
5950
|
+
|
|
5628
5951
|
if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
|
|
5629
5952
|
return invalidFromErrorFactory(
|
|
5630
5953
|
errorFactory,
|
|
@@ -5773,7 +6096,9 @@ const validateColorCreateData = ({ data, errorFactory }) => {
|
|
|
5773
6096
|
const result = validateAllowedKeys({
|
|
5774
6097
|
value: data,
|
|
5775
6098
|
allowedKeys:
|
|
5776
|
-
data.type === "folder"
|
|
6099
|
+
data.type === "folder"
|
|
6100
|
+
? ["type", "name", "description"]
|
|
6101
|
+
: ["type", "name", "description", "hex"],
|
|
5777
6102
|
path: "payload.data",
|
|
5778
6103
|
errorFactory,
|
|
5779
6104
|
});
|
|
@@ -5789,6 +6114,13 @@ const validateColorCreateData = ({ data, errorFactory }) => {
|
|
|
5789
6114
|
);
|
|
5790
6115
|
}
|
|
5791
6116
|
|
|
6117
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6118
|
+
return invalidFromErrorFactory(
|
|
6119
|
+
errorFactory,
|
|
6120
|
+
"payload.data.description must be a string when provided",
|
|
6121
|
+
);
|
|
6122
|
+
}
|
|
6123
|
+
|
|
5792
6124
|
if (data.type === "color" && !isHexColor(data.hex)) {
|
|
5793
6125
|
return invalidFromErrorFactory(
|
|
5794
6126
|
errorFactory,
|
|
@@ -5801,7 +6133,7 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
|
|
|
5801
6133
|
{
|
|
5802
6134
|
const result = validateAllowedKeys({
|
|
5803
6135
|
value: data,
|
|
5804
|
-
allowedKeys: ["name", "hex"],
|
|
6136
|
+
allowedKeys: ["name", "description", "hex"],
|
|
5805
6137
|
path: "payload.data",
|
|
5806
6138
|
errorFactory,
|
|
5807
6139
|
});
|
|
@@ -5824,6 +6156,13 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
|
|
|
5824
6156
|
);
|
|
5825
6157
|
}
|
|
5826
6158
|
|
|
6159
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6160
|
+
return invalidFromErrorFactory(
|
|
6161
|
+
errorFactory,
|
|
6162
|
+
"payload.data.description must be a string when provided",
|
|
6163
|
+
);
|
|
6164
|
+
}
|
|
6165
|
+
|
|
5827
6166
|
if (data.hex !== undefined && !isHexColor(data.hex)) {
|
|
5828
6167
|
return invalidFromErrorFactory(
|
|
5829
6168
|
errorFactory,
|
|
@@ -5852,8 +6191,8 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
|
|
|
5852
6191
|
value: data,
|
|
5853
6192
|
allowedKeys:
|
|
5854
6193
|
data.type === "folder"
|
|
5855
|
-
? ["type", "name"]
|
|
5856
|
-
: ["type", "name", "animation"],
|
|
6194
|
+
? ["type", "name", "description"]
|
|
6195
|
+
: ["type", "name", "description", "animation"],
|
|
5857
6196
|
path: "payload.data",
|
|
5858
6197
|
errorFactory,
|
|
5859
6198
|
});
|
|
@@ -5869,6 +6208,13 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
|
|
|
5869
6208
|
);
|
|
5870
6209
|
}
|
|
5871
6210
|
|
|
6211
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6212
|
+
return invalidFromErrorFactory(
|
|
6213
|
+
errorFactory,
|
|
6214
|
+
"payload.data.description must be a string when provided",
|
|
6215
|
+
);
|
|
6216
|
+
}
|
|
6217
|
+
|
|
5872
6218
|
if (data.type === "animation") {
|
|
5873
6219
|
{
|
|
5874
6220
|
const result = validateAnimationDefinition({
|
|
@@ -5887,7 +6233,7 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
|
|
|
5887
6233
|
{
|
|
5888
6234
|
const result = validateAllowedKeys({
|
|
5889
6235
|
value: data,
|
|
5890
|
-
allowedKeys: ["name", "animation"],
|
|
6236
|
+
allowedKeys: ["name", "description", "animation"],
|
|
5891
6237
|
path: "payload.data",
|
|
5892
6238
|
errorFactory,
|
|
5893
6239
|
});
|
|
@@ -5910,6 +6256,13 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
|
|
|
5910
6256
|
);
|
|
5911
6257
|
}
|
|
5912
6258
|
|
|
6259
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6260
|
+
return invalidFromErrorFactory(
|
|
6261
|
+
errorFactory,
|
|
6262
|
+
"payload.data.description must be a string when provided",
|
|
6263
|
+
);
|
|
6264
|
+
}
|
|
6265
|
+
|
|
5913
6266
|
if (data.animation !== undefined) {
|
|
5914
6267
|
{
|
|
5915
6268
|
const result = validateAnimationDefinition({
|
|
@@ -5944,10 +6297,11 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
|
|
|
5944
6297
|
value: data,
|
|
5945
6298
|
allowedKeys:
|
|
5946
6299
|
data.type === "folder"
|
|
5947
|
-
? ["type", "name"]
|
|
6300
|
+
? ["type", "name", "description"]
|
|
5948
6301
|
: [
|
|
5949
6302
|
"type",
|
|
5950
6303
|
"name",
|
|
6304
|
+
"description",
|
|
5951
6305
|
"x",
|
|
5952
6306
|
"y",
|
|
5953
6307
|
"scaleX",
|
|
@@ -5971,6 +6325,13 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
|
|
|
5971
6325
|
);
|
|
5972
6326
|
}
|
|
5973
6327
|
|
|
6328
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6329
|
+
return invalidFromErrorFactory(
|
|
6330
|
+
errorFactory,
|
|
6331
|
+
"payload.data.description must be a string when provided",
|
|
6332
|
+
);
|
|
6333
|
+
}
|
|
6334
|
+
|
|
5974
6335
|
if (data.type === "transform") {
|
|
5975
6336
|
for (const key of [
|
|
5976
6337
|
"x",
|
|
@@ -5997,6 +6358,7 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
|
|
|
5997
6358
|
value: data,
|
|
5998
6359
|
allowedKeys: [
|
|
5999
6360
|
"name",
|
|
6361
|
+
"description",
|
|
6000
6362
|
"x",
|
|
6001
6363
|
"y",
|
|
6002
6364
|
"scaleX",
|
|
@@ -6027,6 +6389,13 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
|
|
|
6027
6389
|
);
|
|
6028
6390
|
}
|
|
6029
6391
|
|
|
6392
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6393
|
+
return invalidFromErrorFactory(
|
|
6394
|
+
errorFactory,
|
|
6395
|
+
"payload.data.description must be a string when provided",
|
|
6396
|
+
);
|
|
6397
|
+
}
|
|
6398
|
+
|
|
6030
6399
|
for (const key of [
|
|
6031
6400
|
"x",
|
|
6032
6401
|
"y",
|
|
@@ -6065,8 +6434,8 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
|
|
|
6065
6434
|
value: data,
|
|
6066
6435
|
allowedKeys:
|
|
6067
6436
|
data.type === "folder"
|
|
6068
|
-
? ["type", "name"]
|
|
6069
|
-
: ["type", "name", "scope", "default", "value"],
|
|
6437
|
+
? ["type", "name", "description"]
|
|
6438
|
+
: ["type", "name", "description", "scope", "default", "value"],
|
|
6070
6439
|
path: "payload.data",
|
|
6071
6440
|
errorFactory,
|
|
6072
6441
|
});
|
|
@@ -6082,6 +6451,13 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
|
|
|
6082
6451
|
);
|
|
6083
6452
|
}
|
|
6084
6453
|
|
|
6454
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6455
|
+
return invalidFromErrorFactory(
|
|
6456
|
+
errorFactory,
|
|
6457
|
+
"payload.data.description must be a string when provided",
|
|
6458
|
+
);
|
|
6459
|
+
}
|
|
6460
|
+
|
|
6085
6461
|
if (data.type !== "folder") {
|
|
6086
6462
|
if (!VARIABLE_SCOPE_KEYS.includes(data.scope)) {
|
|
6087
6463
|
return invalidFromErrorFactory(
|
|
@@ -6119,7 +6495,7 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
|
|
|
6119
6495
|
{
|
|
6120
6496
|
const result = validateAllowedKeys({
|
|
6121
6497
|
value: data,
|
|
6122
|
-
allowedKeys: ["name", "scope", "default", "value"],
|
|
6498
|
+
allowedKeys: ["name", "description", "scope", "default", "value"],
|
|
6123
6499
|
path: "payload.data",
|
|
6124
6500
|
errorFactory,
|
|
6125
6501
|
});
|
|
@@ -6142,6 +6518,13 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
|
|
|
6142
6518
|
);
|
|
6143
6519
|
}
|
|
6144
6520
|
|
|
6521
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6522
|
+
return invalidFromErrorFactory(
|
|
6523
|
+
errorFactory,
|
|
6524
|
+
"payload.data.description must be a string when provided",
|
|
6525
|
+
);
|
|
6526
|
+
}
|
|
6527
|
+
|
|
6145
6528
|
if (data.scope !== undefined && !VARIABLE_SCOPE_KEYS.includes(data.scope)) {
|
|
6146
6529
|
return invalidFromErrorFactory(
|
|
6147
6530
|
errorFactory,
|
|
@@ -6170,10 +6553,11 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
6170
6553
|
value: data,
|
|
6171
6554
|
allowedKeys:
|
|
6172
6555
|
data.type === "folder"
|
|
6173
|
-
? ["type", "name"]
|
|
6556
|
+
? ["type", "name", "description"]
|
|
6174
6557
|
: [
|
|
6175
6558
|
"type",
|
|
6176
6559
|
"name",
|
|
6560
|
+
"description",
|
|
6177
6561
|
"fontId",
|
|
6178
6562
|
"colorId",
|
|
6179
6563
|
"fontSize",
|
|
@@ -6204,6 +6588,13 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
6204
6588
|
);
|
|
6205
6589
|
}
|
|
6206
6590
|
|
|
6591
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6592
|
+
return invalidFromErrorFactory(
|
|
6593
|
+
errorFactory,
|
|
6594
|
+
"payload.data.description must be a string when provided",
|
|
6595
|
+
);
|
|
6596
|
+
}
|
|
6597
|
+
|
|
6207
6598
|
if (data.type === "textStyle") {
|
|
6208
6599
|
{
|
|
6209
6600
|
const result = validateTextStyleItems({
|
|
@@ -6229,6 +6620,7 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
6229
6620
|
value: data,
|
|
6230
6621
|
allowedKeys: [
|
|
6231
6622
|
"name",
|
|
6623
|
+
"description",
|
|
6232
6624
|
"fontId",
|
|
6233
6625
|
"colorId",
|
|
6234
6626
|
"fontSize",
|
|
@@ -6266,6 +6658,13 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
6266
6658
|
);
|
|
6267
6659
|
}
|
|
6268
6660
|
|
|
6661
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6662
|
+
return invalidFromErrorFactory(
|
|
6663
|
+
errorFactory,
|
|
6664
|
+
"payload.data.description must be a string when provided",
|
|
6665
|
+
);
|
|
6666
|
+
}
|
|
6667
|
+
|
|
6269
6668
|
for (const key of ["fontId", "colorId", "strokeColorId"]) {
|
|
6270
6669
|
if (data[key] !== undefined && !isNonEmptyString(data[key])) {
|
|
6271
6670
|
return invalidFromErrorFactory(
|
|
@@ -6349,6 +6748,7 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6349
6748
|
: [
|
|
6350
6749
|
"type",
|
|
6351
6750
|
"name",
|
|
6751
|
+
"description",
|
|
6352
6752
|
"fileId",
|
|
6353
6753
|
"thumbnailFileId",
|
|
6354
6754
|
"fileType",
|
|
@@ -6371,6 +6771,13 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6371
6771
|
);
|
|
6372
6772
|
}
|
|
6373
6773
|
|
|
6774
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6775
|
+
return invalidFromErrorFactory(
|
|
6776
|
+
errorFactory,
|
|
6777
|
+
"payload.data.description must be a string when provided",
|
|
6778
|
+
);
|
|
6779
|
+
}
|
|
6780
|
+
|
|
6374
6781
|
if (data.type === "image") {
|
|
6375
6782
|
if (!isNonEmptyString(data.fileId)) {
|
|
6376
6783
|
return invalidFromErrorFactory(
|
|
@@ -6416,13 +6823,6 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6416
6823
|
"payload.data.height must be a finite number when provided",
|
|
6417
6824
|
);
|
|
6418
6825
|
}
|
|
6419
|
-
|
|
6420
|
-
if (data.description !== undefined && !isString(data.description)) {
|
|
6421
|
-
return invalidFromErrorFactory(
|
|
6422
|
-
errorFactory,
|
|
6423
|
-
"payload.data.description must be a string when provided",
|
|
6424
|
-
);
|
|
6425
|
-
}
|
|
6426
6826
|
}
|
|
6427
6827
|
};
|
|
6428
6828
|
|
|
@@ -6535,7 +6935,7 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
6535
6935
|
value: data,
|
|
6536
6936
|
allowedKeys:
|
|
6537
6937
|
data.type === "folder"
|
|
6538
|
-
? ["type", "name"]
|
|
6938
|
+
? ["type", "name", "description"]
|
|
6539
6939
|
: [
|
|
6540
6940
|
"type",
|
|
6541
6941
|
"name",
|
|
@@ -6561,14 +6961,14 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
6561
6961
|
);
|
|
6562
6962
|
}
|
|
6563
6963
|
|
|
6564
|
-
if (data.
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
}
|
|
6964
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6965
|
+
return invalidFromErrorFactory(
|
|
6966
|
+
errorFactory,
|
|
6967
|
+
"payload.data.description must be a string when provided",
|
|
6968
|
+
);
|
|
6969
|
+
}
|
|
6571
6970
|
|
|
6971
|
+
if (data.type === "character") {
|
|
6572
6972
|
if (data.shortcut !== undefined && !isString(data.shortcut)) {
|
|
6573
6973
|
return invalidFromErrorFactory(
|
|
6574
6974
|
errorFactory,
|
|
@@ -6705,7 +7105,7 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
|
|
|
6705
7105
|
value: data,
|
|
6706
7106
|
allowedKeys:
|
|
6707
7107
|
data.type === "folder"
|
|
6708
|
-
? ["type", "name"]
|
|
7108
|
+
? ["type", "name", "description"]
|
|
6709
7109
|
: [
|
|
6710
7110
|
"type",
|
|
6711
7111
|
"name",
|
|
@@ -6865,8 +7265,15 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
6865
7265
|
value: data,
|
|
6866
7266
|
allowedKeys:
|
|
6867
7267
|
data.type === "folder"
|
|
6868
|
-
? ["type", "name"]
|
|
6869
|
-
: [
|
|
7268
|
+
? ["type", "name", "description"]
|
|
7269
|
+
: [
|
|
7270
|
+
"type",
|
|
7271
|
+
"name",
|
|
7272
|
+
"description",
|
|
7273
|
+
"thumbnailFileId",
|
|
7274
|
+
"elements",
|
|
7275
|
+
"keyboard",
|
|
7276
|
+
],
|
|
6870
7277
|
path: "payload.data",
|
|
6871
7278
|
errorFactory,
|
|
6872
7279
|
});
|
|
@@ -6882,6 +7289,13 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
6882
7289
|
);
|
|
6883
7290
|
}
|
|
6884
7291
|
|
|
7292
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
7293
|
+
return invalidFromErrorFactory(
|
|
7294
|
+
errorFactory,
|
|
7295
|
+
"payload.data.description must be a string when provided",
|
|
7296
|
+
);
|
|
7297
|
+
}
|
|
7298
|
+
|
|
6885
7299
|
if (
|
|
6886
7300
|
data.thumbnailFileId !== undefined &&
|
|
6887
7301
|
!isNonEmptyString(data.thumbnailFileId)
|
|
@@ -6923,7 +7337,7 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
6923
7337
|
{
|
|
6924
7338
|
const result = validateAllowedKeys({
|
|
6925
7339
|
value: data,
|
|
6926
|
-
allowedKeys: ["name", "keyboard", "thumbnailFileId"],
|
|
7340
|
+
allowedKeys: ["name", "description", "keyboard", "thumbnailFileId"],
|
|
6927
7341
|
path: "payload.data",
|
|
6928
7342
|
errorFactory,
|
|
6929
7343
|
});
|
|
@@ -6946,6 +7360,13 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
6946
7360
|
);
|
|
6947
7361
|
}
|
|
6948
7362
|
|
|
7363
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
7364
|
+
return invalidFromErrorFactory(
|
|
7365
|
+
errorFactory,
|
|
7366
|
+
"payload.data.description must be a string when provided",
|
|
7367
|
+
);
|
|
7368
|
+
}
|
|
7369
|
+
|
|
6949
7370
|
if (
|
|
6950
7371
|
data.thumbnailFileId !== undefined &&
|
|
6951
7372
|
!isNonEmptyString(data.thumbnailFileId)
|
|
@@ -10611,6 +11032,19 @@ const COMMAND_DEFINITIONS = [
|
|
|
10611
11032
|
);
|
|
10612
11033
|
}
|
|
10613
11034
|
}
|
|
11035
|
+
|
|
11036
|
+
if (payload.data.type === "animation") {
|
|
11037
|
+
const result = validateAnimationMaskImageReferences({
|
|
11038
|
+
state,
|
|
11039
|
+
animation: payload.data.animation,
|
|
11040
|
+
path: "payload.data.animation",
|
|
11041
|
+
details: { animationId: payload.animationId },
|
|
11042
|
+
errorFactory: createPreconditionValidationError,
|
|
11043
|
+
});
|
|
11044
|
+
if (!result.valid) {
|
|
11045
|
+
return result;
|
|
11046
|
+
}
|
|
11047
|
+
}
|
|
10614
11048
|
},
|
|
10615
11049
|
reduce: ({ state, payload }) => {
|
|
10616
11050
|
const nextAnimation = {
|
|
@@ -10619,6 +11053,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
10619
11053
|
name: payload.data.name,
|
|
10620
11054
|
};
|
|
10621
11055
|
|
|
11056
|
+
if (payload.data.description !== undefined) {
|
|
11057
|
+
nextAnimation.description = payload.data.description;
|
|
11058
|
+
}
|
|
11059
|
+
|
|
10622
11060
|
if (payload.data.type === "animation") {
|
|
10623
11061
|
nextAnimation.animation = structuredClone(payload.data.animation);
|
|
10624
11062
|
}
|
|
@@ -10685,6 +11123,19 @@ const COMMAND_DEFINITIONS = [
|
|
|
10685
11123
|
"folder animation items cannot update animation fields",
|
|
10686
11124
|
);
|
|
10687
11125
|
}
|
|
11126
|
+
|
|
11127
|
+
if (payload.data.animation !== undefined) {
|
|
11128
|
+
const result = validateAnimationMaskImageReferences({
|
|
11129
|
+
state,
|
|
11130
|
+
animation: payload.data.animation,
|
|
11131
|
+
path: "payload.data.animation",
|
|
11132
|
+
details: { animationId: payload.animationId },
|
|
11133
|
+
errorFactory: createPreconditionValidationError,
|
|
11134
|
+
});
|
|
11135
|
+
if (!result.valid) {
|
|
11136
|
+
return result;
|
|
11137
|
+
}
|
|
11138
|
+
}
|
|
10688
11139
|
},
|
|
10689
11140
|
reduce: ({ state, payload }) => {
|
|
10690
11141
|
const currentAnimation = state.animations.items[payload.animationId];
|
|
@@ -11005,6 +11456,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
11005
11456
|
name: payload.data.name,
|
|
11006
11457
|
};
|
|
11007
11458
|
|
|
11459
|
+
if (payload.data.description !== undefined) {
|
|
11460
|
+
nextFont.description = payload.data.description;
|
|
11461
|
+
}
|
|
11462
|
+
|
|
11008
11463
|
if (payload.data.type === "font") {
|
|
11009
11464
|
nextFont.fileId = payload.data.fileId;
|
|
11010
11465
|
nextFont.fontFamily = payload.data.fontFamily;
|
|
@@ -11401,6 +11856,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
11401
11856
|
name: payload.data.name,
|
|
11402
11857
|
};
|
|
11403
11858
|
|
|
11859
|
+
if (payload.data.description !== undefined) {
|
|
11860
|
+
nextColor.description = payload.data.description;
|
|
11861
|
+
}
|
|
11862
|
+
|
|
11404
11863
|
if (payload.data.type === "color") {
|
|
11405
11864
|
nextColor.hex = payload.data.hex;
|
|
11406
11865
|
}
|
|
@@ -11678,6 +12137,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
11678
12137
|
id: payload.transformId,
|
|
11679
12138
|
type: payload.data.type,
|
|
11680
12139
|
name: payload.data.name,
|
|
12140
|
+
...(payload.data.description !== undefined
|
|
12141
|
+
? {
|
|
12142
|
+
description: payload.data.description,
|
|
12143
|
+
}
|
|
12144
|
+
: {}),
|
|
11681
12145
|
...(payload.data.type === "transform"
|
|
11682
12146
|
? {
|
|
11683
12147
|
x: payload.data.x,
|
|
@@ -11693,7 +12157,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11693
12157
|
validateUpdateState: ({ payload, currentItem }) => {
|
|
11694
12158
|
if (
|
|
11695
12159
|
currentItem.type === "folder" &&
|
|
11696
|
-
Object.keys(payload.data).some(
|
|
12160
|
+
Object.keys(payload.data).some(
|
|
12161
|
+
(key) => key !== "name" && key !== "description",
|
|
12162
|
+
)
|
|
11697
12163
|
) {
|
|
11698
12164
|
return invalidPrecondition(
|
|
11699
12165
|
"folder transform items cannot update transform fields",
|
|
@@ -11712,6 +12178,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
11712
12178
|
id: payload.variableId,
|
|
11713
12179
|
type: payload.data.type,
|
|
11714
12180
|
name: payload.data.name,
|
|
12181
|
+
...(payload.data.description !== undefined
|
|
12182
|
+
? {
|
|
12183
|
+
description: payload.data.description,
|
|
12184
|
+
}
|
|
12185
|
+
: {}),
|
|
11715
12186
|
...(payload.data.type === "folder"
|
|
11716
12187
|
? {}
|
|
11717
12188
|
: {
|
|
@@ -11723,7 +12194,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11723
12194
|
validateUpdateState: ({ payload, currentItem }) => {
|
|
11724
12195
|
if (
|
|
11725
12196
|
currentItem.type === "folder" &&
|
|
11726
|
-
Object.keys(payload.data).some(
|
|
12197
|
+
Object.keys(payload.data).some(
|
|
12198
|
+
(key) => key !== "name" && key !== "description",
|
|
12199
|
+
)
|
|
11727
12200
|
) {
|
|
11728
12201
|
return invalidPrecondition(
|
|
11729
12202
|
"folder variable items cannot update variable fields",
|
|
@@ -11795,7 +12268,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11795
12268
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11796
12269
|
if (
|
|
11797
12270
|
currentItem.type === "folder" &&
|
|
11798
|
-
Object.keys(payload.data).some(
|
|
12271
|
+
Object.keys(payload.data).some(
|
|
12272
|
+
(key) => key !== "name" && key !== "description",
|
|
12273
|
+
)
|
|
11799
12274
|
) {
|
|
11800
12275
|
return invalidPrecondition(
|
|
11801
12276
|
"folder text style items cannot update text style fields",
|
|
@@ -11831,14 +12306,14 @@ const COMMAND_DEFINITIONS = [
|
|
|
11831
12306
|
name: payload.data.name,
|
|
11832
12307
|
};
|
|
11833
12308
|
|
|
11834
|
-
if (item.type !== "character") {
|
|
11835
|
-
return item;
|
|
11836
|
-
}
|
|
11837
|
-
|
|
11838
12309
|
if (payload.data.description !== undefined) {
|
|
11839
12310
|
item.description = payload.data.description;
|
|
11840
12311
|
}
|
|
11841
12312
|
|
|
12313
|
+
if (item.type !== "character") {
|
|
12314
|
+
return item;
|
|
12315
|
+
}
|
|
12316
|
+
|
|
11842
12317
|
if (payload.data.shortcut !== undefined) {
|
|
11843
12318
|
item.shortcut = payload.data.shortcut;
|
|
11844
12319
|
}
|
|
@@ -11924,7 +12399,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11924
12399
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11925
12400
|
if (
|
|
11926
12401
|
currentItem.type === "folder" &&
|
|
11927
|
-
Object.keys(payload.data).some(
|
|
12402
|
+
Object.keys(payload.data).some(
|
|
12403
|
+
(key) => key !== "name" && key !== "description",
|
|
12404
|
+
)
|
|
11928
12405
|
) {
|
|
11929
12406
|
return invalidPrecondition(
|
|
11930
12407
|
"folder character items cannot update character fields",
|
|
@@ -11957,9 +12434,13 @@ const COMMAND_DEFINITIONS = [
|
|
|
11957
12434
|
id: payload.layoutId,
|
|
11958
12435
|
type: payload.data.type,
|
|
11959
12436
|
name: payload.data.name,
|
|
11960
|
-
...(payload.data.
|
|
12437
|
+
...(payload.data.description !== undefined
|
|
11961
12438
|
? {
|
|
11962
12439
|
description: payload.data.description,
|
|
12440
|
+
}
|
|
12441
|
+
: {}),
|
|
12442
|
+
...(payload.data.type === "layout"
|
|
12443
|
+
? {
|
|
11963
12444
|
layoutType: payload.data.layoutType,
|
|
11964
12445
|
isFragment: payload.data.isFragment,
|
|
11965
12446
|
...(payload.data.thumbnailFileId !== undefined
|
|
@@ -11988,7 +12469,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11988
12469
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11989
12470
|
if (
|
|
11990
12471
|
currentItem.type === "folder" &&
|
|
11991
|
-
Object.keys(payload.data).some(
|
|
12472
|
+
Object.keys(payload.data).some(
|
|
12473
|
+
(key) => key !== "name" && key !== "description",
|
|
12474
|
+
)
|
|
11992
12475
|
) {
|
|
11993
12476
|
return invalidPrecondition(
|
|
11994
12477
|
"folder layout items cannot update layout fields",
|
|
@@ -12018,6 +12501,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
12018
12501
|
id: payload.controlId,
|
|
12019
12502
|
type: payload.data.type,
|
|
12020
12503
|
name: payload.data.name,
|
|
12504
|
+
...(payload.data.description !== undefined
|
|
12505
|
+
? {
|
|
12506
|
+
description: payload.data.description,
|
|
12507
|
+
}
|
|
12508
|
+
: {}),
|
|
12021
12509
|
...(payload.data.type === "control"
|
|
12022
12510
|
? {
|
|
12023
12511
|
...(payload.data.thumbnailFileId !== undefined
|
|
@@ -12051,7 +12539,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
12051
12539
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
12052
12540
|
if (
|
|
12053
12541
|
currentItem.type === "folder" &&
|
|
12054
|
-
Object.keys(payload.data).some(
|
|
12542
|
+
Object.keys(payload.data).some(
|
|
12543
|
+
(key) => key !== "name" && key !== "description",
|
|
12544
|
+
)
|
|
12055
12545
|
) {
|
|
12056
12546
|
return invalidPrecondition(
|
|
12057
12547
|
"folder control items cannot update control fields",
|
|
@@ -12273,7 +12763,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
12273
12763
|
|
|
12274
12764
|
if (
|
|
12275
12765
|
currentItem.type === "folder" &&
|
|
12276
|
-
Object.keys(payload.data).some(
|
|
12766
|
+
Object.keys(payload.data).some(
|
|
12767
|
+
(key) => key !== "name" && key !== "description",
|
|
12768
|
+
)
|
|
12277
12769
|
) {
|
|
12278
12770
|
return invalidPrecondition(
|
|
12279
12771
|
"folder sprite items cannot update image fields",
|