@chevre/domain 20.2.0-alpha.8 → 20.2.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.
Files changed (140) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +37 -0
  2. package/example/src/chevre/aggregation/aggregateSystem.ts +116 -0
  3. package/example/src/chevre/attendIfNotAttended.ts +22 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +209 -0
  5. package/example/src/chevre/findByOrderNumberAndReservationId.ts +20 -0
  6. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +27 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +8 -1
  8. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
  9. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +1 -1
  10. package/example/src/chevre/migrateProjectSubscription.ts +51 -0
  11. package/example/src/chevre/ownershipInfosCsv2peopleJson.ts +2 -2
  12. package/example/src/chevre/processReserve.ts +2 -0
  13. package/example/src/chevre/searchEventIds.ts +24 -0
  14. package/example/src/chevre/searchEventTicketOffers.ts +5 -4
  15. package/example/src/chevre/searchEvents.ts +20 -41
  16. package/example/src/chevre/searchOffersByCatalog.ts +27 -0
  17. package/example/src/chevre/updateTransaction.ts +38 -0
  18. package/lib/chevre/factory/event.d.ts +2 -0
  19. package/lib/chevre/factory/event.js +2 -0
  20. package/lib/chevre/repo/action.d.ts +77 -1
  21. package/lib/chevre/repo/action.js +249 -6
  22. package/lib/chevre/repo/aggregation.d.ts +38 -0
  23. package/lib/chevre/repo/aggregation.js +68 -0
  24. package/lib/chevre/repo/assetTransaction.d.ts +32 -0
  25. package/lib/chevre/repo/assetTransaction.js +148 -0
  26. package/lib/chevre/repo/code.d.ts +13 -16
  27. package/lib/chevre/repo/code.js +33 -19
  28. package/lib/chevre/repo/creativeWork.js +13 -12
  29. package/lib/chevre/repo/event.d.ts +64 -17
  30. package/lib/chevre/repo/event.js +456 -156
  31. package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
  32. package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
  33. package/lib/chevre/repo/mongoose/model/event.js +4 -3
  34. package/lib/chevre/repo/mongoose/model/offer.js +2 -1
  35. package/lib/chevre/repo/mongoose/model/project.js +7 -1
  36. package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
  37. package/lib/chevre/repo/offer.d.ts +10 -0
  38. package/lib/chevre/repo/offer.js +47 -16
  39. package/lib/chevre/repo/order.d.ts +6 -0
  40. package/lib/chevre/repo/order.js +53 -7
  41. package/lib/chevre/repo/place.d.ts +26 -1
  42. package/lib/chevre/repo/place.js +216 -12
  43. package/lib/chevre/repo/product.d.ts +1 -0
  44. package/lib/chevre/repo/product.js +5 -0
  45. package/lib/chevre/repo/project.d.ts +7 -1
  46. package/lib/chevre/repo/project.js +15 -6
  47. package/lib/chevre/repo/reservation.d.ts +7 -8
  48. package/lib/chevre/repo/reservation.js +181 -76
  49. package/lib/chevre/repo/task.d.ts +31 -4
  50. package/lib/chevre/repo/task.js +146 -33
  51. package/lib/chevre/repo/transaction.d.ts +57 -5
  52. package/lib/chevre/repo/transaction.js +228 -34
  53. package/lib/chevre/repo/trip.js +33 -27
  54. package/lib/chevre/repository.d.ts +3 -0
  55. package/lib/chevre/repository.js +5 -1
  56. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +86 -68
  57. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +5 -8
  58. package/lib/chevre/service/aggregation/system.d.ts +100 -0
  59. package/lib/chevre/service/aggregation/system.js +409 -0
  60. package/lib/chevre/service/aggregation.d.ts +2 -0
  61. package/lib/chevre/service/aggregation.js +3 -1
  62. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
  63. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
  64. package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
  65. package/lib/chevre/service/assetTransaction/pay.js +65 -32
  66. package/lib/chevre/service/assetTransaction/registerService.js +4 -1
  67. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
  68. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
  69. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +16 -0
  70. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +84 -0
  71. package/lib/chevre/service/assetTransaction/reserve.d.ts +38 -6
  72. package/lib/chevre/service/assetTransaction/reserve.js +120 -94
  73. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  74. package/lib/chevre/service/code.d.ts +2 -3
  75. package/lib/chevre/service/delivery/factory.d.ts +1 -1
  76. package/lib/chevre/service/delivery/product/factory.js +9 -3
  77. package/lib/chevre/service/event.d.ts +2 -4
  78. package/lib/chevre/service/event.js +35 -14
  79. package/lib/chevre/service/offer/event/authorize.d.ts +4 -7
  80. package/lib/chevre/service/offer/event/authorize.js +33 -87
  81. package/lib/chevre/service/offer/event/cancel.js +0 -1
  82. package/lib/chevre/service/offer/event/factory.d.ts +3 -2
  83. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +14 -7
  84. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +95 -53
  85. package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
  86. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  87. package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
  88. package/lib/chevre/service/offer/factory.js +10 -3
  89. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +1 -0
  90. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  91. package/lib/chevre/service/offer/product.d.ts +1 -0
  92. package/lib/chevre/service/offer/product.js +7 -2
  93. package/lib/chevre/service/offer.d.ts +13 -2
  94. package/lib/chevre/service/offer.js +68 -46
  95. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +25 -27
  96. package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
  97. package/lib/chevre/service/order/placeOrder.js +16 -0
  98. package/lib/chevre/service/order/returnOrder.js +6 -4
  99. package/lib/chevre/service/order/sendOrder.js +4 -2
  100. package/lib/chevre/service/payment/any.d.ts +9 -0
  101. package/lib/chevre/service/payment/any.js +16 -1
  102. package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
  103. package/lib/chevre/service/payment/movieTicket.js +8 -2
  104. package/lib/chevre/service/product.js +5 -3
  105. package/lib/chevre/service/report/telemetry.js +1 -1
  106. package/lib/chevre/service/reserve/checkInReservation.js +2 -2
  107. package/lib/chevre/service/reserve/confirmReservation.js +7 -10
  108. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +2 -1
  109. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -1
  110. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  111. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +32 -35
  112. package/lib/chevre/service/reserve/useReservation.d.ts +0 -3
  113. package/lib/chevre/service/reserve/useReservation.js +58 -32
  114. package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
  115. package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
  116. package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
  117. package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
  118. package/lib/chevre/service/task/returnPayTransaction.js +10 -4
  119. package/lib/chevre/service/task.js +6 -9
  120. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  121. package/lib/chevre/service/transaction/orderProgramMembership/findPaymentCardPermit.d.ts +1 -1
  122. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -6
  123. package/lib/chevre/service/transaction/placeOrder.js +5 -3
  124. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -1
  125. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -2
  126. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.js +2 -11
  127. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +1 -1
  128. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +3 -8
  129. package/lib/chevre/service/transaction/placeOrderInProgress.js +92 -107
  130. package/lib/chevre/service/transaction/returnOrder.js +8 -6
  131. package/lib/chevre/settings.d.ts +2 -0
  132. package/lib/chevre/settings.js +20 -12
  133. package/package.json +3 -3
  134. package/CHANGELOG.md +0 -2030
  135. package/example/.gitignore +0 -1
  136. package/example/src/chevre/.gitignore +0 -1
  137. package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
  138. package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
  139. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.d.ts +0 -6
  140. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/confirmPay.js +0 -65
