@chevre/domain 21.4.0-alpha.9 → 21.4.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 (89) hide show
  1. package/example/src/chevre/cleanEventsByMovieTheater.ts +32 -0
  2. package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
  3. package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +31 -0
  4. package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +32 -0
  5. package/example/src/chevre/importEventsFromCOA.ts +5 -4
  6. package/example/src/chevre/migrateEventOrganizer.ts +18 -5
  7. package/example/src/chevre/migrateIAMMemberMemberOf.ts +59 -0
  8. package/example/src/chevre/migrateReservationProvider.ts +119 -0
  9. package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
  10. package/example/src/chevre/processReserve.ts +0 -1
  11. package/example/src/chevre/searchActions.ts +1 -1
  12. package/example/src/chevre/searchPermissions.ts +7 -15
  13. package/lib/chevre/factory/event.d.ts +1 -1
  14. package/lib/chevre/repo/assetTransaction.d.ts +4 -1
  15. package/lib/chevre/repo/assetTransaction.js +6 -12
  16. package/lib/chevre/repo/event.d.ts +16 -0
  17. package/lib/chevre/repo/event.js +34 -1
  18. package/lib/chevre/repo/member.d.ts +77 -5
  19. package/lib/chevre/repo/member.js +115 -97
  20. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  21. package/lib/chevre/repo/mongoose/schemas/member.d.ts +7 -7
  22. package/lib/chevre/repo/mongoose/schemas/member.js +22 -8
  23. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -6
  24. package/lib/chevre/repo/mongoose/schemas/place.js +9 -2
  25. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  26. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +6 -3
  27. package/lib/chevre/repo/mongoose/schemas/reservation.js +10 -4
  28. package/lib/chevre/repo/order.d.ts +21 -0
  29. package/lib/chevre/repo/order.js +54 -62
  30. package/lib/chevre/repo/place.d.ts +57 -16
  31. package/lib/chevre/repo/place.js +112 -167
  32. package/lib/chevre/repo/product.d.ts +2 -4
  33. package/lib/chevre/repo/product.js +52 -7
  34. package/lib/chevre/repo/project.d.ts +5 -3
  35. package/lib/chevre/repo/project.js +48 -8
  36. package/lib/chevre/repo/reservation.d.ts +33 -21
  37. package/lib/chevre/repo/reservation.js +97 -79
  38. package/lib/chevre/repo/role.d.ts +0 -4
  39. package/lib/chevre/repo/role.js +0 -46
  40. package/lib/chevre/repo/seller.d.ts +14 -2
  41. package/lib/chevre/repo/seller.js +13 -8
  42. package/lib/chevre/repo/stockHolder.d.ts +2 -77
  43. package/lib/chevre/repo/stockHolder.js +200 -476
  44. package/lib/chevre/repo/task.d.ts +1 -1
  45. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
  46. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  47. package/lib/chevre/service/aggregation/project.js +5 -1
  48. package/lib/chevre/service/assetTransaction/cancelReservation.js +10 -2
  49. package/lib/chevre/service/assetTransaction/registerService.js +7 -3
  50. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +6 -1
  51. package/lib/chevre/service/assetTransaction/reserve/factory.js +15 -38
  52. package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
  53. package/lib/chevre/service/assetTransaction/reserve.js +7 -22
  54. package/lib/chevre/service/event/createEvent.d.ts +11 -0
  55. package/lib/chevre/service/event/createEvent.js +112 -0
  56. package/lib/chevre/service/event.d.ts +2 -0
  57. package/lib/chevre/service/event.js +8 -4
  58. package/lib/chevre/service/iam.d.ts +5 -0
  59. package/lib/chevre/service/iam.js +7 -19
  60. package/lib/chevre/service/moneyTransfer.js +6 -2
  61. package/lib/chevre/service/notification.js +5 -1
  62. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  63. package/lib/chevre/service/offer/event/authorize.js +6 -2
  64. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
  65. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  66. package/lib/chevre/service/order/returnOrder.js +8 -1
  67. package/lib/chevre/service/order/sendOrder.js +8 -1
  68. package/lib/chevre/service/payment/creditCard.js +5 -1
  69. package/lib/chevre/service/payment/paymentCard.js +6 -4
  70. package/lib/chevre/service/reserve/cancelReservation.js +15 -28
  71. package/lib/chevre/service/reserve/confirmReservation.js +14 -30
  72. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
  73. package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
  74. package/lib/chevre/service/task/{syncScreeningRooms.d.ts → createEvent.d.ts} +1 -1
  75. package/lib/chevre/service/task/{syncScreeningRooms.js → createEvent.js} +11 -3
  76. package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
  77. package/lib/chevre/service/task/returnPayTransaction.js +1 -0
  78. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +6 -2
  79. package/lib/chevre/settings.d.ts +0 -2
  80. package/lib/chevre/settings.js +7 -7
  81. package/package.json +3 -3
  82. package/example/src/chevre/findByOrderNumberAndReservationId.ts +0 -20
  83. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
  84. package/example/src/chevre/searchHoldReservations.ts +0 -38
  85. package/example/src/chevre/searchScreeningRooms.ts +0 -33
  86. package/example/src/chevre/syncScreeningRooms.ts +0 -21
  87. package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
  88. package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +0 -75
  89. package/lib/chevre/repo/mongoose/schemas/holdReservation.js +0 -93
