@chevre/domain 22.1.0-alpha.2 → 22.1.0-alpha.4

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.
Files changed (26) hide show
  1. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +2 -3
  2. package/example/src/chevre/{searchEvents.ts → projectEventFields.ts} +6 -3
  3. package/example/src/chevre/{searchOrders.ts → projectOrderFields.ts} +9 -24
  4. package/example/src/chevre/searchScreeningEventSeries.ts +2 -3
  5. package/lib/chevre/repo/event.d.ts +3 -3
  6. package/lib/chevre/repo/event.js +51 -19
  7. package/lib/chevre/repo/order.d.ts +8 -6
  8. package/lib/chevre/repo/order.js +79 -41
  9. package/lib/chevre/service/aggregation/event/aggregateOffers.js +2 -2
  10. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -8
  11. package/lib/chevre/service/assetTransaction/pay.js +2 -2
  12. package/lib/chevre/service/assetTransaction/reserve/confirm.js +2 -2
  13. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -8
  14. package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
  15. package/lib/chevre/service/offer/onEventChanged.js +9 -17
  16. package/lib/chevre/service/order/deleteOrder.js +4 -2
  17. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +2 -2
  18. package/lib/chevre/service/payment.js +4 -4
  19. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -2
  20. package/lib/chevre/service/reserve/searchByOrder.js +2 -2
  21. package/lib/chevre/service/task/confirmReserveTransaction.js +2 -2
  22. package/lib/chevre/service/task/returnPayTransaction.js +2 -2
  23. package/lib/chevre/service/transaction/moneyTransfer.js +6 -6
  24. package/lib/chevre/service/transaction/returnOrder/preStart.js +7 -7
  25. package/lib/chevre/service/transaction/returnOrder.js +5 -5
  26. package/package.json +1 -1
