@chevre/domain 21.13.0-alpha.7 → 21.13.0-alpha.9

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.
Files changed (43) hide show
  1. package/lib/chevre/repo/creativeWork.d.ts +7 -1
  2. package/lib/chevre/repo/creativeWork.js +36 -8
  3. package/lib/chevre/repo/event.d.ts +4 -4
  4. package/lib/chevre/repo/reservation.d.ts +2 -2
  5. package/lib/chevre/service/event.d.ts +3 -0
  6. package/lib/chevre/service/event.js +24 -3
  7. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  8. package/lib/chevre/settings.d.ts +0 -1
  9. package/lib/chevre/settings.js +1 -5
  10. package/package.json +2 -2
  11. package/example/src/chevre/assetTransaction/searchGMOTrade.ts +0 -27
  12. package/example/src/chevre/countDelayedTasks.ts +0 -22
  13. package/example/src/chevre/countDelayedTransactions.ts +0 -60
  14. package/example/src/chevre/countMoneyTransferTransaction.ts +0 -36
  15. package/example/src/chevre/countOffers.ts +0 -32
  16. package/example/src/chevre/createDeleteTransactionTasks.ts +0 -108
  17. package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +0 -98
  18. package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +0 -126
  19. package/example/src/chevre/createManyEventsIfNotExist.ts +0 -365
  20. package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +0 -31
  21. package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +0 -32
  22. package/example/src/chevre/offer/searchAllByIdsAndOfferCatalogId.ts +0 -34
  23. package/example/src/chevre/offer/searchEventTicketOffers.ts +0 -54
  24. package/example/src/chevre/offer/searchOffersByCatalog.ts +0 -40
  25. package/example/src/chevre/processPay.ts +0 -90
  26. package/example/src/chevre/processRegisterMembership.ts +0 -110
  27. package/example/src/chevre/processRegisterPaymentCard.ts +0 -98
  28. package/example/src/chevre/processReserve.ts +0 -114
  29. package/example/src/chevre/publishConfirmationNumber.ts +0 -27
  30. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +0 -56
  31. package/example/src/chevre/reIndex.ts +0 -25
  32. package/example/src/chevre/redisConfig.ts +0 -32
  33. package/example/src/chevre/saveTasks.ts +0 -41
  34. package/example/src/chevre/searchAbortedTasks.ts +0 -34
  35. package/example/src/chevre/searchAcceptedOfferIds.ts +0 -23
  36. package/example/src/chevre/searchOffersFromAggregateOffer.ts +0 -168
  37. package/example/src/chevre/searchOrdersWithUnwoundOffers.ts +0 -35
  38. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +0 -58
  39. package/example/src/chevre/task/executeTasks.ts +0 -26
  40. package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +0 -41
  41. package/example/src/chevre/updateOfferCatalogs.ts +0 -40
  42. package/example/src/chevre/updateTransaction.ts +0 -38
  43. package/example/src/playOnMoment.ts +0 -24
