Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Provide typescript definitions for data objects and functions #134

Open
ericblade opened this issue Dec 21, 2019 · 10 comments
Open

Provide typescript definitions for data objects and functions #134

ericblade opened this issue Dec 21, 2019 · 10 comments

Comments

@ericblade
Copy link
Owner

This could take quite a long time, but might really help the world. :-D

@ericblade
Copy link
Owner Author

.... and if we built some of our validation code in typescript instead of plain js, we might see some sizeable benefit as well

@pwrnrd
Copy link
Contributor

pwrnrd commented Dec 21, 2019

We could write definitions for every function exposed by MWS-Advanced and add it to DefinitelyTyped (https://github.com/DefinitelyTyped/DefinitelyTyped).

@ericblade
Copy link
Owner Author

ericblade commented Dec 21, 2019

i started in, but it's a daunting task lol :-D mostly it's translating the jsdoc documentation into typescript.. which is often a translation of the MWS documentation. also, the library takes a lot of liberties with / advantage of how loosely typed javascript is...

@ericblade
Copy link
Owner Author

… seems we might be able to auto-generate a bunch of this with tsc command line options. good to know, some things were added in typescript 3.7 to allow for it outputting .d.ts from jsdoc

@ericblade
Copy link
Owner Author

I've added auto-built typescript defs files. It's clearly not where it needs to be to be really useful, but at least it's a start. :)

@ericblade
Copy link
Owner Author

I've just done a really quick conversion for mws-simple to become typescript, and i'll probably use that as a blueprint to allow for the integration of typescript code into this repo

@ericblade
Copy link
Owner Author

... i have an inkling that i might find a way to convert the XSD files from Amazon into typescript types and ship them with mws-simple...

@ericblade
Copy link
Owner Author

There is a utility called 'cxsd' that will convert an entire tree of XSD files. Unfortunately, there doesn't seem to be a complete catalog of all the XSD files that define the MWS system. There is a github repo, but it's not official, not complete, and was last updated 4 years ago.

I'm able to get the process started by using that repo, serving it locally, editing in a targetNamespace="urn:mws" attribute on the amzn-envelope file .. and then it starts complaining about a lot of other files that are missing. I'm not sure if those are actually available on Amazon's servers, or not..

@ericblade
Copy link
Owner Author

woot.

found all the files (they were right there in the same directory, just had to dig out all their filenames, and serve them to myself)

I've committed all the XSDs as well as the typescript output of cxsd, to https://github.com/ericblade/mws-simple/tree/xsd

next i'm going to see if I can actually make use of this information in some way.

@ericblade
Copy link
Owner Author

.. not sure how useful it is. The XSD files that i was able to get from the amazon envelope file, and all the ones that it links to, provides a schema for data, but doesn't really provide a schema for API calls and responses.
I could've swore there were XSD files that also described all the API usage outputs and inputs .. i may be wrong, though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants