@chevre/domain 22.6.0-alpha.4 → 22.6.0-alpha.41

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 (187) hide show
  1. package/example/src/chevre/aggregateAllEvents2.ts +0 -12
  2. package/example/src/chevre/aggregation/aggregateOrderOnSystem.ts +40 -0
  3. package/example/src/chevre/createEventBySchedule.ts +60 -0
  4. package/example/src/chevre/findSchedule.ts +43 -0
  5. package/example/src/chevre/findSetting.ts +90 -0
  6. package/example/src/chevre/projectEventFieldsById.ts +23 -0
  7. package/example/src/chevre/reIndex.ts +24 -0
  8. package/example/src/chevre/retryTasks.ts +6 -4
  9. package/example/src/chevre/unsetUnnecessaryFields.ts +34 -16
  10. package/lib/chevre/credentials.js +0 -13
  11. package/lib/chevre/repo/action.d.ts +11 -5
  12. package/lib/chevre/repo/credentials.d.ts +19 -0
  13. package/lib/chevre/repo/credentials.js +70 -0
  14. package/lib/chevre/repo/event.d.ts +0 -5
  15. package/lib/chevre/repo/event.js +0 -26
  16. package/lib/chevre/repo/interface.d.ts +25 -0
  17. package/lib/chevre/repo/interface.js +62 -0
  18. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +5 -21
  19. package/lib/chevre/repo/mongoose/schemas/aggregation.js +12 -0
  20. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +36 -11
  21. package/lib/chevre/repo/mongoose/schemas/civicStructure.js +9 -1
  22. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +9 -1
  23. package/lib/chevre/repo/mongoose/schemas/interface.d.ts +11 -0
  24. package/lib/chevre/repo/mongoose/schemas/interface.js +55 -0
  25. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +1 -1
  26. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +29 -25
  27. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +1 -1
  28. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +21 -15
  29. package/lib/chevre/repo/mongoose/schemas/place.js +1 -1
  30. package/lib/chevre/repo/mongoose/schemas/schedule.d.ts +10 -0
  31. package/lib/chevre/repo/mongoose/schemas/schedule.js +51 -0
  32. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +33 -0
  33. package/lib/chevre/repo/mongoose/schemas/setting.js +56 -0
  34. package/lib/chevre/repo/offerCatalog.d.ts +5 -1
  35. package/lib/chevre/repo/offerCatalog.js +6 -0
  36. package/lib/chevre/repo/offerCatalogItem.d.ts +5 -1
  37. package/lib/chevre/repo/offerCatalogItem.js +6 -0
  38. package/lib/chevre/repo/place/movieTheater.d.ts +0 -6
  39. package/lib/chevre/repo/place/movieTheater.js +0 -14
  40. package/lib/chevre/repo/schedule.d.ts +22 -0
  41. package/lib/chevre/repo/schedule.js +54 -0
  42. package/lib/chevre/repo/setting.d.ts +50 -0
  43. package/lib/chevre/repo/setting.js +60 -0
  44. package/lib/chevre/repository.d.ts +20 -0
  45. package/lib/chevre/repository.js +54 -2
  46. package/lib/chevre/service/aggregation/event/aggregateOffers.js +44 -29
  47. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +10 -4
  48. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +17 -9
  49. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
  50. package/lib/chevre/service/assetTransaction/pay.js +9 -4
  51. package/lib/chevre/service/assetTransaction/reserve/cancel.d.ts +2 -0
  52. package/lib/chevre/service/assetTransaction/reserve/cancel.js +4 -2
  53. package/lib/chevre/service/assetTransaction/reserve/confirm.d.ts +2 -0
  54. package/lib/chevre/service/assetTransaction/reserve/confirm.js +1 -1
  55. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -0
  56. package/lib/chevre/service/assetTransaction/reserve/start.js +6 -4
  57. package/lib/chevre/service/event.d.ts +1 -2
  58. package/lib/chevre/service/event.js +1 -3
  59. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -0
  60. package/lib/chevre/service/offer/event/authorize.d.ts +2 -0
  61. package/lib/chevre/service/offer/event/voidTransaction/processVoidTransaction4chevre.d.ts +2 -0
  62. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  63. package/lib/chevre/service/offer/event/voidTransactionByActionId.d.ts +2 -0
  64. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +3 -0
  65. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +1 -1
  66. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.d.ts +2 -2
  67. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +5 -2
  68. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.d.ts +3 -2
  69. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered.js +6 -2
  70. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +2 -2
  71. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +5 -2
  72. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.d.ts +3 -2
  73. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially.js +6 -2
  74. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.d.ts +2 -2
  75. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +5 -2
  76. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.d.ts +2 -0
  77. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing.js +2 -1
  78. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +2 -2
  79. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +5 -2
  80. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.d.ts +3 -2
  81. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned.js +6 -2
  82. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +2 -2
  83. package/lib/chevre/service/order/onOrderUpdated/factory.js +5 -2
  84. package/lib/chevre/service/order/onOrderUpdated.d.ts +3 -2
  85. package/lib/chevre/service/order/onOrderUpdated.js +8 -2
  86. package/lib/chevre/service/order/payOrder.d.ts +2 -0
  87. package/lib/chevre/service/order/placeOrder.d.ts +2 -0
  88. package/lib/chevre/service/order/returnOrder.d.ts +3 -2
  89. package/lib/chevre/service/order/returnOrder.js +7 -5
  90. package/lib/chevre/service/order/sendOrder.d.ts +2 -0
  91. package/lib/chevre/service/order/sendOrder.js +5 -3
  92. package/lib/chevre/service/payment/any/onRefund.js +30 -17
  93. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +2 -1
  94. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +26 -17
  95. package/lib/chevre/service/payment/any.d.ts +5 -1
  96. package/lib/chevre/service/payment/any.js +31 -12
  97. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +6 -1
  98. package/lib/chevre/service/payment/movieTicket/authorize.js +4 -2
  99. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +2 -0
  100. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +9 -12
  101. package/lib/chevre/service/payment/movieTicket/factory.js +12 -16
  102. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +2 -0
  103. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +2 -1
  104. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.d.ts +2 -0
  105. package/lib/chevre/service/payment/movieTicket/processPurchaseNumberAuth.js +2 -1
  106. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +2 -0
  107. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +2 -1
  108. package/lib/chevre/service/payment/movieTicket/validation.d.ts +5 -1
  109. package/lib/chevre/service/payment/movieTicket/validation.js +47 -40
  110. package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +2 -0
  111. package/lib/chevre/service/payment.d.ts +13 -4
  112. package/lib/chevre/service/payment.js +15 -11
  113. package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -3
  114. package/lib/chevre/service/reserve/cancelReservation.js +8 -4
  115. package/lib/chevre/service/reserve/checkInReservation.d.ts +3 -8
  116. package/lib/chevre/service/reserve/checkInReservation.js +17 -30
  117. package/lib/chevre/service/reserve/confirmReservation.d.ts +3 -2
  118. package/lib/chevre/service/reserve/confirmReservation.js +4 -2
  119. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.d.ts +3 -2
  120. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +8 -2
  121. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -2
  122. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +8 -2
  123. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +3 -2
  124. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +9 -4
  125. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +3 -2
  126. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +8 -2
  127. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +7 -3
  128. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +28 -13
  129. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.d.ts +3 -2
  130. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +8 -2
  131. package/lib/chevre/service/reserve/useReservation.d.ts +3 -2
  132. package/lib/chevre/service/reserve/useReservation.js +11 -7
  133. package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
  134. package/lib/chevre/service/task/acceptCOAOffer.js +27 -4
  135. package/lib/chevre/service/task/aggregateOnSystem.js +4 -4
  136. package/lib/chevre/service/task/authorizePayment.js +9 -0
  137. package/lib/chevre/service/task/cancelPendingReservation.js +12 -14
  138. package/lib/chevre/service/task/cancelReservation.js +12 -14
  139. package/lib/chevre/service/task/checkMovieTicket.js +12 -3
  140. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +3 -1
  141. package/lib/chevre/service/task/confirmReserveTransaction.js +22 -6
  142. package/lib/chevre/service/task/createEvent/createEvent.d.ts +24 -0
  143. package/lib/chevre/service/task/createEvent/createEvent.js +43 -0
  144. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +24 -0
  145. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +364 -0
  146. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +13 -0
  147. package/lib/chevre/service/{event/createEvent.js → task/createEvent/createEventSeries.js} +4 -4
  148. package/lib/chevre/service/task/createEvent.js +14 -4
  149. package/lib/chevre/service/task/handleNotification.js +4 -3
  150. package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +2 -2
  151. package/lib/chevre/service/task/importEventCapacitiesFromCOA.js +14 -5
  152. package/lib/chevre/service/task/importEventsFromCOA.d.ts +2 -2
  153. package/lib/chevre/service/task/importEventsFromCOA.js +14 -5
  154. package/lib/chevre/service/task/importOffersFromCOA.d.ts +2 -2
  155. package/lib/chevre/service/task/importOffersFromCOA.js +15 -6
  156. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +2 -0
  157. package/lib/chevre/service/task/onAuthorizationCreated.js +22 -37
  158. package/lib/chevre/service/task/onOrderPaymentCompleted.js +2 -0
  159. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.d.ts +3 -3
  160. package/lib/chevre/service/task/onResourceUpdated/onAggregateOfferUpdated.js +7 -3
  161. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +3 -2
  162. package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +8 -3
  163. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +4 -3
  164. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +7 -3
  165. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -2
  166. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +5 -2
  167. package/lib/chevre/service/task/onResourceUpdated.js +62 -32
  168. package/lib/chevre/service/task/pay.js +27 -2
  169. package/lib/chevre/service/task/placeOrder.js +2 -0
  170. package/lib/chevre/service/task/refund.js +10 -0
  171. package/lib/chevre/service/task/reserve.js +6 -2
  172. package/lib/chevre/service/task/returnOrder.js +6 -2
  173. package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
  174. package/lib/chevre/service/task/returnReserveTransaction.js +21 -7
  175. package/lib/chevre/service/task/sendOrder.js +2 -0
  176. package/lib/chevre/service/task/useReservation.js +6 -2
  177. package/lib/chevre/service/task/voidPayment.js +14 -1
  178. package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
  179. package/lib/chevre/service/task/voidReserveTransaction.js +21 -6
  180. package/lib/chevre/service/task.d.ts +0 -5
  181. package/lib/chevre/service/task.js +6 -0
  182. package/lib/chevre/settings/aggregation.d.ts +4 -2
  183. package/lib/chevre/settings/aggregation.js +1 -4
  184. package/lib/chevre/settings.d.ts +21 -50
  185. package/lib/chevre/settings.js +8 -4
  186. package/package.json +5 -5
  187. package/lib/chevre/service/event/createEvent.d.ts +0 -13
