@chevre/domain 22.14.0-alpha.15 → 22.14.0-alpha.17
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/lib/chevre/repo/mongoose/schemas/productOffer.d.ts +36 -0
- package/lib/chevre/repo/mongoose/schemas/{offer/event.js → productOffer.js} +9 -53
- package/lib/chevre/repo/productOffer.d.ts +60 -65
- package/lib/chevre/repo/productOffer.js +121 -163
- package/lib/chevre/repository.d.ts +0 -5
- package/lib/chevre/repository.js +2 -15
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.d.ts +0 -2
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +68 -53
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +0 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -2
- package/lib/chevre/service/offer/product.d.ts +0 -3
- package/lib/chevre/service/offer/product.js +29 -38
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -5
- package/lib/chevre/service/task/onResourceUpdated.js +1 -2
- package/package.json +2 -2
- package/example/src/chevre/eventOffer/adminEventOffers.ts +0 -67
- package/lib/chevre/repo/mongoose/schemas/offer/event.d.ts +0 -10
- package/lib/chevre/repo/offer/event.d.ts +0 -38
- package/lib/chevre/repo/offer/event.js +0 -142
|
@@ -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;
|