@@ -1,41 +0,0 @@
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
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const taskRepo = new chevre.repository.Task(mongoose.connection);
12
-
13
- const result = await taskRepo.saveMany(
14
- [{
15
- name: chevre.factory.taskName.TriggerWebhook,
16
- runsAt: new Date(),
17
- data: {},
18
- executionResults: [],
19
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
20
- numberOfTried: 0,
21
- remainingNumberOfTries: 1,
22
- status: chevre.factory.taskStatus.Ready
23
- }],
24
- { emitImmediately: false }
25
- );
26
-
27
- console.log(result, 'tasks saved');
28
- }
29
-
30
- main()
31
- .then()
32
- .catch(console.error);
33
- // setInterval(
34
- // () => {
35
- // main()
36
- // .then()
37
- // .catch(console.error);
38
- // },
39
- // // tslint:disable-next-line:no-magic-numbers
40
- // 60000
41
- // );
@@ -1,34 +0,0 @@
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.ConfirmReserveTransaction>[]>await taskRepo.search({
13
- // limit: 100,
14
- // page: 1,
15
- name: {
16
- $in: [chevre.factory.taskName.ConfirmReserveTransaction]
17
- // $nin: [
18
- // chevre.factory.taskName.ImportEventsFromCOA,
19
- // chevre.factory.taskName.ImportEventCapacitiesFromCOA
20
- // ]
21
- },
22
- statuses: [chevre.factory.taskStatus.Aborted],
23
- runsFrom: moment('2023-06-02T22:00:00Z')
24
- .toDate(),
25
- sort: { runsAt: chevre.factory.sortType.Ascending }
26
- });
27
- console.log(tasks.map((task) => `${task.data.object?.transactionNumber}`)
28
- .join('\n'));
29
- console.log(tasks.length);
30
- }
31
-
32
- main()
33
- .then(console.log)
34
- .catch(console.error);
@@ -1,23 +0,0 @@
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
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const orderRepo = new chevre.repository.Order(mongoose.connection);
12
-
13
- const offerIds = await orderRepo.searchAcceptedOfferIds({
14
- project: { id: { $eq: project.id } },
15
- orderNumbers: []
16
- });
17
- console.log('offerIds found', offerIds);
18
- console.log(offerIds.length, 'offerIds found');
19
- }
20
-
21
- main()
22
- .then()
23
- .catch(console.error);
@@ -1,168 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // tslint:disable-next-line:max-func-body-length
7
- async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
-
10
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
-
12
- const offers = await offerRepo.search(
13
- {
14
- limit: 10,
15
- page: 1,
16
- sort: {
17
- 'priceSpecification.price': 1,
18
- identifier: 1
19
- },
20
- project: { id: { $eq: String(process.env.PROJECT_ID) } },
21
- availability: { $eq: chevre.factory.itemAvailability.InStock },
22
- itemOffered: {
23
- typeOf: {
24
- // $eq: chevre.factory.product.ProductType.EventService
25
- }
26
- },
27
- addOn: {
28
- itemOffered: {
29
- /**
30
- * アドオンプロダクトID
31
- */
32
- id: {
33
- // $eq: ''
34
- }
35
- }
36
- },
37
- availableAtOrFrom: {
38
- id: {
39
- // $eq: ''
40
- // $in: string[]
41
- }
42
- },
43
- eligibleMembershipType: {
44
- /**
45
- * 適用メンバーシップ区分
46
- */
47
- codeValue: {
48
- // $eq: 'Permit'
49
- }
50
- },
51
- eligibleMonetaryAmount: {
52
- /**
53
- * 適用通貨区分
54
- */
55
- currency: {
56
- // $eq: 'Point'
57
- }
58
- },
59
- eligibleSeatingType: {
60
- /**
61
- * 適用座席区分
62
- */
63
- codeValue: {
64
- // $eq: ''
65
- }
66
- },
67
- hasMerchantReturnPolicy: {
68
- id: {
69
- // $eq: ''
70
- }
71
- },
72
- // parentOffer: { id: { $in: ['901'] } },
73
- id: {
74
- // $eq: '901'
75
- // $in: string[];
76
- },
77
- identifier: {
78
- // $eq: '1001'
79
- // $in: string[];
80
- // $regex: '003'
81
- },
82
- name: {
83
- // $regex: ''
84
- },
85
- priceSpecification: {
86
- appliesToMovieTicket: {
87
- /**
88
- * 適用決済カード区分
89
- */
90
- serviceType: {
91
- /**
92
- * 適用決済カード区分が存在するかどうか
93
- */
94
- // $exists: boolean;
95
- // $eq: '01'
96
- },
97
- serviceOutput: {
98
- /**
99
- * 適用決済方法タイプ
100
- */
101
- typeOf: {
102
- // $eq: ''
103
- // $nin: string[];
104
- }
105
- }
106
- },
107
- price: {
108
- // $gte: 2000,
109
- // $lte: 2000
110
- },
111
- referenceQuantity: {
112
- value: {
113
- // $eq: 2
114
- }
115
- },
116
- accounting: {
117
- accountsReceivable: {
118
- // $gte: 1800,
119
- // $lte: 100
120
- },
121
- operatingRevenue: {
122
- codeValue: {
123
- // $eq: ''
124
- // $in: string[];
125
- }
126
- }
127
- }
128
- },
129
- category: {
130
- codeValue: {
131
- // $in: ['1']
132
- }
133
- }
134
- /**
135
- * 有効期間設定がない、あるいは、有効期間内
136
- */
137
- // onlyValid: true
138
- // additionalProperty: {
139
- // $all: [
140
- // {
141
- // $elemMatch: {
142
- // name: { $eq: 'nameForPrinting' },
143
- // value: { $in: ['General'] }
144
- // }
145
- // }
146
- // ]
147
- // }
148
- },
149
- {
150
- id: 1,
151
- identifier: 1,
152
- name: 1,
153
- alternateName: 1,
154
- priceSpecification: 1,
155
- project: 1
156
- }
157
- );
158
- console.log(offers);
159
- console.log(offers.map((offer) => {
160
- return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id}`;
161
- }));
162
- console.log(offers.length);
163
- console.log('USE_AGGREGATE_OFFERS_AS_PRIMARY:', process.env.USE_AGGREGATE_OFFERS_AS_PRIMARY);
164
- }
165
-
166
- main()
167
- .then(console.log)
168
- .catch(console.error);
@@ -1,35 +0,0 @@
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
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const orderRepo = new chevre.repository.Order(mongoose.connection);
12
-
13
- // const orders = await orderRepo.search({
14
- const orders = await orderRepo.searchWithUnwoundAcceptedOffer(
15
- {
16
- sort: { orderDate: -1 },
17
- limit: 2,
18
- page: 1,
19
- project: { id: { $eq: project.id } },
20
- acceptedOffers: {
21
- itemOffered: {
22
- // ids: ['xxx'],
23
- }
24
- }
25
- // orderNumbers: ['xxx']
26
- },
27
- { _id: 0, acceptedOffers: 1, orderNumber: 1, orderDate: 1 });
28
- console.log('orders found', orders);
29
- console.log(orders.length, 'orders found');
30
- console.log(orders.map((o) => `${o.orderNumber} ${o.orderDate}`));
31
- }
32
-
33
- main()
34
- .then()
35
- .catch(console.error);
@@ -1,58 +0,0 @@
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 orderNumbers = ['TTT9-4703865-8892744', 'TTT9-4703865-8398074', 'SSK6-4815238-3010844'];
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
-
12
- const orderRepo = new chevre.repository.Order(mongoose.connection);
13
-
14
- const reservatioForIds = await orderRepo.searchReservationForIdsByOrderNumbers({
15
- orderNumber: { $in: orderNumbers }
16
- });
17
- console.log('reservatioForIds found', reservatioForIds);
18
- console.log(reservatioForIds.length, 'reservatioForIds found');
19
-
20
- const reservationNumbers = await orderRepo.searchReservationNumbersByOrderNumbers({
21
- orderNumber: { $in: orderNumbers }
22
- });
23
- console.log('reservationNumbers found', reservationNumbers);
24
- console.log(reservationNumbers.length, 'reservationNumbers found');
25
-
26
- const offers = await orderRepo.searchAcceptedOffersByOrderNumbers({
27
- orderNumber: { $in: orderNumbers }
28
- });
29
- console.log('offers found', offers);
30
- console.log(offers.length, 'offers found');
31
-
32
- const movieTickets: any[] = [];
33
- offers.forEach((offer) => {
34
- const movieTicketTypeChargeSpecExists = offer.priceSpecification.priceComponent.some((component) => {
35
- return component.typeOf === chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
36
- });
37
- if (movieTicketTypeChargeSpecExists) {
38
- offer.priceSpecification.priceComponent.forEach((component) => {
39
- if (component.typeOf === chevre.factory.priceSpecificationType.UnitPriceSpecification) {
40
- if (Array.isArray(component.appliesToMovieTicket)) {
41
- component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
42
- movieTickets.push({
43
- identifier: appliesToMovieTicket.identifier,
44
- paymentMethodType: appliesToMovieTicket.serviceOutput.typeOf,
45
- offerId: offer.id
46
- });
47
- });
48
- }
49
- }
50
- });
51
- }
52
- });
53
- console.log('movieTickets found', movieTickets);
54
- }
55
-
56
- main()
57
- .then()
58
- .catch(console.error);
@@ -1,26 +0,0 @@
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 taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
10
- const result = await taskRepo.executeTasks({
11
- now: new Date(),
12
- delayInSeconds: 60,
13
- limit: 1,
14
- name: {
15
- $nin: [
16
- chevre.factory.taskName.ImportEventCapacitiesFromCOA,
17
- chevre.factory.taskName.ImportEventsFromCOA
18
- ]
19
- }
20
- });
21
- console.log(result);
22
- }
23
-
24
- main()
25
- .then(console.log)
26
- .catch(console.error);
@@ -1,41 +0,0 @@
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
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const placeRepo = await chevre.repository.Place.createInstance(mongoose.connection);
12
-
13
- const cursor = placeRepo.getCursor(
14
- {
15
- typeOf: { $eq: chevre.factory.placeType.MovieTheater }
16
- },
17
- {
18
- _id: 1,
19
- name: 1,
20
- project: 1,
21
- typeOf: 1
22
- }
23
- );
24
- console.log('places found');
25
-
26
- let i = 0;
27
- await cursor.eachAsync(async (doc) => {
28
- i += 1;
29
- const { id, name, project, typeOf } = <Pick<chevre.factory.place.movieTheater.IPlace, 'id' | 'name' | 'project' | 'typeOf'>>
30
- doc.toObject();
31
-
32
- console.log('unset processing...', project.id, typeOf, id, name.ja, i);
33
- const result = await placeRepo.unsetContainsPlaceFromMovieTheater({ id });
34
- console.log('unset processed.', project.id, typeOf, id, name.ja, result?.id, i);
35
- });
36
-
37
- }
38
-
39
- main()
40
- .then(console.log)
41
- .catch(console.error);
@@ -1,40 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
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);
8
-
9
- const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
10
-
11
- await offerCatalogRepo.updateManyById({
12
- id: { $in: ['0002'] },
13
- $pull: {
14
- itemListElement: {
15
- $elemMatch: {
16
- id: {
17
- $in: [
18
- // 'al96nqj7z',
19
- // 'akxecjgeu'
20
- ]
21
- }
22
- }
23
- }
24
- },
25
- $push: {
26
- itemListElement: {
27
- $each: [
28
- { typeOf: chevre.factory.offerType.Offer, id: 'al96nqj7z' },
29
- { typeOf: chevre.factory.offerType.Offer, id: 'akxecjgeu' }
30
- ],
31
- $slice: 200
32
- }
33
- }
34
- });
35
- console.log('updated');
36
- }
37
-
38
- main()
39
- .then(console.log)
40
- .catch(console.error);
@@ -1,38 +0,0 @@
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);
9
-
10
- const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
11
- const transactionId = '63ce4d501c45c2000bdb2f9d';
12
- let update = {
13
- $set: { 'object.modifiedTime': new Date() }
14
- };
15
-
16
- let now = moment();
17
- await transactionRepo.findByIdAndUpdateInProgress({
18
- id: transactionId,
19
- update
20
- });
21
- console.log(moment()
22
- .diff(now));
23
-
24
- update = {
25
- $set: { 'object.modifiedTime': new Date() }
26
- };
27
- now = moment();
28
- // await transactionRepo.updateById({
29
- // id: transactionId,
30
- // update
31
- // });
32
- console.log(moment()
33
- .diff(now));
34
- }
35
-
36
- main()
37
- .then()
38
- .catch(console.error);
@@ -1,24 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment-timezone';
3
-
4
- const startDate = moment('2023-05-27T00:00:00Z')
5
- .toDate();
6
- const gracePeriodBeforeStartInDaysMin = {
7
- timezone: 'Asia/Tokyo',
8
- time: '09:38:00',
9
- period: { value: 3 }
10
- };
11
- const returningDate = new Date();
12
-
13
- const minDate: string = moment(startDate)
14
- .tz(gracePeriodBeforeStartInDaysMin.timezone)
15
- .startOf('days')
16
- .subtract(gracePeriodBeforeStartInDaysMin.period.value, 'days')
17
- .format('YYYY-MM-DD');
18
- console.log('minDate:', minDate);
19
-
20
- const returnMaxDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`)
21
- .tz(gracePeriodBeforeStartInDaysMin.timezone);
22
- console.log(returnMaxDate);
23
-
24
- console.log(returnMaxDate.isSameOrAfter(moment(returningDate)));