@chevre/domain 21.37.0-alpha.2 → 21.37.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 (33) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +79 -0
  2. package/lib/chevre/repo/assetTransaction.d.ts +6 -3
  3. package/lib/chevre/repo/assetTransaction.js +53 -27
  4. package/lib/chevre/service/assetTransaction/refund/potentialActions.js +6 -8
  5. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +1 -2
  6. package/lib/chevre/service/assetTransaction/reserve/factory.js +46 -47
  7. package/lib/chevre/service/assetTransaction/reserve.js +47 -36
  8. package/lib/chevre/service/notification.d.ts +5 -1
  9. package/lib/chevre/service/notification.js +5 -2
  10. package/lib/chevre/service/offer/onEventChanged.js +4 -4
  11. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +4 -4
  12. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +4 -4
  13. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +4 -4
  14. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +4 -4
  15. package/lib/chevre/service/order/onOrderUpdated/factory.js +4 -4
  16. package/lib/chevre/service/payment/any/onPaid.d.ts +1 -3
  17. package/lib/chevre/service/payment/any/onPaid.js +7 -4
  18. package/lib/chevre/service/payment/any/onRefund.js +6 -3
  19. package/lib/chevre/service/payment/factory.js +6 -8
  20. package/lib/chevre/service/reserve/factory.d.ts +3 -1
  21. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -4
  22. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +8 -8
  23. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +4 -4
  24. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
  25. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +4 -4
  26. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +4 -4
  27. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +4 -4
  28. package/lib/chevre/service/task/onResourceUpdated.js +24 -24
  29. package/lib/chevre/service/task/triggerWebhook.d.ts +2 -2
  30. package/lib/chevre/service/task/triggerWebhook.js +3 -3
  31. package/lib/chevre/service/task.js +1 -0
  32. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +0 -2
  33. package/package.json +2 -2
@@ -0,0 +1,79 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+ import * as redis from 'redis';
5
+
6
+ import { chevre } from '../../../../lib/index';
7
+
8
+ const project = { id: String(process.env.PROJECT_ID) };
9
+
10
+ async function main() {
11
+ const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
12
+ socket: {
13
+ port: Number(<string>process.env.REDIS_PORT),
14
+ host: <string>process.env.REDIS_HOST
15
+ },
16
+ password: <string>process.env.REDIS_KEY
17
+ });
18
+ await redisClient.connect();
19
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
20
+
21
+ const transactionNumberRepo = await chevre.repository.TransactionNumber.createInstance(redisClient);
22
+ const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
23
+
24
+ const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: new Date() });
25
+ const provider: chevre.factory.reservation.IProvider = {
26
+ id: '59d20831e53ebc2b4e774466',
27
+ typeOf: chevre.factory.organizationType.Corporation
28
+ };
29
+ const reserveTransaction = await assetTransactionRepo.start<chevre.factory.assetTransactionType.Reserve>({
30
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
31
+ typeOf: chevre.factory.assetTransactionType.Reserve,
32
+ transactionNumber,
33
+ agent: { ...provider, name: 'sample agent name' },
34
+ object: {
35
+ provider,
36
+ reservationNumber: transactionNumber,
37
+ reservationStatus: chevre.factory.reservationStatusType.ReservationPending,
38
+ disablePendingReservations: true,
39
+ useHoldStockByTransactionNumber: true,
40
+ typeOf: chevre.factory.reservationType.ReservationPackage
41
+ },
42
+ expires: moment()
43
+ .add(1, 'minute')
44
+ .toDate()
45
+ });
46
+ let cancelResult = await assetTransactionRepo.cancel<chevre.factory.assetTransactionType.Reserve>({
47
+ typeOf: reserveTransaction.typeOf,
48
+ id: reserveTransaction.id
49
+ });
50
+ console.log('cancelResult:', cancelResult);
51
+ cancelResult = await assetTransactionRepo.cancel<chevre.factory.assetTransactionType.Reserve>({
52
+ typeOf: reserveTransaction.typeOf,
53
+ id: reserveTransaction.id
54
+ });
55
+ console.log('cancelResult:', cancelResult);
56
+
57
+ let transaction = await assetTransactionRepo.findById<chevre.factory.assetTransactionType.Reserve>(
58
+ {
59
+ typeOf: chevre.factory.assetTransactionType.Reserve,
60
+ id: reserveTransaction.id
61
+ },
62
+ ['status', 'transactionNumber', 'project', 'typeOf']
63
+ );
64
+ console.log('transaction:', transaction);
65
+
66
+ transaction = await assetTransactionRepo.findByTransactionNumber<chevre.factory.assetTransactionType.Reserve>(
67
+ {
68
+ typeOf: chevre.factory.assetTransactionType.Reserve,
69
+ transactionNumber
70
+ },
71
+ ['status']
72
+ );
73
+ console.log('transaction:', transaction);
74
+
75
+ }
76
+
77
+ main()
78
+ .then(console.log)
79
+ .catch(console.error);
@@ -45,6 +45,7 @@ interface IStatus {
45
45
  export interface IAggregateReserve {
46
46
  statuses: IStatus[];
47
47
  }
48
+ type IKeyOfProjection<T extends factory.assetTransactionType> = keyof Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType>, 'agent' | 'endDate' | 'expires' | 'project' | 'startDate' | 'status' | 'typeOf' | 'transactionNumber'> | Exclude<keyof factory.assetTransaction.ITransaction<T>, 'id'>;
48
49
  /**
49
50
  * 資産取引リポジトリ
50
51
  */
@@ -59,11 +60,11 @@ export declare class MongoRepository {
59
60
  findById<T extends factory.assetTransactionType>(params: {
60
61
  typeOf: T;
61
62
  id: string;
62
- }): Promise<factory.assetTransaction.ITransaction<T>>;
63
+ }, inclusion?: IKeyOfProjection<T>[]): Promise<factory.assetTransaction.ITransaction<T>>;
63
64
  findByTransactionNumber<T extends factory.assetTransactionType>(params: {
64
65
  typeOf: T;
65
66
  transactionNumber: string;
66
- }): Promise<factory.assetTransaction.ITransaction<T>>;
67
+ }, inclusion?: IKeyOfProjection<T>[]): Promise<factory.assetTransaction.ITransaction<T>>;
67
68
  addReservations(params: {
68
69
  typeOf: factory.assetTransactionType.Reserve;
69
70
  id: string;
@@ -147,7 +148,9 @@ export declare class MongoRepository {
147
148
  typeOf: T;
148
149
  id?: string;
149
150
  transactionNumber?: string;
150
- }): Promise<factory.assetTransaction.ITransaction<T>>;
151
+ }): Promise<{
152
+ id: string;
153
+ }>;
151
154
  count<T extends factory.assetTransactionType>(params: factory.assetTransaction.ISearchConditions<T>): Promise<number>;
