@chevre/domain 22.3.0-alpha.12 → 22.3.0-alpha.14
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/example/src/chevre/syncEventSeries2secondary.ts +20 -0
- package/lib/chevre/repo/event.js +1 -1
- package/lib/chevre/repo/eventSeries.d.ts +59 -1
- package/lib/chevre/repo/eventSeries.js +53 -2
- package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +21 -0
- package/lib/chevre/repo/mongoose/schemas/eventSeries.js +228 -0
- package/lib/chevre/service/offer/onEventChanged.js +11 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +5 -1
- package/lib/chevre/settings.d.ts +8 -0
- package/lib/chevre/settings.js +9 -1
- 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);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
await eventSeriesRepo.sync2secondary({
|
|
12
|
+
id: '7k9ayl8hc'
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
main()
|
|
17
|
+
.then(() => {
|
|
18
|
+
console.log('success!');
|
|
19
|
+
})
|
|
20
|
+
.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 = {
|
|
@@ -11,6 +36,7 @@ type IUnset = {
|
|
|
11
36
|
*/
|
|
12
37
|
export declare class EventSeriesRepo {
|
|
13
38
|
private readonly eventModel;
|
|
39
|
+
private readonly secondaryEventModel;
|
|
14
40
|
constructor(connection: Connection);
|
|
15
41
|
static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.event.IEvent<factory.eventType.ScreeningEventSeries>>[];
|
|
16
42
|
/**
|
|
@@ -103,5 +129,37 @@ export declare class EventSeriesRepo {
|
|
|
103
129
|
}): Promise<{
|
|
104
130
|
maxVersion: string;
|
|
105
131
|
}>;
|
|
132
|
+
sync2secondary(params: {
|
|
133
|
+
id: string;
|
|
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>>>;
|
|
106
164
|
}
|
|
107
165
|
export {};
|
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.EventSeriesRepo = void 0;
|
|
24
24
|
const factory = require("../factory");
|
|
25
25
|
const event_1 = require("./mongoose/schemas/event");
|
|
26
|
+
const eventSeries_1 = require("./mongoose/schemas/eventSeries");
|
|
26
27
|
const errorHandler_1 = require("../errorHandler");
|
|
27
28
|
const settings_1 = require("../settings");
|
|
28
29
|
/**
|
|
@@ -30,7 +31,14 @@ const settings_1 = require("../settings");
|
|
|
30
31
|
*/
|
|
31
32
|
class EventSeriesRepo {
|
|
32
33
|
constructor(connection) {
|
|
33
|
-
|
|
34
|
+
if (settings_1.USE_EVENT_SERIES_NEW_SCHEMA) {
|
|
35
|
+
this.eventModel = connection.model(eventSeries_1.modelName, (0, eventSeries_1.createSchema)());
|
|
36
|
+
this.secondaryEventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
40
|
+
this.secondaryEventModel = connection.model(eventSeries_1.modelName, (0, eventSeries_1.createSchema)());
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
36
44
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
@@ -446,6 +454,10 @@ class EventSeriesRepo {
|
|
|
446
454
|
}
|
|
447
455
|
if (bulkWriteOps.length > 0) {
|
|
448
456
|
yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
457
|
+
// sync2secondary(2024-09-10~)
|
|
458
|
+
if (settings_1.USE_EVENT_SERIES_SYNC2SECONDARY) {
|
|
459
|
+
yield this.secondaryEventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
460
|
+
}
|
|
449
461
|
}
|
|
450
462
|
});
|
|
451
463
|
}
|
|
@@ -538,7 +550,7 @@ class EventSeriesRepo {
|
|
|
538
550
|
_id: { $eq: params.id },
|
|
539
551
|
'project.id': { $eq: params.project.id },
|
|
540
552
|
typeOf: { $eq: factory.eventType.ScreeningEventSeries }
|
|
541
|
-
})
|
|
553
|
+
}, { projection: { _id: 1 } })
|
|
542
554
|
.exec();
|
|
543
555
|
});
|
|
544
556
|
}
|
|
@@ -599,5 +611,44 @@ class EventSeriesRepo {
|
|
|
599
611
|
return { maxVersion };
|
|
600
612
|
});
|
|
601
613
|
}
|
|
614
|
+
sync2secondary(params) {
|
|
615
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
616
|
+
if (!settings_1.USE_EVENT_SERIES_SYNC2SECONDARY) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const doc = yield this.eventModel.findOne({
|
|
620
|
+
_id: { $eq: params.id },
|
|
621
|
+
typeOf: { $eq: factory.eventType.ScreeningEventSeries }
|
|
622
|
+
})
|
|
623
|
+
.lean()
|
|
624
|
+
.exec();
|
|
625
|
+
if (doc !== null) {
|
|
626
|
+
const { _id } = doc, replacement = __rest(doc, ["_id"]);
|
|
627
|
+
// console.log('replacing eventSeries', params.id, 'replacement:', replacement);
|
|
628
|
+
const replaceResult = yield this.secondaryEventModel.findOneAndReplace({
|
|
629
|
+
_id: { $eq: params.id },
|
|
630
|
+
typeOf: { $eq: factory.eventType.ScreeningEventSeries }
|
|
631
|
+
}, replacement, {
|
|
632
|
+
upsert: true,
|
|
633
|
+
rawResult: true
|
|
634
|
+
})
|
|
635
|
+
.exec();
|
|
636
|
+
// tslint:disable-next-line:no-console
|
|
637
|
+
console.log('eventSeries', params.id, 'replaced. result:', replaceResult);
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
yield this.secondaryEventModel.findOneAndDelete({
|
|
641
|
+
_id: { $eq: params.id },
|
|
642
|
+
typeOf: { $eq: factory.eventType.ScreeningEventSeries }
|
|
643
|
+
}, { projection: { _id: 1 } })
|
|
644
|
+
.exec();
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
getCursor(conditions, projection) {
|
|
649
|
+
return this.eventModel.find(conditions, projection)
|
|
650
|
+
.sort({ startDate: factory.sortType.Descending })
|
|
651
|
+
.cursor();
|
|
652
|
+
}
|
|
602
653
|
}
|
|
603
654
|
exports.EventSeriesRepo = EventSeriesRepo;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IDocTypeAsEvent = factory.event.IAttributes<factory.eventType.Event> & {
|
|
4
|
+
_id: string;
|
|
5
|
+
};
|
|
6
|
+
type IDocTypeAsScreeningEvent = factory.event.IAttributes<factory.eventType.ScreeningEvent> & {
|
|
7
|
+
_id: string;
|
|
8
|
+
alternateName?: any;
|
|
9
|
+
aggregateOffer?: factory.event.event.IAggregateOffer;
|
|
10
|
+
};
|
|
11
|
+
type IDocTypeAsEventSeries = factory.event.IAttributes<factory.eventType.ScreeningEventSeries> & {
|
|
12
|
+
_id: string;
|
|
13
|
+
};
|
|
14
|
+
export type IDocType = IDocTypeAsEvent | IDocTypeAsScreeningEvent | IDocTypeAsEventSeries;
|
|
15
|
+
type IModel = Model<IDocType>;
|
|
16
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
17
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
18
|
+
declare const modelName = "EventSeries";
|
|
19
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
20
|
+
declare function createSchema(): ISchema;
|
|
21
|
+
export { createSchema, IModel, indexes, modelName };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modelName = exports.indexes = exports.createSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const factory = require("../../../factory");
|
|
7
|
+
const settings_1 = require("../../../settings");
|
|
8
|
+
const modelName = 'EventSeries';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
project: {
|
|
12
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
organizer: {
|
|
16
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
_id: String,
|
|
20
|
+
typeOf: {
|
|
21
|
+
type: String,
|
|
22
|
+
required: true
|
|
23
|
+
},
|
|
24
|
+
identifier: String,
|
|
25
|
+
name: mongoose_1.SchemaTypes.Mixed,
|
|
26
|
+
additionalProperty: mongoose_1.SchemaTypes.Mixed,
|
|
27
|
+
alternativeHeadline: mongoose_1.SchemaTypes.Mixed,
|
|
28
|
+
description: mongoose_1.SchemaTypes.Mixed,
|
|
29
|
+
duration: String,
|
|
30
|
+
endDate: Date,
|
|
31
|
+
eventStatus: String,
|
|
32
|
+
headline: mongoose_1.SchemaTypes.Mixed,
|
|
33
|
+
location: mongoose_1.SchemaTypes.Mixed,
|
|
34
|
+
startDate: Date,
|
|
35
|
+
workPerformed: mongoose_1.SchemaTypes.Mixed,
|
|
36
|
+
videoFormat: mongoose_1.SchemaTypes.Mixed,
|
|
37
|
+
soundFormat: mongoose_1.SchemaTypes.Mixed,
|
|
38
|
+
subtitleLanguage: mongoose_1.SchemaTypes.Mixed,
|
|
39
|
+
dubLanguage: mongoose_1.SchemaTypes.Mixed,
|
|
40
|
+
kanaName: String,
|
|
41
|
+
offers: mongoose_1.SchemaTypes.Mixed,
|
|
42
|
+
coaInfo: mongoose_1.SchemaTypes.Mixed
|
|
43
|
+
// alternateName: SchemaTypes.Mixed,
|
|
44
|
+
// doorTime: SchemaTypes.Mixed,
|
|
45
|
+
// superEvent: SchemaTypes.Mixed,
|
|
46
|
+
// maximumAttendeeCapacity: SchemaTypes.Mixed,
|
|
47
|
+
// remainingAttendeeCapacity: SchemaTypes.Mixed,
|
|
48
|
+
// checkInCount: SchemaTypes.Mixed,
|
|
49
|
+
// attendeeCount: SchemaTypes.Mixed,
|
|
50
|
+
// aggregateReservation: SchemaTypes.Mixed,
|
|
51
|
+
// aggregateOffer: SchemaTypes.Mixed
|
|
52
|
+
};
|
|
53
|
+
const schemaOptions = {
|
|
54
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
55
|
+
autoCreate: false,
|
|
56
|
+
collection: 'eventSeries',
|
|
57
|
+
id: true,
|
|
58
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
59
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
60
|
+
strict: true,
|
|
61
|
+
strictQuery: false,
|
|
62
|
+
timestamps: false,
|
|
63
|
+
versionKey: false,
|
|
64
|
+
toJSON: {
|
|
65
|
+
getters: false,
|
|
66
|
+
virtuals: false,
|
|
67
|
+
minimize: false,
|
|
68
|
+
versionKey: false
|
|
69
|
+
},
|
|
70
|
+
toObject: {
|
|
71
|
+
getters: false,
|
|
72
|
+
virtuals: true,
|
|
73
|
+
minimize: false,
|
|
74
|
+
versionKey: false
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const indexes = [
|
|
78
|
+
[
|
|
79
|
+
{ startDate: 1 },
|
|
80
|
+
{ name: 'startDate' }
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
{ endDate: 1, startDate: 1 },
|
|
84
|
+
{ name: 'endDate' }
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
{ 'project.id': 1, startDate: 1 },
|
|
88
|
+
{ name: 'projectId' }
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
{ 'organizer.id': 1, startDate: 1 },
|
|
92
|
+
{ name: 'organizerId' }
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
{ typeOf: 1, startDate: 1 },
|
|
96
|
+
{ name: 'typeOf' }
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
{ eventStatus: 1, startDate: 1 },
|
|
100
|
+
{ name: 'eventStatus' }
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
{ 'location.id': 1, startDate: 1 },
|
|
104
|
+
{
|
|
105
|
+
name: 'locationId',
|
|
106
|
+
partialFilterExpression: {
|
|
107
|
+
'location.id': { $exists: true }
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
{ 'location.branchCode': 1, startDate: 1 },
|
|
113
|
+
{
|
|
114
|
+
name: 'locationBranchCode',
|
|
115
|
+
partialFilterExpression: {
|
|
116
|
+
'location.branchCode': { $exists: true }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
{ 'workPerformed.identifier': 1, startDate: 1 },
|
|
122
|
+
{
|
|
123
|
+
name: 'workPerformedIdentifier',
|
|
124
|
+
partialFilterExpression: {
|
|
125
|
+
'workPerformed.identifier': { $exists: true }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
{ 'workPerformed.version': 1, startDate: 1 },
|
|
131
|
+
{
|
|
132
|
+
name: 'workPerformedVersion',
|
|
133
|
+
partialFilterExpression: {
|
|
134
|
+
'workPerformed.version': { $exists: true }
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
// コンテンツ+バージョンに対するuniqueness
|
|
140
|
+
{
|
|
141
|
+
'project.id': 1,
|
|
142
|
+
'location.branchCode': 1,
|
|
143
|
+
'workPerformed.identifier': 1,
|
|
144
|
+
'workPerformed.version': 1
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
unique: true,
|
|
148
|
+
name: 'uniqueEventSeries',
|
|
149
|
+
partialFilterExpression: {
|
|
150
|
+
typeOf: factory.eventType.ScreeningEventSeries,
|
|
151
|
+
'location.branchCode': { $exists: true },
|
|
152
|
+
'workPerformed.identifier': { $exists: true },
|
|
153
|
+
'workPerformed.version': { $exists: true }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
{ 'videoFormat.typeOf': 1, startDate: 1 },
|
|
159
|
+
{
|
|
160
|
+
name: 'videoFormatTypeOf',
|
|
161
|
+
partialFilterExpression: {
|
|
162
|
+
'videoFormat.typeOf': { $exists: true }
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
{ 'soundFormat.typeOf': 1, startDate: 1 },
|
|
168
|
+
{
|
|
169
|
+
name: 'soundFormatTypeOf',
|
|
170
|
+
partialFilterExpression: {
|
|
171
|
+
'soundFormat.typeOf': { $exists: true }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
{ 'name.ja': 1, startDate: 1 },
|
|
177
|
+
{
|
|
178
|
+
name: 'nameJa',
|
|
179
|
+
partialFilterExpression: {
|
|
180
|
+
'name.ja': { $exists: true }
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
],
|
|
184
|
+
[
|
|
185
|
+
{ 'name.en': 1, startDate: 1 },
|
|
186
|
+
{
|
|
187
|
+
name: 'nameEn',
|
|
188
|
+
partialFilterExpression: {
|
|
189
|
+
'name.en': { $exists: true }
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
{ kanaName: 1, startDate: 1 },
|
|
195
|
+
{
|
|
196
|
+
name: 'kanaName',
|
|
197
|
+
partialFilterExpression: {
|
|
198
|
+
kanaName: { $exists: true }
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
{ additionalProperty: 1, startDate: 1 },
|
|
204
|
+
{
|
|
205
|
+
name: 'additionalProperty',
|
|
206
|
+
partialFilterExpression: {
|
|
207
|
+
additionalProperty: { $exists: true }
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
];
|
|
212
|
+
exports.indexes = indexes;
|
|
213
|
+
/**
|
|
214
|
+
* 施設コンテンツスキーマ
|
|
215
|
+
*/
|
|
216
|
+
let schema;
|
|
217
|
+
function createSchema() {
|
|
218
|
+
if (schema === undefined) {
|
|
219
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
220
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
221
|
+
indexes.forEach((indexParams) => {
|
|
222
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return schema;
|
|
227
|
+
}
|
|
228
|
+
exports.createSchema = createSchema;
|
|
@@ -50,10 +50,21 @@ function onEventChanged(params) {
|
|
|
50
50
|
// no op
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
+
// 施設コンテンツsecondaryコレクションへ同期(2024-09-10~)
|
|
54
|
+
yield syncEventSeries2secondary({
|
|
55
|
+
ids: params.id
|
|
56
|
+
})(repos);
|
|
53
57
|
}
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
60
|
exports.onEventChanged = onEventChanged;
|
|
61
|
+
function syncEventSeries2secondary(params) {
|
|
62
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
for (const eventSeriesId of params.ids) {
|
|
64
|
+
yield repos.eventSeries.sync2secondary({ id: eventSeriesId });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
57
68
|
function syncEventSeries2screeningEvents(params) {
|
|
58
69
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
59
70
|
const now = new Date();
|
|
@@ -14,8 +14,8 @@ const factory = require("../../../factory");
|
|
|
14
14
|
const onHasPOSUpdated_1 = require("./onHasPOSUpdated");
|
|
15
15
|
const syncCategoryCode_1 = require("./syncCategoryCode");
|
|
16
16
|
const syncOfferCatalog_1 = require("./syncOfferCatalog");
|
|
17
|
-
// tslint:disable-next-line:max-func-body-length
|
|
18
17
|
function onResourceDeleted(params) {
|
|
18
|
+
// tslint:disable-next-line:max-func-body-length
|
|
19
19
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const isDeleted = params.isDeleted === true;
|
|
21
21
|
if (isDeleted) {
|
|
@@ -40,6 +40,10 @@ function onResourceDeleted(params) {
|
|
|
40
40
|
project: { id: params.project.id },
|
|
41
41
|
ids: params.id
|
|
42
42
|
})(repos);
|
|
43
|
+
// 施設コンテンツsecondaryコレクションへ同期(2024-09-10~)
|
|
44
|
+
for (const eventSeriesId of params.id) {
|
|
45
|
+
yield repos.eventSeries.sync2secondary({ id: eventSeriesId });
|
|
46
|
+
}
|
|
43
47
|
break;
|
|
44
48
|
case factory.placeType.ScreeningRoom:
|
|
45
49
|
yield deleteResourcesByScreeningRoom({
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import * as factory from './factory';
|
|
|
2
2
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
3
3
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
4
4
|
export declare const MONGO_AUTO_INDEX: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* 施設コンテンツのprimaryコレクションとして新スキーマを使用するかどうか
|
|
7
|
+
*/
|
|
8
|
+
export declare const USE_EVENT_SERIES_NEW_SCHEMA: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 施設コンテンツのsecondaryコレクションへ同期するかどうか
|
|
11
|
+
*/
|
|
12
|
+
export declare const USE_EVENT_SERIES_SYNC2SECONDARY: boolean;
|
|
5
13
|
interface IOptions {
|
|
6
14
|
onOrderStatusChanged: factory.project.IOnOrderStatusChanged;
|
|
7
15
|
onEventChanged: {
|
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.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
|
|
3
|
+
exports.Settings = exports.USE_EVENT_SERIES_SYNC2SECONDARY = exports.USE_EVENT_SERIES_NEW_SCHEMA = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
|
|
4
4
|
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
5
5
|
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
6
6
|
// tslint:disable-next-line:no-magic-numbers
|
|
@@ -9,6 +9,14 @@ exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 's
|
|
|
9
9
|
? process.env.MONGO_READ_PREFERENCE
|
|
10
10
|
: 'primaryPreferred';
|
|
11
11
|
exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
|
|
12
|
+
/**
|
|
13
|
+
* 施設コンテンツのprimaryコレクションとして新スキーマを使用するかどうか
|
|
14
|
+
*/
|
|
15
|
+
exports.USE_EVENT_SERIES_NEW_SCHEMA = process.env.USE_EVENT_SERIES_NEW_SCHEMA === '1';
|
|
16
|
+
/**
|
|
17
|
+
* 施設コンテンツのsecondaryコレクションへ同期するかどうか
|
|
18
|
+
*/
|
|
19
|
+
exports.USE_EVENT_SERIES_SYNC2SECONDARY = process.env.USE_EVENT_SERIES_SYNC2SECONDARY === '1';
|
|
12
20
|
/**
|
|
13
21
|
* domain settings
|
|
14
22
|
*/
|
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);
|