ScaleLeap / amazon-mws-api-sdk

A fully typed TypeScript and Node.js Amazon MWS API Unofficial SDK
https://npm.im/@scaleleap/amazon-mws-api-sdk
MIT License
20 stars 12 forks source link

Expose all parameter types #96

Closed moltar closed 4 years ago

moltar commented 4 years ago

I think it'd be useful to expose the method parameter types, so that parameters can be build outside of the method call and be typed.

E.g. I am creating a subscription and then subscribing to it. There are the same parameters, but they need to be repeated:

https://github.com/ScaleLeap/amazon-mws-api-sdk/blob/a1e5c8b1f33a7ed7a159a0dcdb1a92b4ecf3720e/test/integration/subscriptions.test.ts#L26

If you try to abstract that into an object, you'll get type errors stating that:

Type 'string' is not assignable to type '"SQS"'.


Screenshot:

image
Type '{ AttributeList: { Key: string; Value: string; }[]; DeliveryChannel: string; }' is not assignable to type 'Destination'.
  Types of property 'DeliveryChannel' are incompatible.
    Type 'string' is not assignable to type '"SQS"'.ts(2322)

But also, regardless of errors, I think it'd be useful to do something like:

const dest: Destination = {
 // and this be type checked / intellisensed
}
justinemmanuelmercado commented 4 years ago

@moltar

They're exported here.

https://github.com/ScaleLeap/amazon-mws-api-sdk/blob/a1e5c8b1f33a7ed7a159a0dcdb1a92b4ecf3720e/src/sections/subscriptions.ts#L13-L20

But you may be referring to exposing them another way. Let me know if you think there's a better way to expose them to be usable for the users

moltar commented 4 years ago

Ah, yeah, missed that part. Certainly useful.

But I was thinking more like the whole parameter interface and all of the underlying parts need to be exposed.

Like in my example, if I just want to have a destination hard coded somewhere once, and it be type checked, it is not currently possible.

justinemmanuelmercado commented 4 years ago

Ahh so you mean exposing something like export interface Destination {...}?

justinemmanuelmercado commented 4 years ago

I can push something like that, have you review it and if approved ~I'll create the issue to apply it to other sections where it could be useful~

Nevermind, just realized this was the issue for it

moltar commented 4 years ago

Ahh so you mean exposing something like export interface Destination {...}?

Ya for all method parameter interfaces, even the inner ones, where makes sense.