@chevre/domain 22.6.0-alpha.3 → 22.6.0-alpha.30

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 (86) hide show
  1. package/example/src/chevre/aggregateAllEvents2.ts +0 -3
  2. package/example/src/chevre/aggregation/aggregateOrderOnSystem.ts +40 -0
  3. package/example/src/chevre/aggregation/aggregateSystem.ts +16 -0
  4. package/example/src/chevre/createEventBySchedule.ts +69 -0
  5. package/example/src/chevre/findInterface.ts +45 -0
  6. package/example/src/chevre/findSchedule.ts +43 -0
  7. package/example/src/chevre/projectEventFieldsById.ts +23 -0
  8. package/example/src/chevre/reIndex.ts +24 -0
  9. package/example/src/chevre/retryTasks.ts +6 -4
  10. package/example/src/chevre/unsetUnnecessaryFields.ts +34 -16
  11. package/lib/chevre/credentials.js +0 -13
  12. package/lib/chevre/repo/action.d.ts +11 -5
  13. package/lib/chevre/repo/credentials.d.ts +19 -0
  14. package/lib/chevre/repo/credentials.js +66 -0
  15. package/lib/chevre/repo/event.d.ts +0 -5
  16. package/lib/chevre/repo/event.js +0 -26
  17. package/lib/chevre/repo/interface.d.ts +25 -0
  18. package/lib/chevre/repo/interface.js +62 -0
  19. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +5 -21
  20. package/lib/chevre/repo/mongoose/schemas/aggregation.js +12 -0
  21. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +36 -11
  22. package/lib/chevre/repo/mongoose/schemas/civicStructure.js +9 -1
  23. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +9 -1
  24. package/lib/chevre/repo/mongoose/schemas/interface.d.ts +11 -0
  25. package/lib/chevre/repo/mongoose/schemas/interface.js +55 -0
  26. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +1 -1
  27. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +29 -25
  28. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -1
  29. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +21 -15
  30. package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
  31. package/lib/chevre/repo/mongoose/schemas/schedule.d.ts +10 -0
  32. package/lib/chevre/repo/mongoose/schemas/schedule.js +51 -0
  33. package/lib/chevre/repo/offerCatalog.d.ts +5 -1
  34. package/lib/chevre/repo/offerCatalog.js +6 -0
  35. package/lib/chevre/repo/offerCatalogItem.d.ts +5 -1
  36. package/lib/chevre/repo/offerCatalogItem.js +6 -0
  37. package/lib/chevre/repo/place/movieTheater.d.ts +0 -6
  38. package/lib/chevre/repo/place/movieTheater.js +0 -14
  39. package/lib/chevre/repo/schedule.d.ts +22 -0
  40. package/lib/chevre/repo/schedule.js +54 -0
  41. package/lib/chevre/repository.d.ts +10 -0
  42. package/lib/chevre/repository.js +28 -2
  43. package/lib/chevre/service/aggregation/event/aggregateOffers.js +44 -29
  44. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +10 -4
  45. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +17 -9
  46. package/lib/chevre/service/aggregation/system.d.ts +18 -71
  47. package/lib/chevre/service/aggregation/system.js +60 -15
  48. package/lib/chevre/service/event.d.ts +1 -2
  49. package/lib/chevre/service/event.js +1 -3
  50. package/lib/chevre/service/reserve/checkInReservation.d.ts +0 -6
  51. package/lib/chevre/service/reserve/checkInReservation.js +7 -24
  52. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -1
  53. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -10
  54. package/lib/chevre/service/reserve/useReservation.js +3 -3
  55. package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
  56. package/lib/chevre/service/task/acceptCOAOffer.js +27 -4
  57. package/lib/chevre/service/task/aggregateOnSystem.js +4 -4
  58. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +1 -1
  59. package/lib/chevre/service/task/confirmReserveTransaction.js +20 -6
  60. package/lib/chevre/service/task/createEvent/createEvent.d.ts +24 -0
  61. package/lib/chevre/service/task/createEvent/createEvent.js +43 -0
  62. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +24 -0
  63. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +364 -0
  64. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +13 -0
  65. package/lib/chevre/service/{event/createEvent.js → task/createEvent/createEventSeries.js} +4 -4
  66. package/lib/chevre/service/task/createEvent.js +14 -4
  67. package/lib/chevre/service/task/handleNotification.js +4 -3
  68. package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +2 -2
  69. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +14 -5
  70. package/lib/chevre/service/task/importEventsFromCOA.d.ts +2 -2
  71. package/lib/chevre/service/task/importEventsFromCOA.js +14 -5
  72. package/lib/chevre/service/task/importOffersFromCOA.d.ts +2 -2
  73. package/lib/chevre/service/task/importOffersFromCOA.js +15 -6
  74. package/lib/chevre/service/task/onAuthorizationCreated.js +9 -25
  75. package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
  76. package/lib/chevre/service/task/returnReserveTransaction.js +21 -7
  77. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  78. package/lib/chevre/service/task/voidReserveTransaction.js +19 -6
  79. package/lib/chevre/service/task.d.ts +0 -5
  80. package/lib/chevre/service/task.js +6 -0
  81. package/lib/chevre/settings/aggregation.d.ts +4 -2
  82. package/lib/chevre/settings/aggregation.js +1 -4
  83. package/lib/chevre/settings.d.ts +2 -0
  84. package/lib/chevre/settings.js +2 -1
  85. package/package.json +4 -4
  86. package/lib/chevre/service/event/createEvent.d.ts +0 -13
