@chevre/domain 22.3.0-alpha.13 → 22.3.0-alpha.15
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/migrateEventSeries2secondary.ts +70 -0
- package/lib/chevre/repo/event.js +1 -1
- package/lib/chevre/repo/eventSeries.d.ts +55 -1
- package/lib/chevre/repo/eventSeries.js +5 -0
- package/lib/chevre/service/event.d.ts +3 -0
- package/lib/chevre/service/event.js +21 -2
- package/package.json +1 -1
- package/example/src/chevre/migrateMembers2.ts +0 -74
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = eventSeriesRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
_id: 1,
|
|
20
|
+
startDate: 1,
|
|
21
|
+
project: 1,
|
|
22
|
+
typeOf: 1
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
console.log('docs found');
|
|
26
|
+
|
|
27
|
+
let i = 0;
|
|
28
|
+
let updateCount = 0;
|
|
29
|
+
await cursor.eachAsync(async (doc) => {
|
|
30
|
+
i += 1;
|
|
31
|
+
const eventSeries: Pick<chevre.factory.event.screeningEventSeries.IEvent, 'id' | 'startDate' | 'project' | 'typeOf'> =
|
|
32
|
+
doc.toObject();
|
|
33
|
+
const alreadyMigrated = false;
|
|
34
|
+
if (alreadyMigrated) {
|
|
35
|
+
console.log(
|
|
36
|
+
'already exist.',
|
|
37
|
+
eventSeries.project.id,
|
|
38
|
+
eventSeries.typeOf,
|
|
39
|
+
eventSeries.id,
|
|
40
|
+
eventSeries.startDate, i, updateCount
|
|
41
|
+
);
|
|
42
|
+
} else {
|
|
43
|
+
updateCount += 1;
|
|
44
|
+
console.log(
|
|
45
|
+
'updating...',
|
|
46
|
+
eventSeries.project.id,
|
|
47
|
+
eventSeries.typeOf,
|
|
48
|
+
eventSeries.id,
|
|
49
|
+
eventSeries.startDate, i, updateCount
|
|
50
|
+
);
|
|
51
|
+
await eventSeriesRepo.sync2secondary({
|
|
52
|
+
id: eventSeries.id
|
|
53
|
+
});
|
|
54
|
+
console.log(
|
|
55
|
+
'updated.',
|
|
56
|
+
eventSeries.project.id,
|
|
57
|
+
eventSeries.typeOf,
|
|
58
|
+
eventSeries.id,
|
|
59
|
+
eventSeries.startDate, i, updateCount
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(i, 'docs checked');
|
|
65
|
+
console.log(updateCount, 'docs updated');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
main()
|
|
69
|
+
.then()
|
|
70
|
+
.catch(console.error);
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -777,7 +777,7 @@ class EventRepo {
|
|
|
777
777
|
findAnyEventById(params) {
|
|
778
778
|
var _a;
|
|
779
779
|
return __awaiter(this, void 0, void 0, function* () {
|
|
780
|
-
const doc = yield this.eventModel.findOne(Object.assign({ _id: { $eq: params.id.$eq }, 'project.id': { $eq: params.project.id.$eq } }, (typeof ((_a = params.organizer) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
|
|
780
|
+
const doc = yield this.eventModel.findOne(Object.assign({ _id: { $eq: params.id.$eq }, 'project.id': { $eq: params.project.id.$eq }, typeOf: { $in: [factory.eventType.Event, factory.eventType.ScreeningEvent] } }, (typeof ((_a = params.organizer) === null || _a === void 0 ? void 0 : _a.id.$eq) === 'string')
|
|
781
781
|
? { 'organizer.id': { $exists: true, $eq: params.organizer.id.$eq } }
|
|
782
782
|
: undefined), {
|
|
783
783
|
__v: 0,
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
1
25
|
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
-
import type { Connection, FilterQuery } from 'mongoose';
|
|
26
|
+
import type { Connection, Document, FilterQuery } from 'mongoose';
|
|
3
27
|
import * as factory from '../factory';
|
|
28
|
+
import { IDocType } from './mongoose/schemas/event';
|
|
4
29
|
type ISearchConditions = Omit<factory.event.ISearchConditions<factory.eventType.ScreeningEventSeries>, 'typeOfIn' | 'hasOfferCatalog'>;
|
|
5
30
|
type IKeyOfProjection = Exclude<keyof factory.event.IEvent<factory.eventType.ScreeningEventSeries>, 'id'>;
|
|
6
31
|
type IUnset = {
|
|
@@ -107,5 +132,34 @@ export declare class EventSeriesRepo {
|
|
|
107
132
|
sync2secondary(params: {
|
|
108
133
|
id: string;
|
|
109
134
|
}): Promise<void>;
|
|
135
|
+
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, IDocType> & Omit<(import("@chevre/factory/lib/event/anyEvent").IAttributes & {
|
|
136
|
+
_id: string;
|
|
137
|
+
} & Required<{
|
|
138
|
+
_id: string;
|
|
139
|
+
}>) | (import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
|
|
140
|
+
_id: string;
|
|
141
|
+
alternateName?: any;
|
|
142
|
+
aggregateOffer?: import("@chevre/factory/lib/event/anyEvent").IAggregateOffer | undefined;
|
|
143
|
+
} & Required<{
|
|
144
|
+
_id: string;
|
|
145
|
+
}>) | (import("@chevre/factory/lib/event/screeningEventSeries").IAttributes & {
|
|
146
|
+
_id: string;
|
|
147
|
+
} & Required<{
|
|
148
|
+
_id: string;
|
|
149
|
+
}>), never>, import("mongoose").QueryOptions<Document<unknown, {}, IDocType> & Omit<(import("@chevre/factory/lib/event/anyEvent").IAttributes & {
|
|
150
|
+
_id: string;
|
|
151
|
+
} & Required<{
|
|
152
|
+
_id: string;
|
|
153
|
+
}>) | (import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
|
|
154
|
+
_id: string;
|
|
155
|
+
alternateName?: any;
|
|
156
|
+
aggregateOffer?: import("@chevre/factory/lib/event/anyEvent").IAggregateOffer | undefined;
|
|
157
|
+
} & Required<{
|
|
158
|
+
_id: string;
|
|
159
|
+
}>) | (import("@chevre/factory/lib/event/screeningEventSeries").IAttributes & {
|
|
160
|
+
_id: string;
|
|
161
|
+
} & Required<{
|
|
162
|
+
_id: string;
|
|
163
|
+
}>), never>>>;
|
|
110
164
|
}
|
|
111
165
|
export {};
|
|
@@ -645,5 +645,10 @@ class EventSeriesRepo {
|
|
|
645
645
|
}
|
|
646
646
|
});
|
|
647
647
|
}
|
|
648
|
+
getCursor(conditions, projection) {
|
|
649
|
+
return this.eventModel.find(conditions, projection)
|
|
650
|
+
.sort({ startDate: factory.sortType.Descending })
|
|
651
|
+
.cursor();
|
|
652
|
+
}
|
|
648
653
|
}
|
|
649
654
|
exports.EventSeriesRepo = EventSeriesRepo;
|
|
@@ -50,6 +50,9 @@ export declare function importFromCOA(params: IImportFromCOAParams): (repos: {
|
|
|
50
50
|
seller: SellerRepo;
|
|
51
51
|
masterService: COA.service.Master;
|
|
52
52
|
}) => Promise<void>;
|
|
53
|
+
export declare function minimizeSuperEvent(params: {
|
|
54
|
+
superEvent: factory.event.screeningEventSeries.IEvent;
|
|
55
|
+
}): factory.event.screeningEvent.ISuperEvent;
|
|
53
56
|
/**
|
|
54
57
|
* COA情報からイベントIDを作成する
|
|
55
58
|
*/
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createEvent = exports.updateEvent4ttts = exports.createScreeningEventIdFromCOA = exports.importFromCOA = void 0;
|
|
12
|
+
exports.createEvent = exports.updateEvent4ttts = exports.createScreeningEventIdFromCOA = exports.minimizeSuperEvent = exports.importFromCOA = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
const difference = require("lodash.difference");
|
|
@@ -480,6 +480,24 @@ function cancelDeletedEvents(params) {
|
|
|
480
480
|
return cancelledIds;
|
|
481
481
|
});
|
|
482
482
|
}
|
|
483
|
+
function minimizeSuperEvent(params) {
|
|
484
|
+
const { workPerformed, videoFormat, startDate, soundFormat, name, location, kanaName, identifier, endDate, duration, coaInfo, alternativeHeadline,
|
|
485
|
+
// additionalProperty,
|
|
486
|
+
typeOf, id
|
|
487
|
+
// project,
|
|
488
|
+
// organizer,
|
|
489
|
+
// offers,
|
|
490
|
+
// eventStatus
|
|
491
|
+
} = params.superEvent;
|
|
492
|
+
return {
|
|
493
|
+
workPerformed, videoFormat, startDate, soundFormat,
|
|
494
|
+
name, location, kanaName, identifier,
|
|
495
|
+
endDate, duration, coaInfo, alternativeHeadline,
|
|
496
|
+
// additionalProperty,
|
|
497
|
+
typeOf, id
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
exports.minimizeSuperEvent = minimizeSuperEvent;
|
|
483
501
|
/**
|
|
484
502
|
* コアデータからイベントを作成する
|
|
485
503
|
*/
|
|
@@ -551,6 +569,7 @@ function createScreeningEventFromCOA(params) {
|
|
|
551
569
|
}
|
|
552
570
|
};
|
|
553
571
|
const { additionalProperty, coaInfo } = createScreeningEventAdditionalPropertyFromCOA(params);
|
|
572
|
+
const superEvent = minimizeSuperEvent({ superEvent: params.superEvent }); // optimize superEvent(2024-09-10~)
|
|
554
573
|
return {
|
|
555
574
|
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
556
575
|
typeOf: factory.eventType.ScreeningEvent,
|
|
@@ -565,7 +584,7 @@ function createScreeningEventFromCOA(params) {
|
|
|
565
584
|
},
|
|
566
585
|
endDate: endDate,
|
|
567
586
|
startDate: startDate,
|
|
568
|
-
superEvent
|
|
587
|
+
superEvent,
|
|
569
588
|
coaInfo,
|
|
570
589
|
offers: offers,
|
|
571
590
|
checkInCount: 0,
|
package/package.json
CHANGED
|
@@ -1,74 +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
|
-
const NEW_ROLE_NAME = 'sellerAdmin';
|
|
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 memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = memberRepo.getCursor(
|
|
17
|
-
{
|
|
18
|
-
'member.memberOf.typeOf': { $eq: chevre.factory.organizationType.Project },
|
|
19
|
-
'member.hasRole.roleName': { $eq: 'inventoryManager' }
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
}
|
|
23
|
-
);
|
|
24
|
-
console.log('members found');
|
|
25
|
-
|
|
26
|
-
let i = 0;
|
|
27
|
-
let updateCount = 0;
|
|
28
|
-
await cursor.eachAsync(async (doc) => {
|
|
29
|
-
i += 1;
|
|
30
|
-
const inventoryManager: chevre.factory.iam.IMember = doc.toObject();
|
|
31
|
-
const alreadyMigrated = inventoryManager.member.hasRole.some(({ roleName }) => roleName === NEW_ROLE_NAME);
|
|
32
|
-
if (alreadyMigrated) {
|
|
33
|
-
console.log(
|
|
34
|
-
'already exist.',
|
|
35
|
-
inventoryManager.project.id,
|
|
36
|
-
inventoryManager.member.memberOf.typeOf, inventoryManager.member.memberOf.id, i, updateCount
|
|
37
|
-
);
|
|
38
|
-
} else {
|
|
39
|
-
updateCount += 1;
|
|
40
|
-
const newHasRole: chevre.factory.iam.IMemberRole[] = [
|
|
41
|
-
...inventoryManager.member.hasRole.map(({ roleName }) => {
|
|
42
|
-
return { typeOf: chevre.factory.iam.RoleType.OrganizationRole, roleName };
|
|
43
|
-
}),
|
|
44
|
-
{ typeOf: chevre.factory.iam.RoleType.OrganizationRole, roleName: NEW_ROLE_NAME }
|
|
45
|
-
].sort((a, b) => (a.roleName > b.roleName) ? 1 : -1);
|
|
46
|
-
console.log(
|
|
47
|
-
'updating...',
|
|
48
|
-
inventoryManager.project.id,
|
|
49
|
-
inventoryManager.member.memberOf.typeOf, inventoryManager.member.memberOf.id, i, updateCount, newHasRole
|
|
50
|
-
);
|
|
51
|
-
await memberRepo.updateByMemberId({
|
|
52
|
-
project: { id: inventoryManager.project.id },
|
|
53
|
-
member: {
|
|
54
|
-
id: inventoryManager.member.id,
|
|
55
|
-
memberOf: inventoryManager.member.memberOf,
|
|
56
|
-
hasRole: newHasRole
|
|
57
|
-
},
|
|
58
|
-
$unset: {}
|
|
59
|
-
});
|
|
60
|
-
console.log(
|
|
61
|
-
'updated.',
|
|
62
|
-
inventoryManager.project.id,
|
|
63
|
-
inventoryManager.member.memberOf.typeOf, inventoryManager.member.memberOf.id, i, updateCount
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
console.log(i, 'members checked');
|
|
69
|
-
console.log(updateCount, 'members updated');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
main()
|
|
73
|
-
.then()
|
|
74
|
-
.catch(console.error);
|