@chevre/domain 22.11.0-alpha.9 → 22.12.0-alpha.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 (156) hide show
  1. package/example/src/chevre/aggregation/aggregateOrderOfCustomer.ts +25 -11
  2. package/example/src/chevre/aggregation/aggregateOrderOfCustomerGlobally.ts +34 -0
  3. package/example/src/chevre/aggregation/aggregateTasks.ts +41 -0
  4. package/example/src/chevre/checkCustomerAttributesLength.ts +109 -0
  5. package/example/src/chevre/notifyAbortedTasksByEmail.ts +1 -1
  6. package/example/src/chevre/reIndex.ts +1 -1
  7. package/example/src/chevre/roles/addEventOfferPermissionIfNotExists.ts +27 -0
  8. package/example/src/chevre/roles/{addAdminInventoryManagerRole.ts → addProjectCreatorRole.ts} +6 -8
  9. package/example/src/chevre/roles/assignGlobalRoles.ts +72 -0
  10. package/example/src/chevre/roles/findPermissions.ts +84 -0
  11. package/example/src/chevre/roles/findRoleNames.ts +117 -0
  12. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +38 -0
  13. package/example/src/chevre/searchEventSeats.ts +1 -1
  14. package/example/src/chevre/searchProducts.ts +28 -0
  15. package/example/src/chevre/settings/addSettings.ts +31 -17
  16. package/example/src/chevre/task/countPotentiallyRunning.ts +41 -0
  17. package/example/src/chevre/task/countTasks.ts +51 -0
  18. package/example/src/chevre/{deleteRunsAtPassedCertainPeriod.ts → task/deleteRunsAtPassedCertainPeriod.ts} +4 -3
  19. package/example/src/chevre/task/deleteUnexpectedTasks.ts +23 -0
  20. package/example/src/chevre/task/emitRunning.ts +89 -0
  21. package/example/src/idaas/auth0/adminApplications.ts +183 -0
  22. package/example/src/idaas/auth0/getToken.ts +55 -0
  23. package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +84 -0
  24. package/example/src/regex.ts +31 -0
  25. package/lib/chevre/eventEmitter/task.d.ts +29 -6
  26. package/lib/chevre/factory/event.d.ts +1 -1
  27. package/lib/chevre/index.d.ts +0 -2
  28. package/lib/chevre/index.js +0 -10
  29. package/lib/chevre/repo/event.js +1 -1
  30. package/lib/chevre/repo/member.d.ts +22 -4
  31. package/lib/chevre/repo/member.js +81 -27
  32. package/lib/chevre/repo/mongoose/schemas/aggregateOrder.js +9 -0
  33. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  34. package/lib/chevre/repo/mongoose/schemas/member/global.d.ts +14 -0
  35. package/lib/chevre/repo/mongoose/schemas/member/global.js +82 -0
  36. package/lib/chevre/repo/mongoose/schemas/product.js +9 -0
  37. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +15 -0
  38. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
  39. package/lib/chevre/repo/mongoose/schemas/task.js +9 -0
  40. package/lib/chevre/repo/order.d.ts +23 -2
  41. package/lib/chevre/repo/order.js +70 -8
  42. package/lib/chevre/repo/pendingReservation.js +1 -0
  43. package/lib/chevre/repo/product.js +12 -17
  44. package/lib/chevre/repo/role.d.ts +5 -4
  45. package/lib/chevre/repo/role.js +35 -32
  46. package/lib/chevre/repo/setting.d.ts +1 -10
  47. package/lib/chevre/repo/setting.js +2 -11
  48. package/lib/chevre/repo/stockHolder.d.ts +4 -27
  49. package/lib/chevre/repo/stockHolder.js +163 -175
  50. package/lib/chevre/repo/task.d.ts +58 -38
  51. package/lib/chevre/repo/task.js +126 -296
  52. package/lib/chevre/repo/transaction.js +10 -10
  53. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +7 -4
  54. package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
  55. package/lib/chevre/service/assetTransaction/registerService.js +4 -0
  56. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +19 -16
  57. package/lib/chevre/service/assetTransaction/reserve/start.js +5 -1
  58. package/lib/chevre/service/code.d.ts +5 -28
  59. package/lib/chevre/service/code.js +3 -79
  60. package/lib/chevre/service/iam.d.ts +17 -7
  61. package/lib/chevre/service/iam.js +26 -6
  62. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +15 -0
  63. package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +38 -0
  64. package/lib/chevre/service/notification.d.ts +2 -1
  65. package/lib/chevre/service/notification.js +3 -1
  66. package/lib/chevre/service/offer/product.js +4 -0
  67. package/lib/chevre/service/order/confirmPayTransaction.d.ts +6 -1
  68. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +3 -3
  69. package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
  70. package/lib/chevre/service/task/aggregateOffers.d.ts +1 -1
  71. package/lib/chevre/service/task/aggregateOffers.js +1 -1
  72. package/lib/chevre/service/task/aggregateOnSystem.d.ts +4 -2
  73. package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +1 -1
  74. package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
  75. package/lib/chevre/service/task/authorizePayment.d.ts +1 -1
  76. package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +1 -1
  77. package/lib/chevre/service/task/cancelPendingReservation.d.ts +1 -1
  78. package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
  79. package/lib/chevre/service/task/cancelReservation.d.ts +1 -1
  80. package/lib/chevre/service/task/cancelReservation.js +1 -1
  81. package/lib/chevre/service/task/checkMovieTicket.d.ts +1 -1
  82. package/lib/chevre/service/task/checkResource.d.ts +1 -1
  83. package/lib/chevre/service/task/checkResource.js +1 -1
  84. package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +1 -1
  85. package/lib/chevre/service/task/confirmPayTransaction.d.ts +2 -2
  86. package/lib/chevre/service/task/confirmPayTransaction.js +3 -2
  87. package/lib/chevre/service/task/confirmRegisterService.d.ts +1 -1
  88. package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
  89. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -2
  90. package/lib/chevre/service/task/confirmReserveTransaction.js +3 -3
  91. package/lib/chevre/service/task/createAccountingReport.d.ts +1 -1
  92. package/lib/chevre/service/task/createEvent.d.ts +1 -1
  93. package/lib/chevre/service/task/deletePerson.d.ts +1 -1
  94. package/lib/chevre/service/task/deleteTransaction.d.ts +1 -1
  95. package/lib/chevre/service/task/givePointAward.d.ts +1 -1
  96. package/lib/chevre/service/task/handleNotification.d.ts +4 -2
  97. package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +1 -1
  98. package/lib/chevre/service/task/importEventsFromCOA.d.ts +1 -1
  99. package/lib/chevre/service/task/importOffersFromCOA.d.ts +1 -1
  100. package/lib/chevre/service/task/invalidatePaymentUrl.d.ts +1 -1
  101. package/lib/chevre/service/task/moneyTransfer.d.ts +1 -1
  102. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +1 -1
  103. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +1 -1
  104. package/lib/chevre/service/task/onEventChanged.d.ts +1 -1
  105. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +1 -1
  106. package/lib/chevre/service/task/onResourceUpdated.d.ts +1 -1
  107. package/lib/chevre/service/task/pay.d.ts +1 -1
  108. package/lib/chevre/service/task/placeOrder.d.ts +1 -1
  109. package/lib/chevre/service/task/publishPaymentUrl.d.ts +1 -1
  110. package/lib/chevre/service/task/refund.d.ts +1 -1
  111. package/lib/chevre/service/task/registerService.d.ts +1 -1
  112. package/lib/chevre/service/task/reserve.d.ts +1 -1
  113. package/lib/chevre/service/task/returnMoneyTransfer.d.ts +1 -1
  114. package/lib/chevre/service/task/returnOrder.d.ts +1 -1
  115. package/lib/chevre/service/task/returnPayTransaction.d.ts +1 -1
  116. package/lib/chevre/service/task/returnPointAward.d.ts +1 -1
  117. package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
  118. package/lib/chevre/service/task/sendEmailMessage.d.ts +1 -1
  119. package/lib/chevre/service/task/sendOrder.d.ts +1 -1
  120. package/lib/chevre/service/task/triggerWebhook.d.ts +1 -1
  121. package/lib/chevre/service/task/useReservation.d.ts +1 -1
  122. package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +1 -1
  123. package/lib/chevre/service/task/voidPayTransaction.d.ts +1 -1
  124. package/lib/chevre/service/task/voidPayment.d.ts +1 -1
  125. package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +1 -1
  126. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  127. package/lib/chevre/service/task/voidReserveTransaction.js +1 -1
  128. package/lib/chevre/service/task.d.ts +7 -29
  129. package/lib/chevre/service/task.js +9 -114
  130. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.d.ts +11 -0
  131. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +105 -0
  132. package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +17 -0
  133. package/lib/chevre/service/taskHandler/onOperationFailed.js +70 -0
  134. package/lib/chevre/service/taskHandler.d.ts +26 -0
  135. package/lib/chevre/service/taskHandler.js +97 -0
  136. package/lib/chevre/service/validation/validateEvent.d.ts +2 -2
  137. package/lib/chevre/service/validation/validateEvent.js +16 -10
  138. package/lib/chevre/service.d.ts +0 -4
  139. package/lib/chevre/service.js +10 -14
  140. package/lib/chevre/settings/aggregation.d.ts +6 -1
  141. package/lib/chevre/settings/aggregation.js +2 -1
  142. package/package.json +6 -4
  143. package/example/src/chevre/adminAuth/adminIdentity.ts +0 -38
  144. package/example/src/chevre/executeOneTask.ts +0 -41
  145. package/example/src/chevre/executeTaskIfExists.ts +0 -80
  146. package/example/src/chevre/findExecutableTask.ts +0 -50
  147. package/example/src/chevre/findSetting.ts +0 -79
  148. package/example/src/chevre/searchPermissions.ts +0 -46
  149. package/example/src/chevre/searchProductOffers.ts +0 -29
  150. package/example/src/chevre/stockHolder/checkIfConflicted.ts +0 -76
  151. package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +0 -186
  152. package/example/src/chevre/stockHolder/migratePendingReservations.ts +0 -96
  153. package/example/src/chevre/stockHolder/playAroundStockHolder.ts +0 -256
  154. package/example/src/chevre/upsertProductsByProductId.ts +0 -100
  155. package/lib/chevre/adminAuth.d.ts +0 -2
  156. package/lib/chevre/adminAuth.js +0 -6