@@ -63,7 +63,7 @@ export declare class MongoRepository {
63
63
  */
64
64
  $nin?: factory.taskName[];
65
65
  };
66
- }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
66
+ }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
67
67
  retry(params: {
68
68
  intervalInMinutes: number;
69
69
  }): Promise<void>;
@@ -80,6 +80,7 @@ function aggregateByEvent(params) {
80
80
  movieTheaterId = String((_a = params.event.offers) === null || _a === void 0 ? void 0 : _a.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
81
81
  }
82
82
  const screeningRoom = yield repos.place.findScreeningRoomsByBranchCode({
83
+ project: { id: event.project.id },
83
84
  branchCode: { $eq: event.location.branchCode },
84
85
  containedInPlace: { id: { $eq: movieTheaterId } }
85
86
  });
@@ -174,7 +175,7 @@ function findOffers(params) {
174
175
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
175
176
  const eventOffers = params.event.offers;
176
177
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
177
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
178
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
178
179
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
179
180
  const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
180
181
  offerCatalog: { id: eventService.hasOfferCatalog.id },
@@ -208,7 +209,7 @@ function calculateOfferCount(params) {
208
209
  try {
209
210
  const eventOffers = params.event.offers;
210
211
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
211
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
212
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
212
213
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
213
214
  const catalogs = yield repos.offerCatalog.search({
214
215
  limit: 1,
@@ -100,7 +100,7 @@ function findOffers(params) {
100
100
  // 興行設定があれば興行のカタログを参照する(2022-08-31~)
101
101
  const eventOffers = params.event.offers;
102
102
  if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
103
- const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
103
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
104
104
  if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
105
105
  const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
106
106
  offerCatalog: { id: eventService.hasOfferCatalog.id },
@@ -21,7 +21,11 @@ function aggregate(params) {
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
22
  const now = new Date();
23
23
  // 集計対象プロジェクト検索
24
- const project = yield repos.project.findById(params.project);
24
+ const project = yield repos.project.findById({
25
+ id: params.project.id,
26
+ inclusion: ['_id', 'typeOf'],
27
+ exclusion: []
28
+ });
25
29
  // 予約集計
26
30
  const { aggregateReservation } = yield aggregateReservationOnProject({
27
31
  aggregateDate: now,
@@ -73,7 +73,11 @@ function validateStartParams(params) {
73
73
  */
74
74
  function start(params) {
75
75
  return (repos) => __awaiter(this, void 0, void 0, function* () {
76
- const project = yield repos.project.findById({ id: params.project.id });
76
+ const project = yield repos.project.findById({
77
+ id: params.project.id,
78
+ inclusion: ['_id', 'typeOf'],
79
+ exclusion: []
80
+ });
77
81
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
78
82
  const transactionNumber = params.transactionNumber;
79
83
  if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
@@ -125,7 +129,11 @@ exports.confirm = confirm;
125
129
  */
126
130
  function startAndConfirm(params) {
127
131
  return (repos) => __awaiter(this, void 0, void 0, function* () {
128
- const project = yield repos.project.findById({ id: params.project.id });
132
+ const project = yield repos.project.findById({
133
+ id: params.project.id,
134
+ inclusion: ['_id', 'typeOf'],
135
+ exclusion: []
136
+ });
129
137
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
130
138
  const transactionNumber = params.transactionNumber;
131
139
  if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
@@ -25,7 +25,11 @@ const PermitService = require("../permit");
25
25
  */
26
26
  function start(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
- const project = yield repos.project.findById({ id: params.project.id });
28
+ const project = yield repos.project.findById({
29
+ id: params.project.id,
30
+ inclusion: ['_id', 'typeOf'],
31
+ exclusion: []
32
+ });
29
33
  // objectはオファー
30
34
  let acceptedOffers = params.object;
31
35
  if (!Array.isArray(acceptedOffers)) {
@@ -40,7 +44,7 @@ function start(params) {
40
44
  throw new factory.errors.ArgumentNull('object.itemOffered.id');
41
45
  }
42
46
  // プロダクト確認
43
- const product = yield repos.product.findById({ id: productId });
47
+ const product = yield repos.product.findById({ id: productId }, [], []);
44
48
  const transactionNumber = params.transactionNumber;
45
49
  if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
46
50
  throw new factory.errors.ArgumentNull('transactionNumber');
@@ -124,7 +128,7 @@ function createTransactionObject(params) {
124
128
  function createPermitService(params) {
125
129
  return (repos) => __awaiter(this, void 0, void 0, function* () {
126
130
  var _a, _b, _c, _d, _e, _f, _g;
127
- const product = yield repos.product.findById({ id: params.issuedThrough.id });
131
+ const product = yield repos.product.findById({ id: params.issuedThrough.id }, [], []);
128
132
  const permitServiceEndpoint = (_a = product.availableChannel) === null || _a === void 0 ? void 0 : _a.serviceUrl;
129
133
  const permitServiceAuthorizeServerDomain = (_c = (_b = product.availableChannel) === null || _b === void 0 ? void 0 : _b.credentials) === null || _c === void 0 ? void 0 : _c.authorizeServerDomain;
130
134
  const permitServiceClientId = (_e = (_d = product.availableChannel) === null || _d === void 0 ? void 0 : _d.credentials) === null || _e === void 0 ? void 0 : _e.clientId;
@@ -4,8 +4,13 @@ import { IAcceptedAddOn } from './factory/price';
4
4
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
5
5
  export { IAcceptedAddOn };
6
6
  export declare function createStartParams(params: factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
7
+ provider: {
8
+ /**
9
+ * 販売者ID
10
+ */
11
+ id: string;
12
+ };
7
13
  reservationNumber: string;
8
- disablePendingReservations: boolean;
9
14
  useHoldStockByTransactionNumber: boolean;
10
15
  }): factory.assetTransaction.IStartParams<factory.assetTransactionType.Reserve>;
11
16
  /**
@@ -11,9 +11,13 @@ const price_1 = require("./factory/price");
11
11
  function createStartParams(params) {
12
12
  var _a;
13
13
  const reservationNumber = params.reservationNumber;
14
- const reservationPackage = Object.assign({
15
- // project: params.project,
16
- reservationNumber: reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending, disablePendingReservations: params.disablePendingReservations, useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, typeOf: factory.reservationType.ReservationPackage }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined);
14
+ const provider = {
15
+ id: params.provider.id,
16
+ typeOf: factory.organizationType.Corporation
17
+ };
18
+ const reservationPackage = Object.assign({ provider, reservationNumber: reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending,
19
+ // trueで固定(2023-07-19~)
20
+ disablePendingReservations: true, useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, typeOf: factory.reservationType.ReservationPackage }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined);
17
21
  return {
18
22
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
19
23
  typeOf: factory.assetTransactionType.Reserve,
@@ -413,36 +417,14 @@ function createReservation(params) {
413
417
  }
414
418
  // priceを最適化
415
419
  const price4reservation = (0, price_1.createPrice)(params);
416
- // const eventOffers = <factory.event.screeningEvent.IOffer | undefined>params.reservationFor.offers;
417
- // // offersは必ず存在するはず
418
- // if (eventOffers === undefined) {
419
- // throw new factory.errors.NotFound('reservationFor.offers');
420
- // }
421
- // const serviceTypeOfIssuedThrough: factory.reservation.eventReservation.IServiceTypeOfIssuedThrough | undefined
422
- // = (typeof eventOffers.itemOffered.serviceType?.codeValue === 'string')
423
- // ? {
424
- // codeValue: eventOffers.itemOffered.serviceType.codeValue,
425
- // inCodeSet: {
426
- // typeOf: 'CategoryCodeSet',
427
- // identifier: factory.categoryCode.CategorySetIdentifier.ServiceType
428
- // },
429
- // typeOf: 'CategoryCode'
430
- // }
431
- // : undefined;
432
- // const availableChannel: factory.reservation.IServiceChannel = eventOffers.itemOffered.availableChannel;
433
420
  if (params.reservationFor.typeOf === factory.eventType.ScreeningEvent) {
434
- // const issuedThrough: factory.reservation.eventReservation.IIssuedThrough = {
435
- // typeOf: factory.product.ProductType.EventService,
436
- // // 興行IDを追加(2022-09-08~)
437
- // id: eventOffers.itemOffered.id,
438
- // availableChannel,
439
- // // issuedThrough.serviceTypeを連携
440
- // ...(typeof serviceTypeOfIssuedThrough?.typeOf === 'string') ? { serviceType: serviceTypeOfIssuedThrough } : undefined
441
- // };
442
421
  return Object.assign(Object.assign(Object.assign({ project: params.project, typeOf: factory.reservationType.EventReservation, id: params.id,
443
422
  // reservationPackage保管に移行(2023-06-06~)
444
423
  // issuedThrough,
445
- additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending, reservedTicket: params.reservedTicket,
424
+ additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber,
425
+ // statusは不要なので削除(2023-07-19~)
426
+ // reservationStatus: factory.reservationStatusType.ReservationPending,
427
+ reservedTicket: params.reservedTicket,
446
428
  // 最適化(2022-12-19~)
447
429
  underName: {
448
430
  typeOf: params.agent.typeOf,
@@ -463,18 +445,13 @@ function createReservation(params) {
463
445
  : undefined);
464
446
  }
465
447
  else {
466
- // const issuedThrough: factory.reservation.busReservation.IIssuedThrough = {
467
- // typeOf: factory.product.ProductType.Transportation,
468
- // // 興行IDを追加(2022-09-08~)
469
- // id: eventOffers.itemOffered.id,
470
- // availableChannel,
471
- // // issuedThrough.serviceTypeを連携
472
- // ...(typeof serviceTypeOfIssuedThrough?.typeOf === 'string') ? { serviceType: serviceTypeOfIssuedThrough } : undefined
473
- // };
474
448
  return Object.assign(Object.assign(Object.assign({ project: params.project, typeOf: factory.reservationType.BusReservation, id: params.id,
475
449
  // reservationPackage保管に移行(2023-06-06~)
476
450
  // issuedThrough,
477
- additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending, reservedTicket: params.reservedTicket, underName: {
451
+ additionalProperty: params.additionalProperty, bookingTime: params.reserveDate, modifiedTime: params.reserveDate, numSeats: 1, price: price4reservation, priceCurrency: factory.priceCurrency.JPY, reservationNumber: params.reservationNumber,
452
+ // statusは不要なので削除(2023-07-19~)
453
+ // reservationStatus: factory.reservationStatusType.ReservationPending,
454
+ reservedTicket: params.reservedTicket, underName: {
478
455
  typeOf: params.agent.typeOf,
479
456
  name: params.agent.name
480
457
  }, checkedIn: false, attended: false }, (typeof params.additionalTicketText === 'string') ? { additionalTicketText: params.additionalTicketText } : undefined), (Array.isArray(params.subReservation))
@@ -96,7 +96,6 @@ type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail &
96
96
  * 取引開始
97
97
  */
98
98
  export declare function start(params: IStartParams & {
99
- disablePendingReservations: boolean;
100
99
  useHoldStockByTransactionNumber: boolean;
101
100
  stockHoldUntilDaysAfterEventEnd: number;
102
101
  }): IStartOperation<{
@@ -55,7 +55,7 @@ function start(params) {
55
55
  now,
56
56
  store: { id: (_c = params.availableAtOrFrom) === null || _c === void 0 ? void 0 : _c.id }
57
57
  });
58
- const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { reservationNumber: reservationNumber }));
58
+ const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { provider: { id: event.organizer.id }, reservationNumber: reservationNumber }));
59
59
  // 取引作成
60
60
  let transaction;
61
61
  try {
@@ -139,20 +139,6 @@ function addReservations(params) {
139
139
  // 予約イベント最適化
140
140
  const reservationFor = (0, factory_1.createReservationFor)(event);
141
141
  const { issuedThrough } = (0, factory_1.createIssuedThrough)({ reservationFor: event });
142
- // const minimizedObjectSubReservations: factory.assetTransaction.reserve.IMinimizedObjectSubReservation[] =
143
- // objectSubReservations.map((r) => {
144
- // return {
145
- // id: r.id,
146
- // typeOf: r.typeOf,
147
- // reservedTicket: {
148
- // ticketType: r.reservedTicket.ticketType,
149
- // ...(typeof r.reservedTicket.ticketedSeat?.typeOf === 'string')
150
- // ? { ticketedSeat: r.reservedTicket.ticketedSeat }
151
- // : undefined
152
- // },
153
- // ...(Array.isArray(r.subReservation)) ? { subReservation: r.subReservation } : undefined
154
- // };
155
- // });
156
142
  // 取引に予約追加
157
143
  let lockedOfferRateLimitKeys = [];
158
144
  try {
@@ -165,9 +151,7 @@ function addReservations(params) {
165
151
  // issuedThroughを追加(2023-06-05~)
166
152
  issuedThrough,
167
153
  reservationFor,
168
- // subReservationにreservationForを保管しない(2021-10-19~)
169
154
  subReservation: objectSubReservations
170
- // subReservation: minimizedObjectSubReservations
171
155
  }
172
156
  });
173
157
  }
@@ -191,10 +175,11 @@ function addReservations(params) {
191
175
  },
192
176
  stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
193
177
  })(repos);
194
- if (transaction.object.disablePendingReservations !== true) {
195
- // 予約作成(insertManyで実装)
196
- yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
197
- }
178
+ // 完全廃止(2023-07-19~)
179
+ // if (transaction.object.disablePendingReservations !== true) {
180
+ // // 予約作成(insertManyで実装)
181
+ // await repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
182
+ // }
198
183
  // ストックホルダー処理(stockHolderで残席数を集計しているので必要)
199
184
  yield onReservationsCreated({ event })(repos);
200
185
  return { transaction, objectSubReservations, issuedThrough };
@@ -546,7 +531,7 @@ function validateProgramMembershipUsed(params) {
546
531
  function createPermitService(params) {
547
532
  return (repos) => __awaiter(this, void 0, void 0, function* () {
548
533
  var _a, _b, _c, _d, _e, _f, _g;
549
- const product = yield repos.product.findById({ id: params.issuedThrough.id });
534
+ const product = yield repos.product.findById({ id: params.issuedThrough.id }, ['availableChannel'], []);
550
535
  const permitServiceEndpoint = (_a = product.availableChannel) === null || _a === void 0 ? void 0 : _a.serviceUrl;
551
536
  const permitServiceAuthorizeServerDomain = (_c = (_b = product.availableChannel) === null || _b === void 0 ? void 0 : _b.credentials) === null || _c === void 0 ? void 0 : _c.authorizeServerDomain;
552
537
  const permitServiceClientId = (_e = (_d = product.availableChannel) === null || _d === void 0 ? void 0 : _d.credentials) === null || _e === void 0 ? void 0 : _e.clientId;
@@ -0,0 +1,11 @@
1
+ import * as factory from '../../factory';
2
+ import { MongoRepository as ActionRepo } from '../../repo/action';
3
+ import { MongoRepository as EventRepo } from '../../repo/event';
4
+ import { MongoRepository as PlaceRepo } from '../../repo/place';
5
+ import { MongoRepository as TaskRepo } from '../../repo/task';
6
+ export declare function createEvent(params: factory.task.createEvent.IData): (repos: {
7
+ action: ActionRepo;
8
+ event: EventRepo;
9
+ place: PlaceRepo;
10
+ task: TaskRepo;
11
+ }) => Promise<void>;
@@ -0,0 +1,112 @@
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.createEvent = void 0;
13
+ const factory = require("../../factory");
14
+ function createEvent(params) {
15
+ // tslint:disable-next-line:max-func-body-length
16
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
17
+ var _a, _b;
18
+ const actionAttributes = params;
19
+ const action = yield repos.action.start(actionAttributes);
20
+ let eventIds = [];
21
+ let eventType;
22
+ try {
23
+ if (actionAttributes.object.length > 0) {
24
+ if (((_a = actionAttributes.instrument) === null || _a === void 0 ? void 0 : _a.createScreeningEventSeriesIfNotExistByWorkPerformed) === true) {
25
+ const createScreeningEventSeriesOnAllLocation = ((_b = actionAttributes.instrument) === null || _b === void 0 ? void 0 : _b.createScreeningEventSeriesOnAllLocation) === true;
26
+ let creatingEventParams = actionAttributes.object.map((p) => {
27
+ if (p.typeOf !== factory.eventType.ScreeningEventSeries) {
28
+ throw new factory.errors.Argument('typeOf', `must be ${factory.eventType.ScreeningEventSeries}`);
29
+ }
30
+ return { attributes: p };
31
+ });
32
+ // 全施設対応(2023-07-21~)
33
+ if (createScreeningEventSeriesOnAllLocation) {
34
+ if (creatingEventParams.length !== 1) {
35
+ throw new factory.errors.NotImplemented('creatingEventAttributes.length must be 1');
36
+ }
37
+ const firstCreatingEventParams = creatingEventParams[0];
38
+ const movieTheaters = yield repos.place.searchMovieTheaters({
39
+ project: { id: { $eq: actionAttributes.project.id } }
40
+ }, ['_id', 'branchCode', 'kanaName', 'name'], []);
41
+ creatingEventParams = movieTheaters.map((movieTheater) => {
42
+ const location = {
43
+ branchCode: movieTheater.branchCode,
44
+ id: movieTheater.id,
45
+ kanaName: movieTheater.kanaName,
46
+ name: movieTheater.name,
47
+ typeOf: factory.placeType.MovieTheater
48
+ };
49
+ return {
50
+ attributes: Object.assign(Object.assign({}, firstCreatingEventParams.attributes), { location })
51
+ };
52
+ });
53
+ }
54
+ const bulkWriteResult = yield repos.event.createScreeningEventSeriesIfNotExistByWorkPerformed(creatingEventParams);
55
+ let upsertedIds;
56
+ if (bulkWriteResult !== undefined) {
57
+ upsertedIds = bulkWriteResult.getUpsertedIds()
58
+ .map((doc) => doc._id.toString());
59
+ }
60
+ eventIds = (Array.isArray(upsertedIds)) ? upsertedIds : [];
61
+ eventType = factory.eventType.ScreeningEventSeries;
62
+ }
63
+ else {
64
+ // no op
65
+ throw new factory.errors.NotImplemented('only createScreeningEventSeriesIfNotExistByWorkPerformed implemented');
66
+ }
67
+ }
68
+ }
69
+ catch (error) {
70
+ // actionにエラー結果を追加
71
+ try {
72
+ const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
73
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
74
+ }
75
+ catch (__) {
76
+ // 失敗したら仕方ない
77
+ }
78
+ throw error;
79
+ }
80
+ // アクション完了
81
+ yield repos.action.complete({
82
+ typeOf: action.typeOf,
83
+ id: action.id,
84
+ result: (Array.isArray(eventIds))
85
+ ? eventIds.map((eventId) => {
86
+ return { id: eventId };
87
+ })
88
+ : undefined
89
+ });
90
+ if (Array.isArray(eventIds) && eventIds.length > 0 && typeof eventType === 'string') {
91
+ // 非同期に変更(2023-06-08~)
92
+ const onEventChangedTask = {
93
+ project: actionAttributes.project,
94
+ name: factory.taskName.OnEventChanged,
95
+ status: factory.taskStatus.Ready,
96
+ runsAt: new Date(),
97
+ remainingNumberOfTries: 3,
98
+ numberOfTried: 0,
99
+ executionResults: [],
100
+ data: {
101
+ id: eventIds,
102
+ project: { id: actionAttributes.project.id },
103
+ typeOf: eventType,
104
+ isNew: true,
105
+ useInform: true
106
+ }
107
+ };
108
+ yield repos.task.saveMany([onEventChangedTask], { emitImmediately: true });
109
+ }
110
+ });
111
+ }
112
+ exports.createEvent = createEvent;
@@ -6,6 +6,7 @@ import { MongoRepository as ProjectRepo } from '../repo/project';
6
6
  import { MongoRepository as SellerRepo } from '../repo/seller';
7
7
  import { MongoRepository as TaskRepo } from '../repo/task';
8
8
  import * as factory from '../factory';
9
+ import { createEvent } from './event/createEvent';
9
10
  /**
10
11
  * Googleで作品画像を検索する
11
12
  */
@@ -71,3 +72,4 @@ export declare function updateEvent4ttts(params: {
71
72
  project: ProjectRepo;
72
73
  task: TaskRepo;
73
74
  }) => Promise<void>;
75
+ export { createEvent };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.updateEvent4ttts = exports.createScreeningEventIdFromCOA = exports.importFromCOA = void 0;
12
+ exports.createEvent = exports.updateEvent4ttts = exports.createScreeningEventIdFromCOA = exports.importFromCOA = void 0;
13
13
  /**
14
14
  * マスターデータ同期サービス
15
15
  */
@@ -21,6 +21,8 @@ const difference = require("lodash.difference");
21
21
  const moment = require("moment-timezone");
22
22
  const credentials_1 = require("../credentials");
23
23
  const factory = require("../factory");
24
+ const createEvent_1 = require("./event/createEvent");
25
+ Object.defineProperty(exports, "createEvent", { enumerable: true, get: function () { return createEvent_1.createEvent; } });
24
26
  const offer_1 = require("./offer");
25
27
  const debug = createDebug('chevre-domain:service:event');
26
28
  const coaAuthClient = new COA.auth.RefreshToken({
@@ -670,7 +672,7 @@ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromC
670
672
  },
671
673
  kanaName: theaterFromCOA.theaterNameKana,
672
674
  containsPlace: screensFromCOA.map((screenFromCOA) => {
673
- return createScreeningRoomFromCOA(project, screenFromCOA);
675
+ return createScreeningRoomFromCOA(project, seller, screenFromCOA);
674
676
  }),
675
677
  typeOf: factory.placeType.MovieTheater,
676
678
  telephone: theaterFromCOA.theaterTelNum,
@@ -712,7 +714,7 @@ function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromC
712
714
  */
713
715
  // tslint:disable-next-line:no-single-line-block-comment
714
716
  /* istanbul ignore next */
715
- function createScreeningRoomFromCOA(project, screenFromCOA) {
717
+ function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
716
718
  const sections = [];
717
719
  const sectionCodes = [];
718
720
  screenFromCOA.listSeat.forEach((seat) => {
@@ -751,7 +753,9 @@ function createScreeningRoomFromCOA(project, screenFromCOA) {
751
753
  en: screenFromCOA.screenNameEng
752
754
  },
753
755
  typeOf: factory.placeType.ScreeningRoom,
754
- maximumAttendeeCapacity: sections[0].containsPlace.length
756
+ maximumAttendeeCapacity: sections[0].containsPlace.length,
757
+ // 必須化(2023-07-14~)
758
+ parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
755
759
  };
756
760
  }
757
761
  function updateEvent4ttts(params) {
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { MongoRepository as MemberRepo } from '../repo/member';
5
5
  import { MongoRepository as RoleRepo } from '../repo/role';
6
+ import * as factory from '../factory';
6
7
  export type IPermission = string;
7
8
  /**
8
9
  * プロジェクトメンバーの権限を検索する
@@ -13,6 +14,10 @@ export declare function searchPermissions(params: {
13
14
  };
14
15
  member: {
15
16
  id: string;
17
+ memberOf: {
18
+ id: string;
19
+ typeOf: factory.organizationType.Corporation | factory.organizationType.Project;
20
+ };
16
21
  };
17
22
  }): (repos: {
18
23
  member: MemberRepo;
@@ -18,30 +18,18 @@ function searchPermissions(params) {
18
18
  let permissions = [];
19
19
  const hasRole = yield repos.member.aggregateRoleNames({
20
20
  project: { id: { $eq: params.project.id } },
21
- member: { id: { $eq: params.member.id } }
21
+ member: {
22
+ id: { $eq: params.member.id },
23
+ memberOf: {
24
+ id: { $eq: params.member.memberOf.id },
25
+ typeOf: { $eq: params.member.memberOf.typeOf }
26
+ }
27
+ }
22
28
  });
23
29
  if (hasRole.length > 0) {
24
30
  permissions = yield repos.role.aggregatePermissions({ roleName: { $in: hasRole.map((r) => r.roleName) } });
25
31
  }
26
32
  return { hasRole, permissions };
27
- // let permissions: IPermission[] = [];
28
- // const projectMembers = await repos.member.search({
29
- // project: { id: { $eq: params.project.id } },
30
- // member: { id: { $eq: params.member.id } }
31
- // });
32
- // // 持っているロールを検索
33
- // const roleNames = projectMembers.reduce<string[]>(
34
- // (a, b) => [...a, ...(Array.isArray(b.member.hasRole)) ? b.member.hasRole.map((r) => r.roleName) : []],
35
- // []
36
- // );
37
- // const roles = await repos.role.search({ roleName: { $in: roleNames } });
38
- // // 権限をまとめる
39
- // permissions = roles.reduce<string[]>(
40
- // (a, b) => [...a, ...b.permissions],
41
- // []
42
- // );
43
- // permissions = [...new Set(permissions)];
44
- // return { roleNames, permissions };
45
33
  });
46
34
  }
47
35
  exports.searchPermissions = searchPermissions;
@@ -22,7 +22,11 @@ const errorHandler_1 = require("../errorHandler");
22
22
  */
23
23
  function authorize(params) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
- const project = yield repos.project.findById({ id: params.project.id });
25
+ const project = yield repos.project.findById({
26
+ id: params.project.id,
27
+ inclusion: ['_id', 'settings', 'typeOf'],
28
+ exclusion: []
29
+ });
26
30
  const transaction = yield repos.assetTransaction.findById({
27
31
  typeOf: params.purpose.typeOf,
28
32
  id: params.purpose.id
@@ -322,7 +326,7 @@ function getIssuedThroughIdByAction(params) {
322
326
  function createPermitServiceCredentials(params) {
323
327
  return (repos) => __awaiter(this, void 0, void 0, function* () {
324
328
  var _a, _b, _c, _d, _e, _f, _g;
325
- const paymentCardService = yield repos.product.findById({ id: params.issuedThrough.id });
329
+ const paymentCardService = yield repos.product.findById({ id: params.issuedThrough.id }, ['availableChannel'], []);
326
330
  const permitServiceEndpoint = (_a = paymentCardService.availableChannel) === null || _a === void 0 ? void 0 : _a.serviceUrl;
327
331
  const permitServiceAuthorizeServerDomain = (_c = (_b = paymentCardService.availableChannel) === null || _b === void 0 ? void 0 : _b.credentials) === null || _c === void 0 ? void 0 : _c.authorizeServerDomain;
328
332
  const permitServiceClientId = (_e = (_d = paymentCardService.availableChannel) === null || _d === void 0 ? void 0 : _d.credentials) === null || _e === void 0 ? void 0 : _e.clientId;
@@ -26,7 +26,11 @@ const debug = createDebug('chevre-domain:service');
26
26
  function sendEmailMessage(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
28
  var _a, _b;
29
- const project = yield repos.project.findById({ id: params.project.id });
29
+ const project = yield repos.project.findById({
30
+ id: params.project.id,
31
+ inclusion: ['_id', 'settings'],
32
+ exclusion: []
33
+ });
30
34
  // アクション開始
31
35
  const action = yield repos.action.start(params);
32
36
  let result = {};
@@ -57,7 +57,6 @@ declare function authorize(params: {
57
57
  */
58
58
  id: string;
59
59
  };
60
- disablePendingReservations: boolean;
61
60
  useHoldStockByTransactionNumber: boolean;
62
61
  stockHoldUntilDaysAfterEventEnd: number;
63
62
  }): IAuthorizeOperation<IAuthorizeOfferAction>;
@@ -67,7 +67,8 @@ function authorize(params) {
67
67
  unitPriceOffers,
68
68
  validateEvent: params.validateEvent === true,
69
69
  validateEventOfferPeriod: params.validateEventOfferPeriod === true,
70
- disablePendingReservations: params.disablePendingReservations,
70
+ // 完全廃止(2023-07-19~)
71
+ // disablePendingReservations: params.disablePendingReservations,
71
72
  useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber,
72
73
  stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd
73
74
  })(repos);
@@ -165,7 +166,10 @@ function processStartReserve4chevre(params) {
165
166
  // requestBody = startParams;
166
167
  const startParamObject = yield validateObjectWithoutDetail(startParams)(repos);
167
168
  // 予約取引開始
168
- const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true, disablePendingReservations: params.disablePendingReservations, useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd }))(repos);
169
+ const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true,
170
+ // 完全廃止(2023-07-19~)
171
+ // disablePendingReservations: params.disablePendingReservations,
172
+ useHoldStockByTransactionNumber: params.useHoldStockByTransactionNumber, stockHoldUntilDaysAfterEventEnd: params.stockHoldUntilDaysAfterEventEnd }))(repos);
169
173
  responseBody = startReserveTransactionResult.transaction;
170
174
  // 予約取引からオファー情報を生成する
171
175
  acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
@@ -18,7 +18,7 @@ function searchTicketOffersByItemOffered(params) {
18
18
  var _a, _b, _c, _d;
19
19
  let catalogId;
20
20
  if (typeof ((_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
21
- const eventService = yield repos.product.findById({ id: (_b = params.itemOffered) === null || _b === void 0 ? void 0 : _b.id });
21
+ const eventService = yield repos.product.findById({ id: (_b = params.itemOffered) === null || _b === void 0 ? void 0 : _b.id }, ['hasOfferCatalog'], []);
22
22
  if (typeof ((_c = eventService.hasOfferCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string') {
23
23
  catalogId = eventService.hasOfferCatalog.id;
24
24
  }
@@ -18,7 +18,7 @@ function searchProductOffers(params) {
18
18
  return (repos) => __awaiter(this, void 0, void 0, function* () {
19
19
  var _a;
20
20
  // プロダクト検索
21
- const productWithOffers = yield repos.product.findById({ id: params.itemOffered.id });
21
+ const productWithOffers = yield repos.product.findById({ id: params.itemOffered.id }, ['hasOfferCatalog'], []);
22
22
  const offerCatalogId = (_a = productWithOffers.hasOfferCatalog) === null || _a === void 0 ? void 0 : _a.id;
23
23
  if (typeof offerCatalogId !== 'string') {
24
24
  return [];