oak-domain 5.1.21 → 5.1.22
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.
|
@@ -285,7 +285,7 @@ function outputContext(depGraph, sourceFile, printer, filename) {
|
|
|
285
285
|
const { statements } = sourceFile;
|
|
286
286
|
const isBackend = filename.includes('BackendRuntimeContext');
|
|
287
287
|
const statements2 = [
|
|
288
|
-
factory.createImportDeclaration(undefined, factory.createImportClause(false, factory.createIdentifier(isBackend ? "BaseBackendRuntimeContext" : "BaseFrontendRuntimeContext"), undefined), factory.createStringLiteral(
|
|
288
|
+
factory.createImportDeclaration(undefined, factory.createImportClause(false, factory.createIdentifier(isBackend ? "BaseBackendRuntimeContext" : "BaseFrontendRuntimeContext"), undefined), factory.createStringLiteral(`@${root}/context/${isBackend ? 'BackendRuntimeContext' : 'FrontendRuntimeContext'}`), undefined),
|
|
289
289
|
...statements
|
|
290
290
|
];
|
|
291
291
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
@@ -745,27 +745,34 @@ function injectDataIndexFile(dataIndexFile, briefNames, printer) {
|
|
|
745
745
|
console.log(`注入${dataIndexFile}文件成功,共注入了${briefNames.length}个初始化数据引用`);
|
|
746
746
|
}
|
|
747
747
|
/**
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* @param
|
|
751
|
-
* @param modulePageDir
|
|
748
|
+
* 将依赖项目的目录去覆盖原来的目录
|
|
749
|
+
* @param fromDir 依赖项目的目录
|
|
750
|
+
* @param toDir 当前项目的目录
|
|
752
751
|
*/
|
|
753
|
-
function
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
if (
|
|
761
|
-
|
|
762
|
-
const srcDir = join(modulePageDir, namespace, page);
|
|
763
|
-
console.log(`拷贝${srcDir}到${destDir}下`);
|
|
764
|
-
(0, fs_extra_1.copySync)(srcDir, destDir, {
|
|
765
|
-
recursive: true,
|
|
766
|
-
});
|
|
752
|
+
function tryCopyFilesRecursively(fromDir, toDir) {
|
|
753
|
+
const files = (0, fs_1.readdirSync)(fromDir);
|
|
754
|
+
files.forEach((file) => {
|
|
755
|
+
const fromFile = join(fromDir, file);
|
|
756
|
+
const toFile = join(toDir, file);
|
|
757
|
+
const stat = (0, fs_1.statSync)(fromFile);
|
|
758
|
+
if (stat.isFile()) {
|
|
759
|
+
if ((0, fs_1.existsSync)(join(toDir, file))) {
|
|
760
|
+
console.log(`覆盖文件${toFile}`);
|
|
767
761
|
}
|
|
768
|
-
|
|
762
|
+
else {
|
|
763
|
+
console.log(`拷贝文件${toFile}`);
|
|
764
|
+
}
|
|
765
|
+
(0, fs_extra_1.copySync)(fromFile, toFile, {
|
|
766
|
+
overwrite: true,
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
if (!(0, fs_1.existsSync)(toFile)) {
|
|
771
|
+
console.log(`创建文件夹${toFile}`);
|
|
772
|
+
(0, fs_extra_1.mkdirSync)(toFile);
|
|
773
|
+
}
|
|
774
|
+
tryCopyFilesRecursively(fromFile, toFile);
|
|
775
|
+
}
|
|
769
776
|
});
|
|
770
777
|
}
|
|
771
778
|
/**
|
|
@@ -792,10 +799,10 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
|
|
|
792
799
|
injectDataIndexFileBriefNames.push(briefNames[idx]);
|
|
793
800
|
}
|
|
794
801
|
}
|
|
795
|
-
//
|
|
796
|
-
const
|
|
797
|
-
if ((0, fs_1.existsSync)(
|
|
798
|
-
|
|
802
|
+
// src下面的文件是可以拷贝到项目中的
|
|
803
|
+
const srcDir = join(moduleTemplateDir, 'src');
|
|
804
|
+
if ((0, fs_1.existsSync)(srcDir)) {
|
|
805
|
+
tryCopyFilesRecursively(srcDir, join(cwd, 'src'));
|
|
799
806
|
}
|
|
800
807
|
}
|
|
801
808
|
});
|
|
@@ -3,6 +3,9 @@ import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
|
|
3
3
|
import { AttrUpdateMatrix } from './EntityDesc';
|
|
4
4
|
import { ActionDefDict } from './Action';
|
|
5
5
|
import { StyleDict } from './Style';
|
|
6
|
+
import type { IKoaBodyOptions } from 'koa-body';
|
|
7
|
+
import Koa from 'koa';
|
|
8
|
+
import KoaRouter from 'koa-router';
|
|
6
9
|
/**
|
|
7
10
|
* redis连接信息,如果是Redis集群,可以配置多个
|
|
8
11
|
*/
|
|
@@ -43,17 +46,9 @@ export type ServerConfiguration = {
|
|
|
43
46
|
methods?: string[];
|
|
44
47
|
};
|
|
45
48
|
internalExceptionMask?: string;
|
|
46
|
-
koaBody?:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
maxFileSize?: number;
|
|
50
|
-
maxFields?: number;
|
|
51
|
-
maxFieldsSize?: number;
|
|
52
|
-
uploadDir?: string;
|
|
53
|
-
keepExtensions?: boolean;
|
|
54
|
-
hashAlgorithm?: string;
|
|
55
|
-
multiples?: boolean;
|
|
56
|
-
};
|
|
49
|
+
koaBody?: IKoaBodyOptions;
|
|
50
|
+
socket?: (ctx: Koa.ParameterizedContext<any, KoaRouter.IRouterParamContext<any, {}>, any>) => {
|
|
51
|
+
url?: string;
|
|
57
52
|
};
|
|
58
53
|
};
|
|
59
54
|
/**
|
package/lib/types/Endpoint.d.ts
CHANGED
|
@@ -3,10 +3,28 @@ import { IncomingHttpHeaders, IncomingMessage } from "http";
|
|
|
3
3
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
4
4
|
import { EntityDict } from "./Entity";
|
|
5
5
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
6
|
-
export
|
|
6
|
+
export type EndpointItem<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = SimpleEndpoint<ED, BackCxt> | FreeEndpoint<ED, BackCxt>;
|
|
7
|
+
export interface SimpleEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> {
|
|
7
8
|
name: string;
|
|
8
9
|
params?: string[];
|
|
9
10
|
method: 'get' | 'post' | 'put' | 'delete';
|
|
11
|
+
type?: "simple";
|
|
10
12
|
fn: (context: BackCxt, params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<any>;
|
|
11
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* 此类型的接口可能会保持长连接,逐步返回内容,所以直接控制res和req即可
|
|
16
|
+
* backendcontext也不能直接传入,在需要时调用方法开启事务
|
|
17
|
+
* 返回时可以指定contentType
|
|
18
|
+
*/
|
|
19
|
+
export interface FreeEndpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> {
|
|
20
|
+
name: string;
|
|
21
|
+
params?: string[];
|
|
22
|
+
method: 'get' | 'post' | 'put' | 'delete';
|
|
23
|
+
type: "free";
|
|
24
|
+
fn: (contextBuilder: () => Promise<BackCxt>, params: Record<string, string>, headers: IncomingHttpHeaders, req: IncomingMessage, body?: any) => Promise<{
|
|
25
|
+
headers?: Record<string, string | string[]>;
|
|
26
|
+
statusCode?: number;
|
|
27
|
+
data: any;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
12
30
|
export type Endpoint<ED extends EntityDict & BaseEntityDict, BackCxt extends AsyncContext<ED>> = EndpointItem<ED, BackCxt> | EndpointItem<ED, BackCxt>[];
|
package/lib/types/Endpoint.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-domain",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.22",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "XuChang"
|
|
6
6
|
},
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"@babel/preset-typescript": "^7.12.13",
|
|
24
24
|
"@types/assert": "^1.5.6",
|
|
25
25
|
"@types/cross-spawn": "^6.0.2",
|
|
26
|
+
"@types/koa": "^2.15.0",
|
|
27
|
+
"@types/koa-router": "^7.4.8",
|
|
26
28
|
"@types/fs-extra": "^9.0.13",
|
|
27
29
|
"@types/lodash": "^4.14.182",
|
|
28
30
|
"@types/mocha": "^8.2.0",
|
|
@@ -45,6 +47,8 @@
|
|
|
45
47
|
},
|
|
46
48
|
"dependencies": {
|
|
47
49
|
"dayjs": "^1.11.9",
|
|
50
|
+
"koa": "^2.16.1",
|
|
51
|
+
"koa-body": "^5.0.0",
|
|
48
52
|
"node-schedule": "^2.1.1",
|
|
49
53
|
"socket.io": "^4.8.1",
|
|
50
54
|
"uuid": "^9.0.0",
|