1 | const moment = require('moment');
|
2 | const mongoose = require('mongoose');
|
3 | const domain = require('../');
|
4 |
|
5 | async function main() {
|
6 | await mongoose.connect(process.env.MONGOLAB_URI);
|
7 |
|
8 | const actionRepo = new domain.repository.Action(mongoose.connection);
|
9 | const orderRepo = new domain.repository.Order(mongoose.connection);
|
10 | const taskRepo = new domain.repository.Task(mongoose.connection);
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | await domain.service.report.order.createReport({
|
20 | typeOf: 'CreateAction',
|
21 | project: { id: 'cinerino' },
|
22 | agent: { name: 'sampleCode' },
|
23 |
|
24 | object: {
|
25 | typeOf: 'Report',
|
26 | about: 'OrderReport',
|
27 | mentions: {
|
28 | typeOf: 'SearchAction',
|
29 | query: {
|
30 | orderDateFrom: moment().add(-3, 'years').toDate(),
|
31 | orderDateThrough: moment().toDate(),
|
32 | },
|
33 | object: {
|
34 | typeOf: 'Order'
|
35 | }
|
36 | },
|
37 |
|
38 | encodingFormat: domain.factory.encodingFormat.Text.csv,
|
39 | expires: moment().add(1, 'hour').toDate()
|
40 | },
|
41 | potentialActions: {
|
42 | sendEmailMessage: [
|
43 | {
|
44 | object: {
|
45 | about: 'レポートが使用可能です',
|
46 | sender: {
|
47 | name: 'Cinerino Report',
|
48 | email: 'noreply@example.com'
|
49 | },
|
50 | toRecipient: { email: 'ilovegadd@gmail.com' }
|
51 | }
|
52 | }
|
53 | ]
|
54 | }
|
55 | })({
|
56 | action: actionRepo,
|
57 | order: orderRepo,
|
58 | task: taskRepo
|
59 | });
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | }
|
65 |
|
66 | main().then(() => {
|
67 | console.log('success!');
|
68 | }).catch((error) => {
|
69 | console.error(error);
|
70 | process.exit(1);
|
71 | });
|