@chevre/domain 21.9.0-alpha.9 → 21.10.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/README.md +4 -35
- package/example/src/chevre/createManyEventsIfNotExist.ts +2 -2
- package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +4 -1
- package/example/src/chevre/searchOfferCatalogItemAvailability.ts +38 -0
- package/example/src/chevre/searchOfferCatalogItems.ts +41 -26
- package/example/src/chevre/searchOffers.ts +16 -4
- package/example/src/chevre/searchOrders.ts +18 -14
- package/example/src/chevre/syncCatalogs2aggregateOffers.ts +23 -21
- package/lib/chevre/repo/aggregateOffer.d.ts +19 -3
- package/lib/chevre/repo/aggregateOffer.js +227 -27
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +45 -45
- package/lib/chevre/repo/offer.d.ts +17 -13
- package/lib/chevre/repo/offer.js +122 -42
- package/lib/chevre/repo/offerCatalog.d.ts +11 -0
- package/lib/chevre/repo/offerCatalog.js +30 -1
- package/lib/chevre/repo/offerCatalogItem.d.ts +20 -1
- package/lib/chevre/repo/offerCatalogItem.js +67 -23
- package/lib/chevre/repo/order.js +19 -11
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +52 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +124 -6
- package/lib/chevre/service/offer/event.d.ts +2 -2
- package/lib/chevre/service/offer/event.js +3 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +3 -3
- package/lib/chevre/service/offer/product.js +3 -30
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +3 -3
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +20 -0
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +28 -0
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +15 -5
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +45 -33
- package/lib/chevre/service/task/onResourceUpdated.js +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,13 +6,12 @@
|
|
|
6
6
|
[](https://snyk.io/test/github/chevre-jp/domain)
|
|
7
7
|
[](https://nodei.co/npm/@chevre/domain/)
|
|
8
8
|
|
|
9
|
-
Node.js client library for using Chevre backend programming.
|
|
10
|
-
|
|
11
9
|
## Table of contents
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
- [Chevre Domain Library for Node.js](#chevre-domain-library-for-nodejs)
|
|
12
|
+
- [Table of contents](#table-of-contents)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [License](#license)
|
|
16
15
|
|
|
17
16
|
## Usage
|
|
18
17
|
|
|
@@ -20,36 +19,6 @@ Node.js client library for using Chevre backend programming.
|
|
|
20
19
|
npm install @chevre/domain
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
### Environment variables
|
|
24
|
-
|
|
25
|
-
| Name | Required | Value | Purpose |
|
|
26
|
-
| -------------------------------- | -------- | --------------- | ------------------------------ |
|
|
27
|
-
| `AWS_ACCESS_KEY_ID` | true | | AWS access key |
|
|
28
|
-
| `AWS_SECRET_ACCESS_KEY` | true | | AWS secret access key |
|
|
29
|
-
| `CHEVRE_AUTHORIZE_SERVER_DOMAIN` | true | | Chevre credentials |
|
|
30
|
-
| `CHEVRE_CLIENT_ID` | true | | Chevre credentials |
|
|
31
|
-
| `CHEVRE_CLIENT_SECRET` | true | | Chevre credentials |
|
|
32
|
-
| `CHEVRE_ENDPOINT` | true | | Chevre credentials |
|
|
33
|
-
| `CUSTOM_SEARCH_ENGINE_ID` | true | | Google Custom Search Engine ID |
|
|
34
|
-
| `COA_ENDPOINT` | true | | COA credentilas |
|
|
35
|
-
| `COA_REFRESH_TOKEN` | true | | credentilas |
|
|
36
|
-
| `DEBUG` | false | chevre-domain:* | Debug |
|
|
37
|
-
| `GOOGLE_API_KEY` | true | | Google API Key |
|
|
38
|
-
| `INFORM_ORDER_URL` | false | | Inform Order URLs |
|
|
39
|
-
| `INFORM_TRANSACTION_URL` | false | | Inform Transaction URLs |
|
|
40
|
-
| `LINE_NOTIFY_URL` | true | | LINE Notify URL |
|
|
41
|
-
| `LINE_NOTIFY_ACCESS_TOKEN` | true | | LINE Notify access token |
|
|
42
|
-
| `SENDGRID_API_KEY` | true | | SendGrid API key |
|
|
43
|
-
| `COA_TIMEOUT` | false | | Timeout settings |
|
|
44
|
-
| `GMO_TIMEOUT` | false | | Timeout settings |
|
|
45
|
-
| `MVTK_TIMEOUT` | false | | Timeout settings |
|
|
46
|
-
| `TRIGGER_WEBHOOK_TIMEOUT` | false | | Timeout settings |
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
## Code Samples
|
|
50
|
-
|
|
51
|
-
Code sample are [here](https://github.com/chevre-jp/domain/tree/master/example).
|
|
52
|
-
|
|
53
22
|
## License
|
|
54
23
|
|
|
55
24
|
ISC
|
|
@@ -92,7 +92,7 @@ async function main() {
|
|
|
92
92
|
.toDate(),
|
|
93
93
|
description: {
|
|
94
94
|
en: 'english description',
|
|
95
|
-
ja: '
|
|
95
|
+
ja: 'イベント説明'
|
|
96
96
|
},
|
|
97
97
|
headline: {
|
|
98
98
|
en: 'headlineheadlineheadlineheadlineheadlineheadlineheadline',
|
|
@@ -261,7 +261,7 @@ async function main() {
|
|
|
261
261
|
.toDate(),
|
|
262
262
|
description: {
|
|
263
263
|
en: 'english description',
|
|
264
|
-
ja: '
|
|
264
|
+
ja: 'イベント説明'
|
|
265
265
|
},
|
|
266
266
|
headline: {
|
|
267
267
|
en: 'headlineheadlineheadlineheadlineheadlineheadlineheadline',
|
|
@@ -15,9 +15,11 @@ async function main() {
|
|
|
15
15
|
limit: 10,
|
|
16
16
|
page: 1,
|
|
17
17
|
subOfferCatalog: {
|
|
18
|
-
id: '0001'
|
|
18
|
+
id: '0001',
|
|
19
|
+
isOfferCatalogItem: false
|
|
19
20
|
},
|
|
20
21
|
excludeAppliesToMovieTicket: false,
|
|
22
|
+
useIncludeInDataCatalog: true,
|
|
21
23
|
unacceptedPaymentMethod: []
|
|
22
24
|
});
|
|
23
25
|
console.log(result);
|
|
@@ -26,6 +28,7 @@ async function main() {
|
|
|
26
28
|
result = await chevre.service.offer.event.searchOfferAppliesToMovieTicket({
|
|
27
29
|
event: { id: 'cllkq475p' },
|
|
28
30
|
onlyValid: true,
|
|
31
|
+
useIncludeInDataCatalog: true,
|
|
29
32
|
limit: 100,
|
|
30
33
|
page: 1
|
|
31
34
|
// ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
|
+
mongoose.Model.on('index', (...args) => {
|
|
8
|
+
console.error('******** index event emitted. ********\n', args);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
16
|
+
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
17
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const result = await chevre.service.offer.event.searchOfferCatalogItemAvailability({
|
|
20
|
+
event: {
|
|
21
|
+
id: 'cllkq475u'
|
|
22
|
+
},
|
|
23
|
+
limit: 10,
|
|
24
|
+
page: 1,
|
|
25
|
+
availableAtOrFrom: { id: '3eo6okferrsdpfd9j2ce1iv9k7' }
|
|
26
|
+
})({
|
|
27
|
+
event: eventRepo,
|
|
28
|
+
offer: offerRepo,
|
|
29
|
+
offerCatalog: offerCatalogRepo,
|
|
30
|
+
product: productRepo
|
|
31
|
+
});
|
|
32
|
+
console.log(result);
|
|
33
|
+
console.log(result.length);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main()
|
|
37
|
+
.then(console.log)
|
|
38
|
+
.catch(console.error);
|
|
@@ -3,7 +3,7 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
-
const PROJECT_ID = process.env.PROJECT_ID;
|
|
6
|
+
// const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
7
|
mongoose.Model.on('index', (...args) => {
|
|
8
8
|
console.error('******** index event emitted. ********\n', args);
|
|
9
9
|
});
|
|
@@ -11,31 +11,46 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
16
|
+
const offerCatalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
|
|
17
|
+
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
18
|
+
|
|
19
|
+
const result = await chevre.service.offer.event.searchOfferCatalogItems({
|
|
20
|
+
event: {
|
|
21
|
+
id: 'cllkq475u'
|
|
22
|
+
},
|
|
23
|
+
limit: 10,
|
|
24
|
+
page: 1
|
|
25
|
+
})({
|
|
26
|
+
event: eventRepo,
|
|
27
|
+
offerCatalog: offerCatalogRepo,
|
|
28
|
+
offerCatalogItem: offerCatalogItemRepo,
|
|
29
|
+
product: productRepo
|
|
30
|
+
});
|
|
31
|
+
console.log(result);
|
|
32
|
+
console.log(result.length);
|
|
33
|
+
|
|
34
|
+
// console.log('searching...');
|
|
35
|
+
// const catalogs = await catalogItemRepo.search(
|
|
36
|
+
// {
|
|
37
|
+
// project: { id: { $eq: PROJECT_ID } },
|
|
38
|
+
// sort: { identifier: chevre.factory.sortType.Descending },
|
|
39
|
+
// limit: 2,
|
|
40
|
+
// page: 1,
|
|
41
|
+
// itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
42
|
+
// }
|
|
43
|
+
// );
|
|
44
|
+
// console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
|
|
45
|
+
// console.log(catalogs.length);
|
|
46
|
+
|
|
47
|
+
// const numCatalogs = await catalogItemRepo.count(
|
|
48
|
+
// {
|
|
49
|
+
// project: { id: { $eq: PROJECT_ID } },
|
|
50
|
+
// itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
51
|
+
// }
|
|
52
|
+
// );
|
|
53
|
+
// console.log('numCatalogs:', numCatalogs);
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
main()
|
|
@@ -3,8 +3,20 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
+
mongoose.Model.on('index', (...args) => {
|
|
7
|
+
console.error('******** index event emitted. ********\n', args);
|
|
8
|
+
});
|
|
9
|
+
|
|
6
10
|
async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
12
|
+
|
|
13
|
+
const indexes = await mongoose.connection.db.collection('aggregateOffers')
|
|
14
|
+
.indexes();
|
|
15
|
+
console.log(indexes);
|
|
16
|
+
console.log(indexes.length);
|
|
17
|
+
// await mongoose.connection.db.collection('aggregateOffers')
|
|
18
|
+
// .dropIndexes();
|
|
19
|
+
// console.log('indexes droped');
|
|
8
20
|
|
|
9
21
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
10
22
|
|
|
@@ -33,9 +45,9 @@ async function main() {
|
|
|
33
45
|
// ]
|
|
34
46
|
// }
|
|
35
47
|
});
|
|
36
|
-
console.log(offers.map((offer) => {
|
|
37
|
-
|
|
38
|
-
}));
|
|
48
|
+
// console.log(offers.map((offer) => {
|
|
49
|
+
// return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja}`;
|
|
50
|
+
// }));
|
|
39
51
|
console.log(offers.length);
|
|
40
52
|
}
|
|
41
53
|
|
|
@@ -6,27 +6,31 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
11
|
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const orders = await orderRepo.search({
|
|
14
14
|
limit: 10,
|
|
15
15
|
project: { id: { $eq: project.id } },
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// $in: [
|
|
25
|
-
// { name: 'orderId', value: '0102022031518442020' },
|
|
26
|
-
// { name: 'orderId', value: '0102022031518423030' }
|
|
27
|
-
// ]
|
|
28
|
-
// }
|
|
16
|
+
acceptedOffers: {
|
|
17
|
+
// $size: 1
|
|
18
|
+
// itemOffered: {
|
|
19
|
+
// issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.MembershipService } }
|
|
20
|
+
// }
|
|
21
|
+
},
|
|
22
|
+
orderedItem: {
|
|
23
|
+
$size: 3
|
|
29
24
|
}
|
|
25
|
+
// paymentMethods: {
|
|
26
|
+
// paymentMethod: { identifier: { $in: ['Cash'] } }
|
|
27
|
+
// additionalProperty: {
|
|
28
|
+
// $in: [
|
|
29
|
+
// { name: 'orderId', value: '0102022031518442020' },
|
|
30
|
+
// { name: 'orderId', value: '0102022031518423030' }
|
|
31
|
+
// ]
|
|
32
|
+
// }
|
|
33
|
+
// }
|
|
30
34
|
});
|
|
31
35
|
console.log('orders found', orders);
|
|
32
36
|
console.log(orders.length, 'orders found');
|
|
@@ -11,15 +11,17 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
// tslint:disable-next-line:max-func-body-length
|
|
12
12
|
async function main() {
|
|
13
13
|
const now = new Date();
|
|
14
|
-
|
|
14
|
+
console.log('now:', now);
|
|
15
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
16
|
|
|
16
17
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
17
18
|
const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
18
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
|
+
// const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
20
|
|
|
20
21
|
const cursor = offerCatalogRepo.getCursor(
|
|
21
22
|
{
|
|
22
23
|
// 'project.id': { $eq: project.id }
|
|
24
|
+
'itemListElement.typeOf': { $exists: true, $eq: chevre.factory.offerType.Offer }
|
|
23
25
|
},
|
|
24
26
|
{
|
|
25
27
|
__v: 0,
|
|
@@ -52,25 +54,25 @@ async function main() {
|
|
|
52
54
|
console.log('already synced.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
53
55
|
} else {
|
|
54
56
|
console.log('creating task...', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
55
|
-
const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
await taskRepo.saveMany([syncTask], { emitImmediately: false });
|
|
57
|
+
// const syncTaskData: chevre.factory.task.onResourceUpdated.IData4common = {
|
|
58
|
+
// typeOf: 'OfferCatalog',
|
|
59
|
+
// id: [String(offerCatalog.id)],
|
|
60
|
+
// isNew: false,
|
|
61
|
+
// isDeleted: false,
|
|
62
|
+
// project: { id: offerCatalog.project.id },
|
|
63
|
+
// useInform: false
|
|
64
|
+
// };
|
|
65
|
+
// const syncTask: chevre.factory.task.IAttributes<chevre.factory.taskName.OnResourceUpdated> = {
|
|
66
|
+
// data: syncTaskData,
|
|
67
|
+
// executionResults: [],
|
|
68
|
+
// name: chevre.factory.taskName.OnResourceUpdated,
|
|
69
|
+
// numberOfTried: 0,
|
|
70
|
+
// project: offerCatalog.project,
|
|
71
|
+
// remainingNumberOfTries: 1,
|
|
72
|
+
// runsAt: now,
|
|
73
|
+
// status: chevre.factory.taskStatus.Ready
|
|
74
|
+
// };
|
|
75
|
+
// await taskRepo.saveMany([syncTask], { emitImmediately: false });
|
|
74
76
|
updateCount += 1;
|
|
75
77
|
console.log('task saved.', offerCatalog.project.id, offerCatalog.id, offerCatalog.identifier, i);
|
|
76
78
|
}
|
|
@@ -11,18 +11,19 @@ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPric
|
|
|
11
11
|
id: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
+
type ISearchConditions = factory.unitPriceOffer.ISearchConditions;
|
|
14
15
|
/**
|
|
15
16
|
* 集計オファーリポジトリ
|
|
16
17
|
*/
|
|
17
18
|
export declare class MongoRepository {
|
|
18
19
|
private readonly aggregateOfferModel;
|
|
19
20
|
constructor(connection: Connection);
|
|
20
|
-
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params:
|
|
21
|
+
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: ISearchConditions): IMatchStage[];
|
|
21
22
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
|
|
22
23
|
[field: string]: AnyExpression;
|
|
23
24
|
};
|
|
24
|
-
count(params: Omit<
|
|
25
|
-
search(params:
|
|
25
|
+
count(params: Omit<ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
26
|
+
search(params: ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
|
|
26
27
|
pushIncludedInDataCatalog(params: {
|
|
27
28
|
project: {
|
|
28
29
|
id: string;
|
|
@@ -58,5 +59,20 @@ export declare class MongoRepository {
|
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
61
|
}): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
|
|
64
|
+
*/
|
|
65
|
+
/**
|
|
66
|
+
* カタログに属するサブカタログを全て除外する
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* サブカタログに属するサブカタログを全て除外する
|
|
70
|
+
*/
|
|
71
|
+
deleteById(params: {
|
|
72
|
+
project: {
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
|
75
|
+
id: string;
|
|
76
|
+
}): Promise<void>;
|
|
61
77
|
}
|
|
62
78
|
export {};
|