@@ -323,7 +323,7 @@ class TransactionRepo {
323
323
  .lean() // 2024-08-26~
324
324
  .exec();
325
325
  if (doc === null) {
326
- throw new factory.errors.NotFound(this.transactionModel.modelName);
326
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} not found`);
327
327
  }
328
328
  return doc;
329
329
  });
@@ -371,7 +371,7 @@ class TransactionRepo {
371
371
  .lean() // 2024-08-26~
372
372
  .exec();
373
373
  if (doc === null) {
374
- throw new factory.errors.NotFound(this.transactionModel.modelName);
374
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
375
375
  }
376
376
  return doc;
377
377
  });
@@ -389,7 +389,7 @@ class TransactionRepo {
389
389
  .lean() // 2024-08-26~
390
390
  .exec();
391
391
  if (doc === null) {
392
- throw new factory.errors.NotFound(this.transactionModel.modelName);
392
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`);
393
393
  }
394
394
  return doc.object.paymentMethods;
395
395
  });
@@ -407,7 +407,7 @@ class TransactionRepo {
407
407
  .lean() // 2024-08-26~
408
408
  .exec();
409
409
  if (doc === null) {
410
- throw new factory.errors.NotFound(this.transactionModel.modelName);
410
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${factory.transactionType.PlaceOrder} ${factory.transactionStatusType.InProgress} not found`);
411
411
  }
412
412
  return doc.object.orderNumber;
413
413
  });
@@ -425,7 +425,7 @@ class TransactionRepo {
425
425
  .lean() // 2024-08-26~
426
426
  .exec();
427
427
  if (doc === null) {
428
- throw new factory.errors.NotFound(this.transactionModel.modelName);
428
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${factory.transactionType.PlaceOrder} ${params.status.$in.join(' or ')} not found`);
429
429
  }
