@chevre/domain 20.2.0-alpha.2 → 20.2.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 (67) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +82 -0
  3. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  4. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +90 -0
  5. package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -5
  6. package/example/src/chevre/migratePaymentServicePaymentUrlExpiresInSeconds.ts +77 -0
  7. package/lib/chevre/repo/action.d.ts +58 -0
  8. package/lib/chevre/repo/action.js +187 -0
  9. package/lib/chevre/repo/aggregation.d.ts +34 -0
  10. package/lib/chevre/repo/aggregation.js +64 -0
  11. package/lib/chevre/repo/event.d.ts +0 -1
  12. package/lib/chevre/repo/event.js +124 -105
  13. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  14. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  15. package/lib/chevre/repo/mongoose/model/event.js +2 -2
  16. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  17. package/lib/chevre/repo/order.d.ts +9 -0
  18. package/lib/chevre/repo/order.js +49 -0
  19. package/lib/chevre/repo/place.d.ts +15 -1
  20. package/lib/chevre/repo/place.js +205 -52
  21. package/lib/chevre/repo/product.d.ts +1 -0
  22. package/lib/chevre/repo/product.js +5 -0
  23. package/lib/chevre/repo/reservation.d.ts +0 -6
  24. package/lib/chevre/repo/reservation.js +106 -66
  25. package/lib/chevre/repo/transaction.d.ts +29 -0
  26. package/lib/chevre/repo/transaction.js +133 -0
  27. package/lib/chevre/repo/trip.js +33 -27
  28. package/lib/chevre/repository.d.ts +3 -0
  29. package/lib/chevre/repository.js +5 -1
  30. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
  31. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +34 -13
  32. package/lib/chevre/service/aggregation/system.d.ts +74 -0
  33. package/lib/chevre/service/aggregation/system.js +266 -0
  34. package/lib/chevre/service/aggregation.d.ts +2 -0
  35. package/lib/chevre/service/aggregation.js +3 -1
  36. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  37. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  38. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  39. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  40. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  41. package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
  42. package/lib/chevre/service/assetTransaction/reserve.js +33 -51
  43. package/lib/chevre/service/delivery/factory.js +1 -0
  44. package/lib/chevre/service/event.d.ts +2 -4
  45. package/lib/chevre/service/event.js +21 -10
  46. package/lib/chevre/service/offer/event/cancel.js +0 -1
  47. package/lib/chevre/service/offer/event/factory.js +25 -5
  48. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +116 -4
  49. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  50. package/lib/chevre/service/offer.js +28 -20
  51. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
  52. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  53. package/lib/chevre/service/order/placeOrder.js +16 -0
  54. package/lib/chevre/service/payment/any.d.ts +5 -0
  55. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  56. package/lib/chevre/service/reserve/useReservation.js +2 -1
  57. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  58. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  59. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  60. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  61. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
  62. package/lib/chevre/settings.d.ts +2 -0
  63. package/lib/chevre/settings.js +7 -2
  64. package/package.json +3 -3
  65. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  66. package/example/src/chevre/migrateEventProjectAttributes.ts +0 -57
  67. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
@@ -41,6 +41,22 @@ function createOrder(params) {
41
41
  : undefined) });
42
42
  return Object.assign(Object.assign({}, o), { itemOffered });
43
43
  }
44
+ else if (o.itemOffered.typeOf === factory.reservationType.BusReservation) {
45
+ let itemOffered = o.itemOffered;
46
+ const reservationFor = itemOffered.reservationFor;
47
+ itemOffered = Object.assign(Object.assign({}, itemOffered), { reservationFor: Object.assign(Object.assign(Object.assign({}, reservationFor), (reservationFor.arrivalTime !== undefined)
48
+ ? {
49
+ arrivalTime: moment(reservationFor.arrivalTime)
50
+ .toDate()
51
+ }
52
+ : undefined), (reservationFor.departureTime !== undefined)
53
+ ? {
54
+ departureTime: moment(reservationFor.departureTime)
55
+ .toDate()
56
+ }
57
+ : undefined) });
58
+ return Object.assign(Object.assign({}, o), { itemOffered });
59
+ }
44
60
  else {
45
61
  return o;
46
62
  }
@@ -47,7 +47,12 @@ declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskNam
47
47
  */
