@chevre/domain 22.2.0-alpha.2 → 22.2.0-alpha.21

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 (86) hide show
  1. package/example/src/chevre/findValidAuthorization.ts +1 -2
  2. package/example/src/chevre/playAroundTicket.ts +3 -2
  3. package/example/src/chevre/{projectReservationFields.ts → projectFields.ts} +10 -8
  4. package/example/src/chevre/{projectReservationFieldsById.ts → projectOwnershipInfoFieldsById.ts} +4 -4
  5. package/example/src/chevre/searchProjects.ts +9 -4
  6. package/example/src/chevre/searchSellersByAggregate.ts +3 -3
  7. package/example/src/chevre/unsetUnnecessaryFields.ts +4 -30
  8. package/lib/chevre/repo/authorization.d.ts +3 -1
  9. package/lib/chevre/repo/authorization.js +21 -10
  10. package/lib/chevre/repo/categoryCode.d.ts +14 -2
  11. package/lib/chevre/repo/categoryCode.js +41 -19
  12. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +1 -1
  13. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +21 -23
  14. package/lib/chevre/repo/mongoose/schemas/paymentService.js +12 -3
  15. package/lib/chevre/repo/mongoose/schemas/product.js +5 -12
  16. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +1 -1
  17. package/lib/chevre/repo/mongoose/schemas/seller.js +21 -23
  18. package/lib/chevre/repo/ownershipInfo.d.ts +10 -6
  19. package/lib/chevre/repo/ownershipInfo.js +75 -19
  20. package/lib/chevre/repo/paymentService.d.ts +2 -2
  21. package/lib/chevre/repo/paymentService.js +108 -58
  22. package/lib/chevre/repo/paymentServiceProvider.d.ts +1 -10
  23. package/lib/chevre/repo/product.d.ts +2 -2
  24. package/lib/chevre/repo/product.js +67 -33
  25. package/lib/chevre/repo/project.d.ts +4 -4
  26. package/lib/chevre/repo/project.js +69 -28
  27. package/lib/chevre/repo/seller.d.ts +10 -12
  28. package/lib/chevre/repo/seller.js +61 -27
  29. package/lib/chevre/repo/ticket.d.ts +3 -2
  30. package/lib/chevre/repo/ticket.js +23 -10
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
  32. package/lib/chevre/service/aggregation/event/findEventOffers.js +1 -1
  33. package/lib/chevre/service/aggregation/project.js +1 -1
  34. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -2
  35. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
  36. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  37. package/lib/chevre/service/assetTransaction/pay/factory.js +1 -1
  38. package/lib/chevre/service/assetTransaction/pay.js +3 -3
  39. package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
  40. package/lib/chevre/service/assetTransaction/refund/factory.js +1 -1
  41. package/lib/chevre/service/assetTransaction/refund.js +3 -3
  42. package/lib/chevre/service/assetTransaction/registerService.js +4 -6
  43. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +26 -23
  44. package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.js +4 -1
  45. package/lib/chevre/service/assetTransaction/reserve/start.js +1 -3
  46. package/lib/chevre/service/code.d.ts +0 -4
  47. package/lib/chevre/service/code.js +21 -17
  48. package/lib/chevre/service/event.js +3 -3
  49. package/lib/chevre/service/moneyTransfer.js +2 -4
  50. package/lib/chevre/service/notification.js +1 -1
  51. package/lib/chevre/service/offer/event/authorize/factory.js +34 -6
  52. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +0 -2
  53. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +22 -22
  54. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +0 -2
  55. package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
  56. package/lib/chevre/service/offer/event/importFromCOA/factory.d.ts +3 -1
  57. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  58. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -12
  59. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  60. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
  61. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -3
  62. package/lib/chevre/service/offer/product.d.ts +1 -1
  63. package/lib/chevre/service/offer/product.js +4 -6
  64. package/lib/chevre/service/order/sendOrder.js +9 -5
  65. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +1 -6
  66. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +26 -34
  67. package/lib/chevre/service/payment/any.d.ts +3 -3
  68. package/lib/chevre/service/payment/any.js +15 -7
  69. package/lib/chevre/service/payment/paymentCard.js +1 -3
  70. package/lib/chevre/service/report/ownershipInfo.d.ts +3 -1
  71. package/lib/chevre/service/task/authorizePayment.js +0 -2
  72. package/lib/chevre/service/task/onAuthorizationCreated.js +20 -16
  73. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +2 -2
  74. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  75. package/lib/chevre/service/task/onResourceUpdated.js +2 -2
  76. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  77. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  78. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +1 -1
  79. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +36 -2
  80. package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -1
  81. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.d.ts +2 -2
  82. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +1 -1
  83. package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +2 -2
  84. package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -1
  85. package/package.json +3 -3
  86. package/example/src/chevre/searchProducts.ts +0 -28
