zova-module-a-bean 5.1.16 → 5.1.18

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.
@@ -3,7 +3,13 @@ import ts from 'typescript';
3
3
 
4
4
  export function extractGenericParamsAndImports(filePath: string, interfaceName: string) {
5
5
  const sourceText = fs.readFileSync(filePath, 'utf-8');
6
- const sourceFile = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
6
+ const sourceFile = ts.createSourceFile(
7
+ filePath,
8
+ sourceText,
9
+ ts.ScriptTarget.Latest,
10
+ true,
11
+ ts.ScriptKind.TSX,
12
+ );
7
13
 
8
14
  // 1. Find the target interface
9
15
  let targetInterface: ts.InterfaceDeclaration | undefined;
@@ -43,7 +49,9 @@ export function extractGenericParamsAndImports(filePath: string, interfaceName:
43
49
  const clause = node.importClause;
44
50
  if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings)) return;
45
51
 
46
- const matched = clause.namedBindings.elements.map(el => el.name.text).filter(name => typeRefNames.has(name));
52
+ const matched = clause.namedBindings.elements
53
+ .map(el => el.name.text)
54
+ .filter(name => typeRefNames.has(name));
47
55
  if (matched.length === 0) return;
48
56
 
49
57
  const specifier = (node.moduleSpecifier as ts.StringLiteral).text;
@@ -36,7 +36,10 @@ export default async function (options: IMetadataCustomGenerateOptions): Promise
36
36
  return content;
37
37
  }
38
38
 
