@chevre/domain 22.5.0-alpha.0 → 22.5.0-alpha.10
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/migrateProductHasOfferCatalog.ts +80 -0
- package/example/src/chevre/projectFields.ts +3 -3
- package/example/src/chevre/searchEventHasOfferCatalog.ts +43 -0
- package/example/src/chevre/searchOfferCatalogItemListElement.ts +26 -0
- package/example/src/chevre/searchOfferCatalogItems.ts +3 -2
- package/lib/chevre/repo/event.d.ts +13 -1
- package/lib/chevre/repo/event.js +24 -25
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/product.js +9 -3
- package/lib/chevre/repo/offer.js +0 -3
- package/lib/chevre/repo/offerCatalog.d.ts +19 -2
- package/lib/chevre/repo/offerCatalog.js +70 -22
- package/lib/chevre/repo/offerCatalogItem.d.ts +3 -6
- package/lib/chevre/repo/offerCatalogItem.js +84 -45
- package/lib/chevre/repo/paymentService.js +0 -10
- package/lib/chevre/repo/product.d.ts +28 -6
- package/lib/chevre/repo/product.js +73 -26
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +11 -7
- package/lib/chevre/service/aggregation/event/findEventOffers.js +6 -3
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +3 -1
- package/lib/chevre/service/assetTransaction/pay.js +3 -1
- package/lib/chevre/service/assetTransaction/refund/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/refund.js +3 -1
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +6 -2
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +6 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +12 -9
- package/lib/chevre/service/moneyTransfer.js +3 -1
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.js +25 -8
- package/lib/chevre/service/offer/event/checkAvailability.d.ts +10 -0
- package/lib/chevre/service/offer/event/checkAvailability.js +48 -0
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +3 -60
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +67 -272
- package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.d.ts +48 -0
- package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +109 -0
- package/lib/chevre/service/offer/event/searchOfferCatalogItems.d.ts +38 -0
- package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +95 -0
- package/lib/chevre/service/offer/event/searchOffersByIds.d.ts +57 -0
- package/lib/chevre/service/offer/event/searchOffersByIds.js +232 -0
- package/lib/chevre/service/offer/event/searchPriceSpecs4event.d.ts +19 -0
- package/lib/chevre/service/offer/event/searchPriceSpecs4event.js +69 -0
- package/lib/chevre/service/offer/event.d.ts +3 -1
- package/lib/chevre/service/offer/event.js +4 -2
- package/lib/chevre/service/offer/product/searchProductOffers.js +17 -5
- package/lib/chevre/service/offer/product.d.ts +1 -1
- package/lib/chevre/service/offer/product.js +6 -2
- package/lib/chevre/service/payment/paymentCard.js +3 -1
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +3 -1
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated.js +3 -1
- package/package.json +3 -3
- package/example/src/chevre/migrateEventSeries2secondary.ts +0 -70
- package/example/src/chevre/offerCatalog2offerCatalogItem.ts +0 -161
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
|
|
8
|
+
// tslint:disable-next-line:max-func-body-length
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const cursor = productRepo.getCursor(
|
|
15
|
+
{
|
|
16
|
+
typeOf: { $exists: true },
|
|
17
|
+
'hasOfferCatalog.id': { $exists: true }
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
project: 1,
|
|
21
|
+
typeOf: 1,
|
|
22
|
+
productID: 1,
|
|
23
|
+
hasOfferCatalog: 1,
|
|
24
|
+
id: { $toString: '$_id' }
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
console.log('docs found');
|
|
28
|
+
|
|
29
|
+
let i = 0;
|
|
30
|
+
let updateCount = 0;
|
|
31
|
+
await cursor.eachAsync(async (doc) => {
|
|
32
|
+
i += 1;
|
|
33
|
+
const product: Pick<chevre.factory.product.IProduct, 'hasOfferCatalog' | 'productID' | 'project' | 'typeOf' | 'id'> = doc;
|
|
34
|
+
// console.log(product);
|
|
35
|
+
const { hasOfferCatalog } = product;
|
|
36
|
+
if (typeof hasOfferCatalog?.id !== 'string') {
|
|
37
|
+
throw new Error(`${product.project.id} ${product.productID} has no catalog`);
|
|
38
|
+
}
|
|
39
|
+
if (typeof product.id !== 'string') {
|
|
40
|
+
throw new Error(`${product.project.id} ${product.productID} has no id`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const alreadyMigrated = Array.isArray(hasOfferCatalog?.itemListElement)
|
|
44
|
+
&& hasOfferCatalog?.itemListElement.length === 1
|
|
45
|
+
&& hasOfferCatalog?.id === hasOfferCatalog.itemListElement[0].id;
|
|
46
|
+
if (alreadyMigrated) {
|
|
47
|
+
console.log(
|
|
48
|
+
'already exist.',
|
|
49
|
+
product.project.id,
|
|
50
|
+
product.typeOf,
|
|
51
|
+
product.id, product.productID, i, updateCount
|
|
52
|
+
);
|
|
53
|
+
} else {
|
|
54
|
+
updateCount += 1;
|
|
55
|
+
console.log(
|
|
56
|
+
'updating...',
|
|
57
|
+
product.project.id,
|
|
58
|
+
product.typeOf,
|
|
59
|
+
product.id, product.productID, i, updateCount
|
|
60
|
+
);
|
|
61
|
+
await productRepo.migrateHasOfferCatalogItemListElement({
|
|
62
|
+
id: product.id,
|
|
63
|
+
hasOfferCatalog: { id: hasOfferCatalog.id }
|
|
64
|
+
});
|
|
65
|
+
console.log(
|
|
66
|
+
'updated.',
|
|
67
|
+
product.project.id,
|
|
68
|
+
product.typeOf,
|
|
69
|
+
product.id, product.productID, i, updateCount
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log(i, 'docs checked');
|
|
75
|
+
console.log(updateCount, 'docs updated');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
main()
|
|
79
|
+
.then()
|
|
80
|
+
.catch(console.error);
|
|
@@ -8,15 +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 repo = await chevre.repository.
|
|
11
|
+
const repo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const docs = await repo.projectFields(
|
|
14
14
|
{
|
|
15
|
-
limit:
|
|
15
|
+
limit: 10,
|
|
16
16
|
page: 1,
|
|
17
17
|
project: { id: { $eq: project.id } }
|
|
18
18
|
},
|
|
19
|
-
['
|
|
19
|
+
['relatedOffer']
|
|
20
20
|
);
|
|
21
21
|
// tslint:disable-next-line:no-null-keyword
|
|
22
22
|
console.dir(docs, { depth: null });
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
+
|
|
11
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
12
|
+
const productRepo = await chevre.repository.Product.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const event = (await eventRepo.projectEventFields(
|
|
15
|
+
{
|
|
16
|
+
id: { $eq: 'bm0f0cadm' },
|
|
17
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
18
|
+
project: { id: { $eq: project.id } }
|
|
19
|
+
},
|
|
20
|
+
['offers.itemOffered.id']
|
|
21
|
+
)).shift();
|
|
22
|
+
console.log('event:', event);
|
|
23
|
+
if (event === undefined) {
|
|
24
|
+
throw new Error('event not found');
|
|
25
|
+
}
|
|
26
|
+
const productId = event.offers.itemOffered.id;
|
|
27
|
+
if (typeof productId !== 'string') {
|
|
28
|
+
throw new Error('offers.itemOffered.id undefined');
|
|
29
|
+
}
|
|
30
|
+
const catalogs = await productRepo.aggregateHasOfferCatalog(
|
|
31
|
+
{
|
|
32
|
+
id: productId,
|
|
33
|
+
limit: 10,
|
|
34
|
+
page: 1
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
console.log(catalogs);
|
|
38
|
+
console.log(catalogs.length);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main()
|
|
42
|
+
.then(console.log)
|
|
43
|
+
.catch(console.error);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
mongoose.Model.on('index', (...args) => {
|
|
8
|
+
console.error('******** index event emitted. ********\n', args);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const result = await offerCatalogRepo.searchItemListElement({
|
|
17
|
+
id: { $in: ['blpj322ni', 'blpc770py', 'xxxx', 'blos0d5gu'] },
|
|
18
|
+
itemListElement: { id: { $in: ['xxx', '65669285c7b871dba60ed72e', '65669285c7b871dba60ed742', '1008'] } }
|
|
19
|
+
});
|
|
20
|
+
console.log(result);
|
|
21
|
+
console.log(result.length);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
main()
|
|
25
|
+
.then(console.log)
|
|
26
|
+
.catch(console.error);
|
|
@@ -18,10 +18,11 @@ async function main() {
|
|
|
18
18
|
|
|
19
19
|
const result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItems({
|
|
20
20
|
event: {
|
|
21
|
-
id: '
|
|
21
|
+
id: 'bm0f0cadm'
|
|
22
22
|
},
|
|
23
23
|
limit: 10,
|
|
24
|
-
page: 1
|
|
24
|
+
page: 1,
|
|
25
|
+
options: { includedInDataCatalog: { id: 'blpj322ni' } }
|
|
25
26
|
})({
|
|
26
27
|
event: eventRepo,
|
|
27
28
|
offerCatalog: offerCatalogRepo,
|
|
@@ -70,7 +70,7 @@ interface IAggregateEvent {
|
|
|
70
70
|
statuses: IStatus[];
|
|
71
71
|
}
|
|
72
72
|
export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
|
|
73
|
-
type IKeyOfProjection<T extends AvailableEventType> = Exclude<keyof factory.event.IEvent<T>, 'id'> | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered';
|
|
73
|
+
type IKeyOfProjection<T extends AvailableEventType> = Exclude<keyof factory.event.IEvent<T>, 'id'> | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id';
|
|
74
74
|
/**
|
|
75
75
|
* minimizedEvent検索時のprojection候補
|
|
76
76
|
* add(2024-07-18~)
|
|
@@ -316,20 +316,32 @@ export declare class EventRepo {
|
|
|
316
316
|
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, IDocType> & ((import("@chevre/factory/lib/event/anyEvent").IAttributes & {
|
|
317
317
|
_id: string;
|
|
318
318
|
} & Required<{
|
|
319
|
+
/**
|
|
320
|
+
* イベントリポジトリ
|
|
321
|
+
*/
|
|
319
322
|
_id: string;
|
|
320
323
|
}>) | (import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
|
|
321
324
|
_id: string;
|
|
322
325
|
aggregateOffer?: import("@chevre/factory/lib/event/anyEvent").IAggregateOffer | undefined;
|
|
323
326
|
} & Required<{
|
|
327
|
+
/**
|
|
328
|
+
* イベントリポジトリ
|
|
329
|
+
*/
|
|
324
330
|
_id: string;
|
|
325
331
|
}>)), import("mongoose").QueryOptions<Document<unknown, {}, IDocType> & ((import("@chevre/factory/lib/event/anyEvent").IAttributes & {
|
|
326
332
|
_id: string;
|
|
327
333
|
} & Required<{
|
|
334
|
+
/**
|
|
335
|
+
* イベントリポジトリ
|
|
336
|
+
*/
|
|
328
337
|
_id: string;
|
|
329
338
|
}>) | (import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
|
|
330
339
|
_id: string;
|
|
331
340
|
aggregateOffer?: import("@chevre/factory/lib/event/anyEvent").IAggregateOffer | undefined;
|
|
332
341
|
} & Required<{
|
|
342
|
+
/**
|
|
343
|
+
* イベントリポジトリ
|
|
344
|
+
*/
|
|
333
345
|
_id: string;
|
|
334
346
|
}>))>>;
|
|
335
347
|
addAvailableAtOrFrom(params: {
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -66,7 +66,7 @@ class EventRepo {
|
|
|
66
66
|
}
|
|
67
67
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
68
68
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27
|
|
69
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27;
|
|
70
70
|
const andConditions = [];
|
|
71
71
|
const typeOfEq = conditions.typeOf;
|
|
72
72
|
if (typeof typeOfEq === 'string') {
|
|
@@ -153,18 +153,17 @@ class EventRepo {
|
|
|
153
153
|
if (Array.isArray(locationBranchCodeIn)) {
|
|
154
154
|
andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
|
|
155
155
|
}
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const additionalPropertyElemMatch = (_o = conditions.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
|
|
156
|
+
// discontinue(2024-09-30)
|
|
157
|
+
// const hasOfferCatalogIdEq = conditions.hasOfferCatalog?.id?.$eq;
|
|
158
|
+
// if (typeof hasOfferCatalogIdEq === 'string') {
|
|
159
|
+
// andConditions.push({
|
|
160
|
+
// 'hasOfferCatalog.id': {
|
|
161
|
+
// $exists: true,
|
|
162
|
+
// $eq: hasOfferCatalogIdEq
|
|
163
|
+
// }
|
|
164
|
+
// });
|
|
165
|
+
// }
|
|
166
|
+
const additionalPropertyElemMatch = (_l = conditions.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
|
|
168
167
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
169
168
|
andConditions.push({
|
|
170
169
|
additionalProperty: {
|
|
@@ -180,7 +179,7 @@ class EventRepo {
|
|
|
180
179
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
181
180
|
/* istanbul ignore else */
|
|
182
181
|
if (params.offers !== undefined) {
|
|
183
|
-
const itemOfferedIdIn4event = (
|
|
182
|
+
const itemOfferedIdIn4event = (_o = (_m = params.offers.itemOffered) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$in;
|
|
184
183
|
if (Array.isArray(itemOfferedIdIn4event)) {
|
|
185
184
|
andConditions.push({
|
|
186
185
|
'offers.itemOffered.id': {
|
|
@@ -230,8 +229,8 @@ class EventRepo {
|
|
|
230
229
|
}
|
|
231
230
|
}
|
|
232
231
|
}
|
|
233
|
-
const sellerMakesOfferElemMatch4event = (
|
|
234
|
-
if (typeof ((
|
|
232
|
+
const sellerMakesOfferElemMatch4event = (_r = (_q = (_p = params.offers) === null || _p === void 0 ? void 0 : _p.seller) === null || _q === void 0 ? void 0 : _q.makesOffer) === null || _r === void 0 ? void 0 : _r.$elemMatch;
|
|
233
|
+
if (typeof ((_s = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _s === void 0 ? void 0 : _s.$eq) === 'string') {
|
|
235
234
|
andConditions.push({
|
|
236
235
|
'offers.seller.makesOffer': {
|
|
237
236
|
$exists: true,
|
|
@@ -239,7 +238,7 @@ class EventRepo {
|
|
|
239
238
|
}
|
|
240
239
|
});
|
|
241
240
|
}
|
|
242
|
-
const reservationForIdentifierEq = (
|
|
241
|
+
const reservationForIdentifierEq = (_x = (_w = (_v = (_u = (_t = params.offers) === null || _t === void 0 ? void 0 : _t.itemOffered) === null || _u === void 0 ? void 0 : _u.serviceOutput) === null || _v === void 0 ? void 0 : _v.reservationFor) === null || _w === void 0 ? void 0 : _w.identifier) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
243
242
|
if (typeof reservationForIdentifierEq === 'string') {
|
|
244
243
|
andConditions.push({
|
|
245
244
|
'offers.itemOffered.serviceOutput.reservationFor.identifier': {
|
|
@@ -248,7 +247,7 @@ class EventRepo {
|
|
|
248
247
|
}
|
|
249
248
|
});
|
|
250
249
|
}
|
|
251
|
-
const reservationForArrivalBusStopBranchCodeEq = (
|
|
250
|
+
const reservationForArrivalBusStopBranchCodeEq = (_3 = (_2 = (_1 = (_0 = (_z = (_y = params.offers) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.serviceOutput) === null || _0 === void 0 ? void 0 : _0.reservationFor) === null || _1 === void 0 ? void 0 : _1.arrivalBusStop) === null || _2 === void 0 ? void 0 : _2.branchCode) === null || _3 === void 0 ? void 0 : _3.$eq;
|
|
252
251
|
if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
|
|
253
252
|
andConditions.push({
|
|
254
253
|
'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
|
|
@@ -257,7 +256,7 @@ class EventRepo {
|
|
|
257
256
|
}
|
|
258
257
|
});
|
|
259
258
|
}
|
|
260
|
-
const reservationForDepartureBusStopBranchCodeEq = (
|
|
259
|
+
const reservationForDepartureBusStopBranchCodeEq = (_9 = (_8 = (_7 = (_6 = (_5 = (_4 = params.offers) === null || _4 === void 0 ? void 0 : _4.itemOffered) === null || _5 === void 0 ? void 0 : _5.serviceOutput) === null || _6 === void 0 ? void 0 : _6.reservationFor) === null || _7 === void 0 ? void 0 : _7.departureBusStop) === null || _8 === void 0 ? void 0 : _8.branchCode) === null || _9 === void 0 ? void 0 : _9.$eq;
|
|
261
260
|
if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
|
|
262
261
|
andConditions.push({
|
|
263
262
|
'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
|
|
@@ -291,7 +290,7 @@ class EventRepo {
|
|
|
291
290
|
}
|
|
292
291
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
293
292
|
/* istanbul ignore else */
|
|
294
|
-
const superEventLocationIdEq = (
|
|
293
|
+
const superEventLocationIdEq = (_12 = (_11 = (_10 = params.superEvent) === null || _10 === void 0 ? void 0 : _10.location) === null || _11 === void 0 ? void 0 : _11.id) === null || _12 === void 0 ? void 0 : _12.$eq;
|
|
295
294
|
if (typeof superEventLocationIdEq === 'string') {
|
|
296
295
|
andConditions.push({
|
|
297
296
|
'superEvent.location.id': {
|
|
@@ -334,7 +333,7 @@ class EventRepo {
|
|
|
334
333
|
});
|
|
335
334
|
}
|
|
336
335
|
}
|
|
337
|
-
const itemOfferedIdIn = (
|
|
336
|
+
const itemOfferedIdIn = (_15 = (_14 = (_13 = params.offers) === null || _13 === void 0 ? void 0 : _13.itemOffered) === null || _14 === void 0 ? void 0 : _14.id) === null || _15 === void 0 ? void 0 : _15.$in;
|
|
338
337
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
339
338
|
andConditions.push({
|
|
340
339
|
'offers.itemOffered.id': {
|
|
@@ -343,7 +342,7 @@ class EventRepo {
|
|
|
343
342
|
}
|
|
344
343
|
});
|
|
345
344
|
}
|
|
346
|
-
const itemOfferedTicketedSeatTypeOfIn = (
|
|
345
|
+
const itemOfferedTicketedSeatTypeOfIn = (_20 = (_19 = (_18 = (_17 = (_16 = params.offers) === null || _16 === void 0 ? void 0 : _16.itemOffered) === null || _17 === void 0 ? void 0 : _17.serviceOutput) === null || _18 === void 0 ? void 0 : _18.reservedTicket) === null || _19 === void 0 ? void 0 : _19.ticketedSeat) === null || _20 === void 0 ? void 0 : _20.typeOfs;
|
|
347
346
|
if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
|
|
348
347
|
andConditions.push({
|
|
349
348
|
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
@@ -352,7 +351,7 @@ class EventRepo {
|
|
|
352
351
|
}
|
|
353
352
|
});
|
|
354
353
|
}
|
|
355
|
-
const itemOfferedServiceTypeIdIn = (
|
|
354
|
+
const itemOfferedServiceTypeIdIn = (_23 = (_22 = (_21 = params.offers) === null || _21 === void 0 ? void 0 : _21.itemOffered) === null || _22 === void 0 ? void 0 : _22.serviceType) === null || _23 === void 0 ? void 0 : _23.ids;
|
|
356
355
|
if (Array.isArray(itemOfferedServiceTypeIdIn)) {
|
|
357
356
|
andConditions.push({
|
|
358
357
|
'offers.itemOffered.serviceType.id': {
|
|
@@ -361,8 +360,8 @@ class EventRepo {
|
|
|
361
360
|
}
|
|
362
361
|
});
|
|
363
362
|
}
|
|
364
|
-
const sellerMakesOfferElemMatch = (
|
|
365
|
-
if (typeof ((
|
|
363
|
+
const sellerMakesOfferElemMatch = (_26 = (_25 = (_24 = params.offers) === null || _24 === void 0 ? void 0 : _24.seller) === null || _25 === void 0 ? void 0 : _25.makesOffer) === null || _26 === void 0 ? void 0 : _26.$elemMatch;
|
|
364
|
+
if (typeof ((_27 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _27 === void 0 ? void 0 : _27.$eq) === 'string') {
|
|
366
365
|
andConditions.push({
|
|
367
366
|
'offers.seller.makesOffer': {
|
|
368
367
|
$exists: true,
|
|
@@ -19,9 +19,6 @@ const schemaDefinition = {
|
|
|
19
19
|
// provider: [SchemaTypes.Mixed], // 廃止(2024-04-12~)
|
|
20
20
|
serviceOutput: mongoose_1.SchemaTypes.Mixed,
|
|
21
21
|
serviceType: mongoose_1.SchemaTypes.Mixed
|
|
22
|
-
// createdAt: SchemaTypes.Mixed,
|
|
23
|
-
// updatedAt: SchemaTypes.Mixed,
|
|
24
|
-
// __v: SchemaTypes.Mixed
|
|
25
22
|
};
|
|
26
23
|
const schemaOptions = {
|
|
27
24
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -65,6 +62,15 @@ const indexes = [
|
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
],
|
|
65
|
+
[
|
|
66
|
+
{ 'hasOfferCatalog.itemListElement.id': 1, productID: 1 },
|
|
67
|
+
{
|
|
68
|
+
name: 'offerCatalogItemId',
|
|
69
|
+
partialFilterExpression: {
|
|
70
|
+
'hasOfferCatalog.itemListElement.id': { $exists: true }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
],
|
|
68
74
|
[
|
|
69
75
|
{ 'serviceOutput.typeOf': 1, productID: 1 },
|
|
70
76
|
{
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -21,13 +21,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.OfferRepo = void 0;
|
|
24
|
-
const createDebug = require("debug");
|
|
25
24
|
const mongoose_1 = require("mongoose");
|
|
26
25
|
const factory = require("../factory");
|
|
27
26
|
const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
|
|
28
27
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
29
28
|
const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
|
|
30
|
-
const debug = createDebug('chevre-domain:repo:offer');
|
|
31
29
|
const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
|
|
32
30
|
/**
|
|
33
31
|
* 単価オファーリポジトリ
|
|
@@ -545,7 +543,6 @@ class OfferRepo {
|
|
|
545
543
|
});
|
|
546
544
|
let offers = [];
|
|
547
545
|
if (aggregateOfferIdsInDataCatalog.length > 0) {
|
|
548
|
-
debug('searchAllByIdsAndOfferCatalogId:searching offers...,aggregateOfferIdsInDataCatalog:', aggregateOfferIdsInDataCatalog, 'ids:', params.ids);
|
|
549
546
|
const searchOffersConditions = Object.assign({
|
|
550
547
|
// aggregateOffer.idで検索する(2023-09-09~)
|
|
551
548
|
parentOffer: { id: { $in: aggregateOfferIdsInDataCatalog } }, id: { $in: params.ids }, priceSpecification: {
|
|
@@ -30,8 +30,9 @@ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, '
|
|
|
30
30
|
numberOfItems?: number;
|
|
31
31
|
itemListElementTypeOf: factory.offerType.Offer | 'OfferCatalog';
|
|
32
32
|
};
|
|
33
|
+
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'additionalProperty' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced';
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* カタログリポジトリ
|
|
35
36
|
*/
|
|
36
37
|
export declare class OfferCatalogRepo {
|
|
37
38
|
private readonly offerCatalogModel;
|
|
@@ -105,7 +106,7 @@ export declare class OfferCatalogRepo {
|
|
|
105
106
|
};
|
|
106
107
|
};
|
|
107
108
|
}): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
108
|
-
|
|
109
|
+
projectFields(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>;
|
|
109
110
|
findItemListElementById(params: {
|
|
110
111
|
id: string;
|
|
111
112
|
project: {
|
|
@@ -133,6 +134,21 @@ export declare class OfferCatalogRepo {
|
|
|
133
134
|
id: string;
|
|
134
135
|
elementIndex: number;
|
|
135
136
|
}[]>;
|
|
137
|
+
/**
|
|
138
|
+
* カタログIDとアイテムIDからアイテムを全て検索する
|
|
139
|
+
*/
|
|
140
|
+
searchItemListElement(params: {
|
|
141
|
+
id: {
|
|
142
|
+
$in: string[];
|
|
143
|
+
};
|
|
144
|
+
itemListElement: {
|
|
145
|
+
id: {
|
|
146
|
+
$in: string[];
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
}): Promise<{
|
|
150
|
+
id: string;
|
|
151
|
+
}[]>;
|
|
136
152
|
deleteById(params: {
|
|
137
153
|
id: string;
|
|
138
154
|
}): Promise<void>;
|
|
@@ -155,3 +171,4 @@ export declare class OfferCatalogRepo {
|
|
|
155
171
|
_id: string;
|
|
156
172
|
}>>>;
|
|
157
173
|
}
|
|
174
|
+
export {};
|
|
@@ -23,8 +23,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.OfferCatalogRepo = void 0;
|
|
24
24
|
const factory = require("../factory");
|
|
25
25
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
26
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
27
|
+
'name',
|
|
28
|
+
'description',
|
|
29
|
+
'project',
|
|
30
|
+
'typeOf',
|
|
31
|
+
'identifier',
|
|
32
|
+
'itemOffered',
|
|
33
|
+
'additionalProperty',
|
|
34
|
+
'numberOfItems',
|
|
35
|
+
'itemListElementTypeOf',
|
|
36
|
+
'dateSynced'
|
|
37
|
+
];
|
|
26
38
|
/**
|
|
27
|
-
*
|
|
39
|
+
* カタログリポジトリ
|
|
28
40
|
*/
|
|
29
41
|
class OfferCatalogRepo {
|
|
30
42
|
constructor(connection) {
|
|
@@ -294,39 +306,44 @@ class OfferCatalogRepo {
|
|
|
294
306
|
.exec();
|
|
295
307
|
});
|
|
296
308
|
}
|
|
297
|
-
|
|
309
|
+
projectFields(params, inclusion) {
|
|
298
310
|
var _a;
|
|
299
311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
312
|
const conditions = OfferCatalogRepo.CREATE_MONGO_CONDITIONS(params);
|
|
301
313
|
const matchStages = conditions.map((condition) => {
|
|
302
314
|
return { $match: condition };
|
|
303
315
|
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
itemOffered: '$itemOffered',
|
|
317
|
-
additionalProperty: '$additionalProperty',
|
|
318
|
-
numberOfItems: {
|
|
316
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
317
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
318
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
// throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
322
|
+
}
|
|
323
|
+
const projection = Object.assign({ _id: 0, id: '$_id' }, Object.fromEntries(positiveProjectionFields.map((key) => {
|
|
324
|
+
let value;
|
|
325
|
+
switch (key) {
|
|
326
|
+
case 'numberOfItems':
|
|
327
|
+
value = {
|
|
319
328
|
$cond: {
|
|
320
329
|
if: { $isArray: '$itemListElement' },
|
|
321
330
|
then: { $size: '$itemListElement' },
|
|
322
331
|
else: 0
|
|
323
332
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
333
|
+
};
|
|
334
|
+
break;
|
|
335
|
+
case 'itemListElementTypeOf':
|
|
336
|
+
value = { $first: '$itemListElement.typeOf' };
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
value = 1;
|
|
329
340
|
}
|
|
341
|
+
return [key, value];
|
|
342
|
+
})));
|
|
343
|
+
const aggregate = this.offerCatalogModel.aggregate([
|
|
344
|
+
...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
|
|
345
|
+
...matchStages,
|
|
346
|
+
{ $project: projection }
|
|
330
347
|
]);
|
|
331
348
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
332
349
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
@@ -402,6 +419,37 @@ class OfferCatalogRepo {
|
|
|
402
419
|
.exec();
|
|
403
420
|
});
|
|
404
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* カタログIDとアイテムIDからアイテムを全て検索する
|
|
424
|
+
*/
|
|
425
|
+
searchItemListElement(params) {
|
|
426
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
427
|
+
const matchStages = [
|
|
428
|
+
{ $match: { _id: { $in: params.id.$in } } },
|
|
429
|
+
{ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElement.id.$in } } }
|
|
430
|
+
];
|
|
431
|
+
return this.offerCatalogModel.aggregate([
|
|
432
|
+
{
|
|
433
|
+
$unwind: {
|
|
434
|
+
path: '$itemListElement'
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
...matchStages,
|
|
438
|
+
{
|
|
439
|
+
$group: {
|
|
440
|
+
_id: '$itemListElement.id'
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
$project: {
|
|
445
|
+
_id: 0,
|
|
446
|
+
id: '$_id'
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
])
|
|
450
|
+
.exec();
|
|
451
|
+
});
|
|
452
|
+
}
|
|
405
453
|
deleteById(params) {
|
|
406
454
|
return __awaiter(this, void 0, void 0, function* () {
|
|
407
455
|
yield this.offerCatalogModel.findOneAndRemove({
|
|
@@ -29,12 +29,9 @@ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, '
|
|
|
29
29
|
numberOfItems?: number;
|
|
30
30
|
itemListElementTypeOf: factory.offerType.Offer;
|
|
31
31
|
};
|
|
32
|
-
type
|
|
33
|
-
type IProjection = {
|
|
34
|
-
[key in KeyOfOfferCatalogItem]?: 0 | 1;
|
|
35
|
-
};
|
|
32
|
+
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'additionalProperty' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced' | 'relatedOffer';
|
|
36
33
|
/**
|
|
37
|
-
*
|
|
34
|
+
* サブカタログリポジトリ
|
|
38
35
|
*/
|
|
39
36
|
export declare class OfferCatalogItemRepo {
|
|
40
37
|
private readonly offerCatalogItemModel;
|
|
@@ -93,7 +90,7 @@ export declare class OfferCatalogItemRepo {
|
|
|
93
90
|
};
|
|
94
91
|
}): Promise<void>;
|
|
95
92
|
count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
96
|
-
|
|
93
|
+
projectFields(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>;
|
|
97
94
|
findItemListElementById(params: {
|
|
98
95
|
id: string;
|
|
99
96
|
project: {
|