@chevre/domain 21.4.0-alpha.2 → 21.4.0-alpha.21

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 (86) hide show
  1. package/example/src/chevre/cleanActions.ts +23 -0
  2. package/example/src/chevre/cleanEventsByMovieTheater.ts +32 -0
  3. package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +6 -0
  5. package/example/src/chevre/migrateEventOrganizer.ts +125 -0
  6. package/example/src/chevre/migrateReservationProvider.ts +117 -0
  7. package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
  8. package/example/src/chevre/processReserve.ts +0 -1
  9. package/example/src/chevre/searchEvents.ts +1 -9
  10. package/example/src/chevre/searchProductOffers.ts +6 -0
  11. package/lib/chevre/factory/event.d.ts +1 -1
  12. package/lib/chevre/repo/action.d.ts +6 -0
  13. package/lib/chevre/repo/action.js +13 -0
  14. package/lib/chevre/repo/assetTransaction.d.ts +4 -1
  15. package/lib/chevre/repo/assetTransaction.js +6 -12
  16. package/lib/chevre/repo/event.d.ts +25 -4
  17. package/lib/chevre/repo/event.js +122 -60
  18. package/lib/chevre/repo/mongoose/schemas/event.d.ts +7 -4
  19. package/lib/chevre/repo/mongoose/schemas/event.js +15 -2
  20. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -6
  21. package/lib/chevre/repo/mongoose/schemas/place.js +9 -2
  22. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  23. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +3 -0
  24. package/lib/chevre/repo/mongoose/schemas/reservation.js +6 -3
  25. package/lib/chevre/repo/order.d.ts +21 -0
  26. package/lib/chevre/repo/order.js +54 -62
  27. package/lib/chevre/repo/place.d.ts +57 -16
  28. package/lib/chevre/repo/place.js +112 -167
  29. package/lib/chevre/repo/product.d.ts +2 -4
  30. package/lib/chevre/repo/product.js +52 -7
  31. package/lib/chevre/repo/productOffer.d.ts +19 -4
  32. package/lib/chevre/repo/productOffer.js +37 -14
  33. package/lib/chevre/repo/reservation.d.ts +33 -21
  34. package/lib/chevre/repo/reservation.js +97 -79
  35. package/lib/chevre/repo/seller.d.ts +4 -3
  36. package/lib/chevre/repo/seller.js +40 -38
  37. package/lib/chevre/repo/task.d.ts +1 -1
  38. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  39. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
  40. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  41. package/lib/chevre/service/assetTransaction/pay/account/validation.js +9 -1
  42. package/lib/chevre/service/assetTransaction/pay.js +9 -1
  43. package/lib/chevre/service/assetTransaction/registerService.js +2 -2
  44. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +10 -4
  45. package/lib/chevre/service/assetTransaction/reserve/factory.js +21 -40
  46. package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
  47. package/lib/chevre/service/assetTransaction/reserve.js +7 -22
  48. package/lib/chevre/service/event/createEvent.d.ts +9 -0
  49. package/lib/chevre/service/event/createEvent.js +86 -0
  50. package/lib/chevre/service/event.d.ts +2 -0
  51. package/lib/chevre/service/event.js +26 -26
  52. package/lib/chevre/service/moneyTransfer.js +1 -1
  53. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  54. package/lib/chevre/service/offer/event/authorize.js +6 -2
  55. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +16 -2
  56. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
  57. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  58. package/lib/chevre/service/order/returnOrder.js +8 -1
  59. package/lib/chevre/service/order/sendOrder.js +8 -1
  60. package/lib/chevre/service/payment/creditCard.js +9 -1
  61. package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -1
  62. package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
  63. package/lib/chevre/service/payment/movieTicket.js +19 -2
  64. package/lib/chevre/service/payment/paymentCard.js +1 -3
  65. package/lib/chevre/service/reserve/cancelReservation.js +15 -28
  66. package/lib/chevre/service/reserve/confirmReservation.js +12 -30
  67. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
  68. package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
  69. package/lib/chevre/service/task/{syncScreeningRooms.d.ts → createEvent.d.ts} +1 -1
  70. package/lib/chevre/service/task/{syncScreeningRooms.js → createEvent.js} +10 -4
  71. package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
  72. package/lib/chevre/service/task/returnPayTransaction.js +1 -0
  73. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  74. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
  75. package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
  76. package/lib/chevre/service/transaction/returnOrder.js +9 -3
  77. package/package.json +3 -3
  78. package/example/src/chevre/findByOrderNumberAndReservationId.ts +0 -20
  79. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
  80. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +0 -90
  81. package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -75
  82. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +0 -64
  83. package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +0 -79
  84. package/example/src/chevre/searchScreeningRooms.ts +0 -33
  85. package/example/src/chevre/syncScreeningRooms.ts +0 -21
  86. package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
