Skip to content
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a8b2976
create car plugin
Bolortulga07 Jun 10, 2025
48e7c3d
endpoint update
Bolortulga07 Jun 10, 2025
d910cb8
update
Bolortulga07 Jun 10, 2025
98ef6a4
update
Bolortulga07 Jun 10, 2025
6c552fb
update
Bolortulga07 Jun 11, 2025
5a1605f
update
Bolortulga07 Jun 11, 2025
3b2ff3c
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 11, 2025
f1116d7
car mutation update
Bolortulga07 Jun 11, 2025
c19612c
schema, constant update
Bolortulga07 Jun 11, 2025
ec03162
update
Bolortulga07 Jun 11, 2025
b674ac4
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 16, 2025
ab58fc5
update
Bolortulga07 Jun 16, 2025
4235df6
carResolver updated
Bolortulga07 Jun 16, 2025
37bf5ec
fillSearchText added
Bolortulga07 Jun 16, 2025
9b7d10c
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 16, 2025
5285325
tags added
Bolortulga07 Jun 16, 2025
a9a0d9a
removed logs
Bolortulga07 Jun 16, 2025
558a47b
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 17, 2025
c08cd5f
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 17, 2025
161a1a3
Update pnpm-lock.yaml
Bolortulga07 Jun 17, 2025
97475c2
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 17, 2025
6ecf141
update
Bolortulga07 Jun 17, 2025
b65dfae
update
Bolortulga07 Jun 17, 2025
fb0772b
update
Bolortulga07 Jun 17, 2025
d3c313b
car_category edit, remove updated
Bolortulga07 Jun 23, 2025
d6cbb96
Merge branch 'main' of github.com:erxes/erxes-next into car_plugin
Bolortulga07 Jun 27, 2025
2fbb658
update
Bolortulga07 Jun 27, 2025
e916cb7
update
Bolortulga07 Jun 27, 2025
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
32 changes: 32 additions & 0 deletions .github/instructions/nx.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
applyTo: '**'
---

// This file is automatically generated by Nx Console

You are in an nx workspace using Nx 20.0.8 and pnpm as the package manager.

You have access to the Nx MCP server and the tools it provides. Use them. Follow these guidelines in order to best help the user:

# General Guidelines
- When answering questions, use the nx_workspace tool first to gain an understanding of the workspace architecture
- For questions around nx configuration, best practices or if you're unsure, use the nx_docs tool to get relevant, up-to-date docs!! Always use this instead of assuming things about nx configuration
- If the user needs help with an Nx configuration or project graph error, use the 'nx_workspace' tool to get any errors
- To help answer questions about the workspace structure or simply help with demonstrating how tasks depend on each other, use the 'nx_visualize_graph' tool

# Generation Guidelines
If the user wants to generate something, use the following flow:

- learn about the nx workspace and any specifics the user needs by using the 'nx_workspace' tool and the 'nx_project_details' tool if applicable
- get the available generators using the 'nx_generators' tool
- decide which generator to use. If no generators seem relevant, check the 'nx_available_plugins' tool to see if the user could install a plugin to help them
- get generator details using the 'nx_generator_schema' tool
- you may use the 'nx_docs' tool to learn more about a specific generator or technology if you're unsure
- decide which options to provide in order to best complete the user's request. Don't make any assumptions and keep the options minimalistic
- open the generator UI using the 'nx_open_generate_ui' tool
- wait for the user to finish the generator
- read the generator log file using the 'nx_read_generator_log' tool
- use the information provided in the log file to answer the user's question or continue with what they were doing



