@chevre/domain 21.4.0-alpha.3 → 21.4.0-alpha.30

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 (93) 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/iam/searchMemberOfIdsByMemberId.ts +31 -0
  6. package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +32 -0
  7. package/example/src/chevre/migrateEventOrganizer.ts +125 -0
  8. package/example/src/chevre/migrateIAMMemberMemberOf.ts +59 -0
  9. package/example/src/chevre/migrateReservationProvider.ts +119 -0
  10. package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
  11. package/example/src/chevre/processReserve.ts +0 -1
  12. package/example/src/chevre/searchEvents.ts +1 -9
  13. package/example/src/chevre/searchPermissions.ts +7 -15
  14. package/lib/chevre/factory/event.d.ts +1 -1
  15. package/lib/chevre/repo/action.d.ts +6 -0
  16. package/lib/chevre/repo/action.js +13 -0
  17. package/lib/chevre/repo/assetTransaction.d.ts +4 -1
  18. package/lib/chevre/repo/assetTransaction.js +6 -12
  19. package/lib/chevre/repo/event.d.ts +25 -4
  20. package/lib/chevre/repo/event.js +122 -60
  21. package/lib/chevre/repo/member.d.ts +76 -1
  22. package/lib/chevre/repo/member.js +81 -20
  23. package/lib/chevre/repo/mongoose/schemas/event.d.ts +7 -4
  24. package/lib/chevre/repo/mongoose/schemas/event.js +15 -2
  25. package/lib/chevre/repo/mongoose/schemas/member.d.ts +7 -7
  26. package/lib/chevre/repo/mongoose/schemas/member.js +12 -6
  27. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -6
  28. package/lib/chevre/repo/mongoose/schemas/place.js +9 -2
  29. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  30. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +6 -3
  31. package/lib/chevre/repo/mongoose/schemas/reservation.js +10 -4
  32. package/lib/chevre/repo/order.d.ts +21 -0
  33. package/lib/chevre/repo/order.js +54 -62
  34. package/lib/chevre/repo/place.d.ts +57 -16
  35. package/lib/chevre/repo/place.js +112 -167
  36. package/lib/chevre/repo/product.d.ts +2 -4
  37. package/lib/chevre/repo/product.js +52 -7
  38. package/lib/chevre/repo/reservation.d.ts +33 -21
  39. package/lib/chevre/repo/reservation.js +97 -79
  40. package/lib/chevre/repo/seller.d.ts +18 -5
  41. package/lib/chevre/repo/seller.js +53 -46
  42. package/lib/chevre/repo/task.d.ts +1 -1
  43. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
  45. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  46. package/lib/chevre/service/assetTransaction/pay/account/validation.js +9 -1
  47. package/lib/chevre/service/assetTransaction/pay.js +9 -1
  48. package/lib/chevre/service/assetTransaction/registerService.js +2 -2
  49. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +10 -4
  50. package/lib/chevre/service/assetTransaction/reserve/factory.js +21 -40
  51. package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
  52. package/lib/chevre/service/assetTransaction/reserve.js +7 -22
  53. package/lib/chevre/service/event/createEvent.d.ts +11 -0
  54. package/lib/chevre/service/event/createEvent.js +112 -0
  55. package/lib/chevre/service/event.d.ts +2 -0
  56. package/lib/chevre/service/event.js +26 -26
  57. package/lib/chevre/service/iam.d.ts +5 -0
  58. package/lib/chevre/service/iam.js +7 -19
  59. package/lib/chevre/service/moneyTransfer.js +1 -1
  60. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  61. package/lib/chevre/service/offer/event/authorize.js +6 -2
  62. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +16 -2
  63. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
  64. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  65. package/lib/chevre/service/order/returnOrder.js +8 -1
  66. package/lib/chevre/service/order/sendOrder.js +8 -1
  67. package/lib/chevre/service/payment/creditCard.js +9 -1
  68. package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -1
  69. package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
  70. package/lib/chevre/service/payment/movieTicket.js +19 -2
  71. package/lib/chevre/service/payment/paymentCard.js +1 -3
  72. package/lib/chevre/service/reserve/cancelReservation.js +15 -28
  73. package/lib/chevre/service/reserve/confirmReservation.js +14 -30
  74. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
  75. package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
  76. package/lib/chevre/service/task/{syncScreeningRooms.d.ts → createEvent.d.ts} +1 -1
  77. package/lib/chevre/service/task/{syncScreeningRooms.js → createEvent.js} +11 -3
  78. package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
  79. package/lib/chevre/service/task/returnPayTransaction.js +1 -0
  80. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  81. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
  82. package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
  83. package/lib/chevre/service/transaction/returnOrder.js +9 -3
  84. package/package.json +3 -3
  85. package/example/src/chevre/findByOrderNumberAndReservationId.ts +0 -20
  86. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
  87. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +0 -90
  88. package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -75
  89. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +0 -64
  90. package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +0 -79
  91. package/example/src/chevre/searchScreeningRooms.ts +0 -33
  92. package/example/src/chevre/syncScreeningRooms.ts +0 -21
  93. package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
