-
Notifications
You must be signed in to change notification settings - Fork 4
Task to operation #236
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?
Task to operation #236
Changes from all commits
9a243ee
1369139
c57ba79
782a0f4
53287f8
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,4 @@ | ||
| node_modules | ||
| dist | ||
| .env | ||
| *.log |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "name": "operation_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" | ||
| }, | ||
| "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": "operation_api", | ||
| "$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
| "sourceRoot": "backend/plugins/operation_api/src", | ||
| "projectType": "application", | ||
| "tags": [], | ||
| "targets": { | ||
| "build": { | ||
| "executor": "nx:run-commands", | ||
| "cache": true, | ||
| "options": { | ||
| "cwd": "backend/plugins/operation_api", | ||
| "commands": [ | ||
| "pnpm build" | ||
| ] | ||
| }, | ||
| "dependsOn": [ | ||
| "^build", | ||
| "build:packageJson" | ||
| ] | ||
| }, | ||
| "build:packageJson": { | ||
| "executor": "@nx/js:tsc", | ||
| "options": { | ||
| "main": "backend/plugins/operation_api/dist/src/main.js", | ||
| "tsConfig": "backend/plugins/operation_api/tsconfig.build.json", | ||
| "outputPath": "backend/plugins/operation_api/dist", | ||
| "updateBuildableProjectDepsInPackageJson": true, | ||
| "buildableProjectDepsInPackageJsonType": "dependencies" | ||
| } | ||
| }, | ||
| "start": { | ||
| "executor": "nx:run-commands", | ||
| "dependsOn": [ | ||
| "typecheck", | ||
| "build" | ||
| ], | ||
| "options": { | ||
| "cwd": "backend/plugins/operation_api", | ||
| "command": "NODE_ENV=development node dist/src/main.js" | ||
| } | ||
| }, | ||
| "serve": { | ||
| "executor": "nx:run-commands", | ||
| "options": { | ||
| "cwd": "backend/plugins/operation_api", | ||
| "command": "NODE_ENV=development pnpm dev" | ||
| } | ||
| }, | ||
| "docker-build": { | ||
| "dependsOn": [ | ||
| "build" | ||
| ], | ||
| "command": "docker build -f backend/plugins/operation_api/Dockerfile . -t erxes/erxes-next-operation_api" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| import { apolloCustomScalars } from 'erxes-api-shared/utils'; | ||||||
| import { mutations } from './mutations'; | ||||||
| import { queries } from './queries'; | ||||||
| import { customResolvers } from './resolvers'; | ||||||
|
|
||||||
| const resolvers: any = { | ||||||
|
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. Consider adding an explicit type for resolvers instead of using 'any' to improve type safety.
Suggested change
|
||||||
| Mutation: { | ||||||
| ...mutations, | ||||||
| }, | ||||||
| Query: { | ||||||
| ...queries, | ||||||
| }, | ||||||
| ...apolloCustomScalars, | ||||||
| ...customResolvers, | ||||||
| }; | ||||||
|
|
||||||
| export default resolvers; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { mutations as taskMutations } from '~/modules/tasks/graphql/resolvers/mutations'; | ||
|
|
||
| export const mutations = { | ||
| ...taskMutations, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { queries as taskQueries } from '~/modules/tasks/graphql/resolvers/queries'; | ||
|
|
||
| export const queries = { | ||
| ...taskQueries, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import taskResolvers from '~/modules/tasks/graphql/resolvers/customResolvers'; | ||
|
|
||
| export const customResolvers = { | ||
| ...taskResolvers, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| export const TypeExtensions = ` | ||
| extend type User @key(fields: "_id") { | ||
| _id: String @external | ||
| } | ||
|
|
||
| extend type Branch @key(fields: "_id") { | ||
| _id: String @external | ||
| } | ||
|
|
||
| extend type Department @key(fields: "_id") { | ||
| _id: String @external | ||
| } | ||
|
|
||
| extend type Company @key(fields: "_id") { | ||
| _id: String @external | ||
| } | ||
|
|
||
| extend type Customer @key(fields: "_id") { | ||
| _id: String @external | ||
| } | ||
|
|
||
| extend type Tag @key(fields: "_id") { | ||
| _id: String @external | ||
| } | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { TypeExtensions } from '~/apollo/schema/extension'; | ||
| import { | ||
| mutations as TasksMutations, | ||
| queries as TasksQueries, | ||
| types as TasksTypes, | ||
| } from '~/modules/tasks/graphql/schemas'; | ||
|
|
||
| export const types = ` | ||
| ${TypeExtensions} | ||
| ${TasksTypes} | ||
| `; | ||
|
|
||
| export const queries = ` | ||
| ${TasksQueries} | ||
| `; | ||
|
|
||
| export const mutations = ` | ||
| ${TasksMutations} | ||
| `; | ||
|
|
||
| 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,40 @@ | ||||||||
| import { IMainContext } from 'erxes-api-shared/core-types'; | ||||||||
| import { createGenerateModels } from 'erxes-api-shared/utils'; | ||||||||
|
|
||||||||
| import mongoose from 'mongoose'; | ||||||||
|
|
||||||||
| import { ITaskModel } from '@/tasks/db/models/Tasks'; | ||||||||
|
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. Fix inconsistent import path for Tasks model. The import path for ITaskModel uses a different pattern ( -import { ITaskModel } from '@/tasks/db/models/Tasks';
+import { ITaskModel } from '~/modules/tasks/db/models/Tasks';📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| import { IBoardModel } from '~/modules/tasks/db/models/Boards'; | ||||||||
| import { | ||||||||
| IChecklistItemModel, | ||||||||
| IChecklistModel, | ||||||||
| } from '~/modules/tasks/db/models/Checklists'; | ||||||||
| import { IPipelineLabelModel } from '~/modules/tasks/db/models/Labels'; | ||||||||
| import { IPipelineModel } from '~/modules/tasks/db/models/Pipelines'; | ||||||||
| import { IStageModel } from '~/modules/tasks/db/models/Stages'; | ||||||||
| import { loadTaskClasses } from '~/modules/tasks/resolver'; | ||||||||
|
|
||||||||
| export interface IModels { | ||||||||
| // TASK MODULE | ||||||||
| Boards: IBoardModel; | ||||||||
| Pipelines: IPipelineModel; | ||||||||
| Stages: IStageModel; | ||||||||
| Tasks: ITaskModel; | ||||||||
| Checklists: IChecklistModel; | ||||||||
| ChecklistItems: IChecklistItemModel; | ||||||||
| PipelineLabels: IPipelineLabelModel; | ||||||||
| } | ||||||||
|
|
||||||||
| export interface IContext extends IMainContext { | ||||||||
| models: IModels; | ||||||||
| } | ||||||||
|
|
||||||||
| export const loadClasses = (db: mongoose.Connection): IModels => { | ||||||||
| const models = {} as IModels; | ||||||||
|
|
||||||||
| loadTaskClasses(models, db); | ||||||||
|
|
||||||||
| 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: 'operation', | ||
| 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,15 @@ | ||
| import { Document } from 'mongoose'; | ||
| import { IPipeline } from '~/modules/tasks/@types/pipelines'; | ||
|
|
||
| export interface IBoard { | ||
| name?: string; | ||
| userId?: string; | ||
| } | ||
|
|
||
| export interface IBoardDocument extends IBoard, Document { | ||
| _id: string; | ||
|
|
||
| type: string; | ||
| pipelines?: IPipeline[]; | ||
| order?: number; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { Document } from 'mongoose'; | ||
|
|
||
| export interface IChecklist { | ||
| contentType: string; | ||
| contentTypeId: string; | ||
| title: string; | ||
| } | ||
|
|
||
| export interface IChecklistDocument extends IChecklist, Document { | ||
| _id: string; | ||
| createdUserId: string; | ||
| createdDate: Date; | ||
| } | ||
|
|
||
| export interface IChecklistItem { | ||
| checklistId: string; | ||
| content: string; | ||
| isChecked: boolean; | ||
| } | ||
|
|
||
| export interface IChecklistItemDocument extends IChecklistItem, Document { | ||
| _id: string; | ||
| order: number; | ||
| createdUserId: string; | ||
| createdDate: Date; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Document } from 'mongoose'; | ||
|
|
||
| export interface IPipelineLabel { | ||
| name: string; | ||
| colorCode: string; | ||
| pipelineId: string; | ||
| createdBy?: string; | ||
| createdAt?: Date; | ||
| } | ||
|
|
||
| export interface IPipelineLabelDocument extends IPipelineLabel, Document { | ||
| _id: string; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { Document } from 'mongoose'; | ||
|
|
||
| export interface IPipeline { | ||
| name?: string; | ||
| boardId: string; | ||
| status?: string; | ||
| visibility?: string; | ||
| memberIds?: string[]; | ||
| bgColor?: string; | ||
| watchedUserIds?: string[]; | ||
| startDate?: Date; | ||
| endDate?: Date; | ||
| metric?: string; | ||
| hackScoringType?: string; | ||
| templateId?: string; | ||
| isCheckDate?: boolean; | ||
| isCheckUser?: boolean; | ||
| isCheckDepartment?: boolean; | ||
| excludeCheckUserIds?: string[]; | ||
| numberConfig?: string; | ||
| numberSize?: string; | ||
| nameConfig?: string; | ||
| lastNum?: string; | ||
| departmentIds?: string[]; | ||
| branchIds?: string[]; | ||
| tagId?: string; | ||
| userId?: string; | ||
| } | ||
|
|
||
| export interface IPipelineDocument extends IPipeline, Document { | ||
| _id: string; | ||
|
|
||
| createdAt?: Date; | ||
| order?: number; | ||
| type: string; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { Document } from 'mongoose'; | ||
|
|
||
| export interface IStage { | ||
| name?: string; | ||
| probability?: string; | ||
| pipelineId: string; | ||
| visibility?: string; | ||
| memberIds?: string[]; | ||
| canMoveMemberIds?: string[]; | ||
| canEditMemberIds?: string[]; | ||
| departmentIds?: string[]; | ||
| formId?: string; | ||
| status?: string; | ||
| code?: string; | ||
| age?: number; | ||
| defaultTick?: boolean; | ||
| userId?: string; | ||
| } | ||
|
|
||
| export interface IStageDocument extends IStage, Document { | ||
| _id: string; | ||
|
|
||
| createdAt?: Date; | ||
| order?: number; | ||
| type: string; | ||
| } |
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
Add missing package metadata and consider additional dependencies.
The package.json is missing several important metadata fields and might need additional dependencies for the functionality described in the AI summary.
{ "name": "operation_api", "version": "1.0.0", - "description": "", + "description": "Backend API plugin for operations and task management", "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" + "start": "node -r tsconfig-paths/register dist/src/main.js", + "clean": "rm -rf dist" }, "keywords": [], - "author": "", + "author": "Your Organization", "license": "ISC",📝 Committable suggestion
🤖 Prompt for AI Agents