@chevre/domain 21.33.0-alpha.5 → 21.33.0-alpha.7

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 (29) hide show
  1. package/example/src/chevre/findTransactionById.ts +2 -2
  2. package/example/src/chevre/findTransactionInProgressById.ts +2 -2
  3. package/example/src/chevre/searchTransactions.ts +13 -15
  4. package/example/src/chevre/transaction/processPlaceOrder.ts +3 -3
  5. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +1 -1
  6. package/lib/chevre/repo/mongoose/schemas/transaction.js +27 -62
  7. package/lib/chevre/repo/transaction.d.ts +6 -4
  8. package/lib/chevre/repo/transaction.js +61 -26
  9. package/lib/chevre/service/offer/event/authorize.js +1 -1
  10. package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -1
  11. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +2 -2
  12. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -1
  13. package/lib/chevre/service/offer/eventServiceByCOA/cancel.js +1 -1
  14. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  15. package/lib/chevre/service/offer/moneyTransfer/authorize.js +1 -1
  16. package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +2 -2
  17. package/lib/chevre/service/offer/product.js +1 -1
  18. package/lib/chevre/service/order/findPlaceOrderTransaction.js +1 -1
  19. package/lib/chevre/service/order/placeOrder.js +1 -2
  20. package/lib/chevre/service/order/returnOrder.js +1 -1
  21. package/lib/chevre/service/payment/any/factory.d.ts +1 -1
  22. package/lib/chevre/service/payment/any.js +3 -3
  23. package/lib/chevre/service/transaction/moneyTransfer.d.ts +2 -3
  24. package/lib/chevre/service/transaction/moneyTransfer.js +4 -2
  25. package/lib/chevre/service/transaction/placeOrder.js +1 -1
  26. package/lib/chevre/service/transaction/placeOrderInProgress/start.d.ts +2 -3
  27. package/lib/chevre/service/transaction/returnOrder.d.ts +2 -2
  28. package/lib/chevre/service/transaction.js +5 -4
  29. package/package.json +3 -3
@@ -10,8 +10,8 @@ async function main() {
10
10
 
11
11
  const transaction = await transactionRepo.findById({
12
12
  typeOf: chevre.factory.transactionType.PlaceOrder,
13
- id: '65ab04d5206595479469f50c',
14
- inclusion: ['endDate', 'id', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']
13
+ id: '6656d35dd1f13f8c658be102',
14
+ inclusion: ['typeOf']
15
15
  });
16
16
  console.log('transaction:', transaction);
17
17
  }
@@ -12,8 +12,8 @@ async function main() {
12
12
  {
13
13
  typeOf: chevre.factory.transactionType.PlaceOrder,
14
14
  id: '6656d35dd1f13f8c658be102'
15
- }
16
- // ['_id']
15
+ },
16
+ ['_id']
17
17
  );
18
18
  console.log('transaction:', transaction);
19
19
  }
@@ -5,6 +5,10 @@ import { chevre } from '../../../lib/index';
5
5
 
6
6
  const project = { id: String(process.env.PROJECT_ID) };
7
7
 
8
+ mongoose.Model.on('index', (...args) => {
9
+ console.error('******** index event emitted. ********\n', args);
10
+ });
11
+
8
12
  async function main() {
9
13
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
14
 
@@ -15,25 +19,19 @@ async function main() {
15
19
  page: 1,
16
20
  project: { id: { $eq: project.id } },
17
21
  typeOf: chevre.factory.transactionType.PlaceOrder,
18
- statuses: [chevre.factory.transactionStatusType.Confirmed],
19
- result: {
20
- order: {
21
- confirmationNumber: { $eq: '14438' },
22
- orderNumbers: ['CIN3-0760465-8981560']
23
- }
24
- },
25
- inclusion: ['id'],
22
+ // statuses: [chevre.factory.transactionStatusType.Confirmed],
23
+ // result: {
24
+ // order: {
25
+ // confirmationNumber: { $eq: '14438' },
26
+ // orderNumbers: ['CIN3-0760465-8981560']
27
+ // }
28
+ // },
29
+ tasksExportAction: { actionStatus: { $eq: chevre.factory.actionStatusType.PotentialActionStatus } },
30
+ inclusion: ['_id'],
26
31
  exclusion: []
27
32
  });
28
33
  console.log('transactions found', transactions);
29
34
  console.log(transactions.length, 'transactions found');
30
-
31
- const transaction = await transactionRepo.findById({
32
- typeOf: chevre.factory.transactionType.PlaceOrder,
33
- id: '6570f9d7834f9638ceec86ad',
34
- inclusion: ['_id', 'typeOf', 'status']
35
- });
36
- console.log('transaction found', transaction);
37
35
  }
38
36
 
39
37
  main()
@@ -59,7 +59,7 @@ async function main() {
59
59
  retUrl: String(process.env.SECURE_TRAN_RET_URL)
60
60
  }
61
61
  },
