@chevre/domain 21.4.0-alpha.18 → 21.4.0-alpha.19
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/migrateReservationProvider.ts +15 -5
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/event/createEvent.d.ts +9 -0
- package/lib/chevre/service/event/createEvent.js +86 -0
- package/lib/chevre/service/event.d.ts +2 -0
- package/lib/chevre/service/event.js +3 -1
- package/lib/chevre/service/task/createEvent.d.ts +7 -0
- package/lib/chevre/service/task/createEvent.js +29 -0
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
|
|
|
9
9
|
|
|
10
10
|
// tslint:disable-next-line:max-func-body-length
|
|
11
11
|
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
14
|
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
15
15
|
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
@@ -20,12 +20,12 @@ async function main() {
|
|
|
20
20
|
$in: [
|
|
21
21
|
chevre.factory.reservationType.EventReservation
|
|
22
22
|
]
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
24
|
// bookingTime: {
|
|
25
25
|
// $gte: moment('2023-06-09T00:00:00Z')
|
|
26
26
|
// .toDate()
|
|
27
27
|
// }
|
|
28
|
-
|
|
28
|
+
'provider.id': { $exists: false }
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
_id: 1,
|
|
@@ -78,14 +78,24 @@ async function main() {
|
|
|
78
78
|
i
|
|
79
79
|
);
|
|
80
80
|
if (typeof sellerId !== 'string') {
|
|
81
|
+
console.error(
|
|
82
|
+
'movieTheater not found',
|
|
83
|
+
reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
|
|
84
|
+
'movieTheaterId:', movieTheaterId,
|
|
85
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
86
|
+
i
|
|
87
|
+
);
|
|
81
88
|
throw new Error('movieTheater not found');
|
|
89
|
+
|
|
90
|
+
// return;
|
|
82
91
|
}
|
|
83
92
|
if (typeof sellerId === 'string') {
|
|
84
93
|
const newProvider: chevre.factory.reservation.IProvider = {
|
|
85
94
|
id: sellerId,
|
|
86
95
|
typeOf: chevre.factory.organizationType.Corporation
|
|
87
96
|
};
|
|
88
|
-
console.log(
|
|
97
|
+
console.log(
|
|
98
|
+
'updating reservation...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
|
|
89
99
|
await reservationRepo.updatePartiallyById({
|
|
90
100
|
id: reservation.id,
|
|
91
101
|
update: <any>{
|
|
@@ -93,7 +103,7 @@ async function main() {
|
|
|
93
103
|
}
|
|
94
104
|
});
|
|
95
105
|
updateCount += 1;
|
|
96
|
-
console.log('updated.', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
|
|
106
|
+
console.log('updated.', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
});
|
|
@@ -63,7 +63,7 @@ export declare class MongoRepository {
|
|
|
63
63
|
*/
|
|
64
64
|
$nin?: factory.taskName[];
|
|
65
65
|
};
|
|
66
|
-
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
66
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
67
67
|
retry(params: {
|
|
68
68
|
intervalInMinutes: number;
|
|
69
69
|
}): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { MongoRepository as ActionRepo } from '../../repo/action';
|
|
3
|
+
import { MongoRepository as EventRepo } from '../../repo/event';
|
|
4
|
+
import { MongoRepository as TaskRepo } from '../../repo/task';
|
|
5
|
+
export declare function createEvent(params: factory.task.createEvent.IData): (repos: {
|
|
6
|
+
action: ActionRepo;
|
|
7
|
+
event: EventRepo;
|
|
8
|
+
task: TaskRepo;
|
|
9
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createEvent = void 0;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
// tslint:disable-next-line:max-func-body-length
|
|
15
|
+
function createEvent(params) {
|
|
16
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a;
|
|
18
|
+
const actionAttributes = params;
|
|
19
|
+
const action = yield repos.action.start(actionAttributes);
|
|
20
|
+
let eventIds = [];
|
|
21
|
+
let eventType;
|
|
22
|
+
try {
|
|
23
|
+
if (((_a = actionAttributes.instrument) === null || _a === void 0 ? void 0 : _a.createScreeningEventSeriesIfNotExistByWorkPerformed) === true) {
|
|
24
|
+
const bulkWriteResult = yield repos.event.createScreeningEventSeriesIfNotExistByWorkPerformed(actionAttributes.object.map((p) => {
|
|
25
|
+
if (p.typeOf !== factory.eventType.ScreeningEventSeries) {
|
|
26
|
+
throw new factory.errors.Argument('typeOf', `must be ${factory.eventType.ScreeningEventSeries}`);
|
|
27
|
+
}
|
|
28
|
+
return { attributes: p };
|
|
29
|
+
}));
|
|
30
|
+
let upsertedIds;
|
|
31
|
+
if (bulkWriteResult !== undefined) {
|
|
32
|
+
upsertedIds = bulkWriteResult.getUpsertedIds()
|
|
33
|
+
.map((doc) => doc._id.toString());
|
|
34
|
+
}
|
|
35
|
+
eventIds = (Array.isArray(upsertedIds)) ? upsertedIds : [];
|
|
36
|
+
eventType = factory.eventType.ScreeningEventSeries;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// no op
|
|
40
|
+
throw new factory.errors.NotImplemented('only createScreeningEventSeriesIfNotExistByWorkPerformed implemented');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// actionにエラー結果を追加
|
|
45
|
+
try {
|
|
46
|
+
const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
|
|
47
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error: actionError });
|
|
48
|
+
}
|
|
49
|
+
catch (__) {
|
|
50
|
+
// 失敗したら仕方ない
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
// アクション完了
|
|
55
|
+
yield repos.action.complete({
|
|
56
|
+
typeOf: action.typeOf,
|
|
57
|
+
id: action.id,
|
|
58
|
+
result: (Array.isArray(eventIds))
|
|
59
|
+
? eventIds.map((eventId) => {
|
|
60
|
+
return { id: eventId };
|
|
61
|
+
})
|
|
62
|
+
: undefined
|
|
63
|
+
});
|
|
64
|
+
if (Array.isArray(eventIds) && eventIds.length > 0) {
|
|
65
|
+
// 非同期に変更(2023-06-08~)
|
|
66
|
+
const onEventChangedTask = {
|
|
67
|
+
project: actionAttributes.project,
|
|
68
|
+
name: factory.taskName.OnEventChanged,
|
|
69
|
+
status: factory.taskStatus.Ready,
|
|
70
|
+
runsAt: new Date(),
|
|
71
|
+
remainingNumberOfTries: 3,
|
|
72
|
+
numberOfTried: 0,
|
|
73
|
+
executionResults: [],
|
|
74
|
+
data: {
|
|
75
|
+
id: eventIds,
|
|
76
|
+
project: { id: actionAttributes.project.id },
|
|
77
|
+
typeOf: eventType,
|
|
78
|
+
isNew: true,
|
|
79
|
+
useInform: true
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
yield repos.task.saveMany([onEventChangedTask], { emitImmediately: true });
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.createEvent = createEvent;
|
|
@@ -6,6 +6,7 @@ import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
|
6
6
|
import { MongoRepository as SellerRepo } from '../repo/seller';
|
|
7
7
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
8
8
|
import * as factory from '../factory';
|
|
9
|
+
import { createEvent } from './event/createEvent';
|
|
9
10
|
/**
|
|
10
11
|
* Googleで作品画像を検索する
|
|
11
12
|
*/
|
|
@@ -71,3 +72,4 @@ export declare function updateEvent4ttts(params: {
|
|
|
71
72
|
project: ProjectRepo;
|
|
72
73
|
task: TaskRepo;
|
|
73
74
|
}) => Promise<void>;
|
|
75
|
+
export { createEvent };
|
|
@@ -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.updateEvent4ttts = exports.createScreeningEventIdFromCOA = exports.importFromCOA = void 0;
|
|
12
|
+
exports.createEvent = exports.updateEvent4ttts = exports.createScreeningEventIdFromCOA = exports.importFromCOA = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* マスターデータ同期サービス
|
|
15
15
|
*/
|
|
@@ -21,6 +21,8 @@ const difference = require("lodash.difference");
|
|
|
21
21
|
const moment = require("moment-timezone");
|
|
22
22
|
const credentials_1 = require("../credentials");
|
|
23
23
|
const factory = require("../factory");
|
|
24
|
+
const createEvent_1 = require("./event/createEvent");
|
|
25
|
+
Object.defineProperty(exports, "createEvent", { enumerable: true, get: function () { return createEvent_1.createEvent; } });
|
|
24
26
|
const offer_1 = require("./offer");
|
|
25
27
|
const debug = createDebug('chevre-domain:service:event');
|
|
26
28
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
import { IConnectionSettings } from '../task';
|
|
3
|
+
export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* タスク実行関数
|
|
6
|
+
*/
|
|
7
|
+
export declare function call(data: factory.task.createEvent.IData): IOperation<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.call = void 0;
|
|
13
|
+
const action_1 = require("../../repo/action");
|
|
14
|
+
const event_1 = require("../../repo/event");
|
|
15
|
+
const task_1 = require("../../repo/task");
|
|
16
|
+
const EventService = require("../event");
|
|
17
|
+
/**
|
|
18
|
+
* タスク実行関数
|
|
19
|
+
*/
|
|
20
|
+
function call(data) {
|
|
21
|
+
return (settings) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
yield EventService.createEvent(data)({
|
|
23
|
+
action: new action_1.MongoRepository(settings.connection),
|
|
24
|
+
event: new event_1.MongoRepository(settings.connection),
|
|
25
|
+
task: new task_1.MongoRepository(settings.connection)
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.call = call;
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.316.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.316.0-alpha.2",
|
|
13
|
+
"@cinerino/sdk": "3.161.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.4.0-alpha.
|
|
120
|
+
"version": "21.4.0-alpha.19"
|
|
121
121
|
}
|