Skip to content

Commit

Permalink
Merge branch 'master' into francismaina/ext-362-slack-document-access…
Browse files Browse the repository at this point in the history
…-requirements-and-setup-guide
  • Loading branch information
Maina-Francis authored Jan 17, 2025
2 parents aedecdb + 2f43687 commit d17e7a4
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 49 deletions.
Binary file modified docs-v2/integrations/all/emarsys-oauth/form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/jobs/lib/routes/tasks/putTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const nangoPropsSchema = z
pre_built: z.boolean(),
is_public: z.boolean(),
input: z.string().nullable(),
sync_type: z.enum(['full', 'incremental']).nullable(),
sync_type: z.enum(['full', 'incremental', 'FULL', 'INCREMENTAL']).nullable(),
metadata: z.record(z.string(), z.any())
})
.passthrough(),
Expand Down
6 changes: 3 additions & 3 deletions packages/jobs/lib/runner/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { envs } from '../env.js';
import { getPersistAPIUrl, getProvidersUrl, getRedisUrl } from '@nangohq/shared';
import type { AxiosResponse } from 'axios';
import { isAxiosError } from 'axios';
import type { RateLimiterAbstract } from 'rate-limiter-flexible';
import type { IRateLimiterRedisOptions, RateLimiterAbstract } from 'rate-limiter-flexible';
import { RateLimiterRedis, RateLimiterMemory } from 'rate-limiter-flexible';
import { createClient } from 'redis';

Expand Down Expand Up @@ -172,13 +172,13 @@ class CombinedThrottler {
}

const serviceCreationThrottler = await (async () => {
const minuteThrottlerOpts = {
const minuteThrottlerOpts: Omit<IRateLimiterRedisOptions, 'storeClient'> = {
keyPrefix: 'minute',
points: envs.RENDER_SERVICE_CREATION_MAX_PER_MINUTE || 50,
duration: 60,
blockDuration: 0
};
const hourThrottlerOpts = {
const hourThrottlerOpts: Omit<IRateLimiterRedisOptions, 'storeClient'> = {
keyPrefix: 'hour',
points: envs.RENDER_SERVICE_CREATION_MAX_PER_HOUR || 700,
duration: 3600,
Expand Down
12 changes: 9 additions & 3 deletions packages/runner/lib/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ export class RunnerMonitor {
}
}

private checkIdle(): NodeJS.Timeout | null {
private checkIdle(timeoutMs: number = 10000): NodeJS.Timeout | null {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
return setInterval(async () => {
return setTimeout(async () => {
let nextTimeout = timeoutMs;
if (this.idleMaxDurationMs > 0 && this.tracked.size == 0) {
const idleTimeMs = Date.now() - this.lastIdleTrackingDate;
if (idleTimeMs > this.idleMaxDurationMs) {
Expand All @@ -105,7 +106,11 @@ export class RunnerMonitor {
const res = await idle();
if (res.isErr()) {
logger.error(`Failed to idle runner`, res.error);
nextTimeout = timeoutMs; // Reset to default on error
}
// Increase the timeout to 2 minutes after a successful idle
// to give enough time to fleet to terminate the runner
nextTimeout = 120_000;
} else {
// TODO: DEPRECATE legacy /idle endpoint
await httpFetch({
Expand All @@ -120,7 +125,8 @@ export class RunnerMonitor {
this.lastIdleTrackingDate = Date.now();
}
}
}, 10000);
this.checkIdle(nextTimeout);
}, timeoutMs);
}
}

Expand Down
66 changes: 27 additions & 39 deletions packages/shared/lib/services/proxy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,52 +76,39 @@ class ProxyService {
let token;
switch (connection.credentials.type) {
case 'OAUTH2':
{
const credentials = connection.credentials;
token = credentials.access_token;
}
case 'APP': {
const credentials = connection.credentials;
token = credentials.access_token;
break;
case 'OAUTH1': {
const error = new Error('OAuth1 is not supported yet in the proxy.');
const nangoError = new NangoError('pass_through_error', error);
return { success: false, error: nangoError, response: null, logs };
}
case 'BASIC':
token = connection.credentials;
break;
case 'API_KEY':
token = connection.credentials;
break;
case 'APP':
{
const credentials = connection.credentials;
token = credentials.access_token;
}
break;
case 'OAUTH2_CC':
{
const credentials = connection.credentials;
token = credentials.token;
}
break;
case 'TWO_STEP':
case 'TABLEAU':
{
const credentials = connection.credentials;
token = credentials.token;
}
break;
case 'JWT':
{
const credentials = connection.credentials;
token = credentials.token;
}
case 'SIGNATURE': {
const credentials = connection.credentials;
token = credentials.token;
break;
case 'SIGNATURE':
{
const credentials = connection.credentials;
token = credentials.token;
}
}
case 'BASIC':
case 'API_KEY':
token = connection.credentials;
break;
case 'OAUTH1': {
const error = new Error('OAuth1 is not supported yet in the proxy.');
const nangoError = new NangoError('pass_through_error', error);
return { success: false, error: nangoError, response: null, logs };
}
case 'APP_STORE':
case 'CUSTOM':
case 'TBA':
case undefined:
case 'BILL': {
break;
}
default: {
throw new Error(`Unhandled connection.credentials for: ${(connection.credentials as any).type}`);
}
}

const provider = getProvider(providerName);
Expand Down Expand Up @@ -470,6 +457,7 @@ class ProxyService {
case 'API_KEY':
case 'OAUTH2_CC':
case 'TABLEAU':
case 'TWO_STEP':
case 'JWT':
if (value.includes('connectionConfig')) {
value = value.replace(/connectionConfig\./g, '');
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2325,7 +2325,7 @@ emarsys:
pattern: '^[a-zA-Z0-9-]+$'

emarsys-oauth:
display_name: Emarsys (Ouath)
display_name: Emarsys (OAuth)
categories:
- marketing
auth_mode: OAUTH2_CC
Expand Down
2 changes: 1 addition & 1 deletion packages/types/lib/nangoYaml/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { OnEventType } from '../scripts/on-events/api';

export type HTTP_METHOD = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
export type SyncTypeLiteral = 'incremental' | 'full';
export type SyncTypeLiteral = 'incremental' | 'full' | 'FULL' | 'INCREMENTAL'; // TODO: There has been some mixed type in the DB, fix casing
export type ScriptFileType = 'actions' | 'syncs' | 'on-events' | 'post-connection-scripts'; // post-connection-scripts is deprecated
export type ScriptTypeLiteral = 'action' | 'sync' | 'on-event';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const SyncRow: React.FC<{ sync: SyncResponse; connection: ApiConnectionFu

const [showPauseStartLoader, setShowPauseStartLoader] = useState(false);
const [showInterruptLoader, setShowInterruptLoader] = useState(false);
const [triggerMode, setTriggerMode] = useState<'incremental' | 'full'>(sync.sync_type === 'full' ? 'full' : 'incremental');
const [triggerMode, setTriggerMode] = useState<'incremental' | 'full'>(sync.sync_type.toLocaleLowerCase() === 'full' ? 'full' : 'incremental');
const [deleteRecords, setDeleteRecords] = useState(false);
const [modalSpinner, setModalShowSpinner] = useState(false);
const [openConfirm, setOpenConfirm] = useState(false);
Expand Down

0 comments on commit d17e7a4

Please sign in to comment.