@dcl/content-validator 4.2.4-4064084886.commit-5f698c4 → 4.2.4-4135566596.commit-6ae9fb8
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/validations/ADR45.d.ts +2 -2
- package/dist/validations/ADR45.d.ts.map +1 -1
- package/dist/validations/ADR45.js +7 -8
- package/dist/validations/ADR45.js.map +1 -1
- package/dist/validations/access-checker/access.d.ts +2 -2
- package/dist/validations/access-checker/access.d.ts.map +1 -1
- package/dist/validations/access-checker/access.js +15 -17
- package/dist/validations/access-checker/access.js.map +1 -1
- package/dist/validations/access-checker/emotes.d.ts +2 -2
- package/dist/validations/access-checker/emotes.d.ts.map +1 -1
- package/dist/validations/access-checker/emotes.js +7 -8
- package/dist/validations/access-checker/emotes.js.map +1 -1
- package/dist/validations/access-checker/items/collection-asset.js +2 -2
- package/dist/validations/access-checker/items/collection-asset.js.map +1 -1
- package/dist/validations/access-checker/items/items.d.ts +1 -3
- package/dist/validations/access-checker/items/items.d.ts.map +1 -1
- package/dist/validations/access-checker/items/items.js +23 -24
- package/dist/validations/access-checker/items/items.js.map +1 -1
- package/dist/validations/access-checker/profiles.d.ts +6 -6
- package/dist/validations/access-checker/profiles.d.ts.map +1 -1
- package/dist/validations/access-checker/profiles.js +59 -61
- package/dist/validations/access-checker/profiles.js.map +1 -1
- package/dist/validations/access-checker/scenes.d.ts +2 -2
- package/dist/validations/access-checker/scenes.d.ts.map +1 -1
- package/dist/validations/access-checker/scenes.js +216 -216
- package/dist/validations/access-checker/scenes.js.map +1 -1
- package/dist/validations/access-checker/stores.d.ts +2 -2
- package/dist/validations/access-checker/stores.d.ts.map +1 -1
- package/dist/validations/access-checker/stores.js +14 -15
- package/dist/validations/access-checker/stores.js.map +1 -1
- package/dist/validations/access-checker/wearables.d.ts +2 -2
- package/dist/validations/access-checker/wearables.d.ts.map +1 -1
- package/dist/validations/access-checker/wearables.js +9 -10
- package/dist/validations/access-checker/wearables.js.map +1 -1
- package/dist/validations/content.d.ts +6 -6
- package/dist/validations/content.d.ts.map +1 -1
- package/dist/validations/content.js +44 -50
- package/dist/validations/content.js.map +1 -1
- package/dist/validations/entity-structure.d.ts +2 -2
- package/dist/validations/entity-structure.d.ts.map +1 -1
- package/dist/validations/entity-structure.js +10 -11
- package/dist/validations/entity-structure.js.map +1 -1
- package/dist/validations/index.d.ts +9 -4
- package/dist/validations/index.d.ts.map +1 -1
- package/dist/validations/index.js +7 -7
- package/dist/validations/index.js.map +1 -1
- package/dist/validations/ipfs-hashing.d.ts +2 -2
- package/dist/validations/ipfs-hashing.d.ts.map +1 -1
- package/dist/validations/ipfs-hashing.js +8 -10
- package/dist/validations/ipfs-hashing.js.map +1 -1
- package/dist/validations/items/emotes.d.ts +4 -4
- package/dist/validations/items/emotes.d.ts.map +1 -1
- package/dist/validations/items/emotes.js +22 -24
- package/dist/validations/items/emotes.js.map +1 -1
- package/dist/validations/items/items.d.ts +4 -4
- package/dist/validations/items/items.d.ts.map +1 -1
- package/dist/validations/items/items.js +54 -55
- package/dist/validations/items/items.js.map +1 -1
- package/dist/validations/items/wearables.d.ts +4 -3
- package/dist/validations/items/wearables.d.ts.map +1 -1
- package/dist/validations/items/wearables.js +16 -17
- package/dist/validations/items/wearables.js.map +1 -1
- package/dist/validations/metadata-schema.d.ts +2 -2
- package/dist/validations/metadata-schema.d.ts.map +1 -1
- package/dist/validations/metadata-schema.js +17 -21
- package/dist/validations/metadata-schema.js.map +1 -1
- package/dist/validations/profile.d.ts +6 -6
- package/dist/validations/profile.d.ts.map +1 -1
- package/dist/validations/profile.js +55 -63
- package/dist/validations/profile.js.map +1 -1
- package/dist/validations/scene.d.ts +3 -3
- package/dist/validations/scene.d.ts.map +1 -1
- package/dist/validations/scene.js +5 -7
- package/dist/validations/scene.js.map +1 -1
- package/dist/validations/signature.d.ts +2 -2
- package/dist/validations/signature.d.ts.map +1 -1
- package/dist/validations/signature.js +6 -8
- package/dist/validations/signature.js.map +1 -1
- package/dist/validations/size.d.ts +2 -2
- package/dist/validations/size.d.ts.map +1 -1
- package/dist/validations/size.js +28 -29
- package/dist/validations/size.js.map +1 -1
- package/dist/validations/validations.d.ts +9 -9
- package/dist/validations/validations.d.ts.map +1 -1
- package/dist/validations/validations.js +34 -38
- package/dist/validations/validations.js.map +1 -1
- package/package.json +3 -3
|
@@ -10,70 +10,64 @@ const correspondsToASnapshot = (fileName, hash, metadata) => {
|
|
|
10
10
|
return false;
|
|
11
11
|
return metadata.avatars.some((avatar) => Object.entries(avatar.avatar.snapshots).some((key) => key[0] === fileNameWithoutExtension && key[1] === hash));
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
errors.push(`This hash is referenced in the entity but was not uploaded or previously available: ${hash}`);
|
|
23
|
-
}
|
|
13
|
+
async function allHashesWereUploadedOrStored(components, deployment) {
|
|
14
|
+
const { entity, files } = deployment;
|
|
15
|
+
const errors = [];
|
|
16
|
+
if (entity.content) {
|
|
17
|
+
const alreadyStoredHashes = await components.externalCalls.isContentStoredAlready(entity.content?.map((file) => file.hash) ?? []);
|
|
18
|
+
for (const { hash } of entity.content) {
|
|
19
|
+
// Validate that all hashes in entity were uploaded, or were already stored on the service
|
|
20
|
+
if (!(files.has(hash) || alreadyStoredHashes.get(hash))) {
|
|
21
|
+
errors.push(`This hash is referenced in the entity but was not uploaded or previously available: ${hash}`);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
return (0, types_1.fromErrors)(...errors);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
25
|
+
return (0, types_1.fromErrors)(...errors);
|
|
26
|
+
}
|
|
27
|
+
exports.allHashesWereUploadedOrStored = allHashesWereUploadedOrStored;
|
|
28
|
+
async function allHashesInUploadedFilesAreReportedInTheEntity(components, deployment) {
|
|
29
|
+
const { entity, files } = deployment;
|
|
30
|
+
const errors = [];
|
|
31
|
+
// Validate that all hashes that belong to uploaded files are actually reported on the entity
|
|
32
|
+
const entityHashes = new Set(entity.content?.map(({ hash }) => hash) ?? []);
|
|
33
|
+
for (const [hash] of files) {
|
|
34
|
+
if (!entityHashes.has(hash) && hash !== entity.id) {
|
|
35
|
+
errors.push(`This hash was uploaded but is not referenced in the entity: ${hash}`);
|
|
39
36
|
}
|
|
40
|
-
return (0, types_1.fromErrors)(...errors);
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
38
|
+
return (0, types_1.fromErrors)(...errors);
|
|
39
|
+
}
|
|
40
|
+
exports.allHashesInUploadedFilesAreReportedInTheEntity = allHashesInUploadedFilesAreReportedInTheEntity;
|
|
41
|
+
exports.allContentFilesCorrespondToAtLeastOneAvatarSnapshotAfterADR45 = (0, validations_1.validateAfterADR45)(async (components, deployment) => {
|
|
42
|
+
const { entity } = deployment;
|
|
43
|
+
const errors = [];
|
|
44
|
+
for (const { file, hash } of entity.content ?? []) {
|
|
45
|
+
// Validate all content files correspond to at least one avatar snapshot
|
|
46
|
+
if (entity.type === schemas_1.EntityType.PROFILE) {
|
|
47
|
+
if (!correspondsToASnapshot(file, hash, entity.metadata)) {
|
|
48
|
+
errors.push(`This file is not expected: '${file}' or its hash is invalid: '${hash}'. Please, include only valid snapshot files.`);
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
|
-
return (0, types_1.fromErrors)(...errors);
|
|
56
51
|
}
|
|
52
|
+
return (0, types_1.fromErrors)(...errors);
|
|
57
53
|
});
|
|
58
|
-
exports.allMandatoryContentFilesArePresent = (0, validations_1.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
errors.push(`Profile entity is missing file 'face256.png'`);
|
|
69
|
-
}
|
|
54
|
+
exports.allMandatoryContentFilesArePresent = (0, validations_1.validateAfterADR158)(async (components, deployment) => {
|
|
55
|
+
const { entity } = deployment;
|
|
56
|
+
const errors = [];
|
|
57
|
+
if (entity.type === schemas_1.EntityType.PROFILE) {
|
|
58
|
+
const fileNames = entity.content.map((a) => a.file.toLowerCase());
|
|
59
|
+
if (!fileNames.includes('body.png')) {
|
|
60
|
+
errors.push(`Profile entity is missing file 'body.png'`);
|
|
61
|
+
}
|
|
62
|
+
if (!fileNames.includes('face256.png')) {
|
|
63
|
+
errors.push(`Profile entity is missing file 'face256.png'`);
|
|
70
64
|
}
|
|
71
|
-
return (0, types_1.fromErrors)(...errors);
|
|
72
65
|
}
|
|
66
|
+
return (0, types_1.fromErrors)(...errors);
|
|
73
67
|
});
|
|
74
68
|
/**
|
|
75
69
|
* Validate that uploaded and reported hashes are corrects and files corresponds to snapshots
|
|
76
70
|
* @public
|
|
77
71
|
*/
|
|
78
|
-
exports.content = (0, validations_1.
|
|
72
|
+
exports.content = (0, validations_1.validateAll)(allHashesWereUploadedOrStored, allHashesInUploadedFilesAreReportedInTheEntity, exports.allContentFilesCorrespondToAtLeastOneAvatarSnapshotAfterADR45, exports.allMandatoryContentFilesArePresent);
|
|
79
73
|
//# sourceMappingURL=content.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/validations/content.ts"],"names":[],"mappings":";;;AAAA,0CAA0D;AAC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,EAAE;gBACxD,MAAM,CAAC,IAAI,CACT,+BAA+B,IAAI,8BAA8B,IAAI,+CAA+C,CACrH,CAAA;aACF;SACF;KACF;IACD,OAAO,IAAA,kBAAU,EAAC,GAAG,MAAM,CAAC,CAAA;AAC9B,CAAC,CACF,CAAA;AAEY,QAAA,kCAAkC,GAAe,IAAA,iCAAmB,EAC/E,KAAK,EAAE,UAAsC,EAAE,UAAgC,EAAE,EAAE;IACjF,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAC7B,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,MAAM,CAAC,IAAI,KAAK,oBAAU,CAAC,OAAO,EAAE;QACtC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;QACjE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACnC,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAA;SACzD;QACD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE;YACtC,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAA;SAC5D;KACF;IACD,OAAO,IAAA,kBAAU,EAAC,GAAG,MAAM,CAAC,CAAA;AAC9B,CAAC,CACF,CAAA;AAED;;;GAGG;AACU,QAAA,OAAO,GAAe,IAAA,yBAAW,EAC5C,6BAA6B,EAC7B,8CAA8C,EAC9C,qEAA6D,EAC7D,0CAAkC,CACnC,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Validate that entity is actually ok
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare
|
|
6
|
+
export declare function entityStructure(components: ContentValidatorComponents, deployment: DeploymentToValidate): Promise<import("../types").ValidationResponse>;
|
|
7
7
|
//# sourceMappingURL=entity-structure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-structure.d.ts","sourceRoot":"","sources":["../../src/validations/entity-structure.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-structure.d.ts","sourceRoot":"","sources":["../../src/validations/entity-structure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAwB,MAAM,UAAU,CAAA;AAEjG;;;GAGG;AACH,wBAAsB,eAAe,CAAC,UAAU,EAAE,0BAA0B,EAAE,UAAU,EAAE,oBAAoB,kDAQ7G"}
|
|
@@ -6,16 +6,15 @@ const types_1 = require("../types");
|
|
|
6
6
|
* Validate that entity is actually ok
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return (0, types_1.validationFailed)('There are repeated pointers in your request.');
|
|
14
|
-
}
|
|
15
|
-
else if (!entity.pointers || entity.pointers.length <= 0) {
|
|
16
|
-
return (0, types_1.validationFailed)('The entity needs to be pointed by one or more pointers.');
|
|
17
|
-
}
|
|
18
|
-
return types_1.OK;
|
|
9
|
+
async function entityStructure(components, deployment) {
|
|
10
|
+
const { entity } = deployment;
|
|
11
|
+
if (new Set(entity.pointers).size != entity.pointers.length) {
|
|
12
|
+
return (0, types_1.validationFailed)('There are repeated pointers in your request.');
|
|
19
13
|
}
|
|
20
|
-
|
|
14
|
+
else if (!entity.pointers || entity.pointers.length <= 0) {
|
|
15
|
+
return (0, types_1.validationFailed)('The entity needs to be pointed by one or more pointers.');
|
|
16
|
+
}
|
|
17
|
+
return types_1.OK;
|
|
18
|
+
}
|
|
19
|
+
exports.entityStructure = entityStructure;
|
|
21
20
|
//# sourceMappingURL=entity-structure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-structure.js","sourceRoot":"","sources":["../../src/validations/entity-structure.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"entity-structure.js","sourceRoot":"","sources":["../../src/validations/entity-structure.ts"],"names":[],"mappings":";;;AAAA,oCAAiG;AAEjG;;;GAGG;AACI,KAAK,UAAU,eAAe,CAAC,UAAsC,EAAE,UAAgC;IAC5G,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAC7B,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;QAC3D,OAAO,IAAA,wBAAgB,EAAC,8CAA8C,CAAC,CAAA;KACxE;SAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE;QAC1D,OAAO,IAAA,wBAAgB,EAAC,yDAAyD,CAAC,CAAA;KACnF;IACD,OAAO,UAAE,CAAA;AACX,CAAC;AARD,0CAQC"}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { DeploymentToValidate, ExternalCalls } from '../types';
|
|
2
|
+
import { access } from './access-checker/access';
|
|
3
|
+
import { adr45 } from './ADR45';
|
|
4
|
+
import { entityStructure } from './entity-structure';
|
|
5
|
+
import { signature } from './signature';
|
|
6
|
+
import { size } from './size';
|
|
2
7
|
/**
|
|
3
8
|
* @public
|
|
4
9
|
*/
|
|
5
|
-
export declare
|
|
10
|
+
export declare function calculateDeploymentSize(deployment: DeploymentToValidate, externalCalls: ExternalCalls): Promise<number | string>;
|
|
6
11
|
/**
|
|
7
12
|
* Stateful validations that are run on a deployment.
|
|
8
13
|
* @public
|
|
9
14
|
*/
|
|
10
|
-
export declare const
|
|
15
|
+
export declare const statefulValidateFns: readonly [typeof signature, typeof access, typeof size, import("../types").ValidateFn, import("../types").ValidateFn, import("../types").ValidateFn, import("../types").ValidateFn, import("../types").ValidateFn];
|
|
11
16
|
/**
|
|
12
17
|
* Stateless validations that are run on a deployment.
|
|
13
18
|
* @public
|
|
14
19
|
*/
|
|
15
|
-
export declare const
|
|
20
|
+
export declare const statelessValidateFns: readonly [typeof entityStructure, import("../types").ValidateFn, import("../types").ValidateFn, typeof adr45];
|
|
16
21
|
/**
|
|
17
22
|
* All validations that are run on a deployment.
|
|
18
23
|
* @public
|
|
19
24
|
*/
|
|
20
|
-
export declare const
|
|
25
|
+
export declare const validateFns: readonly [typeof entityStructure, import("../types").ValidateFn, import("../types").ValidateFn, typeof adr45, typeof signature, typeof access, typeof size, import("../types").ValidateFn, import("../types").ValidateFn, import("../types").ValidateFn, import("../types").ValidateFn, import("../types").ValidateFn];
|
|
21
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAG7B;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,CAa1B;AAED;;;GAGG;AAEH,eAAO,MAAM,mBAAmB,oNAA+E,CAAA;AAE/G;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+GAA2D,CAAA;AAE5F;;;GAGG;AACH,eAAO,MAAM,WAAW,wTAA6D,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const ADR45_1 = require("./ADR45");
|
|
3
|
+
exports.validateFns = exports.statelessValidateFns = exports.statefulValidateFns = exports.calculateDeploymentSize = void 0;
|
|
5
4
|
const access_1 = require("./access-checker/access");
|
|
5
|
+
const ADR45_1 = require("./ADR45");
|
|
6
6
|
const content_1 = require("./content");
|
|
7
7
|
const entity_structure_1 = require("./entity-structure");
|
|
8
8
|
const ipfs_hashing_1 = require("./ipfs-hashing");
|
|
@@ -16,7 +16,7 @@ const scene_1 = require("./scene");
|
|
|
16
16
|
/**
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
async function calculateDeploymentSize(deployment, externalCalls) {
|
|
20
20
|
let totalSize = 0;
|
|
21
21
|
for (const hash of new Set(deployment.entity.content?.map((item) => item.hash) ?? [])) {
|
|
22
22
|
const uploadedFile = deployment.files.get(hash);
|
|
@@ -31,21 +31,21 @@ const calculateDeploymentSize = async (deployment, externalCalls) => {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return totalSize;
|
|
34
|
-
}
|
|
34
|
+
}
|
|
35
35
|
exports.calculateDeploymentSize = calculateDeploymentSize;
|
|
36
36
|
/**
|
|
37
37
|
* Stateful validations that are run on a deployment.
|
|
38
38
|
* @public
|
|
39
39
|
*/
|
|
40
|
-
exports.
|
|
40
|
+
exports.statefulValidateFns = [signature_1.signature, access_1.access, size_1.size, wearables_1.wearable, emotes_1.emote, profile_1.profile, scene_1.scene, content_1.content];
|
|
41
41
|
/**
|
|
42
42
|
* Stateless validations that are run on a deployment.
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
|
-
exports.
|
|
45
|
+
exports.statelessValidateFns = [entity_structure_1.entityStructure, ipfs_hashing_1.ipfsHashing, metadata_schema_1.metadata, ADR45_1.adr45];
|
|
46
46
|
/**
|
|
47
47
|
* All validations that are run on a deployment.
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
|
-
exports.
|
|
50
|
+
exports.validateFns = [...exports.statelessValidateFns, ...exports.statefulValidateFns];
|
|
51
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":";;;AACA,mCAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":";;;AACA,oDAAgD;AAChD,mCAA+B;AAC/B,uCAAmC;AACnC,yDAAoD;AACpD,iDAA4C;AAC5C,2CAAsC;AACtC,iDAA4C;AAC5C,uDAA4C;AAC5C,uCAAmC;AACnC,2CAAuC;AACvC,iCAA6B;AAC7B,mCAA+B;AAE/B;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAC3C,UAAgC,EAChC,aAA4B;IAE5B,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE;QACrF,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC/C,IAAI,YAAY,EAAE;YAChB,SAAS,IAAI,YAAY,CAAC,UAAU,CAAA;SACrC;aAAM;YACL,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;YAClE,IAAI,WAAW,KAAK,SAAS;gBAAE,OAAO,0CAA0C,IAAI,EAAE,CAAA;YACtF,SAAS,IAAI,WAAW,CAAA;SACzB;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAhBD,0DAgBC;AAED;;;GAGG;AAEU,QAAA,mBAAmB,GAAG,CAAC,qBAAS,EAAE,eAAM,EAAE,WAAI,EAAE,oBAAQ,EAAE,cAAK,EAAE,iBAAO,EAAE,aAAK,EAAE,iBAAO,CAAU,CAAA;AAE/G;;;GAGG;AACU,QAAA,oBAAoB,GAAG,CAAC,kCAAe,EAAE,0BAAW,EAAE,0BAAQ,EAAE,aAAK,CAAU,CAAA;AAE5F;;;GAGG;AACU,QAAA,WAAW,GAAG,CAAC,GAAG,4BAAoB,EAAE,GAAG,2BAAmB,CAAU,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValidateFn } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Validate that all hashes used by the entity were actually IPFS hashes
|
|
4
4
|
* @public
|
|
5
5
|
*/
|
|
6
|
-
export declare const ipfsHashing:
|
|
6
|
+
export declare const ipfsHashing: ValidateFn;
|
|
7
7
|
//# sourceMappingURL=ipfs-hashing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs-hashing.d.ts","sourceRoot":"","sources":["../../src/validations/ipfs-hashing.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"ipfs-hashing.d.ts","sourceRoot":"","sources":["../../src/validations/ipfs-hashing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,UAAU,EAAE,MAAM,UAAU,CAAA;AAGvE;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,UAazB,CAAA"}
|
|
@@ -8,15 +8,13 @@ const validations_1 = require("./validations");
|
|
|
8
8
|
* Validate that all hashes used by the entity were actually IPFS hashes
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
exports.ipfsHashing = (0, validations_1.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return (0, types_1.fromErrors)(...errors);
|
|
20
|
-
}
|
|
11
|
+
exports.ipfsHashing = (0, validations_1.validateAfterADR45)((components, deployment) => {
|
|
12
|
+
const { entity } = deployment;
|
|
13
|
+
const hashesInContent = entity.content?.map(({ hash }) => hash) ?? [];
|
|
14
|
+
const allHashes = [entity.id, ...hashesInContent];
|
|
15
|
+
const errors = allHashes
|
|
16
|
+
.filter((hash) => !schemas_1.IPFSv2.validate(hash))
|
|
17
|
+
.map((hash) => `This hash '${hash}' is not valid. It should be IPFS v2 format.`);
|
|
18
|
+
return (0, types_1.fromErrors)(...errors);
|
|
21
19
|
});
|
|
22
20
|
//# sourceMappingURL=ipfs-hashing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs-hashing.js","sourceRoot":"","sources":["../../src/validations/ipfs-hashing.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AAErC,
|
|
1
|
+
{"version":3,"file":"ipfs-hashing.js","sourceRoot":"","sources":["../../src/validations/ipfs-hashing.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AAErC,oCAAuE;AACvE,+CAAkD;AAElD;;;GAGG;AACU,QAAA,WAAW,GAAe,IAAA,gCAAkB,EACvD,CAAC,UAAsC,EAAE,UAAgC,EAAE,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAE7B,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IACrE,MAAM,SAAS,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,eAAe,CAAC,CAAA;IAEjD,MAAM,MAAM,GAAG,SAAS;SACrB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,gBAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACxC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,IAAI,8CAA8C,CAAC,CAAA;IAElF,OAAO,IAAA,kBAAU,EAAC,GAAG,MAAM,CAAC,CAAA;AAC9B,CAAC,CACF,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare const emote:
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate, ValidateFn } from '../../types';
|
|
2
|
+
export declare function wasCreatedAfterADR74(components: ContentValidatorComponents, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
3
|
+
export declare function emoteRepresentationContent(components: ContentValidatorComponents, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
4
|
+
export declare const emote: ValidateFn;
|
|
5
5
|
//# sourceMappingURL=emotes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emotes.d.ts","sourceRoot":"","sources":["../../../src/validations/items/emotes.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"emotes.d.ts","sourceRoot":"","sources":["../../../src/validations/items/emotes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;AAIhH,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,0BAA0B,EAAE,UAAU,EAAE,oBAAoB,qDAMlH;AAED,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,0BAA0B,EACtC,UAAU,EAAE,oBAAoB,qDAgBjC;AAED,eAAO,MAAM,KAAK,EAAE,UAGnB,CAAA"}
|
|
@@ -5,31 +5,29 @@ const schemas_1 = require("@dcl/schemas");
|
|
|
5
5
|
const types_1 = require("../../types");
|
|
6
6
|
const timestamps_1 = require("../timestamps");
|
|
7
7
|
const validations_1 = require("../validations");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!entity.content.find((content) => content.file === representationContent)) {
|
|
27
|
-
return (0, types_1.validationFailed)(`Representation content: '${representationContent}' is not one of the content files`);
|
|
28
|
-
}
|
|
8
|
+
async function wasCreatedAfterADR74(components, deployment) {
|
|
9
|
+
return deployment.entity.timestamp < timestamps_1.ADR_74_TIMESTAMP
|
|
10
|
+
? (0, types_1.validationFailed)(`The emote timestamp ${deployment.entity.timestamp} is before ADR 74. Emotes did not exist before ADR 74.`)
|
|
11
|
+
: types_1.OK;
|
|
12
|
+
}
|
|
13
|
+
exports.wasCreatedAfterADR74 = wasCreatedAfterADR74;
|
|
14
|
+
async function emoteRepresentationContent(components, deployment) {
|
|
15
|
+
const { entity } = deployment;
|
|
16
|
+
const metadata = entity.metadata;
|
|
17
|
+
const representations = metadata?.emoteDataADR74?.representations;
|
|
18
|
+
if (!representations || representations.length === 0)
|
|
19
|
+
return (0, types_1.validationFailed)('No emote representations found');
|
|
20
|
+
if (!entity.content || entity.content.length === 0)
|
|
21
|
+
return (0, types_1.validationFailed)('No content found');
|
|
22
|
+
for (const representation of representations) {
|
|
23
|
+
for (const representationContent of representation.contents) {
|
|
24
|
+
if (!entity.content.find((content) => content.file === representationContent)) {
|
|
25
|
+
return (0, types_1.validationFailed)(`Representation content: '${representationContent}' is not one of the content files`);
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
return types_1.OK;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
return types_1.OK;
|
|
30
|
+
}
|
|
31
|
+
exports.emoteRepresentationContent = emoteRepresentationContent;
|
|
32
|
+
exports.emote = (0, validations_1.validateIfTypeMatches)(schemas_1.EntityType.EMOTE, (0, validations_1.validateAll)(wasCreatedAfterADR74, emoteRepresentationContent));
|
|
35
33
|
//# sourceMappingURL=emotes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emotes.js","sourceRoot":"","sources":["../../../src/validations/items/emotes.ts"],"names":[],"mappings":";;;AAAA,0CAAgD;AAChD,uCAAgH;AAChH,8CAAgD;AAChD,gDAAmE;
|
|
1
|
+
{"version":3,"file":"emotes.js","sourceRoot":"","sources":["../../../src/validations/items/emotes.ts"],"names":[],"mappings":";;;AAAA,0CAAgD;AAChD,uCAAgH;AAChH,8CAAgD;AAChD,gDAAmE;AAE5D,KAAK,UAAU,oBAAoB,CAAC,UAAsC,EAAE,UAAgC;IACjH,OAAO,UAAU,CAAC,MAAM,CAAC,SAAS,GAAG,6BAAgB;QACnD,CAAC,CAAC,IAAA,wBAAgB,EACd,uBAAuB,UAAU,CAAC,MAAM,CAAC,SAAS,wDAAwD,CAC3G;QACH,CAAC,CAAC,UAAE,CAAA;AACR,CAAC;AAND,oDAMC;AAEM,KAAK,UAAU,0BAA0B,CAC9C,UAAsC,EACtC,UAAgC;IAEhC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAiB,CAAA;IACzC,MAAM,eAAe,GAAG,QAAQ,EAAE,cAAc,EAAE,eAAe,CAAA;IACjE,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAA,wBAAgB,EAAC,gCAAgC,CAAC,CAAA;IAC/G,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAA,wBAAgB,EAAC,kBAAkB,CAAC,CAAA;IAE/F,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;QAC5C,KAAK,MAAM,qBAAqB,IAAI,cAAc,CAAC,QAAQ,EAAE;YAC3D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,qBAAqB,CAAC,EAAE;gBAC7E,OAAO,IAAA,wBAAgB,EAAC,4BAA4B,qBAAqB,mCAAmC,CAAC,CAAA;aAC9G;SACF;KACF;IACD,OAAO,UAAE,CAAA;AACX,CAAC;AAlBD,gEAkBC;AAEY,QAAA,KAAK,GAAe,IAAA,mCAAqB,EACpD,oBAAU,CAAC,KAAK,EAChB,IAAA,yBAAW,EAAC,oBAAoB,EAAE,0BAA0B,CAAC,CAC9D,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContentValidatorComponents, DeploymentToValidate, ValidateFn } from '../../types';
|
|
2
2
|
/** Validate item files size, excluding thumbnail, is less than expected */
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
3
|
+
export declare function deploymentMaxSizeExcludingThumbnailIsNotExceeded(components: Pick<ContentValidatorComponents, 'externalCalls'>, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
4
|
+
export declare function thumbnailMaxSizeIsNotExceeded(components: Pick<ContentValidatorComponents, 'externalCalls' | 'logs'>, deployment: DeploymentToValidate): Promise<import("../../types").ValidationResponse>;
|
|
5
5
|
/**
|
|
6
6
|
* Validate that given item deployment includes the thumbnail and doesn't exceed file sizes
|
|
7
7
|
* * @public
|
|
8
8
|
*/
|
|
9
|
-
export declare const items:
|
|
9
|
+
export declare const items: ValidateFn;
|
|
10
10
|
//# sourceMappingURL=items.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../src/validations/items/items.ts"],"names":[],"mappings":"AAIA,OAAO,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"items.d.ts","sourceRoot":"","sources":["../../../src/validations/items/items.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAM,UAAU,EAAoB,MAAM,aAAa,CAAA;AAIhH,2EAA2E;AAC3E,wBAAsB,gDAAgD,CACpE,UAAU,EAAE,IAAI,CAAC,0BAA0B,EAAE,eAAe,CAAC,EAC7D,UAAU,EAAE,oBAAoB,qDAyBjC;AAID,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,IAAI,CAAC,0BAA0B,EAAE,eAAe,GAAG,MAAM,CAAC,EACtE,UAAU,EAAE,oBAAoB,qDAkCjC;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,UAGnB,CAAA"}
|
|
@@ -11,69 +11,68 @@ const types_1 = require("../../types");
|
|
|
11
11
|
const ADR51_1 = require("../ADR51");
|
|
12
12
|
const validations_1 = require("../validations");
|
|
13
13
|
/** Validate item files size, excluding thumbnail, is less than expected */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
14
|
+
async function deploymentMaxSizeExcludingThumbnailIsNotExceeded(components, deployment) {
|
|
15
|
+
const entity = deployment.entity;
|
|
16
|
+
const maxSizeInMB = ADR51_1.entityParameters[entity.type]?.maxSizeInMB;
|
|
17
|
+
if (!maxSizeInMB)
|
|
18
|
+
return (0, types_1.validationFailed)(`Type ${entity.type} is not supported yet`);
|
|
19
|
+
const modelSizeInMB = maxSizeInMB - maxThumbnailSizeInB / 1024;
|
|
20
|
+
const metadata = entity.metadata;
|
|
21
|
+
const thumbnailHash = entity.content?.find(({ file }) => file === metadata.thumbnail)?.hash;
|
|
22
|
+
if (!thumbnailHash)
|
|
23
|
+
return (0, types_1.validationFailed)("Couldn't find the thumbnail hash");
|
|
24
|
+
const totalDeploymentSizeInB = await (0, __1.calculateDeploymentSize)(deployment, components.externalCalls);
|
|
25
|
+
if (typeof totalDeploymentSizeInB === 'string')
|
|
26
|
+
return (0, types_1.validationFailed)(totalDeploymentSizeInB);
|
|
27
|
+
const thumbnailSize = deployment.files.get(thumbnailHash)?.byteLength ?? 0;
|
|
28
|
+
const modelSize = totalDeploymentSizeInB - thumbnailSize;
|
|
29
|
+
if (modelSize > modelSizeInMB * 1024 * 1024)
|
|
30
|
+
return (0, types_1.validationFailed)(`The deployment is too big. The maximum allowed size for ${entity.type} model files is ${modelSizeInMB} MB. You can upload up to ${modelSizeInMB * 1024 * 1024} bytes but you tried to upload ${modelSize}.`);
|
|
31
|
+
return types_1.OK;
|
|
32
|
+
}
|
|
33
|
+
exports.deploymentMaxSizeExcludingThumbnailIsNotExceeded = deploymentMaxSizeExcludingThumbnailIsNotExceeded;
|
|
35
34
|
/** Validate that given item deployment includes a thumbnail with valid format and size */
|
|
36
35
|
const maxThumbnailSizeInB = 1024;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
// otherwise, thumbnail was already uploaded and won't be validated again
|
|
54
|
-
logger.debug(`Thumbnail file with hash: ${hash} is not in the deployment, but it is already stored`);
|
|
55
|
-
return types_1.OK;
|
|
36
|
+
async function thumbnailMaxSizeIsNotExceeded(components, deployment) {
|
|
37
|
+
const { externalCalls, logs } = components;
|
|
38
|
+
const logger = logs.getLogger(`${deployment.entity.type} validator`);
|
|
39
|
+
// read thumbnail field from metadata
|
|
40
|
+
const metadata = deployment.entity.metadata;
|
|
41
|
+
const hash = deployment.entity.content?.find(({ file }) => file === metadata.thumbnail)?.hash;
|
|
42
|
+
if (!hash)
|
|
43
|
+
return (0, types_1.validationFailed)(`Couldn't find hash for thumbnail file with name: ${metadata.thumbnail}`);
|
|
44
|
+
const errors = [];
|
|
45
|
+
// check size
|
|
46
|
+
const thumbnailBuffer = deployment.files.get(hash);
|
|
47
|
+
if (!thumbnailBuffer) {
|
|
48
|
+
const isHashStored = (await externalCalls.isContentStoredAlready([hash])).get(hash) ?? false;
|
|
49
|
+
if (!isHashStored) {
|
|
50
|
+
return (0, types_1.validationFailed)(`Couldn't find thumbnail file with hash: ${hash}`);
|
|
56
51
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
52
|
+
// otherwise, thumbnail was already uploaded and won't be validated again
|
|
53
|
+
logger.debug(`Thumbnail file with hash: ${hash} is not in the deployment, but it is already stored`);
|
|
54
|
+
return types_1.OK;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const { width, height, format } = await (0, sharp_1.default)(thumbnailBuffer).metadata();
|
|
58
|
+
if (!format || format !== 'png')
|
|
59
|
+
errors.push(`Invalid or unknown image format. Only 'PNG' format is accepted.`);
|
|
60
|
+
if (!width || !height) {
|
|
61
|
+
errors.push(`Couldn't validate thumbnail size for file ${metadata.thumbnail}`);
|
|
67
62
|
}
|
|
68
|
-
|
|
69
|
-
errors.push(`
|
|
63
|
+
else if (width > maxThumbnailSizeInB || height > maxThumbnailSizeInB) {
|
|
64
|
+
errors.push(`Invalid thumbnail image size (width = ${width} / height = ${height})`);
|
|
70
65
|
}
|
|
71
|
-
return errors.length > 0 ? (0, types_1.validationFailed)(...errors) : types_1.OK;
|
|
72
66
|
}
|
|
73
|
-
|
|
67
|
+
catch (e) {
|
|
68
|
+
errors.push(`Couldn't parse thumbnail, please check image format.`);
|
|
69
|
+
}
|
|
70
|
+
return errors.length > 0 ? (0, types_1.validationFailed)(...errors) : types_1.OK;
|
|
71
|
+
}
|
|
72
|
+
exports.thumbnailMaxSizeIsNotExceeded = thumbnailMaxSizeIsNotExceeded;
|
|
74
73
|
/**
|
|
75
74
|
* Validate that given item deployment includes the thumbnail and doesn't exceed file sizes
|
|
76
75
|
* * @public
|
|
77
76
|
*/
|
|
78
|
-
exports.items = (0, validations_1.
|
|
77
|
+
exports.items = (0, validations_1.validateIfConditionMet)((deployment) => deployment.entity.type === schemas_1.EntityType.WEARABLE || deployment.entity.type === schemas_1.EntityType.EMOTE, (0, validations_1.validateAfterADR45)((0, validations_1.validateAll)(thumbnailMaxSizeIsNotExceeded, deploymentMaxSizeExcludingThumbnailIsNotExceeded)));
|
|
79
78
|
//# sourceMappingURL=items.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.js","sourceRoot":"","sources":["../../../src/validations/items/items.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAmD;AAEnD,kDAAyB;AACzB,0BAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"items.js","sourceRoot":"","sources":["../../../src/validations/items/items.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAmD;AAEnD,kDAAyB;AACzB,0BAA4C;AAC5C,uCAAgH;AAChH,oCAA2C;AAC3C,gDAAwF;AAExF,2EAA2E;AACpE,KAAK,UAAU,gDAAgD,CACpE,UAA6D,EAC7D,UAAgC;IAEhC,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;IAChC,MAAM,WAAW,GAAG,wBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,WAAW,CAAA;IAC9D,IAAI,CAAC,WAAW;QAAE,OAAO,IAAA,wBAAgB,EAAC,QAAQ,MAAM,CAAC,IAAI,uBAAuB,CAAC,CAAA;IAErF,MAAM,aAAa,GAAG,WAAW,GAAG,mBAAmB,GAAG,IAAI,CAAA;IAE9D,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAoB,CAAA;IAC5C,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EA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