@chevre/domain 20.1.0-alpha.43 → 20.1.0-alpha.45

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.
@@ -0,0 +1,20 @@
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
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+
11
+ const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
12
+
13
+ const result = await reservationRepo.deleteReservedTicketUnderName();
14
+
15
+ console.log('deleted', result);
16
+ }
17
+
18
+ main()
19
+ .then()
20
+ .catch(console.error);
@@ -0,0 +1 @@
1
+ export declare const RESERVED_AGENT_IDENTIFIER_NAMES: string[];
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESERVED_AGENT_IDENTIFIER_NAMES = void 0;
4
+ exports.RESERVED_AGENT_IDENTIFIER_NAMES = [
5
+ 'orderNumber',
6
+ 'tokenIssuer',
7
+ 'iss',
8
+ 'clientId',
9
+ 'sub',
10
+ 'hostname',
11
+ 'username'
12
+ ];
@@ -115,4 +115,5 @@ export declare class MongoRepository {
115
115
  $in: string[];
116
116
  };
117
117
  }): Promise<string[]>;
118
+ deleteReservedTicketUnderName(): Promise<UpdateWriteOpResult>;
118
119
  }
@@ -1087,5 +1087,17 @@ class MongoRepository {
1087
1087
  .then((docs) => docs.map((doc) => doc._id.toString()));
1088
1088
  });
1089
1089
  }
1090
+ deleteReservedTicketUnderName() {
1091
+ return __awaiter(this, void 0, void 0, function* () {
1092
+ const conditions = {
1093
+ 'reservedTicket.underName': { $exists: true }
1094
+ };
1095
+ const update = {
1096
+ $unset: { 'reservedTicket.underName': 1 }
1097
+ };
1098
+ return this.reservationModel.updateMany(conditions, update)
1099
+ .exec();
1100
+ });
1101
+ }
1090
1102
  }
1091
1103
  exports.MongoRepository = MongoRepository;
@@ -21,6 +21,7 @@ const util_1 = require("util");
21
21
  const credentials_1 = require("../../../credentials");
22
22
  const factory = require("../../../factory");
23
23
  const order_1 = require("../../../factory/order");
24
+ const reservedAgentIdentifireNames_1 = require("../../../factory/reservedAgentIdentifireNames");
24
25
  const settings_1 = require("../../../settings");
