@chevre/domain 28.0.0-alpha.3 → 28.0.0-alpha.4

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 (26) hide show
  1. package/lib/chevre/eventEmitter/transaction.d.ts +2 -2
  2. package/lib/chevre/eventEmitter/transaction.js +1 -1
  3. package/lib/chevre/repo/adminTransaction.js +0 -98
  4. package/lib/chevre/repo/aggregateTransaction.d.ts +0 -1
  5. package/lib/chevre/repo/aggregateTransaction.js +0 -1
  6. package/lib/chevre/repo/mongoose/schemas/transaction.js +38 -26
  7. package/lib/chevre/repo/orderInTransaction.js +0 -6
  8. package/lib/chevre/repo/transaction/placeOrder.d.ts +0 -5
  9. package/lib/chevre/repo/transaction/placeOrder.js +16 -76
  10. package/lib/chevre/repo/transaction.js +0 -1
  11. package/lib/chevre/service/aggregation/system.js +1 -3
  12. package/lib/chevre/service/offer/event/authorize.js +1 -4
  13. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
  14. package/lib/chevre/service/offer/event/voidTransaction.js +2 -5
  15. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -4
  16. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +2 -8
  17. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -4
  18. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -4
  19. package/lib/chevre/service/payment/any/authorize.js +1 -1
  20. package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +1 -4
  21. package/lib/chevre/service/payment/any/processVoidPayTransaction.js +2 -2
  22. package/lib/chevre/service/payment/any/publishPaymentUrl.js +1 -1
  23. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -2
  24. package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -4
  25. package/lib/chevre/service/transaction/placeOrder/updateAgent.js +1 -4
  26. package/package.json +1 -1
@@ -5,12 +5,12 @@ interface IListenArgsOnTransactionStatusChanged {
5
5
  * 取引ID
6
6
  */
7
7
  id: string;
8
- typeOf: factory.transactionType;
8
+ typeOf: factory.transactionType.PlaceOrder;
9
9
  status: factory.transactionStatusType;
10
10
  }
11
11
  type IOnTransactionStatusChangedListener = (listenArgs: IListenArgsOnTransactionStatusChanged) => void;
12
12
  /**
13
- * 取引イベントエミッター
13
+ * 注文取引イベントエミッター
14
14
  */
15
15
  declare class TransactionEventEmitter extends EventEmitter {
16
16
  onTransactionStatusChanged(listner: IOnTransactionStatusChangedListener): void;
@@ -7,7 +7,7 @@ var EventName;
7
7
  EventName["OnTransactionStatusChanged"] = "OnTransactionStatusChanged";
8
8
  })(EventName || (EventName = {}));
9
9
  /**
10
- * 取引イベントエミッター
10
+ * 注文取引イベントエミッター
11
11
  */
12
12
  class TransactionEventEmitter extends events_1.EventEmitter {
13
13
  onTransactionStatusChanged(listner) {
@@ -68,51 +68,6 @@ class AdminTransactionRepo {
68
68
  })
69
69
  .exec();
70
70
  }
71
- // /**
72
- // * タスクエクスポートの遅延している取引について明示的にemitTransactionStatusChangedを実行する
73
- // */
74
- // public async exportTasksMany(params: {
75
- // now: Date;
76
- // delayInSeconds: number;
77
- // status: {
78
- // $in: factory.transactionStatusType[];
79
- // };
80
- // limit: number;
81
- // }) {
82
- // const delayedTransactions = await this.transactionModel.find({
83
- // status: { $in: params.status.$in },
84
- // 'tasksExportAction.actionStatus': {
85
- // $exists: true,
86
- // $eq: factory.actionStatusType.PotentialActionStatus
87
- // },
88
- // endDate: {
89
- // $exists: true,
90
- // $lt: moment(params.now)
91
- // .add(-params.delayInSeconds, 'seconds')
92
- // .toDate()
93
- // }
94
- // })
95
- // .select({
96
- // _id: 0,
97
- // id: { $toString: '$_id' },
98
- // typeOf: 1,
99
- // status: 1
100
- // })
101
- // .limit(params.limit)
102
- // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
103
- // .lean<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'status' | 'typeOf'>[]>()
104
- // .exec();
105
- // if (delayedTransactions.length > 0) {
106
- // delayedTransactions.forEach((delayedTransaction) => {
107
- // transactionEventEmitter.emitTransactionStatusChanged({
108
- // id: delayedTransaction.id,
109
- // typeOf: delayedTransaction.typeOf,
110
- // status: delayedTransaction.status
111
- // });
112
- // });
113
- // }
114
- // return delayedTransactions;
115
- // }
116
71
  /**
117
72
  * add(2025-03-13~)
118
73
  */
