@chevre/domain 22.5.0-alpha.9 → 22.5.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 (155) hide show
  1. package/example/src/chevre/activateOptionalAggregationSettings.ts +19 -0
  2. package/example/src/chevre/aggregateAllEvents2.ts +7 -5
  3. package/example/src/chevre/aggregateEventPublicFields.ts +47 -0
  4. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +32 -0
  5. package/example/src/chevre/findReservationByCode.ts +11 -10
  6. package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +101 -0
  7. package/example/src/chevre/migrateProjectMakesOfferAvailableAt.ts +85 -0
  8. package/example/src/chevre/person/cleanUpCognitoUsers.ts +90 -0
  9. package/example/src/chevre/searchCategoryCodesByAggregate.ts +1 -2
  10. package/example/src/chevre/searchProjects.ts +2 -4
  11. package/example/src/chevre/searchSellersByAggregate.ts +4 -6
  12. package/example/src/chevre/unsetUnnecessaryFields.ts +17 -19
  13. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +25 -14
  14. package/example/src/chevre/upsertProductsByProductId.ts +1 -1
  15. package/example/src/createMongooseConnection.ts +26 -0
  16. package/lib/chevre/repo/action.d.ts +41 -41
  17. package/lib/chevre/repo/action.js +5 -39
  18. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  19. package/lib/chevre/repo/categoryCode.d.ts +4 -8
  20. package/lib/chevre/repo/categoryCode.js +8 -36
  21. package/lib/chevre/repo/creativeWork.js +1 -20
  22. package/lib/chevre/repo/customer.d.ts +1 -1
  23. package/lib/chevre/repo/customer.js +4 -4
  24. package/lib/chevre/repo/event.d.ts +21 -12
  25. package/lib/chevre/repo/event.js +135 -37
  26. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +54 -0
  27. package/lib/chevre/repo/eventSellerMakesOffer.js +73 -0
  28. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -3
  29. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +0 -3
  30. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +0 -3
  31. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +0 -3
  32. package/lib/chevre/repo/mongoose/schemas/customer.js +0 -3
  33. package/lib/chevre/repo/mongoose/schemas/event.js +9 -54
  34. package/lib/chevre/repo/mongoose/schemas/member.js +0 -3
  35. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -3
  36. package/lib/chevre/repo/mongoose/schemas/paymentService.js +0 -3
  37. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +0 -3
  38. package/lib/chevre/repo/mongoose/schemas/productModel.js +0 -3
  39. package/lib/chevre/repo/mongoose/schemas/project.js +0 -3
  40. package/lib/chevre/repo/mongoose/schemas/reservation.js +0 -3
  41. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -3
  42. package/lib/chevre/repo/mongoose/schemas/trip.js +0 -3
  43. package/lib/chevre/repo/paymentService.d.ts +1 -1
  44. package/lib/chevre/repo/paymentService.js +0 -19
  45. package/lib/chevre/repo/place/movieTheater.js +1 -25
  46. package/lib/chevre/repo/product.js +1 -6
  47. package/lib/chevre/repo/project.d.ts +8 -2
  48. package/lib/chevre/repo/project.js +25 -26
  49. package/lib/chevre/repo/projectMakesOffer.d.ts +3 -1
  50. package/lib/chevre/repo/projectMakesOffer.js +5 -2
  51. package/lib/chevre/repo/role.js +0 -7
  52. package/lib/chevre/repo/seller.d.ts +18 -16
  53. package/lib/chevre/repo/seller.js +13 -31
  54. package/lib/chevre/repo/task.d.ts +12 -12
  55. package/lib/chevre/repo/transaction.d.ts +1 -1
  56. package/lib/chevre/repository.d.ts +5 -0
  57. package/lib/chevre/repository.js +15 -2
  58. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +4 -18
  59. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +28 -13
  60. package/lib/chevre/service/aggregation/project.js +1 -2
  61. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -4
  62. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  63. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -1
  64. package/lib/chevre/service/assetTransaction/reserve/start.js +11 -38
  65. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +4 -1
  66. package/lib/chevre/service/event.js +2 -2
  67. package/lib/chevre/service/moneyTransfer.js +1 -2
  68. package/lib/chevre/service/notification.d.ts +2 -4
  69. package/lib/chevre/service/notification.js +30 -9
  70. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -1
  71. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  72. package/lib/chevre/service/offer/event/authorize.d.ts +2 -1
  73. package/lib/chevre/service/offer/event/authorize.js +2 -2
  74. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  75. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -30
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +21 -113
  77. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +38 -0
  78. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +97 -0
  79. package/lib/chevre/service/offer/event/searchOffersByIds.js +26 -20
  80. package/lib/chevre/service/offer/event.d.ts +2 -1
  81. package/lib/chevre/service/offer/event.js +2 -1
  82. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  83. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +1 -1
  84. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +4 -4
  85. package/lib/chevre/service/offer/onEventChanged.d.ts +1 -13
  86. package/lib/chevre/service/offer/onEventChanged.js +64 -71
  87. package/lib/chevre/service/offer.d.ts +6 -0
  88. package/lib/chevre/service/offer.js +12 -15
  89. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  90. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +7 -8
  91. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  92. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +7 -8
  93. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +8 -11
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +7 -8
  96. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +1 -4
  97. package/lib/chevre/service/order/onOrderUpdated/factory.js +4 -7
  98. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
  99. package/lib/chevre/service/order/placeOrder.js +1 -1
  100. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  101. package/lib/chevre/service/payment/any.js +1 -1
  102. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
  103. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +0 -3
  104. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  105. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
  106. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  107. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +50 -57
  108. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  109. package/lib/chevre/service/payment/paymentCard.js +0 -5
  110. package/lib/chevre/service/payment.d.ts +1 -1
  111. package/lib/chevre/service/report/telemetry.js +1 -1
  112. package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
  113. package/lib/chevre/service/reserve/cancelReservation.js +14 -6
  114. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  115. package/lib/chevre/service/reserve/factory.d.ts +2 -61
  116. package/lib/chevre/service/reserve/factory.js +0 -11
  117. package/lib/chevre/service/reserve/findByCode.js +0 -1
  118. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.d.ts +19 -0
  119. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +64 -0
  120. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -4
  121. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +37 -61
  122. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +22 -76
  123. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +26 -28
  124. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +0 -3
  125. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +17 -50
  126. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.d.ts +18 -0
  127. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +66 -0
  128. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  129. package/lib/chevre/service/reserve/useReservation.js +4 -4
  130. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -7
  131. package/lib/chevre/service/reserve/verifyToken4reservation.js +17 -12
  132. package/lib/chevre/service/task/aggregateScreeningEvent.js +4 -2
  133. package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +1 -1
  134. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +1 -5
  135. package/lib/chevre/service/task/deletePerson.d.ts +6 -0
  136. package/lib/chevre/service/task/deletePerson.js +420 -0
  137. package/lib/chevre/service/task/handleNotification.d.ts +3 -0
  138. package/lib/chevre/service/task/handleNotification.js +26 -0
  139. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  140. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  141. package/lib/chevre/service/task/triggerWebhook.js +2 -2
  142. package/lib/chevre/service/task.d.ts +3 -0
  143. package/lib/chevre/service/task.js +2 -0
  144. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  145. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +1 -3
  146. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +4 -2
  147. package/lib/chevre/service/transaction/returnOrder/preStart.js +4 -3
  148. package/lib/chevre/settings/aggregation.d.ts +23 -0
  149. package/lib/chevre/settings/aggregation.js +17 -0
  150. package/lib/chevre/settings.d.ts +52 -38
  151. package/lib/chevre/settings.js +12 -13
  152. package/package.json +5 -7
  153. package/example/src/chevre/migratePayTransactionRecipes.ts +0 -252
  154. package/example/src/chevre/migrateProductHasOfferCatalog.ts +0 -80
  155. package/example/src/chevre/migrateProjectMakesOffer.ts +0 -78
