-
Notifications
You must be signed in to change notification settings - Fork 3
Car plugin #225
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
base: main
Are you sure you want to change the base?
Car plugin #225
Changes from 23 commits
a8b2976
48e7c3d
d910cb8
98ef6a4
6c552fb
5a1605f
3b2ff3c
f1116d7
c19612c
ec03162
b674ac4
ab58fc5
4235df6
37bf5ec
9b7d10c
5285325
a9a0d9a
558a47b
c08cd5f
161a1a3
97475c2
6ecf141
b65dfae
fb0772b
d3c313b
d6cbb96
2fbb658
e916cb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| node_modules | ||
| dist | ||
| .env | ||
| *.log |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing devDependencies for tooling 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| "keywords": [], | ||||||||||||||||||||||||||||||||
| "author": "", | ||||||||||||||||||||||||||||||||
| "license": "ISC", | ||||||||||||||||||||||||||||||||
| "dependencies": { | ||||||||||||||||||||||||||||||||
| "erxes-api-shared": "workspace:^" | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| "devDependencies": {} | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
Nx will warn and skip the dependency. Define a 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| "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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
All other targets specify - "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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid Using -const resolvers: any = {
+import { IResolvers } from '@graphql-tools/utils'; // or your preferred typings
+const resolvers: IResolvers = {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| export default resolvers; | ||||||||||||||||||||||||||||||||||||||||||||||
| 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, | ||
| }; |
| 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, | ||
| }; |
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolver map key is wrong—will register a phantom type
Merge the object instead: export const customResolvers = {
Car: carResolver,
- categoryResolver,
+ ...categoryResolver,
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing commas generate invalid GraphQL SDL The comma is illegal in SDL and Apollo will fail to start. -${carTypes},
-${carCategoryTypes}
+${carTypes}
+${carCategoryTypes}Repeat for 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { types, queries, mutations }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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} | ||
| } | ||
| `; | ||
| }; |
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Update the type of |
||
| } | ||
|
|
||
| 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); | ||
| 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; | ||
| }, | ||
| }, | ||
| }); | ||
|
|
| 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; | ||
| } |
| 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; | ||||||
|
||||||
| code: String; | ||||||
| parentId: String; | ||||||
| description: String; | ||||||
| image: IAttachment; | ||||||
| secondaryImages: [IAttachment]; | ||||||
|
||||||
| secondaryImages: [IAttachment]; | |
| secondaryImages: IAttachment[]; |
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
| 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', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Wagon: 'wagon', | |
| WAGON: 'wagon', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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.
Uh oh!
There was an error while loading. Please reload this page.