diff --git a/packages/core/pipeline/src/core/context.ts b/packages/core/pipeline/src/core/context.ts index 11a73a9f..e9417075 100644 --- a/packages/core/pipeline/src/core/context.ts +++ b/packages/core/pipeline/src/core/context.ts @@ -1,4 +1,5 @@ import { IStorage, MemoryStorage } from "./storage.js"; + const CONTEXT_VERSION_KEY = "contextVersion"; export interface IContext { getInt(key: string): Promise<number>; @@ -20,13 +21,11 @@ export class ContextFactory { } getContext(scope: string, namespace: string): IContext { - const context = new StorageContext(scope, namespace, this.storage); - return context; + return new StorageContext(scope, namespace, this.storage); } getMemoryContext(scope: string, namespace: string): IContext { - const context = new StorageContext(scope, namespace, this.memoryStorage); - return context; + return new StorageContext(scope, namespace, this.memoryStorage); } } diff --git a/packages/libs/huawei/.gitignore b/packages/libs/huawei/.gitignore index 9a2e4c91..b59eedaa 100644 --- a/packages/libs/huawei/.gitignore +++ b/packages/libs/huawei/.gitignore @@ -25,4 +25,4 @@ dist-ssr test/user.secret.ts -rollup.cache +.rollup.cache diff --git a/packages/libs/huawei/.npmignore b/packages/libs/huawei/.npmignore index bf40d278..ec6e82b7 100644 --- a/packages/libs/huawei/.npmignore +++ b/packages/libs/huawei/.npmignore @@ -1,2 +1,3 @@ node_modules -src \ No newline at end of file +src +.rollup.cache diff --git a/packages/libs/huawei/CHANGELOG.md b/packages/libs/huawei/CHANGELOG.md deleted file mode 100644 index 1bf3aa01..00000000 --- a/packages/libs/huawei/CHANGELOG.md +++ /dev/null @@ -1,136 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [1.21.2](https://github.com/certd/certd/compare/v1.21.1...v1.21.2) (2024-07-08) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.21.1](https://github.com/certd/certd/compare/v1.21.0...v1.21.1) (2024-07-08) - -**Note:** Version bump only for package @certd/plugin-util - -# [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.17](https://github.com/certd/certd/compare/v1.20.16...v1.20.17) (2024-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.16](https://github.com/certd/certd/compare/v1.20.15...v1.20.16) (2024-07-01) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.15](https://github.com/certd/certd/compare/v1.20.14...v1.20.15) (2024-06-28) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.14](https://github.com/certd/certd/compare/v1.20.13...v1.20.14) (2024-06-23) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.13](https://github.com/certd/certd/compare/v1.20.12...v1.20.13) (2024-06-18) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.12](https://github.com/certd/certd/compare/v1.20.10...v1.20.12) (2024-06-17) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.10](https://github.com/certd/certd/compare/v1.20.9...v1.20.10) (2024-05-30) - -### Performance Improvements - -* 优化文件下载包名 ([d9eb927](https://github.com/certd/certd/commit/d9eb927b0a1445feab08b1958aa9ea80637a5ae6)) - -## [1.20.9](https://github.com/certd/certd/compare/v1.20.8...v1.20.9) (2024-03-22) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.8](https://github.com/certd/certd/compare/v1.20.7...v1.20.8) (2024-03-22) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.7](https://github.com/certd/certd/compare/v1.20.6...v1.20.7) (2024-03-22) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.6](https://github.com/certd/certd/compare/v1.20.5...v1.20.6) (2024-03-21) - -### Performance Improvements - -* 插件贡献文档及示例 ([72fb20a](https://github.com/certd/certd/commit/72fb20abf3ba5bdd862575d2907703a52fd7eb17)) - -## [1.20.5](https://github.com/certd/certd/compare/v1.20.2...v1.20.5) (2024-03-11) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.2](https://github.com/certd/certd/compare/v1.2.1...v1.20.2) (2024-02-28) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.2.1](https://github.com/certd/certd/compare/v1.2.0...v1.2.1) (2023-12-12) - -**Note:** Version bump only for package @certd/plugin-util - -**Note:** Version bump only for package @certd/plugin-util - -# [1.2.0](https://github.com/certd/certd/compare/v1.1.6...v1.2.0) (2023-10-27) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03) - -### Performance Improvements - -* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f)) - -## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.1](https://github.com/certd/certd/compare/v1.1.0...v1.1.1) (2023-06-28) - -**Note:** Version bump only for package @certd/plugin-util - -# [1.1.0](https://github.com/certd/certd/compare/v1.0.6...v1.1.0) (2023-06-28) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.6](https://github.com/certd/certd/compare/v1.0.5...v1.0.6) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.5](https://github.com/certd/certd/compare/v1.0.4...v1.0.5) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.4](https://github.com/certd/certd/compare/v1.0.3...v1.0.4) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.3](https://github.com/certd/certd/compare/v1.0.2...v1.0.3) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.2](https://github.com/certd/certd/compare/v1.0.1...v1.0.2) (2023-05-24) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.1](https://github.com/certd/certd/compare/v1.0.0...v1.0.1) (2023-05-24) - -**Note:** Version bump only for package @certd/plugin-util diff --git a/packages/libs/huawei/package.json b/packages/libs/huawei/package.json index 663eba99..d6600ccc 100644 --- a/packages/libs/huawei/package.json +++ b/packages/libs/huawei/package.json @@ -1,7 +1,7 @@ { "name": "@certd/lib-huawei", "private": false, - "version": "1.21.0", + "version": "1.21.2", "main": "./dist/bundle.js", "module": "./dist/bundle.js", "types": "./dist/d/index.d.ts", diff --git a/packages/libs/k8s/CHANGELOG.md b/packages/libs/k8s/CHANGELOG.md deleted file mode 100644 index 55e6df7f..00000000 --- a/packages/libs/k8s/CHANGELOG.md +++ /dev/null @@ -1,128 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [1.21.0](https://github.com/certd/certd/compare/v1.20.17...v1.21.0) (2024-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.17](https://github.com/certd/certd/compare/v1.20.16...v1.20.17) (2024-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.16](https://github.com/certd/certd/compare/v1.20.15...v1.20.16) (2024-07-01) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.15](https://github.com/certd/certd/compare/v1.20.14...v1.20.15) (2024-06-28) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.14](https://github.com/certd/certd/compare/v1.20.13...v1.20.14) (2024-06-23) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.13](https://github.com/certd/certd/compare/v1.20.12...v1.20.13) (2024-06-18) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.12](https://github.com/certd/certd/compare/v1.20.10...v1.20.12) (2024-06-17) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.10](https://github.com/certd/certd/compare/v1.20.9...v1.20.10) (2024-05-30) - -### Performance Improvements - -* 优化文件下载包名 ([d9eb927](https://github.com/certd/certd/commit/d9eb927b0a1445feab08b1958aa9ea80637a5ae6)) - -## [1.20.9](https://github.com/certd/certd/compare/v1.20.8...v1.20.9) (2024-03-22) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.8](https://github.com/certd/certd/compare/v1.20.7...v1.20.8) (2024-03-22) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.7](https://github.com/certd/certd/compare/v1.20.6...v1.20.7) (2024-03-22) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.6](https://github.com/certd/certd/compare/v1.20.5...v1.20.6) (2024-03-21) - -### Performance Improvements - -* 插件贡献文档及示例 ([72fb20a](https://github.com/certd/certd/commit/72fb20abf3ba5bdd862575d2907703a52fd7eb17)) - -## [1.20.5](https://github.com/certd/certd/compare/v1.20.2...v1.20.5) (2024-03-11) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.20.2](https://github.com/certd/certd/compare/v1.2.1...v1.20.2) (2024-02-28) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.2.1](https://github.com/certd/certd/compare/v1.2.0...v1.2.1) (2023-12-12) - -**Note:** Version bump only for package @certd/plugin-util - -**Note:** Version bump only for package @certd/plugin-util - -# [1.2.0](https://github.com/certd/certd/compare/v1.1.6...v1.2.0) (2023-10-27) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03) - -### Performance Improvements - -* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f)) - -## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.1.1](https://github.com/certd/certd/compare/v1.1.0...v1.1.1) (2023-06-28) - -**Note:** Version bump only for package @certd/plugin-util - -# [1.1.0](https://github.com/certd/certd/compare/v1.0.6...v1.1.0) (2023-06-28) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.6](https://github.com/certd/certd/compare/v1.0.5...v1.0.6) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.5](https://github.com/certd/certd/compare/v1.0.4...v1.0.5) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.4](https://github.com/certd/certd/compare/v1.0.3...v1.0.4) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.3](https://github.com/certd/certd/compare/v1.0.2...v1.0.3) (2023-05-25) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.2](https://github.com/certd/certd/compare/v1.0.1...v1.0.2) (2023-05-24) - -**Note:** Version bump only for package @certd/plugin-util - -## [1.0.1](https://github.com/certd/certd/compare/v1.0.0...v1.0.1) (2023-05-24) - -**Note:** Version bump only for package @certd/plugin-util diff --git a/packages/libs/midway-flyway-js/package.json b/packages/libs/midway-flyway-js/package.json index 5f42ef16..53115c7a 100644 --- a/packages/libs/midway-flyway-js/package.json +++ b/packages/libs/midway-flyway-js/package.json @@ -1,6 +1,6 @@ { "name": "@certd/midway-flyway-js", - "version": "1.21.0", + "version": "1.21.2", "description": "midway with flyway, sql upgrade way ", "private": false, "type": "module", diff --git a/packages/ui/certd-server/.env.pgdev.yaml b/packages/ui/certd-server/.env.pgdev.yaml new file mode 100644 index 00000000..f87abd42 --- /dev/null +++ b/packages/ui/certd-server/.env.pgdev.yaml @@ -0,0 +1,15 @@ +koa: + port: 7001 + +flyway: + scriptDir: './db/migration-pg' + +typeorm: + dataSource: + default: + type: postgres + host: localhost + port: 5433 + username: postgres + password: root + database: postgres diff --git a/packages/ui/certd-server/Dockerfile b/packages/ui/certd-server/Dockerfile deleted file mode 100644 index 9a46a782..00000000 --- a/packages/ui/certd-server/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM registry.cn-shenzhen.aliyuncs.com/greper/node:15.8.0-alpine - -WORKDIR /home - -COPY . . -# 如果各公司有自己的私有源,可以替换registry地址 -#RUN npm install --registry=https://registry.npmmirror.com -RUN npm install -g cnpm -RUN cnpm install -RUN npm run build - -CMD ["npm", "run", "online"] diff --git a/packages/ui/certd-server/db/migration-pg/v00001__init.sql b/packages/ui/certd-server/db/migration-pg/v00001__init.sql new file mode 100644 index 00000000..2e52ae90 --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v00001__init.sql @@ -0,0 +1,77 @@ +-- 表:sys_permission +CREATE TABLE "sys_permission" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "title" varchar(100) NOT NULL, "permission" varchar(100), "parent_id" integer NOT NULL DEFAULT (-1), "sort" integer NOT NULL, "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (1, '系统管理', 'sys', -1, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (2, '权限管理', 'sys:auth', 1, 1 ); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (3, '用户管理', 'sys:auth:user', 2, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (4, '查看', 'sys:auth:user:view', 3, 100); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (5, '权限管理', 'sys:auth:per', 2, 1 ); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (6, '查看', 'sys:auth:per:view', 5, 100); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (7, '角色管理', 'sys:auth:role', 2, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (8, '查看', 'sys:auth:role:view', 7, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (9, '修改', 'sys:auth:user:edit', 3, 300); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (10, '删除', 'sys:auth:user:remove', 3, 400); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (11, '添加', 'sys:auth:user:add', 3, 200); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (12, '修改', 'sys:auth:role:edit', 7, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (13, '删除', 'sys:auth:role:remove', 7, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (14, '添加', 'sys:auth:role:add', 7, 1); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (15, '修改', 'sys:auth:per:edit', 5, 300); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (16, '删除', 'sys:auth:per:remove', 5, 400); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (17, '添加', 'sys:auth:per:add', 5, 200); +INSERT INTO sys_permission (id, title, permission, parent_id, sort ) VALUES (18,'授权','sys:auth:role:authz',7,100); + + + +-- 表:sys_role +CREATE TABLE "sys_role" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "name" varchar(100) NOT NULL, "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); +INSERT INTO sys_role (id, name ) VALUES (1, '管理员'); +INSERT INTO sys_role (id, name ) VALUES (2, '只读角色'); + +-- 表:sys_role_permission +CREATE TABLE "sys_role_permission" ("role_id" integer NOT NULL, "permission_id" integer NOT NULL, PRIMARY KEY ("role_id", "permission_id")); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 1); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 2); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 3); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 4); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 5); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 6); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 7); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 8); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 9); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 10); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 11); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 12); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 13); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 14); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 15); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 16); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 17); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, 18); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, -1); + +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 4); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 6); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 8); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 1); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 2); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 3); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 5); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, 7); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (2, -1); + +-- 表:sys_user +CREATE TABLE "sys_user" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "username" varchar(100) NOT NULL, "password" varchar(50) NOT NULL, "nick_name" varchar(50), "avatar" varchar(255), "phone_code" varchar(20), "mobile" varchar(20), "email" varchar(100),"remark" varchar(100), "status" integer NOT NULL DEFAULT (1), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); +INSERT INTO sys_user (id, username, password, nick_name, avatar, phone_code, mobile, email, status ,remark) VALUES (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', 'admin', NULL, NULL, NULL, NULL, 1,NULL); +INSERT INTO sys_user (id, username, password, nick_name, avatar, phone_code, mobile, email, status ,remark) VALUES (2, 'readonly', 'e10adc3949ba59abbe56e057f20f883e', '只读用户', NULL, NULL, NULL, NULL, 1,'密码:123456'); + +-- 表:sys_user_role +CREATE TABLE "sys_user_role" ("role_id" integer NOT NULL, "user_id" integer NOT NULL, PRIMARY KEY ("role_id", "user_id")); +INSERT INTO sys_user_role (role_id, user_id) VALUES (1, 1); +INSERT INTO sys_user_role (role_id, user_id) VALUES (2, 2); + +-- 索引:IDX_223de54d6badbe43a5490450c3 +CREATE UNIQUE INDEX "IDX_223de54d6badbe43a5490450c3" ON "sys_role" ("name"); + +-- 索引:IDX_9e7164b2f1ea1348bc0eb0a7da +CREATE UNIQUE INDEX "IDX_9e7164b2f1ea1348bc0eb0a7da" ON "sys_user" ("username"); + + diff --git a/packages/ui/certd-server/db/migration-pg/v00002__for_pre.sql b/packages/ui/certd-server/db/migration-pg/v00002__for_pre.sql new file mode 100644 index 00000000..2628eb26 --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v00002__for_pre.sql @@ -0,0 +1,4 @@ +-- for preview 限制演示环境的数据修改 +select setval('sys_permission_id_seq', 1000); +select setval('sys_user_id_seq', 1000); +select setval('sys_role_id_seq', 1000); diff --git a/packages/ui/certd-server/db/migration-pg/v10000__certd.sql b/packages/ui/certd-server/db/migration-pg/v10000__certd.sql new file mode 100644 index 00000000..700505f7 --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v10000__certd.sql @@ -0,0 +1,24 @@ +-- +-- 由SQLiteStudio v3.3.3 产生的文件 周六 7月 3 00:38:02 2021 +-- +-- 文本编码:UTF-8 +-- + +-- 表:cd_access +CREATE TABLE "cd_access" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "name" varchar(100) NOT NULL, "type" varchar(100) NOT NULL, "setting" varchar(1024), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +-- 表:cd_cert +CREATE TABLE "cd_cert" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "domains" varchar(2048) NOT NULL, "email" varchar(100) NOT NULL, "cert_issuer_id" integer, "challenge_type" varchar(100), "challenge_dns_type" varchar(100),"challenge_access_id" integer, "country" varchar(100), "state" varchar(100), "locality" varchar(100), "organization" varchar(100), "organization_unit" varchar(100), "remark" varchar(100), "last_history_id" integer, "last_success_id" integer, "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +-- 表:cd_cert_apply_history +CREATE TABLE "cd_cert_apply_history" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "cert_id" integer NOT NULL, "success" boolean, "result" varchar(1024), "cert_crt" varchar(1024), "cert_key" varchar(1024), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +-- 表:cd_cert_issuer +CREATE TABLE "cd_cert_issuer" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "type" varchar(20) NOT NULL, "account" varchar(100) NOT NULL, "private_key" varchar(1024), "setting" varchar, "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +-- 表:cd_task +CREATE TABLE "cd_task" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "name" varchar(100), "type" varchar(100), "setting" varchar(2048), "cert_id" integer NOT NULL, "last_history_id" integer, "last_success_id" integer, "remark" varchar(100), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +-- 表:cd_task_history +CREATE TABLE "cd_task_history" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "task_id" integer NOT NULL, "cert_id" integer NOT NULL, "cert_apply_history_id" integer NOT NULL, "success" boolean, "result" varchar(2048), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + diff --git a/packages/ui/certd-server/db/migration-pg/v10001__certdv2.sql b/packages/ui/certd-server/db/migration-pg/v10001__certdv2.sql new file mode 100644 index 00000000..41dc897d --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v10001__certdv2.sql @@ -0,0 +1,7 @@ +CREATE TABLE "pi_history" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "pipeline_id" integer NOT NULL, "pipeline" varchar(40960), "status" varchar(20), "end_time" timestamp, "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +CREATE TABLE "pi_history_log" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "pipeline_id" integer NOT NULL, "history_id" integer NOT NULL, "node_id" varchar(100), "logs" varchar(40960), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +CREATE TABLE "pi_pipeline" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "title" integer NOT NULL, "content" varchar(40960) NOT NULL, "keep_history_count" integer, "remark" varchar(100), "status" varchar(100), "disabled" boolean DEFAULT (false), "last_history_time" integer, "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); + +CREATE TABLE "pi_storage" ("id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL, "user_id" integer NOT NULL, "scope" varchar NOT NULL, "namespace" varchar NOT NULL, "version" varchar(100),"key" varchar(100), "value" varchar(40960), "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)); diff --git a/packages/ui/certd-server/db/migration-pg/v10002__settings.sql b/packages/ui/certd-server/db/migration-pg/v10002__settings.sql new file mode 100644 index 00000000..011e659e --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v10002__settings.sql @@ -0,0 +1,9 @@ +CREATE TABLE "sys_settings" ( + "id" integer NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY , + "user_id" integer NOT NULL, + "key" varchar(100) NOT NULL, + "title" varchar(100) NOT NULL, + "setting" varchar(1024), + "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), + "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) +); diff --git a/packages/ui/certd-server/db/migration-pg/v10003__role_user.sql b/packages/ui/certd-server/db/migration-pg/v10003__role_user.sql new file mode 100644 index 00000000..340a9c6e --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v10003__role_user.sql @@ -0,0 +1 @@ +INSERT INTO sys_role (id, name ) VALUES (3, '普通用户'); diff --git a/packages/ui/certd-server/db/migration-pg/v10004__settings.sql b/packages/ui/certd-server/db/migration-pg/v10004__settings.sql new file mode 100644 index 00000000..3d7964dc --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v10004__settings.sql @@ -0,0 +1,20 @@ +ALTER TABLE "sys_settings" RENAME TO "user_settings"; + +CREATE TABLE "sys_settings" ( + "id" integer NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY , + "key" varchar(100) NOT NULL, + "title" varchar(100) NOT NULL, + "setting" varchar(1024), + "access" varchar(100) NOT NULL, + "create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP), + "update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP) +); + + +INSERT INTO sys_permission (title, permission, parent_id, sort ) VALUES ('系统设置', 'sys:settings', (SELECT id FROM sys_permission WHERE permission = 'sys'), 1); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, LASTVAL()); +INSERT INTO sys_permission (title, permission, parent_id, sort ) VALUES ('查看', 'sys:settings:view', (SELECT id FROM sys_permission WHERE permission = 'sys:settings'), 1); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, LASTVAL()); +INSERT INTO sys_permission (title, permission, parent_id, sort ) VALUES ('编辑', 'sys:settings:edit', (SELECT id FROM sys_permission WHERE permission = 'sys:settings'), 1); +INSERT INTO sys_role_permission (role_id, permission_id) VALUES (1, LASTVAL()); + diff --git a/packages/ui/certd-server/db/migration-pg/v10005__password2.sql b/packages/ui/certd-server/db/migration-pg/v10005__password2.sql new file mode 100644 index 00000000..6d279f03 --- /dev/null +++ b/packages/ui/certd-server/db/migration-pg/v10005__password2.sql @@ -0,0 +1,4 @@ +INSERT INTO sys_settings (key, title, setting,access) VALUES ('sys.install','安装信息','{"installTime":'|| (select (timestamp) from flyway_history where id = 1 )||'}','private'); + +ALTER TABLE sys_user ADD COLUMN password_version integer DEFAULT 1; +ALTER TABLE sys_user ADD COLUMN password_salt varchar(36); diff --git a/packages/ui/certd-server/db/readme.md b/packages/ui/certd-server/db/readme.md new file mode 100644 index 00000000..5906f85e --- /dev/null +++ b/packages/ui/certd-server/db/readme.md @@ -0,0 +1,18 @@ +AUTOINCREAMENT +GENERATED BY DEFAULT AS IDENTITY + + +datetime +timestamp + + +update sqlite_sequence set seq = 1000 where name = 'sys_role' ; +select setval('sys_role_id_seq', 1000); + + +"disabled" boolean DEFAULT (0) +"disabled" boolean DEFAULT (false) + + +last_insert_rowid() +LASTVAL() diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json index 4c0f1e75..cbfc2bd6 100644 --- a/packages/ui/certd-server/package.json +++ b/packages/ui/certd-server/package.json @@ -7,6 +7,7 @@ "scripts": { "start": "cross-env NODE_ENV=production node ./bootstrap.js", "dev": "cross-env NODE_ENV=local mwtsc --watch --run @midwayjs/mock/app", + "pgdev": "cross-env NODE_ENV=pgdev mwtsc --watch --run @midwayjs/mock/app", "test": "cross-env NODE_ENV=unittest mocha", "cov": "cross-env c8 --all --reporter=text --reporter=lcovonly npm run test", "lint": "mwts check", @@ -22,7 +23,9 @@ "@certd/acme-client": "^1.21.2", "@certd/pipeline": "^1.21.2", "@certd/plugin-cert": "^1.21.2", - "@certd/plugin-util": "^1.21.2", + "@certd/lib-huawei": "^1.21.2", + "@certd/lib-k8s": "^1.21.2", + "@certd/midway-flyway-js": "^1.21.2", "@koa/cors": "^3.4.3", "@midwayjs/bootstrap": "^3.16.2", "@midwayjs/cache": "^3.14.0", @@ -52,6 +55,7 @@ "nanoid": "^4.0.0", "node-cron": "^3.0.2", "nodemailer": "^6.9.3", + "pg": "^8.12.0", "reflect-metadata": "^0.1.13", "sqlite3": "^5.1.4", "ssh2": "^0.8.9", diff --git a/packages/ui/certd-server/src/config/config.default.ts b/packages/ui/certd-server/src/config/config.default.ts index cfadc5ee..141b68fe 100644 --- a/packages/ui/certd-server/src/config/config.default.ts +++ b/packages/ui/certd-server/src/config/config.default.ts @@ -5,6 +5,7 @@ import { MidwayConfig } from '@midwayjs/core'; // // const __filename = fileURLToPath(import.meta.url); // const __dirname = dirname(fileURLToPath(import.meta.url)); +// eslint-disable-next-line node/no-extraneous-import import { FlywayHistory } from '@certd/midway-flyway-js'; import { UserEntity } from '../modules/authority/entity/user.js'; import { PipelineEntity } from '../modules/pipeline/entity/pipeline.js'; @@ -13,6 +14,8 @@ import { PipelineEntity } from '../modules/pipeline/entity/pipeline.js'; import { mergeConfig } from './loader.js'; import { Keys } from './keys.js'; +const env = process.env.NODE_ENV || 'development'; + const keys = Keys.load(); const development = { keys: keys.cookieKeys, @@ -81,6 +84,6 @@ const development = { resetAdminPasswd: false, }, } as MidwayConfig; -mergeConfig(development, 'development'); +mergeConfig(development, env); export default development; diff --git a/packages/ui/certd-server/src/config/loader.ts b/packages/ui/certd-server/src/config/loader.ts index 2a69f6be..02b91e7a 100644 --- a/packages/ui/certd-server/src/config/loader.ts +++ b/packages/ui/certd-server/src/config/loader.ts @@ -2,6 +2,7 @@ import path from 'path'; import * as _ from 'lodash-es'; import yaml from 'js-yaml'; import fs from 'fs'; +import { logger } from '../utils/logger.js'; function parseEnv(defaultConfig: any) { const config = {}; @@ -28,6 +29,7 @@ function parseEnv(defaultConfig: any) { export function load(config, env = '') { // Get document, or throw exception on error + logger.info('load config', env); const yamlPath = path.join(process.cwd(), `.env.${env}.yaml`); const doc = yaml.load(fs.readFileSync(yamlPath, 'utf8')); _.merge(doc, parseEnv(config)); diff --git a/packages/ui/certd-server/src/modules/pipeline/service/db-storage.ts b/packages/ui/certd-server/src/modules/pipeline/service/db-storage.ts index 8aeb5541..9765d2e2 100644 --- a/packages/ui/certd-server/src/modules/pipeline/service/db-storage.ts +++ b/packages/ui/certd-server/src/modules/pipeline/service/db-storage.ts @@ -12,21 +12,11 @@ export class DbStorage implements IStorage { this.storageService = storageService; } - remove( - scope: string, - namespace: string, - version: string, - key: string - ): Promise<void> { + remove(scope: string, namespace: string, version: string, key: string): Promise<void> { throw new Error('Method not implemented.'); } - async get( - scope: string, - namespace: string, - version: string, - key: string - ): Promise<string | null> { + async get(scope: string, namespace: string, version: string, key: string): Promise<string | null> { const storageEntity = await this.storageService.get({ userId: this.userId, scope: scope, @@ -41,13 +31,7 @@ export class DbStorage implements IStorage { return null; } - async set( - scope: string, - namespace: string, - version: string, - key: string, - value: string - ): Promise<void> { + async set(scope: string, namespace: string, version: string, key: string, value: string): Promise<void> { await this.storageService.set({ userId: this.userId, scope: scope, diff --git a/packages/ui/certd-server/src/modules/pipeline/service/storage-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/storage-service.ts index 7b702de4..5469ef3c 100644 --- a/packages/ui/certd-server/src/modules/pipeline/service/storage-service.ts +++ b/packages/ui/certd-server/src/modules/pipeline/service/storage-service.ts @@ -16,13 +16,7 @@ export class StorageService extends BaseService<StorageEntity> { return this.repository; } - async get(where: { - scope: any; - namespace: any; - userId: number; - version: string; - key: string; - }) { + async get(where: { scope: any; namespace: any; userId: number; version: string; key: string }) { if (where.userId == null) { throw new Error('userId 不能为空'); } @@ -31,15 +25,7 @@ export class StorageService extends BaseService<StorageEntity> { }); } - async set(entity: { - id?: any; - scope: any; - namespace: any; - userId: number; - version: string; - value: string; - key: string; - }) { + async set(entity: { id?: any; scope: any; namespace: any; userId: number; version: string; value: string; key: string }) { entity.id = null; const query = { ...entity }; delete query.value;