@dcl/schemas 5.0.3 → 5.0.4
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/README.md +30 -21
- package/dist/platform/item/emote/adr74/emote-data-adr74.d.ts +1 -0
- package/dist/platform/item/emote/adr74/emote-data-adr74.d.ts.map +1 -1
- package/dist/platform/item/emote/adr74/emote-data-adr74.js +5 -2
- package/dist/platform/item/emote/adr74/emote-data-adr74.js.map +1 -1
- package/dist/platform/item/emote/emote-category.d.ts +1 -2
- package/dist/platform/item/emote/emote-category.d.ts.map +1 -1
- package/dist/platform/item/emote/emote-category.js +0 -1
- package/dist/platform/item/emote/emote-category.js.map +1 -1
- package/dist/platform/merkle-tree/merkle-proof.d.ts.map +1 -1
- package/dist/platform/merkle-tree/merkle-proof.js +1 -2
- package/dist/platform/merkle-tree/merkle-proof.js.map +1 -1
- package/dist/schemas.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
# common-schemas
|
|
2
2
|
|
|
3
|
+
Decentraland data structure interfaces and validators for TypeScript-based projects.
|
|
4
|
+
|
|
5
|
+
Install it with:
|
|
3
6
|
```bash
|
|
4
7
|
npm i @dcl/schemas
|
|
5
8
|
```
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
## Design Guidelines
|
|
11
|
+
|
|
12
|
+
- Prevent type problems across projects
|
|
13
|
+
- Fail as early as possible, aim for compile-time
|
|
14
|
+
- Preserve user optionality through runtime helpers
|
|
15
|
+
- Prefer no-cost implementations and allow no-dependency import
|
|
16
|
+
- Code is written once, read hundreds of times
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
Implementation decisions:
|
|
19
|
+
|
|
20
|
+
- The main entrypoint should only export types
|
|
10
21
|
- Every type is also a namespace
|
|
11
22
|
- Type names are PascalCase
|
|
12
23
|
- Validators and schemas are camelCase
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
### Collaborator's Guide
|
|
26
|
+
|
|
27
|
+
#### Generating types, validators and schemas
|
|
15
28
|
|
|
16
|
-
|
|
29
|
+
This library export types that also act as values. This is achieved through TypeScript's [`namespaces`](https://www.typescriptlang.org/docs/handbook/namespaces.html). This means that every type imported from this library can also be used as a JS object. These types will include two properties named `schema` and `validate`. `namespaces` in typescript can be considered "`cost` imports".
|
|
30
|
+
|
|
31
|
+
#### Example Type Definition
|
|
17
32
|
|
|
18
33
|
```ts
|
|
19
34
|
// Declare type
|
|
@@ -36,12 +51,11 @@ export namespace MyType {
|
|
|
36
51
|
}
|
|
37
52
|
```
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
MyType can now be both used as type `const a: MyType` or as an object `MyType.validate(a)`.
|
|
40
55
|
|
|
41
|
-
Beware that `validate` has type `ValidateFunction<T>` which `ajv` creates automatically. When writing new
|
|
42
|
-
validations always try to implement it as an ajv validation, even if custom code is needed. See [here](https://ajv.js.org/keywords.html#define-keyword-with-code-generation-function).
|
|
56
|
+
Beware that `validate` has type `ValidateFunction<T>` which `ajv` creates automatically. When writing new validations always try to implement it as an ajv validation, even if custom code is needed. See [here](https://ajv.js.org/keywords.html#define-keyword-with-code-generation-function).
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
Particularly, beware of using the library like this, because reports by the `validator.validate` function are lost and never returned to the caller.
|
|
45
59
|
|
|
46
60
|
```ts
|
|
47
61
|
const validator = generateValidator<MyType>(schema);
|
|
@@ -49,28 +63,23 @@ export const validate = (mt: MyType) =>
|
|
|
49
63
|
validator.validate(mt) && otherValidations(mt);
|
|
50
64
|
```
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
to the caller.
|
|
54
|
-
|
|
55
|
-
## Type ownership
|
|
66
|
+
#### Code ownership
|
|
56
67
|
|
|
57
68
|
Please add types and schemas of your domain into the `src/<team>` folder, also add your team to the [CODEOWNERS](.github/CODEOWNERS) repository to make sure nobody accidentally changes it without your team noticing it.
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
Please notify about changes to the schemas to the teams by adding the whole team (i.e. `@decentraland/dapps`) as reviewers of the pull requests.
|
|
70
|
+
#### Informing changes
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
Please notify about changes to the schemas to relevant teams by adding the whole team (i.e. `@decentraland/dapps`) as reviewers of the pull requests.
|
|
64
73
|
|
|
65
|
-
|
|
74
|
+
It is recommended to subscribe to this repository (using the `Watch` function) if you use any internal part of the Decentraland ecosystem.
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
#### Making changes
|
|
68
77
|
|
|
69
|
-
To
|
|
78
|
+
To make sure the relevant persons and groups are aware of changes in these types, there's an api-extraction process executed with https://api-extractor.com that creates [a report file](report/schemas.api.md) for review between commits. It gets included as part of PRs for easier read.
|
|
70
79
|
|
|
71
|
-
|
|
80
|
+
To generate the file before submitting a PR, run `npm run refresh-api`. This is executed by the CI by runnig `npm run check-api`. It also verifies that the generated file matches the exported types.
|
|
72
81
|
|
|
73
|
-
##
|
|
82
|
+
## Versioning and Publishing
|
|
74
83
|
|
|
75
84
|
Versions are handled manually using Github releases and semver.
|
|
76
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emote-data-adr74.d.ts","sourceRoot":"","sources":["../../../../../src/platform/item/emote/adr74/emote-data-adr74.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAEL,UAAU,EACV,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AAEjE,oBAAY,cAAc,GAAG;IAC3B,QAAQ,EAAE,aAAa,CAAA;IACvB,eAAe,EAAE,wBAAwB,EAAE,CAAA;IAC3C,IAAI,EAAE,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"emote-data-adr74.d.ts","sourceRoot":"","sources":["../../../../../src/platform/item/emote/adr74/emote-data-adr74.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAEL,UAAU,EACV,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AAEjE,oBAAY,cAAc,GAAG;IAC3B,QAAQ,EAAE,aAAa,CAAA;IACvB,eAAe,EAAE,wBAAwB,EAAE,CAAA;IAC3C,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAED,yBAAiB,cAAc,CAAC;IACvB,MAAM,MAAM,EAAE,UAAU,CAAC,cAAc,CAsB7C,CAAA;IAEM,MAAM,QAAQ,EAAE,gBAAgB,CAAC,cAAc,CAC3B,CAAA;CAC5B"}
|
|
@@ -21,9 +21,12 @@ var EmoteDataADR74;
|
|
|
21
21
|
items: representation_adr74_1.EmoteRepresentationADR74.schema,
|
|
22
22
|
minItems: 1
|
|
23
23
|
},
|
|
24
|
-
category: emote_category_1.EmoteCategory.schema
|
|
24
|
+
category: emote_category_1.EmoteCategory.schema,
|
|
25
|
+
loop: {
|
|
26
|
+
type: 'boolean'
|
|
27
|
+
}
|
|
25
28
|
},
|
|
26
|
-
required: ['category', 'tags', 'representations'],
|
|
29
|
+
required: ['category', 'tags', 'representations', 'loop'],
|
|
27
30
|
additionalProperties: true
|
|
28
31
|
};
|
|
29
32
|
EmoteDataADR74.validate = (0, validation_1.generateValidator)(EmoteDataADR74.schema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emote-data-adr74.js","sourceRoot":"","sources":["../../../../../src/platform/item/emote/adr74/emote-data-adr74.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AACjD,uDAI+B;AAC/B,iEAAiE;
|
|
1
|
+
{"version":3,"file":"emote-data-adr74.js","sourceRoot":"","sources":["../../../../../src/platform/item/emote/adr74/emote-data-adr74.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AACjD,uDAI+B;AAC/B,iEAAiE;AASjE,IAAiB,cAAc,CA2B9B;AA3BD,WAAiB,cAAc;IAChB,qBAAM,GAA+B;QAChD,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,CAAC;iBACb;aACF;YACD,eAAe,EAAE;gBACf,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,+CAAwB,CAAC,MAAM;gBACtC,QAAQ,EAAE,CAAC;aACZ;YACD,QAAQ,EAAE,8BAAa,CAAC,MAAM;YAC9B,IAAI,EAAE;gBACJ,IAAI,EAAE,SAAS;aAChB;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,CAAU;QAClE,oBAAoB,EAAE,IAAI;KAC3B,CAAA;IAEY,uBAAQ,GACnB,IAAA,8BAAiB,EAAC,eAAA,MAAM,CAAC,CAAA;AAC7B,CAAC,EA3BgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QA2B9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emote-category.d.ts","sourceRoot":"","sources":["../../../../src/platform/item/emote/emote-category.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAE5B,oBAAY,aAAa;IACvB,MAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"emote-category.d.ts","sourceRoot":"","sources":["../../../../src/platform/item/emote/emote-category.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAE5B,oBAAY,aAAa;IACvB,MAAM,WAAW;CAClB;AAED,yBAAiB,aAAa,CAAC;IACtB,MAAM,MAAM,EAAE,UAAU,CAAC,aAAa,CAG5C,CAAA;IAEM,MAAM,QAAQ,EAAE,gBAAgB,CAAC,aAAa,CAC1B,CAAA;CAC5B"}
|
|
@@ -5,7 +5,6 @@ const validation_1 = require("../../../validation");
|
|
|
5
5
|
var EmoteCategory;
|
|
6
6
|
(function (EmoteCategory) {
|
|
7
7
|
EmoteCategory["SIMPLE"] = "simple";
|
|
8
|
-
EmoteCategory["LOOP"] = "loop";
|
|
9
8
|
})(EmoteCategory = exports.EmoteCategory || (exports.EmoteCategory = {}));
|
|
10
9
|
(function (EmoteCategory) {
|
|
11
10
|
EmoteCategory.schema = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emote-category.js","sourceRoot":"","sources":["../../../../src/platform/item/emote/emote-category.ts"],"names":[],"mappings":";;;AAAA,oDAI4B;AAE5B,IAAY,
|
|
1
|
+
{"version":3,"file":"emote-category.js","sourceRoot":"","sources":["../../../../src/platform/item/emote/emote-category.ts"],"names":[],"mappings":";;;AAAA,oDAI4B;AAE5B,IAAY,aAEX;AAFD,WAAY,aAAa;IACvB,kCAAiB,CAAA;AACnB,CAAC,EAFW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAExB;AAED,WAAiB,aAAa;IACf,oBAAM,GAA8B;QAC/C,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;KACnC,CAAA;IAEY,sBAAQ,GACnB,IAAA,8BAAiB,EAAC,cAAA,MAAM,CAAC,CAAA;AAC7B,CAAC,EARgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAQ7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merkle-proof.d.ts","sourceRoot":"","sources":["../../../src/platform/merkle-tree/merkle-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AAEzB;;;GAGG;AACH,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,yBAAiB,WAAW,CAAC;IACpB,MAAM,MAAM,EAAE,UAAU,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"merkle-proof.d.ts","sourceRoot":"","sources":["../../../src/platform/merkle-tree/merkle-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AAEzB;;;GAGG;AACH,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;GAGG;AACH,yBAAiB,WAAW,CAAC;IACpB,MAAM,MAAM,EAAE,UAAU,CAAC,WAAW,CAwB1C,CAAA;IAEM,MAAM,QAAQ,EAAE,gBAAgB,CAAC,WAAW,CACxB,CAAA;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merkle-proof.js","sourceRoot":"","sources":["../../../src/platform/merkle-tree/merkle-proof.ts"],"names":[],"mappings":";;;AAAA,iDAIyB;AAazB;;;GAGG;AACH,IAAiB,WAAW,
|
|
1
|
+
{"version":3,"file":"merkle-proof.js","sourceRoot":"","sources":["../../../src/platform/merkle-tree/merkle-proof.ts"],"names":[],"mappings":";;;AAAA,iDAIyB;AAazB;;;GAGG;AACH,IAAiB,WAAW,CA6B3B;AA7BD,WAAiB,WAAW;IACb,kBAAM,GAA4B;QAC7C,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;aACf;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;aACf;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC;QACzD,oBAAoB,EAAE,IAAI;KAC3B,CAAA;IAEY,oBAAQ,GACnB,IAAA,8BAAiB,EAAC,YAAA,MAAM,CAAC,CAAA;AAC7B,CAAC,EA7BgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA6B3B"}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -469,8 +469,7 @@ declare type EmoteADR74 = BaseItem & (StandardProps | ThirdPartyProps) & {
|
|
|
469
469
|
};
|
|
470
470
|
|
|
471
471
|
export declare enum EmoteCategory {
|
|
472
|
-
SIMPLE = "simple"
|
|
473
|
-
LOOP = "loop"
|
|
472
|
+
SIMPLE = "simple"
|
|
474
473
|
}
|
|
475
474
|
|
|
476
475
|
export declare namespace EmoteCategory {
|
|
@@ -482,6 +481,7 @@ export declare type EmoteDataADR74 = {
|
|
|
482
481
|
category: EmoteCategory;
|
|
483
482
|
representations: EmoteRepresentationADR74[];
|
|
484
483
|
tags: string[];
|
|
484
|
+
loop: boolean;
|
|
485
485
|
};
|
|
486
486
|
|
|
487
487
|
export declare namespace EmoteDataADR74 {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.
|
|
2
|
+
"version": "5.0.4",
|
|
3
3
|
"name": "@dcl/schemas",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"typings": "./dist/index.d.ts",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"files": [
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
|
-
"commit": "
|
|
35
|
+
"commit": "df0b2795925bfd462fb4fbe0688e96db2275c7ef"
|
|
36
36
|
}
|