@chevre/domain 21.8.0-alpha.44 → 21.8.0-alpha.46

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.
@@ -0,0 +1,39 @@
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 aggregateOfferRepo = new chevre.repository.AggregateOffer(mongoose.connection);
10
+
11
+ const offers = await aggregateOfferRepo.search({
12
+ limit: 10,
13
+ // page: 1,
14
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
15
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
16
+ itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } },
17
+ // identifier: { $eq: '901' },
18
+ sort: {
19
+ 'priceSpecification.price': 1,
20
+ identifier: 1
21
+ }
22
+ });
23
+ console.log(offers);
24
+ console.log(offers.map((offer) => {
25
+ return `${offer.project.id} ${(<any>offer).offerCount} ${offer.offers[0].identifier} ${offer.offers[0].name.ja} ${offer.offers[0].priceSpecification.price}`;
26
+ }));
27
+ console.log(offers.length);
28
+
29
+ const aggregateOfferCount = await aggregateOfferRepo.count({
30
+ project: { id: { $eq: String(process.env.PROJECT_ID) } },
31
+ availability: { $eq: chevre.factory.itemAvailability.InStock },
32
+ itemOffered: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } }
33
+ });
34
+ console.log('aggregateOfferCount:', aggregateOfferCount);
35
+ }
36
+
37
+ main()
38
+ .then(console.log)
39
+ .catch(console.error);
@@ -30,7 +30,8 @@ async function main() {
30
30
  validateOfferRateLimit: true,
31
31
  addSortIndex: true,
32
32
  limit: 100,
33
- page: 1
33
+ page: 1,
34
+ useOffersAsPrimaryForcible: false
34
35
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
35
36
  })({
36
37
  event: eventRepo,
@@ -39,6 +40,7 @@ async function main() {
39
40
  priceSpecification: priceSpecificationRepo,
40
41
  product: productRepo
41
42
  });
43
+ console.log(ticketOffers);
42
44
  console.log(ticketOffers.map((o) => o.sortIndex));
43
45
  console.log(ticketOffers.length);
44
46
  }
@@ -21,6 +21,7 @@ async function main() {
21
21
  excludeAppliesToMovieTicket: false,
22
22
  useOffersAsPrimaryForcible: false
23
23
  });
