@chevre/domain 21.33.0-alpha.9 → 21.33.0

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 (95) hide show
  1. package/example/src/chevre/findTransactionById.ts +8 -5
  2. package/example/src/chevre/migratePayCreditCardRecipes.ts +104 -0
  3. package/example/src/chevre/migratePayMovieTicketRecipes.ts +100 -0
  4. package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +147 -0
  5. package/example/src/chevre/reexportTasksByExportAction.ts +37 -0
  6. package/example/src/chevre/searchActionsBySameAs.ts +2 -1
  7. package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +26 -6
  8. package/example/src/chevre/searchTransactions.ts +1 -1
  9. package/example/src/chevre/unsetUnnecessaryFields.ts +3 -18
  10. package/lib/chevre/repo/action.d.ts +51 -0
  11. package/lib/chevre/repo/action.js +122 -2
  12. package/lib/chevre/repo/assetTransaction.d.ts +9 -2
  13. package/lib/chevre/repo/assetTransaction.js +48 -3
  14. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +5 -0
  15. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +89 -0
  16. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +23 -25
  17. package/lib/chevre/repo/mongoose/schemas/transaction.js +5 -52
  18. package/lib/chevre/repo/transaction.d.ts +26 -11
  19. package/lib/chevre/repo/transaction.js +89 -17
  20. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -2
  21. package/lib/chevre/service/assetTransaction/pay.js +49 -5
  22. package/lib/chevre/service/offer/event/voidTransaction.js +4 -6
  23. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +2 -1
  24. package/lib/chevre/service/offer/product.js +1 -1
  25. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +23 -0
  26. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +155 -0
  27. package/lib/chevre/service/payment/any.d.ts +10 -2
  28. package/lib/chevre/service/payment/any.js +83 -114
  29. package/lib/chevre/service/payment/creditCard/authorize.d.ts +41 -0
  30. package/lib/chevre/service/payment/creditCard/authorize.js +216 -0
  31. package/lib/chevre/service/payment/creditCard/factory.d.ts +35 -0
  32. package/lib/chevre/service/payment/creditCard/factory.js +57 -0
  33. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +20 -0
  34. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +47 -0
  35. package/lib/chevre/service/payment/creditCard/gmoError.d.ts +34 -0
  36. package/lib/chevre/service/payment/creditCard/gmoError.js +8 -0
  37. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +20 -0
  38. package/lib/chevre/service/payment/creditCard/payCreditCard.js +151 -0
  39. package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +26 -0
  40. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +196 -0
  41. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +13 -0
  42. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +62 -0
  43. package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +13 -0
  44. package/lib/chevre/service/payment/creditCard/voidTransaction.js +90 -0
  45. package/lib/chevre/service/payment/creditCard.d.ts +7 -106
  46. package/lib/chevre/service/payment/creditCard.js +12 -638
  47. package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
  48. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +38 -0
  49. package/lib/chevre/service/payment/movieTicket/authorize.js +71 -0
  50. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +22 -0
  51. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +109 -0
  52. package/lib/chevre/service/payment/movieTicket/factory.d.ts +52 -1
  53. package/lib/chevre/service/payment/movieTicket/factory.js +114 -1
  54. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +24 -0
  55. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +157 -0
  56. package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.d.ts → processPurchaseNumberAuth.d.ts} +5 -6
  57. package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.js → processPurchaseNumberAuth.js} +4 -8
  58. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +21 -0
  59. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +248 -0
  60. package/lib/chevre/service/payment/movieTicket/validation.js +3 -3
  61. package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +12 -0
  62. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +74 -0
  63. package/lib/chevre/service/payment/movieTicket.d.ts +7 -75
  64. package/lib/chevre/service/payment/movieTicket.js +11 -567
  65. package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
  66. package/lib/chevre/service/payment.d.ts +9 -1
  67. package/lib/chevre/service/payment.js +2 -1
  68. package/lib/chevre/service/task/acceptCOAOffer.js +2 -1
  69. package/lib/chevre/service/task/authorizePayment.js +2 -1
  70. package/lib/chevre/service/task/checkMovieTicket.js +1 -1
  71. package/lib/chevre/service/task/pay.d.ts +2 -2
  72. package/lib/chevre/service/task/pay.js +3 -2
  73. package/lib/chevre/service/task/publishPaymentUrl.js +2 -1
  74. package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
  75. package/lib/chevre/service/task/voidPayTransaction.js +2 -4
  76. package/lib/chevre/service/task/voidPayment.js +0 -1
  77. package/lib/chevre/service/task.js +2 -0
  78. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.d.ts +1 -1
  79. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -1
  80. package/lib/chevre/service/transaction/moneyTransfer.js +2 -2
  81. package/lib/chevre/service/transaction/placeOrder.js +2 -3
  82. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +3 -2
  83. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
  84. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  85. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  86. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +4 -3
  87. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +1 -1
  88. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
  89. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -1
  90. package/lib/chevre/service/transaction/returnOrder.js +2 -2
  91. package/lib/chevre/settings.d.ts +1 -0
  92. package/lib/chevre/settings.js +2 -1
  93. package/package.json +3 -3
  94. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +0 -152
  95. package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +0 -95
