@chevre/domain 21.2.0-alpha.99 → 21.2.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 (162) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +1 -1
  2. package/example/src/chevre/aggregateSellerPaymentAccepted.ts +27 -0
  3. package/example/src/chevre/aggregation/aggregateSystem.ts +53 -22
  4. package/example/src/chevre/countDelayedTasks.ts +7 -2
  5. package/example/src/chevre/createManyEventsIfNotExist.ts +199 -46
  6. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +4 -3
  7. package/example/src/chevre/giveUpStartDatePassedCertainPeriod.ts +56 -0
  8. package/example/src/chevre/lockStockHolder.ts +5 -2
  9. package/example/src/chevre/migrateCategoryCodeAdditionalProperties.ts +116 -0
  10. package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +79 -0
  11. package/example/src/chevre/processRegisterMembership.ts +8 -4
  12. package/example/src/chevre/processRegisterPaymentCard.ts +8 -4
  13. package/example/src/chevre/processReserve.ts +1 -1
  14. package/example/src/chevre/searchAbortedTasks.ts +4 -6
  15. package/example/src/chevre/searchEventSeats.ts +5 -2
  16. package/example/src/chevre/searchHoldReservations.ts +38 -0
  17. package/example/src/chevre/searchPermissions.ts +54 -0
  18. package/example/src/chevre/searchScreeningRooms.ts +35 -0
  19. package/example/src/chevre/sendEmailMessage.ts +1 -2
  20. package/example/src/chevre/syncScreeningRooms.ts +22 -0
  21. package/example/src/chevre/syncScreeningRoomsAll.ts +44 -0
  22. package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +41 -0
  23. package/lib/chevre/factory/order.d.ts +4 -1
  24. package/lib/chevre/factory/order.js +19 -6
  25. package/lib/chevre/repo/account.js +3 -2
  26. package/lib/chevre/repo/accountTransaction.js +2 -1
  27. package/lib/chevre/repo/accountingReport.d.ts +1 -3
  28. package/lib/chevre/repo/action.d.ts +50 -1
  29. package/lib/chevre/repo/action.js +53 -2
  30. package/lib/chevre/repo/additionalProperty.js +2 -1
  31. package/lib/chevre/repo/aggregation.d.ts +3 -0
  32. package/lib/chevre/repo/aggregation.js +3 -0
  33. package/lib/chevre/repo/assetTransaction.js +6 -5
  34. package/lib/chevre/repo/categoryCode.d.ts +1 -1
  35. package/lib/chevre/repo/categoryCode.js +37 -25
  36. package/lib/chevre/repo/code.js +3 -2
  37. package/lib/chevre/repo/comment.js +2 -1
  38. package/lib/chevre/repo/creativeWork.d.ts +1 -1
  39. package/lib/chevre/repo/creativeWork.js +35 -12
  40. package/lib/chevre/repo/customer.js +2 -1
  41. package/lib/chevre/repo/emailMessage.js +2 -1
  42. package/lib/chevre/repo/event.d.ts +30 -2
  43. package/lib/chevre/repo/event.js +87 -36
  44. package/lib/chevre/repo/member.d.ts +14 -0
  45. package/lib/chevre/repo/member.js +31 -3
  46. package/lib/chevre/repo/merchantReturnPolicy.js +2 -1
  47. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +3 -3
  48. package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +75 -0
  49. package/lib/chevre/repo/mongoose/schemas/holdReservation.js +93 -0
  50. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +3 -3
  51. package/lib/chevre/repo/mongoose/schemas/order.d.ts +21 -21
  52. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -0
  53. package/lib/chevre/repo/mongoose/schemas/place.js +16 -1
  54. package/lib/chevre/repo/mongoose/schemas/product.js +6 -0
  55. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +9 -9
  56. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +3 -3
  57. package/lib/chevre/repo/offer.js +3 -2
  58. package/lib/chevre/repo/offerCatalog.js +0 -27
  59. package/lib/chevre/repo/offerItemCondition.js +2 -1
  60. package/lib/chevre/repo/order.js +8 -7
  61. package/lib/chevre/repo/ownershipInfo.js +2 -7
  62. package/lib/chevre/repo/paymentServiceProvider.d.ts +65 -0
  63. package/lib/chevre/repo/paymentServiceProvider.js +156 -0
  64. package/lib/chevre/repo/place.d.ts +203 -27
  65. package/lib/chevre/repo/place.js +1726 -694
  66. package/lib/chevre/repo/priceSpecification.js +3 -2
  67. package/lib/chevre/repo/product.d.ts +5 -3
  68. package/lib/chevre/repo/product.js +92 -5
  69. package/lib/chevre/repo/project.js +2 -1
  70. package/lib/chevre/repo/reservation.d.ts +9 -1
  71. package/lib/chevre/repo/reservation.js +29 -20
  72. package/lib/chevre/repo/role.d.ts +7 -0
  73. package/lib/chevre/repo/role.js +39 -2
  74. package/lib/chevre/repo/seller.d.ts +21 -1
  75. package/lib/chevre/repo/seller.js +59 -4
  76. package/lib/chevre/repo/serviceOutput.js +2 -1
  77. package/lib/chevre/repo/stockHolder.d.ts +143 -7
  78. package/lib/chevre/repo/stockHolder.js +622 -104
  79. package/lib/chevre/repo/task.d.ts +12 -1
  80. package/lib/chevre/repo/task.js +17 -7
  81. package/lib/chevre/repo/transaction.js +6 -5
  82. package/lib/chevre/repo/trip.js +2 -1
  83. package/lib/chevre/repository.d.ts +6 -0
  84. package/lib/chevre/repository.js +8 -1
  85. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +18 -8
  86. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +19 -8
  87. package/lib/chevre/service/aggregation/system.d.ts +43 -1
  88. package/lib/chevre/service/aggregation/system.js +112 -2
  89. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  90. package/lib/chevre/service/assetTransaction/pay/account/validation.js +1 -1
  91. package/lib/chevre/service/assetTransaction/pay.js +2 -2
  92. package/lib/chevre/service/assetTransaction/refund.js +1 -1
  93. package/lib/chevre/service/assetTransaction/reserve.js +10 -3
  94. package/lib/chevre/service/event.d.ts +3 -0
  95. package/lib/chevre/service/event.js +52 -21
  96. package/lib/chevre/service/iam.d.ts +6 -2
  97. package/lib/chevre/service/iam.js +23 -9
  98. package/lib/chevre/service/offer/event/factory.js +22 -13
  99. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  100. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +15 -8
  101. package/lib/chevre/service/offer/eventServiceByCOA.js +7 -9
  102. package/lib/chevre/service/offer/product/factory.js +13 -6
  103. package/lib/chevre/service/offer/product.js +2 -2
  104. package/lib/chevre/service/offer.d.ts +16 -8
  105. package/lib/chevre/service/offer.js +71 -8
  106. package/lib/chevre/service/order/createAccountingReportIfNotExist.js +31 -17
  107. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +1 -1
  108. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -2
  109. package/lib/chevre/service/order/placeOrder.js +4 -4
  110. package/lib/chevre/service/order/returnOrder.js +1 -1
  111. package/lib/chevre/service/order/sendOrder.js +3 -3
  112. package/lib/chevre/service/payment/any/onPaymentStatusChanged.js +4 -6
  113. package/lib/chevre/service/payment/any/onRefund.js +46 -42
  114. package/lib/chevre/service/payment/creditCard.js +2 -2
  115. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +1 -1
  116. package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
  117. package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +1 -1
  118. package/lib/chevre/service/payment/movieTicket/getCredentials.js +1 -1
  119. package/lib/chevre/service/payment/movieTicket/validation.js +16 -9
  120. package/lib/chevre/service/payment/movieTicket.js +2 -2
  121. package/lib/chevre/service/reserve/cancelReservation.js +15 -3
  122. package/lib/chevre/service/reserve/confirmReservation.js +19 -11
  123. package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
  124. package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
  125. package/lib/chevre/service/task/cancelReservation.js +1 -1
  126. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  127. package/lib/chevre/service/task/onEventChanged.d.ts +7 -0
  128. package/lib/chevre/service/task/onEventChanged.js +29 -0
  129. package/lib/chevre/service/task/onResourceUpdated.d.ts +7 -0
  130. package/lib/chevre/service/task/onResourceUpdated.js +396 -0
  131. package/lib/chevre/service/task/syncScreeningRooms.d.ts +7 -0
  132. package/lib/chevre/service/task/syncScreeningRooms.js +24 -0
  133. package/lib/chevre/service/task/voidReserveTransaction.js +1 -1
  134. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  135. package/lib/chevre/service/transaction/deleteTransaction.js +129 -1
  136. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +1 -0
  137. package/lib/chevre/service/transaction/moneyTransfer/factory.d.ts +1 -1
  138. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  139. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
  140. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.js +1 -1
  141. package/lib/chevre/service/transaction/orderProgramMembership.js +1 -1
  142. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +1 -0
  143. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/givePointAward.js +1 -1
  144. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  145. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  146. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +4 -4
  147. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +3 -4
  148. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +8 -12
  149. package/lib/chevre/service/transaction/placeOrderInProgress.js +6 -4
  150. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +1 -0
  151. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnMoneyTransfer.js +2 -2
  152. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +5 -5
  153. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.js +2 -2
  154. package/lib/chevre/service/transaction/returnOrder/potentialActions/sendEmailMessage.js +3 -3
  155. package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -1
  156. package/lib/chevre/service/transaction/returnOrder.js +3 -1
  157. package/lib/chevre/settings.d.ts +11 -0
  158. package/lib/chevre/settings.js +44 -2
  159. package/package.json +3 -3
  160. package/example/src/chevre/eventCatalog2eventService.ts +0 -123
  161. package/example/src/chevre/migrateOrderAdditionalProperties.ts +0 -85
  162. package/example/src/chevre/migrateStockHolderKeys.ts +0 -89
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.call = void 0;
13
+ const event_1 = require("../../repo/event");
14
+ const project_1 = require("../../repo/project");
15
+ const task_1 = require("../../repo/task");
16
+ const offer_1 = require("../offer");
17
+ /**
18
+ * タスク実行関数
19
+ */
20
+ function call(data) {
21
+ return (settings) => __awaiter(this, void 0, void 0, function* () {
22
+ yield (0, offer_1.onEventChanged)(data)({
23
+ event: new event_1.MongoRepository(settings.connection),
24
+ project: new project_1.MongoRepository(settings.connection),
25
+ task: new task_1.MongoRepository(settings.connection)
26
+ });
27
+ });
28
+ }
29
+ exports.call = call;
@@ -0,0 +1,7 @@
1
+ import * as factory from '../../factory';
2
+ import { IConnectionSettings } from '../task';
3
+ export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
4
+ /**
5
+ * タスク実行関数
6
+ */
7
+ export declare function call(data: factory.task.onResourceUpdated.IData): IOperation<void>;
@@ -0,0 +1,396 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.call = void 0;
13
+ const factory = require("../../factory");
14
+ const accountTitle_1 = require("../../repo/accountTitle");
15
+ const categoryCode_1 = require("../../repo/categoryCode");
16
+ const creativeWork_1 = require("../../repo/creativeWork");
17
+ const place_1 = require("../../repo/place");
18
+ const product_1 = require("../../repo/product");
19
+ const task_1 = require("../../repo/task");
20
+ const settings_1 = require("../../settings");
21
+ const informResources = settings_1.settings.onResourceUpdated.informResource;
22
+ /**
23
+ * タスク実行関数
24
+ */
25
+ function call(data) {
26
+ return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
27
+ yield onResourceUpdated(data)({
28
+ accountTitle: new accountTitle_1.MongoRepository(connectionSettings.connection),
29
+ categoryCode: new categoryCode_1.MongoRepository(connectionSettings.connection),
30
+ creativeWork: new creativeWork_1.MongoRepository(connectionSettings.connection),
31
+ place: new place_1.MongoRepository(connectionSettings.connection),
32
+ product: new product_1.MongoRepository(connectionSettings.connection),
33
+ task: new task_1.MongoRepository(connectionSettings.connection)
34
+ });
35
+ });
36
+ }
37
+ exports.call = call;
38
+ function onResourceUpdated(params) {
39
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
40
+ if (params.useInform === true) {
41
+ switch (params.typeOf) {
42
+ case factory.creativeWorkType.Movie:
43
+ yield createInformMovieTasks({
44
+ project: { id: params.project.id },
45
+ ids: params.id,
46
+ typeOf: params.typeOf
47
+ })(repos);
48
+ break;
49
+ case factory.product.ProductType.EventService:
50
+ yield createInformProductTasks({
51
+ project: { id: params.project.id },
52
+ ids: params.id,
53
+ typeOf: params.typeOf
54
+ })(repos);
55
+ break;
56
+ case 'CategoryCode':
57
+ yield createInformCategoryCodeTasks({
58
+ project: { id: params.project.id },
59
+ ids: params.id,
60
+ typeOf: params.typeOf
61
+ })(repos);
62
+ break;
63
+ case factory.placeType.MovieTheater:
64
+ yield createInformMovieTheaterTasks({
65
+ project: { id: params.project.id },
66
+ ids: params.id,
67
+ typeOf: params.typeOf
68
+ })(repos);
69
+ break;
70
+ case 'AccountTitle':
71
+ yield createInformAccountTitleTasks({
72
+ project: { id: params.project.id },
73
+ ids: params.id,
74
+ typeOf: params.typeOf
75
+ })(repos);
76
+ break;
77
+ default:
78
+ // no op
79
+ }
80
+ }
81
+ switch (params.typeOf) {
82
+ // 施設名称を同期する(2023-06-29~)
83
+ case factory.placeType.MovieTheater:
84
+ yield syncMovieTheater({
85
+ project: { id: params.project.id },
86
+ ids: params.id,
87
+ typeOf: params.typeOf
88
+ })(repos);
89
+ break;
90
+ default:
91
+ // no op
92
+ }
93
+ });
94
+ }
95
+ function createInformMovieTasks(params) {
96
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
97
+ const movies4inform = yield repos.creativeWork.searchMovies({ id: { $in: params.ids } }, [
98
+ 'additionalProperty', 'datePublished', 'duration', 'identifier', 'name', 'project',
99
+ 'typeOf', 'distributor', 'contentRating', 'headline', 'thumbnailUrl'
100
+ ], []);
101
+ if (movies4inform.length > 0) {
102
+ const taskRunsAt = new Date();
103
+ const informTasks = [];
104
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
105
+ var _a;
106
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
107
+ movies4inform.forEach((movie4inform) => {
108
+ var _a;
109
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
110
+ delete movie4inform._id;
111
+ const informActionAttributes = {
112
+ agent: movie4inform.project,
113
+ object: movie4inform,
114
+ project: movie4inform.project,
115
+ recipient: {
116
+ id: '',
117
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
118
+ typeOf: factory.creativeWorkType.WebApplication,
119
+ url: informUrl
120
+ },
121
+ typeOf: factory.actionType.InformAction
122
+ };
123
+ informTasks.push({
124
+ project: movie4inform.project,
125
+ name: factory.taskName.TriggerWebhook,
126
+ status: factory.taskStatus.Ready,
127
+ runsAt: taskRunsAt,
128
+ remainingNumberOfTries: 10,
129
+ numberOfTried: 0,
130
+ executionResults: [],
131
+ data: informActionAttributes
132
+ });
133
+ });
134
+ });
135
+ if (informTasks.length > 0) {
136
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
137
+ }
138
+ }
139
+ });
140
+ }
141
+ function createInformProductTasks(params) {
142
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
143
+ const products4inform = yield repos.product.search({
144
+ typeOf: { $eq: params.typeOf },
145
+ id: { $in: params.ids }
146
+ }, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType'], []);
147
+ if (products4inform.length > 0) {
148
+ const taskRunsAt = new Date();
149
+ const informTasks = [];
150
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
151
+ var _a;
152
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
153
+ products4inform.forEach((product4inform) => {
154
+ var _a;
155
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
156
+ delete product4inform._id;
157
+ const informActionAttributes = {
158
+ agent: product4inform.project,
159
+ object: product4inform,
160
+ project: product4inform.project,
161
+ recipient: {
162
+ id: '',
163
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
164
+ typeOf: factory.creativeWorkType.WebApplication,
165
+ url: informUrl
166
+ },
167
+ typeOf: factory.actionType.InformAction
168
+ };
169
+ informTasks.push({
170
+ project: product4inform.project,
171
+ name: factory.taskName.TriggerWebhook,
172
+ status: factory.taskStatus.Ready,
173
+ runsAt: taskRunsAt,
174
+ remainingNumberOfTries: 10,
175
+ numberOfTried: 0,
176
+ executionResults: [],
177
+ data: informActionAttributes
178
+ });
179
+ });
180
+ });
181
+ if (informTasks.length > 0) {
182
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
183
+ }
184
+ }
185
+ });
186
+ }
187
+ function createInformCategoryCodeTasks(params) {
188
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
189
+ const categoryCodes4inform = yield repos.categoryCode.search({
190
+ id: { $in: params.ids },
191
+ // ひとまずDistributorTypeのみ
192
+ inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.DistributorType } }
193
+ }, ['name', 'additionalProperty', 'project', 'typeOf', 'codeValue', 'inCodeSet'], []);
194
+ if (categoryCodes4inform.length > 0) {
195
+ const taskRunsAt = new Date();
196
+ const informTasks = [];
197
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
198
+ var _a;
199
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
200
+ categoryCodes4inform.forEach((categoryCode4inform) => {
201
+ var _a;
202
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
203
+ delete categoryCode4inform._id;
204
+ const informActionAttributes = {
205
+ agent: categoryCode4inform.project,
206
+ object: categoryCode4inform,
207
+ project: categoryCode4inform.project,
208
+ recipient: {
209
+ id: '',
210
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
211
+ typeOf: factory.creativeWorkType.WebApplication,
212
+ url: informUrl
213
+ },
214
+ typeOf: factory.actionType.InformAction
215
+ };
216
+ informTasks.push({
217
+ project: categoryCode4inform.project,
218
+ name: factory.taskName.TriggerWebhook,
219
+ status: factory.taskStatus.Ready,
220
+ runsAt: taskRunsAt,
221
+ remainingNumberOfTries: 10,
222
+ numberOfTried: 0,
223
+ executionResults: [],
224
+ data: informActionAttributes
225
+ });
226
+ });
227
+ });
228
+ if (informTasks.length > 0) {
229
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
230
+ }
231
+ }
232
+ });
233
+ }
234
+ function createInformMovieTheaterTasks(params) {
235
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
236
+ if (params.ids.length !== 1) {
237
+ throw new factory.errors.Argument('id', 'id.length must be 1');
238
+ }
239
+ const movieTheaters = yield repos.place.searchMovieTheaters({
240
+ limit: 1,
241
+ page: 1,
242
+ project: { id: { $eq: params.project.id } },
243
+ id: { $eq: params.ids[0] }
244
+ }, [
245
+ 'additionalProperty',
246
+ 'branchCode',
247
+ 'hasEntranceGate',
248
+ 'hasPOS',
249
+ 'kanaName',
250
+ 'name',
251
+ 'parentOrganization',
252
+ 'project',
253
+ 'telephone',
254
+ 'url',
255
+ 'typeOf'
256
+ ], []);
257
+ const movieTheater = movieTheaters.shift();
258
+ if (movieTheater === undefined) {
259
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
260
+ }
261
+ // ルームを検索
262
+ const screeningRooms = yield repos.place.searchScreeningRooms({
263
+ containedInPlace: { id: { $eq: movieTheater.id } }
264
+ }, settings_1.USE_READ_SCREENING_ROOM_TYPE);
265
+ const movieTheaters4inform = [Object.assign(Object.assign({}, movieTheater), { containsPlace: screeningRooms.map((room) => {
266
+ return {
267
+ branchCode: room.branchCode,
268
+ name: room.name,
269
+ typeOf: room.typeOf,
270
+ additionalProperty: room.additionalProperty,
271
+ address: room.address
272
+ };
273
+ }) })];
274
+ if (movieTheaters4inform.length > 0) {
275
+ const taskRunsAt = new Date();
276
+ const informTasks = [];
277
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
278
+ var _a;
279
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
280
+ movieTheaters4inform.forEach((movieTheater4inform) => {
281
+ var _a;
282
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
283
+ delete movieTheater4inform._id;
284
+ const informActionAttributes = {
285
+ agent: movieTheater4inform.project,
286
+ object: movieTheater4inform,
287
+ project: movieTheater4inform.project,
288
+ recipient: {
289
+ id: '',
290
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
291
+ typeOf: factory.creativeWorkType.WebApplication,
292
+ url: informUrl
293
+ },
294
+ typeOf: factory.actionType.InformAction
295
+ };
296
+ informTasks.push({
297
+ project: movieTheater4inform.project,
298
+ name: factory.taskName.TriggerWebhook,
299
+ status: factory.taskStatus.Ready,
300
+ runsAt: taskRunsAt,
301
+ remainingNumberOfTries: 10,
302
+ numberOfTried: 0,
303
+ executionResults: [],
304
+ data: informActionAttributes
305
+ });
306
+ });
307
+ });
308
+ if (informTasks.length > 0) {
309
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
310
+ }
311
+ }
312
+ });
313
+ }
314
+ function createInformAccountTitleTasks(params) {
315
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
316
+ if (params.ids.length !== 1) {
317
+ throw new factory.errors.Argument('id', 'id.length must be 1');
318
+ }
319
+ const accountTitle = yield repos.accountTitle.accountTitleModel.findOne({
320
+ _id: { $eq: params.ids[0] },
321
+ 'project.id': { $eq: params.project.id }
322
+ }, {
323
+ additionalProperty: 1,
324
+ codeValue: 1,
325
+ hasCategoryCode: 1,
326
+ name: 1,
327
+ project: 1,
328
+ typeOf: 1
329
+ })
330
+ .exec()
331
+ .then((doc) => {
332
+ if (doc === null) {
333
+ throw new factory.errors.NotFound(params.typeOf);
334
+ }
335
+ return doc.toObject();
336
+ });
337
+ const accountTitles4inform = [accountTitle];
338
+ if (accountTitles4inform.length > 0) {
339
+ const taskRunsAt = new Date();
340
+ const informTasks = [];
341
+ informResources === null || informResources === void 0 ? void 0 : informResources.forEach((informResource) => {
342
+ var _a;
343
+ const informUrl = String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.url);
344
+ accountTitles4inform.forEach((accountTitle4inform) => {
345
+ var _a;
346
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
347
+ delete accountTitle4inform._id;
348
+ const informActionAttributes = {
349
+ agent: accountTitle4inform.project,
350
+ object: accountTitle4inform,
351
+ project: accountTitle4inform.project,
352
+ recipient: {
353
+ id: '',
354
+ name: String((_a = informResource.recipient) === null || _a === void 0 ? void 0 : _a.name),
355
+ typeOf: factory.creativeWorkType.WebApplication,
356
+ url: informUrl
357
+ },
358
+ typeOf: factory.actionType.InformAction
359
+ };
360
+ informTasks.push({
361
+ project: accountTitle4inform.project,
362
+ name: factory.taskName.TriggerWebhook,
363
+ status: factory.taskStatus.Ready,
364
+ runsAt: taskRunsAt,
365
+ remainingNumberOfTries: 10,
366
+ numberOfTried: 0,
367
+ executionResults: [],
368
+ data: informActionAttributes
369
+ });
370
+ });
371
+ });
372
+ if (informTasks.length > 0) {
373
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
374
+ }
375
+ }
376
+ });
377
+ }
378
+ function syncMovieTheater(params) {
379
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
380
+ if (params.ids.length !== 1) {
381
+ throw new factory.errors.Argument('id', 'id.length must be 1');
382
+ }
383
+ const movieTheaters = yield repos.place.searchMovieTheaters({
384
+ id: { $eq: params.ids[0] },
385
+ project: { id: { $eq: params.project.id } }
386
+ }, ['_id', 'name'], []);
387
+ const movieTheater = movieTheaters.shift();
388
+ if (movieTheater === undefined) {
389
+ throw new factory.errors.NotFound(factory.placeType.MovieTheater);
390
+ }
391
+ yield repos.place.updateScreeningRoomsByContainedInPlaceId({
392
+ project: { id: params.project.id },
393
+ containedInPlace: movieTheater
394
+ });
395
+ });
396
+ }
@@ -0,0 +1,7 @@
1
+ import * as factory from '../../factory';
2
+ import { IConnectionSettings } from '../task';
3
+ export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
4
+ /**
5
+ * タスク実行関数
6
+ */
7
+ export declare function call(data: factory.task.syncScreeningRooms.IData): IOperation<void>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.call = void 0;
13
+ const place_1 = require("../../repo/place");
14
+ const settings_1 = require("../../settings");
15
+ /**
16
+ * タスク実行関数
17
+ */
18
+ function call(data) {
19
+ return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
20
+ const placeRepo = new place_1.MongoRepository(connectionSettings.connection);
21
+ yield placeRepo.syncScreeningRooms({ id: data.id, useScreeningRoomType: settings_1.USE_WRITE_SCREENING_ROOM_TYPE });
22
+ });
23
+ }
24
+ exports.call = call;
@@ -29,7 +29,7 @@ function call(data) {
29
29
  }
