@chevre/domain 21.34.0-alpha.1 → 21.34.0-alpha.3

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 (31) hide show
  1. package/example/src/chevre/{deleteOwnershipInfosByWebApplication.ts → deleteOwnershipInfosByOwnedThrough.ts} +21 -22
  2. package/example/src/chevre/findCheckAction.ts +2 -5
  3. package/example/src/chevre/migratePayCreditCardRecipes.ts +8 -2
  4. package/example/src/chevre/migratePayMovieTicketRecipes.ts +8 -2
  5. package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +8 -1
  6. package/example/src/chevre/saveRecipe.ts +54 -0
  7. package/example/src/chevre/unsetUnnecessaryFields.ts +26 -14
  8. package/lib/chevre/repo/action.d.ts +33 -9
  9. package/lib/chevre/repo/action.js +92 -15
  10. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +2 -1
  11. package/lib/chevre/service/assetTransaction/pay.js +1 -3
  12. package/lib/chevre/service/assetTransaction/reserveCOA/factory.d.ts +0 -4
  13. package/lib/chevre/service/assetTransaction/reserveCOA/factory.js +1 -2
  14. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.d.ts +0 -4
  15. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer/factory.js +1 -2
  16. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -2
  17. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -1
  18. package/lib/chevre/service/payment/any.d.ts +2 -8
  19. package/lib/chevre/service/payment/any.js +5 -22
  20. package/lib/chevre/service/payment/creditCard/factory.d.ts +0 -8
  21. package/lib/chevre/service/payment/creditCard/factory.js +2 -4
  22. package/lib/chevre/service/payment/creditCard/payCreditCard.js +1 -2
  23. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +1 -2
  24. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +4 -4
  25. package/lib/chevre/service/payment/movieTicket/factory.d.ts +0 -12
  26. package/lib/chevre/service/payment/movieTicket/factory.js +3 -7
  27. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +6 -4
  28. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +29 -8
  29. package/lib/chevre/service/payment/movieTicket/validation.js +18 -6
  30. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -2
  31. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
1
  // tslint:disable:no-console
2
+ import * as moment from 'moment';
2
3
  import * as mongoose from 'mongoose';
3
4
 
4
5
  import { chevre } from '../../../lib/index';