152
155
  /**
153
156
  * 取引を検索する
@@ -307,12 +307,21 @@ class MongoRepository {
307
307
  .then((doc) => doc.toObject());
308
308
  });
309
309
  }
310
- findById(params) {
310
+ findById(params, inclusion) {
311
311
  return __awaiter(this, void 0, void 0, function* () {
312
+ let projection = {};
313
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
314
+ inclusion.forEach((field) => {
315
+ projection[field] = 1;
316
+ });
317
+ }
318
+ else {
319
+ projection = {};
320
+ }
312
321
  const doc = yield this.transactionModel.findOne({
313
- _id: params.id,
314
- typeOf: params.typeOf
315
- })
322
+ _id: { $eq: params.id },
323
+ typeOf: { $eq: params.typeOf }
324
+ }, projection)
316
325
  .exec();
317
326
  if (doc === null) {
318
327
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -320,12 +329,21 @@ class MongoRepository {
320
329
  return doc.toObject();
321
330
  });
322
331
  }
323
- findByTransactionNumber(params) {
332
+ findByTransactionNumber(params, inclusion) {
324
333
  return __awaiter(this, void 0, void 0, function* () {
334
+ let projection = {};
335
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
336
+ inclusion.forEach((field) => {
337
+ projection[field] = 1;
338
+ });
339
+ }
340
+ else {
341
+ projection = {};
342
+ }
325
343
  const doc = yield this.transactionModel.findOne({
326
344
  transactionNumber: { $eq: params.transactionNumber },
327
- typeOf: params.typeOf
328
- })
345
+ typeOf: { $eq: params.typeOf }
346
+ }, projection)
329
347
  .exec();
330
348
  if (doc === null) {
331
349
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -340,11 +358,13 @@ class MongoRepository {
340
358
  typeOf: { $eq: params.typeOf },
341
359
  status: { $eq: factory.transactionStatusType.InProgress }
342
360
  }, {
343
- 'object.acceptedOffer': params.object.acceptedOffer,
344
- 'object.issuedThrough': params.object.issuedThrough,
345
- 'object.reservationFor': params.object.reservationFor,
346
- 'object.subReservation': params.object.subReservation
347
- }, { new: true, projection: { _id: 1 } })
361
+ $set: {
362
+ 'object.acceptedOffer': params.object.acceptedOffer,
363
+ 'object.issuedThrough': params.object.issuedThrough,
364
+ 'object.reservationFor': params.object.reservationFor,
365
+ 'object.subReservation': params.object.subReservation
366
+ }
367
+ }, { new: false, projection: { _id: 1 } })
348
368
  .exec();
349
369
  if (doc === null) {
350
370
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -373,15 +393,15 @@ class MongoRepository {
373
393
  .exec();
374
394
  // NotFoundであれば取引状態確認
375
395
  if (doc === null) {
376
- const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
396
+ const transaction = yield this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
377
397
  if (transaction.status === factory.transactionStatusType.Confirmed) {
378
398
  // すでに確定済の場合スルー
379
399
  }
380
400
  else if (transaction.status === factory.transactionStatusType.Expired) {
381
- throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
401
+ throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already expired`);
382
402
  }
383
403
  else if (transaction.status === factory.transactionStatusType.Canceled) {
384
- throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already canceled`);
404
+ throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${params.id} already canceled`);
385
405
  }
386
406
  else {
387
407
  throw new factory.errors.NotFound(this.transactionModel.modelName);
@@ -593,26 +613,31 @@ class MongoRepository {
593
613
  */
594
614
  cancel(params) {
595
615
  return __awaiter(this, void 0, void 0, function* () {
596
- const endDate = new Date();
597
616
  // 進行中ステータスの取引を中止する
598
617
  const doc = yield this.transactionModel.findOneAndUpdate(Object.assign(Object.assign(Object.assign({ typeOf: { $eq: params.typeOf } }, (typeof params.id === 'string') ? { _id: { $eq: params.id } } : undefined), (typeof params.transactionNumber === 'string')
599
618
  ? { transactionNumber: { $eq: params.transactionNumber } }
600
619
  : undefined), { status: { $eq: factory.transactionStatusType.InProgress } }), {
601
- status: factory.transactionStatusType.Canceled,
602
- endDate: endDate
603
- }, { new: true })
620
+ $set: {
621
+ status: factory.transactionStatusType.Canceled,
622
+ endDate: new Date()
623
+ }
624
+ }, {
625
+ new: true,
626
+ projection: { _id: 1 }
627
+ })
604
628
  .exec();
605
- let transaction;
629
+ let result;
606
630
  // NotFoundであれば取引状態確認
607
631
  if (doc === null) {
632
+ let transaction;
608
633
  if (typeof params.id === 'string') {
609
- transaction = yield this.findById({ typeOf: params.typeOf, id: params.id });
634
+ transaction = yield this.findById({ typeOf: params.typeOf, id: params.id }, ['status']);
610
635
  }
611
636
  else if (typeof params.transactionNumber === 'string') {
612
637
  transaction = yield this.findByTransactionNumber({
613
638
  typeOf: params.typeOf,
614
639
  transactionNumber: params.transactionNumber
615
- });
640
+ }, ['status']);
616
641
  }
