@chevre/domain 21.7.0-alpha.8 → 21.7.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.
- package/example/src/chevre/countDelayedTasks.ts +1 -1
- package/example/src/chevre/createDeleteTransactionTasks.ts +108 -0
- package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +98 -0
- package/example/src/chevre/deleteRunsAtPassedCertainPeriod.ts +28 -0
- package/example/src/chevre/deleteTasksByName.ts +1 -1
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +4 -4
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +4 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +17 -11
- package/lib/chevre/repo/event.d.ts +12 -0
- package/lib/chevre/repo/event.js +11 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/offer.js +5 -6
- package/lib/chevre/repo/project.d.ts +1 -0
- package/lib/chevre/repo/project.js +10 -4
- package/lib/chevre/repo/task.d.ts +6 -2
- package/lib/chevre/repo/task.js +25 -1
- package/lib/chevre/repo/transaction.d.ts +29 -1
- package/lib/chevre/repo/transaction.js +12 -1
- package/lib/chevre/service/notification.js +13 -6
- package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
- package/lib/chevre/service/order/deleteOrder.js +42 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +20 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +242 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +120 -106
- package/lib/chevre/service/order/placeOrder.d.ts +1 -3
- package/lib/chevre/service/order/placeOrder.js +15 -74
- package/lib/chevre/service/order/returnOrder.d.ts +1 -2
- package/lib/chevre/service/order/returnOrder.js +15 -97
- package/lib/chevre/service/order/sendOrder.d.ts +0 -1
- package/lib/chevre/service/order/sendOrder.js +6 -68
- package/lib/chevre/service/payment/any/factory.js +2 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +6 -6
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +1 -5
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +12 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +92 -88
- package/lib/chevre/service/transaction/placeOrderInProgress.js +0 -2
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +8 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +7 -4
- package/lib/chevre/service/transaction/returnOrder.js +0 -1
- package/lib/chevre/settings.d.ts +1 -1
- package/lib/chevre/settings.js +2 -2
- package/package.json +3 -3
- package/example/src/chevre/checkOrderMembershipTasks.ts +0 -127
- package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -65
- package/example/src/chevre/transaction/orderMembershipService.ts +0 -105
- package/lib/chevre/service/task/orderProgramMembership.d.ts +0 -6
- package/lib/chevre/service/task/orderProgramMembership.js +0 -98
- package/lib/chevre/service/transaction/orderProgramMembership.d.ts +0 -50
- package/lib/chevre/service/transaction/orderProgramMembership.js +0 -349
|
@@ -11,7 +11,7 @@ export async function main() {
|
|
|
11
11
|
const count = await taskRepo.countDelayedTasks({
|
|
12
12
|
delayInSeconds: 60,
|
|
13
13
|
name: {
|
|
14
|
-
$nin: [
|
|
14
|
+
$nin: [<any>'orderProgramMembership']
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
console.log('count:', count);
|
|
@@ -0,0 +1,108 @@
|
|
|
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 ONE_YEAR_IN_DAYS = 365;
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const endDateLt: Date = moment(now)
|
|
15
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
16
|
+
.add(-ONE_YEAR_IN_DAYS, 'days')
|
|
17
|
+
.toDate();
|
|
18
|
+
const startDateLt: Date = moment('2022-01-01T00:00:00Z')
|
|
19
|
+
.toDate();
|
|
20
|
+
|
|
21
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
22
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
23
|
+
|
|
24
|
+
const cursor = transactionRepo.getCursor(
|
|
25
|
+
{
|
|
26
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
27
|
+
startDate: {
|
|
28
|
+
$lt: startDateLt
|
|
29
|
+
}
|
|
30
|
+
// endDate: {
|
|
31
|
+
// $exists: true,
|
|
32
|
+
// $lt: moment(now)
|
|
33
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
34
|
+
// .add(-365, 'days')
|
|
35
|
+
// .toDate()
|
|
36
|
+
// }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
_id: 1,
|
|
40
|
+
typeOf: 1,
|
|
41
|
+
project: 1,
|
|
42
|
+
startDate: 1,
|
|
43
|
+
endDate: 1,
|
|
44
|
+
object: 1
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
console.log('transactions found');
|
|
48
|
+
|
|
49
|
+
let i = 0;
|
|
50
|
+
let updateCount = 0;
|
|
51
|
+
await cursor.eachAsync(async (doc) => {
|
|
52
|
+
i += 1;
|
|
53
|
+
const transaction: Pick<
|
|
54
|
+
chevre.factory.transaction.placeOrder.ITransaction,
|
|
55
|
+
'id' | 'project' | 'typeOf' | 'startDate' | 'endDate' | 'object'
|
|
56
|
+
> = doc.toObject();
|
|
57
|
+
console.log('checking...', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
58
|
+
|
|
59
|
+
const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
|
|
60
|
+
.isBefore(endDateLt);
|
|
61
|
+
if (isEndDateBefore) {
|
|
62
|
+
const runsAt: Date = moment(transaction.endDate)
|
|
63
|
+
.add(ONE_YEAR_IN_DAYS, 'days')
|
|
64
|
+
.toDate();
|
|
65
|
+
|
|
66
|
+
updateCount += 1;
|
|
67
|
+
const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
|
|
68
|
+
project: transaction.project,
|
|
69
|
+
name: chevre.factory.taskName.DeleteTransaction,
|
|
70
|
+
status: chevre.factory.taskStatus.Ready,
|
|
71
|
+
runsAt,
|
|
72
|
+
remainingNumberOfTries: 3,
|
|
73
|
+
numberOfTried: 0,
|
|
74
|
+
executionResults: [],
|
|
75
|
+
data: {
|
|
76
|
+
object: {
|
|
77
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
78
|
+
endDate: transaction.endDate,
|
|
79
|
+
id: transaction.id,
|
|
80
|
+
object: {
|
|
81
|
+
...(typeof transaction.object.confirmationNumber === 'string')
|
|
82
|
+
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
83
|
+
: undefined,
|
|
84
|
+
...(typeof transaction.object.orderNumber === 'string')
|
|
85
|
+
? { orderNumber: transaction.object.orderNumber }
|
|
86
|
+
: undefined
|
|
87
|
+
},
|
|
88
|
+
project: transaction.project,
|
|
89
|
+
startDate: transaction.startDate,
|
|
90
|
+
typeOf: transaction.typeOf
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
console.log(
|
|
95
|
+
'saving task...',
|
|
96
|
+
deleteTransactionTask, transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
97
|
+
await taskRepo.saveMany([deleteTransactionTask], { emitImmediately: false });
|
|
98
|
+
console.log('task saved', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
console.log(i, 'transactions checked');
|
|
103
|
+
console.log(updateCount, 'transactions updated');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
main()
|
|
107
|
+
.then()
|
|
108
|
+
.catch(console.error);
|
|
@@ -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 ONE_YEAR_IN_DAYS = 365;
|
|
8
|
+
type IDeletingTransaction = Pick<
|
|
9
|
+
chevre.factory.transaction.placeOrder.ITransaction,
|
|
10
|
+
'id' | 'project' | 'typeOf' | 'startDate' | 'endDate' | 'object'
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
+
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const endDateLt: Date = moment(now)
|
|
18
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
19
|
+
.add(-ONE_YEAR_IN_DAYS, 'days')
|
|
20
|
+
.toDate();
|
|
21
|
+
|
|
22
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
23
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
24
|
+
|
|
25
|
+
const deletingTransactions = <IDeletingTransaction[]>await transactionRepo.search<chevre.factory.transactionType.PlaceOrder>(
|
|
26
|
+
{
|
|
27
|
+
limit: 100,
|
|
28
|
+
page: 1,
|
|
29
|
+
sort: { startDate: chevre.factory.sortType.Ascending },
|
|
30
|
+
typeOf: chevre.factory.transactionType.PlaceOrder,
|
|
31
|
+
statuses: [
|
|
32
|
+
chevre.factory.transactionStatusType.Canceled,
|
|
33
|
+
chevre.factory.transactionStatusType.Confirmed,
|
|
34
|
+
chevre.factory.transactionStatusType.Expired
|
|
35
|
+
],
|
|
36
|
+
endThrough: endDateLt,
|
|
37
|
+
inclusion: ['_id', 'project', 'typeOf', 'startDate', 'endDate', 'object'],
|
|
38
|
+
exclusion: []
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
let i = 0;
|
|
43
|
+
let updateCount = 0;
|
|
44
|
+
for (const deletingTransaction of deletingTransactions) {
|
|
45
|
+
i += 1;
|
|
46
|
+
const transaction: IDeletingTransaction = deletingTransaction;
|
|
47
|
+
console.log('checking...', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
48
|
+
|
|
49
|
+
const isEndDateBefore = transaction.endDate !== undefined && moment(transaction.endDate)
|
|
50
|
+
.isBefore(endDateLt);
|
|
51
|
+
if (isEndDateBefore) {
|
|
52
|
+
const runsAt: Date = moment(transaction.endDate)
|
|
53
|
+
.add(ONE_YEAR_IN_DAYS, 'days')
|
|
54
|
+
.toDate();
|
|
55
|
+
|
|
56
|
+
updateCount += 1;
|
|
57
|
+
const deleteTransactionTask: chevre.factory.task.deleteTransaction.IAttributes = {
|
|
58
|
+
project: transaction.project,
|
|
59
|
+
name: chevre.factory.taskName.DeleteTransaction,
|
|
60
|
+
status: chevre.factory.taskStatus.Ready,
|
|
61
|
+
runsAt,
|
|
62
|
+
remainingNumberOfTries: 3,
|
|
63
|
+
numberOfTried: 0,
|
|
64
|
+
executionResults: [],
|
|
65
|
+
data: {
|
|
66
|
+
object: {
|
|
67
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.Id,
|
|
68
|
+
endDate: transaction.endDate,
|
|
69
|
+
id: transaction.id,
|
|
70
|
+
object: {
|
|
71
|
+
...(typeof transaction.object.confirmationNumber === 'string')
|
|
72
|
+
? { confirmationNumber: transaction.object.confirmationNumber }
|
|
73
|
+
: undefined,
|
|
74
|
+
...(typeof transaction.object.orderNumber === 'string')
|
|
75
|
+
? { orderNumber: transaction.object.orderNumber }
|
|
76
|
+
: undefined
|
|
77
|
+
},
|
|
78
|
+
project: transaction.project,
|
|
79
|
+
startDate: transaction.startDate,
|
|
80
|
+
typeOf: transaction.typeOf
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
console.log(
|
|
85
|
+
'saving task...',
|
|
86
|
+
deleteTransactionTask.runsAt, transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
87
|
+
await taskRepo.createDeleteTransactionTaskIfNotExist(deleteTransactionTask, { emitImmediately: false });
|
|
88
|
+
console.log('task saved', transaction.project.id, transaction.id, transaction.startDate, transaction.endDate, i);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log(i, 'transactions checked');
|
|
93
|
+
console.log(updateCount, 'transactions updated');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
main()
|
|
97
|
+
.then()
|
|
98
|
+
.catch(console.error);
|
|
@@ -0,0 +1,28 @@
|
|
|
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 TASK_STORAGE_PERIOD_IN_DAYS = 365;
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
const now = new Date();
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const result = await taskRepo.deleteRunsAtPassedCertainPeriod({
|
|
16
|
+
runsAt: {
|
|
17
|
+
$lt: moment(now)
|
|
18
|
+
.add(-TASK_STORAGE_PERIOD_IN_DAYS, 'days')
|
|
19
|
+
.toDate()
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log('deleted', result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
main()
|
|
27
|
+
.then()
|
|
28
|
+
.catch(console.error);
|
|
@@ -12,7 +12,7 @@ async function main() {
|
|
|
12
12
|
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
13
13
|
|
|
14
14
|
const result = await taskRepo.deleteByName({
|
|
15
|
-
name:
|
|
15
|
+
name: <any>'orderProgramMembership',
|
|
16
16
|
status: { $eq: chevre.factory.taskStatus.Ready }
|
|
17
17
|
// runsAt: {
|
|
18
18
|
// $gte: moment('2023-05-20T00:00:00Z')
|
|
@@ -20,10 +20,10 @@ async function main() {
|
|
|
20
20
|
'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
21
21
|
'result.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment },
|
|
22
22
|
startDate: {
|
|
23
|
-
$gte: moment('
|
|
24
|
-
.toDate(),
|
|
25
|
-
$lte: moment('2023-08-01T00:00:00Z')
|
|
23
|
+
$gte: moment('2022-08-16T00:00:00Z')
|
|
26
24
|
.toDate()
|
|
25
|
+
// $lte: moment('2023-08-01T00:00:00Z')
|
|
26
|
+
// .toDate()
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
{
|
|
@@ -46,7 +46,7 @@ async function main() {
|
|
|
46
46
|
'id' | 'project' | 'result' | 'typeOf' | 'startDate' | 'actionStatus'
|
|
47
47
|
> = doc.toObject();
|
|
48
48
|
|
|
49
|
-
const oldPaymentMethodType = action.result?.paymentMethod;
|
|
49
|
+
const oldPaymentMethodType = (<any>action).result?.paymentMethod;
|
|
50
50
|
const paymentMethodType = action.result?.paymentMethodAsObject?.typeOf;
|
|
51
51
|
const alreadyMigrated = typeof paymentMethodType === 'string' && oldPaymentMethodType === paymentMethodType;
|
|
52
52
|
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
|
-
import { ISS_PREFIX, USERPOOL_ID_NEW } from './checkOrderMembershipTasks';
|
|
7
6
|
import { migrateUser } from './migrateCognitoUser';
|
|
8
7
|
|
|
8
|
+
// export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
|
|
9
|
+
export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
10
|
+
export const ISS_PREFIX = 'https://cognito-idp.ap-northeast-1.amazonaws.com/';
|
|
11
|
+
|
|
9
12
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
10
13
|
const PRODUCT_TYPE = chevre.factory.product.ProductType.EventService;
|
|
11
14
|
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
2
3
|
import * as mongoose from 'mongoose';
|
|
3
4
|
|
|
4
5
|
import { chevre } from '../../../lib/index';
|
|
5
6
|
|
|
7
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
|
+
|
|
6
9
|
async function main() {
|
|
7
10
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
11
|
|
|
9
|
-
const
|
|
12
|
+
const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
|
|
10
13
|
|
|
11
14
|
let updateResult: any;
|
|
12
|
-
updateResult = await
|
|
13
|
-
filter: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
updateResult = await transactionRepo.unsetUnnecessaryFields({
|
|
16
|
+
filter: {
|
|
17
|
+
// 'project.id': { $eq: PROJECT_ID },
|
|
18
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
19
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
20
|
+
startDate: {
|
|
21
|
+
$lte: moment('2023-08-16T07:26:00Z')
|
|
22
|
+
.toDate()
|
|
23
|
+
},
|
|
24
|
+
'object.authorizeActions': { $exists: true }
|
|
25
|
+
},
|
|
26
|
+
$unset: { 'object.authorizeActions': 1 }
|
|
21
27
|
});
|
|
22
|
-
console.log('unset processed.', updateResult);
|
|
28
|
+
console.log('unset processed.', updateResult, 'PROJECT_ID:', PROJECT_ID);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
main()
|
|
@@ -252,6 +252,18 @@ export declare class MongoRepository {
|
|
|
252
252
|
};
|
|
253
253
|
};
|
|
254
254
|
}): Promise<import("mongodb").DeleteResult>;
|
|
255
|
+
deleteManyEndedByIds(params: {
|
|
256
|
+
typeOf: {
|
|
257
|
+
$in: factory.eventType[];
|
|
258
|
+
};
|
|
259
|
+
project: {
|
|
260
|
+
id: string;
|
|
261
|
+
};
|
|
262
|
+
ids: string[];
|
|
263
|
+
endDate: {
|
|
264
|
+
$lte: Date;
|
|
265
|
+
};
|
|
266
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
255
267
|
deleteByProject(params: {
|
|
256
268
|
project: {
|
|
257
269
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -966,6 +966,17 @@ class MongoRepository {
|
|
|
966
966
|
.exec();
|
|
967
967
|
});
|
|
968
968
|
}
|
|
969
|
+
deleteManyEndedByIds(params) {
|
|
970
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
971
|
+
return this.eventModel.deleteMany({
|
|
972
|
+
typeOf: { $in: params.typeOf.$in },
|
|
973
|
+
'project.id': { $eq: params.project.id },
|
|
974
|
+
_id: { $in: params.ids },
|
|
975
|
+
endDate: { $lte: params.endDate.$lte }
|
|
976
|
+
})
|
|
977
|
+
.exec();
|
|
978
|
+
});
|
|
979
|
+
}
|
|
969
980
|
deleteByProject(params) {
|
|
970
981
|
return __awaiter(this, void 0, void 0, function* () {
|
|
971
982
|
yield this.eventModel.deleteMany({
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Schema } from 'mongoose';
|
|
26
26
|
declare const modelName = "Offer";
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* 単価オファースキーマ
|
|
29
29
|
*/
|
|
30
30
|
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
31
|
collection: string;
|
|
@@ -53,6 +53,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
53
53
|
}, {
|
|
54
54
|
additionalProperty: any[];
|
|
55
55
|
addOn: any[];
|
|
56
|
+
availability: string;
|
|
56
57
|
availableAtOrFrom: any[];
|
|
57
58
|
_id?: string | undefined;
|
|
58
59
|
name?: any;
|
|
@@ -68,7 +69,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
68
69
|
validFrom?: Date | undefined;
|
|
69
70
|
category?: any;
|
|
70
71
|
advanceBookingRequirement?: any;
|
|
71
|
-
availability?: string | undefined;
|
|
72
72
|
hasMerchantReturnPolicy?: any;
|
|
73
73
|
priceSpecification?: any;
|
|
74
74
|
eligibleCustomerType?: any;
|
|
@@ -84,6 +84,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
84
84
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
85
85
|
additionalProperty: any[];
|
|
86
86
|
addOn: any[];
|
|
87
|
+
availability: string;
|
|
87
88
|
availableAtOrFrom: any[];
|
|
88
89
|
_id?: string | undefined;
|
|
89
90
|
name?: any;
|
|
@@ -99,7 +100,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
99
100
|
validFrom?: Date | undefined;
|
|
100
101
|
category?: any;
|
|
101
102
|
advanceBookingRequirement?: any;
|
|
102
|
-
availability?: string | undefined;
|
|
103
103
|
hasMerchantReturnPolicy?: any;
|
|
104
104
|
priceSpecification?: any;
|
|
105
105
|
eligibleCustomerType?: any;
|
|
@@ -115,6 +115,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
115
115
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
116
116
|
additionalProperty: any[];
|
|
117
117
|
addOn: any[];
|
|
118
|
+
availability: string;
|
|
118
119
|
availableAtOrFrom: any[];
|
|
119
120
|
_id?: string | undefined;
|
|
120
121
|
name?: any;
|
|
@@ -130,7 +131,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
130
131
|
validFrom?: Date | undefined;
|
|
131
132
|
category?: any;
|
|
132
133
|
advanceBookingRequirement?: any;
|
|
133
|
-
availability?: string | undefined;
|
|
134
134
|
hasMerchantReturnPolicy?: any;
|
|
135
135
|
priceSpecification?: any;
|
|
136
136
|
eligibleCustomerType?: any;
|
|
@@ -6,7 +6,7 @@ const writeConcern_1 = require("../writeConcern");
|
|
|
6
6
|
const modelName = 'Offer';
|
|
7
7
|
exports.modelName = modelName;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 単価オファースキーマ
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose_1.Schema({
|
|
12
12
|
project: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -22,14 +22,13 @@ const schema = new mongoose_1.Schema({
|
|
|
22
22
|
alternateName: mongoose_1.SchemaTypes.Mixed,
|
|
23
23
|
// acceptedPaymentMethod: SchemaTypes.Mixed, // 削除(2023-02-27~)
|
|
24
24
|
addOn: [mongoose_1.SchemaTypes.Mixed],
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
availability: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
29
|
availableAtOrFrom: [mongoose_1.SchemaTypes.Mixed],
|
|
30
30
|
hasMerchantReturnPolicy: mongoose_1.SchemaTypes.Mixed,
|
|
31
31
|
itemOffered: mongoose_1.SchemaTypes.Mixed,
|
|
32
|
-
// price: Number, // 削除(2023-02-27~)
|
|
33
32
|
priceCurrency: String,
|
|
34
33
|
priceSpecification: mongoose_1.SchemaTypes.Mixed,
|
|
35
34
|
eligibleCustomerType: mongoose_1.SchemaTypes.Mixed,
|
|
@@ -142,13 +142,19 @@ class MongoRepository {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
findByIdAndIUpdate(params) {
|
|
145
|
-
var _a, _b;
|
|
145
|
+
var _a, _b, _c, _d, _e;
|
|
146
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
|
|
147
|
+
yield this.projectModel.findOneAndUpdate({ _id: params.id }, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (typeof params.alternateName === 'string' && params.alternateName.length > 0)
|
|
148
148
|
? { alternateName: params.alternateName }
|
|
149
|
-
: undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_a = params.settings) === null || _a === void 0 ? void 0 : _a.
|
|
149
|
+
: undefined), (typeof params.name === 'string' && params.name.length > 0) ? { name: params.name } : undefined), (typeof params.logo === 'string' && params.logo.length > 0) ? { logo: params.logo } : undefined), (typeof ((_c = (_b = (_a = params.settings) === null || _a === void 0 ? void 0 : _a.sendEmailMessage) === null || _b === void 0 ? void 0 : _b.sender) === null || _c === void 0 ? void 0 : _c.email) === 'string')
|
|
150
|
+
? {
|
|
151
|
+
'settings.sendEmailMessage': {
|
|
152
|
+
sender: { email: params.settings.sendEmailMessage.sender.email }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
: undefined), (typeof ((_d = params.settings) === null || _d === void 0 ? void 0 : _d.sendgridApiKey) === 'string')
|
|
150
156
|
? { 'settings.sendgridApiKey': params.settings.sendgridApiKey }
|
|
151
|
-
: undefined), (typeof ((
|
|
157
|
+
: undefined), (typeof ((_e = params.subscription) === null || _e === void 0 ? void 0 : _e.useEventServiceAsProduct) === 'boolean')
|
|
152
158
|
? { 'subscription.useEventServiceAsProduct': params.subscription.useEventServiceAsProduct }
|
|
153
159
|
: undefined), {
|
|
154
160
|
// ↓customerUserPoolは廃止
|
|
@@ -31,6 +31,10 @@ export declare class MongoRepository {
|
|
|
31
31
|
id: string;
|
|
32
32
|
}[]>;
|
|
33
33
|
createInformTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.TriggerWebhook>, options: IOptionOnCreate): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* 取引削除タスク冪等作成
|
|
36
|
+
*/
|
|
37
|
+
createDeleteTransactionTaskIfNotExist(params: factory.task.IAttributes<factory.taskName.DeleteTransaction>, options: IOptionOnCreate): Promise<void>;
|
|
34
38
|
executeById(params: {
|
|
35
39
|
id: string;
|
|
36
40
|
executor: {
|
|
@@ -63,7 +67,7 @@ export declare class MongoRepository {
|
|
|
63
67
|
*/
|
|
64
68
|
$nin?: factory.taskName[];
|
|
65
69
|
};
|
|
66
|
-
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/
|
|
70
|
+
}): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
|
|
67
71
|
retry(params: {
|
|
68
72
|
intervalInMinutes: number;
|
|
69
73
|
}): Promise<void>;
|
|
@@ -108,7 +112,7 @@ export declare class MongoRepository {
|
|
|
108
112
|
runsAt: {
|
|
109
113
|
$lt: Date;
|
|
110
114
|
};
|
|
111
|
-
}): Promise<
|
|
115
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
112
116
|
countDelayedTasks(params: {
|
|
113
117
|
delayInSeconds: number;
|
|
114
118
|
name: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -206,6 +206,30 @@ class MongoRepository {
|
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* 取引削除タスク冪等作成
|
|
211
|
+
*/
|
|
212
|
+
createDeleteTransactionTaskIfNotExist(params, options) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
if (params.data.object.specifyingMethod !== factory.task.deleteTransaction.SpecifyingMethod.Id) {
|
|
215
|
+
throw new factory.errors.NotImplemented(`only ${factory.task.deleteTransaction.SpecifyingMethod.Id} implemented`);
|
|
216
|
+
}
|
|
217
|
+
const createdTask = yield this.taskModel.findOneAndUpdate({
|
|
218
|
+
'project.id': { $eq: params.project.id },
|
|
219
|
+
name: { $eq: params.name },
|
|
220
|
+
'data.object.id': { $exists: true, $eq: params.data.object.id }
|
|
221
|
+
}, { $setOnInsert: params }, { new: true, upsert: true })
|
|
222
|
+
.select({ _id: 1 })
|
|
223
|
+
.exec();
|
|
224
|
+
if (options.emitImmediately) {
|
|
225
|
+
task_2.taskEventEmitter.emitTaskStatusChanged({
|
|
226
|
+
id: createdTask.id,
|
|
227
|
+
name: params.name,
|
|
228
|
+
status: factory.taskStatus.Ready
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
209
233
|
executeById(params) {
|
|
210
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
211
235
|
const doc = yield this.taskModel.findOneAndUpdate({
|
|
@@ -427,7 +451,7 @@ class MongoRepository {
|
|
|
427
451
|
*/
|
|
428
452
|
deleteRunsAtPassedCertainPeriod(params) {
|
|
429
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
-
|
|
454
|
+
return this.taskModel.deleteMany({
|
|
431
455
|
runsAt: { $lt: params.runsAt.$lt },
|
|
432
456
|
status: { $in: [factory.taskStatus.Aborted, factory.taskStatus.Executed] }
|
|
433
457
|
})
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
1
25
|
import { Connection } from 'mongoose';
|
|
2
26
|
import * as factory from '../factory';
|
|
3
27
|
interface IAggregationByStatus {
|
|
@@ -98,7 +122,6 @@ export declare class MongoRepository {
|
|
|
98
122
|
confirm<T extends factory.transactionType>(params: {
|
|
99
123
|
typeOf: T;
|
|
100
124
|
id: string;
|
|
101
|
-
authorizeActions: factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>>[];
|
|
102
125
|
result: factory.transaction.IResult<T>;
|
|
103
126
|
potentialActions: factory.transaction.IPotentialActions<T>;
|
|
104
127
|
}): Promise<void>;
|
|
@@ -190,6 +213,11 @@ export declare class MongoRepository {
|
|
|
190
213
|
findByIdAndDelete(params: {
|
|
191
214
|
id: string;
|
|
192
215
|
}): Promise<void>;
|
|
216
|
+
unsetUnnecessaryFields(params: {
|
|
217
|
+
filter: any;
|
|
218
|
+
$unset: any;
|
|
219
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
220
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
193
221
|
aggregatePlaceOrder(params: {
|
|
194
222
|
project?: {
|
|
195
223
|
id?: {
|
|
@@ -438,7 +438,7 @@ class MongoRepository {
|
|
|
438
438
|
}, {
|
|
439
439
|
status: factory.transactionStatusType.Confirmed,
|
|
440
440
|
endDate: new Date(),
|
|
441
|
-
'object.authorizeActions': params.authorizeActions,
|
|
441
|
+
// 'object.authorizeActions': params.authorizeActions,
|
|
442
442
|
result: params.result,
|
|
443
443
|
potentialActions: params.potentialActions // resultを更新
|
|
444
444
|
}, {
|
|
@@ -770,6 +770,17 @@ class MongoRepository {
|
|
|
770
770
|
.exec();
|
|
771
771
|
});
|
|
772
772
|
}
|
|
773
|
+
unsetUnnecessaryFields(params) {
|
|
774
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
775
|
+
return this.transactionModel.updateMany(params.filter, { $unset: params.$unset })
|
|
776
|
+
.exec();
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
getCursor(conditions, projection) {
|
|
780
|
+
return this.transactionModel.find(conditions, projection)
|
|
781
|
+
.sort({ startDate: factory.sortType.Descending })
|
|
782
|
+
.cursor();
|
|
783
|
+
}
|
|
773
784
|
aggregatePlaceOrder(params) {
|
|
774
785
|
return __awaiter(this, void 0, void 0, function* () {
|
|
775
786
|
const statuses = yield Promise.all([
|