@@ -11,9 +12,15 @@ async function main() {
11
12
 
12
13
  const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
13
14
 
15
+ const ownedThroughLt = moment()
16
+ .add(-1, 'year')
17
+ .toDate();
14
18
  const cursor = ownershipInfoRepo.getCursor(
15
19
  {
16
- 'ownedBy.typeOf': { $eq: chevre.factory.creativeWorkType.WebApplication }
20
+ ownedThrough: {
21
+ $exists: true,
22
+ $lt: ownedThroughLt
23
+ }
17
24
  },
18
25
  {
19
26
  }
@@ -31,42 +38,34 @@ async function main() {
31
38
 
32
39
  let noNeedToDelete = true;
33
40
  let ownedById: string | undefined;
34
- let ownedByTypeOf: string;
35
- if (Array.isArray(ownershipInfo.ownedBy)) {
36
- ownedByTypeOf = ownershipInfo.ownedBy[0].typeOf;
37
- if (ownershipInfo.ownedBy.every(({ typeOf }) => typeOf === chevre.factory.creativeWorkType.WebApplication)) {
38
- noNeedToDelete = false;
39
- ownedById = ownershipInfo.ownedBy[0].id;
40
- }
41
- } else {
42
- ownedByTypeOf = ownershipInfo.ownedBy.typeOf;
43
- if (ownershipInfo.ownedBy.typeOf === chevre.factory.creativeWorkType.WebApplication) {
44
- noNeedToDelete = false;
45
- ownedById = ownershipInfo.ownedBy.id;
46
- }
41
+ if (ownershipInfo.ownedThrough instanceof Date
42
+ && moment(ownedThroughLt)
43
+ .isAfter(moment(ownershipInfo.ownedThrough))) {
44
+ noNeedToDelete = false;
45
+ ownedById = (Array.isArray(ownershipInfo.ownedBy)) ? ownershipInfo.ownedBy[0].id : ownershipInfo.ownedBy.id;
47
46
  }
48
47
 
49
48
  if (noNeedToDelete) {
50
49
  console.log(
51
50
  'noNeedToDelete.',
52
- ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownedByTypeOf, ownershipInfo.ownedFrom,
51
+ ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownershipInfo.ownedFrom, ownershipInfo.ownedThrough,
53
52
  i, updateCount);
54
53
  } else {
55
54
  console.log(
56
55
  'deleting...',
57
- ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownedByTypeOf, ownershipInfo.ownedFrom,
56
+ ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownershipInfo.ownedFrom, ownershipInfo.ownedThrough,
58
57
  i, updateCount);
59
58
  if (typeof ownedById === 'string') {
60
- await ownershipInfoRepo.deleteByIdAndOwnedById({
61
- project: { id: ownershipInfo.project.id },
62
- id: ownershipInfo.id,
63
- ownedBy: { id: ownedById }
64
- });
59
+ // await ownershipInfoRepo.deleteByIdAndOwnedById({
60
+ // project: { id: ownershipInfo.project.id },
61
+ // id: ownershipInfo.id,
62
+ // ownedBy: { id: ownedById }
63
+ // });
65
64
  }
66
65
  updateCount += 1;
67
66
  console.log(
68
67
  'deleted.',
69
- ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownedByTypeOf, ownershipInfo.ownedFrom,
68
+ ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownershipInfo.ownedFrom, ownershipInfo.ownedThrough,
70
69
  i, updateCount);
71
70
  }
72
71
  });
@@ -16,13 +16,10 @@ async function main() {
16
16
  id: project.id
17
17
  },
18
18
  sameAs: {
19
- id: '664db85f9801179aabb046e5'
19
+ id: '666627d5e7fdb1e29d985675'
20
20
  },
21
21
  purpose: {
22
- id: '664db8219801179aabb04624'
23
- },
24
- options: {
25
- minimize: true
22
+ id: '666627c6e7fdb1e29d985646'
26
23
  }
27
24
  })({
28
25
  action: actionRepo,
@@ -15,7 +15,7 @@ async function main() {
15
15
  startDate: {
16
16
  $gte: moment()
17
17
  // tslint:disable-next-line:no-magic-numbers
18
- .add(-180, 'days')
18
+ .add(-30, 'days')
19
19
  },
20
20
  'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
21
21
  },
@@ -53,7 +53,11 @@ async function main() {
53
53
  throw new Error('alterTranResultByPayAction undefined');
54
54
  }
55
55
 
56
- const recipe: chevre.factory.action.trade.pay.IPayCreditCardRecipe & { dateCreated: Date } = {
56
+ const recipe: chevre.factory.action.trade.pay.IPayCreditCardRecipe & {
57
+ recipeFor: { id: string; typeOf: chevre.factory.actionType };
58
+ dateCreated: Date;
59
+ dateModified: Date;
60
+ } = {
57
61
  project: { id: payAction.project.id, typeOf: chevre.factory.organizationType.Project },
58
62
  typeOf: 'Recipe',
59
63
  recipeCategory: chevre.factory.recipe.RecipeCategory.payCreditCard,
@@ -82,6 +86,8 @@ async function main() {
82
86
  ]
83
87
  }],
84
88
  dateCreated: moment(payAction.endDate)
89
+ .toDate(),
90
+ dateModified: moment(payAction.endDate)
85
91
  .toDate()
86
92
  };
87
93
  console.log(
@@ -15,7 +15,7 @@ async function main() {
15
15
  startDate: {
16
16
  $gte: moment()
17
17
  // tslint:disable-next-line:no-magic-numbers
18
- .add(-180, 'days')
18
+ .add(-30, 'days')
19
19
  },
20
20
  'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
21
21
  },
@@ -58,7 +58,11 @@ async function main() {
58
58
  throw new Error('seatInfoSyncResultByPayAction undefined');
59
59
  }
60
60
 
61
- const recipe: chevre.factory.action.trade.pay.IPayMovieTicketRecipe & { dateCreated: Date } = {
61
+ const recipe: chevre.factory.action.trade.pay.IPayMovieTicketRecipe & {
62
+ recipeFor: { id: string; typeOf: chevre.factory.actionType };
63
+ dateCreated: Date;
64
+ dateModified: Date;
65
+ } = {
62
66
  project: { id: payAction.project.id, typeOf: chevre.factory.organizationType.Project },
63
67
  typeOf: 'Recipe',
64
68
  recipeCategory: chevre.factory.recipe.RecipeCategory.payMovieTicket,
@@ -78,6 +82,8 @@ async function main() {
78
82
  ]
79
83
  }],
80
84
  dateCreated: moment(payAction.endDate)
85
+ .toDate(),
86
+ dateModified: moment(payAction.endDate)
81
87
  .toDate()
82
88
  };
83
89
  console.log(
@@ -38,6 +38,7 @@ async function main() {
38
38
  let i = 0;
39
39
  let updateCount = 0;
40
40
  let saveRecipeCount = 0;
41
+ // tslint:disable-next-line:max-func-body-length
41
42
  await cursor.eachAsync(async (doc) => {
42
43
  i += 1;
43
44
  const placeOrder: Pick<
@@ -92,7 +93,11 @@ async function main() {
92
93
  updateCount += 1;
93
94
  }
94
95
  } else {
95
- const recipe: chevre.factory.action.accept.pay.IRecipe & { dateCreated: Date } = {
96
+ const recipe: chevre.factory.action.accept.pay.IRecipe & {
97
+ recipeFor: { id: string; typeOf: chevre.factory.actionType };
98
+ dateCreated: Date;
99
+ dateModified: Date;
100
+ } = {
96
101
  project: { id: placeOrder.project.id, typeOf: chevre.factory.organizationType.Project },
97
102
  typeOf: 'Recipe',
98
103
  recipeCategory: chevre.factory.recipe.RecipeCategory.publishPaymentUrl,
@@ -121,6 +126,8 @@ async function main() {
121
126
  ]
122
127
  }],
123
128
  dateCreated: moment(acceptPayAction.endDate)
129
+ .toDate(),
130
+ dateModified: moment(acceptPayAction.endDate)
124
131
  .toDate()
125
132
  };
126
133
  console.log(
@@ -0,0 +1,54 @@
1
+ // tslint:disable:no-console
2
+ // import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const now = new Date();
13
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
14
+ const recipe: chevre.factory.action.trade.pay.IPayCreditCardRecipe & {
15
+ recipeFor: { id: string; typeOf: chevre.factory.actionType };
16
+ dateCreated: Date;
17
+ dateModified: Date;
18
+ } = {
19
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
20
+ typeOf: 'Recipe',
21
+ recipeCategory: chevre.factory.recipe.RecipeCategory.payCreditCard,
22
+ recipeFor: { id: 'xxxx', typeOf: chevre.factory.actionType.PayAction },
23
+ step: [{
24
+ typeOf: 'HowToSection',
25
+ itemListElement: [
26
+ {
27
+ typeOf: 'HowToStep',
28
+ identifier: chevre.factory.recipe.StepIdentifier.searchTrade,
29
+ itemListElement: [{
30
+ typeOf: 'HowToDirection'
31
+ // beforeMedia: (<any>paymentMethodsByTransaction).entryTranArgs,
32
+ // afterMedia: (<any>paymentMethodsByTransaction).entryTranResult
33
+ }]
34
+ },
35
+ {
36
+ typeOf: 'HowToStep',
37
+ identifier: chevre.factory.recipe.StepIdentifier.alterTran,
38
+ itemListElement: [{
39
+ typeOf: 'HowToDirection'
40
+ // beforeMedia: (<any>paymentMethodsByTransaction).execTranArgs,
41
+ }]
42
+ }
43
+ ]
44
+ }],
45
+ dateCreated: now,
46
+ dateModified: now
47
+ };
48
+ const result = await actionRepo.saveRecipeWithDateCreated(recipe);
49
+ console.log(result);
50
+ }
51
+
52
+ main()
53
+ .then()
54
+ .catch(console.error);
@@ -4,28 +4,40 @@ import * as mongoose from 'mongoose';
4
4
 
5
5
  import { chevre } from '../../../lib/index';
6
6
 
7
+ const DAYS = 180;
7
8
  async function main() {
8
9
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
10
 
11
+ const now = new Date();
10
12
  let updateResult: any;
11
13
 
12
14
  const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
13
15
 
14
- updateResult = await assetTransactionRepo.unsetUnnecessaryFields({
15
- filter: {
16
- startDate: {
17
- $gte: moment()
18
- .add(-1, 'days')
19
- .toDate()
16
+ // tslint:disable-next-line:no-magic-numbers
17
+ const hours = DAYS * 24;
18
+ // tslint:disable-next-line:no-increment-decrement no-magic-numbers
19
+ for (let index = 0; index < hours; index++) {
20
+ updateResult = await assetTransactionRepo.unsetUnnecessaryFields({
21
+ filter: {
22
+ startDate: {
23
+ $gte: moment(now)
24
+ .add(-(index + 1), 'hours')
25
+ .toDate(),
26
+ $lt: moment(now)
27
+ .add(-index, 'hours')
28
+ .toDate()
29
+ }
30
+ },
31
+ $unset: {
32
+ __v: 1,
33
+ createdAt: 1,
34
+ updatedAt: 1
20
35
  }
21
- },
22
- $unset: {
23
- __v: 1,
24
- createdAt: 1,
25
- updatedAt: 1
26
- }
27
- });
28
- console.log('unset processed.', updateResult);
36
+ });
37
+ console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
38
+ }
39
+
40
+ console.log(DAYS, 'days processed');
29
41
  }
30
42
 
31
43
  main()
@@ -23,7 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import { factory as surfrockFactory } from '@surfrock/sdk';
26
- import { Connection, FilterQuery } from 'mongoose';
26
+ import { Connection, FilterQuery, QueryOptions } from 'mongoose';
27
27
  import * as factory from '../factory';
28
28
  export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
29
29
  export type IPayAction = factory.action.trade.pay.IAction;
@@ -60,6 +60,18 @@ export interface ICancelActionAction {
60
60
  };
61
61
  }
62
62
  export type IActionRecipe<T extends factory.recipe.RecipeCategory> = T extends factory.recipe.RecipeCategory.checkMovieTicket ? factory.action.check.paymentMethod.movieTicket.IRecipe : T extends factory.recipe.RecipeCategory.payCreditCard ? factory.action.trade.pay.IPayCreditCardRecipe : T extends factory.recipe.RecipeCategory.payMovieTicket ? factory.action.trade.pay.IPayMovieTicketRecipe : T extends factory.recipe.RecipeCategory.publishPaymentUrl ? factory.action.accept.pay.IRecipe : T extends factory.recipe.RecipeCategory.refundCreditCard ? factory.action.trade.refund.IRefundCreditCardRecipe : T extends factory.recipe.RecipeCategory.refundMovieTicket ? factory.action.trade.refund.IRefundMovieTicketRecipe : T extends factory.recipe.RecipeCategory.acceptCOAOffer ? factory.action.accept.coaOffer.IRecipe : T extends factory.recipe.RecipeCategory.confirmCOAReserve ? factory.action.interact.confirm.reservation.IConfirmCOAReserveRecipe : never;
63
+ export type IRecipeAsDocument = factory.recipe.IRecipe & {
64
+ recipeFor: {
65
+ id: string;
66
+ typeOf: factory.actionType;
67
+ };
68
+ dateCreated: Date;
69
+ dateModified?: Date;
70
+ };
71
+ export type IRecipeAsActionAttributes = Pick<factory.recipe.IRecipe, 'project' | 'recipeCategory' | 'step' | 'typeOf'>;
72
+ export type IMinimizedPurchaseNumberAuthResult = Pick<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult, 'mkknmiNumSum' | 'resultInfo' | 'ykknmiNumSum'> & {
73
+ knyknrNoInfoOut: Omit<factory.action.check.paymentMethod.movieTicket.IPurchaseNumberInfo, 'ykknInfo' | 'mkknInfo'>[] | null;
74
+ };
63
75
  /**
64
76
  * アクションリポジトリ
65
77
  */
@@ -75,7 +87,9 @@ export declare class MongoRepository {
75
87
  /**
76
88
  * アクション開始
77
89
  */
78
- start<T extends factory.actionType>(attributes: factory.action.IAttributes<T, any, any>): Promise<IAction<T>>;
90
+ start<T extends factory.actionType>(attributes: factory.action.IAttributes<T, any, any>, options?: {
91
+ recipe?: IRecipeAsActionAttributes;
92
+ }): Promise<IAction<T>>;
79
93
  /**
80
94
  * アクション完了
81
95
  */
@@ -83,13 +97,13 @@ export declare class MongoRepository {
83
97
  typeOf: T;
84
98
  id: string;
85
99
  result: any;
86
- recipe?: factory.recipe.IRecipe;
100
+ recipe?: IRecipeAsActionAttributes;
87
101
  }): Promise<IAction<T>>;
88
102
  completeWithVoid(params: {
89
103
  typeOf: factory.actionType;
90
104
  id: string;
91
105
  result: any;
92
- recipe?: factory.recipe.IRecipe;
106
+ recipe?: IRecipeAsActionAttributes;
93
107
  }): Promise<void>;
94
108
  /**
95
109
  * アクション取消
@@ -119,7 +133,9 @@ export declare class MongoRepository {
119
133
  * アクション再開
120
134
  */
121
135
  reStart(params: {
136
+ typeOf: factory.actionType;
122
137
  id: string;
138
+ recipe?: IRecipeAsActionAttributes;
123
139
  }): Promise<void>;
124
140
  /**
125
141
  * 一定期間ActiveActionStatusのアクションをFailedActionStatusにする
@@ -316,9 +332,9 @@ export declare class MongoRepository {
316
332
  }): Promise<{
317
333
  deletedCount?: number;
318
334
  } | null>;
319
- saveRecipeWithDateCreated(savingRecipe: factory.recipe.IRecipe & {
320
- dateCreated: Date;
321
- }): Promise<import("mongodb").InsertManyResult<any>>;
335
+ saveRecipeWithDateCreated(savingRecipe: IRecipeAsDocument & {
336
+ dateModified: Date;
337
+ }): Promise<import("mongodb").UpdateResult>;
322
338
  findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: {
323
339
  project: {
324
340
  id: string;
@@ -327,6 +343,14 @@ export declare class MongoRepository {
327
343
  id: string;
328
344
  };
329
345
  }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>;
346
+ findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe(params: {
347
+ project: {
348
+ id: string;
349
+ };
350
+ recipeFor: {
351
+ id: string;
352
+ };
353
+ }): Promise<IMinimizedPurchaseNumberAuthResult | undefined>;
330
354
  aggregateAuthorizeEventServiceOfferAction(params: {
331
355
  project?: {
332
356
  id?: {
@@ -397,7 +421,7 @@ export declare class MongoRepository {
397
421
  startFrom: Date;
398
422
  startThrough: Date;
399
423
  }): Promise<IAggregateAction>;
400
- getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
424
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, QueryOptions<any>>;
401
425
  unsetUnnecessaryFields(params: {
402
426
  filter: FilterQuery<factory.action.IAction<factory.action.IAttributes<factory.actionType, any, any>>>;
403
427
  $unset: any;
@@ -417,6 +441,6 @@ export declare class MongoRepository {
417
441
  };
418
442
  }): Promise<void>;
419
443
  private agggregateByStatus;
420
- private saveRecipe;
444
+ private upsertRecipe;
421
445
  }
422
446
  export {};
@@ -459,10 +459,16 @@ class MongoRepository {
459
459
  /**
460
460
  * アクション開始
461
461
  */
462
- start(attributes) {
462
+ start(attributes, options) {
463
463
  return __awaiter(this, void 0, void 0, function* () {
464
- return this.actionModel.create(Object.assign(Object.assign({}, attributes), { actionStatus: factory.actionStatusType.ActiveActionStatus, startDate: new Date() }))
464
+ const startedAction = yield this.actionModel.create(Object.assign(Object.assign({}, attributes), { actionStatus: factory.actionStatusType.ActiveActionStatus, startDate: new Date() }))
465
465
  .then((doc) => doc.toObject());
466
+ // add recipe(2024-06-09~)
467
+ const savingRecipe = options === null || options === void 0 ? void 0 : options.recipe;
468
+ if ((savingRecipe === null || savingRecipe === void 0 ? void 0 : savingRecipe.typeOf) === 'Recipe') {
469
+ yield this.upsertRecipe(Object.assign(Object.assign({}, savingRecipe), { recipeFor: { id: startedAction.id, typeOf: startedAction.typeOf } }));
470
+ }
471
+ return startedAction;
466
472
  });
467
473
  }
468
474
  /**
@@ -472,15 +478,17 @@ class MongoRepository {
472
478
  var _a;
473
479
  return __awaiter(this, void 0, void 0, function* () {
474
480
  if (((_a = params.recipe) === null || _a === void 0 ? void 0 : _a.typeOf) === 'Recipe') {
475
- yield this.saveRecipe(params.recipe);
481
+ yield this.upsertRecipe(Object.assign(Object.assign({}, params.recipe), { recipeFor: { id: params.id, typeOf: params.typeOf } }));
476
482
  }
477
483
  const doc = yield this.actionModel.findOneAndUpdate({
478
- typeOf: params.typeOf,
479
- _id: params.id
484
+ typeOf: { $eq: params.typeOf },
485
+ _id: { $eq: params.id }
480
486
  }, {
481
- actionStatus: factory.actionStatusType.CompletedActionStatus,
482
- result: params.result,
483
- endDate: new Date()
487
+ $set: {
488
+ actionStatus: factory.actionStatusType.CompletedActionStatus,
489
+ result: params.result,
490
+ endDate: new Date()
491
+ }
484
492
  }, { new: true })
485
493
  .select({ __v: 0, createdAt: 0, updatedAt: 0 })
486
494
  .exec();
@@ -494,15 +502,17 @@ class MongoRepository {
494
502
  var _a;
495
503
  return __awaiter(this, void 0, void 0, function* () {
496
504
  if (((_a = params.recipe) === null || _a === void 0 ? void 0 : _a.typeOf) === 'Recipe') {
497
- yield this.saveRecipe(params.recipe);
505
+ yield this.upsertRecipe(Object.assign(Object.assign({}, params.recipe), { recipeFor: { id: params.id, typeOf: params.typeOf } }));
498
506
  }
499
507
  const doc = yield this.actionModel.findOneAndUpdate({
500
508
  _id: { $eq: params.id },
501
509
  typeOf: { $eq: params.typeOf }
502
510
  }, {
503
- actionStatus: factory.actionStatusType.CompletedActionStatus,
504
- result: params.result,
505
- endDate: new Date()
511
+ $set: {
512
+ actionStatus: factory.actionStatusType.CompletedActionStatus,
513
+ result: params.result,
514
+ endDate: new Date()
515
+ }
506
516
  }, { new: false, projection: { _id: 1 } })
507
517
  .exec();
508
518
  if (doc === null) {
@@ -597,9 +607,11 @@ class MongoRepository {
597
607
  * アクション再開
598
608
  */
599
609
  reStart(params) {
610
+ var _a;
600
611
  return __awaiter(this, void 0, void 0, function* () {
601
612
  const doc = yield this.actionModel.findOneAndUpdate({
602
613
  _id: { $eq: params.id },
614
+ typeOf: { $eq: params.typeOf },
603
615
  actionStatus: { $eq: factory.actionStatusType.CompletedActionStatus }
604
616
  }, {
605
617
  $set: {
@@ -612,6 +624,10 @@ class MongoRepository {
612
624
  if (doc === null) {
613
625
  throw new factory.errors.NotFound(this.actionModel.modelName);
614
626
  }
627
+ // add recipe(2024-06-09~)
628
+ if (((_a = params.recipe) === null || _a === void 0 ? void 0 : _a.typeOf) === 'Recipe') {
629
+ yield this.upsertRecipe(Object.assign(Object.assign({}, params.recipe), { recipeFor: { id: params.id, typeOf: params.typeOf } }));
630
+ }
615
631
  });
616
632
  }
617
633
  /**
@@ -1056,7 +1072,22 @@ class MongoRepository {
1056
1072
  }
1057
1073
  saveRecipeWithDateCreated(savingRecipe) {
1058
1074
  return __awaiter(this, void 0, void 0, function* () {
1059
- return this.actionRecipeModel.insertMany(Object.assign(Object.assign({}, savingRecipe), { dateCreated: (savingRecipe.dateCreated instanceof Date) ? savingRecipe.dateCreated : new Date() }), { rawResult: true });
1075
+ const { typeOf, project, recipeCategory, recipeFor, step, dateCreated, dateModified } = savingRecipe;
1076
+ const filter = {
1077
+ 'recipeFor.id': { $eq: recipeFor.id }
1078
+ };
1079
+ const setOnInsert = { project, typeOf, recipeCategory, recipeFor, dateCreated };
1080
+ const setKeys = { step, dateModified };
1081
+ const update = {
1082
+ $setOnInsert: setOnInsert,
1083
+ $set: setKeys
1084
+ };
1085
+ const options = {
1086
+ upsert: true,
1087
+ rawResult: true
1088
+ };
1089
+ return this.actionRecipeModel.updateOne(filter, update, options)
1090
+ .exec();
1060
1091
  });
1061
1092
  }
1062
1093
  findRecipeByAction(params) {
@@ -1072,6 +1103,26 @@ class MongoRepository {
1072
1103
  // return result;
1073
1104
  });
1074
1105
  }
1106
+ findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe(params) {
1107
+ var _a, _b, _c;
1108
+ return __awaiter(this, void 0, void 0, function* () {
1109
+ const recipe = yield this.actionRecipeModel.findOne({
1110
+ 'project.id': { $eq: params.project.id },
1111
+ 'recipeFor.id': { $eq: params.recipeFor.id }
1112
+ }, {
1113
+ project: 0,
1114
+ typeOf: 0,
1115
+ recipeCategory: 0,
1116
+ recipeFor: 0,
1117
+ dateCreated: 0,
1118
+ dateModified: 0,
1119
+ 'step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.ykknInfo': 0,
1120
+ 'step.itemListElement.itemListElement.afterMedia.knyknrNoInfoOut.mkknInfo': 0
1121
+ }, { lean: true })
1122
+ .exec();
1123
+ return (_c = (_b = (_a = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.afterMedia;
1124
+ });
1125
+ }
1075
1126
  aggregateAuthorizeEventServiceOfferAction(params) {
1076
1127
  return __awaiter(this, void 0, void 0, function* () {
1077
1128
  const statuses = yield Promise.all([
@@ -1366,9 +1417,35 @@ class MongoRepository {
1366
1417
  };
1367
1418
  });
1368
1419
  }
1369
- saveRecipe(savingRecipe) {
1420
+ upsertRecipe(savingRecipe) {
1370
1421
  return __awaiter(this, void 0, void 0, function* () {
1371
- return this.actionRecipeModel.insertMany(Object.assign(Object.assign({}, savingRecipe), { dateCreated: new Date() }), { rawResult: true });
1422
+ const dateModified = new Date();
1423
+ const { typeOf, project, recipeCategory, recipeFor, step } = savingRecipe;
1424
+ const filter = {
1425
+ 'recipeFor.id': { $eq: recipeFor.id }
1426
+ };
1427
+ const setOnInsert = {
1428
+ project, typeOf, recipeCategory, recipeFor,
1429
+ dateCreated: dateModified
1430
+ };
1431
+ const setKeys = { step, dateModified };
1432
+ const update = {
1433
+ $setOnInsert: setOnInsert,
1434
+ $set: setKeys
1435
+ };
1436
+ const options = {
1437
+ upsert: true,
1438
+ rawResult: true
1439
+ };
1440
+ return this.actionRecipeModel.updateOne(filter, update, options)
1441
+ .exec();
1442
+ // return this.actionRecipeModel.insertMany<factory.recipe.IRecipe & { dateCreated: Date }>(
1443
+ // {
1444
+ // ...savingRecipe,
1445
+ // dateCreated: new Date()
1446
+ // },
1447
+ // { rawResult: true }
1448
+ // );
1372
1449
  // const result = await this.actionRecipeModel.insertMany<IRecipe>(savingRecipe, { rawResult: true });
1373
1450
  // const id = result.insertedIds?.[0]?.toHexString();
1374
1451
  // if (typeof id !== 'string') {
@@ -30,7 +30,8 @@ const schemaDefinition = {
30
30
  dateCreated: {
31
31
  type: Date,
32
32
  required: true
33
- }
33
+ },
34
+ dateModified: Date
34
35
  };
35
36
  const schemaOptions = {
36
37
  autoIndex: settings_1.MONGO_AUTO_INDEX,
@@ -20,12 +20,11 @@ const validation_1 = require("./pay/account/validation");
20
20
  const factory_1 = require("./pay/factory");
21
21
  const debug = createDebug('chevre-domain:service:assetTransaction');
22
22
  function publishPaymentUrlResult2recipe(params) {
23
- const { project, action, result } = params;
23
+ const { project, result } = params;
24
24
  return {
25
25
  project: { id: project.id, typeOf: factory.organizationType.Project },
26
26
  typeOf: 'Recipe',
27
27
  recipeCategory: factory.recipe.RecipeCategory.publishPaymentUrl,
28
- recipeFor: { id: action.id, typeOf: action.typeOf },
29
28
  step: [{
30
29
  typeOf: 'HowToSection',
31
30
  itemListElement: [
@@ -116,7 +115,6 @@ function publishPaymentUrl(params, options) {
116
115
  // create recipe(2024-06-02~)
117
116
  recipe = publishPaymentUrlResult2recipe({
118
117
  project: { id: params.project.id },
119
- action: { id: action.id, typeOf: action.typeOf },
120
118
  result
121
119
  });
122
120
  break;
@@ -11,9 +11,5 @@ declare function processConfirmCOAReserveResult2recipe(params: {
11
11
  project: {
12
12
  id: string;
13
13
  };
14
- action: {
15
- id: string;
16
- typeOf: factory.actionType;
17
- };
18
14
  }): factory.action.interact.confirm.reservation.IConfirmCOAReserveRecipe;
19
15
  export { IProcessConfirmCOAReserveResult, processConfirmCOAReserveResult2recipe };
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processConfirmCOAReserveResult2recipe = void 0;
4
4
  const factory = require("../../../factory");
5
5
  function processConfirmCOAReserveResult2recipe(params) {
6
- const { processConfirmCOAReserveResult, project, action } = params;
6
+ const { processConfirmCOAReserveResult, project } = params;
7
7
  const { stateReserveArgs, stateReserveResult, updReserveArgs, updReserveResult } = processConfirmCOAReserveResult;
8
8
  return {
9
9
  project: { id: project.id, typeOf: factory.organizationType.Project },
10
10
  typeOf: 'Recipe',
11
11
  recipeCategory: factory.recipe.RecipeCategory.confirmCOAReserve,
12
- recipeFor: { id: action.id, typeOf: action.typeOf },
13
12
  step: [{
14
13
  typeOf: 'HowToSection',
15
14
  itemListElement: [
@@ -19,9 +19,5 @@ declare function processUpdTmpReserveSeatResult2recipe(params: {
19
19
  project: {
20
20
  id: string;
21
21
  };
22
- action: {
23
- id: string;
24
- typeOf: factory.actionType;
25
- };
26
22
  }): factory.action.accept.coaOffer.IRecipe;
27
23
  export { IAcceptedOfferWithoutDetail, createUpdTmpReserveSeatArgs, processUpdTmpReserveSeatResult2recipe };
@@ -20,13 +20,12 @@ function createUpdTmpReserveSeatArgs(params) {
20
20
  }
21
21
  exports.createUpdTmpReserveSeatArgs = createUpdTmpReserveSeatArgs;
22
22
  function processUpdTmpReserveSeatResult2recipe(params) {
23
- const { processUpdTmpReserveSeatResult, project, action } = params;
23
+ const { processUpdTmpReserveSeatResult, project } = params;
24
24
  const { updTmpReserveSeatArgs, updTmpReserveSeatResult } = processUpdTmpReserveSeatResult;
25
25
  return {
26
26
  project: { id: project.id, typeOf: factory.organizationType.Project },
27
27
  typeOf: 'Recipe',
28
28
  recipeCategory: factory.recipe.RecipeCategory.acceptCOAOffer,
29
- recipeFor: { id: action.id, typeOf: action.typeOf },
30
29
  step: [{
31
30
  typeOf: 'HowToSection',
32
31
  itemListElement: [
@@ -101,8 +101,7 @@ function acceptOffer(params) {
101
101
  updTmpReserveSeatArgs: requestBody,
102
102
  updTmpReserveSeatResult: responseBody
103
103
  },
104
- project: { id: transaction.project.id },
105
- action: { id: action.id, typeOf: action.typeOf }
104
+ project: { id: transaction.project.id }
106
105
  });
107
106
  const result = {
108
107
  object: {
@@ -99,7 +99,7 @@ function changeOffers(params) {
99
99
  });
100
100
  const actionResult = Object.assign(Object.assign({}, authorizeAction.result), { price: price, amount: eligibleMonetaryAmount, acceptedOffers: [] });
101
101
  // ActiveActionStatus->CompletedActionStatusで再実装(2024-01-15~)
102
- yield repos.action.reStart({ id: authorizeAction.id });
102
+ yield repos.action.reStart({ id: authorizeAction.id, typeOf: authorizeAction.typeOf });
103
103
  try {
104
104
  // まずvoidAcceptedOffer
105
105
  // const orderNumberByTransaction = transaction.object.orderNumber;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import * as factory from '../../factory';
5
5
  import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
6
- import type { MongoRepository as ActionRepo } from '../../repo/action';
6
+ import type { IMinimizedPurchaseNumberAuthResult, MongoRepository as ActionRepo } from '../../repo/action';
7
7
  import type { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
8
8
  import type { AuthorizationRepo } from '../../repo/code';
9
9
  import type { ConfirmationNumberRepo } from '../../repo/confirmationNumber';
@@ -182,7 +182,7 @@ interface IFindCheckActionResult {
182
182
  message?: string;
183
183
  };
184
184
  result?: {
185
- purchaseNumberAuthResult: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult;
185
+ purchaseNumberAuthResult: IMinimizedPurchaseNumberAuthResult;
186
186
  };
187
187
  }
188
188
  interface IFindAcceptActionResult {
@@ -239,12 +239,6 @@ declare function findCheckAction(params: {
239
239
  */
240
240
  id: string;
241
241
  };
242
- options: {
243
- /**
244
- * 最小化すると、ykknInfo,mkknInfoを返さない
245
- */
246
- minimize: boolean;
247
- };
248
242
  }): (repos: {
249
243
  action: ActionRepo;
250
244
  task: TaskRepo;
@@ -551,28 +551,11 @@ function findCheckAction(params) {
551
551
  if (((_b = authorizeAction.purpose) === null || _b === void 0 ? void 0 : _b.id) !== params.purpose.id) {
552
552
  throw new factory.errors.NotFound('Action');
553
553
  }
554
- const authorizeActionWithResult = yield repos.action.findById({ id: authorizeAction.id, typeOf: factory.actionType.CheckAction }, [], [
555
- 'agent',
556
- 'purpose',
557
- 'object',
558
- 'startDate',
559
- 'endDate',
560
- 'actionStatus',
561
- 'typeOf',
562
- 'project',
563
- 'sameAs',
564
- '_id',
565
- ...(params.options.minimize === true)
566
- ? [
567
- 'result.purchaseNumberAuthResult.knyknrNoInfoOut.ykknInfo',
568
- 'result.purchaseNumberAuthResult.knyknrNoInfoOut.mkknInfo'
569
- ]
570
- : []
571
- ]);
572
- let purchaseNumberAuthResult;
573
- if ((authorizeActionWithResult === null || authorizeActionWithResult === void 0 ? void 0 : authorizeActionWithResult.result) !== undefined) {
574
- purchaseNumberAuthResult = authorizeActionWithResult.result.purchaseNumberAuthResult;
575
- }
554
+ // result from recipe(2024-06-10~)
555
+ const purchaseNumberAuthResult = yield repos.action.findIMinimizedPurchaseNumberAuthResultByCheckMovieTicketRecipe({
556
+ project: { id: params.project.id },
557
+ recipeFor: { id: authorizeAction.id }
558
+ });
576
559
  action = Object.assign(Object.assign({ id: authorizeAction.id, actionStatus: authorizeAction.actionStatus }, (authorizeAction.error !== undefined)
577
560
  ? {
578
561
  error: (Array.isArray(authorizeAction.error))
@@ -17,19 +17,11 @@ declare function processAlterTranResult2payRecipe(params: {
17
17
  project: {
18
18
  id: string;
19
19
  };
20
- action: {
21
- id: string;
22
- typeOf: factory.actionType;
23
- };
24
20
  }): factory.action.trade.pay.IPayCreditCardRecipe;
25
21
  declare function processAlterTranResult2refundRecipe(params: {
26
22
  processAlterTranResult: IProcessAlterTranResult4refund;
27
23
  project: {
28
24
  id: string;
29
25
  };
30
- action: {
31
- id: string;
32
- typeOf: factory.actionType;
33
- };
34
26
  }): factory.action.trade.refund.IRefundCreditCardRecipe;
35
27
  export { IProcessAlterTranResult, IProcessAlterTranResult4refund, processAlterTranResult2payRecipe, processAlterTranResult2refundRecipe };
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processAlterTranResult2refundRecipe = exports.processAlterTranResult2payRecipe = void 0;
4
4
  const factory = require("../../../factory");
5
5
  function processAlterTranResult2payRecipe(params) {
6
- const { processAlterTranResults, project, action } = params;
6
+ const { processAlterTranResults, project } = params;
7
7
  return {
8
8
  project: { id: project.id, typeOf: factory.organizationType.Project },
9
9
  typeOf: 'Recipe',
10
10
  recipeCategory: factory.recipe.RecipeCategory.payCreditCard,
11
- recipeFor: { id: action.id, typeOf: action.typeOf },
12
11
  step: processAlterTranResults.map(({ searchTradeArgs, searchTradeResult, alterTranArgs, alterTranResult }) => {
13
12
  return {
14
13
  typeOf: 'HowToSection',
@@ -30,13 +29,12 @@ function processAlterTranResult2payRecipe(params) {
30
29
  }
31
30
  exports.processAlterTranResult2payRecipe = processAlterTranResult2payRecipe;
32
31
  function processAlterTranResult2refundRecipe(params) {
33
- const { processAlterTranResult, project, action } = params;
32
+ const { processAlterTranResult, project } = params;
34
33
  const { searchTradeArgs, searchTradeResult, alterTranResult, alterTranArgs } = processAlterTranResult;
35
34
  return {
36
35
  project: { id: project.id, typeOf: factory.organizationType.Project },
37
36
  typeOf: 'Recipe',
38
37
  recipeCategory: factory.recipe.RecipeCategory.refundCreditCard,
39
- recipeFor: { id: action.id, typeOf: action.typeOf },
40
38
  step: [{
41
39
  typeOf: 'HowToSection',
42
40
  itemListElement: [
@@ -67,8 +67,7 @@ function payCreditCard(params) {
67
67
  // add recipe(2024-06-03~)
68
68
  recipe = (0, factory_1.processAlterTranResult2payRecipe)({
69
69
  processAlterTranResults,
70
- project: { id: params.project.id },
71
- action: { id: action.id, typeOf: action.typeOf }
70
+ project: { id: params.project.id }
72
71
  });
73
72
  }
74
73
  catch (error) {
@@ -93,8 +93,7 @@ function refundCreditCard(params, options) {
93
93
  // add recipe(2024-06-04~)
94
94
  recipe = (0, factory_1.processAlterTranResult2refundRecipe)({
95
95
  processAlterTranResult,
96
- project: { id: params.project.id },
97
- action: { id: action.id, typeOf: action.typeOf }
96
+ project: { id: params.project.id }
98
97
  });
99
98
  }
100
99
  catch (error) {
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.checkMovieTicket = void 0;
13
13
  const errorHandler_1 = require("../../../errorHandler");
14
14
  const factory = require("../../../factory");
15
- const settings_1 = require("../../../settings");
16
15
  const factory_1 = require("./factory");
17
16
  const processPurchaseNumberAuth_1 = require("./processPurchaseNumberAuth");
18
17
  /**
@@ -82,8 +81,7 @@ function checkMovieTicket(params) {
82
81
  // add recipe(2024-06-07~)
83
82
  recipe = (0, factory_1.processPurchaseNumberAuthResult2checkRecipe)({
84
83
  processPurchaseNumberAuthResult,
85
- project: { id: params.project.id },
86
- action: { id: action.id, typeOf: action.typeOf }
84
+ project: { id: params.project.id }
87
85
  });
88
86
  }
89
87
  catch (error) {
@@ -101,7 +99,9 @@ function checkMovieTicket(params) {
101
99
  purchaseNumberAuthIn: processPurchaseNumberAuthResult.purchaseNumberAuthIn,
102
100
  purchaseNumberAuthResult: processPurchaseNumberAuthResult.purchaseNumberAuthResult
103
101
  };
104
- yield repos.action.completeWithVoid(Object.assign({ typeOf: actionAttributes.typeOf, id: action.id, result }, (settings_1.USE_EXPERIMENTAL_FEATURE) ? { recipe } : undefined));
102
+ yield repos.action.completeWithVoid({
103
+ typeOf: actionAttributes.typeOf, id: action.id, result, recipe
104
+ });
105
105
  return { result: processPurchaseNumberAuthResult };
106
106
  });
107
107
  }
@@ -30,20 +30,12 @@ declare function processPurchaseNumberAuthResult2checkRecipe(params: {
30
30
  project: {
31
31
  id: string;
32
32
  };
33
- action: {
34
- id: string;
35
- typeOf: factory.actionType;
36
- };
37
33
  }): factory.action.check.paymentMethod.movieTicket.IRecipe;
38
34
  declare function processSeatInfoSyncResult2payRecipe(params: {
39
35
  processSeatInfoSyncResult: IProcessSeatInfoSyncResult;
40
36
  project: {
41
37
  id: string;
42
38
  };
43
- action: {
44
- id: string;
45
- typeOf: factory.actionType;
46
- };
47
39
  }): factory.action.trade.pay.IPayMovieTicketRecipe;
48
40
  declare function processSeatInfoSyncResult2refundRecipe(params: {
49
41
  processSeatInfoSyncResult?: IProcessSeatInfoSyncResult;
@@ -51,10 +43,6 @@ declare function processSeatInfoSyncResult2refundRecipe(params: {
51
43
  project: {
52
44
  id: string;
53
45
  };
54
- action: {
55
- id: string;
56
- typeOf: factory.actionType;
57
- };
58
46
  }): factory.action.trade.refund.IRefundMovieTicketRecipe;
59
47
  declare enum MovieticketReserveRequestErrorMessage {
60
48
  AlreadyPaid = "\u65E2\u306B\u5B58\u5728\u3059\u308B\u8208\u884C\u30B7\u30B9\u30C6\u30E0\u5EA7\u5E2D\u4E88\u7D04\u756A\u53F7\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F\u3002",
@@ -92,13 +92,12 @@ function createStartingPayAction(params, seatInfoSyncIn) {
92
92
  }
93
93
  exports.createStartingPayAction = createStartingPayAction;
94
94
  function processPurchaseNumberAuthResult2checkRecipe(params) {
95
- const { processPurchaseNumberAuthResult, project, action } = params;
95
+ const { processPurchaseNumberAuthResult, project } = params;
96
96
  const { purchaseNumberAuthIn, purchaseNumberAuthResult } = processPurchaseNumberAuthResult;
97
97
  return {
98
98
  project: { id: project.id, typeOf: factory.organizationType.Project },
99
99
  typeOf: 'Recipe',
100
100
  recipeCategory: factory.recipe.RecipeCategory.checkMovieTicket,
101
- recipeFor: { id: action.id, typeOf: action.typeOf },
102
101
  step: [{
103
102
  typeOf: 'HowToSection',
104
103
  itemListElement: [
@@ -113,13 +112,12 @@ function processPurchaseNumberAuthResult2checkRecipe(params) {
113
112
  }
114
113
  exports.processPurchaseNumberAuthResult2checkRecipe = processPurchaseNumberAuthResult2checkRecipe;
115
114
  function processSeatInfoSyncResult2payRecipe(params) {
116
- const { processSeatInfoSyncResult, project, action } = params;
115
+ const { processSeatInfoSyncResult, project } = params;
117
116
  const { seatInfoSyncIn, seatInfoSyncResult } = processSeatInfoSyncResult;
118
117
  return {
119
118
  project: { id: project.id, typeOf: factory.organizationType.Project },
120
119
  typeOf: 'Recipe',
121
120
  recipeCategory: factory.recipe.RecipeCategory.payMovieTicket,
122
- recipeFor: { id: action.id, typeOf: action.typeOf },
123
121
  step: [{
124
122
  typeOf: 'HowToSection',
125
123
  itemListElement: [
@@ -134,14 +132,13 @@ function processSeatInfoSyncResult2payRecipe(params) {
134
132
  }
135
133
  exports.processSeatInfoSyncResult2payRecipe = processSeatInfoSyncResult2payRecipe;
136
134
  function processSeatInfoSyncResult2refundRecipe(params) {
137
- const { processSeatInfoSyncResult, processSeatInfoSyncCancelResult, project, action } = params;
135
+ const { processSeatInfoSyncResult, processSeatInfoSyncCancelResult, project } = params;
138
136
  if (processSeatInfoSyncResult !== undefined) {
139
137
  const { seatInfoSyncIn, seatInfoSyncResult } = processSeatInfoSyncResult;
140
138
  return {
141
139
  project: { id: project.id, typeOf: factory.organizationType.Project },
142
140
  typeOf: 'Recipe',
143
141
  recipeCategory: factory.recipe.RecipeCategory.refundMovieTicket,
144
- recipeFor: { id: action.id, typeOf: action.typeOf },
145
142
  step: [{
146
143
  typeOf: 'HowToSection',
147
144
  itemListElement: [
@@ -160,7 +157,6 @@ function processSeatInfoSyncResult2refundRecipe(params) {
160
157
  project: { id: project.id, typeOf: factory.organizationType.Project },
161
158
  typeOf: 'Recipe',
162
159
  recipeCategory: factory.recipe.RecipeCategory.refundMovieTicket,
163
- recipeFor: { id: action.id, typeOf: action.typeOf },
164
160
  step: [{
165
161
  typeOf: 'HowToSection',
166
162
  itemListElement: [
@@ -28,9 +28,12 @@ function payMovieTicket(params) {
28
28
  const paymentServiceId = (_b = params.object[0]) === null || _b === void 0 ? void 0 : _b.id;
29
29
  const seatInfoSyncIn = yield payActionParams2seatInfoSyncIn(params)(repos);
30
30
  const startingAction = (0, factory_1.createStartingPayAction)(params, seatInfoSyncIn);
31
- let action = yield repos.action.start(startingAction);
31
+ let recipe = (0, factory_1.processSeatInfoSyncResult2payRecipe)({
32
+ processSeatInfoSyncResult: { seatInfoSyncIn },
33
+ project: { id: params.project.id }
34
+ });
35
+ let action = yield repos.action.start(startingAction, { recipe });
32
36
  let processSeatInfoSyncResult;
33
- let recipe;
34
37
  try {
35
38
  // 着券済に対する冪等性を確保する必要はあるが、
36
39
  // その他のアクションとしての振る舞いは実行される必要もある
@@ -67,8 +70,7 @@ function payMovieTicket(params) {
67
70
  // add recipe(2024-06-03~)
68
71
  recipe = (0, factory_1.processSeatInfoSyncResult2payRecipe)({
69
72
  processSeatInfoSyncResult,
70
- project: { id: params.project.id },
71
- action: { id: action.id, typeOf: action.typeOf }
73
+ project: { id: params.project.id }
72
74
  });
73
75
  }
74
76
  catch (error) {
@@ -55,8 +55,9 @@ function refundMovieTicket(params) {
55
55
  })({ action: repos.action });
56
56
  }
57
57
  const instrument = Object.assign(Object.assign({ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket }, (seatInfoSyncIn !== undefined) ? { seatInfoSyncIn } : undefined), (seatInfoSyncCancelIn !== undefined) ? { seatInfoSyncCancelIn } : undefined);
58
+ let recipe = (0, factory_1.processSeatInfoSyncResult2refundRecipe)(Object.assign(Object.assign({ project: { id: params.project.id } }, (seatInfoSyncIn !== undefined) ? { processSeatInfoSyncResult: { seatInfoSyncIn } } : undefined), (seatInfoSyncCancelIn !== undefined) ? { processSeatInfoSyncCancelResult: { seatInfoSyncCancelIn } } : undefined));
58
59
  let action = yield repos.action.start(Object.assign(Object.assign(Object.assign({}, params), (typeof ((_g = params.sameAs) === null || _g === void 0 ? void 0 : _g.id) === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined), { instrument // instrumentをセット(2024-04-30~)
59
- }));
60
+ }), { recipe });
60
61
  let processSeatInfoSyncCancelResult;
61
62
  let processSeatInfoSyncResult;
62
63
  try {
@@ -95,7 +96,7 @@ function refundMovieTicket(params) {
95
96
  }
96
97
  else {
97
98
  // add recipe(2024-06-04~)
98
- const recipe = (0, factory_1.processSeatInfoSyncResult2refundRecipe)(Object.assign(Object.assign({ project: { id: params.project.id }, action: { id: action.id, typeOf: action.typeOf } }, (processSeatInfoSyncResult !== undefined) ? { processSeatInfoSyncResult } : undefined), (processSeatInfoSyncCancelResult !== undefined) ? { processSeatInfoSyncCancelResult } : undefined));
99
+ recipe = (0, factory_1.processSeatInfoSyncResult2refundRecipe)(Object.assign(Object.assign({ project: { id: params.project.id } }, (processSeatInfoSyncResult !== undefined) ? { processSeatInfoSyncResult } : undefined), (processSeatInfoSyncCancelResult !== undefined) ? { processSeatInfoSyncCancelResult } : undefined));
99
100
  const actionResult = Object.assign(Object.assign({}, ((processSeatInfoSyncResult === null || processSeatInfoSyncResult === void 0 ? void 0 : processSeatInfoSyncResult.seatInfoSyncResult) !== undefined)
100
101
  ? { seatInfoSyncResult: processSeatInfoSyncResult.seatInfoSyncResult }
101
102
  : undefined), ((processSeatInfoSyncCancelResult === null || processSeatInfoSyncCancelResult === void 0 ? void 0 : processSeatInfoSyncCancelResult.seatInfoSyncCancelResult) !== undefined)
@@ -109,7 +110,7 @@ function refundMovieTicket(params) {
109
110
  exports.refundMovieTicket = refundMovieTicket;
110
111
  function createSeatInfoSyncInOnRefund(params) {
111
112
  return (repos) => __awaiter(this, void 0, void 0, function* () {
112
- var _a;
113
+ var _a, _b, _c, _d;
113
114
  // 本アクションに対応するPayActionを取り出す
114
115
  // 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
115
116
  const payAction = yield repos.action.findPayAction({
@@ -126,9 +127,19 @@ function createSeatInfoSyncInOnRefund(params) {
126
127
  if (payAction === undefined) {
127
128
  throw new factory.errors.NotFound('PayAction');
128
129
  }
129
- const seatInfoSyncInOnPay = (_a = payAction.instrument) === null || _a === void 0 ? void 0 : _a.seatInfoSyncIn;
130
+ const recipe = yield repos.action.findRecipeByAction({
131
+ project: { id: params.project.id },
132
+ recipeFor: { id: payAction.id }
133
+ });
134
+ // const seatInfoSyncInOnPay: surfrock.factory.service.seat.seatInfoSync.ISeatInfoSyncIn | undefined =
135
+ // payAction.instrument?.seatInfoSyncIn;
136
+ let seatInfoSyncInOnPay = (_c = (_b = (_a = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia;
137
+ if (seatInfoSyncInOnPay === undefined && ((_d = payAction.instrument) === null || _d === void 0 ? void 0 : _d.seatInfoSyncIn) !== undefined) {
138
+ seatInfoSyncInOnPay = payAction.instrument.seatInfoSyncIn; // compatibility
139
+ }
130
140
  if (seatInfoSyncInOnPay === undefined) {
131
- throw new factory.errors.NotFound('PayAction.instrument?.seatInfoSyncIn');
141
+ // throw new factory.errors.NotFound('PayAction.instrument?.seatInfoSyncIn');
142
+ throw new factory.errors.NotFound('PayAction.recipe.step.itemListElement.itemListElement.beforeMedia');
132
143
  }
133
144
  let seatInfoSyncIn;
134
145
  // 着券時のseatInfoSyncInに対してtrkshFlgだけ変更してリクエストする
@@ -139,7 +150,7 @@ function createSeatInfoSyncInOnRefund(params) {
139
150
  }
140
151
  function createSeatInfoSyncCancelInOnRefund(params) {
141
152
  return (repos) => __awaiter(this, void 0, void 0, function* () {
142
- var _a;
153
+ var _a, _b, _c, _d;
143
154
  // 本アクションに対応するPayActionを取り出す
144
155
  // 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
145
156
  const payAction = yield repos.action.findPayAction({
@@ -156,9 +167,19 @@ function createSeatInfoSyncCancelInOnRefund(params) {
156
167
  if (payAction === undefined) {
157
168
  throw new factory.errors.NotFound('PayAction');
158
169
  }
159
- const seatInfoSyncInOnPay = (_a = payAction.instrument) === null || _a === void 0 ? void 0 : _a.seatInfoSyncIn;
170
+ const recipe = yield repos.action.findRecipeByAction({
171
+ project: { id: params.project.id },
172
+ recipeFor: { id: payAction.id }
173
+ });
174
+ // const seatInfoSyncInOnPay: surfrock.factory.service.seat.seatInfoSync.ISeatInfoSyncIn | undefined =
175
+ // payAction.instrument?.seatInfoSyncIn;
176
+ let seatInfoSyncInOnPay = (_c = (_b = (_a = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0]) === null || _c === void 0 ? void 0 : _c.beforeMedia;
177
+ if (seatInfoSyncInOnPay === undefined && ((_d = payAction.instrument) === null || _d === void 0 ? void 0 : _d.seatInfoSyncIn) !== undefined) {
178
+ seatInfoSyncInOnPay = payAction.instrument.seatInfoSyncIn; // compatibility
179
+ }
160
180
  if (seatInfoSyncInOnPay === undefined) {
161
- throw new factory.errors.NotFound('PayAction.instrument?.seatInfoSyncIn');
181
+ // throw new factory.errors.NotFound('PayAction.instrument?.seatInfoSyncIn');
182
+ throw new factory.errors.NotFound('PayAction.recipe.step.itemListElement.itemListElement.beforeMedia');
162
183
  }
163
184
  let seatInfoSyncCancelIn;
164
185
  seatInfoSyncCancelIn = {
@@ -114,12 +114,11 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
114
114
  exports.validateMovieTicket = validateMovieTicket;
115
115
  function checkByIdentifierIfNotYet(params) {
116
116
  return (repos) => __awaiter(this, void 0, void 0, function* () {
117
- var _a;
117
+ var _a, _b;
118
118
  let checkResult;
119
119
  if (params.useCheckByIdentifierIfNotYet === true) {
120
120
  // すでにCheckActionが存在すれば認証しない(2023-06-06~)
121
- debug('searching alreadyCheckedActions...movieTicketIdentifier:', params.movieTicketIdentifier, 'screeningEvent.id:', params.screeningEvent.id);
122
- const alreadyCheckedAction = yield repos.action.search({
121
+ const alreadyCheckedAction = (yield repos.action.search({
123
122
  limit: 1,
124
123
  page: 1,
125
124
  sort: { startDate: factory.sortType.Descending },
@@ -135,9 +134,22 @@ function checkByIdentifierIfNotYet(params) {
135
134
  }
136
135
  }
137
136
  }
138
- }, ['result'], []);
139
- debug('alreadyCheckedAction found', alreadyCheckedAction, 'movieTicketIdentifier:', params.movieTicketIdentifier, 'screeningEvent.id:', params.screeningEvent.id);
140
- checkResult = (_a = alreadyCheckedAction.shift()) === null || _a === void 0 ? void 0 : _a.result;
137
+ }, ['_id'], [])).shift();
138
+ if (alreadyCheckedAction !== undefined) {
139
+ const recipe = yield repos.action.findRecipeByAction({
140
+ project: { id: params.screeningEvent.project.id },
141
+ recipeFor: { id: alreadyCheckedAction.id }
142
+ });
143
+ const directionPurchaseNumberAuth = (_b = (_a = recipe === null || recipe === void 0 ? void 0 : recipe.step[0]) === null || _a === void 0 ? void 0 : _a.itemListElement[0]) === null || _b === void 0 ? void 0 : _b.itemListElement[0];
144
+ if (directionPurchaseNumberAuth !== undefined) {
145
+ debug('alreadyCheckedAction.directionPurchaseNumberAuth found', directionPurchaseNumberAuth.typeOf, 'movieTicketIdentifier:', params.movieTicketIdentifier, 'screeningEvent.id:', params.screeningEvent.id);
146
+ const { beforeMedia, afterMedia } = directionPurchaseNumberAuth;
147
+ if (beforeMedia !== undefined && afterMedia !== undefined) {
148
+ checkResult = { purchaseNumberAuthIn: beforeMedia, purchaseNumberAuthResult: afterMedia };
149
+ }
150
+ }
151
+ // checkResult = alreadyCheckedAction.shift()?.result;
152
+ }
141
153
  }
142
154
  if (checkResult === undefined) {
143
155
  debug('checkByIdentifier processing because movieTickets not checked yet...', checkResult);
@@ -166,8 +166,7 @@ function confirmReserveTransaction(params, options) {
166
166
  updReserveResult = processConfirmCOAReserveResult.updReserveResult;
167
167
  recipe = (0, factory_1.processConfirmCOAReserveResult2recipe)({
168
168
  processConfirmCOAReserveResult,
169
- project: { id: confirmActionAttributes.project.id },
170
- action: { id: action.id, typeOf: action.typeOf }
169
+ project: { id: confirmActionAttributes.project.id }
171
170
  });
172
171
  break;
173
172
  default:
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.374.0-alpha.9",
13
+ "@chevre/factory": "4.374.0-alpha.10",
14
14
  "@cinerino/sdk": "7.1.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.34.0-alpha.1"
113
+ "version": "21.34.0-alpha.3"
114
114
  }