@chevre/domain 20.1.0-alpha.25 → 20.1.0-alpha.27
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.
- package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +24 -7
- package/example/src/chevre/{migrateSellerMakesOfferTransactionDuration.ts → migrateSSKTSEventCOAEndpoint.ts} +0 -0
- package/lib/chevre/repo/customer.d.ts +1 -0
- package/lib/chevre/repo/customer.js +5 -0
- package/lib/chevre/repository.d.ts +0 -3
- package/lib/chevre/repository.js +3 -5
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +0 -1
- package/package.json +1 -1
- package/example/src/chevre/migrateSection.ts +0 -105
|
@@ -11,19 +11,27 @@ const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
13
|
|
|
14
|
-
// const
|
|
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);
|
|
15
18
|
// const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
19
|
// const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
17
|
-
const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
20
|
+
// const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
18
21
|
// const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
|
|
19
22
|
|
|
20
|
-
const cursor =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
// const cursor = customerRepo.getCursor(
|
|
24
|
+
// const cursor = sellerRepo.getCursor(
|
|
25
|
+
// const cursor = eventRepo.getCursor(
|
|
26
|
+
// const cursor = categoryCodeRepo.getCursor(
|
|
27
|
+
// const cursor = offerRepo.getCursor(
|
|
28
|
+
const cursor = creativeWorkRepo.getCursor(
|
|
23
29
|
// const cursor = placeRepo.getCursor(
|
|
24
30
|
{
|
|
25
31
|
// 'project.id': { $eq: project.id },
|
|
26
|
-
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
32
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
33
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
34
|
+
// starDate: { $gte: new Date() }
|
|
27
35
|
// _id: { $eq: 'al6aff83w' }
|
|
28
36
|
},
|
|
29
37
|
{
|
|
@@ -34,6 +42,7 @@ async function main() {
|
|
|
34
42
|
|
|
35
43
|
const additionalPropertyNames: string[] = [];
|
|
36
44
|
const projectIds: string[] = [];
|
|
45
|
+
const unexpextedprojectIds: string[] = [];
|
|
37
46
|
|
|
38
47
|
let i = 0;
|
|
39
48
|
let updateCount = 0;
|
|
@@ -43,16 +52,23 @@ async function main() {
|
|
|
43
52
|
|
|
44
53
|
const additionalPropertyNamesOnEvent = creativeWork.additionalProperty?.map((p) => p.name);
|
|
45
54
|
if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
|
|
46
|
-
console.log(
|
|
55
|
+
console.log(
|
|
56
|
+
additionalPropertyNamesOnEvent.length,
|
|
57
|
+
'additionalPropertyNamesOnEvent found',
|
|
58
|
+
creativeWork.project.id,
|
|
59
|
+
creativeWork.id
|
|
60
|
+
);
|
|
47
61
|
additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
|
|
48
62
|
projectIds.push(creativeWork.project.id);
|
|
49
63
|
additionalPropertyNamesOnEvent.forEach((name) => {
|
|
50
64
|
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
51
65
|
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
52
67
|
}
|
|
53
68
|
// tslint:disable-next-line:no-magic-numbers
|
|
54
69
|
if (name.length < 5) {
|
|
55
70
|
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
56
72
|
}
|
|
57
73
|
});
|
|
58
74
|
|
|
@@ -88,6 +104,7 @@ async function main() {
|
|
|
88
104
|
console.log(updateCount, 'events updated');
|
|
89
105
|
console.log([...new Set(additionalPropertyNames)]);
|
|
90
106
|
console.log([...new Set(projectIds)]);
|
|
107
|
+
console.log([...new Set(unexpextedprojectIds)]);
|
|
91
108
|
}
|
|
92
109
|
|
|
93
110
|
main()
|
|
File without changes
|
|
@@ -130,5 +130,10 @@ class MongoRepository {
|
|
|
130
130
|
.exec();
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
+
getCursor(conditions, projection) {
|
|
134
|
+
return this.customerModel.find(conditions, projection)
|
|
135
|
+
.sort({ branchCode: factory.sortType.Ascending })
|
|
136
|
+
.cursor();
|
|
137
|
+
}
|
|
133
138
|
}
|
|
134
139
|
exports.MongoRepository = MongoRepository;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* リポジトリ
|
|
3
3
|
*/
|
|
4
4
|
import { MongoRepository as AccountRepo } from './repo/account';
|
|
5
|
-
import { MongoRepository as AccountActionRepo } from './repo/accountAction';
|
|
6
5
|
import { MongoRepository as AccountingReportRepo } from './repo/accountingReport';
|
|
7
6
|
import { MongoRepository as AccountTitleRepo } from './repo/accountTitle';
|
|
8
7
|
import { MongoRepository as AccountTransactionRepo } from './repo/accountTransaction';
|
|
@@ -50,8 +49,6 @@ export declare class Account extends AccountRepo {
|
|
|
50
49
|
/**
|
|
51
50
|
* 口座アクションリポジトリ
|
|
52
51
|
*/
|
|
53
|
-
export declare class AccountAction extends AccountActionRepo {
|
|
54
|
-
}
|
|
55
52
|
/**
|
|
56
53
|
* 経理レポートリポジトリ
|
|
57
54
|
*/
|
package/lib/chevre/repository.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rateLimit = exports.itemAvailability = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.
|
|
3
|
+
exports.rateLimit = exports.itemAvailability = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.OfferCatalog = exports.Offer = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
|
|
4
4
|
// tslint:disable:max-classes-per-file completed-docs
|
|
5
5
|
/**
|
|
6
6
|
* リポジトリ
|
|
7
7
|
*/
|
|
8
8
|
const account_1 = require("./repo/account");
|
|
9
|
-
|
|
9
|
+
// import { MongoRepository as AccountActionRepo } from './repo/accountAction';
|
|
10
10
|
const accountingReport_1 = require("./repo/accountingReport");
|
|
11
11
|
const accountTitle_1 = require("./repo/accountTitle");
|
|
12
12
|
const accountTransaction_1 = require("./repo/accountTransaction");
|
|
@@ -55,9 +55,7 @@ exports.Account = Account;
|
|
|
55
55
|
/**
|
|
56
56
|
* 口座アクションリポジトリ
|
|
57
57
|
*/
|
|
58
|
-
class AccountAction extends
|
|
59
|
-
}
|
|
60
|
-
exports.AccountAction = AccountAction;
|
|
58
|
+
// export class AccountAction extends AccountActionRepo { }
|
|
61
59
|
/**
|
|
62
60
|
* 経理レポートリポジトリ
|
|
63
61
|
*/
|
|
@@ -475,7 +475,7 @@ function createScreeningEventAdditionalPropertyFromCOA(params) {
|
|
|
475
475
|
return {
|
|
476
476
|
coaInfo,
|
|
477
477
|
additionalProperty: [
|
|
478
|
-
{ name: 'COA_ENDPOINT', value:
|
|
478
|
+
// { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
|
|
479
479
|
{ name: 'coaInfo', value: JSON.stringify(coaInfo) }
|
|
480
480
|
]
|
|
481
481
|
};
|
|
@@ -579,7 +579,7 @@ function createScreeningEventSeriesAdditionalPropertyFromCOA(params) {
|
|
|
579
579
|
return {
|
|
580
580
|
coaInfo,
|
|
581
581
|
additionalProperty: [
|
|
582
|
-
{ name: 'COA_ENDPOINT', value:
|
|
582
|
+
// { name: 'COA_ENDPOINT', value: credentials.coa.endpoint },
|
|
583
583
|
{ name: 'coaInfo', value: JSON.stringify(coaInfo) }
|
|
584
584
|
]
|
|
585
585
|
};
|
|
@@ -82,7 +82,6 @@ function responseBody2acceptedOffers4result(params) {
|
|
|
82
82
|
coaInfo = event.coaInfo;
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
// const coaEndpointProperty = event.additionalProperty.find((p) => p.name === 'COA_ENDPOINT');
|
|
86
85
|
const coaInfoProperty = (_a = event.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((p) => p.name === 'coaInfo');
|
|
87
86
|
coaInfo = (coaInfoProperty !== undefined) ? JSON.parse(coaInfoProperty.value) : undefined;
|
|
88
87
|
}
|
package/package.json
CHANGED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console no-magic-numbers
|
|
2
|
-
// import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
import * as redis from 'redis';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../lib/index';
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
|
-
|
|
11
|
-
const client = redis.createClient({
|
|
12
|
-
host: <string>process.env.REDIS_HOST,
|
|
13
|
-
port: Number(process.env.REDIS_PORT),
|
|
14
|
-
password: <string>process.env.REDIS_KEY
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
18
|
-
|
|
19
|
-
const events = await eventRepo.search({
|
|
20
|
-
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
21
|
-
project: { id: { $eq: '' } },
|
|
22
|
-
startFrom: new Date()
|
|
23
|
-
// startThrough: moment().add(4, 'day').toDate()
|
|
24
|
-
});
|
|
25
|
-
console.log(events.length, 'events found');
|
|
26
|
-
|
|
27
|
-
const sectionCode = 'Default';
|
|
28
|
-
await Promise.all(events.map(async (event) => {
|
|
29
|
-
await new Promise<void>((resolve) => {
|
|
30
|
-
const key = `chevre:itemAvailability:screeningEvent:${event.id}`;
|
|
31
|
-
client.hgetall(key, async (__, reply) => {
|
|
32
|
-
if (reply !== null && Object.keys(reply).length > 0) {
|
|
33
|
-
|
|
34
|
-
const fieldAndValues = reply;
|
|
35
|
-
for (const field of Object.keys(fieldAndValues)) {
|
|
36
|
-
// セクションがなければキーを更新
|
|
37
|
-
if (field.slice(0, 7) !== sectionCode) {
|
|
38
|
-
console.log(event.id, field);
|
|
39
|
-
const newField = `${sectionCode}${field}`;
|
|
40
|
-
const newValue = fieldAndValues[field];
|
|
41
|
-
console.log('saving...', newField, newValue);
|
|
42
|
-
|
|
43
|
-
await new Promise<void>((resolveSet) => {
|
|
44
|
-
client.hsetnx(key, newField, newValue, (___, setReply) => {
|
|
45
|
-
console.log('set', setReply, newField, newValue);
|
|
46
|
-
|
|
47
|
-
resolveSet();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// 元のフィールドを削除
|
|
52
|
-
await new Promise<void>((resolveSet) => {
|
|
53
|
-
client.hdel(key, field, (___, setReply) => {
|
|
54
|
-
console.log('deleted', setReply, field);
|
|
55
|
-
|
|
56
|
-
resolveSet();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
resolve();
|
|
64
|
-
// if (err !== null) {
|
|
65
|
-
// reject(err);
|
|
66
|
-
// } else {
|
|
67
|
-
// if (reply !== null) {
|
|
68
|
-
// client.ttl(targetKey, (ttlErr, ttl) => {
|
|
69
|
-
// console.log('ttl:', ttl);
|
|
70
|
-
// const args = Object.keys(reply)
|
|
71
|
-
// .reduce(
|
|
72
|
-
// (a, b) => {
|
|
73
|
-
// return [...a, b, reply[b]];
|
|
74
|
-
// },
|
|
75
|
-
// []
|
|
76
|
-
// );
|
|
77
|
-
// console.log(args.length, 'args ready');
|
|
78
|
-
|
|
79
|
-
// newClient.multi()
|
|
80
|
-
// .hmset(newKey, ...args)
|
|
81
|
-
// .expire(newKey, ttl)
|
|
82
|
-
// .exec((hmsetErr, reply) => {
|
|
83
|
-
// console.log('hmset result:', hmsetErr, reply);
|
|
84
|
-
// resolve();
|
|
85
|
-
// });
|
|
86
|
-
// });
|
|
87
|
-
// } else {
|
|
88
|
-
// console.error('targetKey not found');
|
|
89
|
-
// }
|
|
90
|
-
// }
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
// client.keys('chevre:itemAvailability:screeningEvent:*', async (err, reply) => {
|
|
96
|
-
// console.log(err, reply.length, 'keys found');
|
|
97
|
-
// const targetKeys = reply;
|
|
98
|
-
|
|
99
|
-
// });
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
main()
|
|
104
|
-
.then(console.log)
|
|
105
|
-
.catch(console.error);
|