cabloy 5.1.140 → 5.1.141

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.
Files changed (62) hide show
  1. package/.cabloy-version +1 -1
  2. package/CHANGELOG.md +11 -0
  3. package/cabloy-docs/fullstack/framework-performance.md +3 -3
  4. package/e2e/specs/a-commerce/commerce.spec.ts +3 -3
  5. package/e2e/specs/cabloy-basic/basic.spec.ts +6 -8
  6. package/package.json +1 -1
  7. package/vona/pnpm-lock.yaml +71 -628
  8. package/zova/packages-zova/zova/package.json +2 -2
  9. package/zova/src/suite/a-commerce/modules/commerce-catalog/src/api/openapi/schemas.ts +0 -11
  10. package/zova/src/suite/a-commerce/modules/commerce-catalog/src/api/openapi/types.ts +23 -170
  11. package/zova/src/suite/a-commerce/modules/commerce-member/src/api/openapi/schemas.ts +0 -11
  12. package/zova/src/suite/a-commerce/modules/commerce-member/src/api/openapi/types.ts +23 -170
  13. package/zova/src/suite/a-commerce/modules/commerce-promotion/src/api/openapi/schemas.ts +0 -11
  14. package/zova/src/suite/a-commerce/modules/commerce-promotion/src/api/openapi/types.ts +23 -170
  15. package/zova/src/suite/a-commerce/modules/commerce-siteadmin/src/api/openapi/schemas.ts +0 -11
  16. package/zova/src/suite/a-commerce/modules/commerce-siteadmin/src/api/openapi/types.ts +23 -170
  17. package/zova/src/suite/a-commerce/modules/commerce-trade/src/api/openapi/schemas.ts +0 -11
  18. package/zova/src/suite/a-commerce/modules/commerce-trade/src/api/openapi/types.ts +23 -170
  19. package/zova/src/suite/a-home/modules/home-api/src/api/openapi/schemas.ts +0 -11
  20. package/zova/src/suite/a-home/modules/home-api/src/api/openapi/types.ts +23 -170
  21. package/zova/src/suite/a-training/modules/training-student/src/api/openapi/schemas.ts +0 -11
  22. package/zova/src/suite/a-training/modules/training-student/src/api/openapi/types.ts +23 -170
  23. package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/schemas.ts +0 -11
  24. package/zova/src/suite/cabloy-basic/modules/basic-file/src/api/openapi/types.ts +23 -170
  25. package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/openapi/schemas.ts +0 -11
  26. package/zova/src/suite/cabloy-basic/modules/basic-image/src/api/openapi/types.ts +23 -170
  27. package/zova/src/suite-vendor/a-pay/modules/a-pay/package.json +1 -1
  28. package/zova/src/suite-vendor/a-pay/modules/a-pay/src/api/openapi/schemas.ts +0 -11
  29. package/zova/src/suite-vendor/a-pay/modules/a-pay/src/api/openapi/types.ts +23 -170
  30. package/zova/src/suite-vendor/a-pay/modules/pay-mock/package.json +1 -1
  31. package/zova/src/suite-vendor/a-pay/modules/pay-mock/src/api/openapi/schemas.ts +0 -11
  32. package/zova/src/suite-vendor/a-pay/modules/pay-mock/src/api/openapi/types.ts +23 -170
  33. package/zova/src/suite-vendor/a-pay/package.json +3 -3
  34. package/zova/src/suite-vendor/a-zova/modules/a-ssrserver/package.json +1 -1
  35. package/zova/src/suite-vendor/a-zova/modules/a-ssrserver/src/service/ssrHandler.ts +1 -1
  36. package/zova/src/suite-vendor/a-zova/package.json +2 -2
  37. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/package.json +0 -56
  38. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/.metadata/index.ts +0 -404
  39. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/.metadata/locales.ts +0 -18
  40. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/.metadata/this.ts +0 -2
  41. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/bean/bean.paypal.ts +0 -99
  42. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/bean/event.paypalCancelOrder.ts +0 -15
  43. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/bean/event.paypalCaptureOrder.ts +0 -22
  44. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/bean/meta.version.ts +0 -24
  45. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/config/config.ts +0 -14
  46. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/config/errors.ts +0 -3
  47. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/config/locale/en-us.ts +0 -3
  48. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/config/locale/zh-cn.ts +0 -3
  49. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/controller/paypal.ts +0 -39
  50. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/dto/paypalOrderRecordOptions.tsx +0 -31
  51. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/dto/paypalOrderRecordPayload.tsx +0 -18
  52. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/entity/paypalRecord.tsx +0 -30
  53. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/index.ts +0 -3
  54. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/model/paypalRecord.ts +0 -10
  55. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/service/paypal.ts +0 -83
  56. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/types/index.ts +0 -1
  57. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/src/types/paypal.ts +0 -18
  58. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/tsconfig.build.json +0 -11
  59. package/vona/src/suite-vendor/a-paypal/modules/a-paypal/tsconfig.json +0 -7
  60. package/vona/src/suite-vendor/a-paypal/package.json +0 -13
  61. package/vona/src/suite-vendor/a-paypal/tsconfig.base.json +0 -4
  62. package/vona/src/suite-vendor/a-paypal/tsconfig.json +0 -10
