@chevre/domain 22.14.0-alpha.9 → 23.0.0-alpha.1
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/{createEventBySchedule.ts → addEventBySchedule.ts} +2 -2
- package/example/src/chevre/aggregateEventPublicFields.ts +1 -1
- package/example/src/chevre/aggregation/createAggregateEventTasks.ts +2 -2
- package/example/src/chevre/authorizeEventServiceOffer.ts +119 -0
- package/example/src/chevre/checkEventDuration.ts +1 -1
- package/example/src/chevre/findAnyEventById.ts +1 -1
- package/example/src/chevre/findReservationByCode.ts +0 -1
- package/example/src/chevre/productOffer/publishMemberTierToken.ts +92 -0
- package/example/src/chevre/reIndex.ts +3 -1
- package/example/src/chevre/roles/addAdminProductOfferPermissionIfNotExists.ts +48 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -2
- package/example/src/chevre/updateEventPartiallyById.ts +1 -1
- package/lib/chevre/factory/event.d.ts +2 -4
- package/lib/chevre/repo/accountingReport.d.ts +4 -4
- package/lib/chevre/repo/accountingReport.js +1 -1
- package/lib/chevre/repo/action.d.ts +1 -1
- package/lib/chevre/repo/aggregateReservation.d.ts +2 -2
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +65 -47
- package/lib/chevre/repo/event.d.ts +47 -51
- package/lib/chevre/repo/event.js +13 -112
- package/lib/chevre/repo/eventSeries.d.ts +14 -14
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +2 -15
- package/lib/chevre/repo/mongoose/schemas/aggregateReservation.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -6
- package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/place.js +13 -14
- package/lib/chevre/repo/mongoose/schemas/product.js +14 -4
- package/lib/chevre/repo/mongoose/schemas/{offer/event.d.ts → productOffer.d.ts} +6 -3
- package/lib/chevre/repo/mongoose/schemas/{offer/event.js → productOffer.js} +26 -29
- package/lib/chevre/repo/mongoose/schemas/seller.js +17 -6
- package/lib/chevre/repo/productOffer.d.ts +36 -61
- package/lib/chevre/repo/productOffer.js +163 -157
- package/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +2 -15
- package/lib/chevre/service/aggregation/event/aggregateOffers.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -6
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -19
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +1 -3
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createReservation.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +1 -6
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +4 -4
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +3 -3
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +57 -32
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize/factory.js +2 -2
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -4
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
- package/lib/chevre/service/offer/event/authorize.js +2 -2
- package/lib/chevre/service/offer/event/checkAvailability.d.ts +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
- package/lib/chevre/service/offer/event/searchOffersByIds.d.ts +1 -1
- package/lib/chevre/service/offer/event/searchOffersByIds.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
- package/lib/chevre/service/offer/onEventChanged.js +2 -19
- package/lib/chevre/service/offer/product.d.ts +0 -3
- package/lib/chevre/service/offer/product.js +29 -38
- package/lib/chevre/service/order/createAccountingReportIfNotExist.js +0 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +2 -2
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +1 -1
- package/lib/chevre/service/reserve/useReservation.js +2 -3
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -2
- package/lib/chevre/service/task/checkResource.d.ts +2 -2
- package/lib/chevre/service/task/checkResource.js +8 -6
- package/lib/chevre/service/task/createAccountingReport.d.ts +2 -2
- package/lib/chevre/service/task/createAccountingReport.js +15 -15
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +1 -1
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +2 -1
- package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -6
- package/lib/chevre/service/task/useReservation.js +1 -2
- package/lib/chevre/service/taskHandler.js +2 -0
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPointAward.d.ts +0 -1
- package/lib/chevre/service/validation/validateEvent.js +1 -1
- package/package.json +3 -3
- package/example/src/chevre/eventOffer/adminEventOffers.ts +0 -67
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +0 -48
- package/example/src/chevre/upsertMoviesByIdentifier.ts +0 -58
- package/lib/chevre/repo/offer/event.d.ts +0 -38
- package/lib/chevre/repo/offer/event.js +0 -142
|
@@ -24,17 +24,19 @@ const validateOrder_1 = require("../validation/validateOrder");
|
|
|
24
24
|
/**
|
|
25
25
|
* タスク実行関数
|
|
26
26
|
*/
|
|
27
|
-
function call(
|
|
27
|
+
function call(params) {
|
|
28
28
|
return (_a) => __awaiter(this, [_a], void 0, function* ({ connection, redisClient }) {
|
|
29
29
|
if (redisClient === undefined) {
|
|
30
30
|
throw new factory.errors.Argument('settings', 'redisClient required');
|
|
31
31
|
}
|
|
32
32
|
const actionRepo = new action_1.ActionRepo(connection);
|
|
33
|
+
const { data } = params;
|
|
33
34
|
const actionAttributes = {
|
|
34
|
-
agent: { id:
|
|
35
|
+
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
35
36
|
object: data.object,
|
|
36
|
-
project: { id:
|
|
37
|
-
typeOf: factory.actionType.CheckAction
|
|
37
|
+
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
38
|
+
typeOf: factory.actionType.CheckAction,
|
|
39
|
+
sameAs: { id: params.id, typeOf: 'Task' } // add sameAs(2025-09-22~)
|
|
38
40
|
};
|
|
39
41
|
const action = yield actionRepo.start(actionAttributes);
|
|
40
42
|
const objectTypeOf = data.object.typeOf;
|
|
@@ -43,7 +45,7 @@ function call(data) {
|
|
|
43
45
|
case factory.order.OrderType.Order:
|
|
44
46
|
yield (0, validateOrder_1.validateOrder)({
|
|
45
47
|
orderNumber: data.object.orderNumber,
|
|
46
|
-
project: { id:
|
|
48
|
+
project: { id: params.project.id }
|
|
47
49
|
})({
|
|
48
50
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
49
51
|
assetTransaction: new assetTransaction_1.AssetTransactionRepo(connection),
|
|
@@ -56,7 +58,7 @@ function call(data) {
|
|
|
56
58
|
case factory.eventType.ScreeningEvent:
|
|
57
59
|
yield (0, validateEvent_1.validateEvent)({
|
|
58
60
|
id: data.object.id,
|
|
59
|
-
project: { id:
|
|
61
|
+
project: { id: params.project.id }
|
|
60
62
|
})({
|
|
61
63
|
event: new event_1.EventRepo(connection),
|
|
62
64
|
stockHolder: new stockHolder_1.StockHolderRepo({ connection })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IOperationExecute } from '../taskHandler';
|
|
1
|
+
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
|
|
2
2
|
import * as factory from '../../factory';
|
|
3
3
|
/**
|
|
4
4
|
* タスク実行関数
|
|
5
5
|
*/
|
|
6
|
-
export declare function call(
|
|
6
|
+
export declare function call(params: Pick<factory.task.ITask<factory.taskName.CreateAccountingReport>, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -19,9 +19,9 @@ const createAccountingReportIfNotExist_1 = require("../order/createAccountingRep
|
|
|
19
19
|
/**
|
|
20
20
|
* タスク実行関数
|
|
21
21
|
*/
|
|
22
|
-
function call(
|
|
22
|
+
function call(params) {
|
|
23
23
|
return (_a) => __awaiter(this, [_a], void 0, function* ({ connection }) {
|
|
24
|
-
yield createAccountingReport(
|
|
24
|
+
yield createAccountingReport(params)({
|
|
25
25
|
acceptedOffer: new acceptedOffer_1.AcceptedOfferRepo(connection),
|
|
26
26
|
accountingReport: new accountingReport_1.AccountingReportRepo(connection),
|
|
27
27
|
action: new action_1.ActionRepo(connection),
|
|
@@ -31,8 +31,9 @@ function call(data) {
|
|
|
31
31
|
}
|
|
32
32
|
function createAccountingReport(params) {
|
|
33
33
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const { data } = params;
|
|
34
35
|
const order = yield repos.order.projectFieldsByOrderNumber({
|
|
35
|
-
orderNumber:
|
|
36
|
+
orderNumber: data.object.mainEntity.orderNumber,
|
|
36
37
|
project: { id: params.project.id },
|
|
37
38
|
inclusion: [
|
|
38
39
|
'orderNumber', 'project', 'customer', 'confirmationNumber',
|
|
@@ -41,28 +42,26 @@ function createAccountingReport(params) {
|
|
|
41
42
|
});
|
|
42
43
|
const simpleOrder = {
|
|
43
44
|
typeOf: order.typeOf,
|
|
44
|
-
// seller: {
|
|
45
|
-
// id: order.seller.id,
|
|
46
|
-
// typeOf: order.seller.typeOf,
|
|
47
|
-
// name: order.seller.name
|
|
48
|
-
// }, // 廃止(2024-03-06~)
|
|
49
|
-
// customer: { typeOf: order.customer.typeOf, id: order.customer.id }, // 廃止(2024-03-06~)
|
|
50
45
|
orderNumber: order.orderNumber,
|
|
51
|
-
// price: order.price,
|
|
52
|
-
// priceCurrency: order.priceCurrency,
|
|
53
46
|
orderDate: order.orderDate
|
|
54
47
|
};
|
|
48
|
+
const actionObject = {
|
|
49
|
+
// ...params,
|
|
50
|
+
mainEntity: { orderNumber: simpleOrder.orderNumber },
|
|
51
|
+
typeOf: 'Report'
|
|
52
|
+
};
|
|
55
53
|
const actionAttributes = {
|
|
56
54
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
57
55
|
typeOf: factory.actionType.CreateAction,
|
|
58
56
|
agent: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
59
|
-
object:
|
|
60
|
-
purpose: simpleOrder
|
|
57
|
+
object: actionObject,
|
|
58
|
+
purpose: simpleOrder,
|
|
59
|
+
sameAs: { id: params.id, typeOf: 'Task' } // add sameAs(2025-09-21~)
|
|
61
60
|
};
|
|
62
61
|
const action = yield repos.action.start(actionAttributes);
|
|
63
62
|
try {
|
|
64
63
|
const acceptedOffers = yield repos.acceptedOffer.searchAcceptedOffersByOrderNumber({
|
|
65
|
-
orderNumber: { $eq:
|
|
64
|
+
orderNumber: { $eq: data.object.mainEntity.orderNumber },
|
|
66
65
|
project: { id: { $eq: params.project.id } }
|
|
67
66
|
});
|
|
68
67
|
yield (0, createAccountingReportIfNotExist_1.createAccountingReportIfNotExist)(Object.assign(Object.assign({}, order), { acceptedOffers }))(repos);
|
|
@@ -76,6 +75,7 @@ function createAccountingReport(params) {
|
|
|
76
75
|
}
|
|
77
76
|
throw error;
|
|
78
77
|
}
|
|
79
|
-
|
|
78
|
+
const result = {};
|
|
79
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result });
|
|
80
80
|
});
|
|
81
81
|
}
|
|
@@ -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.
|
|
8
|
+
}, screeningEventSeries: Pick<factory.eventSeries.IEvent, 'location' | 'additionalProperty' | 'description' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'name' | 'soundFormat' | 'startDate' | 'typeOf' | 'videoFormat' | 'workPerformed'>, project: {
|
|
9
9
|
id: string;
|
|
10
10
|
}): ICreatingEvent4ttts;
|
|
11
11
|
interface ITourBySchedule {
|
|
@@ -10,7 +10,7 @@ import type { ScheduleRepo } from '../../../repo/schedule';
|
|
|
10
10
|
import type { SettingRepo } from '../../../repo/setting';
|
|
11
11
|
import type { TaskRepo } from '../../../repo/task';
|
|
12
12
|
import * as factory from '../../../factory';
|
|
13
|
-
export declare function createEventBySchedule(params: factory.task.createEvent.
|
|
13
|
+
export declare function createEventBySchedule(params: factory.task.createEvent.IAddEventByScheduleAction): (repos: {
|
|
14
14
|
action: ActionRepo;
|
|
15
15
|
event: EventRepo;
|
|
16
16
|
eventSeries: EventSeriesRepo;
|
|
@@ -36,7 +36,8 @@ function updateEvent4ttts(params) {
|
|
|
36
36
|
targetCollection: {
|
|
37
37
|
// id: params.attributes.identifier,
|
|
38
38
|
typeOf: factory.eventType.ScreeningEvent
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
instrument: { typeOf: 'Task' }
|
|
40
41
|
};
|
|
41
42
|
const action = yield repos.action.start(actionAttributes);
|
|
42
43
|
let savedEvent;
|
|
@@ -4,7 +4,7 @@ import type { EventRepo } from '../../../repo/event';
|
|
|
4
4
|
import type { EventSeriesRepo } from '../../../repo/eventSeries';
|
|
5
5
|
import type { MovieTheaterRepo } from '../../../repo/place/movieTheater';
|
|
6
6
|
import type { TaskRepo } from '../../../repo/task';
|
|
7
|
-
export declare function createEventSeries(params: factory.task.createEvent.
|
|
7
|
+
export declare function createEventSeries(params: factory.task.createEvent.IAddEventSeriesAction): (repos: {
|
|
8
8
|
action: ActionRepo;
|
|
9
9
|
event: EventRepo;
|
|
10
10
|
eventSeries: EventSeriesRepo;
|
|
@@ -252,11 +252,6 @@ function deleteResourcesBySeller(params) {
|
|
|
252
252
|
project: { id: params.project.id },
|
|
253
253
|
id: sellerId
|
|
254
254
|
});
|
|
255
|
-
// プロダクトオファー削除
|
|
256
|
-
const deleteProductOfferResult = yield repos.productOffer.deleteManyBySellerId({
|
|
257
|
-
project: { id: params.project.id },
|
|
258
|
-
seller: { id: sellerId }
|
|
259
|
-
});
|
|
260
255
|
// イベント削除
|
|
261
256
|
const deleteEventResult = yield repos.event.deleteManyEventByOrganizerId({
|
|
262
257
|
project: { id: params.project.id },
|
|
@@ -277,8 +272,14 @@ function deleteResourcesBySeller(params) {
|
|
|
277
272
|
project: { id: params.project.id },
|
|
278
273
|
parentOrganization: { id: sellerId }
|
|
279
274
|
});
|
|
275
|
+
// プロダクトオファー削除(2025-10-02~)
|
|
276
|
+
const deleteProductOfferResult = yield repos.productOffer.deleteProductOffersBySeller({
|
|
277
|
+
project: { id: params.project.id },
|
|
278
|
+
offeredBy: { id: sellerId }
|
|
279
|
+
});
|
|
280
280
|
deleteResult = {
|
|
281
|
-
deleteMemberResult, deletePaymentServiceProviderResult,
|
|
281
|
+
deleteMemberResult, deletePaymentServiceProviderResult,
|
|
282
|
+
deleteProductOfferResult,
|
|
282
283
|
deleteEventResult, deleteEventSeriesResult, deleteScreeningRoomResult, deleteMovieTheaterResult
|
|
283
284
|
};
|
|
284
285
|
}
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = call;
|
|
13
|
-
const factory = require("../../factory");
|
|
14
13
|
const action_1 = require("../../repo/action");
|
|
15
14
|
const assetTransaction_1 = require("../../repo/assetTransaction");
|
|
16
15
|
const authorization_1 = require("../../repo/authorization");
|
|
@@ -31,7 +30,7 @@ function call(data) {
|
|
|
31
30
|
instrument = data.instrument;
|
|
32
31
|
}
|
|
33
32
|
else {
|
|
34
|
-
if (((_b = data.instrument) === null || _b === void 0 ? void 0 : _b.typeOf) ===
|
|
33
|
+
if (((_b = data.instrument) === null || _b === void 0 ? void 0 : _b.typeOf) === 'Ticket') {
|
|
35
34
|
instrument = [data.instrument];
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -50,6 +50,8 @@ function executeTask(task, next) {
|
|
|
50
50
|
case factory.taskName.AuthorizePayment:
|
|
51
51
|
case factory.taskName.CancelPendingReservation:
|
|
52
52
|
case factory.taskName.CheckMovieTicket:
|
|
53
|
+
case factory.taskName.CheckResource:
|
|
54
|
+
case factory.taskName.CreateAccountingReport:
|
|
53
55
|
case factory.taskName.DeletePerson:
|
|
54
56
|
case factory.taskName.HandleNotification:
|
|
55
57
|
case factory.taskName.ImportEventCapacitiesFromCOA:
|
|
@@ -16,7 +16,7 @@ exports.validateEvent = validateEvent;
|
|
|
16
16
|
function validateEvent(__) {
|
|
17
17
|
return (__2) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
// const event: Pick<factory.event.screeningEvent.IEvent, 'id' | 'startDate'> =
|
|
19
|
-
// await repos.event.projectEventFieldsById
|
|
19
|
+
// await repos.event.projectEventFieldsById(
|
|
20
20
|
// { id: params.id },
|
|
21
21
|
// ['startDate']
|
|
22
22
|
// );
|
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": "
|
|
15
|
-
"@cinerino/sdk": "12.
|
|
14
|
+
"@chevre/factory": "5.0.0-alpha.1",
|
|
15
|
+
"@cinerino/sdk": "12.5.0-alpha.1",
|
|
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",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "
|
|
118
|
+
"version": "23.0.0-alpha.1"
|
|
119
119
|
}
|
|
@@ -1,67 +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
|
-
const IDENTIFIER = 'xxx';
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
// const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
13
|
-
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
let docs = await eventOfferRepo.projectFields(
|
|
16
|
-
{
|
|
17
|
-
project: { id: { $eq: project.id } },
|
|
18
|
-
identifier: { $eq: IDENTIFIER }
|
|
19
|
-
},
|
|
20
|
-
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
21
|
-
);
|
|
22
|
-
console.log('docs:', docs);
|
|
23
|
-
console.log(docs.length, 'docs found');
|
|
24
|
-
|
|
25
|
-
if (docs.length > 0) {
|
|
26
|
-
await eventOfferRepo.deleteById({
|
|
27
|
-
project: { id: docs[0].project.id },
|
|
28
|
-
id: docs[0].id
|
|
29
|
-
});
|
|
30
|
-
console.log('deleted', docs[0].id);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
await eventOfferRepo.save({
|
|
34
|
-
attributes: {
|
|
35
|
-
identifier: IDENTIFIER,
|
|
36
|
-
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
37
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
38
|
-
itemOffered: {
|
|
39
|
-
id: 'xxxxx',
|
|
40
|
-
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
41
|
-
},
|
|
42
|
-
seller: {
|
|
43
|
-
id: 'xxxxx',
|
|
44
|
-
typeOf: chevre.factory.organizationType.Organization
|
|
45
|
-
},
|
|
46
|
-
availableAtOrFrom: { id: 'xxx' },
|
|
47
|
-
validFrom: new Date(),
|
|
48
|
-
validThrough: new Date(),
|
|
49
|
-
validForMemberTier: { identifier: 'xxx', typeOf: 'MemberProgramTier' }
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
console.log('created.');
|
|
53
|
-
|
|
54
|
-
docs = await await eventOfferRepo.projectFields(
|
|
55
|
-
{
|
|
56
|
-
project: { id: { $eq: project.id } },
|
|
57
|
-
identifier: { $eq: IDENTIFIER }
|
|
58
|
-
},
|
|
59
|
-
['availableAtOrFrom', 'identifier', 'itemOffered', 'project', 'validFrom']
|
|
60
|
-
);
|
|
61
|
-
console.log('docs:', docs);
|
|
62
|
-
console.log(docs.length, 'docs found');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
main()
|
|
66
|
-
.then()
|
|
67
|
-
.catch(console.error);
|
|
@@ -1,48 +0,0 @@
|
|
|
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 roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
|
|
10
|
-
|
|
11
|
-
const roleNames = [
|
|
12
|
-
chevre.factory.role.organizationRole.RoleName.AdminInventoryManager
|
|
13
|
-
];
|
|
14
|
-
const permissions = [
|
|
15
|
-
'admin.sellers.events.*'
|
|
16
|
-
];
|
|
17
|
-
for (const roleName of roleNames) {
|
|
18
|
-
for (const permission of permissions) {
|
|
19
|
-
const result = await roleRepo.addPermissionIfNotExists({
|
|
20
|
-
roleName: { $eq: roleName },
|
|
21
|
-
permission
|
|
22
|
-
});
|
|
23
|
-
console.log('permission added.', result, roleName);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// roleNames = [
|
|
28
|
-
// chevre.factory.role.organizationRole.RoleName.InventoryManager,
|
|
29
|
-
// chevre.factory.role.organizationRole.RoleName.SellersOwner,
|
|
30
|
-
// chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
31
|
-
// ];
|
|
32
|
-
// permissions = [
|
|
33
|
-
// 'admin.sellers.eventSeries.*'
|
|
34
|
-
// ];
|
|
35
|
-
// for (const roleName of roleNames) {
|
|
36
|
-
// for (const permission of permissions) {
|
|
37
|
-
// const result = await roleRepo.addPermissionIfNotExists({
|
|
38
|
-
// roleName: { $eq: roleName },
|
|
39
|
-
// permission
|
|
40
|
-
// });
|
|
41
|
-
// console.log('permission added.', result, roleName);
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
main()
|
|
47
|
-
.then()
|
|
48
|
-
.catch(console.error);
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const result = await creativeWorkRepo.upsertMoviesByIdentifier(
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
$set: {
|
|
18
|
-
id: '',
|
|
19
|
-
identifier: '20231215',
|
|
20
|
-
typeOf: chevre.factory.creativeWorkType.Movie,
|
|
21
|
-
duration: 'PT2H',
|
|
22
|
-
name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
|
|
23
|
-
offers: {
|
|
24
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
25
|
-
availabilityEnds: moment('2118-11-04T15:00:00.000Z')
|
|
26
|
-
.toDate(),
|
|
27
|
-
availabilityStarts: moment('2018-11-25T15:00:00.000Z')
|
|
28
|
-
.toDate()
|
|
29
|
-
},
|
|
30
|
-
project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
|
|
31
|
-
additionalProperty: [
|
|
32
|
-
{
|
|
33
|
-
name: 'posterImage',
|
|
34
|
-
value: 'https://iwiz-movies.c.yimg.jp/c/movies/pict/p/p/90/cb/174755_02.jpg'
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
// headline: 'サブタイトルサブタイトル',
|
|
38
|
-
datePublished: moment('2018-11-04T15:00:00.000Z')
|
|
39
|
-
.toDate(),
|
|
40
|
-
distributor: {
|
|
41
|
-
id: '5e35398a8067a30012dd6717',
|
|
42
|
-
codeValue: '001',
|
|
43
|
-
...{
|
|
44
|
-
distributorType: '001'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
$unset: { headline: 1 }
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
{ replace: true }
|
|
52
|
-
);
|
|
53
|
-
console.log('result:', result);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
main()
|
|
57
|
-
.then(console.log)
|
|
58
|
-
.catch(console.error);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Connection, FilterQuery } from 'mongoose';
|
|
2
|
-
import * as factory from '../../factory';
|
|
3
|
-
import { IDocType } from '../mongoose/schemas/offer/event';
|
|
4
|
-
type ISearchConditions = factory.eventOffer.ISearchConditions;
|
|
5
|
-
export type ISavingOffer = Pick<IDocType, 'availableAtOrFrom' | 'identifier' | 'itemOffered' | 'project' | 'seller' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
|
|
6
|
-
id?: never;
|
|
7
|
-
};
|
|
8
|
-
interface IUnset {
|
|
9
|
-
$unset?: {
|
|
10
|
-
[key: string]: 1;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
type IDocWithId = IDocType & {
|
|
14
|
-
id: string;
|
|
15
|
-
};
|
|
16
|
-
type IKeyOfProjection = keyof IDocType;
|
|
17
|
-
/**
|
|
18
|
-
* イベントオファーリポジトリ
|
|
19
|
-
*/
|
|
20
|
-
export declare class EventOfferRepo {
|
|
21
|
-
private readonly eventOfferModel;
|
|
22
|
-
constructor(connection: Connection);
|
|
23
|
-
static CREATE_FILTER_QUERY(params: ISearchConditions): FilterQuery<IDocType>[];
|
|
24
|
-
save(params: {
|
|
25
|
-
id?: string;
|
|
26
|
-
attributes: ISavingOffer & IUnset;
|
|
27
|
-
}): Promise<{
|
|
28
|
-
id: string;
|
|
29
|
-
}>;
|
|
30
|
-
projectFields(conditions: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
|
|
31
|
-
deleteById(params: {
|
|
32
|
-
id: string;
|
|
33
|
-
project: {
|
|
34
|
-
id: string;
|
|
35
|
-
};
|
|
36
|
-
}): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.EventOfferRepo = void 0;
|
|
24
|
-
const factory = require("../../factory");
|
|
25
|
-
const settings_1 = require("../../settings");
|
|
26
|
-
const event_1 = require("../mongoose/schemas/offer/event");
|
|
27
|
-
/**
|
|
28
|
-
* イベントオファーリポジトリ
|
|
29
|
-
*/
|
|
30
|
-
class EventOfferRepo {
|
|
31
|
-
constructor(connection) {
|
|
32
|
-
this.eventOfferModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
33
|
-
}
|
|
34
|
-
// tslint:disable-next-line:max-func-body-length
|
|
35
|
-
static CREATE_FILTER_QUERY(params) {
|
|
36
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
37
|
-
const andConditions = [];
|
|
38
|
-
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
-
if (typeof projectIdEq === 'string') {
|
|
40
|
-
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
-
}
|
|
42
|
-
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
43
|
-
if (typeof idEq === 'string') {
|
|
44
|
-
andConditions.push({ _id: { $eq: idEq } });
|
|
45
|
-
}
|
|
46
|
-
const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
47
|
-
if (Array.isArray(idIn)) {
|
|
48
|
-
andConditions.push({ _id: { $in: idIn } });
|
|
49
|
-
}
|
|
50
|
-
const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
51
|
-
if (typeof identifierEq === 'string') {
|
|
52
|
-
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
53
|
-
}
|
|
54
|
-
const sellerIdEq = (_g = (_f = params.seller) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
55
|
-
if (typeof sellerIdEq === 'string') {
|
|
56
|
-
andConditions.push({ 'seller.id': { $eq: sellerIdEq } });
|
|
57
|
-
}
|
|
58
|
-
const itemOfferedIdEq = (_j = (_h = params.itemOffered) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
59
|
-
if (typeof itemOfferedIdEq === 'string') {
|
|
60
|
-
andConditions.push({ 'itemOffered.id': { $eq: itemOfferedIdEq } });
|
|
61
|
-
}
|
|
62
|
-
const availableAtOrFromIdEq = (_l = (_k = params.availableAtOrFrom) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
63
|
-
if (typeof availableAtOrFromIdEq === 'string') {
|
|
64
|
-
andConditions.push({ 'availableAtOrFrom.id': { $eq: availableAtOrFromIdEq } });
|
|
65
|
-
}
|
|
66
|
-
const validForMemberTierIdentifierEq = (_o = (_m = params.validForMemberTier) === null || _m === void 0 ? void 0 : _m.identifier) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
67
|
-
if (typeof validForMemberTierIdentifierEq === 'string') {
|
|
68
|
-
andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
|
|
69
|
-
}
|
|
70
|
-
return andConditions;
|
|
71
|
-
}
|
|
72
|
-
save(params) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
let doc;
|
|
76
|
-
let savedId;
|
|
77
|
-
const savingId = params.id;
|
|
78
|
-
if (typeof savingId === 'string') {
|
|
79
|
-
if (savingId === '') {
|
|
80
|
-
throw new factory.errors.ArgumentNull('id');
|
|
81
|
-
}
|
|
82
|
-
const _c = params.attributes, { id, identifier, itemOffered, project, seller, typeOf, availableAtOrFrom, validForMemberTier, $unset } = _c, updateFields = __rest(_c, ["id", "identifier", "itemOffered", "project", "seller", "typeOf", "availableAtOrFrom", "validForMemberTier", "$unset"]);
|
|
83
|
-
const filter = {
|
|
84
|
-
_id: { $eq: savingId },
|
|
85
|
-
'project.id': { $eq: project.id }
|
|
86
|
-
};
|
|
87
|
-
const update = Object.assign({ $set: Object.assign({}, updateFields) }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
88
|
-
const options = {
|
|
89
|
-
upsert: false,
|
|
90
|
-
new: true,
|
|
91
|
-
projection: { _id: 1, id: { $toString: '$_id' } }
|
|
92
|
-
};
|
|
93
|
-
doc = yield this.eventOfferModel.findOneAndUpdate(filter, update, options)
|
|
94
|
-
.lean()
|
|
95
|
-
.exec();
|
|
96
|
-
if (doc === null) {
|
|
97
|
-
throw new factory.errors.NotFound(this.eventOfferModel.modelName);
|
|
98
|
-
}
|
|
99
|
-
savedId = savingId;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
const _d = params.attributes, { $unset, id } = _d, createParams = __rest(_d, ["$unset", "id"]);
|
|
103
|
-
const result = yield this.eventOfferModel.insertMany(Object.assign({}, createParams), { rawResult: true });
|
|
104
|
-
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
105
|
-
if (typeof insertedId !== 'string') {
|
|
106
|
-
throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
107
|
-
}
|
|
108
|
-
savedId = insertedId;
|
|
109
|
-
}
|
|
110
|
-
return { id: savedId };
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
projectFields(conditions, inclusion) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
var _a;
|
|
116
|
-
const andConditions = EventOfferRepo.CREATE_FILTER_QUERY(conditions);
|
|
117
|
-
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(inclusion.map((key) => ([key, 1]))));
|
|
118
|
-
const query = this.eventOfferModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
119
|
-
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
120
|
-
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
121
|
-
query.limit(conditions.limit)
|
|
122
|
-
.skip(conditions.limit * (page - 1));
|
|
123
|
-
}
|
|
124
|
-
if (typeof ((_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
|
|
125
|
-
query.sort({ validFrom: conditions.sort.validFrom });
|
|
126
|
-
}
|
|
127
|
-
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
128
|
-
.lean()
|
|
129
|
-
.exec();
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
deleteById(params) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
yield this.eventOfferModel.findOneAndDelete({
|
|
135
|
-
_id: { $eq: params.id },
|
|
136
|
-
'project.id': { $eq: params.project.id }
|
|
137
|
-
}, { projection: { _id: 1 } })
|
|
138
|
-
.exec();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.EventOfferRepo = EventOfferRepo;
|