@mshima/generator-jhipster-nodejs 0.0.0-stage → 0.0.2
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/LICENSE.txt +204 -0
- package/README.md +243 -2
- package/build-info.json +3 -0
- package/cli/cli-customizations.cjs +9 -0
- package/cli/cli.cjs +40 -0
- package/cli/logo.js +31 -0
- package/cli/version.cjs +12 -0
- package/generators/ci-cd/USAGE +5 -0
- package/generators/ci-cd/command.js +5 -0
- package/generators/ci-cd/generator.js +158 -0
- package/generators/ci-cd/index.js +2 -0
- package/generators/ci-cd/templates/.gitlab-ci.yml.ejs +137 -0
- package/generators/ci-cd/templates/azure-pipelines.yml.ejs +68 -0
- package/generators/ci-cd/templates/circle.yml.ejs +59 -0
- package/generators/ci-cd/templates/docker-registry.yml.ejs +58 -0
- package/generators/ci-cd/templates/github-ci.yml.ejs +90 -0
- package/generators/ci-cd/templates/jenkins/Jenkinsfile.ejs +104 -0
- package/generators/ci-cd/templates/jenkins/idea.gdsl +90 -0
- package/generators/ci-cd/templates/jenkins/jenkins.yml.ejs +33 -0
- package/generators/ci-cd/templates/travis.yml.ejs +75 -0
- package/generators/client/command.js +5 -0
- package/generators/client/generator.js +21 -0
- package/generators/client/generators/bootstrap/command.js +5 -0
- package/generators/client/generators/bootstrap/generator.js +28 -0
- package/generators/client/generators/bootstrap/index.js +2 -0
- package/generators/client/index.js +2 -0
- package/generators/common/generators/bootstrap/command.js +5 -0
- package/generators/common/generators/bootstrap/generator.js +37 -0
- package/generators/common/generators/bootstrap/index.js +2 -0
- package/generators/docker/command.js +5 -0
- package/generators/docker/generator.js +16 -0
- package/generators/docker/generators/bootstrap/command.js +5 -0
- package/generators/docker/generators/bootstrap/generator.js +56 -0
- package/generators/docker/generators/bootstrap/index.js +2 -0
- package/generators/docker/index.js +2 -0
- package/generators/docker/templates/docker/app.yml.ejs +25 -0
- package/generators/generator-nodejs-constants.js +32 -0
- package/generators/languages/command.js +5 -0
- package/generators/languages/generator.js +22 -0
- package/generators/languages/index.js +2 -0
- package/generators/languages/templates/src/main/webapp/i18n/en/home.json +19 -0
- package/generators/languages/templates/src/main/webapp/i18n/es/home.json +19 -0
- package/generators/languages/templates/src/main/webapp/i18n/it/home.json +19 -0
- package/generators/node-server/command.js +96 -0
- package/generators/node-server/entity-files.js +26 -0
- package/generators/node-server/files.js +254 -0
- package/generators/node-server/generator.js +705 -0
- package/generators/node-server/generators/bootstrap/command.js +5 -0
- package/generators/node-server/generators/bootstrap/generator.js +84 -0
- package/generators/node-server/generators/bootstrap/index.js +2 -0
- package/generators/node-server/generators/migrations/command.js +5 -0
- package/generators/node-server/generators/migrations/files.js +42 -0
- package/generators/node-server/generators/migrations/generator.js +108 -0
- package/generators/node-server/generators/migrations/index.js +2 -0
- package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityConstraintsMigration_.ts.ejs +40 -0
- package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityMigration_.ts.ejs +26 -0
- package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityRemovedMigration_.ts.ejs +15 -0
- package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityUpdatedConstraintsMigration_.ts.ejs +60 -0
- package/generators/node-server/generators/migrations/templates/server/src/migrations/_entityUpdatedMigration_.ts.ejs +28 -0
- package/generators/node-server/index.js +2 -0
- package/generators/node-server/resources/package.json +76 -0
- package/generators/node-server/support/api-fake-data.js +54 -0
- package/generators/node-server/support/columns.js +73 -0
- package/generators/node-server/support/database.js +24 -0
- package/generators/node-server/support/entity-authorities.js +32 -0
- package/generators/node-server/support/entity-paths.js +13 -0
- package/generators/node-server/support/enums.js +11 -0
- package/generators/node-server/support/index.js +9 -0
- package/generators/node-server/support/mail-templates.js +82 -0
- package/generators/node-server/support/migrations.js +376 -0
- package/generators/node-server/support/validators.js +25 -0
- package/generators/node-server/templates/.dockerignore.ejs +16 -0
- package/generators/node-server/templates/.gitignore.jhi.nodejs.ejs +24 -0
- package/generators/node-server/templates/Dockerfile.ejs +54 -0
- package/generators/node-server/templates/README.md.jhi.nodejs.ejs +220 -0
- package/generators/node-server/templates/package.json.ejs +82 -0
- package/generators/node-server/templates/server/README.md.ejs +277 -0
- package/generators/node-server/templates/server/e2e/_entityFileName_.database.e2e-spec.ts.ejs +192 -0
- package/generators/node-server/templates/server/e2e/_entityFileName_.e2e-spec.ts.ejs +402 -0
- package/generators/node-server/templates/server/e2e/account.e2e-spec.ts.ejs +349 -0
- package/generators/node-server/templates/server/e2e/app.e2e-spec.ts.ejs +188 -0
- package/generators/node-server/templates/server/e2e/authority.e2e-spec.ts.ejs +50 -0
- package/generators/node-server/templates/server/e2e/cors.e2e-spec.ts.ejs +110 -0
- package/generators/node-server/templates/server/e2e/management.e2e-spec.ts.ejs +180 -0
- package/generators/node-server/templates/server/e2e/oauth2-bearer.e2e-spec.ts.ejs +71 -0
- package/generators/node-server/templates/server/e2e/session.e2e-spec.ts.ejs +234 -0
- package/generators/node-server/templates/server/e2e/setup.test.js.ejs +1 -0
- package/generators/node-server/templates/server/e2e/user.e2e-spec.ts.ejs +318 -0
- package/generators/node-server/templates/server/env.ejs +1 -0
- package/generators/node-server/templates/server/eslint.config.mjs.ejs +48 -0
- package/generators/node-server/templates/server/nest-cli.json.ejs +11 -0
- package/generators/node-server/templates/server/ormconfig.ts.ejs +35 -0
- package/generators/node-server/templates/server/package.json.ejs +143 -0
- package/generators/node-server/templates/server/sonar-project.properties.ejs +10 -0
- package/generators/node-server/templates/server/src/app.config.spec.ts.ejs +13 -0
- package/generators/node-server/templates/server/src/app.config.ts.ejs +179 -0
- package/generators/node-server/templates/server/src/app.module.ts.ejs +80 -0
- package/generators/node-server/templates/server/src/application-config.ts.ejs +153 -0
- package/generators/node-server/templates/server/src/auth/account.controller.ts.ejs +183 -0
- package/generators/node-server/templates/server/src/auth/auth.module.ts.ejs +104 -0
- package/generators/node-server/templates/server/src/auth/auth.service.ts.ejs +294 -0
- package/generators/node-server/templates/server/src/auth/csrf.middleware.spec.ts.ejs +76 -0
- package/generators/node-server/templates/server/src/auth/csrf.middleware.ts.ejs +85 -0
- package/generators/node-server/templates/server/src/auth/decorators/auth-user.decorator.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/auth/decorators/roles.decorator.ts.ejs +4 -0
- package/generators/node-server/templates/server/src/auth/dto/key-and-password.dto.ts.ejs +17 -0
- package/generators/node-server/templates/server/src/auth/dto/password-change.dto.ts.ejs +17 -0
- package/generators/node-server/templates/server/src/auth/dto/user-login.dto.ts.ejs +21 -0
- package/generators/node-server/templates/server/src/auth/guards/auth.guard.ts.ejs +50 -0
- package/generators/node-server/templates/server/src/auth/guards/oauth2-login.guard.ts.ejs +6 -0
- package/generators/node-server/templates/server/src/auth/guards/roles.guard.ts.ejs +25 -0
- package/generators/node-server/templates/server/src/auth/index.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/auth/jwt.config.spec.ts.ejs +22 -0
- package/generators/node-server/templates/server/src/auth/jwt.config.ts.ejs +29 -0
- package/generators/node-server/templates/server/src/auth/oauth2.authorities.spec.ts.ejs +24 -0
- package/generators/node-server/templates/server/src/auth/oauth2.authorities.ts.ejs +33 -0
- package/generators/node-server/templates/server/src/auth/oauth2.config.ts.ejs +51 -0
- package/generators/node-server/templates/server/src/auth/passport.jwt.strategy.ts.ejs +45 -0
- package/generators/node-server/templates/server/src/auth/passport.oauth2-bearer.strategy.ts.ejs +32 -0
- package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.spec.ts.ejs +27 -0
- package/generators/node-server/templates/server/src/auth/passport.oauth2.strategy.ts.ejs +44 -0
- package/generators/node-server/templates/server/src/auth/password-util.ts.ejs +10 -0
- package/generators/node-server/templates/server/src/auth/password.service.ts.ejs +34 -0
- package/generators/node-server/templates/server/src/auth/payload.interface.ts.ejs +14 -0
- package/generators/node-server/templates/server/src/auth/role-type.ts.ejs +7 -0
- package/generators/node-server/templates/server/src/auth/session-user.middleware.ts.ejs +33 -0
- package/generators/node-server/templates/server/src/auth/session.entity.ts.ejs +36 -0
- package/generators/node-server/templates/server/src/auth/session.store.spec.ts.ejs +99 -0
- package/generators/node-server/templates/server/src/auth/session.store.ts.ejs +116 -0
- package/generators/node-server/templates/server/src/auth/user.jwt.controller.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/auth/user.oauth2.controller.ts.ejs +78 -0
- package/generators/node-server/templates/server/src/auth/user.session.controller.ts.ejs +103 -0
- package/generators/node-server/templates/server/src/common/common.module.ts.ejs +19 -0
- package/generators/node-server/templates/server/src/common/database/base.entity.ts.ejs +13 -0
- package/generators/node-server/templates/server/src/common/database/column-transformers.spec.ts.ejs +46 -0
- package/generators/node-server/templates/server/src/common/database/column-transformers.ts.ejs +69 -0
- package/generators/node-server/templates/server/src/common/database/column-types.spec.ts.ejs +21 -0
- package/generators/node-server/templates/server/src/common/database/column-types.ts.ejs +29 -0
- package/generators/node-server/templates/server/src/common/database/pagination.entity.spec.ts.ejs +66 -0
- package/generators/node-server/templates/server/src/common/database/pagination.entity.ts.ejs +108 -0
- package/generators/node-server/templates/server/src/common/dto/base.dto.ts.ejs +19 -0
- package/generators/node-server/templates/server/src/common/errors/error-constants.ts.ejs +10 -0
- package/generators/node-server/templates/server/src/common/errors/problem-details.filter.ts.ejs +63 -0
- package/generators/node-server/templates/server/src/common/errors/problem.exception.ts.ejs +92 -0
- package/generators/node-server/templates/server/src/common/field_validators.ejs +77 -0
- package/generators/node-server/templates/server/src/common/header-util.ts.ejs +105 -0
- package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.spec.ts.ejs +93 -0
- package/generators/node-server/templates/server/src/common/interceptors/logging.interceptor.ts.ejs +48 -0
- package/generators/node-server/templates/server/src/common/logging.spec.ts.ejs +83 -0
- package/generators/node-server/templates/server/src/common/logging.ts.ejs +129 -0
- package/generators/node-server/templates/server/src/common/metrics.spec.ts.ejs +43 -0
- package/generators/node-server/templates/server/src/common/metrics.ts.ejs +198 -0
- package/generators/node-server/templates/server/src/common/request.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/common/sortable-properties.ts.ejs +43 -0
- package/generators/node-server/templates/server/src/common/updatable-properties.ts.ejs +14 -0
- package/generators/node-server/templates/server/src/config/application-dev.yml.ejs +118 -0
- package/generators/node-server/templates/server/src/config/application-prod.yml.ejs +97 -0
- package/generators/node-server/templates/server/src/config/application-secret-samples.yml.ejs +42 -0
- package/generators/node-server/templates/server/src/config/application-test.yml.ejs +68 -0
- package/generators/node-server/templates/server/src/config/application-tls-samples.yml.ejs +15 -0
- package/generators/node-server/templates/server/src/config/application-tls.yml.ejs +15 -0
- package/generators/node-server/templates/server/src/config/application.yml.ejs +149 -0
- package/generators/node-server/templates/server/src/config.spec.ts.ejs +81 -0
- package/generators/node-server/templates/server/src/config.ts.ejs +255 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.controller.ts.ejs +178 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.entity.ts.ejs +110 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.mapper.ts.ejs +37 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.module.ts.ejs +14 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/_entityFileName_.service.ts.ejs +123 -0
- package/generators/node-server/templates/server/src/entities/_entityFileName_/dto/_entityFileName_.dto.ts.ejs +99 -0
- package/generators/node-server/templates/server/src/mail/mail.module.ts.ejs +49 -0
- package/generators/node-server/templates/server/src/mail/mail.service.spec.ts.ejs +105 -0
- package/generators/node-server/templates/server/src/mail/mail.service.ts.ejs +120 -0
- package/generators/node-server/templates/server/src/main.ts.ejs +114 -0
- package/generators/node-server/templates/server/src/management/api-docs.controller.ts.ejs +27 -0
- package/generators/node-server/templates/server/src/management/api-docs.service.ts.ejs +8 -0
- package/generators/node-server/templates/server/src/management/configuration.controller.ts.ejs +80 -0
- package/generators/node-server/templates/server/src/management/health.controller.spec.ts.ejs +79 -0
- package/generators/node-server/templates/server/src/management/health.controller.ts.ejs +87 -0
- package/generators/node-server/templates/server/src/management/health.module.ts.ejs +9 -0
- package/generators/node-server/templates/server/src/management/loggers.controller.ts.ejs +40 -0
- package/generators/node-server/templates/server/src/management/management.controller.spec.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/management/management.controller.ts.ejs +34 -0
- package/generators/node-server/templates/server/src/management/management.module.ts.ejs +21 -0
- package/generators/node-server/templates/server/src/management/metrics.controller.ts.ejs +85 -0
- package/generators/node-server/templates/server/src/migrations/1570200270081-CreateTables.ts.ejs +64 -0
- package/generators/node-server/templates/server/src/migrations/1570200270082-CreateSessions.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/migrations/1570200490072-SeedUsersRoles.ts.ejs +74 -0
- package/generators/node-server/templates/server/src/migrations/support/schema.ts.ejs +254 -0
- package/generators/node-server/templates/server/src/orm.config.ts.ejs +147 -0
- package/generators/node-server/templates/server/src/registry/consul.service.ts.ejs +70 -0
- package/generators/node-server/templates/server/src/registry/eureka.service.ts.ejs +129 -0
- package/generators/node-server/templates/server/src/swagger.ts.ejs +24 -0
- package/generators/node-server/templates/server/src/tls.ts.ejs +27 -0
- package/generators/node-server/templates/server/src/users/authority.controller.ts.ejs +85 -0
- package/generators/node-server/templates/server/src/users/authority.entity.ts.ejs +22 -0
- package/generators/node-server/templates/server/src/users/dto/authority.dto.ts.ejs +10 -0
- package/generators/node-server/templates/server/src/users/dto/user.dto.ts.ejs +116 -0
- package/generators/node-server/templates/server/src/users/public.user.controller.ts.ejs +51 -0
- package/generators/node-server/templates/server/src/users/user.controller.ts.ejs +191 -0
- package/generators/node-server/templates/server/src/users/user.entity.ts.ejs +63 -0
- package/generators/node-server/templates/server/src/users/user.mapper.ts.ejs +26 -0
- package/generators/node-server/templates/server/src/users/user.module.ts.ejs +19 -0
- package/generators/node-server/templates/server/src/users/user.service.ts.ejs +156 -0
- package/generators/node-server/templates/server/tsconfig.build.json.ejs +9 -0
- package/generators/node-server/templates/server/tsconfig.json.ejs +23 -0
- package/generators/node-server/templates/server/typeorm-migration.ts.ejs +18 -0
- package/generators/node-server/templates/server/vitest.config.e2e.ts.ejs +16 -0
- package/generators/node-server/templates/server/vitest.config.ts.ejs +16 -0
- package/generators/server/command.js +7 -0
- package/generators/server/generator.js +20 -0
- package/generators/server/generators/bootstrap/command.js +5 -0
- package/generators/server/generators/bootstrap/generator.js +15 -0
- package/generators/server/generators/bootstrap/index.js +2 -0
- package/generators/server/index.js +2 -0
- package/package.json +75 -4
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
|
|
2
|
+
import { hibernateSnakeCase } from 'generator-jhipster/generators/server/support';
|
|
3
|
+
import { prepareSqlApplicationProperties } from 'generator-jhipster/generators/spring-boot/generators/data-relational/support';
|
|
4
|
+
|
|
5
|
+
import { SERVER_NODEJS_SRC_DIR } from '../../../generator-nodejs-constants.js';
|
|
6
|
+
|
|
7
|
+
export default class extends BaseApplicationGenerator {
|
|
8
|
+
constructor(args, opts, features) {
|
|
9
|
+
super(args, opts, { ...features, sbsBlueprint: true });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async beforeQueue() {
|
|
13
|
+
// Node server is a Typescript server, we need typescript preparation.
|
|
14
|
+
await this.dependsOnBootstrap('client');
|
|
15
|
+
await this.dependsOnBootstrap('server');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get [BaseApplicationGenerator.LOADING]() {
|
|
19
|
+
return this.asLoadingTaskGroup({
|
|
20
|
+
async loadingTemplateTask({ applicationDefaults }) {
|
|
21
|
+
applicationDefaults({
|
|
22
|
+
temporaryDir: 'tmp/',
|
|
23
|
+
dockerServicesDir: 'docker/',
|
|
24
|
+
nodeServerRootDir: `${SERVER_NODEJS_SRC_DIR}/`,
|
|
25
|
+
jhiTablePrefix: ({ jhiPrefix }) => hibernateSnakeCase(jhiPrefix),
|
|
26
|
+
clientPackageManager: 'npm',
|
|
27
|
+
dbPortValue: undefined,
|
|
28
|
+
// As in JHipster's Spring Boot application, syncUserWithIdp is disabled by default, enabled for a gateway or
|
|
29
|
+
// when an entity has a relationship with User (JHipster only derives it for a Java backend). Delayed until
|
|
30
|
+
// anyEntityHasRelationshipWithUser is defined, before JHipster derives the built-in entities from it.
|
|
31
|
+
syncUserWithIdp: ({ authenticationType, applicationType, anyEntityHasRelationshipWithUser }) =>
|
|
32
|
+
authenticationType === 'oauth2' && (applicationType === 'gateway' || anyEntityHasRelationshipWithUser),
|
|
33
|
+
// The scripts of the client run from the root package.json with --prefix, not -w (the e2e default): an application
|
|
34
|
+
// of a JHipster workspace is itself a workspace, and npm resolves -w from the root of the outer one.
|
|
35
|
+
clientNpmRun: ({ clientRootDir }) => (clientRootDir ? `npm --prefix ${clientRootDir} run` : 'npm run'),
|
|
36
|
+
clientNgCommand: ({ clientRootDir }) => (clientRootDir ? `npm --prefix ${clientRootDir} exec -- ng` : 'ng'),
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get [BaseApplicationGenerator.PREPARING]() {
|
|
43
|
+
return this.asPreparingTaskGroup({
|
|
44
|
+
prettierFolders({ application }) {
|
|
45
|
+
// The prettier:check and prettier:format scripts of the root package.json cover the server and the client
|
|
46
|
+
// workspaces (JHipster only adds the client sources, and the build plugins of Angular at the root).
|
|
47
|
+
const { nodeServerRootDir, clientRootDir } = application;
|
|
48
|
+
const folders = [nodeServerRootDir, ...['src', 'test', 'e2e', 'scripts'].map(dir => `${nodeServerRootDir}${dir}/**/`)];
|
|
49
|
+
if (application.clientFrameworkAny) {
|
|
50
|
+
folders.push(clientRootDir);
|
|
51
|
+
if (application.clientFrameworkAngular) {
|
|
52
|
+
folders.push(`${clientRootDir}build-plugins/**/`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
application.prettierFolders.push(...folders.filter(folder => !application.prettierFolders.includes(folder)));
|
|
56
|
+
},
|
|
57
|
+
preparing({ application, applicationDefaults }) {
|
|
58
|
+
if (application.databaseTypeSql) {
|
|
59
|
+
prepareSqlApplicationProperties({ application });
|
|
60
|
+
} else {
|
|
61
|
+
applicationDefaults({
|
|
62
|
+
prodDatabaseName: undefined,
|
|
63
|
+
prodDatabaseUsername: undefined,
|
|
64
|
+
prodDatabasePassword: undefined,
|
|
65
|
+
devDatabaseName: undefined,
|
|
66
|
+
devDatabaseUsername: undefined,
|
|
67
|
+
devDatabasePassword: undefined,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
get [BaseApplicationGenerator.DEFAULT]() {
|
|
75
|
+
return this.asDefaultTaskGroup({
|
|
76
|
+
postPreparing({ application }) {
|
|
77
|
+
if (application.authority) {
|
|
78
|
+
// The clients of JHipster with the screens of the built-in Authority, which their user management uses.
|
|
79
|
+
application.authority.skipClient = !application.clientFrameworkAngular && !application.clientFrameworkVue;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SERVER_NODEJS_SRC_DIR } from '../../../generator-nodejs-constants.js';
|
|
2
|
+
|
|
3
|
+
const SERVER_NODEJS_DIR = `${SERVER_NODEJS_SRC_DIR}/`;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The migrations of a changelog of this generation, like the Liquibase changelogs of its entity: for its creation its table,
|
|
7
|
+
* then its constraints when it has some; for an update its fields, then its relationships; for its removal its tables.
|
|
8
|
+
*/
|
|
9
|
+
export const migrationFiles = {
|
|
10
|
+
migrations: [
|
|
11
|
+
{
|
|
12
|
+
path: SERVER_NODEJS_DIR,
|
|
13
|
+
condition: ctx => ctx.nodejsMigration,
|
|
14
|
+
renameTo: data => `${SERVER_NODEJS_DIR}src/migrations/${data.nodejsMigration.fileName}.ts`,
|
|
15
|
+
templates: ['src/migrations/_entityMigration_.ts'],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: SERVER_NODEJS_DIR,
|
|
19
|
+
condition: ctx => ctx.nodejsConstraintsMigration,
|
|
20
|
+
renameTo: data => `${SERVER_NODEJS_DIR}src/migrations/${data.nodejsConstraintsMigration.fileName}.ts`,
|
|
21
|
+
templates: ['src/migrations/_entityConstraintsMigration_.ts'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
path: SERVER_NODEJS_DIR,
|
|
25
|
+
condition: ctx => ctx.nodejsUpdatedMigration,
|
|
26
|
+
renameTo: data => `${SERVER_NODEJS_DIR}src/migrations/${data.nodejsUpdatedMigration.fileName}.ts`,
|
|
27
|
+
templates: ['src/migrations/_entityUpdatedMigration_.ts'],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
path: SERVER_NODEJS_DIR,
|
|
31
|
+
condition: ctx => ctx.nodejsUpdatedConstraintsMigration,
|
|
32
|
+
renameTo: data => `${SERVER_NODEJS_DIR}src/migrations/${data.nodejsUpdatedConstraintsMigration.fileName}.ts`,
|
|
33
|
+
templates: ['src/migrations/_entityUpdatedConstraintsMigration_.ts'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
path: SERVER_NODEJS_DIR,
|
|
37
|
+
condition: ctx => ctx.nodejsRemovedMigration,
|
|
38
|
+
renameTo: data => `${SERVER_NODEJS_DIR}src/migrations/${data.nodejsRemovedMigration.fileName}.ts`,
|
|
39
|
+
templates: ['src/migrations/_entityRemovedMigration_.ts'],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
|
|
2
|
+
import {
|
|
3
|
+
CHANGELOGS_CUSTOM_OBJECT,
|
|
4
|
+
changelogsCustomObject,
|
|
5
|
+
getEntityChangelogs,
|
|
6
|
+
isNewEntityChangelog,
|
|
7
|
+
} from 'generator-jhipster/generators/base-application/generators/database-changelogs/support';
|
|
8
|
+
import { CONTEXT_DATA_APPLICATION_ENTITIES_KEY } from 'generator-jhipster/generators/base-application/support';
|
|
9
|
+
|
|
10
|
+
import { changelogMigrations, migrationOfFile } from '../../support/index.js';
|
|
11
|
+
|
|
12
|
+
import { migrationFiles } from './files.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The migrations of the entities of a SQL server, like the incremental Liquibase changelogs of JHipster Spring Boot: the
|
|
16
|
+
* migrations of the changelogs of the entities JHipster records (jhipster:base-application:database-changelogs, the
|
|
17
|
+
* changelogs custom object), a creation AddedEntity and AddedEntityConstraints, an update UpdatedEntity and
|
|
18
|
+
* UpdatedEntityConstraints (see support/migrations.js). A generation writes the migrations of its own changelogs, recorded
|
|
19
|
+
* in them, and registers every one: the ones of the former changelogs as they record them, written once.
|
|
20
|
+
*/
|
|
21
|
+
export default class extends BaseApplicationGenerator {
|
|
22
|
+
/** The migrations of the changelogs of this generation, with their entity. */
|
|
23
|
+
#migrations = [];
|
|
24
|
+
|
|
25
|
+
constructor(args, options, features) {
|
|
26
|
+
// The changelogs once the entities are prepared: their migrations are written from the entities and their fields.
|
|
27
|
+
super(args, options, { ...features, customObjects: [changelogsCustomObject] });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async beforeQueue() {
|
|
31
|
+
await this.dependsOnJHipster('jhipster-nodejs:node-server:bootstrap');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The changelogs of the entities, the ones of this generation recorded (see getEntityChangelogs of JHipster). */
|
|
35
|
+
get changelogs() {
|
|
36
|
+
return getEntityChangelogs(this);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The entities of the application with a table of the server, as JHipster prepares them. */
|
|
40
|
+
get #entities() {
|
|
41
|
+
return [...this.getContextData(CONTEXT_DATA_APPLICATION_ENTITIES_KEY, { factory: () => new Map() }).values()];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get [BaseApplicationGenerator.COMPOSING]() {
|
|
45
|
+
return this.asComposingTaskGroup({
|
|
46
|
+
async composeChangelogs() {
|
|
47
|
+
await this.composeWithJHipster('jhipster:base-application:database-changelogs');
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get [BaseApplicationGenerator.objectPriority(CHANGELOGS_CUSTOM_OBJECT, 'postPreparing')]() {
|
|
53
|
+
return {
|
|
54
|
+
prepareMigrations: ({ changelogs }) => {
|
|
55
|
+
const entities = this.#entities;
|
|
56
|
+
for (const changelog of changelogs.filter(changelog => isNewEntityChangelog(this, changelog))) {
|
|
57
|
+
// The entity of a creation or an update; a removal has none, its migration written from the entity before it.
|
|
58
|
+
const entity = entities.find(entity => entity.name === changelog.entityName);
|
|
59
|
+
if (!(entity ?? changelog.previousEntity).skipServer) {
|
|
60
|
+
this.#prepareMigrations(changelog, entity, entities);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get [BaseApplicationGenerator.WRITING_OBJECTS]() {
|
|
68
|
+
return this.asWritingObjectsTaskGroup({
|
|
69
|
+
async writeMigrations({ application }) {
|
|
70
|
+
for (const { entity, migrations } of this.#migrations) {
|
|
71
|
+
await this.writeFiles({ sections: migrationFiles, context: { ...application, ...entity, ...migrations } });
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
get [BaseApplicationGenerator.POST_WRITING_OBJECTS]() {
|
|
78
|
+
return this.asPostWritingObjectsTaskGroup({
|
|
79
|
+
registerMigrations({ source }) {
|
|
80
|
+
// The migrations every changelog records, the ones of this generation included.
|
|
81
|
+
for (const changelog of this.changelogs) {
|
|
82
|
+
for (const fileName of this.getObjectConfig(changelogName(changelog))?.nodejsMigrations ?? []) {
|
|
83
|
+
source.addMigrationToNodeConfig(migrationOfFile(fileName));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The migrations of a changelog of this generation (support/migrations.js), written with its entity, and recorded in its
|
|
92
|
+
* object (nodejsMigrations), which the next generations register.
|
|
93
|
+
*/
|
|
94
|
+
#prepareMigrations(changelog, entity, entities) {
|
|
95
|
+
const migrations = changelogMigrations(changelog, entity, entities);
|
|
96
|
+
this.#migrations.push({ entity, migrations });
|
|
97
|
+
const name = changelogName(changelog);
|
|
98
|
+
this.setObjectConfig(name, {
|
|
99
|
+
...this.getObjectConfig(name),
|
|
100
|
+
nodejsMigrations: Object.values(migrations)
|
|
101
|
+
.filter(Boolean)
|
|
102
|
+
.map(migration => migration.fileName),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The name of the object of a changelog, like JHipster names it. */
|
|
108
|
+
const changelogName = ({ changelogDate, entityName }) => `${changelogDate}_${entityName}`;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
import { <%= [nodejsConstraintsMigration.foreignKeys.length > 0 && 'createForeignKeys', nodejsConstraintsMigration.joinTables.length > 0 && 'createJoinTable'].filter(Boolean).join(', ') %> } from './support/schema.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Added the constraints of the entity <%= entityClass %>: its foreign keys and its join tables, after the tables they
|
|
7
|
+
* reference.
|
|
8
|
+
*/
|
|
9
|
+
export class <%= nodejsConstraintsMigration.className %> implements MigrationInterface {
|
|
10
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
11
|
+
<%_ if (nodejsConstraintsMigration.foreignKeys.length > 0) { _%>
|
|
12
|
+
await createForeignKeys(queryRunner, '<%= nodejsConstraintsMigration.tableName %>', [
|
|
13
|
+
<%_ for (const foreignKey of nodejsConstraintsMigration.foreignKeys) { _%>
|
|
14
|
+
{ columnName: '<%= foreignKey.columnName %>', referencedTableName: '<%= foreignKey.referencedTableName %>', referencedColumnName: '<%= foreignKey.referencedColumnName %>' },
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
]);
|
|
17
|
+
<%_ } _%>
|
|
18
|
+
<%_ for (const joinTable of nodejsConstraintsMigration.joinTables) { _%>
|
|
19
|
+
await createJoinTable(
|
|
20
|
+
queryRunner,
|
|
21
|
+
'<%= joinTable.name %>',
|
|
22
|
+
<%_ for (const column of [joinTable.joinColumn, joinTable.inverseJoinColumn]) { _%>
|
|
23
|
+
{ name: '<%= column.name %>', type: <%- column.type %>, referencedTableName: '<%= column.referencedTableName %>', referencedColumnName: '<%= column.referencedColumnName %>' },
|
|
24
|
+
<%_ } _%>
|
|
25
|
+
);
|
|
26
|
+
<%_ } _%>
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
30
|
+
<%_ for (const joinTable of nodejsConstraintsMigration.joinTables) { _%>
|
|
31
|
+
await queryRunner.dropTable('<%= joinTable.name %>', true);
|
|
32
|
+
<%_ } _%>
|
|
33
|
+
<%_ if (nodejsConstraintsMigration.foreignKeys.length > 0) { _%>
|
|
34
|
+
const table = await queryRunner.getTable('<%= nodejsConstraintsMigration.tableName %>');
|
|
35
|
+
if (table) {
|
|
36
|
+
await queryRunner.dropForeignKeys(table, table.foreignKeys);
|
|
37
|
+
}
|
|
38
|
+
<%_ } _%>
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
import { auditColumns, createTable } from './support/schema.ts';
|
|
4
|
+
|
|
5
|
+
/** Added the entity <%= entityClass %>. */
|
|
6
|
+
export class <%= nodejsMigration.className %> implements MigrationInterface {
|
|
7
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
await createTable(
|
|
9
|
+
queryRunner,
|
|
10
|
+
'<%= nodejsMigration.tableName %>',
|
|
11
|
+
[
|
|
12
|
+
...auditColumns(queryRunner),
|
|
13
|
+
<%_ for (const column of nodejsMigration.columns) { _%>
|
|
14
|
+
{ name: '<%= column.name %>', type: <%- column.type %><% if (column.enum) { %>, enum: <%- column.enum %><% } %><% if (column.length) { %>, length: <%= column.length %><% } %><% if (column.precision) { %>, precision: <%= column.precision %>, scale: <%= column.scale %><% } %><% if (column.primary) { %>, primary: true, generated: '<%= column.generated %>'<% } %><% if (column.nullable) { %>, nullable: true<% } %><% if (column.unique) { %>, unique: true<% } %> },
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
],
|
|
17
|
+
<%_ if (nodejsMigration.relationUniques.length > 0) { _%>
|
|
18
|
+
{ relationUniques: [<%- nodejsMigration.relationUniques.map(name => `'${name}'`).join(', ') %>] },
|
|
19
|
+
<%_ } _%>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
24
|
+
await queryRunner.dropTable('<%= nodejsMigration.tableName %>', true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
/** Removed the entity <%= nodejsRemovedMigration.entityName %>: its join tables and its table dropped. */
|
|
4
|
+
export class <%= nodejsRemovedMigration.className %> implements MigrationInterface {
|
|
5
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
6
|
+
<%_ for (const name of nodejsRemovedMigration.joinTables) { _%>
|
|
7
|
+
await queryRunner.dropTable('<%= name %>', true);
|
|
8
|
+
<%_ } _%>
|
|
9
|
+
await queryRunner.dropTable('<%= nodejsRemovedMigration.tableName %>', true);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(_queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
// The table of the removed entity and its join tables are not restored, nor their values.
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
<%_ if (nodejsUpdatedConstraintsMigration.schemaImports) { _%>
|
|
3
|
+
|
|
4
|
+
import { <%= nodejsUpdatedConstraintsMigration.schemaImports %> } from './support/schema.ts';
|
|
5
|
+
<%_ } _%>
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Updated the relationships of the entity <%= entityClass %>: the join columns, their foreign keys and the join tables of its
|
|
9
|
+
* removed relationships dropped, the ones of its added relationships.
|
|
10
|
+
*/
|
|
11
|
+
export class <%= nodejsUpdatedConstraintsMigration.className %> implements MigrationInterface {
|
|
12
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
<%_ for (const name of nodejsUpdatedConstraintsMigration.removedJoinTables) { _%>
|
|
14
|
+
await queryRunner.dropTable('<%= name %>', true);
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
<%_ if (nodejsUpdatedConstraintsMigration.removedJoinColumnNames) { _%>
|
|
17
|
+
await dropColumns(queryRunner, '<%= nodejsUpdatedConstraintsMigration.tableName %>', <%- nodejsUpdatedConstraintsMigration.removedJoinColumnNames %>);
|
|
18
|
+
<%_ } _%>
|
|
19
|
+
<%_ if (nodejsUpdatedConstraintsMigration.addedJoinColumnNames) { _%>
|
|
20
|
+
await addColumns(
|
|
21
|
+
queryRunner,
|
|
22
|
+
'<%= nodejsUpdatedConstraintsMigration.tableName %>',
|
|
23
|
+
[
|
|
24
|
+
<%_ for (const column of nodejsUpdatedConstraintsMigration.addedJoinColumns) { _%>
|
|
25
|
+
{ name: '<%= column.name %>', type: <%- column.type %>, nullable: true },
|
|
26
|
+
<%_ } _%>
|
|
27
|
+
],
|
|
28
|
+
<%_ if (nodejsUpdatedConstraintsMigration.relationUniques) { _%>
|
|
29
|
+
{ relationUniques: <%- nodejsUpdatedConstraintsMigration.relationUniques %> },
|
|
30
|
+
<%_ } _%>
|
|
31
|
+
);
|
|
32
|
+
await createForeignKeys(queryRunner, '<%= nodejsUpdatedConstraintsMigration.tableName %>', [
|
|
33
|
+
<%_ for (const foreignKey of nodejsUpdatedConstraintsMigration.addedForeignKeys) { _%>
|
|
34
|
+
{ columnName: '<%= foreignKey.columnName %>', referencedTableName: '<%= foreignKey.referencedTableName %>', referencedColumnName: '<%= foreignKey.referencedColumnName %>' },
|
|
35
|
+
<%_ } _%>
|
|
36
|
+
]);
|
|
37
|
+
<%_ } _%>
|
|
38
|
+
<%_ for (const joinTable of nodejsUpdatedConstraintsMigration.addedJoinTables) { _%>
|
|
39
|
+
await createJoinTable(
|
|
40
|
+
queryRunner,
|
|
41
|
+
'<%= joinTable.name %>',
|
|
42
|
+
<%_ for (const column of [joinTable.joinColumn, joinTable.inverseJoinColumn]) { _%>
|
|
43
|
+
{ name: '<%= column.name %>', type: <%- column.type %>, referencedTableName: '<%= column.referencedTableName %>', referencedColumnName: '<%= column.referencedColumnName %>' },
|
|
44
|
+
<%_ } _%>
|
|
45
|
+
);
|
|
46
|
+
<%_ } _%>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async down(<%= nodejsUpdatedConstraintsMigration.addedJoinColumnNames || nodejsUpdatedConstraintsMigration.addedJoinTables.length > 0 ? '' : '_' %>queryRunner: QueryRunner): Promise<void> {
|
|
50
|
+
<%_ if (nodejsUpdatedConstraintsMigration.removedJoinColumnNames || nodejsUpdatedConstraintsMigration.removedJoinTables.length > 0) { _%>
|
|
51
|
+
// The join columns and the join tables of the removed relationships are not restored, nor their values.
|
|
52
|
+
<%_ } _%>
|
|
53
|
+
<%_ for (const joinTable of nodejsUpdatedConstraintsMigration.addedJoinTables) { _%>
|
|
54
|
+
await queryRunner.dropTable('<%= joinTable.name %>', true);
|
|
55
|
+
<%_ } _%>
|
|
56
|
+
<%_ if (nodejsUpdatedConstraintsMigration.addedJoinColumnNames) { _%>
|
|
57
|
+
await dropColumns(queryRunner, '<%= nodejsUpdatedConstraintsMigration.tableName %>', <%- nodejsUpdatedConstraintsMigration.addedJoinColumnNames %>);
|
|
58
|
+
<%_ } _%>
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
import { <%= nodejsUpdatedMigration.schemaImports %> } from './support/schema.ts';
|
|
4
|
+
|
|
5
|
+
/** Updated the fields of the entity <%= entityClass %>: the columns of its added fields, the ones of its removed fields dropped. */
|
|
6
|
+
export class <%= nodejsUpdatedMigration.className %> implements MigrationInterface {
|
|
7
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
<%_ if (nodejsUpdatedMigration.addedColumnNames) { _%>
|
|
9
|
+
await addColumns(queryRunner, '<%= nodejsUpdatedMigration.tableName %>', [
|
|
10
|
+
<%_ for (const column of nodejsUpdatedMigration.addedColumns) { _%>
|
|
11
|
+
{ name: '<%= column.name %>', type: <%- column.type %><% if (column.enum) { %>, enum: <%- column.enum %><% } %><% if (column.length) { %>, length: <%= column.length %><% } %><% if (column.precision) { %>, precision: <%= column.precision %>, scale: <%= column.scale %><% } %><% if (column.nullable) { %>, nullable: true<% } %><% if (column.unique) { %>, unique: true<% } %> },
|
|
12
|
+
<%_ } _%>
|
|
13
|
+
]);
|
|
14
|
+
<%_ } _%>
|
|
15
|
+
<%_ if (nodejsUpdatedMigration.removedColumnNames) { _%>
|
|
16
|
+
await dropColumns(queryRunner, '<%= nodejsUpdatedMigration.tableName %>', <%- nodejsUpdatedMigration.removedColumnNames %>);
|
|
17
|
+
<%_ } _%>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async down(<%= nodejsUpdatedMigration.addedColumnNames ? '' : '_' %>queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
<%_ if (nodejsUpdatedMigration.removedColumnNames) { _%>
|
|
22
|
+
// The columns of the removed fields are not restored, nor their values.
|
|
23
|
+
<%_ } _%>
|
|
24
|
+
<%_ if (nodejsUpdatedMigration.addedColumnNames) { _%>
|
|
25
|
+
await dropColumns(queryRunner, '<%= nodejsUpdatedMigration.tableName %>', <%- nodejsUpdatedMigration.addedColumnNames %>);
|
|
26
|
+
<%_ } _%>
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@nestjs-modules/mailer": "3.0.2",
|
|
4
|
+
"@nestjs/axios": "12.0.1",
|
|
5
|
+
"@nestjs/common": "12.2.0",
|
|
6
|
+
"@nestjs/config": "12.0.1",
|
|
7
|
+
"@nestjs/core": "12.2.0",
|
|
8
|
+
"@nestjs/jwt": "12.0.3",
|
|
9
|
+
"@nestjs/passport": "12.0.0",
|
|
10
|
+
"@nestjs/platform-express": "12.2.0",
|
|
11
|
+
"@nestjs/schedule": "12.0.2",
|
|
12
|
+
"@nestjs/serve-static": "12.0.0",
|
|
13
|
+
"@nestjs/swagger": "12.0.4",
|
|
14
|
+
"@nestjs/terminus": "12.1.0",
|
|
15
|
+
"@nestjs/typeorm": "12.0.2",
|
|
16
|
+
"@rocketsoftware/eureka-js-client": "4.5.9",
|
|
17
|
+
"bcrypt": "6.0.0",
|
|
18
|
+
"better-sqlite3": "13.0.3",
|
|
19
|
+
"class-transformer": "0.5.1",
|
|
20
|
+
"class-validator": "0.15.1",
|
|
21
|
+
"cloud-config-client": "1.6.2",
|
|
22
|
+
"consul": "2.0.1",
|
|
23
|
+
"dotenv": "18.0.9",
|
|
24
|
+
"express": "5.3.0",
|
|
25
|
+
"express-session": "1.19.0",
|
|
26
|
+
"handlebars": "4.7.10",
|
|
27
|
+
"js-yaml": "5.5.0",
|
|
28
|
+
"jwks-rsa": "4.1.0",
|
|
29
|
+
"jwt-decode": "4.0.0",
|
|
30
|
+
"mongodb": "7.7.0",
|
|
31
|
+
"mongodb-memory-server": "11.3.0",
|
|
32
|
+
"mssql": "12.7.13",
|
|
33
|
+
"mysql2": "3.24.6",
|
|
34
|
+
"oracledb": "7.0.1",
|
|
35
|
+
"passport": "0.7.0",
|
|
36
|
+
"passport-jwt": "4.0.1",
|
|
37
|
+
"passport-oauth2": "1.8.0",
|
|
38
|
+
"pg": "8.23.1",
|
|
39
|
+
"prom-client": "15.1.3",
|
|
40
|
+
"qs": "6.16.1",
|
|
41
|
+
"reflect-metadata": "0.2.2",
|
|
42
|
+
"rxjs": "7.8.2",
|
|
43
|
+
"swagger-ui-express": "5.0.1",
|
|
44
|
+
"typeorm": "1.1.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@eslint/js": "10.0.1",
|
|
48
|
+
"@nestjs/cli": "12.0.10",
|
|
49
|
+
"@nestjs/schematics": "12.0.9",
|
|
50
|
+
"@nestjs/testing": "12.2.0",
|
|
51
|
+
"@types/bcrypt": "6.0.0",
|
|
52
|
+
"@types/express": "5.0.6",
|
|
53
|
+
"@types/express-serve-static-core": "5.1.3",
|
|
54
|
+
"@types/express-session": "1.19.0",
|
|
55
|
+
"@types/node": "24.19.2",
|
|
56
|
+
"@types/passport": "1.0.17",
|
|
57
|
+
"@types/passport-jwt": "4.0.1",
|
|
58
|
+
"@types/passport-oauth2": "1.8.0",
|
|
59
|
+
"@types/qs": "6.15.1",
|
|
60
|
+
"@types/superagent": "8.1.11",
|
|
61
|
+
"@types/supertest": "7.2.1",
|
|
62
|
+
"@vitest/coverage-v8": "5.0.5",
|
|
63
|
+
"eslint": "10.13.0",
|
|
64
|
+
"eslint-config-prettier": "10.1.8",
|
|
65
|
+
"eslint-plugin-prettier": "5.5.7",
|
|
66
|
+
"globals": "17.13.0",
|
|
67
|
+
"rimraf": "5.0.10",
|
|
68
|
+
"sonarqube-scanner": "5.0.2",
|
|
69
|
+
"supertest": "7.3.1",
|
|
70
|
+
"typescript": "6.0.3",
|
|
71
|
+
"typescript-eslint": "8.72.1",
|
|
72
|
+
"vite": "8.3.5",
|
|
73
|
+
"vitest": "5.0.5"
|
|
74
|
+
},
|
|
75
|
+
"packageManager": "npm@11"
|
|
76
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fake values of the fields of an entity as the API exchanges them, the values of the JSON of JHipster Spring Boot,
|
|
3
|
+
* for the tests storing an entity in the database and reading it back.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** The value of a field in a request and in the response reading it back. */
|
|
7
|
+
export const apiFakeValue = field => {
|
|
8
|
+
// An ISO-8601 duration (PT10M), the JSON of a Duration of JHipster Spring Boot.
|
|
9
|
+
if (field.fieldType === 'Duration') return field.generateFakeData('cypress');
|
|
10
|
+
const value = field.generateFakeData('json-serializable');
|
|
11
|
+
// The text of a TextBlob, a String of JHipster Spring Boot: json-serializable gives the base64 of any byte[].
|
|
12
|
+
if (field.fieldTypeBlobContent === 'text' && typeof value === 'string') return Buffer.from(value, 'base64').toString();
|
|
13
|
+
// Seconds without milliseconds: the datetime columns of MySQL do not keep them.
|
|
14
|
+
if (value instanceof Date) return `${value.toISOString().slice(0, 19)}.000Z`;
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** The content type of a binary blob, like the JHipster clients send it. */
|
|
19
|
+
const contentTypeOf = field => (field.fieldTypeBlobContent === 'image' ? 'image/png' : 'application/octet-stream');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The values of the fields of an entity in a request (and their content types), and the fields compared approximately:
|
|
23
|
+
* a Float is a single precision number of some databases (MySQL).
|
|
24
|
+
*/
|
|
25
|
+
export const apiFakeEntity = entity => {
|
|
26
|
+
const values = {};
|
|
27
|
+
for (const field of entity.fields.filter(field => !field.id && !field.transient && !field.autoGenerate)) {
|
|
28
|
+
const value = apiFakeValue(field);
|
|
29
|
+
if (value === undefined || value === null) continue;
|
|
30
|
+
values[field.fieldName] = value;
|
|
31
|
+
if (['byte[]', 'ByteBuffer'].includes(field.fieldType) && field.fieldTypeBlobContent !== 'text') {
|
|
32
|
+
values[`${field.fieldName}ContentType`] = contentTypeOf(field);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const approximateFields = entity.fields
|
|
36
|
+
.filter(field => field.fieldType === 'Float' && field.fieldName in values)
|
|
37
|
+
.map(field => field.fieldName);
|
|
38
|
+
return { values, approximateFields };
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The mutations of a relationship of an entity: the values of the related record its relationship test of the database
|
|
43
|
+
* end-to-end tests posts, as the API exchanges them, drawn with a seed of that test. JHipster keeps the unique values of a
|
|
44
|
+
* field for the whole generation: the same seed in every test would draw them again, until a unique field is left without
|
|
45
|
+
* one (from the fifth relationship to the same entity).
|
|
46
|
+
*/
|
|
47
|
+
export const mutateRelatedValues = entity => ({
|
|
48
|
+
__override__: false,
|
|
49
|
+
nodejsRelatedValues: ({ otherEntity, propertyName }) => {
|
|
50
|
+
if (otherEntity.builtIn) return undefined;
|
|
51
|
+
otherEntity.resetFakerSeed(`nodejs-database-e2e-${entity.entityInstance}-${propertyName}`);
|
|
52
|
+
return apiFakeEntity(otherEntity).values;
|
|
53
|
+
},
|
|
54
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** The precision and the scale of a BigDecimal column of JHipster Spring Boot (decimal(21,2)). */
|
|
2
|
+
export const bigDecimalPrecision = { precision: 21, scale: 2 };
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The transformer of the column of a field (src/common/database/column-transformers.ts), so the API gives the values of the
|
|
6
|
+
* JSON of JHipster Spring Boot whatever the SQL database: undefined when the driver gives them already.
|
|
7
|
+
* - number: a bigint or a decimal, which the PostgreSQL and MySQL drivers give as a string;
|
|
8
|
+
* - duration: the nanoseconds of a bigint column, an ISO-8601 duration (PT1H30M) in the API;
|
|
9
|
+
* - blob: a blob column, which the drivers give as a Buffer, the base64 or text string the API received.
|
|
10
|
+
*/
|
|
11
|
+
export const columnTransformer = ({ fieldType, nodejsColumnType }) => {
|
|
12
|
+
if (fieldType === 'Duration') return 'duration';
|
|
13
|
+
if (['Long', 'BigDecimal'].includes(fieldType)) return 'number';
|
|
14
|
+
if (nodejsColumnType === 'blob') return 'blob';
|
|
15
|
+
return undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The databases with column types of JHipster Spring Boot better-sqlite3 (dev and test) has not, chosen at runtime by
|
|
20
|
+
* src/common/database/column-types.ts: the long blobs and texts and the microseconds of MySQL and MariaDB.
|
|
21
|
+
*/
|
|
22
|
+
const runtimeColumnTypeDatabases = ['mysql', 'mariadb'];
|
|
23
|
+
|
|
24
|
+
/** Whether the columns of an application get their types at runtime (see runtimeColumnTypeDatabases). */
|
|
25
|
+
export const hasRuntimeColumnTypes = ({ databaseTypeSql, prodDatabaseType }) =>
|
|
26
|
+
Boolean(databaseTypeSql) && runtimeColumnTypeDatabases.includes(prodDatabaseType);
|
|
27
|
+
|
|
28
|
+
/** Whether the column of a field has a type chosen at runtime: a blob, a text, or the precision of an instant. */
|
|
29
|
+
const runtimeColumnType = field => ['blob', 'text'].includes(field.nodejsColumnType);
|
|
30
|
+
const runtimeDatetimePrecision = field => ['Instant', 'ZonedDateTime'].includes(field.fieldType);
|
|
31
|
+
|
|
32
|
+
/** The helpers of src/common/database/column-types.ts the @Column decorator of a field uses. */
|
|
33
|
+
export const fieldColumnTypeImports = (field, application) => {
|
|
34
|
+
if (!hasRuntimeColumnTypes(application)) return [];
|
|
35
|
+
return [runtimeColumnType(field) && 'columnType', runtimeDatetimePrecision(field) && 'datetimePrecision'].filter(Boolean);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The options of the @Column decorator of a field. A MongoDB column has no name: TypeORM writes the documents by the names
|
|
40
|
+
* of the properties and reads them by the names of the columns, so a document would be read without its fields.
|
|
41
|
+
*/
|
|
42
|
+
export const fieldColumnOptions = (field, application) => {
|
|
43
|
+
const { databaseTypeSql } = application;
|
|
44
|
+
const { fieldValidationRequired: required, fieldValidationUnique: unique, fieldValidationMaxlength: maxlength } = field;
|
|
45
|
+
const runtime = hasRuntimeColumnTypes(application);
|
|
46
|
+
const options = [];
|
|
47
|
+
if (field.nodejsColumnType) {
|
|
48
|
+
options.push(
|
|
49
|
+
runtime && runtimeColumnType(field) ? `type: columnType('${field.nodejsColumnType}')` : `type: '${field.nodejsColumnType}'`,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
if (runtime && runtimeDatetimePrecision(field)) options.push('precision: datetimePrecision()');
|
|
53
|
+
if (databaseTypeSql) options.push(`name: '${field.fieldNameAsDatabaseColumn}'`);
|
|
54
|
+
if (field.fieldIsEnum) {
|
|
55
|
+
options.push(`enum: ${field.fieldType}`);
|
|
56
|
+
} else if (field.fieldType === 'BigDecimal') {
|
|
57
|
+
options.push(`precision: ${bigDecimalPrecision.precision}`, `scale: ${bigDecimalPrecision.scale}`);
|
|
58
|
+
} else if (!['Instant', 'ZonedDateTime', 'LocalDate'].includes(field.fieldType) && maxlength) {
|
|
59
|
+
options.push(`length: ${field.fieldValidateRulesMaxlength}`);
|
|
60
|
+
}
|
|
61
|
+
if (!required) options.push('nullable: true');
|
|
62
|
+
if (unique) options.push('unique: true');
|
|
63
|
+
if (field.nodejsColumnTransformer) options.push(`transformer: ${field.nodejsColumnTransformer}Transformer`);
|
|
64
|
+
return options;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** The options of the @Column decorator of the content type of a binary blob. */
|
|
68
|
+
export const contentTypeColumnOptions = (field, { databaseTypeSql }) => {
|
|
69
|
+
return [
|
|
70
|
+
databaseTypeSql && `name: '${field.fieldNameAsDatabaseColumn}_content_type'`,
|
|
71
|
+
!field.fieldValidationRequired && 'nullable: true',
|
|
72
|
+
].filter(Boolean);
|
|
73
|
+
};
|