-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(integration-templates): [nan-1192] add checkr syncs and actions #2378
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know enough about the provider to judge the business logic but code looks ok. Don't we want to systematically validate actions input with zod?
} | ||
|
||
return { services }; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it would be more readable if broken up into smaller functions:
export default async function runAction(nango: NangoAction): Promise<CheckrServicesResponse> {
const { config, connection_config } = await constructRequestWithConnectionConfig(nango, '/v1/packages');
const accountHierarchyEnabled = connection_config['accountHierarchyEnabled'] || false;
let services: CheckrService[] = fetch({nango, config, endpoint: '/v1/packages'});
if (accountHierarchyEnabled) {
const nodes = await fetch({nango, config, endpoint: '/v1/nodes?include=packages'});
services = process(nodes, services);
}
return { services };
}
async function fetch({nango, config, endpoint} : {nango: NangoAction, config: ProxyConfiguration, endpoint: string}) {
const res = [];
for await (const checkrServices of nango.paginate({ ...config, endpoint })) {
res.push(...checkrServices);
}
return res;
}
function process(nodes: any[], services: CheckrService[]): CheckrService[] {
return nodes.flatMap(node => {
if(node.packages.length === 0) {
return [];
} else {
return node.packages.map((pkg: string) => ({
...services.find(service => service.slug === pkg),
node: node.custom_id
}))
}
});
}
Haven't tested so details might be wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, kept as is h/e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good minor comments
* This means we first fetch all the available packages. If accountHierarchyEnabled is true | ||
* and there are nodes with packages we need to grab them from the packages to | ||
* attach them to the node | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo comments are easier to understand at the exact position, I need to do a lot of back and forth to understand why it's done this way
throw new nango.ActionError({ | ||
message: `access_token is missing` | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason a connection would not have an acces_token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More of a check to make TS happy
@@ -0,0 +1,13 @@ | |||
import type { CheckrTriggeredBackgroundCheck, BackgroundCheck } from '../../models'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
english: not sure about the term mappers but it's not my main language, I would call them formatters maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, IMO mappers
is clear
Describe your changes
Add checkr syncs and actions:
GET /background-check/service-list
: returns a possible list of services that Checkr can perform for a background check. Takes into account if the connection has account hierarchy enabled or not and returns the node the background check is associated with if soGET /background-check/service-parameters
: obtains the parameters needed to trigger a background check for a particular background checkPOST /background-check/trigger
: trigger a background check for a candidatePOST /candidates
: create a candidate to be able to trigger background checks forAdds a single sync:
GET /background-checks
: retrieves all background checks for all candidatesIssue ticket number and link
NAN-1192
Checklist before requesting a review (skip if just adding/editing APIs & templates)