@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 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
- ### Design considerations
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
- - The main entrypoint of the library export types only (and the helper functions to prevent lockin)
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
- ## Generating types, validators and schemas
25
+ ### Collaborator's Guide
26
+
27
+ #### Generating types, validators and schemas
15
28
 
16
- We will export types that also act as values. We do that using the "namespaces" of typescript. That is, every type is also a JS object, including two properties: `schema` and `validate`. It can also be a const, but a namespace _sounds_ better.
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
- In that sense, MyType can be both used as type `const a: MyType` and as object `MyType.validate(a)`.
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
- In particular, don't fall in the trap of doing this:
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
- By doing this, all the errors reported by the `validator.validate` function are lost and never returned
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
- ## Informing changes
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
- It is recommended that if you are a stakeholder of the interoperable parts of Decentraland, you are subscribed to this repository (wathing it in the button up right).
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
- ## Making changes
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
- To make sure everybody is aware of changes in types, we have a process of api-extraction using https://api-extractor.com. It creates [a report file](report/schemas.api.md) that should be reviewed upon every change and committed as part of the PR.
76
+ #### Making changes
68
77
 
69
- To generate the file with your changes run `npm run refresh-api`.
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
- In the CI, `npm run check-api` is executed to verify the generated file matches the exported types.
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
- ## Versions and publishing
82
+ ## Versioning and Publishing
74
83
 
75
84
  Versions are handled manually using Github releases and semver.
76
85
 
@@ -5,6 +5,7 @@ export declare type EmoteDataADR74 = {
5
5
  category: EmoteCategory;
6
6
  representations: EmoteRepresentationADR74[];
7
7
  tags: string[];
8
+ loop: boolean;
8
9
  };
9
10
  export declare namespace EmoteDataADR74 {
10
11
  const schema: JSONSchema<EmoteDataADR74>;
@@ -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;CACf,CAAA;AAED,yBAAiB,cAAc,CAAC;IACvB,MAAM,MAAM,EAAE,UAAU,CAAC,cAAc,CAmB7C,CAAA;IAEM,MAAM,QAAQ,EAAE,gBAAgB,CAAC,cAAc,CAC3B,CAAA;CAC5B"}
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;AAQjE,IAAiB,cAAc,CAwB9B;AAxBD,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;SAC/B;QACD,QAAQ,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,iBAAiB,CAAU;QAC1D,oBAAoB,EAAE,IAAI;KAC3B,CAAA;IAEY,uBAAQ,GACnB,IAAA,8BAAiB,EAAC,eAAA,MAAM,CAAC,CAAA;AAC7B,CAAC,EAxBgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAwB9B"}
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,7 +1,6 @@
1
1
  import { JSONSchema, ValidateFunction } from '../../../validation';
2
2
  export declare enum EmoteCategory {
3
- SIMPLE = "simple",
4
- LOOP = "loop"
3
+ SIMPLE = "simple"
5
4
  }
6
5
  export declare namespace EmoteCategory {
7
6
  const schema: JSONSchema<EmoteCategory>;
@@ -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;IACjB,IAAI,SAAS;CACd;AAED,yBAAiB,aAAa,CAAC;IACtB,MAAM,MAAM,EAAE,UAAU,CAAC,aAAa,CAG5C,CAAA;IAEM,MAAM,QAAQ,EAAE,gBAAgB,CAAC,aAAa,CAC1B,CAAA;CAC5B"}
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,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,8BAAa,CAAA;AACf,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;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
+ {"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,CAyB1C,CAAA;IAEM,MAAM,QAAQ,EAAE,gBAAgB,CAAC,WAAW,CACxB,CAAA;CAC5B"}
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"}
@@ -15,8 +15,7 @@ var MerkleProof;
15
15
  type: 'array',
16
16
  items: {
17
17
  type: 'string'
18
- },
19
- minItems: 1
18
+ }
20
19
  },
21
20
  index: {
22
21
  type: 'number'
@@ -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,CA8B3B;AA9BD,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;gBACD,QAAQ,EAAE,CAAC;aACZ;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,EA9BgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QA8B3B"}
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.3",
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": "aecec8ee67ac77663d3b9a993ba701fbe23a9c04"
35
+ "commit": "df0b2795925bfd462fb4fbe0688e96db2275c7ef"
36
36
  }