@chevre/domain 20.4.0-alpha.0 → 20.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.
- package/example/src/chevre/createManyEventsIfNotExist.ts +10 -10
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +26 -0
- package/lib/chevre/repo/account.d.ts +4 -10
- package/lib/chevre/repo/account.js +72 -60
- package/lib/chevre/repo/accountTransaction.d.ts +0 -1
- package/lib/chevre/repo/accountTransaction.js +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +1 -0
- package/lib/chevre/repo/assetTransaction.js +5 -0
- package/lib/chevre/repo/comment.d.ts +31 -0
- package/lib/chevre/repo/comment.js +113 -0
- package/lib/chevre/repo/event.js +7 -1
- package/lib/chevre/repo/mongoose/model/{accountAction.d.ts → comments.d.ts} +2 -2
- package/lib/chevre/repo/mongoose/model/comments.js +82 -0
- package/lib/chevre/repo/mongoose/model/order.js +8 -2
- package/lib/chevre/repo/order.d.ts +6 -0
- package/lib/chevre/repo/order.js +58 -14
- package/lib/chevre/repo/serviceOutput.d.ts +4 -0
- package/lib/chevre/repo/serviceOutput.js +6 -0
- package/lib/chevre/repository.d.ts +6 -3
- package/lib/chevre/repository.js +8 -5
- package/lib/chevre/service/account.d.ts +0 -8
- package/lib/chevre/service/account.js +16 -37
- package/lib/chevre/service/accountTransaction/deposit.js +2 -5
- package/lib/chevre/service/accountTransaction/factory.js +36 -40
- package/lib/chevre/service/accountTransaction/transfer.js +4 -6
- package/lib/chevre/service/accountTransaction/withdraw.js +2 -5
- package/lib/chevre/service/accountTransaction.js +1 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
- package/lib/chevre/service/assetTransaction/pay.js +17 -11
- package/lib/chevre/service/assetTransaction/registerService/factory.js +9 -4
- package/lib/chevre/service/delivery.js +12 -3
- package/lib/chevre/service/event.js +3 -23
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +8 -9
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +6 -2
- package/lib/chevre/service/payment/paymentCard.js +16 -8
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
- package/example/src/chevre/migrateProjectSubscription.ts +0 -51
- package/example/src/chevre/migrateSection.ts +0 -105
- package/lib/chevre/repo/accountAction.d.ts +0 -42
- package/lib/chevre/repo/accountAction.js +0 -474
- package/lib/chevre/repo/mongoose/model/accountAction.js +0 -177
|
@@ -1,157 +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 accountTitleRepo = new chevre.repository.AccountTitle(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const cursor = accountTitleRepo.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('accountTitles found');
|
|
29
|
-
|
|
30
|
-
const additionalPropertyNamesOnCategories: string[] = [];
|
|
31
|
-
const additionalPropertyNames: string[] = [];
|
|
32
|
-
const additionalPropertyNamesOnTitles: string[] = [];
|
|
33
|
-
const projectIdsOnCategories: string[] = [];
|
|
34
|
-
const projectIds: string[] = [];
|
|
35
|
-
const projectIdsOnTitles: string[] = [];
|
|
36
|
-
const unexpextedprojectIdsOnCategories: string[] = [];
|
|
37
|
-
const unexpextedprojectIds: string[] = [];
|
|
38
|
-
const unexpextedprojectIdsOnTitles: 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 accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
|
|
46
|
-
|
|
47
|
-
const additionalPropertyNamesOnCategory = accountTitleCategory.additionalProperty?.map((p) => p.name);
|
|
48
|
-
console.log(
|
|
49
|
-
(Array.isArray(additionalPropertyNamesOnCategory)) ? additionalPropertyNamesOnCategory.length : 0,
|
|
50
|
-
'additionalPropertyNamesOnCategory found',
|
|
51
|
-
accountTitleCategory.project.id,
|
|
52
|
-
accountTitleCategory.codeValue
|
|
53
|
-
);
|
|
54
|
-
if (Array.isArray(additionalPropertyNamesOnCategory) && additionalPropertyNamesOnCategory.length > 0) {
|
|
55
|
-
console.log(
|
|
56
|
-
additionalPropertyNamesOnCategory.length,
|
|
57
|
-
'additionalPropertyNamesOnResource found',
|
|
58
|
-
accountTitleCategory.project.id,
|
|
59
|
-
accountTitleCategory.codeValue
|
|
60
|
-
);
|
|
61
|
-
additionalPropertyNamesOnCategories.push(...additionalPropertyNamesOnCategory);
|
|
62
|
-
projectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
63
|
-
additionalPropertyNamesOnCategory.forEach((name) => {
|
|
64
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
65
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
-
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
67
|
-
}
|
|
68
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
69
|
-
if (name.length < 5) {
|
|
70
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
-
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (Array.isArray(accountTitleCategory.hasCategoryCode)) {
|
|
77
|
-
accountTitleCategory.hasCategoryCode.forEach((accountTitleSet) => {
|
|
78
|
-
const additionalPropertyNamesOnResource = accountTitleSet.additionalProperty?.map((p) => p.name);
|
|
79
|
-
console.log(
|
|
80
|
-
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
81
|
-
'additionalPropertyNamesOnResource found',
|
|
82
|
-
accountTitleCategory.project.id,
|
|
83
|
-
accountTitleCategory.codeValue
|
|
84
|
-
);
|
|
85
|
-
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
86
|
-
console.log(
|
|
87
|
-
additionalPropertyNamesOnResource.length,
|
|
88
|
-
'additionalPropertyNamesOnResource found',
|
|
89
|
-
accountTitleCategory.project.id,
|
|
90
|
-
accountTitleCategory.codeValue
|
|
91
|
-
);
|
|
92
|
-
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
93
|
-
projectIds.push(accountTitleCategory.project.id);
|
|
94
|
-
additionalPropertyNamesOnResource.forEach((name) => {
|
|
95
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
96
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
97
|
-
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
98
|
-
}
|
|
99
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
100
|
-
if (name.length < 5) {
|
|
101
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
102
|
-
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (Array.isArray(accountTitleSet.hasCategoryCode)) {
|
|
108
|
-
accountTitleSet.hasCategoryCode.forEach((accountTitl) => {
|
|
109
|
-
const additionalPropertyNamesOnSection = accountTitl.additionalProperty?.map((p) => p.name);
|
|
110
|
-
console.log(
|
|
111
|
-
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
112
|
-
'additionalPropertyNamesOnSection found',
|
|
113
|
-
accountTitleCategory.project.id,
|
|
114
|
-
accountTitleCategory.codeValue
|
|
115
|
-
);
|
|
116
|
-
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
117
|
-
console.log(
|
|
118
|
-
additionalPropertyNamesOnSection.length,
|
|
119
|
-
'additionalPropertyNamesOnSection found',
|
|
120
|
-
accountTitleCategory.project.id,
|
|
121
|
-
accountTitleCategory.codeValue
|
|
122
|
-
);
|
|
123
|
-
additionalPropertyNamesOnTitles.push(...additionalPropertyNamesOnSection);
|
|
124
|
-
projectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
125
|
-
additionalPropertyNamesOnSection.forEach((name) => {
|
|
126
|
-
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
127
|
-
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
128
|
-
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
129
|
-
}
|
|
130
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
131
|
-
if (name.length < 5) {
|
|
132
|
-
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
133
|
-
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
console.log(i, 'places checked');
|
|
143
|
-
console.log(updateCount, 'places updated');
|
|
144
|
-
console.log([...new Set(additionalPropertyNamesOnCategories)], 'categories');
|
|
145
|
-
console.log([...new Set(projectIdsOnCategories)], 'categories');
|
|
146
|
-
console.log([...new Set(unexpextedprojectIdsOnCategories)], 'categories');
|
|
147
|
-
console.log([...new Set(additionalPropertyNames)], 'sets');
|
|
148
|
-
console.log([...new Set(projectIds)], 'sets');
|
|
149
|
-
console.log([...new Set(unexpextedprojectIds)], 'sets');
|
|
150
|
-
console.log([...new Set(additionalPropertyNamesOnTitles)], 'titles');
|
|
151
|
-
console.log([...new Set(projectIdsOnTitles)], 'titles');
|
|
152
|
-
console.log([...new Set(unexpextedprojectIdsOnTitles)], 'titles');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
main()
|
|
156
|
-
.then()
|
|
157
|
-
.catch(console.error);
|
|
@@ -1,51 +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
|
-
// tslint:disable-next-line:max-func-body-length
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const projectRepo = new chevre.repository.Project(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const cursor = projectRepo.getCursor(
|
|
14
|
-
{
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
// _id: 1,
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
console.log('projects found');
|
|
21
|
-
|
|
22
|
-
let i = 0;
|
|
23
|
-
let updateCount = 0;
|
|
24
|
-
// tslint:disable-next-line:max-func-body-length
|
|
25
|
-
await cursor.eachAsync(async (doc) => {
|
|
26
|
-
i += 1;
|
|
27
|
-
const project: chevre.factory.project.IProject = doc.toObject();
|
|
28
|
-
|
|
29
|
-
const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
|
|
30
|
-
const alreadyMigrated = useEventServiceAsProduct === true;
|
|
31
|
-
|
|
32
|
-
if (alreadyMigrated) {
|
|
33
|
-
console.log('already migrated.', project.id, i);
|
|
34
|
-
} else {
|
|
35
|
-
console.log(
|
|
36
|
-
'updating product...', project.id, i);
|
|
37
|
-
await projectRepo.findByIdAndIUpdate({
|
|
38
|
-
id: project.id,
|
|
39
|
-
subscription: { useEventServiceAsProduct: true }
|
|
40
|
-
});
|
|
41
|
-
updateCount += 1;
|
|
42
|
-
console.log('updated...', project.id, i);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
console.log(i, 'projects checked');
|
|
46
|
-
console.log(updateCount, 'projects updated');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
main()
|
|
50
|
-
.then()
|
|
51
|
-
.catch(console.error);
|
|
@@ -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);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Connection } from 'mongoose';
|
|
2
|
-
import * as factory from '../factory';
|
|
3
|
-
import { modelName } from './mongoose/model/accountAction';
|
|
4
|
-
export { modelName };
|
|
5
|
-
export declare type IAction<T extends factory.actionType> = T extends factory.actionType.MoneyTransfer ? factory.account.action.moneyTransfer.IAction : never;
|
|
6
|
-
/**
|
|
7
|
-
* 口座アクションリポジトリ
|
|
8
|
-
*/
|
|
9
|
-
export declare class MongoRepository {
|
|
10
|
-
private readonly actionModel;
|
|
11
|
-
constructor(connection: Connection);
|
|
12
|
-
/**
|
|
13
|
-
* アクション開始
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* アクション完了
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* アクション中止
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* アクション失敗
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* アクション検索
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* 転送アクションを検索する
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* アクションを検索する
|
|
32
|
-
* @param searchConditions 検索条件
|
|
33
|
-
*/
|
|
34
|
-
clean(params: {
|
|
35
|
-
project?: {
|
|
36
|
-
id?: string;
|
|
37
|
-
};
|
|
38
|
-
startDate: {
|
|
39
|
-
$lt: Date;
|
|
40
|
-
};
|
|
41
|
-
}): Promise<void>;
|
|
42
|
-
}
|