@chevre/domain 21.4.0-alpha.8 → 21.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.
Files changed (96) hide show
  1. package/example/src/chevre/cleanEventsByMovieTheater.ts +32 -0
  2. package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
  3. package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +31 -0
  4. package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +32 -0
  5. package/example/src/chevre/importEventsFromCOA.ts +5 -4
  6. package/example/src/chevre/migrateEventOrganizer.ts +18 -5
  7. package/example/src/chevre/migrateIAMMemberMemberOf.ts +59 -0
  8. package/example/src/chevre/migrateReservationProvider.ts +119 -0
  9. package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
  10. package/example/src/chevre/processReserve.ts +0 -1
  11. package/example/src/chevre/searchActions.ts +1 -1
  12. package/example/src/chevre/searchPermissions.ts +7 -15
  13. package/lib/chevre/factory/event.d.ts +1 -1
  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 +16 -0
  17. package/lib/chevre/repo/event.js +34 -1
  18. package/lib/chevre/repo/member.d.ts +77 -5
  19. package/lib/chevre/repo/member.js +115 -97
  20. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  21. package/lib/chevre/repo/mongoose/schemas/member.d.ts +7 -7
  22. package/lib/chevre/repo/mongoose/schemas/member.js +22 -8
  23. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -6
  24. package/lib/chevre/repo/mongoose/schemas/place.js +9 -2
  25. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  26. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +6 -3
  27. package/lib/chevre/repo/mongoose/schemas/reservation.js +10 -4
  28. package/lib/chevre/repo/order.d.ts +21 -0
  29. package/lib/chevre/repo/order.js +54 -62
  30. package/lib/chevre/repo/place.d.ts +57 -16
  31. package/lib/chevre/repo/place.js +112 -167
  32. package/lib/chevre/repo/product.d.ts +2 -4
  33. package/lib/chevre/repo/product.js +52 -7
  34. package/lib/chevre/repo/project.d.ts +5 -3
  35. package/lib/chevre/repo/project.js +48 -8
  36. package/lib/chevre/repo/reservation.d.ts +33 -21
  37. package/lib/chevre/repo/reservation.js +97 -79
  38. package/lib/chevre/repo/role.d.ts +0 -4
  39. package/lib/chevre/repo/role.js +0 -46
  40. package/lib/chevre/repo/seller.d.ts +18 -5
  41. package/lib/chevre/repo/seller.js +53 -46
  42. package/lib/chevre/repo/stockHolder.d.ts +2 -77
  43. package/lib/chevre/repo/stockHolder.js +200 -476
  44. package/lib/chevre/repo/task.d.ts +1 -1
  45. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
  46. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  47. package/lib/chevre/service/aggregation/project.js +5 -1
  48. package/lib/chevre/service/assetTransaction/cancelReservation.js +10 -2
  49. package/lib/chevre/service/assetTransaction/pay/account/validation.js +9 -1
  50. package/lib/chevre/service/assetTransaction/pay.js +9 -1
  51. package/lib/chevre/service/assetTransaction/registerService.js +7 -3
  52. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +6 -1
  53. package/lib/chevre/service/assetTransaction/reserve/factory.js +15 -38
  54. package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
  55. package/lib/chevre/service/assetTransaction/reserve.js +7 -22
  56. package/lib/chevre/service/event/createEvent.d.ts +11 -0
  57. package/lib/chevre/service/event/createEvent.js +112 -0
  58. package/lib/chevre/service/event.d.ts +2 -0
  59. package/lib/chevre/service/event.js +8 -4
  60. package/lib/chevre/service/iam.d.ts +5 -0
  61. package/lib/chevre/service/iam.js +7 -19
  62. package/lib/chevre/service/moneyTransfer.js +6 -2
  63. package/lib/chevre/service/notification.js +5 -1
  64. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  65. package/lib/chevre/service/offer/event/authorize.js +6 -2
  66. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
  67. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  68. package/lib/chevre/service/order/returnOrder.js +8 -1
  69. package/lib/chevre/service/order/sendOrder.js +8 -1
  70. package/lib/chevre/service/payment/creditCard.js +14 -2
  71. package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
  72. package/lib/chevre/service/payment/movieTicket.js +19 -2
  73. package/lib/chevre/service/payment/paymentCard.js +6 -4
  74. package/lib/chevre/service/reserve/cancelReservation.js +15 -28
  75. package/lib/chevre/service/reserve/confirmReservation.js +14 -30
  76. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
  77. package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
  78. package/lib/chevre/service/task/{syncScreeningRooms.d.ts → createEvent.d.ts} +1 -1
  79. package/lib/chevre/service/task/{syncScreeningRooms.js → createEvent.js} +11 -3
  80. package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
  81. package/lib/chevre/service/task/returnPayTransaction.js +1 -0
  82. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  83. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +6 -2
  84. package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
  85. package/lib/chevre/service/transaction/returnOrder.js +9 -3
  86. package/lib/chevre/settings.d.ts +0 -2
  87. package/lib/chevre/settings.js +7 -7
  88. package/package.json +3 -3
  89. package/example/src/chevre/findByOrderNumberAndReservationId.ts +0 -20
  90. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
  91. package/example/src/chevre/searchHoldReservations.ts +0 -38
  92. package/example/src/chevre/searchScreeningRooms.ts +0 -33
  93. package/example/src/chevre/syncScreeningRooms.ts +0 -21
  94. package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
  95. package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +0 -75
  96. package/lib/chevre/repo/mongoose/schemas/holdReservation.js +0 -93
