RaynorUE / snich

Application for code work on a ServiceNow Instance
22 stars 4 forks source link

Add the ts definitions from u-now #93

Closed jacebenson closed 5 years ago

jacebenson commented 5 years ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like I'm not sure you have all the classes but some great people did some work to make the classes typescript which i believe you need to the intellisense stuff. I'd suggest bringing them in.

Describe alternatives you've considered Instead of putting all definitions in one file, move to separate files for easier pull requests.

Additional context https://github.com/u-now/types-x/tree/master/london has the type files

RaynorUE commented 5 years ago

Jace,

This feature already exists in SNICH. It includes Client Side APIs, Scoped Server APIs, and Legacy Server APIs. Is there something in the u-now ones that are different?

You can see these in action on the Extension page in the marketplace: https://marketplace.visualstudio.com/items?itemName=integrateNate.snich

Let me know if you want more info on how / what i'm doing there in SNICH to make it all work.

RaynorUE commented 5 years ago

To validate if your SNICH is setting itself up properly, you should see an @Types folder and a jsconfig.json file in your "Workspace" folder in vscode...

image

The jsconfig.json (even though its empty) tells VSCode, to look for an @types folder in the same folder as the jsconfig.json and load all the .d.ts files and make their definitions available in all of the ".js" files in all of the folders in the same location as the jsconfig.json.

jacebenson commented 5 years ago

Oh wow. Didn't know that.
I'd make a PR and do it but I don't understand how the client.d.ts and scoped.d.ts get generated.

jacebenson commented 5 years ago

They just seem easier to manage and better than what is today; Video here; Video

jacebenson commented 5 years ago

Oh, I see, https://github.com/RaynorUE/snich/blob/910c5c079c2690c1d4884b36f94bedb3b43b0dc0/src/classes/TSDefinitionGeneator.ts#L62 is where you do that. Yea, would you be opposed to breaking that out?

RaynorUE commented 5 years ago

I guess I don't see what the benefit of breaking out the files or what would need updated? I guess I never stated where I am getting that from...

I'm actually getting a raw JSON dump from the developer.servicenow.com team (The SN Team that runs that site) and parsing it into those files. So ideally we wouldn't need to edit anything since it is coming "from the source?"

So for me to update for a given version, (When new york comes out) I'll bug the developer.servicenow.com team, and they email me a json file that i'll plop in snich, and it will automatically create a "new york" folder and the appropriate .d.ts files in there based on the docs site. Then as a "developer" you'll just need to manage which ones you want by adding/removing the ".inactive" to the file name...

I do plan on adding a "Switcher" code in there, so you can do it through the command pallete and it'll handle everything for you...

RaynorUE commented 5 years ago

Oh I see... I didn't catch it at the end of your video (I didn't watch the whole way through to be honest). So it looks like he has examples in there?

There should be example scripts where SN provided examples for their methods / libraries... But SN's examples on the developer site do leave a lot to be desired...

RaynorUE commented 5 years ago

Oh... and it doesn't look like my code is generating the examples, FML... Totally thought I had those in there...

RaynorUE commented 5 years ago

So i'll get the examples in their from the Developer site, so that they're showing properly.

I'll also use this as an issue to track down a way to "include overriden type definitions" in case folks might want to customize.

I think if i make any small adjustment right now, is every time you load vscode i'm "Regenerating the typescript files" so even if you made changes, i'd just smash over them anyway.. I did this in case someone edits the file and screws it up in a way that breaks the intellisense and doesn't know why...

I think i might add a setting to disable the "Always overwrite @types definition files on load" so that if someone wants to load/edit to make their own versions they can..

RaynorUE commented 5 years ago

And to continue the message spam..

My only hesitation in breaking out the definition files, is that "Scoped" has 101 classes declared on it's own. So we would end up potentially with "noise in the other direction"...... I might give it a try and see what i think about it once i'm digging into it...

jacebenson commented 5 years ago

I didnt realize SN was publishing that. That is amazing. Yea, if your source is the source than great.

RaynorUE commented 5 years ago

Eehhh, I wouldn't say they're "Publishing it" so much as I know a guy... Hopefully they'll publish an API for it someday... would be awesome. Still have no idea why they don't other than needing to build it... seeing as everything is "public knowledge" today..

jacebenson commented 5 years ago

WEll then. That's all I got. Imma close this and hopefully SN opens that up. I won't hold my breath.