@chevre/domain 21.2.0-alpha.3 → 21.2.0-alpha.30
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/countDelayedTasks.ts +17 -0
- package/example/src/chevre/countDelayedTransactions.ts +60 -0
- package/example/src/chevre/countMoneyTransferTransaction.ts +36 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
- package/example/src/chevre/lockStockHolder.ts +48 -0
- package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
- package/example/src/chevre/migrateStockHolderKeys.ts +89 -0
- package/example/src/chevre/searchAbortedTasks.ts +30 -0
- package/example/src/chevre/transaction/findCreditCard.ts +1 -1
- package/example/src/chevre/transaction/makeExpired.ts +18 -0
- package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
- package/example/src/chevre/transaction/startExportTasks.ts +19 -0
- package/example/src/chevre/updateTransaction.ts +1 -1
- package/lib/chevre/credentials.d.ts +1 -0
- package/lib/chevre/credentials.js +2 -1
- package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/assetTransaction.js +28 -0
- package/lib/chevre/eventEmitter/task.d.ts +18 -0
- package/lib/chevre/eventEmitter/task.js +28 -0
- package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
- package/lib/chevre/eventEmitter/transaction.js +28 -0
- package/lib/chevre/eventEmitter.d.ts +4 -0
- package/lib/chevre/eventEmitter.js +9 -0
- package/lib/chevre/index.d.ts +3 -2
- package/lib/chevre/index.js +5 -3
- package/lib/chevre/repo/account.js +0 -4
- package/lib/chevre/repo/accountTitle.js +0 -4
- package/lib/chevre/repo/accountTransaction.d.ts +0 -10
- package/lib/chevre/repo/accountTransaction.js +0 -57
- package/lib/chevre/repo/accountingReport.js +0 -4
- package/lib/chevre/repo/action.js +0 -4
- package/lib/chevre/repo/additionalProperty.js +0 -4
- package/lib/chevre/repo/aggregation.js +0 -4
- package/lib/chevre/repo/assetTransaction.d.ts +9 -6
- package/lib/chevre/repo/assetTransaction.js +132 -48
- package/lib/chevre/repo/categoryCode.js +0 -4
- package/lib/chevre/repo/code.js +0 -4
- package/lib/chevre/repo/comment.js +0 -4
- package/lib/chevre/repo/confirmationNumber.js +1 -1
- package/lib/chevre/repo/creativeWork.d.ts +1 -3
- package/lib/chevre/repo/creativeWork.js +0 -4
- package/lib/chevre/repo/customer.js +0 -4
- package/lib/chevre/repo/emailMessage.d.ts +1 -27
- package/lib/chevre/repo/emailMessage.js +0 -4
- package/lib/chevre/repo/event.d.ts +5 -1
- package/lib/chevre/repo/event.js +0 -4
- package/lib/chevre/repo/member.js +0 -4
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
- package/lib/chevre/repo/merchantReturnPolicy.js +0 -4
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
- package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
- package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
- package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
- package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
- package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
- package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
- package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
- package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
- package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
- package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
- package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +62 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
- package/lib/chevre/repo/mongoose/schemas/seller.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
- package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
- package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
- package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
- package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
- package/lib/chevre/repo/offer.js +0 -5
- package/lib/chevre/repo/offerCatalog.js +0 -4
- package/lib/chevre/repo/order.d.ts +25 -0
- package/lib/chevre/repo/order.js +5 -4
- package/lib/chevre/repo/orderNumber.d.ts +0 -1
- package/lib/chevre/repo/orderNumber.js +2 -12
- package/lib/chevre/repo/ownershipInfo.js +0 -4
- package/lib/chevre/repo/permit.js +0 -4
- package/lib/chevre/repo/place.d.ts +5 -1
- package/lib/chevre/repo/place.js +1 -10
- package/lib/chevre/repo/priceSpecification.js +0 -4
- package/lib/chevre/repo/product.js +0 -4
- package/lib/chevre/repo/project.js +0 -4
- package/lib/chevre/repo/rateLimit/offer.d.ts +3 -2
- package/lib/chevre/repo/rateLimit/offer.js +14 -14
- package/lib/chevre/repo/reservation.js +0 -4
- package/lib/chevre/repo/role.js +0 -4
- package/lib/chevre/repo/seller.js +0 -4
- package/lib/chevre/repo/serviceOutput.js +0 -4
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +2 -1
- package/lib/chevre/repo/serviceOutputIdentifier.js +14 -15
- package/lib/chevre/repo/stockHolder.d.ts +1 -0
- package/lib/chevre/repo/stockHolder.js +74 -7
- package/lib/chevre/repo/task.d.ts +17 -2
- package/lib/chevre/repo/task.js +61 -10
- package/lib/chevre/repo/telemetry.js +0 -4
- package/lib/chevre/repo/transaction.d.ts +10 -2
- package/lib/chevre/repo/transaction.js +144 -55
- package/lib/chevre/repo/transactionNumber.d.ts +2 -1
- package/lib/chevre/repo/transactionNumber.js +14 -15
- package/lib/chevre/repo/trip.js +0 -4
- package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -5
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/assetTransaction/pay.js +2 -2
- package/lib/chevre/service/assetTransaction/refund.js +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +1 -2
- package/lib/chevre/service/assetTransaction/reserve.js +1 -1
- package/lib/chevre/service/assetTransaction.d.ts +6 -2
- package/lib/chevre/service/assetTransaction.js +9 -5
- package/lib/chevre/service/notification.d.ts +3 -1
- package/lib/chevre/service/notification.js +2 -6
- package/lib/chevre/service/order/onOrderStatusChanged.js +1 -1
- package/lib/chevre/service/order/placeOrder.js +1 -1
- package/lib/chevre/service/order/returnOrder.js +1 -5
- package/lib/chevre/service/order/sendOrder.js +1 -1
- package/lib/chevre/service/payment/any.js +25 -10
- package/lib/chevre/service/reserve/useReservation.js +1 -8
- package/lib/chevre/service/task.d.ts +9 -0
- package/lib/chevre/service/task.js +43 -4
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +16 -16
- package/lib/chevre/service/transaction/placeOrder.js +1 -5
- package/lib/chevre/service/transaction/placeOrderInProgress.js +2 -2
- package/lib/chevre/service/transaction/returnOrder.js +1 -5
- package/lib/chevre/service/transaction.d.ts +6 -0
- package/lib/chevre/service/transaction.js +9 -7
- package/lib/chevre/settings.d.ts +3 -1
- package/lib/chevre/settings.js +6 -4
- package/package.json +4 -4
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
- package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
export async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
10
|
+
|
|
11
|
+
const count = await taskRepo.countDelayedTasks({ delayInSeconds: 60 });
|
|
12
|
+
console.log('count:', count);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
main()
|
|
16
|
+
.then()
|
|
17
|
+
.catch(console.error);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
export async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
8
|
+
|
|
9
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
10
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
for (const typeOf of [
|
|
13
|
+
chevre.factory.transactionType.PlaceOrder,
|
|
14
|
+
chevre.factory.transactionType.ReturnOrder,
|
|
15
|
+
chevre.factory.transactionType.MoneyTransfer
|
|
16
|
+
]) {
|
|
17
|
+
const count = await transactionRepo.count({
|
|
18
|
+
typeOf,
|
|
19
|
+
statuses: [
|
|
20
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
21
|
+
chevre.factory.transactionStatusType.Confirmed,
|
|
22
|
+
chevre.factory.transactionStatusType.Expired
|
|
23
|
+
],
|
|
24
|
+
tasksExportationStatuses: [
|
|
25
|
+
chevre.factory.transactionTasksExportationStatus.Exporting,
|
|
26
|
+
chevre.factory.transactionTasksExportationStatus.Unexported
|
|
27
|
+
],
|
|
28
|
+
endThrough: new Date()
|
|
29
|
+
});
|
|
30
|
+
console.log('count:', count, typeOf);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const typeOf of [
|
|
34
|
+
chevre.factory.assetTransactionType.CancelReservation,
|
|
35
|
+
chevre.factory.assetTransactionType.MoneyTransfer,
|
|
36
|
+
chevre.factory.assetTransactionType.Pay,
|
|
37
|
+
chevre.factory.assetTransactionType.Refund,
|
|
38
|
+
chevre.factory.assetTransactionType.RegisterService,
|
|
39
|
+
chevre.factory.assetTransactionType.Reserve
|
|
40
|
+
]) {
|
|
41
|
+
const count = await assetTransactionRepo.count({
|
|
42
|
+
typeOf,
|
|
43
|
+
statuses: [
|
|
44
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
45
|
+
chevre.factory.transactionStatusType.Confirmed,
|
|
46
|
+
chevre.factory.transactionStatusType.Expired
|
|
47
|
+
],
|
|
48
|
+
tasksExportationStatuses: [
|
|
49
|
+
chevre.factory.transactionTasksExportationStatus.Exporting,
|
|
50
|
+
chevre.factory.transactionTasksExportationStatus.Unexported
|
|
51
|
+
],
|
|
52
|
+
endThrough: new Date()
|
|
53
|
+
});
|
|
54
|
+
console.log('count:', count, typeOf);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main()
|
|
59
|
+
.then()
|
|
60
|
+
.catch(console.error);
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
export async function main() {
|
|
11
|
+
const now = new Date();
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
+
|
|
14
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const transactions = await transactionRepo.search<chevre.factory.transactionType.MoneyTransfer>(
|
|
17
|
+
{
|
|
18
|
+
project: { id: { $eq: project.id } },
|
|
19
|
+
typeOf: chevre.factory.transactionType.MoneyTransfer,
|
|
20
|
+
statuses: [chevre.factory.transactionStatusType.Confirmed],
|
|
21
|
+
startFrom: moment(now)
|
|
22
|
+
.add(-1, 'year')
|
|
23
|
+
.toDate(),
|
|
24
|
+
startThrough: now,
|
|
25
|
+
inclusion: ['_id', 'startDate', 'typeOf', 'object'],
|
|
26
|
+
exclusion: []
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
const count = transactions.filter((t) => t.object.description === '受け取り')
|
|
30
|
+
.length;
|
|
31
|
+
console.log('transactions found', count);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
main()
|
|
35
|
+
.then()
|
|
36
|
+
.catch(console.error);
|
|
@@ -197,7 +197,10 @@ async function main() {
|
|
|
197
197
|
}
|
|
198
198
|
]);
|
|
199
199
|
console.log(result);
|
|
200
|
-
console.log('upsertedIds:', (Array.isArray(result?.
|
|
200
|
+
console.log('upsertedIds:', (Array.isArray(result?.getUpsertedIds()))
|
|
201
|
+
? result?.getUpsertedIds()
|
|
202
|
+
.map((u: any) => u._id)
|
|
203
|
+
: []);
|
|
201
204
|
}
|
|
202
205
|
|
|
203
206
|
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as redis from 'redis';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
12
|
+
socket: {
|
|
13
|
+
port: Number(<string>process.env.REDIS_PORT),
|
|
14
|
+
host: <string>process.env.REDIS_HOST
|
|
15
|
+
},
|
|
16
|
+
password: <string>process.env.REDIS_KEY
|
|
17
|
+
});
|
|
18
|
+
await client.connect();
|
|
19
|
+
|
|
20
|
+
const startDate = moment('2023-04-18T00:00:00Z');
|
|
21
|
+
|
|
22
|
+
const stockHolderRepo = new chevre.repository.StockHolder(client);
|
|
23
|
+
await stockHolderRepo.lock({
|
|
24
|
+
eventId: 'sampleEventId',
|
|
25
|
+
startDate: startDate.toDate(),
|
|
26
|
+
offers: [
|
|
27
|
+
{
|
|
28
|
+
seatSection: 'sampleSeatSection',
|
|
29
|
+
seatNumber: 'sampleSeatNumber'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
seatSection: 'sampleSeatSection1',
|
|
33
|
+
seatNumber: 'sampleSeatNumber1'
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
expires: moment(startDate)
|
|
37
|
+
.add(1, 'month')
|
|
38
|
+
.toDate(),
|
|
39
|
+
holder: 'sampleStockHolder'
|
|
40
|
+
});
|
|
41
|
+
console.log('locked');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main()
|
|
45
|
+
.then(() => {
|
|
46
|
+
console.log('success!');
|
|
47
|
+
})
|
|
48
|
+
.catch(console.error);
|
|
@@ -0,0 +1,85 @@
|
|
|
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 orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = orderRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
orderDate: {
|
|
21
|
+
$gte: moment()
|
|
22
|
+
.add(-1, 'months')
|
|
23
|
+
.toDate()
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
paymentMethods: 1,
|
|
28
|
+
project: 1,
|
|
29
|
+
orderDate: 1
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
console.log('movies found');
|
|
33
|
+
|
|
34
|
+
const additionalPropertyNames: string[] = [];
|
|
35
|
+
const projectIds: string[] = [];
|
|
36
|
+
const unexpextedprojectIds: string[] = [];
|
|
37
|
+
|
|
38
|
+
let i = 0;
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const order: chevre.factory.order.IOrder = doc.toObject();
|
|
42
|
+
|
|
43
|
+
const additionalPropertyNamesOnOrder = order.paymentMethods.reduce<string[]>(
|
|
44
|
+
(a, b) => {
|
|
45
|
+
if (Array.isArray(b.additionalProperty)) {
|
|
46
|
+
return [...a, ...b.additionalProperty.map((p) => p.name)];
|
|
47
|
+
} else {
|
|
48
|
+
return a;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[]
|
|
52
|
+
);
|
|
53
|
+
if (Array.isArray(additionalPropertyNamesOnOrder) && additionalPropertyNamesOnOrder.length > 0) {
|
|
54
|
+
console.log(
|
|
55
|
+
additionalPropertyNamesOnOrder.join(','),
|
|
56
|
+
additionalPropertyNamesOnOrder.length,
|
|
57
|
+
'additionalPropertyNamesOnOrder found',
|
|
58
|
+
order.project.id,
|
|
59
|
+
order.id,
|
|
60
|
+
order.orderDate
|
|
61
|
+
);
|
|
62
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnOrder);
|
|
63
|
+
projectIds.push(order.project.id);
|
|
64
|
+
additionalPropertyNamesOnOrder.forEach((name) => {
|
|
65
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
66
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
67
|
+
unexpextedprojectIds.push(order.project.id);
|
|
68
|
+
}
|
|
69
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
70
|
+
if (name.length < 5) {
|
|
71
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
72
|
+
unexpextedprojectIds.push(order.project.id);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
console.log(i, 'orders checked');
|
|
78
|
+
console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
|
|
79
|
+
console.log('projectIds:', [...new Set(projectIds)]);
|
|
80
|
+
console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main()
|
|
84
|
+
.then()
|
|
85
|
+
.catch(console.error);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
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
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
+
socket: {
|
|
15
|
+
host: process.env.REDIS_HOST,
|
|
16
|
+
port: Number(process.env.REDIS_PORT)
|
|
17
|
+
},
|
|
18
|
+
password: process.env.REDIS_KEY
|
|
19
|
+
});
|
|
20
|
+
await client.connect();
|
|
21
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
22
|
+
|
|
23
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
24
|
+
const stockHolderRepo = new chevre.repository.StockHolder(client);
|
|
25
|
+
|
|
26
|
+
const cursor = eventRepo.getCursor(
|
|
27
|
+
{
|
|
28
|
+
// 'project.id': { $eq: project.id },
|
|
29
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
30
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
31
|
+
startDate: {
|
|
32
|
+
$gte: moment('2023-04-23T15:00:00Z')
|
|
33
|
+
.toDate()
|
|
34
|
+
}
|
|
35
|
+
// _id: { $eq: 'al6aff83w' }
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
// _id: 1,
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
console.log('events found');
|
|
42
|
+
|
|
43
|
+
let i = 0;
|
|
44
|
+
let updateCount = 0;
|
|
45
|
+
await cursor.eachAsync(async (doc) => {
|
|
46
|
+
i += 1;
|
|
47
|
+
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
48
|
+
|
|
49
|
+
const oldKey = chevre.repository.StockHolder.GET_KEY({
|
|
50
|
+
eventId: event.id,
|
|
51
|
+
startDate: new Date()
|
|
52
|
+
});
|
|
53
|
+
const newKey = chevre.repository.StockHolder.GET_KEY({
|
|
54
|
+
eventId: event.id,
|
|
55
|
+
startDate: moment(event.startDate)
|
|
56
|
+
.toDate()
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
let conflicted = false;
|
|
60
|
+
try {
|
|
61
|
+
await stockHolderRepo.checkIfConflicted({
|
|
62
|
+
key: newKey,
|
|
63
|
+
eventId: event.id
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
conflicted = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (conflicted) {
|
|
70
|
+
updateCount += 1;
|
|
71
|
+
await stockHolderRepo.migrateKey({
|
|
72
|
+
key: newKey,
|
|
73
|
+
eventId: event.id
|
|
74
|
+
});
|
|
75
|
+
console.log(
|
|
76
|
+
'updated...', event.project.id, event.id, event.startDate, i);
|
|
77
|
+
} else {
|
|
78
|
+
console.log(
|
|
79
|
+
'already exist...', event.project.id, event.id, event.startDate, i);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
console.log(i, 'events checked');
|
|
84
|
+
console.log(updateCount, 'events updated');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main()
|
|
88
|
+
.then()
|
|
89
|
+
.catch(console.error);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment-timezone';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const tasks = <chevre.factory.task.ITask<chevre.factory.taskName.Pay>[]>await taskRepo.search({
|
|
13
|
+
// limit: 100,
|
|
14
|
+
// page: 1,
|
|
15
|
+
name: chevre.factory.taskName.Pay,
|
|
16
|
+
statuses: [chevre.factory.taskStatus.Aborted],
|
|
17
|
+
runsFrom: moment('2023-04-27T00:00:00Z')
|
|
18
|
+
.toDate(),
|
|
19
|
+
sort: { runsAt: chevre.factory.sortType.Ascending }
|
|
20
|
+
});
|
|
21
|
+
console.log(tasks.map((task) => `${task.project.id},${task.id},${moment(task.runsAt)
|
|
22
|
+
.tz('Asia/Tokyo')
|
|
23
|
+
.format('YYYY-MM-DDTHH:mm:ssZ')},"${task.data.object[0].paymentMethod.paymentMethodId}"`)
|
|
24
|
+
.join('\n'));
|
|
25
|
+
console.log(tasks.length);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
main()
|
|
29
|
+
.then(console.log)
|
|
30
|
+
.catch(console.error);
|
|
@@ -11,7 +11,7 @@ async function main() {
|
|
|
11
11
|
|
|
12
12
|
const projectRepo = new chevre.repository.Project(mongoose.connection);
|
|
13
13
|
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
14
|
-
const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.userPoolIdNew });
|
|
14
|
+
const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.settings.userPoolIdNew });
|
|
15
15
|
|
|
16
16
|
const result = await findCreditCard({
|
|
17
17
|
project: { id: project.id },
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
|
+
const result = await transactionRepo.makeExpired({
|
|
11
|
+
expires: new Date()
|
|
12
|
+
});
|
|
13
|
+
console.log(result);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
main()
|
|
17
|
+
.then(console.log)
|
|
18
|
+
.catch(console.error);
|
|
@@ -19,7 +19,7 @@ async function main() {
|
|
|
19
19
|
});
|
|
20
20
|
await redisClient.connect();
|
|
21
21
|
|
|
22
|
-
const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.userPoolIdNew });
|
|
22
|
+
const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.settings.userPoolIdNew });
|
|
23
23
|
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
24
24
|
const accountRepo = new chevre.repository.Account(mongoose.connection);
|
|
25
25
|
const accountingReportRepo = new chevre.repository.AccountingReport(mongoose.connection);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
+
|
|
9
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
|
+
const result = await transactionRepo.startExportTasks({
|
|
11
|
+
typeOf: { $in: [chevre.factory.transactionType.PlaceOrder] },
|
|
12
|
+
status: chevre.factory.transactionStatusType.Confirmed
|
|
13
|
+
});
|
|
14
|
+
console.log(result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
main()
|
|
18
|
+
.then(console.log)
|
|
19
|
+
.catch(console.error);
|
|
@@ -31,7 +31,8 @@ exports.credentials = {
|
|
|
31
31
|
},
|
|
32
32
|
lineNotify: {
|
|
33
33
|
url: process.env.LINE_NOTIFY_URL,
|
|
34
|
-
accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN
|
|
34
|
+
accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN,
|
|
35
|
+
accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT
|
|
35
36
|
},
|
|
36
37
|
movieticketReserve: {
|
|
37
38
|
// tslint:disable-next-line:no-magic-numbers
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
interface IListenArgsOnAssetTransactionStatusChanged {
|
|
5
|
+
/**
|
|
6
|
+
* 取引ID
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
typeOf: factory.assetTransactionType;
|
|
10
|
+
status: factory.transactionStatusType;
|
|
11
|
+
}
|
|
12
|
+
type IOnAssetTransactionStatusChangedListener = (listenArgs: IListenArgsOnAssetTransactionStatusChanged) => void;
|
|
13
|
+
/**
|
|
14
|
+
* 資産取引イベントエミッター
|
|
15
|
+
*/
|
|
16
|
+
declare class AssetTransactionEventEmitter extends EventEmitter {
|
|
17
|
+
onAssetTransactionStatusChanged(listner: IOnAssetTransactionStatusChangedListener): void;
|
|
18
|
+
emitAssetTransactionStatusChanged(args: IListenArgsOnAssetTransactionStatusChanged): void;
|
|
19
|
+
}
|
|
20
|
+
declare const assetTransactionEventEmitter: AssetTransactionEventEmitter;
|
|
21
|
+
export { IListenArgsOnAssetTransactionStatusChanged, assetTransactionEventEmitter };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetTransactionEventEmitter = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
6
|
+
var EventName;
|
|
7
|
+
(function (EventName) {
|
|
8
|
+
EventName["OnAssetTransactionStatusChanged"] = "OnAssetTransactionStatusChanged";
|
|
9
|
+
})(EventName || (EventName = {}));
|
|
10
|
+
/**
|
|
11
|
+
* 資産取引イベントエミッター
|
|
12
|
+
*/
|
|
13
|
+
class AssetTransactionEventEmitter extends events_1.EventEmitter {
|
|
14
|
+
onAssetTransactionStatusChanged(listner) {
|
|
15
|
+
this.on(EventName.OnAssetTransactionStatusChanged, listner);
|
|
16
|
+
}
|
|
17
|
+
emitAssetTransactionStatusChanged(args) {
|
|
18
|
+
if (settings_1.USE_EVENT_EMITTERS) {
|
|
19
|
+
this.emit(EventName.OnAssetTransactionStatusChanged, args);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const assetTransactionEventEmitter = new AssetTransactionEventEmitter();
|
|
24
|
+
exports.assetTransactionEventEmitter = assetTransactionEventEmitter;
|
|
25
|
+
assetTransactionEventEmitter.on('error', (err) => {
|
|
26
|
+
// tslint:disable-next-line:no-console
|
|
27
|
+
console.error('assetTransactionEventEmitter listened an error.', err);
|
|
28
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
interface IListenArgsOnTaskStatusChanged {
|
|
5
|
+
id?: string;
|
|
6
|
+
name: factory.taskName;
|
|
7
|
+
status: factory.taskStatus;
|
|
8
|
+
}
|
|
9
|
+
type IOnTaskStatusChangedListener = (listenArgs: IListenArgsOnTaskStatusChanged) => void;
|
|
10
|
+
/**
|
|
11
|
+
* タスクイベントエミッター
|
|
12
|
+
*/
|
|
13
|
+
declare class TaskEventEmitter extends EventEmitter {
|
|
14
|
+
onTaskStatusChanged(listner: IOnTaskStatusChangedListener): void;
|
|
15
|
+
emitTaskStatusChanged(args: IListenArgsOnTaskStatusChanged): void;
|
|
16
|
+
}
|
|
17
|
+
declare const taskEventEmitter: TaskEventEmitter;
|
|
18
|
+
export { IOnTaskStatusChangedListener, taskEventEmitter };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.taskEventEmitter = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
6
|
+
var EventName;
|
|
7
|
+
(function (EventName) {
|
|
8
|
+
EventName["OnTaskStatusChanged"] = "OnTaskStatusChanged";
|
|
9
|
+
})(EventName || (EventName = {}));
|
|
10
|
+
/**
|
|
11
|
+
* タスクイベントエミッター
|
|
12
|
+
*/
|
|
13
|
+
class TaskEventEmitter extends events_1.EventEmitter {
|
|
14
|
+
onTaskStatusChanged(listner) {
|
|
15
|
+
this.on(EventName.OnTaskStatusChanged, listner);
|
|
16
|
+
}
|
|
17
|
+
emitTaskStatusChanged(args) {
|
|
18
|
+
if (settings_1.USE_EVENT_EMITTERS) {
|
|
19
|
+
this.emit(EventName.OnTaskStatusChanged, args);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const taskEventEmitter = new TaskEventEmitter();
|
|
24
|
+
exports.taskEventEmitter = taskEventEmitter;
|
|
25
|
+
taskEventEmitter.on('error', (err) => {
|
|
26
|
+
// tslint:disable-next-line:no-console
|
|
27
|
+
console.error('taskEventEmitter listened an error.', err);
|
|
28
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
interface IListenArgsOnTransactionStatusChanged {
|
|
5
|
+
/**
|
|
6
|
+
* 取引ID
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
typeOf: factory.transactionType;
|
|
10
|
+
status: factory.transactionStatusType;
|
|
11
|
+
}
|
|
12
|
+
type IOnTransactionStatusChangedListener = (listenArgs: IListenArgsOnTransactionStatusChanged) => void;
|
|
13
|
+
/**
|
|
14
|
+
* 取引イベントエミッター
|
|
15
|
+
*/
|
|
16
|
+
declare class TransactionEventEmitter extends EventEmitter {
|
|
17
|
+
onTransactionStatusChanged(listner: IOnTransactionStatusChangedListener): void;
|
|
18
|
+
emitTransactionStatusChanged(args: IListenArgsOnTransactionStatusChanged): void;
|
|
19
|
+
}
|
|
20
|
+
declare const transactionEventEmitter: TransactionEventEmitter;
|
|
21
|
+
export { IListenArgsOnTransactionStatusChanged, transactionEventEmitter };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transactionEventEmitter = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const settings_1 = require("../settings");
|
|
6
|
+
var EventName;
|
|
7
|
+
(function (EventName) {
|
|
8
|
+
EventName["OnTransactionStatusChanged"] = "OnTransactionStatusChanged";
|
|
9
|
+
})(EventName || (EventName = {}));
|
|
10
|
+
/**
|
|
11
|
+
* 取引イベントエミッター
|
|
12
|
+
*/
|
|
13
|
+
class TransactionEventEmitter extends events_1.EventEmitter {
|
|
14
|
+
onTransactionStatusChanged(listner) {
|
|
15
|
+
this.on(EventName.OnTransactionStatusChanged, listner);
|
|
16
|
+
}
|
|
17
|
+
emitTransactionStatusChanged(args) {
|
|
18
|
+
if (settings_1.USE_EVENT_EMITTERS) {
|
|
19
|
+
this.emit(EventName.OnTransactionStatusChanged, args);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const transactionEventEmitter = new TransactionEventEmitter();
|
|
24
|
+
exports.transactionEventEmitter = transactionEventEmitter;
|
|
25
|
+
transactionEventEmitter.on('error', (err) => {
|
|
26
|
+
// tslint:disable-next-line:no-console
|
|
27
|
+
console.error('transactionEventEmitter listened an error.', err);
|
|
28
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { assetTransactionEventEmitter } from './eventEmitter/assetTransaction';
|
|
2
|
+
import { taskEventEmitter } from './eventEmitter/task';
|
|
3
|
+
import { transactionEventEmitter } from './eventEmitter/transaction';
|
|
4
|
+
export { assetTransactionEventEmitter as assetTransaction, taskEventEmitter as task, transactionEventEmitter as transaction };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transaction = exports.task = exports.assetTransaction = void 0;
|
|
4
|
+
const assetTransaction_1 = require("./eventEmitter/assetTransaction");
|
|
5
|
+
Object.defineProperty(exports, "assetTransaction", { enumerable: true, get: function () { return assetTransaction_1.assetTransactionEventEmitter; } });
|
|
6
|
+
const task_1 = require("./eventEmitter/task");
|
|
7
|
+
Object.defineProperty(exports, "task", { enumerable: true, get: function () { return task_1.taskEventEmitter; } });
|
|
8
|
+
const transaction_1 = require("./eventEmitter/transaction");
|
|
9
|
+
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return transaction_1.transactionEventEmitter; } });
|
package/lib/chevre/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import * as GMO from '@motionpicture/gmo-service';
|
|
|
6
6
|
import * as surfrock from '@surfrock/sdk';
|
|
7
7
|
import { credentials } from './credentials';
|
|
8
8
|
import * as errorHandler from './errorHandler';
|
|
9
|
+
import * as eventEmitter from './eventEmitter';
|
|
9
10
|
import * as factory from './factory';
|
|
10
11
|
import * as pecorinoapi from './pecorinoapi';
|
|
11
12
|
import * as repository from './repository';
|
|
12
13
|
import * as service from './service';
|
|
13
|
-
import
|
|
14
|
-
export { credentials, errorHandler, factory, repository, service, settings, surfrock, pecorinoapi, COA, GMO };
|
|
14
|
+
import * as settings from './settings';
|
|
15
|
+
export { credentials, errorHandler, eventEmitter, factory, repository, service, settings, surfrock, pecorinoapi, COA, GMO };
|