@routevn/creator-model 1.1.9 → 1.1.10
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 +553 -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
|
+
) {
|
|
1364
|
+
return invalidFromErrorFactory(
|
|
1365
|
+
errorFactory,
|
|
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
|
+
) {
|
|
1318
1374
|
return invalidFromErrorFactory(
|
|
1319
1375
|
errorFactory,
|
|
1320
|
-
`${itemPath}.
|
|
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
|
+
) {
|
|
1461
|
+
return invalidFromErrorFactory(
|
|
1462
|
+
errorFactory,
|
|
1463
|
+
`${path}.progressDuration must be a finite number greater than or equal to 1 when provided`,
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
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
|
+
) {
|
|
1392
1482
|
return invalidFromErrorFactory(
|
|
1393
1483
|
errorFactory,
|
|
1394
|
-
`${path}.texture is required when ${path}.kind is 'single'`,
|
|
1484
|
+
`${path}.texture or ${path}.imageId is required when ${path}.kind is 'single'`,
|
|
1395
1485
|
);
|
|
1396
1486
|
}
|
|
1397
1487
|
|
|
1398
|
-
if (
|
|
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 &&
|
|
@@ -2907,7 +3055,7 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
2907
3055
|
value: item,
|
|
2908
3056
|
allowedKeys:
|
|
2909
3057
|
item.type === "folder"
|
|
2910
|
-
? ["id", "type", "name"]
|
|
3058
|
+
? ["id", "type", "name", "description"]
|
|
2911
3059
|
: [
|
|
2912
3060
|
"id",
|
|
2913
3061
|
"type",
|
|
@@ -2948,14 +3096,14 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
2948
3096
|
);
|
|
2949
3097
|
}
|
|
2950
3098
|
|
|
2951
|
-
if (item.
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
}
|
|
3099
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
3100
|
+
return invalidFromErrorFactory(
|
|
3101
|
+
errorFactory,
|
|
3102
|
+
`${itemPath}.description must be a string when provided`,
|
|
3103
|
+
);
|
|
3104
|
+
}
|
|
2958
3105
|
|
|
3106
|
+
if (item.type === "character") {
|
|
2959
3107
|
if (item.shortcut !== undefined && !isString(item.shortcut)) {
|
|
2960
3108
|
return invalidFromErrorFactory(
|
|
2961
3109
|
errorFactory,
|
|
@@ -3048,7 +3196,7 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
|
|
|
3048
3196
|
value: item,
|
|
3049
3197
|
allowedKeys:
|
|
3050
3198
|
item.type === "folder"
|
|
3051
|
-
? ["id", "type", "name"]
|
|
3199
|
+
? ["id", "type", "name", "description"]
|
|
3052
3200
|
: [
|
|
3053
3201
|
"id",
|
|
3054
3202
|
"type",
|
|
@@ -3155,8 +3303,16 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
3155
3303
|
value: item,
|
|
3156
3304
|
allowedKeys:
|
|
3157
3305
|
item.type === "folder"
|
|
3158
|
-
? ["id", "type", "name"]
|
|
3159
|
-
: [
|
|
3306
|
+
? ["id", "type", "name", "description"]
|
|
3307
|
+
: [
|
|
3308
|
+
"id",
|
|
3309
|
+
"type",
|
|
3310
|
+
"name",
|
|
3311
|
+
"description",
|
|
3312
|
+
"thumbnailFileId",
|
|
3313
|
+
"elements",
|
|
3314
|
+
"keyboard",
|
|
3315
|
+
],
|
|
3160
3316
|
path: itemPath,
|
|
3161
3317
|
errorFactory,
|
|
3162
3318
|
});
|
|
@@ -3186,6 +3342,13 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
3186
3342
|
);
|
|
3187
3343
|
}
|
|
3188
3344
|
|
|
3345
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
3346
|
+
return invalidFromErrorFactory(
|
|
3347
|
+
errorFactory,
|
|
3348
|
+
`${itemPath}.description must be a string when provided`,
|
|
3349
|
+
);
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3189
3352
|
if (
|
|
3190
3353
|
item.thumbnailFileId !== undefined &&
|
|
3191
3354
|
!isNonEmptyString(item.thumbnailFileId)
|
|
@@ -3996,6 +4159,108 @@ const validateFileReference = ({
|
|
|
3996
4159
|
return VALID_RESULT;
|
|
3997
4160
|
};
|
|
3998
4161
|
|
|
4162
|
+
const validateImageReference = ({
|
|
4163
|
+
state,
|
|
4164
|
+
imageId,
|
|
4165
|
+
path,
|
|
4166
|
+
details = {},
|
|
4167
|
+
errorFactory = createPreconditionValidationError,
|
|
4168
|
+
}) => {
|
|
4169
|
+
if (imageId === undefined || imageId === null) {
|
|
4170
|
+
return VALID_RESULT;
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
const image = state.images?.items?.[imageId];
|
|
4174
|
+
if (!isPlainObject(image) || image.type === "folder") {
|
|
4175
|
+
return invalidFromErrorFactory(
|
|
4176
|
+
errorFactory,
|
|
4177
|
+
`${path} must reference an existing non-folder image`,
|
|
4178
|
+
details,
|
|
4179
|
+
);
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
return VALID_RESULT;
|
|
4183
|
+
};
|
|
4184
|
+
|
|
4185
|
+
const validateAnimationMaskImageReferences = ({
|
|
4186
|
+
state,
|
|
4187
|
+
animation,
|
|
4188
|
+
path,
|
|
4189
|
+
details = {},
|
|
4190
|
+
errorFactory = createPreconditionValidationError,
|
|
4191
|
+
}) => {
|
|
4192
|
+
if (
|
|
4193
|
+
!isPlainObject(animation) ||
|
|
4194
|
+
animation.type !== "transition" ||
|
|
4195
|
+
!isPlainObject(animation.mask)
|
|
4196
|
+
) {
|
|
4197
|
+
return VALID_RESULT;
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
const { mask } = animation;
|
|
4201
|
+
|
|
4202
|
+
if (mask.imageId !== undefined) {
|
|
4203
|
+
const result = validateImageReference({
|
|
4204
|
+
state,
|
|
4205
|
+
imageId: mask.imageId,
|
|
4206
|
+
path: `${path}.mask.imageId`,
|
|
4207
|
+
details: {
|
|
4208
|
+
...details,
|
|
4209
|
+
field: "imageId",
|
|
4210
|
+
imageId: mask.imageId,
|
|
4211
|
+
},
|
|
4212
|
+
errorFactory,
|
|
4213
|
+
});
|
|
4214
|
+
if (!result.valid) {
|
|
4215
|
+
return result;
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
|
|
4219
|
+
if (Array.isArray(mask.imageIds)) {
|
|
4220
|
+
for (const [index, imageId] of mask.imageIds.entries()) {
|
|
4221
|
+
const result = validateImageReference({
|
|
4222
|
+
state,
|
|
4223
|
+
imageId,
|
|
4224
|
+
path: `${path}.mask.imageIds[${index}]`,
|
|
4225
|
+
details: {
|
|
4226
|
+
...details,
|
|
4227
|
+
field: `imageIds[${index}]`,
|
|
4228
|
+
imageId,
|
|
4229
|
+
},
|
|
4230
|
+
errorFactory,
|
|
4231
|
+
});
|
|
4232
|
+
if (!result.valid) {
|
|
4233
|
+
return result;
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
|
|
4238
|
+
if (Array.isArray(mask.items)) {
|
|
4239
|
+
for (const [index, item] of mask.items.entries()) {
|
|
4240
|
+
if (item?.imageId === undefined) {
|
|
4241
|
+
continue;
|
|
4242
|
+
}
|
|
4243
|
+
|
|
4244
|
+
const result = validateImageReference({
|
|
4245
|
+
state,
|
|
4246
|
+
imageId: item.imageId,
|
|
4247
|
+
path: `${path}.mask.items[${index}].imageId`,
|
|
4248
|
+
details: {
|
|
4249
|
+
...details,
|
|
4250
|
+
field: `items[${index}].imageId`,
|
|
4251
|
+
imageId: item.imageId,
|
|
4252
|
+
},
|
|
4253
|
+
errorFactory,
|
|
4254
|
+
});
|
|
4255
|
+
if (!result.valid) {
|
|
4256
|
+
return result;
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4261
|
+
return VALID_RESULT;
|
|
4262
|
+
};
|
|
4263
|
+
|
|
3999
4264
|
export const assertInvariants = ({ state }) => {
|
|
4000
4265
|
if (!isPlainObject(state)) {
|
|
4001
4266
|
return invalidInvariant("state must be an object");
|
|
@@ -4225,6 +4490,23 @@ export const assertInvariants = ({ state }) => {
|
|
|
4225
4490
|
}
|
|
4226
4491
|
}
|
|
4227
4492
|
|
|
4493
|
+
for (const [animationId, animation] of Object.entries(state.animations.items)) {
|
|
4494
|
+
if (animation.type !== "animation") {
|
|
4495
|
+
continue;
|
|
4496
|
+
}
|
|
4497
|
+
|
|
4498
|
+
const result = validateAnimationMaskImageReferences({
|
|
4499
|
+
state,
|
|
4500
|
+
animation: animation.animation,
|
|
4501
|
+
path: "animation",
|
|
4502
|
+
details: { animationId },
|
|
4503
|
+
errorFactory: createInvariantValidationError,
|
|
4504
|
+
});
|
|
4505
|
+
if (!result.valid) {
|
|
4506
|
+
return result;
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4228
4510
|
for (const [characterId, character] of Object.entries(
|
|
4229
4511
|
state.characters.items,
|
|
4230
4512
|
)) {
|
|
@@ -5550,8 +5832,16 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
5550
5832
|
value: data,
|
|
5551
5833
|
allowedKeys:
|
|
5552
5834
|
data.type === "folder"
|
|
5553
|
-
? ["type", "name"]
|
|
5554
|
-
: [
|
|
5835
|
+
? ["type", "name", "description"]
|
|
5836
|
+
: [
|
|
5837
|
+
"type",
|
|
5838
|
+
"name",
|
|
5839
|
+
"description",
|
|
5840
|
+
"fileId",
|
|
5841
|
+
"fontFamily",
|
|
5842
|
+
"fileType",
|
|
5843
|
+
"fileSize",
|
|
5844
|
+
],
|
|
5555
5845
|
path: "payload.data",
|
|
5556
5846
|
errorFactory,
|
|
5557
5847
|
});
|
|
@@ -5567,6 +5857,13 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
5567
5857
|
);
|
|
5568
5858
|
}
|
|
5569
5859
|
|
|
5860
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
5861
|
+
return invalidFromErrorFactory(
|
|
5862
|
+
errorFactory,
|
|
5863
|
+
"payload.data.description must be a string when provided",
|
|
5864
|
+
);
|
|
5865
|
+
}
|
|
5866
|
+
|
|
5570
5867
|
if (data.type === "font") {
|
|
5571
5868
|
if (!isNonEmptyString(data.fileId)) {
|
|
5572
5869
|
return invalidFromErrorFactory(
|
|
@@ -5602,7 +5899,14 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
5602
5899
|
{
|
|
5603
5900
|
const result = validateAllowedKeys({
|
|
5604
5901
|
value: data,
|
|
5605
|
-
allowedKeys: [
|
|
5902
|
+
allowedKeys: [
|
|
5903
|
+
"name",
|
|
5904
|
+
"description",
|
|
5905
|
+
"fileId",
|
|
5906
|
+
"fontFamily",
|
|
5907
|
+
"fileType",
|
|
5908
|
+
"fileSize",
|
|
5909
|
+
],
|
|
5606
5910
|
path: "payload.data",
|
|
5607
5911
|
errorFactory,
|
|
5608
5912
|
});
|
|
@@ -5625,6 +5929,13 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
5625
5929
|
);
|
|
5626
5930
|
}
|
|
5627
5931
|
|
|
5932
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
5933
|
+
return invalidFromErrorFactory(
|
|
5934
|
+
errorFactory,
|
|
5935
|
+
"payload.data.description must be a string when provided",
|
|
5936
|
+
);
|
|
5937
|
+
}
|
|
5938
|
+
|
|
5628
5939
|
if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
|
|
5629
5940
|
return invalidFromErrorFactory(
|
|
5630
5941
|
errorFactory,
|
|
@@ -5773,7 +6084,9 @@ const validateColorCreateData = ({ data, errorFactory }) => {
|
|
|
5773
6084
|
const result = validateAllowedKeys({
|
|
5774
6085
|
value: data,
|
|
5775
6086
|
allowedKeys:
|
|
5776
|
-
data.type === "folder"
|
|
6087
|
+
data.type === "folder"
|
|
6088
|
+
? ["type", "name", "description"]
|
|
6089
|
+
: ["type", "name", "description", "hex"],
|
|
5777
6090
|
path: "payload.data",
|
|
5778
6091
|
errorFactory,
|
|
5779
6092
|
});
|
|
@@ -5789,6 +6102,13 @@ const validateColorCreateData = ({ data, errorFactory }) => {
|
|
|
5789
6102
|
);
|
|
5790
6103
|
}
|
|
5791
6104
|
|
|
6105
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6106
|
+
return invalidFromErrorFactory(
|
|
6107
|
+
errorFactory,
|
|
6108
|
+
"payload.data.description must be a string when provided",
|
|
6109
|
+
);
|
|
6110
|
+
}
|
|
6111
|
+
|
|
5792
6112
|
if (data.type === "color" && !isHexColor(data.hex)) {
|
|
5793
6113
|
return invalidFromErrorFactory(
|
|
5794
6114
|
errorFactory,
|
|
@@ -5801,7 +6121,7 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
|
|
|
5801
6121
|
{
|
|
5802
6122
|
const result = validateAllowedKeys({
|
|
5803
6123
|
value: data,
|
|
5804
|
-
allowedKeys: ["name", "hex"],
|
|
6124
|
+
allowedKeys: ["name", "description", "hex"],
|
|
5805
6125
|
path: "payload.data",
|
|
5806
6126
|
errorFactory,
|
|
5807
6127
|
});
|
|
@@ -5824,6 +6144,13 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
|
|
|
5824
6144
|
);
|
|
5825
6145
|
}
|
|
5826
6146
|
|
|
6147
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6148
|
+
return invalidFromErrorFactory(
|
|
6149
|
+
errorFactory,
|
|
6150
|
+
"payload.data.description must be a string when provided",
|
|
6151
|
+
);
|
|
6152
|
+
}
|
|
6153
|
+
|
|
5827
6154
|
if (data.hex !== undefined && !isHexColor(data.hex)) {
|
|
5828
6155
|
return invalidFromErrorFactory(
|
|
5829
6156
|
errorFactory,
|
|
@@ -5852,8 +6179,8 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
|
|
|
5852
6179
|
value: data,
|
|
5853
6180
|
allowedKeys:
|
|
5854
6181
|
data.type === "folder"
|
|
5855
|
-
? ["type", "name"]
|
|
5856
|
-
: ["type", "name", "animation"],
|
|
6182
|
+
? ["type", "name", "description"]
|
|
6183
|
+
: ["type", "name", "description", "animation"],
|
|
5857
6184
|
path: "payload.data",
|
|
5858
6185
|
errorFactory,
|
|
5859
6186
|
});
|
|
@@ -5869,6 +6196,13 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
|
|
|
5869
6196
|
);
|
|
5870
6197
|
}
|
|
5871
6198
|
|
|
6199
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6200
|
+
return invalidFromErrorFactory(
|
|
6201
|
+
errorFactory,
|
|
6202
|
+
"payload.data.description must be a string when provided",
|
|
6203
|
+
);
|
|
6204
|
+
}
|
|
6205
|
+
|
|
5872
6206
|
if (data.type === "animation") {
|
|
5873
6207
|
{
|
|
5874
6208
|
const result = validateAnimationDefinition({
|
|
@@ -5887,7 +6221,7 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
|
|
|
5887
6221
|
{
|
|
5888
6222
|
const result = validateAllowedKeys({
|
|
5889
6223
|
value: data,
|
|
5890
|
-
allowedKeys: ["name", "animation"],
|
|
6224
|
+
allowedKeys: ["name", "description", "animation"],
|
|
5891
6225
|
path: "payload.data",
|
|
5892
6226
|
errorFactory,
|
|
5893
6227
|
});
|
|
@@ -5910,6 +6244,13 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
|
|
|
5910
6244
|
);
|
|
5911
6245
|
}
|
|
5912
6246
|
|
|
6247
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6248
|
+
return invalidFromErrorFactory(
|
|
6249
|
+
errorFactory,
|
|
6250
|
+
"payload.data.description must be a string when provided",
|
|
6251
|
+
);
|
|
6252
|
+
}
|
|
6253
|
+
|
|
5913
6254
|
if (data.animation !== undefined) {
|
|
5914
6255
|
{
|
|
5915
6256
|
const result = validateAnimationDefinition({
|
|
@@ -5944,10 +6285,11 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
|
|
|
5944
6285
|
value: data,
|
|
5945
6286
|
allowedKeys:
|
|
5946
6287
|
data.type === "folder"
|
|
5947
|
-
? ["type", "name"]
|
|
6288
|
+
? ["type", "name", "description"]
|
|
5948
6289
|
: [
|
|
5949
6290
|
"type",
|
|
5950
6291
|
"name",
|
|
6292
|
+
"description",
|
|
5951
6293
|
"x",
|
|
5952
6294
|
"y",
|
|
5953
6295
|
"scaleX",
|
|
@@ -5971,6 +6313,13 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
|
|
|
5971
6313
|
);
|
|
5972
6314
|
}
|
|
5973
6315
|
|
|
6316
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6317
|
+
return invalidFromErrorFactory(
|
|
6318
|
+
errorFactory,
|
|
6319
|
+
"payload.data.description must be a string when provided",
|
|
6320
|
+
);
|
|
6321
|
+
}
|
|
6322
|
+
|
|
5974
6323
|
if (data.type === "transform") {
|
|
5975
6324
|
for (const key of [
|
|
5976
6325
|
"x",
|
|
@@ -5997,6 +6346,7 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
|
|
|
5997
6346
|
value: data,
|
|
5998
6347
|
allowedKeys: [
|
|
5999
6348
|
"name",
|
|
6349
|
+
"description",
|
|
6000
6350
|
"x",
|
|
6001
6351
|
"y",
|
|
6002
6352
|
"scaleX",
|
|
@@ -6027,6 +6377,13 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
|
|
|
6027
6377
|
);
|
|
6028
6378
|
}
|
|
6029
6379
|
|
|
6380
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6381
|
+
return invalidFromErrorFactory(
|
|
6382
|
+
errorFactory,
|
|
6383
|
+
"payload.data.description must be a string when provided",
|
|
6384
|
+
);
|
|
6385
|
+
}
|
|
6386
|
+
|
|
6030
6387
|
for (const key of [
|
|
6031
6388
|
"x",
|
|
6032
6389
|
"y",
|
|
@@ -6065,8 +6422,8 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
|
|
|
6065
6422
|
value: data,
|
|
6066
6423
|
allowedKeys:
|
|
6067
6424
|
data.type === "folder"
|
|
6068
|
-
? ["type", "name"]
|
|
6069
|
-
: ["type", "name", "scope", "default", "value"],
|
|
6425
|
+
? ["type", "name", "description"]
|
|
6426
|
+
: ["type", "name", "description", "scope", "default", "value"],
|
|
6070
6427
|
path: "payload.data",
|
|
6071
6428
|
errorFactory,
|
|
6072
6429
|
});
|
|
@@ -6082,6 +6439,13 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
|
|
|
6082
6439
|
);
|
|
6083
6440
|
}
|
|
6084
6441
|
|
|
6442
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6443
|
+
return invalidFromErrorFactory(
|
|
6444
|
+
errorFactory,
|
|
6445
|
+
"payload.data.description must be a string when provided",
|
|
6446
|
+
);
|
|
6447
|
+
}
|
|
6448
|
+
|
|
6085
6449
|
if (data.type !== "folder") {
|
|
6086
6450
|
if (!VARIABLE_SCOPE_KEYS.includes(data.scope)) {
|
|
6087
6451
|
return invalidFromErrorFactory(
|
|
@@ -6119,7 +6483,7 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
|
|
|
6119
6483
|
{
|
|
6120
6484
|
const result = validateAllowedKeys({
|
|
6121
6485
|
value: data,
|
|
6122
|
-
allowedKeys: ["name", "scope", "default", "value"],
|
|
6486
|
+
allowedKeys: ["name", "description", "scope", "default", "value"],
|
|
6123
6487
|
path: "payload.data",
|
|
6124
6488
|
errorFactory,
|
|
6125
6489
|
});
|
|
@@ -6142,6 +6506,13 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
|
|
|
6142
6506
|
);
|
|
6143
6507
|
}
|
|
6144
6508
|
|
|
6509
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6510
|
+
return invalidFromErrorFactory(
|
|
6511
|
+
errorFactory,
|
|
6512
|
+
"payload.data.description must be a string when provided",
|
|
6513
|
+
);
|
|
6514
|
+
}
|
|
6515
|
+
|
|
6145
6516
|
if (data.scope !== undefined && !VARIABLE_SCOPE_KEYS.includes(data.scope)) {
|
|
6146
6517
|
return invalidFromErrorFactory(
|
|
6147
6518
|
errorFactory,
|
|
@@ -6170,10 +6541,11 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
6170
6541
|
value: data,
|
|
6171
6542
|
allowedKeys:
|
|
6172
6543
|
data.type === "folder"
|
|
6173
|
-
? ["type", "name"]
|
|
6544
|
+
? ["type", "name", "description"]
|
|
6174
6545
|
: [
|
|
6175
6546
|
"type",
|
|
6176
6547
|
"name",
|
|
6548
|
+
"description",
|
|
6177
6549
|
"fontId",
|
|
6178
6550
|
"colorId",
|
|
6179
6551
|
"fontSize",
|
|
@@ -6204,6 +6576,13 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
6204
6576
|
);
|
|
6205
6577
|
}
|
|
6206
6578
|
|
|
6579
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6580
|
+
return invalidFromErrorFactory(
|
|
6581
|
+
errorFactory,
|
|
6582
|
+
"payload.data.description must be a string when provided",
|
|
6583
|
+
);
|
|
6584
|
+
}
|
|
6585
|
+
|
|
6207
6586
|
if (data.type === "textStyle") {
|
|
6208
6587
|
{
|
|
6209
6588
|
const result = validateTextStyleItems({
|
|
@@ -6229,6 +6608,7 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
6229
6608
|
value: data,
|
|
6230
6609
|
allowedKeys: [
|
|
6231
6610
|
"name",
|
|
6611
|
+
"description",
|
|
6232
6612
|
"fontId",
|
|
6233
6613
|
"colorId",
|
|
6234
6614
|
"fontSize",
|
|
@@ -6266,6 +6646,13 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
6266
6646
|
);
|
|
6267
6647
|
}
|
|
6268
6648
|
|
|
6649
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6650
|
+
return invalidFromErrorFactory(
|
|
6651
|
+
errorFactory,
|
|
6652
|
+
"payload.data.description must be a string when provided",
|
|
6653
|
+
);
|
|
6654
|
+
}
|
|
6655
|
+
|
|
6269
6656
|
for (const key of ["fontId", "colorId", "strokeColorId"]) {
|
|
6270
6657
|
if (data[key] !== undefined && !isNonEmptyString(data[key])) {
|
|
6271
6658
|
return invalidFromErrorFactory(
|
|
@@ -6349,6 +6736,7 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6349
6736
|
: [
|
|
6350
6737
|
"type",
|
|
6351
6738
|
"name",
|
|
6739
|
+
"description",
|
|
6352
6740
|
"fileId",
|
|
6353
6741
|
"thumbnailFileId",
|
|
6354
6742
|
"fileType",
|
|
@@ -6371,6 +6759,13 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6371
6759
|
);
|
|
6372
6760
|
}
|
|
6373
6761
|
|
|
6762
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6763
|
+
return invalidFromErrorFactory(
|
|
6764
|
+
errorFactory,
|
|
6765
|
+
"payload.data.description must be a string when provided",
|
|
6766
|
+
);
|
|
6767
|
+
}
|
|
6768
|
+
|
|
6374
6769
|
if (data.type === "image") {
|
|
6375
6770
|
if (!isNonEmptyString(data.fileId)) {
|
|
6376
6771
|
return invalidFromErrorFactory(
|
|
@@ -6416,13 +6811,6 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6416
6811
|
"payload.data.height must be a finite number when provided",
|
|
6417
6812
|
);
|
|
6418
6813
|
}
|
|
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
6814
|
}
|
|
6427
6815
|
};
|
|
6428
6816
|
|
|
@@ -6535,7 +6923,7 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
6535
6923
|
value: data,
|
|
6536
6924
|
allowedKeys:
|
|
6537
6925
|
data.type === "folder"
|
|
6538
|
-
? ["type", "name"]
|
|
6926
|
+
? ["type", "name", "description"]
|
|
6539
6927
|
: [
|
|
6540
6928
|
"type",
|
|
6541
6929
|
"name",
|
|
@@ -6561,14 +6949,14 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
6561
6949
|
);
|
|
6562
6950
|
}
|
|
6563
6951
|
|
|
6564
|
-
if (data.
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
}
|
|
6952
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
6953
|
+
return invalidFromErrorFactory(
|
|
6954
|
+
errorFactory,
|
|
6955
|
+
"payload.data.description must be a string when provided",
|
|
6956
|
+
);
|
|
6957
|
+
}
|
|
6571
6958
|
|
|
6959
|
+
if (data.type === "character") {
|
|
6572
6960
|
if (data.shortcut !== undefined && !isString(data.shortcut)) {
|
|
6573
6961
|
return invalidFromErrorFactory(
|
|
6574
6962
|
errorFactory,
|
|
@@ -6705,7 +7093,7 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
|
|
|
6705
7093
|
value: data,
|
|
6706
7094
|
allowedKeys:
|
|
6707
7095
|
data.type === "folder"
|
|
6708
|
-
? ["type", "name"]
|
|
7096
|
+
? ["type", "name", "description"]
|
|
6709
7097
|
: [
|
|
6710
7098
|
"type",
|
|
6711
7099
|
"name",
|
|
@@ -6865,8 +7253,15 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
6865
7253
|
value: data,
|
|
6866
7254
|
allowedKeys:
|
|
6867
7255
|
data.type === "folder"
|
|
6868
|
-
? ["type", "name"]
|
|
6869
|
-
: [
|
|
7256
|
+
? ["type", "name", "description"]
|
|
7257
|
+
: [
|
|
7258
|
+
"type",
|
|
7259
|
+
"name",
|
|
7260
|
+
"description",
|
|
7261
|
+
"thumbnailFileId",
|
|
7262
|
+
"elements",
|
|
7263
|
+
"keyboard",
|
|
7264
|
+
],
|
|
6870
7265
|
path: "payload.data",
|
|
6871
7266
|
errorFactory,
|
|
6872
7267
|
});
|
|
@@ -6882,6 +7277,13 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
6882
7277
|
);
|
|
6883
7278
|
}
|
|
6884
7279
|
|
|
7280
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
7281
|
+
return invalidFromErrorFactory(
|
|
7282
|
+
errorFactory,
|
|
7283
|
+
"payload.data.description must be a string when provided",
|
|
7284
|
+
);
|
|
7285
|
+
}
|
|
7286
|
+
|
|
6885
7287
|
if (
|
|
6886
7288
|
data.thumbnailFileId !== undefined &&
|
|
6887
7289
|
!isNonEmptyString(data.thumbnailFileId)
|
|
@@ -6923,7 +7325,7 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
6923
7325
|
{
|
|
6924
7326
|
const result = validateAllowedKeys({
|
|
6925
7327
|
value: data,
|
|
6926
|
-
allowedKeys: ["name", "keyboard", "thumbnailFileId"],
|
|
7328
|
+
allowedKeys: ["name", "description", "keyboard", "thumbnailFileId"],
|
|
6927
7329
|
path: "payload.data",
|
|
6928
7330
|
errorFactory,
|
|
6929
7331
|
});
|
|
@@ -6946,6 +7348,13 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
6946
7348
|
);
|
|
6947
7349
|
}
|
|
6948
7350
|
|
|
7351
|
+
if (data.description !== undefined && !isString(data.description)) {
|
|
7352
|
+
return invalidFromErrorFactory(
|
|
7353
|
+
errorFactory,
|
|
7354
|
+
"payload.data.description must be a string when provided",
|
|
7355
|
+
);
|
|
7356
|
+
}
|
|
7357
|
+
|
|
6949
7358
|
if (
|
|
6950
7359
|
data.thumbnailFileId !== undefined &&
|
|
6951
7360
|
!isNonEmptyString(data.thumbnailFileId)
|
|
@@ -10611,6 +11020,19 @@ const COMMAND_DEFINITIONS = [
|
|
|
10611
11020
|
);
|
|
10612
11021
|
}
|
|
10613
11022
|
}
|
|
11023
|
+
|
|
11024
|
+
if (payload.data.type === "animation") {
|
|
11025
|
+
const result = validateAnimationMaskImageReferences({
|
|
11026
|
+
state,
|
|
11027
|
+
animation: payload.data.animation,
|
|
11028
|
+
path: "payload.data.animation",
|
|
11029
|
+
details: { animationId: payload.animationId },
|
|
11030
|
+
errorFactory: createPreconditionValidationError,
|
|
11031
|
+
});
|
|
11032
|
+
if (!result.valid) {
|
|
11033
|
+
return result;
|
|
11034
|
+
}
|
|
11035
|
+
}
|
|
10614
11036
|
},
|
|
10615
11037
|
reduce: ({ state, payload }) => {
|
|
10616
11038
|
const nextAnimation = {
|
|
@@ -10619,6 +11041,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
10619
11041
|
name: payload.data.name,
|
|
10620
11042
|
};
|
|
10621
11043
|
|
|
11044
|
+
if (payload.data.description !== undefined) {
|
|
11045
|
+
nextAnimation.description = payload.data.description;
|
|
11046
|
+
}
|
|
11047
|
+
|
|
10622
11048
|
if (payload.data.type === "animation") {
|
|
10623
11049
|
nextAnimation.animation = structuredClone(payload.data.animation);
|
|
10624
11050
|
}
|
|
@@ -10685,6 +11111,19 @@ const COMMAND_DEFINITIONS = [
|
|
|
10685
11111
|
"folder animation items cannot update animation fields",
|
|
10686
11112
|
);
|
|
10687
11113
|
}
|
|
11114
|
+
|
|
11115
|
+
if (payload.data.animation !== undefined) {
|
|
11116
|
+
const result = validateAnimationMaskImageReferences({
|
|
11117
|
+
state,
|
|
11118
|
+
animation: payload.data.animation,
|
|
11119
|
+
path: "payload.data.animation",
|
|
11120
|
+
details: { animationId: payload.animationId },
|
|
11121
|
+
errorFactory: createPreconditionValidationError,
|
|
11122
|
+
});
|
|
11123
|
+
if (!result.valid) {
|
|
11124
|
+
return result;
|
|
11125
|
+
}
|
|
11126
|
+
}
|
|
10688
11127
|
},
|
|
10689
11128
|
reduce: ({ state, payload }) => {
|
|
10690
11129
|
const currentAnimation = state.animations.items[payload.animationId];
|
|
@@ -11005,6 +11444,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
11005
11444
|
name: payload.data.name,
|
|
11006
11445
|
};
|
|
11007
11446
|
|
|
11447
|
+
if (payload.data.description !== undefined) {
|
|
11448
|
+
nextFont.description = payload.data.description;
|
|
11449
|
+
}
|
|
11450
|
+
|
|
11008
11451
|
if (payload.data.type === "font") {
|
|
11009
11452
|
nextFont.fileId = payload.data.fileId;
|
|
11010
11453
|
nextFont.fontFamily = payload.data.fontFamily;
|
|
@@ -11401,6 +11844,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
11401
11844
|
name: payload.data.name,
|
|
11402
11845
|
};
|
|
11403
11846
|
|
|
11847
|
+
if (payload.data.description !== undefined) {
|
|
11848
|
+
nextColor.description = payload.data.description;
|
|
11849
|
+
}
|
|
11850
|
+
|
|
11404
11851
|
if (payload.data.type === "color") {
|
|
11405
11852
|
nextColor.hex = payload.data.hex;
|
|
11406
11853
|
}
|
|
@@ -11678,6 +12125,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
11678
12125
|
id: payload.transformId,
|
|
11679
12126
|
type: payload.data.type,
|
|
11680
12127
|
name: payload.data.name,
|
|
12128
|
+
...(payload.data.description !== undefined
|
|
12129
|
+
? {
|
|
12130
|
+
description: payload.data.description,
|
|
12131
|
+
}
|
|
12132
|
+
: {}),
|
|
11681
12133
|
...(payload.data.type === "transform"
|
|
11682
12134
|
? {
|
|
11683
12135
|
x: payload.data.x,
|
|
@@ -11693,7 +12145,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11693
12145
|
validateUpdateState: ({ payload, currentItem }) => {
|
|
11694
12146
|
if (
|
|
11695
12147
|
currentItem.type === "folder" &&
|
|
11696
|
-
Object.keys(payload.data).some(
|
|
12148
|
+
Object.keys(payload.data).some(
|
|
12149
|
+
(key) => key !== "name" && key !== "description",
|
|
12150
|
+
)
|
|
11697
12151
|
) {
|
|
11698
12152
|
return invalidPrecondition(
|
|
11699
12153
|
"folder transform items cannot update transform fields",
|
|
@@ -11712,6 +12166,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
11712
12166
|
id: payload.variableId,
|
|
11713
12167
|
type: payload.data.type,
|
|
11714
12168
|
name: payload.data.name,
|
|
12169
|
+
...(payload.data.description !== undefined
|
|
12170
|
+
? {
|
|
12171
|
+
description: payload.data.description,
|
|
12172
|
+
}
|
|
12173
|
+
: {}),
|
|
11715
12174
|
...(payload.data.type === "folder"
|
|
11716
12175
|
? {}
|
|
11717
12176
|
: {
|
|
@@ -11723,7 +12182,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11723
12182
|
validateUpdateState: ({ payload, currentItem }) => {
|
|
11724
12183
|
if (
|
|
11725
12184
|
currentItem.type === "folder" &&
|
|
11726
|
-
Object.keys(payload.data).some(
|
|
12185
|
+
Object.keys(payload.data).some(
|
|
12186
|
+
(key) => key !== "name" && key !== "description",
|
|
12187
|
+
)
|
|
11727
12188
|
) {
|
|
11728
12189
|
return invalidPrecondition(
|
|
11729
12190
|
"folder variable items cannot update variable fields",
|
|
@@ -11795,7 +12256,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11795
12256
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11796
12257
|
if (
|
|
11797
12258
|
currentItem.type === "folder" &&
|
|
11798
|
-
Object.keys(payload.data).some(
|
|
12259
|
+
Object.keys(payload.data).some(
|
|
12260
|
+
(key) => key !== "name" && key !== "description",
|
|
12261
|
+
)
|
|
11799
12262
|
) {
|
|
11800
12263
|
return invalidPrecondition(
|
|
11801
12264
|
"folder text style items cannot update text style fields",
|
|
@@ -11831,14 +12294,14 @@ const COMMAND_DEFINITIONS = [
|
|
|
11831
12294
|
name: payload.data.name,
|
|
11832
12295
|
};
|
|
11833
12296
|
|
|
11834
|
-
if (item.type !== "character") {
|
|
11835
|
-
return item;
|
|
11836
|
-
}
|
|
11837
|
-
|
|
11838
12297
|
if (payload.data.description !== undefined) {
|
|
11839
12298
|
item.description = payload.data.description;
|
|
11840
12299
|
}
|
|
11841
12300
|
|
|
12301
|
+
if (item.type !== "character") {
|
|
12302
|
+
return item;
|
|
12303
|
+
}
|
|
12304
|
+
|
|
11842
12305
|
if (payload.data.shortcut !== undefined) {
|
|
11843
12306
|
item.shortcut = payload.data.shortcut;
|
|
11844
12307
|
}
|
|
@@ -11924,7 +12387,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11924
12387
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11925
12388
|
if (
|
|
11926
12389
|
currentItem.type === "folder" &&
|
|
11927
|
-
Object.keys(payload.data).some(
|
|
12390
|
+
Object.keys(payload.data).some(
|
|
12391
|
+
(key) => key !== "name" && key !== "description",
|
|
12392
|
+
)
|
|
11928
12393
|
) {
|
|
11929
12394
|
return invalidPrecondition(
|
|
11930
12395
|
"folder character items cannot update character fields",
|
|
@@ -11957,9 +12422,13 @@ const COMMAND_DEFINITIONS = [
|
|
|
11957
12422
|
id: payload.layoutId,
|
|
11958
12423
|
type: payload.data.type,
|
|
11959
12424
|
name: payload.data.name,
|
|
11960
|
-
...(payload.data.
|
|
12425
|
+
...(payload.data.description !== undefined
|
|
11961
12426
|
? {
|
|
11962
12427
|
description: payload.data.description,
|
|
12428
|
+
}
|
|
12429
|
+
: {}),
|
|
12430
|
+
...(payload.data.type === "layout"
|
|
12431
|
+
? {
|
|
11963
12432
|
layoutType: payload.data.layoutType,
|
|
11964
12433
|
isFragment: payload.data.isFragment,
|
|
11965
12434
|
...(payload.data.thumbnailFileId !== undefined
|
|
@@ -11988,7 +12457,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11988
12457
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11989
12458
|
if (
|
|
11990
12459
|
currentItem.type === "folder" &&
|
|
11991
|
-
Object.keys(payload.data).some(
|
|
12460
|
+
Object.keys(payload.data).some(
|
|
12461
|
+
(key) => key !== "name" && key !== "description",
|
|
12462
|
+
)
|
|
11992
12463
|
) {
|
|
11993
12464
|
return invalidPrecondition(
|
|
11994
12465
|
"folder layout items cannot update layout fields",
|
|
@@ -12018,6 +12489,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
12018
12489
|
id: payload.controlId,
|
|
12019
12490
|
type: payload.data.type,
|
|
12020
12491
|
name: payload.data.name,
|
|
12492
|
+
...(payload.data.description !== undefined
|
|
12493
|
+
? {
|
|
12494
|
+
description: payload.data.description,
|
|
12495
|
+
}
|
|
12496
|
+
: {}),
|
|
12021
12497
|
...(payload.data.type === "control"
|
|
12022
12498
|
? {
|
|
12023
12499
|
...(payload.data.thumbnailFileId !== undefined
|
|
@@ -12051,7 +12527,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
12051
12527
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
12052
12528
|
if (
|
|
12053
12529
|
currentItem.type === "folder" &&
|
|
12054
|
-
Object.keys(payload.data).some(
|
|
12530
|
+
Object.keys(payload.data).some(
|
|
12531
|
+
(key) => key !== "name" && key !== "description",
|
|
12532
|
+
)
|
|
12055
12533
|
) {
|
|
12056
12534
|
return invalidPrecondition(
|
|
12057
12535
|
"folder control items cannot update control fields",
|
|
@@ -12273,7 +12751,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
12273
12751
|
|
|
12274
12752
|
if (
|
|
12275
12753
|
currentItem.type === "folder" &&
|
|
12276
|
-
Object.keys(payload.data).some(
|
|
12754
|
+
Object.keys(payload.data).some(
|
|
12755
|
+
(key) => key !== "name" && key !== "description",
|
|
12756
|
+
)
|
|
12277
12757
|
) {
|
|
12278
12758
|
return invalidPrecondition(
|
|
12279
12759
|
"folder sprite items cannot update image fields",
|