refactor: Use internal namespace for the existing API
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import appConfig from '../../../../../../src/config/app.js';
|
||||
|
||||
const createUserMock = (user) => {
|
||||
const userData = {
|
||||
createdAt: user.createdAt.getTime(),
|
||||
email: user.email,
|
||||
fullName: user.fullName,
|
||||
id: user.id,
|
||||
status: user.status,
|
||||
updatedAt: user.updatedAt.getTime(),
|
||||
};
|
||||
|
||||
if (appConfig.isCloud && user.trialExpiryDate) {
|
||||
userData.trialExpiryDate = user.trialExpiryDate.toISOString();
|
||||
}
|
||||
|
||||
return {
|
||||
data: userData,
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'User',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default createUserMock;
|
||||
@@ -0,0 +1,55 @@
|
||||
const getAppsMock = () => {
|
||||
const appsData = [
|
||||
{
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/deepl/connection',
|
||||
connectionCount: 1,
|
||||
flowCount: 1,
|
||||
iconUrl: 'http://localhost:3000/apps/deepl/assets/favicon.svg',
|
||||
key: 'deepl',
|
||||
name: 'DeepL',
|
||||
primaryColor: '#0d2d45',
|
||||
supportsConnections: true,
|
||||
},
|
||||
{
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/github/connection',
|
||||
connectionCount: 1,
|
||||
flowCount: 1,
|
||||
iconUrl: 'http://localhost:3000/apps/github/assets/favicon.svg',
|
||||
key: 'github',
|
||||
name: 'GitHub',
|
||||
primaryColor: '#000000',
|
||||
supportsConnections: true,
|
||||
},
|
||||
{
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/slack/connection',
|
||||
flowCount: 1,
|
||||
iconUrl: 'http://localhost:3000/apps/slack/assets/favicon.svg',
|
||||
key: 'slack',
|
||||
name: 'Slack',
|
||||
primaryColor: '#4a154b',
|
||||
supportsConnections: true,
|
||||
},
|
||||
{
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/webhook/connection',
|
||||
flowCount: 1,
|
||||
iconUrl: 'http://localhost:3000/apps/webhook/assets/favicon.svg',
|
||||
key: 'webhook',
|
||||
name: 'Webhook',
|
||||
primaryColor: '#0059F7',
|
||||
supportsConnections: false,
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
data: appsData,
|
||||
meta: {
|
||||
count: appsData.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getAppsMock;
|
||||
@@ -0,0 +1,39 @@
|
||||
const getCurrentUserMock = (currentUser, role, permissions) => {
|
||||
return {
|
||||
data: {
|
||||
createdAt: currentUser.createdAt.getTime(),
|
||||
email: currentUser.email,
|
||||
fullName: currentUser.fullName,
|
||||
id: currentUser.id,
|
||||
permissions: permissions.map((permission) => ({
|
||||
id: permission.id,
|
||||
roleId: permission.roleId,
|
||||
action: permission.action,
|
||||
subject: permission.subject,
|
||||
conditions: permission.conditions,
|
||||
createdAt: permission.createdAt.getTime(),
|
||||
updatedAt: permission.updatedAt.getTime(),
|
||||
})),
|
||||
role: {
|
||||
createdAt: role.createdAt.getTime(),
|
||||
description: null,
|
||||
id: role.id,
|
||||
isAdmin: role.isAdmin,
|
||||
name: role.name,
|
||||
updatedAt: role.updatedAt.getTime(),
|
||||
},
|
||||
status: currentUser.status,
|
||||
trialExpiryDate: currentUser.trialExpiryDate.toISOString(),
|
||||
updatedAt: currentUser.updatedAt.getTime(),
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'User',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getCurrentUserMock;
|
||||
@@ -0,0 +1,14 @@
|
||||
const getInvoicesMock = async (invoices) => {
|
||||
return {
|
||||
data: invoices,
|
||||
meta: {
|
||||
count: invoices.length,
|
||||
currentPage: null,
|
||||
isArray: true,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getInvoicesMock;
|
||||
@@ -0,0 +1,27 @@
|
||||
const getSubscriptionMock = (subscription) => {
|
||||
return {
|
||||
data: {
|
||||
id: subscription.id,
|
||||
paddlePlanId: subscription.paddlePlanId,
|
||||
paddleSubscriptionId: subscription.paddleSubscriptionId,
|
||||
cancelUrl: subscription.cancelUrl,
|
||||
updateUrl: subscription.updateUrl,
|
||||
status: subscription.status,
|
||||
nextBillAmount: subscription.nextBillAmount,
|
||||
nextBillDate: subscription.nextBillDate.toISOString(),
|
||||
lastBillDate: subscription.lastBillDate,
|
||||
cancellationEffectiveDate: subscription.cancellationEffectiveDate,
|
||||
createdAt: subscription.createdAt.getTime(),
|
||||
updatedAt: subscription.updatedAt.getTime(),
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'Subscription',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getSubscriptionMock;
|
||||
@@ -0,0 +1,17 @@
|
||||
const getUserTrialMock = async (currentUser) => {
|
||||
return {
|
||||
data: {
|
||||
inTrial: await currentUser.inTrial(),
|
||||
expireAt: currentUser.trialExpiryDate.toISOString(),
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'Object',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getUserTrialMock;
|
||||
@@ -0,0 +1,29 @@
|
||||
import appConfig from '../../../../../../src/config/app.js';
|
||||
|
||||
const registerUserMock = (user) => {
|
||||
const userData = {
|
||||
createdAt: user.createdAt.getTime(),
|
||||
email: user.email,
|
||||
fullName: user.fullName,
|
||||
id: user.id,
|
||||
status: user.status,
|
||||
updatedAt: user.updatedAt.getTime(),
|
||||
};
|
||||
|
||||
if (appConfig.isCloud && user.trialExpiryDate) {
|
||||
userData.trialExpiryDate = user.trialExpiryDate.toISOString();
|
||||
}
|
||||
|
||||
return {
|
||||
data: userData,
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'User',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default registerUserMock;
|
||||
@@ -0,0 +1,22 @@
|
||||
const updateCurrentUserPasswordMock = (currentUser) => {
|
||||
return {
|
||||
data: {
|
||||
createdAt: currentUser.createdAt.getTime(),
|
||||
email: currentUser.email,
|
||||
fullName: currentUser.fullName,
|
||||
id: currentUser.id,
|
||||
status: currentUser.status,
|
||||
updatedAt: currentUser.updatedAt.getTime(),
|
||||
trialExpiryDate: currentUser.trialExpiryDate?.toISOString(),
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'User',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default updateCurrentUserPasswordMock;
|
||||
@@ -0,0 +1,21 @@
|
||||
const updateCurrentUserMock = (currentUser) => {
|
||||
return {
|
||||
data: {
|
||||
createdAt: currentUser.createdAt.getTime(),
|
||||
email: currentUser.email,
|
||||
fullName: currentUser.fullName,
|
||||
id: currentUser.id,
|
||||
status: currentUser.status,
|
||||
updatedAt: currentUser.updatedAt.getTime(),
|
||||
},
|
||||
meta: {
|
||||
count: 1,
|
||||
currentPage: null,
|
||||
isArray: false,
|
||||
totalPages: null,
|
||||
type: 'User',
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default updateCurrentUserMock;
|
||||
Reference in New Issue
Block a user