@tsed/cli-plugin-mongoose 6.6.3 → 7.0.0-alpha.1
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/lib/esm/CliPluginMongooseModule.js +1 -0
- package/lib/esm/hooks/MongooseGenerateHook.js +17 -77
- package/lib/esm/hooks/MongooseInitHook.js +15 -42
- package/lib/esm/index.js +0 -1
- package/lib/esm/services/CliMongoose.js +47 -37
- package/lib/esm/templates/connection.template.js +15 -0
- package/lib/esm/templates/index.js +4 -0
- package/lib/esm/templates/index.template.js +12 -0
- package/lib/esm/templates/mongooseModel.template.js +21 -0
- package/lib/esm/templates/mongooseSchema.template.js +17 -0
- package/lib/types/CliPluginMongooseModule.d.ts +1 -0
- package/lib/types/hooks/MongooseGenerateHook.d.ts +5 -9
- package/lib/types/hooks/MongooseInitHook.d.ts +3 -12
- package/lib/types/index.d.ts +0 -1
- package/lib/types/services/CliMongoose.d.ts +8 -4
- package/lib/types/templates/connection.template.d.ts +2 -0
- package/lib/types/templates/index.d.ts +4 -0
- package/lib/types/templates/index.template.d.ts +2 -0
- package/lib/types/templates/mongooseModel.template.d.ts +2 -0
- package/lib/types/templates/mongooseSchema.template.d.ts +2 -0
- package/package.json +8 -5
- package/lib/esm/utils/templateDir.js +0 -2
- package/lib/types/utils/templateDir.d.ts +0 -1
- package/templates/config.hbs +0 -5
- package/templates/index.hbs +0 -10
- package/templates/mongoose.model.hbs +0 -22
- package/templates/mongoose.schema.hbs +0 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import "./templates/index.js";
|
|
2
3
|
import { inject, Module, OnAdd, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
4
|
import { MongooseGenerateHook } from "./hooks/MongooseGenerateHook.js";
|
|
4
5
|
import { MongooseInitHook } from "./hooks/MongooseInitHook.js";
|
|
@@ -1,88 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CliDockerComposeYaml, inject, OnExec, ProjectPackageJson } from "@tsed/cli-core";
|
|
5
|
-
import { Injectable } from "@tsed/di";
|
|
6
|
-
import { camelCase, kebabCase } from "change-case";
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
import { plural } from "pluralize";
|
|
1
|
+
import { ProjectClient } from "@tsed/cli";
|
|
2
|
+
import { CliDockerComposeYaml, inject, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
|
+
import { injectable } from "@tsed/di";
|
|
9
4
|
import { CliMongoose } from "../services/CliMongoose.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
constructor(providersInfoService) {
|
|
13
|
-
this.providersInfoService = providersInfoService;
|
|
5
|
+
export class MongooseGenerateHook {
|
|
6
|
+
constructor() {
|
|
14
7
|
this.projectPackageJson = inject(ProjectPackageJson);
|
|
15
|
-
this.srcRenderService = inject(SrcRendererService);
|
|
16
8
|
this.cliMongoose = inject(CliMongoose);
|
|
17
9
|
this.cliDockerComposeYaml = inject(CliDockerComposeYaml);
|
|
18
|
-
providersInfoService
|
|
19
|
-
.add({
|
|
20
|
-
name: "Mongoose model",
|
|
21
|
-
value: "mongoose:model",
|
|
22
|
-
model: "{{symbolName}}.model",
|
|
23
|
-
baseDir: "models"
|
|
24
|
-
}, MongooseGenerateHook_1)
|
|
25
|
-
.add({
|
|
26
|
-
name: "Mongoose schema",
|
|
27
|
-
value: "mongoose:schema",
|
|
28
|
-
model: "{{symbolName}}.schema",
|
|
29
|
-
baseDir: "models"
|
|
30
|
-
}, MongooseGenerateHook_1)
|
|
31
|
-
.add({
|
|
32
|
-
name: "Mongoose connection",
|
|
33
|
-
value: "mongoose:connection"
|
|
34
|
-
}, MongooseGenerateHook_1);
|
|
35
10
|
}
|
|
36
|
-
|
|
37
|
-
if (this.providersInfoService.isMyProvider(ctx.type, MongooseGenerateHook_1)) {
|
|
38
|
-
switch (ctx.type) {
|
|
39
|
-
case "mongoose:connection":
|
|
40
|
-
return this.generateConnection(ctx);
|
|
41
|
-
case "mongoose:model":
|
|
42
|
-
case "mongoose:schema":
|
|
43
|
-
return this.generateTemplate(ctx);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
generateTemplate(ctx) {
|
|
49
|
-
const { symbolPath, type, symbolName } = ctx;
|
|
50
|
-
const template = `mongoose.${type.split(":")[1]}.hbs`;
|
|
51
|
-
const newCtx = {
|
|
52
|
-
...ctx,
|
|
53
|
-
collectionName: plural(camelCase(symbolName.replace(/Schema|Model/gi, "")))
|
|
54
|
-
};
|
|
11
|
+
$alterGenerateTasks(tasks, data) {
|
|
55
12
|
return [
|
|
56
|
-
|
|
57
|
-
title: `Generate ${ctx.type} file to '${symbolPath}.ts'`,
|
|
58
|
-
task: () => this.srcRenderService.render(template, newCtx, {
|
|
59
|
-
output: `${symbolPath}.ts`,
|
|
60
|
-
templateDir: TEMPLATE_DIR
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
generateConnection(ctx) {
|
|
66
|
-
return [
|
|
67
|
-
{
|
|
68
|
-
title: `Generate Mongoose configuration file to '${kebabCase(ctx.name)}.config.ts'`,
|
|
69
|
-
task: () => this.cliMongoose.writeConfig(ctx.name, ctx)
|
|
70
|
-
},
|
|
13
|
+
...tasks,
|
|
71
14
|
{
|
|
72
15
|
title: "Generate docker-compose configuration",
|
|
73
|
-
|
|
16
|
+
skip: (ctx) => ctx.type !== "mongoose.connection",
|
|
17
|
+
task: () => this.cliDockerComposeYaml.addDatabaseService(data.name, "mongodb")
|
|
74
18
|
}
|
|
75
19
|
];
|
|
76
20
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
MongooseGenerateHook
|
|
85
|
-
Injectable(),
|
|
86
|
-
__metadata("design:paramtypes", [ProvidersInfoService])
|
|
87
|
-
], MongooseGenerateHook);
|
|
88
|
-
export { MongooseGenerateHook };
|
|
21
|
+
$alterProjectFiles(project, data) {
|
|
22
|
+
if (data.commandName === "generate" && data.type === "mongoose.connection") {
|
|
23
|
+
this.cliMongoose.updateMongooseConfig(project, data.symbolName);
|
|
24
|
+
}
|
|
25
|
+
return project;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
injectable(MongooseGenerateHook);
|
|
@@ -1,47 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Injectable } from "@tsed/di";
|
|
1
|
+
import { ProjectClient } from "@tsed/cli";
|
|
2
|
+
import { inject, injectable } from "@tsed/di";
|
|
4
3
|
import { CliMongoose } from "../services/CliMongoose.js";
|
|
5
|
-
|
|
4
|
+
export class MongooseInitHook {
|
|
6
5
|
constructor() {
|
|
7
6
|
this.cliMongoose = inject(CliMongoose);
|
|
8
|
-
this.packageJson = inject(ProjectPackageJson);
|
|
9
|
-
this.cliDockerComposeYaml = inject(CliDockerComposeYaml);
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
title: "Generate docker-compose configuration",
|
|
24
|
-
task: () => this.cliDockerComposeYaml.addDatabaseService("mongodb", "mongodb")
|
|
25
|
-
}
|
|
26
|
-
];
|
|
8
|
+
async $alterProjectFiles(project, data) {
|
|
9
|
+
if (data.commandName === "init" && data.mongoose) {
|
|
10
|
+
project.serverSourceFile?.addImportDeclaration({
|
|
11
|
+
moduleSpecifier: "@tsed/mongoose"
|
|
12
|
+
});
|
|
13
|
+
await project.dockerCompose.addDatabaseService("mongodb", "mongodb");
|
|
14
|
+
await this.cliMongoose.createMongooseConnection(project, "MONGOOSE_DEFAULT");
|
|
15
|
+
this.cliMongoose.updateConfigFile(project, data);
|
|
16
|
+
}
|
|
17
|
+
return project;
|
|
27
18
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
addDependencies(ctx) {
|
|
32
|
-
this.packageJson.addDependencies({}, ctx);
|
|
33
|
-
}
|
|
34
|
-
addDevDependencies(ctx) {
|
|
35
|
-
this.packageJson.addDevDependencies({}, ctx);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
__decorate([
|
|
39
|
-
OnExec("init"),
|
|
40
|
-
__metadata("design:type", Function),
|
|
41
|
-
__metadata("design:paramtypes", [Object]),
|
|
42
|
-
__metadata("design:returntype", void 0)
|
|
43
|
-
], MongooseInitHook.prototype, "onExec", null);
|
|
44
|
-
MongooseInitHook = __decorate([
|
|
45
|
-
Injectable()
|
|
46
|
-
], MongooseInitHook);
|
|
47
|
-
export { MongooseInitHook };
|
|
19
|
+
}
|
|
20
|
+
injectable(MongooseInitHook);
|
package/lib/esm/index.js
CHANGED
|
@@ -2,5 +2,4 @@ import { CliPluginMongooseModule } from "./CliPluginMongooseModule.js";
|
|
|
2
2
|
export * from "./hooks/MongooseGenerateHook.js";
|
|
3
3
|
export * from "./hooks/MongooseInitHook.js";
|
|
4
4
|
export * from "./services/CliMongoose.js";
|
|
5
|
-
export * from "./utils/templateDir.js";
|
|
6
5
|
export default CliPluginMongooseModule;
|
|
@@ -1,45 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { TEMPLATE_DIR } from "../utils/templateDir.js";
|
|
7
|
-
let CliMongoose = class CliMongoose {
|
|
1
|
+
import { ProjectClient, render } from "@tsed/cli";
|
|
2
|
+
import { inject, injectable, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
|
+
import { camelCase } from "change-case";
|
|
4
|
+
import { SyntaxKind } from "ts-morph";
|
|
5
|
+
export class CliMongoose {
|
|
8
6
|
constructor() {
|
|
9
7
|
this.projectPackageJson = inject(ProjectPackageJson);
|
|
10
|
-
this.srcRenderer = inject(SrcRendererService);
|
|
11
8
|
}
|
|
12
|
-
async
|
|
13
|
-
await
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
async createMongooseConnection(project, name) {
|
|
10
|
+
const obj = await render("mongoose.connection", { name });
|
|
11
|
+
return this.updateMongooseConfig(project, obj.symbolName);
|
|
12
|
+
}
|
|
13
|
+
async updateMongooseConfig(project, name) {
|
|
14
|
+
const connectionSource = project.getSource(`{{srcDir}}/config/mongoose/${name}.ts`);
|
|
15
|
+
const { options, source } = await this.getMongooseConfig(project);
|
|
16
|
+
if (options && connectionSource) {
|
|
17
|
+
source.addImportDeclaration({
|
|
18
|
+
moduleSpecifier: `./${name}.js`,
|
|
19
|
+
defaultImport: camelCase(name)
|
|
20
|
+
});
|
|
21
|
+
options.addElement(camelCase(name));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async getMongooseConfig(project) {
|
|
25
|
+
let source = project.getSource("{{srcDir}}/config/mongoose/index.ts");
|
|
26
|
+
if (!source) {
|
|
27
|
+
source = (await render("mongoose.index", {
|
|
28
|
+
name: "index"
|
|
29
|
+
})).source;
|
|
30
|
+
}
|
|
31
|
+
// get default export options
|
|
32
|
+
const defaultExport = source.getStatement((statement) => {
|
|
33
|
+
return statement.isKind(SyntaxKind.ExportAssignment);
|
|
21
34
|
});
|
|
22
|
-
return
|
|
35
|
+
return { source, options: defaultExport?.getFirstDescendantByKind(SyntaxKind.ArrayLiteralExpression) };
|
|
23
36
|
}
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
updateConfigFile(project, data) {
|
|
38
|
+
const options = project.findConfiguration("config");
|
|
39
|
+
const configFile = project.configSourceFile;
|
|
40
|
+
if (!configFile || !options) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// set that in config.ts
|
|
44
|
+
configFile.addImportDeclaration({
|
|
45
|
+
moduleSpecifier: "./mongoose/index.js",
|
|
46
|
+
defaultImport: "mongooseConfig"
|
|
32
47
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
output: "index.ts",
|
|
38
|
-
rootDir: join(this.srcRenderer.rootDir, "config", "mongoose")
|
|
48
|
+
project.getPropertyAssignment(options, {
|
|
49
|
+
name: "mongoose",
|
|
50
|
+
kind: SyntaxKind.Identifier,
|
|
51
|
+
initializer: "mongooseConfig"
|
|
39
52
|
});
|
|
40
53
|
}
|
|
41
|
-
}
|
|
42
|
-
CliMongoose
|
|
43
|
-
Injectable()
|
|
44
|
-
], CliMongoose);
|
|
45
|
-
export { CliMongoose };
|
|
54
|
+
}
|
|
55
|
+
injectable(CliMongoose);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { constantCase, kebabCase } from "change-case";
|
|
2
|
+
import { defineTemplate } from "@tsed/cli";
|
|
3
|
+
export default defineTemplate({
|
|
4
|
+
id: "mongoose.connection",
|
|
5
|
+
label: "Mongoose Connection",
|
|
6
|
+
fileName: "{{symbolName}}.connection",
|
|
7
|
+
outputDir: "{{srcDir}}/config/mongoose",
|
|
8
|
+
render(symbolName, data) {
|
|
9
|
+
return `export default {
|
|
10
|
+
id: "${symbolName}",
|
|
11
|
+
url: process.env.${constantCase(symbolName)}_URL || "mongodb://localhost:27017/${kebabCase(data.name)}",
|
|
12
|
+
connectionOptions: { }
|
|
13
|
+
}`;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineTemplate } from "@tsed/cli";
|
|
2
|
+
export default defineTemplate({
|
|
3
|
+
id: "mongoose.index",
|
|
4
|
+
label: "Mongoose Index",
|
|
5
|
+
fileName: "index",
|
|
6
|
+
outputDir: "{{srcDir}}/config/mongoose",
|
|
7
|
+
hidden: true,
|
|
8
|
+
render() {
|
|
9
|
+
return `//keep this default
|
|
10
|
+
export default [];`;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineTemplate } from "@tsed/cli";
|
|
2
|
+
import { camelCase } from "change-case";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { plural } from "pluralize";
|
|
5
|
+
export default defineTemplate({
|
|
6
|
+
id: "mongoose.model",
|
|
7
|
+
label: "Mongoose model",
|
|
8
|
+
fileName: "{{symbolName}}.model",
|
|
9
|
+
outputDir: "{{srcDir}}/models",
|
|
10
|
+
render(symbolName) {
|
|
11
|
+
const collectionName = plural(camelCase(symbolName.replace(/Schema|Model/gi, "")));
|
|
12
|
+
return `import { Model, ObjectID } from "@tsed/mongoose";
|
|
13
|
+
@Model({
|
|
14
|
+
name: "${collectionName}"
|
|
15
|
+
})
|
|
16
|
+
export class ${symbolName} {
|
|
17
|
+
@ObjectID("id")
|
|
18
|
+
_id: string;
|
|
19
|
+
}`;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineTemplate } from "@tsed/cli";
|
|
2
|
+
export default defineTemplate({
|
|
3
|
+
id: "mongoose.schema",
|
|
4
|
+
label: "Mongoose schema",
|
|
5
|
+
fileName: "{{symbolName}}.schema",
|
|
6
|
+
outputDir: "{{srcDir}}/schemas",
|
|
7
|
+
render(symbolName) {
|
|
8
|
+
return `import { Property } from "@tsed/schema";
|
|
9
|
+
import { Schema } from "@tsed/mongoose";
|
|
10
|
+
|
|
11
|
+
@Schema()
|
|
12
|
+
export class ${symbolName} {
|
|
13
|
+
@Property()
|
|
14
|
+
unique: string;
|
|
15
|
+
}`;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { CliDockerComposeYaml, ProjectPackageJson, type
|
|
1
|
+
import { type AlterGenerateTasks, type AlterProjectFiles, type GenerateCmdContext, ProjectClient } from "@tsed/cli";
|
|
2
|
+
import { CliDockerComposeYaml, ProjectPackageJson, type Task } from "@tsed/cli-core";
|
|
3
3
|
import { CliMongoose } from "../services/CliMongoose.js";
|
|
4
|
-
export declare class MongooseGenerateHook {
|
|
5
|
-
private providersInfoService;
|
|
4
|
+
export declare class MongooseGenerateHook implements AlterGenerateTasks, AlterProjectFiles {
|
|
6
5
|
protected projectPackageJson: ProjectPackageJson;
|
|
7
|
-
protected srcRenderService: SrcRendererService;
|
|
8
6
|
protected cliMongoose: CliMongoose;
|
|
9
7
|
protected packages: any[];
|
|
10
8
|
protected cliDockerComposeYaml: CliDockerComposeYaml;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private generateTemplate;
|
|
14
|
-
private generateConnection;
|
|
9
|
+
$alterGenerateTasks(tasks: Task[], data: GenerateCmdContext): Task[] | Promise<Task[]>;
|
|
10
|
+
$alterProjectFiles(project: ProjectClient, data: GenerateCmdContext): Promise<ProjectClient> | ProjectClient;
|
|
15
11
|
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { CliDockerComposeYaml, ProjectPackageJson } from "@tsed/cli-core";
|
|
1
|
+
import { type CliCommandHooks, ProjectClient, type RenderDataContext } from "@tsed/cli";
|
|
3
2
|
import { CliMongoose } from "../services/CliMongoose.js";
|
|
4
|
-
export declare class MongooseInitHook {
|
|
3
|
+
export declare class MongooseInitHook implements CliCommandHooks {
|
|
5
4
|
protected cliMongoose: CliMongoose;
|
|
6
|
-
|
|
7
|
-
protected cliDockerComposeYaml: CliDockerComposeYaml;
|
|
8
|
-
onExec(ctx: InitCmdContext): {
|
|
9
|
-
title: string;
|
|
10
|
-
task: () => Promise<void>;
|
|
11
|
-
}[];
|
|
12
|
-
addScripts(): void;
|
|
13
|
-
addDependencies(ctx: InitCmdContext): void;
|
|
14
|
-
addDevDependencies(ctx: InitCmdContext): void;
|
|
5
|
+
$alterProjectFiles(project: ProjectClient, data: RenderDataContext): Promise<ProjectClient>;
|
|
15
6
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ import { CliPluginMongooseModule } from "./CliPluginMongooseModule.js";
|
|
|
2
2
|
export * from "./hooks/MongooseGenerateHook.js";
|
|
3
3
|
export * from "./hooks/MongooseInitHook.js";
|
|
4
4
|
export * from "./services/CliMongoose.js";
|
|
5
|
-
export * from "./utils/templateDir.js";
|
|
6
5
|
export default CliPluginMongooseModule;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProjectClient, type RenderDataContext } from "@tsed/cli";
|
|
2
2
|
import { ProjectPackageJson } from "@tsed/cli-core";
|
|
3
3
|
export declare class CliMongoose {
|
|
4
4
|
protected projectPackageJson: ProjectPackageJson;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
createMongooseConnection(project: ProjectClient, name: string): Promise<void>;
|
|
6
|
+
updateMongooseConfig(project: ProjectClient, name: string): Promise<void>;
|
|
7
|
+
getMongooseConfig(project: ProjectClient): Promise<{
|
|
8
|
+
source: import("ts-morph").SourceFile;
|
|
9
|
+
options: import("ts-morph").ArrayLiteralExpression | undefined;
|
|
10
|
+
}>;
|
|
11
|
+
updateConfigFile(project: ProjectClient, data: RenderDataContext): void;
|
|
8
12
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/cli-plugin-mongoose",
|
|
3
3
|
"description": "Ts.ED CLI plugin. Add Mongoose support",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0-alpha.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
7
7
|
"source": "./src/index.ts",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"tslib": "2.7.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@tsed/cli": "
|
|
31
|
-
"@tsed/cli-core": "
|
|
32
|
-
"@tsed/typescript": "
|
|
30
|
+
"@tsed/cli": "7.0.0-alpha.1",
|
|
31
|
+
"@tsed/cli-core": "7.0.0-alpha.1",
|
|
32
|
+
"@tsed/typescript": "7.0.0-alpha.1",
|
|
33
33
|
"cross-env": "7.0.3",
|
|
34
34
|
"typescript": "5.6.2",
|
|
35
35
|
"vitest": "3.2.4"
|
|
@@ -41,5 +41,8 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli-plugin-mongoose",
|
|
43
43
|
"author": "Romain Lenzotti",
|
|
44
|
-
"license": "MIT"
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"tag": "alpha"
|
|
47
|
+
}
|
|
45
48
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const TEMPLATE_DIR: string;
|
package/templates/config.hbs
DELETED
package/templates/index.hbs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Model, ObjectID } from "@tsed/mongoose";
|
|
2
|
-
/**
|
|
3
|
-
* ## How to inject model?
|
|
4
|
-
*
|
|
5
|
-
* ```typescript
|
|
6
|
-
* import type { MongooseModel } from "@tsed/mongoose";
|
|
7
|
-
* import { Injectable, Inject } from "@tsed/di";
|
|
8
|
-
*
|
|
9
|
-
* @Injectable()
|
|
10
|
-
* class MyService {
|
|
11
|
-
* @Inject({{ collectionName }})
|
|
12
|
-
* model: MongooseModel<{{ collectionName }}>;
|
|
13
|
-
* }
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
@Model({
|
|
17
|
-
name: "{{ collectionName }}"
|
|
18
|
-
})
|
|
19
|
-
export class {{symbolName}} {
|
|
20
|
-
@ObjectID("id")
|
|
21
|
-
_id: string;
|
|
22
|
-
}
|