@@ -151,9 +151,30 @@ class MongoRepository {
151
151
  }
152
152
  return andConditions;
153
153
  }
154
- findById(conditions, projection) {
154
+ findById(conditions,
155
+ // inclusion化(2023-07-20~)
156
+ // projection?: { [key: string]: number }
157
+ inclusion, exclusion) {
155
158
  return __awaiter(this, void 0, void 0, function* () {
156
- const doc = yield this.productModel.findOne({ _id: conditions.id }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
159
+ let projection = {};
160
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
161
+ inclusion.forEach((field) => {
162
+ projection[field] = 1;
163
+ });
164
+ }
165
+ else {
166
+ projection = {
167
+ __v: 0,
168
+ createdAt: 0,
169
+ updatedAt: 0
170
+ };
171
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
172
+ exclusion.forEach((field) => {
173
+ projection[field] = 0;
174
+ });
175
+ }
176
+ }
177
+ const doc = yield this.productModel.findOne({ _id: conditions.id }, projection)
157
178
  .exec();
158
179
  if (doc === null) {
159
180
  throw new factory.errors.NotFound(this.productModel.modelName);
@@ -303,10 +324,34 @@ class MongoRepository {
303
324
  delete params.attributes.id;
304
325
  }
305
326
  if (typeof params.id === 'string') {
306
- // 上書き禁止属性を除外(2022-08-24~)
307
- const _a = params.attributes, { id, productID, project, typeOf } = _a, updateFields = __rest(_a, ["id", "productID", "project", "typeOf"]);
308
- doc = yield this.productModel.findOneAndUpdate({ _id: params.id }, updateFields, { upsert: false, new: true })
309
- .exec();
327
+ const _a = params.attributes, { id, productID, project } = _a, updateFields = __rest(_a, ["id", "productID", "project"]);
328
+ switch (updateFields.typeOf) {
329
+ case factory.product.ProductType.EventService:
330
+ case factory.product.ProductType.MembershipService:
331
+ case factory.product.ProductType.PaymentCard:
332
+ case factory.product.ProductType.Product:
333
+ case factory.product.ProductType.Transportation:
334
+ // 上書き禁止属性を除外(2022-08-24~)
335
+ const { offers } = updateFields, updateProductFields = __rest(updateFields, ["offers"]);
336
+ doc = yield this.productModel.findOneAndUpdate({
337
+ _id: { $eq: params.id },
338
+ typeOf: { $eq: updateProductFields.typeOf }
339
+ }, updateProductFields, { upsert: false, new: true })
340
+ .exec();
341
+ break;
342
+ case factory.service.paymentService.PaymentServiceType.CreditCard:
343
+ case factory.service.paymentService.PaymentServiceType.MovieTicket:
344
+ // 上書き禁止属性を除外(2022-08-24~)
345
+ const { provider } = updateFields, updatePaymentServiceFields = __rest(updateFields, ["provider"]);
346
+ doc = yield this.productModel.findOneAndUpdate({
347
+ _id: { $eq: params.id },
348
+ typeOf: { $eq: updatePaymentServiceFields.typeOf }
349
+ }, updatePaymentServiceFields, { upsert: false, new: true })
350
+ .exec();
351
+ break;
352
+ default:
353
+ throw new factory.errors.NotImplemented(`${updateFields.typeOf} not implemented`);
354
+ }
310
355
  if (doc === null) {
311
356
  throw new factory.errors.NotFound(this.productModel.modelName);
312
357
  }
@@ -315,7 +360,7 @@ class MongoRepository {
315
360
  if (params.createIfNotExist === true) {
316
361
  doc = yield this.productModel.findOneAndUpdate({
317
362
  'project.id': { $eq: params.attributes.project.id },
318
- typeOf: params.attributes.typeOf
363
+ typeOf: { $eq: params.attributes.typeOf }
319
364
  }, { $setOnInsert: params.attributes }, { new: true, upsert: true })
320
365
  .exec();
321
366
  }
@@ -17,16 +17,18 @@ export declare class MongoRepository {
17
17
  $eq?: string;
18
18
  };
19
19
  };
20
- id?: {
21
- $eq?: string;
20
+ itemOffered?: {
21
+ id?: {
22
+ $eq?: string;
23
+ };
22
24
  };
23
25
  seller?: {
24
26
  id?: {
25
27
  $eq?: string;
26
28
  };
27
29
  };
28
- }): Promise<(Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'> & {
29
- offers: Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'>;
30
+ }): Promise<(Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
31
+ itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
30
32
  })[]>;
31
33
  create(params: factory.product.IOffer & {
32
34
  project: {
@@ -54,4 +56,17 @@ export declare class MongoRepository {
54
56
  }): Promise<{
55
57
  id: string;
56
58
  }>;
59
+ deleteOne(params: Pick<factory.product.IOffer, 'seller'> & {
60
+ project: {
61
+ id: string;
62
+ };
63
+ itemOffered: {
64
+ /**
65
+ * プロダクトID
66
+ */
67
+ id: string;
68
+ };
69
+ }): Promise<{
70
+ id: string;
71
+ }>;
57
72
  }
@@ -25,7 +25,7 @@ class MongoRepository {
25
25
  * プロダクトオファー検索
26
26
  */
27
27
  search(params) {
28
- var _a, _b, _c, _d, _e;
28
+ var _a, _b, _c, _d, _e, _f;
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
30
  const matchStages = [{
31
31
  $match: {
@@ -41,11 +41,11 @@ class MongoRepository {
41
41
  if (typeof projectIdEq === 'string') {
42
42
  matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
43
43
  }
44
- const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
45
- if (typeof idEq === 'string') {
46
- matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(idEq) } } });
44
+ const itemOfferedIdEq = (_d = (_c = params.itemOffered) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
45
+ if (typeof itemOfferedIdEq === 'string') {
46
+ matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(itemOfferedIdEq) } } });
47
47
  }
48
- const sellerIdEq = (_e = (_d = params.seller) === null || _d === void 0 ? void 0 : _d.id) === null || _e === void 0 ? void 0 : _e.$eq;
48
+ const sellerIdEq = (_f = (_e = params.seller) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
49
49
  if (typeof sellerIdEq === 'string') {
50
50
  matchStages.push({ $match: { 'offers.seller.id': { $exists: true, $eq: sellerIdEq } } });
51
51
  }
@@ -60,16 +60,16 @@ class MongoRepository {
60
60
  {
61
61
  $project: {
62
62
  _id: 0,
63
- offers: {
64
- availabilityEnds: '$offers.availabilityEnds',
65
- availabilityStarts: '$offers.availabilityStarts',
66
- validFrom: '$offers.validFrom',
67
- validThrough: '$offers.validThrough',
68
- seller: '$offers.seller'
63
+ itemOffered: {
64
+ id: { $toString: '$_id' },
65
+ name: '$name',
66
+ typeOf: '$typeOf'
69
67
  },
70
- id: { $toString: '$_id' },
71
- name: '$name',
72
- typeOf: '$typeOf'
68
+ availabilityEnds: '$offers.availabilityEnds',
69
+ availabilityStarts: '$offers.availabilityStarts',
70
+ validFrom: '$offers.validFrom',
71
+ validThrough: '$offers.validThrough',
72
+ seller: '$offers.seller'
73
73
  }
74
74
  }
75
75
  ]);
@@ -158,5 +158,28 @@ class MongoRepository {
158
158
  return doc.toObject();
159
159
  });
160
160
  }
161
+ deleteOne(params) {
162
+ var _a;
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
165
+ if (typeof sellerId !== 'string' || sellerId.length === 0) {
166
+ throw new factory.errors.ArgumentNull('seller.id');
167
+ }
168
+ const doc = yield this.productModel.findOneAndUpdate({
169
+ 'project.id': { $eq: params.project.id },
170
+ _id: { $eq: params.itemOffered.id },
171
+ 'offers.seller.id': { $exists: true, $eq: sellerId }
172
+ }, {
173
+ $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
174
+ }, {
175
+ projection: { _id: 1 }
176
+ })
177
+ .exec();
178
+ if (doc === null) {
179
+ throw new factory.errors.NotFound('Product');
180
+ }
181
+ return doc.toObject();
182
+ });
183
+ }
161
184
  }
