@chevre/domain 22.2.0-alpha.13 → 22.2.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/projectFields.ts +3 -2
- package/lib/chevre/repo/product.d.ts +2 -2
- package/lib/chevre/repo/product.js +62 -27
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/aggregation/event/findEventOffers.js +1 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +3 -5
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +3 -5
- package/lib/chevre/service/assetTransaction/reserve/start.js +1 -3
- package/lib/chevre/service/moneyTransfer.js +1 -3
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -12
- package/lib/chevre/service/offer/product/searchProductOffers.js +1 -3
- package/lib/chevre/service/offer/product.d.ts +1 -1
- package/lib/chevre/service/offer/product.js +2 -2
- package/lib/chevre/service/payment/paymentCard.js +1 -3
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +1 -1
- package/example/src/chevre/searchProducts.ts +0 -28
|
@@ -8,14 +8,15 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
|
-
const docs = await
|
|
13
|
+
const docs = await productRepo.projectFields(
|
|
14
14
|
{
|
|
15
15
|
limit: 10,
|
|
16
16
|
page: 1,
|
|
17
17
|
project: { id: { $eq: project.id } }
|
|
18
18
|
},
|
|
19
|
+
[],
|
|
19
20
|
[]
|
|
20
21
|
);
|
|
21
22
|
// tslint:disable-next-line:no-null-keyword
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import type { BulkWriteResult } from 'mongodb';
|
|
26
26
|
import type { Connection, FilterQuery } from 'mongoose';
|
|
27
27
|
import * as factory from '../factory';
|
|
28
|
-
type
|
|
28
|
+
type IKeyOfProjection = keyof factory.product.IProduct;
|
|
29
29
|
/**
|
|
30
30
|
* プロダクト検索条件
|
|
31
31
|
*/
|
|
@@ -41,7 +41,7 @@ export declare class ProductRepo {
|
|
|
41
41
|
/**
|
|
42
42
|
* プロダクトを検索する
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
projectFields(conditions: ISearchConditions4product, inclusion: IKeyOfProjection[], exclusion: IKeyOfProjection[]): Promise<(factory.product.IProduct & {
|
|
45
45
|
id: string;
|
|
46
46
|
})[]>;
|
|
47
47
|
deleteProductById(params: {
|
|
@@ -24,6 +24,18 @@ exports.ProductRepo = void 0;
|
|
|
24
24
|
const product_1 = require("./mongoose/schemas/product");
|
|
25
25
|
const factory = require("../factory");
|
|
26
26
|
const settings_1 = require("../settings");
|
|
27
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
28
|
+
'project',
|
|
29
|
+
'typeOf',
|
|
30
|
+
'additionalProperty',
|
|
31
|
+
'availableChannel',
|
|
32
|
+
'description',
|
|
33
|
+
'hasOfferCatalog',
|
|
34
|
+
'name',
|
|
35
|
+
'productID',
|
|
36
|
+
'serviceOutput',
|
|
37
|
+
'serviceType'
|
|
38
|
+
];
|
|
27
39
|
/**
|
|
28
40
|
* プロダクトリポジトリ
|
|
29
41
|
*/
|
|
@@ -154,28 +166,37 @@ class ProductRepo {
|
|
|
154
166
|
/**
|
|
155
167
|
* プロダクトを検索する
|
|
156
168
|
*/
|
|
157
|
-
|
|
169
|
+
projectFields(conditions, inclusion, exclusion) {
|
|
158
170
|
var _a;
|
|
159
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
172
|
const andConditions = ProductRepo.CREATE_MONGO_CONDITIONS(conditions);
|
|
161
|
-
let
|
|
173
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
162
174
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
163
|
-
inclusion.
|
|
164
|
-
projection[field] = 1;
|
|
165
|
-
});
|
|
175
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
166
176
|
}
|
|
167
177
|
else {
|
|
168
|
-
projection = {
|
|
169
|
-
__v: 0,
|
|
170
|
-
createdAt: 0,
|
|
171
|
-
updatedAt: 0
|
|
172
|
-
};
|
|
173
178
|
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
174
|
-
|
|
175
|
-
projection[field] = 0;
|
|
176
|
-
});
|
|
179
|
+
positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
|
|
177
180
|
}
|
|
178
181
|
}
|
|
182
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
183
|
+
// let projection: { [key: string]: number } = {};
|
|
184
|
+
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
185
|
+
// inclusion.forEach((field) => {
|
|
186
|
+
// projection[field] = 1;
|
|
187
|
+
// });
|
|
188
|
+
// } else {
|
|
189
|
+
// projection = {
|
|
190
|
+
// __v: 0,
|
|
191
|
+
// createdAt: 0,
|
|
192
|
+
// updatedAt: 0
|
|
193
|
+
// };
|
|
194
|
+
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
195
|
+
// exclusion.forEach((field) => {
|
|
196
|
+
// projection[field] = 0;
|
|
197
|
+
// });
|
|
198
|
+
// }
|
|
199
|
+
// }
|
|
179
200
|
const query = this.productModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
180
201
|
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
181
202
|
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
@@ -188,13 +209,13 @@ class ProductRepo {
|
|
|
188
209
|
query.sort({ productID: conditions.sort.productID });
|
|
189
210
|
}
|
|
190
211
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
191
|
-
.
|
|
192
|
-
.
|
|
212
|
+
.lean() // 2024-08-20~
|
|
213
|
+
.exec();
|
|
193
214
|
});
|
|
194
215
|
}
|
|
195
216
|
deleteProductById(params) {
|
|
196
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
yield this.productModel.findOneAndDelete({ _id: params.id })
|
|
218
|
+
yield this.productModel.findOneAndDelete({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
|
|
198
219
|
.exec();
|
|
199
220
|
});
|
|
200
221
|
}
|
|
@@ -202,11 +223,13 @@ class ProductRepo {
|
|
|
202
223
|
* プロダクトを保管する
|
|
203
224
|
*/
|
|
204
225
|
saveProduct(params) {
|
|
226
|
+
var _a, _b;
|
|
205
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
206
228
|
let doc;
|
|
229
|
+
let savedId;
|
|
207
230
|
if (typeof params.id === 'string') {
|
|
208
231
|
// 上書き禁止属性を除外
|
|
209
|
-
const
|
|
232
|
+
const _c = params.$set, { id, productID, project, typeOf, offers } = _c, setFields = __rest(_c, ["id", "productID", "project", "typeOf", "offers"]);
|
|
210
233
|
switch (typeOf) {
|
|
211
234
|
case factory.product.ProductType.EventService:
|
|
212
235
|
case factory.product.ProductType.MembershipService:
|
|
@@ -219,30 +242,43 @@ class ProductRepo {
|
|
|
219
242
|
}, {
|
|
220
243
|
$set: setFields,
|
|
221
244
|
$unset: params.$unset
|
|
222
|
-
}, { upsert: false, new: true, projection: { _id: 1 } })
|
|
245
|
+
}, { upsert: false, new: true, projection: { _id: 1, id: { $toString: '$_id' } } })
|
|
246
|
+
.lean()
|
|
223
247
|
.exec();
|
|
248
|
+
if (doc === null) {
|
|
249
|
+
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
250
|
+
}
|
|
224
251
|
break;
|
|
225
252
|
default:
|
|
226
253
|
throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
|
|
227
254
|
}
|
|
255
|
+
savedId = params.id;
|
|
228
256
|
}
|
|
229
257
|
else {
|
|
230
|
-
const
|
|
258
|
+
const _d = params.$set, { id } = _d, createParams = __rest(_d, ["id"]);
|
|
231
259
|
if (params.createIfNotExist === true) {
|
|
232
260
|
doc = yield this.productModel.findOneAndUpdate({
|
|
233
261
|
'project.id': { $eq: createParams.project.id },
|
|
234
262
|
typeOf: { $eq: createParams.typeOf }
|
|
235
|
-
}, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
|
|
263
|
+
}, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1, id: { $toString: '$_id' } } })
|
|
264
|
+
.lean()
|
|
236
265
|
.exec();
|
|
266
|
+
if (doc === null) {
|
|
267
|
+
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
268
|
+
}
|
|
269
|
+
savedId = doc.id;
|
|
237
270
|
}
|
|
238
271
|
else {
|
|
239
|
-
doc =
|
|
272
|
+
// doc = await this.productModel.create(createParams);
|
|
273
|
+
const result = yield this.productModel.insertMany(createParams, { rawResult: true });
|
|
274
|
+
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
275
|
+
if (typeof insertedId !== 'string') {
|
|
276
|
+
throw new factory.errors.Internal(`product not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
277
|
+
}
|
|
278
|
+
savedId = insertedId;
|
|
240
279
|
}
|
|
241
280
|
}
|
|
242
|
-
|
|
243
|
-
throw new factory.errors.NotFound(this.productModel.modelName);
|
|
244
|
-
}
|
|
245
|
-
return doc.toObject();
|
|
281
|
+
return { id: savedId };
|
|
246
282
|
});
|
|
247
283
|
}
|
|
248
284
|
/**
|
|
@@ -297,8 +333,7 @@ class ProductRepo {
|
|
|
297
333
|
*/
|
|
298
334
|
findAvailableChannel(params) {
|
|
299
335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
|
-
|
|
301
|
-
paymentService = (yield this.searchProducts({
|
|
336
|
+
const paymentService = (yield this.projectFields({
|
|
302
337
|
limit: 1,
|
|
303
338
|
page: 1,
|
|
304
339
|
project: { id: { $eq: params.project.id } },
|
|
@@ -165,7 +165,7 @@ function calculateOfferCount(params) {
|
|
|
165
165
|
try {
|
|
166
166
|
const eventOffers = params.event.offers;
|
|
167
167
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
168
|
-
const eventService = (yield repos.product.
|
|
168
|
+
const eventService = (yield repos.product.projectFields({
|
|
169
169
|
limit: 1,
|
|
170
170
|
page: 1,
|
|
171
171
|
id: { $eq: eventOffers.itemOffered.id }
|
|
@@ -23,7 +23,7 @@ function findEventOffers(params) {
|
|
|
23
23
|
// 興行設定があれば興行のカタログを参照する
|
|
24
24
|
const eventOffers = params.event.offers;
|
|
25
25
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
26
|
-
const eventService = (yield repos.product.
|
|
26
|
+
const eventService = (yield repos.product.projectFields({
|
|
27
27
|
limit: 1,
|
|
28
28
|
page: 1,
|
|
29
29
|
id: { $eq: eventOffers.itemOffered.id }
|
|
@@ -28,7 +28,7 @@ function start(params) {
|
|
|
28
28
|
var _a;
|
|
29
29
|
const issuedThroughId = fixIssuedThroughId(params);
|
|
30
30
|
// location.issuedThroughIdからプロダクトをfixする
|
|
31
|
-
const products = yield repos.product.
|
|
31
|
+
const products = yield repos.product.projectFields({
|
|
32
32
|
limit: 1,
|
|
33
33
|
page: 1,
|
|
34
34
|
project: { id: { $eq: params.project.id } },
|
|
@@ -268,7 +268,7 @@ function fixPaymentService(params) {
|
|
|
268
268
|
break;
|
|
269
269
|
// PaymentCardの場合、プロダクト検索
|
|
270
270
|
case factory.service.paymentService.PaymentServiceType.PaymentCard:
|
|
271
|
-
paymentService = (yield repos.product.
|
|
271
|
+
paymentService = (yield repos.product.projectFields({
|
|
272
272
|
limit: 1,
|
|
273
273
|
page: 1,
|
|
274
274
|
project: { id: { $eq: params.project.id } },
|
|
@@ -86,7 +86,7 @@ function fixPaymentService(params) {
|
|
|
86
86
|
break;
|
|
87
87
|
// PaymentCardの場合、プロダクト検索
|
|
88
88
|
case factory.service.paymentService.PaymentServiceType.PaymentCard:
|
|
89
|
-
paymentService = (yield repos.product.
|
|
89
|
+
paymentService = (yield repos.product.projectFields({
|
|
90
90
|
limit: 1,
|
|
91
91
|
page: 1,
|
|
92
92
|
project: { id: { $eq: params.payAction.project.id } },
|
|
@@ -44,8 +44,7 @@ function start(params) {
|
|
|
44
44
|
throw new factory.errors.ArgumentNull('object.itemOffered.id');
|
|
45
45
|
}
|
|
46
46
|
// プロダクト確認
|
|
47
|
-
|
|
48
|
-
const product = (yield repos.product.searchProducts({
|
|
47
|
+
const product = (yield repos.product.projectFields({
|
|
49
48
|
limit: 1,
|
|
50
49
|
page: 1,
|
|
51
50
|
id: { $eq: productId }
|
|
@@ -138,12 +137,11 @@ function createTransactionObject(params) {
|
|
|
138
137
|
function createPermitService(params) {
|
|
139
138
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
140
139
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
141
|
-
|
|
142
|
-
const product = (yield repos.product.searchProducts({
|
|
140
|
+
const product = (yield repos.product.projectFields({
|
|
143
141
|
limit: 1,
|
|
144
142
|
page: 1,
|
|
145
143
|
id: { $eq: params.issuedThrough.id }
|
|
146
|
-
}, [], [])).shift();
|
|
144
|
+
}, ['availableChannel'], [])).shift();
|
|
147
145
|
if (product === undefined) {
|
|
148
146
|
throw new factory.errors.NotFound('Product');
|
|
149
147
|
}
|
|
@@ -294,12 +294,12 @@ function validateProgramMembershipUsed(params) {
|
|
|
294
294
|
if (typeof issuedThroughId !== 'string' || issuedThroughId === '') {
|
|
295
295
|
throw new factory.errors.ArgumentNull('acceptedOffer.itemOffered.serviceOutput.programMembershipUsed.issuedThrough.id');
|
|
296
296
|
}
|
|
297
|
-
permitIssuedThrough = (yield repos.product.
|
|
297
|
+
permitIssuedThrough = (yield repos.product.projectFields({
|
|
298
298
|
limit: 1,
|
|
299
299
|
page: 1,
|
|
300
300
|
id: { $eq: issuedThroughId },
|
|
301
301
|
typeOf: { $eq: factory.product.ProductType.MembershipService }
|
|
302
|
-
}, ['
|
|
302
|
+
}, ['typeOf', 'project', 'serviceType', 'serviceOutput'], [])).shift();
|
|
303
303
|
if (permitIssuedThrough === undefined) {
|
|
304
304
|
throw new factory.errors.NotFound(factory.product.ProductType.MembershipService);
|
|
305
305
|
}
|
|
@@ -410,9 +410,7 @@ function validateProgramMembershipUsed(params) {
|
|
|
410
410
|
function createPermitService(params) {
|
|
411
411
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
412
412
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
413
|
-
|
|
414
|
-
// await repos.product.findProductById({ id: params.issuedThrough.id }, ['availableChannel'], []);
|
|
415
|
-
const product = (yield repos.product.searchProducts({
|
|
413
|
+
const product = (yield repos.product.projectFields({
|
|
416
414
|
limit: 1,
|
|
417
415
|
page: 1,
|
|
418
416
|
id: { $eq: params.issuedThrough.id }
|
|
@@ -405,9 +405,7 @@ function getAcceptedSeatNumbersAndSeatSections(params) {
|
|
|
405
405
|
function createPermitService(params) {
|
|
406
406
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
407
407
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
408
|
-
|
|
409
|
-
// await repos.product.findProductById({ id: params.issuedThrough.id }, ['availableChannel'], []);
|
|
410
|
-
const product = (yield repos.product.searchProducts({
|
|
408
|
+
const product = (yield repos.product.projectFields({
|
|
411
409
|
limit: 1,
|
|
412
410
|
page: 1,
|
|
413
411
|
id: { $eq: params.issuedThrough.id }
|
|
@@ -329,9 +329,7 @@ function getIssuedThroughIdByAction(params) {
|
|
|
329
329
|
function createPermitServiceCredentials(params) {
|
|
330
330
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
331
331
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
332
|
-
|
|
333
|
-
// await repos.product.findProductById({ id: params.issuedThrough.id }, ['availableChannel'], []);
|
|
334
|
-
const paymentCardService = (yield repos.product.searchProducts({
|
|
332
|
+
const paymentCardService = (yield repos.product.projectFields({
|
|
335
333
|
limit: 1,
|
|
336
334
|
page: 1,
|
|
337
335
|
id: { $eq: params.issuedThrough.id },
|
|
@@ -18,10 +18,8 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
18
18
|
// tslint:disable-next-line:max-func-body-length
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
21
|
-
// let eventService: Pick<factory.product.IProduct, 'hasOfferCatalog' | 'project'> | undefined;
|
|
22
21
|
let catalogId;
|
|
23
|
-
|
|
24
|
-
const eventService = (yield repos.product.searchProducts({
|
|
22
|
+
const eventService = (yield repos.product.projectFields({
|
|
25
23
|
limit: 1,
|
|
26
24
|
page: 1,
|
|
27
25
|
id: { $eq: String((_a = params.itemOffered) === null || _a === void 0 ? void 0 : _a.id) }
|
|
@@ -380,9 +378,7 @@ function searchOfferAppliesToMovieTicket(params) {
|
|
|
380
378
|
const eventOffers = event.offers;
|
|
381
379
|
let catalogId;
|
|
382
380
|
if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
383
|
-
|
|
384
|
-
// await repos.product.findProductById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
|
|
385
|
-
const eventService = (yield repos.product.searchProducts({
|
|
381
|
+
const eventService = (yield repos.product.projectFields({
|
|
386
382
|
limit: 1,
|
|
387
383
|
page: 1,
|
|
388
384
|
id: { $eq: eventOffers.itemOffered.id }
|
|
@@ -438,9 +434,7 @@ function searchOfferCatalogItems(params) {
|
|
|
438
434
|
const eventOffers = event.offers;
|
|
439
435
|
let catalogId;
|
|
440
436
|
if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
441
|
-
|
|
442
|
-
// await repos.product.findProductById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
|
|
443
|
-
const eventService = (yield repos.product.searchProducts({
|
|
437
|
+
const eventService = (yield repos.product.projectFields({
|
|
444
438
|
limit: 1,
|
|
445
439
|
page: 1,
|
|
446
440
|
id: { $eq: eventOffers.itemOffered.id }
|
|
@@ -508,9 +502,7 @@ function searchOfferCatalogItemAvailability(params) {
|
|
|
508
502
|
const eventOffers = event.offers;
|
|
509
503
|
let catalogId;
|
|
510
504
|
if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
511
|
-
|
|
512
|
-
// await repos.product.findProductById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
|
|
513
|
-
const eventService = (yield repos.product.searchProducts({
|
|
505
|
+
const eventService = (yield repos.product.projectFields({
|
|
514
506
|
limit: 1,
|
|
515
507
|
page: 1,
|
|
516
508
|
id: { $eq: eventOffers.itemOffered.id }
|
|
@@ -19,9 +19,7 @@ function searchProductOffers(params) {
|
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
var _a, _b;
|
|
21
21
|
// プロダクト検索
|
|
22
|
-
|
|
23
|
-
// await repos.product.findProductById({ id: params.itemOffered.id }, ['hasOfferCatalog', 'project'], []);
|
|
24
|
-
const productWithOffers = (yield repos.product.searchProducts({
|
|
22
|
+
const productWithOffers = (yield repos.product.projectFields({
|
|
25
23
|
limit: 1,
|
|
26
24
|
page: 1,
|
|
27
25
|
id: { $eq: params.itemOffered.id }
|
|
@@ -68,7 +68,7 @@ export declare function search(params: {
|
|
|
68
68
|
productOffer: ProductOfferRepo;
|
|
69
69
|
}) => Promise<{
|
|
70
70
|
offers: factory.product.ITicketOffer[];
|
|
71
|
-
product:
|
|
71
|
+
product: factory.product.IProduct;
|
|
72
72
|
}>;
|
|
73
73
|
export type IAuthorizeOfferAction = factory.action.authorize.offer.product.IAction;
|
|
74
74
|
/**
|
|
@@ -27,7 +27,7 @@ function search(params) {
|
|
|
27
27
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
28
28
|
var _a;
|
|
29
29
|
const now = moment();
|
|
30
|
-
const searchProductsResult = yield repos.product.
|
|
30
|
+
const searchProductsResult = yield repos.product.projectFields({
|
|
31
31
|
limit: 1,
|
|
32
32
|
page: 1,
|
|
33
33
|
project: { id: { $eq: params.project.id } },
|
|
@@ -172,7 +172,7 @@ function fixProductAndOffers(params) {
|
|
|
172
172
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
173
173
|
var _a, _b, _c;
|
|
174
174
|
const productId = String((_b = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id);
|
|
175
|
-
const searchProductsResult = yield repos.product.
|
|
175
|
+
const searchProductsResult = yield repos.product.projectFields({
|
|
176
176
|
limit: 1,
|
|
177
177
|
page: 1,
|
|
178
178
|
project: { id: { $eq: params.project.id } },
|
|
@@ -79,9 +79,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
79
79
|
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
80
80
|
}
|
|
81
81
|
// プロダクトから通貨区分を取得
|
|
82
|
-
|
|
83
|
-
// await repos.product.findProductById({ id: paymentServiceId }, ['serviceOutput'], []);
|
|
84
|
-
const paymentCatdProduct = (yield repos.product.searchProducts({
|
|
82
|
+
const paymentCatdProduct = (yield repos.product.projectFields({
|
|
85
83
|
limit: 1,
|
|
86
84
|
page: 1,
|
|
87
85
|
id: { $eq: paymentServiceId },
|
|
@@ -343,10 +343,10 @@ function deleteResourcesByOfferCatalog(params) {
|
|
|
343
343
|
const action = yield repos.action.start(deleteActionAttributes);
|
|
344
344
|
try {
|
|
345
345
|
// カタログからプロダクト検索
|
|
346
|
-
const productsWithCatalog = yield repos.product.
|
|
346
|
+
const productsWithCatalog = yield repos.product.projectFields({
|
|
347
347
|
project: { id: { $eq: params.project.id } },
|
|
348
348
|
hasOfferCatalog: { id: { $eq: catalogId } }
|
|
349
|
-
}, ['
|
|
349
|
+
}, ['id'], []);
|
|
350
350
|
let deleteEventResult;
|
|
351
351
|
let updateOfferResult;
|
|
352
352
|
if (productsWithCatalog.length > 0) {
|
|
@@ -275,7 +275,7 @@ function createInformMovieTasks(params) {
|
|
|
275
275
|
}
|
|
276
276
|
function createInformProductTasks(params) {
|
|
277
277
|
return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
const products4inform = yield repos.product.
|
|
278
|
+
const products4inform = yield repos.product.projectFields({
|
|
279
279
|
typeOf: { $eq: params.typeOf },
|
|
280
280
|
id: { $in: params.ids }
|
|
281
281
|
}, ['additionalProperty', 'description', 'name', 'productID', 'project', 'typeOf', 'serviceType'], []);
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
-
import { chevre } from '../../../lib/index';
|
|
3
|
-
|
|
4
|
-
import * as mongoose from 'mongoose';
|
|
5
|
-
|
|
6
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
12
|
-
const products = await productRepo.searchProducts(
|
|
13
|
-
{
|
|
14
|
-
project: { id: { $eq: project.id } }
|
|
15
|
-
},
|
|
16
|
-
// ['_id', 'typeOf'],
|
|
17
|
-
[],
|
|
18
|
-
[]
|
|
19
|
-
);
|
|
20
|
-
console.log('products:', products);
|
|
21
|
-
console.log(products.length, 'products found');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
main()
|
|
25
|
-
.then(() => {
|
|
26
|
-
console.log('success!');
|
|
27
|
-
})
|
|
28
|
-
.catch(console.error);
|