@chevre/domain 23.1.0-alpha.1 → 23.1.0-alpha.11

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 (40) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +9 -3
  2. package/example/src/chevre/authorizeEventServiceOffer.ts +8 -5
  3. package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
  4. package/example/src/chevre/member/migrateMemberIdentifier.ts +99 -0
  5. package/example/src/chevre/reIndex.ts +2 -2
  6. package/lib/chevre/repo/eventOffer.d.ts +52 -0
  7. package/lib/chevre/repo/eventOffer.js +191 -0
  8. package/lib/chevre/repo/member.d.ts +18 -1
  9. package/lib/chevre/repo/member.js +14 -8
  10. package/lib/chevre/repo/mongoose/schemas/eventOffer.d.ts +10 -0
  11. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +102 -0
  12. package/lib/chevre/repo/mongoose/schemas/member.js +10 -0
  13. package/lib/chevre/repository.d.ts +5 -0
  14. package/lib/chevre/repository.js +15 -2
  15. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +8 -0
  16. package/lib/chevre/service/assetTransaction/reserve/start.js +6 -1
  17. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +22 -0
  18. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +63 -0
  19. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +7 -2
  20. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +30 -30
  21. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +1 -1
  22. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +10 -26
  23. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.d.ts +23 -0
  24. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +62 -0
  25. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +38 -1
  26. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +39 -19
  27. package/lib/chevre/service/offer/event/authorize/factory.d.ts +0 -3
  28. package/lib/chevre/service/offer/event/authorize/factory.js +4 -3
  29. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +42 -25
  30. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +6 -0
  31. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -4
  32. package/lib/chevre/service/offer/event/authorize.d.ts +5 -0
  33. package/lib/chevre/service/offer/event/authorize.js +10 -5
  34. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
  35. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
  36. package/lib/chevre/service/offer/event.d.ts +2 -1
  37. package/lib/chevre/service/offer/event.js +3 -1
  38. package/lib/chevre/service/offer/onEventChanged.js +29 -13
  39. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +29 -23
  40. package/package.json +3 -3