@@ -1,23 +1,45 @@
1
1
  import * as factory from './factory';
2
- export declare const MONGO_MAX_TIME_MS: number;
3
- export declare const MONGO_READ_PREFERENCE: string;
4
- export declare const MONGO_AUTO_INDEX: boolean;
2
+ import { AggregationSettings, ICallableTaskOperation, ICallResult, IOperationExecute } from './settings/aggregation';
3
+ interface IOnOrderStatusChanged {
4
+ /**
5
+ * AggService通知先
6
+ */
7
+ informOrder?: factory.project.IInformParams[];
8
+ }
9
+ interface IOnReservationStatusChanged {
10
+ /**
11
+ * AggService通知先
12
+ */
13
+ informReservation?: factory.project.IInformParams[];
14
+ }
15
+ interface IWebhookSettings {
16
+ /**
17
+ * リクエストタイムアウト
18
+ */
19
+ timeout: number;
20
+ useFetchAPI: boolean;
21
+ /**
22
+ * 通知署名の鍵
23
+ */
24
+ secretKey?: string;
25
+ /**
26
+ * 固有署名ヘッダー識別子
27
+ */
28
+ headerIdentifier?: string;
29
+ }
30
+ interface IOnEventChanged {
31
+ informEvent?: factory.project.IInformParams[];
32
+ informEvent2agg?: factory.project.IInformParams[];
33
+ }
5
34
  interface IOptions {
6
- onOrderStatusChanged: factory.project.IOnOrderStatusChanged;
7
- onEventChanged: {
8
- informEvent?: factory.project.IInformParams[];
9
- };
10
- onReservationStatusChanged: {
11
- informReservation?: factory.project.IInformParams[];
12
- };
35
+ onOrderStatusChanged: IOnOrderStatusChanged;
36
+ onEventChanged: IOnEventChanged;
37
+ onReservationStatusChanged: IOnReservationStatusChanged;
13
38
  onResourceUpdated: {
14
39
  informResource?: factory.project.IInformParams[];
15
40
  };
16
41
  userPoolIdOld: string;
17
42
  userPoolIdNew: string;
18
- useAggregateEntranceGateProjects: string[];
19
- useAggregateOfferProjects: string[];
20
- useOfferRateLimitProjects: string[];
21
43
  abortedTasksWithoutReport: string[];
22
44
  numTryConfirmReserveTransaction: number;
23
45
  transaction: {
@@ -52,36 +74,27 @@ interface IOptions {
52
74
  * 認証時タイムアウト
53
75
  */
54
76
  timeoutCheck: number;
55
- };
56
- useAssetTransactionSyncProcessing: boolean;
57
- useExperimentalFeature: boolean;
58
- notification: {
59
77
  /**
60
- * リクエストタイムアウト
78
+ * 決済と返金の最小間隔(ms)
61
79
  */
62
- timeout: number;
63
- useFetchAPI: boolean;
80
+ minIntervalBetweenPayAndRefund: number;
64
81
  };
82
+ useAssetTransactionSyncProcessing: boolean;
83
+ useExperimentalFeature: boolean;
84
+ notification: IWebhookSettings;
65
85
  }
66
86
  /**
67
87
  * domain settings
68
88
  */
69
89
  declare class Settings {
70
- readonly onOrderStatusChanged: factory.project.IOnOrderStatusChanged;
71
- readonly onEventChanged: {
72
- informEvent?: factory.project.IInformParams[];
73
- };
74
- readonly onReservationStatusChanged: {
75
- informReservation?: factory.project.IInformParams[];
76
- };
90
+ readonly onOrderStatusChanged: IOnOrderStatusChanged;
91
+ readonly onEventChanged: IOnEventChanged;
92
+ readonly onReservationStatusChanged: IOnReservationStatusChanged;
77
93
  readonly onResourceUpdated: {
78
94
  informResource?: factory.project.IInformParams[];
79
95
  };
80
96
  readonly userPoolIdOld: string;
81
97
  readonly userPoolIdNew: string;
82
- readonly useAggregateEntranceGateProjects: string[];
83
- readonly useAggregateOfferProjects: string[];
84
- readonly useOfferRateLimitProjects: string[];
85
98
  readonly abortedTasksWithoutReport: string[];
86
99
  readonly numTryConfirmReserveTransaction: number;
87
100
  readonly transaction: {
@@ -119,19 +132,20 @@ declare class Settings {
119
132
  * 認証時タイムアウト
120
133
  */
121
134
  timeoutCheck: number;
135
+ /**
136
+ * 決済と返金の最小間隔(ms)
137
+ */
138
+ minIntervalBetweenPayAndRefund: number;
122
139
  };
123
140
  readonly useAssetTransactionSyncProcessing: boolean;
124
141
  readonly useExperimentalFeature: boolean;
125
142
  /**
126
143
  * 通知設定
127
144
  */
128
- readonly notification: {
129
- /**
130
- * リクエストタイムアウト
131
- */
132
- timeout: number;
133
- useFetchAPI: boolean;
134
- };
145
+ readonly notification: IWebhookSettings;
135
146
  constructor(options: IOptions);
136
147
  }
137
- export { Settings };
148
+ export declare const MONGO_MAX_TIME_MS: number;
149
+ export declare const MONGO_READ_PREFERENCE: string;
150
+ export declare const MONGO_AUTO_INDEX: boolean;
151
+ export { AggregationSettings, Settings, ICallableTaskOperation, ICallResult, IOperationExecute, IWebhookSettings };
@@ -1,29 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
4
- exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
5
- ? Number(process.env.MONGO_MAX_TIME_MS)
6
- // tslint:disable-next-line:no-magic-numbers
7
- : 10000;
8
- exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 'string')
9
- ? process.env.MONGO_READ_PREFERENCE
10
- : 'primaryPreferred';
11
- exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
3
+ exports.Settings = exports.AggregationSettings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
4
+ const aggregation_1 = require("./settings/aggregation");
5
+ Object.defineProperty(exports, "AggregationSettings", { enumerable: true, get: function () { return aggregation_1.AggregationSettings; } });
12
6
  /**
13
7
  * domain settings
14
8
  */
15
9
  class Settings {
16
10
  constructor(options) {
17
- const { onEventChanged, onOrderStatusChanged, onResourceUpdated, onReservationStatusChanged, userPoolIdOld, userPoolIdNew, useAggregateEntranceGateProjects, useAggregateOfferProjects, useOfferRateLimitProjects, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
11
+ const { onEventChanged, onOrderStatusChanged, onResourceUpdated, onReservationStatusChanged, userPoolIdOld, userPoolIdNew, abortedTasksWithoutReport, numTryConfirmReserveTransaction, transaction, defaultSenderEmail, deliverOrderLimit, coa, gmo, movieticketReserve, useAssetTransactionSyncProcessing, useExperimentalFeature, notification } = options;
18
12
  this.onEventChanged = onEventChanged;
19
13
  this.onOrderStatusChanged = onOrderStatusChanged;
20
14
  this.onResourceUpdated = onResourceUpdated;
21
15
  this.onReservationStatusChanged = onReservationStatusChanged;
22
16
  this.userPoolIdOld = userPoolIdOld;
23
17
  this.userPoolIdNew = userPoolIdNew;
24
- this.useAggregateEntranceGateProjects = useAggregateEntranceGateProjects;
25
- this.useAggregateOfferProjects = useAggregateOfferProjects;
26
- this.useOfferRateLimitProjects = useOfferRateLimitProjects;
27
18
  this.abortedTasksWithoutReport = abortedTasksWithoutReport;
28
19
  this.numTryConfirmReserveTransaction = numTryConfirmReserveTransaction;
29
20
  this.transaction = transaction;
@@ -38,3 +29,11 @@ class Settings {
38
29
  }
39
30
  }
40
31
  exports.Settings = Settings;
32
+ exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
33
+ ? Number(process.env.MONGO_MAX_TIME_MS)
34
+ // tslint:disable-next-line:no-magic-numbers
35
+ : 10000;
36
+ exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 'string')
37
+ ? process.env.MONGO_READ_PREFERENCE
38
+ : 'primaryPreferred';
39
+ exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
package/package.json CHANGED
@@ -9,8 +9,10 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.386.0-alpha.2",
13
- "@cinerino/sdk": "10.12.0-alpha.2",
12
+ "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
+ "@aws-sdk/credential-providers": "3.600.0",
14
+ "@chevre/factory": "4.388.0",
15
+ "@cinerino/sdk": "10.16.0-alpha.5",
14
16
  "@motionpicture/coa-service": "9.5.0",
15
17
  "@motionpicture/gmo-service": "5.3.0",
16
18
  "@sendgrid/mail": "6.4.0",
@@ -30,8 +32,6 @@
30
32
  },
31
33
  "description": "Chevre Domain Library for Node.js",
32
34
  "devDependencies": {
33
- "@aws-sdk/client-cognito-identity-provider": "3.600.0",
34
- "@aws-sdk/credential-providers": "3.600.0",
35
35
  "@types/debug": "0.0.30",
36
36
  "@types/google-libphonenumber": "^7.4.19",
37
37
  "@types/http-status": "^0.2.30",
@@ -65,8 +65,6 @@
65
65
  "typescript": "5.0.3"
66
66
  },
67
67
  "peerDependencies": {
68
- "@aws-sdk/client-cognito-identity-provider": "^3.600.0",
69
- "@aws-sdk/credential-providers": "^3.600.0",
70
68
  "mongoose": "^7.4.0",
71
69
  "redis": "^4.6.5"
72
70
  },
@@ -110,5 +108,5 @@
110
108
  "postversion": "git push origin --tags",
111
109
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
110
  },
