@chevre/domain 20.3.0-alpha.4 → 20.3.0

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,98 @@
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 additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
15
+ const offerRepo = new chevre.repository.Offer(mongoose.connection);
16
+
17
+ const cursor = offerRepo.getCursor(
18
+ {
19
+ // 'project.id': { $eq: project.id },
20
+ 'project.id': { $ne: EXCLUDED_PROJECT_ID }
21
+ },
22
+ {
23
+ // _id: 1,
24
+ }
25
+ );
26
+ console.log('events found');
27
+
28
+ const additionalPropertyNames: string[] = [];
29
+ const projectIds: string[] = [];
30
+ const unexpextedprojectIds: string[] = [];
31
+
32
+ let i = 0;
33
+ let updateCount = 0;
34
+ await cursor.eachAsync(async (doc) => {
35
+ i += 1;
36
+ const unitPriceOffer: chevre.factory.unitPriceOffer.IUnitPriceOffer = doc.toObject();
37
+
38
+ const additionalPropertyNamesOnEvent = unitPriceOffer.additionalProperty?.map((p) => p.name);
39
+ if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
40
+ console.log(
41
+ additionalPropertyNamesOnEvent.length,
42
+ 'additionalPropertyNamesOnEvent found',
43
+ unitPriceOffer.project.id,
44
+ unitPriceOffer.id
45
+ );
46
+ additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
47
+ projectIds.push(unitPriceOffer.project.id);
48
+ additionalPropertyNamesOnEvent.forEach((name) => {
49
+ if (!name.match(/^[a-zA-Z]*$/)) {
50
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
51
+ unexpextedprojectIds.push(unitPriceOffer.project.id);
52
+ }
53
+ // tslint:disable-next-line:no-magic-numbers
54
+ if (name.length < 5) {
55
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
56
+ unexpextedprojectIds.push(unitPriceOffer.project.id);
57
+ }
58
+ });
59
+
60
+ for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
61
+ const existings = await additionalPropertyRepo.search({
62
+ project: { id: { $eq: unitPriceOffer.project.id } },
63
+ limit: 1,
64
+ page: 1,
65
+ name: { $regex: `^${additionalPropertyNameOnEvent}$` }
66
+ });
67
+ if (existings.length > 0) {
68
+ console.log('already existed', additionalPropertyNameOnEvent, unitPriceOffer.id, unitPriceOffer.project.id);
69
+ } else {
70
+ updateCount += 1;
71
+ const newAdditionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
72
+ project: unitPriceOffer.project,
73
+ typeOf: 'CategoryCode',
74
+ codeValue: additionalPropertyNameOnEvent,
75
+ inCodeSet: {
76
+ typeOf: 'CategoryCodeSet',
77
+ identifier: <any>unitPriceOffer.typeOf
78
+ },
79
+ name: { ja: additionalPropertyNameOnEvent }
80
+ };
81
+ await additionalPropertyRepo.save({
82
+ attributes: newAdditionalProperty
83
+ });
84
+ console.log('created', additionalPropertyNameOnEvent, unitPriceOffer.id, unitPriceOffer.project.id);
85
+ }
86
+ }
87
+ }
88
+ });
89
+ console.log(i, 'events checked');
90
+ console.log(updateCount, 'properties updated');
91
+ console.log([...new Set(additionalPropertyNames)]);
92
+ console.log([...new Set(projectIds)]);
93
+ console.log([...new Set(unexpextedprojectIds)]);
94
+ }
95
+
96
+ main()
97
+ .then()
98
+ .catch(console.error);
@@ -186,7 +186,9 @@ function purchaseNumberAuthResult2movieTickets(params) {
186
186
  purchaseNumberAuthResult.knyknrNoInfoOut.forEach((knyknrNoInfoOut) => {
187
187
  const knyknrNoInfo = knyknrNoInfoIn.find((info) => info.knyknrNo === knyknrNoInfoOut.knyknrNo);
188
188
  if (knyknrNoInfo !== undefined) {
189
- const movieTicketCategoryCode = knyknrNoInfoOut.znkkkytsknGkjknTyp;
189
+ const movieTicketCategoryCode = (typeof knyknrNoInfoOut.znkkkytsknGkjknTyp === 'string')
190
+ ? knyknrNoInfoOut.znkkkytsknGkjknTyp
191
+ : '';
190
192
  if (Array.isArray(knyknrNoInfoOut.ykknInfo)) {
191
193
  knyknrNoInfoOut.ykknInfo.forEach((ykknInfo) => {
192
194
  // tslint:disable-next-line:prefer-array-literal
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.288.0-alpha.1",
13
- "@cinerino/sdk": "3.138.1",
12
+ "@chevre/factory": "4.288.0",
13
+ "@cinerino/sdk": "3.139.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.3.0-alpha.4"
123
+ "version": "20.3.0"
124
124
  }
@@ -1,116 +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 customerRepo = new chevre.repository.Customer(mongoose.connection);
15
- // const sellerRepo = new chevre.repository.Seller(mongoose.connection);
16
- // const eventRepo = new chevre.repository.Event(mongoose.connection);
17
- // const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
18
- // const placeRepo = new chevre.repository.Place(mongoose.connection);
19
- // const offerRepo = new chevre.repository.Offer(mongoose.connection);
20
- // const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
21
- // const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
22
- // const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
23
- const merchantReturnPolicyRepo = new chevre.repository.MerchantReturnPolicy(mongoose.connection);
24
-
25
- // const cursor = customerRepo.getCursor(
26
- // const cursor = sellerRepo.getCursor(
27
- // const cursor = eventRepo.getCursor(
28
- // const cursor = categoryCodeRepo.getCursor(
29
- // const cursor = offerRepo.getCursor(
30
- // const cursor = creativeWorkRepo.getCursor(
31
- // const cursor = placeRepo.getCursor(
32
- // const cursor = offerCatalogRepo.getCursor(
33
- const cursor = merchantReturnPolicyRepo.getCursor(
34
- {
35
- // 'project.id': { $eq: project.id },
36
- 'project.id': { $ne: EXCLUDED_PROJECT_ID },
37
- // typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
38
- // starDate: { $gte: new Date() }
39
- // _id: { $eq: 'al6aff83w' }
40
- },
41
- {
42
- // _id: 1,
43
- }
44
- );
45
- console.log('creativeWorks found');
46
-
47
- const additionalPropertyNames: string[] = [];
48
- const projectIds: string[] = [];
49
- const unexpextedprojectIds: string[] = [];
50
-
51
- let i = 0;
52
- let updateCount = 0;
53
- await cursor.eachAsync(async (doc) => {
54
- i += 1;
55
- const creativeWork: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
56
-
57
- const additionalPropertyNamesOnEvent = creativeWork.additionalProperty?.map((p) => p.name);
58
- if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
59
- console.log(
60
- additionalPropertyNamesOnEvent.length,
61
- 'additionalPropertyNamesOnEvent found',
62
- creativeWork.project.id,
63
- creativeWork.id
64
- );
65
- additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
66
- projectIds.push(creativeWork.project.id);
67
- additionalPropertyNamesOnEvent.forEach((name) => {
68
- if (!name.match(/^[a-zA-Z]*$/)) {
69
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
70
- unexpextedprojectIds.push(creativeWork.project.id);
71
- }
72
- // tslint:disable-next-line:no-magic-numbers
73
- if (name.length < 5) {
74
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
75
- unexpextedprojectIds.push(creativeWork.project.id);
76
- }
77
- });
78
-
79
- // for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
80
- // const existings = await additionalPropertyRepo.search({
81
- // project: { id: { $eq: event.project.id } },
82
- // limit: 1,
83
- // page: 1,
84
- // name: { $regex: `^${additionalPropertyNameOnEvent}$` }
85
- // });
86
- // if (existings.length > 0) {
87
- // console.log('already existed', additionalPropertyNameOnEvent, event.id, event.project.id);
88
- // } else {
89
- // updateCount += 1;
90
- // await additionalPropertyRepo.save({
91
- // attributes: {
92
- // project: event.project,
93
- // typeOf: 'CategoryCode',
94
- // codeValue: additionalPropertyNameOnEvent,
95
- // inCodeSet: {
96
- // typeOf: 'CategoryCodeSet',
97
- // identifier: <any>event.typeOf
98
- // },
99
- // name: { ja: additionalPropertyNameOnEvent }
100
- // }
101
- // });
102
- // console.log('created', additionalPropertyNameOnEvent, event.id, event.project.id);
103
- // }
104
- // }
105
- }
106
- });
107
- console.log(i, 'events checked');
108
- console.log(updateCount, 'events updated');
109
- console.log([...new Set(additionalPropertyNames)]);
110
- console.log([...new Set(projectIds)]);
111
- console.log([...new Set(unexpextedprojectIds)]);
112
- }
113
-
114
- main()
115
- .then()
116
- .catch(console.error);