39
- function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile: IGlobBeanFile): IControllerInfo | undefined {
39
+ function _parseControllerInfo(
40
+ options: IMetadataCustomGenerateOptions,
41
+ globFile: IGlobBeanFile,
42
+ ): IControllerInfo | undefined {
40
43
  const { className, fileContent, fileNameJSRelative, file } = globFile;
41
44
  const matches = fileNameJSRelative.match(/..\/(.+?)\/(.+?)\/controller(.jsx?)$/);
42
45
  if (!matches) return;
@@ -47,7 +50,9 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
47
50
  const controllerExtJs = matches[3];
48
51
  const controllerExtTs = controllerExtJs.replace('.js', '.ts');
49
52
  // componentOptions
50
- const componentOptionsMatched = fileContent.match(/static \$componentOptions[^=]* = (\{[\s\S]*?\});/);
53
+ const componentOptionsMatched = fileContent.match(
54
+ /static \$componentOptions[^=]* = (\{[\s\S]*?\});/,
55
+ );
51
56
  const componentOptions = componentOptionsMatched ? componentOptionsMatched[1] : '';
52
57
  const hasComponentOptions = !!componentOptionsMatched;
53
58
  // props
@@ -61,7 +66,9 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
61
66
  const matchGeneric = hasProps && extractGenericParamsAndImports(file, nameProps); // fileContent.match(__regProps);
62
67
  const hasGeneric = !!(matchGeneric && matchGeneric.genericParams);
63
68
  const generic = hasGeneric ? matchGeneric.genericParams : undefined;
64
- const genericKeys = hasGeneric ? matchGeneric.genericParams.split(',').map(item => item.trim().split(' ')[0]) : undefined;
69
+ const genericKeys = hasGeneric
70
+ ? matchGeneric.genericParams.split(',').map(item => item.trim().split(' ')[0])
71
+ : undefined;
65
72
  const generateImports = hasGeneric ? matchGeneric.imports : undefined;
66
73
  // schemaParams
67
74
  const nameSchemaParams = `${className}SchemaParams`;
@@ -77,10 +84,15 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
77
84
  const fileRenderOthers = globbySync(`src/${type}/${name}/render.*.tsx`, {
78
85
  cwd: options.modulePath,
79
86
  });
80
- const nameRenderOthers: string[] = fileRenderOthers.map(item => /render\.(.*)\.tsx/.exec(item)![1]);
81
- const classNameRenderOthers: string[] = nameRenderOthers.map(item => `Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`);
87
+ const nameRenderOthers: string[] = fileRenderOthers.map(
88
+ item => /render\.(.*)\.tsx/.exec(item)![1],
89
+ );
90
+ const classNameRenderOthers: string[] = nameRenderOthers.map(
91
+ item => `Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`,
92
+ );
82
93
  const importRenderOthers: string[] = nameRenderOthers.map(
83
- item => `import { ${`Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`} } from '../../${type}/${name}/render.${item}.jsx';`,
94
+ item =>
95
+ `import { ${`Render${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`} } from '../../${type}/${name}/render.${item}.jsx';`,
84
96
  );
85
97
  // style
86
98
  const fileStyleFirst = path.join(options.modulePath, `src/${type}/${name}/style.ts`);
@@ -89,9 +101,12 @@ function _parseControllerInfo(options: IMetadataCustomGenerateOptions, globFile:
89
101
  const importStyleFirst = `import { ${classNameStyleFirst} } from '../../${type}/${name}/style.js';`;
90
102
  const fileStyleOthers = globbySync(`src/${type}/${name}/style.*.ts`, { cwd: options.modulePath });
91
103
  const nameStyleOthers: string[] = fileStyleOthers.map(item => /style\.(.*)\.ts/.exec(item)![1]);
92
- const classNameStyleOthers: string[] = nameStyleOthers.map(item => `Style${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`);
104
+ const classNameStyleOthers: string[] = nameStyleOthers.map(
105
+ item => `Style${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`,
106
+ );
93
107
  const importStyleOthers: string[] = nameStyleOthers.map(
94
- item => `import { ${`Style${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`} } from '../../${type}/${name}/style.${item}.js';`,
108
+ item =>
109
+ `import { ${`Style${type === 'page' ? 'Page' : ''}${toUpperCaseFirstChar(item)}`} } from '../../${type}/${name}/style.${item}.js';`,
95
110
  );
96
111
  // ok
97
112
  return {
@@ -1,14 +1,15 @@
1
1
  import type { IMetadataCustomGenerateOptions } from '@cabloy/cli';
2
2
  import type { IGlobBeanFile } from '@cabloy/module-info';
3
3
 
4
- import fse from 'fs-extra';
5
- import path from 'node:path';
6
-
7
4
  import type { IControllerInfo } from './types.ts';
8
5
 
9
- import { combineContentRenderAndStyle, generateRestIndex } from './utils.ts';
6
+ import { combineContentRenderAndStyle } from './utils.ts';
10
7
 
11
- export async function generateFileComponent(options: IMetadataCustomGenerateOptions, globFile: IGlobBeanFile, controllerInfo: IControllerInfo) {
8
+ export async function generateFileComponent(
9
+ options: IMetadataCustomGenerateOptions,
10
+ globFile: IGlobBeanFile,
11
+ controllerInfo: IControllerInfo,
12
+ ) {
12
13
  const { moduleName } = options;
13
14
  const { className } = globFile;
14
15
  const {
@@ -38,10 +39,17 @@ export async function generateFileComponent(options: IMetadataCustomGenerateOpti
38
39
  }
39
40
  const genericDeclare = hasGeneric ? `<${generic}>` : '';
40
41
  const genericArguments = hasGeneric ? `<${genericKeys?.join(', ')}>` : '';
41
- const componentOptions = hasComponentOptions ? `Controller${nameCapitalize}.$componentOptions` : '';
42
+ const componentOptions = hasComponentOptions
43
+ ? `Controller${nameCapitalize}.$componentOptions`
44
+ : '';
42
45
  // import
43
46
  const _contentImportTypeZova: string[] = [];
44
- if (hasModels) _contentImportTypeZova.push('DefineModelOptions', 'TypePropUpdateFromModel', 'TypePropValueFromModel');
47
+ if (hasModels)
48
+ _contentImportTypeZova.push(
49
+ 'DefineModelOptions',
50
+ 'TypePropUpdateFromModel',
51
+ 'TypePropValueFromModel',
52
+ );
45
53
  if (hasProps) _contentImportTypeZova.push('TypeControllerInnerProps');
46
54
  if (_contentImportTypeZova.length > 0) {
47
55
  contentImports.push(`import type { ${_contentImportTypeZova.join(', ')} } from 'zova';`);
@@ -50,12 +58,16 @@ export async function generateFileComponent(options: IMetadataCustomGenerateOpti
50
58
  if (hasModels) _contentImportTypeController.push(nameModels);
51
59
  if (hasProps) _contentImportTypeController.push(nameProps);
52
60
  if (_contentImportTypeController.length > 0) {
53
- contentImports.push(`import type { ${_contentImportTypeController.join(', ')} } from '../../component/${name}/controller${controllerExtJs}';`);
61
+ contentImports.push(
62
+ `import type { ${_contentImportTypeController.join(', ')} } from '../../component/${name}/controller${controllerExtJs}';`,
63
+ );
54
64
  }
55
65
  contentImports.push("import { defineComponent } from 'vue'");
56
66
  contentImports.push("import { prepareComponentOptions, useController } from 'zova';");
57
67
  // controller
58
- contentImports.push(`import { ${className} } from '../../component/${name}/controller${controllerExtJs}';`);
68
+ contentImports.push(
69
+ `import { ${className} } from '../../component/${name}/controller${controllerExtJs}';`,
70
+ );
59
71
  // render
60
72
  if (hasRenderFirst) {
61
73
  contentImports.push(importRenderFirst);
@@ -166,20 +178,6 @@ ${combineContentRenderAndStyle(controllerInfo, moduleName, className, genericDec
166
178
  ${contentComponent}
167
179
  ${contentRestProps}
168
180
  `;
169
- // restComponent
170
- await generateRestComponent(options);
171
181
  // ok
172
182
  return content;
173
183
  }
174
-
175
- async function generateRestComponent(options: IMetadataCustomGenerateOptions) {
176
- const { moduleName, modulePath } = options;
177
- // components
178
- const fileComponents = path.join(modulePath, 'rest/components.ts');
179
- if (fse.existsSync(fileComponents)) return;
180
- const contentComponents = `export * from 'zova-module-${moduleName}';`;
181
- await fse.outputFile(fileComponents, contentComponents);
182
- // index
183
- const exportIndexContent = "export * from './components.js';";
184
- await generateRestIndex(options, modulePath, exportIndexContent);
185
- }
@@ -8,8 +8,6 @@ import path from 'node:path';
8
8
 
9
9
  import type { IControllerInfo } from './types.ts';
10
10
 
11
- import { generateRestIndex } from './utils.ts';
12
-
13
11
  export async function generateMetaPage(
14
12
  options: IMetadataCustomGenerateOptions,
15
13
  globFiles: [IGlobBeanFile, IControllerInfo][],
@@ -124,27 +122,9 @@ declare module 'zova-module-${moduleName}' {
124
122
  }
125
123
  /** pages: end */
126
124
  `;
127
- // restComponent
128
- await generateRestMetaPage(options, contentImportsRest, contentPathRecordsRest);
129
125
  return content;
130
126
  }
131
127
 
132
- async function generateRestMetaPage(
133
- options: IMetadataCustomGenerateOptions,
134
- _contentImportsRest: string[],
135
- contentPathRecordsRest: string[],
136
- ) {
137
- if (contentPathRecordsRest.length === 0) return;
138
- const { moduleName, modulePath } = options;
139
- // pages
140
- const contentPages = `export * from 'zova-module-${moduleName}';\n`;
141
- const filePages = path.join(modulePath, 'rest/pages.ts');
142
- await fse.outputFile(filePages, contentPages);
143
- // index
144
- const exportIndexContent = "export * from './pages.js';";
145
- await generateRestIndex(options, modulePath, exportIndexContent);
146
- }
147
-
148
128
  function _combineModuleNameControllerName(moduleName: string, className: string) {
149
129
  return `NS${toUpperCaseFirstChar(combineResourceName(className, moduleName, false, false))}`;
150
130
  }
@@ -1,8 +1,3 @@
1
- import type { IMetadataCustomGenerateOptions } from '@cabloy/cli';
2
-
3
- import fse from 'fs-extra';
4
- import path from 'node:path';
5
-
6
1
  import type { IControllerInfo } from './types.ts';
7
2
 
8
3
  export function combineContentRenderAndStyle(
@@ -58,22 +53,3 @@ export function combineContentRenderAndStyle(
58
53
  ${contentControllerInterfaceRecords.join('\n')}
59
54
  }`;
60
55
  }
61
-
62
- export async function generateRestIndex(
63
- options: IMetadataCustomGenerateOptions,
64
- modulePath: string,
65
- append: string,
66
- ) {
67
- const { cli } = options;
68
- // index
69
- const fileIndex = path.join(modulePath, 'rest/index.ts');
70
- let contentIndex = '';
71
- if (fse.existsSync(fileIndex)) {
72
- contentIndex = (await fse.readFile(fileIndex)).toString();
73
- }
74
- if (!contentIndex.includes(append)) {
75
- contentIndex = `${contentIndex}${append}\n`;
76
- await fse.outputFile(fileIndex, contentIndex);
77
- await cli.helper.formatFile({ fileName: fileIndex });
78
- }
79
- }
@@ -1 +1 @@
1
- {"version":3,"file":"aop.d.ts","sourceRoot":"","sources":["../../src/types/aop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE1F,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG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B,EAAE,MAAM,UAAU,CAAC,CAAC;KAC3D;CACF;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAiB,YAAY;QAC3B,GAAG,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;KAC5B;IAED,UAAiB,gBAAgB;QAC/B,GAAG,EAAE,KAAK,CAAC;KACZ;CACF"}
@@ -38,7 +38,9 @@ export function extractGenericParamsAndImports(filePath, interfaceName) {
38
38
  const clause = node.importClause;
39
39
  if (!clause?.namedBindings || !ts.isNamedImports(clause.namedBindings))
40
40
  return;
41
- const matched = clause.namedBindings.elements.map(el => el.name.text).filter(name => typeRefNames.has(name));
41
+ const matched = clause.namedBindings.elements
42
+ .map(el => el.name.text)
43
+ .filter(name => typeRefNames.has(name));
42
44
  if (matched.length === 0)
43
45
  return;
44
46
  const specifier = node.moduleSpecifier.text;
@@ -57,7 +57,9 @@ function _parseControllerInfo(options, globFile) {
57
57
  const matchGeneric = hasProps && extractGenericParamsAndImports(file, nameProps); // fileContent.match(__regProps);
58
58
  const hasGeneric = !!(matchGeneric && matchGeneric.genericParams);
59
59
  const generic = hasGeneric ? matchGeneric.genericParams : undefined;
60
- const genericKeys = hasGeneric ? matchGeneric.genericParams.split(',').map(item => item.trim().split(' ')[0]) : undefined;
60
+ const genericKeys = hasGeneric
61
+ ? matchGeneric.genericParams.split(',').map(item => item.trim().split(' ')[0])
62
+ : undefined;
61
63
  const generateImports = hasGeneric ? matchGeneric.imports : undefined;
62
64
  // schemaParams
63
65
  const nameSchemaParams = `${className}SchemaParams`;
@@ -1,6 +1,4 @@
1
- import fse from 'fs-extra';
2
- import path from 'node:path';
3
- import { combineContentRenderAndStyle, generateRestIndex } from "./utils.js";
1
+ import { combineContentRenderAndStyle } from "./utils.js";
4
2
  export async function generateFileComponent(options, globFile, controllerInfo) {
5
3
  const { moduleName } = options;
6
4
  const { className } = globFile;
@@ -11,7 +9,9 @@ export async function generateFileComponent(options, globFile, controllerInfo) {
11
9
  }
12
10
  const genericDeclare = hasGeneric ? `<${generic}>` : '';
13
11
  const genericArguments = hasGeneric ? `<${genericKeys?.join(', ')}>` : '';
14
- const componentOptions = hasComponentOptions ? `Controller${nameCapitalize}.$componentOptions` : '';
12
+ const componentOptions = hasComponentOptions
13
+ ? `Controller${nameCapitalize}.$componentOptions`
14
+ : '';
15
15
  // import
16
16
  const _contentImportTypeZova = [];
17
17
  if (hasModels)
@@ -139,20 +139,6 @@ ${combineContentRenderAndStyle(controllerInfo, moduleName, className, genericDec
139
139
  ${contentComponent}
140
140
  ${contentRestProps}
141
141
  `;
142
- // restComponent
143
- await generateRestComponent(options);
144
142
  // ok
145
143
  return content;
146
144
  }
147
- async function generateRestComponent(options) {
148
- const { moduleName, modulePath } = options;
149
- // components
150
- const fileComponents = path.join(modulePath, 'rest/components.ts');
151
- if (fse.existsSync(fileComponents))
152
- return;
153
- const contentComponents = `export * from 'zova-module-${moduleName}';`;
154
- await fse.outputFile(fileComponents, contentComponents);
155
- // index
156
- const exportIndexContent = "export * from './components.js';";
157
- await generateRestIndex(options, modulePath, exportIndexContent);
158
- }
@@ -2,7 +2,6 @@ import { combineResourceName } from '@cabloy/utils';
2
2
  import { toUpperCaseFirstChar } from '@cabloy/word-utils';
3
3
  import fse from 'fs-extra';
4
4
  import path from 'node:path';
5
- import { generateRestIndex } from "./utils.js";
6
5
  export async function generateMetaPage(options, globFiles) {
7
6
  if (globFiles.length === 0)
8
7
  return '';
@@ -110,22 +109,8 @@ declare module 'zova-module-${moduleName}' {
110
109
  }
111
110
  /** pages: end */
112
111
  `;
113
- // restComponent
114
- await generateRestMetaPage(options, contentImportsRest, contentPathRecordsRest);
115
112
  return content;
116
113
  }
117
- async function generateRestMetaPage(options, _contentImportsRest, contentPathRecordsRest) {
118
- if (contentPathRecordsRest.length === 0)
119
- return;
120
- const { moduleName, modulePath } = options;
121
- // pages
122
- const contentPages = `export * from 'zova-module-${moduleName}';\n`;
123
- const filePages = path.join(modulePath, 'rest/pages.ts');
124
- await fse.outputFile(filePages, contentPages);
125
- // index
126
- const exportIndexContent = "export * from './pages.js';";
127
- await generateRestIndex(options, modulePath, exportIndexContent);
128
- }
129
114
  function _combineModuleNameControllerName(moduleName, className) {
130
115
  return `NS${toUpperCaseFirstChar(combineResourceName(className, moduleName, false, false))}`;
131
116
  }
@@ -1,5 +1,3 @@
1
- import fse from 'fs-extra';
2
- import path from 'node:path';
3
1
  export function combineContentRenderAndStyle(controllerInfo, moduleName, className, genericDeclare, genericArguments) {
4
2
  const { hasRenderFirst, classNameRenderFirst, classNameRenderOthers, hasStyleFirst, classNameStyleFirst, classNameStyleOthers, } = controllerInfo;
5
3
  const contentControllerInterfaceRecords = [];
@@ -31,17 +29,3 @@ export function combineContentRenderAndStyle(controllerInfo, moduleName, classNa
31
29
  ${contentControllerInterfaceRecords.join('\n')}
32
30
  }`;
33
31
  }
34
- export async function generateRestIndex(options, modulePath, append) {
35
- const { cli } = options;
36
- // index
37
- const fileIndex = path.join(modulePath, 'rest/index.ts');
38
- let contentIndex = '';
39
- if (fse.existsSync(fileIndex)) {
40
- contentIndex = (await fse.readFile(fileIndex)).toString();
41
- }
42
- if (!contentIndex.includes(append)) {
43
- contentIndex = `${contentIndex}${append}\n`;
44
- await fse.outputFile(fileIndex, contentIndex);
45
- await cli.helper.formatFile({ fileName: fileIndex });
46
- }
47
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zova-module-a-bean",
3
- "version": "5.1.16",
4
- "gitHead": "6c7a09c8f0a8a0f41c5090b544a1667dbc689f0e",
3
+ "version": "5.1.18",
4
+ "gitHead": "ed6b11bdf77a2b7efcc261676c2812c3044768f1",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -14,7 +14,6 @@
14
14
  "src",
15
15
  "icons",
16
16
  "assets",
17
- "rest",
18
17
  "dist-cli"
19
18
  ],
20
19
  "type": "module",
package/src/types/aop.ts CHANGED
@@ -27,7 +27,12 @@ export type AopAction<T extends {}, NAME extends keyof T, RESULT = undefined> =
27
27
  ? Promise<RESULT>
28
28
  : RESULT;
29
29
 
30
- export type AopActionMethod<T extends {}> = (method: keyof T, args: any[], next: AopActionNext<any[], any>, _receiver: T) => any;
30
+ export type AopActionMethod<T extends {}> = (
31
+ method: keyof T,
32
+ args: any[],
33
+ next: AopActionNext<any[], any>,
34
+ _receiver: T,
35
+ ) => any;
31
36
 
32
37
  export type AopActionGetter<T extends {}, NAME extends keyof T, RESULT = undefined> =
33
38
  // @ts-ignore ignore
@@ -49,7 +54,10 @@ export type AopActionSetter<T extends {}, NAME extends keyof T, DATA = undefined
49
54
  export interface IAopRecord {}
50
55
 
51
56
  export interface IDecoratorAopOptions
52
- extends IOnionOptionsEnable, IOnionOptionsMatch<keyof IBeanRecord | RegExp>, IOnionOptionsDeps<keyof IAopRecord> {}
57
+ extends
58
+ IOnionOptionsEnable,
59
+ IOnionOptionsMatch<keyof IBeanRecord | RegExp>,
60
+ IOnionOptionsDeps<keyof IAopRecord> {}
53
61
 
54
62
  declare module 'zova-module-a-bean' {
55
63
  export interface SysOnion {