@chevre/domain 27.1.0-alpha.4 → 27.1.0-alpha.6

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.
@@ -102,8 +102,7 @@ class AdminEventRepo {
102
102
  bulkWriteOps.push({ updateOne });
103
103
  }
104
104
  else {
105
- const { id, coaInfo, description, // eslint-disable-line @typescript-eslint/no-unused-vars
106
- maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // eslint-disable-line @typescript-eslint/no-unused-vars
105
+ const { id: __id, coaInfo: _coaInfo, description: _description, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // eslint-disable-line @typescript-eslint/no-unused-vars
107
106
  ...setOnInsertFields } = $set;
108
107
  const setOnInsert = {
109
108
  ...setOnInsertFields,
@@ -24,7 +24,7 @@ const schemaDefinition = {
24
24
  identifier: String,
25
25
  name: mongoose_1.SchemaTypes.Mixed,
26
26
  additionalProperty: mongoose_1.SchemaTypes.Mixed,
27
- description: mongoose_1.SchemaTypes.Mixed,
27
+ // description: SchemaTypes.Mixed, // discontinue(2026-09-04~)
28
28
  doorTime: Date,
29
29
  endDate: Date,
30
30
  eventStatus: String,
@@ -40,17 +40,6 @@ const schemaDefinition = {
40
40
  aggregateReservation: mongoose_1.SchemaTypes.Mixed,
41
41
  aggregateOffer: mongoose_1.SchemaTypes.Mixed,
42
42
  coaInfo: mongoose_1.SchemaTypes.Mixed
43
- // ↓discontinue EventSeries(2024-09-17~)
44
- // alternateName: SchemaTypes.Mixed,
45
- // alternativeHeadline: SchemaTypes.Mixed,
46
- // duration: String,
47
- // headline: SchemaTypes.Mixed,
48
- // workPerformed: SchemaTypes.Mixed,
49
- // videoFormat: SchemaTypes.Mixed,
50
- // soundFormat: SchemaTypes.Mixed,
51
- // subtitleLanguage: SchemaTypes.Mixed,
52
- // dubLanguage: SchemaTypes.Mixed,
53
- // kanaName: String,
54
43
  };
55
44
  const schemaOptions = {
56
45
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -158,18 +158,6 @@ class ReturnOrderRepo {
158
158
  id: { $toString: '$_id' },
159
159
  ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
160
160
  };
161
- // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
162
- // if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
163
- // params.inclusion.forEach((field) => {
164
- // projection[field] = 1;
165
- // });
166
- // } else {
167
- // projection = {
168
- // __v: 0,
169
- // createdAt: 0,
170
- // updatedAt: 0
171
- // };
172
- // }
173
161
  const query = this.transactionModel.find((conditions.length > 0) ? { $and: conditions } : {})
174
162
  .select(projection);
175
163
  if (typeof params.limit === 'number' && params.limit > 0) {
@@ -243,18 +231,6 @@ class ReturnOrderRepo {
243
231
  id: { $toString: '$_id' },
244
232
  ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
245
233
  };
246
- // let projection: { [key in (IKeyOfProjection<T> | '__v' | 'createdAt' | 'updatedAt')]?: AnyExpression } = {};
247
- // if (Array.isArray(inclusion) && inclusion.length > 0) {
248
- // inclusion.forEach((field) => {
249
- // projection[field] = 1;
250
- // });
251
- // } else {
252
- // projection = {
253
- // __v: 0,
254
- // createdAt: 0,
255
- // updatedAt: 0
256
- // };
257
- // }
258
234
  const doc = await this.transactionModel.findOne({
259
235
  _id: { $eq: params.id },
260
236
  typeOf: { $eq: params.typeOf }
@@ -3,7 +3,7 @@ import type { SettingRepo } from '../../../repo/setting';
3
3
  import type { TaskRepo } from '../../../repo/task';
4
4
  import { factory } from '../../../factory';
5
5
  import { IReturnAction } from './onOrderReturned/factory';
6
- type IReturnOrderTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'id' | 'typeOf' | 'potentialActions'>;
6
+ type IReturnOrderTransaction = Pick<factory.transaction.returnOrder.ITransaction, 'typeOf' | 'potentialActions' | 'object'>;
7
7
  declare function onOrderReturned(params: {
8
8
  order: Pick<factory.order.IOrder, 'project' | 'typeOf' | 'orderNumber' | 'dateReturned' | 'id' | 'customer' | 'returner' | 'seller' | 'price' | 'priceCurrency' | 'orderDate'> & {
9
9
  orderStatus: factory.orderStatus.OrderReturned;
@@ -223,6 +223,10 @@ function createReturnPayTransactionTasks(order, returnOrderTransaction) {
223
223
  const returnPayActionsByReturnOrderTransaction = returnOrderPotentialActions?.returnPaymentMethod;
224
224
  if (Array.isArray(returnPayActionsByReturnOrderTransaction)) {
225
225
  tasks.push(...returnPayActionsByReturnOrderTransaction.map((a) => {
226
+ const data = {
227
+ ...a,
228
+ returnOrderTransaction: { object: returnOrderTransaction.object } // 返品取引廃止のために、必要な属性を拡張(2026-09-05~)
229
+ };
226
230
  return {
227
231
  project: order.project,
228
232
  name: factory_1.factory.taskName.ReturnPayTransaction,
@@ -231,7 +235,7 @@ function createReturnPayTransactionTasks(order, returnOrderTransaction) {
231
235
  remainingNumberOfTries: 10,
232
236
  numberOfTried: 0,
233
237
  executionResults: [],
234
- data: a
238
+ data
235
239
  };
236
240
  }));
237
241
  }
@@ -15,6 +15,7 @@ declare function returnOrder(params: {
15
15
  id: string;
16
16
  };
17
17
  useOnOrderStatusChanged: boolean;
18
+ returnOrderTransaction?: Pick<factory.transaction.returnOrder.ITransaction, 'object' | 'potentialActions' | 'typeOf'>;
18
19
  }): (repos: {
19
20
  acceptedOffer: AcceptedOfferRepo;
20
21
  actions: {
@@ -44,19 +44,25 @@ function returnOrder(params) {
44
44
  // OrderDeliveredへの処理が進行中と考えられるので、ひとまず失敗させてリトライに期待
45
45
  throw new factory_1.factory.errors.Argument('object.orderNumber', `orderStatus not returnable: ${order.orderStatus}`);
46
46
  }
47
- // 返品取引検索
48
- const returnOrderTransactions = await repos.returnOrder.findReturnOrderTransactions({
49
- limit: 1,
50
- page: 1,
51
- project: { id: { $eq: order.project.id } },
52
- typeOf: factory_1.factory.transactionType.ReturnOrder,
53
- statuses: [factory_1.factory.transactionStatusType.Confirmed],
54
- object: { order: { orderNumbers: [orderNumber] } },
55
- inclusion: ['typeOf', 'potentialActions', 'object']
56
- });
57
- const returnOrderTransaction = returnOrderTransactions.shift();
58
- if (returnOrderTransaction === undefined) {
59
- throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.ReturnOrder);
47
+ let returnOrderTransaction;
48
+ if (params.returnOrderTransaction !== undefined) {
49
+ returnOrderTransaction = params.returnOrderTransaction;
50
+ }
51
+ else {
52
+ // 互換性維持対応としての返品取引検索(2026-09-05~)
53
+ const returnOrderTransactions = await repos.returnOrder.findReturnOrderTransactions({
54
+ limit: 1,
55
+ page: 1,
56
+ project: { id: { $eq: order.project.id } },
57
+ typeOf: factory_1.factory.transactionType.ReturnOrder,
58
+ statuses: [factory_1.factory.transactionStatusType.Confirmed],
59
+ object: { order: { orderNumbers: [orderNumber] } },
60
+ inclusion: ['typeOf', 'potentialActions', 'object']
61
+ });
62
+ returnOrderTransaction = returnOrderTransactions.shift();
63
+ if (returnOrderTransaction === undefined) {
64
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.ReturnOrder);
65
+ }
60
66
  }
61
67
  const simpleOrder = {
62
68
  typeOf: order.typeOf,
@@ -57,7 +57,8 @@ function call(params) {
57
57
  return async ({ connection }) => {
58
58
  await returnPayTransaction({
59
59
  ...params.data,
60
- sameAs: { id: params.id }
60
+ sameAs: { id: params.id },
61
+ project: { id: params.project.id }
61
62
  })({
62
63
  actions: {
63
64
  pay: new pay_1.PayActionRepo(connection),
@@ -86,8 +87,6 @@ function task2actionAttributes(params) {
86
87
  const purpose = {
87
88
  typeOf: order.typeOf,
88
89
  orderNumber: order.orderNumber,
89
- // price: order.price,
90
- // priceCurrency: order.priceCurrency,
91
90
  orderDate: order.orderDate
92
91
  };
93
92
  return {
@@ -101,7 +100,7 @@ function task2actionAttributes(params) {
101
100
  ...(typeof sameAs?.id === 'string') ? { sameAs: { id: sameAs.id, typeOf: 'Task' } } : undefined
102
101
  };
103
102
  }
104
- function fixOrderAndTransaction(params) {
103
+ function fixOrderAndTransaction(params, project) {
105
104
  return async (repos) => {
106
105
  const paymentMethodId = params.object.paymentMethodId;
107
106
  // objectから注文を特定する(2024-06-19~)
@@ -115,19 +114,25 @@ function fixOrderAndTransaction(params) {
115
114
  }
116
115
  // const orderNumber = params.purpose.orderNumber;
117
116
  const orderNumber = orderByPaymentMethodId.orderNumber;
118
- const returnOrderTransaction = (await repos.returnOrder.findReturnOrderTransactions({
119
- limit: 1,
120
- page: 1,
121
- typeOf: factory_1.factory.transactionType.ReturnOrder,
122
- object: { order: { orderNumbers: [orderNumber] } },
123
- inclusion: ['object', 'project']
124
- })).shift();
125
- if (returnOrderTransaction === undefined) {
126
- throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.ReturnOrder);
117
+ let returnOrderTransaction;
118
+ if (params.returnOrderTransaction !== undefined) {
119
+ returnOrderTransaction = params.returnOrderTransaction;
120
+ }
121
+ else {
122
+ returnOrderTransaction = (await repos.returnOrder.findReturnOrderTransactions({
123
+ limit: 1,
124
+ page: 1,
125
+ typeOf: factory_1.factory.transactionType.ReturnOrder,
126
+ object: { order: { orderNumbers: [orderNumber] } },
127
+ inclusion: ['object']
128
+ })).shift();
129
+ if (returnOrderTransaction === undefined) {
130
+ throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.ReturnOrder);
131
+ }
127
132
  }
128
133
  const order = await repos.order.projectFieldsByOrderNumber({
129
134
  orderNumber,
130
- project: { id: returnOrderTransaction.project.id },
135
+ project: { id: project.id },
131
136
  inclusion: ['seller', 'project', 'dateReturned', 'typeOf', 'price', 'priceCurrency', 'orderNumber', 'orderDate', 'customer']
132
137
  });
133
138
  return { order, returnOrderTransaction };
@@ -138,7 +143,7 @@ function fixOrderAndTransaction(params) {
138
143
  */
139
144
  function returnPayTransaction(taskData) {
140
145
  return async (repos) => {
141
- const { order, returnOrderTransaction } = await fixOrderAndTransaction(taskData)(repos);
146
+ const { order, returnOrderTransaction } = await fixOrderAndTransaction(taskData, { id: taskData.project.id })(repos);
142
147
  const paymentServiceType = taskData.object.issuedThrough?.typeOf;
143
148
  if (typeof paymentServiceType !== 'string' || paymentServiceType.length === 0) {
144
149
  throw new factory_1.factory.errors.ArgumentNull('object.issuedThrough.typeOf');
@@ -21,12 +21,14 @@ function createImmediateTasks(params) {
21
21
  if (Array.isArray(returnOrderPotentialActions)) {
22
22
  // 返品タスク
23
23
  const returnOrderTask = returnOrderPotentialActions.map((r) => {
24
+ const { object, potentialActions, typeOf } = transaction;
24
25
  // data最適化(2023-08-22~)
25
26
  const returnOrderTaskData = {
26
27
  agent: r.agent,
27
28
  object: r.object,
28
29
  project: transaction.project,
29
- typeOf: r.typeOf
30
+ typeOf: r.typeOf,
31
+ returnOrderTransaction: { object, potentialActions, typeOf } // add(2026-09-05~)
30
32
  };
31
33
  return {
32
34
  project: transaction.project,
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.2",
14
+ "@chevre/factory": "10.5.0-alpha.6",
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": "27.1.0-alpha.4"
91
+ "version": "27.1.0-alpha.6"
92
92
  }