@@ -0,0 +1,37 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import * as redis from 'redis';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ // const project = { id: <string>process.env.PROJECT_ID };
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
+ const client = redis.createClient({
12
+ host: process.env.REDIS_HOST,
13
+ port: Number(process.env.REDIS_PORT),
14
+ password: process.env.REDIS_KEY
15
+ });
16
+
17
+ // const now = new Date();
18
+ await chevre.service.aggregation.event.aggregateScreeningEvent({
19
+ id: 'alb35u7m4'
20
+ })({
21
+ event: new chevre.repository.Event(mongoose.connection),
22
+ eventAvailability: new chevre.repository.itemAvailability.ScreeningEvent(client),
23
+ offer: new chevre.repository.Offer(mongoose.connection),
24
+ offerRateLimit: new chevre.repository.rateLimit.Offer(client),
25
+ place: new chevre.repository.Place(mongoose.connection),
26
+ product: new chevre.repository.Product(mongoose.connection),
27
+ project: new chevre.repository.Project(mongoose.connection),
28
+ reservation: new chevre.repository.Reservation(mongoose.connection),
29
+ task: new chevre.repository.Task(mongoose.connection)
30
+ });
31
+ }
32
+
33
+ main()
34
+ .then(() => {
35
+ console.log('success!');
36
+ })
37
+ .catch(console.error);
@@ -0,0 +1,116 @@
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 EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
8
+ const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
9
+ const AGGREGATE_CLIENT_IDS = (typeof process.env.AGGREGATE_CLIENT_IDS === 'string') ? process.env.AGGREGATE_CLIENT_IDS.split(',') : [];
10
+
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
+
14
+ const aggregationRepo = new chevre.repository.Aggregation(mongoose.connection);
15
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
16
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
17
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
18
+ const actionRepo = new chevre.repository.Action(mongoose.connection);
19
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
20
+
21
+ await chevre.service.aggregation.system.aggregatePayMovieTicketAction({
22
+ aggregationDays: AGGREGATE_DAYS,
23
+ excludedProjectId: EXCLUDED_PROJECT_ID
24
+ })({
25
+ agregation: aggregationRepo,
26
+ action: actionRepo
27
+ });
28
+ return;
29
+
30
+ await chevre.service.aggregation.system.aggregatePayTransaction({
31
+ aggregationDays: AGGREGATE_DAYS,
32
+ excludedProjectId: EXCLUDED_PROJECT_ID
33
+ })({
34
+ agregation: aggregationRepo,
35
+ assetTransaction: assetTransactionRepo
36
+ });
37
+
38
+ await chevre.service.aggregation.system.aggregateEvent({
39
+ aggregationDays: AGGREGATE_DAYS,
40
+ excludedProjectId: EXCLUDED_PROJECT_ID
41
+ })({
42
+ agregation: aggregationRepo,
43
+ event: eventRepo
44
+ });
45
+
46
+ await chevre.service.aggregation.system.aggregateTask({
47
+ aggregationDays: AGGREGATE_DAYS,
48
+ excludedProjectId: EXCLUDED_PROJECT_ID
49
+ })({
50
+ agregation: aggregationRepo,
51
+ task: taskRepo
52
+ });
53
+
54
+ await chevre.service.aggregation.system.aggregateReserveTransaction({
55
+ aggregationDays: AGGREGATE_DAYS,
56
+ excludedProjectId: EXCLUDED_PROJECT_ID
57
+ })({
58
+ agregation: aggregationRepo,
59
+ assetTransaction: assetTransactionRepo
60
+ });
61
+
62
+ await chevre.service.aggregation.system.aggregatePlaceOrder({
63
+ aggregationDays: AGGREGATE_DAYS,
64
+ excludedProjectId: EXCLUDED_PROJECT_ID,
65
+ clientIds: AGGREGATE_CLIENT_IDS
66
+ })({
67
+ agregation: aggregationRepo,
68
+ transaction: transactionRepo
69
+ });
70
+
71
+ await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
72
+ aggregationDays: AGGREGATE_DAYS,
73
+ excludedProjectId: EXCLUDED_PROJECT_ID
74
+ })({
75
+ agregation: aggregationRepo,
76
+ action: actionRepo
77
+ });
78
+
79
+ await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
80
+ aggregationDays: AGGREGATE_DAYS,
81
+ excludedProjectId: EXCLUDED_PROJECT_ID
82
+ })({
83
+ agregation: aggregationRepo,
84
+ action: actionRepo
85
+ });
86
+
87
+ await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
88
+ aggregationDays: AGGREGATE_DAYS,
89
+ excludedProjectId: EXCLUDED_PROJECT_ID
90
+ })({
91
+ agregation: aggregationRepo,
92
+ action: actionRepo
93
+ });
94
+
95
+ await chevre.service.aggregation.system.aggregateUseAction({
96
+ aggregationDays: AGGREGATE_DAYS,
97
+ excludedProjectId: EXCLUDED_PROJECT_ID
98
+ })({
99
+ agregation: aggregationRepo,
100
+ action: actionRepo
101
+ });
102
+
103
+ await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
104
+ aggregationDays: AGGREGATE_DAYS,
105
+ excludedProjectId: EXCLUDED_PROJECT_ID
106
+ })({
107
+ agregation: aggregationRepo,
108
+ action: actionRepo
109
+ });
110
+ }
111
+
112
+ main()
113
+ .then(() => {
114
+ console.log('success!');
115
+ })
116
+ .catch(console.error);
@@ -0,0 +1,22 @@
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);
8
+
9
+ const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
10
+
11
+ const reservation = await reservationRepo.attendIfNotAttended(
12
+ {
13
+ id: '864318975593476-0',
14
+ now: new Date()
15
+ }
16
+ );
17
+ console.log('event found', reservation);
18
+ }
19
+
20
+ main()
21
+ .then(console.log)
22
+ .catch(console.error);
@@ -0,0 +1,209 @@
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
+ const PROJECT_ID = String(process.env.PROJECT_ID);
8
+ const filterName: string = 'eventIdentifier';
9
+
10
+ // tslint:disable-next-line:max-func-body-length
11
+ async function main() {
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
+
14
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
15
+
16
+ const result = await eventRepo.createManyIfNotExist<chevre.factory.eventType.ScreeningEvent>([
17
+ {
18
+ attributes: {
19
+ additionalProperty: [{
20
+ name: filterName,
21
+ value: '20230201143000-03'
22
+ }],
23
+ project: {
24
+ id: PROJECT_ID,
25
+ typeOf: chevre.factory.organizationType.Project
26
+ },
27
+ typeOf: chevre.factory.eventType.ScreeningEvent,
28
+ doorTime: moment('2023-02-01T05:00:00.000Z')
29
+ .toDate(),
30
+ startDate: moment('2023-02-01T05:00:00.000Z')
31
+ .toDate(),
32
+ endDate: moment('2023-02-01T06:00:00.000Z')
33
+ .toDate(),
34
+ workPerformed: {
35
+ typeOf: chevre.factory.creativeWorkType.Movie,
36
+ identifier: '1622100',
37
+ id: '5bfb841d5a78d7948369980a',
38
+ name: {
39
+ en: 'Pet',
40
+ ja: 'ペット'
41
+ },
42
+ duration: 'PT2H3M'
43
+ },
44
+ location: {
45
+ typeOf: chevre.factory.placeType.ScreeningRoom,
46
+ branchCode: '10',
47
+ name: {
48
+ ja: 'シネマ1',
49
+ en: 'CINEMA1'
50
+ },
51
+ address: {
52
+ ja: '7階',
53
+ en: '7F'
54
+ }
55
+ },
56
+ superEvent: {
57
+ typeOf: chevre.factory.eventType.ScreeningEventSeries,
58
+ project: {
59
+ typeOf: chevre.factory.organizationType.Project,
60
+ id: 'cinerino'
61
+ },
62
+ id: '7k9ayl8hc',
63
+ videoFormat: [
64
+ {
65
+ typeOf: '2D',
66
+ name: '2D'
67
+ }
68
+ ],
69
+ soundFormat: [],
70
+ workPerformed: {
71
+ typeOf: chevre.factory.creativeWorkType.Movie,
72
+ identifier: '1622100',
73
+ id: '5bfb841d5a78d7948369980a',
74
+ name: {
75
+ en: 'Pet',
76
+ ja: 'ペット'
77
+ },
78
+ duration: 'PT2H3M'
79
+ },
80
+ location: {
81
+ typeOf: chevre.factory.placeType.MovieTheater,
82
+ id: '5bfb841d5a78d7948369979a',
83
+ branchCode: '118',
84
+ name: {
85
+ ja: 'シネモーション赤坂 ',
86
+ en: 'CineMotion Akasaka'
87
+ },
88
+ kanaName: 'シネモーションアカサカ'
89
+ },
90
+ kanaName: 'ペットカナタイトル',
91
+ name: {
92
+ en: 'PetPetPetPet',
93
+ ja: 'ペット'
94
+ },
95
+ additionalProperty: [
96
+ {
97
+ name: 'sortNumber',
98
+ value: '99'
99
+ }
100
+ ],
101
+ startDate: moment('2020-03-31T15:00:00.000Z')
102
+ .toDate(),
103
+ endDate: moment('2034-12-01T15:00:00.000Z')
104
+ .toDate(),
105
+ description: {
106
+ en: 'english description',
107
+ ja: 'ムビチケ検証用のイベントです。'
108
+ },
109
+ headline: {
110
+ en: 'headlineheadlineheadlineheadlineheadlineheadlineheadline',
111
+ ja: 'サブタイトルkanaName'
112
+ },
113
+ subtitleLanguage: {
114
+ typeOf: 'Language',
115
+ name: 'Japanese'
116
+ }
117
+ },
118
+ name: {
119
+ en: 'PetPetPetPet',
120
+ ja: 'ペット'
121
+ },
122
+ eventStatus: chevre.factory.eventStatusType.EventScheduled,
123
+ offers: {
124
+ typeOf: chevre.factory.offerType.Offer,
125
+ priceCurrency: chevre.factory.priceCurrency.JPY,
126
+ availabilityEnds: moment('2023-02-01T01:20:00.000Z')
127
+ .toDate(),
128
+ availabilityStarts: moment('2023-01-30T15:00:00.000Z')
129
+ .toDate(),
130
+ eligibleQuantity: {
131
+ typeOf: 'QuantitativeValue',
132
+ unitCode: chevre.factory.unitCode.C62,
133
+ maxValue: 6,
134
+ value: 1
135
+ },
136
+ itemOffered: {
137
+ id: '6308580bdef565000a9aa1fd',
138
+ name: {
139
+ ja: '通常興行カタログ'
140
+ },
141
+ serviceOutput: {
142
+ typeOf: chevre.factory.reservationType.EventReservation,
143
+ reservedTicket: {
144
+ typeOf: 'Ticket',
145
+ ticketedSeat: {
146
+ typeOf: chevre.factory.placeType.Seat
147
+ }
148
+ }
149
+ },
150
+ typeOf: chevre.factory.product.ProductType.EventService,
151
+ availableChannel: {
152
+ typeOf: 'ServiceChannel',
153
+ serviceLocation: {
154
+ typeOf: chevre.factory.placeType.ScreeningRoom,
155
+ branchCode: '10',
156
+ name: {
157
+ ja: 'シネマ1',
158
+ en: 'CINEMA1'
159
+ },
160
+ containedInPlace: {
161
+ typeOf: chevre.factory.placeType.MovieTheater,
162
+ id: '5bfb841d5a78d7948369979a',
163
+ branchCode: '118',
164
+ name: {
165
+ ja: 'シネモーション赤坂 ',
166
+ en: 'CineMotion Akasaka'
167
+ }
168
+ }
169
+ }
170
+ },
171
+ serviceType: {
172
+ codeValue: '0001',
173
+ id: '5e3361d01dc1ef1a20dd8737',
174
+ inCodeSet: {
175
+ typeOf: 'CategoryCodeSet',
176
+ identifier: chevre.factory.categoryCode.CategorySetIdentifier.ServiceType
177
+ },
178
+ project: {
179
+ typeOf: chevre.factory.organizationType.Project,
180
+ id: 'cinerino'
181
+ },
182
+ typeOf: 'CategoryCode'
183
+ }
184
+ },
185
+ validFrom: moment('2023-01-29T15:00:00.000Z')
186
+ .toDate(),
187
+ validThrough: moment('2023-02-01T01:20:00.000Z')
188
+ .toDate(),
189
+ seller: {
190
+ typeOf: chevre.factory.organizationType.Corporation,
191
+ id: '59d20831e53ebc2b4e774466',
192
+ name: {
193
+ ja: 'シネモーション赤坂',
194
+ en: 'CineMotion Akasaka'
195
+ },
196
+ makesOffer: []
197
+ }
198
+ }
199
+ },
200
+ filter: { name: filterName }
201
+ }
202
+ ]);
203
+ console.log(result);
204
+ console.log('upsertedIds:', (Array.isArray(result?.result.upserted)) ? result?.result.upserted.map((u: any) => u._id) : []);
205
+ }
206
+
207
+ main()
208
+ .then(console.log)
209
+ .catch(console.error);
@@ -0,0 +1,20 @@
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);
8
+
9
+ const orderRepo = new chevre.repository.Order(mongoose.connection);
10
+
11
+ const order = await orderRepo.findByOrderNumberAndReservationId({
12
+ orderNumber: 'CIN9-4783801-1618274',
13
+ reservationId: '139787058570943-0'
14
+ });
15
+ console.log('order found', order);
16
+ }
17
+
18
+ main()
19
+ .then()
20
+ .catch(console.error);
@@ -0,0 +1,27 @@
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);
8
+
9
+ const placeRepo = new chevre.repository.Place(mongoose.connection);
10
+
11
+ const event = await placeRepo.findScreeningRoomsByBranchCode({
12
+ branchCode: {
13
+ $eq: '20'
14
+ },
15
+ containedInPlace: {
16
+ id: {
17
+ $eq: '5bfb841d5a78d7948369979a'
18
+ }
19
+ }
20
+ });
21
+ console.log('room found', event);
22
+
23
+ }
24
+
25
+ main()
26
+ .then(console.log)
27
+ .catch(console.error);
@@ -14,6 +14,7 @@ async function main() {
14
14
  const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
15
15
  const eventRepo = new chevre.repository.Event(mongoose.connection);
16
16
  const placeRepo = new chevre.repository.Place(mongoose.connection);
17
+ const sellerRepo = new chevre.repository.Seller(mongoose.connection);
17
18
 
18
19
  await chevre.service.event.importFromCOA({
19
20
  project: {
@@ -28,7 +29,13 @@ async function main() {
28
29
  .toDate(),
29
30
  saveMovieTheater: false,
30
31
  saveScreeningEventSeries: false
31
- })({ action: actionRepo, categoryCode: categoryCodeRepo, event: eventRepo, place: placeRepo });
32
+ })({
33
+ action: actionRepo,
34
+ categoryCode: categoryCodeRepo,
35
+ event: eventRepo,
36
+ place: placeRepo,
37
+ seller: sellerRepo
38
+ });
32
39
  console.log('imported');
33
40
  }