@@ -167,59 +122,6 @@ class AdminTransactionRepo {
167
122
  return doc;
168
123
  }
169
124
  }
170
- // /**
171
- // * 取引を期限切れにする
172
- // */
173
- // public async makeExpired(params: {
174
- // expires: { $lt: Date };
175
- // limit: number; // add limit(2025-02-27~)
176
- // }): Promise<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'typeOf'>[]> {
177
- // if (typeof params.limit !== 'number' || params.limit === 0) {
178
- // throw new factory.errors.ArgumentNull('limit');
179
- // }
180
- // const sort: { [key in keyof factory.transaction.ITransaction<factory.transactionType>]?: factory.sortType } = {
181
- // expires: factory.sortType.Ascending
182
- // };
183
- // // IDをemitしたいのでまずリスト検索(2023-04-27~)
184
- // const expiringTransactions =
185
- // await this.transactionModel.find({
186
- // status: { $eq: factory.transactionStatusType.InProgress },
187
- // expires: { $lt: params.expires.$lt }
188
- // })
189
- // .select({
190
- // _id: 0,
191
- // id: { $toString: '$_id' },
192
- // typeOf: 1
193
- // })
194
- // .limit(params.limit)
195
- // .sort(sort) // sort(2025-03-03~)
196
- // .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
197
- // .lean<Pick<factory.transaction.ITransaction<factory.transactionType>, 'id' | 'typeOf'>[]>()
198
- // .exec();
199
- // if (expiringTransactions.length > 0) {
200
- // // ステータスと期限を見て更新
201
- // await this.transactionModel.updateMany(
202
- // {
203
- // _id: { $in: expiringTransactions.map((t) => t.id) },
204
- // status: { $eq: factory.transactionStatusType.InProgress },
205
- // expires: { $lt: params.expires.$lt }
206
- // },
207
- // {
208
- // status: factory.transactionStatusType.Expired,
209
- // endDate: new Date()
210
- // }
211
- // )
212
- // .exec();
213
- // expiringTransactions.forEach((expiringTransaction) => {
214
- // transactionEventEmitter.emitTransactionStatusChanged({
215
- // id: expiringTransaction.id,
216
- // typeOf: expiringTransaction.typeOf,
217
- // status: factory.transactionStatusType.Expired
218
- // });
219
- // });
220
- // }
221
- // return expiringTransactions;
222
- // }
223
125
  async findByIdAndDelete(params) {
224
126
  await this.transactionModel.findByIdAndDelete(params.id)
225
127
  .exec();
@@ -31,7 +31,6 @@ export declare class AggregateTransactionRepo {
31
31
  };
32
32
  startFrom: Date;
33
33
  startThrough: Date;
34
- typeOf: factory.transactionType;
35
34
  clientId?: string;
36
35
  }): Promise<IAggregatePlaceOrder>;
37
36
  private agggregateByStatus;
@@ -22,7 +22,6 @@ class AggregateTransactionRepo {
22
22
  $gte: params.startFrom,
23
23
  $lte: params.startThrough
24
24
  },
25
- typeOf: { $eq: params.typeOf },
26
25
  status: { $eq: transactionStatus },
27
26
  ...(typeof params.project?.id?.$ne === 'string')
28
27
  ? { 'project.id': { $ne: params.project.id.$ne } }
@@ -9,17 +9,17 @@ const settings_1 = require("../../../settings");
9
9
  const modelName = 'Transaction';
10
10
  exports.modelName = modelName;
