Skip to content
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

fix(syncConfigs): handle new model_schema + display in the UI #2404

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/server/lib/controllers/config.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { isHosted } from '@nangohq/utils';
import type { Template as ProviderTemplate, AuthModeType } from '@nangohq/types';
import {
flowService,
getConfigWithEndpointsByProviderConfigKey,
errorManager,
NangoError,
analytics,
Expand All @@ -22,7 +21,8 @@ import {
getUniqueSyncsByProviderConfig,
getActionsByProviderConfigKey,
getFlowConfigsByParams,
getGlobalWebhookReceiveUrl
getGlobalWebhookReceiveUrl,
getSyncConfigsAsStandardConfig
} from '@nangohq/shared';
import { getOrchestrator, parseConnectionConfigParamsFromTemplate } from '../utils/utils.js';
import type { RequestLocals } from '../utils/express.js';
Expand Down Expand Up @@ -386,7 +386,7 @@ class ConfigController {
if (includeFlows && !isHosted) {
const availablePublicFlows = flowService.getAllAvailableFlowsAsStandardConfig();
const [publicFlows] = availablePublicFlows.filter((flow) => flow.providerConfigKey === config.provider);
const allFlows = await getConfigWithEndpointsByProviderConfigKey(environmentId, providerConfigKey);
const allFlows = await getSyncConfigsAsStandardConfig(environmentId, providerConfigKey);

if (availablePublicFlows.length && publicFlows && allFlows) {
const { disabledFlows, flows } = getEnabledAndDisabledFlows(publicFlows, allFlows);
Expand Down
9 changes: 4 additions & 5 deletions packages/server/lib/controllers/flow.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ import {
deployPreBuilt as deployPreBuiltSyncConfig,
syncManager,
remoteFileService,
getAllSyncsAndActions,
getNangoConfigIdAndLocationFromId,
getConfigWithEndpointsByProviderConfigKeyAndName,
getSyncsByConnectionIdsAndEnvironmentIdAndSyncName,
enableScriptConfig as enableConfig,
disableScriptConfig as disableConfig,
environmentService
environmentService,
getSyncConfigsAsStandardConfig
} from '@nangohq/shared';
import { logContextGetter } from '@nangohq/logs';
import type { RequestLocals } from '../utils/express.js';
Expand Down Expand Up @@ -179,7 +178,7 @@ class FlowController {
try {
const environmentId = res.locals['environment'].id;

const nangoConfigs = await getAllSyncsAndActions(environmentId);
const nangoConfigs = await getSyncConfigsAsStandardConfig(environmentId);

res.send(nangoConfigs);
} catch (e) {
Expand Down Expand Up @@ -277,7 +276,7 @@ class FlowController {

const flow = flowService.getSingleFlowAsStandardConfig(flowName);
const provider = await configService.getProviderName(providerConfigKey);
const flowConfig = await getConfigWithEndpointsByProviderConfigKeyAndName(environment.id, providerConfigKey, flowName);
const flowConfig = await getSyncConfigsAsStandardConfig(environment.id, providerConfigKey, flowName);

res.send({ flowConfig, unEnabledFlow: flow, provider });
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/lib/models/NangoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface NangoIntegrationDataV1 {
type?: ScriptTypeLiteral;
runs: string;
returns: string[];
input?: string;
input?: string | undefined;
track_deletes?: boolean;
auto_start?: boolean;
attributes?: object;
Expand Down Expand Up @@ -127,7 +127,7 @@ export interface NangoSyncConfig {
id?: number;

// v2 additions
input?: NangoSyncModel;
input?: NangoSyncModel | undefined;
sync_type?: SyncType;
nango_yaml_version?: string;
webhookSubscriptions?: string[];
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/lib/models/Sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { JSONSchema7 } from 'json-schema';
import type { HTTP_VERB, Timestamps, TimestampsAndDeleted } from './Generic.js';
import type { NangoProps } from '../sdk/sync.js';
import type { NangoIntegrationData } from './NangoConfig.js';
import type { NangoConfigMetadata, NangoSyncEndpoint, ScriptTypeLiteral } from '@nangohq/types';
import type { NangoConfigMetadata, NangoModel, NangoSyncEndpoint, ScriptTypeLiteral } from '@nangohq/types';
import type { LogContext } from '@nangohq/logs';

export enum SyncStatus {
Expand Down Expand Up @@ -89,7 +89,7 @@ export interface SyncConfig extends TimestampsAndDeleted {
file_location: string;
nango_config_id: number;
models: string[];
model_schema: SyncModelSchema[];
model_schema: SyncModelSchema[] | NangoModel[];
active: boolean;
runs: string;
track_deletes: boolean;
Expand All @@ -100,7 +100,7 @@ export interface SyncConfig extends TimestampsAndDeleted {
pre_built?: boolean | null;
is_public?: boolean | null;
endpoints?: NangoSyncEndpoint[];
input?: string | SyncModelSchema | undefined;
input?: string | undefined;
sync_type?: SyncType | undefined;
webhook_subscriptions: string[] | null;
enabled: boolean;
Expand Down
Loading
Loading