@routevn/creator-model 1.2.8 → 1.2.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 +110 -368
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -36,6 +36,10 @@ const COLLECTION_KEYS = [
|
|
|
36
36
|
"controls",
|
|
37
37
|
];
|
|
38
38
|
const ROOT_KEYS = ["project", "story", ...COLLECTION_KEYS];
|
|
39
|
+
const LINE_UPDATE_ACTIONS_PRESERVE_PATHS = ["dialogue.content"];
|
|
40
|
+
const LINE_UPDATE_ACTIONS_PRESERVE_PATHS_SET = new Set(
|
|
41
|
+
LINE_UPDATE_ACTIONS_PRESERVE_PATHS,
|
|
42
|
+
);
|
|
39
43
|
const createEmptyCollectionState = () => ({
|
|
40
44
|
items: {},
|
|
41
45
|
tree: [],
|
|
@@ -779,8 +783,6 @@ const validateImageItems = ({ items, path, errorFactory }) => {
|
|
|
779
783
|
"description",
|
|
780
784
|
"thumbnailFileId",
|
|
781
785
|
"fileId",
|
|
782
|
-
"fileType",
|
|
783
|
-
"fileSize",
|
|
784
786
|
"width",
|
|
785
787
|
"height",
|
|
786
788
|
],
|
|
@@ -838,20 +840,6 @@ const validateImageItems = ({ items, path, errorFactory }) => {
|
|
|
838
840
|
);
|
|
839
841
|
}
|
|
840
842
|
|
|
841
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
842
|
-
return invalidFromErrorFactory(
|
|
843
|
-
errorFactory,
|
|
844
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
845
|
-
);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
|
|
849
|
-
return invalidFromErrorFactory(
|
|
850
|
-
errorFactory,
|
|
851
|
-
`${itemPath}.fileSize must be a finite number`,
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
|
|
855
843
|
if (item.width !== undefined && !isFiniteNumber(item.width)) {
|
|
856
844
|
return invalidFromErrorFactory(
|
|
857
845
|
errorFactory,
|
|
@@ -962,8 +950,6 @@ const validateSpritesheetItems = ({ items, path, errorFactory }) => {
|
|
|
962
950
|
"description",
|
|
963
951
|
"thumbnailFileId",
|
|
964
952
|
"fileId",
|
|
965
|
-
"fileType",
|
|
966
|
-
"fileSize",
|
|
967
953
|
"sheetWidth",
|
|
968
954
|
"sheetHeight",
|
|
969
955
|
"frameCount",
|
|
@@ -1026,15 +1012,7 @@ const validateSpritesheetItems = ({ items, path, errorFactory }) => {
|
|
|
1026
1012
|
);
|
|
1027
1013
|
}
|
|
1028
1014
|
|
|
1029
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
1030
|
-
return invalidFromErrorFactory(
|
|
1031
|
-
errorFactory,
|
|
1032
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
1033
|
-
);
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
1015
|
for (const key of [
|
|
1037
|
-
"fileSize",
|
|
1038
1016
|
"sheetWidth",
|
|
1039
1017
|
"sheetHeight",
|
|
1040
1018
|
"frameCount",
|
|
@@ -1093,8 +1071,6 @@ const validateSoundItems = ({ items, path, errorFactory }) => {
|
|
|
1093
1071
|
"name",
|
|
1094
1072
|
"description",
|
|
1095
1073
|
"fileId",
|
|
1096
|
-
"fileType",
|
|
1097
|
-
"fileSize",
|
|
1098
1074
|
"waveformDataFileId",
|
|
1099
1075
|
"duration",
|
|
1100
1076
|
],
|
|
@@ -1142,20 +1118,6 @@ const validateSoundItems = ({ items, path, errorFactory }) => {
|
|
|
1142
1118
|
);
|
|
1143
1119
|
}
|
|
1144
1120
|
|
|
1145
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
1146
|
-
return invalidFromErrorFactory(
|
|
1147
|
-
errorFactory,
|
|
1148
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
1149
|
-
);
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
|
|
1153
|
-
return invalidFromErrorFactory(
|
|
1154
|
-
errorFactory,
|
|
1155
|
-
`${itemPath}.fileSize must be a finite number`,
|
|
1156
|
-
);
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
1121
|
if (
|
|
1160
1122
|
item.waveformDataFileId !== undefined &&
|
|
1161
1123
|
item.waveformDataFileId !== null &&
|
|
@@ -1201,8 +1163,6 @@ const validateVideoItems = ({ items, path, errorFactory }) => {
|
|
|
1201
1163
|
"description",
|
|
1202
1164
|
"fileId",
|
|
1203
1165
|
"thumbnailFileId",
|
|
1204
|
-
"fileType",
|
|
1205
|
-
"fileSize",
|
|
1206
1166
|
"duration",
|
|
1207
1167
|
"width",
|
|
1208
1168
|
"height",
|
|
@@ -1258,20 +1218,6 @@ const validateVideoItems = ({ items, path, errorFactory }) => {
|
|
|
1258
1218
|
);
|
|
1259
1219
|
}
|
|
1260
1220
|
|
|
1261
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
1262
|
-
return invalidFromErrorFactory(
|
|
1263
|
-
errorFactory,
|
|
1264
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
1265
|
-
);
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
|
|
1269
|
-
return invalidFromErrorFactory(
|
|
1270
|
-
errorFactory,
|
|
1271
|
-
`${itemPath}.fileSize must be a finite number`,
|
|
1272
|
-
);
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
1221
|
if (item.duration !== undefined && !isFiniteNumber(item.duration)) {
|
|
1276
1222
|
return invalidFromErrorFactory(
|
|
1277
1223
|
errorFactory,
|
|
@@ -1998,8 +1944,6 @@ const validateFontItems = ({ items, path, errorFactory }) => {
|
|
|
1998
1944
|
"description",
|
|
1999
1945
|
"fileId",
|
|
2000
1946
|
"fontFamily",
|
|
2001
|
-
"fileType",
|
|
2002
|
-
"fileSize",
|
|
2003
1947
|
],
|
|
2004
1948
|
path: itemPath,
|
|
2005
1949
|
errorFactory,
|
|
@@ -2052,19 +1996,6 @@ const validateFontItems = ({ items, path, errorFactory }) => {
|
|
|
2052
1996
|
);
|
|
2053
1997
|
}
|
|
2054
1998
|
|
|
2055
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
2056
|
-
return invalidFromErrorFactory(
|
|
2057
|
-
errorFactory,
|
|
2058
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
2059
|
-
);
|
|
2060
|
-
}
|
|
2061
|
-
|
|
2062
|
-
if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
|
|
2063
|
-
return invalidFromErrorFactory(
|
|
2064
|
-
errorFactory,
|
|
2065
|
-
`${itemPath}.fileSize must be a finite number`,
|
|
2066
|
-
);
|
|
2067
|
-
}
|
|
2068
1999
|
}
|
|
2069
2000
|
}
|
|
2070
2001
|
};
|
|
@@ -2687,8 +2618,6 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
|
|
|
2687
2618
|
"description",
|
|
2688
2619
|
"thumbnailFileId",
|
|
2689
2620
|
"fileId",
|
|
2690
|
-
"fileType",
|
|
2691
|
-
"fileSize",
|
|
2692
2621
|
"width",
|
|
2693
2622
|
"height",
|
|
2694
2623
|
],
|
|
@@ -2746,20 +2675,6 @@ const validateCharacterSpriteItems = ({ items, path, errorFactory }) => {
|
|
|
2746
2675
|
);
|
|
2747
2676
|
}
|
|
2748
2677
|
|
|
2749
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
2750
|
-
return invalidFromErrorFactory(
|
|
2751
|
-
errorFactory,
|
|
2752
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
2753
|
-
);
|
|
2754
|
-
}
|
|
2755
|
-
|
|
2756
|
-
if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
|
|
2757
|
-
return invalidFromErrorFactory(
|
|
2758
|
-
errorFactory,
|
|
2759
|
-
`${itemPath}.fileSize must be a finite number when provided`,
|
|
2760
|
-
);
|
|
2761
|
-
}
|
|
2762
|
-
|
|
2763
2678
|
if (item.width !== undefined && !isFiniteNumber(item.width)) {
|
|
2764
2679
|
return invalidFromErrorFactory(
|
|
2765
2680
|
errorFactory,
|
|
@@ -3540,8 +3455,6 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
3540
3455
|
"description",
|
|
3541
3456
|
"shortcut",
|
|
3542
3457
|
"fileId",
|
|
3543
|
-
"fileType",
|
|
3544
|
-
"fileSize",
|
|
3545
3458
|
"sprites",
|
|
3546
3459
|
],
|
|
3547
3460
|
path: itemPath,
|
|
@@ -3595,20 +3508,6 @@ const validateCharacterItems = ({ items, path, errorFactory }) => {
|
|
|
3595
3508
|
);
|
|
3596
3509
|
}
|
|
3597
3510
|
|
|
3598
|
-
if (item.fileType !== undefined && !isString(item.fileType)) {
|
|
3599
|
-
return invalidFromErrorFactory(
|
|
3600
|
-
errorFactory,
|
|
3601
|
-
`${itemPath}.fileType must be a string when provided`,
|
|
3602
|
-
);
|
|
3603
|
-
}
|
|
3604
|
-
|
|
3605
|
-
if (item.fileSize !== undefined && !isFiniteNumber(item.fileSize)) {
|
|
3606
|
-
return invalidFromErrorFactory(
|
|
3607
|
-
errorFactory,
|
|
3608
|
-
`${itemPath}.fileSize must be a finite number when provided`,
|
|
3609
|
-
);
|
|
3610
|
-
}
|
|
3611
|
-
|
|
3612
3511
|
{
|
|
3613
3512
|
const result = validateNestedCollection({
|
|
3614
3513
|
collection: item.sprites,
|
|
@@ -5939,6 +5838,91 @@ const validateLineUpdateActionsData = ({ data, errorFactory }) => {
|
|
|
5939
5838
|
}
|
|
5940
5839
|
};
|
|
5941
5840
|
|
|
5841
|
+
const validateLineUpdateActionsPreserve = ({
|
|
5842
|
+
preserve,
|
|
5843
|
+
data,
|
|
5844
|
+
replace,
|
|
5845
|
+
errorFactory,
|
|
5846
|
+
}) => {
|
|
5847
|
+
if (preserve === undefined) {
|
|
5848
|
+
return VALID_RESULT;
|
|
5849
|
+
}
|
|
5850
|
+
|
|
5851
|
+
if (replace === true) {
|
|
5852
|
+
return invalidFromErrorFactory(
|
|
5853
|
+
errorFactory,
|
|
5854
|
+
"payload.preserve is only supported when payload.replace is not true",
|
|
5855
|
+
);
|
|
5856
|
+
}
|
|
5857
|
+
|
|
5858
|
+
if (!Array.isArray(preserve)) {
|
|
5859
|
+
return invalidFromErrorFactory(
|
|
5860
|
+
errorFactory,
|
|
5861
|
+
"payload.preserve must be an array when provided",
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5864
|
+
|
|
5865
|
+
const seen = new Set();
|
|
5866
|
+
for (let index = 0; index < preserve.length; index += 1) {
|
|
5867
|
+
const path = preserve[index];
|
|
5868
|
+
const preservePath = `payload.preserve[${index}]`;
|
|
5869
|
+
|
|
5870
|
+
if (!isNonEmptyString(path)) {
|
|
5871
|
+
return invalidFromErrorFactory(
|
|
5872
|
+
errorFactory,
|
|
5873
|
+
`${preservePath} must be a non-empty string`,
|
|
5874
|
+
);
|
|
5875
|
+
}
|
|
5876
|
+
|
|
5877
|
+
if (!LINE_UPDATE_ACTIONS_PRESERVE_PATHS_SET.has(path)) {
|
|
5878
|
+
return invalidFromErrorFactory(
|
|
5879
|
+
errorFactory,
|
|
5880
|
+
`${preservePath} must be one of: ${LINE_UPDATE_ACTIONS_PRESERVE_PATHS.join(", ")}`,
|
|
5881
|
+
);
|
|
5882
|
+
}
|
|
5883
|
+
|
|
5884
|
+
if (seen.has(path)) {
|
|
5885
|
+
return invalidFromErrorFactory(
|
|
5886
|
+
errorFactory,
|
|
5887
|
+
`${preservePath} must not duplicate another preserve path`,
|
|
5888
|
+
);
|
|
5889
|
+
}
|
|
5890
|
+
seen.add(path);
|
|
5891
|
+
|
|
5892
|
+
if (path === "dialogue.content" && !isPlainObject(data?.dialogue)) {
|
|
5893
|
+
return invalidFromErrorFactory(
|
|
5894
|
+
errorFactory,
|
|
5895
|
+
"payload.data.dialogue must be an object when preserving dialogue.content",
|
|
5896
|
+
);
|
|
5897
|
+
}
|
|
5898
|
+
}
|
|
5899
|
+
|
|
5900
|
+
return VALID_RESULT;
|
|
5901
|
+
};
|
|
5902
|
+
|
|
5903
|
+
const applyLineUpdateActionsPreserve = ({ currentActions, data, preserve }) => {
|
|
5904
|
+
const nextData = structuredClone(data || {});
|
|
5905
|
+
if (!Array.isArray(preserve) || preserve.length === 0) {
|
|
5906
|
+
return nextData;
|
|
5907
|
+
}
|
|
5908
|
+
|
|
5909
|
+
if (
|
|
5910
|
+
preserve.includes("dialogue.content") &&
|
|
5911
|
+
isPlainObject(nextData.dialogue) &&
|
|
5912
|
+
!Object.hasOwn(nextData.dialogue, "content")
|
|
5913
|
+
) {
|
|
5914
|
+
const currentContent = currentActions?.dialogue?.content;
|
|
5915
|
+
if (currentContent !== undefined) {
|
|
5916
|
+
nextData.dialogue = {
|
|
5917
|
+
...structuredClone(nextData.dialogue),
|
|
5918
|
+
content: structuredClone(currentContent),
|
|
5919
|
+
};
|
|
5920
|
+
}
|
|
5921
|
+
}
|
|
5922
|
+
|
|
5923
|
+
return nextData;
|
|
5924
|
+
};
|
|
5925
|
+
|
|
5942
5926
|
const validateImageCreateData = ({ data, errorFactory }) => {
|
|
5943
5927
|
if (!isPlainObject(data)) {
|
|
5944
5928
|
return invalidFromErrorFactory(
|
|
@@ -5966,8 +5950,6 @@ const validateImageCreateData = ({ data, errorFactory }) => {
|
|
|
5966
5950
|
"description",
|
|
5967
5951
|
"thumbnailFileId",
|
|
5968
5952
|
"fileId",
|
|
5969
|
-
"fileType",
|
|
5970
|
-
"fileSize",
|
|
5971
5953
|
"width",
|
|
5972
5954
|
"height",
|
|
5973
5955
|
],
|
|
@@ -6011,20 +5993,6 @@ const validateImageCreateData = ({ data, errorFactory }) => {
|
|
|
6011
5993
|
);
|
|
6012
5994
|
}
|
|
6013
5995
|
|
|
6014
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6015
|
-
return invalidFromErrorFactory(
|
|
6016
|
-
errorFactory,
|
|
6017
|
-
"payload.data.fileType must be a string when provided",
|
|
6018
|
-
);
|
|
6019
|
-
}
|
|
6020
|
-
|
|
6021
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6022
|
-
return invalidFromErrorFactory(
|
|
6023
|
-
errorFactory,
|
|
6024
|
-
"payload.data.fileSize must be a finite number",
|
|
6025
|
-
);
|
|
6026
|
-
}
|
|
6027
|
-
|
|
6028
5996
|
if (data.width !== undefined && !isFiniteNumber(data.width)) {
|
|
6029
5997
|
return invalidFromErrorFactory(
|
|
6030
5998
|
errorFactory,
|
|
@@ -6050,8 +6018,6 @@ const validateImageUpdateData = ({ data, errorFactory }) => {
|
|
|
6050
6018
|
"description",
|
|
6051
6019
|
"thumbnailFileId",
|
|
6052
6020
|
"fileId",
|
|
6053
|
-
"fileType",
|
|
6054
|
-
"fileSize",
|
|
6055
6021
|
"width",
|
|
6056
6022
|
"height",
|
|
6057
6023
|
],
|
|
@@ -6101,20 +6067,6 @@ const validateImageUpdateData = ({ data, errorFactory }) => {
|
|
|
6101
6067
|
);
|
|
6102
6068
|
}
|
|
6103
6069
|
|
|
6104
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6105
|
-
return invalidFromErrorFactory(
|
|
6106
|
-
errorFactory,
|
|
6107
|
-
"payload.data.fileType must be a string when provided",
|
|
6108
|
-
);
|
|
6109
|
-
}
|
|
6110
|
-
|
|
6111
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6112
|
-
return invalidFromErrorFactory(
|
|
6113
|
-
errorFactory,
|
|
6114
|
-
"payload.data.fileSize must be a finite number",
|
|
6115
|
-
);
|
|
6116
|
-
}
|
|
6117
|
-
|
|
6118
6070
|
if (data.width !== undefined && !isFiniteNumber(data.width)) {
|
|
6119
6071
|
return invalidFromErrorFactory(
|
|
6120
6072
|
errorFactory,
|
|
@@ -6157,8 +6109,6 @@ const validateSpritesheetCreateData = ({ data, errorFactory }) => {
|
|
|
6157
6109
|
"description",
|
|
6158
6110
|
"thumbnailFileId",
|
|
6159
6111
|
"fileId",
|
|
6160
|
-
"fileType",
|
|
6161
|
-
"fileSize",
|
|
6162
6112
|
"sheetWidth",
|
|
6163
6113
|
"sheetHeight",
|
|
6164
6114
|
"frameCount",
|
|
@@ -6207,15 +6157,7 @@ const validateSpritesheetCreateData = ({ data, errorFactory }) => {
|
|
|
6207
6157
|
);
|
|
6208
6158
|
}
|
|
6209
6159
|
|
|
6210
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6211
|
-
return invalidFromErrorFactory(
|
|
6212
|
-
errorFactory,
|
|
6213
|
-
"payload.data.fileType must be a string when provided",
|
|
6214
|
-
);
|
|
6215
|
-
}
|
|
6216
|
-
|
|
6217
6160
|
for (const key of [
|
|
6218
|
-
"fileSize",
|
|
6219
6161
|
"sheetWidth",
|
|
6220
6162
|
"sheetHeight",
|
|
6221
6163
|
"frameCount",
|
|
@@ -6259,8 +6201,6 @@ const validateSpritesheetUpdateData = ({ data, errorFactory }) => {
|
|
|
6259
6201
|
"description",
|
|
6260
6202
|
"thumbnailFileId",
|
|
6261
6203
|
"fileId",
|
|
6262
|
-
"fileType",
|
|
6263
|
-
"fileSize",
|
|
6264
6204
|
"sheetWidth",
|
|
6265
6205
|
"sheetHeight",
|
|
6266
6206
|
"frameCount",
|
|
@@ -6315,15 +6255,7 @@ const validateSpritesheetUpdateData = ({ data, errorFactory }) => {
|
|
|
6315
6255
|
);
|
|
6316
6256
|
}
|
|
6317
6257
|
|
|
6318
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6319
|
-
return invalidFromErrorFactory(
|
|
6320
|
-
errorFactory,
|
|
6321
|
-
"payload.data.fileType must be a string when provided",
|
|
6322
|
-
);
|
|
6323
|
-
}
|
|
6324
|
-
|
|
6325
6258
|
for (const key of [
|
|
6326
|
-
"fileSize",
|
|
6327
6259
|
"sheetWidth",
|
|
6328
6260
|
"sheetHeight",
|
|
6329
6261
|
"frameCount",
|
|
@@ -6383,8 +6315,6 @@ const validateSoundCreateData = ({ data, errorFactory }) => {
|
|
|
6383
6315
|
"name",
|
|
6384
6316
|
"description",
|
|
6385
6317
|
"fileId",
|
|
6386
|
-
"fileType",
|
|
6387
|
-
"fileSize",
|
|
6388
6318
|
"waveformDataFileId",
|
|
6389
6319
|
"duration",
|
|
6390
6320
|
],
|
|
@@ -6418,20 +6348,6 @@ const validateSoundCreateData = ({ data, errorFactory }) => {
|
|
|
6418
6348
|
);
|
|
6419
6349
|
}
|
|
6420
6350
|
|
|
6421
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6422
|
-
return invalidFromErrorFactory(
|
|
6423
|
-
errorFactory,
|
|
6424
|
-
"payload.data.fileType must be a string when provided",
|
|
6425
|
-
);
|
|
6426
|
-
}
|
|
6427
|
-
|
|
6428
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6429
|
-
return invalidFromErrorFactory(
|
|
6430
|
-
errorFactory,
|
|
6431
|
-
"payload.data.fileSize must be a finite number",
|
|
6432
|
-
);
|
|
6433
|
-
}
|
|
6434
|
-
|
|
6435
6351
|
if (
|
|
6436
6352
|
data.waveformDataFileId !== undefined &&
|
|
6437
6353
|
data.waveformDataFileId !== null &&
|
|
@@ -6460,8 +6376,6 @@ const validateSoundUpdateData = ({ data, errorFactory }) => {
|
|
|
6460
6376
|
"name",
|
|
6461
6377
|
"description",
|
|
6462
6378
|
"fileId",
|
|
6463
|
-
"fileType",
|
|
6464
|
-
"fileSize",
|
|
6465
6379
|
"waveformDataFileId",
|
|
6466
6380
|
"duration",
|
|
6467
6381
|
],
|
|
@@ -6501,20 +6415,6 @@ const validateSoundUpdateData = ({ data, errorFactory }) => {
|
|
|
6501
6415
|
);
|
|
6502
6416
|
}
|
|
6503
6417
|
|
|
6504
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6505
|
-
return invalidFromErrorFactory(
|
|
6506
|
-
errorFactory,
|
|
6507
|
-
"payload.data.fileType must be a string when provided",
|
|
6508
|
-
);
|
|
6509
|
-
}
|
|
6510
|
-
|
|
6511
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6512
|
-
return invalidFromErrorFactory(
|
|
6513
|
-
errorFactory,
|
|
6514
|
-
"payload.data.fileSize must be a finite number",
|
|
6515
|
-
);
|
|
6516
|
-
}
|
|
6517
|
-
|
|
6518
6418
|
if (
|
|
6519
6419
|
data.waveformDataFileId !== undefined &&
|
|
6520
6420
|
data.waveformDataFileId !== null &&
|
|
@@ -6561,8 +6461,6 @@ const validateVideoCreateData = ({ data, errorFactory }) => {
|
|
|
6561
6461
|
"description",
|
|
6562
6462
|
"fileId",
|
|
6563
6463
|
"thumbnailFileId",
|
|
6564
|
-
"fileType",
|
|
6565
|
-
"fileSize",
|
|
6566
6464
|
"duration",
|
|
6567
6465
|
"width",
|
|
6568
6466
|
"height",
|
|
@@ -6604,20 +6502,6 @@ const validateVideoCreateData = ({ data, errorFactory }) => {
|
|
|
6604
6502
|
);
|
|
6605
6503
|
}
|
|
6606
6504
|
|
|
6607
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6608
|
-
return invalidFromErrorFactory(
|
|
6609
|
-
errorFactory,
|
|
6610
|
-
"payload.data.fileType must be a string when provided",
|
|
6611
|
-
);
|
|
6612
|
-
}
|
|
6613
|
-
|
|
6614
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6615
|
-
return invalidFromErrorFactory(
|
|
6616
|
-
errorFactory,
|
|
6617
|
-
"payload.data.fileSize must be a finite number",
|
|
6618
|
-
);
|
|
6619
|
-
}
|
|
6620
|
-
|
|
6621
6505
|
if (data.duration !== undefined && !isFiniteNumber(data.duration)) {
|
|
6622
6506
|
return invalidFromErrorFactory(
|
|
6623
6507
|
errorFactory,
|
|
@@ -6650,8 +6534,6 @@ const validateVideoUpdateData = ({ data, errorFactory }) => {
|
|
|
6650
6534
|
"description",
|
|
6651
6535
|
"fileId",
|
|
6652
6536
|
"thumbnailFileId",
|
|
6653
|
-
"fileType",
|
|
6654
|
-
"fileSize",
|
|
6655
6537
|
"duration",
|
|
6656
6538
|
"width",
|
|
6657
6539
|
"height",
|
|
@@ -6702,20 +6584,6 @@ const validateVideoUpdateData = ({ data, errorFactory }) => {
|
|
|
6702
6584
|
);
|
|
6703
6585
|
}
|
|
6704
6586
|
|
|
6705
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6706
|
-
return invalidFromErrorFactory(
|
|
6707
|
-
errorFactory,
|
|
6708
|
-
"payload.data.fileType must be a string when provided",
|
|
6709
|
-
);
|
|
6710
|
-
}
|
|
6711
|
-
|
|
6712
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6713
|
-
return invalidFromErrorFactory(
|
|
6714
|
-
errorFactory,
|
|
6715
|
-
"payload.data.fileSize must be a finite number",
|
|
6716
|
-
);
|
|
6717
|
-
}
|
|
6718
|
-
|
|
6719
6587
|
if (data.duration !== undefined && !isFiniteNumber(data.duration)) {
|
|
6720
6588
|
return invalidFromErrorFactory(
|
|
6721
6589
|
errorFactory,
|
|
@@ -6765,8 +6633,6 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
6765
6633
|
"description",
|
|
6766
6634
|
"fileId",
|
|
6767
6635
|
"fontFamily",
|
|
6768
|
-
"fileType",
|
|
6769
|
-
"fileSize",
|
|
6770
6636
|
],
|
|
6771
6637
|
path: "payload.data",
|
|
6772
6638
|
errorFactory,
|
|
@@ -6805,19 +6671,6 @@ const validateFontCreateData = ({ data, errorFactory }) => {
|
|
|
6805
6671
|
);
|
|
6806
6672
|
}
|
|
6807
6673
|
|
|
6808
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6809
|
-
return invalidFromErrorFactory(
|
|
6810
|
-
errorFactory,
|
|
6811
|
-
"payload.data.fileType must be a string when provided",
|
|
6812
|
-
);
|
|
6813
|
-
}
|
|
6814
|
-
|
|
6815
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6816
|
-
return invalidFromErrorFactory(
|
|
6817
|
-
errorFactory,
|
|
6818
|
-
"payload.data.fileSize must be a finite number",
|
|
6819
|
-
);
|
|
6820
|
-
}
|
|
6821
6674
|
}
|
|
6822
6675
|
};
|
|
6823
6676
|
|
|
@@ -6830,8 +6683,6 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
6830
6683
|
"description",
|
|
6831
6684
|
"fileId",
|
|
6832
6685
|
"fontFamily",
|
|
6833
|
-
"fileType",
|
|
6834
|
-
"fileSize",
|
|
6835
6686
|
],
|
|
6836
6687
|
path: "payload.data",
|
|
6837
6688
|
errorFactory,
|
|
@@ -6876,19 +6727,6 @@ const validateFontUpdateData = ({ data, errorFactory }) => {
|
|
|
6876
6727
|
);
|
|
6877
6728
|
}
|
|
6878
6729
|
|
|
6879
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
6880
|
-
return invalidFromErrorFactory(
|
|
6881
|
-
errorFactory,
|
|
6882
|
-
"payload.data.fileType must be a string when provided",
|
|
6883
|
-
);
|
|
6884
|
-
}
|
|
6885
|
-
|
|
6886
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
6887
|
-
return invalidFromErrorFactory(
|
|
6888
|
-
errorFactory,
|
|
6889
|
-
"payload.data.fileSize must be a finite number",
|
|
6890
|
-
);
|
|
6891
|
-
}
|
|
6892
6730
|
};
|
|
6893
6731
|
|
|
6894
6732
|
const validateFileCreateData = ({ data, errorFactory }) => {
|
|
@@ -7844,8 +7682,6 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
7844
7682
|
"description",
|
|
7845
7683
|
"fileId",
|
|
7846
7684
|
"thumbnailFileId",
|
|
7847
|
-
"fileType",
|
|
7848
|
-
"fileSize",
|
|
7849
7685
|
"width",
|
|
7850
7686
|
"height",
|
|
7851
7687
|
],
|
|
@@ -7889,20 +7725,6 @@ const validateCharacterSpriteCreateData = ({ data, errorFactory }) => {
|
|
|
7889
7725
|
);
|
|
7890
7726
|
}
|
|
7891
7727
|
|
|
7892
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
7893
|
-
return invalidFromErrorFactory(
|
|
7894
|
-
errorFactory,
|
|
7895
|
-
"payload.data.fileType must be a string when provided",
|
|
7896
|
-
);
|
|
7897
|
-
}
|
|
7898
|
-
|
|
7899
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
7900
|
-
return invalidFromErrorFactory(
|
|
7901
|
-
errorFactory,
|
|
7902
|
-
"payload.data.fileSize must be a finite number when provided",
|
|
7903
|
-
);
|
|
7904
|
-
}
|
|
7905
|
-
|
|
7906
7728
|
if (data.width !== undefined && !isFiniteNumber(data.width)) {
|
|
7907
7729
|
return invalidFromErrorFactory(
|
|
7908
7730
|
errorFactory,
|
|
@@ -7928,8 +7750,6 @@ const validateCharacterSpriteUpdateData = ({ data, errorFactory }) => {
|
|
|
7928
7750
|
"description",
|
|
7929
7751
|
"fileId",
|
|
7930
7752
|
"thumbnailFileId",
|
|
7931
|
-
"fileType",
|
|
7932
|
-
"fileSize",
|
|
7933
7753
|
"width",
|
|
7934
7754
|
"height",
|
|
7935
7755
|
],
|
|
@@ -7979,20 +7799,6 @@ const validateCharacterSpriteUpdateData = ({ data, errorFactory }) => {
|
|
|
7979
7799
|
);
|
|
7980
7800
|
}
|
|
7981
7801
|
|
|
7982
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
7983
|
-
return invalidFromErrorFactory(
|
|
7984
|
-
errorFactory,
|
|
7985
|
-
"payload.data.fileType must be a string when provided",
|
|
7986
|
-
);
|
|
7987
|
-
}
|
|
7988
|
-
|
|
7989
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
7990
|
-
return invalidFromErrorFactory(
|
|
7991
|
-
errorFactory,
|
|
7992
|
-
"payload.data.fileSize must be a finite number when provided",
|
|
7993
|
-
);
|
|
7994
|
-
}
|
|
7995
|
-
|
|
7996
7802
|
if (data.width !== undefined && !isFiniteNumber(data.width)) {
|
|
7997
7803
|
return invalidFromErrorFactory(
|
|
7998
7804
|
errorFactory,
|
|
@@ -8035,8 +7841,6 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
8035
7841
|
"description",
|
|
8036
7842
|
"shortcut",
|
|
8037
7843
|
"fileId",
|
|
8038
|
-
"fileType",
|
|
8039
|
-
"fileSize",
|
|
8040
7844
|
"sprites",
|
|
8041
7845
|
],
|
|
8042
7846
|
path: "payload.data",
|
|
@@ -8076,20 +7880,6 @@ const validateCharacterCreateData = ({ data, errorFactory }) => {
|
|
|
8076
7880
|
);
|
|
8077
7881
|
}
|
|
8078
7882
|
|
|
8079
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
8080
|
-
return invalidFromErrorFactory(
|
|
8081
|
-
errorFactory,
|
|
8082
|
-
"payload.data.fileType must be a string when provided",
|
|
8083
|
-
);
|
|
8084
|
-
}
|
|
8085
|
-
|
|
8086
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
8087
|
-
return invalidFromErrorFactory(
|
|
8088
|
-
errorFactory,
|
|
8089
|
-
"payload.data.fileSize must be a finite number when provided",
|
|
8090
|
-
);
|
|
8091
|
-
}
|
|
8092
|
-
|
|
8093
7883
|
if (data.sprites !== undefined) {
|
|
8094
7884
|
{
|
|
8095
7885
|
const result = validateNestedCollection({
|
|
@@ -8117,8 +7907,6 @@ const validateCharacterUpdateData = ({ data, errorFactory }) => {
|
|
|
8117
7907
|
"description",
|
|
8118
7908
|
"shortcut",
|
|
8119
7909
|
"fileId",
|
|
8120
|
-
"fileType",
|
|
8121
|
-
"fileSize",
|
|
8122
7910
|
],
|
|
8123
7911
|
path: "payload.data",
|
|
8124
7912
|
errorFactory,
|
|
@@ -8163,19 +7951,6 @@ const validateCharacterUpdateData = ({ data, errorFactory }) => {
|
|
|
8163
7951
|
);
|
|
8164
7952
|
}
|
|
8165
7953
|
|
|
8166
|
-
if (data.fileType !== undefined && !isString(data.fileType)) {
|
|
8167
|
-
return invalidFromErrorFactory(
|
|
8168
|
-
errorFactory,
|
|
8169
|
-
"payload.data.fileType must be a string when provided",
|
|
8170
|
-
);
|
|
8171
|
-
}
|
|
8172
|
-
|
|
8173
|
-
if (data.fileSize !== undefined && !isFiniteNumber(data.fileSize)) {
|
|
8174
|
-
return invalidFromErrorFactory(
|
|
8175
|
-
errorFactory,
|
|
8176
|
-
"payload.data.fileSize must be a finite number when provided",
|
|
8177
|
-
);
|
|
8178
|
-
}
|
|
8179
7954
|
};
|
|
8180
7955
|
|
|
8181
7956
|
const validateLayoutCreateData = ({ data, errorFactory }) => {
|
|
@@ -9684,16 +9459,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
9684
9459
|
thumbnailFileId: payload.data.thumbnailFileId,
|
|
9685
9460
|
}
|
|
9686
9461
|
: {}),
|
|
9687
|
-
...(payload.data.fileType !== undefined
|
|
9688
|
-
? {
|
|
9689
|
-
fileType: payload.data.fileType,
|
|
9690
|
-
}
|
|
9691
|
-
: {}),
|
|
9692
|
-
...(payload.data.fileSize !== undefined
|
|
9693
|
-
? {
|
|
9694
|
-
fileSize: payload.data.fileSize,
|
|
9695
|
-
}
|
|
9696
|
-
: {}),
|
|
9697
9462
|
...(payload.data.sheetWidth !== undefined
|
|
9698
9463
|
? {
|
|
9699
9464
|
sheetWidth: payload.data.sheetWidth,
|
|
@@ -10769,7 +10534,7 @@ const COMMAND_DEFINITIONS = [
|
|
|
10769
10534
|
{
|
|
10770
10535
|
const result = validateAllowedKeys({
|
|
10771
10536
|
value: payload,
|
|
10772
|
-
allowedKeys: ["lineId", "data", "replace"],
|
|
10537
|
+
allowedKeys: ["lineId", "data", "replace", "preserve"],
|
|
10773
10538
|
path: "payload",
|
|
10774
10539
|
errorFactory: createPayloadValidationError,
|
|
10775
10540
|
});
|
|
@@ -10800,6 +10565,18 @@ const COMMAND_DEFINITIONS = [
|
|
|
10800
10565
|
"payload.replace must be a boolean when provided",
|
|
10801
10566
|
);
|
|
10802
10567
|
}
|
|
10568
|
+
|
|
10569
|
+
{
|
|
10570
|
+
const result = validateLineUpdateActionsPreserve({
|
|
10571
|
+
preserve: payload.preserve,
|
|
10572
|
+
data: payload.data,
|
|
10573
|
+
replace: payload.replace,
|
|
10574
|
+
errorFactory: createPayloadValidationError,
|
|
10575
|
+
});
|
|
10576
|
+
if (result?.valid === false) {
|
|
10577
|
+
return result;
|
|
10578
|
+
}
|
|
10579
|
+
}
|
|
10803
10580
|
},
|
|
10804
10581
|
validateAgainstState: ({ state, payload }) => {
|
|
10805
10582
|
if (!findLineLocation({ state, lineId: payload.lineId })) {
|
|
@@ -10811,12 +10588,17 @@ const COMMAND_DEFINITIONS = [
|
|
|
10811
10588
|
reduce: ({ state, payload }) => {
|
|
10812
10589
|
const location = findLineLocation({ state, lineId: payload.lineId });
|
|
10813
10590
|
const line = location.line;
|
|
10591
|
+
const nextData = applyLineUpdateActionsPreserve({
|
|
10592
|
+
currentActions: line.actions,
|
|
10593
|
+
data: payload.data,
|
|
10594
|
+
preserve: payload.preserve,
|
|
10595
|
+
});
|
|
10814
10596
|
line.actions =
|
|
10815
10597
|
payload.replace === true
|
|
10816
|
-
? structuredClone(
|
|
10598
|
+
? structuredClone(nextData)
|
|
10817
10599
|
: {
|
|
10818
10600
|
...structuredClone(line.actions),
|
|
10819
|
-
...structuredClone(
|
|
10601
|
+
...structuredClone(nextData),
|
|
10820
10602
|
};
|
|
10821
10603
|
return state;
|
|
10822
10604
|
},
|
|
@@ -11117,12 +10899,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
11117
10899
|
if (payload.data.thumbnailFileId !== undefined) {
|
|
11118
10900
|
nextImage.thumbnailFileId = payload.data.thumbnailFileId;
|
|
11119
10901
|
}
|
|
11120
|
-
if (payload.data.fileType !== undefined) {
|
|
11121
|
-
nextImage.fileType = payload.data.fileType;
|
|
11122
|
-
}
|
|
11123
|
-
if (payload.data.fileSize !== undefined) {
|
|
11124
|
-
nextImage.fileSize = payload.data.fileSize;
|
|
11125
|
-
}
|
|
11126
10902
|
if (payload.data.width !== undefined) {
|
|
11127
10903
|
nextImage.width = payload.data.width;
|
|
11128
10904
|
}
|
|
@@ -11189,8 +10965,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
11189
10965
|
currentImage.type === "folder" &&
|
|
11190
10966
|
(payload.data.fileId !== undefined ||
|
|
11191
10967
|
payload.data.thumbnailFileId !== undefined ||
|
|
11192
|
-
payload.data.fileType !== undefined ||
|
|
11193
|
-
payload.data.fileSize !== undefined ||
|
|
11194
10968
|
payload.data.width !== undefined ||
|
|
11195
10969
|
payload.data.height !== undefined)
|
|
11196
10970
|
) {
|
|
@@ -11539,12 +11313,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
11539
11313
|
|
|
11540
11314
|
if (payload.data.type === "sound") {
|
|
11541
11315
|
nextSound.fileId = payload.data.fileId;
|
|
11542
|
-
if (payload.data.fileType !== undefined) {
|
|
11543
|
-
nextSound.fileType = payload.data.fileType;
|
|
11544
|
-
}
|
|
11545
|
-
if (payload.data.fileSize !== undefined) {
|
|
11546
|
-
nextSound.fileSize = payload.data.fileSize;
|
|
11547
|
-
}
|
|
11548
11316
|
if (payload.data.waveformDataFileId !== undefined) {
|
|
11549
11317
|
nextSound.waveformDataFileId = payload.data.waveformDataFileId;
|
|
11550
11318
|
}
|
|
@@ -11610,8 +11378,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
11610
11378
|
if (
|
|
11611
11379
|
currentSound.type === "folder" &&
|
|
11612
11380
|
(payload.data.fileId !== undefined ||
|
|
11613
|
-
payload.data.fileType !== undefined ||
|
|
11614
|
-
payload.data.fileSize !== undefined ||
|
|
11615
11381
|
payload.data.waveformDataFileId !== undefined ||
|
|
11616
11382
|
payload.data.duration !== undefined)
|
|
11617
11383
|
) {
|
|
@@ -11961,12 +11727,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
11961
11727
|
if (payload.data.type === "video") {
|
|
11962
11728
|
nextVideo.fileId = payload.data.fileId;
|
|
11963
11729
|
nextVideo.thumbnailFileId = payload.data.thumbnailFileId;
|
|
11964
|
-
if (payload.data.fileType !== undefined) {
|
|
11965
|
-
nextVideo.fileType = payload.data.fileType;
|
|
11966
|
-
}
|
|
11967
|
-
if (payload.data.fileSize !== undefined) {
|
|
11968
|
-
nextVideo.fileSize = payload.data.fileSize;
|
|
11969
|
-
}
|
|
11970
11730
|
if (payload.data.duration !== undefined) {
|
|
11971
11731
|
nextVideo.duration = payload.data.duration;
|
|
11972
11732
|
}
|
|
@@ -12036,8 +11796,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
12036
11796
|
currentVideo.type === "folder" &&
|
|
12037
11797
|
(payload.data.fileId !== undefined ||
|
|
12038
11798
|
payload.data.thumbnailFileId !== undefined ||
|
|
12039
|
-
payload.data.fileType !== undefined ||
|
|
12040
|
-
payload.data.fileSize !== undefined ||
|
|
12041
11799
|
payload.data.duration !== undefined ||
|
|
12042
11800
|
payload.data.width !== undefined ||
|
|
12043
11801
|
payload.data.height !== undefined)
|
|
@@ -12791,12 +12549,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
12791
12549
|
if (payload.data.type === "font") {
|
|
12792
12550
|
nextFont.fileId = payload.data.fileId;
|
|
12793
12551
|
nextFont.fontFamily = payload.data.fontFamily;
|
|
12794
|
-
if (payload.data.fileType !== undefined) {
|
|
12795
|
-
nextFont.fileType = payload.data.fileType;
|
|
12796
|
-
}
|
|
12797
|
-
if (payload.data.fileSize !== undefined) {
|
|
12798
|
-
nextFont.fileSize = payload.data.fileSize;
|
|
12799
|
-
}
|
|
12800
12552
|
}
|
|
12801
12553
|
|
|
12802
12554
|
state.fonts.items[payload.fontId] = nextFont;
|
|
@@ -12856,9 +12608,7 @@ const COMMAND_DEFINITIONS = [
|
|
|
12856
12608
|
if (
|
|
12857
12609
|
currentFont.type === "folder" &&
|
|
12858
12610
|
(payload.data.fileId !== undefined ||
|
|
12859
|
-
payload.data.fontFamily !== undefined
|
|
12860
|
-
payload.data.fileType !== undefined ||
|
|
12861
|
-
payload.data.fileSize !== undefined)
|
|
12611
|
+
payload.data.fontFamily !== undefined)
|
|
12862
12612
|
) {
|
|
12863
12613
|
return invalidPrecondition(
|
|
12864
12614
|
"folder font items cannot update font fields",
|
|
@@ -13707,14 +13457,6 @@ const COMMAND_DEFINITIONS = [
|
|
|
13707
13457
|
item.fileId = payload.data.fileId;
|
|
13708
13458
|
}
|
|
13709
13459
|
|
|
13710
|
-
if (payload.data.fileType !== undefined) {
|
|
13711
|
-
item.fileType = payload.data.fileType;
|
|
13712
|
-
}
|
|
13713
|
-
|
|
13714
|
-
if (payload.data.fileSize !== undefined) {
|
|
13715
|
-
item.fileSize = payload.data.fileSize;
|
|
13716
|
-
}
|
|
13717
|
-
|
|
13718
13460
|
item.sprites =
|
|
13719
13461
|
payload.data.sprites === undefined
|
|
13720
13462
|
? { items: {}, tree: [] }
|