var restBasePath = "api/";

module.exports.REST_API_WEB_BASE_PATH = restBasePath;

var serverRoutes = {};

serverRoutes.appHome = "/";
serverRoutes.appLogin = "/";

serverRoutes.appForgotPass = "forgotpass";
serverRoutes.appForgotPassAction = "auth/forgotpass";
serverRoutes.appResetPass = "resetpass";
serverRoutes.appResetpassAction = "auth/resetpass";
serverRoutes.appActivateAccount = "activateAccount";
serverRoutes.appActivateAccountAction = "auth/activateAccount";
serverRoutes.appDefault = "default";

serverRoutes.logout = 'auth/logout';
serverRoutes.logoutAllDevices = 'auth/logoutAllDevices';
serverRoutes.login = 'auth/login/local';
serverRoutes.loginSaml = 'auth/login/saml';
serverRoutes.loginGoogle = 'auth/login/google';
serverRoutes.loginGoogleCallback = 'auth/login/google/callback';
serverRoutes.loginFacebook = 'auth/login/facebook';
serverRoutes.loginFacebookCallback = 'auth/login/facebook/callback';
serverRoutes.loggedUser = 'api/loggedUser';
serverRoutes.loggedUserData = 'api/loggedUserData';
serverRoutes.loggedUserAccountControlDocument = serverRoutes.loggedUser + '/accountControlDocument';
serverRoutes.loggedUserAccountGroupConfigDocument = serverRoutes.loggedUser + '/accountGroupConfigDocument';
serverRoutes.testPassword = 'password/test';

serverRoutes.publicLogin = '/auth/login/public';

serverRoutes.uploadFiles = restBasePath + "uploadFiles";
serverRoutes.deleteFile = restBasePath + "deleteFile";
serverRoutes.loadFile = restBasePath + "getFile";
serverRoutes.getFile = restBasePath + "getFile/:fileNo";
serverRoutes.getFileWithName = restBasePath + "getFile/:fileNo/:fileName";

serverRoutes.packageImport = restBasePath + "uploadPackage";
serverRoutes.packageExport = restBasePath + "packageExport/:id";
serverRoutes.packageCleanUp = restBasePath + "packageCleanUp/:type/:id";

//Template and Document routes
serverRoutes.document = restBasePath + "document";
// userId parameter will be ignored because the logged in user will always be used
serverRoutes.documentWithUser = restBasePath + "document/:userId";

serverRoutes.documentWithUserBase = restBasePath + "documentWithUser";
serverRoutes.templateAndDocument = restBasePath + "templateAndDocument";
serverRoutes.templateAndDocumentId = serverRoutes.templateAndDocument + "/:id";
serverRoutes.templateAndDocumentWithTemplateId = serverRoutes.templateAndDocument + "/:id/:templateId";

serverRoutes.documentDeepDiffUpdate = serverRoutes.document + "/deepDiffUpdate";
serverRoutes.documentDeepDiffUpdateSingle = serverRoutes.documentDeepDiffUpdate + "/:id";

serverRoutes.documentExists = serverRoutes.document + "/exists";
serverRoutes.documentExistsFull = serverRoutes.documentExists + "/:id";
serverRoutes.documentExistsIncludeDeleted = serverRoutes.documentExists + "/:id/:includeDeleted";

serverRoutes.documentSingle = serverRoutes.document + "/:id";
// userId parameter will be ignored because the logged in user will always be used
serverRoutes.documentSingleWithUser = serverRoutes.documentWithUserBase + "/:id/:userId";

serverRoutes.documentDestroy = serverRoutes.document + "/:id";
serverRoutes.documentDestroyWithTemplateIdAndPreviousVersionId = serverRoutes.document + "/:id/:templateId/:previousVersionId";

serverRoutes.documentSingleOverrideTpl = serverRoutes.documentDeepDiffUpdate + "/:id/:template";

serverRoutes.documentDeepDiffUpdateWithUser = serverRoutes.document + "/deepDiffUpdateWithUser";
// userId parameter will be ignored because the logged in user will always be used
serverRoutes.documentDeepDiffUpdateSingleWithUser = serverRoutes.documentDeepDiffUpdateWithUser + "/:id/:userId";

serverRoutes.syncDocuments = restBasePath + "syncDocuments";
serverRoutes.syncRecordsByServerUpdatedDateWithPagination = serverRoutes.syncDocuments + "/:startTime/:pageNumber";

serverRoutes.syncDocumentsCountURL = restBasePath + "syncDocumentsCount";
serverRoutes.syncDocumentsCountByDateRoute = serverRoutes.syncDocumentsCountURL + "/:startTime";

serverRoutes.undeleteDocument  = restBasePath + "undelete" + "/:id";

serverRoutes.bulkUploadDocuments = restBasePath + "bulkUploadDocuments";

// document audit
serverRoutes.documentAudit = restBasePath + "documentAudit";

// index.html. This is written dynamically so that the base path can be changed
serverRoutes.indexHtml = "/index.html";

serverRoutes.documentSearch = restBasePath + "documentSearch";
serverRoutes.searchExport = restBasePath + "searchExport";
serverRoutes.generatePit = restBasePath + "generatePit";

// find documents directly in Mongo
serverRoutes.documentFind = restBasePath + "documentFind" + "/:query";
serverRoutes.documentsBaseUrl = restBasePath + "documents";
serverRoutes.documentsUrl = serverRoutes.documentsBaseUrl + "/:query";
serverRoutes.documentFetch = restBasePath + "documentFetch";
serverRoutes.versionFetch = restBasePath + "versionFetch";

/**
 * Could not retrieve docs from client side URL query
 */
serverRoutes.loadDocsForRulesBaseUrl = restBasePath + "documents/loadDocsForRules";
// userId parameter will be ignored because the logged in user will always be used
serverRoutes.loadDocsForRulesUrl = serverRoutes.loadDocsForRulesBaseUrl + "/:userId";
serverRoutes.loadIncludeDocs = restBasePath + "loadIncludeDocs";

serverRoutes.template = restBasePath + "template";
serverRoutes.templateSingle = serverRoutes.template + "/:id";

serverRoutes.sessionTest = restBasePath + "sessionTest";
serverRoutes.healthCheck = restBasePath + "healthCheck";

serverRoutes.serverTime = restBasePath + "time/current";

//custom component functions
serverRoutes.executeFunction = restBasePath + "execute";
serverRoutes.executeFunctionWS = serverRoutes.executeFunction + "/:componentName/:functionName";

serverRoutes.loadComponentDoc = restBasePath + "loadComponentDoc/:componentName";

serverRoutes.loadVendorLibrary = restBasePath + "loadVendorLibrary/:name"; // name or documentId
serverRoutes.loadVendorLibraries = restBasePath + "loadVendorLibraries";

//urls for loading configuration from database
serverRoutes.loadClientConfig = "clientConfig";

serverRoutes.clientResources = restBasePath + "clientResources";

module.exports.serverRoutes = serverRoutes;