@@ -47,15 +47,6 @@ export async function aggregateScreeningEvent() {
47
47
  onEventChanged: {
48
48
  informEvent: []
49
49
  },
50
- onOrderStatusChanged: {
51
- informOrder: []
52
- },
53
- onResourceUpdated: {
54
- informResource: []
55
- },
56
- onReservationStatusChanged: {
57
- informReservation: []
58
- },
59
50
  notification: {
60
51
  timeout: 1000,
61
52
  useFetchAPI: true,
@@ -64,9 +55,6 @@ export async function aggregateScreeningEvent() {
64
55
  },
65
56
  userPoolIdOld: '',
66
57
  userPoolIdNew: '',
67
- // useAggregateEntranceGateProjects: [],
68
- // useAggregateOfferProjects: [],
69
- // useOfferRateLimitProjects: [],
70
58
  defaultSenderEmail: 'test@example.com',
71
59
  deliverOrderLimit: 1,
72
60
  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);
@@ -0,0 +1,60 @@
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
+ notification: {
31
+ timeout: 1000,
32
+ useFetchAPI: true,
33
+ secretKey: 'xx',
34
+ headerIdentifier: 'xx'
35
+ },
36
+ userPoolIdOld: '',
37
+ userPoolIdNew: '',
38
+ defaultSenderEmail: 'test@example.com',
39
+ deliverOrderLimit: 1,
40
+ transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
41
+ abortedTasksWithoutReport: [],
42
+ coa: { timeout: 1000 },
43
+ gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
44
+ movieticketReserve: { timeout: 1000, timeoutCheck: 1000, minIntervalBetweenPayAndRefund: 0 },
45
+ numTryConfirmReserveTransaction: 10,
46
+ useAssetTransactionSyncProcessing: true,
47
+ useExperimentalFeature: false
48
+ })
49
+ },
50
+ {
51
+ executeById: true,
52
+ executeByName: false
53
+ }
54
+ );
55
+ console.log('success!');
56
+ }
57
+
58
+ main()
59
+ .then(console.log)
60
+ .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,90 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ const informOrderUrls = (typeof process.env.INFORM_ORDER_URL === 'string')
7
+ ? process.env.INFORM_ORDER_URL.split(' ')
8
+ : [];
9
+ const informReservationUrls = (typeof process.env.INFORM_RESERVATION_URL === 'string')
10
+ ? process.env.INFORM_RESERVATION_URL.split(' ')
11
+ : [];
12
+ const informResourceUrls = (typeof process.env.INFORM_RESOURCE_URL === 'string')
13
+ ? process.env.INFORM_RESOURCE_URL.split(',')
14
+ : [];
15
+ async function main() {
16
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
17
+
18
+ const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
19
+
20
+ const result = await settingRepo.findOne({}, ['onOrderStatusChanged', 'onReservationStatusChanged', 'onResourceUpdated']);
21
+ // tslint:disable-next-line:no-null-keyword
22
+ console.dir(result, { depth: null });
23
+
24
+ if (result === null) {
25
+ if (informOrderUrls.length > 0) {
26
+ await settingRepo.saveOne({
27
+ project: { id: '*', typeOf: chevre.factory.organizationType.Project },
28
+ onOrderStatusChanged: {
29
+ informOrder: informOrderUrls
30
+ .filter((url) => url.length > 0)
31
+ .map((url) => {
32
+ return {
33
+ recipient: {
34
+ typeOf: chevre.factory.creativeWorkType.WebApplication,
35
+ name: 'Aggregation Service',
36
+ url
37
+ }
38
+ };
39
+ })
40
+ }
41
+ });
42
+ console.log('saved');
43
+ }
44
+ } else {
45
+ const updateResult = await settingRepo.updateByProject(
46
+ { project: { id: { $eq: '*' } } },
47
+ {
48
+ ...(informReservationUrls.length > 0)
49
+ ? {
50
+ onReservationStatusChanged: {
51
+ informReservation: informReservationUrls
52
+ .filter((url) => url.length > 0)
53
+ .map((url) => {
54
+ return {
55
+ recipient: {
56
+ typeOf: chevre.factory.creativeWorkType.WebApplication,
57
+ name: 'Aggregation Service',
58
+ url
59
+ }
60
+ };
61
+ })
62
+ }
63
+ }
64
+ : undefined,
65
+ ...(informResourceUrls.length > 0)
66
+ ? {
67
+ onResourceUpdated: {
68
+ informResource: informResourceUrls
69
+ .filter((url) => url.length > 0)
70
+ .map((url) => {
71
+ return {
72
+ recipient: {
73
+ typeOf: chevre.factory.creativeWorkType.WebApplication,
74
+ name: 'Global HUB',
75
+ url
76
+ }
77
+ };
78
+ })
79
+ }
80
+ }
81
+ : undefined
82
+ }
83
+ );
84
+ console.log('updated', updateResult);
85
+ }
86
+ }
87
+
88
+ main()
89
+ .then(console.log)
90
+ .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,70 @@
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
+ if (typeof this.options.expireInSeconds !== 'number' || this.options.expireInSeconds <= 0) {
24
+ // expireInSeconds:0に設定すれば保管しない
25
+ return;
26
+ }
27
+ // const { access_token, expired_at } = credentials;
28
+ if (typeof credentials.access_token !== 'string') {
29
+ throw new Error('access_token must be string');
30
+ }
31
+ // if (typeof credentials.expired_at !== 'string') {
32
+ // throw new Error('expired_at must be string');
33
+ // }
34
+ const key = this.createKey();
35
+ const value = JSON.stringify(credentials);
36
+ const multi = this.redisClient.multi();
37
+ yield multi.set(key, value)
38
+ // .expireAt(key, Number(expired_at))
39
+ .expire(key, this.options.expireInSeconds)
40
+ .exec();
41
+ // if (Array.isArray(results) && (results[0] === 1 || (<any>results)[0] === true)) {
42
+ // return true;
43
+ // } else {
44
+ // throw new Error('unexpected');
45
+ // }
46
+ });
47
+ }
48
+ find() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const key = this.createKey();
51
+ let credentials;
52
+ try {
53
+ const credentialsStr = yield this.redisClient.get(key);
54
+ if (typeof credentialsStr === 'string') {
55
+ credentials = JSON.parse(credentialsStr);
56
+ }
57
+ }
58
+ catch (error) {
59
+ // tslint:disable-next-line:no-console
60
+ console.error('credential parse error:', error);
61
+ }
62
+ return credentials;
63
+ });
64
+ }
65
+ createKey() {
66
+ return `${CredentialsRepo.KEY_PREFIX}:${this.options.scope}`;
67
+ }
68
+ }
69
+ CredentialsRepo.KEY_PREFIX = 'credentials';
70
+ exports.CredentialsRepo = CredentialsRepo;
@@ -294,11 +294,6 @@ export declare class EventRepo {
294
294
  };
