@chevre/domain 20.4.0-alpha.33 → 20.4.0-alpha.34

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.
@@ -11,7 +11,7 @@ async function main() {
11
11
  const taskRepo = new chevre.repository.Task(mongoose.connection);
12
12
 
13
13
  const result = await taskRepo.deleteByName({
14
- name: <any>'DeleteAuthorization'
14
+ name: <any>'deleteAuthorization'
15
15
  });
16
16
 
17
17
  console.log('deleted', result);
@@ -27,7 +27,8 @@ async function main() {
27
27
  validateOfferRateLimit: true,
28
28
  addSortIndex: true,
29
29
  limit: 100,
30
- page: 1
30
+ page: 1,
31
+ searchAddOns: true
31
32
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
32
33
  })({
33
34
  event: eventRepo,
@@ -0,0 +1,38 @@
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
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
12
+ const productRepo = new chevre.repository.Product(mongoose.connection);
13
+
14
+ const { offers } = await chevre.service.offer.product.search({
15
+ ids: ['7k7bbepxp', 'yyyyyy'],
16
+ project: { id: String(PROJECT_ID) },
17
+ itemOffered: { id: '62b90fef5b3eb4000b75150f' },
18
+ // seller?: {
19
+ // id: string;
20
+ // },
21
+ // availableAt?: {
22
+ // id: string;
23
+ // },
24
+ onlyValid: true,
25
+ // limit?: number,
26
+ // page?: number,
27
+ addSortIndex: false
28
+ })({
29
+ offer: offerRepo,
30
+ product: productRepo
31
+ });
32
+ console.log(offers.map((o) => `${o.sortIndex} ${o.id}`));
33
+ console.log(offers.length);
34
+ }
35
+
36
+ main()
37
+ .then(console.log)
38
+ .catch(console.error);
@@ -120,7 +120,7 @@ function addReservations(params) {
120
120
  onlyValid: true,
121
121
  addSortIndex: false,
122
122
  validateOfferRateLimit: true,
123
- searchAddOns: true
123
+ searchAddOns: false // false化(2023-03-02~)
124
124
  })(repos);
125
125
  ticketOffers = searchEventTicketOffersResult.ticketOffers;
126
126
  availableOffers = searchEventTicketOffersResult.unitPriceOffers;
@@ -310,12 +310,16 @@ function createReservations4transactionObject(params) {
310
310
  let acceptedAddOns = [];
311
311
  let availableAddOns;
312
312
  const acceptedAddOnParams = acceptedOffer.addOn;
313
- // availableAddOns = await searchAvailableAddOns({
314
- // project: { id: params.transaction.project.id },
315
- // ticketOffer,
316
- // availableAtOrFrom: params.availableAtOrFrom
317
- // })(repos);
318
- availableAddOns = ticketOffer.addOn;
313
+ if (Array.isArray(acceptedAddOnParams) && acceptedAddOnParams.length > 0) {
314
+ // アドオンオファー検索(2023-03-02~)
315
+ availableAddOns = yield searchAvailableAddOns({
316
+ ids: acceptedAddOnParams.map((acceptedAddOn) => String(acceptedAddOn.id)),
317
+ project: { id: params.transaction.project.id },
318
+ ticketOffer,
319
+ availableAtOrFrom: params.availableAtOrFrom
320
+ })(repos);
321
+ }
322
+ // availableAddOns = <factory.product.ITicketAddOn[] | undefined>ticketOffer.addOn;
319
323
  if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnParams)) {
320
324
  acceptedAddOns = availableAddOns.filter((availableAddOn) => acceptedAddOnParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id));
321
325
  }
@@ -345,63 +349,37 @@ function createReservations4transactionObject(params) {
345
349
  return reservations;
346
350
  });
347
351
  }