@@ -0,0 +1,123 @@
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.issueEventOfferTicket = issueEventOfferTicket;
13
+ const moment = require("moment");
14
+ const factory = require("../../../factory");
15
+ const validateStartRequest_1 = require("../../assetTransaction/reserve/validateStartRequest");
16
+ function createOfferTicket(params) {
17
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
+ const { audience, expiresInSeconds, issuedBy, object, validFrom, author, project, instrument } = params;
20
+ const actionAttributes = {
21
+ project: { id: project.id, typeOf: factory.organizationType.Project },
22
+ typeOf: factory.actionType.AuthorizeAction,
23
+ agent: author,
24
+ recipient: author,
25
+ object: [object],
26
+ instrument: {
27
+ typeOf: factory.creativeWorkType.WebApplication,
28
+ id: instrument.id
29
+ }
30
+ };
31
+ const action = yield repos.action.start(actionAttributes);
32
+ let authorizations;
33
+ try {
34
+ authorizations = yield repos.authorization.publish([{
35
+ project: { id: project.id, typeOf: factory.organizationType.Project },
36
+ object,
37
+ validFrom,
38
+ expiresInSeconds,
39
+ author,
40
+ issuedBy,
41
+ audience
42
+ }]);
43
+ }
44
+ catch (error) {
45
+ try {
46
+ yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
47
+ }
48
+ catch (__) {
49
+ // 失敗したら仕方ない
50
+ }
51
+ throw error;
52
+ }
53
+ const result = authorizations.map(({ code, typeOf }) => ({ code, typeOf }));
54
+ yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
55
+ const ticketToken = (_a = authorizations.shift()) === null || _a === void 0 ? void 0 : _a.code;
56
+ if (typeof ticketToken !== 'string') {
57
+ // 基本的にありえないフロー
58
+ throw new factory.errors.Internal('code not published by an unexpected reason');
59
+ }
60
+ // チケット作成
61
+ yield repos.ticket.issueByTicketToken({
62
+ project: { id: project.id },
63
+ ticketToken,
64
+ issuedBy
65
+ });
66
+ return { ticketToken };
67
+ });
68
+ }
69
+ function issueEventOfferTicket(params) {
70
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
71
+ var _a, _b;
72
+ const { now, audience, eventId, eventOfferId, ticketedOffer, author, project, instrument } = params;
73
+ // 取引は存在するか
74
+ const transaction = yield repos.transaction.projectFieldsInProgressById({ typeOf: factory.transactionType.PlaceOrder, id: audience.id }, ['expires', 'typeOf', 'seller']);
75
+ // イベントは存在するか
76
+ const event = yield repos.event.projectEventFieldsById({ id: eventId }, ['project', 'offers', 'identifier']);
77
+ // 取引番号発行
78
+ // const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: now });
79
+ const { seller } = transaction;
80
+ // 承認作成
81
+ const issuedBy = Object.assign({ id: seller.id, typeOf: seller.typeOf }, (typeof seller.name.ja === 'string') ? { name: seller.name.ja } : undefined);
82
+ const validForMemberTierToken = (_a = ticketedOffer === null || ticketedOffer === void 0 ? void 0 : ticketedOffer.validForMemberTier) === null || _a === void 0 ? void 0 : _a.token;
83
+ const validForMemberProgramIdentifier = (_b = ticketedOffer === null || ticketedOffer === void 0 ? void 0 : ticketedOffer.validForMemberTier) === null || _b === void 0 ? void 0 : _b.isTierOf.identifier;
84
+ const authorizationObject = Object.assign(Object.assign(Object.assign({ typeOf: factory.offerType.Offer, itemOffered: {
85
+ typeOf: factory.product.ProductType.EventService,
86
+ serviceOutput: {
87
+ typeOf: factory.reservationType.ReservationPackage,
88
+ reservationFor: { id: eventId }
89
+ }
90
+ } }, (typeof eventOfferId === 'string' && eventOfferId !== '') ? { id: eventOfferId } : undefined), (typeof (ticketedOffer === null || ticketedOffer === void 0 ? void 0 : ticketedOffer.token) === 'string' && ticketedOffer.token !== '')
91
+ ? { token: ticketedOffer.token }
92
+ : undefined), (typeof validForMemberTierToken === 'string' && validForMemberTierToken !== ''
93
+ && typeof validForMemberProgramIdentifier === 'string' && validForMemberProgramIdentifier !== '')
94
+ ? {
95
+ validForMemberTier: {
96
+ token: validForMemberTierToken,
97
+ isTierOf: { identifier: validForMemberProgramIdentifier }
98
+ }
99
+ }
100
+ : undefined);
101
+ // validations(eventId,eventOfferIdentifier,offerToken...)
102
+ yield (0, validateStartRequest_1.validEventOfferByApplicationExists)({
103
+ event,
104
+ now,
105
+ availableAt: { id: instrument.id },
106
+ acceptedEventOffer: authorizationObject,
107
+ numAcceptedOffers: 0 // オファーチケット発行時は予約数を検証しないので0でok
108
+ })(repos);
109
+ const expiresInSeconds = moment(transaction.expires)
110
+ .diff(now, 'seconds');
111
+ const { ticketToken } = yield createOfferTicket({
112
+ object: authorizationObject,
113
+ validFrom: now,
114
+ expiresInSeconds,
115
+ issuedBy,
116
+ audience: { id: transaction.id, typeOf: transaction.typeOf },
117
+ author,
118
+ project,
119
+ instrument
120
+ })(repos);
121
+ return { ticketToken };
122
+ });
123
+ }
@@ -1,8 +1,9 @@
1
1
  import { authorize } from './event/authorize';
2
2
  import { importCategoryCodesFromCOA, importFromCOA } from './event/importFromCOA';
3
+ import { issueEventOfferTicket } from './event/issueEventOfferTicket';
3
4
  import { searchEventTicketOffers } from './event/searchEventTicketOffers';
4
5
  import { searchOfferAppliesToMovieTicket } from './event/searchOfferAppliesToMovieTicket';
5
6
  import { searchOfferCatalogItemAvailability } from './event/searchOfferCatalogItemAvailability';
6
7
  import { searchOfferCatalogItems } from './event/searchOfferCatalogItems';
7
8
  import { voidTransaction } from './event/voidTransaction';
8
- export { authorize, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers, searchOfferAppliesToMovieTicket, searchOfferCatalogItemAvailability, searchOfferCatalogItems };
9
+ export { authorize, importCategoryCodesFromCOA, importFromCOA, issueEventOfferTicket, voidTransaction, searchEventTicketOffers, searchOfferAppliesToMovieTicket, searchOfferCatalogItemAvailability, searchOfferCatalogItems };
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchOfferCatalogItems = exports.searchOfferCatalogItemAvailability = exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.authorize = void 0;
3
+ exports.searchOfferCatalogItems = exports.searchOfferCatalogItemAvailability = exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = exports.voidTransaction = exports.issueEventOfferTicket = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.authorize = void 0;
4
4
  const authorize_1 = require("./event/authorize");
