Skip to content

Commit

Permalink
fix(jobs): sync_type validation (#3325)
Browse files Browse the repository at this point in the history
## Changes

- Fix sync_type validation for very old scripts
  • Loading branch information
bodinsamuel authored Jan 17, 2025
1 parent f238cf9 commit 42d695d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
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
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 42d695d

Please sign in to comment.