@chevre/domain 21.29.0-alpha.9 → 21.29.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.
- package/example/src/chevre/migrateCancelReservationObject.ts +71 -0
- package/example/src/chevre/{migrateOrderAcceptedOfferSerialNumber.ts → migrateOrderAcceptedOfferReservedTicketIdentifier.ts} +27 -16
- package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +95 -0
- package/example/src/chevre/searchAssetTransactions.ts +38 -0
- package/example/src/chevre/searchOrders.ts +6 -1
- package/lib/chevre/repo/acceptedOffer.d.ts +7 -2
- package/lib/chevre/repo/acceptedOffer.js +8 -4
- package/lib/chevre/repo/account.js +1 -1
- package/lib/chevre/repo/aggregateOffer.js +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +24 -3
- package/lib/chevre/repo/assetTransaction.js +96 -72
- package/lib/chevre/repo/creativeWork.js +1 -1
- package/lib/chevre/repo/event.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +31 -23
- package/lib/chevre/repo/mongoose/schemas/order.js +12 -3
- package/lib/chevre/repo/order.js +14 -5
- package/lib/chevre/repo/paymentServiceProvider.js +1 -1
- package/lib/chevre/repo/product.js +1 -1
- package/lib/chevre/repo/productModel.d.ts +22 -3
- package/lib/chevre/repo/productModel.js +40 -3
- package/lib/chevre/repo/seller.js +1 -1
- package/lib/chevre/repo/serviceOutput.js +1 -1
- package/lib/chevre/repo/transaction.js +1 -1
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +8 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.d.ts +4 -0
- package/lib/chevre/service/assetTransaction/pay/potentialActions/createPayObjectServiceOutput.js +36 -28
- package/lib/chevre/service/payment/any/factory.d.ts +1 -0
- package/lib/chevre/service/payment/any/factory.js +2 -1
- package/lib/chevre/service/payment/any.js +2 -1
- package/lib/chevre/service/report/telemetry.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.d.ts +15 -0
- package/lib/chevre/service/task/onResourceUpdated/onCategoryCodeUpdated.js +26 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +9 -0
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.d.ts +15 -0
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +54 -0
- package/lib/chevre/service/task/onResourceUpdated.js +11 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +25 -3
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +60 -57
- package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +1 -1
- package/lib/chevre/service/validation/validateOrder.js +13 -1
- package/lib/chevre/settings.d.ts +0 -4
- package/lib/chevre/settings.js +1 -8
- package/package.json +2 -2
- package/example/src/chevre/migrateOrderSeller.ts +0 -65
- package/example/src/chevre/migrateScreeningEventSeriesOffers.ts +0 -87
- package/example/src/chevre/playAroundProductModel.ts +0 -64
package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js
CHANGED
|
@@ -63,6 +63,7 @@ eventReservationAcceptedOffers) {
|
|
|
63
63
|
eventIds.forEach((eventId) => {
|
|
64
64
|
const requiredMovieTicketsByEvent = requiredMovieTickets.filter((t) => t.serviceOutput.reservationFor.id === eventId);
|
|
65
65
|
const authorizedMovieTicketsByEvent = authorizedMovieTickets.filter((t) => t.serviceOutput.reservationFor.id === eventId);
|
|
66
|
+
debug('validating authorizedMovieTicketsByEvent,requiredMovieTicketsByEvent by eventId...', eventId, JSON.stringify(authorizedMovieTicketsByEvent), JSON.stringify(requiredMovieTicketsByEvent));
|
|
66
67
|
// 合計枚数OK?
|
|
67
68
|
if (requiredMovieTicketsByEvent.length !== authorizedMovieTicketsByEvent.length) {
|
|
68
69
|
throw new factory.errors.Argument('transactionId', `required movie tickets for the event '${eventId}' not satisfied`);
|
|
@@ -83,6 +84,10 @@ eventReservationAcceptedOffers) {
|
|
|
83
84
|
if (settings_1.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER) {
|
|
84
85
|
const authorizedMovieTicketByTicketIdentifierExists = authorizedMovieTicketsByEvent.some((authorizedMovieTicket) => {
|
|
85
86
|
return authorizedMovieTicket.serviceType === requiredMovieTicket.serviceType
|
|
87
|
+
&& authorizedMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber
|
|
88
|
+
=== requiredMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatNumber
|
|
89
|
+
&& authorizedMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatSection
|
|
90
|
+
=== requiredMovieTicket.serviceOutput.reservedTicket.ticketedSeat.seatSection
|
|
86
91
|
&& typeof authorizedMovieTicket.serviceOutput.reservedTicket.identifier === 'string'
|
|
87
92
|
&& authorizedMovieTicket.serviceOutput.reservedTicket.identifier
|
|
88
93
|
=== requiredMovieTicket.serviceOutput.reservedTicket.identifier;
|
|
@@ -170,73 +175,71 @@ function validateAppliesToMovieTicketIdentifiers(params) {
|
|
|
170
175
|
*/
|
|
171
176
|
function authorizeSeatReservationActions2requiredMovieTickets(params) {
|
|
172
177
|
const paymentMethodType = params.paymentMethodType;
|
|
173
|
-
//
|
|
174
|
-
// ムビチケオファーを受け付けた座席予約を検索する
|
|
178
|
+
// 決済カードオファーを受け付けた座席予約を検索する
|
|
175
179
|
const requiredMovieTickets = [];
|
|
176
|
-
// tslint:disable-next-line:max-func-body-length
|
|
177
|
-
// seatReservationAuthorizeActions.forEach((action) => {
|
|
178
|
-
// const acceptedOffers = action.result?.acceptedOffers;
|
|
179
|
-
// });
|
|
180
180
|
if (Array.isArray(params.acceptedOffers)) {
|
|
181
181
|
params.acceptedOffers.forEach((offer) => {
|
|
182
|
-
var _a, _b, _c
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
// 単価仕様のappliesToMovieTicketを参照してrequiredMovieTicketsを作成する(2022-07-28~)
|
|
184
|
+
const unitPriceSpec = (_a = offer.priceSpecification) === null || _a === void 0 ? void 0 : _a.priceComponent.find((component) => {
|
|
185
|
+
return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
186
|
+
&& (!Array.isArray(component.appliesToAddOn));
|
|
187
|
+
});
|
|
188
|
+
if (unitPriceSpec === undefined) {
|
|
189
|
+
throw new factory.errors.NotFound('UnitPriceSpecification of acceptedOffer');
|
|
187
190
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const eventOfferedThroughIdentifier = (_c = offer.offeredThrough) === null || _c === void 0 ? void 0 : _c.identifier;
|
|
191
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
192
|
-
/* istanbul ignore if */
|
|
193
|
-
if (typeof eventOfferedThroughIdentifier !== 'string') {
|
|
194
|
-
throw new factory.errors.NotFound('offer.offeredThrough.identifier', `offer.offeredThrough.identifier undefined [serialNumber:${offer.serialNumber}]`);
|
|
195
|
-
}
|
|
196
|
-
// シンプルに単価仕様のappliesToMovieTicketを参照してrequiredMovieTicketsを作成する(2022-07-28~)
|
|
197
|
-
const unitPriceSpec = (_d = offer.priceSpecification) === null || _d === void 0 ? void 0 : _d.priceComponent.find((component) => {
|
|
198
|
-
return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
199
|
-
&& (!Array.isArray(component.appliesToAddOn));
|
|
200
|
-
});
|
|
201
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
202
|
-
/* istanbul ignore if */
|
|
203
|
-
if (unitPriceSpec === undefined) {
|
|
204
|
-
throw new factory.errors.NotFound('UnitPriceSpecification of acceptedOffer');
|
|
205
|
-
}
|
|
206
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
207
|
-
/* istanbul ignore if */
|
|
208
|
-
if (offer.itemOffered.reservationFor.typeOf !== factory.eventType.ScreeningEvent) {
|
|
209
|
-
throw new factory.errors.NotImplemented(`offer.itemOffered.reservationFor.typeOf not imelemented [${offer.itemOffered.reservationFor.typeOf}]`);
|
|
210
|
-
}
|
|
191
|
+
// 現状、ScreeningEventのみ対応で十分(2024-04-16~)
|
|
192
|
+
if (offer.itemOffered.reservationFor.typeOf === factory.eventType.ScreeningEvent) {
|
|
211
193
|
const reservationFor4movieTicket = {
|
|
212
194
|
typeOf: offer.itemOffered.reservationFor.typeOf,
|
|
213
195
|
id: offer.itemOffered.reservationFor.id
|
|
214
196
|
};
|
|
215
|
-
//
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
// 座席無に対応(2024-04-16~)
|
|
198
|
+
let ticketedSeat4MovieTicket;
|
|
199
|
+
// USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIERのみ座席無に対応(2024-04-16~)
|
|
200
|
+
if (settings_1.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER) {
|
|
201
|
+
ticketedSeat4MovieTicket = {
|
|
202
|
+
typeOf: factory.placeType.Seat,
|
|
203
|
+
seatNumber: '',
|
|
204
|
+
seatRow: '',
|
|
205
|
+
seatSection: ''
|
|
206
|
+
};
|
|
222
207
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
208
|
+
const offeredTicketedSeat = (_c = (_b = offer.itemOffered) === null || _b === void 0 ? void 0 : _b.reservedTicket) === null || _c === void 0 ? void 0 : _c.ticketedSeat;
|
|
209
|
+
const ticketedSeatExists = (offeredTicketedSeat === null || offeredTicketedSeat === void 0 ? void 0 : offeredTicketedSeat.typeOf) === factory.placeType.Seat;
|
|
210
|
+
if (ticketedSeatExists) {
|
|
211
|
+
ticketedSeat4MovieTicket = offeredTicketedSeat;
|
|
212
|
+
}
|
|
213
|
+
if (ticketedSeat4MovieTicket !== undefined) {
|
|
214
|
+
// チケット識別子(決済カード承認との照合に必要)
|
|
215
|
+
const reservedTicketIdentifier = (typeof offer.itemOffered.reservedTicket.identifier === 'string')
|
|
216
|
+
? offer.itemOffered.reservedTicket.identifier
|
|
217
|
+
: `${reservationFor4movieTicket.id}:${offer.itemOffered.id}`;
|
|
218
|
+
const movieTicketServiceOutput4validate = {
|
|
219
|
+
reservationFor: reservationFor4movieTicket,
|
|
220
|
+
reservedTicket: {
|
|
221
|
+
identifier: reservedTicketIdentifier,
|
|
222
|
+
ticketedSeat: ticketedSeat4MovieTicket
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
// 指定された決済方法の適用決済カードリスト
|
|
226
|
+
let appliesToMovieTickets4paymentMethod = [];
|
|
227
|
+
const appliesToMovieTickets4reservation = unitPriceSpec.appliesToMovieTicket;
|
|
228
|
+
if (Array.isArray(appliesToMovieTickets4reservation)) {
|
|
229
|
+
appliesToMovieTickets4paymentMethod = appliesToMovieTickets4reservation.filter((a) => {
|
|
230
|
+
return a.serviceOutput.typeOf === paymentMethodType;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
if (Array.isArray(appliesToMovieTickets4paymentMethod) && appliesToMovieTickets4paymentMethod.length > 0) {
|
|
234
|
+
appliesToMovieTickets4paymentMethod.forEach((appliesToMovieTicket) => {
|
|
235
|
+
requiredMovieTickets.push({
|
|
236
|
+
typeOf: paymentMethodType,
|
|
237
|
+
identifier: String(appliesToMovieTicket.identifier),
|
|
238
|
+
serviceType: appliesToMovieTicket.serviceType,
|
|
239
|
+
serviceOutput: movieTicketServiceOutput4validate
|
|
240
|
+
});
|
|
238
241
|
});
|
|
239
|
-
}
|
|
242
|
+
}
|
|
240
243
|
}
|
|
241
244
|
}
|
|
242
245
|
});
|
|
@@ -256,7 +256,7 @@ function validateAcceptedOffers(params) {
|
|
|
256
256
|
debug('ticketIdentifiers unique?', ticketIdentifiers.join(' '), 'numAcceptedOffers:', numAcceptedOffers);
|
|
257
257
|
// チケット識別子が注文内ユニークなので、注文オファー数に一致するはず
|
|
258
258
|
if (ticketIdentifiers.length !== numAcceptedOffers) {
|
|
259
|
-
throw new factory.errors.Argument('Transaction', '
|
|
259
|
+
throw new factory.errors.Argument('Transaction', 'ticketIdentifiers must be unique');
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
// チケット識別子ユニークネス検証(2024-04-15~)
|
|
@@ -18,7 +18,7 @@ const factory_2 = require("../offer/product/factory");
|
|
|
18
18
|
const validateMovieTicket_1 = require("../transaction/placeOrderInProgress/validation/validateMovieTicket");
|
|
19
19
|
// const debug = createDebug('chevre-domain:service:validation');
|
|
20
20
|
function validateOrder(params) {
|
|
21
|
-
// tslint:disable-next-line:max-func-body-length
|
|
21
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
22
22
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
23
|
const order = yield repos.order.findByOrderNumber({
|
|
24
24
|
orderNumber: params.orderNumber,
|
|
@@ -79,11 +79,15 @@ function validateOrder(params) {
|
|
|
79
79
|
});
|
|
80
80
|
let reservationForIds = [];
|
|
81
81
|
let itemOfferedTypeOfs = [];
|
|
82
|
+
let reservationReservedTicketIdentifiers = [];
|
|
82
83
|
acceptedOffers.forEach(({ itemOffered }) => {
|
|
83
84
|
itemOfferedTypeOfs.push(itemOffered.typeOf);
|
|
84
85
|
if (itemOffered.typeOf === factory.reservationType.BusReservation
|
|
85
86
|
|| itemOffered.typeOf === factory.reservationType.EventReservation) {
|
|
86
87
|
reservationForIds.push(itemOffered.reservationFor.id);
|
|
88
|
+
if (typeof itemOffered.reservedTicket.identifier === 'string') {
|
|
89
|
+
reservationReservedTicketIdentifiers.push(itemOffered.reservedTicket.identifier);
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
reservationForIds = [...new Set(reservationForIds)];
|
|
@@ -179,6 +183,14 @@ function validateOrder(params) {
|
|
|
179
183
|
});
|
|
180
184
|
(0, validateMovieTicket_1.validateMovieTicket)(paymentMethod.identifier, { id: 'xxxx' }, authorizedMovieTickets, acceptedOffers);
|
|
181
185
|
});
|
|
186
|
+
// チケット識別子ユニークネス検証(2024-04-17~)
|
|
187
|
+
if (reservationReservedTicketIdentifiers.length > 0) {
|
|
188
|
+
reservationReservedTicketIdentifiers = [...new Set(reservationReservedTicketIdentifiers)];
|
|
189
|
+
// チケット識別子が注文内ユニークなので、注文オファー数に一致するはず
|
|
190
|
+
if (reservationReservedTicketIdentifiers.length !== acceptedOffers.length) {
|
|
191
|
+
throw new Error(`invalid ticketIdentifiers.length:${reservationReservedTicketIdentifiers.length} [expected:${acceptedOffers.length}]`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
182
194
|
});
|
|
183
195
|
}
|
|
184
196
|
exports.validateOrder = validateOrder;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -4,10 +4,6 @@ export declare const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS: number;
|
|
|
4
4
|
export declare const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS: number;
|
|
5
5
|
export declare const ABORTED_TASKS_WITHOUT_REPORT: string[];
|
|
6
6
|
export declare const MAX_NUM_CREDIT_CARD_PAYMENT_METHOD: number;
|
|
7
|
-
/**
|
|
8
|
-
* 資産取引保管期間
|
|
9
|
-
*/
|
|
10
|
-
export declare const ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS: number;
|
|
11
7
|
/**
|
|
12
8
|
* 取引保管期間(Confirmed)
|
|
13
9
|
*/
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.
|
|
3
|
+
exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_VALIDATE_MOVIE_TICKET_BY_TICKET_IDENTIFIER = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const factory = require("./factory");
|
|
5
5
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
6
6
|
? process.env.INFORM_TRANSACTION_URL.split(' ')
|
|
@@ -35,13 +35,6 @@ exports.ABORTED_TASKS_WITHOUT_REPORT = (typeof process.env.ABORTED_TASKS_WITHOUT
|
|
|
35
35
|
exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = (typeof process.env.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD === 'string')
|
|
36
36
|
? Number(process.env.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD)
|
|
37
37
|
: 1;
|
|
38
|
-
/**
|
|
39
|
-
* 資産取引保管期間
|
|
40
|
-
*/
|
|
41
|
-
exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = (typeof process.env.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS === 'string')
|
|
42
|
-
? Number(process.env.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS)
|
|
43
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
-
: 500;
|
|
45
38
|
/**
|
|
46
39
|
* 取引保管期間(Confirmed)
|
|
47
40
|
*/
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.367.0
|
|
13
|
+
"@chevre/factory": "4.367.0",
|
|
14
14
|
"@cinerino/sdk": "5.17.1",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.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.29.0
|
|
113
|
+
"version": "21.29.0"
|
|
114
114
|
}
|
|
@@ -1,65 +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
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
const cursor = orderRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
orderDate: {
|
|
18
|
-
$gte: moment()
|
|
19
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
20
|
-
.add(-12, 'months')
|
|
21
|
-
.toDate()
|
|
22
|
-
// $lte: moment()
|
|
23
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
24
|
-
// .add(-6, 'months')
|
|
25
|
-
// .toDate()
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
orderDate: 1,
|
|
30
|
-
orderNumber: 1,
|
|
31
|
-
project: 1,
|
|
32
|
-
seller: 1
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
console.log('orders found');
|
|
36
|
-
|
|
37
|
-
let i = 0;
|
|
38
|
-
let updateCount = 0;
|
|
39
|
-
await cursor.eachAsync(async (doc) => {
|
|
40
|
-
i += 1;
|
|
41
|
-
const order: Pick<
|
|
42
|
-
chevre.factory.order.IOrder,
|
|
43
|
-
'orderDate' | 'orderNumber' | 'project' | 'seller'
|
|
44
|
-
> = doc.toObject();
|
|
45
|
-
console.log(order);
|
|
46
|
-
|
|
47
|
-
const alreadyMigrated = (<any>order.seller).telephone === undefined
|
|
48
|
-
&& (<any>order.seller).url === undefined;
|
|
49
|
-
|
|
50
|
-
if (alreadyMigrated) {
|
|
51
|
-
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
52
|
-
} else {
|
|
53
|
-
console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
54
|
-
updateCount += 1;
|
|
55
|
-
console.log('updated.', order.project.id, order.orderNumber, order.orderDate, i, updateCount);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
console.log(i, 'orders checked');
|
|
60
|
-
console.log(updateCount, 'orders updated');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main()
|
|
64
|
-
.then()
|
|
65
|
-
.catch(console.error);
|
|
@@ -1,87 +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
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
19
|
-
// typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
20
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
21
|
-
// 'offers.availabilityEnds': { $exists: true }
|
|
22
|
-
},
|
|
23
|
-
{}
|
|
24
|
-
);
|
|
25
|
-
console.log('events found');
|
|
26
|
-
|
|
27
|
-
let i = 0;
|
|
28
|
-
let updateCount = 0;
|
|
29
|
-
const projectIds: string[] = [];
|
|
30
|
-
let createdAtLatest: Date | undefined;
|
|
31
|
-
let updatedAtLatest: Date | undefined;
|
|
32
|
-
await cursor.eachAsync(async (doc) => {
|
|
33
|
-
i += 1;
|
|
34
|
-
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
35
|
-
|
|
36
|
-
const unacceptedPaymentMethod = event.offers?.unacceptedPaymentMethod;
|
|
37
|
-
const alreadyMigrated =
|
|
38
|
-
(!Array.isArray(unacceptedPaymentMethod))
|
|
39
|
-
|| (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length === 0)
|
|
40
|
-
|| (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length === 1 && unacceptedPaymentMethod[0] === 'MovieTicket');
|
|
41
|
-
|
|
42
|
-
if (alreadyMigrated) {
|
|
43
|
-
console.log(
|
|
44
|
-
'already migrated.', event.project.id, event.id, event.startDate, i);
|
|
45
|
-
} else {
|
|
46
|
-
projectIds.push(event.project.id);
|
|
47
|
-
if (createdAtLatest instanceof Date) {
|
|
48
|
-
if (moment(createdAtLatest)
|
|
49
|
-
.isBefore(moment((<any>event).createdAt))) {
|
|
50
|
-
createdAtLatest = (<any>event).createdAt;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
createdAtLatest = (<any>event).createdAt;
|
|
54
|
-
}
|
|
55
|
-
if (updatedAtLatest instanceof Date) {
|
|
56
|
-
if (moment(updatedAtLatest)
|
|
57
|
-
.isBefore(moment((<any>event).updatedAt))) {
|
|
58
|
-
updatedAtLatest = (<any>event).updatedAt;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
updatedAtLatest = (<any>event).updatedAt;
|
|
62
|
-
}
|
|
63
|
-
console.log(
|
|
64
|
-
'updating event...', event.project.id, event.id, event.startDate, unacceptedPaymentMethod,
|
|
65
|
-
(<any>event).createdAt,
|
|
66
|
-
(<any>event).updatedAt,
|
|
67
|
-
i
|
|
68
|
-
);
|
|
69
|
-
// await creativeWorkRepo.saveMovie(<any>{
|
|
70
|
-
// id: String(movie.id),
|
|
71
|
-
// 'offers.availabilityStarts': availabilityStarts
|
|
72
|
-
// });
|
|
73
|
-
updateCount += 1;
|
|
74
|
-
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
console.log(i, 'events checked');
|
|
79
|
-
console.log(updateCount, 'events updated');
|
|
80
|
-
console.log('projectIds:', [...new Set(projectIds)]);
|
|
81
|
-
console.log('createdAtLatest:', createdAtLatest);
|
|
82
|
-
console.log('updatedAtLatest:', updatedAtLatest);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main()
|
|
86
|
-
.then()
|
|
87
|
-
.catch(console.error);
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
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 productModelRepo = await chevre.repository.ProductModel.createInstance(mongoose.connection);
|
|
12
|
-
const result = await productModelRepo.search(
|
|
13
|
-
{
|
|
14
|
-
limit: 100,
|
|
15
|
-
page: 1,
|
|
16
|
-
category: {
|
|
17
|
-
codeValue: { $in: ['Premium'] },
|
|
18
|
-
inCodeSet: { identifier: { $eq: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
[],
|
|
22
|
-
[]
|
|
23
|
-
);
|
|
24
|
-
console.log('result:', result);
|
|
25
|
-
|
|
26
|
-
const productModel = {
|
|
27
|
-
project: {
|
|
28
|
-
id: project.id,
|
|
29
|
-
typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project
|
|
30
|
-
},
|
|
31
|
-
typeOf: <'ProductModel'>'ProductModel',
|
|
32
|
-
category: {
|
|
33
|
-
codeValue: 'Premium',
|
|
34
|
-
inCodeSet: {
|
|
35
|
-
identifier: chevre.factory.categoryCode.CategorySetIdentifier.SeatingType,
|
|
36
|
-
typeOf: <'CategoryCodeSet'>'CategoryCodeSet'
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
name: { ja: 'プレミアムシート' },
|
|
40
|
-
offers: [{
|
|
41
|
-
typeOf: <chevre.factory.offerType.Offer>chevre.factory.offerType.Offer
|
|
42
|
-
}]
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const createdModel = await productModelRepo.save({
|
|
46
|
-
$set: productModel
|
|
47
|
-
});
|
|
48
|
-
console.log('created. id:', createdModel);
|
|
49
|
-
|
|
50
|
-
await productModelRepo.save({
|
|
51
|
-
id: createdModel.id,
|
|
52
|
-
$set: productModel
|
|
53
|
-
});
|
|
54
|
-
console.log('updated. id:', createdModel.id);
|
|
55
|
-
|
|
56
|
-
await productModelRepo.deleteById({
|
|
57
|
-
id: createdModel.id
|
|
58
|
-
});
|
|
59
|
-
console.log('deleted. id:', createdModel.id);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
main()
|
|
63
|
-
.then(console.log)
|
|
64
|
-
.catch(console.error);
|