@routevn/creator-model 1.3.2 → 1.3.3
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 +88 -0
package/package.json
CHANGED
package/src/model.js
CHANGED
|
@@ -2395,6 +2395,7 @@ const validateParticleItems = ({ items, path, errorFactory }) => {
|
|
|
2395
2395
|
"height",
|
|
2396
2396
|
"seed",
|
|
2397
2397
|
"modules",
|
|
2398
|
+
"thumbnailFileId",
|
|
2398
2399
|
],
|
|
2399
2400
|
path: itemPath,
|
|
2400
2401
|
errorFactory,
|
|
@@ -2469,6 +2470,16 @@ const validateParticleItems = ({ items, path, errorFactory }) => {
|
|
|
2469
2470
|
);
|
|
2470
2471
|
}
|
|
2471
2472
|
|
|
2473
|
+
if (
|
|
2474
|
+
item.thumbnailFileId !== undefined &&
|
|
2475
|
+
!isNonEmptyString(item.thumbnailFileId)
|
|
2476
|
+
) {
|
|
2477
|
+
return invalidFromErrorFactory(
|
|
2478
|
+
errorFactory,
|
|
2479
|
+
`${itemPath}.thumbnailFileId must be a non-empty string when provided`,
|
|
2480
|
+
);
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2472
2483
|
{
|
|
2473
2484
|
const result = validateParticleModules({
|
|
2474
2485
|
modules: item.modules,
|
|
@@ -6200,6 +6211,19 @@ export const assertInvariants = ({ state }) => {
|
|
|
6200
6211
|
continue;
|
|
6201
6212
|
}
|
|
6202
6213
|
|
|
6214
|
+
if (particle.thumbnailFileId !== undefined) {
|
|
6215
|
+
const result = validateFileReference({
|
|
6216
|
+
state,
|
|
6217
|
+
fileId: particle.thumbnailFileId,
|
|
6218
|
+
path: "particle.thumbnailFileId",
|
|
6219
|
+
details: { particleId, thumbnailFileId: particle.thumbnailFileId },
|
|
6220
|
+
errorFactory: createInvariantValidationError,
|
|
6221
|
+
});
|
|
6222
|
+
if (!result.valid) {
|
|
6223
|
+
return result;
|
|
6224
|
+
}
|
|
6225
|
+
}
|
|
6226
|
+
|
|
6203
6227
|
{
|
|
6204
6228
|
const result = validateTagIdsAgainstScope({
|
|
6205
6229
|
state,
|
|
@@ -8764,6 +8788,7 @@ const validateParticleCreateData = ({ data, errorFactory }) => {
|
|
|
8764
8788
|
"height",
|
|
8765
8789
|
"seed",
|
|
8766
8790
|
"modules",
|
|
8791
|
+
"thumbnailFileId",
|
|
8767
8792
|
],
|
|
8768
8793
|
path: "payload.data",
|
|
8769
8794
|
errorFactory,
|
|
@@ -8791,6 +8816,16 @@ const validateParticleCreateData = ({ data, errorFactory }) => {
|
|
|
8791
8816
|
return;
|
|
8792
8817
|
}
|
|
8793
8818
|
|
|
8819
|
+
if (
|
|
8820
|
+
data.thumbnailFileId !== undefined &&
|
|
8821
|
+
!isNonEmptyString(data.thumbnailFileId)
|
|
8822
|
+
) {
|
|
8823
|
+
return invalidFromErrorFactory(
|
|
8824
|
+
errorFactory,
|
|
8825
|
+
"payload.data.thumbnailFileId must be a non-empty string when provided",
|
|
8826
|
+
);
|
|
8827
|
+
}
|
|
8828
|
+
|
|
8794
8829
|
{
|
|
8795
8830
|
const result = validateOptionalUniqueIdArray({
|
|
8796
8831
|
value: data.tagIds,
|
|
@@ -8851,6 +8886,7 @@ const validateParticleUpdateData = ({ data, errorFactory }) => {
|
|
|
8851
8886
|
"height",
|
|
8852
8887
|
"seed",
|
|
8853
8888
|
"modules",
|
|
8889
|
+
"thumbnailFileId",
|
|
8854
8890
|
],
|
|
8855
8891
|
path: "payload.data",
|
|
8856
8892
|
errorFactory,
|
|
@@ -8881,6 +8917,16 @@ const validateParticleUpdateData = ({ data, errorFactory }) => {
|
|
|
8881
8917
|
);
|
|
8882
8918
|
}
|
|
8883
8919
|
|
|
8920
|
+
if (
|
|
8921
|
+
data.thumbnailFileId !== undefined &&
|
|
8922
|
+
!isNonEmptyString(data.thumbnailFileId)
|
|
8923
|
+
) {
|
|
8924
|
+
return invalidFromErrorFactory(
|
|
8925
|
+
errorFactory,
|
|
8926
|
+
"payload.data.thumbnailFileId must be a non-empty string when provided",
|
|
8927
|
+
);
|
|
8928
|
+
}
|
|
8929
|
+
|
|
8884
8930
|
{
|
|
8885
8931
|
const result = validateOptionalUniqueIdArray({
|
|
8886
8932
|
value: data.tagIds,
|
|
@@ -11263,6 +11309,20 @@ const findReferencedFileUsage = ({ state, fileId }) => {
|
|
|
11263
11309
|
}
|
|
11264
11310
|
}
|
|
11265
11311
|
|
|
11312
|
+
for (const [particleId, particle] of Object.entries(state.particles.items)) {
|
|
11313
|
+
if (particle.type !== "particle") {
|
|
11314
|
+
continue;
|
|
11315
|
+
}
|
|
11316
|
+
|
|
11317
|
+
if (particle.thumbnailFileId === fileId) {
|
|
11318
|
+
return {
|
|
11319
|
+
kind: "particle",
|
|
11320
|
+
field: "thumbnailFileId",
|
|
11321
|
+
ownerId: particleId,
|
|
11322
|
+
};
|
|
11323
|
+
}
|
|
11324
|
+
}
|
|
11325
|
+
|
|
11266
11326
|
return null;
|
|
11267
11327
|
};
|
|
11268
11328
|
|
|
@@ -15366,6 +15426,10 @@ const COMMAND_DEFINITIONS = [
|
|
|
15366
15426
|
item.seed = payload.data.seed;
|
|
15367
15427
|
}
|
|
15368
15428
|
|
|
15429
|
+
if (payload.data.thumbnailFileId !== undefined) {
|
|
15430
|
+
item.thumbnailFileId = payload.data.thumbnailFileId;
|
|
15431
|
+
}
|
|
15432
|
+
|
|
15369
15433
|
return item;
|
|
15370
15434
|
},
|
|
15371
15435
|
updateItem: ({ currentItem, payload }) => {
|
|
@@ -15393,6 +15457,18 @@ const COMMAND_DEFINITIONS = [
|
|
|
15393
15457
|
}
|
|
15394
15458
|
|
|
15395
15459
|
if (currentItem.type === "particle") {
|
|
15460
|
+
const fileResult = validateReferencedFilesInData({
|
|
15461
|
+
state,
|
|
15462
|
+
data: payload.data,
|
|
15463
|
+
fields: ["thumbnailFileId"],
|
|
15464
|
+
details: {
|
|
15465
|
+
particleId: payload.particleId,
|
|
15466
|
+
},
|
|
15467
|
+
});
|
|
15468
|
+
if (!fileResult.valid) {
|
|
15469
|
+
return fileResult;
|
|
15470
|
+
}
|
|
15471
|
+
|
|
15396
15472
|
return validateTagIdsAgainstScope({
|
|
15397
15473
|
state,
|
|
15398
15474
|
tagIds: payload.data.tagIds,
|
|
@@ -15409,6 +15485,18 @@ const COMMAND_DEFINITIONS = [
|
|
|
15409
15485
|
return;
|
|
15410
15486
|
}
|
|
15411
15487
|
|
|
15488
|
+
const fileResult = validateReferencedFilesInData({
|
|
15489
|
+
state,
|
|
15490
|
+
data: payload.data,
|
|
15491
|
+
fields: ["thumbnailFileId"],
|
|
15492
|
+
details: {
|
|
15493
|
+
particleId: payload.particleId,
|
|
15494
|
+
},
|
|
15495
|
+
});
|
|
15496
|
+
if (!fileResult.valid) {
|
|
15497
|
+
return fileResult;
|
|
15498
|
+
}
|
|
15499
|
+
|
|
15412
15500
|
return validateTagIdsAgainstScope({
|
|
15413
15501
|
state,
|
|
15414
15502
|
tagIds: payload.data.tagIds,
|