2 changes: 1 addition & 1 deletion backend/core-api/src/modules/contacts/trpc/company.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const companyTrpcRouter = t.router({
findOne: t.procedure.input(z.any()).query(async ({ ctx, input }) => {
const { query } = input;
const { models } = ctx;

console.log('company', input);
const defaultFilter = { status: { $ne: 'deleted' } };

if (query.companyPrimaryName) {
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/cars_api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.env
*.log
18 changes: 18 additions & 0 deletions backend/plugins/cars_api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "cars_api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "tsx watch src/main.ts",
"build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"start": "node -r tsconfig-paths/register dist/src/main.js"
},
Comment on lines +6 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing devDependencies for tooling
The scripts reference tsx, tsc-alias, and tsconfig-paths/register, but these packages aren’t declared in devDependencies. This will break CI/local builds.

Apply this diff to add the missing devDependencies:

  "scripts": {
    "dev": "tsx watch src/main.ts",
    "build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
    "start": "node -r tsconfig-paths/register dist/src/main.js"
  },
- "devDependencies": {}
+ "devDependencies": {
+   "tsx": "^2.0.0",
+   "tsc-alias": "^1.0.0",
+   "tsconfig-paths": "^4.1.0"
+ }

(Use versions according to your lockfile or npm registry.)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"scripts": {
"dev": "tsx watch src/main.ts",
"build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"start": "node -r tsconfig-paths/register dist/src/main.js"
},
"scripts": {
"dev": "tsx watch src/main.ts",
"build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"start": "node -r tsconfig-paths/register dist/src/main.js"
},
"devDependencies": {
"tsx": "^2.0.0",
"tsc-alias": "^1.0.0",
"tsconfig-paths": "^4.1.0"
}
🤖 Prompt for AI Agents
In backend/plugins/cars_api/package.json around lines 6 to 10, the scripts use
the tools tsx, tsc-alias, and tsconfig-paths/register, but these packages are
not listed in devDependencies. To fix this, add these packages with appropriate
versions to the devDependencies section to ensure CI and local builds do not
fail due to missing modules.

"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"erxes-api-shared": "workspace:^"
},
"devDependencies": {}
}
57 changes: 57 additions & 0 deletions backend/plugins/cars_api/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "cars_api",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "backend/plugins/cars_api/src",
"projectType": "application",
"tags": [],
"targets": {
"build": {
"executor": "nx:run-commands",
"cache": true,
"options": {
"cwd": "backend/plugins/cars_api",
"commands": [
"pnpm build"
]
},
"dependsOn": [
"^build",
"build:packageJson"
]
},
"build:packageJson": {
"executor": "@nx/js:tsc",
"options": {
"main": "backend/plugins/cars_api/dist/src/main.js",
"tsConfig": "backend/plugins/cars_api/tsconfig.build.json",
"outputPath": "backend/plugins/cars_api/dist",
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies"
}
},
"start": {
"executor": "nx:run-commands",
"dependsOn": [
"typecheck",
"build"
],
Comment on lines +32 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

start depends on typecheck, which is undefined in this project

Nx will warn and skip the dependency. Define a typecheck target (e.g., @nx/js:tsc --noEmit) or drop the dependency.

🤖 Prompt for AI Agents
In backend/plugins/cars_api/project.json around lines 32 to 37, the "start"
target lists "typecheck" as a dependency, but "typecheck" is not defined in this
project, causing Nx to warn and skip it. To fix this, either define a
"typecheck" target in the project configuration that runs a TypeScript type
check command (such as using @nx/js:tsc with --noEmit), or remove "typecheck"
from the "dependsOn" array in the "start" target.

"options": {
"cwd": "backend/plugins/cars_api",
"command": "NODE_ENV=development node dist/src/main.js"
}
},
"serve": {
"executor": "nx:run-commands",
"options": {
"cwd": "backend/plugins/cars_api",
"command": "NODE_ENV=development pnpm dev"
}
},
"docker-build": {
"dependsOn": [
"build"
],
"command": "docker build -f backend/plugins/cars_api/Dockerfile . -t erxes/erxes-next-cars_api"
}
Comment on lines +50 to +55
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

docker-build target is missing an executor – Nx will refuse to run it

All other targets specify "executor": "nx:run-commands".
Without it, nx run cars_api:docker-build fails validation.

-  "docker-build": {
-    "dependsOn": ["build"],
-    "command": "docker build -f backend/plugins/cars_api/Dockerfile . -t erxes/erxes-next-cars_api"
-  }
+  "docker-build": {
+    "executor": "nx:run-commands",
+    "dependsOn": ["build"],
+    "options": {
+      "command": "docker build -f backend/plugins/cars_api/Dockerfile . -t erxes/erxes-next-cars_api",
+      "cwd": "."
+    }
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"docker-build": {
"dependsOn": [
"build"
],
"command": "docker build -f backend/plugins/cars_api/Dockerfile . -t erxes/erxes-next-cars_api"
}
"docker-build": {
"executor": "nx:run-commands",
"dependsOn": [
"build"
],
"options": {
"command": "docker build -f backend/plugins/cars_api/Dockerfile . -t erxes/erxes-next-cars_api",
"cwd": "."
}
}
🤖 Prompt for AI Agents
In backend/plugins/cars_api/project.json around lines 50 to 55, the
"docker-build" target is missing the "executor" field, causing Nx to reject
running it. Add "executor": "nx:run-commands" to the "docker-build" target
alongside the existing "dependsOn" and "command" properties to fix the
validation error and allow Nx to execute the target.

}
}
16 changes: 16 additions & 0 deletions backend/plugins/cars_api/src/apollo/resolvers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { apolloCustomScalars } from 'erxes-api-shared/utils';
import { customResolvers } from './resolvers';
import { mutations } from './mutations';
import { queries } from './queries';
const resolvers: any = {
Mutation: {
...mutations,
},
Query: {
...queries,
},
...apolloCustomScalars,
...customResolvers,
};
Comment on lines +5 to +14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid any; type the resolver map for safer schema-code alignment

Using any defeats TypeScript’s usefulness in catching mismatched resolver signatures (e.g., returning a Promise where the schema expects an object). Prefer IResolvers<Context> (from @graphql-tools/utils / apollo-server-core) or a generated type from @graphql-codegen/*.

-const resolvers: any = {
+import { IResolvers } from '@graphql-tools/utils'; // or your preferred typings
+const resolvers: IResolvers = {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const resolvers: any = {
Mutation: {
...mutations,
},
Query: {
...queries,
},
...apolloCustomScalars,
...customResolvers,
};
import { IResolvers } from '@graphql-tools/utils'; // or your preferred typings
const resolvers: IResolvers = {
Mutation: {
...mutations,
},
Query: {
...queries,
},
...apolloCustomScalars,
...customResolvers,
};
🤖 Prompt for AI Agents
In backend/plugins/cars_api/src/apollo/resolvers/index.ts around lines 5 to 14,
the resolvers object is typed as any, which disables TypeScript's type checking
for resolver signatures. Replace the any type with a proper resolver map type
such as IResolvers<Context> imported from @graphql-tools/utils or
apollo-server-core, or use a generated type from @graphql-codegen to ensure the
resolver signatures align with the GraphQL schema and improve type safety.


export default resolvers;
7 changes: 7 additions & 0 deletions backend/plugins/cars_api/src/apollo/resolvers/mutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { carMutations } from '~/modules/cars/graphql/resolvers/mutations/carMutations';
import { carCategoryMutations } from '~/modules/cars/graphql/resolvers/mutations/categoryMutations';

export const mutations = {
...carMutations,
...carCategoryMutations,
};
7 changes: 7 additions & 0 deletions backend/plugins/cars_api/src/apollo/resolvers/queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { carQueries } from '~/modules/cars/graphql/resolvers/queries/carQueries';
import { CarCategoryQueries } from '~/modules/cars/graphql/resolvers/queries/categoryQueries';

export const queries = {
...carQueries,
...CarCategoryQueries,
};
7 changes: 7 additions & 0 deletions backend/plugins/cars_api/src/apollo/resolvers/resolvers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import carResolver from '~/modules/cars/graphql/resolvers/customResolvers/carResolver';
import categoryResolver from '~/modules/cars/graphql/resolvers/customResolvers/categoryResolver';

export const customResolvers = {
Car: carResolver,
categoryResolver,
};
Comment on lines +4 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Resolver map key is wrong—will register a phantom type

categoryResolver is itself a resolver object. By keeping it under the key categoryResolver, Apollo will look for a GraphQL type literally named categoryResolver, likely causing “Type categoryResolver is not present in the schema” errors.

Merge the object instead:

 export const customResolvers = {
   Car: carResolver,
-  categoryResolver,
+  ...categoryResolver,
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const customResolvers = {
Car: carResolver,
categoryResolver,
};
export const customResolvers = {
Car: carResolver,
...categoryResolver,
};
🤖 Prompt for AI Agents
In backend/plugins/cars_api/src/apollo/resolvers/resolvers.ts around lines 4 to
7, the resolver map incorrectly uses the key 'categoryResolver' for an entire
resolver object, which causes Apollo to look for a GraphQL type named
'categoryResolver' that does not exist. To fix this, merge the properties of the
categoryResolver object directly into the customResolvers object instead of
nesting it under the 'categoryResolver' key, ensuring all resolvers are
correctly registered under their respective GraphQL type names.

31 changes: 31 additions & 0 deletions backend/plugins/cars_api/src/apollo/schema/schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
mutations as carMutations,
queries as carQueries,
types as carTypes,
} from '~/modules/cars/graphql/schemas/cars';

import {
mutations as carCategoryMutations,
queries as CarCategoryQueries,
types as carCategoryTypes,
} from '~/modules/cars/graphql/schemas/category';

import { TypeExtensions } from '~/modules/cars/graphql/schemas/extension';

export const types = `
${TypeExtensions}
${carTypes},
${carCategoryTypes}
`;

export const queries = `
${carQueries},
${CarCategoryQueries}
`;

export const mutations = `
${carMutations},
${carCategoryMutations}
`;
Comment on lines +15 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Trailing commas generate invalid GraphQL SDL
Embedding commas directly after ${carTypes} / ${carQueries} / ${carMutations} results in:

type Car { … },

The comma is illegal in SDL and Apollo will fail to start.

-${carTypes},
-${carCategoryTypes}
+${carTypes}
+${carCategoryTypes}

Repeat for queries and mutations blocks.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const types = `
${TypeExtensions}
${carTypes},
${carCategoryTypes}
`;
export const queries = `
${carQueries},
${CarCategoryQueries}
`;
export const mutations = `
${carMutations},
${carCategoryMutations}
`;
export const types = `
${TypeExtensions}
${carTypes}
${carCategoryTypes}
`;
export const queries = `
${carQueries}
${CarCategoryQueries}
`;
export const mutations = `
${carMutations}
${carCategoryMutations}
`;
🤖 Prompt for AI Agents
In backend/plugins/cars_api/src/apollo/schema/schema.ts around lines 15 to 29,
remove the trailing commas immediately following the template interpolations
(${carTypes}, ${carQueries}, ${carMutations}) in the types, queries, and
mutations string definitions. These commas produce invalid GraphQL SDL syntax
and cause Apollo server startup failures. Ensure the template strings
concatenate the parts without adding commas after each interpolation.


export default { types, queries, mutations };
17 changes: 17 additions & 0 deletions backend/plugins/cars_api/src/apollo/typeDefs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { apolloCommonTypes } from 'erxes-api-shared/utils';
import { DocumentNode } from 'graphql';
import { gql } from 'graphql-tag';
import { mutations, queries, types } from '~/apollo/schema/schema';

export const typeDefs = async (): Promise<DocumentNode> => {
return gql`
${apolloCommonTypes}
${types}
extend type Query {
${queries}
}
extend type Mutation {
${mutations}
}
`;
};
37 changes: 37 additions & 0 deletions backend/plugins/cars_api/src/connectionResolvers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { createGenerateModels } from 'erxes-api-shared/utils';
import { IMainContext } from 'erxes-api-shared/core-types';
import { ICarDocument } from '~/modules/cars/@types/car';

import mongoose from 'mongoose';

import { loadCarClass, ICarModel } from '~/modules/cars/db/models/carModel';
import {
ICarCategoryModel,
loadCarCategoryClass,
} from './modules/cars/db/models/categoryModel';
import { ICarCategoryDocument } from './modules/cars/@types/category';

export interface IModels {
Cars: ICarModel;
CarCategories: ICarCategoryModel;
}

export interface IContext extends IMainContext {
models: IModels;
commonQuerySelector: string;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: commonQuerySelector typed as string but used as filter object

Update the type of commonQuerySelector to an object to match its usage as a filter.

}

export const loadClasses = (db: mongoose.Connection): IModels => {
const models = {} as IModels;

models.Cars = db.model<ICarDocument, ICarModel>('cars', loadCarClass(models));

models.CarCategories = db.model<ICarCategoryDocument, ICarCategoryModel>(
'carCategories',
loadCarCategoryClass(models),
);

return models;
};

export const generateModels = createGenerateModels<IModels>(loadClasses);
32 changes: 32 additions & 0 deletions backend/plugins/cars_api/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { startPlugin } from 'erxes-api-shared/utils';
import { typeDefs } from '~/apollo/typeDefs';
import { appRouter } from '~/trpc/init-trpc';
import resolvers from './apollo/resolvers';
import { generateModels } from './connectionResolvers';

startPlugin({
name: 'cars',
port: 33010,
graphql: async () => ({
typeDefs: await typeDefs(),
resolvers,
}),
apolloServerContext: async (subdomain, context) => {
const models = await generateModels(subdomain);

context.models = models;

return context;
},
trpcAppRouter: {
router: appRouter,
createContext: async (subdomain, context) => {
const models = await generateModels(subdomain);

context.models = models;

return context;
},
},
});

40 changes: 40 additions & 0 deletions backend/plugins/cars_api/src/modules/cars/@types/car.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Document } from 'mongoose';
import {
IAttachment,
ICursorPaginateParams,
IListParams,
} from 'erxes-api-shared/core-types';

export interface ICar {
ownerId: string;
plateNumber: string;
vinNumber: string;
colorCode: string;
categoryId: string;
bodyType: string;
fuelType: string;
gearBox: string;
vintageYear: number;
importYear: number;
status: string;
description: string;
tagIds: string[];
mergeIds: string[];
searchText: string;
attachment: IAttachment;
}

export interface ICarDocument extends ICar, Document {
_id: string;
createdAt: Date;
updatedAt: Date;
ownerId: string;
searchText: string;
}

export interface ICarParams extends IListParams, ICursorPaginateParams {
ids?: string[];
categoryId?: string;
searchValue?: string;
tag?: string;
}
18 changes: 18 additions & 0 deletions backend/plugins/cars_api/src/modules/cars/@types/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Document } from 'mongoose';
import { IAttachment } from 'erxes-api-shared/core-types';

export interface ICarCategory {
name: String;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript primitives: use lowercase string instead of String for properties (e.g. name, code, parentId, description) to follow TypeScript best practices.

code: String;
parentId: String;
description: String;
image: IAttachment;
secondaryImages: [IAttachment];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property secondaryImages is declared as a tuple type ([IAttachment]). Consider using an array type (IAttachment[]) to better represent a list of attachments.

Suggested change
secondaryImages: [IAttachment];
secondaryImages: IAttachment[];

productCategoryId: String;
}

export interface ICarCategoryDocument extends ICarCategory, Document {
_id: string;
createdAt: Date;
updatedAt: Date;
}
47 changes: 47 additions & 0 deletions backend/plugins/cars_api/src/modules/cars/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export const GEARBOX = {
UNKNOWN: '',
AUTOMATIC: 'automatic',
MANUAL: 'manual',
CVT: 'cvt',
SEMI_AUTOMATIC: 'semi_automatic',
ALL: ['', 'automatic', 'manual', 'cvt', 'semi_automatic'],
};

export const FUEL_TYPES = {
UNKNOWN: '',
HYBRID: 'hybrid',
PETROL: 'petrol',
DIESEL: 'diesel',
FLEXIFUEL: 'flexiFuel',
ELECTRIC: 'electric',
ALL: ['', 'hybrid', 'petrol', 'diesel', 'flexiFuel', 'electric'],
};

export const BODY_TYPES = {
UNKNOWN: '',
SEDAN: 'sedan',
SUV: 'suv',
COMPACT: 'compact',
Wagon: 'wagon',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical error: The key Wagon should be in all uppercase (i.e. WAGON) to maintain consistency with the other keys in BODY_TYPES.

Suggested change
Wagon: 'wagon',
WAGON: 'wagon',

VAN: 'van',
HATCHBACK: 'hatchback',
PICKUP: 'pickUp',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical inconsistency: The value for PICKUP is 'pickUp' with a capital 'U'. Consider using 'pickup' (all lowercase) for consistency with the other values.

SPORT_COUPE: 'sport_coupe',
ALL: [
'',
'sedan',
'suv',
'compact',
'wagon',
'van',
'hatchback',
'pickUp',
'sport_coupe',
],
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Inconsistent casing & spelling in BODY_TYPES jeopardises equality checks

Keys/values mix camel-, pascal- and snake-case (Wagon, pickUp, etc.).
Consumers comparing user input to these constants will stumble.

-  Wagon: 'wagon',
-  PICKUP: 'pickUp',
+  WAGON: 'wagon',
+  PICKUP: 'pickup',
 ...
-    'pickUp',
+    'pickup',

Align all enum keys to SCREAMING_SNAKE and values to lowercase snake-case, then update the ALL list accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const BODY_TYPES = {
UNKNOWN: '',
SEDAN: 'sedan',
SUV: 'suv',
COMPACT: 'compact',
Wagon: 'wagon',
VAN: 'van',
HATCHBACK: 'hatchback',
PICKUP: 'pickUp',
SPORT_COUPE: 'sport_coupe',
ALL: [
'',
'sedan',
'suv',
'compact',
'wagon',
'van',
'hatchback',
'pickUp',
'sport_coupe',
],
};
export const BODY_TYPES = {
UNKNOWN: '',
SEDAN: 'sedan',
SUV: 'suv',
COMPACT: 'compact',
WAGON: 'wagon',
VAN: 'van',
HATCHBACK: 'hatchback',
PICKUP: 'pickup',
SPORT_COUPE: 'sport_coupe',
ALL: [
'',
'sedan',
'suv',
'compact',
'wagon',
'van',
'hatchback',
'pickup',
'sport_coupe',
],
};
🤖 Prompt for AI Agents
In backend/plugins/cars_api/src/modules/cars/constants.ts between lines 20 and
41, the BODY_TYPES object has inconsistent casing and spelling in keys and
values, mixing camelCase, PascalCase, and snake_case. To fix this, rename all
keys to SCREAMING_SNAKE_CASE and convert all values to lowercase snake_case
consistently. Also update the ALL array to reflect these corrected lowercase
snake_case values to ensure reliable equality checks.


export const STATUSES = {
ACTIVE: 'active',
DELETED: 'deleted',
ALL: ['active', 'deleted'],
};
Loading