@@ -23,22 +23,15 @@ function cancelPendingReservation(actionAttributes) {
23
23
  return (repos) => __awaiter(this, void 0, void 0, function* () {
24
24
  var _a;
25
25
  const now = new Date();
26
- let canceledReservations = [];
26
+ const canceledReservations = [];
27
27
  const { reserveTransaction } = yield cancelPengindIfNotYet(actionAttributes, now)(repos);
28
28
  if (actionAttributes.object.typeOf === factory.reservationType.ReservationPackage) {
29
29
  if (reserveTransaction.object.disablePendingReservations === true) {
30
30
  // Pendingが存在しない場合は検索しても無駄(2023-06-05~)
31
31
  }
32
32
  else {
33
- canceledReservations = yield repos.reservation.search({
34
- reservationNumber: { $eq: actionAttributes.object.reservationNumber },
35
- typeOf: factory.reservationType.EventReservation
36
- });
37
- canceledReservations = canceledReservations.map((r) => {
38
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
39
- delete r._id;
40
- return r;
41
- });
33
+ // 完全廃止(2023-07-19~)
34
+ throw new factory.errors.NotImplemented('disablePendingReservations must be true');
42
35
  }
43
36
  }
44
37
  yield (0, onReservationCanceled_1.onReservationCanceled)(canceledReservations, false, {
@@ -48,7 +41,7 @@ function cancelPendingReservation(actionAttributes) {
48
41
  });
49
42
  }
50
43
  exports.cancelPendingReservation = cancelPendingReservation;
51
- function cancelPengindIfNotYet(params, now) {
44
+ function cancelPengindIfNotYet(params, __) {
52
45
  // tslint:disable-next-line:max-func-body-length
53
46
  return (repos) => __awaiter(this, void 0, void 0, function* () {
54
47
  const actionAttributes = params;
@@ -83,7 +76,7 @@ function cancelPengindIfNotYet(params, now) {
83
76
  // アクション開始
84
77
  const action = yield repos.action.start(actionAttributes);
85
78
  const actionObject = actionAttributes.object;
86
- let cancelResult;
79
+ // let cancelResult: ICancelResult | undefined;
87
80
  try {
88
81
  if (reserveTransaction !== undefined) {
89
82
  const reservationFor = reserveTransaction.object.reservationFor;
@@ -126,12 +119,8 @@ function cancelPengindIfNotYet(params, now) {
126
119
  // disablePendingReservationsの場合は処理不要(2023-06-05~)
127
120
  }
128
121
  else {
129
- // 予約番号単位でキャンセル状態に変更する
130
- cancelResult = yield repos.reservation.cancelByReservationNumber({
131
- reservationNumber: actionObject.reservationNumber,
132
- previousReservationStatus: actionObject.reservationStatus,
133
- modifiedTime: now
134
- });
122
+ // 完全廃止(2023-07-19~)
123
+ throw new factory.errors.NotImplemented('disablePendingReservations must be true');
135
124
  }
136
125
  }
137
126
  else {
@@ -152,17 +141,15 @@ function cancelPengindIfNotYet(params, now) {
152
141
  throw error;
153
142
  }
154
143
  // アクション完了
155
- const actionResult = Object.assign({}, (cancelResult !== undefined) ? {
156
- cancelResult: {
157
- // n: cancelResult.n,
158
- // nModified: cancelResult.nModified,
159
- // ok: cancelResult.ok,
160
- matchedCount: cancelResult.matchedCount,
161
- modifiedCount: cancelResult.modifiedCount
162
- }
163
- } : undefined
144
+ const actionResult = {
145
+ // ...(cancelResult !== undefined) ? {
146
+ // cancelResult: {
147
+ // matchedCount: cancelResult.matchedCount,
148
+ // modifiedCount: cancelResult.modifiedCount
149
+ // }
150
+ // } : undefined
164
151
  // canceledReservationId: canceledReservation?.id
165
- );
152
+ };
166
153
  yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: actionResult });
167
154
  }
168
155
  return { reserveTransaction };
@@ -51,7 +51,7 @@ exports.confirmReservation = confirmReservation;
51
51
  function reserveIfNotYet(params, options) {
52
52
  // tslint:disable-next-line:max-func-body-length
53
53
  return (repos) => __awaiter(this, void 0, void 0, function* () {
54
- var _a;
54
+ var _a, _b;
55
55
  const reservationPackage = params.object;
56
56
  // 冪等性を担保(2023-05-31~)
57
57
  debug('searching completed reserveAction... byTask:', options === null || options === void 0 ? void 0 : options.byTask, 'reservationNumber:', reservationPackage.reservationNumber);
@@ -97,50 +97,34 @@ function reserveIfNotYet(params, options) {
97
97
  if (reserveTransaction.object.disablePendingReservations === true) {
98
98
  const reservationFor = reserveTransaction.object.reservationFor;
99
99
  const subReservations = reserveTransaction.object.subReservation;
100
- if (Array.isArray(subReservations) && typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.typeOf) === 'string') {
100
+ const issuedThrough = reserveTransaction.object.issuedThrough;
101
+ if (Array.isArray(subReservations)
102
+ && typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.typeOf) === 'string'
103
+ && typeof (issuedThrough === null || issuedThrough === void 0 ? void 0 : issuedThrough.typeOf) === 'string') {
101
104
  // confirmManyに変更(2023-06-13~)
102
105
  const confirmManyIfNotExistResult = yield repos.reservation.confirmManyIfNotExist({
106
+ provider: (typeof ((_b = reserveTransaction.object.provider) === null || _b === void 0 ? void 0 : _b.id) === 'string')
107
+ ? reserveTransaction.object.provider
108
+ : { id: reserveTransaction.agent.id, typeOf: factory.organizationType.Corporation },
103
109
  subReservation: subReservations,
110
+ issuedThrough,
104
111
  reservationFor,
105
112
  underName,
106
- broker: reserveTransaction.object.broker,
107
- issuedThrough: reserveTransaction.object.issuedThrough
113
+ broker: reserveTransaction.object.broker
108
114
  });
109
115
  debug('confirmManyIfNotExistResult:', confirmManyIfNotExistResult, 'reservationNumber:', reservationPackage.reservationNumber);
110
- // await Promise.all(subReservations.map(async (subReservation) => {
111
- // await repos.reservation.confirmByIdIfNotExist({
112
- // reservation: subReservation,
113
- // reservationFor,
114
- // underName,
115
- // broker: reserveTransaction.object.broker,
116
- // issuedThrough: reserveTransaction.object.issuedThrough
117
- // });
118
- // }));
119
116
  }
120
117
  }
121
118
  else {
122
- // 予約を確定状態に変更する
123
- yield repos.reservation.confirmByReservationNumber({
124
- reservationNumber: reservationPackage.reservationNumber,
125
- previousReservationStatus: reservationPackage.reservationStatus,
126
- underName,
127
- broker: reserveTransaction.object.broker,
128
- issuedThrough: reserveTransaction.object.issuedThrough
129
- });
119
+ // 旧予約取引に対して本処理が走る可能性がなくはないが、
120
+ // それらについては実質Confirmedの予約はすでに存在するはずなので、何もしない
121
+ // 完全廃止(2023-07-19~)
122
+ // throw new factory.errors.NotImplemented('disablePendingReservations must be true');
130
123
  }
131
124
  }
132
125
  else {
133
126
  // 廃止(2023-01-18)
134
127
  throw new factory.errors.Forbidden(`${reservationPackage.typeOf} not acceptable`);
135
- // 予約を確定状態に変更する
136
- // await repos.reservation.confirm<factory.reservationType.EventReservation>({
137
- // id: reservation.id,
138
- // previousReservationStatus: reservation.reservationStatus,
139
- // underName: reservation.underName
140
- // });
141
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
142
- // delete (<any>reservation)._id;
143
- // confirmedReservations.push(reservation);
144
128
  }
145
129
  }
146
130
  catch (error) {
@@ -7,6 +7,9 @@ export declare function verifyToken4reservation(params: {
7
7
  project: {
8
8
  id: string;
9
9
  };
10
+ seller?: {
11
+ id?: string;
12
+ };
10
13
  agent: factory.action.check.token.IAgent;
11
14
  reservationId: string;
12
15
  token: string;
@@ -26,8 +26,10 @@ 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
- reservationId: params.reservationId
31
+ reservationId: params.reservationId,
32
+ seller: params.seller
31
33
  });
32
34
  // ステータス検証
33
35
  switch (order.orderStatus) {
@@ -4,4 +4,4 @@ export type IOperation<T> = (settings: IConnectionSettings) => Promise<T>;
4
4
  /**
5
5
  * タスク実行関数
6
6
  */
7
- export declare function call(data: factory.task.syncScreeningRooms.IData): IOperation<void>;
7
+ export declare function call(data: factory.task.createEvent.IData): IOperation<void>;
@@ -10,14 +10,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
+ const action_1 = require("../../repo/action");
14
+ const event_1 = require("../../repo/event");
13
15
  const place_1 = require("../../repo/place");
16
+ const task_1 = require("../../repo/task");
17
+ const EventService = require("../event");
14
18
  /**
15
19
  * タスク実行関数
16
20
  */
17
21
  function call(data) {
18
- return (connectionSettings) => __awaiter(this, void 0, void 0, function* () {
19
- const placeRepo = new place_1.MongoRepository(connectionSettings.connection);
20
- yield placeRepo.syncScreeningRooms({ id: data.id });
22
+ return (settings) => __awaiter(this, void 0, void 0, function* () {
23
+ yield EventService.createEvent(data)({
24
+ action: new action_1.MongoRepository(settings.connection),
25
+ event: new event_1.MongoRepository(settings.connection),
26
+ place: new place_1.MongoRepository(settings.connection),
27
+ task: new task_1.MongoRepository(settings.connection)
28
+ });
21
29
  });
22
30
  }
23
31
  exports.call = call;
@@ -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
  });
@@ -28,7 +28,15 @@ const CodeService = require("../code");
28
28
  */
29
29
  function start(params) {
30
30
  return (repos) => __awaiter(this, void 0, void 0, function* () {
31
- const seller = yield repos.seller.findById({ id: params.seller.id }, ['name', 'typeOf'], []);
31
+ const sellers = yield repos.seller.search({
32
+ limit: 1,
33
+ page: 1,
34
+ id: { $eq: params.seller.id }
35
+ }, ['name', 'typeOf'], []);
36
+ const seller = sellers.shift();
37
+ if (seller === undefined) {
38
+ throw new factory.errors.NotFound(factory.organizationType.Corporation);
39
+ }
32
40
  const passport = yield (0, validation_1.validateWaiterPassport)(params);
33
41
  // 金額をfix
34
42
  const amount = params.object.amount;
@@ -112,7 +112,7 @@ function getCreditCardPaymentServiceChannel(params) {
112
112
  throw new factory.errors.NotFound('PaymentService');
113
113
  }
114
114
  // IDで検索いないとavailableChannelを取得できない
115
- const paymentService = yield repos.product.findById({ id: String(paymentServiceSetting.id) });
115
+ const paymentService = yield repos.product.findById({ id: String(paymentServiceSetting.id) }, ['availableChannel'], []);
116
116
  const availableChannel = paymentService === null || paymentService === void 0 ? void 0 : paymentService.availableChannel;
117
117
  if (typeof (availableChannel === null || availableChannel === void 0 ? void 0 : availableChannel.serviceUrl) !== 'string') {
118
118
  throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
@@ -29,12 +29,15 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
29
29
  function start(params) {
30
30
  return (repos) => __awaiter(this, void 0, void 0, function* () {
31
31
  var _a;
32
- const seller = yield repos.seller.findById({ id: params.seller.id }, ['name', 'project', 'typeOf', 'makesOffer'], []
33
- // {
34
- // hasMerchantReturnPolicy: 0,
35
- // paymentAccepted: 0
36
- // }
37
- );
32
+ const sellers = yield repos.seller.search({
33
+ limit: 1,
34
+ page: 1,
35
+ id: { $eq: params.seller.id }
36
+ }, ['name', 'project', 'typeOf', 'makesOffer'], []);
37
+ const seller = sellers.shift();
38
+ if (seller === undefined) {
39
+ throw new factory.errors.NotFound(factory.organizationType.Corporation);
40
+ }
38
41
  let makesOfferFromClient;
39
42
  // 販売者オファー検証(2022-10-14~)
40
43
  if (params.validateSeller === true) {
@@ -29,9 +29,15 @@ function start(params) {
29
29
  const now = new Date();
30
30
  const { acceptedOffers, eventIds, offerIds, orders } = yield fixOrders(params)(repos);
31
31
  // sellerはorderから自動取得
32
- const seller = yield repos.seller.findById({ id: String(orders[0].seller.id) }, ['name', 'project', 'hasMerchantReturnPolicy', 'typeOf'], []
33
- // { additionalProperty: 0, paymentAccepted: 0 }
34
- );
32
+ const sellers = yield repos.seller.search({
33
+ limit: 1,
34
+ page: 1,
35
+ id: { $eq: String(orders[0].seller.id) }
36
+ }, ['name', 'project', 'hasMerchantReturnPolicy', 'typeOf'], []);
37
+ const seller = sellers.shift();
38
+ if (seller === undefined) {
39
+ throw new factory.errors.NotFound(factory.organizationType.Corporation);
40
+ }
35
41
  yield validateOrder({ orders })(repos);
36
42
  let offers = [];
37
43
  if (offerIds.length > 0) {
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.314.0",
13
- "@cinerino/sdk": "3.157.1",
12
+ "@chevre/factory": "4.316.0-alpha.6",
13
+ "@cinerino/sdk": "3.162.0-alpha.1",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -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.3"
120
+ "version": "21.4.0-alpha.30"
121
121
  }
@@ -1,20 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
-
9
- const orderRepo = new chevre.repository.Order(mongoose.connection);
10
-
11
- const order = await orderRepo.findByOrderNumberAndReservationId({
12
- orderNumber: 'CIN9-4783801-1618274',
13
- reservationId: '139787058570943-0'
14
- });
15
- console.log('order found', order);
16
- }
17
-
18
- main()
19
- .then()
20
- .catch(console.error);
@@ -1,27 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- async function main() {
7
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
-
9
- const placeRepo = new chevre.repository.Place(mongoose.connection);
10
-
11
- const screeningRoom = await placeRepo.findScreeningRoomsByBranchCode({
12
- branchCode: {
13
- $eq: '20'
14
- },
15
- containedInPlace: {
16
- id: {
17
- $eq: '5bfb841d5a78d7948369979a'
18
- }
19
- }
20
- });
21
- console.log('room found', screeningRoom);
22
-
23
- }
24
-
25
- main()
26
- .then(console.log)
27
- .catch(console.error);
@@ -1,90 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
10
-
11
- // tslint:disable-next-line:max-func-body-length
12
- async function main() {
13
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
14
-
15
- const eventRepo = new chevre.repository.Event(mongoose.connection);
16
-
17
- const cursor = eventRepo.getCursor(
18
- {
19
- // 'project.id': { $eq: project.id },
20
- 'project.id': { $ne: EXCLUDED_PROJECT_ID },
21
- typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
22
- startDate: {
23
- $gte: moment()
24
- // tslint:disable-next-line:no-magic-numbers
25
- .add(-6, 'months')
26
- .toDate()
27
- }
28
- // _id: { $eq: 'al6aff83w' }
29
- },
30
- {
31
- // _id: 1,
32
- }
33
- );
34
- console.log('events found');
35
-
36
- let i = 0;
37
- let updateCount = 0;
38
- await cursor.eachAsync(async (doc) => {
39
- i += 1;
40
- const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
41
-
42
- const eventOffers = <chevre.factory.event.screeningEvent.IOffer | undefined>event.offers;
43
- if (eventOffers === undefined) {
44
- throw new Error('event.offers undefined');
45
- }
46
-
47
- const availableChannel = eventOffers.itemOffered.availableChannel;
48
-
49
- const alreadyMigrated = availableChannel?.typeOf === 'ServiceChannel';
50
-
51
- if (alreadyMigrated) {
52
- console.log(
53
- 'already exist...', event.project.id, event.id, event.startDate, availableChannel.serviceLocation.branchCode, i);
54
- } else {
55
- const newAvailableChannel: chevre.factory.reservation.IServiceChannel = {
56
- typeOf: 'ServiceChannel',
57
- serviceLocation: {
58
- typeOf: event.location.typeOf,
59
- branchCode: event.location.branchCode,
60
- name: event.location.name,
61
- containedInPlace: {
62
- typeOf: event.superEvent.location.typeOf,
63
- id: event.superEvent.location.id,
64
- branchCode: event.superEvent.location.branchCode,
65
- name: event.superEvent.location.name
66
- }
67
- }
68
- };
69
- console.log(
70
- 'updating seller...', event.project.id, event.id, event.startDate, newAvailableChannel.serviceLocation.branchCode, i);
71
- await eventRepo.updatePartiallyById({
72
- id: event.id,
73
- attributes: <any>{
74
- typeOf: event.typeOf,
75
- 'offers.itemOffered.availableChannel': newAvailableChannel
76
- }
77
- });
78
- updateCount += 1;
79
- console.log(
80
- 'updated...', event.project.id, event.id, event.startDate, i);
81
- }
82
- });
83
-
84
- console.log(i, 'events checked');
85
- console.log(updateCount, 'events updated');
86
- }
87
-
88
- main()
89
- .then()
90
- .catch(console.error);
@@ -1,75 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- // const project = { id: String(process.env.PROJECT_ID) };
8
- const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
-
14
- const eventRepo = new chevre.repository.Event(mongoose.connection);
15
-
16
- const cursor = eventRepo.getCursor(
17
- {
18
- // 'project.id': { $eq: project.id },
19
- 'project.id': { $ne: EXCLUDED_PROJECT_ID },
20
- typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
21
- startDate: {
22
- $gte: moment()
23
- .add(-1, 'month')
24
- .toDate()
25
- }
26
- // _id: { $eq: 'al6aff83w' }
27
- },
28
- {
29
- // _id: 1,
30
- }
31
- );
32
- console.log('events found');
33
-
34
- let i = 0;
35
- let updateCount = 0;
36
- await cursor.eachAsync(async (doc) => {
37
- i += 1;
38
- const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
39
-
40
- // IAMメンバー検索
41
- const eventOffers = <chevre.factory.event.screeningEvent.IOffer | undefined>event.offers;
42
- if (eventOffers === undefined) {
43
- throw new Error('event.offers undefined');
44
- }
45
-
46
- const itemOfferedTypeOf = eventOffers.itemOffered.typeOf;
47
-
48
- const alreadyMigrated = itemOfferedTypeOf === chevre.factory.product.ProductType.EventService;
49
-
50
- if (alreadyMigrated) {
51
- console.log(
52
- 'already exist...', event.project.id, event.id, event.startDate, itemOfferedTypeOf, i);
53
- } else {
54
- console.log(
55
- 'updating seller...', event.project.id, event.id, event.startDate, i);
56
- await eventRepo.updatePartiallyById({
57
- id: event.id,
58
- attributes: <any>{
59
- typeOf: event.typeOf,
60
- 'offers.itemOffered.typeOf': chevre.factory.product.ProductType.EventService
61
- }
62
- });
63
- updateCount += 1;
64
- console.log(
65
- 'updated...', event.project.id, event.id, event.startDate, i);
66
- }
67
- });
68
-
69
- console.log(i, 'events checked');
70
- console.log(updateCount, 'events updated');
71
- }
72
-
73
- main()
74
- .then()
75
- .catch(console.error);
@@ -1,64 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
- const DELETING_PROPERTY_NAME: string = 'COA_ENDPOINT';
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const eventRepo = new chevre.repository.Event(mongoose.connection);
13
-
14
- const cursor = eventRepo.getCursor(
15
- {
16
- 'project.id': { $eq: project.id },
17
- typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries }
18
- // typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
19
- // startDate: { $gte: new Date() }
20
- },
21
- {
22
- // _id: 1,
23
- }
24
- );
25
- console.log('events found');
26
-
27
- let i = 0;
28
- let updateCount = 0;
29
- await cursor.eachAsync(async (doc) => {
30
- i += 1;
31
- const event: chevre.factory.event.IEvent<chevre.factory.eventType> = doc.toObject();
32
-
33
- const coaEndpointPropert = event.additionalProperty?.find((p) => p.name === DELETING_PROPERTY_NAME);
34
-
35
- if (coaEndpointPropert !== undefined) {
36
- const newAdditionalProperty: chevre.factory.propertyValue.IPropertyValue<string>[] =
37
- (Array.isArray(event.additionalProperty))
38
- ? event.additionalProperty.filter((p) => {
39
- return p.name !== DELETING_PROPERTY_NAME;
40
- })
41
- : [];
42
- console.log(
43
- 'updating event...', event.project.id, event.id, event.startDate, coaEndpointPropert.value, newAdditionalProperty, i);
44
- await eventRepo.updatePartiallyById({
45
- id: event.id,
46
- attributes: <any>{
47
- typeOf: event.typeOf,
48
- additionalProperty: newAdditionalProperty
49
- }
50
- });
51
- updateCount += 1;
52
- console.log('event updated', event.project.id, event.id, event.startDate, i);
53
- } else {
54
- console.log('no property...', event.project.id, event.id, event.startDate, i);
55
- }
56
- });
57
-
58
- console.log(i, 'events checked');
59
- console.log(updateCount, 'events updated');
60
- }
61
-
62
- main()
63
- .then()
64
- .catch(console.error);