@chevre/domain 22.14.0-alpha.8 → 23.0.0-alpha.0
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 +1 -1
- package/example/src/chevre/authorizeEventServiceOffer.ts +119 -0
- 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 +44 -48
- package/lib/chevre/repo/event.js +13 -111
- 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 +2 -5
- 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/searchOffersByIds.d.ts +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 +3 -2
- 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/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
|
@@ -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;
|