teamleadercrm / sdk-js Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Currently there are no typings available for @teamleader/api
.
I'm trying to use this package on Node server. After doing npm i @teamleader/api
and creating a file with the simplest piece of code:
import API from '@teamleader/api';
When trying to run it I'm getting the following error:
<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17
regeneratorRuntime.mark(function _callee(response) {
^
ReferenceError: regeneratorRuntime is not defined
at <project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17:3
at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:46:2)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\checkStatus.js:8:47)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
Any info on how to solve this?
How do we handle loading all results of a specific API request via sdk-js?
In some specific cases, we want to be able to fetch all the results without handling the pagination logic yourself or via the UI.
For example, the case of the month view in the calendar. We would need to see all the events there, paginating them wouldn't work in this case.
Currently, we can receive a maximum of 100 items in 1 request.
We don't have any pagination info in the response, so we would need to fetch the next page sequentially until there the amount of data is smaller than the maximum (could be a lot better).
It doesn't make sense to solve this with a plugin since plugins have a data => data
signature.
I would propose to move plugins into a general options object and allow for the option to add a fetchAll
(feel free to suggest another name).
@nickwaelkens I don't think we can tackle this param in any other way (see discussion in the previous RFC)
Meaning we would need to move the plugins into this object as well.
example:
events.list({ filter: '...' }, { plugins: { response: normalize }, fetchAll: true });
Passing this option would indicate that sdk-js needs to make multiple requests if required & respect the provided plugins.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
.github/workflows/check-types.yaml
actions/checkout v3
actions/setup-node v3
actions/cache v3
.github/workflows/create-tag.yaml
peter-murray/workflow-application-token-action v2
actions/checkout v4
rickstaa/action-contains-tag v1
softprops/action-gh-release v1
mikepenz/release-changelog-builder-action v4.1.0
softprops/action-gh-release v1
.github/workflows/lint.yaml
actions/checkout v3
actions/setup-node v3
actions/cache v3
.github/workflows/test.yaml
actions/checkout v3
actions/setup-node v3
actions/cache v3
Hi,
maybe a newbe question, but how do I autorize my app with teamleader using OAuth2?
Bouke
How do we include side loading in sdk-js?
This proposal will introduce breaking changes.
Using the example of https://teamleader-engineering.blogin.co/single-post.php?id=54221
Using the projects.list
endpoint, triggering a customer
side-load.
endpoint:
https://api.teamleader.eu/projects.list?include=customer
result:
{
"data": [
{
"id": "8ef941ad-214f-0721-b818-f678e53a1714",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "b5d55370-f649-0bfb-9010-03132f9eaae8"
}
},
{
"id": "58bcd4da-f68e-053e-9b1c-3cb6c5796867",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "0709fc3e-e918-00d5-a113-ba00a33102ca"
},
},
{
"id": "795be9dd-ee91-070e-b212-5bf5cb1f57d3",
"title": "azerty",
"status": "active",
"starts_on": "2018-09-13",
"customer": {
"type": "contact",
"id": "29c7a647-bbaf-0807-9722-233e34891f11"
},
}
],
"includes": {
"company": [
{
"id": "0709fc3e-e918-00d5-a113-ba00a33102ca",
"name": "Peterson Paper",
},
{
"id": "b5d55370-f649-0bfb-9010-03132f9eaae8",
"name": "Summers Digital Ltd",
}
],
"contact": [
{
"id": "29c7a647-bbaf-0807-9722-233e34891f11",
"first_name": "Barry",
"last_name": "Green",
},
]
}
}
edited after reading #31 (comment)
We would pass include as the first parameter in the actual function call
projects.list({ include: 'customer' }, { response: normalize });
with extra param
projects.list({ filter: { status: 'active' }, include: 'customer' }, { response: normalize });
include
can be a string (1 include) or an array of strings (multiple includes).
We can handle the way the result is parsed with plugins
I think we should allow for 2 options
normalize
plugin)Normalize all data under within the specific domain (key / value).
We would need to change the normalize plugin a bit to achieve this output.
{
"projects": {
"8ef941ad-214f-0721-b818-f678e53a1714": {
"id": "8ef941ad-214f-0721-b818-f678e53a1714",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "b5d55370-f649-0bfb-9010-03132f9eaae8"
}
},
"58bcd4da-f68e-053e-9b1c-3cb6c5796867": {
"id": "58bcd4da-f68e-053e-9b1c-3cb6c5796867",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "0709fc3e-e918-00d5-a113-ba00a33102ca"
},
},
"795be9dd-ee91-070e-b212-5bf5cb1f57d3": {
"id": "795be9dd-ee91-070e-b212-5bf5cb1f57d3",
"title": "azerty",
"status": "active",
"starts_on": "2018-09-13",
"customer": {
"type": "contact",
"id": "29c7a647-bbaf-0807-9722-233e34891f11"
},
}
},
"companies": {
"0709fc3e-e918-00d5-a113-ba00a33102ca": {
"id": "0709fc3e-e918-00d5-a113-ba00a33102ca",
"name": "Peterson Paper",
},
"b5d55370-f649-0bfb-9010-03132f9eaae8": {
"id": "b5d55370-f649-0bfb-9010-03132f9eaae8",
"name": "Summers Digital Ltd",
}
},
"contacts": {
"29c7a647-bbaf-0807-9722-233e34891f11": {
"id": "29c7a647-bbaf-0807-9722-233e34891f11",
"first_name": "Barry",
"last_name": "Green",
}
}
}
Issue here, the endpoint returns company
/ contact
instead of companies
/ contacts
in the includes
key. I could easily extract projects from the domain name.
This would allow destructuring the received data from the response
const { projects, contacts, companies } = await projects.list(undefined, { include: 'customer', plugins: { response: normalize } });
// everything byId.
Changing the plugin would also mean you'd need to change the destructuring if you don't use any side loading.
const { projects } = await projects.list();
merge
plugin)The merge
plugin would create this output:
{
"data": [
{
"id": "8ef941ad-214f-0721-b818-f678e53a1714",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "b5d55370-f649-0bfb-9010-03132f9eaae8",
"name": "Summers Digital Ltd"
}
},
{
"id": "58bcd4da-f68e-053e-9b1c-3cb6c5796867",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "0709fc3e-e918-00d5-a113-ba00a33102ca",
"name": "Peterson Paper"
}
},
{
"id": "795be9dd-ee91-070e-b212-5bf5cb1f57d3",
"title": "azerty",
"status": "active",
"starts_on": "2018-09-13",
"customer": {
"type": "contact",
"id": "29c7a647-bbaf-0807-9722-233e34891f11",
"first_name": "Barry",
"last_name": "Green"
}
}
]
}
I would keep the types in there for rendering purposes on the FE.
merge
& normalize
plugin?{
"data": {
"8ef941ad-214f-0721-b818-f678e53a1714": {
"id": "8ef941ad-214f-0721-b818-f678e53a1714",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "b5d55370-f649-0bfb-9010-03132f9eaae8",
"name": "Summers Digital Ltd"
}
},
"58bcd4da-f68e-053e-9b1c-3cb6c5796867": {
"id": "58bcd4da-f68e-053e-9b1c-3cb6c5796867",
"title": "New company website",
"status": "active",
"starts_on": "2016-02-04",
"customer": {
"type": "company",
"id": "0709fc3e-e918-00d5-a113-ba00a33102ca",
"name": "Peterson Paper"
},
},
"795be9dd-ee91-070e-b212-5bf5cb1f57d3": {
"id": "795be9dd-ee91-070e-b212-5bf5cb1f57d3",
"title": "azerty",
"status": "active",
"starts_on": "2018-09-13",
"customer": {
"type": "contact",
"id": "29c7a647-bbaf-0807-9722-233e34891f11",
"first_name": "Barry",
"last_name": "Green"
},
}
}
}
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.