@@ -1,24 +0,0 @@
1
- import type { IMetaVersionUpdate, IMetaVersionUpdateOptions } from 'vona-module-a-version';
2
-
3
- import { BeanBase } from 'vona';
4
- import { Meta } from 'vona-module-a-meta';
5
-
6
- @Meta()
7
- export class MetaVersion extends BeanBase implements IMetaVersionUpdate {
8
- async update(options: IMetaVersionUpdateOptions) {
9
- if (options.version === 1) {
10
- const entityPaypalRecord = this.scope.entity.paypalRecord;
11
- await this.bean.model.createTable(entityPaypalRecord.$table, table => {
12
- table.comment(entityPaypalRecord.$comment.$table);
13
- table.basicFields();
14
- table.userId();
15
- table.int0(entityPaypalRecord.status).comment(entityPaypalRecord.$comment.status);
16
- table
17
- .string(entityPaypalRecord.prepayId, 255)
18
- .comment(entityPaypalRecord.$comment.prepayId);
19
- table.json(entityPaypalRecord.payload).comment(entityPaypalRecord.$comment.payload);
20
- table.json(entityPaypalRecord.options).comment(entityPaypalRecord.$comment.options);
21
- });
22
- }
23
- }
24
- }
@@ -1,14 +0,0 @@
1
- import type { VonaApplication } from 'vona';
2
-
3
- export function config(_app: VonaApplication) {
4
- return {
5
- client: {
6
- clientId: '',
7
- clientSecret: '',
8
- logging: false,
9
- },
10
- paypal: {
11
- payFeeRate: 0.1,
12
- },
13
- };
14
- }
@@ -1,3 +0,0 @@
1
- export const errors = {
2
- TransactionException: 1001,
3
- } as const;
@@ -1,3 +0,0 @@
1
- export default {
2
- TransactionException: 'Transaction exception, please try again later',
3
- };
@@ -1,3 +0,0 @@
1
- export default {
2
- TransactionException: '交易异常,请稍后重试',
3
- };
@@ -1,39 +0,0 @@
1
- import type { TableIdentity } from 'table-identity';
2
- import type { IUser } from 'vona-module-a-user';
3
- import type { IDecoratorControllerOptions } from 'vona-module-a-web';
4
-
5
- import { BeanBase } from 'vona';
6
- import { Api, v } from 'vona-module-a-openapiutils';
7
- import { Arg, Controller, Web } from 'vona-module-a-web';
8
-
9
- import { EntityPaypalRecord } from '../entity/paypalRecord.tsx';
10
-
11
- export interface IControllerOptionsPaypal extends IDecoratorControllerOptions {}
12
-
13
- @Controller<IControllerOptionsPaypal>('paypal')
14
- export class ControllerPaypal extends BeanBase {
15
- @Web.get('getRecord/:recordId')
16
- @Api.body(EntityPaypalRecord)
17
- async getRecord(
18
- @Arg.user() user: IUser,
19
- @Arg.param('recordId', v.tableIdentity()) recordId: TableIdentity,
20
- ): Promise<EntityPaypalRecord> {
21
- return await this.scope.service.paypal.getRecord(user.id, recordId);
22
- }
23
-
24
- @Web.post('captureOrder/:recordId')
25
- async captureOrder(
26
- @Arg.user() user: IUser,
27
- @Arg.param('recordId', v.tableIdentity()) recordId: TableIdentity,
28
- ): Promise<void> {
29
- return await this.scope.service.paypal.captureOrder(user.id, recordId);
30
- }
31
-
32
- @Web.post('cancelOrder/:recordId')
33
- async cancelOrder(
34
- @Arg.user() user: IUser,
35
- @Arg.param('recordId', v.tableIdentity()) recordId: TableIdentity,
36
- ): Promise<void> {
37
- return await this.scope.service.paypal.cancelOrder(user.id, recordId);
38
- }
39
- }
@@ -1,31 +0,0 @@
1
- import type { TableIdentity } from 'table-identity';
2
- import type { IDecoratorDtoOptions } from 'vona-module-a-web';
3
-
4
- import { Api, v } from 'vona-module-a-openapiutils';
5
- import { Dto } from 'vona-module-a-web';
6
- import z from 'zod';
7
-
8
- import type { IPaypalOrderSceneRecord } from '../types/paypal.ts';
9
-
10
- export interface IDtoOptionsPaypalOrderRecordOptions extends IDecoratorDtoOptions {}
11
-
12
- @Dto<IDtoOptionsPaypalOrderRecordOptions>()
13
- export class DtoPaypalOrderRecordOptions {
14
- @Api.field()
15
- brandName: string;
16
-
17
- @Api.field()
18
- returnUrl: string;
19
-
20
- @Api.field()
21
- cancelUrl: string;
22
-
23
- @Api.field()
24
- returnTo: string;
25
-
26
- @Api.field(z.string())
27
- scene: keyof IPaypalOrderSceneRecord;
28
-
29
- @Api.field(v.tableIdentity())
30
- orderId: TableIdentity;
31
- }
@@ -1,18 +0,0 @@
1
- import type { IDecoratorDtoOptions } from 'vona-module-a-web';
2
-
3
- import { Api } from 'vona-module-a-openapiutils';
4
- import { Dto } from 'vona-module-a-web';
5
-
6
- export interface IDtoOptionsPaypalOrderRecordPayload extends IDecoratorDtoOptions {}
7
-
8
- @Dto<IDtoOptionsPaypalOrderRecordPayload>()
9
- export class DtoPaypalOrderRecordPayload {
10
- @Api.field()
11
- remark: string;
12
-
13
- @Api.field()
14
- total: string;
15
-
16
- @Api.field()
17
- currencyCode: string;
18
- }
@@ -1,30 +0,0 @@
1
- import type { TableIdentity } from 'table-identity';
2
- import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
3
-
4
- import { Api, v } from 'vona-module-a-openapiutils';
5
- import { Entity, EntityBase } from 'vona-module-a-orm';
6
-
7
- import type { IPaypalOrderRecordOptions, IPaypalOrderRecordPayload } from '../types/paypal.ts';
8
-
9
- import { DtoPaypalOrderRecordOptions } from '../dto/paypalOrderRecordOptions.tsx';
10
- import { DtoPaypalOrderRecordPayload } from '../dto/paypalOrderRecordPayload.tsx';
11
-
12
- export interface IEntityOptionsPaypalRecord extends IDecoratorEntityOptions {}
13
-
14
- @Entity<IEntityOptionsPaypalRecord>('paypalRecord')
15
- export class EntityPaypalRecord extends EntityBase {
16
- @Api.field(v.tableIdentity())
17
- userId: TableIdentity;
18
-
19
- @Api.field(v.default(0))
20
- status: number;
21
-
22
- @Api.field()
23
- prepayId: string;
24
-
25
- @Api.field(v.object(DtoPaypalOrderRecordPayload))
26
- payload: IPaypalOrderRecordPayload;
27
-
28
- @Api.field(v.object(DtoPaypalOrderRecordOptions))
29
- options: IPaypalOrderRecordOptions;
30
- }
@@ -1,3 +0,0 @@
1
- export * from './.metadata/index.ts';
2
- export * from './.metadata/locales.ts';
3
- export * from './types/index.ts';
@@ -1,10 +0,0 @@
1
- import type { IDecoratorModelOptions } from 'vona-module-a-orm';
2
-
3
- import { BeanModelBase, Model } from 'vona-module-a-orm';
4
-
5
- import { EntityPaypalRecord } from '../entity/paypalRecord.tsx';
6
-
7
- export interface IModelOptionsPaypalRecord extends IDecoratorModelOptions<EntityPaypalRecord> {}
8
-
9
- @Model<IModelOptionsPaypalRecord>({ entity: EntityPaypalRecord })
10
- export class ModelPaypalRecord extends BeanModelBase<EntityPaypalRecord> {}
@@ -1,83 +0,0 @@
1
- import type { TableIdentity } from 'table-identity';
2
-
3
- import { OrdersController, OrderStatus } from '@cabloy/paypal-server-sdk';
4
- import { BeanBase } from 'vona';
5
- import { Service } from 'vona-module-a-bean';
6
-
7
- @Service()
8
- export class ServicePaypal extends BeanBase {
9
- async getRecord(userId: TableIdentity, recordId: TableIdentity) {
10
- // get record
11
- const record = await this.scope.model.paypalRecord.getById(recordId);
12
- // check user
13
- if (!record || record.userId !== userId) {
14
- this.app.throw(403);
15
- }
16
- return record;
17
- }
18
-
19
- async captureOrder(userId: TableIdentity, recordId: TableIdentity) {
20
- const record = await this.getRecord(userId, recordId);
21
- if (!record) this.app.throw(403);
22
- // check if handled
23
- if (record.status !== 0) this.app.throw(403);
24
- // prepayId
25
- const prepayId = record.prepayId;
26
- // process
27
- let grossAmount: number;
28
- let payFee: number;
29
- let netAmount: number;
30
- let orderResult: {} | undefined;
31
- if (this.app.meta.isTest) {
32
- grossAmount = Number.parseInt((Number.parseFloat(record.payload.total) * 100) as any);
33
- payFee = grossAmount * this.scope.config.paypal.payFeeRate;
34
- netAmount = grossAmount - payFee;
35
- orderResult = undefined;
36
- } else {
37
- // capture order
38
- const ordersController = new OrdersController(this.bean.paypal.createClient());
39
- const res = await ordersController.captureOrder({ id: prepayId });
40
- if (!res.result || res.result.status !== OrderStatus.Completed) {
41
- this.scope.error.TransactionException.throw();
42
- }
43
- // update
44
- const sellerReceivableBreakdown =
45
- res.result.purchaseUnits![0].payments!.captures![0].sellerReceivableBreakdown!;
46
- grossAmount = Number.parseInt(
47
- (Number.parseFloat(sellerReceivableBreakdown.grossAmount.value) * 100) as any,
48
- );
49
- payFee = Number.parseInt(
50
- (Number.parseFloat(sellerReceivableBreakdown.paypalFee!.value) * 100) as any,
51
- );
52
- netAmount = Number.parseInt(
53
- (Number.parseFloat(sellerReceivableBreakdown.netAmount!.value) * 100) as any,
54
- );
55
- orderResult = res.result;
56
- }
57
- // update status
58
- await this.scope.model.paypalRecord.update({ id: recordId, status: 1 });
59
- // raise event
60
- await this.scope.event.paypalCaptureOrder.emit({
61
- record,
62
- breakdown: {
63
- grossAmount,
64
- payFee,
65
- netAmount,
66
- },
67
- orderResult,
68
- });
69
- }
70
-
71
- async cancelOrder(userId: TableIdentity, recordId: TableIdentity) {
72
- const record = await this.getRecord(userId, recordId);
73
- if (!record) this.app.throw(403);
74
- // check if handled
75
- if (record.status !== 0) this.app.throw(403);
76
- // update status
77
- await this.scope.model.paypalRecord.update({ id: recordId, status: -1 });
78
- // raise event
79
- await this.scope.event.paypalCancelOrder.emit({
80
- record,
81
- });
82
- }
83
- }
@@ -1 +0,0 @@
1
- export * from './paypal.ts';
@@ -1,18 +0,0 @@
1
- import type { TableIdentity } from 'table-identity';
2
-
3
- export interface IPaypalOrderSceneRecord {}
4
-
5
- export interface IPaypalOrderRecordPayload {
6
- remark: string;
7
- total: string;
8
- currencyCode: string;
9
- }
10
-
11
- export interface IPaypalOrderRecordOptions {
12
- brandName: string;
13
- returnUrl: string;
14
- cancelUrl: string;
15
- returnTo: string;
16
- scene: keyof IPaypalOrderSceneRecord;
17
- orderId: TableIdentity;
18
- }
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "declaration": true,
6
- "declarationMap": true,
7
- "emitDeclarationOnly": true,
8
- "outDir": "dist"
9
- },
10
- "include": ["src", "src/.metadata/*.ts", "src/**/*.json"]
11
- }
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base",
3
- "compilerOptions": {
4
- "noEmit": true
5
- },
6
- "include": ["src", "src/.metadata/*.ts", "src/**/*.json", "test"]
7
- }
@@ -1,13 +0,0 @@
1
- {
2
- "name": "vona-suite-a-paypal",
3
- "version": "5.1.14",
4
- "gitHead": "a79189b882c17af5911573896a781bbb0046d37d",
5
- "description": "",
6
- "author": "",
7
- "files": [],
8
- "type": "module",
9
- "dependencies": {
10
- "vona-module-a-paypal": "workspace:^"
11
- },
12
- "title": "a-paypal"
13
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.base",
3
- "compilerOptions": {}
4
- }
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.base",
3
- "compilerOptions": {},
4
- "references": [
5
- {
6
- "path": "modules/a-paypal/tsconfig.build.json"
7
- }
8
- ],
9
- "exclude": ["modules"]
10
- }