430
430
  return doc.object.confirmationNumber;
431
431
  });
@@ -448,7 +448,7 @@ class TransactionRepo {
448
448
  .lean()
449
449
  .exec();
450
450
  if (doc === null) {
451
- throw new factory.errors.NotFound(this.transactionModel.modelName);
451
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
452
452
  }
453
453
  });
454
454
  }
@@ -471,7 +471,7 @@ class TransactionRepo {
471
471
  .lean()
472
472
  .exec();
473
473
  if (doc === null) {
474
- throw new factory.errors.NotFound(this.transactionModel.modelName);
474
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
475
475
  }
476
476
  });
477
477
  }
@@ -494,7 +494,7 @@ class TransactionRepo {
494
494
  .lean()
495
495
  .exec();
496
496
  if (doc === null) {
497
- throw new factory.errors.NotFound(this.transactionModel.modelName);
497
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
498
498
  }
499
499
  });
500
500
  }
@@ -538,7 +538,7 @@ class TransactionRepo {
538
538
  .isSameOrBefore(moment(endDate))) {
539
539
  throw new factory.errors.Argument('Transaction id', 'potentially expired');
540
540
  }
541
- throw new factory.errors.NotFound(this.transactionModel.modelName);
541
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
542
542
  }
543
543
  }
544
544
  transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
@@ -914,7 +914,7 @@ class TransactionRepo {
914
914
  throw new factory.errors.Argument('Transaction id', 'Confirmed transaction unable to cancel');
915
915
  }
916
916
  else {
917
- throw new factory.errors.NotFound(this.transactionModel.modelName);
917
+ throw new factory.errors.NotFound(this.transactionModel.modelName, `${params.typeOf} ${factory.transactionStatusType.InProgress} not found`);
918
918
  }
919
919
  }