@@ -64,9 +64,6 @@ export async function aggregateScreeningEvent() {
64
64
  },
65
65
  userPoolIdOld: '',
66
66
  userPoolIdNew: '',
67
- // useAggregateEntranceGateProjects: [],
68
- // useAggregateOfferProjects: [],
69
- // useOfferRateLimitProjects: [],
70
67
  defaultSenderEmail: 'test@example.com',
71
68
  deliverOrderLimit: 1,
72
69
  transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
@@ -0,0 +1,40 @@
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
+ const EXCLUDED_PROJECT_ID = String(process.env.EXCLUDED_PROJECT_ID);
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
13
+
14
+ const aggregateDate = new Date('2024-11-03T10:00:00+09:00');
15
+ const aggregateDurationUnit = 'days';
16
+ // const aggregateDurationUnit = 'hours';
17
+ const startFrom: Date = moment(aggregateDate)
18
+ .utc()
19
+ .startOf(aggregateDurationUnit)
20
+ .toDate();
21
+ const startThrough: Date = moment(aggregateDate)
22
+ .utc()
23
+ .endOf(aggregateDurationUnit)
24
+ .toDate();
25
+
26
+ const startTime = process.hrtime();
27
+ const aggregateResult = await orderRepo.aggregateOrder({
28
+ project: { id: { $ne: EXCLUDED_PROJECT_ID } },
29
+ orderDate: { $gte: startFrom, $lte: startThrough }
30
+ });
31
+ console.log('aggregateOrder:result', aggregateResult, startFrom, startThrough);
32
+ const diff = process.hrtime(startTime);
33
+ console.log(`importing chevre took ${diff[0]} seconds and ${diff[1]} nanoseconds.`);
34
+ }
35
+
36
+ main()
37
+ .then(() => {
38
+ console.log('success!');
39
+ })
40
+ .catch(console.error);
@@ -22,9 +22,11 @@ async function main() {
22
22
  const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
23
23
  const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
24
24
 
25
+ const aggregateDate = new Date();
25
26
  let result: { aggregationCount: number; aggregateDuration: string };
26
27
 
27
28
  result = await (await chevre.service.aggregation.createService()).system.aggregateOrder({
29
+ aggregateDate,
28
30
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
29
31
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
30
32
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -36,6 +38,7 @@ async function main() {
36
38
  // return;
37
39
 
38
40
  result = await (await chevre.service.aggregation.createService()).system.aggregatePlaceOrder({
41
+ aggregateDate,
39
42
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
40
43
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
41
44
  excludedProjectId: EXCLUDED_PROJECT_ID,
@@ -48,6 +51,7 @@ async function main() {
48
51
  // return;
49
52
 
50
53
  result = await (await chevre.service.aggregation.createService()).system.aggregateReserveAction({
54
+ aggregateDate,
51
55
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
52
56
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
53
57
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -58,6 +62,7 @@ async function main() {
58
62
  console.log('aggregateReserveAction processed.', result);
59
63
 
60
64
  result = await (await chevre.service.aggregation.createService()).system.aggregateOrderAction({
65
+ aggregateDate,
61
66
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
62
67
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
63
68
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -68,6 +73,7 @@ async function main() {
68
73
  console.log('aggregateReserveAction processed.', result);
69
74
 
70
75
  result = await (await chevre.service.aggregation.createService()).system.aggregateCancelReservationAction({
76
+ aggregateDate,
71
77
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
72
78
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
73
79
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -78,6 +84,7 @@ async function main() {
78
84
  console.log('aggregateCancelReservationAction processed.', result);
79
85
 
80
86
  result = await (await chevre.service.aggregation.createService()).system.aggregateTask({
87
+ aggregateDate,
81
88
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
82
89
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
83
90
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -88,6 +95,7 @@ async function main() {
88
95
  console.log('aggregateTask processed.', result);
89
96
 
90
97
  result = await (await chevre.service.aggregation.createService()).system.aggregatePayMovieTicketAction({
98
+ aggregateDate,
91
99
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
92
100
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
93
101
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -98,6 +106,7 @@ async function main() {
98
106
  console.log('aggregatePayMovieTicketAction processed.', result);
99
107
 
100
108
  result = await (await chevre.service.aggregation.createService()).system.aggregatePayTransaction({
109
+ aggregateDate,
101
110
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
102
111
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
103
112
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -108,6 +117,7 @@ async function main() {
108
117
  console.log('aggregatePayTransaction processed.', result);
109
118
 
110
119
  result = await (await chevre.service.aggregation.createService()).system.aggregateEvent({
120
+ aggregateDate,
111
121
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
112
122
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
113
123
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -118,6 +128,7 @@ async function main() {
118
128
  console.log('aggregateEvent processed.', result);
119
129
 
120
130
  result = await (await chevre.service.aggregation.createService()).system.aggregateReserveTransaction({
131
+ aggregateDate,
121
132
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
122
133
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
123
134
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -128,6 +139,7 @@ async function main() {
128
139
  console.log('aggregateReserveTransaction processed.', result);
129
140
 
130
141
  result = await (await chevre.service.aggregation.createService()).system.aggregateAuthorizeOrderAction({
142
+ aggregateDate,
131
143
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
132
144
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
133
145
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -138,6 +150,7 @@ async function main() {
138
150
  console.log('aggregateAuthorizeOrderAction processed.', result);
139
151
 
140
152
  result = await (await chevre.service.aggregation.createService()).system.aggregateAuthorizeEventServiceOfferAction({
153
+ aggregateDate,
141
154
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
142
155
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
143
156
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -148,6 +161,7 @@ async function main() {
148
161
  console.log('aggregateAuthorizeEventServiceOfferAction processed.', result);
149
162
 
150
163
  result = await (await chevre.service.aggregation.createService()).system.aggregateAuthorizePaymentAction({
164
+ aggregateDate,
151
165
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
152
166
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
153
167
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -158,6 +172,7 @@ async function main() {
158
172
  console.log('aggregateAuthorizePaymentAction processed.', result);
159
173
 
160
174
  result = await (await chevre.service.aggregation.createService()).system.aggregateUseAction({
175
+ aggregateDate,
161
176
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
162
177
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
163
178
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -168,6 +183,7 @@ async function main() {
168
183
  console.log('aggregateUseAction processed.', result);
169
184
 
170
185
  result = await (await chevre.service.aggregation.createService()).system.aggregateCheckMovieTicketAction({
186
+ aggregateDate,
171
187
  aggregateDurationUnit: AGGREGATE_DURATION_UNIT,
172
188
  aggregationCount: (AGGREGATE_DURATION_UNIT === 'hours') ? AGGREGATE_DAYS * ONE_DAY_IN_HOURS : AGGREGATE_DAYS,
173
189
  excludedProjectId: EXCLUDED_PROJECT_ID
@@ -0,0 +1,69 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import { call } from '../../../lib/chevre/service/task/createEvent';
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
+ await call({
12
+ agent: { id: 'sample', typeOf: chevre.factory.creativeWorkType.WebApplication },
13
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
14
+ object: {
15
+ typeOf: chevre.factory.eventType.ScreeningEvent,
16
+ eventSchedule: { id: '672bf38b5d6d3f5642d658fc' }
17
+ },
18
+ // targetCollection: {},
19
+ typeOf: chevre.factory.actionType.CreateAction
20
+ })(
21
+ {
22
+ connection: mongoose.connection,
23
+ credentials: {
24
+ sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
25
+ },
26
+ settings: new chevre.settings.Settings({
27
+ onEventChanged: {
28
+ informEvent: []
29
+ },
30
+ onOrderStatusChanged: {
31
+ informOrder: []
32
+ },
33
+ onResourceUpdated: {
34
+ informResource: []
35
+ },
36
+ onReservationStatusChanged: {
37
+ informReservation: []
38
+ },
39
+ notification: {
40
+ timeout: 1000,
41
+ useFetchAPI: true,
42
+ secretKey: 'xx',
43
+ headerIdentifier: 'xx'
44
+ },
45
+ userPoolIdOld: '',
46
+ userPoolIdNew: '',
47
+ defaultSenderEmail: 'test@example.com',
48
+ deliverOrderLimit: 1,
49
+ transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
50
+ abortedTasksWithoutReport: [],
51
+ coa: { timeout: 1000 },
52
+ gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
53
+ movieticketReserve: { timeout: 1000, timeoutCheck: 1000, minIntervalBetweenPayAndRefund: 0 },
54
+ numTryConfirmReserveTransaction: 10,
55
+ useAssetTransactionSyncProcessing: true,
56
+ useExperimentalFeature: false
57
+ })
58
+ },
59
+ {
60
+ executeById: true,
61
+ executeByName: false
62
+ }
63
+ );
64
+ console.log('success!');
65
+ }
66
+
67
+ main()
68
+ .then(console.log)
69
+ .catch(console.error);
@@ -0,0 +1,45 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const { COA_ENDPOINT, COA_REFRESH_TOKEN } = process.env;
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const interfaceRepo = await chevre.repository.Interface.createInstance(mongoose.connection);
11
+
12
+ const findOneIdResult = await interfaceRepo.findOneId();
13
+ // tslint:disable-next-line:no-null-keyword
14
+ console.dir(findOneIdResult, { depth: null });
15
+
16
+ const result = await interfaceRepo.findOne({});
17
+ // tslint:disable-next-line:no-null-keyword
18
+ console.dir(result, { depth: null });
19
+
20
+ if (findOneIdResult === null) {
21
+ if (typeof COA_ENDPOINT === 'string' && typeof COA_REFRESH_TOKEN === 'string') {
22
+ // await interfaceRepo.saveOne({
23
+ // project: { id: 'xxx', typeOf: chevre.factory.organizationType.Project },
24
+ // availableChannel: {
25
+ // typeOf: 'ServiceChannel',
26
+ // credentials: {
27
+ // endpoint: COA_ENDPOINT,
28
+ // refreshToken: COA_REFRESH_TOKEN,
29
+ // useFetch: true
30
+ // },
31
+ // importEventsInWeeks: 5,
32
+ // excludeMovieTheaters: [
33
+ // '007'
34
+ // ]
35
+ // },
36
+ // typeOf: 'WebAPI'
37
+ // });
38
+ // console.log('saved');
39
+ }
40
+ }
41
+ }
42
+
43
+ main()
44
+ .then(console.log)
45
+ .catch(console.error);
@@ -0,0 +1,43 @@
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 scheduleRepo = await chevre.repository.Schedule.createInstance(mongoose.connection);
10
+
11
+ const findOneIdResult = await scheduleRepo.findOneId();
12
+ // tslint:disable-next-line:no-null-keyword
13
+ console.dir(findOneIdResult, { depth: null });
14
+
15
+ const result = await scheduleRepo.findOne({ id: { $eq: '672bf38b5d6d3f5642d658fc' } });
16
+ // tslint:disable-next-line:no-null-keyword
17
+ console.dir(result, { depth: null });
18
+
19
+ if (result === null) {
20
+ // await scheduleRepo.saveOne({
21
+ // project: { id: 'ttts-test', typeOf: chevre.factory.organizationType.Project },
22
+ // film: '001',
23
+ // theater: '001',
24
+ // eventServiceProductID: 'EventService8k7nv3w4b',
25
+ // duration: 15,
26
+ // noPerformanceTimes: [
27
+ // '2215',
28
+ // '2230',
29
+ // '2245'
30
+ // ],
31
+ // hours: ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'],
32
+ // minutes: ['00', '15', '30', '45'],
33
+ // tours: ['1', '2', '3', '4'],
34
+ // start: 91,
35
+ // days: 1
36
+ // });
37
+ // console.log('saved');
38
+ }
39
+ }
40
+
41
+ main()
42
+ .then(console.log)
43
+ .catch(console.error);
@@ -0,0 +1,23 @@
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
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
+
13
+ const doc = await eventRepo.projectEventFieldsById(
14
+ { id: 'blzoa1w8g' },
15
+ ['location', 'project', 'startDate', 'typeOf', 'superEvent.id', 'superEvent.location.id', 'offers.itemOffered']
16
+ );
17
+ // tslint:disable-next-line:no-null-keyword
18
+ console.dir(doc, { depth: null });
19
+ }
20
+
21
+ main()
22
+ .then(console.log)
23
+ .catch(console.error);
@@ -0,0 +1,24 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ mongoose.Model.on('index', (...args) => {
7
+ console.error('******** index event emitted. ********\n', args);
8
+ });
9
+ // const project = { id: String(process.env.PROJECT_ID) };
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ await chevre.repository.CategoryCode.createInstance(mongoose.connection);
15
+ await chevre.repository.CreativeWork.createInstance(mongoose.connection);
16
+ await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
17
+ await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
18
+ await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
19
+ console.log('success!');
20
+ }
21
+
22
+ main()
23
+ .then()
24
+ .catch(console.error);
@@ -12,19 +12,21 @@ async function main() {
12
12
  const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
13
13
  const result = await taskRepo.taskModel.updateMany(
14
14
  {
15
+ // _id: { $eq: '673b5f8f5735a0a2dc953cfc' },
16
+ 'project.id': { $eq: project.id },
15
17
  status: { $eq: chevre.factory.taskStatus.Aborted },
16
18
  lastTriedAt: {
17
19
  $gt: moment()
18
- .add(-1, 'day')
20
+ // tslint:disable-next-line:no-magic-numbers
21
+ .add(-2, 'days')
19
22
  .toDate()
20
23
  },
21
- name: { $eq: chevre.factory.taskName.TriggerWebhook },
22
- 'project.id': { $eq: project.id }
24
+ name: { $eq: chevre.factory.taskName.VoidPayment }
23
25
  },
24
26
  {
25
27
  $set: {
26
28
  status: chevre.factory.taskStatus.Ready,
27
- remainingNumberOfTries: 20
29
+ remainingNumberOfTries: 3
28
30
  }
29
31
  }
30
32
  )
@@ -1,33 +1,51 @@
1
1
  // tslint:disable:no-console
2
- import * as moment from 'moment';
2
+ // import * as moment from 'moment';
3
3
  import * as mongoose from 'mongoose';
4
4
 
5
5
  import { chevre } from '../../../lib/index';
6
6
 
7
- const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
7
+ // const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
8
 
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
+ const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
13
+ const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
14
+ const offerCatalogItemRepo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
13
15
 
14
16
  let updateResult: any;
15
- updateResult = await eventRepo.unsetUnnecessaryFields({
17
+ updateResult = await aggregateOfferRepo.unsetUnnecessaryFields({
16
18
  filter: {
17
- 'project.id': { $ne: excludedProject.id },
18
- 'offers.validFrom': { $exists: true },
19
- startDate: {
20
- $gte: moment()
21
- .add(-1, 'days')
22
- .toDate()
23
- }
24
- // _id: { $eq: 'blxd1grz3' }
19
+ _id: { $exists: true }
25
20
  },
26
21
  $unset: <any>{
27
- 'offers.availabilityEnds': 1,
28
- 'offers.availabilityStarts': 1,
29
- 'offers.validFrom': 1,
30
- 'offers.validThrough': 1
22
+ createdAt: 1,
23
+ updatedAt: 1,
24
+ __v: 1
25
+ }
26
+ });
27
+ console.log(updateResult);
28
+
29
+ updateResult = await offerCatalogRepo.unsetUnnecessaryFields({
30
+ filter: {
31
+ _id: { $exists: true }
32
+ },
33
+ $unset: <any>{
34
+ createdAt: 1,
35
+ updatedAt: 1,
36
+ __v: 1
37
+ }
38
+ });
39
+ console.log(updateResult);
40
+
41
+ updateResult = await offerCatalogItemRepo.unsetUnnecessaryFields({
42
+ filter: {
43
+ _id: { $exists: true }
44
+ },
45
+ $unset: <any>{
46
+ createdAt: 1,
47
+ updatedAt: 1,
48
+ __v: 1
31
49
  }
32
50
  });
33
51
  console.log(updateResult);
@@ -15,19 +15,6 @@ exports.credentials = void 0;
15
15
  */
16
16
  var credentials;
17
17
  (function (credentials) {
18
- // export const customSearch = {
19
- // engineId: <string>process.env.CUSTOM_SEARCH_ENGINE_ID,
20
- // apiKey: <string>process.env.GOOGLE_API_KEY
21
- // };
22
- // export const lineNotify = {
23
- // url: process.env.LINE_NOTIFY_URL,
24
- // accessToken: process.env.LINE_NOTIFY_ACCESS_TOKEN,
25
- // accessTokenAlert: process.env.LINE_NOTIFY_ACCESS_TOKEN_ALERT,
26
- // accessTokenInfo: process.env.LINE_NOTIFY_ACCESS_TOKEN_INFO
27
- // };
28
- // export const sendGrid = {
29
- // apiKey: process.env.SENDGRID_API_KEY
30
- // };
31
18
  let CustomSearch;
32
19
  (function (CustomSearch) {
33
20
  let cred;
@@ -29,7 +29,13 @@ export type IAction4transaction<T extends factory.actionType.AcceptAction | fact
29
29
  export type IAction<T extends factory.actionType> = T extends factory.actionType.OrderAction ? factory.action.trade.order.IAction : T extends factory.actionType.AcceptAction ? IAction4transaction<factory.actionType.AcceptAction> : T extends factory.actionType.AuthorizeAction ? factory.action.authorize.IAction<factory.action.authorize.IAttributes<any, any>> : T extends factory.actionType.CheckAction ? (factory.action.check.paymentMethod.movieTicket.IAction | factory.action.check.token.IAction) : T extends factory.actionType.MoneyTransfer ? factory.action.transfer.moneyTransfer.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction<factory.action.update.replace.IAttributes<any, any>> : factory.action.IAction<factory.action.IAttributes<T, any, any>>;
30
30
  export type IPayAction = factory.action.trade.pay.IAction;
31
31
  export interface IUseActionCountByOffer {
32
- _id: string[];
32
+ /**
33
+ * 単価オファーID
34
+ */
35
+ _id: [string];
36
+ /**
37
+ * 使用アクション数
38
+ */
33
39
  useActionCount?: number;
34
40
  }
35
41
  interface IAggregationByStatus {
@@ -379,6 +385,7 @@ export declare class ActionRepo {
379
385
  agent: import("@chevre/factory/lib/action").IParticipant;
380
386
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
381
387
  typeOf: factory.actionType;
388
+ targetCollection?: any;
382
389
  potentialActions?: any;
383
390
  instrument?: any;
384
391
  recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
@@ -392,7 +399,6 @@ export declare class ActionRepo {
392
399
  fromLocation?: any;
393
400
  toLocation?: any;
394
401
  replacer?: any;
395
- targetCollection?: any;
396
402
  cancelAction?: any;
397
403
  actionStatus: factory.actionStatusType;
398
404
  }> & {
@@ -402,6 +408,7 @@ export declare class ActionRepo {
402
408
  agent: import("@chevre/factory/lib/action").IParticipant;
403
409
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
404
410
  typeOf: factory.actionType;
411
+ targetCollection?: any;
405
412
  potentialActions?: any;
406
413
  instrument?: any;
407
414
  recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
@@ -415,7 +422,6 @@ export declare class ActionRepo {
415
422
  fromLocation?: any;
416
423
  toLocation?: any;
417
424
  replacer?: any;
418
- targetCollection?: any;
419
425
  cancelAction?: any;
420
426
  actionStatus: factory.actionStatusType;
421
427
  } & {
@@ -427,6 +433,7 @@ export declare class ActionRepo {
427
433
  agent: import("@chevre/factory/lib/action").IParticipant;
428
434
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
429
435
  typeOf: factory.actionType;
436
+ targetCollection?: any;
430
437
  potentialActions?: any;
431
438
  instrument?: any;
432
439
  recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
@@ -440,7 +447,6 @@ export declare class ActionRepo {
440
447
  fromLocation?: any;
441
448
  toLocation?: any;
442
449
  replacer?: any;
443
- targetCollection?: any;
444
450
  cancelAction?: any;
445
451
  actionStatus: factory.actionStatusType;
446
452
  }> & {
@@ -450,6 +456,7 @@ export declare class ActionRepo {
450
456
  agent: import("@chevre/factory/lib/action").IParticipant;
451
457
  purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
452
458
  typeOf: factory.actionType;
459
+ targetCollection?: any;
453
460
  potentialActions?: any;
454
461
  instrument?: any;
455
462
  recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
@@ -463,7 +470,6 @@ export declare class ActionRepo {
463
470
  fromLocation?: any;
464
471
  toLocation?: any;
465
472
  replacer?: any;
466
- targetCollection?: any;
467
473
  cancelAction?: any;
468
474
  actionStatus: factory.actionStatusType;
469
475
  } & {
@@ -0,0 +1,19 @@
1
+ import type * as COA from '@motionpicture/coa-service';
2
+ import type { RedisClientType } from 'redis';
3
+ interface IOptions {
4
+ scope: string;
5
+ expireInSeconds: number;
6
+ }
7
+ /**
8
+ * 認証情報リポジトリ
9
+ */
10
+ export declare class CredentialsRepo implements COA.auth.repo.credentials.AbstractCredentialsRepo {
11
+ static KEY_PREFIX: string;
12
+ private readonly redisClient;
13
+ private readonly options;
14
+ constructor(redisClient: RedisClientType, options: IOptions);
15
+ save(credentials: COA.auth.repo.credentials.ISaveParams): Promise<void>;
16
+ find(): Promise<COA.auth.repo.credentials.IFindResult>;
17
+ private createKey;
18
+ }
19
+ export {};
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CredentialsRepo = void 0;
13
+ /**
14
+ * 認証情報リポジトリ
15
+ */
16
+ class CredentialsRepo {
17
+ constructor(redisClient, options) {
18
+ this.redisClient = redisClient;
19
+ this.options = options;
20
+ }
21
+ save(credentials) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const { access_token, expired_at } = credentials;
24
+ if (typeof credentials.access_token !== 'string') {
25
+ throw new Error('access_token must be string');
26
+ }
27
+ if (typeof credentials.expired_at !== 'string') {
28
+ throw new Error('expired_at must be string');
29
+ }
30
+ const key = this.createKey();
31
+ const value = JSON.stringify({ access_token, expired_at });
32
+ const multi = this.redisClient.multi();
33
+ yield multi.set(key, value)
34
+ // .expireAt(key, Number(expired_at))
35
+ .expire(key, this.options.expireInSeconds)
36
+ .exec();
37
+ // if (Array.isArray(results) && (results[0] === 1 || (<any>results)[0] === true)) {
38
+ // return true;
39
+ // } else {
40
+ // throw new Error('unexpected');
41
+ // }
42
+ });
43
+ }
44
+ find() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const key = this.createKey();
47
+ let credentials;
48
+ try {
49
+ const credentialsStr = yield this.redisClient.get(key);
50
+ if (typeof credentialsStr === 'string') {
51
+ credentials = JSON.parse(credentialsStr);
52
+ }
53
+ }
54
+ catch (error) {
55
+ // tslint:disable-next-line:no-console
56
+ console.error('credential parse error:', error);
57
+ }
58
+ return credentials;
59
+ });
60
+ }
61
+ createKey() {
62
+ return `${CredentialsRepo.KEY_PREFIX}:${this.options.scope}`;
63
+ }
64
+ }
65
+ CredentialsRepo.KEY_PREFIX = 'credentials';
66
+ exports.CredentialsRepo = CredentialsRepo;