162
185
  exports.MongoRepository = MongoRepository;
@@ -1,11 +1,39 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
1
25
  import { BulkWriteResult as BulkWriteOpResultObject } from 'mongodb';
2
26
  import { Connection, UpdateWriteOpResult } from 'mongoose';
3
27
  import * as factory from '../factory';
4
28
  export interface IUpdatePartiallyParams {
5
29
  additionalTicketText?: string;
6
- 'reservedTicket.dateUsed'?: Date;
7
30
  }
8
31
  export type ICancelResult = UpdateWriteOpResult;
32
+ export type ICreatingReservation<T extends factory.reservationType> = T extends factory.reservationType.BusReservation ? (factory.reservation.busReservation.IReservation) & {
33
+ _id: string;
34
+ } : T extends factory.reservationType.EventReservation ? (factory.reservation.eventReservation.IReservation) & {
35
+ _id: string;
36
+ } : never;
9
37
  /**
10
38
  * 予約リポジトリ
11
39
  */
@@ -13,10 +41,6 @@ export declare class MongoRepository {
13
41
  private readonly reservationModel;
14
42
  constructor(connection: Connection);
15
43
  static CREATE_MONGO_CONDITIONS(params: factory.reservation.ISearchConditions<factory.reservationType>): any[];
16
- createMany(params: {
17
- reservations: factory.assetTransaction.reserve.IObjectSubReservation[];
18
- reservationFor: factory.assetTransaction.reserve.IReservationFor;
19
- }): Promise<void>;
20
44
  /**
21
45
  * 汎用予約カウント
22
46
  */
@@ -32,26 +56,13 @@ export declare class MongoRepository {
32
56
  inclusion?: string[];
33
57
  exclusion?: string[];
34
58
  }): Promise<factory.reservation.IReservation<T>>;
