@chevre/domain 23.2.0-alpha.57 → 23.2.0-alpha.59
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/event/importEventsFromCOAByTitle.ts +1 -1
- package/example/src/chevre/eventSeries/upsertScreeningEventSeriesByVersion.ts +0 -1
- package/example/src/chevre/settings/addOrderNumberSetting.ts +6 -2
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/factory/event.js +11 -8
- package/lib/chevre/repo/event.d.ts +1 -1
- package/lib/chevre/repo/eventSeries.d.ts +5 -22
- package/lib/chevre/repo/eventSeries.js +97 -77
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +4 -26
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +4 -0
- package/lib/chevre/repo/orderNumber.d.ts +3 -0
- package/lib/chevre/repo/orderNumber.js +18 -30
- package/lib/chevre/repo/transactionNumber.js +8 -10
- package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
- package/lib/chevre/service/event/saveScreeningEvents.js +18 -10
- package/lib/chevre/service/offer/onEventChanged.js +3 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +3 -1
- package/lib/chevre/service/task/syncResourcesFromCOA.js +3 -1
- package/package.json +3 -3
- package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +0 -75
- package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
- package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +0 -80
|
@@ -87,7 +87,7 @@ async function main() {
|
|
|
87
87
|
[
|
|
88
88
|
'project', 'typeOf', 'eventStatus', 'identifier',
|
|
89
89
|
'name', 'kanaName', 'alternativeHeadline', 'location',
|
|
90
|
-
'organizer', '
|
|
90
|
+
'organizer', 'soundFormat', 'workPerformed',
|
|
91
91
|
'duration', 'endDate', 'startDate', 'coaInfo',
|
|
92
92
|
'offers', 'additionalProperty'
|
|
93
93
|
]
|
|
@@ -24,10 +24,14 @@ async function main() {
|
|
|
24
24
|
{ project: { id: { $eq: '*' } } },
|
|
25
25
|
{
|
|
26
26
|
orderNumber: {
|
|
27
|
-
validFrom: moment('
|
|
27
|
+
validFrom: moment('2026-02-10T05:00:00Z')
|
|
28
28
|
.toDate(),
|
|
29
29
|
fpeSecret: FPE_SECRET,
|
|
30
|
-
version: 'A'
|
|
30
|
+
version: 'A',
|
|
31
|
+
versioningForceProjects: [
|
|
32
|
+
'TTT',
|
|
33
|
+
'SSK'
|
|
34
|
+
]
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
);
|
|
@@ -4,5 +4,5 @@ export type IMinimizedIndividualEvent = Pick<factory.event.screeningEvent.IEvent
|
|
|
4
4
|
* 興行イベントのsuperEventを作成する
|
|
5
5
|
*/
|
|
6
6
|
export declare function minimizeSuperEvent(params: {
|
|
7
|
-
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | '
|
|
7
|
+
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
|
|
8
8
|
}): factory.event.screeningEvent.ISuperEvent;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.minimizeSuperEvent = minimizeSuperEvent;
|
|
4
4
|
const factory = require("../factory");
|
|
5
|
-
const USE_DEPRECATED_VIDEO_FORMAT_EVENTS = process.env.USE_DEPRECATED_VIDEO_FORMAT_EVENTS === '1';
|
|
6
5
|
/**
|
|
7
6
|
* 興行イベントのsuperEventを作成する
|
|
8
7
|
*/
|
|
@@ -24,7 +23,7 @@ function minimizeSuperEvent(params) {
|
|
|
24
23
|
// ? { kanaName: params.superEventFromDB.location.kanaName }
|
|
25
24
|
// : undefined
|
|
26
25
|
);
|
|
27
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
26
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: factory.eventType.ScreeningEventSeries, id: params.superEventFromDB.id, soundFormat: params.superEventFromDB.soundFormat, workPerformed,
|
|
28
27
|
location, kanaName: params.superEventFromDB.kanaName, name: Object.assign(Object.assign({}, (typeof params.superEventFromDB.name.en === 'string') ? { en: params.superEventFromDB.name.en } : undefined), (typeof params.superEventFromDB.name.ja === 'string') ? { ja: params.superEventFromDB.name.ja } : undefined) }, (Array.isArray(params.superEventFromDB.additionalProperty))
|
|
29
28
|
? { additionalProperty: params.superEventFromDB.additionalProperty }
|
|
30
29
|
: undefined), (params.superEventFromDB.startDate instanceof Date)
|
|
@@ -39,10 +38,14 @@ function minimizeSuperEvent(params) {
|
|
|
39
38
|
? { dubLanguage: params.superEventFromDB.dubLanguage }
|
|
40
39
|
: undefined), (params.superEventFromDB.subtitleLanguage !== undefined)
|
|
41
40
|
? { subtitleLanguage: params.superEventFromDB.subtitleLanguage }
|
|
42
|
-
: undefined
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
: undefined
|
|
42
|
+
// 完全に廃止(2026-02-10~)
|
|
43
|
+
// // videoFormatをデータとしても廃止(万が一に備えてUSE_DEPRECATED_VIDEO_FORMAT_EVENTSで再設定可能)(2026-02-04~)
|
|
44
|
+
// ...(USE_DEPRECATED_VIDEO_FORMAT_EVENTS)
|
|
45
|
+
// ? {
|
|
46
|
+
// // 現時点で型廃止済だがデータとしては互換性維持(2026-01-15~)
|
|
47
|
+
// videoFormat: params.superEventFromDB.videoFormat
|
|
48
|
+
// }
|
|
49
|
+
// : undefined
|
|
50
|
+
);
|
|
48
51
|
}
|
|
@@ -210,7 +210,7 @@ export declare class EventRepo {
|
|
|
210
210
|
project: {
|
|
211
211
|
id: string;
|
|
212
212
|
};
|
|
213
|
-
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | '
|
|
213
|
+
superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
|
|
214
214
|
startDate: {
|
|
215
215
|
$gte: Date;
|
|
216
216
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
-
import type { Connection,
|
|
2
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
type ISearchConditions = factory.eventSeries.ISearchConditions;
|
|
5
|
-
type IKeyOfProjection = Exclude<keyof factory.eventSeries.IEvent, 'id'>;
|
|
5
|
+
type IKeyOfProjection = Exclude<keyof factory.eventSeries.IEvent, 'id' | 'videoFormat'>;
|
|
6
6
|
type IUnset = {
|
|
7
7
|
[key in keyof factory.eventSeries.IEvent]?: 1;
|
|
8
8
|
};
|
|
@@ -13,13 +13,6 @@ export declare class EventSeriesRepo {
|
|
|
13
13
|
private readonly eventSeriesModel;
|
|
14
14
|
constructor(connection: Connection);
|
|
15
15
|
static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.eventSeries.IEvent>[];
|
|
16
|
-
/**
|
|
17
|
-
* 複数イベントを作成する
|
|
18
|
-
*/
|
|
19
|
-
createManyEventSeries(params: {
|
|
20
|
-
attributes: factory.eventSeries.IAttributes[];
|
|
21
|
-
expectsNoContent: boolean;
|
|
22
|
-
}): Promise<string[] | void>;
|
|
23
16
|
/**
|
|
24
17
|
* コンテンツ+バージョンをキーにして、なければ作成する(複数対応)
|
|
25
18
|
*/
|
|
@@ -44,16 +37,6 @@ export declare class EventSeriesRepo {
|
|
|
44
37
|
id: string;
|
|
45
38
|
}[];
|
|
46
39
|
}>;
|
|
47
|
-
saveEventSeries(params: {
|
|
48
|
-
id?: string;
|
|
49
|
-
attributes: factory.eventSeries.IAttributes;
|
|
50
|
-
/**
|
|
51
|
-
* ドキュメント作成時には無視される
|
|
52
|
-
*/
|
|
53
|
-
$unset?: IUnset;
|
|
54
|
-
}): Promise<{
|
|
55
|
-
id: string;
|
|
56
|
-
}>;
|
|
57
40
|
/**
|
|
58
41
|
* sskts施設コンテンツ保管
|
|
59
42
|
*/
|
|
@@ -64,7 +47,7 @@ export declare class EventSeriesRepo {
|
|
|
64
47
|
/**
|
|
65
48
|
* イベントを検索する(inclusion projection)
|
|
66
49
|
*/
|
|
67
|
-
projectEventSeriesFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.eventSeries.IEvent[]>;
|
|
50
|
+
projectEventSeriesFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.eventSeries.IEvent, 'videoFormat'>[]>;
|
|
68
51
|
deleteEventSeriesById(params: {
|
|
69
52
|
project: {
|
|
70
53
|
id: string;
|
|
@@ -109,13 +92,13 @@ export declare class EventSeriesRepo {
|
|
|
109
92
|
}): Promise<{
|
|
110
93
|
maxVersion: string;
|
|
111
94
|
}>;
|
|
112
|
-
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, factory.eventSeries.IAttributes & {
|
|
95
|
+
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, factory.eventSeries.IAttributes & {
|
|
113
96
|
_id: string;
|
|
114
97
|
}> & factory.eventSeries.IAttributes & {
|
|
115
98
|
_id: string;
|
|
116
99
|
} & Required<{
|
|
117
100
|
_id: string;
|
|
118
|
-
}>, import("mongoose").QueryOptions<Document<unknown, {}, factory.eventSeries.IAttributes & {
|
|
101
|
+
}>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.eventSeries.IAttributes & {
|
|
119
102
|
_id: string;
|
|
120
103
|
}> & factory.eventSeries.IAttributes & {
|
|
121
104
|
_id: string;
|
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.EventSeriesRepo = void 0;
|
|
24
24
|
const factory = require("../factory");
|
|
25
25
|
const eventSeries_1 = require("./mongoose/schemas/eventSeries");
|
|
26
|
-
|
|
26
|
+
// import { isMongoError, MongoErrorCode } from '../errorHandler';
|
|
27
27
|
const settings_1 = require("../settings");
|
|
28
28
|
/**
|
|
29
29
|
* 施設コンテンツリポジトリ
|
|
@@ -224,34 +224,40 @@ class EventSeriesRepo {
|
|
|
224
224
|
}
|
|
225
225
|
return andConditions;
|
|
226
226
|
}
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
createManyEventSeries(params
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
227
|
+
// /**
|
|
228
|
+
// * 複数イベントを作成する
|
|
229
|
+
// */
|
|
230
|
+
// public async createManyEventSeries(params: {
|
|
231
|
+
// attributes: factory.eventSeries.IAttributes[];
|
|
232
|
+
// expectsNoContent: boolean;
|
|
233
|
+
// }): Promise<string[] | void> { // optimize response(only id)(2024-08-02~)
|
|
234
|
+
// const uniqid = await import('uniqid');
|
|
235
|
+
// const insertingDocs: (factory.eventSeries.IAttributes & { _id: string })[] =
|
|
236
|
+
// params.attributes.map((p) => {
|
|
237
|
+
// return {
|
|
238
|
+
// _id: uniqid(),
|
|
239
|
+
// ...p
|
|
240
|
+
// };
|
|
241
|
+
// });
|
|
242
|
+
// try {
|
|
243
|
+
// await this.eventSeriesModel.insertMany<factory.eventSeries.IAttributes & { _id: string }>(
|
|
244
|
+
// insertingDocs,
|
|
245
|
+
// { rawResult: true } // rawResult(2024-08-02~)
|
|
246
|
+
// );
|
|
247
|
+
// // console.dir(insertResult, { depth: null });
|
|
248
|
+
// } catch (error) {
|
|
249
|
+
// if (await isMongoError(error)) {
|
|
250
|
+
// if (error.code === MongoErrorCode.DuplicateKey) {
|
|
251
|
+
// throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
|
|
252
|
+
// }
|
|
253
|
+
// }
|
|
254
|
+
// throw error;
|
|
255
|
+
// }
|
|
256
|
+
// if (params.expectsNoContent) {
|
|
257
|
+
// return;
|
|
258
|
+
// }
|
|
259
|
+
// return insertingDocs.map(({ _id }) => _id);
|
|
260
|
+
// }
|
|
255
261
|
/**
|
|
256
262
|
* コンテンツ+バージョンをキーにして、なければ作成する(複数対応)
|
|
257
263
|
*/
|
|
@@ -374,54 +380,68 @@ class EventSeriesRepo {
|
|
|
374
380
|
return { modifiedEvents: [] };
|
|
375
381
|
});
|
|
376
382
|
}
|
|
377
|
-
saveEventSeries(params
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
383
|
+
// public async saveEventSeries(params: {
|
|
384
|
+
// id?: string;
|
|
385
|
+
// attributes: factory.eventSeries.IAttributes;
|
|
386
|
+
// /**
|
|
387
|
+
// * ドキュメント作成時には無視される
|
|
388
|
+
// */
|
|
389
|
+
// $unset?: IUnset;
|
|
390
|
+
// // upsert?: boolean;
|
|
391
|
+
// }): Promise<{ id: string }> {
|
|
392
|
+
// let savedEventId: string;
|
|
393
|
+
// let doc: Document | { _id: string } | null;
|
|
394
|
+
// const { identifier, project, typeOf, ...updateFields } = params.attributes;
|
|
395
|
+
// if (typeof typeOf !== 'string' || typeOf.length === 0) {
|
|
396
|
+
// throw new factory.errors.ArgumentNull('attributes.typeOf');
|
|
397
|
+
// }
|
|
398
|
+
// try {
|
|
399
|
+
// if (params.id === undefined) {
|
|
400
|
+
// const uniqid = await import('uniqid');
|
|
401
|
+
// const id = uniqid();
|
|
402
|
+
// doc = await this.eventSeriesModel.create({ ...params.attributes, _id: id });
|
|
403
|
+
// savedEventId = id;
|
|
404
|
+
// } else {
|
|
405
|
+
// // const upsert: boolean = params.upsert === true;
|
|
406
|
+
// const upsert: boolean = false;
|
|
407
|
+
// doc = await this.eventSeriesModel.findOneAndUpdate(
|
|
408
|
+
// {
|
|
409
|
+
// _id: { $eq: params.id },
|
|
410
|
+
// typeOf: { $eq: typeOf }
|
|
411
|
+
// },
|
|
412
|
+
// {
|
|
413
|
+
// // 上書き禁止属性を除外(2022-08-24~)
|
|
414
|
+
// $setOnInsert: {
|
|
415
|
+
// typeOf,
|
|
416
|
+
// project,
|
|
417
|
+
// ...(identifier !== undefined) ? { identifier } : undefined
|
|
418
|
+
// },
|
|
419
|
+
// $set: updateFields,
|
|
420
|
+
// ...(params.$unset !== undefined) ? { $unset: params.$unset } : undefined
|
|
421
|
+
// },
|
|
422
|
+
// {
|
|
423
|
+
// upsert,
|
|
424
|
+
// new: true,
|
|
425
|
+
// projection: { _id: 1 }
|
|
426
|
+
// }
|
|
427
|
+
// )
|
|
428
|
+
// .lean<{ _id: string }>()
|
|
429
|
+
// .exec();
|
|
430
|
+
// savedEventId = params.id;
|
|
431
|
+
// }
|
|
432
|
+
// } catch (error) {
|
|
433
|
+
// if (await isMongoError(error)) {
|
|
434
|
+
// if (error.code === MongoErrorCode.DuplicateKey) {
|
|
435
|
+
// throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
|
|
436
|
+
// }
|
|
437
|
+
// }
|
|
438
|
+
// throw error;
|
|
439
|
+
// }
|
|
440
|
+
// if (doc === null) {
|
|
441
|
+
// throw new factory.errors.NotFound(this.eventSeriesModel.modelName);
|
|
442
|
+
// }
|
|
443
|
+
// return { id: savedEventId }; // optimize(2024-07-31~)
|
|
444
|
+
// }
|
|
425
445
|
/**
|
|
426
446
|
* sskts施設コンテンツ保管
|
|
427
447
|
*/
|
|
@@ -8,32 +8,10 @@ const factory = require("../../../factory");
|
|
|
8
8
|
const settings_1 = require("../../../settings");
|
|
9
9
|
const modelName = 'EventSeries';
|
|
10
10
|
exports.modelName = modelName;
|
|
11
|
-
const schemaDefinition = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
typeOf: { type: String, required: true },
|
|
16
|
-
identifier: String,
|
|
17
|
-
name: mongoose_1.SchemaTypes.Mixed,
|
|
18
|
-
additionalProperty: mongoose_1.SchemaTypes.Mixed,
|
|
19
|
-
alternativeHeadline: mongoose_1.SchemaTypes.Mixed,
|
|
20
|
-
description: mongoose_1.SchemaTypes.Mixed,
|
|
21
|
-
duration: String,
|
|
22
|
-
endDate: { type: Date, required: true }, // required(2025-10-08~)
|
|
23
|
-
eventStatus: String,
|
|
24
|
-
headline: mongoose_1.SchemaTypes.Mixed,
|
|
25
|
-
location: mongoose_1.SchemaTypes.Mixed,
|
|
26
|
-
startDate: { type: Date, required: true }, // required(2025-10-08~)
|
|
27
|
-
subEvent: mongoose_1.SchemaTypes.Mixed, // support(2025-12-31~)
|
|
28
|
-
workPerformed: mongoose_1.SchemaTypes.Mixed,
|
|
29
|
-
videoFormat: mongoose_1.SchemaTypes.Mixed,
|
|
30
|
-
soundFormat: mongoose_1.SchemaTypes.Mixed,
|
|
31
|
-
subtitleLanguage: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
-
dubLanguage: mongoose_1.SchemaTypes.Mixed,
|
|
33
|
-
kanaName: String,
|
|
34
|
-
offers: mongoose_1.SchemaTypes.Mixed,
|
|
35
|
-
coaInfo: mongoose_1.SchemaTypes.Mixed
|
|
36
|
-
};
|
|
11
|
+
const schemaDefinition = Object.assign({ project: { type: mongoose_1.SchemaTypes.Mixed, required: true }, organizer: { type: mongoose_1.SchemaTypes.Mixed, required: true }, _id: String, typeOf: { type: String, required: true }, identifier: String, name: mongoose_1.SchemaTypes.Mixed, additionalProperty: mongoose_1.SchemaTypes.Mixed, alternativeHeadline: mongoose_1.SchemaTypes.Mixed, description: mongoose_1.SchemaTypes.Mixed, duration: String, endDate: { type: Date, required: true }, eventStatus: String, headline: mongoose_1.SchemaTypes.Mixed, location: mongoose_1.SchemaTypes.Mixed, startDate: { type: Date, required: true }, subEvent: mongoose_1.SchemaTypes.Mixed, workPerformed: mongoose_1.SchemaTypes.Mixed, soundFormat: mongoose_1.SchemaTypes.Mixed, subtitleLanguage: mongoose_1.SchemaTypes.Mixed, dubLanguage: mongoose_1.SchemaTypes.Mixed, kanaName: String, offers: mongoose_1.SchemaTypes.Mixed, coaInfo: mongoose_1.SchemaTypes.Mixed }, {
|
|
12
|
+
// factory.eventSeries.IEventから廃止したので、ひとまずspread operatorで解決(2026-02-10~)
|
|
13
|
+
videoFormat: mongoose_1.SchemaTypes.Mixed
|
|
14
|
+
});
|
|
37
15
|
const schemaOptions = {
|
|
38
16
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
39
17
|
autoCreate: false,
|
|
@@ -121,6 +121,10 @@ export interface IOrderNumberSetting {
|
|
|
121
121
|
*/
|
|
122
122
|
version: string;
|
|
123
123
|
versioningForceProjects?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* 強制的にバージョニング不使用のプロジェクト
|
|
126
|
+
*/
|
|
127
|
+
versioningExceptionProjects?: string[];
|
|
124
128
|
}
|
|
125
129
|
export interface ITransactionNumberSetting {
|
|
126
130
|
validFrom: Date;
|
|
@@ -12,10 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.OrderNumberRepo = void 0;
|
|
13
13
|
const cdigit = require("cdigit");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
-
// import { RedisClientType } from 'redis';
|
|
16
15
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
17
16
|
const fpe = require('node-fpe-v1');
|
|
18
|
-
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
19
17
|
const factory = require("../factory");
|
|
20
18
|
const transactionNumber_1 = require("../factory/transactionNumber");
|
|
21
19
|
const setting_1 = require("./mongoose/schemas/setting");
|
|
@@ -32,23 +30,9 @@ const defaultVersioningForceProjects = [
|
|
|
32
30
|
*/
|
|
33
31
|
class OrderNumberRepo {
|
|
34
32
|
constructor(params) {
|
|
35
|
-
// const { connection } = params;
|
|
36
|
-
// this.settingModel = connection.model(settingModelName, createSettingSchema());
|
|
37
33
|
this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
|
|
38
34
|
this.settingModel = params.connection.model(setting_1.modelName, (0, setting_1.createSchema)());
|
|
39
35
|
}
|
|
40
|
-
// private static createKey(params: {
|
|
41
|
-
// orderDate: Date;
|
|
42
|
-
// projectPrefix: string;
|
|
43
|
-
// timestamp: string;
|
|
44
|
-
// }): string {
|
|
45
|
-
// return util.format(
|
|
46
|
-
// '%s:%s:%s',
|
|
47
|
-
// OrderNumberRepo.REDIS_KEY_PREFIX,
|
|
48
|
-
// params.projectPrefix,
|
|
49
|
-
// params.timestamp
|
|
50
|
-
// );
|
|
51
|
-
// }
|
|
52
36
|
static GENERATE_VERSION0(timestamp, seq) {
|
|
53
37
|
let orderNumber = `${timestamp}${seq}`;
|
|
54
38
|
// checkdigit
|
|
@@ -63,7 +47,7 @@ class OrderNumberRepo {
|
|
|
63
47
|
*/
|
|
64
48
|
publishByTimestamp(params) {
|
|
65
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const { fpeSecret, version, validFrom, versioningForceProjects } = yield this.findSetting();
|
|
50
|
+
const { fpeSecret, version, validFrom, versioningForceProjects, versioningExceptionProjects } = yield this.findSetting();
|
|
67
51
|
const timestamp = moment(params.orderDate)
|
|
68
52
|
.valueOf()
|
|
69
53
|
.toString();
|
|
@@ -72,7 +56,6 @@ class OrderNumberRepo {
|
|
|
72
56
|
let dataFeedExpires;
|
|
73
57
|
const dataFeedIdentifier = `${projectPrefix}:${timestamp}`;
|
|
74
58
|
let incrReply;
|
|
75
|
-
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
76
59
|
dataFeedExpires = moment(params.orderDate)
|
|
77
60
|
.add(1, 'minute') // ミリ秒でカウントしていくので、注文日時後1分で十分
|
|
78
61
|
.toDate();
|
|
@@ -82,14 +65,18 @@ class OrderNumberRepo {
|
|
|
82
65
|
expires: dataFeedExpires
|
|
83
66
|
});
|
|
84
67
|
let orderNumber;
|
|
85
|
-
|
|
86
|
-
const useVersioning = (validFrom instanceof Date && moment(validFrom)
|
|
68
|
+
let useVersioning = (validFrom instanceof Date && moment(validFrom)
|
|
87
69
|
.isSameOrBefore(params.orderDate))
|
|
70
|
+
// versioningForceProjectsであれば強制的にversioning(2026-02-05~)
|
|
88
71
|
|| versioningForceProjects.includes(projectPrefix);
|
|
72
|
+
// versioningExceptionProjectsであれば強制的にversioning不使用(2026-02-10~)
|
|
73
|
+
if (versioningExceptionProjects.includes(projectPrefix)) {
|
|
74
|
+
useVersioning = false;
|
|
75
|
+
}
|
|
89
76
|
if (typeof fpeSecret === 'string' && typeof version === 'string' && useVersioning) {
|
|
90
77
|
const transactionFactory = new transactionNumber_1.TransactionNumberFactory({ fpeSecret, version });
|
|
91
78
|
orderNumber = transactionFactory.generate(timestamp, incrReply);
|
|
92
|
-
orderNumber = `${projectPrefix.at(0)}${orderNumber}`;
|
|
79
|
+
orderNumber = `${projectPrefix.at(0)}${orderNumber}`; // 桁数をversion0に合わせるためにエイリアスの1文字目のみを採用
|
|
93
80
|
orderNumber = `${[
|
|
94
81
|
// tslint:disable-next-line:no-magic-numbers
|
|
95
82
|
orderNumber.slice(0, 4),
|
|
@@ -102,12 +89,6 @@ class OrderNumberRepo {
|
|
|
102
89
|
else {
|
|
103
90
|
orderNumber = OrderNumberRepo.GENERATE_VERSION0(timestamp, incrReply);
|
|
104
91
|
orderNumber = `${projectPrefix}${orderNumber}`;
|
|
105
|
-
// orderNumber = `${timestamp}${incrReply}`;
|
|
106
|
-
// // checkdigit
|
|
107
|
-
// const cd = cdigit.luhn.compute(orderNumber);
|
|
108
|
-
// orderNumber = fpe({ password: cd })
|
|
109
|
-
// .encrypt(orderNumber);
|
|
110
|
-
// orderNumber = `${projectPrefix}${cd}${orderNumber}`;
|
|
111
92
|
orderNumber = `${[
|
|
112
93
|
// tslint:disable-next-line:no-magic-numbers
|
|
113
94
|
orderNumber.slice(0, 4),
|
|
@@ -135,6 +116,9 @@ class OrderNumberRepo {
|
|
|
135
116
|
}
|
|
136
117
|
});
|
|
137
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* 注文番号生成設定を検索する
|
|
121
|
+
*/
|
|
138
122
|
findSetting() {
|
|
139
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
124
|
const filterQuery = { 'project.id': { $eq: '*' } };
|
|
@@ -146,9 +130,12 @@ class OrderNumberRepo {
|
|
|
146
130
|
.lean()
|
|
147
131
|
.exec();
|
|
148
132
|
if (setting === null || setting.orderNumber === undefined) {
|
|
149
|
-
return {
|
|
133
|
+
return {
|
|
134
|
+
versioningForceProjects: [],
|
|
135
|
+
versioningExceptionProjects: []
|
|
136
|
+
};
|
|
150
137
|
}
|
|
151
|
-
const { fpeSecret, version, validFrom, versioningForceProjects } = setting.orderNumber;
|
|
138
|
+
const { fpeSecret, version, validFrom, versioningForceProjects, versioningExceptionProjects } = setting.orderNumber;
|
|
152
139
|
if (typeof fpeSecret !== 'string' || fpeSecret === '') {
|
|
153
140
|
throw new factory.errors.NotFound('setting.orderNumber.secret');
|
|
154
141
|
}
|
|
@@ -163,7 +150,8 @@ class OrderNumberRepo {
|
|
|
163
150
|
versioningForceProjects: [
|
|
164
151
|
...(Array.isArray(versioningForceProjects)) ? versioningForceProjects : [],
|
|
165
152
|
...defaultVersioningForceProjects
|
|
166
|
-
]
|
|
153
|
+
],
|
|
154
|
+
versioningExceptionProjects: (Array.isArray(versioningExceptionProjects)) ? versioningExceptionProjects : []
|
|
167
155
|
};
|
|
168
156
|
});
|
|
169
157
|
}
|
|
@@ -10,10 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TransactionNumberRepo = void 0;
|
|
13
|
-
const cdigit = require("cdigit");
|
|
14
13
|
const moment = require("moment-timezone");
|
|
15
|
-
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
|
-
const fpe1 = require('node-fpe-v1');
|
|
17
14
|
const factory = require("../factory");
|
|
18
15
|
const transactionNumber_1 = require("../factory/transactionNumber");
|
|
19
16
|
const setting_1 = require("./mongoose/schemas/setting");
|
|
@@ -39,7 +36,6 @@ class TransactionNumberRepo {
|
|
|
39
36
|
let dataFeedExpires;
|
|
40
37
|
const dataFeedIdentifier = timestamp;
|
|
41
38
|
let incrReply;
|
|
42
|
-
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
43
39
|
dataFeedExpires = moment(params.startDate)
|
|
44
40
|
.add(1, 'minute') // ミリ秒でカウントしていくので、予約日時後1分で十分
|
|
45
41
|
.toDate();
|
|
@@ -56,12 +52,14 @@ class TransactionNumberRepo {
|
|
|
56
52
|
transactionNumber = transactionFactory.generate(timestamp, incrReply);
|
|
57
53
|
}
|
|
58
54
|
else {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
transactionNumber =
|
|
55
|
+
// discontinue version0(2026-02-10~)
|
|
56
|
+
throw new factory.errors.NotImplemented('transactionNumber with no version discontinued');
|
|
57
|
+
// transactionNumber = `${timestamp}${incrReply}`;
|
|
58
|
+
// // checkdigit
|
|
59
|
+
// const cd = cdigit.luhn.compute(transactionNumber);
|
|
60
|
+
// transactionNumber = fpe1({ password: cd })
|
|
61
|
+
// .encrypt(transactionNumber);
|
|
62
|
+
// transactionNumber = `${cd}${transactionNumber}`;
|
|
65
63
|
}
|
|
66
64
|
return { transactionNumber, timestamp, incrReply };
|
|
67
65
|
});
|
|
@@ -188,10 +188,9 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
188
188
|
? { version: params.filmFromCOA.titleBranchNum } // add version(2024-01-31~)
|
|
189
189
|
: undefined);
|
|
190
190
|
// redefine videoFormat(2024-09-18~)
|
|
191
|
-
// const videoFormat: factory.
|
|
192
|
-
// params.
|
|
193
|
-
|
|
194
|
-
.map(({ kubunCode }) => ({ typeOf: kubunCode, name: kubunCode }));
|
|
191
|
+
// const videoFormat: factory.eventSeries.IVideoFormat[] =
|
|
192
|
+
// params.joueihousikiKubuns.filter(({ kubunCode }) => kubunCode === params.filmFromCOA.kbnJoueihousiki)
|
|
193
|
+
// .map(({ kubunCode }) => ({ typeOf: kubunCode, name: kubunCode }));
|
|
195
194
|
return {
|
|
196
195
|
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
197
196
|
typeOf: factory.eventType.ScreeningEventSeries,
|
|
@@ -214,7 +213,7 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
214
213
|
},
|
|
215
214
|
// 必須化(2023-07-12~)
|
|
216
215
|
organizer: { id: params.seller.id },
|
|
217
|
-
videoFormat,
|
|
216
|
+
// videoFormat, // discontinue(2026-02-10~)
|
|
218
217
|
soundFormat: [],
|
|
219
218
|
workPerformed,
|
|
220
219
|
duration: moment.duration(params.filmFromCOA.showTime, 'm')
|
|
@@ -8,7 +8,7 @@ type IMovieTheater = Pick<factory.place.movieTheater.IPlace, 'id' | 'typeOf' | '
|
|
|
8
8
|
declare function saveScreeningEvents(params: {
|
|
9
9
|
movieTheater: IMovieTheater;
|
|
10
10
|
screeningRooms: Pick<factory.place.screeningRoom.IPlace, 'branchCode' | 'name' | 'maximumAttendeeCapacity'>[];
|
|
11
|
-
screeningEventSerieses?: factory.eventSeries.IEvent[];
|
|
11
|
+
screeningEventSerieses?: Omit<factory.eventSeries.IEvent, 'videoFormat'>[];
|
|
12
12
|
project: {
|
|
13
13
|
id: string;
|
|
14
14
|
typeOf: factory.organizationType.Project;
|
|
@@ -16,7 +16,6 @@ const createDebug = require("debug");
|
|
|
16
16
|
const moment = require("moment-timezone");
|
|
17
17
|
const factory = require("../../factory");
|
|
18
18
|
const saveScreeningEventSeries_1 = require("./saveScreeningEventSeries");
|
|
19
|
-
const USE_DEPRECATED_VIDEO_FORMAT_EVENTS = process.env.USE_DEPRECATED_VIDEO_FORMAT_EVENTS === '1';
|
|
20
19
|
const debug = createDebug('chevre-domain:service:event');
|
|
21
20
|
function saveScreeningEvents(params, options) {
|
|
22
21
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -102,7 +101,9 @@ function createScreeningEvents(params, options) {
|
|
|
102
101
|
}, [
|
|
103
102
|
'project', 'typeOf', 'eventStatus', 'identifier',
|
|
104
103
|
'name', 'kanaName', 'alternativeHeadline', 'location',
|
|
105
|
-
'organizer',
|
|
104
|
+
'organizer',
|
|
105
|
+
// 'videoFormat', // 参照廃止(2026-02-10~)
|
|
106
|
+
'soundFormat', 'workPerformed',
|
|
106
107
|
'duration', 'endDate', 'startDate', 'coaInfo',
|
|
107
108
|
'offers', 'additionalProperty'
|
|
108
109
|
]);
|
|
@@ -171,16 +172,23 @@ function createScreeningEvents(params, options) {
|
|
|
171
172
|
});
|
|
172
173
|
}
|
|
173
174
|
function minimizeSuperEvent(params) {
|
|
174
|
-
const { workPerformed,
|
|
175
|
-
|
|
175
|
+
const { workPerformed,
|
|
176
|
+
// videoFormat,
|
|
177
|
+
startDate, soundFormat, name, location, kanaName, identifier, endDate, duration, coaInfo, alternativeHeadline, typeOf, id } = params.superEvent;
|
|
178
|
+
return {
|
|
179
|
+
workPerformed, startDate, soundFormat,
|
|
176
180
|
name, location, kanaName, identifier,
|
|
177
181
|
endDate, duration, coaInfo, alternativeHeadline,
|
|
178
|
-
typeOf, id
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
typeOf, id
|
|
183
|
+
// 完全に廃止(2026-02-10~)
|
|
184
|
+
// // videoFormatをデータとしても廃止(万が一に備えてUSE_DEPRECATED_VIDEO_FORMAT_EVENTSで再設定可能)(2026-02-03~)
|
|
185
|
+
// ...(USE_DEPRECATED_VIDEO_FORMAT_EVENTS)
|
|
186
|
+
// ? {
|
|
187
|
+
// // 現時点で型廃止済だがデータとしては互換性維持(2026-01-15~)
|
|
188
|
+
// videoFormat
|
|
189
|
+
// }
|
|
190
|
+
// : undefined
|
|
191
|
+
};
|
|
184
192
|
}
|
|
185
193
|
/**
|
|
186
194
|
* コアデータからイベントを作成する
|
|
@@ -81,7 +81,9 @@ function syncEventSeries2screeningEvents(params) {
|
|
|
81
81
|
}, [
|
|
82
82
|
'additionalProperty', 'alternativeHeadline', 'description', 'dubLanguage',
|
|
83
83
|
'endDate', 'headline', 'kanaName', 'location', 'name',
|
|
84
|
-
'soundFormat', 'startDate', 'subtitleLanguage', 'typeOf',
|
|
84
|
+
'soundFormat', 'startDate', 'subtitleLanguage', 'typeOf',
|
|
85
|
+
// 'videoFormat', // 参照廃止(2026-02-10~)
|
|
86
|
+
'workPerformed'
|
|
85
87
|
]);
|
|
86
88
|
const superEventFromDB = superEvents.shift();
|
|
87
89
|
if (superEventFromDB === undefined) {
|
|
@@ -5,7 +5,7 @@ declare function tour2creatingEvent(tour: ITourBySchedule, movieTheater: Pick<fa
|
|
|
5
5
|
member: ICustomerMember;
|
|
6
6
|
}[], maxValue: number, eventService: Pick<factory.product.IProduct, 'id' | 'name'> & {
|
|
7
7
|
id: string;
|
|
8
|
-
}, screeningEventSeries: Pick<factory.eventSeries.IEvent, 'location' | 'additionalProperty' | 'description' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'name' | 'soundFormat' | 'startDate' | 'typeOf' | '
|
|
8
|
+
}, screeningEventSeries: Pick<factory.eventSeries.IEvent, 'location' | 'additionalProperty' | 'description' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'name' | 'soundFormat' | 'startDate' | 'typeOf' | 'workPerformed'>, project: {
|
|
9
9
|
id: string;
|
|
10
10
|
}): ICreatingEvent4ttts;
|
|
11
11
|
interface ITourBySchedule {
|
|
@@ -46,7 +46,9 @@ function schedule2relatedResources(schedule) {
|
|
|
46
46
|
id: { $eq: eventSeriesId }
|
|
47
47
|
}, [
|
|
48
48
|
'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
|
|
49
|
-
'soundFormat', 'startDate', 'typeOf',
|
|
49
|
+
'soundFormat', 'startDate', 'typeOf',
|
|
50
|
+
// 'videoFormat', // 参照廃止(2026-02-10~)
|
|
51
|
+
'workPerformed'
|
|
50
52
|
])).shift();
|
|
51
53
|
if (screeningEventSeries === undefined) {
|
|
52
54
|
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
@@ -236,7 +236,9 @@ function syncEvents(params) {
|
|
|
236
236
|
}, [
|
|
237
237
|
'project', 'typeOf', 'eventStatus', 'identifier',
|
|
238
238
|
'name', 'kanaName', 'alternativeHeadline', 'location',
|
|
239
|
-
'organizer',
|
|
239
|
+
'organizer',
|
|
240
|
+
// 'videoFormat', // 参照廃止(2026-02-10~)
|
|
241
|
+
'soundFormat', 'workPerformed',
|
|
240
242
|
'duration', 'endDate', 'startDate', 'coaInfo',
|
|
241
243
|
'offers', 'additionalProperty'
|
|
242
244
|
])).shift();
|
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.4.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "13.0.0
|
|
14
|
+
"@chevre/factory": "5.4.0-alpha.29",
|
|
15
|
+
"@cinerino/sdk": "13.0.0",
|
|
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",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"postversion": "git push origin --tags",
|
|
119
119
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
120
120
|
},
|
|
121
|
-
"version": "23.2.0-alpha.
|
|
121
|
+
"version": "23.2.0-alpha.59"
|
|
122
122
|
}
|
|
@@ -1,75 +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
|
-
// tslint:disable-next-line:max-func-body-length
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const cursor = eventSeriesRepo.getCursor(
|
|
14
|
-
{
|
|
15
|
-
// _id: { $eq: 'bmd7x21f2' },
|
|
16
|
-
// 'project.id': { $eq: 'xxx' },
|
|
17
|
-
'offers.typeOf': {
|
|
18
|
-
$exists: true,
|
|
19
|
-
$eq: chevre.factory.offerType.AggregateOffer
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
// _id: 1,
|
|
24
|
-
// offers: 1,
|
|
25
|
-
// startDate: 1,
|
|
26
|
-
// project: 1,
|
|
27
|
-
// typeOf: 1
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
console.log('docs found');
|
|
31
|
-
|
|
32
|
-
let i = 0;
|
|
33
|
-
let updateCount = 0;
|
|
34
|
-
await cursor.eachAsync(async (doc) => {
|
|
35
|
-
i += 1;
|
|
36
|
-
const eventSeries: Pick<
|
|
37
|
-
chevre.factory.eventSeries.IEvent,
|
|
38
|
-
'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
|
|
39
|
-
> = doc.toObject();
|
|
40
|
-
|
|
41
|
-
console.log(
|
|
42
|
-
'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
43
|
-
const alreadyMigrated = eventSeries.offers?.typeOf === chevre.factory.offerType.Offer;
|
|
44
|
-
|
|
45
|
-
if (alreadyMigrated) {
|
|
46
|
-
console.log(
|
|
47
|
-
'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
48
|
-
} else {
|
|
49
|
-
console.log(
|
|
50
|
-
'updating...',
|
|
51
|
-
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
52
|
-
await eventSeriesRepo.saveEventSeries({
|
|
53
|
-
id: eventSeries.id,
|
|
54
|
-
attributes: <any>{
|
|
55
|
-
...{
|
|
56
|
-
typeOf: eventSeries.typeOf,
|
|
57
|
-
'offers.typeOf': chevre.factory.offerType.Offer
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
updateCount += 1;
|
|
62
|
-
console.log(
|
|
63
|
-
'updated.',
|
|
64
|
-
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
console.log(i, 'docs checked');
|
|
70
|
-
console.log(updateCount, 'docs updated');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
main()
|
|
74
|
-
.then()
|
|
75
|
-
.catch(console.error);
|
|
@@ -1,93 +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 DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET = 'MovieTicket';
|
|
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 eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = eventSeriesRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
'project.id': { $eq: 'xxx' },
|
|
19
|
-
'offers.unacceptedPaymentMethod': {
|
|
20
|
-
$exists: true,
|
|
21
|
-
$ne: DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
22
|
-
},
|
|
23
|
-
startDate: {
|
|
24
|
-
$lte: moment()
|
|
25
|
-
.add(-1, 'year')
|
|
26
|
-
.toDate()
|
|
27
|
-
}
|
|
28
|
-
// _id: { $eq: 'bliy11ffa' }
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
// _id: 1,
|
|
32
|
-
// offers: 1,
|
|
33
|
-
// startDate: 1,
|
|
34
|
-
// project: 1,
|
|
35
|
-
// typeOf: 1
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
console.log('docs found');
|
|
39
|
-
|
|
40
|
-
let i = 0;
|
|
41
|
-
let updateCount = 0;
|
|
42
|
-
await cursor.eachAsync(async (doc) => {
|
|
43
|
-
i += 1;
|
|
44
|
-
const eventSeries: Pick<
|
|
45
|
-
chevre.factory.eventSeries.IEvent,
|
|
46
|
-
'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
|
|
47
|
-
> = doc.toObject();
|
|
48
|
-
|
|
49
|
-
console.log(
|
|
50
|
-
'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
51
|
-
const unacceptedPaymentMethod = eventSeries.offers?.unacceptedPaymentMethod;
|
|
52
|
-
const alreadyMigrated = !Array.isArray(unacceptedPaymentMethod)
|
|
53
|
-
|| (Array.isArray(unacceptedPaymentMethod)
|
|
54
|
-
&& unacceptedPaymentMethod.every(
|
|
55
|
-
(paymentMethodType) => paymentMethodType === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
56
|
-
));
|
|
57
|
-
|
|
58
|
-
if (alreadyMigrated) {
|
|
59
|
-
console.log(
|
|
60
|
-
'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
61
|
-
} else {
|
|
62
|
-
if (Array.isArray(unacceptedPaymentMethod)) {
|
|
63
|
-
const newUnacceptedPaymentMethod = unacceptedPaymentMethod.filter(
|
|
64
|
-
(paymentMethod) => paymentMethod === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
65
|
-
);
|
|
66
|
-
console.log(
|
|
67
|
-
'updating project...',
|
|
68
|
-
newUnacceptedPaymentMethod,
|
|
69
|
-
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
70
|
-
await eventSeriesRepo.saveEventSeries({
|
|
71
|
-
id: eventSeries.id,
|
|
72
|
-
attributes: <any>{
|
|
73
|
-
...{
|
|
74
|
-
typeOf: eventSeries.typeOf,
|
|
75
|
-
'offers.unacceptedPaymentMethod': newUnacceptedPaymentMethod
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
updateCount += 1;
|
|
80
|
-
console.log(
|
|
81
|
-
'updated.',
|
|
82
|
-
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
console.log(i, 'docs checked');
|
|
88
|
-
console.log(updateCount, 'docs updated');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
main()
|
|
92
|
-
.then()
|
|
93
|
-
.catch(console.error);
|
|
@@ -1,80 +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
|
-
// tslint:disable-next-line:max-func-body-length
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const cursor = eventSeriesRepo.getCursor(
|
|
14
|
-
{
|
|
15
|
-
// _id: { $eq: 'al9s38bj6' },
|
|
16
|
-
'project.id': { $nin: ['sskts-development', 'sskts-test', 'sskts-production'] }
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
// _id: 1,
|
|
20
|
-
// offers: 1,
|
|
21
|
-
// startDate: 1,
|
|
22
|
-
// project: 1,
|
|
23
|
-
// typeOf: 1
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
console.log('docs found');
|
|
27
|
-
|
|
28
|
-
let i = 0;
|
|
29
|
-
let updateCount = 0;
|
|
30
|
-
await cursor.eachAsync(async (doc) => {
|
|
31
|
-
i += 1;
|
|
32
|
-
const eventSeries: Pick<
|
|
33
|
-
chevre.factory.eventSeries.IEvent,
|
|
34
|
-
'id' | 'videoFormat' | 'subEvent' | 'project' | 'startDate' | 'typeOf'
|
|
35
|
-
> = doc.toObject();
|
|
36
|
-
|
|
37
|
-
const videoFormatByOldAttribute: string[] =
|
|
38
|
-
(Array.isArray(eventSeries.videoFormat)) ? eventSeries.videoFormat.map(({ typeOf }) => typeOf) : [];
|
|
39
|
-
const videoFormatByNewAttribute: string[] =
|
|
40
|
-
(Array.isArray(eventSeries.subEvent?.videoFormat)) ? eventSeries.subEvent.videoFormat : [];
|
|
41
|
-
const alreadyMigrated = videoFormatByOldAttribute.length === videoFormatByNewAttribute.length
|
|
42
|
-
&& videoFormatByOldAttribute.every((codeValue) => videoFormatByNewAttribute.includes(codeValue))
|
|
43
|
-
&& eventSeries.subEvent?.typeOf === chevre.factory.eventType.ScreeningEvent;
|
|
44
|
-
|
|
45
|
-
if (alreadyMigrated) {
|
|
46
|
-
console.log(
|
|
47
|
-
'already migrated.', eventSeries.project.id, eventSeries.id, eventSeries.startDate, i);
|
|
48
|
-
} else {
|
|
49
|
-
const subEvent: chevre.factory.eventSeries.ISubEvent = {
|
|
50
|
-
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
51
|
-
...(videoFormatByOldAttribute.length > 0) ? { videoFormat: videoFormatByOldAttribute } : undefined
|
|
52
|
-
};
|
|
53
|
-
console.log(
|
|
54
|
-
'updating...',
|
|
55
|
-
eventSeries.project.id, eventSeries.id, eventSeries.startDate, i, videoFormatByOldAttribute, subEvent
|
|
56
|
-
);
|
|
57
|
-
await eventSeriesRepo.saveEventSeries({
|
|
58
|
-
id: eventSeries.id,
|
|
59
|
-
attributes: <any>{
|
|
60
|
-
...{
|
|
61
|
-
typeOf: eventSeries.typeOf,
|
|
62
|
-
subEvent
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
updateCount += 1;
|
|
67
|
-
console.log(
|
|
68
|
-
'updated.',
|
|
69
|
-
eventSeries.project.id, eventSeries.id, eventSeries.startDate, i);
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
console.log(i, 'docs checked');
|
|
75
|
-
console.log(updateCount, 'docs updated');
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
main()
|
|
79
|
-
.then()
|
|
80
|
-
.catch(console.error);
|