8bitdesigner / tp-api Goto Github PK
View Code? Open in Web Editor NEWA NodeJS API to access entities from TargetProcess
A NodeJS API to access entities from TargetProcess
It might be beneficial to make a breaking change to convert then
's interface over to just emit the found entities, and have a separate catch
callback, so that requests adhere to Promise
's interface. This would allow easy interop with async
/await
First, thank you for tp-api
. The code still works, I'd just like to suggest adding one note to readme.
Using a very similar example to the one from readme:
tp('Tasks')
.take(1)
.where("EntityState.Name eq 'Open'")
.pluck("CustomFields")
.sortBy('NumericPriority')
.then(function(err, tasks) {
console.log('my tasks', tasks)
}
)
The returned tasks
here is a JavaScript object which can return:
my tasks [ { ResourceType: 'Task',
Id: 3631,
Project: { ResourceType: 'Project', Id: 4026, Process: [Object] },
CustomFields: [ [Object], [Object], [Object], [Object], [Object] ] } ]
In order to convert it into JSON string, the following is enough:
tp('Tasks')
.take(1)
.where("EntityState.Name eq 'Open'")
.pluck("CustomFields")
.sortBy('NumericPriority')
.then(function(err, tasks) {
console.log('my tasks', JSON.stringify(tasks)) // changed here
}
)
and now it returns:
my tasks [{"ResourceType":"Task","Id":3631,"Project":{"ResourceType":"Project","Id":4026,"Process":{"Id":5,"Name":"AIScrum"}},"CustomFields":[{"Name":"Component","Type":"DropDown","Value":null},{"Name":"trac","Type":"Number","Value":null},{"Name":"Job","Type":"DropDown","Value":null},{"Name":"Resolution","Type":"DropDown","Value":null},{"Name":"Domain","Type":"DropDown","Value":null}]}]
It took me some time to find out about it, so I'd like to spare this time for others.
Awesome API, I had to make an alteration though to use http. I may not be doing it right but I at least got it working after playing with your code. Maybe you wanna add the option to index.js
?
var protocol = opts.insecure ? 'http://' : 'https://'
var url = protocol+.....
@8bitDesigner , could you release current master as 1.0.6 so that npm install tp-api
installs 1.0.6?
Update: or maybe I can release it?
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.