Skip to content

Commit

Permalink
fix: tests and query
Browse files Browse the repository at this point in the history
  • Loading branch information
TBonnin committed Nov 27, 2024
1 parent 4a297bf commit 3d86040
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ describe(`POST ${endpoint}`, () => {
isSuccess(res.json);

expect(res.json).toStrictEqual<typeof res.json>([
{ models: ['Output'], name: 'test', providerConfigKey: 'unauthenticated', type: 'sync', version: '1' }
{ models: ['Output'], name: 'test', providerConfigKey: 'unauthenticated', type: 'sync', version: '1' },
{ models: [], name: 'test', providerConfigKey: 'unauthenticated', type: 'on-event', version: '0.0.1' }
]);
expect(res.res.status).toBe(200);

Expand All @@ -151,6 +152,7 @@ describe(`POST ${endpoint}`, () => {
expect(syncConfigs).toStrictEqual([
{
actions: [],
'on-events': [],
provider: 'unauthenticated',
providerConfigKey: 'unauthenticated',
syncs: [
Expand Down
14 changes: 8 additions & 6 deletions packages/shared/lib/services/on-event-scripts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,14 @@ export const onEventScriptService = {
}
if (onEventInserts.length > 0) {
type R = Awaited<ReturnType<typeof onEventScriptService.update>>;
return await trx
.insert<OnEventScript[]>(onEventInserts)
.into(TABLE)
.returning('*')
.join('_nango_configs', `${TABLE}.config_id`, '_nango_configs.id')
.select<R>([`${TABLE}.*`, '_nango_configs.provider_config_key as providerConfigKey']);
const res = await trx
.with('inserted', (qb) => {
qb.insert(onEventInserts).into(TABLE).returning('*');
})
.select<R>(['inserted.*', '_nango_configs.unique_key as providerConfigKey'])
.from('inserted')
.join('_nango_configs', 'inserted.config_id', '_nango_configs.id');
return res;
}
return [];
});
Expand Down

0 comments on commit 3d86040

Please sign in to comment.