@chevre/domain 21.4.0-alpha.16 → 21.4.0-alpha.17

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.
@@ -39,6 +39,9 @@ export declare class MongoRepository {
39
39
  * 注文ステータスを変更する
40
40
  */
41
41
  changeStatus(params: {
42
+ project: {
43
+ id: string;
44
+ };
42
45
  orderNumber: string;
43
46
  orderStatus: factory.orderStatus;
44
47
  previousOrderStatus: factory.orderStatus;
@@ -47,6 +50,9 @@ export declare class MongoRepository {
47
50
  * 注文を返品する
48
51
  */
49
52
  returnOrder(params: {
53
+ project: {
54
+ id: string;
55
+ };
50
56
  orderNumber: string;
51
57
  dateReturned: Date;
52
58
  returner: factory.order.IReturner;
@@ -55,6 +61,9 @@ export declare class MongoRepository {
55
61
  * 変更可能な属性を更新する
56
62
  */
57
63
  updateChangeableAttributes(params: {
64
+ project: {
65
+ id: string;
66
+ };
58
67
  additionalProperty?: factory.propertyValue.IPropertyValue<string>[];
59
68
  name?: string;
60
69
  orderNumber: string;
@@ -71,15 +80,24 @@ export declare class MongoRepository {
71
80
  */
72
81
  findByOrderNumber(params: {
73
82
  orderNumber: string;
83
+ project: {
84
+ id: string;
85
+ };
86
+ seller?: {
87
+ id?: string;
88
+ };
74
89
  inclusion: string[];
75
90
  exclusion: string[];
76
91
  }): Promise<factory.order.IOrder>;
77
92
  findByOrderNumberAndReservationId(params: {
78
- orderNumber: string;
79
- reservationId: string;
93
+ project: {
94
+ id: string;
95
+ };
80
96
  seller?: {
81
97
  id?: string;
82
98
  };
99
+ orderNumber: string;
100
+ reservationId: string;
83
101
  }): Promise<Pick<factory.order.IOrder, 'orderNumber' | 'orderStatus' | 'typeOf'>>;
84
102
  /**
85
103
  * 注文番号で削除する
@@ -24,34 +24,25 @@ class MongoRepository {
24
24
  }
25
25
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
26
26
  static CREATE_MONGO_CONDITIONS(params) {
27
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
27
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
28
28
  const andConditions = [];
29
- // tslint:disable-next-line:no-single-line-block-comment
30
- /* istanbul ignore else */
31
- if (params.project !== undefined) {
32
- if (params.project.id !== undefined && params.project.id !== null) {
33
- if (typeof params.project.id.$eq === 'string') {
34
- andConditions.push({
35
- 'project.id': {
36
- $eq: params.project.id.$eq
37
- }
38
- });
39
- }
40
- }
29
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
30
+ if (typeof projectIdEq === 'string') {
31
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
41
32
  }
42
- const additionalPropertyAll = (_a = params.additionalProperty) === null || _a === void 0 ? void 0 : _a.$all;
33
+ const additionalPropertyAll = (_c = params.additionalProperty) === null || _c === void 0 ? void 0 : _c.$all;
43
34
  if (Array.isArray(additionalPropertyAll)) {
44
35
  andConditions.push({ additionalProperty: { $exists: true, $all: additionalPropertyAll } });
45
36
  }
46
- const additionalPropertyIn = (_b = params.additionalProperty) === null || _b === void 0 ? void 0 : _b.$in;
37
+ const additionalPropertyIn = (_d = params.additionalProperty) === null || _d === void 0 ? void 0 : _d.$in;
47
38
  if (Array.isArray(additionalPropertyIn)) {
48
39
  andConditions.push({ additionalProperty: { $exists: true, $in: additionalPropertyIn } });
49
40
  }
50
- const additionalPropertyNin = (_c = params.additionalProperty) === null || _c === void 0 ? void 0 : _c.$nin;
41
+ const additionalPropertyNin = (_e = params.additionalProperty) === null || _e === void 0 ? void 0 : _e.$nin;
51
42
  if (Array.isArray(additionalPropertyNin)) {
52
43
  andConditions.push({ additionalProperty: { $nin: additionalPropertyNin } });
53
44
  }
54
- const additionalPropertyElemMatch = (_d = params.additionalProperty) === null || _d === void 0 ? void 0 : _d.$elemMatch;
45
+ const additionalPropertyElemMatch = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
55
46
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
56
47
  andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
57
48
  }
@@ -103,7 +94,7 @@ class MongoRepository {
103
94
  });
104
95
  }
105
96
  }
106
- const brokerIdEq = (_f = (_e = params.broker) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
97
+ const brokerIdEq = (_h = (_g = params.broker) === null || _g === void 0 ? void 0 : _g.id) === null || _h === void 0 ? void 0 : _h.$eq;
107
98
  if (typeof brokerIdEq === 'string') {
108
99
  andConditions.push({
109
100
  'broker.id': {
@@ -320,7 +311,7 @@ class MongoRepository {
320
311
  }
321
312
  }
322
313
  }
323
- const nameEq = (_g = params.name) === null || _g === void 0 ? void 0 : _g.$eq;
314
+ const nameEq = (_j = params.name) === null || _j === void 0 ? void 0 : _j.$eq;
324
315
  if (typeof nameEq === 'string') {
325
316
  andConditions.push({
326
317
  name: {
@@ -329,7 +320,7 @@ class MongoRepository {
329
320
  }
330
321
  });
331
322
  }
332
- const nameRegex = (_h = params.name) === null || _h === void 0 ? void 0 : _h.$regex;
323
+ const nameRegex = (_k = params.name) === null || _k === void 0 ? void 0 : _k.$regex;
333
324
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
334
325
  andConditions.push({
335
326
  name: {
@@ -362,7 +353,7 @@ class MongoRepository {
362
353
  }
363
354
  });
364
355
  }
365
- const itemOfferedIdentifierIn = (_l = (_k = (_j = params.acceptedOffers) === null || _j === void 0 ? void 0 : _j.itemOffered) === null || _k === void 0 ? void 0 : _k.identifier) === null || _l === void 0 ? void 0 : _l.$in;
356
+ const itemOfferedIdentifierIn = (_o = (_m = (_l = params.acceptedOffers) === null || _l === void 0 ? void 0 : _l.itemOffered) === null || _m === void 0 ? void 0 : _m.identifier) === null || _o === void 0 ? void 0 : _o.$in;
366
357
  if (Array.isArray(itemOfferedIdentifierIn)) {
367
358
  andConditions.push({
368
359
  'acceptedOffers.itemOffered.identifier': {
@@ -371,7 +362,7 @@ class MongoRepository {
371
362
  }
372
363
  });
373
364
  }
374
- const itemOfferedTypeOfIn = (_p = (_o = (_m = params.acceptedOffers) === null || _m === void 0 ? void 0 : _m.itemOffered) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$in;
365
+ const itemOfferedTypeOfIn = (_r = (_q = (_p = params.acceptedOffers) === null || _p === void 0 ? void 0 : _p.itemOffered) === null || _q === void 0 ? void 0 : _q.typeOf) === null || _r === void 0 ? void 0 : _r.$in;
375
366
  if (Array.isArray(itemOfferedTypeOfIn)) {
376
367
  andConditions.push({
377
368
  'acceptedOffers.itemOffered.typeOf': {
@@ -380,7 +371,7 @@ class MongoRepository {
380
371
  }
381
372
  });
382
373
  }
383
- const itemOfferedIssuedThroughTypeOfEq = (_t = (_s = (_r = (_q = params.acceptedOffers) === null || _q === void 0 ? void 0 : _q.itemOffered) === null || _r === void 0 ? void 0 : _r.issuedThrough) === null || _s === void 0 ? void 0 : _s.typeOf) === null || _t === void 0 ? void 0 : _t.$eq;
374
+ const itemOfferedIssuedThroughTypeOfEq = (_v = (_u = (_t = (_s = params.acceptedOffers) === null || _s === void 0 ? void 0 : _s.itemOffered) === null || _t === void 0 ? void 0 : _t.issuedThrough) === null || _u === void 0 ? void 0 : _u.typeOf) === null || _v === void 0 ? void 0 : _v.$eq;
384
375
  if (typeof itemOfferedIssuedThroughTypeOfEq === 'string') {
385
376
  andConditions.push({
386
377
  'acceptedOffers.itemOffered.issuedThrough.typeOf': {
@@ -389,7 +380,7 @@ class MongoRepository {
389
380
  }
390
381
  });
391
382
  }
392
- const itemOfferedIssuedThroughIdIn = (_x = (_w = (_v = (_u = params.acceptedOffers) === null || _u === void 0 ? void 0 : _u.itemOffered) === null || _v === void 0 ? void 0 : _v.issuedThrough) === null || _w === void 0 ? void 0 : _w.id) === null || _x === void 0 ? void 0 : _x.$in;
383
+ const itemOfferedIssuedThroughIdIn = (_z = (_y = (_x = (_w = params.acceptedOffers) === null || _w === void 0 ? void 0 : _w.itemOffered) === null || _x === void 0 ? void 0 : _x.issuedThrough) === null || _y === void 0 ? void 0 : _y.id) === null || _z === void 0 ? void 0 : _z.$in;
393
384
  if (Array.isArray(itemOfferedIssuedThroughIdIn)) {
394
385
  andConditions.push({
395
386
  'acceptedOffers.itemOffered.issuedThrough.id': {
@@ -398,7 +389,7 @@ class MongoRepository {
398
389
  }
399
390
  });
400
391
  }
401
- const itemOfferedProgramMembershipUsedIdentifierEq = (_1 = (_0 = (_z = (_y = params.acceptedOffers) === null || _y === void 0 ? void 0 : _y.itemOffered) === null || _z === void 0 ? void 0 : _z.programMembershipUsed) === null || _0 === void 0 ? void 0 : _0.identifier) === null || _1 === void 0 ? void 0 : _1.$eq;
392
+ const itemOfferedProgramMembershipUsedIdentifierEq = (_3 = (_2 = (_1 = (_0 = params.acceptedOffers) === null || _0 === void 0 ? void 0 : _0.itemOffered) === null || _1 === void 0 ? void 0 : _1.programMembershipUsed) === null || _2 === void 0 ? void 0 : _2.identifier) === null || _3 === void 0 ? void 0 : _3.$eq;
402
393
  if (typeof itemOfferedProgramMembershipUsedIdentifierEq === 'string') {
403
394
  andConditions.push({
404
395
  'acceptedOffers.itemOffered.programMembershipUsed.identifier': {
@@ -407,7 +398,7 @@ class MongoRepository {
407
398
  }
408
399
  });
409
400
  }
410
- const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_7 = (_6 = (_5 = (_4 = (_3 = (_2 = params.acceptedOffers) === null || _2 === void 0 ? void 0 : _2.itemOffered) === null || _3 === void 0 ? void 0 : _3.programMembershipUsed) === null || _4 === void 0 ? void 0 : _4.issuedThrough) === null || _5 === void 0 ? void 0 : _5.serviceType) === null || _6 === void 0 ? void 0 : _6.codeValue) === null || _7 === void 0 ? void 0 : _7.$eq;
401
+ const itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq = (_9 = (_8 = (_7 = (_6 = (_5 = (_4 = params.acceptedOffers) === null || _4 === void 0 ? void 0 : _4.itemOffered) === null || _5 === void 0 ? void 0 : _5.programMembershipUsed) === null || _6 === void 0 ? void 0 : _6.issuedThrough) === null || _7 === void 0 ? void 0 : _7.serviceType) === null || _8 === void 0 ? void 0 : _8.codeValue) === null || _9 === void 0 ? void 0 : _9.$eq;
411
402
  if (typeof itemOfferedProgramMembershipUsedIssuedThroughServiceTypeCodeValueEq === 'string') {
412
403
  andConditions.push({
413
404
  'acceptedOffers.itemOffered.programMembershipUsed.issuedThrough.serviceType.codeValue': {
@@ -603,7 +594,7 @@ class MongoRepository {
603
594
  });
604
595
  }
605
596
  }
606
- const paymentMethodAdditionalPropertyAll = (_9 = (_8 = params.paymentMethods) === null || _8 === void 0 ? void 0 : _8.additionalProperty) === null || _9 === void 0 ? void 0 : _9.$all;
597
+ const paymentMethodAdditionalPropertyAll = (_11 = (_10 = params.paymentMethods) === null || _10 === void 0 ? void 0 : _10.additionalProperty) === null || _11 === void 0 ? void 0 : _11.$all;
607
598
  if (Array.isArray(paymentMethodAdditionalPropertyAll)) {
608
599
  andConditions.push({
609
600
  'paymentMethods.additionalProperty': {
@@ -612,7 +603,7 @@ class MongoRepository {
612
603
  }
613
604
  });
614
605
  }
615
- const paymentMethodAdditionalPropertyIn = (_11 = (_10 = params.paymentMethods) === null || _10 === void 0 ? void 0 : _10.additionalProperty) === null || _11 === void 0 ? void 0 : _11.$in;
606
+ const paymentMethodAdditionalPropertyIn = (_13 = (_12 = params.paymentMethods) === null || _12 === void 0 ? void 0 : _12.additionalProperty) === null || _13 === void 0 ? void 0 : _13.$in;
616
607
  if (Array.isArray(paymentMethodAdditionalPropertyIn)) {
617
608
  andConditions.push({
618
609
  'paymentMethods.additionalProperty': {
@@ -696,8 +687,9 @@ class MongoRepository {
696
687
  changeStatus(params) {
697
688
  return __awaiter(this, void 0, void 0, function* () {
698
689
  const doc = yield this.orderModel.findOneAndUpdate({
699
- orderNumber: params.orderNumber,
700
- orderStatus: params.previousOrderStatus
690
+ orderNumber: { $eq: params.orderNumber },
691
+ orderStatus: { $eq: params.previousOrderStatus },
692
+ 'project.id': { $eq: params.project.id }
701
693
  }, { orderStatus: params.orderStatus }, {
702
694
  new: true,
703
695
  projection: {
@@ -711,6 +703,7 @@ class MongoRepository {
711
703
  if (doc === null) {
712
704
  const order = yield this.findByOrderNumber({
713
705
  orderNumber: params.orderNumber,
706
+ project: { id: params.project.id },
714
707
  inclusion: [],
715
708
  exclusion: []
716
709
  });
@@ -735,8 +728,9 @@ class MongoRepository {
735
728
  returnOrder(params) {
736
729
  return __awaiter(this, void 0, void 0, function* () {
737
730
  const doc = yield this.orderModel.findOneAndUpdate({
738
- orderNumber: params.orderNumber,
739
- orderStatus: factory.orderStatus.OrderDelivered
731
+ orderNumber: { $eq: params.orderNumber },
732
+ orderStatus: { $eq: factory.orderStatus.OrderDelivered },
733
+ 'project.id': { $eq: params.project.id }
740
734
  }, {
741
735
  orderStatus: factory.orderStatus.OrderReturned,
742
736
  dateReturned: params.dateReturned,
@@ -754,6 +748,7 @@ class MongoRepository {
754
748
  if (doc === null) {
755
749
  const order = yield this.findByOrderNumber({
756
750
  orderNumber: params.orderNumber,
751
+ project: { id: params.project.id },
757
752
  inclusion: [],
758
753
  exclusion: []
759
754
  });
@@ -777,7 +772,10 @@ class MongoRepository {
777
772
  */
778
773
  updateChangeableAttributes(params) {
779
774
  return __awaiter(this, void 0, void 0, function* () {
780
- const doc = yield this.orderModel.findOneAndUpdate({ orderNumber: { $eq: params.orderNumber } }, {
775
+ const doc = yield this.orderModel.findOneAndUpdate({
776
+ orderNumber: { $eq: params.orderNumber },
777
+ 'project.id': { $eq: params.project.id }
778
+ }, {
781
779
  $set: Object.assign(Object.assign({}, (Array.isArray(params.additionalProperty)) ? { additionalProperty: params.additionalProperty } : undefined), (typeof params.name === 'string') ? { name: params.name } : undefined)
782
780
  }, {
783
781
  new: true,
@@ -844,7 +842,10 @@ class MongoRepository {
844
842
  });
845
843
  }
846
844
  }
847
- const doc = yield this.orderModel.findOne({ orderNumber: params.orderNumber }, projection)
845
+ const doc = yield this.orderModel.findOne({
846
+ orderNumber: { $eq: params.orderNumber },
847
+ 'project.id': { $eq: params.project.id }
848
+ }, projection)
848
849
  .exec();
849
850
  if (doc === null) {
850
851
  throw new factory.errors.NotFound(this.orderModel.modelName);
@@ -861,7 +862,7 @@ class MongoRepository {
861
862
  orderNumber: 1,
862
863
  _id: 0
863
864
  };
864
- const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, acceptedOffers: {
865
+ const doc = yield this.orderModel.findOne(Object.assign({ orderNumber: { $eq: params.orderNumber }, 'project.id': { $eq: params.project.id }, acceptedOffers: {
865
866
  $elemMatch: {
866
867
  'itemOffered.typeOf': { $in: [factory.reservationType.BusReservation, factory.reservationType.EventReservation] },
867
868
  'itemOffered.id': { $eq: params.reservationId }
@@ -27,7 +27,6 @@ import { Connection, UpdateWriteOpResult } from 'mongoose';
27
27
  import * as factory from '../factory';
28
28
  export interface IUpdatePartiallyParams {
29
29
  additionalTicketText?: string;
30
- 'reservedTicket.dateUsed'?: Date;
31
30
  }
32
31
  export type ICancelResult = UpdateWriteOpResult;
33
32
  export type ICreatingReservation<T extends factory.reservationType> = T extends factory.reservationType.BusReservation ? (factory.reservation.busReservation.IReservation) & {
@@ -14,6 +14,7 @@ const order_1 = require("../../factory/order");
14
14
  const factory_1 = require("../delivery/factory");
15
15
  const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
16
16
  const factory = require("../../factory");
17
+ // tslint:disable-next-line:max-func-body-length
17
18
  function returnOrder(params) {
18
19
  return (repos) => __awaiter(this, void 0, void 0, function* () {
19
20
  const orderNumber = params.object.orderNumber;
@@ -21,7 +22,12 @@ function returnOrder(params) {
21
22
  ? params.object.dateReturned
22
23
  : new Date();
23
24
  const returner = params.agent;
24
- let order = yield repos.order.findByOrderNumber({ orderNumber, inclusion: [], exclusion: [] });
25
+ let order = yield repos.order.findByOrderNumber({
26
+ orderNumber,
27
+ project: { id: params.project.id },
28
+ inclusion: [],
29
+ exclusion: []
30
+ });
25
31
  // プロジェクト条件検証
26
32
  if (order.project.id !== params.project.id) {
27
33
  throw new factory.errors.NotFound('Order');
@@ -59,6 +65,7 @@ function returnOrder(params) {
59
65
  returnedOwnershipInfos = yield processReturnOrder(order, dateReturned)({ ownershipInfo: repos.ownershipInfo });
60
66
  // 注文ステータス変更
61
67
  order = yield repos.order.returnOrder({
68
+ project: { id: order.project.id },
62
69
  orderNumber,
63
70
  dateReturned,
64
71
  returner
@@ -31,7 +31,12 @@ function sendOrder(params) {
31
31
  orderNumber
32
32
  })({ transaction: repos.transaction });
33
33
  // 注文取得
34
- let order = yield repos.order.findByOrderNumber({ orderNumber, inclusion: [], exclusion: [] });
34
+ let order = yield repos.order.findByOrderNumber({
35
+ orderNumber,
36
+ project: { id: params.project.id },
37
+ inclusion: [],
38
+ exclusion: []
39
+ });
35
40
  // プロジェクト条件検証
36
41
  if (order.project.id !== params.project.id) {
37
42
  throw new factory.errors.NotFound('Order');
@@ -69,6 +74,7 @@ function sendOrder(params) {
69
74
  return repos.ownershipInfo.createIfNotExistByIdentifier(ownershipInfo);
70
75
  })));
71
76
  order = yield repos.order.changeStatus({
77
+ project: { id: order.project.id },
72
78
  orderNumber,
73
79
  orderStatus: factory.orderStatus.OrderDelivered,
74
80
  previousOrderStatus: factory.orderStatus.OrderProcessing
@@ -98,6 +104,7 @@ function sendOrder(params) {
98
104
  // すでにOrderReturnedだった場合、OrderDelivered->OrderReturnedの処理自体は成功しているので、後処理を続行する
99
105
  const currentOrder = yield repos.order.findByOrderNumber({
100
106
  orderNumber: params.object.orderNumber,
107
+ project: { id: params.project.id },
101
108
  inclusion: ['orderStatus'],
102
109
  exclusion: []
103
110
  });
@@ -26,6 +26,7 @@ function verifyToken4reservation(params) {
26
26
  case factory.order.OrderType.Order:
27
27
  // reservationIdを含む注文の存在を確認するだけでよい(2023-01-31~)
28
28
  const order = yield repos.order.findByOrderNumberAndReservationId({
29
+ project: { id: params.project.id },
29
30
  orderNumber: payload.orderNumber,
30
31
  reservationId: params.reservationId,
31
32
  seller: params.seller
@@ -56,6 +56,7 @@ function onAuthorizationCreated(params) {
56
56
  // 最適化(2023-01-28~)
57
57
  const order = yield repos.order.findByOrderNumber({
58
58
  orderNumber,
59
+ project: { id: params.project.id },
59
60
  inclusion: ['acceptedOffers'],
60
61
  exclusion: []
61
62
  });
@@ -68,6 +68,7 @@ function returnPayTransaction(params) {
68
68
  }
69
69
  const order = yield repos.order.findByOrderNumber({
70
70
  orderNumber,
71
+ project: { id: returnOrderTransaction.project.id },
71
72
  inclusion: ['seller', 'project', 'dateReturned'],
72
73
  exclusion: []
73
74
  });
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.4.0-alpha.16"
120
+ "version": "21.4.0-alpha.17"
121
121
  }