34
41
 
@@ -21,7 +21,8 @@ async function main() {
21
21
  typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
22
22
  startDate: {
23
23
  $gte: moment()
24
- .add(-1, 'month')
24
+ // tslint:disable-next-line:no-magic-numbers
25
+ .add(-6, 'months')
25
26
  .toDate()
26
27
  }
27
28
  // _id: { $eq: 'al6aff83w' }
@@ -55,7 +55,7 @@ async function main() {
55
55
  let updateCount = 0;
56
56
  await cursor.eachAsync(async (doc) => {
57
57
  i += 1;
58
- const ownershipInfo = <chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IPermit>>doc.toObject();
58
+ const ownershipInfo = <chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IPermitAsGood>>doc.toObject();
59
59
 
60
60
  const owner = <chevre.factory.person.IPerson>ownershipInfo.ownedBy;
61
61
  let iss =
@@ -0,0 +1,51 @@
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
+ // tslint:disable-next-line:max-func-body-length
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const projectRepo = new chevre.repository.Project(mongoose.connection);
12
+
13
+ const cursor = projectRepo.getCursor(
14
+ {
15
+ },
16
+ {
17
+ // _id: 1,
18
+ }
19
+ );
20
+ console.log('projects found');
21
+
22
+ let i = 0;
23
+ let updateCount = 0;
24
+ // tslint:disable-next-line:max-func-body-length
25
+ await cursor.eachAsync(async (doc) => {
26
+ i += 1;
27
+ const project: chevre.factory.project.IProject = doc.toObject();
28
+
29
+ const useEventServiceAsProduct = project.subscription?.useEventServiceAsProduct;
30
+ const alreadyMigrated = useEventServiceAsProduct === true;
31
+
32
+ if (alreadyMigrated) {
33
+ console.log('already migrated.', project.id, i);
34
+ } else {
35
+ console.log(
36
+ 'updating product...', project.id, i);
37
+ await projectRepo.findByIdAndIUpdate({
38
+ id: project.id,
39
+ subscription: { useEventServiceAsProduct: true }
40
+ });
41
+ updateCount += 1;
42
+ console.log('updated...', project.id, i);
43
+ }
44
+ });
45
+ console.log(i, 'projects checked');
46
+ console.log(updateCount, 'projects updated');
47
+ }
48
+
49
+ main()
50
+ .then()
51
+ .catch(console.error);
@@ -132,7 +132,7 @@ function findAccount(params: {
132
132
  customer: { id: string };
133
133
  now: Date;
134
134
  }) {
135
- return async (): Promise<chevre.factory.ownershipInfo.IPermit | undefined> => {
135
+ return async (): Promise<chevre.factory.ownershipInfo.IPermitAsGood | undefined> => {
136
136
  const ownershipInfoRepo = new chevre.repository.OwnershipInfo(mongoose.connection);
137
137
 
138
138
  // let accountOwnershipInfos = await search({
@@ -171,7 +171,7 @@ function findAccount(params: {
171
171
  // throw new domain.factory.errors.NotFound('accountOwnershipInfos');
172
172
  }
173
173
 
174
- return <chevre.factory.ownershipInfo.IPermit>ownershipInfos[0].typeOfGood;
174
+ return <chevre.factory.ownershipInfo.IPermitAsGood>ownershipInfos[0].typeOfGood;
175
175
  };
176
176
  }
177
177
 
@@ -63,6 +63,8 @@ async function main() {
63
63
  ],
64
64
  reservationFor: { id: 'ckuz8uj0c' }
65
65
  },
66
+ validateEvent: false,
67
+ validateEventOfferPeriod: false,
66
68
  validateAppliesToMovieTicket: true
67
69
  })({
68
70
  eventAvailability: itemAvailabilityRepo,
@@ -0,0 +1,24 @@
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);
10
+
11
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
12
+
13
+ const ids = await eventRepo.searchIds({
14
+ typeOf: chevre.factory.eventType.ScreeningEvent,
15
+ project: { id: { $eq: PROJECT_ID } },
16
+ id: { $in: ['al6afe7ad', 'al6afe7ae'] }
17
+ });
18
+ console.log(ids);
19
+ console.log(ids.length);
20
+ }
21
+
22
+ main()
23
+ .then(console.log)
24
+ .catch(console.error);
@@ -21,9 +21,11 @@ async function main() {
21
21
  const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
22
22
  const productRepo = new chevre.repository.Product(mongoose.connection);
23
23
 
24
- const offers = await chevre.service.offer.event.searchEventTicketOffers({
24
+ const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
25
25
  event: { id: 'al9ew43f5' },
26
- onlyValid: true
26
+ onlyValid: true,
27
+ sort: true,
28
+ validateOfferRateLimit: true
27
29
  // ...(typeof sellerId === 'string') ? { seller: { id: sellerId } } : undefined,
28
30
  // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
29
31
  })({
@@ -33,8 +35,7 @@ async function main() {
33
35
  priceSpecification: priceSpecificationRepo,
34
36
  product: productRepo
35
37
  });
36
- // console.log(offers);
37
- console.log(offers.length);
38
+ console.log(ticketOffers.length);
38
39
  }
39
40
 
40
41
  main()