11
11
  const schemaDefinition = {
12
- project: mongoose_1.SchemaTypes.Mixed,
13
- status: String,
14
- typeOf: String,
12
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
+ status: { type: String, required: true },
14
+ typeOf: { type: String, required: true },
15
15
  agent: mongoose_1.SchemaTypes.Mixed,
16
+ expires: { type: Date, required: true },
17
+ startDate: { type: Date, required: true },
16
18
  // recipient: SchemaTypes.Mixed, // discontinue(2026-09-09~)
17
19
  seller: mongoose_1.SchemaTypes.Mixed,
18
20
  error: mongoose_1.SchemaTypes.Mixed,
19
21
  result: mongoose_1.SchemaTypes.Mixed,
20
22
  object: mongoose_1.SchemaTypes.Mixed,
21
- expires: Date,
22
- startDate: Date,
23
23
  endDate: Date,
24
24
  tasksExportAction: mongoose_1.SchemaTypes.Mixed,
25
25
  potentialActions: mongoose_1.SchemaTypes.Mixed,
@@ -67,31 +67,30 @@ const indexes = [
67
67
  { name: 'searchByStartDateDescending' }
68
68
  ],
69
69
  [
70
- { endDate: 1, startDate: -1 },
70
+ { 'object.confirmationNumber': 1, startDate: -1 },
71
71
  {
72
- name: 'searchByEndDateAndStartDate',
72
+ name: 'searchByObjectConfirmationNumber',
73
73
  partialFilterExpression: {
74
- endDate: { $exists: true }
74
+ 'object.confirmationNumber': { $exists: true }
75
75
  }
76
76
  }
77
77
  ],
78
78
  [
79
- { expires: 1, startDate: -1 },
80
- { name: 'searchByExpiresAndStartDate' }
81
- ],
82
- [
83
- { 'object.confirmationNumber': 1, startDate: -1 },
79
+ { 'object.orderNumber': 1, startDate: -1 },
84
80
  {
85
- name: 'searchByObjectConfirmationNumber',
81
+ name: 'searchByObjectOrderNumber',
86
82
  partialFilterExpression: {
87
- 'object.confirmationNumber': { $exists: true }
83
+ 'object.orderNumber': { $exists: true }
88
84
  }
89
85
  }
90
86
  ],
91
87
  [
92
- { 'object.orderNumber': 1, startDate: -1 },
88
+ // 注文取引のobject.orderNumberも発行されている場合ユニークなはず(2026-02-21~)
89
+ // 返品取引廃止につきuniquePlacingOrderNumberをreIndex
90
+ { 'object.orderNumber': 1 },
93
91
  {
94
- name: 'searchByObjectOrderNumber',
92
+ name: 'uniqueOrderNumber',
93
+ unique: true,
95
94
  partialFilterExpression: {
96
95
  'object.orderNumber': { $exists: true }
97
96
  }
@@ -180,15 +179,6 @@ const indexes = [
180
179
  }
181
180
  }
182
181
  ],
183
- [
184
- { 'tasksExportAction.startDate': 1, startDate: -1 },
185
- {
186
- name: 'searchByTasksExportActionActionStartDate',
187
- partialFilterExpression: {
188
- 'tasksExportAction.startDate': { $exists: true }
189
- }
190
- }
191
- ],
192
182
  // typeOf: ReturnOrder廃止につき以下廃止(2026-09-08~)
193
183
  // [
194
184
  // { 'object.order.orderNumber': 1, startDate: -1 },
@@ -212,6 +202,28 @@ const indexes = [
212
202
  // }
213
203
  // }
214
204
  // ],
205
+ // [
206
+ // { endDate: 1, startDate: -1 },
207
+ // {
208
+ // name: 'searchByEndDateAndStartDate',
209
+ // partialFilterExpression: {
210
+ // endDate: { $exists: true }
211
+ // }
212
+ // }
213
+ // ],
214
+ // [
215
+ // { expires: 1, startDate: -1 },
216
+ // { name: 'searchByExpiresAndStartDate' }
217
+ // ],
218
+ // [
219
+ // { 'tasksExportAction.startDate': 1, startDate: -1 },
220
+ // {
221
+ // name: 'searchByTasksExportActionActionStartDate',
222
+ // partialFilterExpression: {
223
+ // 'tasksExportAction.startDate': { $exists: true }
224
+ // }
225
+ // }
226
+ // ],
215
227
  ];
216
228
  exports.indexes = indexes;
217
229
  /**
@@ -5,11 +5,6 @@ exports.OrderInTransactionRepo = void 0;
5
5
  const errorHandler_1 = require("../errorHandler");
6
6
  const factory_1 = require("../factory");
7
7
  const order_1 = require("./mongoose/schemas/order");
8
- // import {
9
- // createSchema as createTransactionSchema,
10
- // IModel as ITransactionModel, modelName as transactionModelName,
11
- // IDocType as ITransactionDocType
12
- // } from './mongoose/schemas/transaction';
13
8
  const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
14
9
  // const debug = createDebug('chevre-domain:repo:orderInTransaction');
15
10
  /**
@@ -17,7 +12,6 @@ const acceptedOfferInReserve_1 = require("./acceptedOfferInReserve");
17
12
  */
18
13
  class OrderInTransactionRepo extends acceptedOfferInReserve_1.AcceptedOfferInReserveRepo {
19
14
  orderModel;
20
- // private readonly transactionModel: ITransactionModel;
21
15
  constructor(connection) {
22
16
  super(connection);
23
17
  this.orderModel = connection.model(order_1.modelName, (0, order_1.createSchema)());
@@ -41,7 +41,6 @@ export declare class PlaceOrderRepo {
41
41
  * 取引期限変更
42
42
  */
43
43
  updateExpires(params: {
44
- typeOf: factory.transactionType.PlaceOrder;
45
44
  id: string;
46
45
  expires: Date;
47
46
  }): Promise<void>;
@@ -58,14 +57,12 @@ export declare class PlaceOrderRepo {
58
57
  * 進行中の注文取引を取得する
59
58
  */
60
59
  findPlaceOrderInProgressById(params: {
61
- typeOf: factory.transactionType.PlaceOrder;
62
60
  id: string;
63
61
  }, inclusion: IKeyOfProjection[]): Promise<ITransactionInProgress>;
64
62
  /**
65
63
  * 特定注文取引参照
66
64
  */
67
65
  findPlaceOrderById(params: {
68
- typeOf: factory.transactionType.PlaceOrder;
69
66
  id: string;
70
67
  }, inclusion: IKeyOfProjection[]): Promise<IPlaceOrder>;
71
68
  /**
@@ -76,7 +73,6 @@ export declare class PlaceOrderRepo {
76
73
  * 取引を確定する
77
74
  */
78
75
  confirmPlaceOrder(params: {
79
- typeOf: factory.transactionType.PlaceOrder;
80
76
  id: string;
81
77
  object: {
82
78
  orderDate: Date;
@@ -90,7 +86,6 @@ export declare class PlaceOrderRepo {
90
86
  * 取引を中止する
91
87
  */
92
88
  cancelPlaceOrder(params: {
93
- typeOf: factory.transactionType.PlaceOrder;
94
89
  id: string;
95
90
  }): Promise<void>;
96
91
  }
@@ -174,62 +174,12 @@ class PlaceOrderRepo {
174
174
  .lean()
175
175
  .exec();
176
176
  }
177
- // /**
178
- // * 取引の注文番号を検索する
179
- // */
180
- // public async findInProgressOrderNumberById(params: {
181
- // id: string;
182
- // }): Promise<string | undefined> {
183
- // const doc = await this.transactionModel.findOne(
184
- // {
185
- // _id: { $eq: params.id },
186
- // typeOf: { $eq: factory.transactionType.PlaceOrder },
187
- // status: { $eq: factory.transactionStatusType.InProgress }
188
- // },
189
- // { 'object.orderNumber': 1 }
190
- // )
191
- // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'orderNumber'> }>() // 2024-08-26~
192
- // .exec();
193
- // if (doc === null) {
194
- // throw new factory.errors.NotFound(
195
- // this.transactionModel.modelName,
196
- // `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`
197
- // );
198
- // }
199
- // return doc.object.orderNumber;
200
- // }
201
- // /**
202
- // * 取引の確認番号を検索する
203
- // */
204
- // public async findInProgressConfirmationNumberById(params: {
205
- // id: string;
206
- // status: { $in: factory.transactionStatusType[] };
207
- // }): Promise<string | undefined> {
208
- // const doc = await this.transactionModel.findOne(
209
- // {
210
- // _id: { $eq: params.id },
211
- // typeOf: { $eq: factory.transactionType.PlaceOrder },
212
- // status: { $in: params.status.$in }
213
- // },
214
- // { 'object.confirmationNumber': 1 }
215
- // )
216
- // .lean<{ object: Pick<factory.transaction.placeOrder.IObject, 'confirmationNumber'> }>() // 2024-08-26~
217
- // .exec();
218
- // if (doc === null) {
219
- // throw new factory.errors.NotFound(
220
- // this.transactionModel.modelName,
221
- // `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`
222
- // );
223
- // }
224
- // return doc.object.confirmationNumber;
225
- // }
226
177
  /**
227
178
  * 取引期限変更
228
179
  */
229
180
  async updateExpires(params) {
230
181
  const doc = await this.transactionModel.findOneAndUpdate({
231
182
  _id: { $eq: params.id },
232
- typeOf: { $eq: params.typeOf },
233
183
  status: { $eq: factory_1.factory.transactionStatusType.InProgress }
234
184
  }, {
235
185
  $set: {
@@ -241,7 +191,7 @@ class PlaceOrderRepo {
241
191
  .lean()
242
192
  .exec();
243
193
  if (doc === null) {
244
- throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
194
+ throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
245
195
  }
246
196
  }
247
197
  /**
@@ -291,7 +241,6 @@ class PlaceOrderRepo {
291
241
  };
292
242
  const filter = {
293
243
  _id: { $eq: params.id },
294
- typeOf: { $eq: params.typeOf },
295
244
  status: { $eq: factory_1.factory.transactionStatusType.InProgress },
296
245
  // expiresを条件に追加(2023-05-12~),
297
246
  expires: { $gt: new Date() }
@@ -300,7 +249,7 @@ class PlaceOrderRepo {
300
249
  .lean()
301
250
  .exec();
302
251
  if (doc === null) {
303
- throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
252
+ throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
304
253
  }
305
254
  return doc;
306
255
  }
@@ -322,13 +271,12 @@ class PlaceOrderRepo {
322
271
  ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
323
272
  };
324
273
  const doc = await this.transactionModel.findOne({
325
- _id: { $eq: params.id },
326
- typeOf: { $eq: params.typeOf }
274
+ _id: { $eq: params.id }
327
275
  }, projection)
328
276
  .lean() // 2024-08-26~
329
277
  .exec();
330
278
  if (doc === null) {
331
- throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} not found`);
279
+ throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} not found`);
332
280
  }
333
281
  return doc;
334
282
  }
@@ -341,7 +289,7 @@ class PlaceOrderRepo {
341
289
  // const tasksExportationStatus = factory.transactionTasksExportationStatus.Unexported; // discontinue(2024-06-20~)
342
290
  const startDate = new Date();
343
291
  let expires;
344
- const { typeOf } = params;
292
+ const typeOf = factory_1.factory.transactionType.PlaceOrder;
345
293
  // expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
346
294
  if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
347
295
  expires = (0, moment_1.default)(startDate)
@@ -351,18 +299,12 @@ class PlaceOrderRepo {
351
299
  else {
352
300
  throw new factory_1.factory.errors.ArgumentNull('expiresInSeconds');
353
301
  }
354
- let creatingTransaction;
355
- if (typeOf === factory_1.factory.transactionType.PlaceOrder) {
356
- const { agent, project, object, seller, instrument } = params;
357
- creatingTransaction = {
358
- status, startDate, expires, typeOf, tasksExportAction,
359
- agent, project, seller, object,
360
- ...(typeof instrument?.id === 'string') ? { instrument } : undefined
361
- };
362
- }
363
- else {
364
- throw new factory_1.factory.errors.NotImplemented(`${typeOf} not implemented`);
365
- }
302
+ const { agent, project, object, seller, instrument } = params;
303
+ const creatingTransaction = {
304
+ status, startDate, expires, typeOf, tasksExportAction,
305
+ agent, project, seller, object,
306
+ ...(typeof instrument?.id === 'string') ? { instrument } : undefined
307
+ };
366
308
  // reimplemnt with insertMany(2024-05-30~)
367
309
  const result = await this.transactionModel.insertMany(creatingTransaction, { rawResult: true });
368
310
  const id = result.insertedIds?.[0]?.toHexString();
@@ -380,7 +322,6 @@ class PlaceOrderRepo {
380
322
  const endDate = new Date();
381
323
  const doc = await this.transactionModel.findOneAndUpdate({
382
324
  _id: { $eq: params.id },
383
- typeOf: { $eq: params.typeOf },
384
325
  status: { $eq: factory_1.factory.transactionStatusType.InProgress },
385
326
  expires: { $gt: endDate } // add expires(2025-02-27~)
386
327
  }, {
@@ -399,7 +340,7 @@ class PlaceOrderRepo {
399
340
  .exec();
400
341
  // NotFoundであれば取引状態確認
401
342
  if (doc === null) {
402
- const { expires, status } = await this.findPlaceOrderById({ typeOf: params.typeOf, id: params.id }, ['expires', 'status']);
343
+ const { expires, status } = await this.findPlaceOrderById({ id: params.id }, ['expires', 'status']);
403
344
  if (status === factory_1.factory.transactionStatusType.Confirmed) {
404
345
  // すでに確定済の場合スルー
405
346
  }
@@ -414,12 +355,12 @@ class PlaceOrderRepo {
414
355
  .isSameOrBefore((0, moment_1.default)(endDate))) {
415
356
  throw new factory_1.factory.errors.Argument('Transaction id', 'potentially expired');
416
357
  }
417
- throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
358
+ throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
418
359
  }
419
360
  }
420
361
  transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
421
362
  id: params.id,
422
- typeOf: params.typeOf,
363
+ typeOf: factory_1.factory.transactionType.PlaceOrder,
423
364
  status: factory_1.factory.transactionStatusType.Confirmed
424
365
  });
425
366
  }
@@ -430,7 +371,6 @@ class PlaceOrderRepo {
430
371
  const endDate = new Date();
431
372
  // 進行中ステータスの取引を中止する
432
373
  const doc = await this.transactionModel.findOneAndUpdate({
433
- typeOf: params.typeOf,
434
374
  _id: params.id,
435
375
  status: factory_1.factory.transactionStatusType.InProgress
436
376
  }, {
@@ -455,12 +395,12 @@ class PlaceOrderRepo {
455
395
  throw new factory_1.factory.errors.Argument('Transaction id', 'Confirmed transaction unable to cancel');
456
396
  }
457
397
  else {
458
- throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory_1.factory.transactionStatusType.InProgress} not found`);
398
+ throw new factory_1.factory.errors.NotFound(this.transactionModel.modelName, `${factory_1.factory.transactionType.PlaceOrder} ${factory_1.factory.transactionStatusType.InProgress} not found`);
459
399
  }
460
400
  }
461
401
  transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
462
402
  id: params.id,
463
- typeOf: params.typeOf,
403
+ typeOf: factory_1.factory.transactionType.PlaceOrder,
464
404
  status: factory_1.factory.transactionStatusType.Canceled
465
405
  });
466
406
  }
@@ -30,7 +30,6 @@ class TransactionRepo {
30
30
  throw new factory_1.factory.errors.Argument('endDate.$lt', 'must be Date');
31
31
  }
32
32
  const query = this.transactionModel.findOneAndUpdate({
33
- // ...(Array.isArray(typeOfIn)) ? { typeOf: { $in: typeOfIn } } : undefined,
34
33
  status: {
35
34
  ...(typeof statusEq === 'string')
36
35
  ? { $eq: statusEq }
@@ -137,8 +137,7 @@ function aggregatePlaceOrder(params) {
137
137
  const aggregateResult = await repos.aggregateTransaction.aggregatePlaceOrder({
138
138
  project: { id: { $ne: params.excludedProjectId } },
139
139
  startFrom,
140
- startThrough,
141
- typeOf: factory_1.factory.transactionType.PlaceOrder
140
+ startThrough
142
141
  });
143
142
  debug('aggregatePlaceOrder:result', aggregateResult, aggregateResult.statuses[0]?.aggregation, startFrom);
144
143
  const aggregateResultsByClientId = [];
@@ -148,7 +147,6 @@ function aggregatePlaceOrder(params) {
148
147
  project: { id: { $ne: params.excludedProjectId } },
149
148
  startFrom,
150
149
  startThrough,
151
- typeOf: factory_1.factory.transactionType.PlaceOrder,
152
150
  clientId
153
151
  });
154
152
  debug('aggregateResultByClientId', aggregateResultByClientId, aggregateResultByClientId.statuses[0]?.aggregation, clientId, startFrom);
@@ -121,10 +121,7 @@ function minimizeItemOffered(itemOffered, options) {
121
121
  }
122
122
  function validateCreateRequest(params) {
123
123
  return async (repos) => {
124
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
125
- typeOf: factory_1.factory.transactionType.PlaceOrder,
126
- id: params.transaction.id
127
- }, ['agent', 'expires', 'project', 'seller', 'typeOf', 'instrument']);
124
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.transaction.id }, ['agent', 'expires', 'project', 'seller', 'typeOf', 'instrument']);
128
125
  if (transaction.agent.id !== params.agent.id) {
129
126
  throw new factory_1.factory.errors.Forbidden('Transaction not yours');
130
127
  }
@@ -63,7 +63,7 @@ function issueEventOfferTicket(params) {
63
63
  return async (repos) => {
64
64
  const { now, audience, eventId, eventOfferId, ticketedOffer, author, project, instrument } = params;
65
65
  // 取引は存在するか
66
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ typeOf: factory_1.factory.transactionType.PlaceOrder, id: audience.id }, ['expires', 'typeOf', 'seller']);
66
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: audience.id }, ['expires', 'typeOf', 'seller']);
67
67
  // イベントは存在するか
68
68
  const event = await repos.event.projectEventFieldsById({ id: eventId }, ['project', 'offers', 'identifier']);
69
69
  const { seller } = transaction;
@@ -22,7 +22,7 @@ function voidTransaction(params) {
22
22
  agent: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
23
23
  ...(typeof params.sameAs?.id === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined
24
24
  };
25
- const transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['typeOf', 'status', 'object']);
25
+ const transaction = await repos.placeOrder.findPlaceOrderById({ id: params.purpose.id }, ['typeOf', 'status', 'object']);
26
26
  // 興行オファー承認アクション検索
27
27
  let authorizeActions = await repos.actions.authorizeOffer.findAuthorizeOfferActionsByPurpose({
28
28
  // typeOf: factory.actionType.AuthorizeAction,
@@ -115,10 +115,7 @@ function cancelAcceptActions(params) {
115
115
  agent: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
116
116
  ...(typeof params.sameAs?.id === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined
117
117
  };
118
- const transaction = await repos.placeOrder.findPlaceOrderById({
119
- typeOf: params.purpose.typeOf,
120
- id: params.purpose.id
121
- }, ['typeOf', 'status']);
118
+ const transaction = await repos.placeOrder.findPlaceOrderById({ id: params.purpose.id }, ['typeOf', 'status']);
122
119
  // 興行オファー承認アクション検索
123
120
  const completedAuthorizeActions = await repos.actions.authorizeOffer.findAuthorizeOfferActionsByPurpose({
124
121
  // typeOf: factory.actionType.AuthorizeAction,
@@ -19,10 +19,7 @@ function voidTransactionByActionId(params) {
19
19
  agent: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
20
20
  ...(typeof params.sameAs?.id === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined
21
21
  };
22
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
23
- typeOf: factory_1.factory.transactionType.PlaceOrder,
24
- id: params.purpose.id
25
- }, ['typeOf']);
22
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.purpose.id }, ['typeOf']);
26
23
  // if (transaction.agent.id !== params.agent.id) {
27
24
  // throw new factory.errors.Forbidden('Transaction not yours');
28
25
  // }
@@ -33,10 +33,7 @@ function acceptOffer(params) {
33
33
  if (typeof params.sameAs.id !== 'string' || params.sameAs.id === '') {
34
34
  throw new factory_1.factory.errors.ArgumentNull('sameAs.id');
35
35
  }
36
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
37
- typeOf: factory_1.factory.transactionType.PlaceOrder,
38
- id: params.purpose.id
39
- }, ['project', 'agent', 'typeOf']);
36
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.purpose.id }, ['project', 'agent', 'typeOf']);
40
37
  // // 注文ドキュメントを参照(2026-06-24~)
41
38
  // const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
42
39
  // identifier: transaction.id,
@@ -118,10 +115,7 @@ function reAcceptOffer(params) {
118
115
  if (typeof params.potentialActions?.id !== 'string' || params.potentialActions.id === '') {
119
116
  throw new factory_1.factory.errors.ArgumentNull('potentialActions.id');
120
117
  }
121
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
122
- typeOf: factory_1.factory.transactionType.PlaceOrder,
123
- id: params.purpose.id
124
- }, ['project', 'agent', 'typeOf']);
118
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.purpose.id }, ['project', 'agent', 'typeOf']);
125
119
  // const orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: transaction.id });
126
120
  // if (typeof orderNumber !== 'string') {
127
121
  // // 事前に発行されているはず
@@ -14,10 +14,7 @@ const factory_2 = require("../../../factory");
14
14
  */
15
15
  function authorize(params) {
16
16
  return async (repos) => {
17
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
18
- typeOf: factory_2.factory.transactionType.PlaceOrder,
19
- id: params.transaction.id
20
- }, ['agent', 'project', 'seller', 'typeOf', 'instrument']);
17
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.transaction.id }, ['agent', 'project', 'seller', 'typeOf', 'instrument']);
21
18
  if (transaction.agent.id !== params.agent.id) {
22
19
  throw new factory_2.factory.errors.Forbidden('Transaction not yours');
23
20
  }
@@ -14,10 +14,7 @@ const factory_2 = require("../../../factory");
14
14
  */
15
15
  function changeOffers(params) {
16
16
  return async (repos) => {
17
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
18
- typeOf: factory_2.factory.transactionType.PlaceOrder,
19
- id: params.transaction.id
20
- }, ['typeOf', 'agent', 'project', 'seller']);
17
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.transaction.id }, ['typeOf', 'agent', 'project', 'seller']);
21
18
  if (transaction.agent.id !== params.agent.id) {
22
19
  throw new factory_2.factory.errors.Forbidden('Transaction not yours');
23
20
  }
@@ -59,7 +59,7 @@ function authorize(params) {
59
59
  if (purpose.typeOf !== factory_1.factory.transactionType.PlaceOrder) {
60
60
  throw new factory_1.factory.errors.NotImplemented(`purpose.typeOf '${purpose.typeOf} not implemented'`);
61
61
  }
62
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
62
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: purpose.id }, ['agent', 'expires', 'typeOf', 'project', 'seller']);
63
63
  if (project.id !== transaction.project.id) {
64
64
  throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder);
65
65
  }
@@ -12,10 +12,7 @@ function invalidatePaymentUrl(params) {
12
12
  if (params.purpose.typeOf !== factory_1.factory.transactionType.PlaceOrder) {
13
13
  throw new factory_1.factory.errors.Argument('purpose.typeOf', `must be ${factory_1.factory.transactionType.PlaceOrder}`);
14
14
  }
15
- const transaction = await repos.placeOrder.findPlaceOrderById({
16
- typeOf: params.purpose.typeOf,
17
- id: params.purpose.id
18
- }, ['typeOf', 'status', 'object', 'project', 'seller', 'agent']);
15
+ const transaction = await repos.placeOrder.findPlaceOrderById({ id: params.purpose.id }, ['typeOf', 'status', 'object', 'project', 'seller', 'agent']);
19
16
  // const orderCancelled: boolean = params.purpose.result?.order?.orderStatus === factory.orderStatus.OrderCancelled;
20
17
  // if (transaction.status === factory.transactionStatusType.Confirmed) {
21
18
  // if (!orderCancelled) {
@@ -50,10 +50,10 @@ function processVoidPayTransaction(params) {
50
50
  let transaction;
51
51
  // アクションID指定の場合、進行中取引検証(2023-02-24~)
52
52
  if (typeof params.id === 'string') {
53
- transaction = await repos.placeOrder.findPlaceOrderInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['typeOf', 'status']);
53
+ transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.purpose.id }, ['typeOf', 'status']);
54
54
  }
55
55
  else {
56
- transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['typeOf', 'status', 'result']);
56
+ transaction = await repos.placeOrder.findPlaceOrderById({ id: params.purpose.id }, ['typeOf', 'status', 'result']);
57
57
  }
58
58
  // 承認アクションを取得
59
59
  let authorizeActions;
@@ -48,7 +48,7 @@ function publishPaymentUrl(params) {
48
48
  throw new factory_1.factory.errors.NotImplemented(`purpose.typeOf '${purpose.typeOf} not implemented'`);
49
49
  }
50
50
  try {
51
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ typeOf: purpose.typeOf, id: purpose.id }, ['expires', 'seller', 'project']);
51
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: purpose.id }, ['expires', 'seller', 'project']);
52
52
  if (project.id !== transaction.project.id) {
53
53
  throw new factory_1.factory.errors.NotFound(factory_1.factory.transactionType.PlaceOrder);
54
54
  }
@@ -63,7 +63,7 @@ function confirm(params, options) {
63
63
  // status: { $in: [factory.transactionStatusType.Confirmed, factory.transactionStatusType.InProgress] },
64
64
  object: { orderDate: params.result.order.orderDate }
65
65
  })(repos);