348
- // function searchAvailableAddOns(params: {
349
- // project: { id: string };
350
- // ticketOffer: factory.product.ITicketOffer;
351
- // availableAtOrFrom?: { id?: string };
352
- // }) {
353
- // return async (repos: {
354
- // offer: OfferRepo;
355
- // product: ProductRepo;
356
- // }) => {
357
- // const availableAddOns: factory.product.ITicketAddOn[] = [];
358
- // if (Array.isArray(params.ticketOffer.addOn)) {
359
- // const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
360
- // for (const addOnProductId of addOnProductIds) {
361
- // const { offers, product } = await OfferService.product.search({
362
- // // ids?: string[];
363
- // project: { id: params.project.id },
364
- // itemOffered: { id: addOnProductId },
365
- // onlyValid: true,
366
- // addSortIndex: false,
367
- // ...(typeof params.availableAtOrFrom?.id === 'string')
368
- // ? { availableAt: { id: params.availableAtOrFrom.id } }
369
- // : undefined
370
- // })(repos);
371
- // availableAddOns.push(...offers.map<factory.product.ITicketAddOn>((o) => {
372
- // const itemOffered4addOn: factory.offer.IItemOffered4addOn = {
373
- // description: product.description,
374
- // id: product.id,
375
- // name: product.name,
376
- // productID: product.productID,
377
- // typeOf: product.typeOf
378
- // };
379
- // const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
380
- // return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
381
- // });
382
- // if (unitPriceSpec?.typeOf !== factory.priceSpecificationType.UnitPriceSpecification) {
383
- // throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
384
- // }
385
- // return {
386
- // alternateName: o.alternateName,
387
- // availability: o.availability,
388
- // description: o.description,
389
- // id: String(o.id),
390
- // identifier: o.identifier,
391
- // itemOffered: itemOffered4addOn,
392
- // name: o.name,
393
- // priceCurrency: o.priceCurrency,
394
- // priceSpecification: unitPriceSpec,
395
- // typeOf: o.typeOf,
396
- // ...(o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined,
397
- // ...(o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined
398
- // };
399
- // }));
400
- // }
401
- // }
402
- // return availableAddOns;
403
- // };
404
- // }
352
+ function searchAvailableAddOns(params) {
353
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
354
+ var _a;
355
+ const availableAddOns = [];
356
+ if (Array.isArray(params.ticketOffer.addOn)) {
357
+ const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
358
+ for (const addOnProductId of addOnProductIds) {
359
+ const { offers, product } = yield OfferService.product.search(Object.assign({ ids: params.ids, project: { id: params.project.id }, itemOffered: { id: addOnProductId }, onlyValid: true, addSortIndex: false }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
360
+ ? { availableAt: { id: params.availableAtOrFrom.id } }
361
+ : undefined))(repos);
362
+ availableAddOns.push(...offers.map((o) => {
363
+ const itemOffered4addOn = {
364
+ description: product.description,
365
+ id: product.id,
366
+ name: product.name,
367
+ productID: product.productID,
368
+ typeOf: product.typeOf
369
+ };
370
+ const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
371
+ return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
372
+ });
373
+ if ((unitPriceSpec === null || unitPriceSpec === void 0 ? void 0 : unitPriceSpec.typeOf) !== factory.priceSpecificationType.UnitPriceSpecification) {
374
+ throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
375
+ }
376
+ return Object.assign(Object.assign({ alternateName: o.alternateName, availability: o.availability, description: o.description, id: String(o.id), identifier: o.identifier, itemOffered: itemOffered4addOn, name: o.name, priceCurrency: o.priceCurrency, priceSpecification: unitPriceSpec, typeOf: o.typeOf }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
377
+ }));
378
+ }
379
+ }
380
+ return availableAddOns;
381
+ });
382
+ }
405
383
  function getAcceptedSeatNumbersAndSeatSections(params) {
406
384
  const acceptedSeatNumbers = [];
407
385
  const acceptedSeatSections = [];
@@ -227,7 +227,7 @@ function validateAcceptedOffers(params) {
227
227
  onlyValid: true,
228
228
  addSortIndex: false,
229
229
  validateOfferRateLimit: true,
230
- searchAddOns: true
230
+ searchAddOns: false // false化(2023-03-02~)
231
231
  })(repos);
232
232
  // 利用可能なチケットオファーであれば受け入れる
233
233
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.4.0-alpha.33"
123
+ "version": "20.4.0-alpha.34"
124
124
  }