920
920
  transaction_1.transactionEventEmitter.emitTransactionStatusChanged({
@@ -28,7 +28,7 @@ function aggregateScreeningEvent(params) {
28
28
  ) => __awaiter(this, void 0, void 0, function* () {
29
29
  var _a, _b, _c, _d;
30
30
  // 集計対象イベント検索
31
- const event = yield repos.event.projectEventFieldsById({ id: params.id }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.id', 'superEvent.location.id', 'offers.itemOffered']);
31
+ const event = yield repos.event.projectEventFieldsById({ id: params.id }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.id', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
32
32
  // プロジェクト設定検索
33
33
  const project = yield repos.project.findById({
34
34
  id: event.project.id,
@@ -66,7 +66,7 @@ function aggregateScreeningEvent(params) {
66
66
  startFrom: startFrom,
67
67
  startThrough: startThrough,
68
68
  location: { branchCode: { $eq: event.location.branchCode } }
69
- }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
69
+ }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
70
70
  }
71
71
  else if (event.typeOf === factory.eventType.ScreeningEvent) {
72
72
  aggregatingEvents = yield repos.event.projectEventFields({
@@ -78,7 +78,7 @@ function aggregateScreeningEvent(params) {
78
78
  startFrom: startFrom,
79
79
  startThrough: startThrough,
80
80
  location: { branchCode: { $eq: event.location.branchCode } }
81
- }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
81
+ }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered', 'maximumPhysicalAttendeeCapacity']);
82
82
  }
83
83
  // ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
84
84
  aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
@@ -234,7 +234,10 @@ function aggregateReservationByEvent(params) {
234
234
  reservationStatuses: [factory.reservationStatusType.ReservationConfirmed]
235
235
  });
236
236
  // maximumAttendeeCapacityを決定
237
- const eventLocationMaximumAttendeeCapacity = params.event.location.maximumAttendeeCapacity;
237
+ let eventLocationMaximumAttendeeCapacity = params.event.location.maximumAttendeeCapacity;
238
+ if (typeof params.event.maximumPhysicalAttendeeCapacity === 'number') {
239
+ eventLocationMaximumAttendeeCapacity = params.event.maximumPhysicalAttendeeCapacity;
240
+ }
238
241
  if (typeof eventLocationMaximumAttendeeCapacity === 'number') {
239
242
  maximumAttendeeCapacity = eventLocationMaximumAttendeeCapacity;
240
243
  }
@@ -18,7 +18,7 @@ export declare function validateStartParams(params: IStartParams): (repos: {
18
18
  assetTransaction: AssetTransactionRepo;
19
19
  }) => Promise<{
20
20
  reserveTransaction: import("@chevre/factory/lib/assetTransaction/reserve").ITransaction | undefined;
21
- reservations: (Pick<import("@chevre/factory/lib/reservation/event").IReservation, "id" | "typeOf" | "reservationNumber" | "issuedThrough"> & {
21
+ reservations: (Pick<import("@chevre/factory/lib/reservation/event").IReservation, "id" | "typeOf" | "issuedThrough" | "reservationNumber"> & {
22
22
  reservationFor: Pick<factory.reservation.IReservationFor<factory.reservationType.EventReservation>, "id" | "typeOf">;
23
23
  })[] | undefined;
24
24
  }>;
@@ -56,6 +56,10 @@ function start(params) {
56
56
  if (product === undefined) {
57
57
  throw new factory.errors.NotFound('Product');
58
58
  }
59
+ if (product.typeOf !== factory.product.ProductType.MembershipService
60
+ && product.typeOf !== factory.product.ProductType.PaymentCard) {
61
+ throw new factory.errors.Argument('object.itemOffered.id', `invalid product type: ${product.typeOf}`);
62
+ }
59
63
  const transactionNumber = params.transactionNumber;
60
64
  if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
61
65
  throw new factory.errors.ArgumentNull('transactionNumber');
@@ -187,22 +187,25 @@ function searchAvailableAddOns(params) {
187
187
  const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false, includedInDataCatalog: { id: '' }, useIncludeInDataCatalog: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
188
188
  ? { availableAt: { id: params.availableAtOrFrom.id } }
189
189
  : undefined))(repos);
190
- availableAddOns.push(...offers.map((o) => {
191
- const itemOffered4addOn = {
192
- description: product.description,
193
- id: product.id,
194
- name: product.name,
195
- productID: product.productID,
196
- typeOf: product.typeOf
197
- };
198
- const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
199
- return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
200
- });
201
- if ((unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.typeOf) !== factory.priceSpecificationType.UnitPriceSpecification) {
202
- throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
203
- }
204
- return Object.assign(Object.assign({ alternateName: o.alternateName, availability: o.availability, description: o.description, id: String(o.id), identifier: o.identifier, itemOffered: itemOffered4addOn, name: o.name, priceCurrency: o.priceCurrency, priceSpecification: unitPriceSpec, typeOf: o.typeOf }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
205
- }));
190
+ const productType = product.typeOf;
191
+ if (productType === factory.product.ProductType.Product) {
192
+ availableAddOns.push(...offers.map((o) => {
193
+ const itemOffered4addOn = {
194
+ description: product.description,
195
+ id: product.id,
196
+ name: product.name,
197
+ productID: product.productID,
198
+ typeOf: productType
199
+ };
200
+ const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
201
+ return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
202
+ });
203
+ if ((unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.typeOf) !== factory.priceSpecificationType.UnitPriceSpecification) {
204
+ throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
205
+ }
206
+ return Object.assign(Object.assign({ alternateName: o.alternateName, availability: o.availability, description: o.description, id: String(o.id), identifier: o.identifier, itemOffered: itemOffered4addOn, name: o.name, priceCurrency: o.priceCurrency, priceSpecification: unitPriceSpec, typeOf: o.typeOf }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
207
+ }));
208
+ }
206
209
  }
207
210
  }
208
211
  return availableAddOns;
@@ -100,7 +100,7 @@ function fixEvent(params) {
100
100
  // additionalProperty, // discontinue(2024-07-20~)
101
101
  'name', 'doorTime', 'endDate', 'eventStatus',
102
102
  'location', 'startDate', 'superEvent',
103
- 'offers'
103
+ 'offers', 'maximumPhysicalAttendeeCapacity'
104
104
  // 'coaInfo', // discontinue(2024-07-24~)
105
105
  // 'identifier' // discontinue(2024-07-24~)
106
106
  ]);
@@ -504,6 +504,7 @@ function processLockOfferRateLimit(params) {
504
504
  /**
505
505
  * 座席ロックプロセス
506
506
  */
507
+ // tslint:disable-next-line:max-func-body-length
507
508
  function processLockSeats(params) {
508
509
  return (repos) => __awaiter(this, void 0, void 0, function* () {
509
510
  var _a, _b, _c, _d, _e;
@@ -554,6 +555,9 @@ function processLockSeats(params) {
554
555
  const bookingTime = params.transaction.startDate; // fix as transactionNumber(2024-07-02~)
555
556
  const hasTicketedSeat = ((_d = (_c = (_b = params.event.offers.itemOffered.serviceOutput) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat) === null || _d === void 0 ? void 0 : _d.typeOf) === factory.placeType.Seat;
556
557
  let maximumAttendeeCapacity4event = (_e = params.event.location) === null || _e === void 0 ? void 0 : _e.maximumAttendeeCapacity;
558
+ if (typeof params.event.maximumPhysicalAttendeeCapacity === 'number') {
559
+ maximumAttendeeCapacity4event = params.event.maximumPhysicalAttendeeCapacity;
560
+ }
557
561
  // 座席無の場合デフォルトmaximumAttendeeCapacityを適用(2025-04-20~)
558
562
  if (!hasTicketedSeat) {
559
563
  if (typeof maximumAttendeeCapacity4event !== 'number') {
@@ -1,31 +1,8 @@
1
- import type { AuthorizationRepo } from '../repo/authorization';
2
- import type { JWTSettingRepo } from '../repo/setting/jwt';
3
- import type { TicketRepo } from '../repo/ticket';
4
- import * as factory from '../factory';
5
- type IToken = string;
6
- interface IPayload extends Pick<factory.clientUser.IClientUser, 'aud' | 'exp' | 'iat' | 'iss' | 'sub' | 'token_use' | 'typ' | 'version'> {
7
- version: string;
8
- typ: string;
9
- jti?: string;
10
- }
1
+ /**
2
+ * 承認サービス
3
+ * ひとまず不要なので廃止(2025-07-18~)
4
+ */
11
5
  /**
12
6
  * コードをトークンに変換する
13
7
  */
14
- declare function getToken(params: {
15
- agent: {
16
- id: string;
17
- typeOf: factory.creativeWorkType.SoftwareApplication | factory.creativeWorkType.WebApplication | factory.personType.Person;
18
- };
19
- project: {
20
- id: string;
21
- };
22
- code: string;
23
- expiresIn: number;
24
- }): (repos: {
25
- authorization: AuthorizationRepo;
26
- jwtSetting: JWTSettingRepo;
27
- ticket: TicketRepo;
28
- }) => Promise<{
29
- token: IToken;
30
- }>;
31
- export { IPayload, getToken };
8
+ export {};
@@ -1,83 +1,7 @@
1
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.getToken = getToken;
13
2
  /**
14
3
  * 承認サービス
4
+ * ひとまず不要なので廃止(2025-07-18~)
15
5
  */
16
- const jwt = require("jsonwebtoken");
17
- const factory = require("../factory");
18
- /**
19
- * コードをトークンに変換する
20
- */
21
- function getToken(params) {
22
- return (repos) => __awaiter(this, void 0, void 0, function* () {
23
- var _a;
24
- const jwtSetting = yield repos.jwtSetting.findDefault();
25
- if (typeof params.project.id !== 'string' || params.project.id.length === 0) {
26
- throw new factory.errors.ArgumentNull('project.id');
27
- }
28
- if (typeof params.code !== 'string' || params.code.length === 0) {
29
- throw new factory.errors.ArgumentNull('code');
30
- }
31
- const authorization = yield repos.authorization.findValidOneByCode({
32
- project: { id: params.project.id },
33
- code: params.code
34
- });
35
- // if (typeof params.issuer !== 'string' || params.issuer.length === 0) {
36
- // throw new factory.errors.ArgumentNull('issuer');
37
- // }
38
- let subject;
39
- let typ;
40
- // jti必須化(2024-08-22~)
41
- const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
42
- const jti = id;
43
- // ロール承認の場合、subjectはメンバーID,typはメンバータイプ
44
- if (authorization.object.typeOf === factory.role.RoleType.OrganizationRole) {
45
- subject = authorization.object.member.id;
46
- typ = `${jwtSetting.payloadTypPrefix}:${authorization.object.member.typeOf}`;
47
- }
48
- else {
49
- // useJtiの場合、subject,typはagent(2024-05-09~)
50
- subject = params.agent.id;
51
- typ = `${jwtSetting.payloadTypPrefix}:${params.agent.typeOf}`;
52
- }
53
- const payload = {
54
- token_use: 'access', // 拡張(2024-05-01~)
55
- version: jwtSetting.version, // 拡張(2024-05-02~)
56
- typ // 拡張(2024-05-07~)
57
- };
58
- const token = yield new Promise((resolve, reject) => {
59
- // 所有権を暗号化する
60
- jwt.sign(payload, jwtSetting.secret, {
61
- algorithm: jwtSetting.algorithm, // 明示的に指定(2024-05-05~)
62
- issuer: jwtSetting.issuer, // 都度指定に変更(2024-05-05~)
63
- expiresIn: params.expiresIn,
64
- subject, // 拡張(2024-05-01~)
65
- audience: jwtSetting.issuer, // 拡張(2024-05-02~)
66
- jwtid: jti // 拡張(2024-05-08~)
67
- }, (err, encoded) => {
68
- if (err instanceof Error) {
69
- reject(err);
70
- }
71
- else {
72
- if (typeof encoded !== 'string') {
73
- reject(new factory.errors.Internal('authorization.object cannot be signed unexpectedly'));
74
- }
75
- else {
76
- resolve(encoded);
77
- }
78
- }
79
- });
80
- });
81
- return { token };
82
- });
83
- }
6
+ // import * as jwt from 'jsonwebtoken';
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,7 +8,7 @@ export type IPermission = string;
8
8
  /**
9
9
  * プロジェクトメンバーの権限を検索する
10
10
  */
11
- export declare function searchPermissions(params: {
11
+ export declare function findProjectPermissionsByMember(params: {
12
12
  project: {
13
13
  id: string;
14
14
  };
@@ -23,10 +23,20 @@ export declare function searchPermissions(params: {
23
23
  member: MemberRepo;
24
24
  role: RoleRepo;
25
25
  }) => Promise<{
26
- hasRole: {
27
- roleName: string;
28
- }[];
29
- permissions: {
30
- _id: string;
31
- }[];
26
+ roleNames: string[];
27
+ permissions: string[];
28
+ }>;
29
+ /**
30
+ * グローバル権限を検索する
31
+ */
32
+ export declare function findGloablPermissionsByMember(params: {
33
+ member: {
34
+ id: string;
35
+ };
36
+ }): (repos: {
37
+ member: MemberRepo;
38
+ role: RoleRepo;
39
+ }) => Promise<{
40
+ roleNames: string[];
41
+ permissions: string[];
32
42
  }>;
@@ -9,14 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.searchPermissions = searchPermissions;
12
+ exports.findProjectPermissionsByMember = findProjectPermissionsByMember;
13
+ exports.findGloablPermissionsByMember = findGloablPermissionsByMember;
13
14
  /**
14
15
  * プロジェクトメンバーの権限を検索する
15
16
  */
16
- function searchPermissions(params) {
17
+ function findProjectPermissionsByMember(params) {
17
18
  return (repos) => __awaiter(this, void 0, void 0, function* () {
18
19
  let permissions = [];
19
- const hasRole = yield repos.member.aggregateRoleNames({
20
+ // const hasRole = await repos.member.aggregateRoleNames({
21
+ const roleNames = yield repos.member.findRoleNamesByMember({
20
22
  project: { id: { $eq: params.project.id } },
21
23
  member: {
22
24
  id: { $eq: params.member.id },
@@ -26,9 +28,27 @@ function searchPermissions(params) {
26
28
  }
27
29
  }
28
30
  });
29
- if (hasRole.length > 0) {
30
- permissions = yield repos.role.aggregatePermissions({ roleName: { $in: hasRole.map((r) => r.roleName) } });
31
+ if (roleNames.length > 0) {
32
+ // permissions = await repos.role.aggregatePermissions({ roleName: { $in: hasRole.map((r) => r.roleName) } });
33
+ permissions = yield repos.role.findUniquePermissionsByRoleName({ roleName: { $in: roleNames } });
31
34
  }
32
- return { hasRole, permissions };
35
+ return { roleNames, permissions };
36
+ });
37
+ }
38
+ /**
39
+ * グローバル権限を検索する
40
+ */
41
+ function findGloablPermissionsByMember(params) {
42
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
43
+ let permissions = [];
44
+ const roleNames = yield repos.member.findGlobalRoleNamesByMember({
45
+ member: {
46
+ id: { $eq: params.member.id }
47
+ }
48
+ });
49
+ if (roleNames.length > 0) {
50
+ permissions = yield repos.role.findUniquePermissionsByRoleName({ roleName: { $in: roleNames } });
51
+ }
52
+ return { roleNames, permissions };
33
53
  });
34
54
  }
@@ -0,0 +1,15 @@
1
+ import { SendGridCredentials } from '../../credentials/sendGrid';
2
+ import type { TaskRepo } from '../../repo/task';
3
+ import { Settings } from '../../settings';
4
+ /**
5
+ * 中止されたタスクリストをEメールで通知する
6
+ * add(2025-03-13~)
7
+ */
8
+ declare function notifyAbortedTasksByEmail(params: {
9
+ dateAbortedGte: Date;
10
+ }): (repos: {
11
+ task: TaskRepo;
12
+ }, settings: Pick<Settings, "abortedTasksWithoutReport">, credentials: {
13
+ sendGrid: SendGridCredentials;
14
+ }) => Promise<void>;
15
+ export { notifyAbortedTasksByEmail };
@@ -0,0 +1,38 @@
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.notifyAbortedTasksByEmail = notifyAbortedTasksByEmail;
13
+ const createDebug = require("debug");
14
+ const factory = require("../../factory");
15
+ const factory_1 = require("./factory");
16
+ const notifyByEmail_1 = require("./notifyByEmail");
17
+ const debug = createDebug('chevre-domain:service:notification');
18
+ /**
19
+ * 中止されたタスクリストをEメールで通知する
20
+ * add(2025-03-13~)
21
+ */
22
+ function notifyAbortedTasksByEmail(params) {
23
+ return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
24
+ const { abortedTasksWithoutReport } = settings;
25
+ const abortedTasks = yield repos.task.projectFields(Object.assign({ status: { $eq: factory.taskStatus.Aborted }, dateAborted: { $gte: params.dateAbortedGte } }, (abortedTasksWithoutReport.length > 0)
26
+ ? { name: { $nin: abortedTasksWithoutReport } }
27
+ : undefined), []);
28
+ if (abortedTasks.length > 0) {
29
+ // 開発者へ報告
30
+ const message = (0, factory_1.tasks2lineNotify)({ tasks: abortedTasks });
31
+ const notifyResult = yield (0, notifyByEmail_1.notifyByEmail)({
32
+ subject: message.subject, content: message.content,
33
+ logLevel: 'error'
34
+ })({}, credentials);
35
+ debug('notifyResult:', notifyResult);
36
+ }
37
+ });
38
+ }
@@ -1,4 +1,5 @@
1
+ import { notifyAbortedTasksByEmail } from './notification/notifyAbortedTasksByEmail';
1
2
  import { notifyByEmail } from './notification/notifyByEmail';
2
3
  import { sendEmailMessage } from './notification/sendEmailMessage';
3
4
  import { triggerWebhook } from './notification/triggerWebhook';
4
- export { notifyByEmail, sendEmailMessage, triggerWebhook };
5
+ export { notifyAbortedTasksByEmail, notifyByEmail, sendEmailMessage, triggerWebhook };
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.triggerWebhook = exports.sendEmailMessage = exports.notifyByEmail = void 0;
3
+ exports.triggerWebhook = exports.sendEmailMessage = exports.notifyByEmail = exports.notifyAbortedTasksByEmail = void 0;
4
+ const notifyAbortedTasksByEmail_1 = require("./notification/notifyAbortedTasksByEmail");
5
+ Object.defineProperty(exports, "notifyAbortedTasksByEmail", { enumerable: true, get: function () { return notifyAbortedTasksByEmail_1.notifyAbortedTasksByEmail; } });
4
6
  const notifyByEmail_1 = require("./notification/notifyByEmail");
5
7
  Object.defineProperty(exports, "notifyByEmail", { enumerable: true, get: function () { return notifyByEmail_1.notifyByEmail; } });
6
8
  const sendEmailMessage_1 = require("./notification/sendEmailMessage");
@@ -189,6 +189,10 @@ function fixProductAndOffers(params) {
189
189
  if (product === undefined) {
190
190
  throw new factory.errors.NotFound('Product');
191
191
  }
192
+ if (product.typeOf !== factory.product.ProductType.MembershipService
193
+ && product.typeOf !== factory.product.ProductType.PaymentCard) {
194
+ throw new factory.errors.Argument('object.itemOffered.id', `invalid product type: ${product.typeOf}`);
195
+ }
192
196
  const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, includedInDataCatalog: { id: '' }, addSortIndex: false, useIncludeInDataCatalog: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
193
197
  return { product, availableOffers: offers };
194
198
  });
@@ -8,7 +8,12 @@ import type { OrderRepo } from '../../repo/order';
8
8
  import type { ProjectRepo } from '../../repo/project';
9
9
  import type { TaskRepo } from '../../repo/task';
10
10
  import type { TransactionRepo } from '../../repo/transaction';
11
- declare function confirmPayTransaction(data: factory.task.IData<factory.taskName.ConfirmPayTransaction>, options: {}): (repos: {
11
+ declare function confirmPayTransaction(data: factory.task.IData<factory.taskName.ConfirmPayTransaction> & {
12
+ project: {
13
+ id: string;
14
+ typeOf: factory.organizationType.Project;
15
+ };
16
+ }, options: {}): (repos: {
12
17
  acceptedOffer: AcceptedOfferRepo;
13
18
  action: ActionRepo;
14
19
  assetTransaction: AssetTransactionRepo;
@@ -60,14 +60,14 @@ function createConfirmReserveTransactionTasksIfNotExist(order, simpleOrder, opti
60
60
  }
61
61
  yield Promise.all(confirmObjects.map((confirmObject) => __awaiter(this, void 0, void 0, function* () {
62
62
  const data = {
63
- project: order.project,
63
+ // project: order.project, // discontinue(2025-08-20~)
64
64
  typeOf: factory.actionType.ConfirmAction,
65
65
  object: confirmObject,
66
- agent: order.project,
66
+ // agent: order.project, // discontinue(2025-08-20~)
67
67
  purpose: simpleOrder
68
68
  // instrument廃止(2024-03-13~)
69
69
  };
70
- const taskIdentifier = util.format('%s:%s:%s:%s:%s:%s', data.project.id, factory.taskName.ConfirmReserveTransaction, data.purpose.typeOf, data.purpose.orderNumber, data.object.typeOf, data.object.transactionNumber);
70
+ const taskIdentifier = util.format('%s:%s:%s:%s:%s:%s', order.project.id, factory.taskName.ConfirmReserveTransaction, data.purpose.typeOf, data.purpose.orderNumber, data.object.typeOf, data.object.transactionNumber);
71
71
  const confirmReserveTransactionTask = {
72
72
  alternateName: taskIdentifier,
73
73
  identifier: taskIdentifier,
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
2
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -32,7 +32,7 @@ function call(data) {
32
32
  yield (0, aggregateOffers_1.aggregateOffers)(data)({
33
33
  aggregateReservation: new aggregateReservation_1.AggregateReservationRepo(connection),
34
34
  event: new event_1.EventRepo(connection),
35
- stockHolder: new stockHolder_1.StockHolderRepo(redisClient, connection),
35
+ stockHolder: new stockHolder_1.StockHolderRepo({ connection }),
36
36
  offer: new unitPriceInCatalog_1.OfferRepo(connection),
37
37
  offerCatalog: new offerCatalog_1.OfferCatalogRepo(connection),
38
38
  offerRateLimit: new offer_1.OfferRateLimitRepo(redisClient),
@@ -1,3 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
3
- export declare function call(params: Pick<factory.task.aggregateOnSystem.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
2
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
3
+ export declare function call(params: Pick<factory.task.aggregateOnSystem.ITask, IExecutableTaskKeys> & {
4
+ status: factory.taskStatus.Running;
5
+ }): IOperationExecute<ICallResult>;
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -32,7 +32,7 @@ function call(data) {
32
32
  }
33
33
  yield AggregationService.event.aggregateScreeningEvent(data)({
34
34
  event: new event_1.EventRepo(connection),
35
- stockHolder: new stockHolder_1.StockHolderRepo(redisClient, connection),
35
+ stockHolder: new stockHolder_1.StockHolderRepo({ connection }),
36
36
  offer: new unitPriceInCatalog_1.OfferRepo(connection),
37
37
  offerCatalog: new offerCatalog_1.OfferCatalogRepo(connection),
38
38
  offerRateLimit: new offer_1.OfferRateLimitRepo(redisClient),
@@ -1,4 +1,4 @@
1
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
1
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
2
2
  import * as factory from '../../factory';
3
3
  /**
4
4
  * タスク実行関数
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { IOperationExecute } from '../task';
2
+ import type { IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../../factory';
2
- import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../task';
2
+ import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
3
3
  /**
4
4
  * タスク実行関数
5
5
  */