maasglobal / maas-schemas-ts Goto Github PK
View Code? Open in Web Editor NEWTypeScript types and io-ts validators for maas-schemas
TypeScript types and io-ts validators for maas-schemas
Missing tokenId currently produces the following error.
File _customer-profile.json contains an invalid customerProfile example: Invalid value "TOKEN" supplied to : Default/balances: ((Partial<{ WMP: (Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) }> & { [K in string]: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })) }) & { WMP: (UnknownRecord | UnknownArray | string | boolean | number | null) })/0: (Partial<{ WMP: (Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) }> & { [K in string]: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })) })/1: { [K in string]: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })) }/cx-test-token_v2: ((Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }) | (Partial<{ currency: "TOKEN", tokenId: TokenId, amount: (number | null) }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), tokenId: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) }))/0: (Partial<{ currency: "WMP", amount: number }> & { currency: (UnknownRecord | UnknownArray | string | boolean | number | null), amount: (UnknownRecord | UnknownArray | string | boolean | number | null) })/0: Partial<{ currency: "WMP", amount: number }>/currency: "WMP"
At least it would be nice if we could translate (UnknownRecord | UnknownArray | string | boolean | number | null)
to Defined
as that is what it essentially means. In their current form the error messages are too verbose and hide the real error.
At the moment we create/edit the code in this repository manually. However, this entire process could be automated. Based on quick research it seems we have three options.
The main problem with updating this repository by hand is that it is incomplete, out of date and may not match the original schemas because of errors in the manual update process.
SchemaScript provide an automated way of transforming JSON Schema files into io-ts source code. However, the reference solver in SchemaScript is unable to resolve the references used in maas-schemas. It also requires adding arguments to comment fields of the original JSON Schema files which is a bit impractical. SchemaScript is open to contributions if we wish to adapt it to our needs. However, it is unclear how much work would be required to get it working since its implementation is limited and does not adhere to a JSON Schema test suite.
SchemaScript uses io-ts-codegen for io-ts source code generation. As another alternative, we could perhaps create our own JSON schema conversion tool. The code example provided in io-ts-codegen documentation shows how to transform a simplified version of JSON Schema into io-ts source code. The code example is even more limited than SchemaScript but might be a better starting point if SchemaScript is deemed unsuitable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.