@@ -15,7 +15,7 @@ async function main() {
15
15
  const events = <Pick<
16
16
  chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
17
17
  'id' | 'typeOf' | 'startDate' | 'project'
18
- >[]>await eventRepo.search<chevre.factory.eventType.ScreeningEvent>(
18
+ >[]>await eventRepo.projectFields<chevre.factory.eventType.ScreeningEvent>(
19
19
  {
20
20
  typeOf: chevre.factory.eventType.ScreeningEvent,
21
21
  project: { id: { $eq: PROJECT.id } },
@@ -26,8 +26,7 @@ async function main() {
26
26
  // startThrough: moment().add(1, 'day').toDate(),
27
27
  // startThrough: now
28
28
  },
29
- ['id', 'typeOf', 'startDate', 'project'],
30
- []
29
+ ['typeOf', 'startDate', 'project']
31
30
  );
32
31
 
33
32
  // console.log(events);
@@ -13,7 +13,7 @@ async function main() {
13
13
 
14
14
  const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
15
15
 
16
- const events = await eventRepo.search<chevre.factory.eventType.ScreeningEvent>(
16
+ const events = await eventRepo.projectFields<chevre.factory.eventType.ScreeningEvent>(
17
17
  {
18
18
  limit: 1,
19
19
  page: 1,
@@ -23,8 +23,11 @@ async function main() {
23
23
  // id: { $eq: '120162210202407171202250' }
24
24
  id: { $eq: 'blxonxv1m' }
25
25
  },
26
- ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered'],
27
- []
26
+ [
27
+ 'location', 'project', 'startDate', 'typeOf'
28
+ // 'superEvent.location.id'
29
+ // 'offers.itemOffered'
30
+ ]
28
31
  );
29
32
  // tslint:disable-next-line:no-null-keyword
30
33
  console.dir(events, { depth: null });
@@ -19,9 +19,11 @@ async function main() {
19
19
 
20
20
  const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
21
21
 
22
- const orders = await orderRepo.search(
22
+ const orders = await orderRepo.projectFields(
23
23
  {
24
- limit: 1,
24
+ limit: 3,
25
+ page: 1,
26
+ sort: { orderDate: -1 },
25
27
  project: { id: { $eq: project.id } },
26
28
  acceptedOffers: {
27
29
  // itemOffered: {
@@ -34,30 +36,13 @@ async function main() {
34
36
  // issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.MembershipService } }
35
37
  // }
36
38
  }
37
- // orderedItem: {
38
- // $size: 3
39
- // }
40
- // paymentMethods: {
41
- // paymentMethod: { identifier: { $in: ['Cash'] } }
42
- // additionalProperty: {
43
- // $in: [
44
- // { name: 'orderId', value: '0102022031518442020' },
45
- // { name: 'orderId', value: '0102022031518423030' }
46
- // ]
47
- // }
48
- // }
49
39
  },
50
40
  {
51
- inclusion: {
52
- confirmationNumber: 1,
53
- // customer: 1,
54
- identifier: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
55
- // orderedItem: 1,
56
- // paymentMethods: 1,
57
- price: 1, priceCurrency: 1, project: 1,
58
- // seller: 1,
59
- typeOf: 1
60
- }
41
+ inclusion: [
42
+ 'orderNumber', 'orderDate'
43
+ , 'paymentMethods.name'
44
+ // , 'confirmationNumber', 'identifier', 'orderDate', 'orderStatus', 'price', 'typeOf'
45
+ ]
61
46
  }
62
47
  );
63
48
  // tslint:disable-next-line:no-null-keyword
@@ -13,7 +13,7 @@ async function main() {
13
13
 
14
14
  const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
15
15
 
16
- const events = await eventRepo.search(
16
+ const events = await eventRepo.projectFields(
17
17
  {
18
18
  limit: 100,
19
19
  page: 1,
@@ -23,8 +23,7 @@ async function main() {
23
23
  // id: { $eq: 'al6aff83y' },
24
24
  typeOfIn: [chevre.factory.eventType.ScreeningEventSeries]
25
25
  },
26
- [],
27
- []
26
+ ['eventStatus']
28
27
  );
29
28
  console.log(events);
30
29
  console.log(events.length, 'events found');
@@ -69,7 +69,7 @@ interface IAggregateEvent {
69
69
  statuses: IStatus[];
70
70
  }
71
71
  export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
72
- type IKeyOfProjection<T extends factory.eventType> = keyof factory.event.IEvent<T> | '_id' | '__v' | 'createdAt' | 'updatedAt' | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered';
72
+ type IKeyOfProjection<T extends factory.eventType> = Exclude<keyof factory.event.IEvent<T>, 'id'> | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered';
73
73
  /**
74
74
  * minimizedEvent検索時のprojection候補
75
75
  * add(2024-07-18~)
@@ -162,9 +162,9 @@ export declare class EventRepo {
162
162
  id: string;
163
163
  }>;
164
164
  /**
165
- * イベントを検索する
165
+ * イベントを検索する(inclusion projection)
166
166
  */
167
- search<T extends factory.eventType>(params: ISearchConditions<T>, inclusion: IKeyOfProjection<T>[], exclusion?: IKeyOfProjection<T>[]): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]>;
167
+ projectFields<T extends factory.eventType>(params: ISearchConditions<T>, inclusion: IKeyOfProjection<T>[]): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]>;
168
168
  /**
169
169
  * IDのみで検索する
170
170
  * projectionなし
@@ -827,30 +827,62 @@ class EventRepo {
827
827
  // return <factory.event.IEvent<factory.eventType.ScreeningEvent>>doc.toObject();
828
828
  });
829
829
  }
830
+ // migrate to projectFields
831
+ // public async search<T extends factory.eventType>(
832
+ // params: ISearchConditions<T>,
833
+ // inclusion: IKeyOfProjection<T>[],
834
+ // exclusion?: IKeyOfProjection<T>[]
835
+ // ): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]> {
836
+ // const conditions = EventRepo.CREATE_MONGO_CONDITIONS<T>(params);
837
+ // let projection: IProjection<T> = {};
838
+ // if (Array.isArray(inclusion) && inclusion.length > 0) {
839
+ // inclusion.forEach((field) => {
840
+ // projection[field] = 1;
841
+ // });
842
+ // } else {
843
+ // projection = {
844
+ // __v: 0,
845
+ // createdAt: 0,
846
+ // updatedAt: 0
847
+ // };
848
+ // if (Array.isArray(exclusion) && exclusion.length > 0) {
849
+ // exclusion.forEach((field) => {
850
+ // projection[field] = 0;
851
+ // });
852
+ // }
853
+ // }
854
+ // const query = this.eventModel.find<HydratedDocument<factory.event.IEvent<T>>>({ $and: conditions }, projection);
855
+ // if (typeof params.limit === 'number' && params.limit > 0) {
856
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
857
+ // query.limit(params.limit)
858
+ // .skip(params.limit * (page - 1));
859
+ // }
860
+ // // tslint:disable-next-line:no-single-line-block-comment
861
+ // /* istanbul ignore else */
862
+ // if (params.sort?.startDate !== undefined) {
863
+ // query.sort({ startDate: params.sort.startDate });
864
+ // }
865
+ // return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
866
+ // .exec()
867
+ // .then((docs) => docs.map((doc) => doc.toObject()));
868
+ // }
830
869
  /**
831
- * イベントを検索する
870
+ * イベントを検索する(inclusion projection)
832
871
  */
833
- search(params, inclusion, exclusion) {
872
+ projectFields(params, inclusion) {
834
873
  var _a;
835
874
  return __awaiter(this, void 0, void 0, function* () {
836
875
  const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
837
876
  let projection = {};
877
+ const positiveProjectionFields = (Array.isArray(inclusion))
878
+ ? inclusion.filter((key) => key !== 'id' && key !== '_id')
879
+ : [];
838
880
  if (Array.isArray(inclusion) && inclusion.length > 0) {
839
- inclusion.forEach((field) => {
840
- projection[field] = 1;
841
- });
881
+ projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
842
882
  }
843
883
  else {
844
- projection = {
845
- __v: 0,
846
- createdAt: 0,
847
- updatedAt: 0
848
- };
849
- if (Array.isArray(exclusion) && exclusion.length > 0) {
850
- exclusion.forEach((field) => {
851
- projection[field] = 0;
852
- });
853
- }
884
+ // discontinue(2024-07-24~)
885
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
854
886
  }
855
887
  const query = this.eventModel.find({ $and: conditions }, projection);
856
888
  if (typeof params.limit === 'number' && params.limit > 0) {
@@ -872,8 +904,8 @@ class EventRepo {
872
904
  // console.log(explainResult);
873
905
  // return [];
874
906
  return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
875
- .exec()
876
- .then((docs) => docs.map((doc) => doc.toObject()));
907
+ .lean() // lean(2024-08-01~)
908
+ .exec();
877
909
  });
878
910
  }
879
911
  /**
@@ -960,7 +992,7 @@ class EventRepo {
960
992
  */
961
993
  syncScreeningEventSeries2screeningEvents(params) {
962
994
  return __awaiter(this, void 0, void 0, function* () {
963
- const superEvents = yield this.search({
995
+ const superEvents = yield this.projectFields({
964
996
  limit: 1,
965
997
  page: 1,
966
998
  typeOf: factory.eventType.ScreeningEventSeries,
@@ -970,7 +1002,7 @@ class EventRepo {
970
1002
  'additionalProperty', 'alternativeHeadline', 'description', 'dubLanguage',
971
1003
  'endDate', 'headline', 'kanaName', 'location', 'name',
972
1004
  'soundFormat', 'startDate', 'subtitleLanguage', 'typeOf', 'videoFormat', 'workPerformed'
973
- ], []);
1005
+ ]);
974
1006
  const superEventFromDB = superEvents.shift();
975
1007
  if (superEventFromDB === undefined) {
976
1008
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -55,7 +55,7 @@ export type IOrderOnStatusChanged = Pick<IOrderWithoutAcceptedOffers & {
55
55
  export declare class OrderRepo {
56
56
  private readonly orderModel;
57
57
  constructor(connection: Connection);
58
- static CREATE_MONGO_CONDITIONS(params: factory.order.ISearchConditions): FilterQuery<factory.order.IOrder>[];
58
+ static CREATE_MONGO_CONDITIONS(params: Omit<factory.order.ISearchConditions, 'limit' | 'page' | 'sort'>): FilterQuery<factory.order.IOrder>[];
59
59
  /**
60
60
  * なければ作成する
61
61
  */
@@ -149,12 +149,14 @@ export declare class OrderRepo {
149
149
  }): Promise<void>;
150
150
  count(params: factory.order.ISearchConditions): Promise<number>;
151
151
  /**
152
- * 注文を検索する
152
+ * 注文を検索する(inclusion projection)
153
+ * redefine from search(2024-07-31~)
153
154
  */
154
- search(params: factory.order.ISearchConditions, options: {
155
- inclusion: {
156
- [key in IKeyOfProjection]?: 1;
157
- };
155
+ projectFields(params: factory.order.ISearchConditions & {
156
+ limit: number;
157
+ page: number;
158
+ }, options: {
159
+ inclusion: IKeyOfProjection[];
158
160
  }): Promise<(IOrderWithoutAcceptedOffers & {
159
161
  id: string;
160
162
  })[]>;
@@ -988,51 +988,96 @@ class OrderRepo {
988
988
  .exec();
989
989
  });
990
990
  }
991
+ // migrate to projectFields(2024-07-31~)
992
+ // public async search(
993
+ // params: factory.order.ISearchConditions,
994
+ // // projection: { [key in IKeyOfProjection]?: 0 | 1 } // exclusion+inclusion(2024-07-26~)
995
+ // options: {
996
+ // inclusion: { [key in IKeyOfProjection]?: 1 };
997
+ // // exclusion: { [key in IKeyOfProjection]?: 0 }; // discontinue(2024-07-31~)
998
+ // }
999
+ // ): Promise<(IOrderWithoutAcceptedOffers & { id: string })[]> {
1000
+ // const { inclusion } = options;
1001
+ // const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1002
+ // let useInclusionProjection: boolean = false;
1003
+ // let projectStage: { [field: string]: AnyExpression } = {};
1004
+ // const positiveProjectionFields: string[] = (inclusion !== undefined && inclusion !== null)
1005
+ // ? Object.keys(inclusion)
1006
+ // .filter((key) => {
1007
+ // // return inclusion[<IKeyOfProjection>key] === 1
1008
+ // // && key !== 'acceptedOffers' // defaultで隠蔽(2023-12-06~)
1009
+ // // && key !== '_id'
1010
+ // // && key !== 'id';
1011
+ // return inclusion[<IKeyOfProjection>key] === 1
1012
+ // && AVAILABLE_PROJECT_FIELDS.includes(<IKeyOfProjection>key);
1013
+ // })
1014
+ // : [];
1015
+ // if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
1016
+ // useInclusionProjection = true;
1017
+ // projectStage = {
1018
+ // _id: 0, // hide _id(2024-07-25~)
1019
+ // id: { $toString: '$_id' }
1020
+ // };
1021
+ // positiveProjectionFields.forEach((field) => {
1022
+ // projectStage[field] = 1;
1023
+ // });
1024
+ // } else {
1025
+ // throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
1026
+ // // projectStage = {
1027
+ // // __v: 0,
1028
+ // // createdAt: 0,
1029
+ // // updatedAt: 0,
1030
+ // // acceptedOffers: 0, // defaultで隠蔽(2023-12-06~)
1031
+ // // ...exclusion
1032
+ // // };
1033
+ // }
1034
+ // const query = this.orderModel.find<HydratedDocument<IOrderWithoutAcceptedOffers & { id: string }>>(
1035
+ // (conditions.length > 0) ? { $and: conditions } : {},
1036
+ // projectStage
1037
+ // );
1038
+ // // .select(projectStage);
1039
+ // if (typeof params.limit === 'number' && params.limit > 0) {
1040
+ // const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1041
+ // query.limit(params.limit)
1042
+ // .skip(params.limit * (page - 1));
1043
+ // }
1044
+ // // tslint:disable-next-line:no-single-line-block-comment
1045
+ // /* istanbul ignore else */
1046
+ // if (params.sort?.orderDate !== undefined) {
1047
+ // query.sort({ orderDate: params.sort.orderDate });
1048
+ // }
1049
+ // // const explainResult = await (<any>query).explain();
1050
+ // // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
1051
+ // if (useInclusionProjection) {
1052
+ // return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
1053
+ // .lean<(IOrderWithoutAcceptedOffers & { id: string })[]>() // lean(2024-07-25~)
1054
+ // .exec();
1055
+ // } else {
1056
+ // return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
1057
+ // .exec()
1058
+ // .then((docs) => docs.map((doc) => doc.toObject()));
1059
+ // }
1060
+ // }
991
1061
  /**
992
- * 注文を検索する
1062
+ * 注文を検索する(inclusion projection)
1063
+ * redefine from search(2024-07-31~)
993
1064
  */
994
- search(params,
995
- // projection: { [key in IKeyOfProjection]?: 0 | 1 } // exclusion+inclusion(2024-07-26~)
996
- options) {
1065
+ projectFields(params, options) {
997
1066
  var _a;
998
1067
  return __awaiter(this, void 0, void 0, function* () {
999
1068
  const { inclusion } = options;
1000
1069
  const conditions = OrderRepo.CREATE_MONGO_CONDITIONS(params);
1001
- let useInclusionProjection = false;
1002
1070
  let projectStage = {};
1003
- const positiveProjectionFields = (inclusion !== undefined && inclusion !== null)
1004
- ? Object.keys(inclusion)
1005
- .filter((key) => {
1006
- // return inclusion[<IKeyOfProjection>key] === 1
1007
- // && key !== 'acceptedOffers' // defaultで隠蔽(2023-12-06~)
1008
- // && key !== '_id'
1009
- // && key !== 'id';
1010
- return inclusion[key] === 1
1011
- && AVAILABLE_PROJECT_FIELDS.includes(key);
1012
- })
1071
+ const positiveProjectionFields = (Array.isArray(inclusion))
1072
+ ? inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key))
1013
1073
  : [];
1014
1074
  if (Array.isArray(positiveProjectionFields) && positiveProjectionFields.length > 0) {
1015
- useInclusionProjection = true;
1016
- projectStage = {
1017
- _id: 0,
1018
- id: { $toString: '$_id' }
1019
- };
1020
- positiveProjectionFields.forEach((field) => {
1021
- projectStage[field] = 1;
1022
- });
1075
+ projectStage = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
1023
1076
  }
1024
1077
  else {
1025
1078
  throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
1026
- // projectStage = {
1027
- // __v: 0,
1028
- // createdAt: 0,
1029
- // updatedAt: 0,
1030
- // acceptedOffers: 0, // defaultで隠蔽(2023-12-06~)
1031
- // ...exclusion
1032
- // };
1033
1079
  }
1034
1080
  const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {}, projectStage);
1035
- // .select(projectStage);
1036
1081
  if (typeof params.limit === 'number' && params.limit > 0) {
1037
1082
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
1038
1083
  query.limit(params.limit)
@@ -1045,16 +1090,9 @@ class OrderRepo {
1045
1090
  }
1046
1091
  // const explainResult = await (<any>query).explain();
1047
1092
  // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
1048
- if (useInclusionProjection) {
1049
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1050
- .lean() // lean(2024-07-25~)
1051
- .exec();
1052
- }
1053
- else {
1054
- return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1055
- .exec()
1056
- .then((docs) => docs.map((doc) => doc.toObject()));
1057
- }
1093
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
1094
+ .lean() // lean(2024-07-25~)
1095
+ .exec();
1058
1096
  });
1059
1097
  }
1060
1098
  getCursor(conditions, projection) {
@@ -25,12 +25,12 @@ function aggregateOffers(params) {
25
25
  'location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered'
26
26
  ] // projection(2024-07-21~)
27
27
  );
28
- const eventCapacity = (yield repos.event.search({
28
+ const eventCapacity = (yield repos.event.projectFields({
29
29
  limit: 1,
30
30
  page: 1,
31
31
  id: { $eq: params.id },
32
32
  typeOf: params.typeOf
33
- }, ['maximumAttendeeCapacity', 'remainingAttendeeCapacity'], [])).shift();
33
+ }, ['maximumAttendeeCapacity', 'remainingAttendeeCapacity'])).shift();
34
34
  debug('processing aggregateOffersByEvent...', eventCapacity);
35
35
  yield aggregateOffersByEvent({
36
36
  event: Object.assign(Object.assign(Object.assign({}, event), (typeof (eventCapacity === null || eventCapacity === void 0 ? void 0 : eventCapacity.maximumAttendeeCapacity) === 'number')
@@ -40,7 +40,7 @@ function aggregateScreeningEvent(params) {
40
40
  .add(-1, 'second')
41
41
  .toDate();
42
42
  if (event.typeOf === factory.eventType.Event) {
43
- aggregatingEvents = yield repos.event.search({
43
+ aggregatingEvents = yield repos.event.projectFields({
44
44
  limit: 100,
45
45
  page: 1,
46
46
  project: { id: { $eq: event.project.id } },
@@ -49,12 +49,10 @@ function aggregateScreeningEvent(params) {
49
49
  startFrom: startFrom,
50
50
  startThrough: startThrough,
51
51
  location: { branchCode: { $eq: event.location.branchCode } }
52
- }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered'], []
53
- // PROJECTION_MINIMIZED_EVENT
54
- );
52
+ }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
55
53
  }
56
54
  else if (event.typeOf === factory.eventType.ScreeningEvent) {
57
- aggregatingEvents = yield repos.event.search({
55
+ aggregatingEvents = yield repos.event.projectFields({
58
56
  limit: 100,
59
57
  page: 1,
60
58
  project: { id: { $eq: event.project.id } },
@@ -63,9 +61,7 @@ function aggregateScreeningEvent(params) {
63
61
  startFrom: startFrom,
64
62
  startThrough: startThrough,
65
63
  location: { branchCode: { $eq: event.location.branchCode } }
66
- }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered'], []
67
- // PROJECTION_MINIMIZED_EVENT
68
- );
64
+ }, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
69
65
  }
70
66
  // ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
71
67
  aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
@@ -463,13 +463,13 @@ function confirm(params) {
463
463
  }
464
464
  let potentialActions;
465
465
  // 注文検証
466
- const existingOrders = yield repos.order.search({
466
+ const existingOrders = yield repos.order.projectFields({
467
467
  limit: 1,
468
468
  page: 1,
469
469
  project: { id: { $eq: transaction.project.id } },
470
470
  confirmationNumbers: [confirmationNumber],
471
471
  orderNumbers: [orderNumber]
472
- }, { inclusion: { orderNumber: 1 } });
472
+ }, { inclusion: ['orderNumber'] });
473
473
  if (existingOrders.length === 0) {
474
474
  throw new factory.errors.NotFound(factory.order.OrderType.Order);
475
475
  }
@@ -75,13 +75,13 @@ function fixOrderAsPurpose(params, transaction) {
75
75
  && payPurposeConfirmationNumber.length > 0
76
76
  && typeof payPurposeOrderNumber === 'string'
77
77
  && payPurposeOrderNumber.length > 0) {
78
- const orders = yield repos.order.search({
78
+ const orders = yield repos.order.projectFields({
79
79
  limit: 1,
80
80
  page: 1,
81
81
  project: { id: { $eq: transaction.project.id } },
82
82
  confirmationNumbers: [payPurposeConfirmationNumber],
83
83
  orderNumbers: [payPurposeOrderNumber]
84
- }, { inclusion: { customer: 1, orderNumber: 1, typeOf: 1 } });
84
+ }, { inclusion: ['customer', 'orderNumber', 'typeOf'] });
85
85
  order = orders.shift();
86
86
  if (order === undefined) {
87
87
  throw new factory.errors.NotFound('Order as purpose');
@@ -138,14 +138,12 @@ function searchEventTicketOffersByEvent(params) {
138
138
  let soundFormatTypes = [];
139
139
  let videoFormatTypes = [];
140
140
  if (event.typeOf === factory.eventType.ScreeningEvent) {
141
- const superEvents = yield repos.event.search({
141
+ const superEvents = yield repos.event.projectFields({
142
142
  limit: 1,
143
143
  page: 1,
144
144
  id: { $eq: event.superEvent.id },
145
145
  typeOf: factory.eventType.ScreeningEventSeries
146
- }, ['soundFormat', 'videoFormat'], []
147
- // { soundFormat: 1, videoFormat: 1 }
148
- );
146
+ }, ['soundFormat', 'videoFormat']);
149
147
  const superEvent = superEvents.shift();
150
148
  if (superEvent === undefined) {
151
149
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -362,14 +360,12 @@ function searchOfferAppliesToMovieTicket(params) {
362
360
  // let soundFormatTypes: string[] = [];
363
361
  let videoFormatTypes = [];
364
362
  if (event.typeOf === factory.eventType.ScreeningEvent) {
365
- const superEvents = yield repos.event.search({
363
+ const superEvents = yield repos.event.projectFields({
366
364
  limit: 1,
367
365
  page: 1,
368
366
  id: { $eq: event.superEvent.id },
369
367
  typeOf: factory.eventType.ScreeningEventSeries
370
- }, ['soundFormat', 'videoFormat'], []
371
- // { soundFormat: 1, videoFormat: 1 }
372
- );
368
+ }, ['soundFormat', 'videoFormat']);
373
369
  const superEvent = superEvents.shift();
374
370
  if (superEvent === undefined) {
375
371
  throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
@@ -23,7 +23,7 @@ function findCOAInfo(params) {
23
23
  typeOf: factory.eventType.ScreeningEvent,
24
24
  id: { $eq: params.id }
25
25
  };
26
- const event = (yield repos.event.search(searchConditions, ['coaInfo'], [])).shift();
26
+ const event = (yield repos.event.projectFields(searchConditions, ['coaInfo'])).shift();
27
27
  if (event === undefined) {
28
28
  throw new factory.errors.NotFound(factory.eventType.ScreeningEvent);
29
29
  }
@@ -129,17 +129,14 @@ function createInformTasks(params) {
129
129
  let events4inform;
130
130
  const informEvents = settings.onEventChanged.informEvent;
131
131
  if (params.typeOf === factory.eventType.Event) {
132
- const eventsFromDB = yield repos.event.search({
132
+ const eventsFromDB = yield repos.event.projectFields({
133
133
  id: { $in: params.ids },
134
134
  typeOf: params.typeOf
135
135
  }, [
136
136
  'project', 'organizer', 'typeOf', 'name', 'doorTime', 'endDate',
137
137
  'eventStatus', 'location', 'startDate', 'additionalProperty'
138
- ], // inclusion(2024-07-30~)
139
- [
140
- // 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
141
- // 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
142
- ]);
138
+ ] // inclusion(2024-07-30~)
139
+ );
143
140
  // 最適化(2024-03-26~)
144
141
  events4inform = eventsFromDB.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, id, additionalProperty }) => {
145
142
  return {
@@ -149,17 +146,14 @@ function createInformTasks(params) {
149
146
  });
150
147
  }
151
148
  else if (params.typeOf === factory.eventType.ScreeningEvent) {
152
- const screeningEvents4inform = yield repos.event.search({
149
+ const screeningEvents4inform = yield repos.event.projectFields({
153
150
  id: { $in: params.ids },
154
151
  typeOf: params.typeOf
155
152
  }, [
156
153
  'project', 'organizer', 'typeOf', 'name', 'doorTime', 'endDate',
157
154
  'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'additionalProperty'
158
- ], // inclusion(2024-07-30~)
159
- [
160
- // 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
161
- // 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
162
- ]);
155
+ ] // inclusion(2024-07-30~)
156
+ );
163
157
  // 最適化(2024-03-22~)
164
158
  events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty }) => {
165
159
  var _a;
@@ -187,17 +181,15 @@ function createInformTasks(params) {
187
181
  });
188
182
  }
189
183
  else {
190
- const screeningEventSeries4inform = yield repos.event.search({
184
+ const screeningEventSeries4inform = yield repos.event.projectFields({
191
185
  id: { $in: params.ids },
192
186
  typeOf: params.typeOf
193
187
  }, [
194
188
  'project', 'organizer', 'typeOf', 'name', 'location', 'videoFormat', 'soundFormat', 'workPerformed', 'kanaName', 'eventStatus',
195
189
  'endDate', 'startDate', 'additionalProperty', 'subtitleLanguage', 'dubLanguage',
196
190
  'alternativeHeadline', 'description', 'duration', 'headline'
197
- ], // inclusion(2024-07-30~)
198
- [
199
- // 'offers'
200
- ]);
191
+ ] // inclusion(2024-07-30~)
192
+ );
201
193
  // 最適化(2024-03-25~)
202
194
  events4inform = screeningEventSeries4inform.map(({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus, endDate, startDate, additionalProperty, subtitleLanguage, dubLanguage, alternativeHeadline, description, duration, headline }) => {
203
195
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus }, (endDate !== undefined) ? { endDate } : undefined), (startDate !== undefined) ? { startDate } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (subtitleLanguage !== undefined) ? {} : undefined), (dubLanguage !== undefined) ? { dubLanguage } : undefined), (alternativeHeadline !== undefined) ? { alternativeHeadline } : undefined), (description !== undefined) ? { description } : undefined), (typeof duration === 'string') ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined);
@@ -18,9 +18,11 @@ const factory = require("../../factory");
18
18
  */
19
19
  function deleteOrder(params) {
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
- const orders = yield repos.order.search({
21
+ const orders = yield repos.order.projectFields({
22
+ limit: 1,
23
+ page: 1,
22
24
  orderNumbers: [params.object.orderNumber]
23
- }, { inclusion: { orderDate: 1, project: 1, customer: 1, orderNumber: 1, seller: 1 } });
25
+ }, { inclusion: ['orderDate', 'project', 'customer', 'orderNumber', 'seller'] });
24
26
  const order = orders.shift();
25
27
  if (order === undefined) {
26
28
  // すでに削除済
@@ -274,14 +274,14 @@ function cancelOrderIfExist(params) {
274
274
  return;
275
275
  }
276
276
  // 注文のpaymentMethodIdを取得
277
- const ordersByPaymentMethodId = yield repos.order.search({
277
+ const ordersByPaymentMethodId = yield repos.order.projectFields({
278
278
  limit: 1,
279
279
  page: 1,
280
280
  paymentMethods: {
281
281
  paymentMethodIds: [params.paymentMethodId]
282
282
  },
283
283
  project: { id: { $eq: params.project.id } }
284
- }, { inclusion: { confirmationNumber: 1, orderNumber: 1 } });
284
+ }, { inclusion: ['confirmationNumber', 'orderNumber'] });
285
285
  const orderByPaymentMethodId = ordersByPaymentMethodId.shift();
286
286
  if (orderByPaymentMethodId !== undefined) {
287
287
  const placeOrderTransaction = yield (0, findPlaceOrderTransaction_1.findPlaceOrderTransaction)({
@@ -21,13 +21,13 @@ function fixOrderAsPurpose(params, transaction) {
21
21
  var _a;
22
22
  const payPurposeConfirmationNumber = params.potentialActions.pay.purpose.confirmationNumber;
23
23
  const payPurposeOrderNumber = (_a = params.potentialActions.pay.purpose) === null || _a === void 0 ? void 0 : _a.orderNumber;
24
- const ordersWithoutAcceptedOffers = yield repos.order.search({
24
+ const ordersWithoutAcceptedOffers = yield repos.order.projectFields({
25
25
  limit: 1,
26
26
  page: 1,
27
27
  project: { id: { $eq: transaction.project.id } },
28
28
  confirmationNumbers: [payPurposeConfirmationNumber],
29
29
  orderNumbers: [payPurposeOrderNumber]
30
- }, { inclusion: { typeOf: 1, confirmationNumber: 1, orderNumber: 1 } });
30
+ }, { inclusion: ['typeOf', 'confirmationNumber', 'orderNumber'] });
31
31
  const orderWithoutAcceptedOffers = ordersWithoutAcceptedOffers.shift();
32
32
  if (orderWithoutAcceptedOffers === undefined) {
33
33
  throw new factory.errors.NotFound('Order as purpose');
@@ -61,11 +61,11 @@ function payTask2payActionAttributes(params) {
61
61
  const { object, potentialActions, purpose, typeOf } = params;
62
62
  if (typeOf === factory.actionType.PayAction) {
63
63
  // 返金手数料決済の場合
64
- const order = (yield repos.order.search({
64
+ const order = (yield repos.order.projectFields({
65
65
  limit: 1,
66
66
  page: 1,
67
67
  orderNumbers: [params.purpose.object.orderNumber]
68
- }, { inclusion: { seller: 1, project: 1 } })).shift();
68
+ }, { inclusion: ['seller', 'project'] })).shift();
69
69
  if (order === undefined) {
70
70
  throw new factory.errors.NotFound(factory.order.OrderType.Order);
71
71
  }
@@ -110,10 +110,10 @@ function onReservationCheckedIn(params) {
110
110
  yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
111
111
  var _b;
112
112
  // すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
113
- const existingEvents = yield repos.event.search({
113
+ const existingEvents = yield repos.event.projectFields({
114
114
  id: { $eq: reservationForId },
115
115
  typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
116
- }, ['typeOf'], []);
116
+ }, ['typeOf']);
117
117
  if (existingEvents.length > 0) {
118
118
  yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
119
119
  project: { id: params.project.id },
@@ -40,11 +40,11 @@ function searchByOrder(params) {
40
40
  switch (offeredThroughIdentifier) {
41
41
  // COA対応
42
42
  case factory.service.webAPI.Identifier.COA:
43
- const order = (yield repos.order.search({
43
+ const order = (yield repos.order.projectFields({
44
44
  limit: 1,
45
45
  page: 1,
46
46
  orderNumbers: [params.orderNumber]
47
- }, { inclusion: { customer: 1 } })).shift();
47
+ }, { inclusion: ['customer'] })).shift();
48
48
  if (order === undefined) {
49
49
  throw new factory.errors.NotFound(factory.order.OrderType.Order);
50
50
  }
@@ -117,12 +117,12 @@ function fixOrderAsPurpose(params) {
117
117
  return (repos) => __awaiter(this, void 0, void 0, function* () {
118
118
  let order;
119
119
  const purposeOrderNumber = params.purpose.orderNumber;
120
- const orders = yield repos.order.search({
120
+ const orders = yield repos.order.projectFields({
121
121
  limit: 1,
122
122
  page: 1,
123
123
  project: { id: { $eq: params.project.id } },
124
124
  orderNumbers: [purposeOrderNumber]
125
- }, { inclusion: { customer: 1, orderNumber: 1, typeOf: 1 } });
125
+ }, { inclusion: ['customer', 'orderNumber', 'typeOf'] });
126
126
  order = orders.shift();
127
127
  if (order === undefined) {
128
128
  throw new factory.errors.NotFound('Order as purpose');
@@ -66,11 +66,11 @@ function fixOrderAndTransaction(params) {
66
66
  return (repos) => __awaiter(this, void 0, void 0, function* () {
67
67
  const paymentMethodId = params.object.paymentMethodId;
68
68
  // objectから注文を特定する(2024-06-19~)
69
- const orderByPaymentMethodId = (yield repos.order.search({
69
+ const orderByPaymentMethodId = (yield repos.order.projectFields({
70
70
  limit: 1,
71
71
  page: 1,
72
72
  paymentMethods: { paymentMethodIds: [paymentMethodId] }
73
- }, { inclusion: { orderNumber: 1 } })).shift();
73
+ }, { inclusion: ['orderNumber'] })).shift();
74
74
  if (orderByPaymentMethodId === undefined) {
75
75
  throw new factory.errors.NotFound(factory.order.OrderType.Order);
76
76
  }
@@ -400,14 +400,14 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
400
400
  if (fromLocation.typeOf === factory.order.OrderType.Order) {
401
401
  fromLocation = fromLocation;
402
402
  // 注文検索
403
- const orders = yield repos.order.search({
403
+ const orders = yield repos.order.projectFields({
404
404
  limit: 1,
405
405
  page: 1,
406
406
  project: { id: { $eq: project.id } },
407
407
  orderNumbers: [String(fromLocation.orderNumber)],
408
408
  confirmationNumbers: [String(fromLocation.confirmationNumber)]
409
409
  }, {
410
- inclusion: { identifier: 1, orderStatus: 1 }
410
+ inclusion: ['identifier', 'orderStatus']
411
411
  });
412
412
  const order = orders.shift();
413
413
  if (order === undefined) {
@@ -454,16 +454,16 @@ function validateToLocation(project, toLocationBeforeStart, issuedThrough) {
454
454
  if (toLocation.typeOf === factory.order.OrderType.Order) {
455
455
  toLocation = toLocation;
456
456
  // 注文検索
457
- const orders = yield repos.order.search({
457
+ const orders = yield repos.order.projectFields({
458
458
  limit: 1,
459
459
  page: 1,
460
460
  project: { id: { $eq: project.id } },
461
461
  orderNumbers: [String(toLocation.orderNumber)],
462
462
  confirmationNumbers: [String(toLocation.confirmationNumber)]
463
463
  }, {
464
- inclusion: {
465
- identifier: 1
466
- }
464
+ inclusion: [
465
+ 'identifier'
466
+ ]
467
467
  });
468
468
  const order = orders.shift();
469
469
  if (order === undefined) {
@@ -55,10 +55,10 @@ function preStart(params) {
55
55
  // イベント開始日時取得
56
56
  let events = [];
57
57
  if (eventIds.length > 0) {
58
- events = yield repos.event.search({
58
+ events = yield repos.event.projectFields({
59
59
  id: { $in: eventIds },
60
60
  typeOf: factory.eventType.ScreeningEvent
61
- }, ['startDate'], []);
61
+ }, ['startDate']);
62
62
  }
63
63
  let returnPolicies = seller.hasMerchantReturnPolicy;
64
64
  if (!Array.isArray(returnPolicies)) {
@@ -119,7 +119,7 @@ function fixOrders(params) {
119
119
  throw new factory.errors.Argument('object.order', 'number of orders must be 1');
120
120
  }
121
121
  // 注文数を1に限定であれば、findByConfirmationNumberに変更できる(2022-04-28~)
122
- const orders = yield repos.order.search({
122
+ const orders = yield repos.order.projectFields({
123
123
  limit: 1,
124
124
  page: 1,
125
125
  project: { id: { $eq: params.project.id } },
@@ -128,10 +128,10 @@ function fixOrders(params) {
128
128
  },
129
129
  // positive projectionで検索(2023-12-08~)
130
130
  {
131
- inclusion: {
132
- confirmationNumber: 1, dateReturned: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
133
- paymentMethods: 1, price: 1, project: 1, seller: 1, typeOf: 1
134
- }
131
+ inclusion: [
132
+ 'confirmationNumber', 'dateReturned', 'orderDate', 'orderNumber', 'orderStatus',
133
+ 'paymentMethods', 'price', 'project', 'seller', 'typeOf'
134
+ ]
135
135
  }
136
136
  // {
137
137
  // // acceptedOffers: 0, // カスタム返品ポリシーに必要
@@ -101,17 +101,17 @@ function confirm(params) {
101
101
  if (transaction.object.order.length !== 1) {
102
102
  throw new factory.errors.Argument('object.order', 'number of orders must be 1');
103
103
  }
104
- const returningOrders = yield repos.order.search({
104
+ const returningOrders = yield repos.order.projectFields({
105
105
  limit: 1,
106
106
  page: 1,
107
107
  project: { id: { $eq: transaction.project.id } },
108
108
  confirmationNumbers: [transaction.object.order[0].confirmationNumber],
109
109
  orderNumbers: [transaction.object.order[0].orderNumber]
110
110
  }, {
111
- inclusion: {
112
- confirmationNumber: 1, customer: 1, identifier: 1, orderDate: 1, orderNumber: 1, orderStatus: 1,
113
- orderedItem: 1, paymentMethods: 1, price: 1, priceCurrency: 1, project: 1, seller: 1, typeOf: 1
114
- }
111
+ inclusion: [
112
+ 'confirmationNumber', 'customer', 'identifier', 'orderDate', 'orderNumber', 'orderStatus',
113
+ 'orderedItem', 'paymentMethods', 'price', 'priceCurrency', 'project', 'seller', 'typeOf'
114
+ ]
115
115
  });
116
116
  // デフォルトEメールメッセージを検索
117
117
  let emailMessageOnOrderReturned;
package/package.json CHANGED
@@ -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.1.0-alpha.2"
113
+ "version": "22.1.0-alpha.4"
114
114
  }