30
30
  const actionRepo = new action_1.MongoRepository(settings.connection);
31
31
  const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
32
- const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
32
+ const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection);
33
33
  const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
34
34
  const reservationRepo = new reservation_1.MongoRepository(settings.connection);
35
35
  const taskRepo = new task_1.MongoRepository(settings.connection);
@@ -5,6 +5,7 @@ import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransac
5
5
  import { MongoRepository as OrderRepo } from '../../repo/order';
6
6
  import { MongoRepository as OwnershipInfoRepo } from '../../repo/ownershipInfo';
7
7
  import { MongoRepository as ReservationRepo } from '../../repo/reservation';
8
+ import { MongoRepository as TaskRepo } from '../../repo/task';
8
9
  import { MongoRepository as TransactionRepo } from '../../repo/transaction';
9
10
  /**
10
11
  * 取引に関わるリソースを削除する
@@ -17,5 +18,6 @@ export declare function deleteTransaction(params: factory.task.IData<factory.tas
17
18
  order: OrderRepo;
18
19
  ownershipInfo: OwnershipInfoRepo;
19
20
  reservation: ReservationRepo;
21
+ task: TaskRepo;
20
22
  transaction: TransactionRepo;
21
23
  }) => Promise<void>;
@@ -17,9 +17,138 @@ const deleteOrder_1 = require("../order/deleteOrder");
17
17
  * 冪等性を確保すること
18
18
  */