25
26
  const informOrder = (_a = settings_1.settings.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder;
26
27
  function getOrderWithToken(params) {
@@ -132,7 +133,12 @@ function creteOrder4inform(order) {
132
133
  // mask
133
134
  customer: Object.assign(Object.assign({}, (0, order_1.createMaskedCustomer)(order)), { additionalProperty: (Array.isArray(order.customer.additionalProperty)) ? order.customer.additionalProperty : [],
134
135
  // identifierは必要
135
- identifier: (Array.isArray(order.customer.identifier)) ? order.customer.identifier : [] }),
136
+ // 予約後を隠蔽(2022-12-24~)
137
+ identifier: (Array.isArray(order.customer.identifier))
138
+ ? order.customer.identifier.filter((p) => {
139
+ return !reservedAgentIdentifireNames_1.RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
140
+ })
141
+ : [] }),
136
142
  // paymentMethodsに関してもmask(2022-05-30~)
137
143
  paymentMethods: order.paymentMethods.map((p) => {
138
144
  return Object.assign(Object.assign({}, p), (typeof p.accountId === 'string' && p.accountId.length > 0)
@@ -1,5 +1,4 @@
1
1
  import * as factory from '../../factory';
2
- export declare const RESERVED_AGENT_IDENTIFIER_NAMES: string[];
3
2
  declare type IEventReservation = factory.reservation.IReservation<factory.reservationType.EventReservation>;
4
3
  export declare function maskUnderName(reservation: IEventReservation): IEventReservation;
5
4
  export interface IProject {
@@ -1,27 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NUM_TRY_INFORM_RESERVATION = exports.maskUnderName = exports.RESERVED_AGENT_IDENTIFIER_NAMES = void 0;
4
- exports.RESERVED_AGENT_IDENTIFIER_NAMES = [
5
- 'orderNumber',
6
- 'tokenIssuer',
7
- 'iss',
8
- 'clientId',
9
- 'sub',
10
- 'hostname',
11
- 'username'
12
- ];
3
+ exports.NUM_TRY_INFORM_RESERVATION = exports.maskUnderName = void 0;
4
+ const reservedAgentIdentifireNames_1 = require("../../factory/reservedAgentIdentifireNames");
13
5
  const MASKED_PROFILE = '****';
14
6
  function maskUnderName(reservation) {
15
- var _a;
16
- const underName = (typeof ((_a = reservation.underName) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
17
- ? Object.assign(Object.assign({}, reservation.underName), { email: MASKED_PROFILE, telephone: MASKED_PROFILE, name: MASKED_PROFILE, familyName: MASKED_PROFILE, givenName: MASKED_PROFILE }) : undefined;
18
- // 不要なidentifierをmask(2022-12-24~)
19
- const identifiers = (Array.isArray(reservation.identifier))
20
- ? reservation.identifier.filter((p) => {
21
- return !exports.RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
7
+ var _a, _b, _c;
8
+ // 予約後を隠蔽(2022-12-24~)
9
+ const underNameIdentifiers = (Array.isArray((_a = reservation.underName) === null || _a === void 0 ? void 0 : _a.identifier))
10
+ ? (_b = reservation.underName) === null || _b === void 0 ? void 0 : _b.identifier.filter((p) => {
11
+ return !reservedAgentIdentifireNames_1.RESERVED_AGENT_IDENTIFIER_NAMES.includes(p.name);
22
12
  })
23
13
  : undefined;
24
- return Object.assign(Object.assign(Object.assign({}, reservation), (Array.isArray(identifiers)) ? { identifier: identifiers } : undefined), (underName !== undefined) ? { underName } : undefined);
14
+ const underName = (typeof ((_c = reservation.underName) === null || _c === void 0 ? void 0 : _c.typeOf) === 'string')
15
+ ? Object.assign(Object.assign(Object.assign({}, reservation.underName), { email: MASKED_PROFILE, telephone: MASKED_PROFILE, name: MASKED_PROFILE, familyName: MASKED_PROFILE, givenName: MASKED_PROFILE }), (Array.isArray(underNameIdentifiers)) ? { identifier: underNameIdentifiers } : undefined) : undefined;
16
+ return Object.assign(Object.assign({}, reservation), (underName !== undefined) ? { underName } : undefined);
25
17
  }
26
18
  exports.maskUnderName = maskUnderName;
27
19
  exports.NUM_TRY_INFORM_RESERVATION = 10;
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as AccountTransactionIdentifierFactory from './factory/accountTransactionIdentifier';
5
5
  import * as OrderFactory from './factory/order';
6
+ import * as ReservedAgentIdentifireNamesFactory from './factory/reservedAgentIdentifireNames';
6
7
  import * as AccountService from './service/account';
7
8
  import * as AccountTransactionService from './service/accountTransaction';
8
9
  import * as AggregationService from './service/aggregation';
@@ -46,4 +47,5 @@ export import util = UtilService;
46
47
  export declare namespace factory {
47
48
  export import accountTransactionIdentifier = AccountTransactionIdentifierFactory;
48
49
  export import order = OrderFactory;
50
+ export import reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
49
51
  }
@@ -6,6 +6,7 @@ exports.factory = exports.util = exports.transaction = exports.task = exports.re
6
6
  */
7
7
  const AccountTransactionIdentifierFactory = require("./factory/accountTransactionIdentifier");
8
8
  const OrderFactory = require("./factory/order");
9
+ const ReservedAgentIdentifireNamesFactory = require("./factory/reservedAgentIdentifireNames");
9
10
  const AccountService = require("./service/account");
10
11
  const AccountTransactionService = require("./service/accountTransaction");
11
12
  const AggregationService = require("./service/aggregation");
@@ -52,4 +53,5 @@ var factory;
52
53
  factory.accountTransactionIdentifier = AccountTransactionIdentifierFactory;
53
54
  // tslint:disable-next-line:no-shadowed-variable
54
55
  factory.order = OrderFactory;
56
+ factory.reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
55
57
  })(factory = exports.factory || (exports.factory = {}));
package/package.json CHANGED
@@ -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.1.0-alpha.43"
123
+ "version": "20.1.0-alpha.45"
124
124
  }
@@ -1,50 +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 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.ScreeningEvent },
18
- // 'superEvent.location.branchCode': { $eq: '118', $exists: true },
19
- endDate: {
20
- $exists: true,
21
- $lt: moment()
22
- .add(-1, 'month')
23
- .toDate()
24
- }
25
- },
26
- {
27
- // _id: 1,
28
- }
29
- );
30
- console.log('events found');
31
-
32
- let i = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
37
-
38
- console.log('deleting event...', event.project.id, event.id, event.startDate, i);
39
- await eventRepo.deleteById({ id: event.id });
40
- updateCount += 1;
41
- console.log('deleted', event.project.id, event.id, event.startDate, i);
42
- });
43
-
44
- console.log(i, 'events checked');
45
- console.log(updateCount, 'events updated');
46
- }
47
-
48
- main()
49
- .then()
50
- .catch(console.error);