@chevre/domain 21.37.0-alpha.10 → 21.37.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.
@@ -45,7 +45,7 @@ interface IAuthorizeRepos {
45
45
  }
46
46
  type IAuthorizeOperation<T> = (repos: IAuthorizeRepos) => Promise<T>;
47
47
  type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
48
- type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail4chevre;
48
+ type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail<factory.service.webAPI.Identifier.Chevre>;
49
49
  /**
50
50
  * 興行オファー承認
51
51
  */
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.authorize = void 0;
24
13
  const factory = require("../../../factory");
@@ -102,7 +91,7 @@ function authorize(params) {
102
91
  }
103
92
  throw error;
104
93
  }
105
- const result = (0, factory_1.acceptedOffers2authorizeResult)({ acceptedOffers, acceptedOffers4result, noOfferSpecified });
94
+ const result = (0, factory_1.acceptedOffers2authorizeResult)({ acceptedOffers, acceptedOffers4result, noOfferSpecified, ticketOffers });
106
95
  return yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
107
96
  });
108
97
  }
@@ -264,13 +253,21 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
264
253
  });
265
254
  const acceptedAppliesToMovieTicket = (_a = offerWithoutDetail.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
266
255
  // 承認アクションオブジェクトのacceptedOfferにappliesToMovieTicketを連携する(2022-08-02~)
267
- const priceSpecification = Object.assign({
268
- // 必要な属性のみに最適化(2024-04-09~)
269
- // ...offer.priceSpecification,
270
- typeOf: offer.priceSpecification.typeOf, priceCurrency: offer.priceSpecification.priceCurrency, valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded, priceComponent: offer.priceSpecification.priceComponent.map((_a) => {
271
- var { name, accounting, id, priceCurrency, valueAddedTaxIncluded } = _a, necessaryComponentFields = __rest(_a, ["name", "accounting", "id", "priceCurrency", "valueAddedTaxIncluded"]);
272
- return necessaryComponentFields;
273
- }) }, (Array.isArray(acceptedAppliesToMovieTicket) || typeof (acceptedAppliesToMovieTicket === null || acceptedAppliesToMovieTicket === void 0 ? void 0 : acceptedAppliesToMovieTicket.identifier) === 'string')
256
+ // const priceSpecification: IAcceptedOfferPriceSpecification = {
257
+ // // 必要な属性のみに最適化(2024-04-09~)
258
+ // // ...offer.priceSpecification,
259
+ // typeOf: offer.priceSpecification.typeOf,
260
+ // priceCurrency: offer.priceSpecification.priceCurrency,
261
+ // // valueAddedTaxIncluded: offer.priceSpecification.valueAddedTaxIncluded,
262
+ // priceComponent: offer.priceSpecification.priceComponent.map(({
263
+ // name, accounting, id, priceCurrency, valueAddedTaxIncluded, ...necessaryComponentFields
264
+ // }) => necessaryComponentFields),
265
+ // // appliesToMovieTicket.identifierを連携する
266
+ // ...(Array.isArray(acceptedAppliesToMovieTicket) || typeof acceptedAppliesToMovieTicket?.identifier === 'string')
267
+ // ? { appliesToMovieTicket: acceptedAppliesToMovieTicket }
268
+ // : undefined
269
+ // };
270
+ const priceSpecification = Object.assign({}, (Array.isArray(acceptedAppliesToMovieTicket) || typeof (acceptedAppliesToMovieTicket === null || acceptedAppliesToMovieTicket === void 0 ? void 0 : acceptedAppliesToMovieTicket.identifier) === 'string')
274
271
  ? { appliesToMovieTicket: acceptedAppliesToMovieTicket }
275
272
  : undefined);
276
273
  const acceptedAddOns = (Array.isArray(offerWithoutDetail.addOn))
@@ -315,7 +312,12 @@ function acceptedOfferWithoutDetail2acceptedOffer(params) {
315
312
  }
316
313
  const acceptedOffer = Object.assign({
317
314
  // オファーの中身を最適化する(必要最低限の情報のみに)
318
- id: String(offer.id), identifier: offer.identifier, priceSpecification, typeOf: offer.typeOf, priceCurrency: offer.priceCurrency, itemOffered: Object.assign(Object.assign({ typeOf: factory.product.ProductType.EventService }, (itemOfferedServiceOutput !== undefined) ? { serviceOutput: itemOfferedServiceOutput } : undefined), (pointAward !== undefined) ? { pointAward } : undefined), addOn: acceptedAddOns,
315
+ id: String(offer.id),
316
+ // identifier: offer.identifier,
317
+ priceSpecification,
318
+ // typeOf: offer.typeOf,
319
+ // priceCurrency: offer.priceCurrency,
320
+ itemOffered: Object.assign(Object.assign({}, (itemOfferedServiceOutput !== undefined) ? { serviceOutput: itemOfferedServiceOutput } : undefined), (pointAward !== undefined) ? { pointAward } : undefined), addOn: acceptedAddOns,
319
321
  // 追加属性をマージ
320
322
  additionalProperty: [
321
323
  ...(Array.isArray(offerWithoutDetail.additionalProperty)) ? offerWithoutDetail.additionalProperty : [],
@@ -31,6 +31,7 @@ export declare function acceptedOffers2authorizeResult(params: {
31
31
  acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4chevre[];
32
32
  acceptedOffers4result: IResultAcceptedOffer[];
33
33
  noOfferSpecified: boolean;
34
+ ticketOffers: factory.product.ITicketOffer[];
34
35
  }): factory.action.authorize.offer.eventService.IResult;
35
36
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
36
37
  type IResultAcceptedOffer = factory.action.authorize.offer.eventService.IResultAcceptedOffer;
@@ -18,11 +18,12 @@ function createReserveTransactionStartParams(params) {
18
18
  };
19
19
  // 適用決済カード情報を連携(複数対応)(2022-08-02~)
20
20
  let appliesToMovieTicket;
21
- if (Array.isArray(o.priceSpecification.appliesToMovieTicket)) {
22
- appliesToMovieTicket = o.priceSpecification.appliesToMovieTicket;
21
+ const appliesToMovieTicketFromAcceptedOffer = (_b = o.priceSpecification) === null || _b === void 0 ? void 0 : _b.appliesToMovieTicket;
22
+ if (Array.isArray(appliesToMovieTicketFromAcceptedOffer)) {
23
+ appliesToMovieTicket = appliesToMovieTicketFromAcceptedOffer;
23
24
  }
24
- else if (typeof ((_b = o.priceSpecification.appliesToMovieTicket) === null || _b === void 0 ? void 0 : _b.identifier) === 'string') {
25
- appliesToMovieTicket = { identifier: o.priceSpecification.appliesToMovieTicket.identifier };
25
+ else if (typeof (appliesToMovieTicketFromAcceptedOffer === null || appliesToMovieTicketFromAcceptedOffer === void 0 ? void 0 : appliesToMovieTicketFromAcceptedOffer.identifier) === 'string') {
26
+ appliesToMovieTicket = { identifier: appliesToMovieTicketFromAcceptedOffer.identifier };
26
27
  }
27
28
  return Object.assign(Object.assign({
28
29
  // 必要な属性のみ指定する
@@ -156,9 +157,9 @@ function acceptedOffers2amount(params) {
156
157
  }
157
158
  exports.acceptedOffers2amount = acceptedOffers2amount;
158
159
  function acceptedOffers2authorizeResult(params) {
159
- var _a, _b;
160
- const { acceptedOffers, acceptedOffers4result, noOfferSpecified } = params;
161
- const priceCurrency = (_b = (_a = acceptedOffers[0]) === null || _a === void 0 ? void 0 : _a.priceSpecification) === null || _b === void 0 ? void 0 : _b.priceCurrency;
160
+ const { acceptedOffers, acceptedOffers4result, noOfferSpecified, ticketOffers } = params;
161
+ // const priceCurrency = acceptedOffers[0]?.priceSpecification?.priceCurrency;
162
+ const priceCurrency = factory.priceCurrency.JPY; // fix(2024-07-03~)
162
163
  // redefine as typeOf: AggregateOffer(2024-06-18~)
163
164
  let offers;
164
165
  let price;
@@ -167,10 +168,14 @@ function acceptedOffers2authorizeResult(params) {
167
168
  // オファーIDごとに集計
168
169
  const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
169
170
  offers = offerIds.map((offerId) => {
170
- const acceptedOffer = acceptedOffers.find(({ id }) => id === offerId);
171
+ const acceptedOffer = ticketOffers.find(({ id }) => id === offerId);
171
172
  if (acceptedOffer === undefined) {
172
173
  throw new factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
173
174
  }
175
+ // const acceptedOffer = acceptedOffers.find(({ id }) => id === offerId);
176
+ // if (acceptedOffer === undefined) {
177
+ // throw new factory.errors.Internal(`acceptedOffer not found [id:${offerId}]`);
178
+ // }
174
179
  const amountOfThisGood = acceptedOffers.filter(({ id }) => id === offerId).length;
175
180
  const { acceptedPaymentMethod, priceSpecification } = acceptedOffer;
176
181
  const unitPriceSpec = priceSpecification.priceComponent.find((spec) => spec.typeOf === factory.priceSpecificationType.UnitPriceSpecification
@@ -1,12 +1,12 @@
1
1
  import * as factory from '../../../factory';
2
2
  import { IMinimizedIndividualEvent } from '../../../factory/event';
3
3
  export import WebAPIIdentifier = factory.service.webAPI.Identifier;
4
- export type IAcceptedOffer4COA = factory.action.authorize.offer.eventService.IAcceptedOffer<factory.service.webAPI.Identifier.COA>;
4
+ export type IAcceptedOffer4COA = factory.action.authorize.offer.eventService.IAcceptedOffer4COA;
5
5
  export declare function createAuthorizeSeatReservationActionAttributes(params: {
6
6
  acceptAction: {
7
7
  id: string;
8
8
  };
9
- acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
9
+ acceptedOffers: factory.action.authorize.offer.eventService.IAcceptedOffer4COA[];
10
10
  event: Pick<IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>, 'id' | 'typeOf'>;
11
11
  transaction: Pick<factory.transaction.ITransaction<factory.transactionType.PlaceOrder>, 'agent' | 'id' | 'project' | 'seller' | 'typeOf'>;
12
12
  pendingTransaction: factory.action.authorize.offer.eventService.ICOAPendingTransaction;
@@ -24,7 +24,7 @@ type IResultAcceptedOffer = factory.action.authorize.offer.eventService.IResultA
24
24
  */
25
25
  export declare function responseBody2acceptedOffers4result(params: {
26
26
  responseBody: factory.action.authorize.offer.eventService.IResponseBody<factory.service.webAPI.Identifier.COA>;
27
- acceptedOffer: factory.action.authorize.offer.eventService.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
27
+ acceptedOffer: factory.action.authorize.offer.eventService.IAcceptedOffer4COA[];
28
28
  event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
29
29
  seller: Pick<factory.transaction.placeOrder.ISeller, 'typeOf' | 'name'>;
30
30
  bookingTime: Date;
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.377.0-alpha.4",
14
- "@cinerino/sdk": "8.1.0",
13
+ "@chevre/factory": "4.377.0-alpha.5",
14
+ "@cinerino/sdk": "8.2.0-alpha.1",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
17
17
  "@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": "21.37.0-alpha.10"
113
+ "version": "21.37.0-alpha.11"
114
114
  }
@@ -1,163 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- type IUnitPriceSpecification =
8
- chevre.factory.priceSpecification.IPriceSpecification<chevre.factory.priceSpecificationType.UnitPriceSpecification>;
9
- type IAuthorizeAction4chevre = chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier.Chevre>;
10
- type IAcceptedOffer4chevre = chevre.factory.action.authorize.offer.eventService.IAcceptedOffer4chevre;
11
-
12
- // tslint:disable-next-line:max-func-body-length
13
- async function main() {
14
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
15
-
16
- const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
17
- const cursor = actionRepo.getCursor(
18
- {
19
- // _id: { $eq: '66697991037c9d7243208261' },
20
- typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
21
- actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
22
- startDate: {
23
- $lte: moment()
24
- // tslint:disable-next-line:no-magic-numbers
25
- .add(-180, 'days')
26
- // $gte: moment()
27
- // // tslint:disable-next-line:no-magic-numbers
28
- // .add(-180, 'days')
29
- },
30
- 'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation }
31
- },
32
- {
33
- __id: 1, startDate: 1, endDate: 1, result: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
34
- }
35
- );
36
- console.log('actions found');
37
-
38
- let i = 0;
39
- let updateCount = 0;
40
- let saveResultCount = 0;
41
- // tslint:disable-next-line:max-func-body-length
42
- await cursor.eachAsync(async (doc) => {
43
- i += 1;
44
- const authorizeAction = <Pick<
45
- chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
46
- 'id' | 'startDate' | 'endDate' | 'result' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
47
- >>doc.toObject();
48
- const result = authorizeAction.result;
49
- if (result === undefined) {
50
- throw new Error(`result undefined [${authorizeAction.id}]`);
51
- }
52
-
53
- let migrated = false;
54
- if (authorizeAction.instrument.typeOf === chevre.factory.assetTransactionType.COAReserveTransaction
55
- || (<any>authorizeAction.instrument).identifier === chevre.factory.service.webAPI.Identifier.COA) {
56
- migrated = true;
57
- } else {
58
- if (result.typeOf === chevre.factory.offerType.AggregateOffer && Array.isArray(result.offers)) {
59
- migrated = true;
60
- }
61
- if (typeof result.price !== 'number') {
62
- migrated = true;
63
- }
64
- }
65
-
66
- if (migrated) {
67
- console.log(
68
- 'already migrated.',
69
- authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
70
-
71
- // optimize action
72
- if (Array.isArray((<any>authorizeAction.object).acceptedOffer)) {
73
- let unsetResult: any;
74
- unsetResult = await actionRepo.unsetUnnecessaryFields({
75
- filter: { _id: { $eq: authorizeAction.id } },
76
- $unset: {
77
- 'object.acceptedOffer': 1
78
- }
79
- });
80
- updateCount += 1;
81
- console.log(
82
- 'result unset. unsetResult:', unsetResult,
83
- authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
84
- }
85
- } else {
86
- console.log(
87
- 'redefining result as AggreagteOffer...',
88
- authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
89
- const acceptedOffers = <IAcceptedOffer4chevre[]>(<any>(<IAuthorizeAction4chevre>authorizeAction).object).acceptedOffer;
90
- if (!Array.isArray(acceptedOffers)) {
91
- throw new Error(`acceptedOffer undefined [${authorizeAction.id}]`);
92
- }
93
-
94
- let offers: chevre.factory.action.authorize.offer.eventService.IAcceptedOfferInResult[] | undefined;
95
- if (typeof result.price === 'number') {
96
- // オファーIDごとに集計
97
- const offerIds = [...new Set(acceptedOffers.map((o) => o.id))];
98
- offers = offerIds.map<chevre.factory.action.authorize.offer.eventService.IAcceptedOfferInResult>((offerId) => {
99
- const acceptedOfferInObject = acceptedOffers.find(({ id }) => id === offerId);
100
- if (acceptedOfferInObject === undefined) {
101
- throw new Error(`acceptedOffer not found [id:${offerId}]`);
102
- }
103
- const amountOfThisGood: number = acceptedOffers.filter(({ id }) => id === offerId).length;
104
- const { acceptedPaymentMethod, priceSpecification } = acceptedOfferInObject;
105
-
106
- const unitPriceSpec = <IUnitPriceSpecification | undefined>priceSpecification.priceComponent.find(
107
- (spec) => spec.typeOf === chevre.factory.priceSpecificationType.UnitPriceSpecification
108
- && (!Array.isArray(spec.appliesToAddOn)) // アドオン単価ではない
109
- );
110
- if (unitPriceSpec === undefined) {
111
- throw new Error(`unitPriceSpec not found [id:${offerId}]`);
112
- }
113
- const { eligibleQuantity, eligibleTransactionVolume } = unitPriceSpec;
114
-
115
- return {
116
- id: offerId,
117
- includesObject: { amountOfThisGood },
118
- typeOf: chevre.factory.offerType.Offer,
119
- priceSpecification: {
120
- ...(eligibleQuantity !== undefined) ? { eligibleQuantity } : undefined,
121
- ...(eligibleTransactionVolume !== undefined) ? { eligibleTransactionVolume } : undefined
122
- },
123
- ...(acceptedPaymentMethod !== undefined) ? { acceptedPaymentMethod } : undefined
124
- };
125
- });
126
- }
127
- const resultAsAggregateOffer: chevre.factory.action.authorize.offer.eventService.IResultAsAggregateOffer = {
128
- typeOf: chevre.factory.offerType.AggregateOffer,
129
- offers
130
- };
131
- // const newResult: chevre.factory.action.authorize.offer.eventService.IResult = {
132
- // ...result,
133
- // ...resultAsAggregateOffer
134
- // };
135
- console.log(
136
- 'saving action...',
137
- authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
138
- // tslint:disable-next-line:no-null-keyword
139
- console.dir(resultAsAggregateOffer, { depth: null });
140
- await actionRepo.findByIdAndUpdate({
141
- id: authorizeAction.id,
142
- update: {
143
- $set: {
144
- 'result.typeOf': resultAsAggregateOffer.typeOf,
145
- 'result.offers': resultAsAggregateOffer.offers
146
- }
147
- }
148
- });
149
- saveResultCount += 1;
150
- console.log(
151
- 'action saved.',
152
- authorizeAction.project.id, authorizeAction.id, authorizeAction.startDate, i, updateCount, saveResultCount);
153
- }
154
- });
155
-
156
- console.log(i, 'actions checked');
157
- console.log(updateCount, 'actions updated');
158
- console.log(saveResultCount, 'result saved');
159
- }
160
-
161
- main()
162
- .then()
163
- .catch(console.error);