@chevre/domain 28.0.0-alpha.0 → 28.0.0-alpha.2

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.
@@ -77,7 +77,7 @@ export declare class AdminTransactionRepo {
77
77
  seller: import("@chevre/factory/lib/chevre/transaction").ISeller;
78
78
  typeOf: factory.transactionType.ReturnOrder;
79
79
  expires: Date;
80
- result?: import("@chevre/factory/lib/chevre/transaction/returnOrder").IResult | undefined;
80
+ result?: undefined;
81
81
  startDate: Date;
82
82
  endDate?: Date | undefined;
83
83
  agent: import("@chevre/factory/lib/chevre/transaction").IAgent;
@@ -115,7 +115,7 @@ export declare class AdminTransactionRepo {
115
115
  seller: import("@chevre/factory/lib/chevre/transaction").ISeller;
116
116
  typeOf: factory.transactionType.ReturnOrder;
117
117
  expires: Date;
118
- result?: import("@chevre/factory/lib/chevre/transaction/returnOrder").IResult | undefined;
118
+ result?: undefined;
119
119
  startDate: Date;
120
120
  endDate?: Date | undefined;
121
121
  agent: import("@chevre/factory/lib/chevre/transaction").IAgent;
@@ -613,7 +613,9 @@ class OrderRepo {
613
613
  orderNumber: params.orderNumber,
614
614
  project: { id: params.project.id },
615
615
  inclusion: [
616
- 'project', 'typeOf', 'orderNumber', 'dateReturned',
616
+ 'project', 'typeOf', 'orderNumber',
617
+ 'orderStatus', // すでに変更済かどうか検証するので必要
618
+ 'dateReturned',
617
619
  'customer', 'returner', 'seller', 'price', 'priceCurrency', 'orderDate'
618
620
  ]
619
621
  });
@@ -1,7 +1,10 @@
1
1
  import type { RedisClientType } from '@redis/client';
2
2
  import { factory } from '../../factory';
3
- type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
4
- export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType.ReturnOrder>, IStartedTransactionFields>;
3
+ export type IStartedTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'expires' | 'id' | 'startDate' | 'status'>;
4
+ export type IReturnOrderAsValue = Pick<factory.transaction.returnOrder.IAttributes, 'agent' | 'object' | 'project' | 'startDate' | 'typeOf'>;
5
+ export type IReturnOrderAsFindResult = IReturnOrderAsValue & {
6
+ id: string;
7
+ };
5
8
  /**
6
9
  * 返品取引リポジトリ
7
10
  */
@@ -12,10 +15,8 @@ export declare class ReturnOrderInProgressRepo {
12
15
  /**
13
16
  * 取引を開始する
14
17
  */
15
- startReturnOrder(params: factory.transaction.IStartParams<factory.transactionType.ReturnOrder>): Promise<IStartedTransaction>;
18
+ startReturnOrder(params: factory.transaction.returnOrder.IStartParams): Promise<IStartedTransaction>;
16
19
  findReturnOrderById(params: {
17
- typeOf: factory.transactionType.ReturnOrder;
18
20
  id: string;
19
- }): Promise<factory.transaction.ITransaction<factory.transactionType.ReturnOrder>>;
21
+ }): Promise<IReturnOrderAsFindResult>;
20
22
  }