62
- purpose: { id: transaction.id, typeOf: transaction.typeOf },
62
+ purpose: { id: transaction.id, typeOf: chevre.factory.transactionType.PlaceOrder },
63
63
  paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
64
64
  location: {
65
65
  typeOf: chevre.factory.creativeWorkType.WebApplication,
@@ -106,7 +106,7 @@ async function main() {
106
106
  method: '1',
107
107
  creditCard
108
108
  },
109
- purpose: { id: transaction.id, typeOf: transaction.typeOf },
109
+ purpose: { id: transaction.id, typeOf: chevre.factory.transactionType.PlaceOrder },
110
110
  paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
111
111
  location: {
112
112
  typeOf: chevre.factory.creativeWorkType.WebApplication,
@@ -140,7 +140,7 @@ async function main() {
140
140
  } else if (jobCd === 'VOID') {
141
141
  await (await chevre.service.payment.any.createService()).invalidatePaymentUrl({
142
142
  project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
143
- purpose: { id: transaction.id, typeOf: transaction.typeOf }
143
+ purpose: { id: transaction.id, typeOf: chevre.factory.transactionType.PlaceOrder }
144
144
  })({
145
145
  accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
146
146
  action: await chevre.repository.Action.createInstance(mongoose.connection),
@@ -1,5 +1,5 @@
1
1
  import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
2
2
  declare const modelName = "Transaction";
3
- declare function createSchema(): Schema;
4
3
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
4
+ declare function createSchema(): Schema;
5
5
  export { modelName, indexes, createSchema };
@@ -51,17 +51,6 @@ const schemaOptions = {
51
51
  versionKey: false
52
52
  }
53
53
  };
54
- /**
55
- * 取引スキーマ
56
- */
57
- let schema;
58
- function createSchema() {
59
- if (schema === undefined) {
60
- schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
61
- }
62
- return schema;
63
- }
64
- exports.createSchema = createSchema;
65
54
  const indexes = [
66
55
  [
67
56
  { createdAt: 1 },
@@ -234,42 +223,6 @@ const indexes = [
234
223
  }
235
224
  }
236
225
  ],
237
- [
238
- { 'agent.familyName': 1, startDate: -1 },
239
- {
240
- name: 'searchByAgentFamilyName',
241
- partialFilterExpression: {
242
- 'agent.familyName': { $exists: true }
243
- }
244
- }
245
- ],
246
- [
247
- { 'agent.givenName': 1, startDate: -1 },
248
- {
249
- name: 'searchByAgentGivenName',
250
- partialFilterExpression: {
251
- 'agent.givenName': { $exists: true }
252
- }
253
- }
254
- ],
255
- [
256
- { 'agent.email': 1, startDate: -1 },
257
- {
258
- name: 'searchByAgentEmail',
259
- partialFilterExpression: {
260
- 'agent.email': { $exists: true }
261
- }
262
- }
263
- ],
264
- [
265
- { 'agent.telephone': 1, startDate: -1 },
266
- {
267
- name: 'searchByAgentTelephone',
268
- partialFilterExpression: {
269
- 'agent.telephone': { $exists: true }
270
- }
271
- }
272
- ],
273
226
  [
274
227
  { 'seller.typeOf': 1, startDate: -1 },
275
228
  {
@@ -305,33 +258,45 @@ const indexes = [
305
258
  ],
306
259
  [
307
260
  { tasksExportationStatus: 1, updatedAt: 1 },
308
- {
309
- name: 'reexportTasks'
310
- }
261
+ { name: 'reexportTasks' }
311
262
  ],
312
263
  [
313
- { 'project.id': 1, tasksExportationStatus: 1, updatedAt: 1 },
314
- {
315
- name: 'reexportTasks-v2',
316
- partialFilterExpression: {
317
- 'project.id': { $exists: true }
318
- }
319
- }
264
+ { status: 1, expires: 1 },
265
+ { name: 'makeExpired' }
320
266
  ],
321
267
  [
322
- { status: 1, expires: 1 },
268
+ { 'tasksExportAction.actionStatus': 1, startDate: -1 },
323
269
  {
324
- name: 'makeExpired'
270
+ name: 'searchByTasksExportActionActionStatus',
271
+ partialFilterExpression: {
272
+ 'tasksExportAction.actionStatus': { $exists: true }
273
+ }
325
274
  }
326
275
  ],
327
276
  [
328
- { 'project.id': 1, status: 1, expires: 1 },
277
+ { 'tasksExportAction.startDate': 1, startDate: -1 },
329
278
  {
330
- name: 'makeExpired-v2',
279
+ name: 'searchByTasksExportActionActionStartDate',
331
280
  partialFilterExpression: {
332
- 'project.id': { $exists: true }
281
+ 'tasksExportAction.startDate': { $exists: true }
333
282
  }
334
283
  }
335
284
  ]
336
285
  ];
337
286
  exports.indexes = indexes;
287
+ /**
288
+ * 取引スキーマ
289
+ */
290
+ let schema;
291
+ function createSchema() {
292
+ if (schema === undefined) {
293
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
294
+ if (settings_1.MONGO_AUTO_INDEX) {
295
+ indexes.forEach((indexParams) => {
296
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
297
+ });
298
+ }
299
+ }
300
+ return schema;
301
+ }
302
+ exports.createSchema = createSchema;
@@ -24,7 +24,7 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import type { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
- type IKeyOfProjection<T extends factory.transactionType> = keyof factory.transaction.ITransaction<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'object.orderNumber';
27
+ type IKeyOfProjection<T extends factory.transactionType> = Exclude<keyof factory.transaction.ITransaction<T>, 'id'> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'object.orderNumber';
28
28
  interface IAggregationByStatus {
29
29
  transactionCount: number;
30
30
  avgDuration: number;
@@ -49,7 +49,9 @@ export interface IAggregatePlaceOrder {
49
49
  statuses: IStatus[];
50
50
  }
51
51
  type IOmittedFieldsInProgress = 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus';
52
- type ITransactionInProgress<T extends factory.transactionType> = T extends factory.transactionType.MoneyTransfer ? Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.PlaceOrder ? Omit<factory.transaction.placeOrder.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.ReturnOrder ? Omit<factory.transaction.returnOrder.ITransaction, IOmittedFieldsInProgress> : never;
52
+ export type ITransactionInProgress<T extends factory.transactionType> = T extends factory.transactionType.MoneyTransfer ? Omit<factory.transaction.moneyTransfer.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.PlaceOrder ? Omit<factory.transaction.placeOrder.ITransaction, IOmittedFieldsInProgress> : T extends factory.transactionType.ReturnOrder ? Omit<factory.transaction.returnOrder.ITransaction, IOmittedFieldsInProgress> : never;
53
+ type IStartedTransactionFields = 'expires' | 'id' | 'startDate' | 'status';
54
+ export type IStartedTransaction = Pick<factory.transaction.ITransaction<factory.transactionType>, IStartedTransactionFields>;
53
55
  /**
54
56
  * 取引リポジトリ
55
57
  */
@@ -60,7 +62,7 @@ export declare class MongoRepository {
60
62
  /**
61
63
  * 取引を開始する
62
64
  */
63
- start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T>): Promise<factory.transaction.ITransaction<T>>;
65
+ start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T>): Promise<IStartedTransaction>;
64
66
  /**
65
67
  * 特定取引検索
66
68
  */
@@ -76,7 +78,7 @@ export declare class MongoRepository {
76
78
  findInProgressById<T extends factory.transactionType>(params: {
77
79
  typeOf: T;
78
80
  id: string;
79
- }, inclusion?: IKeyOfProjection<T>[]): Promise<ITransactionInProgress<T>>;
81
+ }, inclusion: IKeyOfProjection<T>[]): Promise<ITransactionInProgress<T>>;
80
82
  /**
81
83
  * 取引の注文番号を検索する
82
84
  */
@@ -11,20 +11,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const moment = require("moment");
14
+ const transaction_1 = require("../eventEmitter/transaction");
14
15
  const factory = require("../factory");
15
- const transaction_1 = require("./mongoose/schemas/transaction");
16
- const transaction_2 = require("../eventEmitter/transaction");
17
16
  const settings_1 = require("../settings");
17
+ const transaction_2 = require("./mongoose/schemas/transaction");
18
18
  /**
19
19
  * 取引リポジトリ
20
20
  */
21
21
  class MongoRepository {
22
22
  constructor(connection) {
23
- this.transactionModel = connection.model(transaction_1.modelName, (0, transaction_1.createSchema)());
23
+ this.transactionModel = connection.model(transaction_2.modelName, (0, transaction_2.createSchema)());
24
24
  }
25
25
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
26
26
  static CREATE_MONGO_CONDITIONS(params) {
27
- var _a, _b, _c, _d, _e, _f, _g, _h;
27
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
28
28
  const andConditions = [];
29
29
  // tslint:disable-next-line:no-single-line-block-comment
30
30
  /* istanbul ignore else */
@@ -175,23 +175,27 @@ class MongoRepository {
175
175
  tasksExportationStatus: { $in: params.tasksExportationStatuses }
176
176
  });
177
177
  }
178
+ const tasksExportActionStatusEq = (_b = (_a = params.tasksExportAction) === null || _a === void 0 ? void 0 : _a.actionStatus) === null || _b === void 0 ? void 0 : _b.$eq;
179
+ if (typeof tasksExportActionStatusEq === 'string') {
180
+ andConditions.push({ 'tasksExportAction.actionStatus': { $exists: true, $eq: tasksExportActionStatusEq } });
181
+ }
178
182
  switch (params.typeOf) {
179
183
  case factory.transactionType.PlaceOrder:
180
- const sellerIdIn = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.ids;
184
+ const sellerIdIn = (_c = params.seller) === null || _c === void 0 ? void 0 : _c.ids;
181
185
  if (Array.isArray(sellerIdIn)) {
182
186
  andConditions.push({ 'seller.id': { $exists: true, $in: sellerIdIn } });
183
187
  }
184
- const resultOrderNumberIn = (_c = (_b = params.result) === null || _b === void 0 ? void 0 : _b.order) === null || _c === void 0 ? void 0 : _c.orderNumbers;
188
+ const resultOrderNumberIn = (_e = (_d = params.result) === null || _d === void 0 ? void 0 : _d.order) === null || _e === void 0 ? void 0 : _e.orderNumbers;
185
189
  if (Array.isArray(resultOrderNumberIn)) {
186
190
  andConditions.push({ 'result.order.orderNumber': { $exists: true, $in: resultOrderNumberIn } });
187
191
  }
188
- const resultOrderConfirmationNumberEq = (_f = (_e = (_d = params.result) === null || _d === void 0 ? void 0 : _d.order) === null || _e === void 0 ? void 0 : _e.confirmationNumber) === null || _f === void 0 ? void 0 : _f.$eq;
192
+ const resultOrderConfirmationNumberEq = (_h = (_g = (_f = params.result) === null || _f === void 0 ? void 0 : _f.order) === null || _g === void 0 ? void 0 : _g.confirmationNumber) === null || _h === void 0 ? void 0 : _h.$eq;
189
193
  if (typeof resultOrderConfirmationNumberEq === 'string') {
190
194
  andConditions.push({
191
195
  'result.order.confirmationNumber': { $exists: true, $eq: resultOrderConfirmationNumberEq }
192
196
  });
193
197
  }
194
- const objectOrderNumberEq = (_h = (_g = params.object) === null || _g === void 0 ? void 0 : _g.orderNumber) === null || _h === void 0 ? void 0 : _h.$eq;
198
+ const objectOrderNumberEq = (_k = (_j = params.object) === null || _j === void 0 ? void 0 : _j.orderNumber) === null || _k === void 0 ? void 0 : _k.$eq;
195
199
  if (typeof objectOrderNumberEq === 'string') {
196
200
  andConditions.push({ 'object.orderNumber': { $exists: true, $eq: objectOrderNumberEq } });
197
201
  }
@@ -224,11 +228,16 @@ class MongoRepository {
224
228
  * 取引を開始する
225
229
  */
226
230
  start(params) {
231
+ var _a, _b;
227
232
  return __awaiter(this, void 0, void 0, function* () {
233
+ const status = factory.transactionStatusType.InProgress;
234
+ const tasksExportAction = { actionStatus: factory.actionStatusType.PotentialActionStatus };
235
+ const tasksExportationStatus = factory.transactionTasksExportationStatus.Unexported;
228
236
  const startDate = new Date();
229
237
  let expires;
230
- if (params.typeOf === factory.transactionType.PlaceOrder
231
- || params.typeOf === factory.transactionType.ReturnOrder) {
238
+ const { typeOf } = params;
239
+ if (typeOf === factory.transactionType.PlaceOrder
240
+ || typeOf === factory.transactionType.ReturnOrder) {
232
241
  // expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
233
242
  if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
234
243
  expires = moment(startDate)
@@ -242,17 +251,42 @@ class MongoRepository {
242
251
  else {
243
252
  expires = params.expires;
244
253
  }
245
- const transaction = yield this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportAction: {
246
- actionStatus: factory.actionStatusType.PotentialActionStatus
247
- }, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
248
- .then((doc) => doc.toObject());
254
+ let creatingTransaction;
255
+ if (typeOf === factory.transactionType.MoneyTransfer) {
256
+ const { agent, project, object, seller, recipient } = params;
257
+ creatingTransaction = {
258
+ status, startDate, expires, typeOf, tasksExportAction, tasksExportationStatus,
259
+ agent, project, seller, object, recipient
260
+ };
261
+ }
262
+ else if (typeOf === factory.transactionType.PlaceOrder) {
263
+ const { agent, project, object, seller } = params;
264
+ creatingTransaction = {
265
+ status, startDate, expires, typeOf, tasksExportAction, tasksExportationStatus,
266
+ agent, project, seller, object
267
+ };
268
+ }
269
+ else if (typeOf === factory.transactionType.ReturnOrder) {
270
+ const { agent, project, object, seller } = params;
271
+ creatingTransaction = {
272
+ status, startDate, expires, typeOf, tasksExportAction, tasksExportationStatus,
273
+ agent, project, seller, object
274
+ };
275
+ }
276
+ else {
277
+ throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
278
+ }
279
+ // reimplemnt with insertMany(2024-05-30~)
280
+ // const transaction = await this.transactionModel.create<AnyKeys<factory.transaction.ITransaction<T>>>(creatingTransaction)
281
+ // .then((doc: HydratedDocument<factory.transaction.ITransaction<T>>) => doc.toObject());
282
+ const result = yield this.transactionModel.insertMany(creatingTransaction, { rawResult: true });
283
+ const id = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
284
+ if (typeof id !== 'string') {
285
+ throw new factory.errors.ServiceUnavailable('transaction not saved');
286
+ }
249
287
  // 取引開始時にも取引イベントエミッター連携(2024-03-21~)
250
- transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
251
- id: transaction.id,
252
- typeOf: transaction.typeOf,
253
- status: factory.transactionStatusType.InProgress
254
- });
255
- return transaction;
288
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({ id, typeOf, status });
289
+ return { expires, id, startDate, status }; // minimize response(2024-05-30~)
256
290
  });
257
291
  }
258
292
  /**
@@ -293,7 +327,8 @@ class MongoRepository {
293
327
  /**
294
328
  * 進行中の取引を取得する
295
329
  */
296
- findInProgressById(params, inclusion) {
330
+ findInProgressById(params, inclusion // make required(2024-05-29~)
331
+ ) {
297
332
  return __awaiter(this, void 0, void 0, function* () {
298
333
  let projection = {};
299
334
  if (Array.isArray(inclusion) && inclusion.length > 0) {
@@ -462,7 +497,7 @@ class MongoRepository {
462
497
  throw new factory.errors.NotFound(this.transactionModel.modelName);
463
498
  }
464
499
  }
465
- transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
500
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
466
501
  id: params.id,
467
502
  typeOf: params.typeOf,
468
503
  status: factory.transactionStatusType.Confirmed
@@ -531,7 +566,7 @@ class MongoRepository {
531
566
  tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported
532
567
  })
533
568
  .exec();
534
- transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
569
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
535
570
  id: reexportingTransaction.id,
536
571
  typeOf: reexportingTransaction.typeOf,
537
572
  status: reexportingTransaction.status
@@ -564,7 +599,7 @@ class MongoRepository {
564
599
  .exec();
565
600
  if (delayedTransactions.length > 0) {
566
601
  delayedTransactions.forEach((delayedTransaction) => {
567
- transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
602
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
568
603
  id: delayedTransaction.id,
569
604
  typeOf: delayedTransaction.typeOf,
570
605
  status: delayedTransaction.status
@@ -621,7 +656,7 @@ class MongoRepository {
621
656
  })
622
657
  .exec();
623
658
  expiringTransactions.forEach((expiringTransaction) => {
624
- transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
659
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
625
660
  id: expiringTransaction.id,
626
661
  typeOf: expiringTransaction.typeOf,
627
662
  status: factory.transactionStatusType.Expired
@@ -665,7 +700,7 @@ class MongoRepository {
665
700
  throw new factory.errors.NotFound(this.transactionModel.modelName);
666
701
  }
667
702
  }
668
- transaction_2.transactionEventEmitter.emitTransactionStatusChanged({
703
+ transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
669
704
  id: params.id,
670
705
  typeOf: params.typeOf,
671
706
  status: factory.transactionStatusType.Canceled
@@ -118,7 +118,7 @@ function validateCreateRequest(params) {
118
118
  const transaction = yield repos.transaction.findInProgressById({
119
119
  typeOf: factory.transactionType.PlaceOrder,
120
120
  id: params.transaction.id
121
- });
121
+ }, ['agent', 'expires', 'project', 'seller', 'typeOf', 'object']);
122
122
  if (transaction.agent.id !== params.agent.id) {
123
123
  throw new factory.errors.Forbidden('Transaction not yours');
124
124
  }
@@ -43,7 +43,7 @@ function voidTransactionByActionId(params) {
43
43
  const transaction = yield repos.transaction.findInProgressById({
44
44
  typeOf: factory.transactionType.PlaceOrder,
45
45
  id: params.purpose.id
46
- });
46
+ }, ['typeOf', 'object']);
47
47
  // if (transaction.agent.id !== params.agent.id) {
48
48
  // throw new factory.errors.Forbidden('Transaction not yours');
49
49
  // }
@@ -45,7 +45,7 @@ function acceptOffer(params) {
45
45
  const transaction = yield repos.transaction.findInProgressById({
46
46
  typeOf: factory.transactionType.PlaceOrder,
47
47
  id: params.purpose.id
48
- });
48
+ }, ['project', 'agent', 'typeOf']);
49
49
  const coaInfo = yield findCOAInfo({
50
50
  id: params.object.event.id,
51
51
  project: { id: transaction.project.id }
@@ -122,7 +122,7 @@ function reAcceptOffer(params) {
122
122
  const transaction = yield repos.transaction.findInProgressById({
123
123
  typeOf: factory.transactionType.PlaceOrder,
124
124
  id: params.purpose.id
125
- });
125
+ }, ['project', 'agent', 'typeOf']);
126
126
  const coaInfo = yield findCOAInfo({
127
127
  id: params.object.event.id,
128
128
  project: { id: transaction.project.id }
@@ -26,7 +26,7 @@ function authorize(params) {
26
26
  const transaction = yield repos.transaction.findInProgressById({
27
27
  typeOf: factory.transactionType.PlaceOrder,
28
28
  id: params.transaction.id
29
- });
29
+ }, ['agent', 'project', 'seller', 'typeOf', 'object']);
30
30
  if (transaction.agent.id !== params.agent.id) {
31
31
  throw new factory.errors.Forbidden('Transaction not yours');
32
32
  }
@@ -25,7 +25,7 @@ function cancel(params) {
25
25
  const transaction = yield repos.transaction.findInProgressById({
26
26
  typeOf: factory.transactionType.PlaceOrder,
27
27
  id: params.transaction.id
28
- });
28
+ }, ['typeOf', 'object', 'agent']);
29
29
  if (transaction.agent.id !== params.agent.id) {
30
30
  throw new factory.errors.Forbidden('Transaction not yours');
31
31
  }
@@ -26,7 +26,7 @@ function changeOffers(params) {
26
26
  const transaction = yield repos.transaction.findInProgressById({
27
27
  typeOf: factory.transactionType.PlaceOrder,
28
28
  id: params.transaction.id
29
- });
29
+ }, ['typeOf', 'object', 'agent', 'project', 'seller']);
30
30
  if (transaction.agent.id !== params.agent.id) {
31
31
  throw new factory.errors.Forbidden('Transaction not yours');
32
32
  }
@@ -19,7 +19,7 @@ function authorize(params) {
19
19
  const transaction = yield repos.transaction.findInProgressById({
20
20
  typeOf: params.purpose.typeOf,
21
21
  id: params.purpose.id
22
- });
22
+ }, ['seller', 'project', 'agent', 'typeOf']);
23
23
  if (transaction.agent.id !== params.agent.id) {
24
24
  throw new factory.errors.Forbidden('Transaction not yours');
25
25
  }
@@ -16,10 +16,10 @@ function voidTransaction(params) {
16
16
  return (repos) => __awaiter(this, void 0, void 0, function* () {
17
17
  let transaction;
18
18
  if (params.agent !== undefined && params.agent !== null && typeof params.agent.id === 'string') {
19
- transaction = yield repos.transaction.findInProgressById({
19
+ transaction = (yield repos.transaction.findInProgressById({
20
20
  typeOf: params.purpose.typeOf,
21
21
  id: params.purpose.id
22
- });
22
+ }, ['typeOf']));
23
23
  }
24
24
  let authorizeActions;
25
25
  if (typeof params.id === 'string') {
@@ -92,7 +92,7 @@ function authorize(params) {
92
92
  const transaction = yield repos.transaction.findInProgressById({
93
93
  typeOf: factory.transactionType.PlaceOrder,
94
94
  id: params.transaction.id
95
- });
95
+ }, ['agent', 'project', 'seller', 'typeOf', 'expires']);
96
96
  if (transaction.agent.id !== params.agent.id) {
97
97
  throw new factory.errors.Forbidden('Transaction not yours');
98
98
  }
@@ -25,7 +25,7 @@ function findPlaceOrderTransaction(params) {
25
25
  orderNumbers: [params.orderNumber]
26
26
  }
27
27
  },
28
- inclusion: ['id', 'potentialActions', 'project', 'typeOf'],
28
+ inclusion: ['potentialActions', 'project', 'typeOf'],
29
29
  exclusion: []
30
30
  });
31
31
  const placeOrderTransaction = placeOrderTransactions.shift();
@@ -44,8 +44,7 @@ function createOrderFromBody(params) {
44
44
  orderNumbers: [orderNumber]
45
45
  }
46
46
  },
47
- // inclusion: ['id', 'potentialActions', 'project', 'typeOf', 'result'],
48
- inclusion: ['id', 'project', 'typeOf', 'result'],
47
+ inclusion: ['project', 'typeOf', 'result'],
49
48
  exclusion: []
50
49
  });
51
50
  const placeOrderTransactionWithResult = placeOrderTransactions.shift();
@@ -52,7 +52,7 @@ function returnOrder(params) {
52
52
  typeOf: factory.transactionType.ReturnOrder,
53
53
  statuses: [factory.transactionStatusType.Confirmed],
54
54
  object: { order: { orderNumbers: [orderNumber] } },
55
- inclusion: ['id', 'typeOf', 'potentialActions'],
55
+ inclusion: ['typeOf', 'potentialActions'],
56
56
  exclusion: []
57
57
  });
58
58
  const returnOrderTransaction = returnOrderTransactions.shift();
@@ -14,7 +14,7 @@ export declare function creatPayTransactionStartParams(params: {
14
14
  accountId?: string;
15
15
  object: factory.action.authorize.paymentMethod.any.IObject;
16
16
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
17
- transaction: Omit<factory.transaction.ITransaction<factory.transactionType>, 'tasksExportAction' | 'tasksExportedAt' | 'tasksExportationStatus'>;
17
+ transaction: Pick<factory.transaction.ITransaction<factory.transactionType>, 'expires' | 'seller' | 'project'>;
18
18
  transactionNumber: string;
19
19
  location?: factory.action.trade.pay.ILocation;
20
20
  }): factory.assetTransaction.pay.IStartParamsWithoutDetail;
@@ -117,7 +117,7 @@ function processVoidPayTransaction(params) {
117
117
  let transaction;
118
118
  // アクションID指定の場合、進行中取引検証(2023-02-24~)
119
119
  if (typeof params.id === 'string') {
120
- transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
120
+ transaction = (yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['typeOf', 'status']));
121
121
  }
122
122
  else {
123
123
  transaction = (yield repos.transaction.findById({
@@ -225,7 +225,7 @@ function publishPaymentUrl(params) {
225
225
  return (repos) => __awaiter(this, void 0, void 0, function* () {
226
226
  var _a;
227
227
  try {
228
- const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
228
+ const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['expires', 'seller', 'project']);
229
229
  const paymentServiceType = params.paymentServiceType;
230
230
  // 取引番号生成
231
231
  const { transactionNumber } = yield repos.transactionNumber.publishByTimestamp({
@@ -298,7 +298,7 @@ function authorize(params) {
298
298
  transaction: repos.transaction
299
299
  });
300
300
  }
301
- const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
301
+ const transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id }, ['agent', 'expires', 'object', 'typeOf', 'project', 'seller']);
302
302
  const paymentServiceType = params.paymentServiceType;
303
303
  // 取引番号生成
304
304
  let transactionNumber;
@@ -1,4 +1,3 @@
1
- import * as factory from '../../factory';
2
1
  import type { MongoRepository as ActionRepo } from '../../repo/action';
3
2
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
4
3
  import type { AuthorizationRepo } from '../../repo/code';
@@ -8,7 +7,7 @@ import type { MongoRepository as ProjectRepo } from '../../repo/project';
8
7
  import type { MongoRepository as SellerRepo } from '../../repo/seller';
9
8
  import type { MongoRepository as TaskRepo } from '../../repo/task';
10
9
  import type { TicketRepo } from '../../repo/ticket';
11
- import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
10
+ import type { IStartedTransaction, MongoRepository as TransactionRepo } from '../../repo/transaction';
12
11
  import type { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
13
12
  import { IPassportValidator as IWaiterPassportValidator, moneyTransfer as MoneyTransferFactory } from '../../factory/transaction';
14
13
  export interface IStartOperationRepos {
@@ -38,7 +37,7 @@ export type IStartParams = MoneyTransferFactory.IStartParams;
38
37
  * 取引開始
39
38
  * 通貨転送資産取引サービスを利用して転送取引を開始する
40
39
  */
41
- export declare function start(params: IStartParams): IStartOperation<factory.transaction.moneyTransfer.ITransaction>;
40
+ export declare function start(params: IStartParams): IStartOperation<IStartedTransaction>;
42
41
  export type IAuthorizeOperation<T> = (repos: {
43
42
  action: ActionRepo;
44
43
  authorization: AuthorizationRepo;
@@ -53,7 +53,9 @@ function start(params) {
53
53
  let transaction;
54
54
  try {
55
55
  transaction = yield repos.transaction.start(startParams);
56
- yield authorizePaymentCard({ transaction })(repos);
56
+ yield authorizePaymentCard({
57
+ transaction: Object.assign(Object.assign({}, transaction), { object: startParams.object, seller: startParams.seller, agent: startParams.agent, project: startParams.project, typeOf: startParams.typeOf })
58
+ })(repos);
57
59
  }
58
60
  catch (error) {
59
61
  throw error;
@@ -164,7 +166,7 @@ function processAuthorizePaymentCard(params) {
164
166
  const transaction = yield repos.transaction.findInProgressById({
165
167
  typeOf: factory.transactionType.MoneyTransfer,
166
168
  id: params.purpose.id
167
- });
169
+ }, ['_id', 'agent', 'project', 'recipient', 'seller', 'typeOf', 'object']);
168
170
  const recipient = {
169
171
  typeOf: transaction.recipient.typeOf,
170
172
  id: transaction.recipient.id,
@@ -24,7 +24,7 @@ function exportTasksById(params) {
24
24
  const transaction = yield repos.transaction.findById({
25
25
  typeOf: factory.transactionType.PlaceOrder,
26
26
  id: params.id,
27
- inclusion: ['endDate', 'id', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']
27
+ inclusion: ['endDate', 'object', 'project', 'seller', 'startDate', 'status', 'typeOf']
28
28
  });
29
29
  // タスク実行日時バッファの指定があれば調整
30
30
  let taskRunsAt = new Date();
@@ -1,8 +1,7 @@
1
1
  import type { MongoRepository as MemberRepo } from '../../../repo/member';
2
2
  import type { MongoRepository as ProjectMakesOfferRepo } from '../../../repo/projectMakesOffer';
3
3
  import type { MongoRepository as SellerRepo } from '../../../repo/seller';
4
- import type { MongoRepository as TransactionRepo } from '../../../repo/transaction';
5
- import * as factory from '../../../factory';
4
+ import type { IStartedTransaction, MongoRepository as TransactionRepo } from '../../../repo/transaction';
6
5
  import { placeOrder as PlaceOrderFactory } from '../../../factory/transaction';
7
6
  interface IStartOperationRepos {
8
7
  member: MemberRepo;
@@ -15,5 +14,5 @@ type IStartParams = PlaceOrderFactory.IStartParams;
15
14
  /**
16
15
  * 取引開始
17
16
  */
18
- declare function start(params: IStartParams): IStartOperation<factory.transaction.placeOrder.ITransaction>;
17
+ declare function start(params: IStartParams): IStartOperation<IStartedTransaction>;
19
18
  export { start };
@@ -10,7 +10,7 @@ import type { MongoRepository as ProjectRepo } from '../../repo/project';
10
10
  import type { MongoRepository as ReservationRepo } from '../../repo/reservation';
11
11
  import type { MongoRepository as SellerRepo } from '../../repo/seller';
12
12
  import type { MongoRepository as TaskRepo } from '../../repo/task';
13
- import type { MongoRepository as TransactionRepo } from '../../repo/transaction';
13
+ import type { IStartedTransaction, MongoRepository as TransactionRepo } from '../../repo/transaction';
14
14
  import { preStart } from './returnOrder/preStart';
15
15
  interface IStartOperationRepos {
16
16
  acceptedOffer: AcceptedOfferRepo;
@@ -32,7 +32,7 @@ type ITaskAndTransactionOperation<T> = (repos: {
32
32
  /**
33
33
  * 返品取引開始
34
34
  */
35
- declare function start(params: factory.transaction.returnOrder.IStartParamsWithoutDetail): IStartOperation<factory.transaction.returnOrder.ITransaction>;
35
+ declare function start(params: factory.transaction.returnOrder.IStartParamsWithoutDetail): IStartOperation<IStartedTransaction>;
36
36
  /**
37
37
  * 取引確定
38
38
  */
@@ -48,7 +48,7 @@ function updateAgent(params) {
48
48
  const transaction = yield repos.transaction.findInProgressById({
49
49
  typeOf: params.typeOf,
50
50
  id: params.id
51
- });
51
+ }, ['agent', 'object', 'typeOf']);
52
52
  if (transaction.agent.id !== params.agent.id) {
53
53
  throw new factory.errors.Forbidden('Transaction not yours');
54
54
  }
@@ -61,9 +61,10 @@ function updateAgent(params) {
61
61
  let customer;
62
62
  if (transaction.typeOf === factory.transactionType.PlaceOrder) {
63
63
  // いったんtransaction.object.customer?.typeOfは取引開始時にセットされている前提
64
- if (typeof ((_a = transaction.object.customer) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
65
- customer = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: transaction.object.customer.typeOf, id: transaction.object.customer.id }, (Array.isArray(transaction.object.customer.identifier))
66
- ? { identifier: transaction.object.customer.identifier }
64
+ const trasactionObject = transaction.object;
65
+ if (typeof ((_a = trasactionObject.customer) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
66
+ customer = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: trasactionObject.customer.typeOf, id: trasactionObject.customer.id }, (Array.isArray(trasactionObject.customer.identifier))
67
+ ? { identifier: trasactionObject.customer.identifier }
67
68
  : undefined), (Array.isArray(params.agent.additionalProperty)) ? { additionalProperty: params.agent.additionalProperty } : {}), (typeof params.agent.age === 'string') ? { age: params.agent.age } : {}), (typeof params.agent.address === 'string') ? { address: params.agent.address } : {}), (typeof params.agent.email === 'string') ? { email: params.agent.email } : {}), (typeof params.agent.familyName === 'string') ? { familyName: params.agent.familyName } : {}), (typeof params.agent.gender === 'string') ? { gender: params.agent.gender } : {}), (typeof params.agent.givenName === 'string') ? { givenName: params.agent.givenName } : {}), (typeof params.agent.name === 'string') ? { name: params.agent.name } : {}), (typeof formattedTelephone === 'string') ? { telephone: formattedTelephone } : {}), (typeof params.agent.url === 'string') ? { url: params.agent.url } : {});
68
69
  }
69
70
  }
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.371.0-alpha.6",
14
- "@cinerino/sdk": "7.0.0-alpha.10",
13
+ "@chevre/factory": "4.372.0",
14
+ "@cinerino/sdk": "7.0.0-alpha.12",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
17
17
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.33.0-alpha.5"
113
+ "version": "21.33.0-alpha.7"
114
114
  }