refactor: Use internal namespace for the existing API
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const createConnection = (connection) => {
|
||||
const connectionData = {
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: connection.formattedData,
|
||||
verified: connection.verified || false,
|
||||
createdAt: connection.createdAt.getTime(),
|
||||
updatedAt: connection.updatedAt.getTime(),
|
||||
};
|
||||
|
||||
return {
|
||||
data: connectionData,
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'Connection',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default createConnection;
|
||||
@@ -0,0 +1,14 @@
|
||||
const getActionSubstepsMock = (substeps) => {
|
||||
return {
|
||||
data: substeps,
|
||||
meta: {
|
||||
count: substeps.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getActionSubstepsMock;
|
||||
@@ -0,0 +1,22 @@
|
||||
const getActionsMock = (actions) => {
|
||||
const actionsData = actions.map((trigger) => {
|
||||
return {
|
||||
name: trigger.name,
|
||||
key: trigger.key,
|
||||
description: trigger.description,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
data: actionsData,
|
||||
meta: {
|
||||
count: actions.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getActionsMock;
|
||||
@@ -0,0 +1,22 @@
|
||||
const getAppMock = (app) => {
|
||||
return {
|
||||
data: {
|
||||
authDocUrl: app.authDocUrl,
|
||||
iconUrl: app.iconUrl,
|
||||
key: app.key,
|
||||
name: app.name,
|
||||
primaryColor: app.primaryColor,
|
||||
supportsConnections: app.supportsConnections,
|
||||
supportsOauthClients: app.auth.generateAuthUrl ? true : false,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppMock;
|
||||
@@ -0,0 +1,24 @@
|
||||
const getAppsMock = (apps) => {
|
||||
const appsData = apps.map((app) => ({
|
||||
authDocUrl: app.authDocUrl,
|
||||
iconUrl: app.iconUrl,
|
||||
key: app.key,
|
||||
name: app.name,
|
||||
primaryColor: app.primaryColor,
|
||||
supportsConnections: app.supportsConnections,
|
||||
supportsOauthClients: app?.auth?.generateAuthUrl ? true : false,
|
||||
}));
|
||||
|
||||
return {
|
||||
data: appsData,
|
||||
meta: {
|
||||
count: appsData.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppsMock;
|
||||
@@ -0,0 +1,20 @@
|
||||
const getAuthMock = (auth) => {
|
||||
return {
|
||||
data: {
|
||||
fields: auth.fields,
|
||||
authenticationSteps: auth.authenticationSteps,
|
||||
reconnectionSteps: auth.reconnectionSteps,
|
||||
sharedReconnectionSteps: auth.sharedReconnectionSteps,
|
||||
sharedAuthenticationSteps: auth.sharedAuthenticationSteps,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAuthMock;
|
||||
@@ -0,0 +1,20 @@
|
||||
const getAppConfigMock = (appConfig) => {
|
||||
return {
|
||||
data: {
|
||||
key: appConfig.key,
|
||||
useOnlyPredefinedAuthClients: appConfig.useOnlyPredefinedAuthClients,
|
||||
disabled: appConfig.disabled,
|
||||
createdAt: appConfig.createdAt.getTime(),
|
||||
updatedAt: appConfig.updatedAt.getTime(),
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'AppConfig',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppConfigMock;
|
||||
@@ -0,0 +1,24 @@
|
||||
const getConnectionsMock = (connections) => {
|
||||
return {
|
||||
data: connections.map((connection) => ({
|
||||
id: connection.id,
|
||||
key: connection.key,
|
||||
verified: connection.verified,
|
||||
oauthClientId: connection.oauthClientId,
|
||||
formattedData: {
|
||||
screenName: connection.formattedData.screenName,
|
||||
},
|
||||
createdAt: connection.createdAt.getTime(),
|
||||
updatedAt: connection.updatedAt.getTime(),
|
||||
})),
|
||||
meta: {
|
||||
count: connections.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Connection',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getConnectionsMock;
|
||||
@@ -0,0 +1,40 @@
|
||||
const getFlowsMock = async (flows, steps, currentUserId) => {
|
||||
const data = flows.map((flow) => {
|
||||
const flowSteps = steps.filter((step) => step.flowId === flow.id);
|
||||
|
||||
return {
|
||||
active: flow.active,
|
||||
id: flow.id,
|
||||
name: flow.name,
|
||||
status: flow.active ? 'published' : 'draft',
|
||||
isOwner: flow.userId === currentUserId,
|
||||
createdAt: flow.createdAt.getTime(),
|
||||
updatedAt: flow.updatedAt.getTime(),
|
||||
steps: flowSteps.map((step) => ({
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
id: step.id,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
parameters: step.parameters,
|
||||
position: step.position,
|
||||
status: step.status,
|
||||
type: step.type,
|
||||
webhookUrl: step.webhookUrl,
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
data: data,
|
||||
meta: {
|
||||
count: data.length,
|
||||
currentPage: 1,
|
||||
isArray: true,
|
||||
totalPages: 1,
|
||||
type: 'Flow',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getFlowsMock;
|
||||
@@ -0,0 +1,18 @@
|
||||
const getOAuthClientMock = (oauthClient) => {
|
||||
return {
|
||||
data: {
|
||||
name: oauthClient.name,
|
||||
id: oauthClient.id,
|
||||
active: oauthClient.active,
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getOAuthClientMock;
|
||||
@@ -0,0 +1,18 @@
|
||||
const getOAuthClientsMock = (oauthClients) => {
|
||||
return {
|
||||
data: oauthClients.map((oauthClient) => ({
|
||||
name: oauthClient.name,
|
||||
id: oauthClient.id,
|
||||
active: oauthClient.active,
|
||||
})),
|
||||
meta: {
|
||||
count: oauthClients.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'OAuthClient',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getOAuthClientsMock;
|
||||
@@ -0,0 +1,14 @@
|
||||
const getTriggerSubstepsMock = (substeps) => {
|
||||
return {
|
||||
data: substeps,
|
||||
meta: {
|
||||
count: substeps.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getTriggerSubstepsMock;
|
||||
@@ -0,0 +1,25 @@
|
||||
const getTriggersMock = (triggers) => {
|
||||
const triggersData = triggers.map((trigger) => {
|
||||
return {
|
||||
description: trigger.description,
|
||||
key: trigger.key,
|
||||
name: trigger.name,
|
||||
pollInterval: trigger.pollInterval,
|
||||
showWebhookUrl: trigger.showWebhookUrl,
|
||||
type: trigger.type,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
data: triggersData,
|
||||
meta: {
|
||||
count: triggers.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getTriggersMock;
|
||||
Reference in New Issue
Block a user