295
295
  };
296
296
  }): Promise<import("mongodb").DeleteResult>;
297
- /**
298
- * 旧施設コンテンツ廃止専用メソッド
299
- * 2024-09-11~
300
- */
301
- deleteOldEventSeries(): Promise<import("mongodb").DeleteResult>;
302
297
  deleteManyEventsEndedByProject(params: {
303
298
  typeOf: {
304
299
  $in: AvailableEventType[];
@@ -934,32 +934,6 @@ class EventRepo {
934
934
  .exec();
935
935
  });
936
936
  }
937
- /**
938
- * 旧施設コンテンツ廃止専用メソッド
939
- * 2024-09-11~
940
- */
941
- deleteOldEventSeries() {
942
- return __awaiter(this, void 0, void 0, function* () {
943
- return this.eventModel.deleteMany({
944
- typeOf: { $eq: factory.eventType.ScreeningEventSeries }
945
- })
946
- .exec();
947
- });
948
- }
949
- // public async deleteManyEndedByIds(params: {
950
- // typeOf: { $in: factory.eventType[] };
951
- // project: { id: string };
952
- // ids: string[];
953
- // endDate: { $lte: Date };
954
- // }) {
955
- // return this.eventModel.deleteMany({
956
- // typeOf: { $in: params.typeOf.$in },
957
- // 'project.id': { $eq: params.project.id },
958
- // _id: { $in: params.ids },
959
- // endDate: { $lte: params.endDate.$lte }
960
- // })
961
- // .exec();
962
- // }
963
937
  deleteManyEventsEndedByProject(params) {
964
938
  return __awaiter(this, void 0, void 0, function* () {
965
939
  return this.eventModel.deleteMany({
@@ -0,0 +1,25 @@
1
+ import type { Connection } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ /**
4
+ * IFリポジトリ
5
+ */
6
+ export declare class InterfaceRepo {
7
+ private readonly interfaceModel;
8
+ constructor(connection: Connection);
9
+ saveOne(params: factory.service.webAPI.IServiceWithChannel): Promise<void>;
10
+ findOne(filter: {
11
+ id?: {
12
+ $eq?: string;
13
+ };
14
+ project?: {
15
+ id?: {
16
+ $eq?: string;
17
+ };
18
+ };
19
+ }): Promise<(factory.service.webAPI.IServiceWithChannel & {
20
+ id: string;
21
+ }) | null>;
22
+ findOneId(): Promise<(Pick<factory.service.webAPI.IServiceWithChannel, 'project'> & {
23
+ id: string;
24
+ }) | null>;
25
+ }