113
- "version": "22.5.0-alpha.9"
111
+ "version": "22.5.0"
114
112
  }
@@ -1,252 +0,0 @@
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
- // tslint:disable-next-line:max-func-body-length
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
12
- const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
13
- const cursor = assetTransactionRepo.getCursor(
14
- {
15
- // transactionNumber: { $eq: '792921546706869' },
16
- typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
17
- status: { $eq: chevre.factory.transactionStatusType.Confirmed },
18
- startDate: {
19
- // $lte: moment()
20
- // // tslint:disable-next-line:no-magic-numbers
21
- // .add(-28, 'days'),
22
- $gte: moment()
23
- // tslint:disable-next-line:no-magic-numbers
24
- .add(-180, 'days')
25
- },
26
- 'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
27
- },
28
- {
29
- __id: 1, startDate: 1, object: 1, project: 1, typeOf: 1, status: 1, transactionNumber: 1
30
- }
31
- );
32
- console.log('transactions found');
33
-
34
- let i = 0;
35
- let updateCount = 0;
36
- let saveRecipeCount = 0;
37
- let saveActionCount = 0;
38
- // tslint:disable-next-line:max-func-body-length
39
- await cursor.eachAsync(async (doc) => {
40
- i += 1;
41
- const payTransaction = <Pick<
42
- chevre.factory.assetTransaction.pay.ITransaction,
43
- 'id' | 'startDate' | 'object' | 'project' | 'typeOf' | 'status' | 'transactionNumber'
44
- >>doc.toObject();
45
- let authorizeInvoiceAction: chevre.factory.action.authorize.invoice.IAction | undefined;
46
- authorizeInvoiceAction = (<chevre.factory.action.authorize.invoice.IAction[]>await actionRepo.search(
47
- {
48
- limit: 1,
49
- page: 1,
50
- project: { id: { $eq: payTransaction.project.id } },
51
- sameAs: { id: { $eq: payTransaction.id } },
52
- object: {
53
- typeOf: { $eq: 'Invoice' },
54
- paymentMethodId: { $eq: payTransaction.transactionNumber }
55
- },
56
- typeOf: { $eq: chevre.factory.actionType.AuthorizeAction }
57
- },
58
- [],
59
- []
60
- )).shift();
61
- // authorizeInvoiceAction = undefined;
62
-
63
- const entryTranArgs: chevre.factory.action.authorize.invoice.IEntryTranArgs = (<any>payTransaction.object).entryTranArgs;
64
- const entryTranResult: chevre.factory.action.authorize.invoice.IEntryTranResult = (<any>payTransaction.object).entryTranResult;
65
- const execTranArgs: chevre.factory.action.authorize.invoice.IExecTranArgs = (<any>payTransaction.object).execTranArgs;
66
- const execTranResult: chevre.factory.action.authorize.invoice.IExecTranResult = (<any>payTransaction.object).execTranResult;
67
- const secureTran2Result: chevre.factory.action.authorize.invoice.ISecureTran2Result =
68
- (<any>payTransaction.object).secureTran2Result;
69
-
70
- if (authorizeInvoiceAction !== undefined) {
71
- console.log(
72
- 'authorizeInvoiceAction already exists. step:',
73
- authorizeInvoiceAction.object.paymentMethodId,
74
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i,
75
- updateCount, saveRecipeCount, saveActionCount
76
- );
77
-
78
- const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.checkMovieTicket>({
79
- project: { id: authorizeInvoiceAction.project.id },
80
- recipeFor: { id: authorizeInvoiceAction.id }
81
- });
82
-
83
- if (actionRecipe !== null) {
84
- console.log(
85
- 'actionRecipe already exists. step:',
86
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i,
87
- updateCount, saveRecipeCount, saveActionCount
88
- );
89
-
90
- // optimize payTransaction.object
91
- let unsetResult: any;
92
- if (secureTran2Result !== undefined) {
93
- unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
94
- filter: { _id: { $eq: payTransaction.id } },
95
- $unset: {
96
- 'object.entryTranArgs': 1,
97
- 'object.entryTranResult': 1,
98
- 'object.execTranArgs': 1,
99
- 'object.execTranResult': 1,
100
- 'object.secureTran2Result': 1
101
- }
102
- });
103
- updateCount += 1;
104
- } else if (entryTranArgs !== undefined && execTranResult !== undefined) {
105
- unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
106
- filter: { _id: { $eq: payTransaction.id } },
107
- $unset: {
108
- 'object.entryTranArgs': 1,
109
- 'object.entryTranResult': 1,
110
- 'object.execTranArgs': 1,
111
- 'object.execTranResult': 1
112
- }
113
- });
114
- updateCount += 1;
115
- }
116
- console.log(
117
- 'result unset. unsetResult:', unsetResult,
118
- actionRecipe.step.length,
119
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
120
- );
121
- } else {
122
- console.log(
123
- 'creating recipe...',
124
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
125
- );
126
- if (entryTranArgs === undefined) {
127
- throw new Error('entryTranArgs undefined');
128
- }
129
- if (entryTranResult === undefined) {
130
- throw new Error('entryTranResult undefined');
131
- }
132
- if (execTranArgs === undefined) {
133
- throw new Error('execTranArgs undefined');
134
- }
135
- if (execTranResult === undefined) {
136
- throw new Error('execTranResult undefined');
137
- }
138
-
139
- let recipe: (chevre.factory.action.authorize.invoice.IAuthorizeInvoiceRecipe
140
- | chevre.factory.action.authorize.invoice.IAuthorizeInvoice3dsRecipe) & {
141
- recipeFor: { id: string; typeOf: chevre.factory.actionType };
142
- dateCreated: Date;
143
- dateModified: Date;
144
- };
145
- if (secureTran2Result !== undefined) {
146
- recipe = {
147
- project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
148
- typeOf: 'Recipe',
149
- recipeCategory: chevre.factory.recipe.RecipeCategory.authorizeInvoice3ds,
150
- recipeFor: { id: authorizeInvoiceAction.id, typeOf: authorizeInvoiceAction.typeOf },
151
- step: [{
152
- typeOf: 'HowToSection',
153
- itemListElement: [
154
- {
155
- typeOf: 'HowToStep',
156
- identifier: chevre.factory.recipe.StepIdentifier.secureTran2,
157
- itemListElement: [{
158
- typeOf: 'HowToDirection',
159
- afterMedia: secureTran2Result
160
- }]
161
- }
162
- ]
163
- }],
164
- dateCreated: moment(authorizeInvoiceAction.endDate)
165
- .toDate(),
166
- dateModified: moment(authorizeInvoiceAction.endDate)
167
- .toDate()
168
- };
169
- } else {
170
- recipe = {
171
- project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
172
- typeOf: 'Recipe',
173
- recipeCategory: chevre.factory.recipe.RecipeCategory.authorizeInvoice,
174
- recipeFor: { id: authorizeInvoiceAction.id, typeOf: authorizeInvoiceAction.typeOf },
175
- step: [{
176
- typeOf: 'HowToSection',
177
- itemListElement: [
178
- {
179
- typeOf: 'HowToStep',
180
- identifier: chevre.factory.recipe.StepIdentifier.entryTran,
181
- itemListElement: [{
182
- typeOf: 'HowToDirection',
183
- beforeMedia: entryTranArgs,
184
- afterMedia: entryTranResult
185
- }]
186
- },
187
- {
188
- typeOf: 'HowToStep',
189
- identifier: chevre.factory.recipe.StepIdentifier.execTran,
190
- itemListElement: [{
191
- typeOf: 'HowToDirection',
192
- beforeMedia: execTranArgs,
193
- afterMedia: execTranResult
194
- }]
195
- }
196
- ]
197
- }],
198
- dateCreated: moment(authorizeInvoiceAction.endDate)
199
- .toDate(),
200
- dateModified: moment(authorizeInvoiceAction.endDate)
201
- .toDate()
202
- };
203
- }
204
- console.log(
205
- 'saving recipe...',
206
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
207
- // tslint:disable-next-line:no-null-keyword
208
- console.dir(recipe, { depth: null });
209
- await actionRepo.saveRecipeWithDateCreated(recipe);
210
- saveRecipeCount += 1;
211
- console.log('recipe saved.', payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
212
- }
213
- } else {
214
- const creatingAction: Omit<chevre.factory.action.authorize.invoice.IAction, 'id'> = {
215
- project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
216
- typeOf: chevre.factory.actionType.AuthorizeAction,
217
- agent: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
218
- object: {
219
- typeOf: 'Invoice',
220
- paymentMethodId: payTransaction.transactionNumber
221
- },
222
- startDate: moment(payTransaction.startDate)
223
- .toDate(),
224
- endDate: moment(payTransaction.startDate)
225
- .toDate(),
226
- actionStatus: chevre.factory.actionStatusType.CompletedActionStatus,
227
- result: {},
228
- sameAs: { id: payTransaction.id, typeOf: payTransaction.typeOf }
229
- };
230
- console.log(
231
- 'creating action...',
232
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
233
- );
234
- // tslint:disable-next-line:no-null-keyword
235
- console.dir(creatingAction, { depth: null });
236
- const saveActionResult = await actionRepo.saveActionWithEndDate(creatingAction);
237
- saveActionCount += 1;
238
- console.log(
239
- 'action saved.', saveActionResult,
240
- payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
241
- }
242
- });
243
-
244
- console.log(i, 'transactions checked');
245
- console.log(updateCount, 'transactions updated');
246
- console.log(saveRecipeCount, 'recipe saved');
247
- console.log(saveActionCount, 'action saved');
248
- }
249
-
250
- main()
251
- .then()
252
- .catch(console.error);
@@ -1,80 +0,0 @@
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
- // tslint:disable-next-line:max-func-body-length
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
13
-
14
- const cursor = productRepo.getCursor(
15
- {
16
- typeOf: { $exists: true },
17
- 'hasOfferCatalog.id': { $exists: true }
18
- },
19
- {
20
- project: 1,
21
- typeOf: 1,
22
- productID: 1,
23
- hasOfferCatalog: 1,
24
- id: { $toString: '$_id' }
25
- }
26
- );
27
- console.log('docs found');
28
-
29
- let i = 0;
30
- let updateCount = 0;
31
- await cursor.eachAsync(async (doc) => {
32
- i += 1;
33
- const product: Pick<chevre.factory.product.IProduct, 'hasOfferCatalog' | 'productID' | 'project' | 'typeOf' | 'id'> = doc;
34
- // console.log(product);
35
- const { hasOfferCatalog } = product;
36
- if (typeof hasOfferCatalog?.id !== 'string') {
37
- throw new Error(`${product.project.id} ${product.productID} has no catalog`);
38
- }
39
- if (typeof product.id !== 'string') {
40
- throw new Error(`${product.project.id} ${product.productID} has no id`);
41
- }
42
-
43
- const alreadyMigrated = Array.isArray(hasOfferCatalog?.itemListElement)
44
- && hasOfferCatalog?.itemListElement.length === 1
45
- && hasOfferCatalog?.id === hasOfferCatalog.itemListElement[0].id;
46
- if (alreadyMigrated) {
47
- console.log(
48
- 'already exist.',
49
- product.project.id,
50
- product.typeOf,
51
- product.id, product.productID, i, updateCount
52
- );
53
- } else {
54
- updateCount += 1;
55
- console.log(
56
- 'updating...',
57
- product.project.id,
58
- product.typeOf,
59
- product.id, product.productID, i, updateCount
60
- );
61
- await productRepo.migrateHasOfferCatalogItemListElement({
62
- id: product.id,
63
- hasOfferCatalog: { id: hasOfferCatalog.id }
64
- });
65
- console.log(
66
- 'updated.',
67
- product.project.id,
68
- product.typeOf,
69
- product.id, product.productID, i, updateCount
70
- );
71
- }
72
- });
73
-
74
- console.log(i, 'docs checked');
75
- console.log(updateCount, 'docs updated');
76
- }
77
-
78
- main()
79
- .then()
80
- .catch(console.error);
@@ -1,78 +0,0 @@
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
- enum ROLE_NAME {
8
- Customer = 'customer',
9
- POS = 'pos'
10
- }
11
- const CLIENT_ID = '5an0cmki8v29vdmk627kdo1r0p';
12
- const CUSTOMER_TYPE = 'Enduser';
13
-
14
- // tslint:disable-next-line:max-func-body-length
15
- async function main() {
16
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
17
-
18
- const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
19
- const makesOfferRepo = await chevre.repository.ProjectMakesOffer.createInstance(mongoose.connection);
20
-
21
- const cursor = memberRepo.getCursor(
22
- {
23
- 'member.hasRole.roleName': { $in: [ROLE_NAME.Customer, ROLE_NAME.POS] },
24
- 'member.id': { $eq: CLIENT_ID }
25
- },
26
- {
27
- // _id: 1,
28
- }
29
- );
30
- console.log('members found');
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const iamMember: chevre.factory.iam.IMember = doc.toObject();
37
-
38
- const existingOffers = await makesOfferRepo.search({
39
- offeredBy: { id: { $eq: iamMember.project.id } },
40
- availableAtOrFrom: { id: { $eq: iamMember.member.id } }
41
- });
42
- const alreadyMigrated = existingOffers.length === 1
43
- && Array.isArray(existingOffers[0].eligibleCustomerType)
44
- && existingOffers[0].eligibleCustomerType.length === 1
45
- && existingOffers[0].eligibleCustomerType[0].codeValue === CUSTOMER_TYPE;
46
-
47
- if (alreadyMigrated) {
48
- console.log(
49
- 'already exist...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.name, i);
50
- } else {
51
- console.log(
52
- 'updating project...',
53
- iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.name, i);
54
- try {
55
- await makesOfferRepo.updateOne({
56
- availableAtOrFrom: { id: iamMember.member.id },
57
- eligibleCustomerType: [{
58
- codeValue: CUSTOMER_TYPE
59
- }],
60
- offeredBy: { id: iamMember.project.id }
61
- });
62
- } catch (error) {
63
- console.error(error);
64
- }
65
- updateCount += 1;
66
- console.log(
67
- 'updated.',
68
- iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, iamMember.member.name, i);
69
- }
70
- });
71
-
72
- console.log(i, 'members checked');
73
- console.log(updateCount, 'members updated');
74
- }
75
-
76
- main()
77
- .then()
78
- .catch(console.error);