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

Documentation updates #1229

Merged
merged 9 commits into from
Nov 25, 2024
2,705 changes: 1,669 additions & 1,036 deletions docs/cadt_rpc_api.md

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,51 +44,51 @@
"cors": "^2.8.5",
"csvtojson": "^2.0.10",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"express": "^4.21.1",
"express-joi-validation": "^5.0.1",
"joi": "^17.13.3",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"log-update": "^4.0.0",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.11.0",
"mysql2": "^3.11.3",
"node-xlsx": "^0.23.0",
"regenerator-runtime": "^0.13.11",
"rxjs": "^7.8.1",
"sequelize": "^6.37.3",
"socket.io": "^4.7.5",
"sequelize": "^6.37.5",
"socket.io": "^4.8.1",
"sqlite3": "^5.1.7",
"superagent": "^8.1.2",
"toad-scheduler": "^3.0.1",
"uuidv4": "^6.2.13",
"winston": "^3.14.1",
"winston": "^3.15.0",
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
"@babel/cli": "^7.25.7",
"@babel/core": "^7.25.8",
"@babel/eslint-parser": "^7.25.8",
"@babel/plugin-syntax-import-attributes": "^7.25.7",
"@babel/preset-env": "^7.25.8",
"@babel/register": "^7.25.7",
"@babel/cli": "^7.25.9",
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/register": "^7.25.9",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@eslint/js": "^9.13.0",
"@eslint/eslintrc": "^3.1.0",
"@yao-pkg/pkg": "^5.15.0",
"@eslint/js": "^9.14.0",
"@yao-pkg/pkg": "^5.16.1",
"babel-plugin-module-resolver": "^5.0.2",
"chai": "^5.1.1",
"chai": "^5.1.2",
"chai-http": "^5.1.1",
"eslint": "^9.13.0",
"eslint-plugin-es": "^4.1.0",
"eslint-plugin-mocha": "^10.5.0",
"extensionless": "^1.9.9",
"globals": "^15.11.0",
"husky": "^9.1.6",
"mocha": "^10.7.3",
"mocha": "^10.8.2",
"semver": "^7.6.3",
"sinon": "^19.0.2",
"socket.io-client": "^4.8.0",
"socket.io-client": "^4.8.1",
"standard-version": "^9.5.0",
"supertest": "^7.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export const resyncOrganization = async (req, res) => {

await Organization.update(
{ registryHash: '0' },
{ where: { orgUid: req.body.orgUid } },
{ where: { orgUid: req?.body?.orgUid } },
);

