bmd-extension 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +14 -0
- package/.vscode/settings.json +1 -0
- package/CHANGELOG.md +9 -0
- package/DEPLOY.md +4 -0
- package/README.md +17 -0
- package/README_PRIVATE.md +1 -0
- package/build.sh +5 -0
- package/logo.png +0 -0
- package/media/dark/add.svg +40 -0
- package/media/dark/block.svg +1 -0
- package/media/dark/checklist-1.svg +1 -0
- package/media/dark/checklist.svg +1 -0
- package/media/dark/control.svg +1 -0
- package/media/dark/create.svg +1 -0
- package/media/dark/delete-1.svg +1 -0
- package/media/dark/delete.svg +1 -0
- package/media/dark/deploy-1.svg +2 -0
- package/media/dark/deploy.svg +2 -0
- package/media/dark/documents.svg +66 -0
- package/media/dark/earth.svg +68 -0
- package/media/dark/exe.svg +15 -0
- package/media/dark/export.svg +1 -0
- package/media/dark/function.svg +1 -0
- package/media/dark/game-controller.svg +77 -0
- package/media/dark/get.svg +1 -0
- package/media/dark/id-card.svg +59 -0
- package/media/dark/identity.svg +81 -0
- package/media/dark/import.svg +1 -0
- package/media/dark/information.svg +1 -0
- package/media/dark/interface.svg +1 -0
- package/media/dark/layout.svg +41 -0
- package/media/dark/leaf.svg +54 -0
- package/media/dark/list.svg +13 -0
- package/media/dark/logo.svg +249 -0
- package/media/dark/mockup.svg +1 -0
- package/media/dark/needle.svg +1 -0
- package/media/dark/pass.svg +46 -0
- package/media/dark/plus.svg +1 -0
- package/media/dark/post.svg +1 -0
- package/media/dark/quit.svg +1 -0
- package/media/dark/rocket.svg +28 -0
- package/media/dark/service.svg +1 -0
- package/media/dark/settings.svg +98 -0
- package/media/dark/social.svg +1 -0
- package/media/dark/spaceship-1.svg +1 -0
- package/media/dark/spaceship-2.svg +1 -0
- package/media/dark/spaceship.svg +1 -0
- package/media/dark/support.svg +88 -0
- package/media/dark/transfer.svg +1 -0
- package/media/dark/transform.svg +92 -0
- package/media/dark/update.svg +45 -0
- package/media/dark/upload-1.svg +1 -0
- package/media/dark/upload.svg +41 -0
- package/media/dark/vaccine.svg +1 -0
- package/media/dark/vr-gaming.svg +1 -0
- package/media/light/add.svg +40 -0
- package/media/light/block.svg +1 -0
- package/media/light/checklist-1.svg +1 -0
- package/media/light/checklist.svg +1 -0
- package/media/light/control.svg +1 -0
- package/media/light/create.svg +1 -0
- package/media/light/delete-1.svg +1 -0
- package/media/light/delete.svg +1 -0
- package/media/light/deploy-1.svg +2 -0
- package/media/light/deploy.svg +2 -0
- package/media/light/documents.svg +66 -0
- package/media/light/earth.svg +68 -0
- package/media/light/exe.svg +15 -0
- package/media/light/export.svg +1 -0
- package/media/light/function.svg +1 -0
- package/media/light/game-controller.svg +77 -0
- package/media/light/get.svg +1 -0
- package/media/light/id-card.svg +59 -0
- package/media/light/identity.svg +81 -0
- package/media/light/import.svg +1 -0
- package/media/light/information.svg +1 -0
- package/media/light/interface.svg +1 -0
- package/media/light/layout.svg +41 -0
- package/media/light/leaf.svg +54 -0
- package/media/light/list.svg +13 -0
- package/media/light/logo.svg +249 -0
- package/media/light/mockup.svg +1 -0
- package/media/light/needle.svg +1 -0
- package/media/light/pass.svg +46 -0
- package/media/light/plus.svg +1 -0
- package/media/light/post.svg +1 -0
- package/media/light/quit.svg +1 -0
- package/media/light/rocket.svg +28 -0
- package/media/light/service.svg +1 -0
- package/media/light/settings.svg +98 -0
- package/media/light/social.svg +1 -0
- package/media/light/spaceship-1.svg +1 -0
- package/media/light/spaceship-2.svg +1 -0
- package/media/light/spaceship.svg +1 -0
- package/media/light/support.svg +88 -0
- package/media/light/transfer.svg +1 -0
- package/media/light/transform.svg +92 -0
- package/media/light/update.svg +45 -0
- package/media/light/upload-1.svg +1 -0
- package/media/light/upload.svg +41 -0
- package/media/light/vaccine.svg +1 -0
- package/media/light/vr-gaming.svg +1 -0
- package/package-lock.json +6430 -0
- package/package.json +540 -0
- package/snippets-tsr.json +512 -0
- package/snippets.json +761 -0
- package/src/API.ts +14 -0
- package/src/FsProvider.ts +105 -0
- package/src/Request.ts +24 -0
- package/src/assets/api/api.txt +27 -0
- package/src/assets/configuration/AdminConfigurationController.ts.txt +72 -0
- package/src/assets/configuration/Configuration.ts.txt +37 -0
- package/src/assets/configuration/ConfigurationService.ts.txt +26 -0
- package/src/assets/contentDefine/AdminContentDefineController.ts.txt +91 -0
- package/src/assets/contentDefine/ContentDefine.ts.txt +45 -0
- package/src/assets/contentDefine/ContentDefineService.ts.txt +19 -0
- package/src/assets/contentDefine/CustomerContentDefineController.ts.txt +34 -0
- package/src/assets/controller/controller.txt +46 -0
- package/src/assets/controller/controllerResource.txt +103 -0
- package/src/assets/entity/entity.txt +22 -0
- package/src/assets/entity-request/entity-request.txt +18 -0
- package/src/assets/init/.env.example.txt +37 -0
- package/src/assets/init/.env.production.txt +37 -0
- package/src/assets/init/.gitignore.txt +8 -0
- package/src/assets/init/config.ts.txt +55 -0
- package/src/assets/init/deploy.sh.txt +46 -0
- package/src/assets/init/package-lock.json.txt +4184 -0
- package/src/assets/init/package.json.txt +79 -0
- package/src/assets/init/src/Server.ts.txt +167 -0
- package/src/assets/init/src/controllers/admin/AuthController.ts.txt +96 -0
- package/src/assets/init/src/controllers/admin/CustomerController.ts.txt +107 -0
- package/src/assets/init/src/controllers/admin/RoleController.ts.txt +143 -0
- package/src/assets/init/src/controllers/admin/StaffController.ts.txt +192 -0
- package/src/assets/init/src/controllers/customer/AuthController.ts.txt +170 -0
- package/src/assets/init/src/controllers/customer/CustomerController.ts.txt +32 -0
- package/src/assets/init/src/core/entity/CoreEntity.ts.txt +70 -0
- package/src/assets/init/src/core/services/CoreService.ts.txt +21 -0
- package/src/assets/init/src/entity/Customer.ts.txt +68 -0
- package/src/assets/init/src/entity/Permission.ts.txt +29 -0
- package/src/assets/init/src/entity/Role.ts.txt +36 -0
- package/src/assets/init/src/entity/Staff.ts.txt +54 -0
- package/src/assets/init/src/entity-request/CustomerInsert.ts.txt +42 -0
- package/src/assets/init/src/entity-request/CustomerUpdate.ts.txt +40 -0
- package/src/assets/init/src/entity-request/PermissionImport.ts.txt +12 -0
- package/src/assets/init/src/entity-request/StaffUpdate.ts.txt +33 -0
- package/src/assets/init/src/index.ts.txt +13 -0
- package/src/assets/init/src/middleware/auth/Verification.ts.txt +16 -0
- package/src/assets/init/src/middleware/auth/VerificationJWT.ts.txt +16 -0
- package/src/assets/init/src/middleware/auth/strategy/AuthStrategy.ts.txt +5 -0
- package/src/assets/init/src/middleware/auth/strategy/JWT.ts.txt +147 -0
- package/src/assets/init/src/middleware/error/handleError.ts.txt +22 -0
- package/src/assets/init/src/middleware/error/handleNotFound.ts.txt +7 -0
- package/src/assets/init/src/middleware/response/CustomSendResponse.ts.txt +35 -0
- package/src/assets/init/src/middleware/response/responseAPI.ts.txt +76 -0
- package/src/assets/init/src/middleware/validator/Validator.ts.txt +103 -0
- package/src/assets/init/src/services/CustomerService.ts.txt +79 -0
- package/src/assets/init/src/services/InitService.ts.txt +11 -0
- package/src/assets/init/src/services/MailService.ts.txt +271 -0
- package/src/assets/init/src/services/RoleService.ts.txt +66 -0
- package/src/assets/init/src/services/StaffService.ts.txt +104 -0
- package/src/assets/init/src/ssl/certificate-ca.crt +0 -0
- package/src/assets/init/src/ssl/certificate.crt +0 -0
- package/src/assets/init/src/ssl/private.key +0 -0
- package/src/assets/init/src/types/express.d.ts.txt +97 -0
- package/src/assets/init/src/util/expo.ts.txt +53 -0
- package/src/assets/init/src/util/helper.ts.txt +321 -0
- package/src/assets/init/src/util/language.ts.txt +8 -0
- package/src/assets/init/src/util/logger.ts.txt +47 -0
- package/src/assets/init/src/util/mailer.ts.txt +32 -0
- package/src/assets/init/src/util/password.ts.txt +13 -0
- package/src/assets/init/tsconfig.json.txt +26 -0
- package/src/assets/service/service.txt +34 -0
- package/src/constant.ts +83 -0
- package/src/extension.ts +459 -0
- package/src/provider/codeAction/controller/addPathParams.ts +65 -0
- package/src/provider/codeAction/controller/addTokenParam.ts +43 -0
- package/src/provider/codeAction/controller/addValidation.ts +47 -0
- package/src/provider/codeAction/controller/codeAction.ts +34 -0
- package/src/provider/codeAction/controller/util.ts +48 -0
- package/src/provider/codeAction/entity/codeAction.ts +48 -0
- package/src/provider/codeAction/entity/handleBuilder.ts +87 -0
- package/src/provider/codeAction/entity/handleFunction.ts +487 -0
- package/src/provider/codeAction/entity/handleProperty.ts +32 -0
- package/src/provider/codeAction/entity/handleRelation.ts +72 -0
- package/src/provider/codeAction/entity/helper.ts +132 -0
- package/src/provider/codeAction/entity-request/codeAction.ts +178 -0
- package/src/provider/codeAction/enum/codeAction.ts +95 -0
- package/src/provider/codeAction/service/codeAction.ts +232 -0
- package/src/provider/completion/CompletionProvider.ts +108 -0
- package/src/provider/errorChecking/checkHeaderToken.ts +60 -0
- package/src/provider/errorChecking/checkPathParam.ts +64 -0
- package/src/provider/errorChecking/checkRequired.ts +56 -0
- package/src/provider/errorChecking/errorChecking.ts +35 -0
- package/src/provider/errorChecking/util.ts +56 -0
- package/src/provider/treeDataProvider/Dependency.ts +26 -0
- package/src/provider/treeDataProvider/TreeProviderCommand.ts +60 -0
- package/src/provider/treeDataProvider/TreeProviderProject.ts +65 -0
- package/src/provider/treeDataProvider/api/createApi.ts +106 -0
- package/src/provider/treeDataProvider/controller/command/createController.ts +99 -0
- package/src/provider/treeDataProvider/controller/command/handleMethod.ts +363 -0
- package/src/provider/treeDataProvider/controller/treeData.ts +81 -0
- package/src/provider/treeDataProvider/deploy/command/handleDeploy.ts +70 -0
- package/src/provider/treeDataProvider/deploy/treeData.ts +21 -0
- package/src/provider/treeDataProvider/entity/command/addProperty.ts +144 -0
- package/src/provider/treeDataProvider/entity/command/addRelation.ts +125 -0
- package/src/provider/treeDataProvider/entity/command/createEntity.ts +53 -0
- package/src/provider/treeDataProvider/entity/command/createEntityRequest.ts +65 -0
- package/src/provider/treeDataProvider/entity/command/exportInterface.ts +130 -0
- package/src/provider/treeDataProvider/entity/treeData.ts +49 -0
- package/src/provider/treeDataProvider/module/command/configuration.ts +34 -0
- package/src/provider/treeDataProvider/module/command/contentDefine.ts +36 -0
- package/src/provider/treeDataProvider/module/command/initProject.ts +155 -0
- package/src/provider/treeDataProvider/module/treeData.ts +28 -0
- package/src/provider/treeDataProvider/project/command/addEnum.ts +0 -0
- package/src/provider/treeDataProvider/project/command/addProjectName.ts +23 -0
- package/src/provider/treeDataProvider/project/command/getProjectDetails.ts +284 -0
- package/src/provider/treeDataProvider/project/treeData.ts +28 -0
- package/src/provider/treeDataProvider/service/command/createService.ts +70 -0
- package/src/provider/treeDataProvider/service/command/handleConstructor.ts +134 -0
- package/src/provider/treeDataProvider/service/treeData.ts +25 -0
- package/src/types/project.d.ts +7 -0
- package/src/util.ts +145 -0
- package/src/utils/Password.ts +19 -0
- package/tsconfig.json +18 -0
- package/tslint.json +15 -0
- package/vsc-extension-quickstart.md +42 -0
package/src/extension.ts
ADDED
@@ -0,0 +1,459 @@
|
|
1
|
+
import * as vscode from 'vscode'
|
2
|
+
import { ControllerActionProvider } from './provider/codeAction/controller/codeAction';
|
3
|
+
import { ServiceActionProvider, ServiceAction } from './provider/codeAction/service/codeAction';
|
4
|
+
import { EntityActionProvider } from './provider/codeAction/entity/codeAction';
|
5
|
+
import { EntityRequestActionProvider, EntityRequestAction } from './provider/codeAction/entity-request/codeAction';
|
6
|
+
import { EntityAction, BMDCommand, Deploy, ControllerAction, ConstructorFunction } from './constant';
|
7
|
+
import { insertBuilderRelation } from './provider/codeAction/entity/handleBuilder';
|
8
|
+
import { insertEntityFunction, insertQueryBuilder, insertFindOneOrThrow, insertPropertiesToQuery } from './provider/codeAction/entity/handleFunction';
|
9
|
+
import { addConfiguration } from './provider/treeDataProvider/module/command/configuration';
|
10
|
+
import { insertControllerFunc } from './provider/treeDataProvider/controller/command/handleMethod';
|
11
|
+
import { insertPrivateService } from './provider/treeDataProvider/service/command/handleConstructor';
|
12
|
+
import { handleDeploy, runDev, runStart } from './provider/treeDataProvider/deploy/command/handleDeploy';
|
13
|
+
import { createControllerResource, createControllerNormal } from './provider/treeDataProvider/controller/command/createController';
|
14
|
+
import { createService } from './provider/treeDataProvider/service/command/createService';
|
15
|
+
import { createEntity } from './provider/treeDataProvider/entity/command/createEntity';
|
16
|
+
import { createEntityRequest } from './provider/treeDataProvider/entity/command/createEntityRequest';
|
17
|
+
import { CompletionPropertyProvider, CompletionEntityProvider, CompletionQueryProvider } from './provider/completion/CompletionProvider';
|
18
|
+
import { updateDiagnostics } from './provider/errorChecking/errorChecking';
|
19
|
+
import { TreeProviderCommand } from './provider/treeDataProvider/TreeProviderCommand';
|
20
|
+
import { addProperty } from './provider/treeDataProvider/entity/command/addProperty';
|
21
|
+
import { insertEntityAction } from './provider/treeDataProvider/entity/command/addRelation';
|
22
|
+
import { createInterface } from './provider/treeDataProvider/entity/command/exportInterface';
|
23
|
+
import { initProject } from './provider/treeDataProvider/module/command/initProject';
|
24
|
+
import { addContentDefine } from './provider/treeDataProvider/module/command/contentDefine';
|
25
|
+
import { handleAddPathParams } from './provider/codeAction/controller/addPathParams';
|
26
|
+
import { handleAddTokenParams } from './provider/codeAction/controller/addTokenParam';
|
27
|
+
import { handleAddValidation } from './provider/codeAction/controller/addValidation';
|
28
|
+
import { TreeProviderProject } from './provider/treeDataProvider/TreeProviderProject';
|
29
|
+
import { addProjectName } from './provider/treeDataProvider/project/command/addProjectName';
|
30
|
+
import { getProjectDetails } from './provider/treeDataProvider/project/command/getProjectDetails';
|
31
|
+
import { addEnum, EnumActionProvider } from './provider/codeAction/enum/codeAction';
|
32
|
+
import { createApi } from './provider/treeDataProvider/api/createApi';
|
33
|
+
|
34
|
+
let deploySB: vscode.StatusBarItem;
|
35
|
+
let devSB: vscode.StatusBarItem;
|
36
|
+
let runStartSB: vscode.StatusBarItem
|
37
|
+
const serviceProvider = new ServiceActionProvider()
|
38
|
+
const entityRequestProvider = new EntityRequestActionProvider()
|
39
|
+
|
40
|
+
export function activate({ subscriptions }: vscode.ExtensionContext) {
|
41
|
+
// create a new status bar item that we can now manage
|
42
|
+
|
43
|
+
runStartSB = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 203);
|
44
|
+
runStartSB.text = 'RUN START';
|
45
|
+
runStartSB.command = Deploy.RunStart;
|
46
|
+
runStartSB.show();
|
47
|
+
|
48
|
+
//
|
49
|
+
devSB = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 202);
|
50
|
+
devSB.command = Deploy.RunDev;
|
51
|
+
devSB.text = 'RUN DEV'
|
52
|
+
devSB.show()
|
53
|
+
|
54
|
+
//
|
55
|
+
deploySB = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 201);
|
56
|
+
deploySB.command = Deploy.Deploy;
|
57
|
+
|
58
|
+
deploySB.text = 'DEPLOY V2'
|
59
|
+
deploySB.show()
|
60
|
+
//
|
61
|
+
|
62
|
+
|
63
|
+
/**
|
64
|
+
* *********************************************************
|
65
|
+
* TREE DATA
|
66
|
+
* *********************************************************
|
67
|
+
*/
|
68
|
+
|
69
|
+
//#region
|
70
|
+
const bmdCommand = new TreeProviderCommand(vscode.workspace.rootPath);
|
71
|
+
|
72
|
+
vscode.window.registerTreeDataProvider('bmdextension1', bmdCommand);
|
73
|
+
vscode.window.registerTreeDataProvider('bmdextension2', bmdCommand);
|
74
|
+
|
75
|
+
const bmdProject = new TreeProviderProject(vscode.workspace.rootPath)
|
76
|
+
vscode.window.registerTreeDataProvider('bmdprojects', bmdProject);
|
77
|
+
/**
|
78
|
+
* TREE DATA - ENTITY
|
79
|
+
*/
|
80
|
+
|
81
|
+
|
82
|
+
subscriptions.push(vscode.commands.registerCommand(
|
83
|
+
BMDCommand.GetProjectDetails, async (projectName) => await getProjectDetails(projectName, subscriptions)
|
84
|
+
));
|
85
|
+
|
86
|
+
subscriptions.push(vscode.commands.registerCommand(
|
87
|
+
BMDCommand.AddProjectName, async () => await addProjectName()
|
88
|
+
));
|
89
|
+
|
90
|
+
subscriptions.push(vscode.commands.registerCommand(
|
91
|
+
BMDCommand.CreateEntity, async (doc) => {
|
92
|
+
const fsPath = doc.fsPath
|
93
|
+
await createEntity(fsPath)
|
94
|
+
}
|
95
|
+
));
|
96
|
+
|
97
|
+
subscriptions.push(vscode.commands.registerCommand(
|
98
|
+
BMDCommand.CreateEntityRequest,
|
99
|
+
async (doc) => {
|
100
|
+
const fsPath = doc.fsPath
|
101
|
+
await createEntityRequest(fsPath)
|
102
|
+
}
|
103
|
+
));
|
104
|
+
|
105
|
+
subscriptions.push(vscode.commands.registerCommand(
|
106
|
+
EntityRequestAction.AddProperty,
|
107
|
+
async (doc) => entityRequestProvider.addProperty(doc)
|
108
|
+
));
|
109
|
+
|
110
|
+
subscriptions.push(vscode.commands.registerCommand(
|
111
|
+
EntityAction.AddProperty,
|
112
|
+
async (doc) => addProperty(doc)
|
113
|
+
));
|
114
|
+
|
115
|
+
subscriptions.push(vscode.commands.registerCommand(
|
116
|
+
EntityAction.OneToMany,
|
117
|
+
async (doc) => insertEntityAction(EntityAction.OneToMany, doc)
|
118
|
+
));
|
119
|
+
|
120
|
+
subscriptions.push(vscode.commands.registerCommand(
|
121
|
+
EntityAction.ManyToOne,
|
122
|
+
async (doc) => insertEntityAction(EntityAction.ManyToOne, doc)
|
123
|
+
));
|
124
|
+
|
125
|
+
subscriptions.push(vscode.commands.registerCommand(
|
126
|
+
EntityAction.ManyToMany,
|
127
|
+
async (doc) => insertEntityAction(EntityAction.ManyToMany, doc)
|
128
|
+
));
|
129
|
+
|
130
|
+
subscriptions.push(vscode.commands.registerCommand(
|
131
|
+
EntityAction.OneToOne,
|
132
|
+
async (doc) => insertEntityAction(EntityAction.OneToOne, doc)
|
133
|
+
));
|
134
|
+
|
135
|
+
subscriptions.push(vscode.commands.registerCommand(
|
136
|
+
EntityAction.ExportInterface,
|
137
|
+
async (doc, range) => createInterface(doc, range)
|
138
|
+
));
|
139
|
+
|
140
|
+
/**
|
141
|
+
* TREE DATA - CONTROLLER
|
142
|
+
*/
|
143
|
+
|
144
|
+
subscriptions.push(vscode.commands.registerCommand(
|
145
|
+
BMDCommand.CreateController,
|
146
|
+
async (doc) => {
|
147
|
+
const fsPath = doc.fsPath
|
148
|
+
await createControllerNormal(fsPath)
|
149
|
+
}
|
150
|
+
));
|
151
|
+
|
152
|
+
subscriptions.push(vscode.commands.registerCommand(
|
153
|
+
BMDCommand.CreateControllerResource,
|
154
|
+
async (doc) => {
|
155
|
+
const fsPath = doc.fsPath
|
156
|
+
await createControllerResource(fsPath)
|
157
|
+
}
|
158
|
+
));
|
159
|
+
|
160
|
+
subscriptions.push(vscode.commands.registerCommand(
|
161
|
+
ControllerAction.Get,
|
162
|
+
async (doc) => insertControllerFunc(ControllerAction.Get, doc)
|
163
|
+
));
|
164
|
+
|
165
|
+
subscriptions.push(vscode.commands.registerCommand(
|
166
|
+
ControllerAction.Post,
|
167
|
+
async (doc) => insertControllerFunc(ControllerAction.Post, doc)
|
168
|
+
));
|
169
|
+
|
170
|
+
subscriptions.push(vscode.commands.registerCommand(
|
171
|
+
ControllerAction.GetListPagination,
|
172
|
+
async (doc) => insertControllerFunc(ControllerAction.GetListPagination, doc)
|
173
|
+
));
|
174
|
+
|
175
|
+
subscriptions.push(vscode.commands.registerCommand(
|
176
|
+
ControllerAction.GetListAll,
|
177
|
+
async (doc) => insertControllerFunc(ControllerAction.GetListAll, doc)
|
178
|
+
));
|
179
|
+
|
180
|
+
subscriptions.push(vscode.commands.registerCommand(
|
181
|
+
ControllerAction.CreateItem,
|
182
|
+
async (doc) => insertControllerFunc(ControllerAction.CreateItem, doc)
|
183
|
+
));
|
184
|
+
|
185
|
+
subscriptions.push(vscode.commands.registerCommand(
|
186
|
+
ControllerAction.CreateItemEntityRequest,
|
187
|
+
async (doc) => insertControllerFunc(ControllerAction.CreateItemEntityRequest, doc)
|
188
|
+
));
|
189
|
+
|
190
|
+
subscriptions.push(vscode.commands.registerCommand(
|
191
|
+
ControllerAction.UpdateItem,
|
192
|
+
async (doc) => insertControllerFunc(ControllerAction.UpdateItem, doc)
|
193
|
+
));
|
194
|
+
|
195
|
+
subscriptions.push(vscode.commands.registerCommand(
|
196
|
+
ControllerAction.DeleteItemByRemove,
|
197
|
+
async (doc) => insertControllerFunc(ControllerAction.DeleteItemByRemove, doc)
|
198
|
+
));
|
199
|
+
|
200
|
+
subscriptions.push(vscode.commands.registerCommand(
|
201
|
+
ControllerAction.DeleteItemByBlock,
|
202
|
+
async (doc) => insertControllerFunc(ControllerAction.DeleteItemByBlock, doc)
|
203
|
+
));
|
204
|
+
|
205
|
+
subscriptions.push(vscode.commands.registerCommand(
|
206
|
+
ControllerAction.Upload,
|
207
|
+
async (doc) => insertControllerFunc(ControllerAction.Upload, doc)
|
208
|
+
));
|
209
|
+
|
210
|
+
subscriptions.push(vscode.commands.registerCommand(
|
211
|
+
ControllerAction.UploadResize,
|
212
|
+
async (doc) => insertControllerFunc(ControllerAction.UploadResize, doc)
|
213
|
+
));
|
214
|
+
|
215
|
+
/**
|
216
|
+
* TREE DATA - CREATE API
|
217
|
+
*/
|
218
|
+
|
219
|
+
subscriptions.push(vscode.commands.registerCommand(
|
220
|
+
BMDCommand.CreateApi,
|
221
|
+
async (doc) => {
|
222
|
+
const fsPath = doc.fsPath
|
223
|
+
await createApi(fsPath)
|
224
|
+
}
|
225
|
+
));
|
226
|
+
|
227
|
+
/**
|
228
|
+
* TREE DATA - SERVICE
|
229
|
+
*/
|
230
|
+
|
231
|
+
subscriptions.push(vscode.commands.registerCommand(
|
232
|
+
BMDCommand.CreateService,
|
233
|
+
async (doc) => {
|
234
|
+
const fsPath = doc.fsPath
|
235
|
+
await createService(fsPath)
|
236
|
+
}
|
237
|
+
));
|
238
|
+
|
239
|
+
subscriptions.push(vscode.commands.registerCommand(
|
240
|
+
ConstructorFunction.PrivateService,
|
241
|
+
async (doc) => await insertPrivateService(ConstructorFunction.PrivateService, doc)
|
242
|
+
));
|
243
|
+
|
244
|
+
/**
|
245
|
+
* TREE DATA - MODULE
|
246
|
+
*/
|
247
|
+
|
248
|
+
subscriptions.push(vscode.commands.registerCommand(
|
249
|
+
BMDCommand.Init,
|
250
|
+
async () => await initProject()
|
251
|
+
));
|
252
|
+
|
253
|
+
subscriptions.push(vscode.commands.registerCommand(
|
254
|
+
BMDCommand.AddModuleContentDefine,
|
255
|
+
async () => await addContentDefine()
|
256
|
+
));
|
257
|
+
|
258
|
+
subscriptions.push(vscode.commands.registerCommand(
|
259
|
+
BMDCommand.AddModuleConfiguration,
|
260
|
+
async () => await addConfiguration()
|
261
|
+
));
|
262
|
+
|
263
|
+
/**
|
264
|
+
* TREE DATA - DEPLOY
|
265
|
+
*/
|
266
|
+
|
267
|
+
console.log('register Deploy.Deploy command');
|
268
|
+
|
269
|
+
subscriptions.push(vscode.commands.registerCommand(
|
270
|
+
Deploy.Deploy,
|
271
|
+
() => handleDeploy()
|
272
|
+
));
|
273
|
+
|
274
|
+
|
275
|
+
subscriptions.push(vscode.commands.registerCommand(
|
276
|
+
Deploy.RunDev,
|
277
|
+
() => runDev()
|
278
|
+
));
|
279
|
+
|
280
|
+
subscriptions.push(vscode.commands.registerCommand(
|
281
|
+
Deploy.RunStart,
|
282
|
+
() => runStart()
|
283
|
+
));
|
284
|
+
|
285
|
+
//#endregion
|
286
|
+
|
287
|
+
|
288
|
+
/**
|
289
|
+
* *********************************************************
|
290
|
+
* ERROR CHECKING
|
291
|
+
* *********************************************************
|
292
|
+
*/
|
293
|
+
//#region
|
294
|
+
const collection = vscode.languages.createDiagnosticCollection('checkParamsValidator');
|
295
|
+
|
296
|
+
if (vscode.window.activeTextEditor) {
|
297
|
+
updateDiagnostics(vscode.window.activeTextEditor.document, collection);
|
298
|
+
}
|
299
|
+
|
300
|
+
subscriptions.push(vscode.workspace.onDidChangeTextDocument(event => {
|
301
|
+
if (event) updateDiagnostics(event.document, collection);
|
302
|
+
}))
|
303
|
+
|
304
|
+
subscriptions.push(vscode.window.onDidChangeActiveTextEditor(editor => {
|
305
|
+
if (editor) updateDiagnostics(editor.document, collection);
|
306
|
+
}));
|
307
|
+
//#endregion
|
308
|
+
|
309
|
+
|
310
|
+
/**
|
311
|
+
* *********************************************************
|
312
|
+
* CODE ACTION
|
313
|
+
* *********************************************************
|
314
|
+
*/
|
315
|
+
//#region
|
316
|
+
/**
|
317
|
+
* CODE ACTION - CONTROLLER
|
318
|
+
*/
|
319
|
+
|
320
|
+
subscriptions.push(vscode.languages.registerCodeActionsProvider(
|
321
|
+
'typescript',
|
322
|
+
new ControllerActionProvider(),
|
323
|
+
{ providedCodeActionKinds: ControllerActionProvider.providedCodeActionKinds }
|
324
|
+
));
|
325
|
+
|
326
|
+
subscriptions.push(vscode.commands.registerCommand(
|
327
|
+
ControllerAction.AddPathParams,
|
328
|
+
async (doc, range) => handleAddPathParams(doc, range)
|
329
|
+
));
|
330
|
+
|
331
|
+
subscriptions.push(vscode.commands.registerCommand(
|
332
|
+
ControllerAction.AddTokenParam,
|
333
|
+
async (doc, range) => handleAddTokenParams(doc, range)
|
334
|
+
));
|
335
|
+
|
336
|
+
subscriptions.push(vscode.commands.registerCommand(
|
337
|
+
ControllerAction.AddValidation,
|
338
|
+
async (doc, range) => handleAddValidation(doc, range)
|
339
|
+
));
|
340
|
+
|
341
|
+
/**
|
342
|
+
* CODE ACTION - SERVICE
|
343
|
+
*/
|
344
|
+
|
345
|
+
subscriptions.push(
|
346
|
+
vscode.languages.registerCodeActionsProvider(
|
347
|
+
'typescript',
|
348
|
+
new ServiceActionProvider(),
|
349
|
+
{ providedCodeActionKinds: ServiceActionProvider.providedCodeActionKinds }
|
350
|
+
)
|
351
|
+
);
|
352
|
+
|
353
|
+
subscriptions.push(vscode.commands.registerCommand(
|
354
|
+
ServiceAction.GetLast30,
|
355
|
+
async (doc) => serviceProvider.insertServiceFunc(ServiceAction.GetLast30, doc)
|
356
|
+
));
|
357
|
+
|
358
|
+
subscriptions.push(vscode.commands.registerCommand(
|
359
|
+
ServiceAction.GetSum,
|
360
|
+
async (doc) => await serviceProvider.insertServiceFunc(ServiceAction.GetSum, doc)
|
361
|
+
));
|
362
|
+
|
363
|
+
subscriptions.push(vscode.commands.registerCommand(
|
364
|
+
ServiceAction.GetManyAndCount,
|
365
|
+
async (doc) => serviceProvider.insertServiceFunc(ServiceAction.GetManyAndCount, doc)
|
366
|
+
));
|
367
|
+
|
368
|
+
/**
|
369
|
+
* CODE ACTION - ENTITY
|
370
|
+
*/
|
371
|
+
|
372
|
+
subscriptions.push(
|
373
|
+
vscode.languages.registerCodeActionsProvider(
|
374
|
+
'typescript',
|
375
|
+
new EntityActionProvider(),
|
376
|
+
{ providedCodeActionKinds: EntityActionProvider.providedCodeActionKinds }
|
377
|
+
)
|
378
|
+
);
|
379
|
+
|
380
|
+
subscriptions.push(vscode.commands.registerCommand(
|
381
|
+
EntityAction.AddRelation,
|
382
|
+
async (doc, range) => insertEntityFunction(EntityAction.AddRelation, doc, range)
|
383
|
+
));
|
384
|
+
|
385
|
+
subscriptions.push(vscode.commands.registerCommand(
|
386
|
+
EntityAction.CreateQueryBuilderPagination,
|
387
|
+
async (doc, range) => insertQueryBuilder(EntityAction.CreateQueryBuilderPagination, doc, range)
|
388
|
+
));
|
389
|
+
|
390
|
+
subscriptions.push(vscode.commands.registerCommand(
|
391
|
+
EntityAction.CreateQueryBuilderFindAll,
|
392
|
+
async (doc, range) => insertQueryBuilder(EntityAction.CreateQueryBuilderFindAll, doc, range)
|
393
|
+
));
|
394
|
+
|
395
|
+
subscriptions.push(vscode.commands.registerCommand(
|
396
|
+
EntityAction.CreateQueryBuilderFindOne,
|
397
|
+
async (doc, range) => insertQueryBuilder(EntityAction.CreateQueryBuilderFindOne, doc, range)
|
398
|
+
));
|
399
|
+
|
400
|
+
subscriptions.push(vscode.commands.registerCommand(
|
401
|
+
EntityAction.FindOneOrThrowID,
|
402
|
+
async (doc, range) => insertFindOneOrThrow(EntityAction.FindOneOrThrowID, doc, range)
|
403
|
+
));
|
404
|
+
|
405
|
+
subscriptions.push(vscode.commands.registerCommand(
|
406
|
+
EntityAction.AddPropertyToQuery,
|
407
|
+
async (doc, range, lastIndex, property) => insertPropertiesToQuery(doc, range, lastIndex, property)
|
408
|
+
));
|
409
|
+
|
410
|
+
subscriptions.push(vscode.commands.registerCommand(
|
411
|
+
EntityAction.AddBuilderRelation,
|
412
|
+
async (doc, range) => insertBuilderRelation(EntityAction.AddBuilderRelation, doc, range)
|
413
|
+
));
|
414
|
+
|
415
|
+
|
416
|
+
/**
|
417
|
+
* CODE ACTION - ENTITY REQUEST
|
418
|
+
*/
|
419
|
+
|
420
|
+
subscriptions.push(vscode.languages.registerCodeActionsProvider(
|
421
|
+
'typescript',
|
422
|
+
new EntityRequestActionProvider(),
|
423
|
+
{ providedCodeActionKinds: EntityRequestActionProvider.providedCodeActionKinds }
|
424
|
+
));
|
425
|
+
|
426
|
+
/**
|
427
|
+
* CODE ACTION - ENUM
|
428
|
+
*/
|
429
|
+
|
430
|
+
subscriptions.push(
|
431
|
+
vscode.languages.registerCodeActionsProvider(
|
432
|
+
'typescript',
|
433
|
+
new EnumActionProvider(),
|
434
|
+
{ providedCodeActionKinds: EnumActionProvider.providedCodeActionKinds }
|
435
|
+
)
|
436
|
+
);
|
437
|
+
|
438
|
+
subscriptions.push(vscode.commands.registerCommand(
|
439
|
+
BMDCommand.AddEnum,
|
440
|
+
async (doc, range) => addEnum(doc, range)
|
441
|
+
));
|
442
|
+
|
443
|
+
//#endregion
|
444
|
+
|
445
|
+
|
446
|
+
/**
|
447
|
+
* *********************************************************
|
448
|
+
* COMPLETION
|
449
|
+
* *********************************************************
|
450
|
+
*/
|
451
|
+
subscriptions.push(
|
452
|
+
CompletionEntityProvider,
|
453
|
+
CompletionPropertyProvider,
|
454
|
+
CompletionQueryProvider
|
455
|
+
)
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
export function deactivate() { }
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
import { ControllerAction } from '../../../constant';
|
3
|
+
import { getPath, getPathParams, getLineCloseFunction } from './util';
|
4
|
+
import { getParamLinesInFunction, getParams } from '../../errorChecking/util';
|
5
|
+
|
6
|
+
export function addPathParams(document: vscode.TextDocument, range: vscode.Range) {
|
7
|
+
const line = document.lineAt(range.start)
|
8
|
+
if (isControllerFile(document) && isMethodDecorator(line.text)) {
|
9
|
+
console.log('isControllerFile(document) && isMethodDecorator(line.text):', isControllerFile(document) && isMethodDecorator(line.text))
|
10
|
+
const action = new vscode.CodeAction(ControllerAction.AddPathParams, vscode.CodeActionKind.QuickFix);
|
11
|
+
|
12
|
+
action.command = {
|
13
|
+
command: ControllerAction.AddPathParams,
|
14
|
+
title: 'Add @PathParams: ',
|
15
|
+
tooltip: 'Add @PathParams: ',
|
16
|
+
arguments: [document, range]
|
17
|
+
};
|
18
|
+
|
19
|
+
return action;
|
20
|
+
} else {
|
21
|
+
return undefined
|
22
|
+
}
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
function isMethodDecorator(line: string) {
|
27
|
+
return line.includes('@Get') ||
|
28
|
+
line.includes('@Post') ||
|
29
|
+
line.includes('@Delete') ||
|
30
|
+
line.includes('@Put') ||
|
31
|
+
line.includes('@Patch')
|
32
|
+
}
|
33
|
+
|
34
|
+
function isControllerFile(document: vscode.TextDocument) {
|
35
|
+
return document.fileName.includes('Controller')
|
36
|
+
}
|
37
|
+
|
38
|
+
export async function handleAddPathParams(document: vscode.TextDocument, range: vscode.Range) {
|
39
|
+
const line = document.lineAt(range.start)
|
40
|
+
|
41
|
+
const path = getPath(line.text)
|
42
|
+
if (!path) return vscode.window.showInformationMessage('Cancel: Can not find path.')
|
43
|
+
|
44
|
+
const pathParams = getPathParams(path)
|
45
|
+
if (!pathParams.length) return vscode.window.showInformationMessage('Cancel: Can not find path params with pattern: ":param".')
|
46
|
+
|
47
|
+
const paramLines = getParamLinesInFunction(line.lineNumber, document)
|
48
|
+
const params = paramLines.map(l => getParams(l.text)).filter(Boolean)
|
49
|
+
|
50
|
+
const notExistParams = pathParams.filter(p => !params.includes(p));
|
51
|
+
if (!notExistParams.length) return vscode.window.showInformationMessage('Cancel: All params were existed.')
|
52
|
+
|
53
|
+
const param = await vscode.window.showQuickPick(notExistParams, { ignoreFocusOut: true })
|
54
|
+
|
55
|
+
if (!param) return vscode.window.showInformationMessage('Cancel: Do not select path params.')
|
56
|
+
|
57
|
+
const edit = new vscode.WorkspaceEdit();
|
58
|
+
|
59
|
+
const template = ` @PathParams("${param}") ${param}: number,
|
60
|
+
`
|
61
|
+
const lineCloseFunc = getLineCloseFunction(line, document)
|
62
|
+
edit.insert(document.uri, new vscode.Position(lineCloseFunc.lineNumber, 0), template);
|
63
|
+
|
64
|
+
vscode.workspace.applyEdit(edit)
|
65
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
import { ControllerAction } from '../../../constant';
|
3
|
+
import { getLineOpenFunction } from './util';
|
4
|
+
|
5
|
+
export function addTokenParam(document: vscode.TextDocument, range: vscode.Range) {
|
6
|
+
const line = document.lineAt(range.start)
|
7
|
+
if (isControllerFile(document) && isUseAuthDecorator(line.text)) {
|
8
|
+
const action = new vscode.CodeAction(ControllerAction.AddTokenParam, vscode.CodeActionKind.QuickFix);
|
9
|
+
|
10
|
+
action.command = {
|
11
|
+
command: ControllerAction.AddTokenParam,
|
12
|
+
title: 'Add token param 1',
|
13
|
+
tooltip: 'Add token param 2',
|
14
|
+
arguments: [document, range],
|
15
|
+
};
|
16
|
+
|
17
|
+
return action;
|
18
|
+
} else {
|
19
|
+
return undefined
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
function isUseAuthDecorator(line: string) {
|
25
|
+
return line.includes('@UseAuth')
|
26
|
+
}
|
27
|
+
|
28
|
+
function isControllerFile(document: vscode.TextDocument) {
|
29
|
+
return document.fileName.includes('Controller')
|
30
|
+
}
|
31
|
+
|
32
|
+
export function handleAddTokenParams(document: vscode.TextDocument, range: vscode.Range) {
|
33
|
+
const line = document.lineAt(range.start)
|
34
|
+
|
35
|
+
const edit = new vscode.WorkspaceEdit();
|
36
|
+
|
37
|
+
const template = ` @HeaderParams("token") token: string,
|
38
|
+
`
|
39
|
+
const lineOpenFunc = getLineOpenFunction(line, document)
|
40
|
+
edit.insert(document.uri, new vscode.Position(lineOpenFunc.lineNumber + 1, 0), template);
|
41
|
+
|
42
|
+
vscode.workspace.applyEdit(edit)
|
43
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
import { ControllerAction } from '../../../constant';
|
3
|
+
import { getPath, getPathParams, getLineCloseFunction } from './util';
|
4
|
+
import { getParamLinesInFunction, getParams } from '../../errorChecking/util';
|
5
|
+
|
6
|
+
export function addValidationRequired(document: vscode.TextDocument, range: vscode.Range) {
|
7
|
+
const line = document.lineAt(range.start)
|
8
|
+
if (isControllerFile(document) && isParamsDecorator(line.text)) {
|
9
|
+
const action = new vscode.CodeAction(ControllerAction.AddValidation, vscode.CodeActionKind.QuickFix);
|
10
|
+
|
11
|
+
action.command = {
|
12
|
+
command: ControllerAction.AddValidation,
|
13
|
+
title: 'Validation',
|
14
|
+
arguments: [document, range]
|
15
|
+
};
|
16
|
+
|
17
|
+
return action;
|
18
|
+
} else {
|
19
|
+
return undefined
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
function isParamsDecorator(line: string) {
|
25
|
+
return line.includes('@') && line.includes('Params')
|
26
|
+
}
|
27
|
+
|
28
|
+
function isControllerFile(document: vscode.TextDocument) {
|
29
|
+
return document.fileName.includes('Controller')
|
30
|
+
}
|
31
|
+
|
32
|
+
export async function handleAddValidation(document: vscode.TextDocument, range: vscode.Range) {
|
33
|
+
const line = document.lineAt(range.start)
|
34
|
+
console.log('line:', line)
|
35
|
+
|
36
|
+
const param = getParams(line.text)
|
37
|
+
return
|
38
|
+
|
39
|
+
const edit = new vscode.WorkspaceEdit();
|
40
|
+
|
41
|
+
const template = ` @PathParams("${param}") ${param}: number,
|
42
|
+
`
|
43
|
+
const lineCloseFunc = getLineCloseFunction(line, document)
|
44
|
+
edit.insert(document.uri, new vscode.Position(lineCloseFunc.lineNumber, 0), template);
|
45
|
+
|
46
|
+
vscode.workspace.applyEdit(edit)
|
47
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
import { addPathParams } from './addPathParams';
|
3
|
+
import { addTokenParam } from './addTokenParam';
|
4
|
+
import { addValidationRequired } from './addValidation';
|
5
|
+
|
6
|
+
|
7
|
+
export class ControllerActionProvider implements vscode.CodeActionProvider {
|
8
|
+
|
9
|
+
public static readonly providedCodeActionKinds = [
|
10
|
+
vscode.CodeActionKind.QuickFix
|
11
|
+
];
|
12
|
+
|
13
|
+
public provideCodeActions(
|
14
|
+
document: vscode.TextDocument,
|
15
|
+
range: any,
|
16
|
+
): vscode.CodeAction[] | any {
|
17
|
+
const actionAddPathParams = addPathParams(document, range)
|
18
|
+
if (actionAddPathParams) {
|
19
|
+
return [actionAddPathParams]
|
20
|
+
}
|
21
|
+
|
22
|
+
const actionAddTokenParam = addTokenParam(document, range)
|
23
|
+
if (actionAddTokenParam) {
|
24
|
+
return [actionAddTokenParam]
|
25
|
+
}
|
26
|
+
|
27
|
+
const actionAddValidation = addValidationRequired(document, range)
|
28
|
+
if (actionAddValidation) {
|
29
|
+
return [actionAddValidation]
|
30
|
+
}
|
31
|
+
|
32
|
+
return []
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import * as vscode from 'vscode';
|
2
|
+
import { getMatch } from '../../../util';
|
3
|
+
|
4
|
+
export function getLineCloseFunction(line: vscode.TextLine, document: vscode.TextDocument) {
|
5
|
+
const totalLine = document.lineCount
|
6
|
+
|
7
|
+
for (let index = line.lineNumber; index < totalLine; index++) {
|
8
|
+
const line = document.lineAt(index)
|
9
|
+
|
10
|
+
if (line.text.includes(') {') || line.text.includes('){')) return line
|
11
|
+
}
|
12
|
+
|
13
|
+
return line
|
14
|
+
}
|
15
|
+
|
16
|
+
export function getLineOpenFunction(line: vscode.TextLine, document: vscode.TextDocument) {
|
17
|
+
const totalLine = document.lineCount
|
18
|
+
|
19
|
+
for (let index = line.lineNumber; index < totalLine; index++) {
|
20
|
+
const line = document.lineAt(index)
|
21
|
+
|
22
|
+
if (line.text.includes('async') && line.text.includes('(')) return line
|
23
|
+
}
|
24
|
+
|
25
|
+
return line
|
26
|
+
}
|
27
|
+
|
28
|
+
export function getPathParams(path: string) {
|
29
|
+
const parts = path.split('/').filter(Boolean)
|
30
|
+
|
31
|
+
const params: any[] = []
|
32
|
+
parts.map(p => {
|
33
|
+
if (p.includes(':')) {
|
34
|
+
params.push(p.replace(':', ""))
|
35
|
+
}
|
36
|
+
})
|
37
|
+
|
38
|
+
return params
|
39
|
+
}
|
40
|
+
|
41
|
+
export function getPath(line: string) {
|
42
|
+
const paths = getMatch(/".*"|'.*'|`.*`/gm, line)
|
43
|
+
if (!paths || !paths.length) {
|
44
|
+
return ''
|
45
|
+
}
|
46
|
+
|
47
|
+
return paths[0].replace(/"/g, '').replace(/'/g, '').replace(/`/g, '')
|
48
|
+
}
|