66
- const transaction = await repos.placeOrder.findPlaceOrderById({ typeOf: factory_1.factory.transactionType.PlaceOrder, id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
66
+ const transaction = await repos.placeOrder.findPlaceOrderById({ id: params.id }, ['typeOf', 'project', 'status', 'agent', 'seller', 'object', 'result']);
67
67
  // 注文ドキュメントから注文番号を参照(取引開始時に発行済の前提)(2026-06-26~)
68
68
  const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
69
69
  identifier: params.id,
@@ -169,7 +169,6 @@ function confirm(params, options) {
169
169
  // ステータス変更
170
170
  try {
171
171
  await repos.placeOrder.confirmPlaceOrder({
172
- typeOf: transaction.typeOf,
173
172
  id: transaction.id,
174
173
  object: {
175
174
  orderDate: params.result.order.orderDate,
@@ -12,10 +12,7 @@ const factory_2 = require("./exportTasks/factory");
12
12
  */
13
13
  function exportTasksById(params) {
14
14
  return async (repos) => {
15
- const transaction = await repos.placeOrder.findPlaceOrderById({
16
- typeOf: factory_1.factory.transactionType.PlaceOrder,
17
- id: params.id
18
- }, ['endDate', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']);
15
+ const transaction = await repos.placeOrder.findPlaceOrderById({ id: params.id }, ['endDate', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']);
19
16
  // タスク実行日時バッファの指定があれば調整
20
17
  let taskRunsAt = new Date();
21
18
  if (typeof params.runsTasksAfterInSeconds === 'number') {
@@ -8,10 +8,7 @@ const fixCustomer_1 = require("./updateAgent/fixCustomer");
8
8
  */
9
9
  function updateAgent(params) {
10
10
  return async (repos) => {
11
- const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
12
- typeOf: factory_1.factory.transactionType.PlaceOrder,
13
- id: params.id
14
- }, ['agent', 'object', 'typeOf', 'project']);
11
+ const transaction = await repos.placeOrder.findPlaceOrderInProgressById({ id: params.id }, ['agent', 'object', 'typeOf', 'project']);
15
12
  if (transaction.agent.id !== params.agent.id) {
16
13
  throw new factory_1.factory.errors.Forbidden('Transaction not yours');
17
14
  }
package/package.json CHANGED
@@ -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.3"
91
+ "version": "28.0.0-alpha.4"
92
92
  }