@chevre/domain 21.4.0-alpha.0 → 21.4.0-alpha.10

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 (37) hide show
  1. package/example/src/chevre/cleanActions.ts +23 -0
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +6 -0
  3. package/example/src/chevre/migrateEventOrganizer.ts +112 -0
  4. package/example/src/chevre/searchEvents.ts +1 -9
  5. package/example/src/chevre/searchProductOffers.ts +12 -21
  6. package/lib/chevre/repo/action.d.ts +6 -0
  7. package/lib/chevre/repo/action.js +13 -0
  8. package/lib/chevre/repo/event.d.ts +9 -4
  9. package/lib/chevre/repo/event.js +101 -60
  10. package/lib/chevre/repo/mongoose/schemas/event.d.ts +7 -4
  11. package/lib/chevre/repo/mongoose/schemas/event.js +15 -2
  12. package/lib/chevre/repo/productOffer.d.ts +72 -0
  13. package/lib/chevre/repo/productOffer.js +185 -0
  14. package/lib/chevre/repo/seller.d.ts +4 -3
  15. package/lib/chevre/repo/seller.js +40 -38
  16. package/lib/chevre/repository.d.ts +3 -0
  17. package/lib/chevre/repository.js +5 -1
  18. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  19. package/lib/chevre/service/assetTransaction/pay/account/validation.js +9 -1
  20. package/lib/chevre/service/assetTransaction/pay.js +9 -1
  21. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +4 -3
  22. package/lib/chevre/service/assetTransaction/reserve/factory.js +6 -2
  23. package/lib/chevre/service/event.js +18 -22
  24. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +15 -1
  25. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
  26. package/lib/chevre/service/payment/creditCard.js +9 -1
  27. package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -1
  28. package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
  29. package/lib/chevre/service/payment/movieTicket.js +19 -2
  30. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  31. package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
  32. package/lib/chevre/service/transaction/returnOrder.js +9 -3
  33. package/package.json +3 -3
  34. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +0 -90
  35. package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -75
  36. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +0 -64
  37. package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +0 -79
@@ -27,6 +27,7 @@ const onRefund_1 = require("./any/onRefund");
27
27
  /**
28
28
  * MovieTicket認証
29
29
  */
30
+ // tslint:disable-next-line:max-func-body-length
30
31
  function checkMovieTicket(params) {
31
32
  return (repos) => __awaiter(this, void 0, void 0, function* () {
32
33
  var _a, _b, _c, _d, _e, _f;
@@ -58,7 +59,15 @@ function checkMovieTicket(params) {
58
59
  id: eventIds[0]
59
60
  });
60
61
  // ショップ情報取得
61
- const seller = yield repos.seller.findById({ id: (_e = params.object[0]) === null || _e === void 0 ? void 0 : _e.seller.id }, ['paymentAccepted', 'project'], []);
62
+ const sellers = yield repos.seller.search({
63
+ limit: 1,
64
+ page: 1,
65
+ id: { $eq: (_e = params.object[0]) === null || _e === void 0 ? void 0 : _e.seller.id }
66
+ }, ['paymentAccepted', 'project'], []);
67
+ const seller = sellers.shift();
68
+ if (seller === undefined) {
69
+ throw new factory.errors.NotFound(factory.organizationType.Corporation);
70
+ }
62
71
  const paymentAccepted = (_f = seller.paymentAccepted) === null || _f === void 0 ? void 0 : _f.some((a) => a.paymentMethodType === paymentMethodType);
63
72
  if (paymentAccepted !== true) {
64
73
  throw new factory.errors.Argument('transactionId', 'payment not accepted');
@@ -302,7 +311,15 @@ function payActionParams2seatInfoSyncIn(params) {
302
311
  // イベント取得属性最適化(2023-01-23~)
303
312
  // const event = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: eventIds[0] });
304
313
  const event = yield repos.event.findMinimizedIndividualEventById({ id: eventIds[0] });
305
- const seller = yield repos.seller.findById({ id: String((_d = params.recipient) === null || _d === void 0 ? void 0 : _d.id) }, ['paymentAccepted', 'project'], []);
314
+ const sellers = yield repos.seller.search({
315
+ limit: 1,
316
+ page: 1,
317
+ id: { $eq: String((_d = params.recipient) === null || _d === void 0 ? void 0 : _d.id) }
318
+ }, ['paymentAccepted', 'project'], []);
319
+ const seller = sellers.shift();
320
+ if (seller === undefined) {
321
+ throw new factory.errors.NotFound(factory.organizationType.Corporation);
322
+ }
306
323
  // 全購入管理番号のMovieTicketをマージ
307
324
  const movieTickets = params.object.reduce((a, b) => [...a, ...(Array.isArray(b.movieTickets)) ? b.movieTickets : []], []);
308
325
  const sellerCredentials = yield (0, getCredentials_1.getCredentials)({ paymentMethodType, seller, paymentServiceId })(repos);
@@ -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;
@@ -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.315.0-alpha.2",
13
+ "@cinerino/sdk": "3.160.0-alpha.3",
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.0"
120
+ "version": "21.4.0-alpha.10"
121
121
  }
@@ -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);
@@ -1,79 +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 = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
8
-
9
- const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
10
-
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const eventRepo = new chevre.repository.Event(mongoose.connection);
15
-
16
- const cursor = eventRepo.getCursor(
17
- {
18
- 'project.id': {
19
- // $eq: project.id,
20
- $ne: EXCLUDED_PROJECT_ID
21
- },
22
- typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
23
- 'workPerformed.version': { $exists: false }
24
- // _id: { $eq: 'bl7ed6sq9' }
25
- },
26
- {
27
- _id: 1,
28
- workPerformed: 1,
29
- project: 1,
30
- location: 1,
31
- startDate: 1,
32
- typeOf: 1
33
- }
34
- );
35
- console.log('events found');
36
-
37
- let i = 0;
38
- let updateCount = 0;
39
- await cursor.eachAsync(async (doc) => {
40
- i += 1;
41
- const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
42
- const version = event.workPerformed.version;
43
-
44
- const alreadyMigrated = typeof version === 'string' && version.length > 0;
45
-
46
- if (alreadyMigrated) {
47
- console.log('alreadyMigrated.', event.project.id, event.id, event.startDate, version, i);
48
- } else {
49
- // 既存施設コンテンツバージョンを検索
50
- const { maxVersion } = await eventRepo.aggregateScreeningEventMaxVersion({
51
- project: { id: { $eq: event.project.id } },
52
- workPerformed: { identifier: { $eq: event.workPerformed.identifier } },
53
- location: { branchCode: { $in: [event.location.branchCode] } }
54
- });
55
- console.log('maxVersion:', maxVersion);
56
-
57
- const newVersion: string = `${Number(maxVersion) + 1}`;
58
- console.log('updating event...', event.project.id, event.id, event.startDate, newVersion, i);
59
- await eventRepo.updatePartiallyById({
60
- id: event.id,
61
- attributes: <any>{
62
- typeOf: event.typeOf,
63
- 'workPerformed.version': newVersion
64
- }
65
- });
66
- updateCount += 1;
67
- console.log('updated.', event.project.id, event.id, event.startDate, newVersion, i);
68
- }
69
- });
70
-
71
- console.log(i, 'events checked');
72
- console.log(updateCount, 'events updated');
73
- }
74
-
75
- main()
76
- .then(() => {
77
- console.log('success!');
78
- })
79
- .catch(console.error);