@chevre/domain 21.30.0-alpha.4 → 21.30.0-alpha.40
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/checkActions.ts +65 -0
- package/example/src/chevre/checkReplaceActions.ts +65 -0
- package/example/src/chevre/checkSendEmailMessages4order.ts +73 -0
- package/example/src/chevre/deleteStartDatePassedCertainPeriod.ts +27 -0
- package/example/src/chevre/findReservationByCode.ts +3 -1
- package/example/src/chevre/findValidAuthorization.ts +44 -0
- package/example/src/chevre/importEventsFromCOA.ts +2 -2
- package/example/src/chevre/optimizeActions.ts +38 -9
- package/example/src/chevre/playAroundMessage.ts +73 -0
- package/example/src/chevre/playAroundNote.ts +19 -68
- package/example/src/chevre/playAroundTicket.ts +40 -0
- package/example/src/chevre/searchActions.ts +2 -1
- package/example/src/chevre/searchTasks.ts +43 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +2 -0
- package/example/src/moment.ts +21 -0
- package/lib/chevre/credentials.d.ts +6 -1
- package/lib/chevre/credentials.js +12 -1
- package/lib/chevre/emailMessageBuilder.d.ts +13 -6
- package/lib/chevre/emailMessageBuilder.js +6 -10
- package/lib/chevre/repo/action.js +6 -35
- package/lib/chevre/repo/code.d.ts +21 -13
- package/lib/chevre/repo/code.js +39 -25
- package/lib/chevre/repo/message.d.ts +90 -0
- package/lib/chevre/repo/message.js +183 -0
- package/lib/chevre/repo/mongoose/schemas/authorization.js +4 -9
- package/lib/chevre/repo/mongoose/schemas/message.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/message.js +124 -0
- package/lib/chevre/repo/mongoose/schemas/note.js +12 -0
- package/lib/chevre/repo/mongoose/schemas/task.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/task.js +88 -73
- package/lib/chevre/repo/mongoose/schemas/ticket.d.ts +5 -0
- package/lib/chevre/repo/mongoose/schemas/ticket.js +69 -0
- package/lib/chevre/repo/task.d.ts +27 -8
- package/lib/chevre/repo/task.js +78 -31
- package/lib/chevre/repo/ticket.d.ts +52 -0
- package/lib/chevre/repo/ticket.js +79 -0
- package/lib/chevre/repository.d.ts +13 -3
- package/lib/chevre/repository.js +29 -3
- package/lib/chevre/service/code.d.ts +34 -6
- package/lib/chevre/service/code.js +98 -12
- package/lib/chevre/service/event.d.ts +6 -8
- package/lib/chevre/service/event.js +137 -112
- package/lib/chevre/service/notification.d.ts +2 -0
- package/lib/chevre/service/notification.js +11 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/processStartReserve4chevre.d.ts +4 -0
- package/lib/chevre/service/offer/event/processStartReserve4chevre.js +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.d.ts +1 -0
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/createSendEmailMessageTaskIfNotExist.js +26 -5
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/sendOrder.js +3 -1
- package/lib/chevre/service/payment/any.d.ts +4 -0
- package/lib/chevre/service/payment/any.js +4 -1
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/factory.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +138 -53
- package/lib/chevre/service/reserve/findByCode.d.ts +1 -1
- package/lib/chevre/service/reserve/findByCode.js +4 -4
- package/lib/chevre/service/reserve/useReservation.js +14 -30
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -1
- package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -2
- package/lib/chevre/service/task/authorizePayment.d.ts +2 -2
- package/lib/chevre/service/task/authorizePayment.js +4 -0
- package/lib/chevre/service/task/deleteTransaction.js +2 -0
- package/lib/chevre/service/task/onAuthorizationCreated.js +5 -5
- package/lib/chevre/service/task/refund.d.ts +2 -2
- package/lib/chevre/service/task/refund.js +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +4 -2
- package/lib/chevre/service/task/sendEmailMessage.js +2 -0
- package/lib/chevre/service/task.d.ts +3 -9
- package/lib/chevre/service/task.js +11 -10
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +29 -4
- package/lib/chevre/service/transaction/moneyTransfer.d.ts +6 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +4 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.d.ts +6 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +29 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/sendEmailMessage.js +32 -30
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +5 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +9 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.d.ts +10 -2
- package/lib/chevre/service/transaction/placeOrderInProgress/publishCode.js +4 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +2 -27
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +4 -4
|
@@ -0,0 +1,65 @@
|
|
|
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 CONSOLE_CLIENT_ID = 'xxx';
|
|
8
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
type IAction = chevre.factory.action.IAction<chevre.factory.action.IAttributes<chevre.factory.actionType, any, any>>;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = actionRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
typeOf: { $eq: chevre.factory.actionType.CreateAction },
|
|
20
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
+
startDate: {
|
|
22
|
+
$gte: moment()
|
|
23
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
.add(-60, 'days')
|
|
25
|
+
.toDate()
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('actions found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const action = <IAction>doc.toObject();
|
|
37
|
+
// const size = JSON.stringify(action).length;
|
|
38
|
+
// // console.log(JSON.stringify(action).length);
|
|
39
|
+
// if (action.typeOf !== chevre.factory.actionType.InformAction
|
|
40
|
+
// && action.typeOf !== chevre.factory.actionType.AuthorizeAction
|
|
41
|
+
// && action.typeOf !== chevre.factory.actionType.CheckAction
|
|
42
|
+
// && size > 2000) {
|
|
43
|
+
// console.log(action.typeOf, action.object?.typeOf);
|
|
44
|
+
// console.log(size);
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
const eventCount = (Array.isArray(action.result))
|
|
48
|
+
? action.result.filter(({ typeOf }) => typeOf === chevre.factory.eventType.ScreeningEvent)
|
|
49
|
+
.length
|
|
50
|
+
: 0;
|
|
51
|
+
if (action.instrument?.id !== CONSOLE_CLIENT_ID) {
|
|
52
|
+
console.log(eventCount, 'events created', action.project.id, action.startDate, action.instrument?.id, i);
|
|
53
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
54
|
+
if (eventCount > 10) {
|
|
55
|
+
throw new Error('eventCount too large');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
console.log(i, 'actions checked');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main()
|
|
64
|
+
.then()
|
|
65
|
+
.catch(console.error);
|
|
@@ -0,0 +1,65 @@
|
|
|
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 CONSOLE_CLIENT_ID = 'xxx';
|
|
8
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
type IAction = chevre.factory.action.IAction<chevre.factory.action.IAttributes<chevre.factory.actionType, any, any>>;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = actionRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
typeOf: { $eq: chevre.factory.actionType.ReplaceAction },
|
|
20
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
21
|
+
startDate: {
|
|
22
|
+
$gte: moment()
|
|
23
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
.add(-60, 'days')
|
|
25
|
+
.toDate()
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('actions found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
await cursor.eachAsync(async (doc) => {
|
|
35
|
+
i += 1;
|
|
36
|
+
const action = <IAction>doc.toObject();
|
|
37
|
+
// const size = JSON.stringify(action).length;
|
|
38
|
+
// // console.log(JSON.stringify(action).length);
|
|
39
|
+
// if (action.typeOf !== chevre.factory.actionType.InformAction
|
|
40
|
+
// && action.typeOf !== chevre.factory.actionType.AuthorizeAction
|
|
41
|
+
// && action.typeOf !== chevre.factory.actionType.CheckAction
|
|
42
|
+
// && size > 2000) {
|
|
43
|
+
// console.log(action.typeOf, action.object?.typeOf);
|
|
44
|
+
// console.log(size);
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
const eventCount = (Array.isArray(action.object))
|
|
48
|
+
? action.object.filter(({ typeOf }) => typeOf === chevre.factory.eventType.ScreeningEventSeries)
|
|
49
|
+
.length
|
|
50
|
+
: 0;
|
|
51
|
+
if (action.instrument?.id !== CONSOLE_CLIENT_ID) {
|
|
52
|
+
console.log(eventCount, 'events created', action.project.id, action.startDate, action.instrument?.id, i);
|
|
53
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
54
|
+
if (eventCount > 20) {
|
|
55
|
+
throw new Error('eventCount too large');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
console.log(i, 'actions checked');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main()
|
|
64
|
+
.then()
|
|
65
|
+
.catch(console.error);
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
// const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
|
+
// const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
15
|
+
const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = transactionRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
startDate: {
|
|
20
|
+
$gte: moment()
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
.add(-30, 'days')
|
|
23
|
+
.toDate()
|
|
24
|
+
},
|
|
25
|
+
typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
|
|
26
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed }
|
|
27
|
+
// orderStatus: { $nin: [chevre.factory.orderStatus.OrderReturned] }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
// orderNumber: 1,
|
|
31
|
+
// orderDate: 1,
|
|
32
|
+
// project: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
console.log('transactions found');
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
await cursor.eachAsync(async (doc) => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const transaction = <Pick<
|
|
41
|
+
chevre.factory.transaction.placeOrder.ITransaction,
|
|
42
|
+
'object' | 'result' | 'potentialActions' | 'project' | 'startDate'
|
|
43
|
+
>>doc.toObject();
|
|
44
|
+
|
|
45
|
+
// console.log('searching actions...', order, order.project, order.orderNumber, order.orderDate, i);
|
|
46
|
+
// const actions = await actionRepo.search(
|
|
47
|
+
// {
|
|
48
|
+
// typeOf: { $eq: chevre.factory.actionType.SendAction },
|
|
49
|
+
// purpose: { orderNumber: { $in: [order.orderNumber] } }
|
|
50
|
+
// },
|
|
51
|
+
// ['_id', 'object'],
|
|
52
|
+
// []);
|
|
53
|
+
// const onOrderSentMessageCount: number = actions.filter(
|
|
54
|
+
// ({ object }) => object.about.identifier === chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent
|
|
55
|
+
// ).length;
|
|
56
|
+
let onOrderSentMessageCount: number | undefined =
|
|
57
|
+
transaction.potentialActions?.order.potentialActions?.sendOrder?.potentialActions?.sendEmailMessage?.length;
|
|
58
|
+
if (onOrderSentMessageCount === undefined) {
|
|
59
|
+
onOrderSentMessageCount = 0;
|
|
60
|
+
}
|
|
61
|
+
console.log(
|
|
62
|
+
onOrderSentMessageCount, 'messages found', transaction.project, transaction.object.orderNumber, transaction.startDate, i);
|
|
63
|
+
if (onOrderSentMessageCount > 1) {
|
|
64
|
+
throw new Error(transaction.object.orderNumber);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
console.log(i, 'orders checked');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
main()
|
|
72
|
+
.then()
|
|
73
|
+
.catch(console.error);
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const lt: Date = moment()
|
|
13
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
14
|
+
.add(-16, 'months')
|
|
15
|
+
.toDate();
|
|
16
|
+
let result: any;
|
|
17
|
+
result = await actionRepo.deleteStartDatePassedCertainPeriod({
|
|
18
|
+
$lt: lt
|
|
19
|
+
});
|
|
20
|
+
console.log('result:', result, lt);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main()
|
|
24
|
+
.then(() => {
|
|
25
|
+
console.log('success!');
|
|
26
|
+
})
|
|
27
|
+
.catch(console.error);
|
|
@@ -19,6 +19,7 @@ async function main() {
|
|
|
19
19
|
const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
|
|
20
20
|
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
21
21
|
const reservationRepo = await chevre.repository.Reservation.createInstance(mongoose.connection);
|
|
22
|
+
const ticketRepo = await chevre.repository.Ticket.createInstance(mongoose.connection);
|
|
22
23
|
|
|
23
24
|
await (await chevre.service.reserve.createService()).verifyToken4reservation({
|
|
24
25
|
project: { id: project.id },
|
|
@@ -29,7 +30,8 @@ async function main() {
|
|
|
29
30
|
}
|
|
30
31
|
})({
|
|
31
32
|
authorization: authorizationRepo,
|
|
32
|
-
order: orderRepo
|
|
33
|
+
order: orderRepo,
|
|
34
|
+
ticket: ticketRepo
|
|
33
35
|
});
|
|
34
36
|
console.log('verified.');
|
|
35
37
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const CODE = '85de7dc1-3761-4317-80d6-b36bf0b2788f';
|
|
8
|
+
// const ID = '6631d754c20be0772c217b90';
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const authorizationRepo = await chevre.repository.Code.createInstance(mongoose.connection);
|
|
14
|
+
const ticketRepo = await chevre.repository.Ticket.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const result = await authorizationRepo.findValidOneByCode({
|
|
17
|
+
project,
|
|
18
|
+
code: CODE
|
|
19
|
+
});
|
|
20
|
+
console.log('result:', result);
|
|
21
|
+
|
|
22
|
+
// const result = await authorizationRepo.findValidOneById({
|
|
23
|
+
// project,
|
|
24
|
+
// id: ID
|
|
25
|
+
// });
|
|
26
|
+
// console.log('result:', result);
|
|
27
|
+
|
|
28
|
+
const token = await (await chevre.service.code.createService()).getToken({
|
|
29
|
+
project,
|
|
30
|
+
code: CODE,
|
|
31
|
+
expiresIn: 18000,
|
|
32
|
+
issuer: 'https://example.com',
|
|
33
|
+
audience: 'https://example.com',
|
|
34
|
+
useJti: true
|
|
35
|
+
})({
|
|
36
|
+
authorization: authorizationRepo,
|
|
37
|
+
ticket: ticketRepo
|
|
38
|
+
});
|
|
39
|
+
console.log('token:', token);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main()
|
|
43
|
+
.then(console.log)
|
|
44
|
+
.catch(console.error);
|
|
@@ -30,8 +30,8 @@ async function main() {
|
|
|
30
30
|
.add(1, 'day')
|
|
31
31
|
.toDate(),
|
|
32
32
|
saveMovieTheater: false,
|
|
33
|
-
saveScreeningEventSeries:
|
|
34
|
-
saveScreeningEventSeriesPeriodInMonth:
|
|
33
|
+
saveScreeningEventSeries: false,
|
|
34
|
+
saveScreeningEventSeriesPeriodInMonth: 3
|
|
35
35
|
})({
|
|
36
36
|
action: actionRepo,
|
|
37
37
|
categoryCode: categoryCodeRepo,
|
|
@@ -13,15 +13,14 @@ async function main() {
|
|
|
13
13
|
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
14
14
|
|
|
15
15
|
// tslint:disable-next-line:no-increment-decrement no-magic-numbers
|
|
16
|
-
for (let index = 0; index < 24 *
|
|
16
|
+
for (let index = 0; index < 24 * 1000; index++) {
|
|
17
17
|
const updateResult = await actionRepo.unsetUnnecessaryFields({
|
|
18
18
|
filter: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
typeOf: { $eq: chevre.factory.actionType.PayAction },
|
|
23
|
-
'purpose.typeOf': { $exists: true, $eq: chevre.factory.order.OrderType.Order },
|
|
19
|
+
typeOf: { $eq: chevre.factory.actionType.ReturnAction },
|
|
20
|
+
'object.typeOf': { $exists: true, $eq: 'Invoice' },
|
|
21
|
+
actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
|
|
24
22
|
startDate: {
|
|
23
|
+
// $exists: true,
|
|
25
24
|
$gte: moment()
|
|
26
25
|
.add(-(index + 1), 'hours')
|
|
27
26
|
.toDate(),
|
|
@@ -32,9 +31,39 @@ async function main() {
|
|
|
32
31
|
// _id: { $eq: '61da235d94a80f000af85f6b' }
|
|
33
32
|
},
|
|
34
33
|
$unset: {
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
34
|
+
'result.refundTransaction.project': 1,
|
|
35
|
+
'result.refundTransaction.status': 1,
|
|
36
|
+
'result.refundTransaction.agent': 1,
|
|
37
|
+
'result.refundTransaction.recipient': 1,
|
|
38
|
+
'result.refundTransaction.object': 1,
|
|
39
|
+
'result.refundTransaction.expires': 1,
|
|
40
|
+
'result.refundTransaction.startDate': 1,
|
|
41
|
+
'result.refundTransaction.tasksExportAction': 1,
|
|
42
|
+
'result.refundTransaction.tasksExportationStatus': 1,
|
|
43
|
+
'result.refundTransaction._id': 1,
|
|
44
|
+
'result.refundTransaction.createdAt': 1,
|
|
45
|
+
'result.refundTransaction.updatedAt': 1
|
|
46
|
+
// 'recipient.identifier': 1,
|
|
47
|
+
// 'recipient.memberOf': 1,
|
|
48
|
+
// 'recipient.email': 1,
|
|
49
|
+
// 'recipient.familyName': 1,
|
|
50
|
+
// 'recipient.givenName': 1,
|
|
51
|
+
// 'recipient.telephone': 1
|
|
52
|
+
// 'object.project': 1,
|
|
53
|
+
// 'object.seller': 1,
|
|
54
|
+
// 'object.customer': 1,
|
|
55
|
+
// 'object.paymentMethods': 1,
|
|
56
|
+
// 'object.discounts': 1,
|
|
57
|
+
// 'object.acceptedOffers': 1,
|
|
58
|
+
// 'object.url': 1,
|
|
59
|
+
// 'object.orderStatus': 1,
|
|
60
|
+
// 'object.identifier': 1,
|
|
61
|
+
// 'object.isGift': 1,
|
|
62
|
+
// 'object.broker': 1,
|
|
63
|
+
// 'object.dateReturned': 1,
|
|
64
|
+
// 'object.name': 1,
|
|
65
|
+
// 'object.orderedItem': 1,
|
|
66
|
+
// 'object.returner': 1
|
|
38
67
|
}
|
|
39
68
|
});
|
|
40
69
|
console.log(
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const messageRepo = await chevre.repository.Message.createInstance(mongoose.connection);
|
|
16
|
+
// const createResult = await messageRepo.upsertByIdentifier(
|
|
17
|
+
// [
|
|
18
|
+
// {
|
|
19
|
+
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
20
|
+
// identifier: 'SendOrder-TTT5-8982603-9533198',
|
|
21
|
+
// name: 'SendOrder-TTT5-8982603-9533198',
|
|
22
|
+
// sender: {
|
|
23
|
+
// typeOf: 'Corporation',
|
|
24
|
+
// name: 'sample sender name',
|
|
25
|
+
// email: 'text@example.com'
|
|
26
|
+
// },
|
|
27
|
+
// toRecipient: [
|
|
28
|
+
// {
|
|
29
|
+
// typeOf: 'WebApplication',
|
|
30
|
+
// name: 'sample toRecipient',
|
|
31
|
+
// email: 'text@example.com'
|
|
32
|
+
// }
|
|
33
|
+
// ],
|
|
34
|
+
// about: {
|
|
35
|
+
// typeOf: 'Thing',
|
|
36
|
+
// identifier: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent,
|
|
37
|
+
// name: 'sample about name'
|
|
38
|
+
// },
|
|
39
|
+
// text: 'sample text',
|
|
40
|
+
// mainEntity: {
|
|
41
|
+
// typeOf: chevre.factory.order.OrderType.Order,
|
|
42
|
+
// orderNumber: 'TTT5-8982603-9533198'
|
|
43
|
+
// },
|
|
44
|
+
// provider: { id: '5a392dfdfca1c8737fb6da42', typeOf: chevre.factory.organizationType.Corporation }
|
|
45
|
+
// }
|
|
46
|
+
// ]
|
|
47
|
+
// );
|
|
48
|
+
// console.log('createResult:', createResult);
|
|
49
|
+
|
|
50
|
+
const messages = await messageRepo.search(
|
|
51
|
+
{
|
|
52
|
+
limit: 1,
|
|
53
|
+
page: 1,
|
|
54
|
+
project: {
|
|
55
|
+
id: { $eq: project.id }
|
|
56
|
+
},
|
|
57
|
+
identifier: { $eq: 'SendOrder-TTT5-8982603-9533198' },
|
|
58
|
+
mainEntity: {
|
|
59
|
+
orderNumber: { $eq: 'TTT5-8982603-9533198' }
|
|
60
|
+
},
|
|
61
|
+
about: { identifier: { $eq: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } },
|
|
62
|
+
provider: { id: { $eq: '5a392dfdfca1c8737fb6da42' } }
|
|
63
|
+
},
|
|
64
|
+
['identifier', 'mainEntity', 'about', 'provider'],
|
|
65
|
+
[]
|
|
66
|
+
);
|
|
67
|
+
console.log('messages:', messages);
|
|
68
|
+
console.log(messages.length, 'messages found');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
main()
|
|
72
|
+
.then(console.log)
|
|
73
|
+
.catch(console.error);
|
|
@@ -3,79 +3,30 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
7
11
|
|
|
8
12
|
async function main() {
|
|
9
13
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
14
|
|
|
11
15
|
const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// },
|
|
27
|
-
// creator: {
|
|
28
|
-
// id: '582ee997-86ac-43e4-90c2-213a10c3282f',
|
|
29
|
-
// typeOf: chevre.factory.personType.Person
|
|
30
|
-
// },
|
|
31
|
-
// identifier: '20240213OrderNote',
|
|
32
|
-
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
33
|
-
// text: 'note text',
|
|
34
|
-
// version: '1'
|
|
35
|
-
// }],
|
|
36
|
-
// { overwrite: false }
|
|
37
|
-
// );
|
|
38
|
-
// console.log('createResult:', createResult);
|
|
39
|
-
|
|
40
|
-
// createResult = await noteRepo.upsertByIdentifier(
|
|
41
|
-
// [{
|
|
42
|
-
// about: {
|
|
43
|
-
// id: '65c41ca61898c4feba427e4f',
|
|
44
|
-
// orderNumber: 'CIN2-8393218-6955938',
|
|
45
|
-
// typeOf: chevre.factory.order.OrderType.Order
|
|
46
|
-
// },
|
|
47
|
-
// creator: {
|
|
48
|
-
// id: '582ee997-86ac-43e4-90c2-213a10c3282f',
|
|
49
|
-
// typeOf: chevre.factory.personType.Person
|
|
50
|
-
// },
|
|
51
|
-
// identifier: '20240213OrderNote',
|
|
52
|
-
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
53
|
-
// text: 'note text updated',
|
|
54
|
-
// version: '1'
|
|
55
|
-
// }],
|
|
56
|
-
// { overwrite: false }
|
|
57
|
-
// );
|
|
58
|
-
// console.log('createResult:', createResult);
|
|
59
|
-
|
|
60
|
-
// createResult = await noteRepo.upsertByIdentifier(
|
|
61
|
-
// [{
|
|
62
|
-
// about: {
|
|
63
|
-
// id: '65c41ca61898c4feba427e4f',
|
|
64
|
-
// orderNumber: 'CIN2-8393218-6955938',
|
|
65
|
-
// typeOf: chevre.factory.order.OrderType.Order
|
|
66
|
-
// },
|
|
67
|
-
// creator: {
|
|
68
|
-
// id: '582ee997-86ac-43e4-90c2-213a10c3282f',
|
|
69
|
-
// typeOf: chevre.factory.personType.Person
|
|
70
|
-
// },
|
|
71
|
-
// identifier: '20240213OrderNote',
|
|
72
|
-
// project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
73
|
-
// text: '',
|
|
74
|
-
// version: '1'
|
|
75
|
-
// }],
|
|
76
|
-
// { overwrite: false }
|
|
77
|
-
// );
|
|
78
|
-
// console.log('createResult:', createResult);
|
|
16
|
+
const notes = await noteRepo.search(
|
|
17
|
+
{
|
|
18
|
+
limit: 1,
|
|
19
|
+
page: 1,
|
|
20
|
+
project: {
|
|
21
|
+
id: { $eq: project.id }
|
|
22
|
+
},
|
|
23
|
+
about: { id: { $eq: '' } },
|
|
24
|
+
inclusion: [],
|
|
25
|
+
exclusion: []
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('notes:', notes);
|
|
29
|
+
console.log(notes.length, 'notes found');
|
|
79
30
|
}
|
|
80
31
|
|
|
81
32
|
main()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
const TICKET_TOKEN = 'xxx';
|
|
8
|
+
|
|
9
|
+
mongoose.Model.on('index', (...args) => {
|
|
10
|
+
console.error('******** index event emitted. ********\n', args);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
+
|
|
16
|
+
const ticketRepo = await chevre.repository.Ticket.createInstance(mongoose.connection);
|
|
17
|
+
const tickets = await ticketRepo.search(
|
|
18
|
+
{
|
|
19
|
+
limit: 1,
|
|
20
|
+
page: 1,
|
|
21
|
+
sort: { dateIssued: chevre.factory.sortType.Descending },
|
|
22
|
+
project: {
|
|
23
|
+
id: { $eq: project.id }
|
|
24
|
+
},
|
|
25
|
+
ticketToken: { $eq: TICKET_TOKEN }
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('tickets:', tickets);
|
|
29
|
+
console.log(tickets.length, 'tickets found');
|
|
30
|
+
|
|
31
|
+
const issueResult = await ticketRepo.issueByTicketToken({
|
|
32
|
+
ticketToken: TICKET_TOKEN,
|
|
33
|
+
project: { id: project.id }
|
|
34
|
+
});
|
|
35
|
+
console.log('issueResult:', issueResult);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
main()
|
|
39
|
+
.then(console.log)
|
|
40
|
+
.catch(console.error);
|
|
@@ -24,7 +24,8 @@ async function main() {
|
|
|
24
24
|
// serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
|
|
25
25
|
// }
|
|
26
26
|
// }
|
|
27
|
-
instrument: { transactionNumber: { $eq: 'x' } }
|
|
27
|
+
// instrument: { transactionNumber: { $eq: 'x' } },
|
|
28
|
+
sameAs: { id: { $eq: '66275034ae5d4c3e8997808c' } }
|
|
28
29
|
},
|
|
29
30
|
['_id'],
|
|
30
31
|
[]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
mongoose.Model.on('index', (...args) => {
|
|
9
|
+
console.error('******** index event emitted. ********\n', args);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const indexes = await mongoose.connection.db.collection('tasks')
|
|
16
|
+
.indexes();
|
|
17
|
+
// console.log(indexes);
|
|
18
|
+
console.log(indexes.length, 'indexes found');
|
|
19
|
+
|
|
20
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
21
|
+
const tasks = await taskRepo.search(
|
|
22
|
+
{
|
|
23
|
+
limit: 1,
|
|
24
|
+
page: 1
|
|
25
|
+
// typeOf: { $eq: chevre.factory.actionType.CheckAction },
|
|
26
|
+
// project: { id: { $eq: project.id } },
|
|
27
|
+
// object: {
|
|
28
|
+
// movieTickets: {
|
|
29
|
+
// identifier: { $eq: '0947524082' },
|
|
30
|
+
// serviceOutput: { reservationFor: { id: { $eq: 'clhvvbpyn' } } }
|
|
31
|
+
// }
|
|
32
|
+
// }
|
|
33
|
+
// instrument: { transactionNumber: { $eq: 'x' } },
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
console.log('tasks:', tasks);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main()
|
|
40
|
+
.then(() => {
|
|
41
|
+
console.log('success!');
|
|
42
|
+
})
|
|
43
|
+
.catch(console.error);
|
|
@@ -122,12 +122,14 @@ async function main() {
|
|
|
122
122
|
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
123
123
|
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
124
124
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
125
|
+
authorization: await chevre.repository.Code.createInstance(mongoose.connection),
|
|
125
126
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
126
127
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
127
128
|
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
128
129
|
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
129
130
|
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
130
131
|
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
132
|
+
ticket: await chevre.repository.Ticket.createInstance(mongoose.connection),
|
|
131
133
|
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
132
134
|
transactionProcess:
|
|
133
135
|
await chevre.repository.TransactionProcess.createInstance(client, { lockExpiresInSeconds: 120 }),
|