await Promise.all([
Expand All @@ -367,7 +367,7 @@ export const resyncOrganization = async (req, res) => {
await transaction.commit();

return res.json({
message: 'Resyncing organization completed',
message: 'Resyncing organization process initiated',
success: true,
});
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export const destroy = async (req, res) => {
await Staging.create(stagedData);

res.json({
message: 'Project deleted successfully',
message: 'Project deletion staged successfully',
success: true,
});
} catch (err) {
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/staging.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ import {
assertStagingTableNotEmpty,
} from '../utils/data-assertions';

export const hasPendingTransactions = async (req, res) => {
export const hasPendingCommits = async (req, res) => {
try {
await assertNoPendingCommits();
res.json({
confirmed: true,
message: 'There are no pending transactions',
message: 'There are no pending commits',
success: true,
});
} catch (error) {
} catch {
res.json({
confirmed: false,
message: 'There are currently pending transactions',
message: 'There are currently pending commits',
success: true,
});
}
Expand Down Expand Up @@ -130,7 +130,7 @@ export const destroy = async (req, res) => {
},
});
res.json({
message: 'Deleted from stage',
message: 'Deleted from staging',
success: true,
});
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/units.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const destroy = async (req, res) => {

await Staging.upsert(stagedData);
res.json({
message: 'Unit deleted successfully',
message: 'Unit deletion staged successfully',
success: true,
});
} catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions src/models/organizations/organizations.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ class Organization extends Model {
}

const orgDataObj = orgData.reduce((obj, curr) => {
console.log(curr);
obj[curr.key] = curr.value;
return obj;
}, {});
Expand Down Expand Up @@ -268,13 +267,14 @@ class Organization extends Model {

static async importOrganization(orgUid) {
try {
console.log('Importing organization ' + orgUid);
logger.info('Importing organization ' + orgUid);
const orgData = await datalayer.getSubscribedStoreData(orgUid);

if (!orgData.registryId) {
logger.error(
'Currupted organization, no registryId on the datalayer, can not import',
'Corrupted organization, no registryId on the datalayer, can not import',
);
return;
}

logger.info(`IMPORTING REGISTRY: ${orgData.registryId}`);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/v1/resources/filestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const upload = multer();
import { FileStoreController } from '../../../controllers';
import { getFileSchema, subscribedSchema } from '../../../validations';

FileStoreRouter.post('/get_file', validator.body(getFileSchema), (req, res) => {
FileStoreRouter.get('/get_file', validator.body(getFileSchema), (req, res) => {
return FileStoreController.getFile(req, res);
});

Expand Down
10 changes: 5 additions & 5 deletions src/routes/v1/resources/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import multer from 'multer';
import { OrganizationController } from '../../../controllers';
import {
importOrganizationSchema,
newOrganizationSchema,
newOrganizationWithIconSchema,
resyncOrganizationSchema,
subscribeOrganizationSchema,
unsubscribeOrganizationSchema,
Expand All @@ -25,15 +25,15 @@ OrganizationRouter.get('/', (req, res) => {
return OrganizationController.findAll(req, res);
});

OrganizationRouter.get(
'/organizations',
OrganizationRouter.post(
'/remove-mirror',
validator.body(removeMirrorSchema),
(req, res) => {
return OrganizationController.removeMirror(req, res);
},
);

OrganizationRouter.get('/sync', (req, res) => {
OrganizationRouter.post('/sync', (req, res) => {
return OrganizationController.sync(req, res);
});

Expand All @@ -43,7 +43,7 @@ OrganizationRouter.delete('/', (req, res) => {

OrganizationRouter.post(
'/',
validator.body(newOrganizationSchema),
validator.body(newOrganizationWithIconSchema),
(req, res) => {
return OrganizationController.create(req, res);
},
Expand Down
2 changes: 1 addition & 1 deletion src/routes/v1/resources/staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ StagingRouter.post(
StagingRouter.delete('/clean', StagingController.clean);

StagingRouter.get('/hasPendingTransactions', (req, res) => {
return StagingController.hasPendingTransactions(req, res);
return StagingController.hasPendingCommits(req, res);
});

export { StagingRouter };
12 changes: 6 additions & 6 deletions src/validations/audit.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import Joi from 'joi';

export const auditGetSchema = Joi.object()
.keys({
page: Joi.number(),
limit: Joi.number(),
orgUid: Joi.string(),
page: Joi.number().required(),
limit: Joi.number().required(),
orgUid: Joi.string().required(),
order: Joi.string().valid('ASC', 'DESC').optional(),
})
.with('page', 'limit')
.with('limit', 'page');

export const auditResetToGenerationSchema = Joi.object().keys({
generation: Joi.number(),
orgUid: Joi.string(),
generation: Joi.number().required(),
orgUid: Joi.string().required(),
});

export const auditResetToDateSchema = Joi.object().keys({
date: Joi.date(),
date: Joi.date().required(),
orgUid: Joi.string().optional(),
includeHomeOrg: Joi.bool().optional(),
});
4 changes: 2 additions & 2 deletions src/validations/organizations.validations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Joi from 'joi';

export const newOrganizationSchema = Joi.object({
export const newOrganizationWithIconSchema = Joi.object({
name: Joi.string().required(),
icon: Joi.string().optional(),
icon: Joi.string().required(),
});

export const importOrganizationSchema = Joi.object({
Expand Down
1 change: 1 addition & 0 deletions src/validations/staging.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const commitStagingSchema = Joi.object({
author: Joi.string().optional(),
comment: Joi.string().optional(),
ids: Joi.array().items(Joi.string()).optional(),
table: Joi.string().valid('Projects', 'Units').optional(),
});

export const stagingEditSchema = Joi.object({
Expand Down
2 changes: 1 addition & 1 deletion src/validations/units.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const unitsPostSchema = Joi.object({
export const unitsGetQuerySchema = Joi.object({
page: Joi.number().min(1).required(),
limit: Joi.number().max(1000).min(1).required(),
search: Joi.string(),
search: Joi.string().optional(),
warehouseUnitId: Joi.string(),
columns: Joi.array().items(Joi.string()).single(),
orgUid: Joi.string(),
Expand Down
Loading