24
+ console.log(offers);
24
25
  console.log(offers.map((offer) => {
25
26
  return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id} ${(<any>offer).offerIndex}`;
26
27
  }));
@@ -0,0 +1,27 @@
1
+ import { AnyExpression, Connection, PipelineStage } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ type IMatchStage = PipelineStage.Match;
4
+ type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
5
+ type IProjection = {
6
+ [key in KeyOfUnitPriceOffer]?: 0 | 1;
7
+ };
8
+ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPriceOffer & {
9
+ offerIndex?: number;
10
+ parentOffer?: {
11
+ id: string;
12
+ };
13
+ };
14
+ /**
15
+ * 集計オファーリポジトリ
16
+ */
17
+ export declare class MongoRepository {
18
+ private readonly aggregateOfferModel;
19
+ constructor(connection: Connection);
20
+ static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
21
+ static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
22
+ [field: string]: AnyExpression;
23
+ };
24
+ count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
25
+ search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
26
+ }
27
+ export {};
@@ -0,0 +1,476 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MongoRepository = void 0;
13
+ const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
14
+ /**
15
+ * 集計オファーリポジトリ
16
+ */
17
+ class MongoRepository {
18
+ constructor(connection) {
19
+ this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, aggregateOffer_1.schema);
20
+ }
21
+ // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
22
+ static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
23
+ 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, _28, _29, _30, _31, _32, _33, _34, _35, _36;
24
+ const matchStages = [];
25
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
26
+ if (typeof projectIdEq === 'string') {
27
+ matchStages.push({
28
+ $match: {
29
+ 'project.id': { $eq: projectIdEq }
30
+ }
31
+ });
32
+ }
33
+ const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
34
+ if (typeof idEq === 'string') {
35
+ matchStages.push({
36
+ $match: {
37
+ 'offers.id': { $eq: idEq }
38
+ }
39
+ });
40
+ }
41
+ const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
42
+ if (Array.isArray(idIn)) {
43
+ matchStages.push({
44
+ $match: {
45
+ 'offers.id': {
46
+ $in: idIn
47
+ }
48
+ }
49
+ });
50
+ }
51
+ const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
52
+ if (typeof identifierEq === 'string') {
53
+ matchStages.push({
54
+ $match: {
55
+ 'offers.identifier': {
56
+ $exists: true,
57
+ $eq: identifierEq
58
+ }
59
+ }
60
+ });
61
+ }
62
+ const identifierIn = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$in;
63
+ if (Array.isArray(identifierIn)) {
64
+ matchStages.push({
65
+ $match: {
66
+ 'offers.identifier': {
67
+ $exists: true,
68
+ $in: identifierIn
69
+ }
70
+ }
71
+ });
72
+ }
73
+ const identifierRegex = (_g = params.identifier) === null || _g === void 0 ? void 0 : _g.$regex;
74
+ if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
75
+ matchStages.push({
76
+ $match: {
77
+ 'offers.identifier': {
78
+ $exists: true,
79
+ $regex: new RegExp(identifierRegex)
80
+ }
81
+ }
82
+ });
83
+ }
84
+ const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
85
+ if (typeof nameRegex === 'string' && nameRegex.length > 0) {
86
+ const nameRegexExp = new RegExp(nameRegex);
87
+ matchStages.push({
88
+ $match: {
89
+ $or: [
90
+ {
91
+ 'offers.name.ja': {
92
+ $exists: true,
93
+ $regex: nameRegexExp
94
+ }
95
+ },
96
+ {
97
+ 'offers.name.en': {
98
+ $exists: true,
99
+ $regex: nameRegexExp
100
+ }
101
+ },
102
+ {
103
+ 'offers.alternateName.ja': {
104
+ $exists: true,
105
+ $regex: nameRegexExp
106
+ }
107
+ },
108
+ {
109
+ 'offers.alternateName.en': {
110
+ $exists: true,
111
+ $regex: nameRegexExp
112
+ }
113
+ }
114
+ ]
115
+ }
116
+ });
117
+ }
118
+ const itemOfferedTypeOfEq = (_k = (_j = params.itemOffered) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$eq;
119
+ if (typeof itemOfferedTypeOfEq === 'string') {
120
+ matchStages.push({
121
+ $match: {
122
+ 'offers.itemOffered.typeOf': {
123
+ $exists: true,
124
+ $eq: itemOfferedTypeOfEq
125
+ }
126
+ }
127
+ });
128
+ }
129
+ const categoryCodeValueIn = (_m = (_l = params.category) === null || _l === void 0 ? void 0 : _l.codeValue) === null || _m === void 0 ? void 0 : _m.$in;
130
+ if (Array.isArray(categoryCodeValueIn)) {
131
+ matchStages.push({
132
+ $match: {
133
+ 'offers.category.codeValue': {
134
+ $exists: true,
135
+ $in: categoryCodeValueIn
136
+ }
137
+ }
138
+ });
139
+ }
140
+ const eligibleMembershipTypeCodeValueEq = (_p = (_o = params.eligibleMembershipType) === null || _o === void 0 ? void 0 : _o.codeValue) === null || _p === void 0 ? void 0 : _p.$eq;
141
+ if (typeof eligibleMembershipTypeCodeValueEq === 'string') {
142
+ matchStages.push({
143
+ $match: {
144
+ 'offers.eligibleMembershipType.codeValue': {
145
+ $exists: true,
146
+ $eq: eligibleMembershipTypeCodeValueEq
147
+ }
148
+ }
149
+ });
150
+ }
151
+ const eligibleMonetaryAmountCurrencyEq = (_r = (_q = params.eligibleMonetaryAmount) === null || _q === void 0 ? void 0 : _q.currency) === null || _r === void 0 ? void 0 : _r.$eq;
152
+ if (typeof eligibleMonetaryAmountCurrencyEq === 'string') {
153
+ matchStages.push({
154
+ $match: {
155
+ 'offers.eligibleMonetaryAmount.currency': {
156
+ $exists: true,
157
+ $eq: eligibleMonetaryAmountCurrencyEq
158
+ }
159
+ }
160
+ });
161
+ }
162
+ const eligibleSeatingTypeCodeValueEq = (_t = (_s = params.eligibleSeatingType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
163
+ if (typeof eligibleSeatingTypeCodeValueEq === 'string') {
164
+ matchStages.push({
165
+ $match: {
166
+ 'offers.eligibleSeatingType.codeValue': {
167
+ $exists: true,
168
+ $eq: eligibleSeatingTypeCodeValueEq
169
+ }
170
+ }
171
+ });
172
+ }
173
+ const appliesToMovieTicketServiceTypeExist = (_w = (_v = (_u = params.priceSpecification) === null || _u === void 0 ? void 0 : _u.appliesToMovieTicket) === null || _v === void 0 ? void 0 : _v.serviceType) === null || _w === void 0 ? void 0 : _w.$exists;
174
+ if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
175
+ matchStages.push({
176
+ $match: {
177
+ 'offers.priceSpecification.appliesToMovieTicket.serviceType': {
178
+ $exists: appliesToMovieTicketServiceTypeExist
179
+ }
180
+ }
181
+ });
182
+ }
183
+ const appliesToMovieTicketServiceTypeEq = (_z = (_y = (_x = params.priceSpecification) === null || _x === void 0 ? void 0 : _x.appliesToMovieTicket) === null || _y === void 0 ? void 0 : _y.serviceType) === null || _z === void 0 ? void 0 : _z.$eq;
184
+ if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
185
+ matchStages.push({
186
+ $match: {
187
+ 'offers.priceSpecification.appliesToMovieTicket.serviceType': {
188
+ $exists: true,
189
+ $eq: appliesToMovieTicketServiceTypeEq
190
+ }
191
+ }
192
+ });
193
+ }
194
+ const appliesToMovieTicketServiceOutputTypeOfEq = (_3 = (_2 = (_1 = (_0 = params.priceSpecification) === null || _0 === void 0 ? void 0 : _0.appliesToMovieTicket) === null || _1 === void 0 ? void 0 : _1.serviceOutput) === null || _2 === void 0 ? void 0 : _2.typeOf) === null || _3 === void 0 ? void 0 : _3.$eq;
195
+ if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
196
+ matchStages.push({
197
+ $match: {
198
+ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
199
+ $exists: true,
200
+ $eq: appliesToMovieTicketServiceOutputTypeOfEq
201
+ }
202
+ }
203
+ });
204
+ }
205
+ const appliesToMovieTicketServiceOutputTypeOfNin = (_7 = (_6 = (_5 = (_4 = params.priceSpecification) === null || _4 === void 0 ? void 0 : _4.appliesToMovieTicket) === null || _5 === void 0 ? void 0 : _5.serviceOutput) === null || _6 === void 0 ? void 0 : _6.typeOf) === null || _7 === void 0 ? void 0 : _7.$nin;
206
+ if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
207
+ matchStages.push({
208
+ $match: {
209
+ 'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
210
+ $nin: appliesToMovieTicketServiceOutputTypeOfNin
211
+ }
212
+ }
213
+ });
214
+ }
215
+ if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
216
+ const priceSpecificationPriceGte = (_8 = params.priceSpecification.price) === null || _8 === void 0 ? void 0 : _8.$gte;
217
+ if (typeof priceSpecificationPriceGte === 'number') {
218
+ matchStages.push({
219
+ $match: {
220
+ 'offers.priceSpecification.price': {
221
+ $exists: true,
222
+ $gte: priceSpecificationPriceGte
223
+ }
224
+ }
225
+ });
226
+ }
227
+ const priceSpecificationPriceLte = (_9 = params.priceSpecification.price) === null || _9 === void 0 ? void 0 : _9.$lte;
228
+ if (typeof priceSpecificationPriceLte === 'number') {
229
+ matchStages.push({
230
+ $match: {
231
+ 'offers.priceSpecification.price': {
232
+ $exists: true,
233
+ $lte: priceSpecificationPriceLte
234
+ }
235
+ }
236
+ });
237
+ }
238
+ const accountsReceivableGte = (_11 = (_10 = params.priceSpecification.accounting) === null || _10 === void 0 ? void 0 : _10.accountsReceivable) === null || _11 === void 0 ? void 0 : _11.$gte;
239
+ if (typeof accountsReceivableGte === 'number') {
240
+ matchStages.push({
241
+ $match: {
242
+ 'offers.priceSpecification.accounting.accountsReceivable': {
243
+ $exists: true,
244
+ $gte: accountsReceivableGte
245
+ }
246
+ }
247
+ });
248
+ }
249
+ const accountsReceivableLte = (_13 = (_12 = params.priceSpecification.accounting) === null || _12 === void 0 ? void 0 : _12.accountsReceivable) === null || _13 === void 0 ? void 0 : _13.$lte;
250
+ if (typeof accountsReceivableLte === 'number') {
251
+ matchStages.push({
252
+ $match: {
253
+ 'offers.priceSpecification.accounting.accountsReceivable': {
254
+ $exists: true,
255
+ $lte: accountsReceivableLte
256
+ }
257
+ }
258
+ });
259
+ }
260
+ const accountingCodeValueEq = (_16 = (_15 = (_14 = params.priceSpecification.accounting) === null || _14 === void 0 ? void 0 : _14.operatingRevenue) === null || _15 === void 0 ? void 0 : _15.codeValue) === null || _16 === void 0 ? void 0 : _16.$eq;
261
+ if (typeof accountingCodeValueEq === 'string') {
262
+ matchStages.push({
263
+ $match: {
264
+ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': {
265
+ $exists: true,
266
+ $eq: accountingCodeValueEq
267
+ }
268
+ }
269
+ });
270
+ }
271
+ const accountingCodeValueIn = (_19 = (_18 = (_17 = params.priceSpecification.accounting) === null || _17 === void 0 ? void 0 : _17.operatingRevenue) === null || _18 === void 0 ? void 0 : _18.codeValue) === null || _19 === void 0 ? void 0 : _19.$in;
272
+ if (Array.isArray(accountingCodeValueIn)) {
273
+ matchStages.push({
274
+ $match: {
275
+ 'offers.priceSpecification.accounting.operatingRevenue.codeValue': {
276
+ $exists: true,
277
+ $in: accountingCodeValueIn
278
+ }
279
+ }
280
+ });
281
+ }
282
+ const referenceQuantityValueEq = (_21 = (_20 = params.priceSpecification.referenceQuantity) === null || _20 === void 0 ? void 0 : _20.value) === null || _21 === void 0 ? void 0 : _21.$eq;
283
+ if (typeof referenceQuantityValueEq === 'number') {
284
+ matchStages.push({
285
+ $match: {
286
+ 'offers.priceSpecification.referenceQuantity.value': {
287
+ $exists: true,
288
+ $eq: referenceQuantityValueEq
289
+ }
290
+ }
291
+ });
292
+ }
293
+ }
294
+ const availabilityEq = (_22 = params.availability) === null || _22 === void 0 ? void 0 : _22.$eq;
295
+ if (typeof availabilityEq === 'string') {
296
+ matchStages.push({
297
+ $match: {
298
+ 'offers.availability': { $eq: availabilityEq }
299
+ }
300
+ });
301
+ }
302
+ const availableAtOrFromIdEq = (_24 = (_23 = params.availableAtOrFrom) === null || _23 === void 0 ? void 0 : _23.id) === null || _24 === void 0 ? void 0 : _24.$eq;
303
+ if (typeof availableAtOrFromIdEq === 'string') {
304
+ matchStages.push({
305
+ $match: {
306
+ 'offers.availableAtOrFrom.id': {
307
+ $exists: true,
308
+ $eq: availableAtOrFromIdEq
309
+ }
310
+ }
311
+ });
312
+ }
313
+ const availableAtOrFromIdIn = (_26 = (_25 = params.availableAtOrFrom) === null || _25 === void 0 ? void 0 : _25.id) === null || _26 === void 0 ? void 0 : _26.$in;
314
+ if (Array.isArray(availableAtOrFromIdIn)) {
315
+ matchStages.push({
316
+ $match: {
317
+ 'offers.availableAtOrFrom.id': {
318
+ $exists: true,
319
+ $in: availableAtOrFromIdIn
320
+ }
321
+ }
322
+ });
323
+ }
324
+ const addOnItemOfferedIdEq = (_29 = (_28 = (_27 = params.addOn) === null || _27 === void 0 ? void 0 : _27.itemOffered) === null || _28 === void 0 ? void 0 : _28.id) === null || _29 === void 0 ? void 0 : _29.$eq;
325
+ if (typeof addOnItemOfferedIdEq === 'string') {
326
+ matchStages.push({
327
+ $match: {
328
+ 'offers.addOn.itemOffered.id': { $exists: true, $eq: addOnItemOfferedIdEq }
329
+ }
330
+ });
331
+ }
332
+ const addOnItemOfferedIdIn = (_32 = (_31 = (_30 = params.addOn) === null || _30 === void 0 ? void 0 : _30.itemOffered) === null || _31 === void 0 ? void 0 : _31.id) === null || _32 === void 0 ? void 0 : _32.$in;
333
+ if (Array.isArray(addOnItemOfferedIdIn)) {
334
+ matchStages.push({
335
+ $match: {
336
+ 'offers.addOn.itemOffered.id': { $exists: true, $in: addOnItemOfferedIdIn }
337
+ }
338
+ });
339
+ }
340
+ const hasMerchantReturnPolicyIdEq = (_34 = (_33 = params.hasMerchantReturnPolicy) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$eq;
341
+ if (typeof hasMerchantReturnPolicyIdEq === 'string') {
342
+ matchStages.push({
343
+ $match: {
344
+ 'offers.hasMerchantReturnPolicy.id': {
345
+ $exists: true,
346
+ $eq: hasMerchantReturnPolicyIdEq
347
+ }
348
+ }
349
+ });
350
+ }
351
+ const additionalPropertyAll = (_35 = params.additionalProperty) === null || _35 === void 0 ? void 0 : _35.$all;
352
+ if (Array.isArray(additionalPropertyAll)) {
353
+ matchStages.push({
354
+ $match: {
355
+ 'offers.additionalProperty': {
356
+ $exists: true,
357
+ $all: additionalPropertyAll
358
+ }
359
+ }
360
+ });
361
+ }
362
+ const additionalPropertyElemMatch = (_36 = params.additionalProperty) === null || _36 === void 0 ? void 0 : _36.$elemMatch;
363
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
364
+ matchStages.push({
365
+ $match: {
366
+ 'offers.additionalProperty': {
367
+ $exists: true,
368
+ $elemMatch: additionalPropertyElemMatch
369
+ }
370
+ }
371
+ });
372
+ }
373
+ if (params.onlyValid === true) {
374
+ const now = new Date();
375
+ matchStages.push({
376
+ $match: {
377
+ $or: [
378
+ { 'offers.validFrom': { $exists: false } },
379
+ { 'offers.validFrom': { $exists: true, $lte: now } }
380
+ ]
381
+ }
382
+ }, {
383
+ $match: {
384
+ $or: [
385
+ { 'offers.validThrough': { $exists: false } },
386
+ { 'offers.validThrough': { $exists: true, $gte: now } }
387
+ ]
388
+ }
389
+ });
390
+ }
391
+ return matchStages;
392
+ }
393
+ static CREATE_AGGREGATE_OFFERS_PROJECTION(params) {
394
+ const projectStage = {
395
+ _id: 0,
396
+ id: '$_id',
397
+ typeOf: '$typeOf',
398
+ project: '$project',
399
+ offers: [{ $first: '$offers' }],
400
+ highPrice: { $max: '$offers.priceSpecification.price' },
401
+ lowPrice: { $min: '$offers.priceSpecification.price' },
402
+ offerCount: { $size: '$offers' }
403
+ };
404
+ const positiveProjectionFields = Object.keys(params)
405
+ .filter((key) => params[key] !== 0);
406
+ const negativeProjectionFields = Object.keys(params)
407
+ .filter((key) => params[key] === 0);
408
+ if (positiveProjectionFields.length > 0) {
409
+ // projectStage = {
410
+ // _id: 0,
411
+ // offerIndex: `$${OFFERS_ARRAY_INDEX_NAME}`,
412
+ // parentOffer: {
413
+ // id: '$_id'
414
+ // }
415
+ // };
416
+ // positiveProjectionFields.forEach((field) => {
417
+ // projectStage[field] = `$offers.${field}`;
418
+ // });
419
+ }
420
+ else if (negativeProjectionFields.length > 0) {
421
+ negativeProjectionFields.forEach((field) => {
422
+ if (typeof projectStage[field] === 'string') {
423
+ // tslint:disable-next-line:no-dynamic-delete
424
+ delete projectStage[field];
425
+ }
426
+ });
427
+ }
428
+ return projectStage;
429
+ }
430
+ count(params) {
431
+ return __awaiter(this, void 0, void 0, function* () {
432
+ const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
433
+ const [{ offerCount }] = yield this.aggregateOfferModel.aggregate([
434
+ ...matchStages,
435
+ {
436
+ $count: 'offerCount'
437
+ }
438
+ ])
439
+ .exec();
440
+ return offerCount;
441
+ });
442
+ }
443
+ search(params, projection) {
444
+ var _a, _b;
445
+ return __awaiter(this, void 0, void 0, function* () {
446
+ const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
447
+ const projectStage = MongoRepository.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
448
+ const sortByPrice = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'];
449
+ const sortByIdentifier = (_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier;
450
+ const aggregate = this.aggregateOfferModel.aggregate([
451
+ ...matchStages,
452
+ ...(typeof sortByPrice === 'number' || typeof sortByIdentifier === 'number')
453
+ ? [
454
+ {
455
+ $sort: Object.assign(Object.assign({}, (typeof sortByPrice === 'number')
456
+ ? { 'offers.priceSpecification.price': sortByPrice }
457
+ : undefined), (typeof sortByIdentifier === 'number')
458
+ ? { 'offers.identifier': sortByIdentifier }
459
+ : undefined)
460
+ }
461
+ ]
462
+ : [],
463
+ { $project: projectStage }
464
+ ]);
465
+ // tslint:disable-next-line:no-single-line-block-comment
466
+ /* istanbul ignore else */
467
+ if (typeof params.limit === 'number' && params.limit > 0) {
468
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
469
+ aggregate.limit(params.limit * page)
470
+ .skip(params.limit * (page - 1));
471
+ }
472
+ return aggregate.exec();
473
+ });
474
+ }
475
+ }
476
+ exports.MongoRepository = MongoRepository;
@@ -55,22 +55,22 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
55
55
  object?: any;
56
56
  typeOf?: string | undefined;
57
57
  project?: any;
58
- code?: string | undefined;
59
58
  validFrom?: Date | undefined;
59
+ code?: string | undefined;
60
60
  validUntil?: Date | undefined;
61
61
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
62
62
  object?: any;
63
63
  typeOf?: string | undefined;
64
64
  project?: any;
65
- code?: string | undefined;
66
65
  validFrom?: Date | undefined;
66
+ code?: string | undefined;
67
67
  validUntil?: Date | undefined;
68
68
  }>> & Omit<import("mongoose").FlatRecord<{
69
69
  object?: any;
70
70
  typeOf?: string | undefined;
71
71
  project?: any;
72
- code?: string | undefined;
73
72
  validFrom?: Date | undefined;
73
+ code?: string | undefined;
74
74
  validUntil?: Date | undefined;
75
75
  }> & {
76
76
  _id: import("mongoose").Types.ObjectId;
@@ -59,6 +59,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
59
59
  additionalProperty?: any;
60
60
  identifier?: string | undefined;
61
61
  duration?: string | undefined;
62
+ offers?: any;
62
63
  alternativeHeadline?: string | undefined;
63
64
  copyrightYear?: number | undefined;
64
65
  datePublished?: Date | undefined;
@@ -66,7 +67,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
66
67
  headline?: string | undefined;
67
68
  thumbnailUrl?: string | undefined;
68
69
  contentRating?: string | undefined;
69
- offers?: any;
70
70
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
71
71
  typeOf: string;
72
72
  name?: any;
@@ -75,6 +75,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
75
75
  additionalProperty?: any;
76
76
  identifier?: string | undefined;
77
77
  duration?: string | undefined;
78
+ offers?: any;
78
79
  alternativeHeadline?: string | undefined;
79
80
  copyrightYear?: number | undefined;
80
81
  datePublished?: Date | undefined;
@@ -82,7 +83,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
82
83
  headline?: string | undefined;
83
84
  thumbnailUrl?: string | undefined;
84
85
  contentRating?: string | undefined;
85
- offers?: any;
86
86
  }>> & Omit<import("mongoose").FlatRecord<{
87
87
  typeOf: string;
88
88
  name?: any;
@@ -91,6 +91,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
91
91
  additionalProperty?: any;
92
92
  identifier?: string | undefined;
93
93
  duration?: string | undefined;
94
+ offers?: any;
94
95
  alternativeHeadline?: string | undefined;
95
96
  copyrightYear?: number | undefined;
96
97
  datePublished?: Date | undefined;
@@ -98,7 +99,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
98
99
  headline?: string | undefined;
99
100
  thumbnailUrl?: string | undefined;
100
101
  contentRating?: string | undefined;
101
- offers?: any;
102
102
  }> & {
103
103
  _id: import("mongoose").Types.ObjectId;
104
104
  }, never>>;
@@ -67,9 +67,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
67
67
  endDate?: Date | undefined;
68
68
  location?: any;
69
69
  duration?: string | undefined;
70
+ offers?: any;
70
71
  alternativeHeadline?: any;
71
72
  headline?: any;
72
- offers?: any;
73
73
  doorTime?: Date | undefined;
74
74
  eventStatus?: string | undefined;
75
75
  superEvent?: any;
@@ -101,9 +101,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
101
101
  endDate?: Date | undefined;
102
102
  location?: any;
103
103
  duration?: string | undefined;
104
+ offers?: any;
104
105
  alternativeHeadline?: any;
105
106
  headline?: any;
106
- offers?: any;
107
107
  doorTime?: Date | undefined;
108
108
  eventStatus?: string | undefined;
109
109
  superEvent?: any;
@@ -135,9 +135,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
135
135
  endDate?: Date | undefined;
136
136
  location?: any;
137
137
  duration?: string | undefined;
138
+ offers?: any;
138
139
  alternativeHeadline?: any;
139
140
  headline?: any;
140
- offers?: any;
141
141
  doorTime?: Date | undefined;
142
142
  eventStatus?: string | undefined;
143
143
  superEvent?: any;
@@ -52,9 +52,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
52
52
  };
53
53
  }, {
54
54
  additionalProperty: any[];
55
- addOn: any[];
56
55
  availability: string;
57
56
  availableAtOrFrom: any[];
57
+ addOn: any[];
58
58
  _id?: string | undefined;
59
59
  name?: any;
60
60
  typeOf?: string | undefined;
@@ -64,28 +64,28 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
64
64
  description?: any;
65
65
  identifier?: string | undefined;
66
66
  itemOffered?: any;
67
- eligibleQuantity?: any;
67
+ priceSpecification?: any;
68
68
  color?: any;
69
- validFrom?: Date | undefined;
70
69
  category?: any;
71
- advanceBookingRequirement?: any;
72
- hasMerchantReturnPolicy?: any;
73
- priceSpecification?: any;
74
- eligibleCustomerType?: any;
75
- eligibleDuration?: any;
70
+ eligibleSeatingType?: any;
76
71
  eligibleMembershipType?: any;
77
72
  eligibleMonetaryAmount?: any;
78
- eligibleRegion?: any;
79
- eligibleSeatingType?: any;
80
73
  eligibleSubReservation?: any;
81
- settings?: any;
74
+ validFrom?: Date | undefined;
82
75
  validThrough?: Date | undefined;
83
76
  validRateLimit?: any;
77
+ advanceBookingRequirement?: any;
78
+ hasMerchantReturnPolicy?: any;
79
+ settings?: any;
80
+ eligibleQuantity?: any;
81
+ eligibleCustomerType?: any;
82
+ eligibleDuration?: any;
83
+ eligibleRegion?: any;
84
84
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
85
85
  additionalProperty: any[];
86
- addOn: any[];
87
86
  availability: string;
88
87
  availableAtOrFrom: any[];
88
+ addOn: any[];
89
89
  _id?: string | undefined;
90
90
  name?: any;
91
91
  typeOf?: string | undefined;
@@ -95,28 +95,28 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
95
95
  description?: any;
96
96
  identifier?: string | undefined;
97
97
  itemOffered?: any;
98
- eligibleQuantity?: any;
98
+ priceSpecification?: any;
99
99
  color?: any;
100
- validFrom?: Date | undefined;
101
100
  category?: any;
102
- advanceBookingRequirement?: any;
103
- hasMerchantReturnPolicy?: any;
104
- priceSpecification?: any;
105
- eligibleCustomerType?: any;
106
- eligibleDuration?: any;
101
+ eligibleSeatingType?: any;
107
102
  eligibleMembershipType?: any;
108
103
  eligibleMonetaryAmount?: any;
109
- eligibleRegion?: any;
110
- eligibleSeatingType?: any;
111
104
  eligibleSubReservation?: any;
112
- settings?: any;
105
+ validFrom?: Date | undefined;
113
106
  validThrough?: Date | undefined;
114
107
  validRateLimit?: any;
108
+ advanceBookingRequirement?: any;
109
+ hasMerchantReturnPolicy?: any;
110
+ settings?: any;
111
+ eligibleQuantity?: any;
112
+ eligibleCustomerType?: any;
113
+ eligibleDuration?: any;
114
+ eligibleRegion?: any;
115
115
  }>> & Omit<import("mongoose").FlatRecord<{
116
116
  additionalProperty: any[];
117
- addOn: any[];
118
117
  availability: string;
119
118
  availableAtOrFrom: any[];
119
+ addOn: any[];
120
120
  _id?: string | undefined;
121
121
  name?: any;
122
122
  typeOf?: string | undefined;
@@ -126,23 +126,23 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
126
126
  description?: any;
127
127
  identifier?: string | undefined;
128
128
  itemOffered?: any;
129
- eligibleQuantity?: any;
129
+ priceSpecification?: any;
130
130
  color?: any;
131
- validFrom?: Date | undefined;
132
131
  category?: any;
133
- advanceBookingRequirement?: any;
134
- hasMerchantReturnPolicy?: any;
135
- priceSpecification?: any;
136
- eligibleCustomerType?: any;
137
- eligibleDuration?: any;
132
+ eligibleSeatingType?: any;
138
133
  eligibleMembershipType?: any;
139
134
  eligibleMonetaryAmount?: any;
140
- eligibleRegion?: any;
141
- eligibleSeatingType?: any;
142
135
  eligibleSubReservation?: any;
143
- settings?: any;
136
+ validFrom?: Date | undefined;
144
137
  validThrough?: Date | undefined;
145
138
  validRateLimit?: any;
139
+ advanceBookingRequirement?: any;
140
+ hasMerchantReturnPolicy?: any;
141
+ settings?: any;
142
+ eligibleQuantity?: any;
143
+ eligibleCustomerType?: any;
144
+ eligibleDuration?: any;
145
+ eligibleRegion?: any;
146
146
  }> & Required<{
147
147
  _id: string;
148
148
  }>, never>>;
@@ -57,36 +57,36 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
57
57
  name?: any;
58
58
  project?: any;
59
59
  priceCurrency?: string | undefined;
60
+ validFrom?: Date | undefined;
61
+ validThrough?: Date | undefined;
62
+ appliesToMovieTicket?: any;
60
63
  valueAddedTaxIncluded?: boolean | undefined;
61
64
  appliesToCategoryCode?: any;
62
65
  appliesToVideoFormat?: string | undefined;
63
- appliesToMovieTicket?: any;
64
- validFrom?: Date | undefined;
65
- validThrough?: Date | undefined;
66
66
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
67
67
  typeOf: string;
68
68
  price: number;
69
69
  name?: any;
70
70
  project?: any;
71
71
  priceCurrency?: string | undefined;
72
+ validFrom?: Date | undefined;
73
+ validThrough?: Date | undefined;
74
+ appliesToMovieTicket?: any;
72
75
  valueAddedTaxIncluded?: boolean | undefined;
73
76
  appliesToCategoryCode?: any;
74
77
  appliesToVideoFormat?: string | undefined;
75
- appliesToMovieTicket?: any;
76
- validFrom?: Date | undefined;
77
- validThrough?: Date | undefined;
78
78
  }>> & Omit<import("mongoose").FlatRecord<{
79
79
  typeOf: string;
80
80
  price: number;
81
81
  name?: any;
82
82
  project?: any;
83
83
  priceCurrency?: string | undefined;
84
+ validFrom?: Date | undefined;
85
+ validThrough?: Date | undefined;
86
+ appliesToMovieTicket?: any;
84
87
  valueAddedTaxIncluded?: boolean | undefined;
85
88
  appliesToCategoryCode?: any;
86
89
  appliesToVideoFormat?: string | undefined;
87
- appliesToMovieTicket?: any;
88
- validFrom?: Date | undefined;
89
- validThrough?: Date | undefined;
90
90
  }> & {
91
91
  _id: import("mongoose").Types.ObjectId;
92
92
  }, never>>;
@@ -54,8 +54,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
54
54
  }, {
55
55
  typeOf: string;
56
56
  additionalProperty: any[];
57
- provider: any[];
58
57
  offers: any[];
58
+ provider: any[];
59
59
  productID: string;
60
60
  name?: any;
61
61
  project?: any;
@@ -67,8 +67,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
67
67
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
68
68
  typeOf: string;
69
69
  additionalProperty: any[];
70
- provider: any[];
71
70
  offers: any[];
71
+ provider: any[];
72
72
  productID: string;
73
73
  name?: any;
74
74
  project?: any;
@@ -80,8 +80,8 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
80
80
  }>> & Omit<import("mongoose").FlatRecord<{
81
81
  typeOf: string;
82
82
  additionalProperty: any[];
83
- provider: any[];
84
83
  offers: any[];
84
+ provider: any[];
85
85
  productID: string;
86
86
  name?: any;
87
87
  project?: any;
@@ -56,27 +56,27 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
56
56
  _id?: string | undefined;
57
57
  name?: string | undefined;
58
58
  alternateName?: string | undefined;
59
+ settings?: any;
59
60
  logo?: string | undefined;
60
61
  aggregateReservation?: any;
61
- settings?: any;
62
62
  subscription?: any;
63
63
  }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
64
64
  typeOf: string;
65
65
  _id?: string | undefined;
66
66
  name?: string | undefined;
67
67
  alternateName?: string | undefined;
68
+ settings?: any;
68
69
  logo?: string | undefined;
69
70
  aggregateReservation?: any;
70
- settings?: any;
71
71
  subscription?: any;
72
72
  }>> & Omit<import("mongoose").FlatRecord<{
73
73
  typeOf: string;
74
74
  _id?: string | undefined;
75
75
  name?: string | undefined;
76
76
  alternateName?: string | undefined;
77
+ settings?: any;
77
78
  logo?: string | undefined;
78
79
  aggregateReservation?: any;
79
- settings?: any;
80
80
  subscription?: any;
81
81
  }> & Required<{
82
82
  _id: string;
@@ -32,6 +32,9 @@ type IProjection = {
32
32
  };
33
33
  export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPriceOffer & {
34
34
  offerIndex?: number;
35
+ parentOffer?: {
36
+ id: string;
37
+ };
35
38
  };
36
39
  /**
37
40
  * オファーリポジトリ
@@ -731,6 +731,9 @@ class MongoRepository {
731
731
  let projectStage = {
732
732
  _id: 0,
733
733
  offerIndex: `$${OFFERS_ARRAY_INDEX_NAME}`,
734
+ parentOffer: {
735
+ id: '$_id'
736
+ },
734
737
  typeOf: '$offers.typeOf',
735
738
  project: '$project',
736
739
  id: '$offers.id',
@@ -769,7 +772,10 @@ class MongoRepository {
769
772
  if (positiveProjectionFields.length > 0) {
770
773
  projectStage = {
771
774
  _id: 0,
772
- offerIndex: `$${OFFERS_ARRAY_INDEX_NAME}`
775
+ offerIndex: `$${OFFERS_ARRAY_INDEX_NAME}`,
776
+ parentOffer: {
777
+ id: '$_id'
778
+ }
773
779
  };
774
780
  positiveProjectionFields.forEach((field) => {
775
781
  projectStage[field] = `$offers.${field}`;
@@ -7,6 +7,7 @@ import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
7
7
  import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
8
8
  import { MongoRepository as ActionRepo } from './repo/action';
9
9
  import { MongoRepository as AdditionalPropertyRepo } from './repo/additionalProperty';
10
+ import { MongoRepository as AggregateOfferRepo } from './repo/aggregateOffer';
10
11
  import { MongoRepository as AggregationRepo } from './repo/aggregation';
11
12
  import { MongoRepository as AssetTransactionRepo } from './repo/assetTransaction';
12
13
  import { MongoRepository as CategoryCodeRepo } from './repo/categoryCode';
@@ -71,6 +72,8 @@ export declare class Action extends ActionRepo {
71
72
  */
72
73
  export declare class AdditionalProperty extends AdditionalPropertyRepo {
73
74
  }
75
+ export declare class AggregateOffer extends AggregateOfferRepo {
76
+ }
74
77
  export declare class Aggregation extends AggregationRepo {
75
78
  }
76
79
  export declare namespace action {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
3
+ exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
4
4
  // tslint:disable:max-classes-per-file completed-docs
5
5
  /**
6
6
  * リポジトリ
@@ -11,6 +11,7 @@ const accountTitle_1 = require("./repo/accountTitle");
11
11
  const accountTransaction_1 = require("./repo/accountTransaction");
12
12
  const action_1 = require("./repo/action");
13
13
  const additionalProperty_1 = require("./repo/additionalProperty");
14
+ const aggregateOffer_1 = require("./repo/aggregateOffer");
14
15
  const aggregation_1 = require("./repo/aggregation");
15
16
  const assetTransaction_1 = require("./repo/assetTransaction");
16
17
  const categoryCode_1 = require("./repo/categoryCode");
@@ -81,6 +82,9 @@ exports.Action = Action;
81
82
  class AdditionalProperty extends additionalProperty_1.MongoRepository {
82
83
  }
83
84
  exports.AdditionalProperty = AdditionalProperty;
85
+ class AggregateOffer extends aggregateOffer_1.MongoRepository {
86
+ }
87
+ exports.AggregateOffer = AggregateOffer;
84
88
  class Aggregation extends aggregation_1.MongoRepository {
85
89
  }
86
90
  exports.Aggregation = Aggregation;
@@ -1,10 +1,19 @@
1
1
  import * as factory from '../../factory';
2
2
  type IMovieTicketTypeChargeSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.MovieTicketTypeChargeSpecification>;
3
3
  type ICategoryCodeChargeSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.CategoryCodeChargeSpecification>;
4
+ type ITicketOffer = factory.product.ITicketOffer & {
5
+ offerIndex?: number;
6
+ parentOffer?: {
7
+ id: string;
8
+ };
9
+ };
4
10
  declare function createCompoundPriceSpec4event(params: {
5
11
  eligibleQuantity: factory.quantitativeValue.IQuantitativeValue<factory.unitCode.C62>;
6
12
  offer: factory.unitPriceOffer.IUnitPriceOffer & {
7
13
  offerIndex?: number;
14
+ parentOffer?: {
15
+ id: string;
16
+ };
8
17
  };
9
18
  movieTicketTypeChargeSpecs: IMovieTicketTypeChargeSpecification[];
10
19
  videoFormatChargeSpecs: ICategoryCodeChargeSpecification[];
@@ -13,8 +22,5 @@ declare function createCompoundPriceSpec4event(params: {
13
22
  availability?: factory.itemAvailability;
14
23
  addOn: factory.product.IMinimizedTicketAddOn[];
15
24
  sortIndex?: number;
16
- }): factory.product.ITicketOffer & {
17
- sortIndex?: number;
18
- offerIndex?: number;
19
- };
25
+ }): ITicketOffer;
20
26
  export { createCompoundPriceSpec4event };
@@ -75,12 +75,12 @@ function createCompoundPriceSpec4event(params) {
75
75
  priceComponent
76
76
  };
77
77
  // 必要な属性のみに限定(2023-02-24~)
78
- const { name, description, alternateName, color, typeOf, id, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex } = params.offer;
79
- return Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
78
+ const { name, description, alternateName, color, typeOf, id, availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered, offerIndex, parentOffer } = params.offer;
79
+ return Object.assign(Object.assign(Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
80
80
  availableAtOrFrom, category,
81
81
  eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
82
82
  priceCurrency,
83
83
  validFrom, validThrough, validRateLimit, additionalProperty,
84
- identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined);
84
+ identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined), (typeof offerIndex === 'number') ? { offerIndex } : undefined), (typeof (parentOffer === null || parentOffer === void 0 ? void 0 : parentOffer.id) === 'string') ? { parentOffer: { id: parentOffer.id } } : undefined);
85
85
  }
86
86
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -1,6 +1,12 @@
1
1
  import * as factory from '../../../factory';
2
2
  import { MongoRepository as OfferRepo } from '../../../repo/offer';
3
3
  import { MongoRepository as ProductRepo } from '../../../repo/product';
4
+ type ITicketOffer = factory.product.ITicketOffer & {
5
+ offerIndex?: number;
6
+ parentOffer?: {
7
+ id: string;
8
+ };
9
+ };
4
10
  /**
5
11
  * プロダクトオファーを検索する
6
12
  */
@@ -23,4 +29,5 @@ export declare function searchProductOffers(params: {
23
29
  }): (repos: {
24
30
  offer: OfferRepo;
25
31
  product: ProductRepo;
26
- }) => Promise<factory.product.ITicketOffer[]>;
32
+ }) => Promise<ITicketOffer[]>;
33
+ export {};
@@ -35,6 +35,7 @@ function searchProductOffers(params) {
35
35
  useOffersAsPrimaryForcible: params.useOffersAsPrimaryForcible
36
36
  });
37
37
  return offers.map((o) => {
38
+ var _a;
38
39
  let sortIndex;
39
40
  if (params.addSortIndex) {
40
41
  sortIndex = sortedOfferIds.indexOf(String(o.id));
@@ -48,7 +49,7 @@ function searchProductOffers(params) {
48
49
  ...(unitSpec !== undefined) ? [unitSpec] : []
49
50
  ]
50
51
  };
51
- return Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined);
52
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined), (typeof o.offerIndex === 'number') ? { offerIndex: o.offerIndex } : undefined), (typeof ((_a = o.parentOffer) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { parentOffer: { id: o.parentOffer.id } } : undefined);
52
53
  });
53
54
  });
54
55
  }
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.8.0-alpha.44"
120
+ "version": "21.8.0-alpha.46"
121
121
  }