48
48
  declare function processVoidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction>): (repos: {
49
49
  action: ActionRepo;
50
+ accountingReport: AccountingReportRepo;
50
51
  assetTransaction: AssetTransactionRepo;
52
+ product: ProductRepo;
53
+ project: ProjectRepo;
54
+ seller: SellerRepo;
55
+ task: TaskRepo;
51
56
  transaction: TransactionRepo;
52
57
  }) => Promise<void>;
53
58
  interface IAuthorizeRepos {
@@ -37,17 +37,14 @@ function confirmReservation(actionAttributesList) {
37
37
  });
38
38
  }
39
39
  else {
40
+ // 廃止(2023-01-18)
41
+ throw new factory.errors.Forbidden(`${reservation.typeOf} not acceptable`);
40
42
  // 予約を確定状態に変更する
41
- // reservation = await repos.reservation.confirm<factory.reservationType.EventReservation>({
42
- yield repos.reservation.confirm({
43
- // 更新属性をwhitelist化(2022-06-13~)
44
- // ...actionAttributes.object,
45
- id: reservation.id,
46
- previousReservationStatus: reservation.reservationStatus,
47
- underName: reservation.underName
48
- // issuedThroughは予約取引開始時に確定しているので更新不要(2022-12-21~)
49
- // reservedTicket: reservation.reservedTicket
50
- });
43
+ // await repos.reservation.confirm<factory.reservationType.EventReservation>({
44
+ // id: reservation.id,
45
+ // previousReservationStatus: reservation.reservationStatus,
46
+ // underName: reservation.underName
47
+ // });
51
48
  // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
52
49
  // delete (<any>reservation)._id;
53
50
  // confirmedReservations.push(reservation);
@@ -37,7 +37,8 @@ function verifyToken4reservation(params) {
37
37
  }
38
38
  const acceptedOffers = (Array.isArray(order.acceptedOffers)) ? order.acceptedOffers : [];
39
39
  const reservationExistsInOrder = acceptedOffers.some((offer) => {
40
- return offer.itemOffered.typeOf === factory.reservationType.EventReservation
40
+ return (offer.itemOffered.typeOf === factory.reservationType.EventReservation
41
+ || offer.itemOffered.typeOf === factory.reservationType.BusReservation)
41
42
  && offer.itemOffered.id === params.reservationId;
42
43
  });
43
44
  if (!reservationExistsInOrder) {
@@ -10,9 +10,15 @@ 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 accountingReport_1 = require("../../repo/accountingReport");
13
14
  const action_1 = require("../../repo/action");
14
15
  const assetTransaction_1 = require("../../repo/assetTransaction");
16
+ const event_1 = require("../../repo/event");
15
17
  const order_1 = require("../../repo/order");
18
+ const product_1 = require("../../repo/product");
19
+ const project_1 = require("../../repo/project");
20
+ const seller_1 = require("../../repo/seller");
21
+ const task_1 = require("../../repo/task");
16
22
  const PayTransactionService = require("../assetTransaction/pay");
17
23
  /**
18
24
  * タスク実行関数
@@ -22,6 +28,12 @@ function call(data) {
22
28
  const actionRepo = new action_1.MongoRepository(settings.connection);
23
29
  const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
24
30
  const orderRepo = new order_1.MongoRepository(settings.connection);
31
+ const accountingReportRepo = new accountingReport_1.MongoRepository(settings.connection);
32
+ const eventRepo = new event_1.MongoRepository(settings.connection);
33
+ const productRepo = new product_1.MongoRepository(settings.connection);
34
+ const projectRepo = new project_1.MongoRepository(settings.connection);
35
+ const sellerRepo = new seller_1.MongoRepository(settings.connection);
36
+ const taskRepo = new task_1.MongoRepository(settings.connection);
25
37
  // アクション開始
26
38
  const action = yield actionRepo.start(data);
27
39
  try {
@@ -38,8 +50,15 @@ function call(data) {
38
50
  }
39
51
  }
40
52
  })({
53
+ action: actionRepo,
54
+ accountingReport: accountingReportRepo,
41
55
  assetTransaction: assetTransactionRepo,
42
- order: orderRepo
56
+ event: eventRepo,
57
+ order: orderRepo,
58
+ product: productRepo,
59
+ project: projectRepo,
60
+ seller: sellerRepo,
61
+ task: taskRepo
43
62
  });
44
63
  }
45
64
  }
@@ -3,6 +3,8 @@ import * as factory from '../../factory';
3
3
  import { MongoRepository as ActionRepo } from '../../repo/action';
4
4
  import { MongoRepository as AssetTransactionRepo } from '../../repo/assetTransaction';
5
5
  import { MongoRepository as OrderRepo } from '../../repo/order';
6
+ import { MongoRepository as ReservationRepo } from '../../repo/reservation';
7
+ import { MongoRepository as TaskRepo } from '../../repo/task';
6
8
  /**
7
9
  * タスク実行関数
8
10
  */
@@ -14,4 +16,6 @@ export declare function confirmReserveTransaction(params: factory.action.interac
14
16
  action: ActionRepo;
15
17
  assetTransaction: AssetTransactionRepo;
16
18
  order: OrderRepo;
19
+ reservation: ReservationRepo;
20
+ task: TaskRepo;
17
21
  }) => Promise<void>;
@@ -15,6 +15,8 @@ const factory = require("../../factory");
15
15
  const action_1 = require("../../repo/action");
16
16
  const assetTransaction_1 = require("../../repo/assetTransaction");
17
17
  const order_1 = require("../../repo/order");
18
+ const reservation_1 = require("../../repo/reservation");
19
+ const task_1 = require("../../repo/task");
18
20
  const ReserveTransactionService = require("../assetTransaction/reserve");
19
21
  const credentials_1 = require("../../credentials");
20
22
  const coaAuthClient = new COA.auth.RefreshToken({
@@ -29,7 +31,9 @@ function call(data) {
29
31
  yield confirmReserveTransaction(data)({
30
32
  action: new action_1.MongoRepository(settings.connection),
31
33
  assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
32
- order: new order_1.MongoRepository(settings.connection)
34
+ order: new order_1.MongoRepository(settings.connection),
35
+ reservation: new reservation_1.MongoRepository(settings.connection),
36
+ task: new task_1.MongoRepository(settings.connection)
33
37
  });
34
38
  });
35
39
  }
@@ -44,9 +48,6 @@ function confirmReserveTransaction(params) {
44
48
  const action = yield repos.action.start(confirmActionAttributes);
45
49
  try {
46
50
  let object = confirmActionAttributes.object;
47
- // if (params.instrument === undefined) {
48
- // params.instrument = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
49
- // }
50
51
  switch (params.instrument.identifier) {
51
52
  case factory.service.webAPI.Identifier.COA:
52
53
  // COA本予約
@@ -72,7 +73,6 @@ function confirmReserveTransaction(params) {
72
73
  object = object;
73
74
  yield ReserveTransactionService.confirm({
74
75
  transactionNumber: object.transactionNumber,
75
- // object: object.object,
76
76
  potentialActions: object.potentialActions
77
77
  })(repos);
78
78
  }
@@ -14,6 +14,7 @@ const action_1 = require("../../repo/action");
14
14
  const categoryCode_1 = require("../../repo/categoryCode");
15
15
  const event_1 = require("../../repo/event");
16
16
  const place_1 = require("../../repo/place");
17
+ const seller_1 = require("../../repo/seller");
17
18
  const EventService = require("../event");
18
19
  /**
19
20
  * タスク実行関数
@@ -24,7 +25,8 @@ function call(data) {
24
25
  action: new action_1.MongoRepository(settings.connection),
25
26
  categoryCode: new categoryCode_1.MongoRepository(settings.connection),
26
27
  event: new event_1.MongoRepository(settings.connection),
27
- place: new place_1.MongoRepository(settings.connection)
28
+ place: new place_1.MongoRepository(settings.connection),
29
+ seller: new seller_1.MongoRepository(settings.connection)
28
30
  });
29
31
  });
30
32
  }
@@ -35,37 +35,52 @@ function createReservationAcceptedOffers(params) {
35
35
  }
36
36
  exports.createReservationAcceptedOffers = createReservationAcceptedOffers;
37
37
  function reservationOffers2orderedItem(params) {
38
- var _a, _b, _c, _d;
38
+ var _a, _b, _c, _d, _e;
39
39
  const reservationFor = params.reservationFor;
40
40
  const issuedThrough = params.issuedThrough;
41
- if (reservationFor.typeOf !== factory.eventType.ScreeningEvent) {
42
- throw new factory.errors.NotImplemented(`reservationFor.typeOf '${reservationFor.typeOf}' not implemented`);
43
- }
44
- const reservationFor4orderedItem = {
45
- location: {
46
- branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
47
- name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
41
+ if (reservationFor.typeOf === factory.eventType.ScreeningEvent
42
+ && issuedThrough.typeOf === factory.product.ProductType.EventService) {
43
+ const reservationFor4orderedItem = {
44
+ location: {
45
+ branchCode: (_a = reservationFor.location) === null || _a === void 0 ? void 0 : _a.branchCode,
46
+ name: (_b = reservationFor.location) === null || _b === void 0 ? void 0 : _b.name,
47
+ // 不要なので廃止(2022-12-19~)
48
+ // project: reservationFor.location?.project,
49
+ typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
50
+ },
48
51
  // 不要なので廃止(2022-12-19~)
49
- // project: reservationFor.location?.project,
50
- typeOf: (_c = reservationFor.location) === null || _c === void 0 ? void 0 : _c.typeOf
51
- },
52
- // 不要なので廃止(2022-12-19~)
53
- // project: reservationFor.project,
54
- typeOf: reservationFor.typeOf,
55
- id: reservationFor.id,
56
- name: reservationFor.name,
57
- startDate: reservationFor.startDate,
58
- endDate: reservationFor.endDate
59
- };
60
- if (issuedThrough.typeOf !== factory.product.ProductType.EventService) {
61
- throw new factory.errors.NotImplemented(`issuedThrough.typeOf '${issuedThrough.typeOf}' not implemented`);
52
+ // project: reservationFor.project,
53
+ typeOf: reservationFor.typeOf,
54
+ id: reservationFor.id,
55
+ name: reservationFor.name,
56
+ startDate: reservationFor.startDate,
57
+ endDate: reservationFor.endDate
58
+ };
59
+ return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
60
+ ? { serviceType: issuedThrough.serviceType }
61
+ : undefined), { serviceOutput: {
62
+ typeOf: factory.reservationType.EventReservation,
63
+ reservationFor: reservationFor4orderedItem
64
+ } });
65
+ }
66
+ else if (reservationFor.typeOf === factory.tripType.BusTrip
67
+ && issuedThrough.typeOf === factory.product.ProductType.Transportation) {
68
+ const reservationFor4orderedItem = {
69
+ typeOf: reservationFor.typeOf,
70
+ id: reservationFor.id,
71
+ departureTime: reservationFor.departureTime,
72
+ arrivalTime: reservationFor.arrivalTime
73
+ };
74
+ return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_e = issuedThrough.serviceType) === null || _e === void 0 ? void 0 : _e.typeOf) === 'string')
75
+ ? { serviceType: issuedThrough.serviceType }
76
+ : undefined), { serviceOutput: {
77
+ typeOf: factory.reservationType.ReservationPackage,
78
+ reservationFor: reservationFor4orderedItem
79
+ } });
80
+ }
81
+ else {
82
+ throw new factory.errors.ServiceUnavailable('unexpected params on reservationOffers2orderedItem');
62
83
  }
63
- return Object.assign(Object.assign({ typeOf: issuedThrough.typeOf }, (typeof ((_d = issuedThrough.serviceType) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
64
- ? { serviceType: issuedThrough.serviceType }
65
- : undefined), { serviceOutput: {
66
- typeOf: factory.reservationType.EventReservation,
67
- reservationFor: reservationFor4orderedItem
68
- } });
69
84
  }
70
85
  function createProductItems(params) {
71
86
  const acceptedOffers = [];
@@ -23,6 +23,8 @@ export declare type ISettings = factory.project.ISettings & {
23
23
  maxNumCreditCardPaymentMethod?: number;
24
24
  };
25
25
  export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
26
+ export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
27
+ export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
26
28
  /**
27
29
  * グローバル設定
28
30
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
3
+ exports.settings = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = void 0;
4
4
  const factory = require("./factory");
5
5
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
6
6
  ? process.env.INFORM_TRANSACTION_URL.split(',')
@@ -43,9 +43,14 @@ exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = 365;
43
43
  /**
44
44
  * 取引保管期間(Canceled)
45
45
  */
46
- exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = 7;
46
+ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS === 'string')
47
+ ? Number(process.env.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS)
48
+ // tslint:disable-next-line:no-magic-numbers
49
+ : 7;
47
50
  exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
48
51
  exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = String(process.env.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD);
52
+ exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
53
+ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
49
54
  /**
50
55
  * グローバル設定
51
56
  */
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.281.0-alpha.2",
13
- "@cinerino/sdk": "3.135.0-alpha.6",
12
+ "@chevre/factory": "4.282.0",
13
+ "@cinerino/sdk": "3.135.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.2"
123
+ "version": "20.2.0-alpha.21"
124
124
  }
@@ -1,32 +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
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
-
12
- // const now = new Date();
13
- await chevre.service.aggregation.project.aggregate({
14
- project: { id: project.id },
15
- reservationFor: {
16
- startFrom: moment('2022-01-01T00:00:00+09:00')
17
- .toDate(),
18
- startThrough: moment('2022-01-31T23:59:59+09:00')
19
- .toDate(),
20
- }
21
- })({
22
- project: new chevre.repository.Project(mongoose.connection),
23
- reservation: new chevre.repository.Reservation(mongoose.connection),
24
- task: new chevre.repository.Task(mongoose.connection)
25
- });
26
- }
27
-
28
- main()
29
- .then(() => {
30
- console.log('success!');
31
- })
32
- .catch(console.error);
@@ -1,57 +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
- // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
22
- startDate: {
23
- $gte: moment()
24
- .add(-1, 'month')
25
- .toDate()
26
- }
27
- // _id: { $eq: 'al6aff83w' }
28
- },
29
- {
30
- // _id: 1,
31
- }
32
- );
33
- console.log('events found');
34
-
35
- let i = 0;
36
- let updateCount = 0;
37
- await cursor.eachAsync(async (doc) => {
38
- i += 1;
39
- const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
40
-
41
- const locationProjectId = (<any>event.location).project?.id;
42
- if (typeof locationProjectId !== 'string') {
43
- console.log('already deleted', event.id, event.startDate, event.project.id, i);
44
- } else {
45
- updateCount += 1;
46
- console.log('deleting project...', event.id, event.startDate, event.project.id, i);
47
- await eventRepo.deleteUnnecessaryProjectAttributesById({ id: event.id });
48
- console.log('project deleted', event.id, event.startDate, event.project.id, i);
49
- }
50
- });
51
- console.log(i, 'events checked');
52
- console.log(updateCount, 'events updated');
53
- }
54
-
55
- main()
56
- .then()
57
- .catch(console.error);
@@ -1,162 +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, { autoIndex: false });
13
-
14
- const placeRepo = new chevre.repository.Place(mongoose.connection);
15
-
16
- const cursor = placeRepo.getCursor(
17
- {
18
- // 'project.id': { $eq: project.id },
19
- 'project.id': { $ne: EXCLUDED_PROJECT_ID }
20
- // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
21
- // starDate: { $gte: new Date() }
22
- // _id: { $eq: 'al6aff83w' }
23
- },
24
- {
25
- // _id: 1,
26
- }
27
- );
28
- console.log('creativeWorks found');
29
-
30
- const additionalPropertyNames: string[] = [];
31
- const additionalPropertyNamesOnSections: string[] = [];
32
- const additionalPropertyNamesOnSeats: string[] = [];
33
- const projectIds: string[] = [];
34
- const unexpextedprojectIds: string[] = [];
35
- const projectIdsOnSections: string[] = [];
36
- const unexpextedprojectIdsOnSections: string[] = [];
37
- const projectIdsOnSeats: string[] = [];
38
- const unexpextedprojectIdsOnSeats: string[] = [];
39
-
40
- let i = 0;
41
- let updateCount = 0;
42
- // tslint:disable-next-line:max-func-body-length
43
- await cursor.eachAsync(async (doc) => {
44
- i += 1;
45
- const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
46
-
47
- if (Array.isArray(movieTheater.containsPlace)) {
48
- movieTheater.containsPlace.forEach((screeningRoom) => {
49
- const additionalPropertyNamesOnResource = screeningRoom.additionalProperty?.map((p) => p.name);
50
- console.log(
51
- (Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
52
- 'additionalPropertyNamesOnResource found',
53
- movieTheater.project.id,
54
- movieTheater.id
55
- );
56
- if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
57
- console.log(
58
- additionalPropertyNamesOnResource.length,
59
- 'additionalPropertyNamesOnResource found',
60
- movieTheater.project.id,
61
- movieTheater.id
62
- );
63
- additionalPropertyNames.push(...additionalPropertyNamesOnResource);
64
- projectIds.push(movieTheater.project.id);
65
- additionalPropertyNamesOnResource.forEach((name) => {
66
- if (!name.match(/^[a-zA-Z]*$/)) {
67
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
68
- unexpextedprojectIds.push(movieTheater.project.id);
69
- }
70
- // tslint:disable-next-line:no-magic-numbers
71
- if (name.length < 5) {
72
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
73
- unexpextedprojectIds.push(movieTheater.project.id);
74
- }
75
- });
76
- }
77
-
78
- if (Array.isArray(screeningRoom.containsPlace)) {
79
- screeningRoom.containsPlace.forEach((section) => {
80
- const additionalPropertyNamesOnSection = section.additionalProperty?.map((p) => p.name);
81
- console.log(
82
- (Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
83
- 'additionalPropertyNamesOnSection found',
84
- movieTheater.project.id,
85
- movieTheater.id
86
- );
87
- if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
88
- console.log(
89
- additionalPropertyNamesOnSection.length,
90
- 'additionalPropertyNamesOnSection found',
91
- movieTheater.project.id,
92
- movieTheater.id
93
- );
94
- additionalPropertyNamesOnSections.push(...additionalPropertyNamesOnSection);
95
- projectIdsOnSections.push(movieTheater.project.id);
96
- additionalPropertyNamesOnSection.forEach((name) => {
97
- if (!name.match(/^[a-zA-Z]*$/)) {
98
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
99
- unexpextedprojectIdsOnSections.push(movieTheater.project.id);
100
- }
101
- // tslint:disable-next-line:no-magic-numbers
102
- if (name.length < 5) {
103
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
104
- unexpextedprojectIdsOnSections.push(movieTheater.project.id);
105
- }
106
- });
107
- }
108
-
109
- if (Array.isArray(section.containsPlace)) {
110
- section.containsPlace.forEach((seat) => {
111
- const additionalPropertyNamesOnSeat = seat.additionalProperty?.map((p) => p.name);
112
- console.log(
113
- (Array.isArray(additionalPropertyNamesOnSeat)) ? additionalPropertyNamesOnSeat.length : 0,
114
- 'additionalPropertyNamesOnSeat found',
115
- movieTheater.project.id,
116
- movieTheater.id
117
- );
118
- if (Array.isArray(additionalPropertyNamesOnSeat) && additionalPropertyNamesOnSeat.length > 0) {
119
- console.log(
120
- additionalPropertyNamesOnSeat.length,
121
- 'additionalPropertyNamesOnSeat found',
122
- movieTheater.project.id,
123
- movieTheater.id
124
- );
125
- additionalPropertyNamesOnSeats.push(...additionalPropertyNamesOnSeat);
126
- projectIdsOnSeats.push(movieTheater.project.id);
127
- additionalPropertyNamesOnSeat.forEach((name) => {
128
- if (!name.match(/^[a-zA-Z]*$/)) {
129
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
130
- unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
131
- }
132
- // tslint:disable-next-line:no-magic-numbers
133
- if (name.length < 5) {
134
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
135
- unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
136
- }
137
- });
138
- }
139
-
140
- });
141
- }
142
- });
143
- }
144
- });
145
- }
146
- });
147
- console.log(i, 'places checked');
148
- console.log(updateCount, 'places updated');
149
- console.log([...new Set(additionalPropertyNames)], 'screeningRooms');
150
- console.log([...new Set(projectIds)], 'screeningRooms');
151
- console.log([...new Set(unexpextedprojectIds)], 'screeningRooms');
152
- console.log([...new Set(additionalPropertyNamesOnSections)], 'sections');
153
- console.log([...new Set(projectIdsOnSections)], 'sections');
154
- console.log([...new Set(unexpextedprojectIdsOnSections)], 'sections');
155
- console.log([...new Set(additionalPropertyNamesOnSeats)], 'seats');
156
- console.log([...new Set(projectIdsOnSeats)], 'seats');
157
- console.log([...new Set(unexpextedprojectIdsOnSeats)], 'seats');
158
- }
159
-
160
- main()
161
- .then()
162
- .catch(console.error);