5
5
  Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
6
6
  const importFromCOA_1 = require("./event/importFromCOA");
7
7
  Object.defineProperty(exports, "importCategoryCodesFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importCategoryCodesFromCOA; } });
8
8
  Object.defineProperty(exports, "importFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importFromCOA; } });
9
+ const issueEventOfferTicket_1 = require("./event/issueEventOfferTicket");
10
+ Object.defineProperty(exports, "issueEventOfferTicket", { enumerable: true, get: function () { return issueEventOfferTicket_1.issueEventOfferTicket; } });
9
11
  const searchEventTicketOffers_1 = require("./event/searchEventTicketOffers");
10
12
  Object.defineProperty(exports, "searchEventTicketOffers", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchEventTicketOffers; } });
11
13
  const searchOfferAppliesToMovieTicket_1 = require("./event/searchOfferAppliesToMovieTicket");
@@ -116,29 +116,45 @@ function createInformTasks(params, setting) {
116
116
  );
117
117
  // 最適化(2024-03-22~)
118
118
  events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty, identifier }) => {
119
- var _a;
120
- const eventOfferAsNotification = (((_a = offers.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.COA)
121
- ? {
119
+ var _a, _b;
120
+ const sellerMakesOffersAsNotification = (Array.isArray((_a = offers.seller) === null || _a === void 0 ? void 0 : _a.makesOffer))
121
+ ? offers.seller.makesOffer.map((eventSellerMakesOffer) => {
122
+ return Object.assign({ availabilityEnds: eventSellerMakesOffer.availabilityEnds, availabilityStarts: eventSellerMakesOffer.availabilityStarts, validFrom: eventSellerMakesOffer.validFrom, validThrough: eventSellerMakesOffer.validThrough, availableAtOrFrom: [eventSellerMakesOffer.availableAtOrFrom] }, (typeof eventSellerMakesOffer.identifier === 'string')
123
+ ? { identifier: eventSellerMakesOffer.identifier }
124
+ : undefined // support notify identifier(2025-11-01~)
125
+ );
126
+ })
127
+ : [];
128
+ let eventOfferAsNotification;
129
+ if (((_b = offers.offeredThrough) === null || _b === void 0 ? void 0 : _b.identifier) === factory.service.webAPI.Identifier.COA) {
130
+ eventOfferAsNotification = {
122
131
  typeOf: offers.typeOf,
123
132
  itemOffered: offers.itemOffered
124
- }
125
- : {
133
+ };
134
+ }
135
+ else if (offers.typeOf === factory.offerType.AggregateOffer) {
136
+ eventOfferAsNotification = {
137
+ typeOf: offers.typeOf,
138
+ itemOffered: offers.itemOffered,
139
+ seller: {
140
+ id: offers.seller.id,
141
+ typeOf: offers.seller.typeOf,
142
+ makesOffer: sellerMakesOffersAsNotification
143
+ }
144
+ };
145
+ }
146
+ else {
147
+ eventOfferAsNotification = {
126
148
  typeOf: offers.typeOf,
127
149
  itemOffered: offers.itemOffered,
128
150
  seller: {
129
151
  id: offers.seller.id,
130
152
  typeOf: offers.seller.typeOf,
131
153
  // makesOfferを追加(2024-03-26~)
132
- makesOffer: (Array.isArray(offers.seller.makesOffer))
133
- ? offers.seller.makesOffer.map((eventSellerMakesOffer) => {
134
- return Object.assign({ availabilityEnds: eventSellerMakesOffer.availabilityEnds, availabilityStarts: eventSellerMakesOffer.availabilityStarts, validFrom: eventSellerMakesOffer.validFrom, validThrough: eventSellerMakesOffer.validThrough, availableAtOrFrom: [eventSellerMakesOffer.availableAtOrFrom] }, (typeof eventSellerMakesOffer.identifier === 'string')
135
- ? { identifier: eventSellerMakesOffer.identifier }
136
- : undefined // support notify identifier(2025-11-01~)
137
- );
138
- })
139
- : []
154
+ makesOffer: sellerMakesOffersAsNotification
140
155
  }
141
156
  };
157
+ }
142
158
  return Object.assign({ project, organizer, typeOf, name, doorTime, endDate,
143
159
  eventStatus, location, startDate, superEvent, id, additionalProperty, offers: eventOfferAsNotification }, (typeof identifier === 'string') ? { identifier } : undefined // support notify identifier(2025-11-01~)
144
160
  );
@@ -11,9 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.verifyTicketTokenAsNeeded = verifyTicketTokenAsNeeded;
13
13
  const factory = require("../../../factory");
14
+ // tslint:disable-next-line:max-func-body-length
14
15
  function verifyTicketTokenAsNeeded(params) {
16
+ // tslint:disable-next-line:cyclomatic-complexity
15
17
  return (repos) => __awaiter(this, void 0, void 0, function* () {
16
- var _a, _b;
18
+ var _a;
17
19
  const { paymentServiceType, object, project } = params;
18
20
  const { issuedThrough, ticketToken } = object;
19
21
  let permitOrInvoice;
@@ -46,34 +48,38 @@ function verifyTicketTokenAsNeeded(params) {
46
48
  if (authorizedObject.typeOf === 'OwnershipInfo') {
47
49
  const { typeOfGood } = authorizedObject;
48
50
  if (typeOfGood.typeOf === factory.permit.PermitType.Permit || typeOfGood.typeOf === 'Invoice') {
49
- if (((_b = typeOfGood.issuedThrough) === null || _b === void 0 ? void 0 : _b.typeOf) !== paymentServiceType) {
50
- throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
51
- }
52
- // FaceToFace以外の場合、発行サービスIDを検証
53
- if (typeOfGood.issuedThrough.typeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
54
- if (typeOfGood.issuedThrough.id !== issuedThrough.id) {
55
- throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
56
- }
57
- }
58
- if (typeOfGood.typeOf === factory.permit.PermitType.Permit) {
59
- permitOrInvoice = { identifier: typeOfGood.identifier, typeOf: factory.permit.PermitType.Permit };
60
- }
61
- else if (typeOfGood.typeOf === 'Invoice') {
62
- // support paymentServiceType.MovieTicket(2024-11-23~)
63
- permitOrInvoice = { paymentMethodId: typeOfGood.paymentMethodId, typeOf: 'Invoice' };
64
- }
65
- else {
66
- throw new factory.errors.Argument('ticketToken', 'must be Permit or Invoice');
67
- }
51
+ // discontinue(2025-11-14~)
52
+ throw new factory.errors.Argument('ticketToken', `typeOfGood.typeOf ${typeOfGood.typeOf} discontinued`);
53
+ // if (typeOfGood.issuedThrough?.typeOf !== paymentServiceType) {
54
+ // throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
55
+ // }
56
+ // // FaceToFace以外の場合、発行サービスIDを検証
57
+ // if (typeOfGood.issuedThrough.typeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
58
+ // if (typeOfGood.issuedThrough.id !== issuedThrough.id) {
59
+ // throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
60
+ // }
61
+ // }
62
+ // if (typeOfGood.typeOf === factory.permit.PermitType.Permit) {
63
+ // permitOrInvoice = { identifier: typeOfGood.identifier, typeOf: factory.permit.PermitType.Permit };
64
+ // } else if (typeOfGood.typeOf === 'Invoice') {
65
+ // // support paymentServiceType.MovieTicket(2024-11-23~)
66
+ // permitOrInvoice = { paymentMethodId: typeOfGood.paymentMethodId, typeOf: 'Invoice' };
67
+ // } else {
68
+ // throw new factory.errors.Argument('ticketToken', 'must be Permit or Invoice');
69
+ // }
68
70
  }
69
71
  else if (typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
70
- || typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket) {
72
+ || typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket
73
+ || typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
71
74
  // 決済方法所有権を受け入れる(2025-11-11~)
72
75
  if (typeOfGood.typeOf !== paymentServiceType) {
73
76
  throw new factory.errors.Argument('ticketToken', 'paymentServiceType not matched');
74
77
  }
75
- if (typeOfGood.id !== issuedThrough.id) {
76
- throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
78
+ // FaceToFace以外の場合、発行サービスIDを検証
79
+ if (typeOfGood.typeOf !== factory.service.paymentService.PaymentServiceType.FaceToFace) {
80
+ if (typeOfGood.id !== issuedThrough.id) {
81
+ throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
82
+ }
77
83
  }
78
84
  permitOrInvoice = { paymentMethodId: typeOfGood.serviceOutput.paymentMethodId, typeOf: 'Invoice' };
79
85
  }
package/package.json CHANGED
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "5.2.0-alpha.6",
15
- "@cinerino/sdk": "12.7.0-alpha.3",
14
+ "@chevre/factory": "5.2.0-alpha.15",
15
+ "@cinerino/sdk": "12.8.0-alpha.2",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
18
18
  "@sendgrid/client": "8.1.4",
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "23.1.0-alpha.1"
118
+ "version": "23.1.0-alpha.11"
119
119
  }