@@ -29,7 +29,7 @@ function syncCategoryCode(params) {
29
29
  }
30
30
  else {
31
31
  for (const categoryCodeId of params.ids) {
32
- const syncingCategoryCode = (yield repos.categoryCode.search({
32
+ const syncingCategoryCode = (yield repos.categoryCode.projectFields({
33
33
  limit: 1,
34
34
  page: 1,
35
35
  project: { id: { $eq: params.project.id } },
@@ -275,7 +275,7 @@ function createInformMovieTasks(params) {
275
275
  }
276
276
  function createInformProductTasks(params) {
277
277
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
278
- const products4inform = yield repos.product.searchProducts({
278
+ const products4inform = yield repos.product.projectFields({
279
279
  typeOf: { $eq: params.typeOf },
280
280
  id: { $in: params.ids }
281
281
  }, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType'], []);
@@ -322,7 +322,7 @@ function createInformProductTasks(params) {
322
322
  }
323
323
  function createInformCategoryCodeTasks(params) {
324
324
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
325
- const categoryCodes4inform = yield repos.categoryCode.search({
325
+ const categoryCodes4inform = yield repos.categoryCode.projectFields({
326
326
  id: { $in: params.ids },
327
327
  // ひとまずDistributorTypeのみ
328
328
  inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.DistributorType } }
@@ -13,9 +13,11 @@ exports.call = void 0;
13
13
  const factory = require("../../factory");
14
14
  const action_1 = require("../../repo/action");
15
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
+ const authorization_1 = require("../../repo/authorization");
16
17
  const paymentService_1 = require("../../repo/paymentService");
17
18
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
18
19
  const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
20
+ const ticket_1 = require("../../repo/ticket");
19
21
  const transaction_1 = require("../../repo/transaction");
20
22
  const transactionNumber_1 = require("../../repo/transactionNumber");
21
23
  const transactionProcess_1 = require("../../repo/transactionProcess");
@@ -38,9 +40,11 @@ function call(params) {
38
40
  yield (0, any_1.publishPaymentUrl)(Object.assign(Object.assign({}, params.data), { sameAs: { id: params.id } }))({
39
41
  action: actionRepo,
40
42
  assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
43
+ authorization: new authorization_1.AuthorizationRepo(connection),
41
44
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
42
45
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
43
46
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
47
+ ticket: new ticket_1.TicketRepo(connection),
44
48
  transaction: new transaction_1.TransactionRepo(connection),
45
49
  transactionNumber: new transactionNumber_1.TransactionNumberRepo(redisClient)
46
50
  }, settings);
@@ -28,7 +28,7 @@ const CodeService = require("../code");
28
28
  function start(params) {
29
29
  return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
30
30
  const { passport } = yield repos.passport.validatePassportTokenIfExist(params);
31
- const sellers = yield repos.seller.search({
31
+ const sellers = yield repos.seller.projectFields({
32
32
  limit: 1,
33
33
  page: 1,
34
34
  id: { $eq: params.seller.id }
@@ -41,7 +41,7 @@ export declare function validatePaymentMethods(params: {
41
41
  * 興行オファー適用条件確認
42
42
  */
43
43
  export declare function validateEventOffers(params: {
44
- order: factory.transaction.placeOrder.IOrderAsResult;
44
+ order: Pick<factory.transaction.placeOrder.IOrderAsResult, 'price'>;
45
45
  paymentMethods: factory.order.IReferencedInvoice[];
46
46
  authorizeEventServiceOfferActions: Pick<IAuthorizeEventServiceOffer, 'id' | 'instrument' | 'object' | 'result'>[];
47
47
  }): void;
@@ -350,11 +350,12 @@ exports.validatePaymentMethods = validatePaymentMethods;
350
350
  // tslint:disable-next-line:max-func-body-length
351
351
  function validateEventOffers(params) {
352
352
  var _a, _b;
353
- const firstCreditCardPaymentMethodIdentifier = (_b = (_a = params.paymentMethods.find((referenceInvoice) => {
353
+ const { paymentMethods } = params;
354
+ const firstCreditCardPaymentMethodIdentifier = (_b = (_a = paymentMethods.find((referenceInvoice) => {
354
355
  return referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
355
356
  || referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace;
356
357
  })) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
357
- const numCreditCardOrFaceToFacePaymentMethod = params.paymentMethods.filter((referenceInvoice) => {
358
+ const numCreditCardOrFaceToFacePaymentMethod = paymentMethods.filter((referenceInvoice) => {
358
359
  return referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
359
360
  || referenceInvoice.issuedThrough.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace;
360
361
  }).length;
@@ -411,5 +412,38 @@ function validateEventOffers(params) {
411
412
  });
412
413
  }
413
414
  });
415
+ // check programMembershipUsed(2024-08-15~)
416
+ const programMembershipRequired = params.authorizeEventServiceOfferActions.reduce((a, b) => {
417
+ var _a, _b;
418
+ const programMembershipUsedfromResult = (_b = (_a = b.result) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.serviceOutput.programMembershipUsed;
419
+ if (Array.isArray(programMembershipUsedfromResult)) {
420
+ a.push(...programMembershipUsedfromResult);
421
+ }
422
+ return a;
423
+ }, []);
424
+ const satisfyProgramMembershipRequirement = programMembershipRequired.every(({ identifier, issuedThrough }) => {
425
+ let satisfyThisRequirement = false;
426
+ switch (issuedThrough.typeOf) {
427
+ case factory.product.ProductType.MembershipService:
428
+ // 検証の必要なし
429
+ satisfyThisRequirement = true;
430
+ break;
431
+ case factory.service.paymentService.PaymentServiceType.CreditCard:
432
+ satisfyThisRequirement = paymentMethods.some((paymentMethod) => paymentMethod.paymentMethodId === identifier
433
+ && paymentMethod.issuedThrough.id === issuedThrough.id
434
+ && paymentMethod.issuedThrough.typeOf === issuedThrough.typeOf);
435
+ break;
436
+ case factory.service.paymentService.PaymentServiceType.FaceToFace:
437
+ satisfyThisRequirement = paymentMethods.some((paymentMethod) => paymentMethod.paymentMethodId === identifier
438
+ && paymentMethod.issuedThrough.typeOf === issuedThrough.typeOf);
439
+ break;
440
+ default:
441
+ // no op
442
+ }
443
+ return satisfyThisRequirement;
444
+ });
445
+ if (!satisfyProgramMembershipRequirement) {
446
+ throw new factory.errors.Argument('Transaction', `programMembershipUsed requirement not satisfied`);
447
+ }
414
448
  }
415
449
  exports.validateEventOffers = validateEventOffers;
@@ -293,7 +293,7 @@ function createResult(params, options) {
293
293
  price
294
294
  });
295
295
  (0, validation_1.validateEventOffers)({
296
- order: orderAsResult,
296
+ order: { price },
297
297
  paymentMethods,
298
298
  authorizeEventServiceOfferActions: params.authorizeEventServiceOfferActions
299
299
  });
@@ -1,8 +1,8 @@
1
1
  import type { MemberRepo } from '../../../../repo/member';
2
2
  import type { ProjectMakesOfferRepo } from '../../../../repo/projectMakesOffer';
3
- import type { SellerRepo } from '../../../../repo/seller';
3
+ import type { ISellerWithId, SellerRepo } from '../../../../repo/seller';
4
4
  import * as factory from '../../../../factory';
5
- type ISeller = Pick<factory.seller.ISeller, 'id' | 'name' | 'project' | 'typeOf' | 'makesOffer' | 'additionalProperty'>;
5
+ type ISeller = Pick<ISellerWithId, 'id' | 'name' | 'project' | 'typeOf' | 'makesOffer' | 'additionalProperty'>;
6
6
  declare function validateStartRequest(params: {
7
7
  project: {
8
8
  id: string;
@@ -67,7 +67,7 @@ function validateStartRequest(params) {
67
67
  if (projectMakesOffer === undefined) {
68
68
  throw new factory.errors.Argument('project', 'project makes no offers');
69
69
  }
70
- const seller = (yield repos.seller.search({
70
+ const seller = (yield repos.seller.projectFields({
71
71
  limit: 1,
72
72
  page: 1,
73
73
  project: { id: { $eq: params.project.id } },
@@ -7,7 +7,7 @@ import type { OfferItemConditionRepo } from '../../../repo/offerItemCondition';
7
7
  import type { OrderRepo } from '../../../repo/order';
8
8
  import type { ProjectRepo } from '../../../repo/project';
9
9
  import type { ReservationRepo } from '../../../repo/reservation';
10
- import type { SellerRepo } from '../../../repo/seller';
10
+ import type { ISellerWithId, SellerRepo } from '../../../repo/seller';
11
11
  interface IPreStartOperationRepos {
12
12
  acceptedOffer: AcceptedOfferRepo;
13
13
  event: EventRepo;
@@ -20,7 +20,7 @@ interface IPreStartOperationRepos {
20
20
  seller: SellerRepo;
21
21
  }
22
22
  type IPreStartOperation<T> = (repos: IPreStartOperationRepos) => Promise<T>;
23
- type IFixedSeller = Pick<factory.seller.ISeller, 'id' | 'name' | 'project' | 'hasMerchantReturnPolicy' | 'typeOf'>;
23
+ type IFixedSeller = Pick<ISellerWithId, 'id' | 'name' | 'project' | 'hasMerchantReturnPolicy' | 'typeOf'>;
24
24
  /**
25
25
  * 返品取引開始前処理
26
26
  */
@@ -36,7 +36,7 @@ function preStart(params) {
36
36
  const now = new Date();
37
37
  const { acceptedOffers, eventIds, offerIds, orders } = yield fixOrders(params)(repos);
38
38
  // sellerはorderから自動取得
39
- const sellers = yield repos.seller.search({
39
+ const sellers = yield repos.seller.projectFields({
40
40
  limit: 1,
41
41
  page: 1,
42
42
  id: { $eq: String(orders[0].seller.id) }
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.381.0-alpha.3",
13
- "@cinerino/sdk": "10.5.0-alpha.0",
12
+ "@chevre/factory": "4.381.0-alpha.12",
13
+ "@cinerino/sdk": "10.7.0-alpha.3",
14
14
  "@motionpicture/coa-service": "9.4.0",
15
15
  "@motionpicture/gmo-service": "5.3.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.2.0-alpha.2"
113
+ "version": "22.2.0-alpha.21"
114
114
  }
@@ -1,28 +0,0 @@
1
- // tslint:disable:no-implicit-dependencies no-console
2
- import { chevre } from '../../../lib/index';
3
-
4
- import * as mongoose from 'mongoose';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
12
- const products = await productRepo.searchProducts(
13
- {
14
- project: { id: { $eq: project.id } }
15
- },
16
- // ['_id', 'typeOf'],
17
- [],
18
- []
19
- );
20
- console.log('products:', products);
21
- console.log(products.length, 'products found');
22
- }
23
-
24
- main()
25
- .then(() => {
26
- console.log('success!');
27
- })
28
- .catch(console.error);