zova-module-a-bean 5.1.11 → 5.1.12
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/cli/controller/metadata/_extractGenericParams.ts +64 -0
- package/cli/controller/metadata/generate.ts +13 -6
- package/cli/controller/metadata/generateFile.ts +9 -2
- package/cli/controller/metadata/generateFileComponent.ts +9 -1
- package/cli/controller/metadata/generateFilePage.ts +11 -3
- package/cli/controller/metadata/generateMetaPage.ts +38 -10
- package/cli/controller/metadata/types.ts +1 -0
- package/cli/controller/metadata/utils.ts +28 -7
- package/dist/bean/sys.onion.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/useAopMethod.d.ts.map +1 -1
- package/dist/service/aop.d.ts.map +1 -1
- package/dist/service/onion_.d.ts.map +1 -1
- package/dist/types/aop.d.ts.map +1 -1
- package/dist/types/aopMethod.d.ts.map +1 -1
- package/dist/types/onion.d.ts.map +1 -1
- package/dist-cli/controller/metadata/_extractGenericParams.js +57 -0
- package/dist-cli/controller/metadata/generate.js +12 -6
- package/dist-cli/controller/metadata/generateFileComponent.js +9 -3
- package/dist-cli/controller/metadata/generateMetaPage.js +5 -2
- package/dist-cli/controller/metadata/utils.js +1 -1
- package/package.json +2 -2
- package/src/bean/sys.onion.ts +16 -4
- package/src/lib/useAopMethod.ts +5 -1
- package/src/service/aop.ts +28 -8
- package/src/service/onion_.ts +29 -8
- package/src/types/aop.ts +7 -1
- package/src/types/aopMethod.ts +14 -2
- package/src/types/onion.ts +14 -4
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
|
|
4
|
+
export function extractGenericParamsAndImports(filePath: string, interfaceName: string) {
|
|
5
|
+
const sourceText = fs.readFileSync(filePath, 'utf-8');
|
|
6
|
+
const sourceFile = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
7
|
+
|
|
8
|
+
// 1. Find the target interface
|
|
9
|
+
let targetInterface: ts.InterfaceDeclaration | undefined;
|
|
10
|
+
ts.forEachChild(sourceFile, node => {
|
|
11
|
+
if (ts.isInterfaceDeclaration(node) && node.name.text === interfaceName) {
|
|
12
|
+
targetInterface = node;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (!targetInterface?.typeParameters) {
|
|
16
|
+
return { genericParams: '', imports: [] as string[] };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 2. Extract generic parameters text
|
|
20
|
+
const genericParams = targetInterface.typeParameters.map(tp => tp.getText(sourceFile)).join(', ');
|
|
21
|
+
|
|
22
|
+
// 3. Collect type reference identifiers within generic parameters
|
|
23
|
+
const typeRefNames = new Set<string>();
|
|
24
|
+
const visit = (node: ts.Node) => {
|
|
25
|
+
if (ts.isTypeReferenceNode(node)) {
|
|
26
|
+
// For qualified names like A.B, only take the leftmost identifier
|
|
27
|
+
const id = ts.isQualifiedName(node.typeName) ? node.typeName.left : node.typeName;
|
|
28
|
+
typeRefNames.add(id.getText(sourceFile));
|
|
29
|
+
}
|
|
30
|
+
ts.forEachChild(node, visit);
|
|
31
|
+
};
|
|
32
|
+
targetInterface.typeParameters.forEach(tp => visit(tp));
|
|
33
|
+
|
|
34
|
+
// Exclude the generic parameter names themselves (TParentData, TComponentName, etc.)
|
|
35
|
+
for (const tp of targetInterface.typeParameters) {
|
|
36
|
+
typeRefNames.delete(tp.name.text);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 4. Match type references to import statements
|
|
40
|
+
const imports: string[] = [];
|
|
41
|
+
ts.forEachChild(sourceFile, node => {
|
|
42
|
+
if (!ts.isImportDeclaration(node)) return;
|
|
43
|
+
const clause = node.importClause;
|
|
44
|
+
if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings)) return;
|
|
45
|
+
|
|
46
|
+
const matched = clause.namedBindings.elements.map(el => el.name.text).filter(name => typeRefNames.has(name));
|
|
47
|
+
if (matched.length === 0) return;
|
|
48
|
+
|
|
49
|
+
const specifier = (node.moduleSpecifier as ts.StringLiteral).text;
|
|
50
|
+
const prefix = clause.isTypeOnly ? 'type ' : '';
|
|
51
|
+
imports.push(`import ${prefix}{ ${matched.join(', ')} } from '${specifier}';`);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return { genericParams, imports };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// // --- Demo ---
|
|
58
|
+
// const result = extractGenericParamsAndImports(
|
|
59
|
+
// import.meta.url.replace('file://', '').replace(/_extractGenericParams\.ts$/, 'controller.tsx'),
|
|
60
|
+
// 'ControllerFormFieldPresetProps',
|
|
61
|
+
// );
|
|
62
|
+
// console.log('Generic params:', result.genericParams);
|
|
63
|
+
// console.log('Imports:');
|
|
64
|
+
// result.imports.forEach(imp => console.log(' ', imp));
|
|
@@ -8,10 +8,13 @@ import path from 'node:path';
|
|
|
8
8
|
|
|
9
9
|
import type { IControllerInfo } from './types.ts';
|
|
10
10
|
|
|
11
|
+
import { extractGenericParamsAndImports } from './_extractGenericParams.ts';
|
|
11
12
|
import { generateFile } from './generateFile.ts';
|
|
12
13
|
import { generateMetaComponent } from './generateMetaComponent.ts';
|
|
13
14
|
import { generateMetaPage } from './generateMetaPage.ts';
|
|
14
15
|
|
|
16
|
+
// const __regProps = /interface Controller[^<]*Props<(.*?)>/;
|
|
17
|
+
|
|
15
18
|
export default async function (options: IMetadataCustomGenerateOptions): Promise<string> {
|
|
16
19
|
const { globFiles } = options;
|
|
17
20
|
const globFilesPage: [IGlobBeanFile, IControllerInfo][] = [];
|
|
@@ -34,7 +37,7 @@ export default async function (options: IMetadataCustomGenerateOptions): Promise
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile: IGlobBeanFile): IControllerInfo | undefined {
|
|
37
|
-
const { className, fileContent, fileNameJSRelative } = globFile;
|
|
40
|
+
const { className, fileContent, fileNameJSRelative, file } = globFile;
|
|
38
41
|
const matches = fileNameJSRelative.match(/..\/(.+?)\/(.+?)\/controller(.jsx?)$/);
|
|
39
42
|
if (!matches) return;
|
|
40
43
|
const type = matches[1];
|
|
@@ -55,10 +58,11 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
|
|
|
55
58
|
const hasModels = fileContent.includes(nameModels);
|
|
56
59
|
const hasModelValue = fileContent.includes("'vModel'");
|
|
57
60
|
// generic
|
|
58
|
-
const matchGeneric =
|
|
59
|
-
const hasGeneric = !!matchGeneric;
|
|
60
|
-
const generic = matchGeneric
|
|
61
|
-
const genericKeys =
|
|
61
|
+
const matchGeneric = hasProps && extractGenericParamsAndImports(file, nameProps); // fileContent.match(__regProps);
|
|
62
|
+
const hasGeneric = !!(matchGeneric && matchGeneric.genericParams);
|
|
63
|
+
const generic = hasGeneric ? matchGeneric.genericParams : undefined;
|
|
64
|
+
const genericKeys = hasGeneric ? matchGeneric.genericParams.split(',').map(item => item.trim().split(' ')[0]) : undefined;
|
|
65
|
+
const generateImports = hasGeneric ? matchGeneric.imports : undefined;
|
|
62
66
|
// schemaParams
|
|
63
67
|
const nameSchemaParams = `${className}SchemaParams`;
|
|
64
68
|
const hasSchemaParams = fileContent.includes(nameSchemaParams);
|
|
@@ -70,7 +74,9 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
|
|
|
70
74
|
const hasRenderFirst = fse.existsSync(fileRenderFirst);
|
|
71
75
|
const classNameRenderFirst = `Render${type === 'page' ? 'Page' : ''}${nameCapitalize}`;
|
|
72
76
|
const importRenderFirst = `import { ${classNameRenderFirst} } from '../../${type}/${name}/render.jsx';`;
|
|
73
|
-
const fileRenderOthers = globbySync(`src/${type}/${name}/render.*.tsx`, {
|
|
77
|
+
const fileRenderOthers = globbySync(`src/${type}/${name}/render.*.tsx`, {
|
|
78
|
+
cwd: options.modulePath,
|
|
79
|
+
});
|
|
74
80
|
const nameRenderOthers: string[] = fileRenderOthers.map(item => /render\.(.*)\.tsx/.exec(item)![1]);
|
|
75
81
|
const classNameRenderOthers: string[] = nameRenderOthers.map(item => `Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`);
|
|
76
82
|
const importRenderOthers: string[] = nameRenderOthers.map(
|
|
@@ -104,6 +110,7 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
|
|
|
104
110
|
hasGeneric,
|
|
105
111
|
generic,
|
|
106
112
|
genericKeys,
|
|
113
|
+
generateImports,
|
|
107
114
|
nameSchemaParams,
|
|
108
115
|
hasSchemaParams,
|
|
109
116
|
nameSchemaQuery,
|
|
@@ -9,9 +9,16 @@ import type { IControllerInfo } from './types.ts';
|
|
|
9
9
|
import { generateFileComponent } from './generateFileComponent.ts';
|
|
10
10
|
import { generateFilePage } from './generateFilePage.ts';
|
|
11
11
|
|
|
12
|
-
export async function generateFile(
|
|
12
|
+
export async function generateFile(
|
|
13
|
+
options: IMetadataCustomGenerateOptions,
|
|
14
|
+
globFile: IGlobBeanFile,
|
|
15
|
+
controllerInfo: IControllerInfo,
|
|
16
|
+
) {
|
|
13
17
|
const cli = options.cli;
|
|
14
|
-
const fileDest = path.join(
|
|
18
|
+
const fileDest = path.join(
|
|
19
|
+
options.modulePath,
|
|
20
|
+
`src/.metadata/${controllerInfo.type}/${controllerInfo.name}.ts`,
|
|
21
|
+
);
|
|
15
22
|
const content =
|
|
16
23
|
controllerInfo.type === 'page'
|
|
17
24
|
? await generateFilePage(options, globFile, controllerInfo)
|
|
@@ -26,6 +26,7 @@ export async function generateFileComponent(options: IMetadataCustomGenerateOpti
|
|
|
26
26
|
hasModelValue,
|
|
27
27
|
generic,
|
|
28
28
|
genericKeys,
|
|
29
|
+
generateImports,
|
|
29
30
|
importRenderFirst,
|
|
30
31
|
hasRenderFirst,
|
|
31
32
|
classNameRenderFirst,
|
|
@@ -34,6 +35,9 @@ export async function generateFileComponent(options: IMetadataCustomGenerateOpti
|
|
|
34
35
|
classNameStyleFirst,
|
|
35
36
|
} = controllerInfo;
|
|
36
37
|
const contentImports: string[] = [];
|
|
38
|
+
if (generateImports) {
|
|
39
|
+
contentImports.push(...generateImports);
|
|
40
|
+
}
|
|
37
41
|
const genericDeclare = hasGeneric ? `<${generic}>` : '';
|
|
38
42
|
const genericArguments = hasGeneric ? `<${genericKeys?.join(', ')}>` : '';
|
|
39
43
|
const componentOptions = hasComponentOptions ? `Controller${nameCapitalize}.$componentOptions` : '';
|
|
@@ -139,7 +143,7 @@ ${combineContentRenderAndStyle(controllerInfo, moduleName, className, genericDec
|
|
|
139
143
|
${contentComponent}
|
|
140
144
|
`;
|
|
141
145
|
// restComponent
|
|
142
|
-
await generateRestComponent(options, globFile, controllerInfo, genericDeclare, genericArguments, _contentImportTypeController);
|
|
146
|
+
await generateRestComponent(options, globFile, controllerInfo, genericDeclare, genericArguments, generateImports, _contentImportTypeController);
|
|
143
147
|
// ok
|
|
144
148
|
return content;
|
|
145
149
|
}
|
|
@@ -150,6 +154,7 @@ async function generateRestComponent(
|
|
|
150
154
|
controllerInfo: IControllerInfo,
|
|
151
155
|
genericDeclare: string,
|
|
152
156
|
genericArguments: string,
|
|
157
|
+
generateImports: string[] | null | undefined,
|
|
153
158
|
_contentImportTypeController: string[],
|
|
154
159
|
) {
|
|
155
160
|
const { cli, moduleName, modulePath } = options;
|
|
@@ -173,6 +178,9 @@ async function generateRestComponent(
|
|
|
173
178
|
contentTypeControllerPublicProps = `${contentTypeControllerPublicProps};`;
|
|
174
179
|
// import
|
|
175
180
|
const contentImports: string[] = [];
|
|
181
|
+
if (generateImports) {
|
|
182
|
+
contentImports.push(...generateImports);
|
|
183
|
+
}
|
|
176
184
|
const _contentImportTypeZova: string[] = [];
|
|
177
185
|
if (hasModels) _contentImportTypeZova.push('TypePropUpdateFromModel', 'TypePropValueFromModel');
|
|
178
186
|
if (_contentImportTypeZova.length > 0) {
|
|
@@ -5,7 +5,11 @@ import type { IControllerInfo } from './types.ts';
|
|
|
5
5
|
|
|
6
6
|
import { combineContentRenderAndStyle } from './utils.ts';
|
|
7
7
|
|
|
8
|
-
export async function generateFilePage(
|
|
8
|
+
export async function generateFilePage(
|
|
9
|
+
options: IMetadataCustomGenerateOptions,
|
|
10
|
+
globFile: IGlobBeanFile,
|
|
11
|
+
controllerInfo: IControllerInfo,
|
|
12
|
+
) {
|
|
9
13
|
const { moduleName } = options;
|
|
10
14
|
const { className } = globFile;
|
|
11
15
|
const {
|
|
@@ -23,7 +27,9 @@ export async function generateFilePage(options: IMetadataCustomGenerateOptions,
|
|
|
23
27
|
const contentImports: string[] = [];
|
|
24
28
|
// controller
|
|
25
29
|
contentImports.push("import { createZovaComponentPage } from 'zova';");
|
|
26
|
-
contentImports.push(
|
|
30
|
+
contentImports.push(
|
|
31
|
+
`import { ControllerPage${nameCapitalize} } from '../../page/${name}/controller${controllerExtJs}';`,
|
|
32
|
+
);
|
|
27
33
|
// render
|
|
28
34
|
if (hasRenderFirst) {
|
|
29
35
|
contentImports.push(importRenderFirst);
|
|
@@ -37,7 +43,9 @@ export async function generateFilePage(options: IMetadataCustomGenerateOptions,
|
|
|
37
43
|
if (hasSchemaParams) _contentImports_parts.push(nameSchemaParams);
|
|
38
44
|
if (hasSchemaQuery) _contentImports_parts.push(nameSchemaQuery);
|
|
39
45
|
if (_contentImports_parts.length > 0) {
|
|
40
|
-
contentImports.push(
|
|
46
|
+
contentImports.push(
|
|
47
|
+
`import { ${_contentImports_parts.join(', ')} } from '../../page/${name}/controller${controllerExtJs}';`,
|
|
48
|
+
);
|
|
41
49
|
}
|
|
42
50
|
//
|
|
43
51
|
const _contentRecords2_parts: string[] = [];
|
|
@@ -10,7 +10,10 @@ import type { IControllerInfo } from './types.ts';
|
|
|
10
10
|
|
|
11
11
|
import { generateRestIndex } from './utils.ts';
|
|
12
12
|
|
|
13
|
-
export async function generateMetaPage(
|
|
13
|
+
export async function generateMetaPage(
|
|
14
|
+
options: IMetadataCustomGenerateOptions,
|
|
15
|
+
globFiles: [IGlobBeanFile, IControllerInfo][],
|
|
16
|
+
) {
|
|
14
17
|
if (globFiles.length === 0) return '';
|
|
15
18
|
const { moduleName } = options;
|
|
16
19
|
const contentImports: string[] = [];
|
|
@@ -31,16 +34,27 @@ export async function generateMetaPage(options: IMetadataCustomGenerateOptions,
|
|
|
31
34
|
if (hasSchemaParams || hasSchemaQuery) {
|
|
32
35
|
contentImports.push(`import { ${namespace} } from './page/${name}.js';`);
|
|
33
36
|
// rest
|
|
34
|
-
const restIndexFileRelative = path.relative(
|
|
35
|
-
|
|
37
|
+
const restIndexFileRelative = path.relative(
|
|
38
|
+
srcDirRest,
|
|
39
|
+
path.join(options.modulePath, `src/.metadata/page/${name}.js`),
|
|
40
|
+
);
|
|
41
|
+
contentImportsRest.push(
|
|
42
|
+
`import { ${namespace} as ${namespaceRest} } from '${restIndexFileRelative}';`,
|
|
43
|
+
);
|
|
36
44
|
}
|
|
37
45
|
// controller.tsx
|
|
38
46
|
const { routePath, routeName } = _extractRoutePathOrName(options, globFile, controllerInfo);
|
|
39
47
|
// no matter that: route.meta?.absolute
|
|
40
|
-
const routePathFull = routePath
|
|
48
|
+
const routePathFull = routePath
|
|
49
|
+
? `/${moduleName.replace('-', '/')}/${routePath}`
|
|
50
|
+
: `/${moduleName.replace('-', '/')}`;
|
|
41
51
|
const routeNameFull = `${moduleName}:${routeName}`;
|
|
42
|
-
contentPathRecords.push(
|
|
43
|
-
|
|
52
|
+
contentPathRecords.push(
|
|
53
|
+
_combineContentPathRecord(routePathFull, hasSchemaParams, hasSchemaQuery, namespace),
|
|
54
|
+
);
|
|
55
|
+
contentPathRecordsRest.push(
|
|
56
|
+
_combineContentPathRecord(routePathFull, hasSchemaParams, hasSchemaQuery, namespaceRest),
|
|
57
|
+
);
|
|
44
58
|
if (!routeName) {
|
|
45
59
|
// contentPathRecords.push(_combineContentPathRecord(routePathFull, hasSchemaParams, hasSchemaQuery, className));
|
|
46
60
|
} else {
|
|
@@ -115,7 +129,11 @@ declare module 'zova-module-${moduleName}' {
|
|
|
115
129
|
return content;
|
|
116
130
|
}
|
|
117
131
|
|
|
118
|
-
async function generateRestMetaPage(
|
|
132
|
+
async function generateRestMetaPage(
|
|
133
|
+
options: IMetadataCustomGenerateOptions,
|
|
134
|
+
_contentImportsRest: string[],
|
|
135
|
+
contentPathRecordsRest: string[],
|
|
136
|
+
) {
|
|
119
137
|
if (contentPathRecordsRest.length === 0) return;
|
|
120
138
|
const { moduleName, modulePath } = options;
|
|
121
139
|
// pages
|
|
@@ -131,7 +149,11 @@ function _combineModuleNameControllerName(moduleName: string, className: string)
|
|
|
131
149
|
return `NS${toUpperCaseFirstChar(combineResourceName(className, moduleName, false, false))}`;
|
|
132
150
|
}
|
|
133
151
|
|
|
134
|
-
function _extractRoutePathOrName(
|
|
152
|
+
function _extractRoutePathOrName(
|
|
153
|
+
options: IMetadataCustomGenerateOptions,
|
|
154
|
+
_globFile: IGlobBeanFile,
|
|
155
|
+
controllerInfo: IControllerInfo,
|
|
156
|
+
) {
|
|
135
157
|
const cli = options.cli;
|
|
136
158
|
const targetFile = path.join(options.modulePath, 'src/routes.ts');
|
|
137
159
|
const content = fse.readFileSync(targetFile).toString('utf8');
|
|
@@ -146,7 +168,8 @@ function _extractRoutePathOrName(options: IMetadataCustomGenerateOptions, _globF
|
|
|
146
168
|
return (item.node as any).properties.some(prop => {
|
|
147
169
|
return (
|
|
148
170
|
prop.key.name === 'component' &&
|
|
149
|
-
(prop.value.name === controllerInfo.nameCapitalize ||
|
|
171
|
+
(prop.value.name === controllerInfo.nameCapitalize ||
|
|
172
|
+
prop.value.name === `ZPage${controllerInfo.nameCapitalize}`)
|
|
150
173
|
);
|
|
151
174
|
});
|
|
152
175
|
});
|
|
@@ -164,7 +187,12 @@ function _extractRoutePathOrName(options: IMetadataCustomGenerateOptions, _globF
|
|
|
164
187
|
return { routePath, routeName };
|
|
165
188
|
}
|
|
166
189
|
|
|
167
|
-
function _combineContentPathRecord(
|
|
190
|
+
function _combineContentPathRecord(
|
|
191
|
+
key: string,
|
|
192
|
+
hasSchemaParams,
|
|
193
|
+
hasSchemaQuery: boolean,
|
|
194
|
+
namespace: string,
|
|
195
|
+
) {
|
|
168
196
|
return `'${key}': TypePagePathSchema<${hasSchemaParams ? `${namespace}.ParamsInput` : 'undefined'},${hasSchemaQuery ? `${namespace}.QueryInput` : 'undefined'}>;`;
|
|
169
197
|
// return `'${key}': {
|
|
170
198
|
// path: ${value},
|
|
@@ -12,13 +12,24 @@ export function combineContentRenderAndStyle(
|
|
|
12
12
|
genericDeclare: string,
|
|
13
13
|
genericArguments: string,
|
|
14
14
|
) {
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
hasRenderFirst,
|
|
17
|
+
classNameRenderFirst,
|
|
18
|
+
classNameRenderOthers,
|
|
19
|
+
hasStyleFirst,
|
|
20
|
+
classNameStyleFirst,
|
|
21
|
+
classNameStyleOthers,
|
|
22
|
+
} = controllerInfo;
|
|
16
23
|
const contentControllerInterfaceRecords: string[] = [];
|
|
17
24
|
if (hasStyleFirst) {
|
|
18
|
-
contentControllerInterfaceRecords.push(
|
|
25
|
+
contentControllerInterfaceRecords.push(
|
|
26
|
+
`export interface ${classNameStyleFirst}${genericDeclare} extends ${className}${genericArguments} {}`,
|
|
27
|
+
);
|
|
19
28
|
}
|
|
20
29
|
for (const item of classNameStyleOthers) {
|
|
21
|
-
contentControllerInterfaceRecords.push(
|
|
30
|
+
contentControllerInterfaceRecords.push(
|
|
31
|
+
`export interface ${item}${genericDeclare} extends ${className}${genericArguments} {}`,
|
|
32
|
+
);
|
|
22
33
|
}
|
|
23
34
|
if (hasRenderFirst) {
|
|
24
35
|
if (hasStyleFirst) {
|
|
@@ -26,14 +37,20 @@ export function combineContentRenderAndStyle(
|
|
|
26
37
|
`export interface ${classNameRenderFirst}${genericDeclare} extends ${classNameStyleFirst}${genericArguments} {}`,
|
|
27
38
|
);
|
|
28
39
|
} else {
|
|
29
|
-
contentControllerInterfaceRecords.push(
|
|
40
|
+
contentControllerInterfaceRecords.push(
|
|
41
|
+
`export interface ${classNameRenderFirst}${genericDeclare} extends ${className}${genericArguments} {}`,
|
|
42
|
+
);
|
|
30
43
|
}
|
|
31
44
|
}
|
|
32
45
|
for (const item of classNameRenderOthers) {
|
|
33
46
|
if (hasStyleFirst) {
|
|
34
|
-
contentControllerInterfaceRecords.push(
|
|
47
|
+
contentControllerInterfaceRecords.push(
|
|
48
|
+
`export interface ${item}${genericDeclare} extends ${classNameStyleFirst}${genericArguments} {}`,
|
|
49
|
+
);
|
|
35
50
|
} else {
|
|
36
|
-
contentControllerInterfaceRecords.push(
|
|
51
|
+
contentControllerInterfaceRecords.push(
|
|
52
|
+
`export interface ${item}${genericDeclare} extends ${className}${genericArguments} {}`,
|
|
53
|
+
);
|
|
37
54
|
}
|
|
38
55
|
}
|
|
39
56
|
if (contentControllerInterfaceRecords.length === 0) return '';
|
|
@@ -42,7 +59,11 @@ export function combineContentRenderAndStyle(
|
|
|
42
59
|
}`;
|
|
43
60
|
}
|
|
44
61
|
|
|
45
|
-
export async function generateRestIndex(
|
|
62
|
+
export async function generateRestIndex(
|
|
63
|
+
options: IMetadataCustomGenerateOptions,
|
|
64
|
+
modulePath: string,
|
|
65
|
+
append: string,
|
|
66
|
+
) {
|
|
46
67
|
const { cli } = options;
|
|
47
68
|
// index
|
|
48
69
|
const fileIndex = path.join(modulePath, 'rest/index.ts');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sys.onion.d.ts","sourceRoot":"","sources":["../../src/bean/sys.onion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,MAAM,CAAC;AAE9C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sys.onion.d.ts","sourceRoot":"","sources":["../../src/bean/sys.onion.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAgB,MAAM,MAAM,CAAC;AAE9C,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAK3B,qBAEa,QAAS,SAAQ,QAAQ;IACpC,OAAO,CAAC,WAAW,CAA2B;IAE9C,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM;IAUvB,wBAAwB,CAC7B,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAAC,GAAG,CAAC,EACtD,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,EAC3B,SAAS,CAAC,EAAE,GAAG,EACf,GAAG,SAAS,EAAE,GAAG,EAAE;IAcd,qBAAqB,CAAC,IAAI,CAAC,EAAE,iBAAiB;CAGtD"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/lib/bean.ts","../src/service/onion_.ts","../src/bean/sys.onion.ts","../src/types/aopMethod.ts","../src/service/aop.ts","../src/monkeySys.ts","../src/lib/scope.ts","../src/.metadata/index.ts","../src/lib/useAopMethod.ts","../src/types/onion.ts"],"sourcesContent":["import { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorAopOptions } from '../types/aop.js';\nimport type { IDecoratorAopMethodOptions } from '../types/aopMethod.js';\n\nexport function Sys(): ClassDecorator {\n return createBeanDecorator('sys', 'sys');\n}\n\nexport function Bean(): ClassDecorator {\n return createBeanDecorator('bean', 'ctx');\n}\n\nexport function Service(): ClassDecorator {\n return createBeanDecorator('service', 'ctx');\n}\n\nexport function Store(): ClassDecorator {\n return createBeanDecorator('store', 'app');\n}\n\nexport function Tool(): ClassDecorator {\n return createBeanDecorator('tool', 'app');\n}\n\nexport function Data(): ClassDecorator {\n return createBeanDecorator('data', 'new');\n}\n\nexport function Controller(): ClassDecorator {\n return createBeanDecorator('controller', 'ctx');\n}\n\nexport function Render(): ClassDecorator {\n return createBeanDecorator('render', 'ctx');\n}\n\nexport function Style(): ClassDecorator {\n return createBeanDecorator('style', 'ctx');\n}\n\nexport function Aop(options: IDecoratorAopOptions): ClassDecorator {\n return createBeanDecorator('aop', 'sys', true, options);\n}\n\nexport function AopMethod<T extends IDecoratorAopMethodOptions>(options?: T): ClassDecorator {\n return createBeanDecorator('aopMethod', 'sys', true, options);\n}\n","import type { ISwapDepsItem } from '@cabloy/deps';\nimport type { OnionSceneMeta } from '@cabloy/module-info';\nimport type { Next } from 'zova';\n\nimport { compose as _compose } from '@cabloy/compose';\nimport { swapDeps } from '@cabloy/deps';\nimport { getOnionScenesMeta } from '@cabloy/module-info';\nimport { appResource, BeanSimple, cast, deepExtend, ProxyDisable } from 'zova';\n\nimport type {\n IOnionExecuteCustom,\n IOnionItem,\n IOnionOptionsDeps,\n IOnionOptionsEnable,\n IOnionOptionsMatch,\n IOnionSlice,\n TypeOnionOptionsMatchRule,\n} from '../types/onion.js';\n\nimport { SysOnion } from '../bean/sys.onion.js';\nimport { Service } from '../lib/bean.js';\n\n// const SymbolOnionsEnabled = Symbol('SymbolOnionsEnabled');\n// const SymbolOnionsEnabledWrapped = Symbol('SymbolOnionsEnabledWrapped');\n\n@ProxyDisable()\n@Service()\nexport class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple {\n protected sysOnion: SysOnion;\n sceneName: string;\n sceneMeta: OnionSceneMeta;\n\n onionsAll: IOnionItem<OPTIONS, ONIONNAME>[];\n\n // private [SymbolOnionsEnabled]: Record<string, IOnionSlice<OPTIONS, ONIONNAME>[]> = {};\n // private [SymbolOnionsEnabledWrapped]: Record<string, Function[]> = {};\n\n protected __init__(sceneName: string, sysOnion: SysOnion) {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n this.sysOnion = sysOnion;\n this.sceneName = sceneName;\n this.sceneMeta = getOnionScenesMeta(this.sys.meta.module.modulesMeta.modules)[this.sceneName];\n if (this.sceneMeta.optionsPackage) {\n this._initOnionsAll();\n this._swapOnions(this.onionsAll);\n }\n }\n\n private _initOnionsAll() {\n this.onionsAll = [];\n for (const moduleName in this.sys.meta.module.modulesMeta.modules) {\n const module = this.sys.meta.module.modulesMeta.modules[moduleName];\n const nodeItems = module.info.onionsMeta?.onionsConfig?.[this.sceneName];\n if (!nodeItems) continue;\n for (const itemName in nodeItems) {\n let itemOptions = nodeItems[itemName];\n // extend config\n const onionName = `${moduleName}:${itemName}`;\n const optionsConfig = this.sys.config.onions[this.sceneName]?.[onionName];\n if (optionsConfig) {\n itemOptions = deepExtend({}, itemOptions, optionsConfig);\n }\n this.onionsAll.push({\n name: onionName,\n options: itemOptions,\n } as any);\n }\n }\n }\n\n private _swapOnions(onions: IOnionItem<OPTIONS, ONIONNAME>[]) {\n swapDeps(onions as ISwapDepsItem[], {\n name: 'name',\n dependencies: item => {\n const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item).options as IOnionOptionsDeps<string>;\n return onionOptions.dependencies as any;\n },\n dependents: item => {\n const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item).options as IOnionOptionsDeps<string>;\n return onionOptions.dependents as any;\n },\n });\n }\n\n // getOnionsEnabled(selector?: string) {\n // if (!selector) selector = '';\n // if (!this[SymbolOnionsEnabled][selector]) {\n // this[SymbolOnionsEnabled][selector] = this.onionsGlobal.filter(onionSlice => {\n // const onionOptions = onionSlice.beanOptions.options as IOnionOptionsEnable & IOnionOptionsMatch<string>;\n // return this.sysOnion.checkOnionOptionsEnabled(onionOptions, selector);\n // }) as unknown as IOnionSlice<OPTIONS, ONIONNAME>[];\n // }\n // return this[SymbolOnionsEnabled][selector];\n // }\n\n // getOnionsEnabledOfMeta(beanName: string, selector?: string) {\n // return this.getOnionsEnabled(selector).filter(item => item.beanOptions.name === beanName);\n // }\n\n // getOnionsEnabledWrapped(wrapFn: Function, selector?: string) {\n // if (!selector) selector = '';\n // if (!this[SymbolOnionsEnabledWrapped][selector]) {\n // const onions = this.getOnionsEnabled(selector);\n // this[SymbolOnionsEnabledWrapped][selector] = onions.map(item => {\n // return wrapFn(item);\n // });\n // }\n // return this[SymbolOnionsEnabledWrapped][selector];\n // }\n\n // getOnionSlice(onionName: ONIONNAME): IOnionSlice<OPTIONS, ONIONNAME> {\n // return this.onionsNormal[onionName];\n // }\n\n // getOnionOptions<OPTIONS>(onionName: ONIONNAME): OPTIONS | undefined {\n // return this.getOnionSlice(onionName).beanOptions.options as OPTIONS | undefined;\n // }\n\n async loadOnionsFromPackage(selector?: string | boolean, matchThis?: any, ...matchArgs: any[]): Promise<IOnionSlice<OPTIONS, ONIONNAME>[]> {\n // onionItems\n const onionItems = this.getOnionsEnabled(this.onionsAll, selector, matchThis, ...matchArgs);\n // loadOnions\n return await this.loadOnions(onionItems, selector, matchThis, ...matchArgs);\n }\n\n async loadOnions<T>(\n onionItems: IOnionItem<OPTIONS, ONIONNAME> | IOnionItem<OPTIONS, ONIONNAME>[],\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ): Promise<IOnionSlice<OPTIONS, ONIONNAME, T>[]> {\n if (!Array.isArray(onionItems)) onionItems = [onionItems];\n if (onionItems.length === 0) return [];\n // load modules\n const moduleNames = onionItems.map(item => item.name.split(':')[0]);\n await this._loadModules(moduleNames);\n // onion slices\n const onionSlices: IOnionSlice<OPTIONS, ONIONNAME, T>[] = [];\n for (const item of onionItems) {\n const beanFullName = item.name.replace(':', `.${this.sceneName}.`);\n const beanOptions = appResource.getBean(beanFullName);\n if (!beanOptions) throw new Error(`behavior not found: ${beanFullName}`);\n // options\n let options;\n if (beanOptions.optionsPrimitive) {\n options = item.options !== undefined ? item.options : beanOptions.options;\n } else {\n options = item.options !== undefined ? deepExtend({}, beanOptions.options, item.options) : beanOptions.options;\n }\n // ok\n onionSlices.push({ name: item.name, options, beanFullName });\n }\n // optionsPackage\n if (this.sceneMeta.optionsPackage) return onionSlices;\n // swap\n this._swapOnions(onionSlices);\n // filter\n return this.getOnionsEnabled(onionSlices, selector, matchThis, ...matchArgs);\n }\n\n getOnionsEnabled<T>(\n onions: IOnionItem<OPTIONS, ONIONNAME>[],\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ): IOnionSlice<OPTIONS, ONIONNAME, T>[] {\n if (!onions) return [];\n return onions.filter(onionItem => {\n const onionOptions = onionItem.options as IOnionOptionsEnable & IOnionOptionsMatch<TypeOnionOptionsMatchRule<string>>;\n return this.sysOnion.checkOnionOptionsEnabled(onionOptions, selector, matchThis, ...matchArgs);\n }) as unknown as IOnionSlice<OPTIONS, ONIONNAME, T>[];\n }\n\n compose(onions: IOnionSlice<OPTIONS, ONIONNAME>[], executeCustom: IOnionExecuteCustom<OPTIONS, ONIONNAME>) {\n // fns\n const fns: Function[] = [];\n for (const item of onions) {\n fns.push(this._wrapOnion(item, executeCustom));\n }\n // compose\n return _compose(fns);\n }\n\n async _loadModules(moduleNames: string[]) {\n // load modules\n moduleNames = Array.from(new Set(moduleNames)).filter(item => !this.sys.meta.module.get(item));\n await this.sys.meta.module.loadModules(moduleNames);\n }\n\n /** internal */\n public _wrapOnion(item: IOnionSlice<OPTIONS, ONIONNAME>, executeCustom: IOnionExecuteCustom<OPTIONS, ONIONNAME>) {\n const fn = (data: any, next: Next) => {\n return executeCustom(item, data, next);\n };\n fn._name = item.name;\n return fn;\n }\n}\n","import { checkMeta, isNil, matchSelector } from '@cabloy/utils';\nimport { BeanBase, ProxyDisable } from 'zova';\n\nimport type { IOnionOptionsEnable, IOnionOptionsMatch, IOnionOptionsMeta, TypeOnionOptionsMatchRules } from '../types/onion.js';\n\nimport { Sys } from '../lib/bean.js';\nimport { ServiceOnion } from '../service/onion_.js';\n\n@ProxyDisable()\n@Sys()\nexport class SysOnion extends BeanBase {\n private __instances: Record<string, any> = {};\n\n protected __get__(prop: string) {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n if (!this.__instances[prop]) {\n this.__instances[prop] = this.bean._newBeanSimple(ServiceOnion, false, prop, this);\n }\n return this.__instances[prop];\n }\n\n public checkOnionOptionsEnabled(\n options: IOnionOptionsEnable & IOnionOptionsMatch<any>,\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ) {\n if (options.enable === false) return false;\n if (!this.checkOnionOptionsMeta(options.meta)) return false;\n if (isNil(selector) || selector === false) return true;\n if (isNil(options.match) && isNil(options.ignore)) return true;\n return (\n (!isNil(options.match) && __onionMatchSelector(options.match, selector, matchThis, ...matchArgs)) ||\n (!isNil(options.ignore) && !__onionMatchSelector(options.ignore, selector, matchThis, ...matchArgs))\n );\n }\n\n public checkOnionOptionsMeta(meta?: IOnionOptionsMeta) {\n return checkMeta(meta, this.sys.config.meta);\n }\n}\n\nfunction __onionMatchSelector(match: TypeOnionOptionsMatchRules<string>, selector: string | boolean, matchThis: any, ...matchArgs: any[]) {\n return matchSelector(match, selector, matchThis, ...matchArgs);\n}\n","import type { Next, NextSync, OmitNever } from 'zova';\n\nimport type { ServiceOnion } from '../service/onion_.js';\nimport type { IOnionOptionsEnable } from './onion.js';\n\nexport const SymbolDecoratorUseAopMethod = Symbol('SymbolDecoratorUseAopMethod');\nexport interface IUseAopMethodPropMetadata<T extends keyof IAopMethodRecord = never> {\n beanInstance?: any;\n onionName?: T;\n options?: Partial<IAopMethodRecord[T]>;\n}\n\nexport interface IAopMethodRecord {}\n\nexport interface IAopMethodGet {\n get(options: IDecoratorAopMethodOptions, next: NextSync, receiver: any, prop: string): any;\n}\n\nexport interface IAopMethodSet {\n set(options: IDecoratorAopMethodOptions, value: any, next: NextSync, receiver: any, prop: string): boolean;\n}\n\nexport interface IAopMethodExecute {\n execute(options: IDecoratorAopMethodOptions, args: [], next: Next | NextSync, receiver: any, prop: string): Promise<any> | any;\n}\n\nexport interface IDecoratorAopMethodOptions extends IOnionOptionsEnable {}\n\ndeclare module 'zova-module-a-bean' {\n export interface SysOnion {\n aopMethod: ServiceOnion<IDecoratorAopMethodOptions, keyof IAopMethodRecord>;\n }\n}\n\ndeclare module 'zova' {\n export interface ConfigOnions {\n aopMethod: OmitNever<IAopMethodRecord>;\n }\n\n export interface IBeanSceneRecord {\n aopMethod: never;\n }\n}\n","import type { BeanAopMethodBase, Constructable, IBeanRecord } from 'zova';\n\nimport { appMetadata, appResource, BeanBase, ProxyDisable, Use } from 'zova';\n\nimport type { IAopRecord, IDecoratorAopOptions } from '../types/aop.js';\nimport type { IOnionItem, IOnionSlice } from '../types/onion.js';\n\nimport { SysOnion } from '../bean/sys.onion.js';\nimport { Service } from '../lib/bean.js';\nimport { IAopMethodRecord, IDecoratorAopMethodOptions, IUseAopMethodPropMetadata, SymbolDecoratorUseAopMethod } from '../types/aopMethod.js';\n\ntype AopMethodsMatchedAll = Record<string, IUseAopMethodPropMetadata[]>;\n\n@ProxyDisable()\n@Service()\nexport class ServiceAop extends BeanBase {\n @Use()\n $$sysOnion: SysOnion;\n\n async findAopsMatched<T>(A: Constructable<T>): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;\n async findAopsMatched<K extends keyof IBeanRecord>(beanFullName: K): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;\n async findAopsMatched(beanFullName: string): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;\n async findAopsMatched<T>(beanFullName: Constructable<T> | string): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined> {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n // beanOptions\n const beanOptions = appResource.getBean(beanFullName as any);\n if (!beanOptions) return;\n // loadOnions\n return await this.$$sysOnion.aop.loadOnionsFromPackage(beanOptions.beanFullName);\n }\n\n async findAopMethodsMatched<T>(A: Constructable<T>): Promise<AopMethodsMatchedAll | undefined>;\n async findAopMethodsMatched<K extends keyof IBeanRecord>(beanFullName: K): Promise<AopMethodsMatchedAll | undefined>;\n async findAopMethodsMatched(beanFullName: string): Promise<AopMethodsMatchedAll | undefined>;\n async findAopMethodsMatched<T>(beanFullName: Constructable<T> | string): Promise<AopMethodsMatchedAll | undefined> {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n // beanOptions\n const beanOptions = appResource.getBean(beanFullName as any);\n if (!beanOptions) return;\n const aopMethodsMatchedAll: AopMethodsMatchedAll = {};\n const uses = appMetadata.getMetadata<Record<string, IUseAopMethodPropMetadata[]>>(SymbolDecoratorUseAopMethod, beanOptions.beanClass.prototype);\n for (const prop in uses) {\n const onionItems: IOnionItem<IDecoratorAopMethodOptions, keyof IAopMethodRecord>[] = [];\n const aopMethods: IUseAopMethodPropMetadata[] = uses[prop];\n for (const aopMethod of aopMethods) {\n onionItems.push({\n name: aopMethod.onionName as never,\n options: aopMethod.options,\n });\n }\n // load onions\n const onionSlices = await this.$$sysOnion.aopMethod.loadOnions<BeanAopMethodBase>(onionItems);\n // aopMethodsMatched\n const aopMethodsMatched: IUseAopMethodPropMetadata[] = [];\n for (const onionSlice of onionSlices) {\n const beanInstance = await this.sys.bean._getBean(onionSlice.beanFullName as any, true);\n aopMethodsMatched.push({\n onionName: onionSlice.name as any,\n beanInstance,\n options: onionSlice.options as any,\n });\n }\n aopMethodsMatchedAll[prop] = aopMethodsMatched;\n }\n return Object.keys(aopMethodsMatchedAll).length === 0 ? undefined : aopMethodsMatchedAll;\n }\n}\n","import type { IMonkeySysInitialize } from 'zova';\n\nimport { BeanSimple } from 'zova';\n\nexport class MonkeySys extends BeanSimple implements IMonkeySysInitialize {\n async sysInitialize() {\n let beansPreload: string[] = [];\n for (const moduleName in this.sys.meta.module.modulesMeta.modules) {\n const module = this.sys.meta.module.modulesMeta.modules[moduleName];\n if (!module.info.onionsMeta?.beansPreload) continue;\n beansPreload = beansPreload.concat(module.info.onionsMeta?.beansPreload);\n }\n const promises: Promise<any>[] = beansPreload.map(item => {\n return this.sys.bean._getBean(item as any, false);\n });\n await Promise.all(promises);\n }\n}\n","import { createBeanDecorator } from 'zova';\n\nexport function Scope(): ClassDecorator {\n return createBeanDecorator('scope', 'app', false);\n}\n","// eslint-disable\n/** sys: begin */\nexport * from '../bean/sys.onion.js';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-bean' {\n \n export interface SysOnion {\n /** @internal */\n get scope(): ScopeModuleABean;\n }\n\n export interface SysOnion {\n get $beanFullName(): 'a-bean.sys.onion';\n get $onionName(): 'a-bean:onion';\n \n } \n}\n/** sys: end */\n/** sys: begin */\nimport { SysOnion } from '../bean/sys.onion.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-bean.sys.onion': SysOnion;\n }\n}\n/** sys: end */\n/** service: begin */\nexport * from '../service/aop.js';\nexport * from '../service/onion_.js';\n\nimport 'zova-module-a-bean';\ndeclare module 'zova-module-a-bean' {\n \n export interface IServiceRecord {\n 'a-bean:aop': never;\n }\n\n \n}\ndeclare module 'zova-module-a-bean' {\n \n export interface ServiceAop {\n /** @internal */\n get scope(): ScopeModuleABean;\n }\n\n export interface ServiceAop {\n get $beanFullName(): 'a-bean.service.aop';\n get $onionName(): 'a-bean:aop';\n \n } \n}\n/** service: end */\n/** service: begin */\nimport { ServiceAop } from '../service/aop.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-bean.service.aop': ServiceAop;\n }\n}\n/** service: end */\n/** monkeySys: begin */\nexport * from '../monkeySys.js';\n/** monkeySys: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from '../lib/scope.js';\n\n@Scope()\nexport class ScopeModuleABean extends BeanScopeBase {}\n\nexport interface ScopeModuleABean {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-bean': ScopeModuleABean;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n","import type { MetadataKey } from 'zova';\n\nimport { appMetadata, registerMappedClassMetadataKey } from 'zova';\n\nimport type { IAopMethodRecord, IUseAopMethodPropMetadata } from '../types/aopMethod.js';\n\nimport { SymbolDecoratorUseAopMethod } from '../types/aopMethod.js';\n\nexport function UseAopMethod<T extends keyof IAopMethodRecord>(\n aopMethodName: T,\n options?: Partial<IAopMethodRecord[T]>,\n): PropertyDescriptor & MethodDecorator {\n return function (target: object, prop: MetadataKey, descriptor?: PropertyDescriptor) {\n registerMappedClassMetadataKey(target, SymbolDecoratorUseAopMethod);\n const uses = appMetadata.getOwnMetadataMap<MetadataKey, IUseAopMethodPropMetadata<T>[]>(true, SymbolDecoratorUseAopMethod, target);\n if (!uses[prop]) uses[prop] = [];\n uses[prop].push({ onionName: aopMethodName, options });\n return descriptor;\n } as any;\n}\n","import type { ZovaOnionOptionsMeta } from '@cabloy/module-info';\n\nexport const SymbolUseOnionLocal = Symbol('SymbolUseOnionLocal');\nexport const SymbolUseOnionOptions = Symbol('SymbolUseOnionOptions');\n\nexport type TypeComposer = (context: any, next?: any) => any;\n\nexport type IOnionExecuteCustom<OPTIONS, ONIONNAME> = (onionSlice: IOnionSlice<OPTIONS, ONIONNAME>, data: any, next: Function) => any;\n\nexport type TypeUseOnionGlobalBaseOptions<T> = Omit<T, 'global' | 'dependencies' | 'dependents' | 'ignore' | 'match'>;\n\nexport interface IOnionOptionsEnable {\n enable?: boolean;\n meta?: IOnionOptionsMeta;\n}\n\nexport type TypeOnionOptionsMatchFunction = (this: any, ...args: any[]) => boolean;\nexport type TypeOnionOptionsMatchRule<T> = T | RegExp | TypeOnionOptionsMatchFunction;\nexport type TypeOnionOptionsMatchRules<T> = TypeOnionOptionsMatchRule<T>[] | TypeOnionOptionsMatchRule<T>;\n\nexport interface IOnionOptionsMatch<T> {\n match?: T[] | T;\n ignore?: T[] | T;\n}\n\nexport interface IOnionOptionsDeps<T> {\n dependencies?: T[] | T;\n dependents?: T[] | T;\n}\n\nexport interface IOnionOptionsMeta extends ZovaOnionOptionsMeta {}\n\nexport interface IOnionOptionsBase<T extends string> extends IOnionOptionsEnable, IOnionOptionsMatch<TypeOnionOptionsMatchRule<T>> {}\n\nexport interface IOnionSlice<OPTIONS = unknown, ONIONNAME = string, T = unknown> {\n name: ONIONNAME;\n options: OPTIONS;\n beanFullName: string;\n beanInstance?: T;\n}\n\nexport interface IOnionItem<OPTIONS = unknown, ONIONNAME = string> {\n name: ONIONNAME;\n options?: Partial<OPTIONS>;\n}\n\nexport interface ConfigOnions {}\n\ndeclare module 'zova' {\n export interface ZovaConfig {\n onions: ConfigOnions;\n }\n}\n"],"mappings":";;;;;;;;AAEA,QAAO,oBAAO,OAAsB,MAAM;;;AAG1C,QAAO,oBAAgB,QAAc,MAAC;;AAEtC,SAAA,UAAA;;;AAGA,SAAS,QAAA;AACT,QAAA,oBAAA,SAAA,MAAA;;AAEA,SAAgB,OAAO;AACrB,QAAO,oBAAoB,QAAQ,MAAI;;;AAGzC,QAAO,oBAAkB,QAAA,MAAe;;AAExC,SAAA,aAAA;;;AAGA,SAAS,SAAA;AACT,QAAA,oBAAA,UAAA,MAAA;;AAEA,SAAgB,QAAQ;AACtB,QAAO,oBAAoB,SAAS,MAAK;;;AAG3C,QAAO,oBAAsB,OAAC,OAAA,MAAe,QAAA;;AAE7C,SAAA,UAAA,SAAA;;;;;AC/BA,IAAA,QAAO,SAAO,SAAA;AAWd,IAAE,gBAAU,SAAA,cAAA,EAAA,UAAA,SAAA,EAAA,UAAA,SAAA,EACV,QAAA,UACD,CAAC,EAAA,OAAA,WAAA,QAAmB,WAAA,QAAA,WAAA,MAAA,qBAAA,WAAA;CACnB,YAAA,GAAA,MAAkB;AAClB,QAAA,GAAW,KAAA;AACX,OAAA,WAAA,KAAA;AACA,OAAO,YAAQ,KAAS;;AAE1B,OAAS,YAAW,KAAM;;;AAMzB,MAAA,QAAa,IAAA,OAAA,KAAA,KAAA,kBAAA,MACb,OAAQ,IAAA,MAAA,0BAAA;AAEP,OAAA,WAAkB;AAClB,OAAA,YAAiB;AACjB,OAAA,YAAW,mBAAc,KAAA,IAAA,KAAA,OAAA,YAAA,QAAA,CAAA,KAAA;;AAEzB,QAAS,gBAAa;;;;;AAKtB,OAAA,YAAmB,E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
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/lib/bean.ts","../src/service/onion_.ts","../src/bean/sys.onion.ts","../src/types/aopMethod.ts","../src/service/aop.ts","../src/monkeySys.ts","../src/lib/scope.ts","../src/.metadata/index.ts","../src/lib/useAopMethod.ts","../src/types/onion.ts"],"sourcesContent":["import { createBeanDecorator } from 'zova';\n\nimport type { IDecoratorAopOptions } from '../types/aop.js';\nimport type { IDecoratorAopMethodOptions } from '../types/aopMethod.js';\n\nexport function Sys(): ClassDecorator {\n return createBeanDecorator('sys', 'sys');\n}\n\nexport function Bean(): ClassDecorator {\n return createBeanDecorator('bean', 'ctx');\n}\n\nexport function Service(): ClassDecorator {\n return createBeanDecorator('service', 'ctx');\n}\n\nexport function Store(): ClassDecorator {\n return createBeanDecorator('store', 'app');\n}\n\nexport function Tool(): ClassDecorator {\n return createBeanDecorator('tool', 'app');\n}\n\nexport function Data(): ClassDecorator {\n return createBeanDecorator('data', 'new');\n}\n\nexport function Controller(): ClassDecorator {\n return createBeanDecorator('controller', 'ctx');\n}\n\nexport function Render(): ClassDecorator {\n return createBeanDecorator('render', 'ctx');\n}\n\nexport function Style(): ClassDecorator {\n return createBeanDecorator('style', 'ctx');\n}\n\nexport function Aop(options: IDecoratorAopOptions): ClassDecorator {\n return createBeanDecorator('aop', 'sys', true, options);\n}\n\nexport function AopMethod<T extends IDecoratorAopMethodOptions>(options?: T): ClassDecorator {\n return createBeanDecorator('aopMethod', 'sys', true, options);\n}\n","import type { ISwapDepsItem } from '@cabloy/deps';\nimport type { OnionSceneMeta } from '@cabloy/module-info';\nimport type { Next } from 'zova';\n\nimport { compose as _compose } from '@cabloy/compose';\nimport { swapDeps } from '@cabloy/deps';\nimport { getOnionScenesMeta } from '@cabloy/module-info';\nimport { appResource, BeanSimple, cast, deepExtend, ProxyDisable } from 'zova';\n\nimport type {\n IOnionExecuteCustom,\n IOnionItem,\n IOnionOptionsDeps,\n IOnionOptionsEnable,\n IOnionOptionsMatch,\n IOnionSlice,\n TypeOnionOptionsMatchRule,\n} from '../types/onion.js';\n\nimport { SysOnion } from '../bean/sys.onion.js';\nimport { Service } from '../lib/bean.js';\n\n// const SymbolOnionsEnabled = Symbol('SymbolOnionsEnabled');\n// const SymbolOnionsEnabledWrapped = Symbol('SymbolOnionsEnabledWrapped');\n\n@ProxyDisable()\n@Service()\nexport class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple {\n protected sysOnion: SysOnion;\n sceneName: string;\n sceneMeta: OnionSceneMeta;\n\n onionsAll: IOnionItem<OPTIONS, ONIONNAME>[];\n\n // private [SymbolOnionsEnabled]: Record<string, IOnionSlice<OPTIONS, ONIONNAME>[]> = {};\n // private [SymbolOnionsEnabledWrapped]: Record<string, Function[]> = {};\n\n protected __init__(sceneName: string, sysOnion: SysOnion) {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n this.sysOnion = sysOnion;\n this.sceneName = sceneName;\n this.sceneMeta = getOnionScenesMeta(this.sys.meta.module.modulesMeta.modules)[this.sceneName];\n if (this.sceneMeta.optionsPackage) {\n this._initOnionsAll();\n this._swapOnions(this.onionsAll);\n }\n }\n\n private _initOnionsAll() {\n this.onionsAll = [];\n for (const moduleName in this.sys.meta.module.modulesMeta.modules) {\n const module = this.sys.meta.module.modulesMeta.modules[moduleName];\n const nodeItems = module.info.onionsMeta?.onionsConfig?.[this.sceneName];\n if (!nodeItems) continue;\n for (const itemName in nodeItems) {\n let itemOptions = nodeItems[itemName];\n // extend config\n const onionName = `${moduleName}:${itemName}`;\n const optionsConfig = this.sys.config.onions[this.sceneName]?.[onionName];\n if (optionsConfig) {\n itemOptions = deepExtend({}, itemOptions, optionsConfig);\n }\n this.onionsAll.push({\n name: onionName,\n options: itemOptions,\n } as any);\n }\n }\n }\n\n private _swapOnions(onions: IOnionItem<OPTIONS, ONIONNAME>[]) {\n swapDeps(onions as ISwapDepsItem[], {\n name: 'name',\n dependencies: item => {\n const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item)\n .options as IOnionOptionsDeps<string>;\n return onionOptions.dependencies as any;\n },\n dependents: item => {\n const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item)\n .options as IOnionOptionsDeps<string>;\n return onionOptions.dependents as any;\n },\n });\n }\n\n // getOnionsEnabled(selector?: string) {\n // if (!selector) selector = '';\n // if (!this[SymbolOnionsEnabled][selector]) {\n // this[SymbolOnionsEnabled][selector] = this.onionsGlobal.filter(onionSlice => {\n // const onionOptions = onionSlice.beanOptions.options as IOnionOptionsEnable & IOnionOptionsMatch<string>;\n // return this.sysOnion.checkOnionOptionsEnabled(onionOptions, selector);\n // }) as unknown as IOnionSlice<OPTIONS, ONIONNAME>[];\n // }\n // return this[SymbolOnionsEnabled][selector];\n // }\n\n // getOnionsEnabledOfMeta(beanName: string, selector?: string) {\n // return this.getOnionsEnabled(selector).filter(item => item.beanOptions.name === beanName);\n // }\n\n // getOnionsEnabledWrapped(wrapFn: Function, selector?: string) {\n // if (!selector) selector = '';\n // if (!this[SymbolOnionsEnabledWrapped][selector]) {\n // const onions = this.getOnionsEnabled(selector);\n // this[SymbolOnionsEnabledWrapped][selector] = onions.map(item => {\n // return wrapFn(item);\n // });\n // }\n // return this[SymbolOnionsEnabledWrapped][selector];\n // }\n\n // getOnionSlice(onionName: ONIONNAME): IOnionSlice<OPTIONS, ONIONNAME> {\n // return this.onionsNormal[onionName];\n // }\n\n // getOnionOptions<OPTIONS>(onionName: ONIONNAME): OPTIONS | undefined {\n // return this.getOnionSlice(onionName).beanOptions.options as OPTIONS | undefined;\n // }\n\n async loadOnionsFromPackage(\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ): Promise<IOnionSlice<OPTIONS, ONIONNAME>[]> {\n // onionItems\n const onionItems = this.getOnionsEnabled(this.onionsAll, selector, matchThis, ...matchArgs);\n // loadOnions\n return await this.loadOnions(onionItems, selector, matchThis, ...matchArgs);\n }\n\n async loadOnions<T>(\n onionItems: IOnionItem<OPTIONS, ONIONNAME> | IOnionItem<OPTIONS, ONIONNAME>[],\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ): Promise<IOnionSlice<OPTIONS, ONIONNAME, T>[]> {\n if (!Array.isArray(onionItems)) onionItems = [onionItems];\n if (onionItems.length === 0) return [];\n // load modules\n const moduleNames = onionItems.map(item => item.name.split(':')[0]);\n await this._loadModules(moduleNames);\n // onion slices\n const onionSlices: IOnionSlice<OPTIONS, ONIONNAME, T>[] = [];\n for (const item of onionItems) {\n const beanFullName = item.name.replace(':', `.${this.sceneName}.`);\n const beanOptions = appResource.getBean(beanFullName);\n if (!beanOptions) throw new Error(`behavior not found: ${beanFullName}`);\n // options\n let options;\n if (beanOptions.optionsPrimitive) {\n options = item.options !== undefined ? item.options : beanOptions.options;\n } else {\n options =\n item.options !== undefined\n ? deepExtend({}, beanOptions.options, item.options)\n : beanOptions.options;\n }\n // ok\n onionSlices.push({ name: item.name, options, beanFullName });\n }\n // optionsPackage\n if (this.sceneMeta.optionsPackage) return onionSlices;\n // swap\n this._swapOnions(onionSlices);\n // filter\n return this.getOnionsEnabled(onionSlices, selector, matchThis, ...matchArgs);\n }\n\n getOnionsEnabled<T>(\n onions: IOnionItem<OPTIONS, ONIONNAME>[],\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ): IOnionSlice<OPTIONS, ONIONNAME, T>[] {\n if (!onions) return [];\n return onions.filter(onionItem => {\n const onionOptions = onionItem.options as IOnionOptionsEnable &\n IOnionOptionsMatch<TypeOnionOptionsMatchRule<string>>;\n return this.sysOnion.checkOnionOptionsEnabled(\n onionOptions,\n selector,\n matchThis,\n ...matchArgs,\n );\n }) as unknown as IOnionSlice<OPTIONS, ONIONNAME, T>[];\n }\n\n compose(\n onions: IOnionSlice<OPTIONS, ONIONNAME>[],\n executeCustom: IOnionExecuteCustom<OPTIONS, ONIONNAME>,\n ) {\n // fns\n const fns: Function[] = [];\n for (const item of onions) {\n fns.push(this._wrapOnion(item, executeCustom));\n }\n // compose\n return _compose(fns);\n }\n\n async _loadModules(moduleNames: string[]) {\n // load modules\n moduleNames = Array.from(new Set(moduleNames)).filter(item => !this.sys.meta.module.get(item));\n await this.sys.meta.module.loadModules(moduleNames);\n }\n\n /** internal */\n public _wrapOnion(\n item: IOnionSlice<OPTIONS, ONIONNAME>,\n executeCustom: IOnionExecuteCustom<OPTIONS, ONIONNAME>,\n ) {\n const fn = (data: any, next: Next) => {\n return executeCustom(item, data, next);\n };\n fn._name = item.name;\n return fn;\n }\n}\n","import { checkMeta, isNil, matchSelector } from '@cabloy/utils';\nimport { BeanBase, ProxyDisable } from 'zova';\n\nimport type {\n IOnionOptionsEnable,\n IOnionOptionsMatch,\n IOnionOptionsMeta,\n TypeOnionOptionsMatchRules,\n} from '../types/onion.js';\n\nimport { Sys } from '../lib/bean.js';\nimport { ServiceOnion } from '../service/onion_.js';\n\n@ProxyDisable()\n@Sys()\nexport class SysOnion extends BeanBase {\n private __instances: Record<string, any> = {};\n\n protected __get__(prop: string) {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n if (!this.__instances[prop]) {\n this.__instances[prop] = this.bean._newBeanSimple(ServiceOnion, false, prop, this);\n }\n return this.__instances[prop];\n }\n\n public checkOnionOptionsEnabled(\n options: IOnionOptionsEnable & IOnionOptionsMatch<any>,\n selector?: string | boolean,\n matchThis?: any,\n ...matchArgs: any[]\n ) {\n if (options.enable === false) return false;\n if (!this.checkOnionOptionsMeta(options.meta)) return false;\n if (isNil(selector) || selector === false) return true;\n if (isNil(options.match) && isNil(options.ignore)) return true;\n return (\n (!isNil(options.match) &&\n __onionMatchSelector(options.match, selector, matchThis, ...matchArgs)) ||\n (!isNil(options.ignore) &&\n !__onionMatchSelector(options.ignore, selector, matchThis, ...matchArgs))\n );\n }\n\n public checkOnionOptionsMeta(meta?: IOnionOptionsMeta) {\n return checkMeta(meta, this.sys.config.meta);\n }\n}\n\nfunction __onionMatchSelector(\n match: TypeOnionOptionsMatchRules<string>,\n selector: string | boolean,\n matchThis: any,\n ...matchArgs: any[]\n) {\n return matchSelector(match, selector, matchThis, ...matchArgs);\n}\n","import type { Next, NextSync, OmitNever } from 'zova';\n\nimport type { ServiceOnion } from '../service/onion_.js';\nimport type { IOnionOptionsEnable } from './onion.js';\n\nexport const SymbolDecoratorUseAopMethod = Symbol('SymbolDecoratorUseAopMethod');\nexport interface IUseAopMethodPropMetadata<T extends keyof IAopMethodRecord = never> {\n beanInstance?: any;\n onionName?: T;\n options?: Partial<IAopMethodRecord[T]>;\n}\n\nexport interface IAopMethodRecord {}\n\nexport interface IAopMethodGet {\n get(options: IDecoratorAopMethodOptions, next: NextSync, receiver: any, prop: string): any;\n}\n\nexport interface IAopMethodSet {\n set(\n options: IDecoratorAopMethodOptions,\n value: any,\n next: NextSync,\n receiver: any,\n prop: string,\n ): boolean;\n}\n\nexport interface IAopMethodExecute {\n execute(\n options: IDecoratorAopMethodOptions,\n args: [],\n next: Next | NextSync,\n receiver: any,\n prop: string,\n ): Promise<any> | any;\n}\n\nexport interface IDecoratorAopMethodOptions extends IOnionOptionsEnable {}\n\ndeclare module 'zova-module-a-bean' {\n export interface SysOnion {\n aopMethod: ServiceOnion<IDecoratorAopMethodOptions, keyof IAopMethodRecord>;\n }\n}\n\ndeclare module 'zova' {\n export interface ConfigOnions {\n aopMethod: OmitNever<IAopMethodRecord>;\n }\n\n export interface IBeanSceneRecord {\n aopMethod: never;\n }\n}\n","import type { BeanAopMethodBase, Constructable, IBeanRecord } from 'zova';\n\nimport { appMetadata, appResource, BeanBase, ProxyDisable, Use } from 'zova';\n\nimport type { IAopRecord, IDecoratorAopOptions } from '../types/aop.js';\nimport type { IOnionItem, IOnionSlice } from '../types/onion.js';\n\nimport { SysOnion } from '../bean/sys.onion.js';\nimport { Service } from '../lib/bean.js';\nimport {\n IAopMethodRecord,\n IDecoratorAopMethodOptions,\n IUseAopMethodPropMetadata,\n SymbolDecoratorUseAopMethod,\n} from '../types/aopMethod.js';\n\ntype AopMethodsMatchedAll = Record<string, IUseAopMethodPropMetadata[]>;\n\n@ProxyDisable()\n@Service()\nexport class ServiceAop extends BeanBase {\n @Use()\n $$sysOnion: SysOnion;\n\n async findAopsMatched<T>(\n A: Constructable<T>,\n ): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;\n async findAopsMatched<K extends keyof IBeanRecord>(\n beanFullName: K,\n ): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;\n async findAopsMatched(\n beanFullName: string,\n ): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;\n async findAopsMatched<T>(\n beanFullName: Constructable<T> | string,\n ): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined> {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n // beanOptions\n const beanOptions = appResource.getBean(beanFullName as any);\n if (!beanOptions) return;\n // loadOnions\n return await this.$$sysOnion.aop.loadOnionsFromPackage(beanOptions.beanFullName);\n }\n\n async findAopMethodsMatched<T>(A: Constructable<T>): Promise<AopMethodsMatchedAll | undefined>;\n async findAopMethodsMatched<K extends keyof IBeanRecord>(\n beanFullName: K,\n ): Promise<AopMethodsMatchedAll | undefined>;\n async findAopMethodsMatched(beanFullName: string): Promise<AopMethodsMatchedAll | undefined>;\n async findAopMethodsMatched<T>(\n beanFullName: Constructable<T> | string,\n ): Promise<AopMethodsMatchedAll | undefined> {\n if (process.env.DEV && this.bean.containerType !== 'sys') {\n throw new Error('should in sys container');\n }\n // beanOptions\n const beanOptions = appResource.getBean(beanFullName as any);\n if (!beanOptions) return;\n const aopMethodsMatchedAll: AopMethodsMatchedAll = {};\n const uses = appMetadata.getMetadata<Record<string, IUseAopMethodPropMetadata[]>>(\n SymbolDecoratorUseAopMethod,\n beanOptions.beanClass.prototype,\n );\n for (const prop in uses) {\n const onionItems: IOnionItem<IDecoratorAopMethodOptions, keyof IAopMethodRecord>[] = [];\n const aopMethods: IUseAopMethodPropMetadata[] = uses[prop];\n for (const aopMethod of aopMethods) {\n onionItems.push({\n name: aopMethod.onionName as never,\n options: aopMethod.options,\n });\n }\n // load onions\n const onionSlices = await this.$$sysOnion.aopMethod.loadOnions<BeanAopMethodBase>(onionItems);\n // aopMethodsMatched\n const aopMethodsMatched: IUseAopMethodPropMetadata[] = [];\n for (const onionSlice of onionSlices) {\n const beanInstance = await this.sys.bean._getBean(onionSlice.beanFullName as any, true);\n aopMethodsMatched.push({\n onionName: onionSlice.name as any,\n beanInstance,\n options: onionSlice.options as any,\n });\n }\n aopMethodsMatchedAll[prop] = aopMethodsMatched;\n }\n return Object.keys(aopMethodsMatchedAll).length === 0 ? undefined : aopMethodsMatchedAll;\n }\n}\n","import type { IMonkeySysInitialize } from 'zova';\n\nimport { BeanSimple } from 'zova';\n\nexport class MonkeySys extends BeanSimple implements IMonkeySysInitialize {\n async sysInitialize() {\n let beansPreload: string[] = [];\n for (const moduleName in this.sys.meta.module.modulesMeta.modules) {\n const module = this.sys.meta.module.modulesMeta.modules[moduleName];\n if (!module.info.onionsMeta?.beansPreload) continue;\n beansPreload = beansPreload.concat(module.info.onionsMeta?.beansPreload);\n }\n const promises: Promise<any>[] = beansPreload.map(item => {\n return this.sys.bean._getBean(item as any, false);\n });\n await Promise.all(promises);\n }\n}\n","import { createBeanDecorator } from 'zova';\n\nexport function Scope(): ClassDecorator {\n return createBeanDecorator('scope', 'app', false);\n}\n","// eslint-disable\n/** sys: begin */\nexport * from '../bean/sys.onion.js';\n\nimport 'zova';\ndeclare module 'zova' {\n \n \n}\ndeclare module 'zova-module-a-bean' {\n \n export interface SysOnion {\n /** @internal */\n get scope(): ScopeModuleABean;\n }\n\n export interface SysOnion {\n get $beanFullName(): 'a-bean.sys.onion';\n get $onionName(): 'a-bean:onion';\n \n } \n}\n/** sys: end */\n/** sys: begin */\nimport { SysOnion } from '../bean/sys.onion.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-bean.sys.onion': SysOnion;\n }\n}\n/** sys: end */\n/** service: begin */\nexport * from '../service/aop.js';\nexport * from '../service/onion_.js';\n\nimport 'zova-module-a-bean';\ndeclare module 'zova-module-a-bean' {\n \n export interface IServiceRecord {\n 'a-bean:aop': never;\n }\n\n \n}\ndeclare module 'zova-module-a-bean' {\n \n export interface ServiceAop {\n /** @internal */\n get scope(): ScopeModuleABean;\n }\n\n export interface ServiceAop {\n get $beanFullName(): 'a-bean.service.aop';\n get $onionName(): 'a-bean:aop';\n \n } \n}\n/** service: end */\n/** service: begin */\nimport { ServiceAop } from '../service/aop.js';\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanRecordGeneral {\n 'a-bean.service.aop': ServiceAop;\n }\n}\n/** service: end */\n/** monkeySys: begin */\nexport * from '../monkeySys.js';\n/** monkeySys: end */\n/** scope: begin */\nimport { BeanScopeBase, type BeanScopeUtil } from 'zova';\nimport { Scope } from '../lib/scope.js';\n\n@Scope()\nexport class ScopeModuleABean extends BeanScopeBase {}\n\nexport interface ScopeModuleABean {\n util: BeanScopeUtil;\n}\n\nimport 'zova';\ndeclare module 'zova' {\n export interface IBeanScopeRecord {\n 'a-bean': ScopeModuleABean;\n }\n \n \n\n \n\n \n}\n \n/** scope: end */\n","import type { MetadataKey } from 'zova';\n\nimport { appMetadata, registerMappedClassMetadataKey } from 'zova';\n\nimport type { IAopMethodRecord, IUseAopMethodPropMetadata } from '../types/aopMethod.js';\n\nimport { SymbolDecoratorUseAopMethod } from '../types/aopMethod.js';\n\nexport function UseAopMethod<T extends keyof IAopMethodRecord>(\n aopMethodName: T,\n options?: Partial<IAopMethodRecord[T]>,\n): PropertyDescriptor & MethodDecorator {\n return function (target: object, prop: MetadataKey, descriptor?: PropertyDescriptor) {\n registerMappedClassMetadataKey(target, SymbolDecoratorUseAopMethod);\n const uses = appMetadata.getOwnMetadataMap<MetadataKey, IUseAopMethodPropMetadata<T>[]>(\n true,\n SymbolDecoratorUseAopMethod,\n target,\n );\n if (!uses[prop]) uses[prop] = [];\n uses[prop].push({ onionName: aopMethodName, options });\n return descriptor;\n } as any;\n}\n","import type { ZovaOnionOptionsMeta } from '@cabloy/module-info';\n\nexport const SymbolUseOnionLocal = Symbol('SymbolUseOnionLocal');\nexport const SymbolUseOnionOptions = Symbol('SymbolUseOnionOptions');\n\nexport type TypeComposer = (context: any, next?: any) => any;\n\nexport type IOnionExecuteCustom<OPTIONS, ONIONNAME> = (\n onionSlice: IOnionSlice<OPTIONS, ONIONNAME>,\n data: any,\n next: Function,\n) => any;\n\nexport type TypeUseOnionGlobalBaseOptions<T> = Omit<\n T,\n 'global' | 'dependencies' | 'dependents' | 'ignore' | 'match'\n>;\n\nexport interface IOnionOptionsEnable {\n enable?: boolean;\n meta?: IOnionOptionsMeta;\n}\n\nexport type TypeOnionOptionsMatchFunction = (this: any, ...args: any[]) => boolean;\nexport type TypeOnionOptionsMatchRule<T> = T | RegExp | TypeOnionOptionsMatchFunction;\nexport type TypeOnionOptionsMatchRules<T> =\n | TypeOnionOptionsMatchRule<T>[]\n | TypeOnionOptionsMatchRule<T>;\n\nexport interface IOnionOptionsMatch<T> {\n match?: T[] | T;\n ignore?: T[] | T;\n}\n\nexport interface IOnionOptionsDeps<T> {\n dependencies?: T[] | T;\n dependents?: T[] | T;\n}\n\nexport interface IOnionOptionsMeta extends ZovaOnionOptionsMeta {}\n\nexport interface IOnionOptionsBase<T extends string>\n extends IOnionOptionsEnable, IOnionOptionsMatch<TypeOnionOptionsMatchRule<T>> {}\n\nexport interface IOnionSlice<OPTIONS = unknown, ONIONNAME = string, T = unknown> {\n name: ONIONNAME;\n options: OPTIONS;\n beanFullName: string;\n beanInstance?: T;\n}\n\nexport interface IOnionItem<OPTIONS = unknown, ONIONNAME = string> {\n name: ONIONNAME;\n options?: Partial<OPTIONS>;\n}\n\nexport interface ConfigOnions {}\n\ndeclare module 'zova' {\n export interface ZovaConfig {\n on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3,"file":"useAopMethod.d.ts","sourceRoot":"","sources":["../../src/lib/useAopMethod.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAA6B,MAAM,uBAAuB,CAAC;AAIzF,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAC3D,aAAa,EAAE,CAAC,EAChB,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GACrC,kBAAkB,GAAG,eAAe,CAYtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aop.d.ts","sourceRoot":"","sources":["../../src/service/aop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,aAAa,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAE1E,OAAO,EAA4B,QAAQ,EAAqB,MAAM,MAAM,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,
|
|
1
|
+
{"version":3,"file":"aop.d.ts","sourceRoot":"","sources":["../../src/service/aop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,aAAa,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAE1E,OAAO,EAA4B,QAAQ,EAAqB,MAAM,MAAM,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAGL,yBAAyB,EAE1B,MAAM,uBAAuB,CAAC;AAE/B,KAAK,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAA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C;KAC5B;IAED,UAAiB,gBAAgB;QAC/B,GAAG,EAAE,KAAK,CAAC;KACZ;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aopMethod.d.ts","sourceRoot":"","sources":["../../src/types/aopMethod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AACjF,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,MAAM,gBAAgB,GAAG,KAAK;IACjF,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;CAAG;AAEpC,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,OAAO,EAAE,0BAA0B,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;CAC5F;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,
|
|
1
|
+
{"version":3,"file":"aopMethod.d.ts","sourceRoot":"","sources":["../../src/types/aopMethod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,eAAO,MAAM,2BAA2B,eAAwC,CAAC;AACjF,MAAM,WAAW,yBAAyB,CAAC,CAAC,S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ndImports(filePath, interfaceName) {
|
|
4
|
+
const sourceText = fs.readFileSync(filePath, 'utf-8');
|
|
5
|
+
const sourceFile = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
6
|
+
// 1. Find the target interface
|
|
7
|
+
let targetInterface;
|
|
8
|
+
ts.forEachChild(sourceFile, node => {
|
|
9
|
+
if (ts.isInterfaceDeclaration(node) && node.name.text === interfaceName) {
|
|
10
|
+
targetInterface = node;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if (!targetInterface?.typeParameters) {
|
|
14
|
+
return { genericParams: '', imports: [] };
|
|
15
|
+
}
|
|
16
|
+
// 2. Extract generic parameters text
|
|
17
|
+
const genericParams = targetInterface.typeParameters.map(tp => tp.getText(sourceFile)).join(', ');
|
|
18
|
+
// 3. Collect type reference identifiers within generic parameters
|
|
19
|
+
const typeRefNames = new Set();
|
|
20
|
+
const visit = (node) => {
|
|
21
|
+
if (ts.isTypeReferenceNode(node)) {
|
|
22
|
+
// For qualified names like A.B, only take the leftmost identifier
|
|
23
|
+
const id = ts.isQualifiedName(node.typeName) ? node.typeName.left : node.typeName;
|
|
24
|
+
typeRefNames.add(id.getText(sourceFile));
|
|
25
|
+
}
|
|
26
|
+
ts.forEachChild(node, visit);
|
|
27
|
+
};
|
|
28
|
+
targetInterface.typeParameters.forEach(tp => visit(tp));
|
|
29
|
+
// Exclude the generic parameter names themselves (TParentData, TComponentName, etc.)
|
|
30
|
+
for (const tp of targetInterface.typeParameters) {
|
|
31
|
+
typeRefNames.delete(tp.name.text);
|
|
32
|
+
}
|
|
33
|
+
// 4. Match type references to import statements
|
|
34
|
+
const imports = [];
|
|
35
|
+
ts.forEachChild(sourceFile, node => {
|
|
36
|
+
if (!ts.isImportDeclaration(node))
|
|
37
|
+
return;
|
|
38
|
+
const clause = node.importClause;
|
|
39
|
+
if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings))
|
|
40
|
+
return;
|
|
41
|
+
const matched = clause.namedBindings.elements.map(el => el.name.text).filter(name => typeRefNames.has(name));
|
|
42
|
+
if (matched.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
const specifier = node.moduleSpecifier.text;
|
|
45
|
+
const prefix = clause.isTypeOnly ? 'type ' : '';
|
|
46
|
+
imports.push(`import ${prefix}{ ${matched.join(', ')} } from '${specifier}';`);
|
|
47
|
+
});
|
|
48
|
+
return { genericParams, imports };
|
|
49
|
+
}
|
|
50
|
+
// // --- Demo ---
|
|
51
|
+
// const result = extractGenericParamsAndImports(
|
|
52
|
+
// import.meta.url.replace('file://', '').replace(/_extractGenericParams\.ts$/, 'controller.tsx'),
|
|
53
|
+
// 'ControllerFormFieldPresetProps',
|
|
54
|
+
// );
|
|
55
|
+
// console.log('Generic params:', result.genericParams);
|
|
56
|
+
// console.log('Imports:');
|
|
57
|
+
// result.imports.forEach(imp => console.log(' ', imp));
|
|
@@ -2,9 +2,11 @@ import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
|
2
2
|
import fse from 'fs-extra';
|
|
3
3
|
import { globbySync } from 'globby';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
+
import { extractGenericParamsAndImports } from "./_extractGenericParams.js";
|
|
5
6
|
import { generateFile } from "./generateFile.js";
|
|
6
7
|
import { generateMetaComponent } from "./generateMetaComponent.js";
|
|
7
8
|
import { generateMetaPage } from "./generateMetaPage.js";
|
|
9
|
+
// const __regProps = /interface Controller[^<]*Props<(.*?)>/;
|
|
8
10
|
export default async function (options) {
|
|
9
11
|
const { globFiles } = options;
|
|
10
12
|
const globFilesPage = [];
|
|
@@ -29,7 +31,7 @@ export default async function (options) {
|
|
|
29
31
|
return content;
|
|
30
32
|
}
|
|
31
33
|
function _parseControllerInfo(options, globFile) {
|
|
32
|
-
const { className, fileContent, fileNameJSRelative } = globFile;
|
|
34
|
+
const { className, fileContent, fileNameJSRelative, file } = globFile;
|
|
33
35
|
const matches = fileNameJSRelative.match(/..\/(.+?)\/(.+?)\/controller(.jsx?)$/);
|
|
34
36
|
if (!matches)
|
|
35
37
|
return;
|
|
@@ -52,10 +54,11 @@ function _parseControllerInfo(options, globFile) {
|
|
|
52
54
|
const hasModels = fileContent.includes(nameModels);
|
|
53
55
|
const hasModelValue = fileContent.includes("'vModel'");
|
|
54
56
|
// generic
|
|
55
|
-
const matchGeneric =
|
|
56
|
-
const hasGeneric = !!matchGeneric;
|
|
57
|
-
const generic = matchGeneric
|
|
58
|
-
const genericKeys =
|
|
57
|
+
const matchGeneric = hasProps && extractGenericParamsAndImports(file, nameProps); // fileContent.match(__regProps);
|
|
58
|
+
const hasGeneric = !!(matchGeneric && matchGeneric.genericParams);
|
|
59
|
+
const generic = hasGeneric ? matchGeneric.genericParams : undefined;
|
|
60
|
+
const genericKeys = hasGeneric ? matchGeneric.genericParams.split(',').map(item => item.trim().split(' ')[0]) : undefined;
|
|
61
|
+
const generateImports = hasGeneric ? matchGeneric.imports : undefined;
|
|
59
62
|
// schemaParams
|
|
60
63
|
const nameSchemaParams = `${className}SchemaParams`;
|
|
61
64
|
const hasSchemaParams = fileContent.includes(nameSchemaParams);
|
|
@@ -67,7 +70,9 @@ function _parseControllerInfo(options, globFile) {
|
|
|
67
70
|
const hasRenderFirst = fse.existsSync(fileRenderFirst);
|
|
68
71
|
const classNameRenderFirst = `Render${type === 'page' ? 'Page' : ''}${nameCapitalize}`;
|
|
69
72
|
const importRenderFirst = `import { ${classNameRenderFirst} } from '../../${type}/${name}/render.jsx';`;
|
|
70
|
-
const fileRenderOthers = globbySync(`src/${type}/${name}/render.*.tsx`, {
|
|
73
|
+
const fileRenderOthers = globbySync(`src/${type}/${name}/render.*.tsx`, {
|
|
74
|
+
cwd: options.modulePath,
|
|
75
|
+
});
|
|
71
76
|
const nameRenderOthers = fileRenderOthers.map(item => /render\.(.*)\.tsx/.exec(item)[1]);
|
|
72
77
|
const classNameRenderOthers = nameRenderOthers.map(item => `Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`);
|
|
73
78
|
const importRenderOthers = nameRenderOthers.map(item => `import { ${`Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`} } from '../../${type}/${name}/render.${item}.jsx';`);
|
|
@@ -97,6 +102,7 @@ function _parseControllerInfo(options, globFile) {
|
|
|
97
102
|
hasGeneric,
|
|
98
103
|
generic,
|
|
99
104
|
genericKeys,
|
|
105
|
+
generateImports,
|
|
100
106
|
nameSchemaParams,
|
|
101
107
|
hasSchemaParams,
|
|
102
108
|
nameSchemaQuery,
|
|
@@ -6,8 +6,11 @@ import { combineContentRenderAndStyle, generateRestIndex } from "./utils.js";
|
|
|
6
6
|
export async function generateFileComponent(options, globFile, controllerInfo) {
|
|
7
7
|
const { moduleName } = options;
|
|
8
8
|
const { className } = globFile;
|
|
9
|
-
const { name, nameCapitalize, controllerExtJs, hasComponentOptions, nameProps, hasProps, hasGeneric, nameModels, hasModels, hasModelValue, generic, genericKeys, importRenderFirst, hasRenderFirst, classNameRenderFirst, importStyleFirst, hasStyleFirst, classNameStyleFirst, } = controllerInfo;
|
|
9
|
+
const { name, nameCapitalize, controllerExtJs, hasComponentOptions, nameProps, hasProps, hasGeneric, nameModels, hasModels, hasModelValue, generic, genericKeys, generateImports, importRenderFirst, hasRenderFirst, classNameRenderFirst, importStyleFirst, hasStyleFirst, classNameStyleFirst, } = controllerInfo;
|
|
10
10
|
const contentImports = [];
|
|
11
|
+
if (generateImports) {
|
|
12
|
+
contentImports.push(...generateImports);
|
|
13
|
+
}
|
|
11
14
|
const genericDeclare = hasGeneric ? `<${generic}>` : '';
|
|
12
15
|
const genericArguments = hasGeneric ? `<${genericKeys?.join(', ')}>` : '';
|
|
13
16
|
const componentOptions = hasComponentOptions ? `Controller${nameCapitalize}.$componentOptions` : '';
|
|
@@ -113,11 +116,11 @@ ${combineContentRenderAndStyle(controllerInfo, moduleName, className, genericDec
|
|
|
113
116
|
${contentComponent}
|
|
114
117
|
`;
|
|
115
118
|
// restComponent
|
|
116
|
-
await generateRestComponent(options, globFile, controllerInfo, genericDeclare, genericArguments, _contentImportTypeController);
|
|
119
|
+
await generateRestComponent(options, globFile, controllerInfo, genericDeclare, genericArguments, generateImports, _contentImportTypeController);
|
|
117
120
|
// ok
|
|
118
121
|
return content;
|
|
119
122
|
}
|
|
120
|
-
async function generateRestComponent(options, _globFile, controllerInfo, genericDeclare, genericArguments, _contentImportTypeController) {
|
|
123
|
+
async function generateRestComponent(options, _globFile, controllerInfo, genericDeclare, genericArguments, generateImports, _contentImportTypeController) {
|
|
121
124
|
const { cli, moduleName, modulePath } = options;
|
|
122
125
|
// const { className } = globFile;
|
|
123
126
|
const { name, nameCapitalize, hasProps, nameProps, hasModels, nameModels } = controllerInfo;
|
|
@@ -139,6 +142,9 @@ async function generateRestComponent(options, _globFile, controllerInfo, generic
|
|
|
139
142
|
contentTypeControllerPublicProps = `${contentTypeControllerPublicProps};`;
|
|
140
143
|
// import
|
|
141
144
|
const contentImports = [];
|
|
145
|
+
if (generateImports) {
|
|
146
|
+
contentImports.push(...generateImports);
|
|
147
|
+
}
|
|
142
148
|
const _contentImportTypeZova = [];
|
|
143
149
|
if (hasModels)
|
|
144
150
|
_contentImportTypeZova.push('TypePropUpdateFromModel', 'TypePropValueFromModel');
|
|
@@ -31,7 +31,9 @@ export async function generateMetaPage(options, globFiles) {
|
|
|
31
31
|
// controller.tsx
|
|
32
32
|
const { routePath, routeName } = _extractRoutePathOrName(options, globFile, controllerInfo);
|
|
33
33
|
// no matter that: route.meta?.absolute
|
|
34
|
-
const routePathFull = routePath
|
|
34
|
+
const routePathFull = routePath
|
|
35
|
+
? `/${moduleName.replace('-', '/')}/${routePath}`
|
|
36
|
+
: `/${moduleName.replace('-', '/')}`;
|
|
35
37
|
const routeNameFull = `${moduleName}:${routeName}`;
|
|
36
38
|
contentPathRecords.push(_combineContentPathRecord(routePathFull, hasSchemaParams, hasSchemaQuery, namespace));
|
|
37
39
|
contentPathRecordsRest.push(_combineContentPathRecord(routePathFull, hasSchemaParams, hasSchemaQuery, namespaceRest));
|
|
@@ -141,7 +143,8 @@ function _extractRoutePathOrName(options, _globFile, controllerInfo) {
|
|
|
141
143
|
const astMatch = astMatches.find(item => {
|
|
142
144
|
return item.node.properties.some(prop => {
|
|
143
145
|
return (prop.key.name === 'component' &&
|
|
144
|
-
(prop.value.name === controllerInfo.nameCapitalize ||
|
|
146
|
+
(prop.value.name === controllerInfo.nameCapitalize ||
|
|
147
|
+
prop.value.name === `ZPage${controllerInfo.nameCapitalize}`));
|
|
145
148
|
});
|
|
146
149
|
});
|
|
147
150
|
if (!astMatch) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fse from 'fs-extra';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
export function combineContentRenderAndStyle(controllerInfo, moduleName, className, genericDeclare, genericArguments) {
|
|
4
|
-
const { hasRenderFirst, classNameRenderFirst, classNameRenderOthers, hasStyleFirst, classNameStyleFirst, classNameStyleOthers } = controllerInfo;
|
|
4
|
+
const { hasRenderFirst, classNameRenderFirst, classNameRenderOthers, hasStyleFirst, classNameStyleFirst, classNameStyleOthers, } = controllerInfo;
|
|
5
5
|
const contentControllerInterfaceRecords = [];
|
|
6
6
|
if (hasStyleFirst) {
|
|
7
7
|
contentControllerInterfaceRecords.push(`export interface ${classNameStyleFirst}${genericDeclare} extends ${className}${genericArguments} {}`);
|
package/package.json
CHANGED
package/src/bean/sys.onion.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { checkMeta, isNil, matchSelector } from '@cabloy/utils';
|
|
2
2
|
import { BeanBase, ProxyDisable } from 'zova';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
IOnionOptionsEnable,
|
|
6
|
+
IOnionOptionsMatch,
|
|
7
|
+
IOnionOptionsMeta,
|
|
8
|
+
TypeOnionOptionsMatchRules,
|
|
9
|
+
} from '../types/onion.js';
|
|
5
10
|
|
|
6
11
|
import { Sys } from '../lib/bean.js';
|
|
7
12
|
import { ServiceOnion } from '../service/onion_.js';
|
|
@@ -32,8 +37,10 @@ export class SysOnion extends BeanBase {
|
|
|
32
37
|
if (isNil(selector) || selector === false) return true;
|
|
33
38
|
if (isNil(options.match) && isNil(options.ignore)) return true;
|
|
34
39
|
return (
|
|
35
|
-
(!isNil(options.match) &&
|
|
36
|
-
|
|
40
|
+
(!isNil(options.match) &&
|
|
41
|
+
__onionMatchSelector(options.match, selector, matchThis, ...matchArgs)) ||
|
|
42
|
+
(!isNil(options.ignore) &&
|
|
43
|
+
!__onionMatchSelector(options.ignore, selector, matchThis, ...matchArgs))
|
|
37
44
|
);
|
|
38
45
|
}
|
|
39
46
|
|
|
@@ -42,6 +49,11 @@ export class SysOnion extends BeanBase {
|
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
function __onionMatchSelector(
|
|
52
|
+
function __onionMatchSelector(
|
|
53
|
+
match: TypeOnionOptionsMatchRules<string>,
|
|
54
|
+
selector: string | boolean,
|
|
55
|
+
matchThis: any,
|
|
56
|
+
...matchArgs: any[]
|
|
57
|
+
) {
|
|
46
58
|
return matchSelector(match, selector, matchThis, ...matchArgs);
|
|
47
59
|
}
|
package/src/lib/useAopMethod.ts
CHANGED
|
@@ -12,7 +12,11 @@ export function UseAopMethod<T extends keyof IAopMethodRecord>(
|
|
|
12
12
|
): PropertyDescriptor & MethodDecorator {
|
|
13
13
|
return function (target: object, prop: MetadataKey, descriptor?: PropertyDescriptor) {
|
|
14
14
|
registerMappedClassMetadataKey(target, SymbolDecoratorUseAopMethod);
|
|
15
|
-
const uses = appMetadata.getOwnMetadataMap<MetadataKey, IUseAopMethodPropMetadata<T>[]>(
|
|
15
|
+
const uses = appMetadata.getOwnMetadataMap<MetadataKey, IUseAopMethodPropMetadata<T>[]>(
|
|
16
|
+
true,
|
|
17
|
+
SymbolDecoratorUseAopMethod,
|
|
18
|
+
target,
|
|
19
|
+
);
|
|
16
20
|
if (!uses[prop]) uses[prop] = [];
|
|
17
21
|
uses[prop].push({ onionName: aopMethodName, options });
|
|
18
22
|
return descriptor;
|
package/src/service/aop.ts
CHANGED
|
@@ -7,7 +7,12 @@ import type { IOnionItem, IOnionSlice } from '../types/onion.js';
|
|
|
7
7
|
|
|
8
8
|
import { SysOnion } from '../bean/sys.onion.js';
|
|
9
9
|
import { Service } from '../lib/bean.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
IAopMethodRecord,
|
|
12
|
+
IDecoratorAopMethodOptions,
|
|
13
|
+
IUseAopMethodPropMetadata,
|
|
14
|
+
SymbolDecoratorUseAopMethod,
|
|
15
|
+
} from '../types/aopMethod.js';
|
|
11
16
|
|
|
12
17
|
type AopMethodsMatchedAll = Record<string, IUseAopMethodPropMetadata[]>;
|
|
13
18
|
|
|
@@ -17,10 +22,18 @@ export class ServiceAop extends BeanBase {
|
|
|
17
22
|
@Use()
|
|
18
23
|
$$sysOnion: SysOnion;
|
|
19
24
|
|
|
20
|
-
async findAopsMatched<T>(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
async findAopsMatched<
|
|
25
|
+
async findAopsMatched<T>(
|
|
26
|
+
A: Constructable<T>,
|
|
27
|
+
): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;
|
|
28
|
+
async findAopsMatched<K extends keyof IBeanRecord>(
|
|
29
|
+
beanFullName: K,
|
|
30
|
+
): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;
|
|
31
|
+
async findAopsMatched(
|
|
32
|
+
beanFullName: string,
|
|
33
|
+
): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined>;
|
|
34
|
+
async findAopsMatched<T>(
|
|
35
|
+
beanFullName: Constructable<T> | string,
|
|
36
|
+
): Promise<IOnionSlice<IDecoratorAopOptions, keyof IAopRecord>[] | undefined> {
|
|
24
37
|
if (process.env.DEV && this.bean.containerType !== 'sys') {
|
|
25
38
|
throw new Error('should in sys container');
|
|
26
39
|
}
|
|
@@ -32,9 +45,13 @@ export class ServiceAop extends BeanBase {
|
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
async findAopMethodsMatched<T>(A: Constructable<T>): Promise<AopMethodsMatchedAll | undefined>;
|
|
35
|
-
async findAopMethodsMatched<K extends keyof IBeanRecord>(
|
|
48
|
+
async findAopMethodsMatched<K extends keyof IBeanRecord>(
|
|
49
|
+
beanFullName: K,
|
|
50
|
+
): Promise<AopMethodsMatchedAll | undefined>;
|
|
36
51
|
async findAopMethodsMatched(beanFullName: string): Promise<AopMethodsMatchedAll | undefined>;
|
|
37
|
-
async findAopMethodsMatched<T>(
|
|
52
|
+
async findAopMethodsMatched<T>(
|
|
53
|
+
beanFullName: Constructable<T> | string,
|
|
54
|
+
): Promise<AopMethodsMatchedAll | undefined> {
|
|
38
55
|
if (process.env.DEV && this.bean.containerType !== 'sys') {
|
|
39
56
|
throw new Error('should in sys container');
|
|
40
57
|
}
|
|
@@ -42,7 +59,10 @@ export class ServiceAop extends BeanBase {
|
|
|
42
59
|
const beanOptions = appResource.getBean(beanFullName as any);
|
|
43
60
|
if (!beanOptions) return;
|
|
44
61
|
const aopMethodsMatchedAll: AopMethodsMatchedAll = {};
|
|
45
|
-
const uses = appMetadata.getMetadata<Record<string, IUseAopMethodPropMetadata[]>>(
|
|
62
|
+
const uses = appMetadata.getMetadata<Record<string, IUseAopMethodPropMetadata[]>>(
|
|
63
|
+
SymbolDecoratorUseAopMethod,
|
|
64
|
+
beanOptions.beanClass.prototype,
|
|
65
|
+
);
|
|
46
66
|
for (const prop in uses) {
|
|
47
67
|
const onionItems: IOnionItem<IDecoratorAopMethodOptions, keyof IAopMethodRecord>[] = [];
|
|
48
68
|
const aopMethods: IUseAopMethodPropMetadata[] = uses[prop];
|
package/src/service/onion_.ts
CHANGED
|
@@ -74,11 +74,13 @@ export class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple
|
|
|
74
74
|
swapDeps(onions as ISwapDepsItem[], {
|
|
75
75
|
name: 'name',
|
|
76
76
|
dependencies: item => {
|
|
77
|
-
const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item)
|
|
77
|
+
const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item)
|
|
78
|
+
.options as IOnionOptionsDeps<string>;
|
|
78
79
|
return onionOptions.dependencies as any;
|
|
79
80
|
},
|
|
80
81
|
dependents: item => {
|
|
81
|
-
const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item)
|
|
82
|
+
const onionOptions = cast<IOnionItem<OPTIONS, ONIONNAME>>(item)
|
|
83
|
+
.options as IOnionOptionsDeps<string>;
|
|
82
84
|
return onionOptions.dependents as any;
|
|
83
85
|
},
|
|
84
86
|
});
|
|
@@ -118,7 +120,11 @@ export class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple
|
|
|
118
120
|
// return this.getOnionSlice(onionName).beanOptions.options as OPTIONS | undefined;
|
|
119
121
|
// }
|
|
120
122
|
|
|
121
|
-
async loadOnionsFromPackage(
|
|
123
|
+
async loadOnionsFromPackage(
|
|
124
|
+
selector?: string | boolean,
|
|
125
|
+
matchThis?: any,
|
|
126
|
+
...matchArgs: any[]
|
|
127
|
+
): Promise<IOnionSlice<OPTIONS, ONIONNAME>[]> {
|
|
122
128
|
// onionItems
|
|
123
129
|
const onionItems = this.getOnionsEnabled(this.onionsAll, selector, matchThis, ...matchArgs);
|
|
124
130
|
// loadOnions
|
|
@@ -147,7 +153,10 @@ export class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple
|
|
|
147
153
|
if (beanOptions.optionsPrimitive) {
|
|
148
154
|
options = item.options !== undefined ? item.options : beanOptions.options;
|
|
149
155
|
} else {
|
|
150
|
-
options =
|
|
156
|
+
options =
|
|
157
|
+
item.options !== undefined
|
|
158
|
+
? deepExtend({}, beanOptions.options, item.options)
|
|
159
|
+
: beanOptions.options;
|
|
151
160
|
}
|
|
152
161
|
// ok
|
|
153
162
|
onionSlices.push({ name: item.name, options, beanFullName });
|
|
@@ -168,12 +177,21 @@ export class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple
|
|
|
168
177
|
): IOnionSlice<OPTIONS, ONIONNAME, T>[] {
|
|
169
178
|
if (!onions) return [];
|
|
170
179
|
return onions.filter(onionItem => {
|
|
171
|
-
const onionOptions = onionItem.options as IOnionOptionsEnable &
|
|
172
|
-
|
|
180
|
+
const onionOptions = onionItem.options as IOnionOptionsEnable &
|
|
181
|
+
IOnionOptionsMatch<TypeOnionOptionsMatchRule<string>>;
|
|
182
|
+
return this.sysOnion.checkOnionOptionsEnabled(
|
|
183
|
+
onionOptions,
|
|
184
|
+
selector,
|
|
185
|
+
matchThis,
|
|
186
|
+
...matchArgs,
|
|
187
|
+
);
|
|
173
188
|
}) as unknown as IOnionSlice<OPTIONS, ONIONNAME, T>[];
|
|
174
189
|
}
|
|
175
190
|
|
|
176
|
-
compose(
|
|
191
|
+
compose(
|
|
192
|
+
onions: IOnionSlice<OPTIONS, ONIONNAME>[],
|
|
193
|
+
executeCustom: IOnionExecuteCustom<OPTIONS, ONIONNAME>,
|
|
194
|
+
) {
|
|
177
195
|
// fns
|
|
178
196
|
const fns: Function[] = [];
|
|
179
197
|
for (const item of onions) {
|
|
@@ -190,7 +208,10 @@ export class ServiceOnion<OPTIONS, ONIONNAME extends string> extends BeanSimple
|
|
|
190
208
|
}
|
|
191
209
|
|
|
192
210
|
/** internal */
|
|
193
|
-
public _wrapOnion(
|
|
211
|
+
public _wrapOnion(
|
|
212
|
+
item: IOnionSlice<OPTIONS, ONIONNAME>,
|
|
213
|
+
executeCustom: IOnionExecuteCustom<OPTIONS, ONIONNAME>,
|
|
214
|
+
) {
|
|
194
215
|
const fn = (data: any, next: Next) => {
|
|
195
216
|
return executeCustom(item, data, next);
|
|
196
217
|
};
|
package/src/types/aop.ts
CHANGED
|
@@ -19,7 +19,13 @@ export type AopAction<T extends {}, NAME extends keyof T, RESULT = undefined> =
|
|
|
19
19
|
next: AopActionNext<Parameters<T[NAME]>, ReturnType<T[NAME]>>,
|
|
20
20
|
_receiver: T,
|
|
21
21
|
) // @ts-ignore ignore
|
|
22
|
-
=> RESULT extends undefined
|
|
22
|
+
=> RESULT extends undefined
|
|
23
|
+
? // @ts-ignore ignore
|
|
24
|
+
ReturnType<T[NAME]>
|
|
25
|
+
: // @ts-ignore ignore
|
|
26
|
+
ReturnType<T[NAME]> extends Promise<any>
|
|
27
|
+
? Promise<RESULT>
|
|
28
|
+
: RESULT;
|
|
23
29
|
|
|
24
30
|
export type AopActionMethod<T extends {}> = (method: keyof T, args: any[], next: AopActionNext<any[], any>, _receiver: T) => any;
|
|
25
31
|
|
package/src/types/aopMethod.ts
CHANGED
|
@@ -17,11 +17,23 @@ export interface IAopMethodGet {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export interface IAopMethodSet {
|
|
20
|
-
set(
|
|
20
|
+
set(
|
|
21
|
+
options: IDecoratorAopMethodOptions,
|
|
22
|
+
value: any,
|
|
23
|
+
next: NextSync,
|
|
24
|
+
receiver: any,
|
|
25
|
+
prop: string,
|
|
26
|
+
): boolean;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export interface IAopMethodExecute {
|
|
24
|
-
execute(
|
|
30
|
+
execute(
|
|
31
|
+
options: IDecoratorAopMethodOptions,
|
|
32
|
+
args: [],
|
|
33
|
+
next: Next | NextSync,
|
|
34
|
+
receiver: any,
|
|
35
|
+
prop: string,
|
|
36
|
+
): Promise<any> | any;
|
|
25
37
|
}
|
|
26
38
|
|
|
27
39
|
export interface IDecoratorAopMethodOptions extends IOnionOptionsEnable {}
|
package/src/types/onion.ts
CHANGED
|
@@ -5,9 +5,16 @@ export const SymbolUseOnionOptions = Symbol('SymbolUseOnionOptions');
|
|
|
5
5
|
|
|
6
6
|
export type TypeComposer = (context: any, next?: any) => any;
|
|
7
7
|
|
|
8
|
-
export type IOnionExecuteCustom<OPTIONS, ONIONNAME> = (
|
|
8
|
+
export type IOnionExecuteCustom<OPTIONS, ONIONNAME> = (
|
|
9
|
+
onionSlice: IOnionSlice<OPTIONS, ONIONNAME>,
|
|
10
|
+
data: any,
|
|
11
|
+
next: Function,
|
|
12
|
+
) => any;
|
|
9
13
|
|
|
10
|
-
export type TypeUseOnionGlobalBaseOptions<T> = Omit<
|
|
14
|
+
export type TypeUseOnionGlobalBaseOptions<T> = Omit<
|
|
15
|
+
T,
|
|
16
|
+
'global' | 'dependencies' | 'dependents' | 'ignore' | 'match'
|
|
17
|
+
>;
|
|
11
18
|
|
|
12
19
|
export interface IOnionOptionsEnable {
|
|
13
20
|
enable?: boolean;
|
|
@@ -16,7 +23,9 @@ export interface IOnionOptionsEnable {
|
|
|
16
23
|
|
|
17
24
|
export type TypeOnionOptionsMatchFunction = (this: any, ...args: any[]) => boolean;
|
|
18
25
|
export type TypeOnionOptionsMatchRule<T> = T | RegExp | TypeOnionOptionsMatchFunction;
|
|
19
|
-
export type TypeOnionOptionsMatchRules<T> =
|
|
26
|
+
export type TypeOnionOptionsMatchRules<T> =
|
|
27
|
+
| TypeOnionOptionsMatchRule<T>[]
|
|
28
|
+
| TypeOnionOptionsMatchRule<T>;
|
|
20
29
|
|
|
21
30
|
export interface IOnionOptionsMatch<T> {
|
|
22
31
|
match?: T[] | T;
|
|
@@ -30,7 +39,8 @@ export interface IOnionOptionsDeps<T> {
|
|
|
30
39
|
|
|
31
40
|
export interface IOnionOptionsMeta extends ZovaOnionOptionsMeta {}
|
|
32
41
|
|
|
33
|
-
export interface IOnionOptionsBase<T extends string>
|
|
42
|
+
export interface IOnionOptionsBase<T extends string>
|
|
43
|
+
extends IOnionOptionsEnable, IOnionOptionsMatch<TypeOnionOptionsMatchRule<T>> {}
|
|
34
44
|
|
|
35
45
|
export interface IOnionSlice<OPTIONS = unknown, ONIONNAME = string, T = unknown> {
|
|
36
46
|
name: ONIONNAME;
|