@@ -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
  }
@@ -31,16 +31,18 @@ export declare class MongoRepository {
31
31
  private readonly projectModel;
32
32
  constructor(connection: Connection);
33
33
  static CREATE_MONGO_CONDITIONS(params: factory.project.ISearchConditions): any[];
34
- findById(conditions: {
34
+ findById(params: {
35
35
  id: string;
36
- }, projection?: any): Promise<factory.project.IProject>;
36
+ inclusion: string[];
37
+ exclusion: string[];
38
+ }): Promise<factory.project.IProject>;
37
39
  findAlternateNameById(params: {
38
40
  id: string;
39
41
  }): Promise<Pick<factory.project.IProject, 'alternateName'>>;
40
42
  /**
41
43
  * プロジェクト検索
42
44
  */
43
- search(conditions: factory.project.ISearchConditions, projection?: any): Promise<factory.project.IProject[]>;
45
+ search(conditions: factory.project.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<factory.project.IProject[]>;
44
46
  createById(params: factory.project.IProject): Promise<factory.project.IProject>;
45
47
  findByIdAndIUpdate(params: {
46
48
  id: string;
@@ -26,9 +26,7 @@ class MongoRepository {
26
26
  // tslint:disable-next-line:no-single-line-block-comment
27
27
  /* istanbul ignore else */
28
28
  if (Array.isArray(params.ids)) {
29
- andConditions.push({
30
- _id: { $in: params.ids }
31
- });
29
+ andConditions.push({ _id: { $in: params.ids } });
32
30
  }
33
31
  // tslint:disable-next-line:no-single-line-block-comment
34
32
  /* istanbul ignore else */
@@ -52,9 +50,29 @@ class MongoRepository {
52
50
  }
53
51
  return andConditions;
54
52
  }
55
- findById(conditions, projection) {
53
+ findById(params
54
+ // projection?: any
55
+ ) {
56
56
  return __awaiter(this, void 0, void 0, function* () {
57
- const doc = yield this.projectModel.findOne({ _id: conditions.id }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
57
+ let projection = {};
58
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
59
+ params.inclusion.forEach((field) => {
60
+ projection[field] = 1;
61
+ });
62
+ }
63
+ else {
64
+ projection = {
65
+ __v: 0,
66
+ createdAt: 0,
67
+ updatedAt: 0
68
+ };
69
+ if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
70
+ params.exclusion.forEach((field) => {
71
+ projection[field] = 0;
72
+ });
73
+ }
74
+ }
75
+ const doc = yield this.projectModel.findOne({ _id: { $eq: params.id } }, projection)
58
76
  .exec();
59
77
  if (doc === null) {
60
78
  throw new factory.errors.NotFound(this.projectModel.modelName);
@@ -64,7 +82,7 @@ class MongoRepository {
64
82
  }
65
83
  findAlternateNameById(params) {
66
84
  return __awaiter(this, void 0, void 0, function* () {
67
- const doc = yield this.projectModel.findOne({ _id: params.id }, { alternateName: 1 })
85
+ const doc = yield this.projectModel.findOne({ _id: { $eq: params.id } }, { alternateName: 1 })
68
86
  .exec();
69
87
  if (doc === null) {
70
88
  throw new factory.errors.NotFound(this.projectModel.modelName);
@@ -75,11 +93,33 @@ class MongoRepository {
75
93
  /**
76
94
  * プロジェクト検索
77
95
  */
78
- search(conditions, projection) {
96
+ search(conditions,
97
+ // inclusion対応(2023-07-27~)
98
+ inclusion, exclusion
99
+ // projection?: any
100
+ ) {
79
101
  var _a;
80
102
  return __awaiter(this, void 0, void 0, function* () {
81
103
  const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
82
- const query = this.projectModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
104
+ let projection = {};
105
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
106
+ inclusion.forEach((field) => {
107
+ projection[field] = 1;
108
+ });
109
+ }
110
+ else {
111
+ projection = {
112
+ __v: 0,
113
+ createdAt: 0,
114
+ updatedAt: 0
115
+ };
116
+ if (Array.isArray(exclusion) && exclusion.length > 0) {
117
+ exclusion.forEach((field) => {
118
+ projection[field] = 0;
119
+ });
120
+ }
121
+ }
122
+ const query = this.projectModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
83
123
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
84
124
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
85
125
  query.limit(conditions.limit)
@@ -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
  }