@@ -8,11 +8,14 @@ async function main() {
8
8
 
9
9
  const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
10
10
 
11
- const transaction = await transactionRepo.findById({
12
- typeOf: chevre.factory.transactionType.PlaceOrder,
13
- id: '6656d35dd1f13f8c658be102',
14
- inclusion: ['typeOf']
15
- });
11
+ const transaction = await transactionRepo.findById(
12
+ {
13
+ typeOf: chevre.factory.transactionType.PlaceOrder,
14
+ id: '6656d35dd1f13f8c658be102'
15
+ },
16
+ ['status'],
17
+ ['typeOf', 'object', 'seller', 'agent', 'tasksExportAction']
18
+ );
16
19
  console.log('transaction:', transaction);
17
20
  }
18
21
 
@@ -0,0 +1,104 @@
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
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
11
+ const cursor = actionRepo.getCursor(
12
+ {
13
+ typeOf: { $eq: chevre.factory.actionType.PayAction },
14
+ actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
15
+ startDate: {
16
+ $gte: moment()
17
+ // tslint:disable-next-line:no-magic-numbers
18
+ .add(-180, 'days')
19
+ },
20
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
21
+ },
22
+ {
23
+ __id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1
24
+ }
25
+ );
26
+ console.log('actions found');
27
+
28
+ let i = 0;
29
+ const updateCount = 0;
30
+ let saveRecipeCount = 0;
31
+ await cursor.eachAsync(async (doc) => {
32
+ i += 1;
33
+ const payAction = <Pick<
34
+ chevre.factory.action.trade.pay.IAction,
35
+ 'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus'
36
+ >>doc.toObject();
37
+ const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.payCreditCard>({
38
+ project: { id: payAction.project.id },
39
+ recipeFor: { id: payAction.id }
40
+ });
41
+
42
+ if (actionRecipe !== null) {
43
+ console.log(
44
+ 'actionRecipe already exists. step:',
45
+ actionRecipe.step.length, payAction.project.id, payAction.id, payAction.startDate, i);
46
+ } else {
47
+ const alterTranResultByPayAction = payAction.result?.creditCardSales?.[0];
48
+ console.log(
49
+ 'creating recipe by alterTranResultByPayAction',
50
+ alterTranResultByPayAction?.tranId,
51
+ payAction.project.id, payAction.id, payAction.startDate, i);
52
+ if (alterTranResultByPayAction === undefined) {
53
+ throw new Error('alterTranResultByPayAction undefined');
54
+ }
55
+
56
+ const recipe: chevre.factory.action.trade.pay.IPayCreditCardRecipe & { dateCreated: Date } = {
57
+ project: { id: payAction.project.id, typeOf: chevre.factory.organizationType.Project },
58
+ typeOf: 'Recipe',
59
+ recipeCategory: chevre.factory.recipe.RecipeCategory.payCreditCard,
60
+ recipeFor: { id: payAction.id, typeOf: payAction.typeOf },
61
+ step: [{
62
+ typeOf: 'HowToSection',
63
+ itemListElement: [
64
+ {
65
+ typeOf: 'HowToStep',
66
+ identifier: chevre.factory.recipe.StepIdentifier.searchTrade,
67
+ itemListElement: [{
68
+ typeOf: 'HowToDirection'
69
+ // beforeMedia: (<any>paymentMethodsByTransaction).entryTranArgs,
70
+ // afterMedia: (<any>paymentMethodsByTransaction).entryTranResult
71
+ }]
72
+ },
73
+ {
74
+ typeOf: 'HowToStep',
75
+ identifier: chevre.factory.recipe.StepIdentifier.alterTran,
76
+ itemListElement: [{
77
+ typeOf: 'HowToDirection',
78
+ // beforeMedia: (<any>paymentMethodsByTransaction).execTranArgs,
79
+ ...(alterTranResultByPayAction !== undefined) ? { afterMedia: alterTranResultByPayAction } : undefined
80
+ }]
81
+ }
82
+ ]
83
+ }],
84
+ dateCreated: moment(payAction.endDate)
85
+ .toDate()
86
+ };
87
+ console.log(
88
+ 'saving recipe...',
89
+ payAction.project.id, payAction.id, payAction.startDate, i);
90
+ // console.dir(recipe, { depth: null });
91
+ await actionRepo.saveOneRecipe(recipe);
92
+ saveRecipeCount += 1;
93
+ console.log('recipe saved.', payAction.project.id, payAction.id, payAction.startDate, i);
94
+ }
95
+ });
96
+
97
+ console.log(i, 'transactions checked');
98
+ console.log(updateCount, 'transactions updated');
99
+ console.log(saveRecipeCount, 'recipe saved');
100
+ }
101
+
102
+ main()
103
+ .then()
104
+ .catch(console.error);
@@ -0,0 +1,100 @@
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
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
11
+ const cursor = actionRepo.getCursor(
12
+ {
13
+ typeOf: { $eq: chevre.factory.actionType.PayAction },
14
+ actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
15
+ startDate: {
16
+ $gte: moment()
17
+ // tslint:disable-next-line:no-magic-numbers
18
+ .add(-180, 'days')
19
+ },
20
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
21
+ },
22
+ {
23
+ __id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1
24
+ }
25
+ );
26
+ console.log('actions found');
27
+
28
+ let i = 0;
29
+ const updateCount = 0;
30
+ let saveRecipeCount = 0;
31
+ await cursor.eachAsync(async (doc) => {
32
+ i += 1;
33
+ const payAction = <Pick<
34
+ chevre.factory.action.trade.pay.IAction,
35
+ 'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument'
36
+ >>doc.toObject();
37
+ const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.payMovieTicket>({
38
+ project: { id: payAction.project.id },
39
+ recipeFor: { id: payAction.id }
40
+ });
41
+
42
+ if (actionRecipe !== null) {
43
+ console.log(
44
+ 'actionRecipe already exists. step:',
45
+ actionRecipe.step.length, payAction.project.id, payAction.id, payAction.startDate, i);
46
+ } else {
47
+ const seatInfoSyncInByPayAction = payAction.instrument?.seatInfoSyncIn;
48
+ const seatInfoSyncResultByPayAction = payAction.result?.seatInfoSyncResult;
49
+ console.log(
50
+ 'creating recipe by alterTranResultByPayAction',
51
+ seatInfoSyncInByPayAction?.stCd,
52
+ seatInfoSyncResultByPayAction?.resultInfo.status,
53
+ payAction.project.id, payAction.id, payAction.startDate, i);
54
+ if (seatInfoSyncInByPayAction === undefined) {
55
+ throw new Error('seatInfoSyncInByPayAction undefined');
56
+ }
57
+ if (seatInfoSyncResultByPayAction === undefined) {
58
+ throw new Error('seatInfoSyncResultByPayAction undefined');
59
+ }
60
+
61
+ const recipe: chevre.factory.action.trade.pay.IPayMovieTicketRecipe & { dateCreated: Date } = {
62
+ project: { id: payAction.project.id, typeOf: chevre.factory.organizationType.Project },
63
+ typeOf: 'Recipe',
64
+ recipeCategory: chevre.factory.recipe.RecipeCategory.payMovieTicket,
65
+ recipeFor: { id: payAction.id, typeOf: payAction.typeOf },
66
+ step: [{
67
+ typeOf: 'HowToSection',
68
+ itemListElement: [
69
+ {
70
+ typeOf: 'HowToStep',
71
+ identifier: chevre.factory.recipe.StepIdentifier.seatInfoSync,
72
+ itemListElement: [{
73
+ typeOf: 'HowToDirection',
74
+ beforeMedia: seatInfoSyncInByPayAction,
75
+ afterMedia: seatInfoSyncResultByPayAction
76
+ }]
77
+ }
78
+ ]
79
+ }],
80
+ dateCreated: moment(payAction.endDate)
81
+ .toDate()
82
+ };
83
+ console.log(
84
+ 'saving recipe...',
85
+ payAction.project.id, payAction.id, payAction.startDate, i);
86
+ // console.dir(recipe, { depth: null });
87
+ await actionRepo.saveOneRecipe(recipe);
88
+ saveRecipeCount += 1;
89
+ console.log('recipe saved.', payAction.project.id, payAction.id, payAction.startDate, i);
90
+ }
91
+ });
92
+
93
+ console.log(i, 'transactions checked');
94
+ console.log(updateCount, 'transactions updated');
95
+ console.log(saveRecipeCount, 'recipe saved');
96
+ }
97
+
98
+ main()
99
+ .then()
100
+ .catch(console.error);
@@ -0,0 +1,147 @@
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
+ type IAcceptPayAction = chevre.factory.action.accept.pay.IAction;
10
+
11
+ // tslint:disable-next-line:max-func-body-length
12
+ async function main() {
13
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
+
15
+ const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
+ const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
17
+
18
+ const cursor = transactionRepo.getCursor(
19
+ {
20
+ // 'project.id': { $eq: project.id },
21
+ typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
22
+ status: { $eq: chevre.factory.transactionStatusType.Confirmed },
23
+ startDate: {
24
+ $gte: moment()
25
+ // tslint:disable-next-line:no-magic-numbers
26
+ .add(-30, 'days')
27
+ .toDate()
28
+ }
29
+ },
30
+ {
31
+ startDate: 1,
32
+ project: 1,
33
+ object: 1
34
+ }
35
+ );
36
+ console.log('transactions found');
37
+
38
+ let i = 0;
39
+ let updateCount = 0;
40
+ let saveRecipeCount = 0;
41
+ await cursor.eachAsync(async (doc) => {
42
+ i += 1;
43
+ const placeOrder: Pick<
44
+ chevre.factory.transaction.placeOrder.ITransaction,
45
+ 'startDate' | 'project' | 'object' | 'id'
46
+ > = doc.toObject();
47
+
48
+ const paymentMethodsByTransaction = placeOrder.object.paymentMethods;
49
+ const paymentMethodId4paymentUrl = paymentMethodsByTransaction?.paymentMethodId;
50
+ const alreadyMigrated =
51
+ typeof paymentMethodId4paymentUrl !== 'string'
52
+ || (typeof paymentMethodId4paymentUrl === 'string' && (<any>paymentMethodsByTransaction).entryTranArgs === undefined);
53
+
54
+ if (alreadyMigrated) {
55
+ console.log('already migrated.', placeOrder.project.id, placeOrder.id, placeOrder.startDate, i);
56
+ } else {
57
+ const acceptPayAction = (<Pick<IAcceptPayAction, 'object' | 'result' | 'id' | 'typeOf' | 'endDate'>[]>await actionRepo.search(
58
+ {
59
+ limit: 1,
60
+ page: 1,
61
+ project: { id: { $eq: placeOrder.project.id } },
62
+ typeOf: { $eq: chevre.factory.actionType.AcceptAction },
63
+ actionStatus: { $in: [chevre.factory.actionStatusType.CompletedActionStatus] },
64
+ purpose: { id: { $in: [placeOrder.id] } },
65
+ object: {
66
+ transactionNumber: { $eq: paymentMethodId4paymentUrl },
67
+ typeOf: { $eq: chevre.factory.assetTransactionType.Pay }
68
+ }
69
+ },
70
+ ['object', 'result', 'typeOf', 'endDate'],
71
+ []
72
+ )).shift();
73
+
74
+ if (acceptPayAction !== undefined) {
75
+ const actionRecipe = await actionRepo.findRecipeByAction({
76
+ project: { id: placeOrder.project.id },
77
+ recipeFor: { id: acceptPayAction.id }
78
+ });
79
+ if (actionRecipe !== null) {
80
+ console.log(
81
+ 'actionRecipe already exists. step:',
82
+ actionRecipe.step.length, placeOrder.project.id, placeOrder.id, placeOrder.startDate, i);
83
+
84
+ // 取引から冗長な属性を削除
85
+ if ((<any>paymentMethodsByTransaction).entryTranArgs !== undefined) {
86
+ await transactionRepo.findByIdAndUpdate4migrate({
87
+ id: placeOrder.id,
88
+ update: {
89
+ $set: { 'object.paymentMethods': { paymentMethodId: paymentMethodId4paymentUrl } }
90
+ }
91
+ });
92
+ updateCount += 1;
93
+ }
94
+ } else {
95
+ const recipe: chevre.factory.action.accept.pay.IRecipe & { dateCreated: Date } = {
96
+ project: { id: placeOrder.project.id, typeOf: chevre.factory.organizationType.Project },
97
+ typeOf: 'Recipe',
98
+ recipeCategory: chevre.factory.recipe.RecipeCategory.publishPaymentUrl,
99
+ recipeFor: { id: acceptPayAction.id, typeOf: acceptPayAction.typeOf },
100
+ step: [{
101
+ typeOf: 'HowToSection',
102
+ itemListElement: [
103
+ {
104
+ typeOf: 'HowToStep',
105
+ identifier: chevre.factory.recipe.StepIdentifier.entryTran,
106
+ itemListElement: [{
107
+ typeOf: 'HowToDirection',
108
+ beforeMedia: (<any>paymentMethodsByTransaction).entryTranArgs,
109
+ afterMedia: (<any>paymentMethodsByTransaction).entryTranResult
110
+ }]
111
+ },
112
+ {
113
+ typeOf: 'HowToStep',
114
+ identifier: chevre.factory.recipe.StepIdentifier.execTran,
115
+ itemListElement: [{
116
+ typeOf: 'HowToDirection',
117
+ beforeMedia: (<any>paymentMethodsByTransaction).execTranArgs,
118
+ afterMedia: (<any>paymentMethodsByTransaction).execTranResult
119
+ }]
120
+ }
121
+ ]
122
+ }],
123
+ dateCreated: moment(acceptPayAction.endDate)
124
+ .toDate()
125
+ };
126
+ console.log(
127
+ 'saving recipe...',
128
+ placeOrder.project.id, placeOrder.id, placeOrder.startDate, i);
129
+ // console.dir(recipe, { depth: null });
130
+ await actionRepo.saveOneRecipe(recipe);
131
+ saveRecipeCount += 1;
132
+ console.log('recipe saved.', placeOrder.project.id, placeOrder.id, placeOrder.startDate, i);
133
+ }
134
+ } else {
135
+ console.log('acceptPayAction does not exist.', placeOrder.project.id, placeOrder.id, placeOrder.startDate, i);
136
+ }
137
+ }
138
+ });
139
+
140
+ console.log(i, 'transactions checked');
141
+ console.log(updateCount, 'transactions updated');
142
+ console.log(saveRecipeCount, 'recipe saved');
143
+ }
144
+
145
+ main()
146
+ .then()
147
+ .catch(console.error);
@@ -0,0 +1,37 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ function onTransactionStatusChangedListener() {
9
+ return async (params: {
10
+ /**
11
+ * 取引ID
12
+ */
13
+ id: string;
14
+ typeOf: chevre.factory.assetTransactionType;
15
+ status: chevre.factory.transactionStatusType;
16
+ }) => {
17
+ const { id, typeOf, status } = params;
18
+ console.log('transactionStatusChanged.', id, typeOf, status);
19
+ };
20
+ }
21
+
22
+ chevre.eventEmitter.assetTransaction.onAssetTransactionStatusChanged(onTransactionStatusChangedListener());
23
+
24
+ async function main() {
25
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
26
+
27
+ const transactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
28
+
29
+ const result = await transactionRepo.reexportTasksByExportAction({
30
+ intervalInMinutes: 10
31
+ });
32
+ console.log('reexported', result);
33
+ }
34
+
35
+ main()
36
+ .then()
37
+ .catch(console.error);
@@ -14,7 +14,8 @@ async function main() {
14
14
 
15
15
  const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
16
16
  const actions = await actionRepo.searchBySameAs({
17
- sameAs: { id: { $eq: '662456a40e9f9ad3b50f1481' } }
17
+ sameAs: { id: { $eq: '662456a40e9f9ad3b50f1481' } },
18
+ typeOf: { $eq: chevre.factory.actionType.AuthorizeAction }
18
19
  });
19
20
  console.log('actions:', actions);
20
21
  }
