@routevn/creator-model 1.1.8 → 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 +555 -78
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -1072,11 +1072,8 @@ const validateVideoItems = ({ items, path, errorFactory }) => {
|
|
|
1072
1072
|
};
|
|
1073
1073
|
|
|
1074
1074
|
const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
|
|
1075
|
-
if (!Array.isArray(keyframes)
|
|
1076
|
-
return invalidFromErrorFactory(
|
|
1077
|
-
errorFactory,
|
|
1078
|
-
`${path} must be a non-empty array`,
|
|
1079
|
-
);
|
|
1075
|
+
if (!Array.isArray(keyframes)) {
|
|
1076
|
+
return invalidFromErrorFactory(errorFactory, `${path} must be an array`);
|
|
1080
1077
|
}
|
|
1081
1078
|
|
|
1082
1079
|
for (const [index, keyframe] of keyframes.entries()) {
|
|
@@ -1144,7 +1141,12 @@ const validateAnimationKeyframes = ({ keyframes, path, errorFactory }) => {
|
|
|
1144
1141
|
}
|
|
1145
1142
|
};
|
|
1146
1143
|
|
|
1147
|
-
const validateTweenProperty = ({
|
|
1144
|
+
const validateTweenProperty = ({
|
|
1145
|
+
config,
|
|
1146
|
+
path,
|
|
1147
|
+
allowEmptyKeyframes = false,
|
|
1148
|
+
errorFactory,
|
|
1149
|
+
}) => {
|
|
1148
1150
|
{
|
|
1149
1151
|
const result = validateAllowedKeys({
|
|
1150
1152
|
value: config,
|
|
@@ -1184,6 +1186,13 @@ const validateTweenProperty = ({ config, path, errorFactory }) => {
|
|
|
1184
1186
|
return result;
|
|
1185
1187
|
}
|
|
1186
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
|
+
}
|
|
1187
1196
|
};
|
|
1188
1197
|
|
|
1189
1198
|
const validateTweenDefinition = ({
|
|
@@ -1191,6 +1200,7 @@ const validateTweenDefinition = ({
|
|
|
1191
1200
|
allowedProperties,
|
|
1192
1201
|
path,
|
|
1193
1202
|
unsupportedMessage,
|
|
1203
|
+
allowEmptyKeyframes = false,
|
|
1194
1204
|
errorFactory,
|
|
1195
1205
|
}) => {
|
|
1196
1206
|
if (!isPlainObject(tween)) {
|
|
@@ -1218,6 +1228,7 @@ const validateTweenDefinition = ({
|
|
|
1218
1228
|
const result = validateTweenProperty({
|
|
1219
1229
|
config,
|
|
1220
1230
|
path: propertyPath,
|
|
1231
|
+
allowEmptyKeyframes,
|
|
1221
1232
|
errorFactory,
|
|
1222
1233
|
});
|
|
1223
1234
|
if (result?.valid === false) {
|
|
@@ -1233,6 +1244,8 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1233
1244
|
value: mask,
|
|
1234
1245
|
allowedKeys: [
|
|
1235
1246
|
"kind",
|
|
1247
|
+
"imageId",
|
|
1248
|
+
"imageIds",
|
|
1236
1249
|
"texture",
|
|
1237
1250
|
"textures",
|
|
1238
1251
|
"items",
|
|
@@ -1242,6 +1255,8 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1242
1255
|
"invert",
|
|
1243
1256
|
"sample",
|
|
1244
1257
|
"progress",
|
|
1258
|
+
"progressDuration",
|
|
1259
|
+
"progressEasing",
|
|
1245
1260
|
],
|
|
1246
1261
|
path,
|
|
1247
1262
|
errorFactory,
|
|
@@ -1276,6 +1291,13 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1276
1291
|
);
|
|
1277
1292
|
}
|
|
1278
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
|
+
|
|
1279
1301
|
if (mask.textures !== undefined) {
|
|
1280
1302
|
if (!Array.isArray(mask.textures) || mask.textures.length === 0) {
|
|
1281
1303
|
return invalidFromErrorFactory(
|
|
@@ -1294,6 +1316,24 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1294
1316
|
}
|
|
1295
1317
|
}
|
|
1296
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
|
+
|
|
1297
1337
|
if (mask.items !== undefined) {
|
|
1298
1338
|
if (!Array.isArray(mask.items) || mask.items.length === 0) {
|
|
1299
1339
|
return invalidFromErrorFactory(
|
|
@@ -1308,7 +1348,7 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1308
1348
|
{
|
|
1309
1349
|
const result = validateAllowedKeys({
|
|
1310
1350
|
value: item,
|
|
1311
|
-
allowedKeys: ["texture", "channel", "invert"],
|
|
1351
|
+
allowedKeys: ["texture", "imageId", "channel", "invert"],
|
|
1312
1352
|
path: itemPath,
|
|
1313
1353
|
errorFactory,
|
|
1314
1354
|
});
|
|
@@ -1317,10 +1357,33 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1317
1357
|
}
|
|
1318
1358
|
}
|
|
1319
1359
|
|
|
1320
|
-
if (
|
|
1360
|
+
if (
|
|
1361
|
+
item.texture !== undefined &&
|
|
1362
|
+
!isNonEmptyString(item.texture)
|
|
1363
|
+
) {
|
|
1321
1364
|
return invalidFromErrorFactory(
|
|
1322
1365
|
errorFactory,
|
|
1323
|
-
`${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`,
|
|
1324
1387
|
);
|
|
1325
1388
|
}
|
|
1326
1389
|
|
|
@@ -1391,17 +1454,45 @@ const validateMaskDefinition = ({ mask, path, errorFactory }) => {
|
|
|
1391
1454
|
}
|
|
1392
1455
|
}
|
|
1393
1456
|
|
|
1394
|
-
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
|
+
) {
|
|
1395
1471
|
return invalidFromErrorFactory(
|
|
1396
1472
|
errorFactory,
|
|
1397
|
-
`${path}.
|
|
1473
|
+
`${path}.progressEasing must be a supported Route Graphics easing`,
|
|
1398
1474
|
);
|
|
1399
1475
|
}
|
|
1400
1476
|
|
|
1401
|
-
if (
|
|
1477
|
+
if (
|
|
1478
|
+
mask.kind === "single" &&
|
|
1479
|
+
!isNonEmptyString(mask.texture) &&
|
|
1480
|
+
!isNonEmptyString(mask.imageId)
|
|
1481
|
+
) {
|
|
1402
1482
|
return invalidFromErrorFactory(
|
|
1403
1483
|
errorFactory,
|
|
1404
|
-
`${path}.
|
|
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
|
+
) {
|
|
1493
|
+
return invalidFromErrorFactory(
|
|
1494
|
+
errorFactory,
|
|
1495
|
+
`${path}.textures or ${path}.imageIds is required when ${path}.kind is 'sequence'`,
|
|
1405
1496
|
);
|
|
1406
1497
|
}
|
|
1407
1498
|
|
|
@@ -1516,6 +1607,7 @@ const validateAnimationDefinition = ({ animation, path, errorFactory }) => {
|
|
|
1516
1607
|
allowedProperties: TRANSITION_TWEEN_PROPERTY_KEYS,
|
|
1517
1608
|
path: `${path}.${side}.tween`,
|
|
1518
1609
|
unsupportedMessage: "is not a supported transition tween property",
|
|
1610
|
+
allowEmptyKeyframes: true,
|
|
1519
1611
|
errorFactory,
|
|
1520
1612
|
});
|
|
1521
1613
|
if (result?.valid === false) {
|
|
@@ -1554,8 +1646,8 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
|
|
|
1554
1646
|
value: item,
|
|
1555
1647
|
allowedKeys:
|
|
1556
1648
|
item.type === "folder"
|
|
1557
|
-
? ["id", "type", "name"]
|
|
1558
|
-
: ["id", "type", "name", "animation"],
|
|
1649
|
+
? ["id", "type", "name", "description"]
|
|
1650
|
+
: ["id", "type", "name", "description", "animation"],
|
|
1559
1651
|
path: itemPath,
|
|
1560
1652
|
errorFactory,
|
|
1561
1653
|
});
|
|
@@ -1585,6 +1677,13 @@ const validateAnimationItems = ({ items, path, errorFactory }) => {
|
|
|
1585
1677
|
);
|
|
1586
1678
|
}
|
|
1587
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
|
+
|
|
1588
1687
|
if (item.type === "animation") {
|
|
1589
1688
|
{
|
|
1590
1689
|
const result = validateAnimationDefinition({
|
|
@@ -1616,11 +1715,12 @@ const validateFontItems = ({ items, path, errorFactory }) => {
|
|
|
1616
1715
|
value: item,
|
|
1617
1716
|
allowedKeys:
|
|
1618
1717
|
item.type === "folder"
|
|
1619
|
-
? ["id", "type", "name"]
|
|
1718
|
+
? ["id", "type", "name", "description"]
|
|
1620
1719
|
: [
|
|
1621
1720
|
"id",
|
|
1622
1721
|
"type",
|
|
1623
1722
|
"name",
|
|
1723
|
+
"description",
|
|
1624
1724
|
"fileId",
|
|
1625
1725
|
"fontFamily",
|
|
1626
1726
|
"fileType",
|
|
@@ -1655,6 +1755,13 @@ const validateFontItems = ({ items, path, errorFactory }) => {
|
|
|
1655
1755
|
);
|
|
1656
1756
|
}
|
|
1657
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
|
+
|
|
1658
1765
|
if (item.type === "font") {
|
|
1659
1766
|
if (!isNonEmptyString(item.fileId)) {
|
|
1660
1767
|
return invalidFromErrorFactory(
|
|
@@ -1703,8 +1810,8 @@ const validateColorItems = ({ items, path, errorFactory }) => {
|
|
|
1703
1810
|
value: item,
|
|
1704
1811
|
allowedKeys:
|
|
1705
1812
|
item.type === "folder"
|
|
1706
|
-
? ["id", "type", "name"]
|
|
1707
|
-
: ["id", "type", "name", "hex"],
|
|
1813
|
+
? ["id", "type", "name", "description"]
|
|
1814
|
+
: ["id", "type", "name", "description", "hex"],
|
|
1708
1815
|
path: itemPath,
|
|
1709
1816
|
errorFactory,
|
|
1710
1817
|
});
|
|
@@ -1734,6 +1841,13 @@ const validateColorItems = ({ items, path, errorFactory }) => {
|
|
|
1734
1841
|
);
|
|
1735
1842
|
}
|
|
1736
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
|
+
|
|
1737
1851
|
if (item.type === "color" && !isHexColor(item.hex)) {
|
|
1738
1852
|
return invalidFromErrorFactory(
|
|
1739
1853
|
errorFactory,
|
|
@@ -1759,11 +1873,12 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
|
|
|
1759
1873
|
value: item,
|
|
1760
1874
|
allowedKeys:
|
|
1761
1875
|
item.type === "folder"
|
|
1762
|
-
? ["id", "type", "name"]
|
|
1876
|
+
? ["id", "type", "name", "description"]
|
|
1763
1877
|
: [
|
|
1764
1878
|
"id",
|
|
1765
1879
|
"type",
|
|
1766
1880
|
"name",
|
|
1881
|
+
"description",
|
|
1767
1882
|
"x",
|
|
1768
1883
|
"y",
|
|
1769
1884
|
"scaleX",
|
|
@@ -1801,6 +1916,13 @@ const validateTransformItems = ({ items, path, errorFactory }) => {
|
|
|
1801
1916
|
);
|
|
1802
1917
|
}
|
|
1803
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
|
+
|
|
1804
1926
|
if (item.type === "transform") {
|
|
1805
1927
|
for (const key of [
|
|
1806
1928
|
"x",
|
|
@@ -1864,8 +1986,8 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
|
|
|
1864
1986
|
value: item,
|
|
1865
1987
|
allowedKeys:
|
|
1866
1988
|
variableType === "folder"
|
|
1867
|
-
? ["id", "type", "name"]
|
|
1868
|
-
: ["id", "type", "name", "scope", "default", "value"],
|
|
1989
|
+
? ["id", "type", "name", "description"]
|
|
1990
|
+
: ["id", "type", "name", "description", "scope", "default", "value"],
|
|
1869
1991
|
path: itemPath,
|
|
1870
1992
|
errorFactory,
|
|
1871
1993
|
});
|
|
@@ -1895,6 +2017,13 @@ const validateVariableItems = ({ items, path, errorFactory }) => {
|
|
|
1895
2017
|
);
|
|
1896
2018
|
}
|
|
1897
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
|
+
|
|
1898
2027
|
if (variableType !== "folder") {
|
|
1899
2028
|
if (!VARIABLE_SCOPE_KEYS.includes(item.scope)) {
|
|
1900
2029
|
return invalidFromErrorFactory(
|
|
@@ -1945,11 +2074,12 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
|
1945
2074
|
value: item,
|
|
1946
2075
|
allowedKeys:
|
|
1947
2076
|
item.type === "folder"
|
|
1948
|
-
? ["id", "type", "name"]
|
|
2077
|
+
? ["id", "type", "name", "description"]
|
|
1949
2078
|
: [
|
|
1950
2079
|
"id",
|
|
1951
2080
|
"type",
|
|
1952
2081
|
"name",
|
|
2082
|
+
"description",
|
|
1953
2083
|
"fontId",
|
|
1954
2084
|
"colorId",
|
|
1955
2085
|
"fontSize",
|
|
@@ -1994,6 +2124,13 @@ const validateTextStyleItems = ({ items, path, errorFactory }) => {
|
|
|
1994
2124
|
);
|
|
1995
2125
|
}
|
|
1996
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
|
+
|
|
1997
2134
|
if (item.type === "textStyle") {
|
|
1998
2135
|
if (!isNonEmptyString(item.fontId)) {
|
|
1999
2136
|
return invalidFromErrorFactory(
|
|
@@ -2124,11 +2261,12 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
|
|
|
2124
2261
|
value: item,
|
|
2125
2262
|
allowedKeys:
|
|
2126
2263
|
item.type === "folder"
|
|
2127
|
-
? ["id", "type", "name"]
|
|
2264
|
+
? ["id", "type", "name", "description"]
|
|
2128
2265
|
: [
|
|
2129
2266
|
"id",
|
|
2130
2267
|
"type",
|
|
2131
2268
|
"name",
|
|
2269
|
+
"description",
|
|
2132
2270
|
"thumbnailFileId",
|
|
2133
2271
|
"fileId",
|
|
2134
2272
|
"fileType",
|
|
@@ -2165,6 +2303,13 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
|
|
|
2165
2303
|
);
|
|
2166
2304
|
}
|
|
2167
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
|
+
|
|
2168
2313
|
if (item.type === "image") {
|
|
2169
2314
|
if (
|
|
2170
2315
|
item.thumbnailFileId !== undefined &&
|
|
@@ -2910,7 +3055,7 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
2910
3055
|
value: item,
|
|
2911
3056
|
allowedKeys:
|
|
2912
3057
|
item.type === "folder"
|
|
2913
|
-
? ["id", "type", "name"]
|
|
3058
|
+
? ["id", "type", "name", "description"]
|
|
2914
3059
|
: [
|
|
2915
3060
|
"id",
|
|
2916
3061
|
"type",
|
|
@@ -2951,14 +3096,14 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
2951
3096
|
);
|
|
2952
3097
|
}
|
|
2953
3098
|
|
|
2954
|
-
if (item.
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
}
|
|
3099
|
+
if (item.description !== undefined && !isString(item.description)) {
|
|
3100
|
+
return invalidFromErrorFactory(
|
|
3101
|
+
errorFactory,
|
|
3102
|
+
`${itemPath}.description must be a string when provided`,
|
|
3103
|
+
);
|
|
3104
|
+
}
|
|
2961
3105
|
|
|
3106
|
+
if (item.type === "character") {
|
|
2962
3107
|
if (item.shortcut !== undefined && !isString(item.shortcut)) {
|
|
2963
3108
|
return invalidFromErrorFactory(
|
|
2964
3109
|
errorFactory,
|
|
@@ -3051,7 +3196,7 @@ const validateLayoutItems = ({ items, path, errorFactory }) => {
|
|
|
3051
3196
|
value: item,
|
|
3052
3197
|
allowedKeys:
|
|
3053
3198
|
item.type === "folder"
|
|
3054
|
-
? ["id", "type", "name"]
|
|
3199
|
+
? ["id", "type", "name", "description"]
|
|
3055
3200
|
: [
|
|
3056
3201
|
"id",
|
|
3057
3202
|
"type",
|
|
@@ -3158,8 +3303,16 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
3158
3303
|
value: item,
|
|
3159
3304
|
allowedKeys:
|
|
3160
3305
|
item.type === "folder"
|
|
3161
|
-
? ["id", "type", "name"]
|
|
3162
|
-
: [
|
|
3306
|
+
? ["id", "type", "name", "description"]
|
|
3307
|
+
: [
|
|
3308
|
+
"id",
|
|
3309
|
+
"type",
|
|
3310
|
+
"name",
|
|
3311
|
+
"description",
|
|
3312
|
+
"thumbnailFileId",
|
|
3313
|
+
"elements",
|
|
3314
|
+
"keyboard",
|
|
3315
|
+
],
|
|
3163
3316
|
path: itemPath,
|
|
3164
3317
|
errorFactory,
|
|
3165
3318
|
});
|
|
@@ -3189,6 +3342,13 @@ const validateControlItems = ({ items, path, errorFactory }) => {
|
|
|
3189
3342
|
);
|
|
3190
3343
|
}
|
|
3191
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
|
+
|
|
3192
3352
|
if (
|
|
3193
3353
|
item.thumbnailFileId !== undefined &&
|
|
3194
3354
|
!isNonEmptyString(item.thumbnailFileId)
|
|
@@ -3999,6 +4159,108 @@ const validateFileReference = ({
|
|
|
3999
4159
|
return VALID_RESULT;
|
|
4000
4160
|
};
|
|
4001
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
|
+
|
|
4002
4264
|
export const assertInvariants = ({ state }) => {
|
|
4003
4265
|
if (!isPlainObject(state)) {
|
|
4004
4266
|
return invalidInvariant("state must be an object");
|
|
@@ -4228,6 +4490,23 @@ export const assertInvariants = ({ state }) => {
|
|
|
4228
4490
|
}
|
|
4229
4491
|
}
|
|
4230
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
|
+
|
|
4231
4510
|
for (const [characterId, character] of Object.entries(
|
|
4232
4511
|
state.characters.items,
|
|
4233
4512
|
)) {
|
|
@@ -5553,8 +5832,16 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
5553
5832
|
value: data,
|
|
5554
5833
|
allowedKeys:
|
|
5555
5834
|
data.type === "folder"
|
|
5556
|
-
? ["type", "name"]
|
|
5557
|
-
: [
|
|
5835
|
+
? ["type", "name", "description"]
|
|
5836
|
+
: [
|
|
5837
|
+
"type",
|
|
5838
|
+
"name",
|
|
5839
|
+
"description",
|
|
5840
|
+
"fileId",
|
|
5841
|
+
"fontFamily",
|
|
5842
|
+
"fileType",
|
|
5843
|
+
"fileSize",
|
|
5844
|
+
],
|
|
5558
5845
|
path: "payload.data",
|
|
5559
5846
|
errorFactory,
|
|
5560
5847
|
});
|
|
@@ -5570,6 +5857,13 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
5570
5857
|
);
|
|
5571
5858
|
}
|
|
5572
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
|
+
|
|
5573
5867
|
if (data.type === "font") {
|
|
5574
5868
|
if (!isNonEmptyString(data.fileId)) {
|
|
5575
5869
|
return invalidFromErrorFactory(
|
|
@@ -5605,7 +5899,14 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
5605
5899
|
{
|
|
5606
5900
|
const result = validateAllowedKeys({
|
|
5607
5901
|
value: data,
|
|
5608
|
-
allowedKeys: [
|
|
5902
|
+
allowedKeys: [
|
|
5903
|
+
"name",
|
|
5904
|
+
"description",
|
|
5905
|
+
"fileId",
|
|
5906
|
+
"fontFamily",
|
|
5907
|
+
"fileType",
|
|
5908
|
+
"fileSize",
|
|
5909
|
+
],
|
|
5609
5910
|
path: "payload.data",
|
|
5610
5911
|
errorFactory,
|
|
5611
5912
|
});
|
|
@@ -5628,6 +5929,13 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
5628
5929
|
);
|
|
5629
5930
|
}
|
|
5630
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
|
+
|
|
5631
5939
|
if (data.fileId !== undefined && !isNonEmptyString(data.fileId)) {
|
|
5632
5940
|
return invalidFromErrorFactory(
|
|
5633
5941
|
errorFactory,
|
|
@@ -5776,7 +6084,9 @@ const validateColorCreateData = ({ data, errorFactory }) => {
|
|
|
5776
6084
|
const result = validateAllowedKeys({
|
|
5777
6085
|
value: data,
|
|
5778
6086
|
allowedKeys:
|
|
5779
|
-
data.type === "folder"
|
|
6087
|
+
data.type === "folder"
|
|
6088
|
+
? ["type", "name", "description"]
|
|
6089
|
+
: ["type", "name", "description", "hex"],
|
|
5780
6090
|
path: "payload.data",
|
|
5781
6091
|
errorFactory,
|
|
5782
6092
|
});
|
|
@@ -5792,6 +6102,13 @@ const validateColorCreateData = ({ data, errorFactory }) => {
|
|
|
5792
6102
|
);
|
|
5793
6103
|
}
|
|
5794
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
|
+
|
|
5795
6112
|
if (data.type === "color" && !isHexColor(data.hex)) {
|
|
5796
6113
|
return invalidFromErrorFactory(
|
|
5797
6114
|
errorFactory,
|
|
@@ -5804,7 +6121,7 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
|
|
|
5804
6121
|
{
|
|
5805
6122
|
const result = validateAllowedKeys({
|
|
5806
6123
|
value: data,
|
|
5807
|
-
allowedKeys: ["name", "hex"],
|
|
6124
|
+
allowedKeys: ["name", "description", "hex"],
|
|
5808
6125
|
path: "payload.data",
|
|
5809
6126
|
errorFactory,
|
|
5810
6127
|
});
|
|
@@ -5827,6 +6144,13 @@ const validateColorUpdateData = ({ data, errorFactory }) => {
|
|
|
5827
6144
|
);
|
|
5828
6145
|
}
|
|
5829
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
|
+
|
|
5830
6154
|
if (data.hex !== undefined && !isHexColor(data.hex)) {
|
|
5831
6155
|
return invalidFromErrorFactory(
|
|
5832
6156
|
errorFactory,
|
|
@@ -5855,8 +6179,8 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
|
|
|
5855
6179
|
value: data,
|
|
5856
6180
|
allowedKeys:
|
|
5857
6181
|
data.type === "folder"
|
|
5858
|
-
? ["type", "name"]
|
|
5859
|
-
: ["type", "name", "animation"],
|
|
6182
|
+
? ["type", "name", "description"]
|
|
6183
|
+
: ["type", "name", "description", "animation"],
|
|
5860
6184
|
path: "payload.data",
|
|
5861
6185
|
errorFactory,
|
|
5862
6186
|
});
|
|
@@ -5872,6 +6196,13 @@ const validateAnimationCreateData = ({ data, errorFactory }) => {
|
|
|
5872
6196
|
);
|
|
5873
6197
|
}
|
|
5874
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
|
+
|
|
5875
6206
|
if (data.type === "animation") {
|
|
5876
6207
|
{
|
|
5877
6208
|
const result = validateAnimationDefinition({
|
|
@@ -5890,7 +6221,7 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
|
|
|
5890
6221
|
{
|
|
5891
6222
|
const result = validateAllowedKeys({
|
|
5892
6223
|
value: data,
|
|
5893
|
-
allowedKeys: ["name", "animation"],
|
|
6224
|
+
allowedKeys: ["name", "description", "animation"],
|
|
5894
6225
|
path: "payload.data",
|
|
5895
6226
|
errorFactory,
|
|
5896
6227
|
});
|
|
@@ -5913,6 +6244,13 @@ const validateAnimationUpdateData = ({ data, errorFactory }) => {
|
|
|
5913
6244
|
);
|
|
5914
6245
|
}
|
|
5915
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
|
+
|
|
5916
6254
|
if (data.animation !== undefined) {
|
|
5917
6255
|
{
|
|
5918
6256
|
const result = validateAnimationDefinition({
|
|
@@ -5947,10 +6285,11 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
|
|
|
5947
6285
|
value: data,
|
|
5948
6286
|
allowedKeys:
|
|
5949
6287
|
data.type === "folder"
|
|
5950
|
-
? ["type", "name"]
|
|
6288
|
+
? ["type", "name", "description"]
|
|
5951
6289
|
: [
|
|
5952
6290
|
"type",
|
|
5953
6291
|
"name",
|
|
6292
|
+
"description",
|
|
5954
6293
|
"x",
|
|
5955
6294
|
"y",
|
|
5956
6295
|
"scaleX",
|
|
@@ -5974,6 +6313,13 @@ const validateTransformCreateData = ({ data, errorFactory }) => {
|
|
|
5974
6313
|
);
|
|
5975
6314
|
}
|
|
5976
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
|
+
|
|
5977
6323
|
if (data.type === "transform") {
|
|
5978
6324
|
for (const key of [
|
|
5979
6325
|
"x",
|
|
@@ -6000,6 +6346,7 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
|
|
|
6000
6346
|
value: data,
|
|
6001
6347
|
allowedKeys: [
|
|
6002
6348
|
"name",
|
|
6349
|
+
"description",
|
|
6003
6350
|
"x",
|
|
6004
6351
|
"y",
|
|
6005
6352
|
"scaleX",
|
|
@@ -6030,6 +6377,13 @@ const validateTransformUpdateData = ({ data, errorFactory }) => {
|
|
|
6030
6377
|
);
|
|
6031
6378
|
}
|
|
6032
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
|
+
|
|
6033
6387
|
for (const key of [
|
|
6034
6388
|
"x",
|
|
6035
6389
|
"y",
|
|
@@ -6068,8 +6422,8 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
|
|
|
6068
6422
|
value: data,
|
|
6069
6423
|
allowedKeys:
|
|
6070
6424
|
data.type === "folder"
|
|
6071
|
-
? ["type", "name"]
|
|
6072
|
-
: ["type", "name", "scope", "default", "value"],
|
|
6425
|
+
? ["type", "name", "description"]
|
|
6426
|
+
: ["type", "name", "description", "scope", "default", "value"],
|
|
6073
6427
|
path: "payload.data",
|
|
6074
6428
|
errorFactory,
|
|
6075
6429
|
});
|
|
@@ -6085,6 +6439,13 @@ const validateVariableCreateData = ({ data, errorFactory }) => {
|
|
|
6085
6439
|
);
|
|
6086
6440
|
}
|
|
6087
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
|
+
|
|
6088
6449
|
if (data.type !== "folder") {
|
|
6089
6450
|
if (!VARIABLE_SCOPE_KEYS.includes(data.scope)) {
|
|
6090
6451
|
return invalidFromErrorFactory(
|
|
@@ -6122,7 +6483,7 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
|
|
|
6122
6483
|
{
|
|
6123
6484
|
const result = validateAllowedKeys({
|
|
6124
6485
|
value: data,
|
|
6125
|
-
allowedKeys: ["name", "scope", "default", "value"],
|
|
6486
|
+
allowedKeys: ["name", "description", "scope", "default", "value"],
|
|
6126
6487
|
path: "payload.data",
|
|
6127
6488
|
errorFactory,
|
|
6128
6489
|
});
|
|
@@ -6145,6 +6506,13 @@ const validateVariableUpdateData = ({ data, errorFactory }) => {
|
|
|
6145
6506
|
);
|
|
6146
6507
|
}
|
|
6147
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
|
+
|
|
6148
6516
|
if (data.scope !== undefined && !VARIABLE_SCOPE_KEYS.includes(data.scope)) {
|
|
6149
6517
|
return invalidFromErrorFactory(
|
|
6150
6518
|
errorFactory,
|
|
@@ -6173,10 +6541,11 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
6173
6541
|
value: data,
|
|
6174
6542
|
allowedKeys:
|
|
6175
6543
|
data.type === "folder"
|
|
6176
|
-
? ["type", "name"]
|
|
6544
|
+
? ["type", "name", "description"]
|
|
6177
6545
|
: [
|
|
6178
6546
|
"type",
|
|
6179
6547
|
"name",
|
|
6548
|
+
"description",
|
|
6180
6549
|
"fontId",
|
|
6181
6550
|
"colorId",
|
|
6182
6551
|
"fontSize",
|
|
@@ -6207,6 +6576,13 @@ const validateTextStyleCreateData = ({ data, errorFactory }) => {
|
|
|
6207
6576
|
);
|
|
6208
6577
|
}
|
|
6209
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
|
+
|
|
6210
6586
|
if (data.type === "textStyle") {
|
|
6211
6587
|
{
|
|
6212
6588
|
const result = validateTextStyleItems({
|
|
@@ -6232,6 +6608,7 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
6232
6608
|
value: data,
|
|
6233
6609
|
allowedKeys: [
|
|
6234
6610
|
"name",
|
|
6611
|
+
"description",
|
|
6235
6612
|
"fontId",
|
|
6236
6613
|
"colorId",
|
|
6237
6614
|
"fontSize",
|
|
@@ -6269,6 +6646,13 @@ const validateTextStyleUpdateData = ({ data, errorFactory }) => {
|
|
|
6269
6646
|
);
|
|
6270
6647
|
}
|
|
6271
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
|
+
|
|
6272
6656
|
for (const key of ["fontId", "colorId", "strokeColorId"]) {
|
|
6273
6657
|
if (data[key] !== undefined && !isNonEmptyString(data[key])) {
|
|
6274
6658
|
return invalidFromErrorFactory(
|
|
@@ -6352,6 +6736,7 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6352
6736
|
: [
|
|
6353
6737
|
"type",
|
|
6354
6738
|
"name",
|
|
6739
|
+
"description",
|
|
6355
6740
|
"fileId",
|
|
6356
6741
|
"thumbnailFileId",
|
|
6357
6742
|
"fileType",
|
|
@@ -6374,6 +6759,13 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6374
6759
|
);
|
|
6375
6760
|
}
|
|
6376
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
|
+
|
|
6377
6769
|
if (data.type === "image") {
|
|
6378
6770
|
if (!isNonEmptyString(data.fileId)) {
|
|
6379
6771
|
return invalidFromErrorFactory(
|
|
@@ -6419,13 +6811,6 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
6419
6811
|
"payload.data.height must be a finite number when provided",
|
|
6420
6812
|
);
|
|
6421
6813
|
}
|
|
6422
|
-
|
|
6423
|
-
if (data.description !== undefined && !isString(data.description)) {
|
|
6424
|
-
return invalidFromErrorFactory(
|
|
6425
|
-
errorFactory,
|
|
6426
|
-
"payload.data.description must be a string when provided",
|
|
6427
|
-
);
|
|
6428
|
-
}
|
|
6429
6814
|
}
|
|
6430
6815
|
};
|
|
6431
6816
|
|
|
@@ -6538,7 +6923,7 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
6538
6923
|
value: data,
|
|
6539
6924
|
allowedKeys:
|
|
6540
6925
|
data.type === "folder"
|
|
6541
|
-
? ["type", "name"]
|
|
6926
|
+
? ["type", "name", "description"]
|
|
6542
6927
|
: [
|
|
6543
6928
|
"type",
|
|
6544
6929
|
"name",
|
|
@@ -6564,14 +6949,14 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
6564
6949
|
);
|
|
6565
6950
|
}
|
|
6566
6951
|
|
|
6567
|
-
if (data.
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
|
|
6573
|
-
}
|
|
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
|
+
}
|
|
6574
6958
|
|
|
6959
|
+
if (data.type === "character") {
|
|
6575
6960
|
if (data.shortcut !== undefined && !isString(data.shortcut)) {
|
|
6576
6961
|
return invalidFromErrorFactory(
|
|
6577
6962
|
errorFactory,
|
|
@@ -6708,7 +7093,7 @@ const validateLayoutCreateData = ({ data, errorFactory }) => {
|
|
|
6708
7093
|
value: data,
|
|
6709
7094
|
allowedKeys:
|
|
6710
7095
|
data.type === "folder"
|
|
6711
|
-
? ["type", "name"]
|
|
7096
|
+
? ["type", "name", "description"]
|
|
6712
7097
|
: [
|
|
6713
7098
|
"type",
|
|
6714
7099
|
"name",
|
|
@@ -6868,8 +7253,15 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
6868
7253
|
value: data,
|
|
6869
7254
|
allowedKeys:
|
|
6870
7255
|
data.type === "folder"
|
|
6871
|
-
? ["type", "name"]
|
|
6872
|
-
: [
|
|
7256
|
+
? ["type", "name", "description"]
|
|
7257
|
+
: [
|
|
7258
|
+
"type",
|
|
7259
|
+
"name",
|
|
7260
|
+
"description",
|
|
7261
|
+
"thumbnailFileId",
|
|
7262
|
+
"elements",
|
|
7263
|
+
"keyboard",
|
|
7264
|
+
],
|
|
6873
7265
|
path: "payload.data",
|
|
6874
7266
|
errorFactory,
|
|
6875
7267
|
});
|
|
@@ -6885,6 +7277,13 @@ const validateControlCreateData = ({ data, errorFactory }) => {
|
|
|
6885
7277
|
);
|
|
6886
7278
|
}
|
|
6887
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
|
+
|
|
6888
7287
|
if (
|
|
6889
7288
|
data.thumbnailFileId !== undefined &&
|
|
6890
7289
|
!isNonEmptyString(data.thumbnailFileId)
|
|
@@ -6926,7 +7325,7 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
6926
7325
|
{
|
|
6927
7326
|
const result = validateAllowedKeys({
|
|
6928
7327
|
value: data,
|
|
6929
|
-
allowedKeys: ["name", "keyboard", "thumbnailFileId"],
|
|
7328
|
+
allowedKeys: ["name", "description", "keyboard", "thumbnailFileId"],
|
|
6930
7329
|
path: "payload.data",
|
|
6931
7330
|
errorFactory,
|
|
6932
7331
|
});
|
|
@@ -6949,6 +7348,13 @@ const validateControlUpdateData = ({ data, errorFactory }) => {
|
|
|
6949
7348
|
);
|
|
6950
7349
|
}
|
|
6951
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
|
+
|
|
6952
7358
|
if (
|
|
6953
7359
|
data.thumbnailFileId !== undefined &&
|
|
6954
7360
|
!isNonEmptyString(data.thumbnailFileId)
|
|
@@ -10614,6 +11020,19 @@ const COMMAND_DEFINITIONS = [
|
|
|
10614
11020
|
);
|
|
10615
11021
|
}
|
|
10616
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
|
+
}
|
|
10617
11036
|
},
|
|
10618
11037
|
reduce: ({ state, payload }) => {
|
|
10619
11038
|
const nextAnimation = {
|
|
@@ -10622,6 +11041,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
10622
11041
|
name: payload.data.name,
|
|
10623
11042
|
};
|
|
10624
11043
|
|
|
11044
|
+
if (payload.data.description !== undefined) {
|
|
11045
|
+
nextAnimation.description = payload.data.description;
|
|
11046
|
+
}
|
|
11047
|
+
|
|
10625
11048
|
if (payload.data.type === "animation") {
|
|
10626
11049
|
nextAnimation.animation = structuredClone(payload.data.animation);
|
|
10627
11050
|
}
|
|
@@ -10688,6 +11111,19 @@ const COMMAND_DEFINITIONS = [
|
|
|
10688
11111
|
"folder animation items cannot update animation fields",
|
|
10689
11112
|
);
|
|
10690
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
|
+
}
|
|
10691
11127
|
},
|
|
10692
11128
|
reduce: ({ state, payload }) => {
|
|
10693
11129
|
const currentAnimation = state.animations.items[payload.animationId];
|
|
@@ -11008,6 +11444,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
11008
11444
|
name: payload.data.name,
|
|
11009
11445
|
};
|
|
11010
11446
|
|
|
11447
|
+
if (payload.data.description !== undefined) {
|
|
11448
|
+
nextFont.description = payload.data.description;
|
|
11449
|
+
}
|
|
11450
|
+
|
|
11011
11451
|
if (payload.data.type === "font") {
|
|
11012
11452
|
nextFont.fileId = payload.data.fileId;
|
|
11013
11453
|
nextFont.fontFamily = payload.data.fontFamily;
|
|
@@ -11404,6 +11844,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
11404
11844
|
name: payload.data.name,
|
|
11405
11845
|
};
|
|
11406
11846
|
|
|
11847
|
+
if (payload.data.description !== undefined) {
|
|
11848
|
+
nextColor.description = payload.data.description;
|
|
11849
|
+
}
|
|
11850
|
+
|
|
11407
11851
|
if (payload.data.type === "color") {
|
|
11408
11852
|
nextColor.hex = payload.data.hex;
|
|
11409
11853
|
}
|
|
@@ -11681,6 +12125,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
11681
12125
|
id: payload.transformId,
|
|
11682
12126
|
type: payload.data.type,
|
|
11683
12127
|
name: payload.data.name,
|
|
12128
|
+
...(payload.data.description !== undefined
|
|
12129
|
+
? {
|
|
12130
|
+
description: payload.data.description,
|
|
12131
|
+
}
|
|
12132
|
+
: {}),
|
|
11684
12133
|
...(payload.data.type === "transform"
|
|
11685
12134
|
? {
|
|
11686
12135
|
x: payload.data.x,
|
|
@@ -11696,7 +12145,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11696
12145
|
validateUpdateState: ({ payload, currentItem }) => {
|
|
11697
12146
|
if (
|
|
11698
12147
|
currentItem.type === "folder" &&
|
|
11699
|
-
Object.keys(payload.data).some(
|
|
12148
|
+
Object.keys(payload.data).some(
|
|
12149
|
+
(key) => key !== "name" && key !== "description",
|
|
12150
|
+
)
|
|
11700
12151
|
) {
|
|
11701
12152
|
return invalidPrecondition(
|
|
11702
12153
|
"folder transform items cannot update transform fields",
|
|
@@ -11715,6 +12166,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
11715
12166
|
id: payload.variableId,
|
|
11716
12167
|
type: payload.data.type,
|
|
11717
12168
|
name: payload.data.name,
|
|
12169
|
+
...(payload.data.description !== undefined
|
|
12170
|
+
? {
|
|
12171
|
+
description: payload.data.description,
|
|
12172
|
+
}
|
|
12173
|
+
: {}),
|
|
11718
12174
|
...(payload.data.type === "folder"
|
|
11719
12175
|
? {}
|
|
11720
12176
|
: {
|
|
@@ -11726,7 +12182,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11726
12182
|
validateUpdateState: ({ payload, currentItem }) => {
|
|
11727
12183
|
if (
|
|
11728
12184
|
currentItem.type === "folder" &&
|
|
11729
|
-
Object.keys(payload.data).some(
|
|
12185
|
+
Object.keys(payload.data).some(
|
|
12186
|
+
(key) => key !== "name" && key !== "description",
|
|
12187
|
+
)
|
|
11730
12188
|
) {
|
|
11731
12189
|
return invalidPrecondition(
|
|
11732
12190
|
"folder variable items cannot update variable fields",
|
|
@@ -11798,7 +12256,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11798
12256
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11799
12257
|
if (
|
|
11800
12258
|
currentItem.type === "folder" &&
|
|
11801
|
-
Object.keys(payload.data).some(
|
|
12259
|
+
Object.keys(payload.data).some(
|
|
12260
|
+
(key) => key !== "name" && key !== "description",
|
|
12261
|
+
)
|
|
11802
12262
|
) {
|
|
11803
12263
|
return invalidPrecondition(
|
|
11804
12264
|
"folder text style items cannot update text style fields",
|
|
@@ -11834,14 +12294,14 @@ const COMMAND_DEFINITIONS = [
|
|
|
11834
12294
|
name: payload.data.name,
|
|
11835
12295
|
};
|
|
11836
12296
|
|
|
11837
|
-
if (item.type !== "character") {
|
|
11838
|
-
return item;
|
|
11839
|
-
}
|
|
11840
|
-
|
|
11841
12297
|
if (payload.data.description !== undefined) {
|
|
11842
12298
|
item.description = payload.data.description;
|
|
11843
12299
|
}
|
|
11844
12300
|
|
|
12301
|
+
if (item.type !== "character") {
|
|
12302
|
+
return item;
|
|
12303
|
+
}
|
|
12304
|
+
|
|
11845
12305
|
if (payload.data.shortcut !== undefined) {
|
|
11846
12306
|
item.shortcut = payload.data.shortcut;
|
|
11847
12307
|
}
|
|
@@ -11927,7 +12387,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11927
12387
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11928
12388
|
if (
|
|
11929
12389
|
currentItem.type === "folder" &&
|
|
11930
|
-
Object.keys(payload.data).some(
|
|
12390
|
+
Object.keys(payload.data).some(
|
|
12391
|
+
(key) => key !== "name" && key !== "description",
|
|
12392
|
+
)
|
|
11931
12393
|
) {
|
|
11932
12394
|
return invalidPrecondition(
|
|
11933
12395
|
"folder character items cannot update character fields",
|
|
@@ -11960,9 +12422,13 @@ const COMMAND_DEFINITIONS = [
|
|
|
11960
12422
|
id: payload.layoutId,
|
|
11961
12423
|
type: payload.data.type,
|
|
11962
12424
|
name: payload.data.name,
|
|
11963
|
-
...(payload.data.
|
|
12425
|
+
...(payload.data.description !== undefined
|
|
11964
12426
|
? {
|
|
11965
12427
|
description: payload.data.description,
|
|
12428
|
+
}
|
|
12429
|
+
: {}),
|
|
12430
|
+
...(payload.data.type === "layout"
|
|
12431
|
+
? {
|
|
11966
12432
|
layoutType: payload.data.layoutType,
|
|
11967
12433
|
isFragment: payload.data.isFragment,
|
|
11968
12434
|
...(payload.data.thumbnailFileId !== undefined
|
|
@@ -11991,7 +12457,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
11991
12457
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
11992
12458
|
if (
|
|
11993
12459
|
currentItem.type === "folder" &&
|
|
11994
|
-
Object.keys(payload.data).some(
|
|
12460
|
+
Object.keys(payload.data).some(
|
|
12461
|
+
(key) => key !== "name" && key !== "description",
|
|
12462
|
+
)
|
|
11995
12463
|
) {
|
|
11996
12464
|
return invalidPrecondition(
|
|
11997
12465
|
"folder layout items cannot update layout fields",
|
|
@@ -12021,6 +12489,11 @@ const COMMAND_DEFINITIONS = [
|
|
|
12021
12489
|
id: payload.controlId,
|
|
12022
12490
|
type: payload.data.type,
|
|
12023
12491
|
name: payload.data.name,
|
|
12492
|
+
...(payload.data.description !== undefined
|
|
12493
|
+
? {
|
|
12494
|
+
description: payload.data.description,
|
|
12495
|
+
}
|
|
12496
|
+
: {}),
|
|
12024
12497
|
...(payload.data.type === "control"
|
|
12025
12498
|
? {
|
|
12026
12499
|
...(payload.data.thumbnailFileId !== undefined
|
|
@@ -12054,7 +12527,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
12054
12527
|
validateUpdateState: ({ state, payload, currentItem }) => {
|
|
12055
12528
|
if (
|
|
12056
12529
|
currentItem.type === "folder" &&
|
|
12057
|
-
Object.keys(payload.data).some(
|
|
12530
|
+
Object.keys(payload.data).some(
|
|
12531
|
+
(key) => key !== "name" && key !== "description",
|
|
12532
|
+
)
|
|
12058
12533
|
) {
|
|
12059
12534
|
return invalidPrecondition(
|
|
12060
12535
|
"folder control items cannot update control fields",
|
|
@@ -12276,7 +12751,9 @@ const COMMAND_DEFINITIONS = [
|
|
|
12276
12751
|
|
|
12277
12752
|
if (
|
|
12278
12753
|
currentItem.type === "folder" &&
|
|
12279
|
-
Object.keys(payload.data).some(
|
|
12754
|
+
Object.keys(payload.data).some(
|
|
12755
|
+
(key) => key !== "name" && key !== "description",
|
|
12756
|
+
)
|
|
12280
12757
|
) {
|
|
12281
12758
|
return invalidPrecondition(
|
|
12282
12759
|
"folder sprite items cannot update image fields",
|