35
- confirmByReservationNumber(params: {
36
- reservationNumber: string;
37
- previousReservationStatus: factory.reservationStatusType;
38
- underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
39
- broker?: factory.reservation.IBroker<factory.reservationType>;
40
- issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
41
- }): Promise<void>;
42
- confirmByIdIfNotExist__(params: {
43
- reservation: factory.assetTransaction.reserve.IObjectSubReservation;
44
- reservationFor: factory.assetTransaction.reserve.IReservationFor;
45
- underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
46
- broker?: factory.reservation.IBroker<factory.reservationType>;
47
- issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
48
- }): Promise<void>;
49
59
  confirmManyIfNotExist(params: {
60
+ provider: factory.reservation.IProvider;
50
61
  subReservation: factory.assetTransaction.reserve.IObjectSubReservation[];
62
+ issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
51
63
  reservationFor: factory.assetTransaction.reserve.IReservationFor;
52
64
  underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
53
65
  broker?: factory.reservation.IBroker<factory.reservationType>;
54
- issuedThrough?: factory.assetTransaction.reserve.IIssuedThrough;
55
66
  }): Promise<BulkWriteOpResultObject | void>;
56
67
  /**
57
68
  * 予約取消
@@ -103,7 +114,7 @@ export declare class MongoRepository {
103
114
  updatePartiallyById(params: {
104
115
  id: string;
105
116
  update: IUpdatePartiallyParams;
106
- }): Promise<factory.reservation.eventReservation.IReservation>;
117
+ }): Promise<Pick<factory.reservation.eventReservation.IReservation, 'id'>>;
107
118
  deleteByIds(params: {
108
119
  project: {
109
120
  id: string;
@@ -131,4 +142,5 @@ export declare class MongoRepository {
131
142
  };
132
143
  }): Promise<string[]>;
133
144
  deleteReservedTicketUnderName(): Promise<import("mongodb").UpdateResult>;
145
+ getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
134
146
  }