@@ -10,22 +10,42 @@ async function main() {
10
10
 
11
11
  const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
12
12
 
13
- const mkknInfos = await actionRepo.searchMkknInfoByCheckMovieTicketResult({
13
+ let mkknInfos = await actionRepo.searchMkknInfoByCheckMovieTicketResult({
14
14
  limit: 10,
15
15
  page: 1,
16
- id: '664db85f9801179aabb046e8',
16
+ id: '666171386c7acb70fd9a44ec',
17
17
  project: { id: project.id },
18
- purpose: { id: '664db8219801179aabb04624' }
18
+ purpose: { id: '6661712a6c7acb70fd9a44a8' }
19
19
  });
20
20
  console.log('mkknInfos found', mkknInfos);
21
21
  console.log(mkknInfos.length, 'infos found');
22
22
 
23
- const ykknInfos = await actionRepo.searchYkknInfoByCheckMovieTicketResult({
23
+ mkknInfos = await actionRepo.searchMkknInfoByCheckRecipe({
24
24
  limit: 10,
25
25
  page: 1,
26
- id: '664db85f9801179aabb046e8',
26
+ id: '666171386c7acb70fd9a44ec',
27
27
  project: { id: project.id },
28
- purpose: { id: '664db8219801179aabb04624' }
28
+ purpose: { id: '6661712a6c7acb70fd9a44a8' }
29
+ });
30
+ console.log('mkknInfos found', mkknInfos);
31
+ console.log(mkknInfos.length, 'infos found');
32
+
33
+ let ykknInfos = await actionRepo.searchYkknInfoByCheckMovieTicketResult({
34
+ limit: 10,
35
+ page: 1,
36
+ id: '666171386c7acb70fd9a44ec',
37
+ project: { id: project.id },
38
+ purpose: { id: '6661712a6c7acb70fd9a44a8' }
39
+ });
40
+ console.log('ykknInfos found', ykknInfos);
41
+ console.log(ykknInfos.length, 'infos found');
42
+
43
+ ykknInfos = await actionRepo.searchYkknInfoByCheckRecipe({
44
+ limit: 10,
45
+ page: 1,
46
+ id: '666171386c7acb70fd9a44ec',
47
+ project: { id: project.id },
48
+ purpose: { id: '6661712a6c7acb70fd9a44a8' }
29
49
  });
30
50
  console.log('ykknInfos found', ykknInfos);
31
51
  console.log(ykknInfos.length, 'infos found');
@@ -26,7 +26,7 @@ async function main() {
26
26
  // orderNumbers: ['CIN3-0760465-8981560']
27
27
  // }
28
28
  // },
29
- tasksExportAction: { actionStatus: { $eq: chevre.factory.actionStatusType.PotentialActionStatus } },
29
+ // tasksExportAction: { actionStatus: { $eq: chevre.factory.actionStatusType.PotentialActionStatus } },
30
30
  inclusion: ['_id'],
31
31
  exclusion: []
32
32
  });
@@ -9,26 +9,11 @@ async function main() {
9
9
 
10
10
  let updateResult: any;
11
11
 
12
- const aggregationRepo = await chevre.repository.Aggregation.createInstance(mongoose.connection);
13
- const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
12
+ const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
14
13
 
15
- updateResult = await aggregationRepo.unsetUnnecessaryFields({
14
+ updateResult = await assetTransactionRepo.unsetUnnecessaryFields({
16
15
  filter: {
17
- _id: { $exists: true }
18
- },
19
- $unset: {
20
- __v: 1,
21
- createdAt: 1,
22
- updatedAt: 1
23
- }
24
- });
25
- console.log('unset processed.', updateResult);
26
-
27
- updateResult = await taskRepo.unsetUnnecessaryFields({
28
- filter: {
29
- // _id: { $exists: true },
30
- name: { $nin: ['deleteTransaction'] },
31
- runsAt: {
16
+ startDate: {
32
17
  $gte: moment()
33
18
  .add(-1, 'days')
34
19
  .toDate()
@@ -59,11 +59,13 @@ export interface ICancelActionAction {
59
59
  typeOf: 'Task';
60
60
  };
61
61
  }
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 : never;
62
63
  /**
63
64
  * アクションリポジトリ
64
65
  */
65
66
  export declare class MongoRepository {
66
67
  private readonly actionModel;
68
+ private readonly actionRecipeModel;
67
69
  constructor(connection: Connection);
68
70
  static CREATE_MONGO_CONDITIONS(params: factory.action.ISearchConditions): any[];
69
71
  /**
@@ -185,6 +187,12 @@ export declare class MongoRepository {
185
187
  $eq: string;
186
188
  };
187
189
  };
190
+ /**
191
+ * 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
192
+ */
193
+ typeOf: {
194
+ $eq: factory.actionType;
195
+ };
188
196
  }): Promise<Pick<IAction<factory.actionType>, 'id' | 'actionStatus' | 'error' | 'purpose'>[]>;
189
197
  deleteByProject(params: {
190
198
  project: {
@@ -245,6 +253,38 @@ export declare class MongoRepository {
245
253
  }): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.INvalidTicket & {
246
254
  knyknrNo: string;
247
255
  })[]>;
256
+ searchYkknInfoByCheckRecipe(filter: {
257
+ limit: number;
258
+ page: number;
259
+ /**
260
+ * 認証アクションID
261
+ */
262
+ id: string;
263
+ project: {
264
+ id: string;
265
+ };
266
+ purpose: {
267
+ id: string;
268
+ };
269
+ }): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.IValidTicket & {
270
+ knyknrNo: string;
271
+ })[]>;
272
+ searchMkknInfoByCheckRecipe(filter: {
273
+ limit: number;
274
+ page: number;
275
+ /**
276
+ * 認証アクションID
277
+ */
278
+ id: string;
279
+ project: {
280
+ id: string;
281
+ };
282
+ purpose: {
283
+ id: string;
284
+ };
285
+ }): Promise<(surfrockFactory.service.auth.purchaseNumberAuth.INvalidTicket & {
286
+ knyknrNo: string;
287
+ })[]>;
248
288
  /**
249
289
  * 開始日時を一定期間過ぎたアクションを削除する
250
290
  */
@@ -274,6 +314,17 @@ export declare class MongoRepository {
274
314
  }): Promise<{
275
315
  deletedCount?: number;
276
316
  } | null>;
317
+ saveOneRecipe(savingRecipe: factory.recipe.IRecipe & {
318
+ dateCreated?: Date;
319
+ }): Promise<import("mongodb").InsertManyResult<any>>;
320
+ findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: {
321
+ project: {
322
+ id: string;
323
+ };
324
+ recipeFor: {
325
+ id: string;
326
+ };
327
+ }): Promise<Pick<IActionRecipe<T>, 'step' | 'recipeCategory'> | null>;
277
328
  aggregateAuthorizeEventServiceOfferAction(params: {
278
329
  project?: {
279
330
  id?: {