19
19
  function deleteTransaction(params) {
20
+ // tslint:disable-next-line:max-func-body-length
21
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
22
+ if (params.object.specifyingMethod === factory.task.deleteTransaction.SpecifyingMethod.AgentId) {
23
+ // transaction.agent.id指定による取引削除に対応(2023-06-30~)
24
+ yield createDeleteTransactionTasksByAgentId(params)(repos);
25
+ }
26
+ else {
27
+ yield deleteTransactionById(params)(repos);
28
+ }
29
+ });
30
+ }
31
+ exports.deleteTransaction = deleteTransaction;
32
+ function createDeleteTransactionTasksByAgentId(params) {
33
+ // tslint:disable-next-line:max-func-body-length
34
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
35
+ if (params.object.specifyingMethod !== factory.task.deleteTransaction.SpecifyingMethod.AgentId) {
36
+ throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.task.deleteTransaction.SpecifyingMethod.Id}`);
37
+ }
38
+ const agentIdSpecified = params.object.agent.id;
39
+ // agentIdによる全取引についてDeleteTransactionタスクを作成する
40
+ if (typeof agentIdSpecified === 'string' && agentIdSpecified.length > 0) {
41
+ const transactionTypeOf = params.object.typeOf;
42
+ const transactions = yield repos.transaction.search({
43
+ project: { id: { $eq: params.object.project.id } },
44
+ agent: {
45
+ ids: [agentIdSpecified],
46
+ typeOf: factory.personType.Person
47
+ },
48
+ typeOf: transactionTypeOf,
49
+ inclusion: ['_id', 'typeOf', 'startDate', 'endDate', 'object', 'project'],
50
+ exclusion: []
51
+ });
52
+ const deleteAt = new Date();
53
+ let deleteTransactionTasks = [];
54
+ switch (transactionTypeOf) {
55
+ case factory.transactionType.PlaceOrder:
56
+ deleteTransactionTasks = transactions.map((transaction) => {
57
+ return {
58
+ project: transaction.project,
59
+ name: factory.taskName.DeleteTransaction,
60
+ status: factory.taskStatus.Ready,
61
+ runsAt: deleteAt,
62
+ remainingNumberOfTries: 3,
63
+ numberOfTried: 0,
64
+ executionResults: [],
65
+ data: {
66
+ object: {
67
+ specifyingMethod: factory.task.deleteTransaction.SpecifyingMethod.Id,
68
+ endDate: transaction.endDate,
69
+ id: transaction.id,
70
+ object: Object.assign(Object.assign({}, (typeof transaction.object.confirmationNumber === 'string')
71
+ ? { confirmationNumber: transaction.object.confirmationNumber }
72
+ : undefined), (typeof transaction.object.orderNumber === 'string')
73
+ ? { orderNumber: transaction.object.orderNumber }
74
+ : undefined),
75
+ project: transaction.project,
76
+ startDate: transaction.startDate,
77
+ typeOf: transaction.typeOf
78
+ }
79
+ }
80
+ };
81
+ });
82
+ break;
83
+ case factory.transactionType.ReturnOrder:
84
+ deleteTransactionTasks = transactions.map((transaction) => {
85
+ return {
86
+ project: transaction.project,
87
+ name: factory.taskName.DeleteTransaction,
88
+ status: factory.taskStatus.Ready,
89
+ runsAt: deleteAt,
90
+ remainingNumberOfTries: 3,
91
+ numberOfTried: 0,
92
+ executionResults: [],
93
+ data: {
94
+ object: {
95
+ specifyingMethod: factory.task.deleteTransaction.SpecifyingMethod.Id,
96
+ endDate: transaction.endDate,
97
+ id: transaction.id,
98
+ object: {
99
+ order: transaction.object.order
100
+ },
101
+ project: transaction.project,
102
+ startDate: transaction.startDate,
103
+ typeOf: transaction.typeOf
104
+ }
105
+ }
106
+ };
107
+ });
108
+ break;
109
+ case factory.transactionType.MoneyTransfer:
110
+ deleteTransactionTasks = transactions.map((transaction) => {
111
+ return {
112
+ project: transaction.project,
113
+ name: factory.taskName.DeleteTransaction,
114
+ status: factory.taskStatus.Ready,
115
+ runsAt: deleteAt,
116
+ remainingNumberOfTries: 3,
117
+ numberOfTried: 0,
118
+ executionResults: [],
119
+ data: {
120
+ object: {
121
+ specifyingMethod: factory.task.deleteTransaction.SpecifyingMethod.Id,
122
+ endDate: transaction.endDate,
123
+ id: transaction.id,
124
+ object: Object.assign({}, (transaction.object.pendingTransaction !== undefined)
125
+ ? { pendingTransaction: transaction.object.pendingTransaction }
126
+ : undefined),
127
+ project: transaction.project,
128
+ startDate: transaction.startDate,
129
+ typeOf: transaction.typeOf
130
+ }
131
+ }
132
+ };
133
+ });
134
+ break;
135
+ default:
136
+ throw new factory.errors.NotImplemented(`${transactionTypeOf} not implemented`);
137
+ }
138
+ if (deleteTransactionTasks.length > 0) {
139
+ yield repos.task.saveMany(deleteTransactionTasks, { emitImmediately: true });
140
+ }
141
+ }
142
+ });
143
+ }
144
+ function deleteTransactionById(params) {
20
145
  // tslint:disable-next-line:max-func-body-length
21
146
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
147
  var _a;
148
+ if (typeof params.object.specifyingMethod === 'string'
149
+ && params.object.specifyingMethod !== factory.task.deleteTransaction.SpecifyingMethod.Id) {
150
+ throw new factory.errors.Argument('object.specifyingMethod', `must be ${factory.task.deleteTransaction.SpecifyingMethod.Id}`);
151
+ }
23
152
  const transactions = yield repos.transaction.search({
24
153
  ids: [params.object.id],
25
154
  typeOf: params.object.typeOf,
@@ -137,7 +266,6 @@ function deleteTransaction(params) {
137
266
  yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
138
267
  });
139
268
  }
140
- exports.deleteTransaction = deleteTransaction;
141
269
  function deleteReservationsByPlaceOrder(params) {
142
270
  return (repos) => __awaiter(this, void 0, void 0, function* () {
143
271
  let deleteResult;
@@ -37,6 +37,7 @@ function createTasks(params) {
37
37
  executionResults: [],
38
38
  data: {
39
39
  object: {
40
+ specifyingMethod: factory.task.deleteTransaction.SpecifyingMethod.Id,
40
41
  endDate: transaction.endDate,
41
42
  id: transaction.id,
42
43
  object: Object.assign({}, (transaction.object.pendingTransaction !== undefined)
@@ -1,2 +1,2 @@
1
1
  import * as factory from '../../../factory';
2
- export declare function createStartParams(params: factory.transaction.moneyTransfer.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, amount: factory.monetaryAmount.IMonetaryAmount, fromLocation: factory.assetTransaction.moneyTransfer.IFromLocationBeforeStart, toLocation: factory.transaction.moneyTransfer.IToLocation, transactionNumber: string): factory.transaction.IStartParams<factory.transactionType.MoneyTransfer>;
2
+ export declare function createStartParams(params: factory.transaction.moneyTransfer.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf'>, amount: factory.monetaryAmount.IMonetaryAmount, fromLocation: factory.assetTransaction.moneyTransfer.IFromLocationBeforeStart, toLocation: factory.transaction.moneyTransfer.IToLocation, transactionNumber: string): factory.transaction.IStartParams<factory.transactionType.MoneyTransfer>;
@@ -28,7 +28,7 @@ const CodeService = require("../code");
28
28
  */
29
29
  function start(params) {
30
30
  return (repos) => __awaiter(this, void 0, void 0, function* () {
31
- const seller = yield repos.seller.findById({ id: params.seller.id });
31
+ const seller = yield repos.seller.findById({ id: params.seller.id }, ['name', 'typeOf'], []);
32
32
  const passport = yield (0, validation_1.validateWaiterPassport)(params);
33
33
  // 金額をfix
34
34
  const amount = params.object.amount;