vona-cli-set-api 1.0.362 → 1.0.366

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.
@@ -297,6 +297,18 @@
297
297
  ],
298
298
  "description": "record.locale"
299
299
  },
300
+ "record.mailclient": {
301
+ "scope": "typescript,typescriptreact",
302
+ "prefix": "recordmailclient",
303
+ "body": [
304
+ "declare module 'vona-module-a-mail' {",
305
+ " export interface IMailClientRecord {",
306
+ " $0: never;",
307
+ " }",
308
+ "}"
309
+ ],
310
+ "description": "record.mailclient"
311
+ },
300
312
  "findManyQueryTransform": {
301
313
  "scope": "typescript,typescriptreact",
302
314
  "prefix": "findmanyquerytransform",
@@ -70,4 +70,16 @@ DATABASE_CLIENT_MYSQL_DATABASE = mysql
70
70
  REDIS_DEFAULT_HOST = 127.0.0.1
71
71
  REDIS_DEFAULT_PORT = 6379
72
72
  REDIS_DEFAULT_PASSWORD =
73
- REDIS_DEFAULT_DB = 0
73
+ REDIS_DEFAULT_DB = 0
74
+
75
+ # mail
76
+
77
+ MAIL_DEFAULT_CLIENT = 'system'
78
+
79
+ MAIL_SYSTEM_TRANSPORT_SERVICE =
80
+ MAIL_SYSTEM_TRANSPORT_HOST =
81
+ MAIL_SYSTEM_TRANSPORT_PORT =
82
+ MAIL_SYSTEM_TRANSPORT_SECURE = false
83
+ MAIL_SYSTEM_TRANSPORT_AUTH_USER =
84
+ MAIL_SYSTEM_TRANSPORT_AUTH_PASS =
85
+ MAIL_SYSTEM_DEFAULTS_FROM = no.reply@cabloy.com
@@ -0,0 +1,3 @@
1
+ # mail
2
+
3
+ MAIL_SYSTEM_TRANSPORT_SERVICE = test
@@ -0,0 +1,3 @@
1
+ # mail
2
+
3
+ MAIL_SYSTEM_TRANSPORT_SERVICE = test
@@ -46,7 +46,7 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "vona": "^5.0.208"
49
+ "vona": "^5.0.210"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@cabloy/lint": "^5.0.16",
@@ -1,4 +1,5 @@
1
1
  import type { ILoggerOptionsClientInfo, VonaAppInfo, VonaApplication, VonaConfigEnv, VonaConfigOptional } from 'vona';
2
+ import type { IMailClientRecord } from 'vona-module-a-mail';
2
3
  import type { IDatabaseClientRecord } from 'vona-module-a-orm';
3
4
  import type * as Winston from 'winston';
4
5
  import { replaceTemplate } from '@cabloy/utils';
@@ -20,6 +21,12 @@ declare module 'vona-module-a-orm' {
20
21
  export default function (appInfo: VonaAppInfo, env: VonaConfigEnv) {
21
22
  const config = {} as VonaConfigOptional;
22
23
 
24
+ // modules
25
+ config.modules = {};
26
+
27
+ // onions
28
+ config.onions = {};
29
+
23
30
  // meta
24
31
  config.meta = {
25
32
  flavor: appInfo.configMeta.flavor,
@@ -87,7 +94,7 @@ export default function (appInfo: VonaAppInfo, env: VonaConfigEnv) {
87
94
  this.bean.logger.makeTransportFile(clientInfo, 'http', 'http'),
88
95
  this.bean.logger.makeTransportFile(clientInfo, 'combined'),
89
96
  this.bean.logger.makeTransportConsole(clientInfo),
90
- ].filter(item => !!item);
97
+ ];
91
98
  return { transports };
92
99
  },
93
100
  },
@@ -153,11 +160,27 @@ export default function (appInfo: VonaAppInfo, env: VonaConfigEnv) {
153
160
  ...config.database.clients![env.DATABASE_DEFAULT_CLIENT as keyof IDatabaseClientRecord],
154
161
  };
155
162
 
156
- // modules
157
- config.modules = {};
158
-
159
- // onions
160
- config.onions = {};
163
+ // mail
164
+ config.modules['a-mail'] = {
165
+ defaultClient: env.MAIL_DEFAULT_CLIENT as keyof IMailClientRecord,
166
+ clients: {
167
+ system: {
168
+ transport: {
169
+ service: env.MAIL_SYSTEM_TRANSPORT_SERVICE || undefined,
170
+ host: env.MAIL_SYSTEM_TRANSPORT_HOST || undefined,
171
+ port: env.MAIL_SYSTEM_TRANSPORT_PORT ? Number.parseInt(env.MAIL_SYSTEM_TRANSPORT_PORT) : undefined,
172
+ secure: env.MAIL_SYSTEM_TRANSPORT_SECURE === 'true',
173
+ auth: {
174
+ user: env.MAIL_SYSTEM_TRANSPORT_AUTH_USER || undefined,
175
+ pass: env.MAIL_SYSTEM_TRANSPORT_AUTH_PASS || undefined,
176
+ },
177
+ },
178
+ defaults: {
179
+ from: env.MAIL_SYSTEM_DEFAULTS_FROM || undefined,
180
+ },
181
+ },
182
+ },
183
+ };
161
184
 
162
185
  return config;
163
186
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-home-index",
3
3
  "type": "module",
4
- "version": "5.0.10",
4
+ "version": "5.0.11",
5
5
  "title": "home-index",
6
6
  "vonaModule": {
7
7
  "dependencies": {
@@ -7,7 +7,7 @@ export class MetaPrintTip extends BeanBase implements IMetaPrintTipExecute {
7
7
  async execute(): Promise<TypeMetaPrintTipResult> {
8
8
  return {
9
9
  title: 'home',
10
- message: this.app.util.getAbsoluteUrl(),
10
+ message: this.bean.core.getAbsoluteUrl(),
11
11
  };
12
12
  }
13
13
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-suite-a-home",
3
3
  "type": "module",
4
- "version": "5.0.22",
4
+ "version": "5.0.23",
5
5
  "title": "a-home",
6
6
  "description": "",
7
7
  "author": "zhennann",
@@ -36,6 +36,7 @@ export class CliBinDev extends BeanCliBase {
36
36
  execArgs: [getImportEsm()],
37
37
  // execArgs: ['--experimental-transform-types', getImportEsm(), '--trace-deprecation'],
38
38
  // signal: 'SIGHUP',
39
+ ignore: ['test/**/*.test.ts', 'src/backend/play'],
39
40
  });
40
41
  nodemon.on('quit', () => {
41
42
  resolve(undefined);
@@ -5,10 +5,12 @@ declare module '@cabloy/cli' {
5
5
  mode?: VonaMetaMode;
6
6
  flavor?: VonaMetaFlavor;
7
7
  retainRuntime?: boolean;
8
+ attach?: boolean;
8
9
  }
9
10
  }
10
11
  export declare class CliBinPlay extends BeanCliBase {
11
12
  execute(): Promise<void>;
12
13
  _play(projectPath: string): Promise<void>;
13
- _run(projectPath: string): Promise<void>;
14
+ _runAttach(projectPath: string): Promise<void>;
15
+ _runIsolate(projectPath: string): Promise<void>;
14
16
  }
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { BeanCliBase } from '@cabloy/cli';
3
3
  import fse from 'fs-extra';
4
- import { getImportEsm } from "../utils.js";
4
+ import { getImportEsm, loadJSONFile } from "../utils.js";
5
5
  import { generateVonaMeta } from "./toolsBin/generateVonaMeta.js";
6
6
  export class CliBinPlay extends BeanCliBase {
7
7
  async execute() {
@@ -25,9 +25,49 @@ export class CliBinPlay extends BeanCliBase {
25
25
  };
26
26
  await generateVonaMeta(configMeta, configOptions);
27
27
  }
28
- await this._run(projectPath);
28
+ if (argv.attach) {
29
+ await this._runAttach(projectPath);
30
+ }
31
+ else {
32
+ await this._runIsolate(projectPath);
33
+ }
34
+ }
35
+ async _runAttach(projectPath) {
36
+ const runtimeFile = path.join(projectPath, '.app/runtime/-.json');
37
+ if (!fse.existsSync(runtimeFile))
38
+ throw new Error('dev server not running');
39
+ // args
40
+ let args = [];
41
+ const pos = process.argv.indexOf(':bin:play');
42
+ if (pos > -1) {
43
+ args = args.concat(process.argv.slice(pos + 1));
44
+ }
45
+ const body = { args, projectPath };
46
+ //
47
+ const runtime = await loadJSONFile(runtimeFile);
48
+ const runtimeCore = runtime['a-core'];
49
+ const runtimeUser = runtime['a-user'];
50
+ const result = await fetch(`${runtimeCore.protocol}://${runtimeCore.host}/api/play`, {
51
+ method: 'post',
52
+ headers: {
53
+ 'content-type': 'application/json',
54
+ 'authorization': `Bearer ${runtimeUser.accessToken}`,
55
+ },
56
+ body: JSON.stringify(body),
57
+ });
58
+ if (result.status !== 200) {
59
+ const message = `error: ${result.status}, ${result.statusText}`;
60
+ throw new Error(message);
61
+ }
62
+ const res = await result.json();
63
+ if (res.code !== 0)
64
+ throw new Error(res.message);
65
+ if (res.data !== undefined) {
66
+ // eslint-disable-next-line no-console
67
+ console.log(res.data);
68
+ }
29
69
  }
30
- async _run(projectPath) {
70
+ async _runIsolate(projectPath) {
31
71
  // testFile
32
72
  let testFile = path.join(import.meta.dirname, './toolsBin/play.ts');
33
73
  if (!fse.existsSync(testFile)) {
@@ -17,6 +17,7 @@ const __template = `import type { IArgv, VonaApplication } from 'vona';
17
17
  export async function main(app: VonaApplication, _argv: IArgv) {
18
18
  console.log(import.meta.filename);
19
19
  console.log(app.config.meta);
20
+ return 'Hello VonaJS';
20
21
  }
21
22
  `;
22
23
  const projectPath = process.argv[2];
@@ -40,7 +41,11 @@ async function playRun(projectPath) {
40
41
  }
41
42
  // run
42
43
  const playInstance = await import(__rewriteRelativeImportExtension(pathToHref(playFile)));
43
- await playInstance.main(app, argv);
44
+ const res = await playInstance.main(app, argv);
45
+ if (res !== undefined) {
46
+ // eslint-disable-next-line no-console
47
+ console.log(res);
48
+ }
44
49
  // close
45
50
  await app.close();
46
51
  // handles
@@ -18,6 +18,11 @@ declare const _default: {
18
18
  description: string;
19
19
  type: string;
20
20
  };
21
+ attach: {
22
+ alias: string;
23
+ description: string;
24
+ type: string;
25
+ };
21
26
  };
22
27
  };
23
28
  export default _default;
@@ -3,7 +3,7 @@ export default {
3
3
  info: {
4
4
  version: '5.0.0',
5
5
  title: 'Cli: Bin: Play',
6
- usage: 'vona :bin:play [index.ts] [--flavor=] [--retainRuntime=]',
6
+ usage: 'vona :bin:play [index.ts] [--flavor=] [--retainRuntime=] [--attach]',
7
7
  },
8
8
  options: {
9
9
  mode: {
@@ -18,5 +18,10 @@ export default {
18
18
  description: 'retainRuntime',
19
19
  type: 'boolean',
20
20
  },
21
+ attach: {
22
+ alias: 'a',
23
+ description: 'attach',
24
+ type: 'boolean',
25
+ },
21
26
  },
22
27
  };
@@ -7,6 +7,7 @@ declare const _default: {
7
7
  };
8
8
  options: {
9
9
  module: {
10
+ alias: string;
10
11
  description: string;
11
12
  type: string;
12
13
  };
@@ -7,6 +7,7 @@ export default {
7
7
  },
8
8
  options: {
9
9
  module: {
10
+ alias: 'm',
10
11
  description: 'module name',
11
12
  type: 'string',
12
13
  },
@@ -108,6 +108,11 @@ export declare const commands: {
108
108
  description: string;
109
109
  type: string;
110
110
  };
111
+ attach: {
112
+ alias: string;
113
+ description: string;
114
+ type: string;
115
+ };
111
116
  };
112
117
  };
113
118
  test: {
@@ -272,6 +277,7 @@ export declare const commands: {
272
277
  };
273
278
  options: {
274
279
  module: {
280
+ alias: string;
275
281
  description: string;
276
282
  type: string;
277
283
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-cli-set-api",
3
3
  "type": "module",
4
- "version": "1.0.362",
4
+ "version": "1.0.366",
5
5
  "description": "vona cli-set-api",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "@babel/plugin-proposal-decorators": "^7.25.9",
32
32
  "@babel/plugin-transform-class-properties": "^7.25.9",
33
33
  "@babel/plugin-transform-typescript": "^7.26.8",
34
- "@cabloy/cli": "^3.0.58",
34
+ "@cabloy/cli": "^3.0.59",
35
35
  "@cabloy/dotenv": "^1.1.10",
36
36
  "@cabloy/extend": "^3.1.10",
37
37
  "@cabloy/module-glob": "^5.2.32",
@@ -61,9 +61,9 @@
61
61
  "ts-node-maintained": "^10.9.6",
62
62
  "urllib": "^4.6.11",
63
63
  "uuid": "^11.1.0",
64
- "vona-core": "^5.0.97",
64
+ "vona-core": "^5.0.98",
65
65
  "why-is-node-running": "^3.2.2",
66
- "yargs-parser": "^21.1.1"
66
+ "yargs-parser": "^22.0.0"
67
67
  },
68
68
  "gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
69
69
  "scripts": {