21
- export {};
@@ -20,7 +20,6 @@ class ReturnOrderInProgressRepo {
20
20
  */
21
21
  async startReturnOrder(params) {
22
22
  const status = factory_1.factory.transactionStatusType.InProgress;
23
- const tasksExportAction = { actionStatus: factory_1.factory.actionStatusType.PotentialActionStatus };
24
23
  const startDate = new Date();
25
24
  let expires;
26
25
  const { typeOf } = params;
@@ -33,10 +32,9 @@ class ReturnOrderInProgressRepo {
33
32
  else {
34
33
  throw new factory_1.factory.errors.ArgumentNull('expiresInSeconds');
35
34
  }
36
- const { agent, project, object, seller } = params;
35
+ const { agent, project, object } = params;
37
36
  const creatingTransaction = {
38
- status, startDate, expires, typeOf, tasksExportAction,
39
- agent, project, seller, object
37
+ startDate, typeOf, agent, project, object
40
38
  };
41
39
  const id = `${ReturnOrderInProgressRepo.KEY_PREFIX}:${startDate.getTime()}`;
42
40
  const result = await this.redisClient.set(id, JSON.stringify(creatingTransaction), {
@@ -50,18 +48,16 @@ class ReturnOrderInProgressRepo {
50
48
  return { expires, id, startDate, status };
51
49
  }
52
50
  async findReturnOrderById(params) {
53
- let transaction;
54
51
  const transactionJson = await this.redisClient.get(params.id);
55
52
  if (typeof transactionJson !== 'string') {
56
53
  throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.ReturnOrder);
57
54
  }
55
+ let transactionAsFindResult;
58
56
  try {
59
- transaction = JSON.parse(transactionJson);
60
- transaction = {
61
- ...transaction,
62
- startDate: (0, moment_1.default)(transaction.startDate)
63
- .toDate(),
64
- expires: (0, moment_1.default)(transaction.expires)
57
+ const transactionAsValue = JSON.parse(transactionJson);
58
+ transactionAsFindResult = {
59
+ ...transactionAsValue,
60
+ startDate: (0, moment_1.default)(transactionAsValue.startDate)
65
61
  .toDate(),
66
62
  id: params.id
67
63
  };
@@ -70,7 +66,7 @@ class ReturnOrderInProgressRepo {
70
66
  console.error('transaction parse error:', error);
71
67
  throw error;
72
68
  }
73
- return transaction;
69
+ return transactionAsFindResult;
74
70
  }
75
71
  }
76
72
  exports.ReturnOrderInProgressRepo = ReturnOrderInProgressRepo;
@@ -10,7 +10,10 @@ function call(params) {
10
10
  return async ({ connection }) => {
11
11
  const { data } = params;
12
12
  await exportTasksById({
13
- transaction: data
13
+ transaction: {
14
+ ...data,
15
+ project: params.project
16
+ }
14
17
  })({
15
18
  task: new task_1.TaskRepo(connection),
16
19
  });
@@ -49,5 +49,5 @@ declare function confirm(params: factory.transaction.returnOrder.IConfirmParams
49
49
  dateReturned: Date;
50
50
  };
51
51
  };
52
- }): (repos: IConfirmRepos) => Promise<import("@chevre/factory/lib/chevre/transaction/returnOrder").IResult>;
52
+ }): (repos: IConfirmRepos) => Promise<void>;
53
53
  export { IStartOperationRepos, IConfirmRepos, preStart, start, confirm, };
@@ -63,7 +63,7 @@ function saveMessagesIfNeeded(params) {
63
63
  */
64
64
  function confirm(params) {
65
65
  return async (repos) => {
66
- const transaction = await repos.returnOrderInProgress.findReturnOrderById({ typeOf: factory_1.factory.transactionType.ReturnOrder, id: params.id });
66
+ const transaction = await repos.returnOrderInProgress.findReturnOrderById({ id: params.id });
67
67
  if (typeof params.agent?.id === 'string' && transaction.agent.id !== params.agent.id) {
68
68
  throw new factory_1.factory.errors.Forbidden('Transaction not yours');
69
69
  }
@@ -95,16 +95,13 @@ function confirm(params) {
95
95
  if (typeof setting?.defaultSenderEmail !== 'string') {
96
96
  throw new factory_1.factory.errors.NotFound('setting.defaultSenderEmail');
97
97
  }
98
- const result = {};
99
98
  const { emailMessages, potentialActions } = await (0, potentialActions_1.createPotentialActions)({
100
99
  dateReturned: params.object.order.dateReturned,
101
100
  orders: returningOrders,
102
101
  transaction: transaction,
103
102
  ...(params.potentialActions !== undefined) ? { potentialActions: params.potentialActions } : undefined,
104
103
  // ...(emailMessageOnOrderReturned !== undefined) ? { emailMessageOnOrderReturned } : undefined
105
- },
106
- // settings
107
- setting);
104
+ }, setting);
108
105
  // save messages(2024-06-27~)
109
106
  await saveMessagesIfNeeded({
110
107
  project: { id: transaction.project.id },
@@ -128,12 +125,10 @@ function confirm(params) {
128
125
  agent: transaction.agent,
129
126
  startDate: transaction.startDate,
130
127
  object: transaction.object,
131
- project: transaction.project,
132
- potentialActions,
133
- endDate
128
+ potentialActions
134
129
  }
135
130
  };
136
131
  await repos.task.runTaskByIdentifier(confirmReturnOrderTask);
137
- return result;
132
+ // return result;
138
133
  };
139
134
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.1090.0",
13
13
  "@aws-sdk/credential-providers": "3.1090.0",
14
- "@chevre/factory": "10.5.0-alpha.7",
14
+ "@chevre/factory": "10.5.0-alpha.8",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -88,5 +88,5 @@
88
88
  "postversion": "git push origin --tags",
89
89
  "prepublishOnly": "npm run clean && npm run build"
90
90
  },
91
- "version": "28.0.0-alpha.0"
91
+ "version": "28.0.0-alpha.2"
92
92
  }