vona-cli-set-api 1.1.92 → 1.1.95
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/templates/create/project/cabloy-basic/boilerplate/package.original.json +3 -2
- package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/a-home/modules/home-user/package.json +1 -1
- package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/a-home/modules/home-user/src/.metadata/index.ts +1 -1
- package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/a-home/modules/home-user/src/bean/meta.version.ts +5 -5
- package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/a-home/modules/home-user/src/controller/passport.ts +9 -9
- package/cli/templates/create/project/cabloy-basic/boilerplate/src/suite/a-home/package.json +1 -1
- package/cli/templates/create/project/cabloy-start/boilerplate/package.original.json +3 -2
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/modules/home-user/package.json +1 -1
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/modules/home-user/src/.metadata/index.ts +1 -1
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/modules/home-user/src/bean/meta.version.ts +5 -5
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/modules/home-user/src/controller/passport.ts +9 -9
- package/cli/templates/create/project/cabloy-start/boilerplate/src/suite/a-home/package.json +1 -1
- package/dist/index.js +34 -33
- package/dist/lib/bean/cli.tools.metadata.d.ts +5 -1
- package/package.json +5 -5
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
"format": "oxfmt --check",
|
|
37
37
|
"format:fix": "oxfmt --write",
|
|
38
38
|
"lint": "oxlint",
|
|
39
|
-
"lint:fix": "oxlint --fix"
|
|
39
|
+
"lint:fix": "oxlint --fix",
|
|
40
|
+
"update": "pnpm update && vona :tools:deps"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"vona": "^5.1.
|
|
43
|
+
"vona": "^5.1.34"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@cabloy/lint": "^5.1.7",
|
|
@@ -511,8 +511,8 @@ export interface IApiPathPostRecord{
|
|
|
511
511
|
'/home/user/passport/logout': undefined;
|
|
512
512
|
'/home/user/passport/register': undefined;
|
|
513
513
|
'/home/user/passport/login': undefined;
|
|
514
|
-
'/home/user/passport/refreshAuthToken': undefined;
|
|
515
514
|
'/home/user/passport/createPassportJwtFromOauthCode': undefined;
|
|
515
|
+
'/home/user/passport/refreshAuthToken': undefined;
|
|
516
516
|
'/home/user/passport/createTempAuthToken': undefined;
|
|
517
517
|
}
|
|
518
518
|
|
|
@@ -55,16 +55,16 @@ export class MetaVersion extends BeanBase implements IMetaVersionUpdate, IMetaVe
|
|
|
55
55
|
}
|
|
56
56
|
// user: admin
|
|
57
57
|
if (!this.scope.config.disableUserAdmin) {
|
|
58
|
-
await this.bean.
|
|
59
|
-
{
|
|
58
|
+
await this.bean.auth.authenticate('auth-simple:simple', {
|
|
59
|
+
clientOptions: {
|
|
60
60
|
username: 'admin',
|
|
61
61
|
password: options.password || this.scope.config.passwordDefault.admin,
|
|
62
62
|
avatar: ':emoji:flower',
|
|
63
63
|
confirmed: true,
|
|
64
64
|
},
|
|
65
|
-
'register',
|
|
66
|
-
'default',
|
|
67
|
-
);
|
|
65
|
+
state: { intention: 'register' },
|
|
66
|
+
clientName: 'default',
|
|
67
|
+
});
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -39,7 +39,7 @@ export class ControllerPassport extends BeanBase {
|
|
|
39
39
|
@Core.captchaVerify({ scene: 'captcha-simple:simple' })
|
|
40
40
|
@Api.body(v.object(DtoPassportJwt))
|
|
41
41
|
async register(@Arg.body() data: DtoRegister) {
|
|
42
|
-
const jwt = await this.bean.
|
|
42
|
+
const jwt = await this.bean.auth.authenticate('auth-simple:simple', { clientOptions: data, state: { intention: 'register' }, clientName: 'default' });
|
|
43
43
|
return this._combineDtoPassportJwt(jwt);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ export class ControllerPassport extends BeanBase {
|
|
|
48
48
|
@Core.captchaVerify({ scene: 'captcha-simple:simple' })
|
|
49
49
|
@Api.body(v.object(DtoPassportJwt))
|
|
50
50
|
async login(@Arg.body() data: DtoLogin): Promise<DtoPassportJwt> {
|
|
51
|
-
const jwt = await this.bean.
|
|
51
|
+
const jwt = await this.bean.auth.authenticate('auth-simple:simple', { clientOptions: data, state: { intention: 'login' }, clientName: 'default' });
|
|
52
52
|
return this._combineDtoPassportJwt(jwt);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -103,13 +103,6 @@ export class ControllerPassport extends BeanBase {
|
|
|
103
103
|
return this._combineDtoPassportJwt(jwt);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
@Web.post('refreshAuthToken')
|
|
107
|
-
@Passport.public()
|
|
108
|
-
@Api.body(v.object(DtoJwtToken))
|
|
109
|
-
async refreshAuthToken(@Arg.body('refreshToken') refreshToken: string): Promise<DtoJwtToken> {
|
|
110
|
-
return await this.bean.passport.refreshAuthToken(refreshToken);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
106
|
@Web.post('createPassportJwtFromOauthCode')
|
|
114
107
|
@Passport.public()
|
|
115
108
|
@Api.body(v.object(DtoPassportJwt))
|
|
@@ -118,6 +111,13 @@ export class ControllerPassport extends BeanBase {
|
|
|
118
111
|
return this._combineDtoPassportJwt(jwt);
|
|
119
112
|
}
|
|
120
113
|
|
|
114
|
+
@Web.post('refreshAuthToken')
|
|
115
|
+
@Passport.public()
|
|
116
|
+
@Api.body(v.object(DtoJwtToken))
|
|
117
|
+
async refreshAuthToken(@Arg.body('refreshToken') refreshToken: string): Promise<DtoJwtToken> {
|
|
118
|
+
return await this.bean.passport.refreshAuthToken(refreshToken);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
121
|
@Web.post('createTempAuthToken')
|
|
122
122
|
@Api.body(z.string())
|
|
123
123
|
async createTempAuthToken(@Arg.query('path', v.optional()) path?: string): Promise<string> {
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
"format": "oxfmt --check",
|
|
37
37
|
"format:fix": "oxfmt --write",
|
|
38
38
|
"lint": "oxlint",
|
|
39
|
-
"lint:fix": "oxlint --fix"
|
|
39
|
+
"lint:fix": "oxlint --fix",
|
|
40
|
+
"update": "pnpm update && vona :tools:deps"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"vona": "^5.1.
|
|
43
|
+
"vona": "^5.1.34"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@cabloy/lint": "^5.1.7",
|
|
@@ -511,8 +511,8 @@ export interface IApiPathPostRecord{
|
|
|
511
511
|
'/home/user/passport/logout': undefined;
|
|
512
512
|
'/home/user/passport/register': undefined;
|
|
513
513
|
'/home/user/passport/login': undefined;
|
|
514
|
-
'/home/user/passport/refreshAuthToken': undefined;
|
|
515
514
|
'/home/user/passport/createPassportJwtFromOauthCode': undefined;
|
|
515
|
+
'/home/user/passport/refreshAuthToken': undefined;
|
|
516
516
|
'/home/user/passport/createTempAuthToken': undefined;
|
|
517
517
|
}
|
|
518
518
|
|
|
@@ -55,16 +55,16 @@ export class MetaVersion extends BeanBase implements IMetaVersionUpdate, IMetaVe
|
|
|
55
55
|
}
|
|
56
56
|
// user: admin
|
|
57
57
|
if (!this.scope.config.disableUserAdmin) {
|
|
58
|
-
await this.bean.
|
|
59
|
-
{
|
|
58
|
+
await this.bean.auth.authenticate('auth-simple:simple', {
|
|
59
|
+
clientOptions: {
|
|
60
60
|
username: 'admin',
|
|
61
61
|
password: options.password || this.scope.config.passwordDefault.admin,
|
|
62
62
|
avatar: ':emoji:flower',
|
|
63
63
|
confirmed: true,
|
|
64
64
|
},
|
|
65
|
-
'register',
|
|
66
|
-
'default',
|
|
67
|
-
);
|
|
65
|
+
state: { intention: 'register' },
|
|
66
|
+
clientName: 'default',
|
|
67
|
+
});
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -39,7 +39,7 @@ export class ControllerPassport extends BeanBase {
|
|
|
39
39
|
@Core.captchaVerify({ scene: 'captcha-simple:simple' })
|
|
40
40
|
@Api.body(v.object(DtoPassportJwt))
|
|
41
41
|
async register(@Arg.body() data: DtoRegister) {
|
|
42
|
-
const jwt = await this.bean.
|
|
42
|
+
const jwt = await this.bean.auth.authenticate('auth-simple:simple', { clientOptions: data, state: { intention: 'register' }, clientName: 'default' });
|
|
43
43
|
return this._combineDtoPassportJwt(jwt);
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ export class ControllerPassport extends BeanBase {
|
|
|
48
48
|
@Core.captchaVerify({ scene: 'captcha-simple:simple' })
|
|
49
49
|
@Api.body(v.object(DtoPassportJwt))
|
|
50
50
|
async login(@Arg.body() data: DtoLogin): Promise<DtoPassportJwt> {
|
|
51
|
-
const jwt = await this.bean.
|
|
51
|
+
const jwt = await this.bean.auth.authenticate('auth-simple:simple', { clientOptions: data, state: { intention: 'login' }, clientName: 'default' });
|
|
52
52
|
return this._combineDtoPassportJwt(jwt);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -103,13 +103,6 @@ export class ControllerPassport extends BeanBase {
|
|
|
103
103
|
return this._combineDtoPassportJwt(jwt);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
@Web.post('refreshAuthToken')
|
|
107
|
-
@Passport.public()
|
|
108
|
-
@Api.body(v.object(DtoJwtToken))
|
|
109
|
-
async refreshAuthToken(@Arg.body('refreshToken') refreshToken: string): Promise<DtoJwtToken> {
|
|
110
|
-
return await this.bean.passport.refreshAuthToken(refreshToken);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
106
|
@Web.post('createPassportJwtFromOauthCode')
|
|
114
107
|
@Passport.public()
|
|
115
108
|
@Api.body(v.object(DtoPassportJwt))
|
|
@@ -118,6 +111,13 @@ export class ControllerPassport extends BeanBase {
|
|
|
118
111
|
return this._combineDtoPassportJwt(jwt);
|
|
119
112
|
}
|
|
120
113
|
|
|
114
|
+
@Web.post('refreshAuthToken')
|
|
115
|
+
@Passport.public()
|
|
116
|
+
@Api.body(v.object(DtoJwtToken))
|
|
117
|
+
async refreshAuthToken(@Arg.body('refreshToken') refreshToken: string): Promise<DtoJwtToken> {
|
|
118
|
+
return await this.bean.passport.refreshAuthToken(refreshToken);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
121
|
@Web.post('createTempAuthToken')
|
|
122
122
|
@Api.body(z.string())
|
|
123
123
|
async createTempAuthToken(@Arg.query('path', v.optional()) path?: string): Promise<string> {
|
package/dist/index.js
CHANGED
|
@@ -2657,8 +2657,6 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2657
2657
|
} = this.context;
|
|
2658
2658
|
// super
|
|
2659
2659
|
await super.execute();
|
|
2660
|
-
// noformat: src/index.ts need format
|
|
2661
|
-
// argv.noformat = true;
|
|
2662
2660
|
// moduleNames
|
|
2663
2661
|
let moduleNames = argv._;
|
|
2664
2662
|
const force = argv.force ?? moduleNames.length > 0;
|
|
@@ -2684,7 +2682,7 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2684
2682
|
const modulePath = module.root;
|
|
2685
2683
|
const metaDir = path.join(modulePath, 'src/.metadata');
|
|
2686
2684
|
const metaIndexFile = path.join(metaDir, 'index.ts');
|
|
2687
|
-
if (fse.
|
|
2685
|
+
if ((await fse.pathExists(metaIndexFile)) && !force) {
|
|
2688
2686
|
// do nothing
|
|
2689
2687
|
return;
|
|
2690
2688
|
}
|
|
@@ -2785,13 +2783,14 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2785
2783
|
content = this._generatePatch_resources(content, 'vona', ['PowerPartial'], true);
|
|
2786
2784
|
return content;
|
|
2787
2785
|
}
|
|
2788
|
-
_generatePatch_resources(content, packageName, resources,
|
|
2786
|
+
_generatePatch_resources(content, packageName, resources, isTypeImport) {
|
|
2789
2787
|
const items = resources.filter(item => {
|
|
2790
|
-
const
|
|
2788
|
+
const escaped = item.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
2789
|
+
const regexp = new RegExp(`${escaped}[\\[\\]<,;?:\\s]`);
|
|
2791
2790
|
return !!regexp.exec(content);
|
|
2792
2791
|
});
|
|
2793
2792
|
if (items.length === 0) return content;
|
|
2794
|
-
const importContent = `import ${
|
|
2793
|
+
const importContent = `import ${isTypeImport ? 'type ' : ''}{ ${items.join(',')} } from '${packageName}';`;
|
|
2795
2794
|
return `${importContent}\n${content}`;
|
|
2796
2795
|
}
|
|
2797
2796
|
async _generateLocales(modulePath, contentLocales) {
|
|
@@ -2806,7 +2805,7 @@ class CliToolsMetadata extends BeanCliBase {
|
|
|
2806
2805
|
}
|
|
2807
2806
|
async _generateThis(moduleName, relativeNameCapitalize, modulePath) {
|
|
2808
2807
|
const thisDest = path.join(modulePath, 'src/.metadata/this.ts');
|
|
2809
|
-
if (fse.
|
|
2808
|
+
if (await fse.pathExists(thisDest)) return;
|
|
2810
2809
|
const content = `export const __ThisModule__ = '${moduleName}';
|
|
2811
2810
|
export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts';
|
|
2812
2811
|
`;
|
|
@@ -2816,33 +2815,23 @@ export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts'
|
|
|
2816
2815
|
async _generateIndex(modulePath) {
|
|
2817
2816
|
let jsContent = '';
|
|
2818
2817
|
const jsFile = path.join(modulePath, 'src/index.ts');
|
|
2819
|
-
if (fse.
|
|
2818
|
+
if (await fse.pathExists(jsFile)) {
|
|
2820
2819
|
jsContent = (await fse.readFile(jsFile)).toString();
|
|
2821
2820
|
}
|
|
2822
|
-
//
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
const jsLocalesFile = path.join(modulePath, 'src/.metadata/locales.ts');
|
|
2837
|
-
if (fse.existsSync(jsLocalesFile) && !jsContent.includes(jsLocales)) {
|
|
2838
|
-
jsContent = `${jsLocales}\n${jsContent}`;
|
|
2839
|
-
}
|
|
2840
|
-
// jsMetadata
|
|
2841
|
-
const jsMetadata = "export * from './.metadata/index.ts';";
|
|
2842
|
-
const jsMetadataFile = path.join(modulePath, 'src/.metadata/index.ts');
|
|
2843
|
-
if (fse.existsSync(jsMetadataFile) && !jsContent.includes(jsMetadata)) {
|
|
2844
|
-
jsContent = `${jsMetadata}\n${jsContent}`;
|
|
2845
|
-
}
|
|
2821
|
+
// exports
|
|
2822
|
+
jsContent = await this._prependExportIfNeeded(jsContent, [{
|
|
2823
|
+
exportLine: "export * from './types/index.ts';",
|
|
2824
|
+
sourceFile: path.join(modulePath, 'src/types/index.ts')
|
|
2825
|
+
}, {
|
|
2826
|
+
exportLine: "export * from './lib/index.ts';",
|
|
2827
|
+
sourceFile: path.join(modulePath, 'src/lib/index.ts')
|
|
2828
|
+
}, {
|
|
2829
|
+
exportLine: "export * from './.metadata/locales.ts';",
|
|
2830
|
+
sourceFile: path.join(modulePath, 'src/.metadata/locales.ts')
|
|
2831
|
+
}, {
|
|
2832
|
+
exportLine: "export * from './.metadata/index.ts';",
|
|
2833
|
+
sourceFile: path.join(modulePath, 'src/.metadata/index.ts')
|
|
2834
|
+
}]);
|
|
2846
2835
|
// trim empty
|
|
2847
2836
|
jsContent = jsContent.replace('export {};\n', '');
|
|
2848
2837
|
// write
|
|
@@ -2852,6 +2841,17 @@ export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts'
|
|
|
2852
2841
|
logPrefix: 'format: '
|
|
2853
2842
|
});
|
|
2854
2843
|
}
|
|
2844
|
+
async _prependExportIfNeeded(jsContent, entries) {
|
|
2845
|
+
for (const {
|
|
2846
|
+
exportLine,
|
|
2847
|
+
sourceFile
|
|
2848
|
+
} of entries) {
|
|
2849
|
+
if ((await fse.pathExists(sourceFile)) && !jsContent.includes(exportLine)) {
|
|
2850
|
+
jsContent = `${exportLine}\n${jsContent}`;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
return jsContent;
|
|
2854
|
+
}
|
|
2855
2855
|
async _generatePackage(modulePath) {
|
|
2856
2856
|
let pkgFile;
|
|
2857
2857
|
let pkg;
|
|
@@ -2866,8 +2866,9 @@ export { ScopeModule${relativeNameCapitalize} as ScopeModule } from './index.ts'
|
|
|
2866
2866
|
// cli
|
|
2867
2867
|
for (const name of ['cli', 'zovaRest']) {
|
|
2868
2868
|
const pathCheck = path.join(modulePath, name);
|
|
2869
|
-
if (!fse.
|
|
2869
|
+
if (!(await fse.pathExists(pathCheck))) continue;
|
|
2870
2870
|
pkg = await _loadPkg();
|
|
2871
|
+
pkg.files ??= [];
|
|
2871
2872
|
const index = pkg.files.indexOf(name);
|
|
2872
2873
|
if (index === -1) {
|
|
2873
2874
|
changed = true;
|
|
@@ -8,9 +8,13 @@ export declare class CliToolsMetadata extends BeanCliBase {
|
|
|
8
8
|
execute(): Promise<void>;
|
|
9
9
|
_generateMetadata(moduleName: string, force: boolean): Promise<void>;
|
|
10
10
|
_generatePatch(content: string): string;
|
|
11
|
-
_generatePatch_resources(content: string, packageName: string, resources: string[],
|
|
11
|
+
_generatePatch_resources(content: string, packageName: string, resources: string[], isTypeImport: boolean): string;
|
|
12
12
|
_generateLocales(modulePath: any, contentLocales: any): Promise<void>;
|
|
13
13
|
_generateThis(moduleName: string, relativeNameCapitalize: string, modulePath: string): Promise<void>;
|
|
14
14
|
_generateIndex(modulePath: string): Promise<void>;
|
|
15
|
+
_prependExportIfNeeded(jsContent: string, entries: {
|
|
16
|
+
exportLine: string;
|
|
17
|
+
sourceFile: string;
|
|
18
|
+
}[]): Promise<string>;
|
|
15
19
|
_generatePackage(modulePath: string): Promise<void>;
|
|
16
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-cli-set-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.95",
|
|
4
4
|
"gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
|
|
5
5
|
"description": "vona cli-set-api",
|
|
6
6
|
"keywords": [
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"why-is-node-running": "^3.2.2",
|
|
64
64
|
"yargs-parser": "^22.0.0",
|
|
65
65
|
"@cabloy/cli": "^3.1.13",
|
|
66
|
-
"@cabloy/dotenv": "^1.2.5",
|
|
67
|
-
"@cabloy/module-glob": "^5.3.10",
|
|
68
66
|
"@cabloy/utils": "^2.1.19",
|
|
69
|
-
"@cabloy/
|
|
67
|
+
"@cabloy/dotenv": "^1.2.5",
|
|
70
68
|
"babel-plugin-vona-bean-module": "^1.1.6",
|
|
71
|
-
"
|
|
69
|
+
"@cabloy/module-glob": "^5.3.10",
|
|
70
|
+
"vona-core": "^5.1.17",
|
|
71
|
+
"@cabloy/extend": "^3.2.5"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"clean": "rimraf dist dist-cli dist-toolsIsolate tsconfig.build.tsbuildinfo tsconfig.cli.tsbuildinfo tsconfig.isolate.tsbuildinfo",
|