@chevre/domain 22.4.0-alpha.5 → 22.4.0

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.
@@ -9,9 +9,8 @@ mongoose.Model.on('index', (...args) => {
9
9
  console.error('******** index event emitted. ********\n', args);
10
10
  });
11
11
 
12
- const CODE = '068cb0ba-8529-4a2b-8cf5-890d5af9c536';
13
- const RESERVATION_ID = '589701779538948-0';
14
- // const RESERVATION_ID = '589701779538948-1';
12
+ const CODE = '06bca3f3-07d0-44be-b480-9579cae12755';
13
+ const RESERVATION_ID = '283632655638788-0';
15
14
 
16
15
  async function main() {
17
16
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
@@ -17,17 +17,17 @@ async function main() {
17
17
  {
18
18
  additionalProperty: [],
19
19
  addOn: [],
20
- alternateName: { en: '', ja: '20231223' },
20
+ alternateName: { en: '', ja: '2024092601' },
21
21
  availability: chevre.factory.itemAvailability.InStock,
22
22
  availableAtOrFrom: [],
23
23
  itemOffered: {
24
24
  typeOf: chevre.factory.product.ProductType.EventService,
25
25
  serviceOutput: {}
26
26
  },
27
- name: { ja: '20231223', en: '20231223' },
27
+ name: { ja: '2024092601', en: '2024092601' },
28
28
  priceCurrency: chevre.factory.priceCurrency.JPY,
29
29
  priceSpecification: {
30
- name: { en: '20231223', ja: '20231223' },
30
+ name: { en: '2024092601', ja: '2024092601' },
31
31
  price: PRICE,
32
32
  priceCurrency: chevre.factory.priceCurrency.JPY,
33
33
  referenceQuantity: {
@@ -45,42 +45,7 @@ async function main() {
45
45
  settings: { ignoreCategoryCodeChargeSpec: false },
46
46
  description: { en: '', ja: '' },
47
47
  hasMerchantReturnPolicy: [],
48
- identifier: '20231223',
49
- project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
50
- typeOf: chevre.factory.offerType.Offer
51
- },
52
- {
53
- additionalProperty: [],
54
- addOn: [],
55
- alternateName: { en: '', ja: '2023122302' },
56
- availability: chevre.factory.itemAvailability.InStock,
57
- availableAtOrFrom: [],
58
- itemOffered: {
59
- typeOf: chevre.factory.product.ProductType.EventService,
60
- serviceOutput: {}
61
- },
62
- name: { ja: '2023122302', en: '2023122302' },
63
- priceCurrency: chevre.factory.priceCurrency.JPY,
64
- priceSpecification: {
65
- name: { en: '2023122302', ja: '2023122302' },
66
- price: PRICE,
67
- priceCurrency: chevre.factory.priceCurrency.JPY,
68
- referenceQuantity: {
69
- typeOf: 'QuantitativeValue',
70
- value: 1,
71
- unitCode: chevre.factory.unitCode.C62
72
- },
73
- typeOf: chevre.factory.priceSpecificationType.UnitPriceSpecification,
74
- valueAddedTaxIncluded: true,
75
- accounting: {
76
- typeOf: 'Accounting',
77
- accountsReceivable: PRICE
78
- }
79
- },
80
- settings: { ignoreCategoryCodeChargeSpec: false },
81
- description: { en: '', ja: '' },
82
- hasMerchantReturnPolicy: [],
83
- identifier: '2023122302',
48
+ identifier: '2024092601',
84
49
  project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
85
50
  typeOf: chevre.factory.offerType.Offer
86
51
  }
@@ -825,11 +825,7 @@ class OfferRepo {
825
825
  /**
826
826
  * コードをキーにして冪等置換(2023-12-13~)
827
827
  */
828
- upsertByIdentifier(params
829
- // options?: {
830
- // replace?: boolean;
831
- // }
832
- ) {
828
+ upsertByIdentifier(params) {
833
829
  return __awaiter(this, void 0, void 0, function* () {
834
830
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
835
831
  const insertBulkWriteOps = [];
@@ -848,7 +844,6 @@ class OfferRepo {
848
844
  });
849
845
  const newOfferId = uniqid(); // setOnInsert時のみに利用する新ID
850
846
  // サブオファー最適化(2023-12-22~)
851
- // const subOffer: factory.aggregateOffer.ISubOffer = { ...p, id: newOfferId };
852
847
  const { project } = p, subOffer = __rest(p, ["project"]);
853
848
  const aggregateOffer = {
854
849
  project: p.project,
@@ -856,7 +851,6 @@ class OfferRepo {
856
851
  offers: [subOffer]
857
852
  };
858
853
  const setOnInsert = {
859
- // ...aggregateOffer,
860
854
  project: aggregateOffer.project,
861
855
  typeOf: aggregateOffer.typeOf,
862
856
  _id: newOfferId
@@ -876,37 +870,11 @@ class OfferRepo {
876
870
  if (insertBulkWriteOps.length > 0) {
877
871
  const bulkWriteResult = yield this.aggregateOfferModel.bulkWrite(insertBulkWriteOps, { ordered: false });
878
872
  // modifiedの場合upsertedIdsに含まれないので、idを検索する
879
- const modifiedOffers = yield this.aggregateOfferModel.find({ $or: queryFilters }, { _id: 1, 'offers.identifier': 1 })
880
- .exec()
881
- .then((docs) => docs.map((doc) => doc.toObject()));
882
- // params.forEach((p) => {
883
- // const originalAggregateOffer = modifiedOffers.find(((offer) => offer.offers[0]?.identifier === p.identifier));
884
- // if (originalAggregateOffer === undefined) {
885
- // // upsert後なので、必ず存在するはず
886
- // throw new factory.errors.NotFound(`${factory.offerType.AggregateOffer} [${p.identifier}]`);
887
- // }
888
- // // リソースのユニークネスを保証するfilter
889
- // const filter: Filter<factory.aggregateOffer.IAggregateOffer> = {
890
- // 'project.id': { $eq: p.project.id },
891
- // 'offers.identifier': { $exists: true, $eq: p.identifier }
892
- // };
893
- // // サブオファー最適化(2023-12-22~)
894
- // // const unitPriceOffer: factory.unitPriceOffer.IUnitPriceOffer = { ...p, id: originalAggregateOffer.id };
895
- // const { project, ...subOffer } = p;
896
- // const setOnUpdate: MatchKeysAndValues<factory.aggregateOffer.IAggregateOffer> = {
897
- // 'offers.0': subOffer
898
- // };
899
- // const updateOne: UpdateOneModel<factory.aggregateOffer.IAggregateOffer> = {
900
- // filter,
901
- // update: { $set: setOnUpdate },
902
- // upsert: false
903
- // };
904
- // updateBulkWriteOps.push({ updateOne });
905
- // });
906
- // if (updateBulkWriteOps.length > 0) {
907
- // const bulkWriteResult = await this.aggregateOfferModel.bulkWrite(updateBulkWriteOps, { ordered: false });
908
- // return { bulkWriteResult4insert, bulkWriteResult, modifiedOffers };
909
- // }
873
+ const modifiedOffers = yield this.aggregateOfferModel.find({ $or: queryFilters },
874
+ // { _id: 1, 'offers.identifier': 1 }
875
+ { _id: 0, id: '$_id' })
876
+ .lean() // lean(2024-09-26~)
877
+ .exec();
910
878
  return { bulkWriteResult, modifiedOffers };
911
879
  }
912
880
  });
@@ -63,23 +63,6 @@ class OfferItemConditionRepo {
63
63
  }
64
64
  return andConditions;
65
65
  }
66
- // public async findById(params: {
67
- // id: string;
68
- // }): Promise<factory.offerItemCondition.IOfferItemCondition> {
69
- // const doc = await this.offerItemConditionModel.findOne(
70
- // { _id: params.id },
71
- // {
72
- // __v: 0,
73
- // createdAt: 0,
74
- // updatedAt: 0
75
- // }
76
- // )
77
- // .exec();
78
- // if (doc === null) {
79
- // throw new factory.errors.NotFound(this.offerItemConditionModel.modelName);
80
- // }
81
- // return doc.toObject();
82
- // }
83
66
  projectFields(params,
84
67
  // projection?: IProjection
85
68
  inclusion) {
@@ -105,9 +105,6 @@ export declare class ReservationRepo {
105
105
  */
106
106
  now: Date;
107
107
  }): Promise<void>;
108
- /**
109
- * 発券する
110
- */
111
108
  /**
112
109
  * 入場する
113
110
  */
@@ -1022,50 +1022,6 @@ class ReservationRepo {
1022
1022
  }
1023
1023
  });
1024
1024
  }
1025
- /**
1026
- * 発券する
1027
- */
1028
- // public async checkIn(params: {
1029
- // id?: string | { $in?: string[] };
1030
- // reservationNumber?: string | { $in?: string[] };
1031
- // /**
1032
- // * modifiedTime
1033
- // */
1034
- // now: Date;
1035
- // }): Promise<void> {
1036
- // const conditions: any[] = [];
1037
- // if (typeof params.id === 'string') {
1038
- // if (params.id.length > 0) {
1039
- // conditions.push({ _id: { $eq: params.id } });
1040
- // }
1041
- // } else {
1042
- // const idIn = params.id?.$in;
1043
- // if (Array.isArray(idIn)) {
1044
- // conditions.push({ _id: { $in: idIn } });
1045
- // }
1046
- // }
1047
- // if (typeof params.reservationNumber === 'string') {
1048
- // if (params.reservationNumber.length > 0) {
1049
- // conditions.push({ reservationNumber: { $eq: params.reservationNumber } });
1050
- // }
1051
- // } else {
1052
- // const reservationNumberIn = params.reservationNumber?.$in;
1053
- // if (Array.isArray(reservationNumberIn)) {
1054
- // conditions.push({ reservationNumber: { $in: reservationNumberIn } });
1055
- // }
1056
- // }
1057
- // // 無条件で実行されないように
1058
- // if (conditions.length > 0) {
1059
- // await this.reservationModel.updateMany(
1060
- // { $and: conditions },
1061
- // {
1062
- // checkedIn: true,
1063
- // modifiedTime: params.now
1064
- // }
1065
- // )
1066
- // .exec();
1067
- // }
1068
- // }
1069
1025
  /**
1070
1026
  * 入場する
1071
1027
  */
@@ -3,7 +3,7 @@ import type { AuthorizationRepo } from '../../repo/authorization';
3
3
  import type { OrderRepo } from '../../repo/order';
4
4
  import type { ReservationRepo } from '../../repo/reservation';
5
5
  type AvailableReservationType = factory.reservationType.BusReservation | factory.reservationType.EventReservation;
6
- type IReservationResult = Pick<factory.reservation.IReservation<AvailableReservationType>, 'id' | 'additionalTicketText' | 'reservationStatus'> & {
6
+ type IReservationResult = Pick<factory.reservation.IReservation<AvailableReservationType>, 'id' | 'additionalTicketText' | 'checkedIn' | 'reservationStatus'> & {
7
7
  reservedTicket: {
8
8
  ticketType: Pick<factory.reservation.ITicketType<AvailableReservationType>, 'identifier'> & {
9
9
  name: {
@@ -43,19 +43,16 @@ function findByCode(params) {
43
43
  }
44
44
  const reservationFromRepo = yield repos.reservation.projectFieldsById({
45
45
  id: reservationId,
46
- inclusion: ['additionalTicketText', 'reservationStatus', 'reservedTicket']
46
+ inclusion: ['additionalTicketText', 'checkedIn', 'reservationStatus', 'reservedTicket']
47
47
  // exclusion: [] // discontinue(2024-08-08~)
48
48
  });
49
- const { id, additionalTicketText, reservationStatus, reservedTicket } = reservationFromRepo;
50
- const reservation = {
51
- id, additionalTicketText, reservationStatus,
52
- reservedTicket: {
49
+ const { id, additionalTicketText, checkedIn, reservationStatus, reservedTicket } = reservationFromRepo;
50
+ const reservation = Object.assign(Object.assign({ id, reservationStatus, reservedTicket: {
53
51
  ticketType: {
54
52
  identifier: reservedTicket.ticketType.identifier,
55
53
  name: { ja: (_a = reservedTicket.ticketType.name) === null || _a === void 0 ? void 0 : _a.ja }
56
54
  }
57
- }
58
- };
55
+ } }, (typeof additionalTicketText === 'string') ? { additionalTicketText } : undefined), (typeof checkedIn === 'boolean') ? { checkedIn } : undefined);
59
56
  return { reservation };
60
57
  });
61
58
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@chevre/factory": "4.384.0",
13
- "@cinerino/sdk": "10.10.0",
13
+ "@cinerino/sdk": "10.11.0",
14
14
  "@motionpicture/coa-service": "9.5.0",
15
15
  "@motionpicture/gmo-service": "5.3.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "22.4.0-alpha.5"
113
+ "version": "22.4.0"
114
114
  }