617
642
  else {
618
643
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
@@ -621,24 +646,25 @@ class MongoRepository {
621
646
  // すでに中止済の場合スルー
622
647
  }
623
648
  else if (transaction.status === factory.transactionStatusType.Expired) {
624
- throw new factory.errors.Argument('Transaction id', `Transaction ${transaction.typeOf} ${transaction.transactionNumber} already expired`);
649
+ throw new factory.errors.Argument('Transaction id', `Transaction ${params.typeOf} ${transaction.id} already expired`);
625
650
  }
626
651
  else if (transaction.status === factory.transactionStatusType.Confirmed) {
627
- throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${transaction.typeOf} ${transaction.transactionNumber} unable to cancel`);
652
+ throw new factory.errors.Argument('Transaction id', `Confirmed transaction ${params.typeOf} ${transaction.id} unable to cancel`);
628
653
  }
629
654
  else {
630
655
  throw new factory.errors.NotFound(this.transactionModel.modelName);
631
656
  }
657
+ result = { id: transaction.id };
632
658
  }
633
659
  else {
634
- transaction = doc.toObject();
660
+ result = { id: doc.toObject().id };
635
661
  }
636
662
  assetTransaction_2.assetTransactionEventEmitter.emitAssetTransactionStatusChanged({
637
- id: transaction.id,
663
+ id: result.id,
638
664
  typeOf: params.typeOf,
639
665
  status: factory.transactionStatusType.Canceled
640
666
  });
641
- return transaction;
667
+ return result;
642
668
  });
643
669
  }
644
670
  count(params) {
@@ -50,17 +50,15 @@ function createInformPaymentActions(params) {
50
50
  : String(transaction.agent.id),
51
51
  url: String((_c = a.recipient) === null || _c === void 0 ? void 0 : _c.url)
52
52
  };
53
+ // optimize(2024-07-01~)
53
54
  return {
54
- project: transaction.project,
55
- typeOf: factory.actionType.InformAction,
56
- agent: transaction.project,
55
+ // project: transaction.project,
56
+ // typeOf: factory.actionType.InformAction,
57
+ // agent: transaction.project,
57
58
  recipient,
58
59
  // 実際にタスクが生成される直前にactionに置き換える
59
- object: {},
60
- purpose: {
61
- typeOf: transaction.typeOf,
62
- id: transaction.id
63
- }
60
+ // object: {},
61
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
64
62
  };
65
63
  }));
66
64
  }
@@ -81,8 +81,7 @@ export declare function createReservation(params: {
81
81
  appliesToMovieTicket?: factory.assetTransaction.reserve.IAcceptedAppliesToMovieTicket;
82
82
  validateAppliesToMovieTicket: boolean;
83
83
  }): IObjectSubReservation;
84
- export declare function createPotentialActions(params: factory.assetTransaction.reserve.IConfirmParams & {
85
- transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
84
+ export declare function createPotentialActions(params: {
86
85
  order?: Pick<factory.order.IOrder, 'orderNumber' | 'customer' | 'typeOf'>;
87
86
  }): {
88
87
  potentialActions: factory.assetTransaction.reserve.IPotentialActions;
@@ -490,61 +490,60 @@ function createReservation(params) {
490
490
  exports.createReservation = createReservation;
491
491
  // tslint:disable-next-line:max-func-body-length
492
492
  function createPotentialActions(params) {
493
+ // const transaction = params.transaction;
494
+ // const reservationFor = transaction.object.reservationFor;
495
+ // if (reservationFor === undefined) {
496
+ // throw new factory.errors.NotFound('transaction.object.reservationFor');
497
+ // }
493
498
  var _a;
494
- const transaction = params.transaction;
495
- const reservationFor = transaction.object.reservationFor;
496
- if (reservationFor === undefined) {
497
- throw new factory.errors.NotFound('transaction.object.reservationFor');
498
- }
499
499
  // discontinue(2024-07-01~)
500
500
  // const useOptimizeReservation: boolean = !USE_OPTIMIZE_RESERVATION_EXCEPTIONS.includes(transaction.project.id);
501
501
  // 予約アクション属性作成
502
- const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
502
+ // const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
503
503
  // let reserveActionAttributes: factory.action.reserve.IAttributes[] = [];
504
504
  // let reservationPackage: factory.action.reserve.IObject | undefined;
505
505
  let underName;
506
- if (pendingReservations.length > 0) {
507
- // ReservationPackageに対応(2022-12-22~)
508
- // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
509
- if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
510
- const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
511
- underName = ordre2reservationUnderNameResult.underName;
512
- }
513
- // const moneyTransferActions: factory.action.transfer.moneyTransfer.IAttributes[] = [];
514
- // pendingReservations.forEach((reservation) => {
515
- // const acceptedOffer4reservation = transaction.object.acceptedOffer?.find(
516
- // (o) => o.itemOffered?.serviceOutput?.id === reservation.id
517
- // );
518
- // moneyTransferActions.push(...createMoneyTransferActions({
519
- // acceptedOffer: acceptedOffer4reservation,
520
- // reservation,
521
- // transaction: params.transaction,
522
- // underName
523
- // }));
524
- // });
525
- // reservationPackage = {
526
- // reservationFor: {
527
- // id: String(reservationFor.id),
528
- // typeOf: reservationFor.typeOf,
529
- // optimized: true
530
- // }, // optimize(2024-01-24~)
531
- // reservationNumber: transaction.object.reservationNumber,
532
- // reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
533
- // ? params.transaction.object.reservationStatus
534
- // : factory.reservationStatusType.ReservationPending,
535
- // typeOf: factory.reservationType.ReservationPackage
536
- // };
537
- // reserveActionAttributes = [{
538
- // project: transaction.project,
539
- // typeOf: <factory.actionType.ReserveAction>factory.actionType.ReserveAction,
540
- // object: reservationPackage,
541
- // agent: transaction.project,
542
- // potentialActions: {
543
- // moneyTransfer: moneyTransferActions
544
- // },
545
- // purpose: { typeOf: transaction.typeOf, id: transaction.id }
546
- // }];
506
+ // purpose:Orderの指定があれば、underName,issuedByを調整(2022-05-23~)
507
+ if (typeof ((_a = params.order) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
508
+ const ordre2reservationUnderNameResult = ordre2reservationUnderName({ order: params.order });
509
+ underName = ordre2reservationUnderNameResult.underName;
547
510
  }
511
+ // if (pendingReservations.length > 0) {
512
+ // const moneyTransferActions: factory.action.transfer.moneyTransfer.IAttributes[] = [];
513
+ // pendingReservations.forEach((reservation) => {
514
+ // const acceptedOffer4reservation = transaction.object.acceptedOffer?.find(
515
+ // (o) => o.itemOffered?.serviceOutput?.id === reservation.id
516
+ // );
517
+ // moneyTransferActions.push(...createMoneyTransferActions({
518
+ // acceptedOffer: acceptedOffer4reservation,
519
+ // reservation,
520
+ // transaction: params.transaction,
521
+ // underName
522
+ // }));
523
+ // });
524
+ // reservationPackage = {
525
+ // reservationFor: {
526
+ // id: String(reservationFor.id),
527
+ // typeOf: reservationFor.typeOf,
528
+ // optimized: true
529
+ // }, // optimize(2024-01-24~)
530
+ // reservationNumber: transaction.object.reservationNumber,
531
+ // reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
532
+ // ? params.transaction.object.reservationStatus
533
+ // : factory.reservationStatusType.ReservationPending,
534
+ // typeOf: factory.reservationType.ReservationPackage
535
+ // };
536
+ // reserveActionAttributes = [{
537
+ // project: transaction.project,
538
+ // typeOf: <factory.actionType.ReserveAction>factory.actionType.ReserveAction,
539
+ // object: reservationPackage,
540
+ // agent: transaction.project,
541
+ // potentialActions: {
542
+ // moneyTransfer: moneyTransferActions
543
+ // },
544
+ // purpose: { typeOf: transaction.typeOf, id: transaction.id }
545
+ // }];
546
+ // }
548
547
  return {
549
548
  potentialActions: {
550
549
  // reserve: reserveActionAttributes // discontinue(2024-07-01~)
@@ -57,7 +57,7 @@ function start(params) {
57
57
  now,
58
58
  store: { id: (_c = params.availableAtOrFrom) === null || _c === void 0 ? void 0 : _c.id }
59
59
  });
60
- const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { provider: { id: event.organizer.id }, reservationNumber: reservationNumber }));
60
+ const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { provider: { id: event.organizer.id }, reservationNumber }));
61
61
  // 取引作成
62
62
  let transaction;
63
63
  try {
@@ -68,7 +68,9 @@ function start(params) {
68
68
  }
69
69
  let objectSubReservations = [];
70
70
  const addReservationsResult = yield addReservations({
71
- id: transaction.id,
71
+ // id: transaction.id,
72
+ transaction,
73
+ now,
72
74
  object: params.object,
73
75
  event,
74
76
  preSearchedTicketOffers: params.preSearchedTicketOffers,
@@ -94,8 +96,10 @@ function addReservations(params) {
94
96
  // tslint:disable-next-line:max-func-body-length
95
97
  return (repos) => __awaiter(this, void 0, void 0, function* () {
96
98
  var _a;
97
- const now = new Date();
98
- const transaction = yield repos.assetTransaction.findById({ typeOf: factory.assetTransactionType.Reserve, id: params.id });
99
+ // const now = new Date();
100
+ // const transaction = await repos.assetTransaction.findById({ typeOf: factory.assetTransactionType.Reserve, id: params.id });
101
+ const now = params.now;
102
+ const transaction = params.transaction;
99
103
  const acceptedOffers = (Array.isArray(params.object.acceptedOffer)) ? params.object.acceptedOffer : [];
100
104
  const event = params.event;
101
105
  if (event.typeOf !== factory.eventType.ScreeningEvent && event.typeOf !== factory.eventType.Event) {
@@ -870,20 +874,25 @@ function confirm(params) {
870
874
  transaction = yield repos.assetTransaction.findById({
871
875
  typeOf: factory.assetTransactionType.Reserve,
872
876
  id: params.id
873
- });
877
+ }, ['project', 'transactionNumber'] // projection(2024-07-01~)
878
+ );
874
879
  }
875
880
  else if (typeof params.transactionNumber === 'string') {
876
881
  transaction = yield repos.assetTransaction.findByTransactionNumber({
877
882
  typeOf: factory.assetTransactionType.Reserve,
878
883
  transactionNumber: params.transactionNumber
879
- });
884
+ }, ['project', 'transactionNumber'] // projection(2024-07-01~)
885
+ );
880
886
  }
881
887
  else {
882
888
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
883
889
  }
884
890
  const order = yield fixOrderAsPurpose(params, transaction)(repos);
885
- const { potentialActions, underName } = (0, factory_1.createPotentialActions)(Object.assign(Object.assign({}, params), { transaction,
886
- order }));
891
+ const { potentialActions, underName } = (0, factory_1.createPotentialActions)({
892
+ // ...params,
893
+ // transaction,
894
+ order
895
+ });
887
896
  // 取引確定
888
897
  const result = {};
889
898
  yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Reserve, id: transaction.id, result: result,
@@ -937,7 +946,7 @@ function fixOrderAsPurpose(params, transaction) {
937
946
  function cancel(params) {
938
947
  return (repos) => __awaiter(this, void 0, void 0, function* () {
939
948
  // まず取引状態変更
940
- const transaction = yield repos.assetTransaction.cancel({
949
+ const { id } = yield repos.assetTransaction.cancel({
941
950
  typeOf: factory.assetTransactionType.Reserve,
942
951
  id: params.id,
943
952
  transactionNumber: params.transactionNumber
@@ -951,7 +960,7 @@ function cancel(params) {
951
960
  // }
952
961
  yield (0, cancelReservation_1.cancelPendingReservation)({
953
962
  purpose: {
954
- id: transaction.id,
963
+ id,
955
964
  typeOf: factory.assetTransactionType.Reserve
956
965
  }
957
966
  })(repos);
@@ -967,9 +976,11 @@ function exportTasksById(params) {
967
976
  const transaction = yield repos.assetTransaction.findById({
968
977
  typeOf: factory.assetTransactionType.Reserve,
969
978
  id: params.id
970
- });
979
+ }, ['status', 'transactionNumber', 'project', 'typeOf'] // projection(2024-07-01~)
980
+ );
971
981
  // const potentialActions = transaction.potentialActions;
972
982
  const taskAttributes = [];
983
+ let cancelPendingReservationTask;
973
984
  switch (transaction.status) {
974
985
  case factory.transactionStatusType.Confirmed:
975
986
  // potentialActions依存を完全廃止(2024-07-01~)
@@ -994,30 +1005,10 @@ function exportTasksById(params) {
994
1005
  case factory.transactionStatusType.Canceled:
995
1006
  // sync対応(2023-01-13~)
996
1007
  if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
997
- const cancelActionAttributes4canceled = (0, factory_1.createCancelPendingReservationAction)({ transaction });
998
- if (cancelActionAttributes4canceled !== undefined) {
999
- const cancelPendingReservationTask = {
1000
- project: transaction.project,
1001
- name: factory.taskName.CancelPendingReservation,
1002
- status: factory.taskStatus.Ready,
1003
- runsAt: new Date(),
1004
- remainingNumberOfTries: 10,
1005
- numberOfTried: 0,
1006
- executionResults: [],
1007
- data: {
1008
- // optimize(2024-07-01~)
1009
- // actionAttributes: [cancelActionAttributes4canceled],
1010
- purpose: { id: transaction.id, typeOf: transaction.typeOf }
1011
- }
1012
- };
1013
- taskAttributes.push(cancelPendingReservationTask);
1014
- }
1015
- }
1016
- break;
1017
- case factory.transactionStatusType.Expired:
1018
- const cancelActionAttributes = (0, factory_1.createCancelPendingReservationAction)({ transaction });
1019
- if (cancelActionAttributes !== undefined) {
1020
- const cancelPendingReservationTask = {
1008
+ // const cancelActionAttributes4canceled = createCancelPendingReservationAction({ transaction });
1009
+ // if (cancelActionAttributes4canceled !== undefined) {
1010
+ // }
1011
+ cancelPendingReservationTask = {
1021
1012
  project: transaction.project,
1022
1013
  name: factory.taskName.CancelPendingReservation,
1023
1014
  status: factory.taskStatus.Ready,
@@ -1027,13 +1018,33 @@ function exportTasksById(params) {
1027
1018
  executionResults: [],
1028
1019
  data: {
1029
1020
  // optimize(2024-07-01~)
1030
- // actionAttributes: [cancelActionAttributes]
1021
+ // actionAttributes: [cancelActionAttributes4canceled],
1031
1022
  purpose: { id: transaction.id, typeOf: transaction.typeOf }
1032
1023
  }
1033
1024
  };
1034
1025
  taskAttributes.push(cancelPendingReservationTask);
1035
1026
  }
1036
1027
  break;
1028
+ case factory.transactionStatusType.Expired:
1029
+ // const cancelActionAttributes = createCancelPendingReservationAction({ transaction });
1030
+ // if (cancelActionAttributes !== undefined) {
1031
+ // }
1032
+ cancelPendingReservationTask = {
1033
+ project: transaction.project,
1034
+ name: factory.taskName.CancelPendingReservation,
1035
+ status: factory.taskStatus.Ready,
1036
+ runsAt: new Date(),
1037
+ remainingNumberOfTries: 10,
1038
+ numberOfTried: 0,
1039
+ executionResults: [],
1040
+ data: {
1041
+ // optimize(2024-07-01~)
1042
+ // actionAttributes: [cancelActionAttributes]
1043
+ purpose: { id: transaction.id, typeOf: transaction.typeOf }
1044
+ }
1045
+ };
1046
+ taskAttributes.push(cancelPendingReservationTask);
1047
+ break;
1037
1048
  default:
1038
1049
  throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
1039
1050
  }
@@ -26,7 +26,11 @@ declare function lineNotify({ subject, content, imageThumbnail, imageFullsize, l
26
26
  imageFullsize?: string;
27
27
  logLevel: LineNotifyLogLevel;
28
28
  }): ILineNotifyOperation<void>;
29
- declare function triggerWebhook(params: factory.task.IData<factory.taskName.TriggerWebhook>): (repos: {
29
+ declare function triggerWebhook(params: factory.task.IData<factory.taskName.TriggerWebhook> & {
30
+ project: {
31
+ id: string;
32
+ };
33
+ }): (repos: {
30
34
  action: ActionRepo;
31
35
  useFetchAPI: boolean;
32
36
  }) => Promise<void>;
@@ -231,11 +231,14 @@ function sleep(waitTime) {
231
231
  });
232
232
  });
233
233
  }
234
+ function createInformActionAttributes(params) {
235
+ const { object, purpose, recipient, project } = params;
236
+ return Object.assign({ agent: { id: project.id, typeOf: factory.organizationType.Project }, object, project: { id: project.id, typeOf: factory.organizationType.Project }, recipient, typeOf: factory.actionType.InformAction }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined);
237
+ }
234
238
  function processInformAction(params) {
235
239
  return (repos) => __awaiter(this, void 0, void 0, function* () {
236
240
  var _a, _b, _c;
237
- // アクション開始
238
- const action = yield repos.action.start(params);
241
+ const action = yield repos.action.start(createInformActionAttributes(params));
239
242
  let result = {};
240
243
  try {
241
244
  if (typeof ((_a = params.recipient) === null || _a === void 0 ? void 0 : _a.url) === 'string') {
@@ -201,16 +201,16 @@ function createInformTasks(params) {
201
201
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
202
202
  delete event4inform._id;
203
203
  const informActionAttributes = {
204
- agent: event4inform.project,
204
+ // agent: event4inform.project,
205
205
  object: event4inform,
206
- project: event4inform.project,
206
+ // project: event4inform.project,
207
207
  recipient: {
208
208
  id: '',
209
209
  name: String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.name),
210
210
  typeOf: factory.creativeWorkType.WebApplication,
211
211
  url: informUrl
212
- },
213
- typeOf: factory.actionType.InformAction
212
+ }
213
+ // typeOf: factory.actionType.InformAction
214
214
  };
215
215
  informTasks.push({
216
216
  project: event4inform.project,
@@ -15,16 +15,16 @@ function createInformTasks(order) {
15
15
  informTasks = informOrder.map((informOrderParams) => {
16
16
  var _a, _b;
17
17
  const informActionAttributes = {
18
- agent: order.project,
18
+ // agent: order.project,
19
19
  object: order4inform,
20
- project: order.project,
20
+ // project: order.project,
21
21
  recipient: {
22
22
  url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
23
23
  id: recipientId,
24
24
  name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
25
25
  typeOf: factory.creativeWorkType.WebApplication
26
- },
27
- typeOf: factory.actionType.InformAction
26
+ }
27
+ // typeOf: factory.actionType.InformAction
28
28
  };
29
29
  return {
30
30
  project: order.project,
@@ -19,16 +19,16 @@ function createInformTasks(params) {
19
19
  informTasks = informOrder.map((informOrderParams) => {
20
20
  var _a, _b;
21
21
  const informActionAttributes = {
22
- agent: order.project,
22
+ // agent: order.project,
23
23
  object: order4inform,
24
- project: order.project,
24
+ // project: order.project,
25
25
  recipient: {
26
26
  url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
27
27
  id: recipientId,
28
28
  name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
29
29
  typeOf: factory.creativeWorkType.WebApplication
30
- },
31
- typeOf: factory.actionType.InformAction
30
+ }
31
+ // typeOf: factory.actionType.InformAction
32
32
  };
33
33
  return {
34
34
  project: order.project,
@@ -17,16 +17,16 @@ function createInformTasks(order) {
17
17
  informTasks = informOrder.map((informOrderParams) => {
18
18
  var _a, _b;
19
19
  const informActionAttributes = {
20
- agent: order.project,
20
+ // agent: order.project,
21
21
  object: order4inform,
22
- project: order.project,
22
+ // project: order.project,
23
23
  recipient: {
24
24
  url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
25
25
  id: recipientId,
26
26
  name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
27
27
  typeOf: factory.creativeWorkType.WebApplication
28
- },
29
- typeOf: factory.actionType.InformAction
28
+ }
29
+ // typeOf: factory.actionType.InformAction
30
30
  };
31
31
  return {
32
32
  project: order.project,
@@ -19,16 +19,16 @@ function createInformTasks(order) {
19
19
  informTasks = informOrder.map((informOrderParams) => {
20
20
  var _a, _b;
21
21
  const informActionAttributes = {
22
- agent: order.project,
22
+ // agent: order.project,
23
23
  object: order4inform,
24
- project: order.project,
24
+ // project: order.project,
25
25
  recipient: {
26
26
  url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
27
27
  id: recipientId,
28
28
  name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
29
29
  typeOf: factory.creativeWorkType.WebApplication
30
- },
31
- typeOf: factory.actionType.InformAction
30
+ }
31
+ // typeOf: factory.actionType.InformAction
32
32
  };
33
33
  return {
34
34
  project: order.project,
@@ -14,16 +14,16 @@ function createInformTasks(order) {
14
14
  informTasks = informOrder.map((informOrderParams) => {
15
15
  var _a, _b;
16
16
  const informActionAttributes = {
17
- agent: order.project,
17
+ // agent: order.project,
18
18
  object: order4inform,
19
- project: order.project,
19
+ // project: order.project,
20
20
  recipient: {
21
21
  url: (_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url,
22
22
  id: recipientId,
23
23
  name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name,
24
24
  typeOf: factory.creativeWorkType.WebApplication
25
- },
26
- typeOf: factory.actionType.InformAction
25
+ }
26
+ // typeOf: factory.actionType.InformAction
27
27
  };
28
28
  return {
29
29
  project: order.project,
@@ -12,7 +12,5 @@ declare function onPaid(payAction: factory.action.trade.pay.IAction): (repos: {
12
12
  action: ActionRepo;
13
13
  accountingReport: AccountingReportRepo;
14
14
  task: TaskRepo;
15
- }) => Promise<{
16
- id: string;
17
- }[]>;
15
+ }) => Promise<void>;
18
16
  export { onPaid };
@@ -32,21 +32,24 @@ function onPaid(payAction) {
32
32
  }
33
33
  const informPayment = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.informPayment;
34
34
  if (Array.isArray(informPayment)) {
35
- taskAttributes.push(...informPayment.map((a) => {
35
+ taskAttributes.push(...informPayment.map(({ purpose, recipient }) => {
36
36
  return {
37
- project: a.project,
37
+ project: payAction.project,
38
38
  name: factory.taskName.TriggerWebhook,
39
39
  status: factory.taskStatus.Ready,
40
40
  runsAt: now,
41
41
  remainingNumberOfTries: 30,
42
42
  numberOfTried: 0,
43
43
  executionResults: [],
44
- data: Object.assign(Object.assign({}, a), { object: aciton4inform })
44
+ data: Object.assign({
45
+ // optimize(2024-07-01~)
46
+ // ...a,
47
+ recipient, object: aciton4inform }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined)
45
48
  };
46
49
  }));
47
50
  }
48
51
  // タスク保管
49
- return repos.task.saveMany(taskAttributes, { emitImmediately: true });
52
+ yield repos.task.saveMany(taskAttributes, { emitImmediately: true });
50
53
  });
51
54
  }
52
55
  exports.onPaid = onPaid;
@@ -90,16 +90,19 @@ function onRefund(refundAction) {
90
90
  }
91
91
  }
92
92
  if (Array.isArray(informPayment)) {
93
- taskAttributes.push(...informPayment.map((a) => {
93
+ taskAttributes.push(...informPayment.map(({ purpose, recipient }) => {
94
94
  return {
95
- project: a.project,
95
+ project: refundAction.project,
96
96
  name: factory.taskName.TriggerWebhook,
97
97
  status: factory.taskStatus.Ready,
98
98
  runsAt: now,
99
99
  remainingNumberOfTries: 30,
100
100
  numberOfTried: 0,
101
101
  executionResults: [],
102
- data: Object.assign(Object.assign({}, a), { object: aciton4inform })
102
+ data: Object.assign({
103
+ // optimize(2024-07-01~)
104
+ // ...a,
105
+ recipient, object: aciton4inform }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined)
103
106
  };
104
107
  }));
105
108
  }
@@ -140,17 +140,15 @@ function createInformPaymentActions(params) {
140
140
  : String(transaction.agent.id),
141
141
  url: String((_c = a.recipient) === null || _c === void 0 ? void 0 : _c.url)
142
142
  };
143
+ // optimize(2024-07-01~)
143
144
  return {
144
- project: transaction.project,
145
- typeOf: factory.actionType.InformAction,
146
- agent: transaction.project,
145
+ // project: transaction.project,
146
+ // typeOf: factory.actionType.InformAction,
147
+ // agent: transaction.project,
147
148
  recipient,
148
149
  // 実際にタスクが生成される直前にactionに置き換える
149
- object: {},
150
- purpose: {
151
- typeOf: transaction.typeOf,
152
- id: transaction.id
153
- }
150
+ // object: {},
151
+ purpose: { typeOf: transaction.typeOf, id: transaction.id }
154
152
  };
155
153
  }));
156
154
  }
@@ -60,6 +60,8 @@ export interface IReservation4informUsed {
60
60
  }
61
61
  export type IReservation4inform = IReservationPackage4informConfirmed | IReservation4informCanceled | IReservation4informCheckedIn | IReservation4informUsed;
62
62
  export type IInformObject = IReservation4inform[];
63
- export type InformReservationActionattributes = factory.action.interact.inform.IAttributes<IInformObject, any>;
63
+ export interface IPotentialInformReservationAction extends factory.task.triggerWebhook.IPotentialInformAction {
64
+ object: IInformObject;
65
+ }
64
66
  export declare const NUM_TRY_INFORM_RESERVATION: number;
65
67
  export {};
@@ -55,16 +55,16 @@ reservationFor) {
55
55
  var _a;
56
56
  const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
57
57
  const informReservationAttributes = {
58
- agent: project,
58
+ // agent: project,
59
59
  object: reservations4inform,
60
- project,
60
+ // project,
61
61
  recipient: {
62
62
  id: '',
63
63
  name: informUrl,
64
64
  typeOf: factory.creativeWorkType.WebApplication,
65
65
  url: informUrl
66
- },
67
- typeOf: factory.actionType.InformAction
66
+ }
67
+ // typeOf: factory.actionType.InformAction
68
68
  };
69
69
  return {
70
70
  project,
@@ -42,16 +42,16 @@ function onReservationCheckedIn(params) {
42
42
  };
43
43
  });
44
44
  const informReservationAttributes = {
45
- agent: project,
45
+ // agent: project,
46
46
  object: reservations4inform,
47
- project,
47
+ // project,
48
48
  recipient: {
49
49
  id: '',
50
50
  name: informUrl,
51
51
  typeOf: factory.creativeWorkType.WebApplication,
52
52
  url: informUrl
53
- },
54
- typeOf: factory.actionType.InformAction
53
+ }
54
+ // typeOf: factory.actionType.InformAction
55
55
  };
56
56
  const informReservationTask = {
57
57
  project,
@@ -76,16 +76,16 @@ function onReservationCheckedIn(params) {
76
76
  };
77
77
  });
78
78
  const informReservationAttributes = {
79
- agent: project,
79
+ // agent: project,
80
80
  object: reservations4inform,
81
- project,
81
+ // project,
82
82
  recipient: {
83
83
  id: '',
84
84
  name: informUrl,
85
85
  typeOf: factory.creativeWorkType.WebApplication,
86
86
  url: informUrl
87
- },
88
- typeOf: factory.actionType.InformAction
87
+ }
88
+ // typeOf: factory.actionType.InformAction
89
89
  };
90
90
  const informReservationTask = {
91
91
  project,
@@ -86,16 +86,16 @@ function onReservationConfirmed(confirmedReservations) {
86
86
  : undefined)];
87
87
  const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
88
88
  const informReservationAttributes = {
89
- agent: project,
89
+ // agent: project,
90
90
  object: informObject,
91
- project,
91
+ // project,
92
92
  recipient: {
93
93
  id: '',
94
94
  name: informUrl,
95
95
  typeOf: factory.creativeWorkType.WebApplication,
96
96
  url: informUrl
97
- },
98
- typeOf: factory.actionType.InformAction
97
+ }
98
+ // typeOf: factory.actionType.InformAction
99
99
  };
100
100
  return {
101
101
  project,
@@ -42,16 +42,16 @@ function onReservationUsed(attendedReservation) {
42
42
  var _a;
43
43
  const informUrl = String((_a = informReservation.recipient) === null || _a === void 0 ? void 0 : _a.url);
44
44
  const informReservationAttributes = {
45
- agent: attendedReservation.project,
45
+ // agent: attendedReservation.project,
46
46
  object: [reservation4inform],
47
- project: attendedReservation.project,
47
+ // project: attendedReservation.project,
48
48
  recipient: {
49
49
  id: '',
50
50
  name: informUrl,
51
51
  typeOf: factory.creativeWorkType.WebApplication,
52
52
  url: informUrl
53
- },
54
- typeOf: factory.actionType.InformAction
53
+ }
54
+ // typeOf: factory.actionType.InformAction
55
55
  };
56
56
  return {
57
57
  project: attendedReservation.project,
@@ -33,16 +33,16 @@ function createInformOfferTasks(params) {
33
33
  offers4inform.forEach((offer4inform) => {
34
34
  var _a;
35
35
  const informActionAttributes = {
36
- agent: { id: params.project.id, typeOf: factory.organizationType.Project },
36
+ // agent: { id: params.project.id, typeOf: factory.organizationType.Project },
37
37
  object: offer4inform,
38
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
38
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
39
39
  recipient: {
40
40
  id: '',
41
41
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
42
42
  typeOf: factory.creativeWorkType.WebApplication,
43
43
  url: informUrl
44
- },
45
- typeOf: factory.actionType.InformAction
44
+ }
45
+ // typeOf: factory.actionType.InformAction
46
46
  };
47
47
  informTasks.push({
48
48
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
@@ -48,16 +48,16 @@ function createInformHasPOSTasks(params) {
48
48
  movieTheaters4inform.forEach((movieTheater4inform) => {
49
49
  var _a;
50
50
  const informActionAttributes = {
51
- agent: { id: params.project.id, typeOf: factory.organizationType.Project },
51
+ // agent: { id: params.project.id, typeOf: factory.organizationType.Project },
52
52
  object: movieTheater4inform,
53
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
53
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
54
54
  recipient: {
55
55
  id: '',
56
56
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
57
57
  typeOf: factory.creativeWorkType.WebApplication,
58
58
  url: informUrl
59
- },
60
- typeOf: factory.actionType.InformAction
59
+ }
60
+ // typeOf: factory.actionType.InformAction
61
61
  };
62
62
  informTasks.push({
63
63
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
@@ -38,16 +38,16 @@ function createInformOfferCatalogTasks(params) {
38
38
  offerCatalogs4inform.forEach((offerCatalog4inform) => {
39
39
  var _a;
40
40
  const informActionAttributes = {
41
- agent: { id: params.project.id, typeOf: factory.organizationType.Project },
41
+ // agent: { id: params.project.id, typeOf: factory.organizationType.Project },
42
42
  object: offerCatalog4inform,
43
- project: { id: params.project.id, typeOf: factory.organizationType.Project },
43
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
44
44
  recipient: {
45
45
  id: '',
46
46
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
47
47
  typeOf: factory.creativeWorkType.WebApplication,
48
48
  url: informUrl
49
- },
50
- typeOf: factory.actionType.InformAction
49
+ }
50
+ // typeOf: factory.actionType.InformAction
51
51
  };
52
52
  informTasks.push({
53
53
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
@@ -197,16 +197,16 @@ function createInformNoteTasks(params) {
197
197
  const { about, id, identifier, project, text, typeOf, version } = note4inform;
198
198
  const informObject = { about, id, identifier, project, text, typeOf, version }; // 明示的に必要最低限の属性のみ通知
199
199
  const informActionAttributes = {
200
- agent: project,
200
+ // agent: project,
201
201
  object: informObject,
202
- project: project,
202
+ // project: project,
203
203
  recipient: {
204
204
  id: '',
205
205
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
206
206
  typeOf: factory.creativeWorkType.WebApplication,
207
207
  url: informUrl
208
- },
209
- typeOf: factory.actionType.InformAction
208
+ }
209
+ // typeOf: factory.actionType.InformAction
210
210
  };
211
211
  informTasks.push({
212
212
  project: project,
@@ -243,16 +243,16 @@ function createInformMovieTasks(params) {
243
243
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
244
244
  delete movie4inform._id;
245
245
  const informActionAttributes = {
246
- agent: movie4inform.project,
246
+ // agent: movie4inform.project,
247
247
  object: movie4inform,
248
- project: movie4inform.project,
248
+ // project: movie4inform.project,
249
249
  recipient: {
250
250
  id: '',
251
251
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
252
252
  typeOf: factory.creativeWorkType.WebApplication,
253
253
  url: informUrl
254
- },
255
- typeOf: factory.actionType.InformAction
254
+ }
255
+ // typeOf: factory.actionType.InformAction
256
256
  };
257
257
  informTasks.push({
258
258
  project: movie4inform.project,
@@ -289,16 +289,16 @@ function createInformProductTasks(params) {
289
289
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
290
290
  delete product4inform._id;
291
291
  const informActionAttributes = {
292
- agent: product4inform.project,
292
+ // agent: product4inform.project,
293
293
  object: product4inform,
294
- project: product4inform.project,
294
+ // project: product4inform.project,
295
295
  recipient: {
296
296
  id: '',
297
297
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
298
298
  typeOf: factory.creativeWorkType.WebApplication,
299
299
  url: informUrl
300
- },
301
- typeOf: factory.actionType.InformAction
300
+ }
301
+ // typeOf: factory.actionType.InformAction
302
302
  };
303
303
  informTasks.push({
304
304
  project: product4inform.project,
@@ -336,16 +336,16 @@ function createInformCategoryCodeTasks(params) {
336
336
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
337
337
  delete categoryCode4inform._id;
338
338
  const informActionAttributes = {
339
- agent: categoryCode4inform.project,
339
+ // agent: categoryCode4inform.project,
340
340
  object: categoryCode4inform,
341
- project: categoryCode4inform.project,
341
+ // project: categoryCode4inform.project,
342
342
  recipient: {
343
343
  id: '',
344
344
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
345
345
  typeOf: factory.creativeWorkType.WebApplication,
346
346
  url: informUrl
347
- },
348
- typeOf: factory.actionType.InformAction
347
+ }
348
+ // typeOf: factory.actionType.InformAction
349
349
  };
350
350
  informTasks.push({
351
351
  project: categoryCode4inform.project,
@@ -416,16 +416,16 @@ function createInformMovieTheaterTasks(params) {
416
416
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
417
417
  delete movieTheater4inform._id;
418
418
  const informActionAttributes = {
419
- agent: movieTheater4inform.project,
419
+ // agent: movieTheater4inform.project,
420
420
  object: movieTheater4inform,
421
- project: movieTheater4inform.project,
421
+ // project: movieTheater4inform.project,
422
422
  recipient: {
423
423
  id: '',
424
424
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
425
425
  typeOf: factory.creativeWorkType.WebApplication,
426
426
  url: informUrl
427
- },
428
- typeOf: factory.actionType.InformAction
427
+ }
428
+ // typeOf: factory.actionType.InformAction
429
429
  };
430
430
  informTasks.push({
431
431
  project: movieTheater4inform.project,
@@ -480,16 +480,16 @@ function createInformAccountTitleTasks(params) {
480
480
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
481
481
  delete accountTitle4inform._id;
482
482
  const informActionAttributes = {
483
- agent: accountTitle4inform.project,
483
+ // agent: accountTitle4inform.project,
484
484
  object: accountTitle4inform,
485
- project: accountTitle4inform.project,
485
+ // project: accountTitle4inform.project,
486
486
  recipient: {
487
487
  id: '',
488
488
  name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
489
489
  typeOf: factory.creativeWorkType.WebApplication,
490
490
  url: informUrl
491
- },
492
- typeOf: factory.actionType.InformAction
491
+ }
492
+ // typeOf: factory.actionType.InformAction
493
493
  };
494
494
  informTasks.push({
495
495
  project: accountTitle4inform.project,
@@ -1,6 +1,6 @@
1
- import type { IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
6
- export declare function call(data: factory.task.triggerWebhook.IData): IOperationExecute<void>;
6
+ export declare function call(params: Pick<factory.task.triggerWebhook.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
@@ -12,13 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
13
  const settings_1 = require("../../settings");
14
14
  const action_1 = require("../../repo/action");
15
- const NotificationService = require("../notification");
15
+ const notification_1 = require("../notification");
16
16
  /**
17
17
  * タスク実行関数
18
18
  */
19
- function call(data) {
19
+ function call(params) {
20
20
  return (settings) => __awaiter(this, void 0, void 0, function* () {
21
- yield NotificationService.triggerWebhook(data)({
21
+ yield (0, notification_1.triggerWebhook)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id } }))({
22
22
  action: new action_1.MongoRepository(settings.connection),
23
23
  useFetchAPI: settings_1.USE_FETCH_API
24
24
  });
@@ -116,6 +116,7 @@ function execute(task) {
116
116
  case factory.taskName.ReturnPayTransaction:
117
117
  case factory.taskName.ReturnReserveTransaction:
118
118
  case factory.taskName.SendEmailMessage:
119
+ case factory.taskName.TriggerWebhook:
119
120
  callResult = yield call(task)(settings, options);
120
121
  break;
121
122
  default:
@@ -25,10 +25,8 @@ function createTasks(params) {
25
25
  executionResults: [],
26
26
  data: {
27
27
  agent: transaction.project,
28
- // 通知内容最適化(2022-12-28~)
29
28
  object: informObject,
30
29
  project: transaction.project,
31
- purpose: { typeOf: transaction.typeOf, id: transaction.id },
32
30
  recipient: {
33
31
  id: '',
34
32
  name: webhookUrl,
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.377.0-alpha.2",
13
+ "@chevre/factory": "4.377.0-alpha.3",
14
14
  "@cinerino/sdk": "8.0.0",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.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.37.0-alpha.2"
113
+ "version": "21.37.0-alpha.4"
114
114
  }